blob: 3fcb4cbaab0297b60b1440704dc771fd5035366a [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
Lee Jones3fe52282013-04-02 13:24:12 +010047 * @shared_mode: used when mode is shared between two regulators
Bengt Jonsson7ce46692013-03-21 15:59:00 +000048 * @load_lp_uA: maximum load in idle (low power) mode
Mattias Wallin47c16972010-09-10 17:47:56 +020049 * @update_bank: bank to control on/off
Sundar R IYERc789ca22010-07-13 21:48:56 +053050 * @update_reg: register to control on/off
Emeric Vigierbd28a152013-03-21 15:58:59 +000051 * @update_mask: mask to enable/disable and set mode of regulator
52 * @update_val: bits holding the regulator current mode
53 * @update_val_idle: bits to enable the regulator in idle (low power) mode
54 * @update_val_normal: bits to enable the regulator in normal (high power) mode
Lee Jones3fe52282013-04-02 13:24:12 +010055 * @mode_bank: bank with location of mode register
56 * @mode_reg: mode register
57 * @mode_mask: mask for setting mode
58 * @mode_val_idle: mode setting for low power
59 * @mode_val_normal: mode setting for normal power
Mattias Wallin47c16972010-09-10 17:47:56 +020060 * @voltage_bank: bank to control regulator voltage
Sundar R IYERc789ca22010-07-13 21:48:56 +053061 * @voltage_reg: register to control regulator voltage
62 * @voltage_mask: mask to control regulator voltage
Sundar R IYERc789ca22010-07-13 21:48:56 +053063 */
64struct ab8500_regulator_info {
65 struct device *dev;
66 struct regulator_desc desc;
Lee Jones3fe52282013-04-02 13:24:12 +010067 struct ab8500_shared_mode *shared_mode;
Bengt Jonsson7ce46692013-03-21 15:59:00 +000068 int load_lp_uA;
Mattias Wallin47c16972010-09-10 17:47:56 +020069 u8 update_bank;
70 u8 update_reg;
Bengt Jonssone1159e62010-12-10 11:08:44 +010071 u8 update_mask;
Emeric Vigierbd28a152013-03-21 15:58:59 +000072 u8 update_val;
73 u8 update_val_idle;
74 u8 update_val_normal;
Lee Jones3fe52282013-04-02 13:24:12 +010075 u8 mode_bank;
76 u8 mode_reg;
77 u8 mode_mask;
78 u8 mode_val_idle;
79 u8 mode_val_normal;
Mattias Wallin47c16972010-09-10 17:47:56 +020080 u8 voltage_bank;
81 u8 voltage_reg;
82 u8 voltage_mask;
Lee Jonesd7607ba2013-04-02 13:24:11 +010083 struct {
84 u8 voltage_limit;
85 u8 voltage_bank;
86 u8 voltage_reg;
87 u8 voltage_mask;
Lee Jonesd7607ba2013-04-02 13:24:11 +010088 } expand_register;
Sundar R IYERc789ca22010-07-13 21:48:56 +053089};
90
91/* voltage tables for the vauxn/vintcore supplies */
Axel Linec1cc4d2012-05-20 10:33:35 +080092static const unsigned int ldo_vauxn_voltages[] = {
Sundar R IYERc789ca22010-07-13 21:48:56 +053093 1100000,
94 1200000,
95 1300000,
96 1400000,
97 1500000,
98 1800000,
99 1850000,
100 1900000,
101 2500000,
102 2650000,
103 2700000,
104 2750000,
105 2800000,
106 2900000,
107 3000000,
108 3300000,
109};
110
Axel Linec1cc4d2012-05-20 10:33:35 +0800111static const unsigned int ldo_vaux3_voltages[] = {
Bengt Jonsson2b751512010-12-10 11:08:43 +0100112 1200000,
113 1500000,
114 1800000,
115 2100000,
116 2500000,
117 2750000,
118 2790000,
119 2910000,
120};
121
Lee Jones62ab4112013-03-28 16:11:18 +0000122static const unsigned int ldo_vaux56_voltages[] = {
Lee Jones547f3842013-03-28 16:11:14 +0000123 1800000,
124 1050000,
125 1100000,
126 1200000,
127 1500000,
128 2200000,
129 2500000,
130 2790000,
131};
132
Axel Linec1cc4d2012-05-20 10:33:35 +0800133static const unsigned int ldo_vintcore_voltages[] = {
Sundar R IYERc789ca22010-07-13 21:48:56 +0530134 1200000,
135 1225000,
136 1250000,
137 1275000,
138 1300000,
139 1325000,
140 1350000,
141};
142
Lee Jones62ab4112013-03-28 16:11:18 +0000143static const unsigned int ldo_sdio_voltages[] = {
Lee Jonesae0a9a32013-03-28 16:11:16 +0000144 1160000,
145 1050000,
146 1100000,
147 1500000,
148 1800000,
149 2200000,
150 2910000,
151 3050000,
152};
153
Lee Jonesb080c782013-03-28 16:11:17 +0000154static const unsigned int fixed_1200000_voltage[] = {
155 1200000,
156};
157
158static const unsigned int fixed_1800000_voltage[] = {
159 1800000,
160};
161
162static const unsigned int fixed_2000000_voltage[] = {
163 2000000,
164};
165
166static const unsigned int fixed_2050000_voltage[] = {
167 2050000,
168};
169
170static const unsigned int fixed_3300000_voltage[] = {
171 3300000,
172};
173
Lee Jones8a3b1b82013-04-02 13:24:09 +0100174static const unsigned int ldo_vana_voltages[] = {
175 1050000,
176 1075000,
177 1100000,
178 1125000,
179 1150000,
180 1175000,
181 1200000,
182 1225000,
183};
184
185static const unsigned int ldo_vaudio_voltages[] = {
186 2000000,
187 2100000,
188 2200000,
189 2300000,
190 2400000,
191 2500000,
192 2600000,
193 2600000, /* Duplicated in Vaudio and IsoUicc Control register. */
194};
195
Lee Jones4c84b4d2013-04-02 13:24:13 +0100196static const unsigned int ldo_vdmic_voltages[] = {
197 1800000,
198 1900000,
199 2000000,
200 2850000,
201};
202
Lee Jones3fe52282013-04-02 13:24:12 +0100203static DEFINE_MUTEX(shared_mode_mutex);
204static struct ab8500_shared_mode ldo_anamic1_shared;
205static struct ab8500_shared_mode ldo_anamic2_shared;
206
Sundar R IYERc789ca22010-07-13 21:48:56 +0530207static int ab8500_regulator_enable(struct regulator_dev *rdev)
208{
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100209 int ret;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530210 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
211
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100212 if (info == NULL) {
213 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
Sundar R IYERc789ca22010-07-13 21:48:56 +0530214 return -EINVAL;
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100215 }
Sundar R IYERc789ca22010-07-13 21:48:56 +0530216
Mattias Wallin47c16972010-09-10 17:47:56 +0200217 ret = abx500_mask_and_set_register_interruptible(info->dev,
Bengt Jonssone1159e62010-12-10 11:08:44 +0100218 info->update_bank, info->update_reg,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000219 info->update_mask, info->update_val);
Axel Linf71bf522013-03-26 16:13:14 +0800220 if (ret < 0) {
Sundar R IYERc789ca22010-07-13 21:48:56 +0530221 dev_err(rdev_get_dev(rdev),
222 "couldn't set enable bits for regulator\n");
Axel Linf71bf522013-03-26 16:13:14 +0800223 return ret;
224 }
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100225
226 dev_vdbg(rdev_get_dev(rdev),
227 "%s-enable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
228 info->desc.name, info->update_bank, info->update_reg,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000229 info->update_mask, info->update_val);
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100230
Sundar R IYERc789ca22010-07-13 21:48:56 +0530231 return ret;
232}
233
234static int ab8500_regulator_disable(struct regulator_dev *rdev)
235{
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100236 int ret;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530237 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
238
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100239 if (info == NULL) {
240 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
Sundar R IYERc789ca22010-07-13 21:48:56 +0530241 return -EINVAL;
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100242 }
Sundar R IYERc789ca22010-07-13 21:48:56 +0530243
Mattias Wallin47c16972010-09-10 17:47:56 +0200244 ret = abx500_mask_and_set_register_interruptible(info->dev,
Bengt Jonssone1159e62010-12-10 11:08:44 +0100245 info->update_bank, info->update_reg,
246 info->update_mask, 0x0);
Axel Linf71bf522013-03-26 16:13:14 +0800247 if (ret < 0) {
Sundar R IYERc789ca22010-07-13 21:48:56 +0530248 dev_err(rdev_get_dev(rdev),
249 "couldn't set disable bits for regulator\n");
Axel Linf71bf522013-03-26 16:13:14 +0800250 return ret;
251 }
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100252
253 dev_vdbg(rdev_get_dev(rdev),
254 "%s-disable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
255 info->desc.name, info->update_bank, info->update_reg,
256 info->update_mask, 0x0);
257
Sundar R IYERc789ca22010-07-13 21:48:56 +0530258 return ret;
259}
260
Axel Lin438e6952013-04-07 23:12:28 +0800261static int ab8500_regulator_is_enabled(struct regulator_dev *rdev)
262{
263 int ret;
264 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
265 u8 regval;
266
267 if (info == NULL) {
268 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
269 return -EINVAL;
270 }
271
272 ret = abx500_get_register_interruptible(info->dev,
273 info->update_bank, info->update_reg, &regval);
274 if (ret < 0) {
275 dev_err(rdev_get_dev(rdev),
276 "couldn't read 0x%x register\n", info->update_reg);
277 return ret;
278 }
279
280 dev_vdbg(rdev_get_dev(rdev),
281 "%s-is_enabled (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
282 " 0x%x\n",
283 info->desc.name, info->update_bank, info->update_reg,
284 info->update_mask, regval);
285
286 if (regval & info->update_mask)
287 return 1;
288 else
289 return 0;
290}
291
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000292static unsigned int ab8500_regulator_get_optimum_mode(
293 struct regulator_dev *rdev, int input_uV,
294 int output_uV, int load_uA)
295{
296 unsigned int mode;
297
298 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
299
300 if (info == NULL) {
301 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
302 return -EINVAL;
303 }
304
305 if (load_uA <= info->load_lp_uA)
306 mode = REGULATOR_MODE_IDLE;
307 else
308 mode = REGULATOR_MODE_NORMAL;
309
310 return mode;
311}
312
Emeric Vigierbd28a152013-03-21 15:58:59 +0000313static int ab8500_regulator_set_mode(struct regulator_dev *rdev,
314 unsigned int mode)
315{
Lee Jones3fe52282013-04-02 13:24:12 +0100316 int ret = 0;
Axel Lin0b665062013-04-09 20:17:15 +0800317 u8 bank, reg, mask, val;
318 bool lp_mode_req = false;
Emeric Vigierbd28a152013-03-21 15:58:59 +0000319 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
320
321 if (info == NULL) {
322 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
323 return -EINVAL;
324 }
325
Lee Jones3fe52282013-04-02 13:24:12 +0100326 if (info->mode_mask) {
Lee Jones3fe52282013-04-02 13:24:12 +0100327 bank = info->mode_bank;
328 reg = info->mode_reg;
329 mask = info->mode_mask;
330 } else {
Lee Jones3fe52282013-04-02 13:24:12 +0100331 bank = info->update_bank;
332 reg = info->update_reg;
333 mask = info->update_mask;
334 }
335
Axel Lin0b665062013-04-09 20:17:15 +0800336 if (info->shared_mode)
337 mutex_lock(&shared_mode_mutex);
338
339 switch (mode) {
340 case REGULATOR_MODE_NORMAL:
341 if (info->shared_mode)
342 lp_mode_req = false;
343
344 if (info->mode_mask)
345 val = info->mode_val_normal;
346 else
347 val = info->update_val_normal;
348 break;
349 case REGULATOR_MODE_IDLE:
350 if (info->shared_mode) {
351 struct ab8500_regulator_info *shared_regulator;
352
353 shared_regulator = info->shared_mode->shared_regulator;
354 if (!shared_regulator->shared_mode->lp_mode_req) {
355 /* Other regulator prevent LP mode */
356 info->shared_mode->lp_mode_req = true;
357 goto out_unlock;
358 }
359
360 lp_mode_req = true;
361 }
362
363 if (info->mode_mask)
364 val = info->mode_val_idle;
365 else
366 val = info->update_val_idle;
367 break;
368 default:
369 ret = -EINVAL;
370 goto out_unlock;
371 }
372
373 if (info->mode_mask || ab8500_regulator_is_enabled(rdev)) {
Emeric Vigierbd28a152013-03-21 15:58:59 +0000374 ret = abx500_mask_and_set_register_interruptible(info->dev,
Lee Jones3fe52282013-04-02 13:24:12 +0100375 bank, reg, mask, val);
Axel Linf04adc52013-04-09 20:15:06 +0800376 if (ret < 0) {
Emeric Vigierbd28a152013-03-21 15:58:59 +0000377 dev_err(rdev_get_dev(rdev),
378 "couldn't set regulator mode\n");
Axel Linf04adc52013-04-09 20:15:06 +0800379 goto out_unlock;
380 }
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000381
382 dev_vdbg(rdev_get_dev(rdev),
383 "%s-set_mode (bank, reg, mask, value): "
384 "0x%x, 0x%x, 0x%x, 0x%x\n",
Lee Jones3fe52282013-04-02 13:24:12 +0100385 info->desc.name, bank, reg,
386 mask, val);
Emeric Vigierbd28a152013-03-21 15:58:59 +0000387 }
388
Axel Lin0b665062013-04-09 20:17:15 +0800389 if (!info->mode_mask)
Axel Linf04adc52013-04-09 20:15:06 +0800390 info->update_val = val;
391
Axel Lin0b665062013-04-09 20:17:15 +0800392 if (info->shared_mode)
393 info->shared_mode->lp_mode_req = lp_mode_req;
394
Axel Linf04adc52013-04-09 20:15:06 +0800395out_unlock:
Lee Jones3fe52282013-04-02 13:24:12 +0100396 if (info->shared_mode)
397 mutex_unlock(&shared_mode_mutex);
Axel Lin742a7322013-03-28 17:23:00 +0800398
Lee Jones3fe52282013-04-02 13:24:12 +0100399 return ret;
Emeric Vigierbd28a152013-03-21 15:58:59 +0000400}
401
402static unsigned int ab8500_regulator_get_mode(struct regulator_dev *rdev)
403{
404 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
405 int ret;
Lee Jones3fe52282013-04-02 13:24:12 +0100406 u8 val;
407 u8 val_normal;
408 u8 val_idle;
Emeric Vigierbd28a152013-03-21 15:58:59 +0000409
410 if (info == NULL) {
411 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
412 return -EINVAL;
413 }
414
Lee Jones3fe52282013-04-02 13:24:12 +0100415 /* Need special handling for shared mode */
416 if (info->shared_mode) {
417 if (info->shared_mode->lp_mode_req)
418 return REGULATOR_MODE_IDLE;
419 else
420 return REGULATOR_MODE_NORMAL;
421 }
422
423 if (info->mode_mask) {
424 /* Dedicated register for handling mode */
425 ret = abx500_get_register_interruptible(info->dev,
426 info->mode_bank, info->mode_reg, &val);
427 val = val & info->mode_mask;
428
429 val_normal = info->mode_val_normal;
430 val_idle = info->mode_val_idle;
431 } else {
432 /* Mode register same as enable register */
433 val = info->update_val;
434 val_normal = info->update_val_normal;
435 val_idle = info->update_val_idle;
436 }
437
438 if (val == val_normal)
Emeric Vigierbd28a152013-03-21 15:58:59 +0000439 ret = REGULATOR_MODE_NORMAL;
Lee Jones3fe52282013-04-02 13:24:12 +0100440 else if (val == val_idle)
Emeric Vigierbd28a152013-03-21 15:58:59 +0000441 ret = REGULATOR_MODE_IDLE;
442 else
443 ret = -EINVAL;
444
445 return ret;
446}
447
Axel Lin3bf6e902012-02-24 17:15:45 +0800448static int ab8500_regulator_get_voltage_sel(struct regulator_dev *rdev)
Sundar R IYERc789ca22010-07-13 21:48:56 +0530449{
Axel Lin5d9de8b2013-04-17 22:55:45 +0800450 int ret, voltage_shift;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530451 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100452 u8 regval;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530453
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100454 if (info == NULL) {
455 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
Sundar R IYERc789ca22010-07-13 21:48:56 +0530456 return -EINVAL;
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100457 }
Sundar R IYERc789ca22010-07-13 21:48:56 +0530458
Axel Lin5d9de8b2013-04-17 22:55:45 +0800459 voltage_shift = ffs(info->voltage_mask) - 1;
460
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100461 ret = abx500_get_register_interruptible(info->dev,
462 info->voltage_bank, info->voltage_reg, &regval);
Sundar R IYERc789ca22010-07-13 21:48:56 +0530463 if (ret < 0) {
464 dev_err(rdev_get_dev(rdev),
465 "couldn't read voltage reg for regulator\n");
466 return ret;
467 }
468
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100469 dev_vdbg(rdev_get_dev(rdev),
Linus Walleija0a70142012-08-20 18:41:35 +0200470 "%s-get_voltage (bank, reg, mask, shift, value): "
471 "0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n",
472 info->desc.name, info->voltage_bank,
473 info->voltage_reg, info->voltage_mask,
Axel Lin5d9de8b2013-04-17 22:55:45 +0800474 voltage_shift, regval);
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100475
Axel Lin5d9de8b2013-04-17 22:55:45 +0800476 return (regval & info->voltage_mask) >> voltage_shift;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530477}
478
Axel Linae713d32012-03-20 09:51:08 +0800479static int ab8500_regulator_set_voltage_sel(struct regulator_dev *rdev,
480 unsigned selector)
Sundar R IYERc789ca22010-07-13 21:48:56 +0530481{
Axel Lin5d9de8b2013-04-17 22:55:45 +0800482 int ret, voltage_shift;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530483 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100484 u8 regval;
Sundar R IYERc789ca22010-07-13 21:48:56 +0530485
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100486 if (info == NULL) {
487 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
Sundar R IYERc789ca22010-07-13 21:48:56 +0530488 return -EINVAL;
Bengt Jonssonfc24b422010-12-10 11:08:45 +0100489 }
Sundar R IYERc789ca22010-07-13 21:48:56 +0530490
Axel Lin5d9de8b2013-04-17 22:55:45 +0800491 voltage_shift = ffs(info->voltage_mask) - 1;
492
Sundar R IYERc789ca22010-07-13 21:48:56 +0530493 /* set the registers for the request */
Axel Lin5d9de8b2013-04-17 22:55:45 +0800494 regval = (u8)selector << voltage_shift;
Mattias Wallin47c16972010-09-10 17:47:56 +0200495 ret = abx500_mask_and_set_register_interruptible(info->dev,
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100496 info->voltage_bank, info->voltage_reg,
497 info->voltage_mask, regval);
Sundar R IYERc789ca22010-07-13 21:48:56 +0530498 if (ret < 0)
499 dev_err(rdev_get_dev(rdev),
500 "couldn't set voltage reg for regulator\n");
501
Bengt Jonsson09aefa12010-12-10 11:08:46 +0100502 dev_vdbg(rdev_get_dev(rdev),
503 "%s-set_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
504 " 0x%x\n",
505 info->desc.name, info->voltage_bank, info->voltage_reg,
506 info->voltage_mask, regval);
507
Sundar R IYERc789ca22010-07-13 21:48:56 +0530508 return ret;
509}
510
Axel Lin6d66d992019-04-12 22:11:57 +0800511static const struct regulator_ops ab8500_regulator_volt_mode_ops = {
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000512 .enable = ab8500_regulator_enable,
513 .disable = ab8500_regulator_disable,
514 .is_enabled = ab8500_regulator_is_enabled,
515 .get_optimum_mode = ab8500_regulator_get_optimum_mode,
516 .set_mode = ab8500_regulator_set_mode,
517 .get_mode = ab8500_regulator_get_mode,
518 .get_voltage_sel = ab8500_regulator_get_voltage_sel,
519 .set_voltage_sel = ab8500_regulator_set_voltage_sel,
520 .list_voltage = regulator_list_voltage_table,
Sundar R IYERc789ca22010-07-13 21:48:56 +0530521};
522
Axel Lin6d66d992019-04-12 22:11:57 +0800523static const struct regulator_ops ab8500_regulator_volt_ops = {
Lee Jones8a3b1b82013-04-02 13:24:09 +0100524 .enable = ab8500_regulator_enable,
525 .disable = ab8500_regulator_disable,
526 .is_enabled = ab8500_regulator_is_enabled,
527 .get_voltage_sel = ab8500_regulator_get_voltage_sel,
528 .set_voltage_sel = ab8500_regulator_set_voltage_sel,
529 .list_voltage = regulator_list_voltage_table,
Lee Jones8a3b1b82013-04-02 13:24:09 +0100530};
531
Axel Lin6d66d992019-04-12 22:11:57 +0800532static const struct regulator_ops ab8500_regulator_mode_ops = {
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000533 .enable = ab8500_regulator_enable,
534 .disable = ab8500_regulator_disable,
535 .is_enabled = ab8500_regulator_is_enabled,
536 .get_optimum_mode = ab8500_regulator_get_optimum_mode,
537 .set_mode = ab8500_regulator_set_mode,
538 .get_mode = ab8500_regulator_get_mode,
Axel Lind7816ab2013-04-02 13:24:22 +0100539 .list_voltage = regulator_list_voltage_table,
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000540};
541
Axel Lin6d66d992019-04-12 22:11:57 +0800542static const struct regulator_ops ab8500_regulator_ops = {
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000543 .enable = ab8500_regulator_enable,
544 .disable = ab8500_regulator_disable,
545 .is_enabled = ab8500_regulator_is_enabled,
Axel Lind7816ab2013-04-02 13:24:22 +0100546 .list_voltage = regulator_list_voltage_table,
Sundar R IYERc789ca22010-07-13 21:48:56 +0530547};
548
Axel Lin6d66d992019-04-12 22:11:57 +0800549static const struct regulator_ops ab8500_regulator_anamic_mode_ops = {
Lee Jones3fe52282013-04-02 13:24:12 +0100550 .enable = ab8500_regulator_enable,
551 .disable = ab8500_regulator_disable,
552 .is_enabled = ab8500_regulator_is_enabled,
553 .set_mode = ab8500_regulator_set_mode,
554 .get_mode = ab8500_regulator_get_mode,
555 .list_voltage = regulator_list_voltage_table,
556};
557
Lee Jones8e6a8d72013-03-28 16:11:11 +0000558/* AB8500 regulator information */
Bengt Jonsson6909b452010-12-10 11:08:47 +0100559static struct ab8500_regulator_info
560 ab8500_regulator_info[AB8500_NUM_REGULATORS] = {
Sundar R IYERc789ca22010-07-13 21:48:56 +0530561 /*
Bengt Jonssone1159e62010-12-10 11:08:44 +0100562 * Variable Voltage Regulators
563 * name, min mV, max mV,
564 * update bank, reg, mask, enable val
Axel Linec1cc4d2012-05-20 10:33:35 +0800565 * volt bank, reg, mask
Sundar R IYERc789ca22010-07-13 21:48:56 +0530566 */
Bengt Jonsson6909b452010-12-10 11:08:47 +0100567 [AB8500_LDO_AUX1] = {
568 .desc = {
569 .name = "LDO-AUX1",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000570 .ops = &ab8500_regulator_volt_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100571 .type = REGULATOR_VOLTAGE,
572 .id = AB8500_LDO_AUX1,
573 .owner = THIS_MODULE,
574 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Axel Linec1cc4d2012-05-20 10:33:35 +0800575 .volt_table = ldo_vauxn_voltages,
Axel Lin530158b2013-03-27 17:47:22 +0800576 .enable_time = 200,
Lee Jonesce6f5ea2013-06-07 17:11:28 +0100577 .supply_name = "vin",
Bengt Jonsson6909b452010-12-10 11:08:47 +0100578 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000579 .load_lp_uA = 5000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100580 .update_bank = 0x04,
581 .update_reg = 0x09,
582 .update_mask = 0x03,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000583 .update_val = 0x01,
584 .update_val_idle = 0x03,
585 .update_val_normal = 0x01,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100586 .voltage_bank = 0x04,
587 .voltage_reg = 0x1f,
588 .voltage_mask = 0x0f,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100589 },
590 [AB8500_LDO_AUX2] = {
591 .desc = {
592 .name = "LDO-AUX2",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000593 .ops = &ab8500_regulator_volt_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100594 .type = REGULATOR_VOLTAGE,
595 .id = AB8500_LDO_AUX2,
596 .owner = THIS_MODULE,
597 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Axel Linec1cc4d2012-05-20 10:33:35 +0800598 .volt_table = ldo_vauxn_voltages,
Axel Lin530158b2013-03-27 17:47:22 +0800599 .enable_time = 200,
Lee Jonesce6f5ea2013-06-07 17:11:28 +0100600 .supply_name = "vin",
Bengt Jonsson6909b452010-12-10 11:08:47 +0100601 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000602 .load_lp_uA = 5000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100603 .update_bank = 0x04,
604 .update_reg = 0x09,
605 .update_mask = 0x0c,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000606 .update_val = 0x04,
607 .update_val_idle = 0x0c,
608 .update_val_normal = 0x04,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100609 .voltage_bank = 0x04,
610 .voltage_reg = 0x20,
611 .voltage_mask = 0x0f,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100612 },
613 [AB8500_LDO_AUX3] = {
614 .desc = {
615 .name = "LDO-AUX3",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000616 .ops = &ab8500_regulator_volt_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100617 .type = REGULATOR_VOLTAGE,
618 .id = AB8500_LDO_AUX3,
619 .owner = THIS_MODULE,
620 .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages),
Axel Linec1cc4d2012-05-20 10:33:35 +0800621 .volt_table = ldo_vaux3_voltages,
Axel Lin530158b2013-03-27 17:47:22 +0800622 .enable_time = 450,
Lee Jonesce6f5ea2013-06-07 17:11:28 +0100623 .supply_name = "vin",
Bengt Jonsson6909b452010-12-10 11:08:47 +0100624 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000625 .load_lp_uA = 5000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100626 .update_bank = 0x04,
627 .update_reg = 0x0a,
628 .update_mask = 0x03,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000629 .update_val = 0x01,
630 .update_val_idle = 0x03,
631 .update_val_normal = 0x01,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100632 .voltage_bank = 0x04,
633 .voltage_reg = 0x21,
634 .voltage_mask = 0x07,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100635 },
636 [AB8500_LDO_INTCORE] = {
637 .desc = {
638 .name = "LDO-INTCORE",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000639 .ops = &ab8500_regulator_volt_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100640 .type = REGULATOR_VOLTAGE,
641 .id = AB8500_LDO_INTCORE,
642 .owner = THIS_MODULE,
643 .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
Axel Linec1cc4d2012-05-20 10:33:35 +0800644 .volt_table = ldo_vintcore_voltages,
Axel Lin530158b2013-03-27 17:47:22 +0800645 .enable_time = 750,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100646 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000647 .load_lp_uA = 5000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100648 .update_bank = 0x03,
649 .update_reg = 0x80,
650 .update_mask = 0x44,
Lee Jonescc40dc22013-03-21 15:59:41 +0000651 .update_val = 0x44,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000652 .update_val_idle = 0x44,
653 .update_val_normal = 0x04,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100654 .voltage_bank = 0x03,
655 .voltage_reg = 0x80,
656 .voltage_mask = 0x38,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100657 },
Sundar R IYERc789ca22010-07-13 21:48:56 +0530658
659 /*
Bengt Jonssone1159e62010-12-10 11:08:44 +0100660 * Fixed Voltage Regulators
661 * name, fixed mV,
662 * update bank, reg, mask, enable val
Sundar R IYERc789ca22010-07-13 21:48:56 +0530663 */
Bengt Jonsson6909b452010-12-10 11:08:47 +0100664 [AB8500_LDO_TVOUT] = {
665 .desc = {
666 .name = "LDO-TVOUT",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000667 .ops = &ab8500_regulator_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100668 .type = REGULATOR_VOLTAGE,
669 .id = AB8500_LDO_TVOUT,
670 .owner = THIS_MODULE,
671 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +0000672 .volt_table = fixed_2000000_voltage,
Lee Jonesed3c1382013-03-28 16:11:12 +0000673 .enable_time = 500,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100674 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000675 .load_lp_uA = 1000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100676 .update_bank = 0x03,
677 .update_reg = 0x80,
678 .update_mask = 0x82,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000679 .update_val = 0x02,
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000680 .update_val_idle = 0x82,
681 .update_val_normal = 0x02,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100682 },
683 [AB8500_LDO_AUDIO] = {
684 .desc = {
685 .name = "LDO-AUDIO",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000686 .ops = &ab8500_regulator_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100687 .type = REGULATOR_VOLTAGE,
688 .id = AB8500_LDO_AUDIO,
689 .owner = THIS_MODULE,
690 .n_voltages = 1,
Axel Lin530158b2013-03-27 17:47:22 +0800691 .enable_time = 140,
Lee Jonesb080c782013-03-28 16:11:17 +0000692 .volt_table = fixed_2000000_voltage,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100693 },
Bengt Jonsson6909b452010-12-10 11:08:47 +0100694 .update_bank = 0x03,
695 .update_reg = 0x83,
696 .update_mask = 0x02,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000697 .update_val = 0x02,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100698 },
699 [AB8500_LDO_ANAMIC1] = {
700 .desc = {
701 .name = "LDO-ANAMIC1",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000702 .ops = &ab8500_regulator_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100703 .type = REGULATOR_VOLTAGE,
704 .id = AB8500_LDO_ANAMIC1,
705 .owner = THIS_MODULE,
706 .n_voltages = 1,
Axel Lin530158b2013-03-27 17:47:22 +0800707 .enable_time = 500,
Lee Jonesb080c782013-03-28 16:11:17 +0000708 .volt_table = fixed_2050000_voltage,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100709 },
Bengt Jonsson6909b452010-12-10 11:08:47 +0100710 .update_bank = 0x03,
711 .update_reg = 0x83,
712 .update_mask = 0x08,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000713 .update_val = 0x08,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100714 },
715 [AB8500_LDO_ANAMIC2] = {
716 .desc = {
717 .name = "LDO-ANAMIC2",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000718 .ops = &ab8500_regulator_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100719 .type = REGULATOR_VOLTAGE,
720 .id = AB8500_LDO_ANAMIC2,
721 .owner = THIS_MODULE,
722 .n_voltages = 1,
Axel Lin530158b2013-03-27 17:47:22 +0800723 .enable_time = 500,
Lee Jonesb080c782013-03-28 16:11:17 +0000724 .volt_table = fixed_2050000_voltage,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100725 },
Bengt Jonsson6909b452010-12-10 11:08:47 +0100726 .update_bank = 0x03,
727 .update_reg = 0x83,
728 .update_mask = 0x10,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000729 .update_val = 0x10,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100730 },
731 [AB8500_LDO_DMIC] = {
732 .desc = {
733 .name = "LDO-DMIC",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000734 .ops = &ab8500_regulator_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100735 .type = REGULATOR_VOLTAGE,
736 .id = AB8500_LDO_DMIC,
737 .owner = THIS_MODULE,
738 .n_voltages = 1,
Axel Lin530158b2013-03-27 17:47:22 +0800739 .enable_time = 420,
Lee Jonesb080c782013-03-28 16:11:17 +0000740 .volt_table = fixed_1800000_voltage,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100741 },
Bengt Jonsson6909b452010-12-10 11:08:47 +0100742 .update_bank = 0x03,
743 .update_reg = 0x83,
744 .update_mask = 0x04,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000745 .update_val = 0x04,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100746 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000747
748 /*
749 * Regulators with fixed voltage and normal/idle modes
750 */
Bengt Jonsson6909b452010-12-10 11:08:47 +0100751 [AB8500_LDO_ANA] = {
752 .desc = {
753 .name = "LDO-ANA",
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000754 .ops = &ab8500_regulator_mode_ops,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100755 .type = REGULATOR_VOLTAGE,
756 .id = AB8500_LDO_ANA,
757 .owner = THIS_MODULE,
758 .n_voltages = 1,
Axel Lin530158b2013-03-27 17:47:22 +0800759 .enable_time = 140,
Lee Jonesb080c782013-03-28 16:11:17 +0000760 .volt_table = fixed_1200000_voltage,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100761 },
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000762 .load_lp_uA = 1000,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100763 .update_bank = 0x04,
764 .update_reg = 0x06,
765 .update_mask = 0x0c,
Emeric Vigierbd28a152013-03-21 15:58:59 +0000766 .update_val = 0x04,
Bengt Jonsson7ce46692013-03-21 15:59:00 +0000767 .update_val_idle = 0x0c,
768 .update_val_normal = 0x04,
Bengt Jonsson6909b452010-12-10 11:08:47 +0100769 },
Lee Jones8e6a8d72013-03-28 16:11:11 +0000770};
Bengt Jonsson6909b452010-12-10 11:08:47 +0100771
Lee Jones547f3842013-03-28 16:11:14 +0000772/* AB8505 regulator information */
773static struct ab8500_regulator_info
774 ab8505_regulator_info[AB8505_NUM_REGULATORS] = {
775 /*
776 * Variable Voltage Regulators
777 * name, min mV, max mV,
778 * update bank, reg, mask, enable val
Lee Jonesd3193102013-04-02 13:24:18 +0100779 * volt bank, reg, mask
Lee Jones547f3842013-03-28 16:11:14 +0000780 */
781 [AB8505_LDO_AUX1] = {
782 .desc = {
783 .name = "LDO-AUX1",
784 .ops = &ab8500_regulator_volt_mode_ops,
785 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +0100786 .id = AB8505_LDO_AUX1,
Lee Jones547f3842013-03-28 16:11:14 +0000787 .owner = THIS_MODULE,
788 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +0000789 .volt_table = ldo_vauxn_voltages,
Lee Jones547f3842013-03-28 16:11:14 +0000790 },
Lee Jones547f3842013-03-28 16:11:14 +0000791 .load_lp_uA = 5000,
792 .update_bank = 0x04,
793 .update_reg = 0x09,
794 .update_mask = 0x03,
795 .update_val = 0x01,
796 .update_val_idle = 0x03,
797 .update_val_normal = 0x01,
798 .voltage_bank = 0x04,
799 .voltage_reg = 0x1f,
800 .voltage_mask = 0x0f,
Lee Jones547f3842013-03-28 16:11:14 +0000801 },
802 [AB8505_LDO_AUX2] = {
803 .desc = {
804 .name = "LDO-AUX2",
805 .ops = &ab8500_regulator_volt_mode_ops,
806 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +0100807 .id = AB8505_LDO_AUX2,
Lee Jones547f3842013-03-28 16:11:14 +0000808 .owner = THIS_MODULE,
809 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +0000810 .volt_table = ldo_vauxn_voltages,
Lee Jones547f3842013-03-28 16:11:14 +0000811 },
Lee Jones547f3842013-03-28 16:11:14 +0000812 .load_lp_uA = 5000,
813 .update_bank = 0x04,
814 .update_reg = 0x09,
815 .update_mask = 0x0c,
816 .update_val = 0x04,
817 .update_val_idle = 0x0c,
818 .update_val_normal = 0x04,
819 .voltage_bank = 0x04,
820 .voltage_reg = 0x20,
821 .voltage_mask = 0x0f,
Lee Jones547f3842013-03-28 16:11:14 +0000822 },
823 [AB8505_LDO_AUX3] = {
824 .desc = {
825 .name = "LDO-AUX3",
826 .ops = &ab8500_regulator_volt_mode_ops,
827 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +0100828 .id = AB8505_LDO_AUX3,
Lee Jones547f3842013-03-28 16:11:14 +0000829 .owner = THIS_MODULE,
830 .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +0000831 .volt_table = ldo_vaux3_voltages,
Lee Jones547f3842013-03-28 16:11:14 +0000832 },
Lee Jones547f3842013-03-28 16:11:14 +0000833 .load_lp_uA = 5000,
834 .update_bank = 0x04,
835 .update_reg = 0x0a,
836 .update_mask = 0x03,
837 .update_val = 0x01,
838 .update_val_idle = 0x03,
839 .update_val_normal = 0x01,
840 .voltage_bank = 0x04,
841 .voltage_reg = 0x21,
842 .voltage_mask = 0x07,
Lee Jones547f3842013-03-28 16:11:14 +0000843 },
844 [AB8505_LDO_AUX4] = {
845 .desc = {
846 .name = "LDO-AUX4",
847 .ops = &ab8500_regulator_volt_mode_ops,
848 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +0100849 .id = AB8505_LDO_AUX4,
Lee Jones547f3842013-03-28 16:11:14 +0000850 .owner = THIS_MODULE,
851 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +0000852 .volt_table = ldo_vauxn_voltages,
Lee Jones547f3842013-03-28 16:11:14 +0000853 },
Lee Jones547f3842013-03-28 16:11:14 +0000854 .load_lp_uA = 5000,
855 /* values for Vaux4Regu register */
856 .update_bank = 0x04,
857 .update_reg = 0x2e,
858 .update_mask = 0x03,
859 .update_val = 0x01,
860 .update_val_idle = 0x03,
861 .update_val_normal = 0x01,
862 /* values for Vaux4SEL register */
863 .voltage_bank = 0x04,
864 .voltage_reg = 0x2f,
865 .voltage_mask = 0x0f,
Lee Jones547f3842013-03-28 16:11:14 +0000866 },
867 [AB8505_LDO_AUX5] = {
868 .desc = {
869 .name = "LDO-AUX5",
870 .ops = &ab8500_regulator_volt_mode_ops,
871 .type = REGULATOR_VOLTAGE,
872 .id = AB8505_LDO_AUX5,
873 .owner = THIS_MODULE,
874 .n_voltages = ARRAY_SIZE(ldo_vaux56_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +0000875 .volt_table = ldo_vaux56_voltages,
Lee Jones547f3842013-03-28 16:11:14 +0000876 },
Lee Jones547f3842013-03-28 16:11:14 +0000877 .load_lp_uA = 2000,
878 /* values for CtrlVaux5 register */
879 .update_bank = 0x01,
880 .update_reg = 0x55,
Lee Jonesae0a9a32013-03-28 16:11:16 +0000881 .update_mask = 0x18,
882 .update_val = 0x10,
883 .update_val_idle = 0x18,
884 .update_val_normal = 0x10,
Lee Jones547f3842013-03-28 16:11:14 +0000885 .voltage_bank = 0x01,
886 .voltage_reg = 0x55,
887 .voltage_mask = 0x07,
Lee Jones547f3842013-03-28 16:11:14 +0000888 },
889 [AB8505_LDO_AUX6] = {
890 .desc = {
891 .name = "LDO-AUX6",
892 .ops = &ab8500_regulator_volt_mode_ops,
893 .type = REGULATOR_VOLTAGE,
894 .id = AB8505_LDO_AUX6,
895 .owner = THIS_MODULE,
896 .n_voltages = ARRAY_SIZE(ldo_vaux56_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +0000897 .volt_table = ldo_vaux56_voltages,
Lee Jones547f3842013-03-28 16:11:14 +0000898 },
Lee Jones547f3842013-03-28 16:11:14 +0000899 .load_lp_uA = 2000,
900 /* values for CtrlVaux6 register */
901 .update_bank = 0x01,
902 .update_reg = 0x56,
Lee Jonesae0a9a32013-03-28 16:11:16 +0000903 .update_mask = 0x18,
904 .update_val = 0x10,
905 .update_val_idle = 0x18,
906 .update_val_normal = 0x10,
Lee Jones547f3842013-03-28 16:11:14 +0000907 .voltage_bank = 0x01,
908 .voltage_reg = 0x56,
909 .voltage_mask = 0x07,
Lee Jones547f3842013-03-28 16:11:14 +0000910 },
911 [AB8505_LDO_INTCORE] = {
912 .desc = {
913 .name = "LDO-INTCORE",
914 .ops = &ab8500_regulator_volt_mode_ops,
915 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +0100916 .id = AB8505_LDO_INTCORE,
Lee Jones547f3842013-03-28 16:11:14 +0000917 .owner = THIS_MODULE,
918 .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
Lee Jones62ab4112013-03-28 16:11:18 +0000919 .volt_table = ldo_vintcore_voltages,
Lee Jones547f3842013-03-28 16:11:14 +0000920 },
Lee Jones547f3842013-03-28 16:11:14 +0000921 .load_lp_uA = 5000,
922 .update_bank = 0x03,
923 .update_reg = 0x80,
924 .update_mask = 0x44,
925 .update_val = 0x04,
926 .update_val_idle = 0x44,
927 .update_val_normal = 0x04,
928 .voltage_bank = 0x03,
929 .voltage_reg = 0x80,
930 .voltage_mask = 0x38,
Lee Jones547f3842013-03-28 16:11:14 +0000931 },
932
933 /*
934 * Fixed Voltage Regulators
935 * name, fixed mV,
936 * update bank, reg, mask, enable val
937 */
938 [AB8505_LDO_ADC] = {
939 .desc = {
940 .name = "LDO-ADC",
941 .ops = &ab8500_regulator_mode_ops,
942 .type = REGULATOR_VOLTAGE,
943 .id = AB8505_LDO_ADC,
944 .owner = THIS_MODULE,
945 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +0000946 .volt_table = fixed_2000000_voltage,
Lee Jonesa4d68462013-04-02 13:24:16 +0100947 .enable_time = 10000,
Lee Jones547f3842013-03-28 16:11:14 +0000948 },
Lee Jones547f3842013-03-28 16:11:14 +0000949 .load_lp_uA = 1000,
950 .update_bank = 0x03,
951 .update_reg = 0x80,
952 .update_mask = 0x82,
953 .update_val = 0x02,
954 .update_val_idle = 0x82,
955 .update_val_normal = 0x02,
956 },
957 [AB8505_LDO_USB] = {
958 .desc = {
959 .name = "LDO-USB",
960 .ops = &ab8500_regulator_mode_ops,
961 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +0100962 .id = AB8505_LDO_USB,
Lee Jones547f3842013-03-28 16:11:14 +0000963 .owner = THIS_MODULE,
964 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +0000965 .volt_table = fixed_3300000_voltage,
Lee Jones547f3842013-03-28 16:11:14 +0000966 },
Lee Jones547f3842013-03-28 16:11:14 +0000967 .update_bank = 0x03,
968 .update_reg = 0x82,
969 .update_mask = 0x03,
970 .update_val = 0x01,
971 .update_val_idle = 0x03,
972 .update_val_normal = 0x01,
973 },
974 [AB8505_LDO_AUDIO] = {
975 .desc = {
976 .name = "LDO-AUDIO",
Lee Jones8a3b1b82013-04-02 13:24:09 +0100977 .ops = &ab8500_regulator_volt_ops,
Lee Jones547f3842013-03-28 16:11:14 +0000978 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +0100979 .id = AB8505_LDO_AUDIO,
Lee Jones547f3842013-03-28 16:11:14 +0000980 .owner = THIS_MODULE,
Lee Jones8a3b1b82013-04-02 13:24:09 +0100981 .n_voltages = ARRAY_SIZE(ldo_vaudio_voltages),
982 .volt_table = ldo_vaudio_voltages,
Lee Jones547f3842013-03-28 16:11:14 +0000983 },
Lee Jones547f3842013-03-28 16:11:14 +0000984 .update_bank = 0x03,
985 .update_reg = 0x83,
986 .update_mask = 0x02,
987 .update_val = 0x02,
Lee Jones8a3b1b82013-04-02 13:24:09 +0100988 .voltage_bank = 0x01,
989 .voltage_reg = 0x57,
Axel Line4fc9d62013-04-12 15:33:25 +0800990 .voltage_mask = 0x70,
Lee Jones547f3842013-03-28 16:11:14 +0000991 },
992 [AB8505_LDO_ANAMIC1] = {
993 .desc = {
994 .name = "LDO-ANAMIC1",
Lee Jones3fe52282013-04-02 13:24:12 +0100995 .ops = &ab8500_regulator_anamic_mode_ops,
Lee Jones547f3842013-03-28 16:11:14 +0000996 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +0100997 .id = AB8505_LDO_ANAMIC1,
Lee Jones547f3842013-03-28 16:11:14 +0000998 .owner = THIS_MODULE,
999 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001000 .volt_table = fixed_2050000_voltage,
Lee Jones547f3842013-03-28 16:11:14 +00001001 },
Lee Jones4c84b4d2013-04-02 13:24:13 +01001002 .shared_mode = &ldo_anamic1_shared,
Lee Jones547f3842013-03-28 16:11:14 +00001003 .update_bank = 0x03,
1004 .update_reg = 0x83,
1005 .update_mask = 0x08,
1006 .update_val = 0x08,
Lee Jones3fe52282013-04-02 13:24:12 +01001007 .mode_bank = 0x01,
1008 .mode_reg = 0x54,
1009 .mode_mask = 0x04,
1010 .mode_val_idle = 0x04,
1011 .mode_val_normal = 0x00,
Lee Jones547f3842013-03-28 16:11:14 +00001012 },
1013 [AB8505_LDO_ANAMIC2] = {
1014 .desc = {
1015 .name = "LDO-ANAMIC2",
Lee Jones3fe52282013-04-02 13:24:12 +01001016 .ops = &ab8500_regulator_anamic_mode_ops,
Lee Jones547f3842013-03-28 16:11:14 +00001017 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001018 .id = AB8505_LDO_ANAMIC2,
Lee Jones547f3842013-03-28 16:11:14 +00001019 .owner = THIS_MODULE,
1020 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001021 .volt_table = fixed_2050000_voltage,
Lee Jones547f3842013-03-28 16:11:14 +00001022 },
Lee Jones3fe52282013-04-02 13:24:12 +01001023 .shared_mode = &ldo_anamic2_shared,
Lee Jones547f3842013-03-28 16:11:14 +00001024 .update_bank = 0x03,
1025 .update_reg = 0x83,
1026 .update_mask = 0x10,
1027 .update_val = 0x10,
Lee Jones3fe52282013-04-02 13:24:12 +01001028 .mode_bank = 0x01,
1029 .mode_reg = 0x54,
1030 .mode_mask = 0x04,
1031 .mode_val_idle = 0x04,
1032 .mode_val_normal = 0x00,
Lee Jones547f3842013-03-28 16:11:14 +00001033 },
1034 [AB8505_LDO_AUX8] = {
1035 .desc = {
1036 .name = "LDO-AUX8",
1037 .ops = &ab8500_regulator_ops,
1038 .type = REGULATOR_VOLTAGE,
1039 .id = AB8505_LDO_AUX8,
1040 .owner = THIS_MODULE,
1041 .n_voltages = 1,
Lee Jonesb080c782013-03-28 16:11:17 +00001042 .volt_table = fixed_1800000_voltage,
Lee Jones547f3842013-03-28 16:11:14 +00001043 },
Lee Jones547f3842013-03-28 16:11:14 +00001044 .update_bank = 0x03,
1045 .update_reg = 0x83,
1046 .update_mask = 0x04,
1047 .update_val = 0x04,
1048 },
1049 /*
1050 * Regulators with fixed voltage and normal/idle modes
1051 */
1052 [AB8505_LDO_ANA] = {
1053 .desc = {
1054 .name = "LDO-ANA",
Lee Jones8a3b1b82013-04-02 13:24:09 +01001055 .ops = &ab8500_regulator_volt_mode_ops,
Lee Jones547f3842013-03-28 16:11:14 +00001056 .type = REGULATOR_VOLTAGE,
Lee Jones0b946412013-04-02 13:24:07 +01001057 .id = AB8505_LDO_ANA,
Lee Jones547f3842013-03-28 16:11:14 +00001058 .owner = THIS_MODULE,
Lee Jones8a3b1b82013-04-02 13:24:09 +01001059 .n_voltages = ARRAY_SIZE(ldo_vana_voltages),
1060 .volt_table = ldo_vana_voltages,
Lee Jones547f3842013-03-28 16:11:14 +00001061 },
Lee Jones547f3842013-03-28 16:11:14 +00001062 .load_lp_uA = 1000,
1063 .update_bank = 0x04,
1064 .update_reg = 0x06,
1065 .update_mask = 0x0c,
1066 .update_val = 0x04,
1067 .update_val_idle = 0x0c,
1068 .update_val_normal = 0x04,
Lee Jones8a3b1b82013-04-02 13:24:09 +01001069 .voltage_bank = 0x04,
1070 .voltage_reg = 0x29,
1071 .voltage_mask = 0x7,
Lee Jones547f3842013-03-28 16:11:14 +00001072 },
1073};
1074
Lee Jones3fe52282013-04-02 13:24:12 +01001075static struct ab8500_shared_mode ldo_anamic1_shared = {
1076 .shared_regulator = &ab8505_regulator_info[AB8505_LDO_ANAMIC2],
1077};
1078
1079static struct ab8500_shared_mode ldo_anamic2_shared = {
1080 .shared_regulator = &ab8505_regulator_info[AB8505_LDO_ANAMIC1],
1081};
1082
Bengt Jonsson79568b942011-03-11 11:54:46 +01001083struct ab8500_reg_init {
1084 u8 bank;
1085 u8 addr;
1086 u8 mask;
1087};
1088
1089#define REG_INIT(_id, _bank, _addr, _mask) \
1090 [_id] = { \
1091 .bank = _bank, \
1092 .addr = _addr, \
1093 .mask = _mask, \
1094 }
1095
Lee Jones8e6a8d72013-03-28 16:11:11 +00001096/* AB8500 register init */
Bengt Jonsson79568b942011-03-11 11:54:46 +01001097static struct ab8500_reg_init ab8500_reg_init[] = {
1098 /*
Lee Jones33bc8f42013-03-21 15:59:02 +00001099 * 0x30, VanaRequestCtrl
Bengt Jonsson79568b942011-03-11 11:54:46 +01001100 * 0xc0, VextSupply1RequestCtrl
1101 */
Lee Jones43a59112013-03-21 15:59:15 +00001102 REG_INIT(AB8500_REGUREQUESTCTRL2, 0x03, 0x04, 0xf0),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001103 /*
1104 * 0x03, VextSupply2RequestCtrl
1105 * 0x0c, VextSupply3RequestCtrl
1106 * 0x30, Vaux1RequestCtrl
1107 * 0xc0, Vaux2RequestCtrl
1108 */
1109 REG_INIT(AB8500_REGUREQUESTCTRL3, 0x03, 0x05, 0xff),
1110 /*
1111 * 0x03, Vaux3RequestCtrl
1112 * 0x04, SwHPReq
1113 */
1114 REG_INIT(AB8500_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
1115 /*
1116 * 0x08, VanaSysClkReq1HPValid
1117 * 0x20, Vaux1SysClkReq1HPValid
1118 * 0x40, Vaux2SysClkReq1HPValid
1119 * 0x80, Vaux3SysClkReq1HPValid
1120 */
Lee Jones43a59112013-03-21 15:59:15 +00001121 REG_INIT(AB8500_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xe8),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001122 /*
1123 * 0x10, VextSupply1SysClkReq1HPValid
1124 * 0x20, VextSupply2SysClkReq1HPValid
1125 * 0x40, VextSupply3SysClkReq1HPValid
1126 */
Lee Jones43a59112013-03-21 15:59:15 +00001127 REG_INIT(AB8500_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x70),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001128 /*
1129 * 0x08, VanaHwHPReq1Valid
1130 * 0x20, Vaux1HwHPReq1Valid
1131 * 0x40, Vaux2HwHPReq1Valid
1132 * 0x80, Vaux3HwHPReq1Valid
1133 */
Lee Jones43a59112013-03-21 15:59:15 +00001134 REG_INIT(AB8500_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xe8),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001135 /*
1136 * 0x01, VextSupply1HwHPReq1Valid
1137 * 0x02, VextSupply2HwHPReq1Valid
1138 * 0x04, VextSupply3HwHPReq1Valid
1139 */
Lee Jones43a59112013-03-21 15:59:15 +00001140 REG_INIT(AB8500_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x07),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001141 /*
1142 * 0x08, VanaHwHPReq2Valid
1143 * 0x20, Vaux1HwHPReq2Valid
1144 * 0x40, Vaux2HwHPReq2Valid
1145 * 0x80, Vaux3HwHPReq2Valid
1146 */
Lee Jones43a59112013-03-21 15:59:15 +00001147 REG_INIT(AB8500_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xe8),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001148 /*
1149 * 0x01, VextSupply1HwHPReq2Valid
1150 * 0x02, VextSupply2HwHPReq2Valid
1151 * 0x04, VextSupply3HwHPReq2Valid
1152 */
Lee Jones43a59112013-03-21 15:59:15 +00001153 REG_INIT(AB8500_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x07),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001154 /*
1155 * 0x20, VanaSwHPReqValid
1156 * 0x80, Vaux1SwHPReqValid
1157 */
Lee Jones43a59112013-03-21 15:59:15 +00001158 REG_INIT(AB8500_REGUSWHPREQVALID1, 0x03, 0x0d, 0xa0),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001159 /*
1160 * 0x01, Vaux2SwHPReqValid
1161 * 0x02, Vaux3SwHPReqValid
1162 * 0x04, VextSupply1SwHPReqValid
1163 * 0x08, VextSupply2SwHPReqValid
1164 * 0x10, VextSupply3SwHPReqValid
1165 */
Lee Jones43a59112013-03-21 15:59:15 +00001166 REG_INIT(AB8500_REGUSWHPREQVALID2, 0x03, 0x0e, 0x1f),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001167 /*
1168 * 0x02, SysClkReq2Valid1
Lee Jones43a59112013-03-21 15:59:15 +00001169 * 0x04, SysClkReq3Valid1
1170 * 0x08, SysClkReq4Valid1
1171 * 0x10, SysClkReq5Valid1
1172 * 0x20, SysClkReq6Valid1
1173 * 0x40, SysClkReq7Valid1
Bengt Jonsson79568b942011-03-11 11:54:46 +01001174 * 0x80, SysClkReq8Valid1
1175 */
1176 REG_INIT(AB8500_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0xfe),
1177 /*
1178 * 0x02, SysClkReq2Valid2
Lee Jones43a59112013-03-21 15:59:15 +00001179 * 0x04, SysClkReq3Valid2
1180 * 0x08, SysClkReq4Valid2
1181 * 0x10, SysClkReq5Valid2
1182 * 0x20, SysClkReq6Valid2
1183 * 0x40, SysClkReq7Valid2
Bengt Jonsson79568b942011-03-11 11:54:46 +01001184 * 0x80, SysClkReq8Valid2
1185 */
1186 REG_INIT(AB8500_REGUSYSCLKREQVALID2, 0x03, 0x10, 0xfe),
1187 /*
1188 * 0x02, VTVoutEna
1189 * 0x04, Vintcore12Ena
1190 * 0x38, Vintcore12Sel
1191 * 0x40, Vintcore12LP
1192 * 0x80, VTVoutLP
1193 */
1194 REG_INIT(AB8500_REGUMISC1, 0x03, 0x80, 0xfe),
1195 /*
1196 * 0x02, VaudioEna
1197 * 0x04, VdmicEna
1198 * 0x08, Vamic1Ena
1199 * 0x10, Vamic2Ena
1200 */
1201 REG_INIT(AB8500_VAUDIOSUPPLY, 0x03, 0x83, 0x1e),
1202 /*
1203 * 0x01, Vamic1_dzout
1204 * 0x02, Vamic2_dzout
1205 */
1206 REG_INIT(AB8500_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
1207 /*
Lee Jones43a59112013-03-21 15:59:15 +00001208 * 0x03, VpllRegu (NOTE! PRCMU register bits)
Lee Jones33bc8f42013-03-21 15:59:02 +00001209 * 0x0c, VanaRegu
Bengt Jonsson79568b942011-03-11 11:54:46 +01001210 */
1211 REG_INIT(AB8500_VPLLVANAREGU, 0x04, 0x06, 0x0f),
1212 /*
1213 * 0x01, VrefDDREna
1214 * 0x02, VrefDDRSleepMode
1215 */
1216 REG_INIT(AB8500_VREFDDR, 0x04, 0x07, 0x03),
1217 /*
1218 * 0x03, VextSupply1Regu
1219 * 0x0c, VextSupply2Regu
1220 * 0x30, VextSupply3Regu
1221 * 0x40, ExtSupply2Bypass
1222 * 0x80, ExtSupply3Bypass
1223 */
1224 REG_INIT(AB8500_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
1225 /*
1226 * 0x03, Vaux1Regu
1227 * 0x0c, Vaux2Regu
1228 */
1229 REG_INIT(AB8500_VAUX12REGU, 0x04, 0x09, 0x0f),
1230 /*
1231 * 0x03, Vaux3Regu
1232 */
Lee Jones43a59112013-03-21 15:59:15 +00001233 REG_INIT(AB8500_VRF1VAUX3REGU, 0x04, 0x0a, 0x03),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001234 /*
1235 * 0x0f, Vaux1Sel
1236 */
1237 REG_INIT(AB8500_VAUX1SEL, 0x04, 0x1f, 0x0f),
1238 /*
1239 * 0x0f, Vaux2Sel
1240 */
1241 REG_INIT(AB8500_VAUX2SEL, 0x04, 0x20, 0x0f),
1242 /*
1243 * 0x07, Vaux3Sel
1244 */
Lee Jones43a59112013-03-21 15:59:15 +00001245 REG_INIT(AB8500_VRF1VAUX3SEL, 0x04, 0x21, 0x07),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001246 /*
1247 * 0x01, VextSupply12LP
1248 */
1249 REG_INIT(AB8500_REGUCTRL2SPARE, 0x04, 0x22, 0x01),
1250 /*
1251 * 0x04, Vaux1Disch
1252 * 0x08, Vaux2Disch
1253 * 0x10, Vaux3Disch
1254 * 0x20, Vintcore12Disch
1255 * 0x40, VTVoutDisch
1256 * 0x80, VaudioDisch
1257 */
Lee Jones43a59112013-03-21 15:59:15 +00001258 REG_INIT(AB8500_REGUCTRLDISCH, 0x04, 0x43, 0xfc),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001259 /*
1260 * 0x02, VanaDisch
1261 * 0x04, VdmicPullDownEna
1262 * 0x10, VdmicDisch
1263 */
Lee Jones43a59112013-03-21 15:59:15 +00001264 REG_INIT(AB8500_REGUCTRLDISCH2, 0x04, 0x44, 0x16),
Bengt Jonsson79568b942011-03-11 11:54:46 +01001265};
1266
Lee Jones547f3842013-03-28 16:11:14 +00001267/* AB8505 register init */
1268static struct ab8500_reg_init ab8505_reg_init[] = {
1269 /*
1270 * 0x03, VarmRequestCtrl
1271 * 0x0c, VsmpsCRequestCtrl
1272 * 0x30, VsmpsARequestCtrl
1273 * 0xc0, VsmpsBRequestCtrl
1274 */
1275 REG_INIT(AB8505_REGUREQUESTCTRL1, 0x03, 0x03, 0xff),
1276 /*
1277 * 0x03, VsafeRequestCtrl
1278 * 0x0c, VpllRequestCtrl
1279 * 0x30, VanaRequestCtrl
1280 */
1281 REG_INIT(AB8505_REGUREQUESTCTRL2, 0x03, 0x04, 0x3f),
1282 /*
1283 * 0x30, Vaux1RequestCtrl
1284 * 0xc0, Vaux2RequestCtrl
1285 */
1286 REG_INIT(AB8505_REGUREQUESTCTRL3, 0x03, 0x05, 0xf0),
1287 /*
1288 * 0x03, Vaux3RequestCtrl
1289 * 0x04, SwHPReq
1290 */
1291 REG_INIT(AB8505_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
1292 /*
1293 * 0x01, VsmpsASysClkReq1HPValid
1294 * 0x02, VsmpsBSysClkReq1HPValid
1295 * 0x04, VsafeSysClkReq1HPValid
1296 * 0x08, VanaSysClkReq1HPValid
1297 * 0x10, VpllSysClkReq1HPValid
1298 * 0x20, Vaux1SysClkReq1HPValid
1299 * 0x40, Vaux2SysClkReq1HPValid
1300 * 0x80, Vaux3SysClkReq1HPValid
1301 */
1302 REG_INIT(AB8505_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xff),
1303 /*
1304 * 0x01, VsmpsCSysClkReq1HPValid
1305 * 0x02, VarmSysClkReq1HPValid
1306 * 0x04, VbbSysClkReq1HPValid
1307 * 0x08, VsmpsMSysClkReq1HPValid
1308 */
1309 REG_INIT(AB8505_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x0f),
1310 /*
1311 * 0x01, VsmpsAHwHPReq1Valid
1312 * 0x02, VsmpsBHwHPReq1Valid
1313 * 0x04, VsafeHwHPReq1Valid
1314 * 0x08, VanaHwHPReq1Valid
1315 * 0x10, VpllHwHPReq1Valid
1316 * 0x20, Vaux1HwHPReq1Valid
1317 * 0x40, Vaux2HwHPReq1Valid
1318 * 0x80, Vaux3HwHPReq1Valid
1319 */
1320 REG_INIT(AB8505_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xff),
1321 /*
1322 * 0x08, VsmpsMHwHPReq1Valid
1323 */
1324 REG_INIT(AB8505_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x08),
1325 /*
1326 * 0x01, VsmpsAHwHPReq2Valid
1327 * 0x02, VsmpsBHwHPReq2Valid
1328 * 0x04, VsafeHwHPReq2Valid
1329 * 0x08, VanaHwHPReq2Valid
1330 * 0x10, VpllHwHPReq2Valid
1331 * 0x20, Vaux1HwHPReq2Valid
1332 * 0x40, Vaux2HwHPReq2Valid
1333 * 0x80, Vaux3HwHPReq2Valid
1334 */
1335 REG_INIT(AB8505_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xff),
1336 /*
1337 * 0x08, VsmpsMHwHPReq2Valid
1338 */
1339 REG_INIT(AB8505_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x08),
1340 /*
1341 * 0x01, VsmpsCSwHPReqValid
1342 * 0x02, VarmSwHPReqValid
1343 * 0x04, VsmpsASwHPReqValid
1344 * 0x08, VsmpsBSwHPReqValid
1345 * 0x10, VsafeSwHPReqValid
1346 * 0x20, VanaSwHPReqValid
1347 * 0x40, VpllSwHPReqValid
1348 * 0x80, Vaux1SwHPReqValid
1349 */
1350 REG_INIT(AB8505_REGUSWHPREQVALID1, 0x03, 0x0d, 0xff),
1351 /*
1352 * 0x01, Vaux2SwHPReqValid
1353 * 0x02, Vaux3SwHPReqValid
1354 * 0x20, VsmpsMSwHPReqValid
1355 */
1356 REG_INIT(AB8505_REGUSWHPREQVALID2, 0x03, 0x0e, 0x23),
1357 /*
1358 * 0x02, SysClkReq2Valid1
1359 * 0x04, SysClkReq3Valid1
1360 * 0x08, SysClkReq4Valid1
1361 */
1362 REG_INIT(AB8505_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0x0e),
1363 /*
1364 * 0x02, SysClkReq2Valid2
1365 * 0x04, SysClkReq3Valid2
1366 * 0x08, SysClkReq4Valid2
1367 */
1368 REG_INIT(AB8505_REGUSYSCLKREQVALID2, 0x03, 0x10, 0x0e),
1369 /*
1370 * 0x01, Vaux4SwHPReqValid
1371 * 0x02, Vaux4HwHPReq2Valid
1372 * 0x04, Vaux4HwHPReq1Valid
1373 * 0x08, Vaux4SysClkReq1HPValid
1374 */
1375 REG_INIT(AB8505_REGUVAUX4REQVALID, 0x03, 0x11, 0x0f),
1376 /*
1377 * 0x02, VadcEna
1378 * 0x04, VintCore12Ena
1379 * 0x38, VintCore12Sel
1380 * 0x40, VintCore12LP
1381 * 0x80, VadcLP
1382 */
1383 REG_INIT(AB8505_REGUMISC1, 0x03, 0x80, 0xfe),
1384 /*
1385 * 0x02, VaudioEna
1386 * 0x04, VdmicEna
1387 * 0x08, Vamic1Ena
1388 * 0x10, Vamic2Ena
1389 */
1390 REG_INIT(AB8505_VAUDIOSUPPLY, 0x03, 0x83, 0x1e),
1391 /*
1392 * 0x01, Vamic1_dzout
1393 * 0x02, Vamic2_dzout
1394 */
1395 REG_INIT(AB8505_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
1396 /*
1397 * 0x03, VsmpsARegu
1398 * 0x0c, VsmpsASelCtrl
1399 * 0x10, VsmpsAAutoMode
1400 * 0x20, VsmpsAPWMMode
1401 */
1402 REG_INIT(AB8505_VSMPSAREGU, 0x04, 0x03, 0x3f),
1403 /*
1404 * 0x03, VsmpsBRegu
1405 * 0x0c, VsmpsBSelCtrl
1406 * 0x10, VsmpsBAutoMode
1407 * 0x20, VsmpsBPWMMode
1408 */
1409 REG_INIT(AB8505_VSMPSBREGU, 0x04, 0x04, 0x3f),
1410 /*
1411 * 0x03, VsafeRegu
1412 * 0x0c, VsafeSelCtrl
1413 * 0x10, VsafeAutoMode
1414 * 0x20, VsafePWMMode
1415 */
1416 REG_INIT(AB8505_VSAFEREGU, 0x04, 0x05, 0x3f),
1417 /*
1418 * 0x03, VpllRegu (NOTE! PRCMU register bits)
1419 * 0x0c, VanaRegu
1420 */
1421 REG_INIT(AB8505_VPLLVANAREGU, 0x04, 0x06, 0x0f),
1422 /*
1423 * 0x03, VextSupply1Regu
1424 * 0x0c, VextSupply2Regu
1425 * 0x30, VextSupply3Regu
1426 * 0x40, ExtSupply2Bypass
1427 * 0x80, ExtSupply3Bypass
1428 */
1429 REG_INIT(AB8505_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
1430 /*
1431 * 0x03, Vaux1Regu
1432 * 0x0c, Vaux2Regu
1433 */
1434 REG_INIT(AB8505_VAUX12REGU, 0x04, 0x09, 0x0f),
1435 /*
1436 * 0x0f, Vaux3Regu
1437 */
1438 REG_INIT(AB8505_VRF1VAUX3REGU, 0x04, 0x0a, 0x0f),
1439 /*
1440 * 0x3f, VsmpsASel1
1441 */
1442 REG_INIT(AB8505_VSMPSASEL1, 0x04, 0x13, 0x3f),
1443 /*
1444 * 0x3f, VsmpsASel2
1445 */
1446 REG_INIT(AB8505_VSMPSASEL2, 0x04, 0x14, 0x3f),
1447 /*
1448 * 0x3f, VsmpsASel3
1449 */
1450 REG_INIT(AB8505_VSMPSASEL3, 0x04, 0x15, 0x3f),
1451 /*
1452 * 0x3f, VsmpsBSel1
1453 */
1454 REG_INIT(AB8505_VSMPSBSEL1, 0x04, 0x17, 0x3f),
1455 /*
1456 * 0x3f, VsmpsBSel2
1457 */
1458 REG_INIT(AB8505_VSMPSBSEL2, 0x04, 0x18, 0x3f),
1459 /*
1460 * 0x3f, VsmpsBSel3
1461 */
1462 REG_INIT(AB8505_VSMPSBSEL3, 0x04, 0x19, 0x3f),
1463 /*
1464 * 0x7f, VsafeSel1
1465 */
1466 REG_INIT(AB8505_VSAFESEL1, 0x04, 0x1b, 0x7f),
1467 /*
1468 * 0x3f, VsafeSel2
1469 */
1470 REG_INIT(AB8505_VSAFESEL2, 0x04, 0x1c, 0x7f),
1471 /*
1472 * 0x3f, VsafeSel3
1473 */
1474 REG_INIT(AB8505_VSAFESEL3, 0x04, 0x1d, 0x7f),
1475 /*
1476 * 0x0f, Vaux1Sel
1477 */
1478 REG_INIT(AB8505_VAUX1SEL, 0x04, 0x1f, 0x0f),
1479 /*
1480 * 0x0f, Vaux2Sel
1481 */
1482 REG_INIT(AB8505_VAUX2SEL, 0x04, 0x20, 0x0f),
1483 /*
1484 * 0x07, Vaux3Sel
1485 * 0x30, VRF1Sel
1486 */
1487 REG_INIT(AB8505_VRF1VAUX3SEL, 0x04, 0x21, 0x37),
1488 /*
1489 * 0x03, Vaux4RequestCtrl
1490 */
1491 REG_INIT(AB8505_VAUX4REQCTRL, 0x04, 0x2d, 0x03),
1492 /*
1493 * 0x03, Vaux4Regu
1494 */
1495 REG_INIT(AB8505_VAUX4REGU, 0x04, 0x2e, 0x03),
1496 /*
1497 * 0x0f, Vaux4Sel
1498 */
1499 REG_INIT(AB8505_VAUX4SEL, 0x04, 0x2f, 0x0f),
1500 /*
1501 * 0x04, Vaux1Disch
1502 * 0x08, Vaux2Disch
1503 * 0x10, Vaux3Disch
1504 * 0x20, Vintcore12Disch
1505 * 0x40, VTVoutDisch
1506 * 0x80, VaudioDisch
1507 */
1508 REG_INIT(AB8505_REGUCTRLDISCH, 0x04, 0x43, 0xfc),
1509 /*
1510 * 0x02, VanaDisch
1511 * 0x04, VdmicPullDownEna
1512 * 0x10, VdmicDisch
1513 */
1514 REG_INIT(AB8505_REGUCTRLDISCH2, 0x04, 0x44, 0x16),
1515 /*
1516 * 0x01, Vaux4Disch
1517 */
1518 REG_INIT(AB8505_REGUCTRLDISCH3, 0x04, 0x48, 0x01),
1519 /*
1520 * 0x07, Vaux5Sel
1521 * 0x08, Vaux5LP
1522 * 0x10, Vaux5Ena
1523 * 0x20, Vaux5Disch
1524 * 0x40, Vaux5DisSfst
1525 * 0x80, Vaux5DisPulld
1526 */
1527 REG_INIT(AB8505_CTRLVAUX5, 0x01, 0x55, 0xff),
1528 /*
1529 * 0x07, Vaux6Sel
1530 * 0x08, Vaux6LP
1531 * 0x10, Vaux6Ena
1532 * 0x80, Vaux6DisPulld
1533 */
1534 REG_INIT(AB8505_CTRLVAUX6, 0x01, 0x56, 0x9f),
1535};
1536
Lee Jonesda45edc2013-04-02 13:24:20 +01001537static struct of_regulator_match ab8500_regulator_match[] = {
1538 { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB8500_LDO_AUX1, },
1539 { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB8500_LDO_AUX2, },
1540 { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB8500_LDO_AUX3, },
1541 { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB8500_LDO_INTCORE, },
1542 { .name = "ab8500_ldo_tvout", .driver_data = (void *) AB8500_LDO_TVOUT, },
1543 { .name = "ab8500_ldo_audio", .driver_data = (void *) AB8500_LDO_AUDIO, },
1544 { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB8500_LDO_ANAMIC1, },
Fabio Baltieri5510ed92013-05-30 15:27:42 +02001545 { .name = "ab8500_ldo_anamic2", .driver_data = (void *) AB8500_LDO_ANAMIC2, },
Lee Jonesda45edc2013-04-02 13:24:20 +01001546 { .name = "ab8500_ldo_dmic", .driver_data = (void *) AB8500_LDO_DMIC, },
1547 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB8500_LDO_ANA, },
1548};
1549
1550static struct of_regulator_match ab8505_regulator_match[] = {
1551 { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB8505_LDO_AUX1, },
1552 { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB8505_LDO_AUX2, },
1553 { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB8505_LDO_AUX3, },
1554 { .name = "ab8500_ldo_aux4", .driver_data = (void *) AB8505_LDO_AUX4, },
1555 { .name = "ab8500_ldo_aux5", .driver_data = (void *) AB8505_LDO_AUX5, },
1556 { .name = "ab8500_ldo_aux6", .driver_data = (void *) AB8505_LDO_AUX6, },
1557 { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB8505_LDO_INTCORE, },
1558 { .name = "ab8500_ldo_adc", .driver_data = (void *) AB8505_LDO_ADC, },
1559 { .name = "ab8500_ldo_audio", .driver_data = (void *) AB8505_LDO_AUDIO, },
1560 { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB8505_LDO_ANAMIC1, },
Fabio Baltieri5510ed92013-05-30 15:27:42 +02001561 { .name = "ab8500_ldo_anamic2", .driver_data = (void *) AB8505_LDO_ANAMIC2, },
Lee Jonesda45edc2013-04-02 13:24:20 +01001562 { .name = "ab8500_ldo_aux8", .driver_data = (void *) AB8505_LDO_AUX8, },
1563 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB8505_LDO_ANA, },
1564};
1565
Lee Jones33aeb492013-04-02 13:24:14 +01001566static struct {
1567 struct ab8500_regulator_info *info;
1568 int info_size;
1569 struct ab8500_reg_init *init;
1570 int init_size;
1571 struct of_regulator_match *match;
1572 int match_size;
1573} abx500_regulator;
1574
Lee Jonesda45edc2013-04-02 13:24:20 +01001575static void abx500_get_regulator_info(struct ab8500 *ab8500)
1576{
Linus Walleijec1ba3e52018-03-22 11:17:40 +01001577 if (is_ab8505(ab8500)) {
Lee Jonesda45edc2013-04-02 13:24:20 +01001578 abx500_regulator.info = ab8505_regulator_info;
1579 abx500_regulator.info_size = ARRAY_SIZE(ab8505_regulator_info);
1580 abx500_regulator.init = ab8505_reg_init;
1581 abx500_regulator.init_size = AB8505_NUM_REGULATOR_REGISTERS;
1582 abx500_regulator.match = ab8505_regulator_match;
1583 abx500_regulator.match_size = ARRAY_SIZE(ab8505_regulator_match);
Lee Jonesda45edc2013-04-02 13:24:20 +01001584 } else {
1585 abx500_regulator.info = ab8500_regulator_info;
1586 abx500_regulator.info_size = ARRAY_SIZE(ab8500_regulator_info);
1587 abx500_regulator.init = ab8500_reg_init;
1588 abx500_regulator.init_size = AB8500_NUM_REGULATOR_REGISTERS;
1589 abx500_regulator.match = ab8500_regulator_match;
1590 abx500_regulator.match_size = ARRAY_SIZE(ab8500_regulator_match);
1591 }
1592}
1593
Bill Pembertona5023572012-11-19 13:22:22 -05001594static int ab8500_regulator_register(struct platform_device *pdev,
Lee Jonesb54969a2013-03-28 16:11:10 +00001595 struct regulator_init_data *init_data,
Lee Jonesb54969a2013-03-28 16:11:10 +00001596 int id, struct device_node *np)
Lee Jonesa7ac1d92012-05-17 14:45:14 +01001597{
Lee Jones8e6a8d72013-03-28 16:11:11 +00001598 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01001599 struct ab8500_regulator_info *info = NULL;
1600 struct regulator_config config = { };
Axel Lin7c6b8e32019-04-12 22:11:58 +08001601 struct regulator_dev *rdev;
Lee Jonesa7ac1d92012-05-17 14:45:14 +01001602
1603 /* assign per-regulator data */
Lee Jones33aeb492013-04-02 13:24:14 +01001604 info = &abx500_regulator.info[id];
Lee Jonesa7ac1d92012-05-17 14:45:14 +01001605 info->dev = &pdev->dev;
1606
1607 config.dev = &pdev->dev;
1608 config.init_data = init_data;
1609 config.driver_data = info;
1610 config.of_node = np;
1611
1612 /* fix for hardware before ab8500v2.0 */
Lee Jones8e6a8d72013-03-28 16:11:11 +00001613 if (is_ab8500_1p1_or_earlier(ab8500)) {
Lee Jonesa7ac1d92012-05-17 14:45:14 +01001614 if (info->desc.id == AB8500_LDO_AUX3) {
1615 info->desc.n_voltages =
1616 ARRAY_SIZE(ldo_vauxn_voltages);
Axel Linec1cc4d2012-05-20 10:33:35 +08001617 info->desc.volt_table = ldo_vauxn_voltages;
Lee Jonesa7ac1d92012-05-17 14:45:14 +01001618 info->voltage_mask = 0xf;
1619 }
1620 }
1621
1622 /* register regulator with framework */
Axel Lin7c6b8e32019-04-12 22:11:58 +08001623 rdev = devm_regulator_register(&pdev->dev, &info->desc, &config);
1624 if (IS_ERR(rdev)) {
Lee Jonesa7ac1d92012-05-17 14:45:14 +01001625 dev_err(&pdev->dev, "failed to register regulator %s\n",
1626 info->desc.name);
Axel Lin7c6b8e32019-04-12 22:11:58 +08001627 return PTR_ERR(rdev);
Lee Jonesa7ac1d92012-05-17 14:45:14 +01001628 }
1629
1630 return 0;
1631}
1632
Bill Pembertona5023572012-11-19 13:22:22 -05001633static int ab8500_regulator_probe(struct platform_device *pdev)
Sundar R IYERc789ca22010-07-13 21:48:56 +05301634{
1635 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
Lee Jones3a8334b2012-05-17 14:45:16 +01001636 struct device_node *np = pdev->dev.of_node;
Axel Lina5c1a412014-06-08 22:45:42 +08001637 struct of_regulator_match *match;
1638 int err, i;
Lee Jonesb54969a2013-03-28 16:11:10 +00001639
Lee Jones33aeb492013-04-02 13:24:14 +01001640 if (!ab8500) {
1641 dev_err(&pdev->dev, "null mfd parent\n");
1642 return -EINVAL;
Lee Jones8e6a8d72013-03-28 16:11:11 +00001643 }
Sundar R IYERc789ca22010-07-13 21:48:56 +05301644
Lee Jones33aeb492013-04-02 13:24:14 +01001645 abx500_get_regulator_info(ab8500);
1646
Linus Walleij34c040c2013-12-03 15:08:22 +01001647 err = of_regulator_match(&pdev->dev, np,
1648 abx500_regulator.match,
1649 abx500_regulator.match_size);
1650 if (err < 0) {
1651 dev_err(&pdev->dev,
1652 "Error parsing regulator init data: %d\n", err);
Lee Jones3a8334b2012-05-17 14:45:16 +01001653 return err;
1654 }
Axel Lina5c1a412014-06-08 22:45:42 +08001655
1656 match = abx500_regulator.match;
1657 for (i = 0; i < abx500_regulator.info_size; i++) {
1658 err = ab8500_regulator_register(pdev, match[i].init_data, i,
1659 match[i].of_node);
1660 if (err)
1661 return err;
1662 }
1663
1664 return 0;
Sundar R IYERc789ca22010-07-13 21:48:56 +05301665}
1666
Sundar R IYERc789ca22010-07-13 21:48:56 +05301667static struct platform_driver ab8500_regulator_driver = {
1668 .probe = ab8500_regulator_probe,
Sundar R IYERc789ca22010-07-13 21:48:56 +05301669 .driver = {
1670 .name = "ab8500-regulator",
Sundar R IYERc789ca22010-07-13 21:48:56 +05301671 },
1672};
1673
1674static int __init ab8500_regulator_init(void)
1675{
1676 int ret;
1677
1678 ret = platform_driver_register(&ab8500_regulator_driver);
1679 if (ret != 0)
1680 pr_err("Failed to register ab8500 regulator: %d\n", ret);
1681
1682 return ret;
1683}
1684subsys_initcall(ab8500_regulator_init);
1685
1686static void __exit ab8500_regulator_exit(void)
1687{
1688 platform_driver_unregister(&ab8500_regulator_driver);
1689}
1690module_exit(ab8500_regulator_exit);
1691
1692MODULE_LICENSE("GPL v2");
1693MODULE_AUTHOR("Sundar Iyer <sundar.iyer@stericsson.com>");
Bengt Jonsson732805a2013-03-21 15:59:03 +00001694MODULE_AUTHOR("Bengt Jonsson <bengt.g.jonsson@stericsson.com>");
Lee Jones547f3842013-03-28 16:11:14 +00001695MODULE_AUTHOR("Daniel Willerud <daniel.willerud@stericsson.com>");
Sundar R IYERc789ca22010-07-13 21:48:56 +05301696MODULE_DESCRIPTION("Regulator Driver for ST-Ericsson AB8500 Mixed-Sig PMIC");
1697MODULE_ALIAS("platform:ab8500-regulator");