aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2012-11-26 21:27:34 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-11-27 15:07:40 -0500
commit9119ff6af541feee1daaa5cba3a4b3b5751a2d09 (patch)
tree83c3f4089e7045ebcc85936b8ea3f86f984b7659 /drivers
parent33234e791de2ac3ea915158e042907748191cabd (diff)
regulator: palmas: Use linear_min_sel and regulator_[map|list]_voltage_linear
Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/regulator/palmas-regulator.c37
1 files changed, 5 insertions, 32 deletions
diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c
index 07aee694ba92..111d76b04bb5 100644
--- a/drivers/regulator/palmas-regulator.c
+++ b/drivers/regulator/palmas-regulator.c
@@ -436,44 +436,14 @@ static int palmas_is_enabled_ldo(struct regulator_dev *dev)
436 return !!(reg); 436 return !!(reg);
437} 437}
438 438
439static int palmas_list_voltage_ldo(struct regulator_dev *dev,
440 unsigned selector)
441{
442 if (!selector)
443 return 0;
444
445 /* voltage is 0.85V + (selector * 0.05v) */
446 return 850000 + (selector * 50000);
447}
448
449static int palmas_map_voltage_ldo(struct regulator_dev *rdev,
450 int min_uV, int max_uV)
451{
452 int ret, voltage;
453
454 if (min_uV == 0)
455 return 0;
456
457 if (min_uV < 900000)
458 min_uV = 900000;
459 ret = DIV_ROUND_UP(min_uV - 900000, 50000) + 1;
460
461 /* Map back into a voltage to verify we're still in bounds */
462 voltage = palmas_list_voltage_ldo(rdev, ret);
463 if (voltage < min_uV || voltage > max_uV)
464 return -EINVAL;
465
466 return ret;
467}
468
469static struct regulator_ops palmas_ops_ldo = { 439static struct regulator_ops palmas_ops_ldo = {
470 .is_enabled = palmas_is_enabled_ldo, 440 .is_enabled = palmas_is_enabled_ldo,
471 .enable = regulator_enable_regmap, 441 .enable = regulator_enable_regmap,
472 .disable = regulator_disable_regmap, 442 .disable = regulator_disable_regmap,
473 .get_voltage_sel = regulator_get_voltage_sel_regmap, 443 .get_voltage_sel = regulator_get_voltage_sel_regmap,
474 .set_voltage_sel = regulator_set_voltage_sel_regmap, 444 .set_voltage_sel = regulator_set_voltage_sel_regmap,
475 .list_voltage = palmas_list_voltage_ldo, 445 .list_voltage = regulator_list_voltage_linear,
476 .map_voltage = palmas_map_voltage_ldo, 446 .map_voltage = regulator_map_voltage_linear,
477}; 447};
478 448
479/* 449/*
@@ -821,6 +791,9 @@ static __devinit int palmas_probe(struct platform_device *pdev)
821 791
822 pmic->desc[id].type = REGULATOR_VOLTAGE; 792 pmic->desc[id].type = REGULATOR_VOLTAGE;
823 pmic->desc[id].owner = THIS_MODULE; 793 pmic->desc[id].owner = THIS_MODULE;
794 pmic->desc[id].min_uV = 900000;
795 pmic->desc[id].uV_step = 50000;
796 pmic->desc[id].linear_min_sel = 1;
824 pmic->desc[id].vsel_reg = PALMAS_BASE_TO_REG(PALMAS_LDO_BASE, 797 pmic->desc[id].vsel_reg = PALMAS_BASE_TO_REG(PALMAS_LDO_BASE,
825 palmas_regs_info[id].vsel_addr); 798 palmas_regs_info[id].vsel_addr);
826 pmic->desc[id].vsel_mask = PALMAS_LDO1_VOLTAGE_VSEL_MASK; 799 pmic->desc[id].vsel_mask = PALMAS_LDO1_VOLTAGE_VSEL_MASK;