All of lore.kernel.org
 help / color / mirror / Atom feed
From: Etienne Carriere <etienne.carriere@linaro.org>
To: u-boot@lists.denx.de
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>,
	Patrice Chotard <patrice.chotard@foss.st.com>,
	etienne.carriere@linaro.org
Subject: [PATCH v2 08/14] firmware: scmi: smccc transport: implement multi-channel
Date: Tue, 31 May 2022 18:09:23 +0200	[thread overview]
Message-ID: <20220531160929.931150-9-etienne.carriere@linaro.org> (raw)
In-Reply-To: <20220531160929.931150-1-etienne.carriere@linaro.org>

Updates SCMI SMCCC transport driver to get SCMI channel reference
at initialization and use when posting SCMI messages.

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
---
No change since v1.

---
 drivers/firmware/scmi/smccc_agent.c | 54 +++++++++++++++++++++++++++--
 1 file changed, 52 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/scmi/smccc_agent.c b/drivers/firmware/scmi/smccc_agent.c
index b7a930b24df..73a7e0a844a 100644
--- a/drivers/firmware/scmi/smccc_agent.c
+++ b/drivers/firmware/scmi/smccc_agent.c
@@ -30,6 +30,14 @@ struct scmi_smccc_channel {
 	struct scmi_smt smt;
 };
 
+/**
+ * struct scmi_channel - Channel instance referenced in SCMI drivers
+ * @ref: Reference to local channel instance
+ **/
+struct scmi_channel {
+	struct scmi_smccc_channel ref;
+};
+
 static int scmi_smccc_process_msg(struct udevice *dev,
 				  struct scmi_channel *channel,
 				  struct scmi_msg *msg)
@@ -38,6 +46,10 @@ static int scmi_smccc_process_msg(struct udevice *dev,
 	struct arm_smccc_res res;
 	int ret;
 
+	/* Support SCMI drivers upgraded to of_get_channel operator */
+	if (channel)
+		chan = &channel->ref;
+
 	ret = scmi_write_msg_to_smt(dev, &chan->smt, msg);
 	if (ret)
 		return ret;
@@ -53,9 +65,8 @@ static int scmi_smccc_process_msg(struct udevice *dev,
 	return ret;
 }
 
-static int scmi_smccc_of_to_plat(struct udevice *dev)
+static int setup_channel(struct udevice *dev, struct scmi_smccc_channel *chan)
 {
-	struct scmi_smccc_channel *chan = dev_get_plat(dev);
 	u32 func_id;
 	int ret;
 
@@ -73,12 +84,51 @@ static int scmi_smccc_of_to_plat(struct udevice *dev)
 	return ret;
 }
 
+static int scmi_smccc_get_channel(struct udevice *dev,
+				  struct scmi_channel **channel)
+{
+	struct scmi_smccc_channel *base_chan = dev_get_plat(dev->parent);
+	struct scmi_smccc_channel *chan;
+	u32 func_id;
+	int ret;
+
+	if (dev_read_u32(dev, "arm,smc-id", &func_id)) {
+		/* Uses agent base channel */
+		*channel = container_of(base_chan, struct scmi_channel, ref);
+
+		return 0;
+	}
+
+	/* Setup a dedicated channel */
+	chan = calloc(1, sizeof(*chan));
+	if (!chan)
+		return -ENOMEM;
+
+	ret = setup_channel(dev, chan);
+	if (ret) {
+		free(chan);
+		return ret;
+	}
+
+	*channel = container_of(chan, struct scmi_channel, ref);
+
+	return 0;
+}
+
+static int scmi_smccc_of_to_plat(struct udevice *dev)
+{
+	struct scmi_smccc_channel *chan = dev_get_plat(dev);
+
+	return setup_channel(dev, chan);
+}
+
 static const struct udevice_id scmi_smccc_ids[] = {
 	{ .compatible = "arm,scmi-smc" },
 	{ }
 };
 
 static const struct scmi_agent_ops scmi_smccc_ops = {
+	.of_get_channel = scmi_smccc_get_channel,
 	.process_msg = scmi_smccc_process_msg,
 };
 
-- 
2.25.1


  parent reply	other threads:[~2022-05-31 16:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-31 16:09 [PATCH v2 00/14] SCMI multi-channel and optee shm Etienne Carriere
2022-05-31 16:09 ` [PATCH v2 01/14] firmware: scmi: optee: use TEE shared memory for SCMI messages Etienne Carriere
2022-06-23 18:32   ` Tom Rini
2022-05-31 16:09 ` [PATCH v2 02/14] firmware: scmi: optee: fix inline description of PTA_SCMI_CMD_GET_CHANNEL Etienne Carriere
2022-05-31 16:09 ` [PATCH v2 03/14] firmware: scmi: prepare scmi uclass API to multi-channel Etienne Carriere
2022-05-31 16:09 ` [PATCH v2 04/14] firmware: scmi: prepare uclass to pass channel reference Etienne Carriere
2022-05-31 16:09 ` [PATCH v2 05/14] firmware: scmi: factorize scmi transport look up Etienne Carriere
2022-05-31 16:09 ` [PATCH v2 06/14] firmware: scmi: add multi-channel support Etienne Carriere
2022-05-31 16:09 ` [PATCH v2 07/14] firmware: scmi: mailbox transport: implement multi-channel Etienne Carriere
2022-05-31 16:09 ` Etienne Carriere [this message]
2022-05-31 16:09 ` [PATCH v2 09/14] firmware: scmi: optee " Etienne Carriere
2022-05-31 16:09 ` [PATCH v2 10/14] clk: scmi: support SCMI multi-channel Etienne Carriere
2022-09-28 17:29   ` Sean Anderson
2022-05-31 16:09 ` [PATCH v2 11/14] reset: " Etienne Carriere
2022-05-31 16:09 ` [PATCH v2 12/14] power: regulator: " Etienne Carriere
2022-06-14  2:13   ` Jaehoon Chung
2022-05-31 16:09 ` [PATCH v2 13/14] power: regulator: scmi: simplify scmi_voltd_set_enable() Etienne Carriere
2022-06-14  2:13   ` Jaehoon Chung
2022-05-31 16:09 ` [PATCH v2 14/14] firmware: scmi: use multi channel in mailbox, optee and smccc agents Etienne Carriere

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220531160929.931150-9-etienne.carriere@linaro.org \
    --to=etienne.carriere@linaro.org \
    --cc=patrice.chotard@foss.st.com \
    --cc=patrick.delaunay@foss.st.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.