[PATCH 2/4] ARM64: qemu-virt64: migrate to generic DT image

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

 



Current qemu-virt64 barebox support doesn't look much like what's
offered on physical boards. It's not relocatable, lacks PBL and
doesn't use device tree. As qemu-system-aarch64 -M virt -kernel
already supplies an external device tree, we could just replace
all existing support with BOARD_ARM_GENERIC_DT, which builds a
barebox image that reuses an externally passed device tree.

The 32-bit ARM VIRT support has some board code for host name
setting and overlay applying to handle environment and state
on flash. We could do without that, given the new virtio-blk
support, but the code is already there, so reuse it and drop
all current virt64-specific board code.

As the barebox ELF image resulting from the build can no longer be
directly booted as before and only with -kernel, not -bios, rename
the Kconfig symbol, so existing users can notice this during build.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 Documentation/boards/aarch64-qemu-virt.rst    |  2 +-
 arch/arm/Kconfig                              | 19 ++++--
 arch/arm/Makefile                             |  1 -
 arch/arm/boards/Makefile                      |  3 +-
 arch/arm/boards/qemu-virt/board.c             | 10 +++-
 arch/arm/boards/qemu-virt64/Makefile          |  3 -
 .../qemu-virt64/defaultenv-qemu-virt64/config |  8 ---
 arch/arm/boards/qemu-virt64/init.c            | 59 -------------------
 arch/arm/boards/qemu-virt64/lowlevel.c        | 21 -------
 arch/arm/boards/qemu-virt64/lowlevel_init.S   | 12 ----
 arch/arm/configs/qemu_virt64_defconfig        |  6 +-
 arch/arm/mach-qemu/Kconfig                    | 18 ------
 arch/arm/mach-qemu/Makefile                   |  1 -
 arch/arm/mach-qemu/include/mach/debug_ll.h    | 24 --------
 arch/arm/mach-qemu/include/mach/devices.h     | 13 ----
 arch/arm/mach-qemu/virt_devices.c             | 30 ----------
 arch/arm/mach-vexpress/Kconfig                |  3 +-
 17 files changed, 30 insertions(+), 203 deletions(-)
 delete mode 100644 arch/arm/boards/qemu-virt64/Makefile
 delete mode 100644 arch/arm/boards/qemu-virt64/defaultenv-qemu-virt64/config
 delete mode 100644 arch/arm/boards/qemu-virt64/init.c
 delete mode 100644 arch/arm/boards/qemu-virt64/lowlevel.c
 delete mode 100644 arch/arm/boards/qemu-virt64/lowlevel_init.S
 delete mode 100644 arch/arm/mach-qemu/Kconfig
 delete mode 100644 arch/arm/mach-qemu/Makefile
 delete mode 100644 arch/arm/mach-qemu/include/mach/debug_ll.h
 delete mode 100644 arch/arm/mach-qemu/include/mach/devices.h
 delete mode 100644 arch/arm/mach-qemu/virt_devices.c

diff --git a/Documentation/boards/aarch64-qemu-virt.rst b/Documentation/boards/aarch64-qemu-virt.rst
index 5f6cd882d546..cadc4e5543c1 100644
--- a/Documentation/boards/aarch64-qemu-virt.rst
+++ b/Documentation/boards/aarch64-qemu-virt.rst
@@ -11,4 +11,4 @@ Usage::
 	$ qemu-system-aarch64 -m 2048M \
 		-cpu cortex-a57 -machine virt \
 		-display none -serial stdio \
-		-kernel ../barebox/barebox
+		-kernel ./images/barebox-dt-2nd.img
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index ab0bf030131c..24188d5c7186 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -277,9 +277,16 @@ config ARCH_ZYNQMP
 	select SYS_SUPPORTS_64BIT_KERNEL
 	select HAS_MACB
 
-config ARCH_QEMU
-	bool "ARM QEMU boards"
-	select HAS_DEBUG_LL
+config ARCH_ARM64_VIRT
+	bool "ARM64 QEMU Virt board"
+	select CPU_V8
+	select HAVE_PBL_MULTI_IMAGES
+	select OFDEVICE
+	select OFTREE
+	select RELOCATABLE
+	select SYS_SUPPORTS_64BIT_KERNEL
+	select ARM_AMBA
+	select BOARD_ARM_VIRT
 
 endchoice
 
@@ -307,9 +314,13 @@ source "arch/arm/mach-vexpress/Kconfig"
 source "arch/arm/mach-tegra/Kconfig"
 source "arch/arm/mach-uemd/Kconfig"
 source "arch/arm/mach-zynq/Kconfig"
