
On Sun, May 19, 2024 at 1:54 PM Jiaxun Yang jiaxun.yang@flygoat.com wrote:
Introduce the new board, define every bits.
Signed-off-by: Jiaxun Yang jiaxun.yang@flygoat.com
arch/xtensa/Kconfig | 5 +++ board/emulation/qemu-xtensa/Kconfig | 41 +++++++++++++++++++++ board/emulation/qemu-xtensa/MAINTAINERS | 7 ++++ board/emulation/qemu-xtensa/Makefile | 5 +++ board/emulation/qemu-xtensa/qemu-xtensa.c | 60 +++++++++++++++++++++++++++++++ configs/qemu-xtensa-dc232b_defconfig | 32 +++++++++++++++++ include/configs/qemu-xtensa.h | 34 ++++++++++++++++++ 7 files changed, 184 insertions(+)
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig index 4afd56bca095..70eebb4bd22f 100644 --- a/arch/xtensa/Kconfig +++ b/arch/xtensa/Kconfig @@ -15,6 +15,10 @@ config TARGET_XTFPGA bool "Support XTFPGA" select BOARD_POSTCLK_INIT
+config TARGET_QEMU_XTENSA
bool "Support QEMU Xtensa Virt Board"
select BOARD_LATE_INIT
endchoice
config SYS_ICACHE_OFF @@ -69,5 +73,6 @@ config XTENSA_SIMCALL_GDBIO endchoice
source "board/cadence/xtfpga/Kconfig" +source "board/emulation/qemu-xtensa/Kconfig"
endmenu diff --git a/board/emulation/qemu-xtensa/Kconfig b/board/emulation/qemu-xtensa/Kconfig new file mode 100644 index 000000000000..df9142af0875 --- /dev/null +++ b/board/emulation/qemu-xtensa/Kconfig @@ -0,0 +1,41 @@ +if TARGET_QEMU_XTENSA
+config SYS_BOARD
default "qemu-xtensa"
+config SYS_VENDOR
default "emulation"
+config SYS_CONFIG_NAME
default "qemu-xtensa"
+config TEXT_BASE
default 0xfe000000
+config BOARD_SPECIFIC_OPTIONS # dummy
def_bool y
select BOARD_EARLY_INIT_F
select DM
select CPU
select CPU_XTENSA
select CLK
select DM_SERIAL
select XTENSA_SEMIHOSTING
select XTENSA_SEMIHOSTING_SERIAL
imply BLK
imply VIRTIO
imply VIRTIO_PCI
imply VIRTIO_NET
imply VIRTIO_BLK
imply E1000
imply PCI
imply PCI_INIT_R
imply NVME_PCI
imply PCIE_ECAM_GENERIC
imply SCSI
imply REMAKE_ELF
select OF_CONTROL
select OF_UPSTREAM
imply CMD_DM
+endif diff --git a/board/emulation/qemu-xtensa/MAINTAINERS b/board/emulation/qemu-xtensa/MAINTAINERS new file mode 100644 index 000000000000..851ef596f611 --- /dev/null +++ b/board/emulation/qemu-xtensa/MAINTAINERS @@ -0,0 +1,7 @@ +QEMU XTENSA 'VIRT' BOARD +M: Jiaxun Yang jiaxun.yang@flygoat.com +S: Maintained +F: board/emulation/qemu-xtensa/ +F: board/emulation/common/ +F: include/configs/qemu-riscv.h
This must be qemu-xtensa.h, right?
+F: configs/qemu-xtensa-dc232b_defconfig diff --git a/board/emulation/qemu-xtensa/Makefile b/board/emulation/qemu-xtensa/Makefile new file mode 100644 index 000000000000..0f33a65f6c6b --- /dev/null +++ b/board/emulation/qemu-xtensa/Makefile @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2024, Jiaxun Yang jiaxun.yang@flygoat.com
+obj-y += qemu-xtensa.o diff --git a/board/emulation/qemu-xtensa/qemu-xtensa.c b/board/emulation/qemu-xtensa/qemu-xtensa.c new file mode 100644 index 000000000000..0ca83341c25c --- /dev/null +++ b/board/emulation/qemu-xtensa/qemu-xtensa.c @@ -0,0 +1,60 @@ +// SPDX-License-Identifier: GPL-2.0+ +/*
- Copyright (C) 2018, Bin Meng bmeng.cn@gmail.com
- */
+#include <dm.h> +#include <cpu.h> +#include <log.h> +#include <init.h> +#include <usb.h> +#include <virtio_types.h> +#include <virtio.h>
+DECLARE_GLOBAL_DATA_PTR;
+int board_init(void) +{
return 0;
+}
+unsigned long get_board_sys_clk(void) +{
return gd->cpu_clk ? gd->cpu_clk : 40000000;
+}
+int dram_init(void) +{
return fdtdec_setup_mem_size_base();
+}
+int board_early_init_f(void) +{
struct cpu_plat *cpu_plat;
struct udevice *cpu = cpu_get_current_dev();
if (!cpu)
return -ENODEV;
cpu_plat = dev_get_parent_plat(cpu);
if (!cpu_plat)
return -ENODEV;
gd->cpu_clk = cpu_plat->timebase_freq;
return 0;
+}
+int board_late_init(void) +{
/* start usb so that usb keyboard can be used as input device */
if (CONFIG_IS_ENABLED(USB_KEYBOARD))
usb_init();
/*
* Make sure virtio bus is enumerated so that peripherals
* on the virtio bus can be discovered by their drivers
*/
virtio_init();
return 0;
+} diff --git a/configs/qemu-xtensa-dc232b_defconfig b/configs/qemu-xtensa-dc232b_defconfig new file mode 100644 index 000000000000..12d5ca9399ae --- /dev/null +++ b/configs/qemu-xtensa-dc232b_defconfig @@ -0,0 +1,32 @@ +CONFIG_XTENSA=y +CONFIG_SYS_CPU="dc232b" +CONFIG_SYS_MALLOC_LEN=0x40000 +CONFIG_SYS_MALLOC_F_LEN=0x400 +CONFIG_ENV_SIZE=0x20000 +CONFIG_DEFAULT_DEVICE_TREE="virt" +CONFIG_SYS_MONITOR_LEN=262144 +CONFIG_SYS_LOAD_ADDR=0x02000000 +CONFIG_TARGET_QEMU_XTENSA=y +CONFIG_REMAKE_ELF=y +CONFIG_SYS_MONITOR_BASE=0xF6000000 +CONFIG_DYNAMIC_SYS_CLK_FREQ=y +CONFIG_SHOW_BOOT_PROGRESS=y +CONFIG_BOOTDELAY=10 +CONFIG_AUTOBOOT_KEYED=y +CONFIG_AUTOBOOT_PROMPT="Autobooting in %d seconds, press <SPACE> to stop\n" +CONFIG_AUTOBOOT_STOP_STR=" " +CONFIG_SYS_PBSIZE=1049 +CONFIG_SYS_MALLOC_BOOTPARAMS=y +CONFIG_HUSH_PARSER=y +CONFIG_SYS_PROMPT="U-Boot> " +CONFIG_CMD_ASKENV=y +CONFIG_CRC32_VERIFY=y +CONFIG_CMD_MX_CYCLIC=y +CONFIG_CMD_SAVES=y +CONFIG_CMD_DHCP=y +CONFIG_CMD_PING=y +CONFIG_CMD_DIAG=y +CONFIG_USE_BOOTFILE=y +CONFIG_BOOTFILE="uImage" +CONFIG_VERSION_VARIABLE=y +CONFIG_SYSRESET=y diff --git a/include/configs/qemu-xtensa.h b/include/configs/qemu-xtensa.h new file mode 100644 index 000000000000..56e1cd40e1a6 --- /dev/null +++ b/include/configs/qemu-xtensa.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/*
- Copyright (C) 2007-2013 Tensilica, Inc.
- Copyright (C) 2014 - 2016 Cadence Design Systems Inc.
- Copyright (C) 2024 Jiaxun Yang jiaxun.yang@flygoat.com
- */
+#ifndef __CONFIG_H +#define __CONFIG_H
+#include <asm/arch/core.h> +#include <asm/addrspace.h> +#include <asm/config.h>
+#if XCHAL_HAVE_PTP_MMU +#define CFG_SYS_MEMORY_BASE \
(XCHAL_VECBASE_RESET_VADDR - XCHAL_VECBASE_RESET_PADDR)
+#define CFG_SYS_IO_BASE 0xf0000000 +#else +#define CFG_SYS_MEMORY_BASE 0x60000000 +#define CFG_SYS_IO_BASE 0x90000000 +#define CFG_MAX_MEM_MAPPED 0x10000000 +#endif
+#define CFG_SYS_SDRAM_SIZE 0x80000000
+#define CFG_SYS_SDRAM_BASE MEMADDR(0x00000000)
I'm not sure what CFG_SYS_IO_BASE means for the virt machine, but it looks like in the noMMU case SDRAM is going to overlap the IO range with the above base addresses and sizes. And from QEMU monitor I see the following address space distribution in the virt machine with a noMMU core:
address-space: memory 0000000000000000-ffffffffffffffff (prio 0, i/o): system 000000003ffe0000-000000003fffffff (prio 0, ram): xtensa.dataram0 0000000040000000-000000004001ffff (prio 0, ram): xtensa.instram0 0000000050000000-0000000053ffffff (prio 0, ram): xtensa.sysrom0 0000000060000000-00000000dfffffff (prio 0, ram): xtensa.sysram0 00000000f0000000-00000000f000ffff (prio 0, i/o): alias pcie-pio @gpex_ioport_window 0000000000000000-000000000000ffff 00000000f0100000-00000000f3ffffff (prio 0, i/o): alias pcie-ecam @pcie-mmcfg-mmio 0000000000000000-0000000003efffff 00000000f4000000-00000000fbffffff (prio 0, i/o): alias pcie-mmio @gpex_mmio_window 00000000f4000000-00000000fbffffff
i.e. there's no IO at the address 0x90000000.