From: Hugo Karlsson <huggek@klattorp.se>
To: sre@kernel.org
Cc: linux-pm@vger.kernel.org, matheus@castello.eng.br,
me@iskren.info, krzk@kernel.org, m.szyprowski@samsung.com,
linux-kernel@vger.kernel.org, clamor95@gmail.com
Subject: Re: [PATCH 0/3] power: supply: max17040: report charging status from a gpio-charger
Date: Sun, 8 Nov 2026 16:09:10 +0100 [thread overview]
Message-ID: <3cd1da5d-8888-4127-b406-a1ed35454e77@klattorp.se> (raw)
In-Reply-To: <20261108144548.190622-1-huggek@klattorp.se>
Adding the other MAX17040 reviewers, LKML, and Svyatoslav as the
author of the commit in the Fixes: tag, whom I missed when sending.
Sorry for the noise.
//Hugo
On 08/11/2026 15:45, Hugo Karlsson wrote:
> Hi,
>
> 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(-)
>
next parent reply other threads:[~2026-11-08 15:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20261108144548.190622-1-huggek@klattorp.se>
2026-11-08 15:09 ` Hugo Karlsson [this message]
2026-11-08 15:20 ` Svyatoslav Ryhel
2026-11-08 15:44 ` Hugo Karlsson
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=3cd1da5d-8888-4127-b406-a1ed35454e77@klattorp.se \
--to=huggek@klattorp.se \
--cc=clamor95@gmail.com \
--cc=krzk@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=matheus@castello.eng.br \
--cc=me@iskren.info \
--cc=sre@kernel.org \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®