Re: [PATCH 2/2] power: supply: leds: add a not-charging trigger

Sebastian Reichel <[email protected]>
Newsgroups org.kernel.vger.linux-pm,org.kernel.vger.linux-kernel
Message-ID <amQWViWt8ovRisp0@venus>
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 <[email protected]>
> > > 
> > > 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 <[email protected]>
> > > ---
> > >  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
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAmpkIgEACgkQ2O7X88g7
+po2zw//YJK0dY2pNa4rOGLaZzlc2ovAWnnMzAQ0WOd81vAw4OJvhAW3Vk1K3VAV
kED6MIN0Z3YVLsxMEQh8W5O6rZmmeMtLZkIcpo+RyELfVahqhDQ9kX3drcY2sGvj
UeVAEDqy/P4O8gsZqv+kyAhOS3z9ENX/fN8m2RPOSF2PetjFYudahUO2Qb7Ud1Qa
u3ETUxBXPDUWcACQl8oziVTiS8qQAA3JuC8ptup7+NaI5gGsTnLB4RULm0QpPXEs
opsYugwxMy9+HTV/Z8lD3bq6ZXarmrJ9fhpdfmWPC7tDvuR/3aZTrMHfRllqz5Nu
N3U98flvxplGAoeTNAuLEahgXljRw3ar6nTCO/tUDZ7rcHbYJNORl2Au9TaGxB5N
9WPI1pqy9LD42lZ7XspNgcd1vo7oEowakznGY+yuAK1hGJeF8j6ATa0ZxAadquew
2O+T7c8OVYxinsu5GdlZ1xnmVmRx+nSa3eao0WetG8qx8clOhWyXOwbjn32Lh5vM
O8jEyz84ZJs91ajo00UKpCt07SxYFhV3BEBeFxeouGY8m1om/f1VJ0hcqez1VRuo
CATSaY9XsDl4hjIoQpWqdbHPrLU0X7fq1NuvYtut+QD7CLQ5OmUH2CFc3yg18237
irA6H3cHCLCktj7JcDZ6hHbmLYidZCKYebsK/4hRbBxDkGL26rw=
=L8F/
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.