diff options
author | Axel Lin <axel.lin@ingics.com> | 2013-01-17 20:55:06 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-01-18 01:26:19 -0500 |
commit | 31a932e1079d771df6c2daf0b8a871b9b34d7e83 (patch) | |
tree | e464a9132fe93713217cffcb5b2dcd20fbb2442d /drivers/regulator | |
parent | 854f73ecb5c207007f9e850abd6f82ab89eaefb7 (diff) |
regulator: s5m8767: Convert to regulator_[get|set]_voltage_sel_regmap
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/s5m8767.c | 50 |
1 files changed, 12 insertions, 38 deletions
diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index 94b8e484ef90..aa0ccef5c31c 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c | |||
@@ -255,10 +255,8 @@ static int s5m8767_reg_disable(struct regulator_dev *rdev) | |||
255 | return sec_reg_update(s5m8767->iodev, reg, ~mask, mask); | 255 | return sec_reg_update(s5m8767->iodev, reg, ~mask, mask); |
256 | } | 256 | } |
257 | 257 | ||
258 | static int s5m8767_get_voltage_register(struct regulator_dev *rdev, int *_reg) | 258 | static int s5m8767_get_vsel_reg(int reg_id, struct s5m8767_info *s5m8767) |
259 | { | 259 | { |
260 | struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev); | ||
261 | int reg_id = rdev_get_id(rdev); | ||
262 | int reg; | 260 | int reg; |
263 | 261 | ||
264 | switch (reg_id) { | 262 | switch (reg_id) { |
@@ -296,31 +294,7 @@ static int s5m8767_get_voltage_register(struct regulator_dev *rdev, int *_reg) | |||
296 | return -EINVAL; | 294 | return -EINVAL; |
297 | } | 295 | } |
298 | 296 | ||
299 | *_reg = reg; | 297 | return reg; |
300 | |||
301 | return 0; | ||
302 | } | ||
303 | |||
304 | static int s5m8767_get_voltage_sel(struct regulator_dev *rdev) | ||
305 | { | ||
306 | struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev); | ||
307 | int reg, mask, ret; | ||
308 | int reg_id = rdev_get_id(rdev); | ||
309 | unsigned int val; | ||
310 | |||
311 | ret = s5m8767_get_voltage_register(rdev, ®); | ||
312 | if (ret) | ||
313 | return ret; | ||
314 | |||
315 | mask = (reg_id < S5M8767_BUCK1) ? 0x3f : 0xff; | ||
316 | |||
317 | ret = sec_reg_read(s5m8767->iodev, reg, &val); | ||
318 | if (ret) | ||
319 | return ret; | ||
320 | |||
321 | val &= mask; | ||
322 | |||
323 | return val; | ||
324 | } | 298 | } |
325 | 299 | ||
326 | static int s5m8767_convert_voltage_to_sel(const struct sec_voltage_desc *desc, | 300 | static int s5m8767_convert_voltage_to_sel(const struct sec_voltage_desc *desc, |
@@ -372,15 +346,13 @@ static int s5m8767_set_voltage_sel(struct regulator_dev *rdev, | |||
372 | { | 346 | { |
373 | struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev); | 347 | struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev); |
374 | int reg_id = rdev_get_id(rdev); | 348 | int reg_id = rdev_get_id(rdev); |
375 | int reg, mask, ret = 0, old_index, index = 0; | 349 | int old_index, index = 0; |
376 | u8 *buck234_vol = NULL; | 350 | u8 *buck234_vol = NULL; |
377 | 351 | ||
378 | switch (reg_id) { | 352 | switch (reg_id) { |
379 | case S5M8767_LDO1 ... S5M8767_LDO28: | 353 | case S5M8767_LDO1 ... S5M8767_LDO28: |
380 | mask = 0x3f; | ||
381 | break; | 354 | break; |
382 | case S5M8767_BUCK1 ... S5M8767_BUCK6: | 355 | case S5M8767_BUCK1 ... S5M8767_BUCK6: |
383 | mask = 0xff; | ||
384 | if (reg_id == S5M8767_BUCK2 && s5m8767->buck2_gpiodvs) | 356 | if (reg_id == S5M8767_BUCK2 && s5m8767->buck2_gpiodvs) |
385 | buck234_vol = &s5m8767->buck2_vol[0]; | 357 | buck234_vol = &s5m8767->buck2_vol[0]; |
386 | else if (reg_id == S5M8767_BUCK3 && s5m8767->buck3_gpiodvs) | 358 | else if (reg_id == S5M8767_BUCK3 && s5m8767->buck3_gpiodvs) |
@@ -391,7 +363,6 @@ static int s5m8767_set_voltage_sel(struct regulator_dev *rdev, | |||
391 | case S5M8767_BUCK7 ... S5M8767_BUCK8: | 363 | case S5M8767_BUCK7 ... S5M8767_BUCK8: |
392 | return -EINVAL; | 364 | return -EINVAL; |
393 | case S5M8767_BUCK9: | 365 | case S5M8767_BUCK9: |
394 | mask = 0xff; | ||
395 | break; | 366 | break; |
396 | default: | 367 | default: |
397 | return -EINVAL; | 368 | return -EINVAL; |
@@ -411,11 +382,7 @@ static int s5m8767_set_voltage_sel(struct regulator_dev *rdev, | |||
411 | else | 382 | else |
412 | return s5m8767_set_low(s5m8767); | 383 | return s5m8767_set_low(s5m8767); |
413 | } else { | 384 | } else { |
414 | ret = s5m8767_get_voltage_register(rdev, ®); | 385 | return regulator_set_voltage_sel_regmap(rdev, selector); |
415 | if (ret) | ||
416 | return ret; | ||
417 | |||
418 | return sec_reg_update(s5m8767->iodev, reg, selector, mask); | ||
419 | } | 386 | } |
420 | } | 387 | } |
421 | 388 | ||
@@ -440,7 +407,7 @@ static struct regulator_ops s5m8767_ops = { | |||
440 | .is_enabled = s5m8767_reg_is_enabled, | 407 | .is_enabled = s5m8767_reg_is_enabled, |
441 | .enable = s5m8767_reg_enable, | 408 | .enable = s5m8767_reg_enable, |
442 | .disable = s5m8767_reg_disable, | 409 | .disable = s5m8767_reg_disable, |
443 | .get_voltage_sel = s5m8767_get_voltage_sel, | 410 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
444 | .set_voltage_sel = s5m8767_set_voltage_sel, | 411 | .set_voltage_sel = s5m8767_set_voltage_sel, |
445 | .set_voltage_time_sel = s5m8767_set_voltage_time_sel, | 412 | .set_voltage_time_sel = s5m8767_set_voltage_time_sel, |
446 | }; | 413 | }; |
@@ -747,11 +714,18 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) | |||
747 | (desc->max - desc->min) / desc->step + 1; | 714 | (desc->max - desc->min) / desc->step + 1; |
748 | regulators[id].min_uV = desc->min; | 715 | regulators[id].min_uV = desc->min; |
749 | regulators[id].uV_step = desc->step; | 716 | regulators[id].uV_step = desc->step; |
717 | regulators[id].vsel_reg = | ||
718 | s5m8767_get_vsel_reg(id, s5m8767); | ||
719 | if (id < S5M8767_BUCK1) | ||
720 | regulators[id].vsel_mask = 0x3f; | ||
721 | else | ||
722 | regulators[id].vsel_mask = 0xff; | ||
750 | } | 723 | } |
751 | 724 | ||
752 | config.dev = s5m8767->dev; | 725 | config.dev = s5m8767->dev; |
753 | config.init_data = pdata->regulators[i].initdata; | 726 | config.init_data = pdata->regulators[i].initdata; |
754 | config.driver_data = s5m8767; | 727 | config.driver_data = s5m8767; |
728 | config.regmap = iodev->regmap; | ||
755 | 729 | ||
756 | rdev[i] = regulator_register(®ulators[id], &config); | 730 | rdev[i] = regulator_register(®ulators[id], &config); |
757 | if (IS_ERR(rdev[i])) { | 731 | if (IS_ERR(rdev[i])) { |