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