* [PATCH] power: supply: gpio-charger: Report not charging without input power
@ 2026-10-08 1:27 Igor Velkov via B4 Relay
2026-10-17 23:40 ` Sebastian Reichel
0 siblings, 1 reply; 2+ messages in thread
From: Igor Velkov via B4 Relay @ 2026-10-08 1:27 UTC (permalink / raw)
To: Sebastian Reichel; +Cc: linux-pm, linux-kernel, Igor Velkov
From: Igor Velkov <iav@iav.lv>
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 "Not charging" whenever the online GPIO is present and inactive.
Tested on Helios64: on battery the status now reads "Not charging".
Assisted-by: LLM
Signed-off-by: Igor Velkov <iav@iav.lv>
---
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..2fdff5f8b5ad 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 charger cannot charge, whatever its status pin says */
+ if (gpio_charger->gpiod && !gpiod_get_value_cansleep(gpio_charger->gpiod))
+ val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
+ else if (gpiod_get_value_cansleep(gpio_charger->charge_status))
val->intval = POWER_SUPPLY_STATUS_CHARGING;
else
val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
---
base-commit: a90ee4305c4a5df72c11b31dacfdc76e00fcf78a
change-id: 20261008-gpio-charger-offline-cf51542a10ef
Best regards,
--
Igor Velkov <iav@iav.lv>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] power: supply: gpio-charger: Report not charging without input power
2026-10-08 1:27 [PATCH] power: supply: gpio-charger: Report not charging without input power Igor Velkov via B4 Relay
@ 2026-10-17 23:40 ` Sebastian Reichel
0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Reichel @ 2026-10-17 23:40 UTC (permalink / raw)
To: iav; +Cc: linux-pm, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 2155 bytes --]
Hi,
On Thu, Oct 08, 2026 at 04:27:29AM +0300, Igor Velkov via B4 Relay wrote:
> From: Igor Velkov <iav@iav.lv>
>
> 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 "Not charging" whenever the online GPIO is present and inactive.
>
> Tested on Helios64: on battery the status now reads "Not charging".
>
> Assisted-by: LLM
> Signed-off-by: Igor Velkov <iav@iav.lv>
> ---
Not charging means that the battery neither charges nor discharges.
I.e. the system runs from external power. So without the charger
being online, this should be POWER_SUPPLY_STATUS_DISCHARGING.
Also please add a Fixes tag.
Greetings,
-- Sebastian
> 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..2fdff5f8b5ad 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 charger cannot charge, whatever its status pin says */
> + if (gpio_charger->gpiod && !gpiod_get_value_cansleep(gpio_charger->gpiod))
> + val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
> + else if (gpiod_get_value_cansleep(gpio_charger->charge_status))
> val->intval = POWER_SUPPLY_STATUS_CHARGING;
> else
> val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
>
> ---
> base-commit: a90ee4305c4a5df72c11b31dacfdc76e00fcf78a
> change-id: 20261008-gpio-charger-offline-cf51542a10ef
>
> Best regards,
> --
> Igor Velkov <iav@iav.lv>
>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-17 23:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-08 1:27 [PATCH] power: supply: gpio-charger: Report not charging without input power Igor Velkov via B4 Relay
2026-10-17 23:40 ` Sebastian Reichel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox