summaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-bcm283x/mbox.c
diff options
context:
space:
mode:
authorOleksij Rempel <o.rempel@pengutronix.de>2022-02-03 11:45:48 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2022-02-07 09:05:12 +0100
commit11b8418401f8e747092b424e834f9d7d20ba69e1 (patch)
tree41b2fd68d616f9dbabfb72797bfdc7a4a3e23547 /arch/arm/mach-bcm283x/mbox.c
parent7acb9c143cd173463e7c7e8dc3ae9c58b6060965 (diff)
downloadbarebox-11b8418401f8e747092b424e834f9d7d20ba69e1.tar.gz
barebox-11b8418401f8e747092b424e834f9d7d20ba69e1.tar.xz
ARM: bcm2835 mbox: drop driver mode and probe on first request
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> Link: https://lore.barebox.org/20220203104552.3158202-3-o.rempel@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/mach-bcm283x/mbox.c')
-rw-r--r--arch/arm/mach-bcm283x/mbox.c52
1 files 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);