summaryrefslogtreecommitdiff
path: root/common/boards
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2021-11-25 17:10:40 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2021-12-07 15:03:31 +0100
commit8f47e2ef573f61539b5994b6c52e0c953774a85c (patch)
tree47f871219604c8cb4c0bc2b40969a361c34daae7 /common/boards
parentd1785c8a68e47900569ff18389426f53c841f38c (diff)
downloadbarebox-8f47e2ef573f61539b5994b6c52e0c953774a85c.tar.gz
ARM: qemu: move board code to central location
The state/environment overlay applied on top of QEMU is applicable to other virt platforms as well, like RISC-V. In preparation for sharing code across architectures, add a new common/boards and move the board code there. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211125161042.3829996-6-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/boards')
-rw-r--r--common/boards/Kconfig4
-rw-r--r--common/boards/Makefile3
-rw-r--r--common/boards/qemu-virt/Makefile4
-rw-r--r--common/boards/qemu-virt/board.c52
-rw-r--r--common/boards/qemu-virt/overlay-of-flash.dts97
5 files changed, 160 insertions, 0 deletions
diff --git a/common/boards/Kconfig b/common/boards/Kconfig
new file mode 100644
index 0000000000..e27273b767
--- /dev/null
+++ b/common/boards/Kconfig
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+config BOARD_QEMU_VIRT
+ bool
diff --git a/common/boards/Makefile b/common/boards/Makefile
new file mode 100644
index 0000000000..5b4e429c13
--- /dev/null
+++ b/common/boards/Makefile
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+obj-$(CONFIG_BOARD_QEMU_VIRT) += qemu-virt/
diff --git a/common/boards/qemu-virt/Makefile b/common/boards/qemu-virt/Makefile
new file mode 100644
index 0000000000..f10d391385
--- /dev/null
+++ b/common/boards/qemu-virt/Makefile
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+obj-y += board.o
+obj-y += overlay-of-flash.dtb.o
diff --git a/common/boards/qemu-virt/board.c b/common/boards/qemu-virt/board.c
new file mode 100644
index 0000000000..1333687918
--- /dev/null
+++ b/common/boards/qemu-virt/board.c
@@ -0,0 +1,52 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2020 Pengutronix e.K.
+ *
+ */
+#include <common.h>
+#include <init.h>
+#include <of.h>
+#include <deep-probe.h>
+#include <asm/system_info.h>
+
+#ifdef CONFIG_64BIT
+#define MACHINE "virt64"
+#else
+#define MACHINE "virt"
+#endif
+
+extern char __dtb_overlay_of_flash_start[];
+
+static int virt_probe(struct device_d *dev)
+{
+ const char *hostname = MACHINE;
+ struct device_node *overlay;
+
+ if (cpu_is_cortex_a7())
+ hostname = "virt-a7";
+ else if (cpu_is_cortex_a15())
+ hostname = "virt-a15";
+
+ barebox_set_model("ARM QEMU " MACHINE);
+ barebox_set_hostname(hostname);
+
+ overlay = of_unflatten_dtb(__dtb_overlay_of_flash_start, INT_MAX);
+ of_overlay_apply_tree(dev->device_node, overlay);
+ /* of_probe() will happen later at of_populate_initcall */
+
+ return 0;
+}
+
+static const struct of_device_id virt_of_match[] = {
+ { .compatible = "linux,dummy-virt" },
+ { /* Sentinel */},
+};
+BAREBOX_DEEP_PROBE_ENABLE(virt_of_match);
+
+static struct driver_d virt_board_driver = {
+ .name = "board-qemu-virt",
+ .probe = virt_probe,
+ .of_compatible = virt_of_match,
+};
+
+postcore_platform_driver(virt_board_driver);
diff --git a/common/boards/qemu-virt/overlay-of-flash.dts b/common/boards/qemu-virt/overlay-of-flash.dts
new file mode 100644
index 0000000000..e00dc5d7e2
--- /dev/null
+++ b/common/boards/qemu-virt/overlay-of-flash.dts
@@ -0,0 +1,97 @@
+/dts-v1/;
+/plugin/;
+/ {
+ fragment@0 {
+ target-path = "/flash@0";
+ __overlay__ {
+ partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ partition@0 {
+ label = "initramfs";
+ reg = <0x0 0x3c00000>;
+ };
+
+ environment_flash: partition@3c00000 {
+ label = "barebox-environment";
+ reg = <0x3c00000 0x200000>;
+ };
+
+ backend_state_flash: partition@3e00000 {
+ label = "barebox-state";
+ reg = <0x3e00000 0x200000>;
+ };
+ };
+ };
+ };
+ fragment@1 {
+ target-path="/";
+ __overlay__ {
+ chosen {
+ environment {
+ compatible = "barebox,environment";
+ device-path = "/flash@0/partitions/partition@3c00000";
+ };
+ };
+ aliases {
+ state = "/state";
+ };
+
+ state {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ compatible = "barebox,state";
+ magic = <0x290cf8c6>;
+ backend-type = "raw";
+ backend = < &backend_state_flash >;
+ backend-stridesize = <0x200>;
+
+ bootstate {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ system0 {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ remaining_attempts@0 {
+ reg = <0x0 0x4>;
+ type = "uint32";
+ default = <3>;
+ };
+
+ priority@4 {
+ reg = <0x4 0x4>;
+ type = "uint32";
+ default = <20>;
+ };
+ };
+
+ system1 {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ remaining_attempts@8 {
+ reg = <0x8 0x4>;
+ type = "uint32";
+ default = <3>;
+ };
+
+ priority@c {
+ reg = <0xc 0x4>;
+ type = "uint32";
+ default = <21>;
+ };
+ };
+
+ last_chosen@10 {
+ reg = <0x10 0x4>;
+ type = "uint32";
+ };
+ };
+ };
+ };
+ };
+};