mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] dma: of_fixups: add fallbacks if /soc doesn't exist
@ 2024-05-03 10:29 Ahmad Fatoum
  2024-05-06  6:27 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2024-05-03 10:29 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

The fixup was written for Layerscape LS1046A. Enabling it on i.MX8MP
throws an initcall error, because the SoC node is called /soc@0.

Improve the situation by falling back to either /soc@0 or just plain /.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/dma/of_fixups.c | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/drivers/dma/of_fixups.c b/drivers/dma/of_fixups.c
index 668313bbfb57..084ab94cc71c 100644
--- a/drivers/dma/of_fixups.c
+++ b/drivers/dma/of_fixups.c
@@ -6,15 +6,22 @@
 
 static int of_dma_coherent_fixup(struct device_node *root, void *data)
 {
-	struct device_node *soc;
-	enum dev_dma_coherence coherency = (enum dev_dma_coherence)(uintptr_t)data;
+	struct device_node *soc_bb = data, *soc_kernel;
+	enum dev_dma_coherence coherency;
 
-	soc = of_find_node_by_path_from(root, "/soc");
-	if (!soc)
+	if (of_property_read_bool(soc_bb, "dma-coherent"))
+		coherency = DEV_DMA_COHERENT;
+	else if (of_property_read_bool(soc_bb, "dma-noncoherent"))
+		coherency = DEV_DMA_NON_COHERENT;
+	else
+		coherency = DEV_DMA_COHERENCE_DEFAULT;
+
+	soc_kernel = of_find_node_by_path_from(root, soc_bb->full_name);
+	if (!soc_kernel)
 		return -ENOENT;
 
-	of_property_write_bool(soc, "dma-noncoherent", coherency == DEV_DMA_NON_COHERENT);
-	of_property_write_bool(soc, "dma-coherent", coherency == DEV_DMA_COHERENT);
+	of_property_write_bool(soc_kernel, "dma-noncoherent", coherency == DEV_DMA_NON_COHERENT);
+	of_property_write_bool(soc_kernel, "dma-coherent", coherency == DEV_DMA_COHERENT);
 
 	return 0;
 }
@@ -22,19 +29,15 @@ static int of_dma_coherent_fixup(struct device_node *root, void *data)
 static int of_dma_coherent_fixup_register(void)
 {
 	struct device_node *soc;
-	enum dev_dma_coherence soc_dma_coherency;
 
 	soc = of_find_node_by_path("/soc");
+	if (!soc)
+		soc = of_find_node_by_path("/soc@0");
+	if (!soc)
+		soc = of_find_node_by_path("/");
 	if (!soc)
 		return -ENOENT;
 
-	if (of_property_read_bool(soc, "dma-coherent"))
-		soc_dma_coherency = DEV_DMA_COHERENT;
-	else if (of_property_read_bool(soc, "dma-noncoherent"))
-		soc_dma_coherency = DEV_DMA_NON_COHERENT;
-	else
-		soc_dma_coherency = DEV_DMA_COHERENCE_DEFAULT;
-
-	return of_register_fixup(of_dma_coherent_fixup, (void *)(uintptr_t)soc_dma_coherency);
+	return of_register_fixup(of_dma_coherent_fixup, soc);
 }
 coredevice_initcall(of_dma_coherent_fixup_register);
-- 
2.39.2




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-05-06  6:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-03 10:29 [PATCH] dma: of_fixups: add fallbacks if /soc doesn't exist Ahmad Fatoum
2024-05-06  6:27 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox