Re: [PATCH v2 11/11] power: supply: max17042: report time to full (max17055 & max77759)
From: Peter Griffin
Date: Fri Feb 27 2026 - 11:58:17 EST
On Fri, 27 Feb 2026 at 07:15, André Draszik <andre.draszik@xxxxxxxxxx> wrote:
>
> Report the remaining time to full as calculated by the firmware for
> devices that implement this.
> Similar to time to empty, the reported value is only meaningful when
> charging, i.e. if it is != U16_MAX.
>
> Signed-off-by: André Draszik <andre.draszik@xxxxxxxxxx>
>
> ---
Reviewed-by: Peter Griffin <peter.griffin@xxxxxxxxxx>
> v2:
> - limit to max17055 & max77759, the datasheet for max17047 and max17050
> describes the register as 'reserved'. I was mislead by the comment
> and enum ordering in max17042_battery.h
> - report as POWER_SUPPLY_PROP_TIME_TO_FULL_NOW (not _AVG). The max17050
> datasheet is a bit clearer than the max77759 one on that.
> ---
> drivers/power/supply/max17042_battery.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
> index 89909b140cf9..770d806033b9 100644
> --- a/drivers/power/supply/max17042_battery.c
> +++ b/drivers/power/supply/max17042_battery.c
> @@ -89,6 +89,7 @@ static enum power_supply_property max17042_battery_props[] = {
> POWER_SUPPLY_PROP_HEALTH,
> POWER_SUPPLY_PROP_SCOPE,
> POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW,
> + POWER_SUPPLY_PROP_TIME_TO_FULL_NOW,
> // these two have to be at the end on the list
> POWER_SUPPLY_PROP_CURRENT_NOW,
> POWER_SUPPLY_PROP_CURRENT_AVG,
> @@ -447,6 +448,21 @@ static int max17042_get_property(struct power_supply *psy,
> if (data == U16_MAX)
> return -ENODATA;
>
> + val->intval = data * 5625 / 1000;
> + break;
> + case POWER_SUPPLY_PROP_TIME_TO_FULL_NOW:
> + if (chip->chip_type != MAXIM_DEVICE_TYPE_MAX17055 &&
> + chip->chip_type != MAXIM_DEVICE_TYPE_MAX77759)
> + return -EINVAL;
> +
> + ret = regmap_read(map, MAX17055_TTF, &data);
> + if (ret < 0)
> + return ret;
> +
> + /* when discharging, the value is not meaningful */
> + if (data == U16_MAX)
> + return -ENODATA;
> +
> val->intval = data * 5625 / 1000;
> break;
> default:
>
> --
> 2.53.0.473.g4a7958ca14-goog
>