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