Skip to content

Commit 079cdff

Browse files
akemnadesre
authored andcommitted
power: supply: twl4030_charger: disable eoc interrupt on linear charge
This avoids getting woken up from suspend after power interruptions when the bci wrongly thinks the battery is full just because of input current going low because of low input power Signed-off-by: Andreas Kemnade <andreas@kemnade.info> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
1 parent 8314c21 commit 079cdff

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

drivers/power/supply/twl4030_charger.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@ static void twl4030_current_worker(struct work_struct *data)
440440
static int twl4030_charger_enable_usb(struct twl4030_bci *bci, bool enable)
441441
{
442442
int ret;
443+
u32 reg;
443444

444445
if (bci->usb_mode == CHARGE_OFF)
445446
enable = false;
@@ -453,14 +454,38 @@ static int twl4030_charger_enable_usb(struct twl4030_bci *bci, bool enable)
453454
bci->usb_enabled = 1;
454455
}
455456

456-
if (bci->usb_mode == CHARGE_AUTO)
457+
if (bci->usb_mode == CHARGE_AUTO) {
458+
/* Enable interrupts now. */
459+
reg = ~(u32)(TWL4030_ICHGLOW | TWL4030_ICHGEOC |
460+
TWL4030_TBATOR2 | TWL4030_TBATOR1 |
461+
TWL4030_BATSTS);
462+
ret = twl_i2c_write_u8(TWL4030_MODULE_INTERRUPTS, reg,
463+
TWL4030_INTERRUPTS_BCIIMR1A);
464+
if (ret < 0) {
465+
dev_err(bci->dev,
466+
"failed to unmask interrupts: %d\n",
467+
ret);
468+
return ret;
469+
}
457470
/* forcing the field BCIAUTOUSB (BOOT_BCI[1]) to 1 */
458471
ret = twl4030_clear_set_boot_bci(0, TWL4030_BCIAUTOUSB);
472+
}
459473

460474
/* forcing USBFASTMCHG(BCIMFSTS4[2]) to 1 */
461475
ret = twl4030_clear_set(TWL_MODULE_MAIN_CHARGE, 0,
462476
TWL4030_USBFASTMCHG, TWL4030_BCIMFSTS4);
463477
if (bci->usb_mode == CHARGE_LINEAR) {
478+
/* Enable interrupts now. */
479+
reg = ~(u32)(TWL4030_ICHGLOW | TWL4030_TBATOR2 |
480+
TWL4030_TBATOR1 | TWL4030_BATSTS);
481+
ret = twl_i2c_write_u8(TWL4030_MODULE_INTERRUPTS, reg,
482+
TWL4030_INTERRUPTS_BCIIMR1A);
483+
if (ret < 0) {
484+
dev_err(bci->dev,
485+
"failed to unmask interrupts: %d\n",
486+
ret);
487+
return ret;
488+
}
464489
twl4030_clear_set_boot_bci(TWL4030_BCIAUTOAC|TWL4030_CVENAC, 0);
465490
/* Watch dog key: WOVF acknowledge */
466491
ret = twl_i2c_write_u8(TWL_MODULE_MAIN_CHARGE, 0x33,

0 commit comments

Comments
 (0)