ARM: tegra: dalmore: Enable pull-down for MDM_COLD_BOOT
[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         /* enable pull-down for MDM_COLD_BOOT */
536         tegra_pinmux_set_pullupdown(TEGRA_PINGROUP_KB_COL5,
537                                     TEGRA_PUPD_PULL_DOWN);
538
539         /* export GPIO for user space access through sysfs */
540         gpio_export(MDM_RST, false);
541
542         return 0;
543 }
544
545 static const struct tegra_modem_operations baseband_operations = {
546         .init = baseband_init,
547 };
548
549 static struct tegra_usb_modem_power_platform_data baseband_pdata = {
550         .ops = &baseband_operations,
551         .wake_gpio = -1,
552         .boot_gpio = MDM_COLDBOOT,
553         .boot_irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
554         .autosuspend_delay = 2000,
555         .short_autosuspend_delay = 50,
556         .tegra_ehci_device = &tegra_ehci2_device,
557         .tegra_ehci_pdata = &tegra_ehci2_hsic_baseband_pdata,
558 };
559
560 static struct platform_device icera_nemo_device = {
561         .name = "tegra_usb_modem_power",
562         .id = -1,
563         .dev = {
564                 .platform_data = &baseband_pdata,
565         },
566 };
567
568 static void dalmore_modem_init(void)
569 {
570         platform_device_register(&icera_nemo_device);
571 }
572
573 #else
574 static void dalmore_usb_init(void) { }
575 static void dalmore_modem_init(void) { }
576 #endif
577
578 static void dalmore_audio_init(void)
579 {
580         struct board_info board_info;
581
582         tegra_get_board_info(&board_info);
583
584         dalmore_audio_pdata.codec_name = "rt5640.0-001c";
585         dalmore_audio_pdata.codec_dai_name = "rt5640-aif1";
586 }
587
588
589 static struct platform_device *dalmore_spi_devices[] __initdata = {
590         &tegra11_spi_device4,
591 };
592
593 struct spi_clk_parent spi_parent_clk_dalmore[] = {
594         [0] = {.name = "pll_p"},
595 #ifndef CONFIG_TEGRA_PLLM_RESTRICTED
596         [1] = {.name = "pll_m"},
597         [2] = {.name = "clk_m"},
598 #else
599         [1] = {.name = "clk_m"},
600 #endif
601 };
602
603 static struct tegra_spi_platform_data dalmore_spi_pdata = {
604         .is_dma_based           = false,
605         .max_dma_buffer         = 16 * 1024,
606         .is_clkon_always        = false,
607         .max_rate               = 25000000,
608 };
609
610 static void __init dalmore_spi_init(void)
611 {
612         int i;
613         struct clk *c;
614         struct board_info board_info, display_board_info;
615
616         tegra_get_board_info(&board_info);
617         tegra_get_display_board_info(&display_board_info);
618
619         for (i = 0; i < ARRAY_SIZE(spi_parent_clk_dalmore); ++i) {
620                 c = tegra_get_clock_by_name(spi_parent_clk_dalmore[i].name);
621                 if (IS_ERR_OR_NULL(c)) {
622                         pr_err("Not able to get the clock for %s\n",
623                                                 spi_parent_clk_dalmore[i].name);
624                         continue;
625                 }
626                 spi_parent_clk_dalmore[i].parent_clk = c;
627                 spi_parent_clk_dalmore[i].fixed_clk_rate = clk_get_rate(c);
628         }
629         dalmore_spi_pdata.parent_clk_list = spi_parent_clk_dalmore;
630         dalmore_spi_pdata.parent_clk_count = ARRAY_SIZE(spi_parent_clk_dalmore);
631         tegra11_spi_device4.dev.platform_data = &dalmore_spi_pdata;
632         platform_add_devices(dalmore_spi_devices,
633                                 ARRAY_SIZE(dalmore_spi_devices));
634 }
635
636 static __initdata struct tegra_clk_init_table touch_clk_init_table[] = {
637         /* name         parent          rate            enabled */
638         { "extern2",    "pll_p",        41000000,       false},
639         { "clk_out_2",  "extern2",      40800000,       false},
640         { NULL,         NULL,           0,              0},
641 };
642
643 struct rm_spi_ts_platform_data rm31080ts_dalmore_data = {
644         .gpio_reset = 0,
645         .config = 0,
646         .platform_id = RM_PLATFORM_D010,
647         .name_of_clock = "clk_out_2",
648 };
649
650 static struct tegra_spi_device_controller_data dev_cdata = {
651         .rx_clk_tap_delay = 0,
652         .tx_clk_tap_delay = 16,
653 };
654
655 struct spi_board_info rm31080a_dalmore_spi_board[1] = {
656         {
657          .modalias = "rm_ts_spidev",
658          .bus_num = 3,
659          .chip_select = 2,
660          .max_speed_hz = 18 * 1000 * 1000,
661          .mode = SPI_MODE_0,
662          .controller_data = &dev_cdata,
663          .platform_data = &rm31080ts_dalmore_data,
664          },
665 };
666
667 static int __init dalmore_touch_init(void)
668 {
669         struct board_info board_info;
670
671         tegra_get_display_board_info(&board_info);
672         tegra_clk_init_from_table(touch_clk_init_table);
673         clk_enable(tegra_get_clock_by_name("clk_out_2"));
674         if (board_info.board_id == BOARD_E1582)
675                 rm31080ts_dalmore_data.platform_id = RM_PLATFORM_P005;
676         else
677                 rm31080ts_dalmore_data.platform_id = RM_PLATFORM_D010;
678         mdelay(20);
679         rm31080a_dalmore_spi_board[0].irq = gpio_to_irq(TOUCH_GPIO_IRQ_RAYDIUM_SPI);
680         touch_init_raydium(TOUCH_GPIO_IRQ_RAYDIUM_SPI,
681                                 TOUCH_GPIO_RST_RAYDIUM_SPI,
682                                 &rm31080ts_dalmore_data,
683                                 &rm31080a_dalmore_spi_board[0],
684                                 ARRAY_SIZE(rm31080a_dalmore_spi_board));
685         return 0;
686 }
687
688 static void __init tegra_dalmore_init(void)
689 {
690         struct board_info board_info;
691
692         tegra_get_display_board_info(&board_info);
693         tegra_battery_edp_init(2500);
694         tegra_clk_init_from_table(dalmore_clk_init_table);
695         tegra_soc_device_init("dalmore");
696         tegra_enable_pinmux();
697         dalmore_pinmux_init();
698         dalmore_i2c_init();
699         dalmore_spi_init();
700         dalmore_usb_init();
701         dalmore_uart_init();
702         dalmore_audio_init();
703         platform_add_devices(dalmore_devices, ARRAY_SIZE(dalmore_devices));
704         //tegra_ram_console_debug_init();
705         tegra_io_dpd_init();
706         dalmore_regulator_init();
707         dalmore_sdhci_init();
708         dalmore_suspend_init();
709         dalmore_emc_init();
710         dalmore_edp_init();
711         dalmore_touch_init();
712         if (board_info.board_id == BOARD_E1582)
713                 roth_panel_init();
714         else
715                 dalmore_panel_init();
716         dalmore_kbc_init();
717         dalmore_pmon_init();
718         dalmore_setup_bluesleep();
719         dalmore_setup_bt_rfkill();
720         tegra_release_bootloader_fb();
721         dalmore_modem_init();
722 #ifdef CONFIG_TEGRA_WDT_RECOVERY
723         tegra_wdt_recovery_init();
724 #endif
725         tegra_serial_debug_init(TEGRA_UARTD_BASE, INT_WDT_CPU, NULL, -1, -1);
726         dalmore_sensors_init();
727         dalmore_soctherm_init();
728 }
729
730 static void __init dalmore_ramconsole_reserve(unsigned long size)
731 {
732         tegra_ram_console_debug_reserve(SZ_1M);
733 }
734
735 static void __init tegra_dalmore_dt_init(void)
736 {
737         tegra_dalmore_init();
738
739         of_platform_populate(NULL,
740                 of_default_bus_match_table, NULL, NULL);
741 }
742
743 static void __init tegra_dalmore_reserve(void)
744 {
745 #if defined(CONFIG_NVMAP_CONVERT_CARVEOUT_TO_IOVMM)
746         /* 1920*1200*4*2 = 18432000 bytes */
747         tegra_reserve(0, SZ_16M + SZ_2M, SZ_4M);
748 #else
749         tegra_reserve(SZ_128M, SZ_16M + SZ_2M, SZ_4M);
750 #endif
751         dalmore_ramconsole_reserve(SZ_1M);
752 }
753
754 static const char * const dalmore_dt_board_compat[] = {
755         "nvidia,dalmore",
756         NULL
757 };
758
759 MACHINE_START(DALMORE, "dalmore")
760         .atag_offset    = 0x100,
761         .smp            = smp_ops(tegra_smp_ops),
762         .map_io         = tegra_map_common_io,
763         .reserve        = tegra_dalmore_reserve,
764 #ifdef CONFIG_ARCH_TEGRA_3x_SOC
765         .init_early     = tegra30_init_early,
766 #else
767         .init_early     = tegra11x_init_early,
768 #endif
769         .init_irq       = tegra_init_irq,
770         .handle_irq     = gic_handle_irq,
771         .timer          = &tegra_timer,
772         .init_machine   = tegra_dalmore_dt_init,
773         .restart        = tegra_assert_system_reset,
774         .dt_compat      = dalmore_dt_board_compat,
775 MACHINE_END