]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
board: emulation: New board qemu-xtensa
authorJiaxun Yang <jiaxun.yang@flygoat.com>
Tue, 18 Jun 2024 13:56:09 +0000 (14:56 +0100)
committerTom Rini <trini@konsulko.com>
Thu, 4 Jul 2024 22:08:37 +0000 (16:08 -0600)
Introduce the new board, define every bits.

Tested-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
arch/xtensa/Kconfig
arch/xtensa/dts/virt-u-boot.dtsi [new file with mode: 0644]
board/emulation/qemu-xtensa/Kconfig [new file with mode: 0644]
board/emulation/qemu-xtensa/MAINTAINERS [new file with mode: 0644]
board/emulation/qemu-xtensa/Makefile [new file with mode: 0644]
board/emulation/qemu-xtensa/qemu-xtensa.c [new file with mode: 0644]
configs/qemu-xtensa-dc233c_defconfig [new file with mode: 0644]
include/configs/qemu-xtensa.h [new file with mode: 0644]

index 4afd56bca0950b39e33f9163e1d58836445a0eba..70eebb4bd22fbc9901a0659b1c910577e217f372 100644 (file)
@@ -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/arch/xtensa/dts/virt-u-boot.dtsi b/arch/xtensa/dts/virt-u-boot.dtsi
new file mode 100644 (file)
index 0000000..22b4683
--- /dev/null
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2024 Jiaxun Yang <jiaxun.yang@flygoat.com>
+ */
+
+#include <config.h>
+
+/ {
+       memory@0 {
+               device_type = "memory";
+#if XCHAL_HAVE_PTP_MMU
+               reg = <0x00000000 CFG_SYS_SDRAM_SIZE>;
+#else
+               reg = <CFG_SYS_MEMORY_BASE CFG_SYS_SDRAM_SIZE>;
+#endif
+       };
+};
diff --git a/board/emulation/qemu-xtensa/Kconfig b/board/emulation/qemu-xtensa/Kconfig
new file mode 100644 (file)
index 0000000..8767b6f
--- /dev/null
@@ -0,0 +1,43 @@
+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 0x50000000 if (SYS_CPU = de212)
+       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
+       imply CMD_PCI
+
+endif
diff --git a/board/emulation/qemu-xtensa/MAINTAINERS b/board/emulation/qemu-xtensa/MAINTAINERS
new file mode 100644 (file)
index 0000000..6ffdfe8
--- /dev/null
@@ -0,0 +1,8 @@
+QEMU XTENSA 'VIRT' BOARD
+M:     Jiaxun Yang <jiaxun.yang@flygoat.com>
+M:     Max Filippov <jcmvbkbc@gmail.com>
+S:     Maintained
+F:     board/emulation/qemu-xtensa/
+F:     board/emulation/common/
+F:     include/configs/qemu-xtensa.h
+F:     configs/qemu-xtensa-dc233c_defconfig
diff --git a/board/emulation/qemu-xtensa/Makefile b/board/emulation/qemu-xtensa/Makefile
new file mode 100644 (file)
index 0000000..0f33a65
--- /dev/null
@@ -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 (file)
index 0000000..0ca8334
--- /dev/null
@@ -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-dc233c_defconfig b/configs/qemu-xtensa-dc233c_defconfig
new file mode 100644 (file)
index 0000000..e6f40b3
--- /dev/null
@@ -0,0 +1,32 @@
+CONFIG_XTENSA=y
+CONFIG_SYS_CPU="dc233c"
+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 (file)
index 0000000..505aa06
--- /dev/null
@@ -0,0 +1,36 @@
+/* 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
+#define CFG_SYS_SDRAM_SIZE             0x80000000 /* xtensa.sysram0 */
+#else
+#define CFG_SYS_MEMORY_BASE            0x60000000
+#define CFG_SYS_SDRAM_SIZE             0x08000000 /* xtensa.sysram0 */
+#endif
+
+#define CFG_SYS_SDRAM_BASE             MEMADDR(0x00000000)
+
+#if defined(CFG_MAX_MEM_MAPPED) && \
+       CFG_MAX_MEM_MAPPED < CFG_SYS_SDRAM_SIZE
+#define XTENSA_SYS_TEXT_ADDR           \
+       (MEMADDR(CFG_MAX_MEM_MAPPED) - CONFIG_SYS_MONITOR_LEN)
+#else
+#define XTENSA_SYS_TEXT_ADDR           \
+       (MEMADDR(CFG_SYS_SDRAM_SIZE) - CONFIG_SYS_MONITOR_LEN)
+#endif
+
+#endif /* __CONFIG_H */