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

Krzysztof Kozlowski
2021-09-28T09:18:31Z

On 27/09/2021 21:05, Henrik Grimler wrote:
> On Fri, Sep 24, 2021 at 01:45:29PM +0200, Krzysztof Kozlowski wrote:
>> 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.
>
> So, 0x1 should correspond to AvSOC (i.e. non-filtered RepSOC), while
> right now we write 0x3 (VFSOC) to MiscCFG for devices without current
> sense [1]. Could you elaborate on why AvSOC should be used for alert
> if we use VFSOC to get PROP_CAPACITY?

I meant that same measurement should be used for both: for PROP_CAPACITY
and for alerts.

I double checked the driver and your change is actually aligned with it.
If !enable_current_sense, the driver will set MiscCFG to 0x3 to use
VFSOC for alerts. I think you can ignore that part of my comment before.

However still remaining issue is that switching to VFSoc should happen
not only if !enable_current_sense but also if ModelGauge m3 is not
configured.

> On this particular device it does not seem to make a difference what I
> use for the SOC alert, the alert triggers all the time in any case
> since RepSOC does not give an accurate value. Supposedly this happens
> because ModelGauge configuration is incomplete, as you said. Looking
> at the registers used by the ModelGauge it seems that only the
> "characterization table" at 0x80 - 0xAF is missing. The rest (FullCap,
> DesignCap, ICHGTerm, ..) are set to the same values as with vendor
> kernel.

Are you sure? I could not find setting of these (e.g.
MAX17042_FullCAP/config->fullcap) for a DT platform.

Best regards,
Krzysztof