aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power
diff options
context:
space:
mode:
authorNicolas Guion <nicolas.guion@stericsson.com>2012-05-23 09:59:43 -0400
committerLee Jones <lee.jones@linaro.org>2013-01-23 09:39:17 -0500
commitb016322293c7e3b7efb1835603d149c03d00b0df (patch)
treedbbff0317c7660f86d1fbe91886adef5f1ac4334 /drivers/power
parentc9ade0fca3f7939194677353097b16c9795df46b (diff)
ab8500-charger: Add support for autopower on AB8505 and AB9540
Accessing autopower register fails on the AB8505 and ab9540 as the fallback software control register has moved. Signed-off-by: Marcus Cooper <marcus.xm.cooper@stericsson.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Reviewed-by: Mattias WALLIN <mattias.wallin@stericsson.com> Reviewed-by: Nicolas GUION <nicolas.guion@stericsson.com> Reviewed-by: Jonas ABERG <jonas.aberg@stericsson.com> Tested-by: Jonas ABERG <jonas.aberg@stericsson.com>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/ab8500_charger.c52
1 files changed, 35 insertions, 17 deletions
diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c
index d834566410bc..da965ee615cc 100644
--- a/drivers/power/ab8500_charger.c
+++ b/drivers/power/ab8500_charger.c
@@ -95,6 +95,8 @@
95 95
96#define CHG_WD_INTERVAL (60 * HZ) 96#define CHG_WD_INTERVAL (60 * HZ)
97 97
98#define AB8500_SW_CONTROL_FALLBACK 0x03
99
98/* UsbLineStatus register - usb types */ 100/* UsbLineStatus register - usb types */
99enum ab8500_charger_link_status { 101enum ab8500_charger_link_status {
100 USB_STAT_NOT_CONFIGURED, 102 USB_STAT_NOT_CONFIGURED,
@@ -312,42 +314,58 @@ static enum power_supply_property ab8500_charger_usb_props[] = {
312static void ab8500_enable_disable_sw_fallback(struct ab8500_charger *di, 314static void ab8500_enable_disable_sw_fallback(struct ab8500_charger *di,
313 bool fallback) 315 bool fallback)
314{ 316{
317 u8 val;
315 u8 reg; 318 u8 reg;
319 u8 bank;
320 u8 bit;
316 int ret; 321 int ret;
317 322
318 dev_dbg(di->dev, "SW Fallback: %d\n", fallback); 323 dev_dbg(di->dev, "SW Fallback: %d\n", fallback);
319 324
325 if (is_ab8500(di->parent)) {
326 bank = 0x15;
327 reg = 0x0;
328 bit = 3;
329 } else {
330 bank = AB8500_SYS_CTRL1_BLOCK;
331 reg = AB8500_SW_CONTROL_FALLBACK;
332 bit = 0;
333 }
334
320 /* read the register containing fallback bit */ 335 /* read the register containing fallback bit */
321 ret = abx500_get_register_interruptible(di->dev, 0x15, 0x00, &reg); 336 ret = abx500_get_register_interruptible(di->dev, bank, reg, &val);
322 if (ret) { 337 if (ret < 0) {
323 dev_err(di->dev, "%d write failed\n", __LINE__); 338 dev_err(di->dev, "%d read failed\n", __LINE__);
324 return; 339 return;
325 } 340 }
326 341
327 /* enable the OPT emulation registers */ 342 if (is_ab8500(di->parent)) {
328 ret = abx500_set_register_interruptible(di->dev, 0x11, 0x00, 0x2); 343 /* enable the OPT emulation registers */
329 if (ret) { 344 ret = abx500_set_register_interruptible(di->dev, 0x11, 0x00, 0x2);
330 dev_err(di->dev, "%d write failed\n", __LINE__); 345 if (ret) {
331 return; 346 dev_err(di->dev, "%d write failed\n", __LINE__);
347 goto disable_otp;
348 }
332 } 349 }
333 350
334 if (fallback) 351 if (fallback)
335 reg |= 0x8; 352 val |= (1 << bit);
336 else 353 else
337 reg &= ~0x8; 354 val &= ~(1 << bit);
338 355
339 /* write back the changed fallback bit value to register */ 356 /* write back the changed fallback bit value to register */
340 ret = abx500_set_register_interruptible(di->dev, 0x15, 0x00, reg); 357 ret = abx500_set_register_interruptible(di->dev, bank, reg, val);
341 if (ret) { 358 if (ret) {
342 dev_err(di->dev, "%d write failed\n", __LINE__); 359 dev_err(di->dev, "%d write failed\n", __LINE__);
343 return;
344 } 360 }
345 361
346 /* disable the set OTP registers again */ 362disable_otp:
347 ret = abx500_set_register_interruptible(di->dev, 0x11, 0x00, 0x0); 363 if (is_ab8500(di->parent)) {
348 if (ret) { 364 /* disable the set OTP registers again */
349 dev_err(di->dev, "%d write failed\n", __LINE__); 365 ret = abx500_set_register_interruptible(di->dev, 0x11, 0x00, 0x0);
350 return; 366 if (ret) {
367 dev_err(di->dev, "%d write failed\n", __LINE__);
368 }
351 } 369 }
352} 370}
353 371