]> git.sur5r.net Git - u-boot/blob - arch/arm/mach-socfpga/board.c
cb6530f7e8feea57215940756b0a113ea6b5941c
[u-boot] / arch / arm / mach-socfpga / board.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Altera SoCFPGA common board code
4  *
5  * Copyright (C) 2015 Marek Vasut <marex@denx.de>
6  */
7
8 #include <common.h>
9 #include <errno.h>
10 #include <fdtdec.h>
11 #include <asm/arch/reset_manager.h>
12 #include <asm/arch/clock_manager.h>
13 #include <asm/arch/misc.h>
14 #include <asm/io.h>
15
16 #include <usb.h>
17 #include <usb/dwc2_udc.h>
18
19 DECLARE_GLOBAL_DATA_PTR;
20
21 void s_init(void) {
22         /*
23          * Preconfigure ACTLR, make sure Write Full Line of Zeroes is disabled.
24          * This is optional on CycloneV / ArriaV.
25          * This is mandatory on Arria10, otherwise Linux refuses to boot.
26          */
27         asm volatile(
28                 "mcr p15, 0, %0, c1, c0, 1\n"
29                 "isb\n"
30                 "dsb\n"
31         ::"r"(0x0));
32 }
33
34 /*
35  * Miscellaneous platform dependent initialisations
36  */
37 int board_init(void)
38 {
39         /* Address of boot parameters for ATAG (if ATAG is used) */
40         gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
41
42 #if defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
43         /* configuring the clock based on handoff */
44         cm_basic_init(gd->fdt_blob);
45
46         /* Add device descriptor to FPGA device table */
47         socfpga_fpga_add();
48 #endif
49
50         return 0;
51 }
52
53 int dram_init_banksize(void)
54 {
55         fdtdec_setup_memory_banksize();
56
57         return 0;
58 }
59
60 #ifdef CONFIG_USB_GADGET
61 struct dwc2_plat_otg_data socfpga_otg_data = {
62         .usb_gusbcfg    = 0x1417,
63 };
64
65 int board_usb_init(int index, enum usb_init_type init)
66 {
67         int node[2], count;
68         fdt_addr_t addr;
69
70         count = fdtdec_find_aliases_for_id(gd->fdt_blob, "udc",
71                                            COMPAT_ALTERA_SOCFPGA_DWC2USB,
72                                            node, 2);
73         if (count <= 0) /* No controller found. */
74                 return 0;
75
76         addr = fdtdec_get_addr(gd->fdt_blob, node[0], "reg");
77         if (addr == FDT_ADDR_T_NONE) {
78                 printf("UDC Controller has no 'reg' property!\n");
79                 return -EINVAL;
80         }
81
82         /* Patch the address from OF into the controller pdata. */
83         socfpga_otg_data.regs_otg = addr;
84
85         return dwc2_udc_probe(&socfpga_otg_data);
86 }
87
88 int g_dnl_board_usb_cable_connected(void)
89 {
90         return 1;
91 }
92 #endif