From 63a0a53eabdd89a608c3ebadde4bf4a0ae386fba Mon Sep 17 00:00:00 2001 From: Jianhong Chen Date: Wed, 10 Aug 2016 21:08:13 +0800 Subject: [PATCH] power: rk818-battery: add POWER_SUPPLY_PROP_STATUS report property Change-Id: Ie301f934e8f8cf88702d89b733d7006bbf1ed023 Signed-off-by: Jianhong Chen --- drivers/power/rk818_battery.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/power/rk818_battery.c b/drivers/power/rk818_battery.c index 6e824836b761..618145eaa0e3 100644 --- a/drivers/power/rk818_battery.c +++ b/drivers/power/rk818_battery.c @@ -80,6 +80,7 @@ module_param_named(dbg_level, dbg_enable, int, 0644); #define VIRTUAL_SOC 66 #define VIRTUAL_PRESET 1 #define VIRTUAL_TEMPERATURE 188 +#define VIRTUAL_STATUS POWER_SUPPLY_STATUS_CHARGING /* charge */ #define FINISH_CHRG_CUR 1000 @@ -830,6 +831,7 @@ static enum power_supply_property rk818_bat_props[] = { POWER_SUPPLY_PROP_HEALTH, POWER_SUPPLY_PROP_CAPACITY, POWER_SUPPLY_PROP_TEMP, + POWER_SUPPLY_PROP_STATUS, }; static int rk818_battery_get_property(struct power_supply *psy, @@ -868,6 +870,16 @@ static int rk818_battery_get_property(struct power_supply *psy, if (di->pdata->bat_mode == MODE_VIRTUAL) val->intval = VIRTUAL_TEMPERATURE; break; + case POWER_SUPPLY_PROP_STATUS: + if (di->pdata->bat_mode == MODE_VIRTUAL) + val->intval = VIRTUAL_STATUS; + else if (di->dsoc == 100) + val->intval = POWER_SUPPLY_STATUS_FULL; + else if (rk818_bat_chrg_online(di)) + val->intval = POWER_SUPPLY_STATUS_CHARGING; + else + val->intval = POWER_SUPPLY_STATUS_DISCHARGING; + break; default: return -EINVAL; } -- 2.34.1