The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
To: Sudeep Holla <sudeep.holla@arm.com>,
	 Cristian Marussi <cristian.marussi@arm.com>
Cc: arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	 linux-kernel@vger.kernel.org, Peng Fan <peng.fan@nxp.com>
Subject: [PATCH v2 2/2] firmware: arm_scmi: create scmi_devices that not have of_node
Date: Wed, 26 Jun 2024 16:32:11 +0800	[thread overview]
Message-ID: <20240626-scmi-driver-v2-2-8f2f85b87760@nxp.com> (raw)
In-Reply-To: <20240626-scmi-driver-v2-0-8f2f85b87760@nxp.com>

From: Peng Fan <peng.fan@nxp.com>

The scmi protocol device tree node is expected to have consumers or
per node properties expect `reg`. For System power management protocol,
if no per node channel information, no need to add it in device tree,
and it will also trigger dtbs_check error "scmi: 'protocol@12' does not
match any of the regexes: 'pinctrl-[0-9]+'".

To enable system power protocol, need to explictily create the scmi
device and bind with protocol driver.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/firmware/arm_scmi/driver.c | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
index 6b6957f4743f..44a6e64eb78e 100644
--- a/drivers/firmware/arm_scmi/driver.c
+++ b/drivers/firmware/arm_scmi/driver.c
@@ -2952,7 +2952,7 @@ static int scmi_debugfs_raw_mode_setup(struct scmi_info *info)
 
 static int scmi_probe(struct platform_device *pdev)
 {
-	int ret;
+	int i, ret;
 	char *err_str = "probe failure\n";
 	struct scmi_handle *handle;
 	const struct scmi_desc *desc;
@@ -2960,6 +2960,7 @@ static int scmi_probe(struct platform_device *pdev)
 	bool coex = IS_ENABLED(CONFIG_ARM_SCMI_RAW_MODE_SUPPORT_COEX);
 	struct device *dev = &pdev->dev;
 	struct device_node *child, *np = dev->of_node;
+	uint32_t protocols[] = { SCMI_PROTOCOL_SYSTEM, SCMI_PROTOCOL_POWERCAP };
 
 	desc = of_device_get_match_data(dev);
 	if (!desc)
@@ -3114,6 +3115,36 @@ static int scmi_probe(struct platform_device *pdev)
 		scmi_create_protocol_devices(child, info, prot_id, NULL);
 	}
 
+	/* Create devices that not have a device node */
+	for (i = 0; i < ARRAY_SIZE(protocols); i++) {
+		void *p;
+		u32 prot_id = protocols[i];
+
+		p = idr_find(&info->active_protocols, prot_id);
+		if (p)
+			continue;
+
+		if (!scmi_is_protocol_implemented(handle, prot_id)) {
+			dev_info(dev, "SCMI protocol 0x%x not implemented\n",
+				 protocols[i]);
+			continue;
+		}
+
+		ret = scmi_txrx_setup(info, NULL, prot_id);
+		if (ret) {
+			dev_err(dev, "SCMI protocol 0x%x txrx setup fail(%d)\n",
+				prot_id, ret);
+			continue;
+		}
+
+		ret = idr_alloc(&info->active_protocols, NULL,
+				prot_id, prot_id + 1, GFP_KERNEL);
+		if (ret != prot_id)
+			continue;
+
+		scmi_create_protocol_devices(NULL, info, prot_id, NULL);
+	}
+
 	return 0;
 
 notification_exit:

-- 
2.37.1


      parent reply	other threads:[~2024-06-26  8:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-26  8:32 [PATCH v2 0/2] firmware: arm_scmi: create scmi devices for protocols that not have of_node Peng Fan (OSS)
2024-06-26  8:32 ` [PATCH v2 1/2] firmware: arm_scmi: channel unavailable if no of_node Peng Fan (OSS)
2024-06-26  8:32 ` Peng Fan (OSS) [this message]

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=20240626-scmi-driver-v2-2-8f2f85b87760@nxp.com \
    --to=peng.fan@oss.nxp.com \
    --cc=arm-scmi@vger.kernel.org \
    --cc=cristian.marussi@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peng.fan@nxp.com \
    --cc=sudeep.holla@arm.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox