aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2012-07-08 23:26:28 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-07-15 17:06:05 -0400
commit4bcb9f43426dcb7b326d4b5448f198eea4867e63 (patch)
treef7b80af9a8a186ca2a5cbd5fed1b36cba6e76c50 /drivers/regulator
parenta3cb80f43a9bc9b64aedd14b100e99252767d78c (diff)
regulator: twl: Convert twl6030ldo_ops to [get|set]_voltage_sel
Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/twl-regulator.c24
1 files changed, 7 insertions, 17 deletions
diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c
index bb51decfcb8..de99b784c5d 100644
--- a/drivers/regulator/twl-regulator.c
+++ b/drivers/regulator/twl-regulator.c
@@ -560,37 +560,27 @@ static struct regulator_ops twl6030coresmps_ops = {
560}; 560};
561 561
562static int 562static int
563twl6030ldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV, 563twl6030ldo_set_voltage_sel(struct regulator_dev *rdev, unsigned selector)
564 unsigned *selector)
565{ 564{
566 struct twlreg_info *info = rdev_get_drvdata(rdev); 565 struct twlreg_info *info = rdev_get_drvdata(rdev);
567 int vsel;
568 566
569 if ((min_uV/1000 < info->min_mV) || (max_uV/1000 > info->max_mV)) 567 return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE,
570 return -EDOM; 568 selector);
571
572 vsel = DIV_ROUND_UP(min_uV - rdev->desc->min_uV, rdev->desc->uV_step);
573 *selector = vsel;
574
575 return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE, vsel);
576} 569}
577 570
578static int twl6030ldo_get_voltage(struct regulator_dev *rdev) 571static int twl6030ldo_get_voltage_sel(struct regulator_dev *rdev)
579{ 572{
580 struct twlreg_info *info = rdev_get_drvdata(rdev); 573 struct twlreg_info *info = rdev_get_drvdata(rdev);
581 int vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE); 574 int vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE);
582 575
583 if (vsel < 0) 576 return vsel;
584 return vsel;
585
586 return rdev->desc->min_uV + vsel * rdev->desc->uV_step;
587} 577}
588 578
589static struct regulator_ops twl6030ldo_ops = { 579static struct regulator_ops twl6030ldo_ops = {
590 .list_voltage = regulator_list_voltage_linear, 580 .list_voltage = regulator_list_voltage_linear,
591 581
592 .set_voltage = twl6030ldo_set_voltage, 582 .set_voltage_sel = twl6030ldo_set_voltage_sel,
593 .get_voltage = twl6030ldo_get_voltage, 583 .get_voltage_sel = twl6030ldo_get_voltage_sel,
594 584
595 .enable = twl6030reg_enable, 585 .enable = twl6030reg_enable,
596 .disable = twl6030reg_disable, 586 .disable = twl6030reg_disable,