In the next patch, SCMI_PROTOCOL_VERSION support is added on the existing SCMI protocols and the version check will be introduced. To finish "ut dm scmi_[clocks|resets|voltage_domains]" tests, sandbox SCMI agent should also implement/mimic this command.
Signed-off-by: AKASHI Takahiro <takahiro.aka...@linaro.org> --- drivers/firmware/scmi/sandbox-scmi_agent.c | 80 ++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/drivers/firmware/scmi/sandbox-scmi_agent.c b/drivers/firmware/scmi/sandbox-scmi_agent.c index ab8afb01de40..a99fcb0ad4a9 100644 --- a/drivers/firmware/scmi/sandbox-scmi_agent.c +++ b/drivers/firmware/scmi/sandbox-scmi_agent.c @@ -43,6 +43,10 @@ #define SANDBOX_SCMI_AGENT_NAME "OSPM" #define SANDBOX_SCMI_PLATFORM_NAME "platform" +#define SANDBOX_SCMI_CLOCK_PROTOCOL_VERSION SCMI_CLOCK_PROTOCOL_VERSION +#define SANDBOX_SCMI_RD_PROTOCOL_VERSION SCMI_RESETDOM_PROTOCOL_VERSION +#define SANDBOX_SCMI_VOLTD_PROTOCOL_VERSION SCMI_VOLTDOM_PROTOCOL_VERSION + static u8 protocols[] = { SCMI_PROTOCOL_ID_CLOCK, SCMI_PROTOCOL_ID_RESET_DOMAIN, @@ -440,6 +444,28 @@ static int sandbox_scmi_base_reset_agent_configuration(struct udevice *dev, /* Clock Protocol */ +/** + * sandbox_scmi_clock_protocol_version - implement SCMI_PROTOCOL_VERSION + * @udevice: SCMI device + * @msg: SCMI message + * + * Implement SCMI_PROTOCOL_VERSION command. + */ +static int sandbox_scmi_clock_protocol_version(struct udevice *dev, + struct scmi_msg *msg) +{ + struct scmi_protocol_version_out *out = NULL; + + if (!msg->out_msg || msg->out_msg_sz < sizeof(*out)) + return -EINVAL; + + out = (struct scmi_protocol_version_out *)msg->out_msg; + out->version = SANDBOX_SCMI_CLOCK_PROTOCOL_VERSION; + out->status = SCMI_SUCCESS; + + return 0; +} + static int sandbox_scmi_clock_protocol_attribs(struct udevice *dev, struct scmi_msg *msg) { @@ -577,6 +603,30 @@ static int sandbox_scmi_clock_gate(struct udevice *dev, struct scmi_msg *msg) return 0; } +/* Reset Domain Protocol */ + +/** + * sandbox_scmi_rd_protocol_version - implement SCMI_PROTOCOL_VERSION + * @udevice: SCMI device + * @msg: SCMI message + * + * Implement SCMI_PROTOCOL_VERSION command. + */ +static int sandbox_scmi_rd_protocol_version(struct udevice *dev, + struct scmi_msg *msg) +{ + struct scmi_protocol_version_out *out = NULL; + + if (!msg->out_msg || msg->out_msg_sz < sizeof(*out)) + return -EINVAL; + + out = (struct scmi_protocol_version_out *)msg->out_msg; + out->version = SANDBOX_SCMI_RD_PROTOCOL_VERSION; + out->status = SCMI_SUCCESS; + + return 0; +} + static int sandbox_scmi_rd_attribs(struct udevice *dev, struct scmi_msg *msg) { struct scmi_rd_attr_in *in = NULL; @@ -647,6 +697,30 @@ static int sandbox_scmi_rd_reset(struct udevice *dev, struct scmi_msg *msg) return 0; } +/* Voltage Domain Protocol */ + +/** + * sandbox_scmi_voltd_protocol_version - implement SCMI_PROTOCOL_VERSION + * @udevice: SCMI device + * @msg: SCMI message + * + * Implement SCMI_PROTOCOL_VERSION command. + */ +static int sandbox_scmi_voltd_protocol_version(struct udevice *dev, + struct scmi_msg *msg) +{ + struct scmi_protocol_version_out *out = NULL; + + if (!msg->out_msg || msg->out_msg_sz < sizeof(*out)) + return -EINVAL; + + out = (struct scmi_protocol_version_out *)msg->out_msg; + out->version = SANDBOX_SCMI_VOLTD_PROTOCOL_VERSION; + out->status = SCMI_SUCCESS; + + return 0; +} + static int sandbox_scmi_voltd_attribs(struct udevice *dev, struct scmi_msg *msg) { struct scmi_voltd_attr_in *in = NULL; @@ -833,6 +907,8 @@ static int sandbox_scmi_test_process_msg(struct udevice *dev, break; case SCMI_PROTOCOL_ID_CLOCK: switch (msg->message_id) { + case SCMI_PROTOCOL_VERSION: + return sandbox_scmi_clock_protocol_version(dev, msg); case SCMI_PROTOCOL_ATTRIBUTES: return sandbox_scmi_clock_protocol_attribs(dev, msg); case SCMI_CLOCK_ATTRIBUTES: @@ -849,6 +925,8 @@ static int sandbox_scmi_test_process_msg(struct udevice *dev, break; case SCMI_PROTOCOL_ID_RESET_DOMAIN: switch (msg->message_id) { + case SCMI_PROTOCOL_VERSION: + return sandbox_scmi_rd_protocol_version(dev, msg); case SCMI_RESET_DOMAIN_ATTRIBUTES: return sandbox_scmi_rd_attribs(dev, msg); case SCMI_RESET_DOMAIN_RESET: @@ -859,6 +937,8 @@ static int sandbox_scmi_test_process_msg(struct udevice *dev, break; case SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN: switch (msg->message_id) { + case SCMI_PROTOCOL_VERSION: + return sandbox_scmi_voltd_protocol_version(dev, msg); case SCMI_VOLTAGE_DOMAIN_ATTRIBUTES: return sandbox_scmi_voltd_attribs(dev, msg); case SCMI_VOLTAGE_DOMAIN_CONFIG_SET: -- 2.41.0