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