diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2021-11-25 17:10:41 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-12-07 15:03:31 +0100 |
commit | 4efddf4157111d53c6ae10fa30f68748352e638a (patch) | |
tree | 17ce439c3335d0f2fad24d2cc2739cae9eaf6aaa | |
parent | 8f47e2ef573f61539b5994b6c52e0c953774a85c (diff) | |
download | barebox-4efddf4157111d53c6ae10fa30f68748352e638a.tar.gz barebox-4efddf4157111d53c6ae10fa30f68748352e638a.tar.xz |
common: boards: qemu-virt: genericize to support non-ARM architectures
In preparation for extending support to RISC-V, sprinkle around some
preprocessor directives.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20211125161042.3829996-7-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | common/boards/qemu-virt/board.c | 25 | ||||
-rw-r--r-- | 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 1333687918..f10608e303 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 e00dc5d7e2..ed6ad0072b 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 { |