455f3150d8e7ec63a2fe53a35d267719f6804241
[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/platform_data/serial-tegra.h>
37 #include <linux/memblock.h>
38 #include <linux/spi/spi-tegra.h>
39 #include <linux/nfc/pn544.h>
40 #include <linux/rfkill-gpio.h>
41 #include <linux/skbuff.h>
42 #include <linux/ti_wilink_st.h>
43 #include <linux/regulator/consumer.h>
44 #include <linux/smb349-charger.h>
45 #include <linux/max17048_battery.h>
46 #include <linux/leds.h>
47 #include <linux/i2c/at24.h>
48 #include <linux/of_platform.h>
49 #include <linux/edp.h>
50 #include <linux/usb/tegra_usb_phy.h>
51 #include <linux/clk/tegra.h>
52 #include <linux/clocksource.h>
53 #include <linux/irqchip.h>
54 #include <linux/irqchip/tegra.h>
55 #include <linux/tegra_fiq_debugger.h>
56 #include <linux/platform_data/tegra_usb_modem_power.h>
57
58 #include <mach/irqs.h>
59 #include <mach/pinmux.h>
60 #include <mach/pinmux-t11.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/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 "iomap.h"
78 #include "pm.h"
79 #include "common.h"
80 #include "tegra-board-id.h"
81 #include "tegra-of-dev-auxdata.h"
82
83 static struct board_info board_info, display_board_info;
84
85 #if defined(CONFIG_BT_BLUESLEEP) || defined(CONFIG_BT_BLUESLEEP_MODULE)
86 static struct rfkill_gpio_platform_data dalmore_bt_rfkill_pdata = {
87                 .name           = "bt_rfkill",
88                 .shutdown_gpio  = TEGRA_GPIO_PQ7,
89                 .reset_gpio     = TEGRA_GPIO_PQ6,
90                 .type           = RFKILL_TYPE_BLUETOOTH,
91 };
92
93 static struct platform_device dalmore_bt_rfkill_device = {
94         .name = "rfkill_gpio",
95         .id             = -1,
96         .dev = {
97                 .platform_data = &dalmore_bt_rfkill_pdata,
98         },
99 };
100
101 static struct resource dalmore_bluesleep_resources[] = {
102         [0] = {
103                 .name = "gpio_host_wake",
104                         .start  = TEGRA_GPIO_PU6,
105                         .end    = TEGRA_GPIO_PU6,
106                         .flags  = IORESOURCE_IO,
107         },
108         [1] = {
109                 .name = "gpio_ext_wake",
110                         .start  = TEGRA_GPIO_PEE1,
111                         .end    = TEGRA_GPIO_PEE1,
112                         .flags  = IORESOURCE_IO,
113         },
114         [2] = {
115                 .name = "host_wake",
116                         .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
117         },
118 };
119
120 static struct platform_device dalmore_bluesleep_device = {
121         .name           = "bluesleep",
122         .id             = -1,
123         .num_resources  = ARRAY_SIZE(dalmore_bluesleep_resources),
124         .resource       = dalmore_bluesleep_resources,
125 };
126
127 static noinline void __init dalmore_setup_bt_rfkill(void)
128 {
129         platform_device_register(&dalmore_bt_rfkill_device);
130 }
131
132 static noinline void __init dalmore_setup_bluesleep(void)
133 {
134         dalmore_bluesleep_resources[2].start =
135                 dalmore_bluesleep_resources[2].end =
136                         gpio_to_irq(TEGRA_GPIO_PU6);
137         platform_device_register(&dalmore_bluesleep_device);
138         return;
139 }
140 #elif defined(CONFIG_BLUEDROID_PM) || defined(CONFIG_BLUEDROID_PM_MODULE)
141 static struct resource dalmore_bluedroid_pm_resources[] = {
142         [0] = {
143                 .name   = "shutdown_gpio",
144                 .start  = TEGRA_GPIO_PQ7,
145                 .end    = TEGRA_GPIO_PQ7,
146                 .flags  = IORESOURCE_IO,
147         },
148         [1] = {
149                 .name = "host_wake",
150                 .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
151         },
152         [2] = {
153                 .name = "gpio_ext_wake",
154                 .start  = TEGRA_GPIO_PEE1,
155                 .end    = TEGRA_GPIO_PEE1,
156                 .flags  = IORESOURCE_IO,
157         },
158         [3] = {
159                 .name = "gpio_host_wake",
160                 .start  = TEGRA_GPIO_PU6,
161                 .end    = TEGRA_GPIO_PU6,
162                 .flags  = IORESOURCE_IO,
163         },
164         [4] = {
165                 .name = "reset_gpio",
166                 .start  = TEGRA_GPIO_PQ6,
167                 .end    = TEGRA_GPIO_PQ6,
168                 .flags  = IORESOURCE_IO,
169         },
170 };
171
172 static struct platform_device dalmore_bluedroid_pm_device = {
173         .name = "bluedroid_pm",
174         .id             = 0,
175         .num_resources  = ARRAY_SIZE(dalmore_bluedroid_pm_resources),
176         .resource       = dalmore_bluedroid_pm_resources,
177 };
178
179 static noinline void __init dalmore_setup_bluedroid_pm(void)
180 {
181         dalmore_bluedroid_pm_resources[1].start =
182                 dalmore_bluedroid_pm_resources[1].end =
183                                 gpio_to_irq(TEGRA_GPIO_PU6);
184         platform_device_register(&dalmore_bluedroid_pm_device);
185 }
186 #endif
187
188 static __initdata struct tegra_clk_init_table dalmore_clk_init_table[] = {
189         /* name         parent          rate            enabled */
190         { "pll_m",      NULL,           0,              false},
191         { "hda",        "pll_p",        108000000,      false},
192         { "hda2codec_2x", "pll_p",      48000000,       false},
193         { "pwm",        "pll_p",        3187500,        false},
194         { "blink",      "clk_32k",      32768,          true},
195         { "i2s1",       "pll_a_out0",   0,              false},
196         { "i2s3",       "pll_a_out0",   0,              false},
197         { "i2s4",       "pll_a_out0",   0,              false},
198         { "spdif_out",  "pll_a_out0",   0,              false},
199         { "d_audio",    "clk_m",        12000000,       false},
200         { "dam0",       "clk_m",        12000000,       false},
201         { "dam1",       "clk_m",        12000000,       false},
202         { "dam2",       "clk_m",        12000000,       false},
203         { "audio1",     "i2s1_sync",    0,              false},
204         { "audio3",     "i2s3_sync",    0,              false},
205         /* Setting vi_sensor-clk to true for validation purpose, will imapact
206          * power, later set to be false.*/
207         { "vi_sensor",  "pll_p",        150000000,      false},
208         { "cilab",      "pll_p",        150000000,      false},
209         { "cilcd",      "pll_p",        150000000,      false},
210         { "cile",       "pll_p",        150000000,      false},
211         { "i2c1",       "pll_p",        3200000,        false},
212         { "i2c2",       "pll_p",        3200000,        false},
213         { "i2c3",       "pll_p",        3200000,        false},
214         { "i2c4",       "pll_p",        3200000,        false},
215         { "i2c5",       "pll_p",        3200000,        false},
216         { "sbc1",       "pll_p",        25000000,       false},
217         { "sbc2",       "pll_p",        25000000,       false},
218         { "sbc3",       "pll_p",        25000000,       false},
219         { "sbc4",       "pll_p",        25000000,       false},
220         { "sbc5",       "pll_p",        25000000,       false},
221         { "sbc6",       "pll_p",        25000000,       false},
222         { "uarta",      "pll_p",        408000000,      false},
223         { "uartb",      "pll_p",        408000000,      false},
224         { "uartc",      "pll_p",        408000000,      false},
225         { "uartd",      "pll_p",        408000000,      false},
226         { NULL,         NULL,           0,              0},
227 };
228
229 #ifndef CONFIG_USE_OF
230 static struct tegra_i2c_platform_data dalmore_i2c1_platform_data = {
231         .bus_clk_rate   = 100000,
232         .scl_gpio       = TEGRA_GPIO_I2C1_SCL,
233         .sda_gpio       = TEGRA_GPIO_I2C1_SDA,
234 };
235
236 static struct tegra_i2c_platform_data dalmore_i2c2_platform_data = {
237         .bus_clk_rate   = 100000,
238         .is_clkon_always = true,
239         .scl_gpio       = TEGRA_GPIO_I2C2_SCL,
240         .sda_gpio       = TEGRA_GPIO_I2C2_SDA,
241 };
242
243 static struct tegra_i2c_platform_data dalmore_i2c3_platform_data = {
244         .bus_clk_rate   = 400000,
245         .scl_gpio       = TEGRA_GPIO_I2C3_SCL,
246         .sda_gpio       = TEGRA_GPIO_I2C3_SDA,
247 };
248
249 static struct tegra_i2c_platform_data dalmore_i2c4_platform_data = {
250         .bus_clk_rate   = 10000,
251         .scl_gpio       = TEGRA_GPIO_I2C4_SCL,
252         .sda_gpio       = TEGRA_GPIO_I2C4_SDA,
253 };
254
255 static struct tegra_i2c_platform_data dalmore_i2c5_platform_data = {
256         .bus_clk_rate   = 400000,
257         .scl_gpio       = TEGRA_GPIO_I2C5_SCL,
258         .sda_gpio       = TEGRA_GPIO_I2C5_SDA,
259         .needs_cl_dvfs_clock = true,
260 };
261 #endif
262
263 static struct i2c_board_info __initdata rt5640_board_info = {
264         I2C_BOARD_INFO("rt5640", 0x1c),
265 };
266
267 static struct pn544_i2c_platform_data nfc_pdata = {
268         .irq_gpio = TEGRA_GPIO_PW2,
269         .ven_gpio = TEGRA_GPIO_PQ3,
270         .firm_gpio = TEGRA_GPIO_PH0,
271 };
272
273 static struct i2c_board_info __initdata nfc_board_info = {
274         I2C_BOARD_INFO("pn544", 0x28),
275         .platform_data = &nfc_pdata,
276 };
277
278 static void dalmore_i2c_init(void)
279 {
280 #ifndef CONFIG_USE_OF
281         tegra11_i2c_device1.dev.platform_data = &dalmore_i2c1_platform_data;
282         tegra11_i2c_device2.dev.platform_data = &dalmore_i2c2_platform_data;
283         tegra11_i2c_device3.dev.platform_data = &dalmore_i2c3_platform_data;
284         tegra11_i2c_device4.dev.platform_data = &dalmore_i2c4_platform_data;
285         tegra11_i2c_device5.dev.platform_data = &dalmore_i2c5_platform_data;
286
287         platform_device_register(&tegra11_i2c_device5);
288         platform_device_register(&tegra11_i2c_device4);
289         platform_device_register(&tegra11_i2c_device3);
290         platform_device_register(&tegra11_i2c_device2);
291         platform_device_register(&tegra11_i2c_device1);
292 #endif
293         nfc_board_info.irq = gpio_to_irq(TEGRA_GPIO_PW2);
294         i2c_register_board_info(0, &nfc_board_info, 1);
295         i2c_register_board_info(0, &rt5640_board_info, 1);
296 }
297
298 static struct tegra_serial_platform_data dalmore_uartd_pdata = {
299         .dma_req_selector = 19,
300         .modem_interrupt = false,
301 };
302
303 static void __init dalmore_uart_init(void)
304 {
305         int debug_port_id;
306
307         /* Register low speed only if it is selected */
308         if (!is_tegra_debug_uartport_hs()) {
309                 debug_port_id = uart_console_debug_init(3);
310                 if (debug_port_id < 0)
311                         return;
312
313                 platform_device_register(uart_console_debug_device);
314
315         } else {
316                 tegra_uartd_device.dev.platform_data = &dalmore_uartd_pdata;
317                 platform_device_register(&tegra_uartd_device);
318         }
319
320 }
321
322 static struct resource tegra_rtc_resources[] = {
323         [0] = {
324                 .start = TEGRA_RTC_BASE,
325                 .end = TEGRA_RTC_BASE + TEGRA_RTC_SIZE - 1,
326                 .flags = IORESOURCE_MEM,
327         },
328         [1] = {
329                 .start = INT_RTC,
330                 .end = INT_RTC,
331                 .flags = IORESOURCE_IRQ,
332         },
333 };
334
335 static struct platform_device tegra_rtc_device = {
336         .name = "tegra_rtc",
337         .id   = -1,
338         .resource = tegra_rtc_resources,
339         .num_resources = ARRAY_SIZE(tegra_rtc_resources),
340 };
341
342 static struct tegra_asoc_platform_data dalmore_audio_pdata = {
343         .gpio_spkr_en           = TEGRA_GPIO_SPKR_EN,
344         .gpio_hp_det            = TEGRA_GPIO_HP_DET,
345         .gpio_hp_mute           = -1,
346         .gpio_int_mic_en        = TEGRA_GPIO_INT_MIC_EN,
347         .gpio_ext_mic_en        = TEGRA_GPIO_EXT_MIC_EN,
348         .gpio_ldo1_en           = TEGRA_GPIO_LDO1_EN,
349         .gpio_codec1 = TEGRA_GPIO_CODEC1_EN,
350         .gpio_codec2 = TEGRA_GPIO_CODEC2_EN,
351         .gpio_codec3 = TEGRA_GPIO_CODEC3_EN,
352         .i2s_param[HIFI_CODEC]  = {
353                 .audio_port_id  = 1,
354                 .is_i2s_master  = 1,
355                 .i2s_mode       = TEGRA_DAIFMT_I2S,
356         },
357         .i2s_param[BT_SCO]      = {
358                 .audio_port_id  = 3,
359                 .is_i2s_master  = 1,
360                 .i2s_mode       = TEGRA_DAIFMT_DSP_A,
361         },
362 };
363
364 static struct platform_device dalmore_audio_device = {
365         .name   = "tegra-snd-rt5640",
366         .id     = 0,
367         .dev    = {
368                 .platform_data = &dalmore_audio_pdata,
369         },
370 };
371
372 static struct platform_device *dalmore_devices[] __initdata = {
373         &tegra_pmu_device,
374         &tegra_rtc_device,
375         &tegra_udc_device,
376 #if defined(CONFIG_TEGRA_AVP)
377         &tegra_avp_device,
378 #endif
379 #if defined(CONFIG_CRYPTO_DEV_TEGRA_SE)
380         &tegra11_se_device,
381 #endif
382         &tegra_ahub_device,
383         &tegra_dam_device0,
384         &tegra_dam_device1,
385         &tegra_dam_device2,
386         &tegra_i2s_device1,
387         &tegra_i2s_device3,
388         &tegra_i2s_device4,
389         &tegra_spdif_device,
390         &spdif_dit_device,
391         &bluetooth_dit_device,
392         &tegra_pcm_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_pdata.is_xhci = false;
495                 tegra_udc_pdata.u_data.dev.is_xhci = false;
496         } else {
497                 tegra_otg_pdata.is_xhci = true;
498                 tegra_udc_pdata.u_data.dev.is_xhci = true;
499         }
500         tegra_otg_device.dev.platform_data = &tegra_otg_pdata;
501         platform_device_register(&tegra_otg_device);
502         /* Setup the udc platform data */
503         tegra_udc_device.dev.platform_data = &tegra_udc_pdata;
504
505         if (!(usb_port_owner_info & UTMI2_PORT_OWNER_XUSB)) {
506                 tegra_ehci3_device.dev.platform_data = &tegra_ehci3_utmi_pdata;
507                 platform_device_register(&tegra_ehci3_device);
508         }
509 }
510
511 static struct tegra_xusb_platform_data xusb_pdata = {
512         .portmap = TEGRA_XUSB_SS_P0 | TEGRA_XUSB_USB2_P1 |
513                         TEGRA_XUSB_USB2_P0,
514 };
515
516 static void dalmore_xusb_init(void)
517 {
518         int usb_port_owner_info = tegra_get_usb_port_owner_info();
519
520         if (!(usb_port_owner_info & UTMI1_PORT_OWNER_XUSB))
521                 xusb_pdata.portmap &= ~TEGRA_XUSB_USB2_P0;
522         if (!(usb_port_owner_info & UTMI2_PORT_OWNER_XUSB))
523                 xusb_pdata.portmap &= ~(TEGRA_XUSB_USB2_P1 | TEGRA_XUSB_SS_P0);
524 }
525
526 static struct gpio modem_gpios[] = { /* Nemo modem */
527         {MODEM_EN, GPIOF_OUT_INIT_HIGH, "MODEM EN"},
528         {MDM_RST, GPIOF_OUT_INIT_LOW, "MODEM RESET"},
529 };
530
531 static struct tegra_usb_platform_data tegra_ehci2_hsic_baseband_pdata = {
532         .port_otg = false,
533         .has_hostpc = true,
534         .unaligned_dma_buf_supported = false,
535         .phy_intf = TEGRA_USB_PHY_INTF_HSIC,
536         .op_mode = TEGRA_USB_OPMODE_HOST,
537         .u_data.host = {
538                 .vbus_gpio = -1,
539                 .hot_plug = false,
540                 .remote_wakeup_supported = true,
541                 .power_off_on_suspend = true,
542         },
543 };
544
545 static int baseband_init(void)
546 {
547         int ret;
548
549         ret = gpio_request_array(modem_gpios, ARRAY_SIZE(modem_gpios));
550         if (ret) {
551                 pr_warn("%s:gpio request failed\n", __func__);
552                 return ret;
553         }
554
555         /* enable pull-down for MDM_COLD_BOOT */
556         tegra_pinmux_set_pullupdown(TEGRA_PINGROUP_KB_COL5,
557                                     TEGRA_PUPD_PULL_DOWN);
558
559         /* export GPIO for user space access through sysfs */
560         gpio_export(MDM_RST, false);
561
562         return 0;
563 }
564
565 static const struct tegra_modem_operations baseband_operations = {
566         .init = baseband_init,
567 };
568
569 static struct tegra_usb_modem_power_platform_data baseband_pdata = {
570         .ops = &baseband_operations,
571         .regulator_name = "vdd_modem_3v3",
572         .wake_gpio = -1,
573         .boot_gpio = MDM_COLDBOOT,
574         .boot_irq_flags = IRQF_TRIGGER_RISING |
575                                     IRQF_TRIGGER_FALLING |
576                                     IRQF_ONESHOT,
577         .autosuspend_delay = 2000,
578         .short_autosuspend_delay = 50,
579         .tegra_ehci_device = &tegra_ehci2_device,
580         .tegra_ehci_pdata = &tegra_ehci2_hsic_baseband_pdata,
581 };
582
583 static struct platform_device icera_nemo_device = {
584         .name = "tegra_usb_modem_power",
585         .id = -1,
586         .dev = {
587                 .platform_data = &baseband_pdata,
588         },
589 };
590
591 static void dalmore_modem_init(void)
592 {
593         int modem_id = tegra_get_modem_id();
594         int usb_port_owner_info = tegra_get_usb_port_owner_info();
595         switch (modem_id) {
596         case TEGRA_BB_NEMO: /* on board i500 HSIC */
597                 if (!(usb_port_owner_info & HSIC1_PORT_OWNER_XUSB)) {
598                         platform_device_register(&icera_nemo_device);
599                 }
600                 break;
601         }
602 }
603
604 #else
605 static void dalmore_usb_init(void) { }
606 static void dalmore_modem_init(void) { }
607 static void dalmore_xusb_init(void) { }
608 #endif
609
610 static void dalmore_audio_init(void)
611 {
612         dalmore_audio_pdata.codec_name = "rt5640.0-001c";
613         dalmore_audio_pdata.codec_dai_name = "rt5640-aif1";
614 }
615
616 static __initdata struct tegra_clk_init_table touch_clk_init_table[] = {
617         /* name         parent          rate            enabled */
618         { "extern2",    "pll_p",        41000000,       false},
619         { "clk_out_2",  "extern2",      40800000,       false},
620         { NULL,         NULL,           0,              0},
621 };
622
623 struct rm_spi_ts_platform_data rm31080ts_dalmore_data = {
624         .gpio_reset = TOUCH_GPIO_RST_RAYDIUM_SPI,
625         .config = 0,
626         .platform_id = RM_PLATFORM_D010,
627         .name_of_clock = "clk_out_2",
628         .name_of_clock_con = "extern2",
629 };
630
631 static struct tegra_spi_device_controller_data dev_cdata = {
632         .rx_clk_tap_delay = 16,
633         .tx_clk_tap_delay = 16,
634 };
635
636 struct spi_board_info rm31080a_dalmore_spi_board[1] = {
637         {
638          .modalias = "rm_ts_spidev",
639          .bus_num = 3,
640          .chip_select = 2,
641          .max_speed_hz = 12 * 1000 * 1000,
642          .mode = SPI_MODE_0,
643          .controller_data = &dev_cdata,
644          .platform_data = &rm31080ts_dalmore_data,
645          },
646 };
647
648 static int __init dalmore_touch_init(void)
649 {
650         tegra_clk_init_from_table(touch_clk_init_table);
651         if (display_board_info.board_id == BOARD_E1582)
652                 rm31080ts_dalmore_data.platform_id = RM_PLATFORM_P005;
653         else
654                 rm31080ts_dalmore_data.platform_id = RM_PLATFORM_D010;
655         mdelay(20);
656         rm31080a_dalmore_spi_board[0].irq = gpio_to_irq(TOUCH_GPIO_IRQ_RAYDIUM_SPI);
657         touch_init_raydium(TOUCH_GPIO_IRQ_RAYDIUM_SPI,
658                                 TOUCH_GPIO_RST_RAYDIUM_SPI,
659                                 &rm31080ts_dalmore_data,
660                                 &rm31080a_dalmore_spi_board[0],
661                                 ARRAY_SIZE(rm31080a_dalmore_spi_board));
662         return 0;
663 }
664
665 #ifdef CONFIG_USE_OF
666 struct of_dev_auxdata dalmore_auxdata_lookup[] __initdata = {
667         OF_DEV_AUXDATA("nvidia,tegra114-sdhci", 0x78000600, "sdhci-tegra.3",
668                                 NULL),
669         OF_DEV_AUXDATA("nvidia,tegra114-sdhci", 0x78000400, "sdhci-tegra.2",
670                                 NULL),
671         OF_DEV_AUXDATA("nvidia,tegra114-sdhci", 0x78000000, "sdhci-tegra.0",
672                                 &dalmore_tegra_sdhci_platform_data0),
673         OF_DEV_AUXDATA("nvidia,tegra114-camera", 0x0, "tegra_camera",
674                                 NULL),
675         OF_DEV_AUXDATA("nvidia,tegra114-host1x", TEGRA_HOST1X_BASE, "host1x",
676                                 NULL),
677         OF_DEV_AUXDATA("nvidia,tegra114-gr3d", TEGRA_GR3D_BASE, "gr3d",
678                                 NULL),
679         OF_DEV_AUXDATA("nvidia,tegra114-gr2d", TEGRA_GR2D_BASE, "gr2d",
680                                 NULL),
681         OF_DEV_AUXDATA("nvidia,tegra114-msenc", TEGRA_MSENC_BASE, "msenc",
682                                 NULL),
683         OF_DEV_AUXDATA("nvidia,tegra114-vi", TEGRA_VI_BASE, "vi",
684                                 NULL),
685         OF_DEV_AUXDATA("nvidia,tegra114-isp", TEGRA_ISP_BASE, "isp",
686                                 NULL),
687         OF_DEV_AUXDATA("nvidia,tegra114-tsec", TEGRA_TSEC_BASE, "tsec",
688                                 NULL),
689
690         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c000, "tegra11-i2c.0",
691                                 NULL),
692         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c400, "tegra11-i2c.1",
693                                 NULL),
694         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c500, "tegra11-i2c.2",
695                                 NULL),
696         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c700, "tegra11-i2c.3",
697                                 NULL),
698         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000d000, "tegra11-i2c.4",
699                                 NULL),
700         T114_SPI_OF_DEV_AUXDATA,
701         OF_DEV_AUXDATA("nvidia,tegra114-apbdma", 0x6000a000, "tegra-apbdma",
702                                 NULL),
703         OF_DEV_AUXDATA("nvidia,tegra114-hsuart", 0x70006000, "serial-tegra.0",
704                                 NULL),
705         OF_DEV_AUXDATA("nvidia,tegra114-hsuart", 0x70006040, "serial-tegra.1",
706                                 NULL),
707         OF_DEV_AUXDATA("nvidia,tegra114-hsuart", 0x70006200, "serial-tegra.2",
708                                 NULL),
709         OF_DEV_AUXDATA("nvidia,tegra114-xhci", 0x70090000, "tegra-xhci",
710                                 &xusb_pdata),
711         {}
712 };
713 #endif
714
715 static void __init tegra_dalmore_early_init(void)
716 {
717         tegra_clk_init_from_table(dalmore_clk_init_table);
718         tegra_clk_verify_parents();
719         tegra_soc_device_init("dalmore");
720 }
721
722 static void __init tegra_dalmore_late_init(void)
723 {
724         platform_device_register(&tegra114_pinctrl_device);
725         dalmore_pinmux_init();
726         dalmore_i2c_init();
727         dalmore_usb_init();
728         dalmore_xusb_init();
729         dalmore_uart_init();
730         dalmore_audio_init();
731         platform_add_devices(dalmore_devices, ARRAY_SIZE(dalmore_devices));
732         //tegra_ram_console_debug_init();
733         tegra_io_dpd_init();
734         dalmore_regulator_init();
735         dalmore_sdhci_init();
736         dalmore_suspend_init();
737         dalmore_emc_init();
738         dalmore_edp_init();
739         isomgr_init();
740         dalmore_touch_init();
741         if (board_info.board_id == BOARD_E1582)
742                 roth_panel_init(board_info.board_id);
743         else
744                 dalmore_panel_init();
745         dalmore_kbc_init();
746         dalmore_pmon_init();
747 #if defined(CONFIG_BT_BLUESLEEP) || defined(CONFIG_BT_BLUESLEEP_MODULE)
748         dalmore_setup_bluesleep();
749         dalmore_setup_bt_rfkill();
750 #elif defined(CONFIG_BLUEDROID_PM) || defined(CONFIG_BLUEDROID_PM_MODULE)
751         dalmore_setup_bluedroid_pm();
752 #endif
753         dalmore_modem_init();
754 #ifdef CONFIG_TEGRA_WDT_RECOVERY
755         tegra_wdt_recovery_init();
756 #endif
757         tegra_serial_debug_init(TEGRA_UARTD_BASE, INT_WDT_CPU, NULL, -1, -1);
758         dalmore_sensors_init();
759         dalmore_soctherm_init();
760         tegra_register_fuse();
761 }
762
763 static void __init dalmore_ramconsole_reserve(unsigned long size)
764 {
765         tegra_ram_console_debug_reserve(SZ_1M);
766 }
767
768 static void __init tegra_dalmore_dt_init(void)
769 {
770         tegra_get_board_info(&board_info);
771         tegra_get_display_board_info(&display_board_info);
772
773         tegra_dalmore_early_init();
774
775         of_platform_populate(NULL,
776                 of_default_bus_match_table, dalmore_auxdata_lookup,
777                 &platform_bus);
778
779         tegra_dalmore_late_init();
780 }
781
782 static void __init tegra_dalmore_reserve(void)
783 {
784 #if defined(CONFIG_NVMAP_CONVERT_CARVEOUT_TO_IOVMM)
785         /* 1920*1200*4*2 = 18432000 bytes */
786         tegra_reserve(0, SZ_16M + SZ_2M, SZ_16M);
787 #else
788         tegra_reserve(SZ_512M, SZ_16M + SZ_2M, SZ_4M);
789 #endif
790         dalmore_ramconsole_reserve(SZ_1M);
791 }
792
793 static const char * const dalmore_dt_board_compat[] = {
794         "nvidia,dalmore",
795         NULL
796 };
797
798 MACHINE_START(DALMORE, "dalmore")
799         .atag_offset    = 0x100,
800         .smp            = smp_ops(tegra_smp_ops),
801         .map_io         = tegra_map_common_io,
802         .reserve        = tegra_dalmore_reserve,
803         .init_early     = tegra11x_init_early,
804         .init_irq       = irqchip_init,
805         .init_time      = clocksource_of_init,
806         .init_machine   = tegra_dalmore_dt_init,
807         .restart        = tegra_assert_system_reset,
808         .dt_compat      = dalmore_dt_board_compat,
809         .init_late      = tegra_init_late,
810 MACHINE_END