[PATCH 3/5] power: supply: rk817-charger: Correct the gauge across system sleep

Krzysztof Kozlowski krzk at kernel.org
Thu Oct 29 02:37:07 PDT 2026


On Mon, Oct 26, 2026 at 12:48:32PM -0500, Chris Morgan wrote:
> From: Chris Morgan <macromorgan at hotmail.com>
> 
> The coulomb counter is erratic while the system sleeps. On an RG353M
> charging at 1.4A, one 15 minute sleep registered 69% of the metered
> charge and another 139%, and a charge that finished during sleep still
> showed the pre-sleep percentage at wake. The signals that could correct
> it are gone by the time the driver runs again: RELAX_STS clears as soon
> as the wakeup load exceeds the relax threshold (300mA here, less than
> an idle UI draws), and CHARGE_FINISH disappears while the charger
> re-detects its input. The BSP driver corrects at resume from sleep time
> times current and from the relax voltage. Do the same from evidence
> that persists:
> 
> - At suspend, stamp boottime, charge, current and charging state, and
>   clear the relax-updated flags.
> 
> - At resume, recompute the soc from the counter, capped at full. A
>   relax pair with its flags set was latched during this sleep:
>   recalibrate from it without demanding a live RELAX_STS. Otherwise,
>   if the system slept charging, credit elapsed * current where the
>   counter fell short, saturating at full, which also covers a charge
>   that finished during sleep.
> 
> The constant-current estimate reads high across a CV taper; the cap
> bounds it and the next rested pair corrects the remainder.
> 
> Log the counter at suspend and resume, the battery voltage and the
> relax pair, so the path taken can be read from the log.
> 
> Suggested-by: Jacob Cook <jacobmcook1984 at gmail.com>
> Co-developed-by: Jacob Cook <jacobmcook1984 at gmail.com>
> Signed-off-by: Jacob Cook <jacobmcook1984 at gmail.com>

One cannot suggest own work. How would that work:
Krzysztof 1: Hi Krzysztof, my name is Krzysztof, would you do foo-bar?
Krzysztof 2: Yes, Krzysztof, of course, excellent idea, let me credit
you in Suggested-by.

> Signed-off-by: Chris Morgan <macromorgan at hotmail.com>
> Assisted-by: Claude:claude-5-fable

Drop, not correct format for some time, but regardless checkpatch should
complain.

Please run scripts/checkpatch.pl on the patches and fix reported
warnings. After that, run also 'scripts/checkpatch.pl --strict' on the
patches and (probably) fix more warnings. Some warnings can be ignored,
especially from --strict run, but the code here looks like it needs a
fix. Feel free to get in touch if the warning is not clear.

Best regards,
Krzysztof




More information about the Linux-rockchip mailing list