usb: xhci: tegra: update fuse programming from usb_calib0
[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-tegra30.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 <mach/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   = 100000,
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 };
256 #endif
257
258 static struct i2c_board_info __initdata rt5640_board_info = {
259         I2C_BOARD_INFO("rt5640", 0x1c),
260 };
261
262 static struct pn544_i2c_platform_data nfc_pdata = {
263         .irq_gpio = TEGRA_GPIO_PW2,
264         .ven_gpio = TEGRA_GPIO_PQ3,
265         .firm_gpio = TEGRA_GPIO_PH0,
266 };
267
268 static struct i2c_board_info __initdata nfc_board_info = {
269         I2C_BOARD_INFO("pn544", 0x28),
270         .platform_data = &nfc_pdata,
271 };
272
273 static void dalmore_i2c_init(void)
274 {
275 #ifndef CONFIG_USE_OF
276         tegra11_i2c_device1.dev.platform_data = &dalmore_i2c1_platform_data;
277         tegra11_i2c_device2.dev.platform_data = &dalmore_i2c2_platform_data;
278         tegra11_i2c_device3.dev.platform_data = &dalmore_i2c3_platform_data;
279         tegra11_i2c_device4.dev.platform_data = &dalmore_i2c4_platform_data;
280         tegra11_i2c_device5.dev.platform_data = &dalmore_i2c5_platform_data;
281
282         platform_device_register(&tegra11_i2c_device5);
283         platform_device_register(&tegra11_i2c_device4);
284         platform_device_register(&tegra11_i2c_device3);
285         platform_device_register(&tegra11_i2c_device2);
286         platform_device_register(&tegra11_i2c_device1);
287 #endif
288         nfc_board_info.irq = gpio_to_irq(TEGRA_GPIO_PW2);
289         i2c_register_board_info(0, &nfc_board_info, 1);
290         i2c_register_board_info(0, &rt5640_board_info, 1);
291 }
292
293 static struct platform_device *dalmore_uart_devices[] __initdata = {
294         &tegra_uarta_device,
295         &tegra_uartb_device,
296         &tegra_uartc_device,
297         &tegra_uartd_device,
298 };
299 static struct uart_clk_parent uart_parent_clk[] = {
300         [0] = {.name = "clk_m"},
301         [1] = {.name = "pll_p"},
302 #ifndef CONFIG_TEGRA_PLLM_RESTRICTED
303         [2] = {.name = "pll_m"},
304 #endif
305 };
306
307 static struct tegra_uart_platform_data dalmore_uart_pdata;
308 static struct tegra_uart_platform_data dalmore_loopback_uart_pdata;
309
310 static void __init uart_debug_init(void)
311 {
312         int debug_port_id;
313
314         debug_port_id = uart_console_debug_init(3);
315         if (debug_port_id < 0)
316                 return;
317
318         dalmore_uart_devices[debug_port_id] = uart_console_debug_device;
319 }
320
321 static void __init dalmore_uart_init(void)
322 {
323         struct clk *c;
324         int i;
325
326         for (i = 0; i < ARRAY_SIZE(uart_parent_clk); ++i) {
327                 c = tegra_get_clock_by_name(uart_parent_clk[i].name);
328                 if (IS_ERR_OR_NULL(c)) {
329                         pr_err("Not able to get the clock for %s\n",
330                                                 uart_parent_clk[i].name);
331                         continue;
332                 }
333                 uart_parent_clk[i].parent_clk = c;
334                 uart_parent_clk[i].fixed_clk_rate = clk_get_rate(c);
335         }
336         dalmore_uart_pdata.parent_clk_list = uart_parent_clk;
337         dalmore_uart_pdata.parent_clk_count = ARRAY_SIZE(uart_parent_clk);
338         dalmore_loopback_uart_pdata.parent_clk_list = uart_parent_clk;
339         dalmore_loopback_uart_pdata.parent_clk_count =
340                                                 ARRAY_SIZE(uart_parent_clk);
341         dalmore_loopback_uart_pdata.is_loopback = true;
342         tegra_uarta_device.dev.platform_data = &dalmore_uart_pdata;
343         tegra_uartb_device.dev.platform_data = &dalmore_uart_pdata;
344         tegra_uartc_device.dev.platform_data = &dalmore_uart_pdata;
345         tegra_uartd_device.dev.platform_data = &dalmore_uart_pdata;
346
347         /* Register low speed only if it is selected */
348         if (!is_tegra_debug_uartport_hs())
349                 uart_debug_init();
350
351         platform_add_devices(dalmore_uart_devices,
352                                 ARRAY_SIZE(dalmore_uart_devices));
353 }
354
355 static struct resource tegra_rtc_resources[] = {
356         [0] = {
357                 .start = TEGRA_RTC_BASE,
358                 .end = TEGRA_RTC_BASE + TEGRA_RTC_SIZE - 1,
359                 .flags = IORESOURCE_MEM,
360         },
361         [1] = {
362                 .start = INT_RTC,
363                 .end = INT_RTC,
364                 .flags = IORESOURCE_IRQ,
365         },
366 };
367
368 static struct platform_device tegra_rtc_device = {
369         .name = "tegra_rtc",
370         .id   = -1,
371         .resource = tegra_rtc_resources,
372         .num_resources = ARRAY_SIZE(tegra_rtc_resources),
373 };
374
375 static struct tegra_asoc_platform_data dalmore_audio_pdata = {
376         .gpio_spkr_en           = TEGRA_GPIO_SPKR_EN,
377         .gpio_hp_det            = TEGRA_GPIO_HP_DET,
378         .gpio_hp_mute           = -1,
379         .gpio_int_mic_en        = TEGRA_GPIO_INT_MIC_EN,
380         .gpio_ext_mic_en        = TEGRA_GPIO_EXT_MIC_EN,
381         .gpio_ldo1_en           = TEGRA_GPIO_LDO1_EN,
382         .gpio_codec1 = TEGRA_GPIO_CODEC1_EN,
383         .gpio_codec2 = TEGRA_GPIO_CODEC2_EN,
384         .gpio_codec3 = TEGRA_GPIO_CODEC3_EN,
385         .i2s_param[HIFI_CODEC]  = {
386                 .audio_port_id  = 1,
387                 .is_i2s_master  = 1,
388                 .i2s_mode       = TEGRA_DAIFMT_I2S,
389         },
390         .i2s_param[BT_SCO]      = {
391                 .audio_port_id  = 3,
392                 .is_i2s_master  = 1,
393                 .i2s_mode       = TEGRA_DAIFMT_DSP_A,
394         },
395 };
396
397 static struct platform_device dalmore_audio_device = {
398         .name   = "tegra-snd-rt5640",
399         .id     = 0,
400         .dev    = {
401                 .platform_data = &dalmore_audio_pdata,
402         },
403 };
404
405 static struct platform_device *dalmore_devices[] __initdata = {
406         &tegra_pmu_device,
407         &tegra_rtc_device,
408         &tegra_udc_device,
409 #if defined(CONFIG_TEGRA_AVP)
410         &tegra_avp_device,
411 #endif
412 #if defined(CONFIG_CRYPTO_DEV_TEGRA_SE)
413         &tegra11_se_device,
414 #endif
415         &tegra_ahub_device,
416         &tegra_dam_device0,
417         &tegra_dam_device1,
418         &tegra_dam_device2,
419         &tegra_i2s_device1,
420         &tegra_i2s_device3,
421         &tegra_i2s_device4,
422         &tegra_spdif_device,
423         &spdif_dit_device,
424         &bluetooth_dit_device,
425         &dalmore_audio_device,
426         &tegra_hda_device,
427 #if defined(CONFIG_CRYPTO_DEV_TEGRA_AES)
428         &tegra_aes_device,
429 #endif
430 };
431
432 #ifdef CONFIG_USB_SUPPORT
433 static struct tegra_usb_platform_data tegra_udc_pdata = {
434         .port_otg = true,
435         .has_hostpc = true,
436         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
437         .op_mode = TEGRA_USB_OPMODE_DEVICE,
438         .u_data.dev = {
439                 .vbus_pmu_irq = 0,
440                 .vbus_gpio = -1,
441                 .charging_supported = false,
442                 .remote_wakeup_supported = false,
443         },
444         .u_cfg.utmi = {
445                 .hssync_start_delay = 0,
446                 .elastic_limit = 16,
447                 .idle_wait_delay = 17,
448                 .term_range_adj = 6,
449                 .xcvr_setup = 8,
450                 .xcvr_lsfslew = 2,
451                 .xcvr_lsrslew = 2,
452                 .xcvr_setup_offset = 0,
453                 .xcvr_use_fuses = 1,
454         },
455 };
456
457 static struct tegra_usb_platform_data tegra_ehci1_utmi_pdata = {
458         .port_otg = true,
459         .has_hostpc = true,
460         .unaligned_dma_buf_supported = false,
461         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
462         .op_mode = TEGRA_USB_OPMODE_HOST,
463         .u_data.host = {
464                 .vbus_gpio = -1,
465                 .hot_plug = false,
466                 .remote_wakeup_supported = true,
467                 .power_off_on_suspend = true,
468         },
469         .u_cfg.utmi = {
470                 .hssync_start_delay = 0,
471                 .elastic_limit = 16,
472                 .idle_wait_delay = 17,
473                 .term_range_adj = 6,
474                 .xcvr_setup = 15,
475                 .xcvr_lsfslew = 2,
476                 .xcvr_lsrslew = 2,
477                 .xcvr_setup_offset = 0,
478                 .xcvr_use_fuses = 1,
479                 .vbus_oc_map = 0x4,
480         },
481 };
482
483 static struct tegra_usb_platform_data tegra_ehci3_utmi_pdata = {
484         .port_otg = false,
485         .has_hostpc = true,
486         .unaligned_dma_buf_supported = false,
487         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
488         .op_mode = TEGRA_USB_OPMODE_HOST,
489         .u_data.host = {
490                 .vbus_gpio = -1,
491                 .hot_plug = false,
492                 .remote_wakeup_supported = true,
493                 .power_off_on_suspend = true,
494         },
495         .u_cfg.utmi = {
496         .hssync_start_delay = 0,
497                 .elastic_limit = 16,
498                 .idle_wait_delay = 17,
499                 .term_range_adj = 6,
500                 .xcvr_setup = 8,
501                 .xcvr_lsfslew = 2,
502                 .xcvr_lsrslew = 2,
503                 .xcvr_setup_offset = 0,
504                 .xcvr_use_fuses = 1,
505                 .vbus_oc_map = 0x5,
506         },
507 };
508
509 static struct tegra_usb_otg_data tegra_otg_pdata = {
510         .ehci_device = &tegra_ehci1_device,
511         .ehci_pdata = &tegra_ehci1_utmi_pdata,
512 };
513
514 static void dalmore_usb_init(void)
515 {
516         int usb_port_owner_info = tegra_get_usb_port_owner_info();
517
518         /* Set USB wake sources for dalmore */
519         tegra_set_usb_wake_source();
520
521         if (!(usb_port_owner_info & UTMI1_PORT_OWNER_XUSB)) {
522                 tegra_otg_device.dev.platform_data = &tegra_otg_pdata;
523                 platform_device_register(&tegra_otg_device);
524                 /* Setup the udc platform data */
525                 tegra_udc_device.dev.platform_data = &tegra_udc_pdata;
526         }
527
528         if (!(usb_port_owner_info & UTMI2_PORT_OWNER_XUSB)) {
529                 tegra_ehci3_device.dev.platform_data = &tegra_ehci3_utmi_pdata;
530                 platform_device_register(&tegra_ehci3_device);
531         }
532 }
533
534 static struct tegra_xusb_pad_data xusb_padctl_data = {
535         .pad_mux = (0x1 << 2),
536         .port_cap = (0x1 << 4),
537         .snps_oc_map = (0x1fc << 0),
538         .usb2_oc_map = (0x2f << 0),
539         .ss_port_map = (0x2 << 0),
540         .oc_det = (0x2c << 10),
541         .rx_wander = (0xf << 4),
542         .rx_eq = (0x3070 << 8),
543         .cdr_cntl = (0x26 << 24),
544         .dfe_cntl = 0x002008EE,
545         .hs_slew = (0x3 << 6),
546         .otg_pad0_ctl0 = (0x7 << 19),
547         .otg_pad1_ctl0 = (0x0 << 19),
548         .otg_pad0_ctl1 = (0x4 << 0),
549         .otg_pad1_ctl1 = (0x3 << 0),
550         .hs_disc_lvl = (0x5 << 2),
551         .hsic_pad0_ctl0 = (0x00 << 8),
552         .hsic_pad0_ctl1 = (0x00 << 8),
553 };
554
555 static void dalmore_xusb_init(void)
556 {
557         int usb_port_owner_info = tegra_get_usb_port_owner_info();
558
559         if (usb_port_owner_info & UTMI2_PORT_OWNER_XUSB) {
560                 u32 usb_calib0 = tegra_fuse_readl(FUSE_SKU_USB_CALIB_0);
561
562                 pr_info("dalmore_xusb_init: usb_calib0 = 0x%08x\n", usb_calib0);
563                 /*
564                  * read from usb_calib0 and pass to driver
565                  * set HS_CURR_LEVEL (PAD0)     = usb_calib0[5:0]
566                  * set TERM_RANGE_ADJ           = usb_calib0[10:7]
567                  * set HS_SQUELCH_LEVEL         = usb_calib0[12:11]
568                  * set HS_IREF_CAP              = usb_calib0[14:13]
569                  * set HS_CURR_LEVEL (PAD1)     = usb_calib0[20:15]
570                  */
571
572                 xusb_padctl_data.hs_curr_level_pad0 = (usb_calib0 >> 0) & 0x3f;
573                 xusb_padctl_data.hs_term_range_adj = (usb_calib0 >> 7) & 0xf;
574                 xusb_padctl_data.hs_squelch_level = (usb_calib0 >> 11) & 0x3;
575                 xusb_padctl_data.hs_iref_cap = (usb_calib0 >> 13) & 0x3;
576                 xusb_padctl_data.hs_curr_level_pad1 = (usb_calib0 >> 15) & 0x3f;
577
578                 tegra_xhci_device.dev.platform_data = &xusb_padctl_data;
579                 platform_device_register(&tegra_xhci_device);
580         }
581 }
582
583 static struct gpio modem_gpios[] = { /* Nemo modem */
584         {MODEM_EN, GPIOF_OUT_INIT_HIGH, "MODEM EN"},
585         {MDM_RST, GPIOF_OUT_INIT_LOW, "MODEM RESET"},
586 };
587
588 static struct tegra_usb_platform_data tegra_ehci2_hsic_baseband_pdata = {
589         .port_otg = false,
590         .has_hostpc = true,
591         .unaligned_dma_buf_supported = false,
592         .phy_intf = TEGRA_USB_PHY_INTF_HSIC,
593         .op_mode = TEGRA_USB_OPMODE_HOST,
594         .u_data.host = {
595                 .vbus_gpio = -1,
596                 .hot_plug = false,
597                 .remote_wakeup_supported = true,
598                 .power_off_on_suspend = true,
599         },
600 };
601
602 static int baseband_init(void)
603 {
604         int ret;
605
606         ret = gpio_request_array(modem_gpios, ARRAY_SIZE(modem_gpios));
607         if (ret) {
608                 pr_warn("%s:gpio request failed\n", __func__);
609                 return ret;
610         }
611
612         /* enable pull-down for MDM_COLD_BOOT */
613         tegra_pinmux_set_pullupdown(TEGRA_PINGROUP_KB_COL5,
614                                     TEGRA_PUPD_PULL_DOWN);
615
616         /* export GPIO for user space access through sysfs */
617         gpio_export(MDM_RST, false);
618
619         return 0;
620 }
621
622 static const struct tegra_modem_operations baseband_operations = {
623         .init = baseband_init,
624 };
625
626 static struct tegra_usb_modem_power_platform_data baseband_pdata = {
627         .ops = &baseband_operations,
628         .wake_gpio = -1,
629         .boot_gpio = MDM_COLDBOOT,
630         .boot_irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
631         .autosuspend_delay = 2000,
632         .short_autosuspend_delay = 50,
633         .tegra_ehci_device = &tegra_ehci2_device,
634         .tegra_ehci_pdata = &tegra_ehci2_hsic_baseband_pdata,
635 };
636
637 static struct platform_device icera_nemo_device = {
638         .name = "tegra_usb_modem_power",
639         .id = -1,
640         .dev = {
641                 .platform_data = &baseband_pdata,
642         },
643 };
644
645 static void dalmore_modem_init(void)
646 {
647         int modem_id = tegra_get_modem_id();
648         int usb_port_owner_info = tegra_get_usb_port_owner_info();
649         switch (modem_id) {
650         case TEGRA_BB_NEMO: /* on board i500 HSIC */
651                 if (!(usb_port_owner_info & HSIC1_PORT_OWNER_XUSB))
652                         platform_device_register(&icera_nemo_device);
653                 break;
654         }
655 }
656
657 #else
658 static void dalmore_usb_init(void) { }
659 static void dalmore_modem_init(void) { }
660 static void dalmore_xusb_init(void) { }
661 #endif
662
663 static void dalmore_audio_init(void)
664 {
665         dalmore_audio_pdata.codec_name = "rt5640.0-001c";
666         dalmore_audio_pdata.codec_dai_name = "rt5640-aif1";
667 }
668
669 #ifndef CONFIG_USE_OF
670 static struct platform_device *dalmore_spi_devices[] __initdata = {
671         &tegra11_spi_device4,
672 };
673
674 static struct tegra_spi_platform_data dalmore_spi_pdata = {
675         .dma_req_sel            = 0,
676         .spi_max_frequency      = 25000000,
677         .clock_always_on        = false,
678 };
679
680 static void __init dalmore_spi_init(void)
681 {
682         tegra11_spi_device4.dev.platform_data = &dalmore_spi_pdata;
683         platform_add_devices(dalmore_spi_devices,
684                                 ARRAY_SIZE(dalmore_spi_devices));
685 }
686 #else
687 static void __init dalmore_spi_init(void)
688 {
689 }
690 #endif
691
692 static __initdata struct tegra_clk_init_table touch_clk_init_table[] = {
693         /* name         parent          rate            enabled */
694         { "extern2",    "pll_p",        41000000,       false},
695         { "clk_out_2",  "extern2",      40800000,       false},
696         { NULL,         NULL,           0,              0},
697 };
698
699 struct rm_spi_ts_platform_data rm31080ts_dalmore_data = {
700         .gpio_reset = 0,
701         .config = 0,
702         .platform_id = RM_PLATFORM_D010,
703         .name_of_clock = "clk_out_2",
704         .name_of_clock_con = "extern2",
705 };
706
707 static struct tegra_spi_device_controller_data dev_cdata = {
708         .rx_clk_tap_delay = 0,
709         .tx_clk_tap_delay = 16,
710 };
711
712 struct spi_board_info rm31080a_dalmore_spi_board[1] = {
713         {
714          .modalias = "rm_ts_spidev",
715          .bus_num = 3,
716          .chip_select = 2,
717          .max_speed_hz = 12 * 1000 * 1000,
718          .mode = SPI_MODE_0,
719          .controller_data = &dev_cdata,
720          .platform_data = &rm31080ts_dalmore_data,
721          },
722 };
723
724 static int __init dalmore_touch_init(void)
725 {
726         tegra_clk_init_from_table(touch_clk_init_table);
727         if (display_board_info.board_id == BOARD_E1582)
728                 rm31080ts_dalmore_data.platform_id = RM_PLATFORM_P005;
729         else
730                 rm31080ts_dalmore_data.platform_id = RM_PLATFORM_D010;
731         mdelay(20);
732         rm31080a_dalmore_spi_board[0].irq = gpio_to_irq(TOUCH_GPIO_IRQ_RAYDIUM_SPI);
733         touch_init_raydium(TOUCH_GPIO_IRQ_RAYDIUM_SPI,
734                                 TOUCH_GPIO_RST_RAYDIUM_SPI,
735                                 &rm31080ts_dalmore_data,
736                                 &rm31080a_dalmore_spi_board[0],
737                                 ARRAY_SIZE(rm31080a_dalmore_spi_board));
738         return 0;
739 }
740
741 #ifdef CONFIG_USE_OF
742 struct of_dev_auxdata dalmore_auxdata_lookup[] __initdata = {
743         OF_DEV_AUXDATA("nvidia,tegra114-sdhci", 0x78000600, "sdhci-tegra.3",
744                                 NULL),
745         OF_DEV_AUXDATA("nvidia,tegra114-sdhci", 0x78000400, "sdhci-tegra.2",
746                                 NULL),
747         OF_DEV_AUXDATA("nvidia,tegra114-sdhci", 0x78000000, "sdhci-tegra.0",
748                                 &dalmore_tegra_sdhci_platform_data0),
749         OF_DEV_AUXDATA("nvidia,tegra114-camera", 0x0, "tegra_camera",
750                                 NULL),
751         OF_DEV_AUXDATA("nvidia,tegra114-host1x", TEGRA_HOST1X_BASE, "host1x",
752                                 NULL),
753         OF_DEV_AUXDATA("nvidia,tegra114-gr3d", TEGRA_GR3D_BASE, "gr3d",
754                                 NULL),
755         OF_DEV_AUXDATA("nvidia,tegra114-gr2d", TEGRA_GR2D_BASE, "gr2d",
756                                 NULL),
757         OF_DEV_AUXDATA("nvidia,tegra114-msenc", TEGRA_MSENC_BASE, "msenc",
758                                 NULL),
759         OF_DEV_AUXDATA("nvidia,tegra114-vi", TEGRA_VI_BASE, "vi",
760                                 NULL),
761         OF_DEV_AUXDATA("nvidia,tegra114-isp", TEGRA_ISP_BASE, "isp",
762                                 NULL),
763         OF_DEV_AUXDATA("nvidia,tegra114-tsec", TEGRA_TSEC_BASE, "tsec",
764                                 NULL),
765
766         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c000, "tegra11-i2c.0",
767                                 NULL),
768         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c400, "tegra11-i2c.1",
769                                 NULL),
770         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c500, "tegra11-i2c.2",
771                                 NULL),
772         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c700, "tegra11-i2c.3",
773                                 NULL),
774         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000d000, "tegra11-i2c.4",
775                                 NULL),
776         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000d400, "spi-tegra114.0",
777                                 NULL),
778         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000d600, "spi-tegra114.1",
779                                 NULL),
780         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000d800, "spi-tegra114.2",
781                                 NULL),
782         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000da00, "spi-tegra114.3",
783                                 NULL),
784         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000dc00, "spi-tegra114.4",
785                                 NULL),
786         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000de00, "spi-tegra114.5",
787                                 NULL),
788         OF_DEV_AUXDATA("nvidia,tegra114-apbdma", 0x6000a000, "tegra-apbdma",
789                                 NULL),
790         {}
791 };
792 #endif
793
794 static void __init tegra_dalmore_early_init(void)
795 {
796         tegra_clk_init_from_table(dalmore_clk_init_table);
797         tegra_clk_vefify_parents();
798         tegra_smmu_init();
799         tegra_soc_device_init("dalmore");
800 }
801
802 static void __init tegra_dalmore_late_init(void)
803 {
804         platform_device_register(&tegra_pinmux_device);
805         dalmore_pinmux_init();
806         dalmore_i2c_init();
807         dalmore_spi_init();
808         dalmore_usb_init();
809         dalmore_xusb_init();
810         dalmore_uart_init();
811         dalmore_audio_init();
812         platform_add_devices(dalmore_devices, ARRAY_SIZE(dalmore_devices));
813         //tegra_ram_console_debug_init();
814         tegra_io_dpd_init();
815         dalmore_regulator_init();
816         dalmore_sdhci_init();
817         dalmore_suspend_init();
818         dalmore_emc_init();
819         dalmore_edp_init();
820         isomgr_init();
821         dalmore_touch_init();
822         if (board_info.board_id == BOARD_E1582)
823                 roth_panel_init(board_info.board_id);
824         else
825                 dalmore_panel_init();
826         dalmore_kbc_init();
827         dalmore_pmon_init();
828 #if defined(CONFIG_BT_BLUESLEEP) || defined(CONFIG_BT_BLUESLEEP_MODULE)
829         dalmore_setup_bluesleep();
830         dalmore_setup_bt_rfkill();
831 #elif defined CONFIG_BLUEDROID_PM
832         dalmore_setup_bluedroid_pm();
833 #endif
834         tegra_release_bootloader_fb();
835         dalmore_modem_init();
836 #ifdef CONFIG_TEGRA_WDT_RECOVERY
837         tegra_wdt_recovery_init();
838 #endif
839         tegra_serial_debug_init(TEGRA_UARTD_BASE, INT_WDT_CPU, NULL, -1, -1);
840         dalmore_sensors_init();
841         dalmore_soctherm_init();
842         tegra_register_fuse();
843 }
844
845 static void __init dalmore_ramconsole_reserve(unsigned long size)
846 {
847         tegra_ram_console_debug_reserve(SZ_1M);
848 }
849
850 static void __init tegra_dalmore_dt_init(void)
851 {
852         tegra_get_board_info(&board_info);
853         tegra_get_display_board_info(&display_board_info);
854
855         tegra_dalmore_early_init();
856
857         of_platform_populate(NULL,
858                 of_default_bus_match_table, dalmore_auxdata_lookup,
859                 &platform_bus);
860
861         tegra_dalmore_late_init();
862 }
863
864 static void __init tegra_dalmore_reserve(void)
865 {
866 #if defined(CONFIG_NVMAP_CONVERT_CARVEOUT_TO_IOVMM)
867         /* 1920*1200*4*2 = 18432000 bytes */
868         tegra_reserve(0, SZ_16M + SZ_2M, SZ_16M);
869 #else
870         tegra_reserve(SZ_128M, SZ_16M + SZ_2M, SZ_4M);
871 #endif
872         dalmore_ramconsole_reserve(SZ_1M);
873 }
874
875 static const char * const dalmore_dt_board_compat[] = {
876         "nvidia,dalmore",
877         NULL
878 };
879
880 MACHINE_START(DALMORE, "dalmore")
881         .atag_offset    = 0x100,
882         .smp            = smp_ops(tegra_smp_ops),
883         .map_io         = tegra_map_common_io,
884         .reserve        = tegra_dalmore_reserve,
885         .init_early     = tegra11x_init_early,
886         .init_irq       = tegra_dt_init_irq,
887         .handle_irq     = gic_handle_irq,
888         .timer          = &tegra_sys_timer,
889         .init_machine   = tegra_dalmore_dt_init,
890         .restart        = tegra_assert_system_reset,
891         .dt_compat      = dalmore_dt_board_compat,
892 MACHINE_END