blob: df1cacd2fe9ebddf2a85f74f34cd3d761743fac0 [file] [log] [blame]
Yann Gautiera3f46382023-06-14 10:40:59 +02001#
Yann Gautiera585d762024-01-03 14:28:23 +01002# Copyright (c) 2023-2024, STMicroelectronics - All Rights Reserved
Yann Gautiera3f46382023-06-14 10:40:59 +02003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6
Yann Gautier605facb2023-01-05 14:34:37 +01007# Extra partitions used to find FIP, contains:
8# metadata (2) and fsbl-m (2) and the FIP partitions (default is 2).
9STM32_EXTRA_PARTS := 6
10
Yann Gautiera3f46382023-06-14 10:40:59 +020011include plat/st/common/common.mk
12
13CRASH_REPORTING := 1
14ENABLE_PIE := 1
15PROGRAMMABLE_RESET_ADDRESS := 1
Yann Gautier8053f2b2024-05-21 11:46:59 +020016BL2_IN_XIP_MEM := 1
Yann Gautiera3f46382023-06-14 10:40:59 +020017
18# Default Device tree
19DTB_FILE_NAME ?= stm32mp257f-ev1.dtb
20
21STM32MP25 := 1
22
23# STM32 image header version v2.2
24STM32_HEADER_VERSION_MAJOR := 2
25STM32_HEADER_VERSION_MINOR := 2
26
Yann Gautier7d13b4e2024-02-02 17:07:20 +010027# Set load address for serial boot devices
Yann Gautier8053f2b2024-05-21 11:46:59 +020028DWL_BUFFER_BASE ?= 0x87000000
Yann Gautier7d13b4e2024-02-02 17:07:20 +010029
Nicolas Le Bayoncaff04c2021-07-05 15:23:54 +020030# DDR types
31STM32MP_DDR3_TYPE ?= 0
32STM32MP_DDR4_TYPE ?= 0
33STM32MP_LPDDR4_TYPE ?= 0
34ifeq (${STM32MP_DDR3_TYPE},1)
35DDR_TYPE := ddr3
36endif
37ifeq (${STM32MP_DDR4_TYPE},1)
38DDR_TYPE := ddr4
39endif
40ifeq (${STM32MP_LPDDR4_TYPE},1)
41DDR_TYPE := lpddr4
42endif
43
Maxime Méréb151f682024-09-13 17:57:58 +020044# DDR features
Nicolas Le Bayon068d3412021-07-01 14:44:22 +020045STM32MP_DDR_DUAL_AXI_PORT := 1
Maxime Méréb151f682024-09-13 17:57:58 +020046STM32MP_DDR_FIP_IO_STORAGE := 1
47
Yann Gautier626ec9d2023-06-14 18:44:41 +020048# Device tree
49BL2_DTSI := stm32mp25-bl2.dtsi
50FDT_SOURCES := $(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl2.dts,$(DTB_FILE_NAME)))
Maxime Méré212148f2024-10-02 18:24:40 +020051BL31_DTSI := stm32mp25-bl31.dtsi
52FDT_SOURCES += $(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl31.dts,$(DTB_FILE_NAME)))
Yann Gautier626ec9d2023-06-14 18:44:41 +020053
54# Macros and rules to build TF binary
55STM32_TF_STM32 := $(addprefix ${BUILD_PLAT}/tf-a-, $(patsubst %.dtb,%.stm32,$(DTB_FILE_NAME)))
56STM32_LD_FILE := plat/st/stm32mp2/${ARCH}/stm32mp2.ld.S
57STM32_BINARY_MAPPING := plat/st/stm32mp2/${ARCH}/stm32mp2.S
58
Yann Gautier99f41322024-05-22 16:16:59 +020059STM32MP_FW_CONFIG_NAME := $(patsubst %.dtb,%-fw-config.dtb,$(DTB_FILE_NAME))
60STM32MP_FW_CONFIG := ${BUILD_PLAT}/fdts/$(STM32MP_FW_CONFIG_NAME)
Maxime Méré212148f2024-10-02 18:24:40 +020061STM32MP_SOC_FW_CONFIG := $(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl31.dtb,$(DTB_FILE_NAME)))
Maxime Méréb151f682024-09-13 17:57:58 +020062ifeq (${STM32MP_DDR_FIP_IO_STORAGE},1)
63STM32MP_DDR_FW_PATH ?= drivers/st/ddr/phy/firmware/bin/stm32mp2
64STM32MP_DDR_FW_NAME := ${DDR_TYPE}_pmu_train.bin
65STM32MP_DDR_FW := ${STM32MP_DDR_FW_PATH}/${STM32MP_DDR_FW_NAME}
66endif
Yann Gautier99f41322024-05-22 16:16:59 +020067FDT_SOURCES += $(addprefix fdts/, $(patsubst %.dtb,%.dts,$(STM32MP_FW_CONFIG_NAME)))
68# Add the FW_CONFIG to FIP and specify the same to certtool
69$(eval $(call TOOL_ADD_PAYLOAD,${STM32MP_FW_CONFIG},--fw-config))
Maxime Méré212148f2024-10-02 18:24:40 +020070# Add the SOC_FW_CONFIG to FIP and specify the same to certtool
71$(eval $(call TOOL_ADD_IMG,STM32MP_SOC_FW_CONFIG,--soc-fw-config))
Maxime Méréb151f682024-09-13 17:57:58 +020072ifeq (${STM32MP_DDR_FIP_IO_STORAGE},1)
73# Add the FW_DDR to FIP and specify the same to certtool
74$(eval $(call TOOL_ADD_IMG,STM32MP_DDR_FW,--ddr-fw))
75endif
Yann Gautier99f41322024-05-22 16:16:59 +020076
Yann Gautier8053f2b2024-05-21 11:46:59 +020077# Enable flags for C files
78$(eval $(call assert_booleans,\
79 $(sort \
Nicolas Le Bayon068d3412021-07-01 14:44:22 +020080 STM32MP_DDR_DUAL_AXI_PORT \
Maxime Méréb151f682024-09-13 17:57:58 +020081 STM32MP_DDR_FIP_IO_STORAGE \
Nicolas Le Bayoncaff04c2021-07-05 15:23:54 +020082 STM32MP_DDR3_TYPE \
83 STM32MP_DDR4_TYPE \
84 STM32MP_LPDDR4_TYPE \
Yann Gautier8053f2b2024-05-21 11:46:59 +020085 STM32MP25 \
86)))
87
88$(eval $(call assert_numerics,\
89 $(sort \
90 PLAT_PARTITION_MAX_ENTRIES \
91 STM32_HEADER_VERSION_MAJOR \
92 STM32_TF_A_COPIES \
93)))
94
Yann Gautier7d13b4e2024-02-02 17:07:20 +010095$(eval $(call add_defines,\
96 $(sort \
97 DWL_BUFFER_BASE \
Maxime Méréb151f682024-09-13 17:57:58 +020098 PLAT_DEF_FIP_UUID \
Yann Gautier8053f2b2024-05-21 11:46:59 +020099 PLAT_PARTITION_MAX_ENTRIES \
100 PLAT_TBBR_IMG_DEF \
101 STM32_TF_A_COPIES \
Nicolas Le Bayon068d3412021-07-01 14:44:22 +0200102 STM32MP_DDR_DUAL_AXI_PORT \
Maxime Méréb151f682024-09-13 17:57:58 +0200103 STM32MP_DDR_FIP_IO_STORAGE \
Nicolas Le Bayoncaff04c2021-07-05 15:23:54 +0200104 STM32MP_DDR3_TYPE \
105 STM32MP_DDR4_TYPE \
106 STM32MP_LPDDR4_TYPE \
Yann Gautier8053f2b2024-05-21 11:46:59 +0200107 STM32MP25 \
Yann Gautier7d13b4e2024-02-02 17:07:20 +0100108)))
109
Yann Gautiera3f46382023-06-14 10:40:59 +0200110# STM32MP2x is based on Cortex-A35, which is Armv8.0, and does not support BTI
111# Disable mbranch-protection to avoid adding useless code
112TF_CFLAGS += -mbranch-protection=none
113
114# Include paths and source files
115PLAT_INCLUDES += -Iplat/st/stm32mp2/include/
Nicolas Le Bayon068d3412021-07-01 14:44:22 +0200116PLAT_INCLUDES += -Idrivers/st/ddr/phy/phyinit/include/
117PLAT_INCLUDES += -Idrivers/st/ddr/phy/firmware/include/
Yann Gautiera3f46382023-06-14 10:40:59 +0200118
119PLAT_BL_COMMON_SOURCES += lib/cpus/${ARCH}/cortex_a35.S
Yann Gautiereb91af52023-06-14 18:05:47 +0200120PLAT_BL_COMMON_SOURCES += drivers/st/uart/${ARCH}/stm32_console.S
Yann Gautiera3f46382023-06-14 10:40:59 +0200121PLAT_BL_COMMON_SOURCES += plat/st/stm32mp2/${ARCH}/stm32mp2_helper.S
122
Pascal Paillet3263aea2022-12-16 14:59:34 +0100123PLAT_BL_COMMON_SOURCES += drivers/st/pmic/stm32mp_pmic2.c \
124 drivers/st/pmic/stpmic2.c \
125
126PLAT_BL_COMMON_SOURCES += drivers/st/i2c/stm32_i2c.c
127
Yann Gautier8053f2b2024-05-21 11:46:59 +0200128PLAT_BL_COMMON_SOURCES += plat/st/stm32mp2/stm32mp2_private.c
129
Gabriel Fernandez30437432022-04-20 10:08:08 +0200130PLAT_BL_COMMON_SOURCES += drivers/st/bsec/bsec3.c \
Yann Gautierd58a3d22024-05-21 12:05:43 +0200131 drivers/st/reset/stm32mp2_reset.c \
132 plat/st/stm32mp2/stm32mp2_syscfg.c
Yann Gautiera585d762024-01-03 14:28:23 +0100133
Gabriel Fernandezbcd95062022-04-20 10:08:49 +0200134PLAT_BL_COMMON_SOURCES += drivers/st/clk/clk-stm32-core.c \
135 drivers/st/clk/clk-stm32mp2.c
136
Yann Gautiera3f46382023-06-14 10:40:59 +0200137BL2_SOURCES += plat/st/stm32mp2/plat_bl2_mem_params_desc.c
Yann Gautier8053f2b2024-05-21 11:46:59 +0200138
Pascal Paillet0e1727c2023-01-18 11:47:10 +0100139BL2_SOURCES += plat/st/stm32mp2/bl2_plat_setup.c \
140 plat/st/stm32mp2/plat_ddr.c
Yann Gautiera3f46382023-06-14 10:40:59 +0200141
Yann Gautier8053f2b2024-05-21 11:46:59 +0200142ifneq ($(filter 1,${STM32MP_EMMC} ${STM32MP_SDMMC}),)
143BL2_SOURCES += drivers/st/mmc/stm32_sdmmc2.c
144endif
145
Yann Gautier7d13b4e2024-02-02 17:07:20 +0100146ifeq (${STM32MP_USB_PROGRAMMER},1)
147BL2_SOURCES += plat/st/stm32mp2/stm32mp2_usb_dfu.c
148endif
149
Nicolas Le Bayon068d3412021-07-01 14:44:22 +0200150BL2_SOURCES += drivers/st/ddr/stm32mp2_ddr.c \
151 drivers/st/ddr/stm32mp2_ddr_helpers.c \
152 drivers/st/ddr/stm32mp2_ram.c
153
154BL2_SOURCES += drivers/st/ddr/phy/phyinit/src/ddrphy_phyinit_c_initphyconfig.c \
155 drivers/st/ddr/phy/phyinit/src/ddrphy_phyinit_calcmb.c \
156 drivers/st/ddr/phy/phyinit/src/ddrphy_phyinit_i_loadpieimage.c \
157 drivers/st/ddr/phy/phyinit/src/ddrphy_phyinit_initstruct.c \
158 drivers/st/ddr/phy/phyinit/src/ddrphy_phyinit_isdbytedisabled.c \
159 drivers/st/ddr/phy/phyinit/src/ddrphy_phyinit_loadpieprodcode.c \
160 drivers/st/ddr/phy/phyinit/src/ddrphy_phyinit_mapdrvstren.c \
161 drivers/st/ddr/phy/phyinit/src/ddrphy_phyinit_progcsrskiptrain.c \
162 drivers/st/ddr/phy/phyinit/src/ddrphy_phyinit_reginterface.c \
163 drivers/st/ddr/phy/phyinit/src/ddrphy_phyinit_restore_sequence.c \
164 drivers/st/ddr/phy/phyinit/src/ddrphy_phyinit_sequence.c \
165 drivers/st/ddr/phy/phyinit/src/ddrphy_phyinit_softsetmb.c \
166 drivers/st/ddr/phy/phyinit/usercustom/ddrphy_phyinit_usercustom_custompretrain.c \
167 drivers/st/ddr/phy/phyinit/usercustom/ddrphy_phyinit_usercustom_saveretregs.c
168
169BL2_SOURCES += drivers/st/ddr/phy/phyinit/src/ddrphy_phyinit_d_loadimem.c \
170 drivers/st/ddr/phy/phyinit/src/ddrphy_phyinit_f_loaddmem.c \
171 drivers/st/ddr/phy/phyinit/src/ddrphy_phyinit_g_execfw.c \
172 drivers/st/ddr/phy/phyinit/src/ddrphy_phyinit_writeoutmem.c \
173 drivers/st/ddr/phy/phyinit/usercustom/ddrphy_phyinit_usercustom_g_waitfwdone.c
Yann Gautier40ff1382024-05-21 20:54:04 +0200174
Yann Gautierece4c252023-06-13 18:45:03 +0200175# BL31 sources
176BL31_SOURCES += ${FDT_WRAPPERS_SOURCES}
177
178BL31_SOURCES += plat/st/stm32mp2/bl31_plat_setup.c \
179 plat/st/stm32mp2/stm32mp2_pm.c \
180 plat/st/stm32mp2/stm32mp2_topology.c
181# Generic GIC v2
182include drivers/arm/gic/v2/gicv2.mk
183
184BL31_SOURCES += ${GICV2_SOURCES} \
185 plat/common/plat_gicv2.c \
186 plat/st/common/stm32mp_gic.c
187
188# Generic PSCI
189BL31_SOURCES += plat/common/plat_psci_common.c
190
Yann Gautier8053f2b2024-05-21 11:46:59 +0200191# Compilation rules
Nicolas Le Bayoncaff04c2021-07-05 15:23:54 +0200192.PHONY: check_ddr_type
193.SUFFIXES:
194
195bl2: check_ddr_type
196
197check_ddr_type:
198 $(eval DDR_TYPE = $(shell echo $$(($(STM32MP_DDR3_TYPE) + \
199 $(STM32MP_DDR4_TYPE) + \
200 $(STM32MP_LPDDR4_TYPE)))))
201 @if [ ${DDR_TYPE} != 1 ]; then \
202 echo "One and only one DDR type must be defined"; \
203 false; \
204 fi
205
Maxime Méré212148f2024-10-02 18:24:40 +0200206# Create DTB file for BL31
207${BUILD_PLAT}/fdts/%-bl31.dts: fdts/%.dts fdts/${BL31_DTSI} | $$(@D)/
208 @echo '#include "$(patsubst fdts/%,%,$<)"' > $@
209 @echo '#include "${BL31_DTSI}"' >> $@
210
211${BUILD_PLAT}/fdts/%-bl31.dtb: ${BUILD_PLAT}/fdts/%-bl31.dts
212
Yann Gautiera3f46382023-06-14 10:40:59 +0200213include plat/st/common/common_rules.mk