1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Configuration for Xilinx ZynqMP
4  * (C) Copyright 2014 - 2015 Xilinx, Inc.
5  * Michal Simek <michal.simek@xilinx.com>
6  *
7  * Based on Configuration for Versatile Express
8  */
9 
10 #ifndef __XILINX_ZYNQMP_H
11 #define __XILINX_ZYNQMP_H
12 
13 #define CONFIG_REMAKE_ELF
14 
15 /* #define CONFIG_ARMV8_SWITCH_TO_EL1 */
16 
17 /* Generic Interrupt Controller Definitions */
18 #define CONFIG_GICV2
19 #define GICD_BASE	0xF9010000
20 #define GICC_BASE	0xF9020000
21 
22 #define CONFIG_SYS_INIT_SP_ADDR		CONFIG_SYS_TEXT_BASE
23 
24 /* Generic Timer Definitions - setup in EL3. Setup by ATF for other cases */
25 #if !defined(COUNTER_FREQUENCY)
26 # define COUNTER_FREQUENCY		100000000
27 #endif
28 
29 /* Size of malloc() pool */
30 #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + 0x2000000)
31 
32 /* Serial setup */
33 #define CONFIG_CPU_ARMV8
34 
35 #define CONFIG_SYS_BAUDRATE_TABLE \
36 	{ 4800, 9600, 19200, 38400, 57600, 115200 }
37 
38 /* BOOTP options */
39 #define CONFIG_BOOTP_BOOTFILESIZE
40 #define CONFIG_BOOTP_MAY_FAIL
41 
42 #ifdef CONFIG_NAND_ARASAN
43 # define CONFIG_SYS_MAX_NAND_DEVICE	1
44 # define CONFIG_SYS_NAND_ONFI_DETECTION
45 #endif
46 
47 #if defined(CONFIG_SPL_BUILD)
48 #define CONFIG_ZYNQMP_PSU_INIT_ENABLED
49 #endif
50 
51 /* Miscellaneous configurable options */
52 #define CONFIG_SYS_LOAD_ADDR		0x8000000
53 
54 #if defined(CONFIG_ZYNQMP_USB)
55 #define CONFIG_SYS_DFU_DATA_BUF_SIZE	0x1800000
56 #define DFU_DEFAULT_POLL_TIMEOUT	300
57 #define CONFIG_THOR_RESET_OFF
58 #define DFU_ALT_INFO_RAM \
59 	"dfu_ram_info=" \
60 	"setenv dfu_alt_info " \
61 	"Image ram 80000 $kernel_size_r\\\\;" \
62 	"system.dtb ram $fdt_addr_r $fdt_size_r\0" \
63 	"dfu_ram=run dfu_ram_info && dfu 0 ram 0\0" \
64 	"thor_ram=run dfu_ram_info && thordown 0 ram 0\0" \
65 	"dfu_ram_tftp=run dfu_ram_info && setenv updatefile boot && " \
66 	"setenv loadaddr 10000000 && dfu tftp ram 0\0"
67 
68 #define DFU_ALT_INFO  \
69 		DFU_ALT_INFO_RAM
70 
71 #ifndef CONFIG_SPL_BUILD
72 # define PARTS_DEFAULT \
73 	"partitions=uuid_disk=${uuid_gpt_disk};" \
74 	"name=""boot"",size=16M,uuid=${uuid_gpt_boot};" \
75 	"name=""Linux"",size=-M,uuid=${uuid_gpt_Linux}\0"
76 #endif
77 #endif
78 
79 #if !defined(DFU_ALT_INFO)
80 # define DFU_ALT_INFO
81 #endif
82 
83 #if !defined(PARTS_DEFAULT)
84 # define PARTS_DEFAULT
85 #endif
86 
87 /* Monitor Command Prompt */
88 /* Console I/O Buffer Size */
89 #define CONFIG_SYS_CBSIZE		2048
90 #define CONFIG_SYS_BARGSIZE		CONFIG_SYS_CBSIZE
91 #define CONFIG_SYS_MAXARGS		64
92 
93 /* Ethernet driver */
94 #if defined(CONFIG_ZYNQ_GEM)
95 # define CONFIG_SYS_FAULT_ECHO_LINK_DOWN
96 # define PHY_ANEG_TIMEOUT       20000
97 #endif
98 
99 #define CONFIG_SYS_BOOTM_LEN	(60 * 1024 * 1024)
100 
101 #define CONFIG_CLOCKS
102 
103 #define ENV_MEM_LAYOUT_SETTINGS \
104 	"fdt_addr_r=0x40000000\0" \
105 	"fdt_size_r=0x400000\0" \
106 	"pxefile_addr_r=0x10000000\0" \
107 	"kernel_addr_r=0x18000000\0" \
108 	"kernel_size_r=0x10000000\0" \
109 	"scriptaddr=0x20000000\0" \
110 	"ramdisk_addr_r=0x02100000\0" \
111 	"script_size_f=0x80000\0" \
112 
113 #if defined(CONFIG_MMC_SDHCI_ZYNQ)
114 # define BOOT_TARGET_DEVICES_MMC(func)	func(MMC, mmc, 0) func(MMC, mmc, 1)
115 #else
116 # define BOOT_TARGET_DEVICES_MMC(func)
117 #endif
118 
119 #if defined(CONFIG_SATA_CEVA)
120 # define BOOT_TARGET_DEVICES_SCSI(func)	func(SCSI, scsi, 0)
121 #else
122 # define BOOT_TARGET_DEVICES_SCSI(func)
123 #endif
124 
125 #if defined(CONFIG_ZYNQMP_USB)
126 # define BOOT_TARGET_DEVICES_USB(func)	func(USB, usb, 0) func(USB, usb, 1)
127 #else
128 # define BOOT_TARGET_DEVICES_USB(func)
129 #endif
130 
131 #if defined(CONFIG_CMD_PXE) && defined(CONFIG_CMD_DHCP)
132 # define BOOT_TARGET_DEVICES_PXE(func)	func(PXE, pxe, na)
133 #else
134 # define BOOT_TARGET_DEVICES_PXE(func)
135 #endif
136 
137 #if defined(CONFIG_CMD_DHCP)
138 # define BOOT_TARGET_DEVICES_DHCP(func)	func(DHCP, dhcp, na)
139 #else
140 # define BOOT_TARGET_DEVICES_DHCP(func)
141 #endif
142 
143 #if defined(CONFIG_ZYNQMP_GQSPI)
144 # define BOOT_TARGET_DEVICES_QSPI(func)	func(QSPI, qspi, 0)
145 #else
146 # define BOOT_TARGET_DEVICES_QSPI(func)
147 #endif
148 
149 #if defined(CONFIG_NAND_ARASAN)
150 # define BOOT_TARGET_DEVICES_NAND(func)	func(NAND, nand, 0)
151 #else
152 # define BOOT_TARGET_DEVICES_NAND(func)
153 #endif
154 
155 #define BOOTENV_DEV_QSPI(devtypeu, devtypel, instance) \
156 	"bootcmd_" #devtypel #instance "=sf probe " #instance " 0 0 && " \
157 		       "sf read $scriptaddr $script_offset_f $script_size_f && " \
158 		       "echo QSPI: Trying to boot script at ${scriptaddr} && " \
159 		       "source ${scriptaddr}; echo QSPI: SCRIPT FAILED: continuing...;\0"
160 
161 #define BOOTENV_DEV_NAME_QSPI(devtypeu, devtypel, instance) \
162 	#devtypel #instance " "
163 
164 #define BOOTENV_DEV_NAND(devtypeu, devtypel, instance) \
165 	"bootcmd_" #devtypel #instance "= nand info && " \
166 		       "nand read $scriptaddr $script_offset_f $script_size_f && " \
167 		       "echo NAND: Trying to boot script at ${scriptaddr} && " \
168 		       "source ${scriptaddr}; echo NAND: SCRIPT FAILED: continuing...;\0"
169 
170 #define BOOTENV_DEV_NAME_NAND(devtypeu, devtypel, instance) \
171 	#devtypel #instance " "
172 
173 #define BOOT_TARGET_DEVICES_JTAG(func)	func(JTAG, jtag, na)
174 
175 #define BOOTENV_DEV_JTAG(devtypeu, devtypel, instance) \
176 	"bootcmd_jtag=echo JTAG: Trying to boot script at ${scriptaddr} && " \
177 		"source ${scriptaddr}; echo JTAG: SCRIPT FAILED: continuing...;\0"
178 
179 #define BOOTENV_DEV_NAME_JTAG(devtypeu, devtypel, instance) \
180 	"jtag "
181 
182 #define BOOT_TARGET_DEVICES(func) \
183 	BOOT_TARGET_DEVICES_JTAG(func) \
184 	BOOT_TARGET_DEVICES_MMC(func) \
185 	BOOT_TARGET_DEVICES_QSPI(func) \
186 	BOOT_TARGET_DEVICES_NAND(func) \
187 	BOOT_TARGET_DEVICES_USB(func) \
188 	BOOT_TARGET_DEVICES_SCSI(func) \
189 	BOOT_TARGET_DEVICES_PXE(func) \
190 	BOOT_TARGET_DEVICES_DHCP(func)
191 
192 #include <config_distro_bootcmd.h>
193 
194 /* Initial environment variables */
195 #ifndef CONFIG_EXTRA_ENV_SETTINGS
196 #define CONFIG_EXTRA_ENV_SETTINGS \
197 	ENV_MEM_LAYOUT_SETTINGS \
198 	BOOTENV \
199 	DFU_ALT_INFO
200 #endif
201 
202 /* SPL can't handle all huge variables - define just DFU */
203 #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_DFU)
204 #undef CONFIG_EXTRA_ENV_SETTINGS
205 # define CONFIG_EXTRA_ENV_SETTINGS \
206 	"dfu_alt_info_ram=uboot.bin ram 0x8000000 0x1000000;" \
207 			  "atf-uboot.ub ram 0x10000000 0x1000000;" \
208 			  "Image ram 0x80000 0x3f80000;" \
209 			  "system.dtb ram 0x4000000 0x100000\0" \
210 	"dfu_bufsiz=0x1000\0"
211 #endif
212 
213 #define CONFIG_SPL_STACK		0xfffffffc
214 #define CONFIG_SPL_MAX_SIZE		0x40000
215 
216 /* Just random location in OCM */
217 #define CONFIG_SPL_BSS_START_ADDR	0x0
218 #define CONFIG_SPL_BSS_MAX_SIZE		0x80000
219 
220 #if defined(CONFIG_SPL_SPI_FLASH_SUPPORT)
221 # define CONFIG_SYS_SPI_KERNEL_OFFS	0x80000
222 # define CONFIG_SYS_SPI_ARGS_OFFS	0xa0000
223 # define CONFIG_SYS_SPI_ARGS_SIZE	0xa0000
224 #endif
225 
226 /* u-boot is like dtb */
227 #define CONFIG_SPL_FS_LOAD_ARGS_NAME	"u-boot.bin"
228 #define CONFIG_SYS_SPL_ARGS_ADDR	0x8000000
229 
230 /* ATF is my kernel image */
231 #define CONFIG_SPL_FS_LOAD_KERNEL_NAME	"atf-uboot.ub"
232 
233 /* MMC support */
234 #ifdef CONFIG_MMC_SDHCI_ZYNQ
235 # define CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR	0 /* unused */
236 # define CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS	0 /* unused */
237 # define CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR	0 /* unused */
238 # if defined(CONFIG_SPL_LOAD_FIT)
239 #  define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME	"u-boot.itb"
240 # else
241 #  define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME	"u-boot.img"
242 # endif
243 #endif
244 
245 #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_DFU)
246 # define CONFIG_SPL_ENV_SUPPORT
247 # define CONFIG_SPL_HASH_SUPPORT
248 # define CONFIG_ENV_MAX_ENTRIES	10
249 #endif
250 
251 #define CONFIG_SYS_SPL_MALLOC_START	0x20000000
252 #define CONFIG_SYS_SPL_MALLOC_SIZE	0x100000
253 
254 #ifdef CONFIG_SPL_SYS_MALLOC_SIMPLE
255 # error "Disable CONFIG_SPL_SYS_MALLOC_SIMPLE. Full malloc needs to be used"
256 #endif
257 
258 #endif /* __XILINX_ZYNQMP_H */
259