mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RESEND PATCH 0/3] power: supply: max17040: report charging status from a gpio-charger
@ 2026-11-08 15:42 Hugo Karlsson
  2026-11-08 15:42 ` [RESEND PATCH 1/3] power: supply: max17040: pass the device fwnode to the power supply core Hugo Karlsson
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Hugo Karlsson @ 2026-11-08 15:42 UTC (permalink / raw)
  To: sre
  Cc: linux-pm, linux-kernel, matheus, me, krzk, m.szyprowski,
	clamor95, Hugo Karlsson

Hi,

Resending with LKML and the remaining MAX17040 reviewers in Cc, which
I missed the first time. No changes since the original posting:
https://lore.kernel.org/linux-pm/20261108144548.190622-1-huggek@klattorp.se/

I work on OpenFlight [1], an open-source golf launch monitor built on a
Raspberry Pi 5 with a Geekworm X1202 UPS board. The board pairs a
MAX1704x fuel gauge at I2C address 0x36 with a GPIO that is high while
input power is present.

With the gauge and a gpio-charger described in DT and linked by
power-supplies, the battery still always reports status "Unknown", and
capacity reads above 100 when the cell is full (103 here). Desktop
battery indicators then show the wrong state, so we have been shipping
a patched taskbar plugin to work around it.

Patch 1 passes the device fwnode to the power supply core. Without it,
power-supplies is never parsed, so the supplier status lookup added in
commit f4b782af61ae never finds a supplier.

Patch 2 covers suppliers that only report "online", such as a
gpio-charger without a charge-status GPIO: the status is derived from
power_supply_am_i_supplied(), and the battery now sends a change event
when its supplier changes.

Patch 3 clamps the reported capacity to 100.

The series is based on for-next. I tested it on a Raspberry Pi 5 with an
X1202, on rpi-6.18.y (6.18.50), where max17040_battery.c only differs
in the style of the i2c_device_id table:

  stock driver:          status Unknown, capacity 103
  on mains at 100 %:     Full, capacity 100
  unplugged:             Discharging
  plugged in at 98 %:    Charging

The battery's uevent follows the charger's within 1 ms.

Related changes for the same boards, for context:
  - Raspberry Pi overlay that links the gauge to the charger [2]
  - Raspberry Pi OS taskbar battery plugin reading capacity [3]

The patches and changelogs were written with Claude Code
(claude-opus-5-5) from my description of the problem. I reviewed them
and did the hardware testing above.

[1] https://github.com/open-flight/openflight
[2] https://github.com/raspberrypi/linux/pull/7744
[3] https://github.com/raspberrypi-ui/pplug-batt/pull/17

Thanks,
Hugo

Hugo Karlsson (3):
  power: supply: max17040: pass the device fwnode to the power supply
    core
  power: supply: max17040: derive status from an online supplier
  power: supply: max17040: clamp the reported capacity to 100 %

 drivers/power/supply/max17040_battery.c | 28 +++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

-- 
2.55.0.windows.5


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-11-09 10:06 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-08 15:42 [RESEND PATCH 0/3] power: supply: max17040: report charging status from a gpio-charger Hugo Karlsson
2026-11-08 15:42 ` [RESEND PATCH 1/3] power: supply: max17040: pass the device fwnode to the power supply core Hugo Karlsson
2026-11-08 16:15   ` Svyatoslav Ryhel
2026-11-09  7:30   ` Krzysztof Kozlowski
2026-11-09  8:53     ` Hugo Karlsson
2026-11-09 10:06       ` Krzysztof Kozlowski
2026-11-08 15:42 ` [RESEND PATCH 2/3] power: supply: max17040: derive status from an online supplier Hugo Karlsson
2026-11-08 15:42 ` [RESEND PATCH 3/3] power: supply: max17040: clamp the reported capacity to 100 % Hugo Karlsson
2026-11-08 16:24   ` Svyatoslav Ryhel
2026-11-09  1:23 ` [RESEND PATCH 0/3] power: supply: max17040: report charging status from a gpio-charger Sebastian Reichel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®