aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorRajendra Nayak <rnayak@ti.com>2012-02-28 04:39:11 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-03-11 16:09:08 -0400
commit2098e95ce9bb039ff2e7bf836df358d18a176139 (patch)
treeed2c162f5b37325071fcc39778a60ce3fe9daed1 /drivers/regulator
parent34a38440689b06a515104d668494e0ff8a4e1537 (diff)
regulator: twl: adapt twl-regulator driver to dt
Modify the twl regulator driver to extract the regulator_init_data from device tree when passed, instead of getting it through platform_data structures (on non-DT builds) Also add documentation for TWL regulator specific bindings. Signed-off-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.c259
1 files changed, 172 insertions, 87 deletions
diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c
index 8611282f1d20..2a1321135178 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
@@ -920,7 +923,8 @@ static struct regulator_ops twlsmps_ops = {
920 TWL_FIXED_LDO(label, offset, mVolts, 0x0, turnon_delay, \ 923 TWL_FIXED_LDO(label, offset, mVolts, 0x0, turnon_delay, \
921 0x0, TWL6030, twl6030fixed_ops) 924 0x0, TWL6030, twl6030fixed_ops)
922 925
923#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 = { \
924 .base = offset, \ 928 .base = offset, \
925 .id = num, \ 929 .id = num, \
926 .table_len = ARRAY_SIZE(label##_VSEL_table), \ 930 .table_len = ARRAY_SIZE(label##_VSEL_table), \
@@ -938,7 +942,7 @@ static struct regulator_ops twlsmps_ops = {
938 } 942 }
939 943
940#define TWL4030_ADJUSTABLE_SMPS(label, offset, num, turnon_delay, remap_conf) \ 944#define TWL4030_ADJUSTABLE_SMPS(label, offset, num, turnon_delay, remap_conf) \
941 { \ 945static struct twlreg_info TWL4030_INFO_##label = { \
942 .base = offset, \ 946 .base = offset, \
943 .id = num, \ 947 .id = num, \
944 .delay = turnon_delay, \ 948 .delay = turnon_delay, \
@@ -952,7 +956,8 @@ static struct regulator_ops twlsmps_ops = {
952 }, \ 956 }, \
953 } 957 }
954 958
955#define TWL6030_ADJUSTABLE_SMPS(label) { \ 959#define TWL6030_ADJUSTABLE_SMPS(label) \
960static struct twlreg_info TWL6030_INFO_##label = { \
956 .desc = { \ 961 .desc = { \
957 .name = #label, \ 962 .name = #label, \
958 .id = TWL6030_REG_##label, \ 963 .id = TWL6030_REG_##label, \
@@ -962,7 +967,8 @@ static struct regulator_ops twlsmps_ops = {
962 }, \ 967 }, \
963 } 968 }
964 969
965#define TWL6030_ADJUSTABLE_LDO(label, offset, min_mVolts, max_mVolts) { \ 970#define TWL6030_ADJUSTABLE_LDO(label, offset, min_mVolts, max_mVolts) \
971static struct twlreg_info TWL6030_INFO_##label = { \
966 .base = offset, \ 972 .base = offset, \
967 .min_mV = min_mVolts, \ 973 .min_mV = min_mVolts, \
968 .max_mV = max_mVolts, \ 974 .max_mV = max_mVolts, \
@@ -976,7 +982,8 @@ static struct regulator_ops twlsmps_ops = {
976 }, \ 982 }, \
977 } 983 }
978 984
979#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 = { \
980 .base = offset, \ 987 .base = offset, \
981 .min_mV = min_mVolts, \ 988 .min_mV = min_mVolts, \
982 .max_mV = max_mVolts, \ 989 .max_mV = max_mVolts, \
@@ -991,7 +998,8 @@ static struct regulator_ops twlsmps_ops = {
991 } 998 }
992 999
993#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, \
994 family, operations) { \ 1001 family, operations) \
1002static struct twlreg_info TWLFIXED_INFO_##label = { \
995 .base = offset, \ 1003 .base = offset, \
996 .id = num, \ 1004 .id = num, \
997 .min_mV = mVolts, \ 1005 .min_mV = mVolts, \
@@ -1007,7 +1015,8 @@ static struct regulator_ops twlsmps_ops = {
1007 }, \ 1015 }, \
1008 } 1016 }
1009 1017
1010#define TWL6030_FIXED_RESOURCE(label, offset, turnon_delay) { \ 1018#define TWL6030_FIXED_RESOURCE(label, offset, turnon_delay) \
1019static struct twlreg_info TWLRES_INFO_##label = { \
1011 .base = offset, \ 1020 .base = offset, \
1012 .delay = turnon_delay, \ 1021 .delay = turnon_delay, \
1013 .desc = { \ 1022 .desc = { \
@@ -1019,7 +1028,8 @@ static struct regulator_ops twlsmps_ops = {
1019 }, \ 1028 }, \
1020 } 1029 }
1021 1030
1022#define TWL6025_ADJUSTABLE_SMPS(label, offset) { \ 1031#define TWL6025_ADJUSTABLE_SMPS(label, offset) \
1032static struct twlreg_info TWLSMPS_INFO_##label = { \
1023 .base = offset, \ 1033 .base = offset, \
1024 .min_mV = 600, \ 1034 .min_mV = 600, \
1025 .max_mV = 2100, \ 1035 .max_mV = 2100, \
@@ -1037,62 +1047,57 @@ static struct regulator_ops twlsmps_ops = {
1037 * We list regulators here if systems need some level of 1047 * We list regulators here if systems need some level of
1038 * software control over them after boot. 1048 * software control over them after boot.
1039 */ 1049 */
1040static struct twlreg_info twl_regs[] = { 1050TWL4030_ADJUSTABLE_LDO(VAUX1, 0x17, 1, 100, 0x08);
1041 TWL4030_ADJUSTABLE_LDO(VAUX1, 0x17, 1, 100, 0x08), 1051TWL4030_ADJUSTABLE_LDO(VAUX2_4030, 0x1b, 2, 100, 0x08);
1042 TWL4030_ADJUSTABLE_LDO(VAUX2_4030, 0x1b, 2, 100, 0x08), 1052TWL4030_ADJUSTABLE_LDO(VAUX2, 0x1b, 2, 100, 0x08);
1043 TWL4030_ADJUSTABLE_LDO(VAUX2, 0x1b, 2, 100, 0x08), 1053TWL4030_ADJUSTABLE_LDO(VAUX3, 0x1f, 3, 100, 0x08);
1044 TWL4030_ADJUSTABLE_LDO(VAUX3, 0x1f, 3, 100, 0x08), 1054TWL4030_ADJUSTABLE_LDO(VAUX4, 0x23, 4, 100, 0x08);
1045 TWL4030_ADJUSTABLE_LDO(VAUX4, 0x23, 4, 100, 0x08), 1055TWL4030_ADJUSTABLE_LDO(VMMC1, 0x27, 5, 100, 0x08);
1046 TWL4030_ADJUSTABLE_LDO(VMMC1, 0x27, 5, 100, 0x08), 1056TWL4030_ADJUSTABLE_LDO(VMMC2, 0x2b, 6, 100, 0x08);
1047 TWL4030_ADJUSTABLE_LDO(VMMC2, 0x2b, 6, 100, 0x08), 1057TWL4030_ADJUSTABLE_LDO(VPLL1, 0x2f, 7, 100, 0x00);
1048 TWL4030_ADJUSTABLE_LDO(VPLL1, 0x2f, 7, 100, 0x00), 1058TWL4030_ADJUSTABLE_LDO(VPLL2, 0x33, 8, 100, 0x08);
1049 TWL4030_ADJUSTABLE_LDO(VPLL2, 0x33, 8, 100, 0x08), 1059TWL4030_ADJUSTABLE_LDO(VSIM, 0x37, 9, 100, 0x00);
1050 TWL4030_ADJUSTABLE_LDO(VSIM, 0x37, 9, 100, 0x00), 1060TWL4030_ADJUSTABLE_LDO(VDAC, 0x3b, 10, 100, 0x08);
1051 TWL4030_ADJUSTABLE_LDO(VDAC, 0x3b, 10, 100, 0x08), 1061TWL4030_ADJUSTABLE_LDO(VINTANA2, 0x43, 12, 100, 0x08);
1052 TWL4030_FIXED_LDO(VINTANA1, 0x3f, 1500, 11, 100, 0x08), 1062TWL4030_ADJUSTABLE_LDO(VIO, 0x4b, 14, 1000, 0x08);
1053 TWL4030_ADJUSTABLE_LDO(VINTANA2, 0x43, 12, 100, 0x08), 1063TWL4030_ADJUSTABLE_SMPS(VDD1, 0x55, 15, 1000, 0x08);
1054 TWL4030_FIXED_LDO(VINTDIG, 0x47, 1500, 13, 100, 0x08), 1064TWL4030_ADJUSTABLE_SMPS(VDD2, 0x63, 16, 1000, 0x08);
1055 TWL4030_ADJUSTABLE_LDO(VIO, 0x4b, 14, 1000, 0x08), 1065/* VUSBCP is managed *only* by the USB subchip */
1056 TWL4030_ADJUSTABLE_SMPS(VDD1, 0x55, 15, 1000, 0x08), 1066/* 6030 REG with base as PMC Slave Misc : 0x0030 */
1057 TWL4030_ADJUSTABLE_SMPS(VDD2, 0x63, 16, 1000, 0x08), 1067/* Turnon-delay and remap configuration values for 6030 are not
1058 TWL4030_FIXED_LDO(VUSB1V5, 0x71, 1500, 17, 100, 0x08), 1068 verified since the specification is not public */
1059 TWL4030_FIXED_LDO(VUSB1V8, 0x74, 1800, 18, 100, 0x08), 1069TWL6030_ADJUSTABLE_SMPS(VDD1);
1060 TWL4030_FIXED_LDO(VUSB3V1, 0x77, 3100, 19, 150, 0x08), 1070TWL6030_ADJUSTABLE_SMPS(VDD2);
1061 /* VUSBCP is managed *only* by the USB subchip */ 1071TWL6030_ADJUSTABLE_SMPS(VDD3);
1062 1072TWL6030_ADJUSTABLE_LDO(VAUX1_6030, 0x54, 1000, 3300);
1063 /* 6030 REG with base as PMC Slave Misc : 0x0030 */ 1073TWL6030_ADJUSTABLE_LDO(VAUX2_6030, 0x58, 1000, 3300);
1064 /* Turnon-delay and remap configuration values for 6030 are not 1074TWL6030_ADJUSTABLE_LDO(VAUX3_6030, 0x5c, 1000, 3300);
1065 verified since the specification is not public */ 1075TWL6030_ADJUSTABLE_LDO(VMMC, 0x68, 1000, 3300);
1066 TWL6030_ADJUSTABLE_SMPS(VDD1), 1076TWL6030_ADJUSTABLE_LDO(VPP, 0x6c, 1000, 3300);
1067 TWL6030_ADJUSTABLE_SMPS(VDD2), 1077TWL6030_ADJUSTABLE_LDO(VUSIM, 0x74, 1000, 3300);
1068 TWL6030_ADJUSTABLE_SMPS(VDD3), 1078/* 6025 are renamed compared to 6030 versions */
1069 TWL6030_ADJUSTABLE_LDO(VAUX1_6030, 0x54, 1000, 3300), 1079TWL6025_ADJUSTABLE_LDO(LDO2, 0x54, 1000, 3300);
1070 TWL6030_ADJUSTABLE_LDO(VAUX2_6030, 0x58, 1000, 3300), 1080TWL6025_ADJUSTABLE_LDO(LDO4, 0x58, 1000, 3300);
1071 TWL6030_ADJUSTABLE_LDO(VAUX3_6030, 0x5c, 1000, 3300), 1081TWL6025_ADJUSTABLE_LDO(LDO3, 0x5c, 1000, 3300);
1072 TWL6030_ADJUSTABLE_LDO(VMMC, 0x68, 1000, 3300), 1082TWL6025_ADJUSTABLE_LDO(LDO5, 0x68, 1000, 3300);
1073 TWL6030_ADJUSTABLE_LDO(VPP, 0x6c, 1000, 3300), 1083TWL6025_ADJUSTABLE_LDO(LDO1, 0x6c, 1000, 3300);
1074 TWL6030_ADJUSTABLE_LDO(VUSIM, 0x74, 1000, 3300), 1084TWL6025_ADJUSTABLE_LDO(LDO7, 0x74, 1000, 3300);
1075 TWL6030_FIXED_LDO(VANA, 0x50, 2100, 0), 1085TWL6025_ADJUSTABLE_LDO(LDO6, 0x60, 1000, 3300);
1076 TWL6030_FIXED_LDO(VCXIO, 0x60, 1800, 0), 1086TWL6025_ADJUSTABLE_LDO(LDOLN, 0x64, 1000, 3300);
1077 TWL6030_FIXED_LDO(VDAC, 0x64, 1800, 0), 1087TWL6025_ADJUSTABLE_LDO(LDOUSB, 0x70, 1000, 3300);
1078 TWL6030_FIXED_LDO(VUSB, 0x70, 3300, 0), 1088TWL4030_FIXED_LDO(VINTANA2, 0x3f, 1500, 11, 100, 0x08);
1079 TWL6030_FIXED_RESOURCE(CLK32KG, 0x8C, 0), 1089TWL4030_FIXED_LDO(VINTDIG, 0x47, 1500, 13, 100, 0x08);
1080 1090TWL4030_FIXED_LDO(VUSB1V5, 0x71, 1500, 17, 100, 0x08);
1081 /* 6025 are renamed compared to 6030 versions */ 1091TWL4030_FIXED_LDO(VUSB1V8, 0x74, 1800, 18, 100, 0x08);
1082 TWL6025_ADJUSTABLE_LDO(LDO2, 0x54, 1000, 3300), 1092TWL4030_FIXED_LDO(VUSB3V1, 0x77, 3100, 19, 150, 0x08);
1083 TWL6025_ADJUSTABLE_LDO(LDO4, 0x58, 1000, 3300), 1093TWL6030_FIXED_LDO(VANA, 0x50, 2100, 0);
1084 TWL6025_ADJUSTABLE_LDO(LDO3, 0x5c, 1000, 3300), 1094TWL6030_FIXED_LDO(VCXIO, 0x60, 1800, 0);
1085 TWL6025_ADJUSTABLE_LDO(LDO5, 0x68, 1000, 3300), 1095TWL6030_FIXED_LDO(VDAC, 0x64, 1800, 0);
1086 TWL6025_ADJUSTABLE_LDO(LDO1, 0x6c, 1000, 3300), 1096TWL6030_FIXED_LDO(VUSB, 0x70, 3300, 0);
1087 TWL6025_ADJUSTABLE_LDO(LDO7, 0x74, 1000, 3300), 1097TWL6030_FIXED_RESOURCE(CLK32KG, 0x8C, 0);
1088 TWL6025_ADJUSTABLE_LDO(LDO6, 0x60, 1000, 3300), 1098TWL6025_ADJUSTABLE_SMPS(SMPS3, 0x34);
1089 TWL6025_ADJUSTABLE_LDO(LDOLN, 0x64, 1000, 3300), 1099TWL6025_ADJUSTABLE_SMPS(SMPS4, 0x10);
1090 TWL6025_ADJUSTABLE_LDO(LDOUSB, 0x70, 1000, 3300), 1100TWL6025_ADJUSTABLE_SMPS(VIO, 0x16);
1091
1092 TWL6025_ADJUSTABLE_SMPS(SMPS3, 0x34),
1093 TWL6025_ADJUSTABLE_SMPS(SMPS4, 0x10),
1094 TWL6025_ADJUSTABLE_SMPS(VIO, 0x16),
1095};
1096 1101
1097static u8 twl_get_smps_offset(void) 1102static u8 twl_get_smps_offset(void)
1098{ 1103{
@@ -1112,38 +1117,114 @@ static u8 twl_get_smps_mult(void)
1112 return value; 1117 return value;
1113} 1118}
1114 1119
1120#define TWL_OF_MATCH(comp, family, label) \
1121 { \
1122 .compatible = comp, \
1123 .data = &family##_INFO_##label, \
1124 }
1125
1126#define TWL4030_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWL4030, label)
1127#define TWL6030_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWL6030, label)
1128#define TWL6025_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWL6025, label)
1129#define TWLFIXED_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWLFIXED, label)
1130#define TWLRES_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWLRES, label)
1131#define TWLSMPS_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWLSMPS, label)
1132
1133static const struct of_device_id twl_of_match[] __devinitconst = {
1134 TWL4030_OF_MATCH("ti,twl4030-vaux1", VAUX1),
1135 TWL4030_OF_MATCH("ti,twl4030-vaux2", VAUX2_4030),
1136 TWL4030_OF_MATCH("ti,twl5030-vaux2", VAUX2),
1137 TWL4030_OF_MATCH("ti,twl4030-vaux3", VAUX3),
1138 TWL4030_OF_MATCH("ti,twl4030-vaux4", VAUX4),
1139 TWL4030_OF_MATCH("ti,twl4030-vmmc1", VMMC1),
1140 TWL4030_OF_MATCH("ti,twl4030-vmmc2", VMMC2),
1141 TWL4030_OF_MATCH("ti,twl4030-vpll1", VPLL1),
1142 TWL4030_OF_MATCH("ti,twl4030-vpll2", VPLL2),
1143 TWL4030_OF_MATCH("ti,twl4030-vsim", VSIM),
1144 TWL4030_OF_MATCH("ti,twl4030-vdac", VDAC),
1145 TWL4030_OF_MATCH("ti,twl4030-vintana2", VINTANA2),
1146 TWL4030_OF_MATCH("ti,twl4030-vio", VIO),
1147 TWL4030_OF_MATCH("ti,twl4030-vdd1", VDD1),
1148 TWL4030_OF_MATCH("ti,twl4030-vdd2", VDD2),
1149 TWL6030_OF_MATCH("ti,twl6030-vdd1", VDD1),
1150 TWL6030_OF_MATCH("ti,twl6030-vdd2", VDD2),
1151 TWL6030_OF_MATCH("ti,twl6030-vdd3", VDD3),
1152 TWL6030_OF_MATCH("ti,twl6030-vaux1", VAUX1_6030),
1153 TWL6030_OF_MATCH("ti,twl6030-vaux2", VAUX2_6030),
1154 TWL6030_OF_MATCH("ti,twl6030-vaux3", VAUX3_6030),
1155 TWL6030_OF_MATCH("ti,twl6030-vmmc", VMMC),
1156 TWL6030_OF_MATCH("ti,twl6030-vpp", VPP),
1157 TWL6030_OF_MATCH("ti,twl6030-vusim", VUSIM),
1158 TWL6025_OF_MATCH("ti,twl6025-ldo2", LDO2),
1159 TWL6025_OF_MATCH("ti,twl6025-ldo4", LDO4),
1160 TWL6025_OF_MATCH("ti,twl6025-ldo3", LDO3),
1161 TWL6025_OF_MATCH("ti,twl6025-ldo5", LDO5),
1162 TWL6025_OF_MATCH("ti,twl6025-ldo1", LDO1),
1163 TWL6025_OF_MATCH("ti,twl6025-ldo7", LDO7),
1164 TWL6025_OF_MATCH("ti,twl6025-ldo6", LDO6),
1165 TWL6025_OF_MATCH("ti,twl6025-ldoln", LDOLN),
1166 TWL6025_OF_MATCH("ti,twl6025-ldousb", LDOUSB),
1167 TWLFIXED_OF_MATCH("ti,twl4030-vintana2", VINTANA2),
1168 TWLFIXED_OF_MATCH("ti,twl4030-vintdig", VINTDIG),
1169 TWLFIXED_OF_MATCH("ti,twl4030-vusb1v5", VUSB1V5),
1170 TWLFIXED_OF_MATCH("ti,twl4030-vusb1v8", VUSB1V8),
1171 TWLFIXED_OF_MATCH("ti,twl4030-vusb3v1", VUSB3V1),
1172 TWLFIXED_OF_MATCH("ti,twl6030-vana", VANA),
1173 TWLFIXED_OF_MATCH("ti,twl6030-vcxio", VCXIO),
1174 TWLFIXED_OF_MATCH("ti,twl6030-vdac", VDAC),
1175 TWLFIXED_OF_MATCH("ti,twl6030-vusb", VUSB),
1176 TWLRES_OF_MATCH("ti,twl6030-clk32kg", CLK32KG),
1177 TWLSMPS_OF_MATCH("ti,twl6025-smps3", SMPS3),
1178 TWLSMPS_OF_MATCH("ti,twl6025-smps4", SMPS4),
1179 TWLSMPS_OF_MATCH("ti,twl6025-vio", VIO),
1180 {},
1181};
1182MODULE_DEVICE_TABLE(of, twl_of_match);
1183
1115static int __devinit twlreg_probe(struct platform_device *pdev) 1184static int __devinit twlreg_probe(struct platform_device *pdev)
1116{ 1185{
1117 int i; 1186 int i, id;
1118 struct twlreg_info *info; 1187 struct twlreg_info *info;
1119 struct regulator_init_data *initdata; 1188 struct regulator_init_data *initdata;
1120 struct regulation_constraints *c; 1189 struct regulation_constraints *c;
1121 struct regulator_dev *rdev; 1190 struct regulator_dev *rdev;
1122 struct twl_regulator_driver_data *drvdata; 1191 struct twl_regulator_driver_data *drvdata;
1123 1192 const struct of_device_id *match;
1124 for (i = 0, info = NULL; i < ARRAY_SIZE(twl_regs); i++) { 1193
1125 if (twl_regs[i].desc.id != pdev->id) 1194 match = of_match_device(twl_of_match, &pdev->dev);
1126 continue; 1195 if (match) {
1127 info = twl_regs + i; 1196 info = match->data;
1128 break; 1197 id = info->desc.id;
1198 initdata = of_get_regulator_init_data(&pdev->dev,
1199 pdev->dev.of_node);
1200 drvdata = NULL;
1201 } else {
1202 id = pdev->id;
1203 initdata = pdev->dev.platform_data;
1204 for (i = 0, info = NULL; i < ARRAY_SIZE(twl_of_match); i++) {
1205 info = twl_of_match[i].data;
1206 if (!info || info->desc.id != id)
1207 continue;
1208 break;
1209 }
1210 drvdata = initdata->driver_data;
1211 if (!drvdata)
1212 return -EINVAL;
1129 } 1213 }
1214
1130 if (!info) 1215 if (!info)
1131 return -ENODEV; 1216 return -ENODEV;
1132 1217
1133 initdata = pdev->dev.platform_data;
1134 if (!initdata) 1218 if (!initdata)
1135 return -EINVAL; 1219 return -EINVAL;
1136 1220
1137 drvdata = initdata->driver_data; 1221 if (drvdata) {
1138 1222 /* copy the driver data into regulator data */
1139 if (!drvdata) 1223 info->features = drvdata->features;
1140 return -EINVAL; 1224 info->data = drvdata->data;
1141 1225 info->set_voltage = drvdata->set_voltage;
1142 /* copy the driver data into regulator data */ 1226 info->get_voltage = drvdata->get_voltage;
1143 info->features = drvdata->features; 1227 }
1144 info->data = drvdata->data;
1145 info->set_voltage = drvdata->set_voltage;
1146 info->get_voltage = drvdata->get_voltage;
1147 1228
1148 /* Constrain board-specific capabilities according to what 1229 /* Constrain board-specific capabilities according to what
1149 * this driver and the chip itself can actually do. 1230 * this driver and the chip itself can actually do.
@@ -1153,7 +1234,7 @@ static int __devinit twlreg_probe(struct platform_device *pdev)
1153 c->valid_ops_mask &= REGULATOR_CHANGE_VOLTAGE 1234 c->valid_ops_mask &= REGULATOR_CHANGE_VOLTAGE
1154 | REGULATOR_CHANGE_MODE 1235 | REGULATOR_CHANGE_MODE
1155 | REGULATOR_CHANGE_STATUS; 1236 | REGULATOR_CHANGE_STATUS;
1156 switch (pdev->id) { 1237 switch (id) {
1157 case TWL4030_REG_VIO: 1238 case TWL4030_REG_VIO:
1158 case TWL4030_REG_VDD1: 1239 case TWL4030_REG_VDD1:
1159 case TWL4030_REG_VDD2: 1240 case TWL4030_REG_VDD2:
@@ -1167,7 +1248,7 @@ static int __devinit twlreg_probe(struct platform_device *pdev)
1167 break; 1248 break;
1168 } 1249 }
1169 1250
1170 switch (pdev->id) { 1251 switch (id) {
1171 case TWL6025_REG_SMPS3: 1252 case TWL6025_REG_SMPS3:
1172 if (twl_get_smps_mult() & SMPS_MULTOFFSET_SMPS3) 1253 if (twl_get_smps_mult() & SMPS_MULTOFFSET_SMPS3)
1173 info->flags |= SMPS_EXTENDED_EN; 1254 info->flags |= SMPS_EXTENDED_EN;
@@ -1188,7 +1269,8 @@ static int __devinit twlreg_probe(struct platform_device *pdev)
1188 break; 1269 break;
1189 } 1270 }
1190 1271
1191 rdev = regulator_register(&info->desc, &pdev->dev, initdata, info, NULL); 1272 rdev = regulator_register(&info->desc, &pdev->dev, initdata, info,
1273 pdev->dev.of_node);
1192 if (IS_ERR(rdev)) { 1274 if (IS_ERR(rdev)) {
1193 dev_err(&pdev->dev, "can't register %s, %ld\n", 1275 dev_err(&pdev->dev, "can't register %s, %ld\n",
1194 info->desc.name, PTR_ERR(rdev)); 1276 info->desc.name, PTR_ERR(rdev));
@@ -1225,8 +1307,11 @@ static struct platform_driver twlreg_driver = {
1225 /* NOTE: short name, to work around driver model truncation of 1307 /* NOTE: short name, to work around driver model truncation of
1226 * "twl_regulator.12" (and friends) to "twl_regulator.1". 1308 * "twl_regulator.12" (and friends) to "twl_regulator.1".
1227 */ 1309 */
1228 .driver.name = "twl_reg", 1310 .driver = {
1229 .driver.owner = THIS_MODULE, 1311 .name = "twl_reg",
1312 .owner = THIS_MODULE,
1313 .of_match_table = of_match_ptr(twl_of_match),
1314 },
1230}; 1315};
1231 1316
1232static int __init twlreg_init(void) 1317static int __init twlreg_init(void)