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