aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2012-07-16 06:31:10 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-07-16 15:58:02 -0400
commitc6a717c9d740ec8f5bd134ac8c75b1b7c0666ff8 (patch)
treeca8dd6ad44b9651eb5646b1bd6645c5b1526941b /drivers/regulator
parent4bcb9f43426dcb7b326d4b5448f198eea4867e63 (diff)
regulator: twl: Fix list_voltate for twl6030ldo_ops
According to the datasheet, the voltage for twl6030ldo_ops is not linear for all cases. Linear mapping is only for the selection code from 00000001 to 00011000. Table 9. LDO Output Voltage Selection Code CODE VOUT(V) COD VOUT(V) CODE VOUT(V) CODE VOUT(V) 00000000 0 00001000 1.7 00010000 2.5 00011000 3.3 00000001 1.0 00001001 1.8 00010001 2.6 00011001 Reserved 00000010 1.1 00001010 1.9 00010010 2.7 00011010 Reserved 00000011 1.2 00001011 2.0 00010011 2.8 00011011 Reserved 00000100 1.3 00001100 2.1 00010100 2.9 00011100 Reserved 00000101 1.4 00001101 2.2 00010101 3.0 00011101 Reserved 00000110 1.5 00001110 2.3 00010110 3.1 00011110 Reserved 00000111 1.6 00001111 2.4 00010111 3.2 00011111 2.75 This patch implements the list_voltage callback based on above table. Signed-off-by: Axel Lin <axel.lin@gmail.com> Tested-by: Rajendra Nayak <rnayak@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/twl-regulator.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c
index de99b784c5d..242fe90dc56 100644
--- a/drivers/regulator/twl-regulator.c
+++ b/drivers/regulator/twl-regulator.c
@@ -559,6 +559,27 @@ static struct regulator_ops twl6030coresmps_ops = {
559 .get_voltage = twl6030coresmps_get_voltage, 559 .get_voltage = twl6030coresmps_get_voltage,
560}; 560};
561 561
562static int twl6030ldo_list_voltage(struct regulator_dev *rdev, unsigned sel)
563{
564 struct twlreg_info *info = rdev_get_drvdata(rdev);
565
566 switch (sel) {
567 case 0:
568 return 0;
569 case 1 ... 24:
570 /* Linear mapping from 00000001 to 00011000:
571 * Absolute voltage value = 1.0 V + 0.1 V × (sel – 00000001)
572 */
573 return (info->min_mV + 100 * (sel - 1)) * 1000;
574 case 25 ... 30:
575 return -EINVAL;
576 case 31:
577 return 2750000;
578 default:
579 return -EINVAL;
580 }
581}
582
562static int 583static int
563twl6030ldo_set_voltage_sel(struct regulator_dev *rdev, unsigned selector) 584twl6030ldo_set_voltage_sel(struct regulator_dev *rdev, unsigned selector)
564{ 585{
@@ -577,7 +598,7 @@ static int twl6030ldo_get_voltage_sel(struct regulator_dev *rdev)
577} 598}
578 599
579static struct regulator_ops twl6030ldo_ops = { 600static struct regulator_ops twl6030ldo_ops = {
580 .list_voltage = regulator_list_voltage_linear, 601 .list_voltage = twl6030ldo_list_voltage,
581 602
582 .set_voltage_sel = twl6030ldo_set_voltage_sel, 603 .set_voltage_sel = twl6030ldo_set_voltage_sel,
583 .get_voltage_sel = twl6030ldo_get_voltage_sel, 604 .get_voltage_sel = twl6030ldo_get_voltage_sel,
@@ -906,12 +927,10 @@ static struct twlreg_info TWL6030_INFO_##label = { \
906 .desc = { \ 927 .desc = { \
907 .name = #label, \ 928 .name = #label, \
908 .id = TWL6030_REG_##label, \ 929 .id = TWL6030_REG_##label, \
909 .n_voltages = (max_mVolts - min_mVolts)/100 + 1, \ 930 .n_voltages = 32, \
910 .ops = &twl6030ldo_ops, \ 931 .ops = &twl6030ldo_ops, \
911 .type = REGULATOR_VOLTAGE, \ 932 .type = REGULATOR_VOLTAGE, \
912 .owner = THIS_MODULE, \ 933 .owner = THIS_MODULE, \
913 .min_uV = min_mVolts * 1000, \
914 .uV_step = 100 * 1000, \
915 }, \ 934 }, \
916 } 935 }
917 936
@@ -923,12 +942,10 @@ static struct twlreg_info TWL6025_INFO_##label = { \
923 .desc = { \ 942 .desc = { \
924 .name = #label, \ 943 .name = #label, \
925 .id = TWL6025_REG_##label, \ 944 .id = TWL6025_REG_##label, \
926 .n_voltages = ((max_mVolts - min_mVolts)/100) + 1, \ 945 .n_voltages = 32, \
927 .ops = &twl6030ldo_ops, \ 946 .ops = &twl6030ldo_ops, \
928 .type = REGULATOR_VOLTAGE, \ 947 .type = REGULATOR_VOLTAGE, \
929 .owner = THIS_MODULE, \ 948 .owner = THIS_MODULE, \
930 .min_uV = min_mVolts * 1000, \
931 .uV_step = 100 * 1000, \
932 }, \ 949 }, \
933 } 950 }
934 951