[PATCH v3 2/6] ARM: bcm2835 mbox: drop driver mode and probe on first request

Oleksij Rempel o.rempel at pengutronix.de
Thu Feb 3 02:45:48 PST 2022


Currently we have multiple driver depending on the bcm2835 mbox. Since
the probe dependency currently can't be solved properly we have
different issue depending with or without deep-probe.

To make it work with and without deep-probe, we need to init MBOX on
first request.

Signed-off-by: Oleksij Rempel <o.rempel at pengutronix.de>
---
 arch/arm/mach-bcm283x/mbox.c | 52 +++++++++++++++---------------------
 1 file changed, 22 insertions(+), 30 deletions(-)

diff --git a/arch/arm/mach-bcm283x/mbox.c b/arch/arm/mach-bcm283x/mbox.c
index 9839683d03..4b14afcfe4 100644
--- a/arch/arm/mach-bcm283x/mbox.c
+++ b/arch/arm/mach-bcm283x/mbox.c
@@ -13,6 +13,7 @@
 #include <dma.h>
 #include <init.h>
 #include <io.h>
+#include <of_address.h>
 
 #include <mach/mbox.h>
 
@@ -108,6 +109,21 @@ static void dump_buf(struct bcm2835_mbox_hdr *buffer)
 }
 #endif
 
+static int bcm2835_mbox_probe(void)
+{
+	struct device_node *mbox_node;
+
+	mbox_node = of_find_compatible_node(NULL, NULL, "brcm,bcm2835-mbox");
+	if (!mbox_node) {
+		pr_err("Missing mbox node\n");
+		return -ENOENT;
+	}
+
+	mbox_base = of_iomap(mbox_node, 0);
+
+	return 0;
+}
+
 int bcm2835_mbox_call_prop(u32 chan, struct bcm2835_mbox_hdr *buffer)
 {
 	int ret;
@@ -115,6 +131,12 @@ int bcm2835_mbox_call_prop(u32 chan, struct bcm2835_mbox_hdr *buffer)
 	struct bcm2835_mbox_tag_hdr *tag;
 	int tag_index;
 
+	if (!mbox_base) {
+		ret = bcm2835_mbox_probe();
+		if (ret)
+			return ret;
+	}
+
 	pr_debug("mbox: TX buffer\n");
 	dump_buf(buffer);
 
@@ -150,33 +172,3 @@ int bcm2835_mbox_call_prop(u32 chan, struct bcm2835_mbox_hdr *buffer)
 
 	return 0;
 }
-
-static int bcm2835_mbox_probe(struct device_d *dev)
-{
-	struct resource *iores;
-
-	iores = dev_request_mem_resource(dev, 0);
-	if (IS_ERR(iores)) {
-		dev_err(dev, "could not get memory region\n");
-		return PTR_ERR(iores);
-	}
-	mbox_base = IOMEM(iores->start);
-
-	return 0;
-}
-
-static __maybe_unused struct of_device_id bcm2835_mbox_dt_ids[] = {
-	{
-		.compatible = "brcm,bcm2835-mbox",
-	}, {
-		/* sentinel */
-	},
-};
-
-static struct driver_d bcm2835_mbox_driver = {
-	.name		= "bcm2835_mbox",
-	.of_compatible	= DRV_OF_COMPAT(bcm2835_mbox_dt_ids),
-	.probe		= bcm2835_mbox_probe,
-};
-
-core_platform_driver(bcm2835_mbox_driver);
-- 
2.30.2




More information about the barebox mailing list