diff options
author | Laxman Dewangan <ldewangan@nvidia.com> | 2012-08-30 13:30:01 +0530 |
---|---|---|
committer | Varun Colbert <vcolbert@nvidia.com> | 2012-08-30 17:29:48 -0700 |
commit | 28f0ff246bf80c842e6f8b92b2b9dbdac66f05e1 (patch) | |
tree | 036af2535ac8b42370c31eb75334cb65135a7b0d /drivers/regulator | |
parent | 589595fc63f318f9d234334c9b6df6e70733337d (diff) |
regulator: tps51632: write VMAX when lock bit is not set
TPS51632 hw behavior is that VMAX register can be written only
once as it get locked after first write. The lock get reset only
when device is power-reset. Write register only when lock bit is
not enabled.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Change-Id: I949439a0019ca44212128a23aea842d8be88523a
Reviewed-on: http://git-master/r/128445
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Pradeep Goudagunta <pgoudagunta@nvidia.com>
Tested-by: Pradeep Goudagunta <pgoudagunta@nvidia.com>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/tps51632-regulator.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/drivers/regulator/tps51632-regulator.c b/drivers/regulator/tps51632-regulator.c index 9ca35baf6f89..c43a5e715879 100644 --- a/drivers/regulator/tps51632-regulator.c +++ b/drivers/regulator/tps51632-regulator.c @@ -161,6 +161,7 @@ static int __devinit tps51632_init_dcdc(struct tps51632_chip *tps, int ret; uint8_t control = 0; int vsel; + unsigned int vmax; if (pdata->enable_pwm) { control = TPS51632_DVFS_PWMEN; @@ -182,6 +183,20 @@ static int __devinit tps51632_init_dcdc(struct tps51632_chip *tps, if (pdata->enable_overcurrent_alram) control = TPS51632_DVFS_OCA_EN; if (pdata->max_voltage_uV) { + /** + * TPS51632 hw behavior: VMAX register can be write only + * once as it get locked after first write. The lock get + * reset only when device is power-reset. + * Write register only when lock bit is not enabled. + */ + ret = regmap_read(tps->regmap, TPS51632_VMAX_REG, &vmax); + if (ret < 0) { + dev_err(tps->dev, "VMAX read failed, err %d\n", ret); + return ret; + } + if (vmax & TPS51632_VMAX_LOCK) + goto skip_vmax_config; + vsel = DIV_ROUND_UP(pdata->max_voltage_uV - TPS51632_MIN_VOLATGE, TPS51632_VOLATGE_STEP) + 0x19; ret = regmap_write(tps->regmap, TPS51632_VMAX_REG, vsel); @@ -190,6 +205,8 @@ static int __devinit tps51632_init_dcdc(struct tps51632_chip *tps, return ret; } } + +skip_vmax_config: ret = regmap_write(tps->regmap, TPS51632_DVFS_CONTROL_REG, control); if (ret < 0) { dev_err(tps->dev, "DVFS reg write failed, err %d\n", ret); |