aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/tps65912-regulator.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2012-03-15 05:17:36 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-04-01 06:59:25 -0400
commitf72d643e87581cbee49f39c1fd8268b1a9252b80 (patch)
treeeed628595cab77fb2dc0469d2996dc6f6f946a2a /drivers/regulator/tps65912-regulator.c
parentc8237f01db63b458c34222d07f66c5417cfd866b (diff)
regulator: Implement tps65912_list_voltage to be shared by both DCDCs and LDOs
Merge tps65912_list_voltage_dcdc and tps65912_list_voltage_ldo to tps65912_list_voltage. This change does not add too much complexity in tps65912_list_voltage function. Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/tps65912-regulator.c')
-rw-r--r--drivers/regulator/tps65912-regulator.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/drivers/regulator/tps65912-regulator.c b/drivers/regulator/tps65912-regulator.c
index b36799b1f530..46f3c6160fda 100644
--- a/drivers/regulator/tps65912-regulator.c
+++ b/drivers/regulator/tps65912-regulator.c
@@ -372,12 +372,14 @@ static unsigned int tps65912_get_mode(struct regulator_dev *dev)
372 return mode; 372 return mode;
373} 373}
374 374
375static int tps65912_list_voltage_dcdc(struct regulator_dev *dev, 375static int tps65912_list_voltage(struct regulator_dev *dev, unsigned selector)
376 unsigned selector)
377{ 376{
378 struct tps65912_reg *pmic = rdev_get_drvdata(dev); 377 struct tps65912_reg *pmic = rdev_get_drvdata(dev);
379 int range, voltage = 0, id = rdev_get_id(dev); 378 int range, voltage = 0, id = rdev_get_id(dev);
380 379
380 if (id >= TPS65912_REG_LDO1 && id <= TPS65912_REG_LDO10)
381 return tps65912_vsel_to_uv_ldo(selector);
382
381 if (id > TPS65912_REG_DCDC4) 383 if (id > TPS65912_REG_DCDC4)
382 return -EINVAL; 384 return -EINVAL;
383 385
@@ -418,7 +420,7 @@ static int tps65912_get_voltage_dcdc(struct regulator_dev *dev)
418 vsel = tps65912_reg_read(mfd, reg); 420 vsel = tps65912_reg_read(mfd, reg);
419 vsel &= 0x3F; 421 vsel &= 0x3F;
420 422
421 return tps65912_list_voltage_dcdc(dev, vsel); 423 return tps65912_list_voltage(dev, vsel);
422} 424}
423 425
424static int tps65912_set_voltage_sel(struct regulator_dev *dev, 426static int tps65912_set_voltage_sel(struct regulator_dev *dev,
@@ -451,17 +453,6 @@ static int tps65912_get_voltage_ldo(struct regulator_dev *dev)
451 return tps65912_vsel_to_uv_ldo(vsel); 453 return tps65912_vsel_to_uv_ldo(vsel);
452} 454}
453 455
454static int tps65912_list_voltage_ldo(struct regulator_dev *dev,
455 unsigned selector)
456{
457 int ldo = rdev_get_id(dev);
458
459 if (ldo < TPS65912_REG_LDO1 || ldo > TPS65912_REG_LDO10)
460 return -EINVAL;
461
462 return tps65912_vsel_to_uv_ldo(selector);
463}
464
465/* Operations permitted on DCDCx */ 456/* Operations permitted on DCDCx */
466static struct regulator_ops tps65912_ops_dcdc = { 457static struct regulator_ops tps65912_ops_dcdc = {
467 .is_enabled = tps65912_reg_is_enabled, 458 .is_enabled = tps65912_reg_is_enabled,
@@ -471,7 +462,7 @@ static struct regulator_ops tps65912_ops_dcdc = {
471 .get_mode = tps65912_get_mode, 462 .get_mode = tps65912_get_mode,
472 .get_voltage = tps65912_get_voltage_dcdc, 463 .get_voltage = tps65912_get_voltage_dcdc,
473 .set_voltage_sel = tps65912_set_voltage_sel, 464 .set_voltage_sel = tps65912_set_voltage_sel,
474 .list_voltage = tps65912_list_voltage_dcdc, 465 .list_voltage = tps65912_list_voltage,
475}; 466};
476 467
477/* Operations permitted on LDOx */ 468/* Operations permitted on LDOx */
@@ -481,7 +472,7 @@ static struct regulator_ops tps65912_ops_ldo = {
481 .disable = tps65912_reg_disable, 472 .disable = tps65912_reg_disable,
482 .get_voltage = tps65912_get_voltage_ldo, 473 .get_voltage = tps65912_get_voltage_ldo,
483 .set_voltage_sel = tps65912_set_voltage_sel, 474 .set_voltage_sel = tps65912_set_voltage_sel,
484 .list_voltage = tps65912_list_voltage_ldo, 475 .list_voltage = tps65912_list_voltage,
485}; 476};
486 477
487static __devinit int tps65912_probe(struct platform_device *pdev) 478static __devinit int tps65912_probe(struct platform_device *pdev)