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