From: Vinh Nguyen <[email protected]> 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 <[email protected]> Signed-off-by: Marek Vasut <[email protected]> [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 <[email protected]> Cc: Cristian Marussi <[email protected]> Cc: Patrice Chotard <[email protected]> Cc: Patrick Delaunay <[email protected]> Cc: Peng Fan <[email protected]> Cc: Sean Anderson <[email protected]> Cc: Tom Rini <[email protected]> Cc: Valentin Caron <[email protected]> Cc: Vinh Nguyen <[email protected]> Cc: Ye Li <[email protected]> Cc: [email protected] --- drivers/clk/clk_scmi.c | 22 +++++++++++++++++----- include/scmi_protocols.h | 17 +++++++++++++++-- 2 files changed, 32 insertions(+), 7 deletions(-) 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/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

