aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/regulator/twl-regulator.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c
index 8f0bd56c2118..bb51decfcb8e 100644
--- a/drivers/regulator/twl-regulator.c
+++ b/drivers/regulator/twl-regulator.c
@@ -569,30 +569,21 @@ twl6030ldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV,
569 if ((min_uV/1000 < info->min_mV) || (max_uV/1000 > info->max_mV)) 569 if ((min_uV/1000 < info->min_mV) || (max_uV/1000 > info->max_mV))
570 return -EDOM; 570 return -EDOM;
571 571
572 /* 572 vsel = DIV_ROUND_UP(min_uV - rdev->desc->min_uV, rdev->desc->uV_step);
573 * Use the below formula to calculate vsel
574 * mV = 1000mv + 100mv * (vsel - 1)
575 */
576 vsel = (min_uV/1000 - 1000)/100 + 1;
577 *selector = vsel; 573 *selector = vsel;
578 return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE, vsel);
579 574
575 return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE, vsel);
580} 576}
581 577
582static int twl6030ldo_get_voltage(struct regulator_dev *rdev) 578static int twl6030ldo_get_voltage(struct regulator_dev *rdev)
583{ 579{
584 struct twlreg_info *info = rdev_get_drvdata(rdev); 580 struct twlreg_info *info = rdev_get_drvdata(rdev);
585 int vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER, 581 int vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE);
586 VREG_VOLTAGE);
587 582
588 if (vsel < 0) 583 if (vsel < 0)
589 return vsel; 584 return vsel;
590 585
591 /* 586 return rdev->desc->min_uV + vsel * rdev->desc->uV_step;
592 * Use the below formula to calculate vsel
593 * mV = 1000mv + 100mv * (vsel - 1)
594 */
595 return (1000 + (100 * (vsel - 1))) * 1000;
596} 587}
597 588
598static struct regulator_ops twl6030ldo_ops = { 589static struct regulator_ops twl6030ldo_ops = {