diff options
author | Geordan Neukum <gneukum1@gmail.com> | 2020-03-30 08:33:55 +0300 |
---|---|---|
committer | Sebastian Reichel <sebastian.reichel@collabora.com> | 2020-04-29 21:12:46 +0300 |
commit | 21b01cc879cc3ecef013b3576db2925adfd881aa (patch) | |
tree | a456cc5e1da5c3c3935a976c4e4ad2c0592740d3 /drivers/power/supply/max17042_battery.c | |
parent | aa86e90794c8a76c38f2897aff6c1eaa3b96bba6 (diff) | |
download | linux-21b01cc879cc3ecef013b3576db2925adfd881aa.tar.xz |
power: supply: max17042_battery: Add support for the TTE_NOW prop
The max170{42,47,50,55} family of fuel gauges all provide time-to-empty
estimation. As such, let's export this as a property.
Signed-off-by: Geordan Neukum <gneukum1@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Diffstat (limited to 'drivers/power/supply/max17042_battery.c')
-rw-r--r-- | drivers/power/supply/max17042_battery.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c index 69ec4295d55d..f284547913d6 100644 --- a/drivers/power/supply/max17042_battery.c +++ b/drivers/power/supply/max17042_battery.c @@ -87,6 +87,7 @@ static enum power_supply_property max17042_battery_props[] = { POWER_SUPPLY_PROP_SCOPE, POWER_SUPPLY_PROP_CURRENT_NOW, POWER_SUPPLY_PROP_CURRENT_AVG, + POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW, }; static int max17042_get_temperature(struct max17042_chip *chip, int *temp) @@ -411,6 +412,13 @@ static int max17042_get_property(struct power_supply *psy, return -EINVAL; } break; + case POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW: + ret = regmap_read(map, MAX17042_TTE, &data); + if (ret < 0) + return ret; + + val->intval = data * 5625 / 1000; + break; default: return -EINVAL; } |