aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/power/wm8350_power.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/power/wm8350_power.c b/drivers/power/wm8350_power.c
index 1b16bf343f2f..28b0299c0043 100644
--- a/drivers/power/wm8350_power.c
+++ b/drivers/power/wm8350_power.c
@@ -321,6 +321,24 @@ static int wm8350_bat_check_health(struct wm8350 *wm8350)
321 return POWER_SUPPLY_HEALTH_GOOD; 321 return POWER_SUPPLY_HEALTH_GOOD;
322} 322}
323 323
324static int wm8350_bat_get_charge_type(struct wm8350 *wm8350)
325{
326 int state;
327
328 state = wm8350_reg_read(wm8350, WM8350_BATTERY_CHARGER_CONTROL_2) &
329 WM8350_CHG_STS_MASK;
330 switch (state) {
331 case WM8350_CHG_STS_OFF:
332 return POWER_SUPPLY_CHARGE_TYPE_NONE;
333 case WM8350_CHG_STS_TRICKLE:
334 return POWER_SUPPLY_CHARGE_TYPE_TRICKLE;
335 case WM8350_CHG_STS_FAST:
336 return POWER_SUPPLY_CHARGE_TYPE_FAST;
337 default:
338 return POWER_SUPPLY_CHARGE_TYPE_UNKNOWN;
339 }
340}
341
324static int wm8350_bat_get_property(struct power_supply *psy, 342static int wm8350_bat_get_property(struct power_supply *psy,
325 enum power_supply_property psp, 343 enum power_supply_property psp,
326 union power_supply_propval *val) 344 union power_supply_propval *val)
@@ -342,6 +360,9 @@ static int wm8350_bat_get_property(struct power_supply *psy,
342 case POWER_SUPPLY_PROP_HEALTH: 360 case POWER_SUPPLY_PROP_HEALTH:
343 val->intval = wm8350_bat_check_health(wm8350); 361 val->intval = wm8350_bat_check_health(wm8350);
344 break; 362 break;
363 case POWER_SUPPLY_PROP_CHARGE_TYPE:
364 val->intval = wm8350_bat_get_charge_type(wm8350);
365 break;
345 default: 366 default:
346 ret = -EINVAL; 367 ret = -EINVAL;
347 break; 368 break;
@@ -355,6 +376,7 @@ static enum power_supply_property wm8350_bat_props[] = {
355 POWER_SUPPLY_PROP_ONLINE, 376 POWER_SUPPLY_PROP_ONLINE,
356 POWER_SUPPLY_PROP_VOLTAGE_NOW, 377 POWER_SUPPLY_PROP_VOLTAGE_NOW,
357 POWER_SUPPLY_PROP_HEALTH, 378 POWER_SUPPLY_PROP_HEALTH,
379 POWER_SUPPLY_PROP_CHARGE_TYPE,
358}; 380};
359 381
360/********************************************************************* 382/*********************************************************************