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/regulator/max8660.c | |
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/regulator/max8660.c')
-rw-r--r-- | drivers/regulator/max8660.c | 14 |
1 files changed, 11 insertions, 3 deletions
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 |