summaryrefslogtreecommitdiffstats
path: root/arch/arm/boards/qemu-virt/board.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/boards/qemu-virt/board.c')
-rw-r--r--arch/arm/boards/qemu-virt/board.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/arch/arm/boards/qemu-virt/board.c b/arch/arm/boards/qemu-virt/board.c
index 3aeea1a017..9d8c90eb5b 100644
--- a/arch/arm/boards/qemu-virt/board.c
+++ b/arch/arm/boards/qemu-virt/board.c
@@ -5,7 +5,41 @@
*/
#include <common.h>
#include <init.h>
+#include <of.h>
#include <asm/system_info.h>
+#include <asm/barebox-arm.h>
+
+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);
+
+ if (!of_device_is_compatible(root, "linux,dummy-virt")) {
+ of_delete_node(root);
+ return 0;
+ }
+
+ overlay = of_unflatten_dtb(__dtb_overlay_of_flash_start);
+ of_overlay_apply_tree(root, overlay);
+ barebox_register_of(root);
+
+ return 0;
+}
+
+pure_initcall(replace_dtb);
static int virt_probe(struct device_d *dev)
{