regulator: palmas: do not disable smps10 in suspend if is enabled by client
Mallikarjun Kasoju [Thu, 18 Apr 2013 13:00:38 +0000 (18:00 +0530)]
Do not disable the smps10 in suspend as part of boost suspend if client have
enabled it through regulator call and has not called regulator_disable.

bug 1266948

Change-Id: I27e5dfbd4a55b07ef5214ce2fd57eaa7e78dff5a
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Mallikarjun Kasoju <mkasoju@nvidia.com>
Reviewed-on: http://git-master/r/220551

drivers/regulator/palmas-regulator.c
include/linux/mfd/palmas.h

index 383eeb2..4948659 100644 (file)
@@ -603,6 +603,8 @@ static int palmas_enable_smps10(struct regulator_dev *dev)
        if (ret < 0)
                dev_err(pmic->palmas->dev,
                        "Error in writing smps10 control reg\n");
+
+       pmic->smps10_regulator_enabled = true;
        return ret;
 }
 
@@ -627,6 +629,7 @@ static int palmas_disable_smps10(struct regulator_dev *dev)
        if (ret < 0)
                dev_err(pmic->palmas->dev,
                        "Error in writing smps10 control reg\n");
+       pmic->smps10_regulator_enabled = false;
        return ret;
 }
 
@@ -1506,13 +1509,15 @@ static int __devexit palmas_remove(struct platform_device *pdev)
 static int palmas_suspend(struct device *dev)
 {
        struct palmas *palmas = dev_get_drvdata(dev->parent);
+       struct palmas_pmic *pmic = dev_get_drvdata(dev);
        struct palmas_pmic_platform_data *pdata = dev_get_platdata(dev);
 
        /* Check if LDO8 is in tracking mode disable in suspend or not */
        if (pdata->enable_ldo8_tracking && pdata->disabe_ldo8_tracking_suspend)
                palmas_disable_ldo8_track(palmas);
 
-       if (pdata->disable_smps10_boost_suspend)
+       if (pdata->disable_smps10_boost_suspend &&
+                       !pmic->smps10_regulator_enabled)
                palmas_disable_smps10_boost(palmas);
        return 0;
 }
@@ -1520,13 +1525,15 @@ static int palmas_suspend(struct device *dev)
 static int palmas_resume(struct device *dev)
 {
        struct palmas *palmas = dev_get_drvdata(dev->parent);
+       struct palmas_pmic *pmic = dev_get_drvdata(dev);
        struct palmas_pmic_platform_data *pdata = dev_get_platdata(dev);
 
        /* Check if LDO8 is in tracking mode disable in suspend or not */
        if (pdata->enable_ldo8_tracking && pdata->disabe_ldo8_tracking_suspend)
                palmas_enable_ldo8_track(palmas);
 
-       if (pdata->disable_smps10_boost_suspend)
+       if (pdata->disable_smps10_boost_suspend &&
+                       !pmic->smps10_regulator_enabled)
                palmas_enable_smps10_boost(palmas);
        return 0;
 }
index 28e65c0..43e3fa9 100644 (file)
@@ -303,6 +303,7 @@ struct palmas_pmic {
 
        int smps123;
        int smps457;
+       bool smps10_regulator_enabled;
 
        unsigned int ramp_delay[PALMAS_NUM_REGS];
        unsigned int current_mode_reg[PALMAS_NUM_REGS];