blob: 9cb634807ff883f4351ae511a7c894520d855858 [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
Axel Linec1cc4d2012-05-20 10:33:35 +0800152static const unsigned int ldo_vintcore_voltages[] = {
Sundar R IYERc789ca22010-07-13 21:48:56 +0530153 1200000,
154 1225000,
155 1250000,
156 1275000,
157 1300000,
158 1325000,
159 1350000,
160};
161
Lee Jones62ab4112013-03-28 16:11:18 +0000162static const unsigned int ldo_sdio_voltages[] = {
Lee Jonesae0a9a32013-03-28 16:11:16 +0000163 1160000,
164 1050000,
165 1100000,
166 1500000,
167 1800000,
168 2200000,
169 2910000,
170 3050000,
171};
172
Lee Jonesb080c782013-03-28 16:11:17 +0000173static const unsigned int fixed_1200000_voltage[] = {
174 1200000,
175};
176
177static const unsigned int fixed_1800000_voltage[] = {
178 1800000,
179};
180
181static const unsigned int fixed_2000000_voltage[] = {
182 2000000,
183};
184
185static const unsigned int fixed_2050000_voltage[] = {
186 2050000,
187};
188
189static const unsigned int fixed_3300000_voltage[] = {
190 3300000,
191};
192
Lee Jones8a3b1b82013-04-02 13:24:09 +0100193static const unsigned int ldo_vana_voltages[] = {
194 1050000,
195 1075000,
196 1100000,
197 1125000,
198 1150000,
199 1175000,
200 1200000,
201 1225000,
202};
203
204static const unsigned int ldo_vaudio_voltages[] = {
205 2000000,
206 2100000,
207 2200000,
208 2300000,
209 2400000,
210 2500000,
211 2600000,
212 2600000, /* Duplicated in Vaudio and IsoUicc Control register. */
213};
214
Lee Jones4c84b4d2013-04-02 13:24:13 +0100215static const unsigned int ldo_vdmic_voltages[] = {
216 1800000,
217 1900000,
218 2000000,
219 2850000,
220};
221
Lee Jones3fe52282013-04-02 13:24:12 +0100222static DEFINE_MUTEX(shared_mode_mutex);
223static struct ab8500_shared_mode ldo_anamic1_shared;
224static struct ab8500_shared_mode ldo_anamic2_shared;
Lee Jones4c84b4d2013-04-02 13:24:13 +0100225static struct ab8500_shared_mode ab8540_ldo_anamic1_shared;
226static struct ab8500_shared_mode ab8540_ldo_anamic2_shared;
Lee Jones3fe52282013-04-02 13:24:12 +0100227
Sundar R IYERc789ca22010-07-13 21:48:56 +0530228static int ab8500_regulator_enable(struct regulator_dev *rdev)
229{
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100230 int ret;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530231 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
232
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100233 if (info == NULL) {
234 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
Sundar R IYERc789ca22010-07-13 21:48:56 +0530235 return -EINVAL;
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100236 }
Sundar R IYERc789ca22010-07-13 21:48:56 +0530237
Mattias Wallin47c16972010-09-10 17:47:56 +0200238 ret = abx500_mask_and_set_register_interruptible(info->dev,
Bengt Jonssone1159e62010-12-10 11:08:44 +0100239 info->update_bank, info->update_reg,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000240 info->update_mask, info->update_val);
Axel Linf71bf522013-03-26 16:13:14 +0800241 if (ret < 0) {
Sundar R IYERc789ca22010-07-13 21:48:56 +0530242 dev_err(rdev_get_dev(rdev),
243 "couldn't set enable bits for regulator\n");
Axel Linf71bf522013-03-26 16:13:14 +0800244 return ret;
245 }
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100246
Emeric Vigierbd28a152013-03-21 15:58:59 +0000247 info->is_enabled = true;
248
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100249 dev_vdbg(rdev_get_dev(rdev),
250 "%s-enable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
251 info->desc.name, info->update_bank, info->update_reg,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000252 info->update_mask, info->update_val);
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100253
Sundar R IYERc789ca22010-07-13 21:48:56 +0530254 return ret;
255}
256
257static int ab8500_regulator_disable(struct regulator_dev *rdev)
258{
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100259 int ret;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530260 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
261
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100262 if (info == NULL) {
263 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
Sundar R IYERc789ca22010-07-13 21:48:56 +0530264 return -EINVAL;
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100265 }
Sundar R IYERc789ca22010-07-13 21:48:56 +0530266
Mattias Wallin47c16972010-09-10 17:47:56 +0200267 ret = abx500_mask_and_set_register_interruptible(info->dev,
Bengt Jonssone1159e62010-12-10 11:08:44 +0100268 info->update_bank, info->update_reg,
269 info->update_mask, 0x0);
Axel Linf71bf522013-03-26 16:13:14 +0800270 if (ret < 0) {
Sundar R IYERc789ca22010-07-13 21:48:56 +0530271 dev_err(rdev_get_dev(rdev),
272 "couldn't set disable bits for regulator\n");
Axel Linf71bf522013-03-26 16:13:14 +0800273 return ret;
274 }
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100275
Emeric Vigierbd28a152013-03-21 15:58:59 +0000276 info->is_enabled = false;
277
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100278 dev_vdbg(rdev_get_dev(rdev),
279 "%s-disable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
280 info->desc.name, info->update_bank, info->update_reg,
281 info->update_mask, 0x0);
282
Sundar R IYERc789ca22010-07-13 21:48:56 +0530283 return ret;
284}
285
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000286static unsigned int ab8500_regulator_get_optimum_mode(
287 struct regulator_dev *rdev, int input_uV,
288 int output_uV, int load_uA)
289{
290 unsigned int mode;
291
292 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
293
294 if (info == NULL) {
295 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
296 return -EINVAL;
297 }
298
299 if (load_uA <= info->load_lp_uA)
300 mode = REGULATOR_MODE_IDLE;
301 else
302 mode = REGULATOR_MODE_NORMAL;
303
304 return mode;
305}
306
Emeric Vigierbd28a152013-03-21 15:58:59 +0000307static int ab8500_regulator_set_mode(struct regulator_dev *rdev,
308 unsigned int mode)
309{
Lee Jones3fe52282013-04-02 13:24:12 +0100310 int ret = 0;
311 u8 bank;
312 u8 reg;
313 u8 mask;
314 u8 val;
315 bool dmr = false; /* Dedicated mode register */
Emeric Vigierbd28a152013-03-21 15:58:59 +0000316 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
317
318 if (info == NULL) {
319 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
320 return -EINVAL;
321 }
322
Lee Jones3fe52282013-04-02 13:24:12 +0100323 if (info->shared_mode) {
324 /*
325 * Special case where mode is shared between two regulators.
326 */
327 struct ab8500_shared_mode *sm = info->shared_mode;
328 mutex_lock(&shared_mode_mutex);
329
330 if (mode == REGULATOR_MODE_IDLE) {
331 sm->lp_mode_req = true; /* Low power mode requested */
332 if (!((sm->shared_regulator)->
333 shared_mode->lp_mode_req)) {
334 mutex_unlock(&shared_mode_mutex);
335 return 0; /* Other regulator prevent LP mode */
336 }
337 } else {
338 sm->lp_mode_req = false;
339 }
Emeric Vigierbd28a152013-03-21 15:58:59 +0000340 }
341
Lee Jones3fe52282013-04-02 13:24:12 +0100342 if (info->mode_mask) {
343 /* Dedicated register for handling mode */
344
345 dmr = true;
346
347 switch (mode) {
348 case REGULATOR_MODE_NORMAL:
349 val = info->mode_val_normal;
350 break;
351 case REGULATOR_MODE_IDLE:
352 val = info->mode_val_idle;
353 break;
354 default:
355 if (info->shared_mode)
356 mutex_unlock(&shared_mode_mutex);
357 return -EINVAL;
358 }
359
360 bank = info->mode_bank;
361 reg = info->mode_reg;
362 mask = info->mode_mask;
363 } else {
364 /* Mode register same as enable register */
365
366 switch (mode) {
367 case REGULATOR_MODE_NORMAL:
368 info->update_val = info->update_val_normal;
369 val = info->update_val_normal;
370 break;
371 case REGULATOR_MODE_IDLE:
372 info->update_val = info->update_val_idle;
373 val = info->update_val_idle;
374 break;
375 default:
376 if (info->shared_mode)
377 mutex_unlock(&shared_mode_mutex);
378 return -EINVAL;
379 }
380
381 bank = info->update_bank;
382 reg = info->update_reg;
383 mask = info->update_mask;
384 }
385
386 if (info->is_enabled || dmr) {
Emeric Vigierbd28a152013-03-21 15:58:59 +0000387 ret = abx500_mask_and_set_register_interruptible(info->dev,
Lee Jones3fe52282013-04-02 13:24:12 +0100388 bank, reg, mask, val);
389 if (ret < 0)
Emeric Vigierbd28a152013-03-21 15:58:59 +0000390 dev_err(rdev_get_dev(rdev),
391 "couldn't set regulator mode\n");
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000392
393 dev_vdbg(rdev_get_dev(rdev),
394 "%s-set_mode (bank, reg, mask, value): "
395 "0x%x, 0x%x, 0x%x, 0x%x\n",
Lee Jones3fe52282013-04-02 13:24:12 +0100396 info->desc.name, bank, reg,
397 mask, val);
Emeric Vigierbd28a152013-03-21 15:58:59 +0000398 }
399
Lee Jones3fe52282013-04-02 13:24:12 +0100400 if (info->shared_mode)
401 mutex_unlock(&shared_mode_mutex);
Axel Lin742a7322013-03-28 17:23:00 +0800402
Lee Jones3fe52282013-04-02 13:24:12 +0100403 return ret;
Emeric Vigierbd28a152013-03-21 15:58:59 +0000404}
405
406static unsigned int ab8500_regulator_get_mode(struct regulator_dev *rdev)
407{
408 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
409 int ret;
Lee Jones3fe52282013-04-02 13:24:12 +0100410 u8 val;
411 u8 val_normal;
412 u8 val_idle;
Emeric Vigierbd28a152013-03-21 15:58:59 +0000413
414 if (info == NULL) {
415 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
416 return -EINVAL;
417 }
418
Lee Jones3fe52282013-04-02 13:24:12 +0100419 /* Need special handling for shared mode */
420 if (info->shared_mode) {
421 if (info->shared_mode->lp_mode_req)
422 return REGULATOR_MODE_IDLE;
423 else
424 return REGULATOR_MODE_NORMAL;
425 }
426
427 if (info->mode_mask) {
428 /* Dedicated register for handling mode */
429 ret = abx500_get_register_interruptible(info->dev,
430 info->mode_bank, info->mode_reg, &val);
431 val = val & info->mode_mask;
432
433 val_normal = info->mode_val_normal;
434 val_idle = info->mode_val_idle;
435 } else {
436 /* Mode register same as enable register */
437 val = info->update_val;
438 val_normal = info->update_val_normal;
439 val_idle = info->update_val_idle;
440 }
441
442 if (val == val_normal)
Emeric Vigierbd28a152013-03-21 15:58:59 +0000443 ret = REGULATOR_MODE_NORMAL;
Lee Jones3fe52282013-04-02 13:24:12 +0100444 else if (val == val_idle)
Emeric Vigierbd28a152013-03-21 15:58:59 +0000445 ret = REGULATOR_MODE_IDLE;
446 else
447 ret = -EINVAL;
448
449 return ret;
450}
451
Sundar R IYERc789ca22010-07-13 21:48:56 +0530452static int ab8500_regulator_is_enabled(struct regulator_dev *rdev)
453{
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100454 int ret;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530455 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100456 u8 regval;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530457
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100458 if (info == NULL) {
459 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
Sundar R IYERc789ca22010-07-13 21:48:56 +0530460 return -EINVAL;
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100461 }
Sundar R IYERc789ca22010-07-13 21:48:56 +0530462
Mattias Wallin47c16972010-09-10 17:47:56 +0200463 ret = abx500_get_register_interruptible(info->dev,
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100464 info->update_bank, info->update_reg, &regval);
Sundar R IYERc789ca22010-07-13 21:48:56 +0530465 if (ret < 0) {
466 dev_err(rdev_get_dev(rdev),
467 "couldn't read 0x%x register\n", info->update_reg);
468 return ret;
469 }
470
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100471 dev_vdbg(rdev_get_dev(rdev),
472 "%s-is_enabled (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
473 " 0x%x\n",
474 info->desc.name, info->update_bank, info->update_reg,
475 info->update_mask, regval);
476
477 if (regval & info->update_mask)
Emeric Vigierbd28a152013-03-21 15:58:59 +0000478 info->is_enabled = true;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530479 else
Emeric Vigierbd28a152013-03-21 15:58:59 +0000480 info->is_enabled = false;
481
482 return info->is_enabled;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530483}
484
Axel Lin3bf6e902012-02-24 17:15:45 +0800485static int ab8500_regulator_get_voltage_sel(struct regulator_dev *rdev)
Sundar R IYERc789ca22010-07-13 21:48:56 +0530486{
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100487 int ret, val;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530488 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100489 u8 regval;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530490
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100491 if (info == NULL) {
492 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
Sundar R IYERc789ca22010-07-13 21:48:56 +0530493 return -EINVAL;
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100494 }
Sundar R IYERc789ca22010-07-13 21:48:56 +0530495
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100496 ret = abx500_get_register_interruptible(info->dev,
497 info->voltage_bank, info->voltage_reg, &regval);
Sundar R IYERc789ca22010-07-13 21:48:56 +0530498 if (ret < 0) {
499 dev_err(rdev_get_dev(rdev),
500 "couldn't read voltage reg for regulator\n");
501 return ret;
502 }
503
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100504 dev_vdbg(rdev_get_dev(rdev),
Linus Walleija0a70142012-08-20 18:41:35 +0200505 "%s-get_voltage (bank, reg, mask, shift, value): "
506 "0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n",
507 info->desc.name, info->voltage_bank,
508 info->voltage_reg, info->voltage_mask,
509 info->voltage_shift, regval);
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100510
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100511 val = regval & info->voltage_mask;
Linus Walleija0a70142012-08-20 18:41:35 +0200512 return val >> info->voltage_shift;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530513}
514
Lee Jonesd7607ba2013-04-02 13:24:11 +0100515static int ab8540_aux3_regulator_get_voltage_sel(struct regulator_dev *rdev)
516{
517 int ret, val;
518 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
519 u8 regval, regval_expand;
520
521 if (info == NULL) {
522 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
523 return -EINVAL;
524 }
525
526 ret = abx500_get_register_interruptible(info->dev,
527 info->voltage_bank, info->voltage_reg, &regval);
528
529 if (ret < 0) {
530 dev_err(rdev_get_dev(rdev),
531 "couldn't read voltage reg for regulator\n");
532 return ret;
533 }
534
535 ret = abx500_get_register_interruptible(info->dev,
536 info->expand_register.voltage_bank,
537 info->expand_register.voltage_reg, &regval_expand);
538
539 if (ret < 0) {
540 dev_err(rdev_get_dev(rdev),
541 "couldn't read voltage reg for regulator\n");
542 return ret;
543 }
544
545 dev_vdbg(rdev_get_dev(rdev),
546 "%s-get_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
547 " 0x%x\n",
548 info->desc.name, info->voltage_bank, info->voltage_reg,
549 info->voltage_mask, regval);
550 dev_vdbg(rdev_get_dev(rdev),
551 "%s-get_voltage expand (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
552 " 0x%x\n",
553 info->desc.name, info->expand_register.voltage_bank,
554 info->expand_register.voltage_reg,
555 info->expand_register.voltage_mask, regval_expand);
556
557 if (regval_expand&(info->expand_register.voltage_mask))
558 /* Vaux3 has a different layout */
559 val = info->expand_register.voltage_limit;
560 else
561 val = (regval & info->voltage_mask) >> info->voltage_shift;
562
563 return val;
564}
565
Axel Linae713d32012-03-20 09:51:08 +0800566static int ab8500_regulator_set_voltage_sel(struct regulator_dev *rdev,
567 unsigned selector)
Sundar R IYERc789ca22010-07-13 21:48:56 +0530568{
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100569 int ret;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530570 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100571 u8 regval;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530572
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100573 if (info == NULL) {
574 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
Sundar R IYERc789ca22010-07-13 21:48:56 +0530575 return -EINVAL;
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100576 }
Sundar R IYERc789ca22010-07-13 21:48:56 +0530577
Sundar R IYERc789ca22010-07-13 21:48:56 +0530578 /* set the registers for the request */
Linus Walleija0a70142012-08-20 18:41:35 +0200579 regval = (u8)selector << info->voltage_shift;
Mattias Wallin47c16972010-09-10 17:47:56 +0200580 ret = abx500_mask_and_set_register_interruptible(info->dev,
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100581 info->voltage_bank, info->voltage_reg,
582 info->voltage_mask, regval);
Sundar R IYERc789ca22010-07-13 21:48:56 +0530583 if (ret < 0)
584 dev_err(rdev_get_dev(rdev),
585 "couldn't set voltage reg for regulator\n");
586
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100587 dev_vdbg(rdev_get_dev(rdev),
588 "%s-set_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
589 " 0x%x\n",
590 info->desc.name, info->voltage_bank, info->voltage_reg,
591 info->voltage_mask, regval);
592
Sundar R IYERc789ca22010-07-13 21:48:56 +0530593 return ret;
594}
595
Lee Jonesd7607ba2013-04-02 13:24:11 +0100596static int ab8540_aux3_regulator_set_voltage_sel(struct regulator_dev *rdev,
597 unsigned selector)
598{
599 int ret;
600 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
601 u8 regval;
602
603 if (info == NULL) {
604 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
605 return -EINVAL;
606 }
607
608 if (selector >= info->expand_register.voltage_limit) {
609 /* Vaux3 bit4 has different layout */
610 regval = (u8)selector << info->expand_register.voltage_shift;
611 ret = abx500_mask_and_set_register_interruptible(info->dev,
612 info->expand_register.voltage_bank,
613 info->expand_register.voltage_reg,
614 info->expand_register.voltage_mask,
615 regval);
616 } else {
617 /* set the registers for the request */
618 regval = (u8)selector << info->voltage_shift;
619 ret = abx500_mask_and_set_register_interruptible(info->dev,
620 info->voltage_bank, info->voltage_reg,
621 info->voltage_mask, regval);
622 }
623 if (ret < 0)
624 dev_err(rdev_get_dev(rdev),
625 "couldn't set voltage reg for regulator\n");
626
627 dev_vdbg(rdev_get_dev(rdev),
628 "%s-set_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
629 " 0x%x\n",
630 info->desc.name, info->voltage_bank, info->voltage_reg,
631 info->voltage_mask, regval);
632
633 return ret;
634}
635
636static int ab8500_regulator_set_voltage_time_sel(struct regulator_dev *rdev,
637 unsigned int old_sel,
638 unsigned int new_sel)
639{
640 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
641
642 return info->delay;
643}
644
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000645static struct regulator_ops ab8500_regulator_volt_mode_ops = {
646 .enable = ab8500_regulator_enable,
647 .disable = ab8500_regulator_disable,
648 .is_enabled = ab8500_regulator_is_enabled,
649 .get_optimum_mode = ab8500_regulator_get_optimum_mode,
650 .set_mode = ab8500_regulator_set_mode,
651 .get_mode = ab8500_regulator_get_mode,
652 .get_voltage_sel = ab8500_regulator_get_voltage_sel,
653 .set_voltage_sel = ab8500_regulator_set_voltage_sel,
654 .list_voltage = regulator_list_voltage_table,
Sundar R IYERc789ca22010-07-13 21:48:56 +0530655};
656
Lee Jonesd7607ba2013-04-02 13:24:11 +0100657static struct regulator_ops ab8540_aux3_regulator_volt_mode_ops = {
658 .enable = ab8500_regulator_enable,
659 .disable = ab8500_regulator_disable,
660 .get_optimum_mode = ab8500_regulator_get_optimum_mode,
661 .set_mode = ab8500_regulator_set_mode,
662 .get_mode = ab8500_regulator_get_mode,
663 .is_enabled = ab8500_regulator_is_enabled,
664 .get_voltage_sel = ab8540_aux3_regulator_get_voltage_sel,
665 .set_voltage_sel = ab8540_aux3_regulator_set_voltage_sel,
666 .list_voltage = regulator_list_voltage_table,
667 .set_voltage_time_sel = ab8500_regulator_set_voltage_time_sel,
668};
669
Lee Jones8a3b1b82013-04-02 13:24:09 +0100670static struct regulator_ops ab8500_regulator_volt_ops = {
671 .enable = ab8500_regulator_enable,
672 .disable = ab8500_regulator_disable,
673 .is_enabled = ab8500_regulator_is_enabled,
674 .get_voltage_sel = ab8500_regulator_get_voltage_sel,
675 .set_voltage_sel = ab8500_regulator_set_voltage_sel,
676 .list_voltage = regulator_list_voltage_table,
677 .set_voltage_time_sel = ab8500_regulator_set_voltage_time_sel,
678};
679
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000680static struct regulator_ops ab8500_regulator_mode_ops = {
681 .enable = ab8500_regulator_enable,
682 .disable = ab8500_regulator_disable,
683 .is_enabled = ab8500_regulator_is_enabled,
684 .get_optimum_mode = ab8500_regulator_get_optimum_mode,
685 .set_mode = ab8500_regulator_set_mode,
686 .get_mode = ab8500_regulator_get_mode,
Axel Lin5689e832013-03-25 14:59:00 +0800687 .list_voltage = regulator_list_voltage_linear,
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000688};
689
690static struct regulator_ops ab8500_regulator_ops = {
691 .enable = ab8500_regulator_enable,
692 .disable = ab8500_regulator_disable,
693 .is_enabled = ab8500_regulator_is_enabled,
Axel Lin5689e832013-03-25 14:59:00 +0800694 .list_voltage = regulator_list_voltage_linear,
Sundar R IYERc789ca22010-07-13 21:48:56 +0530695};
696
Lee Jones3fe52282013-04-02 13:24:12 +0100697static struct regulator_ops ab8500_regulator_anamic_mode_ops = {
698 .enable = ab8500_regulator_enable,
699 .disable = ab8500_regulator_disable,
700 .is_enabled = ab8500_regulator_is_enabled,
701 .set_mode = ab8500_regulator_set_mode,
702 .get_mode = ab8500_regulator_get_mode,
703 .list_voltage = regulator_list_voltage_table,
704};
705
Lee Jones8e6a8d72013-03-28 16:11:11 +0000706/* AB8500 regulator information */
Bengt Jonsson6909b452010-12-10 11:08:47 +0100707static struct ab8500_regulator_info
708 ab8500_regulator_info[AB8500_NUM_REGULATORS] = {
Sundar R IYERc789ca22010-07-13 21:48:56 +0530709 /*
Bengt Jonssone1159e62010-12-10 11:08:44 +0100710 * Variable Voltage Regulators
711 * name, min mV, max mV,
712 * update bank, reg, mask, enable val
Axel Linec1cc4d2012-05-20 10:33:35 +0800713 * volt bank, reg, mask
Sundar R IYERc789ca22010-07-13 21:48:56 +0530714 */
Bengt Jonsson6909b452010-12-10 11:08:47 +0100715 [AB8500_LDO_AUX1] = {
716 .desc = {
717 .name = "LDO-AUX1",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000718 .ops = &ab8500_regulator_volt_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100719 .type = REGULATOR_VOLTAGE,
720 .id = AB8500_LDO_AUX1,
721 .owner = THIS_MODULE,
722 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Axel Linec1cc4d2012-05-20 10:33:35 +0800723 .volt_table = ldo_vauxn_voltages,
Axel Lin530158b2013-03-27 17:47:22 +0800724 .enable_time = 200,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100725 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000726 .load_lp_uA = 5000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100727 .update_bank = 0x04,
728 .update_reg = 0x09,
729 .update_mask = 0x03,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000730 .update_val = 0x01,
731 .update_val_idle = 0x03,
732 .update_val_normal = 0x01,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100733 .voltage_bank = 0x04,
734 .voltage_reg = 0x1f,
735 .voltage_mask = 0x0f,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100736 },
737 [AB8500_LDO_AUX2] = {
738 .desc = {
739 .name = "LDO-AUX2",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000740 .ops = &ab8500_regulator_volt_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100741 .type = REGULATOR_VOLTAGE,
742 .id = AB8500_LDO_AUX2,
743 .owner = THIS_MODULE,
744 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Axel Linec1cc4d2012-05-20 10:33:35 +0800745 .volt_table = ldo_vauxn_voltages,
Axel Lin530158b2013-03-27 17:47:22 +0800746 .enable_time = 200,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100747 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000748 .load_lp_uA = 5000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100749 .update_bank = 0x04,
750 .update_reg = 0x09,
751 .update_mask = 0x0c,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000752 .update_val = 0x04,
753 .update_val_idle = 0x0c,
754 .update_val_normal = 0x04,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100755 .voltage_bank = 0x04,
756 .voltage_reg = 0x20,
757 .voltage_mask = 0x0f,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100758 },
759 [AB8500_LDO_AUX3] = {
760 .desc = {
761 .name = "LDO-AUX3",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000762 .ops = &ab8500_regulator_volt_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100763 .type = REGULATOR_VOLTAGE,
764 .id = AB8500_LDO_AUX3,
765 .owner = THIS_MODULE,
766 .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages),
Axel Linec1cc4d2012-05-20 10:33:35 +0800767 .volt_table = ldo_vaux3_voltages,
Axel Lin530158b2013-03-27 17:47:22 +0800768 .enable_time = 450,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100769 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000770 .load_lp_uA = 5000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100771 .update_bank = 0x04,
772 .update_reg = 0x0a,
773 .update_mask = 0x03,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000774 .update_val = 0x01,
775 .update_val_idle = 0x03,
776 .update_val_normal = 0x01,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100777 .voltage_bank = 0x04,
778 .voltage_reg = 0x21,
779 .voltage_mask = 0x07,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100780 },
781 [AB8500_LDO_INTCORE] = {
782 .desc = {
783 .name = "LDO-INTCORE",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000784 .ops = &ab8500_regulator_volt_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100785 .type = REGULATOR_VOLTAGE,
786 .id = AB8500_LDO_INTCORE,
787 .owner = THIS_MODULE,
788 .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
Axel Linec1cc4d2012-05-20 10:33:35 +0800789 .volt_table = ldo_vintcore_voltages,
Axel Lin530158b2013-03-27 17:47:22 +0800790 .enable_time = 750,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100791 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000792 .load_lp_uA = 5000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100793 .update_bank = 0x03,
794 .update_reg = 0x80,
795 .update_mask = 0x44,
Lee Jonescc40dc22013-03-21 15:59:41 +0000796 .update_val = 0x44,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000797 .update_val_idle = 0x44,
798 .update_val_normal = 0x04,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100799 .voltage_bank = 0x03,
800 .voltage_reg = 0x80,
801 .voltage_mask = 0x38,
Linus Walleija0a70142012-08-20 18:41:35 +0200802 .voltage_shift = 3,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100803 },
Sundar R IYERc789ca22010-07-13 21:48:56 +0530804
805 /*
Bengt Jonssone1159e62010-12-10 11:08:44 +0100806 * Fixed Voltage Regulators
807 * name, fixed mV,
808 * update bank, reg, mask, enable val
Sundar R IYERc789ca22010-07-13 21:48:56 +0530809 */
Bengt Jonsson6909b452010-12-10 11:08:47 +0100810 [AB8500_LDO_TVOUT] = {
811 .desc = {
812 .name = "LDO-TVOUT",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000813 .ops = &ab8500_regulator_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100814 .type = REGULATOR_VOLTAGE,
815 .id = AB8500_LDO_TVOUT,
816 .owner = THIS_MODULE,
817 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +0000818 .volt_table = fixed_2000000_voltage,
Lee Jonesed3c1382013-03-28 16:11:12 +0000819 .enable_time = 500,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100820 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000821 .load_lp_uA = 1000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100822 .update_bank = 0x03,
823 .update_reg = 0x80,
824 .update_mask = 0x82,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000825 .update_val = 0x02,
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000826 .update_val_idle = 0x82,
827 .update_val_normal = 0x02,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100828 },
829 [AB8500_LDO_AUDIO] = {
830 .desc = {
831 .name = "LDO-AUDIO",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000832 .ops = &ab8500_regulator_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100833 .type = REGULATOR_VOLTAGE,
834 .id = AB8500_LDO_AUDIO,
835 .owner = THIS_MODULE,
836 .n_voltages = 1,
Axel Lin530158b2013-03-27 17:47:22 +0800837 .enable_time = 140,
Lee Jonesb080c782013-03-28 16:11:17 +0000838 .volt_table = fixed_2000000_voltage,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100839 },
Bengt Jonsson6909b452010-12-10 11:08:47 +0100840 .update_bank = 0x03,
841 .update_reg = 0x83,
842 .update_mask = 0x02,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000843 .update_val = 0x02,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100844 },
845 [AB8500_LDO_ANAMIC1] = {
846 .desc = {
847 .name = "LDO-ANAMIC1",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000848 .ops = &ab8500_regulator_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100849 .type = REGULATOR_VOLTAGE,
850 .id = AB8500_LDO_ANAMIC1,
851 .owner = THIS_MODULE,
852 .n_voltages = 1,
Axel Lin530158b2013-03-27 17:47:22 +0800853 .enable_time = 500,
Lee Jonesb080c782013-03-28 16:11:17 +0000854 .volt_table = fixed_2050000_voltage,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100855 },
Bengt Jonsson6909b452010-12-10 11:08:47 +0100856 .update_bank = 0x03,
857 .update_reg = 0x83,
858 .update_mask = 0x08,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000859 .update_val = 0x08,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100860 },
861 [AB8500_LDO_ANAMIC2] = {
862 .desc = {
863 .name = "LDO-ANAMIC2",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000864 .ops = &ab8500_regulator_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100865 .type = REGULATOR_VOLTAGE,
866 .id = AB8500_LDO_ANAMIC2,
867 .owner = THIS_MODULE,
868 .n_voltages = 1,
Axel Lin530158b2013-03-27 17:47:22 +0800869 .enable_time = 500,
Lee Jonesb080c782013-03-28 16:11:17 +0000870 .volt_table = fixed_2050000_voltage,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100871 },
Bengt Jonsson6909b452010-12-10 11:08:47 +0100872 .update_bank = 0x03,
873 .update_reg = 0x83,
874 .update_mask = 0x10,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000875 .update_val = 0x10,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100876 },
877 [AB8500_LDO_DMIC] = {
878 .desc = {
879 .name = "LDO-DMIC",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000880 .ops = &ab8500_regulator_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100881 .type = REGULATOR_VOLTAGE,
882 .id = AB8500_LDO_DMIC,
883 .owner = THIS_MODULE,
884 .n_voltages = 1,
Axel Lin530158b2013-03-27 17:47:22 +0800885 .enable_time = 420,
Lee Jonesb080c782013-03-28 16:11:17 +0000886 .volt_table = fixed_1800000_voltage,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100887 },
Bengt Jonsson6909b452010-12-10 11:08:47 +0100888 .update_bank = 0x03,
889 .update_reg = 0x83,
890 .update_mask = 0x04,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000891 .update_val = 0x04,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100892 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000893
894 /*
895 * Regulators with fixed voltage and normal/idle modes
896 */
Bengt Jonsson6909b452010-12-10 11:08:47 +0100897 [AB8500_LDO_ANA] = {
898 .desc = {
899 .name = "LDO-ANA",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000900 .ops = &ab8500_regulator_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100901 .type = REGULATOR_VOLTAGE,
902 .id = AB8500_LDO_ANA,
903 .owner = THIS_MODULE,
904 .n_voltages = 1,
Axel Lin530158b2013-03-27 17:47:22 +0800905 .enable_time = 140,
Lee Jonesb080c782013-03-28 16:11:17 +0000906 .volt_table = fixed_1200000_voltage,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100907 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000908 .load_lp_uA = 1000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100909 .update_bank = 0x04,
910 .update_reg = 0x06,
911 .update_mask = 0x0c,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000912 .update_val = 0x04,
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000913 .update_val_idle = 0x0c,
914 .update_val_normal = 0x04,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100915 },
Lee Jones8e6a8d72013-03-28 16:11:11 +0000916};
Bengt Jonsson6909b452010-12-10 11:08:47 +0100917
Lee Jones547f3842013-03-28 16:11:14 +0000918/* AB8505 regulator information */
919static struct ab8500_regulator_info
920 ab8505_regulator_info[AB8505_NUM_REGULATORS] = {
921 /*
922 * Variable Voltage Regulators
923 * name, min mV, max mV,
924 * update bank, reg, mask, enable val
925 * volt bank, reg, mask, table, table length
926 */
927 [AB8505_LDO_AUX1] = {
928 .desc = {
929 .name = "LDO-AUX1",
930 .ops = &ab8500_regulator_volt_mode_ops,
931 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +0100932 .id = AB8505_LDO_AUX1,
Lee Jones547f3842013-03-28 16:11:14 +0000933 .owner = THIS_MODULE,
934 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +0000935 .volt_table = ldo_vauxn_voltages,
Lee Jones547f3842013-03-28 16:11:14 +0000936 },
Lee Jones547f3842013-03-28 16:11:14 +0000937 .load_lp_uA = 5000,
938 .update_bank = 0x04,
939 .update_reg = 0x09,
940 .update_mask = 0x03,
941 .update_val = 0x01,
942 .update_val_idle = 0x03,
943 .update_val_normal = 0x01,
944 .voltage_bank = 0x04,
945 .voltage_reg = 0x1f,
946 .voltage_mask = 0x0f,
Lee Jones547f3842013-03-28 16:11:14 +0000947 },
948 [AB8505_LDO_AUX2] = {
949 .desc = {
950 .name = "LDO-AUX2",
951 .ops = &ab8500_regulator_volt_mode_ops,
952 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +0100953 .id = AB8505_LDO_AUX2,
Lee Jones547f3842013-03-28 16:11:14 +0000954 .owner = THIS_MODULE,
955 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +0000956 .volt_table = ldo_vauxn_voltages,
Lee Jones547f3842013-03-28 16:11:14 +0000957 },
Lee Jones547f3842013-03-28 16:11:14 +0000958 .load_lp_uA = 5000,
959 .update_bank = 0x04,
960 .update_reg = 0x09,
961 .update_mask = 0x0c,
962 .update_val = 0x04,
963 .update_val_idle = 0x0c,
964 .update_val_normal = 0x04,
965 .voltage_bank = 0x04,
966 .voltage_reg = 0x20,
967 .voltage_mask = 0x0f,
Lee Jones547f3842013-03-28 16:11:14 +0000968 },
969 [AB8505_LDO_AUX3] = {
970 .desc = {
971 .name = "LDO-AUX3",
972 .ops = &ab8500_regulator_volt_mode_ops,
973 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +0100974 .id = AB8505_LDO_AUX3,
Lee Jones547f3842013-03-28 16:11:14 +0000975 .owner = THIS_MODULE,
976 .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +0000977 .volt_table = ldo_vaux3_voltages,
Lee Jones547f3842013-03-28 16:11:14 +0000978 },
Lee Jones547f3842013-03-28 16:11:14 +0000979 .load_lp_uA = 5000,
980 .update_bank = 0x04,
981 .update_reg = 0x0a,
982 .update_mask = 0x03,
983 .update_val = 0x01,
984 .update_val_idle = 0x03,
985 .update_val_normal = 0x01,
986 .voltage_bank = 0x04,
987 .voltage_reg = 0x21,
988 .voltage_mask = 0x07,
Lee Jones547f3842013-03-28 16:11:14 +0000989 },
990 [AB8505_LDO_AUX4] = {
991 .desc = {
992 .name = "LDO-AUX4",
993 .ops = &ab8500_regulator_volt_mode_ops,
994 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +0100995 .id = AB8505_LDO_AUX4,
Lee Jones547f3842013-03-28 16:11:14 +0000996 .owner = THIS_MODULE,
997 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +0000998 .volt_table = ldo_vauxn_voltages,
Lee Jones547f3842013-03-28 16:11:14 +0000999 },
Lee Jones547f3842013-03-28 16:11:14 +00001000 .load_lp_uA = 5000,
1001 /* values for Vaux4Regu register */
1002 .update_bank = 0x04,
1003 .update_reg = 0x2e,
1004 .update_mask = 0x03,
1005 .update_val = 0x01,
1006 .update_val_idle = 0x03,
1007 .update_val_normal = 0x01,
1008 /* values for Vaux4SEL register */
1009 .voltage_bank = 0x04,
1010 .voltage_reg = 0x2f,
1011 .voltage_mask = 0x0f,
Lee Jones547f3842013-03-28 16:11:14 +00001012 },
1013 [AB8505_LDO_AUX5] = {
1014 .desc = {
1015 .name = "LDO-AUX5",
1016 .ops = &ab8500_regulator_volt_mode_ops,
1017 .type = REGULATOR_VOLTAGE,
1018 .id = AB8505_LDO_AUX5,
1019 .owner = THIS_MODULE,
1020 .n_voltages = ARRAY_SIZE(ldo_vaux56_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001021 .volt_table = ldo_vaux56_voltages,
Lee Jones547f3842013-03-28 16:11:14 +00001022 },
Lee Jones547f3842013-03-28 16:11:14 +00001023 .load_lp_uA = 2000,
1024 /* values for CtrlVaux5 register */
1025 .update_bank = 0x01,
1026 .update_reg = 0x55,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001027 .update_mask = 0x18,
1028 .update_val = 0x10,
1029 .update_val_idle = 0x18,
1030 .update_val_normal = 0x10,
Lee Jones547f3842013-03-28 16:11:14 +00001031 .voltage_bank = 0x01,
1032 .voltage_reg = 0x55,
1033 .voltage_mask = 0x07,
Lee Jones547f3842013-03-28 16:11:14 +00001034 },
1035 [AB8505_LDO_AUX6] = {
1036 .desc = {
1037 .name = "LDO-AUX6",
1038 .ops = &ab8500_regulator_volt_mode_ops,
1039 .type = REGULATOR_VOLTAGE,
1040 .id = AB8505_LDO_AUX6,
1041 .owner = THIS_MODULE,
1042 .n_voltages = ARRAY_SIZE(ldo_vaux56_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001043 .volt_table = ldo_vaux56_voltages,
Lee Jones547f3842013-03-28 16:11:14 +00001044 },
Lee Jones547f3842013-03-28 16:11:14 +00001045 .load_lp_uA = 2000,
1046 /* values for CtrlVaux6 register */
1047 .update_bank = 0x01,
1048 .update_reg = 0x56,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001049 .update_mask = 0x18,
1050 .update_val = 0x10,
1051 .update_val_idle = 0x18,
1052 .update_val_normal = 0x10,
Lee Jones547f3842013-03-28 16:11:14 +00001053 .voltage_bank = 0x01,
1054 .voltage_reg = 0x56,
1055 .voltage_mask = 0x07,
Lee Jones547f3842013-03-28 16:11:14 +00001056 },
1057 [AB8505_LDO_INTCORE] = {
1058 .desc = {
1059 .name = "LDO-INTCORE",
1060 .ops = &ab8500_regulator_volt_mode_ops,
1061 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001062 .id = AB8505_LDO_INTCORE,
Lee Jones547f3842013-03-28 16:11:14 +00001063 .owner = THIS_MODULE,
1064 .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001065 .volt_table = ldo_vintcore_voltages,
Lee Jones547f3842013-03-28 16:11:14 +00001066 },
Lee Jones547f3842013-03-28 16:11:14 +00001067 .load_lp_uA = 5000,
1068 .update_bank = 0x03,
1069 .update_reg = 0x80,
1070 .update_mask = 0x44,
1071 .update_val = 0x04,
1072 .update_val_idle = 0x44,
1073 .update_val_normal = 0x04,
1074 .voltage_bank = 0x03,
1075 .voltage_reg = 0x80,
1076 .voltage_mask = 0x38,
Lee Jones547f3842013-03-28 16:11:14 +00001077 .voltage_shift = 3,
1078 },
1079
1080 /*
1081 * Fixed Voltage Regulators
1082 * name, fixed mV,
1083 * update bank, reg, mask, enable val
1084 */
1085 [AB8505_LDO_ADC] = {
1086 .desc = {
1087 .name = "LDO-ADC",
1088 .ops = &ab8500_regulator_mode_ops,
1089 .type = REGULATOR_VOLTAGE,
1090 .id = AB8505_LDO_ADC,
1091 .owner = THIS_MODULE,
1092 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001093 .volt_table = fixed_2000000_voltage,
Lee Jones547f3842013-03-28 16:11:14 +00001094 },
1095 .delay = 10000,
Lee Jones547f3842013-03-28 16:11:14 +00001096 .load_lp_uA = 1000,
1097 .update_bank = 0x03,
1098 .update_reg = 0x80,
1099 .update_mask = 0x82,
1100 .update_val = 0x02,
1101 .update_val_idle = 0x82,
1102 .update_val_normal = 0x02,
1103 },
1104 [AB8505_LDO_USB] = {
1105 .desc = {
1106 .name = "LDO-USB",
1107 .ops = &ab8500_regulator_mode_ops,
1108 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001109 .id = AB8505_LDO_USB,
Lee Jones547f3842013-03-28 16:11:14 +00001110 .owner = THIS_MODULE,
1111 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001112 .volt_table = fixed_3300000_voltage,
Lee Jones547f3842013-03-28 16:11:14 +00001113 },
Lee Jones547f3842013-03-28 16:11:14 +00001114 .update_bank = 0x03,
1115 .update_reg = 0x82,
1116 .update_mask = 0x03,
1117 .update_val = 0x01,
1118 .update_val_idle = 0x03,
1119 .update_val_normal = 0x01,
1120 },
1121 [AB8505_LDO_AUDIO] = {
1122 .desc = {
1123 .name = "LDO-AUDIO",
Lee Jones8a3b1b82013-04-02 13:24:09 +01001124 .ops = &ab8500_regulator_volt_ops,
Lee Jones547f3842013-03-28 16:11:14 +00001125 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001126 .id = AB8505_LDO_AUDIO,
Lee Jones547f3842013-03-28 16:11:14 +00001127 .owner = THIS_MODULE,
Lee Jones8a3b1b82013-04-02 13:24:09 +01001128 .n_voltages = ARRAY_SIZE(ldo_vaudio_voltages),
1129 .volt_table = ldo_vaudio_voltages,
Lee Jones547f3842013-03-28 16:11:14 +00001130 },
Lee Jones547f3842013-03-28 16:11:14 +00001131 .update_bank = 0x03,
1132 .update_reg = 0x83,
1133 .update_mask = 0x02,
1134 .update_val = 0x02,
Lee Jones8a3b1b82013-04-02 13:24:09 +01001135 .voltage_bank = 0x01,
1136 .voltage_reg = 0x57,
1137 .voltage_mask = 0x7,
1138 .voltage_shift = 4,
1139 .voltages = ldo_vaudio_voltages,
1140 .voltages_len = ARRAY_SIZE(ldo_vaudio_voltages),
Lee Jones547f3842013-03-28 16:11:14 +00001141 },
1142 [AB8505_LDO_ANAMIC1] = {
1143 .desc = {
1144 .name = "LDO-ANAMIC1",
Lee Jones3fe52282013-04-02 13:24:12 +01001145 .ops = &ab8500_regulator_anamic_mode_ops,
Lee Jones547f3842013-03-28 16:11:14 +00001146 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001147 .id = AB8505_LDO_ANAMIC1,
Lee Jones547f3842013-03-28 16:11:14 +00001148 .owner = THIS_MODULE,
1149 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001150 .volt_table = fixed_2050000_voltage,
Lee Jones547f3842013-03-28 16:11:14 +00001151 },
Lee Jones4c84b4d2013-04-02 13:24:13 +01001152 .shared_mode = &ldo_anamic1_shared,
Lee Jones547f3842013-03-28 16:11:14 +00001153 .update_bank = 0x03,
1154 .update_reg = 0x83,
1155 .update_mask = 0x08,
1156 .update_val = 0x08,
Lee Jones3fe52282013-04-02 13:24:12 +01001157 .mode_bank = 0x01,
1158 .mode_reg = 0x54,
1159 .mode_mask = 0x04,
1160 .mode_val_idle = 0x04,
1161 .mode_val_normal = 0x00,
Lee Jones547f3842013-03-28 16:11:14 +00001162 },
1163 [AB8505_LDO_ANAMIC2] = {
1164 .desc = {
1165 .name = "LDO-ANAMIC2",
Lee Jones3fe52282013-04-02 13:24:12 +01001166 .ops = &ab8500_regulator_anamic_mode_ops,
Lee Jones547f3842013-03-28 16:11:14 +00001167 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001168 .id = AB8505_LDO_ANAMIC2,
Lee Jones547f3842013-03-28 16:11:14 +00001169 .owner = THIS_MODULE,
1170 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001171 .volt_table = fixed_2050000_voltage,
Lee Jones547f3842013-03-28 16:11:14 +00001172 },
Lee Jones3fe52282013-04-02 13:24:12 +01001173 .shared_mode = &ldo_anamic2_shared,
Lee Jones547f3842013-03-28 16:11:14 +00001174 .update_bank = 0x03,
1175 .update_reg = 0x83,
1176 .update_mask = 0x10,
1177 .update_val = 0x10,
Lee Jones3fe52282013-04-02 13:24:12 +01001178 .mode_bank = 0x01,
1179 .mode_reg = 0x54,
1180 .mode_mask = 0x04,
1181 .mode_val_idle = 0x04,
1182 .mode_val_normal = 0x00,
Lee Jones547f3842013-03-28 16:11:14 +00001183 },
1184 [AB8505_LDO_AUX8] = {
1185 .desc = {
1186 .name = "LDO-AUX8",
1187 .ops = &ab8500_regulator_ops,
1188 .type = REGULATOR_VOLTAGE,
1189 .id = AB8505_LDO_AUX8,
1190 .owner = THIS_MODULE,
1191 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001192 .volt_table = fixed_1800000_voltage,
Lee Jones547f3842013-03-28 16:11:14 +00001193 },
Lee Jones547f3842013-03-28 16:11:14 +00001194 .update_bank = 0x03,
1195 .update_reg = 0x83,
1196 .update_mask = 0x04,
1197 .update_val = 0x04,
1198 },
1199 /*
1200 * Regulators with fixed voltage and normal/idle modes
1201 */
1202 [AB8505_LDO_ANA] = {
1203 .desc = {
1204 .name = "LDO-ANA",
Lee Jones8a3b1b82013-04-02 13:24:09 +01001205 .ops = &ab8500_regulator_volt_mode_ops,
Lee Jones547f3842013-03-28 16:11:14 +00001206 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001207 .id = AB8505_LDO_ANA,
Lee Jones547f3842013-03-28 16:11:14 +00001208 .owner = THIS_MODULE,
Lee Jones8a3b1b82013-04-02 13:24:09 +01001209 .n_voltages = ARRAY_SIZE(ldo_vana_voltages),
1210 .volt_table = ldo_vana_voltages,
Lee Jones547f3842013-03-28 16:11:14 +00001211 },
Lee Jones547f3842013-03-28 16:11:14 +00001212 .load_lp_uA = 1000,
1213 .update_bank = 0x04,
1214 .update_reg = 0x06,
1215 .update_mask = 0x0c,
1216 .update_val = 0x04,
1217 .update_val_idle = 0x0c,
1218 .update_val_normal = 0x04,
Lee Jones8a3b1b82013-04-02 13:24:09 +01001219 .voltage_bank = 0x04,
1220 .voltage_reg = 0x29,
1221 .voltage_mask = 0x7,
1222 .voltages = ldo_vana_voltages,
1223 .voltages_len = ARRAY_SIZE(ldo_vana_voltages),
Lee Jones547f3842013-03-28 16:11:14 +00001224 },
1225};
1226
Lee Jones8e6a8d72013-03-28 16:11:11 +00001227/* AB9540 regulator information */
1228static struct ab8500_regulator_info
1229 ab9540_regulator_info[AB9540_NUM_REGULATORS] = {
1230 /*
1231 * Variable Voltage Regulators
1232 * name, min mV, max mV,
1233 * update bank, reg, mask, enable val
1234 * volt bank, reg, mask, table, table length
1235 */
1236 [AB9540_LDO_AUX1] = {
1237 .desc = {
1238 .name = "LDO-AUX1",
1239 .ops = &ab8500_regulator_volt_mode_ops,
1240 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001241 .id = AB9540_LDO_AUX1,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001242 .owner = THIS_MODULE,
1243 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001244 .volt_table = ldo_vauxn_voltages,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001245 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001246 .load_lp_uA = 5000,
1247 .update_bank = 0x04,
1248 .update_reg = 0x09,
1249 .update_mask = 0x03,
1250 .update_val = 0x01,
1251 .update_val_idle = 0x03,
1252 .update_val_normal = 0x01,
1253 .voltage_bank = 0x04,
1254 .voltage_reg = 0x1f,
1255 .voltage_mask = 0x0f,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001256 },
1257 [AB9540_LDO_AUX2] = {
1258 .desc = {
1259 .name = "LDO-AUX2",
1260 .ops = &ab8500_regulator_volt_mode_ops,
1261 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001262 .id = AB9540_LDO_AUX2,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001263 .owner = THIS_MODULE,
1264 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001265 .volt_table = ldo_vauxn_voltages,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001266 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001267 .load_lp_uA = 5000,
1268 .update_bank = 0x04,
1269 .update_reg = 0x09,
1270 .update_mask = 0x0c,
1271 .update_val = 0x04,
1272 .update_val_idle = 0x0c,
1273 .update_val_normal = 0x04,
1274 .voltage_bank = 0x04,
1275 .voltage_reg = 0x20,
1276 .voltage_mask = 0x0f,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001277 },
1278 [AB9540_LDO_AUX3] = {
1279 .desc = {
1280 .name = "LDO-AUX3",
1281 .ops = &ab8500_regulator_volt_mode_ops,
1282 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001283 .id = AB9540_LDO_AUX3,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001284 .owner = THIS_MODULE,
1285 .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001286 .volt_table = ldo_vaux3_voltages,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001287 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001288 .load_lp_uA = 5000,
1289 .update_bank = 0x04,
1290 .update_reg = 0x0a,
1291 .update_mask = 0x03,
1292 .update_val = 0x01,
1293 .update_val_idle = 0x03,
1294 .update_val_normal = 0x01,
1295 .voltage_bank = 0x04,
1296 .voltage_reg = 0x21,
1297 .voltage_mask = 0x07,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001298 },
1299 [AB9540_LDO_AUX4] = {
1300 .desc = {
1301 .name = "LDO-AUX4",
1302 .ops = &ab8500_regulator_volt_mode_ops,
1303 .type = REGULATOR_VOLTAGE,
1304 .id = AB9540_LDO_AUX4,
1305 .owner = THIS_MODULE,
1306 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001307 .volt_table = ldo_vauxn_voltages,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001308 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001309 .load_lp_uA = 5000,
1310 /* values for Vaux4Regu register */
1311 .update_bank = 0x04,
1312 .update_reg = 0x2e,
1313 .update_mask = 0x03,
1314 .update_val = 0x01,
1315 .update_val_idle = 0x03,
1316 .update_val_normal = 0x01,
1317 /* values for Vaux4SEL register */
1318 .voltage_bank = 0x04,
1319 .voltage_reg = 0x2f,
1320 .voltage_mask = 0x0f,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001321 },
1322 [AB9540_LDO_INTCORE] = {
1323 .desc = {
1324 .name = "LDO-INTCORE",
1325 .ops = &ab8500_regulator_volt_mode_ops,
1326 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001327 .id = AB9540_LDO_INTCORE,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001328 .owner = THIS_MODULE,
1329 .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001330 .volt_table = ldo_vintcore_voltages,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001331 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001332 .load_lp_uA = 5000,
1333 .update_bank = 0x03,
1334 .update_reg = 0x80,
1335 .update_mask = 0x44,
1336 .update_val = 0x44,
1337 .update_val_idle = 0x44,
1338 .update_val_normal = 0x04,
1339 .voltage_bank = 0x03,
1340 .voltage_reg = 0x80,
1341 .voltage_mask = 0x38,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001342 .voltage_shift = 3,
1343 },
Bengt Jonsson6909b452010-12-10 11:08:47 +01001344
Lee Jones8e6a8d72013-03-28 16:11:11 +00001345 /*
1346 * Fixed Voltage Regulators
1347 * name, fixed mV,
1348 * update bank, reg, mask, enable val
1349 */
1350 [AB9540_LDO_TVOUT] = {
1351 .desc = {
1352 .name = "LDO-TVOUT",
1353 .ops = &ab8500_regulator_mode_ops,
1354 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001355 .id = AB9540_LDO_TVOUT,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001356 .owner = THIS_MODULE,
1357 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001358 .volt_table = fixed_2000000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001359 },
1360 .delay = 10000,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001361 .load_lp_uA = 1000,
1362 .update_bank = 0x03,
1363 .update_reg = 0x80,
1364 .update_mask = 0x82,
1365 .update_val = 0x02,
1366 .update_val_idle = 0x82,
1367 .update_val_normal = 0x02,
1368 },
1369 [AB9540_LDO_USB] = {
1370 .desc = {
1371 .name = "LDO-USB",
1372 .ops = &ab8500_regulator_ops,
1373 .type = REGULATOR_VOLTAGE,
1374 .id = AB9540_LDO_USB,
1375 .owner = THIS_MODULE,
1376 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001377 .volt_table = fixed_3300000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001378 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001379 .update_bank = 0x03,
1380 .update_reg = 0x82,
1381 .update_mask = 0x03,
1382 .update_val = 0x01,
1383 .update_val_idle = 0x03,
1384 .update_val_normal = 0x01,
1385 },
1386 [AB9540_LDO_AUDIO] = {
1387 .desc = {
1388 .name = "LDO-AUDIO",
1389 .ops = &ab8500_regulator_ops,
1390 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001391 .id = AB9540_LDO_AUDIO,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001392 .owner = THIS_MODULE,
1393 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001394 .volt_table = fixed_2000000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001395 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001396 .update_bank = 0x03,
1397 .update_reg = 0x83,
1398 .update_mask = 0x02,
1399 .update_val = 0x02,
1400 },
1401 [AB9540_LDO_ANAMIC1] = {
1402 .desc = {
1403 .name = "LDO-ANAMIC1",
1404 .ops = &ab8500_regulator_ops,
1405 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001406 .id = AB9540_LDO_ANAMIC1,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001407 .owner = THIS_MODULE,
1408 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001409 .volt_table = fixed_2050000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001410 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001411 .update_bank = 0x03,
1412 .update_reg = 0x83,
1413 .update_mask = 0x08,
1414 .update_val = 0x08,
1415 },
1416 [AB9540_LDO_ANAMIC2] = {
1417 .desc = {
1418 .name = "LDO-ANAMIC2",
1419 .ops = &ab8500_regulator_ops,
1420 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001421 .id = AB9540_LDO_ANAMIC2,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001422 .owner = THIS_MODULE,
1423 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001424 .volt_table = fixed_2050000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001425 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001426 .update_bank = 0x03,
1427 .update_reg = 0x83,
1428 .update_mask = 0x10,
1429 .update_val = 0x10,
1430 },
1431 [AB9540_LDO_DMIC] = {
1432 .desc = {
1433 .name = "LDO-DMIC",
1434 .ops = &ab8500_regulator_ops,
1435 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001436 .id = AB9540_LDO_DMIC,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001437 .owner = THIS_MODULE,
1438 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001439 .volt_table = fixed_1800000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001440 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001441 .update_bank = 0x03,
1442 .update_reg = 0x83,
1443 .update_mask = 0x04,
1444 .update_val = 0x04,
1445 },
1446
1447 /*
1448 * Regulators with fixed voltage and normal/idle modes
1449 */
1450 [AB9540_LDO_ANA] = {
1451 .desc = {
1452 .name = "LDO-ANA",
1453 .ops = &ab8500_regulator_mode_ops,
1454 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001455 .id = AB9540_LDO_ANA,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001456 .owner = THIS_MODULE,
1457 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001458 .volt_table = fixed_1200000_voltage,
Lee Jones8e6a8d72013-03-28 16:11:11 +00001459 },
Lee Jones8e6a8d72013-03-28 16:11:11 +00001460 .load_lp_uA = 1000,
1461 .update_bank = 0x04,
1462 .update_reg = 0x06,
1463 .update_mask = 0x0c,
1464 .update_val = 0x08,
1465 .update_val_idle = 0x0c,
1466 .update_val_normal = 0x08,
1467 },
Sundar R IYERc789ca22010-07-13 21:48:56 +05301468};
1469
Lee Jonesae0a9a32013-03-28 16:11:16 +00001470/* AB8540 regulator information */
1471static struct ab8500_regulator_info
1472 ab8540_regulator_info[AB8540_NUM_REGULATORS] = {
1473 /*
1474 * Variable Voltage Regulators
1475 * name, min mV, max mV,
1476 * update bank, reg, mask, enable val
1477 * volt bank, reg, mask, table, table length
1478 */
1479 [AB8540_LDO_AUX1] = {
1480 .desc = {
1481 .name = "LDO-AUX1",
1482 .ops = &ab8500_regulator_volt_mode_ops,
1483 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001484 .id = AB8540_LDO_AUX1,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001485 .owner = THIS_MODULE,
1486 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001487 .volt_table = ldo_vauxn_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001488 },
1489 .load_lp_uA = 5000,
1490 .update_bank = 0x04,
1491 .update_reg = 0x09,
1492 .update_mask = 0x03,
1493 .update_val = 0x01,
1494 .update_val_idle = 0x03,
1495 .update_val_normal = 0x01,
1496 .voltage_bank = 0x04,
1497 .voltage_reg = 0x1f,
1498 .voltage_mask = 0x0f,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001499 },
1500 [AB8540_LDO_AUX2] = {
1501 .desc = {
1502 .name = "LDO-AUX2",
1503 .ops = &ab8500_regulator_volt_mode_ops,
1504 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001505 .id = AB8540_LDO_AUX2,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001506 .owner = THIS_MODULE,
1507 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001508 .volt_table = ldo_vauxn_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001509 },
1510 .load_lp_uA = 5000,
1511 .update_bank = 0x04,
1512 .update_reg = 0x09,
1513 .update_mask = 0x0c,
1514 .update_val = 0x04,
1515 .update_val_idle = 0x0c,
1516 .update_val_normal = 0x04,
1517 .voltage_bank = 0x04,
1518 .voltage_reg = 0x20,
1519 .voltage_mask = 0x0f,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001520 },
1521 [AB8540_LDO_AUX3] = {
1522 .desc = {
1523 .name = "LDO-AUX3",
Lee Jonesd7607ba2013-04-02 13:24:11 +01001524 .ops = &ab8540_aux3_regulator_volt_mode_ops,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001525 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001526 .id = AB8540_LDO_AUX3,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001527 .owner = THIS_MODULE,
1528 .n_voltages = ARRAY_SIZE(ldo_vaux3_ab8540_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001529 .volt_table = ldo_vaux3_ab8540_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001530 },
1531 .load_lp_uA = 5000,
1532 .update_bank = 0x04,
1533 .update_reg = 0x0a,
1534 .update_mask = 0x03,
1535 .update_val = 0x01,
1536 .update_val_idle = 0x03,
1537 .update_val_normal = 0x01,
1538 .voltage_bank = 0x04,
1539 .voltage_reg = 0x21,
1540 .voltage_mask = 0x07,
Lee Jonesd7607ba2013-04-02 13:24:11 +01001541 .expand_register = {
1542 .voltage_limit = 8,
1543 .voltage_bank = 0x04,
1544 .voltage_reg = 0x01,
1545 .voltage_mask = 0x10,
1546 .voltage_shift = 1,
1547 }
Lee Jonesae0a9a32013-03-28 16:11:16 +00001548 },
1549 [AB8540_LDO_AUX4] = {
1550 .desc = {
1551 .name = "LDO-AUX4",
1552 .ops = &ab8500_regulator_volt_mode_ops,
1553 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001554 .id = AB8540_LDO_AUX4,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001555 .owner = THIS_MODULE,
1556 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001557 .volt_table = ldo_vauxn_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001558 },
1559 .load_lp_uA = 5000,
1560 /* values for Vaux4Regu register */
1561 .update_bank = 0x04,
1562 .update_reg = 0x2e,
1563 .update_mask = 0x03,
1564 .update_val = 0x01,
1565 .update_val_idle = 0x03,
1566 .update_val_normal = 0x01,
1567 /* values for Vaux4SEL register */
1568 .voltage_bank = 0x04,
1569 .voltage_reg = 0x2f,
1570 .voltage_mask = 0x0f,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001571 },
1572 [AB8540_LDO_INTCORE] = {
1573 .desc = {
1574 .name = "LDO-INTCORE",
1575 .ops = &ab8500_regulator_volt_mode_ops,
1576 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001577 .id = AB8540_LDO_INTCORE,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001578 .owner = THIS_MODULE,
1579 .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +00001580 .volt_table = ldo_vintcore_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001581 },
1582 .load_lp_uA = 5000,
1583 .update_bank = 0x03,
1584 .update_reg = 0x80,
1585 .update_mask = 0x44,
1586 .update_val = 0x44,
1587 .update_val_idle = 0x44,
1588 .update_val_normal = 0x04,
1589 .voltage_bank = 0x03,
1590 .voltage_reg = 0x80,
1591 .voltage_mask = 0x38,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001592 .voltage_shift = 3,
1593 },
1594
1595 /*
1596 * Fixed Voltage Regulators
1597 * name, fixed mV,
1598 * update bank, reg, mask, enable val
1599 */
1600 [AB8540_LDO_TVOUT] = {
1601 .desc = {
1602 .name = "LDO-TVOUT",
1603 .ops = &ab8500_regulator_mode_ops,
1604 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001605 .id = AB8540_LDO_TVOUT,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001606 .owner = THIS_MODULE,
1607 .n_voltages = 1,
1608 },
1609 .delay = 10000,
1610 .load_lp_uA = 1000,
1611 .update_bank = 0x03,
1612 .update_reg = 0x80,
1613 .update_mask = 0x82,
1614 .update_val = 0x02,
1615 .update_val_idle = 0x82,
1616 .update_val_normal = 0x02,
1617 },
1618 [AB8540_LDO_AUDIO] = {
1619 .desc = {
1620 .name = "LDO-AUDIO",
1621 .ops = &ab8500_regulator_ops,
1622 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001623 .id = AB8540_LDO_AUDIO,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001624 .owner = THIS_MODULE,
1625 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001626 .volt_table = fixed_2000000_voltage,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001627 },
1628 .update_bank = 0x03,
1629 .update_reg = 0x83,
1630 .update_mask = 0x02,
1631 .update_val = 0x02,
1632 },
1633 [AB8540_LDO_ANAMIC1] = {
1634 .desc = {
1635 .name = "LDO-ANAMIC1",
Lee Jones4c84b4d2013-04-02 13:24:13 +01001636 .ops = &ab8500_regulator_anamic_mode_ops,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001637 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001638 .id = AB8540_LDO_ANAMIC1,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001639 .owner = THIS_MODULE,
1640 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001641 .volt_table = fixed_2050000_voltage,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001642 },
Lee Jones4c84b4d2013-04-02 13:24:13 +01001643 .shared_mode = &ab8540_ldo_anamic1_shared,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001644 .update_bank = 0x03,
1645 .update_reg = 0x83,
1646 .update_mask = 0x08,
1647 .update_val = 0x08,
Lee Jones4c84b4d2013-04-02 13:24:13 +01001648 .mode_bank = 0x03,
1649 .mode_reg = 0x83,
1650 .mode_mask = 0x20,
1651 .mode_val_idle = 0x20,
1652 .mode_val_normal = 0x00,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001653 },
1654 [AB8540_LDO_ANAMIC2] = {
1655 .desc = {
1656 .name = "LDO-ANAMIC2",
Lee Jones4c84b4d2013-04-02 13:24:13 +01001657 .ops = &ab8500_regulator_anamic_mode_ops,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001658 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001659 .id = AB8540_LDO_ANAMIC2,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001660 .owner = THIS_MODULE,
1661 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001662 .volt_table = fixed_2050000_voltage,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001663 },
Lee Jones4c84b4d2013-04-02 13:24:13 +01001664 .shared_mode = &ab8540_ldo_anamic2_shared,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001665 .update_bank = 0x03,
1666 .update_reg = 0x83,
1667 .update_mask = 0x10,
1668 .update_val = 0x10,
Lee Jones4c84b4d2013-04-02 13:24:13 +01001669 .mode_bank = 0x03,
1670 .mode_reg = 0x83,
1671 .mode_mask = 0x20,
1672 .mode_val_idle = 0x20,
1673 .mode_val_normal = 0x00,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001674 },
1675 [AB8540_LDO_DMIC] = {
1676 .desc = {
1677 .name = "LDO-DMIC",
Lee Jones4c84b4d2013-04-02 13:24:13 +01001678 .ops = &ab8500_regulator_volt_mode_ops,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001679 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001680 .id = AB8540_LDO_DMIC,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001681 .owner = THIS_MODULE,
Lee Jones4c84b4d2013-04-02 13:24:13 +01001682 .n_voltages = ARRAY_SIZE(ldo_vdmic_voltages),
Lee Jonesae0a9a32013-03-28 16:11:16 +00001683 },
Lee Jones4c84b4d2013-04-02 13:24:13 +01001684 .load_lp_uA = 1000,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001685 .update_bank = 0x03,
1686 .update_reg = 0x83,
1687 .update_mask = 0x04,
1688 .update_val = 0x04,
Lee Jones4c84b4d2013-04-02 13:24:13 +01001689 .voltage_bank = 0x03,
1690 .voltage_reg = 0x83,
1691 .voltage_mask = 0xc0,
1692 .voltages = ldo_vdmic_voltages,
1693 .voltages_len = ARRAY_SIZE(ldo_vdmic_voltages),
Lee Jonesae0a9a32013-03-28 16:11:16 +00001694 },
1695
1696 /*
1697 * Regulators with fixed voltage and normal/idle modes
1698 */
1699 [AB8540_LDO_ANA] = {
1700 .desc = {
1701 .name = "LDO-ANA",
1702 .ops = &ab8500_regulator_mode_ops,
1703 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001704 .id = AB8540_LDO_ANA,
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_1200000_voltage,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001708 },
1709 .load_lp_uA = 1000,
1710 .update_bank = 0x04,
1711 .update_reg = 0x06,
1712 .update_mask = 0x0c,
1713 .update_val = 0x04,
1714 .update_val_idle = 0x0c,
1715 .update_val_normal = 0x04,
1716 },
1717 [AB8540_LDO_SDIO] = {
1718 .desc = {
1719 .name = "LDO-SDIO",
1720 .ops = &ab8500_regulator_volt_mode_ops,
1721 .type = REGULATOR_VOLTAGE,
1722 .id = AB8540_LDO_SDIO,
1723 .owner = THIS_MODULE,
Lee Jones62ab4112013-03-28 16:11:18 +00001724 .n_voltages = ARRAY_SIZE(ldo_sdio_voltages),
1725 .volt_table = ldo_sdio_voltages,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001726 },
Lee Jonesae0a9a32013-03-28 16:11:16 +00001727 .load_lp_uA = 5000,
1728 .update_bank = 0x03,
1729 .update_reg = 0x88,
1730 .update_mask = 0x30,
1731 .update_val = 0x10,
1732 .update_val_idle = 0x30,
1733 .update_val_normal = 0x10,
1734 .voltage_bank = 0x03,
1735 .voltage_reg = 0x88,
1736 .voltage_mask = 0x07,
Lee Jonesae0a9a32013-03-28 16:11:16 +00001737 },
1738};
1739
Lee Jones3fe52282013-04-02 13:24:12 +01001740static struct ab8500_shared_mode ldo_anamic1_shared = {
1741 .shared_regulator = &ab8505_regulator_info[AB8505_LDO_ANAMIC2],
1742};
1743
1744static struct ab8500_shared_mode ldo_anamic2_shared = {
1745 .shared_regulator = &ab8505_regulator_info[AB8505_LDO_ANAMIC1],
1746};
1747
Lee Jones4c84b4d2013-04-02 13:24:13 +01001748static struct ab8500_shared_mode ab8540_ldo_anamic1_shared = {
1749 .shared_regulator = &ab8540_regulator_info[AB8540_LDO_ANAMIC2],
1750};
1751
1752static struct ab8500_shared_mode ab8540_ldo_anamic2_shared = {
1753 .shared_regulator = &ab8540_regulator_info[AB8540_LDO_ANAMIC1],
1754};
1755
Bengt Jonsson79568b942011-03-11 11:54:46 +01001756struct ab8500_reg_init {
1757 u8 bank;
1758 u8 addr;
1759 u8 mask;
1760};
1761
1762#define REG_INIT(_id, _bank, _addr, _mask) \
1763 [_id] = { \
1764 .bank = _bank, \
1765 .addr = _addr, \
1766 .mask = _mask, \
1767 }
1768
Lee Jones8e6a8d72013-03-28 16:11:11 +00001769/* AB8500 register init */
Bengt Jonsson79568b942011-03-11 11:54:46 +01001770static struct ab8500_reg_init ab8500_reg_init[] = {
1771 /*
Lee Jones33bc8f42013-03-21 15:59:02 +00001772 * 0x30, VanaRequestCtrl
Bengt Jonsson79568b942011-03-11 11:54:46 +01001773 * 0xc0, VextSupply1RequestCtrl
1774 */
Lee Jones43a59112013-03-21 15:59:15 +00001775 REG_INIT(AB8500_REGUREQUESTCTRL2, 0x03, 0x04, 0xf0),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001776 /*
1777 * 0x03, VextSupply2RequestCtrl
1778 * 0x0c, VextSupply3RequestCtrl
1779 * 0x30, Vaux1RequestCtrl
1780 * 0xc0, Vaux2RequestCtrl
1781 */
1782 REG_INIT(AB8500_REGUREQUESTCTRL3, 0x03, 0x05, 0xff),
1783 /*
1784 * 0x03, Vaux3RequestCtrl
1785 * 0x04, SwHPReq
1786 */
1787 REG_INIT(AB8500_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
1788 /*
1789 * 0x08, VanaSysClkReq1HPValid
1790 * 0x20, Vaux1SysClkReq1HPValid
1791 * 0x40, Vaux2SysClkReq1HPValid
1792 * 0x80, Vaux3SysClkReq1HPValid
1793 */
Lee Jones43a59112013-03-21 15:59:15 +00001794 REG_INIT(AB8500_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xe8),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001795 /*
1796 * 0x10, VextSupply1SysClkReq1HPValid
1797 * 0x20, VextSupply2SysClkReq1HPValid
1798 * 0x40, VextSupply3SysClkReq1HPValid
1799 */
Lee Jones43a59112013-03-21 15:59:15 +00001800 REG_INIT(AB8500_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x70),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001801 /*
1802 * 0x08, VanaHwHPReq1Valid
1803 * 0x20, Vaux1HwHPReq1Valid
1804 * 0x40, Vaux2HwHPReq1Valid
1805 * 0x80, Vaux3HwHPReq1Valid
1806 */
Lee Jones43a59112013-03-21 15:59:15 +00001807 REG_INIT(AB8500_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xe8),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001808 /*
1809 * 0x01, VextSupply1HwHPReq1Valid
1810 * 0x02, VextSupply2HwHPReq1Valid
1811 * 0x04, VextSupply3HwHPReq1Valid
1812 */
Lee Jones43a59112013-03-21 15:59:15 +00001813 REG_INIT(AB8500_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x07),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001814 /*
1815 * 0x08, VanaHwHPReq2Valid
1816 * 0x20, Vaux1HwHPReq2Valid
1817 * 0x40, Vaux2HwHPReq2Valid
1818 * 0x80, Vaux3HwHPReq2Valid
1819 */
Lee Jones43a59112013-03-21 15:59:15 +00001820 REG_INIT(AB8500_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xe8),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001821 /*
1822 * 0x01, VextSupply1HwHPReq2Valid
1823 * 0x02, VextSupply2HwHPReq2Valid
1824 * 0x04, VextSupply3HwHPReq2Valid
1825 */
Lee Jones43a59112013-03-21 15:59:15 +00001826 REG_INIT(AB8500_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x07),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001827 /*
1828 * 0x20, VanaSwHPReqValid
1829 * 0x80, Vaux1SwHPReqValid
1830 */
Lee Jones43a59112013-03-21 15:59:15 +00001831 REG_INIT(AB8500_REGUSWHPREQVALID1, 0x03, 0x0d, 0xa0),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001832 /*
1833 * 0x01, Vaux2SwHPReqValid
1834 * 0x02, Vaux3SwHPReqValid
1835 * 0x04, VextSupply1SwHPReqValid
1836 * 0x08, VextSupply2SwHPReqValid
1837 * 0x10, VextSupply3SwHPReqValid
1838 */
Lee Jones43a59112013-03-21 15:59:15 +00001839 REG_INIT(AB8500_REGUSWHPREQVALID2, 0x03, 0x0e, 0x1f),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001840 /*
1841 * 0x02, SysClkReq2Valid1
Lee Jones43a59112013-03-21 15:59:15 +00001842 * 0x04, SysClkReq3Valid1
1843 * 0x08, SysClkReq4Valid1
1844 * 0x10, SysClkReq5Valid1
1845 * 0x20, SysClkReq6Valid1
1846 * 0x40, SysClkReq7Valid1
Bengt Jonsson79568b942011-03-11 11:54:46 +01001847 * 0x80, SysClkReq8Valid1
1848 */
1849 REG_INIT(AB8500_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0xfe),
1850 /*
1851 * 0x02, SysClkReq2Valid2
Lee Jones43a59112013-03-21 15:59:15 +00001852 * 0x04, SysClkReq3Valid2
1853 * 0x08, SysClkReq4Valid2
1854 * 0x10, SysClkReq5Valid2
1855 * 0x20, SysClkReq6Valid2
1856 * 0x40, SysClkReq7Valid2
Bengt Jonsson79568b942011-03-11 11:54:46 +01001857 * 0x80, SysClkReq8Valid2
1858 */
1859 REG_INIT(AB8500_REGUSYSCLKREQVALID2, 0x03, 0x10, 0xfe),
1860 /*
1861 * 0x02, VTVoutEna
1862 * 0x04, Vintcore12Ena
1863 * 0x38, Vintcore12Sel
1864 * 0x40, Vintcore12LP
1865 * 0x80, VTVoutLP
1866 */
1867 REG_INIT(AB8500_REGUMISC1, 0x03, 0x80, 0xfe),
1868 /*
1869 * 0x02, VaudioEna
1870 * 0x04, VdmicEna
1871 * 0x08, Vamic1Ena
1872 * 0x10, Vamic2Ena
1873 */
1874 REG_INIT(AB8500_VAUDIOSUPPLY, 0x03, 0x83, 0x1e),
1875 /*
1876 * 0x01, Vamic1_dzout
1877 * 0x02, Vamic2_dzout
1878 */
1879 REG_INIT(AB8500_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
1880 /*
Lee Jones43a59112013-03-21 15:59:15 +00001881 * 0x03, VpllRegu (NOTE! PRCMU register bits)
Lee Jones33bc8f42013-03-21 15:59:02 +00001882 * 0x0c, VanaRegu
Bengt Jonsson79568b942011-03-11 11:54:46 +01001883 */
1884 REG_INIT(AB8500_VPLLVANAREGU, 0x04, 0x06, 0x0f),
1885 /*
1886 * 0x01, VrefDDREna
1887 * 0x02, VrefDDRSleepMode
1888 */
1889 REG_INIT(AB8500_VREFDDR, 0x04, 0x07, 0x03),
1890 /*
1891 * 0x03, VextSupply1Regu
1892 * 0x0c, VextSupply2Regu
1893 * 0x30, VextSupply3Regu
1894 * 0x40, ExtSupply2Bypass
1895 * 0x80, ExtSupply3Bypass
1896 */
1897 REG_INIT(AB8500_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
1898 /*
1899 * 0x03, Vaux1Regu
1900 * 0x0c, Vaux2Regu
1901 */
1902 REG_INIT(AB8500_VAUX12REGU, 0x04, 0x09, 0x0f),
1903 /*
1904 * 0x03, Vaux3Regu
1905 */
Lee Jones43a59112013-03-21 15:59:15 +00001906 REG_INIT(AB8500_VRF1VAUX3REGU, 0x04, 0x0a, 0x03),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001907 /*
1908 * 0x0f, Vaux1Sel
1909 */
1910 REG_INIT(AB8500_VAUX1SEL, 0x04, 0x1f, 0x0f),
1911 /*
1912 * 0x0f, Vaux2Sel
1913 */
1914 REG_INIT(AB8500_VAUX2SEL, 0x04, 0x20, 0x0f),
1915 /*
1916 * 0x07, Vaux3Sel
1917 */
Lee Jones43a59112013-03-21 15:59:15 +00001918 REG_INIT(AB8500_VRF1VAUX3SEL, 0x04, 0x21, 0x07),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001919 /*
1920 * 0x01, VextSupply12LP
1921 */
1922 REG_INIT(AB8500_REGUCTRL2SPARE, 0x04, 0x22, 0x01),
1923 /*
1924 * 0x04, Vaux1Disch
1925 * 0x08, Vaux2Disch
1926 * 0x10, Vaux3Disch
1927 * 0x20, Vintcore12Disch
1928 * 0x40, VTVoutDisch
1929 * 0x80, VaudioDisch
1930 */
Lee Jones43a59112013-03-21 15:59:15 +00001931 REG_INIT(AB8500_REGUCTRLDISCH, 0x04, 0x43, 0xfc),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001932 /*
1933 * 0x02, VanaDisch
1934 * 0x04, VdmicPullDownEna
1935 * 0x10, VdmicDisch
1936 */
Lee Jones43a59112013-03-21 15:59:15 +00001937 REG_INIT(AB8500_REGUCTRLDISCH2, 0x04, 0x44, 0x16),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001938};
1939
Lee Jones547f3842013-03-28 16:11:14 +00001940/* AB8505 register init */
1941static struct ab8500_reg_init ab8505_reg_init[] = {
1942 /*
1943 * 0x03, VarmRequestCtrl
1944 * 0x0c, VsmpsCRequestCtrl
1945 * 0x30, VsmpsARequestCtrl
1946 * 0xc0, VsmpsBRequestCtrl
1947 */
1948 REG_INIT(AB8505_REGUREQUESTCTRL1, 0x03, 0x03, 0xff),
1949 /*
1950 * 0x03, VsafeRequestCtrl
1951 * 0x0c, VpllRequestCtrl
1952 * 0x30, VanaRequestCtrl
1953 */
1954 REG_INIT(AB8505_REGUREQUESTCTRL2, 0x03, 0x04, 0x3f),
1955 /*
1956 * 0x30, Vaux1RequestCtrl
1957 * 0xc0, Vaux2RequestCtrl
1958 */
1959 REG_INIT(AB8505_REGUREQUESTCTRL3, 0x03, 0x05, 0xf0),
1960 /*
1961 * 0x03, Vaux3RequestCtrl
1962 * 0x04, SwHPReq
1963 */
1964 REG_INIT(AB8505_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
1965 /*
1966 * 0x01, VsmpsASysClkReq1HPValid
1967 * 0x02, VsmpsBSysClkReq1HPValid
1968 * 0x04, VsafeSysClkReq1HPValid
1969 * 0x08, VanaSysClkReq1HPValid
1970 * 0x10, VpllSysClkReq1HPValid
1971 * 0x20, Vaux1SysClkReq1HPValid
1972 * 0x40, Vaux2SysClkReq1HPValid
1973 * 0x80, Vaux3SysClkReq1HPValid
1974 */
1975 REG_INIT(AB8505_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xff),
1976 /*
1977 * 0x01, VsmpsCSysClkReq1HPValid
1978 * 0x02, VarmSysClkReq1HPValid
1979 * 0x04, VbbSysClkReq1HPValid
1980 * 0x08, VsmpsMSysClkReq1HPValid
1981 */
1982 REG_INIT(AB8505_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x0f),
1983 /*
1984 * 0x01, VsmpsAHwHPReq1Valid
1985 * 0x02, VsmpsBHwHPReq1Valid
1986 * 0x04, VsafeHwHPReq1Valid
1987 * 0x08, VanaHwHPReq1Valid
1988 * 0x10, VpllHwHPReq1Valid
1989 * 0x20, Vaux1HwHPReq1Valid
1990 * 0x40, Vaux2HwHPReq1Valid
1991 * 0x80, Vaux3HwHPReq1Valid
1992 */
1993 REG_INIT(AB8505_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xff),
1994 /*
1995 * 0x08, VsmpsMHwHPReq1Valid
1996 */
1997 REG_INIT(AB8505_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x08),
1998 /*
1999 * 0x01, VsmpsAHwHPReq2Valid
2000 * 0x02, VsmpsBHwHPReq2Valid
2001 * 0x04, VsafeHwHPReq2Valid
2002 * 0x08, VanaHwHPReq2Valid
2003 * 0x10, VpllHwHPReq2Valid
2004 * 0x20, Vaux1HwHPReq2Valid
2005 * 0x40, Vaux2HwHPReq2Valid
2006 * 0x80, Vaux3HwHPReq2Valid
2007 */
2008 REG_INIT(AB8505_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xff),
2009 /*
2010 * 0x08, VsmpsMHwHPReq2Valid
2011 */
2012 REG_INIT(AB8505_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x08),
2013 /*
2014 * 0x01, VsmpsCSwHPReqValid
2015 * 0x02, VarmSwHPReqValid
2016 * 0x04, VsmpsASwHPReqValid
2017 * 0x08, VsmpsBSwHPReqValid
2018 * 0x10, VsafeSwHPReqValid
2019 * 0x20, VanaSwHPReqValid
2020 * 0x40, VpllSwHPReqValid
2021 * 0x80, Vaux1SwHPReqValid
2022 */
2023 REG_INIT(AB8505_REGUSWHPREQVALID1, 0x03, 0x0d, 0xff),
2024 /*
2025 * 0x01, Vaux2SwHPReqValid
2026 * 0x02, Vaux3SwHPReqValid
2027 * 0x20, VsmpsMSwHPReqValid
2028 */
2029 REG_INIT(AB8505_REGUSWHPREQVALID2, 0x03, 0x0e, 0x23),
2030 /*
2031 * 0x02, SysClkReq2Valid1
2032 * 0x04, SysClkReq3Valid1
2033 * 0x08, SysClkReq4Valid1
2034 */
2035 REG_INIT(AB8505_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0x0e),
2036 /*
2037 * 0x02, SysClkReq2Valid2
2038 * 0x04, SysClkReq3Valid2
2039 * 0x08, SysClkReq4Valid2
2040 */
2041 REG_INIT(AB8505_REGUSYSCLKREQVALID2, 0x03, 0x10, 0x0e),
2042 /*
2043 * 0x01, Vaux4SwHPReqValid
2044 * 0x02, Vaux4HwHPReq2Valid
2045 * 0x04, Vaux4HwHPReq1Valid
2046 * 0x08, Vaux4SysClkReq1HPValid
2047 */
2048 REG_INIT(AB8505_REGUVAUX4REQVALID, 0x03, 0x11, 0x0f),
2049 /*
2050 * 0x02, VadcEna
2051 * 0x04, VintCore12Ena
2052 * 0x38, VintCore12Sel
2053 * 0x40, VintCore12LP
2054 * 0x80, VadcLP
2055 */
2056 REG_INIT(AB8505_REGUMISC1, 0x03, 0x80, 0xfe),
2057 /*
2058 * 0x02, VaudioEna
2059 * 0x04, VdmicEna
2060 * 0x08, Vamic1Ena
2061 * 0x10, Vamic2Ena
2062 */
2063 REG_INIT(AB8505_VAUDIOSUPPLY, 0x03, 0x83, 0x1e),
2064 /*
2065 * 0x01, Vamic1_dzout
2066 * 0x02, Vamic2_dzout
2067 */
2068 REG_INIT(AB8505_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
2069 /*
2070 * 0x03, VsmpsARegu
2071 * 0x0c, VsmpsASelCtrl
2072 * 0x10, VsmpsAAutoMode
2073 * 0x20, VsmpsAPWMMode
2074 */
2075 REG_INIT(AB8505_VSMPSAREGU, 0x04, 0x03, 0x3f),
2076 /*
2077 * 0x03, VsmpsBRegu
2078 * 0x0c, VsmpsBSelCtrl
2079 * 0x10, VsmpsBAutoMode
2080 * 0x20, VsmpsBPWMMode
2081 */
2082 REG_INIT(AB8505_VSMPSBREGU, 0x04, 0x04, 0x3f),
2083 /*
2084 * 0x03, VsafeRegu
2085 * 0x0c, VsafeSelCtrl
2086 * 0x10, VsafeAutoMode
2087 * 0x20, VsafePWMMode
2088 */
2089 REG_INIT(AB8505_VSAFEREGU, 0x04, 0x05, 0x3f),
2090 /*
2091 * 0x03, VpllRegu (NOTE! PRCMU register bits)
2092 * 0x0c, VanaRegu
2093 */
2094 REG_INIT(AB8505_VPLLVANAREGU, 0x04, 0x06, 0x0f),
2095 /*
2096 * 0x03, VextSupply1Regu
2097 * 0x0c, VextSupply2Regu
2098 * 0x30, VextSupply3Regu
2099 * 0x40, ExtSupply2Bypass
2100 * 0x80, ExtSupply3Bypass
2101 */
2102 REG_INIT(AB8505_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
2103 /*
2104 * 0x03, Vaux1Regu
2105 * 0x0c, Vaux2Regu
2106 */
2107 REG_INIT(AB8505_VAUX12REGU, 0x04, 0x09, 0x0f),
2108 /*
2109 * 0x0f, Vaux3Regu
2110 */
2111 REG_INIT(AB8505_VRF1VAUX3REGU, 0x04, 0x0a, 0x0f),
2112 /*
2113 * 0x3f, VsmpsASel1
2114 */
2115 REG_INIT(AB8505_VSMPSASEL1, 0x04, 0x13, 0x3f),
2116 /*
2117 * 0x3f, VsmpsASel2
2118 */
2119 REG_INIT(AB8505_VSMPSASEL2, 0x04, 0x14, 0x3f),
2120 /*
2121 * 0x3f, VsmpsASel3
2122 */
2123 REG_INIT(AB8505_VSMPSASEL3, 0x04, 0x15, 0x3f),
2124 /*
2125 * 0x3f, VsmpsBSel1
2126 */
2127 REG_INIT(AB8505_VSMPSBSEL1, 0x04, 0x17, 0x3f),
2128 /*
2129 * 0x3f, VsmpsBSel2
2130 */
2131 REG_INIT(AB8505_VSMPSBSEL2, 0x04, 0x18, 0x3f),
2132 /*
2133 * 0x3f, VsmpsBSel3
2134 */
2135 REG_INIT(AB8505_VSMPSBSEL3, 0x04, 0x19, 0x3f),
2136 /*
2137 * 0x7f, VsafeSel1
2138 */
2139 REG_INIT(AB8505_VSAFESEL1, 0x04, 0x1b, 0x7f),
2140 /*
2141 * 0x3f, VsafeSel2
2142 */
2143 REG_INIT(AB8505_VSAFESEL2, 0x04, 0x1c, 0x7f),
2144 /*
2145 * 0x3f, VsafeSel3
2146 */
2147 REG_INIT(AB8505_VSAFESEL3, 0x04, 0x1d, 0x7f),
2148 /*
2149 * 0x0f, Vaux1Sel
2150 */
2151 REG_INIT(AB8505_VAUX1SEL, 0x04, 0x1f, 0x0f),
2152 /*
2153 * 0x0f, Vaux2Sel
2154 */
2155 REG_INIT(AB8505_VAUX2SEL, 0x04, 0x20, 0x0f),
2156 /*
2157 * 0x07, Vaux3Sel
2158 * 0x30, VRF1Sel
2159 */
2160 REG_INIT(AB8505_VRF1VAUX3SEL, 0x04, 0x21, 0x37),
2161 /*
2162 * 0x03, Vaux4RequestCtrl
2163 */
2164 REG_INIT(AB8505_VAUX4REQCTRL, 0x04, 0x2d, 0x03),
2165 /*
2166 * 0x03, Vaux4Regu
2167 */
2168 REG_INIT(AB8505_VAUX4REGU, 0x04, 0x2e, 0x03),
2169 /*
2170 * 0x0f, Vaux4Sel
2171 */
2172 REG_INIT(AB8505_VAUX4SEL, 0x04, 0x2f, 0x0f),
2173 /*
2174 * 0x04, Vaux1Disch
2175 * 0x08, Vaux2Disch
2176 * 0x10, Vaux3Disch
2177 * 0x20, Vintcore12Disch
2178 * 0x40, VTVoutDisch
2179 * 0x80, VaudioDisch
2180 */
2181 REG_INIT(AB8505_REGUCTRLDISCH, 0x04, 0x43, 0xfc),
2182 /*
2183 * 0x02, VanaDisch
2184 * 0x04, VdmicPullDownEna
2185 * 0x10, VdmicDisch
2186 */
2187 REG_INIT(AB8505_REGUCTRLDISCH2, 0x04, 0x44, 0x16),
2188 /*
2189 * 0x01, Vaux4Disch
2190 */
2191 REG_INIT(AB8505_REGUCTRLDISCH3, 0x04, 0x48, 0x01),
2192 /*
2193 * 0x07, Vaux5Sel
2194 * 0x08, Vaux5LP
2195 * 0x10, Vaux5Ena
2196 * 0x20, Vaux5Disch
2197 * 0x40, Vaux5DisSfst
2198 * 0x80, Vaux5DisPulld
2199 */
2200 REG_INIT(AB8505_CTRLVAUX5, 0x01, 0x55, 0xff),
2201 /*
2202 * 0x07, Vaux6Sel
2203 * 0x08, Vaux6LP
2204 * 0x10, Vaux6Ena
2205 * 0x80, Vaux6DisPulld
2206 */
2207 REG_INIT(AB8505_CTRLVAUX6, 0x01, 0x56, 0x9f),
2208};
2209
Lee Jones8e6a8d72013-03-28 16:11:11 +00002210/* AB9540 register init */
2211static struct ab8500_reg_init ab9540_reg_init[] = {
2212 /*
2213 * 0x03, VarmRequestCtrl
2214 * 0x0c, VapeRequestCtrl
2215 * 0x30, Vsmps1RequestCtrl
2216 * 0xc0, Vsmps2RequestCtrl
2217 */
2218 REG_INIT(AB9540_REGUREQUESTCTRL1, 0x03, 0x03, 0xff),
2219 /*
2220 * 0x03, Vsmps3RequestCtrl
2221 * 0x0c, VpllRequestCtrl
2222 * 0x30, VanaRequestCtrl
2223 * 0xc0, VextSupply1RequestCtrl
2224 */
2225 REG_INIT(AB9540_REGUREQUESTCTRL2, 0x03, 0x04, 0xff),
2226 /*
2227 * 0x03, VextSupply2RequestCtrl
2228 * 0x0c, VextSupply3RequestCtrl
2229 * 0x30, Vaux1RequestCtrl
2230 * 0xc0, Vaux2RequestCtrl
2231 */
2232 REG_INIT(AB9540_REGUREQUESTCTRL3, 0x03, 0x05, 0xff),
2233 /*
2234 * 0x03, Vaux3RequestCtrl
2235 * 0x04, SwHPReq
2236 */
2237 REG_INIT(AB9540_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
2238 /*
2239 * 0x01, Vsmps1SysClkReq1HPValid
2240 * 0x02, Vsmps2SysClkReq1HPValid
2241 * 0x04, Vsmps3SysClkReq1HPValid
2242 * 0x08, VanaSysClkReq1HPValid
2243 * 0x10, VpllSysClkReq1HPValid
2244 * 0x20, Vaux1SysClkReq1HPValid
2245 * 0x40, Vaux2SysClkReq1HPValid
2246 * 0x80, Vaux3SysClkReq1HPValid
2247 */
2248 REG_INIT(AB9540_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xff),
2249 /*
2250 * 0x01, VapeSysClkReq1HPValid
2251 * 0x02, VarmSysClkReq1HPValid
2252 * 0x04, VbbSysClkReq1HPValid
2253 * 0x08, VmodSysClkReq1HPValid
2254 * 0x10, VextSupply1SysClkReq1HPValid
2255 * 0x20, VextSupply2SysClkReq1HPValid
2256 * 0x40, VextSupply3SysClkReq1HPValid
2257 */
2258 REG_INIT(AB9540_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x7f),
2259 /*
2260 * 0x01, Vsmps1HwHPReq1Valid
2261 * 0x02, Vsmps2HwHPReq1Valid
2262 * 0x04, Vsmps3HwHPReq1Valid
2263 * 0x08, VanaHwHPReq1Valid
2264 * 0x10, VpllHwHPReq1Valid
2265 * 0x20, Vaux1HwHPReq1Valid
2266 * 0x40, Vaux2HwHPReq1Valid
2267 * 0x80, Vaux3HwHPReq1Valid
2268 */
2269 REG_INIT(AB9540_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xff),
2270 /*
2271 * 0x01, VextSupply1HwHPReq1Valid
2272 * 0x02, VextSupply2HwHPReq1Valid
2273 * 0x04, VextSupply3HwHPReq1Valid
2274 * 0x08, VmodHwHPReq1Valid
2275 */
2276 REG_INIT(AB9540_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x0f),
2277 /*
2278 * 0x01, Vsmps1HwHPReq2Valid
2279 * 0x02, Vsmps2HwHPReq2Valid
2280 * 0x03, Vsmps3HwHPReq2Valid
2281 * 0x08, VanaHwHPReq2Valid
2282 * 0x10, VpllHwHPReq2Valid
2283 * 0x20, Vaux1HwHPReq2Valid
2284 * 0x40, Vaux2HwHPReq2Valid
2285 * 0x80, Vaux3HwHPReq2Valid
2286 */
2287 REG_INIT(AB9540_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xff),
2288 /*
2289 * 0x01, VextSupply1HwHPReq2Valid
2290 * 0x02, VextSupply2HwHPReq2Valid
2291 * 0x04, VextSupply3HwHPReq2Valid
2292 * 0x08, VmodHwHPReq2Valid
2293 */
2294 REG_INIT(AB9540_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x0f),
2295 /*
2296 * 0x01, VapeSwHPReqValid
2297 * 0x02, VarmSwHPReqValid
2298 * 0x04, Vsmps1SwHPReqValid
2299 * 0x08, Vsmps2SwHPReqValid
2300 * 0x10, Vsmps3SwHPReqValid
2301 * 0x20, VanaSwHPReqValid
2302 * 0x40, VpllSwHPReqValid
2303 * 0x80, Vaux1SwHPReqValid
2304 */
2305 REG_INIT(AB9540_REGUSWHPREQVALID1, 0x03, 0x0d, 0xff),
2306 /*
2307 * 0x01, Vaux2SwHPReqValid
2308 * 0x02, Vaux3SwHPReqValid
2309 * 0x04, VextSupply1SwHPReqValid
2310 * 0x08, VextSupply2SwHPReqValid
2311 * 0x10, VextSupply3SwHPReqValid
2312 * 0x20, VmodSwHPReqValid
2313 */
2314 REG_INIT(AB9540_REGUSWHPREQVALID2, 0x03, 0x0e, 0x3f),
2315 /*
2316 * 0x02, SysClkReq2Valid1
2317 * ...
2318 * 0x80, SysClkReq8Valid1
2319 */
2320 REG_INIT(AB9540_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0xfe),
2321 /*
2322 * 0x02, SysClkReq2Valid2
2323 * ...
2324 * 0x80, SysClkReq8Valid2
2325 */
2326 REG_INIT(AB9540_REGUSYSCLKREQVALID2, 0x03, 0x10, 0xfe),
2327 /*
2328 * 0x01, Vaux4SwHPReqValid
2329 * 0x02, Vaux4HwHPReq2Valid
2330 * 0x04, Vaux4HwHPReq1Valid
2331 * 0x08, Vaux4SysClkReq1HPValid
2332 */
2333 REG_INIT(AB9540_REGUVAUX4REQVALID, 0x03, 0x11, 0x0f),
2334 /*
2335 * 0x02, VTVoutEna
2336 * 0x04, Vintcore12Ena
2337 * 0x38, Vintcore12Sel
2338 * 0x40, Vintcore12LP
2339 * 0x80, VTVoutLP
2340 */
2341 REG_INIT(AB9540_REGUMISC1, 0x03, 0x80, 0xfe),
2342 /*
2343 * 0x02, VaudioEna
2344 * 0x04, VdmicEna
2345 * 0x08, Vamic1Ena
2346 * 0x10, Vamic2Ena
2347 */
2348 REG_INIT(AB9540_VAUDIOSUPPLY, 0x03, 0x83, 0x1e),
2349 /*
2350 * 0x01, Vamic1_dzout
2351 * 0x02, Vamic2_dzout
2352 */
2353 REG_INIT(AB9540_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
2354 /*
2355 * 0x03, Vsmps1Regu
2356 * 0x0c, Vsmps1SelCtrl
2357 * 0x10, Vsmps1AutoMode
2358 * 0x20, Vsmps1PWMMode
2359 */
2360 REG_INIT(AB9540_VSMPS1REGU, 0x04, 0x03, 0x3f),
2361 /*
2362 * 0x03, Vsmps2Regu
2363 * 0x0c, Vsmps2SelCtrl
2364 * 0x10, Vsmps2AutoMode
2365 * 0x20, Vsmps2PWMMode
2366 */
2367 REG_INIT(AB9540_VSMPS2REGU, 0x04, 0x04, 0x3f),
2368 /*
2369 * 0x03, Vsmps3Regu
2370 * 0x0c, Vsmps3SelCtrl
2371 * NOTE! PRCMU register
2372 */
2373 REG_INIT(AB9540_VSMPS3REGU, 0x04, 0x05, 0x0f),
2374 /*
2375 * 0x03, VpllRegu
2376 * 0x0c, VanaRegu
2377 */
2378 REG_INIT(AB9540_VPLLVANAREGU, 0x04, 0x06, 0x0f),
2379 /*
2380 * 0x03, VextSupply1Regu
2381 * 0x0c, VextSupply2Regu
2382 * 0x30, VextSupply3Regu
2383 * 0x40, ExtSupply2Bypass
2384 * 0x80, ExtSupply3Bypass
2385 */
2386 REG_INIT(AB9540_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
2387 /*
2388 * 0x03, Vaux1Regu
2389 * 0x0c, Vaux2Regu
2390 */
2391 REG_INIT(AB9540_VAUX12REGU, 0x04, 0x09, 0x0f),
2392 /*
2393 * 0x0c, Vrf1Regu
2394 * 0x03, Vaux3Regu
2395 */
2396 REG_INIT(AB9540_VRF1VAUX3REGU, 0x04, 0x0a, 0x0f),
2397 /*
2398 * 0x3f, Vsmps1Sel1
2399 */
2400 REG_INIT(AB9540_VSMPS1SEL1, 0x04, 0x13, 0x3f),
2401 /*
2402 * 0x3f, Vsmps1Sel2
2403 */
2404 REG_INIT(AB9540_VSMPS1SEL2, 0x04, 0x14, 0x3f),
2405 /*
2406 * 0x3f, Vsmps1Sel3
2407 */
2408 REG_INIT(AB9540_VSMPS1SEL3, 0x04, 0x15, 0x3f),
2409 /*
2410 * 0x3f, Vsmps2Sel1
2411 */
2412 REG_INIT(AB9540_VSMPS2SEL1, 0x04, 0x17, 0x3f),
2413 /*
2414 * 0x3f, Vsmps2Sel2
2415 */
2416 REG_INIT(AB9540_VSMPS2SEL2, 0x04, 0x18, 0x3f),
2417 /*
2418 * 0x3f, Vsmps2Sel3
2419 */
2420 REG_INIT(AB9540_VSMPS2SEL3, 0x04, 0x19, 0x3f),
2421 /*
2422 * 0x7f, Vsmps3Sel1
2423 * NOTE! PRCMU register
2424 */
2425 REG_INIT(AB9540_VSMPS3SEL1, 0x04, 0x1b, 0x7f),
2426 /*
2427 * 0x7f, Vsmps3Sel2
2428 * NOTE! PRCMU register
2429 */
2430 REG_INIT(AB9540_VSMPS3SEL2, 0x04, 0x1c, 0x7f),
2431 /*
2432 * 0x0f, Vaux1Sel
2433 */
2434 REG_INIT(AB9540_VAUX1SEL, 0x04, 0x1f, 0x0f),
2435 /*
2436 * 0x0f, Vaux2Sel
2437 */
2438 REG_INIT(AB9540_VAUX2SEL, 0x04, 0x20, 0x0f),
2439 /*
2440 * 0x07, Vaux3Sel
2441 * 0x30, Vrf1Sel
2442 */
2443 REG_INIT(AB9540_VRF1VAUX3SEL, 0x04, 0x21, 0x37),
2444 /*
2445 * 0x01, VextSupply12LP
2446 */
2447 REG_INIT(AB9540_REGUCTRL2SPARE, 0x04, 0x22, 0x01),
2448 /*
2449 * 0x03, Vaux4RequestCtrl
2450 */
2451 REG_INIT(AB9540_VAUX4REQCTRL, 0x04, 0x2d, 0x03),
2452 /*
2453 * 0x03, Vaux4Regu
2454 */
2455 REG_INIT(AB9540_VAUX4REGU, 0x04, 0x2e, 0x03),
2456 /*
2457 * 0x08, Vaux4Sel
2458 */
2459 REG_INIT(AB9540_VAUX4SEL, 0x04, 0x2f, 0x0f),
2460 /*
2461 * 0x01, VpllDisch
2462 * 0x02, Vrf1Disch
2463 * 0x04, Vaux1Disch
2464 * 0x08, Vaux2Disch
2465 * 0x10, Vaux3Disch
2466 * 0x20, Vintcore12Disch
2467 * 0x40, VTVoutDisch
2468 * 0x80, VaudioDisch
2469 */
2470 REG_INIT(AB9540_REGUCTRLDISCH, 0x04, 0x43, 0xff),
2471 /*
2472 * 0x01, VsimDisch
2473 * 0x02, VanaDisch
2474 * 0x04, VdmicPullDownEna
2475 * 0x08, VpllPullDownEna
2476 * 0x10, VdmicDisch
2477 */
2478 REG_INIT(AB9540_REGUCTRLDISCH2, 0x04, 0x44, 0x1f),
2479 /*
2480 * 0x01, Vaux4Disch
2481 */
2482 REG_INIT(AB9540_REGUCTRLDISCH3, 0x04, 0x48, 0x01),
2483};
2484
Lee Jonesae0a9a32013-03-28 16:11:16 +00002485/* AB8540 register init */
2486static struct ab8500_reg_init ab8540_reg_init[] = {
2487 /*
2488 * 0x01, VSimSycClkReq1Valid
2489 * 0x02, VSimSycClkReq2Valid
2490 * 0x04, VSimSycClkReq3Valid
2491 * 0x08, VSimSycClkReq4Valid
2492 * 0x10, VSimSycClkReq5Valid
2493 * 0x20, VSimSycClkReq6Valid
2494 * 0x40, VSimSycClkReq7Valid
2495 * 0x80, VSimSycClkReq8Valid
2496 */
2497 REG_INIT(AB8540_VSIMSYSCLKCTRL, 0x02, 0x33, 0xff),
2498 /*
2499 * 0x03, VarmRequestCtrl
2500 * 0x0c, VapeRequestCtrl
2501 * 0x30, Vsmps1RequestCtrl
2502 * 0xc0, Vsmps2RequestCtrl
2503 */
2504 REG_INIT(AB8540_REGUREQUESTCTRL1, 0x03, 0x03, 0xff),
2505 /*
2506 * 0x03, Vsmps3RequestCtrl
2507 * 0x0c, VpllRequestCtrl
2508 * 0x30, VanaRequestCtrl
2509 * 0xc0, VextSupply1RequestCtrl
2510 */
2511 REG_INIT(AB8540_REGUREQUESTCTRL2, 0x03, 0x04, 0xff),
2512 /*
2513 * 0x03, VextSupply2RequestCtrl
2514 * 0x0c, VextSupply3RequestCtrl
2515 * 0x30, Vaux1RequestCtrl
2516 * 0xc0, Vaux2RequestCtrl
2517 */
2518 REG_INIT(AB8540_REGUREQUESTCTRL3, 0x03, 0x05, 0xff),
2519 /*
2520 * 0x03, Vaux3RequestCtrl
2521 * 0x04, SwHPReq
2522 */
2523 REG_INIT(AB8540_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
2524 /*
2525 * 0x01, Vsmps1SysClkReq1HPValid
2526 * 0x02, Vsmps2SysClkReq1HPValid
2527 * 0x04, Vsmps3SysClkReq1HPValid
2528 * 0x08, VanaSysClkReq1HPValid
2529 * 0x10, VpllSysClkReq1HPValid
2530 * 0x20, Vaux1SysClkReq1HPValid
2531 * 0x40, Vaux2SysClkReq1HPValid
2532 * 0x80, Vaux3SysClkReq1HPValid
2533 */
2534 REG_INIT(AB8540_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xff),
2535 /*
2536 * 0x01, VapeSysClkReq1HPValid
2537 * 0x02, VarmSysClkReq1HPValid
2538 * 0x04, VbbSysClkReq1HPValid
2539 * 0x10, VextSupply1SysClkReq1HPValid
2540 * 0x20, VextSupply2SysClkReq1HPValid
2541 * 0x40, VextSupply3SysClkReq1HPValid
2542 */
2543 REG_INIT(AB8540_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x77),
2544 /*
2545 * 0x01, Vsmps1HwHPReq1Valid
2546 * 0x02, Vsmps2HwHPReq1Valid
2547 * 0x04, Vsmps3HwHPReq1Valid
2548 * 0x08, VanaHwHPReq1Valid
2549 * 0x10, VpllHwHPReq1Valid
2550 * 0x20, Vaux1HwHPReq1Valid
2551 * 0x40, Vaux2HwHPReq1Valid
2552 * 0x80, Vaux3HwHPReq1Valid
2553 */
2554 REG_INIT(AB8540_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xff),
2555 /*
2556 * 0x01, VextSupply1HwHPReq1Valid
2557 * 0x02, VextSupply2HwHPReq1Valid
2558 * 0x04, VextSupply3HwHPReq1Valid
2559 */
2560 REG_INIT(AB8540_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x07),
2561 /*
2562 * 0x01, Vsmps1HwHPReq2Valid
2563 * 0x02, Vsmps2HwHPReq2Valid
2564 * 0x03, Vsmps3HwHPReq2Valid
2565 * 0x08, VanaHwHPReq2Valid
2566 * 0x10, VpllHwHPReq2Valid
2567 * 0x20, Vaux1HwHPReq2Valid
2568 * 0x40, Vaux2HwHPReq2Valid
2569 * 0x80, Vaux3HwHPReq2Valid
2570 */
2571 REG_INIT(AB8540_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xff),
2572 /*
2573 * 0x01, VextSupply1HwHPReq2Valid
2574 * 0x02, VextSupply2HwHPReq2Valid
2575 * 0x04, VextSupply3HwHPReq2Valid
2576 */
2577 REG_INIT(AB8540_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x07),
2578 /*
2579 * 0x01, VapeSwHPReqValid
2580 * 0x02, VarmSwHPReqValid
2581 * 0x04, Vsmps1SwHPReqValid
2582 * 0x08, Vsmps2SwHPReqValid
2583 * 0x10, Vsmps3SwHPReqValid
2584 * 0x20, VanaSwHPReqValid
2585 * 0x40, VpllSwHPReqValid
2586 * 0x80, Vaux1SwHPReqValid
2587 */
2588 REG_INIT(AB8540_REGUSWHPREQVALID1, 0x03, 0x0d, 0xff),
2589 /*
2590 * 0x01, Vaux2SwHPReqValid
2591 * 0x02, Vaux3SwHPReqValid
2592 * 0x04, VextSupply1SwHPReqValid
2593 * 0x08, VextSupply2SwHPReqValid
2594 * 0x10, VextSupply3SwHPReqValid
2595 */
2596 REG_INIT(AB8540_REGUSWHPREQVALID2, 0x03, 0x0e, 0x1f),
2597 /*
2598 * 0x02, SysClkReq2Valid1
2599 * ...
2600 * 0x80, SysClkReq8Valid1
2601 */
2602 REG_INIT(AB8540_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0xff),
2603 /*
2604 * 0x02, SysClkReq2Valid2
2605 * ...
2606 * 0x80, SysClkReq8Valid2
2607 */
2608 REG_INIT(AB8540_REGUSYSCLKREQVALID2, 0x03, 0x10, 0xff),
2609 /*
2610 * 0x01, Vaux4SwHPReqValid
2611 * 0x02, Vaux4HwHPReq2Valid
2612 * 0x04, Vaux4HwHPReq1Valid
2613 * 0x08, Vaux4SysClkReq1HPValid
2614 */
2615 REG_INIT(AB8540_REGUVAUX4REQVALID, 0x03, 0x11, 0x0f),
2616 /*
2617 * 0x01, Vaux5SwHPReqValid
2618 * 0x02, Vaux5HwHPReq2Valid
2619 * 0x04, Vaux5HwHPReq1Valid
2620 * 0x08, Vaux5SysClkReq1HPValid
2621 */
2622 REG_INIT(AB8540_REGUVAUX5REQVALID, 0x03, 0x12, 0x0f),
2623 /*
2624 * 0x01, Vaux6SwHPReqValid
2625 * 0x02, Vaux6HwHPReq2Valid
2626 * 0x04, Vaux6HwHPReq1Valid
2627 * 0x08, Vaux6SysClkReq1HPValid
2628 */
2629 REG_INIT(AB8540_REGUVAUX6REQVALID, 0x03, 0x13, 0x0f),
2630 /*
2631 * 0x01, VclkbSwHPReqValid
2632 * 0x02, VclkbHwHPReq2Valid
2633 * 0x04, VclkbHwHPReq1Valid
2634 * 0x08, VclkbSysClkReq1HPValid
2635 */
2636 REG_INIT(AB8540_REGUVCLKBREQVALID, 0x03, 0x14, 0x0f),
2637 /*
2638 * 0x01, Vrf1SwHPReqValid
2639 * 0x02, Vrf1HwHPReq2Valid
2640 * 0x04, Vrf1HwHPReq1Valid
2641 * 0x08, Vrf1SysClkReq1HPValid
2642 */
2643 REG_INIT(AB8540_REGUVRF1REQVALID, 0x03, 0x15, 0x0f),
2644 /*
2645 * 0x02, VTVoutEna
2646 * 0x04, Vintcore12Ena
2647 * 0x38, Vintcore12Sel
2648 * 0x40, Vintcore12LP
2649 * 0x80, VTVoutLP
2650 */
2651 REG_INIT(AB8540_REGUMISC1, 0x03, 0x80, 0xfe),
2652 /*
2653 * 0x02, VaudioEna
2654 * 0x04, VdmicEna
2655 * 0x08, Vamic1Ena
2656 * 0x10, Vamic2Ena
2657 * 0x20, Vamic12LP
2658 * 0xC0, VdmicSel
2659 */
2660 REG_INIT(AB8540_VAUDIOSUPPLY, 0x03, 0x83, 0xfe),
2661 /*
2662 * 0x01, Vamic1_dzout
2663 * 0x02, Vamic2_dzout
2664 */
2665 REG_INIT(AB8540_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
2666 /*
2667 * 0x07, VHSICSel
2668 * 0x08, VHSICOffState
2669 * 0x10, VHSIEna
2670 * 0x20, VHSICLP
2671 */
2672 REG_INIT(AB8540_VHSIC, 0x03, 0x87, 0x3f),
2673 /*
2674 * 0x07, VSDIOSel
2675 * 0x08, VSDIOOffState
2676 * 0x10, VSDIOEna
2677 * 0x20, VSDIOLP
2678 */
2679 REG_INIT(AB8540_VSDIO, 0x03, 0x88, 0x3f),
2680 /*
2681 * 0x03, Vsmps1Regu
2682 * 0x0c, Vsmps1SelCtrl
2683 * 0x10, Vsmps1AutoMode
2684 * 0x20, Vsmps1PWMMode
2685 */
2686 REG_INIT(AB8540_VSMPS1REGU, 0x04, 0x03, 0x3f),
2687 /*
2688 * 0x03, Vsmps2Regu
2689 * 0x0c, Vsmps2SelCtrl
2690 * 0x10, Vsmps2AutoMode
2691 * 0x20, Vsmps2PWMMode
2692 */
2693 REG_INIT(AB8540_VSMPS2REGU, 0x04, 0x04, 0x3f),
2694 /*
2695 * 0x03, Vsmps3Regu
2696 * 0x0c, Vsmps3SelCtrl
2697 * 0x10, Vsmps3AutoMode
2698 * 0x20, Vsmps3PWMMode
2699 * NOTE! PRCMU register
2700 */
2701 REG_INIT(AB8540_VSMPS3REGU, 0x04, 0x05, 0x0f),
2702 /*
2703 * 0x03, VpllRegu
2704 * 0x0c, VanaRegu
2705 */
2706 REG_INIT(AB8540_VPLLVANAREGU, 0x04, 0x06, 0x0f),
2707 /*
2708 * 0x03, VextSupply1Regu
2709 * 0x0c, VextSupply2Regu
2710 * 0x30, VextSupply3Regu
2711 * 0x40, ExtSupply2Bypass
2712 * 0x80, ExtSupply3Bypass
2713 */
2714 REG_INIT(AB8540_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
2715 /*
2716 * 0x03, Vaux1Regu
2717 * 0x0c, Vaux2Regu
2718 */
2719 REG_INIT(AB8540_VAUX12REGU, 0x04, 0x09, 0x0f),
2720 /*
2721 * 0x0c, VRF1Regu
2722 * 0x03, Vaux3Regu
2723 */
2724 REG_INIT(AB8540_VRF1VAUX3REGU, 0x04, 0x0a, 0x0f),
2725 /*
2726 * 0x3f, Vsmps1Sel1
2727 */
2728 REG_INIT(AB8540_VSMPS1SEL1, 0x04, 0x13, 0x3f),
2729 /*
2730 * 0x3f, Vsmps1Sel2
2731 */
2732 REG_INIT(AB8540_VSMPS1SEL2, 0x04, 0x14, 0x3f),
2733 /*
2734 * 0x3f, Vsmps1Sel3
2735 */
2736 REG_INIT(AB8540_VSMPS1SEL3, 0x04, 0x15, 0x3f),
2737 /*
2738 * 0x3f, Vsmps2Sel1
2739 */
2740 REG_INIT(AB8540_VSMPS2SEL1, 0x04, 0x17, 0x3f),
2741 /*
2742 * 0x3f, Vsmps2Sel2
2743 */
2744 REG_INIT(AB8540_VSMPS2SEL2, 0x04, 0x18, 0x3f),
2745 /*
2746 * 0x3f, Vsmps2Sel3
2747 */
2748 REG_INIT(AB8540_VSMPS2SEL3, 0x04, 0x19, 0x3f),
2749 /*
2750 * 0x7f, Vsmps3Sel1
2751 * NOTE! PRCMU register
2752 */
2753 REG_INIT(AB8540_VSMPS3SEL1, 0x04, 0x1b, 0x7f),
2754 /*
2755 * 0x7f, Vsmps3Sel2
2756 * NOTE! PRCMU register
2757 */
2758 REG_INIT(AB8540_VSMPS3SEL2, 0x04, 0x1c, 0x7f),
2759 /*
2760 * 0x0f, Vaux1Sel
2761 */
2762 REG_INIT(AB8540_VAUX1SEL, 0x04, 0x1f, 0x0f),
2763 /*
2764 * 0x0f, Vaux2Sel
2765 */
2766 REG_INIT(AB8540_VAUX2SEL, 0x04, 0x20, 0x0f),
2767 /*
2768 * 0x07, Vaux3Sel
2769 * 0x70, Vrf1Sel
2770 */
2771 REG_INIT(AB8540_VRF1VAUX3SEL, 0x04, 0x21, 0x77),
2772 /*
2773 * 0x01, VextSupply12LP
2774 */
2775 REG_INIT(AB8540_REGUCTRL2SPARE, 0x04, 0x22, 0x01),
2776 /*
2777 * 0x07, Vanasel
2778 * 0x30, Vpllsel
2779 */
2780 REG_INIT(AB8540_VANAVPLLSEL, 0x04, 0x29, 0x37),
2781 /*
2782 * 0x03, Vaux4RequestCtrl
2783 */
2784 REG_INIT(AB8540_VAUX4REQCTRL, 0x04, 0x2d, 0x03),
2785 /*
2786 * 0x03, Vaux4Regu
2787 */
2788 REG_INIT(AB8540_VAUX4REGU, 0x04, 0x2e, 0x03),
2789 /*
2790 * 0x0f, Vaux4Sel
2791 */
2792 REG_INIT(AB8540_VAUX4SEL, 0x04, 0x2f, 0x0f),
2793 /*
2794 * 0x03, Vaux5RequestCtrl
2795 */
2796 REG_INIT(AB8540_VAUX5REQCTRL, 0x04, 0x31, 0x03),
2797 /*
2798 * 0x03, Vaux5Regu
2799 */
2800 REG_INIT(AB8540_VAUX5REGU, 0x04, 0x32, 0x03),
2801 /*
2802 * 0x3f, Vaux5Sel
2803 */
2804 REG_INIT(AB8540_VAUX5SEL, 0x04, 0x33, 0x3f),
2805 /*
2806 * 0x03, Vaux6RequestCtrl
2807 */
2808 REG_INIT(AB8540_VAUX6REQCTRL, 0x04, 0x34, 0x03),
2809 /*
2810 * 0x03, Vaux6Regu
2811 */
2812 REG_INIT(AB8540_VAUX6REGU, 0x04, 0x35, 0x03),
2813 /*
2814 * 0x3f, Vaux6Sel
2815 */
2816 REG_INIT(AB8540_VAUX6SEL, 0x04, 0x36, 0x3f),
2817 /*
2818 * 0x03, VCLKBRequestCtrl
2819 */
2820 REG_INIT(AB8540_VCLKBREQCTRL, 0x04, 0x37, 0x03),
2821 /*
2822 * 0x03, VCLKBRegu
2823 */
2824 REG_INIT(AB8540_VCLKBREGU, 0x04, 0x38, 0x03),
2825 /*
2826 * 0x07, VCLKBSel
2827 */
2828 REG_INIT(AB8540_VCLKBSEL, 0x04, 0x39, 0x07),
2829 /*
2830 * 0x03, Vrf1RequestCtrl
2831 */
2832 REG_INIT(AB8540_VRF1REQCTRL, 0x04, 0x3a, 0x03),
2833 /*
2834 * 0x01, VpllDisch
2835 * 0x02, Vrf1Disch
2836 * 0x04, Vaux1Disch
2837 * 0x08, Vaux2Disch
2838 * 0x10, Vaux3Disch
2839 * 0x20, Vintcore12Disch
2840 * 0x40, VTVoutDisch
2841 * 0x80, VaudioDisch
2842 */
2843 REG_INIT(AB8540_REGUCTRLDISCH, 0x04, 0x43, 0xff),
2844 /*
2845 * 0x02, VanaDisch
2846 * 0x04, VdmicPullDownEna
2847 * 0x08, VpllPullDownEna
2848 * 0x10, VdmicDisch
2849 */
2850 REG_INIT(AB8540_REGUCTRLDISCH2, 0x04, 0x44, 0x1e),
2851 /*
2852 * 0x01, Vaux4Disch
2853 */
2854 REG_INIT(AB8540_REGUCTRLDISCH3, 0x04, 0x48, 0x01),
2855 /*
2856 * 0x01, Vaux5Disch
2857 * 0x02, Vaux6Disch
2858 * 0x04, VCLKBDisch
2859 */
2860 REG_INIT(AB8540_REGUCTRLDISCH4, 0x04, 0x49, 0x07),
2861};
2862
Lee Jones33aeb492013-04-02 13:24:14 +01002863static struct {
2864 struct ab8500_regulator_info *info;
2865 int info_size;
2866 struct ab8500_reg_init *init;
2867 int init_size;
2868 struct of_regulator_match *match;
2869 int match_size;
2870} abx500_regulator;
2871
Lee Jones3c1b8432013-03-21 15:59:01 +00002872static int ab8500_regulator_init_registers(struct platform_device *pdev,
2873 int id, int mask, int value)
Lee Jonesa7ac1d92012-05-17 14:45:14 +01002874{
Lee Jones33aeb492013-04-02 13:24:14 +01002875 struct ab8500_reg_init *reg_init = abx500_regulator.init;
Lee Jonesa7ac1d92012-05-17 14:45:14 +01002876 int err;
2877
Lee Jones3c1b8432013-03-21 15:59:01 +00002878 BUG_ON(value & ~mask);
Lee Jonesb54969a2013-03-28 16:11:10 +00002879 BUG_ON(mask & ~reg_init[id].mask);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01002880
Lee Jones3c1b8432013-03-21 15:59:01 +00002881 /* initialize register */
Lee Jonesa7ac1d92012-05-17 14:45:14 +01002882 err = abx500_mask_and_set_register_interruptible(
2883 &pdev->dev,
Lee Jonesb54969a2013-03-28 16:11:10 +00002884 reg_init[id].bank,
2885 reg_init[id].addr,
Lee Jones3c1b8432013-03-21 15:59:01 +00002886 mask, value);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01002887 if (err < 0) {
2888 dev_err(&pdev->dev,
2889 "Failed to initialize 0x%02x, 0x%02x.\n",
Lee Jonesb54969a2013-03-28 16:11:10 +00002890 reg_init[id].bank,
2891 reg_init[id].addr);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01002892 return err;
2893 }
Lee Jonesa7ac1d92012-05-17 14:45:14 +01002894 dev_vdbg(&pdev->dev,
Lee Jones3c1b8432013-03-21 15:59:01 +00002895 " init: 0x%02x, 0x%02x, 0x%02x, 0x%02x\n",
Lee Jonesb54969a2013-03-28 16:11:10 +00002896 reg_init[id].bank,
2897 reg_init[id].addr,
Lee Jones3c1b8432013-03-21 15:59:01 +00002898 mask, value);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01002899
2900 return 0;
2901}
2902
Bill Pembertona5023572012-11-19 13:22:22 -05002903static int ab8500_regulator_register(struct platform_device *pdev,
Lee Jonesb54969a2013-03-28 16:11:10 +00002904 struct regulator_init_data *init_data,
Lee Jonesb54969a2013-03-28 16:11:10 +00002905 int id, struct device_node *np)
Lee Jonesa7ac1d92012-05-17 14:45:14 +01002906{
Lee Jones8e6a8d72013-03-28 16:11:11 +00002907 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01002908 struct ab8500_regulator_info *info = NULL;
2909 struct regulator_config config = { };
2910 int err;
2911
2912 /* assign per-regulator data */
Lee Jones33aeb492013-04-02 13:24:14 +01002913 info = &abx500_regulator.info[id];
Lee Jonesa7ac1d92012-05-17 14:45:14 +01002914 info->dev = &pdev->dev;
2915
2916 config.dev = &pdev->dev;
2917 config.init_data = init_data;
2918 config.driver_data = info;
2919 config.of_node = np;
2920
2921 /* fix for hardware before ab8500v2.0 */
Lee Jones8e6a8d72013-03-28 16:11:11 +00002922 if (is_ab8500_1p1_or_earlier(ab8500)) {
Lee Jonesa7ac1d92012-05-17 14:45:14 +01002923 if (info->desc.id == AB8500_LDO_AUX3) {
2924 info->desc.n_voltages =
2925 ARRAY_SIZE(ldo_vauxn_voltages);
Axel Linec1cc4d2012-05-20 10:33:35 +08002926 info->desc.volt_table = ldo_vauxn_voltages;
Lee Jonesa7ac1d92012-05-17 14:45:14 +01002927 info->voltage_mask = 0xf;
2928 }
2929 }
2930
2931 /* register regulator with framework */
2932 info->regulator = regulator_register(&info->desc, &config);
2933 if (IS_ERR(info->regulator)) {
2934 err = PTR_ERR(info->regulator);
2935 dev_err(&pdev->dev, "failed to register regulator %s\n",
2936 info->desc.name);
2937 /* when we fail, un-register all earlier regulators */
2938 while (--id >= 0) {
Lee Jones33aeb492013-04-02 13:24:14 +01002939 info = &abx500_regulator.info[id];
Lee Jonesa7ac1d92012-05-17 14:45:14 +01002940 regulator_unregister(info->regulator);
2941 }
2942 return err;
2943 }
2944
2945 return 0;
2946}
2947
Lee Jonesb54969a2013-03-28 16:11:10 +00002948static struct of_regulator_match ab8500_regulator_match[] = {
Lee Jones7e715b92012-05-30 12:47:26 +08002949 { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB8500_LDO_AUX1, },
2950 { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB8500_LDO_AUX2, },
2951 { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB8500_LDO_AUX3, },
2952 { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB8500_LDO_INTCORE, },
2953 { .name = "ab8500_ldo_tvout", .driver_data = (void *) AB8500_LDO_TVOUT, },
Lee Jones7e715b92012-05-30 12:47:26 +08002954 { .name = "ab8500_ldo_audio", .driver_data = (void *) AB8500_LDO_AUDIO, },
2955 { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB8500_LDO_ANAMIC1, },
2956 { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB8500_LDO_ANAMIC2, },
2957 { .name = "ab8500_ldo_dmic", .driver_data = (void *) AB8500_LDO_DMIC, },
2958 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB8500_LDO_ANA, },
Lee Jones3a8334b2012-05-17 14:45:16 +01002959};
2960
Lee Jones547f3842013-03-28 16:11:14 +00002961static struct of_regulator_match ab8505_regulator_match[] = {
2962 { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB8505_LDO_AUX1, },
2963 { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB8505_LDO_AUX2, },
2964 { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB8505_LDO_AUX3, },
2965 { .name = "ab8500_ldo_aux4", .driver_data = (void *) AB8505_LDO_AUX4, },
2966 { .name = "ab8500_ldo_aux5", .driver_data = (void *) AB8505_LDO_AUX5, },
2967 { .name = "ab8500_ldo_aux6", .driver_data = (void *) AB8505_LDO_AUX6, },
2968 { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB8505_LDO_INTCORE, },
2969 { .name = "ab8500_ldo_adc", .driver_data = (void *) AB8505_LDO_ADC, },
2970 { .name = "ab8500_ldo_audio", .driver_data = (void *) AB8505_LDO_AUDIO, },
2971 { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB8505_LDO_ANAMIC1, },
2972 { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB8505_LDO_ANAMIC2, },
2973 { .name = "ab8500_ldo_aux8", .driver_data = (void *) AB8505_LDO_AUX8, },
2974 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB8505_LDO_ANA, },
2975};
2976
Lee Jonesae0a9a32013-03-28 16:11:16 +00002977static struct of_regulator_match ab8540_regulator_match[] = {
2978 { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB8540_LDO_AUX1, },
2979 { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB8540_LDO_AUX2, },
2980 { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB8540_LDO_AUX3, },
2981 { .name = "ab8500_ldo_aux4", .driver_data = (void *) AB8540_LDO_AUX4, },
2982 { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB8540_LDO_INTCORE, },
2983 { .name = "ab8500_ldo_tvout", .driver_data = (void *) AB8540_LDO_TVOUT, },
2984 { .name = "ab8500_ldo_audio", .driver_data = (void *) AB8540_LDO_AUDIO, },
2985 { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB8540_LDO_ANAMIC1, },
2986 { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB8540_LDO_ANAMIC2, },
2987 { .name = "ab8500_ldo_dmic", .driver_data = (void *) AB8540_LDO_DMIC, },
2988 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB8540_LDO_ANA, },
2989 { .name = "ab8500_ldo_sdio", .driver_data = (void *) AB8540_LDO_SDIO, },
2990};
2991
Lee Jones8e6a8d72013-03-28 16:11:11 +00002992static struct of_regulator_match ab9540_regulator_match[] = {
2993 { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB9540_LDO_AUX1, },
2994 { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB9540_LDO_AUX2, },
2995 { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB9540_LDO_AUX3, },
2996 { .name = "ab8500_ldo_aux4", .driver_data = (void *) AB9540_LDO_AUX4, },
2997 { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB9540_LDO_INTCORE, },
2998 { .name = "ab8500_ldo_tvout", .driver_data = (void *) AB9540_LDO_TVOUT, },
2999 { .name = "ab8500_ldo_audio", .driver_data = (void *) AB9540_LDO_AUDIO, },
3000 { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB9540_LDO_ANAMIC1, },
3001 { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB9540_LDO_ANAMIC2, },
3002 { .name = "ab8500_ldo_dmic", .driver_data = (void *) AB9540_LDO_DMIC, },
3003 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB9540_LDO_ANA, },
3004};
3005
Lee Jones33aeb492013-04-02 13:24:14 +01003006static void abx500_get_regulator_info(struct ab8500 *ab8500)
3007{
3008 if (is_ab9540(ab8500)) {
3009 abx500_regulator.info = ab9540_regulator_info;
3010 abx500_regulator.info_size = ARRAY_SIZE(ab9540_regulator_info);
3011 abx500_regulator.init = ab9540_reg_init;
3012 abx500_regulator.init_size = AB9540_NUM_REGULATOR_REGISTERS;
3013 abx500_regulator.match = ab9540_regulator_match;
3014 abx500_regulator.match_size = ARRAY_SIZE(ab9540_regulator_match);
3015 } else if (is_ab8505(ab8500)) {
3016 abx500_regulator.info = ab8505_regulator_info;
3017 abx500_regulator.info_size = ARRAY_SIZE(ab8505_regulator_info);
3018 abx500_regulator.init = ab8505_reg_init;
3019 abx500_regulator.init_size = AB8505_NUM_REGULATOR_REGISTERS;
3020 abx500_regulator.match = ab8505_regulator_match;
3021 abx500_regulator.match_size = ARRAY_SIZE(ab8505_regulator_match);
3022 } else if (is_ab8540(ab8500)) {
3023 abx500_regulator.info = ab8540_regulator_info;
3024 abx500_regulator.info_size = ARRAY_SIZE(ab8540_regulator_info);
3025 abx500_regulator.init = ab8540_reg_init;
3026 abx500_regulator.init_size = AB8540_NUM_REGULATOR_REGISTERS;
3027 abx500_regulator.match = ab8540_regulator_match;
3028 abx500_regulator.match_size = ARRAY_SIZE(ab8540_regulator_match);
3029 } else {
3030 abx500_regulator.info = ab8500_regulator_info;
3031 abx500_regulator.info_size = ARRAY_SIZE(ab8500_regulator_info);
3032 abx500_regulator.init = ab8500_reg_init;
3033 abx500_regulator.init_size = AB8500_NUM_REGULATOR_REGISTERS;
3034 abx500_regulator.match = ab8500_regulator_match;
3035 abx500_regulator.match_size = ARRAY_SIZE(ab8500_regulator_match);
3036 }
3037}
3038
Bill Pembertona5023572012-11-19 13:22:22 -05003039static int
Lee Jonesb54969a2013-03-28 16:11:10 +00003040ab8500_regulator_of_probe(struct platform_device *pdev,
Lee Jonesb54969a2013-03-28 16:11:10 +00003041 struct device_node *np)
Lee Jones3a8334b2012-05-17 14:45:16 +01003042{
Lee Jones33aeb492013-04-02 13:24:14 +01003043 struct of_regulator_match *match = abx500_regulator.match;
Lee Jones3a8334b2012-05-17 14:45:16 +01003044 int err, i;
3045
Lee Jones33aeb492013-04-02 13:24:14 +01003046 for (i = 0; i < abx500_regulator.info_size; i++) {
Lee Jones3a8334b2012-05-17 14:45:16 +01003047 err = ab8500_regulator_register(
Lee Jones33aeb492013-04-02 13:24:14 +01003048 pdev, match[i].init_data, i, match[i].of_node);
Lee Jones3a8334b2012-05-17 14:45:16 +01003049 if (err)
3050 return err;
3051 }
3052
3053 return 0;
3054}
3055
Bill Pembertona5023572012-11-19 13:22:22 -05003056static int ab8500_regulator_probe(struct platform_device *pdev)
Sundar R IYERc789ca22010-07-13 21:48:56 +05303057{
3058 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
Lee Jones3a8334b2012-05-17 14:45:16 +01003059 struct device_node *np = pdev->dev.of_node;
Bengt Jonsson732805a2013-03-21 15:59:03 +00003060 struct ab8500_platform_data *ppdata;
3061 struct ab8500_regulator_platform_data *pdata;
Sundar R IYERc789ca22010-07-13 21:48:56 +05303062 int i, err;
Lee Jonesb54969a2013-03-28 16:11:10 +00003063
Lee Jones33aeb492013-04-02 13:24:14 +01003064 if (!ab8500) {
3065 dev_err(&pdev->dev, "null mfd parent\n");
3066 return -EINVAL;
Lee Jones8e6a8d72013-03-28 16:11:11 +00003067 }
Sundar R IYERc789ca22010-07-13 21:48:56 +05303068
Lee Jones33aeb492013-04-02 13:24:14 +01003069 abx500_get_regulator_info(ab8500);
3070
Lee Jones3a8334b2012-05-17 14:45:16 +01003071 if (np) {
Lee Jones33aeb492013-04-02 13:24:14 +01003072 err = of_regulator_match(&pdev->dev, np,
3073 abx500_regulator.match,
3074 abx500_regulator.match_size);
Lee Jones3a8334b2012-05-17 14:45:16 +01003075 if (err < 0) {
3076 dev_err(&pdev->dev,
3077 "Error parsing regulator init data: %d\n", err);
3078 return err;
3079 }
3080
Lee Jones33aeb492013-04-02 13:24:14 +01003081 err = ab8500_regulator_of_probe(pdev, np);
Lee Jones3a8334b2012-05-17 14:45:16 +01003082 return err;
3083 }
3084
Bengt Jonsson732805a2013-03-21 15:59:03 +00003085 ppdata = dev_get_platdata(ab8500->dev);
3086 if (!ppdata) {
3087 dev_err(&pdev->dev, "null parent pdata\n");
3088 return -EINVAL;
3089 }
3090
3091 pdata = ppdata->regulator;
Bengt Jonssonfc24b422010-12-10 11:08:45 +01003092 if (!pdata) {
3093 dev_err(&pdev->dev, "null pdata\n");
3094 return -EINVAL;
3095 }
Sundar R IYERc789ca22010-07-13 21:48:56 +05303096
Bengt Jonssoncb189b02010-12-10 11:08:40 +01003097 /* make sure the platform data has the correct size */
Lee Jones33aeb492013-04-02 13:24:14 +01003098 if (pdata->num_regulator != abx500_regulator.info_size) {
Bengt Jonsson79568b942011-03-11 11:54:46 +01003099 dev_err(&pdev->dev, "Configuration error: size mismatch.\n");
Bengt Jonssoncb189b02010-12-10 11:08:40 +01003100 return -EINVAL;
3101 }
3102
Lee Jonesda0b0c42013-03-28 16:11:09 +00003103 /* initialize debug (initial state is recorded with this call) */
3104 err = ab8500_regulator_debug_init(pdev);
3105 if (err)
3106 return err;
3107
Bengt Jonsson79568b942011-03-11 11:54:46 +01003108 /* initialize registers */
Bengt Jonsson732805a2013-03-21 15:59:03 +00003109 for (i = 0; i < pdata->num_reg_init; i++) {
Lee Jones3c1b8432013-03-21 15:59:01 +00003110 int id, mask, value;
Bengt Jonsson79568b942011-03-11 11:54:46 +01003111
Bengt Jonsson732805a2013-03-21 15:59:03 +00003112 id = pdata->reg_init[i].id;
3113 mask = pdata->reg_init[i].mask;
3114 value = pdata->reg_init[i].value;
Bengt Jonsson79568b942011-03-11 11:54:46 +01003115
3116 /* check for configuration errors */
Lee Jones33aeb492013-04-02 13:24:14 +01003117 BUG_ON(id >= abx500_regulator.init_size);
Bengt Jonsson79568b942011-03-11 11:54:46 +01003118
Lee Jones33aeb492013-04-02 13:24:14 +01003119 err = ab8500_regulator_init_registers(pdev, id, mask, value);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003120 if (err < 0)
Bengt Jonsson79568b942011-03-11 11:54:46 +01003121 return err;
Bengt Jonsson79568b942011-03-11 11:54:46 +01003122 }
3123
Rabin Vincentf7eae372013-04-02 13:24:08 +01003124 if (!is_ab8505(ab8500)) {
3125 /* register external regulators (before Vaux1, 2 and 3) */
3126 err = ab8500_ext_regulator_init(pdev);
3127 if (err)
3128 return err;
3129 }
Lee Jonesd1a82002013-03-28 16:11:01 +00003130
Sundar R IYERc789ca22010-07-13 21:48:56 +05303131 /* register all regulators */
Lee Jones33aeb492013-04-02 13:24:14 +01003132 for (i = 0; i < abx500_regulator.info_size; i++) {
Lee Jonesb54969a2013-03-28 16:11:10 +00003133 err = ab8500_regulator_register(pdev, &pdata->regulator[i],
Lee Jones33aeb492013-04-02 13:24:14 +01003134 i, NULL);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01003135 if (err < 0)
Sundar R IYERc789ca22010-07-13 21:48:56 +05303136 return err;
Sundar R IYERc789ca22010-07-13 21:48:56 +05303137 }
3138
3139 return 0;
3140}
3141
Bill Pemberton8dc995f2012-11-19 13:26:10 -05003142static int ab8500_regulator_remove(struct platform_device *pdev)
Sundar R IYERc789ca22010-07-13 21:48:56 +05303143{
Lee Jonesd1a82002013-03-28 16:11:01 +00003144 int i, err;
Lee Jones8e6a8d72013-03-28 16:11:11 +00003145 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
Sundar R IYERc789ca22010-07-13 21:48:56 +05303146
Lee Jones33aeb492013-04-02 13:24:14 +01003147 for (i = 0; i < abx500_regulator.info_size; i++) {
Sundar R IYERc789ca22010-07-13 21:48:56 +05303148 struct ab8500_regulator_info *info = NULL;
Lee Jones33aeb492013-04-02 13:24:14 +01003149 info = &abx500_regulator.info[i];
Bengt Jonsson09aefa12010-12-10 11:08:46 +01003150
3151 dev_vdbg(rdev_get_dev(info->regulator),
3152 "%s-remove\n", info->desc.name);
3153
Sundar R IYERc789ca22010-07-13 21:48:56 +05303154 regulator_unregister(info->regulator);
3155 }
3156
Rabin Vincentf7eae372013-04-02 13:24:08 +01003157 if (!is_ab8505(ab8500)) {
3158 /* remove external regulators (after Vaux1, 2 and 3) */
3159 err = ab8500_ext_regulator_exit(pdev);
3160 if (err)
3161 return err;
3162 }
Lee Jonesd1a82002013-03-28 16:11:01 +00003163
Lee Jonesda0b0c42013-03-28 16:11:09 +00003164 /* remove regulator debug */
3165 err = ab8500_regulator_debug_exit(pdev);
3166 if (err)
3167 return err;
3168
Sundar R IYERc789ca22010-07-13 21:48:56 +05303169 return 0;
3170}
3171
3172static struct platform_driver ab8500_regulator_driver = {
3173 .probe = ab8500_regulator_probe,
Bill Pemberton5eb9f2b2012-11-19 13:20:42 -05003174 .remove = ab8500_regulator_remove,
Sundar R IYERc789ca22010-07-13 21:48:56 +05303175 .driver = {
3176 .name = "ab8500-regulator",
3177 .owner = THIS_MODULE,
Sundar R IYERc789ca22010-07-13 21:48:56 +05303178 },
3179};
3180
3181static int __init ab8500_regulator_init(void)
3182{
3183 int ret;
3184
3185 ret = platform_driver_register(&ab8500_regulator_driver);
3186 if (ret != 0)
3187 pr_err("Failed to register ab8500 regulator: %d\n", ret);
3188
3189 return ret;
3190}
3191subsys_initcall(ab8500_regulator_init);
3192
3193static void __exit ab8500_regulator_exit(void)
3194{
3195 platform_driver_unregister(&ab8500_regulator_driver);
3196}
3197module_exit(ab8500_regulator_exit);
3198
3199MODULE_LICENSE("GPL v2");
3200MODULE_AUTHOR("Sundar Iyer <sundar.iyer@stericsson.com>");
Bengt Jonsson732805a2013-03-21 15:59:03 +00003201MODULE_AUTHOR("Bengt Jonsson <bengt.g.jonsson@stericsson.com>");
Lee Jones547f3842013-03-28 16:11:14 +00003202MODULE_AUTHOR("Daniel Willerud <daniel.willerud@stericsson.com>");
Sundar R IYERc789ca22010-07-13 21:48:56 +05303203MODULE_DESCRIPTION("Regulator Driver for ST-Ericsson AB8500 Mixed-Sig PMIC");
3204MODULE_ALIAS("platform:ab8500-regulator");