public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: Sebastian Reichel <sebastian.reichel@collabora.com>
To: dimitri.fedrau@liebherr.com
Cc: Rob Herring <robh@kernel.org>,
	 Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	linux-pm@vger.kernel.org,  devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	 Dimitri Fedrau <dima.fedrau@gmail.com>
Subject: Re: [PATCH v2 2/2] power: supply: gpio-charger: add support for fast-charge timer
Date: Fri, 30 Jan 2026 23:19:44 +0100	[thread overview]
Message-ID: <aX0tJLqfY7b9oNAi@venus> (raw)
In-Reply-To: <20260109-gpio-charger-timer-v2-2-63fd1ba75830@liebherr.com>

[-- 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 --]

  reply	other threads:[~2026-01-30 22:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2026-02-04 12:44     ` Dimitri Fedrau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aX0tJLqfY7b9oNAi@venus \
    --to=sebastian.reichel@collabora.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dima.fedrau@gmail.com \
    --cc=dimitri.fedrau@liebherr.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox