summaryrefslogtreecommitdiffstats
path: root/configs/platform-v7a/patches/barebox-2017.08.0/0012-ARM-vexpress-add-fixup-handler-for-virtio-mmio-devic.patch
blob: ff407c922d8594425d5efbf85025dcafa2289268 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
From: Michael Olbrich <m.olbrich@pengutronix.de>
Date: Tue, 13 Sep 2016 21:20:10 +0200
Subject: [PATCH] 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.

v2:
- move from general to platform specific init

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
---
 arch/arm/boards/vexpress/init.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/arch/arm/boards/vexpress/init.c b/arch/arm/boards/vexpress/init.c
index 1bbc8c347638..946385393f44 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);