rtc: tps80031: register as mfd sub device
[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-2012, NVIDIA Corporation.
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
41 #define PMC_CTRL                0x0
42 #define PMC_CTRL_INTR_LOW       (1 << 17)
43
44 static struct regulator_consumer_supply ricoh583_dc1_supply_skubit0_0[] = {
45         REGULATOR_SUPPLY("vdd_core", NULL),
46         REGULATOR_SUPPLY("en_vddio_ddr_1v2", NULL),
47 };
48
49 static struct regulator_consumer_supply ricoh583_dc1_supply_skubit0_1[] = {
50         REGULATOR_SUPPLY("en_vddio_ddr_1v2", NULL),
51 };
52
53 static struct regulator_consumer_supply ricoh583_dc3_supply_0[] = {
54         REGULATOR_SUPPLY("vdd_gen1v5", NULL),
55         REGULATOR_SUPPLY("vcore_lcd", NULL),
56         REGULATOR_SUPPLY("track_ldo1", NULL),
57         REGULATOR_SUPPLY("external_ldo_1v2", NULL),
58         REGULATOR_SUPPLY("vcore_cam1", NULL),
59         REGULATOR_SUPPLY("vcore_cam2", NULL),
60 };
61
62 static struct regulator_consumer_supply ricoh583_dc0_supply_0[] = {
63         REGULATOR_SUPPLY("vdd_cpu_pmu", NULL),
64         REGULATOR_SUPPLY("vdd_cpu", NULL),
65         REGULATOR_SUPPLY("vdd_sys", NULL),
66 };
67
68 static struct regulator_consumer_supply ricoh583_dc2_supply_0[] = {
69         REGULATOR_SUPPLY("vdd_gen1v8", NULL),
70         REGULATOR_SUPPLY("avdd_hdmi_pll", NULL),
71         REGULATOR_SUPPLY("avdd_usb_pll", NULL),
72         REGULATOR_SUPPLY("avdd_osc", NULL),
73         REGULATOR_SUPPLY("vddio_sys", NULL),
74         REGULATOR_SUPPLY("vddio_sdmmc", "sdhci-tegra.3"),
75         REGULATOR_SUPPLY("pwrdet_sdmmc4", NULL),
76         REGULATOR_SUPPLY("vdd1v8_satelite", NULL),
77         REGULATOR_SUPPLY("vddio_uart", NULL),
78         REGULATOR_SUPPLY("pwrdet_uart", NULL),
79         REGULATOR_SUPPLY("vddio_audio", NULL),
80         REGULATOR_SUPPLY("pwrdet_audio", NULL),
81         REGULATOR_SUPPLY("vddio_bb", NULL),
82         REGULATOR_SUPPLY("pwrdet_bb", NULL),
83         REGULATOR_SUPPLY("vddio_lcd_pmu", NULL),
84         REGULATOR_SUPPLY("pwrdet_lcd", NULL),
85         REGULATOR_SUPPLY("vddio_cam", NULL),
86         REGULATOR_SUPPLY("pwrdet_cam", NULL),
87         REGULATOR_SUPPLY("vddio_vi", NULL),
88         REGULATOR_SUPPLY("pwrdet_vi", NULL),
89         REGULATOR_SUPPLY("ldo6", NULL),
90         REGULATOR_SUPPLY("ldo7", NULL),
91         REGULATOR_SUPPLY("ldo8", NULL),
92         REGULATOR_SUPPLY("vcore_audio", NULL),
93         REGULATOR_SUPPLY("avcore_audio", NULL),
94         REGULATOR_SUPPLY("vddio_sdmmc", "sdhci-tegra.2"),
95         REGULATOR_SUPPLY("pwrdet_sdmmc3", NULL),
96         REGULATOR_SUPPLY("vcore1_lpddr2", NULL),
97         REGULATOR_SUPPLY("vcom_1v8", NULL),
98         REGULATOR_SUPPLY("pmuio_1v8", NULL),
99         REGULATOR_SUPPLY("avdd_ic_usb", NULL),
100 };
101
102 static struct regulator_consumer_supply ricoh583_ldo0_supply_0[] = {
103         REGULATOR_SUPPLY("unused_ldo0", NULL),
104 };
105
106 static struct regulator_consumer_supply ricoh583_ldo1_supply_0[] = {
107         REGULATOR_SUPPLY("avdd_pexb", NULL),
108         REGULATOR_SUPPLY("vdd_pexb", NULL),
109         REGULATOR_SUPPLY("avdd_pex_pll", NULL),
110         REGULATOR_SUPPLY("avdd_pexa", NULL),
111         REGULATOR_SUPPLY("vdd_pexa", NULL),
112 };
113
114 static struct regulator_consumer_supply ricoh583_ldo2_supply_0[] = {
115         REGULATOR_SUPPLY("avdd_sata", NULL),
116         REGULATOR_SUPPLY("vdd_sata", NULL),
117         REGULATOR_SUPPLY("avdd_sata_pll", NULL),
118         REGULATOR_SUPPLY("avdd_plle", NULL),
119 };
120
121 static struct regulator_consumer_supply ricoh583_ldo3_supply_0[] = {
122         REGULATOR_SUPPLY("vddio_sdmmc", "sdhci-tegra.0"),
123         REGULATOR_SUPPLY("pwrdet_sdmmc1", NULL),
124 };
125
126 static struct regulator_consumer_supply ricoh583_ldo4_supply_0[] = {
127         REGULATOR_SUPPLY("vdd_rtc", NULL),
128 };
129
130 static struct regulator_consumer_supply ricoh583_ldo5_supply_0[] = {
131         REGULATOR_SUPPLY("avdd_vdac", NULL),
132 };
133
134 static struct regulator_consumer_supply ricoh583_ldo6_supply_0[] = {
135         REGULATOR_SUPPLY("avdd_dsi_csi", NULL),
136         REGULATOR_SUPPLY("pwrdet_mipi", NULL),
137 };
138 static struct regulator_consumer_supply ricoh583_ldo7_supply_0[] = {
139         REGULATOR_SUPPLY("avdd_plla_p_c_s", NULL),
140         REGULATOR_SUPPLY("avdd_pllm", NULL),
141         REGULATOR_SUPPLY("avdd_pllu_d", NULL),
142         REGULATOR_SUPPLY("avdd_pllu_d2", NULL),
143         REGULATOR_SUPPLY("avdd_pllx", NULL),
144 };
145
146 static struct regulator_consumer_supply ricoh583_ldo8_supply_0[] = {
147         REGULATOR_SUPPLY("vdd_ddr_hs", NULL),
148 };
149
150 #define RICOH_PDATA_INIT(_name, _sname, _minmv, _maxmv, _supply_reg, _always_on, \
151         _boot_on, _apply_uv, _init_uV, _init_enable, _init_apply, _flags,      \
152         _ext_contol, _ds_slots) \
153         static struct ricoh583_regulator_platform_data pdata_##_name##_##_sname = \
154         {                                                               \
155                 .regulator = {                                          \
156                         .constraints = {                                \
157                                 .min_uV = (_minmv)*1000,                \
158                                 .max_uV = (_maxmv)*1000,                \
159                                 .valid_modes_mask = (REGULATOR_MODE_NORMAL |  \
160                                                      REGULATOR_MODE_STANDBY), \
161                                 .valid_ops_mask = (REGULATOR_CHANGE_MODE |    \
162                                                    REGULATOR_CHANGE_STATUS |  \
163                                                    REGULATOR_CHANGE_VOLTAGE), \
164                                 .always_on = _always_on,                \
165                                 .boot_on = _boot_on,                    \
166                                 .apply_uV = _apply_uv,                  \
167                         },                                              \
168                         .num_consumer_supplies =                        \
169                                 ARRAY_SIZE(ricoh583_##_name##_supply_##_sname), \
170                         .consumer_supplies = ricoh583_##_name##_supply_##_sname, \
171                         .supply_regulator = _supply_reg,                \
172                 },                                                      \
173                 .init_uV =  _init_uV * 1000,                            \
174                 .init_enable = _init_enable,                            \
175                 .init_apply = _init_apply,                              \
176                 .deepsleep_slots = _ds_slots,                           \
177                 .flags = _flags,                                        \
178                 .ext_pwr_req = _ext_contol,                             \
179         }
180
181 RICOH_PDATA_INIT(dc0, 0,         700,  1500, 0, 1, 1, 0, -1, 0, 0, 0,
182                                 RICOH583_EXT_PWRREQ2_CONTROL, 0);
183 RICOH_PDATA_INIT(dc1, skubit0_0, 700,  1500, 0, 1, 1, 0, -1, 0, 0, 0,
184                                 RICOH583_EXT_PWRREQ1_CONTROL, 0);
185 RICOH_PDATA_INIT(dc2, 0,         900,  2400, 0, 1, 1, 0, -1, 0, 0, 0, 0, 0);
186 RICOH_PDATA_INIT(dc3, 0,         900,  2400, 0, 1, 1, 0, -1, 0, 0, 0, 0, 0);
187
188 RICOH_PDATA_INIT(ldo0, 0,         1000, 3300, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0);
189 RICOH_PDATA_INIT(ldo1, 0,         1000, 3300, ricoh583_rails(DC1), 0, 0, 0, -1, 0, 0, 0, 0, 0);
190 RICOH_PDATA_INIT(ldo2, 0,         1050, 1050, ricoh583_rails(DC1), 0, 0, 1, -1, 0, 0, 0, 0, 0);
191
192 RICOH_PDATA_INIT(ldo3, 0,         1000, 3300, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0);
193 RICOH_PDATA_INIT(ldo4, 0,         750,  1500, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0);
194 RICOH_PDATA_INIT(ldo5, 0,         1000, 3300, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0);
195
196 RICOH_PDATA_INIT(ldo6, 0,         1200, 1200, ricoh583_rails(DC2), 0, 0, 1, -1, 0, 0, 0, 0, 0);
197 RICOH_PDATA_INIT(ldo7, 0,         1200, 1200, ricoh583_rails(DC2), 1, 1, 1, -1, 0, 0, 0, 0, 0);
198 RICOH_PDATA_INIT(ldo8, 0,         900, 3400, ricoh583_rails(DC2), 1, 0, 0, -1, 0, 0, 0, 0, 0);
199
200 static struct ricoh583_rtc_platform_data rtc_data = {
201         .irq = TEGRA_NR_IRQS + RICOH583_IRQ_YALE,
202         .time = {
203                 .tm_year = 2011,
204                 .tm_mon = 0,
205                 .tm_mday = 1,
206                 .tm_hour = 0,
207                 .tm_min = 0,
208                 .tm_sec = 0,
209         },
210 };
211
212 #define RICOH_RTC_REG()                         \
213 {                                               \
214         .id     = 0,                            \
215         .name   = "rtc_ricoh583",               \
216         .platform_data = &rtc_data,             \
217 }
218
219 #define RICOH_REG(_id, _name, _sname)                   \
220 {                                                       \
221         .id     = RICOH583_ID_##_id,                    \
222         .name   = "ricoh583-regulator",                 \
223         .platform_data  = &pdata_##_name##_##_sname,    \
224 }
225
226 #define RICOH583_DEV_COMMON_E118X               \
227         RICOH_REG(DC0, dc0, 0),                 \
228         RICOH_REG(DC1, dc1, skubit0_0),         \
229         RICOH_REG(DC2, dc2, 0),         \
230         RICOH_REG(DC3, dc3, 0),         \
231         RICOH_REG(LDO0, ldo8, 0),               \
232         RICOH_REG(LDO1, ldo7, 0),               \
233         RICOH_REG(LDO2, ldo6, 0),               \
234         RICOH_REG(LDO3, ldo5, 0),               \
235         RICOH_REG(LDO4, ldo4, 0),               \
236         RICOH_REG(LDO5, ldo3, 0),               \
237         RICOH_REG(LDO6, ldo0, 0),               \
238         RICOH_REG(LDO7, ldo1, 0),               \
239         RICOH_REG(LDO8, ldo2, 0),               \
240         RICOH_RTC_REG()
241
242 static struct ricoh583_subdev_info ricoh_devs_e118x_dcdc[] = {
243         RICOH583_DEV_COMMON_E118X,
244 };
245
246 #define RICOH_GPIO_INIT(_init_apply, _pulldn, _output_mode, _output_val) \
247         {                                       \
248                 .pulldn_en = _pulldn,           \
249                 .output_mode_en = _output_mode, \
250                 .output_val = _output_val,      \
251                 .init_apply = _init_apply,      \
252         }
253 struct ricoh583_gpio_init_data ricoh_gpio_data[] = {
254         RICOH_GPIO_INIT(false, false, false, 0),
255         RICOH_GPIO_INIT(false, false, false, 0),
256         RICOH_GPIO_INIT(false, false, false, 0),
257         RICOH_GPIO_INIT(true,  false,  true, 1),
258         RICOH_GPIO_INIT(true,  false, true, 1),
259         RICOH_GPIO_INIT(false, false, false, 0),
260         RICOH_GPIO_INIT(false, false, false, 0),
261         RICOH_GPIO_INIT(false, false, false, 0),
262 };
263
264 static struct ricoh583_platform_data ricoh_platform = {
265         .irq_base       = RICOH583_IRQ_BASE,
266         .gpio_base      = RICOH583_GPIO_BASE,
267         .gpio_init_data = ricoh_gpio_data,
268         .num_gpioinit_data = ARRAY_SIZE(ricoh_gpio_data),
269         .enable_shutdown_pin = true,
270 };
271
272 static struct i2c_board_info __initdata ricoh583_regulators[] = {
273         {
274                 I2C_BOARD_INFO("ricoh583", 0x34),
275                 .irq            = INT_EXTERNAL_PMU,
276                 .platform_data  = &ricoh_platform,
277         },
278 };
279
280 /* TPS62361B DC-DC converter */
281 static struct regulator_consumer_supply tps62361_dcdc_supply[] = {
282         REGULATOR_SUPPLY("vdd_core", NULL),
283 };
284
285 static struct tps62360_regulator_platform_data tps62361_pdata = {
286         .reg_init_data = {                                      \
287                 .constraints = {                                \
288                         .min_uV = 500000,                       \
289                         .max_uV = 1770000,                      \
290                         .valid_modes_mask = (REGULATOR_MODE_NORMAL |  \
291                                              REGULATOR_MODE_STANDBY), \
292                         .valid_ops_mask = (REGULATOR_CHANGE_MODE |    \
293                                            REGULATOR_CHANGE_STATUS |  \
294                                            REGULATOR_CHANGE_VOLTAGE), \
295                         .always_on = 1,                         \
296                         .boot_on =  1,                          \
297                         .apply_uV = 0,                          \
298                 },                                              \
299                 .num_consumer_supplies = ARRAY_SIZE(tps62361_dcdc_supply), \
300                 .consumer_supplies = tps62361_dcdc_supply,      \
301                 },                                              \
302         .en_discharge = true,                                   \
303         .vsel0_gpio = -1,                                       \
304         .vsel1_gpio = -1,                                       \
305         .vsel0_def_state = 1,                                   \
306         .vsel1_def_state = 1,                                   \
307 };
308
309 static struct i2c_board_info __initdata tps62361_boardinfo[] = {
310         {
311                 I2C_BOARD_INFO("tps62361", 0x60),
312                 .platform_data  = &tps62361_pdata,
313         },
314 };
315
316 int __init cardhu_pm299_regulator_init(void)
317 {
318         struct board_info board_info;
319         struct board_info pmu_board_info;
320         void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE);
321         u32 pmc_ctrl;
322
323         /* configure the power management controller to trigger PMU
324          * interrupts when low */
325         pmc_ctrl = readl(pmc + PMC_CTRL);
326         writel(pmc_ctrl | PMC_CTRL_INTR_LOW, pmc + PMC_CTRL);
327
328         /* The regulator details have complete constraints */
329         tegra_get_board_info(&board_info);
330         tegra_get_pmu_board_info(&pmu_board_info);
331         if (pmu_board_info.board_id != BOARD_PMU_PM299) {
332                 pr_err("%s(): Board ID is not proper\n", __func__);
333                 return -ENODEV;
334         }
335
336         /* If TPS6236x DCDC is there then consumer for dc1 should
337          * not have vdd_core */
338         if ((board_info.sku & SKU_DCDC_TPS62361_SUPPORT) ||
339                         (pmu_board_info.sku & SKU_DCDC_TPS62361_SUPPORT)) {
340                 pdata_dc1_skubit0_0.regulator.consumer_supplies =
341                                         ricoh583_dc1_supply_skubit0_1;
342                 pdata_dc1_skubit0_0.regulator.num_consumer_supplies =
343                                 ARRAY_SIZE(ricoh583_dc1_supply_skubit0_1);
344         }
345
346         ricoh_platform.num_subdevs = ARRAY_SIZE(ricoh_devs_e118x_dcdc);
347         ricoh_platform.subdevs = ricoh_devs_e118x_dcdc;
348
349         i2c_register_board_info(4, ricoh583_regulators, 1);
350
351         /* Register the TPS6236x for all boards whose sku bit 0 is set. */
352         if ((board_info.sku & SKU_DCDC_TPS62361_SUPPORT) ||
353                         (pmu_board_info.sku & SKU_DCDC_TPS62361_SUPPORT)) {
354                 pr_info("Registering the device TPS62361\n");
355                 i2c_register_board_info(4, tps62361_boardinfo, 1);
356         }
357         return 0;
358 }
359
360 /* EN_5V_CP from PMU GP0 */
361 static struct regulator_consumer_supply fixed_reg_en_5v_cp_supply[] = {
362         REGULATOR_SUPPLY("vdd_5v0_sby", NULL),
363         REGULATOR_SUPPLY("vdd_hall", NULL),
364         REGULATOR_SUPPLY("vterm_ddr", NULL),
365         REGULATOR_SUPPLY("v2ref_ddr", NULL),
366 };
367
368 /* EN_5V0 From PMU GP2 */
369 static struct regulator_consumer_supply fixed_reg_en_5v0_supply[] = {
370         REGULATOR_SUPPLY("vdd_5v0_sys", NULL),
371 };
372
373 /* EN_DDR From PMU GP6 */
374 static struct regulator_consumer_supply fixed_reg_en_ddr_supply[] = {
375         REGULATOR_SUPPLY("mem_vddio_ddr", NULL),
376         REGULATOR_SUPPLY("t30_vddio_ddr", NULL),
377 };
378
379 /* EN_3V3_SYS From PMU GP7 */
380 static struct regulator_consumer_supply fixed_reg_en_3v3_sys_supply[] = {
381         REGULATOR_SUPPLY("vdd_lvds", NULL),
382         REGULATOR_SUPPLY("vdd_pnl", NULL),
383         REGULATOR_SUPPLY("vcom_3v3", NULL),
384         REGULATOR_SUPPLY("vdd_3v3", NULL),
385         REGULATOR_SUPPLY("vcore_mmc", NULL),
386         REGULATOR_SUPPLY("vddio_pex_ctl", NULL),
387         REGULATOR_SUPPLY("pwrdet_pex_ctl", NULL),
388         REGULATOR_SUPPLY("hvdd_pex_pmu", NULL),
389         REGULATOR_SUPPLY("avdd_hdmi", NULL),
390         REGULATOR_SUPPLY("vpp_fuse", NULL),
391         REGULATOR_SUPPLY("avdd_usb", NULL),
392         REGULATOR_SUPPLY("vdd_ddr_rx", NULL),
393         REGULATOR_SUPPLY("vcore_nand", NULL),
394         REGULATOR_SUPPLY("hvdd_sata", NULL),
395         REGULATOR_SUPPLY("vddio_gmi_pmu", NULL),
396         REGULATOR_SUPPLY("pwrdet_nand", NULL),
397         REGULATOR_SUPPLY("avdd_cam1", NULL),
398         REGULATOR_SUPPLY("vdd_af", NULL),
399         REGULATOR_SUPPLY("avdd_cam2", NULL),
400         REGULATOR_SUPPLY("vdd_acc", NULL),
401         REGULATOR_SUPPLY("vdd_phtl", NULL),
402         REGULATOR_SUPPLY("vddio_tp", NULL),
403         REGULATOR_SUPPLY("vdd_led", NULL),
404         REGULATOR_SUPPLY("vddio_cec", NULL),
405         REGULATOR_SUPPLY("vdd_cmps", NULL),
406         REGULATOR_SUPPLY("vdd_temp", NULL),
407         REGULATOR_SUPPLY("vpp_kfuse", NULL),
408         REGULATOR_SUPPLY("vddio_ts", NULL),
409         REGULATOR_SUPPLY("vdd_ir_led", NULL),
410         REGULATOR_SUPPLY("vddio_1wire", NULL),
411         REGULATOR_SUPPLY("avddio_audio", NULL),
412         REGULATOR_SUPPLY("vdd_ec", NULL),
413         REGULATOR_SUPPLY("vcom_pa", NULL),
414         REGULATOR_SUPPLY("vdd_3v3_devices", NULL),
415         REGULATOR_SUPPLY("vdd_3v3_dock", NULL),
416         REGULATOR_SUPPLY("vdd_3v3_edid", NULL),
417         REGULATOR_SUPPLY("vdd_3v3_hdmi_cec", NULL),
418         REGULATOR_SUPPLY("vdd_3v3_gmi", NULL),
419         REGULATOR_SUPPLY("vdd_3v3_spk_amp", NULL),
420         REGULATOR_SUPPLY("vdd_3v3_sensor", NULL),
421         REGULATOR_SUPPLY("vdd_3v3_cam", NULL),
422         REGULATOR_SUPPLY("vdd_3v3_als", NULL),
423         REGULATOR_SUPPLY("debug_cons", NULL),
424 };
425
426 /* DIS_5V_SWITCH from AP SPI2_SCK X02 */
427 static struct regulator_consumer_supply fixed_reg_dis_5v_switch_supply[] = {
428         REGULATOR_SUPPLY("master_5v_switch", NULL),
429 };
430
431 /* EN_VDD_BL */
432 static struct regulator_consumer_supply fixed_reg_en_vdd_bl_supply[] = {
433         REGULATOR_SUPPLY("vdd_backlight", NULL),
434         REGULATOR_SUPPLY("vdd_backlight1", NULL),
435 };
436
437 /* EN_3V3_MODEM from AP GPIO VI_VSYNCH D06*/
438 static struct regulator_consumer_supply fixed_reg_en_3v3_modem_supply[] = {
439         REGULATOR_SUPPLY("vdd_3v3_mini_card", NULL),
440         REGULATOR_SUPPLY("vdd_mini_card", NULL),
441 };
442
443 /* EN_VDD_PNL1 from AP GPIO VI_D6 L04*/
444 static struct regulator_consumer_supply fixed_reg_en_vdd_pnl1_supply[] = {
445         REGULATOR_SUPPLY("vdd_lcd_panel", NULL),
446 };
447
448 /* CAM1_LDO_EN from AP GPIO KB_ROW6 R06*/
449 static struct regulator_consumer_supply fixed_reg_cam1_ldo_en_supply[] = {
450         REGULATOR_SUPPLY("vdd_2v8_cam1", NULL),
451         REGULATOR_SUPPLY("avdd", "6-0072"),
452 };
453
454 /* CAM2_LDO_EN from AP GPIO KB_ROW7 R07*/
455 static struct regulator_consumer_supply fixed_reg_cam2_ldo_en_supply[] = {
456         REGULATOR_SUPPLY("vdd_2v8_cam2", NULL),
457         REGULATOR_SUPPLY("avdd", "7-0072"),
458 };
459
460 /* CAM3_LDO_EN from AP GPIO KB_ROW8 S00*/
461 static struct regulator_consumer_supply fixed_reg_cam3_ldo_en_supply[] = {
462         REGULATOR_SUPPLY("vdd_cam3", NULL),
463 };
464
465 /* EN_VDD_COM from AP GPIO SDMMC3_DAT5 D00*/
466 static struct regulator_consumer_supply fixed_reg_en_vdd_com_supply[] = {
467         REGULATOR_SUPPLY("vdd_com_bd", NULL),
468 };
469
470 /* EN_VDD_SDMMC1 from AP GPIO VI_HSYNC D07*/
471 static struct regulator_consumer_supply fixed_reg_en_vdd_sdmmc1_supply[] = {
472         REGULATOR_SUPPLY("vddio_sd_slot", "sdhci-tegra.0"),
473 };
474
475 /* EN_3V3_EMMC from AP GPIO SDMMC3_DAT4 D01*/
476 static struct regulator_consumer_supply fixed_reg_en_3v3_emmc_supply[] = {
477         REGULATOR_SUPPLY("vdd_emmc_core", NULL),
478 };
479
480 /* EN_3V3_PEX_HVDD from AP GPIO VI_D09 L07*/
481 static struct regulator_consumer_supply fixed_reg_en_3v3_pex_hvdd_supply[] = {
482         REGULATOR_SUPPLY("hvdd_pex", NULL),
483 };
484
485 /* EN_3v3_FUSE from AP GPIO VI_D08 L06*/
486 static struct regulator_consumer_supply fixed_reg_en_3v3_fuse_supply[] = {
487         REGULATOR_SUPPLY("vdd_fuse", NULL),
488 };
489
490 /* EN_1V8_CAM from AP GPIO GPIO_PBB4 PBB04*/
491 static struct regulator_consumer_supply fixed_reg_en_1v8_cam_supply[] = {
492         REGULATOR_SUPPLY("vdd_1v8_cam1", NULL),
493         REGULATOR_SUPPLY("vdd_1v8_cam2", NULL),
494         REGULATOR_SUPPLY("vdd_1v8_cam3", NULL),
495         REGULATOR_SUPPLY("dvdd", "6-0072"),
496         REGULATOR_SUPPLY("dvdd", "7-0072"),
497         REGULATOR_SUPPLY("vdd_i2c", "2-0033"),
498 };
499
500 static struct regulator_consumer_supply fixed_reg_en_vbrtr_supply[] = {
501         REGULATOR_SUPPLY("vdd_vbrtr", NULL),
502 };
503
504
505 /* EN_USB1_VBUS_OC*/
506 static struct regulator_consumer_supply fixed_reg_en_usb1_vbus_oc_supply[] = {
507         REGULATOR_SUPPLY("vdd_vbus_micro_usb", NULL),
508 };
509
510 /*EN_USB3_VBUS_OC*/
511 static struct regulator_consumer_supply fixed_reg_en_usb3_vbus_oc_supply[] = {
512         REGULATOR_SUPPLY("vdd_vbus_typea_usb", NULL),
513 };
514
515 /* EN_VDDIO_VID_OC from AP GPIO VI_PCLK T00*/
516 static struct regulator_consumer_supply fixed_reg_en_vddio_vid_oc_supply[] = {
517         REGULATOR_SUPPLY("vdd_hdmi_con", NULL),
518 };
519
520 /* Macro for defining fixed regulator sub device data */
521 #define FIXED_SUPPLY(_name) "fixed_reg_"#_name
522 #define FIXED_REG_OD(_id, _var, _name, _in_supply, _always_on, _boot_on,      \
523                  _gpio_nr, _active_high, _boot_state, _millivolts, _od_state) \
524         static struct regulator_init_data ri_data_##_var =              \
525         {                                                               \
526                 .supply_regulator = _in_supply,                         \
527                 .num_consumer_supplies =                                \
528                         ARRAY_SIZE(fixed_reg_##_name##_supply),         \
529                 .consumer_supplies = fixed_reg_##_name##_supply,        \
530                 .constraints = {                                        \
531                         .valid_modes_mask = (REGULATOR_MODE_NORMAL |    \
532                                         REGULATOR_MODE_STANDBY),        \
533                         .valid_ops_mask = (REGULATOR_CHANGE_MODE |      \
534                                         REGULATOR_CHANGE_STATUS |       \
535                                         REGULATOR_CHANGE_VOLTAGE),      \
536                         .always_on = _always_on,                        \
537                         .boot_on = _boot_on,                            \
538                 },                                                      \
539         };                                                              \
540         static struct fixed_voltage_config fixed_reg_##_var##_pdata =   \
541         {                                                               \
542                 .supply_name = FIXED_SUPPLY(_name),                     \
543                 .microvolts = _millivolts * 1000,                       \
544                 .gpio = _gpio_nr,                                       \
545                 .enable_high = _active_high,                            \
546                 .enabled_at_boot = _boot_state,                         \
547                 .init_data = &ri_data_##_var,                           \
548                 .gpio_is_open_drain = _od_state,                        \
549         };                                                              \
550         static struct platform_device fixed_reg_##_var##_dev = {        \
551                 .name   = "reg-fixed-voltage",                          \
552                 .id     = _id,                                          \
553                 .dev    = {                                             \
554                         .platform_data = &fixed_reg_##_var##_pdata,     \
555                 },                                                      \
556         }
557
558 #define FIXED_REG(_id, _var, _name, _in_supply, _always_on, _boot_on,   \
559                  _gpio_nr, _active_high, _boot_state, _millivolts)      \
560         FIXED_REG_OD(_id, _var, _name, _in_supply, _always_on, _boot_on, \
561                  _gpio_nr, _active_high, _boot_state, _millivolts, false)
562
563 /* common to most of boards*/
564 FIXED_REG(0, en_5v_cp,          en_5v_cp,       NULL,                   1,      0,      TPS6591X_GPIO_0,        true,   1, 5000);
565 FIXED_REG(1, en_5v0,            en_5v0,         NULL,                   0,      0,      TPS6591X_GPIO_4,        true,   0, 5000);
566 FIXED_REG(2, en_ddr,            en_ddr,         NULL,                   0,      0,      TPS6591X_GPIO_3,        true,   1, 1500);
567 FIXED_REG(3, en_3v3_sys,        en_3v3_sys,     NULL,                   0,      0,      TPS6591X_GPIO_1,        true,   1, 3300);
568 FIXED_REG(4, en_vdd_bl,         en_vdd_bl,      NULL,                   0,      0,      TEGRA_GPIO_PK3,         true,   1, 5000);
569 FIXED_REG(5, en_3v3_modem,      en_3v3_modem,   NULL,                   1,      0,      TEGRA_GPIO_PD6,         true,   1, 3300);
570 FIXED_REG(6, en_vdd_pnl1,       en_vdd_pnl1,    FIXED_SUPPLY(en_3v3_sys),       0,      0,      TEGRA_GPIO_PL4,         true,   1, 3300);
571 FIXED_REG(7, cam3_ldo_en,       cam3_ldo_en,    FIXED_SUPPLY(en_3v3_sys),       0,      0,      TEGRA_GPIO_PS0,         true,   0, 3300);
572 FIXED_REG(8, en_vdd_com,        en_vdd_com,     FIXED_SUPPLY(en_3v3_sys),       1,      0,      TEGRA_GPIO_PD0,         true,   1, 3300);
573 FIXED_REG(9, en_3v3_fuse,       en_3v3_fuse,    FIXED_SUPPLY(en_3v3_sys),       0,      0,      TEGRA_GPIO_PL6,         true,   0, 3300);
574 FIXED_REG(10, en_3v3_emmc,      en_3v3_emmc,    FIXED_SUPPLY(en_3v3_sys),       1,      0,      TEGRA_GPIO_PD1,         true,   1, 3300);
575 FIXED_REG(11, en_vdd_sdmmc1,    en_vdd_sdmmc1,  FIXED_SUPPLY(en_3v3_sys),       0,      0,      TEGRA_GPIO_PD7,         true,   1, 3300);
576 FIXED_REG(12, en_3v3_pex_hvdd,  en_3v3_pex_hvdd, FIXED_SUPPLY(en_3v3_sys),      0,      0,      TEGRA_GPIO_PL7,         true,   0, 3300);
577 FIXED_REG(13, en_1v8_cam,       en_1v8_cam,     ricoh583_rails(DC2),            0,      0,      TEGRA_GPIO_PBB4,        true,   0, 1800);
578
579 /* E1198/E1291 specific*/
580 FIXED_REG(18, cam1_ldo_en,      cam1_ldo_en,    FIXED_SUPPLY(en_3v3_sys),       0,      0,      TEGRA_GPIO_PR6,         true,   0, 2800);
581 FIXED_REG(19, cam2_ldo_en,      cam2_ldo_en,    FIXED_SUPPLY(en_3v3_sys),       0,      0,      TEGRA_GPIO_PR7,         true,   0, 2800);
582 FIXED_REG(22, en_vbrtr,         en_vbrtr,       FIXED_SUPPLY(en_3v3_sys),       0,      0,      PMU_TCA6416_GPIO_PORT12,true,   0, 3300);
583
584 /*Specific to pm269*/
585 FIXED_REG(4, en_vdd_bl_pm269,           en_vdd_bl,              NULL,                           0,      0,      TEGRA_GPIO_PH3, true,   1, 5000);
586 FIXED_REG(6, en_vdd_pnl1_pm269,         en_vdd_pnl1,            FIXED_SUPPLY(en_3v3_sys),       0,      0,      TEGRA_GPIO_PW1, true,   1, 3300);
587 FIXED_REG(9, en_3v3_fuse_pm269,         en_3v3_fuse,            FIXED_SUPPLY(en_3v3_sys),       0,      0,      TEGRA_GPIO_PC1, true,   0, 3300);
588 FIXED_REG(11, en_vdd_sdmmc1_pm269,      en_vdd_sdmmc1,          FIXED_SUPPLY(en_3v3_sys),       0,      0,      TEGRA_GPIO_PP1, true,   1, 3300);
589 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);
590
591 /* Specific to E1187/E1186/E1256 */
592 FIXED_REG(14, dis_5v_switch_e118x,      dis_5v_switch,          FIXED_SUPPLY(en_5v0),           0,      0,      TEGRA_GPIO_PX2, false,  0, 5000);
593
594 /*** Open collector load switches ************/
595 /*Specific to pm269*/
596 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);
597
598 /* Specific to E1187/E1186/E1256 */
599 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);
600 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);
601 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);
602
603 /*
604  * Creating the fixed/gpio-switch regulator device tables for different boards
605  */
606 #define ADD_FIXED_REG(_name)    (&fixed_reg_##_name##_dev)
607
608 #define COMMON_FIXED_REG                        \
609         ADD_FIXED_REG(en_5v_cp),                \
610         ADD_FIXED_REG(en_5v0),                  \
611         ADD_FIXED_REG(en_ddr),                  \
612         ADD_FIXED_REG(en_3v3_sys),              \
613         ADD_FIXED_REG(en_3v3_modem),            \
614         ADD_FIXED_REG(en_vdd_pnl1),             \
615         ADD_FIXED_REG(cam1_ldo_en),             \
616         ADD_FIXED_REG(cam2_ldo_en),             \
617         ADD_FIXED_REG(cam3_ldo_en),             \
618         ADD_FIXED_REG(en_vdd_com),              \
619         ADD_FIXED_REG(en_3v3_fuse),             \
620         ADD_FIXED_REG(en_3v3_emmc),             \
621         ADD_FIXED_REG(en_vdd_sdmmc1),           \
622         ADD_FIXED_REG(en_3v3_pex_hvdd),         \
623         ADD_FIXED_REG(en_1v8_cam),
624
625 #define PM269_FIXED_REG                         \
626         ADD_FIXED_REG(en_5v_cp),                \
627         ADD_FIXED_REG(en_5v0),                  \
628         ADD_FIXED_REG(en_ddr),                  \
629         ADD_FIXED_REG(en_vdd_bl_pm269),         \
630         ADD_FIXED_REG(en_3v3_sys),              \
631         ADD_FIXED_REG(en_3v3_modem),            \
632         ADD_FIXED_REG(en_vdd_pnl1_pm269),       \
633         ADD_FIXED_REG(cam1_ldo_en),             \
634         ADD_FIXED_REG(cam2_ldo_en),             \
635         ADD_FIXED_REG(cam3_ldo_en),             \
636         ADD_FIXED_REG(en_vdd_com),              \
637         ADD_FIXED_REG(en_3v3_fuse_pm269),       \
638         ADD_FIXED_REG(en_3v3_emmc),             \
639         ADD_FIXED_REG(en_vdd_sdmmc1_pm269),     \
640         ADD_FIXED_REG(en_3v3_pex_hvdd_pm269),   \
641         ADD_FIXED_REG(en_1v8_cam),              \
642         ADD_FIXED_REG(dis_5v_switch_e118x),     \
643         ADD_FIXED_REG(en_usb1_vbus_oc_e118x),   \
644         ADD_FIXED_REG(en_usb3_vbus_oc_e118x),   \
645         ADD_FIXED_REG(en_vddio_vid_oc_pm269),
646
647 #define E118x_FIXED_REG                         \
648         ADD_FIXED_REG(en_vdd_bl),               \
649         ADD_FIXED_REG(dis_5v_switch_e118x),     \
650         ADD_FIXED_REG(en_vbrtr),                \
651         ADD_FIXED_REG(en_usb1_vbus_oc_e118x),   \
652         ADD_FIXED_REG(en_usb3_vbus_oc_e118x),   \
653         ADD_FIXED_REG(en_vddio_vid_oc_e118x),   \
654
655 /* Gpio switch regulator platform data  for E1186/E1187/E1256*/
656 static struct platform_device *fixed_reg_devs_e118x[] = {
657         COMMON_FIXED_REG
658         E118x_FIXED_REG
659 };
660
661 /* Gpio switch regulator platform data for PM269*/
662 static struct platform_device *fixed_reg_devs_pm269[] = {
663         PM269_FIXED_REG
664 };
665
666 int __init cardhu_pm299_gpio_switch_regulator_init(void)
667 {
668         struct board_info board_info;
669         struct platform_device **fixed_reg_devs;
670         int    nfixreg_devs;
671
672         tegra_get_board_info(&board_info);
673
674         switch (board_info.board_id) {
675         case BOARD_PM269:
676         case BOARD_PM305:
677         case BOARD_PM311:
678         case BOARD_E1257:
679                 nfixreg_devs = ARRAY_SIZE(fixed_reg_devs_pm269);
680                 fixed_reg_devs = fixed_reg_devs_pm269;
681                 break;
682
683         default:
684                 nfixreg_devs = ARRAY_SIZE(fixed_reg_devs_e118x);
685                 fixed_reg_devs = fixed_reg_devs_e118x;
686                 break;
687         }
688
689         return platform_add_devices(fixed_reg_devs, nfixreg_devs);
690 }