回复: [PATCH v2] firmware: scmi: Add clock v3.2 CONFIG_SET support

Alice Guo (OSS) alice.guo at oss.nxp.com
Wed Oct 29 09:54:08 CET 2025


> -----邮件原件-----
> 发件人: U-Boot <u-boot-bounces at lists.denx.de> 代表 Marek Vasut
> 发送时间: 2025年10月27日 21:58
> 收件人: u-boot at lists.denx.de
> 抄送: Vinh Nguyen <vinh.nguyen.xz at renesas.com>; Marek Vasut
> <marek.vasut+renesas at mailbox.org>; Alice Guo <alice.guo at nxp.com>;
> Cristian Marussi <cristian.marussi at arm.com>; Patrice Chotard
> <patrice.chotard at foss.st.com>; Patrick Delaunay
> <patrick.delaunay at foss.st.com>; Peng Fan <peng.fan at nxp.com>; Sean
> Anderson <seanga2 at gmail.com>; Tom Rini <trini at konsulko.com>; Valentin
> Caron <valentin.caron at foss.st.com>; Ye Li <ye.li at nxp.com>
> 主题: [PATCH v2] firmware: scmi: Add clock v3.2 CONFIG_SET support
> 
> From: Vinh Nguyen <vinh.nguyen.xz at renesas.com>
> 
> SCMI v3.2 introduces a new clock CONFIG_SET message format that can
> optionally carry also OEM specific configuration values beside the usual clock
> enable/disable requests. Add support to use such new format when talking to a
> v3.2 compliant SCMI platform.
> 
> Support existing enable/disable operations across different clock protocol
> versions: this patch still does not add protocol operations to support the new
> OEM specific optional configuration capabilities.
> 
> No functional change for the SCMI drivers users of the related enable and
> disable clock operations.
> 
> Signed-off-by: Vinh Nguyen <vinh.nguyen.xz at renesas.com>
> Signed-off-by: Marek Vasut <marek.vasut+renesas at mailbox.org>
> [Marek: Remodel after Linux e49e314a2cf7 ("firmware: arm_scmi: Add clock
> v3.2 CONFIG_SET support")
>         Support both old < 2.1 and new >= 2.1 protocol versions.
> 	Update commit message based on Linux one]
> ---
> Cc: Alice Guo <alice.guo at nxp.com>
> Cc: Cristian Marussi <cristian.marussi at arm.com>
> Cc: Patrice Chotard <patrice.chotard at foss.st.com>
> Cc: Patrick Delaunay <patrick.delaunay at foss.st.com>
> Cc: Peng Fan <peng.fan at nxp.com>
> Cc: Sean Anderson <seanga2 at gmail.com>
> Cc: Tom Rini <trini at konsulko.com>
> Cc: Valentin Caron <valentin.caron at foss.st.com>
> Cc: Vinh Nguyen <vinh.nguyen.xz at renesas.com>
> Cc: Ye Li <ye.li at nxp.com>
> Cc: u-boot at lists.denx.de
> ---
> V2: Fix up iMX95 and sandbox after rework
> ---
>  arch/arm/mach-imx/imx9/scmi/clock_scmi.c   |  2 +-
>  drivers/clk/clk_scmi.c                     | 22 +++++++++++++++++-----
>  drivers/firmware/scmi/sandbox-scmi_agent.c |  4 ++--
>  include/scmi_protocols.h                   | 17 +++++++++++++++--
>  4 files changed, 35 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/arm/mach-imx/imx9/scmi/clock_scmi.c
> b/arch/arm/mach-imx/imx9/scmi/clock_scmi.c
> index fa15b5f8df9..fc1d5d77799 100644
> --- a/arch/arm/mach-imx/imx9/scmi/clock_scmi.c
> +++ b/arch/arm/mach-imx/imx9/scmi/clock_scmi.c
> @@ -10,7 +10,7 @@
> 
>  int imx_clk_scmi_enable(u32 clock_id, bool enable)  {
> -	struct scmi_clk_state_in in = {
> +	struct scmi_clk_state_in_v1 in = {
>  		.clock_id = clock_id,
>  		.attributes = (enable) ? 1 : 0,
>  	};
> diff --git a/drivers/clk/clk_scmi.c b/drivers/clk/clk_scmi.c index
> a7d89f32cd7..f9e17c38cad 100644
> --- a/drivers/clk/clk_scmi.c
> +++ b/drivers/clk/clk_scmi.c
> @@ -134,17 +134,29 @@ static int scmi_clk_get_attibute(struct udevice *dev,
> int clkid, char **name,
> 
>  static int scmi_clk_gate(struct clk *clk, int enable)  {
> -	struct scmi_clk_state_in in = {
> +	struct scmi_clock_priv *priv = dev_get_priv(clk->dev->parent);
> +	struct scmi_clk_state_in_v1 in_v1 = {
> +		.clock_id = clk_get_id(clk),
> +		.attributes = enable,
> +	};
> +	/* Valid only from SCMI clock v2.1 */
> +	struct scmi_clk_state_in_v2 in_v2 = {
>  		.clock_id = clk_get_id(clk),
>  		.attributes = enable,
>  	};
>  	struct scmi_clk_state_out out;
> -	struct scmi_msg msg = SCMI_MSG_IN(SCMI_PROTOCOL_ID_CLOCK,
> -					  SCMI_CLOCK_CONFIG_SET,
> -					  in, out);
> +	struct scmi_msg msg_v1 = SCMI_MSG_IN(SCMI_PROTOCOL_ID_CLOCK,
> +					     SCMI_CLOCK_CONFIG_SET,
> +					     in_v1, out);
> +	struct scmi_msg msg_v2 = SCMI_MSG_IN(SCMI_PROTOCOL_ID_CLOCK,
> +					     SCMI_CLOCK_CONFIG_SET,
> +					     in_v2, out);
> +
>  	int ret;
> 
> -	ret = devm_scmi_process_msg(clk->dev, &msg);
> +	ret = devm_scmi_process_msg(clk->dev,
> +				    (priv->version < CLOCK_PROTOCOL_VERSION_2_1) ?
> +				    &msg_v1 : &msg_v2);
>  	if (ret)
>  		return ret;
> 
> diff --git a/drivers/firmware/scmi/sandbox-scmi_agent.c
> b/drivers/firmware/scmi/sandbox-scmi_agent.c
> index 74a87832dcb..5b242a039c2 100644
> --- a/drivers/firmware/scmi/sandbox-scmi_agent.c
> +++ b/drivers/firmware/scmi/sandbox-scmi_agent.c
> @@ -828,7 +828,7 @@ static int sandbox_scmi_clock_rate_get(struct udevice
> *dev,
> 
>  static int sandbox_scmi_clock_gate(struct udevice *dev, struct scmi_msg *msg)
> {
> -	struct scmi_clk_state_in *in = NULL;
> +	struct scmi_clk_state_in_v1 *in = NULL;
>  	struct scmi_clk_state_out *out = NULL;
>  	struct sandbox_scmi_clk *clk_state = NULL;
> 
> @@ -836,7 +836,7 @@ static int sandbox_scmi_clock_gate(struct udevice *dev,
> struct scmi_msg *msg)
>  	    !msg->out_msg || msg->out_msg_sz < sizeof(*out))
>  		return -EINVAL;
> 
> -	in = (struct scmi_clk_state_in *)msg->in_msg;
> +	in = (struct scmi_clk_state_in_v1 *)msg->in_msg;
>  	out = (struct scmi_clk_state_out *)msg->out_msg;
> 
>  	clk_state = get_scmi_clk_state(in->clock_id); diff --git
> a/include/scmi_protocols.h b/include/scmi_protocols.h index
> 81979e81b6b..d89612541ef 100644
> --- a/include/scmi_protocols.h
> +++ b/include/scmi_protocols.h
> @@ -733,6 +733,7 @@ int scmi_pwd_name_get(struct udevice *dev, u32
> domain_id, u8 **name);
>  /*
>   * SCMI Clock Protocol
>   */
> +#define CLOCK_PROTOCOL_VERSION_2_1	0x20001
>  #define CLOCK_PROTOCOL_VERSION_3_0	0x30000
> 
>  enum scmi_clock_message_id {
> @@ -800,15 +801,27 @@ struct scmi_clk_attribute_out_v2 {  };
> 
>  /**
> - * struct scmi_clk_state_in - Message payload for CLOCK_CONFIG_SET
> command
> + * struct scmi_clk_state_in_v1 - Message payload for CLOCK_CONFIG_SET
> + command for protocol < 2.1
>   * @clock_id:	SCMI clock ID
>   * @attributes:	Attributes of the targets clock state
>   */
> -struct scmi_clk_state_in {
> +struct scmi_clk_state_in_v1 {
>  	u32 clock_id;
>  	u32 attributes;
>  };
> 
> +/**
> + * struct scmi_clk_state_in_v2 - Message payload for CLOCK_CONFIG_SET
> command for protocol >= 2.1
> + * @clock_id:	SCMI clock ID
> + * @attributes:	Attributes of the targets clock state
> + * @extended_config_val: Extended and OEM specific configuration  */
> +struct scmi_clk_state_in_v2 {
> +	u32 clock_id;
> +	u32 attributes;
> +	u32 extended_config_val;
> +};
> +
>  /**
>   * struct scmi_clk_state_out - Response payload for CLOCK_CONFIG_SET
> command
>   * @status:	SCMI command status
> --
> 2.51.0

Hi Marek,

I tested this patch on IMX95 and here is the log:
U-Boot SPL 2026.01-rc1-00001-g9bb6f2fc0f57 (Oct 29 2025 - 16:42:02 +0800)
SYS Boot reason: por, origin: -1, errid: -1
Normal Boot
Trying to boot from MMC2
Primary set selected
Load image from MMC/SD 0xd7000
NOTICE:  BL31: v2.12.0(release):android-16.0.0_1.0.0-rc2-2-ga266ff458
NOTICE:  BL31: Built : 10:13:07, Oct 17 2025


U-Boot 2026.01-rc1-00001-g9bb6f2fc0f57 (Oct 29 2025 - 16:42:02 +0800)

CPU:   NXP i.MX95 Rev2.0 A55 at 1800 MHz
Model: NXP i.MX95 19X19 board
DRAM:  15.8 GiB
Core:  283 devices, 24 uclasses, devicetree: separate
MMC:   "Synchronous Abort" handler, esr 0x96000006, far 0x0
elr: 0000000090233fac lr : 0000000090233f60 (reloc)
elr: 00000000fff4dfac lr : 00000000fff4df60
x0 : 0000000000000004 x1 : 00000000fdf089c8
x2 : 000000000000000c x3 : 00000000fdf19f18
x4 : 000000000000001f x5 : 0000000000000000
x6 : 00000000000013f0 x7 : 00000000fdf08bb0
x8 : 00000000000013e0 x9 : 00000000fdf087fc
x10: 0000000000000003 x11: 00000000000013c0
x12: 0000000000000000 x13: 00000000fdf08bb0
x14: 00000000fffffffb x15: 0000000000000002
x16: 00000000fff6887c x17: 0000000000000000
x18: 00000000fdf19dd0 x19: 00000000fdf2c640
x20: 0000000000000001 x21: 0000000000000000
x22: 00000000fffa7750 x23: 00000000fdf29f30
x24: 00000000fdf2dd58 x25: 0000000000000000
x26: 0000000000000000 x27: 0000000000000000
x28: 0000000000000000 x29: 00000000fdf08950

Code: f90047e2 f9004be1 9101e3e1 f9004fe0 (b94002a0)
Resetting CPU ...

resetting ...

Store the protocol version in a global variable "ver" during probe, and use it in scmi_clk_gate() instead of accessing priv->version. In this setup, the IMX95 board boots successfully.

Best regards,
Alice Guo



More information about the U-Boot mailing list