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

Henrik Grimler
2021-09-28T19:18:52Z

On Tue, Sep 28, 2021 at 11:22:15AM +0200, Krzysztof Kozlowski wrote:
> On 19/09/2021 22:07, Henrik Grimler wrote:
> > 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.
> >
> > At least one max170xx driver, found in Asus' Z00D kernel [1], chooses
> > how to get the capacity based on if current sense is available or not.
> > Lets change the mainline driver to match the Asus Z00D driver's
> > behaviour and thereby fix so that correct state of charge values are
> > obtained on Galaxy S3.
> >
> > [1] https://github.com/LineageOS/android_kernel_asus_Z00D/blob/c7ab0e3ec5b5/drivers/power/max17042_battery.c#L1103-L1105
> >
> > Suggested-by: Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de>
> > Signed-off-by: Henrik Grimler <henrik@grimler.se>
> > ---
> > drivers/power/supply/max17042_battery.c | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
>
> After explanation and double-checking of driver this makes sense. The
> driver already uses VFSoc for alerts (MiscCFG register) if
> !enable_current_sense.
>
> Fixes: 359ab9f5b154 ("power_supply: Add MAX17042 Fuel Gauge Driver")
> Cc: <stable@vger.kernel.org>
>
> These could be added when applying but maybe Sebastian wants a v2 with it?
>
> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>

I can send a v2 with updated commit message to mention that we already
use VFSOC for the alert on this device, and sneak in a patch to fix a
typo in Iavg_empty parameter.

> Best regards,
> Krzysztof