firmware: arm_scmi: Add helper to access protocol revision/version
authorCristian Marussi <cristian.marussi@arm.com>
Tue, 16 Mar 2021 12:48:34 +0000 (12:48 +0000)
committerSudeep Holla <sudeep.holla@arm.com>
Mon, 29 Mar 2021 09:00:35 +0000 (10:00 +0100)
Add an helper to access from a protocol handle, the SCMI version data
which is exposed on sysfs. Such helper will be needed by SCMI base
protocol initialization once it will be moved to new protocol handles
scheme.

Link: https://lore.kernel.org/r/20210316124903.35011-10-cristian.marussi@arm.com
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
drivers/firmware/arm_scmi/common.h
drivers/firmware/arm_scmi/driver.c

index 10e24ad43f0fd5e04c4793c4f10f59bbbaf3c7db..6a06adc73f20daaf69cfd6410bfaf1793e5c15f1 100644 (file)
@@ -215,6 +215,8 @@ struct scmi_xfer_ops {
                         struct scmi_xfer *xfer);
 };
 
+struct scmi_revision_info *
+scmi_revision_area_get(const struct scmi_protocol_handle *ph);
 int scmi_handle_put(const struct scmi_handle *handle);
 struct scmi_handle *scmi_handle_get(struct device *dev);
 void scmi_set_handle(struct scmi_device *scmi_dev);
index 8db450a0c294e52414589f04b322cae4ed472c46..fa83e1aec6d7420c0f709b2db56fd3711d79036e 100644 (file)
@@ -698,6 +698,25 @@ static const struct scmi_xfer_ops xfer_ops = {
        .xfer_put = xfer_put,
 };
 
+/**
+ * scmi_revision_area_get  - Retrieve version memory area.
+ *
+ * @ph: A reference to the protocol handle.
+ *
+ * A helper to grab the version memory area reference during SCMI Base protocol
+ * initialization.
+ *
+ * Return: A reference to the version memory area associated to the SCMI
+ *        instance underlying this protocol handle.
+ */
+struct scmi_revision_info *
+scmi_revision_area_get(const struct scmi_protocol_handle *ph)
+{
+       const struct scmi_protocol_instance *pi = ph_to_pi(ph);
+
+       return pi->handle->version;
+}
+
 /**
  * scmi_alloc_init_protocol_instance  - Allocate and initialize a protocol
  * instance descriptor.