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