public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] power: supply: gpio-charger: add support for fast-charge timer
@ 2026-01-09 18:41 Dimitri Fedrau via B4 Relay
  2026-01-09 18:41 ` [PATCH v2 1/2] dt-bindings: " Dimitri Fedrau via B4 Relay
  2026-01-09 18:41 ` [PATCH v2 2/2] " Dimitri Fedrau via B4 Relay
  0 siblings, 2 replies; 6+ messages in thread
From: Dimitri Fedrau via B4 Relay @ 2026-01-09 18:41 UTC (permalink / raw)
  To: Sebastian Reichel, Rob Herring, Krzysztof Kozlowski, Conor Dooley
  Cc: linux-pm, devicetree, linux-kernel, Dimitri Fedrau,
	Dimitri Fedrau, Sebastian Reichel, Conor Dooley

On some devices like TIs BQ24081 battery charger it is possible to activate
or deactivate a fast-charge timer that provides a backup safety for charge
termination. In case of the BQ24081 it is a fixed 7-hour timer. Add support
for enabling/disabling the fast-charge timer via GPIO.

Signed-off-by: Dimitri Fedrau <dimitri.fedrau@liebherr.com>
---
Changes in v2:
- Added Acked-by tag
- Link to v1: https://lore.kernel.org/r/20251022-gpio-charger-timer-v1-0-b557409400f2@liebherr.com

---
Dimitri Fedrau (2):
      dt-bindings: power: supply: gpio-charger: add support for fast-charge timer
      power: supply: gpio-charger: add support for fast-charge timer

 .../ABI/testing/sysfs-class-power-gpio-charger     | 10 ++++++
 .../bindings/power/supply/gpio-charger.yaml        |  5 +++
 drivers/power/supply/gpio-charger.c                | 39 ++++++++++++++++++++++
 3 files changed, 54 insertions(+)
---
base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
change-id: 20251022-gpio-charger-timer-cddae1619714

Best regards,
-- 
Dimitri Fedrau <dimitri.fedrau@liebherr.com>



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/2] dt-bindings: power: supply: gpio-charger: add support for fast-charge timer
  2026-01-09 18:41 [PATCH v2 0/2] power: supply: gpio-charger: add support for fast-charge timer Dimitri Fedrau via B4 Relay
@ 2026-01-09 18:41 ` Dimitri Fedrau via B4 Relay
  2026-01-30 22:13   ` Sebastian Reichel
  2026-01-09 18:41 ` [PATCH v2 2/2] " Dimitri Fedrau via B4 Relay
  1 sibling, 1 reply; 6+ messages in thread
From: Dimitri Fedrau via B4 Relay @ 2026-01-09 18:41 UTC (permalink / raw)
  To: Sebastian Reichel, Rob Herring, Krzysztof Kozlowski, Conor Dooley
  Cc: linux-pm, devicetree, linux-kernel, Dimitri Fedrau,
	Dimitri Fedrau, Sebastian Reichel, Conor Dooley

From: Dimitri Fedrau <dimitri.fedrau@liebherr.com>

On some devices like TIs BQ24081 battery charger it is possible to activate
or deactivate a fast-charge timer that provides a backup safety for charge
termination via GPIO. In case of the BQ24081 it is a fixed 7-hour timer.

Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Dimitri Fedrau <dimitri.fedrau@liebherr.com>
---
 Documentation/devicetree/bindings/power/supply/gpio-charger.yaml | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Documentation/devicetree/bindings/power/supply/gpio-charger.yaml b/Documentation/devicetree/bindings/power/supply/gpio-charger.yaml
index 25826bfc289c1c00c338fd0cee2ae6932529cfc3..0edacc104186497118d4ba41f80947009a9aacf6 100644
--- a/Documentation/devicetree/bindings/power/supply/gpio-charger.yaml
+++ b/Documentation/devicetree/bindings/power/supply/gpio-charger.yaml
@@ -62,6 +62,10 @@ properties:
     description: Default charge current limit. Must be listed in
       charge-current-limit-mapping.
 
+  fast-charge-timer-gpios:
+    maxItems: 1
+    description: GPIO used for enabling/disabling the fast-charge timer
+
 required:
   - compatible
 
@@ -97,4 +101,5 @@ examples:
                                      <700000 0x01>, // 700 mA => GPIO A.12 high
                                      <0 0x02>; // 0 mA => GPIO A.11 high
       charge-current-limit-default-microamp = <700000>;
+      fast-charge-timer-gpios = <&gpioA 13 GPIO_ACTIVE_LOW>;
     };

-- 
2.39.5



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/2] power: supply: gpio-charger: add support for fast-charge timer
  2026-01-09 18:41 [PATCH v2 0/2] power: supply: gpio-charger: add support for fast-charge timer Dimitri Fedrau via B4 Relay
  2026-01-09 18:41 ` [PATCH v2 1/2] dt-bindings: " Dimitri Fedrau via B4 Relay
