Thread (5 messages) 5 messages, 4 authors, 2021-10-02

Re: [PATCH v2 1/2] power: supply: max17042_battery: use VFSOC for capacity when no rsns

From: Sebastian Reichel <hidden>
Date: 2021-10-02 15:53:44
Also in: linux-samsung-soc, stable

Hi,

On Wed, Sep 29, 2021 at 09:43:25PM +0200, Hans de Goede wrote:
On 9/29/21 8:14 PM, Henrik Grimler wrote:
quoted
On Galaxy S3 (i9300/i9305), which has the max17047 fuel gauge and no
current sense resistor (rsns), the RepSOC register does not provide an
accurate state of charge value. The reported value is wrong, and does
not change over time. VFSOC however, which uses the voltage fuel gauge
to determine the state of charge, always shows an accurate value.

For devices without current sense, VFSOC is already used for the
soc-alert (0x0003 is written to MiscCFG register), so with this change
the source of the alert and the PROP_CAPACITY value match.

Fixes: 359ab9f5b154 ("power_supply: Add MAX17042 Fuel Gauge Driver")
Cc: <redacted>
Reviewed-by: Krzysztof Kozlowski <redacted>
Suggested-by: Wolfgang Wiedmeyer <redacted>
Signed-off-by: Henrik Grimler <redacted>
---
Changes in v2:
Re-write commit message to highlight that VFSOC is already used for
alert, after Krzysztof's comments
Thanks, both patches looks good to me:

Reviewed-by: Hans de Goede <redacted>

for the series.
Thanks, both queued.

-- Sebastian

Regards,

Hans

quoted
---
 drivers/power/supply/max17042_battery.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
index 8dffae76b6a3..5809ba997093 100644
--- a/drivers/power/supply/max17042_battery.c
+++ b/drivers/power/supply/max17042_battery.c
@@ -313,7 +313,10 @@ static int max17042_get_property(struct power_supply *psy,
 		val->intval = data * 625 / 8;
 		break;
 	case POWER_SUPPLY_PROP_CAPACITY:
-		ret = regmap_read(map, MAX17042_RepSOC, &data);
+		if (chip->pdata->enable_current_sense)
+			ret = regmap_read(map, MAX17042_RepSOC, &data);
+		else
+			ret = regmap_read(map, MAX17042_VFSOC, &data);
 		if (ret < 0)
 			return ret;
 
base-commit: 5816b3e6577eaa676ceb00a848f0fd65fe2adc29

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help