diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-03-28 03:00:36 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-04-01 06:59:39 -0400 |
commit | 4ca1e1d9e15b99529e55860677fe39b791b88920 (patch) | |
tree | bedfef763eca66559a92136ba419c10993ded1ba /drivers/regulator/88pm8607.c | |
parent | 53b6949ef3291778aa9f921985206fbfd95449d7 (diff) |
regulator: Convert 88pm8607 to set_voltage_sel
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Tested-by: Jett Zhou <jtzhou@marvell.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/88pm8607.c')
-rw-r--r-- | drivers/regulator/88pm8607.c | 43 |
1 files changed, 4 insertions, 39 deletions
diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c index 81b665909171..7fafff23ec43 100644 --- a/drivers/regulator/88pm8607.c +++ b/drivers/regulator/88pm8607.c | |||
@@ -223,51 +223,16 @@ static int pm8607_list_voltage(struct regulator_dev *rdev, unsigned index) | |||
223 | return ret; | 223 | return ret; |
224 | } | 224 | } |
225 | 225 | ||
226 | static int choose_voltage(struct regulator_dev *rdev, int min_uV, int max_uV) | 226 | static int pm8607_set_voltage_sel(struct regulator_dev *rdev, unsigned selector) |
227 | { | ||
228 | struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); | ||
229 | int i, ret = -ENOENT; | ||
230 | |||
231 | if (info->slope_double) { | ||
232 | min_uV = min_uV >> 1; | ||
233 | max_uV = max_uV >> 1; | ||
234 | } | ||
235 | if (info->vol_table) { | ||
236 | for (i = 0; i < rdev->desc->n_voltages; i++) { | ||
237 | if (!info->vol_table[i]) | ||
238 | break; | ||
239 | if ((min_uV <= info->vol_table[i]) | ||
240 | && (max_uV >= info->vol_table[i])) { | ||
241 | ret = i; | ||
242 | break; | ||
243 | } | ||
244 | } | ||
245 | } | ||
246 | if (ret < 0) | ||
247 | pr_err("invalid voltage range (%d %d) uV\n", min_uV, max_uV); | ||
248 | return ret; | ||
249 | } | ||
250 | |||
251 | static int pm8607_set_voltage(struct regulator_dev *rdev, | ||
252 | int min_uV, int max_uV, unsigned *selector) | ||
253 | { | 227 | { |
254 | struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); | 228 | struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); |
255 | uint8_t val, mask; | 229 | uint8_t val, mask; |
256 | int ret; | 230 | int ret; |
257 | 231 | ||
258 | if (min_uV > max_uV) { | 232 | val = (uint8_t)(selector << info->vol_shift); |
259 | pr_err("invalid voltage range (%d, %d) uV\n", min_uV, max_uV); | ||
260 | return -EINVAL; | ||
261 | } | ||
262 | |||
263 | ret = choose_voltage(rdev, min_uV, max_uV); | ||
264 | if (ret < 0) | ||
265 | return -EINVAL; | ||
266 | *selector = ret; | ||
267 | val = (uint8_t)(ret << info->vol_shift); | ||
268 | mask = (rdev->desc->n_voltages - 1) << info->vol_shift; | 233 | mask = (rdev->desc->n_voltages - 1) << info->vol_shift; |
269 | 234 | ||
270 | ret = pm860x_set_bits(info->i2c, info->vol_reg, mask, val); | 235 | ret = pm860x_set_bits(info->i2c, info->vol_reg, mask, selector); |
271 | if (ret) | 236 | if (ret) |
272 | return ret; | 237 | return ret; |
273 | switch (info->desc.id) { | 238 | switch (info->desc.id) { |
@@ -328,7 +293,7 @@ static int pm8607_is_enabled(struct regulator_dev *rdev) | |||
328 | 293 | ||
329 | static struct regulator_ops pm8607_regulator_ops = { | 294 | static struct regulator_ops pm8607_regulator_ops = { |
330 | .list_voltage = pm8607_list_voltage, | 295 | .list_voltage = pm8607_list_voltage, |
331 | .set_voltage = pm8607_set_voltage, | 296 | .set_voltage_sel = pm8607_set_voltage_sel, |
332 | .get_voltage = pm8607_get_voltage, | 297 | .get_voltage = pm8607_get_voltage, |
333 | .enable = pm8607_enable, | 298 | .enable = pm8607_enable, |
334 | .disable = pm8607_disable, | 299 | .disable = pm8607_disable, |