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