diff options
Diffstat (limited to 'drivers/regulator/ab8500.c')
-rw-r--r-- | drivers/regulator/ab8500.c | 453 |
1 files changed, 319 insertions, 134 deletions
diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c index db6b70f2051..d9a052c53ae 100644 --- a/drivers/regulator/ab8500.c +++ b/drivers/regulator/ab8500.c | |||
@@ -3,18 +3,13 @@ | |||
3 | * | 3 | * |
4 | * License Terms: GNU General Public License v2 | 4 | * License Terms: GNU General Public License v2 |
5 | * | 5 | * |
6 | * Author: Sundar Iyer <sundar.iyer@stericsson.com> for ST-Ericsson | 6 | * Authors: Sundar Iyer <sundar.iyer@stericsson.com> for ST-Ericsson |
7 | * Bengt Jonsson <bengt.g.jonsson@stericsson.com> for ST-Ericsson | ||
7 | * | 8 | * |
8 | * AB8500 peripheral regulators | 9 | * AB8500 peripheral regulators |
9 | * | 10 | * |
10 | * AB8500 supports the following regulators, | 11 | * AB8500 supports the following regulators: |
11 | * LDOs - VAUDIO, VANAMIC2/2, VDIGMIC, VINTCORE12, VTVOUT, | 12 | * VAUX1/2/3, VINTCORE, VTVOUT, VAUDIO, VAMIC1/2, VDMIC, VANA |
12 | * VAUX1/2/3, VANA | ||
13 | * | ||
14 | * for DB8500 cut 1.0 and previous versions of the silicon, all accesses | ||
15 | * to registers are through the DB8500 SPI. In cut 1.1 onwards, these | ||
16 | * accesses are through the DB8500 PRCMU I2C | ||
17 | * | ||
18 | */ | 13 | */ |
19 | #include <linux/init.h> | 14 | #include <linux/init.h> |
20 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
@@ -28,38 +23,37 @@ | |||
28 | 23 | ||
29 | /** | 24 | /** |
30 | * struct ab8500_regulator_info - ab8500 regulator information | 25 | * struct ab8500_regulator_info - ab8500 regulator information |
26 | * @dev: device pointer | ||
31 | * @desc: regulator description | 27 | * @desc: regulator description |
32 | * @ab8500: ab8500 parent | ||
33 | * @regulator_dev: regulator device | 28 | * @regulator_dev: regulator device |
34 | * @max_uV: maximum voltage (for variable voltage supplies) | 29 | * @max_uV: maximum voltage (for variable voltage supplies) |
35 | * @min_uV: minimum voltage (for variable voltage supplies) | 30 | * @min_uV: minimum voltage (for variable voltage supplies) |
36 | * @fixed_uV: typical voltage (for fixed voltage supplies) | 31 | * @fixed_uV: typical voltage (for fixed voltage supplies) |
37 | * @update_bank: bank to control on/off | 32 | * @update_bank: bank to control on/off |
38 | * @update_reg: register to control on/off | 33 | * @update_reg: register to control on/off |
39 | * @mask: mask to enable/disable regulator | 34 | * @update_mask: mask to enable/disable regulator |
40 | * @enable: bits to enable the regulator in normal(high power) mode | 35 | * @update_val_enable: bits to enable the regulator in normal (high power) mode |
41 | * @voltage_bank: bank to control regulator voltage | 36 | * @voltage_bank: bank to control regulator voltage |
42 | * @voltage_reg: register to control regulator voltage | 37 | * @voltage_reg: register to control regulator voltage |
43 | * @voltage_mask: mask to control regulator voltage | 38 | * @voltage_mask: mask to control regulator voltage |
44 | * @supported_voltages: supported voltage table | 39 | * @voltages: supported voltage table |
45 | * @voltages_len: number of supported voltages for the regulator | 40 | * @voltages_len: number of supported voltages for the regulator |
46 | */ | 41 | */ |
47 | struct ab8500_regulator_info { | 42 | struct ab8500_regulator_info { |
48 | struct device *dev; | 43 | struct device *dev; |
49 | struct regulator_desc desc; | 44 | struct regulator_desc desc; |
50 | struct ab8500 *ab8500; | ||
51 | struct regulator_dev *regulator; | 45 | struct regulator_dev *regulator; |
52 | int max_uV; | 46 | int max_uV; |
53 | int min_uV; | 47 | int min_uV; |
54 | int fixed_uV; | 48 | int fixed_uV; |
55 | u8 update_bank; | 49 | u8 update_bank; |
56 | u8 update_reg; | 50 | u8 update_reg; |
57 | u8 mask; | 51 | u8 update_mask; |
58 | u8 enable; | 52 | u8 update_val_enable; |
59 | u8 voltage_bank; | 53 | u8 voltage_bank; |
60 | u8 voltage_reg; | 54 | u8 voltage_reg; |
61 | u8 voltage_mask; | 55 | u8 voltage_mask; |
62 | int const *supported_voltages; | 56 | int const *voltages; |
63 | int voltages_len; | 57 | int voltages_len; |
64 | }; | 58 | }; |
65 | 59 | ||
@@ -83,6 +77,17 @@ static const int ldo_vauxn_voltages[] = { | |||
83 | 3300000, | 77 | 3300000, |
84 | }; | 78 | }; |
85 | 79 | ||
80 | static const int ldo_vaux3_voltages[] = { | ||
81 | 1200000, | ||
82 | 1500000, | ||
83 | 1800000, | ||
84 | 2100000, | ||
85 | 2500000, | ||
86 | 2750000, | ||
87 | 2790000, | ||
88 | 2910000, | ||
89 | }; | ||
90 | |||
86 | static const int ldo_vintcore_voltages[] = { | 91 | static const int ldo_vintcore_voltages[] = { |
87 | 1200000, | 92 | 1200000, |
88 | 1225000, | 93 | 1225000, |
@@ -95,57 +100,80 @@ static const int ldo_vintcore_voltages[] = { | |||
95 | 100 | ||
96 | static int ab8500_regulator_enable(struct regulator_dev *rdev) | 101 | static int ab8500_regulator_enable(struct regulator_dev *rdev) |
97 | { | 102 | { |
98 | int regulator_id, ret; | 103 | int ret; |
99 | struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); | 104 | struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); |
100 | 105 | ||
101 | regulator_id = rdev_get_id(rdev); | 106 | if (info == NULL) { |
102 | if (regulator_id >= AB8500_NUM_REGULATORS) | 107 | dev_err(rdev_get_dev(rdev), "regulator info null pointer\n"); |
103 | return -EINVAL; | 108 | return -EINVAL; |
109 | } | ||
104 | 110 | ||
105 | ret = abx500_mask_and_set_register_interruptible(info->dev, | 111 | ret = abx500_mask_and_set_register_interruptible(info->dev, |
106 | info->update_bank, info->update_reg, info->mask, info->enable); | 112 | info->update_bank, info->update_reg, |
113 | info->update_mask, info->update_val_enable); | ||
107 | if (ret < 0) | 114 | if (ret < 0) |
108 | dev_err(rdev_get_dev(rdev), | 115 | dev_err(rdev_get_dev(rdev), |
109 | "couldn't set enable bits for regulator\n"); | 116 | "couldn't set enable bits for regulator\n"); |
117 | |||
118 | dev_vdbg(rdev_get_dev(rdev), | ||
119 | "%s-enable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n", | ||
120 | info->desc.name, info->update_bank, info->update_reg, | ||
121 | info->update_mask, info->update_val_enable); | ||
122 | |||
110 | return ret; | 123 | return ret; |
111 | } | 124 | } |
112 | 125 | ||
113 | static int ab8500_regulator_disable(struct regulator_dev *rdev) | 126 | static int ab8500_regulator_disable(struct regulator_dev *rdev) |
114 | { | 127 | { |
115 | int regulator_id, ret; | 128 | int ret; |
116 | struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); | 129 | struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); |
117 | 130 | ||
118 | regulator_id = rdev_get_id(rdev); | 131 | if (info == NULL) { |
119 | if (regulator_id >= AB8500_NUM_REGULATORS) | 132 | dev_err(rdev_get_dev(rdev), "regulator info null pointer\n"); |
120 | return -EINVAL; | 133 | return -EINVAL; |
134 | } | ||
121 | 135 | ||
122 | ret = abx500_mask_and_set_register_interruptible(info->dev, | 136 | ret = abx500_mask_and_set_register_interruptible(info->dev, |
123 | info->update_bank, info->update_reg, info->mask, 0x0); | 137 | info->update_bank, info->update_reg, |
138 | info->update_mask, 0x0); | ||
124 | if (ret < 0) | 139 | if (ret < 0) |
125 | dev_err(rdev_get_dev(rdev), | 140 | dev_err(rdev_get_dev(rdev), |
126 | "couldn't set disable bits for regulator\n"); | 141 | "couldn't set disable bits for regulator\n"); |
142 | |||
143 | dev_vdbg(rdev_get_dev(rdev), | ||
144 | "%s-disable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n", | ||
145 | info->desc.name, info->update_bank, info->update_reg, | ||
146 | info->update_mask, 0x0); | ||
147 | |||
127 | return ret; | 148 | return ret; |
128 | } | 149 | } |
129 | 150 | ||
130 | static int ab8500_regulator_is_enabled(struct regulator_dev *rdev) | 151 | static int ab8500_regulator_is_enabled(struct regulator_dev *rdev) |
131 | { | 152 | { |
132 | int regulator_id, ret; | 153 | int ret; |
133 | struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); | 154 | struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); |
134 | u8 value; | 155 | u8 regval; |
135 | 156 | ||
136 | regulator_id = rdev_get_id(rdev); | 157 | if (info == NULL) { |
137 | if (regulator_id >= AB8500_NUM_REGULATORS) | 158 | dev_err(rdev_get_dev(rdev), "regulator info null pointer\n"); |
138 | return -EINVAL; | 159 | return -EINVAL; |
160 | } | ||
139 | 161 | ||
140 | ret = abx500_get_register_interruptible(info->dev, | 162 | ret = abx500_get_register_interruptible(info->dev, |
141 | info->update_bank, info->update_reg, &value); | 163 | info->update_bank, info->update_reg, ®val); |
142 | if (ret < 0) { | 164 | if (ret < 0) { |
143 | dev_err(rdev_get_dev(rdev), | 165 | dev_err(rdev_get_dev(rdev), |
144 | "couldn't read 0x%x register\n", info->update_reg); | 166 | "couldn't read 0x%x register\n", info->update_reg); |
145 | return ret; | 167 | return ret; |
146 | } | 168 | } |
147 | 169 | ||
148 | if (value & info->mask) | 170 | dev_vdbg(rdev_get_dev(rdev), |
171 | "%s-is_enabled (bank, reg, mask, value): 0x%x, 0x%x, 0x%x," | ||
172 | " 0x%x\n", | ||
173 | info->desc.name, info->update_bank, info->update_reg, | ||
174 | info->update_mask, regval); | ||
175 | |||
176 | if (regval & info->update_mask) | ||
149 | return true; | 177 | return true; |
150 | else | 178 | else |
151 | return false; | 179 | return false; |
@@ -153,12 +181,12 @@ static int ab8500_regulator_is_enabled(struct regulator_dev *rdev) | |||
153 | 181 | ||
154 | static int ab8500_list_voltage(struct regulator_dev *rdev, unsigned selector) | 182 | static int ab8500_list_voltage(struct regulator_dev *rdev, unsigned selector) |
155 | { | 183 | { |
156 | int regulator_id; | ||
157 | struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); | 184 | struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); |
158 | 185 | ||
159 | regulator_id = rdev_get_id(rdev); | 186 | if (info == NULL) { |
160 | if (regulator_id >= AB8500_NUM_REGULATORS) | 187 | dev_err(rdev_get_dev(rdev), "regulator info null pointer\n"); |
161 | return -EINVAL; | 188 | return -EINVAL; |
189 | } | ||
162 | 190 | ||
163 | /* return the uV for the fixed regulators */ | 191 | /* return the uV for the fixed regulators */ |
164 | if (info->fixed_uV) | 192 | if (info->fixed_uV) |
@@ -167,33 +195,40 @@ static int ab8500_list_voltage(struct regulator_dev *rdev, unsigned selector) | |||
167 | if (selector >= info->voltages_len) | 195 | if (selector >= info->voltages_len) |
168 | return -EINVAL; | 196 | return -EINVAL; |
169 | 197 | ||
170 | return info->supported_voltages[selector]; | 198 | return info->voltages[selector]; |
171 | } | 199 | } |
172 | 200 | ||
173 | static int ab8500_regulator_get_voltage(struct regulator_dev *rdev) | 201 | static int ab8500_regulator_get_voltage(struct regulator_dev *rdev) |
174 | { | 202 | { |
175 | int regulator_id, ret; | 203 | int ret, val; |
176 | struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); | 204 | struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); |
177 | u8 value; | 205 | u8 regval; |
178 | 206 | ||
179 | regulator_id = rdev_get_id(rdev); | 207 | if (info == NULL) { |
180 | if (regulator_id >= AB8500_NUM_REGULATORS) | 208 | dev_err(rdev_get_dev(rdev), "regulator info null pointer\n"); |
181 | return -EINVAL; | 209 | return -EINVAL; |
210 | } | ||
182 | 211 | ||
183 | ret = abx500_get_register_interruptible(info->dev, info->voltage_bank, | 212 | ret = abx500_get_register_interruptible(info->dev, |
184 | info->voltage_reg, &value); | 213 | info->voltage_bank, info->voltage_reg, ®val); |
185 | if (ret < 0) { | 214 | if (ret < 0) { |
186 | dev_err(rdev_get_dev(rdev), | 215 | dev_err(rdev_get_dev(rdev), |
187 | "couldn't read voltage reg for regulator\n"); | 216 | "couldn't read voltage reg for regulator\n"); |
188 | return ret; | 217 | return ret; |
189 | } | 218 | } |
190 | 219 | ||
220 | dev_vdbg(rdev_get_dev(rdev), | ||
221 | "%s-get_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x," | ||
222 | " 0x%x\n", | ||
223 | info->desc.name, info->voltage_bank, info->voltage_reg, | ||
224 | info->voltage_mask, regval); | ||
225 | |||
191 | /* vintcore has a different layout */ | 226 | /* vintcore has a different layout */ |
192 | value &= info->voltage_mask; | 227 | val = regval & info->voltage_mask; |
193 | if (regulator_id == AB8500_LDO_INTCORE) | 228 | if (info->desc.id == AB8500_LDO_INTCORE) |
194 | ret = info->supported_voltages[value >> 0x3]; | 229 | ret = info->voltages[val >> 0x3]; |
195 | else | 230 | else |
196 | ret = info->supported_voltages[value]; | 231 | ret = info->voltages[val]; |
197 | 232 | ||
198 | return ret; | 233 | return ret; |
199 | } | 234 | } |
@@ -206,8 +241,8 @@ static int ab8500_get_best_voltage_index(struct regulator_dev *rdev, | |||
206 | 241 | ||
207 | /* check the supported voltage */ | 242 | /* check the supported voltage */ |
208 | for (i = 0; i < info->voltages_len; i++) { | 243 | for (i = 0; i < info->voltages_len; i++) { |
209 | if ((info->supported_voltages[i] >= min_uV) && | 244 | if ((info->voltages[i] >= min_uV) && |
210 | (info->supported_voltages[i] <= max_uV)) | 245 | (info->voltages[i] <= max_uV)) |
211 | return i; | 246 | return i; |
212 | } | 247 | } |
213 | 248 | ||
@@ -215,14 +250,17 @@ static int ab8500_get_best_voltage_index(struct regulator_dev *rdev, | |||
215 | } | 250 | } |
216 | 251 | ||
217 | static int ab8500_regulator_set_voltage(struct regulator_dev *rdev, | 252 | static int ab8500_regulator_set_voltage(struct regulator_dev *rdev, |
218 | int min_uV, int max_uV) | 253 | int min_uV, int max_uV, |
254 | unsigned *selector) | ||
219 | { | 255 | { |
220 | int regulator_id, ret; | 256 | int ret; |
221 | struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); | 257 | struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); |
258 | u8 regval; | ||
222 | 259 | ||
223 | regulator_id = rdev_get_id(rdev); | 260 | if (info == NULL) { |
224 | if (regulator_id >= AB8500_NUM_REGULATORS) | 261 | dev_err(rdev_get_dev(rdev), "regulator info null pointer\n"); |
225 | return -EINVAL; | 262 | return -EINVAL; |
263 | } | ||
226 | 264 | ||
227 | /* get the appropriate voltages within the range */ | 265 | /* get the appropriate voltages within the range */ |
228 | ret = ab8500_get_best_voltage_index(rdev, min_uV, max_uV); | 266 | ret = ab8500_get_best_voltage_index(rdev, min_uV, max_uV); |
@@ -232,14 +270,23 @@ static int ab8500_regulator_set_voltage(struct regulator_dev *rdev, | |||
232 | return ret; | 270 | return ret; |
233 | } | 271 | } |
234 | 272 | ||
273 | *selector = ret; | ||
274 | |||
235 | /* set the registers for the request */ | 275 | /* set the registers for the request */ |
276 | regval = (u8)ret; | ||
236 | ret = abx500_mask_and_set_register_interruptible(info->dev, | 277 | ret = abx500_mask_and_set_register_interruptible(info->dev, |
237 | info->voltage_bank, info->voltage_reg, | 278 | info->voltage_bank, info->voltage_reg, |
238 | info->voltage_mask, (u8)ret); | 279 | info->voltage_mask, regval); |
239 | if (ret < 0) | 280 | if (ret < 0) |
240 | dev_err(rdev_get_dev(rdev), | 281 | dev_err(rdev_get_dev(rdev), |
241 | "couldn't set voltage reg for regulator\n"); | 282 | "couldn't set voltage reg for regulator\n"); |
242 | 283 | ||
284 | dev_vdbg(rdev_get_dev(rdev), | ||
285 | "%s-set_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x," | ||
286 | " 0x%x\n", | ||
287 | info->desc.name, info->voltage_bank, info->voltage_reg, | ||
288 | info->voltage_mask, regval); | ||
289 | |||
243 | return ret; | 290 | return ret; |
244 | } | 291 | } |
245 | 292 | ||
@@ -254,17 +301,17 @@ static struct regulator_ops ab8500_regulator_ops = { | |||
254 | 301 | ||
255 | static int ab8500_fixed_get_voltage(struct regulator_dev *rdev) | 302 | static int ab8500_fixed_get_voltage(struct regulator_dev *rdev) |
256 | { | 303 | { |
257 | int regulator_id; | ||
258 | struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); | 304 | struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); |
259 | 305 | ||
260 | regulator_id = rdev_get_id(rdev); | 306 | if (info == NULL) { |
261 | if (regulator_id >= AB8500_NUM_REGULATORS) | 307 | dev_err(rdev_get_dev(rdev), "regulator info null pointer\n"); |
262 | return -EINVAL; | 308 | return -EINVAL; |
309 | } | ||
263 | 310 | ||
264 | return info->fixed_uV; | 311 | return info->fixed_uV; |
265 | } | 312 | } |
266 | 313 | ||
267 | static struct regulator_ops ab8500_ldo_fixed_ops = { | 314 | static struct regulator_ops ab8500_regulator_fixed_ops = { |
268 | .enable = ab8500_regulator_enable, | 315 | .enable = ab8500_regulator_enable, |
269 | .disable = ab8500_regulator_disable, | 316 | .disable = ab8500_regulator_disable, |
270 | .is_enabled = ab8500_regulator_is_enabled, | 317 | .is_enabled = ab8500_regulator_is_enabled, |
@@ -272,88 +319,197 @@ static struct regulator_ops ab8500_ldo_fixed_ops = { | |||
272 | .list_voltage = ab8500_list_voltage, | 319 | .list_voltage = ab8500_list_voltage, |
273 | }; | 320 | }; |
274 | 321 | ||
275 | #define AB8500_LDO(_id, min, max, bank, reg, reg_mask, \ | 322 | static struct ab8500_regulator_info |
276 | reg_enable, volt_bank, volt_reg, volt_mask, \ | 323 | ab8500_regulator_info[AB8500_NUM_REGULATORS] = { |
277 | voltages, len_volts) \ | ||
278 | { \ | ||
279 | .desc = { \ | ||
280 | .name = "LDO-" #_id, \ | ||
281 | .ops = &ab8500_regulator_ops, \ | ||
282 | .type = REGULATOR_VOLTAGE, \ | ||
283 | .id = AB8500_LDO_##_id, \ | ||
284 | .owner = THIS_MODULE, \ | ||
285 | }, \ | ||
286 | .min_uV = (min) * 1000, \ | ||
287 | .max_uV = (max) * 1000, \ | ||
288 | .update_bank = bank, \ | ||
289 | .update_reg = reg, \ | ||
290 | .mask = reg_mask, \ | ||
291 | .enable = reg_enable, \ | ||
292 | .voltage_bank = volt_bank, \ | ||
293 | .voltage_reg = volt_reg, \ | ||
294 | .voltage_mask = volt_mask, \ | ||
295 | .supported_voltages = voltages, \ | ||
296 | .voltages_len = len_volts, \ | ||
297 | .fixed_uV = 0, \ | ||
298 | } | ||
299 | |||
300 | #define AB8500_FIXED_LDO(_id, fixed, bank, reg, \ | ||
301 | reg_mask, reg_enable) \ | ||
302 | { \ | ||
303 | .desc = { \ | ||
304 | .name = "LDO-" #_id, \ | ||
305 | .ops = &ab8500_ldo_fixed_ops, \ | ||
306 | .type = REGULATOR_VOLTAGE, \ | ||
307 | .id = AB8500_LDO_##_id, \ | ||
308 | .owner = THIS_MODULE, \ | ||
309 | }, \ | ||
310 | .fixed_uV = fixed * 1000, \ | ||
311 | .update_bank = bank, \ | ||
312 | .update_reg = reg, \ | ||
313 | .mask = reg_mask, \ | ||
314 | .enable = reg_enable, \ | ||
315 | } | ||
316 | |||
317 | static struct ab8500_regulator_info ab8500_regulator_info[] = { | ||
318 | /* | 324 | /* |
319 | * Variable Voltage LDOs | 325 | * Variable Voltage Regulators |
320 | * name, min uV, max uV, ctrl bank, ctrl reg, reg mask, enable mask, | 326 | * name, min mV, max mV, |
321 | * volt ctrl bank, volt ctrl reg, volt ctrl mask, volt table, | 327 | * update bank, reg, mask, enable val |
322 | * num supported volts | 328 | * volt bank, reg, mask, table, table length |
323 | */ | 329 | */ |
324 | AB8500_LDO(AUX1, 1100, 3300, 0x04, 0x09, 0x3, 0x1, 0x04, 0x1f, 0xf, | 330 | [AB8500_LDO_AUX1] = { |
325 | ldo_vauxn_voltages, ARRAY_SIZE(ldo_vauxn_voltages)), | 331 | .desc = { |
326 | AB8500_LDO(AUX2, 1100, 3300, 0x04, 0x09, 0xc, 0x4, 0x04, 0x20, 0xf, | 332 | .name = "LDO-AUX1", |
327 | ldo_vauxn_voltages, ARRAY_SIZE(ldo_vauxn_voltages)), | 333 | .ops = &ab8500_regulator_ops, |
328 | AB8500_LDO(AUX3, 1100, 3300, 0x04, 0x0a, 0x3, 0x1, 0x04, 0x21, 0xf, | 334 | .type = REGULATOR_VOLTAGE, |
329 | ldo_vauxn_voltages, ARRAY_SIZE(ldo_vauxn_voltages)), | 335 | .id = AB8500_LDO_AUX1, |
330 | AB8500_LDO(INTCORE, 1100, 3300, 0x03, 0x80, 0x4, 0x4, 0x03, 0x80, 0x38, | 336 | .owner = THIS_MODULE, |
331 | ldo_vintcore_voltages, ARRAY_SIZE(ldo_vintcore_voltages)), | 337 | .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages), |
338 | }, | ||
339 | .min_uV = 1100000, | ||
340 | .max_uV = 3300000, | ||
341 | .update_bank = 0x04, | ||
342 | .update_reg = 0x09, | ||
343 | .update_mask = 0x03, | ||
344 | .update_val_enable = 0x01, | ||
345 | .voltage_bank = 0x04, | ||
346 | .voltage_reg = 0x1f, | ||
347 | .voltage_mask = 0x0f, | ||
348 | .voltages = ldo_vauxn_voltages, | ||
349 | .voltages_len = ARRAY_SIZE(ldo_vauxn_voltages), | ||
350 | }, | ||
351 | [AB8500_LDO_AUX2] = { | ||
352 | .desc = { | ||
353 | .name = "LDO-AUX2", | ||
354 | .ops = &ab8500_regulator_ops, | ||
355 | .type = REGULATOR_VOLTAGE, | ||
356 | .id = AB8500_LDO_AUX2, | ||
357 | .owner = THIS_MODULE, | ||
358 | .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages), | ||
359 | }, | ||
360 | .min_uV = 1100000, | ||
361 | .max_uV = 3300000, | ||
362 | .update_bank = 0x04, | ||
363 | .update_reg = 0x09, | ||
364 | .update_mask = 0x0c, | ||
365 | .update_val_enable = 0x04, | ||
366 | .voltage_bank = 0x04, | ||
367 | .voltage_reg = 0x20, | ||
368 | .voltage_mask = 0x0f, | ||
369 | .voltages = ldo_vauxn_voltages, | ||
370 | .voltages_len = ARRAY_SIZE(ldo_vauxn_voltages), | ||
371 | }, | ||
372 | [AB8500_LDO_AUX3] = { | ||
373 | .desc = { | ||
374 | .name = "LDO-AUX3", | ||
375 | .ops = &ab8500_regulator_ops, | ||
376 | .type = REGULATOR_VOLTAGE, | ||
377 | .id = AB8500_LDO_AUX3, | ||
378 | .owner = THIS_MODULE, | ||
379 | .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages), | ||
380 | }, | ||
381 | .min_uV = 1100000, | ||
382 | .max_uV = 3300000, | ||
383 | .update_bank = 0x04, | ||
384 | .update_reg = 0x0a, | ||
385 | .update_mask = 0x03, | ||
386 | .update_val_enable = 0x01, | ||
387 | .voltage_bank = 0x04, | ||
388 | .voltage_reg = 0x21, | ||
389 | .voltage_mask = 0x07, | ||
390 | .voltages = ldo_vaux3_voltages, | ||
391 | .voltages_len = ARRAY_SIZE(ldo_vaux3_voltages), | ||
392 | }, | ||
393 | [AB8500_LDO_INTCORE] = { | ||
394 | .desc = { | ||
395 | .name = "LDO-INTCORE", | ||
396 | .ops = &ab8500_regulator_ops, | ||
397 | .type = REGULATOR_VOLTAGE, | ||
398 | .id = AB8500_LDO_INTCORE, | ||
399 | .owner = THIS_MODULE, | ||
400 | .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages), | ||
401 | }, | ||
402 | .min_uV = 1100000, | ||
403 | .max_uV = 3300000, | ||
404 | .update_bank = 0x03, | ||
405 | .update_reg = 0x80, | ||
406 | .update_mask = 0x44, | ||
407 | .update_val_enable = 0x04, | ||
408 | .voltage_bank = 0x03, | ||
409 | .voltage_reg = 0x80, | ||
410 | .voltage_mask = 0x38, | ||
411 | .voltages = ldo_vintcore_voltages, | ||
412 | .voltages_len = ARRAY_SIZE(ldo_vintcore_voltages), | ||
413 | }, | ||
332 | 414 | ||
333 | /* | 415 | /* |
334 | * Fixed Voltage LDOs | 416 | * Fixed Voltage Regulators |
335 | * name, o/p uV, ctrl bank, ctrl reg, enable, disable | 417 | * name, fixed mV, |
418 | * update bank, reg, mask, enable val | ||
336 | */ | 419 | */ |
337 | AB8500_FIXED_LDO(TVOUT, 2000, 0x03, 0x80, 0x2, 0x2), | 420 | [AB8500_LDO_TVOUT] = { |
338 | AB8500_FIXED_LDO(AUDIO, 2000, 0x03, 0x83, 0x2, 0x2), | 421 | .desc = { |
339 | AB8500_FIXED_LDO(ANAMIC1, 2050, 0x03, 0x83, 0x4, 0x4), | 422 | .name = "LDO-TVOUT", |
340 | AB8500_FIXED_LDO(ANAMIC2, 2050, 0x03, 0x83, 0x8, 0x8), | 423 | .ops = &ab8500_regulator_fixed_ops, |
341 | AB8500_FIXED_LDO(DMIC, 1800, 0x03, 0x83, 0x10, 0x10), | 424 | .type = REGULATOR_VOLTAGE, |
342 | AB8500_FIXED_LDO(ANA, 1200, 0x03, 0x83, 0xc, 0x4), | 425 | .id = AB8500_LDO_TVOUT, |
343 | }; | 426 | .owner = THIS_MODULE, |
427 | .n_voltages = 1, | ||
428 | }, | ||
429 | .fixed_uV = 2000000, | ||
430 | .update_bank = 0x03, | ||
431 | .update_reg = 0x80, | ||
432 | .update_mask = 0x82, | ||
433 | .update_val_enable = 0x02, | ||
434 | }, | ||
435 | [AB8500_LDO_AUDIO] = { | ||
436 | .desc = { | ||
437 | .name = "LDO-AUDIO", | ||
438 | .ops = &ab8500_regulator_fixed_ops, | ||
439 | .type = REGULATOR_VOLTAGE, | ||
440 | .id = AB8500_LDO_AUDIO, | ||
441 | .owner = THIS_MODULE, | ||
442 | .n_voltages = 1, | ||
443 | }, | ||
444 | .fixed_uV = 2000000, | ||
445 | .update_bank = 0x03, | ||
446 | .update_reg = 0x83, | ||
447 | .update_mask = 0x02, | ||
448 | .update_val_enable = 0x02, | ||
449 | }, | ||
450 | [AB8500_LDO_ANAMIC1] = { | ||
451 | .desc = { | ||
452 | .name = "LDO-ANAMIC1", | ||
453 | .ops = &ab8500_regulator_fixed_ops, | ||
454 | .type = REGULATOR_VOLTAGE, | ||
455 | .id = AB8500_LDO_ANAMIC1, | ||
456 | .owner = THIS_MODULE, | ||
457 | .n_voltages = 1, | ||
458 | }, | ||
459 | .fixed_uV = 2050000, | ||
460 | .update_bank = 0x03, | ||
461 | .update_reg = 0x83, | ||
462 | .update_mask = 0x08, | ||
463 | .update_val_enable = 0x08, | ||
464 | }, | ||
465 | [AB8500_LDO_ANAMIC2] = { | ||
466 | .desc = { | ||
467 | .name = "LDO-ANAMIC2", | ||
468 | .ops = &ab8500_regulator_fixed_ops, | ||
469 | .type = REGULATOR_VOLTAGE, | ||
470 | .id = AB8500_LDO_ANAMIC2, | ||
471 | .owner = THIS_MODULE, | ||
472 | .n_voltages = 1, | ||
473 | }, | ||
474 | .fixed_uV = 2050000, | ||
475 | .update_bank = 0x03, | ||
476 | .update_reg = 0x83, | ||
477 | .update_mask = 0x10, | ||
478 | .update_val_enable = 0x10, | ||
479 | }, | ||
480 | [AB8500_LDO_DMIC] = { | ||
481 | .desc = { | ||
482 | .name = "LDO-DMIC", | ||
483 | .ops = &ab8500_regulator_fixed_ops, | ||
484 | .type = REGULATOR_VOLTAGE, | ||
485 | .id = AB8500_LDO_DMIC, | ||
486 | .owner = THIS_MODULE, | ||
487 | .n_voltages = 1, | ||
488 | }, | ||
489 | .fixed_uV = 1800000, | ||
490 | .update_bank = 0x03, | ||
491 | .update_reg = 0x83, | ||
492 | .update_mask = 0x04, | ||
493 | .update_val_enable = 0x04, | ||
494 | }, | ||
495 | [AB8500_LDO_ANA] = { | ||
496 | .desc = { | ||
497 | .name = "LDO-ANA", | ||
498 | .ops = &ab8500_regulator_fixed_ops, | ||
499 | .type = REGULATOR_VOLTAGE, | ||
500 | .id = AB8500_LDO_ANA, | ||
501 | .owner = THIS_MODULE, | ||
502 | .n_voltages = 1, | ||
503 | }, | ||
504 | .fixed_uV = 1200000, | ||
505 | .update_bank = 0x04, | ||
506 | .update_reg = 0x06, | ||
507 | .update_mask = 0x0c, | ||
508 | .update_val_enable = 0x04, | ||
509 | }, | ||
344 | 510 | ||
345 | static inline struct ab8500_regulator_info *find_regulator_info(int id) | ||
346 | { | ||
347 | struct ab8500_regulator_info *info; | ||
348 | int i; | ||
349 | 511 | ||
350 | for (i = 0; i < ARRAY_SIZE(ab8500_regulator_info); i++) { | 512 | }; |
351 | info = &ab8500_regulator_info[i]; | ||
352 | if (info->desc.id == id) | ||
353 | return info; | ||
354 | } | ||
355 | return NULL; | ||
356 | } | ||
357 | 513 | ||
358 | static __devinit int ab8500_regulator_probe(struct platform_device *pdev) | 514 | static __devinit int ab8500_regulator_probe(struct platform_device *pdev) |
359 | { | 515 | { |
@@ -366,6 +522,16 @@ static __devinit int ab8500_regulator_probe(struct platform_device *pdev) | |||
366 | return -EINVAL; | 522 | return -EINVAL; |
367 | } | 523 | } |
368 | pdata = dev_get_platdata(ab8500->dev); | 524 | pdata = dev_get_platdata(ab8500->dev); |
525 | if (!pdata) { | ||
526 | dev_err(&pdev->dev, "null pdata\n"); | ||
527 | return -EINVAL; | ||
528 | } | ||
529 | |||
530 | /* make sure the platform data has the correct size */ | ||
531 | if (pdata->num_regulator != ARRAY_SIZE(ab8500_regulator_info)) { | ||
532 | dev_err(&pdev->dev, "platform configuration error\n"); | ||
533 | return -EINVAL; | ||
534 | } | ||
369 | 535 | ||
370 | /* register all regulators */ | 536 | /* register all regulators */ |
371 | for (i = 0; i < ARRAY_SIZE(ab8500_regulator_info); i++) { | 537 | for (i = 0; i < ARRAY_SIZE(ab8500_regulator_info); i++) { |
@@ -374,10 +540,22 @@ static __devinit int ab8500_regulator_probe(struct platform_device *pdev) | |||
374 | /* assign per-regulator data */ | 540 | /* assign per-regulator data */ |
375 | info = &ab8500_regulator_info[i]; | 541 | info = &ab8500_regulator_info[i]; |
376 | info->dev = &pdev->dev; | 542 | info->dev = &pdev->dev; |
377 | info->ab8500 = ab8500; | ||
378 | 543 | ||
544 | /* fix for hardware before ab8500v2.0 */ | ||
545 | if (abx500_get_chip_id(info->dev) < 0x20) { | ||
546 | if (info->desc.id == AB8500_LDO_AUX3) { | ||
547 | info->desc.n_voltages = | ||
548 | ARRAY_SIZE(ldo_vauxn_voltages); | ||
549 | info->voltages = ldo_vauxn_voltages; | ||
550 | info->voltages_len = | ||
551 | ARRAY_SIZE(ldo_vauxn_voltages); | ||
552 | info->voltage_mask = 0xf; | ||
553 | } | ||
554 | } | ||
555 | |||
556 | /* register regulator with framework */ | ||
379 | info->regulator = regulator_register(&info->desc, &pdev->dev, | 557 | info->regulator = regulator_register(&info->desc, &pdev->dev, |
380 | pdata->regulator[i], info); | 558 | &pdata->regulator[i], info); |
381 | if (IS_ERR(info->regulator)) { | 559 | if (IS_ERR(info->regulator)) { |
382 | err = PTR_ERR(info->regulator); | 560 | err = PTR_ERR(info->regulator); |
383 | dev_err(&pdev->dev, "failed to register regulator %s\n", | 561 | dev_err(&pdev->dev, "failed to register regulator %s\n", |
@@ -389,6 +567,9 @@ static __devinit int ab8500_regulator_probe(struct platform_device *pdev) | |||
389 | } | 567 | } |
390 | return err; | 568 | return err; |
391 | } | 569 | } |
570 | |||
571 | dev_vdbg(rdev_get_dev(info->regulator), | ||
572 | "%s-probed\n", info->desc.name); | ||
392 | } | 573 | } |
393 | 574 | ||
394 | return 0; | 575 | return 0; |
@@ -401,6 +582,10 @@ static __devexit int ab8500_regulator_remove(struct platform_device *pdev) | |||
401 | for (i = 0; i < ARRAY_SIZE(ab8500_regulator_info); i++) { | 582 | for (i = 0; i < ARRAY_SIZE(ab8500_regulator_info); i++) { |
402 | struct ab8500_regulator_info *info = NULL; | 583 | struct ab8500_regulator_info *info = NULL; |
403 | info = &ab8500_regulator_info[i]; | 584 | info = &ab8500_regulator_info[i]; |
585 | |||
586 | dev_vdbg(rdev_get_dev(info->regulator), | ||
587 | "%s-remove\n", info->desc.name); | ||
588 | |||
404 | regulator_unregister(info->regulator); | 589 | regulator_unregister(info->regulator); |
405 | } | 590 | } |
406 | 591 | ||