aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/twl-regulator.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/regulator/twl-regulator.c')
-rw-r--r--drivers/regulator/twl-regulator.c92
1 files changed, 31 insertions, 61 deletions
diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c
index c7390711d954..242fe90dc565 100644
--- a/drivers/regulator/twl-regulator.c
+++ b/drivers/regulator/twl-regulator.c
@@ -43,9 +43,6 @@ struct twlreg_info {
43 u8 table_len; 43 u8 table_len;
44 const u16 *table; 44 const u16 *table;
45 45
46 /* regulator specific turn-on delay */
47 u16 delay;
48
49 /* State REMAP default configuration */ 46 /* State REMAP default configuration */
50 u8 remap; 47 u8 remap;
51 48
@@ -223,20 +220,6 @@ static int twl6030reg_enable(struct regulator_dev *rdev)
223 return ret; 220 return ret;
224} 221}
225 222
226static int twl4030reg_enable_time(struct regulator_dev *rdev)
227{
228 struct twlreg_info *info = rdev_get_drvdata(rdev);
229
230 return info->delay;
231}
232
233static int twl6030reg_enable_time(struct regulator_dev *rdev)
234{
235 struct twlreg_info *info = rdev_get_drvdata(rdev);
236
237 return info->delay;
238}
239
240static int twl4030reg_disable(struct regulator_dev *rdev) 223static int twl4030reg_disable(struct regulator_dev *rdev)
241{ 224{
242 struct twlreg_info *info = rdev_get_drvdata(rdev); 225 struct twlreg_info *info = rdev_get_drvdata(rdev);
@@ -508,7 +491,6 @@ static struct regulator_ops twl4030ldo_ops = {
508 .enable = twl4030reg_enable, 491 .enable = twl4030reg_enable,
509 .disable = twl4030reg_disable, 492 .disable = twl4030reg_disable,
510 .is_enabled = twl4030reg_is_enabled, 493 .is_enabled = twl4030reg_is_enabled,
511 .enable_time = twl4030reg_enable_time,
512 494
513 .set_mode = twl4030reg_set_mode, 495 .set_mode = twl4030reg_set_mode,
514 496
@@ -577,59 +559,53 @@ static struct regulator_ops twl6030coresmps_ops = {
577 .get_voltage = twl6030coresmps_get_voltage, 559 .get_voltage = twl6030coresmps_get_voltage,
578}; 560};
579 561
580static int twl6030ldo_list_voltage(struct regulator_dev *rdev, unsigned index) 562static int twl6030ldo_list_voltage(struct regulator_dev *rdev, unsigned sel)
581{ 563{
582 struct twlreg_info *info = rdev_get_drvdata(rdev); 564 struct twlreg_info *info = rdev_get_drvdata(rdev);
583 565
584 return ((info->min_mV + (index * 100)) * 1000); 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 }
585} 581}
586 582
587static int 583static int
588twl6030ldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV, 584twl6030ldo_set_voltage_sel(struct regulator_dev *rdev, unsigned selector)
589 unsigned *selector)
590{ 585{
591 struct twlreg_info *info = rdev_get_drvdata(rdev); 586 struct twlreg_info *info = rdev_get_drvdata(rdev);
592 int vsel;
593
594 if ((min_uV/1000 < info->min_mV) || (max_uV/1000 > info->max_mV))
595 return -EDOM;
596
597 /*
598 * Use the below formula to calculate vsel
599 * mV = 1000mv + 100mv * (vsel - 1)
600 */
601 vsel = (min_uV/1000 - 1000)/100 + 1;
602 *selector = vsel;
603 return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE, vsel);
604 587
588 return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE,
589 selector);
605} 590}
606 591
607static int twl6030ldo_get_voltage(struct regulator_dev *rdev) 592static int twl6030ldo_get_voltage_sel(struct regulator_dev *rdev)
608{ 593{
609 struct twlreg_info *info = rdev_get_drvdata(rdev); 594 struct twlreg_info *info = rdev_get_drvdata(rdev);
610 int vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER, 595 int vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE);
611 VREG_VOLTAGE);
612
613 if (vsel < 0)
614 return vsel;
615 596
616 /* 597 return vsel;
617 * Use the below formula to calculate vsel
618 * mV = 1000mv + 100mv * (vsel - 1)
619 */
620 return (1000 + (100 * (vsel - 1))) * 1000;
621} 598}
622 599
623static struct regulator_ops twl6030ldo_ops = { 600static struct regulator_ops twl6030ldo_ops = {
624 .list_voltage = twl6030ldo_list_voltage, 601 .list_voltage = twl6030ldo_list_voltage,
625 602
626 .set_voltage = twl6030ldo_set_voltage, 603 .set_voltage_sel = twl6030ldo_set_voltage_sel,
627 .get_voltage = twl6030ldo_get_voltage, 604 .get_voltage_sel = twl6030ldo_get_voltage_sel,
628 605
629 .enable = twl6030reg_enable, 606 .enable = twl6030reg_enable,
630 .disable = twl6030reg_disable, 607 .disable = twl6030reg_disable,
631 .is_enabled = twl6030reg_is_enabled, 608 .is_enabled = twl6030reg_is_enabled,
632 .enable_time = twl6030reg_enable_time,
633 609
634 .set_mode = twl6030reg_set_mode, 610 .set_mode = twl6030reg_set_mode,
635 611
@@ -663,7 +639,6 @@ static struct regulator_ops twl4030fixed_ops = {
663 .enable = twl4030reg_enable, 639 .enable = twl4030reg_enable,
664 .disable = twl4030reg_disable, 640 .disable = twl4030reg_disable,
665 .is_enabled = twl4030reg_is_enabled, 641 .is_enabled = twl4030reg_is_enabled,
666 .enable_time = twl4030reg_enable_time,
667 642
668 .set_mode = twl4030reg_set_mode, 643 .set_mode = twl4030reg_set_mode,
669 644
@@ -678,7 +653,6 @@ static struct regulator_ops twl6030fixed_ops = {
678 .enable = twl6030reg_enable, 653 .enable = twl6030reg_enable,
679 .disable = twl6030reg_disable, 654 .disable = twl6030reg_disable,
680 .is_enabled = twl6030reg_is_enabled, 655 .is_enabled = twl6030reg_is_enabled,
681 .enable_time = twl6030reg_enable_time,
682 656
683 .set_mode = twl6030reg_set_mode, 657 .set_mode = twl6030reg_set_mode,
684 658
@@ -689,7 +663,6 @@ static struct regulator_ops twl6030_fixed_resource = {
689 .enable = twl6030reg_enable, 663 .enable = twl6030reg_enable,
690 .disable = twl6030reg_disable, 664 .disable = twl6030reg_disable,
691 .is_enabled = twl6030reg_is_enabled, 665 .is_enabled = twl6030reg_is_enabled,
692 .enable_time = twl6030reg_enable_time,
693 .get_status = twl6030reg_get_status, 666 .get_status = twl6030reg_get_status,
694}; 667};
695 668
@@ -886,7 +859,6 @@ static struct regulator_ops twlsmps_ops = {
886 .enable = twl6030reg_enable, 859 .enable = twl6030reg_enable,
887 .disable = twl6030reg_disable, 860 .disable = twl6030reg_disable,
888 .is_enabled = twl6030reg_is_enabled, 861 .is_enabled = twl6030reg_is_enabled,
889 .enable_time = twl6030reg_enable_time,
890 862
891 .set_mode = twl6030reg_set_mode, 863 .set_mode = twl6030reg_set_mode,
892 864
@@ -909,7 +881,6 @@ static struct twlreg_info TWL4030_INFO_##label = { \
909 .id = num, \ 881 .id = num, \
910 .table_len = ARRAY_SIZE(label##_VSEL_table), \ 882 .table_len = ARRAY_SIZE(label##_VSEL_table), \
911 .table = label##_VSEL_table, \ 883 .table = label##_VSEL_table, \
912 .delay = turnon_delay, \
913 .remap = remap_conf, \ 884 .remap = remap_conf, \
914 .desc = { \ 885 .desc = { \
915 .name = #label, \ 886 .name = #label, \
@@ -918,6 +889,7 @@ static struct twlreg_info TWL4030_INFO_##label = { \
918 .ops = &twl4030ldo_ops, \ 889 .ops = &twl4030ldo_ops, \
919 .type = REGULATOR_VOLTAGE, \ 890 .type = REGULATOR_VOLTAGE, \
920 .owner = THIS_MODULE, \ 891 .owner = THIS_MODULE, \
892 .enable_time = turnon_delay, \
921 }, \ 893 }, \
922 } 894 }
923 895
@@ -925,7 +897,6 @@ static struct twlreg_info TWL4030_INFO_##label = { \
925static struct twlreg_info TWL4030_INFO_##label = { \ 897static struct twlreg_info TWL4030_INFO_##label = { \
926 .base = offset, \ 898 .base = offset, \
927 .id = num, \ 899 .id = num, \
928 .delay = turnon_delay, \
929 .remap = remap_conf, \ 900 .remap = remap_conf, \
930 .desc = { \ 901 .desc = { \
931 .name = #label, \ 902 .name = #label, \
@@ -933,6 +904,7 @@ static struct twlreg_info TWL4030_INFO_##label = { \
933 .ops = &twl4030smps_ops, \ 904 .ops = &twl4030smps_ops, \
934 .type = REGULATOR_VOLTAGE, \ 905 .type = REGULATOR_VOLTAGE, \
935 .owner = THIS_MODULE, \ 906 .owner = THIS_MODULE, \
907 .enable_time = turnon_delay, \
936 }, \ 908 }, \
937 } 909 }
938 910
@@ -955,7 +927,7 @@ static struct twlreg_info TWL6030_INFO_##label = { \
955 .desc = { \ 927 .desc = { \
956 .name = #label, \ 928 .name = #label, \
957 .id = TWL6030_REG_##label, \ 929 .id = TWL6030_REG_##label, \
958 .n_voltages = (max_mVolts - min_mVolts)/100 + 1, \ 930 .n_voltages = 32, \
959 .ops = &twl6030ldo_ops, \ 931 .ops = &twl6030ldo_ops, \
960 .type = REGULATOR_VOLTAGE, \ 932 .type = REGULATOR_VOLTAGE, \
961 .owner = THIS_MODULE, \ 933 .owner = THIS_MODULE, \
@@ -970,7 +942,7 @@ static struct twlreg_info TWL6025_INFO_##label = { \
970 .desc = { \ 942 .desc = { \
971 .name = #label, \ 943 .name = #label, \
972 .id = TWL6025_REG_##label, \ 944 .id = TWL6025_REG_##label, \
973 .n_voltages = ((max_mVolts - min_mVolts)/100) + 1, \ 945 .n_voltages = 32, \
974 .ops = &twl6030ldo_ops, \ 946 .ops = &twl6030ldo_ops, \
975 .type = REGULATOR_VOLTAGE, \ 947 .type = REGULATOR_VOLTAGE, \
976 .owner = THIS_MODULE, \ 948 .owner = THIS_MODULE, \
@@ -983,7 +955,6 @@ static struct twlreg_info TWLFIXED_INFO_##label = { \
983 .base = offset, \ 955 .base = offset, \
984 .id = num, \ 956 .id = num, \
985 .min_mV = mVolts, \ 957 .min_mV = mVolts, \
986 .delay = turnon_delay, \
987 .remap = remap_conf, \ 958 .remap = remap_conf, \
988 .desc = { \ 959 .desc = { \
989 .name = #label, \ 960 .name = #label, \
@@ -992,19 +963,20 @@ static struct twlreg_info TWLFIXED_INFO_##label = { \
992 .ops = &operations, \ 963 .ops = &operations, \
993 .type = REGULATOR_VOLTAGE, \ 964 .type = REGULATOR_VOLTAGE, \
994 .owner = THIS_MODULE, \ 965 .owner = THIS_MODULE, \
966 .enable_time = turnon_delay, \
995 }, \ 967 }, \
996 } 968 }
997 969
998#define TWL6030_FIXED_RESOURCE(label, offset, turnon_delay) \ 970#define TWL6030_FIXED_RESOURCE(label, offset, turnon_delay) \
999static struct twlreg_info TWLRES_INFO_##label = { \ 971static struct twlreg_info TWLRES_INFO_##label = { \
1000 .base = offset, \ 972 .base = offset, \
1001 .delay = turnon_delay, \
1002 .desc = { \ 973 .desc = { \
1003 .name = #label, \ 974 .name = #label, \
1004 .id = TWL6030_REG_##label, \ 975 .id = TWL6030_REG_##label, \
1005 .ops = &twl6030_fixed_resource, \ 976 .ops = &twl6030_fixed_resource, \
1006 .type = REGULATOR_VOLTAGE, \ 977 .type = REGULATOR_VOLTAGE, \
1007 .owner = THIS_MODULE, \ 978 .owner = THIS_MODULE, \
979 .enable_time = turnon_delay, \
1008 }, \ 980 }, \
1009 } 981 }
1010 982
@@ -1109,7 +1081,6 @@ static u8 twl_get_smps_mult(void)
1109#define TWL6030_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWL6030, label) 1081#define TWL6030_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWL6030, label)
1110#define TWL6025_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWL6025, label) 1082#define TWL6025_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWL6025, label)
1111#define TWLFIXED_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWLFIXED, label) 1083#define TWLFIXED_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWLFIXED, label)
1112#define TWLRES_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWLRES, label)
1113#define TWLSMPS_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWLSMPS, label) 1084#define TWLSMPS_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWLSMPS, label)
1114 1085
1115static const struct of_device_id twl_of_match[] __devinitconst = { 1086static const struct of_device_id twl_of_match[] __devinitconst = {
@@ -1157,7 +1128,6 @@ static const struct of_device_id twl_of_match[] __devinitconst = {
1157 TWLFIXED_OF_MATCH("ti,twl6030-vusb", VUSB), 1128 TWLFIXED_OF_MATCH("ti,twl6030-vusb", VUSB),
1158 TWLFIXED_OF_MATCH("ti,twl6030-v1v8", V1V8), 1129 TWLFIXED_OF_MATCH("ti,twl6030-v1v8", V1V8),
1159 TWLFIXED_OF_MATCH("ti,twl6030-v2v1", V2V1), 1130 TWLFIXED_OF_MATCH("ti,twl6030-v2v1", V2V1),
1160 TWLRES_OF_MATCH("ti,twl6030-clk32kg", CLK32KG),
1161 TWLSMPS_OF_MATCH("ti,twl6025-smps3", SMPS3), 1131 TWLSMPS_OF_MATCH("ti,twl6025-smps3", SMPS3),
1162 TWLSMPS_OF_MATCH("ti,twl6025-smps4", SMPS4), 1132 TWLSMPS_OF_MATCH("ti,twl6025-smps4", SMPS4),
1163 TWLSMPS_OF_MATCH("ti,twl6025-vio", VIO), 1133 TWLSMPS_OF_MATCH("ti,twl6025-vio", VIO),