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