zynq-common.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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. #ifndef __CONFIG_ZYNQ_COMMON_H
  9. #define __CONFIG_ZYNQ_COMMON_H
  10. /* CPU clock */
  11. #ifndef CONFIG_CPU_FREQ_HZ
  12. # define CONFIG_CPU_FREQ_HZ 800000000
  13. #endif
  14. /* Cache options */
  15. #define CONFIG_SYS_L2CACHE_OFF
  16. #ifndef CONFIG_SYS_L2CACHE_OFF
  17. # define CONFIG_SYS_L2_PL310
  18. # define CONFIG_SYS_PL310_BASE 0xf8f02000
  19. #endif
  20. #define ZYNQ_SCUTIMER_BASEADDR 0xF8F00600
  21. #define CONFIG_SYS_TIMERBASE ZYNQ_SCUTIMER_BASEADDR
  22. #define CONFIG_SYS_TIMER_COUNTS_DOWN
  23. #define CONFIG_SYS_TIMER_COUNTER (CONFIG_SYS_TIMERBASE + 0x4)
  24. /* Serial drivers */
  25. /* The following table includes the supported baudrates */
  26. #define CONFIG_SYS_BAUDRATE_TABLE \
  27. {300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400}
  28. #define CONFIG_ARM_DCC
  29. /* Ethernet driver */
  30. #if defined(CONFIG_ZYNQ_GEM)
  31. # define CONFIG_MII
  32. # define CONFIG_SYS_FAULT_ECHO_LINK_DOWN
  33. # define CONFIG_BOOTP_MAY_FAIL
  34. #endif
  35. /* SPI */
  36. #ifdef CONFIG_ZYNQ_SPI
  37. #endif
  38. /* QSPI */
  39. #ifdef CONFIG_ZYNQ_QSPI
  40. # define CONFIG_SF_DEFAULT_SPEED 30000000
  41. # define CONFIG_SPI_FLASH_ISSI
  42. #endif
  43. /* NOR */
  44. #ifdef CONFIG_MTD_NOR_FLASH
  45. # define CONFIG_SYS_FLASH_BASE 0xE2000000
  46. # define CONFIG_SYS_FLASH_SIZE (16 * 1024 * 1024)
  47. # define CONFIG_SYS_MAX_FLASH_BANKS 1
  48. # define CONFIG_SYS_MAX_FLASH_SECT 512
  49. # define CONFIG_SYS_FLASH_ERASE_TOUT 1000
  50. # define CONFIG_SYS_FLASH_WRITE_TOUT 5000
  51. # define CONFIG_FLASH_SHOW_PROGRESS 10
  52. # define CONFIG_SYS_FLASH_CFI
  53. # undef CONFIG_SYS_FLASH_EMPTY_INFO
  54. # define CONFIG_FLASH_CFI_DRIVER
  55. # undef CONFIG_SYS_FLASH_PROTECTION
  56. # define CONFIG_SYS_FLASH_USE_BUFFER_WRITE
  57. #endif
  58. #ifdef CONFIG_NAND_ZYNQ
  59. #define CONFIG_SYS_MAX_NAND_DEVICE 1
  60. #define CONFIG_SYS_NAND_ONFI_DETECTION
  61. #define CONFIG_MTD_DEVICE
  62. #endif
  63. #ifdef CONFIG_USB_EHCI_ZYNQ
  64. # define CONFIG_EHCI_IS_TDI
  65. # define CONFIG_SYS_DFU_DATA_BUF_SIZE 0x600000
  66. # define DFU_DEFAULT_POLL_TIMEOUT 300
  67. # define CONFIG_USB_CABLE_CHECK
  68. # define CONFIG_THOR_RESET_OFF
  69. # define DFU_ALT_INFO_RAM \
  70. "dfu_ram_info=" \
  71. "set dfu_alt_info " \
  72. "${kernel_image} ram 0x3000000 0x500000\\\\;" \
  73. "${devicetree_image} ram 0x2A00000 0x20000\\\\;" \
  74. "${ramdisk_image} ram 0x2000000 0x600000\0" \
  75. "dfu_ram=run dfu_ram_info && dfu 0 ram 0\0" \
  76. "thor_ram=run dfu_ram_info && thordown 0 ram 0\0"
  77. # if defined(CONFIG_MMC_SDHCI_ZYNQ)
  78. # define DFU_ALT_INFO_MMC \
  79. "dfu_mmc_info=" \
  80. "set dfu_alt_info " \
  81. "${kernel_image} fat 0 1\\\\;" \
  82. "${devicetree_image} fat 0 1\\\\;" \
  83. "${ramdisk_image} fat 0 1\0" \
  84. "dfu_mmc=run dfu_mmc_info && dfu 0 mmc 0\0" \
  85. "thor_mmc=run dfu_mmc_info && thordown 0 mmc 0\0"
  86. # define DFU_ALT_INFO \
  87. DFU_ALT_INFO_RAM \
  88. DFU_ALT_INFO_MMC
  89. # else
  90. # define DFU_ALT_INFO \
  91. DFU_ALT_INFO_RAM
  92. # endif
  93. #endif
  94. #if !defined(DFU_ALT_INFO)
  95. # define DFU_ALT_INFO
  96. #endif
  97. /* I2C */
  98. #if defined(CONFIG_SYS_I2C_ZYNQ)
  99. # define CONFIG_SYS_I2C
  100. #endif
  101. /* EEPROM */
  102. #ifdef CONFIG_ZYNQ_EEPROM
  103. # define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
  104. # define CONFIG_SYS_I2C_EEPROM_ADDR 0x54
  105. # define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 4
  106. # define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS 5
  107. # define CONFIG_SYS_EEPROM_SIZE 1024 /* Bytes */
  108. #endif
  109. /* Total Size of Environment Sector */
  110. #ifndef CONFIG_ENV_SIZE
  111. # define CONFIG_ENV_SIZE (128 << 10)
  112. #endif
  113. /* Allow to overwrite serial and ethaddr */
  114. #define CONFIG_ENV_OVERWRITE
  115. /* Environment */
  116. #ifndef CONFIG_ENV_IS_NOWHERE
  117. # define CONFIG_ENV_SECT_SIZE CONFIG_ENV_SIZE
  118. # ifndef CONFIG_ENV_OFFSET
  119. # define CONFIG_ENV_OFFSET 0xE0000
  120. # endif
  121. #endif
  122. /* enable preboot to be loaded before CONFIG_BOOTDELAY */
  123. #define CONFIG_PREBOOT
  124. /* Boot configuration */
  125. #define CONFIG_SYS_LOAD_ADDR 0 /* default? */
  126. /* Distro boot enablement */
  127. #ifdef CONFIG_SPL_BUILD
  128. #define BOOTENV
  129. #else
  130. #ifdef CONFIG_CMD_MMC
  131. #define BOOT_TARGET_DEVICES_MMC(func) func(MMC, mmc, 0)
  132. #else
  133. #define BOOT_TARGET_DEVICES_MMC(func)
  134. #endif
  135. #ifdef CONFIG_CMD_USB
  136. #define BOOT_TARGET_DEVICES_USB(func) func(USB, usb, 0)
  137. #else
  138. #define BOOT_TARGET_DEVICES_USB(func)
  139. #endif
  140. #if defined(CONFIG_CMD_PXE) && defined(CONFIG_CMD_DHCP)
  141. #define BOOT_TARGET_DEVICES_PXE(func) func(PXE, pxe, na)
  142. #else
  143. #define BOOT_TARGET_DEVICES_PXE(func)
  144. #endif
  145. #if defined(CONFIG_CMD_DHCP)
  146. #define BOOT_TARGET_DEVICES_DHCP(func) func(DHCP, dhcp, na)
  147. #else
  148. #define BOOT_TARGET_DEVICES_DHCP(func)
  149. #endif
  150. #define BOOT_TARGET_DEVICES(func) \
  151. BOOT_TARGET_DEVICES_MMC(func) \
  152. BOOT_TARGET_DEVICES_USB(func) \
  153. BOOT_TARGET_DEVICES_PXE(func) \
  154. BOOT_TARGET_DEVICES_DHCP(func)
  155. #include <config_distro_bootcmd.h>
  156. #endif /* CONFIG_SPL_BUILD */
  157. /* Default environment */
  158. #ifndef CONFIG_EXTRA_ENV_SETTINGS
  159. #define CONFIG_EXTRA_ENV_SETTINGS \
  160. "fit_image=fit.itb\0" \
  161. "load_addr=0x2000000\0" \
  162. "fit_size=0x800000\0" \
  163. "flash_off=0x100000\0" \
  164. "nor_flash_off=0xE2100000\0" \
  165. "fdt_high=0x20000000\0" \
  166. "initrd_high=0x20000000\0" \
  167. "loadbootenv_addr=0x2000000\0" \
  168. "fdt_addr_r=0x1f00000\0" \
  169. "pxefile_addr_r=0x2000000\0" \
  170. "kernel_addr_r=0x2000000\0" \
  171. "scriptaddr=0x3000000\0" \
  172. "ramdisk_addr_r=0x3100000\0" \
  173. "bootenv=uEnv.txt\0" \
  174. "bootenv_dev=mmc\0" \
  175. "loadbootenv=load ${bootenv_dev} 0 ${loadbootenv_addr} ${bootenv}\0" \
  176. "importbootenv=echo Importing environment from ${bootenv_dev} ...; " \
  177. "env import -t ${loadbootenv_addr} $filesize\0" \
  178. "bootenv_existence_test=test -e ${bootenv_dev} 0 /${bootenv}\0" \
  179. "setbootenv=if env run bootenv_existence_test; then " \
  180. "if env run loadbootenv; then " \
  181. "env run importbootenv; " \
  182. "fi; " \
  183. "fi; \0" \
  184. "sd_loadbootenv=set bootenv_dev mmc && " \
  185. "run setbootenv \0" \
  186. "usb_loadbootenv=set bootenv_dev usb && usb start && run setbootenv \0" \
  187. "preboot=if test $modeboot = sdboot; then " \
  188. "run sd_loadbootenv; " \
  189. "echo Checking if uenvcmd is set ...; " \
  190. "if test -n $uenvcmd; then " \
  191. "echo Running uenvcmd ...; " \
  192. "run uenvcmd; " \
  193. "fi; " \
  194. "fi; \0" \
  195. "norboot=echo Copying FIT from NOR flash to RAM... && " \
  196. "cp.b ${nor_flash_off} ${load_addr} ${fit_size} && " \
  197. "bootm ${load_addr}\0" \
  198. "sdboot=echo Copying FIT from SD to RAM... && " \
  199. "load mmc 0 ${load_addr} ${fit_image} && " \
  200. "bootm ${load_addr}\0" \
  201. "jtagboot=echo TFTPing FIT to RAM... && " \
  202. "tftpboot ${load_addr} ${fit_image} && " \
  203. "bootm ${load_addr}\0" \
  204. "usbboot=if usb start; then " \
  205. "echo Copying FIT from USB to RAM... && " \
  206. "load usb 0 ${load_addr} ${fit_image} && " \
  207. "bootm ${load_addr}; fi\0" \
  208. DFU_ALT_INFO \
  209. BOOTENV
  210. #endif
  211. /* Miscellaneous configurable options */
  212. #define CONFIG_CLOCKS
  213. #define CONFIG_SYS_MAXARGS 32 /* max number of command args */
  214. #ifndef CONFIG_NR_DRAM_BANKS
  215. # define CONFIG_NR_DRAM_BANKS 1
  216. #endif
  217. #define CONFIG_SYS_MEMTEST_START 0
  218. #define CONFIG_SYS_MEMTEST_END 0x1000
  219. #define CONFIG_SYS_MALLOC_LEN 0x1400000
  220. #define CONFIG_SYS_INIT_RAM_ADDR 0xFFFF0000
  221. #define CONFIG_SYS_INIT_RAM_SIZE 0x1000
  222. #define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_INIT_RAM_ADDR + \
  223. CONFIG_SYS_INIT_RAM_SIZE - \
  224. GENERATED_GBL_DATA_SIZE)
  225. /* Extend size of kernel image for uncompression */
  226. #define CONFIG_SYS_BOOTM_LEN (60 * 1024 * 1024)
  227. /* Boot FreeBSD/vxWorks from an ELF image */
  228. #define CONFIG_SYS_MMC_MAX_DEVICE 1
  229. #define CONFIG_SYS_LDSCRIPT "arch/arm/mach-zynq/u-boot.lds"
  230. /* Commands */
  231. /* SPL part */
  232. /* MMC support */
  233. #ifdef CONFIG_MMC_SDHCI_ZYNQ
  234. #define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION 1
  235. #define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME "u-boot.img"
  236. #endif
  237. /* Disable dcache for SPL just for sure */
  238. #ifdef CONFIG_SPL_BUILD
  239. #define CONFIG_SYS_DCACHE_OFF
  240. #endif
  241. /* Address in RAM where the parameters must be copied by SPL. */
  242. #define CONFIG_SYS_SPL_ARGS_ADDR 0x10000000
  243. #define CONFIG_SPL_FS_LOAD_ARGS_NAME "system.dtb"
  244. #define CONFIG_SPL_FS_LOAD_KERNEL_NAME "uImage"
  245. /* Not using MMC raw mode - just for compilation purpose */
  246. #define CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR 0
  247. #define CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS 0
  248. #define CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR 0
  249. /* qspi mode is working fine */
  250. #ifdef CONFIG_ZYNQ_QSPI
  251. #define CONFIG_SYS_SPI_U_BOOT_OFFS 0x100000
  252. #define CONFIG_SYS_SPI_ARGS_OFFS 0x200000
  253. #define CONFIG_SYS_SPI_ARGS_SIZE 0x80000
  254. #define CONFIG_SYS_SPI_KERNEL_OFFS (CONFIG_SYS_SPI_ARGS_OFFS + \
  255. CONFIG_SYS_SPI_ARGS_SIZE)
  256. #endif
  257. /* for booting directly linux */
  258. /* SP location before relocation, must use scratch RAM */
  259. #define CONFIG_SPL_TEXT_BASE 0x0
  260. /* 3 * 64kB blocks of OCM - one is on the top because of bootrom */
  261. #define CONFIG_SPL_MAX_SIZE 0x30000
  262. /* On the top of OCM space */
  263. #define CONFIG_SYS_SPL_MALLOC_START CONFIG_SPL_STACK_R_ADDR
  264. #define CONFIG_SYS_SPL_MALLOC_SIZE 0x2000000
  265. /*
  266. * SPL stack position - and stack goes down
  267. * 0xfffffe00 is used for putting wfi loop.
  268. * Set it up as limit for now.
  269. */
  270. #define CONFIG_SPL_STACK 0xfffffe00
  271. /* BSS setup */
  272. #define CONFIG_SPL_BSS_START_ADDR 0x100000
  273. #define CONFIG_SPL_BSS_MAX_SIZE 0x100000
  274. #define CONFIG_SYS_UBOOT_START CONFIG_SYS_TEXT_BASE
  275. #endif /* __CONFIG_ZYNQ_COMMON_H */