blob: 6a40bbdf3a729bc19e62e2bc5d149952f00957a8 [file] [log] [blame]
Michal Simekd903ce42024-05-29 16:47:58 +02001/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Configuration for AMD Versal Gen 2
4 * Copyright (C) 2016 - 2022, Xilinx, Inc.
5 * Copyright (C) 2022 - 2024, Advanced Micro Devices, Inc.
6 *
7 * Michal Simek <michal.simek@amd.com>
8 *
9 * Based on Configuration for Xilinx ZynqMP
10 */
11
12#ifndef __AMD_VERSAL2_H
13#define __AMD_VERSAL2_H
14
15/* FIXME this is causing issue at least on IPP */
16/* #define CONFIG_ARMV8_SWITCH_TO_EL1 */
17
18/* Generic Interrupt Controller Definitions */
19#define GICD_BASE 0xF9000000
20#define GICR_BASE 0xF9060000
21
22/* Serial setup */
23#define CFG_SYS_BAUDRATE_TABLE \
24 { 4800, 9600, 19200, 38400, 57600, 115200 }
25
26#if defined(CONFIG_CMD_DFU)
27#define DFU_DEFAULT_POLL_TIMEOUT 300
28#define DFU_ALT_INFO_RAM \
29 "dfu_ram_info=" \
30 "setenv dfu_alt_info " \
31 "Image ram 80000 $kernel_size_r\\\\;" \
32 "system.dtb ram $fdt_addr_r $fdt_size_r\0" \
33 "dfu_ram=run dfu_ram_info && dfu 0 ram 0\0" \
34 "thor_ram=run dfu_ram_info && thordown 0 ram 0\0"
35
36#define DFU_ALT_INFO \
37 DFU_ALT_INFO_RAM
38#endif
39
40#if !defined(DFU_ALT_INFO)
41# define DFU_ALT_INFO
42#endif
43
44/* Ethernet driver */
45#if defined(CONFIG_ZYNQ_GEM)
46# define PHY_ANEG_TIMEOUT 20000
47#endif
48
49#define ENV_MEM_LAYOUT_SETTINGS \
50 "fdt_addr_r=0x40000000\0" \
51 "fdt_size_r=0x400000\0" \
52 "pxefile_addr_r=0x10000000\0" \
53 "kernel_addr_r=0x18000000\0" \
54 "kernel_size_r=0x10000000\0" \
55 "kernel_comp_addr_r=0x30000000\0" \
56 "kernel_comp_size=0x3C00000\0" \
57 "ramdisk_addr_r=0x02100000\0" \
58 "script_size_f=0x80000\0"
59
60#if defined(CONFIG_DISTRO_DEFAULTS)
61
62#if defined(CONFIG_MMC_SDHCI_ZYNQ)
63# define BOOT_TARGET_DEVICES_MMC(func) func(MMC, mmc, 0) func(MMC, mmc, 1)
64#else
65# define BOOT_TARGET_DEVICES_MMC(func)
66#endif
67
68#if defined(CONFIG_CMD_PXE) && defined(CONFIG_CMD_DHCP)
69# define BOOT_TARGET_DEVICES_PXE(func) func(PXE, pxe, na)
70#else
71# define BOOT_TARGET_DEVICES_PXE(func)
72#endif
73
74#if defined(CONFIG_CMD_DHCP)
75# define BOOT_TARGET_DEVICES_DHCP(func) func(DHCP, dhcp, na)
76#else
77# define BOOT_TARGET_DEVICES_DHCP(func)
78#endif
79
80#if defined(CONFIG_ZYNQMP_GQSPI) || defined(CONFIG_CADENCE_OSPI_VERSAL)
81# define BOOT_TARGET_DEVICES_XSPI(func) func(XSPI, xspi, 0) func(XSPI, xspi, 1)
82# define BOOTENV_DEV_SHARED_XSPI \
83 "xspi_boot=sf probe $devnum_xspi:0 0 0 && " \
84 "sf read $scriptaddr $script_offset_f $script_size_f && " \
85 "echo XSPI: Trying to boot script at ${scriptaddr} && " \
86 "source ${scriptaddr}; echo XSPI: SCRIPT FAILED: continuing...;\0"
87#else
88# define BOOT_TARGET_DEVICES_XSPI(func)
89# define BOOTENV_DEV_SHARED_XSPI
90#endif
91
92#define BOOTENV_DEV_XSPI(devtypeu, devtypel, instance) \
93 "bootcmd_" #devtypel #instance "=" \
94 "devnum_xspi=" #instance "; run " #devtypel "_boot\0" \
95
96#define BOOTENV_DEV_NAME_XSPI(devtypeu, devtypel, instance) \
97 ""
98
99#define BOOT_TARGET_DEVICES_JTAG(func) func(JTAG, jtag, na)
100
101#define BOOTENV_DEV_JTAG(devtypeu, devtypel, instance) \
102 "bootcmd_jtag=echo JTAG: Trying to boot script at ${scriptaddr} && " \
103 "source ${scriptaddr}; echo JTAG: SCRIPT FAILED: continuing...;\0"
104
105#define BOOTENV_DEV_NAME_JTAG(devtypeu, devtypel, instance) \
106 "jtag "
107
108#define BOOT_TARGET_DEVICES_DFU_USB(func) func(DFU_USB, dfu_usb, 0)
109
110#define BOOTENV_DEV_DFU_USB(devtypeu, devtypel, instance) \
111 "bootcmd_dfu_usb=setenv dfu_alt_info boot.scr ram $scriptaddr " \
112 "$script_size_f; dfu 0 ram 0 && " \
113 "echo DFU: Trying to boot script at ${scriptaddr} && " \
114 "source ${scriptaddr}; " \
115 "echo DFU: SCRIPT FAILED: continuing...;\0"
116
117#define BOOTENV_DEV_NAME_DFU_USB(devtypeu, devtypel, instance) \
118 ""
119
120#define BOOT_TARGET_DEVICES(func) \
121 BOOT_TARGET_DEVICES_JTAG(func) \
122 BOOT_TARGET_DEVICES_MMC(func) \
123 BOOT_TARGET_DEVICES_XSPI(func) \
124 BOOT_TARGET_DEVICES_DFU_USB(func) \
125 BOOT_TARGET_DEVICES_PXE(func) \
126 BOOT_TARGET_DEVICES_DHCP(func)
127
128#include <config_distro_bootcmd.h>
129
130#else /* CONFIG_DISTRO_DEFAULTS */
131# define BOOTENV
132#endif /* CONFIG_DISTRO_DEFAULTS */
133
134/* Initial environment variables */
135#ifndef CFG_EXTRA_ENV_SETTINGS
136#define CFG_EXTRA_ENV_SETTINGS \
137 ENV_MEM_LAYOUT_SETTINGS \
138 BOOTENV \
139 BOOTENV_DEV_SHARED_XSPI \
140 DFU_ALT_INFO
141#endif
142
143#endif /* __AMD_VERSAL2_H */