diff mbox series

[RFC,2/3] firmware: scmi: add PROTOCOL_VERSION support for existing protocols on sandbox

Message ID 20230728003313.10439-3-takahiro.akashi@linaro.org
State New
Headers show
Series firmware: scmi: add sanity checks for protocols | expand

Commit Message

AKASHI Takahiro July 28, 2023, 12:33 a.m. UTC
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.akashi@linaro.org>
---
 drivers/firmware/scmi/sandbox-scmi_agent.c | 80 ++++++++++++++++++++++
 1 file changed, 80 insertions(+)

Comments

Etienne CARRIERE Aug. 3, 2023, 11:39 a.m. UTC | #1
> From: AKASHI Takahiro <takahiro.akashi@linaro.org>
> Sent: Friday, July 28, 2023 02:33
> Subject: [RFC 2/3] firmware: scmi: add PROTOCOL_VERSION support for existing protocols on sandbox
> 
> 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.akashi@linaro.org>

Aside the typos, inherited from previous patch series, the patch looks all good to me.
Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com> preferrably with typos fixed.


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

Typos: s/udevice/udev/g here and for the 2 other inline description comments below.

> + * @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
> 
>
diff mbox series

Patch

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: