arm: tegra: cardhu: Configuring DEV_SLP and gpio2 for A04
[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 #define TPS_GPIO_INIT_PDATA(gpio_nr, _init_apply, _sleep_en, _pulldn_en, _output_en, _output_val)       \
338         [gpio_nr] = {                                   \
339                         .sleep_en       = _sleep_en,    \
340                         .pulldn_en      = _pulldn_en,   \
341                         .output_mode_en = _output_en,   \
342                         .output_val     = _output_val,  \
343                         .init_apply     = _init_apply,  \
344                      }
345 static struct tps6591x_gpio_init_data tps_gpio_pdata_e1291_a04[] =  {
346         TPS_GPIO_INIT_PDATA(0, 0, 0, 0, 0, 0),
347         TPS_GPIO_INIT_PDATA(1, 0, 0, 0, 0, 0),
348         TPS_GPIO_INIT_PDATA(2, 1, 1, 0, 1, 1),
349         TPS_GPIO_INIT_PDATA(3, 0, 0, 0, 0, 0),
350         TPS_GPIO_INIT_PDATA(4, 0, 0, 0, 0, 0),
351         TPS_GPIO_INIT_PDATA(5, 0, 0, 0, 0, 0),
352         TPS_GPIO_INIT_PDATA(6, 0, 0, 0, 0, 0),
353         TPS_GPIO_INIT_PDATA(7, 0, 0, 0, 0, 0),
354         TPS_GPIO_INIT_PDATA(8, 0, 0, 0, 0, 0),
355 };
356
357 static struct tps6591x_platform_data tps_platform = {
358         .irq_base       = TPS6591X_IRQ_BASE,
359         .gpio_base      = TPS6591X_GPIO_BASE,
360 };
361
362 static struct i2c_board_info __initdata cardhu_regulators[] = {
363         {
364                 I2C_BOARD_INFO("tps6591x", 0x2D),
365                 .irq            = INT_EXTERNAL_PMU,
366                 .platform_data  = &tps_platform,
367         },
368 };
369
370 /* TPS62361B DC-DC converter */
371 static struct regulator_consumer_supply tps6236x_dcdc_supply[] = {
372         REGULATOR_SUPPLY("vdd_core", NULL),
373 };
374
375 static struct tps6236x_regulator_platform_data tps6236x_pdata = {
376         .reg_init_data = {                                      \
377                 .constraints = {                                \
378                         .min_uV = 500000,                       \
379                         .max_uV = 1770000,                      \
380                         .valid_modes_mask = (REGULATOR_MODE_NORMAL |  \
381                                              REGULATOR_MODE_STANDBY), \
382                         .valid_ops_mask = (REGULATOR_CHANGE_MODE |    \
383                                            REGULATOR_CHANGE_STATUS |  \
384                                            REGULATOR_CHANGE_VOLTAGE), \
385                         .always_on = 1,                         \
386                         .boot_on =  1,                          \
387                         .apply_uV = 0,                          \
388                 },                                              \
389                 .num_consumer_supplies = ARRAY_SIZE(tps6236x_dcdc_supply), \
390                 .consumer_supplies = tps6236x_dcdc_supply,              \
391                 },                                                      \
392         .internal_pd_enable = 0,                                        \
393         .vsel = 3,                                                      \
394         .init_uV = -1,                                                  \
395         .init_apply = 0,                                                \
396 };
397
398 static struct i2c_board_info __initdata tps6236x_boardinfo[] = {
399         {
400                 I2C_BOARD_INFO("tps62361B", 0x60),
401                 .platform_data  = &tps6236x_pdata,
402         },
403 };
404
405 int __init cardhu_regulator_init(void)
406 {
407         struct board_info board_info;
408         void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE);
409         u32 pmc_ctrl;
410
411         /* configure the power management controller to trigger PMU
412          * interrupts when low */
413
414         pmc_ctrl = readl(pmc + PMC_CTRL);
415         writel(pmc_ctrl | PMC_CTRL_INTR_LOW, pmc + PMC_CTRL);
416
417         tegra_get_board_info(&board_info);
418         if ((board_info.board_id == BOARD_E1198) ||
419                 (board_info.board_id == BOARD_E1291)) {
420                 if ((board_info.sku & 1) == 1) {
421                         tps_platform.num_subdevs =
422                                         ARRAY_SIZE(tps_devs_e1198_skubit0_1);
423                         tps_platform.subdevs = tps_devs_e1198_skubit0_1;
424                 } else {
425                         tps_platform.num_subdevs =
426                                         ARRAY_SIZE(tps_devs_e1198_skubit0_0);
427                         tps_platform.subdevs = tps_devs_e1198_skubit0_0;
428                 }
429         } else {
430                 if ((board_info.sku & 1) == 1) {
431                         tps_platform.num_subdevs = ARRAY_SIZE(tps_devs_e118x_skubit0_1);
432                         tps_platform.subdevs = tps_devs_e118x_skubit0_1;
433                 } else {
434                         tps_platform.num_subdevs = ARRAY_SIZE(tps_devs_e118x_skubit0_0);
435                         tps_platform.subdevs = tps_devs_e118x_skubit0_0;
436                 }
437         }
438
439         /* E1291-A04: Enable DEV_SLP and enable sleep on GPIO2 */
440         if ((board_info.board_id == BOARD_E1291) && (board_info.fab == 0x4)) {
441                 tps_platform.dev_slp_en = true;
442                 tps_platform.gpio_init_data = tps_gpio_pdata_e1291_a04;
443                 tps_platform.num_gpioinit_data =
444                                         ARRAY_SIZE(tps_gpio_pdata_e1291_a04);
445         }
446
447         i2c_register_board_info(4, cardhu_regulators, 1);
448
449         /* Resgister the TPS6236x for all boards whose sku bit 0 is set. */
450         if ((board_info.sku & 1) == 1) {
451                 pr_info("Registering the device TPS62361B\n");
452                 i2c_register_board_info(4, tps6236x_boardinfo, 1);
453         }
454         return 0;
455 }
456
457 /* EN_5V_CP from PMU GP0 */
458 static struct regulator_consumer_supply gpio_switch_en_5v_cp_supply[] = {
459         REGULATOR_SUPPLY("vdd_5v0_sby", NULL),
460         REGULATOR_SUPPLY("vdd_hall", NULL),
461         REGULATOR_SUPPLY("vterm_ddr", NULL),
462         REGULATOR_SUPPLY("v2ref_ddr", NULL),
463 };
464 static int gpio_switch_en_5v_cp_voltages[] = { 5000};
465
466 /* EN_5V0 From PMU GP2 */
467 static struct regulator_consumer_supply gpio_switch_en_5v0_supply[] = {
468         REGULATOR_SUPPLY("vdd_5v0_sys", NULL),
469 };
470 static int gpio_switch_en_5v0_voltages[] = { 5000};
471
472 /* EN_DDR From PMU GP6 */
473 static struct regulator_consumer_supply gpio_switch_en_ddr_supply[] = {
474         REGULATOR_SUPPLY("mem_vddio_ddr", NULL),
475         REGULATOR_SUPPLY("t30_vddio_ddr", NULL),
476 };
477 static int gpio_switch_en_ddr_voltages[] = { 1500};
478
479 /* EN_3V3_SYS From PMU GP7 */
480 static struct regulator_consumer_supply gpio_switch_en_3v3_sys_supply[] = {
481         REGULATOR_SUPPLY("vdd_lvds", NULL),
482         REGULATOR_SUPPLY("vdd_pnl", NULL),
483         REGULATOR_SUPPLY("vcom_3v3", NULL),
484         REGULATOR_SUPPLY("vdd_3v3", NULL),
485         REGULATOR_SUPPLY("vcore_mmc", NULL),
486         REGULATOR_SUPPLY("vddio_pex_ctl", NULL),
487         REGULATOR_SUPPLY("hvdd_pex", NULL),
488         REGULATOR_SUPPLY("avdd_hdmi", NULL),
489         REGULATOR_SUPPLY("vpp_fuse", NULL),
490         REGULATOR_SUPPLY("avdd_usb", NULL),
491         REGULATOR_SUPPLY("vdd_ddr_rx", NULL),
492         REGULATOR_SUPPLY("vcore_nand", NULL),
493         REGULATOR_SUPPLY("hvdd_sata", NULL),
494         REGULATOR_SUPPLY("vddio_gmi_pmu", NULL),
495         REGULATOR_SUPPLY("avdd_cam1", NULL),
496         REGULATOR_SUPPLY("vdd_af", NULL),
497         REGULATOR_SUPPLY("avdd_cam2", NULL),
498         REGULATOR_SUPPLY("vdd_acc", NULL),
499         REGULATOR_SUPPLY("vdd_phtl", NULL),
500         REGULATOR_SUPPLY("vddio_tp", NULL),
501         REGULATOR_SUPPLY("vdd_led", NULL),
502         REGULATOR_SUPPLY("vddio_cec", NULL),
503         REGULATOR_SUPPLY("vdd_cmps", NULL),
504         REGULATOR_SUPPLY("vdd_temp", NULL),
505         REGULATOR_SUPPLY("vpp_kfuse", NULL),
506         REGULATOR_SUPPLY("vddio_ts", NULL),
507         REGULATOR_SUPPLY("vdd_ir_led", NULL),
508         REGULATOR_SUPPLY("vddio_1wire", NULL),
509         REGULATOR_SUPPLY("avddio_audio", NULL),
510         REGULATOR_SUPPLY("vdd_ec", NULL),
511         REGULATOR_SUPPLY("vcom_pa", NULL),
512         REGULATOR_SUPPLY("vdd_3v3_devices", NULL),
513         REGULATOR_SUPPLY("vdd_3v3_dock", NULL),
514         REGULATOR_SUPPLY("vdd_3v3_edid", NULL),
515         REGULATOR_SUPPLY("vdd_3v3_hdmi_cec", NULL),
516         REGULATOR_SUPPLY("vdd_3v3_gmi", NULL),
517         REGULATOR_SUPPLY("vdd_3v3_spk_amp", NULL),
518         REGULATOR_SUPPLY("vdd_3v3_sensor", NULL),
519         REGULATOR_SUPPLY("vdd_3v3_cam", NULL),
520         REGULATOR_SUPPLY("vdd_3v3_als", NULL),
521         REGULATOR_SUPPLY("debug_cons", NULL),
522 };
523 static int gpio_switch_en_3v3_sys_voltages[] = { 3300};
524
525 /* DIS_5V_SWITCH from AP SPI2_SCK X02 */
526 static struct regulator_consumer_supply gpio_switch_dis_5v_switch_supply[] = {
527         REGULATOR_SUPPLY("master_5v_switch", NULL),
528 };
529 static int gpio_switch_dis_5v_switch_voltages[] = { 5000};
530
531 /* EN_VDD_BL */
532 static struct regulator_consumer_supply gpio_switch_en_vdd_bl_supply[] = {
533         REGULATOR_SUPPLY("vdd_backlight", NULL),
534         REGULATOR_SUPPLY("vdd_backlight1", NULL),
535 };
536 static int gpio_switch_en_vdd_bl_voltages[] = { 5000};
537
538 /* EN_VDD_BL2 (E1291-A03) from AP PEX_L0_PRSNT_N DD.00 */
539 static struct regulator_consumer_supply gpio_switch_en_vdd_bl2_supply[] = {
540         REGULATOR_SUPPLY("vdd_backlight2", NULL),
541 };
542 static int gpio_switch_en_vdd_bl2_voltages[] = { 5000};
543
544 /* EN_3V3_MODEM from AP GPIO VI_VSYNCH D06*/
545 static struct regulator_consumer_supply gpio_switch_en_3v3_modem_supply[] = {
546         REGULATOR_SUPPLY("vdd_3v3_mini_card", NULL),
547         REGULATOR_SUPPLY("vdd_mini_card", NULL),
548 };
549 static int gpio_switch_en_3v3_modem_voltages[] = { 3300};
550
551 /* EN_USB1_VBUS_OC*/
552 static struct regulator_consumer_supply gpio_switch_en_usb1_vbus_oc_supply[] = {
553         REGULATOR_SUPPLY("vdd_vbus_micro_usb", NULL),
554 };
555 static int gpio_switch_en_usb1_vbus_oc_voltages[] = { 5000};
556
557 /*EN_USB3_VBUS_OC*/
558 static struct regulator_consumer_supply gpio_switch_en_usb3_vbus_oc_supply[] = {
559         REGULATOR_SUPPLY("vdd_vbus_typea_usb", NULL),
560 };
561 static int gpio_switch_en_usb3_vbus_oc_voltages[] = { 5000};
562
563 /* EN_VDDIO_VID_OC from AP GPIO VI_PCLK T00*/
564 static struct regulator_consumer_supply gpio_switch_en_vddio_vid_oc_supply[] = {
565         REGULATOR_SUPPLY("vdd_hdmi_con", NULL),
566 };
567 static int gpio_switch_en_vddio_vid_oc_voltages[] = { 5000};
568
569 /* EN_VDD_PNL1 from AP GPIO VI_D6 L04*/
570 static struct regulator_consumer_supply gpio_switch_en_vdd_pnl1_supply[] = {
571         REGULATOR_SUPPLY("vdd_lcd_panel", NULL),
572 };
573 static int gpio_switch_en_vdd_pnl1_voltages[] = { 3300};
574
575 /* CAM1_LDO_EN from AP GPIO KB_ROW6 R06*/
576 static struct regulator_consumer_supply gpio_switch_cam1_ldo_en_supply[] = {
577         REGULATOR_SUPPLY("vdd_2v8_cam1", NULL),
578         REGULATOR_SUPPLY("vdd_2v8_cam1_af", NULL),
579 };
580 static int gpio_switch_cam1_ldo_en_voltages[] = { 2800};
581
582 /* CAM2_LDO_EN from AP GPIO KB_ROW7 R07*/
583 static struct regulator_consumer_supply gpio_switch_cam2_ldo_en_supply[] = {
584         REGULATOR_SUPPLY("vdd_2v8_cam2", NULL),
585         REGULATOR_SUPPLY("vdd_2v8_cam2_af", NULL),
586 };
587 static int gpio_switch_cam2_ldo_en_voltages[] = { 2800};
588
589 /* CAM3_LDO_EN from AP GPIO KB_ROW8 S00*/
590 static struct regulator_consumer_supply gpio_switch_cam3_ldo_en_supply[] = {
591         REGULATOR_SUPPLY("vdd_cam3", NULL),
592 };
593 static int gpio_switch_cam3_ldo_en_voltages[] = { 3300};
594
595 /* EN_VDD_COM from AP GPIO SDMMC3_DAT5 D00*/
596 static struct regulator_consumer_supply gpio_switch_en_vdd_com_supply[] = {
597         REGULATOR_SUPPLY("vdd_com_bd", NULL),
598 };
599 static int gpio_switch_en_vdd_com_voltages[] = { 3300};
600
601 /* EN_VDD_SDMMC1 from AP GPIO VI_HSYNC D07*/
602 static struct regulator_consumer_supply gpio_switch_en_vdd_sdmmc1_supply[] = {
603         REGULATOR_SUPPLY("vddio_sd_slot", NULL),
604 };
605 static int gpio_switch_en_vdd_sdmmc1_voltages[] = { 3300};
606
607 /* EN_3V3_EMMC from AP GPIO SDMMC3_DAT4 D01*/
608 static struct regulator_consumer_supply gpio_switch_en_3v3_emmc_supply[] = {
609         REGULATOR_SUPPLY("vdd_emmc_core", NULL),
610 };
611 static int gpio_switch_en_3v3_emmc_voltages[] = { 3300};
612
613 /* EN_3V3_PEX_HVDD from AP GPIO VI_D09 L07*/
614 static struct regulator_consumer_supply gpio_switch_en_3v3_pex_hvdd_supply[] = {
615         REGULATOR_SUPPLY("hvdd_pex_3v3", NULL),
616 };
617 static int gpio_switch_en_3v3_pex_hvdd_voltages[] = { 3300};
618
619 /* EN_3v3_FUSE from AP GPIO VI_D08 L06*/
620 static struct regulator_consumer_supply gpio_switch_en_3v3_fuse_supply[] = {
621         REGULATOR_SUPPLY("vpp_fuse_pg", NULL),
622 };
623 static int gpio_switch_en_3v3_fuse_voltages[] = { 3300};
624
625 /* EN_1V8_CAM from AP GPIO GPIO_PBB4 PBB04*/
626 static struct regulator_consumer_supply gpio_switch_en_1v8_cam_supply[] = {
627         REGULATOR_SUPPLY("vdd_1v8_cam1", NULL),
628         REGULATOR_SUPPLY("vdd_1v8_cam2", NULL),
629         REGULATOR_SUPPLY("vdd_1v8_cam3", NULL),
630 };
631 static int gpio_switch_en_1v8_cam_voltages[] = { 1800};
632
633 static struct regulator_consumer_supply gpio_switch_en_vbrtr_supply[] = {
634         REGULATOR_SUPPLY("vdd_vbrtr", NULL),
635 };
636 static int gpio_switch_en_vbrtr_voltages[] = { 3300};
637
638 static int enable_load_switch_rail(
639                 struct gpio_switch_regulator_subdev_data *psubdev_data)
640 {
641         int ret;
642
643         if (psubdev_data->pin_group <= 0)
644                 return -EINVAL;
645
646         /* Tristate and make pin as input*/
647         ret = tegra_pinmux_set_tristate(psubdev_data->pin_group,
648                                                 TEGRA_TRI_TRISTATE);
649         if (ret < 0)
650                 return ret;
651         return gpio_direction_input(psubdev_data->gpio_nr);
652 }
653
654 static int disable_load_switch_rail(
655                 struct gpio_switch_regulator_subdev_data *psubdev_data)
656 {
657         int ret;
658
659         if (psubdev_data->pin_group <= 0)
660                 return -EINVAL;
661
662         /* Un-tristate and driver low */
663         ret = tegra_pinmux_set_tristate(psubdev_data->pin_group,
664                                                 TEGRA_TRI_NORMAL);
665         if (ret < 0)
666                 return ret;
667         return gpio_direction_output(psubdev_data->gpio_nr, 0);
668 }
669
670
671 /* Macro for defining gpio switch regulator sub device data */
672 #define GREG_INIT(_id, _var, _name, _input_supply, _gpio_nr, _active_low, \
673                         _init_state, _pg, _enable, _disable)            \
674         static struct gpio_switch_regulator_subdev_data gpio_pdata_##_var =  \
675         {                                                               \
676                 .regulator_name = "gpio-switch-"#_name,                 \
677                 .input_supply   = _input_supply,                        \
678                 .id             = _id,                                  \
679                 .gpio_nr        = _gpio_nr,                             \
680                 .pin_group      = _pg,                                  \
681                 .active_low     = _active_low,                          \
682                 .init_state     = _init_state,                          \
683                 .voltages       = gpio_switch_##_name##_voltages,       \
684                 .n_voltages     = ARRAY_SIZE(gpio_switch_##_name##_voltages), \
685                 .num_consumer_supplies =                                \
686                                 ARRAY_SIZE(gpio_switch_##_name##_supply), \
687                 .consumer_supplies = gpio_switch_##_name##_supply,      \
688                 .constraints = {                                        \
689                         .valid_modes_mask = (REGULATOR_MODE_NORMAL |    \
690                                              REGULATOR_MODE_STANDBY),   \
691                         .valid_ops_mask = (REGULATOR_CHANGE_MODE |      \
692                                            REGULATOR_CHANGE_STATUS |    \
693                                            REGULATOR_CHANGE_VOLTAGE),   \
694                 },                                                      \
695                 .enable_rail = _enable,                                 \
696                 .disable_rail = _disable,                               \
697         }
698
699 /* common to all boards */
700 GREG_INIT(0, en_5v_cp,          en_5v_cp,       NULL,                   TPS6591X_GPIO_GP0,      false,  1,      0,      0,      0);
701 GREG_INIT(1, en_5v0,            en_5v0,         NULL,                   TPS6591X_GPIO_GP2,      false,  0,      0,      0,      0);
702 GREG_INIT(2, en_ddr,            en_ddr,         NULL,                   TPS6591X_GPIO_GP6,      false,  0,      0,      0,      0);
703 GREG_INIT(3, en_3v3_sys,        en_3v3_sys,     NULL,                   TPS6591X_GPIO_GP7,      false,  0,      0,      0,      0);
704 GREG_INIT(4, en_vdd_bl,         en_vdd_bl,      NULL,                   TEGRA_GPIO_PK3,         false,  1,      0,      0,      0);
705 GREG_INIT(5, en_3v3_modem,      en_3v3_modem,   NULL,                   TEGRA_GPIO_PD6,         false,  1,      0,      0,      0);
706 GREG_INIT(6, en_vdd_pnl1,       en_vdd_pnl1,    "vdd_3v3_devices",      TEGRA_GPIO_PL4,         false,  1,      0,      0,      0);
707 GREG_INIT(7, cam3_ldo_en,       cam3_ldo_en,    "vdd_3v3_devices",      TEGRA_GPIO_PS0,         false,  0,      0,      0,      0);
708 GREG_INIT(8, en_vdd_com,        en_vdd_com,     "vdd_3v3_devices",      TEGRA_GPIO_PD0,         false,  1,      0,      0,      0);
709 GREG_INIT(9, en_3v3_fuse,       en_3v3_fuse,    "vdd_3v3_devices",      TEGRA_GPIO_PL6,         false,  0,      0,      0,      0);
710 GREG_INIT(10, en_3v3_emmc,      en_3v3_emmc,    "vdd_3v3_devices",      TEGRA_GPIO_PD1,         false,  1,      0,      0,      0);
711 GREG_INIT(11, en_vdd_sdmmc1,    en_vdd_sdmmc1,  "vdd_3v3_devices",      TEGRA_GPIO_PD7,         false,  1,      0,      0,      0);
712 GREG_INIT(12, en_3v3_pex_hvdd,  en_3v3_pex_hvdd, "vdd_3v3_devices",     TEGRA_GPIO_PL7,         false,  0,      0,      0,      0);
713 GREG_INIT(13, en_1v8_cam,       en_1v8_cam,     "vdd_gen1v8",           TEGRA_GPIO_PBB4,        false,  0,      0,      0,      0);
714
715 /*Specific to pm269*/
716 GREG_INIT(4, en_vdd_bl_p269,            en_vdd_bl,              NULL,
717         TEGRA_GPIO_PH3, false,  1,      0,      0,      0);
718 GREG_INIT(6, en_vdd_pnl1_pm269,         en_vdd_pnl1,            "vdd_3v3_devices",
719         TEGRA_GPIO_PW1, false,  1,      0,      0,      0);
720 GREG_INIT(9, en_3v3_fuse_pm269,         en_3v3_fuse,            "vdd_3v3_devices",
721         TEGRA_GPIO_PC1, false,  0,      0,      0,      0);
722 GREG_INIT(11, en_vdd_sdmmc1_pm269,      en_vdd_sdmmc1,          "vdd_3v3_devices",
723         TEGRA_GPIO_PP1, false,  1,      0,      0,      0);
724 GREG_INIT(12, en_3v3_pex_hvdd_pm269,    en_3v3_pex_hvdd,        "vdd_3v3_devices",
725         TEGRA_GPIO_PC6, false,  0,      0,      0,      0);
726 GREG_INIT(17, en_vddio_vid_oc_pm269,    en_vddio_vid_oc,        "vdd_5v0_sys",
727         TEGRA_GPIO_PP2, false,  0,      TEGRA_PINGROUP_VI_PCLK,
728         enable_load_switch_rail, disable_load_switch_rail);
729
730 /* Specific to E1187/E1186 */
731 GREG_INIT(14, dis_5v_switch_e118x,      dis_5v_switch,          "vdd_5v0_sys",
732                 TEGRA_GPIO_PX2,         true,   0,      0,      0,      0);
733 GREG_INIT(15, en_usb1_vbus_oc_e118x,    en_usb1_vbus_oc,        "master_5v_switch",
734                 TEGRA_GPIO_PI4,         false,  0,      TEGRA_PINGROUP_GMI_RST_N,
735                 enable_load_switch_rail, disable_load_switch_rail);
736 GREG_INIT(16, en_usb3_vbus_oc_e118x,    en_usb3_vbus_oc,        "master_5v_switch",
737                 TEGRA_GPIO_PH7,         false,  0,      TEGRA_PINGROUP_GMI_AD15,
738                 enable_load_switch_rail, disable_load_switch_rail);
739 GREG_INIT(17, en_vddio_vid_oc_e118x,    en_vddio_vid_oc,        "master_5v_switch",
740                 TEGRA_GPIO_PT0,         false,  0,      TEGRA_PINGROUP_VI_PCLK,
741                 enable_load_switch_rail, disable_load_switch_rail);
742
743 /* E1198/E1291 specific  fab < A03 */
744 GREG_INIT(15, en_usb1_vbus_oc,          en_usb1_vbus_oc,        "vdd_5v0_sys",
745                 TEGRA_GPIO_PI4,         false,  0,      TEGRA_PINGROUP_GMI_RST_N,
746                 enable_load_switch_rail, disable_load_switch_rail);
747 GREG_INIT(16, en_usb3_vbus_oc,          en_usb3_vbus_oc,        "vdd_5v0_sys",
748                 TEGRA_GPIO_PH7,         false,  0,      TEGRA_PINGROUP_GMI_AD15,
749                 enable_load_switch_rail, disable_load_switch_rail);
750
751 /* E1198/E1291 specific  fab >= A03 */
752 GREG_INIT(15, en_usb1_vbus_oc_a03,              en_usb1_vbus_oc,        "vdd_5v0_sys",
753                 TEGRA_GPIO_PDD6,                false,  0,      TEGRA_PINGROUP_PEX_L1_CLKREQ_N,
754                 enable_load_switch_rail, disable_load_switch_rail);
755 GREG_INIT(16, en_usb3_vbus_oc_a03,              en_usb3_vbus_oc,        "vdd_5v0_sys",
756                 TEGRA_GPIO_PDD4,                false,  0,      TEGRA_PINGROUP_PEX_L1_PRSNT_N,
757                 enable_load_switch_rail, disable_load_switch_rail);
758
759 /* E1198/E1291 specific */
760 GREG_INIT(17, en_vddio_vid_oc,          en_vddio_vid_oc,        "vdd_5v0_sys",
761                 TEGRA_GPIO_PT0,         false,  0,      TEGRA_PINGROUP_VI_PCLK,
762                 enable_load_switch_rail, disable_load_switch_rail);
763
764 /* E1198/E1291 specific*/
765 GREG_INIT(18, cam1_ldo_en,      cam1_ldo_en,            "vdd_3v3_cam",  TEGRA_GPIO_PR6,         false,  0,      0,      0,      0);
766 GREG_INIT(19, cam2_ldo_en,      cam2_ldo_en,            "vdd_3v3_cam",  TEGRA_GPIO_PR7,         false,  0,      0,      0,      0);
767
768 /* E1291 A03 specific */
769 GREG_INIT(20, en_vdd_bl1_a03,   en_vdd_bl,      NULL,           TEGRA_GPIO_PDD2,        false,  1,      0,      0,      0);
770 GREG_INIT(21, en_vdd_bl2_a03,   en_vdd_bl2,     NULL,           TEGRA_GPIO_PDD0,        false,  1,      0,      0,      0);
771
772 GREG_INIT(22, en_vbrtr, en_vbrtr, "vdd_3v3_devices",    PMU_TCA6416_GPIO_PORT12,                false,  0,      0,      0,      0);
773
774 #define ADD_GPIO_REG(_name) &gpio_pdata_##_name
775 #define COMMON_GPIO_REG \
776         ADD_GPIO_REG(en_5v_cp),                 \
777         ADD_GPIO_REG(en_5v0),                   \
778         ADD_GPIO_REG(en_ddr),                   \
779         ADD_GPIO_REG(en_3v3_sys),               \
780         ADD_GPIO_REG(en_3v3_modem),             \
781         ADD_GPIO_REG(en_vdd_pnl1),              \
782         ADD_GPIO_REG(cam3_ldo_en),              \
783         ADD_GPIO_REG(en_vdd_com),               \
784         ADD_GPIO_REG(en_3v3_fuse),              \
785         ADD_GPIO_REG(en_3v3_emmc),              \
786         ADD_GPIO_REG(en_vdd_sdmmc1),            \
787         ADD_GPIO_REG(en_3v3_pex_hvdd),          \
788         ADD_GPIO_REG(en_1v8_cam),
789
790 #define PM269_GPIO_REG \
791         ADD_GPIO_REG(en_5v_cp),                 \
792         ADD_GPIO_REG(en_5v0),                   \
793         ADD_GPIO_REG(en_ddr),                   \
794         ADD_GPIO_REG(en_vdd_bl),                \
795         ADD_GPIO_REG(en_3v3_sys),               \
796         ADD_GPIO_REG(en_3v3_modem),             \
797         ADD_GPIO_REG(en_vdd_pnl1),              \
798         ADD_GPIO_REG(cam3_ldo_en),              \
799         ADD_GPIO_REG(en_vdd_com),               \
800         ADD_GPIO_REG(en_3v3_fuse_pm269),        \
801         ADD_GPIO_REG(en_3v3_emmc),              \
802         ADD_GPIO_REG(en_vdd_sdmmc1_pm269),      \
803         ADD_GPIO_REG(en_3v3_pex_hvdd_pm269),    \
804         ADD_GPIO_REG(en_1v8_cam),               \
805         ADD_GPIO_REG(dis_5v_switch_e118x),      \
806         ADD_GPIO_REG(en_usb1_vbus_oc_e118x),    \
807         ADD_GPIO_REG(en_usb3_vbus_oc_e118x),    \
808         ADD_GPIO_REG(en_vddio_vid_oc_pm269),
809
810 #define E118x_GPIO_REG  \
811         ADD_GPIO_REG(en_vdd_bl),                \
812         ADD_GPIO_REG(dis_5v_switch_e118x),      \
813         ADD_GPIO_REG(en_usb1_vbus_oc_e118x),    \
814         ADD_GPIO_REG(en_usb3_vbus_oc_e118x),    \
815         ADD_GPIO_REG(en_vddio_vid_oc_e118x), \
816         ADD_GPIO_REG(en_vbrtr),
817
818 #define E1198_GPIO_REG  \
819         ADD_GPIO_REG(en_vddio_vid_oc),          \
820         ADD_GPIO_REG(cam1_ldo_en),              \
821         ADD_GPIO_REG(cam2_ldo_en),
822
823 #define E1291_1198_A00_GPIO_REG \
824         ADD_GPIO_REG(en_usb1_vbus_oc),          \
825         ADD_GPIO_REG(en_usb3_vbus_oc),          \
826         ADD_GPIO_REG(en_vdd_bl),
827
828 #define E1291_A03_GPIO_REG      \
829         ADD_GPIO_REG(en_usb1_vbus_oc_a03),              \
830         ADD_GPIO_REG(en_usb3_vbus_oc_a03),              \
831         ADD_GPIO_REG(en_vdd_bl1_a03), \
832         ADD_GPIO_REG(en_vdd_bl2_a03),
833
834 /* Gpio switch regulator platform data  for E1186/E1187*/
835
836 /* Gpio switch regulator platform data  for E1186/E1187*/
837 static struct gpio_switch_regulator_subdev_data *gswitch_subdevs_e118x[] = {
838         COMMON_GPIO_REG
839         E118x_GPIO_REG
840 };
841
842 /* Gpio switch regulator platform data for E1198 and E1291*/
843 static struct gpio_switch_regulator_subdev_data *gswitch_subdevs_e1198[] = {
844         COMMON_GPIO_REG
845         E1291_1198_A00_GPIO_REG
846         E1198_GPIO_REG
847 };
848
849 /* Gpio switch regulator platform data for PM269*/
850 static struct gpio_switch_regulator_subdev_data *gswitch_subdevs_pm269[] = {
851         PM269_GPIO_REG
852 };
853
854 /* Gpio switch regulator platform data for E1291 A03*/
855 static struct gpio_switch_regulator_subdev_data *gswitch_subdevs_e1291_a03[] = {
856         COMMON_GPIO_REG
857         E1291_A03_GPIO_REG
858         E1198_GPIO_REG
859 };
860
861 static struct gpio_switch_regulator_platform_data  gswitch_pdata;
862 static struct platform_device gswitch_regulator_pdata = {
863         .name = "gpio-switch-regulator",
864         .id   = -1,
865         .dev  = {
866              .platform_data = &gswitch_pdata,
867         },
868 };
869
870 int __init cardhu_gpio_switch_regulator_init(void)
871 {
872         int i;
873         struct board_info board_info;
874         tegra_get_board_info(&board_info);
875         switch (board_info.board_id) {
876         case BOARD_E1198:
877                 gswitch_pdata.num_subdevs = ARRAY_SIZE(gswitch_subdevs_e1198);
878                 gswitch_pdata.subdevs = gswitch_subdevs_e1198;
879                 break;
880         case BOARD_E1291:
881                 if (board_info.fab >= 0x3) {
882                         gswitch_pdata.num_subdevs =
883                                         ARRAY_SIZE(gswitch_subdevs_e1291_a03);
884                         gswitch_pdata.subdevs = gswitch_subdevs_e1291_a03;
885                         break;
886                 }
887                 gswitch_pdata.num_subdevs = ARRAY_SIZE(gswitch_subdevs_e1198);
888                 gswitch_pdata.subdevs = gswitch_subdevs_e1198;
889                 break;
890         case BOARD_PM269:
891                 gswitch_pdata.num_subdevs = ARRAY_SIZE(gswitch_subdevs_pm269);
892                 gswitch_pdata.subdevs = gswitch_subdevs_pm269;
893                 break;
894         default:
895                 gswitch_pdata.num_subdevs = ARRAY_SIZE(gswitch_subdevs_e118x);
896                 gswitch_pdata.subdevs = gswitch_subdevs_e118x;
897                 break;
898         }
899
900         for (i = 0; i < gswitch_pdata.num_subdevs; ++i) {
901                 struct gpio_switch_regulator_subdev_data *gswitch_data = gswitch_pdata.subdevs[i];
902                 if (gswitch_data->gpio_nr <= TEGRA_NR_GPIOS)
903                         tegra_gpio_enable(gswitch_data->gpio_nr);
904         }
905
906         return platform_device_register(&gswitch_regulator_pdata);
907 }
908
909 static struct tegra_suspend_platform_data cardhu_suspend_data = {
910         .cpu_timer      = 2000,
911         .cpu_off_timer  = 200,
912         .suspend_mode   = TEGRA_SUSPEND_LP1,
913         .core_timer     = 0x7e7e,
914         .core_off_timer = 0,
915         .separate_req   = true,
916         .corereq_high   = false,
917         .sysclkreq_high = true,
918         .wake_enb       = TEGRA_WAKE_GPIO_PV0 | TEGRA_WAKE_PWR_INT | TEGRA_WAKE_RTC_ALARM,
919         .wake_high      = TEGRA_WAKE_RTC_ALARM,
920         .wake_low       = TEGRA_WAKE_GPIO_PV0 | TEGRA_WAKE_PWR_INT,
921         .wake_any       = 0,
922         .cpu_lp2_min_residency = 2000,
923 };
924
925 int __init cardhu_suspend_init(void)
926 {
927         struct board_info board_info;
928
929         tegra_get_board_info(&board_info);
930
931         /* CORE_PWR_REQ to be high for all board whose sku bit 0 is set.
932          * This is require to enable the dc-dc converter tps62361x */
933         if ((board_info.sku & 1) == 1)
934                 cardhu_suspend_data.corereq_high = true;
935
936         switch (board_info.board_id) {
937         case BOARD_E1291:
938                 /* CORE_PWR_REQ to be high for E1291-A03 */
939                 if (board_info.fab == 0x3)
940                         cardhu_suspend_data.corereq_high = true;
941                 break;
942         case BOARD_E1198:
943                 break;
944         case BOARD_PM269:
945         case BOARD_E1187:
946         case BOARD_E1186:
947                 cardhu_suspend_data.cpu_timer = 5000;
948                 cardhu_suspend_data.cpu_off_timer = 5000;
949                 break;
950         default:
951                 break;
952         }
953
954         tegra_init_suspend(&cardhu_suspend_data);
955         return 0;
956 }
957
958 static void cardhu_power_off(void)
959 {
960         int ret;
961         pr_err("cardhu: Powering off the device\n");
962         ret = tps6591x_power_off();
963         if (ret)
964                 pr_err("cardhu: failed to power off\n");
965
966         while(1);
967 }
968
969 int __init cardhu_power_off_init(void)
970 {
971         pm_power_off = cardhu_power_off;
972         return 0;
973 }
974
975 #ifdef CONFIG_TEGRA_EDP_LIMITS
976 /*
977  * placeholder for now. needs to be changed with characterized data.
978  * step size cannot be less than 4C
979  */
980 static struct tegra_edp_limits cardhu_edp_limits[] = {
981 /* Temperature   1 CPU    2 CPUs   3 CPUs   4 CPUs */
982         {60,    {1400000, 1300000, 1300000, 1300000}},
983         {70,    {1400000, 1300000, 1300000, 1260000}},
984         {80,    {1400000, 1300000, 1300000, 1200000}},
985         {90,    {1400000, 1300000, 1300000, 1100000}},
986 };
987
988 void cardhu_thermal_zones_info(struct tegra_edp_limits **z, int *sz)
989 {
990         *z = cardhu_edp_limits;
991         *sz = ARRAY_SIZE(cardhu_edp_limits);
992 }
993
994 int __init cardhu_edp_init(void)
995 {
996         tegra_init_cpu_edp_limits(cardhu_edp_limits, ARRAY_SIZE(cardhu_edp_limits));
997         return 0;
998 }
999 #endif