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