aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/wm831x-dcdc.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2010-11-10 09:38:29 -0500
committerLiam Girdwood <lrg@slimlogic.co.uk>2011-01-12 09:32:59 -0500
commit3a93f2a9f4d8f73d74c0e552feb68a10f778a219 (patch)
tree8a9f503f2f061ad3fe9712b0986b0da346f4c8d2 /drivers/regulator/wm831x-dcdc.c
parent63cee946148821bca42be10130b061c2d0f5af7e (diff)
regulator: Report actual configured voltage to set_voltage()
Change the interface used by set_voltage() to report the selected value to the regulator core in terms of a selector used by list_voltage(). This allows the regulator core to know the voltage that was chosen without having to do an explict get_voltage(), which would be much more expensive as it will generally access hardware. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'drivers/regulator/wm831x-dcdc.c')
-rw-r--r--drivers/regulator/wm831x-dcdc.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/drivers/regulator/wm831x-dcdc.c b/drivers/regulator/wm831x-dcdc.c
index dbfaf5945e48..71da6b2ad863 100644
--- a/drivers/regulator/wm831x-dcdc.c
+++ b/drivers/regulator/wm831x-dcdc.c
@@ -302,7 +302,7 @@ static int wm831x_buckv_set_dvs(struct regulator_dev *rdev, int state)
302} 302}
303 303
304static int wm831x_buckv_set_voltage(struct regulator_dev *rdev, 304static int wm831x_buckv_set_voltage(struct regulator_dev *rdev,
305 int min_uV, int max_uV) 305 int min_uV, int max_uV, unsigned *selector)
306{ 306{
307 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev); 307 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
308 struct wm831x *wm831x = dcdc->wm831x; 308 struct wm831x *wm831x = dcdc->wm831x;
@@ -314,6 +314,8 @@ static int wm831x_buckv_set_voltage(struct regulator_dev *rdev,
314 if (vsel < 0) 314 if (vsel < 0)
315 return vsel; 315 return vsel;
316 316
317 *selector = vsel;
318
317 /* If this value is already set then do a GPIO update if we can */ 319 /* If this value is already set then do a GPIO update if we can */
318 if (dcdc->dvs_gpio && dcdc->on_vsel == vsel) 320 if (dcdc->dvs_gpio && dcdc->on_vsel == vsel)
319 return wm831x_buckv_set_dvs(rdev, 0); 321 return wm831x_buckv_set_dvs(rdev, 0);
@@ -636,7 +638,7 @@ static int wm831x_buckp_list_voltage(struct regulator_dev *rdev,
636} 638}
637 639
638static int wm831x_buckp_set_voltage_int(struct regulator_dev *rdev, int reg, 640static int wm831x_buckp_set_voltage_int(struct regulator_dev *rdev, int reg,
639 int min_uV, int max_uV) 641 int min_uV, int max_uV, int *selector)
640{ 642{
641 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev); 643 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
642 struct wm831x *wm831x = dcdc->wm831x; 644 struct wm831x *wm831x = dcdc->wm831x;
@@ -650,16 +652,20 @@ static int wm831x_buckp_set_voltage_int(struct regulator_dev *rdev, int reg,
650 if (wm831x_buckp_list_voltage(rdev, vsel) > max_uV) 652 if (wm831x_buckp_list_voltage(rdev, vsel) > max_uV)
651 return -EINVAL; 653 return -EINVAL;
652 654
655 *selector = vsel;
656
653 return wm831x_set_bits(wm831x, reg, WM831X_DC3_ON_VSEL_MASK, vsel); 657 return wm831x_set_bits(wm831x, reg, WM831X_DC3_ON_VSEL_MASK, vsel);
654} 658}
655 659
656static int wm831x_buckp_set_voltage(struct regulator_dev *rdev, 660static int wm831x_buckp_set_voltage(struct regulator_dev *rdev,
657 int min_uV, int max_uV) 661 int min_uV, int max_uV,
662 unsigned *selector)
658{ 663{
659 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev); 664 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
660 u16 reg = dcdc->base + WM831X_DCDC_ON_CONFIG; 665 u16 reg = dcdc->base + WM831X_DCDC_ON_CONFIG;
661 666
662 return wm831x_buckp_set_voltage_int(rdev, reg, min_uV, max_uV); 667 return wm831x_buckp_set_voltage_int(rdev, reg, min_uV, max_uV,
668 selector);
663} 669}
664 670
665static int wm831x_buckp_set_suspend_voltage(struct regulator_dev *rdev, 671static int wm831x_buckp_set_suspend_voltage(struct regulator_dev *rdev,
@@ -667,8 +673,9 @@ static int wm831x_buckp_set_suspend_voltage(struct regulator_dev *rdev,
667{ 673{
668 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev); 674 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
669 u16 reg = dcdc->base + WM831X_DCDC_SLEEP_CONTROL; 675 u16 reg = dcdc->base + WM831X_DCDC_SLEEP_CONTROL;
676 unsigned selector;
670 677
671 return wm831x_buckp_set_voltage_int(rdev, reg, uV, uV); 678 return wm831x_buckp_set_voltage_int(rdev, reg, uV, uV, &selector);
672} 679}
673 680
674static int wm831x_buckp_get_voltage(struct regulator_dev *rdev) 681static int wm831x_buckp_get_voltage(struct regulator_dev *rdev)