blob: 29a727ca399bc16150481e869cb509a7827c4a72 [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:
395 if (info->shared_mode)
396 mutex_unlock(&shared_mode_mutex);
397 return -EINVAL;
398 }
399
400 bank = info->mode_bank;
401 reg = info->mode_reg;
402 mask = info->mode_mask;
403 } else {
404 /* Mode register same as enable register */
405
406 switch (mode) {
407 case REGULATOR_MODE_NORMAL:
408 info->update_val = info->update_val_normal;
409 val = info->update_val_normal;
410 break;
411 case REGULATOR_MODE_IDLE:
412 info->update_val = info->update_val_idle;
413 val = info->update_val_idle;
414 break;
415 default:
416 if (info->shared_mode)
417 mutex_unlock(&shared_mode_mutex);
418 return -EINVAL;
419 }
420
421 bank = info->update_bank;
422 reg = info->update_reg;
423 mask = info->update_mask;
424 }
425
Axel Lin438e6952013-04-07 23:12:28 +0800426 if (dmr || ab8500_regulator_is_enabled(rdev)) {
Emeric Vigierbd28a152013-03-21 15:58:59 +0000427 ret = abx500_mask_and_set_register_interruptible(info->dev,
Lee Jones3fe52282013-04-02 13:24:12 +0100428 bank, reg, mask, val);
429 if (ret < 0)
Emeric Vigierbd28a152013-03-21 15:58:59 +0000430 dev_err(rdev_get_dev(rdev),
431 "couldn't set regulator mode\n");
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000432
433 dev_vdbg(rdev_get_dev(rdev),
434 "%s-set_mode (bank, reg, mask, value): "
435 "0x%x, 0x%x, 0x%x, 0x%x\n",
Lee Jones3fe52282013-04-02 13:24:12 +0100436 info->desc.name, bank, reg,
437 mask, val);
Emeric Vigierbd28a152013-03-21 15:58:59 +0000438 }
439
Lee Jones3fe52282013-04-02 13:24:12 +0100440 if (info->shared_mode)
441 mutex_unlock(&shared_mode_mutex);
Axel Lin742a7322013-03-28 17:23:00 +0800442
Lee Jones3fe52282013-04-02 13:24:12 +0100443 return ret;
Emeric Vigierbd28a152013-03-21 15:58:59 +0000444}
445
446static unsigned int ab8500_regulator_get_mode(struct regulator_dev *rdev)
447{
448 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
449 int ret;
Lee Jones3fe52282013-04-02 13:24:12 +0100450 u8 val;
451 u8 val_normal;
452 u8 val_idle;
Emeric Vigierbd28a152013-03-21 15:58:59 +0000453
454 if (info == NULL) {
455 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
456 return -EINVAL;
457 }
458
Lee Jones3fe52282013-04-02 13:24:12 +0100459 /* Need special handling for shared mode */
460 if (info->shared_mode) {
461 if (info->shared_mode->lp_mode_req)
462 return REGULATOR_MODE_IDLE;
463 else
464 return REGULATOR_MODE_NORMAL;
465 }
466
467 if (info->mode_mask) {
468 /* Dedicated register for handling mode */
469 ret = abx500_get_register_interruptible(info->dev,
470 info->mode_bank, info->mode_reg, &val);
471 val = val & info->mode_mask;
472
473 val_normal = info->mode_val_normal;
474 val_idle = info->mode_val_idle;
475 } else {
476 /* Mode register same as enable register */
477 val = info->update_val;
478 val_normal = info->update_val_normal;
479 val_idle = info->update_val_idle;
480 }
481
482 if (val == val_normal)
Emeric Vigierbd28a152013-03-21 15:58:59 +0000483 ret = REGULATOR_MODE_NORMAL;
Lee Jones3fe52282013-04-02 13:24:12 +0100484 else if (val == val_idle)
Emeric Vigierbd28a152013-03-21 15:58:59 +0000485 ret = REGULATOR_MODE_IDLE;
486 else
487 ret = -EINVAL;
488
489 return ret;
490}
491
Axel Lin3bf6e902012-02-24 17:15:45 +0800492static int ab8500_regulator_get_voltage_sel(struct regulator_dev *rdev)
Sundar R IYERc789ca22010-07-13 21:48:56 +0530493{
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100494 int ret, val;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530495 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100496 u8 regval;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530497
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100498 if (info == NULL) {
499 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
Sundar R IYERc789ca22010-07-13 21:48:56 +0530500 return -EINVAL;
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100501 }
Sundar R IYERc789ca22010-07-13 21:48:56 +0530502
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100503 ret = abx500_get_register_interruptible(info->dev,
504 info->voltage_bank, info->voltage_reg, &regval);
Sundar R IYERc789ca22010-07-13 21:48:56 +0530505 if (ret < 0) {
506 dev_err(rdev_get_dev(rdev),
507 "couldn't read voltage reg for regulator\n");
508 return ret;
509 }
510
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100511 dev_vdbg(rdev_get_dev(rdev),
Linus Walleija0a70142012-08-20 18:41:35 +0200512 "%s-get_voltage (bank, reg, mask, shift, value): "
513 "0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n",
514 info->desc.name, info->voltage_bank,
515 info->voltage_reg, info->voltage_mask,
516 info->voltage_shift, regval);
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100517
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100518 val = regval & info->voltage_mask;
Linus Walleija0a70142012-08-20 18:41:35 +0200519 return val >> info->voltage_shift;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530520}
521
Lee Jonesd7607ba2013-04-02 13:24:11 +0100522static int ab8540_aux3_regulator_get_voltage_sel(struct regulator_dev *rdev)
523{
Axel Lin241896c2013-04-10 14:46:20 +0800524 int ret;
Lee Jonesd7607ba2013-04-02 13:24:11 +0100525 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
526 u8 regval, regval_expand;
527
528 if (info == NULL) {
529 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
530 return -EINVAL;
531 }
532
533 ret = abx500_get_register_interruptible(info->dev,
Lee Jonesd7607ba2013-04-02 13:24:11 +0100534 info->expand_register.voltage_bank,
535 info->expand_register.voltage_reg, &regval_expand);
Axel Lin241896c2013-04-10 14:46:20 +0800536 if (ret < 0) {
537 dev_err(rdev_get_dev(rdev),
538 "couldn't read voltage expand reg for regulator\n");
539 return ret;
540 }
Lee Jonesd7607ba2013-04-02 13:24:11 +0100541
Axel Lin241896c2013-04-10 14:46:20 +0800542 dev_vdbg(rdev_get_dev(rdev),
543 "%s-get_voltage expand (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
544 info->desc.name, info->expand_register.voltage_bank,
545 info->expand_register.voltage_reg,
546 info->expand_register.voltage_mask, regval_expand);
547
548 if (regval_expand & info->expand_register.voltage_mask)
549 return info->expand_register.voltage_limit;
550
551 ret = abx500_get_register_interruptible(info->dev,
552 info->voltage_bank, info->voltage_reg, &regval);
Lee Jonesd7607ba2013-04-02 13:24:11 +0100553 if (ret < 0) {
554 dev_err(rdev_get_dev(rdev),
555 "couldn't read voltage reg for regulator\n");
556 return ret;
557 }
558
559 dev_vdbg(rdev_get_dev(rdev),
Axel Lin241896c2013-04-10 14:46:20 +0800560 "%s-get_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
561 info->desc.name, info->voltage_bank, info->voltage_reg,
562 info->voltage_mask, regval);
Lee Jonesd7607ba2013-04-02 13:24:11 +0100563
Axel Lin241896c2013-04-10 14:46:20 +0800564 return (regval & info->voltage_mask) >> info->voltage_shift;
Lee Jonesd7607ba2013-04-02 13:24:11 +0100565}
566
Axel Linae713d32012-03-20 09:51:08 +0800567static int ab8500_regulator_set_voltage_sel(struct regulator_dev *rdev,
568 unsigned selector)
Sundar R IYERc789ca22010-07-13 21:48:56 +0530569{
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100570 int ret;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530571 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100572 u8 regval;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530573
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100574 if (info == NULL) {
575 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
Sundar R IYERc789ca22010-07-13 21:48:56 +0530576 return -EINVAL;
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100577 }
Sundar R IYERc789ca22010-07-13 21:48:56 +0530578
Sundar R IYERc789ca22010-07-13 21:48:56 +0530579 /* set the registers for the request */
Linus Walleija0a70142012-08-20 18:41:35 +0200580 regval = (u8)selector << info->voltage_shift;
Mattias Wallin47c16972010-09-10 17:47:56 +0200581 ret = abx500_mask_and_set_register_interruptible(info->dev,
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100582 info->voltage_bank, info->voltage_reg,
583 info->voltage_mask, regval);
Sundar R IYERc789ca22010-07-13 21:48:56 +0530584 if (ret < 0)
585 dev_err(rdev_get_dev(rdev),
586 "couldn't set voltage reg for regulator\n");
587
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100588 dev_vdbg(rdev_get_dev(rdev),
589 "%s-set_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
590 " 0x%x\n",
591 info->desc.name, info->voltage_bank, info->voltage_reg,
592 info->voltage_mask, regval);
593
Sundar R IYERc789ca22010-07-13 21:48:56 +0530594 return ret;
595}
596
Lee Jonesd7607ba2013-04-02 13:24:11 +0100597static int ab8540_aux3_regulator_set_voltage_sel(struct regulator_dev *rdev,
598 unsigned selector)
599{
600 int ret;
601 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
602 u8 regval;
603
604 if (info == NULL) {
605 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
606 return -EINVAL;
607 }
608
609 if (selector >= info->expand_register.voltage_limit) {
610 /* Vaux3 bit4 has different layout */
611 regval = (u8)selector << info->expand_register.voltage_shift;
612 ret = abx500_mask_and_set_register_interruptible(info->dev,
613 info->expand_register.voltage_bank,
614 info->expand_register.voltage_reg,
615 info->expand_register.voltage_mask,
616 regval);
617 } else {
618 /* set the registers for the request */
619 regval = (u8)selector << info->voltage_shift;
620 ret = abx500_mask_and_set_register_interruptible(info->dev,
621 info->voltage_bank, info->voltage_reg,
622 info->voltage_mask, regval);
623 }
624 if (ret < 0)
625 dev_err(rdev_get_dev(rdev),
626 "couldn't set voltage reg for regulator\n");
627
628 dev_vdbg(rdev_get_dev(rdev),
629 "%s-set_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
630 " 0x%x\n",
631 info->desc.name, info->voltage_bank, info->voltage_reg,
632 info->voltage_mask, regval);
633
634 return ret;
635}
636
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000637static struct regulator_ops ab8500_regulator_volt_mode_ops = {
638 .enable = ab8500_regulator_enable,
639 .disable = ab8500_regulator_disable,
640 .is_enabled = ab8500_regulator_is_enabled,
641 .get_optimum_mode = ab8500_regulator_get_optimum_mode,
642 .set_mode = ab8500_regulator_set_mode,
643 .get_mode = ab8500_regulator_get_mode,
644 .get_voltage_sel = ab8500_regulator_get_voltage_sel,
645 .set_voltage_sel = ab8500_regulator_set_voltage_sel,
646 .list_voltage = regulator_list_voltage_table,
Sundar R IYERc789ca22010-07-13 21:48:56 +0530647};
648
Lee Jonesd7607ba2013-04-02 13:24:11 +0100649static struct regulator_ops ab8540_aux3_regulator_volt_mode_ops = {
650 .enable = ab8500_regulator_enable,
651 .disable = ab8500_regulator_disable,
652 .get_optimum_mode = ab8500_regulator_get_optimum_mode,
653 .set_mode = ab8500_regulator_set_mode,
654 .get_mode = ab8500_regulator_get_mode,
655 .is_enabled = ab8500_regulator_is_enabled,
656 .get_voltage_sel = ab8540_aux3_regulator_get_voltage_sel,
657 .set_voltage_sel = ab8540_aux3_regulator_set_voltage_sel,
658 .list_voltage = regulator_list_voltage_table,
Lee Jonesd7607ba2013-04-02 13:24:11 +0100659};
660
Lee Jones8a3b1b82013-04-02 13:24:09 +0100661static struct regulator_ops ab8500_regulator_volt_ops = {
662 .enable = ab8500_regulator_enable,
663 .disable = ab8500_regulator_disable,
664 .is_enabled = ab8500_regulator_is_enabled,
665 .get_voltage_sel = ab8500_regulator_get_voltage_sel,
666 .set_voltage_sel = ab8500_regulator_set_voltage_sel,
667 .list_voltage = regulator_list_voltage_table,
Lee Jones8a3b1b82013-04-02 13:24:09 +0100668};
669
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000670static struct regulator_ops ab8500_regulator_mode_ops = {
671 .enable = ab8500_regulator_enable,
672 .disable = ab8500_regulator_disable,
673 .is_enabled = ab8500_regulator_is_enabled,
674 .get_optimum_mode = ab8500_regulator_get_optimum_mode,
675 .set_mode = ab8500_regulator_set_mode,
676 .get_mode = ab8500_regulator_get_mode,
Axel Lind7816ab2013-04-02 13:24:22 +0100677 .list_voltage = regulator_list_voltage_table,
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000678};
679
680static struct regulator_ops ab8500_regulator_ops = {
681 .enable = ab8500_regulator_enable,
682 .disable = ab8500_regulator_disable,
683 .is_enabled = ab8500_regulator_is_enabled,
Axel Lind7816ab2013-04-02 13:24:22 +0100684 .list_voltage = regulator_list_voltage_table,
Sundar R IYERc789ca22010-07-13 21:48:56 +0530685};
686
Lee Jones3fe52282013-04-02 13:24:12 +0100687static struct regulator_ops ab8500_regulator_anamic_mode_ops = {
688 .enable = ab8500_regulator_enable,
689 .disable = ab8500_regulator_disable,
690 .is_enabled = ab8500_regulator_is_enabled,
691 .set_mode = ab8500_regulator_set_mode,
692 .get_mode = ab8500_regulator_get_mode,
693 .list_voltage = regulator_list_voltage_table,
694};
695
Lee Jones8e6a8d72013-03-28 16:11:11 +0000696/* AB8500 regulator information */
Bengt Jonsson6909b452010-12-10 11:08:47 +0100697static struct ab8500_regulator_info
698 ab8500_regulator_info[AB8500_NUM_REGULATORS] = {
Sundar R IYERc789ca22010-07-13 21:48:56 +0530699 /*
Bengt Jonssone1159e62010-12-10 11:08:44 +0100700 * Variable Voltage Regulators
701 * name, min mV, max mV,
702 * update bank, reg, mask, enable val
Axel Linec1cc4d2012-05-20 10:33:35 +0800703 * volt bank, reg, mask
Sundar R IYERc789ca22010-07-13 21:48:56 +0530704 */
Bengt Jonsson6909b452010-12-10 11:08:47 +0100705 [AB8500_LDO_AUX1] = {
706 .desc = {
707 .name = "LDO-AUX1",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000708 .ops = &ab8500_regulator_volt_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100709 .type = REGULATOR_VOLTAGE,
710 .id = AB8500_LDO_AUX1,
711 .owner = THIS_MODULE,
712 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Axel Linec1cc4d2012-05-20 10:33:35 +0800713 .volt_table = ldo_vauxn_voltages,
Axel Lin530158b2013-03-27 17:47:22 +0800714 .enable_time = 200,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100715 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000716 .load_lp_uA = 5000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100717 .update_bank = 0x04,
718 .update_reg = 0x09,
719 .update_mask = 0x03,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000720 .update_val = 0x01,
721 .update_val_idle = 0x03,
722 .update_val_normal = 0x01,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100723 .voltage_bank = 0x04,
724 .voltage_reg = 0x1f,
725 .voltage_mask = 0x0f,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100726 },
727 [AB8500_LDO_AUX2] = {
728 .desc = {
729 .name = "LDO-AUX2",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000730 .ops = &ab8500_regulator_volt_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100731 .type = REGULATOR_VOLTAGE,
732 .id = AB8500_LDO_AUX2,
733 .owner = THIS_MODULE,
734 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Axel Linec1cc4d2012-05-20 10:33:35 +0800735 .volt_table = ldo_vauxn_voltages,
Axel Lin530158b2013-03-27 17:47:22 +0800736 .enable_time = 200,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100737 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000738 .load_lp_uA = 5000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100739 .update_bank = 0x04,
740 .update_reg = 0x09,
741 .update_mask = 0x0c,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000742 .update_val = 0x04,
743 .update_val_idle = 0x0c,
744 .update_val_normal = 0x04,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100745 .voltage_bank = 0x04,
746 .voltage_reg = 0x20,
747 .voltage_mask = 0x0f,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100748 },
749 [AB8500_LDO_AUX3] = {
750 .desc = {
751 .name = "LDO-AUX3",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000752 .ops = &ab8500_regulator_volt_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100753 .type = REGULATOR_VOLTAGE,
754 .id = AB8500_LDO_AUX3,
755 .owner = THIS_MODULE,
756 .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages),
Axel Linec1cc4d2012-05-20 10:33:35 +0800757 .volt_table = ldo_vaux3_voltages,
Axel Lin530158b2013-03-27 17:47:22 +0800758 .enable_time = 450,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100759 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000760 .load_lp_uA = 5000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100761 .update_bank = 0x04,
762 .update_reg = 0x0a,
763 .update_mask = 0x03,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000764 .update_val = 0x01,
765 .update_val_idle = 0x03,
766 .update_val_normal = 0x01,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100767 .voltage_bank = 0x04,
768 .voltage_reg = 0x21,
769 .voltage_mask = 0x07,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100770 },
771 [AB8500_LDO_INTCORE] = {
772 .desc = {
773 .name = "LDO-INTCORE",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000774 .ops = &ab8500_regulator_volt_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100775 .type = REGULATOR_VOLTAGE,
776 .id = AB8500_LDO_INTCORE,
777 .owner = THIS_MODULE,
778 .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
Axel Linec1cc4d2012-05-20 10:33:35 +0800779 .volt_table = ldo_vintcore_voltages,
Axel Lin530158b2013-03-27 17:47:22 +0800780 .enable_time = 750,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100781 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000782 .load_lp_uA = 5000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100783 .update_bank = 0x03,
784 .update_reg = 0x80,
785 .update_mask = 0x44,
Lee Jonescc40dc22013-03-21 15:59:41 +0000786 .update_val = 0x44,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000787 .update_val_idle = 0x44,
788 .update_val_normal = 0x04,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100789 .voltage_bank = 0x03,
790 .voltage_reg = 0x80,
791 .voltage_mask = 0x38,
Linus Walleija0a70142012-08-20 18:41:35 +0200792 .voltage_shift = 3,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100793 },
Sundar R IYERc789ca22010-07-13 21:48:56 +0530794
795 /*
Bengt Jonssone1159e62010-12-10 11:08:44 +0100796 * Fixed Voltage Regulators
797 * name, fixed mV,
798 * update bank, reg, mask, enable val
Sundar R IYERc789ca22010-07-13 21:48:56 +0530799 */
Bengt Jonsson6909b452010-12-10 11:08:47 +0100800 [AB8500_LDO_TVOUT] = {
801 .desc = {
802 .name = "LDO-TVOUT",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000803 .ops = &ab8500_regulator_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100804 .type = REGULATOR_VOLTAGE,
805 .id = AB8500_LDO_TVOUT,
806 .owner = THIS_MODULE,
807 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +0000808 .volt_table = fixed_2000000_voltage,
Lee Jonesed3c1382013-03-28 16:11:12 +0000809 .enable_time = 500,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100810 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000811 .load_lp_uA = 1000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100812 .update_bank = 0x03,
813 .update_reg = 0x80,
814 .update_mask = 0x82,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000815 .update_val = 0x02,
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000816 .update_val_idle = 0x82,
817 .update_val_normal = 0x02,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100818 },
819 [AB8500_LDO_AUDIO] = {
820 .desc = {
821 .name = "LDO-AUDIO",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000822 .ops = &ab8500_regulator_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100823 .type = REGULATOR_VOLTAGE,
824 .id = AB8500_LDO_AUDIO,
825 .owner = THIS_MODULE,
826 .n_voltages = 1,
Axel Lin530158b2013-03-27 17:47:22 +0800827 .enable_time = 140,
Lee Jonesb080c782013-03-28 16:11:17 +0000828 .volt_table = fixed_2000000_voltage,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100829 },
Bengt Jonsson6909b452010-12-10 11:08:47 +0100830 .update_bank = 0x03,
831 .update_reg = 0x83,
832 .update_mask = 0x02,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000833 .update_val = 0x02,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100834 },
835 [AB8500_LDO_ANAMIC1] = {
836 .desc = {
837 .name = "LDO-ANAMIC1",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000838 .ops = &ab8500_regulator_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100839 .type = REGULATOR_VOLTAGE,
840 .id = AB8500_LDO_ANAMIC1,
841 .owner = THIS_MODULE,
842 .n_voltages = 1,
Axel Lin530158b2013-03-27 17:47:22 +0800843 .enable_time = 500,
Lee Jonesb080c782013-03-28 16:11:17 +0000844 .volt_table = fixed_2050000_voltage,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100845 },
Bengt Jonsson6909b452010-12-10 11:08:47 +0100846 .update_bank = 0x03,
847 .update_reg = 0x83,
848 .update_mask = 0x08,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000849 .update_val = 0x08,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100850 },
851 [AB8500_LDO_ANAMIC2] = {
852 .desc = {
853 .name = "LDO-ANAMIC2",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000854 .ops = &ab8500_regulator_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100855 .type = REGULATOR_VOLTAGE,
856 .id = AB8500_LDO_ANAMIC2,
857 .owner = THIS_MODULE,
858 .n_voltages = 1,
Axel Lin530158b2013-03-27 17:47:22 +0800859 .enable_time = 500,
Lee Jonesb080c782013-03-28 16:11:17 +0000860 .volt_table = fixed_2050000_voltage,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100861 },
Bengt Jonsson6909b452010-12-10 11:08:47 +0100862 .update_bank = 0x03,
863 .update_reg = 0x83,
864 .update_mask = 0x10,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000865 .update_val = 0x10,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100866 },
867 [AB8500_LDO_DMIC] = {
868 .desc = {
869 .name = "LDO-DMIC",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000870 .ops = &ab8500_regulator_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100871 .type = REGULATOR_VOLTAGE,
872 .id = AB8500_LDO_DMIC,
873 .owner = THIS_MODULE,
874 .n_voltages = 1,
Axel Lin530158b2013-03-27 17:47:22 +0800875 .enable_time = 420,
Lee Jonesb080c782013-03-28 16:11:17 +0000876 .volt_table = fixed_1800000_voltage,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100877 },
Bengt Jonsson6909b452010-12-10 11:08:47 +0100878 .update_bank = 0x03,
879 .update_reg = 0x83,
880 .update_mask = 0x04,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000881 .update_val = 0x04,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100882 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000883
884 /*
885 * Regulators with fixed voltage and normal/idle modes
886 */
Bengt Jonsson6909b452010-12-10 11:08:47 +0100887 [AB8500_LDO_ANA] = {
888 .desc = {
889 .name = "LDO-ANA",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000890 .ops = &ab8500_regulator_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100891 .type = REGULATOR_VOLTAGE,
892 .id = AB8500_LDO_ANA,
893 .owner = THIS_MODULE,
894 .n_voltages = 1,
Axel Lin530158b2013-03-27 17:47:22 +0800895 .enable_time = 140,
Lee Jonesb080c782013-03-28 16:11:17 +0000896 .volt_table = fixed_1200000_voltage,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100897 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000898 .load_lp_uA = 1000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100899 .update_bank = 0x04,
900 .update_reg = 0x06,
901 .update_mask = 0x0c,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000902 .update_val = 0x04,
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000903 .update_val_idle = 0x0c,
904 .update_val_normal = 0x04,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100905 },
Lee Jones8e6a8d72013-03-28 16:11:11 +0000906};
Bengt Jonsson6909b452010-12-10 11:08:47 +0100907
Lee Jones547f3842013-03-28 16:11:14 +0000908/* AB8505 regulator information */
909static struct ab8500_regulator_info
910 ab8505_regulator_info[AB8505_NUM_REGULATORS] = {
911 /*
912 * Variable Voltage Regulators
913 * name, min mV, max mV,
914 * update bank, reg, mask, enable val
Lee Jonesd3193102013-04-02 13:24:18 +0100915 * volt bank, reg, mask
Lee Jones547f3842013-03-28 16:11:14 +0000916 */
917 [AB8505_LDO_AUX1] = {
918 .desc = {
919 .name = "LDO-AUX1",
920 .ops = &ab8500_regulator_volt_mode_ops,
921 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +0100922 .id = AB8505_LDO_AUX1,
Lee Jones547f3842013-03-28 16:11:14 +0000923 .owner = THIS_MODULE,
924 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +0000925 .volt_table = ldo_vauxn_voltages,
Lee Jones547f3842013-03-28 16:11:14 +0000926 },
Lee Jones547f3842013-03-28 16:11:14 +0000927 .load_lp_uA = 5000,
928 .update_bank = 0x04,
929 .update_reg = 0x09,
930 .update_mask = 0x03,
931 .update_val = 0x01,
932 .update_val_idle = 0x03,
933 .update_val_normal = 0x01,
934 .voltage_bank = 0x04,
935 .voltage_reg = 0x1f,
936 .voltage_mask = 0x0f,
Lee Jones547f3842013-03-28 16:11:14 +0000937 },
938 [AB8505_LDO_AUX2] = {
939 .desc = {
940 .name = "LDO-AUX2",
941 .ops = &ab8500_regulator_volt_mode_ops,
942 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +0100943 .id = AB8505_LDO_AUX2,
Lee Jones547f3842013-03-28 16:11:14 +0000944 .owner = THIS_MODULE,
945 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +0000946 .volt_table = ldo_vauxn_voltages,
Lee Jones547f3842013-03-28 16:11:14 +0000947 },
Lee Jones547f3842013-03-28 16:11:14 +0000948 .load_lp_uA = 5000,
949 .update_bank = 0x04,
950 .update_reg = 0x09,
951 .update_mask = 0x0c,
952 .update_val = 0x04,
953 .update_val_idle = 0x0c,
954 .update_val_normal = 0x04,
955 .voltage_bank = 0x04,
956 .voltage_reg = 0x20,
957 .voltage_mask = 0x0f,
Lee Jones547f3842013-03-28 16:11:14 +0000958 },
959 [AB8505_LDO_AUX3] = {
960 .desc = {
961 .name = "LDO-AUX3",
962 .ops = &ab8500_regulator_volt_mode_ops,
963 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +0100964 .id = AB8505_LDO_AUX3,
Lee Jones547f3842013-03-28 16:11:14 +0000965 .owner = THIS_MODULE,
966 .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +0000967 .volt_table = ldo_vaux3_voltages,
Lee Jones547f3842013-03-28 16:11:14 +0000968 },
Lee Jones547f3842013-03-28 16:11:14 +0000969 .load_lp_uA = 5000,
970 .update_bank = 0x04,
971 .update_reg = 0x0a,
972 .update_mask = 0x03,
973 .update_val = 0x01,
974 .update_val_idle = 0x03,
975 .update_val_normal = 0x01,
976 .voltage_bank = 0x04,
977 .voltage_reg = 0x21,
978 .voltage_mask = 0x07,
Lee Jones547f3842013-03-28 16:11:14 +0000979 },
980 [AB8505_LDO_AUX4] = {
981 .desc = {
982 .name = "LDO-AUX4",
983 .ops = &ab8500_regulator_volt_mode_ops,
984 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +0100985 .id = AB8505_LDO_AUX4,
Lee Jones547f3842013-03-28 16:11:14 +0000986 .owner = THIS_MODULE,
987 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +0000988 .volt_table = ldo_vauxn_voltages,
Lee Jones547f3842013-03-28 16:11:14 +0000989 },
Lee Jones547f3842013-03-28 16:11:14 +0000990 .load_lp_uA = 5000,
991 /* values for Vaux4Regu register */
992 .update_bank = 0x04,
993 .update_reg = 0x2e,
994 .update_mask = 0x03,
995 .update_val = 0x01,
996 .update_val_idle = 0x03,
997 .update_val_normal = 0x01,
998 /* values for Vaux4SEL register */
999 .voltage_bank = 0x04,
1000 .voltage_reg = 0x2f,
1001 .voltage_mask = 0x0f,
Lee Jones547f3842013-03-28 16:11:14 +00001002 },
1003 [AB8505_LDO_AUX5] = {
1004 .desc = {
1005 .name = "LDO-AUX5",
1006 .ops = &ab8500_regulator_volt_mode_ops,
1007 .type = REGULATOR_VOLTAGE,
1008 .id = AB8505_LDO_AUX5,
1009 .owner = THIS_MODULE,
1010 .n_voltages = ARRAY_SIZE(ldo_vaux56_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001011 .volt_table = ldo_vaux56_voltages,
Lee Jones547f3842013-03-28 16:11:14 +00001012 },
Lee Jones547f3842013-03-28 16:11:14 +00001013 .load_lp_uA = 2000,
1014 /* values for CtrlVaux5 register */
1015 .update_bank = 0x01,
1016 .update_reg = 0x55,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001017 .update_mask = 0x18,
1018 .update_val = 0x10,
1019 .update_val_idle = 0x18,
1020 .update_val_normal = 0x10,
Lee Jones547f3842013-03-28 16:11:14 +00001021 .voltage_bank = 0x01,
1022 .voltage_reg = 0x55,
1023 .voltage_mask = 0x07,
Lee Jones547f3842013-03-28 16:11:14 +00001024 },
1025 [AB8505_LDO_AUX6] = {
1026 .desc = {
1027 .name = "LDO-AUX6",
1028 .ops = &ab8500_regulator_volt_mode_ops,
1029 .type = REGULATOR_VOLTAGE,
1030 .id = AB8505_LDO_AUX6,
1031 .owner = THIS_MODULE,
1032 .n_voltages = ARRAY_SIZE(ldo_vaux56_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001033 .volt_table = ldo_vaux56_voltages,
Lee Jones547f3842013-03-28 16:11:14 +00001034 },
Lee Jones547f3842013-03-28 16:11:14 +00001035 .load_lp_uA = 2000,
1036 /* values for CtrlVaux6 register */
1037 .update_bank = 0x01,
1038 .update_reg = 0x56,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001039 .update_mask = 0x18,
1040 .update_val = 0x10,
1041 .update_val_idle = 0x18,
1042 .update_val_normal = 0x10,
Lee Jones547f3842013-03-28 16:11:14 +00001043 .voltage_bank = 0x01,
1044 .voltage_reg = 0x56,
1045 .voltage_mask = 0x07,
Lee Jones547f3842013-03-28 16:11:14 +00001046 },
1047 [AB8505_LDO_INTCORE] = {
1048 .desc = {
1049 .name = "LDO-INTCORE",
1050 .ops = &ab8500_regulator_volt_mode_ops,
1051 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001052 .id = AB8505_LDO_INTCORE,
Lee Jones547f3842013-03-28 16:11:14 +00001053 .owner = THIS_MODULE,
1054 .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001055 .volt_table = ldo_vintcore_voltages,
Lee Jones547f3842013-03-28 16:11:14 +00001056 },
Lee Jones547f3842013-03-28 16:11:14 +00001057 .load_lp_uA = 5000,
1058 .update_bank = 0x03,
1059 .update_reg = 0x80,
1060 .update_mask = 0x44,
1061 .update_val = 0x04,
1062 .update_val_idle = 0x44,
1063 .update_val_normal = 0x04,
1064 .voltage_bank = 0x03,
1065 .voltage_reg = 0x80,
1066 .voltage_mask = 0x38,
Lee Jones547f3842013-03-28 16:11:14 +00001067 .voltage_shift = 3,
1068 },
1069
1070 /*
1071 * Fixed Voltage Regulators
1072 * name, fixed mV,
1073 * update bank, reg, mask, enable val
1074 */
1075 [AB8505_LDO_ADC] = {
1076 .desc = {
1077 .name = "LDO-ADC",
1078 .ops = &ab8500_regulator_mode_ops,
1079 .type = REGULATOR_VOLTAGE,
1080 .id = AB8505_LDO_ADC,
1081 .owner = THIS_MODULE,
1082 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001083 .volt_table = fixed_2000000_voltage,
Lee Jonesa4d68462013-04-02 13:24:16 +01001084 .enable_time = 10000,
Lee Jones547f3842013-03-28 16:11:14 +00001085 },
Lee Jones547f3842013-03-28 16:11:14 +00001086 .load_lp_uA = 1000,
1087 .update_bank = 0x03,
1088 .update_reg = 0x80,
1089 .update_mask = 0x82,
1090 .update_val = 0x02,
1091 .update_val_idle = 0x82,
1092 .update_val_normal = 0x02,
1093 },
1094 [AB8505_LDO_USB] = {
1095 .desc = {
1096 .name = "LDO-USB",
1097 .ops = &ab8500_regulator_mode_ops,
1098 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001099 .id = AB8505_LDO_USB,
Lee Jones547f3842013-03-28 16:11:14 +00001100 .owner = THIS_MODULE,
1101 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001102 .volt_table = fixed_3300000_voltage,
Lee Jones547f3842013-03-28 16:11:14 +00001103 },
Lee Jones547f3842013-03-28 16:11:14 +00001104 .update_bank = 0x03,
1105 .update_reg = 0x82,
1106 .update_mask = 0x03,
1107 .update_val = 0x01,
1108 .update_val_idle = 0x03,
1109 .update_val_normal = 0x01,
1110 },
1111 [AB8505_LDO_AUDIO] = {
1112 .desc = {
1113 .name = "LDO-AUDIO",
Lee Jones8a3b1b82013-04-02 13:24:09 +01001114 .ops = &ab8500_regulator_volt_ops,
Lee Jones547f3842013-03-28 16:11:14 +00001115 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001116 .id = AB8505_LDO_AUDIO,
Lee Jones547f3842013-03-28 16:11:14 +00001117 .owner = THIS_MODULE,
Lee Jones8a3b1b82013-04-02 13:24:09 +01001118 .n_voltages = ARRAY_SIZE(ldo_vaudio_voltages),
1119 .volt_table = ldo_vaudio_voltages,
Lee Jones547f3842013-03-28 16:11:14 +00001120 },
Lee Jones547f3842013-03-28 16:11:14 +00001121 .update_bank = 0x03,
1122 .update_reg = 0x83,
1123 .update_mask = 0x02,
1124 .update_val = 0x02,
Lee Jones8a3b1b82013-04-02 13:24:09 +01001125 .voltage_bank = 0x01,
1126 .voltage_reg = 0x57,
Axel Line4fc9d62013-04-12 15:33:25 +08001127 .voltage_mask = 0x70,
Lee Jones8a3b1b82013-04-02 13:24:09 +01001128 .voltage_shift = 4,
Lee Jones547f3842013-03-28 16:11:14 +00001129 },
1130 [AB8505_LDO_ANAMIC1] = {
1131 .desc = {
1132 .name = "LDO-ANAMIC1",
Lee Jones3fe52282013-04-02 13:24:12 +01001133 .ops = &ab8500_regulator_anamic_mode_ops,
Lee Jones547f3842013-03-28 16:11:14 +00001134 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001135 .id = AB8505_LDO_ANAMIC1,
Lee Jones547f3842013-03-28 16:11:14 +00001136 .owner = THIS_MODULE,
1137 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001138 .volt_table = fixed_2050000_voltage,
Lee Jones547f3842013-03-28 16:11:14 +00001139 },
Lee Jones4c84b4d2013-04-02 13:24:13 +01001140 .shared_mode = &ldo_anamic1_shared,
Lee Jones547f3842013-03-28 16:11:14 +00001141 .update_bank = 0x03,
1142 .update_reg = 0x83,
1143 .update_mask = 0x08,
1144 .update_val = 0x08,
Lee Jones3fe52282013-04-02 13:24:12 +01001145 .mode_bank = 0x01,
1146 .mode_reg = 0x54,
1147 .mode_mask = 0x04,
1148 .mode_val_idle = 0x04,
1149 .mode_val_normal = 0x00,
Lee Jones547f3842013-03-28 16:11:14 +00001150 },
1151 [AB8505_LDO_ANAMIC2] = {
1152 .desc = {
1153 .name = "LDO-ANAMIC2",
Lee Jones3fe52282013-04-02 13:24:12 +01001154 .ops = &ab8500_regulator_anamic_mode_ops,
Lee Jones547f3842013-03-28 16:11:14 +00001155 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001156 .id = AB8505_LDO_ANAMIC2,
Lee Jones547f3842013-03-28 16:11:14 +00001157 .owner = THIS_MODULE,
1158 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001159 .volt_table = fixed_2050000_voltage,
Lee Jones547f3842013-03-28 16:11:14 +00001160 },
Lee Jones3fe52282013-04-02 13:24:12 +01001161 .shared_mode = &ldo_anamic2_shared,
Lee Jones547f3842013-03-28 16:11:14 +00001162 .update_bank = 0x03,
1163 .update_reg = 0x83,
1164 .update_mask = 0x10,
1165 .update_val = 0x10,
Lee Jones3fe52282013-04-02 13:24:12 +01001166 .mode_bank = 0x01,
1167 .mode_reg = 0x54,
1168 .mode_mask = 0x04,
1169 .mode_val_idle = 0x04,
1170 .mode_val_normal = 0x00,
Lee Jones547f3842013-03-28 16:11:14 +00001171 },
1172 [AB8505_LDO_AUX8] = {
1173 .desc = {
1174 .name = "LDO-AUX8",
1175 .ops = &ab8500_regulator_ops,
1176 .type = REGULATOR_VOLTAGE,
1177 .id = AB8505_LDO_AUX8,
1178 .owner = THIS_MODULE,
1179 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001180 .volt_table = fixed_1800000_voltage,
Lee Jones547f3842013-03-28 16:11:14 +00001181 },
Lee Jones547f3842013-03-28 16:11:14 +00001182 .update_bank = 0x03,
1183 .update_reg = 0x83,
1184 .update_mask = 0x04,
1185 .update_val = 0x04,
1186 },
1187 /*
1188 * Regulators with fixed voltage and normal/idle modes
1189 */
1190 [AB8505_LDO_ANA] = {
1191 .desc = {
1192 .name = "LDO-ANA",
Lee Jones8a3b1b82013-04-02 13:24:09 +01001193 .ops = &ab8500_regulator_volt_mode_ops,
Lee Jones547f3842013-03-28 16:11:14 +00001194 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001195 .id = AB8505_LDO_ANA,
Lee Jones547f3842013-03-28 16:11:14 +00001196 .owner = THIS_MODULE,
Lee Jones8a3b1b82013-04-02 13:24:09 +01001197 .n_voltages = ARRAY_SIZE(ldo_vana_voltages),
1198 .volt_table = ldo_vana_voltages,
Lee Jones547f3842013-03-28 16:11:14 +00001199 },
Lee Jones547f3842013-03-28 16:11:14 +00001200 .load_lp_uA = 1000,
1201 .update_bank = 0x04,
1202 .update_reg = 0x06,
1203 .update_mask = 0x0c,
1204 .update_val = 0x04,
1205 .update_val_idle = 0x0c,
1206 .update_val_normal = 0x04,
Lee Jones8a3b1b82013-04-02 13:24:09 +01001207 .voltage_bank = 0x04,
1208 .voltage_reg = 0x29,
1209 .voltage_mask = 0x7,
Lee Jones547f3842013-03-28 16:11:14 +00001210 },
1211};
1212
Lee Jones8e6a8d72013-03-28 16:11:11 +00001213/* AB9540 regulator information */
1214static struct ab8500_regulator_info
1215 ab9540_regulator_info[AB9540_NUM_REGULATORS] = {
1216 /*
1217 * Variable Voltage Regulators
1218 * name, min mV, max mV,
1219 * update bank, reg, mask, enable val
Lee Jonesd3193102013-04-02 13:24:18 +01001220 * volt bank, reg, mask
Lee Jones8e6a8d72013-03-28 16:11:11 +00001221 */
1222 [AB9540_LDO_AUX1] = {
1223 .desc = {
1224 .name = "LDO-AUX1",
1225 .ops = &ab8500_regulator_volt_mode_ops,
1226 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001227 .id = AB9540_LDO_AUX1,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001228 .owner = THIS_MODULE,
1229 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001230 .volt_table = ldo_vauxn_voltages,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001231 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001232 .load_lp_uA = 5000,
1233 .update_bank = 0x04,
1234 .update_reg = 0x09,
1235 .update_mask = 0x03,
1236 .update_val = 0x01,
1237 .update_val_idle = 0x03,
1238 .update_val_normal = 0x01,
1239 .voltage_bank = 0x04,
1240 .voltage_reg = 0x1f,
1241 .voltage_mask = 0x0f,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001242 },
1243 [AB9540_LDO_AUX2] = {
1244 .desc = {
1245 .name = "LDO-AUX2",
1246 .ops = &ab8500_regulator_volt_mode_ops,
1247 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001248 .id = AB9540_LDO_AUX2,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001249 .owner = THIS_MODULE,
1250 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001251 .volt_table = ldo_vauxn_voltages,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001252 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001253 .load_lp_uA = 5000,
1254 .update_bank = 0x04,
1255 .update_reg = 0x09,
1256 .update_mask = 0x0c,
1257 .update_val = 0x04,
1258 .update_val_idle = 0x0c,
1259 .update_val_normal = 0x04,
1260 .voltage_bank = 0x04,
1261 .voltage_reg = 0x20,
1262 .voltage_mask = 0x0f,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001263 },
1264 [AB9540_LDO_AUX3] = {
1265 .desc = {
1266 .name = "LDO-AUX3",
1267 .ops = &ab8500_regulator_volt_mode_ops,
1268 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001269 .id = AB9540_LDO_AUX3,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001270 .owner = THIS_MODULE,
1271 .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001272 .volt_table = ldo_vaux3_voltages,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001273 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001274 .load_lp_uA = 5000,
1275 .update_bank = 0x04,
1276 .update_reg = 0x0a,
1277 .update_mask = 0x03,
1278 .update_val = 0x01,
1279 .update_val_idle = 0x03,
1280 .update_val_normal = 0x01,
1281 .voltage_bank = 0x04,
1282 .voltage_reg = 0x21,
1283 .voltage_mask = 0x07,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001284 },
1285 [AB9540_LDO_AUX4] = {
1286 .desc = {
1287 .name = "LDO-AUX4",
1288 .ops = &ab8500_regulator_volt_mode_ops,
1289 .type = REGULATOR_VOLTAGE,
1290 .id = AB9540_LDO_AUX4,
1291 .owner = THIS_MODULE,
1292 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001293 .volt_table = ldo_vauxn_voltages,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001294 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001295 .load_lp_uA = 5000,
1296 /* values for Vaux4Regu register */
1297 .update_bank = 0x04,
1298 .update_reg = 0x2e,
1299 .update_mask = 0x03,
1300 .update_val = 0x01,
1301 .update_val_idle = 0x03,
1302 .update_val_normal = 0x01,
1303 /* values for Vaux4SEL register */
1304 .voltage_bank = 0x04,
1305 .voltage_reg = 0x2f,
1306 .voltage_mask = 0x0f,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001307 },
1308 [AB9540_LDO_INTCORE] = {
1309 .desc = {
1310 .name = "LDO-INTCORE",
1311 .ops = &ab8500_regulator_volt_mode_ops,
1312 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001313 .id = AB9540_LDO_INTCORE,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001314 .owner = THIS_MODULE,
1315 .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001316 .volt_table = ldo_vintcore_voltages,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001317 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001318 .load_lp_uA = 5000,
1319 .update_bank = 0x03,
1320 .update_reg = 0x80,
1321 .update_mask = 0x44,
1322 .update_val = 0x44,
1323 .update_val_idle = 0x44,
1324 .update_val_normal = 0x04,
1325 .voltage_bank = 0x03,
1326 .voltage_reg = 0x80,
1327 .voltage_mask = 0x38,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001328 .voltage_shift = 3,
1329 },
Bengt Jonsson6909b452010-12-10 11:08:47 +01001330
Lee Jones8e6a8d72013-03-28 16:11:11 +00001331 /*
1332 * Fixed Voltage Regulators
1333 * name, fixed mV,
1334 * update bank, reg, mask, enable val
1335 */
1336 [AB9540_LDO_TVOUT] = {
1337 .desc = {
1338 .name = "LDO-TVOUT",
1339 .ops = &ab8500_regulator_mode_ops,
1340 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001341 .id = AB9540_LDO_TVOUT,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001342 .owner = THIS_MODULE,
1343 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001344 .volt_table = fixed_2000000_voltage,
Lee Jonesa4d68462013-04-02 13:24:16 +01001345 .enable_time = 10000,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001346 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001347 .load_lp_uA = 1000,
1348 .update_bank = 0x03,
1349 .update_reg = 0x80,
1350 .update_mask = 0x82,
1351 .update_val = 0x02,
1352 .update_val_idle = 0x82,
1353 .update_val_normal = 0x02,
1354 },
1355 [AB9540_LDO_USB] = {
1356 .desc = {
1357 .name = "LDO-USB",
1358 .ops = &ab8500_regulator_ops,
1359 .type = REGULATOR_VOLTAGE,
1360 .id = AB9540_LDO_USB,
1361 .owner = THIS_MODULE,
1362 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001363 .volt_table = fixed_3300000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001364 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001365 .update_bank = 0x03,
1366 .update_reg = 0x82,
1367 .update_mask = 0x03,
1368 .update_val = 0x01,
1369 .update_val_idle = 0x03,
1370 .update_val_normal = 0x01,
1371 },
1372 [AB9540_LDO_AUDIO] = {
1373 .desc = {
1374 .name = "LDO-AUDIO",
1375 .ops = &ab8500_regulator_ops,
1376 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001377 .id = AB9540_LDO_AUDIO,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001378 .owner = THIS_MODULE,
1379 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001380 .volt_table = fixed_2000000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001381 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001382 .update_bank = 0x03,
1383 .update_reg = 0x83,
1384 .update_mask = 0x02,
1385 .update_val = 0x02,
1386 },
1387 [AB9540_LDO_ANAMIC1] = {
1388 .desc = {
1389 .name = "LDO-ANAMIC1",
1390 .ops = &ab8500_regulator_ops,
1391 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001392 .id = AB9540_LDO_ANAMIC1,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001393 .owner = THIS_MODULE,
1394 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001395 .volt_table = fixed_2050000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001396 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001397 .update_bank = 0x03,
1398 .update_reg = 0x83,
1399 .update_mask = 0x08,
1400 .update_val = 0x08,
1401 },
1402 [AB9540_LDO_ANAMIC2] = {
1403 .desc = {
1404 .name = "LDO-ANAMIC2",
1405 .ops = &ab8500_regulator_ops,
1406 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001407 .id = AB9540_LDO_ANAMIC2,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001408 .owner = THIS_MODULE,
1409 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001410 .volt_table = fixed_2050000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001411 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001412 .update_bank = 0x03,
1413 .update_reg = 0x83,
1414 .update_mask = 0x10,
1415 .update_val = 0x10,
1416 },
1417 [AB9540_LDO_DMIC] = {
1418 .desc = {
1419 .name = "LDO-DMIC",
1420 .ops = &ab8500_regulator_ops,
1421 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001422 .id = AB9540_LDO_DMIC,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001423 .owner = THIS_MODULE,
1424 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001425 .volt_table = fixed_1800000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001426 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001427 .update_bank = 0x03,
1428 .update_reg = 0x83,
1429 .update_mask = 0x04,
1430 .update_val = 0x04,
1431 },
1432
1433 /*
1434 * Regulators with fixed voltage and normal/idle modes
1435 */
1436 [AB9540_LDO_ANA] = {
1437 .desc = {
1438 .name = "LDO-ANA",
1439 .ops = &ab8500_regulator_mode_ops,
1440 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001441 .id = AB9540_LDO_ANA,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001442 .owner = THIS_MODULE,
1443 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001444 .volt_table = fixed_1200000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001445 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001446 .load_lp_uA = 1000,
1447 .update_bank = 0x04,
1448 .update_reg = 0x06,
1449 .update_mask = 0x0c,
1450 .update_val = 0x08,
1451 .update_val_idle = 0x0c,
1452 .update_val_normal = 0x08,
1453 },
Sundar R IYERc789ca22010-07-13 21:48:56 +05301454};
1455
Lee Jonesae0a9a32013-03-28 16:11:16 +00001456/* AB8540 regulator information */
1457static struct ab8500_regulator_info
1458 ab8540_regulator_info[AB8540_NUM_REGULATORS] = {
1459 /*
1460 * Variable Voltage Regulators
1461 * name, min mV, max mV,
1462 * update bank, reg, mask, enable val
Lee Jonesd3193102013-04-02 13:24:18 +01001463 * volt bank, reg, mask
Lee Jonesae0a9a32013-03-28 16:11:16 +00001464 */
1465 [AB8540_LDO_AUX1] = {
1466 .desc = {
1467 .name = "LDO-AUX1",
1468 .ops = &ab8500_regulator_volt_mode_ops,
1469 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001470 .id = AB8540_LDO_AUX1,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001471 .owner = THIS_MODULE,
1472 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001473 .volt_table = ldo_vauxn_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001474 },
1475 .load_lp_uA = 5000,
1476 .update_bank = 0x04,
1477 .update_reg = 0x09,
1478 .update_mask = 0x03,
1479 .update_val = 0x01,
1480 .update_val_idle = 0x03,
1481 .update_val_normal = 0x01,
1482 .voltage_bank = 0x04,
1483 .voltage_reg = 0x1f,
1484 .voltage_mask = 0x0f,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001485 },
1486 [AB8540_LDO_AUX2] = {
1487 .desc = {
1488 .name = "LDO-AUX2",
1489 .ops = &ab8500_regulator_volt_mode_ops,
1490 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001491 .id = AB8540_LDO_AUX2,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001492 .owner = THIS_MODULE,
1493 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001494 .volt_table = ldo_vauxn_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001495 },
1496 .load_lp_uA = 5000,
1497 .update_bank = 0x04,
1498 .update_reg = 0x09,
1499 .update_mask = 0x0c,
1500 .update_val = 0x04,
1501 .update_val_idle = 0x0c,
1502 .update_val_normal = 0x04,
1503 .voltage_bank = 0x04,
1504 .voltage_reg = 0x20,
1505 .voltage_mask = 0x0f,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001506 },
1507 [AB8540_LDO_AUX3] = {
1508 .desc = {
1509 .name = "LDO-AUX3",
Lee Jonesd7607ba2013-04-02 13:24:11 +01001510 .ops = &ab8540_aux3_regulator_volt_mode_ops,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001511 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001512 .id = AB8540_LDO_AUX3,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001513 .owner = THIS_MODULE,
1514 .n_voltages = ARRAY_SIZE(ldo_vaux3_ab8540_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001515 .volt_table = ldo_vaux3_ab8540_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001516 },
1517 .load_lp_uA = 5000,
1518 .update_bank = 0x04,
1519 .update_reg = 0x0a,
1520 .update_mask = 0x03,
1521 .update_val = 0x01,
1522 .update_val_idle = 0x03,
1523 .update_val_normal = 0x01,
1524 .voltage_bank = 0x04,
1525 .voltage_reg = 0x21,
1526 .voltage_mask = 0x07,
Lee Jonesd7607ba2013-04-02 13:24:11 +01001527 .expand_register = {
1528 .voltage_limit = 8,
1529 .voltage_bank = 0x04,
1530 .voltage_reg = 0x01,
1531 .voltage_mask = 0x10,
1532 .voltage_shift = 1,
1533 }
Lee Jonesae0a9a32013-03-28 16:11:16 +00001534 },
1535 [AB8540_LDO_AUX4] = {
1536 .desc = {
1537 .name = "LDO-AUX4",
1538 .ops = &ab8500_regulator_volt_mode_ops,
1539 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001540 .id = AB8540_LDO_AUX4,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001541 .owner = THIS_MODULE,
1542 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001543 .volt_table = ldo_vauxn_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001544 },
1545 .load_lp_uA = 5000,
1546 /* values for Vaux4Regu register */
1547 .update_bank = 0x04,
1548 .update_reg = 0x2e,
1549 .update_mask = 0x03,
1550 .update_val = 0x01,
1551 .update_val_idle = 0x03,
1552 .update_val_normal = 0x01,
1553 /* values for Vaux4SEL register */
1554 .voltage_bank = 0x04,
1555 .voltage_reg = 0x2f,
1556 .voltage_mask = 0x0f,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001557 },
Zhenhua HUANG684d5ce2013-04-02 13:24:15 +01001558 [AB8540_LDO_AUX5] = {
1559 .desc = {
1560 .name = "LDO-AUX5",
1561 .ops = &ab8500_regulator_volt_mode_ops,
1562 .type = REGULATOR_VOLTAGE,
1563 .id = AB8540_LDO_AUX5,
1564 .owner = THIS_MODULE,
1565 .n_voltages = ARRAY_SIZE(ldo_vaux56_ab8540_voltages),
Lee Jonesd3193102013-04-02 13:24:18 +01001566 .volt_table = ldo_vaux56_ab8540_voltages,
Zhenhua HUANG684d5ce2013-04-02 13:24:15 +01001567 },
1568 .load_lp_uA = 20000,
1569 /* values for Vaux5Regu register */
1570 .update_bank = 0x04,
1571 .update_reg = 0x32,
1572 .update_mask = 0x03,
1573 .update_val = 0x01,
1574 .update_val_idle = 0x03,
1575 .update_val_normal = 0x01,
1576 /* values for Vaux5SEL register */
1577 .voltage_bank = 0x04,
1578 .voltage_reg = 0x33,
1579 .voltage_mask = 0x3f,
Zhenhua HUANG684d5ce2013-04-02 13:24:15 +01001580 },
1581 [AB8540_LDO_AUX6] = {
1582 .desc = {
1583 .name = "LDO-AUX6",
1584 .ops = &ab8500_regulator_volt_mode_ops,
1585 .type = REGULATOR_VOLTAGE,
1586 .id = AB8540_LDO_AUX6,
1587 .owner = THIS_MODULE,
1588 .n_voltages = ARRAY_SIZE(ldo_vaux56_ab8540_voltages),
Lee Jonesd3193102013-04-02 13:24:18 +01001589 .volt_table = ldo_vaux56_ab8540_voltages,
Zhenhua HUANG684d5ce2013-04-02 13:24:15 +01001590 },
1591 .load_lp_uA = 20000,
1592 /* values for Vaux6Regu register */
1593 .update_bank = 0x04,
1594 .update_reg = 0x35,
1595 .update_mask = 0x03,
1596 .update_val = 0x01,
1597 .update_val_idle = 0x03,
1598 .update_val_normal = 0x01,
1599 /* values for Vaux6SEL register */
1600 .voltage_bank = 0x04,
1601 .voltage_reg = 0x36,
1602 .voltage_mask = 0x3f,
Zhenhua HUANG684d5ce2013-04-02 13:24:15 +01001603 },
Lee Jonesae0a9a32013-03-28 16:11:16 +00001604 [AB8540_LDO_INTCORE] = {
1605 .desc = {
1606 .name = "LDO-INTCORE",
1607 .ops = &ab8500_regulator_volt_mode_ops,
1608 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001609 .id = AB8540_LDO_INTCORE,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001610 .owner = THIS_MODULE,
1611 .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001612 .volt_table = ldo_vintcore_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001613 },
1614 .load_lp_uA = 5000,
1615 .update_bank = 0x03,
1616 .update_reg = 0x80,
1617 .update_mask = 0x44,
1618 .update_val = 0x44,
1619 .update_val_idle = 0x44,
1620 .update_val_normal = 0x04,
1621 .voltage_bank = 0x03,
1622 .voltage_reg = 0x80,
1623 .voltage_mask = 0x38,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001624 .voltage_shift = 3,
1625 },
1626
1627 /*
1628 * Fixed Voltage Regulators
1629 * name, fixed mV,
1630 * update bank, reg, mask, enable val
1631 */
1632 [AB8540_LDO_TVOUT] = {
1633 .desc = {
1634 .name = "LDO-TVOUT",
1635 .ops = &ab8500_regulator_mode_ops,
1636 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001637 .id = AB8540_LDO_TVOUT,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001638 .owner = THIS_MODULE,
1639 .n_voltages = 1,
Axel Linaca45e92013-04-02 13:24:23 +01001640 .volt_table = fixed_2000000_voltage,
Lee Jonesa4d68462013-04-02 13:24:16 +01001641 .enable_time = 10000,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001642 },
Lee Jonesae0a9a32013-03-28 16:11:16 +00001643 .load_lp_uA = 1000,
1644 .update_bank = 0x03,
1645 .update_reg = 0x80,
1646 .update_mask = 0x82,
1647 .update_val = 0x02,
1648 .update_val_idle = 0x82,
1649 .update_val_normal = 0x02,
1650 },
1651 [AB8540_LDO_AUDIO] = {
1652 .desc = {
1653 .name = "LDO-AUDIO",
1654 .ops = &ab8500_regulator_ops,
1655 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001656 .id = AB8540_LDO_AUDIO,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001657 .owner = THIS_MODULE,
1658 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001659 .volt_table = fixed_2000000_voltage,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001660 },
1661 .update_bank = 0x03,
1662 .update_reg = 0x83,
1663 .update_mask = 0x02,
1664 .update_val = 0x02,
1665 },
1666 [AB8540_LDO_ANAMIC1] = {
1667 .desc = {
1668 .name = "LDO-ANAMIC1",
Lee Jones4c84b4d2013-04-02 13:24:13 +01001669 .ops = &ab8500_regulator_anamic_mode_ops,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001670 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001671 .id = AB8540_LDO_ANAMIC1,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001672 .owner = THIS_MODULE,
1673 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001674 .volt_table = fixed_2050000_voltage,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001675 },
Lee Jones4c84b4d2013-04-02 13:24:13 +01001676 .shared_mode = &ab8540_ldo_anamic1_shared,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001677 .update_bank = 0x03,
1678 .update_reg = 0x83,
1679 .update_mask = 0x08,
1680 .update_val = 0x08,
Lee Jones4c84b4d2013-04-02 13:24:13 +01001681 .mode_bank = 0x03,
1682 .mode_reg = 0x83,
1683 .mode_mask = 0x20,
1684 .mode_val_idle = 0x20,
1685 .mode_val_normal = 0x00,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001686 },
1687 [AB8540_LDO_ANAMIC2] = {
1688 .desc = {
1689 .name = "LDO-ANAMIC2",
Lee Jones4c84b4d2013-04-02 13:24:13 +01001690 .ops = &ab8500_regulator_anamic_mode_ops,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001691 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001692 .id = AB8540_LDO_ANAMIC2,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001693 .owner = THIS_MODULE,
1694 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001695 .volt_table = fixed_2050000_voltage,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001696 },
Lee Jones4c84b4d2013-04-02 13:24:13 +01001697 .shared_mode = &ab8540_ldo_anamic2_shared,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001698 .update_bank = 0x03,
1699 .update_reg = 0x83,
1700 .update_mask = 0x10,
1701 .update_val = 0x10,
Lee Jones4c84b4d2013-04-02 13:24:13 +01001702 .mode_bank = 0x03,
1703 .mode_reg = 0x83,
1704 .mode_mask = 0x20,
1705 .mode_val_idle = 0x20,
1706 .mode_val_normal = 0x00,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001707 },
1708 [AB8540_LDO_DMIC] = {
1709 .desc = {
1710 .name = "LDO-DMIC",
Lee Jones4c84b4d2013-04-02 13:24:13 +01001711 .ops = &ab8500_regulator_volt_mode_ops,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001712 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001713 .id = AB8540_LDO_DMIC,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001714 .owner = THIS_MODULE,
Lee Jones4c84b4d2013-04-02 13:24:13 +01001715 .n_voltages = ARRAY_SIZE(ldo_vdmic_voltages),
Lee Jonesd3193102013-04-02 13:24:18 +01001716 .volt_table = ldo_vdmic_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001717 },
Lee Jones4c84b4d2013-04-02 13:24:13 +01001718 .load_lp_uA = 1000,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001719 .update_bank = 0x03,
1720 .update_reg = 0x83,
1721 .update_mask = 0x04,
1722 .update_val = 0x04,
Lee Jones4c84b4d2013-04-02 13:24:13 +01001723 .voltage_bank = 0x03,
1724 .voltage_reg = 0x83,
1725 .voltage_mask = 0xc0,
Axel Lin375dc9c2013-04-15 16:36:51 +08001726 .voltage_shift = 6,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001727 },
1728
1729 /*
1730 * Regulators with fixed voltage and normal/idle modes
1731 */
1732 [AB8540_LDO_ANA] = {
1733 .desc = {
1734 .name = "LDO-ANA",
1735 .ops = &ab8500_regulator_mode_ops,
1736 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001737 .id = AB8540_LDO_ANA,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001738 .owner = THIS_MODULE,
1739 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001740 .volt_table = fixed_1200000_voltage,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001741 },
1742 .load_lp_uA = 1000,
1743 .update_bank = 0x04,
1744 .update_reg = 0x06,
1745 .update_mask = 0x0c,
1746 .update_val = 0x04,
1747 .update_val_idle = 0x0c,
1748 .update_val_normal = 0x04,
1749 },
1750 [AB8540_LDO_SDIO] = {
1751 .desc = {
1752 .name = "LDO-SDIO",
1753 .ops = &ab8500_regulator_volt_mode_ops,
1754 .type = REGULATOR_VOLTAGE,
1755 .id = AB8540_LDO_SDIO,
1756 .owner = THIS_MODULE,
Lee Jones62ab4112013-03-28 16:11:18 +00001757 .n_voltages = ARRAY_SIZE(ldo_sdio_voltages),
1758 .volt_table = ldo_sdio_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001759 },
Lee Jonesae0a9a32013-03-28 16:11:16 +00001760 .load_lp_uA = 5000,
1761 .update_bank = 0x03,
1762 .update_reg = 0x88,
1763 .update_mask = 0x30,
1764 .update_val = 0x10,
1765 .update_val_idle = 0x30,
1766 .update_val_normal = 0x10,
1767 .voltage_bank = 0x03,
1768 .voltage_reg = 0x88,
1769 .voltage_mask = 0x07,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001770 },
1771};
1772
Lee Jones3fe52282013-04-02 13:24:12 +01001773static struct ab8500_shared_mode ldo_anamic1_shared = {
1774 .shared_regulator = &ab8505_regulator_info[AB8505_LDO_ANAMIC2],
1775};
1776
1777static struct ab8500_shared_mode ldo_anamic2_shared = {
1778 .shared_regulator = &ab8505_regulator_info[AB8505_LDO_ANAMIC1],
1779};
1780
Lee Jones4c84b4d2013-04-02 13:24:13 +01001781static struct ab8500_shared_mode ab8540_ldo_anamic1_shared = {
1782 .shared_regulator = &ab8540_regulator_info[AB8540_LDO_ANAMIC2],
1783};
1784
1785static struct ab8500_shared_mode ab8540_ldo_anamic2_shared = {
1786 .shared_regulator = &ab8540_regulator_info[AB8540_LDO_ANAMIC1],
1787};
1788
Bengt Jonsson79568b942011-03-11 11:54:46 +01001789struct ab8500_reg_init {
1790 u8 bank;
1791 u8 addr;
1792 u8 mask;
1793};
1794
1795#define REG_INIT(_id, _bank, _addr, _mask) \
1796 [_id] = { \
1797 .bank = _bank, \
1798 .addr = _addr, \
1799 .mask = _mask, \
1800 }
1801
Lee Jones8e6a8d72013-03-28 16:11:11 +00001802/* AB8500 register init */
Bengt Jonsson79568b942011-03-11 11:54:46 +01001803static struct ab8500_reg_init ab8500_reg_init[] = {
1804 /*
Lee Jones33bc8f42013-03-21 15:59:02 +00001805 * 0x30, VanaRequestCtrl
Bengt Jonsson79568b942011-03-11 11:54:46 +01001806 * 0xc0, VextSupply1RequestCtrl
1807 */
Lee Jones43a59112013-03-21 15:59:15 +00001808 REG_INIT(AB8500_REGUREQUESTCTRL2, 0x03, 0x04, 0xf0),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001809 /*
1810 * 0x03, VextSupply2RequestCtrl
1811 * 0x0c, VextSupply3RequestCtrl
1812 * 0x30, Vaux1RequestCtrl
1813 * 0xc0, Vaux2RequestCtrl
1814 */
1815 REG_INIT(AB8500_REGUREQUESTCTRL3, 0x03, 0x05, 0xff),
1816 /*
1817 * 0x03, Vaux3RequestCtrl
1818 * 0x04, SwHPReq
1819 */
1820 REG_INIT(AB8500_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
1821 /*
1822 * 0x08, VanaSysClkReq1HPValid
1823 * 0x20, Vaux1SysClkReq1HPValid
1824 * 0x40, Vaux2SysClkReq1HPValid
1825 * 0x80, Vaux3SysClkReq1HPValid
1826 */
Lee Jones43a59112013-03-21 15:59:15 +00001827 REG_INIT(AB8500_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xe8),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001828 /*
1829 * 0x10, VextSupply1SysClkReq1HPValid
1830 * 0x20, VextSupply2SysClkReq1HPValid
1831 * 0x40, VextSupply3SysClkReq1HPValid
1832 */
Lee Jones43a59112013-03-21 15:59:15 +00001833 REG_INIT(AB8500_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x70),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001834 /*
1835 * 0x08, VanaHwHPReq1Valid
1836 * 0x20, Vaux1HwHPReq1Valid
1837 * 0x40, Vaux2HwHPReq1Valid
1838 * 0x80, Vaux3HwHPReq1Valid
1839 */
Lee Jones43a59112013-03-21 15:59:15 +00001840 REG_INIT(AB8500_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xe8),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001841 /*
1842 * 0x01, VextSupply1HwHPReq1Valid
1843 * 0x02, VextSupply2HwHPReq1Valid
1844 * 0x04, VextSupply3HwHPReq1Valid
1845 */
Lee Jones43a59112013-03-21 15:59:15 +00001846 REG_INIT(AB8500_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x07),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001847 /*
1848 * 0x08, VanaHwHPReq2Valid
1849 * 0x20, Vaux1HwHPReq2Valid
1850 * 0x40, Vaux2HwHPReq2Valid
1851 * 0x80, Vaux3HwHPReq2Valid
1852 */
Lee Jones43a59112013-03-21 15:59:15 +00001853 REG_INIT(AB8500_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xe8),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001854 /*
1855 * 0x01, VextSupply1HwHPReq2Valid
1856 * 0x02, VextSupply2HwHPReq2Valid
1857 * 0x04, VextSupply3HwHPReq2Valid
1858 */
Lee Jones43a59112013-03-21 15:59:15 +00001859 REG_INIT(AB8500_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x07),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001860 /*
1861 * 0x20, VanaSwHPReqValid
1862 * 0x80, Vaux1SwHPReqValid
1863 */
Lee Jones43a59112013-03-21 15:59:15 +00001864 REG_INIT(AB8500_REGUSWHPREQVALID1, 0x03, 0x0d, 0xa0),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001865 /*
1866 * 0x01, Vaux2SwHPReqValid
1867 * 0x02, Vaux3SwHPReqValid
1868 * 0x04, VextSupply1SwHPReqValid
1869 * 0x08, VextSupply2SwHPReqValid
1870 * 0x10, VextSupply3SwHPReqValid
1871 */
Lee Jones43a59112013-03-21 15:59:15 +00001872 REG_INIT(AB8500_REGUSWHPREQVALID2, 0x03, 0x0e, 0x1f),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001873 /*
1874 * 0x02, SysClkReq2Valid1
Lee Jones43a59112013-03-21 15:59:15 +00001875 * 0x04, SysClkReq3Valid1
1876 * 0x08, SysClkReq4Valid1
1877 * 0x10, SysClkReq5Valid1
1878 * 0x20, SysClkReq6Valid1
1879 * 0x40, SysClkReq7Valid1
Bengt Jonsson79568b942011-03-11 11:54:46 +01001880 * 0x80, SysClkReq8Valid1
1881 */
1882 REG_INIT(AB8500_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0xfe),
1883 /*
1884 * 0x02, SysClkReq2Valid2
Lee Jones43a59112013-03-21 15:59:15 +00001885 * 0x04, SysClkReq3Valid2
1886 * 0x08, SysClkReq4Valid2
1887 * 0x10, SysClkReq5Valid2
1888 * 0x20, SysClkReq6Valid2
1889 * 0x40, SysClkReq7Valid2
Bengt Jonsson79568b942011-03-11 11:54:46 +01001890 * 0x80, SysClkReq8Valid2
1891 */
1892 REG_INIT(AB8500_REGUSYSCLKREQVALID2, 0x03, 0x10, 0xfe),
1893 /*
1894 * 0x02, VTVoutEna
1895 * 0x04, Vintcore12Ena
1896 * 0x38, Vintcore12Sel
1897 * 0x40, Vintcore12LP
1898 * 0x80, VTVoutLP
1899 */
1900 REG_INIT(AB8500_REGUMISC1, 0x03, 0x80, 0xfe),
1901 /*
1902 * 0x02, VaudioEna
1903 * 0x04, VdmicEna
1904 * 0x08, Vamic1Ena
1905 * 0x10, Vamic2Ena
1906 */
1907 REG_INIT(AB8500_VAUDIOSUPPLY, 0x03, 0x83, 0x1e),
1908 /*
1909 * 0x01, Vamic1_dzout
1910 * 0x02, Vamic2_dzout
1911 */
1912 REG_INIT(AB8500_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
1913 /*
Lee Jones43a59112013-03-21 15:59:15 +00001914 * 0x03, VpllRegu (NOTE! PRCMU register bits)
Lee Jones33bc8f42013-03-21 15:59:02 +00001915 * 0x0c, VanaRegu
Bengt Jonsson79568b942011-03-11 11:54:46 +01001916 */
1917 REG_INIT(AB8500_VPLLVANAREGU, 0x04, 0x06, 0x0f),
1918 /*
1919 * 0x01, VrefDDREna
1920 * 0x02, VrefDDRSleepMode
1921 */
1922 REG_INIT(AB8500_VREFDDR, 0x04, 0x07, 0x03),
1923 /*
1924 * 0x03, VextSupply1Regu
1925 * 0x0c, VextSupply2Regu
1926 * 0x30, VextSupply3Regu
1927 * 0x40, ExtSupply2Bypass
1928 * 0x80, ExtSupply3Bypass
1929 */
1930 REG_INIT(AB8500_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
1931 /*
1932 * 0x03, Vaux1Regu
1933 * 0x0c, Vaux2Regu
1934 */
1935 REG_INIT(AB8500_VAUX12REGU, 0x04, 0x09, 0x0f),
1936 /*
1937 * 0x03, Vaux3Regu
1938 */
Lee Jones43a59112013-03-21 15:59:15 +00001939 REG_INIT(AB8500_VRF1VAUX3REGU, 0x04, 0x0a, 0x03),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001940 /*
1941 * 0x0f, Vaux1Sel
1942 */
1943 REG_INIT(AB8500_VAUX1SEL, 0x04, 0x1f, 0x0f),
1944 /*
1945 * 0x0f, Vaux2Sel
1946 */
1947 REG_INIT(AB8500_VAUX2SEL, 0x04, 0x20, 0x0f),
1948 /*
1949 * 0x07, Vaux3Sel
1950 */
Lee Jones43a59112013-03-21 15:59:15 +00001951 REG_INIT(AB8500_VRF1VAUX3SEL, 0x04, 0x21, 0x07),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001952 /*
1953 * 0x01, VextSupply12LP
1954 */
1955 REG_INIT(AB8500_REGUCTRL2SPARE, 0x04, 0x22, 0x01),
1956 /*
1957 * 0x04, Vaux1Disch
1958 * 0x08, Vaux2Disch
1959 * 0x10, Vaux3Disch
1960 * 0x20, Vintcore12Disch
1961 * 0x40, VTVoutDisch
1962 * 0x80, VaudioDisch
1963 */
Lee Jones43a59112013-03-21 15:59:15 +00001964 REG_INIT(AB8500_REGUCTRLDISCH, 0x04, 0x43, 0xfc),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001965 /*
1966 * 0x02, VanaDisch
1967 * 0x04, VdmicPullDownEna
1968 * 0x10, VdmicDisch
1969 */
Lee Jones43a59112013-03-21 15:59:15 +00001970 REG_INIT(AB8500_REGUCTRLDISCH2, 0x04, 0x44, 0x16),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001971};
1972
Lee Jones547f3842013-03-28 16:11:14 +00001973/* AB8505 register init */
1974static struct ab8500_reg_init ab8505_reg_init[] = {
1975 /*
1976 * 0x03, VarmRequestCtrl
1977 * 0x0c, VsmpsCRequestCtrl
1978 * 0x30, VsmpsARequestCtrl
1979 * 0xc0, VsmpsBRequestCtrl
1980 */
1981 REG_INIT(AB8505_REGUREQUESTCTRL1, 0x03, 0x03, 0xff),
1982 /*
1983 * 0x03, VsafeRequestCtrl
1984 * 0x0c, VpllRequestCtrl
1985 * 0x30, VanaRequestCtrl
1986 */
1987 REG_INIT(AB8505_REGUREQUESTCTRL2, 0x03, 0x04, 0x3f),
1988 /*
1989 * 0x30, Vaux1RequestCtrl
1990 * 0xc0, Vaux2RequestCtrl
1991 */
1992 REG_INIT(AB8505_REGUREQUESTCTRL3, 0x03, 0x05, 0xf0),
1993 /*
1994 * 0x03, Vaux3RequestCtrl
1995 * 0x04, SwHPReq
1996 */
1997 REG_INIT(AB8505_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
1998 /*
1999 * 0x01, VsmpsASysClkReq1HPValid
2000 * 0x02, VsmpsBSysClkReq1HPValid
2001 * 0x04, VsafeSysClkReq1HPValid
2002 * 0x08, VanaSysClkReq1HPValid
2003 * 0x10, VpllSysClkReq1HPValid
2004 * 0x20, Vaux1SysClkReq1HPValid
2005 * 0x40, Vaux2SysClkReq1HPValid
2006 * 0x80, Vaux3SysClkReq1HPValid
2007 */
2008 REG_INIT(AB8505_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xff),
2009 /*
2010 * 0x01, VsmpsCSysClkReq1HPValid
2011 * 0x02, VarmSysClkReq1HPValid
2012 * 0x04, VbbSysClkReq1HPValid
2013 * 0x08, VsmpsMSysClkReq1HPValid
2014 */
2015 REG_INIT(AB8505_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x0f),
2016 /*
2017 * 0x01, VsmpsAHwHPReq1Valid
2018 * 0x02, VsmpsBHwHPReq1Valid
2019 * 0x04, VsafeHwHPReq1Valid
2020 * 0x08, VanaHwHPReq1Valid
2021 * 0x10, VpllHwHPReq1Valid
2022 * 0x20, Vaux1HwHPReq1Valid
2023 * 0x40, Vaux2HwHPReq1Valid
2024 * 0x80, Vaux3HwHPReq1Valid
2025 */
2026 REG_INIT(AB8505_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xff),
2027 /*
2028 * 0x08, VsmpsMHwHPReq1Valid
2029 */
2030 REG_INIT(AB8505_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x08),
2031 /*
2032 * 0x01, VsmpsAHwHPReq2Valid
2033 * 0x02, VsmpsBHwHPReq2Valid
2034 * 0x04, VsafeHwHPReq2Valid
2035 * 0x08, VanaHwHPReq2Valid
2036 * 0x10, VpllHwHPReq2Valid
2037 * 0x20, Vaux1HwHPReq2Valid
2038 * 0x40, Vaux2HwHPReq2Valid
2039 * 0x80, Vaux3HwHPReq2Valid
2040 */
2041 REG_INIT(AB8505_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xff),
2042 /*
2043 * 0x08, VsmpsMHwHPReq2Valid
2044 */
2045 REG_INIT(AB8505_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x08),
2046 /*
2047 * 0x01, VsmpsCSwHPReqValid
2048 * 0x02, VarmSwHPReqValid
2049 * 0x04, VsmpsASwHPReqValid
2050 * 0x08, VsmpsBSwHPReqValid
2051 * 0x10, VsafeSwHPReqValid
2052 * 0x20, VanaSwHPReqValid
2053 * 0x40, VpllSwHPReqValid
2054 * 0x80, Vaux1SwHPReqValid
2055 */
2056 REG_INIT(AB8505_REGUSWHPREQVALID1, 0x03, 0x0d, 0xff),
2057 /*
2058 * 0x01, Vaux2SwHPReqValid
2059 * 0x02, Vaux3SwHPReqValid
2060 * 0x20, VsmpsMSwHPReqValid
2061 */
2062 REG_INIT(AB8505_REGUSWHPREQVALID2, 0x03, 0x0e, 0x23),
2063 /*
2064 * 0x02, SysClkReq2Valid1
2065 * 0x04, SysClkReq3Valid1
2066 * 0x08, SysClkReq4Valid1
2067 */
2068 REG_INIT(AB8505_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0x0e),
2069 /*
2070 * 0x02, SysClkReq2Valid2
2071 * 0x04, SysClkReq3Valid2
2072 * 0x08, SysClkReq4Valid2
2073 */
2074 REG_INIT(AB8505_REGUSYSCLKREQVALID2, 0x03, 0x10, 0x0e),
2075 /*
2076 * 0x01, Vaux4SwHPReqValid
2077 * 0x02, Vaux4HwHPReq2Valid
2078 * 0x04, Vaux4HwHPReq1Valid
2079 * 0x08, Vaux4SysClkReq1HPValid
2080 */
2081 REG_INIT(AB8505_REGUVAUX4REQVALID, 0x03, 0x11, 0x0f),
2082 /*
2083 * 0x02, VadcEna
2084 * 0x04, VintCore12Ena
2085 * 0x38, VintCore12Sel
2086 * 0x40, VintCore12LP
2087 * 0x80, VadcLP
2088 */
2089 REG_INIT(AB8505_REGUMISC1, 0x03, 0x80, 0xfe),
2090 /*
2091 * 0x02, VaudioEna
2092 * 0x04, VdmicEna
2093 * 0x08, Vamic1Ena
2094 * 0x10, Vamic2Ena
2095 */
2096 REG_INIT(AB8505_VAUDIOSUPPLY, 0x03, 0x83, 0x1e),
2097 /*
2098 * 0x01, Vamic1_dzout
2099 * 0x02, Vamic2_dzout
2100 */
2101 REG_INIT(AB8505_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
2102 /*
2103 * 0x03, VsmpsARegu
2104 * 0x0c, VsmpsASelCtrl
2105 * 0x10, VsmpsAAutoMode
2106 * 0x20, VsmpsAPWMMode
2107 */
2108 REG_INIT(AB8505_VSMPSAREGU, 0x04, 0x03, 0x3f),
2109 /*
2110 * 0x03, VsmpsBRegu
2111 * 0x0c, VsmpsBSelCtrl
2112 * 0x10, VsmpsBAutoMode
2113 * 0x20, VsmpsBPWMMode
2114 */
2115 REG_INIT(AB8505_VSMPSBREGU, 0x04, 0x04, 0x3f),
2116 /*
2117 * 0x03, VsafeRegu
2118 * 0x0c, VsafeSelCtrl
2119 * 0x10, VsafeAutoMode
2120 * 0x20, VsafePWMMode
2121 */
2122 REG_INIT(AB8505_VSAFEREGU, 0x04, 0x05, 0x3f),
2123 /*
2124 * 0x03, VpllRegu (NOTE! PRCMU register bits)
2125 * 0x0c, VanaRegu
2126 */
2127 REG_INIT(AB8505_VPLLVANAREGU, 0x04, 0x06, 0x0f),
2128 /*
2129 * 0x03, VextSupply1Regu
2130 * 0x0c, VextSupply2Regu
2131 * 0x30, VextSupply3Regu
2132 * 0x40, ExtSupply2Bypass
2133 * 0x80, ExtSupply3Bypass
2134 */
2135 REG_INIT(AB8505_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
2136 /*
2137 * 0x03, Vaux1Regu
2138 * 0x0c, Vaux2Regu
2139 */
2140 REG_INIT(AB8505_VAUX12REGU, 0x04, 0x09, 0x0f),
2141 /*
2142 * 0x0f, Vaux3Regu
2143 */
2144 REG_INIT(AB8505_VRF1VAUX3REGU, 0x04, 0x0a, 0x0f),
2145 /*
2146 * 0x3f, VsmpsASel1
2147 */
2148 REG_INIT(AB8505_VSMPSASEL1, 0x04, 0x13, 0x3f),
2149 /*
2150 * 0x3f, VsmpsASel2
2151 */
2152 REG_INIT(AB8505_VSMPSASEL2, 0x04, 0x14, 0x3f),
2153 /*
2154 * 0x3f, VsmpsASel3
2155 */
2156 REG_INIT(AB8505_VSMPSASEL3, 0x04, 0x15, 0x3f),
2157 /*
2158 * 0x3f, VsmpsBSel1
2159 */
2160 REG_INIT(AB8505_VSMPSBSEL1, 0x04, 0x17, 0x3f),
2161 /*
2162 * 0x3f, VsmpsBSel2
2163 */
2164 REG_INIT(AB8505_VSMPSBSEL2, 0x04, 0x18, 0x3f),
2165 /*
2166 * 0x3f, VsmpsBSel3
2167 */
2168 REG_INIT(AB8505_VSMPSBSEL3, 0x04, 0x19, 0x3f),
2169 /*
2170 * 0x7f, VsafeSel1
2171 */
2172 REG_INIT(AB8505_VSAFESEL1, 0x04, 0x1b, 0x7f),
2173 /*
2174 * 0x3f, VsafeSel2
2175 */
2176 REG_INIT(AB8505_VSAFESEL2, 0x04, 0x1c, 0x7f),
2177 /*
2178 * 0x3f, VsafeSel3
2179 */
2180 REG_INIT(AB8505_VSAFESEL3, 0x04, 0x1d, 0x7f),
2181 /*
2182 * 0x0f, Vaux1Sel
2183 */
2184 REG_INIT(AB8505_VAUX1SEL, 0x04, 0x1f, 0x0f),
2185 /*
2186 * 0x0f, Vaux2Sel
2187 */
2188 REG_INIT(AB8505_VAUX2SEL, 0x04, 0x20, 0x0f),
2189 /*
2190 * 0x07, Vaux3Sel
2191 * 0x30, VRF1Sel
2192 */
2193 REG_INIT(AB8505_VRF1VAUX3SEL, 0x04, 0x21, 0x37),
2194 /*
2195 * 0x03, Vaux4RequestCtrl
2196 */
2197 REG_INIT(AB8505_VAUX4REQCTRL, 0x04, 0x2d, 0x03),
2198 /*
2199 * 0x03, Vaux4Regu
2200 */
2201 REG_INIT(AB8505_VAUX4REGU, 0x04, 0x2e, 0x03),
2202 /*
2203 * 0x0f, Vaux4Sel
2204 */
2205 REG_INIT(AB8505_VAUX4SEL, 0x04, 0x2f, 0x0f),
2206 /*
2207 * 0x04, Vaux1Disch
2208 * 0x08, Vaux2Disch
2209 * 0x10, Vaux3Disch
2210 * 0x20, Vintcore12Disch
2211 * 0x40, VTVoutDisch
2212 * 0x80, VaudioDisch
2213 */
2214 REG_INIT(AB8505_REGUCTRLDISCH, 0x04, 0x43, 0xfc),
2215 /*
2216 * 0x02, VanaDisch
2217 * 0x04, VdmicPullDownEna
2218 * 0x10, VdmicDisch
2219 */
2220 REG_INIT(AB8505_REGUCTRLDISCH2, 0x04, 0x44, 0x16),
2221 /*
2222 * 0x01, Vaux4Disch
2223 */
2224 REG_INIT(AB8505_REGUCTRLDISCH3, 0x04, 0x48, 0x01),
2225 /*
2226 * 0x07, Vaux5Sel
2227 * 0x08, Vaux5LP
2228 * 0x10, Vaux5Ena
2229 * 0x20, Vaux5Disch
2230 * 0x40, Vaux5DisSfst
2231 * 0x80, Vaux5DisPulld
2232 */
2233 REG_INIT(AB8505_CTRLVAUX5, 0x01, 0x55, 0xff),
2234 /*
2235 * 0x07, Vaux6Sel
2236 * 0x08, Vaux6LP
2237 * 0x10, Vaux6Ena
2238 * 0x80, Vaux6DisPulld
2239 */
2240 REG_INIT(AB8505_CTRLVAUX6, 0x01, 0x56, 0x9f),
2241};
2242
Lee Jones8e6a8d72013-03-28 16:11:11 +00002243/* AB9540 register init */
2244static struct ab8500_reg_init ab9540_reg_init[] = {
2245 /*
2246 * 0x03, VarmRequestCtrl
2247 * 0x0c, VapeRequestCtrl
2248 * 0x30, Vsmps1RequestCtrl
2249 * 0xc0, Vsmps2RequestCtrl
2250 */
2251 REG_INIT(AB9540_REGUREQUESTCTRL1, 0x03, 0x03, 0xff),
2252 /*
2253 * 0x03, Vsmps3RequestCtrl
2254 * 0x0c, VpllRequestCtrl
2255 * 0x30, VanaRequestCtrl
2256 * 0xc0, VextSupply1RequestCtrl
2257 */
2258 REG_INIT(AB9540_REGUREQUESTCTRL2, 0x03, 0x04, 0xff),
2259 /*
2260 * 0x03, VextSupply2RequestCtrl
2261 * 0x0c, VextSupply3RequestCtrl
2262 * 0x30, Vaux1RequestCtrl
2263 * 0xc0, Vaux2RequestCtrl
2264 */
2265 REG_INIT(AB9540_REGUREQUESTCTRL3, 0x03, 0x05, 0xff),
2266 /*
2267 * 0x03, Vaux3RequestCtrl
2268 * 0x04, SwHPReq
2269 */
2270 REG_INIT(AB9540_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
2271 /*
2272 * 0x01, Vsmps1SysClkReq1HPValid
2273 * 0x02, Vsmps2SysClkReq1HPValid
2274 * 0x04, Vsmps3SysClkReq1HPValid
2275 * 0x08, VanaSysClkReq1HPValid
2276 * 0x10, VpllSysClkReq1HPValid
2277 * 0x20, Vaux1SysClkReq1HPValid
2278 * 0x40, Vaux2SysClkReq1HPValid
2279 * 0x80, Vaux3SysClkReq1HPValid
2280 */
2281 REG_INIT(AB9540_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xff),
2282 /*
2283 * 0x01, VapeSysClkReq1HPValid
2284 * 0x02, VarmSysClkReq1HPValid
2285 * 0x04, VbbSysClkReq1HPValid
2286 * 0x08, VmodSysClkReq1HPValid
2287 * 0x10, VextSupply1SysClkReq1HPValid
2288 * 0x20, VextSupply2SysClkReq1HPValid
2289 * 0x40, VextSupply3SysClkReq1HPValid
2290 */
2291 REG_INIT(AB9540_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x7f),
2292 /*
2293 * 0x01, Vsmps1HwHPReq1Valid
2294 * 0x02, Vsmps2HwHPReq1Valid
2295 * 0x04, Vsmps3HwHPReq1Valid
2296 * 0x08, VanaHwHPReq1Valid
2297 * 0x10, VpllHwHPReq1Valid
2298 * 0x20, Vaux1HwHPReq1Valid
2299 * 0x40, Vaux2HwHPReq1Valid
2300 * 0x80, Vaux3HwHPReq1Valid
2301 */
2302 REG_INIT(AB9540_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xff),
2303 /*
2304 * 0x01, VextSupply1HwHPReq1Valid
2305 * 0x02, VextSupply2HwHPReq1Valid
2306 * 0x04, VextSupply3HwHPReq1Valid
2307 * 0x08, VmodHwHPReq1Valid
2308 */
2309 REG_INIT(AB9540_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x0f),
2310 /*
2311 * 0x01, Vsmps1HwHPReq2Valid
2312 * 0x02, Vsmps2HwHPReq2Valid
2313 * 0x03, Vsmps3HwHPReq2Valid
2314 * 0x08, VanaHwHPReq2Valid
2315 * 0x10, VpllHwHPReq2Valid
2316 * 0x20, Vaux1HwHPReq2Valid
2317 * 0x40, Vaux2HwHPReq2Valid
2318 * 0x80, Vaux3HwHPReq2Valid
2319 */
2320 REG_INIT(AB9540_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xff),
2321 /*
2322 * 0x01, VextSupply1HwHPReq2Valid
2323 * 0x02, VextSupply2HwHPReq2Valid
2324 * 0x04, VextSupply3HwHPReq2Valid
2325 * 0x08, VmodHwHPReq2Valid
2326 */
2327 REG_INIT(AB9540_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x0f),
2328 /*
2329 * 0x01, VapeSwHPReqValid
2330 * 0x02, VarmSwHPReqValid
2331 * 0x04, Vsmps1SwHPReqValid
2332 * 0x08, Vsmps2SwHPReqValid
2333 * 0x10, Vsmps3SwHPReqValid
2334 * 0x20, VanaSwHPReqValid
2335 * 0x40, VpllSwHPReqValid
2336 * 0x80, Vaux1SwHPReqValid
2337 */
2338 REG_INIT(AB9540_REGUSWHPREQVALID1, 0x03, 0x0d, 0xff),
2339 /*
2340 * 0x01, Vaux2SwHPReqValid
2341 * 0x02, Vaux3SwHPReqValid
2342 * 0x04, VextSupply1SwHPReqValid
2343 * 0x08, VextSupply2SwHPReqValid
2344 * 0x10, VextSupply3SwHPReqValid
2345 * 0x20, VmodSwHPReqValid
2346 */
2347 REG_INIT(AB9540_REGUSWHPREQVALID2, 0x03, 0x0e, 0x3f),
2348 /*
2349 * 0x02, SysClkReq2Valid1
2350 * ...
2351 * 0x80, SysClkReq8Valid1
2352 */
2353 REG_INIT(AB9540_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0xfe),
2354 /*
2355 * 0x02, SysClkReq2Valid2
2356 * ...
2357 * 0x80, SysClkReq8Valid2
2358 */
2359 REG_INIT(AB9540_REGUSYSCLKREQVALID2, 0x03, 0x10, 0xfe),
2360 /*
2361 * 0x01, Vaux4SwHPReqValid
2362 * 0x02, Vaux4HwHPReq2Valid
2363 * 0x04, Vaux4HwHPReq1Valid
2364 * 0x08, Vaux4SysClkReq1HPValid
2365 */
2366 REG_INIT(AB9540_REGUVAUX4REQVALID, 0x03, 0x11, 0x0f),
2367 /*
2368 * 0x02, VTVoutEna
2369 * 0x04, Vintcore12Ena
2370 * 0x38, Vintcore12Sel
2371 * 0x40, Vintcore12LP
2372 * 0x80, VTVoutLP
2373 */
2374 REG_INIT(AB9540_REGUMISC1, 0x03, 0x80, 0xfe),
2375 /*
2376 * 0x02, VaudioEna
2377 * 0x04, VdmicEna
2378 * 0x08, Vamic1Ena
2379 * 0x10, Vamic2Ena
2380 */
2381 REG_INIT(AB9540_VAUDIOSUPPLY, 0x03, 0x83, 0x1e),
2382 /*
2383 * 0x01, Vamic1_dzout
2384 * 0x02, Vamic2_dzout
2385 */
2386 REG_INIT(AB9540_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
2387 /*
2388 * 0x03, Vsmps1Regu
2389 * 0x0c, Vsmps1SelCtrl
2390 * 0x10, Vsmps1AutoMode
2391 * 0x20, Vsmps1PWMMode
2392 */
2393 REG_INIT(AB9540_VSMPS1REGU, 0x04, 0x03, 0x3f),
2394 /*
2395 * 0x03, Vsmps2Regu
2396 * 0x0c, Vsmps2SelCtrl
2397 * 0x10, Vsmps2AutoMode
2398 * 0x20, Vsmps2PWMMode
2399 */
2400 REG_INIT(AB9540_VSMPS2REGU, 0x04, 0x04, 0x3f),
2401 /*
2402 * 0x03, Vsmps3Regu
2403 * 0x0c, Vsmps3SelCtrl
2404 * NOTE! PRCMU register
2405 */
2406 REG_INIT(AB9540_VSMPS3REGU, 0x04, 0x05, 0x0f),
2407 /*
2408 * 0x03, VpllRegu
2409 * 0x0c, VanaRegu
2410 */
2411 REG_INIT(AB9540_VPLLVANAREGU, 0x04, 0x06, 0x0f),
2412 /*
2413 * 0x03, VextSupply1Regu
2414 * 0x0c, VextSupply2Regu
2415 * 0x30, VextSupply3Regu
2416 * 0x40, ExtSupply2Bypass
2417 * 0x80, ExtSupply3Bypass
2418 */
2419 REG_INIT(AB9540_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
2420 /*
2421 * 0x03, Vaux1Regu
2422 * 0x0c, Vaux2Regu
2423 */
2424 REG_INIT(AB9540_VAUX12REGU, 0x04, 0x09, 0x0f),
2425 /*
2426 * 0x0c, Vrf1Regu
2427 * 0x03, Vaux3Regu
2428 */
2429 REG_INIT(AB9540_VRF1VAUX3REGU, 0x04, 0x0a, 0x0f),
2430 /*
2431 * 0x3f, Vsmps1Sel1
2432 */
2433 REG_INIT(AB9540_VSMPS1SEL1, 0x04, 0x13, 0x3f),
2434 /*
2435 * 0x3f, Vsmps1Sel2
2436 */
2437 REG_INIT(AB9540_VSMPS1SEL2, 0x04, 0x14, 0x3f),
2438 /*
2439 * 0x3f, Vsmps1Sel3
2440 */
2441 REG_INIT(AB9540_VSMPS1SEL3, 0x04, 0x15, 0x3f),
2442 /*
2443 * 0x3f, Vsmps2Sel1
2444 */
2445 REG_INIT(AB9540_VSMPS2SEL1, 0x04, 0x17, 0x3f),
2446 /*
2447 * 0x3f, Vsmps2Sel2
2448 */
2449 REG_INIT(AB9540_VSMPS2SEL2, 0x04, 0x18, 0x3f),
2450 /*
2451 * 0x3f, Vsmps2Sel3
2452 */
2453 REG_INIT(AB9540_VSMPS2SEL3, 0x04, 0x19, 0x3f),
2454 /*
2455 * 0x7f, Vsmps3Sel1
2456 * NOTE! PRCMU register
2457 */
2458 REG_INIT(AB9540_VSMPS3SEL1, 0x04, 0x1b, 0x7f),
2459 /*
2460 * 0x7f, Vsmps3Sel2
2461 * NOTE! PRCMU register
2462 */
2463 REG_INIT(AB9540_VSMPS3SEL2, 0x04, 0x1c, 0x7f),
2464 /*
2465 * 0x0f, Vaux1Sel
2466 */
2467 REG_INIT(AB9540_VAUX1SEL, 0x04, 0x1f, 0x0f),
2468 /*
2469 * 0x0f, Vaux2Sel
2470 */
2471 REG_INIT(AB9540_VAUX2SEL, 0x04, 0x20, 0x0f),
2472 /*
2473 * 0x07, Vaux3Sel
2474 * 0x30, Vrf1Sel
2475 */
2476 REG_INIT(AB9540_VRF1VAUX3SEL, 0x04, 0x21, 0x37),
2477 /*
2478 * 0x01, VextSupply12LP
2479 */
2480 REG_INIT(AB9540_REGUCTRL2SPARE, 0x04, 0x22, 0x01),
2481 /*
2482 * 0x03, Vaux4RequestCtrl
2483 */
2484 REG_INIT(AB9540_VAUX4REQCTRL, 0x04, 0x2d, 0x03),
2485 /*
2486 * 0x03, Vaux4Regu
2487 */
2488 REG_INIT(AB9540_VAUX4REGU, 0x04, 0x2e, 0x03),
2489 /*
2490 * 0x08, Vaux4Sel
2491 */
2492 REG_INIT(AB9540_VAUX4SEL, 0x04, 0x2f, 0x0f),
2493 /*
2494 * 0x01, VpllDisch
2495 * 0x02, Vrf1Disch
2496 * 0x04, Vaux1Disch
2497 * 0x08, Vaux2Disch
2498 * 0x10, Vaux3Disch
2499 * 0x20, Vintcore12Disch
2500 * 0x40, VTVoutDisch
2501 * 0x80, VaudioDisch
2502 */
2503 REG_INIT(AB9540_REGUCTRLDISCH, 0x04, 0x43, 0xff),
2504 /*
2505 * 0x01, VsimDisch
2506 * 0x02, VanaDisch
2507 * 0x04, VdmicPullDownEna
2508 * 0x08, VpllPullDownEna
2509 * 0x10, VdmicDisch
2510 */
2511 REG_INIT(AB9540_REGUCTRLDISCH2, 0x04, 0x44, 0x1f),
2512 /*
2513 * 0x01, Vaux4Disch
2514 */
2515 REG_INIT(AB9540_REGUCTRLDISCH3, 0x04, 0x48, 0x01),
2516};
2517
Lee Jonesae0a9a32013-03-28 16:11:16 +00002518/* AB8540 register init */
2519static struct ab8500_reg_init ab8540_reg_init[] = {
2520 /*
2521 * 0x01, VSimSycClkReq1Valid
2522 * 0x02, VSimSycClkReq2Valid
2523 * 0x04, VSimSycClkReq3Valid
2524 * 0x08, VSimSycClkReq4Valid
2525 * 0x10, VSimSycClkReq5Valid
2526 * 0x20, VSimSycClkReq6Valid
2527 * 0x40, VSimSycClkReq7Valid
2528 * 0x80, VSimSycClkReq8Valid
2529 */
2530 REG_INIT(AB8540_VSIMSYSCLKCTRL, 0x02, 0x33, 0xff),
2531 /*
2532 * 0x03, VarmRequestCtrl
2533 * 0x0c, VapeRequestCtrl
2534 * 0x30, Vsmps1RequestCtrl
2535 * 0xc0, Vsmps2RequestCtrl
2536 */
2537 REG_INIT(AB8540_REGUREQUESTCTRL1, 0x03, 0x03, 0xff),
2538 /*
2539 * 0x03, Vsmps3RequestCtrl
2540 * 0x0c, VpllRequestCtrl
2541 * 0x30, VanaRequestCtrl
2542 * 0xc0, VextSupply1RequestCtrl
2543 */
2544 REG_INIT(AB8540_REGUREQUESTCTRL2, 0x03, 0x04, 0xff),
2545 /*
2546 * 0x03, VextSupply2RequestCtrl
2547 * 0x0c, VextSupply3RequestCtrl
2548 * 0x30, Vaux1RequestCtrl
2549 * 0xc0, Vaux2RequestCtrl
2550 */
2551 REG_INIT(AB8540_REGUREQUESTCTRL3, 0x03, 0x05, 0xff),
2552 /*
2553 * 0x03, Vaux3RequestCtrl
2554 * 0x04, SwHPReq
2555 */
2556 REG_INIT(AB8540_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
2557 /*
2558 * 0x01, Vsmps1SysClkReq1HPValid
2559 * 0x02, Vsmps2SysClkReq1HPValid
2560 * 0x04, Vsmps3SysClkReq1HPValid
2561 * 0x08, VanaSysClkReq1HPValid
2562 * 0x10, VpllSysClkReq1HPValid
2563 * 0x20, Vaux1SysClkReq1HPValid
2564 * 0x40, Vaux2SysClkReq1HPValid
2565 * 0x80, Vaux3SysClkReq1HPValid
2566 */
2567 REG_INIT(AB8540_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xff),
2568 /*
2569 * 0x01, VapeSysClkReq1HPValid
2570 * 0x02, VarmSysClkReq1HPValid
2571 * 0x04, VbbSysClkReq1HPValid
2572 * 0x10, VextSupply1SysClkReq1HPValid
2573 * 0x20, VextSupply2SysClkReq1HPValid
2574 * 0x40, VextSupply3SysClkReq1HPValid
2575 */
2576 REG_INIT(AB8540_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x77),
2577 /*
2578 * 0x01, Vsmps1HwHPReq1Valid
2579 * 0x02, Vsmps2HwHPReq1Valid
2580 * 0x04, Vsmps3HwHPReq1Valid
2581 * 0x08, VanaHwHPReq1Valid
2582 * 0x10, VpllHwHPReq1Valid
2583 * 0x20, Vaux1HwHPReq1Valid
2584 * 0x40, Vaux2HwHPReq1Valid
2585 * 0x80, Vaux3HwHPReq1Valid
2586 */
2587 REG_INIT(AB8540_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xff),
2588 /*
2589 * 0x01, VextSupply1HwHPReq1Valid
2590 * 0x02, VextSupply2HwHPReq1Valid
2591 * 0x04, VextSupply3HwHPReq1Valid
2592 */
2593 REG_INIT(AB8540_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x07),
2594 /*
2595 * 0x01, Vsmps1HwHPReq2Valid
2596 * 0x02, Vsmps2HwHPReq2Valid
2597 * 0x03, Vsmps3HwHPReq2Valid
2598 * 0x08, VanaHwHPReq2Valid
2599 * 0x10, VpllHwHPReq2Valid
2600 * 0x20, Vaux1HwHPReq2Valid
2601 * 0x40, Vaux2HwHPReq2Valid
2602 * 0x80, Vaux3HwHPReq2Valid
2603 */
2604 REG_INIT(AB8540_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xff),
2605 /*
2606 * 0x01, VextSupply1HwHPReq2Valid
2607 * 0x02, VextSupply2HwHPReq2Valid
2608 * 0x04, VextSupply3HwHPReq2Valid
2609 */
2610 REG_INIT(AB8540_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x07),
2611 /*
2612 * 0x01, VapeSwHPReqValid
2613 * 0x02, VarmSwHPReqValid
2614 * 0x04, Vsmps1SwHPReqValid
2615 * 0x08, Vsmps2SwHPReqValid
2616 * 0x10, Vsmps3SwHPReqValid
2617 * 0x20, VanaSwHPReqValid
2618 * 0x40, VpllSwHPReqValid
2619 * 0x80, Vaux1SwHPReqValid
2620 */
2621 REG_INIT(AB8540_REGUSWHPREQVALID1, 0x03, 0x0d, 0xff),
2622 /*
2623 * 0x01, Vaux2SwHPReqValid
2624 * 0x02, Vaux3SwHPReqValid
2625 * 0x04, VextSupply1SwHPReqValid
2626 * 0x08, VextSupply2SwHPReqValid
2627 * 0x10, VextSupply3SwHPReqValid
2628 */
2629 REG_INIT(AB8540_REGUSWHPREQVALID2, 0x03, 0x0e, 0x1f),
2630 /*
2631 * 0x02, SysClkReq2Valid1
2632 * ...
2633 * 0x80, SysClkReq8Valid1
2634 */
2635 REG_INIT(AB8540_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0xff),
2636 /*
2637 * 0x02, SysClkReq2Valid2
2638 * ...
2639 * 0x80, SysClkReq8Valid2
2640 */
2641 REG_INIT(AB8540_REGUSYSCLKREQVALID2, 0x03, 0x10, 0xff),
2642 /*
2643 * 0x01, Vaux4SwHPReqValid
2644 * 0x02, Vaux4HwHPReq2Valid
2645 * 0x04, Vaux4HwHPReq1Valid
2646 * 0x08, Vaux4SysClkReq1HPValid
2647 */
2648 REG_INIT(AB8540_REGUVAUX4REQVALID, 0x03, 0x11, 0x0f),
2649 /*
2650 * 0x01, Vaux5SwHPReqValid
2651 * 0x02, Vaux5HwHPReq2Valid
2652 * 0x04, Vaux5HwHPReq1Valid
2653 * 0x08, Vaux5SysClkReq1HPValid
2654 */
2655 REG_INIT(AB8540_REGUVAUX5REQVALID, 0x03, 0x12, 0x0f),
2656 /*
2657 * 0x01, Vaux6SwHPReqValid
2658 * 0x02, Vaux6HwHPReq2Valid
2659 * 0x04, Vaux6HwHPReq1Valid
2660 * 0x08, Vaux6SysClkReq1HPValid
2661 */
2662 REG_INIT(AB8540_REGUVAUX6REQVALID, 0x03, 0x13, 0x0f),
2663 /*
2664 * 0x01, VclkbSwHPReqValid
2665 * 0x02, VclkbHwHPReq2Valid
2666 * 0x04, VclkbHwHPReq1Valid
2667 * 0x08, VclkbSysClkReq1HPValid
2668 */
2669 REG_INIT(AB8540_REGUVCLKBREQVALID, 0x03, 0x14, 0x0f),
2670 /*
2671 * 0x01, Vrf1SwHPReqValid
2672 * 0x02, Vrf1HwHPReq2Valid
2673 * 0x04, Vrf1HwHPReq1Valid
2674 * 0x08, Vrf1SysClkReq1HPValid
2675 */
2676 REG_INIT(AB8540_REGUVRF1REQVALID, 0x03, 0x15, 0x0f),
2677 /*
2678 * 0x02, VTVoutEna
2679 * 0x04, Vintcore12Ena
2680 * 0x38, Vintcore12Sel
2681 * 0x40, Vintcore12LP
2682 * 0x80, VTVoutLP
2683 */
2684 REG_INIT(AB8540_REGUMISC1, 0x03, 0x80, 0xfe),
2685 /*
2686 * 0x02, VaudioEna
2687 * 0x04, VdmicEna
2688 * 0x08, Vamic1Ena
2689 * 0x10, Vamic2Ena
2690 * 0x20, Vamic12LP
2691 * 0xC0, VdmicSel
2692 */
2693 REG_INIT(AB8540_VAUDIOSUPPLY, 0x03, 0x83, 0xfe),
2694 /*
2695 * 0x01, Vamic1_dzout
2696 * 0x02, Vamic2_dzout
2697 */
2698 REG_INIT(AB8540_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
2699 /*
2700 * 0x07, VHSICSel
2701 * 0x08, VHSICOffState
2702 * 0x10, VHSIEna
2703 * 0x20, VHSICLP
2704 */
2705 REG_INIT(AB8540_VHSIC, 0x03, 0x87, 0x3f),
2706 /*
2707 * 0x07, VSDIOSel
2708 * 0x08, VSDIOOffState
2709 * 0x10, VSDIOEna
2710 * 0x20, VSDIOLP
2711 */
2712 REG_INIT(AB8540_VSDIO, 0x03, 0x88, 0x3f),
2713 /*
2714 * 0x03, Vsmps1Regu
2715 * 0x0c, Vsmps1SelCtrl
2716 * 0x10, Vsmps1AutoMode
2717 * 0x20, Vsmps1PWMMode
2718 */
2719 REG_INIT(AB8540_VSMPS1REGU, 0x04, 0x03, 0x3f),
2720 /*
2721 * 0x03, Vsmps2Regu
2722 * 0x0c, Vsmps2SelCtrl
2723 * 0x10, Vsmps2AutoMode
2724 * 0x20, Vsmps2PWMMode
2725 */
2726 REG_INIT(AB8540_VSMPS2REGU, 0x04, 0x04, 0x3f),
2727 /*
2728 * 0x03, Vsmps3Regu
2729 * 0x0c, Vsmps3SelCtrl
2730 * 0x10, Vsmps3AutoMode
2731 * 0x20, Vsmps3PWMMode
2732 * NOTE! PRCMU register
2733 */
2734 REG_INIT(AB8540_VSMPS3REGU, 0x04, 0x05, 0x0f),
2735 /*
2736 * 0x03, VpllRegu
2737 * 0x0c, VanaRegu
2738 */
2739 REG_INIT(AB8540_VPLLVANAREGU, 0x04, 0x06, 0x0f),
2740 /*
2741 * 0x03, VextSupply1Regu
2742 * 0x0c, VextSupply2Regu
2743 * 0x30, VextSupply3Regu
2744 * 0x40, ExtSupply2Bypass
2745 * 0x80, ExtSupply3Bypass
2746 */
2747 REG_INIT(AB8540_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
2748 /*
2749 * 0x03, Vaux1Regu
2750 * 0x0c, Vaux2Regu
2751 */
2752 REG_INIT(AB8540_VAUX12REGU, 0x04, 0x09, 0x0f),
2753 /*
2754 * 0x0c, VRF1Regu
2755 * 0x03, Vaux3Regu
2756 */
2757 REG_INIT(AB8540_VRF1VAUX3REGU, 0x04, 0x0a, 0x0f),
2758 /*
2759 * 0x3f, Vsmps1Sel1
2760 */
2761 REG_INIT(AB8540_VSMPS1SEL1, 0x04, 0x13, 0x3f),
2762 /*
2763 * 0x3f, Vsmps1Sel2
2764 */
2765 REG_INIT(AB8540_VSMPS1SEL2, 0x04, 0x14, 0x3f),
2766 /*
2767 * 0x3f, Vsmps1Sel3
2768 */
2769 REG_INIT(AB8540_VSMPS1SEL3, 0x04, 0x15, 0x3f),
2770 /*
2771 * 0x3f, Vsmps2Sel1
2772 */
2773 REG_INIT(AB8540_VSMPS2SEL1, 0x04, 0x17, 0x3f),
2774 /*
2775 * 0x3f, Vsmps2Sel2
2776 */
2777 REG_INIT(AB8540_VSMPS2SEL2, 0x04, 0x18, 0x3f),
2778 /*
2779 * 0x3f, Vsmps2Sel3
2780 */
2781 REG_INIT(AB8540_VSMPS2SEL3, 0x04, 0x19, 0x3f),
2782 /*
2783 * 0x7f, Vsmps3Sel1
2784 * NOTE! PRCMU register
2785 */
2786 REG_INIT(AB8540_VSMPS3SEL1, 0x04, 0x1b, 0x7f),
2787 /*
2788 * 0x7f, Vsmps3Sel2
2789 * NOTE! PRCMU register
2790 */
2791 REG_INIT(AB8540_VSMPS3SEL2, 0x04, 0x1c, 0x7f),
2792 /*
2793 * 0x0f, Vaux1Sel
2794 */
2795 REG_INIT(AB8540_VAUX1SEL, 0x04, 0x1f, 0x0f),
2796 /*
2797 * 0x0f, Vaux2Sel
2798 */
2799 REG_INIT(AB8540_VAUX2SEL, 0x04, 0x20, 0x0f),
2800 /*
2801 * 0x07, Vaux3Sel
2802 * 0x70, Vrf1Sel
2803 */
2804 REG_INIT(AB8540_VRF1VAUX3SEL, 0x04, 0x21, 0x77),
2805 /*
2806 * 0x01, VextSupply12LP
2807 */
2808 REG_INIT(AB8540_REGUCTRL2SPARE, 0x04, 0x22, 0x01),
2809 /*
2810 * 0x07, Vanasel
2811 * 0x30, Vpllsel
2812 */
2813 REG_INIT(AB8540_VANAVPLLSEL, 0x04, 0x29, 0x37),
2814 /*
2815 * 0x03, Vaux4RequestCtrl
2816 */
2817 REG_INIT(AB8540_VAUX4REQCTRL, 0x04, 0x2d, 0x03),
2818 /*
2819 * 0x03, Vaux4Regu
2820 */
2821 REG_INIT(AB8540_VAUX4REGU, 0x04, 0x2e, 0x03),
2822 /*
2823 * 0x0f, Vaux4Sel
2824 */
2825 REG_INIT(AB8540_VAUX4SEL, 0x04, 0x2f, 0x0f),
2826 /*
2827 * 0x03, Vaux5RequestCtrl
2828 */
2829 REG_INIT(AB8540_VAUX5REQCTRL, 0x04, 0x31, 0x03),
2830 /*
2831 * 0x03, Vaux5Regu
2832 */
2833 REG_INIT(AB8540_VAUX5REGU, 0x04, 0x32, 0x03),
2834 /*
2835 * 0x3f, Vaux5Sel
2836 */
2837 REG_INIT(AB8540_VAUX5SEL, 0x04, 0x33, 0x3f),
2838 /*
2839 * 0x03, Vaux6RequestCtrl
2840 */
2841 REG_INIT(AB8540_VAUX6REQCTRL, 0x04, 0x34, 0x03),
2842 /*
2843 * 0x03, Vaux6Regu
2844 */
2845 REG_INIT(AB8540_VAUX6REGU, 0x04, 0x35, 0x03),
2846 /*
2847 * 0x3f, Vaux6Sel
2848 */
2849 REG_INIT(AB8540_VAUX6SEL, 0x04, 0x36, 0x3f),
2850 /*
2851 * 0x03, VCLKBRequestCtrl
2852 */
2853 REG_INIT(AB8540_VCLKBREQCTRL, 0x04, 0x37, 0x03),
2854 /*
2855 * 0x03, VCLKBRegu
2856 */
2857 REG_INIT(AB8540_VCLKBREGU, 0x04, 0x38, 0x03),
2858 /*
2859 * 0x07, VCLKBSel
2860 */
2861 REG_INIT(AB8540_VCLKBSEL, 0x04, 0x39, 0x07),
2862 /*
2863 * 0x03, Vrf1RequestCtrl
2864 */
2865 REG_INIT(AB8540_VRF1REQCTRL, 0x04, 0x3a, 0x03),
2866 /*
2867 * 0x01, VpllDisch
2868 * 0x02, Vrf1Disch
2869 * 0x04, Vaux1Disch
2870 * 0x08, Vaux2Disch
2871 * 0x10, Vaux3Disch
2872 * 0x20, Vintcore12Disch
2873 * 0x40, VTVoutDisch
2874 * 0x80, VaudioDisch
2875 */
2876 REG_INIT(AB8540_REGUCTRLDISCH, 0x04, 0x43, 0xff),
2877 /*
2878 * 0x02, VanaDisch
2879 * 0x04, VdmicPullDownEna
2880 * 0x08, VpllPullDownEna
2881 * 0x10, VdmicDisch
2882 */
2883 REG_INIT(AB8540_REGUCTRLDISCH2, 0x04, 0x44, 0x1e),
2884 /*
2885 * 0x01, Vaux4Disch
2886 */
2887 REG_INIT(AB8540_REGUCTRLDISCH3, 0x04, 0x48, 0x01),
2888 /*
2889 * 0x01, Vaux5Disch
2890 * 0x02, Vaux6Disch
2891 * 0x04, VCLKBDisch
2892 */
2893 REG_INIT(AB8540_REGUCTRLDISCH4, 0x04, 0x49, 0x07),
2894};
2895
Lee Jonesda45edc2013-04-02 13:24:20 +01002896static struct of_regulator_match ab8500_regulator_match[] = {
2897 { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB8500_LDO_AUX1, },
2898 { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB8500_LDO_AUX2, },
2899 { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB8500_LDO_AUX3, },
2900 { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB8500_LDO_INTCORE, },
2901 { .name = "ab8500_ldo_tvout", .driver_data = (void *) AB8500_LDO_TVOUT, },
2902 { .name = "ab8500_ldo_audio", .driver_data = (void *) AB8500_LDO_AUDIO, },
2903 { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB8500_LDO_ANAMIC1, },
2904 { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB8500_LDO_ANAMIC2, },
2905 { .name = "ab8500_ldo_dmic", .driver_data = (void *) AB8500_LDO_DMIC, },
2906 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB8500_LDO_ANA, },
2907};
2908
2909static struct of_regulator_match ab8505_regulator_match[] = {
2910 { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB8505_LDO_AUX1, },
2911 { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB8505_LDO_AUX2, },
2912 { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB8505_LDO_AUX3, },
2913 { .name = "ab8500_ldo_aux4", .driver_data = (void *) AB8505_LDO_AUX4, },
2914 { .name = "ab8500_ldo_aux5", .driver_data = (void *) AB8505_LDO_AUX5, },
2915 { .name = "ab8500_ldo_aux6", .driver_data = (void *) AB8505_LDO_AUX6, },
2916 { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB8505_LDO_INTCORE, },
2917 { .name = "ab8500_ldo_adc", .driver_data = (void *) AB8505_LDO_ADC, },
2918 { .name = "ab8500_ldo_audio", .driver_data = (void *) AB8505_LDO_AUDIO, },
2919 { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB8505_LDO_ANAMIC1, },
2920 { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB8505_LDO_ANAMIC2, },
2921 { .name = "ab8500_ldo_aux8", .driver_data = (void *) AB8505_LDO_AUX8, },
2922 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB8505_LDO_ANA, },
2923};
2924
2925static struct of_regulator_match ab8540_regulator_match[] = {
2926 { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB8540_LDO_AUX1, },
2927 { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB8540_LDO_AUX2, },
2928 { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB8540_LDO_AUX3, },
2929 { .name = "ab8500_ldo_aux4", .driver_data = (void *) AB8540_LDO_AUX4, },
2930 { .name = "ab8500_ldo_aux5", .driver_data = (void *) AB8540_LDO_AUX5, },
2931 { .name = "ab8500_ldo_aux6", .driver_data = (void *) AB8540_LDO_AUX6, },
2932 { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB8540_LDO_INTCORE, },
2933 { .name = "ab8500_ldo_tvout", .driver_data = (void *) AB8540_LDO_TVOUT, },
2934 { .name = "ab8500_ldo_audio", .driver_data = (void *) AB8540_LDO_AUDIO, },
2935 { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB8540_LDO_ANAMIC1, },
2936 { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB8540_LDO_ANAMIC2, },
2937 { .name = "ab8500_ldo_dmic", .driver_data = (void *) AB8540_LDO_DMIC, },
2938 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB8540_LDO_ANA, },
2939 { .name = "ab8500_ldo_sdio", .driver_data = (void *) AB8540_LDO_SDIO, },
2940};
2941
2942static struct of_regulator_match ab9540_regulator_match[] = {
2943 { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB9540_LDO_AUX1, },
2944 { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB9540_LDO_AUX2, },
2945 { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB9540_LDO_AUX3, },
2946 { .name = "ab8500_ldo_aux4", .driver_data = (void *) AB9540_LDO_AUX4, },
2947 { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB9540_LDO_INTCORE, },
2948 { .name = "ab8500_ldo_tvout", .driver_data = (void *) AB9540_LDO_TVOUT, },
2949 { .name = "ab8500_ldo_audio", .driver_data = (void *) AB9540_LDO_AUDIO, },
2950 { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB9540_LDO_ANAMIC1, },
2951 { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB9540_LDO_ANAMIC2, },
2952 { .name = "ab8500_ldo_dmic", .driver_data = (void *) AB9540_LDO_DMIC, },
2953 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB9540_LDO_ANA, },
2954};
2955
Lee Jones33aeb492013-04-02 13:24:14 +01002956static struct {
2957 struct ab8500_regulator_info *info;
2958 int info_size;
2959 struct ab8500_reg_init *init;
2960 int init_size;
2961 struct of_regulator_match *match;
2962 int match_size;
2963} abx500_regulator;
2964
Lee Jonesda45edc2013-04-02 13:24:20 +01002965static void abx500_get_regulator_info(struct ab8500 *ab8500)
2966{
2967 if (is_ab9540(ab8500)) {
2968 abx500_regulator.info = ab9540_regulator_info;
2969 abx500_regulator.info_size = ARRAY_SIZE(ab9540_regulator_info);
2970 abx500_regulator.init = ab9540_reg_init;
2971 abx500_regulator.init_size = AB9540_NUM_REGULATOR_REGISTERS;
2972 abx500_regulator.match = ab9540_regulator_match;
2973 abx500_regulator.match_size = ARRAY_SIZE(ab9540_regulator_match);
2974 } else if (is_ab8505(ab8500)) {
2975 abx500_regulator.info = ab8505_regulator_info;
2976 abx500_regulator.info_size = ARRAY_SIZE(ab8505_regulator_info);
2977 abx500_regulator.init = ab8505_reg_init;
2978 abx500_regulator.init_size = AB8505_NUM_REGULATOR_REGISTERS;
2979 abx500_regulator.match = ab8505_regulator_match;
2980 abx500_regulator.match_size = ARRAY_SIZE(ab8505_regulator_match);
2981 } else if (is_ab8540(ab8500)) {
2982 abx500_regulator.info = ab8540_regulator_info;
2983 abx500_regulator.info_size = ARRAY_SIZE(ab8540_regulator_info);
2984 abx500_regulator.init = ab8540_reg_init;
2985 abx500_regulator.init_size = AB8540_NUM_REGULATOR_REGISTERS;
2986 abx500_regulator.match = ab8540_regulator_match;
2987 abx500_regulator.match_size = ARRAY_SIZE(ab8540_regulator_match);
2988 } else {
2989 abx500_regulator.info = ab8500_regulator_info;
2990 abx500_regulator.info_size = ARRAY_SIZE(ab8500_regulator_info);
2991 abx500_regulator.init = ab8500_reg_init;
2992 abx500_regulator.init_size = AB8500_NUM_REGULATOR_REGISTERS;
2993 abx500_regulator.match = ab8500_regulator_match;
2994 abx500_regulator.match_size = ARRAY_SIZE(ab8500_regulator_match);
2995 }
2996}
2997
Lee Jones3c1b8432013-03-21 15:59:01 +00002998static int ab8500_regulator_init_registers(struct platform_device *pdev,
2999 int id, int mask, int value)
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003000{
Lee Jones33aeb492013-04-02 13:24:14 +01003001 struct ab8500_reg_init *reg_init = abx500_regulator.init;
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003002 int err;
3003
Lee Jones3c1b8432013-03-21 15:59:01 +00003004 BUG_ON(value & ~mask);
Lee Jonesb54969a2013-03-28 16:11:10 +00003005 BUG_ON(mask & ~reg_init[id].mask);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003006
Lee Jones3c1b8432013-03-21 15:59:01 +00003007 /* initialize register */
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003008 err = abx500_mask_and_set_register_interruptible(
3009 &pdev->dev,
Lee Jonesb54969a2013-03-28 16:11:10 +00003010 reg_init[id].bank,
3011 reg_init[id].addr,
Lee Jones3c1b8432013-03-21 15:59:01 +00003012 mask, value);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003013 if (err < 0) {
3014 dev_err(&pdev->dev,
3015 "Failed to initialize 0x%02x, 0x%02x.\n",
Lee Jonesb54969a2013-03-28 16:11:10 +00003016 reg_init[id].bank,
3017 reg_init[id].addr);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003018 return err;
3019 }
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003020 dev_vdbg(&pdev->dev,
Lee Jones3c1b8432013-03-21 15:59:01 +00003021 " init: 0x%02x, 0x%02x, 0x%02x, 0x%02x\n",
Lee Jonesb54969a2013-03-28 16:11:10 +00003022 reg_init[id].bank,
3023 reg_init[id].addr,
Lee Jones3c1b8432013-03-21 15:59:01 +00003024 mask, value);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003025
3026 return 0;
3027}
3028
Bill Pembertona5023572012-11-19 13:22:22 -05003029static int ab8500_regulator_register(struct platform_device *pdev,
Lee Jonesb54969a2013-03-28 16:11:10 +00003030 struct regulator_init_data *init_data,
Lee Jonesb54969a2013-03-28 16:11:10 +00003031 int id, struct device_node *np)
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003032{
Lee Jones8e6a8d72013-03-28 16:11:11 +00003033 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003034 struct ab8500_regulator_info *info = NULL;
3035 struct regulator_config config = { };
3036 int err;
3037
3038 /* assign per-regulator data */
Lee Jones33aeb492013-04-02 13:24:14 +01003039 info = &abx500_regulator.info[id];
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003040 info->dev = &pdev->dev;
3041
3042 config.dev = &pdev->dev;
3043 config.init_data = init_data;
3044 config.driver_data = info;
3045 config.of_node = np;
3046
3047 /* fix for hardware before ab8500v2.0 */
Lee Jones8e6a8d72013-03-28 16:11:11 +00003048 if (is_ab8500_1p1_or_earlier(ab8500)) {
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003049 if (info->desc.id == AB8500_LDO_AUX3) {
3050 info->desc.n_voltages =
3051 ARRAY_SIZE(ldo_vauxn_voltages);
Axel Linec1cc4d2012-05-20 10:33:35 +08003052 info->desc.volt_table = ldo_vauxn_voltages;
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003053 info->voltage_mask = 0xf;
3054 }
3055 }
3056
3057 /* register regulator with framework */
3058 info->regulator = regulator_register(&info->desc, &config);
3059 if (IS_ERR(info->regulator)) {
3060 err = PTR_ERR(info->regulator);
3061 dev_err(&pdev->dev, "failed to register regulator %s\n",
3062 info->desc.name);
3063 /* when we fail, un-register all earlier regulators */
3064 while (--id >= 0) {
Lee Jones33aeb492013-04-02 13:24:14 +01003065 info = &abx500_regulator.info[id];
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003066 regulator_unregister(info->regulator);
3067 }
3068 return err;
3069 }
3070
3071 return 0;
3072}
3073
Bill Pembertona5023572012-11-19 13:22:22 -05003074static int
Lee Jonesb54969a2013-03-28 16:11:10 +00003075ab8500_regulator_of_probe(struct platform_device *pdev,
Lee Jonesb54969a2013-03-28 16:11:10 +00003076 struct device_node *np)
Lee Jones3a8334b2012-05-17 14:45:16 +01003077{
Lee Jones33aeb492013-04-02 13:24:14 +01003078 struct of_regulator_match *match = abx500_regulator.match;
Lee Jones3a8334b2012-05-17 14:45:16 +01003079 int err, i;
3080
Lee Jones33aeb492013-04-02 13:24:14 +01003081 for (i = 0; i < abx500_regulator.info_size; i++) {
Lee Jones3a8334b2012-05-17 14:45:16 +01003082 err = ab8500_regulator_register(
Lee Jones33aeb492013-04-02 13:24:14 +01003083 pdev, match[i].init_data, i, match[i].of_node);
Lee Jones3a8334b2012-05-17 14:45:16 +01003084 if (err)
3085 return err;
3086 }
3087
3088 return 0;
3089}
3090
Bill Pembertona5023572012-11-19 13:22:22 -05003091static int ab8500_regulator_probe(struct platform_device *pdev)
Sundar R IYERc789ca22010-07-13 21:48:56 +05303092{
3093 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
Lee Jones3a8334b2012-05-17 14:45:16 +01003094 struct device_node *np = pdev->dev.of_node;
Bengt Jonsson732805a2013-03-21 15:59:03 +00003095 struct ab8500_platform_data *ppdata;
3096 struct ab8500_regulator_platform_data *pdata;
Sundar R IYERc789ca22010-07-13 21:48:56 +05303097 int i, err;
Lee Jonesb54969a2013-03-28 16:11:10 +00003098
Lee Jones33aeb492013-04-02 13:24:14 +01003099 if (!ab8500) {
3100 dev_err(&pdev->dev, "null mfd parent\n");
3101 return -EINVAL;
Lee Jones8e6a8d72013-03-28 16:11:11 +00003102 }
Sundar R IYERc789ca22010-07-13 21:48:56 +05303103
Lee Jones33aeb492013-04-02 13:24:14 +01003104 abx500_get_regulator_info(ab8500);
3105
Lee Jones3a8334b2012-05-17 14:45:16 +01003106 if (np) {
Lee Jones33aeb492013-04-02 13:24:14 +01003107 err = of_regulator_match(&pdev->dev, np,
3108 abx500_regulator.match,
3109 abx500_regulator.match_size);
Lee Jones3a8334b2012-05-17 14:45:16 +01003110 if (err < 0) {
3111 dev_err(&pdev->dev,
3112 "Error parsing regulator init data: %d\n", err);
3113 return err;
3114 }
3115
Lee Jones33aeb492013-04-02 13:24:14 +01003116 err = ab8500_regulator_of_probe(pdev, np);
Lee Jones3a8334b2012-05-17 14:45:16 +01003117 return err;
3118 }
3119
Bengt Jonsson732805a2013-03-21 15:59:03 +00003120 ppdata = dev_get_platdata(ab8500->dev);
3121 if (!ppdata) {
3122 dev_err(&pdev->dev, "null parent pdata\n");
3123 return -EINVAL;
3124 }
3125
3126 pdata = ppdata->regulator;
Bengt Jonssonfc24b422010-12-10 11:08:45 +01003127 if (!pdata) {
3128 dev_err(&pdev->dev, "null pdata\n");
3129 return -EINVAL;
3130 }
Sundar R IYERc789ca22010-07-13 21:48:56 +05303131
Bengt Jonssoncb189b02010-12-10 11:08:40 +01003132 /* make sure the platform data has the correct size */
Lee Jones33aeb492013-04-02 13:24:14 +01003133 if (pdata->num_regulator != abx500_regulator.info_size) {
Bengt Jonsson79568b942011-03-11 11:54:46 +01003134 dev_err(&pdev->dev, "Configuration error: size mismatch.\n");
Bengt Jonssoncb189b02010-12-10 11:08:40 +01003135 return -EINVAL;
3136 }
3137
Lee Jonesda0b0c42013-03-28 16:11:09 +00003138 /* initialize debug (initial state is recorded with this call) */
3139 err = ab8500_regulator_debug_init(pdev);
3140 if (err)
3141 return err;
3142
Bengt Jonsson79568b942011-03-11 11:54:46 +01003143 /* initialize registers */
Bengt Jonsson732805a2013-03-21 15:59:03 +00003144 for (i = 0; i < pdata->num_reg_init; i++) {
Lee Jones3c1b8432013-03-21 15:59:01 +00003145 int id, mask, value;
Bengt Jonsson79568b942011-03-11 11:54:46 +01003146
Bengt Jonsson732805a2013-03-21 15:59:03 +00003147 id = pdata->reg_init[i].id;
3148 mask = pdata->reg_init[i].mask;
3149 value = pdata->reg_init[i].value;
Bengt Jonsson79568b942011-03-11 11:54:46 +01003150
3151 /* check for configuration errors */
Lee Jones33aeb492013-04-02 13:24:14 +01003152 BUG_ON(id >= abx500_regulator.init_size);
Bengt Jonsson79568b942011-03-11 11:54:46 +01003153
Lee Jones33aeb492013-04-02 13:24:14 +01003154 err = ab8500_regulator_init_registers(pdev, id, mask, value);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003155 if (err < 0)
Bengt Jonsson79568b942011-03-11 11:54:46 +01003156 return err;
Bengt Jonsson79568b942011-03-11 11:54:46 +01003157 }
3158
Rabin Vincentf7eae372013-04-02 13:24:08 +01003159 if (!is_ab8505(ab8500)) {
3160 /* register external regulators (before Vaux1, 2 and 3) */
3161 err = ab8500_ext_regulator_init(pdev);
3162 if (err)
3163 return err;
3164 }
Lee Jonesd1a82002013-03-28 16:11:01 +00003165
Sundar R IYERc789ca22010-07-13 21:48:56 +05303166 /* register all regulators */
Lee Jones33aeb492013-04-02 13:24:14 +01003167 for (i = 0; i < abx500_regulator.info_size; i++) {
Lee Jonesb54969a2013-03-28 16:11:10 +00003168 err = ab8500_regulator_register(pdev, &pdata->regulator[i],
Lee Jones33aeb492013-04-02 13:24:14 +01003169 i, NULL);
Axel Lin42e8c812013-04-11 12:05:43 +08003170 if (err < 0) {
3171 if (!is_ab8505(ab8500))
3172 ab8500_ext_regulator_exit(pdev);
Sundar R IYERc789ca22010-07-13 21:48:56 +05303173 return err;
Axel Lin42e8c812013-04-11 12:05:43 +08003174 }
Sundar R IYERc789ca22010-07-13 21:48:56 +05303175 }
3176
3177 return 0;
3178}
3179
Bill Pemberton8dc995f2012-11-19 13:26:10 -05003180static int ab8500_regulator_remove(struct platform_device *pdev)
Sundar R IYERc789ca22010-07-13 21:48:56 +05303181{
Lee Jonesd1a82002013-03-28 16:11:01 +00003182 int i, err;
Lee Jones8e6a8d72013-03-28 16:11:11 +00003183 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
Sundar R IYERc789ca22010-07-13 21:48:56 +05303184
Lee Jones33aeb492013-04-02 13:24:14 +01003185 for (i = 0; i < abx500_regulator.info_size; i++) {
Sundar R IYERc789ca22010-07-13 21:48:56 +05303186 struct ab8500_regulator_info *info = NULL;
Lee Jones33aeb492013-04-02 13:24:14 +01003187 info = &abx500_regulator.info[i];
Bengt Jonsson09aefa12010-12-10 11:08:46 +01003188
3189 dev_vdbg(rdev_get_dev(info->regulator),
3190 "%s-remove\n", info->desc.name);
3191
Sundar R IYERc789ca22010-07-13 21:48:56 +05303192 regulator_unregister(info->regulator);
3193 }
3194
Axel Lin3480c0c2013-04-11 12:04:18 +08003195 /* remove external regulators (after Vaux1, 2 and 3) */
3196 if (!is_ab8505(ab8500))
3197 ab8500_ext_regulator_exit(pdev);
Lee Jonesd1a82002013-03-28 16:11:01 +00003198
Lee Jonesda0b0c42013-03-28 16:11:09 +00003199 /* remove regulator debug */
3200 err = ab8500_regulator_debug_exit(pdev);
3201 if (err)
3202 return err;
3203
Sundar R IYERc789ca22010-07-13 21:48:56 +05303204 return 0;
3205}
3206
3207static struct platform_driver ab8500_regulator_driver = {
3208 .probe = ab8500_regulator_probe,
Bill Pemberton5eb9f2b2012-11-19 13:20:42 -05003209 .remove = ab8500_regulator_remove,
Sundar R IYERc789ca22010-07-13 21:48:56 +05303210 .driver = {
3211 .name = "ab8500-regulator",
3212 .owner = THIS_MODULE,
Sundar R IYERc789ca22010-07-13 21:48:56 +05303213 },
3214};
3215
3216static int __init ab8500_regulator_init(void)
3217{
3218 int ret;
3219
3220 ret = platform_driver_register(&ab8500_regulator_driver);
3221 if (ret != 0)
3222 pr_err("Failed to register ab8500 regulator: %d\n", ret);
3223
3224 return ret;
3225}
3226subsys_initcall(ab8500_regulator_init);
3227
3228static void __exit ab8500_regulator_exit(void)
3229{
3230 platform_driver_unregister(&ab8500_regulator_driver);
3231}
3232module_exit(ab8500_regulator_exit);
3233
3234MODULE_LICENSE("GPL v2");
3235MODULE_AUTHOR("Sundar Iyer <sundar.iyer@stericsson.com>");
Bengt Jonsson732805a2013-03-21 15:59:03 +00003236MODULE_AUTHOR("Bengt Jonsson <bengt.g.jonsson@stericsson.com>");
Lee Jones547f3842013-03-28 16:11:14 +00003237MODULE_AUTHOR("Daniel Willerud <daniel.willerud@stericsson.com>");
Sundar R IYERc789ca22010-07-13 21:48:56 +05303238MODULE_DESCRIPTION("Regulator Driver for ST-Ericsson AB8500 Mixed-Sig PMIC");
3239MODULE_ALIAS("platform:ab8500-regulator");