arm: regulator: gpio_switch: enable/disable of rail through board apis
[linux-2.6.git] / arch / arm / mach-tegra / board-cardhu-power.c
1 /*
2  * arch/arm/mach-tegra/board-cardhu-power.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/tps6591x.h>
26 #include <linux/gpio.h>
27 #include <mach/suspend.h>
28 #include <linux/io.h>
29 #include <linux/gpio-switch-regulator.h>
30
31 #include <mach/iomap.h>
32 #include <mach/irqs.h>
33 #include <mach/pinmux.h>
34
35 #include "gpio-names.h"
36 #include "board-cardhu.h"
37 #include "power.h"
38 #include "wakeups-t3.h"
39
40 #ifdef CONFIG_MFD_TPS6591X
41 static struct regulator_consumer_supply tps6591x_vdd1_supply[] = {
42         REGULATOR_SUPPLY("vdd_core", NULL),
43         REGULATOR_SUPPLY("en_vddio_ddr_1v2", NULL),
44 };
45
46 static struct regulator_consumer_supply tps6591x_vdd2_supply[] = {
47         REGULATOR_SUPPLY("vdd_gen1v5", NULL),
48         REGULATOR_SUPPLY("vcore_lcd", NULL),
49         REGULATOR_SUPPLY("track_ldo1", NULL),
50         REGULATOR_SUPPLY("external_ldo_1v2", NULL),
51         REGULATOR_SUPPLY("vcore_cam1", NULL),
52         REGULATOR_SUPPLY("vcore_cam2", NULL),
53 };
54
55 static struct regulator_consumer_supply tps6591x_vddctrl_supply[] = {
56         REGULATOR_SUPPLY("vdd_cpu_pmu", NULL),
57         REGULATOR_SUPPLY("vdd_cpu", NULL),
58         REGULATOR_SUPPLY("vdd_sys", NULL),
59 };
60
61 static struct regulator_consumer_supply tps6591x_vio_supply[] = {
62         REGULATOR_SUPPLY("vdd_gen1v8", NULL),
63         REGULATOR_SUPPLY("avdd_hdmi_pll", NULL),
64         REGULATOR_SUPPLY("avdd_usb_pll", NULL),
65         REGULATOR_SUPPLY("avdd_osc", NULL),
66         REGULATOR_SUPPLY("vddio_sys", NULL),
67         REGULATOR_SUPPLY("vddio_sdmmc4", NULL),
68         REGULATOR_SUPPLY("vdd1v8_satelite", NULL),
69         REGULATOR_SUPPLY("vddio_uart", NULL),
70         REGULATOR_SUPPLY("vddio_audio", NULL),
71         REGULATOR_SUPPLY("vddio_bb", NULL),
72         REGULATOR_SUPPLY("vddio_lcd_pmu", NULL),
73         REGULATOR_SUPPLY("vddio_cam", NULL),
74         REGULATOR_SUPPLY("vddio_vi", NULL),
75         REGULATOR_SUPPLY("ldo6", NULL),
76         REGULATOR_SUPPLY("ldo7", NULL),
77         REGULATOR_SUPPLY("ldo8", NULL),
78         REGULATOR_SUPPLY("vcore_audio", NULL),
79         REGULATOR_SUPPLY("avcore_audio", NULL),
80         REGULATOR_SUPPLY("vddio_sdmmc3", NULL),
81         REGULATOR_SUPPLY("vcore1_lpddr2", NULL),
82         REGULATOR_SUPPLY("vcom_1v8", NULL),
83         REGULATOR_SUPPLY("pmuio_1v8", NULL),
84         REGULATOR_SUPPLY("avdd_ic_usb", NULL),
85 };
86
87 static struct regulator_consumer_supply tps6591x_ldo1_supply[] = {
88         REGULATOR_SUPPLY("avdd_pexb", NULL),
89         REGULATOR_SUPPLY("vdd_pexb", NULL),
90         REGULATOR_SUPPLY("avdd_pex_pll", NULL),
91         REGULATOR_SUPPLY("avdd_pexa", NULL),
92         REGULATOR_SUPPLY("vdd_pexa", NULL),
93 };
94
95 static struct regulator_consumer_supply tps6591x_ldo2_supply[] = {
96         REGULATOR_SUPPLY("avdd_sata", NULL),
97         REGULATOR_SUPPLY("vdd_sata", NULL),
98         REGULATOR_SUPPLY("avdd_sata_pll", NULL),
99         REGULATOR_SUPPLY("avdd_plle", NULL),
100 };
101
102 static struct regulator_consumer_supply tps6591x_ldo3_supply[] = {
103         REGULATOR_SUPPLY("vddio_sdmmc1", NULL),
104 };
105
106 static struct regulator_consumer_supply tps6591x_ldo4_supply[] = {
107         REGULATOR_SUPPLY("vdd_rtc", NULL),
108 };
109
110 static struct regulator_consumer_supply tps6591x_ldo5_supply[] = {
111         REGULATOR_SUPPLY("avdd_vdac", NULL),
112 };
113 static struct regulator_consumer_supply tps6591x_ldo6_supply[] = {
114         REGULATOR_SUPPLY("avdd_dsi_csi", NULL),
115 };
116 static struct regulator_consumer_supply tps6591x_ldo7_supply[] = {
117         REGULATOR_SUPPLY("avdd_plla_p_c_s", NULL),
118         REGULATOR_SUPPLY("avdd_pllm", NULL),
119         REGULATOR_SUPPLY("avdd_pllu_d", NULL),
120         REGULATOR_SUPPLY("avdd_pllu_d2", NULL),
121         REGULATOR_SUPPLY("avdd_pllx", NULL),
122 };
123
124 static struct regulator_consumer_supply tps6591x_ldo8_supply[] = {
125         REGULATOR_SUPPLY("vdd_ddr_hs", NULL),
126 };
127
128 #define REGULATOR_INIT(_id, _minmv, _maxmv)                             \
129         {                                                               \
130                 .constraints = {                                        \
131                         .min_uV = (_minmv)*1000,                        \
132                         .max_uV = (_maxmv)*1000,                        \
133                         .valid_modes_mask = (REGULATOR_MODE_NORMAL |    \
134                                              REGULATOR_MODE_STANDBY),   \
135                         .valid_ops_mask = (REGULATOR_CHANGE_MODE |      \
136                                            REGULATOR_CHANGE_STATUS |    \
137                                            REGULATOR_CHANGE_VOLTAGE),   \
138                 },                                                      \
139                 .num_consumer_supplies = ARRAY_SIZE(tps6591x_##_id##_supply),\
140                 .consumer_supplies = tps6591x_##_id##_supply,           \
141         }
142
143 #define REGULATOR_INIT_SUPPLY(_id, _minmv, _maxmv, _supply_reg)         \
144         {                                                               \
145                 .constraints = {                                        \
146                         .min_uV = (_minmv)*1000,                        \
147                         .max_uV = (_maxmv)*1000,                        \
148                         .valid_modes_mask = (REGULATOR_MODE_NORMAL |    \
149                                              REGULATOR_MODE_STANDBY),   \
150                         .valid_ops_mask = (REGULATOR_CHANGE_MODE |      \
151                                            REGULATOR_CHANGE_STATUS |    \
152                                            REGULATOR_CHANGE_VOLTAGE),   \
153                 },                                                      \
154                 .num_consumer_supplies = ARRAY_SIZE(tps6591x_##_id##_supply),\
155                 .consumer_supplies = tps6591x_##_id##_supply,           \
156                 .supply_regulator = tps6591x_rails(_supply_reg),        \
157         }
158
159 static struct regulator_init_data vdd1_data = REGULATOR_INIT(vdd1, 600, 1500);
160 static struct regulator_init_data vdd2_data = REGULATOR_INIT(vdd2, 600, 1500);
161 static struct regulator_init_data vddctrl_data = REGULATOR_INIT(vddctrl, 600,
162                                                 1400);
163 static struct regulator_init_data vio_data = REGULATOR_INIT(vio, 1500, 3300);
164 static struct regulator_init_data ldo1_data = REGULATOR_INIT_SUPPLY(ldo1,
165                                                 1000, 3300, VDD_2);
166 static struct regulator_init_data ldo2_data = REGULATOR_INIT_SUPPLY(ldo2,
167                                                 1000, 3300, VDD_2);
168 static struct regulator_init_data ldo3_data = REGULATOR_INIT(ldo3, 1000, 3300);
169 static struct regulator_init_data ldo4_data = REGULATOR_INIT(ldo4, 1000, 3300);
170 static struct regulator_init_data ldo5_data = REGULATOR_INIT(ldo5, 1000, 3300);
171 static struct regulator_init_data ldo6_data = REGULATOR_INIT_SUPPLY(ldo6,
172                                                 1000, 3300, VIO);
173 static struct regulator_init_data ldo7_data = REGULATOR_INIT_SUPPLY(ldo7,
174                                                 1000, 3300, VIO);
175 static struct regulator_init_data ldo8_data = REGULATOR_INIT_SUPPLY(ldo8,
176                                                 1000, 3300, VIO);
177
178 static struct tps6591x_rtc_platform_data rtc_data = {
179         .irq = TEGRA_NR_IRQS + TPS6591X_INT_RTC_ALARM,
180 };
181
182 #define TPS_REG(_id, _data)                     \
183         {                                       \
184                 .id     = TPS6591X_ID_##_id,    \
185                 .name   = "tps6591x-regulator", \
186                 .platform_data  = _data,        \
187         }
188
189 static struct tps6591x_subdev_info tps_devs[] = {
190         TPS_REG(VIO, &vio_data),
191         TPS_REG(VDD_1, &vdd1_data),
192         TPS_REG(VDD_2, &vdd2_data),
193         TPS_REG(VDDCTRL, &vddctrl_data),
194         TPS_REG(LDO_1, &ldo1_data),
195         TPS_REG(LDO_2, &ldo2_data),
196         TPS_REG(LDO_3, &ldo3_data),
197         TPS_REG(LDO_4, &ldo4_data),
198         TPS_REG(LDO_5, &ldo5_data),
199         TPS_REG(LDO_6, &ldo6_data),
200         TPS_REG(LDO_7, &ldo7_data),
201         TPS_REG(LDO_8, &ldo8_data),
202         {
203                 .id     = 0,
204                 .name   = "tps6591x-rtc",
205                 .platform_data = &rtc_data,
206         },
207 };
208
209 static struct tps6591x_platform_data tps_platform = {
210         .irq_base       = TEGRA_NR_IRQS,
211         .num_subdevs    = ARRAY_SIZE(tps_devs),
212         .subdevs        = tps_devs,
213         .gpio_base      = TPS6591X_GPIO_BASE,
214 };
215
216 static struct i2c_board_info __initdata cardhu_regulators[] = {
217         {
218                 I2C_BOARD_INFO("tps6591x", 0x2D),
219                 .irq            = INT_EXTERNAL_PMU,
220                 .platform_data  = &tps_platform,
221         },
222 };
223
224 int __init cardhu_regulator_init(void)
225 {
226         i2c_register_board_info(4, cardhu_regulators, 1);
227         return 0;
228 }
229 #else
230 int __init cardhu_regulator_init(void)
231 {
232         return 0;
233 }
234 #endif
235
236 #ifdef CONFIG_REGULATOR_GPIO_SWITCH
237
238 /* EN_5V_CP from PMU GP0 */
239 static struct regulator_consumer_supply gpio_switch_en_5v_cp_supply[] = {
240         REGULATOR_SUPPLY("vdd_5v0_sby", NULL),
241         REGULATOR_SUPPLY("vdd_hall", NULL),
242         REGULATOR_SUPPLY("vterm_ddr", NULL),
243         REGULATOR_SUPPLY("v2ref_ddr", NULL),
244 };
245 static int gpio_switch_en_5v_cp_voltages[] = { 5000};
246
247 /* EN_5V0 From PMU GP2 */
248 static struct regulator_consumer_supply gpio_switch_en_5v0_supply[] = {
249         REGULATOR_SUPPLY("vdd_5v0_sys", NULL),
250 };
251 static int gpio_switch_en_5v0_voltages[] = { 5000};
252
253 /* EN_DDR From PMU GP6 */
254 static struct regulator_consumer_supply gpio_switch_en_ddr_supply[] = {
255         REGULATOR_SUPPLY("mem_vddio_ddr", NULL),
256         REGULATOR_SUPPLY("t30_vddio_ddr", NULL),
257 };
258 static int gpio_switch_en_ddr_voltages[] = { 1500};
259
260 /* EN_3V3_SYS From PMU GP7 */
261 static struct regulator_consumer_supply gpio_switch_en_3v3_sys_supply[] = {
262         REGULATOR_SUPPLY("vdd_lvds", NULL),
263         REGULATOR_SUPPLY("vdd_pnl", NULL),
264         REGULATOR_SUPPLY("vcom_3v3", NULL),
265         REGULATOR_SUPPLY("vdd_3v3", NULL),
266         REGULATOR_SUPPLY("vcore_mmc", NULL),
267         REGULATOR_SUPPLY("vddo_pex_ctl", NULL),
268         REGULATOR_SUPPLY("hvdd_pex", NULL),
269         REGULATOR_SUPPLY("avdd_hdmi", NULL),
270         REGULATOR_SUPPLY("vpp_fuse", NULL),
271         REGULATOR_SUPPLY("avdd_usb", NULL),
272         REGULATOR_SUPPLY("vdd_ddr_rx", NULL),
273         REGULATOR_SUPPLY("vcore_nand", NULL),
274         REGULATOR_SUPPLY("hvdd_sata", NULL),
275         REGULATOR_SUPPLY("vddio_gmi_pmu", NULL),
276         REGULATOR_SUPPLY("avdd_cam1", NULL),
277         REGULATOR_SUPPLY("vdd_af", NULL),
278         REGULATOR_SUPPLY("avdd_cam2", NULL),
279         REGULATOR_SUPPLY("vdd_acc", NULL),
280         REGULATOR_SUPPLY("vdd_phtl", NULL),
281         REGULATOR_SUPPLY("vddio_tp", NULL),
282         REGULATOR_SUPPLY("vdd_led", NULL),
283         REGULATOR_SUPPLY("vddio_cec", NULL),
284         REGULATOR_SUPPLY("vdd_cmps", NULL),
285         REGULATOR_SUPPLY("vdd_temp", NULL),
286         REGULATOR_SUPPLY("vpp_kfuse", NULL),
287         REGULATOR_SUPPLY("vddio_ts", NULL),
288         REGULATOR_SUPPLY("vdd_ir_led", NULL),
289         REGULATOR_SUPPLY("vddio_1wire", NULL),
290         REGULATOR_SUPPLY("avddio_audio", NULL),
291         REGULATOR_SUPPLY("vdd_ec", NULL),
292         REGULATOR_SUPPLY("vcom_pa", NULL),
293         REGULATOR_SUPPLY("vdd_3v3_devices", NULL),
294         REGULATOR_SUPPLY("vdd_3v3_dock", NULL),
295         REGULATOR_SUPPLY("debug_cons", NULL),
296 };
297 static int gpio_switch_en_3v3_sys_voltages[] = { 3300};
298
299 /* DIS_5V_SWITCH from AP SPI2_SCK X02 */
300 static struct regulator_consumer_supply gpio_switch_dis_5v_switch_supply[] = {
301         REGULATOR_SUPPLY("master_5v_switch", NULL),
302 };
303 static int gpio_switch_dis_5v_switch_voltages[] = { 5000};
304
305 /* EN_VDD_BL from AP GPIO GMI_CS2  K03 */
306 static struct regulator_consumer_supply gpio_switch_en_vdd_bl_supply[] = {
307         REGULATOR_SUPPLY("vdd_backlight", NULL),
308 };
309 static int gpio_switch_en_vdd_bl_voltages[] = { 5000};
310
311 /* EN_3V3_MODEM from AP GPIO VI_VSYNCH D06*/
312 static struct regulator_consumer_supply gpio_switch_en_3v3_modem_supply[] = {
313         REGULATOR_SUPPLY("vdd_3v3_mini_card", NULL),
314         REGULATOR_SUPPLY("vdd_mini_card", NULL),
315 };
316 static int gpio_switch_en_3v3_modem_voltages[] = { 3300};
317
318 /* EN_USB1_VBUS_OC from AP GPIO GMI_RST I04*/
319 static struct regulator_consumer_supply gpio_switch_en_usb1_vbus_oc_supply[] = {
320         REGULATOR_SUPPLY("vdd_vbus_micro_usb", NULL),
321 };
322 static int gpio_switch_en_usb1_vbus_oc_voltages[] = { 5000};
323
324 /*EN_USB3_VBUS_OC from AP GPIO GMI_AD15 H07*/
325 static struct regulator_consumer_supply gpio_switch_en_usb3_vbus_oc_supply[] = {
326         REGULATOR_SUPPLY("vdd_vbus_typea_usb", NULL),
327 };
328 static int gpio_switch_en_usb3_vbus_oc_voltages[] = { 5000};
329
330 /* EN_VDDIO_VID_OC from AP GPIO VI_PCLK T00*/
331 static struct regulator_consumer_supply gpio_switch_en_vddio_vid_oc_supply[] = {
332         REGULATOR_SUPPLY("vdd_hdmi_con", NULL),
333 };
334 static int gpio_switch_en_vddio_vid_oc_voltages[] = { 5000};
335
336 /* EN_VDD_PNL1 from AP GPIO VI_D6 L04*/
337 static struct regulator_consumer_supply gpio_switch_en_vdd_pnl1_supply[] = {
338         REGULATOR_SUPPLY("vdd_lcd_panel", NULL),
339 };
340 static int gpio_switch_en_vdd_pnl1_voltages[] = { 3300};
341
342 /* CAM3_LDO_EN from AP GPIO KB_ROW8 S00*/
343 static struct regulator_consumer_supply gpio_switch_cam3_ldo_en_supply[] = {
344         REGULATOR_SUPPLY("vdd_cam3", NULL),
345 };
346 static int gpio_switch_cam3_ldo_en_voltages[] = { 3300};
347
348 /* EN_VDD_COM from AP GPIO SDMMC3_DAT5 D00*/
349 static struct regulator_consumer_supply gpio_switch_en_vdd_com_supply[] = {
350         REGULATOR_SUPPLY("vdd_com_bd", NULL),
351 };
352 static int gpio_switch_en_vdd_com_voltages[] = { 3300};
353
354 /* EN_VDD_SDMMC1 from AP GPIO VI_HSYNC D07*/
355 static struct regulator_consumer_supply gpio_switch_en_vdd_sdmmc1_supply[] = {
356         REGULATOR_SUPPLY("vddio_sd_slot", NULL),
357 };
358 static int gpio_switch_en_vdd_sdmmc1_voltages[] = { 3300};
359
360 /* EN_3V3_EMMC from AP GPIO SDMMC3_DAT4 D01*/
361 static struct regulator_consumer_supply gpio_switch_en_3v3_emmc_supply[] = {
362         REGULATOR_SUPPLY("vdd_emmc_core", NULL),
363 };
364 static int gpio_switch_en_3v3_emmc_voltages[] = { 3300};
365
366 /* EN_3V3_PEX_HVDD from AP GPIO VI_D09 L07*/
367 static struct regulator_consumer_supply gpio_switch_en_3v3_pex_hvdd_supply[] = {
368         REGULATOR_SUPPLY("hvdd_pex_3v3", NULL),
369 };
370 static int gpio_switch_en_3v3_pex_hvdd_voltages[] = { 3300};
371
372 /* EN_3v3_FUSE from AP GPIO VI_D08 L06*/
373 static struct regulator_consumer_supply gpio_switch_en_3v3_fuse_supply[] = {
374         REGULATOR_SUPPLY("vpp_fuse_pg", NULL),
375 };
376 static int gpio_switch_en_3v3_fuse_voltages[] = { 3300};
377
378 /* EN_1V8_CAM from AP GPIO GPIO_PBB4 PBB04*/
379 static struct regulator_consumer_supply gpio_switch_en_1v8_cam_supply[] = {
380         REGULATOR_SUPPLY("vdd_1v8_cam1", NULL),
381         REGULATOR_SUPPLY("vdd_1v8_cam2", NULL),
382         REGULATOR_SUPPLY("vdd_1v8_cam3", NULL),
383 };
384 static int gpio_switch_en_1v8_cam_voltages[] = { 1800};
385
386 static int enable_load_switch_rail(
387                 struct gpio_switch_regulator_platform_data *pdata)
388 {
389         int ret;
390
391         if (pdata->pin_group <= 0)
392                 return -EINVAL;
393
394         /* Tristate and make pin as input*/
395         ret = tegra_pinmux_set_tristate(pdata->pin_group, TEGRA_TRI_TRISTATE);
396         if (ret < 0)
397                 return ret;
398         return gpio_direction_input(pdata->gpio_nr);
399 }
400
401 static int disable_load_switch_rail(
402                 struct gpio_switch_regulator_platform_data *pdata)
403 {
404         int ret;
405
406         if (pdata->pin_group <= 0)
407                 return -EINVAL;
408
409         /* Un-tristate and driver low */
410         ret = tegra_pinmux_set_tristate(pdata->pin_group, TEGRA_TRI_NORMAL);
411         if (ret < 0)
412                 return ret;
413         return gpio_direction_output(pdata->gpio_nr, 0);
414 }
415
416 /* Macro for defining gpio switch regulator platform data and device */
417 #define GPIO_REGULATOR_PINIT(_id, _name, _input_supply, _gpio_nr, _active_low, _init_state, _pg, _enable, _disable) \
418         static struct gpio_switch_regulator_platform_data               \
419                                 gpio_switch_regulator_##_name##_pdata = { \
420                 .regulator_name = "gpio-switch-"#_name,                 \
421                 .input_supply   = _input_supply,                        \
422                 .id             = _id,                                  \
423                 .gpio_nr        = _gpio_nr,                             \
424                 .pin_group      = _pg,                                  \
425                 .active_low     = _active_low,                          \
426                 .init_state     = _init_state,                          \
427                 .voltages       = gpio_switch_##_name##_voltages,       \
428                 .n_voltages     = ARRAY_SIZE(gpio_switch_##_name##_voltages), \
429                 .num_consumer_supplies =                                \
430                                 ARRAY_SIZE(gpio_switch_##_name##_supply), \
431                 .consumer_supplies = gpio_switch_##_name##_supply,      \
432                 .constraints = {                                        \
433                         .valid_modes_mask = (REGULATOR_MODE_NORMAL |    \
434                                              REGULATOR_MODE_STANDBY),   \
435                         .valid_ops_mask = (REGULATOR_CHANGE_MODE |      \
436                                            REGULATOR_CHANGE_STATUS |    \
437                                            REGULATOR_CHANGE_VOLTAGE),   \
438                 },                                                      \
439                 .enable_rail = _enable,                                 \
440                 .disable_rail = _disable,                               \
441         };                                                              \
442                                                                         \
443         static struct platform_device gpio_switch_regulator_##_name = { \
444                 .name = "gpio-switch-regulator",                        \
445                 .id   = _id,                                            \
446                 .dev  = {                                               \
447                      .platform_data = &gpio_switch_regulator_##_name##_pdata,\
448                 },                                                      \
449         };
450
451 /* Gpio switch regulator platform data */
452 GPIO_REGULATOR_PINIT(0, en_5v_cp,   NULL, TPS6591X_GPIO_GP0, false, 0, 0, 0, 0)
453 GPIO_REGULATOR_PINIT(1, en_5v0,     NULL, TPS6591X_GPIO_GP2, false, 0, 0, 0, 0)
454 GPIO_REGULATOR_PINIT(2, en_ddr,     NULL, TPS6591X_GPIO_GP6, false, 0, 0, 0, 0)
455 GPIO_REGULATOR_PINIT(3, en_3v3_sys, NULL, TPS6591X_GPIO_GP7, false, 0, 0, 0, 0)
456
457 GPIO_REGULATOR_PINIT(4, dis_5v_switch,   "vdd_5v0_sys", TEGRA_GPIO_PX2,
458                         true, 0, 0, 0, 0)
459 GPIO_REGULATOR_PINIT(5, en_vdd_bl,       NULL,          TEGRA_GPIO_PK3,
460                         false, 1, 0, 0, 0)
461 GPIO_REGULATOR_PINIT(6, en_3v3_modem,    NULL,          TEGRA_GPIO_PD6,
462                         false, 0, 0, 0, 0)
463 GPIO_REGULATOR_PINIT(7, en_usb1_vbus_oc, "master_5v_switch", TEGRA_GPIO_PI4,
464                         false, 0, TEGRA_PINGROUP_GMI_RST_N,
465                         enable_load_switch_rail, disable_load_switch_rail)
466 GPIO_REGULATOR_PINIT(8, en_usb3_vbus_oc, "master_5v_switch", TEGRA_GPIO_PH7,
467                         false, 0, TEGRA_PINGROUP_GMI_AD15,
468                         enable_load_switch_rail, disable_load_switch_rail)
469 GPIO_REGULATOR_PINIT(9, en_vddio_vid_oc, "master_5v_switch", TEGRA_GPIO_PT0,
470                         false, 0, TEGRA_PINGROUP_VI_PCLK,
471                         enable_load_switch_rail, disable_load_switch_rail)
472
473 GPIO_REGULATOR_PINIT(10, en_vdd_pnl1, "vdd_3v3_devices", TEGRA_GPIO_PL4,
474                         false, 1, 0, 0, 0)
475 GPIO_REGULATOR_PINIT(11, cam3_ldo_en, "vdd_3v3_devices", TEGRA_GPIO_PS0,
476                         false, 0, 0, 0, 0)
477 GPIO_REGULATOR_PINIT(12, en_vdd_com,  "vdd_3v3_devices", TEGRA_GPIO_PD0,
478                         false, 1, 0, 0, 0)
479 GPIO_REGULATOR_PINIT(13, en_3v3_fuse, "vdd_3v3_devices", TEGRA_GPIO_PL6,
480                         false, 0, 0, 0, 0)
481 GPIO_REGULATOR_PINIT(14, en_3v3_emmc, "vdd_3v3_devices", TEGRA_GPIO_PD1,
482                         false, 1, 0, 0, 0)
483 GPIO_REGULATOR_PINIT(15, en_vdd_sdmmc1, "vdd_3v3_devices", TEGRA_GPIO_PD7,
484                         false, 1, 0, 0, 0)
485 GPIO_REGULATOR_PINIT(16, en_3v3_pex_hvdd, "vdd_3v3_devices", TEGRA_GPIO_PL7,
486                         false, 0, 0, 0, 0)
487
488 GPIO_REGULATOR_PINIT(17, en_1v8_cam,  "vdd_gen1v8", TEGRA_GPIO_PBB4,
489                         false, 0, 0, 0, 0)
490
491 static struct platform_device *gpio_switch_regulator_devices[] __initdata = {
492         &gpio_switch_regulator_en_5v_cp,
493         &gpio_switch_regulator_en_5v0,
494         &gpio_switch_regulator_en_ddr,
495         &gpio_switch_regulator_en_3v3_sys,
496         &gpio_switch_regulator_dis_5v_switch,
497         &gpio_switch_regulator_en_vdd_bl,
498         &gpio_switch_regulator_en_3v3_modem,
499         &gpio_switch_regulator_en_usb1_vbus_oc,
500         &gpio_switch_regulator_en_usb3_vbus_oc,
501         &gpio_switch_regulator_en_vddio_vid_oc,
502         &gpio_switch_regulator_en_vdd_pnl1,
503         &gpio_switch_regulator_cam3_ldo_en,
504         &gpio_switch_regulator_en_vdd_com,
505         &gpio_switch_regulator_en_3v3_fuse,
506         &gpio_switch_regulator_en_3v3_emmc,
507         &gpio_switch_regulator_en_vdd_sdmmc1,
508         &gpio_switch_regulator_en_3v3_pex_hvdd,
509         &gpio_switch_regulator_en_1v8_cam,
510 };
511
512 int __init cardhu_gpio_switch_regulator_init(void)
513 {
514         int i;
515         struct gpio_switch_regulator_platform_data *pdata;
516         for (i = 0; i < ARRAY_SIZE(gpio_switch_regulator_devices); ++i) {
517                 pdata = gpio_switch_regulator_devices[i]->dev.platform_data;
518                 if (pdata->gpio_nr <= TEGRA_NR_GPIOS)
519                         tegra_gpio_enable(pdata->gpio_nr);
520         }
521
522         platform_add_devices(gpio_switch_regulator_devices,
523                                 ARRAY_SIZE(gpio_switch_regulator_devices));
524         return 0;
525 }
526 #else
527 int __init cardhu_gpio_switch_regulator_init(void)
528 {
529         return 0;
530 }
531 #endif
532
533 static struct tegra_suspend_platform_data cardhu_suspend_data = {
534         .cpu_timer      = 2000,
535         .cpu_off_timer  = 0,
536         .suspend_mode   = TEGRA_SUSPEND_NONE,
537         .core_timer     = 0x7e7e,
538         .core_off_timer = 0,
539         .separate_req   = true,
540         .corereq_high   = false,
541         .sysclkreq_high = true,
542         .wake_enb       = 0,
543         .wake_high      = 0,
544         .wake_low       = 0,
545         .wake_any       = 0,
546 };
547
548 int __init cardhu_suspend_init(void)
549 {
550         tegra_init_suspend(&cardhu_suspend_data);
551         return 0;
552
553 }