@ 2026-01-09 18:41 ` Dimitri Fedrau via B4 Relay
  2026-01-30 22:19   ` Sebastian Reichel
  1 sibling, 1 reply; 6+ messages in thread
From: Dimitri Fedrau via B4 Relay @ 2026-01-09 18:41 UTC (permalink / raw)
  To: Sebastian Reichel, Rob Herring, Krzysztof Kozlowski, Conor Dooley
  Cc: linux-pm, devicetree, linux-kernel, Dimitri Fedrau,
	Dimitri Fedrau, Sebastian Reichel

From: Dimitri Fedrau <dimitri.fedrau@liebherr.com>

On some devices like TIs BQ24081 battery charger it is possible to activate
or deactivate a fast-charge timer that provides a backup safety for charge
termination. In case of the BQ24081 it is a fixed 7-hour timer. Add support
for enabling/disabling the fast-charge timer via GPIO.

Signed-off-by: Dimitri Fedrau <dimitri.fedrau@liebherr.com>
---
 .../ABI/testing/sysfs-class-power-gpio-charger     | 10 ++++++
 drivers/power/supply/gpio-charger.c                | 39 ++++++++++++++++++++++
 2 files changed, 49 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-class-power-gpio-charger b/Documentation/ABI/testing/sysfs-class-power-gpio-charger
