blob: 8a9cd45eac028b314847f4092a8ee75f1cf42954 [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
651static int ab8500_regulator_set_voltage_time_sel(struct regulator_dev *rdev,
652 unsigned int old_sel,
653 unsigned int new_sel)
654{
655 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
656
657 return info->delay;
658}
659
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000660static struct regulator_ops ab8500_regulator_volt_mode_ops = {
661 .enable = ab8500_regulator_enable,
662 .disable = ab8500_regulator_disable,
663 .is_enabled = ab8500_regulator_is_enabled,
664 .get_optimum_mode = ab8500_regulator_get_optimum_mode,
665 .set_mode = ab8500_regulator_set_mode,
666 .get_mode = ab8500_regulator_get_mode,
667 .get_voltage_sel = ab8500_regulator_get_voltage_sel,
668 .set_voltage_sel = ab8500_regulator_set_voltage_sel,
669 .list_voltage = regulator_list_voltage_table,
Sundar R IYERc789ca22010-07-13 21:48:56 +0530670};
671
Lee Jonesd7607ba2013-04-02 13:24:11 +0100672static struct regulator_ops ab8540_aux3_regulator_volt_mode_ops = {
673 .enable = ab8500_regulator_enable,
674 .disable = ab8500_regulator_disable,
675 .get_optimum_mode = ab8500_regulator_get_optimum_mode,
676 .set_mode = ab8500_regulator_set_mode,
677 .get_mode = ab8500_regulator_get_mode,
678 .is_enabled = ab8500_regulator_is_enabled,
679 .get_voltage_sel = ab8540_aux3_regulator_get_voltage_sel,
680 .set_voltage_sel = ab8540_aux3_regulator_set_voltage_sel,
681 .list_voltage = regulator_list_voltage_table,
682 .set_voltage_time_sel = ab8500_regulator_set_voltage_time_sel,
683};
684
Lee Jones8a3b1b82013-04-02 13:24:09 +0100685static struct regulator_ops ab8500_regulator_volt_ops = {
686 .enable = ab8500_regulator_enable,
687 .disable = ab8500_regulator_disable,
688 .is_enabled = ab8500_regulator_is_enabled,
689 .get_voltage_sel = ab8500_regulator_get_voltage_sel,
690 .set_voltage_sel = ab8500_regulator_set_voltage_sel,
691 .list_voltage = regulator_list_voltage_table,
692 .set_voltage_time_sel = ab8500_regulator_set_voltage_time_sel,
693};
694
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000695static struct regulator_ops ab8500_regulator_mode_ops = {
696 .enable = ab8500_regulator_enable,
697 .disable = ab8500_regulator_disable,
698 .is_enabled = ab8500_regulator_is_enabled,
699 .get_optimum_mode = ab8500_regulator_get_optimum_mode,
700 .set_mode = ab8500_regulator_set_mode,
701 .get_mode = ab8500_regulator_get_mode,
Axel Lin5689e832013-03-25 14:59:00 +0800702 .list_voltage = regulator_list_voltage_linear,
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000703};
704
705static struct regulator_ops ab8500_regulator_ops = {
706 .enable = ab8500_regulator_enable,
707 .disable = ab8500_regulator_disable,
708 .is_enabled = ab8500_regulator_is_enabled,
Axel Lin5689e832013-03-25 14:59:00 +0800709 .list_voltage = regulator_list_voltage_linear,
Sundar R IYERc789ca22010-07-13 21:48:56 +0530710};
711
Lee Jones3fe52282013-04-02 13:24:12 +0100712static struct regulator_ops ab8500_regulator_anamic_mode_ops = {
713 .enable = ab8500_regulator_enable,
714 .disable = ab8500_regulator_disable,
715 .is_enabled = ab8500_regulator_is_enabled,
716 .set_mode = ab8500_regulator_set_mode,
717 .get_mode = ab8500_regulator_get_mode,
718 .list_voltage = regulator_list_voltage_table,
719};
720
Lee Jones8e6a8d72013-03-28 16:11:11 +0000721/* AB8500 regulator information */
Bengt Jonsson6909b452010-12-10 11:08:47 +0100722static struct ab8500_regulator_info
723 ab8500_regulator_info[AB8500_NUM_REGULATORS] = {
Sundar R IYERc789ca22010-07-13 21:48:56 +0530724 /*
Bengt Jonssone1159e62010-12-10 11:08:44 +0100725 * Variable Voltage Regulators
726 * name, min mV, max mV,
727 * update bank, reg, mask, enable val
Axel Linec1cc4d2012-05-20 10:33:35 +0800728 * volt bank, reg, mask
Sundar R IYERc789ca22010-07-13 21:48:56 +0530729 */
Bengt Jonsson6909b452010-12-10 11:08:47 +0100730 [AB8500_LDO_AUX1] = {
731 .desc = {
732 .name = "LDO-AUX1",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000733 .ops = &ab8500_regulator_volt_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100734 .type = REGULATOR_VOLTAGE,
735 .id = AB8500_LDO_AUX1,
736 .owner = THIS_MODULE,
737 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Axel Linec1cc4d2012-05-20 10:33:35 +0800738 .volt_table = ldo_vauxn_voltages,
Axel Lin530158b2013-03-27 17:47:22 +0800739 .enable_time = 200,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100740 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000741 .load_lp_uA = 5000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100742 .update_bank = 0x04,
743 .update_reg = 0x09,
744 .update_mask = 0x03,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000745 .update_val = 0x01,
746 .update_val_idle = 0x03,
747 .update_val_normal = 0x01,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100748 .voltage_bank = 0x04,
749 .voltage_reg = 0x1f,
750 .voltage_mask = 0x0f,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100751 },
752 [AB8500_LDO_AUX2] = {
753 .desc = {
754 .name = "LDO-AUX2",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000755 .ops = &ab8500_regulator_volt_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100756 .type = REGULATOR_VOLTAGE,
757 .id = AB8500_LDO_AUX2,
758 .owner = THIS_MODULE,
759 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Axel Linec1cc4d2012-05-20 10:33:35 +0800760 .volt_table = ldo_vauxn_voltages,
Axel Lin530158b2013-03-27 17:47:22 +0800761 .enable_time = 200,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100762 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000763 .load_lp_uA = 5000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100764 .update_bank = 0x04,
765 .update_reg = 0x09,
766 .update_mask = 0x0c,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000767 .update_val = 0x04,
768 .update_val_idle = 0x0c,
769 .update_val_normal = 0x04,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100770 .voltage_bank = 0x04,
771 .voltage_reg = 0x20,
772 .voltage_mask = 0x0f,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100773 },
774 [AB8500_LDO_AUX3] = {
775 .desc = {
776 .name = "LDO-AUX3",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000777 .ops = &ab8500_regulator_volt_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100778 .type = REGULATOR_VOLTAGE,
779 .id = AB8500_LDO_AUX3,
780 .owner = THIS_MODULE,
781 .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages),
Axel Linec1cc4d2012-05-20 10:33:35 +0800782 .volt_table = ldo_vaux3_voltages,
Axel Lin530158b2013-03-27 17:47:22 +0800783 .enable_time = 450,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100784 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000785 .load_lp_uA = 5000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100786 .update_bank = 0x04,
787 .update_reg = 0x0a,
788 .update_mask = 0x03,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000789 .update_val = 0x01,
790 .update_val_idle = 0x03,
791 .update_val_normal = 0x01,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100792 .voltage_bank = 0x04,
793 .voltage_reg = 0x21,
794 .voltage_mask = 0x07,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100795 },
796 [AB8500_LDO_INTCORE] = {
797 .desc = {
798 .name = "LDO-INTCORE",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000799 .ops = &ab8500_regulator_volt_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100800 .type = REGULATOR_VOLTAGE,
801 .id = AB8500_LDO_INTCORE,
802 .owner = THIS_MODULE,
803 .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
Axel Linec1cc4d2012-05-20 10:33:35 +0800804 .volt_table = ldo_vintcore_voltages,
Axel Lin530158b2013-03-27 17:47:22 +0800805 .enable_time = 750,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100806 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000807 .load_lp_uA = 5000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100808 .update_bank = 0x03,
809 .update_reg = 0x80,
810 .update_mask = 0x44,
Lee Jonescc40dc22013-03-21 15:59:41 +0000811 .update_val = 0x44,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000812 .update_val_idle = 0x44,
813 .update_val_normal = 0x04,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100814 .voltage_bank = 0x03,
815 .voltage_reg = 0x80,
816 .voltage_mask = 0x38,
Linus Walleija0a70142012-08-20 18:41:35 +0200817 .voltage_shift = 3,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100818 },
Sundar R IYERc789ca22010-07-13 21:48:56 +0530819
820 /*
Bengt Jonssone1159e62010-12-10 11:08:44 +0100821 * Fixed Voltage Regulators
822 * name, fixed mV,
823 * update bank, reg, mask, enable val
Sundar R IYERc789ca22010-07-13 21:48:56 +0530824 */
Bengt Jonsson6909b452010-12-10 11:08:47 +0100825 [AB8500_LDO_TVOUT] = {
826 .desc = {
827 .name = "LDO-TVOUT",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000828 .ops = &ab8500_regulator_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100829 .type = REGULATOR_VOLTAGE,
830 .id = AB8500_LDO_TVOUT,
831 .owner = THIS_MODULE,
832 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +0000833 .volt_table = fixed_2000000_voltage,
Lee Jonesed3c1382013-03-28 16:11:12 +0000834 .enable_time = 500,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100835 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000836 .load_lp_uA = 1000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100837 .update_bank = 0x03,
838 .update_reg = 0x80,
839 .update_mask = 0x82,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000840 .update_val = 0x02,
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000841 .update_val_idle = 0x82,
842 .update_val_normal = 0x02,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100843 },
844 [AB8500_LDO_AUDIO] = {
845 .desc = {
846 .name = "LDO-AUDIO",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000847 .ops = &ab8500_regulator_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100848 .type = REGULATOR_VOLTAGE,
849 .id = AB8500_LDO_AUDIO,
850 .owner = THIS_MODULE,
851 .n_voltages = 1,
Axel Lin530158b2013-03-27 17:47:22 +0800852 .enable_time = 140,
Lee Jonesb080c782013-03-28 16:11:17 +0000853 .volt_table = fixed_2000000_voltage,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100854 },
Bengt Jonsson6909b452010-12-10 11:08:47 +0100855 .update_bank = 0x03,
856 .update_reg = 0x83,
857 .update_mask = 0x02,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000858 .update_val = 0x02,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100859 },
860 [AB8500_LDO_ANAMIC1] = {
861 .desc = {
862 .name = "LDO-ANAMIC1",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000863 .ops = &ab8500_regulator_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100864 .type = REGULATOR_VOLTAGE,
865 .id = AB8500_LDO_ANAMIC1,
866 .owner = THIS_MODULE,
867 .n_voltages = 1,
Axel Lin530158b2013-03-27 17:47:22 +0800868 .enable_time = 500,
Lee Jonesb080c782013-03-28 16:11:17 +0000869 .volt_table = fixed_2050000_voltage,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100870 },
Bengt Jonsson6909b452010-12-10 11:08:47 +0100871 .update_bank = 0x03,
872 .update_reg = 0x83,
873 .update_mask = 0x08,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000874 .update_val = 0x08,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100875 },
876 [AB8500_LDO_ANAMIC2] = {
877 .desc = {
878 .name = "LDO-ANAMIC2",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000879 .ops = &ab8500_regulator_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100880 .type = REGULATOR_VOLTAGE,
881 .id = AB8500_LDO_ANAMIC2,
882 .owner = THIS_MODULE,
883 .n_voltages = 1,
Axel Lin530158b2013-03-27 17:47:22 +0800884 .enable_time = 500,
Lee Jonesb080c782013-03-28 16:11:17 +0000885 .volt_table = fixed_2050000_voltage,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100886 },
Bengt Jonsson6909b452010-12-10 11:08:47 +0100887 .update_bank = 0x03,
888 .update_reg = 0x83,
889 .update_mask = 0x10,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000890 .update_val = 0x10,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100891 },
892 [AB8500_LDO_DMIC] = {
893 .desc = {
894 .name = "LDO-DMIC",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000895 .ops = &ab8500_regulator_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100896 .type = REGULATOR_VOLTAGE,
897 .id = AB8500_LDO_DMIC,
898 .owner = THIS_MODULE,
899 .n_voltages = 1,
Axel Lin530158b2013-03-27 17:47:22 +0800900 .enable_time = 420,
Lee Jonesb080c782013-03-28 16:11:17 +0000901 .volt_table = fixed_1800000_voltage,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100902 },
Bengt Jonsson6909b452010-12-10 11:08:47 +0100903 .update_bank = 0x03,
904 .update_reg = 0x83,
905 .update_mask = 0x04,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000906 .update_val = 0x04,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100907 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000908
909 /*
910 * Regulators with fixed voltage and normal/idle modes
911 */
Bengt Jonsson6909b452010-12-10 11:08:47 +0100912 [AB8500_LDO_ANA] = {
913 .desc = {
914 .name = "LDO-ANA",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000915 .ops = &ab8500_regulator_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100916 .type = REGULATOR_VOLTAGE,
917 .id = AB8500_LDO_ANA,
918 .owner = THIS_MODULE,
919 .n_voltages = 1,
Axel Lin530158b2013-03-27 17:47:22 +0800920 .enable_time = 140,
Lee Jonesb080c782013-03-28 16:11:17 +0000921 .volt_table = fixed_1200000_voltage,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100922 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000923 .load_lp_uA = 1000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100924 .update_bank = 0x04,
925 .update_reg = 0x06,
926 .update_mask = 0x0c,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000927 .update_val = 0x04,
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000928 .update_val_idle = 0x0c,
929 .update_val_normal = 0x04,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100930 },
Lee Jones8e6a8d72013-03-28 16:11:11 +0000931};
Bengt Jonsson6909b452010-12-10 11:08:47 +0100932
Lee Jones547f3842013-03-28 16:11:14 +0000933/* AB8505 regulator information */
934static struct ab8500_regulator_info
935 ab8505_regulator_info[AB8505_NUM_REGULATORS] = {
936 /*
937 * Variable Voltage Regulators
938 * name, min mV, max mV,
939 * update bank, reg, mask, enable val
940 * volt bank, reg, mask, table, table length
941 */
942 [AB8505_LDO_AUX1] = {
943 .desc = {
944 .name = "LDO-AUX1",
945 .ops = &ab8500_regulator_volt_mode_ops,
946 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +0100947 .id = AB8505_LDO_AUX1,
Lee Jones547f3842013-03-28 16:11:14 +0000948 .owner = THIS_MODULE,
949 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +0000950 .volt_table = ldo_vauxn_voltages,
Lee Jones547f3842013-03-28 16:11:14 +0000951 },
Lee Jones547f3842013-03-28 16:11:14 +0000952 .load_lp_uA = 5000,
953 .update_bank = 0x04,
954 .update_reg = 0x09,
955 .update_mask = 0x03,
956 .update_val = 0x01,
957 .update_val_idle = 0x03,
958 .update_val_normal = 0x01,
959 .voltage_bank = 0x04,
960 .voltage_reg = 0x1f,
961 .voltage_mask = 0x0f,
Lee Jones547f3842013-03-28 16:11:14 +0000962 },
963 [AB8505_LDO_AUX2] = {
964 .desc = {
965 .name = "LDO-AUX2",
966 .ops = &ab8500_regulator_volt_mode_ops,
967 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +0100968 .id = AB8505_LDO_AUX2,
Lee Jones547f3842013-03-28 16:11:14 +0000969 .owner = THIS_MODULE,
970 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +0000971 .volt_table = ldo_vauxn_voltages,
Lee Jones547f3842013-03-28 16:11:14 +0000972 },
Lee Jones547f3842013-03-28 16:11:14 +0000973 .load_lp_uA = 5000,
974 .update_bank = 0x04,
975 .update_reg = 0x09,
976 .update_mask = 0x0c,
977 .update_val = 0x04,
978 .update_val_idle = 0x0c,
979 .update_val_normal = 0x04,
980 .voltage_bank = 0x04,
981 .voltage_reg = 0x20,
982 .voltage_mask = 0x0f,
Lee Jones547f3842013-03-28 16:11:14 +0000983 },
984 [AB8505_LDO_AUX3] = {
985 .desc = {
986 .name = "LDO-AUX3",
987 .ops = &ab8500_regulator_volt_mode_ops,
988 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +0100989 .id = AB8505_LDO_AUX3,
Lee Jones547f3842013-03-28 16:11:14 +0000990 .owner = THIS_MODULE,
991 .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +0000992 .volt_table = ldo_vaux3_voltages,
Lee Jones547f3842013-03-28 16:11:14 +0000993 },
Lee Jones547f3842013-03-28 16:11:14 +0000994 .load_lp_uA = 5000,
995 .update_bank = 0x04,
996 .update_reg = 0x0a,
997 .update_mask = 0x03,
998 .update_val = 0x01,
999 .update_val_idle = 0x03,
1000 .update_val_normal = 0x01,
1001 .voltage_bank = 0x04,
1002 .voltage_reg = 0x21,
1003 .voltage_mask = 0x07,
Lee Jones547f3842013-03-28 16:11:14 +00001004 },
1005 [AB8505_LDO_AUX4] = {
1006 .desc = {
1007 .name = "LDO-AUX4",
1008 .ops = &ab8500_regulator_volt_mode_ops,
1009 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001010 .id = AB8505_LDO_AUX4,
Lee Jones547f3842013-03-28 16:11:14 +00001011 .owner = THIS_MODULE,
1012 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001013 .volt_table = ldo_vauxn_voltages,
Lee Jones547f3842013-03-28 16:11:14 +00001014 },
Lee Jones547f3842013-03-28 16:11:14 +00001015 .load_lp_uA = 5000,
1016 /* values for Vaux4Regu register */
1017 .update_bank = 0x04,
1018 .update_reg = 0x2e,
1019 .update_mask = 0x03,
1020 .update_val = 0x01,
1021 .update_val_idle = 0x03,
1022 .update_val_normal = 0x01,
1023 /* values for Vaux4SEL register */
1024 .voltage_bank = 0x04,
1025 .voltage_reg = 0x2f,
1026 .voltage_mask = 0x0f,
Lee Jones547f3842013-03-28 16:11:14 +00001027 },
1028 [AB8505_LDO_AUX5] = {
1029 .desc = {
1030 .name = "LDO-AUX5",
1031 .ops = &ab8500_regulator_volt_mode_ops,
1032 .type = REGULATOR_VOLTAGE,
1033 .id = AB8505_LDO_AUX5,
1034 .owner = THIS_MODULE,
1035 .n_voltages = ARRAY_SIZE(ldo_vaux56_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001036 .volt_table = ldo_vaux56_voltages,
Lee Jones547f3842013-03-28 16:11:14 +00001037 },
Lee Jones547f3842013-03-28 16:11:14 +00001038 .load_lp_uA = 2000,
1039 /* values for CtrlVaux5 register */
1040 .update_bank = 0x01,
1041 .update_reg = 0x55,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001042 .update_mask = 0x18,
1043 .update_val = 0x10,
1044 .update_val_idle = 0x18,
1045 .update_val_normal = 0x10,
Lee Jones547f3842013-03-28 16:11:14 +00001046 .voltage_bank = 0x01,
1047 .voltage_reg = 0x55,
1048 .voltage_mask = 0x07,
Lee Jones547f3842013-03-28 16:11:14 +00001049 },
1050 [AB8505_LDO_AUX6] = {
1051 .desc = {
1052 .name = "LDO-AUX6",
1053 .ops = &ab8500_regulator_volt_mode_ops,
1054 .type = REGULATOR_VOLTAGE,
1055 .id = AB8505_LDO_AUX6,
1056 .owner = THIS_MODULE,
1057 .n_voltages = ARRAY_SIZE(ldo_vaux56_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001058 .volt_table = ldo_vaux56_voltages,
Lee Jones547f3842013-03-28 16:11:14 +00001059 },
Lee Jones547f3842013-03-28 16:11:14 +00001060 .load_lp_uA = 2000,
1061 /* values for CtrlVaux6 register */
1062 .update_bank = 0x01,
1063 .update_reg = 0x56,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001064 .update_mask = 0x18,
1065 .update_val = 0x10,
1066 .update_val_idle = 0x18,
1067 .update_val_normal = 0x10,
Lee Jones547f3842013-03-28 16:11:14 +00001068 .voltage_bank = 0x01,
1069 .voltage_reg = 0x56,
1070 .voltage_mask = 0x07,
Lee Jones547f3842013-03-28 16:11:14 +00001071 },
1072 [AB8505_LDO_INTCORE] = {
1073 .desc = {
1074 .name = "LDO-INTCORE",
1075 .ops = &ab8500_regulator_volt_mode_ops,
1076 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001077 .id = AB8505_LDO_INTCORE,
Lee Jones547f3842013-03-28 16:11:14 +00001078 .owner = THIS_MODULE,
1079 .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001080 .volt_table = ldo_vintcore_voltages,
Lee Jones547f3842013-03-28 16:11:14 +00001081 },
Lee Jones547f3842013-03-28 16:11:14 +00001082 .load_lp_uA = 5000,
1083 .update_bank = 0x03,
1084 .update_reg = 0x80,
1085 .update_mask = 0x44,
1086 .update_val = 0x04,
1087 .update_val_idle = 0x44,
1088 .update_val_normal = 0x04,
1089 .voltage_bank = 0x03,
1090 .voltage_reg = 0x80,
1091 .voltage_mask = 0x38,
Lee Jones547f3842013-03-28 16:11:14 +00001092 .voltage_shift = 3,
1093 },
1094
1095 /*
1096 * Fixed Voltage Regulators
1097 * name, fixed mV,
1098 * update bank, reg, mask, enable val
1099 */
1100 [AB8505_LDO_ADC] = {
1101 .desc = {
1102 .name = "LDO-ADC",
1103 .ops = &ab8500_regulator_mode_ops,
1104 .type = REGULATOR_VOLTAGE,
1105 .id = AB8505_LDO_ADC,
1106 .owner = THIS_MODULE,
1107 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001108 .volt_table = fixed_2000000_voltage,
Lee Jonesa4d68462013-04-02 13:24:16 +01001109 .enable_time = 10000,
Lee Jones547f3842013-03-28 16:11:14 +00001110 },
1111 .delay = 10000,
Lee Jones547f3842013-03-28 16:11:14 +00001112 .load_lp_uA = 1000,
1113 .update_bank = 0x03,
1114 .update_reg = 0x80,
1115 .update_mask = 0x82,
1116 .update_val = 0x02,
1117 .update_val_idle = 0x82,
1118 .update_val_normal = 0x02,
1119 },
1120 [AB8505_LDO_USB] = {
1121 .desc = {
1122 .name = "LDO-USB",
1123 .ops = &ab8500_regulator_mode_ops,
1124 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001125 .id = AB8505_LDO_USB,
Lee Jones547f3842013-03-28 16:11:14 +00001126 .owner = THIS_MODULE,
1127 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001128 .volt_table = fixed_3300000_voltage,
Lee Jones547f3842013-03-28 16:11:14 +00001129 },
Lee Jones547f3842013-03-28 16:11:14 +00001130 .update_bank = 0x03,
1131 .update_reg = 0x82,
1132 .update_mask = 0x03,
1133 .update_val = 0x01,
1134 .update_val_idle = 0x03,
1135 .update_val_normal = 0x01,
1136 },
1137 [AB8505_LDO_AUDIO] = {
1138 .desc = {
1139 .name = "LDO-AUDIO",
Lee Jones8a3b1b82013-04-02 13:24:09 +01001140 .ops = &ab8500_regulator_volt_ops,
Lee Jones547f3842013-03-28 16:11:14 +00001141 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001142 .id = AB8505_LDO_AUDIO,
Lee Jones547f3842013-03-28 16:11:14 +00001143 .owner = THIS_MODULE,
Lee Jones8a3b1b82013-04-02 13:24:09 +01001144 .n_voltages = ARRAY_SIZE(ldo_vaudio_voltages),
1145 .volt_table = ldo_vaudio_voltages,
Lee Jones547f3842013-03-28 16:11:14 +00001146 },
Lee Jones547f3842013-03-28 16:11:14 +00001147 .update_bank = 0x03,
1148 .update_reg = 0x83,
1149 .update_mask = 0x02,
1150 .update_val = 0x02,
Lee Jones8a3b1b82013-04-02 13:24:09 +01001151 .voltage_bank = 0x01,
1152 .voltage_reg = 0x57,
1153 .voltage_mask = 0x7,
1154 .voltage_shift = 4,
1155 .voltages = ldo_vaudio_voltages,
1156 .voltages_len = ARRAY_SIZE(ldo_vaudio_voltages),
Lee Jones547f3842013-03-28 16:11:14 +00001157 },
1158 [AB8505_LDO_ANAMIC1] = {
1159 .desc = {
1160 .name = "LDO-ANAMIC1",
Lee Jones3fe52282013-04-02 13:24:12 +01001161 .ops = &ab8500_regulator_anamic_mode_ops,
Lee Jones547f3842013-03-28 16:11:14 +00001162 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001163 .id = AB8505_LDO_ANAMIC1,
Lee Jones547f3842013-03-28 16:11:14 +00001164 .owner = THIS_MODULE,
1165 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001166 .volt_table = fixed_2050000_voltage,
Lee Jones547f3842013-03-28 16:11:14 +00001167 },
Lee Jones4c84b4d2013-04-02 13:24:13 +01001168 .shared_mode = &ldo_anamic1_shared,
Lee Jones547f3842013-03-28 16:11:14 +00001169 .update_bank = 0x03,
1170 .update_reg = 0x83,
1171 .update_mask = 0x08,
1172 .update_val = 0x08,
Lee Jones3fe52282013-04-02 13:24:12 +01001173 .mode_bank = 0x01,
1174 .mode_reg = 0x54,
1175 .mode_mask = 0x04,
1176 .mode_val_idle = 0x04,
1177 .mode_val_normal = 0x00,
Lee Jones547f3842013-03-28 16:11:14 +00001178 },
1179 [AB8505_LDO_ANAMIC2] = {
1180 .desc = {
1181 .name = "LDO-ANAMIC2",
Lee Jones3fe52282013-04-02 13:24:12 +01001182 .ops = &ab8500_regulator_anamic_mode_ops,
Lee Jones547f3842013-03-28 16:11:14 +00001183 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001184 .id = AB8505_LDO_ANAMIC2,
Lee Jones547f3842013-03-28 16:11:14 +00001185 .owner = THIS_MODULE,
1186 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001187 .volt_table = fixed_2050000_voltage,
Lee Jones547f3842013-03-28 16:11:14 +00001188 },
Lee Jones3fe52282013-04-02 13:24:12 +01001189 .shared_mode = &ldo_anamic2_shared,
Lee Jones547f3842013-03-28 16:11:14 +00001190 .update_bank = 0x03,
1191 .update_reg = 0x83,
1192 .update_mask = 0x10,
1193 .update_val = 0x10,
Lee Jones3fe52282013-04-02 13:24:12 +01001194 .mode_bank = 0x01,
1195 .mode_reg = 0x54,
1196 .mode_mask = 0x04,
1197 .mode_val_idle = 0x04,
1198 .mode_val_normal = 0x00,
Lee Jones547f3842013-03-28 16:11:14 +00001199 },
1200 [AB8505_LDO_AUX8] = {
1201 .desc = {
1202 .name = "LDO-AUX8",
1203 .ops = &ab8500_regulator_ops,
1204 .type = REGULATOR_VOLTAGE,
1205 .id = AB8505_LDO_AUX8,
1206 .owner = THIS_MODULE,
1207 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001208 .volt_table = fixed_1800000_voltage,
Lee Jones547f3842013-03-28 16:11:14 +00001209 },
Lee Jones547f3842013-03-28 16:11:14 +00001210 .update_bank = 0x03,
1211 .update_reg = 0x83,
1212 .update_mask = 0x04,
1213 .update_val = 0x04,
1214 },
1215 /*
1216 * Regulators with fixed voltage and normal/idle modes
1217 */
1218 [AB8505_LDO_ANA] = {
1219 .desc = {
1220 .name = "LDO-ANA",
Lee Jones8a3b1b82013-04-02 13:24:09 +01001221 .ops = &ab8500_regulator_volt_mode_ops,
Lee Jones547f3842013-03-28 16:11:14 +00001222 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001223 .id = AB8505_LDO_ANA,
Lee Jones547f3842013-03-28 16:11:14 +00001224 .owner = THIS_MODULE,
Lee Jones8a3b1b82013-04-02 13:24:09 +01001225 .n_voltages = ARRAY_SIZE(ldo_vana_voltages),
1226 .volt_table = ldo_vana_voltages,
Lee Jones547f3842013-03-28 16:11:14 +00001227 },
Lee Jones547f3842013-03-28 16:11:14 +00001228 .load_lp_uA = 1000,
1229 .update_bank = 0x04,
1230 .update_reg = 0x06,
1231 .update_mask = 0x0c,
1232 .update_val = 0x04,
1233 .update_val_idle = 0x0c,
1234 .update_val_normal = 0x04,
Lee Jones8a3b1b82013-04-02 13:24:09 +01001235 .voltage_bank = 0x04,
1236 .voltage_reg = 0x29,
1237 .voltage_mask = 0x7,
1238 .voltages = ldo_vana_voltages,
1239 .voltages_len = ARRAY_SIZE(ldo_vana_voltages),
Lee Jones547f3842013-03-28 16:11:14 +00001240 },
1241};
1242
Lee Jones8e6a8d72013-03-28 16:11:11 +00001243/* AB9540 regulator information */
1244static struct ab8500_regulator_info
1245 ab9540_regulator_info[AB9540_NUM_REGULATORS] = {
1246 /*
1247 * Variable Voltage Regulators
1248 * name, min mV, max mV,
1249 * update bank, reg, mask, enable val
1250 * volt bank, reg, mask, table, table length
1251 */
1252 [AB9540_LDO_AUX1] = {
1253 .desc = {
1254 .name = "LDO-AUX1",
1255 .ops = &ab8500_regulator_volt_mode_ops,
1256 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001257 .id = AB9540_LDO_AUX1,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001258 .owner = THIS_MODULE,
1259 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001260 .volt_table = ldo_vauxn_voltages,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001261 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001262 .load_lp_uA = 5000,
1263 .update_bank = 0x04,
1264 .update_reg = 0x09,
1265 .update_mask = 0x03,
1266 .update_val = 0x01,
1267 .update_val_idle = 0x03,
1268 .update_val_normal = 0x01,
1269 .voltage_bank = 0x04,
1270 .voltage_reg = 0x1f,
1271 .voltage_mask = 0x0f,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001272 },
1273 [AB9540_LDO_AUX2] = {
1274 .desc = {
1275 .name = "LDO-AUX2",
1276 .ops = &ab8500_regulator_volt_mode_ops,
1277 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001278 .id = AB9540_LDO_AUX2,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001279 .owner = THIS_MODULE,
1280 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001281 .volt_table = ldo_vauxn_voltages,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001282 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001283 .load_lp_uA = 5000,
1284 .update_bank = 0x04,
1285 .update_reg = 0x09,
1286 .update_mask = 0x0c,
1287 .update_val = 0x04,
1288 .update_val_idle = 0x0c,
1289 .update_val_normal = 0x04,
1290 .voltage_bank = 0x04,
1291 .voltage_reg = 0x20,
1292 .voltage_mask = 0x0f,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001293 },
1294 [AB9540_LDO_AUX3] = {
1295 .desc = {
1296 .name = "LDO-AUX3",
1297 .ops = &ab8500_regulator_volt_mode_ops,
1298 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001299 .id = AB9540_LDO_AUX3,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001300 .owner = THIS_MODULE,
1301 .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001302 .volt_table = ldo_vaux3_voltages,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001303 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001304 .load_lp_uA = 5000,
1305 .update_bank = 0x04,
1306 .update_reg = 0x0a,
1307 .update_mask = 0x03,
1308 .update_val = 0x01,
1309 .update_val_idle = 0x03,
1310 .update_val_normal = 0x01,
1311 .voltage_bank = 0x04,
1312 .voltage_reg = 0x21,
1313 .voltage_mask = 0x07,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001314 },
1315 [AB9540_LDO_AUX4] = {
1316 .desc = {
1317 .name = "LDO-AUX4",
1318 .ops = &ab8500_regulator_volt_mode_ops,
1319 .type = REGULATOR_VOLTAGE,
1320 .id = AB9540_LDO_AUX4,
1321 .owner = THIS_MODULE,
1322 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001323 .volt_table = ldo_vauxn_voltages,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001324 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001325 .load_lp_uA = 5000,
1326 /* values for Vaux4Regu register */
1327 .update_bank = 0x04,
1328 .update_reg = 0x2e,
1329 .update_mask = 0x03,
1330 .update_val = 0x01,
1331 .update_val_idle = 0x03,
1332 .update_val_normal = 0x01,
1333 /* values for Vaux4SEL register */
1334 .voltage_bank = 0x04,
1335 .voltage_reg = 0x2f,
1336 .voltage_mask = 0x0f,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001337 },
1338 [AB9540_LDO_INTCORE] = {
1339 .desc = {
1340 .name = "LDO-INTCORE",
1341 .ops = &ab8500_regulator_volt_mode_ops,
1342 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001343 .id = AB9540_LDO_INTCORE,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001344 .owner = THIS_MODULE,
1345 .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001346 .volt_table = ldo_vintcore_voltages,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001347 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001348 .load_lp_uA = 5000,
1349 .update_bank = 0x03,
1350 .update_reg = 0x80,
1351 .update_mask = 0x44,
1352 .update_val = 0x44,
1353 .update_val_idle = 0x44,
1354 .update_val_normal = 0x04,
1355 .voltage_bank = 0x03,
1356 .voltage_reg = 0x80,
1357 .voltage_mask = 0x38,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001358 .voltage_shift = 3,
1359 },
Bengt Jonsson6909b452010-12-10 11:08:47 +01001360
Lee Jones8e6a8d72013-03-28 16:11:11 +00001361 /*
1362 * Fixed Voltage Regulators
1363 * name, fixed mV,
1364 * update bank, reg, mask, enable val
1365 */
1366 [AB9540_LDO_TVOUT] = {
1367 .desc = {
1368 .name = "LDO-TVOUT",
1369 .ops = &ab8500_regulator_mode_ops,
1370 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001371 .id = AB9540_LDO_TVOUT,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001372 .owner = THIS_MODULE,
1373 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001374 .volt_table = fixed_2000000_voltage,
Lee Jonesa4d68462013-04-02 13:24:16 +01001375 .enable_time = 10000,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001376 },
1377 .delay = 10000,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001378 .load_lp_uA = 1000,
1379 .update_bank = 0x03,
1380 .update_reg = 0x80,
1381 .update_mask = 0x82,
1382 .update_val = 0x02,
1383 .update_val_idle = 0x82,
1384 .update_val_normal = 0x02,
1385 },
1386 [AB9540_LDO_USB] = {
1387 .desc = {
1388 .name = "LDO-USB",
1389 .ops = &ab8500_regulator_ops,
1390 .type = REGULATOR_VOLTAGE,
1391 .id = AB9540_LDO_USB,
1392 .owner = THIS_MODULE,
1393 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001394 .volt_table = fixed_3300000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001395 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001396 .update_bank = 0x03,
1397 .update_reg = 0x82,
1398 .update_mask = 0x03,
1399 .update_val = 0x01,
1400 .update_val_idle = 0x03,
1401 .update_val_normal = 0x01,
1402 },
1403 [AB9540_LDO_AUDIO] = {
1404 .desc = {
1405 .name = "LDO-AUDIO",
1406 .ops = &ab8500_regulator_ops,
1407 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001408 .id = AB9540_LDO_AUDIO,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001409 .owner = THIS_MODULE,
1410 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001411 .volt_table = fixed_2000000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001412 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001413 .update_bank = 0x03,
1414 .update_reg = 0x83,
1415 .update_mask = 0x02,
1416 .update_val = 0x02,
1417 },
1418 [AB9540_LDO_ANAMIC1] = {
1419 .desc = {
1420 .name = "LDO-ANAMIC1",
1421 .ops = &ab8500_regulator_ops,
1422 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001423 .id = AB9540_LDO_ANAMIC1,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001424 .owner = THIS_MODULE,
1425 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001426 .volt_table = fixed_2050000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001427 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001428 .update_bank = 0x03,
1429 .update_reg = 0x83,
1430 .update_mask = 0x08,
1431 .update_val = 0x08,
1432 },
1433 [AB9540_LDO_ANAMIC2] = {
1434 .desc = {
1435 .name = "LDO-ANAMIC2",
1436 .ops = &ab8500_regulator_ops,
1437 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001438 .id = AB9540_LDO_ANAMIC2,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001439 .owner = THIS_MODULE,
1440 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001441 .volt_table = fixed_2050000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001442 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001443 .update_bank = 0x03,
1444 .update_reg = 0x83,
1445 .update_mask = 0x10,
1446 .update_val = 0x10,
1447 },
1448 [AB9540_LDO_DMIC] = {
1449 .desc = {
1450 .name = "LDO-DMIC",
1451 .ops = &ab8500_regulator_ops,
1452 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001453 .id = AB9540_LDO_DMIC,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001454 .owner = THIS_MODULE,
1455 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001456 .volt_table = fixed_1800000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001457 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001458 .update_bank = 0x03,
1459 .update_reg = 0x83,
1460 .update_mask = 0x04,
1461 .update_val = 0x04,
1462 },
1463
1464 /*
1465 * Regulators with fixed voltage and normal/idle modes
1466 */
1467 [AB9540_LDO_ANA] = {
1468 .desc = {
1469 .name = "LDO-ANA",
1470 .ops = &ab8500_regulator_mode_ops,
1471 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001472 .id = AB9540_LDO_ANA,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001473 .owner = THIS_MODULE,
1474 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001475 .volt_table = fixed_1200000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001476 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001477 .load_lp_uA = 1000,
1478 .update_bank = 0x04,
1479 .update_reg = 0x06,
1480 .update_mask = 0x0c,
1481 .update_val = 0x08,
1482 .update_val_idle = 0x0c,
1483 .update_val_normal = 0x08,
1484 },
Sundar R IYERc789ca22010-07-13 21:48:56 +05301485};
1486
Lee Jonesae0a9a32013-03-28 16:11:16 +00001487/* AB8540 regulator information */
1488static struct ab8500_regulator_info
1489 ab8540_regulator_info[AB8540_NUM_REGULATORS] = {
1490 /*
1491 * Variable Voltage Regulators
1492 * name, min mV, max mV,
1493 * update bank, reg, mask, enable val
1494 * volt bank, reg, mask, table, table length
1495 */
1496 [AB8540_LDO_AUX1] = {
1497 .desc = {
1498 .name = "LDO-AUX1",
1499 .ops = &ab8500_regulator_volt_mode_ops,
1500 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001501 .id = AB8540_LDO_AUX1,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001502 .owner = THIS_MODULE,
1503 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001504 .volt_table = ldo_vauxn_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001505 },
1506 .load_lp_uA = 5000,
1507 .update_bank = 0x04,
1508 .update_reg = 0x09,
1509 .update_mask = 0x03,
1510 .update_val = 0x01,
1511 .update_val_idle = 0x03,
1512 .update_val_normal = 0x01,
1513 .voltage_bank = 0x04,
1514 .voltage_reg = 0x1f,
1515 .voltage_mask = 0x0f,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001516 },
1517 [AB8540_LDO_AUX2] = {
1518 .desc = {
1519 .name = "LDO-AUX2",
1520 .ops = &ab8500_regulator_volt_mode_ops,
1521 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001522 .id = AB8540_LDO_AUX2,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001523 .owner = THIS_MODULE,
1524 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001525 .volt_table = ldo_vauxn_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001526 },
1527 .load_lp_uA = 5000,
1528 .update_bank = 0x04,
1529 .update_reg = 0x09,
1530 .update_mask = 0x0c,
1531 .update_val = 0x04,
1532 .update_val_idle = 0x0c,
1533 .update_val_normal = 0x04,
1534 .voltage_bank = 0x04,
1535 .voltage_reg = 0x20,
1536 .voltage_mask = 0x0f,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001537 },
1538 [AB8540_LDO_AUX3] = {
1539 .desc = {
1540 .name = "LDO-AUX3",
Lee Jonesd7607ba2013-04-02 13:24:11 +01001541 .ops = &ab8540_aux3_regulator_volt_mode_ops,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001542 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001543 .id = AB8540_LDO_AUX3,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001544 .owner = THIS_MODULE,
1545 .n_voltages = ARRAY_SIZE(ldo_vaux3_ab8540_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001546 .volt_table = ldo_vaux3_ab8540_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001547 },
1548 .load_lp_uA = 5000,
1549 .update_bank = 0x04,
1550 .update_reg = 0x0a,
1551 .update_mask = 0x03,
1552 .update_val = 0x01,
1553 .update_val_idle = 0x03,
1554 .update_val_normal = 0x01,
1555 .voltage_bank = 0x04,
1556 .voltage_reg = 0x21,
1557 .voltage_mask = 0x07,
Lee Jonesd7607ba2013-04-02 13:24:11 +01001558 .expand_register = {
1559 .voltage_limit = 8,
1560 .voltage_bank = 0x04,
1561 .voltage_reg = 0x01,
1562 .voltage_mask = 0x10,
1563 .voltage_shift = 1,
1564 }
Lee Jonesae0a9a32013-03-28 16:11:16 +00001565 },
1566 [AB8540_LDO_AUX4] = {
1567 .desc = {
1568 .name = "LDO-AUX4",
1569 .ops = &ab8500_regulator_volt_mode_ops,
1570 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001571 .id = AB8540_LDO_AUX4,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001572 .owner = THIS_MODULE,
1573 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001574 .volt_table = ldo_vauxn_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001575 },
1576 .load_lp_uA = 5000,
1577 /* values for Vaux4Regu register */
1578 .update_bank = 0x04,
1579 .update_reg = 0x2e,
1580 .update_mask = 0x03,
1581 .update_val = 0x01,
1582 .update_val_idle = 0x03,
1583 .update_val_normal = 0x01,
1584 /* values for Vaux4SEL register */
1585 .voltage_bank = 0x04,
1586 .voltage_reg = 0x2f,
1587 .voltage_mask = 0x0f,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001588 },
Zhenhua HUANG684d5ce2013-04-02 13:24:15 +01001589 [AB8540_LDO_AUX5] = {
1590 .desc = {
1591 .name = "LDO-AUX5",
1592 .ops = &ab8500_regulator_volt_mode_ops,
1593 .type = REGULATOR_VOLTAGE,
1594 .id = AB8540_LDO_AUX5,
1595 .owner = THIS_MODULE,
1596 .n_voltages = ARRAY_SIZE(ldo_vaux56_ab8540_voltages),
1597 },
1598 .load_lp_uA = 20000,
1599 /* values for Vaux5Regu register */
1600 .update_bank = 0x04,
1601 .update_reg = 0x32,
1602 .update_mask = 0x03,
1603 .update_val = 0x01,
1604 .update_val_idle = 0x03,
1605 .update_val_normal = 0x01,
1606 /* values for Vaux5SEL register */
1607 .voltage_bank = 0x04,
1608 .voltage_reg = 0x33,
1609 .voltage_mask = 0x3f,
1610 .voltages = ldo_vaux56_ab8540_voltages,
1611 .voltages_len = ARRAY_SIZE(ldo_vaux56_ab8540_voltages),
1612 },
1613 [AB8540_LDO_AUX6] = {
1614 .desc = {
1615 .name = "LDO-AUX6",
1616 .ops = &ab8500_regulator_volt_mode_ops,
1617 .type = REGULATOR_VOLTAGE,
1618 .id = AB8540_LDO_AUX6,
1619 .owner = THIS_MODULE,
1620 .n_voltages = ARRAY_SIZE(ldo_vaux56_ab8540_voltages),
1621 },
1622 .load_lp_uA = 20000,
1623 /* values for Vaux6Regu register */
1624 .update_bank = 0x04,
1625 .update_reg = 0x35,
1626 .update_mask = 0x03,
1627 .update_val = 0x01,
1628 .update_val_idle = 0x03,
1629 .update_val_normal = 0x01,
1630 /* values for Vaux6SEL register */
1631 .voltage_bank = 0x04,
1632 .voltage_reg = 0x36,
1633 .voltage_mask = 0x3f,
1634 .voltages = ldo_vaux56_ab8540_voltages,
1635 .voltages_len = ARRAY_SIZE(ldo_vaux56_ab8540_voltages),
1636 },
Lee Jonesae0a9a32013-03-28 16:11:16 +00001637 [AB8540_LDO_INTCORE] = {
1638 .desc = {
1639 .name = "LDO-INTCORE",
1640 .ops = &ab8500_regulator_volt_mode_ops,
1641 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001642 .id = AB8540_LDO_INTCORE,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001643 .owner = THIS_MODULE,
1644 .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001645 .volt_table = ldo_vintcore_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001646 },
1647 .load_lp_uA = 5000,
1648 .update_bank = 0x03,
1649 .update_reg = 0x80,
1650 .update_mask = 0x44,
1651 .update_val = 0x44,
1652 .update_val_idle = 0x44,
1653 .update_val_normal = 0x04,
1654 .voltage_bank = 0x03,
1655 .voltage_reg = 0x80,
1656 .voltage_mask = 0x38,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001657 .voltage_shift = 3,
1658 },
1659
1660 /*
1661 * Fixed Voltage Regulators
1662 * name, fixed mV,
1663 * update bank, reg, mask, enable val
1664 */
1665 [AB8540_LDO_TVOUT] = {
1666 .desc = {
1667 .name = "LDO-TVOUT",
1668 .ops = &ab8500_regulator_mode_ops,
1669 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001670 .id = AB8540_LDO_TVOUT,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001671 .owner = THIS_MODULE,
1672 .n_voltages = 1,
Lee Jonesa4d68462013-04-02 13:24:16 +01001673 .enable_time = 10000,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001674 },
1675 .delay = 10000,
1676 .load_lp_uA = 1000,
1677 .update_bank = 0x03,
1678 .update_reg = 0x80,
1679 .update_mask = 0x82,
1680 .update_val = 0x02,
1681 .update_val_idle = 0x82,
1682 .update_val_normal = 0x02,
1683 },
1684 [AB8540_LDO_AUDIO] = {
1685 .desc = {
1686 .name = "LDO-AUDIO",
1687 .ops = &ab8500_regulator_ops,
1688 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001689 .id = AB8540_LDO_AUDIO,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001690 .owner = THIS_MODULE,
1691 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001692 .volt_table = fixed_2000000_voltage,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001693 },
1694 .update_bank = 0x03,
1695 .update_reg = 0x83,
1696 .update_mask = 0x02,
1697 .update_val = 0x02,
1698 },
1699 [AB8540_LDO_ANAMIC1] = {
1700 .desc = {
1701 .name = "LDO-ANAMIC1",
Lee Jones4c84b4d2013-04-02 13:24:13 +01001702 .ops = &ab8500_regulator_anamic_mode_ops,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001703 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001704 .id = AB8540_LDO_ANAMIC1,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001705 .owner = THIS_MODULE,
1706 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001707 .volt_table = fixed_2050000_voltage,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001708 },
Lee Jones4c84b4d2013-04-02 13:24:13 +01001709 .shared_mode = &ab8540_ldo_anamic1_shared,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001710 .update_bank = 0x03,
1711 .update_reg = 0x83,
1712 .update_mask = 0x08,
1713 .update_val = 0x08,
Lee Jones4c84b4d2013-04-02 13:24:13 +01001714 .mode_bank = 0x03,
1715 .mode_reg = 0x83,
1716 .mode_mask = 0x20,
1717 .mode_val_idle = 0x20,
1718 .mode_val_normal = 0x00,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001719 },
1720 [AB8540_LDO_ANAMIC2] = {
1721 .desc = {
1722 .name = "LDO-ANAMIC2",
Lee Jones4c84b4d2013-04-02 13:24:13 +01001723 .ops = &ab8500_regulator_anamic_mode_ops,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001724 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001725 .id = AB8540_LDO_ANAMIC2,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001726 .owner = THIS_MODULE,
1727 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001728 .volt_table = fixed_2050000_voltage,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001729 },
Lee Jones4c84b4d2013-04-02 13:24:13 +01001730 .shared_mode = &ab8540_ldo_anamic2_shared,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001731 .update_bank = 0x03,
1732 .update_reg = 0x83,
1733 .update_mask = 0x10,
1734 .update_val = 0x10,
Lee Jones4c84b4d2013-04-02 13:24:13 +01001735 .mode_bank = 0x03,
1736 .mode_reg = 0x83,
1737 .mode_mask = 0x20,
1738 .mode_val_idle = 0x20,
1739 .mode_val_normal = 0x00,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001740 },
1741 [AB8540_LDO_DMIC] = {
1742 .desc = {
1743 .name = "LDO-DMIC",
Lee Jones4c84b4d2013-04-02 13:24:13 +01001744 .ops = &ab8500_regulator_volt_mode_ops,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001745 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001746 .id = AB8540_LDO_DMIC,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001747 .owner = THIS_MODULE,
Lee Jones4c84b4d2013-04-02 13:24:13 +01001748 .n_voltages = ARRAY_SIZE(ldo_vdmic_voltages),
Lee Jonesae0a9a32013-03-28 16:11:16 +00001749 },
Lee Jones4c84b4d2013-04-02 13:24:13 +01001750 .load_lp_uA = 1000,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001751 .update_bank = 0x03,
1752 .update_reg = 0x83,
1753 .update_mask = 0x04,
1754 .update_val = 0x04,
Lee Jones4c84b4d2013-04-02 13:24:13 +01001755 .voltage_bank = 0x03,
1756 .voltage_reg = 0x83,
1757 .voltage_mask = 0xc0,
1758 .voltages = ldo_vdmic_voltages,
1759 .voltages_len = ARRAY_SIZE(ldo_vdmic_voltages),
Lee Jonesae0a9a32013-03-28 16:11:16 +00001760 },
1761
1762 /*
1763 * Regulators with fixed voltage and normal/idle modes
1764 */
1765 [AB8540_LDO_ANA] = {
1766 .desc = {
1767 .name = "LDO-ANA",
1768 .ops = &ab8500_regulator_mode_ops,
1769 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001770 .id = AB8540_LDO_ANA,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001771 .owner = THIS_MODULE,
1772 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001773 .volt_table = fixed_1200000_voltage,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001774 },
1775 .load_lp_uA = 1000,
1776 .update_bank = 0x04,
1777 .update_reg = 0x06,
1778 .update_mask = 0x0c,
1779 .update_val = 0x04,
1780 .update_val_idle = 0x0c,
1781 .update_val_normal = 0x04,
1782 },
1783 [AB8540_LDO_SDIO] = {
1784 .desc = {
1785 .name = "LDO-SDIO",
1786 .ops = &ab8500_regulator_volt_mode_ops,
1787 .type = REGULATOR_VOLTAGE,
1788 .id = AB8540_LDO_SDIO,
1789 .owner = THIS_MODULE,
Lee Jones62ab4112013-03-28 16:11:18 +00001790 .n_voltages = ARRAY_SIZE(ldo_sdio_voltages),
1791 .volt_table = ldo_sdio_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001792 },
Lee Jonesae0a9a32013-03-28 16:11:16 +00001793 .load_lp_uA = 5000,
1794 .update_bank = 0x03,
1795 .update_reg = 0x88,
1796 .update_mask = 0x30,
1797 .update_val = 0x10,
1798 .update_val_idle = 0x30,
1799 .update_val_normal = 0x10,
1800 .voltage_bank = 0x03,
1801 .voltage_reg = 0x88,
1802 .voltage_mask = 0x07,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001803 },
1804};
1805
Lee Jones3fe52282013-04-02 13:24:12 +01001806static struct ab8500_shared_mode ldo_anamic1_shared = {
1807 .shared_regulator = &ab8505_regulator_info[AB8505_LDO_ANAMIC2],
1808};
1809
1810static struct ab8500_shared_mode ldo_anamic2_shared = {
1811 .shared_regulator = &ab8505_regulator_info[AB8505_LDO_ANAMIC1],
1812};
1813
Lee Jones4c84b4d2013-04-02 13:24:13 +01001814static struct ab8500_shared_mode ab8540_ldo_anamic1_shared = {
1815 .shared_regulator = &ab8540_regulator_info[AB8540_LDO_ANAMIC2],
1816};
1817
1818static struct ab8500_shared_mode ab8540_ldo_anamic2_shared = {
1819 .shared_regulator = &ab8540_regulator_info[AB8540_LDO_ANAMIC1],
1820};
1821
Bengt Jonsson79568b942011-03-11 11:54:46 +01001822struct ab8500_reg_init {
1823 u8 bank;
1824 u8 addr;
1825 u8 mask;
1826};
1827
1828#define REG_INIT(_id, _bank, _addr, _mask) \
1829 [_id] = { \
1830 .bank = _bank, \
1831 .addr = _addr, \
1832 .mask = _mask, \
1833 }
1834
Lee Jones8e6a8d72013-03-28 16:11:11 +00001835/* AB8500 register init */
Bengt Jonsson79568b942011-03-11 11:54:46 +01001836static struct ab8500_reg_init ab8500_reg_init[] = {
1837 /*
Lee Jones33bc8f42013-03-21 15:59:02 +00001838 * 0x30, VanaRequestCtrl
Bengt Jonsson79568b942011-03-11 11:54:46 +01001839 * 0xc0, VextSupply1RequestCtrl
1840 */
Lee Jones43a59112013-03-21 15:59:15 +00001841 REG_INIT(AB8500_REGUREQUESTCTRL2, 0x03, 0x04, 0xf0),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001842 /*
1843 * 0x03, VextSupply2RequestCtrl
1844 * 0x0c, VextSupply3RequestCtrl
1845 * 0x30, Vaux1RequestCtrl
1846 * 0xc0, Vaux2RequestCtrl
1847 */
1848 REG_INIT(AB8500_REGUREQUESTCTRL3, 0x03, 0x05, 0xff),
1849 /*
1850 * 0x03, Vaux3RequestCtrl
1851 * 0x04, SwHPReq
1852 */
1853 REG_INIT(AB8500_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
1854 /*
1855 * 0x08, VanaSysClkReq1HPValid
1856 * 0x20, Vaux1SysClkReq1HPValid
1857 * 0x40, Vaux2SysClkReq1HPValid
1858 * 0x80, Vaux3SysClkReq1HPValid
1859 */
Lee Jones43a59112013-03-21 15:59:15 +00001860 REG_INIT(AB8500_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xe8),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001861 /*
1862 * 0x10, VextSupply1SysClkReq1HPValid
1863 * 0x20, VextSupply2SysClkReq1HPValid
1864 * 0x40, VextSupply3SysClkReq1HPValid
1865 */
Lee Jones43a59112013-03-21 15:59:15 +00001866 REG_INIT(AB8500_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x70),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001867 /*
1868 * 0x08, VanaHwHPReq1Valid
1869 * 0x20, Vaux1HwHPReq1Valid
1870 * 0x40, Vaux2HwHPReq1Valid
1871 * 0x80, Vaux3HwHPReq1Valid
1872 */
Lee Jones43a59112013-03-21 15:59:15 +00001873 REG_INIT(AB8500_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xe8),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001874 /*
1875 * 0x01, VextSupply1HwHPReq1Valid
1876 * 0x02, VextSupply2HwHPReq1Valid
1877 * 0x04, VextSupply3HwHPReq1Valid
1878 */
Lee Jones43a59112013-03-21 15:59:15 +00001879 REG_INIT(AB8500_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x07),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001880 /*
1881 * 0x08, VanaHwHPReq2Valid
1882 * 0x20, Vaux1HwHPReq2Valid
1883 * 0x40, Vaux2HwHPReq2Valid
1884 * 0x80, Vaux3HwHPReq2Valid
1885 */
Lee Jones43a59112013-03-21 15:59:15 +00001886 REG_INIT(AB8500_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xe8),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001887 /*
1888 * 0x01, VextSupply1HwHPReq2Valid
1889 * 0x02, VextSupply2HwHPReq2Valid
1890 * 0x04, VextSupply3HwHPReq2Valid
1891 */
Lee Jones43a59112013-03-21 15:59:15 +00001892 REG_INIT(AB8500_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x07),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001893 /*
1894 * 0x20, VanaSwHPReqValid
1895 * 0x80, Vaux1SwHPReqValid
1896 */
Lee Jones43a59112013-03-21 15:59:15 +00001897 REG_INIT(AB8500_REGUSWHPREQVALID1, 0x03, 0x0d, 0xa0),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001898 /*
1899 * 0x01, Vaux2SwHPReqValid
1900 * 0x02, Vaux3SwHPReqValid
1901 * 0x04, VextSupply1SwHPReqValid
1902 * 0x08, VextSupply2SwHPReqValid
1903 * 0x10, VextSupply3SwHPReqValid
1904 */
Lee Jones43a59112013-03-21 15:59:15 +00001905 REG_INIT(AB8500_REGUSWHPREQVALID2, 0x03, 0x0e, 0x1f),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001906 /*
1907 * 0x02, SysClkReq2Valid1
Lee Jones43a59112013-03-21 15:59:15 +00001908 * 0x04, SysClkReq3Valid1
1909 * 0x08, SysClkReq4Valid1
1910 * 0x10, SysClkReq5Valid1
1911 * 0x20, SysClkReq6Valid1
1912 * 0x40, SysClkReq7Valid1
Bengt Jonsson79568b942011-03-11 11:54:46 +01001913 * 0x80, SysClkReq8Valid1
1914 */
1915 REG_INIT(AB8500_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0xfe),
1916 /*
1917 * 0x02, SysClkReq2Valid2
Lee Jones43a59112013-03-21 15:59:15 +00001918 * 0x04, SysClkReq3Valid2
1919 * 0x08, SysClkReq4Valid2
1920 * 0x10, SysClkReq5Valid2
1921 * 0x20, SysClkReq6Valid2
1922 * 0x40, SysClkReq7Valid2
Bengt Jonsson79568b942011-03-11 11:54:46 +01001923 * 0x80, SysClkReq8Valid2
1924 */
1925 REG_INIT(AB8500_REGUSYSCLKREQVALID2, 0x03, 0x10, 0xfe),
1926 /*
1927 * 0x02, VTVoutEna
1928 * 0x04, Vintcore12Ena
1929 * 0x38, Vintcore12Sel
1930 * 0x40, Vintcore12LP
1931 * 0x80, VTVoutLP
1932 */
1933 REG_INIT(AB8500_REGUMISC1, 0x03, 0x80, 0xfe),
1934 /*
1935 * 0x02, VaudioEna
1936 * 0x04, VdmicEna
1937 * 0x08, Vamic1Ena
1938 * 0x10, Vamic2Ena
1939 */
1940 REG_INIT(AB8500_VAUDIOSUPPLY, 0x03, 0x83, 0x1e),
1941 /*
1942 * 0x01, Vamic1_dzout
1943 * 0x02, Vamic2_dzout
1944 */
1945 REG_INIT(AB8500_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
1946 /*
Lee Jones43a59112013-03-21 15:59:15 +00001947 * 0x03, VpllRegu (NOTE! PRCMU register bits)
Lee Jones33bc8f42013-03-21 15:59:02 +00001948 * 0x0c, VanaRegu
Bengt Jonsson79568b942011-03-11 11:54:46 +01001949 */
1950 REG_INIT(AB8500_VPLLVANAREGU, 0x04, 0x06, 0x0f),
1951 /*
1952 * 0x01, VrefDDREna
1953 * 0x02, VrefDDRSleepMode
1954 */
1955 REG_INIT(AB8500_VREFDDR, 0x04, 0x07, 0x03),
1956 /*
1957 * 0x03, VextSupply1Regu
1958 * 0x0c, VextSupply2Regu
1959 * 0x30, VextSupply3Regu
1960 * 0x40, ExtSupply2Bypass
1961 * 0x80, ExtSupply3Bypass
1962 */
1963 REG_INIT(AB8500_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
1964 /*
1965 * 0x03, Vaux1Regu
1966 * 0x0c, Vaux2Regu
1967 */
1968 REG_INIT(AB8500_VAUX12REGU, 0x04, 0x09, 0x0f),
1969 /*
1970 * 0x03, Vaux3Regu
1971 */
Lee Jones43a59112013-03-21 15:59:15 +00001972 REG_INIT(AB8500_VRF1VAUX3REGU, 0x04, 0x0a, 0x03),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001973 /*
1974 * 0x0f, Vaux1Sel
1975 */
1976 REG_INIT(AB8500_VAUX1SEL, 0x04, 0x1f, 0x0f),
1977 /*
1978 * 0x0f, Vaux2Sel
1979 */
1980 REG_INIT(AB8500_VAUX2SEL, 0x04, 0x20, 0x0f),
1981 /*
1982 * 0x07, Vaux3Sel
1983 */
Lee Jones43a59112013-03-21 15:59:15 +00001984 REG_INIT(AB8500_VRF1VAUX3SEL, 0x04, 0x21, 0x07),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001985 /*
1986 * 0x01, VextSupply12LP
1987 */
1988 REG_INIT(AB8500_REGUCTRL2SPARE, 0x04, 0x22, 0x01),
1989 /*
1990 * 0x04, Vaux1Disch
1991 * 0x08, Vaux2Disch
1992 * 0x10, Vaux3Disch
1993 * 0x20, Vintcore12Disch
1994 * 0x40, VTVoutDisch
1995 * 0x80, VaudioDisch
1996 */
Lee Jones43a59112013-03-21 15:59:15 +00001997 REG_INIT(AB8500_REGUCTRLDISCH, 0x04, 0x43, 0xfc),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001998 /*
1999 * 0x02, VanaDisch
2000 * 0x04, VdmicPullDownEna
2001 * 0x10, VdmicDisch
2002 */
Lee Jones43a59112013-03-21 15:59:15 +00002003 REG_INIT(AB8500_REGUCTRLDISCH2, 0x04, 0x44, 0x16),
Bengt Jonsson79568b942011-03-11 11:54:46 +01002004};
2005
Lee Jones547f3842013-03-28 16:11:14 +00002006/* AB8505 register init */
2007static struct ab8500_reg_init ab8505_reg_init[] = {
2008 /*
2009 * 0x03, VarmRequestCtrl
2010 * 0x0c, VsmpsCRequestCtrl
2011 * 0x30, VsmpsARequestCtrl
2012 * 0xc0, VsmpsBRequestCtrl
2013 */
2014 REG_INIT(AB8505_REGUREQUESTCTRL1, 0x03, 0x03, 0xff),
2015 /*
2016 * 0x03, VsafeRequestCtrl
2017 * 0x0c, VpllRequestCtrl
2018 * 0x30, VanaRequestCtrl
2019 */
2020 REG_INIT(AB8505_REGUREQUESTCTRL2, 0x03, 0x04, 0x3f),
2021 /*
2022 * 0x30, Vaux1RequestCtrl
2023 * 0xc0, Vaux2RequestCtrl
2024 */
2025 REG_INIT(AB8505_REGUREQUESTCTRL3, 0x03, 0x05, 0xf0),
2026 /*
2027 * 0x03, Vaux3RequestCtrl
2028 * 0x04, SwHPReq
2029 */
2030 REG_INIT(AB8505_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
2031 /*
2032 * 0x01, VsmpsASysClkReq1HPValid
2033 * 0x02, VsmpsBSysClkReq1HPValid
2034 * 0x04, VsafeSysClkReq1HPValid
2035 * 0x08, VanaSysClkReq1HPValid
2036 * 0x10, VpllSysClkReq1HPValid
2037 * 0x20, Vaux1SysClkReq1HPValid
2038 * 0x40, Vaux2SysClkReq1HPValid
2039 * 0x80, Vaux3SysClkReq1HPValid
2040 */
2041 REG_INIT(AB8505_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xff),
2042 /*
2043 * 0x01, VsmpsCSysClkReq1HPValid
2044 * 0x02, VarmSysClkReq1HPValid
2045 * 0x04, VbbSysClkReq1HPValid
2046 * 0x08, VsmpsMSysClkReq1HPValid
2047 */
2048 REG_INIT(AB8505_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x0f),
2049 /*
2050 * 0x01, VsmpsAHwHPReq1Valid
2051 * 0x02, VsmpsBHwHPReq1Valid
2052 * 0x04, VsafeHwHPReq1Valid
2053 * 0x08, VanaHwHPReq1Valid
2054 * 0x10, VpllHwHPReq1Valid
2055 * 0x20, Vaux1HwHPReq1Valid
2056 * 0x40, Vaux2HwHPReq1Valid
2057 * 0x80, Vaux3HwHPReq1Valid
2058 */
2059 REG_INIT(AB8505_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xff),
2060 /*
2061 * 0x08, VsmpsMHwHPReq1Valid
2062 */
2063 REG_INIT(AB8505_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x08),
2064 /*
2065 * 0x01, VsmpsAHwHPReq2Valid
2066 * 0x02, VsmpsBHwHPReq2Valid
2067 * 0x04, VsafeHwHPReq2Valid
2068 * 0x08, VanaHwHPReq2Valid
2069 * 0x10, VpllHwHPReq2Valid
2070 * 0x20, Vaux1HwHPReq2Valid
2071 * 0x40, Vaux2HwHPReq2Valid
2072 * 0x80, Vaux3HwHPReq2Valid
2073 */
2074 REG_INIT(AB8505_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xff),
2075 /*
2076 * 0x08, VsmpsMHwHPReq2Valid
2077 */
2078 REG_INIT(AB8505_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x08),
2079 /*
2080 * 0x01, VsmpsCSwHPReqValid
2081 * 0x02, VarmSwHPReqValid
2082 * 0x04, VsmpsASwHPReqValid
2083 * 0x08, VsmpsBSwHPReqValid
2084 * 0x10, VsafeSwHPReqValid
2085 * 0x20, VanaSwHPReqValid
2086 * 0x40, VpllSwHPReqValid
2087 * 0x80, Vaux1SwHPReqValid
2088 */
2089 REG_INIT(AB8505_REGUSWHPREQVALID1, 0x03, 0x0d, 0xff),
2090 /*
2091 * 0x01, Vaux2SwHPReqValid
2092 * 0x02, Vaux3SwHPReqValid
2093 * 0x20, VsmpsMSwHPReqValid
2094 */
2095 REG_INIT(AB8505_REGUSWHPREQVALID2, 0x03, 0x0e, 0x23),
2096 /*
2097 * 0x02, SysClkReq2Valid1
2098 * 0x04, SysClkReq3Valid1
2099 * 0x08, SysClkReq4Valid1
2100 */
2101 REG_INIT(AB8505_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0x0e),
2102 /*
2103 * 0x02, SysClkReq2Valid2
2104 * 0x04, SysClkReq3Valid2
2105 * 0x08, SysClkReq4Valid2
2106 */
2107 REG_INIT(AB8505_REGUSYSCLKREQVALID2, 0x03, 0x10, 0x0e),
2108 /*
2109 * 0x01, Vaux4SwHPReqValid
2110 * 0x02, Vaux4HwHPReq2Valid
2111 * 0x04, Vaux4HwHPReq1Valid
2112 * 0x08, Vaux4SysClkReq1HPValid
2113 */
2114 REG_INIT(AB8505_REGUVAUX4REQVALID, 0x03, 0x11, 0x0f),
2115 /*
2116 * 0x02, VadcEna
2117 * 0x04, VintCore12Ena
2118 * 0x38, VintCore12Sel
2119 * 0x40, VintCore12LP
2120 * 0x80, VadcLP
2121 */
2122 REG_INIT(AB8505_REGUMISC1, 0x03, 0x80, 0xfe),
2123 /*
2124 * 0x02, VaudioEna
2125 * 0x04, VdmicEna
2126 * 0x08, Vamic1Ena
2127 * 0x10, Vamic2Ena
2128 */
2129 REG_INIT(AB8505_VAUDIOSUPPLY, 0x03, 0x83, 0x1e),
2130 /*
2131 * 0x01, Vamic1_dzout
2132 * 0x02, Vamic2_dzout
2133 */
2134 REG_INIT(AB8505_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
2135 /*
2136 * 0x03, VsmpsARegu
2137 * 0x0c, VsmpsASelCtrl
2138 * 0x10, VsmpsAAutoMode
2139 * 0x20, VsmpsAPWMMode
2140 */
2141 REG_INIT(AB8505_VSMPSAREGU, 0x04, 0x03, 0x3f),
2142 /*
2143 * 0x03, VsmpsBRegu
2144 * 0x0c, VsmpsBSelCtrl
2145 * 0x10, VsmpsBAutoMode
2146 * 0x20, VsmpsBPWMMode
2147 */
2148 REG_INIT(AB8505_VSMPSBREGU, 0x04, 0x04, 0x3f),
2149 /*
2150 * 0x03, VsafeRegu
2151 * 0x0c, VsafeSelCtrl
2152 * 0x10, VsafeAutoMode
2153 * 0x20, VsafePWMMode
2154 */
2155 REG_INIT(AB8505_VSAFEREGU, 0x04, 0x05, 0x3f),
2156 /*
2157 * 0x03, VpllRegu (NOTE! PRCMU register bits)
2158 * 0x0c, VanaRegu
2159 */
2160 REG_INIT(AB8505_VPLLVANAREGU, 0x04, 0x06, 0x0f),
2161 /*
2162 * 0x03, VextSupply1Regu
2163 * 0x0c, VextSupply2Regu
2164 * 0x30, VextSupply3Regu
2165 * 0x40, ExtSupply2Bypass
2166 * 0x80, ExtSupply3Bypass
2167 */
2168 REG_INIT(AB8505_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
2169 /*
2170 * 0x03, Vaux1Regu
2171 * 0x0c, Vaux2Regu
2172 */
2173 REG_INIT(AB8505_VAUX12REGU, 0x04, 0x09, 0x0f),
2174 /*
2175 * 0x0f, Vaux3Regu
2176 */
2177 REG_INIT(AB8505_VRF1VAUX3REGU, 0x04, 0x0a, 0x0f),
2178 /*
2179 * 0x3f, VsmpsASel1
2180 */
2181 REG_INIT(AB8505_VSMPSASEL1, 0x04, 0x13, 0x3f),
2182 /*
2183 * 0x3f, VsmpsASel2
2184 */
2185 REG_INIT(AB8505_VSMPSASEL2, 0x04, 0x14, 0x3f),
2186 /*
2187 * 0x3f, VsmpsASel3
2188 */
2189 REG_INIT(AB8505_VSMPSASEL3, 0x04, 0x15, 0x3f),
2190 /*
2191 * 0x3f, VsmpsBSel1
2192 */
2193 REG_INIT(AB8505_VSMPSBSEL1, 0x04, 0x17, 0x3f),
2194 /*
2195 * 0x3f, VsmpsBSel2
2196 */
2197 REG_INIT(AB8505_VSMPSBSEL2, 0x04, 0x18, 0x3f),
2198 /*
2199 * 0x3f, VsmpsBSel3
2200 */
2201 REG_INIT(AB8505_VSMPSBSEL3, 0x04, 0x19, 0x3f),
2202 /*
2203 * 0x7f, VsafeSel1
2204 */
2205 REG_INIT(AB8505_VSAFESEL1, 0x04, 0x1b, 0x7f),
2206 /*
2207 * 0x3f, VsafeSel2
2208 */
2209 REG_INIT(AB8505_VSAFESEL2, 0x04, 0x1c, 0x7f),
2210 /*
2211 * 0x3f, VsafeSel3
2212 */
2213 REG_INIT(AB8505_VSAFESEL3, 0x04, 0x1d, 0x7f),
2214 /*
2215 * 0x0f, Vaux1Sel
2216 */
2217 REG_INIT(AB8505_VAUX1SEL, 0x04, 0x1f, 0x0f),
2218 /*
2219 * 0x0f, Vaux2Sel
2220 */
2221 REG_INIT(AB8505_VAUX2SEL, 0x04, 0x20, 0x0f),
2222 /*
2223 * 0x07, Vaux3Sel
2224 * 0x30, VRF1Sel
2225 */
2226 REG_INIT(AB8505_VRF1VAUX3SEL, 0x04, 0x21, 0x37),
2227 /*
2228 * 0x03, Vaux4RequestCtrl
2229 */
2230 REG_INIT(AB8505_VAUX4REQCTRL, 0x04, 0x2d, 0x03),
2231 /*
2232 * 0x03, Vaux4Regu
2233 */
2234 REG_INIT(AB8505_VAUX4REGU, 0x04, 0x2e, 0x03),
2235 /*
2236 * 0x0f, Vaux4Sel
2237 */
2238 REG_INIT(AB8505_VAUX4SEL, 0x04, 0x2f, 0x0f),
2239 /*
2240 * 0x04, Vaux1Disch
2241 * 0x08, Vaux2Disch
2242 * 0x10, Vaux3Disch
2243 * 0x20, Vintcore12Disch
2244 * 0x40, VTVoutDisch
2245 * 0x80, VaudioDisch
2246 */
2247 REG_INIT(AB8505_REGUCTRLDISCH, 0x04, 0x43, 0xfc),
2248 /*
2249 * 0x02, VanaDisch
2250 * 0x04, VdmicPullDownEna
2251 * 0x10, VdmicDisch
2252 */
2253 REG_INIT(AB8505_REGUCTRLDISCH2, 0x04, 0x44, 0x16),
2254 /*
2255 * 0x01, Vaux4Disch
2256 */
2257 REG_INIT(AB8505_REGUCTRLDISCH3, 0x04, 0x48, 0x01),
2258 /*
2259 * 0x07, Vaux5Sel
2260 * 0x08, Vaux5LP
2261 * 0x10, Vaux5Ena
2262 * 0x20, Vaux5Disch
2263 * 0x40, Vaux5DisSfst
2264 * 0x80, Vaux5DisPulld
2265 */
2266 REG_INIT(AB8505_CTRLVAUX5, 0x01, 0x55, 0xff),
2267 /*
2268 * 0x07, Vaux6Sel
2269 * 0x08, Vaux6LP
2270 * 0x10, Vaux6Ena
2271 * 0x80, Vaux6DisPulld
2272 */
2273 REG_INIT(AB8505_CTRLVAUX6, 0x01, 0x56, 0x9f),
2274};
2275
Lee Jones8e6a8d72013-03-28 16:11:11 +00002276/* AB9540 register init */
2277static struct ab8500_reg_init ab9540_reg_init[] = {
2278 /*
2279 * 0x03, VarmRequestCtrl
2280 * 0x0c, VapeRequestCtrl
2281 * 0x30, Vsmps1RequestCtrl
2282 * 0xc0, Vsmps2RequestCtrl
2283 */
2284 REG_INIT(AB9540_REGUREQUESTCTRL1, 0x03, 0x03, 0xff),
2285 /*
2286 * 0x03, Vsmps3RequestCtrl
2287 * 0x0c, VpllRequestCtrl
2288 * 0x30, VanaRequestCtrl
2289 * 0xc0, VextSupply1RequestCtrl
2290 */
2291 REG_INIT(AB9540_REGUREQUESTCTRL2, 0x03, 0x04, 0xff),
2292 /*
2293 * 0x03, VextSupply2RequestCtrl
2294 * 0x0c, VextSupply3RequestCtrl
2295 * 0x30, Vaux1RequestCtrl
2296 * 0xc0, Vaux2RequestCtrl
2297 */
2298 REG_INIT(AB9540_REGUREQUESTCTRL3, 0x03, 0x05, 0xff),
2299 /*
2300 * 0x03, Vaux3RequestCtrl
2301 * 0x04, SwHPReq
2302 */
2303 REG_INIT(AB9540_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
2304 /*
2305 * 0x01, Vsmps1SysClkReq1HPValid
2306 * 0x02, Vsmps2SysClkReq1HPValid
2307 * 0x04, Vsmps3SysClkReq1HPValid
2308 * 0x08, VanaSysClkReq1HPValid
2309 * 0x10, VpllSysClkReq1HPValid
2310 * 0x20, Vaux1SysClkReq1HPValid
2311 * 0x40, Vaux2SysClkReq1HPValid
2312 * 0x80, Vaux3SysClkReq1HPValid
2313 */
2314 REG_INIT(AB9540_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xff),
2315 /*
2316 * 0x01, VapeSysClkReq1HPValid
2317 * 0x02, VarmSysClkReq1HPValid
2318 * 0x04, VbbSysClkReq1HPValid
2319 * 0x08, VmodSysClkReq1HPValid
2320 * 0x10, VextSupply1SysClkReq1HPValid
2321 * 0x20, VextSupply2SysClkReq1HPValid
2322 * 0x40, VextSupply3SysClkReq1HPValid
2323 */
2324 REG_INIT(AB9540_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x7f),
2325 /*
2326 * 0x01, Vsmps1HwHPReq1Valid
2327 * 0x02, Vsmps2HwHPReq1Valid
2328 * 0x04, Vsmps3HwHPReq1Valid
2329 * 0x08, VanaHwHPReq1Valid
2330 * 0x10, VpllHwHPReq1Valid
2331 * 0x20, Vaux1HwHPReq1Valid
2332 * 0x40, Vaux2HwHPReq1Valid
2333 * 0x80, Vaux3HwHPReq1Valid
2334 */
2335 REG_INIT(AB9540_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xff),
2336 /*
2337 * 0x01, VextSupply1HwHPReq1Valid
2338 * 0x02, VextSupply2HwHPReq1Valid
2339 * 0x04, VextSupply3HwHPReq1Valid
2340 * 0x08, VmodHwHPReq1Valid
2341 */
2342 REG_INIT(AB9540_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x0f),
2343 /*
2344 * 0x01, Vsmps1HwHPReq2Valid
2345 * 0x02, Vsmps2HwHPReq2Valid
2346 * 0x03, Vsmps3HwHPReq2Valid
2347 * 0x08, VanaHwHPReq2Valid
2348 * 0x10, VpllHwHPReq2Valid
2349 * 0x20, Vaux1HwHPReq2Valid
2350 * 0x40, Vaux2HwHPReq2Valid
2351 * 0x80, Vaux3HwHPReq2Valid
2352 */
2353 REG_INIT(AB9540_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xff),
2354 /*
2355 * 0x01, VextSupply1HwHPReq2Valid
2356 * 0x02, VextSupply2HwHPReq2Valid
2357 * 0x04, VextSupply3HwHPReq2Valid
2358 * 0x08, VmodHwHPReq2Valid
2359 */
2360 REG_INIT(AB9540_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x0f),
2361 /*
2362 * 0x01, VapeSwHPReqValid
2363 * 0x02, VarmSwHPReqValid
2364 * 0x04, Vsmps1SwHPReqValid
2365 * 0x08, Vsmps2SwHPReqValid
2366 * 0x10, Vsmps3SwHPReqValid
2367 * 0x20, VanaSwHPReqValid
2368 * 0x40, VpllSwHPReqValid
2369 * 0x80, Vaux1SwHPReqValid
2370 */
2371 REG_INIT(AB9540_REGUSWHPREQVALID1, 0x03, 0x0d, 0xff),
2372 /*
2373 * 0x01, Vaux2SwHPReqValid
2374 * 0x02, Vaux3SwHPReqValid
2375 * 0x04, VextSupply1SwHPReqValid
2376 * 0x08, VextSupply2SwHPReqValid
2377 * 0x10, VextSupply3SwHPReqValid
2378 * 0x20, VmodSwHPReqValid
2379 */
2380 REG_INIT(AB9540_REGUSWHPREQVALID2, 0x03, 0x0e, 0x3f),
2381 /*
2382 * 0x02, SysClkReq2Valid1
2383 * ...
2384 * 0x80, SysClkReq8Valid1
2385 */
2386 REG_INIT(AB9540_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0xfe),
2387 /*
2388 * 0x02, SysClkReq2Valid2
2389 * ...
2390 * 0x80, SysClkReq8Valid2
2391 */
2392 REG_INIT(AB9540_REGUSYSCLKREQVALID2, 0x03, 0x10, 0xfe),
2393 /*
2394 * 0x01, Vaux4SwHPReqValid
2395 * 0x02, Vaux4HwHPReq2Valid
2396 * 0x04, Vaux4HwHPReq1Valid
2397 * 0x08, Vaux4SysClkReq1HPValid
2398 */
2399 REG_INIT(AB9540_REGUVAUX4REQVALID, 0x03, 0x11, 0x0f),
2400 /*
2401 * 0x02, VTVoutEna
2402 * 0x04, Vintcore12Ena
2403 * 0x38, Vintcore12Sel
2404 * 0x40, Vintcore12LP
2405 * 0x80, VTVoutLP
2406 */
2407 REG_INIT(AB9540_REGUMISC1, 0x03, 0x80, 0xfe),
2408 /*
2409 * 0x02, VaudioEna
2410 * 0x04, VdmicEna
2411 * 0x08, Vamic1Ena
2412 * 0x10, Vamic2Ena
2413 */
2414 REG_INIT(AB9540_VAUDIOSUPPLY, 0x03, 0x83, 0x1e),
2415 /*
2416 * 0x01, Vamic1_dzout
2417 * 0x02, Vamic2_dzout
2418 */
2419 REG_INIT(AB9540_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
2420 /*
2421 * 0x03, Vsmps1Regu
2422 * 0x0c, Vsmps1SelCtrl
2423 * 0x10, Vsmps1AutoMode
2424 * 0x20, Vsmps1PWMMode
2425 */
2426 REG_INIT(AB9540_VSMPS1REGU, 0x04, 0x03, 0x3f),
2427 /*
2428 * 0x03, Vsmps2Regu
2429 * 0x0c, Vsmps2SelCtrl
2430 * 0x10, Vsmps2AutoMode
2431 * 0x20, Vsmps2PWMMode
2432 */
2433 REG_INIT(AB9540_VSMPS2REGU, 0x04, 0x04, 0x3f),
2434 /*
2435 * 0x03, Vsmps3Regu
2436 * 0x0c, Vsmps3SelCtrl
2437 * NOTE! PRCMU register
2438 */
2439 REG_INIT(AB9540_VSMPS3REGU, 0x04, 0x05, 0x0f),
2440 /*
2441 * 0x03, VpllRegu
2442 * 0x0c, VanaRegu
2443 */
2444 REG_INIT(AB9540_VPLLVANAREGU, 0x04, 0x06, 0x0f),
2445 /*
2446 * 0x03, VextSupply1Regu
2447 * 0x0c, VextSupply2Regu
2448 * 0x30, VextSupply3Regu
2449 * 0x40, ExtSupply2Bypass
2450 * 0x80, ExtSupply3Bypass
2451 */
2452 REG_INIT(AB9540_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
2453 /*
2454 * 0x03, Vaux1Regu
2455 * 0x0c, Vaux2Regu
2456 */
2457 REG_INIT(AB9540_VAUX12REGU, 0x04, 0x09, 0x0f),
2458 /*
2459 * 0x0c, Vrf1Regu
2460 * 0x03, Vaux3Regu
2461 */
2462 REG_INIT(AB9540_VRF1VAUX3REGU, 0x04, 0x0a, 0x0f),
2463 /*
2464 * 0x3f, Vsmps1Sel1
2465 */
2466 REG_INIT(AB9540_VSMPS1SEL1, 0x04, 0x13, 0x3f),
2467 /*
2468 * 0x3f, Vsmps1Sel2
2469 */
2470 REG_INIT(AB9540_VSMPS1SEL2, 0x04, 0x14, 0x3f),
2471 /*
2472 * 0x3f, Vsmps1Sel3
2473 */
2474 REG_INIT(AB9540_VSMPS1SEL3, 0x04, 0x15, 0x3f),
2475 /*
2476 * 0x3f, Vsmps2Sel1
2477 */
2478 REG_INIT(AB9540_VSMPS2SEL1, 0x04, 0x17, 0x3f),
2479 /*
2480 * 0x3f, Vsmps2Sel2
2481 */
2482 REG_INIT(AB9540_VSMPS2SEL2, 0x04, 0x18, 0x3f),
2483 /*
2484 * 0x3f, Vsmps2Sel3
2485 */
2486 REG_INIT(AB9540_VSMPS2SEL3, 0x04, 0x19, 0x3f),
2487 /*
2488 * 0x7f, Vsmps3Sel1
2489 * NOTE! PRCMU register
2490 */
2491 REG_INIT(AB9540_VSMPS3SEL1, 0x04, 0x1b, 0x7f),
2492 /*
2493 * 0x7f, Vsmps3Sel2
2494 * NOTE! PRCMU register
2495 */
2496 REG_INIT(AB9540_VSMPS3SEL2, 0x04, 0x1c, 0x7f),
2497 /*
2498 * 0x0f, Vaux1Sel
2499 */
2500 REG_INIT(AB9540_VAUX1SEL, 0x04, 0x1f, 0x0f),
2501 /*
2502 * 0x0f, Vaux2Sel
2503 */
2504 REG_INIT(AB9540_VAUX2SEL, 0x04, 0x20, 0x0f),
2505 /*
2506 * 0x07, Vaux3Sel
2507 * 0x30, Vrf1Sel
2508 */
2509 REG_INIT(AB9540_VRF1VAUX3SEL, 0x04, 0x21, 0x37),
2510 /*
2511 * 0x01, VextSupply12LP
2512 */
2513 REG_INIT(AB9540_REGUCTRL2SPARE, 0x04, 0x22, 0x01),
2514 /*
2515 * 0x03, Vaux4RequestCtrl
2516 */
2517 REG_INIT(AB9540_VAUX4REQCTRL, 0x04, 0x2d, 0x03),
2518 /*
2519 * 0x03, Vaux4Regu
2520 */
2521 REG_INIT(AB9540_VAUX4REGU, 0x04, 0x2e, 0x03),
2522 /*
2523 * 0x08, Vaux4Sel
2524 */
2525 REG_INIT(AB9540_VAUX4SEL, 0x04, 0x2f, 0x0f),
2526 /*
2527 * 0x01, VpllDisch
2528 * 0x02, Vrf1Disch
2529 * 0x04, Vaux1Disch
2530 * 0x08, Vaux2Disch
2531 * 0x10, Vaux3Disch
2532 * 0x20, Vintcore12Disch
2533 * 0x40, VTVoutDisch
2534 * 0x80, VaudioDisch
2535 */
2536 REG_INIT(AB9540_REGUCTRLDISCH, 0x04, 0x43, 0xff),
2537 /*
2538 * 0x01, VsimDisch
2539 * 0x02, VanaDisch
2540 * 0x04, VdmicPullDownEna
2541 * 0x08, VpllPullDownEna
2542 * 0x10, VdmicDisch
2543 */
2544 REG_INIT(AB9540_REGUCTRLDISCH2, 0x04, 0x44, 0x1f),
2545 /*
2546 * 0x01, Vaux4Disch
2547 */
2548 REG_INIT(AB9540_REGUCTRLDISCH3, 0x04, 0x48, 0x01),
2549};
2550
Lee Jonesae0a9a32013-03-28 16:11:16 +00002551/* AB8540 register init */
2552static struct ab8500_reg_init ab8540_reg_init[] = {
2553 /*
2554 * 0x01, VSimSycClkReq1Valid
2555 * 0x02, VSimSycClkReq2Valid
2556 * 0x04, VSimSycClkReq3Valid
2557 * 0x08, VSimSycClkReq4Valid
2558 * 0x10, VSimSycClkReq5Valid
2559 * 0x20, VSimSycClkReq6Valid
2560 * 0x40, VSimSycClkReq7Valid
2561 * 0x80, VSimSycClkReq8Valid
2562 */
2563 REG_INIT(AB8540_VSIMSYSCLKCTRL, 0x02, 0x33, 0xff),
2564 /*
2565 * 0x03, VarmRequestCtrl
2566 * 0x0c, VapeRequestCtrl
2567 * 0x30, Vsmps1RequestCtrl
2568 * 0xc0, Vsmps2RequestCtrl
2569 */
2570 REG_INIT(AB8540_REGUREQUESTCTRL1, 0x03, 0x03, 0xff),
2571 /*
2572 * 0x03, Vsmps3RequestCtrl
2573 * 0x0c, VpllRequestCtrl
2574 * 0x30, VanaRequestCtrl
2575 * 0xc0, VextSupply1RequestCtrl
2576 */
2577 REG_INIT(AB8540_REGUREQUESTCTRL2, 0x03, 0x04, 0xff),
2578 /*
2579 * 0x03, VextSupply2RequestCtrl
2580 * 0x0c, VextSupply3RequestCtrl
2581 * 0x30, Vaux1RequestCtrl
2582 * 0xc0, Vaux2RequestCtrl
2583 */
2584 REG_INIT(AB8540_REGUREQUESTCTRL3, 0x03, 0x05, 0xff),
2585 /*
2586 * 0x03, Vaux3RequestCtrl
2587 * 0x04, SwHPReq
2588 */
2589 REG_INIT(AB8540_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
2590 /*
2591 * 0x01, Vsmps1SysClkReq1HPValid
2592 * 0x02, Vsmps2SysClkReq1HPValid
2593 * 0x04, Vsmps3SysClkReq1HPValid
2594 * 0x08, VanaSysClkReq1HPValid
2595 * 0x10, VpllSysClkReq1HPValid
2596 * 0x20, Vaux1SysClkReq1HPValid
2597 * 0x40, Vaux2SysClkReq1HPValid
2598 * 0x80, Vaux3SysClkReq1HPValid
2599 */
2600 REG_INIT(AB8540_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xff),
2601 /*
2602 * 0x01, VapeSysClkReq1HPValid
2603 * 0x02, VarmSysClkReq1HPValid
2604 * 0x04, VbbSysClkReq1HPValid
2605 * 0x10, VextSupply1SysClkReq1HPValid
2606 * 0x20, VextSupply2SysClkReq1HPValid
2607 * 0x40, VextSupply3SysClkReq1HPValid
2608 */
2609 REG_INIT(AB8540_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x77),
2610 /*
2611 * 0x01, Vsmps1HwHPReq1Valid
2612 * 0x02, Vsmps2HwHPReq1Valid
2613 * 0x04, Vsmps3HwHPReq1Valid
2614 * 0x08, VanaHwHPReq1Valid
2615 * 0x10, VpllHwHPReq1Valid
2616 * 0x20, Vaux1HwHPReq1Valid
2617 * 0x40, Vaux2HwHPReq1Valid
2618 * 0x80, Vaux3HwHPReq1Valid
2619 */
2620 REG_INIT(AB8540_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xff),
2621 /*
2622 * 0x01, VextSupply1HwHPReq1Valid
2623 * 0x02, VextSupply2HwHPReq1Valid
2624 * 0x04, VextSupply3HwHPReq1Valid
2625 */
2626 REG_INIT(AB8540_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x07),
2627 /*
2628 * 0x01, Vsmps1HwHPReq2Valid
2629 * 0x02, Vsmps2HwHPReq2Valid
2630 * 0x03, Vsmps3HwHPReq2Valid
2631 * 0x08, VanaHwHPReq2Valid
2632 * 0x10, VpllHwHPReq2Valid
2633 * 0x20, Vaux1HwHPReq2Valid
2634 * 0x40, Vaux2HwHPReq2Valid
2635 * 0x80, Vaux3HwHPReq2Valid
2636 */
2637 REG_INIT(AB8540_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xff),
2638 /*
2639 * 0x01, VextSupply1HwHPReq2Valid
2640 * 0x02, VextSupply2HwHPReq2Valid
2641 * 0x04, VextSupply3HwHPReq2Valid
2642 */
2643 REG_INIT(AB8540_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x07),
2644 /*
2645 * 0x01, VapeSwHPReqValid
2646 * 0x02, VarmSwHPReqValid
2647 * 0x04, Vsmps1SwHPReqValid
2648 * 0x08, Vsmps2SwHPReqValid
2649 * 0x10, Vsmps3SwHPReqValid
2650 * 0x20, VanaSwHPReqValid
2651 * 0x40, VpllSwHPReqValid
2652 * 0x80, Vaux1SwHPReqValid
2653 */
2654 REG_INIT(AB8540_REGUSWHPREQVALID1, 0x03, 0x0d, 0xff),
2655 /*
2656 * 0x01, Vaux2SwHPReqValid
2657 * 0x02, Vaux3SwHPReqValid
2658 * 0x04, VextSupply1SwHPReqValid
2659 * 0x08, VextSupply2SwHPReqValid
2660 * 0x10, VextSupply3SwHPReqValid
2661 */
2662 REG_INIT(AB8540_REGUSWHPREQVALID2, 0x03, 0x0e, 0x1f),
2663 /*
2664 * 0x02, SysClkReq2Valid1
2665 * ...
2666 * 0x80, SysClkReq8Valid1
2667 */
2668 REG_INIT(AB8540_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0xff),
2669 /*
2670 * 0x02, SysClkReq2Valid2
2671 * ...
2672 * 0x80, SysClkReq8Valid2
2673 */
2674 REG_INIT(AB8540_REGUSYSCLKREQVALID2, 0x03, 0x10, 0xff),
2675 /*
2676 * 0x01, Vaux4SwHPReqValid
2677 * 0x02, Vaux4HwHPReq2Valid
2678 * 0x04, Vaux4HwHPReq1Valid
2679 * 0x08, Vaux4SysClkReq1HPValid
2680 */
2681 REG_INIT(AB8540_REGUVAUX4REQVALID, 0x03, 0x11, 0x0f),
2682 /*
2683 * 0x01, Vaux5SwHPReqValid
2684 * 0x02, Vaux5HwHPReq2Valid
2685 * 0x04, Vaux5HwHPReq1Valid
2686 * 0x08, Vaux5SysClkReq1HPValid
2687 */
2688 REG_INIT(AB8540_REGUVAUX5REQVALID, 0x03, 0x12, 0x0f),
2689 /*
2690 * 0x01, Vaux6SwHPReqValid
2691 * 0x02, Vaux6HwHPReq2Valid
2692 * 0x04, Vaux6HwHPReq1Valid
2693 * 0x08, Vaux6SysClkReq1HPValid
2694 */
2695 REG_INIT(AB8540_REGUVAUX6REQVALID, 0x03, 0x13, 0x0f),
2696 /*
2697 * 0x01, VclkbSwHPReqValid
2698 * 0x02, VclkbHwHPReq2Valid
2699 * 0x04, VclkbHwHPReq1Valid
2700 * 0x08, VclkbSysClkReq1HPValid
2701 */
2702 REG_INIT(AB8540_REGUVCLKBREQVALID, 0x03, 0x14, 0x0f),
2703 /*
2704 * 0x01, Vrf1SwHPReqValid
2705 * 0x02, Vrf1HwHPReq2Valid
2706 * 0x04, Vrf1HwHPReq1Valid
2707 * 0x08, Vrf1SysClkReq1HPValid
2708 */
2709 REG_INIT(AB8540_REGUVRF1REQVALID, 0x03, 0x15, 0x0f),
2710 /*
2711 * 0x02, VTVoutEna
2712 * 0x04, Vintcore12Ena
2713 * 0x38, Vintcore12Sel
2714 * 0x40, Vintcore12LP
2715 * 0x80, VTVoutLP
2716 */
2717 REG_INIT(AB8540_REGUMISC1, 0x03, 0x80, 0xfe),
2718 /*
2719 * 0x02, VaudioEna
2720 * 0x04, VdmicEna
2721 * 0x08, Vamic1Ena
2722 * 0x10, Vamic2Ena
2723 * 0x20, Vamic12LP
2724 * 0xC0, VdmicSel
2725 */
2726 REG_INIT(AB8540_VAUDIOSUPPLY, 0x03, 0x83, 0xfe),
2727 /*
2728 * 0x01, Vamic1_dzout
2729 * 0x02, Vamic2_dzout
2730 */
2731 REG_INIT(AB8540_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
2732 /*
2733 * 0x07, VHSICSel
2734 * 0x08, VHSICOffState
2735 * 0x10, VHSIEna
2736 * 0x20, VHSICLP
2737 */
2738 REG_INIT(AB8540_VHSIC, 0x03, 0x87, 0x3f),
2739 /*
2740 * 0x07, VSDIOSel
2741 * 0x08, VSDIOOffState
2742 * 0x10, VSDIOEna
2743 * 0x20, VSDIOLP
2744 */
2745 REG_INIT(AB8540_VSDIO, 0x03, 0x88, 0x3f),
2746 /*
2747 * 0x03, Vsmps1Regu
2748 * 0x0c, Vsmps1SelCtrl
2749 * 0x10, Vsmps1AutoMode
2750 * 0x20, Vsmps1PWMMode
2751 */
2752 REG_INIT(AB8540_VSMPS1REGU, 0x04, 0x03, 0x3f),
2753 /*
2754 * 0x03, Vsmps2Regu
2755 * 0x0c, Vsmps2SelCtrl
2756 * 0x10, Vsmps2AutoMode
2757 * 0x20, Vsmps2PWMMode
2758 */
2759 REG_INIT(AB8540_VSMPS2REGU, 0x04, 0x04, 0x3f),
2760 /*
2761 * 0x03, Vsmps3Regu
2762 * 0x0c, Vsmps3SelCtrl
2763 * 0x10, Vsmps3AutoMode
2764 * 0x20, Vsmps3PWMMode
2765 * NOTE! PRCMU register
2766 */
2767 REG_INIT(AB8540_VSMPS3REGU, 0x04, 0x05, 0x0f),
2768 /*
2769 * 0x03, VpllRegu
2770 * 0x0c, VanaRegu
2771 */
2772 REG_INIT(AB8540_VPLLVANAREGU, 0x04, 0x06, 0x0f),
2773 /*
2774 * 0x03, VextSupply1Regu
2775 * 0x0c, VextSupply2Regu
2776 * 0x30, VextSupply3Regu
2777 * 0x40, ExtSupply2Bypass
2778 * 0x80, ExtSupply3Bypass
2779 */
2780 REG_INIT(AB8540_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
2781 /*
2782 * 0x03, Vaux1Regu
2783 * 0x0c, Vaux2Regu
2784 */
2785 REG_INIT(AB8540_VAUX12REGU, 0x04, 0x09, 0x0f),
2786 /*
2787 * 0x0c, VRF1Regu
2788 * 0x03, Vaux3Regu
2789 */
2790 REG_INIT(AB8540_VRF1VAUX3REGU, 0x04, 0x0a, 0x0f),
2791 /*
2792 * 0x3f, Vsmps1Sel1
2793 */
2794 REG_INIT(AB8540_VSMPS1SEL1, 0x04, 0x13, 0x3f),
2795 /*
2796 * 0x3f, Vsmps1Sel2
2797 */
2798 REG_INIT(AB8540_VSMPS1SEL2, 0x04, 0x14, 0x3f),
2799 /*
2800 * 0x3f, Vsmps1Sel3
2801 */
2802 REG_INIT(AB8540_VSMPS1SEL3, 0x04, 0x15, 0x3f),
2803 /*
2804 * 0x3f, Vsmps2Sel1
2805 */
2806 REG_INIT(AB8540_VSMPS2SEL1, 0x04, 0x17, 0x3f),
2807 /*
2808 * 0x3f, Vsmps2Sel2
2809 */
2810 REG_INIT(AB8540_VSMPS2SEL2, 0x04, 0x18, 0x3f),
2811 /*
2812 * 0x3f, Vsmps2Sel3
2813 */
2814 REG_INIT(AB8540_VSMPS2SEL3, 0x04, 0x19, 0x3f),
2815 /*
2816 * 0x7f, Vsmps3Sel1
2817 * NOTE! PRCMU register
2818 */
2819 REG_INIT(AB8540_VSMPS3SEL1, 0x04, 0x1b, 0x7f),
2820 /*
2821 * 0x7f, Vsmps3Sel2
2822 * NOTE! PRCMU register
2823 */
2824 REG_INIT(AB8540_VSMPS3SEL2, 0x04, 0x1c, 0x7f),
2825 /*
2826 * 0x0f, Vaux1Sel
2827 */
2828 REG_INIT(AB8540_VAUX1SEL, 0x04, 0x1f, 0x0f),
2829 /*
2830 * 0x0f, Vaux2Sel
2831 */
2832 REG_INIT(AB8540_VAUX2SEL, 0x04, 0x20, 0x0f),
2833 /*
2834 * 0x07, Vaux3Sel
2835 * 0x70, Vrf1Sel
2836 */
2837 REG_INIT(AB8540_VRF1VAUX3SEL, 0x04, 0x21, 0x77),
2838 /*
2839 * 0x01, VextSupply12LP
2840 */
2841 REG_INIT(AB8540_REGUCTRL2SPARE, 0x04, 0x22, 0x01),
2842 /*
2843 * 0x07, Vanasel
2844 * 0x30, Vpllsel
2845 */
2846 REG_INIT(AB8540_VANAVPLLSEL, 0x04, 0x29, 0x37),
2847 /*
2848 * 0x03, Vaux4RequestCtrl
2849 */
2850 REG_INIT(AB8540_VAUX4REQCTRL, 0x04, 0x2d, 0x03),
2851 /*
2852 * 0x03, Vaux4Regu
2853 */
2854 REG_INIT(AB8540_VAUX4REGU, 0x04, 0x2e, 0x03),
2855 /*
2856 * 0x0f, Vaux4Sel
2857 */
2858 REG_INIT(AB8540_VAUX4SEL, 0x04, 0x2f, 0x0f),
2859 /*
2860 * 0x03, Vaux5RequestCtrl
2861 */
2862 REG_INIT(AB8540_VAUX5REQCTRL, 0x04, 0x31, 0x03),
2863 /*
2864 * 0x03, Vaux5Regu
2865 */
2866 REG_INIT(AB8540_VAUX5REGU, 0x04, 0x32, 0x03),
2867 /*
2868 * 0x3f, Vaux5Sel
2869 */
2870 REG_INIT(AB8540_VAUX5SEL, 0x04, 0x33, 0x3f),
2871 /*
2872 * 0x03, Vaux6RequestCtrl
2873 */
2874 REG_INIT(AB8540_VAUX6REQCTRL, 0x04, 0x34, 0x03),
2875 /*
2876 * 0x03, Vaux6Regu
2877 */
2878 REG_INIT(AB8540_VAUX6REGU, 0x04, 0x35, 0x03),
2879 /*
2880 * 0x3f, Vaux6Sel
2881 */
2882 REG_INIT(AB8540_VAUX6SEL, 0x04, 0x36, 0x3f),
2883 /*
2884 * 0x03, VCLKBRequestCtrl
2885 */
2886 REG_INIT(AB8540_VCLKBREQCTRL, 0x04, 0x37, 0x03),
2887 /*
2888 * 0x03, VCLKBRegu
2889 */
2890 REG_INIT(AB8540_VCLKBREGU, 0x04, 0x38, 0x03),
2891 /*
2892 * 0x07, VCLKBSel
2893 */
2894 REG_INIT(AB8540_VCLKBSEL, 0x04, 0x39, 0x07),
2895 /*
2896 * 0x03, Vrf1RequestCtrl
2897 */
2898 REG_INIT(AB8540_VRF1REQCTRL, 0x04, 0x3a, 0x03),
2899 /*
2900 * 0x01, VpllDisch
2901 * 0x02, Vrf1Disch
2902 * 0x04, Vaux1Disch
2903 * 0x08, Vaux2Disch
2904 * 0x10, Vaux3Disch
2905 * 0x20, Vintcore12Disch
2906 * 0x40, VTVoutDisch
2907 * 0x80, VaudioDisch
2908 */
2909 REG_INIT(AB8540_REGUCTRLDISCH, 0x04, 0x43, 0xff),
2910 /*
2911 * 0x02, VanaDisch
2912 * 0x04, VdmicPullDownEna
2913 * 0x08, VpllPullDownEna
2914 * 0x10, VdmicDisch
2915 */
2916 REG_INIT(AB8540_REGUCTRLDISCH2, 0x04, 0x44, 0x1e),
2917 /*
2918 * 0x01, Vaux4Disch
2919 */
2920 REG_INIT(AB8540_REGUCTRLDISCH3, 0x04, 0x48, 0x01),
2921 /*
2922 * 0x01, Vaux5Disch
2923 * 0x02, Vaux6Disch
2924 * 0x04, VCLKBDisch
2925 */
2926 REG_INIT(AB8540_REGUCTRLDISCH4, 0x04, 0x49, 0x07),
2927};
2928
Lee Jones33aeb492013-04-02 13:24:14 +01002929static struct {
2930 struct ab8500_regulator_info *info;
2931 int info_size;
2932 struct ab8500_reg_init *init;
2933 int init_size;
2934 struct of_regulator_match *match;
2935 int match_size;
2936} abx500_regulator;
2937
Lee Jones3c1b8432013-03-21 15:59:01 +00002938static int ab8500_regulator_init_registers(struct platform_device *pdev,
2939 int id, int mask, int value)
Lee Jonesa7ac1d92012-05-17 14:45:14 +01002940{
Lee Jones33aeb492013-04-02 13:24:14 +01002941 struct ab8500_reg_init *reg_init = abx500_regulator.init;
Lee Jonesa7ac1d92012-05-17 14:45:14 +01002942 int err;
2943
Lee Jones3c1b8432013-03-21 15:59:01 +00002944 BUG_ON(value & ~mask);
Lee Jonesb54969a2013-03-28 16:11:10 +00002945 BUG_ON(mask & ~reg_init[id].mask);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01002946
Lee Jones3c1b8432013-03-21 15:59:01 +00002947 /* initialize register */
Lee Jonesa7ac1d92012-05-17 14:45:14 +01002948 err = abx500_mask_and_set_register_interruptible(
2949 &pdev->dev,
Lee Jonesb54969a2013-03-28 16:11:10 +00002950 reg_init[id].bank,
2951 reg_init[id].addr,
Lee Jones3c1b8432013-03-21 15:59:01 +00002952 mask, value);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01002953 if (err < 0) {
2954 dev_err(&pdev->dev,
2955 "Failed to initialize 0x%02x, 0x%02x.\n",
Lee Jonesb54969a2013-03-28 16:11:10 +00002956 reg_init[id].bank,
2957 reg_init[id].addr);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01002958 return err;
2959 }
Lee Jonesa7ac1d92012-05-17 14:45:14 +01002960 dev_vdbg(&pdev->dev,
Lee Jones3c1b8432013-03-21 15:59:01 +00002961 " init: 0x%02x, 0x%02x, 0x%02x, 0x%02x\n",
Lee Jonesb54969a2013-03-28 16:11:10 +00002962 reg_init[id].bank,
2963 reg_init[id].addr,
Lee Jones3c1b8432013-03-21 15:59:01 +00002964 mask, value);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01002965
2966 return 0;
2967}
2968
Bill Pembertona5023572012-11-19 13:22:22 -05002969static int ab8500_regulator_register(struct platform_device *pdev,
Lee Jonesb54969a2013-03-28 16:11:10 +00002970 struct regulator_init_data *init_data,
Lee Jonesb54969a2013-03-28 16:11:10 +00002971 int id, struct device_node *np)
Lee Jonesa7ac1d92012-05-17 14:45:14 +01002972{
Lee Jones8e6a8d72013-03-28 16:11:11 +00002973 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01002974 struct ab8500_regulator_info *info = NULL;
2975 struct regulator_config config = { };
2976 int err;
2977
2978 /* assign per-regulator data */
Lee Jones33aeb492013-04-02 13:24:14 +01002979 info = &abx500_regulator.info[id];
Lee Jonesa7ac1d92012-05-17 14:45:14 +01002980 info->dev = &pdev->dev;
2981
2982 config.dev = &pdev->dev;
2983 config.init_data = init_data;
2984 config.driver_data = info;
2985 config.of_node = np;
2986
2987 /* fix for hardware before ab8500v2.0 */
Lee Jones8e6a8d72013-03-28 16:11:11 +00002988 if (is_ab8500_1p1_or_earlier(ab8500)) {
Lee Jonesa7ac1d92012-05-17 14:45:14 +01002989 if (info->desc.id == AB8500_LDO_AUX3) {
2990 info->desc.n_voltages =
2991 ARRAY_SIZE(ldo_vauxn_voltages);
Axel Linec1cc4d2012-05-20 10:33:35 +08002992 info->desc.volt_table = ldo_vauxn_voltages;
Lee Jonesa7ac1d92012-05-17 14:45:14 +01002993 info->voltage_mask = 0xf;
2994 }
2995 }
2996
2997 /* register regulator with framework */
2998 info->regulator = regulator_register(&info->desc, &config);
2999 if (IS_ERR(info->regulator)) {
3000 err = PTR_ERR(info->regulator);
3001 dev_err(&pdev->dev, "failed to register regulator %s\n",
3002 info->desc.name);
3003 /* when we fail, un-register all earlier regulators */
3004 while (--id >= 0) {
Lee Jones33aeb492013-04-02 13:24:14 +01003005 info = &abx500_regulator.info[id];
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003006 regulator_unregister(info->regulator);
3007 }
3008 return err;
3009 }
3010
3011 return 0;
3012}
3013
Lee Jonesb54969a2013-03-28 16:11:10 +00003014static struct of_regulator_match ab8500_regulator_match[] = {
Lee Jones7e715b92012-05-30 12:47:26 +08003015 { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB8500_LDO_AUX1, },
3016 { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB8500_LDO_AUX2, },
3017 { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB8500_LDO_AUX3, },
3018 { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB8500_LDO_INTCORE, },
3019 { .name = "ab8500_ldo_tvout", .driver_data = (void *) AB8500_LDO_TVOUT, },
Lee Jones7e715b92012-05-30 12:47:26 +08003020 { .name = "ab8500_ldo_audio", .driver_data = (void *) AB8500_LDO_AUDIO, },
3021 { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB8500_LDO_ANAMIC1, },
3022 { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB8500_LDO_ANAMIC2, },
3023 { .name = "ab8500_ldo_dmic", .driver_data = (void *) AB8500_LDO_DMIC, },
3024 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB8500_LDO_ANA, },
Lee Jones3a8334b2012-05-17 14:45:16 +01003025};
3026
Lee Jones547f3842013-03-28 16:11:14 +00003027static struct of_regulator_match ab8505_regulator_match[] = {
3028 { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB8505_LDO_AUX1, },
3029 { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB8505_LDO_AUX2, },
3030 { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB8505_LDO_AUX3, },
3031 { .name = "ab8500_ldo_aux4", .driver_data = (void *) AB8505_LDO_AUX4, },
3032 { .name = "ab8500_ldo_aux5", .driver_data = (void *) AB8505_LDO_AUX5, },
3033 { .name = "ab8500_ldo_aux6", .driver_data = (void *) AB8505_LDO_AUX6, },
3034 { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB8505_LDO_INTCORE, },
3035 { .name = "ab8500_ldo_adc", .driver_data = (void *) AB8505_LDO_ADC, },
3036 { .name = "ab8500_ldo_audio", .driver_data = (void *) AB8505_LDO_AUDIO, },
3037 { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB8505_LDO_ANAMIC1, },
3038 { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB8505_LDO_ANAMIC2, },
3039 { .name = "ab8500_ldo_aux8", .driver_data = (void *) AB8505_LDO_AUX8, },
3040 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB8505_LDO_ANA, },
3041};
3042
Lee Jonesae0a9a32013-03-28 16:11:16 +00003043static struct of_regulator_match ab8540_regulator_match[] = {
3044 { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB8540_LDO_AUX1, },
3045 { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB8540_LDO_AUX2, },
3046 { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB8540_LDO_AUX3, },
3047 { .name = "ab8500_ldo_aux4", .driver_data = (void *) AB8540_LDO_AUX4, },
Zhenhua HUANG684d5ce2013-04-02 13:24:15 +01003048 { .name = "ab8500_ldo_aux5", .driver_data = (void *) AB8540_LDO_AUX5, },
3049 { .name = "ab8500_ldo_aux6", .driver_data = (void *) AB8540_LDO_AUX6, },
Lee Jonesae0a9a32013-03-28 16:11:16 +00003050 { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB8540_LDO_INTCORE, },
3051 { .name = "ab8500_ldo_tvout", .driver_data = (void *) AB8540_LDO_TVOUT, },
3052 { .name = "ab8500_ldo_audio", .driver_data = (void *) AB8540_LDO_AUDIO, },
3053 { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB8540_LDO_ANAMIC1, },
3054 { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB8540_LDO_ANAMIC2, },
3055 { .name = "ab8500_ldo_dmic", .driver_data = (void *) AB8540_LDO_DMIC, },
3056 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB8540_LDO_ANA, },
3057 { .name = "ab8500_ldo_sdio", .driver_data = (void *) AB8540_LDO_SDIO, },
3058};
3059
Lee Jones8e6a8d72013-03-28 16:11:11 +00003060static struct of_regulator_match ab9540_regulator_match[] = {
3061 { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB9540_LDO_AUX1, },
3062 { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB9540_LDO_AUX2, },
3063 { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB9540_LDO_AUX3, },
3064 { .name = "ab8500_ldo_aux4", .driver_data = (void *) AB9540_LDO_AUX4, },
3065 { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB9540_LDO_INTCORE, },
3066 { .name = "ab8500_ldo_tvout", .driver_data = (void *) AB9540_LDO_TVOUT, },
3067 { .name = "ab8500_ldo_audio", .driver_data = (void *) AB9540_LDO_AUDIO, },
3068 { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB9540_LDO_ANAMIC1, },
3069 { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB9540_LDO_ANAMIC2, },
3070 { .name = "ab8500_ldo_dmic", .driver_data = (void *) AB9540_LDO_DMIC, },
3071 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB9540_LDO_ANA, },
3072};
3073
Lee Jones33aeb492013-04-02 13:24:14 +01003074static void abx500_get_regulator_info(struct ab8500 *ab8500)
3075{
3076 if (is_ab9540(ab8500)) {
3077 abx500_regulator.info = ab9540_regulator_info;
3078 abx500_regulator.info_size = ARRAY_SIZE(ab9540_regulator_info);
3079 abx500_regulator.init = ab9540_reg_init;
3080 abx500_regulator.init_size = AB9540_NUM_REGULATOR_REGISTERS;
3081 abx500_regulator.match = ab9540_regulator_match;
3082 abx500_regulator.match_size = ARRAY_SIZE(ab9540_regulator_match);
3083 } else if (is_ab8505(ab8500)) {
3084 abx500_regulator.info = ab8505_regulator_info;
3085 abx500_regulator.info_size = ARRAY_SIZE(ab8505_regulator_info);
3086 abx500_regulator.init = ab8505_reg_init;
3087 abx500_regulator.init_size = AB8505_NUM_REGULATOR_REGISTERS;
3088 abx500_regulator.match = ab8505_regulator_match;
3089 abx500_regulator.match_size = ARRAY_SIZE(ab8505_regulator_match);
3090 } else if (is_ab8540(ab8500)) {
3091 abx500_regulator.info = ab8540_regulator_info;
3092 abx500_regulator.info_size = ARRAY_SIZE(ab8540_regulator_info);
3093 abx500_regulator.init = ab8540_reg_init;
3094 abx500_regulator.init_size = AB8540_NUM_REGULATOR_REGISTERS;
3095 abx500_regulator.match = ab8540_regulator_match;
3096 abx500_regulator.match_size = ARRAY_SIZE(ab8540_regulator_match);
3097 } else {
3098 abx500_regulator.info = ab8500_regulator_info;
3099 abx500_regulator.info_size = ARRAY_SIZE(ab8500_regulator_info);
3100 abx500_regulator.init = ab8500_reg_init;
3101 abx500_regulator.init_size = AB8500_NUM_REGULATOR_REGISTERS;
3102 abx500_regulator.match = ab8500_regulator_match;
3103 abx500_regulator.match_size = ARRAY_SIZE(ab8500_regulator_match);
3104 }
3105}
3106
Bill Pembertona5023572012-11-19 13:22:22 -05003107static int
Lee Jonesb54969a2013-03-28 16:11:10 +00003108ab8500_regulator_of_probe(struct platform_device *pdev,
Lee Jonesb54969a2013-03-28 16:11:10 +00003109 struct device_node *np)
Lee Jones3a8334b2012-05-17 14:45:16 +01003110{
Lee Jones33aeb492013-04-02 13:24:14 +01003111 struct of_regulator_match *match = abx500_regulator.match;
Lee Jones3a8334b2012-05-17 14:45:16 +01003112 int err, i;
3113
Lee Jones33aeb492013-04-02 13:24:14 +01003114 for (i = 0; i < abx500_regulator.info_size; i++) {
Lee Jones3a8334b2012-05-17 14:45:16 +01003115 err = ab8500_regulator_register(
Lee Jones33aeb492013-04-02 13:24:14 +01003116 pdev, match[i].init_data, i, match[i].of_node);
Lee Jones3a8334b2012-05-17 14:45:16 +01003117 if (err)
3118 return err;
3119 }
3120
3121 return 0;
3122}
3123
Bill Pembertona5023572012-11-19 13:22:22 -05003124static int ab8500_regulator_probe(struct platform_device *pdev)
Sundar R IYERc789ca22010-07-13 21:48:56 +05303125{
3126 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
Lee Jones3a8334b2012-05-17 14:45:16 +01003127 struct device_node *np = pdev->dev.of_node;
Bengt Jonsson732805a2013-03-21 15:59:03 +00003128 struct ab8500_platform_data *ppdata;
3129 struct ab8500_regulator_platform_data *pdata;
Sundar R IYERc789ca22010-07-13 21:48:56 +05303130 int i, err;
Lee Jonesb54969a2013-03-28 16:11:10 +00003131
Lee Jones33aeb492013-04-02 13:24:14 +01003132 if (!ab8500) {
3133 dev_err(&pdev->dev, "null mfd parent\n");
3134 return -EINVAL;
Lee Jones8e6a8d72013-03-28 16:11:11 +00003135 }
Sundar R IYERc789ca22010-07-13 21:48:56 +05303136
Lee Jones33aeb492013-04-02 13:24:14 +01003137 abx500_get_regulator_info(ab8500);
3138
Lee Jones3a8334b2012-05-17 14:45:16 +01003139 if (np) {
Lee Jones33aeb492013-04-02 13:24:14 +01003140 err = of_regulator_match(&pdev->dev, np,
3141 abx500_regulator.match,
3142 abx500_regulator.match_size);
Lee Jones3a8334b2012-05-17 14:45:16 +01003143 if (err < 0) {
3144 dev_err(&pdev->dev,
3145 "Error parsing regulator init data: %d\n", err);
3146 return err;
3147 }
3148
Lee Jones33aeb492013-04-02 13:24:14 +01003149 err = ab8500_regulator_of_probe(pdev, np);
Lee Jones3a8334b2012-05-17 14:45:16 +01003150 return err;
3151 }
3152
Bengt Jonsson732805a2013-03-21 15:59:03 +00003153 ppdata = dev_get_platdata(ab8500->dev);
3154 if (!ppdata) {
3155 dev_err(&pdev->dev, "null parent pdata\n");
3156 return -EINVAL;
3157 }
3158
3159 pdata = ppdata->regulator;
Bengt Jonssonfc24b422010-12-10 11:08:45 +01003160 if (!pdata) {
3161 dev_err(&pdev->dev, "null pdata\n");
3162 return -EINVAL;
3163 }
Sundar R IYERc789ca22010-07-13 21:48:56 +05303164
Bengt Jonssoncb189b02010-12-10 11:08:40 +01003165 /* make sure the platform data has the correct size */
Lee Jones33aeb492013-04-02 13:24:14 +01003166 if (pdata->num_regulator != abx500_regulator.info_size) {
Bengt Jonsson79568b942011-03-11 11:54:46 +01003167 dev_err(&pdev->dev, "Configuration error: size mismatch.\n");
Bengt Jonssoncb189b02010-12-10 11:08:40 +01003168 return -EINVAL;
3169 }
3170
Lee Jonesda0b0c42013-03-28 16:11:09 +00003171 /* initialize debug (initial state is recorded with this call) */
3172 err = ab8500_regulator_debug_init(pdev);
3173 if (err)
3174 return err;
3175
Bengt Jonsson79568b942011-03-11 11:54:46 +01003176 /* initialize registers */
Bengt Jonsson732805a2013-03-21 15:59:03 +00003177 for (i = 0; i < pdata->num_reg_init; i++) {
Lee Jones3c1b8432013-03-21 15:59:01 +00003178 int id, mask, value;
Bengt Jonsson79568b942011-03-11 11:54:46 +01003179
Bengt Jonsson732805a2013-03-21 15:59:03 +00003180 id = pdata->reg_init[i].id;
3181 mask = pdata->reg_init[i].mask;
3182 value = pdata->reg_init[i].value;
Bengt Jonsson79568b942011-03-11 11:54:46 +01003183
3184 /* check for configuration errors */
Lee Jones33aeb492013-04-02 13:24:14 +01003185 BUG_ON(id >= abx500_regulator.init_size);
Bengt Jonsson79568b942011-03-11 11:54:46 +01003186
Lee Jones33aeb492013-04-02 13:24:14 +01003187 err = ab8500_regulator_init_registers(pdev, id, mask, value);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003188 if (err < 0)
Bengt Jonsson79568b942011-03-11 11:54:46 +01003189 return err;
Bengt Jonsson79568b942011-03-11 11:54:46 +01003190 }
3191
Rabin Vincentf7eae372013-04-02 13:24:08 +01003192 if (!is_ab8505(ab8500)) {
3193 /* register external regulators (before Vaux1, 2 and 3) */
3194 err = ab8500_ext_regulator_init(pdev);
3195 if (err)
3196 return err;
3197 }
Lee Jonesd1a82002013-03-28 16:11:01 +00003198
Sundar R IYERc789ca22010-07-13 21:48:56 +05303199 /* register all regulators */
Lee Jones33aeb492013-04-02 13:24:14 +01003200 for (i = 0; i < abx500_regulator.info_size; i++) {
Lee Jonesb54969a2013-03-28 16:11:10 +00003201 err = ab8500_regulator_register(pdev, &pdata->regulator[i],
Lee Jones33aeb492013-04-02 13:24:14 +01003202 i, NULL);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003203 if (err < 0)
Sundar R IYERc789ca22010-07-13 21:48:56 +05303204 return err;
Sundar R IYERc789ca22010-07-13 21:48:56 +05303205 }
3206
3207 return 0;
3208}
3209
Bill Pemberton8dc995f2012-11-19 13:26:10 -05003210static int ab8500_regulator_remove(struct platform_device *pdev)
Sundar R IYERc789ca22010-07-13 21:48:56 +05303211{
Lee Jonesd1a82002013-03-28 16:11:01 +00003212 int i, err;
Lee Jones8e6a8d72013-03-28 16:11:11 +00003213 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
Sundar R IYERc789ca22010-07-13 21:48:56 +05303214
Lee Jones33aeb492013-04-02 13:24:14 +01003215 for (i = 0; i < abx500_regulator.info_size; i++) {
Sundar R IYERc789ca22010-07-13 21:48:56 +05303216 struct ab8500_regulator_info *info = NULL;
Lee Jones33aeb492013-04-02 13:24:14 +01003217 info = &abx500_regulator.info[i];
Bengt Jonsson09aefa12010-12-10 11:08:46 +01003218
3219 dev_vdbg(rdev_get_dev(info->regulator),
3220 "%s-remove\n", info->desc.name);
3221
Sundar R IYERc789ca22010-07-13 21:48:56 +05303222 regulator_unregister(info->regulator);
3223 }
3224
Rabin Vincentf7eae372013-04-02 13:24:08 +01003225 if (!is_ab8505(ab8500)) {
3226 /* remove external regulators (after Vaux1, 2 and 3) */
3227 err = ab8500_ext_regulator_exit(pdev);
3228 if (err)
3229 return err;
3230 }
Lee Jonesd1a82002013-03-28 16:11:01 +00003231
Lee Jonesda0b0c42013-03-28 16:11:09 +00003232 /* remove regulator debug */
3233 err = ab8500_regulator_debug_exit(pdev);
3234 if (err)
3235 return err;
3236
Sundar R IYERc789ca22010-07-13 21:48:56 +05303237 return 0;
3238}
3239
3240static struct platform_driver ab8500_regulator_driver = {
3241 .probe = ab8500_regulator_probe,
Bill Pemberton5eb9f2b2012-11-19 13:20:42 -05003242 .remove = ab8500_regulator_remove,
Sundar R IYERc789ca22010-07-13 21:48:56 +05303243 .driver = {
3244 .name = "ab8500-regulator",
3245 .owner = THIS_MODULE,
Sundar R IYERc789ca22010-07-13 21:48:56 +05303246 },
3247};
3248
3249static int __init ab8500_regulator_init(void)
3250{
3251 int ret;
3252
3253 ret = platform_driver_register(&ab8500_regulator_driver);
3254 if (ret != 0)
3255 pr_err("Failed to register ab8500 regulator: %d\n", ret);
3256
3257 return ret;
3258}
3259subsys_initcall(ab8500_regulator_init);
3260
3261static void __exit ab8500_regulator_exit(void)
3262{
3263 platform_driver_unregister(&ab8500_regulator_driver);
3264}
3265module_exit(ab8500_regulator_exit);
3266
3267MODULE_LICENSE("GPL v2");
3268MODULE_AUTHOR("Sundar Iyer <sundar.iyer@stericsson.com>");
Bengt Jonsson732805a2013-03-21 15:59:03 +00003269MODULE_AUTHOR("Bengt Jonsson <bengt.g.jonsson@stericsson.com>");
Lee Jones547f3842013-03-28 16:11:14 +00003270MODULE_AUTHOR("Daniel Willerud <daniel.willerud@stericsson.com>");
Sundar R IYERc789ca22010-07-13 21:48:56 +05303271MODULE_DESCRIPTION("Regulator Driver for ST-Ericsson AB8500 Mixed-Sig PMIC");
3272MODULE_ALIAS("platform:ab8500-regulator");