linux-samsung-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
To: Henrik Grimler <henrik@grimler.se>,
	sre@kernel.org, linux-pm@vger.kernel.org,
	linux-samsung-soc@vger.kernel.org,
	~postmarketos/upstreaming@lists.sr.ht, wolfgit@wiedmeyer.de
Cc: Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm>,
	Hans de Goede <hdegoede@redhat.com>,
	Nikita Travkin <nikita@trvn.ru>
Subject: Re: [PATCH 1/1] power: supply: max17042_battery: use VFSOC for capacity when no rsns
Date: Fri, 24 Sep 2021 13:45:29 +0200	[thread overview]
Message-ID: <17ba5aaa-c456-2bb9-1680-ff0a302b412f@canonical.com> (raw)
In-Reply-To: <20210919200735.142862-2-henrik@grimler.se>

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(-)
> 
> diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
> index 622bdae6182c..7233670978d0 100644
> --- a/drivers/power/supply/max17042_battery.c
> +++ b/drivers/power/supply/max17042_battery.c
> @@ -317,7 +317,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);

Thanks for the patch. I found also my comments to Wolfgang's patch in
2016, which you resolve here but I have more. :)

I think my previous message about current sense are not correct. What is
important is whether ModelGauge is being used/configured. For example
none of DT platforms support it but ACPI might.

There is incoming patch around it:
https://lore.kernel.org/lkml/5702731.UytLkSCjyO@pliszka/

If you switch to VSSoc, I think you need to modify the SOC Alert Config
in MiscCFG register (bits 0:1 to 0x1). Otherwise the alerts will be
generated on different value.

Different topic:
When touching Exynos-based boards (like Galaxy S3), please Cc me as
well, even if I don't pop up in the maintainers.

For max17042 we need to Cc broader group of users, for example using it
in ACPI platforms. The best is to pick the contributors.

Best regards,
Krzysztof

  reply	other threads:[~2021-09-24 11:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-19 20:07 [PATCH 0/1] " Henrik Grimler
2021-09-19 20:07 ` [PATCH 1/1] " Henrik Grimler
2021-09-24 11:45   ` Krzysztof Kozlowski [this message]
2021-09-27 19:05     ` Henrik Grimler
2021-09-28  9:18       ` Krzysztof Kozlowski
2021-09-28 18:32         ` Henrik Grimler
2021-09-28  9:22   ` Krzysztof Kozlowski
2021-09-28 19:18     ` Henrik Grimler

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=17ba5aaa-c456-2bb9-1680-ff0a302b412f@canonical.com \
    --to=krzysztof.kozlowski@canonical.com \
    --cc=hdegoede@redhat.com \
    --cc=henrik@grimler.se \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=nikita@trvn.ru \
    --cc=sebastian.krzyszkowiak@puri.sm \
    --cc=sre@kernel.org \
    --cc=wolfgit@wiedmeyer.de \
    --cc=~postmarketos/upstreaming@lists.sr.ht \
    --subject='Re: [PATCH 1/1] power: supply: max17042_battery: use VFSOC for capacity when no rsns' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).