mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 14:53:58 -04:00
power: supply: max17042: report time to full (max17055 & max77759)
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. Reviewed-by: Peter Griffin <peter.griffin@linaro.org> Signed-off-by: André Draszik <andre.draszik@linaro.org> Link: https://patch.msgid.link/20260302-max77759-fg-v3-11-3c5f01dbda23@linaro.org Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This commit is contained in:
committed by
Sebastian Reichel
parent
83a86e27c3
commit
c10b68e331
@@ -89,6 +89,7 @@ static enum power_supply_property max17042_battery_props[] = {
|
|||||||
POWER_SUPPLY_PROP_HEALTH,
|
POWER_SUPPLY_PROP_HEALTH,
|
||||||
POWER_SUPPLY_PROP_SCOPE,
|
POWER_SUPPLY_PROP_SCOPE,
|
||||||
POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW,
|
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
|
// these two have to be at the end on the list
|
||||||
POWER_SUPPLY_PROP_CURRENT_NOW,
|
POWER_SUPPLY_PROP_CURRENT_NOW,
|
||||||
POWER_SUPPLY_PROP_CURRENT_AVG,
|
POWER_SUPPLY_PROP_CURRENT_AVG,
|
||||||
@@ -443,6 +444,21 @@ static int max17042_get_property(struct power_supply *psy,
|
|||||||
if (data == U16_MAX)
|
if (data == U16_MAX)
|
||||||
return -ENODATA;
|
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;
|
val->intval = data * 5625 / 1000;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user