Commit 4aed03ae authored by Mark Brown's avatar Mark Brown Committed by Anton Vorontsov

wm8350_power: Implement charge type property

Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: default avatarAnton Vorontsov <cbouatmailru@gmail.com>
parent ee8076ed
...@@ -321,6 +321,24 @@ static int wm8350_bat_check_health(struct wm8350 *wm8350) ...@@ -321,6 +321,24 @@ static int wm8350_bat_check_health(struct wm8350 *wm8350)
return POWER_SUPPLY_HEALTH_GOOD; return POWER_SUPPLY_HEALTH_GOOD;
} }
static int wm8350_bat_get_charge_type(struct wm8350 *wm8350)
{
int state;
state = wm8350_reg_read(wm8350, WM8350_BATTERY_CHARGER_CONTROL_2) &
WM8350_CHG_STS_MASK;
switch (state) {
case WM8350_CHG_STS_OFF:
return POWER_SUPPLY_CHARGE_TYPE_NONE;
case WM8350_CHG_STS_TRICKLE:
return POWER_SUPPLY_CHARGE_TYPE_TRICKLE;
case WM8350_CHG_STS_FAST:
return POWER_SUPPLY_CHARGE_TYPE_FAST;
default:
return POWER_SUPPLY_CHARGE_TYPE_UNKNOWN;
}
}
static int wm8350_bat_get_property(struct power_supply *psy, static int wm8350_bat_get_property(struct power_supply *psy,
enum power_supply_property psp, enum power_supply_property psp,
union power_supply_propval *val) union power_supply_propval *val)
...@@ -342,6 +360,9 @@ static int wm8350_bat_get_property(struct power_supply *psy, ...@@ -342,6 +360,9 @@ static int wm8350_bat_get_property(struct power_supply *psy,
case POWER_SUPPLY_PROP_HEALTH: case POWER_SUPPLY_PROP_HEALTH:
val->intval = wm8350_bat_check_health(wm8350); val->intval = wm8350_bat_check_health(wm8350);
break; break;
case POWER_SUPPLY_PROP_CHARGE_TYPE:
val->intval = wm8350_bat_get_charge_type(wm8350);
break;
default: default:
ret = -EINVAL; ret = -EINVAL;
break; break;
...@@ -355,6 +376,7 @@ static enum power_supply_property wm8350_bat_props[] = { ...@@ -355,6 +376,7 @@ static enum power_supply_property wm8350_bat_props[] = {
POWER_SUPPLY_PROP_ONLINE, POWER_SUPPLY_PROP_ONLINE,
POWER_SUPPLY_PROP_VOLTAGE_NOW, POWER_SUPPLY_PROP_VOLTAGE_NOW,
POWER_SUPPLY_PROP_HEALTH, POWER_SUPPLY_PROP_HEALTH,
POWER_SUPPLY_PROP_CHARGE_TYPE,
}; };
/********************************************************************* /*********************************************************************
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment