Merge https://gitlab.denx.de/u-boot/custodians/u-boot-spi
[platform/kernel/u-boot.git] / include / configs / zynq-common.h
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * (C) Copyright 2012 Michal Simek <monstr@monstr.eu>
4  * (C) Copyright 2013 - 2018 Xilinx, Inc.
5  *
6  * Common configuration options for all Zynq boards.
7  */
8
9 #ifndef __CONFIG_ZYNQ_COMMON_H
10 #define __CONFIG_ZYNQ_COMMON_H
11
12 /* CPU clock */
13 #ifndef CONFIG_CPU_FREQ_HZ
14 # define CONFIG_CPU_FREQ_HZ     800000000
15 #endif
16
17 #define CONFIG_REMAKE_ELF
18
19 /* Cache options */
20 #define CONFIG_SYS_L2CACHE_OFF
21 #ifndef CONFIG_SYS_L2CACHE_OFF
22 # define CONFIG_SYS_L2_PL310
23 # define CONFIG_SYS_PL310_BASE          0xf8f02000
24 #endif
25
26 #define ZYNQ_SCUTIMER_BASEADDR          0xF8F00600
27 #define CONFIG_SYS_TIMERBASE            ZYNQ_SCUTIMER_BASEADDR
28 #define CONFIG_SYS_TIMER_COUNTS_DOWN
29 #define CONFIG_SYS_TIMER_COUNTER        (CONFIG_SYS_TIMERBASE + 0x4)
30
31 /* Serial drivers */
32 /* The following table includes the supported baudrates */
33 #define CONFIG_SYS_BAUDRATE_TABLE  \
34         {300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400}
35
36 #define CONFIG_ARM_DCC
37
38 /* Ethernet driver */
39 #if defined(CONFIG_ZYNQ_GEM)
40 # define CONFIG_SYS_FAULT_ECHO_LINK_DOWN
41 # define CONFIG_BOOTP_MAY_FAIL
42 #endif
43
44 /* NOR */
45 #ifdef CONFIG_MTD_NOR_FLASH
46 # define CONFIG_SYS_MAX_FLASH_BANKS     1
47 # define CONFIG_SYS_MAX_FLASH_SECT      512
48 # define CONFIG_SYS_FLASH_ERASE_TOUT    1000
49 # define CONFIG_SYS_FLASH_WRITE_TOUT    5000
50 # define CONFIG_FLASH_SHOW_PROGRESS     10
51 # undef CONFIG_SYS_FLASH_EMPTY_INFO
52 # define CONFIG_SYS_FLASH_QUIET_TEST
53 #endif
54
55 #ifdef CONFIG_NAND_ZYNQ
56 #define CONFIG_SYS_MAX_NAND_DEVICE      1
57 #define CONFIG_SYS_NAND_ONFI_DETECTION
58 #endif
59
60 #ifdef CONFIG_USB_EHCI_ZYNQ
61 # define CONFIG_EHCI_IS_TDI
62
63 # define CONFIG_SYS_DFU_DATA_BUF_SIZE   0x600000
64 # define DFU_DEFAULT_POLL_TIMEOUT       300
65 # define CONFIG_THOR_RESET_OFF
66 # define DFU_ALT_INFO_RAM \
67         "dfu_ram_info=" \
68         "setenv dfu_alt_info " \
69         "${kernel_image} ram 0x3000000 0x500000\\\\;" \
70         "${devicetree_image} ram 0x2A00000 0x20000\\\\;" \
71         "${ramdisk_image} ram 0x2000000 0x600000\0" \
72         "dfu_ram=run dfu_ram_info && dfu 0 ram 0\0" \
73         "thor_ram=run dfu_ram_info && thordown 0 ram 0\0"
74
75 # if defined(CONFIG_MMC_SDHCI_ZYNQ)
76 #  define DFU_ALT_INFO_MMC \
77         "dfu_mmc_info=" \
78         "setenv dfu_alt_info " \
79         "${kernel_image} fat 0 1\\\\;" \
80         "${devicetree_image} fat 0 1\\\\;" \
81         "${ramdisk_image} fat 0 1\0" \
82         "dfu_mmc=run dfu_mmc_info && dfu 0 mmc 0\0" \
83         "thor_mmc=run dfu_mmc_info && thordown 0 mmc 0\0"
84
85 #  define DFU_ALT_INFO  \
86         DFU_ALT_INFO_RAM \
87         DFU_ALT_INFO_MMC
88 # else
89 #  define DFU_ALT_INFO  \
90         DFU_ALT_INFO_RAM
91 # endif
92 #endif
93
94 #if !defined(DFU_ALT_INFO)
95 # define DFU_ALT_INFO
96 #endif
97
98 /* Allow to overwrite serial and ethaddr */
99 #define CONFIG_ENV_OVERWRITE
100
101 /* enable preboot to be loaded before CONFIG_BOOTDELAY */
102
103 /* Boot configuration */
104 #define CONFIG_SYS_LOAD_ADDR            0 /* default? */
105
106 #ifdef CONFIG_SPL_BUILD
107 #define BOOTENV
108 #else
109
110 #ifdef CONFIG_CMD_MMC
111 #define BOOT_TARGET_DEVICES_MMC(func) func(MMC, mmc, 0) func(MMC, mmc, 1)
112 #else
113 #define BOOT_TARGET_DEVICES_MMC(func)
114 #endif
115
116 #ifdef CONFIG_CMD_USB
117 #define BOOT_TARGET_DEVICES_USB(func) func(USB, usb, 0) func(USB, usb, 1)
118 #else
119 #define BOOT_TARGET_DEVICES_USB(func)
120 #endif
121
122 #if defined(CONFIG_CMD_PXE) && defined(CONFIG_CMD_DHCP)
123 #define BOOT_TARGET_DEVICES_PXE(func) func(PXE, pxe, na)
124 #else
125 #define BOOT_TARGET_DEVICES_PXE(func)
126 #endif
127
128 #if defined(CONFIG_CMD_DHCP)
129 #define BOOT_TARGET_DEVICES_DHCP(func) func(DHCP, dhcp, na)
130 #else
131 #define BOOT_TARGET_DEVICES_DHCP(func)
132 #endif
133
134 #if defined(CONFIG_ZYNQ_QSPI)
135 # define BOOT_TARGET_DEVICES_QSPI(func) func(QSPI, qspi, na)
136 #else
137 # define BOOT_TARGET_DEVICES_QSPI(func)
138 #endif
139
140 #if defined(CONFIG_NAND_ZYNQ)
141 # define BOOT_TARGET_DEVICES_NAND(func) func(NAND, nand, na)
142 #else
143 # define BOOT_TARGET_DEVICES_NAND(func)
144 #endif
145
146 #if defined(CONFIG_MTD_NOR_FLASH)
147 # define BOOT_TARGET_DEVICES_NOR(func)  func(NOR, nor, na)
148 #else
149 # define BOOT_TARGET_DEVICES_NOR(func)
150 #endif
151
152 #define BOOTENV_DEV_QSPI(devtypeu, devtypel, instance) \
153         "bootcmd_qspi=sf probe 0 0 0 && " \
154                       "sf read ${scriptaddr} ${script_offset_f} ${script_size_f} && " \
155                       "echo QSPI: Trying to boot script at ${scriptaddr} && " \
156                       "source ${scriptaddr}; echo QSPI: SCRIPT FAILED: continuing...;\0"
157
158 #define BOOTENV_DEV_NAME_QSPI(devtypeu, devtypel, instance) \
159         "qspi "
160
161 #define BOOTENV_DEV_NAND(devtypeu, devtypel, instance) \
162         "bootcmd_nand=nand info && " \
163                       "nand read ${scriptaddr} ${script_offset_f} ${script_size_f} && " \
164                       "echo NAND: Trying to boot script at ${scriptaddr} && " \
165                       "source ${scriptaddr}; echo NAND: SCRIPT FAILED: continuing...;\0"
166
167 #define BOOTENV_DEV_NAME_NAND(devtypeu, devtypel, instance) \
168         "nand "
169
170 #define BOOTENV_DEV_NOR(devtypeu, devtypel, instance) \
171         "script_offset_nor=0xE2FC0000\0"        \
172         "bootcmd_nor=cp.b ${script_offset_nor} ${scriptaddr} ${script_size_f} && " \
173                      "echo NOR: Trying to boot script at ${scriptaddr} && " \
174                      "source ${scriptaddr}; echo NOR: SCRIPT FAILED: continuing...;\0"
175
176 #define BOOTENV_DEV_NAME_NOR(devtypeu, devtypel, instance) \
177         "nor "
178
179 #define BOOT_TARGET_DEVICES_JTAG(func)  func(JTAG, jtag, na)
180
181 #define BOOTENV_DEV_JTAG(devtypeu, devtypel, instance) \
182         "bootcmd_jtag=echo JTAG: Trying to boot script at ${scriptaddr} && " \
183                 "source ${scriptaddr}; echo JTAG: SCRIPT FAILED: continuing...;\0"
184
185 #define BOOTENV_DEV_NAME_JTAG(devtypeu, devtypel, instance) \
186         "jtag "
187
188 #define BOOT_TARGET_DEVICES(func) \
189         BOOT_TARGET_DEVICES_JTAG(func) \
190         BOOT_TARGET_DEVICES_MMC(func) \
191         BOOT_TARGET_DEVICES_QSPI(func) \
192         BOOT_TARGET_DEVICES_NAND(func) \
193         BOOT_TARGET_DEVICES_NOR(func) \
194         BOOT_TARGET_DEVICES_USB(func) \
195         BOOT_TARGET_DEVICES_PXE(func) \
196         BOOT_TARGET_DEVICES_DHCP(func)
197
198 #include <config_distro_bootcmd.h>
199 #endif /* CONFIG_SPL_BUILD */
200
201 /* Default environment */
202 #ifndef CONFIG_EXTRA_ENV_SETTINGS
203 #define CONFIG_EXTRA_ENV_SETTINGS       \
204         "fdt_high=0x20000000\0"         \
205         "scriptaddr=0x20000\0"  \
206         "script_size_f=0x40000\0"       \
207         "fdt_addr_r=0x1f00000\0"        \
208         "pxefile_addr_r=0x2000000\0"    \
209         "kernel_addr_r=0x2000000\0"     \
210         "scriptaddr=0x3000000\0"        \
211         "ramdisk_addr_r=0x3100000\0"    \
212         DFU_ALT_INFO \
213         BOOTENV
214 #endif
215
216 /* Miscellaneous configurable options */
217
218 #define CONFIG_CLOCKS
219 #define CONFIG_SYS_MAXARGS              32 /* max number of command args */
220 #define CONFIG_SYS_CBSIZE               2048 /* Console I/O Buffer Size */
221
222 #define CONFIG_SYS_MEMTEST_START        0
223 #define CONFIG_SYS_MEMTEST_END          0x1000
224
225 #define CONFIG_SYS_INIT_RAM_ADDR        0xFFFF0000
226 #define CONFIG_SYS_INIT_RAM_SIZE        0x2000
227 #define CONFIG_SYS_INIT_SP_ADDR         (CONFIG_SYS_INIT_RAM_ADDR + \
228                                         CONFIG_SYS_INIT_RAM_SIZE - \
229                                         GENERATED_GBL_DATA_SIZE)
230
231
232 /* Extend size of kernel image for uncompression */
233 #define CONFIG_SYS_BOOTM_LEN    (60 * 1024 * 1024)
234
235 /* Boot FreeBSD/vxWorks from an ELF image */
236 #define CONFIG_SYS_MMC_MAX_DEVICE       1
237
238 /* MMC support */
239 #ifdef CONFIG_MMC_SDHCI_ZYNQ
240 #define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION     1
241 #define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME     "u-boot.img"
242 #endif
243
244 /* Address in RAM where the parameters must be copied by SPL. */
245 #define CONFIG_SYS_SPL_ARGS_ADDR        0x10000000
246
247 #define CONFIG_SPL_FS_LOAD_ARGS_NAME            "system.dtb"
248 #define CONFIG_SPL_FS_LOAD_KERNEL_NAME          "uImage"
249
250 /* Not using MMC raw mode - just for compilation purpose */
251 #define CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR   0
252 #define CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS  0
253 #define CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR 0
254
255 /* qspi mode is working fine */
256 #ifdef CONFIG_ZYNQ_QSPI
257 #define CONFIG_SYS_SPI_ARGS_OFFS        0x200000
258 #define CONFIG_SYS_SPI_ARGS_SIZE        0x80000
259 #define CONFIG_SYS_SPI_KERNEL_OFFS      (CONFIG_SYS_SPI_ARGS_OFFS + \
260                                         CONFIG_SYS_SPI_ARGS_SIZE)
261 #endif
262
263 /* SP location before relocation, must use scratch RAM */
264
265 /* 3 * 64kB blocks of OCM - one is on the top because of bootrom */
266 #define CONFIG_SPL_MAX_SIZE     0x30000
267
268 /* On the top of OCM space */
269 #define CONFIG_SYS_SPL_MALLOC_START     CONFIG_SPL_STACK_R_ADDR
270 #define CONFIG_SYS_SPL_MALLOC_SIZE      0x2000000
271
272 /*
273  * SPL stack position - and stack goes down
274  * 0xfffffe00 is used for putting wfi loop.
275  * Set it up as limit for now.
276  */
277 #define CONFIG_SPL_STACK        0xfffffe00
278
279 /* BSS setup */
280 #define CONFIG_SPL_BSS_START_ADDR       0x100000
281 #define CONFIG_SPL_BSS_MAX_SIZE         0x100000
282
283 #define CONFIG_SPL_LOAD_FIT_ADDRESS 0x10000000
284
285 #endif /* __CONFIG_ZYNQ_COMMON_H */