ARM: tegra: cardhu: Remove tegra_gpio_enb/disable
[linux-2.6.git] / arch / arm / mach-tegra / board-cardhu-pm299-power-rails.c
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/fixed.h>
29 #include <linux/regulator/ricoh583-regulator.h>
30 #include <linux/regulator/tps62360.h>
31
32 #include <mach/iomap.h>
33 #include <mach/irqs.h>
34 #include <mach/pinmux.h>
35 #include <mach/edp.h>
36
37 #include "gpio-names.h"
38 #include "board.h"
39 #include "board-cardhu.h"
40 #include "wakeups-t3.h"
41
42 #define PMC_CTRL                0x0
43 #define PMC_CTRL_INTR_LOW       (1 << 17)
44
45 static struct regulator_consumer_supply ricoh583_dc1_supply_skubit0_0[] = {
46         REGULATOR_SUPPLY("vdd_core", NULL),
47         REGULATOR_SUPPLY("en_vddio_ddr_1v2", NULL),
48 };
49
50 static struct regulator_consumer_supply ricoh583_dc1_supply_skubit0_1[] = {
51         REGULATOR_SUPPLY("en_vddio_ddr_1v2", NULL),
52 };
53
54 static struct regulator_consumer_supply ricoh583_dc3_supply_0[] = {
55         REGULATOR_SUPPLY("vdd_gen1v5", NULL),
56         REGULATOR_SUPPLY("vcore_lcd", NULL),
57         REGULATOR_SUPPLY("track_ldo1", NULL),
58         REGULATOR_SUPPLY("external_ldo_1v2", NULL),
59         REGULATOR_SUPPLY("vcore_cam1", NULL),
60         REGULATOR_SUPPLY("vcore_cam2", NULL),
61 };
62
63 static struct regulator_consumer_supply ricoh583_dc0_supply_0[] = {
64         REGULATOR_SUPPLY("vdd_cpu_pmu", NULL),
65         REGULATOR_SUPPLY("vdd_cpu", NULL),
66         REGULATOR_SUPPLY("vdd_sys", NULL),
67 };
68
69 static struct regulator_consumer_supply ricoh583_dc2_supply_0[] = {
70         REGULATOR_SUPPLY("vdd_gen1v8", NULL),
71         REGULATOR_SUPPLY("avdd_hdmi_pll", NULL),
72         REGULATOR_SUPPLY("avdd_usb_pll", NULL),
73         REGULATOR_SUPPLY("avdd_osc", NULL),
74         REGULATOR_SUPPLY("vddio_sys", NULL),
75         REGULATOR_SUPPLY("vddio_sdmmc", "sdhci-tegra.3"),
76         REGULATOR_SUPPLY("pwrdet_sdmmc4", NULL),
77         REGULATOR_SUPPLY("vdd1v8_satelite", NULL),
78         REGULATOR_SUPPLY("vddio_uart", NULL),
79         REGULATOR_SUPPLY("pwrdet_uart", NULL),
80         REGULATOR_SUPPLY("vddio_audio", NULL),
81         REGULATOR_SUPPLY("pwrdet_audio", NULL),
82         REGULATOR_SUPPLY("vddio_bb", NULL),
83         REGULATOR_SUPPLY("pwrdet_bb", NULL),
84         REGULATOR_SUPPLY("vddio_lcd_pmu", NULL),
85         REGULATOR_SUPPLY("pwrdet_lcd", NULL),
86         REGULATOR_SUPPLY("vddio_cam", NULL),
87         REGULATOR_SUPPLY("pwrdet_cam", NULL),
88         REGULATOR_SUPPLY("vddio_vi", NULL),
89         REGULATOR_SUPPLY("pwrdet_vi", NULL),
90         REGULATOR_SUPPLY("ldo6", NULL),
91         REGULATOR_SUPPLY("ldo7", NULL),
92         REGULATOR_SUPPLY("ldo8", NULL),
93         REGULATOR_SUPPLY("vcore_audio", NULL),
94         REGULATOR_SUPPLY("avcore_audio", NULL),
95         REGULATOR_SUPPLY("vddio_sdmmc", "sdhci-tegra.2"),
96         REGULATOR_SUPPLY("pwrdet_sdmmc3", NULL),
97         REGULATOR_SUPPLY("vcore1_lpddr2", NULL),
98         REGULATOR_SUPPLY("vcom_1v8", NULL),
99         REGULATOR_SUPPLY("pmuio_1v8", NULL),
100         REGULATOR_SUPPLY("avdd_ic_usb", NULL),
101 };
102
103 static struct regulator_consumer_supply ricoh583_ldo0_supply_0[] = {
104         REGULATOR_SUPPLY("unused_ldo0", NULL),
105 };
106
107 static struct regulator_consumer_supply ricoh583_ldo1_supply_0[] = {
108         REGULATOR_SUPPLY("avdd_pexb", NULL),
109         REGULATOR_SUPPLY("vdd_pexb", NULL),
110         REGULATOR_SUPPLY("avdd_pex_pll", NULL),
111         REGULATOR_SUPPLY("avdd_pexa", NULL),
112         REGULATOR_SUPPLY("vdd_pexa", NULL),
113 };
114
115 static struct regulator_consumer_supply ricoh583_ldo2_supply_0[] = {
116         REGULATOR_SUPPLY("avdd_sata", NULL),
117         REGULATOR_SUPPLY("vdd_sata", NULL),
118         REGULATOR_SUPPLY("avdd_sata_pll", NULL),
119         REGULATOR_SUPPLY("avdd_plle", NULL),
120 };
121
122 static struct regulator_consumer_supply ricoh583_ldo3_supply_0[] = {
123         REGULATOR_SUPPLY("vddio_sdmmc", "sdhci-tegra.0"),
124         REGULATOR_SUPPLY("pwrdet_sdmmc1", NULL),
125 };
126
127 static struct regulator_consumer_supply ricoh583_ldo4_supply_0[] = {
128         REGULATOR_SUPPLY("vdd_rtc", NULL),
129 };
130
131 static struct regulator_consumer_supply ricoh583_ldo5_supply_0[] = {
132         REGULATOR_SUPPLY("avdd_vdac", NULL),
133 };
134
135 static struct regulator_consumer_supply ricoh583_ldo6_supply_0[] = {
136         REGULATOR_SUPPLY("avdd_dsi_csi", NULL),
137         REGULATOR_SUPPLY("pwrdet_mipi", NULL),
138 };
139 static struct regulator_consumer_supply ricoh583_ldo7_supply_0[] = {
140         REGULATOR_SUPPLY("avdd_plla_p_c_s", NULL),
141         REGULATOR_SUPPLY("avdd_pllm", NULL),
142         REGULATOR_SUPPLY("avdd_pllu_d", NULL),
143         REGULATOR_SUPPLY("avdd_pllu_d2", NULL),
144         REGULATOR_SUPPLY("avdd_pllx", NULL),
145 };
146
147 static struct regulator_consumer_supply ricoh583_ldo8_supply_0[] = {
148         REGULATOR_SUPPLY("vdd_ddr_hs", NULL),
149 };
150
151 #define RICOH_PDATA_INIT(_name, _sname, _minmv, _maxmv, _supply_reg, _always_on, \
152         _boot_on, _apply_uv, _init_uV, _init_enable, _init_apply, _flags,      \
153         _ext_contol, _ds_slots) \
154         static struct ricoh583_regulator_platform_data pdata_##_name##_##_sname = \
155         {                                                               \
156                 .regulator = {                                          \
157                         .constraints = {                                \
158                                 .min_uV = (_minmv)*1000,                \
159                                 .max_uV = (_maxmv)*1000,                \
160                                 .valid_modes_mask = (REGULATOR_MODE_NORMAL |  \
161                                                      REGULATOR_MODE_STANDBY), \
162                                 .valid_ops_mask = (REGULATOR_CHANGE_MODE |    \
163                                                    REGULATOR_CHANGE_STATUS |  \
164                                                    REGULATOR_CHANGE_VOLTAGE), \
165                                 .always_on = _always_on,                \
166                                 .boot_on = _boot_on,                    \
167                                 .apply_uV = _apply_uv,                  \
168                         },                                              \
169                         .num_consumer_supplies =                        \
170                                 ARRAY_SIZE(ricoh583_##_name##_supply_##_sname), \
171                         .consumer_supplies = ricoh583_##_name##_supply_##_sname, \
172                         .supply_regulator = _supply_reg,                \
173                 },                                                      \
174                 .init_uV =  _init_uV * 1000,                            \
175                 .init_enable = _init_enable,                            \
176                 .init_apply = _init_apply,                              \
177                 .deepsleep_slots = _ds_slots,                           \
178                 .flags = _flags,                                        \
179                 .ext_pwr_req = _ext_contol,                             \
180         }
181
182 RICOH_PDATA_INIT(dc0, 0,         700,  1500, 0, 1, 1, 0, -1, 0, 0, 0,
183                                 RICOH583_EXT_PWRREQ2_CONTROL, 0);
184 RICOH_PDATA_INIT(dc1, skubit0_0, 700,  1500, 0, 1, 1, 0, -1, 0, 0, 0,
185                                 RICOH583_EXT_PWRREQ1_CONTROL, 0);
186 RICOH_PDATA_INIT(dc2, 0,         900,  2400, 0, 1, 1, 0, -1, 0, 0, 0, 0, 0);
187 RICOH_PDATA_INIT(dc3, 0,         900,  2400, 0, 1, 1, 0, -1, 0, 0, 0, 0, 0);
188
189 RICOH_PDATA_INIT(ldo0, 0,         1000, 3300, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0);
190 RICOH_PDATA_INIT(ldo1, 0,         1000, 3300, ricoh583_rails(DC1), 0, 0, 0, -1, 0, 0, 0, 0, 0);
191 RICOH_PDATA_INIT(ldo2, 0,         1050, 1050, ricoh583_rails(DC1), 0, 0, 1, -1, 0, 0, 0, 0, 0);
192
193 RICOH_PDATA_INIT(ldo3, 0,         1000, 3300, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0);
194 RICOH_PDATA_INIT(ldo4, 0,         750,  1500, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0);
195 RICOH_PDATA_INIT(ldo5, 0,         1000, 3300, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0);
196
197 RICOH_PDATA_INIT(ldo6, 0,         1200, 1200, ricoh583_rails(DC2), 0, 0, 1, -1, 0, 0, 0, 0, 0);
198 RICOH_PDATA_INIT(ldo7, 0,         1200, 1200, ricoh583_rails(DC2), 1, 1, 1, -1, 0, 0, 0, 0, 0);
199 RICOH_PDATA_INIT(ldo8, 0,         900, 3400, ricoh583_rails(DC2), 1, 0, 0, -1, 0, 0, 0, 0, 0);
200
201 static 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
243 static 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         }
254 struct 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
265 static 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
273 static 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 */
282 static struct regulator_consumer_supply tps62361_dcdc_supply[] = {
283         REGULATOR_SUPPLY("vdd_core", NULL),
284 };
285
286 static 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
310 static struct i2c_board_info __initdata tps62361_boardinfo[] = {
311         {
312                 I2C_BOARD_INFO("tps62361", 0x60),
313                 .platform_data  = &tps62361_pdata,
314         },
315 };
316
317 int __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 */
362 static 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 */
370 static struct regulator_consumer_supply fixed_reg_en_5v0_supply[] = {
371         REGULATOR_SUPPLY("vdd_5v0_sys", NULL),
372 };
373
374 /* EN_DDR From PMU GP6 */
375 static 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 */
381 static 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 */
428 static struct regulator_consumer_supply fixed_reg_dis_5v_switch_supply[] = {
429         REGULATOR_SUPPLY("master_5v_switch", NULL),
430 };
431
432 /* EN_VDD_BL */
433 static 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*/
439 static 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*/
445 static 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*/
450 static struct regulator_consumer_supply fixed_reg_cam1_ldo_en_supply[] = {
451         REGULATOR_SUPPLY("vdd_2v8_cam1", NULL),
452         REGULATOR_SUPPLY("avdd", "6-0072"),
453 };
454
455 /* CAM2_LDO_EN from AP GPIO KB_ROW7 R07*/
456 static struct regulator_consumer_supply fixed_reg_cam2_ldo_en_supply[] = {
457         REGULATOR_SUPPLY("vdd_2v8_cam2", NULL),
458         REGULATOR_SUPPLY("avdd", "7-0072"),
459 };
460
461 /* CAM3_LDO_EN from AP GPIO KB_ROW8 S00*/
462 static 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*/
467 static 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*/
472 static 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*/
477 static 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*/
482 static 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*/
487 static 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*/
492 static 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("dvdd", "6-0072"),
497         REGULATOR_SUPPLY("dvdd", "7-0072"),
498         REGULATOR_SUPPLY("vdd_i2c", "2-0033"),
499 };
500
501 static struct regulator_consumer_supply fixed_reg_en_vbrtr_supply[] = {
502         REGULATOR_SUPPLY("vdd_vbrtr", NULL),
503 };
504
505
506 /* EN_USB1_VBUS_OC*/
507 static struct regulator_consumer_supply fixed_reg_en_usb1_vbus_oc_supply[] = {
508         REGULATOR_SUPPLY("vdd_vbus_micro_usb", NULL),
509 };
510
511 /*EN_USB3_VBUS_OC*/
512 static struct regulator_consumer_supply fixed_reg_en_usb3_vbus_oc_supply[] = {
513         REGULATOR_SUPPLY("vdd_vbus_typea_usb", NULL),
514 };
515
516 /* EN_VDDIO_VID_OC from AP GPIO VI_PCLK T00*/
517 static struct regulator_consumer_supply fixed_reg_en_vddio_vid_oc_supply[] = {
518         REGULATOR_SUPPLY("vdd_hdmi_con", NULL),
519 };
520
521 /* Macro for defining fixed regulator sub device data */
522 #define FIXED_SUPPLY(_name) "fixed_reg_"#_name
523 #define FIXED_REG_OD(_id, _var, _name, _in_supply, _always_on, _boot_on,      \
524                  _gpio_nr, _active_high, _boot_state, _millivolts, _od_state) \
525         static struct regulator_init_data ri_data_##_var =              \
526         {                                                               \
527                 .supply_regulator = _in_supply,                         \
528                 .num_consumer_supplies =                                \
529                         ARRAY_SIZE(fixed_reg_##_name##_supply),         \
530                 .consumer_supplies = fixed_reg_##_name##_supply,        \
531                 .constraints = {                                        \
532                         .valid_modes_mask = (REGULATOR_MODE_NORMAL |    \
533                                         REGULATOR_MODE_STANDBY),        \
534                         .valid_ops_mask = (REGULATOR_CHANGE_MODE |      \
535                                         REGULATOR_CHANGE_STATUS |       \
536                                         REGULATOR_CHANGE_VOLTAGE),      \
537                         .always_on = _always_on,                        \
538                         .boot_on = _boot_on,                            \
539                 },                                                      \
540         };                                                              \
541         static struct fixed_voltage_config fixed_reg_##_var##_pdata =   \
542         {                                                               \
543                 .supply_name = FIXED_SUPPLY(_name),                     \
544                 .microvolts = _millivolts * 1000,                       \
545                 .gpio = _gpio_nr,                                       \
546                 .enable_high = _active_high,                            \
547                 .enabled_at_boot = _boot_state,                         \
548                 .init_data = &ri_data_##_var,                           \
549                 .gpio_is_open_drain = _od_state,                        \
550         };                                                              \
551         static struct platform_device fixed_reg_##_var##_dev = {        \
552                 .name   = "reg-fixed-voltage",                          \
553                 .id     = _id,                                          \
554                 .dev    = {                                             \
555                         .platform_data = &fixed_reg_##_var##_pdata,     \
556                 },                                                      \
557         }
558
559 #define FIXED_REG(_id, _var, _name, _in_supply, _always_on, _boot_on,   \
560                  _gpio_nr, _active_high, _boot_state, _millivolts)      \
561         FIXED_REG_OD(_id, _var, _name, _in_supply, _always_on, _boot_on, \
562                  _gpio_nr, _active_high, _boot_state, _millivolts, false)
563
564 /* common to most of boards*/
565 FIXED_REG(0, en_5v_cp,          en_5v_cp,       NULL,                   1,      0,      TPS6591X_GPIO_0,        true,   1, 5000);
566 FIXED_REG(1, en_5v0,            en_5v0,         NULL,                   0,      0,      TPS6591X_GPIO_4,        true,   0, 5000);
567 FIXED_REG(2, en_ddr,            en_ddr,         NULL,                   0,      0,      TPS6591X_GPIO_3,        true,   1, 1500);
568 FIXED_REG(3, en_3v3_sys,        en_3v3_sys,     NULL,                   0,      0,      TPS6591X_GPIO_1,        true,   1, 3300);
569 FIXED_REG(4, en_vdd_bl,         en_vdd_bl,      NULL,                   0,      0,      TEGRA_GPIO_PK3,         true,   1, 5000);
570 FIXED_REG(5, en_3v3_modem,      en_3v3_modem,   NULL,                   1,      0,      TEGRA_GPIO_PD6,         true,   1, 3300);
571 FIXED_REG(6, en_vdd_pnl1,       en_vdd_pnl1,    FIXED_SUPPLY(en_3v3_sys),       0,      0,      TEGRA_GPIO_PL4,         true,   1, 3300);
572 FIXED_REG(7, cam3_ldo_en,       cam3_ldo_en,    FIXED_SUPPLY(en_3v3_sys),       0,      0,      TEGRA_GPIO_PS0,         true,   0, 3300);
573 FIXED_REG(8, en_vdd_com,        en_vdd_com,     FIXED_SUPPLY(en_3v3_sys),       1,      0,      TEGRA_GPIO_PD0,         true,   1, 3300);
574 FIXED_REG(9, en_3v3_fuse,       en_3v3_fuse,    FIXED_SUPPLY(en_3v3_sys),       0,      0,      TEGRA_GPIO_PL6,         true,   0, 3300);
575 FIXED_REG(10, en_3v3_emmc,      en_3v3_emmc,    FIXED_SUPPLY(en_3v3_sys),       1,      0,      TEGRA_GPIO_PD1,         true,   1, 3300);
576 FIXED_REG(11, en_vdd_sdmmc1,    en_vdd_sdmmc1,  FIXED_SUPPLY(en_3v3_sys),       0,      0,      TEGRA_GPIO_PD7,         true,   1, 3300);
577 FIXED_REG(12, en_3v3_pex_hvdd,  en_3v3_pex_hvdd, FIXED_SUPPLY(en_3v3_sys),      0,      0,      TEGRA_GPIO_PL7,         true,   0, 3300);
578 FIXED_REG(13, en_1v8_cam,       en_1v8_cam,     ricoh583_rails(DC2),            0,      0,      TEGRA_GPIO_PBB4,        true,   0, 1800);
579
580 /* E1198/E1291 specific*/
581 FIXED_REG(18, cam1_ldo_en,      cam1_ldo_en,    FIXED_SUPPLY(en_3v3_sys),       0,      0,      TEGRA_GPIO_PR6,         true,   0, 2800);
582 FIXED_REG(19, cam2_ldo_en,      cam2_ldo_en,    FIXED_SUPPLY(en_3v3_sys),       0,      0,      TEGRA_GPIO_PR7,         true,   0, 2800);
583 FIXED_REG(22, en_vbrtr,         en_vbrtr,       FIXED_SUPPLY(en_3v3_sys),       0,      0,      PMU_TCA6416_GPIO_PORT12,true,   0, 3300);
584
585 /*Specific to pm269*/
586 FIXED_REG(4, en_vdd_bl_pm269,           en_vdd_bl,              NULL,                           0,      0,      TEGRA_GPIO_PH3, true,   1, 5000);
587 FIXED_REG(6, en_vdd_pnl1_pm269,         en_vdd_pnl1,            FIXED_SUPPLY(en_3v3_sys),       0,      0,      TEGRA_GPIO_PW1, true,   1, 3300);
588 FIXED_REG(9, en_3v3_fuse_pm269,         en_3v3_fuse,            FIXED_SUPPLY(en_3v3_sys),       0,      0,      TEGRA_GPIO_PC1, true,   0, 3300);
589 FIXED_REG(11, en_vdd_sdmmc1_pm269,      en_vdd_sdmmc1,          FIXED_SUPPLY(en_3v3_sys),       0,      0,      TEGRA_GPIO_PP1, true,   1, 3300);
590 FIXED_REG(12, en_3v3_pex_hvdd_pm269,    en_3v3_pex_hvdd,        FIXED_SUPPLY(en_3v3_sys),       0,      0,      TEGRA_GPIO_PC6, true,   0, 3300);
591
592 /* Specific to E1187/E1186/E1256 */
593 FIXED_REG(14, dis_5v_switch_e118x,      dis_5v_switch,          FIXED_SUPPLY(en_5v0),           0,      0,      TEGRA_GPIO_PX2, false,  0, 5000);
594
595 /*** Open collector load switches ************/
596 /*Specific to pm269*/
597 FIXED_REG_OD(17, en_vddio_vid_oc_pm269, en_vddio_vid_oc,        FIXED_SUPPLY(dis_5v_switch),    0,      0,      TEGRA_GPIO_PP2, true,   0, 5000, true);
598
599 /* Specific to E1187/E1186/E1256 */
600 FIXED_REG_OD(15, en_usb1_vbus_oc_e118x, en_usb1_vbus_oc,        FIXED_SUPPLY(dis_5v_switch),    0,      0,      TEGRA_GPIO_PI4, true,   0, 5000, true);
601 FIXED_REG_OD(16, en_usb3_vbus_oc_e118x, en_usb3_vbus_oc,        FIXED_SUPPLY(dis_5v_switch),    0,      0,      TEGRA_GPIO_PH7, true,   0, 5000, true);
602 FIXED_REG_OD(17, en_vddio_vid_oc_e118x, en_vddio_vid_oc,        FIXED_SUPPLY(dis_5v_switch),    0,      0,      TEGRA_GPIO_PT0, true,   0, 5000, true);
603
604 /*
605  * Creating the fixed/gpio-switch regulator device tables for different boards
606  */
607 #define ADD_FIXED_REG(_name)    (&fixed_reg_##_name##_dev)
608
609 #define COMMON_FIXED_REG                        \
610         ADD_FIXED_REG(en_5v_cp),                \
611         ADD_FIXED_REG(en_5v0),                  \
612         ADD_FIXED_REG(en_ddr),                  \
613         ADD_FIXED_REG(en_3v3_sys),              \
614         ADD_FIXED_REG(en_3v3_modem),            \
615         ADD_FIXED_REG(en_vdd_pnl1),             \
616         ADD_FIXED_REG(cam1_ldo_en),             \
617         ADD_FIXED_REG(cam2_ldo_en),             \
618         ADD_FIXED_REG(cam3_ldo_en),             \
619         ADD_FIXED_REG(en_vdd_com),              \
620         ADD_FIXED_REG(en_3v3_fuse),             \
621         ADD_FIXED_REG(en_3v3_emmc),             \
622         ADD_FIXED_REG(en_vdd_sdmmc1),           \
623         ADD_FIXED_REG(en_3v3_pex_hvdd),         \
624         ADD_FIXED_REG(en_1v8_cam),
625
626 #define PM269_FIXED_REG                         \
627         ADD_FIXED_REG(en_5v_cp),                \
628         ADD_FIXED_REG(en_5v0),                  \
629         ADD_FIXED_REG(en_ddr),                  \
630         ADD_FIXED_REG(en_vdd_bl_pm269),         \
631         ADD_FIXED_REG(en_3v3_sys),              \
632         ADD_FIXED_REG(en_3v3_modem),            \
633         ADD_FIXED_REG(en_vdd_pnl1_pm269),       \
634         ADD_FIXED_REG(cam1_ldo_en),             \
635         ADD_FIXED_REG(cam2_ldo_en),             \
636         ADD_FIXED_REG(cam3_ldo_en),             \
637         ADD_FIXED_REG(en_vdd_com),              \
638         ADD_FIXED_REG(en_3v3_fuse_pm269),       \
639         ADD_FIXED_REG(en_3v3_emmc),             \
640         ADD_FIXED_REG(en_vdd_sdmmc1_pm269),     \
641         ADD_FIXED_REG(en_3v3_pex_hvdd_pm269),   \
642         ADD_FIXED_REG(en_1v8_cam),              \
643         ADD_FIXED_REG(dis_5v_switch_e118x),     \
644         ADD_FIXED_REG(en_usb1_vbus_oc_e118x),   \
645         ADD_FIXED_REG(en_usb3_vbus_oc_e118x),   \
646         ADD_FIXED_REG(en_vddio_vid_oc_pm269),
647
648 #define E118x_FIXED_REG                         \
649         ADD_FIXED_REG(en_vdd_bl),               \
650         ADD_FIXED_REG(dis_5v_switch_e118x),     \
651         ADD_FIXED_REG(en_vbrtr),                \
652         ADD_FIXED_REG(en_usb1_vbus_oc_e118x),   \
653         ADD_FIXED_REG(en_usb3_vbus_oc_e118x),   \
654         ADD_FIXED_REG(en_vddio_vid_oc_e118x),   \
655
656 /* Gpio switch regulator platform data  for E1186/E1187/E1256*/
657 static struct platform_device *fixed_reg_devs_e118x[] = {
658         COMMON_FIXED_REG
659         E118x_FIXED_REG
660 };
661
662 /* Gpio switch regulator platform data for PM269*/
663 static struct platform_device *fixed_reg_devs_pm269[] = {
664         PM269_FIXED_REG
665 };
666
667 int __init cardhu_pm299_gpio_switch_regulator_init(void)
668 {
669         int i;
670         struct board_info board_info;
671         struct platform_device **fixed_reg_devs;
672         int    nfixreg_devs;
673
674         tegra_get_board_info(&board_info);
675
676         switch (board_info.board_id) {
677         case BOARD_PM269:
678         case BOARD_PM305:
679         case BOARD_PM311:
680         case BOARD_E1257:
681                 nfixreg_devs = ARRAY_SIZE(fixed_reg_devs_pm269);
682                 fixed_reg_devs = fixed_reg_devs_pm269;
683                 break;
684
685         default:
686                 nfixreg_devs = ARRAY_SIZE(fixed_reg_devs_e118x);
687                 fixed_reg_devs = fixed_reg_devs_e118x;
688                 break;
689         }
690
691         return platform_add_devices(fixed_reg_devs, nfixreg_devs);
692 }