aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-tegra/board-cardhu-pm299-power-rails.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-tegra/board-cardhu-pm299-power-rails.c')
-rw-r--r--arch/arm/mach-tegra/board-cardhu-pm299-power-rails.c791
1 files changed, 791 insertions, 0 deletions
diff --git a/arch/arm/mach-tegra/board-cardhu-pm299-power-rails.c b/arch/arm/mach-tegra/board-cardhu-pm299-power-rails.c
new file mode 100644
index 00000000000..798904c1809
--- /dev/null
+++ b/arch/arm/mach-tegra/board-cardhu-pm299-power-rails.c
@@ -0,0 +1,791 @@
1/*
2 * arch/arm/mach-tegra/board-cardhu-pm299-power-rails.c
3 *
4 * Copyright (C) 2011 NVIDIA, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 * 02111-1307, USA
19 */
20#include <linux/i2c.h>
21#include <linux/pda_power.h>
22#include <linux/platform_device.h>
23#include <linux/resource.h>
24#include <linux/regulator/machine.h>
25#include <linux/mfd/ricoh583.h>
26#include <linux/gpio.h>
27#include <linux/io.h>
28#include <linux/regulator/gpio-switch-regulator.h>
29#include <linux/regulator/fixed.h>
30#include <linux/regulator/ricoh583-regulator.h>
31#include <linux/regulator/tps62360.h>
32
33#include <mach/iomap.h>
34#include <mach/irqs.h>
35#include <mach/pinmux.h>
36#include <mach/edp.h>
37
38#include "gpio-names.h"
39#include "board.h"
40#include "board-cardhu.h"
41#include "wakeups-t3.h"
42
43#define PMC_CTRL 0x0
44#define PMC_CTRL_INTR_LOW (1 << 17)
45
46static struct regulator_consumer_supply ricoh583_dc1_supply_skubit0_0[] = {
47 REGULATOR_SUPPLY("vdd_core", NULL),
48 REGULATOR_SUPPLY("en_vddio_ddr_1v2", NULL),
49};
50
51static struct regulator_consumer_supply ricoh583_dc1_supply_skubit0_1[] = {
52 REGULATOR_SUPPLY("en_vddio_ddr_1v2", NULL),
53};
54
55static struct regulator_consumer_supply ricoh583_dc3_supply_0[] = {
56 REGULATOR_SUPPLY("vdd_gen1v5", NULL),
57 REGULATOR_SUPPLY("vcore_lcd", NULL),
58 REGULATOR_SUPPLY("track_ldo1", NULL),
59 REGULATOR_SUPPLY("external_ldo_1v2", NULL),
60 REGULATOR_SUPPLY("vcore_cam1", NULL),
61 REGULATOR_SUPPLY("vcore_cam2", NULL),
62};
63
64static struct regulator_consumer_supply ricoh583_dc0_supply_0[] = {
65 REGULATOR_SUPPLY("vdd_cpu_pmu", NULL),
66 REGULATOR_SUPPLY("vdd_cpu", NULL),
67 REGULATOR_SUPPLY("vdd_sys", NULL),
68};
69
70static struct regulator_consumer_supply ricoh583_dc2_supply_0[] = {
71 REGULATOR_SUPPLY("vdd_gen1v8", NULL),
72 REGULATOR_SUPPLY("avdd_hdmi_pll", NULL),
73 REGULATOR_SUPPLY("avdd_usb_pll", NULL),
74 REGULATOR_SUPPLY("avdd_osc", NULL),
75 REGULATOR_SUPPLY("vddio_sys", NULL),
76 REGULATOR_SUPPLY("vddio_sdmmc", "sdhci-tegra.3"),
77 REGULATOR_SUPPLY("pwrdet_sdmmc4", NULL),
78 REGULATOR_SUPPLY("vdd1v8_satelite", NULL),
79 REGULATOR_SUPPLY("vddio_uart", NULL),
80 REGULATOR_SUPPLY("pwrdet_uart", NULL),
81 REGULATOR_SUPPLY("vddio_audio", NULL),
82 REGULATOR_SUPPLY("pwrdet_audio", NULL),
83 REGULATOR_SUPPLY("vddio_bb", NULL),
84 REGULATOR_SUPPLY("pwrdet_bb", NULL),
85 REGULATOR_SUPPLY("vddio_lcd_pmu", NULL),
86 REGULATOR_SUPPLY("pwrdet_lcd", NULL),
87 REGULATOR_SUPPLY("vddio_cam", NULL),
88 REGULATOR_SUPPLY("pwrdet_cam", NULL),
89 REGULATOR_SUPPLY("vddio_vi", NULL),
90 REGULATOR_SUPPLY("pwrdet_vi", NULL),
91 REGULATOR_SUPPLY("ldo6", NULL),
92 REGULATOR_SUPPLY("ldo7", NULL),
93 REGULATOR_SUPPLY("ldo8", NULL),
94 REGULATOR_SUPPLY("vcore_audio", NULL),
95 REGULATOR_SUPPLY("avcore_audio", NULL),
96 REGULATOR_SUPPLY("vddio_sdmmc", "sdhci-tegra.2"),
97 REGULATOR_SUPPLY("pwrdet_sdmmc3", NULL),
98 REGULATOR_SUPPLY("vcore1_lpddr2", NULL),
99 REGULATOR_SUPPLY("vcom_1v8", NULL),
100 REGULATOR_SUPPLY("pmuio_1v8", NULL),
101 REGULATOR_SUPPLY("avdd_ic_usb", NULL),
102};
103
104static struct regulator_consumer_supply ricoh583_ldo0_supply_0[] = {
105 REGULATOR_SUPPLY("unused_ldo0", NULL),
106};
107
108static struct regulator_consumer_supply ricoh583_ldo1_supply_0[] = {
109 REGULATOR_SUPPLY("avdd_pexb", NULL),
110 REGULATOR_SUPPLY("vdd_pexb", NULL),
111 REGULATOR_SUPPLY("avdd_pex_pll", NULL),
112 REGULATOR_SUPPLY("avdd_pexa", NULL),
113 REGULATOR_SUPPLY("vdd_pexa", NULL),
114};
115
116static struct regulator_consumer_supply ricoh583_ldo2_supply_0[] = {
117 REGULATOR_SUPPLY("avdd_sata", NULL),
118 REGULATOR_SUPPLY("vdd_sata", NULL),
119 REGULATOR_SUPPLY("avdd_sata_pll", NULL),
120 REGULATOR_SUPPLY("avdd_plle", NULL),
121};
122
123static struct regulator_consumer_supply ricoh583_ldo3_supply_0[] = {
124 REGULATOR_SUPPLY("vddio_sdmmc", "sdhci-tegra.0"),
125 REGULATOR_SUPPLY("pwrdet_sdmmc1", NULL),
126};
127
128static struct regulator_consumer_supply ricoh583_ldo4_supply_0[] = {
129 REGULATOR_SUPPLY("vdd_rtc", NULL),
130};
131
132static struct regulator_consumer_supply ricoh583_ldo5_supply_0[] = {
133 REGULATOR_SUPPLY("avdd_vdac", NULL),
134};
135
136static struct regulator_consumer_supply ricoh583_ldo6_supply_0[] = {
137 REGULATOR_SUPPLY("avdd_dsi_csi", NULL),
138 REGULATOR_SUPPLY("pwrdet_mipi", NULL),
139};
140static struct regulator_consumer_supply ricoh583_ldo7_supply_0[] = {
141 REGULATOR_SUPPLY("avdd_plla_p_c_s", NULL),
142 REGULATOR_SUPPLY("avdd_pllm", NULL),
143 REGULATOR_SUPPLY("avdd_pllu_d", NULL),
144 REGULATOR_SUPPLY("avdd_pllu_d2", NULL),
145 REGULATOR_SUPPLY("avdd_pllx", NULL),
146};
147
148static struct regulator_consumer_supply ricoh583_ldo8_supply_0[] = {
149 REGULATOR_SUPPLY("vdd_ddr_hs", NULL),
150};
151
152#define RICOH_PDATA_INIT(_name, _sname, _minmv, _maxmv, _supply_reg, _always_on, \
153 _boot_on, _apply_uv, _init_uV, _init_enable, _init_apply, _flags, \
154 _ext_contol, _ds_slots) \
155 static struct ricoh583_regulator_platform_data pdata_##_name##_##_sname = \
156 { \
157 .regulator = { \
158 .constraints = { \
159 .min_uV = (_minmv)*1000, \
160 .max_uV = (_maxmv)*1000, \
161 .valid_modes_mask = (REGULATOR_MODE_NORMAL | \
162 REGULATOR_MODE_STANDBY), \
163 .valid_ops_mask = (REGULATOR_CHANGE_MODE | \
164 REGULATOR_CHANGE_STATUS | \
165 REGULATOR_CHANGE_VOLTAGE), \
166 .always_on = _always_on, \
167 .boot_on = _boot_on, \
168 .apply_uV = _apply_uv, \
169 }, \
170 .num_consumer_supplies = \
171 ARRAY_SIZE(ricoh583_##_name##_supply_##_sname), \
172 .consumer_supplies = ricoh583_##_name##_supply_##_sname, \
173 .supply_regulator = _supply_reg, \
174 }, \
175 .init_uV = _init_uV * 1000, \
176 .init_enable = _init_enable, \
177 .init_apply = _init_apply, \
178 .deepsleep_slots = _ds_slots, \
179 .flags = _flags, \
180 .ext_pwr_req = _ext_contol, \
181 }
182
183RICOH_PDATA_INIT(dc0, 0, 700, 1500, 0, 1, 1, 0, -1, 0, 0, 0,
184 RICOH583_EXT_PWRREQ2_CONTROL, 0);
185RICOH_PDATA_INIT(dc1, skubit0_0, 700, 1500, 0, 1, 1, 0, -1, 0, 0, 0, 0, 0);
186RICOH_PDATA_INIT(dc2, 0, 900, 2400, 0, 1, 1, 0, -1, 0, 0, 0, 0, 0);
187RICOH_PDATA_INIT(dc3, 0, 900, 2400, 0, 1, 1, 0, -1, 0, 0, 0, 0, 0);
188
189RICOH_PDATA_INIT(ldo0, 0, 1000, 3300, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0);
190RICOH_PDATA_INIT(ldo1, 0, 1000, 3300, ricoh583_rails(DC1), 0, 0, 0, -1, 0, 0, 0, 0, 0);
191RICOH_PDATA_INIT(ldo2, 0, 1050, 1050, ricoh583_rails(DC1), 0, 0, 1, -1, 0, 0, 0, 0, 0);
192
193RICOH_PDATA_INIT(ldo3, 0, 1000, 3300, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0);
194RICOH_PDATA_INIT(ldo4, 0, 750, 1500, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0);
195RICOH_PDATA_INIT(ldo5, 0, 1000, 3300, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0);
196
197RICOH_PDATA_INIT(ldo6, 0, 1200, 1200, ricoh583_rails(DC2), 0, 0, 1, -1, 0, 0, 0, 0, 0);
198RICOH_PDATA_INIT(ldo7, 0, 1200, 1200, ricoh583_rails(DC2), 1, 1, 1, -1, 0, 0, 0, 0, 0);
199RICOH_PDATA_INIT(ldo8, 0, 900, 3400, ricoh583_rails(DC2), 1, 0, 0, -1, 0, 0, 0, 0, 0);
200
201static struct ricoh583_rtc_platform_data rtc_data = {
202 .irq = TEGRA_NR_IRQS + RICOH583_IRQ_YALE,
203 .time = {
204 .tm_year = 2011,
205 .tm_mon = 0,
206 .tm_mday = 1,
207 .tm_hour = 0,
208 .tm_min = 0,
209 .tm_sec = 0,
210 },
211};
212
213#define RICOH_RTC_REG() \
214{ \
215 .id = 0, \
216 .name = "rtc_ricoh583", \
217 .platform_data = &rtc_data, \
218}
219
220#define RICOH_REG(_id, _name, _sname) \
221{ \
222 .id = RICOH583_ID_##_id, \
223 .name = "ricoh583-regulator", \
224 .platform_data = &pdata_##_name##_##_sname, \
225}
226
227#define RICOH583_DEV_COMMON_E118X \
228 RICOH_REG(DC0, dc0, 0), \
229 RICOH_REG(DC1, dc1, skubit0_0), \
230 RICOH_REG(DC2, dc2, 0), \
231 RICOH_REG(DC3, dc3, 0), \
232 RICOH_REG(LDO0, ldo8, 0), \
233 RICOH_REG(LDO1, ldo7, 0), \
234 RICOH_REG(LDO2, ldo6, 0), \
235 RICOH_REG(LDO3, ldo5, 0), \
236 RICOH_REG(LDO4, ldo4, 0), \
237 RICOH_REG(LDO5, ldo3, 0), \
238 RICOH_REG(LDO6, ldo0, 0), \
239 RICOH_REG(LDO7, ldo1, 0), \
240 RICOH_REG(LDO8, ldo2, 0), \
241 RICOH_RTC_REG()
242
243static struct ricoh583_subdev_info ricoh_devs_e118x_dcdc[] = {
244 RICOH583_DEV_COMMON_E118X,
245};
246
247#define RICOH_GPIO_INIT(_init_apply, _pulldn, _output_mode, _output_val) \
248 { \
249 .pulldn_en = _pulldn, \
250 .output_mode_en = _output_mode, \
251 .output_val = _output_val, \
252 .init_apply = _init_apply, \
253 }
254struct ricoh583_gpio_init_data ricoh_gpio_data[] = {
255 RICOH_GPIO_INIT(false, false, false, 0),
256 RICOH_GPIO_INIT(false, false, false, 0),
257 RICOH_GPIO_INIT(false, false, false, 0),
258 RICOH_GPIO_INIT(true, false, true, 1),
259 RICOH_GPIO_INIT(true, false, true, 1),
260 RICOH_GPIO_INIT(false, false, false, 0),
261 RICOH_GPIO_INIT(false, false, false, 0),
262 RICOH_GPIO_INIT(false, false, false, 0),
263};
264
265static struct ricoh583_platform_data ricoh_platform = {
266 .irq_base = RICOH583_IRQ_BASE,
267 .gpio_base = RICOH583_GPIO_BASE,
268 .gpio_init_data = ricoh_gpio_data,
269 .num_gpioinit_data = ARRAY_SIZE(ricoh_gpio_data),
270 .enable_shutdown_pin = true,
271};
272
273static struct i2c_board_info __initdata ricoh583_regulators[] = {
274 {
275 I2C_BOARD_INFO("ricoh583", 0x34),
276 .irq = INT_EXTERNAL_PMU,
277 .platform_data = &ricoh_platform,
278 },
279};
280
281/* TPS62361B DC-DC converter */
282static struct regulator_consumer_supply tps62361_dcdc_supply[] = {
283 REGULATOR_SUPPLY("vdd_core", NULL),
284};
285
286static struct tps62360_regulator_platform_data tps62361_pdata = {
287 .reg_init_data = { \
288 .constraints = { \
289 .min_uV = 500000, \
290 .max_uV = 1770000, \
291 .valid_modes_mask = (REGULATOR_MODE_NORMAL | \
292 REGULATOR_MODE_STANDBY), \
293 .valid_ops_mask = (REGULATOR_CHANGE_MODE | \
294 REGULATOR_CHANGE_STATUS | \
295 REGULATOR_CHANGE_VOLTAGE), \
296 .always_on = 1, \
297 .boot_on = 1, \
298 .apply_uV = 0, \
299 }, \
300 .num_consumer_supplies = ARRAY_SIZE(tps62361_dcdc_supply), \
301 .consumer_supplies = tps62361_dcdc_supply, \
302 }, \
303 .en_discharge = true, \
304 .vsel0_gpio = -1, \
305 .vsel1_gpio = -1, \
306 .vsel0_def_state = 1, \
307 .vsel1_def_state = 1, \
308};
309
310static struct i2c_board_info __initdata tps62361_boardinfo[] = {
311 {
312 I2C_BOARD_INFO("tps62361", 0x60),
313 .platform_data = &tps62361_pdata,
314 },
315};
316
317int __init cardhu_pm299_regulator_init(void)
318{
319 struct board_info board_info;
320 struct board_info pmu_board_info;
321 void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE);
322 u32 pmc_ctrl;
323
324 /* configure the power management controller to trigger PMU
325 * interrupts when low */
326 pmc_ctrl = readl(pmc + PMC_CTRL);
327 writel(pmc_ctrl | PMC_CTRL_INTR_LOW, pmc + PMC_CTRL);
328
329 /* The regulator details have complete constraints */
330 tegra_get_board_info(&board_info);
331 tegra_get_pmu_board_info(&pmu_board_info);
332 if (pmu_board_info.board_id != BOARD_PMU_PM299) {
333 pr_err("%s(): Board ID is not proper\n", __func__);
334 return -ENODEV;
335 }
336
337 /* If TPS6236x DCDC is there then consumer for dc1 should
338 * not have vdd_core */
339 if ((board_info.sku & SKU_DCDC_TPS62361_SUPPORT) ||
340 (pmu_board_info.sku & SKU_DCDC_TPS62361_SUPPORT)) {
341 pdata_dc1_skubit0_0.regulator.consumer_supplies =
342 ricoh583_dc1_supply_skubit0_1;
343 pdata_dc1_skubit0_0.regulator.num_consumer_supplies =
344 ARRAY_SIZE(ricoh583_dc1_supply_skubit0_1);
345 }
346
347 ricoh_platform.num_subdevs = ARRAY_SIZE(ricoh_devs_e118x_dcdc);
348 ricoh_platform.subdevs = ricoh_devs_e118x_dcdc;
349
350 i2c_register_board_info(4, ricoh583_regulators, 1);
351
352 /* Register the TPS6236x for all boards whose sku bit 0 is set. */
353 if ((board_info.sku & SKU_DCDC_TPS62361_SUPPORT) ||
354 (pmu_board_info.sku & SKU_DCDC_TPS62361_SUPPORT)) {
355 pr_info("Registering the device TPS62361\n");
356 i2c_register_board_info(4, tps62361_boardinfo, 1);
357 }
358 return 0;
359}
360
361/* EN_5V_CP from PMU GP0 */
362static struct regulator_consumer_supply fixed_reg_en_5v_cp_supply[] = {
363 REGULATOR_SUPPLY("vdd_5v0_sby", NULL),
364 REGULATOR_SUPPLY("vdd_hall", NULL),
365 REGULATOR_SUPPLY("vterm_ddr", NULL),
366 REGULATOR_SUPPLY("v2ref_ddr", NULL),
367};
368
369/* EN_5V0 From PMU GP2 */
370static struct regulator_consumer_supply fixed_reg_en_5v0_supply[] = {
371 REGULATOR_SUPPLY("vdd_5v0_sys", NULL),
372};
373
374/* EN_DDR From PMU GP6 */
375static struct regulator_consumer_supply fixed_reg_en_ddr_supply[] = {
376 REGULATOR_SUPPLY("mem_vddio_ddr", NULL),
377 REGULATOR_SUPPLY("t30_vddio_ddr", NULL),
378};
379
380/* EN_3V3_SYS From PMU GP7 */
381static struct regulator_consumer_supply fixed_reg_en_3v3_sys_supply[] = {
382 REGULATOR_SUPPLY("vdd_lvds", NULL),
383 REGULATOR_SUPPLY("vdd_pnl", NULL),
384 REGULATOR_SUPPLY("vcom_3v3", NULL),
385 REGULATOR_SUPPLY("vdd_3v3", NULL),
386 REGULATOR_SUPPLY("vcore_mmc", NULL),
387 REGULATOR_SUPPLY("vddio_pex_ctl", NULL),
388 REGULATOR_SUPPLY("pwrdet_pex_ctl", NULL),
389 REGULATOR_SUPPLY("hvdd_pex_pmu", NULL),
390 REGULATOR_SUPPLY("avdd_hdmi", NULL),
391 REGULATOR_SUPPLY("vpp_fuse", NULL),
392 REGULATOR_SUPPLY("avdd_usb", NULL),
393 REGULATOR_SUPPLY("vdd_ddr_rx", NULL),
394 REGULATOR_SUPPLY("vcore_nand", NULL),
395 REGULATOR_SUPPLY("hvdd_sata", NULL),
396 REGULATOR_SUPPLY("vddio_gmi_pmu", NULL),
397 REGULATOR_SUPPLY("pwrdet_nand", NULL),
398 REGULATOR_SUPPLY("avdd_cam1", NULL),
399 REGULATOR_SUPPLY("vdd_af", NULL),
400 REGULATOR_SUPPLY("avdd_cam2", NULL),
401 REGULATOR_SUPPLY("vdd_acc", NULL),
402 REGULATOR_SUPPLY("vdd_phtl", NULL),
403 REGULATOR_SUPPLY("vddio_tp", NULL),
404 REGULATOR_SUPPLY("vdd_led", NULL),
405 REGULATOR_SUPPLY("vddio_cec", NULL),
406 REGULATOR_SUPPLY("vdd_cmps", NULL),
407 REGULATOR_SUPPLY("vdd_temp", NULL),
408 REGULATOR_SUPPLY("vpp_kfuse", NULL),
409 REGULATOR_SUPPLY("vddio_ts", NULL),
410 REGULATOR_SUPPLY("vdd_ir_led", NULL),
411 REGULATOR_SUPPLY("vddio_1wire", NULL),
412 REGULATOR_SUPPLY("avddio_audio", NULL),
413 REGULATOR_SUPPLY("vdd_ec", NULL),
414 REGULATOR_SUPPLY("vcom_pa", NULL),
415 REGULATOR_SUPPLY("vdd_3v3_devices", NULL),
416 REGULATOR_SUPPLY("vdd_3v3_dock", NULL),
417 REGULATOR_SUPPLY("vdd_3v3_edid", NULL),
418 REGULATOR_SUPPLY("vdd_3v3_hdmi_cec", NULL),
419 REGULATOR_SUPPLY("vdd_3v3_gmi", NULL),
420 REGULATOR_SUPPLY("vdd_3v3_spk_amp", NULL),
421 REGULATOR_SUPPLY("vdd_3v3_sensor", NULL),
422 REGULATOR_SUPPLY("vdd_3v3_cam", NULL),
423 REGULATOR_SUPPLY("vdd_3v3_als", NULL),
424 REGULATOR_SUPPLY("debug_cons", NULL),
425};
426
427/* DIS_5V_SWITCH from AP SPI2_SCK X02 */
428static struct regulator_consumer_supply fixed_reg_dis_5v_switch_supply[] = {
429 REGULATOR_SUPPLY("master_5v_switch", NULL),
430};
431
432/* EN_VDD_BL */
433static struct regulator_consumer_supply fixed_reg_en_vdd_bl_supply[] = {
434 REGULATOR_SUPPLY("vdd_backlight", NULL),
435 REGULATOR_SUPPLY("vdd_backlight1", NULL),
436};
437
438/* EN_3V3_MODEM from AP GPIO VI_VSYNCH D06*/
439static struct regulator_consumer_supply fixed_reg_en_3v3_modem_supply[] = {
440 REGULATOR_SUPPLY("vdd_3v3_mini_card", NULL),
441 REGULATOR_SUPPLY("vdd_mini_card", NULL),
442};
443
444/* EN_VDD_PNL1 from AP GPIO VI_D6 L04*/
445static struct regulator_consumer_supply fixed_reg_en_vdd_pnl1_supply[] = {
446 REGULATOR_SUPPLY("vdd_lcd_panel", NULL),
447};
448
449/* CAM1_LDO_EN from AP GPIO KB_ROW6 R06*/
450static struct regulator_consumer_supply fixed_reg_cam1_ldo_en_supply[] = {
451 REGULATOR_SUPPLY("vdd_2v8_cam1", NULL),
452 REGULATOR_SUPPLY("vdd", "6-0072"),
453};
454
455/* CAM2_LDO_EN from AP GPIO KB_ROW7 R07*/
456static struct regulator_consumer_supply fixed_reg_cam2_ldo_en_supply[] = {
457 REGULATOR_SUPPLY("vdd_2v8_cam2", NULL),
458 REGULATOR_SUPPLY("vdd", "7-0072"),
459};
460
461/* CAM3_LDO_EN from AP GPIO KB_ROW8 S00*/
462static struct regulator_consumer_supply fixed_reg_cam3_ldo_en_supply[] = {
463 REGULATOR_SUPPLY("vdd_cam3", NULL),
464};
465
466/* EN_VDD_COM from AP GPIO SDMMC3_DAT5 D00*/
467static struct regulator_consumer_supply fixed_reg_en_vdd_com_supply[] = {
468 REGULATOR_SUPPLY("vdd_com_bd", NULL),
469};
470
471/* EN_VDD_SDMMC1 from AP GPIO VI_HSYNC D07*/
472static struct regulator_consumer_supply fixed_reg_en_vdd_sdmmc1_supply[] = {
473 REGULATOR_SUPPLY("vddio_sd_slot", "sdhci-tegra.0"),
474};
475
476/* EN_3V3_EMMC from AP GPIO SDMMC3_DAT4 D01*/
477static struct regulator_consumer_supply fixed_reg_en_3v3_emmc_supply[] = {
478 REGULATOR_SUPPLY("vdd_emmc_core", NULL),
479};
480
481/* EN_3V3_PEX_HVDD from AP GPIO VI_D09 L07*/
482static struct regulator_consumer_supply fixed_reg_en_3v3_pex_hvdd_supply[] = {
483 REGULATOR_SUPPLY("hvdd_pex", NULL),
484};
485
486/* EN_3v3_FUSE from AP GPIO VI_D08 L06*/
487static struct regulator_consumer_supply fixed_reg_en_3v3_fuse_supply[] = {
488 REGULATOR_SUPPLY("vdd_fuse", NULL),
489};
490
491/* EN_1V8_CAM from AP GPIO GPIO_PBB4 PBB04*/
492static struct regulator_consumer_supply fixed_reg_en_1v8_cam_supply[] = {
493 REGULATOR_SUPPLY("vdd_1v8_cam1", NULL),
494 REGULATOR_SUPPLY("vdd_1v8_cam2", NULL),
495 REGULATOR_SUPPLY("vdd_1v8_cam3", NULL),
496 REGULATOR_SUPPLY("vdd_i2c", "6-0072"),
497 REGULATOR_SUPPLY("vdd_i2c", "7-0072"),
498 REGULATOR_SUPPLY("vdd_i2c", "2-0033"),
499};
500
501static struct regulator_consumer_supply fixed_reg_en_vbrtr_supply[] = {
502 REGULATOR_SUPPLY("vdd_vbrtr", NULL),
503};
504
505
506/* EN_USB1_VBUS_OC*/
507static struct regulator_consumer_supply gpio_switch_en_usb1_vbus_oc_supply[] = {
508 REGULATOR_SUPPLY("vdd_vbus_micro_usb", NULL),
509};
510static int gpio_switch_en_usb1_vbus_oc_voltages[] = { 5000};
511
512/*EN_USB3_VBUS_OC*/
513static struct regulator_consumer_supply gpio_switch_en_usb3_vbus_oc_supply[] = {
514 REGULATOR_SUPPLY("vdd_vbus_typea_usb", NULL),
515};
516static int gpio_switch_en_usb3_vbus_oc_voltages[] = { 5000};
517
518/* EN_VDDIO_VID_OC from AP GPIO VI_PCLK T00*/
519static struct regulator_consumer_supply gpio_switch_en_vddio_vid_oc_supply[] = {
520 REGULATOR_SUPPLY("vdd_hdmi_con", NULL),
521};
522static int gpio_switch_en_vddio_vid_oc_voltages[] = { 5000};
523
524static int enable_load_switch_rail(
525 struct gpio_switch_regulator_subdev_data *psubdev_data)
526{
527 int ret;
528
529 if (psubdev_data->pin_group <= 0)
530 return -EINVAL;
531
532 /* Tristate and make pin as input*/
533 ret = tegra_pinmux_set_tristate(psubdev_data->pin_group,
534 TEGRA_TRI_TRISTATE);
535 if (ret < 0)
536 return ret;
537 return gpio_direction_input(psubdev_data->gpio_nr);
538}
539
540static int disable_load_switch_rail(
541 struct gpio_switch_regulator_subdev_data *psubdev_data)
542{
543 int ret;
544
545 if (psubdev_data->pin_group <= 0)
546 return -EINVAL;
547
548 /* Un-tristate and driver low */
549 ret = tegra_pinmux_set_tristate(psubdev_data->pin_group,
550 TEGRA_TRI_NORMAL);
551 if (ret < 0)
552 return ret;
553 return gpio_direction_output(psubdev_data->gpio_nr, 0);
554}
555
556/* Macro for defining gpio switch regulator sub device data */
557#define GREG_INIT(_id, _var, _name, _input_supply, _always_on, _boot_on, \
558 _gpio_nr, _active_low, _init_state, _pg, _enable, _disable) \
559 static struct gpio_switch_regulator_subdev_data gpio_pdata_##_var = \
560 { \
561 .regulator_name = "gpio-switch-"#_name, \
562 .input_supply = _input_supply, \
563 .id = _id, \
564 .gpio_nr = _gpio_nr, \
565 .pin_group = _pg, \
566 .active_low = _active_low, \
567 .init_state = _init_state, \
568 .voltages = gpio_switch_##_name##_voltages, \
569 .n_voltages = ARRAY_SIZE(gpio_switch_##_name##_voltages), \
570 .num_consumer_supplies = \
571 ARRAY_SIZE(gpio_switch_##_name##_supply), \
572 .consumer_supplies = gpio_switch_##_name##_supply, \
573 .constraints = { \
574 .valid_modes_mask = (REGULATOR_MODE_NORMAL | \
575 REGULATOR_MODE_STANDBY), \
576 .valid_ops_mask = (REGULATOR_CHANGE_MODE | \
577 REGULATOR_CHANGE_STATUS | \
578 REGULATOR_CHANGE_VOLTAGE), \
579 .always_on = _always_on, \
580 .boot_on = _boot_on, \
581 }, \
582 .enable_rail = _enable, \
583 .disable_rail = _disable, \
584 }; \
585 static struct gpio_switch_regulator_subdev_data \
586 *gpio_pdata_##_var##_list[] = { \
587 &gpio_pdata_##_var, \
588 }; \
589 static struct gpio_switch_regulator_platform_data gs_##_var##_pdata = \
590 { \
591 .num_subdevs = 1, \
592 .subdevs = gpio_pdata_##_var##_list, \
593 }; \
594 static struct platform_device gswitch_reg_##_var##_dev = { \
595 .name = "gpio-switch-regulator", \
596 .id = _id, \
597 .dev = { \
598 .platform_data = &gs_##_var##_pdata, \
599 }, \
600 }
601
602/* Macro for defining fixed regulator sub device data */
603#define FIXED_SUPPLY(_name) "fixed_reg_"#_name
604#define FIXED_REG(_id, _var, _name, _in_supply, _always_on, _boot_on, \
605 _gpio_nr, _active_high, _boot_state, _millivolts) \
606 static struct regulator_init_data ri_data_##_var = \
607 { \
608 .supply_regulator = _in_supply, \
609 .num_consumer_supplies = \
610 ARRAY_SIZE(fixed_reg_##_name##_supply), \
611 .consumer_supplies = fixed_reg_##_name##_supply, \
612 .constraints = { \
613 .valid_modes_mask = (REGULATOR_MODE_NORMAL | \
614 REGULATOR_MODE_STANDBY), \
615 .valid_ops_mask = (REGULATOR_CHANGE_MODE | \
616 REGULATOR_CHANGE_STATUS | \
617 REGULATOR_CHANGE_VOLTAGE), \
618 .always_on = _always_on, \
619 .boot_on = _boot_on, \
620 }, \
621 }; \
622 static struct fixed_voltage_config fixed_reg_##_var##_pdata = \
623 { \
624 .supply_name = FIXED_SUPPLY(_name), \
625 .microvolts = _millivolts * 1000, \
626 .gpio = _gpio_nr, \
627 .enable_high = _active_high, \
628 .enabled_at_boot = _boot_state, \
629 .init_data = &ri_data_##_var, \
630 }; \
631 static struct platform_device fixed_reg_##_var##_dev = { \
632 .name = "reg-fixed-voltage", \
633 .id = _id, \
634 .dev = { \
635 .platform_data = &fixed_reg_##_var##_pdata, \
636 }, \
637 }
638
639/* common to most of boards*/
640FIXED_REG(0, en_5v_cp, en_5v_cp, NULL, 1, 0, TPS6591X_GPIO_0, true, 1, 5000);
641FIXED_REG(1, en_5v0, en_5v0, NULL, 0, 0, TPS6591X_GPIO_4, true, 0, 5000);
642FIXED_REG(2, en_ddr, en_ddr, NULL, 0, 0, TPS6591X_GPIO_3, true, 1, 1500);
643FIXED_REG(3, en_3v3_sys, en_3v3_sys, NULL, 0, 0, TPS6591X_GPIO_1, true, 0, 3300);
644FIXED_REG(4, en_vdd_bl, en_vdd_bl, NULL, 0, 0, TEGRA_GPIO_PK3, true, 1, 5000);
645FIXED_REG(5, en_3v3_modem, en_3v3_modem, NULL, 1, 0, TEGRA_GPIO_PD6, true, 1, 3300);
646FIXED_REG(6, en_vdd_pnl1, en_vdd_pnl1, FIXED_SUPPLY(en_3v3_sys), 0, 0, TEGRA_GPIO_PL4, true, 1, 3300);
647FIXED_REG(7, cam3_ldo_en, cam3_ldo_en, FIXED_SUPPLY(en_3v3_sys), 0, 0, TEGRA_GPIO_PS0, true, 0, 3300);
648FIXED_REG(8, en_vdd_com, en_vdd_com, FIXED_SUPPLY(en_3v3_sys), 1, 0, TEGRA_GPIO_PD0, true, 1, 3300);
649FIXED_REG(9, en_3v3_fuse, en_3v3_fuse, FIXED_SUPPLY(en_3v3_sys), 0, 0, TEGRA_GPIO_PL6, true, 0, 3300);
650FIXED_REG(10, en_3v3_emmc, en_3v3_emmc, FIXED_SUPPLY(en_3v3_sys), 1, 0, TEGRA_GPIO_PD1, true, 1, 3300);
651FIXED_REG(11, en_vdd_sdmmc1, en_vdd_sdmmc1, FIXED_SUPPLY(en_3v3_sys), 0, 0, TEGRA_GPIO_PD7, true, 1, 3300);
652FIXED_REG(12, en_3v3_pex_hvdd, en_3v3_pex_hvdd, FIXED_SUPPLY(en_3v3_sys), 0, 0, TEGRA_GPIO_PL7, true, 0, 3300);
653FIXED_REG(13, en_1v8_cam, en_1v8_cam, ricoh583_rails(DC2), 0, 0, TEGRA_GPIO_PBB4, true, 0, 1800);
654
655/* E1198/E1291 specific*/
656FIXED_REG(18, cam1_ldo_en, cam1_ldo_en, FIXED_SUPPLY(en_3v3_sys), 0, 0, TEGRA_GPIO_PR6, true, 0, 2800);
657FIXED_REG(19, cam2_ldo_en, cam2_ldo_en, FIXED_SUPPLY(en_3v3_sys), 0, 0, TEGRA_GPIO_PR7, true, 0, 2800);
658FIXED_REG(22, en_vbrtr, en_vbrtr, FIXED_SUPPLY(en_3v3_sys), 0, 0, PMU_TCA6416_GPIO_PORT12,true, 0, 3300);
659
660/*Specific to pm269*/
661FIXED_REG(4, en_vdd_bl_pm269, en_vdd_bl, NULL, 0, 0, TEGRA_GPIO_PH3, true, 1, 5000);
662FIXED_REG(6, en_vdd_pnl1_pm269, en_vdd_pnl1, FIXED_SUPPLY(en_3v3_sys), 0, 0, TEGRA_GPIO_PW1, true, 1, 3300);
663FIXED_REG(9, en_3v3_fuse_pm269, en_3v3_fuse, FIXED_SUPPLY(en_3v3_sys), 0, 0, TEGRA_GPIO_PC1, true, 0, 3300);
664FIXED_REG(11, en_vdd_sdmmc1_pm269, en_vdd_sdmmc1, FIXED_SUPPLY(en_3v3_sys), 0, 0, TEGRA_GPIO_PP1, true, 1, 3300);
665FIXED_REG(12, en_3v3_pex_hvdd_pm269, en_3v3_pex_hvdd, FIXED_SUPPLY(en_3v3_sys), 0, 0, TEGRA_GPIO_PC6, true, 0, 3300);
666
667/* Specific to E1187/E1186/E1256 */
668FIXED_REG(14, dis_5v_switch_e118x, dis_5v_switch, FIXED_SUPPLY(en_5v0), 0, 0, TEGRA_GPIO_PX2, false, 0, 5000);
669
670/*** Open collector load switches ************/
671/*Specific to pm269*/
672GREG_INIT(17, en_vddio_vid_oc_pm269, en_vddio_vid_oc, "master_5v_switch",
673 0, 0, TEGRA_GPIO_PP2, false, 0, TEGRA_PINGROUP_DAP3_DOUT,
674 enable_load_switch_rail, disable_load_switch_rail);
675
676/* Specific to E1187/E1186/E1256 */
677GREG_INIT(15, en_usb1_vbus_oc_e118x, en_usb1_vbus_oc, "master_5v_switch",
678 0, 0, TEGRA_GPIO_PI4, false, 0, TEGRA_PINGROUP_GMI_RST_N,
679 enable_load_switch_rail, disable_load_switch_rail);
680GREG_INIT(16, en_usb3_vbus_oc_e118x, en_usb3_vbus_oc, "master_5v_switch",
681 0, 0, TEGRA_GPIO_PH7, false, 0, TEGRA_PINGROUP_GMI_AD15,
682 enable_load_switch_rail, disable_load_switch_rail);
683GREG_INIT(17, en_vddio_vid_oc_e118x, en_vddio_vid_oc, "master_5v_switch",
684 0, 0, TEGRA_GPIO_PT0, false, 0, TEGRA_PINGROUP_VI_PCLK,
685 enable_load_switch_rail, disable_load_switch_rail);
686
687/*
688 * Creating the fixed/gpio-switch regulator device tables for different boards
689 */
690#define ADD_FIXED_REG(_name) (&fixed_reg_##_name##_dev)
691#define ADD_GPIO_REG(_name) (&gswitch_reg_##_name##_dev)
692
693#define COMMON_FIXED_REG \
694 ADD_FIXED_REG(en_5v_cp), \
695 ADD_FIXED_REG(en_5v0), \
696 ADD_FIXED_REG(en_ddr), \
697 ADD_FIXED_REG(en_3v3_sys), \
698 ADD_FIXED_REG(en_3v3_modem), \
699 ADD_FIXED_REG(en_vdd_pnl1), \
700 ADD_FIXED_REG(cam1_ldo_en), \
701 ADD_FIXED_REG(cam2_ldo_en), \
702 ADD_FIXED_REG(cam3_ldo_en), \
703 ADD_FIXED_REG(en_vdd_com), \
704 ADD_FIXED_REG(en_3v3_fuse), \
705 ADD_FIXED_REG(en_3v3_emmc), \
706 ADD_FIXED_REG(en_vdd_sdmmc1), \
707 ADD_FIXED_REG(en_3v3_pex_hvdd), \
708 ADD_FIXED_REG(en_1v8_cam),
709
710#define PM269_FIXED_REG \
711 ADD_FIXED_REG(en_5v_cp), \
712 ADD_FIXED_REG(en_5v0), \
713 ADD_FIXED_REG(en_ddr), \
714 ADD_FIXED_REG(en_vdd_bl_pm269), \
715 ADD_FIXED_REG(en_3v3_sys), \
716 ADD_FIXED_REG(en_3v3_modem), \
717 ADD_FIXED_REG(en_vdd_pnl1_pm269), \
718 ADD_FIXED_REG(cam1_ldo_en), \
719 ADD_FIXED_REG(cam2_ldo_en), \
720 ADD_FIXED_REG(cam3_ldo_en), \
721 ADD_FIXED_REG(en_vdd_com), \
722 ADD_FIXED_REG(en_3v3_fuse_pm269), \
723 ADD_FIXED_REG(en_3v3_emmc), \
724 ADD_FIXED_REG(en_vdd_sdmmc1_pm269), \
725 ADD_FIXED_REG(en_3v3_pex_hvdd_pm269), \
726 ADD_FIXED_REG(en_1v8_cam), \
727 ADD_FIXED_REG(dis_5v_switch_e118x), \
728 ADD_GPIO_REG(en_usb1_vbus_oc_e118x), \
729 ADD_GPIO_REG(en_usb3_vbus_oc_e118x), \
730 ADD_GPIO_REG(en_vddio_vid_oc_pm269),
731
732#define E118x_FIXED_REG \
733 ADD_FIXED_REG(en_vdd_bl), \
734 ADD_FIXED_REG(dis_5v_switch_e118x), \
735 ADD_FIXED_REG(en_vbrtr), \
736 ADD_GPIO_REG(en_usb1_vbus_oc_e118x), \
737 ADD_GPIO_REG(en_usb3_vbus_oc_e118x), \
738 ADD_GPIO_REG(en_vddio_vid_oc_e118x), \
739
740/* Gpio switch regulator platform data for E1186/E1187/E1256*/
741static struct platform_device *fixed_reg_devs_e118x[] = {
742 COMMON_FIXED_REG
743 E118x_FIXED_REG
744};
745
746/* Gpio switch regulator platform data for PM269*/
747static struct platform_device *fixed_reg_devs_pm269[] = {
748 PM269_FIXED_REG
749};
750
751int __init cardhu_pm299_gpio_switch_regulator_init(void)
752{
753 int i;
754 struct board_info board_info;
755 struct platform_device **fixed_reg_devs;
756 int nfixreg_devs;
757
758 tegra_get_board_info(&board_info);
759
760 switch (board_info.board_id) {
761 case BOARD_PM269:
762 case BOARD_PM305:
763 case BOARD_PM311:
764 case BOARD_E1257:
765 nfixreg_devs = ARRAY_SIZE(fixed_reg_devs_pm269);
766 fixed_reg_devs = fixed_reg_devs_pm269;
767 break;
768
769 default:
770 nfixreg_devs = ARRAY_SIZE(fixed_reg_devs_e118x);
771 fixed_reg_devs = fixed_reg_devs_e118x;
772 break;
773 }
774
775 for (i = 0; i < nfixreg_devs; ++i) {
776 int gpio_nr;
777 if (!strncmp(fixed_reg_devs[i]->name, "gpio", 4)) {
778 struct gpio_switch_regulator_platform_data *gs_pdata =
779 fixed_reg_devs[i]->dev.platform_data;
780 gpio_nr = gs_pdata->subdevs[0]->gpio_nr;
781 } else {
782 struct fixed_voltage_config *fixed_reg_pdata =
783 fixed_reg_devs[i]->dev.platform_data;
784 gpio_nr = fixed_reg_pdata->gpio;
785 }
786
787 if (gpio_nr < TEGRA_NR_GPIOS)
788 tegra_gpio_enable(gpio_nr);
789 }
790 return platform_add_devices(fixed_reg_devs, nfixreg_devs);
791}