2 * Copyright (C) ST-Ericsson SA 2010
4 * License Terms: GNU General Public License v2
6 * Authors: Sundar Iyer <sundar.iyer@stericsson.com>
7 * Bengt Jonsson <bengt.g.jonsson@stericsson.com>
9 * MOP500 board specific initialization for regulators
11 #include <linux/kernel.h>
12 #include <linux/regulator/machine.h>
13 #include <linux/regulator/ab8500.h>
14 #include "board-mop500-regulators.h"
16 static struct regulator_consumer_supply gpio_en_3v3_consumers
[] = {
17 REGULATOR_SUPPLY("vdd33a", "smsc911x.0"),
20 struct regulator_init_data gpio_en_3v3_regulator
= {
25 .valid_ops_mask
= REGULATOR_CHANGE_STATUS
,
27 .num_consumer_supplies
= ARRAY_SIZE(gpio_en_3v3_consumers
),
28 .consumer_supplies
= gpio_en_3v3_consumers
,
34 static struct regulator_consumer_supply tps61052_vaudio_consumers
[] = {
36 * Boost converter supply to raise voltage on audio speaker, this
37 * is actually connected to three pins, VInVhfL (left amplifier)
38 * VInVhfR (right amplifier) and VIntDClassInt - all three must
39 * be connected to the same voltage.
41 REGULATOR_SUPPLY("vintdclassint", "ab8500-codec.0"),
44 struct regulator_init_data tps61052_regulator
= {
49 .valid_ops_mask
= REGULATOR_CHANGE_STATUS
,
51 .num_consumer_supplies
= ARRAY_SIZE(tps61052_vaudio_consumers
),
52 .consumer_supplies
= tps61052_vaudio_consumers
,
55 static struct regulator_consumer_supply ab8500_vaux1_consumers
[] = {
56 /* Main display, u8500 R3 uib */
57 REGULATOR_SUPPLY("vddi", "mcde_disp_sony_acx424akp.0"),
58 /* Main display, u8500 uib and ST uib */
59 REGULATOR_SUPPLY("vdd1", "samsung_s6d16d0.0"),
60 /* Secondary display, ST uib */
61 REGULATOR_SUPPLY("vdd1", "samsung_s6d16d0.1"),
62 /* SFH7741 proximity sensor */
63 REGULATOR_SUPPLY("vcc", "gpio-keys.0"),
64 /* BH1780GLS ambient light sensor */
65 REGULATOR_SUPPLY("vcc", "2-0029"),
66 /* lsm303dlh accelerometer */
67 REGULATOR_SUPPLY("vdd", "3-0018"),
68 /* lsm303dlhc accelerometer */
69 REGULATOR_SUPPLY("vdd", "2-0019"),
70 /* lsm303dlh magnetometer */
71 REGULATOR_SUPPLY("vdd", "2-001e"),
72 /* Rohm BU21013 Touchscreen devices */
73 REGULATOR_SUPPLY("avdd", "3-005c"),
74 REGULATOR_SUPPLY("avdd", "3-005d"),
75 /* Synaptics RMI4 Touchscreen device */
76 REGULATOR_SUPPLY("vdd", "3-004b"),
77 /* L3G4200D Gyroscope device */
78 REGULATOR_SUPPLY("vdd", "2-0068"),
79 /* Ambient light sensor device */
80 REGULATOR_SUPPLY("vdd", "3-0029"),
81 /* Pressure sensor device */
82 REGULATOR_SUPPLY("vdd", "2-005c"),
83 /* Cypress TrueTouch Touchscreen device */
84 REGULATOR_SUPPLY("vcpin", "spi8.0"),
86 REGULATOR_SUPPLY("vaux12v5", "mmio_camera"),
89 static struct regulator_consumer_supply ab8500_vaux2_consumers
[] = {
90 /* On-board eMMC power */
91 REGULATOR_SUPPLY("vmmc", "sdi4"),
92 /* AB8500 audio codec */
93 REGULATOR_SUPPLY("vcc-N2158", "ab8500-codec.0"),
96 static struct regulator_consumer_supply ab8500_vaux3_consumers
[] = {
97 /* External MMC slot power */
98 REGULATOR_SUPPLY("vmmc", "sdi0"),
101 static struct regulator_consumer_supply ab8500_vtvout_consumers
[] = {
102 /* TV-out DENC supply */
103 REGULATOR_SUPPLY("vtvout", "ab8500-denc.0"),
104 /* Internal general-purpose ADC */
105 REGULATOR_SUPPLY("vddadc", "ab8500-gpadc.0"),
108 static struct regulator_consumer_supply ab8500_vaud_consumers
[] = {
109 /* AB8500 audio-codec main supply */
110 REGULATOR_SUPPLY("vaud", "ab8500-codec.0"),
113 static struct regulator_consumer_supply ab8500_vamic1_consumers
[] = {
114 /* AB8500 audio-codec Mic1 supply */
115 REGULATOR_SUPPLY("vamic1", "ab8500-codec.0"),
118 static struct regulator_consumer_supply ab8500_vamic2_consumers
[] = {
119 /* AB8500 audio-codec Mic2 supply */
120 REGULATOR_SUPPLY("vamic2", "ab8500-codec.0"),
123 static struct regulator_consumer_supply ab8500_vdmic_consumers
[] = {
124 /* AB8500 audio-codec DMic supply */
125 REGULATOR_SUPPLY("vdmic", "ab8500-codec.0"),
128 static struct regulator_consumer_supply ab8500_vintcore_consumers
[] = {
129 /* SoC core supply, no device */
130 REGULATOR_SUPPLY("v-intcore", NULL
),
131 /* USB Transceiver */
132 REGULATOR_SUPPLY("vddulpivio18", "ab8500-usb.0"),
135 static struct regulator_consumer_supply ab8500_vana_consumers
[] = {
136 /* External displays, connector on board, 1v8 power supply */
137 REGULATOR_SUPPLY("vsmps2", "mcde.0"),
140 /* ab8500 regulator register initialization */
141 static struct ab8500_regulator_reg_init ab8500_reg_init
[] = {
143 * VanaRequestCtrl = HP/LP depending on VxRequest
144 * VextSupply1RequestCtrl = HP/LP depending on VxRequest
146 INIT_REGULATOR_REGISTER(AB8500_REGUREQUESTCTRL2
, 0xf0, 0x00),
148 * VextSupply2RequestCtrl = HP/LP depending on VxRequest
149 * VextSupply3RequestCtrl = HP/LP depending on VxRequest
150 * Vaux1RequestCtrl = HP/LP depending on VxRequest
151 * Vaux2RequestCtrl = HP/LP depending on VxRequest
153 INIT_REGULATOR_REGISTER(AB8500_REGUREQUESTCTRL3
, 0xff, 0x00),
155 * Vaux3RequestCtrl = HP/LP depending on VxRequest
156 * SwHPReq = Control through SWValid disabled
158 INIT_REGULATOR_REGISTER(AB8500_REGUREQUESTCTRL4
, 0x07, 0x00),
160 * VanaSysClkReq1HPValid = disabled
161 * Vaux1SysClkReq1HPValid = disabled
162 * Vaux2SysClkReq1HPValid = disabled
163 * Vaux3SysClkReq1HPValid = disabled
165 INIT_REGULATOR_REGISTER(AB8500_REGUSYSCLKREQ1HPVALID1
, 0xe8, 0x00),
167 * VextSupply1SysClkReq1HPValid = disabled
168 * VextSupply2SysClkReq1HPValid = disabled
169 * VextSupply3SysClkReq1HPValid = SysClkReq1 controlled
171 INIT_REGULATOR_REGISTER(AB8500_REGUSYSCLKREQ1HPVALID2
, 0x70, 0x40),
173 * VanaHwHPReq1Valid = disabled
174 * Vaux1HwHPreq1Valid = disabled
175 * Vaux2HwHPReq1Valid = disabled
176 * Vaux3HwHPReqValid = disabled
178 INIT_REGULATOR_REGISTER(AB8500_REGUHWHPREQ1VALID1
, 0xe8, 0x00),
180 * VextSupply1HwHPReq1Valid = disabled
181 * VextSupply2HwHPReq1Valid = disabled
182 * VextSupply3HwHPReq1Valid = disabled
184 INIT_REGULATOR_REGISTER(AB8500_REGUHWHPREQ1VALID2
, 0x07, 0x00),
186 * VanaHwHPReq2Valid = disabled
187 * Vaux1HwHPReq2Valid = disabled
188 * Vaux2HwHPReq2Valid = disabled
189 * Vaux3HwHPReq2Valid = disabled
191 INIT_REGULATOR_REGISTER(AB8500_REGUHWHPREQ2VALID1
, 0xe8, 0x00),
193 * VextSupply1HwHPReq2Valid = disabled
194 * VextSupply2HwHPReq2Valid = disabled
195 * VextSupply3HwHPReq2Valid = HWReq2 controlled
197 INIT_REGULATOR_REGISTER(AB8500_REGUHWHPREQ2VALID2
, 0x07, 0x04),
199 * VanaSwHPReqValid = disabled
200 * Vaux1SwHPReqValid = disabled
202 INIT_REGULATOR_REGISTER(AB8500_REGUSWHPREQVALID1
, 0xa0, 0x00),
204 * Vaux2SwHPReqValid = disabled
205 * Vaux3SwHPReqValid = disabled
206 * VextSupply1SwHPReqValid = disabled
207 * VextSupply2SwHPReqValid = disabled
208 * VextSupply3SwHPReqValid = disabled
210 INIT_REGULATOR_REGISTER(AB8500_REGUSWHPREQVALID2
, 0x1f, 0x00),
212 * SysClkReq2Valid1 = SysClkReq2 controlled
213 * SysClkReq3Valid1 = disabled
214 * SysClkReq4Valid1 = SysClkReq4 controlled
215 * SysClkReq5Valid1 = disabled
216 * SysClkReq6Valid1 = SysClkReq6 controlled
217 * SysClkReq7Valid1 = disabled
218 * SysClkReq8Valid1 = disabled
220 INIT_REGULATOR_REGISTER(AB8500_REGUSYSCLKREQVALID1
, 0xfe, 0x2a),
222 * SysClkReq2Valid2 = disabled
223 * SysClkReq3Valid2 = disabled
224 * SysClkReq4Valid2 = disabled
225 * SysClkReq5Valid2 = disabled
226 * SysClkReq6Valid2 = SysClkReq6 controlled
227 * SysClkReq7Valid2 = disabled
228 * SysClkReq8Valid2 = disabled
230 INIT_REGULATOR_REGISTER(AB8500_REGUSYSCLKREQVALID2
, 0xfe, 0x20),
232 * VTVoutEna = disabled
233 * Vintcore12Ena = disabled
234 * Vintcore12Sel = 1.25 V
235 * Vintcore12LP = inactive (HP)
236 * VTVoutLP = inactive (HP)
238 INIT_REGULATOR_REGISTER(AB8500_REGUMISC1
, 0xfe, 0x10),
240 * VaudioEna = disabled
241 * VdmicEna = disabled
242 * Vamic1Ena = disabled
243 * Vamic2Ena = disabled
245 INIT_REGULATOR_REGISTER(AB8500_VAUDIOSUPPLY
, 0x1e, 0x00),
247 * Vamic1_dzout = high-Z when Vamic1 is disabled
248 * Vamic2_dzout = high-Z when Vamic2 is disabled
250 INIT_REGULATOR_REGISTER(AB8500_REGUCTRL1VAMIC
, 0x03, 0x00),
252 * VPll = Hw controlled (NOTE! PRCMU bits)
253 * VanaRegu = force off
255 INIT_REGULATOR_REGISTER(AB8500_VPLLVANAREGU
, 0x0f, 0x02),
257 * VrefDDREna = disabled
258 * VrefDDRSleepMode = inactive (no pulldown)
260 INIT_REGULATOR_REGISTER(AB8500_VREFDDR
, 0x03, 0x00),
262 * VextSupply1Regu = force LP
263 * VextSupply2Regu = force OFF
264 * VextSupply3Regu = force HP (-> STBB2=LP and TPS=LP)
265 * ExtSupply2Bypass = ExtSupply12LPn ball is 0 when Ena is 0
266 * ExtSupply3Bypass = ExtSupply3LPn ball is 0 when Ena is 0
268 INIT_REGULATOR_REGISTER(AB8500_EXTSUPPLYREGU
, 0xff, 0x13),
270 * Vaux1Regu = force HP
271 * Vaux2Regu = force off
273 INIT_REGULATOR_REGISTER(AB8500_VAUX12REGU
, 0x0f, 0x01),
275 * Vaux3Regu = force off
277 INIT_REGULATOR_REGISTER(AB8500_VRF1VAUX3REGU
, 0x03, 0x00),
281 INIT_REGULATOR_REGISTER(AB8500_VAUX1SEL
, 0x0f, 0x08),
285 INIT_REGULATOR_REGISTER(AB8500_VAUX2SEL
, 0x0f, 0x0d),
289 INIT_REGULATOR_REGISTER(AB8500_VRF1VAUX3SEL
, 0x07, 0x07),
291 * VextSupply12LP = disabled (no LP)
293 INIT_REGULATOR_REGISTER(AB8500_REGUCTRL2SPARE
, 0x01, 0x00),
295 * Vaux1Disch = short discharge time
296 * Vaux2Disch = short discharge time
297 * Vaux3Disch = short discharge time
298 * Vintcore12Disch = short discharge time
299 * VTVoutDisch = short discharge time
300 * VaudioDisch = short discharge time
302 INIT_REGULATOR_REGISTER(AB8500_REGUCTRLDISCH
, 0xfc, 0x00),
304 * VanaDisch = short discharge time
305 * VdmicPullDownEna = pulldown disabled when Vdmic is disabled
306 * VdmicDisch = short discharge time
308 INIT_REGULATOR_REGISTER(AB8500_REGUCTRLDISCH2
, 0x16, 0x00),
311 /* AB8500 regulators */
312 static struct regulator_init_data ab8500_regulators
[AB8500_NUM_REGULATORS
] = {
313 /* supplies to the display/camera */
314 [AB8500_LDO_AUX1
] = {
319 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
|
320 REGULATOR_CHANGE_STATUS
,
321 .boot_on
= 1, /* display is on at boot */
323 * This voltage cannot be disabled right now because
324 * it is somehow affecting the external MMC
325 * functionality, though that typically will use
330 .num_consumer_supplies
= ARRAY_SIZE(ab8500_vaux1_consumers
),
331 .consumer_supplies
= ab8500_vaux1_consumers
,
333 /* supplies to the on-board eMMC */
334 [AB8500_LDO_AUX2
] = {
339 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
|
340 REGULATOR_CHANGE_STATUS
,
342 .num_consumer_supplies
= ARRAY_SIZE(ab8500_vaux2_consumers
),
343 .consumer_supplies
= ab8500_vaux2_consumers
,
345 /* supply for VAUX3, supplies to SDcard slots */
346 [AB8500_LDO_AUX3
] = {
351 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
|
352 REGULATOR_CHANGE_STATUS
,
354 .num_consumer_supplies
= ARRAY_SIZE(ab8500_vaux3_consumers
),
355 .consumer_supplies
= ab8500_vaux3_consumers
,
357 /* supply for tvout, gpadc, TVOUT LDO */
358 [AB8500_LDO_TVOUT
] = {
361 .valid_ops_mask
= REGULATOR_CHANGE_STATUS
,
363 .num_consumer_supplies
= ARRAY_SIZE(ab8500_vtvout_consumers
),
364 .consumer_supplies
= ab8500_vtvout_consumers
,
366 /* supply for ab8500-vaudio, VAUDIO LDO */
367 [AB8500_LDO_AUDIO
] = {
370 .valid_ops_mask
= REGULATOR_CHANGE_STATUS
,
372 .num_consumer_supplies
= ARRAY_SIZE(ab8500_vaud_consumers
),
373 .consumer_supplies
= ab8500_vaud_consumers
,
375 /* supply for v-anamic1 VAMic1-LDO */
376 [AB8500_LDO_ANAMIC1
] = {
379 .valid_ops_mask
= REGULATOR_CHANGE_STATUS
,
381 .num_consumer_supplies
= ARRAY_SIZE(ab8500_vamic1_consumers
),
382 .consumer_supplies
= ab8500_vamic1_consumers
,
384 /* supply for v-amic2, VAMIC2 LDO, reuse constants for AMIC1 */
385 [AB8500_LDO_ANAMIC2
] = {
388 .valid_ops_mask
= REGULATOR_CHANGE_STATUS
,
390 .num_consumer_supplies
= ARRAY_SIZE(ab8500_vamic2_consumers
),
391 .consumer_supplies
= ab8500_vamic2_consumers
,
393 /* supply for v-dmic, VDMIC LDO */
394 [AB8500_LDO_DMIC
] = {
397 .valid_ops_mask
= REGULATOR_CHANGE_STATUS
,
399 .num_consumer_supplies
= ARRAY_SIZE(ab8500_vdmic_consumers
),
400 .consumer_supplies
= ab8500_vdmic_consumers
,
402 /* supply for v-intcore12, VINTCORE12 LDO */
403 [AB8500_LDO_INTCORE
] = {
406 .valid_ops_mask
= REGULATOR_CHANGE_STATUS
,
408 .num_consumer_supplies
= ARRAY_SIZE(ab8500_vintcore_consumers
),
409 .consumer_supplies
= ab8500_vintcore_consumers
,
411 /* supply for U8500 CSI/DSI, VANA LDO */
415 .valid_ops_mask
= REGULATOR_CHANGE_STATUS
,
417 .num_consumer_supplies
= ARRAY_SIZE(ab8500_vana_consumers
),
418 .consumer_supplies
= ab8500_vana_consumers
,
422 /* supply for VextSupply3 */
423 static struct regulator_consumer_supply ab8500_ext_supply3_consumers
[] = {
424 /* SIM supply for 3 V SIM cards */
425 REGULATOR_SUPPLY("vinvsim", "sim-detect.0"),
428 /* extended configuration for VextSupply2, only used for HREFP_V20 boards */
429 static struct ab8500_ext_regulator_cfg ab8500_ext_supply2
= {
434 * AB8500 external regulators
436 static struct regulator_init_data ab8500_ext_regulators
[] = {
437 /* fixed Vbat supplies VSMPS1_EXT_1V8 */
438 [AB8500_EXT_SUPPLY1
] = {
440 .name
= "ab8500-ext-supply1",
443 .initial_mode
= REGULATOR_MODE_IDLE
,
448 /* fixed Vbat supplies VSMPS2_EXT_1V36 and VSMPS5_EXT_1V15 */
449 [AB8500_EXT_SUPPLY2
] = {
451 .name
= "ab8500-ext-supply2",
456 /* fixed Vbat supplies VSMPS3_EXT_3V4 and VSMPS4_EXT_3V4 */
457 [AB8500_EXT_SUPPLY3
] = {
459 .name
= "ab8500-ext-supply3",
462 .valid_ops_mask
= REGULATOR_CHANGE_STATUS
,
465 .num_consumer_supplies
=
466 ARRAY_SIZE(ab8500_ext_supply3_consumers
),
467 .consumer_supplies
= ab8500_ext_supply3_consumers
,
471 struct ab8500_regulator_platform_data ab8500_regulator_plat_data
= {
472 .reg_init
= ab8500_reg_init
,
473 .num_reg_init
= ARRAY_SIZE(ab8500_reg_init
),
474 .regulator
= ab8500_regulators
,
475 .num_regulator
= ARRAY_SIZE(ab8500_regulators
),
476 .ext_regulator
= ab8500_ext_regulators
,
477 .num_ext_regulator
= ARRAY_SIZE(ab8500_ext_regulators
),
480 static void ab8500_modify_reg_init(int id
, u8 mask
, u8 value
)
484 for (i
= ARRAY_SIZE(ab8500_reg_init
) - 1; i
>= 0; i
--) {
485 if (ab8500_reg_init
[i
].id
== id
) {
486 u8 initval
= ab8500_reg_init
[i
].value
;
487 initval
= (initval
& ~mask
) | (value
& mask
);
488 ab8500_reg_init
[i
].value
= initval
;
490 BUG_ON(mask
& ~ab8500_reg_init
[i
].mask
);