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