[PATCH 2/2] clk: scmi: add compatibility for clock version 3.0 and onwards

Peng Fan peng.fan at oss.nxp.com
Mon Aug 18 09:11:45 CEST 2025


On Wed, Aug 13, 2025 at 03:59:36PM +0530, Kamlesh Gurudasani wrote:
>Clock version 3.0 specified in ARM SCMI Platform design document
>v3.2, adds extended_config_val parameter in CLOCK_CONFIG_SET.
>
>The SCMI server with clock version 3.0 rejects the message if
>they don't have this field.
>
>Add support so that both SCMI server with clock version 2.0 and 3.0
>can be handled.
>
>Signed-off-by: Kamlesh Gurudasani <kamlesh at ti.com>
>---
> drivers/clk/clk_scmi.c   | 49 ++++++++++++++++++++++++++++++++++++++-----------
> include/scmi_protocols.h |  6 ++++++
> 2 files changed, 44 insertions(+), 11 deletions(-)
>
>diff --git a/drivers/clk/clk_scmi.c b/drivers/clk/clk_scmi.c
>index 83ea7bb4286..b547f2494c6 100644
>--- a/drivers/clk/clk_scmi.c
>+++ b/drivers/clk/clk_scmi.c
>@@ -135,17 +135,44 @@ static int scmi_clk_gate(struct clk *clk, int enable)
> 		.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_clock_priv *priv = dev_get_priv(clk->dev);
>+
> 	int ret;
> 
>-	ret = devm_scmi_process_msg(clk->dev, &msg);
>-	if (ret)
>-		return ret;
>+	if (priv->version >= CLOCK_PROTOCOL_VERSION_3_0) {
>+		struct scmi_clk_state_in_v2 in = {
>+			.clock_id = clk->id,

Use clk_get_id

>+			.attributes = enable,

			.extended_config_val = 0,

>+		};
>+		struct scmi_clk_state_out out;
>+		struct scmi_msg msg = SCMI_MSG_IN(SCMI_PROTOCOL_ID_CLOCK,
>+						  SCMI_CLOCK_CONFIG_SET,
>+						  in, out);
> 
>-	return scmi_to_linux_errno(out.status);
>+		ret = devm_scmi_process_msg(clk->dev, &msg);
>+		if (ret)
>+			return ret;
>+
>+		return scmi_to_linux_errno(out.status);
>+	} else {
>+		struct scmi_clk_state_in_v2 in = {
>+			.clock_id = clk->id,
>+			.attributes = enable,

This is wrong, I think you need to use 'struct scmi_clk_state_in in = {'

Regards
Peng

>+		};
>+		struct scmi_clk_state_out out;
>+		struct scmi_msg msg = SCMI_MSG_IN(SCMI_PROTOCOL_ID_CLOCK,
>+						  SCMI_CLOCK_CONFIG_SET,
>+						  in, out);
>+
>+		ret = devm_scmi_process_msg(clk->dev, &msg);
>+		if (ret)
>+			return ret;
>+
>+		return scmi_to_linux_errno(out.status);
>+	}
>+
>+	return 0;
> }
> 
> static int scmi_clk_enable(struct clk *clk)
>@@ -275,12 +302,12 @@ static int scmi_clk_probe(struct udevice *dev)
> 	if (ret)
> 		return ret;
> 
>-	if (!CONFIG_IS_ENABLED(CLK_CCF))
>-		return 0;
>-
> 	ret = scmi_generic_protocol_version(dev, SCMI_PROTOCOL_ID_CLOCK,
> 					    &priv->version);
> 
>+	if (!CONFIG_IS_ENABLED(CLK_CCF))
>+		return 0;
>+
> 	/* register CCF children: CLK UCLASS, no probed again */
> 	if (device_get_uclass_id(dev->parent) == UCLASS_CLK)
> 		return 0;
>diff --git a/include/scmi_protocols.h b/include/scmi_protocols.h
>index 762a1032c37..a4d1a4c80c8 100644
>--- a/include/scmi_protocols.h
>+++ b/include/scmi_protocols.h
>@@ -807,6 +807,12 @@ struct scmi_clk_state_in {
> 	u32 attributes;
> };
> 
>+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.34.1
>


More information about the U-Boot mailing list