aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
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 bb51decfcb8e..de99b784c5da 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,