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