ARM: tegra11: dalmore/pluto: Add AUXDATA for APB DMA
[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-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/iomap.h>
57 #include <mach/irqs.h>
58 #include <mach/pinmux.h>
59 #include <mach/pinmux-tegra30.h>
60 #include <mach/iomap.h>
61 #include <mach/io_dpd.h>
62 #include <mach/i2s.h>
63 #include <mach/isomgr.h>
64 #include <mach/tegra_asoc_pdata.h>
65 #include <asm/mach-types.h>
66 #include <asm/mach/arch.h>
67 #include <mach/gpio-tegra.h>
68 #include <mach/tegra_fiq_debugger.h>
69 #include <mach/tegra_usb_modem_power.h>
70
71 #include "board-touch-raydium.h"
72 #include "board.h"
73 #include "board-common.h"
74 #include "clock.h"
75 #include "board-dalmore.h"
76 #include "devices.h"
77 #include "gpio-names.h"
78 #include "fuse.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         { NULL,         NULL,           0,              0},
218 };
219
220 #ifndef CONFIG_USE_OF
221 static struct tegra_i2c_platform_data dalmore_i2c1_platform_data = {
222         .bus_clk_rate   = 100000,
223         .scl_gpio       = TEGRA_GPIO_I2C1_SCL,
224         .sda_gpio       = TEGRA_GPIO_I2C1_SDA,
225 };
226
227 static struct tegra_i2c_platform_data dalmore_i2c2_platform_data = {
228         .bus_clk_rate   = 100000,
229         .is_clkon_always = true,
230         .scl_gpio       = TEGRA_GPIO_I2C2_SCL,
231         .sda_gpio       = TEGRA_GPIO_I2C2_SDA,
232 };
233
234 static struct tegra_i2c_platform_data dalmore_i2c3_platform_data = {
235         .bus_clk_rate   = 100000,
236         .scl_gpio       = TEGRA_GPIO_I2C3_SCL,
237         .sda_gpio       = TEGRA_GPIO_I2C3_SDA,
238 };
239
240 static struct tegra_i2c_platform_data dalmore_i2c4_platform_data = {
241         .bus_clk_rate   = 10000,
242         .scl_gpio       = TEGRA_GPIO_I2C4_SCL,
243         .sda_gpio       = TEGRA_GPIO_I2C4_SDA,
244 };
245
246 static struct tegra_i2c_platform_data dalmore_i2c5_platform_data = {
247         .bus_clk_rate   = 400000,
248         .scl_gpio       = TEGRA_GPIO_I2C5_SCL,
249         .sda_gpio       = TEGRA_GPIO_I2C5_SDA,
250 };
251 #endif
252
253 static struct i2c_board_info __initdata rt5640_board_info = {
254         I2C_BOARD_INFO("rt5640", 0x1c),
255 };
256
257 static struct pn544_i2c_platform_data nfc_pdata = {
258         .irq_gpio = TEGRA_GPIO_PW2,
259         .ven_gpio = TEGRA_GPIO_PQ3,
260         .firm_gpio = TEGRA_GPIO_PH0,
261 };
262
263 static struct i2c_board_info __initdata nfc_board_info = {
264         I2C_BOARD_INFO("pn544", 0x28),
265         .platform_data = &nfc_pdata,
266 };
267
268 static void dalmore_i2c_init(void)
269 {
270 #ifndef CONFIG_USE_OF
271         tegra11_i2c_device1.dev.platform_data = &dalmore_i2c1_platform_data;
272         tegra11_i2c_device2.dev.platform_data = &dalmore_i2c2_platform_data;
273         tegra11_i2c_device3.dev.platform_data = &dalmore_i2c3_platform_data;
274         tegra11_i2c_device4.dev.platform_data = &dalmore_i2c4_platform_data;
275         tegra11_i2c_device5.dev.platform_data = &dalmore_i2c5_platform_data;
276
277         platform_device_register(&tegra11_i2c_device5);
278         platform_device_register(&tegra11_i2c_device4);
279         platform_device_register(&tegra11_i2c_device3);
280         platform_device_register(&tegra11_i2c_device2);
281         platform_device_register(&tegra11_i2c_device1);
282 #endif
283         nfc_board_info.irq = gpio_to_irq(TEGRA_GPIO_PW2);
284         i2c_register_board_info(0, &nfc_board_info, 1);
285         i2c_register_board_info(0, &rt5640_board_info, 1);
286 }
287
288 static struct platform_device *dalmore_uart_devices[] __initdata = {
289         &tegra_uarta_device,
290         &tegra_uartb_device,
291         &tegra_uartc_device,
292         &tegra_uartd_device,
293 };
294 static struct uart_clk_parent uart_parent_clk[] = {
295         [0] = {.name = "clk_m"},
296         [1] = {.name = "pll_p"},
297 #ifndef CONFIG_TEGRA_PLLM_RESTRICTED
298         [2] = {.name = "pll_m"},
299 #endif
300 };
301
302 static struct tegra_uart_platform_data dalmore_uart_pdata;
303 static struct tegra_uart_platform_data dalmore_loopback_uart_pdata;
304
305 static void __init uart_debug_init(void)
306 {
307         int debug_port_id;
308
309         debug_port_id = uart_console_debug_init(3);
310         if (debug_port_id < 0)
311                 return;
312
313         dalmore_uart_devices[debug_port_id] = uart_console_debug_device;
314 }
315
316 static void __init dalmore_uart_init(void)
317 {
318         struct clk *c;
319         int i;
320
321         for (i = 0; i < ARRAY_SIZE(uart_parent_clk); ++i) {
322                 c = tegra_get_clock_by_name(uart_parent_clk[i].name);
323                 if (IS_ERR_OR_NULL(c)) {
324                         pr_err("Not able to get the clock for %s\n",
325                                                 uart_parent_clk[i].name);
326                         continue;
327                 }
328                 uart_parent_clk[i].parent_clk = c;
329                 uart_parent_clk[i].fixed_clk_rate = clk_get_rate(c);
330         }
331         dalmore_uart_pdata.parent_clk_list = uart_parent_clk;
332         dalmore_uart_pdata.parent_clk_count = ARRAY_SIZE(uart_parent_clk);
333         dalmore_loopback_uart_pdata.parent_clk_list = uart_parent_clk;
334         dalmore_loopback_uart_pdata.parent_clk_count =
335                                                 ARRAY_SIZE(uart_parent_clk);
336         dalmore_loopback_uart_pdata.is_loopback = true;
337         tegra_uarta_device.dev.platform_data = &dalmore_uart_pdata;
338         tegra_uartb_device.dev.platform_data = &dalmore_uart_pdata;
339         tegra_uartc_device.dev.platform_data = &dalmore_uart_pdata;
340         tegra_uartd_device.dev.platform_data = &dalmore_uart_pdata;
341
342         /* Register low speed only if it is selected */
343         if (!is_tegra_debug_uartport_hs())
344                 uart_debug_init();
345
346         platform_add_devices(dalmore_uart_devices,
347                                 ARRAY_SIZE(dalmore_uart_devices));
348 }
349
350 static struct resource tegra_rtc_resources[] = {
351         [0] = {
352                 .start = TEGRA_RTC_BASE,
353                 .end = TEGRA_RTC_BASE + TEGRA_RTC_SIZE - 1,
354                 .flags = IORESOURCE_MEM,
355         },
356         [1] = {
357                 .start = INT_RTC,
358                 .end = INT_RTC,
359                 .flags = IORESOURCE_IRQ,
360         },
361 };
362
363 static struct platform_device tegra_rtc_device = {
364         .name = "tegra_rtc",
365         .id   = -1,
366         .resource = tegra_rtc_resources,
367         .num_resources = ARRAY_SIZE(tegra_rtc_resources),
368 };
369
370 static struct tegra_asoc_platform_data dalmore_audio_pdata = {
371         .gpio_spkr_en           = TEGRA_GPIO_SPKR_EN,
372         .gpio_hp_det            = TEGRA_GPIO_HP_DET,
373         .gpio_hp_mute           = -1,
374         .gpio_int_mic_en        = TEGRA_GPIO_INT_MIC_EN,
375         .gpio_ext_mic_en        = TEGRA_GPIO_EXT_MIC_EN,
376         .gpio_ldo1_en           = TEGRA_GPIO_LDO1_EN,
377         .gpio_codec1 = TEGRA_GPIO_CODEC1_EN,
378         .gpio_codec2 = TEGRA_GPIO_CODEC2_EN,
379         .gpio_codec3 = TEGRA_GPIO_CODEC3_EN,
380         .i2s_param[HIFI_CODEC]  = {
381                 .audio_port_id  = 1,
382                 .is_i2s_master  = 1,
383                 .i2s_mode       = TEGRA_DAIFMT_I2S,
384         },
385         .i2s_param[BT_SCO]      = {
386                 .audio_port_id  = 3,
387                 .is_i2s_master  = 1,
388                 .i2s_mode       = TEGRA_DAIFMT_DSP_A,
389         },
390 };
391
392 static struct platform_device dalmore_audio_device = {
393         .name   = "tegra-snd-rt5640",
394         .id     = 0,
395         .dev    = {
396                 .platform_data = &dalmore_audio_pdata,
397         },
398 };
399
400 #ifndef CONFIG_USE_OF
401 static struct platform_device tegra_camera = {
402         .name = "tegra_camera",
403         .id = -1,
404 };
405 #endif
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 #ifndef CONFIG_USE_OF
415         &tegra_camera,
416 #endif
417 #if defined(CONFIG_CRYPTO_DEV_TEGRA_SE)
418         &tegra11_se_device,
419 #endif
420         &tegra_ahub_device,
421         &tegra_dam_device0,
422         &tegra_dam_device1,
423         &tegra_dam_device2,
424         &tegra_i2s_device1,
425         &tegra_i2s_device3,
426         &tegra_i2s_device4,
427         &tegra_spdif_device,
428         &spdif_dit_device,
429         &bluetooth_dit_device,
430         &dalmore_audio_device,
431         &tegra_hda_device,
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         .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 = 2,
456                 .xcvr_lsrslew = 2,
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 = 2,
481                 .xcvr_lsrslew = 2,
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 = 2,
507                 .xcvr_lsrslew = 2,
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 = 0x4,
541         .port_cap = 0x10,
542         .snps_oc_map = 0x1fc,
543         .usb2_oc_map = 0x2f,
544         .ss_port_map = 0x1,
545         .oc_det = 0xb000,
546         .rx_wander = 0xf0,
547         .rx_eq = 0x307000,
548         .cdr_cntl = 0x26000000,
549         .dfe_cntl = 0x002008EE,
550         .otg_pad0_ctl0 = 0xffffffff,
551         .hs_slew = 0x30,
552         .otg_pad0_ctl1 = 0x0,
553         .otg_pad1_ctl0 = 0xffc7ffff,
554         .otg_pad1_ctl1 = 0x7,
555         .bias_pad_ctl0 = 0,
556         .hsic_pad0_ctl0 = 0xffff00ff,
557         .hsic_pad0_ctl1 = 0xffff00ff,
558         .pmc_value = 0xfff0ffff,
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                 /*
569                  * read from usb_calib0 and pass to driver
570                  * set HS_CURR_LEVEL = usb_calib0[5:0]
571                  * set TERM_RANGE_ADJ = usb_calib0[10:7]
572                  * set HS_IREF_CAP = usb_calib0[14:13]
573                  * set HS_SQUELCH_LEVEL = usb_calib0[12:11]
574                  */
575
576                 xusb_padctl_data.hs_curr_level = (usb_calib0 >> 0) & 0x3f;
577                 xusb_padctl_data.hs_iref_cap = (usb_calib0 >> 13) & 0x3;
578                 xusb_padctl_data.hs_term_range_adj = (usb_calib0 >> 7) & 0xf;
579                 xusb_padctl_data.hs_squelch_level = (usb_calib0 >> 11) & 0x3;
580
581                 tegra_xhci_device.dev.platform_data = &xusb_padctl_data;
582                 platform_device_register(&tegra_xhci_device);
583         }
584 }
585
586 static struct gpio modem_gpios[] = { /* Nemo modem */
587         {MODEM_EN, GPIOF_OUT_INIT_HIGH, "MODEM EN"},
588         {MDM_RST, GPIOF_OUT_INIT_LOW, "MODEM RESET"},
589 };
590
591 static struct tegra_usb_platform_data tegra_ehci2_hsic_baseband_pdata = {
592         .port_otg = false,
593         .has_hostpc = true,
594         .unaligned_dma_buf_supported = false,
595         .phy_intf = TEGRA_USB_PHY_INTF_HSIC,
596         .op_mode = TEGRA_USB_OPMODE_HOST,
597         .u_data.host = {
598                 .vbus_gpio = -1,
599                 .hot_plug = false,
600                 .remote_wakeup_supported = true,
601                 .power_off_on_suspend = true,
602         },
603 };
604
605 static int baseband_init(void)
606 {
607         int ret;
608
609         ret = gpio_request_array(modem_gpios, ARRAY_SIZE(modem_gpios));
610         if (ret) {
611                 pr_warn("%s:gpio request failed\n", __func__);
612                 return ret;
613         }
614
615         /* enable pull-down for MDM_COLD_BOOT */
616         tegra_pinmux_set_pullupdown(TEGRA_PINGROUP_KB_COL5,
617                                     TEGRA_PUPD_PULL_DOWN);
618
619         /* export GPIO for user space access through sysfs */
620         gpio_export(MDM_RST, false);
621
622         return 0;
623 }
624
625 static const struct tegra_modem_operations baseband_operations = {
626         .init = baseband_init,
627 };
628
629 static struct tegra_usb_modem_power_platform_data baseband_pdata = {
630         .ops = &baseband_operations,
631         .wake_gpio = -1,
632         .boot_gpio = MDM_COLDBOOT,
633         .boot_irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
634         .autosuspend_delay = 2000,
635         .short_autosuspend_delay = 50,
636         .tegra_ehci_device = &tegra_ehci2_device,
637         .tegra_ehci_pdata = &tegra_ehci2_hsic_baseband_pdata,
638 };
639
640 static struct platform_device icera_nemo_device = {
641         .name = "tegra_usb_modem_power",
642         .id = -1,
643         .dev = {
644                 .platform_data = &baseband_pdata,
645         },
646 };
647
648 static void dalmore_modem_init(void)
649 {
650         int modem_id = tegra_get_modem_id();
651         int usb_port_owner_info = tegra_get_usb_port_owner_info();
652         switch (modem_id) {
653         case TEGRA_BB_NEMO: /* on board i500 HSIC */
654                 if (!(usb_port_owner_info & HSIC1_PORT_OWNER_XUSB))
655                         platform_device_register(&icera_nemo_device);
656                 break;
657         }
658 }
659
660 #else
661 static void dalmore_usb_init(void) { }
662 static void dalmore_modem_init(void) { }
663 static void dalmore_xusb_init(void) { }
664 #endif
665
666 static void dalmore_audio_init(void)
667 {
668         dalmore_audio_pdata.codec_name = "rt5640.0-001c";
669         dalmore_audio_pdata.codec_dai_name = "rt5640-aif1";
670 }
671
672
673 static struct platform_device *dalmore_spi_devices[] __initdata = {
674         &tegra11_spi_device4,
675 };
676
677 struct spi_clk_parent spi_parent_clk_dalmore[] = {
678         [0] = {.name = "pll_p"},
679 #ifndef CONFIG_TEGRA_PLLM_RESTRICTED
680         [1] = {.name = "pll_m"},
681         [2] = {.name = "clk_m"},
682 #else
683         [1] = {.name = "clk_m"},
684 #endif
685 };
686
687 static struct tegra_spi_platform_data dalmore_spi_pdata = {
688         .is_dma_based           = false,
689         .max_dma_buffer         = 16 * 1024,
690         .is_clkon_always        = false,
691         .max_rate               = 25000000,
692 };
693
694 static void __init dalmore_spi_init(void)
695 {
696         int i;
697         struct clk *c;
698
699         for (i = 0; i < ARRAY_SIZE(spi_parent_clk_dalmore); ++i) {
700                 c = tegra_get_clock_by_name(spi_parent_clk_dalmore[i].name);
701                 if (IS_ERR_OR_NULL(c)) {
702                         pr_err("Not able to get the clock for %s\n",
703                                                 spi_parent_clk_dalmore[i].name);
704                         continue;
705                 }
706                 spi_parent_clk_dalmore[i].parent_clk = c;
707                 spi_parent_clk_dalmore[i].fixed_clk_rate = clk_get_rate(c);
708         }
709         dalmore_spi_pdata.parent_clk_list = spi_parent_clk_dalmore;
710         dalmore_spi_pdata.parent_clk_count = ARRAY_SIZE(spi_parent_clk_dalmore);
711         tegra11_spi_device4.dev.platform_data = &dalmore_spi_pdata;
712         platform_add_devices(dalmore_spi_devices,
713                                 ARRAY_SIZE(dalmore_spi_devices));
714 }
715
716 static __initdata struct tegra_clk_init_table touch_clk_init_table[] = {
717         /* name         parent          rate            enabled */
718         { "extern2",    "pll_p",        41000000,       false},
719         { "clk_out_2",  "extern2",      40800000,       false},
720         { NULL,         NULL,           0,              0},
721 };
722
723 struct rm_spi_ts_platform_data rm31080ts_dalmore_data = {
724         .gpio_reset = 0,
725         .config = 0,
726         .platform_id = RM_PLATFORM_D010,
727         .name_of_clock = "clk_out_2",
728 };
729
730 static struct tegra_spi_device_controller_data dev_cdata = {
731         .rx_clk_tap_delay = 0,
732         .tx_clk_tap_delay = 16,
733 };
734
735 struct spi_board_info rm31080a_dalmore_spi_board[1] = {
736         {
737          .modalias = "rm_ts_spidev",
738          .bus_num = 3,
739          .chip_select = 2,
740          .max_speed_hz = 12 * 1000 * 1000,
741          .mode = SPI_MODE_0,
742          .controller_data = &dev_cdata,
743          .platform_data = &rm31080ts_dalmore_data,
744          },
745 };
746
747 static int __init dalmore_touch_init(void)
748 {
749         tegra_clk_init_from_table(touch_clk_init_table);
750         clk_enable(tegra_get_clock_by_name("clk_out_2"));
751         if (display_board_info.board_id == BOARD_E1582)
752                 rm31080ts_dalmore_data.platform_id = RM_PLATFORM_P005;
753         else
754                 rm31080ts_dalmore_data.platform_id = RM_PLATFORM_D010;
755         mdelay(20);
756         rm31080a_dalmore_spi_board[0].irq = gpio_to_irq(TOUCH_GPIO_IRQ_RAYDIUM_SPI);
757         touch_init_raydium(TOUCH_GPIO_IRQ_RAYDIUM_SPI,
758                                 TOUCH_GPIO_RST_RAYDIUM_SPI,
759                                 &rm31080ts_dalmore_data,
760                                 &rm31080a_dalmore_spi_board[0],
761                                 ARRAY_SIZE(rm31080a_dalmore_spi_board));
762         return 0;
763 }
764
765 #ifdef CONFIG_EDP_FRAMEWORK
766 static struct edp_manager battery_edp_manager = {
767         .name = "battery",
768         .max = 9500
769 };
770
771 static void __init dalmore_battery_edp_init(void)
772 {
773         struct edp_governor *g;
774         int r;
775
776         r = edp_register_manager(&battery_edp_manager);
777         if (r)
778                 goto err_ret;
779
780         /* start with priority governor */
781         g = edp_get_governor("priority");
782         if (!g) {
783                 r = -EFAULT;
784                 goto err_ret;
785         }
786
787         r = edp_set_governor(&battery_edp_manager, g);
788         if (r)
789                 goto err_ret;
790
791         return;
792
793 err_ret:
794         pr_err("Battery EDP init failed with error %d\n", r);
795         WARN_ON(1);
796 }
797 #else
798 static inline void dalmore_battery_edp_init(void) {}
799 #endif
800
801 #ifdef CONFIG_USE_OF
802 struct of_dev_auxdata dalmore_auxdata_lookup[] __initdata = {
803         OF_DEV_AUXDATA("nvidia,tegra114-apbdma", 0x6000a000, "tegra-dma", NULL),
804         OF_DEV_AUXDATA("nvidia,tegra114-sdhci", 0x78000600, "sdhci-tegra.3",
805                                 NULL),
806         OF_DEV_AUXDATA("nvidia,tegra114-sdhci", 0x78000400, "sdhci-tegra.2",
807                                 NULL),
808         OF_DEV_AUXDATA("nvidia,tegra114-sdhci", 0x78000000, "sdhci-tegra.0",
809                                 &dalmore_tegra_sdhci_platform_data0),
810         OF_DEV_AUXDATA("nvidia,tegra114-camera", 0x0, "tegra_camera",
811                                 NULL),
812         OF_DEV_AUXDATA("nvidia,tegra114-host1x", TEGRA_HOST1X_BASE, "host1x",
813                                 NULL),
814         OF_DEV_AUXDATA("nvidia,tegra114-gr3d", TEGRA_GR3D_BASE, "gr3d",
815                                 NULL),
816         OF_DEV_AUXDATA("nvidia,tegra114-gr2d", TEGRA_GR2D_BASE, "gr2d",
817                                 NULL),
818         OF_DEV_AUXDATA("nvidia,tegra114-msenc", TEGRA_MSENC_BASE, "msenc",
819                                 NULL),
820         OF_DEV_AUXDATA("nvidia,tegra114-vi", TEGRA_VI_BASE, "vi",
821                                 NULL),
822         OF_DEV_AUXDATA("nvidia,tegra114-isp", TEGRA_ISP_BASE, "isp",
823                                 NULL),
824         OF_DEV_AUXDATA("nvidia,tegra114-tsec", TEGRA_TSEC_BASE, "tsec",
825                                 NULL),
826
827         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c000, "tegra11-i2c.0",
828                                 NULL),
829         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c400, "tegra11-i2c.1",
830                                 NULL),
831         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c500, "tegra11-i2c.2",
832                                 NULL),
833         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c700, "tegra11-i2c.3",
834                                 NULL),
835         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000d000, "tegra11-i2c.4",
836                                 NULL),
837         {}
838 };
839 #endif
840
841 static void __init tegra_dalmore_early_init(void)
842 {
843         dalmore_battery_edp_init();
844         tegra_clk_init_from_table(dalmore_clk_init_table);
845         tegra_clk_vefify_parents();
846         tegra_smmu_init();
847         tegra_soc_device_init("dalmore");
848 }
849
850 static void __init tegra_dalmore_late_init(void)
851 {
852         platform_device_register(&tegra_pinmux_device);
853         dalmore_pinmux_init();
854         dalmore_i2c_init();
855         dalmore_spi_init();
856         dalmore_usb_init();
857         dalmore_xusb_init();
858         dalmore_uart_init();
859         dalmore_audio_init();
860         platform_add_devices(dalmore_devices, ARRAY_SIZE(dalmore_devices));
861         //tegra_ram_console_debug_init();
862         tegra_io_dpd_init();
863         dalmore_regulator_init();
864         dalmore_sdhci_init();
865         dalmore_suspend_init();
866         dalmore_emc_init();
867         dalmore_edp_init();
868         isomgr_init();
869         dalmore_touch_init();
870         if (board_info.board_id == BOARD_E1582)
871                 roth_panel_init();
872         else
873                 dalmore_panel_init();
874         dalmore_kbc_init();
875         dalmore_pmon_init();
876 #if defined(CONFIG_BT_BLUESLEEP) || defined(CONFIG_BT_BLUESLEEP_MODULE)
877         dalmore_setup_bluesleep();
878         dalmore_setup_bt_rfkill();
879 #elif defined CONFIG_BLUEDROID_PM
880         dalmore_setup_bluedroid_pm();
881 #endif
882         tegra_release_bootloader_fb();
883         dalmore_modem_init();
884 #ifdef CONFIG_TEGRA_WDT_RECOVERY
885         tegra_wdt_recovery_init();
886 #endif
887         tegra_serial_debug_init(TEGRA_UARTD_BASE, INT_WDT_CPU, NULL, -1, -1);
888         dalmore_sensors_init();
889         dalmore_soctherm_init();
890         tegra_register_fuse();
891 }
892
893 static void __init dalmore_ramconsole_reserve(unsigned long size)
894 {
895         tegra_ram_console_debug_reserve(SZ_1M);
896 }
897
898 static void __init tegra_dalmore_dt_init(void)
899 {
900         tegra_get_board_info(&board_info);
901         tegra_get_display_board_info(&display_board_info);
902
903         tegra_dalmore_early_init();
904
905         of_platform_populate(NULL,
906                 of_default_bus_match_table, dalmore_auxdata_lookup,
907                 &platform_bus);
908
909         tegra_dalmore_late_init();
910 }
911
912 static void __init tegra_dalmore_reserve(void)
913 {
914 #if defined(CONFIG_NVMAP_CONVERT_CARVEOUT_TO_IOVMM)
915         /* 1920*1200*4*2 = 18432000 bytes */
916         tegra_reserve(0, SZ_16M + SZ_2M, SZ_16M);
917 #else
918         tegra_reserve(SZ_128M, SZ_16M + SZ_2M, SZ_4M);
919 #endif
920         dalmore_ramconsole_reserve(SZ_1M);
921 }
922
923 static const char * const dalmore_dt_board_compat[] = {
924         "nvidia,dalmore",
925         NULL
926 };
927
928 MACHINE_START(DALMORE, "dalmore")
929         .atag_offset    = 0x100,
930         .smp            = smp_ops(tegra_smp_ops),
931         .map_io         = tegra_map_common_io,
932         .reserve        = tegra_dalmore_reserve,
933         .init_early     = tegra11x_init_early,
934         .init_irq       = tegra_dt_init_irq,
935         .handle_irq     = gic_handle_irq,
936         .timer          = &tegra_timer,
937         .init_machine   = tegra_dalmore_dt_init,
938         .restart        = tegra_assert_system_reset,
939         .dt_compat      = dalmore_dt_board_compat,
940 MACHINE_END