summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2021-11-25 17:10:39 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2021-12-07 15:03:31 +0100
commitd1785c8a68e47900569ff18389426f53c841f38c (patch)
tree627d4560074ac10f1629df14d80cc51bcc9df6b2 /arch
parent307c140cb12e28cafe44b3225c4521d716a6ec02 (diff)
downloadbarebox-d1785c8a68e47900569ff18389426f53c841f38c.tar.gz
barebox-d1785c8a68e47900569ff18389426f53c841f38c.tar.xz
ARM: qemu: enable deep probe support
It's a bug to call barebox_register_of at pure_initcall level, because device tree probe may depend on other initialization done at pure_initcall. For example, if the QEMU-supplied Virt device tree had a model, barebox would attempt to register a new global variable before the global device is even initialized. With the move to deep probe we can just do overlay fixup in the board driver at safe postcore level. Fixes: ff8b098a4ad2 ("ARM: qemu: support for state & env via DT overlay") Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211125161042.3829996-5-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/boards/qemu-virt/board.c37
1 files changed, 7 insertions, 30 deletions
diff --git a/arch/arm/boards/qemu-virt/board.c b/arch/arm/boards/qemu-virt/board.c
index b2a3cb29ab..1333687918 100644
--- a/arch/arm/boards/qemu-virt/board.c
+++ b/arch/arm/boards/qemu-virt/board.c
@@ -6,8 +6,8 @@
#include <common.h>
#include <init.h>
#include <of.h>
+#include <deep-probe.h>
#include <asm/system_info.h>
-#include <asm/barebox-arm.h>
#ifdef CONFIG_64BIT
#define MACHINE "virt64"
@@ -17,38 +17,10 @@
extern char __dtb_overlay_of_flash_start[];
-static int replace_dtb(void) {
- struct device_node *overlay;
- void *fdt;
- struct device_node *root;
-
- fdt = barebox_arm_boot_dtb();
- if (fdt)
- pr_debug("using boarddata provided DTB\n");
-
- if (!fdt) {
- pr_debug("No DTB found\n");
- return 0;
- }
-
- root = of_unflatten_dtb(fdt, INT_MAX);
-
- if (!of_device_is_compatible(root, "linux,dummy-virt")) {
- of_delete_node(root);
- return 0;
- }
-
- overlay = of_unflatten_dtb(__dtb_overlay_of_flash_start, INT_MAX);
- of_overlay_apply_tree(root, overlay);
-
- return barebox_register_of(root);
-}
-
-pure_initcall(replace_dtb);
-
static int virt_probe(struct device_d *dev)
{
const char *hostname = MACHINE;
+ struct device_node *overlay;
if (cpu_is_cortex_a7())
hostname = "virt-a7";
@@ -58,6 +30,10 @@ static int virt_probe(struct device_d *dev)
barebox_set_model("ARM QEMU " MACHINE);
barebox_set_hostname(hostname);
+ overlay = of_unflatten_dtb(__dtb_overlay_of_flash_start, INT_MAX);
+ of_overlay_apply_tree(dev->device_node, overlay);
+ /* of_probe() will happen later at of_populate_initcall */
+
return 0;
}
@@ -65,6 +41,7 @@ static const struct of_device_id virt_of_match[] = {
{ .compatible = "linux,dummy-virt" },
{ /* Sentinel */},
};
+BAREBOX_DEEP_PROBE_ENABLE(virt_of_match);
static struct driver_d virt_board_driver = {
.name = "board-qemu-virt",