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