ARM: tegra: usb: enable pmu vbus interrupts
[linux-2.6.git] / arch / arm / mach-tegra / board-enterprise.c
1 /*
2  * arch/arm/mach-tegra/board-enterprise.c
3  *
4  * Copyright (c) 2011-2012, NVIDIA Corporation.
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 as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19  */
20
21 #include <linux/kernel.h>
22 #include <linux/init.h>
23 #include <linux/slab.h>
24 #include <linux/ctype.h>
25 #include <linux/platform_device.h>
26 #include <linux/clk.h>
27 #include <linux/serial_8250.h>
28 #include <linux/i2c.h>
29 #include <linux/dma-mapping.h>
30 #include <linux/delay.h>
31 #include <linux/i2c-tegra.h>
32 #include <linux/gpio.h>
33 #include <linux/input.h>
34 #include <linux/platform_data/tegra_usb.h>
35 #include <linux/spi/spi.h>
36 #include <linux/tegra_uart.h>
37 #include <linux/fsl_devices.h>
38 #include <linux/i2c/atmel_mxt_ts.h>
39 #include <linux/memblock.h>
40
41 #include <linux/nfc/pn544.h>
42 #include <sound/max98088.h>
43
44 #include <asm/hardware/gic.h>
45
46 #include <mach/clk.h>
47 #include <mach/iomap.h>
48 #include <mach/irqs.h>
49 #include <mach/pinmux.h>
50 #include <mach/iomap.h>
51 #include <mach/io.h>
52 #include <asm/mach-types.h>
53 #include <asm/mach/arch.h>
54 #include <mach/usb_phy.h>
55 #include <mach/i2s.h>
56 #include <mach/tegra_asoc_pdata.h>
57 #include <mach/thermal.h>
58 #include <mach/tegra-bb-power.h>
59 #include <mach/gpio-tegra.h>
60
61 #include "board.h"
62 #include "clock.h"
63 #include "board-enterprise.h"
64 #include "baseband-xmm-power.h"
65 #include "devices.h"
66 #include "gpio-names.h"
67 #include "fuse.h"
68 #include "pm.h"
69
70 /* All units are in millicelsius */
71 static struct tegra_thermal_data thermal_data = {
72         .temp_shutdown = 90000,
73         .temp_offset = TDIODE_OFFSET, /* temps based on tdiode */
74 #ifdef CONFIG_TEGRA_EDP_LIMITS
75         .edp_offset = TDIODE_OFFSET,  /* edp based on tdiode */
76         .hysteresis_edp = 3000,
77 #endif
78 #ifdef CONFIG_TEGRA_THERMAL_THROTTLE
79         .temp_throttle = 85000,
80         .tc1 = 0,
81         .tc2 = 1,
82         .passive_delay = 2000,
83 #endif
84 };
85
86 static struct resource enterprise_bcm4329_rfkill_resources[] = {
87         {
88                 .name   = "bcm4329_nshutdown_gpio",
89                 .start  = TEGRA_GPIO_PE6,
90                 .end    = TEGRA_GPIO_PE6,
91                 .flags  = IORESOURCE_IO,
92         },
93 };
94
95 static struct platform_device enterprise_bcm4329_rfkill_device = {
96         .name = "bcm4329_rfkill",
97         .id             = -1,
98         .num_resources  = ARRAY_SIZE(enterprise_bcm4329_rfkill_resources),
99         .resource       = enterprise_bcm4329_rfkill_resources,
100 };
101
102 static struct resource enterprise_bluesleep_resources[] = {
103         [0] = {
104                 .name = "gpio_host_wake",
105                         .start  = TEGRA_GPIO_PS2,
106                         .end    = TEGRA_GPIO_PS2,
107                         .flags  = IORESOURCE_IO,
108         },
109         [1] = {
110                 .name = "gpio_ext_wake",
111                         .start  = TEGRA_GPIO_PE7,
112                         .end    = TEGRA_GPIO_PE7,
113                         .flags  = IORESOURCE_IO,
114         },
115         [2] = {
116                 .name = "host_wake",
117                         .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
118         },
119 };
120
121 static struct platform_device enterprise_bluesleep_device = {
122         .name           = "bluesleep",
123         .id             = -1,
124         .num_resources  = ARRAY_SIZE(enterprise_bluesleep_resources),
125         .resource       = enterprise_bluesleep_resources,
126 };
127
128 static void __init enterprise_setup_bluesleep(void)
129 {
130         enterprise_bluesleep_resources[2].start =
131                 enterprise_bluesleep_resources[2].end =
132                         gpio_to_irq(TEGRA_GPIO_PS2);
133         platform_device_register(&enterprise_bluesleep_device);
134         tegra_gpio_enable(TEGRA_GPIO_PS2);
135         tegra_gpio_enable(TEGRA_GPIO_PE7);
136         return;
137 }
138
139 static __initdata struct tegra_clk_init_table enterprise_clk_init_table[] = {
140         /* name         parent          rate            enabled */
141         { "pll_m",      NULL,           0,              false},
142         { "hda",        "pll_p",        108000000,      false},
143         { "hda2codec_2x","pll_p",       48000000,       false},
144         { "pwm",        "clk_32k",      32768,          false},
145         { "blink",      "clk_32k",      32768,          true},
146         { "i2s0",       "pll_a_out0",   0,              false},
147         { "i2s1",       "pll_a_out0",   0,              false},
148         { "i2s2",       "pll_a_out0",   0,              false},
149         { "i2s3",       "pll_a_out0",   0,              false},
150         { "spdif_out",  "pll_a_out0",   0,              false},
151         { "d_audio",    "clk_m",        12000000,       false},
152         { "dam0",       "clk_m",        12000000,       false},
153         { "dam1",       "clk_m",        12000000,       false},
154         { "dam2",       "clk_m",        12000000,       false},
155         { "audio0",     "i2s0_sync",    0,              false},
156         { "audio1",     "i2s1_sync",    0,              false},
157         { "audio2",     "i2s2_sync",    0,              false},
158         { "audio3",     "i2s3_sync",    0,              false},
159         { "vi",         "pll_p",        0,              false},
160         { "vi_sensor",  "pll_p",        0,              false},
161         { NULL,         NULL,           0,              0},
162 };
163
164 static struct tegra_i2c_platform_data enterprise_i2c1_platform_data = {
165         .adapter_nr     = 0,
166         .bus_count      = 1,
167         .bus_clk_rate   = { 100000, 0 },
168         .scl_gpio               = {TEGRA_GPIO_PC4, 0},
169         .sda_gpio               = {TEGRA_GPIO_PC5, 0},
170         .arb_recovery = arb_lost_recovery,
171 };
172
173 static struct tegra_i2c_platform_data enterprise_i2c2_platform_data = {
174         .adapter_nr     = 1,
175         .bus_count      = 1,
176         .bus_clk_rate   = { 400000, 0 },
177         .is_clkon_always = true,
178         .scl_gpio               = {TEGRA_GPIO_PT5, 0},
179         .sda_gpio               = {TEGRA_GPIO_PT6, 0},
180         .arb_recovery = arb_lost_recovery,
181 };
182
183 static struct tegra_i2c_platform_data enterprise_i2c3_platform_data = {
184         .adapter_nr     = 2,
185         .bus_count      = 1,
186         .bus_clk_rate   = { 271000, 0 },
187         .scl_gpio               = {TEGRA_GPIO_PBB1, 0},
188         .sda_gpio               = {TEGRA_GPIO_PBB2, 0},
189         .arb_recovery = arb_lost_recovery,
190 };
191
192 static struct tegra_i2c_platform_data enterprise_i2c4_platform_data = {
193         .adapter_nr     = 3,
194         .bus_count      = 1,
195         .bus_clk_rate   = { 10000, 0 },
196         .scl_gpio               = {TEGRA_GPIO_PV4, 0},
197         .sda_gpio               = {TEGRA_GPIO_PV5, 0},
198         .arb_recovery = arb_lost_recovery,
199 };
200
201 static struct tegra_i2c_platform_data enterprise_i2c5_platform_data = {
202         .adapter_nr     = 4,
203         .bus_count      = 1,
204         .bus_clk_rate   = { 100000, 0 },
205         .scl_gpio               = {TEGRA_GPIO_PZ6, 0},
206         .sda_gpio               = {TEGRA_GPIO_PZ7, 0},
207         .arb_recovery = arb_lost_recovery,
208 };
209
210 /* Equalizer filter coefs generated from the MAXIM MAX98088
211  * evkit software tool */
212 static struct max98088_eq_cfg max98088_eq_cfg[] = {
213         {
214                 .name = "FLAT",
215                 .rate = 44100,
216                 .band1 = {0x2000, 0xC002, 0x4000, 0x00E9, 0x0000},
217                 .band2 = {0x2000, 0xC00F, 0x4000, 0x02BC, 0x0000},
218                 .band3 = {0x2000, 0xC0A7, 0x4000, 0x0916, 0x0000},
219                 .band4 = {0x2000, 0xC5C2, 0x4000, 0x1A87, 0x0000},
220                 .band5 = {0x2000, 0xF6B0, 0x4000, 0x3F51, 0x0000},
221         },
222         {
223                 .name = "LOWPASS1K",
224                 .rate = 44100,
225                 .band1 = {0x205D, 0xC001, 0x3FEF, 0x002E, 0x02E0},
226                 .band2 = {0x5B9A, 0xC093, 0x3AB2, 0x088B, 0x1981},
227                 .band3 = {0x0D22, 0xC170, 0x26EA, 0x0D79, 0x32CF},
228                 .band4 = {0x0894, 0xC612, 0x01B3, 0x1B34, 0x3FFA},
229                 .band5 = {0x0815, 0x3FFF, 0xCF78, 0x0000, 0x29B7},
230         },
231         { /* BASS=-12dB, TREBLE=+9dB, Fc=5KHz */
232                 .name = "HIBOOST",
233                 .rate = 44100,
234                 .band1 = {0x0815, 0xC001, 0x3AA4, 0x0003, 0x19A2},
235                 .band2 = {0x0815, 0xC103, 0x092F, 0x0B55, 0x3F56},
236                 .band3 = {0x0E0A, 0xC306, 0x1E5C, 0x136E, 0x3856},
237                 .band4 = {0x2459, 0xF665, 0x0CAA, 0x3F46, 0x3EBB},
238                 .band5 = {0x5BBB, 0x3FFF, 0xCEB0, 0x0000, 0x28CA},
239         },
240         { /* BASS=12dB, TREBLE=+12dB */
241                 .name = "LOUD12DB",
242                 .rate = 44100,
243                 .band1 = {0x7FC1, 0xC001, 0x3EE8, 0x0020, 0x0BC7},
244                 .band2 = {0x51E9, 0xC016, 0x3C7C, 0x033F, 0x14E9},
245                 .band3 = {0x1745, 0xC12C, 0x1680, 0x0C2F, 0x3BE9},
246                 .band4 = {0x4536, 0xD7E2, 0x0ED4, 0x31DD, 0x3E42},
247                 .band5 = {0x7FEF, 0x3FFF, 0x0BAB, 0x0000, 0x3EED},
248         },
249         {
250                 .name = "FLAT",
251                 .rate = 16000,
252                 .band1 = {0x2000, 0xC004, 0x4000, 0x0141, 0x0000},
253                 .band2 = {0x2000, 0xC033, 0x4000, 0x0505, 0x0000},
254                 .band3 = {0x2000, 0xC268, 0x4000, 0x115F, 0x0000},
255                 .band4 = {0x2000, 0xDA62, 0x4000, 0x33C6, 0x0000},
256                 .band5 = {0x2000, 0x4000, 0x4000, 0x0000, 0x0000},
257         },
258         {
259                 .name = "LOWPASS1K",
260                 .rate = 16000,
261                 .band1 = {0x2000, 0xC004, 0x4000, 0x0141, 0x0000},
262                 .band2 = {0x5BE8, 0xC3E0, 0x3307, 0x15ED, 0x26A0},
263                 .band3 = {0x0F71, 0xD15A, 0x08B3, 0x2BD0, 0x3F67},
264                 .band4 = {0x0815, 0x3FFF, 0xCF78, 0x0000, 0x29B7},
265                 .band5 = {0x0815, 0x3FFF, 0xCF78, 0x0000, 0x29B7},
266         },
267         { /* BASS=-12dB, TREBLE=+9dB, Fc=2KHz */
268                 .name = "HIBOOST",
269                 .rate = 16000,
270                 .band1 = {0x0815, 0xC001, 0x3BD2, 0x0009, 0x16BF},
271                 .band2 = {0x080E, 0xC17E, 0xF653, 0x0DBD, 0x3F43},
272                 .band3 = {0x0F80, 0xDF45, 0xEE33, 0x36FE, 0x3D79},
273                 .band4 = {0x590B, 0x3FF0, 0xE882, 0x02BD, 0x3B87},
274                 .band5 = {0x4C87, 0xF3D0, 0x063F, 0x3ED4, 0x3FB1},
275         },
276         { /* BASS=12dB, TREBLE=+12dB */
277                 .name = "LOUD12DB",
278                 .rate = 16000,
279                 .band1 = {0x7FC1, 0xC001, 0x3D07, 0x0058, 0x1344},
280                 .band2 = {0x2DA6, 0xC013, 0x3CF1, 0x02FF, 0x138B},
281                 .band3 = {0x18F1, 0xC08E, 0x244D, 0x0863, 0x34B5},
282                 .band4 = {0x2BE0, 0xF385, 0x04FD, 0x3EC5, 0x3FCE},
283                 .band5 = {0x7FEF, 0x4000, 0x0BAB, 0x0000, 0x3EED},
284         },
285 };
286
287
288 static struct max98088_pdata enterprise_max98088_pdata = {
289         /* equalizer configuration */
290         .eq_cfg = max98088_eq_cfg,
291         .eq_cfgcnt = ARRAY_SIZE(max98088_eq_cfg),
292
293         /* debounce time */
294         .debounce_time_ms = 200,
295
296         /* microphone configuration */
297         .digmic_left_mode = 1,
298         .digmic_right_mode = 1,
299
300         /* receiver output configuration */
301         .receiver_mode = 0,     /* 0 = amplifier, 1 = line output */
302 };
303
304 static struct pn544_i2c_platform_data nfc_pdata = {
305                 .irq_gpio = TEGRA_GPIO_PS4,
306                 .ven_gpio = TEGRA_GPIO_PM6,
307                 .firm_gpio = 0,
308 };
309
310
311 static struct i2c_board_info __initdata max98088_board_info = {
312         I2C_BOARD_INFO("max98088", 0x10),
313         .platform_data = &enterprise_max98088_pdata,
314 };
315
316 static struct i2c_board_info __initdata enterprise_codec_aic326x_info = {
317         I2C_BOARD_INFO("aic3262-codec", 0x18),
318 };
319
320 static struct i2c_board_info __initdata nfc_board_info = {
321         I2C_BOARD_INFO("pn544", 0x28),
322         .platform_data = &nfc_pdata,
323 };
324
325 static void enterprise_i2c_init(void)
326 {
327         tegra_i2c_device1.dev.platform_data = &enterprise_i2c1_platform_data;
328         tegra_i2c_device2.dev.platform_data = &enterprise_i2c2_platform_data;
329         tegra_i2c_device3.dev.platform_data = &enterprise_i2c3_platform_data;
330         tegra_i2c_device4.dev.platform_data = &enterprise_i2c4_platform_data;
331         tegra_i2c_device5.dev.platform_data = &enterprise_i2c5_platform_data;
332
333         platform_device_register(&tegra_i2c_device5);
334         platform_device_register(&tegra_i2c_device4);
335         platform_device_register(&tegra_i2c_device3);
336         platform_device_register(&tegra_i2c_device2);
337         platform_device_register(&tegra_i2c_device1);
338
339         max98088_board_info.irq = enterprise_codec_aic326x_info.irq =
340                 gpio_to_irq(TEGRA_GPIO_HP_DET);
341         i2c_register_board_info(0, &max98088_board_info, 1);
342         i2c_register_board_info(0, &enterprise_codec_aic326x_info, 1);
343         nfc_board_info.irq = gpio_to_irq(TEGRA_GPIO_PS4);
344         i2c_register_board_info(0, &nfc_board_info, 1);
345 }
346
347 static struct platform_device *enterprise_uart_devices[] __initdata = {
348         &tegra_uarta_device,
349         &tegra_uartb_device,
350         &tegra_uartc_device,
351         &tegra_uartd_device,
352         &tegra_uarte_device,
353 };
354
355 static struct uart_clk_parent uart_parent_clk[] = {
356         [0] = {.name = "clk_m"},
357         [1] = {.name = "pll_p"},
358 #ifndef CONFIG_TEGRA_PLLM_RESTRICTED
359         [2] = {.name = "pll_m"},
360 #endif
361 };
362 static struct tegra_uart_platform_data enterprise_uart_pdata;
363 static struct tegra_uart_platform_data enterprise_loopback_uart_pdata;
364
365 static void __init uart_debug_init(void)
366 {
367         unsigned long rate;
368         struct clk *c;
369
370         /* UARTD is the debug port. */
371         pr_info("Selecting UARTD as the debug console\n");
372         enterprise_uart_devices[3] = &debug_uartd_device;
373         debug_uart_port_base = ((struct plat_serial8250_port *)(
374                         debug_uartd_device.dev.platform_data))->mapbase;
375         debug_uart_clk = clk_get_sys("serial8250.0", "uartd");
376
377         /* Clock enable for the debug channel */
378         if (!IS_ERR_OR_NULL(debug_uart_clk)) {
379                 rate = ((struct plat_serial8250_port *)(
380                         debug_uartd_device.dev.platform_data))->uartclk;
381                 pr_info("The debug console clock name is %s\n",
382                                                 debug_uart_clk->name);
383                 c = tegra_get_clock_by_name("pll_p");
384                 if (IS_ERR_OR_NULL(c))
385                         pr_err("Not getting the parent clock pll_p\n");
386                 else
387                         clk_set_parent(debug_uart_clk, c);
388
389                 clk_enable(debug_uart_clk);
390                 clk_set_rate(debug_uart_clk, rate);
391         } else {
392                 pr_err("Not getting the clock %s for debug console\n",
393                                 debug_uart_clk->name);
394         }
395 }
396
397 static void __init enterprise_uart_init(void)
398 {
399         int i;
400         struct clk *c;
401
402         for (i = 0; i < ARRAY_SIZE(uart_parent_clk); ++i) {
403                 c = tegra_get_clock_by_name(uart_parent_clk[i].name);
404                 if (IS_ERR_OR_NULL(c)) {
405                         pr_err("Not able to get the clock for %s\n",
406                                                 uart_parent_clk[i].name);
407                         continue;
408                 }
409                 uart_parent_clk[i].parent_clk = c;
410                 uart_parent_clk[i].fixed_clk_rate = clk_get_rate(c);
411         }
412         enterprise_uart_pdata.parent_clk_list = uart_parent_clk;
413         enterprise_uart_pdata.parent_clk_count = ARRAY_SIZE(uart_parent_clk);
414         enterprise_loopback_uart_pdata.parent_clk_list = uart_parent_clk;
415         enterprise_loopback_uart_pdata.parent_clk_count =
416                                                 ARRAY_SIZE(uart_parent_clk);
417         enterprise_loopback_uart_pdata.is_loopback = true;
418         tegra_uarta_device.dev.platform_data = &enterprise_uart_pdata;
419         tegra_uartb_device.dev.platform_data = &enterprise_uart_pdata;
420         tegra_uartc_device.dev.platform_data = &enterprise_uart_pdata;
421         tegra_uartd_device.dev.platform_data = &enterprise_uart_pdata;
422         /* UARTE is used for loopback test purpose */
423         tegra_uarte_device.dev.platform_data = &enterprise_loopback_uart_pdata;
424
425         /* Register low speed only if it is selected */
426         if (!is_tegra_debug_uartport_hs())
427                 uart_debug_init();
428
429         platform_add_devices(enterprise_uart_devices,
430                                 ARRAY_SIZE(enterprise_uart_devices));
431 }
432
433
434
435 static struct resource tegra_rtc_resources[] = {
436         [0] = {
437                 .start = TEGRA_RTC_BASE,
438                 .end = TEGRA_RTC_BASE + TEGRA_RTC_SIZE - 1,
439                 .flags = IORESOURCE_MEM,
440         },
441         [1] = {
442                 .start = INT_RTC,
443                 .end = INT_RTC,
444                 .flags = IORESOURCE_IRQ,
445         },
446 };
447
448 static struct platform_device tegra_rtc_device = {
449         .name = "tegra_rtc",
450         .id   = -1,
451         .resource = tegra_rtc_resources,
452         .num_resources = ARRAY_SIZE(tegra_rtc_resources),
453 };
454
455 static struct platform_device tegra_camera = {
456         .name = "tegra_camera",
457         .id = -1,
458 };
459
460 static struct tegra_asoc_platform_data enterprise_audio_pdata = {
461         .gpio_spkr_en           = -1,
462         .gpio_hp_det            = TEGRA_GPIO_HP_DET,
463         .gpio_hp_mute           = -1,
464         .gpio_int_mic_en        = -1,
465         .gpio_ext_mic_en        = -1,
466         .debounce_time_hp = -1,
467         /*defaults for Enterprise board*/
468         .audio_port_id          = {
469                 [HIFI_CODEC] = 0,
470                 [BASEBAND] = 2,
471                 [BT_SCO] = 3,
472         },
473         .baseband_param         = {
474                 .rate = 8000,
475                 .channels = 1,
476         },
477 };
478
479 static struct platform_device enterprise_audio_device = {
480         .name   = "tegra-snd-max98088",
481         .id     = 0,
482         .dev    = {
483                 .platform_data  = &enterprise_audio_pdata,
484         },
485 };
486
487 static struct tegra_asoc_platform_data enterprise_audio_aic326x_pdata = {
488         .gpio_spkr_en           = -1,
489         .gpio_hp_det            = TEGRA_GPIO_HP_DET,
490         .gpio_hp_mute           = -1,
491         .gpio_int_mic_en        = -1,
492         .gpio_ext_mic_en        = -1,
493         /*defaults for Verbier-Enterprise (E1197) board with TI AIC326X codec*/
494         .audio_port_id          = {
495                 [HIFI_CODEC] = 0,
496                 [BASEBAND] = 2,
497                 [BT_SCO] = 3,
498         },
499         .baseband_param         = {
500                 .rate = 8000,
501                 .channels = 1,
502                 .bit_format = TEGRA_DAIFMT_DSP_A,
503         },
504 };
505
506 static struct platform_device enterprise_audio_aic326x_device = {
507         .name   = "tegra-snd-aic326x",
508         .id     = 0,
509         .dev    = {
510                 .platform_data  = &enterprise_audio_aic326x_pdata,
511         },
512 };
513
514 static struct platform_device *enterprise_devices[] __initdata = {
515         &tegra_pmu_device,
516         &tegra_rtc_device,
517         &tegra_udc_device,
518 #if defined(CONFIG_TEGRA_IOVMM_SMMU) || defined(CONFIG_TEGRA_IOMMU_SMMU)
519         &tegra_smmu_device,
520 #endif
521         &tegra_wdt_device,
522 #if defined(CONFIG_TEGRA_AVP)
523         &tegra_avp_device,
524 #endif
525         &tegra_camera,
526         &enterprise_bcm4329_rfkill_device,
527         &tegra_spi_device4,
528         &tegra_hda_device,
529 #if defined(CONFIG_CRYPTO_DEV_TEGRA_SE)
530         &tegra_se_device,
531 #endif
532 #if defined(CONFIG_CRYPTO_DEV_TEGRA_AES)
533         &tegra_aes_device,
534 #endif
535 };
536
537 #define MXT_CONFIG_CRC 0x62F903
538 /*
539  * Config converted from memory-mapped cfg-file with
540  * following version information:
541  *
542  *
543  *
544  *      FAMILY_ID=128
545  *      VARIANT=1
546  *      VERSION=32
547  *      BUILD=170
548  *      VENDOR_ID=255
549  *      PRODUCT_ID=TBD
550  *      CHECKSUM=0xC189B6
551  *
552  *
553  */
554
555 static const u8 config[] = {
556         0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
557         0xFF, 0xFF, 0x32, 0x0A, 0x00, 0x05, 0x01, 0x00,
558         0x00, 0x1E, 0x0A, 0x8B, 0x00, 0x00, 0x13, 0x0B,
559         0x00, 0x10, 0x32, 0x03, 0x03, 0x00, 0x03, 0x01,
560         0x00, 0x0A, 0x0A, 0x0A, 0x0A, 0xBF, 0x03, 0x1B,
561         0x02, 0x00, 0x00, 0x37, 0x37, 0x00, 0x00, 0x00,
562         0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
563         0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
564         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
565         0x00, 0x00, 0x00, 0xA9, 0x7F, 0x9A, 0x0E, 0x00,
566         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
567         0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00,
568         0x00, 0x00, 0x03, 0x23, 0x00, 0x00, 0x00, 0x0A,
569         0x0F, 0x14, 0x19, 0x03, 0x00, 0x00, 0x00, 0x00,
570         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
571         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
572         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
573         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
574         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
575         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
576         0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0x08, 0x10,
577         0x00
578 };
579
580 static struct mxt_platform_data atmel_mxt_info = {
581         .x_line         = 19,
582         .y_line         = 11,
583         .x_size         = 960,
584         .y_size         = 540,
585         .blen           = 0x10,
586         .threshold      = 0x32,
587         .voltage        = 3300000,              /* 3.3V */
588         .orient         = 3,
589         .config         = config,
590         .config_length  = 168,
591         .config_crc     = MXT_CONFIG_CRC,
592         .irqflags       = IRQF_TRIGGER_FALLING,
593 /*      .read_chg       = &read_chg, */
594         .read_chg       = NULL,
595 };
596
597 static struct i2c_board_info __initdata atmel_i2c_info[] = {
598         {
599                 I2C_BOARD_INFO("atmel_mxt_ts", MXT224_I2C_ADDR1),
600                 .platform_data = &atmel_mxt_info,
601         }
602 };
603
604 static int __init enterprise_touch_init(void)
605 {
606         tegra_gpio_enable(TEGRA_GPIO_PH6);
607         tegra_gpio_enable(TEGRA_GPIO_PF5);
608
609         gpio_request(TEGRA_GPIO_PH6, "atmel-irq");
610         gpio_direction_input(TEGRA_GPIO_PH6);
611
612         gpio_request(TEGRA_GPIO_PF5, "atmel-reset");
613         gpio_direction_output(TEGRA_GPIO_PF5, 0);
614         msleep(1);
615         gpio_set_value(TEGRA_GPIO_PF5, 1);
616         msleep(100);
617
618         atmel_i2c_info[0].irq = gpio_to_irq(TEGRA_GPIO_PH6);
619         i2c_register_board_info(1, atmel_i2c_info, 1);
620
621         return 0;
622 }
623
624 static void enterprise_usb_hsic_postsupend(void)
625 {
626         pr_debug("%s\n", __func__);
627 #ifdef CONFIG_TEGRA_BB_XMM_POWER
628         baseband_xmm_set_power_status(BBXMM_PS_L2);
629 #endif
630 }
631
632 static void enterprise_usb_hsic_preresume(void)
633 {
634         pr_debug("%s\n", __func__);
635 #ifdef CONFIG_TEGRA_BB_XMM_POWER
636         baseband_xmm_set_power_status(BBXMM_PS_L2TOL0);
637 #endif
638 }
639
640 static void enterprise_usb_hsic_phy_power(void)
641 {
642         pr_debug("%s\n", __func__);
643 #ifdef CONFIG_TEGRA_BB_XMM_POWER
644         baseband_xmm_set_power_status(BBXMM_PS_L0);
645 #endif
646 }
647
648 static void enterprise_usb_hsic_post_phy_off(void)
649 {
650         pr_debug("%s\n", __func__);
651 #ifdef CONFIG_TEGRA_BB_XMM_POWER
652         baseband_xmm_set_power_status(BBXMM_PS_L3);
653 #endif
654 }
655
656 static struct tegra_usb_phy_platform_ops hsic_xmm_plat_ops = {
657         .post_suspend = enterprise_usb_hsic_postsupend,
658         .pre_resume = enterprise_usb_hsic_preresume,
659         .port_power = enterprise_usb_hsic_phy_power,
660         .post_phy_off = enterprise_usb_hsic_post_phy_off,
661 };
662
663 static struct tegra_usb_platform_data tegra_ehci2_hsic_xmm_pdata = {
664         .port_otg = false,
665         .has_hostpc = true,
666         .phy_intf = TEGRA_USB_PHY_INTF_HSIC,
667         .op_mode        = TEGRA_USB_OPMODE_HOST,
668         .u_data.host = {
669                 .vbus_gpio = -1,
670                 .hot_plug = false,
671                 .remote_wakeup_supported = false,
672                 .power_off_on_suspend = false,
673         },
674         .u_cfg.hsic = {
675                 .sync_start_delay = 9,
676                 .idle_wait_delay = 17,
677                 .term_range_adj = 0,
678                 .elastic_underrun_limit = 16,
679                 .elastic_overrun_limit = 16,
680         },
681         .ops = &hsic_xmm_plat_ops,
682 };
683
684
685
686 static struct tegra_usb_platform_data tegra_udc_pdata = {
687         .port_otg = true,
688         .has_hostpc = true,
689         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
690         .op_mode = TEGRA_USB_OPMODE_DEVICE,
691         .u_data.dev = {
692                 .vbus_pmu_irq = ENT_TPS80031_IRQ_BASE +
693                                 TPS80031_INT_VBUS_DET,
694                 .vbus_gpio = -1,
695                 .charging_supported = false,
696                 .remote_wakeup_supported = false,
697         },
698         .u_cfg.utmi = {
699                 .hssync_start_delay = 0,
700                 .elastic_limit = 16,
701                 .idle_wait_delay = 17,
702                 .term_range_adj = 6,
703                 .xcvr_setup = 8,
704                 .xcvr_lsfslew = 2,
705                 .xcvr_lsrslew = 2,
706                 .xcvr_setup_offset = 0,
707                 .xcvr_use_fuses = 1,
708         },
709 };
710
711 static struct tegra_usb_platform_data tegra_ehci1_utmi_pdata = {
712         .port_otg = true,
713         .has_hostpc = true,
714         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
715         .op_mode = TEGRA_USB_OPMODE_HOST,
716         .u_data.host = {
717                 .vbus_gpio = -1,
718                 .vbus_reg = "usb_vbus",
719                 .hot_plug = true,
720                 .remote_wakeup_supported = true,
721                 .power_off_on_suspend = true,
722         },
723         .u_cfg.utmi = {
724                 .hssync_start_delay = 0,
725                 .elastic_limit = 16,
726                 .idle_wait_delay = 17,
727                 .term_range_adj = 6,
728                 .xcvr_setup = 15,
729                 .xcvr_lsfslew = 2,
730                 .xcvr_lsrslew = 2,
731                 .xcvr_setup_offset = 0,
732                 .xcvr_use_fuses = 1,
733         },
734 };
735
736 static struct tegra_usb_otg_data tegra_otg_pdata = {
737         .ehci_device = &tegra_ehci1_device,
738         .ehci_pdata = &tegra_ehci1_utmi_pdata,
739 };
740
741 struct platform_device *tegra_usb_hsic_host_register(void)
742 {
743         struct platform_device *pdev;
744         int val;
745
746         pdev = platform_device_alloc(tegra_ehci2_device.name,
747                 tegra_ehci2_device.id);
748         if (!pdev)
749                 return NULL;
750
751         val = platform_device_add_resources(pdev, tegra_ehci2_device.resource,
752                 tegra_ehci2_device.num_resources);
753         if (val)
754                 goto error;
755
756         pdev->dev.dma_mask =  tegra_ehci2_device.dev.dma_mask;
757         pdev->dev.coherent_dma_mask = tegra_ehci2_device.dev.coherent_dma_mask;
758
759         val = platform_device_add_data(pdev, &tegra_ehci2_hsic_xmm_pdata,
760                         sizeof(struct tegra_usb_platform_data));
761         if (val)
762                 goto error;
763
764         val = platform_device_add(pdev);
765         if (val)
766                 goto error;
767
768         return pdev;
769
770 error:
771         pr_err("%s: failed to add the host contoller device\n", __func__);
772         platform_device_put(pdev);
773         return NULL;
774 }
775
776 void tegra_usb_hsic_host_unregister(struct platform_device *pdev)
777 {
778         platform_device_unregister(pdev);
779 }
780
781 static void enterprise_usb_init(void)
782 {
783         tegra_udc_device.dev.platform_data = &tegra_udc_pdata;
784
785         tegra_otg_device.dev.platform_data = &tegra_otg_pdata;
786         platform_device_register(&tegra_otg_device);
787 }
788
789 static struct platform_device *enterprise_audio_devices[] __initdata = {
790         &tegra_ahub_device,
791         &tegra_dam_device0,
792         &tegra_dam_device1,
793         &tegra_dam_device2,
794         &tegra_i2s_device0,
795         &tegra_i2s_device1,
796         &tegra_i2s_device2,
797         &tegra_i2s_device3,
798         &tegra_spdif_device,
799         &spdif_dit_device,
800         &bluetooth_dit_device,
801         &baseband_dit_device,
802         &tegra_pcm_device,
803         &enterprise_audio_device,
804         &enterprise_audio_aic326x_device,
805 };
806
807 static void enterprise_audio_init(void)
808 {
809         struct board_info board_info;
810
811         tegra_get_board_info(&board_info);
812
813         if (board_info.board_id == BOARD_E1197)
814                 enterprise_audio_pdata.audio_port_id[HIFI_CODEC] = 1;
815
816         platform_add_devices(enterprise_audio_devices,
817                         ARRAY_SIZE(enterprise_audio_devices));
818 }
819
820 static void enterprise_gps_init(void)
821 {
822         tegra_gpio_enable(TEGRA_GPIO_PE4);
823         tegra_gpio_enable(TEGRA_GPIO_PE5);
824 }
825
826 static struct baseband_power_platform_data tegra_baseband_power_data = {
827         .baseband_type = BASEBAND_XMM,
828         .modem = {
829                 .xmm = {
830                         .bb_rst = XMM_GPIO_BB_RST,
831                         .bb_on = XMM_GPIO_BB_ON,
832                         .ipc_bb_wake = XMM_GPIO_IPC_BB_WAKE,
833                         .ipc_ap_wake = XMM_GPIO_IPC_AP_WAKE,
834                         .ipc_hsic_active = XMM_GPIO_IPC_HSIC_ACTIVE,
835                         .ipc_hsic_sus_req = XMM_GPIO_IPC_HSIC_SUS_REQ,
836                 },
837         },
838 };
839
840 static struct platform_device tegra_baseband_power_device = {
841         .name = "baseband_xmm_power",
842         .id = -1,
843         .dev = {
844                 .platform_data = &tegra_baseband_power_data,
845         },
846 };
847
848 static struct platform_device tegra_baseband_power2_device = {
849         .name = "baseband_xmm_power2",
850         .id = -1,
851         .dev = {
852                 .platform_data = &tegra_baseband_power_data,
853         },
854 };
855
856 #ifdef CONFIG_TEGRA_BB_M7400
857 static union tegra_bb_gpio_id m7400_gpio_id = {
858         .m7400 = {
859                 .pwr_status = GPIO_BB_RESET,
860                 .pwr_on = GPIO_BB_PWRON,
861                 .uart_awr = GPIO_BB_APACK,
862                 .uart_cwr = GPIO_BB_CPACK,
863                 .usb_awr = GPIO_BB_APACK2,
864                 .usb_cwr = GPIO_BB_CPACK2,
865                 .service = GPIO_BB_RSVD2,
866                 .resout2 = GPIO_BB_RSVD1,
867         },
868 };
869
870 static struct tegra_bb_pdata m7400_pdata = {
871         .id = &m7400_gpio_id,
872         .device = &tegra_ehci2_device,
873         .ehci_register = tegra_usb_hsic_host_register,
874         .ehci_unregister = tegra_usb_hsic_host_unregister,
875         .bb_id = TEGRA_BB_M7400,
876 };
877
878 static struct platform_device tegra_baseband_m7400_device = {
879         .name = "tegra_baseband_power",
880         .id = -1,
881         .dev = {
882                 .platform_data = &m7400_pdata,
883         },
884 };
885 #endif
886
887 static void enterprise_baseband_init(void)
888 {
889         int modem_id = tegra_get_modem_id();
890
891         switch (modem_id) {
892         case TEGRA_BB_PH450: /* PH450 ULPI */
893                 enterprise_modem_init();
894                 break;
895         case TEGRA_BB_XMM6260: /* XMM6260 HSIC */
896                 /* baseband-power.ko will register ehci2 device */
897                 tegra_ehci2_device.dev.platform_data =
898                                         &tegra_ehci2_hsic_xmm_pdata;
899                 /* enable XMM6260 baseband gpio(s) */
900                 tegra_gpio_enable(tegra_baseband_power_data.modem.generic
901                         .mdm_reset);
902                 tegra_gpio_enable(tegra_baseband_power_data.modem.generic
903                         .mdm_on);
904                 tegra_gpio_enable(tegra_baseband_power_data.modem.generic
905                         .ap2mdm_ack);
906                 tegra_gpio_enable(tegra_baseband_power_data.modem.generic
907                         .mdm2ap_ack);
908                 tegra_gpio_enable(tegra_baseband_power_data.modem.generic
909                         .ap2mdm_ack2);
910                 tegra_gpio_enable(tegra_baseband_power_data.modem.generic
911                         .mdm2ap_ack2);
912                 tegra_baseband_power_data.hsic_register =
913                                                 &tegra_usb_hsic_host_register;
914                 tegra_baseband_power_data.hsic_unregister =
915                                                 &tegra_usb_hsic_host_unregister;
916                 platform_device_register(&tegra_baseband_power_device);
917                 platform_device_register(&tegra_baseband_power2_device);
918                 break;
919 #ifdef CONFIG_TEGRA_BB_M7400
920         case TEGRA_BB_M7400: /* M7400 HSIC */
921                 tegra_ehci2_hsic_xmm_pdata.u_data.host.power_off_on_suspend = 0;
922                 tegra_ehci2_device.dev.platform_data
923                         = &tegra_ehci2_hsic_xmm_pdata;
924                 platform_device_register(&tegra_baseband_m7400_device);
925                 break;
926 #endif
927         }
928 }
929
930 static void enterprise_nfc_init(void)
931 {
932         struct board_info bi;
933
934         tegra_gpio_enable(TEGRA_GPIO_PS4);
935         tegra_gpio_enable(TEGRA_GPIO_PM6);
936
937         /* Enable firmware GPIO PX7 for board E1205 */
938         tegra_get_board_info(&bi);
939         if (bi.board_id == BOARD_E1205 && bi.fab >= BOARD_FAB_A03) {
940                 nfc_pdata.firm_gpio = TEGRA_GPIO_PX7;
941                 tegra_gpio_enable(TEGRA_GPIO_PX7);
942         }
943 }
944
945 static void __init tegra_enterprise_init(void)
946 {
947         tegra_thermal_init(&thermal_data);
948         tegra_clk_init_from_table(enterprise_clk_init_table);
949         tegra_enable_pinmux();
950         enterprise_pinmux_init();
951         enterprise_i2c_init();
952         enterprise_uart_init();
953         enterprise_usb_init();
954         platform_add_devices(enterprise_devices, ARRAY_SIZE(enterprise_devices));
955         tegra_ram_console_debug_init();
956         enterprise_regulator_init();
957         enterprise_sdhci_init();
958 #ifdef CONFIG_TEGRA_EDP_LIMITS
959         enterprise_edp_init();
960 #endif
961         enterprise_kbc_init();
962         enterprise_touch_init();
963         enterprise_audio_init();
964         enterprise_gps_init();
965         enterprise_baseband_init();
966         enterprise_panel_init();
967         enterprise_setup_bluesleep();
968         enterprise_emc_init();
969         enterprise_sensors_init();
970         enterprise_suspend_init();
971         enterprise_bpc_mgmt_init();
972         tegra_release_bootloader_fb();
973         enterprise_nfc_init();
974 }
975
976 static void __init tegra_enterprise_reserve(void)
977 {
978 #if defined(CONFIG_NVMAP_CONVERT_CARVEOUT_TO_IOVMM)
979         tegra_reserve(0, SZ_4M, SZ_8M);
980 #else
981         tegra_reserve(SZ_128M, SZ_4M, SZ_8M);
982 #endif
983         tegra_ram_console_debug_reserve(SZ_1M);
984 }
985
986 MACHINE_START(TEGRA_ENTERPRISE, "tegra_enterprise")
987         .atag_offset    = 0x100,
988         .map_io         = tegra_map_common_io,
989         .reserve        = tegra_enterprise_reserve,
990         .init_early     = tegra30_init_early,
991         .init_irq       = tegra_init_irq,
992         .handle_irq     = gic_handle_irq,
993         .timer          = &tegra_timer,
994         .init_machine   = tegra_enterprise_init,
995         .restart        = tegra_assert_system_reset,
996 MACHINE_END