aae3b0445c3d281605e28259c56c5f9b8150586e
[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
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 "common.h"
81 #include "tegra-board-id.h"
82
83 static struct board_info board_info, display_board_info;
84
85 #if defined(CONFIG_BT_BLUESLEEP) || defined(CONFIG_BT_BLUESLEEP_MODULE)
86 static struct rfkill_gpio_platform_data dalmore_bt_rfkill_pdata = {
87                 .name           = "bt_rfkill",
88                 .shutdown_gpio  = TEGRA_GPIO_PQ7,
89                 .reset_gpio     = TEGRA_GPIO_PQ6,
90                 .type           = RFKILL_TYPE_BLUETOOTH,
91 };
92
93 static struct platform_device dalmore_bt_rfkill_device = {
94         .name = "rfkill_gpio",
95         .id             = -1,
96         .dev = {
97                 .platform_data = &dalmore_bt_rfkill_pdata,
98         },
99 };
100
101 static struct resource dalmore_bluesleep_resources[] = {
102         [0] = {
103                 .name = "gpio_host_wake",
104                         .start  = TEGRA_GPIO_PU6,
105                         .end    = TEGRA_GPIO_PU6,
106                         .flags  = IORESOURCE_IO,
107         },
108         [1] = {
109                 .name = "gpio_ext_wake",
110                         .start  = TEGRA_GPIO_PEE1,
111                         .end    = TEGRA_GPIO_PEE1,
112                         .flags  = IORESOURCE_IO,
113         },
114         [2] = {
115                 .name = "host_wake",
116                         .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
117         },
118 };
119
120 static struct platform_device dalmore_bluesleep_device = {
121         .name           = "bluesleep",
122         .id             = -1,
123         .num_resources  = ARRAY_SIZE(dalmore_bluesleep_resources),
124         .resource       = dalmore_bluesleep_resources,
125 };
126
127 static noinline void __init dalmore_setup_bt_rfkill(void)
128 {
129         platform_device_register(&dalmore_bt_rfkill_device);
130 }
131
132 static noinline void __init dalmore_setup_bluesleep(void)
133 {
134         dalmore_bluesleep_resources[2].start =
135                 dalmore_bluesleep_resources[2].end =
136                         gpio_to_irq(TEGRA_GPIO_PU6);
137         platform_device_register(&dalmore_bluesleep_device);
138         return;
139 }
140 #elif defined(CONFIG_BLUEDROID_PM) || 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_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         .uses_external_pmic = false,
511         .supply = {
512                 .utmi_vbuses = {
513                         NULL, "usb_vbus", NULL
514                 },
515                 .s3p3v = "hvdd_usb",
516                 .s1p8v = "avdd_usb_pll",
517                 .vddio_hsic = "vddio_hsic",
518                 .s1p05v = "avddio_usb",
519         },
520 };
521
522 static void dalmore_xusb_init(void)
523 {
524         int usb_port_owner_info = tegra_get_usb_port_owner_info();
525
526         if (usb_port_owner_info & UTMI2_PORT_OWNER_XUSB)
527                 tegra_xusb_init(&xusb_bdata);
528 }
529
530 static struct gpio modem_gpios[] = { /* Nemo modem */
531         {MODEM_EN, GPIOF_OUT_INIT_HIGH, "MODEM EN"},
532         {MDM_RST, GPIOF_OUT_INIT_LOW, "MODEM RESET"},
533 };
534
535 static struct tegra_usb_platform_data tegra_ehci2_hsic_baseband_pdata = {
536         .port_otg = false,
537         .has_hostpc = true,
538         .unaligned_dma_buf_supported = false,
539         .phy_intf = TEGRA_USB_PHY_INTF_HSIC,
540         .op_mode = TEGRA_USB_OPMODE_HOST,
541         .u_data.host = {
542                 .vbus_gpio = -1,
543                 .hot_plug = false,
544                 .remote_wakeup_supported = true,
545                 .power_off_on_suspend = true,
546         },
547 };
548
549 static int baseband_init(void)
550 {
551         int ret;
552
553         ret = gpio_request_array(modem_gpios, ARRAY_SIZE(modem_gpios));
554         if (ret) {
555                 pr_warn("%s:gpio request failed\n", __func__);
556                 return ret;
557         }
558
559         /* enable pull-down for MDM_COLD_BOOT */
560         tegra_pinmux_set_pullupdown(TEGRA_PINGROUP_KB_COL5,
561                                     TEGRA_PUPD_PULL_DOWN);
562
563         /* export GPIO for user space access through sysfs */
564         gpio_export(MDM_RST, false);
565
566         return 0;
567 }
568
569 static const struct tegra_modem_operations baseband_operations = {
570         .init = baseband_init,
571 };
572
573 static struct tegra_usb_modem_power_platform_data baseband_pdata = {
574         .ops = &baseband_operations,
575         .regulator_name = "vdd_modem_3v3",
576         .wake_gpio = -1,
577         .boot_gpio = MDM_COLDBOOT,
578         .boot_irq_flags = IRQF_TRIGGER_RISING |
579                                     IRQF_TRIGGER_FALLING |
580                                     IRQF_ONESHOT,
581         .autosuspend_delay = 2000,
582         .short_autosuspend_delay = 50,
583         .tegra_ehci_device = &tegra_ehci2_device,
584         .tegra_ehci_pdata = &tegra_ehci2_hsic_baseband_pdata,
585 };
586
587 static struct platform_device icera_nemo_device = {
588         .name = "tegra_usb_modem_power",
589         .id = -1,
590         .dev = {
591                 .platform_data = &baseband_pdata,
592         },
593 };
594
595 static void dalmore_modem_init(void)
596 {
597         int modem_id = tegra_get_modem_id();
598         int usb_port_owner_info = tegra_get_usb_port_owner_info();
599         switch (modem_id) {
600         case TEGRA_BB_NEMO: /* on board i500 HSIC */
601                 if (!(usb_port_owner_info & HSIC1_PORT_OWNER_XUSB)) {
602                         platform_device_register(&icera_nemo_device);
603                 }
604                 break;
605         }
606 }
607
608 #else
609 static void dalmore_usb_init(void) { }
610 static void dalmore_modem_init(void) { }
611 static void dalmore_xusb_init(void) { }
612 #endif
613
614 static void dalmore_audio_init(void)
615 {
616         dalmore_audio_pdata.codec_name = "rt5640.0-001c";
617         dalmore_audio_pdata.codec_dai_name = "rt5640-aif1";
618 }
619
620 #ifndef CONFIG_USE_OF
621 static struct platform_device *dalmore_spi_devices[] __initdata = {
622         &tegra11_spi_device4,
623 };
624
625 static struct tegra_spi_platform_data dalmore_spi_pdata = {
626         .dma_req_sel            = 0,
627         .spi_max_frequency      = 25000000,
628         .clock_always_on        = false,
629 };
630
631 static void __init dalmore_spi_init(void)
632 {
633         tegra11_spi_device4.dev.platform_data = &dalmore_spi_pdata;
634         platform_add_devices(dalmore_spi_devices,
635                                 ARRAY_SIZE(dalmore_spi_devices));
636 }
637 #else
638 static void __init dalmore_spi_init(void)
639 {
640 }
641 #endif
642
643 static __initdata struct tegra_clk_init_table touch_clk_init_table[] = {
644         /* name         parent          rate            enabled */
645         { "extern2",    "pll_p",        41000000,       false},
646         { "clk_out_2",  "extern2",      40800000,       false},
647         { NULL,         NULL,           0,              0},
648 };
649
650 struct rm_spi_ts_platform_data rm31080ts_dalmore_data = {
651         .gpio_reset = TOUCH_GPIO_RST_RAYDIUM_SPI,
652         .config = 0,
653         .platform_id = RM_PLATFORM_D010,
654         .name_of_clock = "clk_out_2",
655         .name_of_clock_con = "extern2",
656 };
657
658 static struct tegra_spi_device_controller_data dev_cdata = {
659         .rx_clk_tap_delay = 16,
660         .tx_clk_tap_delay = 16,
661 };
662
663 struct spi_board_info rm31080a_dalmore_spi_board[1] = {
664         {
665          .modalias = "rm_ts_spidev",
666          .bus_num = 3,
667          .chip_select = 2,
668          .max_speed_hz = 12 * 1000 * 1000,
669          .mode = SPI_MODE_0,
670          .controller_data = &dev_cdata,
671          .platform_data = &rm31080ts_dalmore_data,
672          },
673 };
674
675 static int __init dalmore_touch_init(void)
676 {
677         tegra_clk_init_from_table(touch_clk_init_table);
678         if (display_board_info.board_id == BOARD_E1582)
679                 rm31080ts_dalmore_data.platform_id = RM_PLATFORM_P005;
680         else
681                 rm31080ts_dalmore_data.platform_id = RM_PLATFORM_D010;
682         mdelay(20);
683         rm31080a_dalmore_spi_board[0].irq = gpio_to_irq(TOUCH_GPIO_IRQ_RAYDIUM_SPI);
684         touch_init_raydium(TOUCH_GPIO_IRQ_RAYDIUM_SPI,
685                                 TOUCH_GPIO_RST_RAYDIUM_SPI,
686                                 &rm31080ts_dalmore_data,
687                                 &rm31080a_dalmore_spi_board[0],
688                                 ARRAY_SIZE(rm31080a_dalmore_spi_board));
689         return 0;
690 }
691
692 #ifdef CONFIG_USE_OF
693 struct of_dev_auxdata dalmore_auxdata_lookup[] __initdata = {
694         OF_DEV_AUXDATA("nvidia,tegra114-sdhci", 0x78000600, "sdhci-tegra.3",
695                                 NULL),
696         OF_DEV_AUXDATA("nvidia,tegra114-sdhci", 0x78000400, "sdhci-tegra.2",
697                                 NULL),
698         OF_DEV_AUXDATA("nvidia,tegra114-sdhci", 0x78000000, "sdhci-tegra.0",
699                                 &dalmore_tegra_sdhci_platform_data0),
700         OF_DEV_AUXDATA("nvidia,tegra114-camera", 0x0, "tegra_camera",
701                                 NULL),
702         OF_DEV_AUXDATA("nvidia,tegra114-host1x", TEGRA_HOST1X_BASE, "host1x",
703                                 NULL),
704         OF_DEV_AUXDATA("nvidia,tegra114-gr3d", TEGRA_GR3D_BASE, "gr3d",
705                                 NULL),
706         OF_DEV_AUXDATA("nvidia,tegra114-gr2d", TEGRA_GR2D_BASE, "gr2d",
707                                 NULL),
708         OF_DEV_AUXDATA("nvidia,tegra114-msenc", TEGRA_MSENC_BASE, "msenc",
709                                 NULL),
710         OF_DEV_AUXDATA("nvidia,tegra114-vi", TEGRA_VI_BASE, "vi",
711                                 NULL),
712         OF_DEV_AUXDATA("nvidia,tegra114-isp", TEGRA_ISP_BASE, "isp",
713                                 NULL),
714         OF_DEV_AUXDATA("nvidia,tegra114-tsec", TEGRA_TSEC_BASE, "tsec",
715                                 NULL),
716
717         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c000, "tegra11-i2c.0",
718                                 NULL),
719         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c400, "tegra11-i2c.1",
720                                 NULL),
721         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c500, "tegra11-i2c.2",
722                                 NULL),
723         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c700, "tegra11-i2c.3",
724                                 NULL),
725         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000d000, "tegra11-i2c.4",
726                                 NULL),
727         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000d400, "spi-tegra114.0",
728                                 NULL),
729         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000d600, "spi-tegra114.1",
730                                 NULL),
731         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000d800, "spi-tegra114.2",
732                                 NULL),
733         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000da00, "spi-tegra114.3",
734                                 NULL),
735         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000dc00, "spi-tegra114.4",
736                                 NULL),
737         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000de00, "spi-tegra114.5",
738                                 NULL),
739         OF_DEV_AUXDATA("nvidia,tegra114-apbdma", 0x6000a000, "tegra-apbdma",
740                                 NULL),
741         OF_DEV_AUXDATA("nvidia,tegra114-hsuart", 0x70006000, "serial-tegra.0",
742                                 NULL),
743         OF_DEV_AUXDATA("nvidia,tegra114-hsuart", 0x70006040, "serial-tegra.1",
744                                 NULL),
745         OF_DEV_AUXDATA("nvidia,tegra114-hsuart", 0x70006200, "serial-tegra.2",
746                                 NULL),
747         {}
748 };
749 #endif
750
751 static void __init tegra_dalmore_early_init(void)
752 {
753         tegra_clk_init_from_table(dalmore_clk_init_table);
754         tegra_clk_verify_parents();
755         tegra_soc_device_init("dalmore");
756 }
757
758 static void __init tegra_dalmore_late_init(void)
759 {
760         platform_device_register(&tegra_pinmux_device);
761         dalmore_pinmux_init();
762         dalmore_i2c_init();
763         dalmore_spi_init();
764         dalmore_usb_init();
765         dalmore_xusb_init();
766         dalmore_uart_init();
767         dalmore_audio_init();
768         platform_add_devices(dalmore_devices, ARRAY_SIZE(dalmore_devices));
769         //tegra_ram_console_debug_init();
770         tegra_io_dpd_init();
771         dalmore_regulator_init();
772         dalmore_sdhci_init();
773         dalmore_suspend_init();
774         dalmore_emc_init();
775         dalmore_edp_init();
776         isomgr_init();
777         dalmore_touch_init();
778         if (board_info.board_id == BOARD_E1582)
779                 roth_panel_init(board_info.board_id);
780         else
781                 dalmore_panel_init();
782         dalmore_kbc_init();
783         dalmore_pmon_init();
784 #if defined(CONFIG_BT_BLUESLEEP) || defined(CONFIG_BT_BLUESLEEP_MODULE)
785         dalmore_setup_bluesleep();
786         dalmore_setup_bt_rfkill();
787 #elif defined(CONFIG_BLUEDROID_PM) || defined(CONFIG_BLUEDROID_PM_MODULE)
788         dalmore_setup_bluedroid_pm();
789 #endif
790         dalmore_modem_init();
791 #ifdef CONFIG_TEGRA_WDT_RECOVERY
792         tegra_wdt_recovery_init();
793 #endif
794         tegra_serial_debug_init(TEGRA_UARTD_BASE, INT_WDT_CPU, NULL, -1, -1);
795         dalmore_sensors_init();
796         dalmore_soctherm_init();
797         tegra_register_fuse();
798 }
799
800 static void __init dalmore_ramconsole_reserve(unsigned long size)
801 {
802         tegra_ram_console_debug_reserve(SZ_1M);
803 }
804
805 static void __init tegra_dalmore_dt_init(void)
806 {
807         tegra_get_board_info(&board_info);
808         tegra_get_display_board_info(&display_board_info);
809
810         tegra_dalmore_early_init();
811
812         of_platform_populate(NULL,
813                 of_default_bus_match_table, dalmore_auxdata_lookup,
814                 &platform_bus);
815
816         tegra_dalmore_late_init();
817 }
818
819 static void __init tegra_dalmore_reserve(void)
820 {
821 #if defined(CONFIG_NVMAP_CONVERT_CARVEOUT_TO_IOVMM)
822         /* 1920*1200*4*2 = 18432000 bytes */
823         tegra_reserve(0, SZ_16M + SZ_2M, SZ_16M);
824 #else
825         tegra_reserve(SZ_512M, SZ_16M + SZ_2M, SZ_4M);
826 #endif
827         dalmore_ramconsole_reserve(SZ_1M);
828 }
829
830 static const char * const dalmore_dt_board_compat[] = {
831         "nvidia,dalmore",
832         NULL
833 };
834
835 MACHINE_START(DALMORE, "dalmore")
836         .atag_offset    = 0x100,
837         .smp            = smp_ops(tegra_smp_ops),
838         .map_io         = tegra_map_common_io,
839         .reserve        = tegra_dalmore_reserve,
840         .init_early     = tegra11x_init_early,
841         .init_irq       = irqchip_init,
842         .init_time      = clocksource_of_init,
843         .init_machine   = tegra_dalmore_dt_init,
844         .restart        = tegra_assert_system_reset,
845         .dt_compat      = dalmore_dt_board_compat,
846         .init_late      = tegra_init_late,
847 MACHINE_END