14c4212e9SVincent Guittot# SCMI server library is built from SCP-firmware source tree. 24c4212e9SVincent Guittot# The firmware is made of a framework, a product and modules. 34c4212e9SVincent Guittot# Only modules used by firmware must be built, as stated by 44c4212e9SVincent Guittot# CFG_SCPFW_MOD_* swtches. SCP-firmware needs a C source and 54c4212e9SVincent Guittot# a header file to be generated to describe embedded modules. 64c4212e9SVincent Guittot# This is done through cmake configuration of the package. 74c4212e9SVincent Guittot# The toolchain build directive must also match the list of 84c4212e9SVincent Guittot# embedded modules. 94c4212e9SVincent Guittot 104c4212e9SVincent Guittotscpfw-path = $(CFG_SCP_FIRMWARE) 114c4212e9SVincent Guittotscpfw-product = $(CFG_SCMI_SCPFW_PRODUCT) 124c4212e9SVincent Guittotscpfw-out-path := $(out-dir)/$(libdir) 134c4212e9SVincent Guittot 144c4212e9SVincent Guittot# This script was validated against SCP-firmware 2.11.0 development branch, 154c4212e9SVincent Guittot# from commit f1d894921d76 ("product/optee-fvp: Add new OPTEE FVP product"). 164c4212e9SVincent Guittotscpfw-integ-version-maj = 2 174c4212e9SVincent Guittotscpfw-integ-version-min = 11 184c4212e9SVincent Guittotscpfw-integ-version-pat = 0 194c4212e9SVincent Guittotscpfw-integ-version = $(scpfw-integ-version-maj).$(scpfw-integ-version-min).$(scpfw-integ-version-pat) 204c4212e9SVincent Guittot 214c4212e9SVincent Guittotsrcs-y += scmi_server.c 224c4212e9SVincent Guittotincdirs-y += include 234c4212e9SVincent Guittot 244c4212e9SVincent Guittot# SCP-firmware cmake configuration generates header fwk_module_idx.h and 254c4212e9SVincent Guittot# source files fwk_module_list.c needed for scp-firmware compilation. 264c4212e9SVincent Guittotscpfw-cmake-flags-y = -DSCP_FIRMWARE_SOURCE_DIR:PATH=$(scpfw-product)/fw \ 274c4212e9SVincent Guittot -DSCP_LOG_LEVEL="TRACE" \ 284c4212e9SVincent Guittot -DDISABLE_CPPCHECK=1 \ 294c4212e9SVincent Guittot -DCFG_NUM_THREADS=$(CFG_NUM_THREADS) \ 304c4212e9SVincent Guittot -DSCP_OPTEE_DIR:PATH=$(CURDIR) \ 314c4212e9SVincent Guittot -DCFG_CROSS_COMPILE=$(lastword $(CROSS_COMPILE_core)) 324c4212e9SVincent Guittot 33*08204d7eSEtienne Carriere# CMake does not need to check the cross compilation toolchain since we do not 34*08204d7eSEtienne Carriere# compile any source file with CMake, we only generate some SCP-firmware 35*08204d7eSEtienne Carriere# files. 36*08204d7eSEtienne Carrierescpfw-cmake-flags-y += -DCMAKE_C_COMPILER_WORKS=1 37*08204d7eSEtienne Carriere 384c4212e9SVincent Guittotifeq ($(cmd-echo-silent),true) 394c4212e9SVincent Guittotscpfw-cmake-redirect = >/dev/null 404c4212e9SVincent Guittotendif 414c4212e9SVincent Guittot 424c4212e9SVincent Guittotgensrcs-y += fwk_module_list 434c4212e9SVincent Guittotforce-gensrc-fwk_module_list := y 444c4212e9SVincent Guittotproduce-fwk_module_list = build/framework/src/fwk_module_list.c 454c4212e9SVincent Guittotrecipe-fwk_module_list = cmake -S $(scpfw-path) -B $(scpfw-out-path)/build \ 464c4212e9SVincent Guittot $(scpfw-cmake-flags-y) --log-level=WARNING $(scpfw-cmake-redirect) 474c4212e9SVincent Guittotdepends-fwk_module_list = $(scpfw-path)/product/$(scpfw-product)/fw/Firmware.cmake $(conf-file) 484c4212e9SVincent Guittot# Include path of generated header file fwk_module_idx.h 494c4212e9SVincent Guittotincdirs_ext-y += $(scpfw-out-path)/build/framework/include 504c4212e9SVincent Guittot 514c4212e9SVincent Guittotcppflags-lib-y += -DBUILD_VERSION_MAJOR=$(scpfw-integ-version-maj) \ 524c4212e9SVincent Guittot -DBUILD_VERSION_MINOR=$(scpfw-integ-version-min) \ 534c4212e9SVincent Guittot -DBUILD_VERSION_PATCH=$(scpfw-integ-version-pat) 544c4212e9SVincent Guittot 554c4212e9SVincent Guittotscpfw-impl-version := $(shell git -C $(scpfw-path) describe --tags --always --dirty=-dev 2>/dev/null || \ 564c4212e9SVincent Guittot echo Unknown_$(scpfw-integ-version)) 574c4212e9SVincent Guittotcppflags-lib-y += -DBUILD_VERSION_DESCRIBE_STRING=\"$(scpfw-impl-version)\" 584c4212e9SVincent Guittot 594c4212e9SVincent Guittotcppflags-lib-y += -DFWK_LOG_LEVEL=$(CFG_SCPFW_LOG_LEVEL) 604c4212e9SVincent Guittotifneq ($(CFG_SCPFW_LOG_LEVEL),0) 614c4212e9SVincent Guittotcppflags-lib-y += -DFMW_LOG_MINIMAL_BANNER=1 624c4212e9SVincent Guittotendif 634c4212e9SVincent Guittot 644c4212e9SVincent Guittotcflags-lib-y += -Wno-cast-align \ 654c4212e9SVincent Guittot -Wno-nonnull-compare \ 664c4212e9SVincent Guittot -Wno-unused-parameter \ 674c4212e9SVincent Guittot -Wno-suggest-attribute=format \ 684c4212e9SVincent Guittot -Wno-declaration-after-statement 694c4212e9SVincent Guittot 704c4212e9SVincent Guittot# The below directives will be removed once SCP-firmware pull requests 714c4212e9SVincent Guittot# 728 and 732 are merged. 724c4212e9SVincent Guittotcflags-lib-y += -Wno-undef \ 734c4212e9SVincent Guittot -Wno-missing-prototypes \ 744c4212e9SVincent Guittot -Wno-missing-declarations \ 754c4212e9SVincent Guittot -Wno-unused-but-set-variable \ 764c4212e9SVincent Guittot -Wno-suggest-attribute=format 774c4212e9SVincent Guittot 784c4212e9SVincent Guittot# Notification implementation has strict aliasing issues 794c4212e9SVincent Guittotcflags-lib-$(CFG_SCPFW_NOTIFICATION) += -Wno-strict-aliasing 804c4212e9SVincent Guittot 814c4212e9SVincent Guittotcppflags-lib-y += -DBUILD_HAS_SUB_SYSTEM_MODE=1 \ 824c4212e9SVincent Guittot -DBUILD_HAS_BASE_PROTOCOL 834c4212e9SVincent Guittot 844c4212e9SVincent Guittotcppflags-lib-$(CFG_SCPFW_NOTIFICATION) += -DBUILD_HAS_NOTIFICATION \ 854c4212e9SVincent Guittot -DBUILD_HAS_SCMI_NOTIFICATIONS 864c4212e9SVincent Guittot 874c4212e9SVincent Guittotcppflags-lib-$(CFG_SCPFW_FAST_CHANNELS) += -DBUILD_HAS_FAST_CHANNELS \ 884c4212e9SVincent Guittot -DBUILD_HAS_SCMI_FAST_CHANNELS 894c4212e9SVincent Guittot 904c4212e9SVincent Guittotcppflags-lib-$(CFG_SCPFW_CLOCK_TREE_MGMT) += -DBUILD_HAS_CLOCK_TREE_MGMT 914c4212e9SVincent Guittot 924c4212e9SVincent Guittotcppflags-lib-$(CFG_SCPFW_SCMI_PERF_FAST_CHANNELS) += -DBUILD_HAS_SCMI_PERF_FAST_CHANNELS 934c4212e9SVincent Guittot 94f5b856d8SNicola Mazzucatocppflags-lib-$(CFG_SCPFW_SCMI_PERF_PROTOCOL_OPS) \ 95f5b856d8SNicola Mazzucato += -DBUILD_HAS_SCMI_PERF_PROTOCOL_OPS 96f5b856d8SNicola Mazzucato 974c4212e9SVincent Guittotcppflags-lib-$(CFG_SCPFW_SCMI_SENSOR_EVENTS) += -DBUILD_HAS_SCMI_SENSOR_EVENTS 984c4212e9SVincent Guittotcppflags-lib-$(CFG_SCPFW_SCMI_SENSOR_V2) += -DBUILD_HAS_SCMI_SENSOR_V2 \ 994c4212e9SVincent Guittot -DBUILD_HAS_SENSOR_TIMESTAMP \ 1004c4212e9SVincent Guittot -DBUILD_HAS_SENSOR_MULTI_AXIS \ 1014c4212e9SVincent Guittot -DBUILD_HAS_SENSOR_EXT_ATTRIBS \ 1024c4212e9SVincent Guittot -DBUILD_HAS_SENSOR_SIGNED_VALUE 1034c4212e9SVincent Guittot 1044c4212e9SVincent Guittotcppflags-lib-$(CFG_SCPFW_SENSOR_TIMESTAMP) += -DBUILD_HAS_SENSOR_TIMESTAMP 1054c4212e9SVincent Guittotcppflags-lib-$(CFG_SCPFW_SENSOR_MULTI_AXIS) += -DBUILD_HAS_SENSOR_MULTI_AXI 1064c4212e9SVincent Guittotcppflags-lib-$(CFG_SCPFW_SENSOR_EXT_ATTRIBS) += -DBUILD_HAS_SENSOR_EXT_ATTRIBS 1074c4212e9SVincent Guittotcppflags-lib-$(CFG_SCPFW_SENSOR_SIGNED_VALUE) += -DBUILD_HAS_SENSOR_SIGNED_VALUE 1084c4212e9SVincent Guittotcppflags-lib-$(CFG_SCPFW_INBAND_MSG_SUPPORT) += -DBUILD_HAS_INBAND_MSG_SUPPORT 1094c4212e9SVincent Guittot 1104c4212e9SVincent Guittotincdirs_ext-y += $(scpfw-path)/arch/none/optee/include 1114c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/arch/none/optee/src/arch_interrupt.c 1124c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/arch/none/optee/src/arch_main.c 1134c4212e9SVincent Guittot 1144c4212e9SVincent Guittotincdirs_ext-y += $(scpfw-path)/framework/include 1154c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/framework/src/fwk_arch.c 1164c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/framework/src/fwk_dlist.c 1174c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/framework/src/fwk_id.c 1184c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/framework/src/fwk_interrupt.c 1194c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/framework/src/fwk_io.c 1204c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/framework/src/fwk_log.c 1214c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/framework/src/fwk_mm.c 1224c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/framework/src/fwk_module.c 1234c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/framework/src/fwk_ring.c 1244c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/framework/src/fwk_slist.c 1254c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/framework/src/fwk_status.c 1264c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/framework/src/fwk_string.c 1274c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/framework/src/fwk_delayed_resp.c 1284c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/framework/src/fwk_time.c 1294c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/framework/src/fwk_core.c 1304c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/framework/src/assert.c 1314c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/framework/src/stdlib.c 1324c4212e9SVincent Guittotsrcs-$(CFG_SCPFW_NOTIFICATION) += $(scpfw-path)/framework/src/fwk_notification.c 1334c4212e9SVincent Guittot 1344c4212e9SVincent Guittot# Helper macros for listing SCP-firmware modules source files (in srcs-y) 1354c4212e9SVincent Guittot# and header include paths (in incdirs_ext-y). Each module provides a C source 1364c4212e9SVincent Guittot# file named mod_<module-name>.c and possibly an include directory. Build 1374c4212e9SVincent Guittot# directive BUILD_HAS_MOD_<NAME> must be set for each embedded module. 1384c4212e9SVincent Guittot# 1394c4212e9SVincent Guittot# Standard modules source tree: <scp-path>/module/<name>/src/mod_<name>.c 1404c4212e9SVincent Guittot# Optee modules source tree: <scp-path>/module/optee/<short-name>/src/mod_<name>.c 1414c4212e9SVincent Guittot# Product modules source tree: <scp-path>/product/<product-name>/module/<name>/src/mod_<name>.c 1424c4212e9SVincent Guittot# 1434c4212e9SVincent Guittot# scpfw-embed-generic-module is to be used for standard modules. 1444c4212e9SVincent Guittot# scpfw-embed-optee-module is to be used for optee modules. 1454c4212e9SVincent Guittot# scpfw-embed-product-module is to be used for product modules. 1464c4212e9SVincent Guittot# For modules that implement other C source files aside mandatory mod_<name>.c we must 1474c4212e9SVincent Guittot# add to srcs-y the required source file paths. 1484c4212e9SVincent Guittot# 1494c4212e9SVincent Guittot# scpfw-embed-mod takes 4 arguments: 1504c4212e9SVincent Guittot# $1 module name, lowercase 1514c4212e9SVincent Guittot# $2 module directory name 1524c4212e9SVincent Guittot# $3 module parent directory relative path in scpfw tree 1534c4212e9SVincent Guittot# $4 module name, uppercase, relates to CFG_SCPFW_MOD_$4 1544c4212e9SVincent Guittotdefine scpfw-embed-mod 1554c4212e9SVincent Guittotifneq (,$$(wildcard $(scpfw-path)/$3/$2/include/*)) 1564c4212e9SVincent Guittotincdirs_ext-y += $(scpfw-path)/$3/$2/include 1574c4212e9SVincent Guittotendif 1584c4212e9SVincent Guittotsrcs-$(CFG_SCPFW_MOD_$4) += $(scpfw-path)/$3/$2/src/mod_$1.c 159f5b856d8SNicola Mazzucato 160f5b856d8SNicola Mazzucato# SCMI_Perf in SCP-firmware has components that can be added conditionally at 161f5b856d8SNicola Mazzucato# build time. 162f5b856d8SNicola Mazzucatoifeq ($(1), scmi_perf) 163f5b856d8SNicola Mazzucato 164f5b856d8SNicola Mazzucatoifeq ($(CFG_SCPFW_SCMI_PERF_PROTOCOL_OPS),y) 165f5b856d8SNicola Mazzucatosrcs-$(CFG_SCPFW_MOD_SCMI_PERF) += $(scpfw-path)/$3/$2/src/scmi_perf_protocol_ops.c 166f5b856d8SNicola Mazzucatoendif 167f5b856d8SNicola Mazzucato 168f5b856d8SNicola Mazzucatoifeq ($(CFG_SCPFW_SCMI_PERF_FAST_CHANNELS),y) 169f5b856d8SNicola Mazzucatosrcs-$(CFG_SCPFW_MOD_SCMI_PERF) += $(scpfw-path)/$3/$2/src/scmi_perf_fastchannels.c 170f5b856d8SNicola Mazzucatoendif 171f5b856d8SNicola Mazzucato 172f5b856d8SNicola Mazzucatoendif 173f5b856d8SNicola Mazzucato 1744c4212e9SVincent Guittotcflags-lib-$(CFG_SCPFW_MOD_$4) += -DBUILD_HAS_MOD_$4 1754c4212e9SVincent Guittotendef 1764c4212e9SVincent Guittot 1774c4212e9SVincent Guittotdefine scpfw-embed-generic-module 1784c4212e9SVincent Guittot$(eval $(call scpfw-embed-mod,$1,$1,module,$(shell echo $1 | tr a-z A-Z))) 1794c4212e9SVincent Guittotendef 1804c4212e9SVincent Guittot 1814c4212e9SVincent Guittotdefine scpfw-embed-optee-module 1824c4212e9SVincent Guittot$(eval $(call scpfw-embed-mod,optee_$1,$1,module/optee,OPTEE_$(shell echo $1 | tr a-z A-Z))) 1834c4212e9SVincent Guittotendef 1844c4212e9SVincent Guittot 1854c4212e9SVincent Guittotdefine scpfw-embed-product-module 1864c4212e9SVincent Guittot$(eval $(call scpfw-embed-mod,$1,$1,product/$(scpfw-product)/module,$(shell echo $1 | tr a-z A-Z))) 1874c4212e9SVincent Guittotendef 1884c4212e9SVincent Guittot 1894c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,clock)) 1904c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,dvfs)) 1914c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,mock_clock)) 1924c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,mock_ppu)) 1934c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,mock_psu)) 1944c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,msg_smt)) 1954c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,power_domain)) 1964c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,psu)) 1974c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,reg_sensor)) 1984c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,reset_domain)) 1994c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,sensor)) 2004c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,scmi)) 2014c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,scmi_apcore)) 2024c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,scmi_clock)) 2034c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,scmi_perf)) 2044c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,scmi_power_domain)) 2054c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,scmi_reset_domain)) 2064c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,scmi_sensor)) 2074c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,scmi_voltage_domain)) 2084c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,system_pll)) 2094c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,voltage_domain)) 2104c4212e9SVincent Guittot$(eval $(call scpfw-embed-optee-module,clock)) 2114c4212e9SVincent Guittot$(eval $(call scpfw-embed-optee-module,console)) 2124c4212e9SVincent Guittot$(eval $(call scpfw-embed-optee-module,mbx)) 2134c4212e9SVincent Guittot$(eval $(call scpfw-embed-optee-module,reset)) 2144c4212e9SVincent Guittot$(eval $(call scpfw-embed-optee-module,smt)) 2154c4212e9SVincent Guittot 2164c4212e9SVincent Guittotsrcs-$(CFG_SCPFW_MOD_CLOCK) += $(scpfw-path)/module/clock/src/clock_tree_management.c 2174c4212e9SVincent Guittotsrcs-$(CFG_SCPFW_MOD_POWER_DOMAIN) += $(scpfw-path)/module/power_domain/src/power_domain_utils.c 2184c4212e9SVincent Guittotsrcs-$(CFG_SCPFW_MOD_SCMI) += $(scpfw-path)/module/scmi/src/mod_scmi_base.c 2194c4212e9SVincent Guittotsrcs-$(CFG_SCPFW_MOD_SCMI_SENSOR) += $(scpfw-path)/module/scmi_sensor/src/mod_scmi_ext_attrib.c 2204c4212e9SVincent Guittotsrcs-$(CFG_SCPFW_MOD_SENSOR) += $(scpfw-path)/module/sensor/src/sensor_extended.c 2214c4212e9SVincent Guittot 2224c4212e9SVincent Guittot# Architecture arch/none/optee requires optee mbx header file 2234c4212e9SVincent Guittotincdirs_ext-y += $(scpfw-path)/module/optee/mbx/include 2244c4212e9SVincent Guittot# Some modules require header files from module that are not embedded 2254c4212e9SVincent Guittotifneq (,$(filter y, $(CFG_SCPFW_MOD_DVFS) $(CFG_SCPFW_MOD_MOCK_PSU) $(CFG_SCPFW_MOD_SCMI_PERF))) 2264c4212e9SVincent Guittotincdirs_ext-y += $(scpfw-path)/module/timer/include 2274c4212e9SVincent Guittotendif 2284c4212e9SVincent Guittotincdirs_ext-$(CFG_SCPFW_MOD_OPTEE_MBX) += $(scpfw-path)/module/msg_smt/include 2294c4212e9SVincent Guittotincdirs_ext-$(CFG_SCPFW_MOD_SCMI) += $(scpfw-path)/module/power_domain/include 2304c4212e9SVincent Guittot 2314c4212e9SVincent Guittotinclude core/lib/scmi-server/sub-$(CFG_SCMI_SCPFW_PRODUCT).mk 232