platform.mk 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. #
  2. # Copyright (c) 2023-2024, STMicroelectronics - All Rights Reserved
  3. #
  4. # SPDX-License-Identifier: BSD-3-Clause
  5. #
  6. # Extra partitions used to find FIP, contains:
  7. # metadata (2) and fsbl-m (2) and the FIP partitions (default is 2).
  8. STM32_EXTRA_PARTS := 6
  9. include plat/st/common/common.mk
  10. CRASH_REPORTING := 1
  11. ENABLE_PIE := 1
  12. PROGRAMMABLE_RESET_ADDRESS := 1
  13. BL2_IN_XIP_MEM := 1
  14. STM32MP_BL33_EL1 ?= 1
  15. ifeq ($(STM32MP_BL33_EL1),1)
  16. INIT_UNUSED_NS_EL2 := 1
  17. endif
  18. # Disable features unsupported in ARMv8.0
  19. ENABLE_SPE_FOR_NS := 0
  20. ENABLE_SVE_FOR_NS := 0
  21. # Default Device tree
  22. DTB_FILE_NAME ?= stm32mp257f-ev1.dtb
  23. STM32MP25 := 1
  24. # STM32 image header version v2.2
  25. STM32_HEADER_VERSION_MAJOR := 2
  26. STM32_HEADER_VERSION_MINOR := 2
  27. # Set load address for serial boot devices
  28. DWL_BUFFER_BASE ?= 0x87000000
  29. # DDR types
  30. STM32MP_DDR3_TYPE ?= 0
  31. STM32MP_DDR4_TYPE ?= 0
  32. STM32MP_LPDDR4_TYPE ?= 0
  33. ifeq (${STM32MP_DDR3_TYPE},1)
  34. DDR_TYPE := ddr3
  35. endif
  36. ifeq (${STM32MP_DDR4_TYPE},1)
  37. DDR_TYPE := ddr4
  38. endif
  39. ifeq (${STM32MP_LPDDR4_TYPE},1)
  40. DDR_TYPE := lpddr4
  41. endif
  42. # DDR features
  43. STM32MP_DDR_DUAL_AXI_PORT := 1
  44. STM32MP_DDR_FIP_IO_STORAGE := 1
  45. # Device tree
  46. BL2_DTSI := stm32mp25-bl2.dtsi
  47. FDT_SOURCES := $(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl2.dts,$(DTB_FILE_NAME)))
  48. BL31_DTSI := stm32mp25-bl31.dtsi
  49. FDT_SOURCES += $(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl31.dts,$(DTB_FILE_NAME)))
  50. # Macros and rules to build TF binary
  51. STM32_TF_STM32 := $(addprefix ${BUILD_PLAT}/tf-a-, $(patsubst %.dtb,%.stm32,$(DTB_FILE_NAME)))
  52. STM32_LD_FILE := plat/st/stm32mp2/${ARCH}/stm32mp2.ld.S
  53. STM32_BINARY_MAPPING := plat/st/stm32mp2/${ARCH}/stm32mp2.S
  54. STM32MP_FW_CONFIG_NAME := $(patsubst %.dtb,%-fw-config.dtb,$(DTB_FILE_NAME))
  55. STM32MP_FW_CONFIG := ${BUILD_PLAT}/fdts/$(STM32MP_FW_CONFIG_NAME)
  56. STM32MP_SOC_FW_CONFIG := $(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl31.dtb,$(DTB_FILE_NAME)))
  57. ifeq (${STM32MP_DDR_FIP_IO_STORAGE},1)
  58. STM32MP_DDR_FW_PATH ?= drivers/st/ddr/phy/firmware/bin/stm32mp2
  59. STM32MP_DDR_FW_NAME := ${DDR_TYPE}_pmu_train.bin
  60. STM32MP_DDR_FW := ${STM32MP_DDR_FW_PATH}/${STM32MP_DDR_FW_NAME}
  61. endif
  62. FDT_SOURCES += $(addprefix fdts/, $(patsubst %.dtb,%.dts,$(STM32MP_FW_CONFIG_NAME)))
  63. # Add the FW_CONFIG to FIP and specify the same to certtool
  64. $(eval $(call TOOL_ADD_PAYLOAD,${STM32MP_FW_CONFIG},--fw-config))
  65. # Add the SOC_FW_CONFIG to FIP and specify the same to certtool
  66. $(eval $(call TOOL_ADD_IMG_PAYLOAD,STM32MP_SOC_FW_CONFIG,$(STM32MP_SOC_FW_CONFIG),--soc-fw-config,$(patsubst %.dtb,%.dts,$(STM32MP_SOC_FW_CONFIG))))
  67. ifeq (${STM32MP_DDR_FIP_IO_STORAGE},1)
  68. # Add the FW_DDR to FIP and specify the same to certtool
  69. $(eval $(call TOOL_ADD_IMG,STM32MP_DDR_FW,--ddr-fw))
  70. endif
  71. # Enable flags for C files
  72. $(eval $(call assert_booleans,\
  73. $(sort \
  74. STM32MP_DDR_DUAL_AXI_PORT \
  75. STM32MP_DDR_FIP_IO_STORAGE \
  76. STM32MP_DDR3_TYPE \
  77. STM32MP_DDR4_TYPE \
  78. STM32MP_LPDDR4_TYPE \
  79. STM32MP25 \
  80. STM32MP_BL33_EL1 \
  81. )))
  82. $(eval $(call assert_numerics,\
  83. $(sort \
  84. PLAT_PARTITION_MAX_ENTRIES \
  85. STM32_HEADER_VERSION_MAJOR \
  86. STM32_TF_A_COPIES \
  87. )))
  88. $(eval $(call add_defines,\
  89. $(sort \
  90. DWL_BUFFER_BASE \
  91. PLAT_DEF_FIP_UUID \
  92. PLAT_PARTITION_MAX_ENTRIES \
  93. PLAT_TBBR_IMG_DEF \
  94. STM32_TF_A_COPIES \
  95. STM32MP_DDR_DUAL_AXI_PORT \
  96. STM32MP_DDR_FIP_IO_STORAGE \
  97. STM32MP_DDR3_TYPE \
  98. STM32MP_DDR4_TYPE \
  99. STM32MP_LPDDR4_TYPE \
  100. STM32MP25 \
  101. STM32MP_BL33_EL1 \
  102. )))
  103. # STM32MP2x is based on Cortex-A35, which is Armv8.0, and does not support BTI
  104. # Disable mbranch-protection to avoid adding useless code
  105. TF_CFLAGS += -mbranch-protection=none
  106. # Include paths and source files
  107. PLAT_INCLUDES += -Iplat/st/stm32mp2/include/
  108. PLAT_INCLUDES += -Idrivers/st/ddr/phy/phyinit/include/
  109. PLAT_INCLUDES += -Idrivers/st/ddr/phy/firmware/include/
  110. PLAT_BL_COMMON_SOURCES += lib/cpus/${ARCH}/cortex_a35.S
  111. PLAT_BL_COMMON_SOURCES += drivers/st/uart/${ARCH}/stm32_console.S
  112. PLAT_BL_COMMON_SOURCES += plat/st/stm32mp2/${ARCH}/stm32mp2_helper.S
  113. PLAT_BL_COMMON_SOURCES += drivers/st/pmic/stm32mp_pmic2.c \
  114. drivers/st/pmic/stpmic2.c \
  115. PLAT_BL_COMMON_SOURCES += drivers/st/i2c/stm32_i2c.c
  116. PLAT_BL_COMMON_SOURCES += plat/st/stm32mp2/stm32mp2_private.c
  117. PLAT_BL_COMMON_SOURCES += drivers/st/bsec/bsec3.c \
  118. drivers/st/reset/stm32mp2_reset.c \
  119. plat/st/stm32mp2/stm32mp2_syscfg.c
  120. PLAT_BL_COMMON_SOURCES += drivers/st/clk/clk-stm32-core.c \
  121. drivers/st/clk/clk-stm32mp2.c
  122. BL2_SOURCES += plat/st/stm32mp2/plat_bl2_mem_params_desc.c
  123. BL2_SOURCES += plat/st/stm32mp2/bl2_plat_setup.c \
  124. plat/st/stm32mp2/plat_ddr.c
  125. ifneq ($(filter 1,${STM32MP_EMMC} ${STM32MP_SDMMC}),)
  126. BL2_SOURCES += drivers/st/mmc/stm32_sdmmc2.c
  127. endif
  128. ifeq (${STM32MP_USB_PROGRAMMER},1)
  129. BL2_SOURCES += plat/st/stm32mp2/stm32mp2_usb_dfu.c
  130. endif
  131. BL2_SOURCES += drivers/st/ddr/stm32mp2_ddr.c \
  132. drivers/st/ddr/stm32mp2_ddr_helpers.c \
  133. drivers/st/ddr/stm32mp2_ram.c
  134. BL2_SOURCES += drivers/st/ddr/phy/phyinit/src/ddrphy_phyinit_c_initphyconfig.c \
  135. drivers/st/ddr/phy/phyinit/src/ddrphy_phyinit_calcmb.c \
  136. drivers/st/ddr/phy/phyinit/src/ddrphy_phyinit_i_loadpieimage.c \
  137. drivers/st/ddr/phy/phyinit/src/ddrphy_phyinit_initstruct.c \
  138. drivers/st/ddr/phy/phyinit/src/ddrphy_phyinit_isdbytedisabled.c \
  139. drivers/st/ddr/phy/phyinit/src/ddrphy_phyinit_loadpieprodcode.c \
  140. drivers/st/ddr/phy/phyinit/src/ddrphy_phyinit_mapdrvstren.c \
  141. drivers/st/ddr/phy/phyinit/src/ddrphy_phyinit_progcsrskiptrain.c \
  142. drivers/st/ddr/phy/phyinit/src/ddrphy_phyinit_reginterface.c \
  143. drivers/st/ddr/phy/phyinit/src/ddrphy_phyinit_restore_sequence.c \
  144. drivers/st/ddr/phy/phyinit/src/ddrphy_phyinit_sequence.c \
  145. drivers/st/ddr/phy/phyinit/src/ddrphy_phyinit_softsetmb.c \
  146. drivers/st/ddr/phy/phyinit/usercustom/ddrphy_phyinit_usercustom_custompretrain.c \
  147. drivers/st/ddr/phy/phyinit/usercustom/ddrphy_phyinit_usercustom_saveretregs.c
  148. BL2_SOURCES += drivers/st/ddr/phy/phyinit/src/ddrphy_phyinit_d_loadimem.c \
  149. drivers/st/ddr/phy/phyinit/src/ddrphy_phyinit_f_loaddmem.c \
  150. drivers/st/ddr/phy/phyinit/src/ddrphy_phyinit_g_execfw.c \
  151. drivers/st/ddr/phy/phyinit/src/ddrphy_phyinit_writeoutmem.c \
  152. drivers/st/ddr/phy/phyinit/usercustom/ddrphy_phyinit_usercustom_g_waitfwdone.c
  153. # BL31 sources
  154. BL31_SOURCES += ${FDT_WRAPPERS_SOURCES}
  155. BL31_SOURCES += plat/st/stm32mp2/bl31_plat_setup.c \
  156. plat/st/stm32mp2/stm32mp2_pm.c \
  157. plat/st/stm32mp2/stm32mp2_topology.c
  158. # Generic GIC v2
  159. include drivers/arm/gic/v2/gicv2.mk
  160. BL31_SOURCES += ${GICV2_SOURCES} \
  161. plat/common/plat_gicv2.c \
  162. plat/st/common/stm32mp_gic.c
  163. # Generic PSCI
  164. BL31_SOURCES += plat/common/plat_psci_common.c
  165. # Compilation rules
  166. .PHONY: check_ddr_type
  167. bl2: check_ddr_type
  168. check_ddr_type:
  169. $(eval DDR_TYPE = $(shell echo $$(($(STM32MP_DDR3_TYPE) + \
  170. $(STM32MP_DDR4_TYPE) + \
  171. $(STM32MP_LPDDR4_TYPE)))))
  172. @if [ ${DDR_TYPE} != 1 ]; then \
  173. echo "One and only one DDR type must be defined"; \
  174. false; \
  175. fi
  176. # Create DTB file for BL31
  177. ${BUILD_PLAT}/fdts/%-bl31.dts: fdts/%.dts fdts/${BL31_DTSI} | $$(@D)/
  178. @echo '#include "$(patsubst fdts/%,%,$<)"' > $@
  179. @echo '#include "${BL31_DTSI}"' >> $@
  180. include plat/st/common/common_rules.mk