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