Re: [PATCH 2/2] power: supply: leds: add a not-charging trigger
From: Sebastian Reichel
Date: Fri Jul 24 2026 - 22:42:12 EST
Hi,
On Tue, Jul 21, 2026 at 08:56:47AM +0200, Steffen Dirkwinkel wrote:
> On Tue, 2026-07-21 at 00:23 +0200, Sebastian Reichel wrote:
> > On Thu, Jun 25, 2026 at 07:07:35PM +0200, Steffen Dirkwinkel wrote:
> > > From: Steffen Dirkwinkel <s.dirkwinkel@xxxxxxxxxxxx>
> > >
> > > We intend to use this with a gpio-charger ups device that reports
> > > charging or not-charging based on a gpio to set a "power failure" led.
> > >
> > > Signed-off-by: Steffen Dirkwinkel <s.dirkwinkel@xxxxxxxxxxxx>
> > > ---
> > > drivers/power/supply/power_supply_leds.c | 7 +++++++
> > > include/linux/power_supply.h | 1 +
> > > 2 files changed, 8 insertions(+)
> >
> > POWER_SUPPLY_STATUS_NOT_CHARGING means, that a battery is neither
> > charged **nor discharged**. I think the NOT_CHARGING status has a
> > bad name, but it's ABI and cannot be changed easily. But I certainly
> > don't want it to spread further. Let's find a better name for this
> > trigger. Maybe idle?
>
> Hm, I guess I was also mislead by the name, as it's somewhat correct for my
> usecase, our gpio connected ups is indicating "not-charging" via a gpio and I'm
> using it as a gpio-charger charge-status-gpio.
>
> I guess it would be more correct if I could map the gpio-charger charge status
> to switch between charging and discharging instead of indicating not-charging.
> If you agree I'd add that as an option via device tree binding there and add a
> discharging trigger instead of the not charging one to the led triggers:
>
> charge-status-discharging:
> type: boolean
> description:
> Interpret a deasserted charge-status-gpio as "discharging" instead of
> "not charging".
For a normal charger your gpio would be the ONLINE state effectively
(i.e. "gpios" in the binding). For most devices that's basically the
only thing a charger reports.
Looking at UPS support in the mainline kernel, it does not look like
anyone used it so far (not just with gpio-charger; I cannot finy *any*
user for POWER_SUPPLY_TYPE_UPS). I do see some issues with some of
the power-supply framework's properties as a UPS is basically a
combination of a charger and a battery. I wonder if it's better to
simply expose them separately to avoid these problems.
Can you share a bit more details about your platform? Would it be
possible to expose your UPS like this?
ups_charger: charger {
compatible = "gpio-charger";
charger-type = "mains";
gpios = <your_status_gpio>;
};
ups_battery: battery {
compatible = "gpio-battery";
power-supplies = <&ups_charger>;
/*
* does not yet exist, any GPIOs are optional. In the simple
* case it creates a TYPE_BATTERY device, which sets its own
* status based on the ONLINE state of the charger it is being
* supplied from. Potentially could have a gpio to notify
* critical battery status.
*/
};
Greetings,
-- Sebastian
Attachment:
signature.asc
Description: PGP signature