socfpga_common.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  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. /* FIXME */
  128. /* using smaller max blk cnt to avoid flooding the limited stack we have */
  129. #define CONFIG_SYS_MMC_MAX_BLK_COUNT 256 /* FIXME -- SPL only? */
  130. #endif
  131. /*
  132. * NAND Support
  133. */
  134. #ifdef CONFIG_NAND_DENALI
  135. #define CONFIG_SYS_MAX_NAND_DEVICE 1
  136. #define CONFIG_SYS_NAND_MAX_CHIPS 1
  137. #define CONFIG_SYS_NAND_ONFI_DETECTION
  138. #define CONFIG_NAND_DENALI_ECC_SIZE 512
  139. #define CONFIG_SYS_NAND_REGS_BASE SOCFPGA_NANDREGS_ADDRESS
  140. #define CONFIG_SYS_NAND_DATA_BASE SOCFPGA_NANDDATA_ADDRESS
  141. #define CONFIG_SYS_NAND_BASE (CONFIG_SYS_NAND_DATA_BASE + 0x10)
  142. #endif
  143. /*
  144. * I2C support
  145. */
  146. #define CONFIG_SYS_I2C
  147. #define CONFIG_SYS_I2C_BUS_MAX 4
  148. #define CONFIG_SYS_I2C_BASE SOCFPGA_I2C0_ADDRESS
  149. #define CONFIG_SYS_I2C_BASE1 SOCFPGA_I2C1_ADDRESS
  150. #define CONFIG_SYS_I2C_BASE2 SOCFPGA_I2C2_ADDRESS
  151. #define CONFIG_SYS_I2C_BASE3 SOCFPGA_I2C3_ADDRESS
  152. /* Using standard mode which the speed up to 100Kb/s */
  153. #define CONFIG_SYS_I2C_SPEED 100000
  154. #define CONFIG_SYS_I2C_SPEED1 100000
  155. #define CONFIG_SYS_I2C_SPEED2 100000
  156. #define CONFIG_SYS_I2C_SPEED3 100000
  157. /* Address of device when used as slave */
  158. #define CONFIG_SYS_I2C_SLAVE 0x02
  159. #define CONFIG_SYS_I2C_SLAVE1 0x02
  160. #define CONFIG_SYS_I2C_SLAVE2 0x02
  161. #define CONFIG_SYS_I2C_SLAVE3 0x02
  162. #ifndef __ASSEMBLY__
  163. /* Clock supplied to I2C controller in unit of MHz */
  164. unsigned int cm_get_l4_sp_clk_hz(void);
  165. #define IC_CLK (cm_get_l4_sp_clk_hz() / 1000000)
  166. #endif
  167. /*
  168. * QSPI support
  169. */
  170. /* Enable multiple SPI NOR flash manufacturers */
  171. #ifndef CONFIG_SPL_BUILD
  172. #define CONFIG_SPI_FLASH_MTD
  173. #define CONFIG_CMD_MTDPARTS
  174. #define CONFIG_MTD_DEVICE
  175. #define CONFIG_MTD_PARTITIONS
  176. #define MTDIDS_DEFAULT "nor0=ff705000.spi.0"
  177. #endif
  178. /* QSPI reference clock */
  179. #ifndef __ASSEMBLY__
  180. unsigned int cm_get_qspi_controller_clk_hz(void);
  181. #define CONFIG_CQSPI_REF_CLK cm_get_qspi_controller_clk_hz()
  182. #endif
  183. #define CONFIG_CQSPI_DECODER 0
  184. #define CONFIG_BOUNCE_BUFFER
  185. /*
  186. * Designware SPI support
  187. */
  188. /*
  189. * Serial Driver
  190. */
  191. #define CONFIG_SYS_NS16550_SERIAL
  192. #define CONFIG_SYS_NS16550_REG_SIZE -4
  193. #define CONFIG_SYS_NS16550_COM1 SOCFPGA_UART0_ADDRESS
  194. #ifdef CONFIG_SOCFPGA_VIRTUAL_TARGET
  195. #define CONFIG_SYS_NS16550_CLK 1000000
  196. #else
  197. #define CONFIG_SYS_NS16550_CLK 100000000
  198. #endif
  199. #define CONFIG_CONS_INDEX 1
  200. #define CONFIG_BAUDRATE 115200
  201. /*
  202. * USB
  203. */
  204. #ifdef CONFIG_CMD_USB
  205. #define CONFIG_USB_DWC2
  206. #endif
  207. /*
  208. * USB Gadget (DFU, UMS)
  209. */
  210. #if defined(CONFIG_CMD_DFU) || defined(CONFIG_CMD_USB_MASS_STORAGE)
  211. #define CONFIG_USB_FUNCTION_MASS_STORAGE
  212. #define CONFIG_SYS_DFU_DATA_BUF_SIZE (32 * 1024 * 1024)
  213. #define DFU_DEFAULT_POLL_TIMEOUT 300
  214. /* USB IDs */
  215. #define CONFIG_G_DNL_UMS_VENDOR_NUM 0x0525
  216. #define CONFIG_G_DNL_UMS_PRODUCT_NUM 0xA4A5
  217. #endif
  218. /*
  219. * U-Boot environment
  220. */
  221. #if !defined(CONFIG_ENV_SIZE)
  222. #define CONFIG_ENV_SIZE 4096
  223. #endif
  224. /* Environment for SDMMC boot */
  225. #if defined(CONFIG_ENV_IS_IN_MMC) && !defined(CONFIG_ENV_OFFSET)
  226. #define CONFIG_SYS_MMC_ENV_DEV 0 /* device 0 */
  227. #define CONFIG_ENV_OFFSET 512 /* just after the MBR */
  228. #endif
  229. /* Environment for QSPI boot */
  230. #if defined(CONFIG_ENV_IS_IN_SPI_FLASH) && !defined(CONFIG_ENV_OFFSET)
  231. #define CONFIG_ENV_OFFSET 0x00100000
  232. #define CONFIG_ENV_SECT_SIZE (64 * 1024)
  233. #endif
  234. /*
  235. * mtd partitioning for serial NOR flash
  236. *
  237. * device nor0 <ff705000.spi.0>, # parts = 6
  238. * #: name size offset mask_flags
  239. * 0: u-boot 0x00100000 0x00000000 0
  240. * 1: env1 0x00040000 0x00100000 0
  241. * 2: env2 0x00040000 0x00140000 0
  242. * 3: UBI 0x03e80000 0x00180000 0
  243. * 4: boot 0x00e80000 0x00180000 0
  244. * 5: rootfs 0x01000000 0x01000000 0
  245. *
  246. */
  247. #if defined(CONFIG_CMD_SF) && !defined(MTDPARTS_DEFAULT)
  248. #define MTDPARTS_DEFAULT "mtdparts=ff705000.spi.0:"\
  249. "1m(u-boot)," \
  250. "256k(env1)," \
  251. "256k(env2)," \
  252. "14848k(boot)," \
  253. "16m(rootfs)," \
  254. "-@1536k(UBI)\0"
  255. #endif
  256. /* UBI and UBIFS support */
  257. #if defined(CONFIG_CMD_SF) || defined(CONFIG_CMD_NAND)
  258. #define CONFIG_CMD_UBIFS
  259. #define CONFIG_RBTREE
  260. #define CONFIG_LZO
  261. #endif
  262. /*
  263. * SPL
  264. *
  265. * SRAM Memory layout:
  266. *
  267. * 0xFFFF_0000 ...... Start of SRAM
  268. * 0xFFFF_xxxx ...... Top of stack (grows down)
  269. * 0xFFFF_yyyy ...... Malloc area
  270. * 0xFFFF_zzzz ...... Global Data
  271. * 0xFFFF_FF00 ...... End of SRAM
  272. */
  273. #define CONFIG_SPL_FRAMEWORK
  274. #define CONFIG_SPL_RAM_DEVICE
  275. #define CONFIG_SPL_TEXT_BASE CONFIG_SYS_INIT_RAM_ADDR
  276. #define CONFIG_SPL_MAX_SIZE (64 * 1024)
  277. /* SPL SDMMC boot support */
  278. #ifdef CONFIG_SPL_MMC_SUPPORT
  279. #if defined(CONFIG_SPL_FAT_SUPPORT) || defined(CONFIG_SPL_EXT_SUPPORT)
  280. #define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION 2
  281. #define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME "u-boot-dtb.img"
  282. #else
  283. #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION 1
  284. #endif
  285. #endif
  286. /* SPL QSPI boot support */
  287. #ifdef CONFIG_SPL_SPI_SUPPORT
  288. #define CONFIG_SPL_SPI_LOAD
  289. #define CONFIG_SYS_SPI_U_BOOT_OFFS 0x40000
  290. #endif
  291. /* SPL NAND boot support */
  292. #ifdef CONFIG_SPL_NAND_SUPPORT
  293. #define CONFIG_SYS_NAND_USE_FLASH_BBT
  294. #define CONFIG_SYS_NAND_BAD_BLOCK_POS 0
  295. #define CONFIG_SYS_NAND_U_BOOT_OFFS 0x40000
  296. #endif
  297. /*
  298. * Stack setup
  299. */
  300. #define CONFIG_SPL_STACK CONFIG_SYS_INIT_SP_ADDR
  301. #endif /* __CONFIG_SOCFPGA_COMMON_H__ */