-source "arch/arm/mach-qemu/Kconfig"
 source "arch/arm/mach-zynqmp/Kconfig"
 
+config BOARD_ARM_VIRT
+	bool
+	select BOARD_ARM_GENERIC_DT
+	select OF_OVERLAY
+
 config BOARD_ARM_GENERIC_DT
 	select LIBFDT
 	select ARM_AMBA
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 9dc0897e5833..ccfd244e17e6 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -106,7 +106,6 @@ machine-$(CONFIG_ARCH_TEGRA)		:= tegra
 machine-$(CONFIG_ARCH_UEMD)		:= uemd
 machine-$(CONFIG_ARCH_ZYNQ)		:= zynq
 machine-$(CONFIG_ARCH_ZYNQMP)		:= zynqmp
-machine-$(CONFIG_ARCH_QEMU)		:= qemu
 
 
 # Board directory name.  This list is sorted alphanumerically
diff --git a/arch/arm/boards/Makefile b/arch/arm/boards/Makefile
index b6ddbd8f6359..d4272e18a18b 100644
--- a/arch/arm/boards/Makefile
+++ b/arch/arm/boards/Makefile
@@ -164,8 +164,7 @@ obj-$(CONFIG_MACH_ZEDBOARD)			+= avnet-zedboard/
 obj-$(CONFIG_MACH_ZYLONITE)			+= zylonite/
 obj-$(CONFIG_MACH_VARISCITE_MX6)		+= variscite-mx6/
 obj-$(CONFIG_MACH_VSCOM_BALTOS)			+= vscom-baltos/
-obj-$(CONFIG_MACH_QEMU_VIRT64)			+= qemu-virt64/
-obj-$(CONFIG_MACH_VIRT)				+= qemu-virt/
+obj-$(CONFIG_BOARD_ARM_VIRT)			+= qemu-virt/
 obj-$(CONFIG_MACH_WARP7)			+= element14-warp7/
 obj-$(CONFIG_MACH_WEBASTO_CCBV2)		+= webasto-ccbv2/
 obj-$(CONFIG_MACH_VF610_TWR)			+= freescale-vf610-twr/
diff --git a/arch/arm/boards/qemu-virt/board.c b/arch/arm/boards/qemu-virt/board.c
index 9d8c90eb5b1d..3e2c00ca1763 100644
--- a/arch/arm/boards/qemu-virt/board.c
+++ b/arch/arm/boards/qemu-virt/board.c
@@ -9,6 +9,12 @@
 #include <asm/system_info.h>
 #include <asm/barebox-arm.h>
 
