mfd: tps80031: turn on backup battery charger circuit
Tom Cherry [Fri, 18 May 2012 21:00:51 +0000 (14:00 -0700)]
The backup battery for the RTC circuit needs to be manually turned
on.  This change turns it on when the driver is first probed, off
during LP0 to prevent excess power draw, and back on again upon
resume.

Bug 986402

Change-Id: Id4768929d6a73546662806f04d98d714997174b0
Signed-off-by: Tom Cherry <tcherry@nvidia.com>
Reviewed-on: http://git-master/r/103425
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>

drivers/mfd/tps80031.c

index 94ba777..f0f2ce1 100644 (file)
 #define TPS80031_CFG_INPUT_PUPD3 0xF2
 #define TPS80031_CFG_INPUT_PUPD4 0xF3
 
+#define TPS80031_BBSPOR_CFG    0xE6
+#define TPS80031_BBSPOR_CHG_EN 0x8
+
 struct tps80031_pupd_data {
        u8      reg;
        u8      pullup_bit;
@@ -568,6 +571,17 @@ static void tps80031_pupd_init(struct tps80031 *tps80031,
        }
 }
 
+static void tps80031_backup_battery_charger_control(struct tps80031 *tps80031,
+                                                   int enable)
+{
+       if (enable)
+               tps80031_update(tps80031->dev, SLAVE_ID1, TPS80031_BBSPOR_CFG,
+                               TPS80031_BBSPOR_CHG_EN, TPS80031_BBSPOR_CHG_EN);
+       else
+               tps80031_update(tps80031->dev, SLAVE_ID1, TPS80031_BBSPOR_CFG,
+                               0, TPS80031_BBSPOR_CHG_EN);
+}
+
 static void tps80031_init_ext_control(struct tps80031 *tps80031,
                        struct tps80031_platform_data *pdata) {
        int ret;
@@ -1287,6 +1301,8 @@ static int __devinit tps80031_i2c_probe(struct i2c_client *client,
 
        tps80031_debuginit(tps80031);
 
+       tps80031_backup_battery_charger_control(tps80031, 1);
+
        if (pdata->use_power_off && !pm_power_off)
                pm_power_off = tps80031_power_off;
 
@@ -1302,13 +1318,17 @@ fail:
 #ifdef CONFIG_PM
 static int tps80031_i2c_suspend(struct i2c_client *client, pm_message_t state)
 {
+       struct tps80031 *tps80031 = i2c_get_clientdata(client);
        if (client->irq)
                disable_irq(client->irq);
+       tps80031_backup_battery_charger_control(tps80031, 0);
        return 0;
 }
 
 static int tps80031_i2c_resume(struct i2c_client *client)
 {
+       struct tps80031 *tps80031 = i2c_get_clientdata(client);
+       tps80031_backup_battery_charger_control(tps80031, 1);
        if (client->irq)
                enable_irq(client->irq);
        return 0;