zynq-common.h 7.9 KB

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