aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2012-11-27 18:22:54 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-11-28 14:21:32 -0500
commitbd0ec7c1e52423429d9ee7b34e2c899f01db01b0 (patch)
treef65bcc4ff914c9798dbf0b3e0926637dbae3cabb /drivers/regulator
parent05cf34c1af48e2e1308a03fbc778039243bebd3a (diff)
regulator: tps51632: Use linear_min_sel and regulator_[map|list]_voltage_linear
Signed-off-by: Axel Lin <axel.lin@ingics.com> Acked-by: Laxman Dewangan <ldewangan@nvidia.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/tps51632-regulator.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/drivers/regulator/tps51632-regulator.c b/drivers/regulator/tps51632-regulator.c
index 34603640d6d9..dce5eb3fa706 100644
--- a/drivers/regulator/tps51632-regulator.c
+++ b/drivers/regulator/tps51632-regulator.c
@@ -106,29 +106,23 @@ static int tps51632_dcdc_get_voltage_sel(struct regulator_dev *rdev)
106 } 106 }
107 107
108 vsel = data & TPS51632_VOUT_MASK; 108 vsel = data & TPS51632_VOUT_MASK;
109 109 return vsel;
110 if (vsel < TPS51632_MIN_VSEL)
111 return 0;
112 else
113 return vsel - TPS51632_MIN_VSEL;
114} 110}
115 111
116static int tps51632_dcdc_set_voltage_sel(struct regulator_dev *rdev, 112static int tps51632_dcdc_set_voltage_sel(struct regulator_dev *rdev,
117 unsigned selector) 113 unsigned selector)
118{ 114{
119 struct tps51632_chip *tps = rdev_get_drvdata(rdev); 115 struct tps51632_chip *tps = rdev_get_drvdata(rdev);
120 int vsel;
121 int ret; 116 int ret;
122 unsigned int reg = TPS51632_VOLTAGE_SELECT_REG; 117 unsigned int reg = TPS51632_VOLTAGE_SELECT_REG;
123 118
124 if (tps->enable_pwm_dvfs) 119 if (tps->enable_pwm_dvfs)
125 reg = TPS51632_VOLTAGE_BASE_REG; 120 reg = TPS51632_VOLTAGE_BASE_REG;
126 121
127 vsel = selector + TPS51632_MIN_VSEL; 122 if (selector > TPS51632_MAX_VSEL)
128 if (vsel > TPS51632_MAX_VSEL)
129 return -EINVAL; 123 return -EINVAL;
130 124
131 ret = regmap_write(tps->regmap, TPS51632_VOLTAGE_SELECT_REG, vsel); 125 ret = regmap_write(tps->regmap, TPS51632_VOLTAGE_SELECT_REG, selector);
132 if (ret < 0) 126 if (ret < 0)
133 dev_err(tps->dev, "reg write failed, err %d\n", ret); 127 dev_err(tps->dev, "reg write failed, err %d\n", ret);
134 return ret; 128 return ret;
@@ -254,7 +248,8 @@ static int __devinit tps51632_probe(struct i2c_client *client,
254 tps->desc.ramp_delay = TPS51632_DEFAULT_RAMP_DELAY; 248 tps->desc.ramp_delay = TPS51632_DEFAULT_RAMP_DELAY;
255 tps->desc.min_uV = TPS51632_MIN_VOLATGE; 249 tps->desc.min_uV = TPS51632_MIN_VOLATGE;
256 tps->desc.uV_step = TPS51632_VOLATGE_STEP_10mV; 250 tps->desc.uV_step = TPS51632_VOLATGE_STEP_10mV;
257 tps->desc.n_voltages = (TPS51632_MAX_VSEL - TPS51632_MIN_VSEL) + 1; 251 tps->desc.linear_min_sel = TPS51632_MIN_VSEL;
252 tps->desc.n_voltages = TPS51632_MAX_VSEL + 1;
258 tps->desc.ops = &tps51632_dcdc_ops; 253 tps->desc.ops = &tps51632_dcdc_ops;
259 tps->desc.type = REGULATOR_VOLTAGE; 254 tps->desc.type = REGULATOR_VOLTAGE;
260 tps->desc.owner = THIS_MODULE; 255 tps->desc.owner = THIS_MODULE;