[PATCH 06/14] firmware: scmi: add multi-channel support
Etienne Carriere
etienne.carriere at linaro.org
Fri May 13 08:26:14 CEST 2022
Adds resources for SCMI protocols to possibly use a dedicated SCMI
channel instead of the default channel allocated by the SCMI agent
during initialization. As per DT binding documentation, some SCMI
transports can define a specific SCMI communication channel for
given SCMI protocols. It allows SCMI protocols to pass messages
concurrently each other.
This change introduces new scmi agent uclass API function
devm_scmi_of_get_channel() for SCMI drivers probe sequences to get
a reference to the SCMI channel assigned to its related SCMI protocol.
The function queries the channel reference to its SCMI transport driver
through new scmi agent uclass operator .of_get_channel that uses Device
Tree information from related SCMI agent node.
Operator .of_get_channel returns a reference to the SCMI channel
assigned to SCMI protocol used by the caller device. SCMI transport
drivers that do not support multi-channel are not mandated to register
this operator. When so, API function devm_scmi_of_get_channel() returns
NULL and SCMI transport driver are expected to retrieve by their own
means the reference to the unique SCMI channel, for example using
platform data as these drivers currently do in U-Boot source tree.
Signed-off-by: Etienne Carriere <etienne.carriere at linaro.org>
---
drivers/firmware/scmi/scmi_agent-uclass.c | 19 ++++++++++++++++++-
include/scmi_agent-uclass.h | 9 +++++++++
include/scmi_agent.h | 9 +++++++++
3 files changed, 36 insertions(+), 1 deletion(-)
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
@@ -13,6 +13,15 @@ struct scmi_channel;
* struct scmi_transport_ops - The functions that a SCMI transport layer must implement.
*/
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
*
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
@@ -45,6 +45,15 @@ struct scmi_msg {
.out_msg_sz = sizeof(_out_array), \
}
+/**
+ * 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
*
--
2.25.1
More information about the U-Boot
mailing list