[PATCH 6/7] common: boards: qemu-virt: genericize to support non-ARM architectures

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In preparation for extending support to RISC-V, sprinkle around some
preprocessor directives.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 common/boards/qemu-virt/board.c              | 25 ++++++++++++++++----
 common/boards/qemu-virt/overlay-of-flash.dts |  8 +++++--
 2 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/common/boards/qemu-virt/board.c b/common/boards/qemu-virt/board.c
index 1333687918e1..f10608e30343 100644
--- a/common/boards/qemu-virt/board.c
+++ b/common/boards/qemu-virt/board.c
@@ -7,7 +7,6 @@
 #include <init.h>
 #include <of.h>
 #include <deep-probe.h>
-#include <asm/system_info.h>
 
 #ifdef CONFIG_64BIT
 #define MACHINE "virt64"
@@ -15,12 +14,12 @@
 #define MACHINE "virt"
 #endif
 
-extern char __dtb_overlay_of_flash_start[];
+#ifdef CONFIG_ARM
+#include <asm/system_info.h>
 
-static int virt_probe(struct device_d *dev)
+static inline void arm_virt_init(void)
 {
 	const char *hostname = MACHINE;
-	struct device_node *overlay;
 
 	if (cpu_is_cortex_a7())
 		hostname = "virt-a7";
@@ -29,6 +28,22 @@ static int virt_probe(struct device_d *dev)
 
 	barebox_set_model("ARM QEMU " MACHINE);
 	barebox_set_hostname(hostname);
+}
+
+#else
+static inline void arm_virt_init(void) {}
+#endif
+
+extern char __dtb_overlay_of_flash_start[];
+
+static int virt_probe(struct device_d *dev)
+{
+	struct device_node *overlay;
+	void (*init)(void);
+
+	init = device_get_match_data(dev);
+	if (init)
+		init();
 
 	overlay = of_unflatten_dtb(__dtb_overlay_of_flash_start, INT_MAX);
 	of_overlay_apply_tree(dev->device_node, overlay);
@@ -38,7 +53,7 @@ static int virt_probe(struct device_d *dev)
 }
 
 static const struct of_device_id virt_of_match[] = {
-	{ .compatible = "linux,dummy-virt" },
+	{ .compatible = "linux,dummy-virt", .data = arm_virt_init },
 	{ /* Sentinel */},
 };
 BAREBOX_DEEP_PROBE_ENABLE(virt_of_match);
diff --git a/common/boards/qemu-virt/overlay-of-flash.dts b/common/boards/qemu-virt/overlay-of-flash.dts
index e00dc5d7e233..ed6ad0072b55 100644
--- a/common/boards/qemu-virt/overlay-of-flash.dts
+++ b/common/boards/qemu-virt/overlay-of-flash.dts
@@ -1,8 +1,12 @@
 /dts-v1/;
 /plugin/;
+
+#define PARTS_TARGET_PATH	"/flash@0"
+#define ENV_DEVICE_PATH		"/flash@0/partitions/partition@3c00000"
+
 / {
 	fragment@0 {
-		target-path = "/flash@0";
+		target-path = PARTS_TARGET_PATH;
 		__overlay__ {
 			partitions {
 				compatible = "fixed-partitions";
@@ -32,7 +36,7 @@
 			chosen {
 				environment {
 					compatible = "barebox,environment";
-					device-path = "/flash@0/partitions/partition@3c00000";
+					device-path = ENV_DEVICE_PATH;
 				};
 			};
 			aliases {
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux