Linux Input/HID development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Molnár Máté" <matemolnar88@gmail.com>
Cc: devicetree@vger.kernel.org, linux-input@vger.kernel.org,
	mfd@lists.linux.dev, robh@kernel.org, conor+dt@kernel.org,
	dmitry.torokhov@gmail.com, lee@kernel.org
Subject: Re: [PATCH v7 5/9] power: axp20x_battery: Support battery status without fuel gauge
Date: Sun, 06 Dec 2026 03:23:02 +0000	[thread overview]
Message-ID: <sashiko-outbox-252118@kernel.org> (raw)
In-Reply-To: <20261206-axp192-v7-5-0200fc77da53@gmail.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] power: axp20x_battery_get_prop() ignores charger enable and
  battery presence
- [Low] power: supply: axp20x_battery: axp717_data omits has_fg flag
- [Low] power: axp20x_battery: omit has_fg flag on axp717_data
--

commit a493fb18308210a804a2cff64dc6cfb93847bd0d
Author: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>

power: axp20x_battery: Support battery status without fuel gauge

This commit adds a has_fg flag to struct axp_data and uses battery voltage
relative to the maximum charge voltage to determine POWER_SUPPLY_STATUS_FULL
when a chip has no fuel gauge.

> diff --git a/drivers/power/supply/axp20x_battery.c b/drivers/power/supply/axp20x_battery.c
> index f31b735ed6548..f7485ac6a9aca 100644
> --- a/drivers/power/supply/axp20x_battery.c
> +++ b/drivers/power/supply/axp20x_battery.c

[ ... ]

> @@ -323,6 +324,34 @@ static int axp20x_battery_get_prop(struct power_supply *psy,
>  			return 0;
>  		}
>  
> +		/*
> +		 * If the chip does not have a fuel gauge, we check battery full status
> +		 * using voltage instead.
> +		 */
> +		if (!axp20x_batt->data->has_fg) {
> +			ret = axp20x_batt->data->get_max_voltage(axp20x_batt, &val1);
> +			if (ret)
> +				return ret;
> +
> +			ret = iio_read_channel_processed(axp20x_batt->batt_v, &val2);
> +			if (ret)
> +				return ret;
> +
> +			/* IIO subsystem reports voltage in mV but we need uV */
> +			val2 *= 1000;
> +
> +			/*
> +			 * According to the AXP192 datasheet, charging will restart if
> +			 * the battery voltage drops below V_rch = V_tgt - 0.1 V, so we
> +			 * report the battery is full if its voltage is at least V_rch.
> +			 */
> +			if (val2 >= val1 - 100000)
> +				val->intval = POWER_SUPPLY_STATUS_FULL;
> +			else
> +				val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
> +			break;
> +		}
> +
>  		ret = regmap_read(axp20x_batt->regmap, AXP20X_FG_RES, &val1);
>  		if (ret)
>  			return ret;

[Severity: Medium]
Can this report POWER_SUPPLY_STATUS_FULL when charging is disabled or no
battery is attached?

axp20x_battery_set_prop() allows userspace to disable charging by clearing
AXP20X_CHRG_CTRL1_ENABLE, so the recharge threshold no longer holds and a
partially charged battery above V_tgt - 0.1 V is reported as full.

This path also does not check AXP20X_PWR_OP_BATT_PRESENT before inferring
full status from the battery voltage.

[ ... ]

> @@ -1075,6 +1105,7 @@ static const struct axp_data axp221_data = {
>  	.ccc_reg = AXP20X_CHRG_CTRL1,
>  	.ccc_mask = AXP20X_CHRG_CTRL1_TGT_CURR,
>  	.has_fg_valid = true,
> +	.has_fg = true,
>  	.bat_ps_desc = &axp209_batt_ps_desc,
>  	.get_max_voltage = axp22x_battery_get_max_voltage,
>  	.set_max_voltage = axp22x_battery_set_max_voltage,
> @@ -1100,6 +1131,7 @@ static const struct axp_data axp813_data = {
>  	.ccc_reg = AXP20X_CHRG_CTRL1,
>  	.ccc_mask = AXP20X_CHRG_CTRL1_TGT_CURR,
>  	.has_fg_valid = true,
> +	.has_fg = true,
>  	.bat_ps_desc = &axp209_batt_ps_desc,
>  	.get_max_voltage = axp813_battery_get_max_voltage,
>  	.set_max_voltage = axp20x_battery_set_max_voltage,

[Severity: Low]
Should axp717_data also set .has_fg = true?

AXP717 has a hardware fuel gauge (axp717_battery_get_prop() reads
AXP717_BATT_PERCENT_DATA).

Later in this series, commit "power: axp20x_battery: Estimate AXP192
capacity from the OCV table" gates power_supply_put_battery_info() on
has_fg in axp20x_power_probe(), so leaving has_fg false causes AXP717 to
retain unused battery_info allocations.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261206-axp192-v7-0-0200fc77da53@gmail.com?part=5

  reply	other threads:[~2026-12-06  3:23 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-06  3:08 [PATCH v7 0/9] Add the remaining AXP192 PMIC support Molnár Máté via B4 Relay
2026-12-06  3:08 ` [PATCH v7 1/9] dt-bindings: iio: adc: axp209: Add AXP192 compatible Molnár Máté via B4 Relay
2026-12-06  3:08 ` [PATCH v7 2/9] dt-bindings: power: axp20x-battery: " Molnár Máté via B4 Relay
2026-12-06  3:08 ` [PATCH v7 3/9] regulator: axp20x: Add support for AXP192 Molnár Máté via B4 Relay
2026-12-06  3:22   ` sashiko-bot
2026-12-06  3:08 ` [PATCH v7 4/9] power: axp20x_battery: Add constant charge current table Molnár Máté via B4 Relay
2026-12-06  3:24   ` sashiko-bot
2026-12-06  3:08 ` [PATCH v7 5/9] power: axp20x_battery: Support battery status without fuel gauge Molnár Máté via B4 Relay
2026-12-06  3:23   ` sashiko-bot [this message]
2026-12-06  3:08 ` [PATCH v7 6/9] power: axp20x_battery: Add support for AXP192 Molnár Máté via B4 Relay
2026-12-06  3:08 ` [PATCH v7 7/9] power: axp20x_battery: Estimate AXP192 capacity from the OCV table Molnár Máté via B4 Relay
2026-12-06  3:24   ` sashiko-bot
2026-12-06  3:09 ` [PATCH v7 8/9] Input: axp20x-pek: Add AXP192 support Molnár Máté via B4 Relay
2026-12-06  3:21   ` sashiko-bot
2026-12-06  3:09 ` [PATCH v7 9/9] mfd: axp20x: Add the AXP192 power key cell Molnár Máté via B4 Relay
2026-12-06  3:18   ` sashiko-bot

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=sashiko-outbox-252118@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=lee@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=matemolnar88@gmail.com \
    --cc=mfd@lists.linux.dev \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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