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