xhci: tegra: only enable vbus owned by xusb
[linux-3.10.git] / arch / arm / mach-tegra / board-dalmore.c
1 /*
2  * arch/arm/mach-tegra/board-dalmore.c
3  *
4  * Copyright (c) 2012-2013, 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/dma-mapping.h>
29 #include <linux/delay.h>
30 #include <linux/i2c-tegra.h>
31 #include <linux/gpio.h>
32 #include <linux/input.h>
33 #include <linux/platform_data/tegra_usb.h>
34 #include <linux/spi/spi.h>
35 #include <linux/spi/rm31080a_ts.h>
36 #include <linux/platform_data/serial-tegra.h>
37 #include <linux/memblock.h>
38 #include <linux/spi/spi-tegra.h>
39 #include <linux/nfc/pn544.h>
40 #include <linux/rfkill-gpio.h>
41 #include <linux/skbuff.h>
42 #include <linux/ti_wilink_st.h>
43 #include <linux/regulator/consumer.h>
44 #include <linux/smb349-charger.h>
45 #include <linux/max17048_battery.h>
46 #include <linux/leds.h>
47 #include <linux/i2c/at24.h>
48 #include <linux/of_platform.h>
49 #include <linux/edp.h>
50 #include <linux/usb/tegra_usb_phy.h>
51 #include <linux/clk/tegra.h>
52
53 #include <mach/irqs.h>
54 #include <mach/pinmux.h>
55 #include <mach/pinmux-t11.h>
56 #include <mach/io_dpd.h>
57 #include <mach/i2s.h>
58 #include <mach/isomgr.h>
59 #include <mach/tegra_asoc_pdata.h>
60 #include <asm/mach-types.h>
61 #include <asm/mach/arch.h>
62 #include <mach/gpio-tegra.h>
63 #include <mach/tegra_fiq_debugger.h>
64 #include <linux/platform_data/tegra_usb_modem_power.h>
65 #include <mach/xusb.h>
66
67 #include "board-touch-raydium.h"
68 #include "board.h"
69 #include "board-common.h"
70 #include "clock.h"
71 #include "board-dalmore.h"
72 #include "devices.h"
73 #include "gpio-names.h"
74 #include "fuse.h"
75 #include "iomap.h"
76 #include "pm.h"
77 #include "pm-irq.h"
78 #include "common.h"
79 #include "tegra-board-id.h"
80
81 static struct board_info board_info, display_board_info;
82
83 #if defined(CONFIG_BT_BLUESLEEP) || defined(CONFIG_BT_BLUESLEEP_MODULE)
84 static struct rfkill_gpio_platform_data dalmore_bt_rfkill_pdata = {
85                 .name           = "bt_rfkill",
86                 .shutdown_gpio  = TEGRA_GPIO_PQ7,
87                 .reset_gpio     = TEGRA_GPIO_PQ6,
88                 .type           = RFKILL_TYPE_BLUETOOTH,
89 };
90
91 static struct platform_device dalmore_bt_rfkill_device = {
92         .name = "rfkill_gpio",
93         .id             = -1,
94         .dev = {
95                 .platform_data = &dalmore_bt_rfkill_pdata,
96         },
97 };
98
99 static struct resource dalmore_bluesleep_resources[] = {
100         [0] = {
101                 .name = "gpio_host_wake",
102                         .start  = TEGRA_GPIO_PU6,
103                         .end    = TEGRA_GPIO_PU6,
104                         .flags  = IORESOURCE_IO,
105         },
106         [1] = {
107                 .name = "gpio_ext_wake",
108                         .start  = TEGRA_GPIO_PEE1,
109                         .end    = TEGRA_GPIO_PEE1,
110                         .flags  = IORESOURCE_IO,
111         },
112         [2] = {
113                 .name = "host_wake",
114                         .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
115         },
116 };
117
118 static struct platform_device dalmore_bluesleep_device = {
119         .name           = "bluesleep",
120         .id             = -1,
121         .num_resources  = ARRAY_SIZE(dalmore_bluesleep_resources),
122         .resource       = dalmore_bluesleep_resources,
123 };
124
125 static noinline void __init dalmore_setup_bt_rfkill(void)
126 {
127         platform_device_register(&dalmore_bt_rfkill_device);
128 }
129
130 static noinline void __init dalmore_setup_bluesleep(void)
131 {
132         dalmore_bluesleep_resources[2].start =
133                 dalmore_bluesleep_resources[2].end =
134                         gpio_to_irq(TEGRA_GPIO_PU6);
135         platform_device_register(&dalmore_bluesleep_device);
136         return;
137 }
138 #elif defined(CONFIG_BLUEDROID_PM) || defined(CONFIG_BLUEDROID_PM_MODULE)
139 static struct resource dalmore_bluedroid_pm_resources[] = {
140         [0] = {
141                 .name   = "shutdown_gpio",
142                 .start  = TEGRA_GPIO_PQ7,
143                 .end    = TEGRA_GPIO_PQ7,
144                 .flags  = IORESOURCE_IO,
145         },
146         [1] = {
147                 .name = "host_wake",
148                 .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
149         },
150         [2] = {
151                 .name = "gpio_ext_wake",
152                 .start  = TEGRA_GPIO_PEE1,
153                 .end    = TEGRA_GPIO_PEE1,
154                 .flags  = IORESOURCE_IO,
155         },
156         [3] = {
157                 .name = "gpio_host_wake",
158                 .start  = TEGRA_GPIO_PU6,
159                 .end    = TEGRA_GPIO_PU6,
160                 .flags  = IORESOURCE_IO,
161         },
162         [4] = {
163                 .name = "reset_gpio",
164                 .start  = TEGRA_GPIO_PQ6,
165                 .end    = TEGRA_GPIO_PQ6,
166                 .flags  = IORESOURCE_IO,
167         },
168 };
169
170 static struct platform_device dalmore_bluedroid_pm_device = {
171         .name = "bluedroid_pm",
172         .id             = 0,
173         .num_resources  = ARRAY_SIZE(dalmore_bluedroid_pm_resources),
174         .resource       = dalmore_bluedroid_pm_resources,
175 };
176
177 static noinline void __init dalmore_setup_bluedroid_pm(void)
178 {
179         dalmore_bluedroid_pm_resources[1].start =
180                 dalmore_bluedroid_pm_resources[1].end =
181                                 gpio_to_irq(TEGRA_GPIO_PU6);
182         platform_device_register(&dalmore_bluedroid_pm_device);
183 }
184 #endif
185
186 static __initdata struct tegra_clk_init_table dalmore_clk_init_table[] = {
187         /* name         parent          rate            enabled */
188         { "pll_m",      NULL,           0,              false},
189         { "hda",        "pll_p",        108000000,      false},
190         { "hda2codec_2x", "pll_p",      48000000,       false},
191         { "pwm",        "pll_p",        3187500,        false},
192         { "blink",      "clk_32k",      32768,          true},
193         { "i2s1",       "pll_a_out0",   0,              false},
194         { "i2s3",       "pll_a_out0",   0,              false},
195         { "i2s4",       "pll_a_out0",   0,              false},
196         { "spdif_out",  "pll_a_out0",   0,              false},
197         { "d_audio",    "clk_m",        12000000,       false},
198         { "dam0",       "clk_m",        12000000,       false},
199         { "dam1",       "clk_m",        12000000,       false},
200         { "dam2",       "clk_m",        12000000,       false},
201         { "audio1",     "i2s1_sync",    0,              false},
202         { "audio3",     "i2s3_sync",    0,              false},
203         /* Setting vi_sensor-clk to true for validation purpose, will imapact
204          * power, later set to be false.*/
205         { "vi_sensor",  "pll_p",        150000000,      false},
206         { "cilab",      "pll_p",        150000000,      false},
207         { "cilcd",      "pll_p",        150000000,      false},
208         { "cile",       "pll_p",        150000000,      false},
209         { "i2c1",       "pll_p",        3200000,        false},
210         { "i2c2",       "pll_p",        3200000,        false},
211         { "i2c3",       "pll_p",        3200000,        false},
212         { "i2c4",       "pll_p",        3200000,        false},
213         { "i2c5",       "pll_p",        3200000,        false},
214         { "sbc1",       "pll_p",        25000000,       false},
215         { "sbc2",       "pll_p",        25000000,       false},
216         { "sbc3",       "pll_p",        25000000,       false},
217         { "sbc4",       "pll_p",        25000000,       false},
218         { "sbc5",       "pll_p",        25000000,       false},
219         { "sbc6",       "pll_p",        25000000,       false},
220         { "uarta",      "pll_p",        408000000,      false},
221         { "uartb",      "pll_p",        408000000,      false},
222         { "uartc",      "pll_p",        408000000,      false},
223         { "uartd",      "pll_p",        408000000,      false},
224         { NULL,         NULL,           0,              0},
225 };
226
227 #ifndef CONFIG_USE_OF
228 static struct tegra_i2c_platform_data dalmore_i2c1_platform_data = {
229         .bus_clk_rate   = 100000,
230         .scl_gpio       = TEGRA_GPIO_I2C1_SCL,
231         .sda_gpio       = TEGRA_GPIO_I2C1_SDA,
232 };
233
234 static struct tegra_i2c_platform_data dalmore_i2c2_platform_data = {
235         .bus_clk_rate   = 100000,
236         .is_clkon_always = true,
237         .scl_gpio       = TEGRA_GPIO_I2C2_SCL,
238         .sda_gpio       = TEGRA_GPIO_I2C2_SDA,
239 };
240
241 static struct tegra_i2c_platform_data dalmore_i2c3_platform_data = {
242         .bus_clk_rate   = 400000,
243         .scl_gpio       = TEGRA_GPIO_I2C3_SCL,
244         .sda_gpio       = TEGRA_GPIO_I2C3_SDA,
245 };
246
247 static struct tegra_i2c_platform_data dalmore_i2c4_platform_data = {
248         .bus_clk_rate   = 10000,
249         .scl_gpio       = TEGRA_GPIO_I2C4_SCL,
250         .sda_gpio       = TEGRA_GPIO_I2C4_SDA,
251 };
252
253 static struct tegra_i2c_platform_data dalmore_i2c5_platform_data = {
254         .bus_clk_rate   = 400000,
255         .scl_gpio       = TEGRA_GPIO_I2C5_SCL,
256         .sda_gpio       = TEGRA_GPIO_I2C5_SDA,
257         .needs_cl_dvfs_clock = true,
258 };
259 #endif
260
261 static struct i2c_board_info __initdata rt5640_board_info = {
262         I2C_BOARD_INFO("rt5640", 0x1c),
263 };
264
265 static struct pn544_i2c_platform_data nfc_pdata = {
266         .irq_gpio = TEGRA_GPIO_PW2,
267         .ven_gpio = TEGRA_GPIO_PQ3,
268         .firm_gpio = TEGRA_GPIO_PH0,
269 };
270
271 static struct i2c_board_info __initdata nfc_board_info = {
272         I2C_BOARD_INFO("pn544", 0x28),
273         .platform_data = &nfc_pdata,
274 };
275
276 static void dalmore_i2c_init(void)
277 {
278 #ifndef CONFIG_USE_OF
279         tegra11_i2c_device1.dev.platform_data = &dalmore_i2c1_platform_data;
280         tegra11_i2c_device2.dev.platform_data = &dalmore_i2c2_platform_data;
281         tegra11_i2c_device3.dev.platform_data = &dalmore_i2c3_platform_data;
282         tegra11_i2c_device4.dev.platform_data = &dalmore_i2c4_platform_data;
283         tegra11_i2c_device5.dev.platform_data = &dalmore_i2c5_platform_data;
284
285         platform_device_register(&tegra11_i2c_device5);
286         platform_device_register(&tegra11_i2c_device4);
287         platform_device_register(&tegra11_i2c_device3);
288         platform_device_register(&tegra11_i2c_device2);
289         platform_device_register(&tegra11_i2c_device1);
290 #endif
291         nfc_board_info.irq = gpio_to_irq(TEGRA_GPIO_PW2);
292         i2c_register_board_info(0, &nfc_board_info, 1);
293         i2c_register_board_info(0, &rt5640_board_info, 1);
294 }
295
296 static struct tegra_serial_platform_data dalmore_uartd_pdata = {
297         .dma_req_selector = 19,
298         .modem_interrupt = false,
299 };
300
301 static void __init dalmore_uart_init(void)
302 {
303         int debug_port_id;
304
305         /* Register low speed only if it is selected */
306         if (!is_tegra_debug_uartport_hs()) {
307                 debug_port_id = uart_console_debug_init(3);
308                 if (debug_port_id < 0)
309                         return;
310
311                 platform_device_register(uart_console_debug_device);
312
313         } else {
314                 tegra_uartd_device.dev.platform_data = &dalmore_uartd_pdata;
315                 platform_device_register(&tegra_uartd_device);
316         }
317
318 }
319
320 static struct resource tegra_rtc_resources[] = {
321         [0] = {
322                 .start = TEGRA_RTC_BASE,
323                 .end = TEGRA_RTC_BASE + TEGRA_RTC_SIZE - 1,
324                 .flags = IORESOURCE_MEM,
325         },
326         [1] = {
327                 .start = INT_RTC,
328                 .end = INT_RTC,
329                 .flags = IORESOURCE_IRQ,
330         },
331 };
332
333 static struct platform_device tegra_rtc_device = {
334         .name = "tegra_rtc",
335         .id   = -1,
336         .resource = tegra_rtc_resources,
337         .num_resources = ARRAY_SIZE(tegra_rtc_resources),
338 };
339
340 static struct tegra_asoc_platform_data dalmore_audio_pdata = {
341         .gpio_spkr_en           = TEGRA_GPIO_SPKR_EN,
342         .gpio_hp_det            = TEGRA_GPIO_HP_DET,
343         .gpio_hp_mute           = -1,
344         .gpio_int_mic_en        = TEGRA_GPIO_INT_MIC_EN,
345         .gpio_ext_mic_en        = TEGRA_GPIO_EXT_MIC_EN,
346         .gpio_ldo1_en           = TEGRA_GPIO_LDO1_EN,
347         .gpio_codec1 = TEGRA_GPIO_CODEC1_EN,
348         .gpio_codec2 = TEGRA_GPIO_CODEC2_EN,
349         .gpio_codec3 = TEGRA_GPIO_CODEC3_EN,
350         .i2s_param[HIFI_CODEC]  = {
351                 .audio_port_id  = 1,
352                 .is_i2s_master  = 1,
353                 .i2s_mode       = TEGRA_DAIFMT_I2S,
354         },
355         .i2s_param[BT_SCO]      = {
356                 .audio_port_id  = 3,
357                 .is_i2s_master  = 1,
358                 .i2s_mode       = TEGRA_DAIFMT_DSP_A,
359         },
360 };
361
362 static struct platform_device dalmore_audio_device = {
363         .name   = "tegra-snd-rt5640",
364         .id     = 0,
365         .dev    = {
366                 .platform_data = &dalmore_audio_pdata,
367         },
368 };
369
370 static struct platform_device *dalmore_devices[] __initdata = {
371         &tegra_pmu_device,
372         &tegra_rtc_device,
373         &tegra_udc_device,
374 #if defined(CONFIG_TEGRA_AVP)
375         &tegra_avp_device,
376 #endif
377 #if defined(CONFIG_CRYPTO_DEV_TEGRA_SE)
378         &tegra11_se_device,
379 #endif
380         &tegra_ahub_device,
381         &tegra_dam_device0,
382         &tegra_dam_device1,
383         &tegra_dam_device2,
384         &tegra_i2s_device1,
385         &tegra_i2s_device3,
386         &tegra_i2s_device4,
387         &tegra_spdif_device,
388         &spdif_dit_device,
389         &bluetooth_dit_device,
390         &tegra_pcm_device,
391         &dalmore_audio_device,
392         &tegra_hda_device,
393 #if defined(CONFIG_TEGRA_CEC_SUPPORT)
394         &tegra_cec_device,
395 #endif
396 #if defined(CONFIG_CRYPTO_DEV_TEGRA_AES)
397         &tegra_aes_device,
398 #endif
399 };
400
401 #ifdef CONFIG_USB_SUPPORT
402 static struct tegra_usb_platform_data tegra_udc_pdata = {
403         .port_otg = true,
404         .has_hostpc = true,
405         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
406         .unaligned_dma_buf_supported = false,
407         .op_mode = TEGRA_USB_OPMODE_DEVICE,
408         .u_data.dev = {
409                 .vbus_pmu_irq = 0,
410                 .vbus_gpio = -1,
411                 .charging_supported = false,
412                 .remote_wakeup_supported = false,
413         },
414         .u_cfg.utmi = {
415                 .hssync_start_delay = 0,
416                 .elastic_limit = 16,
417                 .idle_wait_delay = 17,
418                 .term_range_adj = 6,
419                 .xcvr_setup = 8,
420                 .xcvr_lsfslew = 0,
421                 .xcvr_lsrslew = 3,
422                 .xcvr_setup_offset = 0,
423                 .xcvr_use_fuses = 1,
424         },
425 };
426
427 static struct tegra_usb_platform_data tegra_ehci1_utmi_pdata = {
428         .port_otg = true,
429         .has_hostpc = true,
430         .unaligned_dma_buf_supported = false,
431         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
432         .op_mode = TEGRA_USB_OPMODE_HOST,
433         .u_data.host = {
434                 .vbus_gpio = -1,
435                 .hot_plug = false,
436                 .remote_wakeup_supported = true,
437                 .power_off_on_suspend = true,
438         },
439         .u_cfg.utmi = {
440                 .hssync_start_delay = 0,
441                 .elastic_limit = 16,
442                 .idle_wait_delay = 17,
443                 .term_range_adj = 6,
444                 .xcvr_setup = 15,
445                 .xcvr_lsfslew = 0,
446                 .xcvr_lsrslew = 3,
447                 .xcvr_setup_offset = 0,
448                 .xcvr_use_fuses = 1,
449                 .vbus_oc_map = 0x4,
450         },
451 };
452
453 static struct tegra_usb_platform_data tegra_ehci3_utmi_pdata = {
454         .port_otg = false,
455         .has_hostpc = true,
456         .unaligned_dma_buf_supported = false,
457         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
458         .op_mode = TEGRA_USB_OPMODE_HOST,
459         .u_data.host = {
460                 .vbus_gpio = -1,
461                 .hot_plug = false,
462                 .remote_wakeup_supported = true,
463                 .power_off_on_suspend = true,
464         },
465         .u_cfg.utmi = {
466         .hssync_start_delay = 0,
467                 .elastic_limit = 16,
468                 .idle_wait_delay = 17,
469                 .term_range_adj = 6,
470                 .xcvr_setup = 8,
471                 .xcvr_lsfslew = 0,
472                 .xcvr_lsrslew = 3,
473                 .xcvr_setup_offset = 0,
474                 .xcvr_use_fuses = 1,
475                 .vbus_oc_map = 0x5,
476         },
477 };
478
479 static struct tegra_usb_otg_data tegra_otg_pdata = {
480         .ehci_device = &tegra_ehci1_device,
481         .ehci_pdata = &tegra_ehci1_utmi_pdata,
482 };
483
484 static void dalmore_usb_init(void)
485 {
486         int usb_port_owner_info = tegra_get_usb_port_owner_info();
487
488         /* Set USB wake sources for dalmore */
489         tegra_set_usb_wake_source();
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
498         if (!(usb_port_owner_info & UTMI2_PORT_OWNER_XUSB)) {
499                 tegra_ehci3_device.dev.platform_data = &tegra_ehci3_utmi_pdata;
500                 platform_device_register(&tegra_ehci3_device);
501         }
502 }
503
504 static struct tegra_xusb_board_data xusb_bdata = {
505         .portmap = TEGRA_XUSB_SS_P0 | TEGRA_XUSB_USB2_P1,
506         /* ss_portmap[0:3] = SS0 map, ss_portmap[4:7] = SS1 map */
507         .ss_portmap = (TEGRA_XUSB_SS_PORT_MAP_USB2_P1 << 0),
508         .uses_external_pmic = false,
509         .supply = {
510                 .utmi_vbuses = {
511                         NULL, "usb_vbus", NULL
512                 },
513                 .s3p3v = "hvdd_usb",
514                 .s1p8v = "avdd_usb_pll",
515                 .vddio_hsic = "vddio_hsic",
516                 .s1p05v = "avddio_usb",
517         },
518 };
519
520 static void dalmore_xusb_init(void)
521 {
522         int usb_port_owner_info = tegra_get_usb_port_owner_info();
523
524         if (usb_port_owner_info & UTMI2_PORT_OWNER_XUSB)
525                 tegra_xusb_init(&xusb_bdata);
526 }
527
528 static struct gpio modem_gpios[] = { /* Nemo modem */
529         {MODEM_EN, GPIOF_OUT_INIT_HIGH, "MODEM EN"},
530         {MDM_RST, GPIOF_OUT_INIT_LOW, "MODEM RESET"},
531 };
532
533 static struct tegra_usb_platform_data tegra_ehci2_hsic_baseband_pdata = {
534         .port_otg = false,
535         .has_hostpc = true,
536         .unaligned_dma_buf_supported = false,
537         .phy_intf = TEGRA_USB_PHY_INTF_HSIC,
538         .op_mode = TEGRA_USB_OPMODE_HOST,
539         .u_data.host = {
540                 .vbus_gpio = -1,
541                 .hot_plug = false,
542                 .remote_wakeup_supported = true,
543                 .power_off_on_suspend = true,
544         },
545 };
546
547 static int baseband_init(void)
548 {
549         int ret;
550
551         ret = gpio_request_array(modem_gpios, ARRAY_SIZE(modem_gpios));
552         if (ret) {
553                 pr_warn("%s:gpio request failed\n", __func__);
554                 return ret;
555         }
556
557         /* enable pull-down for MDM_COLD_BOOT */
558         tegra_pinmux_set_pullupdown(TEGRA_PINGROUP_KB_COL5,
559                                     TEGRA_PUPD_PULL_DOWN);
560
561         /* export GPIO for user space access through sysfs */
562         gpio_export(MDM_RST, false);
563
564         return 0;
565 }
566
567 static const struct tegra_modem_operations baseband_operations = {
568         .init = baseband_init,
569 };
570
571 static struct tegra_usb_modem_power_platform_data baseband_pdata = {
572         .ops = &baseband_operations,
573         .regulator_name = "vdd_modem_3v3",
574         .wake_gpio = -1,
575         .boot_gpio = MDM_COLDBOOT,
576         .boot_irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
577         .autosuspend_delay = 2000,
578         .short_autosuspend_delay = 50,
579         .tegra_ehci_device = &tegra_ehci2_device,
580         .tegra_ehci_pdata = &tegra_ehci2_hsic_baseband_pdata,
581 };
582
583 static struct platform_device icera_nemo_device = {
584         .name = "tegra_usb_modem_power",
585         .id = -1,
586         .dev = {
587                 .platform_data = &baseband_pdata,
588         },
589 };
590
591 static void dalmore_modem_init(void)
592 {
593         int modem_id = tegra_get_modem_id();
594         int usb_port_owner_info = tegra_get_usb_port_owner_info();
595         switch (modem_id) {
596         case TEGRA_BB_NEMO: /* on board i500 HSIC */
597                 if (!(usb_port_owner_info & HSIC1_PORT_OWNER_XUSB)) {
598                         platform_device_register(&icera_nemo_device);
599                 }
600                 break;
601         }
602 }
603
604 #else
605 static void dalmore_usb_init(void) { }
606 static void dalmore_modem_init(void) { }
607 static void dalmore_xusb_init(void) { }
608 #endif
609
610 static void dalmore_audio_init(void)
611 {
612         dalmore_audio_pdata.codec_name = "rt5640.0-001c";
613         dalmore_audio_pdata.codec_dai_name = "rt5640-aif1";
614 }
615
616 #ifndef CONFIG_USE_OF
617 static struct platform_device *dalmore_spi_devices[] __initdata = {
618         &tegra11_spi_device4,
619 };
620
621 static struct tegra_spi_platform_data dalmore_spi_pdata = {
622         .dma_req_sel            = 0,
623         .spi_max_frequency      = 25000000,
624         .clock_always_on        = false,
625 };
626
627 static void __init dalmore_spi_init(void)
628 {
629         tegra11_spi_device4.dev.platform_data = &dalmore_spi_pdata;
630         platform_add_devices(dalmore_spi_devices,
631                                 ARRAY_SIZE(dalmore_spi_devices));
632 }
633 #else
634 static void __init dalmore_spi_init(void)
635 {
636 }
637 #endif
638
639 static __initdata struct tegra_clk_init_table touch_clk_init_table[] = {
640         /* name         parent          rate            enabled */
641         { "extern2",    "pll_p",        41000000,       false},
642         { "clk_out_2",  "extern2",      40800000,       false},
643         { NULL,         NULL,           0,              0},
644 };
645
646 struct rm_spi_ts_platform_data rm31080ts_dalmore_data = {
647         .gpio_reset = TOUCH_GPIO_RST_RAYDIUM_SPI,
648         .config = 0,
649         .platform_id = RM_PLATFORM_D010,
650         .name_of_clock = "clk_out_2",
651         .name_of_clock_con = "extern2",
652 };
653
654 static struct tegra_spi_device_controller_data dev_cdata = {
655         .rx_clk_tap_delay = 16,
656         .tx_clk_tap_delay = 16,
657 };
658
659 struct spi_board_info rm31080a_dalmore_spi_board[1] = {
660         {
661          .modalias = "rm_ts_spidev",
662          .bus_num = 3,
663          .chip_select = 2,
664          .max_speed_hz = 12 * 1000 * 1000,
665          .mode = SPI_MODE_0,
666          .controller_data = &dev_cdata,
667          .platform_data = &rm31080ts_dalmore_data,
668          },
669 };
670
671 static int __init dalmore_touch_init(void)
672 {
673         tegra_clk_init_from_table(touch_clk_init_table);
674         if (display_board_info.board_id == BOARD_E1582)
675                 rm31080ts_dalmore_data.platform_id = RM_PLATFORM_P005;
676         else
677                 rm31080ts_dalmore_data.platform_id = RM_PLATFORM_D010;
678         mdelay(20);
679         rm31080a_dalmore_spi_board[0].irq = gpio_to_irq(TOUCH_GPIO_IRQ_RAYDIUM_SPI);
680         touch_init_raydium(TOUCH_GPIO_IRQ_RAYDIUM_SPI,
681                                 TOUCH_GPIO_RST_RAYDIUM_SPI,
682                                 &rm31080ts_dalmore_data,
683                                 &rm31080a_dalmore_spi_board[0],
684                                 ARRAY_SIZE(rm31080a_dalmore_spi_board));
685         return 0;
686 }
687
688 #ifdef CONFIG_USE_OF
689 struct of_dev_auxdata dalmore_auxdata_lookup[] __initdata = {
690         OF_DEV_AUXDATA("nvidia,tegra114-sdhci", 0x78000600, "sdhci-tegra.3",
691                                 NULL),
692         OF_DEV_AUXDATA("nvidia,tegra114-sdhci", 0x78000400, "sdhci-tegra.2",
693                                 NULL),
694         OF_DEV_AUXDATA("nvidia,tegra114-sdhci", 0x78000000, "sdhci-tegra.0",
695                                 &dalmore_tegra_sdhci_platform_data0),
696         OF_DEV_AUXDATA("nvidia,tegra114-camera", 0x0, "tegra_camera",
697                                 NULL),
698         OF_DEV_AUXDATA("nvidia,tegra114-host1x", TEGRA_HOST1X_BASE, "host1x",
699                                 NULL),
700         OF_DEV_AUXDATA("nvidia,tegra114-gr3d", TEGRA_GR3D_BASE, "gr3d",
701                                 NULL),
702         OF_DEV_AUXDATA("nvidia,tegra114-gr2d", TEGRA_GR2D_BASE, "gr2d",
703                                 NULL),
704         OF_DEV_AUXDATA("nvidia,tegra114-msenc", TEGRA_MSENC_BASE, "msenc",
705                                 NULL),
706         OF_DEV_AUXDATA("nvidia,tegra114-vi", TEGRA_VI_BASE, "vi",
707                                 NULL),
708         OF_DEV_AUXDATA("nvidia,tegra114-isp", TEGRA_ISP_BASE, "isp",
709                                 NULL),
710         OF_DEV_AUXDATA("nvidia,tegra114-tsec", TEGRA_TSEC_BASE, "tsec",
711                                 NULL),
712
713         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c000, "tegra11-i2c.0",
714                                 NULL),
715         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c400, "tegra11-i2c.1",
716                                 NULL),
717         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c500, "tegra11-i2c.2",
718                                 NULL),
719         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c700, "tegra11-i2c.3",
720                                 NULL),
721         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000d000, "tegra11-i2c.4",
722                                 NULL),
723         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000d400, "spi-tegra114.0",
724                                 NULL),
725         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000d600, "spi-tegra114.1",
726                                 NULL),
727         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000d800, "spi-tegra114.2",
728                                 NULL),
729         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000da00, "spi-tegra114.3",
730                                 NULL),
731         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000dc00, "spi-tegra114.4",
732                                 NULL),
733         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000de00, "spi-tegra114.5",
734                                 NULL),
735         OF_DEV_AUXDATA("nvidia,tegra114-apbdma", 0x6000a000, "tegra-apbdma",
736                                 NULL),
737         OF_DEV_AUXDATA("nvidia,tegra114-hsuart", 0x70006000, "serial-tegra.0",
738                                 NULL),
739         OF_DEV_AUXDATA("nvidia,tegra114-hsuart", 0x70006040, "serial-tegra.1",
740                                 NULL),
741         OF_DEV_AUXDATA("nvidia,tegra114-hsuart", 0x70006200, "serial-tegra.2",
742                                 NULL),
743         {}
744 };
745 #endif
746
747 static void __init tegra_dalmore_early_init(void)
748 {
749         tegra_clk_init_from_table(dalmore_clk_init_table);
750         tegra_clk_verify_parents();
751         tegra_soc_device_init("dalmore");
752 }
753
754 static void __init tegra_dalmore_late_init(void)
755 {
756         platform_device_register(&tegra_pinmux_device);
757         dalmore_pinmux_init();
758         dalmore_i2c_init();
759         dalmore_spi_init();
760         dalmore_usb_init();
761         dalmore_xusb_init();
762         dalmore_uart_init();
763         dalmore_audio_init();
764         platform_add_devices(dalmore_devices, ARRAY_SIZE(dalmore_devices));
765         //tegra_ram_console_debug_init();
766         tegra_io_dpd_init();
767         dalmore_regulator_init();
768         dalmore_sdhci_init();
769         dalmore_suspend_init();
770         dalmore_emc_init();
771         dalmore_edp_init();
772         isomgr_init();
773         dalmore_touch_init();
774         if (board_info.board_id == BOARD_E1582)
775                 roth_panel_init(board_info.board_id);
776         else
777                 dalmore_panel_init();
778         dalmore_kbc_init();
779         dalmore_pmon_init();
780 #if defined(CONFIG_BT_BLUESLEEP) || defined(CONFIG_BT_BLUESLEEP_MODULE)
781         dalmore_setup_bluesleep();
782         dalmore_setup_bt_rfkill();
783 #elif defined(CONFIG_BLUEDROID_PM) || defined(CONFIG_BLUEDROID_PM_MODULE)
784         dalmore_setup_bluedroid_pm();
785 #endif
786         dalmore_modem_init();
787 #ifdef CONFIG_TEGRA_WDT_RECOVERY
788         tegra_wdt_recovery_init();
789 #endif
790         tegra_serial_debug_init(TEGRA_UARTD_BASE, INT_WDT_CPU, NULL, -1, -1);
791         dalmore_sensors_init();
792         dalmore_soctherm_init();
793         tegra_register_fuse();
794 }
795
796 static void __init dalmore_ramconsole_reserve(unsigned long size)
797 {
798         tegra_ram_console_debug_reserve(SZ_1M);
799 }
800
801 static void __init tegra_dalmore_dt_init(void)
802 {
803         tegra_get_board_info(&board_info);
804         tegra_get_display_board_info(&display_board_info);
805
806         tegra_dalmore_early_init();
807
808         of_platform_populate(NULL,
809                 of_default_bus_match_table, dalmore_auxdata_lookup,
810                 &platform_bus);
811
812         tegra_dalmore_late_init();
813 }
814
815 static void __init tegra_dalmore_reserve(void)
816 {
817 #if defined(CONFIG_NVMAP_CONVERT_CARVEOUT_TO_IOVMM)
818         /* 1920*1200*4*2 = 18432000 bytes */
819         tegra_reserve(0, SZ_16M + SZ_2M, SZ_16M);
820 #else
821         tegra_reserve(SZ_128M, SZ_16M + SZ_2M, SZ_4M);
822 #endif
823         dalmore_ramconsole_reserve(SZ_1M);
824 }
825
826 static const char * const dalmore_dt_board_compat[] = {
827         "nvidia,dalmore",
828         NULL
829 };
830
831 MACHINE_START(DALMORE, "dalmore")
832         .atag_offset    = 0x100,
833         .smp            = smp_ops(tegra_smp_ops),
834         .map_io         = tegra_map_common_io,
835         .reserve        = tegra_dalmore_reserve,
836         .init_early     = tegra11x_init_early,
837         .init_irq       = tegra_dt_init_irq,
838         .init_time      = tegra_init_timer,
839         .init_machine   = tegra_dalmore_dt_init,
840         .restart        = tegra_assert_system_reset,
841         .dt_compat      = dalmore_dt_board_compat,
842         .init_late      = tegra_init_late,
843 MACHINE_END