blob: 517305e201267db279b0e67532dfa2fd1b342662 [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
Emeric Vigierbd28a152013-03-21 15:58:59 +000049 * @is_enabled: status of regulator (on/off)
Bengt Jonsson7ce46692013-03-21 15:59:00 +000050 * @load_lp_uA: maximum load in idle (low power) mode
Mattias Wallin47c16972010-09-10 17:47:56 +020051 * @update_bank: bank to control on/off
Sundar R IYERc789ca22010-07-13 21:48:56 +053052 * @update_reg: register to control on/off
Emeric Vigierbd28a152013-03-21 15:58:59 +000053 * @update_mask: mask to enable/disable and set mode of regulator
54 * @update_val: bits holding the regulator current mode
55 * @update_val_idle: bits to enable the regulator in idle (low power) mode
56 * @update_val_normal: bits to enable the regulator in normal (high power) mode
Lee Jones3fe52282013-04-02 13:24:12 +010057 * @mode_bank: bank with location of mode register
58 * @mode_reg: mode register
59 * @mode_mask: mask for setting mode
60 * @mode_val_idle: mode setting for low power
61 * @mode_val_normal: mode setting for normal power
Mattias Wallin47c16972010-09-10 17:47:56 +020062 * @voltage_bank: bank to control regulator voltage
Sundar R IYERc789ca22010-07-13 21:48:56 +053063 * @voltage_reg: register to control regulator voltage
64 * @voltage_mask: mask to control regulator voltage
Linus Walleija0a70142012-08-20 18:41:35 +020065 * @voltage_shift: shift to control regulator voltage
Sundar R IYERc789ca22010-07-13 21:48:56 +053066 */
67struct ab8500_regulator_info {
68 struct device *dev;
69 struct regulator_desc desc;
Sundar R IYERc789ca22010-07-13 21:48:56 +053070 struct regulator_dev *regulator;
Lee Jones3fe52282013-04-02 13:24:12 +010071 struct ab8500_shared_mode *shared_mode;
Emeric Vigierbd28a152013-03-21 15:58:59 +000072 bool is_enabled;
Bengt Jonsson7ce46692013-03-21 15:59:00 +000073 int load_lp_uA;
Mattias Wallin47c16972010-09-10 17:47:56 +020074 u8 update_bank;
75 u8 update_reg;
Bengt Jonssone1159e62010-12-10 11:08:44 +010076 u8 update_mask;
Emeric Vigierbd28a152013-03-21 15:58:59 +000077 u8 update_val;
78 u8 update_val_idle;
79 u8 update_val_normal;
Lee Jones3fe52282013-04-02 13:24:12 +010080 u8 mode_bank;
81 u8 mode_reg;
82 u8 mode_mask;
83 u8 mode_val_idle;
84 u8 mode_val_normal;
Mattias Wallin47c16972010-09-10 17:47:56 +020085 u8 voltage_bank;
86 u8 voltage_reg;
87 u8 voltage_mask;
Linus Walleija0a70142012-08-20 18:41:35 +020088 u8 voltage_shift;
Lee Jonesd7607ba2013-04-02 13:24:11 +010089 struct {
90 u8 voltage_limit;
91 u8 voltage_bank;
92 u8 voltage_reg;
93 u8 voltage_mask;
94 u8 voltage_shift;
95 } expand_register;
Sundar R IYERc789ca22010-07-13 21:48:56 +053096};
97
98/* voltage tables for the vauxn/vintcore supplies */
Axel Linec1cc4d2012-05-20 10:33:35 +080099static const unsigned int ldo_vauxn_voltages[] = {
Sundar R IYERc789ca22010-07-13 21:48:56 +0530100 1100000,
101 1200000,
102 1300000,
103 1400000,
104 1500000,
105 1800000,
106 1850000,
107 1900000,
108 2500000,
109 2650000,
110 2700000,
111 2750000,
112 2800000,
113 2900000,
114 3000000,
115 3300000,
116};
117
Axel Linec1cc4d2012-05-20 10:33:35 +0800118static const unsigned int ldo_vaux3_voltages[] = {
Bengt Jonsson2b751512010-12-10 11:08:43 +0100119 1200000,
120 1500000,
121 1800000,
122 2100000,
123 2500000,
124 2750000,
125 2790000,
126 2910000,
127};
128
Lee Jones62ab4112013-03-28 16:11:18 +0000129static const unsigned int ldo_vaux56_voltages[] = {
Lee Jones547f3842013-03-28 16:11:14 +0000130 1800000,
131 1050000,
132 1100000,
133 1200000,
134 1500000,
135 2200000,
136 2500000,
137 2790000,
138};
139
Lee Jones62ab4112013-03-28 16:11:18 +0000140static const unsigned int ldo_vaux3_ab8540_voltages[] = {
Lee Jonesae0a9a32013-03-28 16:11:16 +0000141 1200000,
142 1500000,
143 1800000,
144 2100000,
145 2500000,
146 2750000,
147 2790000,
148 2910000,
149 3050000,
150};
151
Zhenhua HUANG684d5ce2013-04-02 13:24:15 +0100152static const unsigned int ldo_vaux56_ab8540_voltages[] = {
153 750000, 760000, 770000, 780000, 790000, 800000,
154 810000, 820000, 830000, 840000, 850000, 860000,
155 870000, 880000, 890000, 900000, 910000, 920000,
156 930000, 940000, 950000, 960000, 970000, 980000,
157 990000, 1000000, 1010000, 1020000, 1030000,
158 1040000, 1050000, 1060000, 1070000, 1080000,
159 1090000, 1100000, 1110000, 1120000, 1130000,
160 1140000, 1150000, 1160000, 1170000, 1180000,
161 1190000, 1200000, 1210000, 1220000, 1230000,
162 1240000, 1250000, 1260000, 1270000, 1280000,
163 1290000, 1300000, 1310000, 1320000, 1330000,
164 1340000, 1350000, 1360000, 1800000, 2790000,
165};
166
Axel Linec1cc4d2012-05-20 10:33:35 +0800167static const unsigned int ldo_vintcore_voltages[] = {
Sundar R IYERc789ca22010-07-13 21:48:56 +0530168 1200000,
169 1225000,
170 1250000,
171 1275000,
172 1300000,
173 1325000,
174 1350000,
175};
176
Lee Jones62ab4112013-03-28 16:11:18 +0000177static const unsigned int ldo_sdio_voltages[] = {
Lee Jonesae0a9a32013-03-28 16:11:16 +0000178 1160000,
179 1050000,
180 1100000,
181 1500000,
182 1800000,
183 2200000,
184 2910000,
185 3050000,
186};
187
Lee Jonesb080c782013-03-28 16:11:17 +0000188static const unsigned int fixed_1200000_voltage[] = {
189 1200000,
190};
191
192static const unsigned int fixed_1800000_voltage[] = {
193 1800000,
194};
195
196static const unsigned int fixed_2000000_voltage[] = {
197 2000000,
198};
199
200static const unsigned int fixed_2050000_voltage[] = {
201 2050000,
202};
203
204static const unsigned int fixed_3300000_voltage[] = {
205 3300000,
206};
207
Lee Jones8a3b1b82013-04-02 13:24:09 +0100208static const unsigned int ldo_vana_voltages[] = {
209 1050000,
210 1075000,
211 1100000,
212 1125000,
213 1150000,
214 1175000,
215 1200000,
216 1225000,
217};
218
219static const unsigned int ldo_vaudio_voltages[] = {
220 2000000,
221 2100000,
222 2200000,
223 2300000,
224 2400000,
225 2500000,
226 2600000,
227 2600000, /* Duplicated in Vaudio and IsoUicc Control register. */
228};
229
Lee Jones4c84b4d2013-04-02 13:24:13 +0100230static const unsigned int ldo_vdmic_voltages[] = {
231 1800000,
232 1900000,
233 2000000,
234 2850000,
235};
236
Lee Jones3fe52282013-04-02 13:24:12 +0100237static DEFINE_MUTEX(shared_mode_mutex);
238static struct ab8500_shared_mode ldo_anamic1_shared;
239static struct ab8500_shared_mode ldo_anamic2_shared;
Lee Jones4c84b4d2013-04-02 13:24:13 +0100240static struct ab8500_shared_mode ab8540_ldo_anamic1_shared;
241static struct ab8500_shared_mode ab8540_ldo_anamic2_shared;
Lee Jones3fe52282013-04-02 13:24:12 +0100242
Sundar R IYERc789ca22010-07-13 21:48:56 +0530243static int ab8500_regulator_enable(struct regulator_dev *rdev)
244{
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100245 int ret;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530246 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
247
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100248 if (info == NULL) {
249 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
Sundar R IYERc789ca22010-07-13 21:48:56 +0530250 return -EINVAL;
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100251 }
Sundar R IYERc789ca22010-07-13 21:48:56 +0530252
Mattias Wallin47c16972010-09-10 17:47:56 +0200253 ret = abx500_mask_and_set_register_interruptible(info->dev,
Bengt Jonssone1159e62010-12-10 11:08:44 +0100254 info->update_bank, info->update_reg,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000255 info->update_mask, info->update_val);
Axel Linf71bf522013-03-26 16:13:14 +0800256 if (ret < 0) {
Sundar R IYERc789ca22010-07-13 21:48:56 +0530257 dev_err(rdev_get_dev(rdev),
258 "couldn't set enable bits for regulator\n");
Axel Linf71bf522013-03-26 16:13:14 +0800259 return ret;
260 }
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100261
Emeric Vigierbd28a152013-03-21 15:58:59 +0000262 info->is_enabled = true;
263
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100264 dev_vdbg(rdev_get_dev(rdev),
265 "%s-enable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
266 info->desc.name, info->update_bank, info->update_reg,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000267 info->update_mask, info->update_val);
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100268
Sundar R IYERc789ca22010-07-13 21:48:56 +0530269 return ret;
270}
271
272static int ab8500_regulator_disable(struct regulator_dev *rdev)
273{
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100274 int ret;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530275 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
276
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100277 if (info == NULL) {
278 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
Sundar R IYERc789ca22010-07-13 21:48:56 +0530279 return -EINVAL;
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100280 }
Sundar R IYERc789ca22010-07-13 21:48:56 +0530281
Mattias Wallin47c16972010-09-10 17:47:56 +0200282 ret = abx500_mask_and_set_register_interruptible(info->dev,
Bengt Jonssone1159e62010-12-10 11:08:44 +0100283 info->update_bank, info->update_reg,
284 info->update_mask, 0x0);
Axel Linf71bf522013-03-26 16:13:14 +0800285 if (ret < 0) {
Sundar R IYERc789ca22010-07-13 21:48:56 +0530286 dev_err(rdev_get_dev(rdev),
287 "couldn't set disable bits for regulator\n");
Axel Linf71bf522013-03-26 16:13:14 +0800288 return ret;
289 }
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100290
Emeric Vigierbd28a152013-03-21 15:58:59 +0000291 info->is_enabled = false;
292
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100293 dev_vdbg(rdev_get_dev(rdev),
294 "%s-disable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
295 info->desc.name, info->update_bank, info->update_reg,
296 info->update_mask, 0x0);
297
Sundar R IYERc789ca22010-07-13 21:48:56 +0530298 return ret;
299}
300
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000301static unsigned int ab8500_regulator_get_optimum_mode(
302 struct regulator_dev *rdev, int input_uV,
303 int output_uV, int load_uA)
304{
305 unsigned int mode;
306
307 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
308
309 if (info == NULL) {
310 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
311 return -EINVAL;
312 }
313
314 if (load_uA <= info->load_lp_uA)
315 mode = REGULATOR_MODE_IDLE;
316 else
317 mode = REGULATOR_MODE_NORMAL;
318
319 return mode;
320}
321
Emeric Vigierbd28a152013-03-21 15:58:59 +0000322static int ab8500_regulator_set_mode(struct regulator_dev *rdev,
323 unsigned int mode)
324{
Lee Jones3fe52282013-04-02 13:24:12 +0100325 int ret = 0;
326 u8 bank;
327 u8 reg;
328 u8 mask;
329 u8 val;
330 bool dmr = false; /* Dedicated mode register */
Emeric Vigierbd28a152013-03-21 15:58:59 +0000331 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
332
333 if (info == NULL) {
334 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
335 return -EINVAL;
336 }
337
Lee Jones3fe52282013-04-02 13:24:12 +0100338 if (info->shared_mode) {
339 /*
340 * Special case where mode is shared between two regulators.
341 */
342 struct ab8500_shared_mode *sm = info->shared_mode;
343 mutex_lock(&shared_mode_mutex);
344
345 if (mode == REGULATOR_MODE_IDLE) {
346 sm->lp_mode_req = true; /* Low power mode requested */
347 if (!((sm->shared_regulator)->
348 shared_mode->lp_mode_req)) {
349 mutex_unlock(&shared_mode_mutex);
350 return 0; /* Other regulator prevent LP mode */
351 }
352 } else {
353 sm->lp_mode_req = false;
354 }
Emeric Vigierbd28a152013-03-21 15:58:59 +0000355 }
356
Lee Jones3fe52282013-04-02 13:24:12 +0100357 if (info->mode_mask) {
358 /* Dedicated register for handling mode */
359
360 dmr = true;
361
362 switch (mode) {
363 case REGULATOR_MODE_NORMAL:
364 val = info->mode_val_normal;
365 break;
366 case REGULATOR_MODE_IDLE:
367 val = info->mode_val_idle;
368 break;
369 default:
370 if (info->shared_mode)
371 mutex_unlock(&shared_mode_mutex);
372 return -EINVAL;
373 }
374
375 bank = info->mode_bank;
376 reg = info->mode_reg;
377 mask = info->mode_mask;
378 } else {
379 /* Mode register same as enable register */
380
381 switch (mode) {
382 case REGULATOR_MODE_NORMAL:
383 info->update_val = info->update_val_normal;
384 val = info->update_val_normal;
385 break;
386 case REGULATOR_MODE_IDLE:
387 info->update_val = info->update_val_idle;
388 val = info->update_val_idle;
389 break;
390 default:
391 if (info->shared_mode)
392 mutex_unlock(&shared_mode_mutex);
393 return -EINVAL;
394 }
395
396 bank = info->update_bank;
397 reg = info->update_reg;
398 mask = info->update_mask;
399 }
400
401 if (info->is_enabled || dmr) {
Emeric Vigierbd28a152013-03-21 15:58:59 +0000402 ret = abx500_mask_and_set_register_interruptible(info->dev,
Lee Jones3fe52282013-04-02 13:24:12 +0100403 bank, reg, mask, val);
404 if (ret < 0)
Emeric Vigierbd28a152013-03-21 15:58:59 +0000405 dev_err(rdev_get_dev(rdev),
406 "couldn't set regulator mode\n");
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000407
408 dev_vdbg(rdev_get_dev(rdev),
409 "%s-set_mode (bank, reg, mask, value): "
410 "0x%x, 0x%x, 0x%x, 0x%x\n",
Lee Jones3fe52282013-04-02 13:24:12 +0100411 info->desc.name, bank, reg,
412 mask, val);
Emeric Vigierbd28a152013-03-21 15:58:59 +0000413 }
414
Lee Jones3fe52282013-04-02 13:24:12 +0100415 if (info->shared_mode)
416 mutex_unlock(&shared_mode_mutex);
Axel Lin742a7322013-03-28 17:23:00 +0800417
Lee Jones3fe52282013-04-02 13:24:12 +0100418 return ret;
Emeric Vigierbd28a152013-03-21 15:58:59 +0000419}
420
421static unsigned int ab8500_regulator_get_mode(struct regulator_dev *rdev)
422{
423 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
424 int ret;
Lee Jones3fe52282013-04-02 13:24:12 +0100425 u8 val;
426 u8 val_normal;
427 u8 val_idle;
Emeric Vigierbd28a152013-03-21 15:58:59 +0000428
429 if (info == NULL) {
430 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
431 return -EINVAL;
432 }
433
Lee Jones3fe52282013-04-02 13:24:12 +0100434 /* Need special handling for shared mode */
435 if (info->shared_mode) {
436 if (info->shared_mode->lp_mode_req)
437 return REGULATOR_MODE_IDLE;
438 else
439 return REGULATOR_MODE_NORMAL;
440 }
441
442 if (info->mode_mask) {
443 /* Dedicated register for handling mode */
444 ret = abx500_get_register_interruptible(info->dev,
445 info->mode_bank, info->mode_reg, &val);
446 val = val & info->mode_mask;
447
448 val_normal = info->mode_val_normal;
449 val_idle = info->mode_val_idle;
450 } else {
451 /* Mode register same as enable register */
452 val = info->update_val;
453 val_normal = info->update_val_normal;
454 val_idle = info->update_val_idle;
455 }
456
457 if (val == val_normal)
Emeric Vigierbd28a152013-03-21 15:58:59 +0000458 ret = REGULATOR_MODE_NORMAL;
Lee Jones3fe52282013-04-02 13:24:12 +0100459 else if (val == val_idle)
Emeric Vigierbd28a152013-03-21 15:58:59 +0000460 ret = REGULATOR_MODE_IDLE;
461 else
462 ret = -EINVAL;
463
464 return ret;
465}
466
Sundar R IYERc789ca22010-07-13 21:48:56 +0530467static int ab8500_regulator_is_enabled(struct regulator_dev *rdev)
468{
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100469 int ret;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530470 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100471 u8 regval;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530472
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100473 if (info == NULL) {
474 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
Sundar R IYERc789ca22010-07-13 21:48:56 +0530475 return -EINVAL;
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100476 }
Sundar R IYERc789ca22010-07-13 21:48:56 +0530477
Mattias Wallin47c16972010-09-10 17:47:56 +0200478 ret = abx500_get_register_interruptible(info->dev,
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100479 info->update_bank, info->update_reg, &regval);
Sundar R IYERc789ca22010-07-13 21:48:56 +0530480 if (ret < 0) {
481 dev_err(rdev_get_dev(rdev),
482 "couldn't read 0x%x register\n", info->update_reg);
483 return ret;
484 }
485
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100486 dev_vdbg(rdev_get_dev(rdev),
487 "%s-is_enabled (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
488 " 0x%x\n",
489 info->desc.name, info->update_bank, info->update_reg,
490 info->update_mask, regval);
491
492 if (regval & info->update_mask)
Emeric Vigierbd28a152013-03-21 15:58:59 +0000493 info->is_enabled = true;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530494 else
Emeric Vigierbd28a152013-03-21 15:58:59 +0000495 info->is_enabled = false;
496
497 return info->is_enabled;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530498}
499
Axel Lin3bf6e902012-02-24 17:15:45 +0800500static int ab8500_regulator_get_voltage_sel(struct regulator_dev *rdev)
Sundar R IYERc789ca22010-07-13 21:48:56 +0530501{
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100502 int ret, val;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530503 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100504 u8 regval;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530505
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100506 if (info == NULL) {
507 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
Sundar R IYERc789ca22010-07-13 21:48:56 +0530508 return -EINVAL;
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100509 }
Sundar R IYERc789ca22010-07-13 21:48:56 +0530510
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100511 ret = abx500_get_register_interruptible(info->dev,
512 info->voltage_bank, info->voltage_reg, &regval);
Sundar R IYERc789ca22010-07-13 21:48:56 +0530513 if (ret < 0) {
514 dev_err(rdev_get_dev(rdev),
515 "couldn't read voltage reg for regulator\n");
516 return ret;
517 }
518
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100519 dev_vdbg(rdev_get_dev(rdev),
Linus Walleija0a70142012-08-20 18:41:35 +0200520 "%s-get_voltage (bank, reg, mask, shift, value): "
521 "0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n",
522 info->desc.name, info->voltage_bank,
523 info->voltage_reg, info->voltage_mask,
524 info->voltage_shift, regval);
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100525
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100526 val = regval & info->voltage_mask;
Linus Walleija0a70142012-08-20 18:41:35 +0200527 return val >> info->voltage_shift;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530528}
529
Lee Jonesd7607ba2013-04-02 13:24:11 +0100530static int ab8540_aux3_regulator_get_voltage_sel(struct regulator_dev *rdev)
531{
532 int ret, val;
533 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
534 u8 regval, regval_expand;
535
536 if (info == NULL) {
537 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
538 return -EINVAL;
539 }
540
541 ret = abx500_get_register_interruptible(info->dev,
542 info->voltage_bank, info->voltage_reg, &regval);
543
544 if (ret < 0) {
545 dev_err(rdev_get_dev(rdev),
546 "couldn't read voltage reg for regulator\n");
547 return ret;
548 }
549
550 ret = abx500_get_register_interruptible(info->dev,
551 info->expand_register.voltage_bank,
552 info->expand_register.voltage_reg, &regval_expand);
553
554 if (ret < 0) {
555 dev_err(rdev_get_dev(rdev),
556 "couldn't read voltage reg for regulator\n");
557 return ret;
558 }
559
560 dev_vdbg(rdev_get_dev(rdev),
561 "%s-get_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
562 " 0x%x\n",
563 info->desc.name, info->voltage_bank, info->voltage_reg,
564 info->voltage_mask, regval);
565 dev_vdbg(rdev_get_dev(rdev),
566 "%s-get_voltage expand (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
567 " 0x%x\n",
568 info->desc.name, info->expand_register.voltage_bank,
569 info->expand_register.voltage_reg,
570 info->expand_register.voltage_mask, regval_expand);
571
572 if (regval_expand&(info->expand_register.voltage_mask))
573 /* Vaux3 has a different layout */
574 val = info->expand_register.voltage_limit;
575 else
576 val = (regval & info->voltage_mask) >> info->voltage_shift;
577
578 return val;
579}
580
Axel Linae713d32012-03-20 09:51:08 +0800581static int ab8500_regulator_set_voltage_sel(struct regulator_dev *rdev,
582 unsigned selector)
Sundar R IYERc789ca22010-07-13 21:48:56 +0530583{
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100584 int ret;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530585 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100586 u8 regval;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530587
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100588 if (info == NULL) {
589 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
Sundar R IYERc789ca22010-07-13 21:48:56 +0530590 return -EINVAL;
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100591 }
Sundar R IYERc789ca22010-07-13 21:48:56 +0530592
Sundar R IYERc789ca22010-07-13 21:48:56 +0530593 /* set the registers for the request */
Linus Walleija0a70142012-08-20 18:41:35 +0200594 regval = (u8)selector << info->voltage_shift;
Mattias Wallin47c16972010-09-10 17:47:56 +0200595 ret = abx500_mask_and_set_register_interruptible(info->dev,
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100596 info->voltage_bank, info->voltage_reg,
597 info->voltage_mask, regval);
Sundar R IYERc789ca22010-07-13 21:48:56 +0530598 if (ret < 0)
599 dev_err(rdev_get_dev(rdev),
600 "couldn't set voltage reg for regulator\n");
601
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100602 dev_vdbg(rdev_get_dev(rdev),
603 "%s-set_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
604 " 0x%x\n",
605 info->desc.name, info->voltage_bank, info->voltage_reg,
606 info->voltage_mask, regval);
607
Sundar R IYERc789ca22010-07-13 21:48:56 +0530608 return ret;
609}
610
Lee Jonesd7607ba2013-04-02 13:24:11 +0100611static int ab8540_aux3_regulator_set_voltage_sel(struct regulator_dev *rdev,
612 unsigned selector)
613{
614 int ret;
615 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
616 u8 regval;
617
618 if (info == NULL) {
619 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
620 return -EINVAL;
621 }
622
623 if (selector >= info->expand_register.voltage_limit) {
624 /* Vaux3 bit4 has different layout */
625 regval = (u8)selector << info->expand_register.voltage_shift;
626 ret = abx500_mask_and_set_register_interruptible(info->dev,
627 info->expand_register.voltage_bank,
628 info->expand_register.voltage_reg,
629 info->expand_register.voltage_mask,
630 regval);
631 } else {
632 /* set the registers for the request */
633 regval = (u8)selector << info->voltage_shift;
634 ret = abx500_mask_and_set_register_interruptible(info->dev,
635 info->voltage_bank, info->voltage_reg,
636 info->voltage_mask, regval);
637 }
638 if (ret < 0)
639 dev_err(rdev_get_dev(rdev),
640 "couldn't set voltage reg for regulator\n");
641
642 dev_vdbg(rdev_get_dev(rdev),
643 "%s-set_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
644 " 0x%x\n",
645 info->desc.name, info->voltage_bank, info->voltage_reg,
646 info->voltage_mask, regval);
647
648 return ret;
649}
650
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000651static struct regulator_ops ab8500_regulator_volt_mode_ops = {
652 .enable = ab8500_regulator_enable,
653 .disable = ab8500_regulator_disable,
654 .is_enabled = ab8500_regulator_is_enabled,
655 .get_optimum_mode = ab8500_regulator_get_optimum_mode,
656 .set_mode = ab8500_regulator_set_mode,
657 .get_mode = ab8500_regulator_get_mode,
658 .get_voltage_sel = ab8500_regulator_get_voltage_sel,
659 .set_voltage_sel = ab8500_regulator_set_voltage_sel,
660 .list_voltage = regulator_list_voltage_table,
Sundar R IYERc789ca22010-07-13 21:48:56 +0530661};
662
Lee Jonesd7607ba2013-04-02 13:24:11 +0100663static struct regulator_ops ab8540_aux3_regulator_volt_mode_ops = {
664 .enable = ab8500_regulator_enable,
665 .disable = ab8500_regulator_disable,
666 .get_optimum_mode = ab8500_regulator_get_optimum_mode,
667 .set_mode = ab8500_regulator_set_mode,
668 .get_mode = ab8500_regulator_get_mode,
669 .is_enabled = ab8500_regulator_is_enabled,
670 .get_voltage_sel = ab8540_aux3_regulator_get_voltage_sel,
671 .set_voltage_sel = ab8540_aux3_regulator_set_voltage_sel,
672 .list_voltage = regulator_list_voltage_table,
Lee Jonesd7607ba2013-04-02 13:24:11 +0100673};
674
Lee Jones8a3b1b82013-04-02 13:24:09 +0100675static struct regulator_ops ab8500_regulator_volt_ops = {
676 .enable = ab8500_regulator_enable,
677 .disable = ab8500_regulator_disable,
678 .is_enabled = ab8500_regulator_is_enabled,
679 .get_voltage_sel = ab8500_regulator_get_voltage_sel,
680 .set_voltage_sel = ab8500_regulator_set_voltage_sel,
681 .list_voltage = regulator_list_voltage_table,
Lee Jones8a3b1b82013-04-02 13:24:09 +0100682};
683
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000684static struct regulator_ops ab8500_regulator_mode_ops = {
685 .enable = ab8500_regulator_enable,
686 .disable = ab8500_regulator_disable,
687 .is_enabled = ab8500_regulator_is_enabled,
688 .get_optimum_mode = ab8500_regulator_get_optimum_mode,
689 .set_mode = ab8500_regulator_set_mode,
690 .get_mode = ab8500_regulator_get_mode,
Axel Lind7816ab2013-04-02 13:24:22 +0100691 .list_voltage = regulator_list_voltage_table,
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000692};
693
694static struct regulator_ops ab8500_regulator_ops = {
695 .enable = ab8500_regulator_enable,
696 .disable = ab8500_regulator_disable,
697 .is_enabled = ab8500_regulator_is_enabled,
Axel Lind7816ab2013-04-02 13:24:22 +0100698 .list_voltage = regulator_list_voltage_table,
Sundar R IYERc789ca22010-07-13 21:48:56 +0530699};
700
Lee Jones3fe52282013-04-02 13:24:12 +0100701static struct regulator_ops ab8500_regulator_anamic_mode_ops = {
702 .enable = ab8500_regulator_enable,
703 .disable = ab8500_regulator_disable,
704 .is_enabled = ab8500_regulator_is_enabled,
705 .set_mode = ab8500_regulator_set_mode,
706 .get_mode = ab8500_regulator_get_mode,
707 .list_voltage = regulator_list_voltage_table,
708};
709
Lee Jones8e6a8d72013-03-28 16:11:11 +0000710/* AB8500 regulator information */
Bengt Jonsson6909b452010-12-10 11:08:47 +0100711static struct ab8500_regulator_info
712 ab8500_regulator_info[AB8500_NUM_REGULATORS] = {
Sundar R IYERc789ca22010-07-13 21:48:56 +0530713 /*
Bengt Jonssone1159e62010-12-10 11:08:44 +0100714 * Variable Voltage Regulators
715 * name, min mV, max mV,
716 * update bank, reg, mask, enable val
Axel Linec1cc4d2012-05-20 10:33:35 +0800717 * volt bank, reg, mask
Sundar R IYERc789ca22010-07-13 21:48:56 +0530718 */
Bengt Jonsson6909b452010-12-10 11:08:47 +0100719 [AB8500_LDO_AUX1] = {
720 .desc = {
721 .name = "LDO-AUX1",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000722 .ops = &ab8500_regulator_volt_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100723 .type = REGULATOR_VOLTAGE,
724 .id = AB8500_LDO_AUX1,
725 .owner = THIS_MODULE,
726 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Axel Linec1cc4d2012-05-20 10:33:35 +0800727 .volt_table = ldo_vauxn_voltages,
Axel Lin530158b2013-03-27 17:47:22 +0800728 .enable_time = 200,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100729 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000730 .load_lp_uA = 5000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100731 .update_bank = 0x04,
732 .update_reg = 0x09,
733 .update_mask = 0x03,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000734 .update_val = 0x01,
735 .update_val_idle = 0x03,
736 .update_val_normal = 0x01,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100737 .voltage_bank = 0x04,
738 .voltage_reg = 0x1f,
739 .voltage_mask = 0x0f,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100740 },
741 [AB8500_LDO_AUX2] = {
742 .desc = {
743 .name = "LDO-AUX2",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000744 .ops = &ab8500_regulator_volt_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100745 .type = REGULATOR_VOLTAGE,
746 .id = AB8500_LDO_AUX2,
747 .owner = THIS_MODULE,
748 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Axel Linec1cc4d2012-05-20 10:33:35 +0800749 .volt_table = ldo_vauxn_voltages,
Axel Lin530158b2013-03-27 17:47:22 +0800750 .enable_time = 200,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100751 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000752 .load_lp_uA = 5000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100753 .update_bank = 0x04,
754 .update_reg = 0x09,
755 .update_mask = 0x0c,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000756 .update_val = 0x04,
757 .update_val_idle = 0x0c,
758 .update_val_normal = 0x04,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100759 .voltage_bank = 0x04,
760 .voltage_reg = 0x20,
761 .voltage_mask = 0x0f,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100762 },
763 [AB8500_LDO_AUX3] = {
764 .desc = {
765 .name = "LDO-AUX3",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000766 .ops = &ab8500_regulator_volt_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100767 .type = REGULATOR_VOLTAGE,
768 .id = AB8500_LDO_AUX3,
769 .owner = THIS_MODULE,
770 .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages),
Axel Linec1cc4d2012-05-20 10:33:35 +0800771 .volt_table = ldo_vaux3_voltages,
Axel Lin530158b2013-03-27 17:47:22 +0800772 .enable_time = 450,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100773 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000774 .load_lp_uA = 5000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100775 .update_bank = 0x04,
776 .update_reg = 0x0a,
777 .update_mask = 0x03,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000778 .update_val = 0x01,
779 .update_val_idle = 0x03,
780 .update_val_normal = 0x01,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100781 .voltage_bank = 0x04,
782 .voltage_reg = 0x21,
783 .voltage_mask = 0x07,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100784 },
785 [AB8500_LDO_INTCORE] = {
786 .desc = {
787 .name = "LDO-INTCORE",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000788 .ops = &ab8500_regulator_volt_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100789 .type = REGULATOR_VOLTAGE,
790 .id = AB8500_LDO_INTCORE,
791 .owner = THIS_MODULE,
792 .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
Axel Linec1cc4d2012-05-20 10:33:35 +0800793 .volt_table = ldo_vintcore_voltages,
Axel Lin530158b2013-03-27 17:47:22 +0800794 .enable_time = 750,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100795 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000796 .load_lp_uA = 5000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100797 .update_bank = 0x03,
798 .update_reg = 0x80,
799 .update_mask = 0x44,
Lee Jonescc40dc22013-03-21 15:59:41 +0000800 .update_val = 0x44,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000801 .update_val_idle = 0x44,
802 .update_val_normal = 0x04,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100803 .voltage_bank = 0x03,
804 .voltage_reg = 0x80,
805 .voltage_mask = 0x38,
Linus Walleija0a70142012-08-20 18:41:35 +0200806 .voltage_shift = 3,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100807 },
Sundar R IYERc789ca22010-07-13 21:48:56 +0530808
809 /*
Bengt Jonssone1159e62010-12-10 11:08:44 +0100810 * Fixed Voltage Regulators
811 * name, fixed mV,
812 * update bank, reg, mask, enable val
Sundar R IYERc789ca22010-07-13 21:48:56 +0530813 */
Bengt Jonsson6909b452010-12-10 11:08:47 +0100814 [AB8500_LDO_TVOUT] = {
815 .desc = {
816 .name = "LDO-TVOUT",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000817 .ops = &ab8500_regulator_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100818 .type = REGULATOR_VOLTAGE,
819 .id = AB8500_LDO_TVOUT,
820 .owner = THIS_MODULE,
821 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +0000822 .volt_table = fixed_2000000_voltage,
Lee Jonesed3c1382013-03-28 16:11:12 +0000823 .enable_time = 500,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100824 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000825 .load_lp_uA = 1000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100826 .update_bank = 0x03,
827 .update_reg = 0x80,
828 .update_mask = 0x82,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000829 .update_val = 0x02,
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000830 .update_val_idle = 0x82,
831 .update_val_normal = 0x02,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100832 },
833 [AB8500_LDO_AUDIO] = {
834 .desc = {
835 .name = "LDO-AUDIO",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000836 .ops = &ab8500_regulator_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100837 .type = REGULATOR_VOLTAGE,
838 .id = AB8500_LDO_AUDIO,
839 .owner = THIS_MODULE,
840 .n_voltages = 1,
Axel Lin530158b2013-03-27 17:47:22 +0800841 .enable_time = 140,
Lee Jonesb080c782013-03-28 16:11:17 +0000842 .volt_table = fixed_2000000_voltage,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100843 },
Bengt Jonsson6909b452010-12-10 11:08:47 +0100844 .update_bank = 0x03,
845 .update_reg = 0x83,
846 .update_mask = 0x02,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000847 .update_val = 0x02,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100848 },
849 [AB8500_LDO_ANAMIC1] = {
850 .desc = {
851 .name = "LDO-ANAMIC1",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000852 .ops = &ab8500_regulator_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100853 .type = REGULATOR_VOLTAGE,
854 .id = AB8500_LDO_ANAMIC1,
855 .owner = THIS_MODULE,
856 .n_voltages = 1,
Axel Lin530158b2013-03-27 17:47:22 +0800857 .enable_time = 500,
Lee Jonesb080c782013-03-28 16:11:17 +0000858 .volt_table = fixed_2050000_voltage,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100859 },
Bengt Jonsson6909b452010-12-10 11:08:47 +0100860 .update_bank = 0x03,
861 .update_reg = 0x83,
862 .update_mask = 0x08,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000863 .update_val = 0x08,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100864 },
865 [AB8500_LDO_ANAMIC2] = {
866 .desc = {
867 .name = "LDO-ANAMIC2",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000868 .ops = &ab8500_regulator_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100869 .type = REGULATOR_VOLTAGE,
870 .id = AB8500_LDO_ANAMIC2,
871 .owner = THIS_MODULE,
872 .n_voltages = 1,
Axel Lin530158b2013-03-27 17:47:22 +0800873 .enable_time = 500,
Lee Jonesb080c782013-03-28 16:11:17 +0000874 .volt_table = fixed_2050000_voltage,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100875 },
Bengt Jonsson6909b452010-12-10 11:08:47 +0100876 .update_bank = 0x03,
877 .update_reg = 0x83,
878 .update_mask = 0x10,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000879 .update_val = 0x10,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100880 },
881 [AB8500_LDO_DMIC] = {
882 .desc = {
883 .name = "LDO-DMIC",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000884 .ops = &ab8500_regulator_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100885 .type = REGULATOR_VOLTAGE,
886 .id = AB8500_LDO_DMIC,
887 .owner = THIS_MODULE,
888 .n_voltages = 1,
Axel Lin530158b2013-03-27 17:47:22 +0800889 .enable_time = 420,
Lee Jonesb080c782013-03-28 16:11:17 +0000890 .volt_table = fixed_1800000_voltage,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100891 },
Bengt Jonsson6909b452010-12-10 11:08:47 +0100892 .update_bank = 0x03,
893 .update_reg = 0x83,
894 .update_mask = 0x04,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000895 .update_val = 0x04,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100896 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000897
898 /*
899 * Regulators with fixed voltage and normal/idle modes
900 */
Bengt Jonsson6909b452010-12-10 11:08:47 +0100901 [AB8500_LDO_ANA] = {
902 .desc = {
903 .name = "LDO-ANA",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000904 .ops = &ab8500_regulator_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100905 .type = REGULATOR_VOLTAGE,
906 .id = AB8500_LDO_ANA,
907 .owner = THIS_MODULE,
908 .n_voltages = 1,
Axel Lin530158b2013-03-27 17:47:22 +0800909 .enable_time = 140,
Lee Jonesb080c782013-03-28 16:11:17 +0000910 .volt_table = fixed_1200000_voltage,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100911 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000912 .load_lp_uA = 1000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100913 .update_bank = 0x04,
914 .update_reg = 0x06,
915 .update_mask = 0x0c,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000916 .update_val = 0x04,
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000917 .update_val_idle = 0x0c,
918 .update_val_normal = 0x04,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100919 },
Lee Jones8e6a8d72013-03-28 16:11:11 +0000920};
Bengt Jonsson6909b452010-12-10 11:08:47 +0100921
Lee Jones547f3842013-03-28 16:11:14 +0000922/* AB8505 regulator information */
923static struct ab8500_regulator_info
924 ab8505_regulator_info[AB8505_NUM_REGULATORS] = {
925 /*
926 * Variable Voltage Regulators
927 * name, min mV, max mV,
928 * update bank, reg, mask, enable val
Lee Jonesd3193102013-04-02 13:24:18 +0100929 * volt bank, reg, mask
Lee Jones547f3842013-03-28 16:11:14 +0000930 */
931 [AB8505_LDO_AUX1] = {
932 .desc = {
933 .name = "LDO-AUX1",
934 .ops = &ab8500_regulator_volt_mode_ops,
935 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +0100936 .id = AB8505_LDO_AUX1,
Lee Jones547f3842013-03-28 16:11:14 +0000937 .owner = THIS_MODULE,
938 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +0000939 .volt_table = ldo_vauxn_voltages,
Lee Jones547f3842013-03-28 16:11:14 +0000940 },
Lee Jones547f3842013-03-28 16:11:14 +0000941 .load_lp_uA = 5000,
942 .update_bank = 0x04,
943 .update_reg = 0x09,
944 .update_mask = 0x03,
945 .update_val = 0x01,
946 .update_val_idle = 0x03,
947 .update_val_normal = 0x01,
948 .voltage_bank = 0x04,
949 .voltage_reg = 0x1f,
950 .voltage_mask = 0x0f,
Lee Jones547f3842013-03-28 16:11:14 +0000951 },
952 [AB8505_LDO_AUX2] = {
953 .desc = {
954 .name = "LDO-AUX2",
955 .ops = &ab8500_regulator_volt_mode_ops,
956 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +0100957 .id = AB8505_LDO_AUX2,
Lee Jones547f3842013-03-28 16:11:14 +0000958 .owner = THIS_MODULE,
959 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +0000960 .volt_table = ldo_vauxn_voltages,
Lee Jones547f3842013-03-28 16:11:14 +0000961 },
Lee Jones547f3842013-03-28 16:11:14 +0000962 .load_lp_uA = 5000,
963 .update_bank = 0x04,
964 .update_reg = 0x09,
965 .update_mask = 0x0c,
966 .update_val = 0x04,
967 .update_val_idle = 0x0c,
968 .update_val_normal = 0x04,
969 .voltage_bank = 0x04,
970 .voltage_reg = 0x20,
971 .voltage_mask = 0x0f,
Lee Jones547f3842013-03-28 16:11:14 +0000972 },
973 [AB8505_LDO_AUX3] = {
974 .desc = {
975 .name = "LDO-AUX3",
976 .ops = &ab8500_regulator_volt_mode_ops,
977 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +0100978 .id = AB8505_LDO_AUX3,
Lee Jones547f3842013-03-28 16:11:14 +0000979 .owner = THIS_MODULE,
980 .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +0000981 .volt_table = ldo_vaux3_voltages,
Lee Jones547f3842013-03-28 16:11:14 +0000982 },
Lee Jones547f3842013-03-28 16:11:14 +0000983 .load_lp_uA = 5000,
984 .update_bank = 0x04,
985 .update_reg = 0x0a,
986 .update_mask = 0x03,
987 .update_val = 0x01,
988 .update_val_idle = 0x03,
989 .update_val_normal = 0x01,
990 .voltage_bank = 0x04,
991 .voltage_reg = 0x21,
992 .voltage_mask = 0x07,
Lee Jones547f3842013-03-28 16:11:14 +0000993 },
994 [AB8505_LDO_AUX4] = {
995 .desc = {
996 .name = "LDO-AUX4",
997 .ops = &ab8500_regulator_volt_mode_ops,
998 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +0100999 .id = AB8505_LDO_AUX4,
Lee Jones547f3842013-03-28 16:11:14 +00001000 .owner = THIS_MODULE,
1001 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001002 .volt_table = ldo_vauxn_voltages,
Lee Jones547f3842013-03-28 16:11:14 +00001003 },
Lee Jones547f3842013-03-28 16:11:14 +00001004 .load_lp_uA = 5000,
1005 /* values for Vaux4Regu register */
1006 .update_bank = 0x04,
1007 .update_reg = 0x2e,
1008 .update_mask = 0x03,
1009 .update_val = 0x01,
1010 .update_val_idle = 0x03,
1011 .update_val_normal = 0x01,
1012 /* values for Vaux4SEL register */
1013 .voltage_bank = 0x04,
1014 .voltage_reg = 0x2f,
1015 .voltage_mask = 0x0f,
Lee Jones547f3842013-03-28 16:11:14 +00001016 },
1017 [AB8505_LDO_AUX5] = {
1018 .desc = {
1019 .name = "LDO-AUX5",
1020 .ops = &ab8500_regulator_volt_mode_ops,
1021 .type = REGULATOR_VOLTAGE,
1022 .id = AB8505_LDO_AUX5,
1023 .owner = THIS_MODULE,
1024 .n_voltages = ARRAY_SIZE(ldo_vaux56_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001025 .volt_table = ldo_vaux56_voltages,
Lee Jones547f3842013-03-28 16:11:14 +00001026 },
Lee Jones547f3842013-03-28 16:11:14 +00001027 .load_lp_uA = 2000,
1028 /* values for CtrlVaux5 register */
1029 .update_bank = 0x01,
1030 .update_reg = 0x55,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001031 .update_mask = 0x18,
1032 .update_val = 0x10,
1033 .update_val_idle = 0x18,
1034 .update_val_normal = 0x10,
Lee Jones547f3842013-03-28 16:11:14 +00001035 .voltage_bank = 0x01,
1036 .voltage_reg = 0x55,
1037 .voltage_mask = 0x07,
Lee Jones547f3842013-03-28 16:11:14 +00001038 },
1039 [AB8505_LDO_AUX6] = {
1040 .desc = {
1041 .name = "LDO-AUX6",
1042 .ops = &ab8500_regulator_volt_mode_ops,
1043 .type = REGULATOR_VOLTAGE,
1044 .id = AB8505_LDO_AUX6,
1045 .owner = THIS_MODULE,
1046 .n_voltages = ARRAY_SIZE(ldo_vaux56_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001047 .volt_table = ldo_vaux56_voltages,
Lee Jones547f3842013-03-28 16:11:14 +00001048 },
Lee Jones547f3842013-03-28 16:11:14 +00001049 .load_lp_uA = 2000,
1050 /* values for CtrlVaux6 register */
1051 .update_bank = 0x01,
1052 .update_reg = 0x56,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001053 .update_mask = 0x18,
1054 .update_val = 0x10,
1055 .update_val_idle = 0x18,
1056 .update_val_normal = 0x10,
Lee Jones547f3842013-03-28 16:11:14 +00001057 .voltage_bank = 0x01,
1058 .voltage_reg = 0x56,
1059 .voltage_mask = 0x07,
Lee Jones547f3842013-03-28 16:11:14 +00001060 },
1061 [AB8505_LDO_INTCORE] = {
1062 .desc = {
1063 .name = "LDO-INTCORE",
1064 .ops = &ab8500_regulator_volt_mode_ops,
1065 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001066 .id = AB8505_LDO_INTCORE,
Lee Jones547f3842013-03-28 16:11:14 +00001067 .owner = THIS_MODULE,
1068 .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001069 .volt_table = ldo_vintcore_voltages,
Lee Jones547f3842013-03-28 16:11:14 +00001070 },
Lee Jones547f3842013-03-28 16:11:14 +00001071 .load_lp_uA = 5000,
1072 .update_bank = 0x03,
1073 .update_reg = 0x80,
1074 .update_mask = 0x44,
1075 .update_val = 0x04,
1076 .update_val_idle = 0x44,
1077 .update_val_normal = 0x04,
1078 .voltage_bank = 0x03,
1079 .voltage_reg = 0x80,
1080 .voltage_mask = 0x38,
Lee Jones547f3842013-03-28 16:11:14 +00001081 .voltage_shift = 3,
1082 },
1083
1084 /*
1085 * Fixed Voltage Regulators
1086 * name, fixed mV,
1087 * update bank, reg, mask, enable val
1088 */
1089 [AB8505_LDO_ADC] = {
1090 .desc = {
1091 .name = "LDO-ADC",
1092 .ops = &ab8500_regulator_mode_ops,
1093 .type = REGULATOR_VOLTAGE,
1094 .id = AB8505_LDO_ADC,
1095 .owner = THIS_MODULE,
1096 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001097 .volt_table = fixed_2000000_voltage,
Lee Jonesa4d68462013-04-02 13:24:16 +01001098 .enable_time = 10000,
Lee Jones547f3842013-03-28 16:11:14 +00001099 },
Lee Jones547f3842013-03-28 16:11:14 +00001100 .load_lp_uA = 1000,
1101 .update_bank = 0x03,
1102 .update_reg = 0x80,
1103 .update_mask = 0x82,
1104 .update_val = 0x02,
1105 .update_val_idle = 0x82,
1106 .update_val_normal = 0x02,
1107 },
1108 [AB8505_LDO_USB] = {
1109 .desc = {
1110 .name = "LDO-USB",
1111 .ops = &ab8500_regulator_mode_ops,
1112 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001113 .id = AB8505_LDO_USB,
Lee Jones547f3842013-03-28 16:11:14 +00001114 .owner = THIS_MODULE,
1115 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001116 .volt_table = fixed_3300000_voltage,
Lee Jones547f3842013-03-28 16:11:14 +00001117 },
Lee Jones547f3842013-03-28 16:11:14 +00001118 .update_bank = 0x03,
1119 .update_reg = 0x82,
1120 .update_mask = 0x03,
1121 .update_val = 0x01,
1122 .update_val_idle = 0x03,
1123 .update_val_normal = 0x01,
1124 },
1125 [AB8505_LDO_AUDIO] = {
1126 .desc = {
1127 .name = "LDO-AUDIO",
Lee Jones8a3b1b82013-04-02 13:24:09 +01001128 .ops = &ab8500_regulator_volt_ops,
Lee Jones547f3842013-03-28 16:11:14 +00001129 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001130 .id = AB8505_LDO_AUDIO,
Lee Jones547f3842013-03-28 16:11:14 +00001131 .owner = THIS_MODULE,
Lee Jones8a3b1b82013-04-02 13:24:09 +01001132 .n_voltages = ARRAY_SIZE(ldo_vaudio_voltages),
1133 .volt_table = ldo_vaudio_voltages,
Lee Jones547f3842013-03-28 16:11:14 +00001134 },
Lee Jones547f3842013-03-28 16:11:14 +00001135 .update_bank = 0x03,
1136 .update_reg = 0x83,
1137 .update_mask = 0x02,
1138 .update_val = 0x02,
Lee Jones8a3b1b82013-04-02 13:24:09 +01001139 .voltage_bank = 0x01,
1140 .voltage_reg = 0x57,
1141 .voltage_mask = 0x7,
1142 .voltage_shift = 4,
Lee Jones547f3842013-03-28 16:11:14 +00001143 },
1144 [AB8505_LDO_ANAMIC1] = {
1145 .desc = {
1146 .name = "LDO-ANAMIC1",
Lee Jones3fe52282013-04-02 13:24:12 +01001147 .ops = &ab8500_regulator_anamic_mode_ops,
Lee Jones547f3842013-03-28 16:11:14 +00001148 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001149 .id = AB8505_LDO_ANAMIC1,
Lee Jones547f3842013-03-28 16:11:14 +00001150 .owner = THIS_MODULE,
1151 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001152 .volt_table = fixed_2050000_voltage,
Lee Jones547f3842013-03-28 16:11:14 +00001153 },
Lee Jones4c84b4d2013-04-02 13:24:13 +01001154 .shared_mode = &ldo_anamic1_shared,
Lee Jones547f3842013-03-28 16:11:14 +00001155 .update_bank = 0x03,
1156 .update_reg = 0x83,
1157 .update_mask = 0x08,
1158 .update_val = 0x08,
Lee Jones3fe52282013-04-02 13:24:12 +01001159 .mode_bank = 0x01,
1160 .mode_reg = 0x54,
1161 .mode_mask = 0x04,
1162 .mode_val_idle = 0x04,
1163 .mode_val_normal = 0x00,
Lee Jones547f3842013-03-28 16:11:14 +00001164 },
1165 [AB8505_LDO_ANAMIC2] = {
1166 .desc = {
1167 .name = "LDO-ANAMIC2",
Lee Jones3fe52282013-04-02 13:24:12 +01001168 .ops = &ab8500_regulator_anamic_mode_ops,
Lee Jones547f3842013-03-28 16:11:14 +00001169 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001170 .id = AB8505_LDO_ANAMIC2,
Lee Jones547f3842013-03-28 16:11:14 +00001171 .owner = THIS_MODULE,
1172 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001173 .volt_table = fixed_2050000_voltage,
Lee Jones547f3842013-03-28 16:11:14 +00001174 },
Lee Jones3fe52282013-04-02 13:24:12 +01001175 .shared_mode = &ldo_anamic2_shared,
Lee Jones547f3842013-03-28 16:11:14 +00001176 .update_bank = 0x03,
1177 .update_reg = 0x83,
1178 .update_mask = 0x10,
1179 .update_val = 0x10,
Lee Jones3fe52282013-04-02 13:24:12 +01001180 .mode_bank = 0x01,
1181 .mode_reg = 0x54,
1182 .mode_mask = 0x04,
1183 .mode_val_idle = 0x04,
1184 .mode_val_normal = 0x00,
Lee Jones547f3842013-03-28 16:11:14 +00001185 },
1186 [AB8505_LDO_AUX8] = {
1187 .desc = {
1188 .name = "LDO-AUX8",
1189 .ops = &ab8500_regulator_ops,
1190 .type = REGULATOR_VOLTAGE,
1191 .id = AB8505_LDO_AUX8,
1192 .owner = THIS_MODULE,
1193 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001194 .volt_table = fixed_1800000_voltage,
Lee Jones547f3842013-03-28 16:11:14 +00001195 },
Lee Jones547f3842013-03-28 16:11:14 +00001196 .update_bank = 0x03,
1197 .update_reg = 0x83,
1198 .update_mask = 0x04,
1199 .update_val = 0x04,
1200 },
1201 /*
1202 * Regulators with fixed voltage and normal/idle modes
1203 */
1204 [AB8505_LDO_ANA] = {
1205 .desc = {
1206 .name = "LDO-ANA",
Lee Jones8a3b1b82013-04-02 13:24:09 +01001207 .ops = &ab8500_regulator_volt_mode_ops,
Lee Jones547f3842013-03-28 16:11:14 +00001208 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001209 .id = AB8505_LDO_ANA,
Lee Jones547f3842013-03-28 16:11:14 +00001210 .owner = THIS_MODULE,
Lee Jones8a3b1b82013-04-02 13:24:09 +01001211 .n_voltages = ARRAY_SIZE(ldo_vana_voltages),
1212 .volt_table = ldo_vana_voltages,
Lee Jones547f3842013-03-28 16:11:14 +00001213 },
Lee Jones547f3842013-03-28 16:11:14 +00001214 .load_lp_uA = 1000,
1215 .update_bank = 0x04,
1216 .update_reg = 0x06,
1217 .update_mask = 0x0c,
1218 .update_val = 0x04,
1219 .update_val_idle = 0x0c,
1220 .update_val_normal = 0x04,
Lee Jones8a3b1b82013-04-02 13:24:09 +01001221 .voltage_bank = 0x04,
1222 .voltage_reg = 0x29,
1223 .voltage_mask = 0x7,
Lee Jones547f3842013-03-28 16:11:14 +00001224 },
1225};
1226
Lee Jones8e6a8d72013-03-28 16:11:11 +00001227/* AB9540 regulator information */
1228static struct ab8500_regulator_info
1229 ab9540_regulator_info[AB9540_NUM_REGULATORS] = {
1230 /*
1231 * Variable Voltage Regulators
1232 * name, min mV, max mV,
1233 * update bank, reg, mask, enable val
Lee Jonesd3193102013-04-02 13:24:18 +01001234 * volt bank, reg, mask
Lee Jones8e6a8d72013-03-28 16:11:11 +00001235 */
1236 [AB9540_LDO_AUX1] = {
1237 .desc = {
1238 .name = "LDO-AUX1",
1239 .ops = &ab8500_regulator_volt_mode_ops,
1240 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001241 .id = AB9540_LDO_AUX1,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001242 .owner = THIS_MODULE,
1243 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001244 .volt_table = ldo_vauxn_voltages,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001245 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001246 .load_lp_uA = 5000,
1247 .update_bank = 0x04,
1248 .update_reg = 0x09,
1249 .update_mask = 0x03,
1250 .update_val = 0x01,
1251 .update_val_idle = 0x03,
1252 .update_val_normal = 0x01,
1253 .voltage_bank = 0x04,
1254 .voltage_reg = 0x1f,
1255 .voltage_mask = 0x0f,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001256 },
1257 [AB9540_LDO_AUX2] = {
1258 .desc = {
1259 .name = "LDO-AUX2",
1260 .ops = &ab8500_regulator_volt_mode_ops,
1261 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001262 .id = AB9540_LDO_AUX2,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001263 .owner = THIS_MODULE,
1264 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001265 .volt_table = ldo_vauxn_voltages,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001266 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001267 .load_lp_uA = 5000,
1268 .update_bank = 0x04,
1269 .update_reg = 0x09,
1270 .update_mask = 0x0c,
1271 .update_val = 0x04,
1272 .update_val_idle = 0x0c,
1273 .update_val_normal = 0x04,
1274 .voltage_bank = 0x04,
1275 .voltage_reg = 0x20,
1276 .voltage_mask = 0x0f,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001277 },
1278 [AB9540_LDO_AUX3] = {
1279 .desc = {
1280 .name = "LDO-AUX3",
1281 .ops = &ab8500_regulator_volt_mode_ops,
1282 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001283 .id = AB9540_LDO_AUX3,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001284 .owner = THIS_MODULE,
1285 .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001286 .volt_table = ldo_vaux3_voltages,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001287 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001288 .load_lp_uA = 5000,
1289 .update_bank = 0x04,
1290 .update_reg = 0x0a,
1291 .update_mask = 0x03,
1292 .update_val = 0x01,
1293 .update_val_idle = 0x03,
1294 .update_val_normal = 0x01,
1295 .voltage_bank = 0x04,
1296 .voltage_reg = 0x21,
1297 .voltage_mask = 0x07,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001298 },
1299 [AB9540_LDO_AUX4] = {
1300 .desc = {
1301 .name = "LDO-AUX4",
1302 .ops = &ab8500_regulator_volt_mode_ops,
1303 .type = REGULATOR_VOLTAGE,
1304 .id = AB9540_LDO_AUX4,
1305 .owner = THIS_MODULE,
1306 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001307 .volt_table = ldo_vauxn_voltages,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001308 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001309 .load_lp_uA = 5000,
1310 /* values for Vaux4Regu register */
1311 .update_bank = 0x04,
1312 .update_reg = 0x2e,
1313 .update_mask = 0x03,
1314 .update_val = 0x01,
1315 .update_val_idle = 0x03,
1316 .update_val_normal = 0x01,
1317 /* values for Vaux4SEL register */
1318 .voltage_bank = 0x04,
1319 .voltage_reg = 0x2f,
1320 .voltage_mask = 0x0f,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001321 },
1322 [AB9540_LDO_INTCORE] = {
1323 .desc = {
1324 .name = "LDO-INTCORE",
1325 .ops = &ab8500_regulator_volt_mode_ops,
1326 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001327 .id = AB9540_LDO_INTCORE,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001328 .owner = THIS_MODULE,
1329 .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001330 .volt_table = ldo_vintcore_voltages,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001331 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001332 .load_lp_uA = 5000,
1333 .update_bank = 0x03,
1334 .update_reg = 0x80,
1335 .update_mask = 0x44,
1336 .update_val = 0x44,
1337 .update_val_idle = 0x44,
1338 .update_val_normal = 0x04,
1339 .voltage_bank = 0x03,
1340 .voltage_reg = 0x80,
1341 .voltage_mask = 0x38,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001342 .voltage_shift = 3,
1343 },
Bengt Jonsson6909b452010-12-10 11:08:47 +01001344
Lee Jones8e6a8d72013-03-28 16:11:11 +00001345 /*
1346 * Fixed Voltage Regulators
1347 * name, fixed mV,
1348 * update bank, reg, mask, enable val
1349 */
1350 [AB9540_LDO_TVOUT] = {
1351 .desc = {
1352 .name = "LDO-TVOUT",
1353 .ops = &ab8500_regulator_mode_ops,
1354 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001355 .id = AB9540_LDO_TVOUT,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001356 .owner = THIS_MODULE,
1357 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001358 .volt_table = fixed_2000000_voltage,
Lee Jonesa4d68462013-04-02 13:24:16 +01001359 .enable_time = 10000,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001360 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001361 .load_lp_uA = 1000,
1362 .update_bank = 0x03,
1363 .update_reg = 0x80,
1364 .update_mask = 0x82,
1365 .update_val = 0x02,
1366 .update_val_idle = 0x82,
1367 .update_val_normal = 0x02,
1368 },
1369 [AB9540_LDO_USB] = {
1370 .desc = {
1371 .name = "LDO-USB",
1372 .ops = &ab8500_regulator_ops,
1373 .type = REGULATOR_VOLTAGE,
1374 .id = AB9540_LDO_USB,
1375 .owner = THIS_MODULE,
1376 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001377 .volt_table = fixed_3300000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001378 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001379 .update_bank = 0x03,
1380 .update_reg = 0x82,
1381 .update_mask = 0x03,
1382 .update_val = 0x01,
1383 .update_val_idle = 0x03,
1384 .update_val_normal = 0x01,
1385 },
1386 [AB9540_LDO_AUDIO] = {
1387 .desc = {
1388 .name = "LDO-AUDIO",
1389 .ops = &ab8500_regulator_ops,
1390 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001391 .id = AB9540_LDO_AUDIO,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001392 .owner = THIS_MODULE,
1393 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001394 .volt_table = fixed_2000000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001395 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001396 .update_bank = 0x03,
1397 .update_reg = 0x83,
1398 .update_mask = 0x02,
1399 .update_val = 0x02,
1400 },
1401 [AB9540_LDO_ANAMIC1] = {
1402 .desc = {
1403 .name = "LDO-ANAMIC1",
1404 .ops = &ab8500_regulator_ops,
1405 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001406 .id = AB9540_LDO_ANAMIC1,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001407 .owner = THIS_MODULE,
1408 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001409 .volt_table = fixed_2050000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001410 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001411 .update_bank = 0x03,
1412 .update_reg = 0x83,
1413 .update_mask = 0x08,
1414 .update_val = 0x08,
1415 },
1416 [AB9540_LDO_ANAMIC2] = {
1417 .desc = {
1418 .name = "LDO-ANAMIC2",
1419 .ops = &ab8500_regulator_ops,
1420 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001421 .id = AB9540_LDO_ANAMIC2,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001422 .owner = THIS_MODULE,
1423 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001424 .volt_table = fixed_2050000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001425 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001426 .update_bank = 0x03,
1427 .update_reg = 0x83,
1428 .update_mask = 0x10,
1429 .update_val = 0x10,
1430 },
1431 [AB9540_LDO_DMIC] = {
1432 .desc = {
1433 .name = "LDO-DMIC",
1434 .ops = &ab8500_regulator_ops,
1435 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001436 .id = AB9540_LDO_DMIC,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001437 .owner = THIS_MODULE,
1438 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001439 .volt_table = fixed_1800000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001440 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001441 .update_bank = 0x03,
1442 .update_reg = 0x83,
1443 .update_mask = 0x04,
1444 .update_val = 0x04,
1445 },
1446
1447 /*
1448 * Regulators with fixed voltage and normal/idle modes
1449 */
1450 [AB9540_LDO_ANA] = {
1451 .desc = {
1452 .name = "LDO-ANA",
1453 .ops = &ab8500_regulator_mode_ops,
1454 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001455 .id = AB9540_LDO_ANA,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001456 .owner = THIS_MODULE,
1457 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001458 .volt_table = fixed_1200000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001459 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001460 .load_lp_uA = 1000,
1461 .update_bank = 0x04,
1462 .update_reg = 0x06,
1463 .update_mask = 0x0c,
1464 .update_val = 0x08,
1465 .update_val_idle = 0x0c,
1466 .update_val_normal = 0x08,
1467 },
Sundar R IYERc789ca22010-07-13 21:48:56 +05301468};
1469
Lee Jonesae0a9a32013-03-28 16:11:16 +00001470/* AB8540 regulator information */
1471static struct ab8500_regulator_info
1472 ab8540_regulator_info[AB8540_NUM_REGULATORS] = {
1473 /*
1474 * Variable Voltage Regulators
1475 * name, min mV, max mV,
1476 * update bank, reg, mask, enable val
Lee Jonesd3193102013-04-02 13:24:18 +01001477 * volt bank, reg, mask
Lee Jonesae0a9a32013-03-28 16:11:16 +00001478 */
1479 [AB8540_LDO_AUX1] = {
1480 .desc = {
1481 .name = "LDO-AUX1",
1482 .ops = &ab8500_regulator_volt_mode_ops,
1483 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001484 .id = AB8540_LDO_AUX1,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001485 .owner = THIS_MODULE,
1486 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001487 .volt_table = ldo_vauxn_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001488 },
1489 .load_lp_uA = 5000,
1490 .update_bank = 0x04,
1491 .update_reg = 0x09,
1492 .update_mask = 0x03,
1493 .update_val = 0x01,
1494 .update_val_idle = 0x03,
1495 .update_val_normal = 0x01,
1496 .voltage_bank = 0x04,
1497 .voltage_reg = 0x1f,
1498 .voltage_mask = 0x0f,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001499 },
1500 [AB8540_LDO_AUX2] = {
1501 .desc = {
1502 .name = "LDO-AUX2",
1503 .ops = &ab8500_regulator_volt_mode_ops,
1504 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001505 .id = AB8540_LDO_AUX2,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001506 .owner = THIS_MODULE,
1507 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001508 .volt_table = ldo_vauxn_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001509 },
1510 .load_lp_uA = 5000,
1511 .update_bank = 0x04,
1512 .update_reg = 0x09,
1513 .update_mask = 0x0c,
1514 .update_val = 0x04,
1515 .update_val_idle = 0x0c,
1516 .update_val_normal = 0x04,
1517 .voltage_bank = 0x04,
1518 .voltage_reg = 0x20,
1519 .voltage_mask = 0x0f,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001520 },
1521 [AB8540_LDO_AUX3] = {
1522 .desc = {
1523 .name = "LDO-AUX3",
Lee Jonesd7607ba2013-04-02 13:24:11 +01001524 .ops = &ab8540_aux3_regulator_volt_mode_ops,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001525 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001526 .id = AB8540_LDO_AUX3,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001527 .owner = THIS_MODULE,
1528 .n_voltages = ARRAY_SIZE(ldo_vaux3_ab8540_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001529 .volt_table = ldo_vaux3_ab8540_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001530 },
1531 .load_lp_uA = 5000,
1532 .update_bank = 0x04,
1533 .update_reg = 0x0a,
1534 .update_mask = 0x03,
1535 .update_val = 0x01,
1536 .update_val_idle = 0x03,
1537 .update_val_normal = 0x01,
1538 .voltage_bank = 0x04,
1539 .voltage_reg = 0x21,
1540 .voltage_mask = 0x07,
Lee Jonesd7607ba2013-04-02 13:24:11 +01001541 .expand_register = {
1542 .voltage_limit = 8,
1543 .voltage_bank = 0x04,
1544 .voltage_reg = 0x01,
1545 .voltage_mask = 0x10,
1546 .voltage_shift = 1,
1547 }
Lee Jonesae0a9a32013-03-28 16:11:16 +00001548 },
1549 [AB8540_LDO_AUX4] = {
1550 .desc = {
1551 .name = "LDO-AUX4",
1552 .ops = &ab8500_regulator_volt_mode_ops,
1553 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001554 .id = AB8540_LDO_AUX4,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001555 .owner = THIS_MODULE,
1556 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001557 .volt_table = ldo_vauxn_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001558 },
1559 .load_lp_uA = 5000,
1560 /* values for Vaux4Regu register */
1561 .update_bank = 0x04,
1562 .update_reg = 0x2e,
1563 .update_mask = 0x03,
1564 .update_val = 0x01,
1565 .update_val_idle = 0x03,
1566 .update_val_normal = 0x01,
1567 /* values for Vaux4SEL register */
1568 .voltage_bank = 0x04,
1569 .voltage_reg = 0x2f,
1570 .voltage_mask = 0x0f,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001571 },
Zhenhua HUANG684d5ce2013-04-02 13:24:15 +01001572 [AB8540_LDO_AUX5] = {
1573 .desc = {
1574 .name = "LDO-AUX5",
1575 .ops = &ab8500_regulator_volt_mode_ops,
1576 .type = REGULATOR_VOLTAGE,
1577 .id = AB8540_LDO_AUX5,
1578 .owner = THIS_MODULE,
1579 .n_voltages = ARRAY_SIZE(ldo_vaux56_ab8540_voltages),
Lee Jonesd3193102013-04-02 13:24:18 +01001580 .volt_table = ldo_vaux56_ab8540_voltages,
Zhenhua HUANG684d5ce2013-04-02 13:24:15 +01001581 },
1582 .load_lp_uA = 20000,
1583 /* values for Vaux5Regu register */
1584 .update_bank = 0x04,
1585 .update_reg = 0x32,
1586 .update_mask = 0x03,
1587 .update_val = 0x01,
1588 .update_val_idle = 0x03,
1589 .update_val_normal = 0x01,
1590 /* values for Vaux5SEL register */
1591 .voltage_bank = 0x04,
1592 .voltage_reg = 0x33,
1593 .voltage_mask = 0x3f,
Zhenhua HUANG684d5ce2013-04-02 13:24:15 +01001594 },
1595 [AB8540_LDO_AUX6] = {
1596 .desc = {
1597 .name = "LDO-AUX6",
1598 .ops = &ab8500_regulator_volt_mode_ops,
1599 .type = REGULATOR_VOLTAGE,
1600 .id = AB8540_LDO_AUX6,
1601 .owner = THIS_MODULE,
1602 .n_voltages = ARRAY_SIZE(ldo_vaux56_ab8540_voltages),
Lee Jonesd3193102013-04-02 13:24:18 +01001603 .volt_table = ldo_vaux56_ab8540_voltages,
Zhenhua HUANG684d5ce2013-04-02 13:24:15 +01001604 },
1605 .load_lp_uA = 20000,
1606 /* values for Vaux6Regu register */
1607 .update_bank = 0x04,
1608 .update_reg = 0x35,
1609 .update_mask = 0x03,
1610 .update_val = 0x01,
1611 .update_val_idle = 0x03,
1612 .update_val_normal = 0x01,
1613 /* values for Vaux6SEL register */
1614 .voltage_bank = 0x04,
1615 .voltage_reg = 0x36,
1616 .voltage_mask = 0x3f,
Zhenhua HUANG684d5ce2013-04-02 13:24:15 +01001617 },
Lee Jonesae0a9a32013-03-28 16:11:16 +00001618 [AB8540_LDO_INTCORE] = {
1619 .desc = {
1620 .name = "LDO-INTCORE",
1621 .ops = &ab8500_regulator_volt_mode_ops,
1622 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001623 .id = AB8540_LDO_INTCORE,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001624 .owner = THIS_MODULE,
1625 .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001626 .volt_table = ldo_vintcore_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001627 },
1628 .load_lp_uA = 5000,
1629 .update_bank = 0x03,
1630 .update_reg = 0x80,
1631 .update_mask = 0x44,
1632 .update_val = 0x44,
1633 .update_val_idle = 0x44,
1634 .update_val_normal = 0x04,
1635 .voltage_bank = 0x03,
1636 .voltage_reg = 0x80,
1637 .voltage_mask = 0x38,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001638 .voltage_shift = 3,
1639 },
1640
1641 /*
1642 * Fixed Voltage Regulators
1643 * name, fixed mV,
1644 * update bank, reg, mask, enable val
1645 */
1646 [AB8540_LDO_TVOUT] = {
1647 .desc = {
1648 .name = "LDO-TVOUT",
1649 .ops = &ab8500_regulator_mode_ops,
1650 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001651 .id = AB8540_LDO_TVOUT,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001652 .owner = THIS_MODULE,
1653 .n_voltages = 1,
Axel Linaca45e92013-04-02 13:24:23 +01001654 .volt_table = fixed_2000000_voltage,
Lee Jonesa4d68462013-04-02 13:24:16 +01001655 .enable_time = 10000,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001656 },
Lee Jonesae0a9a32013-03-28 16:11:16 +00001657 .load_lp_uA = 1000,
1658 .update_bank = 0x03,
1659 .update_reg = 0x80,
1660 .update_mask = 0x82,
1661 .update_val = 0x02,
1662 .update_val_idle = 0x82,
1663 .update_val_normal = 0x02,
1664 },
1665 [AB8540_LDO_AUDIO] = {
1666 .desc = {
1667 .name = "LDO-AUDIO",
1668 .ops = &ab8500_regulator_ops,
1669 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001670 .id = AB8540_LDO_AUDIO,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001671 .owner = THIS_MODULE,
1672 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001673 .volt_table = fixed_2000000_voltage,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001674 },
1675 .update_bank = 0x03,
1676 .update_reg = 0x83,
1677 .update_mask = 0x02,
1678 .update_val = 0x02,
1679 },
1680 [AB8540_LDO_ANAMIC1] = {
1681 .desc = {
1682 .name = "LDO-ANAMIC1",
Lee Jones4c84b4d2013-04-02 13:24:13 +01001683 .ops = &ab8500_regulator_anamic_mode_ops,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001684 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001685 .id = AB8540_LDO_ANAMIC1,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001686 .owner = THIS_MODULE,
1687 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001688 .volt_table = fixed_2050000_voltage,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001689 },
Lee Jones4c84b4d2013-04-02 13:24:13 +01001690 .shared_mode = &ab8540_ldo_anamic1_shared,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001691 .update_bank = 0x03,
1692 .update_reg = 0x83,
1693 .update_mask = 0x08,
1694 .update_val = 0x08,
Lee Jones4c84b4d2013-04-02 13:24:13 +01001695 .mode_bank = 0x03,
1696 .mode_reg = 0x83,
1697 .mode_mask = 0x20,
1698 .mode_val_idle = 0x20,
1699 .mode_val_normal = 0x00,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001700 },
1701 [AB8540_LDO_ANAMIC2] = {
1702 .desc = {
1703 .name = "LDO-ANAMIC2",
Lee Jones4c84b4d2013-04-02 13:24:13 +01001704 .ops = &ab8500_regulator_anamic_mode_ops,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001705 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001706 .id = AB8540_LDO_ANAMIC2,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001707 .owner = THIS_MODULE,
1708 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001709 .volt_table = fixed_2050000_voltage,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001710 },
Lee Jones4c84b4d2013-04-02 13:24:13 +01001711 .shared_mode = &ab8540_ldo_anamic2_shared,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001712 .update_bank = 0x03,
1713 .update_reg = 0x83,
1714 .update_mask = 0x10,
1715 .update_val = 0x10,
Lee Jones4c84b4d2013-04-02 13:24:13 +01001716 .mode_bank = 0x03,
1717 .mode_reg = 0x83,
1718 .mode_mask = 0x20,
1719 .mode_val_idle = 0x20,
1720 .mode_val_normal = 0x00,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001721 },
1722 [AB8540_LDO_DMIC] = {
1723 .desc = {
1724 .name = "LDO-DMIC",
Lee Jones4c84b4d2013-04-02 13:24:13 +01001725 .ops = &ab8500_regulator_volt_mode_ops,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001726 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001727 .id = AB8540_LDO_DMIC,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001728 .owner = THIS_MODULE,
Lee Jones4c84b4d2013-04-02 13:24:13 +01001729 .n_voltages = ARRAY_SIZE(ldo_vdmic_voltages),
Lee Jonesd3193102013-04-02 13:24:18 +01001730 .volt_table = ldo_vdmic_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001731 },
Lee Jones4c84b4d2013-04-02 13:24:13 +01001732 .load_lp_uA = 1000,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001733 .update_bank = 0x03,
1734 .update_reg = 0x83,
1735 .update_mask = 0x04,
1736 .update_val = 0x04,
Lee Jones4c84b4d2013-04-02 13:24:13 +01001737 .voltage_bank = 0x03,
1738 .voltage_reg = 0x83,
1739 .voltage_mask = 0xc0,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001740 },
1741
1742 /*
1743 * Regulators with fixed voltage and normal/idle modes
1744 */
1745 [AB8540_LDO_ANA] = {
1746 .desc = {
1747 .name = "LDO-ANA",
1748 .ops = &ab8500_regulator_mode_ops,
1749 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001750 .id = AB8540_LDO_ANA,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001751 .owner = THIS_MODULE,
1752 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001753 .volt_table = fixed_1200000_voltage,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001754 },
1755 .load_lp_uA = 1000,
1756 .update_bank = 0x04,
1757 .update_reg = 0x06,
1758 .update_mask = 0x0c,
1759 .update_val = 0x04,
1760 .update_val_idle = 0x0c,
1761 .update_val_normal = 0x04,
1762 },
1763 [AB8540_LDO_SDIO] = {
1764 .desc = {
1765 .name = "LDO-SDIO",
1766 .ops = &ab8500_regulator_volt_mode_ops,
1767 .type = REGULATOR_VOLTAGE,
1768 .id = AB8540_LDO_SDIO,
1769 .owner = THIS_MODULE,
Lee Jones62ab4112013-03-28 16:11:18 +00001770 .n_voltages = ARRAY_SIZE(ldo_sdio_voltages),
1771 .volt_table = ldo_sdio_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001772 },
Lee Jonesae0a9a32013-03-28 16:11:16 +00001773 .load_lp_uA = 5000,
1774 .update_bank = 0x03,
1775 .update_reg = 0x88,
1776 .update_mask = 0x30,
1777 .update_val = 0x10,
1778 .update_val_idle = 0x30,
1779 .update_val_normal = 0x10,
1780 .voltage_bank = 0x03,
1781 .voltage_reg = 0x88,
1782 .voltage_mask = 0x07,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001783 },
1784};
1785
Lee Jones3fe52282013-04-02 13:24:12 +01001786static struct ab8500_shared_mode ldo_anamic1_shared = {
1787 .shared_regulator = &ab8505_regulator_info[AB8505_LDO_ANAMIC2],
1788};
1789
1790static struct ab8500_shared_mode ldo_anamic2_shared = {
1791 .shared_regulator = &ab8505_regulator_info[AB8505_LDO_ANAMIC1],
1792};
1793
Lee Jones4c84b4d2013-04-02 13:24:13 +01001794static struct ab8500_shared_mode ab8540_ldo_anamic1_shared = {
1795 .shared_regulator = &ab8540_regulator_info[AB8540_LDO_ANAMIC2],
1796};
1797
1798static struct ab8500_shared_mode ab8540_ldo_anamic2_shared = {
1799 .shared_regulator = &ab8540_regulator_info[AB8540_LDO_ANAMIC1],
1800};
1801
Bengt Jonsson79568b942011-03-11 11:54:46 +01001802struct ab8500_reg_init {
1803 u8 bank;
1804 u8 addr;
1805 u8 mask;
1806};
1807
1808#define REG_INIT(_id, _bank, _addr, _mask) \
1809 [_id] = { \
1810 .bank = _bank, \
1811 .addr = _addr, \
1812 .mask = _mask, \
1813 }
1814
Lee Jones8e6a8d72013-03-28 16:11:11 +00001815/* AB8500 register init */
Bengt Jonsson79568b942011-03-11 11:54:46 +01001816static struct ab8500_reg_init ab8500_reg_init[] = {
1817 /*
Lee Jones33bc8f42013-03-21 15:59:02 +00001818 * 0x30, VanaRequestCtrl
Bengt Jonsson79568b942011-03-11 11:54:46 +01001819 * 0xc0, VextSupply1RequestCtrl
1820 */
Lee Jones43a59112013-03-21 15:59:15 +00001821 REG_INIT(AB8500_REGUREQUESTCTRL2, 0x03, 0x04, 0xf0),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001822 /*
1823 * 0x03, VextSupply2RequestCtrl
1824 * 0x0c, VextSupply3RequestCtrl
1825 * 0x30, Vaux1RequestCtrl
1826 * 0xc0, Vaux2RequestCtrl
1827 */
1828 REG_INIT(AB8500_REGUREQUESTCTRL3, 0x03, 0x05, 0xff),
1829 /*
1830 * 0x03, Vaux3RequestCtrl
1831 * 0x04, SwHPReq
1832 */
1833 REG_INIT(AB8500_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
1834 /*
1835 * 0x08, VanaSysClkReq1HPValid
1836 * 0x20, Vaux1SysClkReq1HPValid
1837 * 0x40, Vaux2SysClkReq1HPValid
1838 * 0x80, Vaux3SysClkReq1HPValid
1839 */
Lee Jones43a59112013-03-21 15:59:15 +00001840 REG_INIT(AB8500_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xe8),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001841 /*
1842 * 0x10, VextSupply1SysClkReq1HPValid
1843 * 0x20, VextSupply2SysClkReq1HPValid
1844 * 0x40, VextSupply3SysClkReq1HPValid
1845 */
Lee Jones43a59112013-03-21 15:59:15 +00001846 REG_INIT(AB8500_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x70),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001847 /*
1848 * 0x08, VanaHwHPReq1Valid
1849 * 0x20, Vaux1HwHPReq1Valid
1850 * 0x40, Vaux2HwHPReq1Valid
1851 * 0x80, Vaux3HwHPReq1Valid
1852 */
Lee Jones43a59112013-03-21 15:59:15 +00001853 REG_INIT(AB8500_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xe8),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001854 /*
1855 * 0x01, VextSupply1HwHPReq1Valid
1856 * 0x02, VextSupply2HwHPReq1Valid
1857 * 0x04, VextSupply3HwHPReq1Valid
1858 */
Lee Jones43a59112013-03-21 15:59:15 +00001859 REG_INIT(AB8500_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x07),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001860 /*
1861 * 0x08, VanaHwHPReq2Valid
1862 * 0x20, Vaux1HwHPReq2Valid
1863 * 0x40, Vaux2HwHPReq2Valid
1864 * 0x80, Vaux3HwHPReq2Valid
1865 */
Lee Jones43a59112013-03-21 15:59:15 +00001866 REG_INIT(AB8500_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xe8),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001867 /*
1868 * 0x01, VextSupply1HwHPReq2Valid
1869 * 0x02, VextSupply2HwHPReq2Valid
1870 * 0x04, VextSupply3HwHPReq2Valid
1871 */
Lee Jones43a59112013-03-21 15:59:15 +00001872 REG_INIT(AB8500_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x07),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001873 /*
1874 * 0x20, VanaSwHPReqValid
1875 * 0x80, Vaux1SwHPReqValid
1876 */
Lee Jones43a59112013-03-21 15:59:15 +00001877 REG_INIT(AB8500_REGUSWHPREQVALID1, 0x03, 0x0d, 0xa0),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001878 /*
1879 * 0x01, Vaux2SwHPReqValid
1880 * 0x02, Vaux3SwHPReqValid
1881 * 0x04, VextSupply1SwHPReqValid
1882 * 0x08, VextSupply2SwHPReqValid
1883 * 0x10, VextSupply3SwHPReqValid
1884 */
Lee Jones43a59112013-03-21 15:59:15 +00001885 REG_INIT(AB8500_REGUSWHPREQVALID2, 0x03, 0x0e, 0x1f),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001886 /*
1887 * 0x02, SysClkReq2Valid1
Lee Jones43a59112013-03-21 15:59:15 +00001888 * 0x04, SysClkReq3Valid1
1889 * 0x08, SysClkReq4Valid1
1890 * 0x10, SysClkReq5Valid1
1891 * 0x20, SysClkReq6Valid1
1892 * 0x40, SysClkReq7Valid1
Bengt Jonsson79568b942011-03-11 11:54:46 +01001893 * 0x80, SysClkReq8Valid1
1894 */
1895 REG_INIT(AB8500_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0xfe),
1896 /*
1897 * 0x02, SysClkReq2Valid2
Lee Jones43a59112013-03-21 15:59:15 +00001898 * 0x04, SysClkReq3Valid2
1899 * 0x08, SysClkReq4Valid2
1900 * 0x10, SysClkReq5Valid2
1901 * 0x20, SysClkReq6Valid2
1902 * 0x40, SysClkReq7Valid2
Bengt Jonsson79568b942011-03-11 11:54:46 +01001903 * 0x80, SysClkReq8Valid2
1904 */
1905 REG_INIT(AB8500_REGUSYSCLKREQVALID2, 0x03, 0x10, 0xfe),
1906 /*
1907 * 0x02, VTVoutEna
1908 * 0x04, Vintcore12Ena
1909 * 0x38, Vintcore12Sel
1910 * 0x40, Vintcore12LP
1911 * 0x80, VTVoutLP
1912 */
1913 REG_INIT(AB8500_REGUMISC1, 0x03, 0x80, 0xfe),
1914 /*
1915 * 0x02, VaudioEna
1916 * 0x04, VdmicEna
1917 * 0x08, Vamic1Ena
1918 * 0x10, Vamic2Ena
1919 */
1920 REG_INIT(AB8500_VAUDIOSUPPLY, 0x03, 0x83, 0x1e),
1921 /*
1922 * 0x01, Vamic1_dzout
1923 * 0x02, Vamic2_dzout
1924 */
1925 REG_INIT(AB8500_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
1926 /*
Lee Jones43a59112013-03-21 15:59:15 +00001927 * 0x03, VpllRegu (NOTE! PRCMU register bits)
Lee Jones33bc8f42013-03-21 15:59:02 +00001928 * 0x0c, VanaRegu
Bengt Jonsson79568b942011-03-11 11:54:46 +01001929 */
1930 REG_INIT(AB8500_VPLLVANAREGU, 0x04, 0x06, 0x0f),
1931 /*
1932 * 0x01, VrefDDREna
1933 * 0x02, VrefDDRSleepMode
1934 */
1935 REG_INIT(AB8500_VREFDDR, 0x04, 0x07, 0x03),
1936 /*
1937 * 0x03, VextSupply1Regu
1938 * 0x0c, VextSupply2Regu
1939 * 0x30, VextSupply3Regu
1940 * 0x40, ExtSupply2Bypass
1941 * 0x80, ExtSupply3Bypass
1942 */
1943 REG_INIT(AB8500_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
1944 /*
1945 * 0x03, Vaux1Regu
1946 * 0x0c, Vaux2Regu
1947 */
1948 REG_INIT(AB8500_VAUX12REGU, 0x04, 0x09, 0x0f),
1949 /*
1950 * 0x03, Vaux3Regu
1951 */
Lee Jones43a59112013-03-21 15:59:15 +00001952 REG_INIT(AB8500_VRF1VAUX3REGU, 0x04, 0x0a, 0x03),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001953 /*
1954 * 0x0f, Vaux1Sel
1955 */
1956 REG_INIT(AB8500_VAUX1SEL, 0x04, 0x1f, 0x0f),
1957 /*
1958 * 0x0f, Vaux2Sel
1959 */
1960 REG_INIT(AB8500_VAUX2SEL, 0x04, 0x20, 0x0f),
1961 /*
1962 * 0x07, Vaux3Sel
1963 */
Lee Jones43a59112013-03-21 15:59:15 +00001964 REG_INIT(AB8500_VRF1VAUX3SEL, 0x04, 0x21, 0x07),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001965 /*
1966 * 0x01, VextSupply12LP
1967 */
1968 REG_INIT(AB8500_REGUCTRL2SPARE, 0x04, 0x22, 0x01),
1969 /*
1970 * 0x04, Vaux1Disch
1971 * 0x08, Vaux2Disch
1972 * 0x10, Vaux3Disch
1973 * 0x20, Vintcore12Disch
1974 * 0x40, VTVoutDisch
1975 * 0x80, VaudioDisch
1976 */
Lee Jones43a59112013-03-21 15:59:15 +00001977 REG_INIT(AB8500_REGUCTRLDISCH, 0x04, 0x43, 0xfc),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001978 /*
1979 * 0x02, VanaDisch
1980 * 0x04, VdmicPullDownEna
1981 * 0x10, VdmicDisch
1982 */
Lee Jones43a59112013-03-21 15:59:15 +00001983 REG_INIT(AB8500_REGUCTRLDISCH2, 0x04, 0x44, 0x16),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001984};
1985
Lee Jones547f3842013-03-28 16:11:14 +00001986/* AB8505 register init */
1987static struct ab8500_reg_init ab8505_reg_init[] = {
1988 /*
1989 * 0x03, VarmRequestCtrl
1990 * 0x0c, VsmpsCRequestCtrl
1991 * 0x30, VsmpsARequestCtrl
1992 * 0xc0, VsmpsBRequestCtrl
1993 */
1994 REG_INIT(AB8505_REGUREQUESTCTRL1, 0x03, 0x03, 0xff),
1995 /*
1996 * 0x03, VsafeRequestCtrl
1997 * 0x0c, VpllRequestCtrl
1998 * 0x30, VanaRequestCtrl
1999 */
2000 REG_INIT(AB8505_REGUREQUESTCTRL2, 0x03, 0x04, 0x3f),
2001 /*
2002 * 0x30, Vaux1RequestCtrl
2003 * 0xc0, Vaux2RequestCtrl
2004 */
2005 REG_INIT(AB8505_REGUREQUESTCTRL3, 0x03, 0x05, 0xf0),
2006 /*
2007 * 0x03, Vaux3RequestCtrl
2008 * 0x04, SwHPReq
2009 */
2010 REG_INIT(AB8505_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
2011 /*
2012 * 0x01, VsmpsASysClkReq1HPValid
2013 * 0x02, VsmpsBSysClkReq1HPValid
2014 * 0x04, VsafeSysClkReq1HPValid
2015 * 0x08, VanaSysClkReq1HPValid
2016 * 0x10, VpllSysClkReq1HPValid
2017 * 0x20, Vaux1SysClkReq1HPValid
2018 * 0x40, Vaux2SysClkReq1HPValid
2019 * 0x80, Vaux3SysClkReq1HPValid
2020 */
2021 REG_INIT(AB8505_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xff),
2022 /*
2023 * 0x01, VsmpsCSysClkReq1HPValid
2024 * 0x02, VarmSysClkReq1HPValid
2025 * 0x04, VbbSysClkReq1HPValid
2026 * 0x08, VsmpsMSysClkReq1HPValid
2027 */
2028 REG_INIT(AB8505_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x0f),
2029 /*
2030 * 0x01, VsmpsAHwHPReq1Valid
2031 * 0x02, VsmpsBHwHPReq1Valid
2032 * 0x04, VsafeHwHPReq1Valid
2033 * 0x08, VanaHwHPReq1Valid
2034 * 0x10, VpllHwHPReq1Valid
2035 * 0x20, Vaux1HwHPReq1Valid
2036 * 0x40, Vaux2HwHPReq1Valid
2037 * 0x80, Vaux3HwHPReq1Valid
2038 */
2039 REG_INIT(AB8505_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xff),
2040 /*
2041 * 0x08, VsmpsMHwHPReq1Valid
2042 */
2043 REG_INIT(AB8505_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x08),
2044 /*
2045 * 0x01, VsmpsAHwHPReq2Valid
2046 * 0x02, VsmpsBHwHPReq2Valid
2047 * 0x04, VsafeHwHPReq2Valid
2048 * 0x08, VanaHwHPReq2Valid
2049 * 0x10, VpllHwHPReq2Valid
2050 * 0x20, Vaux1HwHPReq2Valid
2051 * 0x40, Vaux2HwHPReq2Valid
2052 * 0x80, Vaux3HwHPReq2Valid
2053 */
2054 REG_INIT(AB8505_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xff),
2055 /*
2056 * 0x08, VsmpsMHwHPReq2Valid
2057 */
2058 REG_INIT(AB8505_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x08),
2059 /*
2060 * 0x01, VsmpsCSwHPReqValid
2061 * 0x02, VarmSwHPReqValid
2062 * 0x04, VsmpsASwHPReqValid
2063 * 0x08, VsmpsBSwHPReqValid
2064 * 0x10, VsafeSwHPReqValid
2065 * 0x20, VanaSwHPReqValid
2066 * 0x40, VpllSwHPReqValid
2067 * 0x80, Vaux1SwHPReqValid
2068 */
2069 REG_INIT(AB8505_REGUSWHPREQVALID1, 0x03, 0x0d, 0xff),
2070 /*
2071 * 0x01, Vaux2SwHPReqValid
2072 * 0x02, Vaux3SwHPReqValid
2073 * 0x20, VsmpsMSwHPReqValid
2074 */
2075 REG_INIT(AB8505_REGUSWHPREQVALID2, 0x03, 0x0e, 0x23),
2076 /*
2077 * 0x02, SysClkReq2Valid1
2078 * 0x04, SysClkReq3Valid1
2079 * 0x08, SysClkReq4Valid1
2080 */
2081 REG_INIT(AB8505_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0x0e),
2082 /*
2083 * 0x02, SysClkReq2Valid2
2084 * 0x04, SysClkReq3Valid2
2085 * 0x08, SysClkReq4Valid2
2086 */
2087 REG_INIT(AB8505_REGUSYSCLKREQVALID2, 0x03, 0x10, 0x0e),
2088 /*
2089 * 0x01, Vaux4SwHPReqValid
2090 * 0x02, Vaux4HwHPReq2Valid
2091 * 0x04, Vaux4HwHPReq1Valid
2092 * 0x08, Vaux4SysClkReq1HPValid
2093 */
2094 REG_INIT(AB8505_REGUVAUX4REQVALID, 0x03, 0x11, 0x0f),
2095 /*
2096 * 0x02, VadcEna
2097 * 0x04, VintCore12Ena
2098 * 0x38, VintCore12Sel
2099 * 0x40, VintCore12LP
2100 * 0x80, VadcLP
2101 */
2102 REG_INIT(AB8505_REGUMISC1, 0x03, 0x80, 0xfe),
2103 /*
2104 * 0x02, VaudioEna
2105 * 0x04, VdmicEna
2106 * 0x08, Vamic1Ena
2107 * 0x10, Vamic2Ena
2108 */
2109 REG_INIT(AB8505_VAUDIOSUPPLY, 0x03, 0x83, 0x1e),
2110 /*
2111 * 0x01, Vamic1_dzout
2112 * 0x02, Vamic2_dzout
2113 */
2114 REG_INIT(AB8505_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
2115 /*
2116 * 0x03, VsmpsARegu
2117 * 0x0c, VsmpsASelCtrl
2118 * 0x10, VsmpsAAutoMode
2119 * 0x20, VsmpsAPWMMode
2120 */
2121 REG_INIT(AB8505_VSMPSAREGU, 0x04, 0x03, 0x3f),
2122 /*
2123 * 0x03, VsmpsBRegu
2124 * 0x0c, VsmpsBSelCtrl
2125 * 0x10, VsmpsBAutoMode
2126 * 0x20, VsmpsBPWMMode
2127 */
2128 REG_INIT(AB8505_VSMPSBREGU, 0x04, 0x04, 0x3f),
2129 /*
2130 * 0x03, VsafeRegu
2131 * 0x0c, VsafeSelCtrl
2132 * 0x10, VsafeAutoMode
2133 * 0x20, VsafePWMMode
2134 */
2135 REG_INIT(AB8505_VSAFEREGU, 0x04, 0x05, 0x3f),
2136 /*
2137 * 0x03, VpllRegu (NOTE! PRCMU register bits)
2138 * 0x0c, VanaRegu
2139 */
2140 REG_INIT(AB8505_VPLLVANAREGU, 0x04, 0x06, 0x0f),
2141 /*
2142 * 0x03, VextSupply1Regu
2143 * 0x0c, VextSupply2Regu
2144 * 0x30, VextSupply3Regu
2145 * 0x40, ExtSupply2Bypass
2146 * 0x80, ExtSupply3Bypass
2147 */
2148 REG_INIT(AB8505_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
2149 /*
2150 * 0x03, Vaux1Regu
2151 * 0x0c, Vaux2Regu
2152 */
2153 REG_INIT(AB8505_VAUX12REGU, 0x04, 0x09, 0x0f),
2154 /*
2155 * 0x0f, Vaux3Regu
2156 */
2157 REG_INIT(AB8505_VRF1VAUX3REGU, 0x04, 0x0a, 0x0f),
2158 /*
2159 * 0x3f, VsmpsASel1
2160 */
2161 REG_INIT(AB8505_VSMPSASEL1, 0x04, 0x13, 0x3f),
2162 /*
2163 * 0x3f, VsmpsASel2
2164 */
2165 REG_INIT(AB8505_VSMPSASEL2, 0x04, 0x14, 0x3f),
2166 /*
2167 * 0x3f, VsmpsASel3
2168 */
2169 REG_INIT(AB8505_VSMPSASEL3, 0x04, 0x15, 0x3f),
2170 /*
2171 * 0x3f, VsmpsBSel1
2172 */
2173 REG_INIT(AB8505_VSMPSBSEL1, 0x04, 0x17, 0x3f),
2174 /*
2175 * 0x3f, VsmpsBSel2
2176 */
2177 REG_INIT(AB8505_VSMPSBSEL2, 0x04, 0x18, 0x3f),
2178 /*
2179 * 0x3f, VsmpsBSel3
2180 */
2181 REG_INIT(AB8505_VSMPSBSEL3, 0x04, 0x19, 0x3f),
2182 /*
2183 * 0x7f, VsafeSel1
2184 */
2185 REG_INIT(AB8505_VSAFESEL1, 0x04, 0x1b, 0x7f),
2186 /*
2187 * 0x3f, VsafeSel2
2188 */
2189 REG_INIT(AB8505_VSAFESEL2, 0x04, 0x1c, 0x7f),
2190 /*
2191 * 0x3f, VsafeSel3
2192 */
2193 REG_INIT(AB8505_VSAFESEL3, 0x04, 0x1d, 0x7f),
2194 /*
2195 * 0x0f, Vaux1Sel
2196 */
2197 REG_INIT(AB8505_VAUX1SEL, 0x04, 0x1f, 0x0f),
2198 /*
2199 * 0x0f, Vaux2Sel
2200 */
2201 REG_INIT(AB8505_VAUX2SEL, 0x04, 0x20, 0x0f),
2202 /*
2203 * 0x07, Vaux3Sel
2204 * 0x30, VRF1Sel
2205 */
2206 REG_INIT(AB8505_VRF1VAUX3SEL, 0x04, 0x21, 0x37),
2207 /*
2208 * 0x03, Vaux4RequestCtrl
2209 */
2210 REG_INIT(AB8505_VAUX4REQCTRL, 0x04, 0x2d, 0x03),
2211 /*
2212 * 0x03, Vaux4Regu
2213 */
2214 REG_INIT(AB8505_VAUX4REGU, 0x04, 0x2e, 0x03),
2215 /*
2216 * 0x0f, Vaux4Sel
2217 */
2218 REG_INIT(AB8505_VAUX4SEL, 0x04, 0x2f, 0x0f),
2219 /*
2220 * 0x04, Vaux1Disch
2221 * 0x08, Vaux2Disch
2222 * 0x10, Vaux3Disch
2223 * 0x20, Vintcore12Disch
2224 * 0x40, VTVoutDisch
2225 * 0x80, VaudioDisch
2226 */
2227 REG_INIT(AB8505_REGUCTRLDISCH, 0x04, 0x43, 0xfc),
2228 /*
2229 * 0x02, VanaDisch
2230 * 0x04, VdmicPullDownEna
2231 * 0x10, VdmicDisch
2232 */
2233 REG_INIT(AB8505_REGUCTRLDISCH2, 0x04, 0x44, 0x16),
2234 /*
2235 * 0x01, Vaux4Disch
2236 */
2237 REG_INIT(AB8505_REGUCTRLDISCH3, 0x04, 0x48, 0x01),
2238 /*
2239 * 0x07, Vaux5Sel
2240 * 0x08, Vaux5LP
2241 * 0x10, Vaux5Ena
2242 * 0x20, Vaux5Disch
2243 * 0x40, Vaux5DisSfst
2244 * 0x80, Vaux5DisPulld
2245 */
2246 REG_INIT(AB8505_CTRLVAUX5, 0x01, 0x55, 0xff),
2247 /*
2248 * 0x07, Vaux6Sel
2249 * 0x08, Vaux6LP
2250 * 0x10, Vaux6Ena
2251 * 0x80, Vaux6DisPulld
2252 */
2253 REG_INIT(AB8505_CTRLVAUX6, 0x01, 0x56, 0x9f),
2254};
2255
Lee Jones8e6a8d72013-03-28 16:11:11 +00002256/* AB9540 register init */
2257static struct ab8500_reg_init ab9540_reg_init[] = {
2258 /*
2259 * 0x03, VarmRequestCtrl
2260 * 0x0c, VapeRequestCtrl
2261 * 0x30, Vsmps1RequestCtrl
2262 * 0xc0, Vsmps2RequestCtrl
2263 */
2264 REG_INIT(AB9540_REGUREQUESTCTRL1, 0x03, 0x03, 0xff),
2265 /*
2266 * 0x03, Vsmps3RequestCtrl
2267 * 0x0c, VpllRequestCtrl
2268 * 0x30, VanaRequestCtrl
2269 * 0xc0, VextSupply1RequestCtrl
2270 */
2271 REG_INIT(AB9540_REGUREQUESTCTRL2, 0x03, 0x04, 0xff),
2272 /*
2273 * 0x03, VextSupply2RequestCtrl
2274 * 0x0c, VextSupply3RequestCtrl
2275 * 0x30, Vaux1RequestCtrl
2276 * 0xc0, Vaux2RequestCtrl
2277 */
2278 REG_INIT(AB9540_REGUREQUESTCTRL3, 0x03, 0x05, 0xff),
2279 /*
2280 * 0x03, Vaux3RequestCtrl
2281 * 0x04, SwHPReq
2282 */
2283 REG_INIT(AB9540_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
2284 /*
2285 * 0x01, Vsmps1SysClkReq1HPValid
2286 * 0x02, Vsmps2SysClkReq1HPValid
2287 * 0x04, Vsmps3SysClkReq1HPValid
2288 * 0x08, VanaSysClkReq1HPValid
2289 * 0x10, VpllSysClkReq1HPValid
2290 * 0x20, Vaux1SysClkReq1HPValid
2291 * 0x40, Vaux2SysClkReq1HPValid
2292 * 0x80, Vaux3SysClkReq1HPValid
2293 */
2294 REG_INIT(AB9540_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xff),
2295 /*
2296 * 0x01, VapeSysClkReq1HPValid
2297 * 0x02, VarmSysClkReq1HPValid
2298 * 0x04, VbbSysClkReq1HPValid
2299 * 0x08, VmodSysClkReq1HPValid
2300 * 0x10, VextSupply1SysClkReq1HPValid
2301 * 0x20, VextSupply2SysClkReq1HPValid
2302 * 0x40, VextSupply3SysClkReq1HPValid
2303 */
2304 REG_INIT(AB9540_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x7f),
2305 /*
2306 * 0x01, Vsmps1HwHPReq1Valid
2307 * 0x02, Vsmps2HwHPReq1Valid
2308 * 0x04, Vsmps3HwHPReq1Valid
2309 * 0x08, VanaHwHPReq1Valid
2310 * 0x10, VpllHwHPReq1Valid
2311 * 0x20, Vaux1HwHPReq1Valid
2312 * 0x40, Vaux2HwHPReq1Valid
2313 * 0x80, Vaux3HwHPReq1Valid
2314 */
2315 REG_INIT(AB9540_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xff),
2316 /*
2317 * 0x01, VextSupply1HwHPReq1Valid
2318 * 0x02, VextSupply2HwHPReq1Valid
2319 * 0x04, VextSupply3HwHPReq1Valid
2320 * 0x08, VmodHwHPReq1Valid
2321 */
2322 REG_INIT(AB9540_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x0f),
2323 /*
2324 * 0x01, Vsmps1HwHPReq2Valid
2325 * 0x02, Vsmps2HwHPReq2Valid
2326 * 0x03, Vsmps3HwHPReq2Valid
2327 * 0x08, VanaHwHPReq2Valid
2328 * 0x10, VpllHwHPReq2Valid
2329 * 0x20, Vaux1HwHPReq2Valid
2330 * 0x40, Vaux2HwHPReq2Valid
2331 * 0x80, Vaux3HwHPReq2Valid
2332 */
2333 REG_INIT(AB9540_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xff),
2334 /*
2335 * 0x01, VextSupply1HwHPReq2Valid
2336 * 0x02, VextSupply2HwHPReq2Valid
2337 * 0x04, VextSupply3HwHPReq2Valid
2338 * 0x08, VmodHwHPReq2Valid
2339 */
2340 REG_INIT(AB9540_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x0f),
2341 /*
2342 * 0x01, VapeSwHPReqValid
2343 * 0x02, VarmSwHPReqValid
2344 * 0x04, Vsmps1SwHPReqValid
2345 * 0x08, Vsmps2SwHPReqValid
2346 * 0x10, Vsmps3SwHPReqValid
2347 * 0x20, VanaSwHPReqValid
2348 * 0x40, VpllSwHPReqValid
2349 * 0x80, Vaux1SwHPReqValid
2350 */
2351 REG_INIT(AB9540_REGUSWHPREQVALID1, 0x03, 0x0d, 0xff),
2352 /*
2353 * 0x01, Vaux2SwHPReqValid
2354 * 0x02, Vaux3SwHPReqValid
2355 * 0x04, VextSupply1SwHPReqValid
2356 * 0x08, VextSupply2SwHPReqValid
2357 * 0x10, VextSupply3SwHPReqValid
2358 * 0x20, VmodSwHPReqValid
2359 */
2360 REG_INIT(AB9540_REGUSWHPREQVALID2, 0x03, 0x0e, 0x3f),
2361 /*
2362 * 0x02, SysClkReq2Valid1
2363 * ...
2364 * 0x80, SysClkReq8Valid1
2365 */
2366 REG_INIT(AB9540_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0xfe),
2367 /*
2368 * 0x02, SysClkReq2Valid2
2369 * ...
2370 * 0x80, SysClkReq8Valid2
2371 */
2372 REG_INIT(AB9540_REGUSYSCLKREQVALID2, 0x03, 0x10, 0xfe),
2373 /*
2374 * 0x01, Vaux4SwHPReqValid
2375 * 0x02, Vaux4HwHPReq2Valid
2376 * 0x04, Vaux4HwHPReq1Valid
2377 * 0x08, Vaux4SysClkReq1HPValid
2378 */
2379 REG_INIT(AB9540_REGUVAUX4REQVALID, 0x03, 0x11, 0x0f),
2380 /*
2381 * 0x02, VTVoutEna
2382 * 0x04, Vintcore12Ena
2383 * 0x38, Vintcore12Sel
2384 * 0x40, Vintcore12LP
2385 * 0x80, VTVoutLP
2386 */
2387 REG_INIT(AB9540_REGUMISC1, 0x03, 0x80, 0xfe),
2388 /*
2389 * 0x02, VaudioEna
2390 * 0x04, VdmicEna
2391 * 0x08, Vamic1Ena
2392 * 0x10, Vamic2Ena
2393 */
2394 REG_INIT(AB9540_VAUDIOSUPPLY, 0x03, 0x83, 0x1e),
2395 /*
2396 * 0x01, Vamic1_dzout
2397 * 0x02, Vamic2_dzout
2398 */
2399 REG_INIT(AB9540_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
2400 /*
2401 * 0x03, Vsmps1Regu
2402 * 0x0c, Vsmps1SelCtrl
2403 * 0x10, Vsmps1AutoMode
2404 * 0x20, Vsmps1PWMMode
2405 */
2406 REG_INIT(AB9540_VSMPS1REGU, 0x04, 0x03, 0x3f),
2407 /*
2408 * 0x03, Vsmps2Regu
2409 * 0x0c, Vsmps2SelCtrl
2410 * 0x10, Vsmps2AutoMode
2411 * 0x20, Vsmps2PWMMode
2412 */
2413 REG_INIT(AB9540_VSMPS2REGU, 0x04, 0x04, 0x3f),
2414 /*
2415 * 0x03, Vsmps3Regu
2416 * 0x0c, Vsmps3SelCtrl
2417 * NOTE! PRCMU register
2418 */
2419 REG_INIT(AB9540_VSMPS3REGU, 0x04, 0x05, 0x0f),
2420 /*
2421 * 0x03, VpllRegu
2422 * 0x0c, VanaRegu
2423 */
2424 REG_INIT(AB9540_VPLLVANAREGU, 0x04, 0x06, 0x0f),
2425 /*
2426 * 0x03, VextSupply1Regu
2427 * 0x0c, VextSupply2Regu
2428 * 0x30, VextSupply3Regu
2429 * 0x40, ExtSupply2Bypass
2430 * 0x80, ExtSupply3Bypass
2431 */
2432 REG_INIT(AB9540_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
2433 /*
2434 * 0x03, Vaux1Regu
2435 * 0x0c, Vaux2Regu
2436 */
2437 REG_INIT(AB9540_VAUX12REGU, 0x04, 0x09, 0x0f),
2438 /*
2439 * 0x0c, Vrf1Regu
2440 * 0x03, Vaux3Regu
2441 */
2442 REG_INIT(AB9540_VRF1VAUX3REGU, 0x04, 0x0a, 0x0f),
2443 /*
2444 * 0x3f, Vsmps1Sel1
2445 */
2446 REG_INIT(AB9540_VSMPS1SEL1, 0x04, 0x13, 0x3f),
2447 /*
2448 * 0x3f, Vsmps1Sel2
2449 */
2450 REG_INIT(AB9540_VSMPS1SEL2, 0x04, 0x14, 0x3f),
2451 /*
2452 * 0x3f, Vsmps1Sel3
2453 */
2454 REG_INIT(AB9540_VSMPS1SEL3, 0x04, 0x15, 0x3f),
2455 /*
2456 * 0x3f, Vsmps2Sel1
2457 */
2458 REG_INIT(AB9540_VSMPS2SEL1, 0x04, 0x17, 0x3f),
2459 /*
2460 * 0x3f, Vsmps2Sel2
2461 */
2462 REG_INIT(AB9540_VSMPS2SEL2, 0x04, 0x18, 0x3f),
2463 /*
2464 * 0x3f, Vsmps2Sel3
2465 */
2466 REG_INIT(AB9540_VSMPS2SEL3, 0x04, 0x19, 0x3f),
2467 /*
2468 * 0x7f, Vsmps3Sel1
2469 * NOTE! PRCMU register
2470 */
2471 REG_INIT(AB9540_VSMPS3SEL1, 0x04, 0x1b, 0x7f),
2472 /*
2473 * 0x7f, Vsmps3Sel2
2474 * NOTE! PRCMU register
2475 */
2476 REG_INIT(AB9540_VSMPS3SEL2, 0x04, 0x1c, 0x7f),
2477 /*
2478 * 0x0f, Vaux1Sel
2479 */
2480 REG_INIT(AB9540_VAUX1SEL, 0x04, 0x1f, 0x0f),
2481 /*
2482 * 0x0f, Vaux2Sel
2483 */
2484 REG_INIT(AB9540_VAUX2SEL, 0x04, 0x20, 0x0f),
2485 /*
2486 * 0x07, Vaux3Sel
2487 * 0x30, Vrf1Sel
2488 */
2489 REG_INIT(AB9540_VRF1VAUX3SEL, 0x04, 0x21, 0x37),
2490 /*
2491 * 0x01, VextSupply12LP
2492 */
2493 REG_INIT(AB9540_REGUCTRL2SPARE, 0x04, 0x22, 0x01),
2494 /*
2495 * 0x03, Vaux4RequestCtrl
2496 */
2497 REG_INIT(AB9540_VAUX4REQCTRL, 0x04, 0x2d, 0x03),
2498 /*
2499 * 0x03, Vaux4Regu
2500 */
2501 REG_INIT(AB9540_VAUX4REGU, 0x04, 0x2e, 0x03),
2502 /*
2503 * 0x08, Vaux4Sel
2504 */
2505 REG_INIT(AB9540_VAUX4SEL, 0x04, 0x2f, 0x0f),
2506 /*
2507 * 0x01, VpllDisch
2508 * 0x02, Vrf1Disch
2509 * 0x04, Vaux1Disch
2510 * 0x08, Vaux2Disch
2511 * 0x10, Vaux3Disch
2512 * 0x20, Vintcore12Disch
2513 * 0x40, VTVoutDisch
2514 * 0x80, VaudioDisch
2515 */
2516 REG_INIT(AB9540_REGUCTRLDISCH, 0x04, 0x43, 0xff),
2517 /*
2518 * 0x01, VsimDisch
2519 * 0x02, VanaDisch
2520 * 0x04, VdmicPullDownEna
2521 * 0x08, VpllPullDownEna
2522 * 0x10, VdmicDisch
2523 */
2524 REG_INIT(AB9540_REGUCTRLDISCH2, 0x04, 0x44, 0x1f),
2525 /*
2526 * 0x01, Vaux4Disch
2527 */
2528 REG_INIT(AB9540_REGUCTRLDISCH3, 0x04, 0x48, 0x01),
2529};
2530
Lee Jonesae0a9a32013-03-28 16:11:16 +00002531/* AB8540 register init */
2532static struct ab8500_reg_init ab8540_reg_init[] = {
2533 /*
2534 * 0x01, VSimSycClkReq1Valid
2535 * 0x02, VSimSycClkReq2Valid
2536 * 0x04, VSimSycClkReq3Valid
2537 * 0x08, VSimSycClkReq4Valid
2538 * 0x10, VSimSycClkReq5Valid
2539 * 0x20, VSimSycClkReq6Valid
2540 * 0x40, VSimSycClkReq7Valid
2541 * 0x80, VSimSycClkReq8Valid
2542 */
2543 REG_INIT(AB8540_VSIMSYSCLKCTRL, 0x02, 0x33, 0xff),
2544 /*
2545 * 0x03, VarmRequestCtrl
2546 * 0x0c, VapeRequestCtrl
2547 * 0x30, Vsmps1RequestCtrl
2548 * 0xc0, Vsmps2RequestCtrl
2549 */
2550 REG_INIT(AB8540_REGUREQUESTCTRL1, 0x03, 0x03, 0xff),
2551 /*
2552 * 0x03, Vsmps3RequestCtrl
2553 * 0x0c, VpllRequestCtrl
2554 * 0x30, VanaRequestCtrl
2555 * 0xc0, VextSupply1RequestCtrl
2556 */
2557 REG_INIT(AB8540_REGUREQUESTCTRL2, 0x03, 0x04, 0xff),
2558 /*
2559 * 0x03, VextSupply2RequestCtrl
2560 * 0x0c, VextSupply3RequestCtrl
2561 * 0x30, Vaux1RequestCtrl
2562 * 0xc0, Vaux2RequestCtrl
2563 */
2564 REG_INIT(AB8540_REGUREQUESTCTRL3, 0x03, 0x05, 0xff),
2565 /*
2566 * 0x03, Vaux3RequestCtrl
2567 * 0x04, SwHPReq
2568 */
2569 REG_INIT(AB8540_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
2570 /*
2571 * 0x01, Vsmps1SysClkReq1HPValid
2572 * 0x02, Vsmps2SysClkReq1HPValid
2573 * 0x04, Vsmps3SysClkReq1HPValid
2574 * 0x08, VanaSysClkReq1HPValid
2575 * 0x10, VpllSysClkReq1HPValid
2576 * 0x20, Vaux1SysClkReq1HPValid
2577 * 0x40, Vaux2SysClkReq1HPValid
2578 * 0x80, Vaux3SysClkReq1HPValid
2579 */
2580 REG_INIT(AB8540_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xff),
2581 /*
2582 * 0x01, VapeSysClkReq1HPValid
2583 * 0x02, VarmSysClkReq1HPValid
2584 * 0x04, VbbSysClkReq1HPValid
2585 * 0x10, VextSupply1SysClkReq1HPValid
2586 * 0x20, VextSupply2SysClkReq1HPValid
2587 * 0x40, VextSupply3SysClkReq1HPValid
2588 */
2589 REG_INIT(AB8540_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x77),
2590 /*
2591 * 0x01, Vsmps1HwHPReq1Valid
2592 * 0x02, Vsmps2HwHPReq1Valid
2593 * 0x04, Vsmps3HwHPReq1Valid
2594 * 0x08, VanaHwHPReq1Valid
2595 * 0x10, VpllHwHPReq1Valid
2596 * 0x20, Vaux1HwHPReq1Valid
2597 * 0x40, Vaux2HwHPReq1Valid
2598 * 0x80, Vaux3HwHPReq1Valid
2599 */
2600 REG_INIT(AB8540_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xff),
2601 /*
2602 * 0x01, VextSupply1HwHPReq1Valid
2603 * 0x02, VextSupply2HwHPReq1Valid
2604 * 0x04, VextSupply3HwHPReq1Valid
2605 */
2606 REG_INIT(AB8540_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x07),
2607 /*
2608 * 0x01, Vsmps1HwHPReq2Valid
2609 * 0x02, Vsmps2HwHPReq2Valid
2610 * 0x03, Vsmps3HwHPReq2Valid
2611 * 0x08, VanaHwHPReq2Valid
2612 * 0x10, VpllHwHPReq2Valid
2613 * 0x20, Vaux1HwHPReq2Valid
2614 * 0x40, Vaux2HwHPReq2Valid
2615 * 0x80, Vaux3HwHPReq2Valid
2616 */
2617 REG_INIT(AB8540_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xff),
2618 /*
2619 * 0x01, VextSupply1HwHPReq2Valid
2620 * 0x02, VextSupply2HwHPReq2Valid
2621 * 0x04, VextSupply3HwHPReq2Valid
2622 */
2623 REG_INIT(AB8540_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x07),
2624 /*
2625 * 0x01, VapeSwHPReqValid
2626 * 0x02, VarmSwHPReqValid
2627 * 0x04, Vsmps1SwHPReqValid
2628 * 0x08, Vsmps2SwHPReqValid
2629 * 0x10, Vsmps3SwHPReqValid
2630 * 0x20, VanaSwHPReqValid
2631 * 0x40, VpllSwHPReqValid
2632 * 0x80, Vaux1SwHPReqValid
2633 */
2634 REG_INIT(AB8540_REGUSWHPREQVALID1, 0x03, 0x0d, 0xff),
2635 /*
2636 * 0x01, Vaux2SwHPReqValid
2637 * 0x02, Vaux3SwHPReqValid
2638 * 0x04, VextSupply1SwHPReqValid
2639 * 0x08, VextSupply2SwHPReqValid
2640 * 0x10, VextSupply3SwHPReqValid
2641 */
2642 REG_INIT(AB8540_REGUSWHPREQVALID2, 0x03, 0x0e, 0x1f),
2643 /*
2644 * 0x02, SysClkReq2Valid1
2645 * ...
2646 * 0x80, SysClkReq8Valid1
2647 */
2648 REG_INIT(AB8540_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0xff),
2649 /*
2650 * 0x02, SysClkReq2Valid2
2651 * ...
2652 * 0x80, SysClkReq8Valid2
2653 */
2654 REG_INIT(AB8540_REGUSYSCLKREQVALID2, 0x03, 0x10, 0xff),
2655 /*
2656 * 0x01, Vaux4SwHPReqValid
2657 * 0x02, Vaux4HwHPReq2Valid
2658 * 0x04, Vaux4HwHPReq1Valid
2659 * 0x08, Vaux4SysClkReq1HPValid
2660 */
2661 REG_INIT(AB8540_REGUVAUX4REQVALID, 0x03, 0x11, 0x0f),
2662 /*
2663 * 0x01, Vaux5SwHPReqValid
2664 * 0x02, Vaux5HwHPReq2Valid
2665 * 0x04, Vaux5HwHPReq1Valid
2666 * 0x08, Vaux5SysClkReq1HPValid
2667 */
2668 REG_INIT(AB8540_REGUVAUX5REQVALID, 0x03, 0x12, 0x0f),
2669 /*
2670 * 0x01, Vaux6SwHPReqValid
2671 * 0x02, Vaux6HwHPReq2Valid
2672 * 0x04, Vaux6HwHPReq1Valid
2673 * 0x08, Vaux6SysClkReq1HPValid
2674 */
2675 REG_INIT(AB8540_REGUVAUX6REQVALID, 0x03, 0x13, 0x0f),
2676 /*
2677 * 0x01, VclkbSwHPReqValid
2678 * 0x02, VclkbHwHPReq2Valid
2679 * 0x04, VclkbHwHPReq1Valid
2680 * 0x08, VclkbSysClkReq1HPValid
2681 */
2682 REG_INIT(AB8540_REGUVCLKBREQVALID, 0x03, 0x14, 0x0f),
2683 /*
2684 * 0x01, Vrf1SwHPReqValid
2685 * 0x02, Vrf1HwHPReq2Valid
2686 * 0x04, Vrf1HwHPReq1Valid
2687 * 0x08, Vrf1SysClkReq1HPValid
2688 */
2689 REG_INIT(AB8540_REGUVRF1REQVALID, 0x03, 0x15, 0x0f),
2690 /*
2691 * 0x02, VTVoutEna
2692 * 0x04, Vintcore12Ena
2693 * 0x38, Vintcore12Sel
2694 * 0x40, Vintcore12LP
2695 * 0x80, VTVoutLP
2696 */
2697 REG_INIT(AB8540_REGUMISC1, 0x03, 0x80, 0xfe),
2698 /*
2699 * 0x02, VaudioEna
2700 * 0x04, VdmicEna
2701 * 0x08, Vamic1Ena
2702 * 0x10, Vamic2Ena
2703 * 0x20, Vamic12LP
2704 * 0xC0, VdmicSel
2705 */
2706 REG_INIT(AB8540_VAUDIOSUPPLY, 0x03, 0x83, 0xfe),
2707 /*
2708 * 0x01, Vamic1_dzout
2709 * 0x02, Vamic2_dzout
2710 */
2711 REG_INIT(AB8540_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
2712 /*
2713 * 0x07, VHSICSel
2714 * 0x08, VHSICOffState
2715 * 0x10, VHSIEna
2716 * 0x20, VHSICLP
2717 */
2718 REG_INIT(AB8540_VHSIC, 0x03, 0x87, 0x3f),
2719 /*
2720 * 0x07, VSDIOSel
2721 * 0x08, VSDIOOffState
2722 * 0x10, VSDIOEna
2723 * 0x20, VSDIOLP
2724 */
2725 REG_INIT(AB8540_VSDIO, 0x03, 0x88, 0x3f),
2726 /*
2727 * 0x03, Vsmps1Regu
2728 * 0x0c, Vsmps1SelCtrl
2729 * 0x10, Vsmps1AutoMode
2730 * 0x20, Vsmps1PWMMode
2731 */
2732 REG_INIT(AB8540_VSMPS1REGU, 0x04, 0x03, 0x3f),
2733 /*
2734 * 0x03, Vsmps2Regu
2735 * 0x0c, Vsmps2SelCtrl
2736 * 0x10, Vsmps2AutoMode
2737 * 0x20, Vsmps2PWMMode
2738 */
2739 REG_INIT(AB8540_VSMPS2REGU, 0x04, 0x04, 0x3f),
2740 /*
2741 * 0x03, Vsmps3Regu
2742 * 0x0c, Vsmps3SelCtrl
2743 * 0x10, Vsmps3AutoMode
2744 * 0x20, Vsmps3PWMMode
2745 * NOTE! PRCMU register
2746 */
2747 REG_INIT(AB8540_VSMPS3REGU, 0x04, 0x05, 0x0f),
2748 /*
2749 * 0x03, VpllRegu
2750 * 0x0c, VanaRegu
2751 */
2752 REG_INIT(AB8540_VPLLVANAREGU, 0x04, 0x06, 0x0f),
2753 /*
2754 * 0x03, VextSupply1Regu
2755 * 0x0c, VextSupply2Regu
2756 * 0x30, VextSupply3Regu
2757 * 0x40, ExtSupply2Bypass
2758 * 0x80, ExtSupply3Bypass
2759 */
2760 REG_INIT(AB8540_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
2761 /*
2762 * 0x03, Vaux1Regu
2763 * 0x0c, Vaux2Regu
2764 */
2765 REG_INIT(AB8540_VAUX12REGU, 0x04, 0x09, 0x0f),
2766 /*
2767 * 0x0c, VRF1Regu
2768 * 0x03, Vaux3Regu
2769 */
2770 REG_INIT(AB8540_VRF1VAUX3REGU, 0x04, 0x0a, 0x0f),
2771 /*
2772 * 0x3f, Vsmps1Sel1
2773 */
2774 REG_INIT(AB8540_VSMPS1SEL1, 0x04, 0x13, 0x3f),
2775 /*
2776 * 0x3f, Vsmps1Sel2
2777 */
2778 REG_INIT(AB8540_VSMPS1SEL2, 0x04, 0x14, 0x3f),
2779 /*
2780 * 0x3f, Vsmps1Sel3
2781 */
2782 REG_INIT(AB8540_VSMPS1SEL3, 0x04, 0x15, 0x3f),
2783 /*
2784 * 0x3f, Vsmps2Sel1
2785 */
2786 REG_INIT(AB8540_VSMPS2SEL1, 0x04, 0x17, 0x3f),
2787 /*
2788 * 0x3f, Vsmps2Sel2
2789 */
2790 REG_INIT(AB8540_VSMPS2SEL2, 0x04, 0x18, 0x3f),
2791 /*
2792 * 0x3f, Vsmps2Sel3
2793 */
2794 REG_INIT(AB8540_VSMPS2SEL3, 0x04, 0x19, 0x3f),
2795 /*
2796 * 0x7f, Vsmps3Sel1
2797 * NOTE! PRCMU register
2798 */
2799 REG_INIT(AB8540_VSMPS3SEL1, 0x04, 0x1b, 0x7f),
2800 /*
2801 * 0x7f, Vsmps3Sel2
2802 * NOTE! PRCMU register
2803 */
2804 REG_INIT(AB8540_VSMPS3SEL2, 0x04, 0x1c, 0x7f),
2805 /*
2806 * 0x0f, Vaux1Sel
2807 */
2808 REG_INIT(AB8540_VAUX1SEL, 0x04, 0x1f, 0x0f),
2809 /*
2810 * 0x0f, Vaux2Sel
2811 */
2812 REG_INIT(AB8540_VAUX2SEL, 0x04, 0x20, 0x0f),
2813 /*
2814 * 0x07, Vaux3Sel
2815 * 0x70, Vrf1Sel
2816 */
2817 REG_INIT(AB8540_VRF1VAUX3SEL, 0x04, 0x21, 0x77),
2818 /*
2819 * 0x01, VextSupply12LP
2820 */
2821 REG_INIT(AB8540_REGUCTRL2SPARE, 0x04, 0x22, 0x01),
2822 /*
2823 * 0x07, Vanasel
2824 * 0x30, Vpllsel
2825 */
2826 REG_INIT(AB8540_VANAVPLLSEL, 0x04, 0x29, 0x37),
2827 /*
2828 * 0x03, Vaux4RequestCtrl
2829 */
2830 REG_INIT(AB8540_VAUX4REQCTRL, 0x04, 0x2d, 0x03),
2831 /*
2832 * 0x03, Vaux4Regu
2833 */
2834 REG_INIT(AB8540_VAUX4REGU, 0x04, 0x2e, 0x03),
2835 /*
2836 * 0x0f, Vaux4Sel
2837 */
2838 REG_INIT(AB8540_VAUX4SEL, 0x04, 0x2f, 0x0f),
2839 /*
2840 * 0x03, Vaux5RequestCtrl
2841 */
2842 REG_INIT(AB8540_VAUX5REQCTRL, 0x04, 0x31, 0x03),
2843 /*
2844 * 0x03, Vaux5Regu
2845 */
2846 REG_INIT(AB8540_VAUX5REGU, 0x04, 0x32, 0x03),
2847 /*
2848 * 0x3f, Vaux5Sel
2849 */
2850 REG_INIT(AB8540_VAUX5SEL, 0x04, 0x33, 0x3f),
2851 /*
2852 * 0x03, Vaux6RequestCtrl
2853 */
2854 REG_INIT(AB8540_VAUX6REQCTRL, 0x04, 0x34, 0x03),
2855 /*
2856 * 0x03, Vaux6Regu
2857 */
2858 REG_INIT(AB8540_VAUX6REGU, 0x04, 0x35, 0x03),
2859 /*
2860 * 0x3f, Vaux6Sel
2861 */
2862 REG_INIT(AB8540_VAUX6SEL, 0x04, 0x36, 0x3f),
2863 /*
2864 * 0x03, VCLKBRequestCtrl
2865 */
2866 REG_INIT(AB8540_VCLKBREQCTRL, 0x04, 0x37, 0x03),
2867 /*
2868 * 0x03, VCLKBRegu
2869 */
2870 REG_INIT(AB8540_VCLKBREGU, 0x04, 0x38, 0x03),
2871 /*
2872 * 0x07, VCLKBSel
2873 */
2874 REG_INIT(AB8540_VCLKBSEL, 0x04, 0x39, 0x07),
2875 /*
2876 * 0x03, Vrf1RequestCtrl
2877 */
2878 REG_INIT(AB8540_VRF1REQCTRL, 0x04, 0x3a, 0x03),
2879 /*
2880 * 0x01, VpllDisch
2881 * 0x02, Vrf1Disch
2882 * 0x04, Vaux1Disch
2883 * 0x08, Vaux2Disch
2884 * 0x10, Vaux3Disch
2885 * 0x20, Vintcore12Disch
2886 * 0x40, VTVoutDisch
2887 * 0x80, VaudioDisch
2888 */
2889 REG_INIT(AB8540_REGUCTRLDISCH, 0x04, 0x43, 0xff),
2890 /*
2891 * 0x02, VanaDisch
2892 * 0x04, VdmicPullDownEna
2893 * 0x08, VpllPullDownEna
2894 * 0x10, VdmicDisch
2895 */
2896 REG_INIT(AB8540_REGUCTRLDISCH2, 0x04, 0x44, 0x1e),
2897 /*
2898 * 0x01, Vaux4Disch
2899 */
2900 REG_INIT(AB8540_REGUCTRLDISCH3, 0x04, 0x48, 0x01),
2901 /*
2902 * 0x01, Vaux5Disch
2903 * 0x02, Vaux6Disch
2904 * 0x04, VCLKBDisch
2905 */
2906 REG_INIT(AB8540_REGUCTRLDISCH4, 0x04, 0x49, 0x07),
2907};
2908
Lee Jonesda45edc2013-04-02 13:24:20 +01002909static struct of_regulator_match ab8500_regulator_match[] = {
2910 { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB8500_LDO_AUX1, },
2911 { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB8500_LDO_AUX2, },
2912 { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB8500_LDO_AUX3, },
2913 { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB8500_LDO_INTCORE, },
2914 { .name = "ab8500_ldo_tvout", .driver_data = (void *) AB8500_LDO_TVOUT, },
2915 { .name = "ab8500_ldo_audio", .driver_data = (void *) AB8500_LDO_AUDIO, },
2916 { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB8500_LDO_ANAMIC1, },
2917 { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB8500_LDO_ANAMIC2, },
2918 { .name = "ab8500_ldo_dmic", .driver_data = (void *) AB8500_LDO_DMIC, },
2919 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB8500_LDO_ANA, },
2920};
2921
2922static struct of_regulator_match ab8505_regulator_match[] = {
2923 { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB8505_LDO_AUX1, },
2924 { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB8505_LDO_AUX2, },
2925 { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB8505_LDO_AUX3, },
2926 { .name = "ab8500_ldo_aux4", .driver_data = (void *) AB8505_LDO_AUX4, },
2927 { .name = "ab8500_ldo_aux5", .driver_data = (void *) AB8505_LDO_AUX5, },
2928 { .name = "ab8500_ldo_aux6", .driver_data = (void *) AB8505_LDO_AUX6, },
2929 { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB8505_LDO_INTCORE, },
2930 { .name = "ab8500_ldo_adc", .driver_data = (void *) AB8505_LDO_ADC, },
2931 { .name = "ab8500_ldo_audio", .driver_data = (void *) AB8505_LDO_AUDIO, },
2932 { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB8505_LDO_ANAMIC1, },
2933 { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB8505_LDO_ANAMIC2, },
2934 { .name = "ab8500_ldo_aux8", .driver_data = (void *) AB8505_LDO_AUX8, },
2935 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB8505_LDO_ANA, },
2936};
2937
2938static struct of_regulator_match ab8540_regulator_match[] = {
2939 { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB8540_LDO_AUX1, },
2940 { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB8540_LDO_AUX2, },
2941 { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB8540_LDO_AUX3, },
2942 { .name = "ab8500_ldo_aux4", .driver_data = (void *) AB8540_LDO_AUX4, },
2943 { .name = "ab8500_ldo_aux5", .driver_data = (void *) AB8540_LDO_AUX5, },
2944 { .name = "ab8500_ldo_aux6", .driver_data = (void *) AB8540_LDO_AUX6, },
2945 { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB8540_LDO_INTCORE, },
2946 { .name = "ab8500_ldo_tvout", .driver_data = (void *) AB8540_LDO_TVOUT, },
2947 { .name = "ab8500_ldo_audio", .driver_data = (void *) AB8540_LDO_AUDIO, },
2948 { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB8540_LDO_ANAMIC1, },
2949 { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB8540_LDO_ANAMIC2, },
2950 { .name = "ab8500_ldo_dmic", .driver_data = (void *) AB8540_LDO_DMIC, },
2951 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB8540_LDO_ANA, },
2952 { .name = "ab8500_ldo_sdio", .driver_data = (void *) AB8540_LDO_SDIO, },
2953};
2954
2955static struct of_regulator_match ab9540_regulator_match[] = {
2956 { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB9540_LDO_AUX1, },
2957 { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB9540_LDO_AUX2, },
2958 { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB9540_LDO_AUX3, },
2959 { .name = "ab8500_ldo_aux4", .driver_data = (void *) AB9540_LDO_AUX4, },
2960 { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB9540_LDO_INTCORE, },
2961 { .name = "ab8500_ldo_tvout", .driver_data = (void *) AB9540_LDO_TVOUT, },
2962 { .name = "ab8500_ldo_audio", .driver_data = (void *) AB9540_LDO_AUDIO, },
2963 { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB9540_LDO_ANAMIC1, },
2964 { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB9540_LDO_ANAMIC2, },
2965 { .name = "ab8500_ldo_dmic", .driver_data = (void *) AB9540_LDO_DMIC, },
2966 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB9540_LDO_ANA, },
2967};
2968
Lee Jones33aeb492013-04-02 13:24:14 +01002969static struct {
2970 struct ab8500_regulator_info *info;
2971 int info_size;
2972 struct ab8500_reg_init *init;
2973 int init_size;
2974 struct of_regulator_match *match;
2975 int match_size;
2976} abx500_regulator;
2977
Lee Jonesda45edc2013-04-02 13:24:20 +01002978static void abx500_get_regulator_info(struct ab8500 *ab8500)
2979{
2980 if (is_ab9540(ab8500)) {
2981 abx500_regulator.info = ab9540_regulator_info;
2982 abx500_regulator.info_size = ARRAY_SIZE(ab9540_regulator_info);
2983 abx500_regulator.init = ab9540_reg_init;
2984 abx500_regulator.init_size = AB9540_NUM_REGULATOR_REGISTERS;
2985 abx500_regulator.match = ab9540_regulator_match;
2986 abx500_regulator.match_size = ARRAY_SIZE(ab9540_regulator_match);
2987 } else if (is_ab8505(ab8500)) {
2988 abx500_regulator.info = ab8505_regulator_info;
2989 abx500_regulator.info_size = ARRAY_SIZE(ab8505_regulator_info);
2990 abx500_regulator.init = ab8505_reg_init;
2991 abx500_regulator.init_size = AB8505_NUM_REGULATOR_REGISTERS;
2992 abx500_regulator.match = ab8505_regulator_match;
2993 abx500_regulator.match_size = ARRAY_SIZE(ab8505_regulator_match);
2994 } else if (is_ab8540(ab8500)) {
2995 abx500_regulator.info = ab8540_regulator_info;
2996 abx500_regulator.info_size = ARRAY_SIZE(ab8540_regulator_info);
2997 abx500_regulator.init = ab8540_reg_init;
2998 abx500_regulator.init_size = AB8540_NUM_REGULATOR_REGISTERS;
2999 abx500_regulator.match = ab8540_regulator_match;
3000 abx500_regulator.match_size = ARRAY_SIZE(ab8540_regulator_match);
3001 } else {
3002 abx500_regulator.info = ab8500_regulator_info;
3003 abx500_regulator.info_size = ARRAY_SIZE(ab8500_regulator_info);
3004 abx500_regulator.init = ab8500_reg_init;
3005 abx500_regulator.init_size = AB8500_NUM_REGULATOR_REGISTERS;
3006 abx500_regulator.match = ab8500_regulator_match;
3007 abx500_regulator.match_size = ARRAY_SIZE(ab8500_regulator_match);
3008 }
3009}
3010
Lee Jones3c1b8432013-03-21 15:59:01 +00003011static int ab8500_regulator_init_registers(struct platform_device *pdev,
3012 int id, int mask, int value)
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003013{
Lee Jones33aeb492013-04-02 13:24:14 +01003014 struct ab8500_reg_init *reg_init = abx500_regulator.init;
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003015 int err;
3016
Lee Jones3c1b8432013-03-21 15:59:01 +00003017 BUG_ON(value & ~mask);
Lee Jonesb54969a2013-03-28 16:11:10 +00003018 BUG_ON(mask & ~reg_init[id].mask);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003019
Lee Jones3c1b8432013-03-21 15:59:01 +00003020 /* initialize register */
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003021 err = abx500_mask_and_set_register_interruptible(
3022 &pdev->dev,
Lee Jonesb54969a2013-03-28 16:11:10 +00003023 reg_init[id].bank,
3024 reg_init[id].addr,
Lee Jones3c1b8432013-03-21 15:59:01 +00003025 mask, value);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003026 if (err < 0) {
3027 dev_err(&pdev->dev,
3028 "Failed to initialize 0x%02x, 0x%02x.\n",
Lee Jonesb54969a2013-03-28 16:11:10 +00003029 reg_init[id].bank,
3030 reg_init[id].addr);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003031 return err;
3032 }
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003033 dev_vdbg(&pdev->dev,
Lee Jones3c1b8432013-03-21 15:59:01 +00003034 " init: 0x%02x, 0x%02x, 0x%02x, 0x%02x\n",
Lee Jonesb54969a2013-03-28 16:11:10 +00003035 reg_init[id].bank,
3036 reg_init[id].addr,
Lee Jones3c1b8432013-03-21 15:59:01 +00003037 mask, value);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003038
3039 return 0;
3040}
3041
Bill Pembertona5023572012-11-19 13:22:22 -05003042static int ab8500_regulator_register(struct platform_device *pdev,
Lee Jonesb54969a2013-03-28 16:11:10 +00003043 struct regulator_init_data *init_data,
Lee Jonesb54969a2013-03-28 16:11:10 +00003044 int id, struct device_node *np)
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003045{
Lee Jones8e6a8d72013-03-28 16:11:11 +00003046 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003047 struct ab8500_regulator_info *info = NULL;
3048 struct regulator_config config = { };
3049 int err;
3050
3051 /* assign per-regulator data */
Lee Jones33aeb492013-04-02 13:24:14 +01003052 info = &abx500_regulator.info[id];
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003053 info->dev = &pdev->dev;
3054
3055 config.dev = &pdev->dev;
3056 config.init_data = init_data;
3057 config.driver_data = info;
3058 config.of_node = np;
3059
3060 /* fix for hardware before ab8500v2.0 */
Lee Jones8e6a8d72013-03-28 16:11:11 +00003061 if (is_ab8500_1p1_or_earlier(ab8500)) {
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003062 if (info->desc.id == AB8500_LDO_AUX3) {
3063 info->desc.n_voltages =
3064 ARRAY_SIZE(ldo_vauxn_voltages);
Axel Linec1cc4d2012-05-20 10:33:35 +08003065 info->desc.volt_table = ldo_vauxn_voltages;
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003066 info->voltage_mask = 0xf;
3067 }
3068 }
3069
3070 /* register regulator with framework */
3071 info->regulator = regulator_register(&info->desc, &config);
3072 if (IS_ERR(info->regulator)) {
3073 err = PTR_ERR(info->regulator);
3074 dev_err(&pdev->dev, "failed to register regulator %s\n",
3075 info->desc.name);
3076 /* when we fail, un-register all earlier regulators */
3077 while (--id >= 0) {
Lee Jones33aeb492013-04-02 13:24:14 +01003078 info = &abx500_regulator.info[id];
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003079 regulator_unregister(info->regulator);
3080 }
3081 return err;
3082 }
3083
3084 return 0;
3085}
3086
Bill Pembertona5023572012-11-19 13:22:22 -05003087static int
Lee Jonesb54969a2013-03-28 16:11:10 +00003088ab8500_regulator_of_probe(struct platform_device *pdev,
Lee Jonesb54969a2013-03-28 16:11:10 +00003089 struct device_node *np)
Lee Jones3a8334b2012-05-17 14:45:16 +01003090{
Lee Jones33aeb492013-04-02 13:24:14 +01003091 struct of_regulator_match *match = abx500_regulator.match;
Lee Jones3a8334b2012-05-17 14:45:16 +01003092 int err, i;
3093
Lee Jones33aeb492013-04-02 13:24:14 +01003094 for (i = 0; i < abx500_regulator.info_size; i++) {
Lee Jones3a8334b2012-05-17 14:45:16 +01003095 err = ab8500_regulator_register(
Lee Jones33aeb492013-04-02 13:24:14 +01003096 pdev, match[i].init_data, i, match[i].of_node);
Lee Jones3a8334b2012-05-17 14:45:16 +01003097 if (err)
3098 return err;
3099 }
3100
3101 return 0;
3102}
3103
Bill Pembertona5023572012-11-19 13:22:22 -05003104static int ab8500_regulator_probe(struct platform_device *pdev)
Sundar R IYERc789ca22010-07-13 21:48:56 +05303105{
3106 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
Lee Jones3a8334b2012-05-17 14:45:16 +01003107 struct device_node *np = pdev->dev.of_node;
Bengt Jonsson732805a2013-03-21 15:59:03 +00003108 struct ab8500_platform_data *ppdata;
3109 struct ab8500_regulator_platform_data *pdata;
Sundar R IYERc789ca22010-07-13 21:48:56 +05303110 int i, err;
Lee Jonesb54969a2013-03-28 16:11:10 +00003111
Lee Jones33aeb492013-04-02 13:24:14 +01003112 if (!ab8500) {
3113 dev_err(&pdev->dev, "null mfd parent\n");
3114 return -EINVAL;
Lee Jones8e6a8d72013-03-28 16:11:11 +00003115 }
Sundar R IYERc789ca22010-07-13 21:48:56 +05303116
Lee Jones33aeb492013-04-02 13:24:14 +01003117 abx500_get_regulator_info(ab8500);
3118
Lee Jones3a8334b2012-05-17 14:45:16 +01003119 if (np) {
Lee Jones33aeb492013-04-02 13:24:14 +01003120 err = of_regulator_match(&pdev->dev, np,
3121 abx500_regulator.match,
3122 abx500_regulator.match_size);
Lee Jones3a8334b2012-05-17 14:45:16 +01003123 if (err < 0) {
3124 dev_err(&pdev->dev,
3125 "Error parsing regulator init data: %d\n", err);
3126 return err;
3127 }
3128
Lee Jones33aeb492013-04-02 13:24:14 +01003129 err = ab8500_regulator_of_probe(pdev, np);
Lee Jones3a8334b2012-05-17 14:45:16 +01003130 return err;
3131 }
3132
Bengt Jonsson732805a2013-03-21 15:59:03 +00003133 ppdata = dev_get_platdata(ab8500->dev);
3134 if (!ppdata) {
3135 dev_err(&pdev->dev, "null parent pdata\n");
3136 return -EINVAL;
3137 }
3138
3139 pdata = ppdata->regulator;
Bengt Jonssonfc24b422010-12-10 11:08:45 +01003140 if (!pdata) {
3141 dev_err(&pdev->dev, "null pdata\n");
3142 return -EINVAL;
3143 }
Sundar R IYERc789ca22010-07-13 21:48:56 +05303144
Bengt Jonssoncb189b02010-12-10 11:08:40 +01003145 /* make sure the platform data has the correct size */
Lee Jones33aeb492013-04-02 13:24:14 +01003146 if (pdata->num_regulator != abx500_regulator.info_size) {
Bengt Jonsson79568b942011-03-11 11:54:46 +01003147 dev_err(&pdev->dev, "Configuration error: size mismatch.\n");
Bengt Jonssoncb189b02010-12-10 11:08:40 +01003148 return -EINVAL;
3149 }
3150
Lee Jonesda0b0c42013-03-28 16:11:09 +00003151 /* initialize debug (initial state is recorded with this call) */
3152 err = ab8500_regulator_debug_init(pdev);
3153 if (err)
3154 return err;
3155
Bengt Jonsson79568b942011-03-11 11:54:46 +01003156 /* initialize registers */
Bengt Jonsson732805a2013-03-21 15:59:03 +00003157 for (i = 0; i < pdata->num_reg_init; i++) {
Lee Jones3c1b8432013-03-21 15:59:01 +00003158 int id, mask, value;
Bengt Jonsson79568b942011-03-11 11:54:46 +01003159
Bengt Jonsson732805a2013-03-21 15:59:03 +00003160 id = pdata->reg_init[i].id;
3161 mask = pdata->reg_init[i].mask;
3162 value = pdata->reg_init[i].value;
Bengt Jonsson79568b942011-03-11 11:54:46 +01003163
3164 /* check for configuration errors */
Lee Jones33aeb492013-04-02 13:24:14 +01003165 BUG_ON(id >= abx500_regulator.init_size);
Bengt Jonsson79568b942011-03-11 11:54:46 +01003166
Lee Jones33aeb492013-04-02 13:24:14 +01003167 err = ab8500_regulator_init_registers(pdev, id, mask, value);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003168 if (err < 0)
Bengt Jonsson79568b942011-03-11 11:54:46 +01003169 return err;
Bengt Jonsson79568b942011-03-11 11:54:46 +01003170 }
3171
Rabin Vincentf7eae372013-04-02 13:24:08 +01003172 if (!is_ab8505(ab8500)) {
3173 /* register external regulators (before Vaux1, 2 and 3) */
3174 err = ab8500_ext_regulator_init(pdev);
3175 if (err)
3176 return err;
3177 }
Lee Jonesd1a82002013-03-28 16:11:01 +00003178
Sundar R IYERc789ca22010-07-13 21:48:56 +05303179 /* register all regulators */
Lee Jones33aeb492013-04-02 13:24:14 +01003180 for (i = 0; i < abx500_regulator.info_size; i++) {
Lee Jonesb54969a2013-03-28 16:11:10 +00003181 err = ab8500_regulator_register(pdev, &pdata->regulator[i],
Lee Jones33aeb492013-04-02 13:24:14 +01003182 i, NULL);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003183 if (err < 0)
Sundar R IYERc789ca22010-07-13 21:48:56 +05303184 return err;
Sundar R IYERc789ca22010-07-13 21:48:56 +05303185 }
3186
3187 return 0;
3188}
3189
Bill Pemberton8dc995f2012-11-19 13:26:10 -05003190static int ab8500_regulator_remove(struct platform_device *pdev)
Sundar R IYERc789ca22010-07-13 21:48:56 +05303191{
Lee Jonesd1a82002013-03-28 16:11:01 +00003192 int i, err;
Lee Jones8e6a8d72013-03-28 16:11:11 +00003193 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
Sundar R IYERc789ca22010-07-13 21:48:56 +05303194
Lee Jones33aeb492013-04-02 13:24:14 +01003195 for (i = 0; i < abx500_regulator.info_size; i++) {
Sundar R IYERc789ca22010-07-13 21:48:56 +05303196 struct ab8500_regulator_info *info = NULL;
Lee Jones33aeb492013-04-02 13:24:14 +01003197 info = &abx500_regulator.info[i];
Bengt Jonsson09aefa12010-12-10 11:08:46 +01003198
3199 dev_vdbg(rdev_get_dev(info->regulator),
3200 "%s-remove\n", info->desc.name);
3201
Sundar R IYERc789ca22010-07-13 21:48:56 +05303202 regulator_unregister(info->regulator);
3203 }
3204
Rabin Vincentf7eae372013-04-02 13:24:08 +01003205 if (!is_ab8505(ab8500)) {
3206 /* remove external regulators (after Vaux1, 2 and 3) */
3207 err = ab8500_ext_regulator_exit(pdev);
3208 if (err)
3209 return err;
3210 }
Lee Jonesd1a82002013-03-28 16:11:01 +00003211
Lee Jonesda0b0c42013-03-28 16:11:09 +00003212 /* remove regulator debug */
3213 err = ab8500_regulator_debug_exit(pdev);
3214 if (err)
3215 return err;
3216
Sundar R IYERc789ca22010-07-13 21:48:56 +05303217 return 0;
3218}
3219
3220static struct platform_driver ab8500_regulator_driver = {
3221 .probe = ab8500_regulator_probe,
Bill Pemberton5eb9f2b2012-11-19 13:20:42 -05003222 .remove = ab8500_regulator_remove,
Sundar R IYERc789ca22010-07-13 21:48:56 +05303223 .driver = {
3224 .name = "ab8500-regulator",
3225 .owner = THIS_MODULE,
Sundar R IYERc789ca22010-07-13 21:48:56 +05303226 },
3227};
3228
3229static int __init ab8500_regulator_init(void)
3230{
3231 int ret;
3232
3233 ret = platform_driver_register(&ab8500_regulator_driver);
3234 if (ret != 0)
3235 pr_err("Failed to register ab8500 regulator: %d\n", ret);
3236
3237 return ret;
3238}
3239subsys_initcall(ab8500_regulator_init);
3240
3241static void __exit ab8500_regulator_exit(void)
3242{
3243 platform_driver_unregister(&ab8500_regulator_driver);
3244}
3245module_exit(ab8500_regulator_exit);
3246
3247MODULE_LICENSE("GPL v2");
3248MODULE_AUTHOR("Sundar Iyer <sundar.iyer@stericsson.com>");
Bengt Jonsson732805a2013-03-21 15:59:03 +00003249MODULE_AUTHOR("Bengt Jonsson <bengt.g.jonsson@stericsson.com>");
Lee Jones547f3842013-03-28 16:11:14 +00003250MODULE_AUTHOR("Daniel Willerud <daniel.willerud@stericsson.com>");
Sundar R IYERc789ca22010-07-13 21:48:56 +05303251MODULE_DESCRIPTION("Regulator Driver for ST-Ericsson AB8500 Mixed-Sig PMIC");
3252MODULE_ALIAS("platform:ab8500-regulator");