diff options
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/88pm8607.c | 533 | ||||
-rw-r--r-- | drivers/regulator/ab3100.c | 49 | ||||
-rw-r--r-- | drivers/regulator/bq24022.c | 1 | ||||
-rw-r--r-- | drivers/regulator/core.c | 85 | ||||
-rw-r--r-- | drivers/regulator/lp3971.c | 2 | ||||
-rw-r--r-- | drivers/regulator/max1586.c | 1 | ||||
-rw-r--r-- | drivers/regulator/max8649.c | 2 | ||||
-rw-r--r-- | drivers/regulator/max8660.c | 1 | ||||
-rw-r--r-- | drivers/regulator/mc13783-regulator.c | 6 | ||||
-rw-r--r-- | drivers/regulator/tps65023-regulator.c | 3 | ||||
-rw-r--r-- | drivers/regulator/tps6507x-regulator.c | 405 | ||||
-rw-r--r-- | drivers/regulator/twl-regulator.c | 138 | ||||
-rw-r--r-- | drivers/regulator/wm8350-regulator.c | 2 |
13 files changed, 595 insertions, 633 deletions
diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c index 5fb83e2ced25..7d149a8d8d9b 100644 --- a/drivers/regulator/88pm8607.c +++ b/drivers/regulator/88pm8607.c | |||
@@ -23,9 +23,9 @@ struct pm8607_regulator_info { | |||
23 | struct regulator_dev *regulator; | 23 | struct regulator_dev *regulator; |
24 | struct i2c_client *i2c; | 24 | struct i2c_client *i2c; |
25 | 25 | ||
26 | int min_uV; | 26 | unsigned int *vol_table; |
27 | int max_uV; | 27 | unsigned int *vol_suspend; |
28 | int step_uV; | 28 | |
29 | int vol_reg; | 29 | int vol_reg; |
30 | int vol_shift; | 30 | int vol_shift; |
31 | int vol_nbits; | 31 | int vol_nbits; |
@@ -36,83 +36,189 @@ struct pm8607_regulator_info { | |||
36 | int slope_double; | 36 | int slope_double; |
37 | }; | 37 | }; |
38 | 38 | ||
39 | static inline int check_range(struct pm8607_regulator_info *info, | 39 | static const unsigned int BUCK1_table[] = { |
40 | int min_uV, int max_uV) | 40 | 725000, 750000, 775000, 800000, 825000, 850000, 875000, 900000, |
41 | { | 41 | 925000, 950000, 975000, 1000000, 1025000, 1050000, 1075000, 1100000, |
42 | if (max_uV < info->min_uV || min_uV > info->max_uV || min_uV > max_uV) | 42 | 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, |
43 | return -EINVAL; | 43 | 1325000, 1350000, 1375000, 1400000, 1425000, 1450000, 1475000, 1500000, |
44 | 0, 25000, 50000, 75000, 100000, 125000, 150000, 175000, | ||
45 | 200000, 225000, 250000, 275000, 300000, 325000, 350000, 375000, | ||
46 | 400000, 425000, 450000, 475000, 500000, 525000, 550000, 575000, | ||
47 | 600000, 625000, 650000, 675000, 700000, 725000, 750000, 775000, | ||
48 | }; | ||
44 | 49 | ||
45 | return 0; | 50 | static const unsigned int BUCK1_suspend_table[] = { |
46 | } | 51 | 0, 25000, 50000, 75000, 100000, 125000, 150000, 175000, |
52 | 200000, 225000, 250000, 275000, 300000, 325000, 350000, 375000, | ||
53 | 400000, 425000, 450000, 475000, 500000, 525000, 550000, 575000, | ||
54 | 600000, 625000, 650000, 675000, 700000, 725000, 750000, 775000, | ||
55 | 800000, 825000, 850000, 875000, 900000, 925000, 950000, 975000, | ||
56 | 1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, | ||
57 | 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000, 1375000, | ||
58 | 1400000, 1425000, 1450000, 1475000, 1500000, 1500000, 1500000, 1500000, | ||
59 | }; | ||
60 | |||
61 | static const unsigned int BUCK2_table[] = { | ||
62 | 0, 50000, 100000, 150000, 200000, 250000, 300000, 350000, | ||
63 | 400000, 450000, 500000, 550000, 600000, 650000, 700000, 750000, | ||
64 | 800000, 850000, 900000, 950000, 1000000, 1050000, 1100000, 1150000, | ||
65 | 1200000, 1250000, 1300000, 1350000, 1400000, 1450000, 1500000, 1550000, | ||
66 | 1600000, 1650000, 1700000, 1750000, 1800000, 1850000, 1900000, 1950000, | ||
67 | 2000000, 2050000, 2100000, 2150000, 2200000, 2250000, 2300000, 2350000, | ||
68 | 2400000, 2450000, 2500000, 2550000, 2600000, 2650000, 2700000, 2750000, | ||
69 | 2800000, 2850000, 2900000, 2950000, 3000000, 3000000, 3000000, 3000000, | ||
70 | }; | ||
71 | |||
72 | static const unsigned int BUCK2_suspend_table[] = { | ||
73 | 0, 50000, 100000, 150000, 200000, 250000, 300000, 350000, | ||
74 | 400000, 450000, 500000, 550000, 600000, 650000, 700000, 750000, | ||
75 | 800000, 850000, 900000, 950000, 1000000, 1050000, 1100000, 1150000, | ||
76 | 1200000, 1250000, 1300000, 1350000, 1400000, 1450000, 1500000, 1550000, | ||
77 | 1600000, 1650000, 1700000, 1750000, 1800000, 1850000, 1900000, 1950000, | ||
78 | 2000000, 2050000, 2100000, 2150000, 2200000, 2250000, 2300000, 2350000, | ||
79 | 2400000, 2450000, 2500000, 2550000, 2600000, 2650000, 2700000, 2750000, | ||
80 | 2800000, 2850000, 2900000, 2950000, 3000000, 3000000, 3000000, 3000000, | ||
81 | }; | ||
82 | |||
83 | static const unsigned int BUCK3_table[] = { | ||
84 | 0, 25000, 50000, 75000, 100000, 125000, 150000, 175000, | ||
85 | 200000, 225000, 250000, 275000, 300000, 325000, 350000, 375000, | ||
86 | 400000, 425000, 450000, 475000, 500000, 525000, 550000, 575000, | ||
87 | 600000, 625000, 650000, 675000, 700000, 725000, 750000, 775000, | ||
88 | 800000, 825000, 850000, 875000, 900000, 925000, 950000, 975000, | ||
89 | 1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, | ||
90 | 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000, 1375000, | ||
91 | 1400000, 1425000, 1450000, 1475000, 1500000, 1500000, 1500000, 1500000, | ||
92 | }; | ||
93 | |||
94 | static const unsigned int BUCK3_suspend_table[] = { | ||
95 | 0, 25000, 50000, 75000, 100000, 125000, 150000, 175000, | ||
96 | 200000, 225000, 250000, 275000, 300000, 325000, 350000, 375000, | ||
97 | 400000, 425000, 450000, 475000, 500000, 525000, 550000, 575000, | ||
98 | 600000, 625000, 650000, 675000, 700000, 725000, 750000, 775000, | ||
99 | 800000, 825000, 850000, 875000, 900000, 925000, 950000, 975000, | ||
100 | 1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, | ||
101 | 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000, 1375000, | ||
102 | 1400000, 1425000, 1450000, 1475000, 1500000, 1500000, 1500000, 1500000, | ||
103 | }; | ||
104 | |||
105 | static const unsigned int LDO1_table[] = { | ||
106 | 1800000, 1200000, 2800000, 0, | ||
107 | }; | ||
108 | |||
109 | static const unsigned int LDO1_suspend_table[] = { | ||
110 | 1800000, 1200000, 0, 0, | ||
111 | }; | ||
112 | |||
113 | static const unsigned int LDO2_table[] = { | ||
114 | 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 3300000, | ||
115 | }; | ||
116 | |||
117 | static const unsigned int LDO2_suspend_table[] = { | ||
118 | 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 2900000, | ||
119 | }; | ||
120 | |||
121 | static const unsigned int LDO3_table[] = { | ||
122 | 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 3300000, | ||
123 | }; | ||
124 | |||
125 | static const unsigned int LDO3_suspend_table[] = { | ||
126 | 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 2900000, | ||
127 | }; | ||
128 | |||
129 | static const unsigned int LDO4_table[] = { | ||
130 | 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2900000, 3300000, | ||
131 | }; | ||
132 | |||
133 | static const unsigned int LDO4_suspend_table[] = { | ||
134 | 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2900000, 2900000, | ||
135 | }; | ||
136 | |||
137 | static const unsigned int LDO5_table[] = { | ||
138 | 2900000, 3000000, 3100000, 3300000, | ||
139 | }; | ||
140 | |||
141 | static const unsigned int LDO5_suspend_table[] = { | ||
142 | 2900000, 0, 0, 0, | ||
143 | }; | ||
144 | |||
145 | static const unsigned int LDO6_table[] = { | ||
146 | 1800000, 1850000, 2600000, 2650000, 2700000, 2750000, 2800000, 3300000, | ||
147 | }; | ||
148 | |||
149 | static const unsigned int LDO6_suspend_table[] = { | ||
150 | 1800000, 1850000, 2600000, 2650000, 2700000, 2750000, 2800000, 2900000, | ||
151 | }; | ||
152 | |||
153 | static const unsigned int LDO7_table[] = { | ||
154 | 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 2900000, | ||
155 | }; | ||
156 | |||
157 | static const unsigned int LDO7_suspend_table[] = { | ||
158 | 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 2900000, | ||
159 | }; | ||
160 | |||
161 | static const unsigned int LDO8_table[] = { | ||
162 | 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 2900000, | ||
163 | }; | ||
164 | |||
165 | static const unsigned int LDO8_suspend_table[] = { | ||
166 | 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 2900000, | ||
167 | }; | ||
168 | |||
169 | static const unsigned int LDO9_table[] = { | ||
170 | 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 3300000, | ||
171 | }; | ||
172 | |||
173 | static const unsigned int LDO9_suspend_table[] = { | ||
174 | 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 2900000, | ||
175 | }; | ||
176 | |||
177 | static const unsigned int LDO10_table[] = { | ||
178 | 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 3300000, | ||
179 | 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, | ||
180 | }; | ||
181 | |||
182 | static const unsigned int LDO10_suspend_table[] = { | ||
183 | 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 2900000, | ||
184 | 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, | ||
185 | }; | ||
186 | |||
187 | static const unsigned int LDO12_table[] = { | ||
188 | 1800000, 1900000, 2700000, 2800000, 2900000, 3000000, 3100000, 3300000, | ||
189 | 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, | ||
190 | }; | ||
191 | |||
192 | static const unsigned int LDO12_suspend_table[] = { | ||
193 | 1800000, 1900000, 2700000, 2800000, 2900000, 2900000, 2900000, 2900000, | ||
194 | 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, | ||
195 | }; | ||
196 | |||
197 | static const unsigned int LDO13_table[] = { | ||
198 | 1300000, 1800000, 2000000, 2500000, 2800000, 3000000, 0, 0, | ||
199 | }; | ||
200 | |||
201 | static const unsigned int LDO13_suspend_table[] = { | ||
202 | 0, | ||
203 | }; | ||
204 | |||
205 | static const unsigned int LDO14_table[] = { | ||
206 | 1800000, 1850000, 2700000, 2750000, 2800000, 2850000, 2900000, 3300000, | ||
207 | }; | ||
208 | |||
209 | static const unsigned int LDO14_suspend_table[] = { | ||
210 | 1800000, 1850000, 2700000, 2750000, 2800000, 2850000, 2900000, 2900000, | ||
211 | }; | ||
47 | 212 | ||
48 | static int pm8607_list_voltage(struct regulator_dev *rdev, unsigned index) | 213 | static int pm8607_list_voltage(struct regulator_dev *rdev, unsigned index) |
49 | { | 214 | { |
50 | struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); | 215 | struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); |
51 | int ret = -EINVAL; | 216 | int ret = -EINVAL; |
52 | 217 | ||
53 | switch (info->desc.id) { | 218 | if (info->vol_table && (index < (2 << info->vol_nbits))) { |
54 | case PM8607_ID_BUCK1: | 219 | ret = info->vol_table[index]; |
55 | ret = (index < 0x1d) ? (index * 25000 + 800000) : | ||
56 | ((index < 0x20) ? 1500000 : | ||
57 | ((index < 0x40) ? ((index - 0x20) * 25000) : | ||
58 | -EINVAL)); | ||
59 | break; | ||
60 | case PM8607_ID_BUCK3: | ||
61 | ret = (index < 0x3d) ? (index * 25000) : | ||
62 | ((index < 0x40) ? 1500000 : -EINVAL); | ||
63 | if (ret < 0) | ||
64 | break; | ||
65 | if (info->slope_double) | 220 | if (info->slope_double) |
66 | ret <<= 1; | 221 | ret <<= 1; |
67 | break; | ||
68 | case PM8607_ID_LDO1: | ||
69 | ret = (index == 0) ? 1800000 : | ||
70 | ((index == 1) ? 1200000 : | ||
71 | ((index == 2) ? 2800000 : -EINVAL)); | ||
72 | break; | ||
73 | case PM8607_ID_LDO5: | ||
74 | ret = (index == 0) ? 2900000 : | ||
75 | ((index == 1) ? 3000000 : | ||
76 | ((index == 2) ? 3100000 : 3300000)); | ||
77 | break; | ||
78 | case PM8607_ID_LDO7: | ||
79 | case PM8607_ID_LDO8: | ||
80 | ret = (index < 3) ? (index * 50000 + 1800000) : | ||
81 | ((index < 8) ? (index * 50000 + 2550000) : | ||
82 | -EINVAL); | ||
83 | break; | ||
84 | case PM8607_ID_LDO12: | ||
85 | ret = (index < 2) ? (index * 100000 + 1800000) : | ||
86 | ((index < 7) ? (index * 100000 + 2500000) : | ||
87 | ((index == 7) ? 3300000 : 1200000)); | ||
88 | break; | ||
89 | case PM8607_ID_LDO2: | ||
90 | case PM8607_ID_LDO3: | ||
91 | case PM8607_ID_LDO9: | ||
92 | ret = (index < 3) ? (index * 50000 + 1800000) : | ||
93 | ((index < 7) ? (index * 50000 + 2550000) : | ||
94 | 3300000); | ||
95 | break; | ||
96 | case PM8607_ID_LDO4: | ||
97 | ret = (index < 3) ? (index * 50000 + 1800000) : | ||
98 | ((index < 6) ? (index * 50000 + 2550000) : | ||
99 | ((index == 6) ? 2900000 : 3300000)); | ||
100 | break; | ||
101 | case PM8607_ID_LDO6: | ||
102 | ret = (index < 2) ? (index * 50000 + 1800000) : | ||
103 | ((index < 7) ? (index * 50000 + 2500000) : | ||
104 | 3300000); | ||
105 | break; | ||
106 | case PM8607_ID_LDO10: | ||
107 | ret = (index < 3) ? (index * 50000 + 1800000) : | ||
108 | ((index < 7) ? (index * 50000 + 2550000) : | ||
109 | ((index == 7) ? 3300000 : 1200000)); | ||
110 | break; | ||
111 | case PM8607_ID_LDO14: | ||
112 | ret = (index < 2) ? (index * 50000 + 1800000) : | ||
113 | ((index < 7) ? (index * 50000 + 2600000) : | ||
114 | 3300000); | ||
115 | break; | ||
116 | } | 222 | } |
117 | return ret; | 223 | return ret; |
118 | } | 224 | } |
@@ -120,174 +226,26 @@ static int pm8607_list_voltage(struct regulator_dev *rdev, unsigned index) | |||
120 | static int choose_voltage(struct regulator_dev *rdev, int min_uV, int max_uV) | 226 | static int choose_voltage(struct regulator_dev *rdev, int min_uV, int max_uV) |
121 | { | 227 | { |
122 | struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); | 228 | struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); |
123 | int val = -ENOENT; | 229 | int i, ret = -ENOENT; |
124 | int ret; | ||
125 | 230 | ||
126 | switch (info->desc.id) { | 231 | if (info->slope_double) { |
127 | case PM8607_ID_BUCK1: | 232 | min_uV = min_uV >> 1; |
128 | if (min_uV >= 800000) /* 800mV ~ 1500mV / 25mV */ | 233 | max_uV = max_uV >> 1; |
129 | val = (min_uV - 775001) / 25000; | ||
130 | else { /* 25mV ~ 775mV / 25mV */ | ||
131 | val = (min_uV + 249999) / 25000; | ||
132 | val += 32; | ||
133 | } | ||
134 | break; | ||
135 | case PM8607_ID_BUCK3: | ||
136 | if (info->slope_double) | ||
137 | min_uV = min_uV >> 1; | ||
138 | val = (min_uV + 249999) / 25000; /* 0mV ~ 1500mV / 25mV */ | ||
139 | |||
140 | break; | ||
141 | case PM8607_ID_LDO1: | ||
142 | if (min_uV > 1800000) | ||
143 | val = 2; | ||
144 | else if (min_uV > 1200000) | ||
145 | val = 0; | ||
146 | else | ||
147 | val = 1; | ||
148 | break; | ||
149 | case PM8607_ID_LDO5: | ||
150 | if (min_uV > 3100000) | ||
151 | val = 3; | ||
152 | else /* 2900mV ~ 3100mV / 100mV */ | ||
153 | val = (min_uV - 2800001) / 100000; | ||
154 | break; | ||
155 | case PM8607_ID_LDO7: | ||
156 | case PM8607_ID_LDO8: | ||
157 | if (min_uV < 2700000) { /* 1800mV ~ 1900mV / 50mV */ | ||
158 | if (min_uV <= 1800000) | ||
159 | val = 0; /* 1800mv */ | ||
160 | else if (min_uV <= 1900000) | ||
161 | val = (min_uV - 1750001) / 50000; | ||
162 | else | ||
163 | val = 3; /* 2700mV */ | ||
164 | } else { /* 2700mV ~ 2900mV / 50mV */ | ||
165 | if (min_uV <= 2900000) { | ||
166 | val = (min_uV - 2650001) / 50000; | ||
167 | val += 3; | ||
168 | } else | ||
169 | val = -EINVAL; | ||
170 | } | ||
171 | break; | ||
172 | case PM8607_ID_LDO10: | ||
173 | if (min_uV > 2850000) | ||
174 | val = 7; | ||
175 | else if (min_uV <= 1200000) | ||
176 | val = 8; | ||
177 | else if (min_uV < 2700000) /* 1800mV ~ 1900mV / 50mV */ | ||
178 | val = (min_uV - 1750001) / 50000; | ||
179 | else { /* 2700mV ~ 2850mV / 50mV */ | ||
180 | val = (min_uV - 2650001) / 50000; | ||
181 | val += 3; | ||
182 | } | ||
183 | break; | ||
184 | case PM8607_ID_LDO12: | ||
185 | if (min_uV < 2700000) { /* 1800mV ~ 1900mV / 100mV */ | ||
186 | if (min_uV <= 1200000) | ||
187 | val = 8; /* 1200mV */ | ||
188 | else if (min_uV <= 1800000) | ||
189 | val = 0; /* 1800mV */ | ||
190 | else if (min_uV <= 1900000) | ||
191 | val = (min_uV - 1700001) / 100000; | ||
192 | else | ||
193 | val = 2; /* 2700mV */ | ||
194 | } else { /* 2700mV ~ 3100mV / 100mV */ | ||
195 | if (min_uV <= 3100000) { | ||
196 | val = (min_uV - 2600001) / 100000; | ||
197 | val += 2; | ||
198 | } else if (min_uV <= 3300000) | ||
199 | val = 7; | ||
200 | else | ||
201 | val = -EINVAL; | ||
202 | } | ||
203 | break; | ||
204 | case PM8607_ID_LDO2: | ||
205 | case PM8607_ID_LDO3: | ||
206 | case PM8607_ID_LDO9: | ||
207 | if (min_uV < 2700000) { /* 1800mV ~ 1900mV / 50mV */ | ||
208 | if (min_uV <= 1800000) | ||
209 | val = 0; | ||
210 | else if (min_uV <= 1900000) | ||
211 | val = (min_uV - 1750001) / 50000; | ||
212 | else | ||
213 | val = 3; /* 2700mV */ | ||
214 | } else { /* 2700mV ~ 2850mV / 50mV */ | ||
215 | if (min_uV <= 2850000) { | ||
216 | val = (min_uV - 2650001) / 50000; | ||
217 | val += 3; | ||
218 | } else if (min_uV <= 3300000) | ||
219 | val = 7; | ||
220 | else | ||
221 | val = -EINVAL; | ||
222 | } | ||
223 | break; | ||
224 | case PM8607_ID_LDO4: | ||
225 | if (min_uV < 2700000) { /* 1800mV ~ 1900mV / 50mV */ | ||
226 | if (min_uV <= 1800000) | ||
227 | val = 0; | ||
228 | else if (min_uV <= 1900000) | ||
229 | val = (min_uV - 1750001) / 50000; | ||
230 | else | ||
231 | val = 3; /* 2700mV */ | ||
232 | } else { /* 2700mV ~ 2800mV / 50mV */ | ||
233 | if (min_uV <= 2850000) { | ||
234 | val = (min_uV - 2650001) / 50000; | ||
235 | val += 3; | ||
236 | } else if (min_uV <= 2900000) | ||
237 | val = 6; | ||
238 | else if (min_uV <= 3300000) | ||
239 | val = 7; | ||
240 | else | ||
241 | val = -EINVAL; | ||
242 | } | ||
243 | break; | ||
244 | case PM8607_ID_LDO6: | ||
245 | if (min_uV < 2600000) { /* 1800mV ~ 1850mV / 50mV */ | ||
246 | if (min_uV <= 1800000) | ||
247 | val = 0; | ||
248 | else if (min_uV <= 1850000) | ||
249 | val = (min_uV - 1750001) / 50000; | ||
250 | else | ||
251 | val = 2; /* 2600mV */ | ||
252 | } else { /* 2600mV ~ 2800mV / 50mV */ | ||
253 | if (min_uV <= 2800000) { | ||
254 | val = (min_uV - 2550001) / 50000; | ||
255 | val += 2; | ||
256 | } else if (min_uV <= 3300000) | ||
257 | val = 7; | ||
258 | else | ||
259 | val = -EINVAL; | ||
260 | } | ||
261 | break; | ||
262 | case PM8607_ID_LDO14: | ||
263 | if (min_uV < 2700000) { /* 1800mV ~ 1850mV / 50mV */ | ||
264 | if (min_uV <= 1800000) | ||
265 | val = 0; | ||
266 | else if (min_uV <= 1850000) | ||
267 | val = (min_uV - 1750001) / 50000; | ||
268 | else | ||
269 | val = 2; /* 2700mV */ | ||
270 | } else { /* 2700mV ~ 2900mV / 50mV */ | ||
271 | if (min_uV <= 2900000) { | ||
272 | val = (min_uV - 2650001) / 50000; | ||
273 | val += 2; | ||
274 | } else if (min_uV <= 3300000) | ||
275 | val = 7; | ||
276 | else | ||
277 | val = -EINVAL; | ||
278 | } | ||
279 | break; | ||
280 | } | 234 | } |
281 | if (val >= 0) { | 235 | if (info->vol_table) { |
282 | ret = pm8607_list_voltage(rdev, val); | 236 | for (i = 0; i < (2 << info->vol_nbits); i++) { |
283 | if (ret > max_uV) { | 237 | if (!info->vol_table[i]) |
284 | pr_err("exceed voltage range (%d %d) uV", | 238 | break; |
285 | min_uV, max_uV); | 239 | if ((min_uV <= info->vol_table[i]) |
286 | return -EINVAL; | 240 | && (max_uV >= info->vol_table[i])) { |
241 | ret = i; | ||
242 | break; | ||
243 | } | ||
287 | } | 244 | } |
288 | } else | 245 | } |
289 | pr_err("invalid voltage range (%d %d) uV", min_uV, max_uV); | 246 | if (ret < 0) |
290 | return val; | 247 | pr_err("invalid voltage range (%d %d) uV\n", min_uV, max_uV); |
248 | return ret; | ||
291 | } | 249 | } |
292 | 250 | ||
293 | static int pm8607_set_voltage(struct regulator_dev *rdev, | 251 | static int pm8607_set_voltage(struct regulator_dev *rdev, |
@@ -297,7 +255,7 @@ static int pm8607_set_voltage(struct regulator_dev *rdev, | |||
297 | uint8_t val, mask; | 255 | uint8_t val, mask; |
298 | int ret; | 256 | int ret; |
299 | 257 | ||
300 | if (check_range(info, min_uV, max_uV)) { | 258 | if (min_uV > max_uV) { |
301 | pr_err("invalid voltage range (%d, %d) uV\n", min_uV, max_uV); | 259 | pr_err("invalid voltage range (%d, %d) uV\n", min_uV, max_uV); |
302 | return -EINVAL; | 260 | return -EINVAL; |
303 | } | 261 | } |
@@ -375,18 +333,15 @@ static struct regulator_ops pm8607_regulator_ops = { | |||
375 | .is_enabled = pm8607_is_enabled, | 333 | .is_enabled = pm8607_is_enabled, |
376 | }; | 334 | }; |
377 | 335 | ||
378 | #define PM8607_DVC(_id, min, max, step, vreg, nbits, ureg, ubit, ereg, ebit) \ | 336 | #define PM8607_DVC(vreg, nbits, ureg, ubit, ereg, ebit) \ |
379 | { \ | 337 | { \ |
380 | .desc = { \ | 338 | .desc = { \ |
381 | .name = "BUCK" #_id, \ | 339 | .name = #vreg, \ |
382 | .ops = &pm8607_regulator_ops, \ | 340 | .ops = &pm8607_regulator_ops, \ |
383 | .type = REGULATOR_VOLTAGE, \ | 341 | .type = REGULATOR_VOLTAGE, \ |
384 | .id = PM8607_ID_BUCK##_id, \ | 342 | .id = PM8607_ID_##vreg, \ |
385 | .owner = THIS_MODULE, \ | 343 | .owner = THIS_MODULE, \ |
386 | }, \ | 344 | }, \ |
387 | .min_uV = (min) * 1000, \ | ||
388 | .max_uV = (max) * 1000, \ | ||
389 | .step_uV = (step) * 1000, \ | ||
390 | .vol_reg = PM8607_##vreg, \ | 345 | .vol_reg = PM8607_##vreg, \ |
391 | .vol_shift = (0), \ | 346 | .vol_shift = (0), \ |
392 | .vol_nbits = (nbits), \ | 347 | .vol_nbits = (nbits), \ |
@@ -395,9 +350,11 @@ static struct regulator_ops pm8607_regulator_ops = { | |||
395 | .enable_reg = PM8607_##ereg, \ | 350 | .enable_reg = PM8607_##ereg, \ |
396 | .enable_bit = (ebit), \ | 351 | .enable_bit = (ebit), \ |
397 | .slope_double = (0), \ | 352 | .slope_double = (0), \ |
353 | .vol_table = (unsigned int *)&vreg##_table, \ | ||
354 | .vol_suspend = (unsigned int *)&vreg##_suspend_table, \ | ||
398 | } | 355 | } |
399 | 356 | ||
400 | #define PM8607_LDO(_id, min, max, step, vreg, shift, nbits, ereg, ebit) \ | 357 | #define PM8607_LDO(_id, vreg, shift, nbits, ereg, ebit) \ |
401 | { \ | 358 | { \ |
402 | .desc = { \ | 359 | .desc = { \ |
403 | .name = "LDO" #_id, \ | 360 | .name = "LDO" #_id, \ |
@@ -406,33 +363,34 @@ static struct regulator_ops pm8607_regulator_ops = { | |||
406 | .id = PM8607_ID_LDO##_id, \ | 363 | .id = PM8607_ID_LDO##_id, \ |
407 | .owner = THIS_MODULE, \ | 364 | .owner = THIS_MODULE, \ |
408 | }, \ | 365 | }, \ |
409 | .min_uV = (min) * 1000, \ | ||
410 | .max_uV = (max) * 1000, \ | ||
411 | .step_uV = (step) * 1000, \ | ||
412 | .vol_reg = PM8607_##vreg, \ | 366 | .vol_reg = PM8607_##vreg, \ |
413 | .vol_shift = (shift), \ | 367 | .vol_shift = (shift), \ |
414 | .vol_nbits = (nbits), \ | 368 | .vol_nbits = (nbits), \ |
415 | .enable_reg = PM8607_##ereg, \ | 369 | .enable_reg = PM8607_##ereg, \ |
416 | .enable_bit = (ebit), \ | 370 | .enable_bit = (ebit), \ |
417 | .slope_double = (0), \ | 371 | .slope_double = (0), \ |
372 | .vol_table = (unsigned int *)&LDO##_id##_table, \ | ||
373 | .vol_suspend = (unsigned int *)&LDO##_id##_suspend_table, \ | ||
418 | } | 374 | } |
419 | 375 | ||
420 | static struct pm8607_regulator_info pm8607_regulator_info[] = { | 376 | static struct pm8607_regulator_info pm8607_regulator_info[] = { |
421 | PM8607_DVC(1, 0, 1500, 25, BUCK1, 6, GO, 0, SUPPLIES_EN11, 0), | 377 | PM8607_DVC(BUCK1, 6, GO, 0, SUPPLIES_EN11, 0), |
422 | PM8607_DVC(3, 0, 1500, 25, BUCK3, 6, GO, 2, SUPPLIES_EN11, 2), | 378 | PM8607_DVC(BUCK2, 6, GO, 1, SUPPLIES_EN11, 1), |
423 | 379 | PM8607_DVC(BUCK3, 6, GO, 2, SUPPLIES_EN11, 2), | |
424 | PM8607_LDO(1 , 1200, 2800, 0, LDO1 , 0, 2, SUPPLIES_EN11, 3), | 380 | |
425 | PM8607_LDO(2 , 1800, 3300, 0, LDO2 , 0, 3, SUPPLIES_EN11, 4), | 381 | PM8607_LDO( 1, LDO1, 0, 2, SUPPLIES_EN11, 3), |
426 | PM8607_LDO(3 , 1800, 3300, 0, LDO3 , 0, 3, SUPPLIES_EN11, 5), | 382 | PM8607_LDO( 2, LDO2, 0, 3, SUPPLIES_EN11, 4), |
427 | PM8607_LDO(4 , 1800, 3300, 0, LDO4 , 0, 3, SUPPLIES_EN11, 6), | 383 | PM8607_LDO( 3, LDO3, 0, 3, SUPPLIES_EN11, 5), |
428 | PM8607_LDO(5 , 2900, 3300, 0, LDO5 , 0, 2, SUPPLIES_EN11, 7), | 384 | PM8607_LDO( 4, LDO4, 0, 3, SUPPLIES_EN11, 6), |
429 | PM8607_LDO(6 , 1800, 3300, 0, LDO6 , 0, 3, SUPPLIES_EN12, 0), | 385 | PM8607_LDO( 5, LDO5, 0, 2, SUPPLIES_EN11, 7), |
430 | PM8607_LDO(7 , 1800, 2900, 0, LDO7 , 0, 3, SUPPLIES_EN12, 1), | 386 | PM8607_LDO( 6, LDO6, 0, 3, SUPPLIES_EN12, 0), |
431 | PM8607_LDO(8 , 1800, 2900, 0, LDO8 , 0, 3, SUPPLIES_EN12, 2), | 387 | PM8607_LDO( 7, LDO7, 0, 3, SUPPLIES_EN12, 1), |
432 | PM8607_LDO(9 , 1800, 3300, 0, LDO9 , 0, 3, SUPPLIES_EN12, 3), | 388 | PM8607_LDO( 8, LDO8, 0, 3, SUPPLIES_EN12, 2), |
433 | PM8607_LDO(10, 1200, 3300, 0, LDO10, 0, 4, SUPPLIES_EN11, 4), | 389 | PM8607_LDO( 9, LDO9, 0, 3, SUPPLIES_EN12, 3), |
434 | PM8607_LDO(12, 1200, 3300, 0, LDO12, 0, 4, SUPPLIES_EN11, 5), | 390 | PM8607_LDO(10, LDO10, 0, 3, SUPPLIES_EN12, 4), |
435 | PM8607_LDO(14, 1800, 3300, 0, LDO14, 0, 3, SUPPLIES_EN11, 6), | 391 | PM8607_LDO(12, LDO12, 0, 4, SUPPLIES_EN12, 5), |
392 | PM8607_LDO(13, VIBRATOR_SET, 1, 3, VIBRATOR_SET, 0), | ||
393 | PM8607_LDO(14, LDO14, 0, 4, SUPPLIES_EN12, 6), | ||
436 | }; | 394 | }; |
437 | 395 | ||
438 | static inline struct pm8607_regulator_info *find_regulator_info(int id) | 396 | static inline struct pm8607_regulator_info *find_regulator_info(int id) |
@@ -484,60 +442,29 @@ static int __devexit pm8607_regulator_remove(struct platform_device *pdev) | |||
484 | { | 442 | { |
485 | struct pm8607_regulator_info *info = platform_get_drvdata(pdev); | 443 | struct pm8607_regulator_info *info = platform_get_drvdata(pdev); |
486 | 444 | ||
445 | platform_set_drvdata(pdev, NULL); | ||
487 | regulator_unregister(info->regulator); | 446 | regulator_unregister(info->regulator); |
488 | return 0; | 447 | return 0; |
489 | } | 448 | } |
490 | 449 | ||
491 | #define PM8607_REGULATOR_DRIVER(_name) \ | 450 | static struct platform_driver pm8607_regulator_driver = { |
492 | { \ | 451 | .driver = { |
493 | .driver = { \ | 452 | .name = "88pm860x-regulator", |
494 | .name = "88pm8607-" #_name, \ | 453 | .owner = THIS_MODULE, |
495 | .owner = THIS_MODULE, \ | 454 | }, |
496 | }, \ | 455 | .probe = pm8607_regulator_probe, |
497 | .probe = pm8607_regulator_probe, \ | 456 | .remove = __devexit_p(pm8607_regulator_remove), |
498 | .remove = __devexit_p(pm8607_regulator_remove), \ | ||
499 | } | ||
500 | |||
501 | static struct platform_driver pm8607_regulator_driver[] = { | ||
502 | PM8607_REGULATOR_DRIVER(buck1), | ||
503 | PM8607_REGULATOR_DRIVER(buck2), | ||
504 | PM8607_REGULATOR_DRIVER(buck3), | ||
505 | PM8607_REGULATOR_DRIVER(ldo1), | ||
506 | PM8607_REGULATOR_DRIVER(ldo2), | ||
507 | PM8607_REGULATOR_DRIVER(ldo3), | ||
508 | PM8607_REGULATOR_DRIVER(ldo4), | ||
509 | PM8607_REGULATOR_DRIVER(ldo5), | ||
510 | PM8607_REGULATOR_DRIVER(ldo6), | ||
511 | PM8607_REGULATOR_DRIVER(ldo7), | ||
512 | PM8607_REGULATOR_DRIVER(ldo8), | ||
513 | PM8607_REGULATOR_DRIVER(ldo9), | ||
514 | PM8607_REGULATOR_DRIVER(ldo10), | ||
515 | PM8607_REGULATOR_DRIVER(ldo12), | ||
516 | PM8607_REGULATOR_DRIVER(ldo14), | ||
517 | }; | 457 | }; |
518 | 458 | ||
519 | static int __init pm8607_regulator_init(void) | 459 | static int __init pm8607_regulator_init(void) |
520 | { | 460 | { |
521 | int i, count, ret; | 461 | return platform_driver_register(&pm8607_regulator_driver); |
522 | |||
523 | count = ARRAY_SIZE(pm8607_regulator_driver); | ||
524 | for (i = 0; i < count; i++) { | ||
525 | ret = platform_driver_register(&pm8607_regulator_driver[i]); | ||
526 | if (ret != 0) | ||
527 | pr_err("Failed to register regulator driver: %d\n", | ||
528 | ret); | ||
529 | } | ||
530 | return 0; | ||
531 | } | 462 | } |
532 | subsys_initcall(pm8607_regulator_init); | 463 | subsys_initcall(pm8607_regulator_init); |
533 | 464 | ||
534 | static void __exit pm8607_regulator_exit(void) | 465 | static void __exit pm8607_regulator_exit(void) |
535 | { | 466 | { |
536 | int i, count; | 467 | platform_driver_unregister(&pm8607_regulator_driver); |
537 | |||
538 | count = ARRAY_SIZE(pm8607_regulator_driver); | ||
539 | for (i = 0; i < count; i++) | ||
540 | platform_driver_unregister(&pm8607_regulator_driver[i]); | ||
541 | } | 468 | } |
542 | module_exit(pm8607_regulator_exit); | 469 | module_exit(pm8607_regulator_exit); |
543 | 470 | ||
diff --git a/drivers/regulator/ab3100.c b/drivers/regulator/ab3100.c index 7de950959ed2..11790990277a 100644 --- a/drivers/regulator/ab3100.c +++ b/drivers/regulator/ab3100.c | |||
@@ -16,7 +16,7 @@ | |||
16 | #include <linux/delay.h> | 16 | #include <linux/delay.h> |
17 | #include <linux/platform_device.h> | 17 | #include <linux/platform_device.h> |
18 | #include <linux/regulator/driver.h> | 18 | #include <linux/regulator/driver.h> |
19 | #include <linux/mfd/ab3100.h> | 19 | #include <linux/mfd/abx500.h> |
20 | 20 | ||
21 | /* LDO registers and some handy masking definitions for AB3100 */ | 21 | /* LDO registers and some handy masking definitions for AB3100 */ |
22 | #define AB3100_LDO_A 0x40 | 22 | #define AB3100_LDO_A 0x40 |
@@ -41,7 +41,7 @@ | |||
41 | * struct ab3100_regulator | 41 | * struct ab3100_regulator |
42 | * A struct passed around the individual regulator functions | 42 | * A struct passed around the individual regulator functions |
43 | * @platform_device: platform device holding this regulator | 43 | * @platform_device: platform device holding this regulator |
44 | * @ab3100: handle to the AB3100 parent chip | 44 | * @dev: handle to the device |
45 | * @plfdata: AB3100 platform data passed in at probe time | 45 | * @plfdata: AB3100 platform data passed in at probe time |
46 | * @regreg: regulator register number in the AB3100 | 46 | * @regreg: regulator register number in the AB3100 |
47 | * @fixed_voltage: a fixed voltage for this regulator, if this | 47 | * @fixed_voltage: a fixed voltage for this regulator, if this |
@@ -52,7 +52,7 @@ | |||
52 | */ | 52 | */ |
53 | struct ab3100_regulator { | 53 | struct ab3100_regulator { |
54 | struct regulator_dev *rdev; | 54 | struct regulator_dev *rdev; |
55 | struct ab3100 *ab3100; | 55 | struct device *dev; |
56 | struct ab3100_platform_data *plfdata; | 56 | struct ab3100_platform_data *plfdata; |
57 | u8 regreg; | 57 | u8 regreg; |
58 | int fixed_voltage; | 58 | int fixed_voltage; |
@@ -183,7 +183,7 @@ static int ab3100_enable_regulator(struct regulator_dev *reg) | |||
183 | int err; | 183 | int err; |
184 | u8 regval; | 184 | u8 regval; |
185 | 185 | ||
186 | err = ab3100_get_register_interruptible(abreg->ab3100, abreg->regreg, | 186 | err = abx500_get_register_interruptible(abreg->dev, 0, abreg->regreg, |
187 | ®val); | 187 | ®val); |
188 | if (err) { | 188 | if (err) { |
189 | dev_warn(®->dev, "failed to get regid %d value\n", | 189 | dev_warn(®->dev, "failed to get regid %d value\n", |
@@ -197,7 +197,7 @@ static int ab3100_enable_regulator(struct regulator_dev *reg) | |||
197 | 197 | ||
198 | regval |= AB3100_REG_ON_MASK; | 198 | regval |= AB3100_REG_ON_MASK; |
199 | 199 | ||
200 | err = ab3100_set_register_interruptible(abreg->ab3100, abreg->regreg, | 200 | err = abx500_set_register_interruptible(abreg->dev, 0, abreg->regreg, |
201 | regval); | 201 | regval); |
202 | if (err) { | 202 | if (err) { |
203 | dev_warn(®->dev, "failed to set regid %d value\n", | 203 | dev_warn(®->dev, "failed to set regid %d value\n", |
@@ -245,14 +245,14 @@ static int ab3100_disable_regulator(struct regulator_dev *reg) | |||
245 | if (abreg->regreg == AB3100_LDO_D) { | 245 | if (abreg->regreg == AB3100_LDO_D) { |
246 | dev_info(®->dev, "disabling LDO D - shut down system\n"); | 246 | dev_info(®->dev, "disabling LDO D - shut down system\n"); |
247 | /* Setting LDO D to 0x00 cuts the power to the SoC */ | 247 | /* Setting LDO D to 0x00 cuts the power to the SoC */ |
248 | return ab3100_set_register_interruptible(abreg->ab3100, | 248 | return abx500_set_register_interruptible(abreg->dev, 0, |
249 | AB3100_LDO_D, 0x00U); | 249 | AB3100_LDO_D, 0x00U); |
250 | } | 250 | } |
251 | 251 | ||
252 | /* | 252 | /* |
253 | * All other regulators are handled here | 253 | * All other regulators are handled here |
254 | */ | 254 | */ |
255 | err = ab3100_get_register_interruptible(abreg->ab3100, abreg->regreg, | 255 | err = abx500_get_register_interruptible(abreg->dev, 0, abreg->regreg, |
256 | ®val); | 256 | ®val); |
257 | if (err) { | 257 | if (err) { |
258 | dev_err(®->dev, "unable to get register 0x%x\n", | 258 | dev_err(®->dev, "unable to get register 0x%x\n", |
@@ -260,7 +260,7 @@ static int ab3100_disable_regulator(struct regulator_dev *reg) | |||
260 | return err; | 260 | return err; |
261 | } | 261 | } |
262 | regval &= ~AB3100_REG_ON_MASK; | 262 | regval &= ~AB3100_REG_ON_MASK; |
263 | return ab3100_set_register_interruptible(abreg->ab3100, abreg->regreg, | 263 | return abx500_set_register_interruptible(abreg->dev, 0, abreg->regreg, |
264 | regval); | 264 | regval); |
265 | } | 265 | } |
266 | 266 | ||
@@ -270,7 +270,7 @@ static int ab3100_is_enabled_regulator(struct regulator_dev *reg) | |||
270 | u8 regval; | 270 | u8 regval; |
271 | int err; | 271 | int err; |
272 | 272 | ||
273 | err = ab3100_get_register_interruptible(abreg->ab3100, abreg->regreg, | 273 | err = abx500_get_register_interruptible(abreg->dev, 0, abreg->regreg, |
274 | ®val); | 274 | ®val); |
275 | if (err) { | 275 | if (err) { |
276 | dev_err(®->dev, "unable to get register 0x%x\n", | 276 | dev_err(®->dev, "unable to get register 0x%x\n", |
@@ -286,7 +286,7 @@ static int ab3100_list_voltage_regulator(struct regulator_dev *reg, | |||
286 | { | 286 | { |
287 | struct ab3100_regulator *abreg = reg->reg_data; | 287 | struct ab3100_regulator *abreg = reg->reg_data; |
288 | 288 | ||
289 | if (selector > abreg->voltages_len) | 289 | if (selector >= abreg->voltages_len) |
290 | return -EINVAL; | 290 | return -EINVAL; |
291 | return abreg->typ_voltages[selector]; | 291 | return abreg->typ_voltages[selector]; |
292 | } | 292 | } |
@@ -305,7 +305,7 @@ static int ab3100_get_voltage_regulator(struct regulator_dev *reg) | |||
305 | * For variable types, read out setting and index into | 305 | * For variable types, read out setting and index into |
306 | * supplied voltage list. | 306 | * supplied voltage list. |
307 | */ | 307 | */ |
308 | err = ab3100_get_register_interruptible(abreg->ab3100, | 308 | err = abx500_get_register_interruptible(abreg->dev, 0, |
309 | abreg->regreg, ®val); | 309 | abreg->regreg, ®val); |
310 | if (err) { | 310 | if (err) { |
311 | dev_warn(®->dev, | 311 | dev_warn(®->dev, |
@@ -318,7 +318,7 @@ static int ab3100_get_voltage_regulator(struct regulator_dev *reg) | |||
318 | regval &= 0xE0; | 318 | regval &= 0xE0; |
319 | regval >>= 5; | 319 | regval >>= 5; |
320 | 320 | ||
321 | if (regval > abreg->voltages_len) { | 321 | if (regval >= abreg->voltages_len) { |
322 | dev_err(®->dev, | 322 | dev_err(®->dev, |
323 | "regulator register %02x contains an illegal voltage setting\n", | 323 | "regulator register %02x contains an illegal voltage setting\n", |
324 | abreg->regreg); | 324 | abreg->regreg); |
@@ -373,7 +373,7 @@ static int ab3100_set_voltage_regulator(struct regulator_dev *reg, | |||
373 | if (bestindex < 0) | 373 | if (bestindex < 0) |
374 | return bestindex; | 374 | return bestindex; |
375 | 375 | ||
376 | err = ab3100_get_register_interruptible(abreg->ab3100, | 376 | err = abx500_get_register_interruptible(abreg->dev, 0, |
377 | abreg->regreg, ®val); | 377 | abreg->regreg, ®val); |
378 | if (err) { | 378 | if (err) { |
379 | dev_warn(®->dev, | 379 | dev_warn(®->dev, |
@@ -386,7 +386,7 @@ static int ab3100_set_voltage_regulator(struct regulator_dev *reg, | |||
386 | regval &= ~0xE0; | 386 | regval &= ~0xE0; |
387 | regval |= (bestindex << 5); | 387 | regval |= (bestindex << 5); |
388 | 388 | ||
389 | err = ab3100_set_register_interruptible(abreg->ab3100, | 389 | err = abx500_set_register_interruptible(abreg->dev, 0, |
390 | abreg->regreg, regval); | 390 | abreg->regreg, regval); |
391 | if (err) | 391 | if (err) |
392 | dev_warn(®->dev, "failed to set regulator register %02x\n", | 392 | dev_warn(®->dev, "failed to set regulator register %02x\n", |
@@ -414,7 +414,7 @@ static int ab3100_set_suspend_voltage_regulator(struct regulator_dev *reg, | |||
414 | /* LDO E and BUCK have special suspend voltages you can set */ | 414 | /* LDO E and BUCK have special suspend voltages you can set */ |
415 | bestindex = ab3100_get_best_voltage_index(reg, uV, uV); | 415 | bestindex = ab3100_get_best_voltage_index(reg, uV, uV); |
416 | 416 | ||
417 | err = ab3100_get_register_interruptible(abreg->ab3100, | 417 | err = abx500_get_register_interruptible(abreg->dev, 0, |
418 | targetreg, ®val); | 418 | targetreg, ®val); |
419 | if (err) { | 419 | if (err) { |
420 | dev_warn(®->dev, | 420 | dev_warn(®->dev, |
@@ -427,7 +427,7 @@ static int ab3100_set_suspend_voltage_regulator(struct regulator_dev *reg, | |||
427 | regval &= ~0xE0; | 427 | regval &= ~0xE0; |
428 | regval |= (bestindex << 5); | 428 | regval |= (bestindex << 5); |
429 | 429 | ||
430 | err = ab3100_set_register_interruptible(abreg->ab3100, | 430 | err = abx500_set_register_interruptible(abreg->dev, 0, |
431 | targetreg, regval); | 431 | targetreg, regval); |
432 | if (err) | 432 | if (err) |
433 | dev_warn(®->dev, "failed to set regulator register %02x\n", | 433 | dev_warn(®->dev, "failed to set regulator register %02x\n", |
@@ -492,18 +492,21 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = { | |||
492 | .id = AB3100_LDO_A, | 492 | .id = AB3100_LDO_A, |
493 | .ops = ®ulator_ops_fixed, | 493 | .ops = ®ulator_ops_fixed, |
494 | .type = REGULATOR_VOLTAGE, | 494 | .type = REGULATOR_VOLTAGE, |
495 | .owner = THIS_MODULE, | ||
495 | }, | 496 | }, |
496 | { | 497 | { |
497 | .name = "LDO_C", | 498 | .name = "LDO_C", |
498 | .id = AB3100_LDO_C, | 499 | .id = AB3100_LDO_C, |
499 | .ops = ®ulator_ops_fixed, | 500 | .ops = ®ulator_ops_fixed, |
500 | .type = REGULATOR_VOLTAGE, | 501 | .type = REGULATOR_VOLTAGE, |
502 | .owner = THIS_MODULE, | ||
501 | }, | 503 | }, |
502 | { | 504 | { |
503 | .name = "LDO_D", | 505 | .name = "LDO_D", |
504 | .id = AB3100_LDO_D, | 506 | .id = AB3100_LDO_D, |
505 | .ops = ®ulator_ops_fixed, | 507 | .ops = ®ulator_ops_fixed, |
506 | .type = REGULATOR_VOLTAGE, | 508 | .type = REGULATOR_VOLTAGE, |
509 | .owner = THIS_MODULE, | ||
507 | }, | 510 | }, |
508 | { | 511 | { |
509 | .name = "LDO_E", | 512 | .name = "LDO_E", |
@@ -511,6 +514,7 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = { | |||
511 | .ops = ®ulator_ops_variable_sleepable, | 514 | .ops = ®ulator_ops_variable_sleepable, |
512 | .n_voltages = ARRAY_SIZE(ldo_e_buck_typ_voltages), | 515 | .n_voltages = ARRAY_SIZE(ldo_e_buck_typ_voltages), |
513 | .type = REGULATOR_VOLTAGE, | 516 | .type = REGULATOR_VOLTAGE, |
517 | .owner = THIS_MODULE, | ||
514 | }, | 518 | }, |
515 | { | 519 | { |
516 | .name = "LDO_F", | 520 | .name = "LDO_F", |
@@ -518,6 +522,7 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = { | |||
518 | .ops = ®ulator_ops_variable, | 522 | .ops = ®ulator_ops_variable, |
519 | .n_voltages = ARRAY_SIZE(ldo_f_typ_voltages), | 523 | .n_voltages = ARRAY_SIZE(ldo_f_typ_voltages), |
520 | .type = REGULATOR_VOLTAGE, | 524 | .type = REGULATOR_VOLTAGE, |
525 | .owner = THIS_MODULE, | ||
521 | }, | 526 | }, |
522 | { | 527 | { |
523 | .name = "LDO_G", | 528 | .name = "LDO_G", |
@@ -525,6 +530,7 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = { | |||
525 | .ops = ®ulator_ops_variable, | 530 | .ops = ®ulator_ops_variable, |
526 | .n_voltages = ARRAY_SIZE(ldo_g_typ_voltages), | 531 | .n_voltages = ARRAY_SIZE(ldo_g_typ_voltages), |
527 | .type = REGULATOR_VOLTAGE, | 532 | .type = REGULATOR_VOLTAGE, |
533 | .owner = THIS_MODULE, | ||
528 | }, | 534 | }, |
529 | { | 535 | { |
530 | .name = "LDO_H", | 536 | .name = "LDO_H", |
@@ -532,6 +538,7 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = { | |||
532 | .ops = ®ulator_ops_variable, | 538 | .ops = ®ulator_ops_variable, |
533 | .n_voltages = ARRAY_SIZE(ldo_h_typ_voltages), | 539 | .n_voltages = ARRAY_SIZE(ldo_h_typ_voltages), |
534 | .type = REGULATOR_VOLTAGE, | 540 | .type = REGULATOR_VOLTAGE, |
541 | .owner = THIS_MODULE, | ||
535 | }, | 542 | }, |
536 | { | 543 | { |
537 | .name = "LDO_K", | 544 | .name = "LDO_K", |
@@ -539,12 +546,14 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = { | |||
539 | .ops = ®ulator_ops_variable, | 546 | .ops = ®ulator_ops_variable, |
540 | .n_voltages = ARRAY_SIZE(ldo_k_typ_voltages), | 547 | .n_voltages = ARRAY_SIZE(ldo_k_typ_voltages), |
541 | .type = REGULATOR_VOLTAGE, | 548 | .type = REGULATOR_VOLTAGE, |
549 | .owner = THIS_MODULE, | ||
542 | }, | 550 | }, |
543 | { | 551 | { |
544 | .name = "LDO_EXT", | 552 | .name = "LDO_EXT", |
545 | .id = AB3100_LDO_EXT, | 553 | .id = AB3100_LDO_EXT, |
546 | .ops = ®ulator_ops_external, | 554 | .ops = ®ulator_ops_external, |
547 | .type = REGULATOR_VOLTAGE, | 555 | .type = REGULATOR_VOLTAGE, |
556 | .owner = THIS_MODULE, | ||
548 | }, | 557 | }, |
549 | { | 558 | { |
550 | .name = "BUCK", | 559 | .name = "BUCK", |
@@ -552,6 +561,7 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = { | |||
552 | .ops = ®ulator_ops_variable_sleepable, | 561 | .ops = ®ulator_ops_variable_sleepable, |
553 | .n_voltages = ARRAY_SIZE(ldo_e_buck_typ_voltages), | 562 | .n_voltages = ARRAY_SIZE(ldo_e_buck_typ_voltages), |
554 | .type = REGULATOR_VOLTAGE, | 563 | .type = REGULATOR_VOLTAGE, |
564 | .owner = THIS_MODULE, | ||
555 | }, | 565 | }, |
556 | }; | 566 | }; |
557 | 567 | ||
@@ -564,13 +574,12 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = { | |||
564 | static int __devinit ab3100_regulators_probe(struct platform_device *pdev) | 574 | static int __devinit ab3100_regulators_probe(struct platform_device *pdev) |
565 | { | 575 | { |
566 | struct ab3100_platform_data *plfdata = pdev->dev.platform_data; | 576 | struct ab3100_platform_data *plfdata = pdev->dev.platform_data; |
567 | struct ab3100 *ab3100 = platform_get_drvdata(pdev); | ||
568 | int err = 0; | 577 | int err = 0; |
569 | u8 data; | 578 | u8 data; |
570 | int i; | 579 | int i; |
571 | 580 | ||
572 | /* Check chip state */ | 581 | /* Check chip state */ |
573 | err = ab3100_get_register_interruptible(ab3100, | 582 | err = abx500_get_register_interruptible(&pdev->dev, 0, |
574 | AB3100_LDO_D, &data); | 583 | AB3100_LDO_D, &data); |
575 | if (err) { | 584 | if (err) { |
576 | dev_err(&pdev->dev, "could not read initial status of LDO_D\n"); | 585 | dev_err(&pdev->dev, "could not read initial status of LDO_D\n"); |
@@ -585,7 +594,7 @@ static int __devinit ab3100_regulators_probe(struct platform_device *pdev) | |||
585 | 594 | ||
586 | /* Set up regulators */ | 595 | /* Set up regulators */ |
587 | for (i = 0; i < ARRAY_SIZE(ab3100_reg_init_order); i++) { | 596 | for (i = 0; i < ARRAY_SIZE(ab3100_reg_init_order); i++) { |
588 | err = ab3100_set_register_interruptible(ab3100, | 597 | err = abx500_set_register_interruptible(&pdev->dev, 0, |
589 | ab3100_reg_init_order[i], | 598 | ab3100_reg_init_order[i], |
590 | plfdata->reg_initvals[i]); | 599 | plfdata->reg_initvals[i]); |
591 | if (err) { | 600 | if (err) { |
@@ -607,7 +616,7 @@ static int __devinit ab3100_regulators_probe(struct platform_device *pdev) | |||
607 | * see what it looks like for a certain machine, go | 616 | * see what it looks like for a certain machine, go |
608 | * into the machine I2C setup. | 617 | * into the machine I2C setup. |
609 | */ | 618 | */ |
610 | reg->ab3100 = ab3100; | 619 | reg->dev = &pdev->dev; |
611 | reg->plfdata = plfdata; | 620 | reg->plfdata = plfdata; |
612 | 621 | ||
613 | /* | 622 | /* |
diff --git a/drivers/regulator/bq24022.c b/drivers/regulator/bq24022.c index d08cd9b66c6d..068d488a4f71 100644 --- a/drivers/regulator/bq24022.c +++ b/drivers/regulator/bq24022.c | |||
@@ -78,6 +78,7 @@ static struct regulator_desc bq24022_desc = { | |||
78 | .name = "bq24022", | 78 | .name = "bq24022", |
79 | .ops = &bq24022_ops, | 79 | .ops = &bq24022_ops, |
80 | .type = REGULATOR_CURRENT, | 80 | .type = REGULATOR_CURRENT, |
81 | .owner = THIS_MODULE, | ||
81 | }; | 82 | }; |
82 | 83 | ||
83 | static int __init bq24022_probe(struct platform_device *pdev) | 84 | static int __init bq24022_probe(struct platform_device *pdev) |
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 2b4e40d31190..2248087b9be2 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -944,8 +944,13 @@ static int set_consumer_device_supply(struct regulator_dev *rdev, | |||
944 | has_dev = 0; | 944 | has_dev = 0; |
945 | 945 | ||
946 | list_for_each_entry(node, ®ulator_map_list, list) { | 946 | list_for_each_entry(node, ®ulator_map_list, list) { |
947 | if (consumer_dev_name != node->dev_name) | 947 | if (node->dev_name && consumer_dev_name) { |
948 | if (strcmp(node->dev_name, consumer_dev_name) != 0) | ||
949 | continue; | ||
950 | } else if (node->dev_name || consumer_dev_name) { | ||
948 | continue; | 951 | continue; |
952 | } | ||
953 | |||
949 | if (strcmp(node->supply, supply) != 0) | 954 | if (strcmp(node->supply, supply) != 0) |
950 | continue; | 955 | continue; |
951 | 956 | ||
@@ -976,29 +981,6 @@ static int set_consumer_device_supply(struct regulator_dev *rdev, | |||
976 | return 0; | 981 | return 0; |
977 | } | 982 | } |
978 | 983 | ||
979 | static void unset_consumer_device_supply(struct regulator_dev *rdev, | ||
980 | const char *consumer_dev_name, struct device *consumer_dev) | ||
981 | { | ||
982 | struct regulator_map *node, *n; | ||
983 | |||
984 | if (consumer_dev && !consumer_dev_name) | ||
985 | consumer_dev_name = dev_name(consumer_dev); | ||
986 | |||
987 | list_for_each_entry_safe(node, n, ®ulator_map_list, list) { | ||
988 | if (rdev != node->regulator) | ||
989 | continue; | ||
990 | |||
991 | if (consumer_dev_name && node->dev_name && | ||
992 | strcmp(consumer_dev_name, node->dev_name)) | ||
993 | continue; | ||
994 | |||
995 | list_del(&node->list); | ||
996 | kfree(node->dev_name); | ||
997 | kfree(node); | ||
998 | return; | ||
999 | } | ||
1000 | } | ||
1001 | |||
1002 | static void unset_regulator_supplies(struct regulator_dev *rdev) | 984 | static void unset_regulator_supplies(struct regulator_dev *rdev) |
1003 | { | 985 | { |
1004 | struct regulator_map *node, *n; | 986 | struct regulator_map *node, *n; |
@@ -1008,7 +990,6 @@ static void unset_regulator_supplies(struct regulator_dev *rdev) | |||
1008 | list_del(&node->list); | 990 | list_del(&node->list); |
1009 | kfree(node->dev_name); | 991 | kfree(node->dev_name); |
1010 | kfree(node); | 992 | kfree(node); |
1011 | return; | ||
1012 | } | 993 | } |
1013 | } | 994 | } |
1014 | } | 995 | } |
@@ -1540,7 +1521,7 @@ EXPORT_SYMBOL_GPL(regulator_count_voltages); | |||
1540 | * Context: can sleep | 1521 | * Context: can sleep |
1541 | * | 1522 | * |
1542 | * Returns a voltage that can be passed to @regulator_set_voltage(), | 1523 | * Returns a voltage that can be passed to @regulator_set_voltage(), |
1543 | * zero if this selector code can't be used on this sytem, or a | 1524 | * zero if this selector code can't be used on this system, or a |
1544 | * negative errno. | 1525 | * negative errno. |
1545 | */ | 1526 | */ |
1546 | int regulator_list_voltage(struct regulator *regulator, unsigned selector) | 1527 | int regulator_list_voltage(struct regulator *regulator, unsigned selector) |
@@ -1764,6 +1745,7 @@ int regulator_set_mode(struct regulator *regulator, unsigned int mode) | |||
1764 | { | 1745 | { |
1765 | struct regulator_dev *rdev = regulator->rdev; | 1746 | struct regulator_dev *rdev = regulator->rdev; |
1766 | int ret; | 1747 | int ret; |
1748 | int regulator_curr_mode; | ||
1767 | 1749 | ||
1768 | mutex_lock(&rdev->mutex); | 1750 | mutex_lock(&rdev->mutex); |
1769 | 1751 | ||
@@ -1773,6 +1755,15 @@ int regulator_set_mode(struct regulator *regulator, unsigned int mode) | |||
1773 | goto out; | 1755 | goto out; |
1774 | } | 1756 | } |
1775 | 1757 | ||
1758 | /* return if the same mode is requested */ | ||
1759 | if (rdev->desc->ops->get_mode) { | ||
1760 | regulator_curr_mode = rdev->desc->ops->get_mode(rdev); | ||
1761 | if (regulator_curr_mode == mode) { | ||
1762 | ret = 0; | ||
1763 | goto out; | ||
1764 | } | ||
1765 | } | ||
1766 | |||
1776 | /* constraints check */ | 1767 | /* constraints check */ |
1777 | ret = regulator_check_mode(rdev, mode); | 1768 | ret = regulator_check_mode(rdev, mode); |
1778 | if (ret < 0) | 1769 | if (ret < 0) |
@@ -2328,7 +2319,37 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc, | |||
2328 | goto scrub; | 2319 | goto scrub; |
2329 | 2320 | ||
2330 | /* set supply regulator if it exists */ | 2321 | /* set supply regulator if it exists */ |
2322 | if (init_data->supply_regulator && init_data->supply_regulator_dev) { | ||
2323 | dev_err(dev, | ||
2324 | "Supply regulator specified by both name and dev\n"); | ||
2325 | goto scrub; | ||
2326 | } | ||
2327 | |||
2328 | if (init_data->supply_regulator) { | ||
2329 | struct regulator_dev *r; | ||
2330 | int found = 0; | ||
2331 | |||
2332 | list_for_each_entry(r, ®ulator_list, list) { | ||
2333 | if (strcmp(rdev_get_name(r), | ||
2334 | init_data->supply_regulator) == 0) { | ||
2335 | found = 1; | ||
2336 | break; | ||
2337 | } | ||
2338 | } | ||
2339 | |||
2340 | if (!found) { | ||
2341 | dev_err(dev, "Failed to find supply %s\n", | ||
2342 | init_data->supply_regulator); | ||
2343 | goto scrub; | ||
2344 | } | ||
2345 | |||
2346 | ret = set_supply(rdev, r); | ||
2347 | if (ret < 0) | ||
2348 | goto scrub; | ||
2349 | } | ||
2350 | |||
2331 | if (init_data->supply_regulator_dev) { | 2351 | if (init_data->supply_regulator_dev) { |
2352 | dev_warn(dev, "Uses supply_regulator_dev instead of regulator_supply\n"); | ||
2332 | ret = set_supply(rdev, | 2353 | ret = set_supply(rdev, |
2333 | dev_get_drvdata(init_data->supply_regulator_dev)); | 2354 | dev_get_drvdata(init_data->supply_regulator_dev)); |
2334 | if (ret < 0) | 2355 | if (ret < 0) |
@@ -2341,13 +2362,8 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc, | |||
2341 | init_data->consumer_supplies[i].dev, | 2362 | init_data->consumer_supplies[i].dev, |
2342 | init_data->consumer_supplies[i].dev_name, | 2363 | init_data->consumer_supplies[i].dev_name, |
2343 | init_data->consumer_supplies[i].supply); | 2364 | init_data->consumer_supplies[i].supply); |
2344 | if (ret < 0) { | 2365 | if (ret < 0) |
2345 | for (--i; i >= 0; i--) | 2366 | goto unset_supplies; |
2346 | unset_consumer_device_supply(rdev, | ||
2347 | init_data->consumer_supplies[i].dev_name, | ||
2348 | init_data->consumer_supplies[i].dev); | ||
2349 | goto scrub; | ||
2350 | } | ||
2351 | } | 2367 | } |
2352 | 2368 | ||
2353 | list_add(&rdev->list, ®ulator_list); | 2369 | list_add(&rdev->list, ®ulator_list); |
@@ -2355,6 +2371,9 @@ out: | |||
2355 | mutex_unlock(®ulator_list_mutex); | 2371 | mutex_unlock(®ulator_list_mutex); |
2356 | return rdev; | 2372 | return rdev; |
2357 | 2373 | ||
2374 | unset_supplies: | ||
2375 | unset_regulator_supplies(rdev); | ||
2376 | |||
2358 | scrub: | 2377 | scrub: |
2359 | device_unregister(&rdev->dev); | 2378 | device_unregister(&rdev->dev); |
2360 | /* device core frees rdev */ | 2379 | /* device core frees rdev */ |
diff --git a/drivers/regulator/lp3971.c b/drivers/regulator/lp3971.c index 671a7d1f1f0e..8ae3732eb24b 100644 --- a/drivers/regulator/lp3971.c +++ b/drivers/regulator/lp3971.c | |||
@@ -519,8 +519,6 @@ static int __devexit lp3971_i2c_remove(struct i2c_client *i2c) | |||
519 | struct lp3971 *lp3971 = i2c_get_clientdata(i2c); | 519 | struct lp3971 *lp3971 = i2c_get_clientdata(i2c); |
520 | int i; | 520 | int i; |
521 | 521 | ||
522 | i2c_set_clientdata(i2c, NULL); | ||
523 | |||
524 | for (i = 0; i < lp3971->num_regulators; i++) | 522 | for (i = 0; i < lp3971->num_regulators; i++) |
525 | regulator_unregister(lp3971->rdev[i]); | 523 | regulator_unregister(lp3971->rdev[i]); |
526 | 524 | ||
diff --git a/drivers/regulator/max1586.c b/drivers/regulator/max1586.c index b3c1afc16889..2b54d9d75f11 100644 --- a/drivers/regulator/max1586.c +++ b/drivers/regulator/max1586.c | |||
@@ -244,7 +244,6 @@ static int __devexit max1586_pmic_remove(struct i2c_client *client) | |||
244 | for (i = 0; i <= MAX1586_V6; i++) | 244 | for (i = 0; i <= MAX1586_V6; i++) |
245 | if (rdev[i]) | 245 | if (rdev[i]) |
246 | regulator_unregister(rdev[i]); | 246 | regulator_unregister(rdev[i]); |
247 | i2c_set_clientdata(client, NULL); | ||
248 | kfree(rdev); | 247 | kfree(rdev); |
249 | 248 | ||
250 | return 0; | 249 | return 0; |
diff --git a/drivers/regulator/max8649.c b/drivers/regulator/max8649.c index bfc4c5ffdc96..4520ace3f7e7 100644 --- a/drivers/regulator/max8649.c +++ b/drivers/regulator/max8649.c | |||
@@ -357,7 +357,6 @@ static int __devinit max8649_regulator_probe(struct i2c_client *client, | |||
357 | dev_info(info->dev, "Max8649 regulator device is detected.\n"); | 357 | dev_info(info->dev, "Max8649 regulator device is detected.\n"); |
358 | return 0; | 358 | return 0; |
359 | out: | 359 | out: |
360 | i2c_set_clientdata(client, NULL); | ||
361 | kfree(info); | 360 | kfree(info); |
362 | return ret; | 361 | return ret; |
363 | } | 362 | } |
@@ -369,7 +368,6 @@ static int __devexit max8649_regulator_remove(struct i2c_client *client) | |||
369 | if (info) { | 368 | if (info) { |
370 | if (info->regulator) | 369 | if (info->regulator) |
371 | regulator_unregister(info->regulator); | 370 | regulator_unregister(info->regulator); |
372 | i2c_set_clientdata(client, NULL); | ||
373 | kfree(info); | 371 | kfree(info); |
374 | } | 372 | } |
375 | 373 | ||
diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c index 3790b21879ff..d97220efae5a 100644 --- a/drivers/regulator/max8660.c +++ b/drivers/regulator/max8660.c | |||
@@ -471,7 +471,6 @@ static int __devexit max8660_remove(struct i2c_client *client) | |||
471 | for (i = 0; i < MAX8660_V_END; i++) | 471 | for (i = 0; i < MAX8660_V_END; i++) |
472 | if (rdev[i]) | 472 | if (rdev[i]) |
473 | regulator_unregister(rdev[i]); | 473 | regulator_unregister(rdev[i]); |
474 | i2c_set_clientdata(client, NULL); | ||
475 | kfree(rdev); | 474 | kfree(rdev); |
476 | 475 | ||
477 | return 0; | 476 | return 0; |
diff --git a/drivers/regulator/mc13783-regulator.c b/drivers/regulator/mc13783-regulator.c index ad036dd8da13..4597d508a229 100644 --- a/drivers/regulator/mc13783-regulator.c +++ b/drivers/regulator/mc13783-regulator.c | |||
@@ -440,8 +440,8 @@ static int mc13783_fixed_regulator_set_voltage(struct regulator_dev *rdev, | |||
440 | dev_dbg(rdev_get_dev(rdev), "%s id: %d min_uV: %d max_uV: %d\n", | 440 | dev_dbg(rdev_get_dev(rdev), "%s id: %d min_uV: %d max_uV: %d\n", |
441 | __func__, id, min_uV, max_uV); | 441 | __func__, id, min_uV, max_uV); |
442 | 442 | ||
443 | if (min_uV > mc13783_regulators[id].voltages[0] && | 443 | if (min_uV >= mc13783_regulators[id].voltages[0] && |
444 | max_uV < mc13783_regulators[id].voltages[0]) | 444 | max_uV <= mc13783_regulators[id].voltages[0]) |
445 | return 0; | 445 | return 0; |
446 | else | 446 | else |
447 | return -EINVAL; | 447 | return -EINVAL; |
@@ -649,6 +649,6 @@ static void __exit mc13783_regulator_exit(void) | |||
649 | module_exit(mc13783_regulator_exit); | 649 | module_exit(mc13783_regulator_exit); |
650 | 650 | ||
651 | MODULE_LICENSE("GPL v2"); | 651 | MODULE_LICENSE("GPL v2"); |
652 | MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de"); | 652 | MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>"); |
653 | MODULE_DESCRIPTION("Regulator Driver for Freescale MC13783 PMIC"); | 653 | MODULE_DESCRIPTION("Regulator Driver for Freescale MC13783 PMIC"); |
654 | MODULE_ALIAS("platform:mc13783-regulator"); | 654 | MODULE_ALIAS("platform:mc13783-regulator"); |
diff --git a/drivers/regulator/tps65023-regulator.c b/drivers/regulator/tps65023-regulator.c index 8e2f2098b005..f50afc9f287a 100644 --- a/drivers/regulator/tps65023-regulator.c +++ b/drivers/regulator/tps65023-regulator.c | |||
@@ -538,9 +538,6 @@ static int __devexit tps_65023_remove(struct i2c_client *client) | |||
538 | struct tps_pmic *tps = i2c_get_clientdata(client); | 538 | struct tps_pmic *tps = i2c_get_clientdata(client); |
539 | int i; | 539 | int i; |
540 | 540 | ||
541 | /* clear the client data in i2c */ | ||
542 | i2c_set_clientdata(client, NULL); | ||
543 | |||
544 | for (i = 0; i < TPS65023_NUM_REGULATOR; i++) | 541 | for (i = 0; i < TPS65023_NUM_REGULATOR; i++) |
545 | regulator_unregister(tps->rdev[i]); | 542 | regulator_unregister(tps->rdev[i]); |
546 | 543 | ||
diff --git a/drivers/regulator/tps6507x-regulator.c b/drivers/regulator/tps6507x-regulator.c index 74841abcc9cc..8152d65220f5 100644 --- a/drivers/regulator/tps6507x-regulator.c +++ b/drivers/regulator/tps6507x-regulator.c | |||
@@ -22,68 +22,10 @@ | |||
22 | #include <linux/platform_device.h> | 22 | #include <linux/platform_device.h> |
23 | #include <linux/regulator/driver.h> | 23 | #include <linux/regulator/driver.h> |
24 | #include <linux/regulator/machine.h> | 24 | #include <linux/regulator/machine.h> |
25 | #include <linux/i2c.h> | 25 | #include <linux/regulator/tps6507x.h> |
26 | #include <linux/delay.h> | 26 | #include <linux/delay.h> |
27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
28 | 28 | #include <linux/mfd/tps6507x.h> | |
29 | /* Register definitions */ | ||
30 | #define TPS6507X_REG_PPATH1 0X01 | ||
31 | #define TPS6507X_REG_INT 0X02 | ||
32 | #define TPS6507X_REG_CHGCONFIG0 0X03 | ||
33 | #define TPS6507X_REG_CHGCONFIG1 0X04 | ||
34 | #define TPS6507X_REG_CHGCONFIG2 0X05 | ||
35 | #define TPS6507X_REG_CHGCONFIG3 0X06 | ||
36 | #define TPS6507X_REG_REG_ADCONFIG 0X07 | ||
37 | #define TPS6507X_REG_TSCMODE 0X08 | ||
38 | #define TPS6507X_REG_ADRESULT_1 0X09 | ||
39 | #define TPS6507X_REG_ADRESULT_2 0X0A | ||
40 | #define TPS6507X_REG_PGOOD 0X0B | ||
41 | #define TPS6507X_REG_PGOODMASK 0X0C | ||
42 | #define TPS6507X_REG_CON_CTRL1 0X0D | ||
43 | #define TPS6507X_REG_CON_CTRL2 0X0E | ||
44 | #define TPS6507X_REG_CON_CTRL3 0X0F | ||
45 | #define TPS6507X_REG_DEFDCDC1 0X10 | ||
46 | #define TPS6507X_REG_DEFDCDC2_LOW 0X11 | ||
47 | #define TPS6507X_REG_DEFDCDC2_HIGH 0X12 | ||
48 | #define TPS6507X_REG_DEFDCDC3_LOW 0X13 | ||
49 | #define TPS6507X_REG_DEFDCDC3_HIGH 0X14 | ||
50 | #define TPS6507X_REG_DEFSLEW 0X15 | ||
51 | #define TPS6507X_REG_LDO_CTRL1 0X16 | ||
52 | #define TPS6507X_REG_DEFLDO2 0X17 | ||
53 | #define TPS6507X_REG_WLED_CTRL1 0X18 | ||
54 | #define TPS6507X_REG_WLED_CTRL2 0X19 | ||
55 | |||
56 | /* CON_CTRL1 bitfields */ | ||
57 | #define TPS6507X_CON_CTRL1_DCDC1_ENABLE BIT(4) | ||
58 | #define TPS6507X_CON_CTRL1_DCDC2_ENABLE BIT(3) | ||
59 | #define TPS6507X_CON_CTRL1_DCDC3_ENABLE BIT(2) | ||
60 | #define TPS6507X_CON_CTRL1_LDO1_ENABLE BIT(1) | ||
61 | #define TPS6507X_CON_CTRL1_LDO2_ENABLE BIT(0) | ||
62 | |||
63 | /* DEFDCDC1 bitfields */ | ||
64 | #define TPS6507X_DEFDCDC1_DCDC1_EXT_ADJ_EN BIT(7) | ||
65 | #define TPS6507X_DEFDCDC1_DCDC1_MASK 0X3F | ||
66 | |||
67 | /* DEFDCDC2_LOW bitfields */ | ||
68 | #define TPS6507X_DEFDCDC2_LOW_DCDC2_MASK 0X3F | ||
69 | |||
70 | /* DEFDCDC2_HIGH bitfields */ | ||
71 | #define TPS6507X_DEFDCDC2_HIGH_DCDC2_MASK 0X3F | ||
72 | |||
73 | /* DEFDCDC3_LOW bitfields */ | ||
74 | #define TPS6507X_DEFDCDC3_LOW_DCDC3_MASK 0X3F | ||
75 | |||
76 | /* DEFDCDC3_HIGH bitfields */ | ||
77 | #define TPS6507X_DEFDCDC3_HIGH_DCDC3_MASK 0X3F | ||
78 | |||
79 | /* TPS6507X_REG_LDO_CTRL1 bitfields */ | ||
80 | #define TPS6507X_REG_LDO_CTRL1_LDO1_MASK 0X0F | ||
81 | |||
82 | /* TPS6507X_REG_DEFLDO2 bitfields */ | ||
83 | #define TPS6507X_REG_DEFLDO2_LDO2_MASK 0X3F | ||
84 | |||
85 | /* VDCDC MASK */ | ||
86 | #define TPS6507X_DEFDCDCX_DCDC_MASK 0X3F | ||
87 | 29 | ||
88 | /* DCDC's */ | 30 | /* DCDC's */ |
89 | #define TPS6507X_DCDC_1 0 | 31 | #define TPS6507X_DCDC_1 0 |
@@ -160,103 +102,151 @@ struct tps_info { | |||
160 | unsigned max_uV; | 102 | unsigned max_uV; |
161 | u8 table_len; | 103 | u8 table_len; |
162 | const u16 *table; | 104 | const u16 *table; |
105 | |||
106 | /* Does DCDC high or the low register defines output voltage? */ | ||
107 | bool defdcdc_default; | ||
163 | }; | 108 | }; |
164 | 109 | ||
165 | struct tps_pmic { | 110 | static struct tps_info tps6507x_pmic_regs[] = { |
111 | { | ||
112 | .name = "VDCDC1", | ||
113 | .min_uV = 725000, | ||
114 | .max_uV = 3300000, | ||
115 | .table_len = ARRAY_SIZE(VDCDCx_VSEL_table), | ||
116 | .table = VDCDCx_VSEL_table, | ||
117 | }, | ||
118 | { | ||
119 | .name = "VDCDC2", | ||
120 | .min_uV = 725000, | ||
121 | .max_uV = 3300000, | ||
122 | .table_len = ARRAY_SIZE(VDCDCx_VSEL_table), | ||
123 | .table = VDCDCx_VSEL_table, | ||
124 | }, | ||
125 | { | ||
126 | .name = "VDCDC3", | ||
127 | .min_uV = 725000, | ||
128 | .max_uV = 3300000, | ||
129 | .table_len = ARRAY_SIZE(VDCDCx_VSEL_table), | ||
130 | .table = VDCDCx_VSEL_table, | ||
131 | }, | ||
132 | { | ||
133 | .name = "LDO1", | ||
134 | .min_uV = 1000000, | ||
135 | .max_uV = 3300000, | ||
136 | .table_len = ARRAY_SIZE(LDO1_VSEL_table), | ||
137 | .table = LDO1_VSEL_table, | ||
138 | }, | ||
139 | { | ||
140 | .name = "LDO2", | ||
141 | .min_uV = 725000, | ||
142 | .max_uV = 3300000, | ||
143 | .table_len = ARRAY_SIZE(LDO2_VSEL_table), | ||
144 | .table = LDO2_VSEL_table, | ||
145 | }, | ||
146 | }; | ||
147 | |||
148 | struct tps6507x_pmic { | ||
166 | struct regulator_desc desc[TPS6507X_NUM_REGULATOR]; | 149 | struct regulator_desc desc[TPS6507X_NUM_REGULATOR]; |
167 | struct i2c_client *client; | 150 | struct tps6507x_dev *mfd; |
168 | struct regulator_dev *rdev[TPS6507X_NUM_REGULATOR]; | 151 | struct regulator_dev *rdev[TPS6507X_NUM_REGULATOR]; |
169 | const struct tps_info *info[TPS6507X_NUM_REGULATOR]; | 152 | struct tps_info *info[TPS6507X_NUM_REGULATOR]; |
170 | struct mutex io_lock; | 153 | struct mutex io_lock; |
171 | }; | 154 | }; |
172 | 155 | static inline int tps6507x_pmic_read(struct tps6507x_pmic *tps, u8 reg) | |
173 | static inline int tps_6507x_read(struct tps_pmic *tps, u8 reg) | ||
174 | { | 156 | { |
175 | return i2c_smbus_read_byte_data(tps->client, reg); | 157 | u8 val; |
158 | int err; | ||
159 | |||
160 | err = tps->mfd->read_dev(tps->mfd, reg, 1, &val); | ||
161 | |||
162 | if (err) | ||
163 | return err; | ||
164 | |||
165 | return val; | ||
176 | } | 166 | } |
177 | 167 | ||
178 | static inline int tps_6507x_write(struct tps_pmic *tps, u8 reg, u8 val) | 168 | static inline int tps6507x_pmic_write(struct tps6507x_pmic *tps, u8 reg, u8 val) |
179 | { | 169 | { |
180 | return i2c_smbus_write_byte_data(tps->client, reg, val); | 170 | return tps->mfd->write_dev(tps->mfd, reg, 1, &val); |
181 | } | 171 | } |
182 | 172 | ||
183 | static int tps_6507x_set_bits(struct tps_pmic *tps, u8 reg, u8 mask) | 173 | static int tps6507x_pmic_set_bits(struct tps6507x_pmic *tps, u8 reg, u8 mask) |
184 | { | 174 | { |
185 | int err, data; | 175 | int err, data; |
186 | 176 | ||
187 | mutex_lock(&tps->io_lock); | 177 | mutex_lock(&tps->io_lock); |
188 | 178 | ||
189 | data = tps_6507x_read(tps, reg); | 179 | data = tps6507x_pmic_read(tps, reg); |
190 | if (data < 0) { | 180 | if (data < 0) { |
191 | dev_err(&tps->client->dev, "Read from reg 0x%x failed\n", reg); | 181 | dev_err(tps->mfd->dev, "Read from reg 0x%x failed\n", reg); |
192 | err = data; | 182 | err = data; |
193 | goto out; | 183 | goto out; |
194 | } | 184 | } |
195 | 185 | ||
196 | data |= mask; | 186 | data |= mask; |
197 | err = tps_6507x_write(tps, reg, data); | 187 | err = tps6507x_pmic_write(tps, reg, data); |
198 | if (err) | 188 | if (err) |
199 | dev_err(&tps->client->dev, "Write for reg 0x%x failed\n", reg); | 189 | dev_err(tps->mfd->dev, "Write for reg 0x%x failed\n", reg); |
200 | 190 | ||
201 | out: | 191 | out: |
202 | mutex_unlock(&tps->io_lock); | 192 | mutex_unlock(&tps->io_lock); |
203 | return err; | 193 | return err; |
204 | } | 194 | } |
205 | 195 | ||
206 | static int tps_6507x_clear_bits(struct tps_pmic *tps, u8 reg, u8 mask) | 196 | static int tps6507x_pmic_clear_bits(struct tps6507x_pmic *tps, u8 reg, u8 mask) |
207 | { | 197 | { |
208 | int err, data; | 198 | int err, data; |
209 | 199 | ||
210 | mutex_lock(&tps->io_lock); | 200 | mutex_lock(&tps->io_lock); |
211 | 201 | ||
212 | data = tps_6507x_read(tps, reg); | 202 | data = tps6507x_pmic_read(tps, reg); |
213 | if (data < 0) { | 203 | if (data < 0) { |
214 | dev_err(&tps->client->dev, "Read from reg 0x%x failed\n", reg); | 204 | dev_err(tps->mfd->dev, "Read from reg 0x%x failed\n", reg); |
215 | err = data; | 205 | err = data; |
216 | goto out; | 206 | goto out; |
217 | } | 207 | } |
218 | 208 | ||
219 | data &= ~mask; | 209 | data &= ~mask; |
220 | err = tps_6507x_write(tps, reg, data); | 210 | err = tps6507x_pmic_write(tps, reg, data); |
221 | if (err) | 211 | if (err) |
222 | dev_err(&tps->client->dev, "Write for reg 0x%x failed\n", reg); | 212 | dev_err(tps->mfd->dev, "Write for reg 0x%x failed\n", reg); |
223 | 213 | ||
224 | out: | 214 | out: |
225 | mutex_unlock(&tps->io_lock); | 215 | mutex_unlock(&tps->io_lock); |
226 | return err; | 216 | return err; |
227 | } | 217 | } |
228 | 218 | ||
229 | static int tps_6507x_reg_read(struct tps_pmic *tps, u8 reg) | 219 | static int tps6507x_pmic_reg_read(struct tps6507x_pmic *tps, u8 reg) |
230 | { | 220 | { |
231 | int data; | 221 | int data; |
232 | 222 | ||
233 | mutex_lock(&tps->io_lock); | 223 | mutex_lock(&tps->io_lock); |
234 | 224 | ||
235 | data = tps_6507x_read(tps, reg); | 225 | data = tps6507x_pmic_read(tps, reg); |
236 | if (data < 0) | 226 | if (data < 0) |
237 | dev_err(&tps->client->dev, "Read from reg 0x%x failed\n", reg); | 227 | dev_err(tps->mfd->dev, "Read from reg 0x%x failed\n", reg); |
238 | 228 | ||
239 | mutex_unlock(&tps->io_lock); | 229 | mutex_unlock(&tps->io_lock); |
240 | return data; | 230 | return data; |
241 | } | 231 | } |
242 | 232 | ||
243 | static int tps_6507x_reg_write(struct tps_pmic *tps, u8 reg, u8 val) | 233 | static int tps6507x_pmic_reg_write(struct tps6507x_pmic *tps, u8 reg, u8 val) |
244 | { | 234 | { |
245 | int err; | 235 | int err; |
246 | 236 | ||
247 | mutex_lock(&tps->io_lock); | 237 | mutex_lock(&tps->io_lock); |
248 | 238 | ||
249 | err = tps_6507x_write(tps, reg, val); | 239 | err = tps6507x_pmic_write(tps, reg, val); |
250 | if (err < 0) | 240 | if (err < 0) |
251 | dev_err(&tps->client->dev, "Write for reg 0x%x failed\n", reg); | 241 | dev_err(tps->mfd->dev, "Write for reg 0x%x failed\n", reg); |
252 | 242 | ||
253 | mutex_unlock(&tps->io_lock); | 243 | mutex_unlock(&tps->io_lock); |
254 | return err; | 244 | return err; |
255 | } | 245 | } |
256 | 246 | ||
257 | static int tps6507x_dcdc_is_enabled(struct regulator_dev *dev) | 247 | static int tps6507x_pmic_dcdc_is_enabled(struct regulator_dev *dev) |
258 | { | 248 | { |
259 | struct tps_pmic *tps = rdev_get_drvdata(dev); | 249 | struct tps6507x_pmic *tps = rdev_get_drvdata(dev); |
260 | int data, dcdc = rdev_get_id(dev); | 250 | int data, dcdc = rdev_get_id(dev); |
261 | u8 shift; | 251 | u8 shift; |
262 | 252 | ||
@@ -264,7 +254,7 @@ static int tps6507x_dcdc_is_enabled(struct regulator_dev *dev) | |||
264 | return -EINVAL; | 254 | return -EINVAL; |
265 | 255 | ||
266 | shift = TPS6507X_MAX_REG_ID - dcdc; | 256 | shift = TPS6507X_MAX_REG_ID - dcdc; |
267 | data = tps_6507x_reg_read(tps, TPS6507X_REG_CON_CTRL1); | 257 | data = tps6507x_pmic_reg_read(tps, TPS6507X_REG_CON_CTRL1); |
268 | 258 | ||
269 | if (data < 0) | 259 | if (data < 0) |
270 | return data; | 260 | return data; |
@@ -272,9 +262,9 @@ static int tps6507x_dcdc_is_enabled(struct regulator_dev *dev) | |||
272 | return (data & 1<<shift) ? 1 : 0; | 262 | return (data & 1<<shift) ? 1 : 0; |
273 | } | 263 | } |
274 | 264 | ||
275 | static int tps6507x_ldo_is_enabled(struct regulator_dev *dev) | 265 | static int tps6507x_pmic_ldo_is_enabled(struct regulator_dev *dev) |
276 | { | 266 | { |
277 | struct tps_pmic *tps = rdev_get_drvdata(dev); | 267 | struct tps6507x_pmic *tps = rdev_get_drvdata(dev); |
278 | int data, ldo = rdev_get_id(dev); | 268 | int data, ldo = rdev_get_id(dev); |
279 | u8 shift; | 269 | u8 shift; |
280 | 270 | ||
@@ -282,7 +272,7 @@ static int tps6507x_ldo_is_enabled(struct regulator_dev *dev) | |||
282 | return -EINVAL; | 272 | return -EINVAL; |
283 | 273 | ||
284 | shift = TPS6507X_MAX_REG_ID - ldo; | 274 | shift = TPS6507X_MAX_REG_ID - ldo; |
285 | data = tps_6507x_reg_read(tps, TPS6507X_REG_CON_CTRL1); | 275 | data = tps6507x_pmic_reg_read(tps, TPS6507X_REG_CON_CTRL1); |
286 | 276 | ||
287 | if (data < 0) | 277 | if (data < 0) |
288 | return data; | 278 | return data; |
@@ -290,9 +280,9 @@ static int tps6507x_ldo_is_enabled(struct regulator_dev *dev) | |||
290 | return (data & 1<<shift) ? 1 : 0; | 280 | return (data & 1<<shift) ? 1 : 0; |
291 | } | 281 | } |
292 | 282 | ||
293 | static int tps6507x_dcdc_enable(struct regulator_dev *dev) | 283 | static int tps6507x_pmic_dcdc_enable(struct regulator_dev *dev) |
294 | { | 284 | { |
295 | struct tps_pmic *tps = rdev_get_drvdata(dev); | 285 | struct tps6507x_pmic *tps = rdev_get_drvdata(dev); |
296 | int dcdc = rdev_get_id(dev); | 286 | int dcdc = rdev_get_id(dev); |
297 | u8 shift; | 287 | u8 shift; |
298 | 288 | ||
@@ -300,12 +290,12 @@ static int tps6507x_dcdc_enable(struct regulator_dev *dev) | |||
300 | return -EINVAL; | 290 | return -EINVAL; |
301 | 291 | ||
302 | shift = TPS6507X_MAX_REG_ID - dcdc; | 292 | shift = TPS6507X_MAX_REG_ID - dcdc; |
303 | return tps_6507x_set_bits(tps, TPS6507X_REG_CON_CTRL1, 1 << shift); | 293 | return tps6507x_pmic_set_bits(tps, TPS6507X_REG_CON_CTRL1, 1 << shift); |
304 | } | 294 | } |
305 | 295 | ||
306 | static int tps6507x_dcdc_disable(struct regulator_dev *dev) | 296 | static int tps6507x_pmic_dcdc_disable(struct regulator_dev *dev) |
307 | { | 297 | { |
308 | struct tps_pmic *tps = rdev_get_drvdata(dev); | 298 | struct tps6507x_pmic *tps = rdev_get_drvdata(dev); |
309 | int dcdc = rdev_get_id(dev); | 299 | int dcdc = rdev_get_id(dev); |
310 | u8 shift; | 300 | u8 shift; |
311 | 301 | ||
@@ -313,12 +303,13 @@ static int tps6507x_dcdc_disable(struct regulator_dev *dev) | |||
313 | return -EINVAL; | 303 | return -EINVAL; |
314 | 304 | ||
315 | shift = TPS6507X_MAX_REG_ID - dcdc; | 305 | shift = TPS6507X_MAX_REG_ID - dcdc; |
316 | return tps_6507x_clear_bits(tps, TPS6507X_REG_CON_CTRL1, 1 << shift); | 306 | return tps6507x_pmic_clear_bits(tps, TPS6507X_REG_CON_CTRL1, |
307 | 1 << shift); | ||
317 | } | 308 | } |
318 | 309 | ||
319 | static int tps6507x_ldo_enable(struct regulator_dev *dev) | 310 | static int tps6507x_pmic_ldo_enable(struct regulator_dev *dev) |
320 | { | 311 | { |
321 | struct tps_pmic *tps = rdev_get_drvdata(dev); | 312 | struct tps6507x_pmic *tps = rdev_get_drvdata(dev); |
322 | int ldo = rdev_get_id(dev); | 313 | int ldo = rdev_get_id(dev); |
323 | u8 shift; | 314 | u8 shift; |
324 | 315 | ||
@@ -326,12 +317,12 @@ static int tps6507x_ldo_enable(struct regulator_dev *dev) | |||
326 | return -EINVAL; | 317 | return -EINVAL; |
327 | 318 | ||
328 | shift = TPS6507X_MAX_REG_ID - ldo; | 319 | shift = TPS6507X_MAX_REG_ID - ldo; |
329 | return tps_6507x_set_bits(tps, TPS6507X_REG_CON_CTRL1, 1 << shift); | 320 | return tps6507x_pmic_set_bits(tps, TPS6507X_REG_CON_CTRL1, 1 << shift); |
330 | } | 321 | } |
331 | 322 | ||
332 | static int tps6507x_ldo_disable(struct regulator_dev *dev) | 323 | static int tps6507x_pmic_ldo_disable(struct regulator_dev *dev) |
333 | { | 324 | { |
334 | struct tps_pmic *tps = rdev_get_drvdata(dev); | 325 | struct tps6507x_pmic *tps = rdev_get_drvdata(dev); |
335 | int ldo = rdev_get_id(dev); | 326 | int ldo = rdev_get_id(dev); |
336 | u8 shift; | 327 | u8 shift; |
337 | 328 | ||
@@ -339,12 +330,13 @@ static int tps6507x_ldo_disable(struct regulator_dev *dev) | |||
339 | return -EINVAL; | 330 | return -EINVAL; |
340 | 331 | ||
341 | shift = TPS6507X_MAX_REG_ID - ldo; | 332 | shift = TPS6507X_MAX_REG_ID - ldo; |
342 | return tps_6507x_clear_bits(tps, TPS6507X_REG_CON_CTRL1, 1 << shift); | 333 | return tps6507x_pmic_clear_bits(tps, TPS6507X_REG_CON_CTRL1, |
334 | 1 << shift); | ||
343 | } | 335 | } |
344 | 336 | ||
345 | static int tps6507x_dcdc_get_voltage(struct regulator_dev *dev) | 337 | static int tps6507x_pmic_dcdc_get_voltage(struct regulator_dev *dev) |
346 | { | 338 | { |
347 | struct tps_pmic *tps = rdev_get_drvdata(dev); | 339 | struct tps6507x_pmic *tps = rdev_get_drvdata(dev); |
348 | int data, dcdc = rdev_get_id(dev); | 340 | int data, dcdc = rdev_get_id(dev); |
349 | u8 reg; | 341 | u8 reg; |
350 | 342 | ||
@@ -353,16 +345,22 @@ static int tps6507x_dcdc_get_voltage(struct regulator_dev *dev) | |||
353 | reg = TPS6507X_REG_DEFDCDC1; | 345 | reg = TPS6507X_REG_DEFDCDC1; |
354 | break; | 346 | break; |
355 | case TPS6507X_DCDC_2: | 347 | case TPS6507X_DCDC_2: |
356 | reg = TPS6507X_REG_DEFDCDC2_LOW; | 348 | if (tps->info[dcdc]->defdcdc_default) |
349 | reg = TPS6507X_REG_DEFDCDC2_HIGH; | ||
350 | else | ||
351 | reg = TPS6507X_REG_DEFDCDC2_LOW; | ||
357 | break; | 352 | break; |
358 | case TPS6507X_DCDC_3: | 353 | case TPS6507X_DCDC_3: |
359 | reg = TPS6507X_REG_DEFDCDC3_LOW; | 354 | if (tps->info[dcdc]->defdcdc_default) |
355 | reg = TPS6507X_REG_DEFDCDC3_HIGH; | ||
356 | else | ||
357 | reg = TPS6507X_REG_DEFDCDC3_LOW; | ||
360 | break; | 358 | break; |
361 | default: | 359 | default: |
362 | return -EINVAL; | 360 | return -EINVAL; |
363 | } | 361 | } |
364 | 362 | ||
365 | data = tps_6507x_reg_read(tps, reg); | 363 | data = tps6507x_pmic_reg_read(tps, reg); |
366 | if (data < 0) | 364 | if (data < 0) |
367 | return data; | 365 | return data; |
368 | 366 | ||
@@ -370,10 +368,10 @@ static int tps6507x_dcdc_get_voltage(struct regulator_dev *dev) | |||
370 | return tps->info[dcdc]->table[data] * 1000; | 368 | return tps->info[dcdc]->table[data] * 1000; |
371 | } | 369 | } |
372 | 370 | ||
373 | static int tps6507x_dcdc_set_voltage(struct regulator_dev *dev, | 371 | static int tps6507x_pmic_dcdc_set_voltage(struct regulator_dev *dev, |
374 | int min_uV, int max_uV) | 372 | int min_uV, int max_uV) |
375 | { | 373 | { |
376 | struct tps_pmic *tps = rdev_get_drvdata(dev); | 374 | struct tps6507x_pmic *tps = rdev_get_drvdata(dev); |
377 | int data, vsel, dcdc = rdev_get_id(dev); | 375 | int data, vsel, dcdc = rdev_get_id(dev); |
378 | u8 reg; | 376 | u8 reg; |
379 | 377 | ||
@@ -382,10 +380,16 @@ static int tps6507x_dcdc_set_voltage(struct regulator_dev *dev, | |||
382 | reg = TPS6507X_REG_DEFDCDC1; | 380 | reg = TPS6507X_REG_DEFDCDC1; |
383 | break; | 381 | break; |
384 | case TPS6507X_DCDC_2: | 382 | case TPS6507X_DCDC_2: |
385 | reg = TPS6507X_REG_DEFDCDC2_LOW; | 383 | if (tps->info[dcdc]->defdcdc_default) |
384 | reg = TPS6507X_REG_DEFDCDC2_HIGH; | ||
385 | else | ||
386 | reg = TPS6507X_REG_DEFDCDC2_LOW; | ||
386 | break; | 387 | break; |
387 | case TPS6507X_DCDC_3: | 388 | case TPS6507X_DCDC_3: |
388 | reg = TPS6507X_REG_DEFDCDC3_LOW; | 389 | if (tps->info[dcdc]->defdcdc_default) |
390 | reg = TPS6507X_REG_DEFDCDC3_HIGH; | ||
391 | else | ||
392 | reg = TPS6507X_REG_DEFDCDC3_LOW; | ||
389 | break; | 393 | break; |
390 | default: | 394 | default: |
391 | return -EINVAL; | 395 | return -EINVAL; |
@@ -411,19 +415,19 @@ static int tps6507x_dcdc_set_voltage(struct regulator_dev *dev, | |||
411 | if (vsel == tps->info[dcdc]->table_len) | 415 | if (vsel == tps->info[dcdc]->table_len) |
412 | return -EINVAL; | 416 | return -EINVAL; |
413 | 417 | ||
414 | data = tps_6507x_reg_read(tps, reg); | 418 | data = tps6507x_pmic_reg_read(tps, reg); |
415 | if (data < 0) | 419 | if (data < 0) |
416 | return data; | 420 | return data; |
417 | 421 | ||
418 | data &= ~TPS6507X_DEFDCDCX_DCDC_MASK; | 422 | data &= ~TPS6507X_DEFDCDCX_DCDC_MASK; |
419 | data |= vsel; | 423 | data |= vsel; |
420 | 424 | ||
421 | return tps_6507x_reg_write(tps, reg, data); | 425 | return tps6507x_pmic_reg_write(tps, reg, data); |
422 | } | 426 | } |
423 | 427 | ||
424 | static int tps6507x_ldo_get_voltage(struct regulator_dev *dev) | 428 | static int tps6507x_pmic_ldo_get_voltage(struct regulator_dev *dev) |
425 | { | 429 | { |
426 | struct tps_pmic *tps = rdev_get_drvdata(dev); | 430 | struct tps6507x_pmic *tps = rdev_get_drvdata(dev); |
427 | int data, ldo = rdev_get_id(dev); | 431 | int data, ldo = rdev_get_id(dev); |
428 | u8 reg, mask; | 432 | u8 reg, mask; |
429 | 433 | ||
@@ -437,7 +441,7 @@ static int tps6507x_ldo_get_voltage(struct regulator_dev *dev) | |||
437 | TPS6507X_REG_DEFLDO2_LDO2_MASK); | 441 | TPS6507X_REG_DEFLDO2_LDO2_MASK); |
438 | } | 442 | } |
439 | 443 | ||
440 | data = tps_6507x_reg_read(tps, reg); | 444 | data = tps6507x_pmic_reg_read(tps, reg); |
441 | if (data < 0) | 445 | if (data < 0) |
442 | return data; | 446 | return data; |
443 | 447 | ||
@@ -445,10 +449,10 @@ static int tps6507x_ldo_get_voltage(struct regulator_dev *dev) | |||
445 | return tps->info[ldo]->table[data] * 1000; | 449 | return tps->info[ldo]->table[data] * 1000; |
446 | } | 450 | } |
447 | 451 | ||
448 | static int tps6507x_ldo_set_voltage(struct regulator_dev *dev, | 452 | static int tps6507x_pmic_ldo_set_voltage(struct regulator_dev *dev, |
449 | int min_uV, int max_uV) | 453 | int min_uV, int max_uV) |
450 | { | 454 | { |
451 | struct tps_pmic *tps = rdev_get_drvdata(dev); | 455 | struct tps6507x_pmic *tps = rdev_get_drvdata(dev); |
452 | int data, vsel, ldo = rdev_get_id(dev); | 456 | int data, vsel, ldo = rdev_get_id(dev); |
453 | u8 reg, mask; | 457 | u8 reg, mask; |
454 | 458 | ||
@@ -479,20 +483,20 @@ static int tps6507x_ldo_set_voltage(struct regulator_dev *dev, | |||
479 | if (vsel == tps->info[ldo]->table_len) | 483 | if (vsel == tps->info[ldo]->table_len) |
480 | return -EINVAL; | 484 | return -EINVAL; |
481 | 485 | ||
482 | data = tps_6507x_reg_read(tps, reg); | 486 | data = tps6507x_pmic_reg_read(tps, reg); |
483 | if (data < 0) | 487 | if (data < 0) |
484 | return data; | 488 | return data; |
485 | 489 | ||
486 | data &= ~mask; | 490 | data &= ~mask; |
487 | data |= vsel; | 491 | data |= vsel; |
488 | 492 | ||
489 | return tps_6507x_reg_write(tps, reg, data); | 493 | return tps6507x_pmic_reg_write(tps, reg, data); |
490 | } | 494 | } |
491 | 495 | ||
492 | static int tps6507x_dcdc_list_voltage(struct regulator_dev *dev, | 496 | static int tps6507x_pmic_dcdc_list_voltage(struct regulator_dev *dev, |
493 | unsigned selector) | 497 | unsigned selector) |
494 | { | 498 | { |
495 | struct tps_pmic *tps = rdev_get_drvdata(dev); | 499 | struct tps6507x_pmic *tps = rdev_get_drvdata(dev); |
496 | int dcdc = rdev_get_id(dev); | 500 | int dcdc = rdev_get_id(dev); |
497 | 501 | ||
498 | if (dcdc < TPS6507X_DCDC_1 || dcdc > TPS6507X_DCDC_3) | 502 | if (dcdc < TPS6507X_DCDC_1 || dcdc > TPS6507X_DCDC_3) |
@@ -504,10 +508,10 @@ static int tps6507x_dcdc_list_voltage(struct regulator_dev *dev, | |||
504 | return tps->info[dcdc]->table[selector] * 1000; | 508 | return tps->info[dcdc]->table[selector] * 1000; |
505 | } | 509 | } |
506 | 510 | ||
507 | static int tps6507x_ldo_list_voltage(struct regulator_dev *dev, | 511 | static int tps6507x_pmic_ldo_list_voltage(struct regulator_dev *dev, |
508 | unsigned selector) | 512 | unsigned selector) |
509 | { | 513 | { |
510 | struct tps_pmic *tps = rdev_get_drvdata(dev); | 514 | struct tps6507x_pmic *tps = rdev_get_drvdata(dev); |
511 | int ldo = rdev_get_id(dev); | 515 | int ldo = rdev_get_id(dev); |
512 | 516 | ||
513 | if (ldo < TPS6507X_LDO_1 || ldo > TPS6507X_LDO_2) | 517 | if (ldo < TPS6507X_LDO_1 || ldo > TPS6507X_LDO_2) |
@@ -520,47 +524,54 @@ static int tps6507x_ldo_list_voltage(struct regulator_dev *dev, | |||
520 | } | 524 | } |
521 | 525 | ||
522 | /* Operations permitted on VDCDCx */ | 526 | /* Operations permitted on VDCDCx */ |
523 | static struct regulator_ops tps6507x_dcdc_ops = { | 527 | static struct regulator_ops tps6507x_pmic_dcdc_ops = { |
524 | .is_enabled = tps6507x_dcdc_is_enabled, | 528 | .is_enabled = tps6507x_pmic_dcdc_is_enabled, |
525 | .enable = tps6507x_dcdc_enable, | 529 | .enable = tps6507x_pmic_dcdc_enable, |
526 | .disable = tps6507x_dcdc_disable, | 530 | .disable = tps6507x_pmic_dcdc_disable, |
527 | .get_voltage = tps6507x_dcdc_get_voltage, | 531 | .get_voltage = tps6507x_pmic_dcdc_get_voltage, |
528 | .set_voltage = tps6507x_dcdc_set_voltage, | 532 | .set_voltage = tps6507x_pmic_dcdc_set_voltage, |
529 | .list_voltage = tps6507x_dcdc_list_voltage, | 533 | .list_voltage = tps6507x_pmic_dcdc_list_voltage, |
530 | }; | 534 | }; |
531 | 535 | ||
532 | /* Operations permitted on LDOx */ | 536 | /* Operations permitted on LDOx */ |
533 | static struct regulator_ops tps6507x_ldo_ops = { | 537 | static struct regulator_ops tps6507x_pmic_ldo_ops = { |
534 | .is_enabled = tps6507x_ldo_is_enabled, | 538 | .is_enabled = tps6507x_pmic_ldo_is_enabled, |
535 | .enable = tps6507x_ldo_enable, | 539 | .enable = tps6507x_pmic_ldo_enable, |
536 | .disable = tps6507x_ldo_disable, | 540 | .disable = tps6507x_pmic_ldo_disable, |
537 | .get_voltage = tps6507x_ldo_get_voltage, | 541 | .get_voltage = tps6507x_pmic_ldo_get_voltage, |
538 | .set_voltage = tps6507x_ldo_set_voltage, | 542 | .set_voltage = tps6507x_pmic_ldo_set_voltage, |
539 | .list_voltage = tps6507x_ldo_list_voltage, | 543 | .list_voltage = tps6507x_pmic_ldo_list_voltage, |
540 | }; | 544 | }; |
541 | 545 | ||
542 | static int __devinit tps_6507x_probe(struct i2c_client *client, | 546 | static __devinit |
543 | const struct i2c_device_id *id) | 547 | int tps6507x_pmic_probe(struct platform_device *pdev) |
544 | { | 548 | { |
549 | struct tps6507x_dev *tps6507x_dev = dev_get_drvdata(pdev->dev.parent); | ||
545 | static int desc_id; | 550 | static int desc_id; |
546 | const struct tps_info *info = (void *)id->driver_data; | 551 | struct tps_info *info = &tps6507x_pmic_regs[0]; |
547 | struct regulator_init_data *init_data; | 552 | struct regulator_init_data *init_data; |
548 | struct regulator_dev *rdev; | 553 | struct regulator_dev *rdev; |
549 | struct tps_pmic *tps; | 554 | struct tps6507x_pmic *tps; |
555 | struct tps6507x_board *tps_board; | ||
550 | int i; | 556 | int i; |
551 | int error; | 557 | int error; |
552 | 558 | ||
553 | if (!i2c_check_functionality(client->adapter, | 559 | /** |
554 | I2C_FUNC_SMBUS_BYTE_DATA)) | 560 | * tps_board points to pmic related constants |
555 | return -EIO; | 561 | * coming from the board-evm file. |
562 | */ | ||
563 | |||
564 | tps_board = dev_get_platdata(tps6507x_dev->dev); | ||
565 | if (!tps_board) | ||
566 | return -EINVAL; | ||
556 | 567 | ||
557 | /** | 568 | /** |
558 | * init_data points to array of regulator_init structures | 569 | * init_data points to array of regulator_init structures |
559 | * coming from the board-evm file. | 570 | * coming from the board-evm file. |
560 | */ | 571 | */ |
561 | init_data = client->dev.platform_data; | 572 | init_data = tps_board->tps6507x_pmic_init_data; |
562 | if (!init_data) | 573 | if (!init_data) |
563 | return -EIO; | 574 | return -EINVAL; |
564 | 575 | ||
565 | tps = kzalloc(sizeof(*tps), GFP_KERNEL); | 576 | tps = kzalloc(sizeof(*tps), GFP_KERNEL); |
566 | if (!tps) | 577 | if (!tps) |
@@ -569,24 +580,31 @@ static int __devinit tps_6507x_probe(struct i2c_client *client, | |||
569 | mutex_init(&tps->io_lock); | 580 | mutex_init(&tps->io_lock); |
570 | 581 | ||
571 | /* common for all regulators */ | 582 | /* common for all regulators */ |
572 | tps->client = client; | 583 | tps->mfd = tps6507x_dev; |
573 | 584 | ||
574 | for (i = 0; i < TPS6507X_NUM_REGULATOR; i++, info++, init_data++) { | 585 | for (i = 0; i < TPS6507X_NUM_REGULATOR; i++, info++, init_data++) { |
575 | /* Register the regulators */ | 586 | /* Register the regulators */ |
576 | tps->info[i] = info; | 587 | tps->info[i] = info; |
588 | if (init_data->driver_data) { | ||
589 | struct tps6507x_reg_platform_data *data = | ||
590 | init_data->driver_data; | ||
591 | tps->info[i]->defdcdc_default = data->defdcdc_default; | ||
592 | } | ||
593 | |||
577 | tps->desc[i].name = info->name; | 594 | tps->desc[i].name = info->name; |
578 | tps->desc[i].id = desc_id++; | 595 | tps->desc[i].id = desc_id++; |
579 | tps->desc[i].n_voltages = num_voltages[i]; | 596 | tps->desc[i].n_voltages = num_voltages[i]; |
580 | tps->desc[i].ops = (i > TPS6507X_DCDC_3 ? | 597 | tps->desc[i].ops = (i > TPS6507X_DCDC_3 ? |
581 | &tps6507x_ldo_ops : &tps6507x_dcdc_ops); | 598 | &tps6507x_pmic_ldo_ops : &tps6507x_pmic_dcdc_ops); |
582 | tps->desc[i].type = REGULATOR_VOLTAGE; | 599 | tps->desc[i].type = REGULATOR_VOLTAGE; |
583 | tps->desc[i].owner = THIS_MODULE; | 600 | tps->desc[i].owner = THIS_MODULE; |
584 | 601 | ||
585 | rdev = regulator_register(&tps->desc[i], | 602 | rdev = regulator_register(&tps->desc[i], |
586 | &client->dev, init_data, tps); | 603 | tps6507x_dev->dev, init_data, tps); |
587 | if (IS_ERR(rdev)) { | 604 | if (IS_ERR(rdev)) { |
588 | dev_err(&client->dev, "failed to register %s\n", | 605 | dev_err(tps6507x_dev->dev, |
589 | id->name); | 606 | "failed to register %s regulator\n", |
607 | pdev->name); | ||
590 | error = PTR_ERR(rdev); | 608 | error = PTR_ERR(rdev); |
591 | goto fail; | 609 | goto fail; |
592 | } | 610 | } |
@@ -595,7 +613,7 @@ static int __devinit tps_6507x_probe(struct i2c_client *client, | |||
595 | tps->rdev[i] = rdev; | 613 | tps->rdev[i] = rdev; |
596 | } | 614 | } |
597 | 615 | ||
598 | i2c_set_clientdata(client, tps); | 616 | tps6507x_dev->pmic = tps; |
599 | 617 | ||
600 | return 0; | 618 | return 0; |
601 | 619 | ||
@@ -608,19 +626,17 @@ fail: | |||
608 | } | 626 | } |
609 | 627 | ||
610 | /** | 628 | /** |
611 | * tps_6507x_remove - TPS6507x driver i2c remove handler | 629 | * tps6507x_remove - TPS6507x driver i2c remove handler |
612 | * @client: i2c driver client device structure | 630 | * @client: i2c driver client device structure |
613 | * | 631 | * |
614 | * Unregister TPS driver as an i2c client device driver | 632 | * Unregister TPS driver as an i2c client device driver |
615 | */ | 633 | */ |
616 | static int __devexit tps_6507x_remove(struct i2c_client *client) | 634 | static int __devexit tps6507x_pmic_remove(struct platform_device *pdev) |
617 | { | 635 | { |
618 | struct tps_pmic *tps = i2c_get_clientdata(client); | 636 | struct tps6507x_dev *tps6507x_dev = platform_get_drvdata(pdev); |
637 | struct tps6507x_pmic *tps = tps6507x_dev->pmic; | ||
619 | int i; | 638 | int i; |
620 | 639 | ||
621 | /* clear the client data in i2c */ | ||
622 | i2c_set_clientdata(client, NULL); | ||
623 | |||
624 | for (i = 0; i < TPS6507X_NUM_REGULATOR; i++) | 640 | for (i = 0; i < TPS6507X_NUM_REGULATOR; i++) |
625 | regulator_unregister(tps->rdev[i]); | 641 | regulator_unregister(tps->rdev[i]); |
626 | 642 | ||
@@ -629,83 +645,38 @@ static int __devexit tps_6507x_remove(struct i2c_client *client) | |||
629 | return 0; | 645 | return 0; |
630 | } | 646 | } |
631 | 647 | ||
632 | static const struct tps_info tps6507x_regs[] = { | 648 | static struct platform_driver tps6507x_pmic_driver = { |
633 | { | ||
634 | .name = "VDCDC1", | ||
635 | .min_uV = 725000, | ||
636 | .max_uV = 3300000, | ||
637 | .table_len = ARRAY_SIZE(VDCDCx_VSEL_table), | ||
638 | .table = VDCDCx_VSEL_table, | ||
639 | }, | ||
640 | { | ||
641 | .name = "VDCDC2", | ||
642 | .min_uV = 725000, | ||
643 | .max_uV = 3300000, | ||
644 | .table_len = ARRAY_SIZE(VDCDCx_VSEL_table), | ||
645 | .table = VDCDCx_VSEL_table, | ||
646 | }, | ||
647 | { | ||
648 | .name = "VDCDC3", | ||
649 | .min_uV = 725000, | ||
650 | .max_uV = 3300000, | ||
651 | .table_len = ARRAY_SIZE(VDCDCx_VSEL_table), | ||
652 | .table = VDCDCx_VSEL_table, | ||
653 | }, | ||
654 | { | ||
655 | .name = "LDO1", | ||
656 | .min_uV = 1000000, | ||
657 | .max_uV = 3300000, | ||
658 | .table_len = ARRAY_SIZE(LDO1_VSEL_table), | ||
659 | .table = LDO1_VSEL_table, | ||
660 | }, | ||
661 | { | ||
662 | .name = "LDO2", | ||
663 | .min_uV = 725000, | ||
664 | .max_uV = 3300000, | ||
665 | .table_len = ARRAY_SIZE(LDO2_VSEL_table), | ||
666 | .table = LDO2_VSEL_table, | ||
667 | }, | ||
668 | }; | ||
669 | |||
670 | static const struct i2c_device_id tps_6507x_id[] = { | ||
671 | {.name = "tps6507x", | ||
672 | .driver_data = (unsigned long) tps6507x_regs,}, | ||
673 | { }, | ||
674 | }; | ||
675 | MODULE_DEVICE_TABLE(i2c, tps_6507x_id); | ||
676 | |||
677 | static struct i2c_driver tps_6507x_i2c_driver = { | ||
678 | .driver = { | 649 | .driver = { |
679 | .name = "tps6507x", | 650 | .name = "tps6507x-pmic", |
680 | .owner = THIS_MODULE, | 651 | .owner = THIS_MODULE, |
681 | }, | 652 | }, |
682 | .probe = tps_6507x_probe, | 653 | .probe = tps6507x_pmic_probe, |
683 | .remove = __devexit_p(tps_6507x_remove), | 654 | .remove = __devexit_p(tps6507x_pmic_remove), |
684 | .id_table = tps_6507x_id, | ||
685 | }; | 655 | }; |
686 | 656 | ||
687 | /** | 657 | /** |
688 | * tps_6507x_init | 658 | * tps6507x_pmic_init |
689 | * | 659 | * |
690 | * Module init function | 660 | * Module init function |
691 | */ | 661 | */ |
692 | static int __init tps_6507x_init(void) | 662 | static int __init tps6507x_pmic_init(void) |
693 | { | 663 | { |
694 | return i2c_add_driver(&tps_6507x_i2c_driver); | 664 | return platform_driver_register(&tps6507x_pmic_driver); |
695 | } | 665 | } |
696 | subsys_initcall(tps_6507x_init); | 666 | subsys_initcall(tps6507x_pmic_init); |
697 | 667 | ||
698 | /** | 668 | /** |
699 | * tps_6507x_cleanup | 669 | * tps6507x_pmic_cleanup |
700 | * | 670 | * |
701 | * Module exit function | 671 | * Module exit function |
702 | */ | 672 | */ |
703 | static void __exit tps_6507x_cleanup(void) | 673 | static void __exit tps6507x_pmic_cleanup(void) |
704 | { | 674 | { |
705 | i2c_del_driver(&tps_6507x_i2c_driver); | 675 | platform_driver_unregister(&tps6507x_pmic_driver); |
706 | } | 676 | } |
707 | module_exit(tps_6507x_cleanup); | 677 | module_exit(tps6507x_pmic_cleanup); |
708 | 678 | ||
709 | MODULE_AUTHOR("Texas Instruments"); | 679 | MODULE_AUTHOR("Texas Instruments"); |
710 | MODULE_DESCRIPTION("TPS6507x voltage regulator driver"); | 680 | MODULE_DESCRIPTION("TPS6507x voltage regulator driver"); |
711 | MODULE_LICENSE("GPL v2"); | 681 | MODULE_LICENSE("GPL v2"); |
682 | MODULE_ALIAS("platform:tps6507x-pmic"); | ||
diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c index 9729d760fb4d..7e5892efc437 100644 --- a/drivers/regulator/twl-regulator.c +++ b/drivers/regulator/twl-regulator.c | |||
@@ -49,6 +49,7 @@ struct twlreg_info { | |||
49 | 49 | ||
50 | /* chip constraints on regulator behavior */ | 50 | /* chip constraints on regulator behavior */ |
51 | u16 min_mV; | 51 | u16 min_mV; |
52 | u16 max_mV; | ||
52 | 53 | ||
53 | /* used by regulator core */ | 54 | /* used by regulator core */ |
54 | struct regulator_desc desc; | 55 | struct regulator_desc desc; |
@@ -318,31 +319,8 @@ static const u16 VIO_VSEL_table[] = { | |||
318 | static const u16 VINTANA2_VSEL_table[] = { | 319 | static const u16 VINTANA2_VSEL_table[] = { |
319 | 2500, 2750, | 320 | 2500, 2750, |
320 | }; | 321 | }; |
321 | static const u16 VAUX1_6030_VSEL_table[] = { | ||
322 | 1000, 1300, 1800, 2500, | ||
323 | 2800, 2900, 3000, 3000, | ||
324 | }; | ||
325 | static const u16 VAUX2_6030_VSEL_table[] = { | ||
326 | 1200, 1800, 2500, 2750, | ||
327 | 2800, 2800, 2800, 2800, | ||
328 | }; | ||
329 | static const u16 VAUX3_6030_VSEL_table[] = { | ||
330 | 1000, 1200, 1300, 1800, | ||
331 | 2500, 2800, 3000, 3000, | ||
332 | }; | ||
333 | static const u16 VMMC_VSEL_table[] = { | ||
334 | 1200, 1800, 2800, 2900, | ||
335 | 3000, 3000, 3000, 3000, | ||
336 | }; | ||
337 | static const u16 VPP_VSEL_table[] = { | ||
338 | 1800, 1900, 2000, 2100, | ||
339 | 2200, 2300, 2400, 2500, | ||
340 | }; | ||
341 | static const u16 VUSIM_VSEL_table[] = { | ||
342 | 1200, 1800, 2500, 2900, | ||
343 | }; | ||
344 | 322 | ||
345 | static int twlldo_list_voltage(struct regulator_dev *rdev, unsigned index) | 323 | static int twl4030ldo_list_voltage(struct regulator_dev *rdev, unsigned index) |
346 | { | 324 | { |
347 | struct twlreg_info *info = rdev_get_drvdata(rdev); | 325 | struct twlreg_info *info = rdev_get_drvdata(rdev); |
348 | int mV = info->table[index]; | 326 | int mV = info->table[index]; |
@@ -351,7 +329,7 @@ static int twlldo_list_voltage(struct regulator_dev *rdev, unsigned index) | |||
351 | } | 329 | } |
352 | 330 | ||
353 | static int | 331 | static int |
354 | twlldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV) | 332 | twl4030ldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV) |
355 | { | 333 | { |
356 | struct twlreg_info *info = rdev_get_drvdata(rdev); | 334 | struct twlreg_info *info = rdev_get_drvdata(rdev); |
357 | int vsel; | 335 | int vsel; |
@@ -375,7 +353,7 @@ twlldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV) | |||
375 | return -EDOM; | 353 | return -EDOM; |
376 | } | 354 | } |
377 | 355 | ||
378 | static int twlldo_get_voltage(struct regulator_dev *rdev) | 356 | static int twl4030ldo_get_voltage(struct regulator_dev *rdev) |
379 | { | 357 | { |
380 | struct twlreg_info *info = rdev_get_drvdata(rdev); | 358 | struct twlreg_info *info = rdev_get_drvdata(rdev); |
381 | int vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER, | 359 | int vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER, |
@@ -388,11 +366,67 @@ static int twlldo_get_voltage(struct regulator_dev *rdev) | |||
388 | return LDO_MV(info->table[vsel]) * 1000; | 366 | return LDO_MV(info->table[vsel]) * 1000; |
389 | } | 367 | } |
390 | 368 | ||
391 | static struct regulator_ops twlldo_ops = { | 369 | static struct regulator_ops twl4030ldo_ops = { |
392 | .list_voltage = twlldo_list_voltage, | 370 | .list_voltage = twl4030ldo_list_voltage, |
393 | 371 | ||
394 | .set_voltage = twlldo_set_voltage, | 372 | .set_voltage = twl4030ldo_set_voltage, |
395 | .get_voltage = twlldo_get_voltage, | 373 | .get_voltage = twl4030ldo_get_voltage, |
374 | |||
375 | .enable = twlreg_enable, | ||
376 | .disable = twlreg_disable, | ||
377 | .is_enabled = twlreg_is_enabled, | ||
378 | |||
379 | .set_mode = twlreg_set_mode, | ||
380 | |||
381 | .get_status = twlreg_get_status, | ||
382 | }; | ||
383 | |||
384 | static int twl6030ldo_list_voltage(struct regulator_dev *rdev, unsigned index) | ||
385 | { | ||
386 | struct twlreg_info *info = rdev_get_drvdata(rdev); | ||
387 | |||
388 | return ((info->min_mV + (index * 100)) * 1000); | ||
389 | } | ||
390 | |||
391 | static int | ||
392 | twl6030ldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV) | ||
393 | { | ||
394 | struct twlreg_info *info = rdev_get_drvdata(rdev); | ||
395 | int vsel; | ||
396 | |||
397 | if ((min_uV/1000 < info->min_mV) || (max_uV/1000 > info->max_mV)) | ||
398 | return -EDOM; | ||
399 | |||
400 | /* | ||
401 | * Use the below formula to calculate vsel | ||
402 | * mV = 1000mv + 100mv * (vsel - 1) | ||
403 | */ | ||
404 | vsel = (min_uV/1000 - 1000)/100 + 1; | ||
405 | return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE, vsel); | ||
406 | |||
407 | } | ||
408 | |||
409 | static int twl6030ldo_get_voltage(struct regulator_dev *rdev) | ||
410 | { | ||
411 | struct twlreg_info *info = rdev_get_drvdata(rdev); | ||
412 | int vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER, | ||
413 | VREG_VOLTAGE); | ||
414 | |||
415 | if (vsel < 0) | ||
416 | return vsel; | ||
417 | |||
418 | /* | ||
419 | * Use the below formula to calculate vsel | ||
420 | * mV = 1000mv + 100mv * (vsel - 1) | ||
421 | */ | ||
422 | return (1000 + (100 * (vsel - 1))) * 1000; | ||
423 | } | ||
424 | |||
425 | static struct regulator_ops twl6030ldo_ops = { | ||
426 | .list_voltage = twl6030ldo_list_voltage, | ||
427 | |||
428 | .set_voltage = twl6030ldo_set_voltage, | ||
429 | .get_voltage = twl6030ldo_get_voltage, | ||
396 | 430 | ||
397 | .enable = twlreg_enable, | 431 | .enable = twlreg_enable, |
398 | .disable = twlreg_disable, | 432 | .disable = twlreg_disable, |
@@ -438,24 +472,16 @@ static struct regulator_ops twlfixed_ops = { | |||
438 | 472 | ||
439 | /*----------------------------------------------------------------------*/ | 473 | /*----------------------------------------------------------------------*/ |
440 | 474 | ||
441 | #define TWL4030_ADJUSTABLE_LDO(label, offset, num, turnon_delay, remap_conf) \ | ||
442 | TWL_ADJUSTABLE_LDO(label, offset, num, turnon_delay, \ | ||
443 | remap_conf, TWL4030) | ||
444 | #define TWL4030_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \ | 475 | #define TWL4030_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \ |
445 | remap_conf) \ | 476 | remap_conf) \ |
446 | TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \ | 477 | TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \ |
447 | remap_conf, TWL4030) | 478 | remap_conf, TWL4030) |
448 | #define TWL6030_ADJUSTABLE_LDO(label, offset, num, turnon_delay, \ | ||
449 | remap_conf) \ | ||
450 | TWL_ADJUSTABLE_LDO(label, offset, num, turnon_delay, \ | ||
451 | remap_conf, TWL6030) | ||
452 | #define TWL6030_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \ | 479 | #define TWL6030_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \ |
453 | remap_conf) \ | 480 | remap_conf) \ |
454 | TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \ | 481 | TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \ |
455 | remap_conf, TWL6030) | 482 | remap_conf, TWL6030) |
456 | 483 | ||
457 | #define TWL_ADJUSTABLE_LDO(label, offset, num, turnon_delay, remap_conf, \ | 484 | #define TWL4030_ADJUSTABLE_LDO(label, offset, num, turnon_delay, remap_conf) { \ |
458 | family) { \ | ||
459 | .base = offset, \ | 485 | .base = offset, \ |
460 | .id = num, \ | 486 | .id = num, \ |
461 | .table_len = ARRAY_SIZE(label##_VSEL_table), \ | 487 | .table_len = ARRAY_SIZE(label##_VSEL_table), \ |
@@ -464,14 +490,32 @@ static struct regulator_ops twlfixed_ops = { | |||
464 | .remap = remap_conf, \ | 490 | .remap = remap_conf, \ |
465 | .desc = { \ | 491 | .desc = { \ |
466 | .name = #label, \ | 492 | .name = #label, \ |
467 | .id = family##_REG_##label, \ | 493 | .id = TWL4030_REG_##label, \ |
468 | .n_voltages = ARRAY_SIZE(label##_VSEL_table), \ | 494 | .n_voltages = ARRAY_SIZE(label##_VSEL_table), \ |
469 | .ops = &twlldo_ops, \ | 495 | .ops = &twl4030ldo_ops, \ |
470 | .type = REGULATOR_VOLTAGE, \ | 496 | .type = REGULATOR_VOLTAGE, \ |
471 | .owner = THIS_MODULE, \ | 497 | .owner = THIS_MODULE, \ |
472 | }, \ | 498 | }, \ |
473 | } | 499 | } |
474 | 500 | ||
501 | #define TWL6030_ADJUSTABLE_LDO(label, offset, min_mVolts, max_mVolts, num, \ | ||
502 | remap_conf) { \ | ||
503 | .base = offset, \ | ||
504 | .id = num, \ | ||
505 | .min_mV = min_mVolts, \ | ||
506 | .max_mV = max_mVolts, \ | ||
507 | .remap = remap_conf, \ | ||
508 | .desc = { \ | ||
509 | .name = #label, \ | ||
510 | .id = TWL6030_REG_##label, \ | ||
511 | .n_voltages = (max_mVolts - min_mVolts)/100, \ | ||
512 | .ops = &twl6030ldo_ops, \ | ||
513 | .type = REGULATOR_VOLTAGE, \ | ||
514 | .owner = THIS_MODULE, \ | ||
515 | }, \ | ||
516 | } | ||
517 | |||
518 | |||
475 | #define TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, remap_conf, \ | 519 | #define TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, remap_conf, \ |
476 | family) { \ | 520 | family) { \ |
477 | .base = offset, \ | 521 | .base = offset, \ |
@@ -519,12 +563,12 @@ static struct twlreg_info twl_regs[] = { | |||
519 | /* 6030 REG with base as PMC Slave Misc : 0x0030 */ | 563 | /* 6030 REG with base as PMC Slave Misc : 0x0030 */ |
520 | /* Turnon-delay and remap configuration values for 6030 are not | 564 | /* Turnon-delay and remap configuration values for 6030 are not |
521 | verified since the specification is not public */ | 565 | verified since the specification is not public */ |
522 | TWL6030_ADJUSTABLE_LDO(VAUX1_6030, 0x54, 1, 0, 0x21), | 566 | TWL6030_ADJUSTABLE_LDO(VAUX1_6030, 0x54, 1000, 3300, 1, 0x21), |
523 | TWL6030_ADJUSTABLE_LDO(VAUX2_6030, 0x58, 2, 0, 0x21), | 567 | TWL6030_ADJUSTABLE_LDO(VAUX2_6030, 0x58, 1000, 3300, 2, 0x21), |
524 | TWL6030_ADJUSTABLE_LDO(VAUX3_6030, 0x5c, 3, 0, 0x21), | 568 | TWL6030_ADJUSTABLE_LDO(VAUX3_6030, 0x5c, 1000, 3300, 3, 0x21), |
525 | TWL6030_ADJUSTABLE_LDO(VMMC, 0x68, 4, 0, 0x21), | 569 | TWL6030_ADJUSTABLE_LDO(VMMC, 0x68, 1000, 3300, 4, 0x21), |
526 | TWL6030_ADJUSTABLE_LDO(VPP, 0x6c, 5, 0, 0x21), | 570 | TWL6030_ADJUSTABLE_LDO(VPP, 0x6c, 1000, 3300, 5, 0x21), |
527 | TWL6030_ADJUSTABLE_LDO(VUSIM, 0x74, 7, 0, 0x21), | 571 | TWL6030_ADJUSTABLE_LDO(VUSIM, 0x74, 1000, 3300, 7, 0x21), |
528 | TWL6030_FIXED_LDO(VANA, 0x50, 2100, 15, 0, 0x21), | 572 | TWL6030_FIXED_LDO(VANA, 0x50, 2100, 15, 0, 0x21), |
529 | TWL6030_FIXED_LDO(VCXIO, 0x60, 1800, 16, 0, 0x21), | 573 | TWL6030_FIXED_LDO(VCXIO, 0x60, 1800, 16, 0, 0x21), |
530 | TWL6030_FIXED_LDO(VDAC, 0x64, 1800, 17, 0, 0x21), | 574 | TWL6030_FIXED_LDO(VDAC, 0x64, 1800, 17, 0, 0x21), |
diff --git a/drivers/regulator/wm8350-regulator.c b/drivers/regulator/wm8350-regulator.c index 723cd1fb4867..0e6ed7db9364 100644 --- a/drivers/regulator/wm8350-regulator.c +++ b/drivers/regulator/wm8350-regulator.c | |||
@@ -1495,7 +1495,7 @@ int wm8350_register_regulator(struct wm8350 *wm8350, int reg, | |||
1495 | if (ret != 0) { | 1495 | if (ret != 0) { |
1496 | dev_err(wm8350->dev, "Failed to register regulator %d: %d\n", | 1496 | dev_err(wm8350->dev, "Failed to register regulator %d: %d\n", |
1497 | reg, ret); | 1497 | reg, ret); |
1498 | platform_device_del(pdev); | 1498 | platform_device_put(pdev); |
1499 | wm8350->pmic.pdev[reg] = NULL; | 1499 | wm8350->pmic.pdev[reg] = NULL; |
1500 | } | 1500 | } |
1501 | 1501 | ||