summaryrefslogtreecommitdiff
path: root/drivers/power
diff options
context:
space:
mode:
authorBaolin Wang <baolin.wang7@gmail.com>2020-02-14 13:38:58 +0800
committerSebastian Reichel <sebastian.reichel@collabora.com>2020-02-24 18:09:30 +0100
commit1c5dfc5e3f2df5892a849621d729daa87cfef436 (patch)
tree92a48f52614439e23bf8f545e608e5d843bc81d6 /drivers/power
parent5b11e5d784c2dab41cd3171f4d297bdcac1b85ed (diff)
downloadlwn-1c5dfc5e3f2df5892a849621d729daa87cfef436.tar.gz
lwn-1c5dfc5e3f2df5892a849621d729daa87cfef436.zip
power: supply: sc27xx: Add POWER_SUPPLY_PROP_CHARGE_NOW attribute
Add the POWER_SUPPLY_PROP_CHARGE_NOW attribute to allow user to get current battery capacity (uAh) to do measurement. Signed-off-by: Baolin Wang <baolin.wang7@gmail.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/supply/sc27xx_fuel_gauge.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/power/supply/sc27xx_fuel_gauge.c b/drivers/power/supply/sc27xx_fuel_gauge.c
index 469c83fdaa8e..a7c8a8453db1 100644
--- a/drivers/power/supply/sc27xx_fuel_gauge.c
+++ b/drivers/power/supply/sc27xx_fuel_gauge.c
@@ -614,6 +614,17 @@ static int sc27xx_fgu_get_property(struct power_supply *psy,
val->intval = data->total_cap * 1000;
break;
+ case POWER_SUPPLY_PROP_CHARGE_NOW:
+ ret = sc27xx_fgu_get_clbcnt(data, &value);
+ if (ret)
+ goto error;
+
+ value = DIV_ROUND_CLOSEST(value * 10,
+ 36 * SC27XX_FGU_SAMPLE_HZ);
+ val->intval = sc27xx_fgu_adc_to_current(data, value);
+
+ break;
+
default:
ret = -EINVAL;
break;
@@ -682,6 +693,7 @@ static enum power_supply_property sc27xx_fgu_props[] = {
POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE,
POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN,
POWER_SUPPLY_PROP_CALIBRATE,
+ POWER_SUPPLY_PROP_CHARGE_NOW
};
static const struct power_supply_desc sc27xx_fgu_desc = {