ARM: tegra114: dalmore/pluto: use spi-tegra114 spi driver
[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/platform_data/tegra_xusb.h>
35 #include <linux/spi/spi.h>
36 #include <linux/spi/rm31080a_ts.h>
37 #include <linux/tegra_uart.h>
38 #include <linux/memblock.h>
39 #include <linux/spi/spi-tegra.h>
40 #include <linux/nfc/pn544.h>
41 #include <linux/rfkill-gpio.h>
42 #include <linux/skbuff.h>
43 #include <linux/ti_wilink_st.h>
44 #include <linux/regulator/consumer.h>
45 #include <linux/smb349-charger.h>
46 #include <linux/max17048_battery.h>
47 #include <linux/leds.h>
48 #include <linux/i2c/at24.h>
49 #include <linux/of_platform.h>
50 #include <linux/edp.h>
51 #include <linux/usb/tegra_usb_phy.h>
52
53 #include <asm/hardware/gic.h>
54
55 #include <mach/clk.h>
56 #include <mach/iomap.h>
57 #include <mach/irqs.h>
58 #include <mach/pinmux.h>
59 #include <mach/pinmux-tegra30.h>
60 #include <mach/iomap.h>
61 #include <mach/io_dpd.h>
62 #include <mach/i2s.h>
63 #include <mach/isomgr.h>
64 #include <mach/tegra_asoc_pdata.h>
65 #include <asm/mach-types.h>
66 #include <asm/mach/arch.h>
67 #include <mach/gpio-tegra.h>
68 #include <mach/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 #if defined(CONFIG_BT_BLUESLEEP) || defined(CONFIG_BT_BLUESLEEP_MODULE)
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         { "sbc1",       "pll_p",        25000000,       false},
218         { "sbc2",       "pll_p",        25000000,       false},
219         { "sbc3",       "pll_p",        25000000,       false},
220         { "sbc4",       "pll_p",        25000000,       false},
221         { "sbc5",       "pll_p",        25000000,       false},
222         { "sbc6",       "pll_p",        25000000,       false},
223         { NULL,         NULL,           0,              0},
224 };
225
226 #ifndef CONFIG_USE_OF
227 static struct tegra_i2c_platform_data dalmore_i2c1_platform_data = {
228         .bus_clk_rate   = 100000,
229         .scl_gpio       = TEGRA_GPIO_I2C1_SCL,
230         .sda_gpio       = TEGRA_GPIO_I2C1_SDA,
231 };
232
233 static struct tegra_i2c_platform_data dalmore_i2c2_platform_data = {
234         .bus_clk_rate   = 100000,
235         .is_clkon_always = true,
236         .scl_gpio       = TEGRA_GPIO_I2C2_SCL,
237         .sda_gpio       = TEGRA_GPIO_I2C2_SDA,
238 };
239
240 static struct tegra_i2c_platform_data dalmore_i2c3_platform_data = {
241         .bus_clk_rate   = 100000,
242         .scl_gpio       = TEGRA_GPIO_I2C3_SCL,
243         .sda_gpio       = TEGRA_GPIO_I2C3_SDA,
244 };
245
246 static struct tegra_i2c_platform_data dalmore_i2c4_platform_data = {
247         .bus_clk_rate   = 10000,
248         .scl_gpio       = TEGRA_GPIO_I2C4_SCL,
249         .sda_gpio       = TEGRA_GPIO_I2C4_SDA,
250 };
251
252 static struct tegra_i2c_platform_data dalmore_i2c5_platform_data = {
253         .bus_clk_rate   = 400000,
254         .scl_gpio       = TEGRA_GPIO_I2C5_SCL,
255         .sda_gpio       = TEGRA_GPIO_I2C5_SDA,
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 #ifndef CONFIG_USE_OF
407 static struct platform_device tegra_camera = {
408         .name = "tegra_camera",
409         .id = -1,
410 };
411 #endif
412
413 static struct platform_device *dalmore_devices[] __initdata = {
414         &tegra_pmu_device,
415         &tegra_rtc_device,
416         &tegra_udc_device,
417 #if defined(CONFIG_TEGRA_AVP)
418         &tegra_avp_device,
419 #endif
420 #ifndef CONFIG_USE_OF
421         &tegra_camera,
422 #endif
423 #if defined(CONFIG_CRYPTO_DEV_TEGRA_SE)
424         &tegra11_se_device,
425 #endif
426         &tegra_ahub_device,
427         &tegra_dam_device0,
428         &tegra_dam_device1,
429         &tegra_dam_device2,
430         &tegra_i2s_device1,
431         &tegra_i2s_device3,
432         &tegra_i2s_device4,
433         &tegra_spdif_device,
434         &spdif_dit_device,
435         &bluetooth_dit_device,
436         &dalmore_audio_device,
437         &tegra_hda_device,
438 #if defined(CONFIG_CRYPTO_DEV_TEGRA_AES)
439         &tegra_aes_device,
440 #endif
441 };
442
443 #ifdef CONFIG_USB_SUPPORT
444 static struct tegra_usb_platform_data tegra_udc_pdata = {
445         .port_otg = true,
446         .has_hostpc = true,
447         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
448         .op_mode = TEGRA_USB_OPMODE_DEVICE,
449         .u_data.dev = {
450                 .vbus_pmu_irq = 0,
451                 .vbus_gpio = -1,
452                 .charging_supported = false,
453                 .remote_wakeup_supported = false,
454         },
455         .u_cfg.utmi = {
456                 .hssync_start_delay = 0,
457                 .elastic_limit = 16,
458                 .idle_wait_delay = 17,
459                 .term_range_adj = 6,
460                 .xcvr_setup = 8,
461                 .xcvr_lsfslew = 2,
462                 .xcvr_lsrslew = 2,
463                 .xcvr_setup_offset = 0,
464                 .xcvr_use_fuses = 1,
465         },
466 };
467
468 static struct tegra_usb_platform_data tegra_ehci1_utmi_pdata = {
469         .port_otg = true,
470         .has_hostpc = true,
471         .unaligned_dma_buf_supported = false,
472         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
473         .op_mode = TEGRA_USB_OPMODE_HOST,
474         .u_data.host = {
475                 .vbus_gpio = -1,
476                 .hot_plug = false,
477                 .remote_wakeup_supported = true,
478                 .power_off_on_suspend = true,
479         },
480         .u_cfg.utmi = {
481                 .hssync_start_delay = 0,
482                 .elastic_limit = 16,
483                 .idle_wait_delay = 17,
484                 .term_range_adj = 6,
485                 .xcvr_setup = 15,
486                 .xcvr_lsfslew = 2,
487                 .xcvr_lsrslew = 2,
488                 .xcvr_setup_offset = 0,
489                 .xcvr_use_fuses = 1,
490                 .vbus_oc_map = 0x4,
491         },
492 };
493
494 static struct tegra_usb_platform_data tegra_ehci3_utmi_pdata = {
495         .port_otg = false,
496         .has_hostpc = true,
497         .unaligned_dma_buf_supported = false,
498         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
499         .op_mode = TEGRA_USB_OPMODE_HOST,
500         .u_data.host = {
501                 .vbus_gpio = -1,
502                 .hot_plug = false,
503                 .remote_wakeup_supported = true,
504                 .power_off_on_suspend = true,
505         },
506         .u_cfg.utmi = {
507         .hssync_start_delay = 0,
508                 .elastic_limit = 16,
509                 .idle_wait_delay = 17,
510                 .term_range_adj = 6,
511                 .xcvr_setup = 8,
512                 .xcvr_lsfslew = 2,
513                 .xcvr_lsrslew = 2,
514                 .xcvr_setup_offset = 0,
515                 .xcvr_use_fuses = 1,
516                 .vbus_oc_map = 0x5,
517         },
518 };
519
520 static struct tegra_usb_otg_data tegra_otg_pdata = {
521         .ehci_device = &tegra_ehci1_device,
522         .ehci_pdata = &tegra_ehci1_utmi_pdata,
523 };
524
525 static void dalmore_usb_init(void)
526 {
527         int usb_port_owner_info = tegra_get_usb_port_owner_info();
528
529         /* Set USB wake sources for dalmore */
530         tegra_set_usb_wake_source();
531
532         if (!(usb_port_owner_info & UTMI1_PORT_OWNER_XUSB)) {
533                 tegra_otg_device.dev.platform_data = &tegra_otg_pdata;
534                 platform_device_register(&tegra_otg_device);
535                 /* Setup the udc platform data */
536                 tegra_udc_device.dev.platform_data = &tegra_udc_pdata;
537         }
538
539         if (!(usb_port_owner_info & UTMI2_PORT_OWNER_XUSB)) {
540                 tegra_ehci3_device.dev.platform_data = &tegra_ehci3_utmi_pdata;
541                 platform_device_register(&tegra_ehci3_device);
542         }
543 }
544
545 static struct tegra_xusb_pad_data xusb_padctl_data = {
546         .pad_mux = 0x4,
547         .port_cap = 0x10,
548         .snps_oc_map = 0x1fc,
549         .usb2_oc_map = 0x2f,
550         .ss_port_map = 0x1,
551         .oc_det = 0xb000,
552         .rx_wander = 0xf0,
553         .rx_eq = 0x307000,
554         .cdr_cntl = 0x26000000,
555         .dfe_cntl = 0x002008EE,
556         .otg_pad0_ctl0 = 0xffffffff,
557         .hs_slew = 0x30,
558         .otg_pad0_ctl1 = 0x0,
559         .otg_pad1_ctl0 = 0xffc7ffff,
560         .otg_pad1_ctl1 = 0x7,
561         .bias_pad_ctl0 = 0,
562         .hsic_pad0_ctl0 = 0xffff00ff,
563         .hsic_pad0_ctl1 = 0xffff00ff,
564         .pmc_value = 0xfff0ffff,
565 };
566
567 static void dalmore_xusb_init(void)
568 {
569         int usb_port_owner_info = tegra_get_usb_port_owner_info();
570
571         if (usb_port_owner_info & UTMI2_PORT_OWNER_XUSB) {
572                 u32 usb_calib0 = tegra_fuse_readl(FUSE_SKU_USB_CALIB_0);
573
574                 /*
575                  * read from usb_calib0 and pass to driver
576                  * set HS_CURR_LEVEL = usb_calib0[5:0]
577                  * set TERM_RANGE_ADJ = usb_calib0[10:7]
578                  * set HS_IREF_CAP = usb_calib0[14:13]
579                  * set HS_SQUELCH_LEVEL = usb_calib0[12:11]
580                  */
581
582                 xusb_padctl_data.hs_curr_level = (usb_calib0 >> 0) & 0x3f;
583                 xusb_padctl_data.hs_iref_cap = (usb_calib0 >> 13) & 0x3;
584                 xusb_padctl_data.hs_term_range_adj = (usb_calib0 >> 7) & 0xf;
585                 xusb_padctl_data.hs_squelch_level = (usb_calib0 >> 11) & 0x3;
586
587                 tegra_xhci_device.dev.platform_data = &xusb_padctl_data;
588                 platform_device_register(&tegra_xhci_device);
589         }
590 }
591
592 static struct gpio modem_gpios[] = { /* Nemo modem */
593         {MODEM_EN, GPIOF_OUT_INIT_HIGH, "MODEM EN"},
594         {MDM_RST, GPIOF_OUT_INIT_LOW, "MODEM RESET"},
595 };
596
597 static struct tegra_usb_platform_data tegra_ehci2_hsic_baseband_pdata = {
598         .port_otg = false,
599         .has_hostpc = true,
600         .unaligned_dma_buf_supported = false,
601         .phy_intf = TEGRA_USB_PHY_INTF_HSIC,
602         .op_mode = TEGRA_USB_OPMODE_HOST,
603         .u_data.host = {
604                 .vbus_gpio = -1,
605                 .hot_plug = false,
606                 .remote_wakeup_supported = true,
607                 .power_off_on_suspend = true,
608         },
609 };
610
611 static int baseband_init(void)
612 {
613         int ret;
614
615         ret = gpio_request_array(modem_gpios, ARRAY_SIZE(modem_gpios));
616         if (ret) {
617                 pr_warn("%s:gpio request failed\n", __func__);
618                 return ret;
619         }
620
621         /* enable pull-down for MDM_COLD_BOOT */
622         tegra_pinmux_set_pullupdown(TEGRA_PINGROUP_KB_COL5,
623                                     TEGRA_PUPD_PULL_DOWN);
624
625         /* export GPIO for user space access through sysfs */
626         gpio_export(MDM_RST, false);
627
628         return 0;
629 }
630
631 static const struct tegra_modem_operations baseband_operations = {
632         .init = baseband_init,
633 };
634
635 static struct tegra_usb_modem_power_platform_data baseband_pdata = {
636         .ops = &baseband_operations,
637         .wake_gpio = -1,
638         .boot_gpio = MDM_COLDBOOT,
639         .boot_irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
640         .autosuspend_delay = 2000,
641         .short_autosuspend_delay = 50,
642         .tegra_ehci_device = &tegra_ehci2_device,
643         .tegra_ehci_pdata = &tegra_ehci2_hsic_baseband_pdata,
644 };
645
646 static struct platform_device icera_nemo_device = {
647         .name = "tegra_usb_modem_power",
648         .id = -1,
649         .dev = {
650                 .platform_data = &baseband_pdata,
651         },
652 };
653
654 static void dalmore_modem_init(void)
655 {
656         int modem_id = tegra_get_modem_id();
657         int usb_port_owner_info = tegra_get_usb_port_owner_info();
658         switch (modem_id) {
659         case TEGRA_BB_NEMO: /* on board i500 HSIC */
660                 if (!(usb_port_owner_info & HSIC1_PORT_OWNER_XUSB))
661                         platform_device_register(&icera_nemo_device);
662                 break;
663         }
664 }
665
666 #else
667 static void dalmore_usb_init(void) { }
668 static void dalmore_modem_init(void) { }
669 static void dalmore_xusb_init(void) { }
670 #endif
671
672 static void dalmore_audio_init(void)
673 {
674         dalmore_audio_pdata.codec_name = "rt5640.0-001c";
675         dalmore_audio_pdata.codec_dai_name = "rt5640-aif1";
676 }
677
678 #ifndef CONFIG_USE_OF
679 static struct platform_device *dalmore_spi_devices[] __initdata = {
680         &tegra11_spi_device4,
681 };
682
683 static struct tegra_spi_platform_data dalmore_spi_pdata = {
684         .dma_req_sel            = 0,
685         .spi_max_frequency      = 25000000,
686         .clock_always_on        = false,
687 };
688
689 static void __init dalmore_spi_init(void)
690 {
691         tegra11_spi_device4.dev.platform_data = &dalmore_spi_pdata;
692         platform_add_devices(dalmore_spi_devices,
693                                 ARRAY_SIZE(dalmore_spi_devices));
694 }
695 #else
696 static void __init dalmore_spi_init(void)
697 {
698 }
699 #endif
700
701 static __initdata struct tegra_clk_init_table touch_clk_init_table[] = {
702         /* name         parent          rate            enabled */
703         { "extern2",    "pll_p",        41000000,       false},
704         { "clk_out_2",  "extern2",      40800000,       false},
705         { NULL,         NULL,           0,              0},
706 };
707
708 struct rm_spi_ts_platform_data rm31080ts_dalmore_data = {
709         .gpio_reset = 0,
710         .config = 0,
711         .platform_id = RM_PLATFORM_D010,
712         .name_of_clock = "clk_out_2",
713 };
714
715 static struct tegra_spi_device_controller_data dev_cdata = {
716         .rx_clk_tap_delay = 0,
717         .tx_clk_tap_delay = 16,
718 };
719
720 struct spi_board_info rm31080a_dalmore_spi_board[1] = {
721         {
722          .modalias = "rm_ts_spidev",
723          .bus_num = 3,
724          .chip_select = 2,
725          .max_speed_hz = 12 * 1000 * 1000,
726          .mode = SPI_MODE_0,
727          .controller_data = &dev_cdata,
728          .platform_data = &rm31080ts_dalmore_data,
729          },
730 };
731
732 static int __init dalmore_touch_init(void)
733 {
734         tegra_clk_init_from_table(touch_clk_init_table);
735         clk_enable(tegra_get_clock_by_name("clk_out_2"));
736         if (display_board_info.board_id == BOARD_E1582)
737                 rm31080ts_dalmore_data.platform_id = RM_PLATFORM_P005;
738         else
739                 rm31080ts_dalmore_data.platform_id = RM_PLATFORM_D010;
740         mdelay(20);
741         rm31080a_dalmore_spi_board[0].irq = gpio_to_irq(TOUCH_GPIO_IRQ_RAYDIUM_SPI);
742         touch_init_raydium(TOUCH_GPIO_IRQ_RAYDIUM_SPI,
743                                 TOUCH_GPIO_RST_RAYDIUM_SPI,
744                                 &rm31080ts_dalmore_data,
745                                 &rm31080a_dalmore_spi_board[0],
746                                 ARRAY_SIZE(rm31080a_dalmore_spi_board));
747         return 0;
748 }
749
750 #ifdef CONFIG_EDP_FRAMEWORK
751 static struct edp_manager battery_edp_manager = {
752         .name = "battery",
753         .max = 9500
754 };
755
756 static void __init dalmore_battery_edp_init(void)
757 {
758         struct edp_governor *g;
759         int r;
760
761         r = edp_register_manager(&battery_edp_manager);
762         if (r)
763                 goto err_ret;
764
765         /* start with priority governor */
766         g = edp_get_governor("priority");
767         if (!g) {
768                 r = -EFAULT;
769                 goto err_ret;
770         }
771
772         r = edp_set_governor(&battery_edp_manager, g);
773         if (r)
774                 goto err_ret;
775
776         return;
777
778 err_ret:
779         pr_err("Battery EDP init failed with error %d\n", r);
780         WARN_ON(1);
781 }
782 #else
783 static inline void dalmore_battery_edp_init(void) {}
784 #endif
785
786 #ifdef CONFIG_USE_OF
787 struct of_dev_auxdata dalmore_auxdata_lookup[] __initdata = {
788         OF_DEV_AUXDATA("nvidia,tegra114-apbdma", 0x6000a000, "tegra-dma", NULL),
789         OF_DEV_AUXDATA("nvidia,tegra114-sdhci", 0x78000600, "sdhci-tegra.3",
790                                 NULL),
791         OF_DEV_AUXDATA("nvidia,tegra114-sdhci", 0x78000400, "sdhci-tegra.2",
792                                 NULL),
793         OF_DEV_AUXDATA("nvidia,tegra114-sdhci", 0x78000000, "sdhci-tegra.0",
794                                 &dalmore_tegra_sdhci_platform_data0),
795         OF_DEV_AUXDATA("nvidia,tegra114-camera", 0x0, "tegra_camera",
796                                 NULL),
797         OF_DEV_AUXDATA("nvidia,tegra114-host1x", TEGRA_HOST1X_BASE, "host1x",
798                                 NULL),
799         OF_DEV_AUXDATA("nvidia,tegra114-gr3d", TEGRA_GR3D_BASE, "gr3d",
800                                 NULL),
801         OF_DEV_AUXDATA("nvidia,tegra114-gr2d", TEGRA_GR2D_BASE, "gr2d",
802                                 NULL),
803         OF_DEV_AUXDATA("nvidia,tegra114-msenc", TEGRA_MSENC_BASE, "msenc",
804                                 NULL),
805         OF_DEV_AUXDATA("nvidia,tegra114-vi", TEGRA_VI_BASE, "vi",
806                                 NULL),
807         OF_DEV_AUXDATA("nvidia,tegra114-isp", TEGRA_ISP_BASE, "isp",
808                                 NULL),
809         OF_DEV_AUXDATA("nvidia,tegra114-tsec", TEGRA_TSEC_BASE, "tsec",
810                                 NULL),
811
812         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c000, "tegra11-i2c.0",
813                                 NULL),
814         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c400, "tegra11-i2c.1",
815                                 NULL),
816         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c500, "tegra11-i2c.2",
817                                 NULL),
818         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000c700, "tegra11-i2c.3",
819                                 NULL),
820         OF_DEV_AUXDATA("nvidia,tegra114-i2c", 0x7000d000, "tegra11-i2c.4",
821                                 NULL),
822         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000d400, "spi-tegra114.0",
823                                 NULL),
824         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000d600, "spi-tegra114.1",
825                                 NULL),
826         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000d800, "spi-tegra114.2",
827                                 NULL),
828         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000da00, "spi-tegra114.3",
829                                 NULL),
830         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000dc00, "spi-tegra114.4",
831                                 NULL),
832         OF_DEV_AUXDATA("nvidia,tegra114-spi", 0x7000de00, "spi-tegra114.5",
833                                 NULL),
834
835         {}
836 };
837 #endif
838
839 static void __init tegra_dalmore_early_init(void)
840 {
841         dalmore_battery_edp_init();
842         tegra_clk_init_from_table(dalmore_clk_init_table);
843         tegra_clk_vefify_parents();
844         tegra_smmu_init();
845         tegra_soc_device_init("dalmore");
846 }
847
848 static void __init tegra_dalmore_late_init(void)
849 {
850         platform_device_register(&tegra_pinmux_device);
851         dalmore_pinmux_init();
852         dalmore_i2c_init();
853         dalmore_spi_init();
854         dalmore_usb_init();
855         dalmore_xusb_init();
856         dalmore_uart_init();
857         dalmore_audio_init();
858         platform_add_devices(dalmore_devices, ARRAY_SIZE(dalmore_devices));
859         //tegra_ram_console_debug_init();
860         tegra_io_dpd_init();
861         dalmore_regulator_init();
862         dalmore_sdhci_init();
863         dalmore_suspend_init();
864         dalmore_emc_init();
865         dalmore_edp_init();
866         isomgr_init();
867         dalmore_touch_init();
868         if (board_info.board_id == BOARD_E1582)
869                 roth_panel_init();
870         else
871                 dalmore_panel_init();
872         dalmore_kbc_init();
873         dalmore_pmon_init();
874 #if defined(CONFIG_BT_BLUESLEEP) || defined(CONFIG_BT_BLUESLEEP_MODULE)
875         dalmore_setup_bluesleep();
876         dalmore_setup_bt_rfkill();
877 #elif defined CONFIG_BLUEDROID_PM
878         dalmore_setup_bluedroid_pm();
879 #endif
880         tegra_release_bootloader_fb();
881         dalmore_modem_init();
882 #ifdef CONFIG_TEGRA_WDT_RECOVERY
883         tegra_wdt_recovery_init();
884 #endif
885         tegra_serial_debug_init(TEGRA_UARTD_BASE, INT_WDT_CPU, NULL, -1, -1);
886         dalmore_sensors_init();
887         dalmore_soctherm_init();
888         tegra_register_fuse();
889 }
890
891 static void __init dalmore_ramconsole_reserve(unsigned long size)
892 {
893         tegra_ram_console_debug_reserve(SZ_1M);
894 }
895
896 static void __init tegra_dalmore_dt_init(void)
897 {
898         tegra_get_board_info(&board_info);
899         tegra_get_display_board_info(&display_board_info);
900
901         tegra_dalmore_early_init();
902
903         of_platform_populate(NULL,
904                 of_default_bus_match_table, dalmore_auxdata_lookup,
905                 &platform_bus);
906
907         tegra_dalmore_late_init();
908 }
909
910 static void __init tegra_dalmore_reserve(void)
911 {
912 #if defined(CONFIG_NVMAP_CONVERT_CARVEOUT_TO_IOVMM)
913         /* 1920*1200*4*2 = 18432000 bytes */
914         tegra_reserve(0, SZ_16M + SZ_2M, SZ_16M);
915 #else
916         tegra_reserve(SZ_128M, SZ_16M + SZ_2M, SZ_4M);
917 #endif
918         dalmore_ramconsole_reserve(SZ_1M);
919 }
920
921 static const char * const dalmore_dt_board_compat[] = {
922         "nvidia,dalmore",
923         NULL
924 };
925
926 MACHINE_START(DALMORE, "dalmore")
927         .atag_offset    = 0x100,
928         .smp            = smp_ops(tegra_smp_ops),
929         .map_io         = tegra_map_common_io,
930         .reserve        = tegra_dalmore_reserve,
931         .init_early     = tegra11x_init_early,
932         .init_irq       = tegra_dt_init_irq,
933         .handle_irq     = gic_handle_irq,
934         .timer          = &tegra_timer,
935         .init_machine   = tegra_dalmore_dt_init,
936         .restart        = tegra_assert_system_reset,
937         .dt_compat      = dalmore_dt_board_compat,
938 MACHINE_END