diff options
author | Haojian Zhuang <haojian.zhuang@marvell.com> | 2009-07-10 04:03:36 -0400 |
---|---|---|
committer | Liam Girdwood <lrg@slimlogic.co.uk> | 2009-09-22 08:32:38 -0400 |
commit | c1b60873ca2078bfca94b73bc88ef1c5adcc928b (patch) | |
tree | 73240a703d2c6beff066359069d013825b980063 /drivers/regulator/da903x.c | |
parent | ed6543243a1c557dbe2005a86f6d8e851c1ebb79 (diff) |
regulator: support list voltage in da903x
Make da903x driver to list voltage and count voltage.
Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Eric Miao <eric.y.miao@gmail.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'drivers/regulator/da903x.c')
-rw-r--r-- | drivers/regulator/da903x.c | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/drivers/regulator/da903x.c b/drivers/regulator/da903x.c index d8d251f066a4..236de1134397 100644 --- a/drivers/regulator/da903x.c +++ b/drivers/regulator/da903x.c | |||
@@ -87,6 +87,10 @@ struct da903x_regulator_info { | |||
87 | int enable_bit; | 87 | int enable_bit; |
88 | }; | 88 | }; |
89 | 89 | ||
90 | static int da9034_ldo12_data[] = { 1700, 1750, 1800, 1850, 1900, 1950, | ||
91 | 2000, 2050, 2700, 2750, 2800, 2850, | ||
92 | 2900, 2950, 3000, 3050 }; | ||
93 | |||
90 | static inline struct device *to_da903x_dev(struct regulator_dev *rdev) | 94 | static inline struct device *to_da903x_dev(struct regulator_dev *rdev) |
91 | { | 95 | { |
92 | return rdev_get_dev(rdev)->parent->parent; | 96 | return rdev_get_dev(rdev)->parent->parent; |
@@ -170,6 +174,17 @@ static int da903x_is_enabled(struct regulator_dev *rdev) | |||
170 | return !!(reg_val & (1 << info->enable_bit)); | 174 | return !!(reg_val & (1 << info->enable_bit)); |
171 | } | 175 | } |
172 | 176 | ||
177 | static int da903x_list_voltage(struct regulator_dev *rdev, unsigned selector) | ||
178 | { | ||
179 | struct da903x_regulator_info *info = rdev_get_drvdata(rdev); | ||
180 | int ret; | ||
181 | |||
182 | ret = info->min_uV + info->step_uV * selector; | ||
183 | if (ret > info->max_uV) | ||
184 | return -EINVAL; | ||
185 | return ret; | ||
186 | } | ||
187 | |||
173 | /* DA9030 specific operations */ | 188 | /* DA9030 specific operations */ |
174 | static int da9030_set_ldo1_15_voltage(struct regulator_dev *rdev, | 189 | static int da9030_set_ldo1_15_voltage(struct regulator_dev *rdev, |
175 | int min_uV, int max_uV) | 190 | int min_uV, int max_uV) |
@@ -313,9 +328,18 @@ static int da9034_get_ldo12_voltage(struct regulator_dev *rdev) | |||
313 | return info->min_uV + info->step_uV * val; | 328 | return info->min_uV + info->step_uV * val; |
314 | } | 329 | } |
315 | 330 | ||
331 | static int da9034_list_ldo12_voltage(struct regulator_dev *rdev, | ||
332 | unsigned selector) | ||
333 | { | ||
334 | if (selector > ARRAY_SIZE(da9034_ldo12_data)) | ||
335 | return -EINVAL; | ||
336 | return da9034_ldo12_data[selector] * 1000; | ||
337 | } | ||
338 | |||
316 | static struct regulator_ops da903x_regulator_ldo_ops = { | 339 | static struct regulator_ops da903x_regulator_ldo_ops = { |
317 | .set_voltage = da903x_set_ldo_voltage, | 340 | .set_voltage = da903x_set_ldo_voltage, |
318 | .get_voltage = da903x_get_voltage, | 341 | .get_voltage = da903x_get_voltage, |
342 | .list_voltage = da903x_list_voltage, | ||
319 | .enable = da903x_enable, | 343 | .enable = da903x_enable, |
320 | .disable = da903x_disable, | 344 | .disable = da903x_disable, |
321 | .is_enabled = da903x_is_enabled, | 345 | .is_enabled = da903x_is_enabled, |
@@ -325,6 +349,7 @@ static struct regulator_ops da903x_regulator_ldo_ops = { | |||
325 | static struct regulator_ops da9030_regulator_ldo14_ops = { | 349 | static struct regulator_ops da9030_regulator_ldo14_ops = { |
326 | .set_voltage = da9030_set_ldo14_voltage, | 350 | .set_voltage = da9030_set_ldo14_voltage, |
327 | .get_voltage = da9030_get_ldo14_voltage, | 351 | .get_voltage = da9030_get_ldo14_voltage, |
352 | .list_voltage = da903x_list_voltage, | ||
328 | .enable = da903x_enable, | 353 | .enable = da903x_enable, |
329 | .disable = da903x_disable, | 354 | .disable = da903x_disable, |
330 | .is_enabled = da903x_is_enabled, | 355 | .is_enabled = da903x_is_enabled, |
@@ -334,6 +359,7 @@ static struct regulator_ops da9030_regulator_ldo14_ops = { | |||
334 | static struct regulator_ops da9030_regulator_ldo1_15_ops = { | 359 | static struct regulator_ops da9030_regulator_ldo1_15_ops = { |
335 | .set_voltage = da9030_set_ldo1_15_voltage, | 360 | .set_voltage = da9030_set_ldo1_15_voltage, |
336 | .get_voltage = da903x_get_voltage, | 361 | .get_voltage = da903x_get_voltage, |
362 | .list_voltage = da903x_list_voltage, | ||
337 | .enable = da903x_enable, | 363 | .enable = da903x_enable, |
338 | .disable = da903x_disable, | 364 | .disable = da903x_disable, |
339 | .is_enabled = da903x_is_enabled, | 365 | .is_enabled = da903x_is_enabled, |
@@ -342,6 +368,7 @@ static struct regulator_ops da9030_regulator_ldo1_15_ops = { | |||
342 | static struct regulator_ops da9034_regulator_dvc_ops = { | 368 | static struct regulator_ops da9034_regulator_dvc_ops = { |
343 | .set_voltage = da9034_set_dvc_voltage, | 369 | .set_voltage = da9034_set_dvc_voltage, |
344 | .get_voltage = da903x_get_voltage, | 370 | .get_voltage = da903x_get_voltage, |
371 | .list_voltage = da903x_list_voltage, | ||
345 | .enable = da903x_enable, | 372 | .enable = da903x_enable, |
346 | .disable = da903x_disable, | 373 | .disable = da903x_disable, |
347 | .is_enabled = da903x_is_enabled, | 374 | .is_enabled = da903x_is_enabled, |
@@ -351,6 +378,7 @@ static struct regulator_ops da9034_regulator_dvc_ops = { | |||
351 | static struct regulator_ops da9034_regulator_ldo12_ops = { | 378 | static struct regulator_ops da9034_regulator_ldo12_ops = { |
352 | .set_voltage = da9034_set_ldo12_voltage, | 379 | .set_voltage = da9034_set_ldo12_voltage, |
353 | .get_voltage = da9034_get_ldo12_voltage, | 380 | .get_voltage = da9034_get_ldo12_voltage, |
381 | .list_voltage = da9034_list_ldo12_voltage, | ||
354 | .enable = da903x_enable, | 382 | .enable = da903x_enable, |
355 | .disable = da903x_disable, | 383 | .disable = da903x_disable, |
356 | .is_enabled = da903x_is_enabled, | 384 | .is_enabled = da903x_is_enabled, |
@@ -363,6 +391,7 @@ static struct regulator_ops da9034_regulator_ldo12_ops = { | |||
363 | .ops = &da903x_regulator_ldo_ops, \ | 391 | .ops = &da903x_regulator_ldo_ops, \ |
364 | .type = REGULATOR_VOLTAGE, \ | 392 | .type = REGULATOR_VOLTAGE, \ |
365 | .id = _pmic##_ID_LDO##_id, \ | 393 | .id = _pmic##_ID_LDO##_id, \ |
394 | .n_voltages = (step) ? ((max - min) / step + 1) : 1, \ | ||
366 | .owner = THIS_MODULE, \ | 395 | .owner = THIS_MODULE, \ |
367 | }, \ | 396 | }, \ |
368 | .min_uV = (min) * 1000, \ | 397 | .min_uV = (min) * 1000, \ |
@@ -382,6 +411,7 @@ static struct regulator_ops da9034_regulator_ldo12_ops = { | |||
382 | .ops = &da9034_regulator_dvc_ops, \ | 411 | .ops = &da9034_regulator_dvc_ops, \ |
383 | .type = REGULATOR_VOLTAGE, \ | 412 | .type = REGULATOR_VOLTAGE, \ |
384 | .id = DA9030_ID_##_id, \ | 413 | .id = DA9030_ID_##_id, \ |
414 | .n_voltages = (step) ? ((max - min) / step + 1) : 1, \ | ||
385 | .owner = THIS_MODULE, \ | 415 | .owner = THIS_MODULE, \ |
386 | }, \ | 416 | }, \ |
387 | .min_uV = (min) * 1000, \ | 417 | .min_uV = (min) * 1000, \ |
@@ -403,6 +433,7 @@ static struct regulator_ops da9034_regulator_ldo12_ops = { | |||
403 | .ops = &da9034_regulator_dvc_ops, \ | 433 | .ops = &da9034_regulator_dvc_ops, \ |
404 | .type = REGULATOR_VOLTAGE, \ | 434 | .type = REGULATOR_VOLTAGE, \ |
405 | .id = DA9034_ID_##_id, \ | 435 | .id = DA9034_ID_##_id, \ |
436 | .n_voltages = (step) ? ((max - min) / step + 1) : 1, \ | ||
406 | .owner = THIS_MODULE, \ | 437 | .owner = THIS_MODULE, \ |
407 | }, \ | 438 | }, \ |
408 | .min_uV = (min) * 1000, \ | 439 | .min_uV = (min) * 1000, \ |
@@ -424,6 +455,7 @@ static struct regulator_ops da9034_regulator_ldo12_ops = { | |||
424 | .ops = &da9034_regulator_dvc_ops, \ | 455 | .ops = &da9034_regulator_dvc_ops, \ |
425 | .type = REGULATOR_VOLTAGE, \ | 456 | .type = REGULATOR_VOLTAGE, \ |
426 | .id = DA9035_ID_##_id, \ | 457 | .id = DA9035_ID_##_id, \ |
458 | .n_voltages = (step) ? ((max - min) / step + 1) : 1, \ | ||
427 | .owner = THIS_MODULE, \ | 459 | .owner = THIS_MODULE, \ |
428 | }, \ | 460 | }, \ |
429 | .min_uV = (min) * 1000, \ | 461 | .min_uV = (min) * 1000, \ |
@@ -517,8 +549,10 @@ static int __devinit da903x_regulator_probe(struct platform_device *pdev) | |||
517 | } | 549 | } |
518 | 550 | ||
519 | /* Workaround for the weird LDO12 voltage setting */ | 551 | /* Workaround for the weird LDO12 voltage setting */ |
520 | if (ri->desc.id == DA9034_ID_LDO12) | 552 | if (ri->desc.id == DA9034_ID_LDO12) { |
521 | ri->desc.ops = &da9034_regulator_ldo12_ops; | 553 | ri->desc.ops = &da9034_regulator_ldo12_ops; |
554 | ri->desc.n_voltages = ARRAY_SIZE(da9034_ldo12_data); | ||
555 | } | ||
522 | 556 | ||
523 | if (ri->desc.id == DA9030_ID_LDO14) | 557 | if (ri->desc.id == DA9030_ID_LDO14) |
524 | ri->desc.ops = &da9030_regulator_ldo14_ops; | 558 | ri->desc.ops = &da9030_regulator_ldo14_ops; |