diff mbox series

remoteproc: mediatek: Fix compatibility of probing SCP cores

Message ID 20230920084611.30890-1-tinghan.shen@mediatek.com (mailing list archive)
State New, archived
Headers show
Series remoteproc: mediatek: Fix compatibility of probing SCP cores | expand

Commit Message

Tinghan Shen Sept. 20, 2023, 8:46 a.m. UTC
The SCP dt-binding introduces a new SCP node format to describe
the multi-core SCP HW. However, the old format for single-core
SCP is co-existed with the new format. It suggests that
there are two different approaches, using either the old style or
the new format, to describe the single-core SCP HW in devicetree.

the driver checks the immediate child node name in the SCP node to
determin the format that is being utilized. The node name is expected
 "scp" for new format and "cros-ec-rpmsg" for the old format. However,
the expected node name for old format didn't defined in earlier
SCP dt-binding and the old node name is "cros_ec" in old devicetree.
So, this checking breaks the compatibility with old SCP devicetree.

In order to distinguish between the various forms of SCP devicetree and
maintain compatibility with the previous SCP devicetree, this fix
verifies the existence of the compatible name "mediatek,scp-core"
introduced in the new format.

Reported-by: Laura Nao <laura.nao@collabora.com>
Fixes: 1fdbf0cdde98 ("remoteproc: mediatek: Probe SCP cluster on multi-core SCP")
Signed-off-by: Tinghan Shen <tinghan.shen@mediatek.com>
---
 drivers/remoteproc/mtk_scp.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c
index ea227b566c54..76472e50c8f5 100644
--- a/drivers/remoteproc/mtk_scp.c
+++ b/drivers/remoteproc/mtk_scp.c
@@ -1144,29 +1144,29 @@  static int scp_add_multi_core(struct platform_device *pdev,
 	return ret;
 }
 
-static int scp_is_single_core(struct platform_device *pdev)
+static bool scp_find_core_node(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct device_node *np = dev_of_node(dev);
 	struct device_node *child;
+	int found = 0;
 
-	child = of_get_next_available_child(np, NULL);
-	if (!child)
-		return dev_err_probe(dev, -ENODEV, "No child node\n");
+	for_each_child_of_node(np, child) {
+		if (of_device_is_compatible(child, "mediatek,scp-core")) {
+			found = 1;
+			of_node_put(child);
+			break;
+		}
+	}
 
-	of_node_put(child);
-	return of_node_name_eq(child, "cros-ec-rpmsg");
+	return found;
 }
 
 static int scp_cluster_init(struct platform_device *pdev, struct mtk_scp_of_cluster *scp_cluster)
 {
 	int ret;
 
-	ret = scp_is_single_core(pdev);
-	if (ret < 0)
-		return ret;
-
-	if (ret)
+	if (!scp_find_core_node(pdev))
 		ret = scp_add_single_core(pdev, scp_cluster);
 	else
 		ret = scp_add_multi_core(pdev, scp_cluster);