aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/mfd/wm8350-regmap.c2
-rw-r--r--drivers/power/wm8350_power.c33
-rw-r--r--include/linux/mfd/wm8350/core.h7
3 files changed, 33 insertions, 9 deletions
diff --git a/drivers/mfd/wm8350-regmap.c b/drivers/mfd/wm8350-regmap.c
index aaf394aa9c2d..b43d64c2b920 100644
--- a/drivers/mfd/wm8350-regmap.c
+++ b/drivers/mfd/wm8350-regmap.c
@@ -1314,7 +1314,7 @@ const struct wm8350_reg_access wm8350_reg_io_map[] = {
1314 { 0xFFFF, 0xFFFF, 0xFFFF }, /* R223 */ 1314 { 0xFFFF, 0xFFFF, 0xFFFF }, /* R223 */
1315 { 0x0000, 0x0000, 0x0000 }, /* R224 */ 1315 { 0x0000, 0x0000, 0x0000 }, /* R224 */
1316 { 0x8F3F, 0x0000, 0xFFFF }, /* R225 - DCDC/LDO status */ 1316 { 0x8F3F, 0x0000, 0xFFFF }, /* R225 - DCDC/LDO status */
1317 { 0x0000, 0x0000, 0x0000 }, /* R226 */ 1317 { 0x0000, 0x0000, 0xFFFF }, /* R226 - Charger status */
1318 { 0x0000, 0x0000, 0xFFFF }, /* R227 */ 1318 { 0x0000, 0x0000, 0xFFFF }, /* R227 */
1319 { 0x0000, 0x0000, 0x0000 }, /* R228 */ 1319 { 0x0000, 0x0000, 0x0000 }, /* R228 */
1320 { 0x0000, 0x0000, 0x0000 }, /* R229 */ 1320 { 0x0000, 0x0000, 0x0000 }, /* R229 */
diff --git a/drivers/power/wm8350_power.c b/drivers/power/wm8350_power.c
index 74e7593beffb..1b16bf343f2f 100644
--- a/drivers/power/wm8350_power.c
+++ b/drivers/power/wm8350_power.c
@@ -190,22 +190,18 @@ static void wm8350_charger_handler(struct wm8350 *wm8350, int irq, void *data)
190 struct wm8350_charger_policy *policy = power->policy; 190 struct wm8350_charger_policy *policy = power->policy;
191 191
192 switch (irq) { 192 switch (irq) {
193 case WM8350_IRQ_CHG_BAT_HOT:
194 dev_err(wm8350->dev, "battery too hot\n");
195 break;
196 case WM8350_IRQ_CHG_BAT_COLD:
197 dev_err(wm8350->dev, "battery too cold\n");
198 break;
199 case WM8350_IRQ_CHG_BAT_FAIL: 193 case WM8350_IRQ_CHG_BAT_FAIL:
200 dev_err(wm8350->dev, "battery failed\n"); 194 dev_err(wm8350->dev, "battery failed\n");
201 break; 195 break;
202 case WM8350_IRQ_CHG_TO: 196 case WM8350_IRQ_CHG_TO:
203 dev_err(wm8350->dev, "charger timeout\n"); 197 dev_err(wm8350->dev, "charger timeout\n");
204 break;
205 case WM8350_IRQ_CHG_END:
206 power_supply_changed(&power->battery); 198 power_supply_changed(&power->battery);
207 break; 199 break;
200
201 case WM8350_IRQ_CHG_BAT_HOT:
202 case WM8350_IRQ_CHG_BAT_COLD:
208 case WM8350_IRQ_CHG_START: 203 case WM8350_IRQ_CHG_START:
204 case WM8350_IRQ_CHG_END:
209 power_supply_changed(&power->battery); 205 power_supply_changed(&power->battery);
210 break; 206 break;
211 207
@@ -308,6 +304,23 @@ static enum power_supply_property wm8350_usb_props[] = {
308 * Battery properties 304 * Battery properties
309 *********************************************************************/ 305 *********************************************************************/
310 306
307static int wm8350_bat_check_health(struct wm8350 *wm8350)
308{
309 u16 reg;
310
311 if (wm8350_read_battery_uvolts(wm8350) < 2850000)
312 return POWER_SUPPLY_HEALTH_UNSPEC_FAILURE;
313
314 reg = wm8350_reg_read(wm8350, WM8350_CHARGER_OVERRIDES);
315 if (reg & WM8350_CHG_BATT_HOT_OVRDE)
316 return POWER_SUPPLY_HEALTH_OVERHEAT;
317
318 if (reg & WM8350_CHG_BATT_COLD_OVRDE)
319 return POWER_SUPPLY_HEALTH_COLD;
320
321 return POWER_SUPPLY_HEALTH_GOOD;
322}
323
311static int wm8350_bat_get_property(struct power_supply *psy, 324static int wm8350_bat_get_property(struct power_supply *psy,
312 enum power_supply_property psp, 325 enum power_supply_property psp,
313 union power_supply_propval *val) 326 union power_supply_propval *val)
@@ -326,6 +339,9 @@ static int wm8350_bat_get_property(struct power_supply *psy,
326 case POWER_SUPPLY_PROP_VOLTAGE_NOW: 339 case POWER_SUPPLY_PROP_VOLTAGE_NOW:
327 val->intval = wm8350_read_battery_uvolts(wm8350); 340 val->intval = wm8350_read_battery_uvolts(wm8350);
328 break; 341 break;
342 case POWER_SUPPLY_PROP_HEALTH:
343 val->intval = wm8350_bat_check_health(wm8350);
344 break;
329 default: 345 default:
330 ret = -EINVAL; 346 ret = -EINVAL;
331 break; 347 break;
@@ -338,6 +354,7 @@ static enum power_supply_property wm8350_bat_props[] = {
338 POWER_SUPPLY_PROP_STATUS, 354 POWER_SUPPLY_PROP_STATUS,
339 POWER_SUPPLY_PROP_ONLINE, 355 POWER_SUPPLY_PROP_ONLINE,
340 POWER_SUPPLY_PROP_VOLTAGE_NOW, 356 POWER_SUPPLY_PROP_VOLTAGE_NOW,
357 POWER_SUPPLY_PROP_HEALTH,
341}; 358};
342 359
343/********************************************************************* 360/*********************************************************************
diff --git a/include/linux/mfd/wm8350/core.h b/include/linux/mfd/wm8350/core.h
index 2a7abeebe777..afeff6f1316c 100644
--- a/include/linux/mfd/wm8350/core.h
+++ b/include/linux/mfd/wm8350/core.h
@@ -58,6 +58,7 @@
58#define WM8350_OVER_CURRENT_INT_STATUS_MASK 0x25 58#define WM8350_OVER_CURRENT_INT_STATUS_MASK 0x25
59#define WM8350_GPIO_INT_STATUS_MASK 0x26 59#define WM8350_GPIO_INT_STATUS_MASK 0x26
60#define WM8350_COMPARATOR_INT_STATUS_MASK 0x27 60#define WM8350_COMPARATOR_INT_STATUS_MASK 0x27
61#define WM8350_CHARGER_OVERRIDES 0xE2
61#define WM8350_MISC_OVERRIDES 0xE3 62#define WM8350_MISC_OVERRIDES 0xE3
62#define WM8350_COMPARATOR_OVERRIDES 0xE7 63#define WM8350_COMPARATOR_OVERRIDES 0xE7
63#define WM8350_STATE_MACHINE_STATUS 0xE9 64#define WM8350_STATE_MACHINE_STATUS 0xE9
@@ -533,6 +534,12 @@
533#define WM8350_DC1_STS 0x0001 534#define WM8350_DC1_STS 0x0001
534 535
535/* 536/*
537 * R226 (0xE2) - Charger status
538 */
539#define WM8350_CHG_BATT_HOT_OVRDE 0x8000
540#define WM8350_CHG_BATT_COLD_OVRDE 0x4000
541
542/*
536 * R227 (0xE3) - Misc Overrides 543 * R227 (0xE3) - Misc Overrides
537 */ 544 */
538#define WM8350_USB_LIMIT_OVRDE 0x0400 545#define WM8350_USB_LIMIT_OVRDE 0x0400