blob: 279793e26d94ac123028cc683ba34c4622fcd4a8 [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;
Axel Lin0b665062013-04-09 20:17:15 +0800351 u8 bank, reg, mask, val;
352 bool lp_mode_req = false;
Emeric Vigierbd28a152013-03-21 15:58:59 +0000353 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
354
355 if (info == NULL) {
356 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
357 return -EINVAL;
358 }
359
Lee Jones3fe52282013-04-02 13:24:12 +0100360 if (info->mode_mask) {
Lee Jones3fe52282013-04-02 13:24:12 +0100361 bank = info->mode_bank;
362 reg = info->mode_reg;
363 mask = info->mode_mask;
364 } else {
Lee Jones3fe52282013-04-02 13:24:12 +0100365 bank = info->update_bank;
366 reg = info->update_reg;
367 mask = info->update_mask;
368 }
369
Axel Lin0b665062013-04-09 20:17:15 +0800370 if (info->shared_mode)
371 mutex_lock(&shared_mode_mutex);
372
373 switch (mode) {
374 case REGULATOR_MODE_NORMAL:
375 if (info->shared_mode)
376 lp_mode_req = false;
377
378 if (info->mode_mask)
379 val = info->mode_val_normal;
380 else
381 val = info->update_val_normal;
382 break;
383 case REGULATOR_MODE_IDLE:
384 if (info->shared_mode) {
385 struct ab8500_regulator_info *shared_regulator;
386
387 shared_regulator = info->shared_mode->shared_regulator;
388 if (!shared_regulator->shared_mode->lp_mode_req) {
389 /* Other regulator prevent LP mode */
390 info->shared_mode->lp_mode_req = true;
391 goto out_unlock;
392 }
393
394 lp_mode_req = true;
395 }
396
397 if (info->mode_mask)
398 val = info->mode_val_idle;
399 else
400 val = info->update_val_idle;
401 break;
402 default:
403 ret = -EINVAL;
404 goto out_unlock;
405 }
406
407 if (info->mode_mask || ab8500_regulator_is_enabled(rdev)) {
Emeric Vigierbd28a152013-03-21 15:58:59 +0000408 ret = abx500_mask_and_set_register_interruptible(info->dev,
Lee Jones3fe52282013-04-02 13:24:12 +0100409 bank, reg, mask, val);
Axel Linf04adc52013-04-09 20:15:06 +0800410 if (ret < 0) {
Emeric Vigierbd28a152013-03-21 15:58:59 +0000411 dev_err(rdev_get_dev(rdev),
412 "couldn't set regulator mode\n");
Axel Linf04adc52013-04-09 20:15:06 +0800413 goto out_unlock;
414 }
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000415
416 dev_vdbg(rdev_get_dev(rdev),
417 "%s-set_mode (bank, reg, mask, value): "
418 "0x%x, 0x%x, 0x%x, 0x%x\n",
Lee Jones3fe52282013-04-02 13:24:12 +0100419 info->desc.name, bank, reg,
420 mask, val);
Emeric Vigierbd28a152013-03-21 15:58:59 +0000421 }
422
Axel Lin0b665062013-04-09 20:17:15 +0800423 if (!info->mode_mask)
Axel Linf04adc52013-04-09 20:15:06 +0800424 info->update_val = val;
425
Axel Lin0b665062013-04-09 20:17:15 +0800426 if (info->shared_mode)
427 info->shared_mode->lp_mode_req = lp_mode_req;
428
Axel Linf04adc52013-04-09 20:15:06 +0800429out_unlock:
Lee Jones3fe52282013-04-02 13:24:12 +0100430 if (info->shared_mode)
431 mutex_unlock(&shared_mode_mutex);
Axel Lin742a7322013-03-28 17:23:00 +0800432
Lee Jones3fe52282013-04-02 13:24:12 +0100433 return ret;
Emeric Vigierbd28a152013-03-21 15:58:59 +0000434}
435
436static unsigned int ab8500_regulator_get_mode(struct regulator_dev *rdev)
437{
438 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
439 int ret;
Lee Jones3fe52282013-04-02 13:24:12 +0100440 u8 val;
441 u8 val_normal;
442 u8 val_idle;
Emeric Vigierbd28a152013-03-21 15:58:59 +0000443
444 if (info == NULL) {
445 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
446 return -EINVAL;
447 }
448
Lee Jones3fe52282013-04-02 13:24:12 +0100449 /* Need special handling for shared mode */
450 if (info->shared_mode) {
451 if (info->shared_mode->lp_mode_req)
452 return REGULATOR_MODE_IDLE;
453 else
454 return REGULATOR_MODE_NORMAL;
455 }
456
457 if (info->mode_mask) {
458 /* Dedicated register for handling mode */
459 ret = abx500_get_register_interruptible(info->dev,
460 info->mode_bank, info->mode_reg, &val);
461 val = val & info->mode_mask;
462
463 val_normal = info->mode_val_normal;
464 val_idle = info->mode_val_idle;
465 } else {
466 /* Mode register same as enable register */
467 val = info->update_val;
468 val_normal = info->update_val_normal;
469 val_idle = info->update_val_idle;
470 }
471
472 if (val == val_normal)
Emeric Vigierbd28a152013-03-21 15:58:59 +0000473 ret = REGULATOR_MODE_NORMAL;
Lee Jones3fe52282013-04-02 13:24:12 +0100474 else if (val == val_idle)
Emeric Vigierbd28a152013-03-21 15:58:59 +0000475 ret = REGULATOR_MODE_IDLE;
476 else
477 ret = -EINVAL;
478
479 return ret;
480}
481
Axel Lin3bf6e902012-02-24 17:15:45 +0800482static int ab8500_regulator_get_voltage_sel(struct regulator_dev *rdev)
Sundar R IYERc789ca22010-07-13 21:48:56 +0530483{
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100484 int ret, val;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530485 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100486 u8 regval;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530487
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100488 if (info == NULL) {
489 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
Sundar R IYERc789ca22010-07-13 21:48:56 +0530490 return -EINVAL;
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100491 }
Sundar R IYERc789ca22010-07-13 21:48:56 +0530492
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100493 ret = abx500_get_register_interruptible(info->dev,
494 info->voltage_bank, info->voltage_reg, &regval);
Sundar R IYERc789ca22010-07-13 21:48:56 +0530495 if (ret < 0) {
496 dev_err(rdev_get_dev(rdev),
497 "couldn't read voltage reg for regulator\n");
498 return ret;
499 }
500
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100501 dev_vdbg(rdev_get_dev(rdev),
Linus Walleija0a70142012-08-20 18:41:35 +0200502 "%s-get_voltage (bank, reg, mask, shift, value): "
503 "0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n",
504 info->desc.name, info->voltage_bank,
505 info->voltage_reg, info->voltage_mask,
506 info->voltage_shift, regval);
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100507
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100508 val = regval & info->voltage_mask;
Linus Walleija0a70142012-08-20 18:41:35 +0200509 return val >> info->voltage_shift;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530510}
511
Lee Jonesd7607ba2013-04-02 13:24:11 +0100512static int ab8540_aux3_regulator_get_voltage_sel(struct regulator_dev *rdev)
513{
Axel Lin241896c2013-04-10 14:46:20 +0800514 int ret;
Lee Jonesd7607ba2013-04-02 13:24:11 +0100515 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
516 u8 regval, regval_expand;
517
518 if (info == NULL) {
519 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
520 return -EINVAL;
521 }
522
523 ret = abx500_get_register_interruptible(info->dev,
Lee Jonesd7607ba2013-04-02 13:24:11 +0100524 info->expand_register.voltage_bank,
525 info->expand_register.voltage_reg, &regval_expand);
Axel Lin241896c2013-04-10 14:46:20 +0800526 if (ret < 0) {
527 dev_err(rdev_get_dev(rdev),
528 "couldn't read voltage expand reg for regulator\n");
529 return ret;
530 }
Lee Jonesd7607ba2013-04-02 13:24:11 +0100531
Axel Lin241896c2013-04-10 14:46:20 +0800532 dev_vdbg(rdev_get_dev(rdev),
533 "%s-get_voltage expand (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
534 info->desc.name, info->expand_register.voltage_bank,
535 info->expand_register.voltage_reg,
536 info->expand_register.voltage_mask, regval_expand);
537
538 if (regval_expand & info->expand_register.voltage_mask)
539 return info->expand_register.voltage_limit;
540
541 ret = abx500_get_register_interruptible(info->dev,
542 info->voltage_bank, info->voltage_reg, &regval);
Lee Jonesd7607ba2013-04-02 13:24:11 +0100543 if (ret < 0) {
544 dev_err(rdev_get_dev(rdev),
545 "couldn't read voltage reg for regulator\n");
546 return ret;
547 }
548
549 dev_vdbg(rdev_get_dev(rdev),
Axel Lin241896c2013-04-10 14:46:20 +0800550 "%s-get_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
551 info->desc.name, info->voltage_bank, info->voltage_reg,
552 info->voltage_mask, regval);
Lee Jonesd7607ba2013-04-02 13:24:11 +0100553
Axel Lin241896c2013-04-10 14:46:20 +0800554 return (regval & info->voltage_mask) >> info->voltage_shift;
Lee Jonesd7607ba2013-04-02 13:24:11 +0100555}
556
Axel Linae713d32012-03-20 09:51:08 +0800557static int ab8500_regulator_set_voltage_sel(struct regulator_dev *rdev,
558 unsigned selector)
Sundar R IYERc789ca22010-07-13 21:48:56 +0530559{
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100560 int ret;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530561 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100562 u8 regval;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530563
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100564 if (info == NULL) {
565 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
Sundar R IYERc789ca22010-07-13 21:48:56 +0530566 return -EINVAL;
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100567 }
Sundar R IYERc789ca22010-07-13 21:48:56 +0530568
Sundar R IYERc789ca22010-07-13 21:48:56 +0530569 /* set the registers for the request */
Linus Walleija0a70142012-08-20 18:41:35 +0200570 regval = (u8)selector << info->voltage_shift;
Mattias Wallin47c16972010-09-10 17:47:56 +0200571 ret = abx500_mask_and_set_register_interruptible(info->dev,
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100572 info->voltage_bank, info->voltage_reg,
573 info->voltage_mask, regval);
Sundar R IYERc789ca22010-07-13 21:48:56 +0530574 if (ret < 0)
575 dev_err(rdev_get_dev(rdev),
576 "couldn't set voltage reg for regulator\n");
577
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100578 dev_vdbg(rdev_get_dev(rdev),
579 "%s-set_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
580 " 0x%x\n",
581 info->desc.name, info->voltage_bank, info->voltage_reg,
582 info->voltage_mask, regval);
583
Sundar R IYERc789ca22010-07-13 21:48:56 +0530584 return ret;
585}
586
Lee Jonesd7607ba2013-04-02 13:24:11 +0100587static int ab8540_aux3_regulator_set_voltage_sel(struct regulator_dev *rdev,
588 unsigned selector)
589{
590 int ret;
591 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
Axel Linb4d12a72013-04-17 00:50:20 +0800592 u8 regval, regval_expand;
Lee Jonesd7607ba2013-04-02 13:24:11 +0100593
594 if (info == NULL) {
595 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
596 return -EINVAL;
597 }
598
Axel Linb4d12a72013-04-17 00:50:20 +0800599 if (selector < info->expand_register.voltage_limit) {
Lee Jonesd7607ba2013-04-02 13:24:11 +0100600 regval = (u8)selector << info->voltage_shift;
601 ret = abx500_mask_and_set_register_interruptible(info->dev,
Axel Linb4d12a72013-04-17 00:50:20 +0800602 info->voltage_bank, info->voltage_reg,
603 info->voltage_mask, regval);
604 if (ret < 0) {
605 dev_err(rdev_get_dev(rdev),
606 "couldn't set voltage reg for regulator\n");
607 return ret;
608 }
609
610 dev_vdbg(rdev_get_dev(rdev),
611 "%s-set_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
612 info->desc.name, info->voltage_bank, info->voltage_reg,
613 info->voltage_mask, regval);
614
615 regval_expand = 0;
616 } else {
617 regval_expand = info->expand_register.voltage_mask;
Lee Jonesd7607ba2013-04-02 13:24:11 +0100618 }
Axel Linb4d12a72013-04-17 00:50:20 +0800619
620 ret = abx500_mask_and_set_register_interruptible(info->dev,
621 info->expand_register.voltage_bank,
622 info->expand_register.voltage_reg,
623 info->expand_register.voltage_mask,
624 regval_expand);
625 if (ret < 0) {
Lee Jonesd7607ba2013-04-02 13:24:11 +0100626 dev_err(rdev_get_dev(rdev),
Axel Linb4d12a72013-04-17 00:50:20 +0800627 "couldn't set expand voltage reg for regulator\n");
628 return ret;
629 }
Lee Jonesd7607ba2013-04-02 13:24:11 +0100630
631 dev_vdbg(rdev_get_dev(rdev),
Axel Linb4d12a72013-04-17 00:50:20 +0800632 "%s-set_voltage expand (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
633 info->desc.name, info->expand_register.voltage_bank,
634 info->expand_register.voltage_reg,
635 info->expand_register.voltage_mask, regval_expand);
Lee Jonesd7607ba2013-04-02 13:24:11 +0100636
Axel Linb4d12a72013-04-17 00:50:20 +0800637 return 0;
Lee Jonesd7607ba2013-04-02 13:24:11 +0100638}
639
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000640static struct regulator_ops ab8500_regulator_volt_mode_ops = {
641 .enable = ab8500_regulator_enable,
642 .disable = ab8500_regulator_disable,
643 .is_enabled = ab8500_regulator_is_enabled,
644 .get_optimum_mode = ab8500_regulator_get_optimum_mode,
645 .set_mode = ab8500_regulator_set_mode,
646 .get_mode = ab8500_regulator_get_mode,
647 .get_voltage_sel = ab8500_regulator_get_voltage_sel,
648 .set_voltage_sel = ab8500_regulator_set_voltage_sel,
649 .list_voltage = regulator_list_voltage_table,
Sundar R IYERc789ca22010-07-13 21:48:56 +0530650};
651
Lee Jonesd7607ba2013-04-02 13:24:11 +0100652static struct regulator_ops ab8540_aux3_regulator_volt_mode_ops = {
653 .enable = ab8500_regulator_enable,
654 .disable = ab8500_regulator_disable,
655 .get_optimum_mode = ab8500_regulator_get_optimum_mode,
656 .set_mode = ab8500_regulator_set_mode,
657 .get_mode = ab8500_regulator_get_mode,
658 .is_enabled = ab8500_regulator_is_enabled,
659 .get_voltage_sel = ab8540_aux3_regulator_get_voltage_sel,
660 .set_voltage_sel = ab8540_aux3_regulator_set_voltage_sel,
661 .list_voltage = regulator_list_voltage_table,
Lee Jonesd7607ba2013-04-02 13:24:11 +0100662};
663
Lee Jones8a3b1b82013-04-02 13:24:09 +0100664static struct regulator_ops ab8500_regulator_volt_ops = {
665 .enable = ab8500_regulator_enable,
666 .disable = ab8500_regulator_disable,
667 .is_enabled = ab8500_regulator_is_enabled,
668 .get_voltage_sel = ab8500_regulator_get_voltage_sel,
669 .set_voltage_sel = ab8500_regulator_set_voltage_sel,
670 .list_voltage = regulator_list_voltage_table,
Lee Jones8a3b1b82013-04-02 13:24:09 +0100671};
672
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000673static struct regulator_ops ab8500_regulator_mode_ops = {
674 .enable = ab8500_regulator_enable,
675 .disable = ab8500_regulator_disable,
676 .is_enabled = ab8500_regulator_is_enabled,
677 .get_optimum_mode = ab8500_regulator_get_optimum_mode,
678 .set_mode = ab8500_regulator_set_mode,
679 .get_mode = ab8500_regulator_get_mode,
Axel Lind7816ab2013-04-02 13:24:22 +0100680 .list_voltage = regulator_list_voltage_table,
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000681};
682
683static struct regulator_ops ab8500_regulator_ops = {
684 .enable = ab8500_regulator_enable,
685 .disable = ab8500_regulator_disable,
686 .is_enabled = ab8500_regulator_is_enabled,
Axel Lind7816ab2013-04-02 13:24:22 +0100687 .list_voltage = regulator_list_voltage_table,
Sundar R IYERc789ca22010-07-13 21:48:56 +0530688};
689
Lee Jones3fe52282013-04-02 13:24:12 +0100690static struct regulator_ops ab8500_regulator_anamic_mode_ops = {
691 .enable = ab8500_regulator_enable,
692 .disable = ab8500_regulator_disable,
693 .is_enabled = ab8500_regulator_is_enabled,
694 .set_mode = ab8500_regulator_set_mode,
695 .get_mode = ab8500_regulator_get_mode,
696 .list_voltage = regulator_list_voltage_table,
697};
698
Lee Jones8e6a8d72013-03-28 16:11:11 +0000699/* AB8500 regulator information */
Bengt Jonsson6909b452010-12-10 11:08:47 +0100700static struct ab8500_regulator_info
701 ab8500_regulator_info[AB8500_NUM_REGULATORS] = {
Sundar R IYERc789ca22010-07-13 21:48:56 +0530702 /*
Bengt Jonssone1159e62010-12-10 11:08:44 +0100703 * Variable Voltage Regulators
704 * name, min mV, max mV,
705 * update bank, reg, mask, enable val
Axel Linec1cc4d2012-05-20 10:33:35 +0800706 * volt bank, reg, mask
Sundar R IYERc789ca22010-07-13 21:48:56 +0530707 */
Bengt Jonsson6909b452010-12-10 11:08:47 +0100708 [AB8500_LDO_AUX1] = {
709 .desc = {
710 .name = "LDO-AUX1",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000711 .ops = &ab8500_regulator_volt_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100712 .type = REGULATOR_VOLTAGE,
713 .id = AB8500_LDO_AUX1,
714 .owner = THIS_MODULE,
715 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Axel Linec1cc4d2012-05-20 10:33:35 +0800716 .volt_table = ldo_vauxn_voltages,
Axel Lin530158b2013-03-27 17:47:22 +0800717 .enable_time = 200,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100718 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000719 .load_lp_uA = 5000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100720 .update_bank = 0x04,
721 .update_reg = 0x09,
722 .update_mask = 0x03,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000723 .update_val = 0x01,
724 .update_val_idle = 0x03,
725 .update_val_normal = 0x01,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100726 .voltage_bank = 0x04,
727 .voltage_reg = 0x1f,
728 .voltage_mask = 0x0f,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100729 },
730 [AB8500_LDO_AUX2] = {
731 .desc = {
732 .name = "LDO-AUX2",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000733 .ops = &ab8500_regulator_volt_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100734 .type = REGULATOR_VOLTAGE,
735 .id = AB8500_LDO_AUX2,
736 .owner = THIS_MODULE,
737 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Axel Linec1cc4d2012-05-20 10:33:35 +0800738 .volt_table = ldo_vauxn_voltages,
Axel Lin530158b2013-03-27 17:47:22 +0800739 .enable_time = 200,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100740 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000741 .load_lp_uA = 5000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100742 .update_bank = 0x04,
743 .update_reg = 0x09,
744 .update_mask = 0x0c,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000745 .update_val = 0x04,
746 .update_val_idle = 0x0c,
747 .update_val_normal = 0x04,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100748 .voltage_bank = 0x04,
749 .voltage_reg = 0x20,
750 .voltage_mask = 0x0f,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100751 },
752 [AB8500_LDO_AUX3] = {
753 .desc = {
754 .name = "LDO-AUX3",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000755 .ops = &ab8500_regulator_volt_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100756 .type = REGULATOR_VOLTAGE,
757 .id = AB8500_LDO_AUX3,
758 .owner = THIS_MODULE,
759 .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages),
Axel Linec1cc4d2012-05-20 10:33:35 +0800760 .volt_table = ldo_vaux3_voltages,
Axel Lin530158b2013-03-27 17:47:22 +0800761 .enable_time = 450,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100762 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000763 .load_lp_uA = 5000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100764 .update_bank = 0x04,
765 .update_reg = 0x0a,
766 .update_mask = 0x03,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000767 .update_val = 0x01,
768 .update_val_idle = 0x03,
769 .update_val_normal = 0x01,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100770 .voltage_bank = 0x04,
771 .voltage_reg = 0x21,
772 .voltage_mask = 0x07,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100773 },
774 [AB8500_LDO_INTCORE] = {
775 .desc = {
776 .name = "LDO-INTCORE",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000777 .ops = &ab8500_regulator_volt_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100778 .type = REGULATOR_VOLTAGE,
779 .id = AB8500_LDO_INTCORE,
780 .owner = THIS_MODULE,
781 .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
Axel Linec1cc4d2012-05-20 10:33:35 +0800782 .volt_table = ldo_vintcore_voltages,
Axel Lin530158b2013-03-27 17:47:22 +0800783 .enable_time = 750,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100784 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000785 .load_lp_uA = 5000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100786 .update_bank = 0x03,
787 .update_reg = 0x80,
788 .update_mask = 0x44,
Lee Jonescc40dc22013-03-21 15:59:41 +0000789 .update_val = 0x44,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000790 .update_val_idle = 0x44,
791 .update_val_normal = 0x04,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100792 .voltage_bank = 0x03,
793 .voltage_reg = 0x80,
794 .voltage_mask = 0x38,
Linus Walleija0a70142012-08-20 18:41:35 +0200795 .voltage_shift = 3,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100796 },
Sundar R IYERc789ca22010-07-13 21:48:56 +0530797
798 /*
Bengt Jonssone1159e62010-12-10 11:08:44 +0100799 * Fixed Voltage Regulators
800 * name, fixed mV,
801 * update bank, reg, mask, enable val
Sundar R IYERc789ca22010-07-13 21:48:56 +0530802 */
Bengt Jonsson6909b452010-12-10 11:08:47 +0100803 [AB8500_LDO_TVOUT] = {
804 .desc = {
805 .name = "LDO-TVOUT",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000806 .ops = &ab8500_regulator_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100807 .type = REGULATOR_VOLTAGE,
808 .id = AB8500_LDO_TVOUT,
809 .owner = THIS_MODULE,
810 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +0000811 .volt_table = fixed_2000000_voltage,
Lee Jonesed3c1382013-03-28 16:11:12 +0000812 .enable_time = 500,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100813 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000814 .load_lp_uA = 1000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100815 .update_bank = 0x03,
816 .update_reg = 0x80,
817 .update_mask = 0x82,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000818 .update_val = 0x02,
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000819 .update_val_idle = 0x82,
820 .update_val_normal = 0x02,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100821 },
822 [AB8500_LDO_AUDIO] = {
823 .desc = {
824 .name = "LDO-AUDIO",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000825 .ops = &ab8500_regulator_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100826 .type = REGULATOR_VOLTAGE,
827 .id = AB8500_LDO_AUDIO,
828 .owner = THIS_MODULE,
829 .n_voltages = 1,
Axel Lin530158b2013-03-27 17:47:22 +0800830 .enable_time = 140,
Lee Jonesb080c782013-03-28 16:11:17 +0000831 .volt_table = fixed_2000000_voltage,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100832 },
Bengt Jonsson6909b452010-12-10 11:08:47 +0100833 .update_bank = 0x03,
834 .update_reg = 0x83,
835 .update_mask = 0x02,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000836 .update_val = 0x02,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100837 },
838 [AB8500_LDO_ANAMIC1] = {
839 .desc = {
840 .name = "LDO-ANAMIC1",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000841 .ops = &ab8500_regulator_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100842 .type = REGULATOR_VOLTAGE,
843 .id = AB8500_LDO_ANAMIC1,
844 .owner = THIS_MODULE,
845 .n_voltages = 1,
Axel Lin530158b2013-03-27 17:47:22 +0800846 .enable_time = 500,
Lee Jonesb080c782013-03-28 16:11:17 +0000847 .volt_table = fixed_2050000_voltage,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100848 },
Bengt Jonsson6909b452010-12-10 11:08:47 +0100849 .update_bank = 0x03,
850 .update_reg = 0x83,
851 .update_mask = 0x08,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000852 .update_val = 0x08,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100853 },
854 [AB8500_LDO_ANAMIC2] = {
855 .desc = {
856 .name = "LDO-ANAMIC2",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000857 .ops = &ab8500_regulator_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100858 .type = REGULATOR_VOLTAGE,
859 .id = AB8500_LDO_ANAMIC2,
860 .owner = THIS_MODULE,
861 .n_voltages = 1,
Axel Lin530158b2013-03-27 17:47:22 +0800862 .enable_time = 500,
Lee Jonesb080c782013-03-28 16:11:17 +0000863 .volt_table = fixed_2050000_voltage,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100864 },
Bengt Jonsson6909b452010-12-10 11:08:47 +0100865 .update_bank = 0x03,
866 .update_reg = 0x83,
867 .update_mask = 0x10,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000868 .update_val = 0x10,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100869 },
870 [AB8500_LDO_DMIC] = {
871 .desc = {
872 .name = "LDO-DMIC",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000873 .ops = &ab8500_regulator_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100874 .type = REGULATOR_VOLTAGE,
875 .id = AB8500_LDO_DMIC,
876 .owner = THIS_MODULE,
877 .n_voltages = 1,
Axel Lin530158b2013-03-27 17:47:22 +0800878 .enable_time = 420,
Lee Jonesb080c782013-03-28 16:11:17 +0000879 .volt_table = fixed_1800000_voltage,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100880 },
Bengt Jonsson6909b452010-12-10 11:08:47 +0100881 .update_bank = 0x03,
882 .update_reg = 0x83,
883 .update_mask = 0x04,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000884 .update_val = 0x04,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100885 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000886
887 /*
888 * Regulators with fixed voltage and normal/idle modes
889 */
Bengt Jonsson6909b452010-12-10 11:08:47 +0100890 [AB8500_LDO_ANA] = {
891 .desc = {
892 .name = "LDO-ANA",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000893 .ops = &ab8500_regulator_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100894 .type = REGULATOR_VOLTAGE,
895 .id = AB8500_LDO_ANA,
896 .owner = THIS_MODULE,
897 .n_voltages = 1,
Axel Lin530158b2013-03-27 17:47:22 +0800898 .enable_time = 140,
Lee Jonesb080c782013-03-28 16:11:17 +0000899 .volt_table = fixed_1200000_voltage,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100900 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000901 .load_lp_uA = 1000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100902 .update_bank = 0x04,
903 .update_reg = 0x06,
904 .update_mask = 0x0c,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000905 .update_val = 0x04,
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000906 .update_val_idle = 0x0c,
907 .update_val_normal = 0x04,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100908 },
Lee Jones8e6a8d72013-03-28 16:11:11 +0000909};
Bengt Jonsson6909b452010-12-10 11:08:47 +0100910
Lee Jones547f3842013-03-28 16:11:14 +0000911/* AB8505 regulator information */
912static struct ab8500_regulator_info
913 ab8505_regulator_info[AB8505_NUM_REGULATORS] = {
914 /*
915 * Variable Voltage Regulators
916 * name, min mV, max mV,
917 * update bank, reg, mask, enable val
Lee Jonesd3193102013-04-02 13:24:18 +0100918 * volt bank, reg, mask
Lee Jones547f3842013-03-28 16:11:14 +0000919 */
920 [AB8505_LDO_AUX1] = {
921 .desc = {
922 .name = "LDO-AUX1",
923 .ops = &ab8500_regulator_volt_mode_ops,
924 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +0100925 .id = AB8505_LDO_AUX1,
Lee Jones547f3842013-03-28 16:11:14 +0000926 .owner = THIS_MODULE,
927 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +0000928 .volt_table = ldo_vauxn_voltages,
Lee Jones547f3842013-03-28 16:11:14 +0000929 },
Lee Jones547f3842013-03-28 16:11:14 +0000930 .load_lp_uA = 5000,
931 .update_bank = 0x04,
932 .update_reg = 0x09,
933 .update_mask = 0x03,
934 .update_val = 0x01,
935 .update_val_idle = 0x03,
936 .update_val_normal = 0x01,
937 .voltage_bank = 0x04,
938 .voltage_reg = 0x1f,
939 .voltage_mask = 0x0f,
Lee Jones547f3842013-03-28 16:11:14 +0000940 },
941 [AB8505_LDO_AUX2] = {
942 .desc = {
943 .name = "LDO-AUX2",
944 .ops = &ab8500_regulator_volt_mode_ops,
945 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +0100946 .id = AB8505_LDO_AUX2,
Lee Jones547f3842013-03-28 16:11:14 +0000947 .owner = THIS_MODULE,
948 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +0000949 .volt_table = ldo_vauxn_voltages,
Lee Jones547f3842013-03-28 16:11:14 +0000950 },
Lee Jones547f3842013-03-28 16:11:14 +0000951 .load_lp_uA = 5000,
952 .update_bank = 0x04,
953 .update_reg = 0x09,
954 .update_mask = 0x0c,
955 .update_val = 0x04,
956 .update_val_idle = 0x0c,
957 .update_val_normal = 0x04,
958 .voltage_bank = 0x04,
959 .voltage_reg = 0x20,
960 .voltage_mask = 0x0f,
Lee Jones547f3842013-03-28 16:11:14 +0000961 },
962 [AB8505_LDO_AUX3] = {
963 .desc = {
964 .name = "LDO-AUX3",
965 .ops = &ab8500_regulator_volt_mode_ops,
966 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +0100967 .id = AB8505_LDO_AUX3,
Lee Jones547f3842013-03-28 16:11:14 +0000968 .owner = THIS_MODULE,
969 .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +0000970 .volt_table = ldo_vaux3_voltages,
Lee Jones547f3842013-03-28 16:11:14 +0000971 },
Lee Jones547f3842013-03-28 16:11:14 +0000972 .load_lp_uA = 5000,
973 .update_bank = 0x04,
974 .update_reg = 0x0a,
975 .update_mask = 0x03,
976 .update_val = 0x01,
977 .update_val_idle = 0x03,
978 .update_val_normal = 0x01,
979 .voltage_bank = 0x04,
980 .voltage_reg = 0x21,
981 .voltage_mask = 0x07,
Lee Jones547f3842013-03-28 16:11:14 +0000982 },
983 [AB8505_LDO_AUX4] = {
984 .desc = {
985 .name = "LDO-AUX4",
986 .ops = &ab8500_regulator_volt_mode_ops,
987 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +0100988 .id = AB8505_LDO_AUX4,
Lee Jones547f3842013-03-28 16:11:14 +0000989 .owner = THIS_MODULE,
990 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +0000991 .volt_table = ldo_vauxn_voltages,
Lee Jones547f3842013-03-28 16:11:14 +0000992 },
Lee Jones547f3842013-03-28 16:11:14 +0000993 .load_lp_uA = 5000,
994 /* values for Vaux4Regu register */
995 .update_bank = 0x04,
996 .update_reg = 0x2e,
997 .update_mask = 0x03,
998 .update_val = 0x01,
999 .update_val_idle = 0x03,
1000 .update_val_normal = 0x01,
1001 /* values for Vaux4SEL register */
1002 .voltage_bank = 0x04,
1003 .voltage_reg = 0x2f,
1004 .voltage_mask = 0x0f,
Lee Jones547f3842013-03-28 16:11:14 +00001005 },
1006 [AB8505_LDO_AUX5] = {
1007 .desc = {
1008 .name = "LDO-AUX5",
1009 .ops = &ab8500_regulator_volt_mode_ops,
1010 .type = REGULATOR_VOLTAGE,
1011 .id = AB8505_LDO_AUX5,
1012 .owner = THIS_MODULE,
1013 .n_voltages = ARRAY_SIZE(ldo_vaux56_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001014 .volt_table = ldo_vaux56_voltages,
Lee Jones547f3842013-03-28 16:11:14 +00001015 },
Lee Jones547f3842013-03-28 16:11:14 +00001016 .load_lp_uA = 2000,
1017 /* values for CtrlVaux5 register */
1018 .update_bank = 0x01,
1019 .update_reg = 0x55,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001020 .update_mask = 0x18,
1021 .update_val = 0x10,
1022 .update_val_idle = 0x18,
1023 .update_val_normal = 0x10,
Lee Jones547f3842013-03-28 16:11:14 +00001024 .voltage_bank = 0x01,
1025 .voltage_reg = 0x55,
1026 .voltage_mask = 0x07,
Lee Jones547f3842013-03-28 16:11:14 +00001027 },
1028 [AB8505_LDO_AUX6] = {
1029 .desc = {
1030 .name = "LDO-AUX6",
1031 .ops = &ab8500_regulator_volt_mode_ops,
1032 .type = REGULATOR_VOLTAGE,
1033 .id = AB8505_LDO_AUX6,
1034 .owner = THIS_MODULE,
1035 .n_voltages = ARRAY_SIZE(ldo_vaux56_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001036 .volt_table = ldo_vaux56_voltages,
Lee Jones547f3842013-03-28 16:11:14 +00001037 },
Lee Jones547f3842013-03-28 16:11:14 +00001038 .load_lp_uA = 2000,
1039 /* values for CtrlVaux6 register */
1040 .update_bank = 0x01,
1041 .update_reg = 0x56,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001042 .update_mask = 0x18,
1043 .update_val = 0x10,
1044 .update_val_idle = 0x18,
1045 .update_val_normal = 0x10,
Lee Jones547f3842013-03-28 16:11:14 +00001046 .voltage_bank = 0x01,
1047 .voltage_reg = 0x56,
1048 .voltage_mask = 0x07,
Lee Jones547f3842013-03-28 16:11:14 +00001049 },
1050 [AB8505_LDO_INTCORE] = {
1051 .desc = {
1052 .name = "LDO-INTCORE",
1053 .ops = &ab8500_regulator_volt_mode_ops,
1054 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001055 .id = AB8505_LDO_INTCORE,
Lee Jones547f3842013-03-28 16:11:14 +00001056 .owner = THIS_MODULE,
1057 .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001058 .volt_table = ldo_vintcore_voltages,
Lee Jones547f3842013-03-28 16:11:14 +00001059 },
Lee Jones547f3842013-03-28 16:11:14 +00001060 .load_lp_uA = 5000,
1061 .update_bank = 0x03,
1062 .update_reg = 0x80,
1063 .update_mask = 0x44,
1064 .update_val = 0x04,
1065 .update_val_idle = 0x44,
1066 .update_val_normal = 0x04,
1067 .voltage_bank = 0x03,
1068 .voltage_reg = 0x80,
1069 .voltage_mask = 0x38,
Lee Jones547f3842013-03-28 16:11:14 +00001070 .voltage_shift = 3,
1071 },
1072
1073 /*
1074 * Fixed Voltage Regulators
1075 * name, fixed mV,
1076 * update bank, reg, mask, enable val
1077 */
1078 [AB8505_LDO_ADC] = {
1079 .desc = {
1080 .name = "LDO-ADC",
1081 .ops = &ab8500_regulator_mode_ops,
1082 .type = REGULATOR_VOLTAGE,
1083 .id = AB8505_LDO_ADC,
1084 .owner = THIS_MODULE,
1085 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001086 .volt_table = fixed_2000000_voltage,
Lee Jonesa4d68462013-04-02 13:24:16 +01001087 .enable_time = 10000,
Lee Jones547f3842013-03-28 16:11:14 +00001088 },
Lee Jones547f3842013-03-28 16:11:14 +00001089 .load_lp_uA = 1000,
1090 .update_bank = 0x03,
1091 .update_reg = 0x80,
1092 .update_mask = 0x82,
1093 .update_val = 0x02,
1094 .update_val_idle = 0x82,
1095 .update_val_normal = 0x02,
1096 },
1097 [AB8505_LDO_USB] = {
1098 .desc = {
1099 .name = "LDO-USB",
1100 .ops = &ab8500_regulator_mode_ops,
1101 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001102 .id = AB8505_LDO_USB,
Lee Jones547f3842013-03-28 16:11:14 +00001103 .owner = THIS_MODULE,
1104 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001105 .volt_table = fixed_3300000_voltage,
Lee Jones547f3842013-03-28 16:11:14 +00001106 },
Lee Jones547f3842013-03-28 16:11:14 +00001107 .update_bank = 0x03,
1108 .update_reg = 0x82,
1109 .update_mask = 0x03,
1110 .update_val = 0x01,
1111 .update_val_idle = 0x03,
1112 .update_val_normal = 0x01,
1113 },
1114 [AB8505_LDO_AUDIO] = {
1115 .desc = {
1116 .name = "LDO-AUDIO",
Lee Jones8a3b1b82013-04-02 13:24:09 +01001117 .ops = &ab8500_regulator_volt_ops,
Lee Jones547f3842013-03-28 16:11:14 +00001118 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001119 .id = AB8505_LDO_AUDIO,
Lee Jones547f3842013-03-28 16:11:14 +00001120 .owner = THIS_MODULE,
Lee Jones8a3b1b82013-04-02 13:24:09 +01001121 .n_voltages = ARRAY_SIZE(ldo_vaudio_voltages),
1122 .volt_table = ldo_vaudio_voltages,
Lee Jones547f3842013-03-28 16:11:14 +00001123 },
Lee Jones547f3842013-03-28 16:11:14 +00001124 .update_bank = 0x03,
1125 .update_reg = 0x83,
1126 .update_mask = 0x02,
1127 .update_val = 0x02,
Lee Jones8a3b1b82013-04-02 13:24:09 +01001128 .voltage_bank = 0x01,
1129 .voltage_reg = 0x57,
Axel Line4fc9d62013-04-12 15:33:25 +08001130 .voltage_mask = 0x70,
Lee Jones8a3b1b82013-04-02 13:24:09 +01001131 .voltage_shift = 4,
Lee Jones547f3842013-03-28 16:11:14 +00001132 },
1133 [AB8505_LDO_ANAMIC1] = {
1134 .desc = {
1135 .name = "LDO-ANAMIC1",
Lee Jones3fe52282013-04-02 13:24:12 +01001136 .ops = &ab8500_regulator_anamic_mode_ops,
Lee Jones547f3842013-03-28 16:11:14 +00001137 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001138 .id = AB8505_LDO_ANAMIC1,
Lee Jones547f3842013-03-28 16:11:14 +00001139 .owner = THIS_MODULE,
1140 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001141 .volt_table = fixed_2050000_voltage,
Lee Jones547f3842013-03-28 16:11:14 +00001142 },
Lee Jones4c84b4d2013-04-02 13:24:13 +01001143 .shared_mode = &ldo_anamic1_shared,
Lee Jones547f3842013-03-28 16:11:14 +00001144 .update_bank = 0x03,
1145 .update_reg = 0x83,
1146 .update_mask = 0x08,
1147 .update_val = 0x08,
Lee Jones3fe52282013-04-02 13:24:12 +01001148 .mode_bank = 0x01,
1149 .mode_reg = 0x54,
1150 .mode_mask = 0x04,
1151 .mode_val_idle = 0x04,
1152 .mode_val_normal = 0x00,
Lee Jones547f3842013-03-28 16:11:14 +00001153 },
1154 [AB8505_LDO_ANAMIC2] = {
1155 .desc = {
1156 .name = "LDO-ANAMIC2",
Lee Jones3fe52282013-04-02 13:24:12 +01001157 .ops = &ab8500_regulator_anamic_mode_ops,
Lee Jones547f3842013-03-28 16:11:14 +00001158 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001159 .id = AB8505_LDO_ANAMIC2,
Lee Jones547f3842013-03-28 16:11:14 +00001160 .owner = THIS_MODULE,
1161 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001162 .volt_table = fixed_2050000_voltage,
Lee Jones547f3842013-03-28 16:11:14 +00001163 },
Lee Jones3fe52282013-04-02 13:24:12 +01001164 .shared_mode = &ldo_anamic2_shared,
Lee Jones547f3842013-03-28 16:11:14 +00001165 .update_bank = 0x03,
1166 .update_reg = 0x83,
1167 .update_mask = 0x10,
1168 .update_val = 0x10,
Lee Jones3fe52282013-04-02 13:24:12 +01001169 .mode_bank = 0x01,
1170 .mode_reg = 0x54,
1171 .mode_mask = 0x04,
1172 .mode_val_idle = 0x04,
1173 .mode_val_normal = 0x00,
Lee Jones547f3842013-03-28 16:11:14 +00001174 },
1175 [AB8505_LDO_AUX8] = {
1176 .desc = {
1177 .name = "LDO-AUX8",
1178 .ops = &ab8500_regulator_ops,
1179 .type = REGULATOR_VOLTAGE,
1180 .id = AB8505_LDO_AUX8,
1181 .owner = THIS_MODULE,
1182 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001183 .volt_table = fixed_1800000_voltage,
Lee Jones547f3842013-03-28 16:11:14 +00001184 },
Lee Jones547f3842013-03-28 16:11:14 +00001185 .update_bank = 0x03,
1186 .update_reg = 0x83,
1187 .update_mask = 0x04,
1188 .update_val = 0x04,
1189 },
1190 /*
1191 * Regulators with fixed voltage and normal/idle modes
1192 */
1193 [AB8505_LDO_ANA] = {
1194 .desc = {
1195 .name = "LDO-ANA",
Lee Jones8a3b1b82013-04-02 13:24:09 +01001196 .ops = &ab8500_regulator_volt_mode_ops,
Lee Jones547f3842013-03-28 16:11:14 +00001197 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001198 .id = AB8505_LDO_ANA,
Lee Jones547f3842013-03-28 16:11:14 +00001199 .owner = THIS_MODULE,
Lee Jones8a3b1b82013-04-02 13:24:09 +01001200 .n_voltages = ARRAY_SIZE(ldo_vana_voltages),
1201 .volt_table = ldo_vana_voltages,
Lee Jones547f3842013-03-28 16:11:14 +00001202 },
Lee Jones547f3842013-03-28 16:11:14 +00001203 .load_lp_uA = 1000,
1204 .update_bank = 0x04,
1205 .update_reg = 0x06,
1206 .update_mask = 0x0c,
1207 .update_val = 0x04,
1208 .update_val_idle = 0x0c,
1209 .update_val_normal = 0x04,
Lee Jones8a3b1b82013-04-02 13:24:09 +01001210 .voltage_bank = 0x04,
1211 .voltage_reg = 0x29,
1212 .voltage_mask = 0x7,
Lee Jones547f3842013-03-28 16:11:14 +00001213 },
1214};
1215
Lee Jones8e6a8d72013-03-28 16:11:11 +00001216/* AB9540 regulator information */
1217static struct ab8500_regulator_info
1218 ab9540_regulator_info[AB9540_NUM_REGULATORS] = {
1219 /*
1220 * Variable Voltage Regulators
1221 * name, min mV, max mV,
1222 * update bank, reg, mask, enable val
Lee Jonesd3193102013-04-02 13:24:18 +01001223 * volt bank, reg, mask
Lee Jones8e6a8d72013-03-28 16:11:11 +00001224 */
1225 [AB9540_LDO_AUX1] = {
1226 .desc = {
1227 .name = "LDO-AUX1",
1228 .ops = &ab8500_regulator_volt_mode_ops,
1229 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001230 .id = AB9540_LDO_AUX1,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001231 .owner = THIS_MODULE,
1232 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001233 .volt_table = ldo_vauxn_voltages,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001234 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001235 .load_lp_uA = 5000,
1236 .update_bank = 0x04,
1237 .update_reg = 0x09,
1238 .update_mask = 0x03,
1239 .update_val = 0x01,
1240 .update_val_idle = 0x03,
1241 .update_val_normal = 0x01,
1242 .voltage_bank = 0x04,
1243 .voltage_reg = 0x1f,
1244 .voltage_mask = 0x0f,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001245 },
1246 [AB9540_LDO_AUX2] = {
1247 .desc = {
1248 .name = "LDO-AUX2",
1249 .ops = &ab8500_regulator_volt_mode_ops,
1250 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001251 .id = AB9540_LDO_AUX2,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001252 .owner = THIS_MODULE,
1253 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001254 .volt_table = ldo_vauxn_voltages,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001255 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001256 .load_lp_uA = 5000,
1257 .update_bank = 0x04,
1258 .update_reg = 0x09,
1259 .update_mask = 0x0c,
1260 .update_val = 0x04,
1261 .update_val_idle = 0x0c,
1262 .update_val_normal = 0x04,
1263 .voltage_bank = 0x04,
1264 .voltage_reg = 0x20,
1265 .voltage_mask = 0x0f,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001266 },
1267 [AB9540_LDO_AUX3] = {
1268 .desc = {
1269 .name = "LDO-AUX3",
1270 .ops = &ab8500_regulator_volt_mode_ops,
1271 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001272 .id = AB9540_LDO_AUX3,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001273 .owner = THIS_MODULE,
1274 .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001275 .volt_table = ldo_vaux3_voltages,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001276 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001277 .load_lp_uA = 5000,
1278 .update_bank = 0x04,
1279 .update_reg = 0x0a,
1280 .update_mask = 0x03,
1281 .update_val = 0x01,
1282 .update_val_idle = 0x03,
1283 .update_val_normal = 0x01,
1284 .voltage_bank = 0x04,
1285 .voltage_reg = 0x21,
1286 .voltage_mask = 0x07,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001287 },
1288 [AB9540_LDO_AUX4] = {
1289 .desc = {
1290 .name = "LDO-AUX4",
1291 .ops = &ab8500_regulator_volt_mode_ops,
1292 .type = REGULATOR_VOLTAGE,
1293 .id = AB9540_LDO_AUX4,
1294 .owner = THIS_MODULE,
1295 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001296 .volt_table = ldo_vauxn_voltages,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001297 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001298 .load_lp_uA = 5000,
1299 /* values for Vaux4Regu register */
1300 .update_bank = 0x04,
1301 .update_reg = 0x2e,
1302 .update_mask = 0x03,
1303 .update_val = 0x01,
1304 .update_val_idle = 0x03,
1305 .update_val_normal = 0x01,
1306 /* values for Vaux4SEL register */
1307 .voltage_bank = 0x04,
1308 .voltage_reg = 0x2f,
1309 .voltage_mask = 0x0f,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001310 },
1311 [AB9540_LDO_INTCORE] = {
1312 .desc = {
1313 .name = "LDO-INTCORE",
1314 .ops = &ab8500_regulator_volt_mode_ops,
1315 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001316 .id = AB9540_LDO_INTCORE,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001317 .owner = THIS_MODULE,
1318 .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001319 .volt_table = ldo_vintcore_voltages,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001320 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001321 .load_lp_uA = 5000,
1322 .update_bank = 0x03,
1323 .update_reg = 0x80,
1324 .update_mask = 0x44,
1325 .update_val = 0x44,
1326 .update_val_idle = 0x44,
1327 .update_val_normal = 0x04,
1328 .voltage_bank = 0x03,
1329 .voltage_reg = 0x80,
1330 .voltage_mask = 0x38,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001331 .voltage_shift = 3,
1332 },
Bengt Jonsson6909b452010-12-10 11:08:47 +01001333
Lee Jones8e6a8d72013-03-28 16:11:11 +00001334 /*
1335 * Fixed Voltage Regulators
1336 * name, fixed mV,
1337 * update bank, reg, mask, enable val
1338 */
1339 [AB9540_LDO_TVOUT] = {
1340 .desc = {
1341 .name = "LDO-TVOUT",
1342 .ops = &ab8500_regulator_mode_ops,
1343 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001344 .id = AB9540_LDO_TVOUT,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001345 .owner = THIS_MODULE,
1346 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001347 .volt_table = fixed_2000000_voltage,
Lee Jonesa4d68462013-04-02 13:24:16 +01001348 .enable_time = 10000,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001349 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001350 .load_lp_uA = 1000,
1351 .update_bank = 0x03,
1352 .update_reg = 0x80,
1353 .update_mask = 0x82,
1354 .update_val = 0x02,
1355 .update_val_idle = 0x82,
1356 .update_val_normal = 0x02,
1357 },
1358 [AB9540_LDO_USB] = {
1359 .desc = {
1360 .name = "LDO-USB",
1361 .ops = &ab8500_regulator_ops,
1362 .type = REGULATOR_VOLTAGE,
1363 .id = AB9540_LDO_USB,
1364 .owner = THIS_MODULE,
1365 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001366 .volt_table = fixed_3300000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001367 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001368 .update_bank = 0x03,
1369 .update_reg = 0x82,
1370 .update_mask = 0x03,
1371 .update_val = 0x01,
1372 .update_val_idle = 0x03,
1373 .update_val_normal = 0x01,
1374 },
1375 [AB9540_LDO_AUDIO] = {
1376 .desc = {
1377 .name = "LDO-AUDIO",
1378 .ops = &ab8500_regulator_ops,
1379 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001380 .id = AB9540_LDO_AUDIO,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001381 .owner = THIS_MODULE,
1382 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001383 .volt_table = fixed_2000000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001384 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001385 .update_bank = 0x03,
1386 .update_reg = 0x83,
1387 .update_mask = 0x02,
1388 .update_val = 0x02,
1389 },
1390 [AB9540_LDO_ANAMIC1] = {
1391 .desc = {
1392 .name = "LDO-ANAMIC1",
1393 .ops = &ab8500_regulator_ops,
1394 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001395 .id = AB9540_LDO_ANAMIC1,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001396 .owner = THIS_MODULE,
1397 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001398 .volt_table = fixed_2050000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001399 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001400 .update_bank = 0x03,
1401 .update_reg = 0x83,
1402 .update_mask = 0x08,
1403 .update_val = 0x08,
1404 },
1405 [AB9540_LDO_ANAMIC2] = {
1406 .desc = {
1407 .name = "LDO-ANAMIC2",
1408 .ops = &ab8500_regulator_ops,
1409 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001410 .id = AB9540_LDO_ANAMIC2,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001411 .owner = THIS_MODULE,
1412 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001413 .volt_table = fixed_2050000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001414 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001415 .update_bank = 0x03,
1416 .update_reg = 0x83,
1417 .update_mask = 0x10,
1418 .update_val = 0x10,
1419 },
1420 [AB9540_LDO_DMIC] = {
1421 .desc = {
1422 .name = "LDO-DMIC",
1423 .ops = &ab8500_regulator_ops,
1424 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001425 .id = AB9540_LDO_DMIC,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001426 .owner = THIS_MODULE,
1427 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001428 .volt_table = fixed_1800000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001429 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001430 .update_bank = 0x03,
1431 .update_reg = 0x83,
1432 .update_mask = 0x04,
1433 .update_val = 0x04,
1434 },
1435
1436 /*
1437 * Regulators with fixed voltage and normal/idle modes
1438 */
1439 [AB9540_LDO_ANA] = {
1440 .desc = {
1441 .name = "LDO-ANA",
1442 .ops = &ab8500_regulator_mode_ops,
1443 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001444 .id = AB9540_LDO_ANA,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001445 .owner = THIS_MODULE,
1446 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001447 .volt_table = fixed_1200000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001448 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001449 .load_lp_uA = 1000,
1450 .update_bank = 0x04,
1451 .update_reg = 0x06,
1452 .update_mask = 0x0c,
1453 .update_val = 0x08,
1454 .update_val_idle = 0x0c,
1455 .update_val_normal = 0x08,
1456 },
Sundar R IYERc789ca22010-07-13 21:48:56 +05301457};
1458
Lee Jonesae0a9a32013-03-28 16:11:16 +00001459/* AB8540 regulator information */
1460static struct ab8500_regulator_info
1461 ab8540_regulator_info[AB8540_NUM_REGULATORS] = {
1462 /*
1463 * Variable Voltage Regulators
1464 * name, min mV, max mV,
1465 * update bank, reg, mask, enable val
Lee Jonesd3193102013-04-02 13:24:18 +01001466 * volt bank, reg, mask
Lee Jonesae0a9a32013-03-28 16:11:16 +00001467 */
1468 [AB8540_LDO_AUX1] = {
1469 .desc = {
1470 .name = "LDO-AUX1",
1471 .ops = &ab8500_regulator_volt_mode_ops,
1472 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001473 .id = AB8540_LDO_AUX1,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001474 .owner = THIS_MODULE,
1475 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001476 .volt_table = ldo_vauxn_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001477 },
1478 .load_lp_uA = 5000,
1479 .update_bank = 0x04,
1480 .update_reg = 0x09,
1481 .update_mask = 0x03,
1482 .update_val = 0x01,
1483 .update_val_idle = 0x03,
1484 .update_val_normal = 0x01,
1485 .voltage_bank = 0x04,
1486 .voltage_reg = 0x1f,
1487 .voltage_mask = 0x0f,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001488 },
1489 [AB8540_LDO_AUX2] = {
1490 .desc = {
1491 .name = "LDO-AUX2",
1492 .ops = &ab8500_regulator_volt_mode_ops,
1493 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001494 .id = AB8540_LDO_AUX2,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001495 .owner = THIS_MODULE,
1496 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001497 .volt_table = ldo_vauxn_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001498 },
1499 .load_lp_uA = 5000,
1500 .update_bank = 0x04,
1501 .update_reg = 0x09,
1502 .update_mask = 0x0c,
1503 .update_val = 0x04,
1504 .update_val_idle = 0x0c,
1505 .update_val_normal = 0x04,
1506 .voltage_bank = 0x04,
1507 .voltage_reg = 0x20,
1508 .voltage_mask = 0x0f,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001509 },
1510 [AB8540_LDO_AUX3] = {
1511 .desc = {
1512 .name = "LDO-AUX3",
Lee Jonesd7607ba2013-04-02 13:24:11 +01001513 .ops = &ab8540_aux3_regulator_volt_mode_ops,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001514 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001515 .id = AB8540_LDO_AUX3,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001516 .owner = THIS_MODULE,
1517 .n_voltages = ARRAY_SIZE(ldo_vaux3_ab8540_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001518 .volt_table = ldo_vaux3_ab8540_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001519 },
1520 .load_lp_uA = 5000,
1521 .update_bank = 0x04,
1522 .update_reg = 0x0a,
1523 .update_mask = 0x03,
1524 .update_val = 0x01,
1525 .update_val_idle = 0x03,
1526 .update_val_normal = 0x01,
1527 .voltage_bank = 0x04,
1528 .voltage_reg = 0x21,
1529 .voltage_mask = 0x07,
Lee Jonesd7607ba2013-04-02 13:24:11 +01001530 .expand_register = {
1531 .voltage_limit = 8,
1532 .voltage_bank = 0x04,
1533 .voltage_reg = 0x01,
1534 .voltage_mask = 0x10,
1535 .voltage_shift = 1,
1536 }
Lee Jonesae0a9a32013-03-28 16:11:16 +00001537 },
1538 [AB8540_LDO_AUX4] = {
1539 .desc = {
1540 .name = "LDO-AUX4",
1541 .ops = &ab8500_regulator_volt_mode_ops,
1542 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001543 .id = AB8540_LDO_AUX4,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001544 .owner = THIS_MODULE,
1545 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001546 .volt_table = ldo_vauxn_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001547 },
1548 .load_lp_uA = 5000,
1549 /* values for Vaux4Regu register */
1550 .update_bank = 0x04,
1551 .update_reg = 0x2e,
1552 .update_mask = 0x03,
1553 .update_val = 0x01,
1554 .update_val_idle = 0x03,
1555 .update_val_normal = 0x01,
1556 /* values for Vaux4SEL register */
1557 .voltage_bank = 0x04,
1558 .voltage_reg = 0x2f,
1559 .voltage_mask = 0x0f,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001560 },
Zhenhua HUANG684d5ce2013-04-02 13:24:15 +01001561 [AB8540_LDO_AUX5] = {
1562 .desc = {
1563 .name = "LDO-AUX5",
1564 .ops = &ab8500_regulator_volt_mode_ops,
1565 .type = REGULATOR_VOLTAGE,
1566 .id = AB8540_LDO_AUX5,
1567 .owner = THIS_MODULE,
1568 .n_voltages = ARRAY_SIZE(ldo_vaux56_ab8540_voltages),
Lee Jonesd3193102013-04-02 13:24:18 +01001569 .volt_table = ldo_vaux56_ab8540_voltages,
Zhenhua HUANG684d5ce2013-04-02 13:24:15 +01001570 },
1571 .load_lp_uA = 20000,
1572 /* values for Vaux5Regu register */
1573 .update_bank = 0x04,
1574 .update_reg = 0x32,
1575 .update_mask = 0x03,
1576 .update_val = 0x01,
1577 .update_val_idle = 0x03,
1578 .update_val_normal = 0x01,
1579 /* values for Vaux5SEL register */
1580 .voltage_bank = 0x04,
1581 .voltage_reg = 0x33,
1582 .voltage_mask = 0x3f,
Zhenhua HUANG684d5ce2013-04-02 13:24:15 +01001583 },
1584 [AB8540_LDO_AUX6] = {
1585 .desc = {
1586 .name = "LDO-AUX6",
1587 .ops = &ab8500_regulator_volt_mode_ops,
1588 .type = REGULATOR_VOLTAGE,
1589 .id = AB8540_LDO_AUX6,
1590 .owner = THIS_MODULE,
1591 .n_voltages = ARRAY_SIZE(ldo_vaux56_ab8540_voltages),
Lee Jonesd3193102013-04-02 13:24:18 +01001592 .volt_table = ldo_vaux56_ab8540_voltages,
Zhenhua HUANG684d5ce2013-04-02 13:24:15 +01001593 },
1594 .load_lp_uA = 20000,
1595 /* values for Vaux6Regu register */
1596 .update_bank = 0x04,
1597 .update_reg = 0x35,
1598 .update_mask = 0x03,
1599 .update_val = 0x01,
1600 .update_val_idle = 0x03,
1601 .update_val_normal = 0x01,
1602 /* values for Vaux6SEL register */
1603 .voltage_bank = 0x04,
1604 .voltage_reg = 0x36,
1605 .voltage_mask = 0x3f,
Zhenhua HUANG684d5ce2013-04-02 13:24:15 +01001606 },
Lee Jonesae0a9a32013-03-28 16:11:16 +00001607 [AB8540_LDO_INTCORE] = {
1608 .desc = {
1609 .name = "LDO-INTCORE",
1610 .ops = &ab8500_regulator_volt_mode_ops,
1611 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001612 .id = AB8540_LDO_INTCORE,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001613 .owner = THIS_MODULE,
1614 .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001615 .volt_table = ldo_vintcore_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001616 },
1617 .load_lp_uA = 5000,
1618 .update_bank = 0x03,
1619 .update_reg = 0x80,
1620 .update_mask = 0x44,
1621 .update_val = 0x44,
1622 .update_val_idle = 0x44,
1623 .update_val_normal = 0x04,
1624 .voltage_bank = 0x03,
1625 .voltage_reg = 0x80,
1626 .voltage_mask = 0x38,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001627 .voltage_shift = 3,
1628 },
1629
1630 /*
1631 * Fixed Voltage Regulators
1632 * name, fixed mV,
1633 * update bank, reg, mask, enable val
1634 */
1635 [AB8540_LDO_TVOUT] = {
1636 .desc = {
1637 .name = "LDO-TVOUT",
1638 .ops = &ab8500_regulator_mode_ops,
1639 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001640 .id = AB8540_LDO_TVOUT,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001641 .owner = THIS_MODULE,
1642 .n_voltages = 1,
Axel Linaca45e92013-04-02 13:24:23 +01001643 .volt_table = fixed_2000000_voltage,
Lee Jonesa4d68462013-04-02 13:24:16 +01001644 .enable_time = 10000,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001645 },
Lee Jonesae0a9a32013-03-28 16:11:16 +00001646 .load_lp_uA = 1000,
1647 .update_bank = 0x03,
1648 .update_reg = 0x80,
1649 .update_mask = 0x82,
1650 .update_val = 0x02,
1651 .update_val_idle = 0x82,
1652 .update_val_normal = 0x02,
1653 },
1654 [AB8540_LDO_AUDIO] = {
1655 .desc = {
1656 .name = "LDO-AUDIO",
1657 .ops = &ab8500_regulator_ops,
1658 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001659 .id = AB8540_LDO_AUDIO,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001660 .owner = THIS_MODULE,
1661 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001662 .volt_table = fixed_2000000_voltage,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001663 },
1664 .update_bank = 0x03,
1665 .update_reg = 0x83,
1666 .update_mask = 0x02,
1667 .update_val = 0x02,
1668 },
1669 [AB8540_LDO_ANAMIC1] = {
1670 .desc = {
1671 .name = "LDO-ANAMIC1",
Lee Jones4c84b4d2013-04-02 13:24:13 +01001672 .ops = &ab8500_regulator_anamic_mode_ops,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001673 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001674 .id = AB8540_LDO_ANAMIC1,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001675 .owner = THIS_MODULE,
1676 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001677 .volt_table = fixed_2050000_voltage,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001678 },
Lee Jones4c84b4d2013-04-02 13:24:13 +01001679 .shared_mode = &ab8540_ldo_anamic1_shared,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001680 .update_bank = 0x03,
1681 .update_reg = 0x83,
1682 .update_mask = 0x08,
1683 .update_val = 0x08,
Lee Jones4c84b4d2013-04-02 13:24:13 +01001684 .mode_bank = 0x03,
1685 .mode_reg = 0x83,
1686 .mode_mask = 0x20,
1687 .mode_val_idle = 0x20,
1688 .mode_val_normal = 0x00,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001689 },
1690 [AB8540_LDO_ANAMIC2] = {
1691 .desc = {
1692 .name = "LDO-ANAMIC2",
Lee Jones4c84b4d2013-04-02 13:24:13 +01001693 .ops = &ab8500_regulator_anamic_mode_ops,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001694 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001695 .id = AB8540_LDO_ANAMIC2,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001696 .owner = THIS_MODULE,
1697 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001698 .volt_table = fixed_2050000_voltage,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001699 },
Lee Jones4c84b4d2013-04-02 13:24:13 +01001700 .shared_mode = &ab8540_ldo_anamic2_shared,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001701 .update_bank = 0x03,
1702 .update_reg = 0x83,
1703 .update_mask = 0x10,
1704 .update_val = 0x10,
Lee Jones4c84b4d2013-04-02 13:24:13 +01001705 .mode_bank = 0x03,
1706 .mode_reg = 0x83,
1707 .mode_mask = 0x20,
1708 .mode_val_idle = 0x20,
1709 .mode_val_normal = 0x00,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001710 },
1711 [AB8540_LDO_DMIC] = {
1712 .desc = {
1713 .name = "LDO-DMIC",
Lee Jones4c84b4d2013-04-02 13:24:13 +01001714 .ops = &ab8500_regulator_volt_mode_ops,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001715 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001716 .id = AB8540_LDO_DMIC,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001717 .owner = THIS_MODULE,
Lee Jones4c84b4d2013-04-02 13:24:13 +01001718 .n_voltages = ARRAY_SIZE(ldo_vdmic_voltages),
Lee Jonesd3193102013-04-02 13:24:18 +01001719 .volt_table = ldo_vdmic_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001720 },
Lee Jones4c84b4d2013-04-02 13:24:13 +01001721 .load_lp_uA = 1000,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001722 .update_bank = 0x03,
1723 .update_reg = 0x83,
1724 .update_mask = 0x04,
1725 .update_val = 0x04,
Lee Jones4c84b4d2013-04-02 13:24:13 +01001726 .voltage_bank = 0x03,
1727 .voltage_reg = 0x83,
1728 .voltage_mask = 0xc0,
Axel Lin375dc9c2013-04-15 16:36:51 +08001729 .voltage_shift = 6,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001730 },
1731
1732 /*
1733 * Regulators with fixed voltage and normal/idle modes
1734 */
1735 [AB8540_LDO_ANA] = {
1736 .desc = {
1737 .name = "LDO-ANA",
1738 .ops = &ab8500_regulator_mode_ops,
1739 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001740 .id = AB8540_LDO_ANA,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001741 .owner = THIS_MODULE,
1742 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001743 .volt_table = fixed_1200000_voltage,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001744 },
1745 .load_lp_uA = 1000,
1746 .update_bank = 0x04,
1747 .update_reg = 0x06,
1748 .update_mask = 0x0c,
1749 .update_val = 0x04,
1750 .update_val_idle = 0x0c,
1751 .update_val_normal = 0x04,
1752 },
1753 [AB8540_LDO_SDIO] = {
1754 .desc = {
1755 .name = "LDO-SDIO",
1756 .ops = &ab8500_regulator_volt_mode_ops,
1757 .type = REGULATOR_VOLTAGE,
1758 .id = AB8540_LDO_SDIO,
1759 .owner = THIS_MODULE,
Lee Jones62ab4112013-03-28 16:11:18 +00001760 .n_voltages = ARRAY_SIZE(ldo_sdio_voltages),
1761 .volt_table = ldo_sdio_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001762 },
Lee Jonesae0a9a32013-03-28 16:11:16 +00001763 .load_lp_uA = 5000,
1764 .update_bank = 0x03,
1765 .update_reg = 0x88,
1766 .update_mask = 0x30,
1767 .update_val = 0x10,
1768 .update_val_idle = 0x30,
1769 .update_val_normal = 0x10,
1770 .voltage_bank = 0x03,
1771 .voltage_reg = 0x88,
1772 .voltage_mask = 0x07,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001773 },
1774};
1775
Lee Jones3fe52282013-04-02 13:24:12 +01001776static struct ab8500_shared_mode ldo_anamic1_shared = {
1777 .shared_regulator = &ab8505_regulator_info[AB8505_LDO_ANAMIC2],
1778};
1779
1780static struct ab8500_shared_mode ldo_anamic2_shared = {
1781 .shared_regulator = &ab8505_regulator_info[AB8505_LDO_ANAMIC1],
1782};
1783
Lee Jones4c84b4d2013-04-02 13:24:13 +01001784static struct ab8500_shared_mode ab8540_ldo_anamic1_shared = {
1785 .shared_regulator = &ab8540_regulator_info[AB8540_LDO_ANAMIC2],
1786};
1787
1788static struct ab8500_shared_mode ab8540_ldo_anamic2_shared = {
1789 .shared_regulator = &ab8540_regulator_info[AB8540_LDO_ANAMIC1],
1790};
1791
Bengt Jonsson79568b942011-03-11 11:54:46 +01001792struct ab8500_reg_init {
1793 u8 bank;
1794 u8 addr;
1795 u8 mask;
1796};
1797
1798#define REG_INIT(_id, _bank, _addr, _mask) \
1799 [_id] = { \
1800 .bank = _bank, \
1801 .addr = _addr, \
1802 .mask = _mask, \
1803 }
1804
Lee Jones8e6a8d72013-03-28 16:11:11 +00001805/* AB8500 register init */
Bengt Jonsson79568b942011-03-11 11:54:46 +01001806static struct ab8500_reg_init ab8500_reg_init[] = {
1807 /*
Lee Jones33bc8f42013-03-21 15:59:02 +00001808 * 0x30, VanaRequestCtrl
Bengt Jonsson79568b942011-03-11 11:54:46 +01001809 * 0xc0, VextSupply1RequestCtrl
1810 */
Lee Jones43a59112013-03-21 15:59:15 +00001811 REG_INIT(AB8500_REGUREQUESTCTRL2, 0x03, 0x04, 0xf0),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001812 /*
1813 * 0x03, VextSupply2RequestCtrl
1814 * 0x0c, VextSupply3RequestCtrl
1815 * 0x30, Vaux1RequestCtrl
1816 * 0xc0, Vaux2RequestCtrl
1817 */
1818 REG_INIT(AB8500_REGUREQUESTCTRL3, 0x03, 0x05, 0xff),
1819 /*
1820 * 0x03, Vaux3RequestCtrl
1821 * 0x04, SwHPReq
1822 */
1823 REG_INIT(AB8500_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
1824 /*
1825 * 0x08, VanaSysClkReq1HPValid
1826 * 0x20, Vaux1SysClkReq1HPValid
1827 * 0x40, Vaux2SysClkReq1HPValid
1828 * 0x80, Vaux3SysClkReq1HPValid
1829 */
Lee Jones43a59112013-03-21 15:59:15 +00001830 REG_INIT(AB8500_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xe8),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001831 /*
1832 * 0x10, VextSupply1SysClkReq1HPValid
1833 * 0x20, VextSupply2SysClkReq1HPValid
1834 * 0x40, VextSupply3SysClkReq1HPValid
1835 */
Lee Jones43a59112013-03-21 15:59:15 +00001836 REG_INIT(AB8500_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x70),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001837 /*
1838 * 0x08, VanaHwHPReq1Valid
1839 * 0x20, Vaux1HwHPReq1Valid
1840 * 0x40, Vaux2HwHPReq1Valid
1841 * 0x80, Vaux3HwHPReq1Valid
1842 */
Lee Jones43a59112013-03-21 15:59:15 +00001843 REG_INIT(AB8500_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xe8),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001844 /*
1845 * 0x01, VextSupply1HwHPReq1Valid
1846 * 0x02, VextSupply2HwHPReq1Valid
1847 * 0x04, VextSupply3HwHPReq1Valid
1848 */
Lee Jones43a59112013-03-21 15:59:15 +00001849 REG_INIT(AB8500_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x07),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001850 /*
1851 * 0x08, VanaHwHPReq2Valid
1852 * 0x20, Vaux1HwHPReq2Valid
1853 * 0x40, Vaux2HwHPReq2Valid
1854 * 0x80, Vaux3HwHPReq2Valid
1855 */
Lee Jones43a59112013-03-21 15:59:15 +00001856 REG_INIT(AB8500_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xe8),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001857 /*
1858 * 0x01, VextSupply1HwHPReq2Valid
1859 * 0x02, VextSupply2HwHPReq2Valid
1860 * 0x04, VextSupply3HwHPReq2Valid
1861 */
Lee Jones43a59112013-03-21 15:59:15 +00001862 REG_INIT(AB8500_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x07),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001863 /*
1864 * 0x20, VanaSwHPReqValid
1865 * 0x80, Vaux1SwHPReqValid
1866 */
Lee Jones43a59112013-03-21 15:59:15 +00001867 REG_INIT(AB8500_REGUSWHPREQVALID1, 0x03, 0x0d, 0xa0),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001868 /*
1869 * 0x01, Vaux2SwHPReqValid
1870 * 0x02, Vaux3SwHPReqValid
1871 * 0x04, VextSupply1SwHPReqValid
1872 * 0x08, VextSupply2SwHPReqValid
1873 * 0x10, VextSupply3SwHPReqValid
1874 */
Lee Jones43a59112013-03-21 15:59:15 +00001875 REG_INIT(AB8500_REGUSWHPREQVALID2, 0x03, 0x0e, 0x1f),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001876 /*
1877 * 0x02, SysClkReq2Valid1
Lee Jones43a59112013-03-21 15:59:15 +00001878 * 0x04, SysClkReq3Valid1
1879 * 0x08, SysClkReq4Valid1
1880 * 0x10, SysClkReq5Valid1
1881 * 0x20, SysClkReq6Valid1
1882 * 0x40, SysClkReq7Valid1
Bengt Jonsson79568b942011-03-11 11:54:46 +01001883 * 0x80, SysClkReq8Valid1
1884 */
1885 REG_INIT(AB8500_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0xfe),
1886 /*
1887 * 0x02, SysClkReq2Valid2
Lee Jones43a59112013-03-21 15:59:15 +00001888 * 0x04, SysClkReq3Valid2
1889 * 0x08, SysClkReq4Valid2
1890 * 0x10, SysClkReq5Valid2
1891 * 0x20, SysClkReq6Valid2
1892 * 0x40, SysClkReq7Valid2
Bengt Jonsson79568b942011-03-11 11:54:46 +01001893 * 0x80, SysClkReq8Valid2
1894 */
1895 REG_INIT(AB8500_REGUSYSCLKREQVALID2, 0x03, 0x10, 0xfe),
1896 /*
1897 * 0x02, VTVoutEna
1898 * 0x04, Vintcore12Ena
1899 * 0x38, Vintcore12Sel
1900 * 0x40, Vintcore12LP
1901 * 0x80, VTVoutLP
1902 */
1903 REG_INIT(AB8500_REGUMISC1, 0x03, 0x80, 0xfe),
1904 /*
1905 * 0x02, VaudioEna
1906 * 0x04, VdmicEna
1907 * 0x08, Vamic1Ena
1908 * 0x10, Vamic2Ena
1909 */
1910 REG_INIT(AB8500_VAUDIOSUPPLY, 0x03, 0x83, 0x1e),
1911 /*
1912 * 0x01, Vamic1_dzout
1913 * 0x02, Vamic2_dzout
1914 */
1915 REG_INIT(AB8500_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
1916 /*
Lee Jones43a59112013-03-21 15:59:15 +00001917 * 0x03, VpllRegu (NOTE! PRCMU register bits)
Lee Jones33bc8f42013-03-21 15:59:02 +00001918 * 0x0c, VanaRegu
Bengt Jonsson79568b942011-03-11 11:54:46 +01001919 */
1920 REG_INIT(AB8500_VPLLVANAREGU, 0x04, 0x06, 0x0f),
1921 /*
1922 * 0x01, VrefDDREna
1923 * 0x02, VrefDDRSleepMode
1924 */
1925 REG_INIT(AB8500_VREFDDR, 0x04, 0x07, 0x03),
1926 /*
1927 * 0x03, VextSupply1Regu
1928 * 0x0c, VextSupply2Regu
1929 * 0x30, VextSupply3Regu
1930 * 0x40, ExtSupply2Bypass
1931 * 0x80, ExtSupply3Bypass
1932 */
1933 REG_INIT(AB8500_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
1934 /*
1935 * 0x03, Vaux1Regu
1936 * 0x0c, Vaux2Regu
1937 */
1938 REG_INIT(AB8500_VAUX12REGU, 0x04, 0x09, 0x0f),
1939 /*
1940 * 0x03, Vaux3Regu
1941 */
Lee Jones43a59112013-03-21 15:59:15 +00001942 REG_INIT(AB8500_VRF1VAUX3REGU, 0x04, 0x0a, 0x03),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001943 /*
1944 * 0x0f, Vaux1Sel
1945 */
1946 REG_INIT(AB8500_VAUX1SEL, 0x04, 0x1f, 0x0f),
1947 /*
1948 * 0x0f, Vaux2Sel
1949 */
1950 REG_INIT(AB8500_VAUX2SEL, 0x04, 0x20, 0x0f),
1951 /*
1952 * 0x07, Vaux3Sel
1953 */
Lee Jones43a59112013-03-21 15:59:15 +00001954 REG_INIT(AB8500_VRF1VAUX3SEL, 0x04, 0x21, 0x07),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001955 /*
1956 * 0x01, VextSupply12LP
1957 */
1958 REG_INIT(AB8500_REGUCTRL2SPARE, 0x04, 0x22, 0x01),
1959 /*
1960 * 0x04, Vaux1Disch
1961 * 0x08, Vaux2Disch
1962 * 0x10, Vaux3Disch
1963 * 0x20, Vintcore12Disch
1964 * 0x40, VTVoutDisch
1965 * 0x80, VaudioDisch
1966 */
Lee Jones43a59112013-03-21 15:59:15 +00001967 REG_INIT(AB8500_REGUCTRLDISCH, 0x04, 0x43, 0xfc),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001968 /*
1969 * 0x02, VanaDisch
1970 * 0x04, VdmicPullDownEna
1971 * 0x10, VdmicDisch
1972 */
Lee Jones43a59112013-03-21 15:59:15 +00001973 REG_INIT(AB8500_REGUCTRLDISCH2, 0x04, 0x44, 0x16),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001974};
1975
Lee Jones547f3842013-03-28 16:11:14 +00001976/* AB8505 register init */
1977static struct ab8500_reg_init ab8505_reg_init[] = {
1978 /*
1979 * 0x03, VarmRequestCtrl
1980 * 0x0c, VsmpsCRequestCtrl
1981 * 0x30, VsmpsARequestCtrl
1982 * 0xc0, VsmpsBRequestCtrl
1983 */
1984 REG_INIT(AB8505_REGUREQUESTCTRL1, 0x03, 0x03, 0xff),
1985 /*
1986 * 0x03, VsafeRequestCtrl
1987 * 0x0c, VpllRequestCtrl
1988 * 0x30, VanaRequestCtrl
1989 */
1990 REG_INIT(AB8505_REGUREQUESTCTRL2, 0x03, 0x04, 0x3f),
1991 /*
1992 * 0x30, Vaux1RequestCtrl
1993 * 0xc0, Vaux2RequestCtrl
1994 */
1995 REG_INIT(AB8505_REGUREQUESTCTRL3, 0x03, 0x05, 0xf0),
1996 /*
1997 * 0x03, Vaux3RequestCtrl
1998 * 0x04, SwHPReq
1999 */
2000 REG_INIT(AB8505_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
2001 /*
2002 * 0x01, VsmpsASysClkReq1HPValid
2003 * 0x02, VsmpsBSysClkReq1HPValid
2004 * 0x04, VsafeSysClkReq1HPValid
2005 * 0x08, VanaSysClkReq1HPValid
2006 * 0x10, VpllSysClkReq1HPValid
2007 * 0x20, Vaux1SysClkReq1HPValid
2008 * 0x40, Vaux2SysClkReq1HPValid
2009 * 0x80, Vaux3SysClkReq1HPValid
2010 */
2011 REG_INIT(AB8505_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xff),
2012 /*
2013 * 0x01, VsmpsCSysClkReq1HPValid
2014 * 0x02, VarmSysClkReq1HPValid
2015 * 0x04, VbbSysClkReq1HPValid
2016 * 0x08, VsmpsMSysClkReq1HPValid
2017 */
2018 REG_INIT(AB8505_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x0f),
2019 /*
2020 * 0x01, VsmpsAHwHPReq1Valid
2021 * 0x02, VsmpsBHwHPReq1Valid
2022 * 0x04, VsafeHwHPReq1Valid
2023 * 0x08, VanaHwHPReq1Valid
2024 * 0x10, VpllHwHPReq1Valid
2025 * 0x20, Vaux1HwHPReq1Valid
2026 * 0x40, Vaux2HwHPReq1Valid
2027 * 0x80, Vaux3HwHPReq1Valid
2028 */
2029 REG_INIT(AB8505_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xff),
2030 /*
2031 * 0x08, VsmpsMHwHPReq1Valid
2032 */
2033 REG_INIT(AB8505_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x08),
2034 /*
2035 * 0x01, VsmpsAHwHPReq2Valid
2036 * 0x02, VsmpsBHwHPReq2Valid
2037 * 0x04, VsafeHwHPReq2Valid
2038 * 0x08, VanaHwHPReq2Valid
2039 * 0x10, VpllHwHPReq2Valid
2040 * 0x20, Vaux1HwHPReq2Valid
2041 * 0x40, Vaux2HwHPReq2Valid
2042 * 0x80, Vaux3HwHPReq2Valid
2043 */
2044 REG_INIT(AB8505_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xff),
2045 /*
2046 * 0x08, VsmpsMHwHPReq2Valid
2047 */
2048 REG_INIT(AB8505_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x08),
2049 /*
2050 * 0x01, VsmpsCSwHPReqValid
2051 * 0x02, VarmSwHPReqValid
2052 * 0x04, VsmpsASwHPReqValid
2053 * 0x08, VsmpsBSwHPReqValid
2054 * 0x10, VsafeSwHPReqValid
2055 * 0x20, VanaSwHPReqValid
2056 * 0x40, VpllSwHPReqValid
2057 * 0x80, Vaux1SwHPReqValid
2058 */
2059 REG_INIT(AB8505_REGUSWHPREQVALID1, 0x03, 0x0d, 0xff),
2060 /*
2061 * 0x01, Vaux2SwHPReqValid
2062 * 0x02, Vaux3SwHPReqValid
2063 * 0x20, VsmpsMSwHPReqValid
2064 */
2065 REG_INIT(AB8505_REGUSWHPREQVALID2, 0x03, 0x0e, 0x23),
2066 /*
2067 * 0x02, SysClkReq2Valid1
2068 * 0x04, SysClkReq3Valid1
2069 * 0x08, SysClkReq4Valid1
2070 */
2071 REG_INIT(AB8505_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0x0e),
2072 /*
2073 * 0x02, SysClkReq2Valid2
2074 * 0x04, SysClkReq3Valid2
2075 * 0x08, SysClkReq4Valid2
2076 */
2077 REG_INIT(AB8505_REGUSYSCLKREQVALID2, 0x03, 0x10, 0x0e),
2078 /*
2079 * 0x01, Vaux4SwHPReqValid
2080 * 0x02, Vaux4HwHPReq2Valid
2081 * 0x04, Vaux4HwHPReq1Valid
2082 * 0x08, Vaux4SysClkReq1HPValid
2083 */
2084 REG_INIT(AB8505_REGUVAUX4REQVALID, 0x03, 0x11, 0x0f),
2085 /*
2086 * 0x02, VadcEna
2087 * 0x04, VintCore12Ena
2088 * 0x38, VintCore12Sel
2089 * 0x40, VintCore12LP
2090 * 0x80, VadcLP
2091 */
2092 REG_INIT(AB8505_REGUMISC1, 0x03, 0x80, 0xfe),
2093 /*
2094 * 0x02, VaudioEna
2095 * 0x04, VdmicEna
2096 * 0x08, Vamic1Ena
2097 * 0x10, Vamic2Ena
2098 */
2099 REG_INIT(AB8505_VAUDIOSUPPLY, 0x03, 0x83, 0x1e),
2100 /*
2101 * 0x01, Vamic1_dzout
2102 * 0x02, Vamic2_dzout
2103 */
2104 REG_INIT(AB8505_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
2105 /*
2106 * 0x03, VsmpsARegu
2107 * 0x0c, VsmpsASelCtrl
2108 * 0x10, VsmpsAAutoMode
2109 * 0x20, VsmpsAPWMMode
2110 */
2111 REG_INIT(AB8505_VSMPSAREGU, 0x04, 0x03, 0x3f),
2112 /*
2113 * 0x03, VsmpsBRegu
2114 * 0x0c, VsmpsBSelCtrl
2115 * 0x10, VsmpsBAutoMode
2116 * 0x20, VsmpsBPWMMode
2117 */
2118 REG_INIT(AB8505_VSMPSBREGU, 0x04, 0x04, 0x3f),
2119 /*
2120 * 0x03, VsafeRegu
2121 * 0x0c, VsafeSelCtrl
2122 * 0x10, VsafeAutoMode
2123 * 0x20, VsafePWMMode
2124 */
2125 REG_INIT(AB8505_VSAFEREGU, 0x04, 0x05, 0x3f),
2126 /*
2127 * 0x03, VpllRegu (NOTE! PRCMU register bits)
2128 * 0x0c, VanaRegu
2129 */
2130 REG_INIT(AB8505_VPLLVANAREGU, 0x04, 0x06, 0x0f),
2131 /*
2132 * 0x03, VextSupply1Regu
2133 * 0x0c, VextSupply2Regu
2134 * 0x30, VextSupply3Regu
2135 * 0x40, ExtSupply2Bypass
2136 * 0x80, ExtSupply3Bypass
2137 */
2138 REG_INIT(AB8505_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
2139 /*
2140 * 0x03, Vaux1Regu
2141 * 0x0c, Vaux2Regu
2142 */
2143 REG_INIT(AB8505_VAUX12REGU, 0x04, 0x09, 0x0f),
2144 /*
2145 * 0x0f, Vaux3Regu
2146 */
2147 REG_INIT(AB8505_VRF1VAUX3REGU, 0x04, 0x0a, 0x0f),
2148 /*
2149 * 0x3f, VsmpsASel1
2150 */
2151 REG_INIT(AB8505_VSMPSASEL1, 0x04, 0x13, 0x3f),
2152 /*
2153 * 0x3f, VsmpsASel2
2154 */
2155 REG_INIT(AB8505_VSMPSASEL2, 0x04, 0x14, 0x3f),
2156 /*
2157 * 0x3f, VsmpsASel3
2158 */
2159 REG_INIT(AB8505_VSMPSASEL3, 0x04, 0x15, 0x3f),
2160 /*
2161 * 0x3f, VsmpsBSel1
2162 */
2163 REG_INIT(AB8505_VSMPSBSEL1, 0x04, 0x17, 0x3f),
2164 /*
2165 * 0x3f, VsmpsBSel2
2166 */
2167 REG_INIT(AB8505_VSMPSBSEL2, 0x04, 0x18, 0x3f),
2168 /*
2169 * 0x3f, VsmpsBSel3
2170 */
2171 REG_INIT(AB8505_VSMPSBSEL3, 0x04, 0x19, 0x3f),
2172 /*
2173 * 0x7f, VsafeSel1
2174 */
2175 REG_INIT(AB8505_VSAFESEL1, 0x04, 0x1b, 0x7f),
2176 /*
2177 * 0x3f, VsafeSel2
2178 */
2179 REG_INIT(AB8505_VSAFESEL2, 0x04, 0x1c, 0x7f),
2180 /*
2181 * 0x3f, VsafeSel3
2182 */
2183 REG_INIT(AB8505_VSAFESEL3, 0x04, 0x1d, 0x7f),
2184 /*
2185 * 0x0f, Vaux1Sel
2186 */
2187 REG_INIT(AB8505_VAUX1SEL, 0x04, 0x1f, 0x0f),
2188 /*
2189 * 0x0f, Vaux2Sel
2190 */
2191 REG_INIT(AB8505_VAUX2SEL, 0x04, 0x20, 0x0f),
2192 /*
2193 * 0x07, Vaux3Sel
2194 * 0x30, VRF1Sel
2195 */
2196 REG_INIT(AB8505_VRF1VAUX3SEL, 0x04, 0x21, 0x37),
2197 /*
2198 * 0x03, Vaux4RequestCtrl
2199 */
2200 REG_INIT(AB8505_VAUX4REQCTRL, 0x04, 0x2d, 0x03),
2201 /*
2202 * 0x03, Vaux4Regu
2203 */
2204 REG_INIT(AB8505_VAUX4REGU, 0x04, 0x2e, 0x03),
2205 /*
2206 * 0x0f, Vaux4Sel
2207 */
2208 REG_INIT(AB8505_VAUX4SEL, 0x04, 0x2f, 0x0f),
2209 /*
2210 * 0x04, Vaux1Disch
2211 * 0x08, Vaux2Disch
2212 * 0x10, Vaux3Disch
2213 * 0x20, Vintcore12Disch
2214 * 0x40, VTVoutDisch
2215 * 0x80, VaudioDisch
2216 */
2217 REG_INIT(AB8505_REGUCTRLDISCH, 0x04, 0x43, 0xfc),
2218 /*
2219 * 0x02, VanaDisch
2220 * 0x04, VdmicPullDownEna
2221 * 0x10, VdmicDisch
2222 */
2223 REG_INIT(AB8505_REGUCTRLDISCH2, 0x04, 0x44, 0x16),
2224 /*
2225 * 0x01, Vaux4Disch
2226 */
2227 REG_INIT(AB8505_REGUCTRLDISCH3, 0x04, 0x48, 0x01),
2228 /*
2229 * 0x07, Vaux5Sel
2230 * 0x08, Vaux5LP
2231 * 0x10, Vaux5Ena
2232 * 0x20, Vaux5Disch
2233 * 0x40, Vaux5DisSfst
2234 * 0x80, Vaux5DisPulld
2235 */
2236 REG_INIT(AB8505_CTRLVAUX5, 0x01, 0x55, 0xff),
2237 /*
2238 * 0x07, Vaux6Sel
2239 * 0x08, Vaux6LP
2240 * 0x10, Vaux6Ena
2241 * 0x80, Vaux6DisPulld
2242 */
2243 REG_INIT(AB8505_CTRLVAUX6, 0x01, 0x56, 0x9f),
2244};
2245
Lee Jones8e6a8d72013-03-28 16:11:11 +00002246/* AB9540 register init */
2247static struct ab8500_reg_init ab9540_reg_init[] = {
2248 /*
2249 * 0x03, VarmRequestCtrl
2250 * 0x0c, VapeRequestCtrl
2251 * 0x30, Vsmps1RequestCtrl
2252 * 0xc0, Vsmps2RequestCtrl
2253 */
2254 REG_INIT(AB9540_REGUREQUESTCTRL1, 0x03, 0x03, 0xff),
2255 /*
2256 * 0x03, Vsmps3RequestCtrl
2257 * 0x0c, VpllRequestCtrl
2258 * 0x30, VanaRequestCtrl
2259 * 0xc0, VextSupply1RequestCtrl
2260 */
2261 REG_INIT(AB9540_REGUREQUESTCTRL2, 0x03, 0x04, 0xff),
2262 /*
2263 * 0x03, VextSupply2RequestCtrl
2264 * 0x0c, VextSupply3RequestCtrl
2265 * 0x30, Vaux1RequestCtrl
2266 * 0xc0, Vaux2RequestCtrl
2267 */
2268 REG_INIT(AB9540_REGUREQUESTCTRL3, 0x03, 0x05, 0xff),
2269 /*
2270 * 0x03, Vaux3RequestCtrl
2271 * 0x04, SwHPReq
2272 */
2273 REG_INIT(AB9540_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
2274 /*
2275 * 0x01, Vsmps1SysClkReq1HPValid
2276 * 0x02, Vsmps2SysClkReq1HPValid
2277 * 0x04, Vsmps3SysClkReq1HPValid
2278 * 0x08, VanaSysClkReq1HPValid
2279 * 0x10, VpllSysClkReq1HPValid
2280 * 0x20, Vaux1SysClkReq1HPValid
2281 * 0x40, Vaux2SysClkReq1HPValid
2282 * 0x80, Vaux3SysClkReq1HPValid
2283 */
2284 REG_INIT(AB9540_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xff),
2285 /*
2286 * 0x01, VapeSysClkReq1HPValid
2287 * 0x02, VarmSysClkReq1HPValid
2288 * 0x04, VbbSysClkReq1HPValid
2289 * 0x08, VmodSysClkReq1HPValid
2290 * 0x10, VextSupply1SysClkReq1HPValid
2291 * 0x20, VextSupply2SysClkReq1HPValid
2292 * 0x40, VextSupply3SysClkReq1HPValid
2293 */
2294 REG_INIT(AB9540_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x7f),
2295 /*
2296 * 0x01, Vsmps1HwHPReq1Valid
2297 * 0x02, Vsmps2HwHPReq1Valid
2298 * 0x04, Vsmps3HwHPReq1Valid
2299 * 0x08, VanaHwHPReq1Valid
2300 * 0x10, VpllHwHPReq1Valid
2301 * 0x20, Vaux1HwHPReq1Valid
2302 * 0x40, Vaux2HwHPReq1Valid
2303 * 0x80, Vaux3HwHPReq1Valid
2304 */
2305 REG_INIT(AB9540_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xff),
2306 /*
2307 * 0x01, VextSupply1HwHPReq1Valid
2308 * 0x02, VextSupply2HwHPReq1Valid
2309 * 0x04, VextSupply3HwHPReq1Valid
2310 * 0x08, VmodHwHPReq1Valid
2311 */
2312 REG_INIT(AB9540_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x0f),
2313 /*
2314 * 0x01, Vsmps1HwHPReq2Valid
2315 * 0x02, Vsmps2HwHPReq2Valid
2316 * 0x03, Vsmps3HwHPReq2Valid
2317 * 0x08, VanaHwHPReq2Valid
2318 * 0x10, VpllHwHPReq2Valid
2319 * 0x20, Vaux1HwHPReq2Valid
2320 * 0x40, Vaux2HwHPReq2Valid
2321 * 0x80, Vaux3HwHPReq2Valid
2322 */
2323 REG_INIT(AB9540_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xff),
2324 /*
2325 * 0x01, VextSupply1HwHPReq2Valid
2326 * 0x02, VextSupply2HwHPReq2Valid
2327 * 0x04, VextSupply3HwHPReq2Valid
2328 * 0x08, VmodHwHPReq2Valid
2329 */
2330 REG_INIT(AB9540_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x0f),
2331 /*
2332 * 0x01, VapeSwHPReqValid
2333 * 0x02, VarmSwHPReqValid
2334 * 0x04, Vsmps1SwHPReqValid
2335 * 0x08, Vsmps2SwHPReqValid
2336 * 0x10, Vsmps3SwHPReqValid
2337 * 0x20, VanaSwHPReqValid
2338 * 0x40, VpllSwHPReqValid
2339 * 0x80, Vaux1SwHPReqValid
2340 */
2341 REG_INIT(AB9540_REGUSWHPREQVALID1, 0x03, 0x0d, 0xff),
2342 /*
2343 * 0x01, Vaux2SwHPReqValid
2344 * 0x02, Vaux3SwHPReqValid
2345 * 0x04, VextSupply1SwHPReqValid
2346 * 0x08, VextSupply2SwHPReqValid
2347 * 0x10, VextSupply3SwHPReqValid
2348 * 0x20, VmodSwHPReqValid
2349 */
2350 REG_INIT(AB9540_REGUSWHPREQVALID2, 0x03, 0x0e, 0x3f),
2351 /*
2352 * 0x02, SysClkReq2Valid1
2353 * ...
2354 * 0x80, SysClkReq8Valid1
2355 */
2356 REG_INIT(AB9540_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0xfe),
2357 /*
2358 * 0x02, SysClkReq2Valid2
2359 * ...
2360 * 0x80, SysClkReq8Valid2
2361 */
2362 REG_INIT(AB9540_REGUSYSCLKREQVALID2, 0x03, 0x10, 0xfe),
2363 /*
2364 * 0x01, Vaux4SwHPReqValid
2365 * 0x02, Vaux4HwHPReq2Valid
2366 * 0x04, Vaux4HwHPReq1Valid
2367 * 0x08, Vaux4SysClkReq1HPValid
2368 */
2369 REG_INIT(AB9540_REGUVAUX4REQVALID, 0x03, 0x11, 0x0f),
2370 /*
2371 * 0x02, VTVoutEna
2372 * 0x04, Vintcore12Ena
2373 * 0x38, Vintcore12Sel
2374 * 0x40, Vintcore12LP
2375 * 0x80, VTVoutLP
2376 */
2377 REG_INIT(AB9540_REGUMISC1, 0x03, 0x80, 0xfe),
2378 /*
2379 * 0x02, VaudioEna
2380 * 0x04, VdmicEna
2381 * 0x08, Vamic1Ena
2382 * 0x10, Vamic2Ena
2383 */
2384 REG_INIT(AB9540_VAUDIOSUPPLY, 0x03, 0x83, 0x1e),
2385 /*
2386 * 0x01, Vamic1_dzout
2387 * 0x02, Vamic2_dzout
2388 */
2389 REG_INIT(AB9540_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
2390 /*
2391 * 0x03, Vsmps1Regu
2392 * 0x0c, Vsmps1SelCtrl
2393 * 0x10, Vsmps1AutoMode
2394 * 0x20, Vsmps1PWMMode
2395 */
2396 REG_INIT(AB9540_VSMPS1REGU, 0x04, 0x03, 0x3f),
2397 /*
2398 * 0x03, Vsmps2Regu
2399 * 0x0c, Vsmps2SelCtrl
2400 * 0x10, Vsmps2AutoMode
2401 * 0x20, Vsmps2PWMMode
2402 */
2403 REG_INIT(AB9540_VSMPS2REGU, 0x04, 0x04, 0x3f),
2404 /*
2405 * 0x03, Vsmps3Regu
2406 * 0x0c, Vsmps3SelCtrl
2407 * NOTE! PRCMU register
2408 */
2409 REG_INIT(AB9540_VSMPS3REGU, 0x04, 0x05, 0x0f),
2410 /*
2411 * 0x03, VpllRegu
2412 * 0x0c, VanaRegu
2413 */
2414 REG_INIT(AB9540_VPLLVANAREGU, 0x04, 0x06, 0x0f),
2415 /*
2416 * 0x03, VextSupply1Regu
2417 * 0x0c, VextSupply2Regu
2418 * 0x30, VextSupply3Regu
2419 * 0x40, ExtSupply2Bypass
2420 * 0x80, ExtSupply3Bypass
2421 */
2422 REG_INIT(AB9540_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
2423 /*
2424 * 0x03, Vaux1Regu
2425 * 0x0c, Vaux2Regu
2426 */
2427 REG_INIT(AB9540_VAUX12REGU, 0x04, 0x09, 0x0f),
2428 /*
2429 * 0x0c, Vrf1Regu
2430 * 0x03, Vaux3Regu
2431 */
2432 REG_INIT(AB9540_VRF1VAUX3REGU, 0x04, 0x0a, 0x0f),
2433 /*
2434 * 0x3f, Vsmps1Sel1
2435 */
2436 REG_INIT(AB9540_VSMPS1SEL1, 0x04, 0x13, 0x3f),
2437 /*
2438 * 0x3f, Vsmps1Sel2
2439 */
2440 REG_INIT(AB9540_VSMPS1SEL2, 0x04, 0x14, 0x3f),
2441 /*
2442 * 0x3f, Vsmps1Sel3
2443 */
2444 REG_INIT(AB9540_VSMPS1SEL3, 0x04, 0x15, 0x3f),
2445 /*
2446 * 0x3f, Vsmps2Sel1
2447 */
2448 REG_INIT(AB9540_VSMPS2SEL1, 0x04, 0x17, 0x3f),
2449 /*
2450 * 0x3f, Vsmps2Sel2
2451 */
2452 REG_INIT(AB9540_VSMPS2SEL2, 0x04, 0x18, 0x3f),
2453 /*
2454 * 0x3f, Vsmps2Sel3
2455 */
2456 REG_INIT(AB9540_VSMPS2SEL3, 0x04, 0x19, 0x3f),
2457 /*
2458 * 0x7f, Vsmps3Sel1
2459 * NOTE! PRCMU register
2460 */
2461 REG_INIT(AB9540_VSMPS3SEL1, 0x04, 0x1b, 0x7f),
2462 /*
2463 * 0x7f, Vsmps3Sel2
2464 * NOTE! PRCMU register
2465 */
2466 REG_INIT(AB9540_VSMPS3SEL2, 0x04, 0x1c, 0x7f),
2467 /*
2468 * 0x0f, Vaux1Sel
2469 */
2470 REG_INIT(AB9540_VAUX1SEL, 0x04, 0x1f, 0x0f),
2471 /*
2472 * 0x0f, Vaux2Sel
2473 */
2474 REG_INIT(AB9540_VAUX2SEL, 0x04, 0x20, 0x0f),
2475 /*
2476 * 0x07, Vaux3Sel
2477 * 0x30, Vrf1Sel
2478 */
2479 REG_INIT(AB9540_VRF1VAUX3SEL, 0x04, 0x21, 0x37),
2480 /*
2481 * 0x01, VextSupply12LP
2482 */
2483 REG_INIT(AB9540_REGUCTRL2SPARE, 0x04, 0x22, 0x01),
2484 /*
2485 * 0x03, Vaux4RequestCtrl
2486 */
2487 REG_INIT(AB9540_VAUX4REQCTRL, 0x04, 0x2d, 0x03),
2488 /*
2489 * 0x03, Vaux4Regu
2490 */
2491 REG_INIT(AB9540_VAUX4REGU, 0x04, 0x2e, 0x03),
2492 /*
2493 * 0x08, Vaux4Sel
2494 */
2495 REG_INIT(AB9540_VAUX4SEL, 0x04, 0x2f, 0x0f),
2496 /*
2497 * 0x01, VpllDisch
2498 * 0x02, Vrf1Disch
2499 * 0x04, Vaux1Disch
2500 * 0x08, Vaux2Disch
2501 * 0x10, Vaux3Disch
2502 * 0x20, Vintcore12Disch
2503 * 0x40, VTVoutDisch
2504 * 0x80, VaudioDisch
2505 */
2506 REG_INIT(AB9540_REGUCTRLDISCH, 0x04, 0x43, 0xff),
2507 /*
2508 * 0x01, VsimDisch
2509 * 0x02, VanaDisch
2510 * 0x04, VdmicPullDownEna
2511 * 0x08, VpllPullDownEna
2512 * 0x10, VdmicDisch
2513 */
2514 REG_INIT(AB9540_REGUCTRLDISCH2, 0x04, 0x44, 0x1f),
2515 /*
2516 * 0x01, Vaux4Disch
2517 */
2518 REG_INIT(AB9540_REGUCTRLDISCH3, 0x04, 0x48, 0x01),
2519};
2520
Lee Jonesae0a9a32013-03-28 16:11:16 +00002521/* AB8540 register init */
2522static struct ab8500_reg_init ab8540_reg_init[] = {
2523 /*
2524 * 0x01, VSimSycClkReq1Valid
2525 * 0x02, VSimSycClkReq2Valid
2526 * 0x04, VSimSycClkReq3Valid
2527 * 0x08, VSimSycClkReq4Valid
2528 * 0x10, VSimSycClkReq5Valid
2529 * 0x20, VSimSycClkReq6Valid
2530 * 0x40, VSimSycClkReq7Valid
2531 * 0x80, VSimSycClkReq8Valid
2532 */
2533 REG_INIT(AB8540_VSIMSYSCLKCTRL, 0x02, 0x33, 0xff),
2534 /*
2535 * 0x03, VarmRequestCtrl
2536 * 0x0c, VapeRequestCtrl
2537 * 0x30, Vsmps1RequestCtrl
2538 * 0xc0, Vsmps2RequestCtrl
2539 */
2540 REG_INIT(AB8540_REGUREQUESTCTRL1, 0x03, 0x03, 0xff),
2541 /*
2542 * 0x03, Vsmps3RequestCtrl
2543 * 0x0c, VpllRequestCtrl
2544 * 0x30, VanaRequestCtrl
2545 * 0xc0, VextSupply1RequestCtrl
2546 */
2547 REG_INIT(AB8540_REGUREQUESTCTRL2, 0x03, 0x04, 0xff),
2548 /*
2549 * 0x03, VextSupply2RequestCtrl
2550 * 0x0c, VextSupply3RequestCtrl
2551 * 0x30, Vaux1RequestCtrl
2552 * 0xc0, Vaux2RequestCtrl
2553 */
2554 REG_INIT(AB8540_REGUREQUESTCTRL3, 0x03, 0x05, 0xff),
2555 /*
2556 * 0x03, Vaux3RequestCtrl
2557 * 0x04, SwHPReq
2558 */
2559 REG_INIT(AB8540_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
2560 /*
2561 * 0x01, Vsmps1SysClkReq1HPValid
2562 * 0x02, Vsmps2SysClkReq1HPValid
2563 * 0x04, Vsmps3SysClkReq1HPValid
2564 * 0x08, VanaSysClkReq1HPValid
2565 * 0x10, VpllSysClkReq1HPValid
2566 * 0x20, Vaux1SysClkReq1HPValid
2567 * 0x40, Vaux2SysClkReq1HPValid
2568 * 0x80, Vaux3SysClkReq1HPValid
2569 */
2570 REG_INIT(AB8540_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xff),
2571 /*
2572 * 0x01, VapeSysClkReq1HPValid
2573 * 0x02, VarmSysClkReq1HPValid
2574 * 0x04, VbbSysClkReq1HPValid
2575 * 0x10, VextSupply1SysClkReq1HPValid
2576 * 0x20, VextSupply2SysClkReq1HPValid
2577 * 0x40, VextSupply3SysClkReq1HPValid
2578 */
2579 REG_INIT(AB8540_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x77),
2580 /*
2581 * 0x01, Vsmps1HwHPReq1Valid
2582 * 0x02, Vsmps2HwHPReq1Valid
2583 * 0x04, Vsmps3HwHPReq1Valid
2584 * 0x08, VanaHwHPReq1Valid
2585 * 0x10, VpllHwHPReq1Valid
2586 * 0x20, Vaux1HwHPReq1Valid
2587 * 0x40, Vaux2HwHPReq1Valid
2588 * 0x80, Vaux3HwHPReq1Valid
2589 */
2590 REG_INIT(AB8540_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xff),
2591 /*
2592 * 0x01, VextSupply1HwHPReq1Valid
2593 * 0x02, VextSupply2HwHPReq1Valid
2594 * 0x04, VextSupply3HwHPReq1Valid
2595 */
2596 REG_INIT(AB8540_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x07),
2597 /*
2598 * 0x01, Vsmps1HwHPReq2Valid
2599 * 0x02, Vsmps2HwHPReq2Valid
2600 * 0x03, Vsmps3HwHPReq2Valid
2601 * 0x08, VanaHwHPReq2Valid
2602 * 0x10, VpllHwHPReq2Valid
2603 * 0x20, Vaux1HwHPReq2Valid
2604 * 0x40, Vaux2HwHPReq2Valid
2605 * 0x80, Vaux3HwHPReq2Valid
2606 */
2607 REG_INIT(AB8540_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xff),
2608 /*
2609 * 0x01, VextSupply1HwHPReq2Valid
2610 * 0x02, VextSupply2HwHPReq2Valid
2611 * 0x04, VextSupply3HwHPReq2Valid
2612 */
2613 REG_INIT(AB8540_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x07),
2614 /*
2615 * 0x01, VapeSwHPReqValid
2616 * 0x02, VarmSwHPReqValid
2617 * 0x04, Vsmps1SwHPReqValid
2618 * 0x08, Vsmps2SwHPReqValid
2619 * 0x10, Vsmps3SwHPReqValid
2620 * 0x20, VanaSwHPReqValid
2621 * 0x40, VpllSwHPReqValid
2622 * 0x80, Vaux1SwHPReqValid
2623 */
2624 REG_INIT(AB8540_REGUSWHPREQVALID1, 0x03, 0x0d, 0xff),
2625 /*
2626 * 0x01, Vaux2SwHPReqValid
2627 * 0x02, Vaux3SwHPReqValid
2628 * 0x04, VextSupply1SwHPReqValid
2629 * 0x08, VextSupply2SwHPReqValid
2630 * 0x10, VextSupply3SwHPReqValid
2631 */
2632 REG_INIT(AB8540_REGUSWHPREQVALID2, 0x03, 0x0e, 0x1f),
2633 /*
2634 * 0x02, SysClkReq2Valid1
2635 * ...
2636 * 0x80, SysClkReq8Valid1
2637 */
2638 REG_INIT(AB8540_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0xff),
2639 /*
2640 * 0x02, SysClkReq2Valid2
2641 * ...
2642 * 0x80, SysClkReq8Valid2
2643 */
2644 REG_INIT(AB8540_REGUSYSCLKREQVALID2, 0x03, 0x10, 0xff),
2645 /*
2646 * 0x01, Vaux4SwHPReqValid
2647 * 0x02, Vaux4HwHPReq2Valid
2648 * 0x04, Vaux4HwHPReq1Valid
2649 * 0x08, Vaux4SysClkReq1HPValid
2650 */
2651 REG_INIT(AB8540_REGUVAUX4REQVALID, 0x03, 0x11, 0x0f),
2652 /*
2653 * 0x01, Vaux5SwHPReqValid
2654 * 0x02, Vaux5HwHPReq2Valid
2655 * 0x04, Vaux5HwHPReq1Valid
2656 * 0x08, Vaux5SysClkReq1HPValid
2657 */
2658 REG_INIT(AB8540_REGUVAUX5REQVALID, 0x03, 0x12, 0x0f),
2659 /*
2660 * 0x01, Vaux6SwHPReqValid
2661 * 0x02, Vaux6HwHPReq2Valid
2662 * 0x04, Vaux6HwHPReq1Valid
2663 * 0x08, Vaux6SysClkReq1HPValid
2664 */
2665 REG_INIT(AB8540_REGUVAUX6REQVALID, 0x03, 0x13, 0x0f),
2666 /*
2667 * 0x01, VclkbSwHPReqValid
2668 * 0x02, VclkbHwHPReq2Valid
2669 * 0x04, VclkbHwHPReq1Valid
2670 * 0x08, VclkbSysClkReq1HPValid
2671 */
2672 REG_INIT(AB8540_REGUVCLKBREQVALID, 0x03, 0x14, 0x0f),
2673 /*
2674 * 0x01, Vrf1SwHPReqValid
2675 * 0x02, Vrf1HwHPReq2Valid
2676 * 0x04, Vrf1HwHPReq1Valid
2677 * 0x08, Vrf1SysClkReq1HPValid
2678 */
2679 REG_INIT(AB8540_REGUVRF1REQVALID, 0x03, 0x15, 0x0f),
2680 /*
2681 * 0x02, VTVoutEna
2682 * 0x04, Vintcore12Ena
2683 * 0x38, Vintcore12Sel
2684 * 0x40, Vintcore12LP
2685 * 0x80, VTVoutLP
2686 */
2687 REG_INIT(AB8540_REGUMISC1, 0x03, 0x80, 0xfe),
2688 /*
2689 * 0x02, VaudioEna
2690 * 0x04, VdmicEna
2691 * 0x08, Vamic1Ena
2692 * 0x10, Vamic2Ena
2693 * 0x20, Vamic12LP
2694 * 0xC0, VdmicSel
2695 */
2696 REG_INIT(AB8540_VAUDIOSUPPLY, 0x03, 0x83, 0xfe),
2697 /*
2698 * 0x01, Vamic1_dzout
2699 * 0x02, Vamic2_dzout
2700 */
2701 REG_INIT(AB8540_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
2702 /*
2703 * 0x07, VHSICSel
2704 * 0x08, VHSICOffState
2705 * 0x10, VHSIEna
2706 * 0x20, VHSICLP
2707 */
2708 REG_INIT(AB8540_VHSIC, 0x03, 0x87, 0x3f),
2709 /*
2710 * 0x07, VSDIOSel
2711 * 0x08, VSDIOOffState
2712 * 0x10, VSDIOEna
2713 * 0x20, VSDIOLP
2714 */
2715 REG_INIT(AB8540_VSDIO, 0x03, 0x88, 0x3f),
2716 /*
2717 * 0x03, Vsmps1Regu
2718 * 0x0c, Vsmps1SelCtrl
2719 * 0x10, Vsmps1AutoMode
2720 * 0x20, Vsmps1PWMMode
2721 */
2722 REG_INIT(AB8540_VSMPS1REGU, 0x04, 0x03, 0x3f),
2723 /*
2724 * 0x03, Vsmps2Regu
2725 * 0x0c, Vsmps2SelCtrl
2726 * 0x10, Vsmps2AutoMode
2727 * 0x20, Vsmps2PWMMode
2728 */
2729 REG_INIT(AB8540_VSMPS2REGU, 0x04, 0x04, 0x3f),
2730 /*
2731 * 0x03, Vsmps3Regu
2732 * 0x0c, Vsmps3SelCtrl
2733 * 0x10, Vsmps3AutoMode
2734 * 0x20, Vsmps3PWMMode
2735 * NOTE! PRCMU register
2736 */
2737 REG_INIT(AB8540_VSMPS3REGU, 0x04, 0x05, 0x0f),
2738 /*
2739 * 0x03, VpllRegu
2740 * 0x0c, VanaRegu
2741 */
2742 REG_INIT(AB8540_VPLLVANAREGU, 0x04, 0x06, 0x0f),
2743 /*
2744 * 0x03, VextSupply1Regu
2745 * 0x0c, VextSupply2Regu
2746 * 0x30, VextSupply3Regu
2747 * 0x40, ExtSupply2Bypass
2748 * 0x80, ExtSupply3Bypass
2749 */
2750 REG_INIT(AB8540_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
2751 /*
2752 * 0x03, Vaux1Regu
2753 * 0x0c, Vaux2Regu
2754 */
2755 REG_INIT(AB8540_VAUX12REGU, 0x04, 0x09, 0x0f),
2756 /*
2757 * 0x0c, VRF1Regu
2758 * 0x03, Vaux3Regu
2759 */
2760 REG_INIT(AB8540_VRF1VAUX3REGU, 0x04, 0x0a, 0x0f),
2761 /*
2762 * 0x3f, Vsmps1Sel1
2763 */
2764 REG_INIT(AB8540_VSMPS1SEL1, 0x04, 0x13, 0x3f),
2765 /*
2766 * 0x3f, Vsmps1Sel2
2767 */
2768 REG_INIT(AB8540_VSMPS1SEL2, 0x04, 0x14, 0x3f),
2769 /*
2770 * 0x3f, Vsmps1Sel3
2771 */
2772 REG_INIT(AB8540_VSMPS1SEL3, 0x04, 0x15, 0x3f),
2773 /*
2774 * 0x3f, Vsmps2Sel1
2775 */
2776 REG_INIT(AB8540_VSMPS2SEL1, 0x04, 0x17, 0x3f),
2777 /*
2778 * 0x3f, Vsmps2Sel2
2779 */
2780 REG_INIT(AB8540_VSMPS2SEL2, 0x04, 0x18, 0x3f),
2781 /*
2782 * 0x3f, Vsmps2Sel3
2783 */
2784 REG_INIT(AB8540_VSMPS2SEL3, 0x04, 0x19, 0x3f),
2785 /*
2786 * 0x7f, Vsmps3Sel1
2787 * NOTE! PRCMU register
2788 */
2789 REG_INIT(AB8540_VSMPS3SEL1, 0x04, 0x1b, 0x7f),
2790 /*
2791 * 0x7f, Vsmps3Sel2
2792 * NOTE! PRCMU register
2793 */
2794 REG_INIT(AB8540_VSMPS3SEL2, 0x04, 0x1c, 0x7f),
2795 /*
2796 * 0x0f, Vaux1Sel
2797 */
2798 REG_INIT(AB8540_VAUX1SEL, 0x04, 0x1f, 0x0f),
2799 /*
2800 * 0x0f, Vaux2Sel
2801 */
2802 REG_INIT(AB8540_VAUX2SEL, 0x04, 0x20, 0x0f),
2803 /*
2804 * 0x07, Vaux3Sel
2805 * 0x70, Vrf1Sel
2806 */
2807 REG_INIT(AB8540_VRF1VAUX3SEL, 0x04, 0x21, 0x77),
2808 /*
2809 * 0x01, VextSupply12LP
2810 */
2811 REG_INIT(AB8540_REGUCTRL2SPARE, 0x04, 0x22, 0x01),
2812 /*
2813 * 0x07, Vanasel
2814 * 0x30, Vpllsel
2815 */
2816 REG_INIT(AB8540_VANAVPLLSEL, 0x04, 0x29, 0x37),
2817 /*
2818 * 0x03, Vaux4RequestCtrl
2819 */
2820 REG_INIT(AB8540_VAUX4REQCTRL, 0x04, 0x2d, 0x03),
2821 /*
2822 * 0x03, Vaux4Regu
2823 */
2824 REG_INIT(AB8540_VAUX4REGU, 0x04, 0x2e, 0x03),
2825 /*
2826 * 0x0f, Vaux4Sel
2827 */
2828 REG_INIT(AB8540_VAUX4SEL, 0x04, 0x2f, 0x0f),
2829 /*
2830 * 0x03, Vaux5RequestCtrl
2831 */
2832 REG_INIT(AB8540_VAUX5REQCTRL, 0x04, 0x31, 0x03),
2833 /*
2834 * 0x03, Vaux5Regu
2835 */
2836 REG_INIT(AB8540_VAUX5REGU, 0x04, 0x32, 0x03),
2837 /*
2838 * 0x3f, Vaux5Sel
2839 */
2840 REG_INIT(AB8540_VAUX5SEL, 0x04, 0x33, 0x3f),
2841 /*
2842 * 0x03, Vaux6RequestCtrl
2843 */
2844 REG_INIT(AB8540_VAUX6REQCTRL, 0x04, 0x34, 0x03),
2845 /*
2846 * 0x03, Vaux6Regu
2847 */
2848 REG_INIT(AB8540_VAUX6REGU, 0x04, 0x35, 0x03),
2849 /*
2850 * 0x3f, Vaux6Sel
2851 */
2852 REG_INIT(AB8540_VAUX6SEL, 0x04, 0x36, 0x3f),
2853 /*
2854 * 0x03, VCLKBRequestCtrl
2855 */
2856 REG_INIT(AB8540_VCLKBREQCTRL, 0x04, 0x37, 0x03),
2857 /*
2858 * 0x03, VCLKBRegu
2859 */
2860 REG_INIT(AB8540_VCLKBREGU, 0x04, 0x38, 0x03),
2861 /*
2862 * 0x07, VCLKBSel
2863 */
2864 REG_INIT(AB8540_VCLKBSEL, 0x04, 0x39, 0x07),
2865 /*
2866 * 0x03, Vrf1RequestCtrl
2867 */
2868 REG_INIT(AB8540_VRF1REQCTRL, 0x04, 0x3a, 0x03),
2869 /*
2870 * 0x01, VpllDisch
2871 * 0x02, Vrf1Disch
2872 * 0x04, Vaux1Disch
2873 * 0x08, Vaux2Disch
2874 * 0x10, Vaux3Disch
2875 * 0x20, Vintcore12Disch
2876 * 0x40, VTVoutDisch
2877 * 0x80, VaudioDisch
2878 */
2879 REG_INIT(AB8540_REGUCTRLDISCH, 0x04, 0x43, 0xff),
2880 /*
2881 * 0x02, VanaDisch
2882 * 0x04, VdmicPullDownEna
2883 * 0x08, VpllPullDownEna
2884 * 0x10, VdmicDisch
2885 */
2886 REG_INIT(AB8540_REGUCTRLDISCH2, 0x04, 0x44, 0x1e),
2887 /*
2888 * 0x01, Vaux4Disch
2889 */
2890 REG_INIT(AB8540_REGUCTRLDISCH3, 0x04, 0x48, 0x01),
2891 /*
2892 * 0x01, Vaux5Disch
2893 * 0x02, Vaux6Disch
2894 * 0x04, VCLKBDisch
2895 */
2896 REG_INIT(AB8540_REGUCTRLDISCH4, 0x04, 0x49, 0x07),
2897};
2898
Lee Jonesda45edc2013-04-02 13:24:20 +01002899static struct of_regulator_match ab8500_regulator_match[] = {
2900 { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB8500_LDO_AUX1, },
2901 { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB8500_LDO_AUX2, },
2902 { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB8500_LDO_AUX3, },
2903 { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB8500_LDO_INTCORE, },
2904 { .name = "ab8500_ldo_tvout", .driver_data = (void *) AB8500_LDO_TVOUT, },
2905 { .name = "ab8500_ldo_audio", .driver_data = (void *) AB8500_LDO_AUDIO, },
2906 { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB8500_LDO_ANAMIC1, },
2907 { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB8500_LDO_ANAMIC2, },
2908 { .name = "ab8500_ldo_dmic", .driver_data = (void *) AB8500_LDO_DMIC, },
2909 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB8500_LDO_ANA, },
2910};
2911
2912static struct of_regulator_match ab8505_regulator_match[] = {
2913 { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB8505_LDO_AUX1, },
2914 { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB8505_LDO_AUX2, },
2915 { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB8505_LDO_AUX3, },
2916 { .name = "ab8500_ldo_aux4", .driver_data = (void *) AB8505_LDO_AUX4, },
2917 { .name = "ab8500_ldo_aux5", .driver_data = (void *) AB8505_LDO_AUX5, },
2918 { .name = "ab8500_ldo_aux6", .driver_data = (void *) AB8505_LDO_AUX6, },
2919 { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB8505_LDO_INTCORE, },
2920 { .name = "ab8500_ldo_adc", .driver_data = (void *) AB8505_LDO_ADC, },
2921 { .name = "ab8500_ldo_audio", .driver_data = (void *) AB8505_LDO_AUDIO, },
2922 { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB8505_LDO_ANAMIC1, },
2923 { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB8505_LDO_ANAMIC2, },
2924 { .name = "ab8500_ldo_aux8", .driver_data = (void *) AB8505_LDO_AUX8, },
2925 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB8505_LDO_ANA, },
2926};
2927
2928static struct of_regulator_match ab8540_regulator_match[] = {
2929 { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB8540_LDO_AUX1, },
2930 { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB8540_LDO_AUX2, },
2931 { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB8540_LDO_AUX3, },
2932 { .name = "ab8500_ldo_aux4", .driver_data = (void *) AB8540_LDO_AUX4, },
2933 { .name = "ab8500_ldo_aux5", .driver_data = (void *) AB8540_LDO_AUX5, },
2934 { .name = "ab8500_ldo_aux6", .driver_data = (void *) AB8540_LDO_AUX6, },
2935 { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB8540_LDO_INTCORE, },
2936 { .name = "ab8500_ldo_tvout", .driver_data = (void *) AB8540_LDO_TVOUT, },
2937 { .name = "ab8500_ldo_audio", .driver_data = (void *) AB8540_LDO_AUDIO, },
2938 { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB8540_LDO_ANAMIC1, },
2939 { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB8540_LDO_ANAMIC2, },
2940 { .name = "ab8500_ldo_dmic", .driver_data = (void *) AB8540_LDO_DMIC, },
2941 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB8540_LDO_ANA, },
2942 { .name = "ab8500_ldo_sdio", .driver_data = (void *) AB8540_LDO_SDIO, },
2943};
2944
2945static struct of_regulator_match ab9540_regulator_match[] = {
2946 { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB9540_LDO_AUX1, },
2947 { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB9540_LDO_AUX2, },
2948 { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB9540_LDO_AUX3, },
2949 { .name = "ab8500_ldo_aux4", .driver_data = (void *) AB9540_LDO_AUX4, },
2950 { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB9540_LDO_INTCORE, },
2951 { .name = "ab8500_ldo_tvout", .driver_data = (void *) AB9540_LDO_TVOUT, },
2952 { .name = "ab8500_ldo_audio", .driver_data = (void *) AB9540_LDO_AUDIO, },
2953 { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB9540_LDO_ANAMIC1, },
2954 { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB9540_LDO_ANAMIC2, },
2955 { .name = "ab8500_ldo_dmic", .driver_data = (void *) AB9540_LDO_DMIC, },
2956 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB9540_LDO_ANA, },
2957};
2958
Lee Jones33aeb492013-04-02 13:24:14 +01002959static struct {
2960 struct ab8500_regulator_info *info;
2961 int info_size;
2962 struct ab8500_reg_init *init;
2963 int init_size;
2964 struct of_regulator_match *match;
2965 int match_size;
2966} abx500_regulator;
2967
Lee Jonesda45edc2013-04-02 13:24:20 +01002968static void abx500_get_regulator_info(struct ab8500 *ab8500)
2969{
2970 if (is_ab9540(ab8500)) {
2971 abx500_regulator.info = ab9540_regulator_info;
2972 abx500_regulator.info_size = ARRAY_SIZE(ab9540_regulator_info);
2973 abx500_regulator.init = ab9540_reg_init;
2974 abx500_regulator.init_size = AB9540_NUM_REGULATOR_REGISTERS;
2975 abx500_regulator.match = ab9540_regulator_match;
2976 abx500_regulator.match_size = ARRAY_SIZE(ab9540_regulator_match);
2977 } else if (is_ab8505(ab8500)) {
2978 abx500_regulator.info = ab8505_regulator_info;
2979 abx500_regulator.info_size = ARRAY_SIZE(ab8505_regulator_info);
2980 abx500_regulator.init = ab8505_reg_init;
2981 abx500_regulator.init_size = AB8505_NUM_REGULATOR_REGISTERS;
2982 abx500_regulator.match = ab8505_regulator_match;
2983 abx500_regulator.match_size = ARRAY_SIZE(ab8505_regulator_match);
2984 } else if (is_ab8540(ab8500)) {
2985 abx500_regulator.info = ab8540_regulator_info;
2986 abx500_regulator.info_size = ARRAY_SIZE(ab8540_regulator_info);
2987 abx500_regulator.init = ab8540_reg_init;
2988 abx500_regulator.init_size = AB8540_NUM_REGULATOR_REGISTERS;
2989 abx500_regulator.match = ab8540_regulator_match;
2990 abx500_regulator.match_size = ARRAY_SIZE(ab8540_regulator_match);
2991 } else {
2992 abx500_regulator.info = ab8500_regulator_info;
2993 abx500_regulator.info_size = ARRAY_SIZE(ab8500_regulator_info);
2994 abx500_regulator.init = ab8500_reg_init;
2995 abx500_regulator.init_size = AB8500_NUM_REGULATOR_REGISTERS;
2996 abx500_regulator.match = ab8500_regulator_match;
2997 abx500_regulator.match_size = ARRAY_SIZE(ab8500_regulator_match);
2998 }
2999}
3000
Lee Jones3c1b8432013-03-21 15:59:01 +00003001static int ab8500_regulator_init_registers(struct platform_device *pdev,
3002 int id, int mask, int value)
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003003{
Lee Jones33aeb492013-04-02 13:24:14 +01003004 struct ab8500_reg_init *reg_init = abx500_regulator.init;
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003005 int err;
3006
Lee Jones3c1b8432013-03-21 15:59:01 +00003007 BUG_ON(value & ~mask);
Lee Jonesb54969a2013-03-28 16:11:10 +00003008 BUG_ON(mask & ~reg_init[id].mask);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003009
Lee Jones3c1b8432013-03-21 15:59:01 +00003010 /* initialize register */
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003011 err = abx500_mask_and_set_register_interruptible(
3012 &pdev->dev,
Lee Jonesb54969a2013-03-28 16:11:10 +00003013 reg_init[id].bank,
3014 reg_init[id].addr,
Lee Jones3c1b8432013-03-21 15:59:01 +00003015 mask, value);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003016 if (err < 0) {
3017 dev_err(&pdev->dev,
3018 "Failed to initialize 0x%02x, 0x%02x.\n",
Lee Jonesb54969a2013-03-28 16:11:10 +00003019 reg_init[id].bank,
3020 reg_init[id].addr);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003021 return err;
3022 }
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003023 dev_vdbg(&pdev->dev,
Lee Jones3c1b8432013-03-21 15:59:01 +00003024 " init: 0x%02x, 0x%02x, 0x%02x, 0x%02x\n",
Lee Jonesb54969a2013-03-28 16:11:10 +00003025 reg_init[id].bank,
3026 reg_init[id].addr,
Lee Jones3c1b8432013-03-21 15:59:01 +00003027 mask, value);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003028
3029 return 0;
3030}
3031
Bill Pembertona5023572012-11-19 13:22:22 -05003032static int ab8500_regulator_register(struct platform_device *pdev,
Lee Jonesb54969a2013-03-28 16:11:10 +00003033 struct regulator_init_data *init_data,
Lee Jonesb54969a2013-03-28 16:11:10 +00003034 int id, struct device_node *np)
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003035{
Lee Jones8e6a8d72013-03-28 16:11:11 +00003036 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003037 struct ab8500_regulator_info *info = NULL;
3038 struct regulator_config config = { };
3039 int err;
3040
3041 /* assign per-regulator data */
Lee Jones33aeb492013-04-02 13:24:14 +01003042 info = &abx500_regulator.info[id];
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003043 info->dev = &pdev->dev;
3044
3045 config.dev = &pdev->dev;
3046 config.init_data = init_data;
3047 config.driver_data = info;
3048 config.of_node = np;
3049
3050 /* fix for hardware before ab8500v2.0 */
Lee Jones8e6a8d72013-03-28 16:11:11 +00003051 if (is_ab8500_1p1_or_earlier(ab8500)) {
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003052 if (info->desc.id == AB8500_LDO_AUX3) {
3053 info->desc.n_voltages =
3054 ARRAY_SIZE(ldo_vauxn_voltages);
Axel Linec1cc4d2012-05-20 10:33:35 +08003055 info->desc.volt_table = ldo_vauxn_voltages;
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003056 info->voltage_mask = 0xf;
3057 }
3058 }
3059
3060 /* register regulator with framework */
3061 info->regulator = regulator_register(&info->desc, &config);
3062 if (IS_ERR(info->regulator)) {
3063 err = PTR_ERR(info->regulator);
3064 dev_err(&pdev->dev, "failed to register regulator %s\n",
3065 info->desc.name);
3066 /* when we fail, un-register all earlier regulators */
3067 while (--id >= 0) {
Lee Jones33aeb492013-04-02 13:24:14 +01003068 info = &abx500_regulator.info[id];
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003069 regulator_unregister(info->regulator);
3070 }
3071 return err;
3072 }
3073
3074 return 0;
3075}
3076
Bill Pembertona5023572012-11-19 13:22:22 -05003077static int
Lee Jonesb54969a2013-03-28 16:11:10 +00003078ab8500_regulator_of_probe(struct platform_device *pdev,
Lee Jonesb54969a2013-03-28 16:11:10 +00003079 struct device_node *np)
Lee Jones3a8334b2012-05-17 14:45:16 +01003080{
Lee Jones33aeb492013-04-02 13:24:14 +01003081 struct of_regulator_match *match = abx500_regulator.match;
Lee Jones3a8334b2012-05-17 14:45:16 +01003082 int err, i;
3083
Lee Jones33aeb492013-04-02 13:24:14 +01003084 for (i = 0; i < abx500_regulator.info_size; i++) {
Lee Jones3a8334b2012-05-17 14:45:16 +01003085 err = ab8500_regulator_register(
Lee Jones33aeb492013-04-02 13:24:14 +01003086 pdev, match[i].init_data, i, match[i].of_node);
Lee Jones3a8334b2012-05-17 14:45:16 +01003087 if (err)
3088 return err;
3089 }
3090
3091 return 0;
3092}
3093
Bill Pembertona5023572012-11-19 13:22:22 -05003094static int ab8500_regulator_probe(struct platform_device *pdev)
Sundar R IYERc789ca22010-07-13 21:48:56 +05303095{
3096 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
Lee Jones3a8334b2012-05-17 14:45:16 +01003097 struct device_node *np = pdev->dev.of_node;
Bengt Jonsson732805a2013-03-21 15:59:03 +00003098 struct ab8500_platform_data *ppdata;
3099 struct ab8500_regulator_platform_data *pdata;
Sundar R IYERc789ca22010-07-13 21:48:56 +05303100 int i, err;
Lee Jonesb54969a2013-03-28 16:11:10 +00003101
Lee Jones33aeb492013-04-02 13:24:14 +01003102 if (!ab8500) {
3103 dev_err(&pdev->dev, "null mfd parent\n");
3104 return -EINVAL;
Lee Jones8e6a8d72013-03-28 16:11:11 +00003105 }
Sundar R IYERc789ca22010-07-13 21:48:56 +05303106
Lee Jones33aeb492013-04-02 13:24:14 +01003107 abx500_get_regulator_info(ab8500);
3108
Lee Jones3a8334b2012-05-17 14:45:16 +01003109 if (np) {
Lee Jones33aeb492013-04-02 13:24:14 +01003110 err = of_regulator_match(&pdev->dev, np,
3111 abx500_regulator.match,
3112 abx500_regulator.match_size);
Lee Jones3a8334b2012-05-17 14:45:16 +01003113 if (err < 0) {
3114 dev_err(&pdev->dev,
3115 "Error parsing regulator init data: %d\n", err);
3116 return err;
3117 }
3118
Lee Jones33aeb492013-04-02 13:24:14 +01003119 err = ab8500_regulator_of_probe(pdev, np);
Lee Jones3a8334b2012-05-17 14:45:16 +01003120 return err;
3121 }
3122
Bengt Jonsson732805a2013-03-21 15:59:03 +00003123 ppdata = dev_get_platdata(ab8500->dev);
3124 if (!ppdata) {
3125 dev_err(&pdev->dev, "null parent pdata\n");
3126 return -EINVAL;
3127 }
3128
3129 pdata = ppdata->regulator;
Bengt Jonssonfc24b422010-12-10 11:08:45 +01003130 if (!pdata) {
3131 dev_err(&pdev->dev, "null pdata\n");
3132 return -EINVAL;
3133 }
Sundar R IYERc789ca22010-07-13 21:48:56 +05303134
Bengt Jonssoncb189b02010-12-10 11:08:40 +01003135 /* make sure the platform data has the correct size */
Lee Jones33aeb492013-04-02 13:24:14 +01003136 if (pdata->num_regulator != abx500_regulator.info_size) {
Bengt Jonsson79568b942011-03-11 11:54:46 +01003137 dev_err(&pdev->dev, "Configuration error: size mismatch.\n");
Bengt Jonssoncb189b02010-12-10 11:08:40 +01003138 return -EINVAL;
3139 }
3140
Lee Jonesda0b0c42013-03-28 16:11:09 +00003141 /* initialize debug (initial state is recorded with this call) */
3142 err = ab8500_regulator_debug_init(pdev);
3143 if (err)
3144 return err;
3145
Bengt Jonsson79568b942011-03-11 11:54:46 +01003146 /* initialize registers */
Bengt Jonsson732805a2013-03-21 15:59:03 +00003147 for (i = 0; i < pdata->num_reg_init; i++) {
Lee Jones3c1b8432013-03-21 15:59:01 +00003148 int id, mask, value;
Bengt Jonsson79568b942011-03-11 11:54:46 +01003149
Bengt Jonsson732805a2013-03-21 15:59:03 +00003150 id = pdata->reg_init[i].id;
3151 mask = pdata->reg_init[i].mask;
3152 value = pdata->reg_init[i].value;
Bengt Jonsson79568b942011-03-11 11:54:46 +01003153
3154 /* check for configuration errors */
Lee Jones33aeb492013-04-02 13:24:14 +01003155 BUG_ON(id >= abx500_regulator.init_size);
Bengt Jonsson79568b942011-03-11 11:54:46 +01003156
Lee Jones33aeb492013-04-02 13:24:14 +01003157 err = ab8500_regulator_init_registers(pdev, id, mask, value);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003158 if (err < 0)
Bengt Jonsson79568b942011-03-11 11:54:46 +01003159 return err;
Bengt Jonsson79568b942011-03-11 11:54:46 +01003160 }
3161
Rabin Vincentf7eae372013-04-02 13:24:08 +01003162 if (!is_ab8505(ab8500)) {
3163 /* register external regulators (before Vaux1, 2 and 3) */
3164 err = ab8500_ext_regulator_init(pdev);
3165 if (err)
3166 return err;
3167 }
Lee Jonesd1a82002013-03-28 16:11:01 +00003168
Sundar R IYERc789ca22010-07-13 21:48:56 +05303169 /* register all regulators */
Lee Jones33aeb492013-04-02 13:24:14 +01003170 for (i = 0; i < abx500_regulator.info_size; i++) {
Lee Jonesb54969a2013-03-28 16:11:10 +00003171 err = ab8500_regulator_register(pdev, &pdata->regulator[i],
Lee Jones33aeb492013-04-02 13:24:14 +01003172 i, NULL);
Axel Lin42e8c812013-04-11 12:05:43 +08003173 if (err < 0) {
3174 if (!is_ab8505(ab8500))
3175 ab8500_ext_regulator_exit(pdev);
Sundar R IYERc789ca22010-07-13 21:48:56 +05303176 return err;
Axel Lin42e8c812013-04-11 12:05:43 +08003177 }
Sundar R IYERc789ca22010-07-13 21:48:56 +05303178 }
3179
3180 return 0;
3181}
3182
Bill Pemberton8dc995f2012-11-19 13:26:10 -05003183static int ab8500_regulator_remove(struct platform_device *pdev)
Sundar R IYERc789ca22010-07-13 21:48:56 +05303184{
Lee Jonesd1a82002013-03-28 16:11:01 +00003185 int i, err;
Lee Jones8e6a8d72013-03-28 16:11:11 +00003186 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
Sundar R IYERc789ca22010-07-13 21:48:56 +05303187
Lee Jones33aeb492013-04-02 13:24:14 +01003188 for (i = 0; i < abx500_regulator.info_size; i++) {
Sundar R IYERc789ca22010-07-13 21:48:56 +05303189 struct ab8500_regulator_info *info = NULL;
Lee Jones33aeb492013-04-02 13:24:14 +01003190 info = &abx500_regulator.info[i];
Bengt Jonsson09aefa12010-12-10 11:08:46 +01003191
3192 dev_vdbg(rdev_get_dev(info->regulator),
3193 "%s-remove\n", info->desc.name);
3194
Sundar R IYERc789ca22010-07-13 21:48:56 +05303195 regulator_unregister(info->regulator);
3196 }
3197
Axel Lin3480c0c2013-04-11 12:04:18 +08003198 /* remove external regulators (after Vaux1, 2 and 3) */
3199 if (!is_ab8505(ab8500))
3200 ab8500_ext_regulator_exit(pdev);
Lee Jonesd1a82002013-03-28 16:11:01 +00003201
Lee Jonesda0b0c42013-03-28 16:11:09 +00003202 /* remove regulator debug */
3203 err = ab8500_regulator_debug_exit(pdev);
3204 if (err)
3205 return err;
3206
Sundar R IYERc789ca22010-07-13 21:48:56 +05303207 return 0;
3208}
3209
3210static struct platform_driver ab8500_regulator_driver = {
3211 .probe = ab8500_regulator_probe,
Bill Pemberton5eb9f2b2012-11-19 13:20:42 -05003212 .remove = ab8500_regulator_remove,
Sundar R IYERc789ca22010-07-13 21:48:56 +05303213 .driver = {
3214 .name = "ab8500-regulator",
3215 .owner = THIS_MODULE,
Sundar R IYERc789ca22010-07-13 21:48:56 +05303216 },
3217};
3218
3219static int __init ab8500_regulator_init(void)
3220{
3221 int ret;
3222
3223 ret = platform_driver_register(&ab8500_regulator_driver);
3224 if (ret != 0)
3225 pr_err("Failed to register ab8500 regulator: %d\n", ret);
3226
3227 return ret;
3228}
3229subsys_initcall(ab8500_regulator_init);
3230
3231static void __exit ab8500_regulator_exit(void)
3232{
3233 platform_driver_unregister(&ab8500_regulator_driver);
3234}
3235module_exit(ab8500_regulator_exit);
3236
3237MODULE_LICENSE("GPL v2");
3238MODULE_AUTHOR("Sundar Iyer <sundar.iyer@stericsson.com>");
Bengt Jonsson732805a2013-03-21 15:59:03 +00003239MODULE_AUTHOR("Bengt Jonsson <bengt.g.jonsson@stericsson.com>");
Lee Jones547f3842013-03-28 16:11:14 +00003240MODULE_AUTHOR("Daniel Willerud <daniel.willerud@stericsson.com>");
Sundar R IYERc789ca22010-07-13 21:48:56 +05303241MODULE_DESCRIPTION("Regulator Driver for ST-Ericsson AB8500 Mixed-Sig PMIC");
3242MODULE_ALIAS("platform:ab8500-regulator");