From a5eb6e506296c76f571492752e807b18f3bf77f7 Mon Sep 17 00:00:00 2001 From: Michael Olbrich Date: Thu, 12 Oct 2017 12:26:58 +0200 Subject: ARM: vexpress: add fixup handler for 'virtio, mmio' devices Qemu adds 'virtio,mmio' nodes to the device tree. Before passing it to the bootloader or the Linux kernel. This fixup handler copies these nodes to the new device tree. Signed-off-by: Michael Olbrich Signed-off-by: Rouven Czerwinski Signed-off-by: Lucas Stach Signed-off-by: Sascha Hauer --- arch/arm/boards/vexpress/init.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'arch') diff --git a/arch/arm/boards/vexpress/init.c b/arch/arm/boards/vexpress/init.c index 1bbc8c3476..946385393f 100644 --- a/arch/arm/boards/vexpress/init.c +++ b/arch/arm/boards/vexpress/init.c @@ -45,3 +45,32 @@ static int vexpress_core_init(void) return 0; } postcore_initcall(vexpress_core_init); + +static int of_fixup_virtio_mmio(struct device_node *root, void *unused) +{ + struct device_node *barebox_root, *np, *parent; + + barebox_root = of_get_root_node(); + if (root == barebox_root) + return 0; + + for_each_compatible_node_from(np, barebox_root, NULL, "virtio,mmio") { + if (of_get_parent(np) == barebox_root) + parent = root; + else + parent = of_find_node_by_path_from(root, + of_get_parent(np)->full_name); + if (!parent) + return -EINVAL; + + of_copy_node(parent, np); + } + + return 0; +} + +static int of_register_virtio_mmio_fixup(void) +{ + return of_register_fixup(of_fixup_virtio_mmio, NULL); +} +late_initcall(of_register_virtio_mmio_fixup); -- cgit v1.2.3