mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Oleksij Rempel <o.rempel@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Oleksij Rempel <o.rempel@pengutronix.de>
Subject: [PATCH v3 2/6] ARM: bcm2835 mbox: drop driver mode and probe on first request
Date: Thu,  3 Feb 2022 11:45:48 +0100	[thread overview]
Message-ID: <20220203104552.3158202-3-o.rempel@pengutronix.de> (raw)
In-Reply-To: <20220203104552.3158202-1-o.rempel@pengutronix.de>

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@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


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


  parent reply	other threads:[~2022-02-03 10:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-03 10:45 [PATCH v3 0/6] refactore rpi board code Oleksij Rempel
2022-02-03 10:45 ` [PATCH v3 1/6] ARM: rpi: convert board code to a driver Oleksij Rempel
2022-02-03 10:45 ` Oleksij Rempel [this message]
2022-02-03 10:45 ` [PATCH v3 3/6] ARM: rpi: move clk support to a separate driver Oleksij Rempel
2022-02-03 10:45 ` [PATCH v3 4/6] ARM: rpi: validate devicetree compatible instead of changing model name Oleksij Rempel
2022-02-03 10:45 ` [PATCH v3 5/6] ARM: rpi: set host name based on DT compatible Oleksij Rempel
2022-02-03 10:45 ` [PATCH v3 6/6] ARM: rpi: enable deep-probe support Oleksij Rempel
2022-02-03 12:37   ` Ahmad Fatoum
2022-02-07  8:05 ` [PATCH v3 0/6] refactore rpi board code Sascha Hauer

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=20220203104552.3158202-3-o.rempel@pengutronix.de \
    --to=o.rempel@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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