mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 6/7] common: boards: qemu-virt: genericize to support non-ARM architectures
Date: Thu, 25 Nov 2021 17:10:41 +0100	[thread overview]
Message-ID: <20211125161042.3829996-7-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20211125161042.3829996-1-a.fatoum@pengutronix.de>

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

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


  parent reply	other threads:[~2021-11-25 16:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-25 16:10 [PATCH 0/7] ARM/RISC-V: qemu-virt: share common cleaned up state/env support Ahmad Fatoum
2021-11-25 16:10 ` [PATCH 1/7] state: mark state init errors specially Ahmad Fatoum
2021-11-25 16:10 ` [PATCH 2/7] state: make first boot less verbose Ahmad Fatoum
2021-11-30 10:47   ` Sascha Hauer
2021-11-30 13:52     ` Ahmad Fatoum
2021-11-25 16:10 ` [PATCH 3/7] of: overlay: rescan aliases calling of_overlay_apply_tree on live tree Ahmad Fatoum
2021-11-25 16:10 ` [PATCH 4/7] ARM: qemu: enable deep probe support Ahmad Fatoum
2021-11-25 16:10 ` [PATCH 5/7] ARM: qemu: move board code to central location Ahmad Fatoum
2021-11-25 16:10 ` Ahmad Fatoum [this message]
2021-11-25 16:10 ` [PATCH 7/7] RISC-V: qemu-virt: add overlay for environment and state Ahmad Fatoum
2021-12-07 14:04 ` [PATCH 0/7] ARM/RISC-V: qemu-virt: share common cleaned up state/env support Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211125161042.3829996-7-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox