summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/firmware/scmi/scmi_agent-uclass.c19
-rw-r--r--include/scmi_agent-uclass.h9
-rw-r--r--include/scmi_agent.h9
3 files changed, 36 insertions, 1 deletions
diff --git a/drivers/firmware/scmi/scmi_agent-uclass.c b/drivers/firmware/scmi/scmi_agent-uclass.c
index f7fa5df214c..2b6211c4e6a 100644
--- a/drivers/firmware/scmi/scmi_agent-uclass.c
+++ b/drivers/firmware/scmi/scmi_agent-uclass.c
@@ -128,6 +128,23 @@ static const struct scmi_agent_ops *transport_dev_ops(struct udevice *dev)
return (const struct scmi_agent_ops *)dev->driver->ops;
}
+int devm_scmi_of_get_channel(struct udevice *dev, struct scmi_channel **channel)
+{
+ struct udevice *parent;
+
+ parent = find_scmi_transport_device(dev);
+ if (!parent)
+ return -ENODEV;
+
+ if (transport_dev_ops(parent)->of_get_channel)
+ return transport_dev_ops(parent)->of_get_channel(dev, channel);
+
+ /* Drivers without a get_channel operator don't need a channel ref */
+ *channel = NULL;
+
+ return 0;
+}
+
int devm_scmi_process_msg(struct udevice *dev, struct scmi_channel *channel,
struct scmi_msg *msg)
{
@@ -141,7 +158,7 @@ int devm_scmi_process_msg(struct udevice *dev, struct scmi_channel *channel,
ops = transport_dev_ops(parent);
if (ops->process_msg)
- return ops->process_msg(parent, NULL, msg);
+ return ops->process_msg(parent, channel, msg);
return -EPROTONOSUPPORT;
}
diff --git a/include/scmi_agent-uclass.h b/include/scmi_agent-uclass.h
index 562a4cc99af..b1c93532c0e 100644
--- a/include/scmi_agent-uclass.h
+++ b/include/scmi_agent-uclass.h
@@ -14,6 +14,15 @@ struct scmi_channel;
*/
struct scmi_agent_ops {
/*
+ * of_get_channel - Get SCMI channel from SCMI agent device tree node
+ *
+ * @dev: SCMI protocol device using the transport
+ * @channel: Output reference to SCMI channel upon success
+ * Return 0 upon success and a negative errno on failure
+ */
+ int (*of_get_channel)(struct udevice *dev, struct scmi_channel **channel);
+
+ /*
* process_msg - Request transport to get the SCMI message processed
*
* @dev: SCMI protocol device using the transport
diff --git a/include/scmi_agent.h b/include/scmi_agent.h
index f4d85cae773..ee6286366df 100644
--- a/include/scmi_agent.h
+++ b/include/scmi_agent.h
@@ -46,6 +46,15 @@ struct scmi_msg {
}
/**
+ * devm_scmi_of_get_channel() - Get SCMI channel handle from SCMI agent DT node
+ *
+ * @dev: Device requesting a channel
+ * @channel: Output reference to the SCMI channel upon success
+ * @return 0 on success and a negative errno on failure
+ */
+int devm_scmi_of_get_channel(struct udevice *dev, struct scmi_channel **channel);
+
+/**
* devm_scmi_process_msg() - Send and process an SCMI message
*
* Send a message to an SCMI server through a target SCMI agent device.