blob: 5fd3b34274cc9665f1453a323e53545596f7392a [file] [log] [blame]
Sundar R IYERc789ca22010-07-13 21:48:56 +05301/*
2 * Copyright (C) ST-Ericsson SA 2010
3 *
4 * License Terms: GNU General Public License v2
5 *
Bengt Jonssone1159e62010-12-10 11:08:44 +01006 * Authors: Sundar Iyer <sundar.iyer@stericsson.com> for ST-Ericsson
7 * Bengt Jonsson <bengt.g.jonsson@stericsson.com> for ST-Ericsson
Lee Jones547f3842013-03-28 16:11:14 +00008 * Daniel Willerud <daniel.willerud@stericsson.com> for ST-Ericsson
Sundar R IYERc789ca22010-07-13 21:48:56 +05309 *
10 * AB8500 peripheral regulators
11 *
Bengt Jonssone1159e62010-12-10 11:08:44 +010012 * AB8500 supports the following regulators:
Bengt Jonssonea05ef32011-03-10 14:43:31 +010013 * VAUX1/2/3, VINTCORE, VTVOUT, VUSB, VAUDIO, VAMIC1/2, VDMIC, VANA
Lee Jones547f3842013-03-28 16:11:14 +000014 *
15 * AB8505 supports the following regulators:
16 * VAUX1/2/3/4/5/6, VINTCORE, VADC, VUSB, VAUDIO, VAMIC1/2, VDMIC, VANA
Sundar R IYERc789ca22010-07-13 21:48:56 +053017 */
18#include <linux/init.h>
19#include <linux/kernel.h>
Paul Gortmaker65602c32011-07-17 16:28:23 -040020#include <linux/module.h>
Sundar R IYERc789ca22010-07-13 21:48:56 +053021#include <linux/err.h>
22#include <linux/platform_device.h>
Mattias Wallin47c16972010-09-10 17:47:56 +020023#include <linux/mfd/abx500.h>
Linus Walleijee66e652011-12-02 14:16:33 +010024#include <linux/mfd/abx500/ab8500.h>
Lee Jones3a8334b2012-05-17 14:45:16 +010025#include <linux/of.h>
26#include <linux/regulator/of_regulator.h>
Sundar R IYERc789ca22010-07-13 21:48:56 +053027#include <linux/regulator/driver.h>
28#include <linux/regulator/machine.h>
29#include <linux/regulator/ab8500.h>
Lee Jones3a8334b2012-05-17 14:45:16 +010030#include <linux/slab.h>
Sundar R IYERc789ca22010-07-13 21:48:56 +053031
32/**
Lee Jones3fe52282013-04-02 13:24:12 +010033 * struct ab8500_shared_mode - is used when mode is shared between
34 * two regulators.
35 * @shared_regulator: pointer to the other sharing regulator
36 * @lp_mode_req: low power mode requested by this regulator
37 */
38struct ab8500_shared_mode {
39 struct ab8500_regulator_info *shared_regulator;
40 bool lp_mode_req;
41};
42
43/**
Sundar R IYERc789ca22010-07-13 21:48:56 +053044 * struct ab8500_regulator_info - ab8500 regulator information
Bengt Jonssone1159e62010-12-10 11:08:44 +010045 * @dev: device pointer
Sundar R IYERc789ca22010-07-13 21:48:56 +053046 * @desc: regulator description
Sundar R IYERc789ca22010-07-13 21:48:56 +053047 * @regulator_dev: regulator device
Lee Jones3fe52282013-04-02 13:24:12 +010048 * @shared_mode: used when mode is shared between two regulators
Bengt Jonsson7ce46692013-03-21 15:59:00 +000049 * @load_lp_uA: maximum load in idle (low power) mode
Mattias Wallin47c16972010-09-10 17:47:56 +020050 * @update_bank: bank to control on/off
Sundar R IYERc789ca22010-07-13 21:48:56 +053051 * @update_reg: register to control on/off
Emeric Vigierbd28a152013-03-21 15:58:59 +000052 * @update_mask: mask to enable/disable and set mode of regulator
53 * @update_val: bits holding the regulator current mode
54 * @update_val_idle: bits to enable the regulator in idle (low power) mode
55 * @update_val_normal: bits to enable the regulator in normal (high power) mode
Lee Jones3fe52282013-04-02 13:24:12 +010056 * @mode_bank: bank with location of mode register
57 * @mode_reg: mode register
58 * @mode_mask: mask for setting mode
59 * @mode_val_idle: mode setting for low power
60 * @mode_val_normal: mode setting for normal power
Mattias Wallin47c16972010-09-10 17:47:56 +020061 * @voltage_bank: bank to control regulator voltage
Sundar R IYERc789ca22010-07-13 21:48:56 +053062 * @voltage_reg: register to control regulator voltage
63 * @voltage_mask: mask to control regulator voltage
Linus Walleija0a70142012-08-20 18:41:35 +020064 * @voltage_shift: shift to control regulator voltage
Sundar R IYERc789ca22010-07-13 21:48:56 +053065 */
66struct ab8500_regulator_info {
67 struct device *dev;
68 struct regulator_desc desc;
Sundar R IYERc789ca22010-07-13 21:48:56 +053069 struct regulator_dev *regulator;
Lee Jones3fe52282013-04-02 13:24:12 +010070 struct ab8500_shared_mode *shared_mode;
Bengt Jonsson7ce46692013-03-21 15:59:00 +000071 int load_lp_uA;
Mattias Wallin47c16972010-09-10 17:47:56 +020072 u8 update_bank;
73 u8 update_reg;
Bengt Jonssone1159e62010-12-10 11:08:44 +010074 u8 update_mask;
Emeric Vigierbd28a152013-03-21 15:58:59 +000075 u8 update_val;
76 u8 update_val_idle;
77 u8 update_val_normal;
Lee Jones3fe52282013-04-02 13:24:12 +010078 u8 mode_bank;
79 u8 mode_reg;
80 u8 mode_mask;
81 u8 mode_val_idle;
82 u8 mode_val_normal;
Mattias Wallin47c16972010-09-10 17:47:56 +020083 u8 voltage_bank;
84 u8 voltage_reg;
85 u8 voltage_mask;
Linus Walleija0a70142012-08-20 18:41:35 +020086 u8 voltage_shift;
Lee Jonesd7607ba2013-04-02 13:24:11 +010087 struct {
88 u8 voltage_limit;
89 u8 voltage_bank;
90 u8 voltage_reg;
91 u8 voltage_mask;
92 u8 voltage_shift;
93 } expand_register;
Sundar R IYERc789ca22010-07-13 21:48:56 +053094};
95
96/* voltage tables for the vauxn/vintcore supplies */
Axel Linec1cc4d2012-05-20 10:33:35 +080097static const unsigned int ldo_vauxn_voltages[] = {
Sundar R IYERc789ca22010-07-13 21:48:56 +053098 1100000,
99 1200000,
100 1300000,
101 1400000,
102 1500000,
103 1800000,
104 1850000,
105 1900000,
106 2500000,
107 2650000,
108 2700000,
109 2750000,
110 2800000,
111 2900000,
112 3000000,
113 3300000,
114};
115
Axel Linec1cc4d2012-05-20 10:33:35 +0800116static const unsigned int ldo_vaux3_voltages[] = {
Bengt Jonsson2b751512010-12-10 11:08:43 +0100117 1200000,
118 1500000,
119 1800000,
120 2100000,
121 2500000,
122 2750000,
123 2790000,
124 2910000,
125};
126
Lee Jones62ab4112013-03-28 16:11:18 +0000127static const unsigned int ldo_vaux56_voltages[] = {
Lee Jones547f3842013-03-28 16:11:14 +0000128 1800000,
129 1050000,
130 1100000,
131 1200000,
132 1500000,
133 2200000,
134 2500000,
135 2790000,
136};
137
Lee Jones62ab4112013-03-28 16:11:18 +0000138static const unsigned int ldo_vaux3_ab8540_voltages[] = {
Lee Jonesae0a9a32013-03-28 16:11:16 +0000139 1200000,
140 1500000,
141 1800000,
142 2100000,
143 2500000,
144 2750000,
145 2790000,
146 2910000,
147 3050000,
148};
149
Zhenhua HUANG684d5ce2013-04-02 13:24:15 +0100150static const unsigned int ldo_vaux56_ab8540_voltages[] = {
151 750000, 760000, 770000, 780000, 790000, 800000,
152 810000, 820000, 830000, 840000, 850000, 860000,
153 870000, 880000, 890000, 900000, 910000, 920000,
154 930000, 940000, 950000, 960000, 970000, 980000,
155 990000, 1000000, 1010000, 1020000, 1030000,
156 1040000, 1050000, 1060000, 1070000, 1080000,
157 1090000, 1100000, 1110000, 1120000, 1130000,
158 1140000, 1150000, 1160000, 1170000, 1180000,
159 1190000, 1200000, 1210000, 1220000, 1230000,
160 1240000, 1250000, 1260000, 1270000, 1280000,
161 1290000, 1300000, 1310000, 1320000, 1330000,
162 1340000, 1350000, 1360000, 1800000, 2790000,
163};
164
Axel Linec1cc4d2012-05-20 10:33:35 +0800165static const unsigned int ldo_vintcore_voltages[] = {
Sundar R IYERc789ca22010-07-13 21:48:56 +0530166 1200000,
167 1225000,
168 1250000,
169 1275000,
170 1300000,
171 1325000,
172 1350000,
173};
174
Lee Jones62ab4112013-03-28 16:11:18 +0000175static const unsigned int ldo_sdio_voltages[] = {
Lee Jonesae0a9a32013-03-28 16:11:16 +0000176 1160000,
177 1050000,
178 1100000,
179 1500000,
180 1800000,
181 2200000,
182 2910000,
183 3050000,
184};
185
Lee Jonesb080c782013-03-28 16:11:17 +0000186static const unsigned int fixed_1200000_voltage[] = {
187 1200000,
188};
189
190static const unsigned int fixed_1800000_voltage[] = {
191 1800000,
192};
193
194static const unsigned int fixed_2000000_voltage[] = {
195 2000000,
196};
197
198static const unsigned int fixed_2050000_voltage[] = {
199 2050000,
200};
201
202static const unsigned int fixed_3300000_voltage[] = {
203 3300000,
204};
205
Lee Jones8a3b1b82013-04-02 13:24:09 +0100206static const unsigned int ldo_vana_voltages[] = {
207 1050000,
208 1075000,
209 1100000,
210 1125000,
211 1150000,
212 1175000,
213 1200000,
214 1225000,
215};
216
217static const unsigned int ldo_vaudio_voltages[] = {
218 2000000,
219 2100000,
220 2200000,
221 2300000,
222 2400000,
223 2500000,
224 2600000,
225 2600000, /* Duplicated in Vaudio and IsoUicc Control register. */
226};
227
Lee Jones4c84b4d2013-04-02 13:24:13 +0100228static const unsigned int ldo_vdmic_voltages[] = {
229 1800000,
230 1900000,
231 2000000,
232 2850000,
233};
234
Lee Jones3fe52282013-04-02 13:24:12 +0100235static DEFINE_MUTEX(shared_mode_mutex);
236static struct ab8500_shared_mode ldo_anamic1_shared;
237static struct ab8500_shared_mode ldo_anamic2_shared;
Lee Jones4c84b4d2013-04-02 13:24:13 +0100238static struct ab8500_shared_mode ab8540_ldo_anamic1_shared;
239static struct ab8500_shared_mode ab8540_ldo_anamic2_shared;
Lee Jones3fe52282013-04-02 13:24:12 +0100240
Sundar R IYERc789ca22010-07-13 21:48:56 +0530241static int ab8500_regulator_enable(struct regulator_dev *rdev)
242{
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100243 int ret;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530244 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
245
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100246 if (info == NULL) {
247 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
Sundar R IYERc789ca22010-07-13 21:48:56 +0530248 return -EINVAL;
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100249 }
Sundar R IYERc789ca22010-07-13 21:48:56 +0530250
Mattias Wallin47c16972010-09-10 17:47:56 +0200251 ret = abx500_mask_and_set_register_interruptible(info->dev,
Bengt Jonssone1159e62010-12-10 11:08:44 +0100252 info->update_bank, info->update_reg,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000253 info->update_mask, info->update_val);
Axel Linf71bf522013-03-26 16:13:14 +0800254 if (ret < 0) {
Sundar R IYERc789ca22010-07-13 21:48:56 +0530255 dev_err(rdev_get_dev(rdev),
256 "couldn't set enable bits for regulator\n");
Axel Linf71bf522013-03-26 16:13:14 +0800257 return ret;
258 }
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100259
260 dev_vdbg(rdev_get_dev(rdev),
261 "%s-enable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
262 info->desc.name, info->update_bank, info->update_reg,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000263 info->update_mask, info->update_val);
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100264
Sundar R IYERc789ca22010-07-13 21:48:56 +0530265 return ret;
266}
267
268static int ab8500_regulator_disable(struct regulator_dev *rdev)
269{
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100270 int ret;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530271 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
272
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100273 if (info == NULL) {
274 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
Sundar R IYERc789ca22010-07-13 21:48:56 +0530275 return -EINVAL;
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100276 }
Sundar R IYERc789ca22010-07-13 21:48:56 +0530277
Mattias Wallin47c16972010-09-10 17:47:56 +0200278 ret = abx500_mask_and_set_register_interruptible(info->dev,
Bengt Jonssone1159e62010-12-10 11:08:44 +0100279 info->update_bank, info->update_reg,
280 info->update_mask, 0x0);
Axel Linf71bf522013-03-26 16:13:14 +0800281 if (ret < 0) {
Sundar R IYERc789ca22010-07-13 21:48:56 +0530282 dev_err(rdev_get_dev(rdev),
283 "couldn't set disable bits for regulator\n");
Axel Linf71bf522013-03-26 16:13:14 +0800284 return ret;
285 }
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100286
287 dev_vdbg(rdev_get_dev(rdev),
288 "%s-disable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
289 info->desc.name, info->update_bank, info->update_reg,
290 info->update_mask, 0x0);
291
Sundar R IYERc789ca22010-07-13 21:48:56 +0530292 return ret;
293}
294
Axel Lin438e6952013-04-07 23:12:28 +0800295static int ab8500_regulator_is_enabled(struct regulator_dev *rdev)
296{
297 int ret;
298 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
299 u8 regval;
300
301 if (info == NULL) {
302 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
303 return -EINVAL;
304 }
305
306 ret = abx500_get_register_interruptible(info->dev,
307 info->update_bank, info->update_reg, &regval);
308 if (ret < 0) {
309 dev_err(rdev_get_dev(rdev),
310 "couldn't read 0x%x register\n", info->update_reg);
311 return ret;
312 }
313
314 dev_vdbg(rdev_get_dev(rdev),
315 "%s-is_enabled (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
316 " 0x%x\n",
317 info->desc.name, info->update_bank, info->update_reg,
318 info->update_mask, regval);
319
320 if (regval & info->update_mask)
321 return 1;
322 else
323 return 0;
324}
325
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000326static unsigned int ab8500_regulator_get_optimum_mode(
327 struct regulator_dev *rdev, int input_uV,
328 int output_uV, int load_uA)
329{
330 unsigned int mode;
331
332 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
333
334 if (info == NULL) {
335 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
336 return -EINVAL;
337 }
338
339 if (load_uA <= info->load_lp_uA)
340 mode = REGULATOR_MODE_IDLE;
341 else
342 mode = REGULATOR_MODE_NORMAL;
343
344 return mode;
345}
346
Emeric Vigierbd28a152013-03-21 15:58:59 +0000347static int ab8500_regulator_set_mode(struct regulator_dev *rdev,
348 unsigned int mode)
349{
Lee Jones3fe52282013-04-02 13:24:12 +0100350 int ret = 0;
351 u8 bank;
352 u8 reg;
353 u8 mask;
354 u8 val;
355 bool dmr = false; /* Dedicated mode register */
Emeric Vigierbd28a152013-03-21 15:58:59 +0000356 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
357
358 if (info == NULL) {
359 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
360 return -EINVAL;
361 }
362
Lee Jones3fe52282013-04-02 13:24:12 +0100363 if (info->shared_mode) {
364 /*
365 * Special case where mode is shared between two regulators.
366 */
367 struct ab8500_shared_mode *sm = info->shared_mode;
368 mutex_lock(&shared_mode_mutex);
369
370 if (mode == REGULATOR_MODE_IDLE) {
371 sm->lp_mode_req = true; /* Low power mode requested */
372 if (!((sm->shared_regulator)->
373 shared_mode->lp_mode_req)) {
374 mutex_unlock(&shared_mode_mutex);
375 return 0; /* Other regulator prevent LP mode */
376 }
377 } else {
378 sm->lp_mode_req = false;
379 }
Emeric Vigierbd28a152013-03-21 15:58:59 +0000380 }
381
Lee Jones3fe52282013-04-02 13:24:12 +0100382 if (info->mode_mask) {
383 /* Dedicated register for handling mode */
384
385 dmr = true;
386
387 switch (mode) {
388 case REGULATOR_MODE_NORMAL:
389 val = info->mode_val_normal;
390 break;
391 case REGULATOR_MODE_IDLE:
392 val = info->mode_val_idle;
393 break;
394 default:
Axel Linf04adc52013-04-09 20:15:06 +0800395 ret = -EINVAL;
396 goto out_unlock;
Lee Jones3fe52282013-04-02 13:24:12 +0100397 }
398
399 bank = info->mode_bank;
400 reg = info->mode_reg;
401 mask = info->mode_mask;
402 } else {
403 /* Mode register same as enable register */
404
405 switch (mode) {
406 case REGULATOR_MODE_NORMAL:
Lee Jones3fe52282013-04-02 13:24:12 +0100407 val = info->update_val_normal;
408 break;
409 case REGULATOR_MODE_IDLE:
Lee Jones3fe52282013-04-02 13:24:12 +0100410 val = info->update_val_idle;
411 break;
412 default:
Axel Linf04adc52013-04-09 20:15:06 +0800413 ret = -EINVAL;
414 goto out_unlock;
Lee Jones3fe52282013-04-02 13:24:12 +0100415 }
416
417 bank = info->update_bank;
418 reg = info->update_reg;
419 mask = info->update_mask;
420 }
421
Axel Lin438e6952013-04-07 23:12:28 +0800422 if (dmr || ab8500_regulator_is_enabled(rdev)) {
Emeric Vigierbd28a152013-03-21 15:58:59 +0000423 ret = abx500_mask_and_set_register_interruptible(info->dev,
Lee Jones3fe52282013-04-02 13:24:12 +0100424 bank, reg, mask, val);
Axel Linf04adc52013-04-09 20:15:06 +0800425 if (ret < 0) {
Emeric Vigierbd28a152013-03-21 15:58:59 +0000426 dev_err(rdev_get_dev(rdev),
427 "couldn't set regulator mode\n");
Axel Linf04adc52013-04-09 20:15:06 +0800428 goto out_unlock;
429 }
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000430
431 dev_vdbg(rdev_get_dev(rdev),
432 "%s-set_mode (bank, reg, mask, value): "
433 "0x%x, 0x%x, 0x%x, 0x%x\n",
Lee Jones3fe52282013-04-02 13:24:12 +0100434 info->desc.name, bank, reg,
435 mask, val);
Emeric Vigierbd28a152013-03-21 15:58:59 +0000436 }
437
Axel Linf04adc52013-04-09 20:15:06 +0800438 if (!dmr)
439 info->update_val = val;
440
441out_unlock:
Lee Jones3fe52282013-04-02 13:24:12 +0100442 if (info->shared_mode)
443 mutex_unlock(&shared_mode_mutex);
Axel Lin742a7322013-03-28 17:23:00 +0800444
Lee Jones3fe52282013-04-02 13:24:12 +0100445 return ret;
Emeric Vigierbd28a152013-03-21 15:58:59 +0000446}
447
448static unsigned int ab8500_regulator_get_mode(struct regulator_dev *rdev)
449{
450 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
451 int ret;
Lee Jones3fe52282013-04-02 13:24:12 +0100452 u8 val;
453 u8 val_normal;
454 u8 val_idle;
Emeric Vigierbd28a152013-03-21 15:58:59 +0000455
456 if (info == NULL) {
457 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
458 return -EINVAL;
459 }
460
Lee Jones3fe52282013-04-02 13:24:12 +0100461 /* Need special handling for shared mode */
462 if (info->shared_mode) {
463 if (info->shared_mode->lp_mode_req)
464 return REGULATOR_MODE_IDLE;
465 else
466 return REGULATOR_MODE_NORMAL;
467 }
468
469 if (info->mode_mask) {
470 /* Dedicated register for handling mode */
471 ret = abx500_get_register_interruptible(info->dev,
472 info->mode_bank, info->mode_reg, &val);
473 val = val & info->mode_mask;
474
475 val_normal = info->mode_val_normal;
476 val_idle = info->mode_val_idle;
477 } else {
478 /* Mode register same as enable register */
479 val = info->update_val;
480 val_normal = info->update_val_normal;
481 val_idle = info->update_val_idle;
482 }
483
484 if (val == val_normal)
Emeric Vigierbd28a152013-03-21 15:58:59 +0000485 ret = REGULATOR_MODE_NORMAL;
Lee Jones3fe52282013-04-02 13:24:12 +0100486 else if (val == val_idle)
Emeric Vigierbd28a152013-03-21 15:58:59 +0000487 ret = REGULATOR_MODE_IDLE;
488 else
489 ret = -EINVAL;
490
491 return ret;
492}
493
Axel Lin3bf6e902012-02-24 17:15:45 +0800494static int ab8500_regulator_get_voltage_sel(struct regulator_dev *rdev)
Sundar R IYERc789ca22010-07-13 21:48:56 +0530495{
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100496 int ret, val;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530497 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100498 u8 regval;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530499
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100500 if (info == NULL) {
501 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
Sundar R IYERc789ca22010-07-13 21:48:56 +0530502 return -EINVAL;
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100503 }
Sundar R IYERc789ca22010-07-13 21:48:56 +0530504
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100505 ret = abx500_get_register_interruptible(info->dev,
506 info->voltage_bank, info->voltage_reg, &regval);
Sundar R IYERc789ca22010-07-13 21:48:56 +0530507 if (ret < 0) {
508 dev_err(rdev_get_dev(rdev),
509 "couldn't read voltage reg for regulator\n");
510 return ret;
511 }
512
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100513 dev_vdbg(rdev_get_dev(rdev),
Linus Walleija0a70142012-08-20 18:41:35 +0200514 "%s-get_voltage (bank, reg, mask, shift, value): "
515 "0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n",
516 info->desc.name, info->voltage_bank,
517 info->voltage_reg, info->voltage_mask,
518 info->voltage_shift, regval);
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100519
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100520 val = regval & info->voltage_mask;
Linus Walleija0a70142012-08-20 18:41:35 +0200521 return val >> info->voltage_shift;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530522}
523
Lee Jonesd7607ba2013-04-02 13:24:11 +0100524static int ab8540_aux3_regulator_get_voltage_sel(struct regulator_dev *rdev)
525{
Axel Lin241896c2013-04-10 14:46:20 +0800526 int ret;
Lee Jonesd7607ba2013-04-02 13:24:11 +0100527 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
528 u8 regval, regval_expand;
529
530 if (info == NULL) {
531 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
532 return -EINVAL;
533 }
534
535 ret = abx500_get_register_interruptible(info->dev,
Lee Jonesd7607ba2013-04-02 13:24:11 +0100536 info->expand_register.voltage_bank,
537 info->expand_register.voltage_reg, &regval_expand);
Axel Lin241896c2013-04-10 14:46:20 +0800538 if (ret < 0) {
539 dev_err(rdev_get_dev(rdev),
540 "couldn't read voltage expand reg for regulator\n");
541 return ret;
542 }
Lee Jonesd7607ba2013-04-02 13:24:11 +0100543
Axel Lin241896c2013-04-10 14:46:20 +0800544 dev_vdbg(rdev_get_dev(rdev),
545 "%s-get_voltage expand (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
546 info->desc.name, info->expand_register.voltage_bank,
547 info->expand_register.voltage_reg,
548 info->expand_register.voltage_mask, regval_expand);
549
550 if (regval_expand & info->expand_register.voltage_mask)
551 return info->expand_register.voltage_limit;
552
553 ret = abx500_get_register_interruptible(info->dev,
554 info->voltage_bank, info->voltage_reg, &regval);
Lee Jonesd7607ba2013-04-02 13:24:11 +0100555 if (ret < 0) {
556 dev_err(rdev_get_dev(rdev),
557 "couldn't read voltage reg for regulator\n");
558 return ret;
559 }
560
561 dev_vdbg(rdev_get_dev(rdev),
Axel Lin241896c2013-04-10 14:46:20 +0800562 "%s-get_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
563 info->desc.name, info->voltage_bank, info->voltage_reg,
564 info->voltage_mask, regval);
Lee Jonesd7607ba2013-04-02 13:24:11 +0100565
Axel Lin241896c2013-04-10 14:46:20 +0800566 return (regval & info->voltage_mask) >> info->voltage_shift;
Lee Jonesd7607ba2013-04-02 13:24:11 +0100567}
568
Axel Linae713d32012-03-20 09:51:08 +0800569static int ab8500_regulator_set_voltage_sel(struct regulator_dev *rdev,
570 unsigned selector)
Sundar R IYERc789ca22010-07-13 21:48:56 +0530571{
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100572 int ret;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530573 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100574 u8 regval;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530575
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100576 if (info == NULL) {
577 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
Sundar R IYERc789ca22010-07-13 21:48:56 +0530578 return -EINVAL;
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100579 }
Sundar R IYERc789ca22010-07-13 21:48:56 +0530580
Sundar R IYERc789ca22010-07-13 21:48:56 +0530581 /* set the registers for the request */
Linus Walleija0a70142012-08-20 18:41:35 +0200582 regval = (u8)selector << info->voltage_shift;
Mattias Wallin47c16972010-09-10 17:47:56 +0200583 ret = abx500_mask_and_set_register_interruptible(info->dev,
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100584 info->voltage_bank, info->voltage_reg,
585 info->voltage_mask, regval);
Sundar R IYERc789ca22010-07-13 21:48:56 +0530586 if (ret < 0)
587 dev_err(rdev_get_dev(rdev),
588 "couldn't set voltage reg for regulator\n");
589
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100590 dev_vdbg(rdev_get_dev(rdev),
591 "%s-set_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
592 " 0x%x\n",
593 info->desc.name, info->voltage_bank, info->voltage_reg,
594 info->voltage_mask, regval);
595
Sundar R IYERc789ca22010-07-13 21:48:56 +0530596 return ret;
597}
598
Lee Jonesd7607ba2013-04-02 13:24:11 +0100599static int ab8540_aux3_regulator_set_voltage_sel(struct regulator_dev *rdev,
600 unsigned selector)
601{
602 int ret;
603 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
604 u8 regval;
605
606 if (info == NULL) {
607 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
608 return -EINVAL;
609 }
610
611 if (selector >= info->expand_register.voltage_limit) {
612 /* Vaux3 bit4 has different layout */
613 regval = (u8)selector << info->expand_register.voltage_shift;
614 ret = abx500_mask_and_set_register_interruptible(info->dev,
615 info->expand_register.voltage_bank,
616 info->expand_register.voltage_reg,
617 info->expand_register.voltage_mask,
618 regval);
619 } else {
620 /* set the registers for the request */
621 regval = (u8)selector << info->voltage_shift;
622 ret = abx500_mask_and_set_register_interruptible(info->dev,
623 info->voltage_bank, info->voltage_reg,
624 info->voltage_mask, regval);
625 }
626 if (ret < 0)
627 dev_err(rdev_get_dev(rdev),
628 "couldn't set voltage reg for regulator\n");
629
630 dev_vdbg(rdev_get_dev(rdev),
631 "%s-set_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
632 " 0x%x\n",
633 info->desc.name, info->voltage_bank, info->voltage_reg,
634 info->voltage_mask, regval);
635
636 return ret;
637}
638
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000639static struct regulator_ops ab8500_regulator_volt_mode_ops = {
640 .enable = ab8500_regulator_enable,
641 .disable = ab8500_regulator_disable,
642 .is_enabled = ab8500_regulator_is_enabled,
643 .get_optimum_mode = ab8500_regulator_get_optimum_mode,
644 .set_mode = ab8500_regulator_set_mode,
645 .get_mode = ab8500_regulator_get_mode,
646 .get_voltage_sel = ab8500_regulator_get_voltage_sel,
647 .set_voltage_sel = ab8500_regulator_set_voltage_sel,
648 .list_voltage = regulator_list_voltage_table,
Sundar R IYERc789ca22010-07-13 21:48:56 +0530649};
650
Lee Jonesd7607ba2013-04-02 13:24:11 +0100651static struct regulator_ops ab8540_aux3_regulator_volt_mode_ops = {
652 .enable = ab8500_regulator_enable,
653 .disable = ab8500_regulator_disable,
654 .get_optimum_mode = ab8500_regulator_get_optimum_mode,
655 .set_mode = ab8500_regulator_set_mode,
656 .get_mode = ab8500_regulator_get_mode,
657 .is_enabled = ab8500_regulator_is_enabled,
658 .get_voltage_sel = ab8540_aux3_regulator_get_voltage_sel,
659 .set_voltage_sel = ab8540_aux3_regulator_set_voltage_sel,
660 .list_voltage = regulator_list_voltage_table,
Lee Jonesd7607ba2013-04-02 13:24:11 +0100661};
662
Lee Jones8a3b1b82013-04-02 13:24:09 +0100663static struct regulator_ops ab8500_regulator_volt_ops = {
664 .enable = ab8500_regulator_enable,
665 .disable = ab8500_regulator_disable,
666 .is_enabled = ab8500_regulator_is_enabled,
667 .get_voltage_sel = ab8500_regulator_get_voltage_sel,
668 .set_voltage_sel = ab8500_regulator_set_voltage_sel,
669 .list_voltage = regulator_list_voltage_table,
Lee Jones8a3b1b82013-04-02 13:24:09 +0100670};
671
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000672static struct regulator_ops ab8500_regulator_mode_ops = {
673 .enable = ab8500_regulator_enable,
674 .disable = ab8500_regulator_disable,
675 .is_enabled = ab8500_regulator_is_enabled,
676 .get_optimum_mode = ab8500_regulator_get_optimum_mode,
677 .set_mode = ab8500_regulator_set_mode,
678 .get_mode = ab8500_regulator_get_mode,
Axel Lind7816ab2013-04-02 13:24:22 +0100679 .list_voltage = regulator_list_voltage_table,
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000680};
681
682static struct regulator_ops ab8500_regulator_ops = {
683 .enable = ab8500_regulator_enable,
684 .disable = ab8500_regulator_disable,
685 .is_enabled = ab8500_regulator_is_enabled,
Axel Lind7816ab2013-04-02 13:24:22 +0100686 .list_voltage = regulator_list_voltage_table,
Sundar R IYERc789ca22010-07-13 21:48:56 +0530687};
688
Lee Jones3fe52282013-04-02 13:24:12 +0100689static struct regulator_ops ab8500_regulator_anamic_mode_ops = {
690 .enable = ab8500_regulator_enable,
691 .disable = ab8500_regulator_disable,
692 .is_enabled = ab8500_regulator_is_enabled,
693 .set_mode = ab8500_regulator_set_mode,
694 .get_mode = ab8500_regulator_get_mode,
695 .list_voltage = regulator_list_voltage_table,
696};
697
Lee Jones8e6a8d72013-03-28 16:11:11 +0000698/* AB8500 regulator information */
Bengt Jonsson6909b452010-12-10 11:08:47 +0100699static struct ab8500_regulator_info
700 ab8500_regulator_info[AB8500_NUM_REGULATORS] = {
Sundar R IYERc789ca22010-07-13 21:48:56 +0530701 /*
Bengt Jonssone1159e62010-12-10 11:08:44 +0100702 * Variable Voltage Regulators
703 * name, min mV, max mV,
704 * update bank, reg, mask, enable val
Axel Linec1cc4d2012-05-20 10:33:35 +0800705 * volt bank, reg, mask
Sundar R IYERc789ca22010-07-13 21:48:56 +0530706 */
Bengt Jonsson6909b452010-12-10 11:08:47 +0100707 [AB8500_LDO_AUX1] = {
708 .desc = {
709 .name = "LDO-AUX1",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000710 .ops = &ab8500_regulator_volt_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100711 .type = REGULATOR_VOLTAGE,
712 .id = AB8500_LDO_AUX1,
713 .owner = THIS_MODULE,
714 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Axel Linec1cc4d2012-05-20 10:33:35 +0800715 .volt_table = ldo_vauxn_voltages,
Axel Lin530158b2013-03-27 17:47:22 +0800716 .enable_time = 200,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100717 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000718 .load_lp_uA = 5000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100719 .update_bank = 0x04,
720 .update_reg = 0x09,
721 .update_mask = 0x03,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000722 .update_val = 0x01,
723 .update_val_idle = 0x03,
724 .update_val_normal = 0x01,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100725 .voltage_bank = 0x04,
726 .voltage_reg = 0x1f,
727 .voltage_mask = 0x0f,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100728 },
729 [AB8500_LDO_AUX2] = {
730 .desc = {
731 .name = "LDO-AUX2",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000732 .ops = &ab8500_regulator_volt_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100733 .type = REGULATOR_VOLTAGE,
734 .id = AB8500_LDO_AUX2,
735 .owner = THIS_MODULE,
736 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Axel Linec1cc4d2012-05-20 10:33:35 +0800737 .volt_table = ldo_vauxn_voltages,
Axel Lin530158b2013-03-27 17:47:22 +0800738 .enable_time = 200,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100739 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000740 .load_lp_uA = 5000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100741 .update_bank = 0x04,
742 .update_reg = 0x09,
743 .update_mask = 0x0c,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000744 .update_val = 0x04,
745 .update_val_idle = 0x0c,
746 .update_val_normal = 0x04,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100747 .voltage_bank = 0x04,
748 .voltage_reg = 0x20,
749 .voltage_mask = 0x0f,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100750 },
751 [AB8500_LDO_AUX3] = {
752 .desc = {
753 .name = "LDO-AUX3",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000754 .ops = &ab8500_regulator_volt_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100755 .type = REGULATOR_VOLTAGE,
756 .id = AB8500_LDO_AUX3,
757 .owner = THIS_MODULE,
758 .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages),
Axel Linec1cc4d2012-05-20 10:33:35 +0800759 .volt_table = ldo_vaux3_voltages,
Axel Lin530158b2013-03-27 17:47:22 +0800760 .enable_time = 450,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100761 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000762 .load_lp_uA = 5000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100763 .update_bank = 0x04,
764 .update_reg = 0x0a,
765 .update_mask = 0x03,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000766 .update_val = 0x01,
767 .update_val_idle = 0x03,
768 .update_val_normal = 0x01,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100769 .voltage_bank = 0x04,
770 .voltage_reg = 0x21,
771 .voltage_mask = 0x07,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100772 },
773 [AB8500_LDO_INTCORE] = {
774 .desc = {
775 .name = "LDO-INTCORE",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000776 .ops = &ab8500_regulator_volt_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100777 .type = REGULATOR_VOLTAGE,
778 .id = AB8500_LDO_INTCORE,
779 .owner = THIS_MODULE,
780 .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
Axel Linec1cc4d2012-05-20 10:33:35 +0800781 .volt_table = ldo_vintcore_voltages,
Axel Lin530158b2013-03-27 17:47:22 +0800782 .enable_time = 750,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100783 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000784 .load_lp_uA = 5000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100785 .update_bank = 0x03,
786 .update_reg = 0x80,
787 .update_mask = 0x44,
Lee Jonescc40dc22013-03-21 15:59:41 +0000788 .update_val = 0x44,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000789 .update_val_idle = 0x44,
790 .update_val_normal = 0x04,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100791 .voltage_bank = 0x03,
792 .voltage_reg = 0x80,
793 .voltage_mask = 0x38,
Linus Walleija0a70142012-08-20 18:41:35 +0200794 .voltage_shift = 3,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100795 },
Sundar R IYERc789ca22010-07-13 21:48:56 +0530796
797 /*
Bengt Jonssone1159e62010-12-10 11:08:44 +0100798 * Fixed Voltage Regulators
799 * name, fixed mV,
800 * update bank, reg, mask, enable val
Sundar R IYERc789ca22010-07-13 21:48:56 +0530801 */
Bengt Jonsson6909b452010-12-10 11:08:47 +0100802 [AB8500_LDO_TVOUT] = {
803 .desc = {
804 .name = "LDO-TVOUT",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000805 .ops = &ab8500_regulator_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100806 .type = REGULATOR_VOLTAGE,
807 .id = AB8500_LDO_TVOUT,
808 .owner = THIS_MODULE,
809 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +0000810 .volt_table = fixed_2000000_voltage,
Lee Jonesed3c1382013-03-28 16:11:12 +0000811 .enable_time = 500,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100812 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000813 .load_lp_uA = 1000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100814 .update_bank = 0x03,
815 .update_reg = 0x80,
816 .update_mask = 0x82,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000817 .update_val = 0x02,
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000818 .update_val_idle = 0x82,
819 .update_val_normal = 0x02,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100820 },
821 [AB8500_LDO_AUDIO] = {
822 .desc = {
823 .name = "LDO-AUDIO",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000824 .ops = &ab8500_regulator_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100825 .type = REGULATOR_VOLTAGE,
826 .id = AB8500_LDO_AUDIO,
827 .owner = THIS_MODULE,
828 .n_voltages = 1,
Axel Lin530158b2013-03-27 17:47:22 +0800829 .enable_time = 140,
Lee Jonesb080c782013-03-28 16:11:17 +0000830 .volt_table = fixed_2000000_voltage,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100831 },
Bengt Jonsson6909b452010-12-10 11:08:47 +0100832 .update_bank = 0x03,
833 .update_reg = 0x83,
834 .update_mask = 0x02,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000835 .update_val = 0x02,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100836 },
837 [AB8500_LDO_ANAMIC1] = {
838 .desc = {
839 .name = "LDO-ANAMIC1",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000840 .ops = &ab8500_regulator_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100841 .type = REGULATOR_VOLTAGE,
842 .id = AB8500_LDO_ANAMIC1,
843 .owner = THIS_MODULE,
844 .n_voltages = 1,
Axel Lin530158b2013-03-27 17:47:22 +0800845 .enable_time = 500,
Lee Jonesb080c782013-03-28 16:11:17 +0000846 .volt_table = fixed_2050000_voltage,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100847 },
Bengt Jonsson6909b452010-12-10 11:08:47 +0100848 .update_bank = 0x03,
849 .update_reg = 0x83,
850 .update_mask = 0x08,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000851 .update_val = 0x08,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100852 },
853 [AB8500_LDO_ANAMIC2] = {
854 .desc = {
855 .name = "LDO-ANAMIC2",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000856 .ops = &ab8500_regulator_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100857 .type = REGULATOR_VOLTAGE,
858 .id = AB8500_LDO_ANAMIC2,
859 .owner = THIS_MODULE,
860 .n_voltages = 1,
Axel Lin530158b2013-03-27 17:47:22 +0800861 .enable_time = 500,
Lee Jonesb080c782013-03-28 16:11:17 +0000862 .volt_table = fixed_2050000_voltage,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100863 },
Bengt Jonsson6909b452010-12-10 11:08:47 +0100864 .update_bank = 0x03,
865 .update_reg = 0x83,
866 .update_mask = 0x10,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000867 .update_val = 0x10,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100868 },
869 [AB8500_LDO_DMIC] = {
870 .desc = {
871 .name = "LDO-DMIC",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000872 .ops = &ab8500_regulator_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100873 .type = REGULATOR_VOLTAGE,
874 .id = AB8500_LDO_DMIC,
875 .owner = THIS_MODULE,
876 .n_voltages = 1,
Axel Lin530158b2013-03-27 17:47:22 +0800877 .enable_time = 420,
Lee Jonesb080c782013-03-28 16:11:17 +0000878 .volt_table = fixed_1800000_voltage,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100879 },
Bengt Jonsson6909b452010-12-10 11:08:47 +0100880 .update_bank = 0x03,
881 .update_reg = 0x83,
882 .update_mask = 0x04,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000883 .update_val = 0x04,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100884 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000885
886 /*
887 * Regulators with fixed voltage and normal/idle modes
888 */
Bengt Jonsson6909b452010-12-10 11:08:47 +0100889 [AB8500_LDO_ANA] = {
890 .desc = {
891 .name = "LDO-ANA",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000892 .ops = &ab8500_regulator_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100893 .type = REGULATOR_VOLTAGE,
894 .id = AB8500_LDO_ANA,
895 .owner = THIS_MODULE,
896 .n_voltages = 1,
Axel Lin530158b2013-03-27 17:47:22 +0800897 .enable_time = 140,
Lee Jonesb080c782013-03-28 16:11:17 +0000898 .volt_table = fixed_1200000_voltage,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100899 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000900 .load_lp_uA = 1000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100901 .update_bank = 0x04,
902 .update_reg = 0x06,
903 .update_mask = 0x0c,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000904 .update_val = 0x04,
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000905 .update_val_idle = 0x0c,
906 .update_val_normal = 0x04,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100907 },
Lee Jones8e6a8d72013-03-28 16:11:11 +0000908};
Bengt Jonsson6909b452010-12-10 11:08:47 +0100909
Lee Jones547f3842013-03-28 16:11:14 +0000910/* AB8505 regulator information */
911static struct ab8500_regulator_info
912 ab8505_regulator_info[AB8505_NUM_REGULATORS] = {
913 /*
914 * Variable Voltage Regulators
915 * name, min mV, max mV,
916 * update bank, reg, mask, enable val
Lee Jonesd3193102013-04-02 13:24:18 +0100917 * volt bank, reg, mask
Lee Jones547f3842013-03-28 16:11:14 +0000918 */
919 [AB8505_LDO_AUX1] = {
920 .desc = {
921 .name = "LDO-AUX1",
922 .ops = &ab8500_regulator_volt_mode_ops,
923 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +0100924 .id = AB8505_LDO_AUX1,
Lee Jones547f3842013-03-28 16:11:14 +0000925 .owner = THIS_MODULE,
926 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +0000927 .volt_table = ldo_vauxn_voltages,
Lee Jones547f3842013-03-28 16:11:14 +0000928 },
Lee Jones547f3842013-03-28 16:11:14 +0000929 .load_lp_uA = 5000,
930 .update_bank = 0x04,
931 .update_reg = 0x09,
932 .update_mask = 0x03,
933 .update_val = 0x01,
934 .update_val_idle = 0x03,
935 .update_val_normal = 0x01,
936 .voltage_bank = 0x04,
937 .voltage_reg = 0x1f,
938 .voltage_mask = 0x0f,
Lee Jones547f3842013-03-28 16:11:14 +0000939 },
940 [AB8505_LDO_AUX2] = {
941 .desc = {
942 .name = "LDO-AUX2",
943 .ops = &ab8500_regulator_volt_mode_ops,
944 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +0100945 .id = AB8505_LDO_AUX2,
Lee Jones547f3842013-03-28 16:11:14 +0000946 .owner = THIS_MODULE,
947 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +0000948 .volt_table = ldo_vauxn_voltages,
Lee Jones547f3842013-03-28 16:11:14 +0000949 },
Lee Jones547f3842013-03-28 16:11:14 +0000950 .load_lp_uA = 5000,
951 .update_bank = 0x04,
952 .update_reg = 0x09,
953 .update_mask = 0x0c,
954 .update_val = 0x04,
955 .update_val_idle = 0x0c,
956 .update_val_normal = 0x04,
957 .voltage_bank = 0x04,
958 .voltage_reg = 0x20,
959 .voltage_mask = 0x0f,
Lee Jones547f3842013-03-28 16:11:14 +0000960 },
961 [AB8505_LDO_AUX3] = {
962 .desc = {
963 .name = "LDO-AUX3",
964 .ops = &ab8500_regulator_volt_mode_ops,
965 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +0100966 .id = AB8505_LDO_AUX3,
Lee Jones547f3842013-03-28 16:11:14 +0000967 .owner = THIS_MODULE,
968 .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +0000969 .volt_table = ldo_vaux3_voltages,
Lee Jones547f3842013-03-28 16:11:14 +0000970 },
Lee Jones547f3842013-03-28 16:11:14 +0000971 .load_lp_uA = 5000,
972 .update_bank = 0x04,
973 .update_reg = 0x0a,
974 .update_mask = 0x03,
975 .update_val = 0x01,
976 .update_val_idle = 0x03,
977 .update_val_normal = 0x01,
978 .voltage_bank = 0x04,
979 .voltage_reg = 0x21,
980 .voltage_mask = 0x07,
Lee Jones547f3842013-03-28 16:11:14 +0000981 },
982 [AB8505_LDO_AUX4] = {
983 .desc = {
984 .name = "LDO-AUX4",
985 .ops = &ab8500_regulator_volt_mode_ops,
986 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +0100987 .id = AB8505_LDO_AUX4,
Lee Jones547f3842013-03-28 16:11:14 +0000988 .owner = THIS_MODULE,
989 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +0000990 .volt_table = ldo_vauxn_voltages,
Lee Jones547f3842013-03-28 16:11:14 +0000991 },
Lee Jones547f3842013-03-28 16:11:14 +0000992 .load_lp_uA = 5000,
993 /* values for Vaux4Regu register */
994 .update_bank = 0x04,
995 .update_reg = 0x2e,
996 .update_mask = 0x03,
997 .update_val = 0x01,
998 .update_val_idle = 0x03,
999 .update_val_normal = 0x01,
1000 /* values for Vaux4SEL register */
1001 .voltage_bank = 0x04,
1002 .voltage_reg = 0x2f,
1003 .voltage_mask = 0x0f,
Lee Jones547f3842013-03-28 16:11:14 +00001004 },
1005 [AB8505_LDO_AUX5] = {
1006 .desc = {
1007 .name = "LDO-AUX5",
1008 .ops = &ab8500_regulator_volt_mode_ops,
1009 .type = REGULATOR_VOLTAGE,
1010 .id = AB8505_LDO_AUX5,
1011 .owner = THIS_MODULE,
1012 .n_voltages = ARRAY_SIZE(ldo_vaux56_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001013 .volt_table = ldo_vaux56_voltages,
Lee Jones547f3842013-03-28 16:11:14 +00001014 },
Lee Jones547f3842013-03-28 16:11:14 +00001015 .load_lp_uA = 2000,
1016 /* values for CtrlVaux5 register */
1017 .update_bank = 0x01,
1018 .update_reg = 0x55,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001019 .update_mask = 0x18,
1020 .update_val = 0x10,
1021 .update_val_idle = 0x18,
1022 .update_val_normal = 0x10,
Lee Jones547f3842013-03-28 16:11:14 +00001023 .voltage_bank = 0x01,
1024 .voltage_reg = 0x55,
1025 .voltage_mask = 0x07,
Lee Jones547f3842013-03-28 16:11:14 +00001026 },
1027 [AB8505_LDO_AUX6] = {
1028 .desc = {
1029 .name = "LDO-AUX6",
1030 .ops = &ab8500_regulator_volt_mode_ops,
1031 .type = REGULATOR_VOLTAGE,
1032 .id = AB8505_LDO_AUX6,
1033 .owner = THIS_MODULE,
1034 .n_voltages = ARRAY_SIZE(ldo_vaux56_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001035 .volt_table = ldo_vaux56_voltages,
Lee Jones547f3842013-03-28 16:11:14 +00001036 },
Lee Jones547f3842013-03-28 16:11:14 +00001037 .load_lp_uA = 2000,
1038 /* values for CtrlVaux6 register */
1039 .update_bank = 0x01,
1040 .update_reg = 0x56,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001041 .update_mask = 0x18,
1042 .update_val = 0x10,
1043 .update_val_idle = 0x18,
1044 .update_val_normal = 0x10,
Lee Jones547f3842013-03-28 16:11:14 +00001045 .voltage_bank = 0x01,
1046 .voltage_reg = 0x56,
1047 .voltage_mask = 0x07,
Lee Jones547f3842013-03-28 16:11:14 +00001048 },
1049 [AB8505_LDO_INTCORE] = {
1050 .desc = {
1051 .name = "LDO-INTCORE",
1052 .ops = &ab8500_regulator_volt_mode_ops,
1053 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001054 .id = AB8505_LDO_INTCORE,
Lee Jones547f3842013-03-28 16:11:14 +00001055 .owner = THIS_MODULE,
1056 .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001057 .volt_table = ldo_vintcore_voltages,
Lee Jones547f3842013-03-28 16:11:14 +00001058 },
Lee Jones547f3842013-03-28 16:11:14 +00001059 .load_lp_uA = 5000,
1060 .update_bank = 0x03,
1061 .update_reg = 0x80,
1062 .update_mask = 0x44,
1063 .update_val = 0x04,
1064 .update_val_idle = 0x44,
1065 .update_val_normal = 0x04,
1066 .voltage_bank = 0x03,
1067 .voltage_reg = 0x80,
1068 .voltage_mask = 0x38,
Lee Jones547f3842013-03-28 16:11:14 +00001069 .voltage_shift = 3,
1070 },
1071
1072 /*
1073 * Fixed Voltage Regulators
1074 * name, fixed mV,
1075 * update bank, reg, mask, enable val
1076 */
1077 [AB8505_LDO_ADC] = {
1078 .desc = {
1079 .name = "LDO-ADC",
1080 .ops = &ab8500_regulator_mode_ops,
1081 .type = REGULATOR_VOLTAGE,
1082 .id = AB8505_LDO_ADC,
1083 .owner = THIS_MODULE,
1084 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001085 .volt_table = fixed_2000000_voltage,
Lee Jonesa4d68462013-04-02 13:24:16 +01001086 .enable_time = 10000,
Lee Jones547f3842013-03-28 16:11:14 +00001087 },
Lee Jones547f3842013-03-28 16:11:14 +00001088 .load_lp_uA = 1000,
1089 .update_bank = 0x03,
1090 .update_reg = 0x80,
1091 .update_mask = 0x82,
1092 .update_val = 0x02,
1093 .update_val_idle = 0x82,
1094 .update_val_normal = 0x02,
1095 },
1096 [AB8505_LDO_USB] = {
1097 .desc = {
1098 .name = "LDO-USB",
1099 .ops = &ab8500_regulator_mode_ops,
1100 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001101 .id = AB8505_LDO_USB,
Lee Jones547f3842013-03-28 16:11:14 +00001102 .owner = THIS_MODULE,
1103 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001104 .volt_table = fixed_3300000_voltage,
Lee Jones547f3842013-03-28 16:11:14 +00001105 },
Lee Jones547f3842013-03-28 16:11:14 +00001106 .update_bank = 0x03,
1107 .update_reg = 0x82,
1108 .update_mask = 0x03,
1109 .update_val = 0x01,
1110 .update_val_idle = 0x03,
1111 .update_val_normal = 0x01,
1112 },
1113 [AB8505_LDO_AUDIO] = {
1114 .desc = {
1115 .name = "LDO-AUDIO",
Lee Jones8a3b1b82013-04-02 13:24:09 +01001116 .ops = &ab8500_regulator_volt_ops,
Lee Jones547f3842013-03-28 16:11:14 +00001117 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001118 .id = AB8505_LDO_AUDIO,
Lee Jones547f3842013-03-28 16:11:14 +00001119 .owner = THIS_MODULE,
Lee Jones8a3b1b82013-04-02 13:24:09 +01001120 .n_voltages = ARRAY_SIZE(ldo_vaudio_voltages),
1121 .volt_table = ldo_vaudio_voltages,
Lee Jones547f3842013-03-28 16:11:14 +00001122 },
Lee Jones547f3842013-03-28 16:11:14 +00001123 .update_bank = 0x03,
1124 .update_reg = 0x83,
1125 .update_mask = 0x02,
1126 .update_val = 0x02,
Lee Jones8a3b1b82013-04-02 13:24:09 +01001127 .voltage_bank = 0x01,
1128 .voltage_reg = 0x57,
Axel Line4fc9d62013-04-12 15:33:25 +08001129 .voltage_mask = 0x70,
Lee Jones8a3b1b82013-04-02 13:24:09 +01001130 .voltage_shift = 4,
Lee Jones547f3842013-03-28 16:11:14 +00001131 },
1132 [AB8505_LDO_ANAMIC1] = {
1133 .desc = {
1134 .name = "LDO-ANAMIC1",
Lee Jones3fe52282013-04-02 13:24:12 +01001135 .ops = &ab8500_regulator_anamic_mode_ops,
Lee Jones547f3842013-03-28 16:11:14 +00001136 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001137 .id = AB8505_LDO_ANAMIC1,
Lee Jones547f3842013-03-28 16:11:14 +00001138 .owner = THIS_MODULE,
1139 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001140 .volt_table = fixed_2050000_voltage,
Lee Jones547f3842013-03-28 16:11:14 +00001141 },
Lee Jones4c84b4d2013-04-02 13:24:13 +01001142 .shared_mode = &ldo_anamic1_shared,
Lee Jones547f3842013-03-28 16:11:14 +00001143 .update_bank = 0x03,
1144 .update_reg = 0x83,
1145 .update_mask = 0x08,
1146 .update_val = 0x08,
Lee Jones3fe52282013-04-02 13:24:12 +01001147 .mode_bank = 0x01,
1148 .mode_reg = 0x54,
1149 .mode_mask = 0x04,
1150 .mode_val_idle = 0x04,
1151 .mode_val_normal = 0x00,
Lee Jones547f3842013-03-28 16:11:14 +00001152 },
1153 [AB8505_LDO_ANAMIC2] = {
1154 .desc = {
1155 .name = "LDO-ANAMIC2",
Lee Jones3fe52282013-04-02 13:24:12 +01001156 .ops = &ab8500_regulator_anamic_mode_ops,
Lee Jones547f3842013-03-28 16:11:14 +00001157 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001158 .id = AB8505_LDO_ANAMIC2,
Lee Jones547f3842013-03-28 16:11:14 +00001159 .owner = THIS_MODULE,
1160 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001161 .volt_table = fixed_2050000_voltage,
Lee Jones547f3842013-03-28 16:11:14 +00001162 },
Lee Jones3fe52282013-04-02 13:24:12 +01001163 .shared_mode = &ldo_anamic2_shared,
Lee Jones547f3842013-03-28 16:11:14 +00001164 .update_bank = 0x03,
1165 .update_reg = 0x83,
1166 .update_mask = 0x10,
1167 .update_val = 0x10,
Lee Jones3fe52282013-04-02 13:24:12 +01001168 .mode_bank = 0x01,
1169 .mode_reg = 0x54,
1170 .mode_mask = 0x04,
1171 .mode_val_idle = 0x04,
1172 .mode_val_normal = 0x00,
Lee Jones547f3842013-03-28 16:11:14 +00001173 },
1174 [AB8505_LDO_AUX8] = {
1175 .desc = {
1176 .name = "LDO-AUX8",
1177 .ops = &ab8500_regulator_ops,
1178 .type = REGULATOR_VOLTAGE,
1179 .id = AB8505_LDO_AUX8,
1180 .owner = THIS_MODULE,
1181 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001182 .volt_table = fixed_1800000_voltage,
Lee Jones547f3842013-03-28 16:11:14 +00001183 },
Lee Jones547f3842013-03-28 16:11:14 +00001184 .update_bank = 0x03,
1185 .update_reg = 0x83,
1186 .update_mask = 0x04,
1187 .update_val = 0x04,
1188 },
1189 /*
1190 * Regulators with fixed voltage and normal/idle modes
1191 */
1192 [AB8505_LDO_ANA] = {
1193 .desc = {
1194 .name = "LDO-ANA",
Lee Jones8a3b1b82013-04-02 13:24:09 +01001195 .ops = &ab8500_regulator_volt_mode_ops,
Lee Jones547f3842013-03-28 16:11:14 +00001196 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001197 .id = AB8505_LDO_ANA,
Lee Jones547f3842013-03-28 16:11:14 +00001198 .owner = THIS_MODULE,
Lee Jones8a3b1b82013-04-02 13:24:09 +01001199 .n_voltages = ARRAY_SIZE(ldo_vana_voltages),
1200 .volt_table = ldo_vana_voltages,
Lee Jones547f3842013-03-28 16:11:14 +00001201 },
Lee Jones547f3842013-03-28 16:11:14 +00001202 .load_lp_uA = 1000,
1203 .update_bank = 0x04,
1204 .update_reg = 0x06,
1205 .update_mask = 0x0c,
1206 .update_val = 0x04,
1207 .update_val_idle = 0x0c,
1208 .update_val_normal = 0x04,
Lee Jones8a3b1b82013-04-02 13:24:09 +01001209 .voltage_bank = 0x04,
1210 .voltage_reg = 0x29,
1211 .voltage_mask = 0x7,
Lee Jones547f3842013-03-28 16:11:14 +00001212 },
1213};
1214
Lee Jones8e6a8d72013-03-28 16:11:11 +00001215/* AB9540 regulator information */
1216static struct ab8500_regulator_info
1217 ab9540_regulator_info[AB9540_NUM_REGULATORS] = {
1218 /*
1219 * Variable Voltage Regulators
1220 * name, min mV, max mV,
1221 * update bank, reg, mask, enable val
Lee Jonesd3193102013-04-02 13:24:18 +01001222 * volt bank, reg, mask
Lee Jones8e6a8d72013-03-28 16:11:11 +00001223 */
1224 [AB9540_LDO_AUX1] = {
1225 .desc = {
1226 .name = "LDO-AUX1",
1227 .ops = &ab8500_regulator_volt_mode_ops,
1228 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001229 .id = AB9540_LDO_AUX1,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001230 .owner = THIS_MODULE,
1231 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001232 .volt_table = ldo_vauxn_voltages,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001233 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001234 .load_lp_uA = 5000,
1235 .update_bank = 0x04,
1236 .update_reg = 0x09,
1237 .update_mask = 0x03,
1238 .update_val = 0x01,
1239 .update_val_idle = 0x03,
1240 .update_val_normal = 0x01,
1241 .voltage_bank = 0x04,
1242 .voltage_reg = 0x1f,
1243 .voltage_mask = 0x0f,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001244 },
1245 [AB9540_LDO_AUX2] = {
1246 .desc = {
1247 .name = "LDO-AUX2",
1248 .ops = &ab8500_regulator_volt_mode_ops,
1249 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001250 .id = AB9540_LDO_AUX2,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001251 .owner = THIS_MODULE,
1252 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001253 .volt_table = ldo_vauxn_voltages,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001254 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001255 .load_lp_uA = 5000,
1256 .update_bank = 0x04,
1257 .update_reg = 0x09,
1258 .update_mask = 0x0c,
1259 .update_val = 0x04,
1260 .update_val_idle = 0x0c,
1261 .update_val_normal = 0x04,
1262 .voltage_bank = 0x04,
1263 .voltage_reg = 0x20,
1264 .voltage_mask = 0x0f,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001265 },
1266 [AB9540_LDO_AUX3] = {
1267 .desc = {
1268 .name = "LDO-AUX3",
1269 .ops = &ab8500_regulator_volt_mode_ops,
1270 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001271 .id = AB9540_LDO_AUX3,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001272 .owner = THIS_MODULE,
1273 .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001274 .volt_table = ldo_vaux3_voltages,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001275 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001276 .load_lp_uA = 5000,
1277 .update_bank = 0x04,
1278 .update_reg = 0x0a,
1279 .update_mask = 0x03,
1280 .update_val = 0x01,
1281 .update_val_idle = 0x03,
1282 .update_val_normal = 0x01,
1283 .voltage_bank = 0x04,
1284 .voltage_reg = 0x21,
1285 .voltage_mask = 0x07,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001286 },
1287 [AB9540_LDO_AUX4] = {
1288 .desc = {
1289 .name = "LDO-AUX4",
1290 .ops = &ab8500_regulator_volt_mode_ops,
1291 .type = REGULATOR_VOLTAGE,
1292 .id = AB9540_LDO_AUX4,
1293 .owner = THIS_MODULE,
1294 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001295 .volt_table = ldo_vauxn_voltages,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001296 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001297 .load_lp_uA = 5000,
1298 /* values for Vaux4Regu register */
1299 .update_bank = 0x04,
1300 .update_reg = 0x2e,
1301 .update_mask = 0x03,
1302 .update_val = 0x01,
1303 .update_val_idle = 0x03,
1304 .update_val_normal = 0x01,
1305 /* values for Vaux4SEL register */
1306 .voltage_bank = 0x04,
1307 .voltage_reg = 0x2f,
1308 .voltage_mask = 0x0f,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001309 },
1310 [AB9540_LDO_INTCORE] = {
1311 .desc = {
1312 .name = "LDO-INTCORE",
1313 .ops = &ab8500_regulator_volt_mode_ops,
1314 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001315 .id = AB9540_LDO_INTCORE,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001316 .owner = THIS_MODULE,
1317 .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001318 .volt_table = ldo_vintcore_voltages,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001319 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001320 .load_lp_uA = 5000,
1321 .update_bank = 0x03,
1322 .update_reg = 0x80,
1323 .update_mask = 0x44,
1324 .update_val = 0x44,
1325 .update_val_idle = 0x44,
1326 .update_val_normal = 0x04,
1327 .voltage_bank = 0x03,
1328 .voltage_reg = 0x80,
1329 .voltage_mask = 0x38,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001330 .voltage_shift = 3,
1331 },
Bengt Jonsson6909b452010-12-10 11:08:47 +01001332
Lee Jones8e6a8d72013-03-28 16:11:11 +00001333 /*
1334 * Fixed Voltage Regulators
1335 * name, fixed mV,
1336 * update bank, reg, mask, enable val
1337 */
1338 [AB9540_LDO_TVOUT] = {
1339 .desc = {
1340 .name = "LDO-TVOUT",
1341 .ops = &ab8500_regulator_mode_ops,
1342 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001343 .id = AB9540_LDO_TVOUT,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001344 .owner = THIS_MODULE,
1345 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001346 .volt_table = fixed_2000000_voltage,
Lee Jonesa4d68462013-04-02 13:24:16 +01001347 .enable_time = 10000,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001348 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001349 .load_lp_uA = 1000,
1350 .update_bank = 0x03,
1351 .update_reg = 0x80,
1352 .update_mask = 0x82,
1353 .update_val = 0x02,
1354 .update_val_idle = 0x82,
1355 .update_val_normal = 0x02,
1356 },
1357 [AB9540_LDO_USB] = {
1358 .desc = {
1359 .name = "LDO-USB",
1360 .ops = &ab8500_regulator_ops,
1361 .type = REGULATOR_VOLTAGE,
1362 .id = AB9540_LDO_USB,
1363 .owner = THIS_MODULE,
1364 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001365 .volt_table = fixed_3300000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001366 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001367 .update_bank = 0x03,
1368 .update_reg = 0x82,
1369 .update_mask = 0x03,
1370 .update_val = 0x01,
1371 .update_val_idle = 0x03,
1372 .update_val_normal = 0x01,
1373 },
1374 [AB9540_LDO_AUDIO] = {
1375 .desc = {
1376 .name = "LDO-AUDIO",
1377 .ops = &ab8500_regulator_ops,
1378 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001379 .id = AB9540_LDO_AUDIO,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001380 .owner = THIS_MODULE,
1381 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001382 .volt_table = fixed_2000000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001383 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001384 .update_bank = 0x03,
1385 .update_reg = 0x83,
1386 .update_mask = 0x02,
1387 .update_val = 0x02,
1388 },
1389 [AB9540_LDO_ANAMIC1] = {
1390 .desc = {
1391 .name = "LDO-ANAMIC1",
1392 .ops = &ab8500_regulator_ops,
1393 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001394 .id = AB9540_LDO_ANAMIC1,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001395 .owner = THIS_MODULE,
1396 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001397 .volt_table = fixed_2050000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001398 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001399 .update_bank = 0x03,
1400 .update_reg = 0x83,
1401 .update_mask = 0x08,
1402 .update_val = 0x08,
1403 },
1404 [AB9540_LDO_ANAMIC2] = {
1405 .desc = {
1406 .name = "LDO-ANAMIC2",
1407 .ops = &ab8500_regulator_ops,
1408 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001409 .id = AB9540_LDO_ANAMIC2,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001410 .owner = THIS_MODULE,
1411 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001412 .volt_table = fixed_2050000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001413 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001414 .update_bank = 0x03,
1415 .update_reg = 0x83,
1416 .update_mask = 0x10,
1417 .update_val = 0x10,
1418 },
1419 [AB9540_LDO_DMIC] = {
1420 .desc = {
1421 .name = "LDO-DMIC",
1422 .ops = &ab8500_regulator_ops,
1423 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001424 .id = AB9540_LDO_DMIC,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001425 .owner = THIS_MODULE,
1426 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001427 .volt_table = fixed_1800000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001428 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001429 .update_bank = 0x03,
1430 .update_reg = 0x83,
1431 .update_mask = 0x04,
1432 .update_val = 0x04,
1433 },
1434
1435 /*
1436 * Regulators with fixed voltage and normal/idle modes
1437 */
1438 [AB9540_LDO_ANA] = {
1439 .desc = {
1440 .name = "LDO-ANA",
1441 .ops = &ab8500_regulator_mode_ops,
1442 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001443 .id = AB9540_LDO_ANA,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001444 .owner = THIS_MODULE,
1445 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001446 .volt_table = fixed_1200000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001447 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001448 .load_lp_uA = 1000,
1449 .update_bank = 0x04,
1450 .update_reg = 0x06,
1451 .update_mask = 0x0c,
1452 .update_val = 0x08,
1453 .update_val_idle = 0x0c,
1454 .update_val_normal = 0x08,
1455 },
Sundar R IYERc789ca22010-07-13 21:48:56 +05301456};
1457
Lee Jonesae0a9a32013-03-28 16:11:16 +00001458/* AB8540 regulator information */
1459static struct ab8500_regulator_info
1460 ab8540_regulator_info[AB8540_NUM_REGULATORS] = {
1461 /*
1462 * Variable Voltage Regulators
1463 * name, min mV, max mV,
1464 * update bank, reg, mask, enable val
Lee Jonesd3193102013-04-02 13:24:18 +01001465 * volt bank, reg, mask
Lee Jonesae0a9a32013-03-28 16:11:16 +00001466 */
1467 [AB8540_LDO_AUX1] = {
1468 .desc = {
1469 .name = "LDO-AUX1",
1470 .ops = &ab8500_regulator_volt_mode_ops,
1471 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001472 .id = AB8540_LDO_AUX1,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001473 .owner = THIS_MODULE,
1474 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001475 .volt_table = ldo_vauxn_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001476 },
1477 .load_lp_uA = 5000,
1478 .update_bank = 0x04,
1479 .update_reg = 0x09,
1480 .update_mask = 0x03,
1481 .update_val = 0x01,
1482 .update_val_idle = 0x03,
1483 .update_val_normal = 0x01,
1484 .voltage_bank = 0x04,
1485 .voltage_reg = 0x1f,
1486 .voltage_mask = 0x0f,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001487 },
1488 [AB8540_LDO_AUX2] = {
1489 .desc = {
1490 .name = "LDO-AUX2",
1491 .ops = &ab8500_regulator_volt_mode_ops,
1492 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001493 .id = AB8540_LDO_AUX2,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001494 .owner = THIS_MODULE,
1495 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001496 .volt_table = ldo_vauxn_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001497 },
1498 .load_lp_uA = 5000,
1499 .update_bank = 0x04,
1500 .update_reg = 0x09,
1501 .update_mask = 0x0c,
1502 .update_val = 0x04,
1503 .update_val_idle = 0x0c,
1504 .update_val_normal = 0x04,
1505 .voltage_bank = 0x04,
1506 .voltage_reg = 0x20,
1507 .voltage_mask = 0x0f,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001508 },
1509 [AB8540_LDO_AUX3] = {
1510 .desc = {
1511 .name = "LDO-AUX3",
Lee Jonesd7607ba2013-04-02 13:24:11 +01001512 .ops = &ab8540_aux3_regulator_volt_mode_ops,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001513 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001514 .id = AB8540_LDO_AUX3,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001515 .owner = THIS_MODULE,
1516 .n_voltages = ARRAY_SIZE(ldo_vaux3_ab8540_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001517 .volt_table = ldo_vaux3_ab8540_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001518 },
1519 .load_lp_uA = 5000,
1520 .update_bank = 0x04,
1521 .update_reg = 0x0a,
1522 .update_mask = 0x03,
1523 .update_val = 0x01,
1524 .update_val_idle = 0x03,
1525 .update_val_normal = 0x01,
1526 .voltage_bank = 0x04,
1527 .voltage_reg = 0x21,
1528 .voltage_mask = 0x07,
Lee Jonesd7607ba2013-04-02 13:24:11 +01001529 .expand_register = {
1530 .voltage_limit = 8,
1531 .voltage_bank = 0x04,
1532 .voltage_reg = 0x01,
1533 .voltage_mask = 0x10,
1534 .voltage_shift = 1,
1535 }
Lee Jonesae0a9a32013-03-28 16:11:16 +00001536 },
1537 [AB8540_LDO_AUX4] = {
1538 .desc = {
1539 .name = "LDO-AUX4",
1540 .ops = &ab8500_regulator_volt_mode_ops,
1541 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001542 .id = AB8540_LDO_AUX4,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001543 .owner = THIS_MODULE,
1544 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001545 .volt_table = ldo_vauxn_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001546 },
1547 .load_lp_uA = 5000,
1548 /* values for Vaux4Regu register */
1549 .update_bank = 0x04,
1550 .update_reg = 0x2e,
1551 .update_mask = 0x03,
1552 .update_val = 0x01,
1553 .update_val_idle = 0x03,
1554 .update_val_normal = 0x01,
1555 /* values for Vaux4SEL register */
1556 .voltage_bank = 0x04,
1557 .voltage_reg = 0x2f,
1558 .voltage_mask = 0x0f,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001559 },
Zhenhua HUANG684d5ce2013-04-02 13:24:15 +01001560 [AB8540_LDO_AUX5] = {
1561 .desc = {
1562 .name = "LDO-AUX5",
1563 .ops = &ab8500_regulator_volt_mode_ops,
1564 .type = REGULATOR_VOLTAGE,
1565 .id = AB8540_LDO_AUX5,
1566 .owner = THIS_MODULE,
1567 .n_voltages = ARRAY_SIZE(ldo_vaux56_ab8540_voltages),
Lee Jonesd3193102013-04-02 13:24:18 +01001568 .volt_table = ldo_vaux56_ab8540_voltages,
Zhenhua HUANG684d5ce2013-04-02 13:24:15 +01001569 },
1570 .load_lp_uA = 20000,
1571 /* values for Vaux5Regu register */
1572 .update_bank = 0x04,
1573 .update_reg = 0x32,
1574 .update_mask = 0x03,
1575 .update_val = 0x01,
1576 .update_val_idle = 0x03,
1577 .update_val_normal = 0x01,
1578 /* values for Vaux5SEL register */
1579 .voltage_bank = 0x04,
1580 .voltage_reg = 0x33,
1581 .voltage_mask = 0x3f,
Zhenhua HUANG684d5ce2013-04-02 13:24:15 +01001582 },
1583 [AB8540_LDO_AUX6] = {
1584 .desc = {
1585 .name = "LDO-AUX6",
1586 .ops = &ab8500_regulator_volt_mode_ops,
1587 .type = REGULATOR_VOLTAGE,
1588 .id = AB8540_LDO_AUX6,
1589 .owner = THIS_MODULE,
1590 .n_voltages = ARRAY_SIZE(ldo_vaux56_ab8540_voltages),
Lee Jonesd3193102013-04-02 13:24:18 +01001591 .volt_table = ldo_vaux56_ab8540_voltages,
Zhenhua HUANG684d5ce2013-04-02 13:24:15 +01001592 },
1593 .load_lp_uA = 20000,
1594 /* values for Vaux6Regu register */
1595 .update_bank = 0x04,
1596 .update_reg = 0x35,
1597 .update_mask = 0x03,
1598 .update_val = 0x01,
1599 .update_val_idle = 0x03,
1600 .update_val_normal = 0x01,
1601 /* values for Vaux6SEL register */
1602 .voltage_bank = 0x04,
1603 .voltage_reg = 0x36,
1604 .voltage_mask = 0x3f,
Zhenhua HUANG684d5ce2013-04-02 13:24:15 +01001605 },
Lee Jonesae0a9a32013-03-28 16:11:16 +00001606 [AB8540_LDO_INTCORE] = {
1607 .desc = {
1608 .name = "LDO-INTCORE",
1609 .ops = &ab8500_regulator_volt_mode_ops,
1610 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001611 .id = AB8540_LDO_INTCORE,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001612 .owner = THIS_MODULE,
1613 .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001614 .volt_table = ldo_vintcore_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001615 },
1616 .load_lp_uA = 5000,
1617 .update_bank = 0x03,
1618 .update_reg = 0x80,
1619 .update_mask = 0x44,
1620 .update_val = 0x44,
1621 .update_val_idle = 0x44,
1622 .update_val_normal = 0x04,
1623 .voltage_bank = 0x03,
1624 .voltage_reg = 0x80,
1625 .voltage_mask = 0x38,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001626 .voltage_shift = 3,
1627 },
1628
1629 /*
1630 * Fixed Voltage Regulators
1631 * name, fixed mV,
1632 * update bank, reg, mask, enable val
1633 */
1634 [AB8540_LDO_TVOUT] = {
1635 .desc = {
1636 .name = "LDO-TVOUT",
1637 .ops = &ab8500_regulator_mode_ops,
1638 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001639 .id = AB8540_LDO_TVOUT,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001640 .owner = THIS_MODULE,
1641 .n_voltages = 1,
Axel Linaca45e92013-04-02 13:24:23 +01001642 .volt_table = fixed_2000000_voltage,
Lee Jonesa4d68462013-04-02 13:24:16 +01001643 .enable_time = 10000,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001644 },
Lee Jonesae0a9a32013-03-28 16:11:16 +00001645 .load_lp_uA = 1000,
1646 .update_bank = 0x03,
1647 .update_reg = 0x80,
1648 .update_mask = 0x82,
1649 .update_val = 0x02,
1650 .update_val_idle = 0x82,
1651 .update_val_normal = 0x02,
1652 },
1653 [AB8540_LDO_AUDIO] = {
1654 .desc = {
1655 .name = "LDO-AUDIO",
1656 .ops = &ab8500_regulator_ops,
1657 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001658 .id = AB8540_LDO_AUDIO,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001659 .owner = THIS_MODULE,
1660 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001661 .volt_table = fixed_2000000_voltage,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001662 },
1663 .update_bank = 0x03,
1664 .update_reg = 0x83,
1665 .update_mask = 0x02,
1666 .update_val = 0x02,
1667 },
1668 [AB8540_LDO_ANAMIC1] = {
1669 .desc = {
1670 .name = "LDO-ANAMIC1",
Lee Jones4c84b4d2013-04-02 13:24:13 +01001671 .ops = &ab8500_regulator_anamic_mode_ops,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001672 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001673 .id = AB8540_LDO_ANAMIC1,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001674 .owner = THIS_MODULE,
1675 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001676 .volt_table = fixed_2050000_voltage,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001677 },
Lee Jones4c84b4d2013-04-02 13:24:13 +01001678 .shared_mode = &ab8540_ldo_anamic1_shared,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001679 .update_bank = 0x03,
1680 .update_reg = 0x83,
1681 .update_mask = 0x08,
1682 .update_val = 0x08,
Lee Jones4c84b4d2013-04-02 13:24:13 +01001683 .mode_bank = 0x03,
1684 .mode_reg = 0x83,
1685 .mode_mask = 0x20,
1686 .mode_val_idle = 0x20,
1687 .mode_val_normal = 0x00,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001688 },
1689 [AB8540_LDO_ANAMIC2] = {
1690 .desc = {
1691 .name = "LDO-ANAMIC2",
Lee Jones4c84b4d2013-04-02 13:24:13 +01001692 .ops = &ab8500_regulator_anamic_mode_ops,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001693 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001694 .id = AB8540_LDO_ANAMIC2,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001695 .owner = THIS_MODULE,
1696 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001697 .volt_table = fixed_2050000_voltage,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001698 },
Lee Jones4c84b4d2013-04-02 13:24:13 +01001699 .shared_mode = &ab8540_ldo_anamic2_shared,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001700 .update_bank = 0x03,
1701 .update_reg = 0x83,
1702 .update_mask = 0x10,
1703 .update_val = 0x10,
Lee Jones4c84b4d2013-04-02 13:24:13 +01001704 .mode_bank = 0x03,
1705 .mode_reg = 0x83,
1706 .mode_mask = 0x20,
1707 .mode_val_idle = 0x20,
1708 .mode_val_normal = 0x00,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001709 },
1710 [AB8540_LDO_DMIC] = {
1711 .desc = {
1712 .name = "LDO-DMIC",
Lee Jones4c84b4d2013-04-02 13:24:13 +01001713 .ops = &ab8500_regulator_volt_mode_ops,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001714 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001715 .id = AB8540_LDO_DMIC,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001716 .owner = THIS_MODULE,
Lee Jones4c84b4d2013-04-02 13:24:13 +01001717 .n_voltages = ARRAY_SIZE(ldo_vdmic_voltages),
Lee Jonesd3193102013-04-02 13:24:18 +01001718 .volt_table = ldo_vdmic_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001719 },
Lee Jones4c84b4d2013-04-02 13:24:13 +01001720 .load_lp_uA = 1000,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001721 .update_bank = 0x03,
1722 .update_reg = 0x83,
1723 .update_mask = 0x04,
1724 .update_val = 0x04,
Lee Jones4c84b4d2013-04-02 13:24:13 +01001725 .voltage_bank = 0x03,
1726 .voltage_reg = 0x83,
1727 .voltage_mask = 0xc0,
Axel Lin375dc9c2013-04-15 16:36:51 +08001728 .voltage_shift = 6,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001729 },
1730
1731 /*
1732 * Regulators with fixed voltage and normal/idle modes
1733 */
1734 [AB8540_LDO_ANA] = {
1735 .desc = {
1736 .name = "LDO-ANA",
1737 .ops = &ab8500_regulator_mode_ops,
1738 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001739 .id = AB8540_LDO_ANA,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001740 .owner = THIS_MODULE,
1741 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001742 .volt_table = fixed_1200000_voltage,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001743 },
1744 .load_lp_uA = 1000,
1745 .update_bank = 0x04,
1746 .update_reg = 0x06,
1747 .update_mask = 0x0c,
1748 .update_val = 0x04,
1749 .update_val_idle = 0x0c,
1750 .update_val_normal = 0x04,
1751 },
1752 [AB8540_LDO_SDIO] = {
1753 .desc = {
1754 .name = "LDO-SDIO",
1755 .ops = &ab8500_regulator_volt_mode_ops,
1756 .type = REGULATOR_VOLTAGE,
1757 .id = AB8540_LDO_SDIO,
1758 .owner = THIS_MODULE,
Lee Jones62ab4112013-03-28 16:11:18 +00001759 .n_voltages = ARRAY_SIZE(ldo_sdio_voltages),
1760 .volt_table = ldo_sdio_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001761 },
Lee Jonesae0a9a32013-03-28 16:11:16 +00001762 .load_lp_uA = 5000,
1763 .update_bank = 0x03,
1764 .update_reg = 0x88,
1765 .update_mask = 0x30,
1766 .update_val = 0x10,
1767 .update_val_idle = 0x30,
1768 .update_val_normal = 0x10,
1769 .voltage_bank = 0x03,
1770 .voltage_reg = 0x88,
1771 .voltage_mask = 0x07,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001772 },
1773};
1774
Lee Jones3fe52282013-04-02 13:24:12 +01001775static struct ab8500_shared_mode ldo_anamic1_shared = {
1776 .shared_regulator = &ab8505_regulator_info[AB8505_LDO_ANAMIC2],
1777};
1778
1779static struct ab8500_shared_mode ldo_anamic2_shared = {
1780 .shared_regulator = &ab8505_regulator_info[AB8505_LDO_ANAMIC1],
1781};
1782
Lee Jones4c84b4d2013-04-02 13:24:13 +01001783static struct ab8500_shared_mode ab8540_ldo_anamic1_shared = {
1784 .shared_regulator = &ab8540_regulator_info[AB8540_LDO_ANAMIC2],
1785};
1786
1787static struct ab8500_shared_mode ab8540_ldo_anamic2_shared = {
1788 .shared_regulator = &ab8540_regulator_info[AB8540_LDO_ANAMIC1],
1789};
1790
Bengt Jonsson79568b942011-03-11 11:54:46 +01001791struct ab8500_reg_init {
1792 u8 bank;
1793 u8 addr;
1794 u8 mask;
1795};
1796
1797#define REG_INIT(_id, _bank, _addr, _mask) \
1798 [_id] = { \
1799 .bank = _bank, \
1800 .addr = _addr, \
1801 .mask = _mask, \
1802 }
1803
Lee Jones8e6a8d72013-03-28 16:11:11 +00001804/* AB8500 register init */
Bengt Jonsson79568b942011-03-11 11:54:46 +01001805static struct ab8500_reg_init ab8500_reg_init[] = {
1806 /*
Lee Jones33bc8f42013-03-21 15:59:02 +00001807 * 0x30, VanaRequestCtrl
Bengt Jonsson79568b942011-03-11 11:54:46 +01001808 * 0xc0, VextSupply1RequestCtrl
1809 */
Lee Jones43a59112013-03-21 15:59:15 +00001810 REG_INIT(AB8500_REGUREQUESTCTRL2, 0x03, 0x04, 0xf0),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001811 /*
1812 * 0x03, VextSupply2RequestCtrl
1813 * 0x0c, VextSupply3RequestCtrl
1814 * 0x30, Vaux1RequestCtrl
1815 * 0xc0, Vaux2RequestCtrl
1816 */
1817 REG_INIT(AB8500_REGUREQUESTCTRL3, 0x03, 0x05, 0xff),
1818 /*
1819 * 0x03, Vaux3RequestCtrl
1820 * 0x04, SwHPReq
1821 */
1822 REG_INIT(AB8500_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
1823 /*
1824 * 0x08, VanaSysClkReq1HPValid
1825 * 0x20, Vaux1SysClkReq1HPValid
1826 * 0x40, Vaux2SysClkReq1HPValid
1827 * 0x80, Vaux3SysClkReq1HPValid
1828 */
Lee Jones43a59112013-03-21 15:59:15 +00001829 REG_INIT(AB8500_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xe8),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001830 /*
1831 * 0x10, VextSupply1SysClkReq1HPValid
1832 * 0x20, VextSupply2SysClkReq1HPValid
1833 * 0x40, VextSupply3SysClkReq1HPValid
1834 */
Lee Jones43a59112013-03-21 15:59:15 +00001835 REG_INIT(AB8500_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x70),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001836 /*
1837 * 0x08, VanaHwHPReq1Valid
1838 * 0x20, Vaux1HwHPReq1Valid
1839 * 0x40, Vaux2HwHPReq1Valid
1840 * 0x80, Vaux3HwHPReq1Valid
1841 */
Lee Jones43a59112013-03-21 15:59:15 +00001842 REG_INIT(AB8500_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xe8),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001843 /*
1844 * 0x01, VextSupply1HwHPReq1Valid
1845 * 0x02, VextSupply2HwHPReq1Valid
1846 * 0x04, VextSupply3HwHPReq1Valid
1847 */
Lee Jones43a59112013-03-21 15:59:15 +00001848 REG_INIT(AB8500_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x07),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001849 /*
1850 * 0x08, VanaHwHPReq2Valid
1851 * 0x20, Vaux1HwHPReq2Valid
1852 * 0x40, Vaux2HwHPReq2Valid
1853 * 0x80, Vaux3HwHPReq2Valid
1854 */
Lee Jones43a59112013-03-21 15:59:15 +00001855 REG_INIT(AB8500_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xe8),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001856 /*
1857 * 0x01, VextSupply1HwHPReq2Valid
1858 * 0x02, VextSupply2HwHPReq2Valid
1859 * 0x04, VextSupply3HwHPReq2Valid
1860 */
Lee Jones43a59112013-03-21 15:59:15 +00001861 REG_INIT(AB8500_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x07),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001862 /*
1863 * 0x20, VanaSwHPReqValid
1864 * 0x80, Vaux1SwHPReqValid
1865 */
Lee Jones43a59112013-03-21 15:59:15 +00001866 REG_INIT(AB8500_REGUSWHPREQVALID1, 0x03, 0x0d, 0xa0),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001867 /*
1868 * 0x01, Vaux2SwHPReqValid
1869 * 0x02, Vaux3SwHPReqValid
1870 * 0x04, VextSupply1SwHPReqValid
1871 * 0x08, VextSupply2SwHPReqValid
1872 * 0x10, VextSupply3SwHPReqValid
1873 */
Lee Jones43a59112013-03-21 15:59:15 +00001874 REG_INIT(AB8500_REGUSWHPREQVALID2, 0x03, 0x0e, 0x1f),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001875 /*
1876 * 0x02, SysClkReq2Valid1
Lee Jones43a59112013-03-21 15:59:15 +00001877 * 0x04, SysClkReq3Valid1
1878 * 0x08, SysClkReq4Valid1
1879 * 0x10, SysClkReq5Valid1
1880 * 0x20, SysClkReq6Valid1
1881 * 0x40, SysClkReq7Valid1
Bengt Jonsson79568b942011-03-11 11:54:46 +01001882 * 0x80, SysClkReq8Valid1
1883 */
1884 REG_INIT(AB8500_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0xfe),
1885 /*
1886 * 0x02, SysClkReq2Valid2
Lee Jones43a59112013-03-21 15:59:15 +00001887 * 0x04, SysClkReq3Valid2
1888 * 0x08, SysClkReq4Valid2
1889 * 0x10, SysClkReq5Valid2
1890 * 0x20, SysClkReq6Valid2
1891 * 0x40, SysClkReq7Valid2
Bengt Jonsson79568b942011-03-11 11:54:46 +01001892 * 0x80, SysClkReq8Valid2
1893 */
1894 REG_INIT(AB8500_REGUSYSCLKREQVALID2, 0x03, 0x10, 0xfe),
1895 /*
1896 * 0x02, VTVoutEna
1897 * 0x04, Vintcore12Ena
1898 * 0x38, Vintcore12Sel
1899 * 0x40, Vintcore12LP
1900 * 0x80, VTVoutLP
1901 */
1902 REG_INIT(AB8500_REGUMISC1, 0x03, 0x80, 0xfe),
1903 /*
1904 * 0x02, VaudioEna
1905 * 0x04, VdmicEna
1906 * 0x08, Vamic1Ena
1907 * 0x10, Vamic2Ena
1908 */
1909 REG_INIT(AB8500_VAUDIOSUPPLY, 0x03, 0x83, 0x1e),
1910 /*
1911 * 0x01, Vamic1_dzout
1912 * 0x02, Vamic2_dzout
1913 */
1914 REG_INIT(AB8500_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
1915 /*
Lee Jones43a59112013-03-21 15:59:15 +00001916 * 0x03, VpllRegu (NOTE! PRCMU register bits)
Lee Jones33bc8f42013-03-21 15:59:02 +00001917 * 0x0c, VanaRegu
Bengt Jonsson79568b942011-03-11 11:54:46 +01001918 */
1919 REG_INIT(AB8500_VPLLVANAREGU, 0x04, 0x06, 0x0f),
1920 /*
1921 * 0x01, VrefDDREna
1922 * 0x02, VrefDDRSleepMode
1923 */
1924 REG_INIT(AB8500_VREFDDR, 0x04, 0x07, 0x03),
1925 /*
1926 * 0x03, VextSupply1Regu
1927 * 0x0c, VextSupply2Regu
1928 * 0x30, VextSupply3Regu
1929 * 0x40, ExtSupply2Bypass
1930 * 0x80, ExtSupply3Bypass
1931 */
1932 REG_INIT(AB8500_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
1933 /*
1934 * 0x03, Vaux1Regu
1935 * 0x0c, Vaux2Regu
1936 */
1937 REG_INIT(AB8500_VAUX12REGU, 0x04, 0x09, 0x0f),
1938 /*
1939 * 0x03, Vaux3Regu
1940 */
Lee Jones43a59112013-03-21 15:59:15 +00001941 REG_INIT(AB8500_VRF1VAUX3REGU, 0x04, 0x0a, 0x03),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001942 /*
1943 * 0x0f, Vaux1Sel
1944 */
1945 REG_INIT(AB8500_VAUX1SEL, 0x04, 0x1f, 0x0f),
1946 /*
1947 * 0x0f, Vaux2Sel
1948 */
1949 REG_INIT(AB8500_VAUX2SEL, 0x04, 0x20, 0x0f),
1950 /*
1951 * 0x07, Vaux3Sel
1952 */
Lee Jones43a59112013-03-21 15:59:15 +00001953 REG_INIT(AB8500_VRF1VAUX3SEL, 0x04, 0x21, 0x07),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001954 /*
1955 * 0x01, VextSupply12LP
1956 */
1957 REG_INIT(AB8500_REGUCTRL2SPARE, 0x04, 0x22, 0x01),
1958 /*
1959 * 0x04, Vaux1Disch
1960 * 0x08, Vaux2Disch
1961 * 0x10, Vaux3Disch
1962 * 0x20, Vintcore12Disch
1963 * 0x40, VTVoutDisch
1964 * 0x80, VaudioDisch
1965 */
Lee Jones43a59112013-03-21 15:59:15 +00001966 REG_INIT(AB8500_REGUCTRLDISCH, 0x04, 0x43, 0xfc),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001967 /*
1968 * 0x02, VanaDisch
1969 * 0x04, VdmicPullDownEna
1970 * 0x10, VdmicDisch
1971 */
Lee Jones43a59112013-03-21 15:59:15 +00001972 REG_INIT(AB8500_REGUCTRLDISCH2, 0x04, 0x44, 0x16),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001973};
1974
Lee Jones547f3842013-03-28 16:11:14 +00001975/* AB8505 register init */
1976static struct ab8500_reg_init ab8505_reg_init[] = {
1977 /*
1978 * 0x03, VarmRequestCtrl
1979 * 0x0c, VsmpsCRequestCtrl
1980 * 0x30, VsmpsARequestCtrl
1981 * 0xc0, VsmpsBRequestCtrl
1982 */
1983 REG_INIT(AB8505_REGUREQUESTCTRL1, 0x03, 0x03, 0xff),
1984 /*
1985 * 0x03, VsafeRequestCtrl
1986 * 0x0c, VpllRequestCtrl
1987 * 0x30, VanaRequestCtrl
1988 */
1989 REG_INIT(AB8505_REGUREQUESTCTRL2, 0x03, 0x04, 0x3f),
1990 /*
1991 * 0x30, Vaux1RequestCtrl
1992 * 0xc0, Vaux2RequestCtrl
1993 */
1994 REG_INIT(AB8505_REGUREQUESTCTRL3, 0x03, 0x05, 0xf0),
1995 /*
1996 * 0x03, Vaux3RequestCtrl
1997 * 0x04, SwHPReq
1998 */
1999 REG_INIT(AB8505_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
2000 /*
2001 * 0x01, VsmpsASysClkReq1HPValid
2002 * 0x02, VsmpsBSysClkReq1HPValid
2003 * 0x04, VsafeSysClkReq1HPValid
2004 * 0x08, VanaSysClkReq1HPValid
2005 * 0x10, VpllSysClkReq1HPValid
2006 * 0x20, Vaux1SysClkReq1HPValid
2007 * 0x40, Vaux2SysClkReq1HPValid
2008 * 0x80, Vaux3SysClkReq1HPValid
2009 */
2010 REG_INIT(AB8505_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xff),
2011 /*
2012 * 0x01, VsmpsCSysClkReq1HPValid
2013 * 0x02, VarmSysClkReq1HPValid
2014 * 0x04, VbbSysClkReq1HPValid
2015 * 0x08, VsmpsMSysClkReq1HPValid
2016 */
2017 REG_INIT(AB8505_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x0f),
2018 /*
2019 * 0x01, VsmpsAHwHPReq1Valid
2020 * 0x02, VsmpsBHwHPReq1Valid
2021 * 0x04, VsafeHwHPReq1Valid
2022 * 0x08, VanaHwHPReq1Valid
2023 * 0x10, VpllHwHPReq1Valid
2024 * 0x20, Vaux1HwHPReq1Valid
2025 * 0x40, Vaux2HwHPReq1Valid
2026 * 0x80, Vaux3HwHPReq1Valid
2027 */
2028 REG_INIT(AB8505_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xff),
2029 /*
2030 * 0x08, VsmpsMHwHPReq1Valid
2031 */
2032 REG_INIT(AB8505_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x08),
2033 /*
2034 * 0x01, VsmpsAHwHPReq2Valid
2035 * 0x02, VsmpsBHwHPReq2Valid
2036 * 0x04, VsafeHwHPReq2Valid
2037 * 0x08, VanaHwHPReq2Valid
2038 * 0x10, VpllHwHPReq2Valid
2039 * 0x20, Vaux1HwHPReq2Valid
2040 * 0x40, Vaux2HwHPReq2Valid
2041 * 0x80, Vaux3HwHPReq2Valid
2042 */
2043 REG_INIT(AB8505_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xff),
2044 /*
2045 * 0x08, VsmpsMHwHPReq2Valid
2046 */
2047 REG_INIT(AB8505_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x08),
2048 /*
2049 * 0x01, VsmpsCSwHPReqValid
2050 * 0x02, VarmSwHPReqValid
2051 * 0x04, VsmpsASwHPReqValid
2052 * 0x08, VsmpsBSwHPReqValid
2053 * 0x10, VsafeSwHPReqValid
2054 * 0x20, VanaSwHPReqValid
2055 * 0x40, VpllSwHPReqValid
2056 * 0x80, Vaux1SwHPReqValid
2057 */
2058 REG_INIT(AB8505_REGUSWHPREQVALID1, 0x03, 0x0d, 0xff),
2059 /*
2060 * 0x01, Vaux2SwHPReqValid
2061 * 0x02, Vaux3SwHPReqValid
2062 * 0x20, VsmpsMSwHPReqValid
2063 */
2064 REG_INIT(AB8505_REGUSWHPREQVALID2, 0x03, 0x0e, 0x23),
2065 /*
2066 * 0x02, SysClkReq2Valid1
2067 * 0x04, SysClkReq3Valid1
2068 * 0x08, SysClkReq4Valid1
2069 */
2070 REG_INIT(AB8505_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0x0e),
2071 /*
2072 * 0x02, SysClkReq2Valid2
2073 * 0x04, SysClkReq3Valid2
2074 * 0x08, SysClkReq4Valid2
2075 */
2076 REG_INIT(AB8505_REGUSYSCLKREQVALID2, 0x03, 0x10, 0x0e),
2077 /*
2078 * 0x01, Vaux4SwHPReqValid
2079 * 0x02, Vaux4HwHPReq2Valid
2080 * 0x04, Vaux4HwHPReq1Valid
2081 * 0x08, Vaux4SysClkReq1HPValid
2082 */
2083 REG_INIT(AB8505_REGUVAUX4REQVALID, 0x03, 0x11, 0x0f),
2084 /*
2085 * 0x02, VadcEna
2086 * 0x04, VintCore12Ena
2087 * 0x38, VintCore12Sel
2088 * 0x40, VintCore12LP
2089 * 0x80, VadcLP
2090 */
2091 REG_INIT(AB8505_REGUMISC1, 0x03, 0x80, 0xfe),
2092 /*
2093 * 0x02, VaudioEna
2094 * 0x04, VdmicEna
2095 * 0x08, Vamic1Ena
2096 * 0x10, Vamic2Ena
2097 */
2098 REG_INIT(AB8505_VAUDIOSUPPLY, 0x03, 0x83, 0x1e),
2099 /*
2100 * 0x01, Vamic1_dzout
2101 * 0x02, Vamic2_dzout
2102 */
2103 REG_INIT(AB8505_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
2104 /*
2105 * 0x03, VsmpsARegu
2106 * 0x0c, VsmpsASelCtrl
2107 * 0x10, VsmpsAAutoMode
2108 * 0x20, VsmpsAPWMMode
2109 */
2110 REG_INIT(AB8505_VSMPSAREGU, 0x04, 0x03, 0x3f),
2111 /*
2112 * 0x03, VsmpsBRegu
2113 * 0x0c, VsmpsBSelCtrl
2114 * 0x10, VsmpsBAutoMode
2115 * 0x20, VsmpsBPWMMode
2116 */
2117 REG_INIT(AB8505_VSMPSBREGU, 0x04, 0x04, 0x3f),
2118 /*
2119 * 0x03, VsafeRegu
2120 * 0x0c, VsafeSelCtrl
2121 * 0x10, VsafeAutoMode
2122 * 0x20, VsafePWMMode
2123 */
2124 REG_INIT(AB8505_VSAFEREGU, 0x04, 0x05, 0x3f),
2125 /*
2126 * 0x03, VpllRegu (NOTE! PRCMU register bits)
2127 * 0x0c, VanaRegu
2128 */
2129 REG_INIT(AB8505_VPLLVANAREGU, 0x04, 0x06, 0x0f),
2130 /*
2131 * 0x03, VextSupply1Regu
2132 * 0x0c, VextSupply2Regu
2133 * 0x30, VextSupply3Regu
2134 * 0x40, ExtSupply2Bypass
2135 * 0x80, ExtSupply3Bypass
2136 */
2137 REG_INIT(AB8505_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
2138 /*
2139 * 0x03, Vaux1Regu
2140 * 0x0c, Vaux2Regu
2141 */
2142 REG_INIT(AB8505_VAUX12REGU, 0x04, 0x09, 0x0f),
2143 /*
2144 * 0x0f, Vaux3Regu
2145 */
2146 REG_INIT(AB8505_VRF1VAUX3REGU, 0x04, 0x0a, 0x0f),
2147 /*
2148 * 0x3f, VsmpsASel1
2149 */
2150 REG_INIT(AB8505_VSMPSASEL1, 0x04, 0x13, 0x3f),
2151 /*
2152 * 0x3f, VsmpsASel2
2153 */
2154 REG_INIT(AB8505_VSMPSASEL2, 0x04, 0x14, 0x3f),
2155 /*
2156 * 0x3f, VsmpsASel3
2157 */
2158 REG_INIT(AB8505_VSMPSASEL3, 0x04, 0x15, 0x3f),
2159 /*
2160 * 0x3f, VsmpsBSel1
2161 */
2162 REG_INIT(AB8505_VSMPSBSEL1, 0x04, 0x17, 0x3f),
2163 /*
2164 * 0x3f, VsmpsBSel2
2165 */
2166 REG_INIT(AB8505_VSMPSBSEL2, 0x04, 0x18, 0x3f),
2167 /*
2168 * 0x3f, VsmpsBSel3
2169 */
2170 REG_INIT(AB8505_VSMPSBSEL3, 0x04, 0x19, 0x3f),
2171 /*
2172 * 0x7f, VsafeSel1
2173 */
2174 REG_INIT(AB8505_VSAFESEL1, 0x04, 0x1b, 0x7f),
2175 /*
2176 * 0x3f, VsafeSel2
2177 */
2178 REG_INIT(AB8505_VSAFESEL2, 0x04, 0x1c, 0x7f),
2179 /*
2180 * 0x3f, VsafeSel3
2181 */
2182 REG_INIT(AB8505_VSAFESEL3, 0x04, 0x1d, 0x7f),
2183 /*
2184 * 0x0f, Vaux1Sel
2185 */
2186 REG_INIT(AB8505_VAUX1SEL, 0x04, 0x1f, 0x0f),
2187 /*
2188 * 0x0f, Vaux2Sel
2189 */
2190 REG_INIT(AB8505_VAUX2SEL, 0x04, 0x20, 0x0f),
2191 /*
2192 * 0x07, Vaux3Sel
2193 * 0x30, VRF1Sel
2194 */
2195 REG_INIT(AB8505_VRF1VAUX3SEL, 0x04, 0x21, 0x37),
2196 /*
2197 * 0x03, Vaux4RequestCtrl
2198 */
2199 REG_INIT(AB8505_VAUX4REQCTRL, 0x04, 0x2d, 0x03),
2200 /*
2201 * 0x03, Vaux4Regu
2202 */
2203 REG_INIT(AB8505_VAUX4REGU, 0x04, 0x2e, 0x03),
2204 /*
2205 * 0x0f, Vaux4Sel
2206 */
2207 REG_INIT(AB8505_VAUX4SEL, 0x04, 0x2f, 0x0f),
2208 /*
2209 * 0x04, Vaux1Disch
2210 * 0x08, Vaux2Disch
2211 * 0x10, Vaux3Disch
2212 * 0x20, Vintcore12Disch
2213 * 0x40, VTVoutDisch
2214 * 0x80, VaudioDisch
2215 */
2216 REG_INIT(AB8505_REGUCTRLDISCH, 0x04, 0x43, 0xfc),
2217 /*
2218 * 0x02, VanaDisch
2219 * 0x04, VdmicPullDownEna
2220 * 0x10, VdmicDisch
2221 */
2222 REG_INIT(AB8505_REGUCTRLDISCH2, 0x04, 0x44, 0x16),
2223 /*
2224 * 0x01, Vaux4Disch
2225 */
2226 REG_INIT(AB8505_REGUCTRLDISCH3, 0x04, 0x48, 0x01),
2227 /*
2228 * 0x07, Vaux5Sel
2229 * 0x08, Vaux5LP
2230 * 0x10, Vaux5Ena
2231 * 0x20, Vaux5Disch
2232 * 0x40, Vaux5DisSfst
2233 * 0x80, Vaux5DisPulld
2234 */
2235 REG_INIT(AB8505_CTRLVAUX5, 0x01, 0x55, 0xff),
2236 /*
2237 * 0x07, Vaux6Sel
2238 * 0x08, Vaux6LP
2239 * 0x10, Vaux6Ena
2240 * 0x80, Vaux6DisPulld
2241 */
2242 REG_INIT(AB8505_CTRLVAUX6, 0x01, 0x56, 0x9f),
2243};
2244
Lee Jones8e6a8d72013-03-28 16:11:11 +00002245/* AB9540 register init */
2246static struct ab8500_reg_init ab9540_reg_init[] = {
2247 /*
2248 * 0x03, VarmRequestCtrl
2249 * 0x0c, VapeRequestCtrl
2250 * 0x30, Vsmps1RequestCtrl
2251 * 0xc0, Vsmps2RequestCtrl
2252 */
2253 REG_INIT(AB9540_REGUREQUESTCTRL1, 0x03, 0x03, 0xff),
2254 /*
2255 * 0x03, Vsmps3RequestCtrl
2256 * 0x0c, VpllRequestCtrl
2257 * 0x30, VanaRequestCtrl
2258 * 0xc0, VextSupply1RequestCtrl
2259 */
2260 REG_INIT(AB9540_REGUREQUESTCTRL2, 0x03, 0x04, 0xff),
2261 /*
2262 * 0x03, VextSupply2RequestCtrl
2263 * 0x0c, VextSupply3RequestCtrl
2264 * 0x30, Vaux1RequestCtrl
2265 * 0xc0, Vaux2RequestCtrl
2266 */
2267 REG_INIT(AB9540_REGUREQUESTCTRL3, 0x03, 0x05, 0xff),
2268 /*
2269 * 0x03, Vaux3RequestCtrl
2270 * 0x04, SwHPReq
2271 */
2272 REG_INIT(AB9540_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
2273 /*
2274 * 0x01, Vsmps1SysClkReq1HPValid
2275 * 0x02, Vsmps2SysClkReq1HPValid
2276 * 0x04, Vsmps3SysClkReq1HPValid
2277 * 0x08, VanaSysClkReq1HPValid
2278 * 0x10, VpllSysClkReq1HPValid
2279 * 0x20, Vaux1SysClkReq1HPValid
2280 * 0x40, Vaux2SysClkReq1HPValid
2281 * 0x80, Vaux3SysClkReq1HPValid
2282 */
2283 REG_INIT(AB9540_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xff),
2284 /*
2285 * 0x01, VapeSysClkReq1HPValid
2286 * 0x02, VarmSysClkReq1HPValid
2287 * 0x04, VbbSysClkReq1HPValid
2288 * 0x08, VmodSysClkReq1HPValid
2289 * 0x10, VextSupply1SysClkReq1HPValid
2290 * 0x20, VextSupply2SysClkReq1HPValid
2291 * 0x40, VextSupply3SysClkReq1HPValid
2292 */
2293 REG_INIT(AB9540_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x7f),
2294 /*
2295 * 0x01, Vsmps1HwHPReq1Valid
2296 * 0x02, Vsmps2HwHPReq1Valid
2297 * 0x04, Vsmps3HwHPReq1Valid
2298 * 0x08, VanaHwHPReq1Valid
2299 * 0x10, VpllHwHPReq1Valid
2300 * 0x20, Vaux1HwHPReq1Valid
2301 * 0x40, Vaux2HwHPReq1Valid
2302 * 0x80, Vaux3HwHPReq1Valid
2303 */
2304 REG_INIT(AB9540_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xff),
2305 /*
2306 * 0x01, VextSupply1HwHPReq1Valid
2307 * 0x02, VextSupply2HwHPReq1Valid
2308 * 0x04, VextSupply3HwHPReq1Valid
2309 * 0x08, VmodHwHPReq1Valid
2310 */
2311 REG_INIT(AB9540_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x0f),
2312 /*
2313 * 0x01, Vsmps1HwHPReq2Valid
2314 * 0x02, Vsmps2HwHPReq2Valid
2315 * 0x03, Vsmps3HwHPReq2Valid
2316 * 0x08, VanaHwHPReq2Valid
2317 * 0x10, VpllHwHPReq2Valid
2318 * 0x20, Vaux1HwHPReq2Valid
2319 * 0x40, Vaux2HwHPReq2Valid
2320 * 0x80, Vaux3HwHPReq2Valid
2321 */
2322 REG_INIT(AB9540_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xff),
2323 /*
2324 * 0x01, VextSupply1HwHPReq2Valid
2325 * 0x02, VextSupply2HwHPReq2Valid
2326 * 0x04, VextSupply3HwHPReq2Valid
2327 * 0x08, VmodHwHPReq2Valid
2328 */
2329 REG_INIT(AB9540_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x0f),
2330 /*
2331 * 0x01, VapeSwHPReqValid
2332 * 0x02, VarmSwHPReqValid
2333 * 0x04, Vsmps1SwHPReqValid
2334 * 0x08, Vsmps2SwHPReqValid
2335 * 0x10, Vsmps3SwHPReqValid
2336 * 0x20, VanaSwHPReqValid
2337 * 0x40, VpllSwHPReqValid
2338 * 0x80, Vaux1SwHPReqValid
2339 */
2340 REG_INIT(AB9540_REGUSWHPREQVALID1, 0x03, 0x0d, 0xff),
2341 /*
2342 * 0x01, Vaux2SwHPReqValid
2343 * 0x02, Vaux3SwHPReqValid
2344 * 0x04, VextSupply1SwHPReqValid
2345 * 0x08, VextSupply2SwHPReqValid
2346 * 0x10, VextSupply3SwHPReqValid
2347 * 0x20, VmodSwHPReqValid
2348 */
2349 REG_INIT(AB9540_REGUSWHPREQVALID2, 0x03, 0x0e, 0x3f),
2350 /*
2351 * 0x02, SysClkReq2Valid1
2352 * ...
2353 * 0x80, SysClkReq8Valid1
2354 */
2355 REG_INIT(AB9540_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0xfe),
2356 /*
2357 * 0x02, SysClkReq2Valid2
2358 * ...
2359 * 0x80, SysClkReq8Valid2
2360 */
2361 REG_INIT(AB9540_REGUSYSCLKREQVALID2, 0x03, 0x10, 0xfe),
2362 /*
2363 * 0x01, Vaux4SwHPReqValid
2364 * 0x02, Vaux4HwHPReq2Valid
2365 * 0x04, Vaux4HwHPReq1Valid
2366 * 0x08, Vaux4SysClkReq1HPValid
2367 */
2368 REG_INIT(AB9540_REGUVAUX4REQVALID, 0x03, 0x11, 0x0f),
2369 /*
2370 * 0x02, VTVoutEna
2371 * 0x04, Vintcore12Ena
2372 * 0x38, Vintcore12Sel
2373 * 0x40, Vintcore12LP
2374 * 0x80, VTVoutLP
2375 */
2376 REG_INIT(AB9540_REGUMISC1, 0x03, 0x80, 0xfe),
2377 /*
2378 * 0x02, VaudioEna
2379 * 0x04, VdmicEna
2380 * 0x08, Vamic1Ena
2381 * 0x10, Vamic2Ena
2382 */
2383 REG_INIT(AB9540_VAUDIOSUPPLY, 0x03, 0x83, 0x1e),
2384 /*
2385 * 0x01, Vamic1_dzout
2386 * 0x02, Vamic2_dzout
2387 */
2388 REG_INIT(AB9540_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
2389 /*
2390 * 0x03, Vsmps1Regu
2391 * 0x0c, Vsmps1SelCtrl
2392 * 0x10, Vsmps1AutoMode
2393 * 0x20, Vsmps1PWMMode
2394 */
2395 REG_INIT(AB9540_VSMPS1REGU, 0x04, 0x03, 0x3f),
2396 /*
2397 * 0x03, Vsmps2Regu
2398 * 0x0c, Vsmps2SelCtrl
2399 * 0x10, Vsmps2AutoMode
2400 * 0x20, Vsmps2PWMMode
2401 */
2402 REG_INIT(AB9540_VSMPS2REGU, 0x04, 0x04, 0x3f),
2403 /*
2404 * 0x03, Vsmps3Regu
2405 * 0x0c, Vsmps3SelCtrl
2406 * NOTE! PRCMU register
2407 */
2408 REG_INIT(AB9540_VSMPS3REGU, 0x04, 0x05, 0x0f),
2409 /*
2410 * 0x03, VpllRegu
2411 * 0x0c, VanaRegu
2412 */
2413 REG_INIT(AB9540_VPLLVANAREGU, 0x04, 0x06, 0x0f),
2414 /*
2415 * 0x03, VextSupply1Regu
2416 * 0x0c, VextSupply2Regu
2417 * 0x30, VextSupply3Regu
2418 * 0x40, ExtSupply2Bypass
2419 * 0x80, ExtSupply3Bypass
2420 */
2421 REG_INIT(AB9540_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
2422 /*
2423 * 0x03, Vaux1Regu
2424 * 0x0c, Vaux2Regu
2425 */
2426 REG_INIT(AB9540_VAUX12REGU, 0x04, 0x09, 0x0f),
2427 /*
2428 * 0x0c, Vrf1Regu
2429 * 0x03, Vaux3Regu
2430 */
2431 REG_INIT(AB9540_VRF1VAUX3REGU, 0x04, 0x0a, 0x0f),
2432 /*
2433 * 0x3f, Vsmps1Sel1
2434 */
2435 REG_INIT(AB9540_VSMPS1SEL1, 0x04, 0x13, 0x3f),
2436 /*
2437 * 0x3f, Vsmps1Sel2
2438 */
2439 REG_INIT(AB9540_VSMPS1SEL2, 0x04, 0x14, 0x3f),
2440 /*
2441 * 0x3f, Vsmps1Sel3
2442 */
2443 REG_INIT(AB9540_VSMPS1SEL3, 0x04, 0x15, 0x3f),
2444 /*
2445 * 0x3f, Vsmps2Sel1
2446 */
2447 REG_INIT(AB9540_VSMPS2SEL1, 0x04, 0x17, 0x3f),
2448 /*
2449 * 0x3f, Vsmps2Sel2
2450 */
2451 REG_INIT(AB9540_VSMPS2SEL2, 0x04, 0x18, 0x3f),
2452 /*
2453 * 0x3f, Vsmps2Sel3
2454 */
2455 REG_INIT(AB9540_VSMPS2SEL3, 0x04, 0x19, 0x3f),
2456 /*
2457 * 0x7f, Vsmps3Sel1
2458 * NOTE! PRCMU register
2459 */
2460 REG_INIT(AB9540_VSMPS3SEL1, 0x04, 0x1b, 0x7f),
2461 /*
2462 * 0x7f, Vsmps3Sel2
2463 * NOTE! PRCMU register
2464 */
2465 REG_INIT(AB9540_VSMPS3SEL2, 0x04, 0x1c, 0x7f),
2466 /*
2467 * 0x0f, Vaux1Sel
2468 */
2469 REG_INIT(AB9540_VAUX1SEL, 0x04, 0x1f, 0x0f),
2470 /*
2471 * 0x0f, Vaux2Sel
2472 */
2473 REG_INIT(AB9540_VAUX2SEL, 0x04, 0x20, 0x0f),
2474 /*
2475 * 0x07, Vaux3Sel
2476 * 0x30, Vrf1Sel
2477 */
2478 REG_INIT(AB9540_VRF1VAUX3SEL, 0x04, 0x21, 0x37),
2479 /*
2480 * 0x01, VextSupply12LP
2481 */
2482 REG_INIT(AB9540_REGUCTRL2SPARE, 0x04, 0x22, 0x01),
2483 /*
2484 * 0x03, Vaux4RequestCtrl
2485 */
2486 REG_INIT(AB9540_VAUX4REQCTRL, 0x04, 0x2d, 0x03),
2487 /*
2488 * 0x03, Vaux4Regu
2489 */
2490 REG_INIT(AB9540_VAUX4REGU, 0x04, 0x2e, 0x03),
2491 /*
2492 * 0x08, Vaux4Sel
2493 */
2494 REG_INIT(AB9540_VAUX4SEL, 0x04, 0x2f, 0x0f),
2495 /*
2496 * 0x01, VpllDisch
2497 * 0x02, Vrf1Disch
2498 * 0x04, Vaux1Disch
2499 * 0x08, Vaux2Disch
2500 * 0x10, Vaux3Disch
2501 * 0x20, Vintcore12Disch
2502 * 0x40, VTVoutDisch
2503 * 0x80, VaudioDisch
2504 */
2505 REG_INIT(AB9540_REGUCTRLDISCH, 0x04, 0x43, 0xff),
2506 /*
2507 * 0x01, VsimDisch
2508 * 0x02, VanaDisch
2509 * 0x04, VdmicPullDownEna
2510 * 0x08, VpllPullDownEna
2511 * 0x10, VdmicDisch
2512 */
2513 REG_INIT(AB9540_REGUCTRLDISCH2, 0x04, 0x44, 0x1f),
2514 /*
2515 * 0x01, Vaux4Disch
2516 */
2517 REG_INIT(AB9540_REGUCTRLDISCH3, 0x04, 0x48, 0x01),
2518};
2519
Lee Jonesae0a9a32013-03-28 16:11:16 +00002520/* AB8540 register init */
2521static struct ab8500_reg_init ab8540_reg_init[] = {
2522 /*
2523 * 0x01, VSimSycClkReq1Valid
2524 * 0x02, VSimSycClkReq2Valid
2525 * 0x04, VSimSycClkReq3Valid
2526 * 0x08, VSimSycClkReq4Valid
2527 * 0x10, VSimSycClkReq5Valid
2528 * 0x20, VSimSycClkReq6Valid
2529 * 0x40, VSimSycClkReq7Valid
2530 * 0x80, VSimSycClkReq8Valid
2531 */
2532 REG_INIT(AB8540_VSIMSYSCLKCTRL, 0x02, 0x33, 0xff),
2533 /*
2534 * 0x03, VarmRequestCtrl
2535 * 0x0c, VapeRequestCtrl
2536 * 0x30, Vsmps1RequestCtrl
2537 * 0xc0, Vsmps2RequestCtrl
2538 */
2539 REG_INIT(AB8540_REGUREQUESTCTRL1, 0x03, 0x03, 0xff),
2540 /*
2541 * 0x03, Vsmps3RequestCtrl
2542 * 0x0c, VpllRequestCtrl
2543 * 0x30, VanaRequestCtrl
2544 * 0xc0, VextSupply1RequestCtrl
2545 */
2546 REG_INIT(AB8540_REGUREQUESTCTRL2, 0x03, 0x04, 0xff),
2547 /*
2548 * 0x03, VextSupply2RequestCtrl
2549 * 0x0c, VextSupply3RequestCtrl
2550 * 0x30, Vaux1RequestCtrl
2551 * 0xc0, Vaux2RequestCtrl
2552 */
2553 REG_INIT(AB8540_REGUREQUESTCTRL3, 0x03, 0x05, 0xff),
2554 /*
2555 * 0x03, Vaux3RequestCtrl
2556 * 0x04, SwHPReq
2557 */
2558 REG_INIT(AB8540_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
2559 /*
2560 * 0x01, Vsmps1SysClkReq1HPValid
2561 * 0x02, Vsmps2SysClkReq1HPValid
2562 * 0x04, Vsmps3SysClkReq1HPValid
2563 * 0x08, VanaSysClkReq1HPValid
2564 * 0x10, VpllSysClkReq1HPValid
2565 * 0x20, Vaux1SysClkReq1HPValid
2566 * 0x40, Vaux2SysClkReq1HPValid
2567 * 0x80, Vaux3SysClkReq1HPValid
2568 */
2569 REG_INIT(AB8540_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xff),
2570 /*
2571 * 0x01, VapeSysClkReq1HPValid
2572 * 0x02, VarmSysClkReq1HPValid
2573 * 0x04, VbbSysClkReq1HPValid
2574 * 0x10, VextSupply1SysClkReq1HPValid
2575 * 0x20, VextSupply2SysClkReq1HPValid
2576 * 0x40, VextSupply3SysClkReq1HPValid
2577 */
2578 REG_INIT(AB8540_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x77),
2579 /*
2580 * 0x01, Vsmps1HwHPReq1Valid
2581 * 0x02, Vsmps2HwHPReq1Valid
2582 * 0x04, Vsmps3HwHPReq1Valid
2583 * 0x08, VanaHwHPReq1Valid
2584 * 0x10, VpllHwHPReq1Valid
2585 * 0x20, Vaux1HwHPReq1Valid
2586 * 0x40, Vaux2HwHPReq1Valid
2587 * 0x80, Vaux3HwHPReq1Valid
2588 */
2589 REG_INIT(AB8540_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xff),
2590 /*
2591 * 0x01, VextSupply1HwHPReq1Valid
2592 * 0x02, VextSupply2HwHPReq1Valid
2593 * 0x04, VextSupply3HwHPReq1Valid
2594 */
2595 REG_INIT(AB8540_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x07),
2596 /*
2597 * 0x01, Vsmps1HwHPReq2Valid
2598 * 0x02, Vsmps2HwHPReq2Valid
2599 * 0x03, Vsmps3HwHPReq2Valid
2600 * 0x08, VanaHwHPReq2Valid
2601 * 0x10, VpllHwHPReq2Valid
2602 * 0x20, Vaux1HwHPReq2Valid
2603 * 0x40, Vaux2HwHPReq2Valid
2604 * 0x80, Vaux3HwHPReq2Valid
2605 */
2606 REG_INIT(AB8540_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xff),
2607 /*
2608 * 0x01, VextSupply1HwHPReq2Valid
2609 * 0x02, VextSupply2HwHPReq2Valid
2610 * 0x04, VextSupply3HwHPReq2Valid
2611 */
2612 REG_INIT(AB8540_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x07),
2613 /*
2614 * 0x01, VapeSwHPReqValid
2615 * 0x02, VarmSwHPReqValid
2616 * 0x04, Vsmps1SwHPReqValid
2617 * 0x08, Vsmps2SwHPReqValid
2618 * 0x10, Vsmps3SwHPReqValid
2619 * 0x20, VanaSwHPReqValid
2620 * 0x40, VpllSwHPReqValid
2621 * 0x80, Vaux1SwHPReqValid
2622 */
2623 REG_INIT(AB8540_REGUSWHPREQVALID1, 0x03, 0x0d, 0xff),
2624 /*
2625 * 0x01, Vaux2SwHPReqValid
2626 * 0x02, Vaux3SwHPReqValid
2627 * 0x04, VextSupply1SwHPReqValid
2628 * 0x08, VextSupply2SwHPReqValid
2629 * 0x10, VextSupply3SwHPReqValid
2630 */
2631 REG_INIT(AB8540_REGUSWHPREQVALID2, 0x03, 0x0e, 0x1f),
2632 /*
2633 * 0x02, SysClkReq2Valid1
2634 * ...
2635 * 0x80, SysClkReq8Valid1
2636 */
2637 REG_INIT(AB8540_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0xff),
2638 /*
2639 * 0x02, SysClkReq2Valid2
2640 * ...
2641 * 0x80, SysClkReq8Valid2
2642 */
2643 REG_INIT(AB8540_REGUSYSCLKREQVALID2, 0x03, 0x10, 0xff),
2644 /*
2645 * 0x01, Vaux4SwHPReqValid
2646 * 0x02, Vaux4HwHPReq2Valid
2647 * 0x04, Vaux4HwHPReq1Valid
2648 * 0x08, Vaux4SysClkReq1HPValid
2649 */
2650 REG_INIT(AB8540_REGUVAUX4REQVALID, 0x03, 0x11, 0x0f),
2651 /*
2652 * 0x01, Vaux5SwHPReqValid
2653 * 0x02, Vaux5HwHPReq2Valid
2654 * 0x04, Vaux5HwHPReq1Valid
2655 * 0x08, Vaux5SysClkReq1HPValid
2656 */
2657 REG_INIT(AB8540_REGUVAUX5REQVALID, 0x03, 0x12, 0x0f),
2658 /*
2659 * 0x01, Vaux6SwHPReqValid
2660 * 0x02, Vaux6HwHPReq2Valid
2661 * 0x04, Vaux6HwHPReq1Valid
2662 * 0x08, Vaux6SysClkReq1HPValid
2663 */
2664 REG_INIT(AB8540_REGUVAUX6REQVALID, 0x03, 0x13, 0x0f),
2665 /*
2666 * 0x01, VclkbSwHPReqValid
2667 * 0x02, VclkbHwHPReq2Valid
2668 * 0x04, VclkbHwHPReq1Valid
2669 * 0x08, VclkbSysClkReq1HPValid
2670 */
2671 REG_INIT(AB8540_REGUVCLKBREQVALID, 0x03, 0x14, 0x0f),
2672 /*
2673 * 0x01, Vrf1SwHPReqValid
2674 * 0x02, Vrf1HwHPReq2Valid
2675 * 0x04, Vrf1HwHPReq1Valid
2676 * 0x08, Vrf1SysClkReq1HPValid
2677 */
2678 REG_INIT(AB8540_REGUVRF1REQVALID, 0x03, 0x15, 0x0f),
2679 /*
2680 * 0x02, VTVoutEna
2681 * 0x04, Vintcore12Ena
2682 * 0x38, Vintcore12Sel
2683 * 0x40, Vintcore12LP
2684 * 0x80, VTVoutLP
2685 */
2686 REG_INIT(AB8540_REGUMISC1, 0x03, 0x80, 0xfe),
2687 /*
2688 * 0x02, VaudioEna
2689 * 0x04, VdmicEna
2690 * 0x08, Vamic1Ena
2691 * 0x10, Vamic2Ena
2692 * 0x20, Vamic12LP
2693 * 0xC0, VdmicSel
2694 */
2695 REG_INIT(AB8540_VAUDIOSUPPLY, 0x03, 0x83, 0xfe),
2696 /*
2697 * 0x01, Vamic1_dzout
2698 * 0x02, Vamic2_dzout
2699 */
2700 REG_INIT(AB8540_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
2701 /*
2702 * 0x07, VHSICSel
2703 * 0x08, VHSICOffState
2704 * 0x10, VHSIEna
2705 * 0x20, VHSICLP
2706 */
2707 REG_INIT(AB8540_VHSIC, 0x03, 0x87, 0x3f),
2708 /*
2709 * 0x07, VSDIOSel
2710 * 0x08, VSDIOOffState
2711 * 0x10, VSDIOEna
2712 * 0x20, VSDIOLP
2713 */
2714 REG_INIT(AB8540_VSDIO, 0x03, 0x88, 0x3f),
2715 /*
2716 * 0x03, Vsmps1Regu
2717 * 0x0c, Vsmps1SelCtrl
2718 * 0x10, Vsmps1AutoMode
2719 * 0x20, Vsmps1PWMMode
2720 */
2721 REG_INIT(AB8540_VSMPS1REGU, 0x04, 0x03, 0x3f),
2722 /*
2723 * 0x03, Vsmps2Regu
2724 * 0x0c, Vsmps2SelCtrl
2725 * 0x10, Vsmps2AutoMode
2726 * 0x20, Vsmps2PWMMode
2727 */
2728 REG_INIT(AB8540_VSMPS2REGU, 0x04, 0x04, 0x3f),
2729 /*
2730 * 0x03, Vsmps3Regu
2731 * 0x0c, Vsmps3SelCtrl
2732 * 0x10, Vsmps3AutoMode
2733 * 0x20, Vsmps3PWMMode
2734 * NOTE! PRCMU register
2735 */
2736 REG_INIT(AB8540_VSMPS3REGU, 0x04, 0x05, 0x0f),
2737 /*
2738 * 0x03, VpllRegu
2739 * 0x0c, VanaRegu
2740 */
2741 REG_INIT(AB8540_VPLLVANAREGU, 0x04, 0x06, 0x0f),
2742 /*
2743 * 0x03, VextSupply1Regu
2744 * 0x0c, VextSupply2Regu
2745 * 0x30, VextSupply3Regu
2746 * 0x40, ExtSupply2Bypass
2747 * 0x80, ExtSupply3Bypass
2748 */
2749 REG_INIT(AB8540_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
2750 /*
2751 * 0x03, Vaux1Regu
2752 * 0x0c, Vaux2Regu
2753 */
2754 REG_INIT(AB8540_VAUX12REGU, 0x04, 0x09, 0x0f),
2755 /*
2756 * 0x0c, VRF1Regu
2757 * 0x03, Vaux3Regu
2758 */
2759 REG_INIT(AB8540_VRF1VAUX3REGU, 0x04, 0x0a, 0x0f),
2760 /*
2761 * 0x3f, Vsmps1Sel1
2762 */
2763 REG_INIT(AB8540_VSMPS1SEL1, 0x04, 0x13, 0x3f),
2764 /*
2765 * 0x3f, Vsmps1Sel2
2766 */
2767 REG_INIT(AB8540_VSMPS1SEL2, 0x04, 0x14, 0x3f),
2768 /*
2769 * 0x3f, Vsmps1Sel3
2770 */
2771 REG_INIT(AB8540_VSMPS1SEL3, 0x04, 0x15, 0x3f),
2772 /*
2773 * 0x3f, Vsmps2Sel1
2774 */
2775 REG_INIT(AB8540_VSMPS2SEL1, 0x04, 0x17, 0x3f),
2776 /*
2777 * 0x3f, Vsmps2Sel2
2778 */
2779 REG_INIT(AB8540_VSMPS2SEL2, 0x04, 0x18, 0x3f),
2780 /*
2781 * 0x3f, Vsmps2Sel3
2782 */
2783 REG_INIT(AB8540_VSMPS2SEL3, 0x04, 0x19, 0x3f),
2784 /*
2785 * 0x7f, Vsmps3Sel1
2786 * NOTE! PRCMU register
2787 */
2788 REG_INIT(AB8540_VSMPS3SEL1, 0x04, 0x1b, 0x7f),
2789 /*
2790 * 0x7f, Vsmps3Sel2
2791 * NOTE! PRCMU register
2792 */
2793 REG_INIT(AB8540_VSMPS3SEL2, 0x04, 0x1c, 0x7f),
2794 /*
2795 * 0x0f, Vaux1Sel
2796 */
2797 REG_INIT(AB8540_VAUX1SEL, 0x04, 0x1f, 0x0f),
2798 /*
2799 * 0x0f, Vaux2Sel
2800 */
2801 REG_INIT(AB8540_VAUX2SEL, 0x04, 0x20, 0x0f),
2802 /*
2803 * 0x07, Vaux3Sel
2804 * 0x70, Vrf1Sel
2805 */
2806 REG_INIT(AB8540_VRF1VAUX3SEL, 0x04, 0x21, 0x77),
2807 /*
2808 * 0x01, VextSupply12LP
2809 */
2810 REG_INIT(AB8540_REGUCTRL2SPARE, 0x04, 0x22, 0x01),
2811 /*
2812 * 0x07, Vanasel
2813 * 0x30, Vpllsel
2814 */
2815 REG_INIT(AB8540_VANAVPLLSEL, 0x04, 0x29, 0x37),
2816 /*
2817 * 0x03, Vaux4RequestCtrl
2818 */
2819 REG_INIT(AB8540_VAUX4REQCTRL, 0x04, 0x2d, 0x03),
2820 /*
2821 * 0x03, Vaux4Regu
2822 */
2823 REG_INIT(AB8540_VAUX4REGU, 0x04, 0x2e, 0x03),
2824 /*
2825 * 0x0f, Vaux4Sel
2826 */
2827 REG_INIT(AB8540_VAUX4SEL, 0x04, 0x2f, 0x0f),
2828 /*
2829 * 0x03, Vaux5RequestCtrl
2830 */
2831 REG_INIT(AB8540_VAUX5REQCTRL, 0x04, 0x31, 0x03),
2832 /*
2833 * 0x03, Vaux5Regu
2834 */
2835 REG_INIT(AB8540_VAUX5REGU, 0x04, 0x32, 0x03),
2836 /*
2837 * 0x3f, Vaux5Sel
2838 */
2839 REG_INIT(AB8540_VAUX5SEL, 0x04, 0x33, 0x3f),
2840 /*
2841 * 0x03, Vaux6RequestCtrl
2842 */
2843 REG_INIT(AB8540_VAUX6REQCTRL, 0x04, 0x34, 0x03),
2844 /*
2845 * 0x03, Vaux6Regu
2846 */
2847 REG_INIT(AB8540_VAUX6REGU, 0x04, 0x35, 0x03),
2848 /*
2849 * 0x3f, Vaux6Sel
2850 */
2851 REG_INIT(AB8540_VAUX6SEL, 0x04, 0x36, 0x3f),
2852 /*
2853 * 0x03, VCLKBRequestCtrl
2854 */
2855 REG_INIT(AB8540_VCLKBREQCTRL, 0x04, 0x37, 0x03),
2856 /*
2857 * 0x03, VCLKBRegu
2858 */
2859 REG_INIT(AB8540_VCLKBREGU, 0x04, 0x38, 0x03),
2860 /*
2861 * 0x07, VCLKBSel
2862 */
2863 REG_INIT(AB8540_VCLKBSEL, 0x04, 0x39, 0x07),
2864 /*
2865 * 0x03, Vrf1RequestCtrl
2866 */
2867 REG_INIT(AB8540_VRF1REQCTRL, 0x04, 0x3a, 0x03),
2868 /*
2869 * 0x01, VpllDisch
2870 * 0x02, Vrf1Disch
2871 * 0x04, Vaux1Disch
2872 * 0x08, Vaux2Disch
2873 * 0x10, Vaux3Disch
2874 * 0x20, Vintcore12Disch
2875 * 0x40, VTVoutDisch
2876 * 0x80, VaudioDisch
2877 */
2878 REG_INIT(AB8540_REGUCTRLDISCH, 0x04, 0x43, 0xff),
2879 /*
2880 * 0x02, VanaDisch
2881 * 0x04, VdmicPullDownEna
2882 * 0x08, VpllPullDownEna
2883 * 0x10, VdmicDisch
2884 */
2885 REG_INIT(AB8540_REGUCTRLDISCH2, 0x04, 0x44, 0x1e),
2886 /*
2887 * 0x01, Vaux4Disch
2888 */
2889 REG_INIT(AB8540_REGUCTRLDISCH3, 0x04, 0x48, 0x01),
2890 /*
2891 * 0x01, Vaux5Disch
2892 * 0x02, Vaux6Disch
2893 * 0x04, VCLKBDisch
2894 */
2895 REG_INIT(AB8540_REGUCTRLDISCH4, 0x04, 0x49, 0x07),
2896};
2897
Lee Jonesda45edc2013-04-02 13:24:20 +01002898static struct of_regulator_match ab8500_regulator_match[] = {
2899 { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB8500_LDO_AUX1, },
2900 { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB8500_LDO_AUX2, },
2901 { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB8500_LDO_AUX3, },
2902 { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB8500_LDO_INTCORE, },
2903 { .name = "ab8500_ldo_tvout", .driver_data = (void *) AB8500_LDO_TVOUT, },
2904 { .name = "ab8500_ldo_audio", .driver_data = (void *) AB8500_LDO_AUDIO, },
2905 { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB8500_LDO_ANAMIC1, },
2906 { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB8500_LDO_ANAMIC2, },
2907 { .name = "ab8500_ldo_dmic", .driver_data = (void *) AB8500_LDO_DMIC, },
2908 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB8500_LDO_ANA, },
2909};
2910
2911static struct of_regulator_match ab8505_regulator_match[] = {
2912 { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB8505_LDO_AUX1, },
2913 { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB8505_LDO_AUX2, },
2914 { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB8505_LDO_AUX3, },
2915 { .name = "ab8500_ldo_aux4", .driver_data = (void *) AB8505_LDO_AUX4, },
2916 { .name = "ab8500_ldo_aux5", .driver_data = (void *) AB8505_LDO_AUX5, },
2917 { .name = "ab8500_ldo_aux6", .driver_data = (void *) AB8505_LDO_AUX6, },
2918 { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB8505_LDO_INTCORE, },
2919 { .name = "ab8500_ldo_adc", .driver_data = (void *) AB8505_LDO_ADC, },
2920 { .name = "ab8500_ldo_audio", .driver_data = (void *) AB8505_LDO_AUDIO, },
2921 { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB8505_LDO_ANAMIC1, },
2922 { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB8505_LDO_ANAMIC2, },
2923 { .name = "ab8500_ldo_aux8", .driver_data = (void *) AB8505_LDO_AUX8, },
2924 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB8505_LDO_ANA, },
2925};
2926
2927static struct of_regulator_match ab8540_regulator_match[] = {
2928 { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB8540_LDO_AUX1, },
2929 { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB8540_LDO_AUX2, },
2930 { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB8540_LDO_AUX3, },
2931 { .name = "ab8500_ldo_aux4", .driver_data = (void *) AB8540_LDO_AUX4, },
2932 { .name = "ab8500_ldo_aux5", .driver_data = (void *) AB8540_LDO_AUX5, },
2933 { .name = "ab8500_ldo_aux6", .driver_data = (void *) AB8540_LDO_AUX6, },
2934 { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB8540_LDO_INTCORE, },
2935 { .name = "ab8500_ldo_tvout", .driver_data = (void *) AB8540_LDO_TVOUT, },
2936 { .name = "ab8500_ldo_audio", .driver_data = (void *) AB8540_LDO_AUDIO, },
2937 { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB8540_LDO_ANAMIC1, },
2938 { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB8540_LDO_ANAMIC2, },
2939 { .name = "ab8500_ldo_dmic", .driver_data = (void *) AB8540_LDO_DMIC, },
2940 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB8540_LDO_ANA, },
2941 { .name = "ab8500_ldo_sdio", .driver_data = (void *) AB8540_LDO_SDIO, },
2942};
2943
2944static struct of_regulator_match ab9540_regulator_match[] = {
2945 { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB9540_LDO_AUX1, },
2946 { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB9540_LDO_AUX2, },
2947 { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB9540_LDO_AUX3, },
2948 { .name = "ab8500_ldo_aux4", .driver_data = (void *) AB9540_LDO_AUX4, },
2949 { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB9540_LDO_INTCORE, },
2950 { .name = "ab8500_ldo_tvout", .driver_data = (void *) AB9540_LDO_TVOUT, },
2951 { .name = "ab8500_ldo_audio", .driver_data = (void *) AB9540_LDO_AUDIO, },
2952 { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB9540_LDO_ANAMIC1, },
2953 { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB9540_LDO_ANAMIC2, },
2954 { .name = "ab8500_ldo_dmic", .driver_data = (void *) AB9540_LDO_DMIC, },
2955 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB9540_LDO_ANA, },
2956};
2957
Lee Jones33aeb492013-04-02 13:24:14 +01002958static struct {
2959 struct ab8500_regulator_info *info;
2960 int info_size;
2961 struct ab8500_reg_init *init;
2962 int init_size;
2963 struct of_regulator_match *match;
2964 int match_size;
2965} abx500_regulator;
2966
Lee Jonesda45edc2013-04-02 13:24:20 +01002967static void abx500_get_regulator_info(struct ab8500 *ab8500)
2968{
2969 if (is_ab9540(ab8500)) {
2970 abx500_regulator.info = ab9540_regulator_info;
2971 abx500_regulator.info_size = ARRAY_SIZE(ab9540_regulator_info);
2972 abx500_regulator.init = ab9540_reg_init;
2973 abx500_regulator.init_size = AB9540_NUM_REGULATOR_REGISTERS;
2974 abx500_regulator.match = ab9540_regulator_match;
2975 abx500_regulator.match_size = ARRAY_SIZE(ab9540_regulator_match);
2976 } else if (is_ab8505(ab8500)) {
2977 abx500_regulator.info = ab8505_regulator_info;
2978 abx500_regulator.info_size = ARRAY_SIZE(ab8505_regulator_info);
2979 abx500_regulator.init = ab8505_reg_init;
2980 abx500_regulator.init_size = AB8505_NUM_REGULATOR_REGISTERS;
2981 abx500_regulator.match = ab8505_regulator_match;
2982 abx500_regulator.match_size = ARRAY_SIZE(ab8505_regulator_match);
2983 } else if (is_ab8540(ab8500)) {
2984 abx500_regulator.info = ab8540_regulator_info;
2985 abx500_regulator.info_size = ARRAY_SIZE(ab8540_regulator_info);
2986 abx500_regulator.init = ab8540_reg_init;
2987 abx500_regulator.init_size = AB8540_NUM_REGULATOR_REGISTERS;
2988 abx500_regulator.match = ab8540_regulator_match;
2989 abx500_regulator.match_size = ARRAY_SIZE(ab8540_regulator_match);
2990 } else {
2991 abx500_regulator.info = ab8500_regulator_info;
2992 abx500_regulator.info_size = ARRAY_SIZE(ab8500_regulator_info);
2993 abx500_regulator.init = ab8500_reg_init;
2994 abx500_regulator.init_size = AB8500_NUM_REGULATOR_REGISTERS;
2995 abx500_regulator.match = ab8500_regulator_match;
2996 abx500_regulator.match_size = ARRAY_SIZE(ab8500_regulator_match);
2997 }
2998}
2999
Lee Jones3c1b8432013-03-21 15:59:01 +00003000static int ab8500_regulator_init_registers(struct platform_device *pdev,
3001 int id, int mask, int value)
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003002{
Lee Jones33aeb492013-04-02 13:24:14 +01003003 struct ab8500_reg_init *reg_init = abx500_regulator.init;
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003004 int err;
3005
Lee Jones3c1b8432013-03-21 15:59:01 +00003006 BUG_ON(value & ~mask);
Lee Jonesb54969a2013-03-28 16:11:10 +00003007 BUG_ON(mask & ~reg_init[id].mask);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003008
Lee Jones3c1b8432013-03-21 15:59:01 +00003009 /* initialize register */
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003010 err = abx500_mask_and_set_register_interruptible(
3011 &pdev->dev,
Lee Jonesb54969a2013-03-28 16:11:10 +00003012 reg_init[id].bank,
3013 reg_init[id].addr,
Lee Jones3c1b8432013-03-21 15:59:01 +00003014 mask, value);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003015 if (err < 0) {
3016 dev_err(&pdev->dev,
3017 "Failed to initialize 0x%02x, 0x%02x.\n",
Lee Jonesb54969a2013-03-28 16:11:10 +00003018 reg_init[id].bank,
3019 reg_init[id].addr);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003020 return err;
3021 }
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003022 dev_vdbg(&pdev->dev,
Lee Jones3c1b8432013-03-21 15:59:01 +00003023 " init: 0x%02x, 0x%02x, 0x%02x, 0x%02x\n",
Lee Jonesb54969a2013-03-28 16:11:10 +00003024 reg_init[id].bank,
3025 reg_init[id].addr,
Lee Jones3c1b8432013-03-21 15:59:01 +00003026 mask, value);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003027
3028 return 0;
3029}
3030
Bill Pembertona5023572012-11-19 13:22:22 -05003031static int ab8500_regulator_register(struct platform_device *pdev,
Lee Jonesb54969a2013-03-28 16:11:10 +00003032 struct regulator_init_data *init_data,
Lee Jonesb54969a2013-03-28 16:11:10 +00003033 int id, struct device_node *np)
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003034{
Lee Jones8e6a8d72013-03-28 16:11:11 +00003035 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003036 struct ab8500_regulator_info *info = NULL;
3037 struct regulator_config config = { };
3038 int err;
3039
3040 /* assign per-regulator data */
Lee Jones33aeb492013-04-02 13:24:14 +01003041 info = &abx500_regulator.info[id];
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003042 info->dev = &pdev->dev;
3043
3044 config.dev = &pdev->dev;
3045 config.init_data = init_data;
3046 config.driver_data = info;
3047 config.of_node = np;
3048
3049 /* fix for hardware before ab8500v2.0 */
Lee Jones8e6a8d72013-03-28 16:11:11 +00003050 if (is_ab8500_1p1_or_earlier(ab8500)) {
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003051 if (info->desc.id == AB8500_LDO_AUX3) {
3052 info->desc.n_voltages =
3053 ARRAY_SIZE(ldo_vauxn_voltages);
Axel Linec1cc4d2012-05-20 10:33:35 +08003054 info->desc.volt_table = ldo_vauxn_voltages;
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003055 info->voltage_mask = 0xf;
3056 }
3057 }
3058
3059 /* register regulator with framework */
3060 info->regulator = regulator_register(&info->desc, &config);
3061 if (IS_ERR(info->regulator)) {
3062 err = PTR_ERR(info->regulator);
3063 dev_err(&pdev->dev, "failed to register regulator %s\n",
3064 info->desc.name);
3065 /* when we fail, un-register all earlier regulators */
3066 while (--id >= 0) {
Lee Jones33aeb492013-04-02 13:24:14 +01003067 info = &abx500_regulator.info[id];
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003068 regulator_unregister(info->regulator);
3069 }
3070 return err;
3071 }
3072
3073 return 0;
3074}
3075
Bill Pembertona5023572012-11-19 13:22:22 -05003076static int
Lee Jonesb54969a2013-03-28 16:11:10 +00003077ab8500_regulator_of_probe(struct platform_device *pdev,
Lee Jonesb54969a2013-03-28 16:11:10 +00003078 struct device_node *np)
Lee Jones3a8334b2012-05-17 14:45:16 +01003079{
Lee Jones33aeb492013-04-02 13:24:14 +01003080 struct of_regulator_match *match = abx500_regulator.match;
Lee Jones3a8334b2012-05-17 14:45:16 +01003081 int err, i;
3082
Lee Jones33aeb492013-04-02 13:24:14 +01003083 for (i = 0; i < abx500_regulator.info_size; i++) {
Lee Jones3a8334b2012-05-17 14:45:16 +01003084 err = ab8500_regulator_register(
Lee Jones33aeb492013-04-02 13:24:14 +01003085 pdev, match[i].init_data, i, match[i].of_node);
Lee Jones3a8334b2012-05-17 14:45:16 +01003086 if (err)
3087 return err;
3088 }
3089
3090 return 0;
3091}
3092
Bill Pembertona5023572012-11-19 13:22:22 -05003093static int ab8500_regulator_probe(struct platform_device *pdev)
Sundar R IYERc789ca22010-07-13 21:48:56 +05303094{
3095 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
Lee Jones3a8334b2012-05-17 14:45:16 +01003096 struct device_node *np = pdev->dev.of_node;
Bengt Jonsson732805a2013-03-21 15:59:03 +00003097 struct ab8500_platform_data *ppdata;
3098 struct ab8500_regulator_platform_data *pdata;
Sundar R IYERc789ca22010-07-13 21:48:56 +05303099 int i, err;
Lee Jonesb54969a2013-03-28 16:11:10 +00003100
Lee Jones33aeb492013-04-02 13:24:14 +01003101 if (!ab8500) {
3102 dev_err(&pdev->dev, "null mfd parent\n");
3103 return -EINVAL;
Lee Jones8e6a8d72013-03-28 16:11:11 +00003104 }
Sundar R IYERc789ca22010-07-13 21:48:56 +05303105
Lee Jones33aeb492013-04-02 13:24:14 +01003106 abx500_get_regulator_info(ab8500);
3107
Lee Jones3a8334b2012-05-17 14:45:16 +01003108 if (np) {
Lee Jones33aeb492013-04-02 13:24:14 +01003109 err = of_regulator_match(&pdev->dev, np,
3110 abx500_regulator.match,
3111 abx500_regulator.match_size);
Lee Jones3a8334b2012-05-17 14:45:16 +01003112 if (err < 0) {
3113 dev_err(&pdev->dev,
3114 "Error parsing regulator init data: %d\n", err);
3115 return err;
3116 }
3117
Lee Jones33aeb492013-04-02 13:24:14 +01003118 err = ab8500_regulator_of_probe(pdev, np);
Lee Jones3a8334b2012-05-17 14:45:16 +01003119 return err;
3120 }
3121
Bengt Jonsson732805a2013-03-21 15:59:03 +00003122 ppdata = dev_get_platdata(ab8500->dev);
3123 if (!ppdata) {
3124 dev_err(&pdev->dev, "null parent pdata\n");
3125 return -EINVAL;
3126 }
3127
3128 pdata = ppdata->regulator;
Bengt Jonssonfc24b422010-12-10 11:08:45 +01003129 if (!pdata) {
3130 dev_err(&pdev->dev, "null pdata\n");
3131 return -EINVAL;
3132 }
Sundar R IYERc789ca22010-07-13 21:48:56 +05303133
Bengt Jonssoncb189b02010-12-10 11:08:40 +01003134 /* make sure the platform data has the correct size */
Lee Jones33aeb492013-04-02 13:24:14 +01003135 if (pdata->num_regulator != abx500_regulator.info_size) {
Bengt Jonsson79568b942011-03-11 11:54:46 +01003136 dev_err(&pdev->dev, "Configuration error: size mismatch.\n");
Bengt Jonssoncb189b02010-12-10 11:08:40 +01003137 return -EINVAL;
3138 }
3139
Lee Jonesda0b0c42013-03-28 16:11:09 +00003140 /* initialize debug (initial state is recorded with this call) */
3141 err = ab8500_regulator_debug_init(pdev);
3142 if (err)
3143 return err;
3144
Bengt Jonsson79568b942011-03-11 11:54:46 +01003145 /* initialize registers */
Bengt Jonsson732805a2013-03-21 15:59:03 +00003146 for (i = 0; i < pdata->num_reg_init; i++) {
Lee Jones3c1b8432013-03-21 15:59:01 +00003147 int id, mask, value;
Bengt Jonsson79568b942011-03-11 11:54:46 +01003148
Bengt Jonsson732805a2013-03-21 15:59:03 +00003149 id = pdata->reg_init[i].id;
3150 mask = pdata->reg_init[i].mask;
3151 value = pdata->reg_init[i].value;
Bengt Jonsson79568b942011-03-11 11:54:46 +01003152
3153 /* check for configuration errors */
Lee Jones33aeb492013-04-02 13:24:14 +01003154 BUG_ON(id >= abx500_regulator.init_size);
Bengt Jonsson79568b942011-03-11 11:54:46 +01003155
Lee Jones33aeb492013-04-02 13:24:14 +01003156 err = ab8500_regulator_init_registers(pdev, id, mask, value);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003157 if (err < 0)
Bengt Jonsson79568b942011-03-11 11:54:46 +01003158 return err;
Bengt Jonsson79568b942011-03-11 11:54:46 +01003159 }
3160
Rabin Vincentf7eae372013-04-02 13:24:08 +01003161 if (!is_ab8505(ab8500)) {
3162 /* register external regulators (before Vaux1, 2 and 3) */
3163 err = ab8500_ext_regulator_init(pdev);
3164 if (err)
3165 return err;
3166 }
Lee Jonesd1a82002013-03-28 16:11:01 +00003167
Sundar R IYERc789ca22010-07-13 21:48:56 +05303168 /* register all regulators */
Lee Jones33aeb492013-04-02 13:24:14 +01003169 for (i = 0; i < abx500_regulator.info_size; i++) {
Lee Jonesb54969a2013-03-28 16:11:10 +00003170 err = ab8500_regulator_register(pdev, &pdata->regulator[i],
Lee Jones33aeb492013-04-02 13:24:14 +01003171 i, NULL);
Axel Lin42e8c812013-04-11 12:05:43 +08003172 if (err < 0) {
3173 if (!is_ab8505(ab8500))
3174 ab8500_ext_regulator_exit(pdev);
Sundar R IYERc789ca22010-07-13 21:48:56 +05303175 return err;
Axel Lin42e8c812013-04-11 12:05:43 +08003176 }
Sundar R IYERc789ca22010-07-13 21:48:56 +05303177 }
3178
3179 return 0;
3180}
3181
Bill Pemberton8dc995f2012-11-19 13:26:10 -05003182static int ab8500_regulator_remove(struct platform_device *pdev)
Sundar R IYERc789ca22010-07-13 21:48:56 +05303183{
Lee Jonesd1a82002013-03-28 16:11:01 +00003184 int i, err;
Lee Jones8e6a8d72013-03-28 16:11:11 +00003185 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
Sundar R IYERc789ca22010-07-13 21:48:56 +05303186
Lee Jones33aeb492013-04-02 13:24:14 +01003187 for (i = 0; i < abx500_regulator.info_size; i++) {
Sundar R IYERc789ca22010-07-13 21:48:56 +05303188 struct ab8500_regulator_info *info = NULL;
Lee Jones33aeb492013-04-02 13:24:14 +01003189 info = &abx500_regulator.info[i];
Bengt Jonsson09aefa12010-12-10 11:08:46 +01003190
3191 dev_vdbg(rdev_get_dev(info->regulator),
3192 "%s-remove\n", info->desc.name);
3193
Sundar R IYERc789ca22010-07-13 21:48:56 +05303194 regulator_unregister(info->regulator);
3195 }
3196
Axel Lin3480c0c2013-04-11 12:04:18 +08003197 /* remove external regulators (after Vaux1, 2 and 3) */
3198 if (!is_ab8505(ab8500))
3199 ab8500_ext_regulator_exit(pdev);
Lee Jonesd1a82002013-03-28 16:11:01 +00003200
Lee Jonesda0b0c42013-03-28 16:11:09 +00003201 /* remove regulator debug */
3202 err = ab8500_regulator_debug_exit(pdev);
3203 if (err)
3204 return err;
3205
Sundar R IYERc789ca22010-07-13 21:48:56 +05303206 return 0;
3207}
3208
3209static struct platform_driver ab8500_regulator_driver = {
3210 .probe = ab8500_regulator_probe,
Bill Pemberton5eb9f2b2012-11-19 13:20:42 -05003211 .remove = ab8500_regulator_remove,
Sundar R IYERc789ca22010-07-13 21:48:56 +05303212 .driver = {
3213 .name = "ab8500-regulator",
3214 .owner = THIS_MODULE,
Sundar R IYERc789ca22010-07-13 21:48:56 +05303215 },
3216};
3217
3218static int __init ab8500_regulator_init(void)
3219{
3220 int ret;
3221
3222 ret = platform_driver_register(&ab8500_regulator_driver);
3223 if (ret != 0)
3224 pr_err("Failed to register ab8500 regulator: %d\n", ret);
3225
3226 return ret;
3227}
3228subsys_initcall(ab8500_regulator_init);
3229
3230static void __exit ab8500_regulator_exit(void)
3231{
3232 platform_driver_unregister(&ab8500_regulator_driver);
3233}
3234module_exit(ab8500_regulator_exit);
3235
3236MODULE_LICENSE("GPL v2");
3237MODULE_AUTHOR("Sundar Iyer <sundar.iyer@stericsson.com>");
Bengt Jonsson732805a2013-03-21 15:59:03 +00003238MODULE_AUTHOR("Bengt Jonsson <bengt.g.jonsson@stericsson.com>");
Lee Jones547f3842013-03-28 16:11:14 +00003239MODULE_AUTHOR("Daniel Willerud <daniel.willerud@stericsson.com>");
Sundar R IYERc789ca22010-07-13 21:48:56 +05303240MODULE_DESCRIPTION("Regulator Driver for ST-Ericsson AB8500 Mixed-Sig PMIC");
3241MODULE_ALIAS("platform:ab8500-regulator");