socfpga_common.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. /*
  2. * Copyright (C) 2012 Altera Corporation <www.altera.com>
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #ifndef __CONFIG_SOCFPGA_COMMON_H__
  7. #define __CONFIG_SOCFPGA_COMMON_H__
  8. /* Virtual target or real hardware */
  9. #undef CONFIG_SOCFPGA_VIRTUAL_TARGET
  10. #define CONFIG_SYS_THUMB_BUILD
  11. /*
  12. * High level configuration
  13. */
  14. #define CONFIG_DISPLAY_BOARDINFO_LATE
  15. #define CONFIG_ARCH_MISC_INIT
  16. #define CONFIG_ARCH_EARLY_INIT_R
  17. #define CONFIG_SYS_NO_FLASH
  18. #define CONFIG_CLOCKS
  19. #define CONFIG_CRC32_VERIFY
  20. #define CONFIG_SYS_BOOTMAPSZ (64 * 1024 * 1024)
  21. #define CONFIG_TIMESTAMP /* Print image info with timestamp */
  22. /* add target to build it automatically upon "make" */
  23. #define CONFIG_BUILD_TARGET "u-boot-with-spl.sfp"
  24. /*
  25. * Memory configurations
  26. */
  27. #define CONFIG_NR_DRAM_BANKS 1
  28. #define PHYS_SDRAM_1 0x0
  29. #define CONFIG_SYS_MALLOC_LEN (64 * 1024 * 1024)
  30. #define CONFIG_SYS_MEMTEST_START PHYS_SDRAM_1
  31. #define CONFIG_SYS_MEMTEST_END PHYS_SDRAM_1_SIZE
  32. #define CONFIG_SYS_INIT_RAM_ADDR 0xFFFF0000
  33. #define CONFIG_SYS_INIT_RAM_SIZE 0x10000
  34. #define CONFIG_SYS_INIT_SP_OFFSET \
  35. (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
  36. #define CONFIG_SYS_INIT_SP_ADDR \
  37. (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
  38. #define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1
  39. #ifdef CONFIG_SOCFPGA_VIRTUAL_TARGET
  40. #define CONFIG_SYS_TEXT_BASE 0x08000040
  41. #else
  42. #define CONFIG_SYS_TEXT_BASE 0x01000040
  43. #endif
  44. /*
  45. * U-Boot general configurations
  46. */
  47. #define CONFIG_SYS_LONGHELP
  48. #define CONFIG_SYS_CBSIZE 1024 /* Console I/O buffer size */
  49. #define CONFIG_SYS_PBSIZE \
  50. (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
  51. /* Print buffer size */
  52. #define CONFIG_SYS_MAXARGS 32 /* Max number of command args */
  53. #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE
  54. /* Boot argument buffer size */
  55. #define CONFIG_AUTO_COMPLETE /* Command auto complete */
  56. #define CONFIG_CMDLINE_EDITING /* Command history etc */
  57. #ifndef CONFIG_SYS_HOSTNAME
  58. #define CONFIG_SYS_HOSTNAME CONFIG_SYS_BOARD
  59. #endif
  60. /*
  61. * Cache
  62. */
  63. #define CONFIG_SYS_L2_PL310
  64. #define CONFIG_SYS_PL310_BASE SOCFPGA_MPUL2_ADDRESS
  65. /*
  66. * SDRAM controller
  67. */
  68. #define CONFIG_ALTERA_SDRAM
  69. /*
  70. * EPCS/EPCQx1 Serial Flash Controller
  71. */
  72. #ifdef CONFIG_ALTERA_SPI
  73. #define CONFIG_SF_DEFAULT_SPEED 30000000
  74. /*
  75. * The base address is configurable in QSys, each board must specify the
  76. * base address based on it's particular FPGA configuration. Please note
  77. * that the address here is incremented by 0x400 from the Base address
  78. * selected in QSys, since the SPI registers are at offset +0x400.
  79. * #define CONFIG_SYS_SPI_BASE 0xff240400
  80. */
  81. #endif
  82. /*
  83. * Ethernet on SoC (EMAC)
  84. */
  85. #if defined(CONFIG_CMD_NET) && !defined(CONFIG_SOCFPGA_VIRTUAL_TARGET)
  86. #define CONFIG_DW_ALTDESCRIPTOR
  87. #define CONFIG_MII
  88. #define CONFIG_AUTONEG_TIMEOUT (15 * CONFIG_SYS_HZ)
  89. #define CONFIG_PHY_GIGE
  90. #endif
  91. /*
  92. * FPGA Driver
  93. */
  94. #ifdef CONFIG_CMD_FPGA
  95. #define CONFIG_FPGA
  96. #define CONFIG_FPGA_ALTERA
  97. #define CONFIG_FPGA_SOCFPGA
  98. #define CONFIG_FPGA_COUNT 1
  99. #endif
  100. /*
  101. * L4 OSC1 Timer 0
  102. */
  103. /* This timer uses eosc1, whose clock frequency is fixed at any condition. */
  104. #define CONFIG_SYS_TIMERBASE SOCFPGA_OSC1TIMER0_ADDRESS
  105. #define CONFIG_SYS_TIMER_COUNTS_DOWN
  106. #define CONFIG_SYS_TIMER_COUNTER (CONFIG_SYS_TIMERBASE + 0x4)
  107. #ifdef CONFIG_SOCFPGA_VIRTUAL_TARGET
  108. #define CONFIG_SYS_TIMER_RATE 2400000
  109. #else
  110. #define CONFIG_SYS_TIMER_RATE 25000000
  111. #endif
  112. /*
  113. * L4 Watchdog
  114. */
  115. #ifdef CONFIG_HW_WATCHDOG
  116. #define CONFIG_DESIGNWARE_WATCHDOG
  117. #define CONFIG_DW_WDT_BASE SOCFPGA_L4WD0_ADDRESS
  118. #define CONFIG_DW_WDT_CLOCK_KHZ 25000
  119. #define CONFIG_HW_WATCHDOG_TIMEOUT_MS 30000
  120. #endif
  121. /*
  122. * MMC Driver
  123. */
  124. #ifdef CONFIG_CMD_MMC
  125. #define CONFIG_BOUNCE_BUFFER
  126. #define CONFIG_GENERIC_MMC
  127. #define CONFIG_DWMMC
  128. #define CONFIG_SOCFPGA_DWMMC
  129. #define CONFIG_SOCFPGA_DWMMC_FIFO_DEPTH 1024
  130. /* FIXME */
  131. /* using smaller max blk cnt to avoid flooding the limited stack we have */
  132. #define CONFIG_SYS_MMC_MAX_BLK_COUNT 256 /* FIXME -- SPL only? */
  133. #endif
  134. /*
  135. * NAND Support
  136. */
  137. #ifdef CONFIG_NAND_DENALI
  138. #define CONFIG_SYS_MAX_NAND_DEVICE 1
  139. #define CONFIG_SYS_NAND_MAX_CHIPS 1
  140. #define CONFIG_SYS_NAND_ONFI_DETECTION
  141. #define CONFIG_NAND_DENALI_ECC_SIZE 512
  142. #define CONFIG_SYS_NAND_REGS_BASE SOCFPGA_NANDREGS_ADDRESS
  143. #define CONFIG_SYS_NAND_DATA_BASE SOCFPGA_NANDDATA_ADDRESS
  144. #define CONFIG_SYS_NAND_BASE (CONFIG_SYS_NAND_DATA_BASE + 0x10)
  145. #endif
  146. /*
  147. * I2C support
  148. */
  149. #define CONFIG_SYS_I2C
  150. #define CONFIG_SYS_I2C_BUS_MAX 4
  151. #define CONFIG_SYS_I2C_BASE SOCFPGA_I2C0_ADDRESS
  152. #define CONFIG_SYS_I2C_BASE1 SOCFPGA_I2C1_ADDRESS
  153. #define CONFIG_SYS_I2C_BASE2 SOCFPGA_I2C2_ADDRESS
  154. #define CONFIG_SYS_I2C_BASE3 SOCFPGA_I2C3_ADDRESS
  155. /* Using standard mode which the speed up to 100Kb/s */
  156. #define CONFIG_SYS_I2C_SPEED 100000
  157. #define CONFIG_SYS_I2C_SPEED1 100000
  158. #define CONFIG_SYS_I2C_SPEED2 100000
  159. #define CONFIG_SYS_I2C_SPEED3 100000
  160. /* Address of device when used as slave */
  161. #define CONFIG_SYS_I2C_SLAVE 0x02
  162. #define CONFIG_SYS_I2C_SLAVE1 0x02
  163. #define CONFIG_SYS_I2C_SLAVE2 0x02
  164. #define CONFIG_SYS_I2C_SLAVE3 0x02
  165. #ifndef __ASSEMBLY__
  166. /* Clock supplied to I2C controller in unit of MHz */
  167. unsigned int cm_get_l4_sp_clk_hz(void);
  168. #define IC_CLK (cm_get_l4_sp_clk_hz() / 1000000)
  169. #endif
  170. /*
  171. * QSPI support
  172. */
  173. /* Enable multiple SPI NOR flash manufacturers */
  174. #ifndef CONFIG_SPL_BUILD
  175. #define CONFIG_SPI_FLASH_MTD
  176. #define CONFIG_CMD_MTDPARTS
  177. #define CONFIG_MTD_DEVICE
  178. #define CONFIG_MTD_PARTITIONS
  179. #define MTDIDS_DEFAULT "nor0=ff705000.spi.0"
  180. #endif
  181. /* QSPI reference clock */
  182. #ifndef __ASSEMBLY__
  183. unsigned int cm_get_qspi_controller_clk_hz(void);
  184. #define CONFIG_CQSPI_REF_CLK cm_get_qspi_controller_clk_hz()
  185. #endif
  186. #define CONFIG_CQSPI_DECODER 0
  187. #define CONFIG_BOUNCE_BUFFER
  188. /*
  189. * Designware SPI support
  190. */
  191. /*
  192. * Serial Driver
  193. */
  194. #define CONFIG_SYS_NS16550_SERIAL
  195. #define CONFIG_SYS_NS16550_REG_SIZE -4
  196. #define CONFIG_SYS_NS16550_COM1 SOCFPGA_UART0_ADDRESS
  197. #ifdef CONFIG_SOCFPGA_VIRTUAL_TARGET
  198. #define CONFIG_SYS_NS16550_CLK 1000000
  199. #else
  200. #define CONFIG_SYS_NS16550_CLK 100000000
  201. #endif
  202. #define CONFIG_CONS_INDEX 1
  203. #define CONFIG_BAUDRATE 115200
  204. /*
  205. * USB
  206. */
  207. #ifdef CONFIG_CMD_USB
  208. #define CONFIG_USB_DWC2
  209. #endif
  210. /*
  211. * USB Gadget (DFU, UMS)
  212. */
  213. #if defined(CONFIG_CMD_DFU) || defined(CONFIG_CMD_USB_MASS_STORAGE)
  214. #define CONFIG_USB_FUNCTION_MASS_STORAGE
  215. #define CONFIG_SYS_DFU_DATA_BUF_SIZE (32 * 1024 * 1024)
  216. #define DFU_DEFAULT_POLL_TIMEOUT 300
  217. /* USB IDs */
  218. #define CONFIG_G_DNL_UMS_VENDOR_NUM 0x0525
  219. #define CONFIG_G_DNL_UMS_PRODUCT_NUM 0xA4A5
  220. #endif
  221. /*
  222. * U-Boot environment
  223. */
  224. #if !defined(CONFIG_ENV_SIZE)
  225. #define CONFIG_ENV_SIZE 4096
  226. #endif
  227. /* Environment for SDMMC boot */
  228. #if defined(CONFIG_ENV_IS_IN_MMC) && !defined(CONFIG_ENV_OFFSET)
  229. #define CONFIG_SYS_MMC_ENV_DEV 0 /* device 0 */
  230. #define CONFIG_ENV_OFFSET 512 /* just after the MBR */
  231. #endif
  232. /* Environment for QSPI boot */
  233. #if defined(CONFIG_ENV_IS_IN_SPI_FLASH) && !defined(CONFIG_ENV_OFFSET)
  234. #define CONFIG_ENV_OFFSET 0x00100000
  235. #define CONFIG_ENV_SECT_SIZE (64 * 1024)
  236. #endif
  237. /*
  238. * mtd partitioning for serial NOR flash
  239. *
  240. * device nor0 <ff705000.spi.0>, # parts = 6
  241. * #: name size offset mask_flags
  242. * 0: u-boot 0x00100000 0x00000000 0
  243. * 1: env1 0x00040000 0x00100000 0
  244. * 2: env2 0x00040000 0x00140000 0
  245. * 3: UBI 0x03e80000 0x00180000 0
  246. * 4: boot 0x00e80000 0x00180000 0
  247. * 5: rootfs 0x01000000 0x01000000 0
  248. *
  249. */
  250. #if defined(CONFIG_CMD_SF) && !defined(MTDPARTS_DEFAULT)
  251. #define MTDPARTS_DEFAULT "mtdparts=ff705000.spi.0:"\
  252. "1m(u-boot)," \
  253. "256k(env1)," \
  254. "256k(env2)," \
  255. "14848k(boot)," \
  256. "16m(rootfs)," \
  257. "-@1536k(UBI)\0"
  258. #endif
  259. /* UBI and UBIFS support */
  260. #if defined(CONFIG_CMD_SF) || defined(CONFIG_CMD_NAND)
  261. #define CONFIG_CMD_UBIFS
  262. #define CONFIG_RBTREE
  263. #define CONFIG_LZO
  264. #endif
  265. /*
  266. * SPL
  267. *
  268. * SRAM Memory layout:
  269. *
  270. * 0xFFFF_0000 ...... Start of SRAM
  271. * 0xFFFF_xxxx ...... Top of stack (grows down)
  272. * 0xFFFF_yyyy ...... Malloc area
  273. * 0xFFFF_zzzz ...... Global Data
  274. * 0xFFFF_FF00 ...... End of SRAM
  275. */
  276. #define CONFIG_SPL_FRAMEWORK
  277. #define CONFIG_SPL_RAM_DEVICE
  278. #define CONFIG_SPL_TEXT_BASE CONFIG_SYS_INIT_RAM_ADDR
  279. #define CONFIG_SPL_MAX_SIZE (64 * 1024)
  280. /* SPL SDMMC boot support */
  281. #ifdef CONFIG_SPL_MMC_SUPPORT
  282. #if defined(CONFIG_SPL_FAT_SUPPORT) || defined(CONFIG_SPL_EXT_SUPPORT)
  283. #define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION 2
  284. #define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME "u-boot-dtb.img"
  285. #else
  286. #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION 1
  287. #endif
  288. #endif
  289. /* SPL QSPI boot support */
  290. #ifdef CONFIG_SPL_SPI_SUPPORT
  291. #define CONFIG_SPL_SPI_LOAD
  292. #define CONFIG_SYS_SPI_U_BOOT_OFFS 0x40000
  293. #endif
  294. /* SPL NAND boot support */
  295. #ifdef CONFIG_SPL_NAND_SUPPORT
  296. #define CONFIG_SYS_NAND_USE_FLASH_BBT
  297. #define CONFIG_SYS_NAND_BAD_BLOCK_POS 0
  298. #define CONFIG_SYS_NAND_U_BOOT_OFFS 0x40000
  299. #endif
  300. /*
  301. * Stack setup
  302. */
  303. #define CONFIG_SPL_STACK CONFIG_SYS_INIT_SP_ADDR
  304. #endif /* __CONFIG_SOCFPGA_COMMON_H__ */