power: max17048: Forced power off when VCELL < VALRT.MIN.
Hyongbin Kim [Mon, 3 Jun 2013 07:51:56 +0000 (16:51 +0900)]
When SOC is low and system drain too much current, it makes
system hangup due to voltage drop. When VALRT occurs, set
forced SOC to 0% for power off.

Bug 1245249
Bug 1298560

Change-Id: I5057f762b9ec32f530a09a5c03df253ae3cbbad0
Signed-off-by: Hyongbin Kim <hyongbink@nvidia.com>
Reviewed-on: http://git-master/r/234912
(cherry picked from commit b673440eb08f62ad31cfa098bbed413e5df4efe0)
Reviewed-on: http://git-master/r/235252
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>

drivers/power/max17048_battery.c

index 20345d2..11ac7bb 100644 (file)
@@ -518,11 +518,20 @@ static irqreturn_t max17048_irq(int id, void *dev)
                dev_info(&client->dev, "%s(): STATUS_RI\n", __func__);
        if (val & MAX17048_STATUS_VH)
                dev_info(&client->dev, "%s(): STATUS_VH\n", __func__);
-       if (val & MAX17048_STATUS_VL)
+       if (val & MAX17048_STATUS_VL) {
                dev_info(&client->dev, "%s(): STATUS_VL\n", __func__);
+               /* Forced set SOC 0 to power off */
+               chip->soc = 0;
+               chip->lasttime_soc = chip->soc;
+               chip->status = chip->lasttime_status;
+               chip->health = POWER_SUPPLY_HEALTH_DEAD;
+               chip->capacity_level = POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL;
+               power_supply_changed(&chip->battery);
+       }
        if (val & MAX17048_STATUS_VR)
                dev_info(&client->dev, "%s(): STATUS_VR\n", __func__);
        if (val & MAX17048_STATUS_HD) {
+               max17048_get_vcell(client);
                max17048_get_soc(client);
                chip->lasttime_soc = chip->soc;
                dev_info(&client->dev,
@@ -531,6 +540,7 @@ static irqreturn_t max17048_irq(int id, void *dev)
                power_supply_changed(&chip->battery);
        }
        if (val & MAX17048_STATUS_SC) {
+               max17048_get_vcell(client);
                max17048_get_soc(client);
                chip->lasttime_soc = chip->soc;
                dev_info(&client->dev,