ARM: tegra: vcm30_t124: Enable more interfaces
[linux-3.10.git] / arch / arm / mach-tegra / board-vcm30_t124.c
1 /*
2  * arch/arm/mach-tegra/board-vcm30_t124.c
3  *
4  * Copyright (c) 2013, NVIDIA CORPORATION.  All rights reserved.
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms and conditions of the GNU General Public License,
8  * version 2, as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope 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
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18
19 #include <linux/platform_device.h>
20 #include <linux/i2c-tegra.h>
21 #include <linux/i2c.h>
22 #include <linux/platform_data/serial-tegra.h>
23 #include <linux/platform_data/tegra_usb.h>
24 #include <linux/platform_data/tegra_nor.h>
25 #include <linux/platform_data/tegra_ahci.h>
26 #include <linux/spi/spi-tegra.h>
27 #include <linux/of_platform.h>
28 #include <linux/kernel.h>
29
30 #include <mach/tegra_asoc_pdata.h>
31 #include <mach/pci.h>
32 #include <mach/io_dpd.h>
33 #include <asm/mach/arch.h>
34 #include <mach/isomgr.h>
35
36 #include "iomap.h"
37 #include "board.h"
38 #include "clock.h"
39 #include "board-vcm30_t124.h"
40 #include "devices.h"
41 #include "board-common.h"
42 #include "common.h"
43
44 #include <asm/mach-types.h>
45
46 static struct board_info board_info, display_board_info;
47
48 static __initdata struct tegra_clk_init_table vcm30_t124_clk_init_table[] = {
49         /* name         parent          rate            enabled (always on)*/
50         { "pll_m",      NULL,           0,              false},
51         { "hda",        "pll_p",        108000000,      false},
52         { "hda2codec_2x", "pll_p",      48000000,       false},
53         { "pwm",        "pll_p",        3187500,        false},
54         { "i2s1",       "pll_a_out0",   0,              false},
55         { "i2s3",       "pll_a_out0",   0,              false},
56         { "i2s4",       "pll_a_out0",   0,              false},
57         { "spdif_out",  "pll_a_out0",   0,              false},
58         { "d_audio",    "clk_m",        12000000,       false},
59         { "dam0",       "clk_m",        12000000,       false},
60         { "dam1",       "clk_m",        12000000,       false},
61         { "dam2",       "clk_m",        12000000,       false},
62         { "audio1",     "i2s1_sync",    0,              false},
63         { "audio3",     "i2s3_sync",    0,              false},
64         { "vi_sensor",  "pll_p",        150000000,      false},
65         { "vi_sensor2", "pll_p",        150000000,      false},
66         { "cilab",      "pll_p",        150000000,      false},
67         { "cilcd",      "pll_p",        150000000,      false},
68         { "cile",       "pll_p",        150000000,      false},
69         { "i2c1",       "pll_p",        3200000,        false},
70         { "i2c2",       "pll_p",        3200000,        false},
71         { "i2c3",       "pll_p",        3200000,        false},
72         { "i2c4",       "pll_p",        3200000,        false},
73         { "i2c5",       "pll_p",        3200000,        false},
74         { "sbc1",       "pll_p",        25000000,       false},
75         { "sbc2",       "pll_p",        25000000,       false},
76         { "sbc3",       "pll_p",        25000000,       false},
77         { "sbc4",       "pll_p",        25000000,       false},
78         { "sbc5",       "pll_p",        25000000,       false},
79         { "sbc6",       "pll_p",        25000000,       false},
80         { "uarta",      "pll_p",        408000000,      false},
81         { "uartb",      "pll_p",        408000000,      false},
82         { "uartc",      "pll_p",        408000000,      false},
83         { "uartd",      "pll_p",        408000000,      false},
84         { "nor",        "pll_p",        102000000,      true},
85         { NULL,         NULL,           0,              0},
86 };
87
88 static struct tegra_i2c_platform_data vcm30_t124_i2c1_platform_data = {
89         .bus_clk_rate   = 100000,
90         .scl_gpio       = TEGRA_GPIO_I2C1_SCL,
91         .sda_gpio       = TEGRA_GPIO_I2C1_SDA,
92 };
93
94 static struct tegra_i2c_platform_data vcm30_t124_i2c2_platform_data = {
95         .bus_clk_rate   = 100000,
96         .is_clkon_always = true,
97         .scl_gpio       = TEGRA_GPIO_I2C2_SCL,
98         .sda_gpio       = TEGRA_GPIO_I2C2_SDA,
99 };
100
101 static struct tegra_i2c_platform_data vcm30_t124_i2c3_platform_data = {
102         .bus_clk_rate   = 400000,
103         .scl_gpio       = TEGRA_GPIO_I2C3_SCL,
104         .sda_gpio       = TEGRA_GPIO_I2C3_SDA,
105 };
106
107 static struct tegra_i2c_platform_data vcm30_t124_i2c4_platform_data = {
108         .bus_clk_rate   = 10000,
109         .scl_gpio       = TEGRA_GPIO_I2C4_SCL,
110         .sda_gpio       = TEGRA_GPIO_I2C4_SDA,
111 };
112
113 static struct tegra_i2c_platform_data vcm30_t124_i2c5_platform_data = {
114         .bus_clk_rate   = 400000,
115         .scl_gpio       = TEGRA_GPIO_I2C5_SCL,
116         .sda_gpio       = TEGRA_GPIO_I2C5_SDA,
117 };
118
119 static struct tegra_nor_platform_data vcm30_t124_nor_data = {
120         .flash = {
121                 .map_name = "cfi_probe",
122                 .width = 2,
123         },
124         .chip_parms = {
125                 .MuxMode = NorMuxMode_ADNonMux,
126                 .ReadMode = NorReadMode_Page,
127                 .PageLength = NorPageLength_8Word,
128                 .ReadyActive = NorReadyActive_WithData,
129                 /* FIXME: Need to use characterized value */
130                 .timing_default = {
131                         .timing0 = 0x30300273,
132                         .timing1 = 0x00030302,
133                 },
134                 .timing_read = {
135                         .timing0 = 0x30300273,
136                         .timing1 = 0x00030302,
137                 },
138         },
139 };
140
141 static struct cs_info vcm30_t124_cs_info[] = {
142         {
143                 .cs = CS_0,
144                 .num_cs_gpio = 0,
145                 .virt = IO_ADDRESS(TEGRA_NOR_FLASH_BASE),
146                 .size = SZ_64M,
147                 .phys = TEGRA_NOR_FLASH_BASE,
148         },
149 };
150
151 static void vcm30_t124_nor_init(void)
152 {
153         tegra_nor_device.resource[2].end = TEGRA_NOR_FLASH_BASE + SZ_64M - 1;
154
155         vcm30_t124_nor_data.info.cs = kzalloc(sizeof(struct cs_info) *
156                                         ARRAY_SIZE(vcm30_t124_cs_info),
157                                         GFP_KERNEL);
158         if (!vcm30_t124_nor_data.info.cs)
159                 BUG();
160
161         vcm30_t124_nor_data.info.num_chips = ARRAY_SIZE(vcm30_t124_cs_info);
162
163         memcpy(vcm30_t124_nor_data.info.cs, vcm30_t124_cs_info,
164                                 sizeof(struct cs_info) * ARRAY_SIZE(vcm30_t124_cs_info));
165
166         tegra_nor_device.dev.platform_data = &vcm30_t124_nor_data;
167         platform_device_register(&tegra_nor_device);
168 }
169
170
171 static void vcm30_t124_i2c_init(void)
172 {
173         struct board_info board_info;
174         tegra_get_board_info(&board_info);
175         /* T124 does not use device tree as of now */
176         tegra12_i2c_device1.dev.platform_data = &vcm30_t124_i2c1_platform_data;
177         tegra12_i2c_device2.dev.platform_data = &vcm30_t124_i2c2_platform_data;
178         tegra12_i2c_device3.dev.platform_data = &vcm30_t124_i2c3_platform_data;
179         tegra12_i2c_device4.dev.platform_data = &vcm30_t124_i2c4_platform_data;
180         tegra12_i2c_device5.dev.platform_data = &vcm30_t124_i2c5_platform_data;
181
182         platform_device_register(&tegra12_i2c_device5);
183         platform_device_register(&tegra12_i2c_device4);
184         platform_device_register(&tegra12_i2c_device3);
185         platform_device_register(&tegra12_i2c_device2);
186         platform_device_register(&tegra12_i2c_device1);
187 }
188
189 /* Register debug UART in old fashion and use DT for all others */
190 #ifndef CONFIG_USE_OF
191 static struct platform_device *vcm30_t124_uart_devices[] __initdata = {
192         &tegra_uarta_device,
193         &tegra_uartb_device,
194         &tegra_uartd_device,
195 };
196
197 static struct tegra_serial_platform_data vcm30_t124_uarta_pdata = {
198         .dma_req_selector = 8,
199         .modem_interrupt = false,
200 };
201
202 static struct tegra_serial_platform_data vcm30_t124_uartb_pdata = {
203         .dma_req_selector = 9,
204         .modem_interrupt = false,
205 };
206
207 static struct tegra_serial_platform_data vcm30_t124_uartd_pdata = {
208         .dma_req_selector = 19,
209         .modem_interrupt = false,
210 };
211 #endif
212
213 static struct tegra_serial_platform_data vcm30_t124_uartc_pdata = {
214         .dma_req_selector = 10,
215         .modem_interrupt = false,
216 };
217
218 static void __init vcm30_t124_uart_init(void)
219 {
220         int debug_port_id;
221
222 #ifndef CONFIG_USE_OF
223         tegra_uarta_device.dev.platform_data = &vcm30_t124_uarta_pdata;
224         tegra_uartb_device.dev.platform_data = &vcm30_t124_uartb_pdata;
225         tegra_uartd_device.dev.platform_data = &vcm30_t124_uartd_pdata;
226         platform_add_devices(vcm30_t124_uart_devices,
227                         ARRAY_SIZE(vcm30_t124_uart_devices));
228 #endif
229         tegra_uartc_device.dev.platform_data = &vcm30_t124_uartc_pdata;
230         if (!is_tegra_debug_uartport_hs()) {
231                 debug_port_id = uart_console_debug_init(2);
232                 if (debug_port_id < 0)
233                         return;
234
235                 platform_device_register(uart_console_debug_device);
236         } else {
237                 tegra_uartc_device.dev.platform_data = &vcm30_t124_uartc_pdata;
238                 platform_device_register(&tegra_uartc_device);
239         }
240
241 }
242
243 static struct resource tegra_rtc_resources[] = {
244         [0] = {
245                 .start = TEGRA_RTC_BASE,
246                 .end = TEGRA_RTC_BASE + TEGRA_RTC_SIZE - 1,
247                 .flags = IORESOURCE_MEM,
248         },
249         [1] = {
250                 .start = INT_RTC,
251                 .end = INT_RTC,
252                 .flags = IORESOURCE_IRQ,
253         },
254 };
255
256 static struct platform_device tegra_rtc_device = {
257         .name = "tegra_rtc",
258         .id   = -1,
259         .resource = tegra_rtc_resources,
260         .num_resources = ARRAY_SIZE(tegra_rtc_resources),
261 };
262
263 static struct tegra_pci_platform_data vcm30_t124_pcie_platform_data = {
264         .port_status[0] = 1,
265         .port_status[1] = 1,
266         .use_dock_detect        = 1,
267         .gpio   = TEGRA_GPIO_PO1,
268         .gpio_x1_slot   = PMU_TCA6416_GPIO(12),
269 };
270
271 static void vcm30_t124_pcie_init(void)
272 {
273 /* FIXME: Check this for VCM30_T124 */
274 #if 0
275         struct board_info board_info;
276         /* root port 1(x1 slot) is supported only on of ERS-S board */
277         laguna_pcie_platform_data.port_status[1] = 0;
278
279         tegra_pci_device.dev.platform_data = &laguna_pcie_platform_data;
280         platform_device_register(&tegra_pci_device);
281 #endif
282 }
283
284 #ifdef CONFIG_SATA_AHCI_TEGRA
285 static struct tegra_ahci_platform_data ahci_plat_data = {
286         .gen2_rx_eq = 7,
287 };
288
289 static void vcm30_t124_sata_init(void)
290 {
291         tegra_sata_device.dev.platform_data = &ahci_plat_data;
292         platform_device_register(&tegra_sata_device);
293 }
294 #else
295 static void vcm30_t124_sata_init(void) { }
296 #endif
297
298 /* FIXME: Check which devices are needed from the below list */
299 static struct platform_device *vcm30_t124_devices[] __initdata = {
300         &tegra_pmu_device,
301         &tegra_rtc_device,
302         &tegra_udc_device,
303 #if defined(CONFIG_TEGRA_AVP)
304         &tegra_avp_device,
305 #endif
306 #if defined(CONFIG_CRYPTO_DEV_TEGRA_SE)
307         &tegra12_se_device,
308 #endif
309         &tegra_ahub_device,
310         &tegra_dam_device0,
311         &tegra_dam_device1,
312         &tegra_dam_device2,
313         &tegra_i2s_device1,
314         &tegra_i2s_device3,
315         &tegra_i2s_device4,
316         &tegra_spdif_device,
317         &spdif_dit_device,
318         &bluetooth_dit_device,
319         &tegra_hda_device,
320 };
321
322 static struct tegra_usb_platform_data tegra_ehci1_utmi_pdata = {
323         .port_otg = true,
324         .has_hostpc = true,
325         .unaligned_dma_buf_supported = true,
326         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
327         .op_mode = TEGRA_USB_OPMODE_HOST,
328         .u_data.host = {
329                 .vbus_gpio = -1,
330                 .hot_plug = false,
331                 .remote_wakeup_supported = true,
332                 .power_off_on_suspend = true,
333         },
334         .u_cfg.utmi = {
335                 .hssync_start_delay = 0,
336                 .elastic_limit = 16,
337                 .idle_wait_delay = 17,
338                 .term_range_adj = 6,
339                 .xcvr_setup = 15,
340                 .xcvr_lsfslew = 2,
341                 .xcvr_lsrslew = 2,
342                 .xcvr_setup_offset = 0,
343                 .xcvr_use_fuses = 1,
344                 .vbus_oc_map = 0x4,
345         },
346 };
347
348 static struct tegra_usb_platform_data tegra_ehci2_utmi_pdata = {
349         .port_otg = false,
350         .has_hostpc = true,
351         .unaligned_dma_buf_supported = true,
352         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
353         .op_mode = TEGRA_USB_OPMODE_HOST,
354         .u_data.host = {
355                 /* FIXME: Set this only for E1855. */
356                 .vbus_gpio = TEGRA_GPIO_PN5,
357                 .hot_plug = false,
358                 .remote_wakeup_supported = true,
359                 .power_off_on_suspend = true,
360         },
361         .u_cfg.utmi = {
362                 .hssync_start_delay = 0,
363                 .elastic_limit = 16,
364                 .idle_wait_delay = 17,
365                 .term_range_adj = 6,
366                 .xcvr_setup = 8,
367                 .xcvr_lsfslew = 2,
368                 .xcvr_lsrslew = 2,
369                 .xcvr_setup_offset = 0,
370                 .xcvr_use_fuses = 1,
371                 .vbus_oc_map = 0x5,
372         },
373 };
374
375 static struct tegra_usb_platform_data tegra_ehci3_utmi_pdata = {
376         .port_otg = false,
377         .has_hostpc = true,
378         .unaligned_dma_buf_supported = true,
379         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
380         .op_mode = TEGRA_USB_OPMODE_HOST,
381         .u_data.host = {
382                 .vbus_gpio = -1,
383                 .hot_plug = false,
384                 .remote_wakeup_supported = true,
385                 .power_off_on_suspend = true,
386         },
387         .u_cfg.utmi = {
388         .hssync_start_delay = 0,
389                 .elastic_limit = 16,
390                 .idle_wait_delay = 17,
391                 .term_range_adj = 6,
392                 .xcvr_setup = 8,
393                 .xcvr_lsfslew = 2,
394                 .xcvr_lsrslew = 2,
395                 .xcvr_setup_offset = 0,
396                 .xcvr_use_fuses = 1,
397                 .vbus_oc_map = 0x5,
398         },
399 };
400
401 static struct tegra_usb_otg_data tegra_otg_pdata = {
402         .ehci_device = &tegra_ehci1_device,
403         .ehci_pdata = &tegra_ehci1_utmi_pdata,
404 };
405
406 static void vcm30_t124_usb_init(void)
407 {
408         int usb_port_owner_info = tegra_get_usb_port_owner_info();
409
410         if (!(usb_port_owner_info & UTMI2_PORT_OWNER_XUSB)) {
411                 tegra_ehci2_device.dev.platform_data = &tegra_ehci2_utmi_pdata;
412                 platform_device_register(&tegra_ehci2_device);
413         }
414
415         if (!(usb_port_owner_info & UTMI3_PORT_OWNER_XUSB)) {
416                 tegra_ehci3_device.dev.platform_data = &tegra_ehci3_utmi_pdata;
417                 platform_device_register(&tegra_ehci3_device);
418         }
419 }
420
421 #ifndef CONFIG_USE_OF
422 static struct platform_device *vcm30_t124_spi_devices[] __initdata = {
423         &tegra11_spi_device1,
424         &tegra11_spi_device4,
425 };
426
427 static struct tegra_spi_platform_data vcm30_t124_spi1_pdata = {
428         .dma_req_sel            = 15,
429         .spi_max_frequency      = 25000000,
430         .clock_always_on        = false,
431 };
432
433 static struct tegra_spi_platform_data vcm30_t124_spi4_pdata = {
434         .dma_req_sel            = 18,
435         .spi_max_frequency      = 25000000,
436         .clock_always_on        = false,
437 };
438
439 static void __init vcm30_t124_spi_init(void)
440 {
441         tegra11_spi_device1.dev.platform_data = &vcm30_t124_spi1_pdata;
442         tegra11_spi_device4.dev.platform_data = &vcm30_t124_spi4_pdata;
443         platform_add_devices(vcm30_t124_spi_devices,
444                         ARRAY_SIZE(vcm30_t124_spi_devices));
445 }
446 #else
447 static void __init vcm30_t124_spi_init(void)
448 {
449 }
450 #endif
451
452 #ifdef CONFIG_USE_OF
453 struct of_dev_auxdata vcm30_t124_auxdata_lookup[] __initdata = {
454         OF_DEV_AUXDATA("nvidia,tegra114-hsuart", TEGRA_UARTA_BASE,
455                                 "serial-tegra.0", NULL),
456         OF_DEV_AUXDATA("nvidia,tegra114-hsuart", TEGRA_UARTB_BASE,
457                                 "serial-tegra.1", NULL),
458         OF_DEV_AUXDATA("nvidia,tegra114-hsuart", TEGRA_UARTD_BASE,
459                                 "serial-tegra.3", NULL),
460         {}
461 };
462 #endif
463
464 static void __init tegra_vcm30_t124_early_init(void)
465 {
466         tegra_clk_init_from_table(vcm30_t124_clk_init_table);
467         tegra_clk_verify_parents();
468         tegra_soc_device_init("vcm30_t124");
469 }
470
471 static void __init tegra_vcm30_t124_late_init(void)
472 {
473         struct board_info board_info;
474         tegra_get_board_info(&board_info);
475         pr_info("board_info: id:sku:fab:major:minor = 0x%04x:0x%04x:0x%02x:0x%02x:0x%02x\n",
476                 board_info.board_id, board_info.sku,
477                 board_info.fab, board_info.major_revision,
478                 board_info.minor_revision);
479         platform_device_register(&tegra_pinmux_device);
480         vcm30_t124_pinmux_init();
481         vcm30_t124_usb_init();
482 /*      vcm30_t124_xusb_init(); */
483         vcm30_t124_nor_init();
484         vcm30_t124_i2c_init();
485         vcm30_t124_spi_init();
486         vcm30_t124_uart_init();
487         platform_add_devices(vcm30_t124_devices,
488                         ARRAY_SIZE(vcm30_t124_devices));
489         tegra_io_dpd_init();
490         vcm30_t124_sdhci_init();
491         vcm30_t124_regulator_init();
492         /* vcm30_t124_suspend_init(); */
493 #if 0
494         vcm30_t124_emc_init();
495         vcm30_t124_edp_init();
496 #endif
497         isomgr_init();
498         /* vcm30_t124_panel_init(); */
499         /* vcm30_t124_pmon_init(); */
500         vcm30_t124_pcie_init();
501         vcm30_t124_sata_init();
502 #ifdef CONFIG_TEGRA_WDT_RECOVERY
503         tegra_wdt_recovery_init();
504 #endif
505         /* FIXME: Required? */
506 #if 0
507         tegra_serial_debug_init(TEGRA_UARTD_BASE, INT_WDT_CPU, NULL, -1, -1);
508
509         vcm30_t124_sensors_init();
510         vcm30_t124_soctherm_init();
511 #endif
512         tegra_register_fuse();
513 }
514
515 static void __init vcm30_t124_ramconsole_reserve(unsigned long size)
516 {
517         tegra_ram_console_debug_reserve(SZ_1M);
518 }
519
520 static void __init tegra_vcm30_t124_dt_init(void)
521 {
522         tegra_get_board_info(&board_info);
523         tegra_get_display_board_info(&display_board_info);
524
525         tegra_vcm30_t124_early_init();
526 #ifdef CONFIG_USE_OF
527         of_platform_populate(NULL,
528                 of_default_bus_match_table, vcm30_t124_auxdata_lookup,
529                 &platform_bus);
530 #endif
531
532         tegra_vcm30_t124_late_init();
533 }
534
535 static void __init tegra_vcm30_t124_reserve(void)
536 {
537 #if defined(CONFIG_NVMAP_CONVERT_CARVEOUT_TO_IOVMM)
538         /* 1920*1200*4*2 = 18432000 bytes */
539         tegra_reserve(0, SZ_16M + SZ_2M, SZ_16M);
540 #else
541         tegra_reserve(SZ_128M, SZ_16M + SZ_2M, SZ_4M);
542 #endif
543         vcm30_t124_ramconsole_reserve(SZ_1M);
544 }
545
546 static const char * const vcm30_t124_dt_board_compat[] = {
547         "nvidia,vcm30_t124",
548         NULL
549 };
550
551 DT_MACHINE_START(VCM30_T124, "vcm30_t124")
552         .atag_offset    = 0x100,
553         .smp            = smp_ops(tegra_smp_ops),
554         .map_io         = tegra_map_common_io,
555         .reserve        = tegra_vcm30_t124_reserve,
556         .init_early     = tegra12x_init_early,
557         .init_irq       = tegra_dt_init_irq,
558         .init_time      = tegra_init_timer,
559         .init_machine   = tegra_vcm30_t124_dt_init,
560         .restart        = tegra_assert_system_reset,
561         .dt_compat      = vcm30_t124_dt_board_compat,
562         .init_late      = tegra_init_late
563 MACHINE_END