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 | |
| 18 | # Default Device tree |
| 19 | DTB_FILE_NAME ?= stm32mp257f-ev1.dtb |
| 20 | |
| 21 | STM32MP25 := 1 |
| 22 | |
| 23 | # STM32 image header version v2.2 |
| 24 | STM32_HEADER_VERSION_MAJOR := 2 |
| 25 | STM32_HEADER_VERSION_MINOR := 2 |
| 26 | |
Yann Gautier | 7d13b4e | 2024-02-02 17:07:20 +0100 | [diff] [blame] | 27 | # Set load address for serial boot devices |
Yann Gautier | 8053f2b | 2024-05-21 11:46:59 +0200 | [diff] [blame] | 28 | DWL_BUFFER_BASE ?= 0x87000000 |
Yann Gautier | 7d13b4e | 2024-02-02 17:07:20 +0100 | [diff] [blame] | 29 | |
Nicolas Le Bayon | caff04c | 2021-07-05 15:23:54 +0200 | [diff] [blame] | 30 | # DDR types |
| 31 | STM32MP_DDR3_TYPE ?= 0 |
| 32 | STM32MP_DDR4_TYPE ?= 0 |
| 33 | STM32MP_LPDDR4_TYPE ?= 0 |
| 34 | ifeq (${STM32MP_DDR3_TYPE},1) |
| 35 | DDR_TYPE := ddr3 |
| 36 | endif |
| 37 | ifeq (${STM32MP_DDR4_TYPE},1) |
| 38 | DDR_TYPE := ddr4 |
| 39 | endif |
| 40 | ifeq (${STM32MP_LPDDR4_TYPE},1) |
| 41 | DDR_TYPE := lpddr4 |
| 42 | endif |
| 43 | |
Maxime Méré | b151f68 | 2024-09-13 17:57:58 +0200 | [diff] [blame] | 44 | # DDR features |
| 45 | STM32MP_DDR_FIP_IO_STORAGE := 1 |
| 46 | |
Yann Gautier | 626ec9d | 2023-06-14 18:44:41 +0200 | [diff] [blame] | 47 | # Device tree |
| 48 | BL2_DTSI := stm32mp25-bl2.dtsi |
| 49 | FDT_SOURCES := $(addprefix ${BUILD_PLAT}/fdts/, $(patsubst %.dtb,%-bl2.dts,$(DTB_FILE_NAME))) |
| 50 | |
| 51 | # Macros and rules to build TF binary |
| 52 | STM32_TF_STM32 := $(addprefix ${BUILD_PLAT}/tf-a-, $(patsubst %.dtb,%.stm32,$(DTB_FILE_NAME))) |
| 53 | STM32_LD_FILE := plat/st/stm32mp2/${ARCH}/stm32mp2.ld.S |
| 54 | STM32_BINARY_MAPPING := plat/st/stm32mp2/${ARCH}/stm32mp2.S |
| 55 | |
Yann Gautier | 99f4132 | 2024-05-22 16:16:59 +0200 | [diff] [blame] | 56 | STM32MP_FW_CONFIG_NAME := $(patsubst %.dtb,%-fw-config.dtb,$(DTB_FILE_NAME)) |
| 57 | STM32MP_FW_CONFIG := ${BUILD_PLAT}/fdts/$(STM32MP_FW_CONFIG_NAME) |
Maxime Méré | b151f68 | 2024-09-13 17:57:58 +0200 | [diff] [blame] | 58 | ifeq (${STM32MP_DDR_FIP_IO_STORAGE},1) |
| 59 | STM32MP_DDR_FW_PATH ?= drivers/st/ddr/phy/firmware/bin/stm32mp2 |
| 60 | STM32MP_DDR_FW_NAME := ${DDR_TYPE}_pmu_train.bin |
| 61 | STM32MP_DDR_FW := ${STM32MP_DDR_FW_PATH}/${STM32MP_DDR_FW_NAME} |
| 62 | endif |
Yann Gautier | 99f4132 | 2024-05-22 16:16:59 +0200 | [diff] [blame] | 63 | FDT_SOURCES += $(addprefix fdts/, $(patsubst %.dtb,%.dts,$(STM32MP_FW_CONFIG_NAME))) |
| 64 | # Add the FW_CONFIG to FIP and specify the same to certtool |
| 65 | $(eval $(call TOOL_ADD_PAYLOAD,${STM32MP_FW_CONFIG},--fw-config)) |
Maxime Méré | b151f68 | 2024-09-13 17:57:58 +0200 | [diff] [blame] | 66 | ifeq (${STM32MP_DDR_FIP_IO_STORAGE},1) |
| 67 | # Add the FW_DDR to FIP and specify the same to certtool |
| 68 | $(eval $(call TOOL_ADD_IMG,STM32MP_DDR_FW,--ddr-fw)) |
| 69 | endif |
Yann Gautier | 99f4132 | 2024-05-22 16:16:59 +0200 | [diff] [blame] | 70 | |
Yann Gautier | 8053f2b | 2024-05-21 11:46:59 +0200 | [diff] [blame] | 71 | # Enable flags for C files |
| 72 | $(eval $(call assert_booleans,\ |
| 73 | $(sort \ |
Maxime Méré | b151f68 | 2024-09-13 17:57:58 +0200 | [diff] [blame] | 74 | STM32MP_DDR_FIP_IO_STORAGE \ |
Nicolas Le Bayon | caff04c | 2021-07-05 15:23:54 +0200 | [diff] [blame] | 75 | STM32MP_DDR3_TYPE \ |
| 76 | STM32MP_DDR4_TYPE \ |
| 77 | STM32MP_LPDDR4_TYPE \ |
Yann Gautier | 8053f2b | 2024-05-21 11:46:59 +0200 | [diff] [blame] | 78 | STM32MP25 \ |
| 79 | ))) |
| 80 | |
| 81 | $(eval $(call assert_numerics,\ |
| 82 | $(sort \ |
| 83 | PLAT_PARTITION_MAX_ENTRIES \ |
| 84 | STM32_HEADER_VERSION_MAJOR \ |
| 85 | STM32_TF_A_COPIES \ |
| 86 | ))) |
| 87 | |
Yann Gautier | 7d13b4e | 2024-02-02 17:07:20 +0100 | [diff] [blame] | 88 | $(eval $(call add_defines,\ |
| 89 | $(sort \ |
| 90 | DWL_BUFFER_BASE \ |
Maxime Méré | b151f68 | 2024-09-13 17:57:58 +0200 | [diff] [blame] | 91 | PLAT_DEF_FIP_UUID \ |
Yann Gautier | 8053f2b | 2024-05-21 11:46:59 +0200 | [diff] [blame] | 92 | PLAT_PARTITION_MAX_ENTRIES \ |
| 93 | PLAT_TBBR_IMG_DEF \ |
| 94 | STM32_TF_A_COPIES \ |
Maxime Méré | b151f68 | 2024-09-13 17:57:58 +0200 | [diff] [blame] | 95 | STM32MP_DDR_FIP_IO_STORAGE \ |
Nicolas Le Bayon | caff04c | 2021-07-05 15:23:54 +0200 | [diff] [blame] | 96 | STM32MP_DDR3_TYPE \ |
| 97 | STM32MP_DDR4_TYPE \ |
| 98 | STM32MP_LPDDR4_TYPE \ |
Yann Gautier | 8053f2b | 2024-05-21 11:46:59 +0200 | [diff] [blame] | 99 | STM32MP25 \ |
Yann Gautier | 7d13b4e | 2024-02-02 17:07:20 +0100 | [diff] [blame] | 100 | ))) |
| 101 | |
Yann Gautier | a3f4638 | 2023-06-14 10:40:59 +0200 | [diff] [blame] | 102 | # STM32MP2x is based on Cortex-A35, which is Armv8.0, and does not support BTI |
| 103 | # Disable mbranch-protection to avoid adding useless code |
| 104 | TF_CFLAGS += -mbranch-protection=none |
| 105 | |
| 106 | # Include paths and source files |
| 107 | PLAT_INCLUDES += -Iplat/st/stm32mp2/include/ |
| 108 | |
| 109 | PLAT_BL_COMMON_SOURCES += lib/cpus/${ARCH}/cortex_a35.S |
Yann Gautier | eb91af5 | 2023-06-14 18:05:47 +0200 | [diff] [blame] | 110 | PLAT_BL_COMMON_SOURCES += drivers/st/uart/${ARCH}/stm32_console.S |
Yann Gautier | a3f4638 | 2023-06-14 10:40:59 +0200 | [diff] [blame] | 111 | PLAT_BL_COMMON_SOURCES += plat/st/stm32mp2/${ARCH}/stm32mp2_helper.S |
| 112 | |
Yann Gautier | 8053f2b | 2024-05-21 11:46:59 +0200 | [diff] [blame] | 113 | PLAT_BL_COMMON_SOURCES += plat/st/stm32mp2/stm32mp2_private.c |
| 114 | |
Gabriel Fernandez | 3043743 | 2022-04-20 10:08:08 +0200 | [diff] [blame] | 115 | PLAT_BL_COMMON_SOURCES += drivers/st/bsec/bsec3.c \ |
Yann Gautier | d58a3d2 | 2024-05-21 12:05:43 +0200 | [diff] [blame] | 116 | drivers/st/reset/stm32mp2_reset.c \ |
| 117 | plat/st/stm32mp2/stm32mp2_syscfg.c |
Yann Gautier | a585d76 | 2024-01-03 14:28:23 +0100 | [diff] [blame] | 118 | |
Gabriel Fernandez | bcd9506 | 2022-04-20 10:08:49 +0200 | [diff] [blame] | 119 | PLAT_BL_COMMON_SOURCES += drivers/st/clk/clk-stm32-core.c \ |
| 120 | drivers/st/clk/clk-stm32mp2.c |
| 121 | |
Yann Gautier | a3f4638 | 2023-06-14 10:40:59 +0200 | [diff] [blame] | 122 | BL2_SOURCES += plat/st/stm32mp2/plat_bl2_mem_params_desc.c |
Yann Gautier | 8053f2b | 2024-05-21 11:46:59 +0200 | [diff] [blame] | 123 | |
Yann Gautier | a3f4638 | 2023-06-14 10:40:59 +0200 | [diff] [blame] | 124 | BL2_SOURCES += plat/st/stm32mp2/bl2_plat_setup.c |
| 125 | |
Yann Gautier | 8053f2b | 2024-05-21 11:46:59 +0200 | [diff] [blame] | 126 | ifneq ($(filter 1,${STM32MP_EMMC} ${STM32MP_SDMMC}),) |
| 127 | BL2_SOURCES += drivers/st/mmc/stm32_sdmmc2.c |
| 128 | endif |
| 129 | |
Yann Gautier | 7d13b4e | 2024-02-02 17:07:20 +0100 | [diff] [blame] | 130 | ifeq (${STM32MP_USB_PROGRAMMER},1) |
| 131 | BL2_SOURCES += plat/st/stm32mp2/stm32mp2_usb_dfu.c |
| 132 | endif |
| 133 | |
Yann Gautier | 40ff138 | 2024-05-21 20:54:04 +0200 | [diff] [blame] | 134 | BL2_SOURCES += drivers/st/ddr/stm32mp2_ddr_helpers.c |
| 135 | |
Yann Gautier | ece4c25 | 2023-06-13 18:45:03 +0200 | [diff] [blame] | 136 | # BL31 sources |
| 137 | BL31_SOURCES += ${FDT_WRAPPERS_SOURCES} |
| 138 | |
| 139 | BL31_SOURCES += plat/st/stm32mp2/bl31_plat_setup.c \ |
| 140 | plat/st/stm32mp2/stm32mp2_pm.c \ |
| 141 | plat/st/stm32mp2/stm32mp2_topology.c |
| 142 | # Generic GIC v2 |
| 143 | include drivers/arm/gic/v2/gicv2.mk |
| 144 | |
| 145 | BL31_SOURCES += ${GICV2_SOURCES} \ |
| 146 | plat/common/plat_gicv2.c \ |
| 147 | plat/st/common/stm32mp_gic.c |
| 148 | |
| 149 | # Generic PSCI |
| 150 | BL31_SOURCES += plat/common/plat_psci_common.c |
| 151 | |
Yann Gautier | 8053f2b | 2024-05-21 11:46:59 +0200 | [diff] [blame] | 152 | # Compilation rules |
Nicolas Le Bayon | caff04c | 2021-07-05 15:23:54 +0200 | [diff] [blame] | 153 | .PHONY: check_ddr_type |
| 154 | .SUFFIXES: |
| 155 | |
| 156 | bl2: check_ddr_type |
| 157 | |
| 158 | check_ddr_type: |
| 159 | $(eval DDR_TYPE = $(shell echo $$(($(STM32MP_DDR3_TYPE) + \ |
| 160 | $(STM32MP_DDR4_TYPE) + \ |
| 161 | $(STM32MP_LPDDR4_TYPE))))) |
| 162 | @if [ ${DDR_TYPE} != 1 ]; then \ |
| 163 | echo "One and only one DDR type must be defined"; \ |
| 164 | false; \ |
| 165 | fi |
| 166 | |
Yann Gautier | a3f4638 | 2023-06-14 10:40:59 +0200 | [diff] [blame] | 167 | include plat/st/common/common_rules.mk |