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