board_common.mk 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. #
  2. # Copyright (c) 2015 - 2021, Broadcom
  3. #
  4. # SPDX-License-Identifier: BSD-3-Clause
  5. #
  6. PLAT_BL_COMMON_SOURCES += plat/brcm/board/common/board_common.c
  7. # If no board config makefile, do not include it
  8. ifneq (${BOARD_CFG},)
  9. BOARD_CFG_MAKE := $(shell find plat/brcm/board/${PLAT} -name '${BOARD_CFG}.mk')
  10. $(eval $(call add_define,BOARD_CFG))
  11. ifneq (${BOARD_CFG_MAKE},)
  12. $(info Including ${BOARD_CFG_MAKE})
  13. include ${BOARD_CFG_MAKE}
  14. else
  15. $(error Error: File ${BOARD_CFG}.mk not found in plat/brcm/board/${PLAT})
  16. endif
  17. endif
  18. # To compile with highest log level (VERBOSE) set value to 50
  19. LOG_LEVEL := 40
  20. # Use custom generic timer clock
  21. ifneq (${GENTIMER_ACTUAL_CLOCK},)
  22. $(info Using GENTIMER_ACTUAL_CLOCK=$(GENTIMER_ACTUAL_CLOCK))
  23. SYSCNT_FREQ := $(GENTIMER_ACTUAL_CLOCK)
  24. $(eval $(call add_define,SYSCNT_FREQ))
  25. endif
  26. ifeq (${DRIVER_EMMC_ENABLE},)
  27. DRIVER_EMMC_ENABLE :=1
  28. endif
  29. ifeq (${DRIVER_SPI_ENABLE},)
  30. DRIVER_SPI_ENABLE := 0
  31. endif
  32. ifeq (${DRIVER_I2C_ENABLE},)
  33. DRIVER_I2C_ENABLE := 0
  34. endif
  35. # By default, Trusted Watchdog is always enabled unless SPIN_ON_BL1_EXIT is set
  36. ifeq (${BRCM_DISABLE_TRUSTED_WDOG},)
  37. BRCM_DISABLE_TRUSTED_WDOG := 0
  38. endif
  39. ifeq (${SPIN_ON_BL1_EXIT}, 1)
  40. BRCM_DISABLE_TRUSTED_WDOG := 1
  41. endif
  42. $(eval $(call assert_boolean,BRCM_DISABLE_TRUSTED_WDOG))
  43. $(eval $(call add_define,BRCM_DISABLE_TRUSTED_WDOG))
  44. # Process ARM_BL31_IN_DRAM flag
  45. ifeq (${ARM_BL31_IN_DRAM},)
  46. ARM_BL31_IN_DRAM := 0
  47. endif
  48. $(eval $(call assert_boolean,ARM_BL31_IN_DRAM))
  49. $(eval $(call add_define,ARM_BL31_IN_DRAM))
  50. ifeq (${STANDALONE_BL2},yes)
  51. BL2_LOG_LEVEL := 40
  52. $(eval $(call add_define,MMU_DISABLED))
  53. endif
  54. # BL2 XIP from QSPI
  55. RUN_BL2_FROM_QSPI := 0
  56. ifeq (${RUN_BL2_FROM_QSPI},1)
  57. $(eval $(call add_define,RUN_BL2_FROM_QSPI))
  58. endif
  59. # BL2 XIP from NAND
  60. RUN_BL2_FROM_NAND := 0
  61. ifeq (${RUN_BL2_FROM_NAND},1)
  62. $(eval $(call add_define,RUN_BL2_FROM_NAND))
  63. endif
  64. ifneq (${ELOG_AP_UART_LOG_BASE},)
  65. $(eval $(call add_define,ELOG_AP_UART_LOG_BASE))
  66. endif
  67. ifeq (${ELOG_SUPPORT},1)
  68. ifeq (${ELOG_STORE_MEDIA},DDR)
  69. $(eval $(call add_define,ELOG_STORE_MEDIA_DDR))
  70. ifneq (${ELOG_STORE_OFFSET},)
  71. $(eval $(call add_define,ELOG_STORE_OFFSET))
  72. endif
  73. endif
  74. endif
  75. ifneq (${BL2_LOG_LEVEL},)
  76. $(eval $(call add_define,BL2_LOG_LEVEL))
  77. endif
  78. ifneq (${BL31_LOG_LEVEL},)
  79. $(eval $(call add_define,BL31_LOG_LEVEL))
  80. endif
  81. # Use CRMU SRAM from iHOST
  82. ifneq (${USE_CRMU_SRAM},)
  83. $(eval $(call add_define,USE_CRMU_SRAM))
  84. endif
  85. # Use PIO mode if DDR is not used
  86. ifeq (${USE_DDR},yes)
  87. EMMC_USE_DMA := 1
  88. else
  89. EMMC_USE_DMA := 0
  90. endif
  91. $(eval $(call add_define,EMMC_USE_DMA))
  92. # On BRCM platforms, separate the code and read-only data sections to allow
  93. # mapping the former as executable and the latter as execute-never.
  94. SEPARATE_CODE_AND_RODATA := 1
  95. # Use generic OID definition (tbbr_oid.h)
  96. USE_TBBR_DEFS := 1
  97. PLAT_INCLUDES += -Iplat/brcm/board/common \
  98. -Iinclude/drivers/brcm \
  99. -Iinclude/drivers/brcm/emmc \
  100. -Iinclude/drivers/brcm/mdio
  101. PLAT_BL_COMMON_SOURCES += plat/brcm/common/brcm_common.c \
  102. plat/brcm/board/common/cmn_sec.c \
  103. plat/brcm/board/common/bcm_console.c \
  104. plat/brcm/board/common/brcm_mbedtls.c \
  105. plat/brcm/board/common/plat_setup.c \
  106. plat/brcm/board/common/platform_common.c \
  107. drivers/arm/sp804/sp804_delay_timer.c \
  108. drivers/brcm/sotp.c \
  109. drivers/delay_timer/delay_timer.c \
  110. drivers/io/io_fip.c \
  111. drivers/io/io_memmap.c \
  112. drivers/io/io_storage.c \
  113. plat/brcm/common/brcm_io_storage.c \
  114. plat/brcm/board/common/err.c \
  115. plat/brcm/board/common/sbl_util.c \
  116. drivers/arm/sp805/sp805.c
  117. # Add RNG driver
  118. DRIVER_RNG_ENABLE := 1
  119. ifeq (${DRIVER_RNG_ENABLE},1)
  120. PLAT_BL_COMMON_SOURCES += drivers/brcm/rng.c
  121. endif
  122. # Add eMMC driver
  123. ifeq (${DRIVER_EMMC_ENABLE},1)
  124. $(eval $(call add_define,DRIVER_EMMC_ENABLE))
  125. EMMC_SOURCES += drivers/brcm/emmc/emmc_chal_sd.c \
  126. drivers/brcm/emmc/emmc_csl_sdcard.c \
  127. drivers/brcm/emmc/emmc_csl_sdcmd.c \
  128. drivers/brcm/emmc/emmc_pboot_hal_memory_drv.c
  129. PLAT_BL_COMMON_SOURCES += ${EMMC_SOURCES}
  130. ifeq (${DRIVER_EMMC_ENABLE_DATA_WIDTH_8BIT},)
  131. $(eval $(call add_define,DRIVER_EMMC_ENABLE_DATA_WIDTH_8BIT))
  132. endif
  133. endif
  134. BL2_SOURCES += plat/brcm/common/brcm_bl2_mem_params_desc.c \
  135. plat/brcm/common/brcm_image_load.c \
  136. common/desc_image_load.c
  137. BL2_SOURCES += plat/brcm/common/brcm_bl2_setup.c
  138. BL31_SOURCES += plat/brcm/common/brcm_bl31_setup.c
  139. ifeq (${BCM_ELOG},yes)
  140. ELOG_SOURCES += plat/brcm/board/common/bcm_elog.c
  141. BL2_SOURCES += ${ELOG_SOURCES}
  142. BL31_SOURCES += ${ELOG_SOURCES}
  143. endif
  144. # Add spi driver
  145. ifeq (${DRIVER_SPI_ENABLE},1)
  146. PLAT_BL_COMMON_SOURCES += drivers/brcm/spi/iproc_spi.c \
  147. drivers/brcm/spi/iproc_qspi.c
  148. endif
  149. # Add spi nor/flash driver
  150. ifeq (${DRIVER_SPI_NOR_ENABLE},1)
  151. PLAT_BL_COMMON_SOURCES += drivers/brcm/spi_sf.c \
  152. drivers/brcm/spi_flash.c
  153. endif
  154. ifeq (${DRIVER_I2C_ENABLE},1)
  155. $(eval $(call add_define,DRIVER_I2C_ENABLE))
  156. BL2_SOURCES += drivers/brcm/i2c/i2c.c
  157. PLAT_INCLUDES += -Iinclude/drivers/brcm/i2c
  158. endif
  159. ifeq (${DRIVER_OCOTP_ENABLE},1)
  160. $(eval $(call add_define,DRIVER_OCOTP_ENABLE))
  161. BL2_SOURCES += drivers/brcm/ocotp.c
  162. endif
  163. # Enable FRU table support
  164. ifeq (${USE_FRU},yes)
  165. $(eval $(call add_define,USE_FRU))
  166. BL2_SOURCES += drivers/brcm/fru.c
  167. endif
  168. # Enable GPIO support
  169. ifeq (${USE_GPIO},yes)
  170. $(eval $(call add_define,USE_GPIO))
  171. BL2_SOURCES += drivers/gpio/gpio.c
  172. BL2_SOURCES += drivers/brcm/iproc_gpio.c
  173. ifeq (${GPIO_SUPPORT_FLOAT_DETECTION},yes)
  174. $(eval $(call add_define,GPIO_SUPPORT_FLOAT_DETECTION))
  175. endif
  176. endif
  177. # Include mbedtls if it can be located
  178. MBEDTLS_DIR ?= mbedtls
  179. MBEDTLS_CHECK := $(shell find ${MBEDTLS_DIR}/include -name '$(notdir ${MBEDTLS_DIR})')
  180. ifneq (${MBEDTLS_CHECK},)
  181. $(info Found mbedTLS at ${MBEDTLS_DIR})
  182. PLAT_INCLUDES += -I${MBEDTLS_DIR}/include/mbedtls
  183. # By default, use RSA keys
  184. KEY_ALG := rsa_1_5
  185. # Include common TBB sources
  186. AUTH_SOURCES += drivers/auth/auth_mod.c \
  187. drivers/auth/crypto_mod.c \
  188. drivers/auth/img_parser_mod.c \
  189. drivers/auth/tbbr/tbbr_cot_common.c \
  190. drivers/auth/tbbr/tbbr_cot_bl2.c
  191. BL2_SOURCES += ${AUTH_SOURCES}
  192. # Use ATF framework for MBEDTLS
  193. TRUSTED_BOARD_BOOT := 1
  194. CRYPTO_LIB_MK := drivers/auth/mbedtls/mbedtls_crypto.mk
  195. IMG_PARSER_LIB_MK := drivers/auth/mbedtls/mbedtls_x509.mk
  196. $(info Including ${CRYPTO_LIB_MK})
  197. include ${CRYPTO_LIB_MK}
  198. $(info Including ${IMG_PARSER_LIB_MK})
  199. include ${IMG_PARSER_LIB_MK}
  200. # Use ATF secure boot functions
  201. # Use Hardcoded hash for devel
  202. ARM_ROTPK_LOCATION=arm_rsa
  203. ifeq (${ARM_ROTPK_LOCATION}, arm_rsa)
  204. ARM_ROTPK_LOCATION_ID=ARM_ROTPK_DEVEL_RSA_ID
  205. ROT_KEY=plat/arm/board/common/rotpk/arm_rotprivk_rsa.pem
  206. else ifeq (${ARM_ROTPK_LOCATION}, brcm_rsa)
  207. ARM_ROTPK_LOCATION_ID=BRCM_ROTPK_SOTP_RSA_ID
  208. ifeq (${ROT_KEY},)
  209. ROT_KEY=plat/brcm/board/common/rotpk/rsa_dauth2048_key.pem
  210. endif
  211. KEY_FIND := $(shell m="${ROT_KEY}"; [ -f "$$m" ] && echo "$$m")
  212. ifeq (${KEY_FIND},)
  213. $(error Error: No ${ROT_KEY} located)
  214. else
  215. $(info Using ROT_KEY: ${ROT_KEY})
  216. endif
  217. else
  218. $(error "Unsupported ARM_ROTPK_LOCATION value")
  219. endif
  220. $(eval $(call add_define,ARM_ROTPK_LOCATION_ID))
  221. PLAT_BL_COMMON_SOURCES+=plat/brcm/board/common/board_arm_trusted_boot.c
  222. endif
  223. #M0 runtime firmware
  224. ifdef SCP_BL2
  225. $(eval $(call add_define,NEED_SCP_BL2))
  226. SCP_CFG_DIR=$(dir ${SCP_BL2})
  227. PLAT_INCLUDES += -I${SCP_CFG_DIR}
  228. endif
  229. ifneq (${NEED_BL33},yes)
  230. # If there is no BL33, BL31 will jump to this address.
  231. ifeq (${USE_DDR},yes)
  232. PRELOADED_BL33_BASE := 0x80000000
  233. else
  234. PRELOADED_BL33_BASE := 0x74000000
  235. endif
  236. endif
  237. # Use translation tables library v1 by default
  238. ARM_XLAT_TABLES_LIB_V1 := 1
  239. ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
  240. $(eval $(call assert_boolean,ARM_XLAT_TABLES_LIB_V1))
  241. $(eval $(call add_define,ARM_XLAT_TABLES_LIB_V1))
  242. PLAT_BL_COMMON_SOURCES += lib/xlat_tables/aarch64/xlat_tables.c \
  243. lib/xlat_tables/xlat_tables_common.c
  244. endif