+#if CONFIG_64BIT
+#define MACHINE "virt64"
+#else
+#define MACHINE "virt"
+#endif
+
 extern char __dtb_overlay_of_flash_start[];
 
 static int replace_dtb(void) {
@@ -43,14 +49,14 @@ pure_initcall(replace_dtb);
 
 static int virt_probe(struct device_d *dev)
 {
-	char *hostname = "virt";
+	const char *hostname = MACHINE;
 
 	if (cpu_is_cortex_a7())
 		hostname = "virt-a7";
 	else if (cpu_is_cortex_a15())
 		hostname = "virt-a15";
 
-	barebox_set_model("ARM QEMU virt");
+	barebox_set_model("ARM QEMU " MACHINE);
 	barebox_set_hostname(hostname);
 
 	return 0;
diff --git a/arch/arm/boards/qemu-virt64/Makefile b/arch/arm/boards/qemu-virt64/Makefile
deleted file mode 100644
index b394dde0a1fe..000000000000
--- a/arch/arm/boards/qemu-virt64/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-obj-y += init.o
-lwl-y += lowlevel.o lowlevel_init.o
-bbenv-$(CONFIG_DEFAULT_ENVIRONMENT_GENERIC) += defaultenv-qemu-virt64
diff --git a/arch/arm/boards/qemu-virt64/defaultenv-qemu-virt64/config b/arch/arm/boards/qemu-virt64/defaultenv-qemu-virt64/config
deleted file mode 100644
index 781dbfefa676..000000000000
--- a/arch/arm/boards/qemu-virt64/defaultenv-qemu-virt64/config
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-autoboot_timeout=3
-
-bootargs="console=ttyAMA0,115200"
-
-# set a fancy prompt (if support is compiled in)
-PS1="\e[1;31m[barebox@\h]:\w\e[0m\n# "
diff --git a/arch/arm/boards/qemu-virt64/init.c b/arch/arm/boards/qemu-virt64/init.c
deleted file mode 100644
index c2e7af77bba1..000000000000
--- a/arch/arm/boards/qemu-virt64/init.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2016 Raphaël Poggi <poggi.raph@xxxxxxxxx>
- *
- * GPLv2 only
- */
-
-#include <common.h>
-#include <init.h>
-#include <asm/armlinux.h>
-#include <asm/system_info.h>
-#include <asm/pgtable64.h>
-#include <mach/devices.h>
-#include <environment.h>
-#include <linux/sizes.h>
-#include <io.h>
-#include <envfs.h>
-#include <globalvar.h>
-#include <asm/mmu.h>
-
-static int virt_mem_init(void)
-{
-	virt_add_ddram(SZ_2G);
-
-	return 0;
-}
-mem_initcall(virt_mem_init);
-
-static int virt_env_init(void)
-{
-	add_cfi_flash_device(0, 0x00000000, SZ_128M, 0);
-
-	devfs_add_partition("nor0", 0x00000, 0x40000, DEVFS_PARTITION_FIXED, "self0");
-	devfs_add_partition("nor0", 0x40000, 0x20000, DEVFS_PARTITION_FIXED, "env0");
-
-	if (IS_ENABLED(CONFIG_DEFAULT_ENVIRONMENT_GENERIC))
-		defaultenv_append_directory(defaultenv_qemu_virt64);
-
-	return 0;
-}
-device_initcall(virt_env_init);
-
-static int virt_console_init(void)
-{
-	virt_register_uart(0);
-
-	return 0;
-}
-console_initcall(virt_console_init);
-
-static int virt_core_init(void)
-{
-	char *hostname = "virt64";
-
-	barebox_set_model("ARM QEMU virt64");
-	barebox_set_hostname(hostname);
-
-	return 0;
-}
-postcore_initcall(virt_core_init);
diff --git a/arch/arm/boards/qemu-virt64/lowlevel.c b/arch/arm/boards/qemu-virt64/lowlevel.c
deleted file mode 100644
index fcb052369abc..000000000000
--- a/arch/arm/boards/qemu-virt64/lowlevel.c
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD <plagnio@xxxxxxxxxxxx>
- *
- * GPLv2 only
- */
-
-#include <common.h>
-#include <linux/sizes.h>
-#include <asm/barebox-arm-head.h>
-#include <asm/barebox-arm.h>
-#include <asm/system_info.h>
-
-void qemu_virt64_start(uint32_t, uint32_t, uint32_t);
-
-void noinline qemu_virt64_start(uint32_t r0, uint32_t r1, uint32_t r2)
-{
-	arm_cpu_lowlevel_init();
-	arm_setup_stack(0x40000000 + SZ_2G - SZ_16K);
-
-	barebox_arm_entry(0x40000000, SZ_2G, NULL);
-}
diff --git a/arch/arm/boards/qemu-virt64/lowlevel_init.S b/arch/arm/boards/qemu-virt64/lowlevel_init.S
deleted file mode 100644
index 1967fadb6cbe..000000000000
--- a/arch/arm/boards/qemu-virt64/lowlevel_init.S
+++ /dev/null
@@ -1,12 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-#include <linux/linkage.h>
-#include <asm/barebox-arm64.h>
-
-/* The DRAM is already setup */
-#define STACK_TOP 0x80000000
-
-ENTRY_PROC(barebox_arm_reset_vector)
-	mov x0, #STACK_TOP
-	mov sp, x0
-	b qemu_virt64_start
-ENTRY_PROC_END(barebox_arm_reset_vector)
diff --git a/arch/arm/configs/qemu_virt64_defconfig b/arch/arm/configs/qemu_virt64_defconfig
index 6f9bb9591c20..f138dc648de8 100644
--- a/arch/arm/configs/qemu_virt64_defconfig
+++ b/arch/arm/configs/qemu_virt64_defconfig
@@ -1,5 +1,4 @@
-CONFIG_TEXT_BASE=0x41000000
-CONFIG_ARCH_QEMU=y
+CONFIG_ARCH_ARM64_VIRT=y
 CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
 CONFIG_MMU=y
 # CONFIG_MMU_EARLY is not set
@@ -32,10 +31,13 @@ CONFIG_CMD_PASSWD=y
 CONFIG_CMD_READLINE=y
 CONFIG_CMD_TIMEOUT=y
 CONFIG_CMD_OFTREE=y
+CONFIG_OF_BAREBOX_DRIVERS=y
+CONFIG_OF_BAREBOX_ENV_IN_FS=y
 CONFIG_SERIAL_AMBA_PL011=y
 # CONFIG_SPI is not set
 CONFIG_MTD=y
 CONFIG_DRIVER_CFI=y
 CONFIG_CFI_BUFFER_WRITE=y
+# CONFIG_PINCTRL is not set
 CONFIG_DIGEST_SHA1_GENERIC=y
 CONFIG_DIGEST_SHA256_GENERIC=y
diff --git a/arch/arm/mach-qemu/Kconfig b/arch/arm/mach-qemu/Kconfig
deleted file mode 100644
index d30bae4c6fcc..000000000000
--- a/arch/arm/mach-qemu/Kconfig
+++ /dev/null
@@ -1,18 +0,0 @@
-if ARCH_QEMU
-
-config ARCH_TEXT_BASE
-	hex
-	default 0x40000000
-
-choice
-	prompt "ARM Board type"
-
-config MACH_QEMU_VIRT64
-	bool "QEMU arm64 virt machine"
-	select CPU_V8
-	select SYS_SUPPORTS_64BIT_KERNEL
-	select ARM_AMBA
-	select HAVE_CONFIGURABLE_MEMORY_LAYOUT
-
-endchoice
-endif
diff --git a/arch/arm/mach-qemu/Makefile b/arch/arm/mach-qemu/Makefile
deleted file mode 100644
index ece277ce0e20..000000000000
--- a/arch/arm/mach-qemu/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-obj-$(CONFIG_MACH_QEMU_VIRT64) += virt_devices.o
diff --git a/arch/arm/mach-qemu/include/mach/debug_ll.h b/arch/arm/mach-qemu/include/mach/debug_ll.h
deleted file mode 100644
index d59f68ea1973..000000000000
--- a/arch/arm/mach-qemu/include/mach/debug_ll.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright 2013 Jean-Christophe PLAGNIOL-VILLARD <plagniol@xxxxxxxxxxxx>
- *
- * GPLv2 only
- */
-
-#ifndef __MACH_DEBUG_LL_H__
-#define   __MACH_DEBUG_LL_H__
-
-#include <linux/amba/serial.h>
-#include <io.h>
-
-#define DEBUG_LL_PHYS_BASE		0x10000000
-#define DEBUG_LL_PHYS_BASE_RS1		0x1c000000
-
-#ifdef MP
-#define DEBUG_LL_UART_ADDR DEBUG_LL_PHYS_BASE
-#else
-#define DEBUG_LL_UART_ADDR DEBUG_LL_PHYS_BASE_RS1
-#endif
-
-#include <debug_ll/pl011.h>
-
-#endif
diff --git a/arch/arm/mach-qemu/include/mach/devices.h b/arch/arm/mach-qemu/include/mach/devices.h
deleted file mode 100644
index 9872c61b49ff..000000000000
--- a/arch/arm/mach-qemu/include/mach/devices.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * Copyright (C) 2016 Raphaël Poggi <poggi.raph@xxxxxxxxx>
- *
- * GPLv2 only
- */
-
-#ifndef __ASM_ARCH_DEVICES_H__
-#define __ASM_ARCH_DEVICES_H__
-
-void virt_add_ddram(u32 size);
-void virt_register_uart(unsigned id);
-
-#endif /* __ASM_ARCH_DEVICES_H__ */
diff --git a/arch/arm/mach-qemu/virt_devices.c b/arch/arm/mach-qemu/virt_devices.c
deleted file mode 100644
index 999f463125c6..000000000000
--- a/arch/arm/mach-qemu/virt_devices.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2016 Raphaël Poggi <poggi.raph@xxxxxxxxx>
- *
- * GPLv2 only
- */
-
-#include <common.h>
-#include <linux/amba/bus.h>
-#include <asm/memory.h>
-#include <mach/devices.h>
-#include <linux/ioport.h>
-
-void virt_add_ddram(u32 size)
-{
-	arm_add_mem_device("ram0", 0x40000000, size);
-}
-
-void virt_register_uart(unsigned id)
-{
-	resource_size_t start;
-
-	switch (id) {
-	case 0:
-		start = 0x09000000;
-		break;
-	default:
-		return;
-	}
-	amba_apb_device_add(NULL, "uart-pl011", id, start, 4096, NULL, 0);
-}
diff --git a/arch/arm/mach-vexpress/Kconfig b/arch/arm/mach-vexpress/Kconfig
index 557c9653f425..b72684caa722 100644
--- a/arch/arm/mach-vexpress/Kconfig
+++ b/arch/arm/mach-vexpress/Kconfig
@@ -9,8 +9,7 @@ config MACH_VEXPRESS
 
 config MACH_VIRT
 	bool "QEMU virt"
+	select BOARD_ARM_VIRT
 	select ARM_PSCI_CLIENT
-	select BOARD_ARM_GENERIC_DT
-	select OF_OVERLAY
 
 endif
-- 
2.29.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