diff options
author | Laxman Dewangan <ldewangan@nvidia.com> | 2011-11-24 19:23:46 +0530 |
---|---|---|
committer | Varun Wadekar <vwadekar@nvidia.com> | 2011-12-08 16:53:33 +0530 |
commit | d454cee86edac49aca7bdc1d2357e69adfe829ee (patch) | |
tree | 7cba30a2f92311f487a89ca8469d9c71f16207ac /drivers/regulator | |
parent | c0d0a8a770697079991a6338af01f86360c839f2 (diff) |
mfd: tps80031: Support sleep configuration through platform data
Supporting the sleep configuration through platform data.
Rearranging clock initialization to take external power control.
Reviewed-on: http://git-master/r/67076
(cherry picked from commit 9da9d369bdbe988b98eec9b63085dfdb26de8237)
Change-Id: I40c5a8608522dbc322e148b5d569e8f5a00faa21
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: http://git-master/r/67331
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/tps80031-regulator.c | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/drivers/regulator/tps80031-regulator.c b/drivers/regulator/tps80031-regulator.c index 9ea5cb9725a6..deca7adebb14 100644 --- a/drivers/regulator/tps80031-regulator.c +++ b/drivers/regulator/tps80031-regulator.c @@ -106,7 +106,7 @@ struct tps80031_regulator { u8 flags; unsigned int platform_flags; - enum tps80031_ext_control ext_pwr_ctrl; + unsigned int ext_ctrl_flag; /* used by regulator core */ struct regulator_desc desc; @@ -160,7 +160,7 @@ static int tps80031_reg_is_enabled(struct regulator_dev *rdev) { struct tps80031_regulator *ri = rdev_get_drvdata(rdev); - if (ri->ext_pwr_ctrl & EXT_PWR_REQ) + if (ri->ext_ctrl_flag & EXT_PWR_REQ) return true; return ((ri->state_reg_cache & STATE_MASK) == STATE_ON); } @@ -172,7 +172,7 @@ static int tps80031_reg_enable(struct regulator_dev *rdev) int ret; uint8_t reg_val; - if (ri->ext_pwr_ctrl & EXT_PWR_REQ) + if (ri->ext_ctrl_flag & EXT_PWR_REQ) return 0; reg_val = (ri->state_reg_cache & ~STATE_MASK) | @@ -194,7 +194,7 @@ static int tps80031_reg_disable(struct regulator_dev *rdev) int ret; uint8_t reg_val; - if (ri->ext_pwr_ctrl & EXT_PWR_REQ) + if (ri->ext_ctrl_flag & EXT_PWR_REQ) return 0; reg_val = (ri->state_reg_cache & ~STATE_MASK) | @@ -793,10 +793,12 @@ static int tps80031_power_req_config(struct device *parent, struct tps80031_regulator_platform_data *tps80031_pdata) { int ret; + uint8_t reg_val; + if (ri->preq_bit < 0) return 0; - ret = tps80031_ext_power_req_config(parent, ri->ext_pwr_ctrl, + ret = tps80031_ext_power_req_config(parent, ri->ext_ctrl_flag, ri->preq_bit, ri->state_reg, ri->trans_reg); if (!ret) ret = tps80031_read(parent, SLAVE_ID1, ri->trans_reg, @@ -805,6 +807,25 @@ static int tps80031_power_req_config(struct device *parent, if (!ret && ri->state_reg) ret = tps80031_read(parent, SLAVE_ID1, ri->state_reg, &ri->state_reg_cache); + if (ret < 0) { + dev_err(ri->dev, "%s() fails\n", __func__); + return ret; + } + + if (tps80031_pdata->ext_ctrl_flag & + (PWR_OFF_ON_SLEEP | PWR_ON_ON_SLEEP)) { + reg_val = (ri->trans_reg_cache & ~0xC); + if (tps80031_pdata->ext_ctrl_flag & PWR_ON_ON_SLEEP) + reg_val |= 0x4; + + ret = tps80031_write(parent, SLAVE_ID1, ri->trans_reg, + reg_val); + if (ret < 0) + dev_err(ri->dev, "Not able to write reg 0x%02x\n", + ri->trans_reg); + else + ri->trans_reg_cache = reg_val; + } return ret; } @@ -997,7 +1018,7 @@ static int __devinit tps80031_regulator_probe(struct platform_device *pdev) check_smps_mode_mult(pdev->dev.parent, ri); ri->platform_flags = tps_pdata->flags; - ri->ext_pwr_ctrl = tps_pdata->ext_pwr_ctrl; + ri->ext_ctrl_flag = tps_pdata->ext_ctrl_flag; err = tps80031_cache_regulator_register(pdev->dev.parent, ri); if (err) { |