All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Bakker <xc-racer2@live.ca>
To: sre@kernel.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org, robh+dt@kernel.org,
	devicetree@vger.kernel.org
Cc: Jonathan Bakker <xc-racer2@live.ca>
Subject: [PATCH 1/3] power: supply: max17040: Correct voltage reading
Date: Mon,  4 May 2020 15:12:58 -0700	[thread overview]
Message-ID: <BN6PR04MB0660DA4AED9364441DA33094A3A60@BN6PR04MB0660.namprd04.prod.outlook.com> (raw)
In-Reply-To: <20200504221300.3153-1-xc-racer2@live.ca>

According to the datasheet available at (1), the bottom four
bits are always zero and the actual voltage is 1.25x this value
in mV.  Since the kernel API specifies that voltages should be in
uV, it should report 1250x the shifted value.

1) https://datasheets.maximintegrated.com/en/ds/MAX17040-MAX17041.pdf

Signed-off-by: Jonathan Bakker <xc-racer2@live.ca>
---
 drivers/power/supply/max17040_battery.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/power/supply/max17040_battery.c b/drivers/power/supply/max17040_battery.c
index 8a1f0ee493aa..48aa44665e2f 100644
--- a/drivers/power/supply/max17040_battery.c
+++ b/drivers/power/supply/max17040_battery.c
@@ -126,7 +126,7 @@ static void max17040_get_vcell(struct i2c_client *client)
 
 	vcell = max17040_read_reg(client, MAX17040_VCELL);
 
-	chip->vcell = vcell;
+	chip->vcell = (vcell >> 4) * 1250;
 }
 
 static void max17040_get_soc(struct i2c_client *client)
-- 
2.20.1


       reply	other threads:[~2020-05-04 22:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200504221300.3153-1-xc-racer2@live.ca>
2020-05-04 22:12 ` Jonathan Bakker [this message]
2020-05-10 20:09   ` [PATCH 1/3] power: supply: max17040: Correct voltage reading Sebastian Reichel
2020-05-04 22:12 ` [PATCH 2/3] dt-bindings: power: supply: Document maxim,rcomp-value for max17040 Jonathan Bakker
2020-05-13  2:16   ` Rob Herring
2020-05-04 22:13 ` [PATCH 3/3] power: supply: max17040: Set rcomp value Jonathan Bakker
2020-05-10 20:08   ` Sebastian Reichel
2020-05-11  2:41     ` Jonathan Bakker
2020-05-28 17:02   ` Sebastian Reichel
2020-05-29 20:09     ` Jonathan Bakker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BN6PR04MB0660DA4AED9364441DA33094A3A60@BN6PR04MB0660.namprd04.prod.outlook.com \
    --to=xc-racer2@live.ca \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=sre@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.