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