new file mode 100644
index 0000000000000000000000000000000000000000..95fb31ac4af3d5354bdc642c98baa7df267d150d
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-power-gpio-charger
@@ -0,0 +1,10 @@
+What:		/sys/class/power_supply/<supply_name>/fast_charge_timer
+Date:		October 2025
+KernelVersion:	6.19.0
+Contact:	Dimitri Fedrau <dimitri.fedrau@liebherr.com>
+Description:
+		This entry enables or disables the timer in fast-charge mode.
+
+		Access: Write
+
+		Valid values: 0 (disabled) or 1 (enabled)
diff --git a/drivers/power/supply/gpio-charger.c b/drivers/power/supply/gpio-charger.c
index 2504190eba82e69b79382320e67de6b8f3dedc77..52997205879406fae600171b070a0328657fa79b 100644
--- a/drivers/power/supply/gpio-charger.c
+++ b/drivers/power/supply/gpio-charger.c
@@ -32,6 +32,7 @@ struct gpio_charger {
 	struct power_supply_desc charger_desc;
 	struct gpio_desc *gpiod;
 	struct gpio_desc *charge_status;
+	struct gpio_desc *timer;
 
 	struct gpio_descs *current_limit_gpios;
 	struct gpio_mapping *current_limit_map;
@@ -259,6 +260,36 @@ static int init_charge_current_limit(struct device *dev,
 	return 0;
 }
 
+static ssize_t fast_charge_timer_store(struct device *dev,
+				       struct device_attribute *attr,
+				       const char *buf, size_t count)
+{
+	struct power_supply *psy = dev_get_drvdata(dev);
+	struct gpio_charger *gpio_charger = power_supply_get_drvdata(psy);
+	int ret;
+	bool en;
+
+	if (kstrtobool(buf, &en))
+		return -EINVAL;
+
+	if (!gpio_charger->timer)
+		return -ENODEV;
+
+	ret = gpiod_set_value_cansleep(gpio_charger->timer, en);
+	if (ret)
+		return ret;
+
+	return count;
+}
+
+static DEVICE_ATTR_WO(fast_charge_timer);
+
+static struct attribute *gpio_charger_attrs[] = {
+	&dev_attr_fast_charge_timer.attr,
+	NULL
+};
+ATTRIBUTE_GROUPS(gpio_charger);
+
 /*
  * The entries will be overwritten by driver's probe routine depending
  * on the available features. This list ensures, that the array is big
@@ -308,6 +339,13 @@ static int gpio_charger_probe(struct platform_device *pdev)
 		num_props++;
 	}
 
+	gpio_charger->timer = devm_gpiod_get_optional(dev, "fast-charge-timer",
+						      GPIOD_OUT_HIGH);
+	if (IS_ERR(gpio_charger->timer)) {
+		return dev_err_probe(dev, PTR_ERR(gpio_charger->timer),
+				     "error getting fast-charge timer GPIO descriptor\n");
+	}
+
 	charge_status = devm_gpiod_get_optional(dev, "charge-status", GPIOD_IN);
 	if (IS_ERR(charge_status))
 		return PTR_ERR(charge_status);
@@ -336,6 +374,7 @@ static int gpio_charger_probe(struct platform_device *pdev)
 
 	psy_cfg.fwnode = dev_fwnode(dev);
 	psy_cfg.drv_data = gpio_charger;
+	psy_cfg.attr_grp = gpio_charger_groups;
 
 	if (pdata) {
 		charger_desc->name = pdata->name;

-- 
2.39.5



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/2] dt-bindings: power: supply: gpio-charger: add support for fast-charge timer
  2026-01-09 18:41 ` [PATCH v2 1/2] dt-bindings: " Dimitri Fedrau via B4 Relay
@ 2026-01-30 22:13   ` Sebastian Reichel
  0 siblings, 0 replies; 6+ messages in thread
From: Sebastian Reichel @ 2026-01-30 22:13 UTC (permalink / raw)
  To: dimitri.fedrau
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, linux-pm,
	devicetree, linux-kernel, Dimitri Fedrau, Conor Dooley

[-- Attachment #1: Type: text/plain, Size: 1980 bytes --]

Hi,

On Fri, Jan 09, 2026 at 07:41:19PM +0100, Dimitri Fedrau via B4 Relay wrote:
> From: Dimitri Fedrau <dimitri.fedrau@liebherr.com>
> 
> On some devices like TIs BQ24081 battery charger it is possible to activate
> or deactivate a fast-charge timer that provides a backup safety for charge
> termination via GPIO. In case of the BQ24081 it is a fixed 7-hour timer.
> 
> Acked-by: Conor Dooley <conor.dooley@microchip.com>
> Signed-off-by: Dimitri Fedrau <dimitri.fedrau@liebherr.com>
> ---

With the time being charger specific, this is not a good solution
for the generic gpio-charger compatible. You should add a compatible
for the BQ24081 (using gpio-charger as fallback) and then only allow
'fast-charge-timer-gpios' for the BQ24081.

Greetings,

-- Sebastian

>  Documentation/devicetree/bindings/power/supply/gpio-charger.yaml | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/power/supply/gpio-charger.yaml b/Documentation/devicetree/bindings/power/supply/gpio-charger.yaml
> index 25826bfc289c1c00c338fd0cee2ae6932529cfc3..0edacc104186497118d4ba41f80947009a9aacf6 100644
> --- a/Documentation/devicetree/bindings/power/supply/gpio-charger.yaml
> +++ b/Documentation/devicetree/bindings/power/supply/gpio-charger.yaml
> @@ -62,6 +62,10 @@ properties:
>      description: Default charge current limit. Must be listed in
>        charge-current-limit-mapping.
>  
> +  fast-charge-timer-gpios:
> +    maxItems: 1
> +    description: GPIO used for enabling/disabling the fast-charge timer
> +
>  required:
>    - compatible
>  
> @@ -97,4 +101,5 @@ examples:
>                                       <700000 0x01>, // 700 mA => GPIO A.12 high
>                                       <0 0x02>; // 0 mA => GPIO A.11 high
>        charge-current-limit-default-microamp = <700000>;
> +      fast-charge-timer-gpios = <&gpioA 13 GPIO_ACTIVE_LOW>;
>      };
> 
> -- 
> 2.39.5
> 
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 2/2] power: supply: gpio-charger: add support for fast-charge timer
  2026-01-09 18:41 ` [PATCH v2 2/2] " Dimitri Fedrau via B4 Relay
@ 2026-01-30 22:19   ` Sebastian Reichel
  2026-02-04 12:44     ` Dimitri Fedrau
  0 siblings, 1 reply; 6+ messages in thread
From: Sebastian Reichel @ 2026-01-30 22:19 UTC (permalink / raw)
  To: dimitri.fedrau
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, linux-pm,
	devicetree, linux-kernel, Dimitri Fedrau

[-- Attachment #1: Type: text/plain, Size: 4087 bytes --]

Hi,

On Fri, Jan 09, 2026 at 07:41:20PM +0100, Dimitri Fedrau via B4 Relay wrote:
> From: Dimitri Fedrau <dimitri.fedrau@liebherr.com>
> 
> On some devices like TIs BQ24081 battery charger it is possible to activate
> or deactivate a fast-charge timer that provides a backup safety for charge
> termination. In case of the BQ24081 it is a fixed 7-hour timer. Add support
> for enabling/disabling the fast-charge timer via GPIO.
> 
> Signed-off-by: Dimitri Fedrau <dimitri.fedrau@liebherr.com>
> ---

The documentation is missing _a lot of information_. What happens
when the fast-charge timer is disabled? What happens when it is
enabled and times out? What do you expect users to do with this
control knob?

Greetings,

-- Sebastian

>  .../ABI/testing/sysfs-class-power-gpio-charger     | 10 ++++++
>  drivers/power/supply/gpio-charger.c                | 39 ++++++++++++++++++++++
>  2 files changed, 49 insertions(+)
> 
> diff --git a/Documentation/ABI/testing/sysfs-class-power-gpio-charger b/Documentation/ABI/testing/sysfs-class-power-gpio-charger
> new file mode 100644
> index 0000000000000000000000000000000000000000..95fb31ac4af3d5354bdc642c98baa7df267d150d
> --- /dev/null
> +++ b/Documentation/ABI/testing/sysfs-class-power-gpio-charger
> @@ -0,0 +1,10 @@
> +What:		/sys/class/power_supply/<supply_name>/fast_charge_timer
> +Date:		October 2025
> +KernelVersion:	6.19.0
> +Contact:	Dimitri Fedrau <dimitri.fedrau@liebherr.com>
> +Description:
> +		This entry enables or disables the timer in fast-charge mode.
> +
> +		Access: Write
> +
> +		Valid values: 0 (disabled) or 1 (enabled)
> diff --git a/drivers/power/supply/gpio-charger.c b/drivers/power/supply/gpio-charger.c
> index 2504190eba82e69b79382320e67de6b8f3dedc77..52997205879406fae600171b070a0328657fa79b 100644
> --- a/drivers/power/supply/gpio-charger.c
> +++ b/drivers/power/supply/gpio-charger.c
> @@ -32,6 +32,7 @@ struct gpio_charger {
>  	struct power_supply_desc charger_desc;
>  	struct gpio_desc *gpiod;
>  	struct gpio_desc *charge_status;
> +	struct gpio_desc *timer;
>  
>  	struct gpio_descs *current_limit_gpios;
>  	struct gpio_mapping *current_limit_map;
> @@ -259,6 +260,36 @@ static int init_charge_current_limit(struct device *dev,
>  	return 0;
>  }
>  
> +static ssize_t fast_charge_timer_store(struct device *dev,
> +				       struct device_attribute *attr,
> +				       const char *buf, size_t count)
> +{
> +	struct power_supply *psy = dev_get_drvdata(dev);
> +	struct gpio_charger *gpio_charger = power_supply_get_drvdata(psy);
> +	int ret;
> +	bool en;
> +
> +	if (kstrtobool(buf, &en))
> +		return -EINVAL;
> +
> +	if (!gpio_charger->timer)
> +		return -ENODEV;
> +
> +	ret = gpiod_set_value_cansleep(gpio_charger->timer, en);
> +	if (ret)
> +		return ret;
> +
> +	return count;
> +}
> +
> +static DEVICE_ATTR_WO(fast_charge_timer);
> +
> +static struct attribute *gpio_charger_attrs[] = {
> +	&dev_attr_fast_charge_timer.attr,
> +	NULL
> +};
> +ATTRIBUTE_GROUPS(gpio_charger);
> +
>  /*
>   * The entries will be overwritten by driver's probe routine depending
>   * on the available features. This list ensures, that the array is big
> @@ -308,6 +339,13 @@ static int gpio_charger_probe(struct platform_device *pdev)
>  		num_props++;
>  	}
>  
> +	gpio_charger->timer = devm_gpiod_get_optional(dev, "fast-charge-timer",
> +						      GPIOD_OUT_HIGH);
> +	if (IS_ERR(gpio_charger->timer)) {
> +		return dev_err_probe(dev, PTR_ERR(gpio_charger->timer),
> +				     "error getting fast-charge timer GPIO descriptor\n");
> +	}
> +
>  	charge_status = devm_gpiod_get_optional(dev, "charge-status", GPIOD_IN);
>  	if (IS_ERR(charge_status))
>  		return PTR_ERR(charge_status);
> @@ -336,6 +374,7 @@ static int gpio_charger_probe(struct platform_device *pdev)
>  
>  	psy_cfg.fwnode = dev_fwnode(dev);
>  	psy_cfg.drv_data = gpio_charger;
> +	psy_cfg.attr_grp = gpio_charger_groups;
>  
>  	if (pdata) {
>  		charger_desc->name = pdata->name;
> 
> -- 
> 2.39.5
> 
> 
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 2/2] power: supply: gpio-charger: add support for fast-charge timer
  2026-01-30 22:19   ` Sebastian Reichel
@ 2026-02-04 12:44     ` Dimitri Fedrau
  0 siblings, 0 replies; 6+ messages in thread
From: Dimitri Fedrau @ 2026-02-04 12:44 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: dimitri.fedrau, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	linux-pm, devicetree, linux-kernel

Am Fri, Jan 30, 2026 at 11:19:44PM +0100 schrieb Sebastian Reichel:
> Hi,
> 
> On Fri, Jan 09, 2026 at 07:41:20PM +0100, Dimitri Fedrau via B4 Relay wrote:
> > From: Dimitri Fedrau <dimitri.fedrau@liebherr.com>
> > 
> > On some devices like TIs BQ24081 battery charger it is possible to activate
> > or deactivate a fast-charge timer that provides a backup safety for charge
> > termination. In case of the BQ24081 it is a fixed 7-hour timer. Add support
> > for enabling/disabling the fast-charge timer via GPIO.
> > 
> > Signed-off-by: Dimitri Fedrau <dimitri.fedrau@liebherr.com>
> > ---
> 
> The documentation is missing _a lot of information_. What happens
> when the fast-charge timer is disabled? What happens when it is
> enabled and times out? What do you expect users to do with this
> control knob?
>

Yes, you are right. Will add the missing information for the BQ24081.
When the timer is enabled and 7-hours are passed the device will enter
state "Timer fault" where charging is disabled and cannot be enabled
without powering the device down and up again.

Disabling the timer will just deactive the mechanism above but charging
is not affected by it.

It's just a safety feature that can be turned on/off.

Will add this information, am I missing anything else ?

Best regards,
Dimitri Fedrau

[...]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-02-04 12:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-09 18:41 [PATCH v2 0/2] power: supply: gpio-charger: add support for fast-charge timer Dimitri Fedrau via B4 Relay
2026-01-09 18:41 ` [PATCH v2 1/2] dt-bindings: " Dimitri Fedrau via B4 Relay
2026-01-30 22:13   ` Sebastian Reichel
2026-01-09 18:41 ` [PATCH v2 2/2] " Dimitri Fedrau via B4 Relay
2026-01-30 22:19   ` Sebastian Reichel
2026-02-04 12:44     ` Dimitri Fedrau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox