1*4c4212e9SVincent Guittot# SCMI server library is built from SCP-firmware source tree. 2*4c4212e9SVincent Guittot# The firmware is made of a framework, a product and modules. 3*4c4212e9SVincent Guittot# Only modules used by firmware must be built, as stated by 4*4c4212e9SVincent Guittot# CFG_SCPFW_MOD_* swtches. SCP-firmware needs a C source and 5*4c4212e9SVincent Guittot# a header file to be generated to describe embedded modules. 6*4c4212e9SVincent Guittot# This is done through cmake configuration of the package. 7*4c4212e9SVincent Guittot# The toolchain build directive must also match the list of 8*4c4212e9SVincent Guittot# embedded modules. 9*4c4212e9SVincent Guittot 10*4c4212e9SVincent Guittotscpfw-path = $(CFG_SCP_FIRMWARE) 11*4c4212e9SVincent Guittotscpfw-product = $(CFG_SCMI_SCPFW_PRODUCT) 12*4c4212e9SVincent Guittotscpfw-out-path := $(out-dir)/$(libdir) 13*4c4212e9SVincent Guittot 14*4c4212e9SVincent Guittot# This script was validated against SCP-firmware 2.11.0 development branch, 15*4c4212e9SVincent Guittot# from commit f1d894921d76 ("product/optee-fvp: Add new OPTEE FVP product"). 16*4c4212e9SVincent Guittotscpfw-integ-version-maj = 2 17*4c4212e9SVincent Guittotscpfw-integ-version-min = 11 18*4c4212e9SVincent Guittotscpfw-integ-version-pat = 0 19*4c4212e9SVincent Guittotscpfw-integ-version = $(scpfw-integ-version-maj).$(scpfw-integ-version-min).$(scpfw-integ-version-pat) 20*4c4212e9SVincent Guittot 21*4c4212e9SVincent Guittotsrcs-y += scmi_server.c 22*4c4212e9SVincent Guittotincdirs-y += include 23*4c4212e9SVincent Guittot 24*4c4212e9SVincent Guittot# SCP-firmware cmake configuration generates header fwk_module_idx.h and 25*4c4212e9SVincent Guittot# source files fwk_module_list.c needed for scp-firmware compilation. 26*4c4212e9SVincent Guittotscpfw-cmake-flags-y = -DSCP_FIRMWARE_SOURCE_DIR:PATH=$(scpfw-product)/fw \ 27*4c4212e9SVincent Guittot -DSCP_LOG_LEVEL="TRACE" \ 28*4c4212e9SVincent Guittot -DDISABLE_CPPCHECK=1 \ 29*4c4212e9SVincent Guittot -DCFG_NUM_THREADS=$(CFG_NUM_THREADS) \ 30*4c4212e9SVincent Guittot -DSCP_OPTEE_DIR:PATH=$(CURDIR) \ 31*4c4212e9SVincent Guittot -DCFG_CROSS_COMPILE=$(lastword $(CROSS_COMPILE_core)) 32*4c4212e9SVincent Guittot 33*4c4212e9SVincent Guittotifeq ($(cmd-echo-silent),true) 34*4c4212e9SVincent Guittotscpfw-cmake-redirect = >/dev/null 35*4c4212e9SVincent Guittotendif 36*4c4212e9SVincent Guittot 37*4c4212e9SVincent Guittotgensrcs-y += fwk_module_list 38*4c4212e9SVincent Guittotforce-gensrc-fwk_module_list := y 39*4c4212e9SVincent Guittotproduce-fwk_module_list = build/framework/src/fwk_module_list.c 40*4c4212e9SVincent Guittotrecipe-fwk_module_list = cmake -S $(scpfw-path) -B $(scpfw-out-path)/build \ 41*4c4212e9SVincent Guittot $(scpfw-cmake-flags-y) --log-level=WARNING $(scpfw-cmake-redirect) 42*4c4212e9SVincent Guittotdepends-fwk_module_list = $(scpfw-path)/product/$(scpfw-product)/fw/Firmware.cmake $(conf-file) 43*4c4212e9SVincent Guittot# Include path of generated header file fwk_module_idx.h 44*4c4212e9SVincent Guittotincdirs_ext-y += $(scpfw-out-path)/build/framework/include 45*4c4212e9SVincent Guittot 46*4c4212e9SVincent Guittotcppflags-lib-y += -DBUILD_VERSION_MAJOR=$(scpfw-integ-version-maj) \ 47*4c4212e9SVincent Guittot -DBUILD_VERSION_MINOR=$(scpfw-integ-version-min) \ 48*4c4212e9SVincent Guittot -DBUILD_VERSION_PATCH=$(scpfw-integ-version-pat) 49*4c4212e9SVincent Guittot 50*4c4212e9SVincent Guittotscpfw-impl-version := $(shell git -C $(scpfw-path) describe --tags --always --dirty=-dev 2>/dev/null || \ 51*4c4212e9SVincent Guittot echo Unknown_$(scpfw-integ-version)) 52*4c4212e9SVincent Guittotcppflags-lib-y += -DBUILD_VERSION_DESCRIBE_STRING=\"$(scpfw-impl-version)\" 53*4c4212e9SVincent Guittot 54*4c4212e9SVincent Guittotcppflags-lib-y += -DFWK_LOG_LEVEL=$(CFG_SCPFW_LOG_LEVEL) 55*4c4212e9SVincent Guittotifneq ($(CFG_SCPFW_LOG_LEVEL),0) 56*4c4212e9SVincent Guittotcppflags-lib-y += -DFMW_LOG_MINIMAL_BANNER=1 57*4c4212e9SVincent Guittotendif 58*4c4212e9SVincent Guittot 59*4c4212e9SVincent Guittotcflags-lib-y += -Wno-cast-align \ 60*4c4212e9SVincent Guittot -Wno-nonnull-compare \ 61*4c4212e9SVincent Guittot -Wno-unused-parameter \ 62*4c4212e9SVincent Guittot -Wno-suggest-attribute=format \ 63*4c4212e9SVincent Guittot -Wno-declaration-after-statement 64*4c4212e9SVincent Guittot 65*4c4212e9SVincent Guittot# The below directives will be removed once SCP-firmware pull requests 66*4c4212e9SVincent Guittot# 728 and 732 are merged. 67*4c4212e9SVincent Guittotcflags-lib-y += -Wno-undef \ 68*4c4212e9SVincent Guittot -Wno-missing-prototypes \ 69*4c4212e9SVincent Guittot -Wno-missing-declarations \ 70*4c4212e9SVincent Guittot -Wno-unused-but-set-variable \ 71*4c4212e9SVincent Guittot -Wno-suggest-attribute=format 72*4c4212e9SVincent Guittot 73*4c4212e9SVincent Guittot# Notification implementation has strict aliasing issues 74*4c4212e9SVincent Guittotcflags-lib-$(CFG_SCPFW_NOTIFICATION) += -Wno-strict-aliasing 75*4c4212e9SVincent Guittot 76*4c4212e9SVincent Guittotcppflags-lib-y += -DBUILD_HAS_SUB_SYSTEM_MODE=1 \ 77*4c4212e9SVincent Guittot -DBUILD_HAS_BASE_PROTOCOL 78*4c4212e9SVincent Guittot 79*4c4212e9SVincent Guittotcppflags-lib-$(CFG_SCPFW_NOTIFICATION) += -DBUILD_HAS_NOTIFICATION \ 80*4c4212e9SVincent Guittot -DBUILD_HAS_SCMI_NOTIFICATIONS 81*4c4212e9SVincent Guittot 82*4c4212e9SVincent Guittotcppflags-lib-$(CFG_SCPFW_FAST_CHANNELS) += -DBUILD_HAS_FAST_CHANNELS \ 83*4c4212e9SVincent Guittot -DBUILD_HAS_SCMI_FAST_CHANNELS 84*4c4212e9SVincent Guittot 85*4c4212e9SVincent Guittotcppflags-lib-$(CFG_SCPFW_CLOCK_TREE_MGMT) += -DBUILD_HAS_CLOCK_TREE_MGMT 86*4c4212e9SVincent Guittot 87*4c4212e9SVincent Guittotcppflags-lib-$(CFG_SCPFW_SCMI_PERF_FAST_CHANNELS) += -DBUILD_HAS_SCMI_PERF_FAST_CHANNELS 88*4c4212e9SVincent Guittot 89*4c4212e9SVincent Guittotcppflags-lib-$(CFG_SCPFW_SCMI_SENSOR_EVENTS) += -DBUILD_HAS_SCMI_SENSOR_EVENTS 90*4c4212e9SVincent Guittotcppflags-lib-$(CFG_SCPFW_SCMI_SENSOR_V2) += -DBUILD_HAS_SCMI_SENSOR_V2 \ 91*4c4212e9SVincent Guittot -DBUILD_HAS_SENSOR_TIMESTAMP \ 92*4c4212e9SVincent Guittot -DBUILD_HAS_SENSOR_MULTI_AXIS \ 93*4c4212e9SVincent Guittot -DBUILD_HAS_SENSOR_EXT_ATTRIBS \ 94*4c4212e9SVincent Guittot -DBUILD_HAS_SENSOR_SIGNED_VALUE 95*4c4212e9SVincent Guittot 96*4c4212e9SVincent Guittotcppflags-lib-$(CFG_SCPFW_SENSOR_TIMESTAMP) += -DBUILD_HAS_SENSOR_TIMESTAMP 97*4c4212e9SVincent Guittotcppflags-lib-$(CFG_SCPFW_SENSOR_MULTI_AXIS) += -DBUILD_HAS_SENSOR_MULTI_AXI 98*4c4212e9SVincent Guittotcppflags-lib-$(CFG_SCPFW_SENSOR_EXT_ATTRIBS) += -DBUILD_HAS_SENSOR_EXT_ATTRIBS 99*4c4212e9SVincent Guittotcppflags-lib-$(CFG_SCPFW_SENSOR_SIGNED_VALUE) += -DBUILD_HAS_SENSOR_SIGNED_VALUE 100*4c4212e9SVincent Guittotcppflags-lib-$(CFG_SCPFW_INBAND_MSG_SUPPORT) += -DBUILD_HAS_INBAND_MSG_SUPPORT 101*4c4212e9SVincent Guittot 102*4c4212e9SVincent Guittotincdirs_ext-y += $(scpfw-path)/arch/none/optee/include 103*4c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/arch/none/optee/src/arch_interrupt.c 104*4c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/arch/none/optee/src/arch_main.c 105*4c4212e9SVincent Guittot 106*4c4212e9SVincent Guittotincdirs_ext-y += $(scpfw-path)/framework/include 107*4c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/framework/src/fwk_arch.c 108*4c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/framework/src/fwk_dlist.c 109*4c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/framework/src/fwk_id.c 110*4c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/framework/src/fwk_interrupt.c 111*4c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/framework/src/fwk_io.c 112*4c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/framework/src/fwk_log.c 113*4c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/framework/src/fwk_mm.c 114*4c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/framework/src/fwk_module.c 115*4c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/framework/src/fwk_ring.c 116*4c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/framework/src/fwk_slist.c 117*4c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/framework/src/fwk_status.c 118*4c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/framework/src/fwk_string.c 119*4c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/framework/src/fwk_delayed_resp.c 120*4c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/framework/src/fwk_time.c 121*4c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/framework/src/fwk_core.c 122*4c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/framework/src/assert.c 123*4c4212e9SVincent Guittotsrcs-y += $(scpfw-path)/framework/src/stdlib.c 124*4c4212e9SVincent Guittotsrcs-$(CFG_SCPFW_NOTIFICATION) += $(scpfw-path)/framework/src/fwk_notification.c 125*4c4212e9SVincent Guittot 126*4c4212e9SVincent Guittot# Helper macros for listing SCP-firmware modules source files (in srcs-y) 127*4c4212e9SVincent Guittot# and header include paths (in incdirs_ext-y). Each module provides a C source 128*4c4212e9SVincent Guittot# file named mod_<module-name>.c and possibly an include directory. Build 129*4c4212e9SVincent Guittot# directive BUILD_HAS_MOD_<NAME> must be set for each embedded module. 130*4c4212e9SVincent Guittot# 131*4c4212e9SVincent Guittot# Standard modules source tree: <scp-path>/module/<name>/src/mod_<name>.c 132*4c4212e9SVincent Guittot# Optee modules source tree: <scp-path>/module/optee/<short-name>/src/mod_<name>.c 133*4c4212e9SVincent Guittot# Product modules source tree: <scp-path>/product/<product-name>/module/<name>/src/mod_<name>.c 134*4c4212e9SVincent Guittot# 135*4c4212e9SVincent Guittot# scpfw-embed-generic-module is to be used for standard modules. 136*4c4212e9SVincent Guittot# scpfw-embed-optee-module is to be used for optee modules. 137*4c4212e9SVincent Guittot# scpfw-embed-product-module is to be used for product modules. 138*4c4212e9SVincent Guittot# For modules that implement other C source files aside mandatory mod_<name>.c we must 139*4c4212e9SVincent Guittot# add to srcs-y the required source file paths. 140*4c4212e9SVincent Guittot# 141*4c4212e9SVincent Guittot# scpfw-embed-mod takes 4 arguments: 142*4c4212e9SVincent Guittot# $1 module name, lowercase 143*4c4212e9SVincent Guittot# $2 module directory name 144*4c4212e9SVincent Guittot# $3 module parent directory relative path in scpfw tree 145*4c4212e9SVincent Guittot# $4 module name, uppercase, relates to CFG_SCPFW_MOD_$4 146*4c4212e9SVincent Guittotdefine scpfw-embed-mod 147*4c4212e9SVincent Guittotifneq (,$$(wildcard $(scpfw-path)/$3/$2/include/*)) 148*4c4212e9SVincent Guittotincdirs_ext-y += $(scpfw-path)/$3/$2/include 149*4c4212e9SVincent Guittotendif 150*4c4212e9SVincent Guittotsrcs-$(CFG_SCPFW_MOD_$4) += $(scpfw-path)/$3/$2/src/mod_$1.c 151*4c4212e9SVincent Guittotcflags-lib-$(CFG_SCPFW_MOD_$4) += -DBUILD_HAS_MOD_$4 152*4c4212e9SVincent Guittotendef 153*4c4212e9SVincent Guittot 154*4c4212e9SVincent Guittotdefine scpfw-embed-generic-module 155*4c4212e9SVincent Guittot$(eval $(call scpfw-embed-mod,$1,$1,module,$(shell echo $1 | tr a-z A-Z))) 156*4c4212e9SVincent Guittotendef 157*4c4212e9SVincent Guittot 158*4c4212e9SVincent Guittotdefine scpfw-embed-optee-module 159*4c4212e9SVincent Guittot$(eval $(call scpfw-embed-mod,optee_$1,$1,module/optee,OPTEE_$(shell echo $1 | tr a-z A-Z))) 160*4c4212e9SVincent Guittotendef 161*4c4212e9SVincent Guittot 162*4c4212e9SVincent Guittotdefine scpfw-embed-product-module 163*4c4212e9SVincent Guittot$(eval $(call scpfw-embed-mod,$1,$1,product/$(scpfw-product)/module,$(shell echo $1 | tr a-z A-Z))) 164*4c4212e9SVincent Guittotendef 165*4c4212e9SVincent Guittot 166*4c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,clock)) 167*4c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,dvfs)) 168*4c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,mock_clock)) 169*4c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,mock_ppu)) 170*4c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,mock_psu)) 171*4c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,msg_smt)) 172*4c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,power_domain)) 173*4c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,psu)) 174*4c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,reg_sensor)) 175*4c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,reset_domain)) 176*4c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,sensor)) 177*4c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,scmi)) 178*4c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,scmi_apcore)) 179*4c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,scmi_clock)) 180*4c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,scmi_perf)) 181*4c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,scmi_power_domain)) 182*4c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,scmi_reset_domain)) 183*4c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,scmi_sensor)) 184*4c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,scmi_voltage_domain)) 185*4c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,system_pll)) 186*4c4212e9SVincent Guittot$(eval $(call scpfw-embed-generic-module,voltage_domain)) 187*4c4212e9SVincent Guittot$(eval $(call scpfw-embed-optee-module,clock)) 188*4c4212e9SVincent Guittot$(eval $(call scpfw-embed-optee-module,console)) 189*4c4212e9SVincent Guittot$(eval $(call scpfw-embed-optee-module,mbx)) 190*4c4212e9SVincent Guittot$(eval $(call scpfw-embed-optee-module,reset)) 191*4c4212e9SVincent Guittot$(eval $(call scpfw-embed-optee-module,smt)) 192*4c4212e9SVincent Guittot 193*4c4212e9SVincent Guittotsrcs-$(CFG_SCPFW_MOD_CLOCK) += $(scpfw-path)/module/clock/src/clock_tree_management.c 194*4c4212e9SVincent Guittotsrcs-$(CFG_SCPFW_MOD_POWER_DOMAIN) += $(scpfw-path)/module/power_domain/src/power_domain_utils.c 195*4c4212e9SVincent Guittotsrcs-$(CFG_SCPFW_MOD_SCMI) += $(scpfw-path)/module/scmi/src/mod_scmi_base.c 196*4c4212e9SVincent Guittotsrcs-$(CFG_SCPFW_MOD_SCMI_SENSOR) += $(scpfw-path)/module/scmi_sensor/src/mod_scmi_ext_attrib.c 197*4c4212e9SVincent Guittotsrcs-$(CFG_SCPFW_MOD_SENSOR) += $(scpfw-path)/module/sensor/src/sensor_extended.c 198*4c4212e9SVincent Guittot 199*4c4212e9SVincent Guittot# Architecture arch/none/optee requires optee mbx header file 200*4c4212e9SVincent Guittotincdirs_ext-y += $(scpfw-path)/module/optee/mbx/include 201*4c4212e9SVincent Guittot# Some modules require header files from module that are not embedded 202*4c4212e9SVincent Guittotifneq (,$(filter y, $(CFG_SCPFW_MOD_DVFS) $(CFG_SCPFW_MOD_MOCK_PSU) $(CFG_SCPFW_MOD_SCMI_PERF))) 203*4c4212e9SVincent Guittotincdirs_ext-y += $(scpfw-path)/module/timer/include 204*4c4212e9SVincent Guittotendif 205*4c4212e9SVincent Guittotincdirs_ext-$(CFG_SCPFW_MOD_OPTEE_MBX) += $(scpfw-path)/module/msg_smt/include 206*4c4212e9SVincent Guittotincdirs_ext-$(CFG_SCPFW_MOD_SCMI) += $(scpfw-path)/module/power_domain/include 207*4c4212e9SVincent Guittot 208*4c4212e9SVincent Guittotinclude core/lib/scmi-server/sub-$(CFG_SCMI_SCPFW_PRODUCT).mk 209