aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2012-03-23 04:49:22 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-04-01 06:59:28 -0400
commitd5ec96357d743288bd03a685defd586ad35d351e (patch)
treed30cec9d5ce3f5ab9d3d44e9e67c1c82cddf11ee /drivers/regulator
parent24c896f5482d864f526ce3d085eb90298b82c49f (diff)
regulator: Convert pcap-regulator to set_voltage_sel
After converting to set_voltage_sel, we can remove the workaroud of getting the best match voltage for V1. The core will iterate through the whole voltage table and find the best match for us. 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/pcap-regulator.c33
1 files changed, 6 insertions, 27 deletions
diff --git a/drivers/regulator/pcap-regulator.c b/drivers/regulator/pcap-regulator.c
index a5aab1b08bcf..b9666a2c45f3 100644
--- a/drivers/regulator/pcap-regulator.c
+++ b/drivers/regulator/pcap-regulator.c
@@ -150,40 +150,19 @@ static struct pcap_regulator vreg_table[] = {
150 VREG_INFO(SW2S, PCAP_REG_LOWPWR, NA, 20, NA, NA), */ 150 VREG_INFO(SW2S, PCAP_REG_LOWPWR, NA, 20, NA, NA), */
151}; 151};
152 152
153static int pcap_regulator_set_voltage(struct regulator_dev *rdev, 153static int pcap_regulator_set_voltage_sel(struct regulator_dev *rdev,
154 int min_uV, int max_uV, 154 unsigned selector)
155 unsigned *selector)
156{ 155{
157 struct pcap_regulator *vreg = &vreg_table[rdev_get_id(rdev)]; 156 struct pcap_regulator *vreg = &vreg_table[rdev_get_id(rdev)];
158 void *pcap = rdev_get_drvdata(rdev); 157 void *pcap = rdev_get_drvdata(rdev);
159 int uV;
160 u8 i;
161 158
162 /* the regulator doesn't support voltage switching */ 159 /* the regulator doesn't support voltage switching */
163 if (vreg->n_voltages == 1) 160 if (vreg->n_voltages == 1)
164 return -EINVAL; 161 return -EINVAL;
165 162
166 for (i = 0; i < vreg->n_voltages; i++) { 163 return ezx_pcap_set_bits(pcap, vreg->reg,
167 /* For V1 the first is not the best match */ 164 (vreg->n_voltages - 1) << vreg->index,
168 if (i == 0 && rdev_get_id(rdev) == V1) 165 selector << vreg->index);
169 i = 1;
170 else if (i + 1 == vreg->n_voltages && rdev_get_id(rdev) == V1)
171 i = 0;
172
173 uV = vreg->voltage_table[i] * 1000;
174 if (min_uV <= uV && uV <= max_uV) {
175 *selector = i;
176 return ezx_pcap_set_bits(pcap, vreg->reg,
177 (vreg->n_voltages - 1) << vreg->index,
178 i << vreg->index);
179 }
180
181 if (i == 0 && rdev_get_id(rdev) == V1)
182 i = vreg->n_voltages - 1;
183 }
184
185 /* the requested voltage range is not supported by this regulator */
186 return -EINVAL;
187} 166}
188 167
189static int pcap_regulator_get_voltage(struct regulator_dev *rdev) 168static int pcap_regulator_get_voltage(struct regulator_dev *rdev)
@@ -248,7 +227,7 @@ static int pcap_regulator_list_voltage(struct regulator_dev *rdev,
248 227
249static struct regulator_ops pcap_regulator_ops = { 228static struct regulator_ops pcap_regulator_ops = {
250 .list_voltage = pcap_regulator_list_voltage, 229 .list_voltage = pcap_regulator_list_voltage,
251 .set_voltage = pcap_regulator_set_voltage, 230 .set_voltage_sel = pcap_regulator_set_voltage_sel,
252 .get_voltage = pcap_regulator_get_voltage, 231 .get_voltage = pcap_regulator_get_voltage,
253 .enable = pcap_regulator_enable, 232 .enable = pcap_regulator_enable,
254 .disable = pcap_regulator_disable, 233 .disable = pcap_regulator_disable,