firmware: add SCMI agent uclass
Subsystems (3)
PATCH v4 1/8 firmware: add SCMI agent uclass
This change introduces SCMI agent uclass to interact with a firmware using the SCMI protocols [1].
SCMI agent uclass currently supports a single method to request processing of the SCMI message by an identified server. A SCMI message is made of a byte payload associated to a protocol ID and a message ID, all defined by the SCMI specification [1]. On return from process_msg() method, the caller gets the service response.
SCMI agent uclass defines a post bind generic sequence for all devices. The sequence binds all the SCMI protocols listed in the FDT for that SCMI agent device. Currently none, but later change will introduce protocols.
This change implements a simple sandbox device for the SCMI agent uclass. The sandbox nicely answers SCMI_NOT_SUPPORTED to SCMI messages. To prepare for further test support, the sandbox exposes a architecture function for test application to read the sandbox emulated devices state. Currently supports 2 SCMI agents, identified by an ID in the FDT device name. The simplistic DM test does nothing yet.
SCMI agent uclass is designed for platforms that embed a SCMI server in a firmware hosted somewhere, for example in a companion co-processor or in the secure world of the executing processor. SCMI protocols allow an SCMI agent to discover and access external resources as clock, reset controllers and more. SCMI agent and server communicate following the SCMI specification [1]. This SCMI agent implementation complies with the DT bindings defined in the Linux kernel source tree regarding SCMI agent description since v5.8.
Links: [1] https://developer.arm.com/architectures/system-architectures/software-standards/scmi
---
Changes in v4:
- Remove local helper function dev2agent() used to hide a useless cast.
Changes in v3:
- Address comments about adding a new uclass and some sandbox test from v2 in https://patchwork.ozlabs.org/project/uboot/list/?series=196253
- New directory drivers/firmware/scmi/. The path mimics Linux kernel source tree for the equivalent driver.
- Split scmi.h (patch v2) into scmi_protocols.h, scmi_agent.h and scmi_agent-uclass.h.
- Create new uclass UCLASS_SCMI_AGENT.
- Introduce a simple sandbox on that agent. Mailbox and smccc agents are moved to specific commits in the series.
Changes in v2:
- Fix CONFIG_SCMI_FIRMWARE description with explicit SCMI reference.
- Move struct, enum and macro definitions at source file top and add inline comment description for the structures and local functions.
- Replace rc with ret as return value local variable label.
- Use explicit return 0 on successful return paths.
- Replace EINVAL with more accurate error numbers.
- Use dev_read_u32() instead of ofnode_read_u32(dev_ofnode(), ...).
- Use memcpy_toio()/memcpy_fromio() when copying message payload to/from IO memory.
- Embed mailbox transport resources upon CONFIG_DM_MAILBOX and SMCCC transport resources upon CONFIG_ARM_SMCCC.
Note: review comments on defining a uclass and sandbox for SCMI transport drivers are NOT addressed in this v2. Main issue is that there is no driver/device defined for SCMI transport layer as well as and no defined compatible ID in the SCMI DT bindings documentation.
--- arch/sandbox/dts/test.dts | 16 +++ arch/sandbox/include/asm/scmi_test.h | 43 +++++++ configs/sandbox_defconfig | 2 + drivers/firmware/Kconfig | 2 + drivers/firmware/Makefile | 1 + drivers/firmware/scmi/Kconfig | 17 +++ drivers/firmware/scmi/Makefile | 2 + drivers/firmware/scmi/sandbox-scmi_agent.c | 142 +++++++++++++++++++++ drivers/firmware/scmi/scmi_agent-uclass.c | 107 ++++++++++++++++ include/dm/uclass-id.h | 1 + include/scmi_agent-uclass.h | 24 ++++ include/scmi_agent.h | 68 ++++++++++ include/scmi_protocols.h | 41 ++++++ test/dm/Makefile | 1 + test/dm/scmi.c | 38 ++++++ 15 files changed, 505 insertions(+) create mode 100644 arch/sandbox/include/asm/scmi_test.h create mode 100644 drivers/firmware/scmi/Kconfig create mode 100644 drivers/firmware/scmi/Makefile create mode 100644 drivers/firmware/scmi/sandbox-scmi_agent.c create mode 100644 drivers/firmware/scmi/scmi_agent-uclass.c create mode 100644 include/scmi_agent-uclass.h create mode 100644 include/scmi_agent.h create mode 100644 include/scmi_protocols.h create mode 100644 test/dm/scmi.c
arch/sandbox/dts/test.dts +16 -0
@@ -356,6 +356,22 @@ sandbox_firmware: sandbox-firmware { compatible = "sandbox,firmware"; }; + + sandbox-scmi-agent at 0 { + compatible = "sandbox,scmi-agent"; + #address-cells = <1>; + #size-cells = <0>; + }; + + sandbox-scmi-agent at 1 { + compatible = "sandbox,scmi-agent"; + #address-cells = <1>; + #size-cells = <0>; + + protocol at 10 { + reg = <0x10>; + }; + }; }; pinctrl-gpio {
arch/sandbox/include/asm/scmi_test.h new file +43 -0
43 lines not on this page · raw message
configs/sandbox_defconfig +2 -0
@@ -132,6 +132,8 @@ CONFIG_BOARD_SANDBOX=y CONFIG_DMA=y CONFIG_DMA_CHANNELS=y CONFIG_SANDBOX_DMA=y +CONFIG_FIRMWARE=y +CONFIG_SCMI_FIRMWARE=y CONFIG_GPIO_HOG=y CONFIG_DM_GPIO_LOOKUP_LABEL=y CONFIG_PM8916_GPIO=y
drivers/firmware/Kconfig +2 -0
@@ -36,3 +36,5 @@ config ZYNQMP_FIRMWARE various platform management services. Say yes to enable ZynqMP firmware interface driver. If in doubt, say N. + +source "drivers/firmware/scmi/Kconfig"
drivers/firmware/Makefile +1 -0
@@ -3,3 +3,4 @@ obj-$(CONFIG_$(SPL_)ARM_PSCI_FW) += psci.o obj-$(CONFIG_TI_SCI_PROTOCOL) += ti_sci.o obj-$(CONFIG_SANDBOX) += firmware-sandbox.o obj-$(CONFIG_ZYNQMP_FIRMWARE) += firmware-zynqmp.o +obj-$(CONFIG_SCMI_FIRMWARE) += scmi/
drivers/firmware/scmi/Kconfig new file +17 -0
@@ -0,0 +1,17 @@ +config SCMI_FIRMWARE + bool "Enable SCMI support" + select FIRMWARE + select OF_TRANSLATE + depends on SANDBOX + help + System Control and Management Interface (SCMI) is a communication + protocol that defines standard interfaces for power, performance + and system management. The SCMI specification is available at + https://developer.arm.com/architectures/system-architectures/software-standards/scmi + + An SCMI agent communicates with a related SCMI server firmware + located in another sub-system, as a companion micro controller + or a companion host in the CPU system. + + Communications between agent (client) and the SCMI server are + based on message exchange.
drivers/firmware/scmi/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +obj-y += scmi_agent-uclass.o +obj-$(CONFIG_SANDBOX) += sandbox-scmi_agent.o
drivers/firmware/scmi/sandbox-scmi_agent.c new file +142 -0
142 lines not on this page · raw message
drivers/firmware/scmi/scmi_agent-uclass.c new file +107 -0
107 lines not on this page · raw message
include/dm/uclass-id.h +1 -0
@@ -94,6 +94,7 @@ enum uclass_id {UCLASS_RESET ,/* Reset controller device */ UCLASS_RNG ,/* Random Number Generator */ UCLASS_RTC ,/* Real time clock device */ +UCLASS_SCMI_AGENT ,/* Interface with an SCMI server */ UCLASS_SCSI ,/* SCSI device */ UCLASS_SERIAL ,/* Serial UART */ UCLASS_SIMPLE_BUS, /* Bus with child devices */
include/scmi_agent-uclass.h new file +24 -0
@@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2019-2020 Linaro Limited. +*/ +#ifndef _SCMI_AGENT_UCLASS_H +#define _SCMI_AGENT_UCLASS_H + +struct udevice ; +struct scmi_msg ; + +/** +* struct scmi_transport_ops - The functions that a SCMI transport layer must implement. +*/ +struct scmi_agent_ops { +/* +* process_msg - Request transport to get the SCMI message processed +* +* @agent: Agent using the transport +* @msg: SCMI message to be transmitted +*/ +int (*process_msg)(struct udevice *dev,struct scmi_msg *msg); +}; + +#endif /* _SCMI_TRANSPORT_UCLASS_H */
include/scmi_agent.h new file +68 -0
68 lines not on this page · raw message
include/scmi_protocols.h new file +41 -0
41 lines not on this page · raw message
test/dm/Makefile +1 -0
@@ -80,4 +80,5 @@ obj-$(CONFIG_DM_RNG) += rng.o obj-$(CONFIG_CLK_K210_SET_RATE) += k210_pll.o obj-$(CONFIG_SIMPLE_PM_BUS) += simple-pm-bus.o obj-$(CONFIG_RESET_SYSCON) += syscon-reset.o +obj-$(CONFIG_SCMI_FIRMWARE) += scmi.o endif
test/dm/scmi.c new file +38 -0
@@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2020, Linaro Limited +* +* Tests scmi_agent uclass and the SCMI drivers implemented in other +* uclass devices probe when a SCMI server exposes resources. +* +* Note in test.dts the protocol at 10 node in agent 1. Protocol 0x10 is not +* implemented in U-Boot SCMI components but the implementation is exepected +* to not complain on unknown protocol IDs, as long as it is not used. Note +* in test.dts tests that SCMI drivers probing does not fail for such an +* unknown SCMI protocol ID. +*/ + +#include <common.h> +#include <dm.h> +#include <asm/scmi_test.h> +#include <dm/device-internal.h> +#include <dm/test.h> +#include <test/ut.h> + +/* +* Test SCMI states when loading and releasing resources +* related to SCMI drivers. +*/ +static int dm_test_scmi_sandbox_agent (struct unit_test_state *uts) +{ +struct sandbox_scmi_service *scmi_ctx =sandbox_scmi_service_ctx (); + +ut_assertnonnull (scmi_ctx); +ut_asserteq (2 , scmi_ctx->agent_count); +ut_assertnull (scmi_ctx->agent[0 ]); +ut_assertnull (scmi_ctx->agent[1 ]); + +return 0 ; +} + +DM_TEST (dm_test_scmi_sandbox_agent,UT_TESTF_SCAN_FDT );
Signature · 1 line
2.17.1
PATCH v4 2/8 firmware: scmi: mailbox/smt agent device
This change implements a mailbox transport using SMT format for SCMI exchanges. This implementation follows the Linux kernel and SCP-firmware [1] as references implementation for SCMI message processing using SMT format for communication channel meta-data.
Use of mailboxes in SCMI FDT bindings are defined in the Linux kernel DT bindings since v4.17.
Links: [1] https://github.com/ARM-software/SCP-firmware
---
Changes in v4:
- Replace __arm__ with CONFIG_ARM.
- Remove cast for priv reference hence remove helper scmi_mbox_get_priv().
Changes in v3:
- This is a followup of the SCMI agent patches posted in
https://patchwork.ozlabs.org/project/uboot/list/?series=196253
The v3 splits commits and introduces a new uclass as requested.
- This patch implements the same mailbox SCMI agent proposed in v2 but split over few source files.
--- drivers/firmware/scmi/Kconfig | 6 +- drivers/firmware/scmi/Makefile | 2 + drivers/firmware/scmi/mailbox_agent.c | 102 +++++++++++++++++++ drivers/firmware/scmi/smt.c | 139 ++++++++++++++++++++++++++ drivers/firmware/scmi/smt.h | 86 ++++++++++++++++ 5 files changed, 333 insertions(+), 2 deletions(-) create mode 100644 drivers/firmware/scmi/mailbox_agent.c create mode 100644 drivers/firmware/scmi/smt.c create mode 100644 drivers/firmware/scmi/smt.h
drivers/firmware/scmi/Kconfig +4 -2
@@ -2,7 +2,7 @@ config SCMI_FIRMWARE bool "Enable SCMI support" select FIRMWARE select OF_TRANSLATE - depends on SANDBOX + depends on SANDBOX || DM_MAILBOX help System Control and Management Interface (SCMI) is a communication protocol that defines standard interfaces for power, performance
@@ -14,4 +14,6 @@ config SCMI_FIRMWARE or a companion host in the CPU system. Communications between agent (client) and the SCMI server are - based on message exchange. + based on message exchange. Messages can be exchange over tranport + channels as a mailbox device with some piece of identified shared + memory.
drivers/firmware/scmi/Makefile +2 -0
@@ -1,2 +1,4 @@ obj-y += scmi_agent-uclass.o +obj-y += smt.o +obj-$(CONFIG_DM_MAILBOX) += mailbox_agent.o obj-$(CONFIG_SANDBOX) += sandbox-scmi_agent.o
drivers/firmware/scmi/mailbox_agent.c new file +102 -0
102 lines not on this page · raw message
drivers/firmware/scmi/smt.c new file +139 -0
139 lines not on this page · raw message
drivers/firmware/scmi/smt.h new file +86 -0
86 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v4 2/8 firmware: scmi: mailbox/smt agent device
Quoted 26 lines · Etienne Carriere
This change implements a mailbox transport using SMT format for SCMI exchanges. This implementation follows the Linux kernel and SCP-firmware [1] as references implementation for SCMI message processing using SMT format for communication channel meta-data.
Use of mailboxes in SCMI FDT bindings are defined in the Linux kernel DT bindings since v4.17.
Links: [1] https://github.com/ARM-software/SCP-firmware
Signed-off-by Etienne Carriere <[email protected]>Cc Simon Glass <[email protected]>Cc Peng Fan <[email protected]>Cc Sudeep Holla <[email protected]>---
Changes in v4:
- Replace__arm__withCONFIG_ARM.
- Remove cast for priv reference hence remove helperscmi_mbox_get_priv().Changes in v3:
- This is a followup of the SCMI agent patches posted in
https://patchwork.ozlabs.org/project/uboot/list/?series=196253
The v3 splits commits and introduces a new uclass as requested.
- This patch implements the same mailbox SCMI agent proposed in v2 but split over few source files.
Quoted 10 lines
--- drivers/firmware/scmi/Kconfig | 6 +- drivers/firmware/scmi/Makefile | 2 + drivers/firmware/scmi/mailbox_agent.c | 102 +++++++++++++++++++ drivers/firmware/scmi/smt.c | 139 ++++++++++++++++++++++++++ drivers/firmware/scmi/smt.h | 86 ++++++++++++++++ 5 files changed, 333 insertions(+), 2 deletions(-) create mode 100644 drivers/firmware/scmi/mailbox_agent.c create mode 100644 drivers/firmware/scmi/smt.c create mode 100644 drivers/firmware/scmi/smt.h
PATCH v4 2/8 firmware: scmi: mailbox/smt agent device
In reply to Etienne CarriereQuoted 8 lines · Etienne Carriere
This change implements a mailbox transport using SMT format for SCMI exchanges. This implementation follows the Linux kernel and SCP-firmware [1] as references implementation for SCMI message processing using SMT format for communication channel meta-data.
Use of mailboxes in SCMI FDT bindings are defined in the Linux kernel DT bindings since v4.17.
Quoted 6 lines
Links: [1] https://github.com/ARM-software/SCP-firmware
Signed-off-by Etienne Carriere <[email protected]>Cc Simon Glass <[email protected]>Cc Peng Fan <[email protected]>Cc Sudeep Holla <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/next, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201001/f64a3af6/attachment.sig>
PATCH v4 3/8 firmware: scmi: support Arm SMCCC transport
In reply to Etienne CarriereThis change implements a SMCCC transport for SCMI exchanges. This implementation follows the Linux kernel as references implementation for SCMI message processing, using the SMT format for communication channel meta-data.
Use of SMCCC transport in SCMI FDT bindings are defined in the Linux kernel DT bindings since v5.8. SMCCC with SMT is implemented in OP-TEE from tag 3.9.0 [2].
Links: [2] https://github.com/OP-TEE/optee_os/commit/a58c4d706d23
---
Changes in v4:
- Update CONFIG_SCMI_FIRMWARE dependencies regarding CONFIG_ARM_SMCCC.
- Remove useless cast hence remove helper dev2agent() to get dev private.
- Fix header file inclusion ordering.
Changes in v3:
- This is a followup of the SCMI agent patches posted in
https://patchwork.ozlabs.org/project/uboot/list/?series=196253
The v3 splits commits and introduces a new uclass as requested.
- This patch implements the same Arm SMCCC SCMI agent as presented in v2 but in its own source file smccc_agent.c, and based in smt.h.
--- drivers/firmware/scmi/Kconfig | 6 +- drivers/firmware/scmi/Makefile | 1 + drivers/firmware/scmi/smccc_agent.c | 89 +++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+), 3 deletions(-) create mode 100644 drivers/firmware/scmi/smccc_agent.c
drivers/firmware/scmi/Kconfig +3 -3
@@ -2,7 +2,7 @@ config SCMI_FIRMWARE bool "Enable SCMI support" select FIRMWARE select OF_TRANSLATE - depends on SANDBOX || DM_MAILBOX + depends on SANDBOX || DM_MAILBOX || ARM_SMCCC help System Control and Management Interface (SCMI) is a communication protocol that defines standard interfaces for power, performance
@@ -15,5 +15,5 @@ config SCMI_FIRMWARE Communications between agent (client) and the SCMI server are based on message exchange. Messages can be exchange over tranport - channels as a mailbox device with some piece of identified shared - memory. + channels as a mailbox device or an Arm SMCCC service with some + piece of identified shared memory.
drivers/firmware/scmi/Makefile +1 -0
@@ -1,4 +1,5 @@ obj-y += scmi_agent-uclass.o obj-y += smt.o +obj-$(CONFIG_ARM_SMCCC) += smccc_agent.o obj-$(CONFIG_DM_MAILBOX) += mailbox_agent.o obj-$(CONFIG_SANDBOX) += sandbox-scmi_agent.o
drivers/firmware/scmi/smccc_agent.c new file +89 -0
89 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v4 3/8 firmware: scmi: support Arm SMCCC transport
Quoted 28 lines · Etienne Carriere
This change implements a SMCCC transport for SCMI exchanges. This implementation follows the Linux kernel as references implementation for SCMI message processing, using the SMT format for communication channel meta-data.
Use of SMCCC transport in SCMI FDT bindings are defined in the Linux kernel DT bindings since v5.8. SMCCC with SMT is implemented in OP-TEE from tag 3.9.0 [2].
Links: [2] https://github.com/OP-TEE/optee_os/commit/a58c4d706d23
Signed-off-by Etienne Carriere <[email protected]>Cc Simon Glass <[email protected]>Cc Peng Fan <[email protected]>Cc Sudeep Holla <[email protected]>---
Changes in v4:
- UpdateCONFIG_SCMI_FIRMWAREdependencies regardingCONFIG_ARM_SMCCC.
- Remove useless cast hence remove helperdev2agent()to get dev private.
- Fix header file inclusion ordering.Changes in v3:
- This is a followup of the SCMI agent patches posted in
https://patchwork.ozlabs.org/project/uboot/list/?series=196253
The v3 splits commits and introduces a new uclass as requested.
- This patch implements the same Arm SMCCC SCMI agent as presented in v2 but in its own source filesmccc_agent.c, and based insmt.h.
Quoted 6 lines
--- drivers/firmware/scmi/Kconfig | 6 +- drivers/firmware/scmi/Makefile | 1 + drivers/firmware/scmi/smccc_agent.c | 89 +++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+), 3 deletions(-) create mode 100644 drivers/firmware/scmi/smccc_agent.c
PATCH v4 3/8 firmware: scmi: support Arm SMCCC transport
In reply to Etienne CarriereQuoted 9 lines · Etienne Carriere
This change implements a SMCCC transport for SCMI exchanges. This implementation follows the Linux kernel as references implementation for SCMI message processing, using the SMT format for communication channel meta-data.
Use of SMCCC transport in SCMI FDT bindings are defined in the Linux kernel DT bindings since v5.8. SMCCC with SMT is implemented in OP-TEE from tag 3.9.0 [2].
Quoted 6 lines
Links: [2] https://github.com/OP-TEE/optee_os/commit/a58c4d706d23
Signed-off-by Etienne Carriere <[email protected]>Cc Simon Glass <[email protected]>Cc Peng Fan <[email protected]>Cc Sudeep Holla <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/next, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201001/06594b70/attachment.sig>
PATCH v4 4/8 dt-bindings: arm: SCMI bindings documentation
In reply to Etienne CarriereDump SCMI DT bindings documentation from Linux kernel source tree v5.8-rc1.
---
No change in v4.
No change in v3.
Changes in v2:
- No change but added R-b tag.
- Yet a question: do we need to add this binding doc in U-Boot since already existing in Linux DT bindings docs? Related to review comment https://www.mail-archive.com/u-boot at lists.denx.de/msg377725.html
--- doc/device-tree-bindings/arm/arm,scmi.txt | 197 ++++++++++++++++++++++ 1 file changed, 197 insertions(+) create mode 100644 doc/device-tree-bindings/arm/arm,scmi.txt
doc/device-tree-bindings/arm/arm,scmi.txt new file +197 -0
@@ -0,0 +1,197 @@ +System Control and Management Interface (SCMI) Message Protocol +---------------------------------------------------------- + +The SCMI is intended to allow agents such as OSPM to manage various functions +that are provided by the hardware platform it is running on, including power +and performance functions. + +This binding is intended to define the interface the firmware implementing +the SCMI as described in ARM document number ARM DEN 0056A ("ARM System Control +and Management Interface Platform Design Document")[0] provide for OSPM in +the device tree. + +Required properties: + +The scmi node with the following properties shall be under the /firmware/ node. + +- compatible : shall be "arm,scmi" or "arm,scmi-smc" for smc/hvc transports +- mboxes: List of phandle and mailbox channel specifiers. It should contain + exactly one or two mailboxes, one for transmitting messages("tx") + and another optional for receiving the notifications("rx") if + supported. +- shmem : List of phandle pointing to the shared memory(SHM) area as per + generic mailbox client binding. +- #address-cells : should be '1' if the device has sub-nodes, maps to + protocol identifier for a given sub-node. +- #size-cells : should be '0' as 'reg' property doesn't have any size + associated with it. +- arm,smc-id : SMC id required when using smc or hvc transports + +Optional properties: + +- mbox-names: shall be "tx" or "rx" depending on mboxes entries. + +See Documentation/devicetree/bindings/mailbox/mailbox.txt for more details +about the generic mailbox controller and client driver bindings. + +The mailbox is the only permitted method of calling the SCMI firmware. +Mailbox doorbell is used as a mechanism to alert the presence of a +messages and/or notification. + +Each protocol supported shall have a sub-node with corresponding compatible +as described in the following sections. If the platform supports dedicated +communication channel for a particular protocol, the 3 properties namely: +mboxes, mbox-names and shmem shall be present in the sub-node corresponding +to that protocol. + +Clock/Performance bindings for the clocks/OPPs based on SCMI Message Protocol +------------------------------------------------------------ + +This binding uses the common clock binding[1]. + +Required properties: +- #clock-cells : Should be 1. Contains the Clock ID value used by SCMI commands. + +Power domain bindings for the power domains based on SCMI Message Protocol +------------------------------------------------------------ + +This binding for the SCMI power domain providers uses the generic power +domain binding[2]. + +Required properties: + - #power-domain-cells : Should be 1. Contains the device or the power + domain ID value used by SCMI commands. + +Sensor bindings for the sensors based on SCMI Message Protocol +-------------------------------------------------------------- +SCMI provides an API to access the various sensors on the SoC. + +Required properties: +- #thermal-sensor-cells: should be set to 1. This property follows the + thermal device tree bindings[3]. + + Valid cell values are raw identifiers (Sensor ID) + as used by the firmware. Refer to platform details + for your implementation for the IDs to use. + +Reset signal bindings for the reset domains based on SCMI Message Protocol +------------------------------------------------------------ + +This binding for the SCMI reset domain providers uses the generic reset +signal binding[5]. + +Required properties: + - #reset-cells : Should be 1. Contains the reset domain ID value used + by SCMI commands. + +SRAM and Shared Memory for SCMI +------------------------------- + +A small area of SRAM is reserved for SCMI communication between application +processors and SCP. + +The properties should follow the generic mmio-sram description found in [4] + +Each sub-node represents the reserved area for SCMI. + +Required sub-node properties: +- reg : The base offset and size of the reserved area with the SRAM +- compatible : should be "arm,scmi-shmem" for Non-secure SRAM based + shared memory + +[0] http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/index.html +[1] Documentation/devicetree/bindings/clock/clock-bindings.txt +[2] Documentation/devicetree/bindings/power/power-domain.yaml +[3] Documentation/devicetree/bindings/thermal/thermal.txt +[4] Documentation/devicetree/bindings/sram/sram.yaml +[5] Documentation/devicetree/bindings/reset/reset.txt + +Example: + +sram at 50000000 { + compatible = "mmio-sram"; + reg = <0x0 0x50000000 0x0 0x10000>; + + #address-cells = <1>; + #size-cells = <1>; + ranges = <0 0x0 0x50000000 0x10000>; + + cpu_scp_lpri: scp-shmem at 0 { + compatible = "arm,scmi-shmem"; + reg = <0x0 0x200>; + }; + + cpu_scp_hpri: scp-shmem at 200 { + compatible = "arm,scmi-shmem"; + reg = <0x200 0x200>; + }; +}; + +mailbox at 40000000 { + .... + #mbox-cells = <1>; + reg = <0x0 0x40000000 0x0 0x10000>; +}; + +firmware { + + ... + + scmi { + compatible = "arm,scmi"; + mboxes = <&mailbox 0 &mailbox 1>; + mbox-names = "tx", "rx"; + shmem = <&cpu_scp_lpri &cpu_scp_hpri>; + #address-cells = <1>; + #size-cells = <0>; + + scmi_devpd: protocol at 11 { + reg = <0x11>; + #power-domain-cells = <1>; + }; + + scmi_dvfs: protocol at 13 { + reg = <0x13>; + #clock-cells = <1>; + }; + + scmi_clk: protocol at 14 { + reg = <0x14>; + #clock-cells = <1>; + }; + + scmi_sensors0: protocol at 15 { + reg = <0x15>; + #thermal-sensor-cells = <1>; + }; + + scmi_reset: protocol at 16 { + reg = <0x16>; + #reset-cells = <1>; + }; + }; +}; + +cpu at 0 { + ... + reg = <0 0>; + clocks = <&scmi_dvfs 0>; +}; + +hdlcd at 7ff60000 { + ... + reg = <0 0x7ff60000 0 0x1000>; + clocks = <&scmi_clk 4>; + power-domains = <&scmi_devpd 1>; + resets = <&scmi_reset 10>; +}; + +thermal-zones { + soc_thermal { + polling-delay-passive = <100>; + polling-delay = <1000>; + /* sensor ID */ + thermal-sensors = <&scmi_sensors0 3>; + ... + }; +};
Signature · 1 line
2.17.1
PATCH v4 4/8 dt-bindings: arm: SCMI bindings documentation
Quoted 10 lines · Etienne Carriere
Dump SCMI DT bindings documentation from Linux kernel source tree v5.8-rc1.
Signed-off-by Etienne Carriere <[email protected]>Reviewed-by Simon Glass <[email protected]>---
No change in v4.
Quoted 7 lines
No change in v3.
Changes in v2:
- No change but added R-b tag.
- Yet a question: do we need to add this binding doc in U-Boot since already existing in Linux DT bindings docs? Related to review comment https://www.mail-archive.com/u-boot at lists.denx.de/msg377725.html
Yes please
Quoted 4 lines
--- doc/device-tree-bindings/arm/arm,scmi.txt | 197 ++++++++++++++++++++++ 1 file changed, 197 insertions(+) create mode 100644 doc/device-tree-bindings/arm/arm,scmi.txt
PATCH v4 4/8 dt-bindings: arm: SCMI bindings documentation
In reply to Etienne CarriereQuoted 6 lines · Etienne Carriere
Dump SCMI DT bindings documentation from Linux kernel source tree v5.8-rc1.
Signed-off-by Etienne Carriere <[email protected]>Reviewed-by Simon Glass <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/next, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201001/8c9bcf67/attachment.sig>
PATCH v4 5/8 clk: add clock driver for SCMI agents
In reply to Etienne CarriereThis change introduces a clock driver for SCMI agent devices. When SCMI agent and SCMI clock drivers are enabled, SCMI agent binds a clock device for each SCMI clock protocol devices enabled in the FDT.
SCMI clock driver is embedded upon CONFIG_CLK_SCMI=y. If enabled, CONFIG_SCMI_AGENT is also enabled.
SCMI Clock protocol is defined in the SCMI specification [1].
Links: [1] https://developer.arm.com/architectures/system-architectures/software-standards/scmi
---
Changes in v4:
- Condition DM_GET_DRIVER(scmi_clock) to IS_ENABLED(CONFIG_CLK_SCMI) to prevent a build error (linker) when CONFIG_CLK_SCMI is disabled.
Changes in v3:
- Rebased in the series without major conflict.
Changes in v2:
- CONFIG_CLK_SCMI depends on CONFIG_SCMI_FIRMWARE instead of selecting CONFIG_SCMI_FIRMWARE.
- Add inline comment description for structures and moves them to source file top. Add/fixup some functions inline description comments.
- Replace rc with ret as return value local variable label.
- Fix scmi_clk_get_rate() return value to propagate error number.
- Fix scmi_clk_set_rate() to request synchronous rate set operation:
drop flag SCMI_CLK_RATE_ASYNC_NORESP in the SCMI message payload.
- Fix scmi_clk_set_rate() return value to return clock effective rate on success.
--- drivers/clk/Kconfig | 8 ++ drivers/clk/Makefile | 1 + drivers/clk/clk_scmi.c | 99 +++++++++++++++++++++++ drivers/firmware/scmi/scmi_agent-uclass.c | 14 +++- include/scmi_protocols.h | 78 ++++++++++++++++++ 5 files changed, 197 insertions(+), 3 deletions(-) create mode 100644 drivers/clk/clk_scmi.c
drivers/clk/Kconfig +8 -0
@@ -159,6 +159,14 @@ config CLK_CDCE9XX Enable the clock synthesizer driver for CDCE913/925/937/949 series of chips. +config CLK_SCMI + bool "Enable SCMI clock driver" + depends on SCMI_FIRMWARE + help + Enable this option if you want to support clock devices exposed + by a SCMI agent based on SCMI clock protocol communication + with a SCMI server. + source "drivers/clk/analogbits/Kconfig" source "drivers/clk/at91/Kconfig" source "drivers/clk/exynos/Kconfig"
drivers/clk/Makefile +1 -0
@@ -32,6 +32,7 @@ obj-$(CONFIG_CLK_MPC83XX) += mpc83xx_clk.o obj-$(CONFIG_CLK_OCTEON) += clk_octeon.o obj-$(CONFIG_CLK_OWL) += owl/ obj-$(CONFIG_CLK_RENESAS) += renesas/ +obj-$(CONFIG_CLK_SCMI) += clk_scmi.o obj-$(CONFIG_CLK_SIFIVE) += sifive/ obj-$(CONFIG_ARCH_SUNXI) += sunxi/ obj-$(CONFIG_CLK_STM32F) += clk_stm32f.o
drivers/clk/clk_scmi.c new file +99 -0
99 lines not on this page · raw message
drivers/firmware/scmi/scmi_agent-uclass.c +11 -3
@@ -58,9 +58,9 @@ static int scmi_bind_protocols(struct udevice *dev) {int ret =0 ;ofnode node; -struct driver *drv;dev_for_each_subnode (node, dev) { +struct driver *drv =NULL ;u32 protocol_id;if (!ofnode_is_available (node))
@@ -70,9 +70,17 @@ static int scmi_bind_protocols(struct udevice *dev)continue ;switch (protocol_id) { +case SCMI_PROTOCOL_ID_CLOCK : +if (IS_ENABLED (CONFIG_CLK_SCMI )) + drv =DM_GET_DRIVER (scmi_clock); +break ;default : -dev_info (dev,"Ignore unsupported SCMI protocol %#x\n" , - protocol_id); +break ; + } + +if (!drv) { +dev_dbg (dev,"Ignore unsupported SCMI protocol %#x\n" , + protocol_id);continue ; }
include/scmi_protocols.h +78 -0
88 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v4 5/8 clk: add clock driver for SCMI agents
Quoted 36 lines · Etienne Carriere
This change introduces a clock driver for SCMI agent devices. When SCMI agent and SCMI clock drivers are enabled, SCMI agent binds a clock device for each SCMI clock protocol devices enabled in the FDT.
SCMI clock driver is embedded upon
CONFIG_CLK_SCMI=y. If enabled,CONFIG_SCMI_AGENTis also enabled.SCMI Clock protocol is defined in the SCMI specification [1].
Links: [1] https://developer.arm.com/architectures/system-architectures/software-standards/scmi
Signed-off-by Etienne Carriere <[email protected]>Cc Lukasz Majewski <[email protected]>Cc Simon Glass <[email protected]>Cc Peng Fan <[email protected]>Cc Sudeep Holla <[email protected]>---
Changes in v4:
- ConditionDM_GET_DRIVER(scmi_clock)toIS_ENABLED(CONFIG_CLK_SCMI)to prevent a build error (linker) whenCONFIG_CLK_SCMIis disabled.Changes in v3:
- Rebased in the series without major conflict.Changes in v2:
-CONFIG_CLK_SCMIdepends onCONFIG_SCMI_FIRMWAREinstead of selectingCONFIG_SCMI_FIRMWARE.
- Add inline comment description for structures and moves them to source file top. Add/fixup some functions inline description comments.
- Replace rc with ret as return value local variable label.
- Fixscmi_clk_get_rate()return value to propagate error number.
- Fixscmi_clk_set_rate()to request synchronous rate set operation:
drop flagSCMI_CLK_RATE_ASYNC_NORESPin the SCMI message payload.
- Fixscmi_clk_set_rate()return value to return clock effective rate on success.
Quoted 8 lines
--- drivers/clk/Kconfig | 8 ++ drivers/clk/Makefile | 1 + drivers/clk/clk_scmi.c | 99 +++++++++++++++++++++++ drivers/firmware/scmi/scmi_agent-uclass.c | 14 +++- include/scmi_protocols.h | 78 ++++++++++++++++++ 5 files changed, 197 insertions(+), 3 deletions(-) create mode 100644 drivers/clk/clk_scmi.c
PATCH v4 5/8 clk: add clock driver for SCMI agents
In reply to Etienne CarriereQuoted 9 lines · Etienne Carriere
This change introduces a clock driver for SCMI agent devices. When SCMI agent and SCMI clock drivers are enabled, SCMI agent binds a clock device for each SCMI clock protocol devices enabled in the FDT.
SCMI clock driver is embedded upon
CONFIG_CLK_SCMI=y. If enabled,CONFIG_SCMI_AGENTis also enabled.SCMI Clock protocol is defined in the SCMI specification [1].
Quoted 7 lines
Links: [1] https://developer.arm.com/architectures/system-architectures/software-standards/scmi
Signed-off-by Etienne Carriere <[email protected]>Cc Lukasz Majewski <[email protected]>Cc Simon Glass <[email protected]>Cc Peng Fan <[email protected]>Cc Sudeep Holla <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/next, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201001/1431e3fd/attachment.sig>
PATCH v4 6/8 firmware: scmi: sandbox test for SCMI clocks
In reply to Etienne CarriereAdd tests for SCMI clocks. A test device driver sandbox-scmi_devices.c is used to get clock resources, allowing further clock manipulation.
Change sandbox-smci_agent to emulate 3 clocks exposed through 2 agents. Add DM test scmi_clocks to test these 3 clocks.
Update DM test sandbox_scmi_agent with load/remove test sequences factorized by {load|remove}_sandbox_scmi_test_devices() helper functions.
---
Changes in v4:
- Move SCMI test devices instances from BSS to test device private data and update test/dm/scmi.c accordingly.
- Update sandbox_scmi_devices_ctx() helper to add device reference arg.
- Fix spelling issues in inline comments.
- Rename local variables rc to ret for consistency.
Changes in v3:
- New commit in the series, addresses review comments on test support. ut_dm_scmi_clocks test SCMI are found and behave as expected for the implemented clk uclass methods.
--- arch/sandbox/dts/test.dts | 15 ++ arch/sandbox/include/asm/scmi_test.h | 39 +++++ configs/sandbox_defconfig | 1 + drivers/firmware/scmi/Makefile | 2 +- drivers/firmware/scmi/sandbox-scmi_agent.c | 169 ++++++++++++++++++- drivers/firmware/scmi/sandbox-scmi_devices.c | 75 ++++++++ test/dm/scmi.c | 141 +++++++++++++++- 7 files changed, 431 insertions(+), 11 deletions(-) create mode 100644 drivers/firmware/scmi/sandbox-scmi_devices.c
arch/sandbox/dts/test.dts +15 -0
@@ -361,6 +361,11 @@ compatible = "sandbox,scmi-agent"; #address-cells = <1>; #size-cells = <0>; + + clk_scmi0: protocol at 14 { + reg = <0x14>; + #clock-cells = <1>; + }; }; sandbox-scmi-agent at 1 {
@@ -368,6 +373,11 @@ #address-cells = <1>; #size-cells = <0>; + clk_scmi1: protocol at 14 { + reg = <0x14>; + #clock-cells = <1>; + }; + protocol at 10 { reg = <0x10>; };
@@ -1052,6 +1062,11 @@ compatible = "sandbox,virtio2"; }; + sandbox_scmi { + compatible = "sandbox,scmi-devices"; + clocks = <&clk_scmi0 7>, <&clk_scmi0 3>, <&clk_scmi1 1>; + }; + pinctrl { compatible = "sandbox,pinctrl";
arch/sandbox/include/asm/scmi_test.h +39 -0
@@ -10,12 +10,28 @@ struct udevice;struct sandbox_scmi_agent ;struct sandbox_scmi_service ; +/** +* struct sandbox_scmi_clk - Simulated clock exposed by SCMI +* @id: Identifier of the clock used in the SCMI protocol +* @enabled: Clock state: true if enabled, false if disabled +* @rate: Clock rate in Hertz +*/ +struct sandbox_scmi_clk { +uint id; +bool enabled; +ulong rate; +}; +/** * struct sandbox_scmi_agent - Simulated SCMI service seen by SCMI agent * @idx: Identifier for the SCMI agent, its index +* @clk: Simulated clocks +* @clk_count: Simulated clocks array size */ struct sandbox_scmi_agent {uint idx; +struct sandbox_scmi_clk *clk; +size_t clk_count; };/**
@@ -28,16 +44,39 @@ struct sandbox_scmi_service { size_t agent_count; }; +/** +* struct sandbox_scmi_devices - Reference to devices probed through SCMI +* @clk: Array the clock devices +* @clk_count: Number of clock devices probed +*/ +struct sandbox_scmi_devices { +struct clk *clk; +size_t clk_count; +}; +#ifdef CONFIG_SCMI_FIRMWARE /** * sandbox_scmi_service_context - Get the simulated SCMI services context * @return: Reference to backend simulated resources state */ struct sandbox_scmi_service *sandbox_scmi_service_ctx (void ); + +/** +* sandbox_scmi_devices_get_ref - Get references to devices accessed through SCMI +* @dev: Reference to the test device used get test resources +* @return: Reference to the devices probed by the SCMI test +*/ +struct sandbox_scmi_devices *sandbox_scmi_devices_ctx (struct udevice *dev);#else static inline struct sandbox_scmi_service *sandbox_scmi_service_ctx (void ) {return NULL ; } + +static inline +struct sandbox_scmi_devices *sandbox_scmi_devices_ctx (struct udevice *dev) +{ +return NULL ; +}#endif /* CONFIG_SCMI_FIRMWARE */ #endif /* __SANDBOX_SCMI_TEST_H */
configs/sandbox_defconfig +1 -0
@@ -122,6 +122,7 @@ CONFIG_BUTTON=y CONFIG_BUTTON_GPIO=y CONFIG_CLK=y CONFIG_CLK_COMPOSITE_CCF=y +CONFIG_CLK_SCMI=y CONFIG_SANDBOX_CLK_CCF=y CONFIG_CPU=y CONFIG_DM_DEMO=y
drivers/firmware/scmi/Makefile +1 -1
@@ -2,4 +2,4 @@ obj-y += scmi_agent-uclass.o obj-y += smt.o obj-$(CONFIG_ARM_SMCCC) += smccc_agent.o obj-$(CONFIG_DM_MAILBOX) += mailbox_agent.o -obj-$(CONFIG_SANDBOX) += sandbox-scmi_agent.o +obj-$(CONFIG_SANDBOX) += sandbox-scmi_agent.o sandbox-scmi_devices.o
drivers/firmware/scmi/sandbox-scmi_agent.c +165 -4
211 lines not on this page · raw message
drivers/firmware/scmi/sandbox-scmi_devices.c new file +75 -0
75 lines not on this page · raw message
test/dm/scmi.c +135 -6
161 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v4 6/8 firmware: scmi: sandbox test for SCMI clocks
Quoted 26 lines · Etienne Carriere
Add tests for SCMI clocks. A test device driver
sandbox-scmi_devices.cis used to get clock resources, allowing further clock manipulation.Change sandbox-smci_agent to emulate 3 clocks exposed through 2 agents. Add DM test
scmi_clocksto test these 3 clocks.
Update DM testsandbox_scmi_agentwith load/remove test sequences factorized by {load|remove}_sandbox_scmi_test_devices() helper functions.Signed-off-by Etienne Carriere <[email protected]>Cc Simon Glass <[email protected]>Cc Peng Fan <[email protected]>Cc Sudeep Holla <[email protected]>---
Changes in v4:
- Move SCMI test devices instances from BSS to test device private data and updatetest/dm/scmi.caccordingly.
- Updatesandbox_scmi_devices_ctx()helper to add device reference arg.
- Fix spelling issues in inline comments.
- Rename local variables rc to ret for consistency.Changes in v3:
- New commit in the series, addresses review comments on test support.ut_dm_scmi_clockstest SCMI are found and behave as expected for the implemented clk uclass methods.
Quoted 10 lines
--- arch/sandbox/dts/test.dts | 15 ++ arch/sandbox/include/asm/scmi_test.h | 39 +++++ configs/sandbox_defconfig | 1 + drivers/firmware/scmi/Makefile | 2 +- drivers/firmware/scmi/sandbox-scmi_agent.c | 169 ++++++++++++++++++- drivers/firmware/scmi/sandbox-scmi_devices.c | 75 ++++++++ test/dm/scmi.c | 141 +++++++++++++++- 7 files changed, 431 insertions(+), 11 deletions(-) create mode 100644 drivers/firmware/scmi/sandbox-scmi_devices.c
PATCH v4 6/8 firmware: scmi: sandbox test for SCMI clocks
In reply to Etienne CarriereQuoted 8 lines · Etienne Carriere
Add tests for SCMI clocks. A test device driver
sandbox-scmi_devices.cis used to get clock resources, allowing further clock manipulation.Change sandbox-smci_agent to emulate 3 clocks exposed through 2 agents. Add DM test
scmi_clocksto test these 3 clocks.
Update DM testsandbox_scmi_agentwith load/remove test sequences factorized by {load|remove}_sandbox_scmi_test_devices() helper functions.
Quoted 5 lines
Signed-off-by Etienne Carriere <[email protected]>Cc Simon Glass <[email protected]>Cc Peng Fan <[email protected]>Cc Sudeep Holla <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/next, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201001/69f7622c/attachment.sig>
PATCH v4 7/8 reset: add reset controller driver for SCMI agents
In reply to Etienne CarriereThis change introduces a reset controller driver for SCMI agent devices. When SCMI agent and SCMI reset domain drivers are enabled, SCMI agent binds a reset controller device for each SCMI reset domain protocol devices enabled in the FDT.
SCMI reset driver is embedded upon CONFIG_RESET_SCMI=y. If enabled, CONFIG_SCMI_AGENT is also enabled.
SCMI Reset Domain protocol is defined in the SCMI specification [1].
Links: [1] https://developer.arm.com/architectures/system-architectures/software-standards/scmi
---
Changes in v4:
- Condition DM_GET_DRIVER(scmi_reset_domain) to IS_ENABLED(CONFIG_RESET_SCMI) to prevent a build error (linker) when CONFIG_RESET_SCMI is disabled.
Changes in v3:
- Upgrade to rename into devm_scmi_process_msg() and scmi.h split into scmi_*.h.
- Fix message ID used in scmi_reset_request().
Changes in v2:
- Change reset request() method to at least check the reset domain exists by sending a SCMI RESET_DOMAIN_ATTRIBUTE message.
- Add inline description for the several structures.
- Patch v1 R-b tag not applied since the above changes in this v2.
BACKPORTED FROM v2020.10-rc2 to V2020.04
--- drivers/firmware/scmi/scmi_agent-uclass.c | 4 ++ drivers/reset/Kconfig | 8 +++ drivers/reset/Makefile | 1 + drivers/reset/reset-scmi.c | 81 +++++++++++++++++++++++ include/scmi_protocols.h | 60 +++++++++++++++++ 5 files changed, 154 insertions(+) create mode 100644 drivers/reset/reset-scmi.c
drivers/firmware/scmi/scmi_agent-uclass.c +4 -0
@@ -74,6 +74,10 @@ static int scmi_bind_protocols(struct udevice *dev)if (IS_ENABLED (CONFIG_CLK_SCMI )) drv =DM_GET_DRIVER (scmi_clock);break ; +case SCMI_PROTOCOL_ID_RESET_DOMAIN : +if (IS_ENABLED (CONFIG_RESET_SCMI )) + drv =DM_GET_DRIVER (scmi_reset_domain); +break ;default :break ; }
drivers/reset/Kconfig +8 -0
@@ -173,4 +173,12 @@ config RESET_RASPBERRYPI relevant. This driver provides a reset controller capable of interfacing with RPi4's co-processor and model these firmware initialization routines as reset lines. + +config RESET_SCMI + bool "Enable SCMI reset domain driver" + select SCMI_FIRMWARE + help + Enable this option if you want to support reset controller + devices exposed by a SCMI agent based on SCMI reset domain + protocol communication with a SCMI server. endmenu
drivers/reset/Makefile +1 -0
@@ -26,3 +26,4 @@ obj-$(CONFIG_RESET_IMX7) += reset-imx7.o obj-$(CONFIG_RESET_SIFIVE) += reset-sifive.o obj-$(CONFIG_RESET_SYSCON) += reset-syscon.o obj-$(CONFIG_RESET_RASPBERRYPI) += reset-raspberrypi.o +obj-$(CONFIG_RESET_SCMI) += reset-scmi.o
drivers/reset/reset-scmi.c new file +81 -0
81 lines not on this page · raw message
include/scmi_protocols.h +60 -0
64 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v4 7/8 reset: add reset controller driver for SCMI agents
Quoted 35 lines · Etienne Carriere
This change introduces a reset controller driver for SCMI agent devices. When SCMI agent and SCMI reset domain drivers are enabled, SCMI agent binds a reset controller device for each SCMI reset domain protocol devices enabled in the FDT.
SCMI reset driver is embedded upon
CONFIG_RESET_SCMI=y. If enabled,CONFIG_SCMI_AGENTis also enabled.SCMI Reset Domain protocol is defined in the SCMI specification [1].
Links: [1] https://developer.arm.com/architectures/system-architectures/software-standards/scmi
Signed-off-by Etienne Carriere <[email protected]>Cc Simon Glass <[email protected]>Cc Peng Fan <[email protected]>Cc Sudeep Holla <[email protected]>---
Changes in v4:
- ConditionDM_GET_DRIVER(scmi_reset_domain)toIS_ENABLED(CONFIG_RESET_SCMI)to prevent a build error (linker) whenCONFIG_RESET_SCMIis disabled.Changes in v3:
- Upgrade to rename intodevm_scmi_process_msg()andscmi.hsplit into scmi_*.h.
- Fix message ID used inscmi_reset_request().Changes in v2:
- Change resetrequest()method to at least check the reset domain exists by sending a SCMIRESET_DOMAIN_ATTRIBUTEmessage.
- Add inline description for the several structures.
- Patch v1 R-b tag not applied since the above changes in this v2.BACKPORTED FROM v2020.10-rc2 to V2020.04
Quoted 9 lines
--- drivers/firmware/scmi/scmi_agent-uclass.c | 4 ++ drivers/reset/Kconfig | 8 +++ drivers/reset/Makefile | 1 + drivers/reset/reset-scmi.c | 81 +++++++++++++++++++++++ include/scmi_protocols.h | 60 +++++++++++++++++ 5 files changed, 154 insertions(+) create mode 100644 drivers/reset/reset-scmi.c
PATCH v4 7/8 reset: add reset controller driver for SCMI agents
In reply to Etienne CarriereQuoted 8 lines · Etienne Carriere
This change introduces a reset controller driver for SCMI agent devices. When SCMI agent and SCMI reset domain drivers are enabled, SCMI agent binds a reset controller device for each SCMI reset domain protocol devices enabled in the FDT.
SCMI reset driver is embedded upon
CONFIG_RESET_SCMI=y. If enabled,CONFIG_SCMI_AGENTis also enabled.
Quoted 8 lines
SCMI Reset Domain protocol is defined in the SCMI specification [1].
Links: [1] https://developer.arm.com/architectures/system-architectures/software-standards/scmi
Signed-off-by Etienne Carriere <[email protected]>Cc Simon Glass <[email protected]>Cc Peng Fan <[email protected]>Cc Sudeep Holla <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/next, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201001/f5f94383/attachment.sig>
PATCH v4 8/8 firmware: smci: sandbox test for SCMI reset controllers
In reply to Etienne CarriereAdd tests for SCMI reset controllers. A test device driver sandbox-scmi_devices.c is used to get reset resources, allowing further resets manipulation.
Change sandbox-smci_agent to emulate 1 reset controller exposed through an agent. Add DM test scmi_resets to test this reset controller.
---
Changes in v4:
- Rebase in the series without major conflict.
- Rename test/dm/scmi.c local variables rc to ret for consistency.
Changes in v3:
- New commit in the series, addresses review comments on test support. ut_dm_scmi_resets() tests SCMI resources are found and behave as expected for the implemented reset uclass methods.
--- arch/sandbox/dts/test.dts | 6 + arch/sandbox/include/asm/scmi_test.h | 17 +++ configs/sandbox_defconfig | 1 + drivers/firmware/scmi/sandbox-scmi_agent.c | 117 ++++++++++++++++++- drivers/firmware/scmi/sandbox-scmi_devices.c | 40 ++++++- test/dm/scmi.c | 36 ++++++ 6 files changed, 211 insertions(+), 6 deletions(-)
arch/sandbox/dts/test.dts +6 -0
@@ -366,6 +366,11 @@ reg = <0x14>; #clock-cells = <1>; }; + + reset_scmi0: protocol at 16 { + reg = <0x16>; + #reset-cells = <1>; + }; }; sandbox-scmi-agent at 1 {
@@ -1065,6 +1070,7 @@ sandbox_scmi { compatible = "sandbox,scmi-devices"; clocks = <&clk_scmi0 7>, <&clk_scmi0 3>, <&clk_scmi1 1>; + resets = <&reset_scmi0 3>; }; pinctrl {
arch/sandbox/include/asm/scmi_test.h +17 -0
@@ -22,16 +22,29 @@ struct sandbox_scmi_clk {ulong rate; }; +/** +* struct sandbox_scmi_reset - Simulated reset controller exposed by SCMI +* @asserted: Reset control state: true if asserted, false if desasserted +*/ +struct sandbox_scmi_reset { +uint id; +bool asserted; +}; +/** * struct sandbox_scmi_agent - Simulated SCMI service seen by SCMI agent * @idx: Identifier for the SCMI agent, its index * @clk: Simulated clocks * @clk_count: Simulated clocks array size +* @clk: Simulated reset domains +* @clk_count: Simulated reset domains array size */ struct sandbox_scmi_agent {uint idx;struct sandbox_scmi_clk *clk;size_t clk_count; +struct sandbox_scmi_reset *reset; +size_t reset_count; };/**
@@ -48,10 +61,14 @@ struct sandbox_scmi_service {* struct sandbox_scmi_devices - Reference to devices probed through SCMI * @clk: Array the clock devices * @clk_count: Number of clock devices probed +* @reset: Array the reset controller devices +* @reset_count: Number of reset controller devices probed */ struct sandbox_scmi_devices {struct clk *clk;size_t clk_count; +struct reset_ctl *reset; +size_t reset_count; };#ifdef CONFIG_SCMI_FIRMWARE
configs/sandbox_defconfig +1 -0
@@ -220,6 +220,7 @@ CONFIG_REMOTEPROC_SANDBOX=y CONFIG_DM_RESET=y CONFIG_SANDBOX_RESET=y CONFIG_RESET_SYSCON=y +CONFIG_RESET_SCMI=y CONFIG_DM_RNG=y CONFIG_DM_RTC=y CONFIG_RTC_RV8803=y
drivers/firmware/scmi/sandbox-scmi_agent.c +112 -5
173 lines not on this page · raw message
drivers/firmware/scmi/sandbox-scmi_devices.c +39 -1
@@ -7,6 +7,7 @@#include <clk.h> #include <dm.h> #include <malloc.h> +#include <reset.h> #include <asm/io.h> #include <asm/scmi_test.h> #include <dm/device_compat.h>
@@ -14,18 +15,22 @@/* * Simulate to some extent a SCMI exchange. * This drivers gets SCMI resources and offers API function to the -* SCMI test sequence manipulate the resources, currently clocks. +* SCMI test sequence manipulate the resources, currently clock +* and reset controllers. */ #define SCMI_TEST_DEVICES_CLK_COUNT 3 +#define SCMI_TEST_DEVICES_RD_COUNT 1/* * struct sandbox_scmi_device_priv - Storage for device handles used by test * @clk: Array of clock instances used by tests +* @reset_clt: Array of the reset controller instances used by tests * @devices: Resources exposed by sandbox_scmi_devices_ctx() */ struct sandbox_scmi_device_priv {struct clk clk[SCMI_TEST_DEVICES_CLK_COUNT ]; +struct reset_ctl reset_ctl[SCMI_TEST_DEVICES_RD_COUNT ];struct sandbox_scmi_devices devices; };
@@ -39,6 +44,22 @@ struct sandbox_scmi_devices *sandbox_scmi_devices_ctx(struct udevice *dev)return NULL ; } +static int sandbox_scmi_devices_remove (struct udevice *dev) +{ +struct sandbox_scmi_devices *devices =sandbox_scmi_devices_ctx (dev); +int ret =0 ; +size_t n; + +for (n =0 ; n <SCMI_TEST_DEVICES_RD_COUNT ; n++) { +int ret2 =reset_free (devices->reset + n); + +if (ret2 && !ret) + ret = ret2; + } + +return ret; +} +static int sandbox_scmi_devices_probe (struct udevice *dev) {struct sandbox_scmi_device_priv *priv =dev_get_priv (dev);
@@ -48,6 +69,8 @@ static int sandbox_scmi_devices_probe(struct udevice *dev) priv->devices = (struct sandbox_scmi_devices ){ .clk = priv->clk, .clk_count =SCMI_TEST_DEVICES_CLK_COUNT , + .reset = priv->reset_ctl, + .reset_count =SCMI_TEST_DEVICES_RD_COUNT , };for (n =0 ; n <SCMI_TEST_DEVICES_CLK_COUNT ; n++) {
@@ -58,7 +81,21 @@ static int sandbox_scmi_devices_probe(struct udevice *dev) } } +for (n =0 ; n <SCMI_TEST_DEVICES_RD_COUNT ; n++) { + ret =reset_get_by_index (dev, n, priv->devices.reset + n); +if (ret) { +dev_err (dev,"%s: Failed on reset %zu\n" , __func__, n); + goto err_reset; + } + } +return 0 ; + +err_reset: +for (; n >0 ; n--) +reset_free (priv->devices.reset + n -1 ); + +return ret; }static const struct udevice_id sandbox_scmi_devices_ids[] = {
@@ -71,5 +108,6 @@ U_BOOT_DRIVER(sandbox_scmi_devices) = { .id = UCLASS_MISC, .of_match = sandbox_scmi_devices_ids, .priv_auto_alloc_size = sizeof(struct sandbox_scmi_device_priv), + .remove = sandbox_scmi_devices_remove, .probe = sandbox_scmi_devices_probe, };
test/dm/scmi.c +36 -0
@@ -15,6 +15,7 @@#include <common.h> #include <clk.h> #include <dm.h> +#include <reset.h> #include <asm/scmi_test.h> #include <dm/device-internal.h> #include <dm/test.h>
@@ -44,6 +45,8 @@ static int ut_assert_scmi_state_postprobe(struct unit_test_state *uts,ut_assertnonnull (scmi_devices);if (IS_ENABLED (CONFIG_CLK_SCMI ))ut_asserteq (3 , scmi_devices->clk_count); +if (IS_ENABLED (CONFIG_RESET_SCMI )) +ut_asserteq (1 , scmi_devices->reset_count);/* State of the simulated SCMI server exposed */ scmi_ctx =sandbox_scmi_service_ctx ();
@@ -53,6 +56,8 @@ static int ut_assert_scmi_state_postprobe(struct unit_test_state *uts,ut_assertnonnull (scmi_ctx->agent[0 ]);ut_asserteq (2 , scmi_ctx->agent[0 ]->clk_count);ut_assertnonnull (scmi_ctx->agent[0 ]->clk); +ut_asserteq (1 , scmi_ctx->agent[0 ]->reset_count); +ut_assertnonnull (scmi_ctx->agent[0 ]->reset);ut_assertnonnull (scmi_ctx->agent[1 ]);ut_assertnonnull (scmi_ctx->agent[1 ]->clk);
@@ -165,3 +170,34 @@ static int dm_test_scmi_clocks(struct unit_test_state *uts) }DM_TEST (dm_test_scmi_clocks,UT_TESTF_SCAN_FDT ); + +static int dm_test_scmi_resets (struct unit_test_state *uts) +{ +struct sandbox_scmi_devices *scmi_devices; +struct sandbox_scmi_service *scmi_ctx; +struct udevice *dev =NULL ; +int ret; + +if (!IS_ENABLED (CONFIG_RESET_SCMI )) +return 0 ; + + ret =load_sandbox_scmi_test_devices (uts, &dev); +if (ret) +return ret; + + scmi_devices =sandbox_scmi_devices_ctx (dev); + scmi_ctx =sandbox_scmi_service_ctx (); + +/* Test SCMI resect controller manipulation */ + ut_assert(!scmi_ctx->agent[0]->reset[0].asserted) + +ut_assertok (reset_assert (&scmi_devices->reset[0 ])); + ut_assert(scmi_ctx->agent[0]->reset[0].asserted) + +ut_assertok (reset_deassert (&scmi_devices->reset[0 ])); +ut_assert (!scmi_ctx->agent[0 ]->reset[0 ].asserted); + +return release_sandbox_scmi_test_devices (uts, dev); +} + +DM_TEST (dm_test_scmi_resets,UT_TESTF_SCAN_FDT );
Signature · 1 line
2.17.1
PATCH v4 8/8 firmware: smci: sandbox test for SCMI reset controllers
Quoted 22 lines · Etienne Carriere
Add tests for SCMI reset controllers. A test device driver
sandbox-scmi_devices.cis used to get reset resources, allowing further resets manipulation.Change sandbox-smci_agent to emulate 1 reset controller exposed through an agent. Add DM test
scmi_resetsto test this reset controller.Signed-off-by Etienne Carriere <[email protected]>Cc Simon Glass <[email protected]>Cc Peng Fan <[email protected]>Cc Sudeep Holla <[email protected]>---
Changes in v4:
- Rebase in the series without major conflict.
- Renametest/dm/scmi.clocal variables rc to ret for consistency.Changes in v3:
- New commit in the series, addresses review comments on test support.ut_dm_scmi_resets()tests SCMI resources are found and behave as expected for the implemented reset uclass methods.
Quoted 8 lines
--- arch/sandbox/dts/test.dts | 6 + arch/sandbox/include/asm/scmi_test.h | 17 +++ configs/sandbox_defconfig | 1 + drivers/firmware/scmi/sandbox-scmi_agent.c | 117 ++++++++++++++++++- drivers/firmware/scmi/sandbox-scmi_devices.c | 40 ++++++- test/dm/scmi.c | 36 ++++++ 6 files changed, 211 insertions(+), 6 deletions(-)
PATCH v4 8/8 firmware: smci: sandbox test for SCMI reset controllers
In reply to Etienne CarriereQuoted 4 lines · Etienne Carriere
Add tests for SCMI reset controllers. A test device driver
sandbox-scmi_devices.cis used to get reset resources, allowing further resets manipulation.
Quoted 8 lines
Change sandbox-smci_agent to emulate 1 reset controller exposed through an agent. Add DM test
scmi_resetsto test this reset controller.Signed-off-by Etienne Carriere <[email protected]>Cc Simon Glass <[email protected]>Cc Peng Fan <[email protected]>Cc Sudeep Holla <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/next, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201001/ad69d3a8/attachment.sig>
PATCH v4 1/8 firmware: add SCMI agent uclass
In reply to Etienne CarriereQuoted 30 lines · Etienne Carriere
This change introduces SCMI agent uclass to interact with a firmware using the SCMI protocols [1].
SCMI agent uclass currently supports a single method to request processing of the SCMI message by an identified server. A SCMI message is made of a byte payload associated to a protocol ID and a message ID, all defined by the SCMI specification [1]. On return from
process_msg()method, the caller gets the service response.SCMI agent uclass defines a post bind generic sequence for all devices. The sequence binds all the SCMI protocols listed in the FDT for that SCMI agent device. Currently none, but later change will introduce protocols.
This change implements a simple sandbox device for the SCMI agent uclass. The sandbox nicely answers
SCMI_NOT_SUPPORTEDto SCMI messages. To prepare for further test support, the sandbox exposes a architecture function for test application to read the sandbox emulated devices state. Currently supports 2 SCMI agents, identified by an ID in the FDT device name. The simplistic DM test does nothing yet.SCMI agent uclass is designed for platforms that embed a SCMI server in a firmware hosted somewhere, for example in a companion co-processor or in the secure world of the executing processor. SCMI protocols allow an SCMI agent to discover and access external resources as clock, reset controllers and more. SCMI agent and server communicate following the SCMI specification [1]. This SCMI agent implementation complies with the DT bindings defined in the Linux kernel source tree regarding SCMI agent description since v5.8.
Quoted 6 lines
Links: [1] https://developer.arm.com/architectures/system-architectures/software-standards/scmi
Signed-off-by Etienne Carriere <[email protected]>Cc Simon Glass <[email protected]>Cc Peng Fan <[email protected]>Cc Sudeep Holla <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/next, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201001/5063fe28/attachment.sig>