ARM: tegra: move pinmux table to DT for vcm30-t124
[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-2014, 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/of_platform.h>
27 #include <linux/kernel.h>
28 #include <linux/clocksource.h>
29 #include <linux/irqchip.h>
30 #include <linux/pci-tegra.h>
31
32 #include <mach/tegra_asoc_pdata.h>
33 #include <mach/io_dpd.h>
34 #include <asm/mach/arch.h>
35 #include <mach/isomgr.h>
36
37 #include "iomap.h"
38 #include "board.h"
39 #include "clock.h"
40 #include "board-vcm30_t124.h"
41 #include "devices.h"
42 #include "board-common.h"
43 #include "common.h"
44
45 #include <asm/mach-types.h>
46 #include "tegra-of-dev-auxdata.h"
47
48 static struct board_info board_info, display_board_info;
49
50 /*
51  * Set clock values as per automotive POR
52  */
53 static __initdata struct tegra_clk_init_table vcm30_t124_clk_init_table[] = {
54         /* name                 parent          rate    enabled (always on)*/
55
56         { "pll_c",              NULL,           792000000,      true},
57
58         { "automotive.sclk",    NULL,           316800000,      true},
59         { "automotive.hclk",    NULL,           316800000,      true},
60         { "automotive.pclk",    NULL,           158400000,      true},
61
62         { "mselect",            "pll_p",        408000000,      true},
63         /* FIXME: Remove this once the issue with cap.vcore.mselect is fixed */
64         { "override.mselect",   NULL,           408000000,      true},
65
66         { "se.cbus",            NULL,           432000000,      false},
67         { "msenc.cbus",         NULL,           432000000,      false},
68         { "vde.cbus",           NULL,           432000000,      false},
69
70         { "vic03.cbus",         NULL,           660000000,      false},
71         { "tsec.cbus",          NULL,           660000000,      false},
72
73         { "vi.c4bus",           NULL,           600000000,      false},
74         { "isp.c4bus",          NULL,           600000000,      false},
75
76         { "pll_d_out0",         "pll_d",        474000000,      true},
77         { "disp2",              "pll_d_out0",   474000000,      false},
78         { "disp1",              "pll_d_out0",   474000000,      false},
79
80         { "pll_d2",             NULL,           297000000,      true},
81         { "hdmi",               "pll_d2",       297000000,      false},
82
83         { "pll_a_out0",         NULL,           24600000,       true},
84         { "i2s0",               "pll_a_out0",   24600000,       false},
85         { "i2s1",               "pll_a_out0",   24600000,       false},
86         { "i2s2",               "pll_a_out0",   24600000,       false},
87         { "i2s3",               "pll_a_out0",   24600000,       false},
88         { "i2s4",               "pll_a_out0",   24600000,       false},
89
90         { "dam0",               "pll_p",        19900000,       false},
91         { "dam1",               "pll_p",        19900000,       false},
92         { "dam2",               "pll_p",        19900000,       false},
93         { "adx",                "pll_p",        19900000,       false},
94         { "adx1",               "pll_p",        19900000,       false},
95         { "amx",                "pll_p",        19900000,       false},
96         { "amx1",               "pll_p",        19900000,       false},
97
98         { "spdif_out",          "pll_a_out0",   24600000,       false},
99         { "hda",                "pll_p",        48000000,       false},
100         { "cilab",              "pll_p",        10200000,       false},
101         { "cilcd",              "pll_p",        10200000,       false},
102         { "cile",               "pll_p",        10200000,       false},
103
104         { "nor",                "pll_p",        102000000,      false},
105
106         { "sbc1",               "pll_p",        25000000,       false},
107         { "sbc2",               "pll_p",        25000000,       false},
108         { "sbc3",               "pll_p",        25000000,       false},
109         { "sbc4",               "pll_p",        25000000,       false},
110         { "sbc5",               "pll_p",        25000000,       false},
111         { "sbc6",               "pll_p",        25000000,       false},
112
113         { "uarta",              "pll_p",        408000000,      false},
114         { "uartb",              "pll_p",        408000000,      false},
115         { "uartc",              "pll_p",        408000000,      false},
116         { "uartd",              "pll_p",        408000000,      false},
117
118         { NULL,                 NULL,           0,              0},
119 };
120
121 static struct tegra_nor_platform_data vcm30_t124_nor_data = {
122         .flash = {
123                 .map_name = "cfi_probe",
124                 .width = 2,
125         },
126         .chip_parms = {
127                 .MuxMode = NorMuxMode_ADNonMux,
128                 .ReadMode = NorReadMode_Page,
129                 .PageLength = NorPageLength_8Word,
130                 .ReadyActive = NorReadyActive_WithData,
131                 /* FIXME: Need to use characterized value */
132                 .timing_default = {
133                         .timing0 = 0x30300273,
134                         .timing1 = 0x00030302,
135                 },
136                 .timing_read = {
137                         .timing0 = 0x30300273,
138                         .timing1 = 0x00030302,
139                 },
140         },
141 };
142
143 static struct cs_info vcm30_t124_cs_info[] = {
144         {
145                 .cs = CS_0,
146                 .num_cs_gpio = 0,
147                 .virt = IO_ADDRESS(TEGRA_NOR_FLASH_BASE),
148                 .size = SZ_64M,
149                 .phys = TEGRA_NOR_FLASH_BASE,
150         },
151 };
152
153 static void vcm30_t124_nor_init(void)
154 {
155         tegra_nor_device.resource[2].end = TEGRA_NOR_FLASH_BASE + SZ_64M - 1;
156
157         vcm30_t124_nor_data.info.cs = kzalloc(sizeof(struct cs_info) *
158                                         ARRAY_SIZE(vcm30_t124_cs_info),
159                                         GFP_KERNEL);
160         if (!vcm30_t124_nor_data.info.cs)
161                 BUG();
162
163         vcm30_t124_nor_data.info.num_chips = ARRAY_SIZE(vcm30_t124_cs_info);
164
165         memcpy(vcm30_t124_nor_data.info.cs, vcm30_t124_cs_info,
166                                 sizeof(struct cs_info) * ARRAY_SIZE(vcm30_t124_cs_info));
167
168         tegra_nor_device.dev.platform_data = &vcm30_t124_nor_data;
169         platform_device_register(&tegra_nor_device);
170 }
171
172 static struct i2c_board_info __initdata wm8731_board_info = {
173         I2C_BOARD_INFO("wm8731", 0x1a),
174 };
175
176 static struct i2c_board_info __initdata ad1937_board_info = {
177         I2C_BOARD_INFO("ad1937", 0x07),
178 };
179
180 static void vcm30_t124_i2c_init(void)
181 {
182         struct board_info board_info;
183
184         tegra_get_board_info(&board_info);
185         i2c_register_board_info(0, &wm8731_board_info, 1);
186         i2c_register_board_info(0, &ad1937_board_info, 1);
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         .gpio_hot_plug = -1,
267         .gpio_wake = -1,
268         .gpio_x1_slot = -1,
269 };
270
271 static void vcm30_t124_pcie_init(void)
272 {
273         tegra_pci_device.dev.platform_data = &vcm30_t124_pcie_platform_data;
274         platform_device_register(&tegra_pci_device);
275 }
276
277 #ifdef CONFIG_SATA_AHCI_TEGRA
278 static struct tegra_ahci_platform_data ahci_plat_data = {
279         .gen2_rx_eq = 7,
280 };
281
282 static void vcm30_t124_sata_init(void)
283 {
284         tegra_sata_device.dev.platform_data = &ahci_plat_data;
285         platform_device_register(&tegra_sata_device);
286 }
287 #else
288 static void vcm30_t124_sata_init(void) { }
289 #endif
290
291 static struct platform_device tegra_snd_vcm30t124 = {
292         .name = "tegra-snd-vcm30t124",
293         .id = 0,
294 };
295
296 /* FIXME: Check which devices are needed from the below list */
297 static struct platform_device *vcm30_t124_devices[] __initdata = {
298         &tegra_pmu_device,
299         &tegra_rtc_device,
300         &tegra_udc_device,
301 #if defined(CONFIG_TEGRA_AVP)
302         &tegra_avp_device,
303 #endif
304 #if defined(CONFIG_CRYPTO_DEV_TEGRA_SE)
305         &tegra12_se_device,
306 #endif
307         &tegra_snd_vcm30t124,
308 };
309
310 static struct tegra_usb_platform_data tegra_ehci1_utmi_pdata = {
311         .port_otg = false,
312         .has_hostpc = true,
313         .unaligned_dma_buf_supported = true,
314         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
315         .op_mode = TEGRA_USB_OPMODE_HOST,
316         .u_data.host = {
317                 .vbus_gpio = -1,
318                 .hot_plug = false,
319                 .remote_wakeup_supported = false,
320                 .power_off_on_suspend = true,
321                 .turn_off_vbus_on_lp0 = true,
322         },
323         .u_cfg.utmi = {
324                 .hssync_start_delay = 0,
325                 .elastic_limit = 16,
326                 .idle_wait_delay = 17,
327                 .term_range_adj = 6,
328                 .xcvr_setup = 15,
329                 .xcvr_lsfslew = 2,
330                 .xcvr_lsrslew = 2,
331                 .xcvr_setup_offset = 0,
332                 .xcvr_use_fuses = 1,
333                 .vbus_oc_map = 0x4,
334         },
335 };
336
337 static struct tegra_usb_platform_data tegra_ehci2_utmi_pdata = {
338         .port_otg = false,
339         .has_hostpc = true,
340         .unaligned_dma_buf_supported = true,
341         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
342         .op_mode = TEGRA_USB_OPMODE_HOST,
343         .u_data.host = {
344                 /* FIXME: Set this only for E1855. */
345                 .vbus_gpio = TEGRA_GPIO_PN5,
346                 .hot_plug = true,
347                 .remote_wakeup_supported = false,
348                 .power_off_on_suspend = true,
349                 .turn_off_vbus_on_lp0 = true,
350         },
351         .u_cfg.utmi = {
352                 .hssync_start_delay = 0,
353                 .elastic_limit = 16,
354                 .idle_wait_delay = 17,
355                 .term_range_adj = 6,
356                 .xcvr_setup = 8,
357                 .xcvr_lsfslew = 2,
358                 .xcvr_lsrslew = 2,
359                 .xcvr_setup_offset = 0,
360                 .xcvr_use_fuses = 1,
361                 .vbus_oc_map = 0x5,
362         },
363 };
364
365 static struct tegra_usb_platform_data tegra_ehci3_utmi_pdata = {
366         .port_otg = false,
367         .has_hostpc = true,
368         .unaligned_dma_buf_supported = true,
369         .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
370         .op_mode = TEGRA_USB_OPMODE_HOST,
371         .u_data.host = {
372                 .vbus_gpio = -1,
373                 .hot_plug = true,
374                 .remote_wakeup_supported = false,
375                 .power_off_on_suspend = true,
376                 .turn_off_vbus_on_lp0 = true,
377         },
378         .u_cfg.utmi = {
379         .hssync_start_delay = 0,
380                 .elastic_limit = 16,
381                 .idle_wait_delay = 17,
382                 .term_range_adj = 6,
383                 .xcvr_setup = 8,
384                 .xcvr_lsfslew = 2,
385                 .xcvr_lsrslew = 2,
386                 .xcvr_setup_offset = 0,
387                 .xcvr_use_fuses = 1,
388                 .vbus_oc_map = 0x5,
389         },
390 };
391
392 static struct tegra_usb_otg_data tegra_otg_pdata = {
393         .ehci_device = &tegra_ehci1_device,
394         .ehci_pdata = &tegra_ehci1_utmi_pdata,
395 };
396
397 static void vcm30_t124_usb_init(void)
398 {
399         int usb_port_owner_info = tegra_get_usb_port_owner_info();
400
401         if (!(usb_port_owner_info & UTMI2_PORT_OWNER_XUSB)) {
402                 tegra_ehci2_device.dev.platform_data = &tegra_ehci2_utmi_pdata;
403                 platform_device_register(&tegra_ehci2_device);
404         }
405
406         if (!(usb_port_owner_info & UTMI3_PORT_OWNER_XUSB)) {
407                 tegra_ehci3_device.dev.platform_data = &tegra_ehci3_utmi_pdata;
408                 platform_device_register(&tegra_ehci3_device);
409         }
410 }
411
412 #ifdef CONFIG_USE_OF
413 struct of_dev_auxdata vcm30_t124_auxdata_lookup[] __initdata = {
414         OF_DEV_AUXDATA("nvidia,tegra114-hsuart", TEGRA_UARTA_BASE,
415                                 "serial-tegra.0", NULL),
416         OF_DEV_AUXDATA("nvidia,tegra114-hsuart", TEGRA_UARTB_BASE,
417                                 "serial-tegra.1", NULL),
418         OF_DEV_AUXDATA("nvidia,tegra114-hsuart", TEGRA_UARTD_BASE,
419                                 "serial-tegra.3", NULL),
420         OF_DEV_AUXDATA("nvidia,tegra124-host1x", TEGRA_HOST1X_BASE, "host1x",
421                 NULL),
422         OF_DEV_AUXDATA("nvidia,tegra124-gk20a", TEGRA_GK20A_BAR0_BASE, "gk20a.0", NULL),
423         OF_DEV_AUXDATA("nvidia,tegra124-vic", TEGRA_VIC_BASE, "vic03.0", NULL),
424         OF_DEV_AUXDATA("nvidia,tegra124-msenc", TEGRA_MSENC_BASE, "msenc",
425                 NULL),
426         OF_DEV_AUXDATA("nvidia,tegra124-vi", TEGRA_VI_BASE, "vi.0", NULL),
427         OF_DEV_AUXDATA("nvidia,tegra124-isp", TEGRA_ISP_BASE, "isp.0", NULL),
428         OF_DEV_AUXDATA("nvidia,tegra124-isp", TEGRA_ISPB_BASE, "isp.1", NULL),
429         OF_DEV_AUXDATA("nvidia,tegra124-tsec", TEGRA_TSEC_BASE, "tsec", NULL),
430         OF_DEV_AUXDATA("nvidia,tegra124-apbdma", 0x60020000, "tegra-apbdma",
431                                 NULL),
432         OF_DEV_AUXDATA("nvidia,tegra124-ahub", 0x70300000,
433                                 "tegra30-ahub-apbif", NULL),
434         T124_I2C_OF_DEV_AUXDATA,
435         T124_SPI_OF_DEV_AUXDATA,
436
437         {}
438 };
439 #endif
440
441 static void __init tegra_vcm30_t124_early_init(void)
442 {
443         tegra_clk_init_from_table(vcm30_t124_clk_init_table);
444         tegra_clk_verify_parents();
445         tegra_soc_device_init("vcm30t124");
446 }
447
448 static void __init tegra_vcm30_t124_late_init(void)
449 {
450         struct board_info board_info;
451         tegra_get_board_info(&board_info);
452         pr_info("board_info: id:sku:fab:major:minor = 0x%04x:0x%04x:0x%02x:0x%02x:0x%02x\n",
453                 board_info.board_id, board_info.sku,
454                 board_info.fab, board_info.major_revision,
455                 board_info.minor_revision);
456         vcm30_t124_usb_init();
457 /*      vcm30_t124_xusb_init(); */
458         vcm30_t124_nor_init();
459         vcm30_t124_i2c_init();
460         vcm30_t124_uart_init();
461         vcm30_t124_pca953x_init();
462         platform_add_devices(vcm30_t124_devices,
463                         ARRAY_SIZE(vcm30_t124_devices));
464         tegra_io_dpd_init();
465         vcm30_t124_sdhci_init();
466         vcm30_t124_regulator_init();
467         vcm30_t124_suspend_init();
468 #if 0
469         vcm30_t124_emc_init();
470         vcm30_t124_edp_init();
471 #endif
472         isomgr_init();
473         /* vcm30_t124_panel_init(); */
474         /* vcm30_t124_pmon_init(); */
475         vcm30_t124_pcie_init();
476         vcm30_t124_sata_init();
477 #ifdef CONFIG_TEGRA_WDT_RECOVERY
478         tegra_wdt_recovery_init();
479 #endif
480         /* FIXME: Required? */
481 #if 0
482         tegra_serial_debug_init(TEGRA_UARTD_BASE, INT_WDT_CPU, NULL, -1, -1);
483
484         vcm30_t124_sensors_init();
485         vcm30_t124_soctherm_init();
486 #endif
487         tegra_register_fuse();
488         vcm30_t124_panel_init();
489 }
490
491 static void __init vcm30_t124_ramconsole_reserve(unsigned long size)
492 {
493         tegra_ram_console_debug_reserve(SZ_1M);
494 }
495
496 static void __init tegra_vcm30_t124_dt_init(void)
497 {
498         tegra_get_board_info(&board_info);
499         tegra_get_display_board_info(&display_board_info);
500
501         tegra_vcm30_t124_early_init();
502 #ifdef CONFIG_USE_OF
503         of_platform_populate(NULL,
504                 of_default_bus_match_table, vcm30_t124_auxdata_lookup,
505                 &platform_bus);
506 #endif
507
508         tegra_vcm30_t124_late_init();
509 }
510
511 static void __init tegra_vcm30_t124_reserve(void)
512 {
513 #if defined(CONFIG_NVMAP_CONVERT_CARVEOUT_TO_IOVMM)
514         /* 1920*1200*4*2 = 18432000 bytes */
515         tegra_reserve(0, SZ_16M + SZ_2M, SZ_16M);
516 #else
517         tegra_reserve(SZ_128M, SZ_16M + SZ_2M, SZ_4M);
518 #endif
519         vcm30_t124_ramconsole_reserve(SZ_1M);
520 }
521
522 static const char * const vcm30_t124_dt_board_compat[] = {
523         "nvidia,vcm30t124",
524         NULL
525 };
526
527 DT_MACHINE_START(VCM30_T124, "vcm30t124")
528         .atag_offset    = 0x100,
529         .smp            = smp_ops(tegra_smp_ops),
530         .map_io         = tegra_map_common_io,
531         .reserve        = tegra_vcm30_t124_reserve,
532         .init_early     = tegra12x_init_early,
533         .init_irq       = irqchip_init,
534         .init_time      = clocksource_of_init,
535         .init_machine   = tegra_vcm30_t124_dt_init,
536         .restart        = tegra_assert_system_reset,
537         .dt_compat      = vcm30_t124_dt_board_compat,
538         .init_late      = tegra_init_late
539 MACHINE_END