]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
firmware: scmi: Add clock v3.2 CONFIG_SET support
authorVinh Nguyen <vinh.nguyen.xz@renesas.com>
Wed, 5 Nov 2025 03:42:26 +0000 (04:42 +0100)
committerPeng Fan <peng.fan@nxp.com>
Mon, 10 Nov 2025 12:57:42 +0000 (20:57 +0800)
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.

[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]

Signed-off-by: Vinh Nguyen <vinh.nguyen.xz@renesas.com>
Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Reviewed-by: Alice Guo <alice.guo@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
arch/arm/mach-imx/imx9/scmi/clock_scmi.c
drivers/clk/clk_scmi.c
drivers/firmware/scmi/sandbox-scmi_agent.c
include/scmi_protocols.h

index b6be20ec6741b9e23f62460ae84827acebbd6a05..9030dbf600dd7387edf00cbd1e70096aee394eb3 100644 (file)
@@ -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,
        };
index a7d89f32cd7c97a0ede1995612ce0b7302d06392..54378b4e1ec355ceef7bfe180444bbbfa970c81b 100644 (file)
@@ -8,6 +8,7 @@
 #include <clk-uclass.h>
 #include <dm.h>
 #include <dm/device_compat.h>
+#include <dm/device-internal.h>
 #include <scmi_agent.h>
 #include <scmi_agent-uclass.h>
 #include <scmi_protocols.h>
@@ -134,17 +135,28 @@ 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_parent_priv(clk->dev);
+       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;
 
@@ -319,6 +331,7 @@ static int scmi_clk_probe(struct udevice *dev)
                        }
 
                        dev_clk_dm(dev, i, &clk_scmi->clk);
+                       dev_set_parent_priv(clk_scmi->clk.dev, priv);
 
                        if (CLK_HAS_RESTRICTIONS(attributes)) {
                                u32 perm;
index 74a87832dcb14d63550e450f4bea2632844199e9..5b242a039c2a65ec362c0818147541ead70228ed 100644 (file)
@@ -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);
index bcd8e6711494e7af149062f57fa946968f3937ae..ecab021b47283860e25abfe3e88de74eb7d4becb 100644 (file)
@@ -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