aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/regulator/twl-regulator.txt68
-rw-r--r--drivers/mfd/twl-core.c41
-rw-r--r--drivers/regulator/twl-regulator.c327
-rw-r--r--include/linux/i2c/twl.h14
4 files changed, 366 insertions, 84 deletions
diff --git a/Documentation/devicetree/bindings/regulator/twl-regulator.txt b/Documentation/devicetree/bindings/regulator/twl-regulator.txt
new file mode 100644
index 000000000000..0c3395d55ac1
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/twl-regulator.txt
@@ -0,0 +1,68 @@
1TWL family of regulators
2
3Required properties:
4For twl6030 regulators/LDOs
5- compatible:
6 - "ti,twl6030-vaux1" for VAUX1 LDO
7 - "ti,twl6030-vaux2" for VAUX2 LDO
8 - "ti,twl6030-vaux3" for VAUX3 LDO
9 - "ti,twl6030-vmmc" for VMMC LDO
10 - "ti,twl6030-vpp" for VPP LDO
11 - "ti,twl6030-vusim" for VUSIM LDO
12 - "ti,twl6030-vana" for VANA LDO
13 - "ti,twl6030-vcxio" for VCXIO LDO
14 - "ti,twl6030-vdac" for VDAC LDO
15 - "ti,twl6030-vusb" for VUSB LDO
16 - "ti,twl6030-v1v8" for V1V8 LDO
17 - "ti,twl6030-v2v1" for V2V1 LDO
18 - "ti,twl6030-clk32kg" for CLK32KG RESOURCE
19 - "ti,twl6030-vdd1" for VDD1 SMPS
20 - "ti,twl6030-vdd2" for VDD2 SMPS
21 - "ti,twl6030-vdd3" for VDD3 SMPS
22For twl6025 regulators/LDOs
23- compatible:
24 - "ti,twl6025-ldo1" for LDO1 LDO
25 - "ti,twl6025-ldo2" for LDO2 LDO
26 - "ti,twl6025-ldo3" for LDO3 LDO
27 - "ti,twl6025-ldo4" for LDO4 LDO
28 - "ti,twl6025-ldo5" for LDO5 LDO
29 - "ti,twl6025-ldo6" for LDO6 LDO
30 - "ti,twl6025-ldo7" for LDO7 LDO
31 - "ti,twl6025-ldoln" for LDOLN LDO
32 - "ti,twl6025-ldousb" for LDOUSB LDO
33 - "ti,twl6025-smps3" for SMPS3 SMPS
34 - "ti,twl6025-smps4" for SMPS4 SMPS
35 - "ti,twl6025-vio" for VIO SMPS
36For twl4030 regulators/LDOs
37- compatible:
38 - "ti,twl4030-vaux1" for VAUX1 LDO
39 - "ti,twl4030-vaux2" for VAUX2 LDO
40 - "ti,twl5030-vaux2" for VAUX2 LDO
41 - "ti,twl4030-vaux3" for VAUX3 LDO
42 - "ti,twl4030-vaux4" for VAUX4 LDO
43 - "ti,twl4030-vmmc1" for VMMC1 LDO
44 - "ti,twl4030-vmmc2" for VMMC2 LDO
45 - "ti,twl4030-vpll1" for VPLL1 LDO
46 - "ti,twl4030-vpll2" for VPLL2 LDO
47 - "ti,twl4030-vsim" for VSIM LDO
48 - "ti,twl4030-vdac" for VDAC LDO
49 - "ti,twl4030-vintana2" for VINTANA2 LDO
50 - "ti,twl4030-vio" for VIO LDO
51 - "ti,twl4030-vdd1" for VDD1 SMPS
52 - "ti,twl4030-vdd2" for VDD2 SMPS
53 - "ti,twl4030-vintana1" for VINTANA1 LDO
54 - "ti,twl4030-vintdig" for VINTDIG LDO
55 - "ti,twl4030-vusb1v5" for VUSB1V5 LDO
56 - "ti,twl4030-vusb1v8" for VUSB1V8 LDO
57 - "ti,twl4030-vusb3v1" for VUSB3V1 LDO
58
59Optional properties:
60- Any optional property defined in bindings/regulator/regulator.txt
61
62Example:
63
64 xyz: regulator@0 {
65 compatible = "ti,twl6030-vaux1";
66 regulator-min-microvolt = <1000000>;
67 regulator-max-microvolt = <3000000>;
68 };
diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index c1e4f1a277e9..6cb10610a161 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -621,6 +621,8 @@ add_regulator_linked(int num, struct regulator_init_data *pdata,
621 unsigned num_consumers, unsigned long features) 621 unsigned num_consumers, unsigned long features)
622{ 622{
623 unsigned sub_chip_id; 623 unsigned sub_chip_id;
624 struct twl_regulator_driver_data drv_data;
625
624 /* regulator framework demands init_data ... */ 626 /* regulator framework demands init_data ... */
625 if (!pdata) 627 if (!pdata)
626 return NULL; 628 return NULL;
@@ -630,7 +632,19 @@ add_regulator_linked(int num, struct regulator_init_data *pdata,
630 pdata->num_consumer_supplies = num_consumers; 632 pdata->num_consumer_supplies = num_consumers;
631 } 633 }
632 634
633 pdata->driver_data = (void *)features; 635 if (pdata->driver_data) {
636 /* If we have existing drv_data, just add the flags */
637 struct twl_regulator_driver_data *tmp;
638 tmp = pdata->driver_data;
639 tmp->features |= features;
640 } else {
641 /* add new driver data struct, used only during init */
642 drv_data.features = features;
643 drv_data.set_voltage = NULL;
644 drv_data.get_voltage = NULL;
645 drv_data.data = NULL;
646 pdata->driver_data = &drv_data;
647 }
634 648
635 /* NOTE: we currently ignore regulator IRQs, e.g. for short circuits */ 649 /* NOTE: we currently ignore regulator IRQs, e.g. for short circuits */
636 sub_chip_id = twl_map[TWL_MODULE_PM_MASTER].sid; 650 sub_chip_id = twl_map[TWL_MODULE_PM_MASTER].sid;
@@ -937,6 +951,31 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)
937 /* twl6030 regulators */ 951 /* twl6030 regulators */
938 if (twl_has_regulator() && twl_class_is_6030() && 952 if (twl_has_regulator() && twl_class_is_6030() &&
939 !(features & TWL6025_SUBCLASS)) { 953 !(features & TWL6025_SUBCLASS)) {
954 child = add_regulator(TWL6030_REG_VDD1, pdata->vdd1,
955 features);
956 if (IS_ERR(child))
957 return PTR_ERR(child);
958
959 child = add_regulator(TWL6030_REG_VDD2, pdata->vdd2,
960 features);
961 if (IS_ERR(child))
962 return PTR_ERR(child);
963
964 child = add_regulator(TWL6030_REG_VDD3, pdata->vdd3,
965 features);
966 if (IS_ERR(child))
967 return PTR_ERR(child);
968
969 child = add_regulator(TWL6030_REG_V1V8, pdata->v1v8,
970 features);
971 if (IS_ERR(child))
972 return PTR_ERR(child);
973
974 child = add_regulator(TWL6030_REG_V2V1, pdata->v2v1,
975 features);
976 if (IS_ERR(child))
977 return PTR_ERR(child);
978
940 child = add_regulator(TWL6030_REG_VMMC, pdata->vmmc, 979 child = add_regulator(TWL6030_REG_VMMC, pdata->vmmc,
941 features); 980 features);
942 if (IS_ERR(child)) 981 if (IS_ERR(child))
diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c
index 181a2cfe180c..9cdfc389ca26 100644
--- a/drivers/regulator/twl-regulator.c
+++ b/drivers/regulator/twl-regulator.c
@@ -14,8 +14,11 @@
14#include <linux/err.h> 14#include <linux/err.h>
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/of.h>
18#include <linux/of_device.h>
17#include <linux/regulator/driver.h> 19#include <linux/regulator/driver.h>
18#include <linux/regulator/machine.h> 20#include <linux/regulator/machine.h>
21#include <linux/regulator/of_regulator.h>
19#include <linux/i2c/twl.h> 22#include <linux/i2c/twl.h>
20 23
21 24
@@ -58,6 +61,16 @@ struct twlreg_info {
58 61
59 /* chip specific features */ 62 /* chip specific features */
60 unsigned long features; 63 unsigned long features;
64
65 /*
66 * optional override functions for voltage set/get
67 * these are currently only used for SMPS regulators
68 */
69 int (*get_voltage)(void *data);
70 int (*set_voltage)(void *data, int target_uV);
71
72 /* data passed from board for external get/set voltage */
73 void *data;
61}; 74};
62 75
63 76
@@ -522,15 +535,25 @@ twl4030smps_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV,
522 struct twlreg_info *info = rdev_get_drvdata(rdev); 535 struct twlreg_info *info = rdev_get_drvdata(rdev);
523 int vsel = DIV_ROUND_UP(min_uV - 600000, 12500); 536 int vsel = DIV_ROUND_UP(min_uV - 600000, 12500);
524 537
525 twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE_SMPS_4030, 538 if (info->set_voltage) {
526 vsel); 539 return info->set_voltage(info->data, min_uV);
540 } else {
541 twlreg_write(info, TWL_MODULE_PM_RECEIVER,
542 VREG_VOLTAGE_SMPS_4030, vsel);
543 }
544
527 return 0; 545 return 0;
528} 546}
529 547
530static int twl4030smps_get_voltage(struct regulator_dev *rdev) 548static int twl4030smps_get_voltage(struct regulator_dev *rdev)
531{ 549{
532 struct twlreg_info *info = rdev_get_drvdata(rdev); 550 struct twlreg_info *info = rdev_get_drvdata(rdev);
533 int vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER, 551 int vsel;
552
553 if (info->get_voltage)
554 return info->get_voltage(info->data);
555
556 vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER,
534 VREG_VOLTAGE_SMPS_4030); 557 VREG_VOLTAGE_SMPS_4030);
535 558
536 return vsel * 12500 + 600000; 559 return vsel * 12500 + 600000;
@@ -541,6 +564,32 @@ static struct regulator_ops twl4030smps_ops = {
541 .get_voltage = twl4030smps_get_voltage, 564 .get_voltage = twl4030smps_get_voltage,
542}; 565};
543 566
567static int twl6030coresmps_set_voltage(struct regulator_dev *rdev, int min_uV,
568 int max_uV, unsigned *selector)
569{
570 struct twlreg_info *info = rdev_get_drvdata(rdev);
571
572 if (info->set_voltage)
573 return info->set_voltage(info->data, min_uV);
574
575 return -ENODEV;
576}
577
578static int twl6030coresmps_get_voltage(struct regulator_dev *rdev)
579{
580 struct twlreg_info *info = rdev_get_drvdata(rdev);
581
582 if (info->get_voltage)
583 return info->get_voltage(info->data);
584
585 return -ENODEV;
586}
587
588static struct regulator_ops twl6030coresmps_ops = {
589 .set_voltage = twl6030coresmps_set_voltage,
590 .get_voltage = twl6030coresmps_get_voltage,
591};
592
544static int twl6030ldo_list_voltage(struct regulator_dev *rdev, unsigned index) 593static int twl6030ldo_list_voltage(struct regulator_dev *rdev, unsigned index)
545{ 594{
546 struct twlreg_info *info = rdev_get_drvdata(rdev); 595 struct twlreg_info *info = rdev_get_drvdata(rdev);
@@ -755,12 +804,16 @@ twl6030smps_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV,
755 case 0: 804 case 0:
756 if (min_uV == 0) 805 if (min_uV == 0)
757 vsel = 0; 806 vsel = 0;
758 else if ((min_uV >= 600000) && (max_uV <= 1300000)) { 807 else if ((min_uV >= 600000) && (min_uV <= 1300000)) {
808 int calc_uV;
759 vsel = (min_uV - 600000) / 125; 809 vsel = (min_uV - 600000) / 125;
760 if (vsel % 100) 810 if (vsel % 100)
761 vsel += 100; 811 vsel += 100;
762 vsel /= 100; 812 vsel /= 100;
763 vsel++; 813 vsel++;
814 calc_uV = twl6030smps_list_voltage(rdev, vsel);
815 if (calc_uV > max_uV)
816 return -EINVAL;
764 } 817 }
765 /* Values 1..57 for vsel are linear and can be calculated 818 /* Values 1..57 for vsel are linear and can be calculated
766 * values 58..62 are non linear. 819 * values 58..62 are non linear.
@@ -781,12 +834,16 @@ twl6030smps_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV,
781 case SMPS_OFFSET_EN: 834 case SMPS_OFFSET_EN:
782 if (min_uV == 0) 835 if (min_uV == 0)
783 vsel = 0; 836 vsel = 0;
784 else if ((min_uV >= 700000) && (max_uV <= 1420000)) { 837 else if ((min_uV >= 700000) && (min_uV <= 1420000)) {
838 int calc_uV;
785 vsel = (min_uV - 700000) / 125; 839 vsel = (min_uV - 700000) / 125;
786 if (vsel % 100) 840 if (vsel % 100)
787 vsel += 100; 841 vsel += 100;
788 vsel /= 100; 842 vsel /= 100;
789 vsel++; 843 vsel++;
844 calc_uV = twl6030smps_list_voltage(rdev, vsel);
845 if (calc_uV > max_uV)
846 return -EINVAL;
790 } 847 }
791 /* Values 1..57 for vsel are linear and can be calculated 848 /* Values 1..57 for vsel are linear and can be calculated
792 * values 58..62 are non linear. 849 * values 58..62 are non linear.
@@ -819,7 +876,7 @@ twl6030smps_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV,
819 if (min_uV == 0) 876 if (min_uV == 0)
820 vsel = 0; 877 vsel = 0;
821 else if ((min_uV >= 2161000) && (max_uV <= 4321000)) { 878 else if ((min_uV >= 2161000) && (max_uV <= 4321000)) {
822 vsel = (min_uV - 1852000) / 386; 879 vsel = (min_uV - 2161000) / 386;
823 if (vsel % 100) 880 if (vsel % 100)
824 vsel += 100; 881 vsel += 100;
825 vsel /= 100; 882 vsel /= 100;
@@ -866,7 +923,8 @@ static struct regulator_ops twlsmps_ops = {
866 TWL_FIXED_LDO(label, offset, mVolts, 0x0, turnon_delay, \ 923 TWL_FIXED_LDO(label, offset, mVolts, 0x0, turnon_delay, \
867 0x0, TWL6030, twl6030fixed_ops) 924 0x0, TWL6030, twl6030fixed_ops)
868 925
869#define TWL4030_ADJUSTABLE_LDO(label, offset, num, turnon_delay, remap_conf) { \ 926#define TWL4030_ADJUSTABLE_LDO(label, offset, num, turnon_delay, remap_conf) \
927static struct twlreg_info TWL4030_INFO_##label = { \
870 .base = offset, \ 928 .base = offset, \
871 .id = num, \ 929 .id = num, \
872 .table_len = ARRAY_SIZE(label##_VSEL_table), \ 930 .table_len = ARRAY_SIZE(label##_VSEL_table), \
@@ -884,7 +942,7 @@ static struct regulator_ops twlsmps_ops = {
884 } 942 }
885 943
886#define TWL4030_ADJUSTABLE_SMPS(label, offset, num, turnon_delay, remap_conf) \ 944#define TWL4030_ADJUSTABLE_SMPS(label, offset, num, turnon_delay, remap_conf) \
887 { \ 945static struct twlreg_info TWL4030_INFO_##label = { \
888 .base = offset, \ 946 .base = offset, \
889 .id = num, \ 947 .id = num, \
890 .delay = turnon_delay, \ 948 .delay = turnon_delay, \
@@ -898,7 +956,19 @@ static struct regulator_ops twlsmps_ops = {
898 }, \ 956 }, \
899 } 957 }
900 958
901#define TWL6030_ADJUSTABLE_LDO(label, offset, min_mVolts, max_mVolts) { \ 959#define TWL6030_ADJUSTABLE_SMPS(label) \
960static struct twlreg_info TWL6030_INFO_##label = { \
961 .desc = { \
962 .name = #label, \
963 .id = TWL6030_REG_##label, \
964 .ops = &twl6030coresmps_ops, \
965 .type = REGULATOR_VOLTAGE, \
966 .owner = THIS_MODULE, \
967 }, \
968 }
969
970#define TWL6030_ADJUSTABLE_LDO(label, offset, min_mVolts, max_mVolts) \
971static struct twlreg_info TWL6030_INFO_##label = { \
902 .base = offset, \ 972 .base = offset, \
903 .min_mV = min_mVolts, \ 973 .min_mV = min_mVolts, \
904 .max_mV = max_mVolts, \ 974 .max_mV = max_mVolts, \
@@ -912,7 +982,8 @@ static struct regulator_ops twlsmps_ops = {
912 }, \ 982 }, \
913 } 983 }
914 984
915#define TWL6025_ADJUSTABLE_LDO(label, offset, min_mVolts, max_mVolts) { \ 985#define TWL6025_ADJUSTABLE_LDO(label, offset, min_mVolts, max_mVolts) \
986static struct twlreg_info TWL6025_INFO_##label = { \
916 .base = offset, \ 987 .base = offset, \
917 .min_mV = min_mVolts, \ 988 .min_mV = min_mVolts, \
918 .max_mV = max_mVolts, \ 989 .max_mV = max_mVolts, \
@@ -927,7 +998,8 @@ static struct regulator_ops twlsmps_ops = {
927 } 998 }
928 999
929#define TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, remap_conf, \ 1000#define TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, remap_conf, \
930 family, operations) { \ 1001 family, operations) \
1002static struct twlreg_info TWLFIXED_INFO_##label = { \
931 .base = offset, \ 1003 .base = offset, \
932 .id = num, \ 1004 .id = num, \
933 .min_mV = mVolts, \ 1005 .min_mV = mVolts, \
@@ -943,7 +1015,8 @@ static struct regulator_ops twlsmps_ops = {
943 }, \ 1015 }, \
944 } 1016 }
945 1017
946#define TWL6030_FIXED_RESOURCE(label, offset, turnon_delay) { \ 1018#define TWL6030_FIXED_RESOURCE(label, offset, turnon_delay) \
1019static struct twlreg_info TWLRES_INFO_##label = { \
947 .base = offset, \ 1020 .base = offset, \
948 .delay = turnon_delay, \ 1021 .delay = turnon_delay, \
949 .desc = { \ 1022 .desc = { \
@@ -955,7 +1028,8 @@ static struct regulator_ops twlsmps_ops = {
955 }, \ 1028 }, \
956 } 1029 }
957 1030
958#define TWL6025_ADJUSTABLE_SMPS(label, offset) { \ 1031#define TWL6025_ADJUSTABLE_SMPS(label, offset) \
1032static struct twlreg_info TWLSMPS_INFO_##label = { \
959 .base = offset, \ 1033 .base = offset, \
960 .min_mV = 600, \ 1034 .min_mV = 600, \
961 .max_mV = 2100, \ 1035 .max_mV = 2100, \
@@ -973,59 +1047,59 @@ static struct regulator_ops twlsmps_ops = {
973 * We list regulators here if systems need some level of 1047 * We list regulators here if systems need some level of
974 * software control over them after boot. 1048 * software control over them after boot.
975 */ 1049 */
976static struct twlreg_info twl_regs[] = { 1050TWL4030_ADJUSTABLE_LDO(VAUX1, 0x17, 1, 100, 0x08);
977 TWL4030_ADJUSTABLE_LDO(VAUX1, 0x17, 1, 100, 0x08), 1051TWL4030_ADJUSTABLE_LDO(VAUX2_4030, 0x1b, 2, 100, 0x08);
978 TWL4030_ADJUSTABLE_LDO(VAUX2_4030, 0x1b, 2, 100, 0x08), 1052TWL4030_ADJUSTABLE_LDO(VAUX2, 0x1b, 2, 100, 0x08);
979 TWL4030_ADJUSTABLE_LDO(VAUX2, 0x1b, 2, 100, 0x08), 1053TWL4030_ADJUSTABLE_LDO(VAUX3, 0x1f, 3, 100, 0x08);
980 TWL4030_ADJUSTABLE_LDO(VAUX3, 0x1f, 3, 100, 0x08), 1054TWL4030_ADJUSTABLE_LDO(VAUX4, 0x23, 4, 100, 0x08);
981 TWL4030_ADJUSTABLE_LDO(VAUX4, 0x23, 4, 100, 0x08), 1055TWL4030_ADJUSTABLE_LDO(VMMC1, 0x27, 5, 100, 0x08);
982 TWL4030_ADJUSTABLE_LDO(VMMC1, 0x27, 5, 100, 0x08), 1056TWL4030_ADJUSTABLE_LDO(VMMC2, 0x2b, 6, 100, 0x08);
983 TWL4030_ADJUSTABLE_LDO(VMMC2, 0x2b, 6, 100, 0x08), 1057TWL4030_ADJUSTABLE_LDO(VPLL1, 0x2f, 7, 100, 0x00);
984 TWL4030_ADJUSTABLE_LDO(VPLL1, 0x2f, 7, 100, 0x00), 1058TWL4030_ADJUSTABLE_LDO(VPLL2, 0x33, 8, 100, 0x08);
985 TWL4030_ADJUSTABLE_LDO(VPLL2, 0x33, 8, 100, 0x08), 1059TWL4030_ADJUSTABLE_LDO(VSIM, 0x37, 9, 100, 0x00);
986 TWL4030_ADJUSTABLE_LDO(VSIM, 0x37, 9, 100, 0x00), 1060TWL4030_ADJUSTABLE_LDO(VDAC, 0x3b, 10, 100, 0x08);
987 TWL4030_ADJUSTABLE_LDO(VDAC, 0x3b, 10, 100, 0x08), 1061TWL4030_ADJUSTABLE_LDO(VINTANA2, 0x43, 12, 100, 0x08);
988 TWL4030_FIXED_LDO(VINTANA1, 0x3f, 1500, 11, 100, 0x08), 1062TWL4030_ADJUSTABLE_LDO(VIO, 0x4b, 14, 1000, 0x08);
989 TWL4030_ADJUSTABLE_LDO(VINTANA2, 0x43, 12, 100, 0x08), 1063TWL4030_ADJUSTABLE_SMPS(VDD1, 0x55, 15, 1000, 0x08);
990 TWL4030_FIXED_LDO(VINTDIG, 0x47, 1500, 13, 100, 0x08), 1064TWL4030_ADJUSTABLE_SMPS(VDD2, 0x63, 16, 1000, 0x08);
991 TWL4030_ADJUSTABLE_LDO(VIO, 0x4b, 14, 1000, 0x08), 1065/* VUSBCP is managed *only* by the USB subchip */
992 TWL4030_ADJUSTABLE_SMPS(VDD1, 0x55, 15, 1000, 0x08), 1066/* 6030 REG with base as PMC Slave Misc : 0x0030 */
993 TWL4030_ADJUSTABLE_SMPS(VDD2, 0x63, 16, 1000, 0x08), 1067/* Turnon-delay and remap configuration values for 6030 are not
994 TWL4030_FIXED_LDO(VUSB1V5, 0x71, 1500, 17, 100, 0x08), 1068 verified since the specification is not public */
995 TWL4030_FIXED_LDO(VUSB1V8, 0x74, 1800, 18, 100, 0x08), 1069TWL6030_ADJUSTABLE_SMPS(VDD1);
996 TWL4030_FIXED_LDO(VUSB3V1, 0x77, 3100, 19, 150, 0x08), 1070TWL6030_ADJUSTABLE_SMPS(VDD2);
997 /* VUSBCP is managed *only* by the USB subchip */ 1071TWL6030_ADJUSTABLE_SMPS(VDD3);
998 1072TWL6030_ADJUSTABLE_LDO(VAUX1_6030, 0x54, 1000, 3300);
999 /* 6030 REG with base as PMC Slave Misc : 0x0030 */ 1073TWL6030_ADJUSTABLE_LDO(VAUX2_6030, 0x58, 1000, 3300);
1000 /* Turnon-delay and remap configuration values for 6030 are not 1074TWL6030_ADJUSTABLE_LDO(VAUX3_6030, 0x5c, 1000, 3300);
1001 verified since the specification is not public */ 1075TWL6030_ADJUSTABLE_LDO(VMMC, 0x68, 1000, 3300);
1002 TWL6030_ADJUSTABLE_LDO(VAUX1_6030, 0x54, 1000, 3300), 1076TWL6030_ADJUSTABLE_LDO(VPP, 0x6c, 1000, 3300);
1003 TWL6030_ADJUSTABLE_LDO(VAUX2_6030, 0x58, 1000, 3300), 1077TWL6030_ADJUSTABLE_LDO(VUSIM, 0x74, 1000, 3300);
1004 TWL6030_ADJUSTABLE_LDO(VAUX3_6030, 0x5c, 1000, 3300), 1078/* 6025 are renamed compared to 6030 versions */
1005 TWL6030_ADJUSTABLE_LDO(VMMC, 0x68, 1000, 3300), 1079TWL6025_ADJUSTABLE_LDO(LDO2, 0x54, 1000, 3300);
1006 TWL6030_ADJUSTABLE_LDO(VPP, 0x6c, 1000, 3300), 1080TWL6025_ADJUSTABLE_LDO(LDO4, 0x58, 1000, 3300);
1007 TWL6030_ADJUSTABLE_LDO(VUSIM, 0x74, 1000, 3300), 1081TWL6025_ADJUSTABLE_LDO(LDO3, 0x5c, 1000, 3300);
1008 TWL6030_FIXED_LDO(VANA, 0x50, 2100, 0), 1082TWL6025_ADJUSTABLE_LDO(LDO5, 0x68, 1000, 3300);
1009 TWL6030_FIXED_LDO(VCXIO, 0x60, 1800, 0), 1083TWL6025_ADJUSTABLE_LDO(LDO1, 0x6c, 1000, 3300);
1010 TWL6030_FIXED_LDO(VDAC, 0x64, 1800, 0), 1084TWL6025_ADJUSTABLE_LDO(LDO7, 0x74, 1000, 3300);
1011 TWL6030_FIXED_LDO(VUSB, 0x70, 3300, 0), 1085TWL6025_ADJUSTABLE_LDO(LDO6, 0x60, 1000, 3300);
1012 TWL6030_FIXED_RESOURCE(CLK32KG, 0x8C, 0), 1086TWL6025_ADJUSTABLE_LDO(LDOLN, 0x64, 1000, 3300);
1013 1087TWL6025_ADJUSTABLE_LDO(LDOUSB, 0x70, 1000, 3300);
1014 /* 6025 are renamed compared to 6030 versions */ 1088TWL4030_FIXED_LDO(VINTANA2, 0x3f, 1500, 11, 100, 0x08);
1015 TWL6025_ADJUSTABLE_LDO(LDO2, 0x54, 1000, 3300), 1089TWL4030_FIXED_LDO(VINTDIG, 0x47, 1500, 13, 100, 0x08);
1016 TWL6025_ADJUSTABLE_LDO(LDO4, 0x58, 1000, 3300), 1090TWL4030_FIXED_LDO(VUSB1V5, 0x71, 1500, 17, 100, 0x08);
1017 TWL6025_ADJUSTABLE_LDO(LDO3, 0x5c, 1000, 3300), 1091TWL4030_FIXED_LDO(VUSB1V8, 0x74, 1800, 18, 100, 0x08);
1018 TWL6025_ADJUSTABLE_LDO(LDO5, 0x68, 1000, 3300), 1092TWL4030_FIXED_LDO(VUSB3V1, 0x77, 3100, 19, 150, 0x08);
1019 TWL6025_ADJUSTABLE_LDO(LDO1, 0x6c, 1000, 3300), 1093TWL6030_FIXED_LDO(VANA, 0x50, 2100, 0);
1020 TWL6025_ADJUSTABLE_LDO(LDO7, 0x74, 1000, 3300), 1094TWL6030_FIXED_LDO(VCXIO, 0x60, 1800, 0);
1021 TWL6025_ADJUSTABLE_LDO(LDO6, 0x60, 1000, 3300), 1095TWL6030_FIXED_LDO(VDAC, 0x64, 1800, 0);
1022 TWL6025_ADJUSTABLE_LDO(LDOLN, 0x64, 1000, 3300), 1096TWL6030_FIXED_LDO(VUSB, 0x70, 3300, 0);
1023 TWL6025_ADJUSTABLE_LDO(LDOUSB, 0x70, 1000, 3300), 1097TWL6030_FIXED_LDO(V1V8, 0x16, 1800, 0);
1024 1098TWL6030_FIXED_LDO(V2V1, 0x1c, 2100, 0);
1025 TWL6025_ADJUSTABLE_SMPS(SMPS3, 0x34), 1099TWL6030_FIXED_RESOURCE(CLK32KG, 0x8C, 0);
1026 TWL6025_ADJUSTABLE_SMPS(SMPS4, 0x10), 1100TWL6025_ADJUSTABLE_SMPS(SMPS3, 0x34);
1027 TWL6025_ADJUSTABLE_SMPS(VIO, 0x16), 1101TWL6025_ADJUSTABLE_SMPS(SMPS4, 0x10);
1028}; 1102TWL6025_ADJUSTABLE_SMPS(VIO, 0x16);
1029 1103
1030static u8 twl_get_smps_offset(void) 1104static u8 twl_get_smps_offset(void)
1031{ 1105{
@@ -1045,29 +1119,116 @@ static u8 twl_get_smps_mult(void)
1045 return value; 1119 return value;
1046} 1120}
1047 1121
1122#define TWL_OF_MATCH(comp, family, label) \
1123 { \
1124 .compatible = comp, \
1125 .data = &family##_INFO_##label, \
1126 }
1127
1128#define TWL4030_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWL4030, label)
1129#define TWL6030_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWL6030, label)
1130#define TWL6025_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWL6025, label)
1131#define TWLFIXED_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWLFIXED, label)
1132#define TWLRES_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWLRES, label)
1133#define TWLSMPS_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWLSMPS, label)
1134
1135static const struct of_device_id twl_of_match[] __devinitconst = {
1136 TWL4030_OF_MATCH("ti,twl4030-vaux1", VAUX1),
1137 TWL4030_OF_MATCH("ti,twl4030-vaux2", VAUX2_4030),
1138 TWL4030_OF_MATCH("ti,twl5030-vaux2", VAUX2),
1139 TWL4030_OF_MATCH("ti,twl4030-vaux3", VAUX3),
1140 TWL4030_OF_MATCH("ti,twl4030-vaux4", VAUX4),
1141 TWL4030_OF_MATCH("ti,twl4030-vmmc1", VMMC1),
1142 TWL4030_OF_MATCH("ti,twl4030-vmmc2", VMMC2),
1143 TWL4030_OF_MATCH("ti,twl4030-vpll1", VPLL1),
1144 TWL4030_OF_MATCH("ti,twl4030-vpll2", VPLL2),
1145 TWL4030_OF_MATCH("ti,twl4030-vsim", VSIM),
1146 TWL4030_OF_MATCH("ti,twl4030-vdac", VDAC),
1147 TWL4030_OF_MATCH("ti,twl4030-vintana2", VINTANA2),
1148 TWL4030_OF_MATCH("ti,twl4030-vio", VIO),
1149 TWL4030_OF_MATCH("ti,twl4030-vdd1", VDD1),
1150 TWL4030_OF_MATCH("ti,twl4030-vdd2", VDD2),
1151 TWL6030_OF_MATCH("ti,twl6030-vdd1", VDD1),
1152 TWL6030_OF_MATCH("ti,twl6030-vdd2", VDD2),
1153 TWL6030_OF_MATCH("ti,twl6030-vdd3", VDD3),
1154 TWL6030_OF_MATCH("ti,twl6030-vaux1", VAUX1_6030),
1155 TWL6030_OF_MATCH("ti,twl6030-vaux2", VAUX2_6030),
1156 TWL6030_OF_MATCH("ti,twl6030-vaux3", VAUX3_6030),
1157 TWL6030_OF_MATCH("ti,twl6030-vmmc", VMMC),
1158 TWL6030_OF_MATCH("ti,twl6030-vpp", VPP),
1159 TWL6030_OF_MATCH("ti,twl6030-vusim", VUSIM),
1160 TWL6025_OF_MATCH("ti,twl6025-ldo2", LDO2),
1161 TWL6025_OF_MATCH("ti,twl6025-ldo4", LDO4),
1162 TWL6025_OF_MATCH("ti,twl6025-ldo3", LDO3),
1163 TWL6025_OF_MATCH("ti,twl6025-ldo5", LDO5),
1164 TWL6025_OF_MATCH("ti,twl6025-ldo1", LDO1),
1165 TWL6025_OF_MATCH("ti,twl6025-ldo7", LDO7),
1166 TWL6025_OF_MATCH("ti,twl6025-ldo6", LDO6),
1167 TWL6025_OF_MATCH("ti,twl6025-ldoln", LDOLN),
1168 TWL6025_OF_MATCH("ti,twl6025-ldousb", LDOUSB),
1169 TWLFIXED_OF_MATCH("ti,twl4030-vintana2", VINTANA2),
1170 TWLFIXED_OF_MATCH("ti,twl4030-vintdig", VINTDIG),
1171 TWLFIXED_OF_MATCH("ti,twl4030-vusb1v5", VUSB1V5),
1172 TWLFIXED_OF_MATCH("ti,twl4030-vusb1v8", VUSB1V8),
1173 TWLFIXED_OF_MATCH("ti,twl4030-vusb3v1", VUSB3V1),
1174 TWLFIXED_OF_MATCH("ti,twl6030-vana", VANA),
1175 TWLFIXED_OF_MATCH("ti,twl6030-vcxio", VCXIO),
1176 TWLFIXED_OF_MATCH("ti,twl6030-vdac", VDAC),
1177 TWLFIXED_OF_MATCH("ti,twl6030-vusb", VUSB),
1178 TWLFIXED_OF_MATCH("ti,twl6030-v1v8", V1V8),
1179 TWLFIXED_OF_MATCH("ti,twl6030-v2v1", V2V1),
1180 TWLRES_OF_MATCH("ti,twl6030-clk32kg", CLK32KG),
1181 TWLSMPS_OF_MATCH("ti,twl6025-smps3", SMPS3),
1182 TWLSMPS_OF_MATCH("ti,twl6025-smps4", SMPS4),
1183 TWLSMPS_OF_MATCH("ti,twl6025-vio", VIO),
1184 {},
1185};
1186MODULE_DEVICE_TABLE(of, twl_of_match);
1187
1048static int __devinit twlreg_probe(struct platform_device *pdev) 1188static int __devinit twlreg_probe(struct platform_device *pdev)
1049{ 1189{
1050 int i; 1190 int i, id;
1051 struct twlreg_info *info; 1191 struct twlreg_info *info;
1052 struct regulator_init_data *initdata; 1192 struct regulator_init_data *initdata;
1053 struct regulation_constraints *c; 1193 struct regulation_constraints *c;
1054 struct regulator_dev *rdev; 1194 struct regulator_dev *rdev;
1055 1195 struct twl_regulator_driver_data *drvdata;
1056 for (i = 0, info = NULL; i < ARRAY_SIZE(twl_regs); i++) { 1196 const struct of_device_id *match;
1057 if (twl_regs[i].desc.id != pdev->id) 1197
1058 continue; 1198 match = of_match_device(twl_of_match, &pdev->dev);
1059 info = twl_regs + i; 1199 if (match) {
1060 break; 1200 info = match->data;
1201 id = info->desc.id;
1202 initdata = of_get_regulator_init_data(&pdev->dev,
1203 pdev->dev.of_node);
1204 drvdata = NULL;
1205 } else {
1206 id = pdev->id;
1207 initdata = pdev->dev.platform_data;
1208 for (i = 0, info = NULL; i < ARRAY_SIZE(twl_of_match); i++) {
1209 info = twl_of_match[i].data;
1210 if (!info || info->desc.id != id)
1211 continue;
1212 break;
1213 }
1214 drvdata = initdata->driver_data;
1215 if (!drvdata)
1216 return -EINVAL;
1061 } 1217 }
1218
1062 if (!info) 1219 if (!info)
1063 return -ENODEV; 1220 return -ENODEV;
1064 1221
1065 initdata = pdev->dev.platform_data;
1066 if (!initdata) 1222 if (!initdata)
1067 return -EINVAL; 1223 return -EINVAL;
1068 1224
1069 /* copy the features into regulator data */ 1225 if (drvdata) {
1070 info->features = (unsigned long)initdata->driver_data; 1226 /* copy the driver data into regulator data */
1227 info->features = drvdata->features;
1228 info->data = drvdata->data;
1229 info->set_voltage = drvdata->set_voltage;
1230 info->get_voltage = drvdata->get_voltage;
1231 }
1071 1232
1072 /* Constrain board-specific capabilities according to what 1233 /* Constrain board-specific capabilities according to what
1073 * this driver and the chip itself can actually do. 1234 * this driver and the chip itself can actually do.
@@ -1077,7 +1238,7 @@ static int __devinit twlreg_probe(struct platform_device *pdev)
1077 c->valid_ops_mask &= REGULATOR_CHANGE_VOLTAGE 1238 c->valid_ops_mask &= REGULATOR_CHANGE_VOLTAGE
1078 | REGULATOR_CHANGE_MODE 1239 | REGULATOR_CHANGE_MODE
1079 | REGULATOR_CHANGE_STATUS; 1240 | REGULATOR_CHANGE_STATUS;
1080 switch (pdev->id) { 1241 switch (id) {
1081 case TWL4030_REG_VIO: 1242 case TWL4030_REG_VIO:
1082 case TWL4030_REG_VDD1: 1243 case TWL4030_REG_VDD1:
1083 case TWL4030_REG_VDD2: 1244 case TWL4030_REG_VDD2:
@@ -1091,7 +1252,7 @@ static int __devinit twlreg_probe(struct platform_device *pdev)
1091 break; 1252 break;
1092 } 1253 }
1093 1254
1094 switch (pdev->id) { 1255 switch (id) {
1095 case TWL6025_REG_SMPS3: 1256 case TWL6025_REG_SMPS3:
1096 if (twl_get_smps_mult() & SMPS_MULTOFFSET_SMPS3) 1257 if (twl_get_smps_mult() & SMPS_MULTOFFSET_SMPS3)
1097 info->flags |= SMPS_EXTENDED_EN; 1258 info->flags |= SMPS_EXTENDED_EN;
@@ -1112,7 +1273,8 @@ static int __devinit twlreg_probe(struct platform_device *pdev)
1112 break; 1273 break;
1113 } 1274 }
1114 1275
1115 rdev = regulator_register(&info->desc, &pdev->dev, initdata, info, NULL); 1276 rdev = regulator_register(&info->desc, &pdev->dev, initdata, info,
1277 pdev->dev.of_node);
1116 if (IS_ERR(rdev)) { 1278 if (IS_ERR(rdev)) {
1117 dev_err(&pdev->dev, "can't register %s, %ld\n", 1279 dev_err(&pdev->dev, "can't register %s, %ld\n",
1118 info->desc.name, PTR_ERR(rdev)); 1280 info->desc.name, PTR_ERR(rdev));
@@ -1149,8 +1311,11 @@ static struct platform_driver twlreg_driver = {
1149 /* NOTE: short name, to work around driver model truncation of 1311 /* NOTE: short name, to work around driver model truncation of
1150 * "twl_regulator.12" (and friends) to "twl_regulator.1". 1312 * "twl_regulator.12" (and friends) to "twl_regulator.1".
1151 */ 1313 */
1152 .driver.name = "twl_reg", 1314 .driver = {
1153 .driver.owner = THIS_MODULE, 1315 .name = "twl_reg",
1316 .owner = THIS_MODULE,
1317 .of_match_table = of_match_ptr(twl_of_match),
1318 },
1154}; 1319};
1155 1320
1156static int __init twlreg_init(void) 1321static int __init twlreg_init(void)
diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h
index 78d3465251d6..7fcab23c59ce 100644
--- a/include/linux/i2c/twl.h
+++ b/include/linux/i2c/twl.h
@@ -712,6 +712,9 @@ struct twl4030_platform_data {
712 struct regulator_init_data *vaux1; 712 struct regulator_init_data *vaux1;
713 struct regulator_init_data *vaux2; 713 struct regulator_init_data *vaux2;
714 struct regulator_init_data *vaux3; 714 struct regulator_init_data *vaux3;
715 struct regulator_init_data *vdd1;
716 struct regulator_init_data *vdd2;
717 struct regulator_init_data *vdd3;
715 /* TWL4030 LDO regulators */ 718 /* TWL4030 LDO regulators */
716 struct regulator_init_data *vpll1; 719 struct regulator_init_data *vpll1;
717 struct regulator_init_data *vpll2; 720 struct regulator_init_data *vpll2;
@@ -720,8 +723,6 @@ struct twl4030_platform_data {
720 struct regulator_init_data *vsim; 723 struct regulator_init_data *vsim;
721 struct regulator_init_data *vaux4; 724 struct regulator_init_data *vaux4;
722 struct regulator_init_data *vio; 725 struct regulator_init_data *vio;
723 struct regulator_init_data *vdd1;
724 struct regulator_init_data *vdd2;
725 struct regulator_init_data *vintana1; 726 struct regulator_init_data *vintana1;
726 struct regulator_init_data *vintana2; 727 struct regulator_init_data *vintana2;
727 struct regulator_init_data *vintdig; 728 struct regulator_init_data *vintdig;
@@ -733,6 +734,8 @@ struct twl4030_platform_data {
733 struct regulator_init_data *vcxio; 734 struct regulator_init_data *vcxio;
734 struct regulator_init_data *vusb; 735 struct regulator_init_data *vusb;
735 struct regulator_init_data *clk32kg; 736 struct regulator_init_data *clk32kg;
737 struct regulator_init_data *v1v8;
738 struct regulator_init_data *v2v1;
736 /* TWL6025 LDO regulators */ 739 /* TWL6025 LDO regulators */
737 struct regulator_init_data *ldo1; 740 struct regulator_init_data *ldo1;
738 struct regulator_init_data *ldo2; 741 struct regulator_init_data *ldo2;
@@ -749,6 +752,13 @@ struct twl4030_platform_data {
749 struct regulator_init_data *vio6025; 752 struct regulator_init_data *vio6025;
750}; 753};
751 754
755struct twl_regulator_driver_data {
756 int (*set_voltage)(void *data, int target_uV);
757 int (*get_voltage)(void *data);
758 void *data;
759 unsigned long features;
760};
761
752/*----------------------------------------------------------------------*/ 762/*----------------------------------------------------------------------*/
753 763
754int twl4030_sih_setup(int module); 764int twl4030_sih_setup(int module);