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