regulator: palma: Configure pull-down of LOD8 in tracking mode
Laxman Dewangan [Thu, 4 Oct 2012 09:04:49 +0000 (14:04 +0530)]
LDO8 pull-down should be as follows:
- Disable the pull-down of LDO8 when it is in tracking mode.
- Enable the pull-down of LDO8 when it is in non-tracking mode.
Add support of this.

bug 1058685

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

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

drivers/regulator/palmas-regulator.c

index 0707d9b..9227dd5 100644 (file)
@@ -923,6 +923,7 @@ static void palmas_enable_ldo8_track(struct palmas *palmas)
        unsigned int reg;
        unsigned int addr;
        int ret;
+       int i;
 
        addr = palmas_regs_info[PALMAS_REG_LDO8].ctrl_addr;
 
@@ -952,8 +953,27 @@ static void palmas_enable_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;
+       }
+
+       /*
+        * When Tracking is enbled, it need to disable Pull-Down for LDO8 and
+        * when tracking is disabled, SW has to enabe Pull-Down.
+        */
+       addr = PALMAS_LDO_PD_CTRL1;
+       ret = palmas_ldo_read(palmas, addr, &reg);
+       if (ret < 0) {
+               dev_err(palmas->dev, "Error in reading pulldown control reg\n");
+               return;
+       }
+       reg &= ~PALMAS_LDO_PD_CTRL1_LDO8;
+       ret = palmas_ldo_write(palmas, addr, reg);
+       if (ret < 0) {
+               dev_err(palmas->dev, "Error in setting pulldown control reg\n");
+               return;
+       }
 
        return;
 }
@@ -992,8 +1012,27 @@ static void palmas_disable_ldo8_track(struct palmas *palmas)
        }
        reg &= ~PALMAS_LDO8_CTRL_LDO_TRACKING_EN;
        ret = palmas_ldo_write(palmas, addr, reg);
-       if (ret < 0)
+       if (ret < 0) {
                dev_err(palmas->dev, "Error in disabling tracking mode\n");
+               return;
+       }
+
+       /*
+        * When Tracking is enbled, it need to disable Pull-Down for LDO8 and
+        * when tracking is disabled, SW has to enabe Pull-Down.
+        */
+       addr = PALMAS_LDO_PD_CTRL1;
+       ret = palmas_ldo_read(palmas, addr, &reg);
+       if (ret < 0) {
+               dev_err(palmas->dev, "Error in reading pulldown control reg\n");
+               return;
+       }
+       reg |= PALMAS_LDO_PD_CTRL1_LDO8;
+       ret = palmas_ldo_write(palmas, addr, reg);
+       if (ret < 0) {
+               dev_err(palmas->dev, "Error in setting pulldown control reg\n");
+               return;
+       }
 
        return;
 }