aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/tps6586x-regulator.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/tps6586x-regulator.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/tps6586x-regulator.c')
-rw-r--r--drivers/regulator/tps6586x-regulator.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/drivers/regulator/tps6586x-regulator.c b/drivers/regulator/tps6586x-regulator.c
index 6d20b0454a1d..bb04a75a4c98 100644
--- a/drivers/regulator/tps6586x-regulator.c
+++ b/drivers/regulator/tps6586x-regulator.c
@@ -85,7 +85,8 @@ static int tps6586x_ldo_list_voltage(struct regulator_dev *rdev,
85 85
86static int __tps6586x_ldo_set_voltage(struct device *parent, 86static int __tps6586x_ldo_set_voltage(struct device *parent,
87 struct tps6586x_regulator *ri, 87 struct tps6586x_regulator *ri,
88 int min_uV, int max_uV) 88 int min_uV, int max_uV,
89 unsigned *selector)
89{ 90{
90 int val, uV; 91 int val, uV;
91 uint8_t mask; 92 uint8_t mask;
@@ -100,6 +101,8 @@ static int __tps6586x_ldo_set_voltage(struct device *parent,
100 /* use the first in-range value */ 101 /* use the first in-range value */
101 if (min_uV <= uV && uV <= max_uV) { 102 if (min_uV <= uV && uV <= max_uV) {
102 103
104 *selector = val;
105
103 val <<= ri->volt_shift; 106 val <<= ri->volt_shift;
104 mask = ((1 << ri->volt_nbits) - 1) << ri->volt_shift; 107 mask = ((1 << ri->volt_nbits) - 1) << ri->volt_shift;
105 108
@@ -111,12 +114,13 @@ static int __tps6586x_ldo_set_voltage(struct device *parent,
111} 114}
112 115
113static int tps6586x_ldo_set_voltage(struct regulator_dev *rdev, 116static int tps6586x_ldo_set_voltage(struct regulator_dev *rdev,
114 int min_uV, int max_uV) 117 int min_uV, int max_uV, unsigned *selector)
115{ 118{
116 struct tps6586x_regulator *ri = rdev_get_drvdata(rdev); 119 struct tps6586x_regulator *ri = rdev_get_drvdata(rdev);
117 struct device *parent = to_tps6586x_dev(rdev); 120 struct device *parent = to_tps6586x_dev(rdev);
118 121
119 return __tps6586x_ldo_set_voltage(parent, ri, min_uV, max_uV); 122 return __tps6586x_ldo_set_voltage(parent, ri, min_uV, max_uV,
123 selector);
120} 124}
121 125
122static int tps6586x_ldo_get_voltage(struct regulator_dev *rdev) 126static int tps6586x_ldo_get_voltage(struct regulator_dev *rdev)
@@ -140,13 +144,14 @@ static int tps6586x_ldo_get_voltage(struct regulator_dev *rdev)
140} 144}
141 145
142static int tps6586x_dvm_set_voltage(struct regulator_dev *rdev, 146static int tps6586x_dvm_set_voltage(struct regulator_dev *rdev,
143 int min_uV, int max_uV) 147 int min_uV, int max_uV, unsigned *selector)
144{ 148{
145 struct tps6586x_regulator *ri = rdev_get_drvdata(rdev); 149 struct tps6586x_regulator *ri = rdev_get_drvdata(rdev);
146 struct device *parent = to_tps6586x_dev(rdev); 150 struct device *parent = to_tps6586x_dev(rdev);
147 int ret; 151 int ret;
148 152
149 ret = __tps6586x_ldo_set_voltage(parent, ri, min_uV, max_uV); 153 ret = __tps6586x_ldo_set_voltage(parent, ri, min_uV, max_uV,
154 selector);
150 if (ret) 155 if (ret)
151 return ret; 156 return ret;
152 157