Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scmi/fix scp compilation #6769

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
function _make() { make -j$(nproc) -s O=out $*; }
function download_plug_and_trust() { mkdir -p $HOME/se050 && git clone --single-branch -b v0.4.2 https://github.com/foundriesio/plug-and-trust $HOME/se050/plug-and-trust || (rm -rf $HOME/se050 ; echo Nervermind); }
function download_scp_firmware() { git clone --depth 1 https://github.com/ARM-software/SCP-firmware.git -b v2.13.0 $HOME/scp-firmware || echo Nervermind; }
function download_scp_firmware() { git clone --depth 1 https://git.gitlab.arm.com/firmware/SCP-firmware.git -b vg/add-optee-makefile $HOME/scp-firmware || echo Nervermind; }
ccache -s -v
download_plug_and_trust
Expand Down
2 changes: 1 addition & 1 deletion core/arch/arm/plat-stm32mp1/conf.mk
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ endif # CFG_SCMI_PTA

CFG_SCMI_SCPFW ?= n
ifeq ($(CFG_SCMI_SCPFW),y)
$(call force,CFG_SCMI_SCPFW_PRODUCT,optee-stm32mp1)
$(call force,CFG_SCMI_SCPFW_PRODUCT,stm32mp1)
endif

CFG_SCMI_MSG_DRIVERS ?= n
Expand Down
4 changes: 2 additions & 2 deletions core/arch/arm/plat-vexpress/conf.mk
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ $(call force,CFG_CORE_LARGE_PHYS_ADDR,y)
$(call force,CFG_CORE_ARM64_PA_BITS,36)
CFG_AUTO_MAX_PA_BITS ?= y
ifeq ($(CFG_SCMI_SCPFW),y)
$(call force,CFG_SCMI_SCPFW_PRODUCT,optee-fvp)
$(call force,CFG_SCMI_SCPFW_PRODUCT,fvp)
endif
ifeq ($(CFG_CORE_SEL1_SPMC),y)
CFG_CORE_ASYNC_NOTIF_GIC_INTID ?= 9
Expand Down Expand Up @@ -152,7 +152,7 @@ endif
$(call force,CFG_DT,y)
CFG_DTB_MAX_SIZE ?= 0x100000
ifeq ($(CFG_SCMI_SCPFW),y)
$(call force,CFG_SCMI_SCPFW_PRODUCT,optee-fvp)
$(call force,CFG_SCMI_SCPFW_PRODUCT,fvp)
endif

CFG_CORE_ASYNC_NOTIF ?= y
Expand Down
4 changes: 3 additions & 1 deletion core/include/drivers/stpmic1_regulator.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
* Copyright (c) 2021-2022, STMicroelectronics
* Copyright (c) 2021-2024, STMicroelectronics
*/

#ifndef __DRIVERS_STPMIC1_REGULATOR_H
#define __DRIVERS_STPMIC1_REGULATOR_H

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

/*
Expand Down
4 changes: 4 additions & 0 deletions core/lib/scmi-server/conf-optee-stm32mp1.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ $(call force,CFG_SCPFW_MOD_OPTEE_CLOCK,y)
$(call force,CFG_SCPFW_MOD_OPTEE_CONSOLE,y)
$(call force,CFG_SCPFW_MOD_OPTEE_MBX,y)
$(call force,CFG_SCPFW_MOD_OPTEE_RESET,y)
ifeq ($(CFG_STM32MP1_SCMI_SHM_SYSRAM),y)
$(call force,CFG_SCPFW_MOD_OPTEE_SMT,y)
else
$(call force,CFG_SCPFW_MOD_MSG_SMT,y)
endif
$(call force,CFG_SCPFW_MOD_SCMI,y)
$(call force,CFG_SCPFW_MOD_SCMI_CLOCK,y)
$(call force,CFG_SCPFW_MOD_SCMI_RESET_DOMAIN,y)
Expand Down
2 changes: 1 addition & 1 deletion core/lib/scmi-server/conf.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# CFG_SCPFW_SENSOR_EXT_ATTRIBS
# CFG_SCPFW_SENSOR_SIGNED_VALUE

include core/lib/scmi-server/conf-$(CFG_SCMI_SCPFW_PRODUCT).mk
include core/lib/scmi-server/conf-optee-$(CFG_SCMI_SCPFW_PRODUCT).mk

# SCP-fmw log level: 0 trace/verbose, 1 info, 2 warning, 3 error, 4 critical
ifeq ($(CFG_TEE_CORE_LOG_LEVEL),0)
Expand Down
17 changes: 0 additions & 17 deletions core/lib/scmi-server/sub-optee-fvp.mk

This file was deleted.

10 changes: 0 additions & 10 deletions core/lib/scmi-server/sub-optee-stm32mp1.mk

This file was deleted.

136 changes: 10 additions & 126 deletions core/lib/scmi-server/sub.mk
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
# SCMI server library is built from SCP-firmware source tree.
# The firmware is made of a framework, a product and modules.
# Only modules used by firmware must be built, as stated by
# CFG_SCPFW_MOD_* swtches. SCP-firmware needs a C source and
# CFG_SCPFW_MOD_* switches. SCP-firmware needs a C source and
# a header file to be generated to describe embedded modules.
# This is done through cmake configuration of the package.
# The toolchain build directive must also match the list of
# embedded modules.

scpfw-path = $(CFG_SCP_FIRMWARE)
scpfw-product = $(CFG_SCMI_SCPFW_PRODUCT)
scpfw-product = optee/$(CFG_SCMI_SCPFW_PRODUCT)
scpfw-out-path := $(out-dir)/$(libdir)

# This script was validated against SCP-firmware 2.11.0 development branch,
# from commit f1d894921d76 ("product/optee-fvp: Add new OPTEE FVP product").
scpfw-integ-version-maj = 2
scpfw-integ-version-min = 11
scpfw-integ-version-min = 14
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update or remove the above comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

scpfw-integ-version-pat = 0
scpfw-integ-version = $(scpfw-integ-version-maj).$(scpfw-integ-version-min).$(scpfw-integ-version-pat)

Expand All @@ -30,6 +28,11 @@ scpfw-cmake-flags-y = -DSCP_FIRMWARE_SOURCE_DIR:PATH=$(scpfw-product)/fw \
-DSCP_OPTEE_DIR:PATH=$(CURDIR) \
-DCFG_CROSS_COMPILE=$(lastword $(CROSS_COMPILE_core))

# CMake does not need to check the cross compilation toolchain since we do not
# compile any source file with CMake, we only generate some SCP-firmware
# files.
scpfw-cmake-flags-y += -DCMAKE_C_COMPILER_WORKS=1

ifeq ($(cmd-echo-silent),true)
scpfw-cmake-redirect = >/dev/null
endif
Expand Down Expand Up @@ -102,125 +105,6 @@ cppflags-lib-$(CFG_SCPFW_SENSOR_EXT_ATTRIBS) += -DBUILD_HAS_SENSOR_EXT_ATTRIBS
cppflags-lib-$(CFG_SCPFW_SENSOR_SIGNED_VALUE) += -DBUILD_HAS_SENSOR_SIGNED_VALUE
cppflags-lib-$(CFG_SCPFW_INBAND_MSG_SUPPORT) += -DBUILD_HAS_INBAND_MSG_SUPPORT

incdirs_ext-y += $(scpfw-path)/arch/none/optee/include
srcs-y += $(scpfw-path)/arch/none/optee/src/arch_interrupt.c
srcs-y += $(scpfw-path)/arch/none/optee/src/arch_main.c

incdirs_ext-y += $(scpfw-path)/framework/include
srcs-y += $(scpfw-path)/framework/src/fwk_arch.c
srcs-y += $(scpfw-path)/framework/src/fwk_dlist.c
srcs-y += $(scpfw-path)/framework/src/fwk_id.c
srcs-y += $(scpfw-path)/framework/src/fwk_interrupt.c
srcs-y += $(scpfw-path)/framework/src/fwk_io.c
srcs-y += $(scpfw-path)/framework/src/fwk_log.c
srcs-y += $(scpfw-path)/framework/src/fwk_mm.c
srcs-y += $(scpfw-path)/framework/src/fwk_module.c
srcs-y += $(scpfw-path)/framework/src/fwk_ring.c
srcs-y += $(scpfw-path)/framework/src/fwk_slist.c
srcs-y += $(scpfw-path)/framework/src/fwk_status.c
srcs-y += $(scpfw-path)/framework/src/fwk_string.c
srcs-y += $(scpfw-path)/framework/src/fwk_delayed_resp.c
srcs-y += $(scpfw-path)/framework/src/fwk_time.c
srcs-y += $(scpfw-path)/framework/src/fwk_core.c
srcs-y += $(scpfw-path)/framework/src/assert.c
srcs-y += $(scpfw-path)/framework/src/stdlib.c
srcs-$(CFG_SCPFW_NOTIFICATION) += $(scpfw-path)/framework/src/fwk_notification.c

# Helper macros for listing SCP-firmware modules source files (in srcs-y)
# and header include paths (in incdirs_ext-y). Each module provides a C source
# file named mod_<module-name>.c and possibly an include directory. Build
# directive BUILD_HAS_MOD_<NAME> must be set for each embedded module.
#
# Standard modules source tree: <scp-path>/module/<name>/src/mod_<name>.c
# Optee modules source tree: <scp-path>/module/optee/<short-name>/src/mod_<name>.c
# Product modules source tree: <scp-path>/product/<product-name>/module/<name>/src/mod_<name>.c
#
# scpfw-embed-generic-module is to be used for standard modules.
# scpfw-embed-optee-module is to be used for optee modules.
# scpfw-embed-product-module is to be used for product modules.
# For modules that implement other C source files aside mandatory mod_<name>.c we must
# add to srcs-y the required source file paths.
#
# scpfw-embed-mod takes 4 arguments:
# $1 module name, lowercase
# $2 module directory name
# $3 module parent directory relative path in scpfw tree
# $4 module name, uppercase, relates to CFG_SCPFW_MOD_$4
define scpfw-embed-mod
ifneq (,$$(wildcard $(scpfw-path)/$3/$2/include/*))
incdirs_ext-y += $(scpfw-path)/$3/$2/include
endif
srcs-$(CFG_SCPFW_MOD_$4) += $(scpfw-path)/$3/$2/src/mod_$1.c

# SCMI_Perf in SCP-firmware has components that can be added conditionally at
# build time.
ifeq ($(1), scmi_perf)

ifeq ($(CFG_SCPFW_SCMI_PERF_PROTOCOL_OPS),y)
srcs-$(CFG_SCPFW_MOD_SCMI_PERF) += $(scpfw-path)/$3/$2/src/scmi_perf_protocol_ops.c
endif

ifeq ($(CFG_SCPFW_SCMI_PERF_FAST_CHANNELS),y)
srcs-$(CFG_SCPFW_MOD_SCMI_PERF) += $(scpfw-path)/$3/$2/src/scmi_perf_fastchannels.c
endif

endif

cflags-lib-$(CFG_SCPFW_MOD_$4) += -DBUILD_HAS_MOD_$4
endef

define scpfw-embed-generic-module
$(eval $(call scpfw-embed-mod,$1,$1,module,$(shell echo $1 | tr a-z A-Z)))
endef

define scpfw-embed-optee-module
$(eval $(call scpfw-embed-mod,optee_$1,$1,module/optee,OPTEE_$(shell echo $1 | tr a-z A-Z)))
endef

define scpfw-embed-product-module
$(eval $(call scpfw-embed-mod,$1,$1,product/$(scpfw-product)/module,$(shell echo $1 | tr a-z A-Z)))
endef

$(eval $(call scpfw-embed-generic-module,clock))
$(eval $(call scpfw-embed-generic-module,dvfs))
$(eval $(call scpfw-embed-generic-module,mock_clock))
$(eval $(call scpfw-embed-generic-module,mock_ppu))
$(eval $(call scpfw-embed-generic-module,mock_psu))
$(eval $(call scpfw-embed-generic-module,msg_smt))
$(eval $(call scpfw-embed-generic-module,power_domain))
$(eval $(call scpfw-embed-generic-module,psu))
$(eval $(call scpfw-embed-generic-module,reg_sensor))
$(eval $(call scpfw-embed-generic-module,reset_domain))
$(eval $(call scpfw-embed-generic-module,sensor))
$(eval $(call scpfw-embed-generic-module,scmi))
$(eval $(call scpfw-embed-generic-module,scmi_apcore))
$(eval $(call scpfw-embed-generic-module,scmi_clock))
$(eval $(call scpfw-embed-generic-module,scmi_perf))
$(eval $(call scpfw-embed-generic-module,scmi_power_domain))
$(eval $(call scpfw-embed-generic-module,scmi_reset_domain))
$(eval $(call scpfw-embed-generic-module,scmi_sensor))
$(eval $(call scpfw-embed-generic-module,scmi_voltage_domain))
$(eval $(call scpfw-embed-generic-module,system_pll))
$(eval $(call scpfw-embed-generic-module,voltage_domain))
$(eval $(call scpfw-embed-optee-module,clock))
$(eval $(call scpfw-embed-optee-module,console))
$(eval $(call scpfw-embed-optee-module,mbx))
$(eval $(call scpfw-embed-optee-module,reset))
$(eval $(call scpfw-embed-optee-module,smt))

srcs-$(CFG_SCPFW_MOD_CLOCK) += $(scpfw-path)/module/clock/src/clock_tree_management.c
srcs-$(CFG_SCPFW_MOD_POWER_DOMAIN) += $(scpfw-path)/module/power_domain/src/power_domain_utils.c
srcs-$(CFG_SCPFW_MOD_SCMI) += $(scpfw-path)/module/scmi/src/mod_scmi_base.c
srcs-$(CFG_SCPFW_MOD_SCMI_SENSOR) += $(scpfw-path)/module/scmi_sensor/src/mod_scmi_ext_attrib.c
srcs-$(CFG_SCPFW_MOD_SENSOR) += $(scpfw-path)/module/sensor/src/sensor_extended.c

# Architecture arch/none/optee requires optee mbx header file
incdirs_ext-y += $(scpfw-path)/module/optee/mbx/include
# Some modules require header files from module that are not embedded
ifneq (,$(filter y, $(CFG_SCPFW_MOD_DVFS) $(CFG_SCPFW_MOD_MOCK_PSU) $(CFG_SCPFW_MOD_SCMI_PERF)))
incdirs_ext-y += $(scpfw-path)/module/timer/include
endif
incdirs_ext-$(CFG_SCPFW_MOD_OPTEE_MBX) += $(scpfw-path)/module/msg_smt/include
incdirs_ext-$(CFG_SCPFW_MOD_SCMI) += $(scpfw-path)/module/power_domain/include
# Include SCP-firmware make files
include $(scpfw-path)/product/optee/sub.mk

include core/lib/scmi-server/sub-$(CFG_SCMI_SCPFW_PRODUCT).mk