PageRenderTime 68ms CodeModel.GetById 14ms app.highlight 48ms RepoModel.GetById 1ms app.codeStats 1ms

/arch/arm/mach-msm/board-8960-regulator.c

https://github.com/AICP/kernel_google_msm
C | 638 lines | 562 code | 37 blank | 39 comment | 4 complexity | bc85005f83f68f4923119c4e60188b5b MD5 | raw file
  1/*
  2 * Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
  3 *
  4 * This program is free software; you can redistribute it and/or modify
  5 * it under the terms of the GNU General Public License version 2 and
  6 * only version 2 as published by the Free Software Foundation.
  7 *
  8 * This program is distributed in the hope that it will be useful,
  9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 11 * GNU General Public License for more details.
 12 */
 13
 14#include <linux/regulator/pm8xxx-regulator.h>
 15#include <linux/regulator/msm-gpio-regulator.h>
 16#include <mach/rpm-regulator.h>
 17#include <mach/socinfo.h>
 18
 19#include "board-8960.h"
 20
 21#define VREG_CONSUMERS(_id) \
 22	static struct regulator_consumer_supply vreg_consumers_##_id[]
 23
 24/*
 25 * Consumer specific regulator names:
 26 *			 regulator name		consumer dev_name
 27 */
 28VREG_CONSUMERS(L1) = {
 29	REGULATOR_SUPPLY("8921_l1",		NULL),
 30};
 31VREG_CONSUMERS(L2) = {
 32	REGULATOR_SUPPLY("8921_l2",		NULL),
 33	REGULATOR_SUPPLY("dsi_vdda",		"mipi_dsi.1"),
 34	REGULATOR_SUPPLY("mipi_csi_vdd",	"msm_csid.0"),
 35	REGULATOR_SUPPLY("mipi_csi_vdd",	"msm_csid.1"),
 36	REGULATOR_SUPPLY("mipi_csi_vdd",	"msm_csid.2"),
 37};
 38VREG_CONSUMERS(L3) = {
 39	REGULATOR_SUPPLY("8921_l3",		NULL),
 40	REGULATOR_SUPPLY("HSUSB_3p3",		"msm_otg"),
 41};
 42VREG_CONSUMERS(L4) = {
 43	REGULATOR_SUPPLY("8921_l4",		NULL),
 44	REGULATOR_SUPPLY("HSUSB_1p8",		"msm_otg"),
 45	REGULATOR_SUPPLY("iris_vddxo",		"wcnss_wlan.0"),
 46};
 47VREG_CONSUMERS(L5) = {
 48	REGULATOR_SUPPLY("8921_l5",		NULL),
 49	REGULATOR_SUPPLY("sdc_vdd",		"msm_sdcc.1"),
 50};
 51VREG_CONSUMERS(L6) = {
 52	REGULATOR_SUPPLY("8921_l6",		NULL),
 53	REGULATOR_SUPPLY("sdc_vdd",		"msm_sdcc.3"),
 54};
 55VREG_CONSUMERS(L7) = {
 56	REGULATOR_SUPPLY("8921_l7",		NULL),
 57	REGULATOR_SUPPLY("sdc_vdd_io",		"msm_sdcc.3"),
 58};
 59VREG_CONSUMERS(L8) = {
 60	REGULATOR_SUPPLY("8921_l8",		NULL),
 61	REGULATOR_SUPPLY("dsi_vdc",		"mipi_dsi.1"),
 62};
 63VREG_CONSUMERS(L9) = {
 64	REGULATOR_SUPPLY("8921_l9",		NULL),
 65	REGULATOR_SUPPLY("vdd",			"3-0024"),
 66	REGULATOR_SUPPLY("vdd_ana",		"3-004a"),
 67};
 68VREG_CONSUMERS(L10) = {
 69	REGULATOR_SUPPLY("8921_l10",		NULL),
 70	REGULATOR_SUPPLY("iris_vddpa",		"wcnss_wlan.0"),
 71
 72};
 73VREG_CONSUMERS(L11) = {
 74	REGULATOR_SUPPLY("8921_l11",		NULL),
 75	REGULATOR_SUPPLY("cam_vana",		"4-001a"),
 76	REGULATOR_SUPPLY("cam_vana",		"4-006c"),
 77	REGULATOR_SUPPLY("cam_vana",		"4-0048"),
 78	REGULATOR_SUPPLY("cam_vana",		"4-0020"),
 79	REGULATOR_SUPPLY("cam_vana",		"4-0034"),
 80};
 81VREG_CONSUMERS(L12) = {
 82	REGULATOR_SUPPLY("8921_l12",		NULL),
 83	REGULATOR_SUPPLY("cam_vdig",		"4-001a"),
 84	REGULATOR_SUPPLY("cam_vdig",		"4-006c"),
 85	REGULATOR_SUPPLY("cam_vdig",		"4-0048"),
 86	REGULATOR_SUPPLY("cam_vdig",		"4-0020"),
 87	REGULATOR_SUPPLY("cam_vdig",		"4-0034"),
 88};
 89VREG_CONSUMERS(L14) = {
 90	REGULATOR_SUPPLY("8921_l14",		NULL),
 91	REGULATOR_SUPPLY("pa_therm",		"pm8xxx-adc"),
 92};
 93VREG_CONSUMERS(L15) = {
 94	REGULATOR_SUPPLY("8921_l15",		NULL),
 95};
 96VREG_CONSUMERS(L16) = {
 97	REGULATOR_SUPPLY("8921_l16",		NULL),
 98	REGULATOR_SUPPLY("cam_vaf",		"4-001a"),
 99	REGULATOR_SUPPLY("cam_vaf",		"4-006c"),
100	REGULATOR_SUPPLY("cam_vaf",		"4-0048"),
101	REGULATOR_SUPPLY("cam_vaf",		"4-0020"),
102	REGULATOR_SUPPLY("cam_vaf",		"4-0034"),
103};
104VREG_CONSUMERS(L17) = {
105	REGULATOR_SUPPLY("8921_l17",		NULL),
106};
107VREG_CONSUMERS(L18) = {
108	REGULATOR_SUPPLY("8921_l18",		NULL),
109};
110VREG_CONSUMERS(L21) = {
111	REGULATOR_SUPPLY("8921_l21",		NULL),
112};
113VREG_CONSUMERS(L22) = {
114	REGULATOR_SUPPLY("8921_l22",		NULL),
115};
116VREG_CONSUMERS(L23) = {
117	REGULATOR_SUPPLY("8921_l23",		NULL),
118	REGULATOR_SUPPLY("dsi_vddio",		"mipi_dsi.1"),
119	REGULATOR_SUPPLY("hdmi_avdd",		"hdmi_msm.0"),
120	REGULATOR_SUPPLY("pll_vdd",		"pil_riva"),
121	REGULATOR_SUPPLY("pll_vdd",		"pil_qdsp6v4.1"),
122	REGULATOR_SUPPLY("pll_vdd",		"pil_qdsp6v4.2"),
123};
124VREG_CONSUMERS(L24) = {
125	REGULATOR_SUPPLY("8921_l24",		NULL),
126	REGULATOR_SUPPLY("riva_vddmx",		"wcnss_wlan.0"),
127};
128VREG_CONSUMERS(L25) = {
129	REGULATOR_SUPPLY("8921_l25",		NULL),
130	REGULATOR_SUPPLY("VDDD_CDC_D",		"tabla-slim"),
131	REGULATOR_SUPPLY("CDC_VDDA_A_1P2V",	"tabla-slim"),
132	REGULATOR_SUPPLY("VDDD_CDC_D",		"tabla2x-slim"),
133	REGULATOR_SUPPLY("CDC_VDDA_A_1P2V",	"tabla2x-slim"),
134};
135VREG_CONSUMERS(L26) = {
136	REGULATOR_SUPPLY("8921_l26",		NULL),
137	REGULATOR_SUPPLY("core_vdd",		"pil_qdsp6v4.0"),
138};
139VREG_CONSUMERS(L27) = {
140	REGULATOR_SUPPLY("8921_l27",		NULL),
141	REGULATOR_SUPPLY("core_vdd",		"pil_qdsp6v4.2"),
142};
143VREG_CONSUMERS(L28) = {
144	REGULATOR_SUPPLY("8921_l28",		NULL),
145	REGULATOR_SUPPLY("core_vdd",		"pil_qdsp6v4.1"),
146};
147VREG_CONSUMERS(L29) = {
148	REGULATOR_SUPPLY("8921_l29",		NULL),
149};
150VREG_CONSUMERS(S1) = {
151	REGULATOR_SUPPLY("8921_s1",		NULL),
152};
153VREG_CONSUMERS(S2) = {
154	REGULATOR_SUPPLY("8921_s2",		NULL),
155	REGULATOR_SUPPLY("iris_vddrfa",		"wcnss_wlan.0"),
156
157};
158VREG_CONSUMERS(S3) = {
159	REGULATOR_SUPPLY("8921_s3",		NULL),
160	REGULATOR_SUPPLY("HSUSB_VDDCX",		"msm_otg"),
161	REGULATOR_SUPPLY("riva_vddcx",		"wcnss_wlan.0"),
162	REGULATOR_SUPPLY("HSIC_VDDCX",		"msm_hsic_host"),
163};
164VREG_CONSUMERS(S4) = {
165	REGULATOR_SUPPLY("8921_s4",		NULL),
166	REGULATOR_SUPPLY("sdc_vdd_io",		"msm_sdcc.1"),
167	REGULATOR_SUPPLY("sdc_vdd",		"msm_sdcc.2"),
168	REGULATOR_SUPPLY("sdc_vdd_io",            "msm_sdcc.4"),
169	REGULATOR_SUPPLY("riva_vddpx",		"wcnss_wlan.0"),
170	REGULATOR_SUPPLY("hdmi_vcc",		"hdmi_msm.0"),
171	REGULATOR_SUPPLY("VDDIO_CDC",		"tabla-slim"),
172	REGULATOR_SUPPLY("CDC_VDD_CP",		"tabla-slim"),
173	REGULATOR_SUPPLY("CDC_VDDA_TX",		"tabla-slim"),
174	REGULATOR_SUPPLY("CDC_VDDA_RX",		"tabla-slim"),
175	REGULATOR_SUPPLY("VDDIO_CDC",		"tabla2x-slim"),
176	REGULATOR_SUPPLY("CDC_VDD_CP",		"tabla2x-slim"),
177	REGULATOR_SUPPLY("CDC_VDDA_TX",		"tabla2x-slim"),
178	REGULATOR_SUPPLY("CDC_VDDA_RX",		"tabla2x-slim"),
179	REGULATOR_SUPPLY("vcc_i2c",		"3-005b"),
180	REGULATOR_SUPPLY("EXT_HUB_VDDIO",	"msm_smsc_hub"),
181	REGULATOR_SUPPLY("vcc_i2c",		"10-0048"),
182};
183VREG_CONSUMERS(S5) = {
184	REGULATOR_SUPPLY("8921_s5",		NULL),
185	REGULATOR_SUPPLY("krait0",		"acpuclk-8960"),
186	REGULATOR_SUPPLY("krait0",		"acpuclk-8960ab"),
187};
188VREG_CONSUMERS(S6) = {
189	REGULATOR_SUPPLY("8921_s6",		NULL),
190	REGULATOR_SUPPLY("krait1",		"acpuclk-8960"),
191	REGULATOR_SUPPLY("krait1",		"acpuclk-8960ab"),
192};
193VREG_CONSUMERS(S7) = {
194	REGULATOR_SUPPLY("8921_s7",		NULL),
195};
196VREG_CONSUMERS(S8) = {
197	REGULATOR_SUPPLY("8921_s8",		NULL),
198};
199VREG_CONSUMERS(LVS1) = {
200	REGULATOR_SUPPLY("8921_lvs1",		NULL),
201	REGULATOR_SUPPLY("iris_vddio",		"wcnss_wlan.0"),
202};
203VREG_CONSUMERS(LVS2) = {
204	REGULATOR_SUPPLY("8921_lvs2",		NULL),
205	REGULATOR_SUPPLY("iris_vdddig",		"wcnss_wlan.0"),
206};
207VREG_CONSUMERS(LVS3) = {
208	REGULATOR_SUPPLY("8921_lvs3",		NULL),
209};
210VREG_CONSUMERS(LVS4) = {
211	REGULATOR_SUPPLY("8921_lvs4",		NULL),
212	REGULATOR_SUPPLY("vcc_i2c",		"3-0024"),
213	REGULATOR_SUPPLY("vcc_i2c",		"3-004a"),
214};
215VREG_CONSUMERS(LVS5) = {
216	REGULATOR_SUPPLY("8921_lvs5",		NULL),
217	REGULATOR_SUPPLY("cam_vio",		"4-001a"),
218	REGULATOR_SUPPLY("cam_vio",		"4-006c"),
219	REGULATOR_SUPPLY("cam_vio",		"4-0048"),
220	REGULATOR_SUPPLY("cam_vio",		"4-0020"),
221	REGULATOR_SUPPLY("cam_vio",		"4-0034"),
222};
223/* This mapping is used for CDP only. */
224VREG_CONSUMERS(CDP_LVS6) = {
225	REGULATOR_SUPPLY("8921_lvs6",		NULL),
226	REGULATOR_SUPPLY("vdd-io",		"spi0.0"),
227};
228/* This mapping is used for non-CDP targets only. */
229VREG_CONSUMERS(LVS6) = {
230	REGULATOR_SUPPLY("8921_lvs6",		NULL),
231	REGULATOR_SUPPLY("vdd-io",		"spi0.0"),
232	REGULATOR_SUPPLY("vdd-phy",		"spi0.0"),
233};
234VREG_CONSUMERS(LVS7) = {
235	REGULATOR_SUPPLY("8921_lvs7",		NULL),
236};
237VREG_CONSUMERS(USB_OTG) = {
238	REGULATOR_SUPPLY("8921_usb_otg",	NULL),
239};
240VREG_CONSUMERS(HDMI_MVS) = {
241	REGULATOR_SUPPLY("8921_hdmi_mvs",	NULL),
242	REGULATOR_SUPPLY("hdmi_mvs",		"hdmi_msm.0"),
243};
244VREG_CONSUMERS(NCP) = {
245	REGULATOR_SUPPLY("8921_ncp",		NULL),
246};
247VREG_CONSUMERS(EXT_5V) = {
248	REGULATOR_SUPPLY("ext_5v",		NULL),
249};
250VREG_CONSUMERS(EXT_L2) = {
251	REGULATOR_SUPPLY("ext_l2",		NULL),
252	REGULATOR_SUPPLY("vdd-phy",		"spi0.0"),
253};
254VREG_CONSUMERS(EXT_3P3V) = {
255	REGULATOR_SUPPLY("ext_3p3v",		NULL),
256	REGULATOR_SUPPLY("vdd_ana",		"3-005b"),
257	REGULATOR_SUPPLY("vdd_lvds_3p3v",	"mipi_dsi.1"),
258	REGULATOR_SUPPLY("mhl_usb_hs_switch",	"msm_otg"),
259};
260VREG_CONSUMERS(EXT_OTG_SW) = {
261	REGULATOR_SUPPLY("ext_otg_sw",		NULL),
262	REGULATOR_SUPPLY("vbus_otg",		"msm_otg"),
263};
264
265#define PM8XXX_VREG_INIT(_id, _name, _min_uV, _max_uV, _modes, _ops, \
266			 _apply_uV, _pull_down, _always_on, _supply_regulator, \
267			 _system_uA, _enable_time, _reg_id) \
268	{ \
269		.init_data = { \
270			.constraints = { \
271				.valid_modes_mask	= _modes, \
272				.valid_ops_mask		= _ops, \
273				.min_uV			= _min_uV, \
274				.max_uV			= _max_uV, \
275				.input_uV		= _max_uV, \
276				.apply_uV		= _apply_uV, \
277				.always_on		= _always_on, \
278				.name			= _name, \
279			}, \
280			.num_consumer_supplies	= \
281					ARRAY_SIZE(vreg_consumers_##_id), \
282			.consumer_supplies	= vreg_consumers_##_id, \
283			.supply_regulator	= _supply_regulator, \
284		}, \
285		.id			= _reg_id, \
286		.pull_down_enable	= _pull_down, \
287		.system_uA		= _system_uA, \
288		.enable_time		= _enable_time, \
289	}
290
291#define PM8XXX_LDO(_id, _name, _always_on, _pull_down, _min_uV, _max_uV, \
292		_enable_time, _supply_regulator, _system_uA, _reg_id) \
293	PM8XXX_VREG_INIT(_id, _name, _min_uV, _max_uV, REGULATOR_MODE_NORMAL \
294		| REGULATOR_MODE_IDLE, REGULATOR_CHANGE_VOLTAGE | \
295		REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
296		REGULATOR_CHANGE_DRMS, 0, _pull_down, _always_on, \
297		_supply_regulator, _system_uA, _enable_time, _reg_id)
298
299#define PM8XXX_NLDO1200(_id, _name, _always_on, _pull_down, _min_uV, \
300		_max_uV, _enable_time, _supply_regulator, _system_uA, _reg_id) \
301	PM8XXX_VREG_INIT(_id, _name, _min_uV, _max_uV, REGULATOR_MODE_NORMAL \
302		| REGULATOR_MODE_IDLE, REGULATOR_CHANGE_VOLTAGE | \
303		REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
304		REGULATOR_CHANGE_DRMS, 0, _pull_down, _always_on, \
305		_supply_regulator, _system_uA, _enable_time, _reg_id)
306
307#define PM8XXX_SMPS(_id, _name, _always_on, _pull_down, _min_uV, _max_uV, \
308		_enable_time, _supply_regulator, _system_uA, _reg_id) \
309	PM8XXX_VREG_INIT(_id, _name, _min_uV, _max_uV, REGULATOR_MODE_NORMAL \
310		| REGULATOR_MODE_IDLE, REGULATOR_CHANGE_VOLTAGE | \
311		REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
312		REGULATOR_CHANGE_DRMS, 0, _pull_down, _always_on, \
313		_supply_regulator, _system_uA, _enable_time, _reg_id)
314
315#define PM8XXX_FTSMPS(_id, _name, _always_on, _pull_down, _min_uV, _max_uV, \
316		_enable_time, _supply_regulator, _system_uA, _reg_id) \
317	PM8XXX_VREG_INIT(_id, _name, _min_uV, _max_uV, REGULATOR_MODE_NORMAL, \
318		REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_STATUS \
319		| REGULATOR_CHANGE_MODE, 0, _pull_down, _always_on, \
320		_supply_regulator, _system_uA, _enable_time, _reg_id)
321
322#define PM8XXX_VS(_id, _name, _always_on, _pull_down, _enable_time, \
323		_supply_regulator, _reg_id) \
324	PM8XXX_VREG_INIT(_id, _name, 0, 0, 0, REGULATOR_CHANGE_STATUS, 0, \
325		_pull_down, _always_on, _supply_regulator, 0, _enable_time, \
326		_reg_id)
327
328#define PM8XXX_VS300(_id, _name, _always_on, _pull_down, _enable_time, \
329		_supply_regulator, _reg_id) \
330	PM8XXX_VREG_INIT(_id, _name, 0, 0, 0, REGULATOR_CHANGE_STATUS, 0, \
331		_pull_down, _always_on, _supply_regulator, 0, _enable_time, \
332		_reg_id)
333
334#define PM8XXX_NCP(_id, _name, _always_on, _min_uV, _max_uV, _enable_time, \
335		_supply_regulator, _reg_id) \
336	PM8XXX_VREG_INIT(_id, _name, _min_uV, _max_uV, 0, \
337		REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_STATUS, 0, 0, \
338		_always_on, _supply_regulator, 0, _enable_time, _reg_id)
339
340/* Pin control initialization */
341#define PM8XXX_PC(_id, _name, _always_on, _pin_fn, _pin_ctrl, \
342		  _supply_regulator, _reg_id) \
343	{ \
344		.init_data = { \
345			.constraints = { \
346				.valid_ops_mask	= REGULATOR_CHANGE_STATUS, \
347				.always_on	= _always_on, \
348				.name		= _name, \
349			}, \
350			.num_consumer_supplies	= \
351					ARRAY_SIZE(vreg_consumers_##_id##_PC), \
352			.consumer_supplies	= vreg_consumers_##_id##_PC, \
353			.supply_regulator  = _supply_regulator, \
354		}, \
355		.id		= _reg_id, \
356		.pin_fn		= PM8XXX_VREG_PIN_FN_##_pin_fn, \
357		.pin_ctrl	= _pin_ctrl, \
358	}
359
360#define GPIO_VREG(_id, _reg_name, _gpio_label, _gpio, _supply_regulator) \
361	[GPIO_VREG_ID_##_id] = { \
362		.init_data = { \
363			.constraints = { \
364				.valid_ops_mask	= REGULATOR_CHANGE_STATUS, \
365			}, \
366			.num_consumer_supplies	= \
367					ARRAY_SIZE(vreg_consumers_##_id), \
368			.consumer_supplies	= vreg_consumers_##_id, \
369			.supply_regulator	= _supply_regulator, \
370		}, \
371		.regulator_name = _reg_name, \
372		.gpio_label	= _gpio_label, \
373		.gpio		= _gpio, \
374	}
375
376#define SAW_VREG_INIT(_id, _name, _min_uV, _max_uV) \
377	{ \
378		.constraints = { \
379			.name		= _name, \
380			.valid_ops_mask	= REGULATOR_CHANGE_VOLTAGE, \
381			.min_uV		= _min_uV, \
382			.max_uV		= _max_uV, \
383		}, \
384		.num_consumer_supplies	= ARRAY_SIZE(vreg_consumers_##_id), \
385		.consumer_supplies	= vreg_consumers_##_id, \
386	}
387
388#define RPM_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, _default_uV, \
389		 _peak_uA, _avg_uA, _pull_down, _pin_ctrl, _freq, _pin_fn, \
390		 _force_mode, _sleep_set_force_mode, _power_mode, _state, \
391		 _sleep_selectable, _always_on, _supply_regulator, _system_uA) \
392	{ \
393		.init_data = { \
394			.constraints = { \
395				.valid_modes_mask	= _modes, \
396				.valid_ops_mask		= _ops, \
397				.min_uV			= _min_uV, \
398				.max_uV			= _max_uV, \
399				.input_uV		= _min_uV, \
400				.apply_uV		= _apply_uV, \
401				.always_on		= _always_on, \
402			}, \
403			.num_consumer_supplies	= \
404					ARRAY_SIZE(vreg_consumers_##_id), \
405			.consumer_supplies	= vreg_consumers_##_id, \
406			.supply_regulator	= _supply_regulator, \
407		}, \
408		.id			= RPM_VREG_ID_PM8921_##_id, \
409		.default_uV		= _default_uV, \
410		.peak_uA		= _peak_uA, \
411		.avg_uA			= _avg_uA, \
412		.pull_down_enable	= _pull_down, \
413		.pin_ctrl		= _pin_ctrl, \
414		.freq			= RPM_VREG_FREQ_##_freq, \
415		.pin_fn			= _pin_fn, \
416		.force_mode		= _force_mode, \
417		.sleep_set_force_mode	= _sleep_set_force_mode, \
418		.power_mode		= _power_mode, \
419		.state			= _state, \
420		.sleep_selectable	= _sleep_selectable, \
421		.system_uA		= _system_uA, \
422	}
423
424#define RPM_LDO(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
425		_supply_regulator, _system_uA, _init_peak_uA) \
426	RPM_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_NORMAL \
427		 | REGULATOR_MODE_IDLE, REGULATOR_CHANGE_VOLTAGE \
428		 | REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE \
429		 | REGULATOR_CHANGE_DRMS, 0, _max_uV, _init_peak_uA, 0, _pd, \
430		 RPM_VREG_PIN_CTRL_NONE, NONE, RPM_VREG_PIN_FN_8960_NONE, \
431		 RPM_VREG_FORCE_MODE_8960_NONE, \
432		 RPM_VREG_FORCE_MODE_8960_NONE, RPM_VREG_POWER_MODE_8960_PWM, \
433		 RPM_VREG_STATE_OFF, _sleep_selectable, _always_on, \
434		 _supply_regulator, _system_uA)
435
436#define RPM_SMPS(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
437		 _supply_regulator, _system_uA, _freq, _force_mode, \
438		 _sleep_set_force_mode) \
439	RPM_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_NORMAL \
440		 | REGULATOR_MODE_IDLE, REGULATOR_CHANGE_VOLTAGE \
441		 | REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE \
442		 | REGULATOR_CHANGE_DRMS, 0, _max_uV, _system_uA, 0, _pd, \
443		 RPM_VREG_PIN_CTRL_NONE, _freq, RPM_VREG_PIN_FN_8960_NONE, \
444		 RPM_VREG_FORCE_MODE_8960_##_force_mode, \
445		 RPM_VREG_FORCE_MODE_8960_##_sleep_set_force_mode, \
446		 RPM_VREG_POWER_MODE_8960_PWM, RPM_VREG_STATE_OFF, \
447		 _sleep_selectable, _always_on, _supply_regulator, _system_uA)
448
449#define RPM_VS(_id, _always_on, _pd, _sleep_selectable, _supply_regulator) \
450	RPM_INIT(_id, 0, 0, 0, REGULATOR_CHANGE_STATUS, 0, 0, 1000, 1000, _pd, \
451		 RPM_VREG_PIN_CTRL_NONE, NONE, RPM_VREG_PIN_FN_8960_NONE, \
452		 RPM_VREG_FORCE_MODE_8960_NONE, \
453		 RPM_VREG_FORCE_MODE_8960_NONE, RPM_VREG_POWER_MODE_8960_PWM, \
454		 RPM_VREG_STATE_OFF, _sleep_selectable, _always_on, \
455		 _supply_regulator, 0)
456
457#define RPM_NCP(_id, _always_on, _sleep_selectable, _min_uV, _max_uV, \
458		_supply_regulator, _freq) \
459	RPM_INIT(_id, _min_uV, _max_uV, 0, REGULATOR_CHANGE_VOLTAGE \
460		 | REGULATOR_CHANGE_STATUS, 0, _max_uV, 1000, 1000, 0, \
461		 RPM_VREG_PIN_CTRL_NONE, _freq, RPM_VREG_PIN_FN_8960_NONE, \
462		 RPM_VREG_FORCE_MODE_8960_NONE, \
463		 RPM_VREG_FORCE_MODE_8960_NONE, RPM_VREG_POWER_MODE_8960_PWM, \
464		 RPM_VREG_STATE_OFF, _sleep_selectable, _always_on, \
465		 _supply_regulator, 0)
466
467/* Pin control initialization */
468#define RPM_PC_INIT(_id, _always_on, _pin_fn, _pin_ctrl, _supply_regulator) \
469	{ \
470		.init_data = { \
471			.constraints = { \
472				.valid_ops_mask	= REGULATOR_CHANGE_STATUS, \
473				.always_on	= _always_on, \
474			}, \
475			.num_consumer_supplies	= \
476					ARRAY_SIZE(vreg_consumers_##_id##_PC), \
477			.consumer_supplies	= vreg_consumers_##_id##_PC, \
478			.supply_regulator	= _supply_regulator, \
479		}, \
480		.id	  = RPM_VREG_ID_PM8921_##_id##_PC, \
481		.pin_fn	  = RPM_VREG_PIN_FN_8960_##_pin_fn, \
482		.pin_ctrl = _pin_ctrl, \
483	}
484
485/* GPIO regulator constraints */
486struct gpio_regulator_platform_data msm_gpio_regulator_pdata[] __devinitdata = {
487	/*        ID      vreg_name gpio_label   gpio                  supply */
488	GPIO_VREG(EXT_5V, "ext_5v", "ext_5v_en", PM8921_MPP_PM_TO_SYS(7), NULL),
489	GPIO_VREG(EXT_L2, "ext_l2", "ext_l2_en", 91, NULL),
490	GPIO_VREG(EXT_3P3V, "ext_3p3v", "ext_3p3v_en",
491		PM8921_GPIO_PM_TO_SYS(17), NULL),
492	GPIO_VREG(EXT_OTG_SW, "ext_otg_sw", "ext_otg_sw_en",
493		PM8921_GPIO_PM_TO_SYS(42), "8921_usb_otg"),
494};
495
496/* SAW regulator constraints */
497struct regulator_init_data msm_saw_regulator_pdata_s5 =
498	/*	      ID  vreg_name	       min_uV   max_uV */
499	SAW_VREG_INIT(S5, "8921_s5",	       850000, 1300000);
500struct regulator_init_data msm_saw_regulator_pdata_s6 =
501	SAW_VREG_INIT(S6, "8921_s6",	       850000, 1300000);
502
503/* PM8921 regulator constraints */
504struct pm8xxx_regulator_platform_data
505msm_pm8921_regulator_pdata[] __devinitdata = {
506	/*
507	 *		ID   name always_on pd min_uV   max_uV   en_t supply
508	 *	system_uA reg_ID
509	 */
510	PM8XXX_NLDO1200(L26, "8921_l26", 0, 1, 375000, 1050000, 200, "8921_s7",
511		0, 1),
512	PM8XXX_NLDO1200(L27, "8921_l27", 0, 1, 375000, 1050000, 200, "8921_s7",
513		0, 2),
514	PM8XXX_NLDO1200(L28, "8921_l28", 0, 1, 375000, 1050000, 200, "8921_s7",
515		0, 3),
516	PM8XXX_LDO(L29,      "8921_l29", 0, 1, 2050000, 2100000, 200, "8921_s8",
517		0, 4),
518
519	/*	     ID        name      always_on pd en_t supply    reg_ID */
520	PM8XXX_VS300(USB_OTG,  "8921_usb_otg",  0, 1, 0,   "ext_5v", 5),
521	PM8XXX_VS300(HDMI_MVS, "8921_hdmi_mvs", 0, 1, 0,   "ext_5v", 6),
522};
523
524static struct rpm_regulator_init_data
525msm_rpm_regulator_init_data[] __devinitdata = {
526	/*	ID a_on pd ss min_uV   max_uV  supply sys_uA  freq  fm  ss_fm */
527	RPM_SMPS(S1, 1, 1, 0, 1225000, 1225000, NULL, 100000, 3p20, NONE, NONE),
528	RPM_SMPS(S2, 0, 1, 0, 1300000, 1300000, NULL,      0, 1p60, NONE, NONE),
529	RPM_SMPS(S3, 0, 1, 1,  500000, 1150000, NULL, 100000, 4p80, NONE, NONE),
530	RPM_SMPS(S4, 1, 1, 0, 1800000, 1800000, NULL, 100000, 1p60, AUTO, AUTO),
531	RPM_SMPS(S7, 0, 1, 0, 1150000, 1150000, NULL, 100000, 3p20, NONE, NONE),
532	RPM_SMPS(S8, 1, 1, 1, 2050000, 2050000, NULL, 100000, 1p60, NONE, NONE),
533
534	/*	ID     a_on pd ss min_uV   max_uV  supply  sys_uA init_ip */
535	RPM_LDO(L1,	 1, 1, 0, 1050000, 1050000, "8921_s4", 0, 10000),
536	RPM_LDO(L2,	 0, 1, 0, 1200000, 1200000, "8921_s4", 0, 0),
537	RPM_LDO(L3,	 0, 1, 0, 3075000, 3075000, NULL,      0, 0),
538	RPM_LDO(L4,	 1, 1, 0, 1800000, 1800000, NULL,      10000, 10000),
539	RPM_LDO(L5,	 0, 1, 0, 2950000, 2950000, NULL,      0, 0),
540	RPM_LDO(L6,	 0, 1, 0, 2950000, 2950000, NULL,      0, 0),
541	RPM_LDO(L7,	 1, 1, 0, 1850000, 2950000, NULL,      10000, 10000),
542	RPM_LDO(L8,	 0, 1, 0, 2800000, 3000000, NULL,      0, 0),
543	RPM_LDO(L9,	 0, 1, 0, 3000000, 3000000, NULL,      0, 0),
544	RPM_LDO(L10,	 0, 1, 0, 3000000, 3000000, NULL,      0, 0),
545	RPM_LDO(L11,	 0, 1, 0, 2850000, 2850000, NULL,      0, 0),
546	RPM_LDO(L12,	 0, 1, 0, 1200000, 1200000, "8921_s4", 0, 0),
547	RPM_LDO(L14,	 0, 1, 0, 1800000, 1800000, NULL,      0, 0),
548	RPM_LDO(L15,	 0, 1, 0, 1800000, 2950000, NULL,      0, 0),
549	RPM_LDO(L16,	 0, 1, 0, 2800000, 2800000, NULL,      0, 0),
550	RPM_LDO(L17,	 0, 1, 0, 1800000, 2950000, NULL,      0, 0),
551	RPM_LDO(L18,	 0, 1, 0, 1300000, 1300000, "8921_s4", 0, 0),
552	RPM_LDO(L21,	 0, 1, 0, 1900000, 1900000, "8921_s8", 0, 0),
553	RPM_LDO(L22,	 0, 1, 0, 2750000, 2750000, NULL,      0, 0),
554	RPM_LDO(L23,	 1, 1, 1, 1800000, 1800000, "8921_s8", 10000, 10000),
555	RPM_LDO(L24,	 0, 1, 1,  750000, 1150000, "8921_s1", 10000, 10000),
556	RPM_LDO(L25,	 1, 1, 0, 1250000, 1250000, "8921_s1", 10000, 10000),
557
558	/*	ID     a_on pd ss		    supply */
559	RPM_VS(LVS1,	 0, 1, 0,		    "8921_s4"),
560	RPM_VS(LVS2,	 0, 1, 0,		    "8921_s1"),
561	RPM_VS(LVS3,	 0, 1, 0,		    "8921_s4"),
562	RPM_VS(LVS4,	 0, 1, 0,		    "8921_s4"),
563	RPM_VS(LVS5,	 0, 1, 0,		    "8921_s4"),
564	RPM_VS(LVS6,	 0, 1, 0,		    "8921_s4"),
565	RPM_VS(LVS7,	 0, 1, 0,		    "8921_s4"),
566
567	/*	 ID      a_on  ss min_uV   max_uV   supply        freq */
568	RPM_NCP(NCP,	 0,    0, 1800000, 1800000, "8921_l6",    1p60),
569};
570
571int msm_pm8921_regulator_pdata_len __devinitdata =
572	ARRAY_SIZE(msm_pm8921_regulator_pdata);
573
574#define RPM_REG_MAP(_id, _sleep_also, _voter, _supply, _dev_name) \
575	{ \
576		.vreg_id = RPM_VREG_ID_PM8921_##_id, \
577		.sleep_also = _sleep_also, \
578		.voter = _voter, \
579		.supply = _supply, \
580		.dev_name = _dev_name, \
581	}
582static struct rpm_regulator_consumer_mapping
583	      msm_rpm_regulator_consumer_mapping[] __devinitdata = {
584	RPM_REG_MAP(L23, 0, 1, "krait0_l23", "acpuclk-8960"),
585	RPM_REG_MAP(L23, 0, 2, "krait1_l23", "acpuclk-8960"),
586	RPM_REG_MAP(L23, 0, 6, "l2_l23",     "acpuclk-8960"),
587	RPM_REG_MAP(L24, 0, 1, "krait0_mem", "acpuclk-8960"),
588	RPM_REG_MAP(L24, 0, 2, "krait1_mem", "acpuclk-8960"),
589	RPM_REG_MAP(S3,  0, 1, "krait0_dig", "acpuclk-8960"),
590	RPM_REG_MAP(S3,  0, 2, "krait1_dig", "acpuclk-8960"),
591	RPM_REG_MAP(S8,  0, 1, "krait0_s8",  "acpuclk-8960"),
592	RPM_REG_MAP(S8,  0, 2, "krait1_s8",  "acpuclk-8960"),
593	RPM_REG_MAP(S8,  0, 6, "l2_s8",      "acpuclk-8960"),
594
595	RPM_REG_MAP(L23, 0, 1, "krait0_l23", "acpuclk-8960ab"),
596	RPM_REG_MAP(L23, 0, 2, "krait1_l23", "acpuclk-8960ab"),
597	RPM_REG_MAP(L23, 0, 6, "l2_l23",     "acpuclk-8960ab"),
598	RPM_REG_MAP(L24, 0, 1, "krait0_mem", "acpuclk-8960ab"),
599	RPM_REG_MAP(L24, 0, 2, "krait1_mem", "acpuclk-8960ab"),
600	RPM_REG_MAP(S3,  0, 1, "krait0_dig", "acpuclk-8960ab"),
601	RPM_REG_MAP(S3,  0, 2, "krait1_dig", "acpuclk-8960ab"),
602	RPM_REG_MAP(S8,  0, 1, "krait0_s8",  "acpuclk-8960ab"),
603	RPM_REG_MAP(S8,  0, 2, "krait1_s8",  "acpuclk-8960ab"),
604	RPM_REG_MAP(S8,  0, 6, "l2_s8",      "acpuclk-8960ab"),
605};
606
607struct rpm_regulator_platform_data msm_rpm_regulator_pdata __devinitdata = {
608	.init_data		= msm_rpm_regulator_init_data,
609	.num_regulators		= ARRAY_SIZE(msm_rpm_regulator_init_data),
610	.version		= RPM_VREG_VERSION_8960,
611	.vreg_id_vdd_mem	= RPM_VREG_ID_PM8921_L24,
612	.vreg_id_vdd_dig	= RPM_VREG_ID_PM8921_S3,
613	.consumer_map		= msm_rpm_regulator_consumer_mapping,
614	.consumer_map_len = ARRAY_SIZE(msm_rpm_regulator_consumer_mapping),
615};
616
617/*
618 * Fix up regulator consumer data that moves to a different regulator based on
619 * the current target.
620 */
621void __init configure_msm8960_power_grid(void)
622{
623	static struct rpm_regulator_init_data *rpm_data;
624	int i;
625
626	if (machine_is_msm8960_cdp()) {
627		/* Only modify LVS6 consumers for CDP targets. */
628		for (i = 0; i < ARRAY_SIZE(msm_rpm_regulator_init_data); i++) {
629			rpm_data = &msm_rpm_regulator_init_data[i];
630			if (rpm_data->id == RPM_VREG_ID_PM8921_LVS6) {
631				rpm_data->init_data.consumer_supplies
632					= vreg_consumers_CDP_LVS6;
633				rpm_data->init_data.num_consumer_supplies
634					= ARRAY_SIZE(vreg_consumers_CDP_LVS6);
635			}
636		}
637	}
638}