arm: tergra: enterprise: Add init code for system edp
[linux-2.6.git] / arch / arm / mach-tegra / board-enterprise-power.c
1 /*
2  * arch/arm/mach-tegra/board-enterprise-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/regulator/gpio-switch-regulator.h>
26 #include <linux/mfd/tps80031.h>
27 #include <linux/regulator/tps80031-regulator.h>
28 #include <linux/tps80031-charger.h>
29 #include <linux/gpio.h>
30 #include <linux/io.h>
31 #include <linux/cpumask.h>
32 #include <linux/platform_data/tegra_bpc_mgmt.h>
33
34 #include <mach/edp.h>
35 #include <mach/iomap.h>
36 #include <mach/irqs.h>
37 #include <mach/pinmux.h>
38 #include <mach/tsensor.h>
39
40 #include "gpio-names.h"
41 #include "board.h"
42 #include "board-enterprise.h"
43 #include "pm.h"
44 #include "wakeups-t3.h"
45
46 #define PMC_CTRL                0x0
47 #define PMC_CTRL_INTR_LOW       (1 << 17)
48
49 #define PMC_DPD_PADS_ORIDE              0x01c
50 #define PMC_DPD_PADS_ORIDE_BLINK        (1 << 20)
51
52 /************************ TPS80031 based regulator ****************/
53 static struct regulator_consumer_supply tps80031_vio_supply[] = {
54         REGULATOR_SUPPLY("vio_1v8", NULL),
55         REGULATOR_SUPPLY("avdd_osc", NULL),
56         REGULATOR_SUPPLY("vddio_sys", NULL),
57         REGULATOR_SUPPLY("vddio_uart", NULL),
58         REGULATOR_SUPPLY("pwrdet_uart", NULL),
59         REGULATOR_SUPPLY("vddio_lcd", NULL),
60         REGULATOR_SUPPLY("pwrdet_lcd", NULL),
61         REGULATOR_SUPPLY("vddio_audio", NULL),
62         REGULATOR_SUPPLY("pwrdet_audio", NULL),
63         REGULATOR_SUPPLY("vddio_bb", NULL),
64         REGULATOR_SUPPLY("pwrdet_bb", NULL),
65         REGULATOR_SUPPLY("vddio_gmi", NULL),
66         REGULATOR_SUPPLY("avdd_usb_pll", NULL),
67         REGULATOR_SUPPLY("vddio_cam", NULL),
68         REGULATOR_SUPPLY("pwrdet_cam", NULL),
69         REGULATOR_SUPPLY("vddio_sdmmc1", NULL),
70         REGULATOR_SUPPLY("pwrdet_sdmmc1", NULL),
71         REGULATOR_SUPPLY("vddio_sdmmc4", NULL),
72         REGULATOR_SUPPLY("pwrdet_sdmmc4", NULL),
73         REGULATOR_SUPPLY("avdd_hdmi_pll", NULL),
74         REGULATOR_SUPPLY("vddio_gps", NULL),
75         REGULATOR_SUPPLY("vdd_lcd_buffered", NULL),
76         REGULATOR_SUPPLY("vddio_nand", NULL),
77         REGULATOR_SUPPLY("pwrdet_nand", NULL),
78         REGULATOR_SUPPLY("vddio_sd", NULL),
79         REGULATOR_SUPPLY("vdd_bat", NULL),
80         REGULATOR_SUPPLY("vdd_io", NULL),
81         REGULATOR_SUPPLY("pwrdet_pex_ctl", NULL),
82 };
83
84 static struct regulator_consumer_supply tps80031_smps1_supply[] = {
85         REGULATOR_SUPPLY("vdd_cpu", NULL),
86 };
87
88 static struct regulator_consumer_supply tps80031_smps2_supply[] = {
89         REGULATOR_SUPPLY("vdd_core", NULL),
90 };
91
92 static struct regulator_consumer_supply tps80031_smps3_supply[] = {
93         REGULATOR_SUPPLY("en_vddio_ddr_1v2", NULL),
94         REGULATOR_SUPPLY("vddio_ddr", NULL),
95         REGULATOR_SUPPLY("vdd_lpddr", NULL),
96         REGULATOR_SUPPLY("ddr_comp_pu", NULL),
97 };
98
99 static struct regulator_consumer_supply tps80031_smps4_supply[] = {
100         REGULATOR_SUPPLY("vddio_sdmmc_2v85", NULL),
101         REGULATOR_SUPPLY("pwrdet_sdmmc3", NULL),
102 };
103
104 static struct regulator_consumer_supply tps80031_vana_supply[] = {
105         REGULATOR_SUPPLY("unused_vana", NULL),
106 };
107
108 static struct regulator_consumer_supply tps80031_ldo1_supply[] = {
109         REGULATOR_SUPPLY("avdd_dsi_csi", NULL),
110         REGULATOR_SUPPLY("pwrdet_mipi", NULL),
111 };
112
113 static struct regulator_consumer_supply tps80031_ldo2_supply[] = {
114         REGULATOR_SUPPLY("vdd_rtc", NULL),
115 };
116
117 static struct regulator_consumer_supply tps80031_ldo3_supply[] = {
118         REGULATOR_SUPPLY("vdd_vbrtr", NULL),
119 };
120
121 static struct regulator_consumer_supply tps80031_ldo4_supply[] = {
122         REGULATOR_SUPPLY("avdd_lcd", NULL),
123 };
124
125 static struct regulator_consumer_supply tps80031_ldo5_supply[] = {
126         REGULATOR_SUPPLY("vdd_sensor", NULL),
127         REGULATOR_SUPPLY("vdd_compass", NULL),
128         REGULATOR_SUPPLY("vdd_als", NULL),
129         REGULATOR_SUPPLY("vdd_gyro", NULL),
130         REGULATOR_SUPPLY("vdd_touch", NULL),
131         REGULATOR_SUPPLY("vdd_proxim_diode", NULL),
132 };
133
134 static struct regulator_consumer_supply tps80031_ldo6_supply[] = {
135         REGULATOR_SUPPLY("vdd_ddr_rx", NULL),
136         REGULATOR_SUPPLY("vddf_core_emmc", NULL),
137 };
138
139 static struct regulator_consumer_supply tps80031_ldo7_supply[] = {
140         REGULATOR_SUPPLY("vdd_plla_p_c_s", NULL),
141         REGULATOR_SUPPLY("vdd_pllm", NULL),
142         REGULATOR_SUPPLY("vdd_pllu_d", NULL),
143         REGULATOR_SUPPLY("vdd_pllx", NULL),
144 };
145
146 static struct regulator_consumer_supply tps80031_ldoln_supply[] = {
147         REGULATOR_SUPPLY("vdd_ddr_hs", NULL),
148 };
149
150 static struct regulator_consumer_supply tps80031_ldousb_supply[] = {
151         REGULATOR_SUPPLY("unused_ldousb", NULL),
152 };
153
154 static struct regulator_consumer_supply tps80031_vbus_supply[] = {
155         REGULATOR_SUPPLY("usb_vbus", NULL),
156 };
157
158 static struct regulator_consumer_supply tps80031_battery_charge_supply[] = {
159         REGULATOR_SUPPLY("usb_bat_chg", NULL),
160 };
161
162 #define TPS_PDATA_INIT(_id, _minmv, _maxmv, _supply_reg, _always_on,    \
163         _boot_on, _apply_uv, _init_uV, _init_enable, _init_apply,       \
164         _flags, _ectrl, _delay)                                         \
165         static struct tps80031_regulator_platform_data pdata_##_id = {  \
166                 .regulator = {                                          \
167                         .constraints = {                                \
168                                 .min_uV = (_minmv)*1000,                \
169                                 .max_uV = (_maxmv)*1000,                \
170                                 .valid_modes_mask = (REGULATOR_MODE_NORMAL |  \
171                                                 REGULATOR_MODE_STANDBY),      \
172                                 .valid_ops_mask = (REGULATOR_CHANGE_MODE |    \
173                                                 REGULATOR_CHANGE_STATUS |     \
174                                                 REGULATOR_CHANGE_VOLTAGE),    \
175                                 .always_on = _always_on,                \
176                                 .boot_on = _boot_on,                    \
177                                 .apply_uV = _apply_uv,                  \
178                         },                                              \
179                         .num_consumer_supplies =                        \
180                                 ARRAY_SIZE(tps80031_##_id##_supply),    \
181                         .consumer_supplies = tps80031_##_id##_supply,   \
182                         .supply_regulator = _supply_reg,                \
183                 },                                                      \
184                 .init_uV =  _init_uV * 1000,                            \
185                 .init_enable = _init_enable,                            \
186                 .init_apply = _init_apply,                              \
187                 .flags = _flags,                                        \
188                 .ext_ctrl_flag = _ectrl,                                \
189                 .delay_us = _delay,                                     \
190         }
191
192 TPS_PDATA_INIT(vio,   600, 2100, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0);
193 TPS_PDATA_INIT(smps1, 600, 2100, 0, 0, 0, 0, -1, 0, 0, 0, PWR_REQ_INPUT_PREQ2 | PWR_OFF_ON_SLEEP, 0);
194 TPS_PDATA_INIT(smps2, 600, 2100, 0, 0, 0, 0, -1, 0, 0, 0, PWR_REQ_INPUT_PREQ1, 0);
195 TPS_PDATA_INIT(smps3, 600, 2100, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0);
196 TPS_PDATA_INIT(smps4, 600, 2100, 0, 0, 0, 0, -1, 0, 0, 0, PWR_REQ_INPUT_PREQ1, 0);
197 TPS_PDATA_INIT(ldo1, 1000, 3300, tps80031_rails(VIO), 0, 0, 0, -1, 0, 0, 0, 0, 0);
198 TPS_PDATA_INIT(ldo2, 1000, 3300, 0, 1, 1, 1, 1000, 1, 1, 0, 0, 0);
199 TPS_PDATA_INIT(ldo3, 1000, 3300, tps80031_rails(VIO), 0, 0, 0, -1, 0, 0, 0, PWR_OFF_ON_SLEEP, 0);
200 TPS_PDATA_INIT(ldo4, 1000, 3300, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0);
201 TPS_PDATA_INIT(ldo5, 1000, 3300, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0);
202 TPS_PDATA_INIT(ldo6, 1000, 3300, 0, 0, 0, 0, -1, 0, 0, 0, PWR_REQ_INPUT_PREQ1, 0);
203 TPS_PDATA_INIT(ldo7, 1000, 3300, tps80031_rails(VIO), 0, 0, 0, -1, 0, 0, 0, PWR_REQ_INPUT_PREQ1, 0);
204 TPS_PDATA_INIT(ldoln, 1000, 3300, tps80031_rails(SMPS3), 0, 0, 0, -1, 0, 0, 0, PWR_REQ_INPUT_PREQ1, 0);
205 TPS_PDATA_INIT(ldousb, 1000, 3300, 0, 0, 0, 0, -1, 0, 0, USBLDO_INPUT_VSYS, PWR_OFF_ON_SLEEP, 0);
206 TPS_PDATA_INIT(vana,  1000, 3300, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0);
207 TPS_PDATA_INIT(vbus,  0, 5000, 0, 0, 0, 0, -1, 0, 0, (VBUS_SW_ONLY | VBUS_DISCHRG_EN_PDN), 0, 100000);
208
209 static struct tps80031_rtc_platform_data rtc_data = {
210         .irq = ENT_TPS80031_IRQ_BASE + TPS80031_INT_RTC_ALARM,
211         .time = {
212                 .tm_year = 2011,
213                 .tm_mon = 0,
214                 .tm_mday = 1,
215                 .tm_hour = 1,
216                 .tm_min = 2,
217                 .tm_sec = 3,
218         },
219 };
220
221 int battery_charger_init(void *board_data)
222 {
223         int ret;
224         ret = gpio_request(TEGRA_GPIO_PF6, "lcd_d14-bat_charge");
225         if (ret < 0) {
226                 pr_err("%s() The gpio_request for battery"
227                                 " charger fails\n", __func__);
228         }
229         gpio_direction_output(TEGRA_GPIO_PF6, 1);
230         tegra_gpio_enable(TEGRA_GPIO_PF6);
231         return 0;
232 }
233
234 static struct tps80031_charger_platform_data bcharger_pdata = {
235         .max_charge_volt_mV = 4100,
236         .max_charge_current_mA = 1000,
237         .charging_term_current_mA = 100,
238         .watch_time_sec = 100,
239         .irq_base = ENT_TPS80031_IRQ_BASE,
240         .consumer_supplies = tps80031_battery_charge_supply,
241         .num_consumer_supplies = ARRAY_SIZE(tps80031_battery_charge_supply),
242         .board_init = battery_charger_init,
243         .board_data = NULL,
244 };
245
246 static struct tps80031_bg_platform_data battery_gauge_data = {
247         .irq_base = ENT_TPS80031_IRQ_BASE,
248         .battery_present = 1,
249 };
250
251 #define TPS_RTC()                               \
252         {                                               \
253                 .id     = 0,            \
254                 .name   = "rtc_tps80031",       \
255                 .platform_data = &rtc_data,     \
256         }
257
258 #define TPS_REG(_id, _data)                             \
259         {                                               \
260                 .id      = TPS80031_ID_##_id,           \
261                 .name   = "tps80031-regulator",         \
262                 .platform_data  = &pdata_##_data,       \
263         }
264 #define TPS_BATTERY()                                   \
265         {                                               \
266                 .name   = "tps80031-charger",           \
267                 .platform_data = &bcharger_pdata,       \
268         }
269 #define TPS_BATTERY_GAUGE()                             \
270         {                                               \
271                 .name   = "tps80031-battery-gauge",     \
272                 .platform_data = &battery_gauge_data,   \
273         }
274 #define TPS_GPADC()                                     \
275         {                                               \
276                 .name   = "tps80031-gpadc",             \
277         }
278
279 static struct tps80031_subdev_info tps80031_devs[] = {
280         TPS_REG(VIO, vio),
281         TPS_REG(SMPS1, smps1),
282         TPS_REG(SMPS2, smps2),
283         TPS_REG(SMPS3, smps3),
284         TPS_REG(SMPS4, smps4),
285         TPS_REG(LDO1, ldo1),
286         TPS_REG(LDO2, ldo2),
287         TPS_REG(LDO3, ldo3),
288         TPS_REG(LDO4, ldo4),
289         TPS_REG(LDO5, ldo5),
290         TPS_REG(LDO6, ldo6),
291         TPS_REG(LDO7, ldo7),
292         TPS_REG(LDOLN, ldoln),
293         TPS_REG(LDOUSB, ldousb),
294         TPS_REG(VANA, vana),
295         TPS_REG(VBUS, vbus),
296         TPS_RTC(),
297         TPS_BATTERY(),
298         TPS_BATTERY_GAUGE(),
299         TPS_GPADC(),
300 };
301
302 struct tps80031_clk32k_init_data clk32k_idata[] = {
303         {
304                 .clk32k_nr = TPS80031_CLOCK32K_G,
305                 .enable = true,
306                 .ext_ctrl_flag = PWR_REQ_INPUT_PREQ1,
307         },
308         {
309                 .clk32k_nr = TPS80031_CLOCK32K_AUDIO,
310                 .enable = true,
311                 .ext_ctrl_flag = PWR_REQ_INPUT_PREQ1,
312         },
313 };
314
315 static struct tps80031_platform_data tps_platform = {
316         .num_subdevs    = ARRAY_SIZE(tps80031_devs),
317         .subdevs        = tps80031_devs,
318         .irq_base       = ENT_TPS80031_IRQ_BASE,
319         .gpio_base      = ENT_TPS80031_GPIO_BASE,
320         .clk32k_init_data       = clk32k_idata,
321         .clk32k_init_data_size  = ARRAY_SIZE(clk32k_idata),
322 };
323
324 static struct i2c_board_info __initdata enterprise_regulators[] = {
325         {
326                 I2C_BOARD_INFO("tps80031", 0x4A),
327                 .irq            = INT_EXTERNAL_PMU,
328                 .platform_data  = &tps_platform,
329         },
330 };
331
332 /************************ GPIO based switch regulator ****************/
333
334 /* REGEN1 from PMU*/
335 static struct regulator_consumer_supply gpio_switch_pmu_5v15_en_supply[] = {
336         REGULATOR_SUPPLY("vdd_5v15", NULL),
337 };
338 static int gpio_switch_pmu_5v15_en_voltages[] = {5000};
339
340 /* REGEN2 from PMU*/
341 static struct regulator_consumer_supply gpio_switch_pmu_3v3_en_supply[] = {
342         REGULATOR_SUPPLY("avdd_usb_hdmi_3v3", NULL),
343         REGULATOR_SUPPLY("avdd_usb", NULL),
344         REGULATOR_SUPPLY("avdd_hdmi", NULL),
345         REGULATOR_SUPPLY("vdd", "4-004c"),
346 };
347 static int gpio_switch_pmu_3v3_en_voltages[] = {3300};
348
349 /* SYSEN from PMU*/
350 static struct regulator_consumer_supply gpio_switch_pmu_hdmi_5v0_en_supply[] = {
351         REGULATOR_SUPPLY("hdmi_5v0", NULL),
352 };
353 static int gpio_switch_pmu_hdmi_5v0_en_voltages[] = {5000};
354
355 /* LCD-D16 (GPIO M0) from T30*/
356 static struct regulator_consumer_supply gpio_switch_vdd_fuse_en_supply[] = {
357         REGULATOR_SUPPLY("vdd_fuse", NULL),
358 };
359 static int gpio_switch_vdd_fuse_en_voltages[] = {3300};
360
361 /* LCD-D17 (GPIO M1) from T30*/
362 static struct regulator_consumer_supply gpio_switch_sdmmc3_vdd_sel_supply[] = {
363         REGULATOR_SUPPLY("vddio_sdmmc3_2v85_1v8", NULL),
364         REGULATOR_SUPPLY("sdmmc3_compu_pu", NULL),
365         REGULATOR_SUPPLY("vddio_sdmmc3", NULL),
366         REGULATOR_SUPPLY("vsys_3v7", NULL),
367 };
368 static int gpio_switch_sdmmc3_vdd_sel_voltages[] = {2850};
369
370 /* LCD-D23 (GPIO M7) from T30*/
371 /* 2-0036 is dev_name of ar0832 in Enterprise A01*/
372 /* 2-0032 is alternative dev_name of ar0832 Enterprise A01*/
373 /* 2-0010 is dev_name of ov9726 */
374 /* 2-0070 is dev_name of PCA9546 in Enterprise A02*/
375 /* 6-0036 is dev_name of ar0832 in Enterprise A02 */
376 /* 7-0036 is dev_name of ar0832 in Enterprise A02 */
377 static struct regulator_consumer_supply gpio_switch_cam_ldo_2v8_en_supply[] = {
378         REGULATOR_SUPPLY("vaa", "2-0036"),
379         REGULATOR_SUPPLY("vaa", "2-0032"),
380         REGULATOR_SUPPLY("avdd", "2-0010"),
381         REGULATOR_SUPPLY("vdd_2v8_cam", NULL),
382         REGULATOR_SUPPLY("vcc", "2-0070"),
383         REGULATOR_SUPPLY("vaa", "6-0036"),
384         REGULATOR_SUPPLY("vaa", "7-0036"),
385 };
386 static int gpio_switch_cam_ldo_2v8_en_voltages[] = {2800};
387
388 /* LCD-D9 (GPIO F1) from T30*/
389 /* 2-0036 is dev_name of ar0832 in Enterprise A01*/
390 /* 2-0032 is alternative dev_name of ar0832 Enterprise A01*/
391 /* 2-0010 is dev_name of ov9726 */
392 /* 2-0033 is dev_name of tps61050 */
393 /* 2-0070 is dev_name of PCA9546 in Enterprise A02*/
394 /* 6-0036 is dev_name of ar0832 in Enterprise A02 */
395 /* 7-0036 is dev_name of ar0832 in Enterprise A02 */
396 static struct regulator_consumer_supply gpio_switch_cam_ldo_1v8_en_supply[] = {
397         REGULATOR_SUPPLY("vdd", "2-0036"),
398         REGULATOR_SUPPLY("vdd", "2-0032"),
399         REGULATOR_SUPPLY("dovdd", "2-0010"),
400         REGULATOR_SUPPLY("vdd_1v8_cam", NULL),
401         REGULATOR_SUPPLY("vdd_i2c", "2-0033"),
402         REGULATOR_SUPPLY("vcc_i2c", "2-0070"),
403         REGULATOR_SUPPLY("vdd", "6-0036"),
404         REGULATOR_SUPPLY("vdd", "7-0036"),
405 };
406 static int gpio_switch_cam_ldo_1v8_en_voltages[] = {1800};
407
408 /* Macro for defining gpio switch regulator sub device data */
409 #define GREG_INIT(_id, _name, _input_supply, _gpio_nr, _active_low, \
410                         _init_state, _pg, _enable, _disable)            \
411         static struct gpio_switch_regulator_subdev_data gpio_pdata_##_name =  \
412         {                                                               \
413                 .regulator_name = "gpio-switch-"#_name,                 \
414                 .input_supply   = _input_supply,                        \
415                 .id             = _id,                                  \
416                 .gpio_nr        = _gpio_nr,                             \
417                 .pin_group      = _pg,                                  \
418                 .active_low     = _active_low,                          \
419                 .init_state     = _init_state,                          \
420                 .voltages       = gpio_switch_##_name##_voltages,       \
421                 .n_voltages     = ARRAY_SIZE(gpio_switch_##_name##_voltages), \
422                 .num_consumer_supplies =                                \
423                                 ARRAY_SIZE(gpio_switch_##_name##_supply), \
424                 .consumer_supplies = gpio_switch_##_name##_supply,      \
425                 .constraints = {                                        \
426                         .valid_modes_mask = (REGULATOR_MODE_NORMAL |    \
427                                         REGULATOR_MODE_STANDBY),        \
428                         .valid_ops_mask = (REGULATOR_CHANGE_MODE |      \
429                                         REGULATOR_CHANGE_STATUS |       \
430                                         REGULATOR_CHANGE_VOLTAGE),      \
431                 },                                                      \
432                 .enable_rail = _enable,                                 \
433                 .disable_rail = _disable,                               \
434         }
435
436 GREG_INIT(0, pmu_5v15_en,     NULL,      ENT_TPS80031_GPIO_REGEN1, false, 0, 0, 0, 0);
437 GREG_INIT(1, pmu_3v3_en,      "vdd_5v15", ENT_TPS80031_GPIO_REGEN2, false, 0, 0, 0, 0);
438 GREG_INIT(2, pmu_hdmi_5v0_en, "vdd_5v15", ENT_TPS80031_GPIO_SYSEN, false, 0, 0, 0, 0);
439
440 GREG_INIT(3, vdd_fuse_en, "avdd_usb_hdmi_3v3", TEGRA_GPIO_PM0, false, 0, 0, 0, 0);
441 GREG_INIT(4, sdmmc3_vdd_sel, "vddio_sdmmc_2v85", TEGRA_GPIO_PM1, false, 0, 0, 0, 0);
442 GREG_INIT(5, cam_ldo_2v8_en, NULL, TEGRA_GPIO_PM7, false, 0, 0, 0, 0);
443 GREG_INIT(6, cam_ldo_1v8_en, NULL, TEGRA_GPIO_PF1, false, 0, 0, 0, 0);
444
445 #define ADD_GPIO_REG(_name)     (&gpio_pdata_##_name)
446 static struct gpio_switch_regulator_subdev_data *gswitch_subdevs[] = {
447         ADD_GPIO_REG(pmu_5v15_en),
448         ADD_GPIO_REG(pmu_3v3_en),
449         ADD_GPIO_REG(pmu_hdmi_5v0_en),
450         ADD_GPIO_REG(vdd_fuse_en),
451         ADD_GPIO_REG(sdmmc3_vdd_sel),
452         ADD_GPIO_REG(cam_ldo_2v8_en),
453         ADD_GPIO_REG(cam_ldo_1v8_en),
454 };
455
456 static struct gpio_switch_regulator_platform_data  gswitch_pdata = {
457         .num_subdevs = ARRAY_SIZE(gswitch_subdevs),
458         .subdevs = gswitch_subdevs,
459 };
460
461 static struct platform_device gswitch_regulator_pdata = {
462         .name   = "gpio-switch-regulator",
463         .id     = -1,
464         .dev    = {
465                 .platform_data = &gswitch_pdata,
466         },
467 };
468
469 static int __init enterprise_gpio_switch_regulator_init(void)
470 {
471         int i;
472         for (i = 0; i < gswitch_pdata.num_subdevs; ++i) {
473                 struct gpio_switch_regulator_subdev_data *gswitch_data =
474                                                 gswitch_pdata.subdevs[i];
475                 if (gswitch_data->gpio_nr <= TEGRA_NR_GPIOS)
476                         tegra_gpio_enable(gswitch_data->gpio_nr);
477         }
478         return platform_device_register(&gswitch_regulator_pdata);
479 }
480
481 static void enterprise_power_off(void)
482 {
483         int ret;
484         pr_info("enterprise: Powering off the device\n");
485         ret = tps80031_power_off();
486         if (ret)
487                 pr_err("enterprise: failed to power off\n");
488         while(1);
489 }
490
491 void __init enterprise_tsensor_init(void)
492 {
493         tegra3_tsensor_init(NULL);
494 }
495
496 int __init enterprise_regulator_init(void)
497 {
498         void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE);
499         u32 pmc_ctrl;
500         u32 pmc_dpd_pads;
501
502         /* configure the power management controller to trigger PMU
503          * interrupts when low */
504
505         pmc_ctrl = readl(pmc + PMC_CTRL);
506         writel(pmc_ctrl | PMC_CTRL_INTR_LOW, pmc + PMC_CTRL);
507
508         pmc_dpd_pads = readl(pmc + PMC_DPD_PADS_ORIDE);
509         writel(pmc_dpd_pads & ~PMC_DPD_PADS_ORIDE_BLINK , pmc + PMC_DPD_PADS_ORIDE);
510
511         /* Disable battery charging if power adapter is connected. */
512         if (get_power_supply_type() == POWER_SUPPLY_TYPE_MAINS) {
513                 bcharger_pdata.num_consumer_supplies = 0;
514                 bcharger_pdata.consumer_supplies = NULL;
515                 battery_gauge_data.battery_present = 0;
516         }
517
518         i2c_register_board_info(4, enterprise_regulators, 1);
519         enterprise_gpio_switch_regulator_init();
520         pm_power_off = enterprise_power_off;
521
522         return 0;
523 }
524
525 static void enterprise_board_suspend(int lp_state, enum suspend_stage stg)
526 {
527         if ((lp_state == TEGRA_SUSPEND_LP1) && (stg == TEGRA_SUSPEND_BEFORE_CPU))
528                 tegra_console_uart_suspend();
529 }
530
531 static void enterprise_board_resume(int lp_state, enum resume_stage stg)
532 {
533         if ((lp_state == TEGRA_SUSPEND_LP1) && (stg == TEGRA_RESUME_AFTER_CPU))
534                 tegra_console_uart_resume();
535 }
536
537 static struct tegra_suspend_platform_data enterprise_suspend_data = {
538         .cpu_timer      = 2000,
539         .cpu_off_timer  = 200,
540         .suspend_mode   = TEGRA_SUSPEND_LP0,
541         .core_timer     = 0x7e7e,
542         .core_off_timer = 0,
543         .corereq_high   = true,
544         .sysclkreq_high = true,
545         .board_suspend = enterprise_board_suspend,
546         .board_resume = enterprise_board_resume,
547 };
548
549 static void enterprise_init_deep_sleep_mode(void)
550 {
551         struct board_info bi;
552         tegra_get_board_info(&bi);
553
554         if (bi.board_id == BOARD_E1205 && bi.fab == BOARD_FAB_A01)
555                 enterprise_suspend_data.suspend_mode = TEGRA_SUSPEND_LP1;
556
557         if ((bi.board_id == BOARD_E1205 && (bi.sku & BOARD_SKU_VF_BIT) == 0) ||
558             (bi.board_id == BOARD_E1197 && (bi.sku & BOARD_SKU_VF_BIT)))
559                 enterprise_suspend_data.cpu_timer = 8000;
560 }
561
562 int __init enterprise_suspend_init(void)
563 {
564         enterprise_init_deep_sleep_mode();
565         tegra_init_suspend(&enterprise_suspend_data);
566         return 0;
567 }
568
569 #ifdef CONFIG_TEGRA_EDP_LIMITS
570
571 int __init enterprise_edp_init(void)
572 {
573         unsigned int regulator_mA;
574
575         regulator_mA = get_maximum_cpu_current_supported();
576         if (!regulator_mA) {
577                 regulator_mA = 2500; /* regular AP30 */
578         }
579         pr_info("%s: CPU regulator %d mA\n", __func__, regulator_mA);
580
581         tegra_init_cpu_edp_limits(regulator_mA);
582         tegra_init_system_edp_limits(TEGRA_BPC_CPU_PWR_LIMIT);
583         return 0;
584 }
585 #endif
586
587 static struct tegra_bpc_mgmt_platform_data bpc_mgmt_platform_data = {
588         .gpio_trigger = TEGRA_BPC_TRIGGER,
589         .bpc_mgmt_timeout = TEGRA_BPC_TIMEOUT,
590 };
591
592 static struct platform_device enterprise_bpc_mgmt_device = {
593         .name           = "tegra-bpc-mgmt",
594         .id             = -1,
595         .dev            = {
596                 .platform_data = &bpc_mgmt_platform_data,
597         },
598 };
599
600 void __init enterprise_bpc_mgmt_init(void)
601 {
602         int int_gpio = TEGRA_GPIO_TO_IRQ(TEGRA_BPC_TRIGGER);
603
604         tegra_gpio_enable(TEGRA_BPC_TRIGGER);
605
606 #ifdef CONFIG_SMP
607         cpumask_setall(&(bpc_mgmt_platform_data.affinity_mask));
608         irq_set_affinity_hint(int_gpio,
609                                 &(bpc_mgmt_platform_data.affinity_mask));
610         irq_set_affinity(int_gpio, &(bpc_mgmt_platform_data.affinity_mask));
611 #endif
612         platform_device_register(&enterprise_bpc_mgmt_device);
613
614         return;
615 }