power: ds2781: Add voltage check before 100% reset
authorGreg Meiste <w30289@motorola.com>
Mon, 25 Apr 2011 23:06:50 +0000 (18:06 -0500)
committerRebecca Schultz Zavin <rebecca@android.com>
Wed, 27 Apr 2011 23:41:45 +0000 (16:41 -0700)
Sanity check the voltage before performing the 100% coulumb
counter reset. This will prevent an inadvertent reset in case
charge complete is reported incorrectly by the system.

Change-Id: Iadcfbd13dee8bd1ce0bdc4186f1490c90d75251a
Signed-off-by: Greg Meiste <w30289@motorola.com>
drivers/power/ds2781_battery.c

index 5916eea69103f6d663850f54a3d0f9202ceac630..0b2d78a416c3e6ad1fcab79a99a040241f01842b 100644 (file)
@@ -72,6 +72,12 @@ struct battery_status {
 #define THRES_BATT      7500000
 #define THRES_CHRG      7750000
 
+/* When charge complete is reached, a sanity check is performed on the reported
+ * capacity. If the capacity is less than 100, but the battery voltage is above
+ * THRES_100_RESET, the ACR will be reset to full capacity.
+ */
+#define THRES_100_RESET 8320000
+
 #define BATTERY_LOG_MAX 1024
 #define BATTERY_LOG_MASK (BATTERY_LOG_MAX - 1)
 
@@ -386,7 +392,8 @@ static void ds2781_reset_if_necessary(struct ds2781_device_info *di)
 {
        /* If we have read from the DS2781 and the percentage is not 100%,
         * the ACR should be reset. */
-       if (di->raw[DS2781_REG_RSNSP] && (di->status.percentage < 100)) {
+       if (di->raw[DS2781_REG_RSNSP] && (di->status.percentage < 100) &&
+           (di->status.voltage_uV > THRES_100_RESET)) {
                dev_err(di->dev, "Charge complete before 100 percent.\n");
                dev_err(di->dev, "Resetting ACR registers to Full 40 value.\n");