diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-11-10 09:38:29 -0500 |
---|---|---|
committer | Liam Girdwood <lrg@slimlogic.co.uk> | 2011-01-12 09:32:59 -0500 |
commit | 3a93f2a9f4d8f73d74c0e552feb68a10f778a219 (patch) | |
tree | 8a9f503f2f061ad3fe9712b0986b0da346f4c8d2 /drivers | |
parent | 63cee946148821bca42be10130b061c2d0f5af7e (diff) |
regulator: Report actual configured voltage to set_voltage()
Change the interface used by set_voltage() to report the selected value
to the regulator core in terms of a selector used by list_voltage().
This allows the regulator core to know the voltage that was chosen
without having to do an explict get_voltage(), which would be much more
expensive as it will generally access hardware.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'drivers')
26 files changed, 200 insertions, 78 deletions
diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c index 2ce2eb71d0f5..dd6308499bd4 100644 --- a/drivers/regulator/88pm8607.c +++ b/drivers/regulator/88pm8607.c | |||
@@ -249,7 +249,7 @@ static int choose_voltage(struct regulator_dev *rdev, int min_uV, int max_uV) | |||
249 | } | 249 | } |
250 | 250 | ||
251 | static int pm8607_set_voltage(struct regulator_dev *rdev, | 251 | static int pm8607_set_voltage(struct regulator_dev *rdev, |
252 | int min_uV, int max_uV) | 252 | int min_uV, int max_uV, unsigned *selector) |
253 | { | 253 | { |
254 | struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); | 254 | struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); |
255 | uint8_t val, mask; | 255 | uint8_t val, mask; |
@@ -263,6 +263,7 @@ static int pm8607_set_voltage(struct regulator_dev *rdev, | |||
263 | ret = choose_voltage(rdev, min_uV, max_uV); | 263 | ret = choose_voltage(rdev, min_uV, max_uV); |
264 | if (ret < 0) | 264 | if (ret < 0) |
265 | return -EINVAL; | 265 | return -EINVAL; |
266 | *selector = ret; | ||
266 | val = (uint8_t)(ret << info->vol_shift); | 267 | val = (uint8_t)(ret << info->vol_shift); |
267 | mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; | 268 | mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; |
268 | 269 | ||
diff --git a/drivers/regulator/ab3100.c b/drivers/regulator/ab3100.c index b349266a43de..ed6feaf9398d 100644 --- a/drivers/regulator/ab3100.c +++ b/drivers/regulator/ab3100.c | |||
@@ -362,7 +362,8 @@ static int ab3100_get_best_voltage_index(struct regulator_dev *reg, | |||
362 | } | 362 | } |
363 | 363 | ||
364 | static int ab3100_set_voltage_regulator(struct regulator_dev *reg, | 364 | static int ab3100_set_voltage_regulator(struct regulator_dev *reg, |
365 | int min_uV, int max_uV) | 365 | int min_uV, int max_uV, |
366 | unsigned *selector) | ||
366 | { | 367 | { |
367 | struct ab3100_regulator *abreg = reg->reg_data; | 368 | struct ab3100_regulator *abreg = reg->reg_data; |
368 | u8 regval; | 369 | u8 regval; |
@@ -373,6 +374,8 @@ static int ab3100_set_voltage_regulator(struct regulator_dev *reg, | |||
373 | if (bestindex < 0) | 374 | if (bestindex < 0) |
374 | return bestindex; | 375 | return bestindex; |
375 | 376 | ||
377 | *selector = bestindex; | ||
378 | |||
376 | err = abx500_get_register_interruptible(abreg->dev, 0, | 379 | err = abx500_get_register_interruptible(abreg->dev, 0, |
377 | abreg->regreg, ®val); | 380 | abreg->regreg, ®val); |
378 | if (err) { | 381 | if (err) { |
diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c index db6b70f20511..2f4ec0facef1 100644 --- a/drivers/regulator/ab8500.c +++ b/drivers/regulator/ab8500.c | |||
@@ -215,7 +215,8 @@ static int ab8500_get_best_voltage_index(struct regulator_dev *rdev, | |||
215 | } | 215 | } |
216 | 216 | ||
217 | static int ab8500_regulator_set_voltage(struct regulator_dev *rdev, | 217 | static int ab8500_regulator_set_voltage(struct regulator_dev *rdev, |
218 | int min_uV, int max_uV) | 218 | int min_uV, int max_uV, |
219 | unsigned *selector) | ||
219 | { | 220 | { |
220 | int regulator_id, ret; | 221 | int regulator_id, ret; |
221 | struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); | 222 | struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); |
@@ -232,6 +233,8 @@ static int ab8500_regulator_set_voltage(struct regulator_dev *rdev, | |||
232 | return ret; | 233 | return ret; |
233 | } | 234 | } |
234 | 235 | ||
236 | *selector = ret; | ||
237 | |||
235 | /* set the registers for the request */ | 238 | /* set the registers for the request */ |
236 | ret = abx500_mask_and_set_register_interruptible(info->dev, | 239 | ret = abx500_mask_and_set_register_interruptible(info->dev, |
237 | info->voltage_bank, info->voltage_reg, | 240 | info->voltage_bank, info->voltage_reg, |
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 81336e23848a..67d3a61f3785 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -723,13 +723,16 @@ static int machine_constraints_voltage(struct regulator_dev *rdev, | |||
723 | struct regulator_ops *ops = rdev->desc->ops; | 723 | struct regulator_ops *ops = rdev->desc->ops; |
724 | const char *name = rdev_get_name(rdev); | 724 | const char *name = rdev_get_name(rdev); |
725 | int ret; | 725 | int ret; |
726 | unsigned selector; | ||
726 | 727 | ||
727 | /* do we need to apply the constraint voltage */ | 728 | /* do we need to apply the constraint voltage */ |
728 | if (rdev->constraints->apply_uV && | 729 | if (rdev->constraints->apply_uV && |
729 | rdev->constraints->min_uV == rdev->constraints->max_uV && | 730 | rdev->constraints->min_uV == rdev->constraints->max_uV && |
730 | ops->set_voltage) { | 731 | ops->set_voltage) { |
731 | ret = ops->set_voltage(rdev, | 732 | ret = ops->set_voltage(rdev, |
732 | rdev->constraints->min_uV, rdev->constraints->max_uV); | 733 | rdev->constraints->min_uV, |
734 | rdev->constraints->max_uV, | ||
735 | &selector); | ||
733 | if (ret < 0) { | 736 | if (ret < 0) { |
734 | printk(KERN_ERR "%s: failed to apply %duV constraint to %s\n", | 737 | printk(KERN_ERR "%s: failed to apply %duV constraint to %s\n", |
735 | __func__, | 738 | __func__, |
@@ -1625,6 +1628,7 @@ int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV) | |||
1625 | { | 1628 | { |
1626 | struct regulator_dev *rdev = regulator->rdev; | 1629 | struct regulator_dev *rdev = regulator->rdev; |
1627 | int ret; | 1630 | int ret; |
1631 | unsigned selector; | ||
1628 | 1632 | ||
1629 | mutex_lock(&rdev->mutex); | 1633 | mutex_lock(&rdev->mutex); |
1630 | 1634 | ||
@@ -1640,7 +1644,13 @@ int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV) | |||
1640 | goto out; | 1644 | goto out; |
1641 | regulator->min_uV = min_uV; | 1645 | regulator->min_uV = min_uV; |
1642 | regulator->max_uV = max_uV; | 1646 | regulator->max_uV = max_uV; |
1643 | ret = rdev->desc->ops->set_voltage(rdev, min_uV, max_uV); | 1647 | |
1648 | ret = rdev->desc->ops->set_voltage(rdev, min_uV, max_uV, &selector); | ||
1649 | |||
1650 | if (rdev->desc->ops->list_voltage) | ||
1651 | selector = rdev->desc->ops->list_voltage(rdev, selector); | ||
1652 | else | ||
1653 | selector = -1; | ||
1644 | 1654 | ||
1645 | out: | 1655 | out: |
1646 | _notifier_call_chain(rdev, REGULATOR_EVENT_VOLTAGE_CHANGE, NULL); | 1656 | _notifier_call_chain(rdev, REGULATOR_EVENT_VOLTAGE_CHANGE, NULL); |
diff --git a/drivers/regulator/da903x.c b/drivers/regulator/da903x.c index f8c4661a7a81..362e08221085 100644 --- a/drivers/regulator/da903x.c +++ b/drivers/regulator/da903x.c | |||
@@ -107,7 +107,7 @@ static inline int check_range(struct da903x_regulator_info *info, | |||
107 | 107 | ||
108 | /* DA9030/DA9034 common operations */ | 108 | /* DA9030/DA9034 common operations */ |
109 | static int da903x_set_ldo_voltage(struct regulator_dev *rdev, | 109 | static int da903x_set_ldo_voltage(struct regulator_dev *rdev, |
110 | int min_uV, int max_uV) | 110 | int min_uV, int max_uV, unsigned *selector) |
111 | { | 111 | { |
112 | struct da903x_regulator_info *info = rdev_get_drvdata(rdev); | 112 | struct da903x_regulator_info *info = rdev_get_drvdata(rdev); |
113 | struct device *da9034_dev = to_da903x_dev(rdev); | 113 | struct device *da9034_dev = to_da903x_dev(rdev); |
@@ -119,6 +119,7 @@ static int da903x_set_ldo_voltage(struct regulator_dev *rdev, | |||
119 | } | 119 | } |
120 | 120 | ||
121 | val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV; | 121 | val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV; |
122 | *selector = val; | ||
122 | val <<= info->vol_shift; | 123 | val <<= info->vol_shift; |
123 | mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; | 124 | mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; |
124 | 125 | ||
@@ -187,7 +188,8 @@ static int da903x_list_voltage(struct regulator_dev *rdev, unsigned selector) | |||
187 | 188 | ||
188 | /* DA9030 specific operations */ | 189 | /* DA9030 specific operations */ |
189 | static int da9030_set_ldo1_15_voltage(struct regulator_dev *rdev, | 190 | static int da9030_set_ldo1_15_voltage(struct regulator_dev *rdev, |
190 | int min_uV, int max_uV) | 191 | int min_uV, int max_uV, |
192 | unsigned *selector) | ||
191 | { | 193 | { |
192 | struct da903x_regulator_info *info = rdev_get_drvdata(rdev); | 194 | struct da903x_regulator_info *info = rdev_get_drvdata(rdev); |
193 | struct device *da903x_dev = to_da903x_dev(rdev); | 195 | struct device *da903x_dev = to_da903x_dev(rdev); |
@@ -200,6 +202,7 @@ static int da9030_set_ldo1_15_voltage(struct regulator_dev *rdev, | |||
200 | } | 202 | } |
201 | 203 | ||
202 | val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV; | 204 | val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV; |
205 | *selector = val; | ||
203 | val <<= info->vol_shift; | 206 | val <<= info->vol_shift; |
204 | mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; | 207 | mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; |
205 | val |= DA9030_LDO_UNLOCK; /* have to set UNLOCK bits */ | 208 | val |= DA9030_LDO_UNLOCK; /* have to set UNLOCK bits */ |
@@ -214,7 +217,8 @@ static int da9030_set_ldo1_15_voltage(struct regulator_dev *rdev, | |||
214 | } | 217 | } |
215 | 218 | ||
216 | static int da9030_set_ldo14_voltage(struct regulator_dev *rdev, | 219 | static int da9030_set_ldo14_voltage(struct regulator_dev *rdev, |
217 | int min_uV, int max_uV) | 220 | int min_uV, int max_uV, |
221 | unsigned *selector) | ||
218 | { | 222 | { |
219 | struct da903x_regulator_info *info = rdev_get_drvdata(rdev); | 223 | struct da903x_regulator_info *info = rdev_get_drvdata(rdev); |
220 | struct device *da903x_dev = to_da903x_dev(rdev); | 224 | struct device *da903x_dev = to_da903x_dev(rdev); |
@@ -234,6 +238,7 @@ static int da9030_set_ldo14_voltage(struct regulator_dev *rdev, | |||
234 | val = (min_uV - thresh + info->step_uV - 1) / info->step_uV; | 238 | val = (min_uV - thresh + info->step_uV - 1) / info->step_uV; |
235 | } | 239 | } |
236 | 240 | ||
241 | *selector = val; | ||
237 | val <<= info->vol_shift; | 242 | val <<= info->vol_shift; |
238 | mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; | 243 | mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; |
239 | 244 | ||
@@ -263,7 +268,7 @@ static int da9030_get_ldo14_voltage(struct regulator_dev *rdev) | |||
263 | 268 | ||
264 | /* DA9034 specific operations */ | 269 | /* DA9034 specific operations */ |
265 | static int da9034_set_dvc_voltage(struct regulator_dev *rdev, | 270 | static int da9034_set_dvc_voltage(struct regulator_dev *rdev, |
266 | int min_uV, int max_uV) | 271 | int min_uV, int max_uV, unsigned *selector) |
267 | { | 272 | { |
268 | struct da903x_regulator_info *info = rdev_get_drvdata(rdev); | 273 | struct da903x_regulator_info *info = rdev_get_drvdata(rdev); |
269 | struct device *da9034_dev = to_da903x_dev(rdev); | 274 | struct device *da9034_dev = to_da903x_dev(rdev); |
@@ -276,6 +281,7 @@ static int da9034_set_dvc_voltage(struct regulator_dev *rdev, | |||
276 | } | 281 | } |
277 | 282 | ||
278 | val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV; | 283 | val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV; |
284 | *selector = val; | ||
279 | val <<= info->vol_shift; | 285 | val <<= info->vol_shift; |
280 | mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; | 286 | mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; |
281 | 287 | ||
@@ -289,7 +295,7 @@ static int da9034_set_dvc_voltage(struct regulator_dev *rdev, | |||
289 | } | 295 | } |
290 | 296 | ||
291 | static int da9034_set_ldo12_voltage(struct regulator_dev *rdev, | 297 | static int da9034_set_ldo12_voltage(struct regulator_dev *rdev, |
292 | int min_uV, int max_uV) | 298 | int min_uV, int max_uV, unsigned *selector) |
293 | { | 299 | { |
294 | struct da903x_regulator_info *info = rdev_get_drvdata(rdev); | 300 | struct da903x_regulator_info *info = rdev_get_drvdata(rdev); |
295 | struct device *da9034_dev = to_da903x_dev(rdev); | 301 | struct device *da9034_dev = to_da903x_dev(rdev); |
@@ -302,6 +308,7 @@ static int da9034_set_ldo12_voltage(struct regulator_dev *rdev, | |||
302 | 308 | ||
303 | val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV; | 309 | val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV; |
304 | val = (val >= 20) ? val - 12 : ((val > 7) ? 8 : val); | 310 | val = (val >= 20) ? val - 12 : ((val > 7) ? 8 : val); |
311 | *selector = val; | ||
305 | val <<= info->vol_shift; | 312 | val <<= info->vol_shift; |
306 | mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; | 313 | mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; |
307 | 314 | ||
diff --git a/drivers/regulator/isl6271a-regulator.c b/drivers/regulator/isl6271a-regulator.c index b8cc6389a541..b5639e82fcc7 100644 --- a/drivers/regulator/isl6271a-regulator.c +++ b/drivers/regulator/isl6271a-regulator.c | |||
@@ -58,7 +58,9 @@ out: | |||
58 | return data; | 58 | return data; |
59 | } | 59 | } |
60 | 60 | ||
61 | static int isl6271a_set_voltage(struct regulator_dev *dev, int minuV, int maxuV) | 61 | static int isl6271a_set_voltage(struct regulator_dev *dev, |
62 | int minuV, int maxuV, | ||
63 | unsigned *selector) | ||
62 | { | 64 | { |
63 | struct isl_pmic *pmic = rdev_get_drvdata(dev); | 65 | struct isl_pmic *pmic = rdev_get_drvdata(dev); |
64 | int vsel, err, data; | 66 | int vsel, err, data; |
@@ -78,6 +80,8 @@ static int isl6271a_set_voltage(struct regulator_dev *dev, int minuV, int maxuV) | |||
78 | /* Convert the microvolts to data for the chip */ | 80 | /* Convert the microvolts to data for the chip */ |
79 | data = (vsel - ISL6271A_VOLTAGE_MIN) / ISL6271A_VOLTAGE_STEP; | 81 | data = (vsel - ISL6271A_VOLTAGE_MIN) / ISL6271A_VOLTAGE_STEP; |
80 | 82 | ||
83 | *selector = data; | ||
84 | |||
81 | mutex_lock(&pmic->mtx); | 85 | mutex_lock(&pmic->mtx); |
82 | 86 | ||
83 | err = i2c_smbus_write_byte(pmic->client, data); | 87 | err = i2c_smbus_write_byte(pmic->client, data); |
diff --git a/drivers/regulator/lp3971.c b/drivers/regulator/lp3971.c index 3bb82b624e19..0f22ef12601c 100644 --- a/drivers/regulator/lp3971.c +++ b/drivers/regulator/lp3971.c | |||
@@ -168,7 +168,8 @@ static int lp3971_ldo_get_voltage(struct regulator_dev *dev) | |||
168 | } | 168 | } |
169 | 169 | ||
170 | static int lp3971_ldo_set_voltage(struct regulator_dev *dev, | 170 | static int lp3971_ldo_set_voltage(struct regulator_dev *dev, |
171 | int min_uV, int max_uV) | 171 | int min_uV, int max_uV, |
172 | unsigned int *selector) | ||
172 | { | 173 | { |
173 | struct lp3971 *lp3971 = rdev_get_drvdata(dev); | 174 | struct lp3971 *lp3971 = rdev_get_drvdata(dev); |
174 | int ldo = rdev_get_id(dev) - LP3971_LDO1; | 175 | int ldo = rdev_get_id(dev) - LP3971_LDO1; |
@@ -187,6 +188,8 @@ static int lp3971_ldo_set_voltage(struct regulator_dev *dev, | |||
187 | if (val > LDO_VOL_MAX_IDX || vol_map[val] > max_vol) | 188 | if (val > LDO_VOL_MAX_IDX || vol_map[val] > max_vol) |
188 | return -EINVAL; | 189 | return -EINVAL; |
189 | 190 | ||
191 | *selector = val; | ||
192 | |||
190 | return lp3971_set_bits(lp3971, LP3971_LDO_VOL_CONTR_REG(ldo), | 193 | return lp3971_set_bits(lp3971, LP3971_LDO_VOL_CONTR_REG(ldo), |
191 | LDO_VOL_CONTR_MASK << LDO_VOL_CONTR_SHIFT(ldo), | 194 | LDO_VOL_CONTR_MASK << LDO_VOL_CONTR_SHIFT(ldo), |
192 | val << LDO_VOL_CONTR_SHIFT(ldo)); | 195 | val << LDO_VOL_CONTR_SHIFT(ldo)); |
@@ -256,7 +259,8 @@ static int lp3971_dcdc_get_voltage(struct regulator_dev *dev) | |||
256 | } | 259 | } |
257 | 260 | ||
258 | static int lp3971_dcdc_set_voltage(struct regulator_dev *dev, | 261 | static int lp3971_dcdc_set_voltage(struct regulator_dev *dev, |
259 | int min_uV, int max_uV) | 262 | int min_uV, int max_uV, |
263 | unsigned int *selector) | ||
260 | { | 264 | { |
261 | struct lp3971 *lp3971 = rdev_get_drvdata(dev); | 265 | struct lp3971 *lp3971 = rdev_get_drvdata(dev); |
262 | int buck = rdev_get_id(dev) - LP3971_DCDC1; | 266 | int buck = rdev_get_id(dev) - LP3971_DCDC1; |
@@ -277,6 +281,8 @@ static int lp3971_dcdc_set_voltage(struct regulator_dev *dev, | |||
277 | if (val > BUCK_TARGET_VOL_MAX_IDX || vol_map[val] > max_vol) | 281 | if (val > BUCK_TARGET_VOL_MAX_IDX || vol_map[val] > max_vol) |
278 | return -EINVAL; | 282 | return -EINVAL; |
279 | 283 | ||
284 | *selector = val; | ||
285 | |||
280 | ret = lp3971_set_bits(lp3971, LP3971_BUCK_TARGET_VOL1_REG(buck), | 286 | ret = lp3971_set_bits(lp3971, LP3971_BUCK_TARGET_VOL1_REG(buck), |
281 | BUCK_TARGET_VOL_MASK, val); | 287 | BUCK_TARGET_VOL_MASK, val); |
282 | if (ret) | 288 | if (ret) |
diff --git a/drivers/regulator/lp3972.c b/drivers/regulator/lp3972.c index e07062fd0b42..6aa1b506fb5d 100644 --- a/drivers/regulator/lp3972.c +++ b/drivers/regulator/lp3972.c | |||
@@ -292,7 +292,8 @@ static int lp3972_ldo_get_voltage(struct regulator_dev *dev) | |||
292 | } | 292 | } |
293 | 293 | ||
294 | static int lp3972_ldo_set_voltage(struct regulator_dev *dev, | 294 | static int lp3972_ldo_set_voltage(struct regulator_dev *dev, |
295 | int min_uV, int max_uV) | 295 | int min_uV, int max_uV, |
296 | unsigned int *selector) | ||
296 | { | 297 | { |
297 | struct lp3972 *lp3972 = rdev_get_drvdata(dev); | 298 | struct lp3972 *lp3972 = rdev_get_drvdata(dev); |
298 | int ldo = rdev_get_id(dev) - LP3972_LDO1; | 299 | int ldo = rdev_get_id(dev) - LP3972_LDO1; |
@@ -313,6 +314,8 @@ static int lp3972_ldo_set_voltage(struct regulator_dev *dev, | |||
313 | if (val > LP3972_LDO_VOL_MAX_IDX(ldo) || vol_map[val] > max_vol) | 314 | if (val > LP3972_LDO_VOL_MAX_IDX(ldo) || vol_map[val] > max_vol) |
314 | return -EINVAL; | 315 | return -EINVAL; |
315 | 316 | ||
317 | *selector = val; | ||
318 | |||
316 | shift = LP3972_LDO_VOL_CONTR_SHIFT(ldo); | 319 | shift = LP3972_LDO_VOL_CONTR_SHIFT(ldo); |
317 | ret = lp3972_set_bits(lp3972, LP3972_LDO_VOL_CONTR_REG(ldo), | 320 | ret = lp3972_set_bits(lp3972, LP3972_LDO_VOL_CONTR_REG(ldo), |
318 | LP3972_LDO_VOL_MASK(ldo) << shift, val << shift); | 321 | LP3972_LDO_VOL_MASK(ldo) << shift, val << shift); |
@@ -416,7 +419,8 @@ static int lp3972_dcdc_get_voltage(struct regulator_dev *dev) | |||
416 | } | 419 | } |
417 | 420 | ||
418 | static int lp3972_dcdc_set_voltage(struct regulator_dev *dev, | 421 | static int lp3972_dcdc_set_voltage(struct regulator_dev *dev, |
419 | int min_uV, int max_uV) | 422 | int min_uV, int max_uV, |
423 | unsigned int *selector) | ||
420 | { | 424 | { |
421 | struct lp3972 *lp3972 = rdev_get_drvdata(dev); | 425 | struct lp3972 *lp3972 = rdev_get_drvdata(dev); |
422 | int buck = rdev_get_id(dev) - LP3972_DCDC1; | 426 | int buck = rdev_get_id(dev) - LP3972_DCDC1; |
@@ -438,6 +442,8 @@ static int lp3972_dcdc_set_voltage(struct regulator_dev *dev, | |||
438 | vol_map[val] > max_vol) | 442 | vol_map[val] > max_vol) |
439 | return -EINVAL; | 443 | return -EINVAL; |
440 | 444 | ||
445 | *selector = val; | ||
446 | |||
441 | ret = lp3972_set_bits(lp3972, LP3972_BUCK_VOL1_REG(buck), | 447 | ret = lp3972_set_bits(lp3972, LP3972_BUCK_VOL1_REG(buck), |
442 | LP3972_BUCK_VOL_MASK, val); | 448 | LP3972_BUCK_VOL_MASK, val); |
443 | if (ret) | 449 | if (ret) |
diff --git a/drivers/regulator/max1586.c b/drivers/regulator/max1586.c index 559cfa271a44..3f49512c5134 100644 --- a/drivers/regulator/max1586.c +++ b/drivers/regulator/max1586.c | |||
@@ -63,12 +63,12 @@ static int max1586_v3_calc_voltage(struct max1586_data *max1586, | |||
63 | return max1586->min_uV + (selector * range_uV / MAX1586_V3_MAX_VSEL); | 63 | return max1586->min_uV + (selector * range_uV / MAX1586_V3_MAX_VSEL); |
64 | } | 64 | } |
65 | 65 | ||
66 | static int max1586_v3_set(struct regulator_dev *rdev, int min_uV, int max_uV) | 66 | static int max1586_v3_set(struct regulator_dev *rdev, int min_uV, int max_uV, |
67 | unsigned *selector) | ||
67 | { | 68 | { |
68 | struct max1586_data *max1586 = rdev_get_drvdata(rdev); | 69 | struct max1586_data *max1586 = rdev_get_drvdata(rdev); |
69 | struct i2c_client *client = max1586->client; | 70 | struct i2c_client *client = max1586->client; |
70 | unsigned range_uV = max1586->max_uV - max1586->min_uV; | 71 | unsigned range_uV = max1586->max_uV - max1586->min_uV; |
71 | unsigned selector; | ||
72 | u8 v3_prog; | 72 | u8 v3_prog; |
73 | 73 | ||
74 | if (min_uV > max1586->max_uV || max_uV < max1586->min_uV) | 74 | if (min_uV > max1586->max_uV || max_uV < max1586->min_uV) |
@@ -76,15 +76,15 @@ static int max1586_v3_set(struct regulator_dev *rdev, int min_uV, int max_uV) | |||
76 | if (min_uV < max1586->min_uV) | 76 | if (min_uV < max1586->min_uV) |
77 | min_uV = max1586->min_uV; | 77 | min_uV = max1586->min_uV; |
78 | 78 | ||
79 | selector = ((min_uV - max1586->min_uV) * MAX1586_V3_MAX_VSEL + | 79 | *selector = ((min_uV - max1586->min_uV) * MAX1586_V3_MAX_VSEL + |
80 | range_uV - 1) / range_uV; | 80 | range_uV - 1) / range_uV; |
81 | if (max1586_v3_calc_voltage(max1586, selector) > max_uV) | 81 | if (max1586_v3_calc_voltage(max1586, *selector) > max_uV) |
82 | return -EINVAL; | 82 | return -EINVAL; |
83 | 83 | ||
84 | dev_dbg(&client->dev, "changing voltage v3 to %dmv\n", | 84 | dev_dbg(&client->dev, "changing voltage v3 to %dmv\n", |
85 | max1586_v3_calc_voltage(max1586, selector) / 1000); | 85 | max1586_v3_calc_voltage(max1586, *selector) / 1000); |
86 | 86 | ||
87 | v3_prog = I2C_V3_SELECT | (u8) selector; | 87 | v3_prog = I2C_V3_SELECT | (u8) *selector; |
88 | return i2c_smbus_write_byte(client, v3_prog); | 88 | return i2c_smbus_write_byte(client, v3_prog); |
89 | } | 89 | } |
90 | 90 | ||
@@ -110,10 +110,10 @@ static int max1586_v6_calc_voltage(unsigned selector) | |||
110 | return voltages_uv[selector]; | 110 | return voltages_uv[selector]; |
111 | } | 111 | } |
112 | 112 | ||
113 | static int max1586_v6_set(struct regulator_dev *rdev, int min_uV, int max_uV) | 113 | static int max1586_v6_set(struct regulator_dev *rdev, int min_uV, int max_uV, |
114 | unsigned int *selector) | ||
114 | { | 115 | { |
115 | struct i2c_client *client = rdev_get_drvdata(rdev); | 116 | struct i2c_client *client = rdev_get_drvdata(rdev); |
116 | unsigned selector; | ||
117 | u8 v6_prog; | 117 | u8 v6_prog; |
118 | 118 | ||
119 | if (min_uV < MAX1586_V6_MIN_UV || min_uV > MAX1586_V6_MAX_UV) | 119 | if (min_uV < MAX1586_V6_MIN_UV || min_uV > MAX1586_V6_MAX_UV) |
@@ -122,21 +122,21 @@ static int max1586_v6_set(struct regulator_dev *rdev, int min_uV, int max_uV) | |||
122 | return -EINVAL; | 122 | return -EINVAL; |
123 | 123 | ||
124 | if (min_uV < 1800000) | 124 | if (min_uV < 1800000) |
125 | selector = 0; | 125 | *selector = 0; |
126 | else if (min_uV < 2500000) | 126 | else if (min_uV < 2500000) |
127 | selector = 1; | 127 | *selector = 1; |
128 | else if (min_uV < 3000000) | 128 | else if (min_uV < 3000000) |
129 | selector = 2; | 129 | *selector = 2; |
130 | else if (min_uV >= 3000000) | 130 | else if (min_uV >= 3000000) |
131 | selector = 3; | 131 | *selector = 3; |
132 | 132 | ||
133 | if (max1586_v6_calc_voltage(selector) > max_uV) | 133 | if (max1586_v6_calc_voltage(*selector) > max_uV) |
134 | return -EINVAL; | 134 | return -EINVAL; |
135 | 135 | ||
136 | dev_dbg(&client->dev, "changing voltage v6 to %dmv\n", | 136 | dev_dbg(&client->dev, "changing voltage v6 to %dmv\n", |
137 | max1586_v6_calc_voltage(selector) / 1000); | 137 | max1586_v6_calc_voltage(*selector) / 1000); |
138 | 138 | ||
139 | v6_prog = I2C_V6_SELECT | (u8) selector; | 139 | v6_prog = I2C_V6_SELECT | (u8) *selector; |
140 | return i2c_smbus_write_byte(client, v6_prog); | 140 | return i2c_smbus_write_byte(client, v6_prog); |
141 | } | 141 | } |
142 | 142 | ||
diff --git a/drivers/regulator/max8649.c b/drivers/regulator/max8649.c index 6b60a9c0366b..30eb9e54f7ec 100644 --- a/drivers/regulator/max8649.c +++ b/drivers/regulator/max8649.c | |||
@@ -155,7 +155,7 @@ static int max8649_get_voltage(struct regulator_dev *rdev) | |||
155 | } | 155 | } |
156 | 156 | ||
157 | static int max8649_set_voltage(struct regulator_dev *rdev, | 157 | static int max8649_set_voltage(struct regulator_dev *rdev, |
158 | int min_uV, int max_uV) | 158 | int min_uV, int max_uV, unsigned *selector) |
159 | { | 159 | { |
160 | struct max8649_regulator_info *info = rdev_get_drvdata(rdev); | 160 | struct max8649_regulator_info *info = rdev_get_drvdata(rdev); |
161 | unsigned char data, mask; | 161 | unsigned char data, mask; |
@@ -168,6 +168,7 @@ static int max8649_set_voltage(struct regulator_dev *rdev, | |||
168 | data = (min_uV - MAX8649_DCDC_VMIN + MAX8649_DCDC_STEP - 1) | 168 | data = (min_uV - MAX8649_DCDC_VMIN + MAX8649_DCDC_STEP - 1) |
169 | / MAX8649_DCDC_STEP; | 169 | / MAX8649_DCDC_STEP; |
170 | mask = MAX8649_VOL_MASK; | 170 | mask = MAX8649_VOL_MASK; |
171 | *selector = data & mask; | ||
171 | 172 | ||
172 | return max8649_set_bits(info->i2c, info->vol_reg, mask, data); | 173 | return max8649_set_bits(info->i2c, info->vol_reg, mask, data); |
173 | } | 174 | } |
diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c index c570e6eb0db2..33f5d9a492ef 100644 --- a/drivers/regulator/max8660.c +++ b/drivers/regulator/max8660.c | |||
@@ -141,7 +141,8 @@ static int max8660_dcdc_get(struct regulator_dev *rdev) | |||
141 | return MAX8660_DCDC_MIN_UV + selector * MAX8660_DCDC_STEP; | 141 | return MAX8660_DCDC_MIN_UV + selector * MAX8660_DCDC_STEP; |
142 | } | 142 | } |
143 | 143 | ||
144 | static int max8660_dcdc_set(struct regulator_dev *rdev, int min_uV, int max_uV) | 144 | static int max8660_dcdc_set(struct regulator_dev *rdev, int min_uV, int max_uV, |
145 | unsigned int *s) | ||
145 | { | 146 | { |
146 | struct max8660 *max8660 = rdev_get_drvdata(rdev); | 147 | struct max8660 *max8660 = rdev_get_drvdata(rdev); |
147 | u8 reg, selector, bits; | 148 | u8 reg, selector, bits; |
@@ -154,6 +155,7 @@ static int max8660_dcdc_set(struct regulator_dev *rdev, int min_uV, int max_uV) | |||
154 | 155 | ||
155 | selector = (min_uV - (MAX8660_DCDC_MIN_UV - MAX8660_DCDC_STEP + 1)) | 156 | selector = (min_uV - (MAX8660_DCDC_MIN_UV - MAX8660_DCDC_STEP + 1)) |
156 | / MAX8660_DCDC_STEP; | 157 | / MAX8660_DCDC_STEP; |
158 | *s = selector; | ||
157 | 159 | ||
158 | ret = max8660_dcdc_list(rdev, selector); | 160 | ret = max8660_dcdc_list(rdev, selector); |
159 | if (ret < 0 || ret > max_uV) | 161 | if (ret < 0 || ret > max_uV) |
@@ -196,7 +198,8 @@ static int max8660_ldo5_get(struct regulator_dev *rdev) | |||
196 | return MAX8660_LDO5_MIN_UV + selector * MAX8660_LDO5_STEP; | 198 | return MAX8660_LDO5_MIN_UV + selector * MAX8660_LDO5_STEP; |
197 | } | 199 | } |
198 | 200 | ||
199 | static int max8660_ldo5_set(struct regulator_dev *rdev, int min_uV, int max_uV) | 201 | static int max8660_ldo5_set(struct regulator_dev *rdev, int min_uV, int max_uV, |
202 | unsigned int *s) | ||
200 | { | 203 | { |
201 | struct max8660 *max8660 = rdev_get_drvdata(rdev); | 204 | struct max8660 *max8660 = rdev_get_drvdata(rdev); |
202 | u8 selector; | 205 | u8 selector; |
@@ -213,6 +216,8 @@ static int max8660_ldo5_set(struct regulator_dev *rdev, int min_uV, int max_uV) | |||
213 | if (ret < 0 || ret > max_uV) | 216 | if (ret < 0 || ret > max_uV) |
214 | return -EINVAL; | 217 | return -EINVAL; |
215 | 218 | ||
219 | *s = selector; | ||
220 | |||
216 | ret = max8660_write(max8660, MAX8660_MDTV2, 0, selector); | 221 | ret = max8660_write(max8660, MAX8660_MDTV2, 0, selector); |
217 | if (ret) | 222 | if (ret) |
218 | return ret; | 223 | return ret; |
@@ -270,7 +275,8 @@ static int max8660_ldo67_get(struct regulator_dev *rdev) | |||
270 | return MAX8660_LDO67_MIN_UV + selector * MAX8660_LDO67_STEP; | 275 | return MAX8660_LDO67_MIN_UV + selector * MAX8660_LDO67_STEP; |
271 | } | 276 | } |
272 | 277 | ||
273 | static int max8660_ldo67_set(struct regulator_dev *rdev, int min_uV, int max_uV) | 278 | static int max8660_ldo67_set(struct regulator_dev *rdev, int min_uV, |
279 | int max_uV, unsigned int *s) | ||
274 | { | 280 | { |
275 | struct max8660 *max8660 = rdev_get_drvdata(rdev); | 281 | struct max8660 *max8660 = rdev_get_drvdata(rdev); |
276 | u8 selector; | 282 | u8 selector; |
@@ -288,6 +294,8 @@ static int max8660_ldo67_set(struct regulator_dev *rdev, int min_uV, int max_uV) | |||
288 | if (ret < 0 || ret > max_uV) | 294 | if (ret < 0 || ret > max_uV) |
289 | return -EINVAL; | 295 | return -EINVAL; |
290 | 296 | ||
297 | *s = selector; | ||
298 | |||
291 | if (rdev_get_id(rdev) == MAX8660_V6) | 299 | if (rdev_get_id(rdev) == MAX8660_V6) |
292 | return max8660_write(max8660, MAX8660_L12VCR, 0xf0, selector); | 300 | return max8660_write(max8660, MAX8660_L12VCR, 0xf0, selector); |
293 | else | 301 | else |
diff --git a/drivers/regulator/max8925-regulator.c b/drivers/regulator/max8925-regulator.c index 552cad85ae5a..8ae147549c6a 100644 --- a/drivers/regulator/max8925-regulator.c +++ b/drivers/regulator/max8925-regulator.c | |||
@@ -55,7 +55,7 @@ static int max8925_list_voltage(struct regulator_dev *rdev, unsigned index) | |||
55 | } | 55 | } |
56 | 56 | ||
57 | static int max8925_set_voltage(struct regulator_dev *rdev, | 57 | static int max8925_set_voltage(struct regulator_dev *rdev, |
58 | int min_uV, int max_uV) | 58 | int min_uV, int max_uV, unsigned int *selector) |
59 | { | 59 | { |
60 | struct max8925_regulator_info *info = rdev_get_drvdata(rdev); | 60 | struct max8925_regulator_info *info = rdev_get_drvdata(rdev); |
61 | unsigned char data, mask; | 61 | unsigned char data, mask; |
@@ -66,6 +66,7 @@ static int max8925_set_voltage(struct regulator_dev *rdev, | |||
66 | return -EINVAL; | 66 | return -EINVAL; |
67 | } | 67 | } |
68 | data = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV; | 68 | data = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV; |
69 | *selector = data; | ||
69 | data <<= info->vol_shift; | 70 | data <<= info->vol_shift; |
70 | mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; | 71 | mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; |
71 | 72 | ||
diff --git a/drivers/regulator/max8952.c b/drivers/regulator/max8952.c index 0d5dda4fd911..a8f4ecfb0843 100644 --- a/drivers/regulator/max8952.c +++ b/drivers/regulator/max8952.c | |||
@@ -133,7 +133,7 @@ static int max8952_get_voltage(struct regulator_dev *rdev) | |||
133 | } | 133 | } |
134 | 134 | ||
135 | static int max8952_set_voltage(struct regulator_dev *rdev, | 135 | static int max8952_set_voltage(struct regulator_dev *rdev, |
136 | int min_uV, int max_uV) | 136 | int min_uV, int max_uV, unsigned *selector) |
137 | { | 137 | { |
138 | struct max8952_data *max8952 = rdev_get_drvdata(rdev); | 138 | struct max8952_data *max8952 = rdev_get_drvdata(rdev); |
139 | s8 vid = -1, i; | 139 | s8 vid = -1, i; |
@@ -156,6 +156,7 @@ static int max8952_set_voltage(struct regulator_dev *rdev, | |||
156 | if (vid >= 0 && vid < MAX8952_NUM_DVS_MODE) { | 156 | if (vid >= 0 && vid < MAX8952_NUM_DVS_MODE) { |
157 | max8952->vid0 = (vid % 2 == 1); | 157 | max8952->vid0 = (vid % 2 == 1); |
158 | max8952->vid1 = (((vid >> 1) % 2) == 1); | 158 | max8952->vid1 = (((vid >> 1) % 2) == 1); |
159 | *selector = vid; | ||
159 | gpio_set_value(max8952->pdata->gpio_vid0, max8952->vid0); | 160 | gpio_set_value(max8952->pdata->gpio_vid0, max8952->vid0); |
160 | gpio_set_value(max8952->pdata->gpio_vid1, max8952->vid1); | 161 | gpio_set_value(max8952->pdata->gpio_vid1, max8952->vid1); |
161 | } else | 162 | } else |
diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c index 5c20756db607..cb28cf8b9397 100644 --- a/drivers/regulator/max8998.c +++ b/drivers/regulator/max8998.c | |||
@@ -304,7 +304,7 @@ static int max8998_get_voltage(struct regulator_dev *rdev) | |||
304 | } | 304 | } |
305 | 305 | ||
306 | static int max8998_set_voltage_ldo(struct regulator_dev *rdev, | 306 | static int max8998_set_voltage_ldo(struct regulator_dev *rdev, |
307 | int min_uV, int max_uV) | 307 | int min_uV, int max_uV, unsigned *selector) |
308 | { | 308 | { |
309 | struct max8998_data *max8998 = rdev_get_drvdata(rdev); | 309 | struct max8998_data *max8998 = rdev_get_drvdata(rdev); |
310 | struct i2c_client *i2c = max8998->iodev->i2c; | 310 | struct i2c_client *i2c = max8998->iodev->i2c; |
@@ -331,6 +331,8 @@ static int max8998_set_voltage_ldo(struct regulator_dev *rdev, | |||
331 | if (desc->min + desc->step*i > max_vol) | 331 | if (desc->min + desc->step*i > max_vol) |
332 | return -EINVAL; | 332 | return -EINVAL; |
333 | 333 | ||
334 | *selector = i; | ||
335 | |||
334 | ret = max8998_get_voltage_register(rdev, ®, &shift, &mask); | 336 | ret = max8998_get_voltage_register(rdev, ®, &shift, &mask); |
335 | if (ret) | 337 | if (ret) |
336 | return ret; | 338 | return ret; |
@@ -352,7 +354,7 @@ static inline void buck2_gpio_set(int gpio, int v) | |||
352 | } | 354 | } |
353 | 355 | ||
354 | static int max8998_set_voltage_buck(struct regulator_dev *rdev, | 356 | static int max8998_set_voltage_buck(struct regulator_dev *rdev, |
355 | int min_uV, int max_uV) | 357 | int min_uV, int max_uV, int *selector) |
356 | { | 358 | { |
357 | struct max8998_data *max8998 = rdev_get_drvdata(rdev); | 359 | struct max8998_data *max8998 = rdev_get_drvdata(rdev); |
358 | struct max8998_platform_data *pdata = | 360 | struct max8998_platform_data *pdata = |
@@ -384,6 +386,8 @@ static int max8998_set_voltage_buck(struct regulator_dev *rdev, | |||
384 | if (desc->min + desc->step*i > max_vol) | 386 | if (desc->min + desc->step*i > max_vol) |
385 | return -EINVAL; | 387 | return -EINVAL; |
386 | 388 | ||
389 | *selector = i; | ||
390 | |||
387 | ret = max8998_get_voltage_register(rdev, ®, &shift, &mask); | 391 | ret = max8998_get_voltage_register(rdev, ®, &shift, &mask); |
388 | if (ret) | 392 | if (ret) |
389 | return ret; | 393 | return ret; |
diff --git a/drivers/regulator/mc13783-regulator.c b/drivers/regulator/mc13783-regulator.c index ecd99f59dba8..47ea99949798 100644 --- a/drivers/regulator/mc13783-regulator.c +++ b/drivers/regulator/mc13783-regulator.c | |||
@@ -373,7 +373,8 @@ static int mc13783_get_best_voltage_index(struct regulator_dev *rdev, | |||
373 | } | 373 | } |
374 | 374 | ||
375 | static int mc13783_regulator_set_voltage(struct regulator_dev *rdev, | 375 | static int mc13783_regulator_set_voltage(struct regulator_dev *rdev, |
376 | int min_uV, int max_uV) | 376 | int min_uV, int max_uV, |
377 | unsigned *selector) | ||
377 | { | 378 | { |
378 | struct mc13783_regulator_priv *priv = rdev_get_drvdata(rdev); | 379 | struct mc13783_regulator_priv *priv = rdev_get_drvdata(rdev); |
379 | int value, id = rdev_get_id(rdev); | 380 | int value, id = rdev_get_id(rdev); |
@@ -388,6 +389,8 @@ static int mc13783_regulator_set_voltage(struct regulator_dev *rdev, | |||
388 | if (value < 0) | 389 | if (value < 0) |
389 | return value; | 390 | return value; |
390 | 391 | ||
392 | *selector = value; | ||
393 | |||
391 | mc13783_lock(priv->mc13783); | 394 | mc13783_lock(priv->mc13783); |
392 | ret = mc13783_reg_rmw(priv->mc13783, mc13783_regulators[id].vsel_reg, | 395 | ret = mc13783_reg_rmw(priv->mc13783, mc13783_regulators[id].vsel_reg, |
393 | mc13783_regulators[id].vsel_mask, | 396 | mc13783_regulators[id].vsel_mask, |
@@ -433,13 +436,16 @@ static struct regulator_ops mc13783_regulator_ops = { | |||
433 | }; | 436 | }; |
434 | 437 | ||
435 | static int mc13783_fixed_regulator_set_voltage(struct regulator_dev *rdev, | 438 | static int mc13783_fixed_regulator_set_voltage(struct regulator_dev *rdev, |
436 | int min_uV, int max_uV) | 439 | int min_uV, int max_uV, |
440 | unsigned int *selector) | ||
437 | { | 441 | { |
438 | int id = rdev_get_id(rdev); | 442 | int id = rdev_get_id(rdev); |
439 | 443 | ||
440 | dev_dbg(rdev_get_dev(rdev), "%s id: %d min_uV: %d max_uV: %d\n", | 444 | dev_dbg(rdev_get_dev(rdev), "%s id: %d min_uV: %d max_uV: %d\n", |
441 | __func__, id, min_uV, max_uV); | 445 | __func__, id, min_uV, max_uV); |
442 | 446 | ||
447 | *selector = 0; | ||
448 | |||
443 | if (min_uV >= mc13783_regulators[id].voltages[0] && | 449 | if (min_uV >= mc13783_regulators[id].voltages[0] && |
444 | max_uV <= mc13783_regulators[id].voltages[0]) | 450 | max_uV <= mc13783_regulators[id].voltages[0]) |
445 | return 0; | 451 | return 0; |
diff --git a/drivers/regulator/pcap-regulator.c b/drivers/regulator/pcap-regulator.c index 29d0566379ae..8dca11694f75 100644 --- a/drivers/regulator/pcap-regulator.c +++ b/drivers/regulator/pcap-regulator.c | |||
@@ -151,7 +151,8 @@ static struct pcap_regulator vreg_table[] = { | |||
151 | }; | 151 | }; |
152 | 152 | ||
153 | static int pcap_regulator_set_voltage(struct regulator_dev *rdev, | 153 | static int pcap_regulator_set_voltage(struct regulator_dev *rdev, |
154 | int min_uV, int max_uV) | 154 | int min_uV, int max_uV, |
155 | unsiged *selector) | ||
155 | { | 156 | { |
156 | struct pcap_regulator *vreg = &vreg_table[rdev_get_id(rdev)]; | 157 | struct pcap_regulator *vreg = &vreg_table[rdev_get_id(rdev)]; |
157 | void *pcap = rdev_get_drvdata(rdev); | 158 | void *pcap = rdev_get_drvdata(rdev); |
@@ -170,10 +171,12 @@ static int pcap_regulator_set_voltage(struct regulator_dev *rdev, | |||
170 | i = 0; | 171 | i = 0; |
171 | 172 | ||
172 | uV = vreg->voltage_table[i] * 1000; | 173 | uV = vreg->voltage_table[i] * 1000; |
173 | if (min_uV <= uV && uV <= max_uV) | 174 | if (min_uV <= uV && uV <= max_uV) { |
175 | *selector = i; | ||
174 | return ezx_pcap_set_bits(pcap, vreg->reg, | 176 | return ezx_pcap_set_bits(pcap, vreg->reg, |
175 | (vreg->n_voltages - 1) << vreg->index, | 177 | (vreg->n_voltages - 1) << vreg->index, |
176 | i << vreg->index); | 178 | i << vreg->index); |
179 | } | ||
177 | 180 | ||
178 | if (i == 0 && rdev_get_id(rdev) == V1) | 181 | if (i == 0 && rdev_get_id(rdev) == V1) |
179 | i = vreg->n_voltages - 1; | 182 | i = vreg->n_voltages - 1; |
diff --git a/drivers/regulator/pcf50633-regulator.c b/drivers/regulator/pcf50633-regulator.c index c8f41dc05b76..69a11d9dd87f 100644 --- a/drivers/regulator/pcf50633-regulator.c +++ b/drivers/regulator/pcf50633-regulator.c | |||
@@ -108,7 +108,8 @@ static unsigned int ldo_voltage_value(u8 bits) | |||
108 | } | 108 | } |
109 | 109 | ||
110 | static int pcf50633_regulator_set_voltage(struct regulator_dev *rdev, | 110 | static int pcf50633_regulator_set_voltage(struct regulator_dev *rdev, |
111 | int min_uV, int max_uV) | 111 | int min_uV, int max_uV, |
112 | unsigned *selector) | ||
112 | { | 113 | { |
113 | struct pcf50633 *pcf; | 114 | struct pcf50633 *pcf; |
114 | int regulator_id, millivolts; | 115 | int regulator_id, millivolts; |
@@ -147,6 +148,8 @@ static int pcf50633_regulator_set_voltage(struct regulator_dev *rdev, | |||
147 | return -EINVAL; | 148 | return -EINVAL; |
148 | } | 149 | } |
149 | 150 | ||
151 | *selector = volt_bits; | ||
152 | |||
150 | return pcf50633_reg_write(pcf, regnr, volt_bits); | 153 | return pcf50633_reg_write(pcf, regnr, volt_bits); |
151 | } | 154 | } |
152 | 155 | ||
diff --git a/drivers/regulator/tps65023-regulator.c b/drivers/regulator/tps65023-regulator.c index cd6d4fc9d74f..60a7ca5409e9 100644 --- a/drivers/regulator/tps65023-regulator.c +++ b/drivers/regulator/tps65023-regulator.c | |||
@@ -321,7 +321,8 @@ static int tps65023_dcdc_get_voltage(struct regulator_dev *dev) | |||
321 | } | 321 | } |
322 | 322 | ||
323 | static int tps65023_dcdc_set_voltage(struct regulator_dev *dev, | 323 | static int tps65023_dcdc_set_voltage(struct regulator_dev *dev, |
324 | int min_uV, int max_uV) | 324 | int min_uV, int max_uV, |
325 | unsigned *selector) | ||
325 | { | 326 | { |
326 | struct tps_pmic *tps = rdev_get_drvdata(dev); | 327 | struct tps_pmic *tps = rdev_get_drvdata(dev); |
327 | int dcdc = rdev_get_id(dev); | 328 | int dcdc = rdev_get_id(dev); |
@@ -346,6 +347,8 @@ static int tps65023_dcdc_set_voltage(struct regulator_dev *dev, | |||
346 | break; | 347 | break; |
347 | } | 348 | } |
348 | 349 | ||
350 | *selector = vsel; | ||
351 | |||
349 | /* write to the register in case we found a match */ | 352 | /* write to the register in case we found a match */ |
350 | if (vsel == tps->info[dcdc]->table_len) | 353 | if (vsel == tps->info[dcdc]->table_len) |
351 | return -EINVAL; | 354 | return -EINVAL; |
@@ -371,7 +374,7 @@ static int tps65023_ldo_get_voltage(struct regulator_dev *dev) | |||
371 | } | 374 | } |
372 | 375 | ||
373 | static int tps65023_ldo_set_voltage(struct regulator_dev *dev, | 376 | static int tps65023_ldo_set_voltage(struct regulator_dev *dev, |
374 | int min_uV, int max_uV) | 377 | int min_uV, int max_uV, unsigned *selector) |
375 | { | 378 | { |
376 | struct tps_pmic *tps = rdev_get_drvdata(dev); | 379 | struct tps_pmic *tps = rdev_get_drvdata(dev); |
377 | int data, vsel, ldo = rdev_get_id(dev); | 380 | int data, vsel, ldo = rdev_get_id(dev); |
@@ -396,6 +399,8 @@ static int tps65023_ldo_set_voltage(struct regulator_dev *dev, | |||
396 | if (vsel == tps->info[ldo]->table_len) | 399 | if (vsel == tps->info[ldo]->table_len) |
397 | return -EINVAL; | 400 | return -EINVAL; |
398 | 401 | ||
402 | *selector = vsel; | ||
403 | |||
399 | data = tps_65023_reg_read(tps, TPS65023_REG_LDO_CTRL); | 404 | data = tps_65023_reg_read(tps, TPS65023_REG_LDO_CTRL); |
400 | if (data < 0) | 405 | if (data < 0) |
401 | return data; | 406 | return data; |
diff --git a/drivers/regulator/tps6507x-regulator.c b/drivers/regulator/tps6507x-regulator.c index 020f5878d7ff..064755290599 100644 --- a/drivers/regulator/tps6507x-regulator.c +++ b/drivers/regulator/tps6507x-regulator.c | |||
@@ -369,7 +369,8 @@ static int tps6507x_pmic_dcdc_get_voltage(struct regulator_dev *dev) | |||
369 | } | 369 | } |
370 | 370 | ||
371 | static int tps6507x_pmic_dcdc_set_voltage(struct regulator_dev *dev, | 371 | static int tps6507x_pmic_dcdc_set_voltage(struct regulator_dev *dev, |
372 | int min_uV, int max_uV) | 372 | int min_uV, int max_uV, |
373 | unsigned *selector) | ||
373 | { | 374 | { |
374 | struct tps6507x_pmic *tps = rdev_get_drvdata(dev); | 375 | struct tps6507x_pmic *tps = rdev_get_drvdata(dev); |
375 | int data, vsel, dcdc = rdev_get_id(dev); | 376 | int data, vsel, dcdc = rdev_get_id(dev); |
@@ -415,6 +416,8 @@ static int tps6507x_pmic_dcdc_set_voltage(struct regulator_dev *dev, | |||
415 | if (vsel == tps->info[dcdc]->table_len) | 416 | if (vsel == tps->info[dcdc]->table_len) |
416 | return -EINVAL; | 417 | return -EINVAL; |
417 | 418 | ||
419 | *selector = vsel; | ||
420 | |||
418 | data = tps6507x_pmic_reg_read(tps, reg); | 421 | data = tps6507x_pmic_reg_read(tps, reg); |
419 | if (data < 0) | 422 | if (data < 0) |
420 | return data; | 423 | return data; |
@@ -450,7 +453,8 @@ static int tps6507x_pmic_ldo_get_voltage(struct regulator_dev *dev) | |||
450 | } | 453 | } |
451 | 454 | ||
452 | static int tps6507x_pmic_ldo_set_voltage(struct regulator_dev *dev, | 455 | static int tps6507x_pmic_ldo_set_voltage(struct regulator_dev *dev, |
453 | int min_uV, int max_uV) | 456 | int min_uV, int max_uV, |
457 | unsigned *selector) | ||
454 | { | 458 | { |
455 | struct tps6507x_pmic *tps = rdev_get_drvdata(dev); | 459 | struct tps6507x_pmic *tps = rdev_get_drvdata(dev); |
456 | int data, vsel, ldo = rdev_get_id(dev); | 460 | int data, vsel, ldo = rdev_get_id(dev); |
@@ -483,6 +487,8 @@ static int tps6507x_pmic_ldo_set_voltage(struct regulator_dev *dev, | |||
483 | if (vsel == tps->info[ldo]->table_len) | 487 | if (vsel == tps->info[ldo]->table_len) |
484 | return -EINVAL; | 488 | return -EINVAL; |
485 | 489 | ||
490 | *selector = vsel; | ||
491 | |||
486 | data = tps6507x_pmic_reg_read(tps, reg); | 492 | data = tps6507x_pmic_reg_read(tps, reg); |
487 | if (data < 0) | 493 | if (data < 0) |
488 | return data; | 494 | return data; |
diff --git a/drivers/regulator/tps6586x-regulator.c b/drivers/regulator/tps6586x-regulator.c index 6d20b0454a1d..bb04a75a4c98 100644 --- a/drivers/regulator/tps6586x-regulator.c +++ b/drivers/regulator/tps6586x-regulator.c | |||
@@ -85,7 +85,8 @@ static int tps6586x_ldo_list_voltage(struct regulator_dev *rdev, | |||
85 | 85 | ||
86 | static int __tps6586x_ldo_set_voltage(struct device *parent, | 86 | static int __tps6586x_ldo_set_voltage(struct device *parent, |
87 | struct tps6586x_regulator *ri, | 87 | struct tps6586x_regulator *ri, |
88 | int min_uV, int max_uV) | 88 | int min_uV, int max_uV, |
89 | unsigned *selector) | ||
89 | { | 90 | { |
90 | int val, uV; | 91 | int val, uV; |
91 | uint8_t mask; | 92 | uint8_t mask; |
@@ -100,6 +101,8 @@ static int __tps6586x_ldo_set_voltage(struct device *parent, | |||
100 | /* use the first in-range value */ | 101 | /* use the first in-range value */ |
101 | if (min_uV <= uV && uV <= max_uV) { | 102 | if (min_uV <= uV && uV <= max_uV) { |
102 | 103 | ||
104 | *selector = val; | ||
105 | |||
103 | val <<= ri->volt_shift; | 106 | val <<= ri->volt_shift; |
104 | mask = ((1 << ri->volt_nbits) - 1) << ri->volt_shift; | 107 | mask = ((1 << ri->volt_nbits) - 1) << ri->volt_shift; |
105 | 108 | ||
@@ -111,12 +114,13 @@ static int __tps6586x_ldo_set_voltage(struct device *parent, | |||
111 | } | 114 | } |
112 | 115 | ||
113 | static int tps6586x_ldo_set_voltage(struct regulator_dev *rdev, | 116 | static int tps6586x_ldo_set_voltage(struct regulator_dev *rdev, |
114 | int min_uV, int max_uV) | 117 | int min_uV, int max_uV, unsigned *selector) |
115 | { | 118 | { |
116 | struct tps6586x_regulator *ri = rdev_get_drvdata(rdev); | 119 | struct tps6586x_regulator *ri = rdev_get_drvdata(rdev); |
117 | struct device *parent = to_tps6586x_dev(rdev); | 120 | struct device *parent = to_tps6586x_dev(rdev); |
118 | 121 | ||
119 | return __tps6586x_ldo_set_voltage(parent, ri, min_uV, max_uV); | 122 | return __tps6586x_ldo_set_voltage(parent, ri, min_uV, max_uV, |
123 | selector); | ||
120 | } | 124 | } |
121 | 125 | ||
122 | static int tps6586x_ldo_get_voltage(struct regulator_dev *rdev) | 126 | static int tps6586x_ldo_get_voltage(struct regulator_dev *rdev) |
@@ -140,13 +144,14 @@ static int tps6586x_ldo_get_voltage(struct regulator_dev *rdev) | |||
140 | } | 144 | } |
141 | 145 | ||
142 | static int tps6586x_dvm_set_voltage(struct regulator_dev *rdev, | 146 | static int tps6586x_dvm_set_voltage(struct regulator_dev *rdev, |
143 | int min_uV, int max_uV) | 147 | int min_uV, int max_uV, unsigned *selector) |
144 | { | 148 | { |
145 | struct tps6586x_regulator *ri = rdev_get_drvdata(rdev); | 149 | struct tps6586x_regulator *ri = rdev_get_drvdata(rdev); |
146 | struct device *parent = to_tps6586x_dev(rdev); | 150 | struct device *parent = to_tps6586x_dev(rdev); |
147 | int ret; | 151 | int ret; |
148 | 152 | ||
149 | ret = __tps6586x_ldo_set_voltage(parent, ri, min_uV, max_uV); | 153 | ret = __tps6586x_ldo_set_voltage(parent, ri, min_uV, max_uV, |
154 | selector); | ||
150 | if (ret) | 155 | if (ret) |
151 | return ret; | 156 | return ret; |
152 | 157 | ||
diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c index a57262a4fa6c..bd332cf1cc3f 100644 --- a/drivers/regulator/twl-regulator.c +++ b/drivers/regulator/twl-regulator.c | |||
@@ -329,7 +329,8 @@ static int twl4030ldo_list_voltage(struct regulator_dev *rdev, unsigned index) | |||
329 | } | 329 | } |
330 | 330 | ||
331 | static int | 331 | static int |
332 | twl4030ldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV) | 332 | twl4030ldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV, |
333 | unsigned *selector) | ||
333 | { | 334 | { |
334 | struct twlreg_info *info = rdev_get_drvdata(rdev); | 335 | struct twlreg_info *info = rdev_get_drvdata(rdev); |
335 | int vsel; | 336 | int vsel; |
@@ -345,9 +346,11 @@ twl4030ldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV) | |||
345 | /* REVISIT for VAUX2, first match may not be best/lowest */ | 346 | /* REVISIT for VAUX2, first match may not be best/lowest */ |
346 | 347 | ||
347 | /* use the first in-range value */ | 348 | /* use the first in-range value */ |
348 | if (min_uV <= uV && uV <= max_uV) | 349 | if (min_uV <= uV && uV <= max_uV) { |
350 | *selector = vsel; | ||
349 | return twlreg_write(info, TWL_MODULE_PM_RECEIVER, | 351 | return twlreg_write(info, TWL_MODULE_PM_RECEIVER, |
350 | VREG_VOLTAGE, vsel); | 352 | VREG_VOLTAGE, vsel); |
353 | } | ||
351 | } | 354 | } |
352 | 355 | ||
353 | return -EDOM; | 356 | return -EDOM; |
@@ -389,7 +392,8 @@ static int twl6030ldo_list_voltage(struct regulator_dev *rdev, unsigned index) | |||
389 | } | 392 | } |
390 | 393 | ||
391 | static int | 394 | static int |
392 | twl6030ldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV) | 395 | twl6030ldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV, |
396 | unsigned *selector) | ||
393 | { | 397 | { |
394 | struct twlreg_info *info = rdev_get_drvdata(rdev); | 398 | struct twlreg_info *info = rdev_get_drvdata(rdev); |
395 | int vsel; | 399 | int vsel; |
@@ -402,6 +406,7 @@ twl6030ldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV) | |||
402 | * mV = 1000mv + 100mv * (vsel - 1) | 406 | * mV = 1000mv + 100mv * (vsel - 1) |
403 | */ | 407 | */ |
404 | vsel = (min_uV/1000 - 1000)/100 + 1; | 408 | vsel = (min_uV/1000 - 1000)/100 + 1; |
409 | *selector = vsel; | ||
405 | return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE, vsel); | 410 | return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE, vsel); |
406 | 411 | ||
407 | } | 412 | } |
diff --git a/drivers/regulator/wm831x-dcdc.c b/drivers/regulator/wm831x-dcdc.c index dbfaf5945e48..71da6b2ad863 100644 --- a/drivers/regulator/wm831x-dcdc.c +++ b/drivers/regulator/wm831x-dcdc.c | |||
@@ -302,7 +302,7 @@ static int wm831x_buckv_set_dvs(struct regulator_dev *rdev, int state) | |||
302 | } | 302 | } |
303 | 303 | ||
304 | static int wm831x_buckv_set_voltage(struct regulator_dev *rdev, | 304 | static int wm831x_buckv_set_voltage(struct regulator_dev *rdev, |
305 | int min_uV, int max_uV) | 305 | int min_uV, int max_uV, unsigned *selector) |
306 | { | 306 | { |
307 | struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev); | 307 | struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev); |
308 | struct wm831x *wm831x = dcdc->wm831x; | 308 | struct wm831x *wm831x = dcdc->wm831x; |
@@ -314,6 +314,8 @@ static int wm831x_buckv_set_voltage(struct regulator_dev *rdev, | |||
314 | if (vsel < 0) | 314 | if (vsel < 0) |
315 | return vsel; | 315 | return vsel; |
316 | 316 | ||
317 | *selector = vsel; | ||
318 | |||
317 | /* If this value is already set then do a GPIO update if we can */ | 319 | /* If this value is already set then do a GPIO update if we can */ |
318 | if (dcdc->dvs_gpio && dcdc->on_vsel == vsel) | 320 | if (dcdc->dvs_gpio && dcdc->on_vsel == vsel) |
319 | return wm831x_buckv_set_dvs(rdev, 0); | 321 | return wm831x_buckv_set_dvs(rdev, 0); |
@@ -636,7 +638,7 @@ static int wm831x_buckp_list_voltage(struct regulator_dev *rdev, | |||
636 | } | 638 | } |
637 | 639 | ||
638 | static int wm831x_buckp_set_voltage_int(struct regulator_dev *rdev, int reg, | 640 | static int wm831x_buckp_set_voltage_int(struct regulator_dev *rdev, int reg, |
639 | int min_uV, int max_uV) | 641 | int min_uV, int max_uV, int *selector) |
640 | { | 642 | { |
641 | struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev); | 643 | struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev); |
642 | struct wm831x *wm831x = dcdc->wm831x; | 644 | struct wm831x *wm831x = dcdc->wm831x; |
@@ -650,16 +652,20 @@ static int wm831x_buckp_set_voltage_int(struct regulator_dev *rdev, int reg, | |||
650 | if (wm831x_buckp_list_voltage(rdev, vsel) > max_uV) | 652 | if (wm831x_buckp_list_voltage(rdev, vsel) > max_uV) |
651 | return -EINVAL; | 653 | return -EINVAL; |
652 | 654 | ||
655 | *selector = vsel; | ||
656 | |||
653 | return wm831x_set_bits(wm831x, reg, WM831X_DC3_ON_VSEL_MASK, vsel); | 657 | return wm831x_set_bits(wm831x, reg, WM831X_DC3_ON_VSEL_MASK, vsel); |
654 | } | 658 | } |
655 | 659 | ||
656 | static int wm831x_buckp_set_voltage(struct regulator_dev *rdev, | 660 | static int wm831x_buckp_set_voltage(struct regulator_dev *rdev, |
657 | int min_uV, int max_uV) | 661 | int min_uV, int max_uV, |
662 | unsigned *selector) | ||
658 | { | 663 | { |
659 | struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev); | 664 | struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev); |
660 | u16 reg = dcdc->base + WM831X_DCDC_ON_CONFIG; | 665 | u16 reg = dcdc->base + WM831X_DCDC_ON_CONFIG; |
661 | 666 | ||
662 | return wm831x_buckp_set_voltage_int(rdev, reg, min_uV, max_uV); | 667 | return wm831x_buckp_set_voltage_int(rdev, reg, min_uV, max_uV, |
668 | selector); | ||
663 | } | 669 | } |
664 | 670 | ||
665 | static int wm831x_buckp_set_suspend_voltage(struct regulator_dev *rdev, | 671 | static int wm831x_buckp_set_suspend_voltage(struct regulator_dev *rdev, |
@@ -667,8 +673,9 @@ static int wm831x_buckp_set_suspend_voltage(struct regulator_dev *rdev, | |||
667 | { | 673 | { |
668 | struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev); | 674 | struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev); |
669 | u16 reg = dcdc->base + WM831X_DCDC_SLEEP_CONTROL; | 675 | u16 reg = dcdc->base + WM831X_DCDC_SLEEP_CONTROL; |
676 | unsigned selector; | ||
670 | 677 | ||
671 | return wm831x_buckp_set_voltage_int(rdev, reg, uV, uV); | 678 | return wm831x_buckp_set_voltage_int(rdev, reg, uV, uV, &selector); |
672 | } | 679 | } |
673 | 680 | ||
674 | static int wm831x_buckp_get_voltage(struct regulator_dev *rdev) | 681 | static int wm831x_buckp_get_voltage(struct regulator_dev *rdev) |
diff --git a/drivers/regulator/wm831x-ldo.c b/drivers/regulator/wm831x-ldo.c index 9edf8f692341..9594e7161b4d 100644 --- a/drivers/regulator/wm831x-ldo.c +++ b/drivers/regulator/wm831x-ldo.c | |||
@@ -113,7 +113,8 @@ static int wm831x_gp_ldo_list_voltage(struct regulator_dev *rdev, | |||
113 | } | 113 | } |
114 | 114 | ||
115 | static int wm831x_gp_ldo_set_voltage_int(struct regulator_dev *rdev, int reg, | 115 | static int wm831x_gp_ldo_set_voltage_int(struct regulator_dev *rdev, int reg, |
116 | int min_uV, int max_uV) | 116 | int min_uV, int max_uV, |
117 | unsigned *selector) | ||
117 | { | 118 | { |
118 | struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); | 119 | struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); |
119 | struct wm831x *wm831x = ldo->wm831x; | 120 | struct wm831x *wm831x = ldo->wm831x; |
@@ -133,16 +134,20 @@ static int wm831x_gp_ldo_set_voltage_int(struct regulator_dev *rdev, int reg, | |||
133 | if (ret < min_uV || ret > max_uV) | 134 | if (ret < min_uV || ret > max_uV) |
134 | return -EINVAL; | 135 | return -EINVAL; |
135 | 136 | ||
137 | *selector = vsel; | ||
138 | |||
136 | return wm831x_set_bits(wm831x, reg, WM831X_LDO1_ON_VSEL_MASK, vsel); | 139 | return wm831x_set_bits(wm831x, reg, WM831X_LDO1_ON_VSEL_MASK, vsel); |
137 | } | 140 | } |
138 | 141 | ||
139 | static int wm831x_gp_ldo_set_voltage(struct regulator_dev *rdev, | 142 | static int wm831x_gp_ldo_set_voltage(struct regulator_dev *rdev, |
140 | int min_uV, int max_uV) | 143 | int min_uV, int max_uV, |
144 | unsigned *selector) | ||
141 | { | 145 | { |
142 | struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); | 146 | struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); |
143 | int reg = ldo->base + WM831X_LDO_ON_CONTROL; | 147 | int reg = ldo->base + WM831X_LDO_ON_CONTROL; |
144 | 148 | ||
145 | return wm831x_gp_ldo_set_voltage_int(rdev, reg, min_uV, max_uV); | 149 | return wm831x_gp_ldo_set_voltage_int(rdev, reg, min_uV, max_uV, |
150 | selector); | ||
146 | } | 151 | } |
147 | 152 | ||
148 | static int wm831x_gp_ldo_set_suspend_voltage(struct regulator_dev *rdev, | 153 | static int wm831x_gp_ldo_set_suspend_voltage(struct regulator_dev *rdev, |
@@ -150,8 +155,9 @@ static int wm831x_gp_ldo_set_suspend_voltage(struct regulator_dev *rdev, | |||
150 | { | 155 | { |
151 | struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); | 156 | struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); |
152 | int reg = ldo->base + WM831X_LDO_SLEEP_CONTROL; | 157 | int reg = ldo->base + WM831X_LDO_SLEEP_CONTROL; |
158 | unsigned int selector; | ||
153 | 159 | ||
154 | return wm831x_gp_ldo_set_voltage_int(rdev, reg, uV, uV); | 160 | return wm831x_gp_ldo_set_voltage_int(rdev, reg, uV, uV, &selector); |
155 | } | 161 | } |
156 | 162 | ||
157 | static int wm831x_gp_ldo_get_voltage(struct regulator_dev *rdev) | 163 | static int wm831x_gp_ldo_get_voltage(struct regulator_dev *rdev) |
@@ -413,7 +419,8 @@ static int wm831x_aldo_list_voltage(struct regulator_dev *rdev, | |||
413 | } | 419 | } |
414 | 420 | ||
415 | static int wm831x_aldo_set_voltage_int(struct regulator_dev *rdev, int reg, | 421 | static int wm831x_aldo_set_voltage_int(struct regulator_dev *rdev, int reg, |
416 | int min_uV, int max_uV) | 422 | int min_uV, int max_uV, |
423 | unsigned *selector) | ||
417 | { | 424 | { |
418 | struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); | 425 | struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); |
419 | struct wm831x *wm831x = ldo->wm831x; | 426 | struct wm831x *wm831x = ldo->wm831x; |
@@ -433,16 +440,19 @@ static int wm831x_aldo_set_voltage_int(struct regulator_dev *rdev, int reg, | |||
433 | if (ret < min_uV || ret > max_uV) | 440 | if (ret < min_uV || ret > max_uV) |
434 | return -EINVAL; | 441 | return -EINVAL; |
435 | 442 | ||
443 | *selector = vsel; | ||
444 | |||
436 | return wm831x_set_bits(wm831x, reg, WM831X_LDO7_ON_VSEL_MASK, vsel); | 445 | return wm831x_set_bits(wm831x, reg, WM831X_LDO7_ON_VSEL_MASK, vsel); |
437 | } | 446 | } |
438 | 447 | ||
439 | static int wm831x_aldo_set_voltage(struct regulator_dev *rdev, | 448 | static int wm831x_aldo_set_voltage(struct regulator_dev *rdev, |
440 | int min_uV, int max_uV) | 449 | int min_uV, int max_uV, unsigned *selector) |
441 | { | 450 | { |
442 | struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); | 451 | struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); |
443 | int reg = ldo->base + WM831X_LDO_ON_CONTROL; | 452 | int reg = ldo->base + WM831X_LDO_ON_CONTROL; |
444 | 453 | ||
445 | return wm831x_aldo_set_voltage_int(rdev, reg, min_uV, max_uV); | 454 | return wm831x_aldo_set_voltage_int(rdev, reg, min_uV, max_uV, |
455 | selector); | ||
446 | } | 456 | } |
447 | 457 | ||
448 | static int wm831x_aldo_set_suspend_voltage(struct regulator_dev *rdev, | 458 | static int wm831x_aldo_set_suspend_voltage(struct regulator_dev *rdev, |
@@ -450,8 +460,9 @@ static int wm831x_aldo_set_suspend_voltage(struct regulator_dev *rdev, | |||
450 | { | 460 | { |
451 | struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); | 461 | struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); |
452 | int reg = ldo->base + WM831X_LDO_SLEEP_CONTROL; | 462 | int reg = ldo->base + WM831X_LDO_SLEEP_CONTROL; |
463 | unsigned int selector; | ||
453 | 464 | ||
454 | return wm831x_aldo_set_voltage_int(rdev, reg, uV, uV); | 465 | return wm831x_aldo_set_voltage_int(rdev, reg, uV, uV, &selector); |
455 | } | 466 | } |
456 | 467 | ||
457 | static int wm831x_aldo_get_voltage(struct regulator_dev *rdev) | 468 | static int wm831x_aldo_get_voltage(struct regulator_dev *rdev) |
@@ -666,7 +677,8 @@ static int wm831x_alive_ldo_list_voltage(struct regulator_dev *rdev, | |||
666 | 677 | ||
667 | static int wm831x_alive_ldo_set_voltage_int(struct regulator_dev *rdev, | 678 | static int wm831x_alive_ldo_set_voltage_int(struct regulator_dev *rdev, |
668 | int reg, | 679 | int reg, |
669 | int min_uV, int max_uV) | 680 | int min_uV, int max_uV, |
681 | unsigned *selector) | ||
670 | { | 682 | { |
671 | struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); | 683 | struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); |
672 | struct wm831x *wm831x = ldo->wm831x; | 684 | struct wm831x *wm831x = ldo->wm831x; |
@@ -680,16 +692,20 @@ static int wm831x_alive_ldo_set_voltage_int(struct regulator_dev *rdev, | |||
680 | if (ret < min_uV || ret > max_uV) | 692 | if (ret < min_uV || ret > max_uV) |
681 | return -EINVAL; | 693 | return -EINVAL; |
682 | 694 | ||
695 | *selector = vsel; | ||
696 | |||
683 | return wm831x_set_bits(wm831x, reg, WM831X_LDO11_ON_VSEL_MASK, vsel); | 697 | return wm831x_set_bits(wm831x, reg, WM831X_LDO11_ON_VSEL_MASK, vsel); |
684 | } | 698 | } |
685 | 699 | ||
686 | static int wm831x_alive_ldo_set_voltage(struct regulator_dev *rdev, | 700 | static int wm831x_alive_ldo_set_voltage(struct regulator_dev *rdev, |
687 | int min_uV, int max_uV) | 701 | int min_uV, int max_uV, |
702 | unsigned *selector) | ||
688 | { | 703 | { |
689 | struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); | 704 | struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); |
690 | int reg = ldo->base + WM831X_ALIVE_LDO_ON_CONTROL; | 705 | int reg = ldo->base + WM831X_ALIVE_LDO_ON_CONTROL; |
691 | 706 | ||
692 | return wm831x_alive_ldo_set_voltage_int(rdev, reg, min_uV, max_uV); | 707 | return wm831x_alive_ldo_set_voltage_int(rdev, reg, min_uV, max_uV, |
708 | selector); | ||
693 | } | 709 | } |
694 | 710 | ||
695 | static int wm831x_alive_ldo_set_suspend_voltage(struct regulator_dev *rdev, | 711 | static int wm831x_alive_ldo_set_suspend_voltage(struct regulator_dev *rdev, |
@@ -697,8 +713,9 @@ static int wm831x_alive_ldo_set_suspend_voltage(struct regulator_dev *rdev, | |||
697 | { | 713 | { |
698 | struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); | 714 | struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); |
699 | int reg = ldo->base + WM831X_ALIVE_LDO_SLEEP_CONTROL; | 715 | int reg = ldo->base + WM831X_ALIVE_LDO_SLEEP_CONTROL; |
716 | unsigned selector; | ||
700 | 717 | ||
701 | return wm831x_alive_ldo_set_voltage_int(rdev, reg, uV, uV); | 718 | return wm831x_alive_ldo_set_voltage_int(rdev, reg, uV, uV, &selector); |
702 | } | 719 | } |
703 | 720 | ||
704 | static int wm831x_alive_ldo_get_voltage(struct regulator_dev *rdev) | 721 | static int wm831x_alive_ldo_get_voltage(struct regulator_dev *rdev) |
diff --git a/drivers/regulator/wm8350-regulator.c b/drivers/regulator/wm8350-regulator.c index fe4b8a8a9dfd..7e45b0ddd710 100644 --- a/drivers/regulator/wm8350-regulator.c +++ b/drivers/regulator/wm8350-regulator.c | |||
@@ -360,7 +360,7 @@ int wm8350_isink_set_flash(struct wm8350 *wm8350, int isink, u16 mode, | |||
360 | EXPORT_SYMBOL_GPL(wm8350_isink_set_flash); | 360 | EXPORT_SYMBOL_GPL(wm8350_isink_set_flash); |
361 | 361 | ||
362 | static int wm8350_dcdc_set_voltage(struct regulator_dev *rdev, int min_uV, | 362 | static int wm8350_dcdc_set_voltage(struct regulator_dev *rdev, int min_uV, |
363 | int max_uV) | 363 | int max_uV, unsigned *selector) |
364 | { | 364 | { |
365 | struct wm8350 *wm8350 = rdev_get_drvdata(rdev); | 365 | struct wm8350 *wm8350 = rdev_get_drvdata(rdev); |
366 | int volt_reg, dcdc = rdev_get_id(rdev), mV, | 366 | int volt_reg, dcdc = rdev_get_id(rdev), mV, |
@@ -397,6 +397,8 @@ static int wm8350_dcdc_set_voltage(struct regulator_dev *rdev, int min_uV, | |||
397 | return -EINVAL; | 397 | return -EINVAL; |
398 | } | 398 | } |
399 | 399 | ||
400 | *selector = mV; | ||
401 | |||
400 | /* all DCDCs have same mV bits */ | 402 | /* all DCDCs have same mV bits */ |
401 | val = wm8350_reg_read(wm8350, volt_reg) & ~WM8350_DC1_VSEL_MASK; | 403 | val = wm8350_reg_read(wm8350, volt_reg) & ~WM8350_DC1_VSEL_MASK; |
402 | wm8350_reg_write(wm8350, volt_reg, val | mV); | 404 | wm8350_reg_write(wm8350, volt_reg, val | mV); |
@@ -754,7 +756,7 @@ static int wm8350_ldo_set_suspend_disable(struct regulator_dev *rdev) | |||
754 | } | 756 | } |
755 | 757 | ||
756 | static int wm8350_ldo_set_voltage(struct regulator_dev *rdev, int min_uV, | 758 | static int wm8350_ldo_set_voltage(struct regulator_dev *rdev, int min_uV, |
757 | int max_uV) | 759 | int max_uV, unsigned *selector) |
758 | { | 760 | { |
759 | struct wm8350 *wm8350 = rdev_get_drvdata(rdev); | 761 | struct wm8350 *wm8350 = rdev_get_drvdata(rdev); |
760 | int volt_reg, ldo = rdev_get_id(rdev), mV, min_mV = min_uV / 1000, | 762 | int volt_reg, ldo = rdev_get_id(rdev), mV, min_mV = min_uV / 1000, |
@@ -797,6 +799,8 @@ static int wm8350_ldo_set_voltage(struct regulator_dev *rdev, int min_uV, | |||
797 | return -EINVAL; | 799 | return -EINVAL; |
798 | } | 800 | } |
799 | 801 | ||
802 | *selector = mV; | ||
803 | |||
800 | /* all LDOs have same mV bits */ | 804 | /* all LDOs have same mV bits */ |
801 | val = wm8350_reg_read(wm8350, volt_reg) & ~WM8350_LDO1_VSEL_MASK; | 805 | val = wm8350_reg_read(wm8350, volt_reg) & ~WM8350_LDO1_VSEL_MASK; |
802 | wm8350_reg_write(wm8350, volt_reg, val | mV); | 806 | wm8350_reg_write(wm8350, volt_reg, val | mV); |
diff --git a/drivers/regulator/wm8400-regulator.c b/drivers/regulator/wm8400-regulator.c index 924c7eb29ee9..b42d01cef35a 100644 --- a/drivers/regulator/wm8400-regulator.c +++ b/drivers/regulator/wm8400-regulator.c | |||
@@ -67,7 +67,7 @@ static int wm8400_ldo_get_voltage(struct regulator_dev *dev) | |||
67 | } | 67 | } |
68 | 68 | ||
69 | static int wm8400_ldo_set_voltage(struct regulator_dev *dev, | 69 | static int wm8400_ldo_set_voltage(struct regulator_dev *dev, |
70 | int min_uV, int max_uV) | 70 | int min_uV, int max_uV, unsigned *selector) |
71 | { | 71 | { |
72 | struct wm8400 *wm8400 = rdev_get_drvdata(dev); | 72 | struct wm8400 *wm8400 = rdev_get_drvdata(dev); |
73 | u16 val; | 73 | u16 val; |
@@ -93,6 +93,8 @@ static int wm8400_ldo_set_voltage(struct regulator_dev *dev, | |||
93 | val += 0xf; | 93 | val += 0xf; |
94 | } | 94 | } |
95 | 95 | ||
96 | *selector = val; | ||
97 | |||
96 | return wm8400_set_bits(wm8400, WM8400_LDO1_CONTROL + rdev_get_id(dev), | 98 | return wm8400_set_bits(wm8400, WM8400_LDO1_CONTROL + rdev_get_id(dev), |
97 | WM8400_LDO1_VSEL_MASK, val); | 99 | WM8400_LDO1_VSEL_MASK, val); |
98 | } | 100 | } |
@@ -156,7 +158,7 @@ static int wm8400_dcdc_get_voltage(struct regulator_dev *dev) | |||
156 | } | 158 | } |
157 | 159 | ||
158 | static int wm8400_dcdc_set_voltage(struct regulator_dev *dev, | 160 | static int wm8400_dcdc_set_voltage(struct regulator_dev *dev, |
159 | int min_uV, int max_uV) | 161 | int min_uV, int max_uV, unsigned *selector) |
160 | { | 162 | { |
161 | struct wm8400 *wm8400 = rdev_get_drvdata(dev); | 163 | struct wm8400 *wm8400 = rdev_get_drvdata(dev); |
162 | u16 val; | 164 | u16 val; |
@@ -171,6 +173,8 @@ static int wm8400_dcdc_set_voltage(struct regulator_dev *dev, | |||
171 | return -EINVAL; | 173 | return -EINVAL; |
172 | BUG_ON(850000 + (25000 * val) < min_uV); | 174 | BUG_ON(850000 + (25000 * val) < min_uV); |
173 | 175 | ||
176 | *selector = val; | ||
177 | |||
174 | return wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_1 + offset, | 178 | return wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_1 + offset, |
175 | WM8400_DC1_VSEL_MASK, val); | 179 | WM8400_DC1_VSEL_MASK, val); |
176 | } | 180 | } |
diff --git a/drivers/regulator/wm8994-regulator.c b/drivers/regulator/wm8994-regulator.c index 03713bc66e4a..1b162e699368 100644 --- a/drivers/regulator/wm8994-regulator.c +++ b/drivers/regulator/wm8994-regulator.c | |||
@@ -101,7 +101,7 @@ static int wm8994_ldo1_get_voltage(struct regulator_dev *rdev) | |||
101 | } | 101 | } |
102 | 102 | ||
103 | static int wm8994_ldo1_set_voltage(struct regulator_dev *rdev, | 103 | static int wm8994_ldo1_set_voltage(struct regulator_dev *rdev, |
104 | int min_uV, int max_uV) | 104 | int min_uV, int max_uV, unsigned *s) |
105 | { | 105 | { |
106 | struct wm8994_ldo *ldo = rdev_get_drvdata(rdev); | 106 | struct wm8994_ldo *ldo = rdev_get_drvdata(rdev); |
107 | int selector, v; | 107 | int selector, v; |
@@ -111,6 +111,7 @@ static int wm8994_ldo1_set_voltage(struct regulator_dev *rdev, | |||
111 | if (v < 0 || v > max_uV) | 111 | if (v < 0 || v > max_uV) |
112 | return -EINVAL; | 112 | return -EINVAL; |
113 | 113 | ||
114 | *s = selector; | ||
114 | selector <<= WM8994_LDO1_VSEL_SHIFT; | 115 | selector <<= WM8994_LDO1_VSEL_SHIFT; |
115 | 116 | ||
116 | return wm8994_set_bits(ldo->wm8994, WM8994_LDO_1, | 117 | return wm8994_set_bits(ldo->wm8994, WM8994_LDO_1, |
@@ -152,7 +153,7 @@ static int wm8994_ldo2_get_voltage(struct regulator_dev *rdev) | |||
152 | } | 153 | } |
153 | 154 | ||
154 | static int wm8994_ldo2_set_voltage(struct regulator_dev *rdev, | 155 | static int wm8994_ldo2_set_voltage(struct regulator_dev *rdev, |
155 | int min_uV, int max_uV) | 156 | int min_uV, int max_uV, unsigned *s) |
156 | { | 157 | { |
157 | struct wm8994_ldo *ldo = rdev_get_drvdata(rdev); | 158 | struct wm8994_ldo *ldo = rdev_get_drvdata(rdev); |
158 | int selector, v; | 159 | int selector, v; |
@@ -162,6 +163,7 @@ static int wm8994_ldo2_set_voltage(struct regulator_dev *rdev, | |||
162 | if (v < 0 || v > max_uV) | 163 | if (v < 0 || v > max_uV) |
163 | return -EINVAL; | 164 | return -EINVAL; |
164 | 165 | ||
166 | *s = selector; | ||
165 | selector <<= WM8994_LDO2_VSEL_SHIFT; | 167 | selector <<= WM8994_LDO2_VSEL_SHIFT; |
166 | 168 | ||
167 | return wm8994_set_bits(ldo->wm8994, WM8994_LDO_2, | 169 | return wm8994_set_bits(ldo->wm8994, WM8994_LDO_2, |