pcf50633: properly reenable charging when the supply conditions change
authorPaul Fertser <fercerpav@gmail.com>
Wed, 29 Jul 2009 14:09:20 +0000 (18:09 +0400)
committerPaul Fertser <fercerpav@gmail.com>
Sun, 2 Aug 2009 07:27:19 +0000 (11:27 +0400)
If chgmod == BATFULL, setting chgena has no effect. Datasheet says we
need to set resume instead but when autoresume is used resume doesn't
work. Clear and set chgena instead.

This enables a user to force charging by re-plugging USB even when the
charger entered Battery Full mode, might be handy before a long trip.

Signed-off-by: Paul Fertser <fercerpav@gmail.com>
drivers/power/pcf50633-charger.c

index cda0c67..5b5fe80 100644 (file)
@@ -90,14 +90,18 @@ int pcf50633_mbc_usb_curlim_set(struct pcf50633 *pcf, int ma)
        chgmod = (mbcs2 & PCF50633_MBCS2_MBC_MASK);
 
        /* If chgmod == BATFULL, setting chgena has no effect.
-        * We need to set resume instead.
+        * Datasheet says we need to set resume instead but when autoresume is
+        * used resume doesn't work. Clear and set chgena instead.
         */
        if (chgmod != PCF50633_MBCS2_MBC_BAT_FULL)
                pcf50633_reg_set_bit_mask(pcf, PCF50633_REG_MBCC1,
                                PCF50633_MBCC1_CHGENA, PCF50633_MBCC1_CHGENA);
-       else
+       else {
+               pcf50633_reg_clear_bits(pcf, PCF50633_REG_MBCC1,
+                               PCF50633_MBCC1_CHGENA);
                pcf50633_reg_set_bit_mask(pcf, PCF50633_REG_MBCC1,
-                               PCF50633_MBCC1_RESUME, PCF50633_MBCC1_RESUME);
+                               PCF50633_MBCC1_CHGENA, PCF50633_MBCC1_CHGENA);
+       }
 
        mbc->usb_active = charging_start;