diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-05-15 03:17:58 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-05-18 03:38:32 -0400 |
commit | 8b22285fd710976b2a1c6f625ca64dfbfe25ba2b (patch) | |
tree | 44828b76f9037f575b8b7d52588c7a26c93c8a5b /drivers/regulator | |
parent | 3a8334b94850b08728237235df94a69c6ea9f6e7 (diff) |
regulator: tps65217: Convert to set_voltage_sel and map_voltage
Convert tps65217_pmic_ops to use set_voltage_sel and map_voltage.
After this convertion, we can also use tps65217_pmic_set_voltage_sel()
for set_voltage_sel callback of tps65217_pmic_ldo1_ops.
Thus this patch also removes tps65217_pmic_ldo1_set_voltage_sel() function.
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/tps65217-regulator.c | 68 |
1 files changed, 30 insertions, 38 deletions
diff --git a/drivers/regulator/tps65217-regulator.c b/drivers/regulator/tps65217-regulator.c index 00c5c1c96d19..9d371d2cbcae 100644 --- a/drivers/regulator/tps65217-regulator.c +++ b/drivers/regulator/tps65217-regulator.c | |||
@@ -213,65 +213,56 @@ static int tps65217_pmic_get_voltage_sel(struct regulator_dev *dev) | |||
213 | return selector; | 213 | return selector; |
214 | } | 214 | } |
215 | 215 | ||
216 | static int tps65217_pmic_ldo1_set_voltage_sel(struct regulator_dev *dev, | 216 | static int tps65217_pmic_set_voltage_sel(struct regulator_dev *dev, |
217 | unsigned selector) | 217 | unsigned selector) |
218 | { | 218 | { |
219 | int ret; | ||
219 | struct tps65217 *tps = rdev_get_drvdata(dev); | 220 | struct tps65217 *tps = rdev_get_drvdata(dev); |
220 | int ldo = rdev_get_id(dev); | 221 | unsigned int rid = rdev_get_id(dev); |
221 | 222 | ||
222 | if (ldo != TPS65217_LDO_1) | 223 | /* Set the voltage based on vsel value and write protect level is 2 */ |
223 | return -EINVAL; | 224 | ret = tps65217_set_bits(tps, tps->info[rid]->set_vout_reg, |
225 | tps->info[rid]->set_vout_mask, | ||
226 | selector, TPS65217_PROTECT_L2); | ||
224 | 227 | ||
225 | if (selector >= tps->info[ldo]->table_len) | 228 | /* Set GO bit for DCDCx to initiate voltage transistion */ |
226 | return -EINVAL; | 229 | switch (rid) { |
230 | case TPS65217_DCDC_1 ... TPS65217_DCDC_3: | ||
231 | ret = tps65217_set_bits(tps, TPS65217_REG_DEFSLEW, | ||
232 | TPS65217_DEFSLEW_GO, TPS65217_DEFSLEW_GO, | ||
233 | TPS65217_PROTECT_L2); | ||
234 | break; | ||
235 | } | ||
227 | 236 | ||
228 | /* Set the voltage based on vsel value and write protect level is 2 */ | 237 | return ret; |
229 | return tps65217_set_bits(tps, tps->info[ldo]->set_vout_reg, | ||
230 | tps->info[ldo]->set_vout_mask, | ||
231 | selector, TPS65217_PROTECT_L2); | ||
232 | } | 238 | } |
233 | 239 | ||
234 | static int tps65217_pmic_set_voltage(struct regulator_dev *dev, | 240 | static int tps65217_pmic_map_voltage(struct regulator_dev *dev, |
235 | int min_uV, int max_uV, unsigned *selector) | 241 | int min_uV, int max_uV) |
236 | { | 242 | { |
237 | int ret; | 243 | |
238 | struct tps65217 *tps = rdev_get_drvdata(dev); | 244 | struct tps65217 *tps = rdev_get_drvdata(dev); |
239 | unsigned int rid = rdev_get_id(dev); | 245 | unsigned int sel, rid = rdev_get_id(dev); |
246 | int ret; | ||
240 | 247 | ||
241 | /* LDO1 implements set_voltage_sel callback */ | 248 | /* LDO1 uses regulator_map_voltage_iterate() */ |
242 | if (rid == TPS65217_LDO_1) | 249 | if (rid == TPS65217_LDO_1) |
243 | return -EINVAL; | 250 | return -EINVAL; |
244 | 251 | ||
245 | if (rid < TPS65217_DCDC_1 || rid > TPS65217_LDO_4) | 252 | if (rid < TPS65217_DCDC_1 || rid > TPS65217_LDO_4) |
246 | return -EINVAL; | 253 | return -EINVAL; |
247 | 254 | ||
248 | if (min_uV < tps->info[rid]->min_uV | 255 | if (min_uV < tps->info[rid]->min_uV || min_uV > tps->info[rid]->max_uV) |
249 | || min_uV > tps->info[rid]->max_uV) | ||
250 | return -EINVAL; | 256 | return -EINVAL; |
251 | 257 | ||
252 | if (max_uV < tps->info[rid]->min_uV | 258 | if (max_uV < tps->info[rid]->min_uV || max_uV > tps->info[rid]->max_uV) |
253 | || max_uV > tps->info[rid]->max_uV) | ||
254 | return -EINVAL; | 259 | return -EINVAL; |
255 | 260 | ||
256 | ret = tps->info[rid]->uv_to_vsel(min_uV, selector); | 261 | ret = tps->info[rid]->uv_to_vsel(min_uV, &sel); |
257 | if (ret) | 262 | if (ret) |
258 | return ret; | 263 | return ret; |
259 | 264 | ||
260 | /* Set the voltage based on vsel value and write protect level is 2 */ | 265 | return sel; |
261 | ret = tps65217_set_bits(tps, tps->info[rid]->set_vout_reg, | ||
262 | tps->info[rid]->set_vout_mask, | ||
263 | *selector, TPS65217_PROTECT_L2); | ||
264 | |||
265 | /* Set GO bit for DCDCx to initiate voltage transistion */ | ||
266 | switch (rid) { | ||
267 | case TPS65217_DCDC_1 ... TPS65217_DCDC_3: | ||
268 | ret = tps65217_set_bits(tps, TPS65217_REG_DEFSLEW, | ||
269 | TPS65217_DEFSLEW_GO, TPS65217_DEFSLEW_GO, | ||
270 | TPS65217_PROTECT_L2); | ||
271 | break; | ||
272 | } | ||
273 | |||
274 | return ret; | ||
275 | } | 266 | } |
276 | 267 | ||
277 | static int tps65217_pmic_list_voltage(struct regulator_dev *dev, | 268 | static int tps65217_pmic_list_voltage(struct regulator_dev *dev, |
@@ -298,8 +289,9 @@ static struct regulator_ops tps65217_pmic_ops = { | |||
298 | .enable = tps65217_pmic_enable, | 289 | .enable = tps65217_pmic_enable, |
299 | .disable = tps65217_pmic_disable, | 290 | .disable = tps65217_pmic_disable, |
300 | .get_voltage_sel = tps65217_pmic_get_voltage_sel, | 291 | .get_voltage_sel = tps65217_pmic_get_voltage_sel, |
301 | .set_voltage = tps65217_pmic_set_voltage, | 292 | .set_voltage_sel = tps65217_pmic_set_voltage_sel, |
302 | .list_voltage = tps65217_pmic_list_voltage, | 293 | .list_voltage = tps65217_pmic_list_voltage, |
294 | .map_voltage = tps65217_pmic_map_voltage, | ||
303 | }; | 295 | }; |
304 | 296 | ||
305 | /* Operations permitted on LDO1 */ | 297 | /* Operations permitted on LDO1 */ |
@@ -308,7 +300,7 @@ static struct regulator_ops tps65217_pmic_ldo1_ops = { | |||
308 | .enable = tps65217_pmic_enable, | 300 | .enable = tps65217_pmic_enable, |
309 | .disable = tps65217_pmic_disable, | 301 | .disable = tps65217_pmic_disable, |
310 | .get_voltage_sel = tps65217_pmic_get_voltage_sel, | 302 | .get_voltage_sel = tps65217_pmic_get_voltage_sel, |
311 | .set_voltage_sel = tps65217_pmic_ldo1_set_voltage_sel, | 303 | .set_voltage_sel = tps65217_pmic_set_voltage_sel, |
312 | .list_voltage = tps65217_pmic_list_voltage, | 304 | .list_voltage = tps65217_pmic_list_voltage, |
313 | }; | 305 | }; |
314 | 306 | ||