power: max17048: Set default RCOMP when power off
Hyongbin Kim [Mon, 12 Aug 2013 10:46:55 +0000 (19:46 +0900)]
Reset to default RCOMP value when power off.

Bug 1341794

Change-Id: I4b5b4d375a39593c67bf38703e782ce2d1bec933
Signed-off-by: Hyongbin Kim <hyongbink@nvidia.com>
Reviewed-on: http://git-master/r/260486
(cherry picked from commit 8f74af093cd0e5859a9adce2b98ee0d316609a93)
Reviewed-on: http://git-master/r/289143
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Gabby Lee <galee@nvidia.com>

drivers/power/max17048_battery.c

index e4798e4..d8ee14e 100644 (file)
@@ -943,6 +943,26 @@ static int __devexit max17048_remove(struct i2c_client *client)
 static void max17048_shutdown(struct i2c_client *client)
 {
        struct max17048_chip *chip = i2c_get_clientdata(client);
+       struct max17048_battery_model *mdata = chip->pdata->model_data;
+       int ret, val;
+
+       /* reset RCOMP to default value */
+       val = max17048_read_word(client, MAX17048_CONFIG);
+       if (val < 0) {
+               dev_err(&client->dev,
+                               "%s(): Failed in reading register" \
+                               "MAX17048_CONFIG err %d\n",
+                                       __func__, val);
+       } else {
+               /* clear upper byte */
+               val &= 0xFF;
+               /* Apply defaut Rcomp value */
+               val |= (mdata->rcomp << 8);
+               ret = max17048_write_word(client, MAX17048_CONFIG, val);
+               if (ret < 0)
+                       dev_err(&client->dev,
+                               "failed set RCOMP\n");
+       }
 
        if (client->irq)
                disable_irq(client->irq);