From f0f400459bf6a037e70768de623fff3f8920b8bb Mon Sep 17 00:00:00 2001 From: Igor Velkov Date: Sun, 18 Oct 2026 03:57:53 +0000 Subject: [PATCH] power: supply: gpio-charger: Report discharging without input power The status property follows only the charge-status GPIO. Without input power a charger such as the BQ24133 releases its open-drain STAT pin, and depending on the board the GPIO then reads as charging. On Kobol Helios64 the board runs from its battery after a mains loss, and the charger reports online 0 with status "Charging". Report "Discharging" whenever the online GPIO is present and inactive. Fixes: df68c44c720a ("power: supply: gpio-charger: Add support for charger status.") Assisted-by: LLM Signed-off-by: Igor Velkov Link: https://patch.msgid.link/20261018-gpio-charger-offline-v2-1-482795f9e27c@iav.lv Signed-off-by: Sebastian Reichel --- drivers/power/supply/gpio-charger.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/power/supply/gpio-charger.c b/drivers/power/supply/gpio-charger.c index 2504190eba82..1dad49acc424 100644 --- a/drivers/power/supply/gpio-charger.c +++ b/drivers/power/supply/gpio-charger.c @@ -101,7 +101,10 @@ static int gpio_charger_get_property(struct power_supply *psy, val->intval = gpiod_get_value_cansleep(gpio_charger->gpiod); break; case POWER_SUPPLY_PROP_STATUS: - if (gpiod_get_value_cansleep(gpio_charger->charge_status)) + /* Without input power the battery discharges, whatever the status pin says */ + if (gpio_charger->gpiod && !gpiod_get_value_cansleep(gpio_charger->gpiod)) + val->intval = POWER_SUPPLY_STATUS_DISCHARGING; + else if (gpiod_get_value_cansleep(gpio_charger->charge_status)) val->intval = POWER_SUPPLY_STATUS_CHARGING; else val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;