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