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
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
>
>
>
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 [...]
© 2016 - 2026 Red Hat, Inc.