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