regulator: palmas: make sure disable boost during suspend for SMPS10
Laxman Dewangan [Tue, 18 Jun 2013 11:11:57 +0000 (16:11 +0530)]
If flag for SMPS10 has the disable_boost_on_suspend is true then
make sure that boost of SMPS10 is disabled.

If any regulator is using this then defer the boost disable and
disable when client actually disable the smps10.

bug 1291841

Change-Id: Ia03d29f68132f87b970d4df8402b3cdd4dba95df
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: http://git-master/r/239722
Reviewed-by: Riham Haidar <rhaidar@nvidia.com>
Tested-by: Riham Haidar <rhaidar@nvidia.com>

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

index c1e7af8..1d8a0d5 100644 (file)
@@ -232,6 +232,9 @@ static unsigned int palmas_smps_ramp_delay[4] = {0, 10000, 5000, 2500};
 
 #define REGULATOR_SLAVE                        0
 
+static void palmas_disable_smps10_boost(struct palmas *palmas);
+static void palmas_enable_smps10_boost(struct palmas *palmas);
+
 static int palmas_smps_read(struct palmas *palmas, unsigned int reg,
                unsigned int *dest)
 {
@@ -625,6 +628,7 @@ static int palmas_enable_smps10(struct regulator_dev *dev)
                dev_err(pmic->palmas->dev,
                        "Error in writing smps10 control reg\n");
 
+       palmas_enable_smps10_boost(pmic->palmas);
        pmic->smps10_regulator_enabled = true;
        return ret;
 }
@@ -654,6 +658,12 @@ static int palmas_disable_smps10(struct regulator_dev *dev)
                dev_err(pmic->palmas->dev,
                        "Error in writing smps10 control reg\n");
        pmic->smps10_regulator_enabled = false;
+
+       if (pmic->smps10_boost_disable_deferred) {
+               palmas_disable_smps10_boost(pmic->palmas);
+               pmic->smps10_boost_disable_deferred = false;
+       }
+
        return ret;
 }
 
@@ -1568,9 +1578,12 @@ static int palmas_suspend(struct device *dev)
        if (pdata->enable_ldo8_tracking && pdata->disabe_ldo8_tracking_suspend)
                palmas_disable_ldo8_track(palmas);
 
-       if (pdata->disable_smps10_boost_suspend &&
-                       !pmic->smps10_regulator_enabled)
-               palmas_disable_smps10_boost(palmas);
+       if (pdata->disable_smps10_boost_suspend) {
+               if (!pmic->smps10_regulator_enabled)
+                       palmas_disable_smps10_boost(palmas);
+               else
+                       pmic->smps10_boost_disable_deferred = true;
+       }
 
        for (id = 0; id < PALMAS_NUM_REGS; id++) {
                if (pmic->config_flags[id] &
index 50a19ad..60b93cb 100644 (file)
@@ -315,6 +315,7 @@ struct palmas_pmic {
        int smps123;
        int smps457;
        bool smps10_regulator_enabled;
+       bool smps10_boost_disable_deferred;
 
        unsigned int ramp_delay[PALMAS_NUM_REGS];
        unsigned int current_mode_reg[PALMAS_NUM_REGS];