ARM: tegra: init irq from device-tree
[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, 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/memblock.h>
38 #include <linux/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
51 #include <asm/hardware/gic.h>
52
53 #include <mach/clk.h>
54 #include <mach/iomap.h>
55 #include <mach/irqs.h>
56 #include <mach/pinmux.h>
57 #include <mach/pinmux-tegra30.h>
58 #include <mach/iomap.h>
59 #include <mach/io.h>
60 #include <mach/io_dpd.h>
61 #include <mach/i2s.h>
62 #include <mach/tegra_asoc_pdata.h>
63 #include <asm/mach-types.h>
64 #include <asm/mach/arch.h>
65 #include <mach/usb_phy.h>
66 #include <mach/gpio-tegra.h>
67 #include <mach/tegra_fiq_debugger.h>
68 #include <mach/tegra_usb_modem_power.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 "pm.h"
79 #include "pm-irq.h"
80 #include "common.h"
81 #include "tegra-board-id.h"
82
83 #ifdef CONFIG_BT_BLUESLEEP
84 static struct rfkill_gpio_platform_data dalmore_bt_rfkill_pdata = {
85                 .name           = "bt_rfkill",
86                 .shutdown_gpio  = TEGRA_GPIO_PQ7,
87                 .reset_gpio     = TEGRA_GPIO_PQ6,
88                 .type           = RFKILL_TYPE_BLUETOOTH,
89 };
90
91 static struct platform_device dalmore_bt_rfkill_device = {
92         .name = "rfkill_gpio",
93         .id             = -1,
94         .dev = {
95                 .platform_data = &dalmore_bt_rfkill_pdata,
96         },
97 };
98
99 static struct resource dalmore_bluesleep_resources[] = {
100         [0] = {
101                 .name = "gpio_host_wake",
102                         .start  = TEGRA_GPIO_PU6,
103                         .end    = TEGRA_GPIO_PU6,
104                         .flags  = IORESOURCE_IO,
105         },
106         [1] = {
107                 .name = "gpio_ext_wake",
108                         .start  = TEGRA_GPIO_PEE1,
109                         .end    = TEGRA_GPIO_PEE1,
110                         .flags  = IORESOURCE_IO,
111         },
112         [2] = {
113                 .name = "host_wake",
114                         .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
115         },
116 };
117
118 static struct platform_device dalmore_bluesleep_device = {
119         .name           = "bluesleep",
120         .id             = -1,
121         .num_resources  = ARRAY_SIZE(dalmore_bluesleep_resources),
122         .resource       = dalmore_bluesleep_resources,
123 };
124
125 static noinline void __init dalmore_setup_bt_rfkill(void)
126 {
127         platform_device_register(&dalmore_bt_rfkill_device);
128 }
129
130 static noinline void __init dalmore_setup_bluesleep(void)
131 {
132         dalmore_bluesleep_resources[2].start =
133                 dalmore_bluesleep_resources[2].end =
134                         gpio_to_irq(TEGRA_GPIO_PU6);
135         platform_device_register(&dalmore_bluesleep_device);
136         return;
137 }
138 #elif defined CONFIG_BLUEDROID_PM
139 static struct resource dalmore_bluedroid_pm_resources[] = {
140         [0] = {
141                 .name   = "shutdown_gpio",
142                 .start  = TEGRA_GPIO_PQ7,
143                 .end    = TEGRA_GPIO_PQ7,
144                 .flags  = IORESOURCE_IO,
145         },
146         [1] = {
147                 .name = "host_wake",
148                 .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
149         },
150         [2] = {
151                 .name = "gpio_ext_wake",
152                 .start  = TEGRA_GPIO_PEE1,
153                 .end    = TEGRA_GPIO_PEE1,
154                 .flags  = IORESOURCE_IO,
155         },
156         [3] = {
157                 .name = "gpio_host_wake",
158                 .start  = TEGRA_GPIO_PU6,
159                 .end    = TEGRA_GPIO_PU6,
160                 .flags  = IORESOURCE_IO,
161         },
162         [4] = {
163                 .name = "reset_gpio",
164                 .start  = TEGRA_GPIO_PQ6,
165                 .end    = TEGRA_GPIO_PQ6,
166                 .flags  = IORESOURCE_IO,
167         },
168 };
169
170 static struct platform_device dalmore_bluedroid_pm_device = {
171         .name = "bluedroid_pm",
172         .id             = 0,
173         .num_resources  = ARRAY_SIZE(dalmore_bluedroid_pm_resources),
174         .resource       = dalmore_bluedroid_pm_resources,
175 };
176
177 static noinline void __init dalmore_setup_bluedroid_pm(void)
178 {
179         dalmore_bluedroid_pm_resources[1].start =
180                 dalmore_bluedroid_pm_resources[1].end =
181                                 gpio_to_irq(TEGRA_GPIO_PU6);
182         platform_device_register(&dalmore_bluedroid_pm_device);
183 }
184 #endif
185
186 static __initdata struct tegra_clk_init_table dalmore_clk_init_table[] = {
187         /* name         parent          rate            enabled */
188         { "pll_m",      NULL,           0,              false},
189         { "hda",        "pll_p",        108000000,      false},
190         { "hda2codec_2x", "pll_p",      48000000,       false},
191         { "pwm",        "pll_p",        3187500,        false},
192         { "blink",      "clk_32k",      32768,          true},
193         { "i2s1",       "pll_a_out0",   0,              false},
194         { "i2s3",       "pll_a_out0",   0,              false},
195         { "i2s4",       "pll_a_out0",   0,              false},
196         { "spdif_out",  "pll_a_out0",   0,              false},
197         { "d_audio",    "clk_m",        12000000,       false},
198         { "dam0",       "clk_m",        12000000,       false},
199         { "dam1",       "clk_m",        12000000,       false},
200         { "dam2",       "clk_m",        12000000,       false},
201         { "audio1",     "i2s1_sync",    0,              false},
202         { "audio3",     "i2s3_sync",    0,              false},
203         /* Setting vi_sensor-clk to true for validation purpose, will imapact
204          * power, later set to be false.*/
205         { "vi_sensor",  "pll_p",        150000000,      false},
206         { "cilab",      "pll_p",        150000000,      false},
207         { "cilcd",      "pll_p",        150000000,      false},
208         { "cile",       "pll_p",        150000000,      false},
209         { "i2c1",       "pll_p",        3200000,        false},
210         { "i2c2",       "pll_p",        3200000,        false},
211         { "i2c3",       "pll_p",        3200000,        false},
212         { "i2c4",       "pll_p",        3200000,        false},
213         { "i2c5",       "pll_p",        3200000,        false},
214         { NULL,         NULL,           0,              0},
215 };
216
217 static struct tegra_i2c_platform_data dalmore_i2c1_platform_data = {
218         .adapter_nr     = 0,
219         .bus_count      = 1,
220         .bus_clk_rate   = { 100000, 0 },
221         .scl_gpio               = {TEGRA_GPIO_I2C1_SCL, 0},
222         .sda_gpio               = {TEGRA_GPIO_I2C1_SDA, 0},
223         .arb_recovery = arb_lost_recovery,
224 };
225
226 static struct tegra_i2c_platform_data dalmore_i2c2_platform_data = {
227         .adapter_nr     = 1,
228         .bus_count      = 1,
229         .bus_clk_rate   = { 100000, 0 },
230         .is_clkon_always = true,
231         .scl_gpio               = {TEGRA_GPIO_I2C2_SCL, 0},
232         .sda_gpio               = {TEGRA_GPIO_I2C2_SDA, 0},
233         .arb_recovery = arb_lost_recovery,
234 };
235
236 static struct tegra_i2c_platform_data dalmore_i2c3_platform_data = {
237         .adapter_nr     = 2,
238         .bus_count      = 1,
239         .bus_clk_rate   = { 100000, 0 },
240         .scl_gpio               = {TEGRA_GPIO_I2C3_SCL, 0},
241         .sda_gpio               = {TEGRA_GPIO_I2C3_SDA, 0},
242         .arb_recovery = arb_lost_recovery,
243 };
244
245 static struct tegra_i2c_platform_data dalmore_i2c4_platform_data = {
246         .adapter_nr     = 3,
247         .bus_count      = 1,
248         .bus_clk_rate   = { 10000, 0 },
249         .scl_gpio               = {TEGRA_GPIO_I2C4_SCL, 0},
250         .sda_gpio               = {TEGRA_GPIO_I2C4_SDA, 0},
251         .arb_recovery = arb_lost_recovery,
252 };
253
254 static struct tegra_i2c_platform_data dalmore_i2c5_platform_data = {
255         .adapter_nr     = 4,
256         .bus_count      = 1,
257         .bus_clk_rate   = { 400000, 0 },
258         .scl_gpio               = {TEGRA_GPIO_I2C5_SCL, 0},
259         .sda_gpio               = {TEGRA_GPIO_I2C5_SDA, 0},
260         .arb_recovery = arb_lost_recovery,
261 };
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         struct board_info board_info;
281
282         tegra_get_board_info(&board_info);
283         tegra11_i2c_device1.dev.platform_data = &dalmore_i2c1_platform_data;
284         tegra11_i2c_device2.dev.platform_data = &dalmore_i2c2_platform_data;
285         tegra11_i2c_device3.dev.platform_data = &dalmore_i2c3_platform_data;
286         tegra11_i2c_device4.dev.platform_data = &dalmore_i2c4_platform_data;
287         tegra11_i2c_device5.dev.platform_data = &dalmore_i2c5_platform_data;
288
289         nfc_board_info.irq = gpio_to_irq(TEGRA_GPIO_PW2);
290         i2c_register_board_info(0, &nfc_board_info, 1);
291
292         platform_device_register(&tegra11_i2c_device5);
293         platform_device_register(&tegra11_i2c_device4);
294         platform_device_register(&tegra11_i2c_device3);
295         platform_device_register(&tegra11_i2c_device2);
296         platform_device_register(&tegra11_i2c_device1);
297
298         i2c_register_board_info(0, &rt5640_board_info, 1);
299 }
300
301 static struct platform_device *dalmore_uart_devices[] __initdata = {
302         &tegra_uarta_device,
303         &tegra_uartb_device,
304         &tegra_uartc_device,
305         &tegra_uartd_device,
306 };
307 static struct uart_clk_parent uart_parent_clk[] = {
308         [0] = {.name = "clk_m"},
309         [1] = {.name = "pll_p"},
310 #ifndef CONFIG_TEGRA_PLLM_RESTRICTED
311         [2] = {.name = "pll_m"},
312 #endif
313 };
314
315 static struct tegra_uart_platform_data dalmore_uart_pdata;
316 static struct tegra_uart_platform_data dalmore_loopback_uart_pdata;
317
318 static void __init uart_debug_init(void)
319 {
320         int debug_port_id;
321
322         debug_port_id = uart_console_debug_init(3);
323         if (debug_port_id < 0)
324                 return;
325
326         dalmore_uart_devices[debug_port_id] = uart_console_debug_device;
327 }
328
329 static void __init dalmore_uart_init(void)
330 {
331         struct clk *c;
332         int i;
333
334         for (i = 0; i < ARRAY_SIZE(uart_parent_clk); ++i) {
335                 c = tegra_get_clock_by_name(uart_parent_clk[i].name);
336                 if (IS_ERR_OR_NULL(c)) {
337                         pr_err("Not able to get the clock for %s\n",
338                                                 uart_parent_clk[i].name);
339                         continue;
340                 }
341                 uart_parent_clk[i].parent_clk = c;
342                 uart_parent_clk[i].fixed_clk_rate = clk_get_rate(c);
343         }
344         dalmore_uart_pdata.parent_clk_list = uart_parent_clk;
345         dalmore_uart_pdata.parent_clk_count = ARRAY_SIZE(uart_parent_clk);
346         dalmore_loopback_uart_pdata.parent_clk_list = uart_parent_clk;
347         dalmore_loopback_uart_pdata.parent_clk_count =
348                                                 ARRAY_SIZE(uart_parent_clk);
349         dalmore_loopback_uart_pdata.is_loopback = true;
350         tegra_uarta_device.dev.platform_data = &dalmore_uart_pdata;
351         tegra_uartb_device.dev.platform_data = &dalmore_uart_pdata;
352         tegra_uartc_device.dev.platform_data = &dalmore_uart_pdata;
353         tegra_uartd_device.dev.platform_data = &dalmore_uart_pdata;
354
355         /* Register low speed only if it is selected */
356         if (!is_tegra_debug_uartport_hs())
357                 uart_debug_init();
358
359         platform_add_devices(dalmore_uart_devices,
360                                 ARRAY_SIZE(dalmore_uart_devices));
361 }
362
363 static struct resource tegra_rtc_resources[] = {
364         [0] = {
365                 .start = TEGRA_RTC_BASE,
366                 .end = TEGRA_RTC_BASE + TEGRA_RTC_SIZE - 1,
367                 .flags = IORESOURCE_MEM,
368         },
369         [1] = {
370                 .start = INT_RTC,
371                 .end = INT_RTC,
372                 .flags = IORESOURCE_IRQ,
373         },
374 };
375
376 static struct platform_device tegra_rtc_device = {
377         .name = "tegra_rtc",
378         .id   = -1,
379         .resource = tegra_rtc_resources,
380         .num_resources = ARRAY_SIZE(tegra_rtc_resources),
381 };
382
383 static struct tegra_asoc_platform_data dalmore_audio_pdata = {
384         .gpio_spkr_en           = TEGRA_GPIO_SPKR_EN,
385         .gpio_hp_det            = TEGRA_GPIO_HP_DET,
386         .gpio_hp_mute           = -1,
387         .gpio_int_mic_en        = TEGRA_GPIO_INT_MIC_EN,
388         .gpio_ext_mic_en        = TEGRA_GPIO_EXT_MIC_EN,
389         .gpio_ldo1_en           = TEGRA_GPIO_LDO1_EN,
390         .gpio_codec1 = TEGRA_GPIO_CODEC1_EN,
391         .gpio_codec2 = TEGRA_GPIO_CODEC2_EN,
392         .gpio_codec3 = TEGRA_GPIO_CODEC3_EN,
393         .i2s_param[HIFI_CODEC]  = {
394                 .audio_port_id  = 1,
395                 .is_i2s_master  = 1,
396                 .i2s_mode       = TEGRA_DAIFMT_I2S,
397         },
398         .i2s_param[BT_SCO]      = {
399                 .audio_port_id  = 3,
400                 .is_i2s_master  = 1,
401                 .i2s_mode       = TEGRA_DAIFMT_DSP_A,
402         },
403 };
404
405 static struct platform_device dalmore_audio_device = {
406         .name   = "tegra-snd-rt5640",
407         .id     = 0,
408         .dev    = {
409                 .platform_data = &dalmore_audio_pdata,
410         },
411 };
412
413 static struct platform_device tegra_camera = {
414         .name = "tegra_camera",
415         .id = -1,
416 };
417
418 static struct platform_device *dalmore_devices[] __initdata = {
419         &tegra_pmu_device,
420         &tegra_rtc_device,
421         &tegra_udc_device,
422 #if defined(CONFIG_TEGRA_AVP)
423         &tegra_avp_device,
424 #endif
425         &tegra_camera,
426 #if defined(CONFIG_CRYPTO_DEV_TEGRA_SE)
427         &tegra11_se_device,
428 #endif
429         &tegra_ahub_device,
430         &tegra_dam_device0,
431         &tegra_dam_device1,
432         &tegra_dam_device2,
433         &tegra_i2s_device1,
434         &tegra_i2s_device3,
435         &tegra_i2s_device4,
436         &tegra_spdif_device,
437         &spdif_dit_device,
438         &bluetooth_dit_device,
439         &dalmore_audio_device,
440         &tegra_hda_device,
441 #if defined(CONFIG_CRYPTO_DEV_TEGRA_AES)
442         &tegra_aes_device,
443 #endif
444 };
445
446 #ifdef CONFIG_USB_SUPPORT
447 static struct tegra_usb_platform_data tegra_udc_pdata = {
448         .port_otg = true,
449         .has_hostpc = true,
450         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
451         .op_mode = TEGRA_USB_OPMODE_DEVICE,
452         .u_data.dev = {
453                 .vbus_pmu_irq = 0,
454                 .vbus_gpio = -1,
455                 .charging_supported = false,
456                 .remote_wakeup_supported = false,
457         },
458         .u_cfg.utmi = {
459                 .hssync_start_delay = 0,
460                 .elastic_limit = 16,
461                 .idle_wait_delay = 17,
462                 .term_range_adj = 6,
463                 .xcvr_setup = 8,
464                 .xcvr_lsfslew = 2,
465                 .xcvr_lsrslew = 2,
466                 .xcvr_setup_offset = 0,
467                 .xcvr_use_fuses = 1,
468         },
469 };
470
471 static struct tegra_usb_platform_data tegra_ehci1_utmi_pdata = {
472         .port_otg = true,
473         .has_hostpc = true,
474         .unaligned_dma_buf_supported = false,
475         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
476         .op_mode = TEGRA_USB_OPMODE_HOST,
477         .u_data.host = {
478                 .vbus_gpio = -1,
479                 .hot_plug = false,
480                 .remote_wakeup_supported = true,
481                 .power_off_on_suspend = true,
482         },
483         .u_cfg.utmi = {
484                 .hssync_start_delay = 0,
485                 .elastic_limit = 16,
486                 .idle_wait_delay = 17,
487                 .term_range_adj = 6,
488                 .xcvr_setup = 15,
489                 .xcvr_lsfslew = 2,
490                 .xcvr_lsrslew = 2,
491                 .xcvr_setup_offset = 0,
492                 .xcvr_use_fuses = 1,
493         },
494 };
495
496 static struct tegra_usb_platform_data tegra_ehci3_utmi_pdata = {
497         .port_otg = false,
498         .has_hostpc = true,
499         .unaligned_dma_buf_supported = false,
500         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
501         .op_mode = TEGRA_USB_OPMODE_HOST,
502         .u_data.host = {
503                 .vbus_gpio = -1,
504                 .hot_plug = false,
505                 .remote_wakeup_supported = true,
506                 .power_off_on_suspend = true,
507         },
508         .u_cfg.utmi = {
509         .hssync_start_delay = 0,
510                 .elastic_limit = 16,
511                 .idle_wait_delay = 17,
512                 .term_range_adj = 6,
513                 .xcvr_setup = 8,
514                 .xcvr_lsfslew = 2,
515                 .xcvr_lsrslew = 2,
516                 .xcvr_setup_offset = 0,
517                 .xcvr_use_fuses = 1,
518         },
519 };
520
521 static struct tegra_usb_otg_data tegra_otg_pdata = {
522         .ehci_device = &tegra_ehci1_device,
523         .ehci_pdata = &tegra_ehci1_utmi_pdata,
524 };
525
526 static void dalmore_usb_init(void)
527 {
528         int usb_port_owner_info = tegra_get_usb_port_owner_info();
529
530         /* Set USB wake sources for dalmore */
531         tegra_set_usb_wake_source();
532
533         if (!(usb_port_owner_info & UTMI1_PORT_OWNER_XUSB)) {
534                 tegra_otg_device.dev.platform_data = &tegra_otg_pdata;
535                 platform_device_register(&tegra_otg_device);
536                 /* Setup the udc platform data */
537                 tegra_udc_device.dev.platform_data = &tegra_udc_pdata;
538         }
539
540         if (!(usb_port_owner_info & UTMI2_PORT_OWNER_XUSB)) {
541                 tegra_ehci3_device.dev.platform_data = &tegra_ehci3_utmi_pdata;
542                 platform_device_register(&tegra_ehci3_device);
543         }
544 }
545
546 static struct gpio modem_gpios[] = { /* Nemo modem */
547         {MODEM_EN, GPIOF_OUT_INIT_HIGH, "MODEM EN"},
548         {MDM_RST, GPIOF_OUT_INIT_LOW, "MODEM RESET"},
549 };
550
551 static struct tegra_usb_platform_data tegra_ehci2_hsic_baseband_pdata = {
552         .port_otg = false,
553         .has_hostpc = true,
554         .unaligned_dma_buf_supported = false,
555         .phy_intf = TEGRA_USB_PHY_INTF_HSIC,
556         .op_mode = TEGRA_USB_OPMODE_HOST,
557         .u_data.host = {
558                 .vbus_gpio = -1,
559                 .hot_plug = false,
560                 .remote_wakeup_supported = true,
561                 .power_off_on_suspend = true,
562         },
563 };
564
565 static int baseband_init(void)
566 {
567         int ret;
568
569         ret = gpio_request_array(modem_gpios, ARRAY_SIZE(modem_gpios));
570         if (ret) {
571                 pr_warn("%s:gpio request failed\n", __func__);
572                 return ret;
573         }
574
575         /* enable pull-down for MDM_COLD_BOOT */
576         tegra_pinmux_set_pullupdown(TEGRA_PINGROUP_KB_COL5,
577                                     TEGRA_PUPD_PULL_DOWN);
578
579         /* export GPIO for user space access through sysfs */
580         gpio_export(MDM_RST, false);
581
582         return 0;
583 }
584
585 static const struct tegra_modem_operations baseband_operations = {
586         .init = baseband_init,
587 };
588
589 static struct tegra_usb_modem_power_platform_data baseband_pdata = {
590         .ops = &baseband_operations,
591         .wake_gpio = -1,
592         .boot_gpio = MDM_COLDBOOT,
593         .boot_irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
594         .autosuspend_delay = 2000,
595         .short_autosuspend_delay = 50,
596         .tegra_ehci_device = &tegra_ehci2_device,
597         .tegra_ehci_pdata = &tegra_ehci2_hsic_baseband_pdata,
598 };
599
600 static struct platform_device icera_nemo_device = {
601         .name = "tegra_usb_modem_power",
602         .id = -1,
603         .dev = {
604                 .platform_data = &baseband_pdata,
605         },
606 };
607
608 static void dalmore_modem_init(void)
609 {
610         int usb_port_owner_info = tegra_get_usb_port_owner_info();
611         if (!(usb_port_owner_info & HSIC1_PORT_OWNER_XUSB))
612                 platform_device_register(&icera_nemo_device);
613 }
614
615 #else
616 static void dalmore_usb_init(void) { }
617 static void dalmore_modem_init(void) { }
618 #endif
619
620 static void dalmore_audio_init(void)
621 {
622         struct board_info board_info;
623
624         tegra_get_board_info(&board_info);
625
626         dalmore_audio_pdata.codec_name = "rt5640.0-001c";
627         dalmore_audio_pdata.codec_dai_name = "rt5640-aif1";
628 }
629
630
631 static struct platform_device *dalmore_spi_devices[] __initdata = {
632         &tegra11_spi_device4,
633 };
634
635 struct spi_clk_parent spi_parent_clk_dalmore[] = {
636         [0] = {.name = "pll_p"},
637 #ifndef CONFIG_TEGRA_PLLM_RESTRICTED
638         [1] = {.name = "pll_m"},
639         [2] = {.name = "clk_m"},
640 #else
641         [1] = {.name = "clk_m"},
642 #endif
643 };
644
645 static struct tegra_spi_platform_data dalmore_spi_pdata = {
646         .is_dma_based           = false,
647         .max_dma_buffer         = 16 * 1024,
648         .is_clkon_always        = false,
649         .max_rate               = 25000000,
650 };
651
652 static void __init dalmore_spi_init(void)
653 {
654         int i;
655         struct clk *c;
656         struct board_info board_info, display_board_info;
657
658         tegra_get_board_info(&board_info);
659         tegra_get_display_board_info(&display_board_info);
660
661         for (i = 0; i < ARRAY_SIZE(spi_parent_clk_dalmore); ++i) {
662                 c = tegra_get_clock_by_name(spi_parent_clk_dalmore[i].name);
663                 if (IS_ERR_OR_NULL(c)) {
664                         pr_err("Not able to get the clock for %s\n",
665                                                 spi_parent_clk_dalmore[i].name);
666                         continue;
667                 }
668                 spi_parent_clk_dalmore[i].parent_clk = c;
669                 spi_parent_clk_dalmore[i].fixed_clk_rate = clk_get_rate(c);
670         }
671         dalmore_spi_pdata.parent_clk_list = spi_parent_clk_dalmore;
672         dalmore_spi_pdata.parent_clk_count = ARRAY_SIZE(spi_parent_clk_dalmore);
673         tegra11_spi_device4.dev.platform_data = &dalmore_spi_pdata;
674         platform_add_devices(dalmore_spi_devices,
675                                 ARRAY_SIZE(dalmore_spi_devices));
676 }
677
678 static __initdata struct tegra_clk_init_table touch_clk_init_table[] = {
679         /* name         parent          rate            enabled */
680         { "extern2",    "pll_p",        41000000,       false},
681         { "clk_out_2",  "extern2",      40800000,       false},
682         { NULL,         NULL,           0,              0},
683 };
684
685 struct rm_spi_ts_platform_data rm31080ts_dalmore_data = {
686         .gpio_reset = 0,
687         .config = 0,
688         .platform_id = RM_PLATFORM_D010,
689         .name_of_clock = "clk_out_2",
690 };
691
692 static struct tegra_spi_device_controller_data dev_cdata = {
693         .rx_clk_tap_delay = 0,
694         .tx_clk_tap_delay = 16,
695 };
696
697 struct spi_board_info rm31080a_dalmore_spi_board[1] = {
698         {
699          .modalias = "rm_ts_spidev",
700          .bus_num = 3,
701          .chip_select = 2,
702          .max_speed_hz = 12 * 1000 * 1000,
703          .mode = SPI_MODE_0,
704          .controller_data = &dev_cdata,
705          .platform_data = &rm31080ts_dalmore_data,
706          },
707 };
708
709 static int __init dalmore_touch_init(void)
710 {
711         struct board_info board_info;
712
713         tegra_get_display_board_info(&board_info);
714         tegra_clk_init_from_table(touch_clk_init_table);
715         clk_enable(tegra_get_clock_by_name("clk_out_2"));
716         if (board_info.board_id == BOARD_E1582)
717                 rm31080ts_dalmore_data.platform_id = RM_PLATFORM_P005;
718         else
719                 rm31080ts_dalmore_data.platform_id = RM_PLATFORM_D010;
720         mdelay(20);
721         rm31080a_dalmore_spi_board[0].irq = gpio_to_irq(TOUCH_GPIO_IRQ_RAYDIUM_SPI);
722         touch_init_raydium(TOUCH_GPIO_IRQ_RAYDIUM_SPI,
723                                 TOUCH_GPIO_RST_RAYDIUM_SPI,
724                                 &rm31080ts_dalmore_data,
725                                 &rm31080a_dalmore_spi_board[0],
726                                 ARRAY_SIZE(rm31080a_dalmore_spi_board));
727         return 0;
728 }
729
730 #ifdef CONFIG_EDP_FRAMEWORK
731 static struct edp_manager battery_edp_manager = {
732         .name = "battery",
733         .imax = 2500
734 };
735
736 static void __init dalmore_battery_edp_init(void)
737 {
738         struct edp_governor *g;
739         int r;
740
741         r = edp_register_manager(&battery_edp_manager);
742         if (r)
743                 goto err_ret;
744
745         /* start with priority governor */
746         g = edp_get_governor("priority");
747         if (!g) {
748                 r = -EFAULT;
749                 goto err_ret;
750         }
751
752         r = edp_set_governor(&battery_edp_manager, g);
753         if (r)
754                 goto err_ret;
755
756         return;
757
758 err_ret:
759         pr_err("Battery EDP init failed with error %d\n", r);
760         WARN_ON(1);
761 }
762 #else
763 static inline void dalmore_battery_edp_init(void) {}
764 #endif
765 static void __init tegra_dalmore_init(void)
766 {
767         struct board_info board_info;
768
769         tegra_get_display_board_info(&board_info);
770         dalmore_battery_edp_init();
771         tegra_clk_init_from_table(dalmore_clk_init_table);
772         tegra_smmu_init();
773         tegra_soc_device_init("dalmore");
774         tegra_enable_pinmux();
775         dalmore_pinmux_init();
776         dalmore_i2c_init();
777         dalmore_spi_init();
778         dalmore_usb_init();
779         dalmore_uart_init();
780         dalmore_audio_init();
781         platform_add_devices(dalmore_devices, ARRAY_SIZE(dalmore_devices));
782         //tegra_ram_console_debug_init();
783         tegra_io_dpd_init();
784         dalmore_regulator_init();
785         dalmore_sdhci_init();
786         dalmore_suspend_init();
787         dalmore_emc_init();
788         dalmore_edp_init();
789         dalmore_touch_init();
790         if (board_info.board_id == BOARD_E1582)
791                 roth_panel_init();
792         else
793                 dalmore_panel_init();
794         dalmore_kbc_init();
795         dalmore_pmon_init();
796 #ifdef CONFIG_BT_BLUESLEEP
797         dalmore_setup_bluesleep();
798         dalmore_setup_bt_rfkill();
799 #elif defined CONFIG_BLUEDROID_PM
800         dalmore_setup_bluedroid_pm();
801 #endif
802         tegra_release_bootloader_fb();
803         dalmore_modem_init();
804 #ifdef CONFIG_TEGRA_WDT_RECOVERY
805         tegra_wdt_recovery_init();
806 #endif
807         tegra_serial_debug_init(TEGRA_UARTD_BASE, INT_WDT_CPU, NULL, -1, -1);
808         dalmore_sensors_init();
809         dalmore_soctherm_init();
810 }
811
812 static void __init dalmore_ramconsole_reserve(unsigned long size)
813 {
814         tegra_ram_console_debug_reserve(SZ_1M);
815 }
816
817 static void __init tegra_dalmore_dt_init(void)
818 {
819         tegra_dalmore_init();
820
821         of_platform_populate(NULL,
822                 of_default_bus_match_table, NULL, NULL);
823 }
824
825 static void __init tegra_dalmore_reserve(void)
826 {
827 #if defined(CONFIG_NVMAP_CONVERT_CARVEOUT_TO_IOVMM)
828         /* 1920*1200*4*2 = 18432000 bytes */
829         tegra_reserve(0, SZ_16M + SZ_2M, SZ_16M);
830 #else
831         tegra_reserve(SZ_128M, SZ_16M + SZ_2M, SZ_4M);
832 #endif
833         dalmore_ramconsole_reserve(SZ_1M);
834 }
835
836 static const char * const dalmore_dt_board_compat[] = {
837         "nvidia,dalmore",
838         NULL
839 };
840
841 MACHINE_START(DALMORE, "dalmore")
842         .atag_offset    = 0x100,
843         .smp            = smp_ops(tegra_smp_ops),
844         .map_io         = tegra_map_common_io,
845         .reserve        = tegra_dalmore_reserve,
846         .init_early     = tegra11x_init_early,
847         .init_irq       = tegra_dt_init_irq,
848         .handle_irq     = gic_handle_irq,
849         .timer          = &tegra_timer,
850         .init_machine   = tegra_dalmore_dt_init,
851         .restart        = tegra_assert_system_reset,
852         .dt_compat      = dalmore_dt_board_compat,
853 MACHINE_END