]> nv-tegra.nvidia Code Review - linux-3.10.git/blob - arch/arm/mach-tegra/board-loki.c
ARM: tegra12: set CPU rate to 2.2GHz for sku 0x87
[linux-3.10.git] / arch / arm / mach-tegra / board-loki.c
1 /*
2  * arch/arm/mach-tegra/board-loki.c
3  *
4  * Copyright (c) 2013-2014, 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 version 2 as
8  * published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18  */
19
20 #include <linux/kernel.h>
21 #include <linux/init.h>
22 #include <linux/slab.h>
23 #include <linux/ctype.h>
24 #include <linux/platform_device.h>
25 #include <linux/clk.h>
26 #include <linux/serial_8250.h>
27 #include <linux/i2c.h>
28 #include <linux/i2c/i2c-hid.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/platform_data/tegra_c2port_platform_data.h>
36 #include <linux/spi/spi.h>
37 #include <linux/spi/rm31080a_ts.h>
38 #include <linux/memblock.h>
39 #include <linux/spi/spi-tegra.h>
40 #include <linux/nfc/pn544.h>
41 #include <linux/rfkill-gpio.h>
42 #include <linux/skbuff.h>
43 #include <linux/ti_wilink_st.h>
44 #include <linux/regulator/consumer.h>
45 #include <linux/smb349-charger.h>
46 #include <linux/max17048_battery.h>
47 #include <linux/leds.h>
48 #include <linux/i2c/at24.h>
49 #include <linux/of_platform.h>
50 #include <linux/i2c.h>
51 #include <linux/i2c-tegra.h>
52 #include <linux/tegra-soc.h>
53 #include <linux/platform_data/serial-tegra.h>
54 #include <linux/edp.h>
55 #include <linux/mfd/palmas.h>
56 #include <linux/usb/tegra_usb_phy.h>
57 #include <linux/clk/tegra.h>
58 #include <linux/clocksource.h>
59 #include <linux/platform_data/tegra_usb_modem_power.h>
60 #include <linux/irqchip.h>
61 #include <linux/tegra_fiq_debugger.h>
62 #include <linux/irqchip/tegra.h>
63
64 #include <mach/irqs.h>
65 #include <mach/pinmux.h>
66 #include <mach/pinmux-t12.h>
67 #include <mach/io_dpd.h>
68 #include <mach/i2s.h>
69 #include <mach/isomgr.h>
70 #include <mach/tegra_asoc_pdata.h>
71 #include <asm/mach-types.h>
72 #include <asm/mach/arch.h>
73 #include <asm/system_info.h>
74 #include <mach/gpio-tegra.h>
75 #include <mach/xusb.h>
76
77 #include "board-touch-raydium.h"
78 #include "board.h"
79 #include "board-common.h"
80 #include "clock.h"
81 #include "board-loki.h"
82 #include "devices.h"
83 #include "gpio-names.h"
84 #include "pm.h"
85 #include "common.h"
86 #include "tegra-board-id.h"
87 #include "iomap.h"
88 #include "tegra-of-dev-auxdata.h"
89
90 static struct board_info board_info, display_board_info;
91
92 static struct resource loki_bluedroid_pm_resources[] = {
93         [0] = {
94                 .name   = "shutdown_gpio",
95                 .start  = TEGRA_GPIO_PR1,
96                 .end    = TEGRA_GPIO_PR1,
97                 .flags  = IORESOURCE_IO,
98         },
99         [1] = {
100                 .name = "host_wake",
101                 .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
102         },
103         [2] = {
104                 .name = "gpio_ext_wake",
105                 .start  = TEGRA_GPIO_PEE1,
106                 .end    = TEGRA_GPIO_PEE1,
107                 .flags  = IORESOURCE_IO,
108         },
109         [3] = {
110                 .name = "gpio_host_wake",
111                 .start  = TEGRA_GPIO_PU0,
112                 .end    = TEGRA_GPIO_PU0,
113                 .flags  = IORESOURCE_IO,
114         },
115         [4] = {
116                 .name = "reset_gpio",
117                 .start  = TEGRA_GPIO_PQ6,
118                 .end    = TEGRA_GPIO_PQ6,
119                 .flags  = IORESOURCE_IO,
120         },
121 };
122
123 static struct platform_device loki_bluedroid_pm_device = {
124         .name = "bluedroid_pm",
125         .id             = 0,
126         .num_resources  = ARRAY_SIZE(loki_bluedroid_pm_resources),
127         .resource       = loki_bluedroid_pm_resources,
128 };
129
130 static noinline void __init loki_setup_bluedroid_pm(void)
131 {
132         loki_bluedroid_pm_resources[1].start =
133                 loki_bluedroid_pm_resources[1].end =
134                                 gpio_to_irq(TEGRA_GPIO_PU0);
135         platform_device_register(&loki_bluedroid_pm_device);
136 }
137
138 static struct i2c_board_info __initdata rt5639_board_info = {
139         I2C_BOARD_INFO("rt5639", 0x1c),
140 };
141
142 static __initdata struct tegra_clk_init_table loki_clk_init_table[] = {
143         /* name         parent          rate            enabled */
144         { "pll_m",      NULL,           0,              false},
145         { "hda",        "pll_p",        108000000,      false},
146         { "hda2codec_2x", "pll_p",      48000000,       false},
147         { "pwm",        "pll_p",        6375000,        false},
148         { "i2s1",       "pll_a_out0",   0,              false},
149         { "i2s3",       "pll_a_out0",   0,              false},
150         { "i2s4",       "pll_a_out0",   0,              false},
151         { "spdif_out",  "pll_a_out0",   0,              false},
152         { "d_audio",    "clk_m",        12000000,       false},
153         { "dam0",       "clk_m",        12000000,       false},
154         { "dam1",       "clk_m",        12000000,       false},
155         { "dam2",       "clk_m",        12000000,       false},
156         { "audio1",     "i2s1_sync",    0,              false},
157         { "audio3",     "i2s3_sync",    0,              false},
158         { "vi_sensor",  "pll_p",        150000000,      false},
159         { "vi_sensor2", "pll_p",        150000000,      false},
160         { "cilab",      "pll_p",        150000000,      false},
161         { "cilcd",      "pll_p",        150000000,      false},
162         { "cile",       "pll_p",        150000000,      false},
163         { "i2c1",       "pll_p",        3200000,        false},
164         { "i2c2",       "pll_p",        3200000,        false},
165         { "i2c3",       "pll_p",        3200000,        false},
166         { "i2c4",       "pll_p",        3200000,        false},
167         { "i2c5",       "pll_p",        3200000,        false},
168         { "sbc1",       "pll_p",        25000000,       false},
169         { "sbc2",       "pll_p",        25000000,       false},
170         { "sbc3",       "pll_p",        25000000,       false},
171         { "sbc4",       "pll_p",        25000000,       false},
172         { "sbc5",       "pll_p",        25000000,       false},
173         { "sbc6",       "pll_p",        25000000,       false},
174         { "uarta",      "pll_p",        408000000,      false},
175         { "uartb",      "pll_p",        408000000,      false},
176         { "uartc",      "pll_p",        408000000,      false},
177         { "uartd",      "pll_p",        408000000,      false},
178         { NULL,         NULL,           0,              0},
179 };
180
181 static void loki_i2c_init(void)
182 {
183         i2c_register_board_info(0, &rt5639_board_info, 1);
184 }
185
186 #ifndef CONFIG_USE_OF
187 static struct platform_device *loki_uart_devices[] __initdata = {
188         &tegra_uarta_device,
189         &tegra_uartb_device,
190         &tegra_uartc_device,
191 };
192
193 static struct tegra_serial_platform_data loki_uarta_pdata = {
194         .dma_req_selector = 8,
195         .modem_interrupt = false,
196 };
197
198 static struct tegra_serial_platform_data loki_uartb_pdata = {
199         .dma_req_selector = 9,
200         .modem_interrupt = false,
201 };
202
203 static struct tegra_serial_platform_data loki_uartc_pdata = {
204         .dma_req_selector = 10,
205         .modem_interrupt = false,
206 };
207 #endif
208
209 static struct tegra_serial_platform_data loki_uartd_pdata = {
210         .dma_req_selector = 19,
211         .modem_interrupt = false,
212 };
213
214 static struct tegra_asoc_platform_data loki_audio_pdata_rt5639 = {
215         .gpio_hp_det = TEGRA_GPIO_HP_DET,
216         .gpio_ldo1_en = TEGRA_GPIO_LDO_EN,
217         .gpio_spkr_en = -1,
218         .gpio_int_mic_en = -1,
219         .gpio_ext_mic_en = -1,
220         .gpio_hp_mute = -1,
221         .gpio_codec1 = -1,
222         .gpio_codec2 = -1,
223         .gpio_codec3 = -1,
224         .i2s_param[HIFI_CODEC]       = {
225                 .audio_port_id = 1,
226                 .is_i2s_master = 0,
227                 .i2s_mode = TEGRA_DAIFMT_I2S,
228         },
229         .i2s_param[BT_SCO] = {
230                 .audio_port_id = 3,
231                 .is_i2s_master = 1,
232                 .i2s_mode = TEGRA_DAIFMT_DSP_A,
233         },
234 };
235
236 static void loki_audio_init(void)
237 {
238         loki_audio_pdata_rt5639.gpio_hp_det =
239                         TEGRA_GPIO_HP_DET;
240
241         loki_audio_pdata_rt5639.gpio_hp_det_active_high = 0;
242
243         loki_audio_pdata_rt5639.gpio_ldo1_en =
244                         TEGRA_GPIO_LDO_EN;
245
246         loki_audio_pdata_rt5639.codec_name = "rt5639.0-001c";
247         loki_audio_pdata_rt5639.codec_dai_name = "rt5639-aif1";
248 }
249
250 static struct platform_device loki_audio_device_rt5639 = {
251         .name = "tegra-snd-rt5639",
252         .id = 0,
253         .dev = {
254                 .platform_data = &loki_audio_pdata_rt5639,
255         },
256 };
257
258 static void __init loki_uart_init(void)
259 {
260         int debug_port_id;
261
262 #ifndef CONFIG_USE_OF
263         tegra_uarta_device.dev.platform_data = &loki_uarta_pdata;
264         tegra_uartb_device.dev.platform_data = &loki_uartb_pdata;
265         tegra_uartc_device.dev.platform_data = &loki_uartc_pdata;
266         platform_add_devices(loki_uart_devices,
267                         ARRAY_SIZE(loki_uart_devices));
268 #endif
269         tegra_uartd_device.dev.platform_data = &loki_uartd_pdata;
270         if (!is_tegra_debug_uartport_hs()) {
271                 debug_port_id = uart_console_debug_init(3);
272                 if (debug_port_id < 0)
273                         return;
274
275                 platform_device_register(uart_console_debug_device);
276         } else {
277                 tegra_uartd_device.dev.platform_data = &loki_uartd_pdata;
278                 platform_device_register(&tegra_uartd_device);
279         }
280
281 }
282
283 static struct resource tegra_rtc_resources[] = {
284         [0] = {
285                 .start = TEGRA_RTC_BASE,
286                 .end = TEGRA_RTC_BASE + TEGRA_RTC_SIZE - 1,
287                 .flags = IORESOURCE_MEM,
288         },
289         [1] = {
290                 .start = INT_RTC,
291                 .end = INT_RTC,
292                 .flags = IORESOURCE_IRQ,
293         },
294 };
295
296 static struct platform_device tegra_rtc_device = {
297         .name = "tegra_rtc",
298         .id   = -1,
299         .resource = tegra_rtc_resources,
300         .num_resources = ARRAY_SIZE(tegra_rtc_resources),
301 };
302
303 static struct platform_device *loki_devices[] __initdata = {
304         &tegra_pmu_device,
305         &tegra_rtc_device,
306         &tegra_udc_device,
307 #if defined(CONFIG_TEGRA_WATCHDOG)
308         &tegra_wdt0_device,
309 #endif
310 #if defined(CONFIG_TEGRA_AVP)
311         &tegra_avp_device,
312 #endif
313 #if defined(CONFIG_CRYPTO_DEV_TEGRA_SE) && !defined(CONFIG_USE_OF)
314         &tegra12_se_device,
315 #endif
316         &tegra_ahub_device,
317         &tegra_dam_device0,
318         &tegra_dam_device1,
319         &tegra_dam_device2,
320         &tegra_i2s_device1,
321         &tegra_i2s_device3,
322         &tegra_i2s_device4,
323         &loki_audio_device_rt5639,
324         &tegra_spdif_device,
325         &spdif_dit_device,
326         &bluetooth_dit_device,
327         &baseband_dit_device,
328         &tegra_hda_device,
329 #if defined(CONFIG_TEGRA_CEC_SUPPORT)
330         &tegra_cec_device,
331 #endif
332 #if defined(CONFIG_CRYPTO_DEV_TEGRA_AES)
333         &tegra_aes_device,
334 #endif
335 };
336
337 static struct tegra_usb_platform_data tegra_udc_pdata = {
338         .port_otg = true,
339         .has_hostpc = true,
340         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
341         .op_mode = TEGRA_USB_OPMODE_DEVICE,
342         .u_data.dev = {
343                 .vbus_pmu_irq = 0,
344                 .vbus_gpio = -1,
345                 .dcp_current_limit_ma = 2000,
346                 .charging_supported = false,
347                 .remote_wakeup_supported = false,
348         },
349         .u_cfg.utmi = {
350                 .hssync_start_delay = 0,
351                 .elastic_limit = 16,
352                 .idle_wait_delay = 17,
353                 .term_range_adj = 6,
354                 .xcvr_setup = 8,
355                 .xcvr_lsfslew = 2,
356                 .xcvr_lsrslew = 2,
357                 .xcvr_setup_offset = 0,
358                 .xcvr_use_fuses = 1,
359         },
360 };
361
362 static struct tegra_usb_platform_data tegra_ehci1_utmi_pdata = {
363         .port_otg = true,
364         .has_hostpc = true,
365         .unaligned_dma_buf_supported = true,
366         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
367         .op_mode = TEGRA_USB_OPMODE_HOST,
368         .u_data.host = {
369                 .vbus_gpio = -1,
370                 .hot_plug = false,
371                 .remote_wakeup_supported = true,
372                 .power_off_on_suspend = true,
373                 .turn_off_vbus_on_lp0 = true,
374         },
375         .u_cfg.utmi = {
376                 .hssync_start_delay = 0,
377                 .elastic_limit = 16,
378                 .idle_wait_delay = 17,
379                 .term_range_adj = 6,
380                 .xcvr_setup = 15,
381                 .xcvr_lsfslew = 0,
382                 .xcvr_lsrslew = 3,
383                 .xcvr_setup_offset = 0,
384                 .xcvr_use_fuses = 0,
385                 .vbus_oc_map = 0x4,
386                 .xcvr_hsslew_lsb = 2,
387         },
388 };
389
390 static struct tegra_usb_platform_data tegra_ehci2_utmi_pdata = {
391         .port_otg = false,
392         .has_hostpc = true,
393         .unaligned_dma_buf_supported = true,
394         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
395         .op_mode = TEGRA_USB_OPMODE_HOST,
396         .u_data.host = {
397                 .vbus_gpio = -1,
398                 .hot_plug = false,
399                 .remote_wakeup_supported = true,
400                 .power_off_on_suspend = true,
401         },
402         .u_cfg.utmi = {
403                 .hssync_start_delay = 0,
404                 .elastic_limit = 16,
405                 .idle_wait_delay = 17,
406                 .term_range_adj = 6,
407                 .xcvr_setup = 8,
408                 .xcvr_lsfslew = 2,
409                 .xcvr_lsrslew = 2,
410                 .xcvr_setup_offset = 0,
411                 .xcvr_use_fuses = 1,
412                 .vbus_oc_map = 0x5,
413         },
414 };
415
416 static struct tegra_usb_platform_data tegra_ehci3_utmi_pdata = {
417         .port_otg = false,
418         .has_hostpc = true,
419         .unaligned_dma_buf_supported = true,
420         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
421         .op_mode = TEGRA_USB_OPMODE_HOST,
422         .u_data.host = {
423                 .vbus_gpio = -1,
424                 .hot_plug = false,
425                 .remote_wakeup_supported = true,
426                 .power_off_on_suspend = true,
427         },
428         .u_cfg.utmi = {
429         .hssync_start_delay = 0,
430                 .elastic_limit = 16,
431                 .idle_wait_delay = 17,
432                 .term_range_adj = 6,
433                 .xcvr_setup = 8,
434                 .xcvr_lsfslew = 2,
435                 .xcvr_lsrslew = 2,
436                 .xcvr_setup_offset = 0,
437                 .xcvr_use_fuses = 1,
438                 .vbus_oc_map = 0x5,
439         },
440 };
441
442 static struct gpio modem_gpios[] = { /* Bruce modem */
443         {MDM_RST, GPIOF_OUT_INIT_LOW, "MODEM RESET"},
444 };
445
446 static struct tegra_usb_platform_data tegra_ehci2_hsic_baseband_pdata = {
447         .port_otg = false,
448         .has_hostpc = true,
449         .unaligned_dma_buf_supported = true,
450         .phy_intf = TEGRA_USB_PHY_INTF_HSIC,
451         .op_mode = TEGRA_USB_OPMODE_HOST,
452         .u_data.host = {
453                 .vbus_gpio = -1,
454                 .hot_plug = false,
455                 .remote_wakeup_supported = true,
456                 .power_off_on_suspend = true,
457         },
458 };
459
460 static struct tegra_usb_platform_data tegra_ehci2_hsic_smsc_hub_pdata = {
461         .port_otg = false,
462         .has_hostpc = true,
463         .unaligned_dma_buf_supported = true,
464         .phy_intf = TEGRA_USB_PHY_INTF_HSIC,
465         .op_mode        = TEGRA_USB_OPMODE_HOST,
466         .u_data.host = {
467                 .vbus_gpio = -1,
468                 .hot_plug = false,
469                 .remote_wakeup_supported = true,
470                 .power_off_on_suspend = true,
471         },
472 };
473
474
475 static struct tegra_usb_otg_data tegra_otg_pdata = {
476         .ehci_device = &tegra_ehci1_device,
477         .ehci_pdata = &tegra_ehci1_utmi_pdata,
478 };
479
480 static void loki_usb_init(void)
481 {
482         int usb_port_owner_info = tegra_get_usb_port_owner_info();
483         int modem_id = tegra_get_modem_id();
484
485         /* Device cable is detected through PMU Interrupt */
486         tegra_udc_pdata.support_pmu_vbus = true;
487         tegra_udc_pdata.vbus_extcon_dev_name = "palmas-extcon";
488         tegra_ehci1_utmi_pdata.support_pmu_vbus = true;
489         tegra_ehci1_utmi_pdata.vbus_extcon_dev_name = "palmas-extcon";
490
491         if (!(usb_port_owner_info & UTMI1_PORT_OWNER_XUSB)) {
492                 tegra_otg_device.dev.platform_data = &tegra_otg_pdata;
493                 platform_device_register(&tegra_otg_device);
494                 /* Setup the udc platform data */
495                 tegra_udc_device.dev.platform_data = &tegra_udc_pdata;
496         }
497         if (!(usb_port_owner_info & UTMI2_PORT_OWNER_XUSB)) {
498                 if (!modem_id) {
499                         tegra_ehci2_device.dev.platform_data =
500                                 &tegra_ehci2_utmi_pdata;
501                         platform_device_register(&tegra_ehci2_device);
502                 }
503         }
504         if (!(usb_port_owner_info & UTMI3_PORT_OWNER_XUSB)) {
505                 tegra_ehci3_device.dev.platform_data = &tegra_ehci3_utmi_pdata;
506                 platform_device_register(&tegra_ehci3_device);
507         }
508 }
509
510 static struct tegra_xusb_platform_data xusb_pdata = {
511         .portmap = TEGRA_XUSB_SS_P0 | TEGRA_XUSB_USB2_P0 | TEGRA_XUSB_SS_P1 |
512                         TEGRA_XUSB_USB2_P1 | TEGRA_XUSB_USB2_P2,
513 };
514
515 static void loki_xusb_init(void)
516 {
517         int usb_port_owner_info = tegra_get_usb_port_owner_info();
518
519         xusb_pdata.lane_owner = (u8) tegra_get_lane_owner_info();
520
521         if (board_info.board_id == BOARD_PM359 ||
522                         board_info.board_id == BOARD_PM358 ||
523                         board_info.board_id == BOARD_PM363) {
524                 /* Laguna */
525                 if (!(usb_port_owner_info & UTMI1_PORT_OWNER_XUSB))
526                         xusb_pdata.portmap &= ~(TEGRA_XUSB_USB2_P0 |
527                                 TEGRA_XUSB_SS_P0);
528
529                 if (!(usb_port_owner_info & UTMI2_PORT_OWNER_XUSB))
530                         xusb_pdata.portmap &= ~(TEGRA_XUSB_USB2_P1 |
531                                 TEGRA_XUSB_SS_P1);
532
533                 /* FIXME Add for UTMIP2 when have odmdata assigend */
534         } else {
535                 /* Loki */
536                 if (board_info.board_id == BOARD_E1781) {
537                         pr_info("Shield ERS-S. 0x%x\n", board_info.board_id);
538                         /* Shield ERS-S */
539                         if (!(usb_port_owner_info & UTMI1_PORT_OWNER_XUSB))
540                                 xusb_pdata.portmap &= ~(TEGRA_XUSB_USB2_P0);
541
542                         if (!(usb_port_owner_info & UTMI2_PORT_OWNER_XUSB))
543                                 xusb_pdata.portmap &= ~(
544                                         TEGRA_XUSB_USB2_P1 | TEGRA_XUSB_SS_P0 |
545                                         TEGRA_XUSB_USB2_P2 | TEGRA_XUSB_SS_P1);
546                 } else {
547                         pr_info("Shield ERS 0x%x\n", board_info.board_id);
548                         /* Shield ERS */
549
550                         if (!(usb_port_owner_info & UTMI1_PORT_OWNER_XUSB))
551                                 xusb_pdata.portmap &= ~(TEGRA_XUSB_USB2_P0 |
552                                         TEGRA_XUSB_SS_P0);
553
554                         if (!(usb_port_owner_info & UTMI2_PORT_OWNER_XUSB))
555                                 xusb_pdata.portmap &= ~(TEGRA_XUSB_USB2_P1 |
556                                         TEGRA_XUSB_USB2_P2 | TEGRA_XUSB_SS_P1);
557                 }
558                 /* FIXME Add for UTMIP2 when have odmdata assigend */
559         }
560 }
561
562 static int baseband_init(void)
563 {
564         int ret;
565
566         ret = gpio_request_array(modem_gpios, ARRAY_SIZE(modem_gpios));
567         if (ret) {
568                 pr_warn("%s:gpio request failed\n", __func__);
569                 return ret;
570         }
571
572         /* enable pull-down for MDM_COLD_BOOT */
573         tegra_pinmux_set_pullupdown(TEGRA_PINGROUP_ULPI_DATA4,
574                                     TEGRA_PUPD_PULL_DOWN);
575
576         /* export GPIO for user space access through sysfs */
577         gpio_export(MDM_RST, false);
578
579         return 0;
580 }
581
582 static const struct tegra_modem_operations baseband_operations = {
583         .init = baseband_init,
584 };
585
586 static struct tegra_usb_modem_power_platform_data baseband_pdata = {
587         .ops = &baseband_operations,
588         .regulator_name = "vdd_wwan_mdm",
589         .wake_gpio = -1,
590         .boot_gpio = MDM_COLDBOOT,
591         .boot_irq_flags = IRQF_TRIGGER_RISING |
592                                     IRQF_TRIGGER_FALLING |
593                                     IRQF_ONESHOT,
594         .autosuspend_delay = 2000,
595         .short_autosuspend_delay = 50,
596         .tegra_ehci_device = &tegra_ehci2_device,
597         .tegra_ehci_pdata = &tegra_ehci2_hsic_baseband_pdata,
598 };
599
600 static struct platform_device icera_bruce_device = {
601         .name = "tegra_usb_modem_power",
602         .id = -1,
603         .dev = {
604                 .platform_data = &baseband_pdata,
605         },
606 };
607
608 static void loki_modem_init(void)
609 {
610         int modem_id = tegra_get_modem_id();
611         struct board_info board_info;
612         int usb_port_owner_info = tegra_get_usb_port_owner_info();
613
614         tegra_get_board_info(&board_info);
615         pr_info("%s: modem_id = %d\n", __func__, modem_id);
616
617         switch (modem_id) {
618         case TEGRA_BB_BRUCE:
619                 if (!(usb_port_owner_info & HSIC1_PORT_OWNER_XUSB))
620                         platform_device_register(&icera_bruce_device);
621                 break;
622         case TEGRA_BB_HSIC_HUB: /* HSIC hub */
623                 if (!(usb_port_owner_info & HSIC1_PORT_OWNER_XUSB)) {
624                         tegra_ehci2_device.dev.platform_data =
625                                 &tegra_ehci2_hsic_smsc_hub_pdata;
626                         platform_device_register(&tegra_ehci2_device);
627                 }
628                 break;
629         default:
630                 return;
631         }
632 }
633
634 #ifdef CONFIG_USE_OF
635 struct of_dev_auxdata loki_auxdata_lookup[] __initdata = {
636         T124_SPI_OF_DEV_AUXDATA,
637         OF_DEV_AUXDATA("nvidia,tegra124-apbdma", 0x60020000, "tegra-apbdma",
638                                 NULL),
639         OF_DEV_AUXDATA("nvidia,tegra124-se", 0x70012000, "tegra12-se", NULL),
640         OF_DEV_AUXDATA("nvidia,tegra124-host1x", TEGRA_HOST1X_BASE, "host1x",
641                 NULL),
642         OF_DEV_AUXDATA("nvidia,tegra124-gk20a", TEGRA_GK20A_BAR0_BASE,
643                 "gk20a.0", NULL),
644 #ifdef CONFIG_ARCH_TEGRA_VIC
645         OF_DEV_AUXDATA("nvidia,tegra124-vic", TEGRA_VIC_BASE, "vic03.0", NULL),
646 #endif
647         OF_DEV_AUXDATA("nvidia,tegra124-msenc", TEGRA_MSENC_BASE, "msenc",
648                 NULL),
649         OF_DEV_AUXDATA("nvidia,tegra124-vi", TEGRA_VI_BASE, "vi.0", NULL),
650         OF_DEV_AUXDATA("nvidia,tegra124-isp", TEGRA_ISP_BASE, "isp.0", NULL),
651         OF_DEV_AUXDATA("nvidia,tegra124-isp", TEGRA_ISPB_BASE, "isp.1", NULL),
652         OF_DEV_AUXDATA("nvidia,tegra124-tsec", TEGRA_TSEC_BASE, "tsec", NULL),
653         OF_DEV_AUXDATA("nvidia,tegra114-hsuart", 0x70006000, "serial-tegra.0",
654                                 NULL),
655         OF_DEV_AUXDATA("nvidia,tegra114-hsuart", 0x70006040, "serial-tegra.1",
656                                 NULL),
657         OF_DEV_AUXDATA("nvidia,tegra114-hsuart", 0x70006200, "serial-tegra.2",
658                                 NULL),
659         T124_I2C_OF_DEV_AUXDATA,
660         OF_DEV_AUXDATA("nvidia,tegra124-xhci", 0x70090000, "tegra-xhci",
661                                 &xusb_pdata),
662         {}
663 };
664 #endif
665
666 static __initdata struct tegra_clk_init_table touch_clk_init_table[] = {
667         /* name         parent          rate            enabled */
668         { "extern2",    "pll_p",        41000000,       false},
669         { "clk_out_2",  "extern2",      40800000,       false},
670         { NULL,         NULL,           0,              0},
671 };
672
673 struct rm_spi_ts_platform_data rm31080ts_loki_data = {
674         .gpio_reset = TOUCH_GPIO_RST_RAYDIUM_SPI,
675         .config = 0,
676         .platform_id = RM_PLATFORM_L005,
677         .name_of_clock = "clk_out_2",
678         .name_of_clock_con = "extern2",
679 };
680
681 struct rm_spi_ts_platform_data rm31080ts_loki_data_t_1_95 = {
682         .gpio_reset = TOUCH_GPIO_RST_RAYDIUM_SPI,
683         .config = 0,
684         .platform_id = RM_PLATFORM_L005,
685         .name_of_clock = "clk_out_2",
686         .name_of_clock_con = "extern2",
687         .gpio_sensor_select0 = true,
688         .gpio_sensor_select1 = false,
689 };
690
691 static struct tegra_spi_device_controller_data dev_cdata = {
692         .rx_clk_tap_delay = 0,
693         .tx_clk_tap_delay = 16,
694 };
695
696 struct spi_board_info rm31080a_loki_spi_board[1] = {
697         {
698                 .modalias = "rm_ts_spidev",
699                 .bus_num = TOUCH_SPI_ID,
700                 .chip_select = TOUCH_SPI_CS,
701                 .max_speed_hz = 12 * 1000 * 1000,
702                 .mode = SPI_MODE_0,
703                 .controller_data = &dev_cdata,
704                 .platform_data = &rm31080ts_loki_data,
705         },
706 };
707
708 static int __init loki_touch_init(void)
709 {
710         struct board_info bi;
711         tegra_get_board_info(&bi);
712         if (bi.board_id == BOARD_P2530 && bi.sku == BOARD_SKU_FOSTER)
713                 return 0;
714
715         if (tegra_get_touch_panel_id() == TOUCH_PANEL_THOR_WINTEK)
716                 rm31080a_loki_spi_board[0].platform_data =
717                                         &rm31080ts_loki_data_t_1_95;
718
719         /*
720         ** remove touch clock initialization for ffd fab a3, higher
721         ** Move clock from tegra clock to external xtal
722         */
723         if (bi.board_id == BOARD_P2530 && bi.fab >= 0xa3) {
724                 rm31080ts_loki_data.name_of_clock = NULL;
725                 rm31080ts_loki_data.name_of_clock_con = NULL;
726         } else
727                 tegra_clk_init_from_table(touch_clk_init_table);
728         rm31080a_loki_spi_board[0].irq =
729                 gpio_to_irq(TOUCH_GPIO_IRQ_RAYDIUM_SPI);
730         touch_init_raydium(TOUCH_GPIO_IRQ_RAYDIUM_SPI,
731                                 TOUCH_GPIO_RST_RAYDIUM_SPI,
732                                 &rm31080ts_loki_data,
733                                 &rm31080a_loki_spi_board[0],
734                                 ARRAY_SIZE(rm31080a_loki_spi_board));
735         return 0;
736 }
737
738 static void __init loki_revision_init(struct board_info *binf)
739 {
740
741         struct board_info disp_board_info;
742
743         system_rev = P2530_LOKI;
744         tegra_get_display_board_info(&disp_board_info);
745         if (!binf)
746                 return;
747         if (binf->board_id == BOARD_E2548) {
748                 system_rev = E2548;
749         } else if (binf->board_id == BOARD_E2549) {
750                 system_rev = E2549;
751         } else if (binf->board_id == BOARD_P2530) {
752                 if (binf->sku == BOARD_SKU_FOSTER)
753                         system_rev = P2530_FOSTER;
754                 else if (disp_board_info.fab == 0x1)
755                         system_rev = P2530_LOKI_PREM;
756         }
757 }
758
759 static void __init tegra_loki_early_init(void)
760 {
761         tegra_clk_init_from_table(loki_clk_init_table);
762         tegra_clk_verify_parents();
763         tegra_soc_device_init("loki");
764 }
765
766 #ifdef CONFIG_C2PORT_LOKI
767 /* Init mcu debugger for Loki */
768 static struct tegra_c2port_platform_data mcu_init_data = {
769         .gpio_c2ck = TEGRA_GPIO_PK0,
770         .gpio_c2d = TEGRA_GPIO_PS0
771 };
772 static struct platform_device tegra_loki_mcu_debugger = {
773                 .name = "tegra_c2port",
774                 .id = 0,
775                 .dev = {
776                         .platform_data = &mcu_init_data,
777                 }
778 };
779 static void __init tegra_loki_mcu_debugger_init(void)
780 {
781         platform_device_register(&tegra_loki_mcu_debugger);
782 }
783 #endif
784
785 static void __init tegra_loki_late_init(void)
786 {
787         struct board_info board_info;
788         tegra_get_board_info(&board_info);
789         pr_info("board_info: id:sku:fab:major:minor = 0x%04x:0x%04x:0x%02x:0x%02x:0x%02x\n",
790                 board_info.board_id, board_info.sku,
791                 board_info.fab, board_info.major_revision,
792                 board_info.minor_revision);
793         loki_revision_init(&board_info);
794         loki_pinmux_init();
795         loki_usb_init();
796         loki_modem_init();
797         loki_xusb_init();
798         loki_i2c_init();
799         loki_uart_init();
800         loki_audio_init();
801         platform_add_devices(loki_devices, ARRAY_SIZE(loki_devices));
802         tegra_io_dpd_init();
803         loki_sdhci_init();
804         loki_regulator_init();
805         loki_suspend_init();
806         loki_emc_init();
807         loki_edp_init();
808         isomgr_init();
809         loki_touch_init();
810         loki_panel_init();
811         loki_kbc_init();
812         loki_pmon_init();
813 #ifdef CONFIG_TEGRA_WDT_RECOVERY
814         tegra_wdt_recovery_init();
815 #endif
816         tegra_serial_debug_init(TEGRA_UARTD_BASE, INT_WDT_CPU, NULL, -1, -1);
817
818         loki_sensors_init();
819         loki_fan_init();
820         loki_soctherm_init();
821         loki_setup_bluedroid_pm();
822         tegra_register_fuse();
823         tegra_serial_debug_init(TEGRA_UARTD_BASE, INT_WDT_CPU, NULL, -1, -1);
824 #ifdef CONFIG_C2PORT_LOKI
825         tegra_loki_mcu_debugger_init();
826 #endif
827 }
828
829 static void __init tegra_loki_dt_init(void)
830 {
831         tegra_get_board_info(&board_info);
832         tegra_get_display_board_info(&display_board_info);
833
834         tegra_loki_early_init();
835 #ifdef CONFIG_USE_OF
836         of_platform_populate(NULL,
837                 of_default_bus_match_table, loki_auxdata_lookup,
838                 &platform_bus);
839 #endif
840
841         tegra_loki_late_init();
842 }
843
844 static void __init tegra_loki_reserve(void)
845 {
846 #if defined(CONFIG_NVMAP_CONVERT_CARVEOUT_TO_IOVMM) || \
847                 defined(CONFIG_TEGRA_NO_CARVEOUT)
848         /* 1920*1200*4*2 = 18432000 bytes */
849         tegra_reserve(0, SZ_16M + SZ_2M, SZ_16M);
850 #else
851         tegra_reserve(SZ_1G, SZ_16M + SZ_2M, SZ_4M);
852 #endif
853 }
854
855 static const char * const loki_dt_board_compat[] = {
856         "nvidia,loki",
857         NULL
858 };
859
860 static void __init tegra_loki_init_early(void)
861 {
862         loki_rail_alignment_init();
863         tegra12x_init_early();
864 }
865
866 DT_MACHINE_START(LOKI, "loki")
867         .atag_offset    = 0x100,
868         .smp            = smp_ops(tegra_smp_ops),
869         .map_io         = tegra_map_common_io,
870         .reserve        = tegra_loki_reserve,
871         .init_early     = tegra_loki_init_early,
872         .init_irq       = irqchip_init,
873         .init_time      = clocksource_of_init,
874         .init_machine   = tegra_loki_dt_init,
875         .restart        = tegra_assert_system_reset,
876         .dt_compat      = loki_dt_board_compat,
877         .init_late      = tegra_init_late
878 MACHINE_END