diff options
Diffstat (limited to 'plat/mediatek/build_helpers')
-rw-r--r-- | plat/mediatek/build_helpers/conditional_eval_options.mk | 51 | ||||
-rw-r--r-- | plat/mediatek/build_helpers/mtk_build_helpers.mk | 117 | ||||
-rw-r--r-- | plat/mediatek/build_helpers/mtk_build_helpers_epilogue.mk | 15 | ||||
-rw-r--r-- | plat/mediatek/build_helpers/options.mk | 26 |
4 files changed, 209 insertions, 0 deletions
diff --git a/plat/mediatek/build_helpers/conditional_eval_options.mk b/plat/mediatek/build_helpers/conditional_eval_options.mk new file mode 100644 index 0000000..6bb3b4e --- /dev/null +++ b/plat/mediatek/build_helpers/conditional_eval_options.mk @@ -0,0 +1,51 @@ +# +# Copyright (c) 2022, MediaTek Inc. All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# + +# Conditional makefile variable assignment + +# Options depend on BUILD_TYPE variable +ifeq ($(BUILD_TYPE),release) +MTK_DEBUGSYS_LOCK := 1 +MTK_GET_PERM_DIS := 1 +ERRATA_KLEIN_2218950 := 0 +ERRATA_KLEIN_2184257 := 0 +ERRATA_KLEIN_BOOKER := 0 +ERRATA_MTH_BOOKER := 0 +ERRATA_MTHELP_BOOKER := 0 +CRASH_REPORTING := 1 +CONFIG_MTK_BL31_RAMDUMP := 0 +endif + +ifeq ($(BUILD_TYPE),debug) +MTK_PTP3_PROC_DEBUG := 1 +MTK_SRAMRC_DEBUG := 1 +MTK_IOMMU_DEBUG := 1 +MTK_DCM_DEBUG := 1 +MTK_EMI_MPU_DEBUG := 1 +endif + +ifeq (${SPD},none) +SPD_NONE:=1 +$(eval $(call add_define,SPD_NONE)) +endif + +# TEE OS config +ifeq ($(SPD), tbase) +CONFIG_TBASE := y +endif + +# MICROTRUST OS config +ifeq ($(SPD), teeid) +CONFIG_MICROTRUST_TEEI := y +endif + +ifeq (${CONFIG_ARCH_ARM_V8_2},y) +ARCH_VERSION := armv8_2 +endif + +ifeq (${CONFIG_ARCH_ARM_V9},y) +ARCH_VERSION := armv9 +endif diff --git a/plat/mediatek/build_helpers/mtk_build_helpers.mk b/plat/mediatek/build_helpers/mtk_build_helpers.mk new file mode 100644 index 0000000..83a4dd2 --- /dev/null +++ b/plat/mediatek/build_helpers/mtk_build_helpers.mk @@ -0,0 +1,117 @@ +# +# Copyright (c) 2022, MediaTek Inc. All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# + +# Get local directory path +define GET_LOCAL_DIR +$(patsubst %/,%,$(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))) +endef + +# Clear module source variable +define CLEAR_LOCAL_SRCS +$(eval $(1) :=) +endef + +define EXPAND_SUB_MAKEFILE +include $(S) +endef + +# Expand sub rules.mk +define INCLUDE_MAKEFILE +$(eval MODULES_SUB_MAKEFILE := $(patsubst %,%/rules.mk,$(1))) +$(foreach S,$(MODULES_SUB_MAKEFILE),$(eval $(EXPAND_SUB_MAKEFILE))) +endef + +# Determine option variable is defined or not then define it +define add_defined_option +ifdef $(1) +ifeq ($(findstring $(value $(1)), $(uppercase_table)),) +DEFINES += -D$(1)$(if $(value $(1)),=$(value $(1)),) +else +ifeq ($(strip $(value $(1))),y) +DEFINES += -D$(1)$(if $(value $(1)),=1,) +endif +endif +endif +endef + +define EXPAND_RULES_MAKEFILE +LOCAL_SRCS-y := +MODULE := +SUB_RULES-y := +include $(S) +endef + +# INCLUDE_MODULES macro expand included modules rules.mk +# Arguments: +# $(1) = MODULES variables +define INCLUDE_MODULES +$(eval MODULES_TEMP := $(1)) +$(eval MODULES_MAKEFILE := $(patsubst %,%/rules.mk,$(MODULES_TEMP))) +$(foreach S,$(MODULES_MAKEFILE),$(eval $(EXPAND_RULES_MAKEFILE))) +endef + +# MAKE_LOCALS expand module source file variable to BL${BL}_SOURCES +# Arguments: +# $(1) = source file +# $(2) = BL stage (1, 2, 2u, 31, 32) +define MAKE_LOCALS +$(eval $(call uppercase,$(2))_SOURCES += $(1)) +endef + +# MAKE_MODULE reference MAKE_OBJS. +# Create module folder under out/bl$(BL)/$(module) +# Arguments: +# $(1) = module name +# $(2) = source file +# $(3) = BL stage +define MAKE_MODULE + $(eval MODULE := $(strip $(1))) + $(eval BUILD_DIR := ${BUILD_PLAT}/${3}) + $(eval SOURCES := $(2)) + $(eval OBJS_TEMP := $(addprefix $(BUILD_DIR)/$(MODULE)/,$(call SOURCES_TO_OBJS,$(SOURCES)))) + $(eval MODULE_OBJS += $(OBJS_TEMP)) + # We use sort only to get a list of unique object directory names. + # ordering is not relevant but sort removes duplicates. + $(eval TEMP_OBJ_DIRS := $(sort $(dir ${OBJS_TEMP} ${LINKERFILE}))) + # The $(dir ) function leaves a trailing / on the directory names + # Rip off the / to match directory names with make rule targets. + $(eval OBJ_DIRS := $(patsubst %/,%,$(TEMP_OBJ_DIRS))) + +$(eval $(foreach objd,${OBJ_DIRS},$(call MAKE_PREREQ_DIR,${objd},${BUILD_DIR}))) +${3}_dirs: | ${OBJ_DIRS} + +$(eval $(call MAKE_OBJS,$(BUILD_DIR)/$(MODULE),$(SOURCES),${3})) + +libraries: $(OBJS_TEMP) +endef + +# Include MTK configuration files + +# MTK makefile variables +ifeq (${COREBOOT},1) +MTK_COMMON_CFG := $(MTK_PLAT)/common/coreboot_config.mk +else +MTK_COMMON_CFG := $(MTK_PLAT)/common/common_config.mk +endif +MTK_PLAT := plat/mediatek +MTK_PLAT_SOC := ${MTK_PLAT}/${MTK_SOC} +MTK_PLAT_CFG := $(MTK_PLAT_SOC)/plat_config.mk +MTK_PROJECT_CFG := $(MTK_PLAT)/project/$(PLAT)/project_config.mk +MTK_OPTIONS := $(MTK_PLAT)/build_helpers/options.mk +MTK_COND_EVAL := $(MTK_PLAT)/build_helpers/conditional_eval_options.mk + +# Indicate which BL should be built in command line +ifeq (${NEED_BL32},yes) +MTK_BL := bl32 +else +MTK_BL := bl31 +endif +# Include common, platform, board level config +include $(MTK_COMMON_CFG) +include $(MTK_PLAT_CFG) +-include $(MTK_PROJECT_CFG) +include $(MTK_COND_EVAL) +include $(MTK_OPTIONS) diff --git a/plat/mediatek/build_helpers/mtk_build_helpers_epilogue.mk b/plat/mediatek/build_helpers/mtk_build_helpers_epilogue.mk new file mode 100644 index 0000000..4fed41f --- /dev/null +++ b/plat/mediatek/build_helpers/mtk_build_helpers_epilogue.mk @@ -0,0 +1,15 @@ +# +# Copyright (c) 2022, MediaTek Inc. All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# + +# Expand include modules +$(eval $(call INCLUDE_MODULES,$(MODULES-y))) + +# Make next section align to page size +ifneq ($(MTK_EXTRA_LINKERFILE),) + # mtk_align.ld MUST BE THE LAST LINKER SCRIPT! + BL31_LINKER_SCRIPT_SOURCES += $(MTK_LINKERFILE_SOURCE) + BL31_LINKER_SCRIPT_SOURCES += ${MTK_PLAT}/include/mtk_align.ld +endif diff --git a/plat/mediatek/build_helpers/options.mk b/plat/mediatek/build_helpers/options.mk new file mode 100644 index 0000000..128b14f --- /dev/null +++ b/plat/mediatek/build_helpers/options.mk @@ -0,0 +1,26 @@ +# +# Copyright (c) 2022-2023, MediaTek Inc. All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# + +# call add_defined_option to evaluate MTK defined value +$(eval $(call add_defined_option,MTK_SIP_KERNEL_BOOT_ENABLE)) +$(eval $(call add_defined_option,PLAT_EXTRA_RODATA_INCLUDES)) +$(eval $(call add_defined_option,MTK_EXTRA_LINKERFILE)) +$(eval $(call add_defined_option,MTK_BL31_AS_BL2)) +$(eval $(call add_defined_option,MTK_BL33_IS_64BIT)) +$(eval $(call add_defined_option,PLAT_XLAT_TABLES_DYNAMIC)) +$(eval $(call add_defined_option,MTK_ADAPTED)) +$(eval $(call add_defined_option,MTK_PUBEVENT_ENABLE)) +$(eval $(call add_defined_option,MTK_SOC)) +$(eval $(call add_defined_option,UART_CLOCK)) +$(eval $(call add_defined_option,UART_BAUDRATE)) +$(eval $(call add_defined_option,CONFIG_MTK_MCUSYS)) +$(eval $(call add_defined_option,CONFIG_MTK_PM_SUPPORT)) +$(eval $(call add_defined_option,CONFIG_MTK_CPU_PM_SUPPORT)) +$(eval $(call add_defined_option,CONFIG_MTK_SMP_EN)) +$(eval $(call add_defined_option,CONFIG_MTK_CPU_SUSPEND_EN)) +$(eval $(call add_defined_option,CONFIG_MTK_PM_ARCH)) +$(eval $(call add_defined_option,CONFIG_MTK_CPU_PM_ARCH)) +$(eval $(call add_defined_option,CONFIG_MTK_SUPPORT_SYSTEM_SUSPEND)) |