1 // SPDX-License-Identifier: GPL-2.0+
3 * Altera SoCFPGA common board code
5 * Copyright (C) 2015 Marek Vasut <marex@denx.de>
9 #include <asm/arch/clock_manager.h>
10 #include <asm/arch/misc.h>
11 #include <asm/arch/reset_manager.h>
12 #include <asm/arch/secure_vab.h>
13 #include <asm/global_data.h>
22 #include <usb/dwc2_udc.h>
24 DECLARE_GLOBAL_DATA_PTR
;
29 * Preconfigure ACTLR and CPACR, make sure Write Full Line of Zeroes
30 * is disabled in ACTLR.
31 * This is optional on CycloneV / ArriaV.
32 * This is mandatory on Arria10, otherwise Linux refuses to boot.
35 "mcr p15, 0, %0, c1, c0, 1\n"
36 "mcr p15, 0, %0, c1, c0, 2\n"
44 * Miscellaneous platform dependent initialisations
48 /* Address of boot parameters for ATAG (if ATAG is used) */
49 gd
->bd
->bi_boot_params
= CFG_SYS_SDRAM_BASE
+ 0x100;
54 int dram_init_banksize(void)
56 fdtdec_setup_memory_banksize();
61 #ifdef CONFIG_USB_GADGET
62 struct dwc2_plat_otg_data socfpga_otg_data
= {
63 .usb_gusbcfg
= 0x1417,
66 int board_usb_init(int index
, enum usb_init_type init
)
71 count
= fdtdec_find_aliases_for_id(gd
->fdt_blob
, "udc",
72 COMPAT_ALTERA_SOCFPGA_DWC2USB
,
74 if (count
<= 0) /* No controller found. */
77 addr
= fdtdec_get_addr(gd
->fdt_blob
, node
[0], "reg");
78 if (addr
== FDT_ADDR_T_NONE
) {
79 printf("UDC Controller has no 'reg' property!\n");
83 /* Patch the address from OF into the controller pdata. */
84 socfpga_otg_data
.regs_otg
= addr
;
86 return dwc2_udc_probe(&socfpga_otg_data
);
89 int g_dnl_board_usb_cable_connected(void)
95 #ifdef CONFIG_SPL_BUILD
96 __weak
int board_fit_config_name_match(const char *name
)
98 /* Just empty function now - can't decide what to choose */
99 debug("%s: %s\n", __func__
, name
);
105 #if IS_ENABLED(CONFIG_FIT_IMAGE_POST_PROCESS)
106 void board_fit_image_post_process(const void *fit
, int node
, void **p_image
,
109 if (IS_ENABLED(CONFIG_SOCFPGA_SECURE_VAB_AUTH
)) {
110 if (socfpga_vendor_authentication(p_image
, p_size
))
116 #if !IS_ENABLED(CONFIG_SPL_BUILD) && IS_ENABLED(CONFIG_FIT)
117 void board_prep_linux(struct bootm_headers
*images
)
119 if (!images
->fit_uname_cfg
) {
120 if (IS_ENABLED(CONFIG_SOCFPGA_SECURE_VAB_AUTH
) &&
121 !IS_ENABLED(CONFIG_SOCFPGA_SECURE_VAB_AUTH_ALLOW_NON_FIT_IMAGE
)) {
123 * Ensure the OS is always booted from FIT and with
124 * VAB signed certificate
126 printf("Please use FIT with VAB signed images!\n");
130 /* Update fdt_addr in enviroment variable */
131 env_set_hex("fdt_addr", (ulong
)images
->ft_addr
);
132 debug("images->ft_addr = 0x%08lx\n", (ulong
)images
->ft_addr
);
135 if (IS_ENABLED(CONFIG_CADENCE_QSPI
)) {
136 if (env_get("linux_qspi_enable"))
137 run_command(env_get("linux_qspi_enable"), 0);