summaryrefslogtreecommitdiff
path: root/drivers/regulator/tps80031-regulator.c
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2011-10-13 12:34:58 +0530
committerDan Willemsen <dwillemsen@nvidia.com>2011-11-30 21:49:28 -0800
commit6980642e8cd2357a4d62eefa4ca9c3b58947ba09 (patch)
treea287c29406dbbad2fca971c00657778cd925a99c /drivers/regulator/tps80031-regulator.c
parentfa36ff379b8283fce834329fd707ca70a8afe306 (diff)
regulator: tps80031: Proper configuration for PREQ1 control
When any rail is configured such that it can be enable by PREQ1 then only control the sleep mode of rails through TRANS register, not the STATE register. PREQ1 control the rail to switch from active to sleep and sleep to active mode. Reviewed-on: http://git-master/r/58278 (cherry picked from commit 6a8db3200c3119673b85769b1caa56422a22b4f9) Change-Id: I9763a4d283f0171eb9b7755d44ca3b9059755033 Reviewed-on: http://git-master/r/59289 Reviewed-by: Varun Colbert <vcolbert@nvidia.com> Tested-by: Varun Colbert <vcolbert@nvidia.com> Rebase-Id: R25d191b2429a5f60e77d70aed1eefecaa3b75ba3
Diffstat (limited to 'drivers/regulator/tps80031-regulator.c')
-rw-r--r--drivers/regulator/tps80031-regulator.c46
1 files changed, 40 insertions, 6 deletions
diff --git a/drivers/regulator/tps80031-regulator.c b/drivers/regulator/tps80031-regulator.c
index 5816af324a12..704de70a0e46 100644
--- a/drivers/regulator/tps80031-regulator.c
+++ b/drivers/regulator/tps80031-regulator.c
@@ -49,6 +49,10 @@
#define STATE_ON 0x01
#define STATE_MASK 0x03
+#define TRANS_SLEEP_OFF 0x00
+#define TRANS_SLEEP_ON 0x04
+#define TRANS_SLEEP_MASK 0x0C
+
#define SMPS_CMD_MASK 0xC0
#define SMPS_VSEL_MASK 0x3F
#define LDO_VSEL_MASK 0x1F
@@ -741,6 +745,25 @@ static int tps80031_power_req_config(struct device *parent,
int ret;
uint8_t reg_val;
+ /* Clear all external control for this rail */
+ ret = tps80031_clr_bits(parent, SLAVE_ID1,
+ TPS80031_PREQ1_RES_ASS_A + (ri->preq_bit >> 3),
+ BIT(ri->preq_bit & 0x7));
+ if (!ret)
+ ret = tps80031_clr_bits(parent, SLAVE_ID1,
+ TPS80031_PREQ2_RES_ASS_A + (ri->preq_bit >> 3),
+ BIT(ri->preq_bit & 0x7));
+ if (!ret)
+ ret = tps80031_clr_bits(parent, SLAVE_ID1,
+ TPS80031_PREQ3_RES_ASS_A + (ri->preq_bit >> 3),
+ BIT(ri->preq_bit & 0x7));
+ if (ret < 0) {
+ dev_err(ri->dev, "%s() Not able to clr bit %d of "
+ "TPS80031_PREQ_RES_ASS error %d\n",
+ __func__, preq_bit, ret);
+ return ret;
+ }
+
if (!(ri->platform_flags & EXT_PWR_REQ))
return 0;
@@ -777,13 +800,24 @@ static int tps80031_power_req_config(struct device *parent,
}
/* Switch regulator control to resource now */
- reg_val = (ri->state_reg_cache & ~STATE_MASK);
- ret = tps80031_write(parent, SLAVE_ID1, ri->state_reg, reg_val);
- if (ret < 0)
- dev_err(ri->dev, "%s() Error in writing the STATE "
+ if (ri->platform_flags & (PWR_REQ_INPUT_PREQ2 | PWR_REQ_INPUT_PREQ3)) {
+ reg_val = (ri->state_reg_cache & ~STATE_MASK);
+ ret = tps80031_write(parent, SLAVE_ID1, ri->state_reg, reg_val);
+ if (ret < 0)
+ dev_err(ri->dev, "%s() Error in writing the STATE "
"register error %d\n", __func__, ret);
- else
- ri->state_reg_cache = reg_val;
+ else
+ ri->state_reg_cache = reg_val;
+ } else {
+ reg_val = (ri->trans_reg_cache & ~TRANS_SLEEP_MASK) |
+ TRANS_SLEEP_OFF;
+ ret = tps80031_write(parent, SLAVE_ID1, ri->trans_reg, reg_val);
+ if (ret < 0)
+ dev_err(ri->dev, "%s() Error in writing the TRANS "
+ "register error %d\n", __func__, ret);
+ else
+ ri->trans_reg_cache = reg_val;
+ }
return ret;
}