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