regulator: palma: set ldo8 voltage before disabling tracking mode.
Laxman Dewangan [Mon, 1 Oct 2012 09:44:51 +0000 (14:44 +0530)]
When LDO8 is in tracking mode and want to disable tracking mode
then ldo8 voltage should be set before disabling tracking
mode as in tacking mode, the voltage selection value is double
than the non-tracking mode and it can spike high voltage
on the rail.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: http://git-master/r/140595
(cherry picked from commit cd0e02af8288bebccab92dcda27d6953b2a58955)

Signed-off-by: Pradeep Goudagunta <pgoudagunta@nvidia.com>
Change-Id: I322acccfe22e2e1af856e2fa06154c75b094091f
Reviewed-on: http://git-master/r/146388
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>

drivers/regulator/palmas-regulator.c

index 8f49cb0..0707d9b 100644 (file)
@@ -964,20 +964,6 @@ static void palmas_disable_ldo8_track(struct palmas *palmas)
        unsigned int addr;
        int ret;
 
-       addr = palmas_regs_info[PALMAS_REG_LDO8].ctrl_addr;
-
-       ret = palmas_ldo_read(palmas, addr, &reg);
-       if (ret) {
-               dev_err(palmas->dev, "Error in reading ldo8 control reg\n");
-               return;
-       }
-
-       reg &= ~PALMAS_LDO8_CTRL_LDO_TRACKING_EN;
-       ret = palmas_ldo_write(palmas, addr, reg);
-       if (ret < 0) {
-               dev_err(palmas->dev, "Error in enabling tracking mode\n");
-               return;
-       }
        /*
         * When SMPS4&5 is set to off and LDO8 tracking is enabled, the LDO8
         * output is defined by the LDO8_VOLTAGE.VSEL register divided by two,
@@ -992,8 +978,22 @@ static void palmas_disable_ldo8_track(struct palmas *palmas)
 
        reg = (reg >> 1) & PALMAS_LDO8_VOLTAGE_VSEL_MASK;
        ret = palmas_ldo_write(palmas, addr, reg);
-       if (ret < 0)
+       if (ret < 0) {
                dev_err(palmas->dev, "Error in setting ldo8 voltage reg\n");
+               return;
+       }
+
+       /* Disable the tracking mode */
+       addr = palmas_regs_info[PALMAS_REG_LDO8].ctrl_addr;
+       ret = palmas_ldo_read(palmas, addr, &reg);
+       if (ret) {
+               dev_err(palmas->dev, "Error in reading ldo8 control reg\n");
+               return;
+       }
+       reg &= ~PALMAS_LDO8_CTRL_LDO_TRACKING_EN;
+       ret = palmas_ldo_write(palmas, addr, reg);
+       if (ret < 0)
+               dev_err(palmas->dev, "Error in disabling tracking mode\n");
 
        return;
 }