Revert "arm: tegra: cardhu: core related fixes for lp0"
[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/regulator/gpio-switch-regulator.h>
30 #include <linux/regulator/tps6591x-regulator.h>
31 #include <linux/regulator/tps6236x-regulator.h>
32
33 #include <mach/iomap.h>
34 #include <mach/irqs.h>
35 #include <mach/pinmux.h>
36 #include <mach/edp.h>
37
38 #include "gpio-names.h"
39 #include "board.h"
40 #include "board-cardhu.h"
41 #include "power.h"
42 #include "wakeups-t3.h"
43
44 #define PMC_CTRL                0x0
45 #define PMC_CTRL_INTR_LOW       (1 << 17)
46
47 static struct regulator_consumer_supply tps6591x_vdd1_supply_skubit0_0[] = {
48         REGULATOR_SUPPLY("vdd_core", NULL),
49         REGULATOR_SUPPLY("en_vddio_ddr_1v2", NULL),
50 };
51
52 static struct regulator_consumer_supply tps6591x_vdd1_supply_skubit0_1[] = {
53         REGULATOR_SUPPLY("en_vddio_ddr_1v2", NULL),
54 };
55
56 static struct regulator_consumer_supply tps6591x_vdd2_supply[] = {
57         REGULATOR_SUPPLY("vdd_gen1v5", NULL),
58         REGULATOR_SUPPLY("vcore_lcd", NULL),
59         REGULATOR_SUPPLY("track_ldo1", NULL),
60         REGULATOR_SUPPLY("external_ldo_1v2", NULL),
61         REGULATOR_SUPPLY("vcore_cam1", NULL),
62         REGULATOR_SUPPLY("vcore_cam2", NULL),
63 };
64
65 static struct regulator_consumer_supply tps6591x_vddctrl_supply[] = {
66         REGULATOR_SUPPLY("vdd_cpu_pmu", NULL),
67         REGULATOR_SUPPLY("vdd_cpu", NULL),
68         REGULATOR_SUPPLY("vdd_sys", NULL),
69 };
70
71 static struct regulator_consumer_supply tps6591x_vio_supply[] = {
72         REGULATOR_SUPPLY("vdd_gen1v8", NULL),
73         REGULATOR_SUPPLY("avdd_hdmi_pll", NULL),
74         REGULATOR_SUPPLY("avdd_usb_pll", NULL),
75         REGULATOR_SUPPLY("avdd_osc", NULL),
76         REGULATOR_SUPPLY("vddio_sys", NULL),
77         REGULATOR_SUPPLY("vddio_sdmmc4", NULL),
78         REGULATOR_SUPPLY("vdd1v8_satelite", NULL),
79         REGULATOR_SUPPLY("vddio_uart", NULL),
80         REGULATOR_SUPPLY("vddio_audio", NULL),
81         REGULATOR_SUPPLY("vddio_bb", NULL),
82         REGULATOR_SUPPLY("vddio_lcd_pmu", NULL),
83         REGULATOR_SUPPLY("vddio_cam", NULL),
84         REGULATOR_SUPPLY("vddio_vi", NULL),
85         REGULATOR_SUPPLY("ldo6", NULL),
86         REGULATOR_SUPPLY("ldo7", NULL),
87         REGULATOR_SUPPLY("ldo8", NULL),
88         REGULATOR_SUPPLY("vcore_audio", NULL),
89         REGULATOR_SUPPLY("avcore_audio", NULL),
90         REGULATOR_SUPPLY("vddio_sdmmc3", NULL),
91         REGULATOR_SUPPLY("vcore1_lpddr2", NULL),
92         REGULATOR_SUPPLY("vcom_1v8", NULL),
93         REGULATOR_SUPPLY("pmuio_1v8", NULL),
94         REGULATOR_SUPPLY("avdd_ic_usb", NULL),
95 };
96
97 static struct regulator_consumer_supply tps6591x_ldo1_supply[] = {
98         REGULATOR_SUPPLY("avdd_pexb", NULL),
99         REGULATOR_SUPPLY("vdd_pexb", NULL),
100         REGULATOR_SUPPLY("avdd_pex_pll", NULL),
101         REGULATOR_SUPPLY("avdd_pexa", NULL),
102         REGULATOR_SUPPLY("vdd_pexa", NULL),
103 };
104
105 static struct regulator_consumer_supply tps6591x_ldo2_supply[] = {
106         REGULATOR_SUPPLY("avdd_sata", NULL),
107         REGULATOR_SUPPLY("vdd_sata", NULL),
108         REGULATOR_SUPPLY("avdd_sata_pll", NULL),
109         REGULATOR_SUPPLY("avdd_plle", NULL),
110 };
111
112 static struct regulator_consumer_supply tps6591x_ldo3_supply_e118x[] = {
113         REGULATOR_SUPPLY("vddio_sdmmc1", NULL),
114 };
115
116 static struct regulator_consumer_supply tps6591x_ldo3_supply_e1198[] = {
117         REGULATOR_SUPPLY("unused_rail_ldo3", NULL),
118 };
119
120 static struct regulator_consumer_supply tps6591x_ldo4_supply[] = {
121         REGULATOR_SUPPLY("vdd_rtc", NULL),
122 };
123
124 static struct regulator_consumer_supply tps6591x_ldo5_supply_e118x[] = {
125         REGULATOR_SUPPLY("avdd_vdac", NULL),
126 };
127
128 static struct regulator_consumer_supply tps6591x_ldo5_supply_e1198[] = {
129         REGULATOR_SUPPLY("avdd_vdac", NULL),
130         REGULATOR_SUPPLY("vddio_sdmmc1", NULL),
131 };
132
133 static struct regulator_consumer_supply tps6591x_ldo6_supply[] = {
134         REGULATOR_SUPPLY("avdd_dsi_csi", NULL),
135 };
136 static struct regulator_consumer_supply tps6591x_ldo7_supply[] = {
137         REGULATOR_SUPPLY("avdd_plla_p_c_s", NULL),
138         REGULATOR_SUPPLY("avdd_pllm", NULL),
139         REGULATOR_SUPPLY("avdd_pllu_d", NULL),
140         REGULATOR_SUPPLY("avdd_pllu_d2", NULL),
141         REGULATOR_SUPPLY("avdd_pllx", NULL),
142 };
143
144 static struct regulator_consumer_supply tps6591x_ldo8_supply[] = {
145         REGULATOR_SUPPLY("vdd_ddr_hs", NULL),
146 };
147
148 #define TPS_PDATA_INIT_SUPPLY(_id, _minmv, _maxmv, _supply_reg, _always_on, \
149         _boot_on, _apply_uv, _init_uV, _init_enable, _init_apply, _ectrl) \
150         static struct tps6591x_regulator_platform_data pdata_##_id =    \
151         {                                                               \
152                 .regulator = {                                          \
153                         .constraints = {                                \
154                                 .min_uV = (_minmv)*1000,                \
155                                 .max_uV = (_maxmv)*1000,                \
156                                 .valid_modes_mask = (REGULATOR_MODE_NORMAL |  \
157                                                      REGULATOR_MODE_STANDBY), \
158                                 .valid_ops_mask = (REGULATOR_CHANGE_MODE |    \
159                                                    REGULATOR_CHANGE_STATUS |  \
160                                                    REGULATOR_CHANGE_VOLTAGE), \
161                                 .always_on = _always_on,                \
162                                 .boot_on = _boot_on,                    \
163                                 .apply_uV = _apply_uv,                  \
164                         },                                              \
165                         .num_consumer_supplies =                        \
166                                 ARRAY_SIZE(tps6591x_##_id##_supply),    \
167                         .consumer_supplies = tps6591x_##_id##_supply,   \
168                         .supply_regulator = tps6591x_rails(_supply_reg), \
169                 },                                                      \
170                 .init_uV =  _init_uV * 1000,                            \
171                 .init_enable = _init_enable,                            \
172                 .init_apply = _init_apply,                              \
173                 .ectrl = _ectrl                                         \
174         }
175
176 #define TPS_PDATA_INIT(_id, _minmv, _maxmv, _supply_reg, _always_on,    \
177         _boot_on, _apply_uv, _init_uV, _init_enable, _init_apply, _ectrl) \
178         static struct tps6591x_regulator_platform_data pdata_##_id =    \
179         {                                                               \
180                 .regulator = {                                          \
181                         .constraints = {                                \
182                                 .min_uV = (_minmv)*1000,                \
183                                 .max_uV = (_maxmv)*1000,                \
184                                 .valid_modes_mask = (REGULATOR_MODE_NORMAL |  \
185                                                      REGULATOR_MODE_STANDBY), \
186                                 .valid_ops_mask = (REGULATOR_CHANGE_MODE |    \
187                                                    REGULATOR_CHANGE_STATUS |  \
188                                                    REGULATOR_CHANGE_VOLTAGE), \
189                                 .always_on = _always_on,                \
190                                 .boot_on = _boot_on,                    \
191                                 .apply_uV = _apply_uv,                  \
192                         },                                              \
193                         .num_consumer_supplies =                        \
194                                 ARRAY_SIZE(tps6591x_##_id##_supply),    \
195                         .consumer_supplies = tps6591x_##_id##_supply,   \
196                 },                                                      \
197                 .init_uV =  _init_uV * 1000,                            \
198                 .init_enable = _init_enable,                            \
199                 .init_apply = _init_apply,                              \
200                 .ectrl = _ectrl                                         \
201         }
202
203 #define TPS_PDATA_INIT_BOARD(_id, _board, _minmv, _maxmv, _supply_reg, _always_on,      \
204         _boot_on, _apply_uv, _init_uV, _init_enable, _init_apply, _ectrl) \
205         static struct tps6591x_regulator_platform_data pdata_##_id##_##_board = \
206         {                                                               \
207                 .regulator = {                                          \
208                         .constraints = {                                \
209                                 .min_uV = (_minmv)*1000,                \
210                                 .max_uV = (_maxmv)*1000,                \
211                                 .valid_modes_mask = (REGULATOR_MODE_NORMAL |  \
212                                                      REGULATOR_MODE_STANDBY), \
213                                 .valid_ops_mask = (REGULATOR_CHANGE_MODE |    \
214                                                    REGULATOR_CHANGE_STATUS |  \
215                                                    REGULATOR_CHANGE_VOLTAGE), \
216                                 .always_on = _always_on,                \
217                                 .boot_on = _boot_on,                    \
218                                 .apply_uV = _apply_uv,                  \
219                         },                                              \
220                         .num_consumer_supplies =                        \
221                                 ARRAY_SIZE(tps6591x_##_id##_supply##_##_board),  \
222                         .consumer_supplies = tps6591x_##_id##_supply##_##_board, \
223                 },                                                      \
224                 .init_uV =  _init_uV * 1000,                            \
225                 .init_enable = _init_enable,                            \
226                 .init_apply = _init_apply,                              \
227                 .ectrl = _ectrl                                         \
228         }
229
230 TPS_PDATA_INIT_BOARD(vdd1, skubit0_0, 600, 1500, 0, 1, 1, 0, -1, 0, 0, 0);
231 TPS_PDATA_INIT_BOARD(vdd1, skubit0_1, 600, 1500, 0, 1, 1, 0, -1, 0, 0, 0);
232 TPS_PDATA_INIT(vdd2,    600, 1500, 0, 1, 1, 0, -1, 0, 0, 0);
233 TPS_PDATA_INIT(vddctrl, 600, 1400, 0, 1, 1, 0, -1, 0, 0, EXT_CTRL_EN1);
234 TPS_PDATA_INIT(vio,    1500, 3300, 0, 1, 1, 0, -1, 0, 0, 0);
235
236 TPS_PDATA_INIT_SUPPLY(ldo1, 1000, 3300, VDD_2, 0, 0, 0, -1, 0, 1, 0);
237 TPS_PDATA_INIT_SUPPLY(ldo2, 1000, 3300, VDD_2, 0, 0, 0, -1, 0, 1, 0);
238
239 TPS_PDATA_INIT_BOARD(ldo3, e118x, 1000, 3300, 0, 0, 0, 0, -1, 0, 0, 0);
240 TPS_PDATA_INIT_BOARD(ldo3, e1198, 1000, 3300, 0, 0, 0, 0, -1, 0, 0, 0);
241 TPS_PDATA_INIT(ldo4, 1000, 3300, 0, 0, 0, 0, -1, 0, 0, 0);
242 TPS_PDATA_INIT_BOARD(ldo5, e118x, 1000, 3300, 0, 0, 0, 0, -1, 0, 0, 0);
243 TPS_PDATA_INIT_BOARD(ldo5, e1198, 1000, 3300, 0, 0, 0, 0, -1, 0, 0, 0);
244
245 TPS_PDATA_INIT_SUPPLY(ldo6, 1000, 3300, VIO, 0, 0, 0, -1, 0, 0, 0);
246 TPS_PDATA_INIT_SUPPLY(ldo7, 1000, 3300, VIO, 0, 0, 0, -1, 0, 0, 0);
247 TPS_PDATA_INIT_SUPPLY(ldo8, 1000, 3300, VIO, 0, 0, 0, -1, 0, 0, 0);
248
249 #if defined(CONFIG_RTC_DRV_TPS6591x)
250 static struct tps6591x_rtc_platform_data rtc_data = {
251         .irq = TEGRA_NR_IRQS + TPS6591X_INT_RTC_ALARM,
252         .time = {
253                 .tm_year = 2000,
254                 .tm_mon = 0,
255                 .tm_mday = 1,
256                 .tm_hour = 0,
257                 .tm_min = 0,
258                 .tm_sec = 0,
259         },
260 };
261
262 #define TPS_RTC_REG()                           \
263         {                                               \
264                 .id     = 0,            \
265                 .name   = "rtc_tps6591x",       \
266                 .platform_data = &rtc_data,     \
267         }
268 #endif
269
270 #define TPS_REG(_id, _data)                             \
271         {                                               \
272                 .id     = TPS6591X_ID_##_id,            \
273                 .name   = "tps6591x-regulator",         \
274                 .platform_data  = &pdata_##_data,       \
275         }
276
277 #define TPS6591X_DEV_COMMON_E118X \
278         TPS_REG(VDD_2, vdd2),           \
279         TPS_REG(VDDCTRL, vddctrl),      \
280         TPS_REG(LDO_1, ldo1),           \
281         TPS_REG(LDO_2, ldo2),           \
282         TPS_REG(LDO_3, ldo3_e118x),     \
283         TPS_REG(LDO_4, ldo4),           \
284         TPS_REG(LDO_5, ldo5_e118x),     \
285         TPS_REG(LDO_6, ldo6),           \
286         TPS_REG(LDO_7, ldo7),           \
287         TPS_REG(LDO_8, ldo8)
288
289 static struct tps6591x_subdev_info tps_devs_e118x_skubit0_0[] = {
290         TPS_REG(VIO, vio),
291         TPS_REG(VDD_1, vdd1_skubit0_0),
292         TPS6591X_DEV_COMMON_E118X,
293 #if defined(CONFIG_RTC_DRV_TPS6591x)
294         TPS_RTC_REG(),
295 #endif
296 };
297
298 static struct tps6591x_subdev_info tps_devs_e118x_skubit0_1[] = {
299         TPS_REG(VIO, vio),
300         TPS_REG(VDD_1, vdd1_skubit0_1),
301         TPS6591X_DEV_COMMON_E118X,
302 #if defined(CONFIG_RTC_DRV_TPS6591x)
303         TPS_RTC_REG(),
304 #endif
305 };
306
307 #define TPS6591X_DEV_COMMON_CARDHU      \
308         TPS_REG(VDD_2, vdd2),           \
309         TPS_REG(VDDCTRL, vddctrl),      \
310         TPS_REG(LDO_1, ldo1),           \
311         TPS_REG(LDO_2, ldo2),           \
312         TPS_REG(LDO_3, ldo3_e1198),     \
313         TPS_REG(LDO_4, ldo4),           \
314         TPS_REG(LDO_5, ldo5_e1198),     \
315         TPS_REG(LDO_6, ldo6),           \
316         TPS_REG(LDO_7, ldo7),           \
317         TPS_REG(LDO_8, ldo8)
318
319 static struct tps6591x_subdev_info tps_devs_e1198_skubit0_0[] = {
320         TPS_REG(VIO, vio),
321         TPS_REG(VDD_1, vdd1_skubit0_0),
322         TPS6591X_DEV_COMMON_CARDHU,
323 #if defined(CONFIG_RTC_DRV_TPS6591x)
324         TPS_RTC_REG(),
325 #endif
326 };
327
328 static struct tps6591x_subdev_info tps_devs_e1198_skubit0_1[] = {
329         TPS_REG(VIO, vio),
330         TPS_REG(VDD_1, vdd1_skubit0_1),
331         TPS6591X_DEV_COMMON_CARDHU,
332 #if defined(CONFIG_RTC_DRV_TPS6591x)
333         TPS_RTC_REG(),
334 #endif
335 };
336
337 static struct tps6591x_platform_data tps_platform = {
338         .irq_base       = TPS6591X_IRQ_BASE,
339         .gpio_base      = TPS6591X_GPIO_BASE,
340 };
341
342 static struct i2c_board_info __initdata cardhu_regulators[] = {
343         {
344                 I2C_BOARD_INFO("tps6591x", 0x2D),
345                 .irq            = INT_EXTERNAL_PMU,
346                 .platform_data  = &tps_platform,
347         },
348 };
349
350 /* TPS62361B DC-DC converter */
351 static struct regulator_consumer_supply tps6236x_dcdc_supply[] = {
352         REGULATOR_SUPPLY("vdd_core", NULL),
353 };
354
355 static struct tps6236x_regulator_platform_data tps6236x_pdata = {
356         .reg_init_data = {                                      \
357                 .constraints = {                                \
358                         .min_uV = 500000,                       \
359                         .max_uV = 1770000,                      \
360                         .valid_modes_mask = (REGULATOR_MODE_NORMAL |  \
361                                              REGULATOR_MODE_STANDBY), \
362                         .valid_ops_mask = (REGULATOR_CHANGE_MODE |    \
363                                            REGULATOR_CHANGE_STATUS |  \
364                                            REGULATOR_CHANGE_VOLTAGE), \
365                         .always_on = 1,                         \
366                         .boot_on =  1,                          \
367                         .apply_uV = 0,                          \
368                 },                                              \
369                 .num_consumer_supplies = ARRAY_SIZE(tps6236x_dcdc_supply), \
370                 .consumer_supplies = tps6236x_dcdc_supply,              \
371                 },                                                      \
372         .internal_pd_enable = 0,                                        \
373         .vsel = 3,                                                      \
374         .init_uV = -1,                                                  \
375         .init_apply = 0,                                                \
376 };
377
378 static struct i2c_board_info __initdata tps6236x_boardinfo[] = {
379         {
380                 I2C_BOARD_INFO("tps62361B", 0x60),
381                 .platform_data  = &tps6236x_pdata,
382         },
383 };
384
385 int __init cardhu_regulator_init(void)
386 {
387         struct board_info board_info;
388         void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE);
389         u32 pmc_ctrl;
390
391         /* configure the power management controller to trigger PMU
392          * interrupts when low */
393
394         pmc_ctrl = readl(pmc + PMC_CTRL);
395         writel(pmc_ctrl | PMC_CTRL_INTR_LOW, pmc + PMC_CTRL);
396
397         tegra_get_board_info(&board_info);
398         if ((board_info.board_id == BOARD_E1198) ||
399                 (board_info.board_id == BOARD_E1291)) {
400                 if ((board_info.sku & 1) == 1) {
401                         tps_platform.num_subdevs =
402                                         ARRAY_SIZE(tps_devs_e1198_skubit0_1);
403                         tps_platform.subdevs = tps_devs_e1198_skubit0_1;
404                 } else {
405                         tps_platform.num_subdevs =
406                                         ARRAY_SIZE(tps_devs_e1198_skubit0_0);
407                         tps_platform.subdevs = tps_devs_e1198_skubit0_0;
408                 }
409         } else {
410                 if ((board_info.sku & 1) == 1) {
411                         tps_platform.num_subdevs = ARRAY_SIZE(tps_devs_e118x_skubit0_1);
412                         tps_platform.subdevs = tps_devs_e118x_skubit0_1;
413                 } else {
414                         tps_platform.num_subdevs = ARRAY_SIZE(tps_devs_e118x_skubit0_0);
415                         tps_platform.subdevs = tps_devs_e118x_skubit0_0;
416                 }
417         }
418
419         i2c_register_board_info(4, cardhu_regulators, 1);
420
421         /* Resgister the TPS6236x for all boards whose sku bit 0 is set. */
422         if ((board_info.sku & 1) == 1) {
423                 pr_info("Registering the device TPS62361B\n");
424                 i2c_register_board_info(4, tps6236x_boardinfo, 1);
425         }
426         return 0;
427 }
428
429 /* EN_5V_CP from PMU GP0 */
430 static struct regulator_consumer_supply gpio_switch_en_5v_cp_supply[] = {
431         REGULATOR_SUPPLY("vdd_5v0_sby", NULL),
432         REGULATOR_SUPPLY("vdd_hall", NULL),
433         REGULATOR_SUPPLY("vterm_ddr", NULL),
434         REGULATOR_SUPPLY("v2ref_ddr", NULL),
435 };
436 static int gpio_switch_en_5v_cp_voltages[] = { 5000};
437
438 /* EN_5V0 From PMU GP2 */
439 static struct regulator_consumer_supply gpio_switch_en_5v0_supply[] = {
440         REGULATOR_SUPPLY("vdd_5v0_sys", NULL),
441 };
442 static int gpio_switch_en_5v0_voltages[] = { 5000};
443
444 /* EN_DDR From PMU GP6 */
445 static struct regulator_consumer_supply gpio_switch_en_ddr_supply[] = {
446         REGULATOR_SUPPLY("mem_vddio_ddr", NULL),
447         REGULATOR_SUPPLY("t30_vddio_ddr", NULL),
448 };
449 static int gpio_switch_en_ddr_voltages[] = { 1500};
450
451 /* EN_3V3_SYS From PMU GP7 */
452 static struct regulator_consumer_supply gpio_switch_en_3v3_sys_supply[] = {
453         REGULATOR_SUPPLY("vdd_lvds", NULL),
454         REGULATOR_SUPPLY("vdd_pnl", NULL),
455         REGULATOR_SUPPLY("vcom_3v3", NULL),
456         REGULATOR_SUPPLY("vdd_3v3", NULL),
457         REGULATOR_SUPPLY("vcore_mmc", NULL),
458         REGULATOR_SUPPLY("vddio_pex_ctl", NULL),
459         REGULATOR_SUPPLY("hvdd_pex", NULL),
460         REGULATOR_SUPPLY("avdd_hdmi", NULL),
461         REGULATOR_SUPPLY("vpp_fuse", NULL),
462         REGULATOR_SUPPLY("avdd_usb", NULL),
463         REGULATOR_SUPPLY("vdd_ddr_rx", NULL),
464         REGULATOR_SUPPLY("vcore_nand", NULL),
465         REGULATOR_SUPPLY("hvdd_sata", NULL),
466         REGULATOR_SUPPLY("vddio_gmi_pmu", NULL),
467         REGULATOR_SUPPLY("avdd_cam1", NULL),
468         REGULATOR_SUPPLY("vdd_af", NULL),
469         REGULATOR_SUPPLY("avdd_cam2", NULL),
470         REGULATOR_SUPPLY("vdd_acc", NULL),
471         REGULATOR_SUPPLY("vdd_phtl", NULL),
472         REGULATOR_SUPPLY("vddio_tp", NULL),
473         REGULATOR_SUPPLY("vdd_led", NULL),
474         REGULATOR_SUPPLY("vddio_cec", NULL),
475         REGULATOR_SUPPLY("vdd_cmps", NULL),
476         REGULATOR_SUPPLY("vdd_temp", NULL),
477         REGULATOR_SUPPLY("vpp_kfuse", NULL),
478         REGULATOR_SUPPLY("vddio_ts", NULL),
479         REGULATOR_SUPPLY("vdd_ir_led", NULL),
480         REGULATOR_SUPPLY("vddio_1wire", NULL),
481         REGULATOR_SUPPLY("avddio_audio", NULL),
482         REGULATOR_SUPPLY("vdd_ec", NULL),
483         REGULATOR_SUPPLY("vcom_pa", NULL),
484         REGULATOR_SUPPLY("vdd_3v3_devices", NULL),
485         REGULATOR_SUPPLY("vdd_3v3_dock", NULL),
486         REGULATOR_SUPPLY("vdd_3v3_edid", NULL),
487         REGULATOR_SUPPLY("vdd_3v3_hdmi_cec", NULL),
488         REGULATOR_SUPPLY("vdd_3v3_gmi", NULL),
489         REGULATOR_SUPPLY("vdd_3v3_spk_amp", NULL),
490         REGULATOR_SUPPLY("vdd_3v3_sensor", NULL),
491         REGULATOR_SUPPLY("vdd_3v3_cam", NULL),
492         REGULATOR_SUPPLY("vdd_3v3_als", NULL),
493         REGULATOR_SUPPLY("debug_cons", NULL),
494 };
495 static int gpio_switch_en_3v3_sys_voltages[] = { 3300};
496
497 /* DIS_5V_SWITCH from AP SPI2_SCK X02 */
498 static struct regulator_consumer_supply gpio_switch_dis_5v_switch_supply[] = {
499         REGULATOR_SUPPLY("master_5v_switch", NULL),
500 };
501 static int gpio_switch_dis_5v_switch_voltages[] = { 5000};
502
503 /* EN_VDD_BL */
504 static struct regulator_consumer_supply gpio_switch_en_vdd_bl_supply[] = {
505         REGULATOR_SUPPLY("vdd_backlight", NULL),
506         REGULATOR_SUPPLY("vdd_backlight1", NULL),
507 };
508 static int gpio_switch_en_vdd_bl_voltages[] = { 5000};
509
510 /* EN_VDD_BL2 (E1291-A03) from AP PEX_L0_PRSNT_N DD.00 */
511 static struct regulator_consumer_supply gpio_switch_en_vdd_bl2_supply[] = {
512         REGULATOR_SUPPLY("vdd_backlight2", NULL),
513 };
514 static int gpio_switch_en_vdd_bl2_voltages[] = { 5000};
515
516 /* EN_3V3_MODEM from AP GPIO VI_VSYNCH D06*/
517 static struct regulator_consumer_supply gpio_switch_en_3v3_modem_supply[] = {
518         REGULATOR_SUPPLY("vdd_3v3_mini_card", NULL),
519         REGULATOR_SUPPLY("vdd_mini_card", NULL),
520 };
521 static int gpio_switch_en_3v3_modem_voltages[] = { 3300};
522
523 /* EN_USB1_VBUS_OC*/
524 static struct regulator_consumer_supply gpio_switch_en_usb1_vbus_oc_supply[] = {
525         REGULATOR_SUPPLY("vdd_vbus_micro_usb", NULL),
526 };
527 static int gpio_switch_en_usb1_vbus_oc_voltages[] = { 5000};
528
529 /*EN_USB3_VBUS_OC*/
530 static struct regulator_consumer_supply gpio_switch_en_usb3_vbus_oc_supply[] = {
531         REGULATOR_SUPPLY("vdd_vbus_typea_usb", NULL),
532 };
533 static int gpio_switch_en_usb3_vbus_oc_voltages[] = { 5000};
534
535 /* EN_VDDIO_VID_OC from AP GPIO VI_PCLK T00*/
536 static struct regulator_consumer_supply gpio_switch_en_vddio_vid_oc_supply[] = {
537         REGULATOR_SUPPLY("vdd_hdmi_con", NULL),
538 };
539 static int gpio_switch_en_vddio_vid_oc_voltages[] = { 5000};
540
541 /* EN_VDD_PNL1 from AP GPIO VI_D6 L04*/
542 static struct regulator_consumer_supply gpio_switch_en_vdd_pnl1_supply[] = {
543         REGULATOR_SUPPLY("vdd_lcd_panel", NULL),
544 };
545 static int gpio_switch_en_vdd_pnl1_voltages[] = { 3300};
546
547 /* CAM1_LDO_EN from AP GPIO KB_ROW6 R06*/
548 static struct regulator_consumer_supply gpio_switch_cam1_ldo_en_supply[] = {
549         REGULATOR_SUPPLY("vdd_2v8_cam1", NULL),
550         REGULATOR_SUPPLY("vdd_2v8_cam1_af", NULL),
551 };
552 static int gpio_switch_cam1_ldo_en_voltages[] = { 2800};
553
554 /* CAM2_LDO_EN from AP GPIO KB_ROW7 R07*/
555 static struct regulator_consumer_supply gpio_switch_cam2_ldo_en_supply[] = {
556         REGULATOR_SUPPLY("vdd_2v8_cam2", NULL),
557         REGULATOR_SUPPLY("vdd_2v8_cam2_af", NULL),
558 };
559 static int gpio_switch_cam2_ldo_en_voltages[] = { 2800};
560
561 /* CAM3_LDO_EN from AP GPIO KB_ROW8 S00*/
562 static struct regulator_consumer_supply gpio_switch_cam3_ldo_en_supply[] = {
563         REGULATOR_SUPPLY("vdd_cam3", NULL),
564 };
565 static int gpio_switch_cam3_ldo_en_voltages[] = { 3300};
566
567 /* EN_VDD_COM from AP GPIO SDMMC3_DAT5 D00*/
568 static struct regulator_consumer_supply gpio_switch_en_vdd_com_supply[] = {
569         REGULATOR_SUPPLY("vdd_com_bd", NULL),
570 };
571 static int gpio_switch_en_vdd_com_voltages[] = { 3300};
572
573 /* EN_VDD_SDMMC1 from AP GPIO VI_HSYNC D07*/
574 static struct regulator_consumer_supply gpio_switch_en_vdd_sdmmc1_supply[] = {
575         REGULATOR_SUPPLY("vddio_sd_slot", NULL),
576 };
577 static int gpio_switch_en_vdd_sdmmc1_voltages[] = { 3300};
578
579 /* EN_3V3_EMMC from AP GPIO SDMMC3_DAT4 D01*/
580 static struct regulator_consumer_supply gpio_switch_en_3v3_emmc_supply[] = {
581         REGULATOR_SUPPLY("vdd_emmc_core", NULL),
582 };
583 static int gpio_switch_en_3v3_emmc_voltages[] = { 3300};
584
585 /* EN_3V3_PEX_HVDD from AP GPIO VI_D09 L07*/
586 static struct regulator_consumer_supply gpio_switch_en_3v3_pex_hvdd_supply[] = {
587         REGULATOR_SUPPLY("hvdd_pex_3v3", NULL),
588 };
589 static int gpio_switch_en_3v3_pex_hvdd_voltages[] = { 3300};
590
591 /* EN_3v3_FUSE from AP GPIO VI_D08 L06*/
592 static struct regulator_consumer_supply gpio_switch_en_3v3_fuse_supply[] = {
593         REGULATOR_SUPPLY("vpp_fuse_pg", NULL),
594 };
595 static int gpio_switch_en_3v3_fuse_voltages[] = { 3300};
596
597 /* EN_1V8_CAM from AP GPIO GPIO_PBB4 PBB04*/
598 static struct regulator_consumer_supply gpio_switch_en_1v8_cam_supply[] = {
599         REGULATOR_SUPPLY("vdd_1v8_cam1", NULL),
600         REGULATOR_SUPPLY("vdd_1v8_cam2", NULL),
601         REGULATOR_SUPPLY("vdd_1v8_cam3", NULL),
602 };
603 static int gpio_switch_en_1v8_cam_voltages[] = { 1800};
604
605 static struct regulator_consumer_supply gpio_switch_en_vbrtr_supply[] = {
606         REGULATOR_SUPPLY("vdd_vbrtr", NULL),
607 };
608 static int gpio_switch_en_vbrtr_voltages[] = { 3300};
609
610 static int enable_load_switch_rail(
611                 struct gpio_switch_regulator_subdev_data *psubdev_data)
612 {
613         int ret;
614
615         if (psubdev_data->pin_group <= 0)
616                 return -EINVAL;
617
618         /* Tristate and make pin as input*/
619         ret = tegra_pinmux_set_tristate(psubdev_data->pin_group,
620                                                 TEGRA_TRI_TRISTATE);
621         if (ret < 0)
622                 return ret;
623         return gpio_direction_input(psubdev_data->gpio_nr);
624 }
625
626 static int disable_load_switch_rail(
627                 struct gpio_switch_regulator_subdev_data *psubdev_data)
628 {
629         int ret;
630
631         if (psubdev_data->pin_group <= 0)
632                 return -EINVAL;
633
634         /* Un-tristate and driver low */
635         ret = tegra_pinmux_set_tristate(psubdev_data->pin_group,
636                                                 TEGRA_TRI_NORMAL);
637         if (ret < 0)
638                 return ret;
639         return gpio_direction_output(psubdev_data->gpio_nr, 0);
640 }
641
642
643 /* Macro for defining gpio switch regulator sub device data */
644 #define GREG_INIT(_id, _var, _name, _input_supply, _gpio_nr, _active_low, \
645                         _init_state, _pg, _enable, _disable)            \
646         static struct gpio_switch_regulator_subdev_data gpio_pdata_##_var =  \
647         {                                                               \
648                 .regulator_name = "gpio-switch-"#_name,                 \
649                 .input_supply   = _input_supply,                        \
650                 .id             = _id,                                  \
651                 .gpio_nr        = _gpio_nr,                             \
652                 .pin_group      = _pg,                                  \
653                 .active_low     = _active_low,                          \
654                 .init_state     = _init_state,                          \
655                 .voltages       = gpio_switch_##_name##_voltages,       \
656                 .n_voltages     = ARRAY_SIZE(gpio_switch_##_name##_voltages), \
657                 .num_consumer_supplies =                                \
658                                 ARRAY_SIZE(gpio_switch_##_name##_supply), \
659                 .consumer_supplies = gpio_switch_##_name##_supply,      \
660                 .constraints = {                                        \
661                         .valid_modes_mask = (REGULATOR_MODE_NORMAL |    \
662                                              REGULATOR_MODE_STANDBY),   \
663                         .valid_ops_mask = (REGULATOR_CHANGE_MODE |      \
664                                            REGULATOR_CHANGE_STATUS |    \
665                                            REGULATOR_CHANGE_VOLTAGE),   \
666                 },                                                      \
667                 .enable_rail = _enable,                                 \
668                 .disable_rail = _disable,                               \
669         }
670
671 /* common to all boards */
672 GREG_INIT(0, en_5v_cp,          en_5v_cp,       NULL,                   TPS6591X_GPIO_GP0,      false,  1,      0,      0,      0);
673 GREG_INIT(1, en_5v0,            en_5v0,         NULL,                   TPS6591X_GPIO_GP2,      false,  0,      0,      0,      0);
674 GREG_INIT(2, en_ddr,            en_ddr,         NULL,                   TPS6591X_GPIO_GP6,      false,  0,      0,      0,      0);
675 GREG_INIT(3, en_3v3_sys,        en_3v3_sys,     NULL,                   TPS6591X_GPIO_GP7,      false,  0,      0,      0,      0);
676 GREG_INIT(4, en_vdd_bl,         en_vdd_bl,      NULL,                   TEGRA_GPIO_PK3,         false,  1,      0,      0,      0);
677 GREG_INIT(5, en_3v3_modem,      en_3v3_modem,   NULL,                   TEGRA_GPIO_PD6,         false,  1,      0,      0,      0);
678 GREG_INIT(6, en_vdd_pnl1,       en_vdd_pnl1,    "vdd_3v3_devices",      TEGRA_GPIO_PL4,         false,  1,      0,      0,      0);
679 GREG_INIT(7, cam3_ldo_en,       cam3_ldo_en,    "vdd_3v3_devices",      TEGRA_GPIO_PS0,         false,  0,      0,      0,      0);
680 GREG_INIT(8, en_vdd_com,        en_vdd_com,     "vdd_3v3_devices",      TEGRA_GPIO_PD0,         false,  1,      0,      0,      0);
681 GREG_INIT(9, en_3v3_fuse,       en_3v3_fuse,    "vdd_3v3_devices",      TEGRA_GPIO_PL6,         false,  0,      0,      0,      0);
682 GREG_INIT(10, en_3v3_emmc,      en_3v3_emmc,    "vdd_3v3_devices",      TEGRA_GPIO_PD1,         false,  1,      0,      0,      0);
683 GREG_INIT(11, en_vdd_sdmmc1,    en_vdd_sdmmc1,  "vdd_3v3_devices",      TEGRA_GPIO_PD7,         false,  1,      0,      0,      0);
684 GREG_INIT(12, en_3v3_pex_hvdd,  en_3v3_pex_hvdd, "vdd_3v3_devices",     TEGRA_GPIO_PL7,         false,  0,      0,      0,      0);
685 GREG_INIT(13, en_1v8_cam,       en_1v8_cam,     "vdd_gen1v8",           TEGRA_GPIO_PBB4,        false,  0,      0,      0,      0);
686
687 /*Specific to pm269*/
688 GREG_INIT(4, en_vdd_bl_p269,            en_vdd_bl,              NULL,
689         TEGRA_GPIO_PH3, false,  1,      0,      0,      0);
690 GREG_INIT(6, en_vdd_pnl1_pm269,         en_vdd_pnl1,            "vdd_3v3_devices",
691         TEGRA_GPIO_PW1, false,  1,      0,      0,      0);
692 GREG_INIT(9, en_3v3_fuse_pm269,         en_3v3_fuse,            "vdd_3v3_devices",
693         TEGRA_GPIO_PC1, false,  0,      0,      0,      0);
694 GREG_INIT(11, en_vdd_sdmmc1_pm269,      en_vdd_sdmmc1,          "vdd_3v3_devices",
695         TEGRA_GPIO_PP1, false,  1,      0,      0,      0);
696 GREG_INIT(12, en_3v3_pex_hvdd_pm269,    en_3v3_pex_hvdd,        "vdd_3v3_devices",
697         TEGRA_GPIO_PC6, false,  0,      0,      0,      0);
698 GREG_INIT(17, en_vddio_vid_oc_pm269,    en_vddio_vid_oc,        "vdd_5v0_sys",
699         TEGRA_GPIO_PP2, false,  0,      TEGRA_PINGROUP_VI_PCLK,
700         enable_load_switch_rail, disable_load_switch_rail);
701
702 /* Specific to E1187/E1186 */
703 GREG_INIT(14, dis_5v_switch_e118x,      dis_5v_switch,          "vdd_5v0_sys",
704                 TEGRA_GPIO_PX2,         true,   0,      0,      0,      0);
705 GREG_INIT(15, en_usb1_vbus_oc_e118x,    en_usb1_vbus_oc,        "master_5v_switch",
706                 TEGRA_GPIO_PI4,         false,  0,      TEGRA_PINGROUP_GMI_RST_N,
707                 enable_load_switch_rail, disable_load_switch_rail);
708 GREG_INIT(16, en_usb3_vbus_oc_e118x,    en_usb3_vbus_oc,        "master_5v_switch",
709                 TEGRA_GPIO_PH7,         false,  0,      TEGRA_PINGROUP_GMI_AD15,
710                 enable_load_switch_rail, disable_load_switch_rail);
711 GREG_INIT(17, en_vddio_vid_oc_e118x,    en_vddio_vid_oc,        "master_5v_switch",
712                 TEGRA_GPIO_PT0,         false,  0,      TEGRA_PINGROUP_VI_PCLK,
713                 enable_load_switch_rail, disable_load_switch_rail);
714
715 /* E1198/E1291 specific  fab < A03 */
716 GREG_INIT(15, en_usb1_vbus_oc,          en_usb1_vbus_oc,        "vdd_5v0_sys",
717                 TEGRA_GPIO_PI4,         false,  0,      TEGRA_PINGROUP_GMI_RST_N,
718                 enable_load_switch_rail, disable_load_switch_rail);
719 GREG_INIT(16, en_usb3_vbus_oc,          en_usb3_vbus_oc,        "vdd_5v0_sys",
720                 TEGRA_GPIO_PH7,         false,  0,      TEGRA_PINGROUP_GMI_AD15,
721                 enable_load_switch_rail, disable_load_switch_rail);
722
723 /* E1198/E1291 specific  fab >= A03 */
724 GREG_INIT(15, en_usb1_vbus_oc_a03,              en_usb1_vbus_oc,        "vdd_5v0_sys",
725                 TEGRA_GPIO_PDD6,                false,  0,      TEGRA_PINGROUP_PEX_L1_CLKREQ_N,
726                 enable_load_switch_rail, disable_load_switch_rail);
727 GREG_INIT(16, en_usb3_vbus_oc_a03,              en_usb3_vbus_oc,        "vdd_5v0_sys",
728                 TEGRA_GPIO_PDD4,                false,  0,      TEGRA_PINGROUP_PEX_L1_PRSNT_N,
729                 enable_load_switch_rail, disable_load_switch_rail);
730
731 /* E1198/E1291 specific */
732 GREG_INIT(17, en_vddio_vid_oc,          en_vddio_vid_oc,        "vdd_5v0_sys",
733                 TEGRA_GPIO_PT0,         false,  0,      TEGRA_PINGROUP_VI_PCLK,
734                 enable_load_switch_rail, disable_load_switch_rail);
735
736 /* E1198/E1291 specific*/
737 GREG_INIT(18, cam1_ldo_en,      cam1_ldo_en,            "vdd_3v3_cam",  TEGRA_GPIO_PR6,         false,  0,      0,      0,      0);
738 GREG_INIT(19, cam2_ldo_en,      cam2_ldo_en,            "vdd_3v3_cam",  TEGRA_GPIO_PR7,         false,  0,      0,      0,      0);
739
740 /* E1291 A03 specific */
741 GREG_INIT(20, en_vdd_bl1_a03,   en_vdd_bl,      NULL,           TEGRA_GPIO_PDD2,        false,  1,      0,      0,      0);
742 GREG_INIT(21, en_vdd_bl2_a03,   en_vdd_bl2,     NULL,           TEGRA_GPIO_PDD0,        false,  1,      0,      0,      0);
743
744 GREG_INIT(22, en_vbrtr, en_vbrtr, "vdd_3v3_devices",    PMU_TCA6416_GPIO_PORT12,                false,  0,      0,      0,      0);
745
746 #define ADD_GPIO_REG(_name) &gpio_pdata_##_name
747 #define COMMON_GPIO_REG \
748         ADD_GPIO_REG(en_5v_cp),                 \
749         ADD_GPIO_REG(en_5v0),                   \
750         ADD_GPIO_REG(en_ddr),                   \
751         ADD_GPIO_REG(en_3v3_sys),               \
752         ADD_GPIO_REG(en_3v3_modem),             \
753         ADD_GPIO_REG(en_vdd_pnl1),              \
754         ADD_GPIO_REG(cam3_ldo_en),              \
755         ADD_GPIO_REG(en_vdd_com),               \
756         ADD_GPIO_REG(en_3v3_fuse),              \
757         ADD_GPIO_REG(en_3v3_emmc),              \
758         ADD_GPIO_REG(en_vdd_sdmmc1),            \
759         ADD_GPIO_REG(en_3v3_pex_hvdd),          \
760         ADD_GPIO_REG(en_1v8_cam),
761
762 #define PM269_GPIO_REG \
763         ADD_GPIO_REG(en_5v_cp),                 \
764         ADD_GPIO_REG(en_5v0),                   \
765         ADD_GPIO_REG(en_ddr),                   \
766         ADD_GPIO_REG(en_vdd_bl),                \
767         ADD_GPIO_REG(en_3v3_sys),               \
768         ADD_GPIO_REG(en_3v3_modem),             \
769         ADD_GPIO_REG(en_vdd_pnl1),              \
770         ADD_GPIO_REG(cam3_ldo_en),              \
771         ADD_GPIO_REG(en_vdd_com),               \
772         ADD_GPIO_REG(en_3v3_fuse_pm269),        \
773         ADD_GPIO_REG(en_3v3_emmc),              \
774         ADD_GPIO_REG(en_vdd_sdmmc1_pm269),      \
775         ADD_GPIO_REG(en_3v3_pex_hvdd_pm269),    \
776         ADD_GPIO_REG(en_1v8_cam),               \
777         ADD_GPIO_REG(dis_5v_switch_e118x),      \
778         ADD_GPIO_REG(en_usb1_vbus_oc_e118x),    \
779         ADD_GPIO_REG(en_usb3_vbus_oc_e118x),    \
780         ADD_GPIO_REG(en_vddio_vid_oc_pm269),
781
782 #define E118x_GPIO_REG  \
783         ADD_GPIO_REG(en_vdd_bl),                \
784         ADD_GPIO_REG(dis_5v_switch_e118x),      \
785         ADD_GPIO_REG(en_usb1_vbus_oc_e118x),    \
786         ADD_GPIO_REG(en_usb3_vbus_oc_e118x),    \
787         ADD_GPIO_REG(en_vddio_vid_oc_e118x), \
788         ADD_GPIO_REG(en_vbrtr),
789
790 #define E1198_GPIO_REG  \
791         ADD_GPIO_REG(en_vddio_vid_oc),          \
792         ADD_GPIO_REG(cam1_ldo_en),              \
793         ADD_GPIO_REG(cam2_ldo_en),
794
795 #define E1291_1198_A00_GPIO_REG \
796         ADD_GPIO_REG(en_usb1_vbus_oc),          \
797         ADD_GPIO_REG(en_usb3_vbus_oc),          \
798         ADD_GPIO_REG(en_vdd_bl),
799
800 #define E1291_A03_GPIO_REG      \
801         ADD_GPIO_REG(en_usb1_vbus_oc_a03),              \
802         ADD_GPIO_REG(en_usb3_vbus_oc_a03),              \
803         ADD_GPIO_REG(en_vdd_bl1_a03), \
804         ADD_GPIO_REG(en_vdd_bl2_a03),
805
806 /* Gpio switch regulator platform data  for E1186/E1187*/
807
808 /* Gpio switch regulator platform data  for E1186/E1187*/
809 static struct gpio_switch_regulator_subdev_data *gswitch_subdevs_e118x[] = {
810         COMMON_GPIO_REG
811         E118x_GPIO_REG
812 };
813
814 /* Gpio switch regulator platform data for E1198 and E1291*/
815 static struct gpio_switch_regulator_subdev_data *gswitch_subdevs_e1198[] = {
816         COMMON_GPIO_REG
817         E1291_1198_A00_GPIO_REG
818         E1198_GPIO_REG
819 };
820
821 /* Gpio switch regulator platform data for PM269*/
822 static struct gpio_switch_regulator_subdev_data *gswitch_subdevs_pm269[] = {
823         PM269_GPIO_REG
824 };
825
826 /* Gpio switch regulator platform data for E1291 A03*/
827 static struct gpio_switch_regulator_subdev_data *gswitch_subdevs_e1291_a03[] = {
828         COMMON_GPIO_REG
829         E1291_A03_GPIO_REG
830         E1198_GPIO_REG
831 };
832
833 static struct gpio_switch_regulator_platform_data  gswitch_pdata;
834 static struct platform_device gswitch_regulator_pdata = {
835         .name = "gpio-switch-regulator",
836         .id   = -1,
837         .dev  = {
838              .platform_data = &gswitch_pdata,
839         },
840 };
841
842 int __init cardhu_gpio_switch_regulator_init(void)
843 {
844         int i;
845         struct board_info board_info;
846         tegra_get_board_info(&board_info);
847         switch (board_info.board_id) {
848         case BOARD_E1198:
849                 gswitch_pdata.num_subdevs = ARRAY_SIZE(gswitch_subdevs_e1198);
850                 gswitch_pdata.subdevs = gswitch_subdevs_e1198;
851                 break;
852         case BOARD_E1291:
853                 if (board_info.fab >= 0x3) {
854                         gswitch_pdata.num_subdevs =
855                                         ARRAY_SIZE(gswitch_subdevs_e1291_a03);
856                         gswitch_pdata.subdevs = gswitch_subdevs_e1291_a03;
857                         break;
858                 }
859                 gswitch_pdata.num_subdevs = ARRAY_SIZE(gswitch_subdevs_e1198);
860                 gswitch_pdata.subdevs = gswitch_subdevs_e1198;
861                 break;
862         case BOARD_PM269:
863                 gswitch_pdata.num_subdevs = ARRAY_SIZE(gswitch_subdevs_pm269);
864                 gswitch_pdata.subdevs = gswitch_subdevs_pm269;
865                 break;
866         default:
867                 gswitch_pdata.num_subdevs = ARRAY_SIZE(gswitch_subdevs_e118x);
868                 gswitch_pdata.subdevs = gswitch_subdevs_e118x;
869                 break;
870         }
871
872         for (i = 0; i < gswitch_pdata.num_subdevs; ++i) {
873                 struct gpio_switch_regulator_subdev_data *gswitch_data = gswitch_pdata.subdevs[i];
874                 if (gswitch_data->gpio_nr <= TEGRA_NR_GPIOS)
875                         tegra_gpio_enable(gswitch_data->gpio_nr);
876         }
877
878         return platform_device_register(&gswitch_regulator_pdata);
879 }
880
881 static struct tegra_suspend_platform_data cardhu_suspend_data = {
882         .cpu_timer      = 2000,
883         .cpu_off_timer  = 200,
884         .suspend_mode   = TEGRA_SUSPEND_LP1,
885         .core_timer     = 0x7e7e,
886         .core_off_timer = 0,
887         .separate_req   = true,
888         .corereq_high   = false,
889         .sysclkreq_high = true,
890         .wake_enb       = TEGRA_WAKE_GPIO_PV0 | TEGRA_WAKE_PWR_INT | TEGRA_WAKE_RTC_ALARM,
891         .wake_high      = TEGRA_WAKE_RTC_ALARM,
892         .wake_low       = TEGRA_WAKE_GPIO_PV0 | TEGRA_WAKE_PWR_INT,
893         .wake_any       = 0,
894         .cpu_lp2_min_residency = 2000,
895 };
896
897 int __init cardhu_suspend_init(void)
898 {
899         struct board_info board_info;
900
901         tegra_get_board_info(&board_info);
902
903         /* CORE_PWR_REQ to be high for all board whose sku bit 0 is set.
904          * This is require to enable the dc-dc converter tps62361x */
905         if ((board_info.sku & 1) == 1)
906                 cardhu_suspend_data.corereq_high = true;
907
908         switch (board_info.board_id) {
909         case BOARD_E1291:
910                 /* CORE_PWR_REQ to be high for E1291-A03 */
911                 if (board_info.fab == 0x3)
912                         cardhu_suspend_data.corereq_high = true;
913                 break;
914         case BOARD_E1198:
915                 break;
916         case BOARD_PM269:
917         case BOARD_E1187:
918         case BOARD_E1186:
919                 cardhu_suspend_data.cpu_timer = 5000;
920                 cardhu_suspend_data.cpu_off_timer = 5000;
921                 break;
922         default:
923                 break;
924         }
925
926         tegra_init_suspend(&cardhu_suspend_data);
927         return 0;
928 }
929
930 static void cardhu_power_off(void)
931 {
932         int ret;
933         pr_err("cardhu: Powering off the device\n");
934         ret = tps6591x_power_off();
935         if (ret)
936                 pr_err("cardhu: failed to power off\n");
937
938         while(1);
939 }
940
941 int __init cardhu_power_off_init(void)
942 {
943         pm_power_off = cardhu_power_off;
944         return 0;
945 }
946
947 #ifdef CONFIG_TEGRA_EDP_LIMITS
948 /*
949  * placeholder for now. needs to be changed with characterized data.
950  * step size cannot be less than 4C
951  */
952 static struct tegra_edp_limits cardhu_edp_limits[] = {
953 /* Temperature   1 CPU    2 CPUs   3 CPUs   4 CPUs */
954         {60,    {1400000, 1300000, 1300000, 1300000}},
955         {70,    {1400000, 1300000, 1300000, 1260000}},
956         {80,    {1400000, 1300000, 1300000, 1200000}},
957         {90,    {1400000, 1300000, 1300000, 1100000}},
958 };
959
960 void cardhu_thermal_zones_info(struct tegra_edp_limits **z, int *sz)
961 {
962         *z = cardhu_edp_limits;
963         *sz = ARRAY_SIZE(cardhu_edp_limits);
964 }
965
966 int __init cardhu_edp_init(void)
967 {
968         tegra_init_cpu_edp_limits(cardhu_edp_limits, ARRAY_SIZE(cardhu_edp_limits));
969         return 0;
970 }
971 #endif