m68k: Add support for QEMU virt machine
Subsystems (2)
v6 cover m68k: Add support for QEMU virt machine
Add support for the QEMU 'virt' machine on the m68k architecture. The QEMU virt machine models a generic system utilizing Goldfish virtual peripherals and is capable of emulating various classic 68k CPUs.
Currently, U-Boot's m68k architecture support focuses on ColdFire variants. This series expands support to include the classic M680x0 architecture, implementing the necessary exception vectors, startup code, and a bootinfo parser compatible with the QEMU interface.
Drivers for Goldfish peripherals (TTY, Timer, RTC) and the QEMU Virtual System Controller (sysreset) are also added to enable serial console, timekeeping, and system reset functionality.
The implementation has been verified on QEMU targeting the M68040 CPU, confirming successful hardware initialization and boot to the U-Boot command shell. Additionally, the CI configuration was verified locally using gitlab-ci-local "qemu_m68k_virt test.py", resulting in PASS qemu_m68k_virt test.py.
---
Changes in v6:
- Refactor Goldfish drivers (TTY, Timer, RTC) to strictly separate of_to_plat (parsing) and probe (mapping), supporting both device tree and explicit platform data.
- Introduce a new sysreset driver for the QEMU virtual system controller, replacing the previous board-file implementation.
- Refactor m68k Kconfig/Makefile to use a hidden CONFIG_ARCH_COLDFIRE symbol for cleaner file grouping.
- Improve board initialization: move bootinfo parsing to board_early_init_f and remove all hardcoded MMIO addresses.
- Update MAINTAINERS to reflect the removal of inactive maintainers.
Changes in v5:
- Rebase on u-boot/next branch.
- Add 'imply CMD_DM' to TARGET_QEMU_M68K in Kconfig.
- Add a new patch to update the M68K entry in MAINTAINERS and add myself as a co-maintainer.
Changes in v4:
- Support DT probing with platform data as a fallback. (serial & timer)
- Fix sandbox build warnings by removing incorrect type casting.
- Add comment explaining read latching behavior in the timer driver.
- Sort headers alphabetically in the timer driver.
Changes in v3:
- Add Goldfish timer driver.
- Update Goldfish RTC driver to support non-DT probing.
- Enable Goldfish RTC and Timer support in board configuration.
- Add safety loop limit to bootinfo parsing in dram_init.
- Remove dummy timer functions from architecture code.
- Remove unnecessary type casts in Goldfish TTY driver.
- Remove TEST_PY_ID from CI job definitions.
- Update documentation to include new RTC support.
Changes in v2:
- Refactor Goldfish TTY driver to use priv data for the RX buffer and ensure single-byte reads.
- Rename arch/m68k/cpu/m68040 to arch/m68k/cpu/m680x0 to separate the architecture family from the specific CPU model.
- Introduce M680x0 Kconfig symbol and separate MAINTAINERS entries for the architecture and the board.
- Regenerate qemu-m68k_defconfig using make savedefconfig and add the board to the documentation index.
- Add a new patch to enable CI testing on GitLab and Azure Pipelines.
- Update SPDX identifiers to GPL-2.0-or-later.
- Sort headers alphabetically.
- Fix tabs vs spaces.
v5: https://lore.kernel.org/u-boot/[email protected]/
v4: https://lore.kernel.org/u-boot/[email protected]/
v3: https://lore.kernel.org/u-boot/[email protected]/
v2: https://lore.kernel.org/u-boot/[email protected]/
v1: https://lore.kernel.org/u-boot/[email protected]/
Kuan-Wei Chiu (8):
serial: Add Goldfish TTY driver
timer: Add Goldfish timer driver
rtc: goldfish: Support platform data for non-DT probing
sysreset: Add QEMU virtual system controller driver
m68k: Add support for M68040 CPU
board: Add QEMU m68k virt board support
CI: Add test jobs for QEMU m68k virt machine
MAINTAINERS: Update m68k entry
.azure-pipelines.yml | 3 + .gitlab-ci.yml | 6 ++ MAINTAINERS | 28 ++++- arch/m68k/Kconfig | 39 +++++++ arch/m68k/Makefile | 1 + arch/m68k/config.mk | 10 +- arch/m68k/cpu/m680x0/Makefile | 6 ++ arch/m68k/cpu/m680x0/cpu.c | 73 +++++++++++++ arch/m68k/cpu/m680x0/start.S | 73 +++++++++++++ arch/m68k/cpu/m680x0/u-boot.lds | 47 +++++++++ arch/m68k/include/asm/bootinfo.h | 39 +++++++ arch/m68k/lib/Makefile | 7 +- board/emulation/qemu-m68k/Kconfig | 12 +++ board/emulation/qemu-m68k/MAINTAINERS | 8 ++ board/emulation/qemu-m68k/Makefile | 5 + board/emulation/qemu-m68k/qemu-m68k.c | 117 +++++++++++++++++++++ configs/qemu-m68k_defconfig | 20 ++++ doc/board/emulation/index.rst | 1 + doc/board/emulation/qemu-m68k.rst | 39 +++++++ drivers/rtc/goldfish_rtc.c | 23 +++- drivers/serial/Kconfig | 8 ++ drivers/serial/Makefile | 1 + drivers/serial/serial_goldfish.c | 117 +++++++++++++++++++++ drivers/sysreset/Kconfig | 8 ++ drivers/sysreset/Makefile | 1 + drivers/sysreset/sysreset_qemu_virt_ctrl.c | 55 ++++++++++ drivers/timer/Kconfig | 8 ++ drivers/timer/Makefile | 1 + drivers/timer/goldfish_timer.c | 89 ++++++++++++++++ include/configs/qemu-m68k.h | 18 ++++ include/goldfish_rtc.h | 15 +++ include/goldfish_timer.h | 13 +++ include/goldfish_tty.h | 18 ++++ include/qemu_virt_ctrl.h | 13 +++ 34 files changed, 908 insertions(+), 14 deletions(-) create mode 100644 arch/m68k/cpu/m680x0/Makefile create mode 100644 arch/m68k/cpu/m680x0/cpu.c create mode 100644 arch/m68k/cpu/m680x0/start.S create mode 100644 arch/m68k/cpu/m680x0/u-boot.lds create mode 100644 arch/m68k/include/asm/bootinfo.h create mode 100644 board/emulation/qemu-m68k/Kconfig create mode 100644 board/emulation/qemu-m68k/MAINTAINERS create mode 100644 board/emulation/qemu-m68k/Makefile create mode 100644 board/emulation/qemu-m68k/qemu-m68k.c create mode 100644 configs/qemu-m68k_defconfig create mode 100644 doc/board/emulation/qemu-m68k.rst create mode 100644 drivers/serial/serial_goldfish.c create mode 100644 drivers/sysreset/sysreset_qemu_virt_ctrl.c create mode 100644 drivers/timer/goldfish_timer.c create mode 100644 include/configs/qemu-m68k.h create mode 100644 include/goldfish_rtc.h create mode 100644 include/goldfish_timer.h create mode 100644 include/goldfish_tty.h create mode 100644 include/qemu_virt_ctrl.h
Signature · 1 line
2.52.0.457.g6b5491de43-goog
PATCH v6 1/8 serial: Add Goldfish TTY driver
Add support for the Google Goldfish TTY serial device. This virtual device is commonly used in QEMU virtual machines (such as the m68k virt machine) and Android emulators.
The driver implements basic console output and input polling using the Goldfish MMIO interface.
---
Changes in v6:
- Refactor driver to separate device tree reading into .of_to_plat.
- Rename platform data member from 'base' to 'reg' (phys_addr_t).
- Update header includes to follow U-Boot coding style.
MAINTAINERS | 6 ++ drivers/serial/Kconfig | 8 +++ drivers/serial/Makefile | 1 + drivers/serial/serial_goldfish.c | 117 +++++++++++++++++++++++++++++++ include/goldfish_tty.h | 18 +++++ 5 files changed, 150 insertions(+) create mode 100644 drivers/serial/serial_goldfish.c create mode 100644 include/goldfish_tty.h
MAINTAINERS +6 -0
@@ -1260,6 +1260,12 @@ S: Maintained F: drivers/misc/gsc.c F: include/gsc.h +GOLDFISH SERIAL DRIVER +M: Kuan-Wei Chiu <[email protected]> +S: Maintained +F: drivers/serial/serial_goldfish.c +F: include/goldfish_tty.h + INTERCONNECT: M: Neil Armstrong <[email protected]> S: Maintained
drivers/serial/Kconfig +8 -0
@@ -1193,4 +1193,12 @@ config SYS_SDMR depends on MPC8XX_CONS default 0x0 +config SERIAL_GOLDFISH + bool "Goldfish TTY support" + depends on DM_SERIAL + help + Select this to enable support for the Goldfish TTY serial port. + This virtual device is commonly used by QEMU virtual machines + (e.g. m68k virt) for console output. + endif
drivers/serial/Makefile +1 -0
@@ -63,3 +63,4 @@ obj-$(CONFIG_XTENSA_SEMIHOSTING_SERIAL) += serial_xtensa_semihosting.o obj-$(CONFIG_S5P4418_PL011_SERIAL) += serial_s5p4418_pl011.o obj-$(CONFIG_UART4_SERIAL) += serial_adi_uart4.o +obj-$(CONFIG_SERIAL_GOLDFISH) += serial_goldfish.o
drivers/serial/serial_goldfish.c new file +117 -0
117 lines not on this page · raw message
include/goldfish_tty.h new file +18 -0
@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* Copyright (C) 2025, Kuan-Wei Chiu <[email protected]> +*/ + +#ifndef _GOLDFISH_TTY_H_ +#define _GOLDFISH_TTY_H_ + +#include <linux/types.h> + +/* Platform data for the Goldfish TTY driver +* Used to pass hardware base address from Board to Driver +*/ +struct goldfish_tty_plat { +phys_addr_t reg; +}; + +#endif /* _GOLDFISH_TTY_H_ */
Signature · 1 line
2.52.0.457.g6b5491de43-goog
PATCH v6 2/8 timer: Add Goldfish timer driver
In reply to Kuan-Wei ChiuAdd support for the Goldfish timer driver. This driver utilizes the Goldfish RTC hardware to provide a nanosecond-resolution timer. This virtual device is commonly found in QEMU virtual machines (such as the m68k virt machine) and Android emulators.
The driver implements the standard U-Boot timer UCLASS interface, exposing a 64-bit monotonically increasing counter with a 1GHz clock rate derived from the RTC registers.
---
Changes in v6:
- Refactor driver to separate device tree reading into .of_to_plat.
- Rename platform data member from 'base' to 'reg' (phys_addr_t).
- Update header includes to follow U-Boot coding style.
MAINTAINERS | 6 +++ drivers/timer/Kconfig | 8 +++ drivers/timer/Makefile | 1 + drivers/timer/goldfish_timer.c | 89 ++++++++++++++++++++++++++++++++++ include/goldfish_timer.h | 13 +++++ 5 files changed, 117 insertions(+) create mode 100644 drivers/timer/goldfish_timer.c create mode 100644 include/goldfish_timer.h
MAINTAINERS +6 -0
@@ -1266,6 +1266,12 @@ S: Maintained F: drivers/serial/serial_goldfish.c F: include/goldfish_tty.h +GOLDFISH TIMER DRIVER +M: Kuan-Wei Chiu <[email protected]> +S: Maintained +F: drivers/timer/goldfish_timer.c +F: include/goldfish_timer.h + INTERCONNECT: M: Neil Armstrong <[email protected]> S: Maintained
drivers/timer/Kconfig +8 -0
@@ -340,4 +340,12 @@ config STARFIVE_TIMER Select this to enable support for the timer found on Starfive SoC. +config GOLDFISH_TIMER + bool "Goldfish Timer support" + depends on TIMER + help + Select this to enable support for the Goldfish Timer. + It uses the Goldfish RTC hardware to provide a nanosecond-resolution + timer, commonly found in QEMU virt machines. + endmenu
drivers/timer/Makefile +1 -0
@@ -36,3 +36,4 @@ obj-$(CONFIG_MCHP_PIT64B_TIMER) += mchp-pit64b-timer.o obj-$(CONFIG_IMX_GPT_TIMER) += imx-gpt-timer.o obj-$(CONFIG_XILINX_TIMER) += xilinx-timer.o obj-$(CONFIG_STARFIVE_TIMER) += starfive-timer.o +obj-$(CONFIG_GOLDFISH_TIMER) += goldfish_timer.o
drivers/timer/goldfish_timer.c new file +89 -0
89 lines not on this page · raw message
include/goldfish_timer.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* Copyright (C) 2025, Kuan-Wei Chiu <[email protected]> +*/ + +#ifndef _GOLDFISH_TIMER_H_ +#define _GOLDFISH_TIMER_H_ + +struct goldfish_timer_plat { +phys_addr_t reg; +}; + +#endif /* _GOLDFISH_TIMER_H_ */
Signature · 1 line
2.52.0.457.g6b5491de43-goog
PATCH v6 3/8 rtc: goldfish: Support platform data for non-DT probing
In reply to Kuan-Wei ChiuCurrently, the Goldfish RTC driver exclusively relies on device tree to retrieve the base address, failing immediately if dev_read_addr() returns FDT_ADDR_T_NONE. This restriction prevents the driver from being used on platforms that instantiate devices via U_BOOT_DRVINFO() instead of device tree, such as the QEMU m68k virt machine.
Add support for platform data to address this limitation. Introduce a new .of_to_plat hook to handle device tree parsing and populate the platform data. Update the probe function to rely exclusively on this platform data, enabling support for both Device Tree and manual instantiation.
Introduce a new header file include/goldfish_rtc.h to define the platform data structure.
---
Changes in v6:
- Refactor driver to use .of_to_plat for DT parsing instead of fallback logic in probe.
- Ensure platform data member is named 'reg' with phys_addr_t type.
- Update header includes to follow U-Boot coding style.
drivers/rtc/goldfish_rtc.c | 23 +++++++++++++++++++---- include/goldfish_rtc.h | 15 +++++++++++++++ 2 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 include/goldfish_rtc.h
drivers/rtc/goldfish_rtc.c +19 -4
@@ -9,6 +9,7 @@#include <div64.h> #include <dm.h> +#include <goldfish_rtc.h> #include <mapmem.h> #include <rtc.h> #include <linux/io.h>
@@ -74,15 +75,27 @@ static int goldfish_rtc_set(struct udevice *dev, const struct rtc_time *time)return 0 ; } -static int goldfish_rtc_probe (struct udevice *dev) +static int goldfish_rtc_of_to_plat (struct udevice *dev) { -struct goldfish_rtc *priv =dev_get_priv (dev); +struct goldfish_rtc_plat *plat =dev_get_plat (dev);fdt_addr_t addr; addr =dev_read_addr (dev); -if (addr ==FDT_ADDR_T_NONE ) +if (addr !=FDT_ADDR_T_NONE ) + plat->reg = addr; + +return 0 ; +} + +static int goldfish_rtc_probe (struct udevice *dev) +{ +struct goldfish_rtc_plat *plat =dev_get_plat (dev); +struct goldfish_rtc *priv =dev_get_priv (dev); + +if (!plat->reg)return -EINVAL ; - priv->base =map_sysmem (addr,0x20 ); + + priv->base =map_sysmem (plat->reg,0x20 );return 0 ; }
@@ -103,5 +116,7 @@ U_BOOT_DRIVER(rtc_goldfish) = { .ops = &goldfish_rtc_ops, .probe = goldfish_rtc_probe, .of_match = goldfish_rtc_of_match, + .of_to_plat = goldfish_rtc_of_to_plat, + .plat_auto = sizeof(struct goldfish_rtc_plat), .priv_auto = sizeof(struct goldfish_rtc), };
include/goldfish_rtc.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* Copyright (C) 2025, Kuan-Wei Chiu <[email protected]> +*/ + +#ifndef _GOLDFISH_RTC_H_ +#define _GOLDFISH_RTC_H_ + +#include <linux/types.h> + +struct goldfish_rtc_plat { +phys_addr_t reg; +}; + +#endif /* _GOLDFISH_RTC_H_ */
Signature · 1 line
2.52.0.457.g6b5491de43-goog
PATCH v6 4/8 sysreset: Add QEMU virtual system controller driver
In reply to Kuan-Wei ChiuIntroduce a new sysreset driver for the QEMU Virtual System Controller. This device is found on QEMU "virt" machines (such as the m68k virt target) and provides a mechanism to trigger system reset and power-off events.
The driver maps U-Boot sysreset types to the corresponding controller commands:
- SYSRESET_WARM / SYSRESET_COLD -> VIRT_CTRL_CMD_RESET
- SYSRESET_POWER_OFF -> VIRT_CTRL_CMD_HALT
---
Changes in v6:
- Introduce new driver to replace board-file reset implementation.
MAINTAINERS | 6 +++ drivers/sysreset/Kconfig | 8 ++++ drivers/sysreset/Makefile | 1 + drivers/sysreset/sysreset_qemu_virt_ctrl.c | 55 ++++++++++++++++++++++ include/qemu_virt_ctrl.h | 13 +++++ 5 files changed, 83 insertions(+) create mode 100644 drivers/sysreset/sysreset_qemu_virt_ctrl.c create mode 100644 include/qemu_virt_ctrl.h
MAINTAINERS +6 -0
@@ -1598,6 +1598,12 @@ S: Maintained T: git https://source.denx.de/u-boot/custodians/u-boot-mpc85xx.git F: arch/powerpc/cpu/mpc85xx/ +QEMU VIRTUAL SYSTEM CONTROLLER +M: Kuan-Wei Chiu <[email protected]> +S: Maintained +F: drivers/sysreset/sysreset_qemu_virt_ctrl.c +F: include/qemu_virt_ctrl.h + RAW NAND M: Dario Binacchi <[email protected]> M: Michael Trimarchi <[email protected]>
drivers/sysreset/Kconfig +8 -0
@@ -298,6 +298,14 @@ config SYSRESET_QCOM_PSHOLD help Add support for the system reboot on Qualcomm SoCs via PSHOLD. +config SYSRESET_QEMU_VIRT_CTRL + bool "QEMU Virtual System Controller support" + depends on SYSRESET + help + Enable support for the QEMU Virtual System Controller. + This device is used in QEMU machines (e.g. m68k virt) to trigger + system reset and poweroff events. + endif endmenu
drivers/sysreset/Makefile +1 -0
@@ -32,3 +32,4 @@ obj-$(CONFIG_$(PHASE_)SYSRESET_X86) += sysreset_x86.o obj-$(CONFIG_SYSRESET_RAA215300) += sysreset_raa215300.o obj-$(CONFIG_SYSRESET_QCOM_PSHOLD) += sysreset_qcom-pshold.o obj-$(CONFIG_TARGET_XTFPGA) += sysreset_xtfpga.o +obj-$(CONFIG_SYSRESET_QEMU_VIRT_CTRL) += sysreset_qemu_virt_ctrl.o
drivers/sysreset/sysreset_qemu_virt_ctrl.c new file +55 -0
55 lines not on this page · raw message
include/qemu_virt_ctrl.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* Copyright (C) 2025, Kuan-Wei Chiu <[email protected]> +*/ + +#ifndef _QEMU_VIRT_CTRL_H_ +#define _QEMU_VIRT_CTRL_H_ + +struct qemu_virt_ctrl_plat { +phys_addr_t reg; +}; + +#endif /* _QEMU_VIRT_CTRL_H_ */
Signature · 1 line
2.52.0.457.g6b5491de43-goog
Re: [PATCH v6 4/8] sysreset: Add QEMU virtual system controller driver
Quoted 16 lines · Kuan-Wei Chiu
Introduce a new sysreset driver for the QEMU Virtual System Controller. This device is found on QEMU "virt" machines (such as the m68k virt target) and provides a mechanism to trigger system reset and power-off events.
The driver maps U-Boot sysreset types to the corresponding controller commands:
-SYSRESET_WARM/SYSRESET_COLD->VIRT_CTRL_CMD_RESET
-SYSRESET_POWER_OFF->VIRT_CTRL_CMD_HALTSigned-off-by Kuan-Wei Chiu <[email protected]>---
Changes in v6:
- Introduce new driver to replace board-file reset implementation.
Quoted 9 lines
MAINTAINERS | 6 +++ drivers/sysreset/Kconfig | 8 ++++ drivers/sysreset/Makefile | 1 + drivers/sysreset/sysreset_qemu_virt_ctrl.c | 55 ++++++++++++++++++++++ include/qemu_virt_ctrl.h | 13 +++++ 5 files changed, 83 insertions(+) create mode 100644 drivers/sysreset/sysreset_qemu_virt_ctrl.c create mode 100644 include/qemu_virt_ctrl.h
Re: [PATCH v6 4/8] sysreset: Add QEMU virtual system controller driver
In reply to Kuan-Wei ChiuKuan-Wei Chiu <[email protected]> schrieb am Mi., 7. Jan. 2026, 21:19:
Quoted 46 lines
Introduce a new sysreset driver for the QEMU Virtual System Controller. This device is found on QEMU "virt" machines (such as the m68k virt target) and provides a mechanism to trigger system reset and power-off events.
The driver maps U-Boot sysreset types to the corresponding controller commands:
-SYSRESET_WARM/SYSRESET_COLD->VIRT_CTRL_CMD_RESET
-SYSRESET_POWER_OFF->VIRT_CTRL_CMD_HALTSigned-off-by Kuan-Wei Chiu <[email protected]>---
Changes in v6:
- Introduce new driver to replace board-file reset implementation.MAINTAINERS | 6 +++ drivers/sysreset/Kconfig | 8 ++++ drivers/sysreset/Makefile | 1 + drivers/sysreset/sysreset_qemu_virt_ctrl.c | 55 ++++++++++++++++++++++ include/qemu_virt_ctrl.h | 13 +++++ 5 files changed, 83 insertions(+) create mode 100644 drivers/sysreset/sysreset_qemu_virt_ctrl.c create mode 100644 include/qemu_virt_ctrl.hMAINTAINERS +6
-0@@ -1598,6 +1598,12 @@ S: Maintained T: git https://source.denx.de/u-boot/custodians/u-boot-mpc85xx.git F: arch/powerpc/cpu/mpc85xx/ +QEMU VIRTUAL SYSTEM CONTROLLER +M: Kuan-Wei Chiu <[email protected]> +S: Maintained +F: drivers/sysreset/sysreset_qemu_virt_ctrl.c +F: include/qemu_virt_ctrl.h + RAW NAND M: Dario Binacchi <[email protected]> M: Michael Trimarchi <[email protected]>drivers/sysreset/Kconfig +0
-0
drivers/sysreset/Kconfig config SYSRESET_QCOM_PSHOLD · line 307
Quoted 10 lines
drivers/sysreset/Kconfig +6
-0@@ -298,6 +298,14 @@ config SYSRESET_QCOM_PSHOLD help Add support for the system reboot on Qualcomm SoCs via PSHOLD. +config SYSRESET_QEMU_VIRT_CTRL + bool "QEMU Virtual System Controller support" + depends on SYSRESET + help + Enable support for the QEMU Virtual System Controller. + This device is used in QEMU machines (e.g. m68k virt) to trigger
Is this specific to m68k or does it work on all QEMU architectures? If it works everywhere, I would not mention m68k here.
On x86 QEMU we currently lack poweroff support. So this would come in handy.
Best regards
Heinrich
+ system reset and poweroff events.
Quoted 99 lines
drivers/sysreset/Kconfig +1
-0+ endif endmenudrivers/sysreset/Makefile +1
-0@@ -32,3 +32,4 @@ obj-$(CONFIG_$(PHASE_)SYSRESET_X86) += sysreset_x86.o obj-$(CONFIG_SYSRESET_RAA215300) += sysreset_raa215300.o obj-$(CONFIG_SYSRESET_QCOM_PSHOLD) += sysreset_qcom-pshold.o obj-$(CONFIG_TARGET_XTFPGA) += sysreset_xtfpga.o +obj-$(CONFIG_SYSRESET_QEMU_VIRT_CTRL) += sysreset_qemu_virt_ctrl.odrivers/sysreset/sysreset_qemu_virt_ctrl.c new file +24
-0@@ -0,0 +1,55 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (C) 2025, Kuan-Wei Chiu <[email protected]> +* +* QEMU Virtual System Controller Driver +*/ + +#include <dm.h> +#include <qemu_virt_ctrl.h> +#include <sysreset.h> +#include <asm/io.h> +#include <linux/err.h> + +/* Register offsets */ +#define VIRT_CTRL_REG_FEATURES 0x00 +#define VIRT_CTRL_REG_CMD 0x04 + +/* Commands */ +#define VIRT_CTRL_CMD_NOOP 0x00 +#define VIRT_CTRL_CMD_RESET 0x01 +#define VIRT_CTRL_CMD_HALT 0x02 +#define VIRT_CTRL_CMD_PANIC 0x03 + +static int qemu_virt_ctrl_request(struct udevice *dev, enum sysreset_ttype)
drivers/sysreset/sysreset_qemu_virt_ctrl.c new file +31
-0+{ +struct qemu_virt_ctrl_plat *plat =dev_get_plat (dev); +u32 val; + +switch (type) { +case SYSRESET_WARM : +case SYSRESET_COLD : + val =VIRT_CTRL_CMD_RESET ; +break ; +case SYSRESET_POWER_OFF : + val =VIRT_CTRL_CMD_HALT ; +break ; +default : +return -EPROTONOSUPPORT ; + } + +writel (val, plat->reg +VIRT_CTRL_REG_CMD ); + +return -EINPROGRESS ; +} + +static struct sysreset_ops qemu_virt_ctrl_ops = { + .request = qemu_virt_ctrl_request, +}; + +U_BOOT_DRIVER (sysreset_qemu_virt_ctrl) = { + .name ="sysreset_qemu_virt_ctrl" , + .id =UCLASS_SYSRESET , + .ops = &qemu_virt_ctrl_ops, + .plat_auto =sizeof (struct qemu_virt_ctrl_plat ), +};include/qemu_virt_ctrl.h new file +13
-1@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* Copyright (C) 2025, Kuan-Wei Chiu <[email protected]> +*/ + +#ifndef _QEMU_VIRT_CTRL_H_ +#define _QEMU_VIRT_CTRL_H_ + +struct qemu_virt_ctrl_plat { +phys_addr_t reg; +}; + +#endif /* _QEMU_VIRT_CTRL_H_ */ --2.52.0.457.g6b5491de43-goog
Re: [PATCH v6 4/8] sysreset: Add QEMU virtual system controller driver
Hi Heinrich,
Quoted 51 lines · Heinrich Schuchardt
Kuan-Wei Chiu <[email protected]> schrieb am Mi., 7. Jan. 2026, 21:19:
Quoted 49 lines
Introduce a new sysreset driver for the QEMU Virtual System Controller. This device is found on QEMU "virt" machines (such as the m68k virt target) and provides a mechanism to trigger system reset and power-off events.
The driver maps U-Boot sysreset types to the corresponding controller commands:
-SYSRESET_WARM/SYSRESET_COLD->VIRT_CTRL_CMD_RESET
-SYSRESET_POWER_OFF->VIRT_CTRL_CMD_HALTSigned-off-by Kuan-Wei Chiu <[email protected]>---
Changes in v6:
- Introduce new driver to replace board-file reset implementation.MAINTAINERS | 6 +++ drivers/sysreset/Kconfig | 8 ++++ drivers/sysreset/Makefile | 1 + drivers/sysreset/sysreset_qemu_virt_ctrl.c | 55 ++++++++++++++++++++++ include/qemu_virt_ctrl.h | 13 +++++ 5 files changed, 83 insertions(+) create mode 100644 drivers/sysreset/sysreset_qemu_virt_ctrl.c create mode 100644 include/qemu_virt_ctrl.hMAINTAINERS +6
-0@@ -1598,6 +1598,12 @@ S: Maintained T: git https://source.denx.de/u-boot/custodians/u-boot-mpc85xx.git F: arch/powerpc/cpu/mpc85xx/ +QEMU VIRTUAL SYSTEM CONTROLLER +M: Kuan-Wei Chiu <[email protected]> +S: Maintained +F: drivers/sysreset/sysreset_qemu_virt_ctrl.c +F: include/qemu_virt_ctrl.h + RAW NAND M: Dario Binacchi <[email protected]> M: Michael Trimarchi <[email protected]>drivers/sysreset/Kconfig +0
-0@@ -298,6 +298,14 @@ config SYSRESET_QCOM_PSHOLD help Add support for the system reboot on Qualcomm SoCs via PSHOLD.
Quoted 10 lines
drivers/sysreset/Kconfig config SYSRESET_QCOM_PSHOLD · line 310
Quoted 7 lines
drivers/sysreset/Kconfig +6
-0+config SYSRESET_QEMU_VIRT_CTRL + bool "QEMU Virtual System Controller support" + depends on SYSRESET + help + Enable support for the QEMU Virtual System Controller. + This device is used in QEMU machines (e.g. m68k virt) to triggerIs this specific to m68k or does it work on all QEMU architectures? If it works everywhere, I would not mention m68k here.
The virt-ctrl device was originally introduced in qemu for the m68k virt machine, which remains its sole user to date. However, as the implementation resides in hw/misc/virt_ctrl.c, I believe it was designed to be generic and architecture-agnostic from the start.
Regards,
Kuan-Wei
Quoted 107 lines
On x86 QEMU we currently lack poweroff support. So this would come in handy.
Best regards
Heinrich
+ system reset and poweroff events.
Quoted 99 lines
drivers/sysreset/Kconfig +1
-0+ endif endmenudrivers/sysreset/Makefile +1
-0@@ -32,3 +32,4 @@ obj-$(CONFIG_$(PHASE_)SYSRESET_X86) += sysreset_x86.o obj-$(CONFIG_SYSRESET_RAA215300) += sysreset_raa215300.o obj-$(CONFIG_SYSRESET_QCOM_PSHOLD) += sysreset_qcom-pshold.o obj-$(CONFIG_TARGET_XTFPGA) += sysreset_xtfpga.o +obj-$(CONFIG_SYSRESET_QEMU_VIRT_CTRL) += sysreset_qemu_virt_ctrl.odrivers/sysreset/sysreset_qemu_virt_ctrl.c new file +24
-0@@ -0,0 +1,55 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (C) 2025, Kuan-Wei Chiu <[email protected]> +* +* QEMU Virtual System Controller Driver +*/ + +#include <dm.h> +#include <qemu_virt_ctrl.h> +#include <sysreset.h> +#include <asm/io.h> +#include <linux/err.h> + +/* Register offsets */ +#define VIRT_CTRL_REG_FEATURES 0x00 +#define VIRT_CTRL_REG_CMD 0x04 + +/* Commands */ +#define VIRT_CTRL_CMD_NOOP 0x00 +#define VIRT_CTRL_CMD_RESET 0x01 +#define VIRT_CTRL_CMD_HALT 0x02 +#define VIRT_CTRL_CMD_PANIC 0x03 + +static int qemu_virt_ctrl_request(struct udevice *dev, enum sysreset_ttype)
drivers/sysreset/sysreset_qemu_virt_ctrl.c new file +31
-0+{ +struct qemu_virt_ctrl_plat *plat =dev_get_plat (dev); +u32 val; + +switch (type) { +case SYSRESET_WARM : +case SYSRESET_COLD : + val =VIRT_CTRL_CMD_RESET ; +break ; +case SYSRESET_POWER_OFF : + val =VIRT_CTRL_CMD_HALT ; +break ; +default : +return -EPROTONOSUPPORT ; + } + +writel (val, plat->reg +VIRT_CTRL_REG_CMD ); + +return -EINPROGRESS ; +} + +static struct sysreset_ops qemu_virt_ctrl_ops = { + .request = qemu_virt_ctrl_request, +}; + +U_BOOT_DRIVER (sysreset_qemu_virt_ctrl) = { + .name ="sysreset_qemu_virt_ctrl" , + .id =UCLASS_SYSRESET , + .ops = &qemu_virt_ctrl_ops, + .plat_auto =sizeof (struct qemu_virt_ctrl_plat ), +};include/qemu_virt_ctrl.h new file +13
-1@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* Copyright (C) 2025, Kuan-Wei Chiu <[email protected]> +*/ + +#ifndef _QEMU_VIRT_CTRL_H_ +#define _QEMU_VIRT_CTRL_H_ + +struct qemu_virt_ctrl_plat { +phys_addr_t reg; +}; + +#endif /* _QEMU_VIRT_CTRL_H_ */ --2.52.0.457.g6b5491de43-goog
PATCH v6 5/8 m68k: Add support for M68040 CPU
In reply to Kuan-Wei ChiuAdd support for the Motorola 68040 architecture. Currently, m68k support in U-Boot is primarily focused on ColdFire variants. Introduce the necessary infrastructure to support the classic M680x0 series, specifically targeting the M68040 as emulated by QEMU.
The implementation includes exception vectors, early startup code, and minimal CPU initialization and relocation stubs. It also defines the standard m68k boot information structure used for passing hardware information to the operating system. To ensure compatibility, ColdFire- specific library objects such as cache and interrupt handling are excluded from the build when M68040 is selected.
Additionally, apply a specific workaround during the early memory reservation stage. Use a manual loop to clear global data instead of the standard memset() function, as utilizing memset() at this point was observed to cause a hang on the QEMU platform.
---
Changes in v6:
- Introduce hidden Kconfig symbol CONFIG_ARCH_COLDFIRE to group ColdFire-specific files in Makefile, removing the need for 'ifndef CONFIG_M680x0'.
- Add help text for CONFIG_M680x0.
MAINTAINERS | 6 +++ arch/m68k/Kconfig | 30 +++++++++++++ arch/m68k/Makefile | 1 + arch/m68k/config.mk | 10 ++++- arch/m68k/cpu/m680x0/Makefile | 6 +++ arch/m68k/cpu/m680x0/cpu.c | 73 ++++++++++++++++++++++++++++++++ arch/m68k/cpu/m680x0/start.S | 73 ++++++++++++++++++++++++++++++++ arch/m68k/cpu/m680x0/u-boot.lds | 47 ++++++++++++++++++++ arch/m68k/include/asm/bootinfo.h | 39 +++++++++++++++++ arch/m68k/lib/Makefile | 7 +-- 10 files changed, 284 insertions(+), 8 deletions(-) create mode 100644 arch/m68k/cpu/m680x0/Makefile create mode 100644 arch/m68k/cpu/m680x0/cpu.c create mode 100644 arch/m68k/cpu/m680x0/start.S create mode 100644 arch/m68k/cpu/m680x0/u-boot.lds create mode 100644 arch/m68k/include/asm/bootinfo.h
MAINTAINERS +6 -0
@@ -1324,6 +1324,12 @@ F: lib/getopt.c F: test/log/ F: test/py/tests/test_log.py +M680X0 ARCHITECTURE +M: Kuan-Wei Chiu <[email protected]> +S: Maintained +F: arch/m68k/cpu/m680x0/ +F: arch/m68k/include/asm/bootinfo.h + MALI DISPLAY PROCESSORS M: Liviu Dudau <[email protected]> S: Supported
arch/m68k/Kconfig +30 -0
@@ -12,50 +12,64 @@ config MCF520x select OF_CONTROL select DM select DM_SERIAL + select ARCH_COLDFIRE bool config MCF52x2 select OF_CONTROL select DM select DM_SERIAL + select ARCH_COLDFIRE bool config MCF523x select OF_CONTROL select DM select DM_SERIAL + select ARCH_COLDFIRE bool config MCF530x select OF_CONTROL select DM select DM_SERIAL + select ARCH_COLDFIRE bool config MCF5301x select OF_CONTROL select DM select DM_SERIAL + select ARCH_COLDFIRE bool config MCF532x select OF_CONTROL select DM select DM_SERIAL + select ARCH_COLDFIRE bool config MCF537x select OF_CONTROL select DM select DM_SERIAL + select ARCH_COLDFIRE bool config MCF5441x select OF_CONTROL select DM select DM_SERIAL + select ARCH_COLDFIRE bool +config M680x0 + bool + help + This enables support for the classic Motorola 68000 family of + processors. + # processor type config M5208 bool
@@ -110,6 +124,10 @@ config M54418 bool select MCF5441x +config M68040 + bool + select M680x0 + # peripherals config CF_DSPI bool
@@ -178,6 +196,18 @@ config TARGET_STMARK2 endchoice +config SYS_CPU + string + default "mcf52x2" if MCF52x2 + default "mcf523x" if MCF523x + default "mcf530x" if MCF530x + default "mcf532x" if MCF532x + default "mcf5445x" if MCF5445x + default "m680x0" if M680x0 + +config ARCH_COLDFIRE + bool + source "board/BuS/eb_cpu5282/Kconfig" source "board/cobra5272/Kconfig" source "board/freescale/m5208evbe/Kconfig"
arch/m68k/Makefile +1 -0
@@ -17,6 +17,7 @@ cpuflags-$(CONFIG_M5307) := -mcpu=5307 cpuflags-$(CONFIG_MCF5301x) := -mcpu=53015 -fPIC cpuflags-$(CONFIG_MCF532x) := -mcpu=5329 -fPIC cpuflags-$(CONFIG_MCF5441x) := -mcpu=54418 -fPIC +cpuflags-$(CONFIG_M68040) := -mcpu=68040 -fno-pic PLATFORM_CPPFLAGS += $(cpuflags-y)
arch/m68k/config.mk +8 -2
@@ -3,8 +3,14 @@ # (C) Copyright 2000-2002 # Wolfgang Denk, DENX Software Engineering, [email protected]. -PLATFORM_CPPFLAGS += -D__M68K__ -fPIC +PLATFORM_CPPFLAGS += -D__M68K__ +ifneq ($(CONFIG_M680x0),y) +PLATFORM_CPPFLAGS += -fPIC +endif KBUILD_LDFLAGS += -n -pie PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections -PLATFORM_RELFLAGS += -ffixed-d7 -msep-data +PLATFORM_RELFLAGS += -ffixed-d7 +ifneq ($(CONFIG_M680x0),y) +PLATFORM_RELFLAGS += -msep-data +endif LDFLAGS_FINAL += --gc-sections -pie
arch/m68k/cpu/m680x0/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Copyright (C) 2025, Kuan-Wei Chiu <[email protected]> + +extra-y += start.o +obj-y += cpu.o
arch/m68k/cpu/m680x0/cpu.c new file +73 -0
73 lines not on this page · raw message
arch/m68k/cpu/m680x0/start.S new file +73 -0
73 lines not on this page · raw message
arch/m68k/cpu/m680x0/u-boot.lds new file +47 -0
47 lines not on this page · raw message
arch/m68k/include/asm/bootinfo.h new file +39 -0
@@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* Copyright (C) 2025, Kuan-Wei Chiu <[email protected]> +* +* Definitions for the m68k bootinfo interface. +*/ + +#ifndef _ASM_M68K_BOOTINFO_H +#define _ASM_M68K_BOOTINFO_H + +#ifndef __ASSEMBLY__ + +struct bi_record { +unsigned short tag;/* tag ID */ +unsigned short size;/* size of record (in bytes) */ +unsigned long data[0 ];/* data */ +}; + +#endif /* __ASSEMBLY__ */ + +/* Bootinfo Tag IDs */ +#define BI_LAST 0x0000 +#define BI_MACHTYPE 0x0001 +#define BI_CPUTYPE 0x0002 +#define BI_FPUTYPE 0x0003 +#define BI_MMUTYPE 0x0004 +#define BI_MEMCHUNK 0x0005 +#define BI_RAMDISK 0x0006 +#define BI_COMMAND_LINE 0x0007 + +/* QEMU virt specific tags */ +#define BI_VIRT_QEMU_VERSION 0x8000 +#define BI_VIRT_GF_PIC_BASE 0x8001 +#define BI_VIRT_GF_RTC_BASE 0x8002 +#define BI_VIRT_GF_TTY_BASE 0x8003 +#define BI_VIRT_VIRTIO_BASE 0x8004 +#define BI_VIRT_CTRL_BASE 0x8005 + +#endif /* _ASM_M68K_BOOTINFO_H */
arch/m68k/lib/Makefile +1 -6
@@ -7,10 +7,5 @@ ## if the user asked for it lib-$(CONFIG_USE_PRIVATE_LIBGCC) += lshrdi3.o muldi3.o ashldi3.o ashrdi3.o -obj-y += bdinfo.o obj-$(CONFIG_CMD_BOOTM) += bootm.o -obj-y += cache.o -obj-y += interrupts.o -obj-y += time.o -obj-y += traps.o -obj-y += fec.o +obj-$(CONFIG_ARCH_COLDFIRE) += cache.o interrupts.o time.o traps.o bdinfo.o fec.o
Signature · 1 line
2.52.0.457.g6b5491de43-goog
Re: [PATCH v6 5/8] m68k: Add support for M68040 CPU
Quoted 26 lines · Kuan-Wei Chiu
Add support for the Motorola 68040 architecture. Currently, m68k support in U-Boot is primarily focused on ColdFire variants. Introduce the necessary infrastructure to support the classic M680x0 series, specifically targeting the M68040 as emulated by QEMU.
The implementation includes exception vectors, early startup code, and minimal CPU initialization and relocation stubs. It also defines the standard m68k boot information structure used for passing hardware information to the operating system. To ensure compatibility, ColdFire- specific library objects such as cache and interrupt handling are excluded from the build when M68040 is selected.
Additionally, apply a specific workaround during the early memory reservation stage. Use a manual loop to clear global data instead of the standard
memset()function, as utilizingmemset()at this point was observed to cause a hang on the QEMU platform.Signed-off-by Kuan-Wei Chiu <[email protected]>---
Changes in v6:
- Introduce hiddenKconfigsymbolCONFIG_ARCH_COLDFIREto group ColdFire-specific files inMakefile, removing the need for 'ifndefCONFIG_M680x0'.
- Add help text forCONFIG_M680x0.
Quoted 17 lines
MAINTAINERS | 6 +++ arch/m68k/Kconfig | 30 +++++++++++++ arch/m68k/Makefile | 1 + arch/m68k/config.mk | 10 ++++- arch/m68k/cpu/m680x0/Makefile | 6 +++ arch/m68k/cpu/m680x0/cpu.c | 73 ++++++++++++++++++++++++++++++++ arch/m68k/cpu/m680x0/start.S | 73 ++++++++++++++++++++++++++++++++ arch/m68k/cpu/m680x0/u-boot.lds | 47 ++++++++++++++++++++ arch/m68k/include/asm/bootinfo.h | 39 +++++++++++++++++ arch/m68k/lib/Makefile | 7 +-- 10 files changed, 284 insertions(+), 8 deletions(-) create mode 100644 arch/m68k/cpu/m680x0/Makefile create mode 100644 arch/m68k/cpu/m680x0/cpu.c create mode 100644 arch/m68k/cpu/m680x0/start.S create mode 100644 arch/m68k/cpu/m680x0/u-boot.lds create mode 100644 arch/m68k/include/asm/bootinfo.h
Re: [PATCH v6 5/8] m68k: Add support for M68040 CPU
In reply to Kuan-Wei ChiuHi Kuan-Wei,
i rebuilt all ColdFire boards and this patch is not causing any build issue, and with some quick tests on stmark2 board there are no issues either, nothing is broken.
Thanks a lot.
Quoted 465 lines · Kuan-Wei Chiu
Add support for the Motorola 68040 architecture. Currently, m68k support in U-Boot is primarily focused on ColdFire variants. Introduce the necessary infrastructure to support the classic M680x0 series, specifically targeting the M68040 as emulated by QEMU.
The implementation includes exception vectors, early startup code, and minimal CPU initialization and relocation stubs. It also defines the standard m68k boot information structure used for passing hardware information to the operating system. To ensure compatibility, ColdFire- specific library objects such as cache and interrupt handling are excluded from the build when M68040 is selected.
Additionally, apply a specific workaround during the early memory reservation stage. Use a manual loop to clear global data instead of the standard
memset()function, as utilizingmemset()at this point was observed to cause a hang on the QEMU platform.Signed-off-by Kuan-Wei Chiu <[email protected]>---
Changes in v6:
- Introduce hiddenKconfigsymbolCONFIG_ARCH_COLDFIREto group ColdFire-specific files inMakefile, removing the need for 'ifndefCONFIG_M680x0'.
- Add help text forCONFIG_M680x0.MAINTAINERS | 6 +++ arch/m68k/Kconfig | 30 +++++++++++++ arch/m68k/Makefile | 1 + arch/m68k/config.mk | 10 ++++- arch/m68k/cpu/m680x0/Makefile | 6 +++ arch/m68k/cpu/m680x0/cpu.c | 73 ++++++++++++++++++++++++++++++++ arch/m68k/cpu/m680x0/start.S | 73 ++++++++++++++++++++++++++++++++ arch/m68k/cpu/m680x0/u-boot.lds | 47 ++++++++++++++++++++ arch/m68k/include/asm/bootinfo.h | 39 +++++++++++++++++ arch/m68k/lib/Makefile | 7 +-- 10 files changed, 284 insertions(+), 8 deletions(-) create mode 100644 arch/m68k/cpu/m680x0/Makefile create mode 100644 arch/m68k/cpu/m680x0/cpu.c create mode 100644 arch/m68k/cpu/m680x0/start.S create mode 100644 arch/m68k/cpu/m680x0/u-boot.lds create mode 100644 arch/m68k/include/asm/bootinfo.hMAINTAINERS +6
-0@@ -1324,6 +1324,12 @@ F: lib/getopt.c F: test/log/ F: test/py/tests/test_log.py +M680X0 ARCHITECTURE +M: Kuan-Wei Chiu <[email protected]> +S: Maintained +F: arch/m68k/cpu/m680x0/ +F: arch/m68k/include/asm/bootinfo.h + MALI DISPLAY PROCESSORS M: Liviu Dudau <[email protected]> S: Supportedarch/m68k/Kconfig +30
-0@@ -12,50 +12,64 @@ config MCF520x select OF_CONTROL select DM select DM_SERIAL + select ARCH_COLDFIRE bool config MCF52x2 select OF_CONTROL select DM select DM_SERIAL + select ARCH_COLDFIRE bool config MCF523x select OF_CONTROL select DM select DM_SERIAL + select ARCH_COLDFIRE bool config MCF530x select OF_CONTROL select DM select DM_SERIAL + select ARCH_COLDFIRE bool config MCF5301x select OF_CONTROL select DM select DM_SERIAL + select ARCH_COLDFIRE bool config MCF532x select OF_CONTROL select DM select DM_SERIAL + select ARCH_COLDFIRE bool config MCF537x select OF_CONTROL select DM select DM_SERIAL + select ARCH_COLDFIRE bool config MCF5441x select OF_CONTROL select DM select DM_SERIAL + select ARCH_COLDFIRE bool +config M680x0 + bool + help + This enables support for the classic Motorola 68000 family of + processors. + # processor type config M5208 bool@@ -110,6 +124,10 @@ config M54418 bool select MCF5441x +config M68040 + bool + select M680x0 + # peripherals config CF_DSPI bool@@ -178,6 +196,18 @@ config TARGET_STMARK2 endchoice +config SYS_CPU + string + default "mcf52x2" if MCF52x2 + default "mcf523x" if MCF523x + default "mcf530x" if MCF530x + default "mcf532x" if MCF532x + default "mcf5445x" if MCF5445x + default "m680x0" if M680x0 + +config ARCH_COLDFIRE + bool + source "board/BuS/eb_cpu5282/Kconfig" source "board/cobra5272/Kconfig" source "board/freescale/m5208evbe/Kconfig"arch/m68k/Makefile +1
-0@@ -17,6 +17,7 @@ cpuflags-$(CONFIG_M5307) := -mcpu=5307 cpuflags-$(CONFIG_MCF5301x) := -mcpu=53015 -fPIC cpuflags-$(CONFIG_MCF532x) := -mcpu=5329 -fPIC cpuflags-$(CONFIG_MCF5441x) := -mcpu=54418 -fPIC +cpuflags-$(CONFIG_M68040) := -mcpu=68040 -fno-pic PLATFORM_CPPFLAGS += $(cpuflags-y)arch/m68k/config.mk +8
-2@@ -3,8 +3,14 @@ # (C) Copyright 2000-2002 # Wolfgang Denk, DENX Software Engineering, [email protected]. -PLATFORM_CPPFLAGS += -D__M68K__ -fPIC +PLATFORM_CPPFLAGS += -D__M68K__ +ifneq ($(CONFIG_M680x0),y) +PLATFORM_CPPFLAGS += -fPIC +endif KBUILD_LDFLAGS += -n -pie PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections -PLATFORM_RELFLAGS += -ffixed-d7 -msep-data +PLATFORM_RELFLAGS += -ffixed-d7 +ifneq ($(CONFIG_M680x0),y) +PLATFORM_RELFLAGS += -msep-data +endif LDFLAGS_FINAL += --gc-sections -piearch/m68k/cpu/m680x0/Makefile new file +6
-0@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Copyright (C) 2025, Kuan-Wei Chiu <[email protected]> + +extra-y += start.o +obj-y += cpu.oarch/m68k/cpu/m680x0/cpu.c new file +73
-0@@ -0,0 +1,73 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* CPU specific code for m68040 +* +* Copyright (C) 2025, Kuan-Wei Chiu <[email protected]> +*/ + +#include <config.h> +#include <cpu_func.h> +#include <init.h> +#include <stdio.h> +#include <asm/global_data.h> +#include <linux/types.h> + +DECLARE_GLOBAL_DATA_PTR ; + +void m68k_virt_init_reserve (ulong base) +{ +struct global_data *gd_ptr = (struct global_data *)base; +char *p = (char *)gd_ptr; +unsigned int i; + +/* FIXME: usage of memset() here caused a hang on QEMU m68k virt. */ +for (i =0 ; i <sizeof (*gd_ptr); i++) + p[i] =0 ; + + gd = gd_ptr; + + gd->malloc_base = base +sizeof (*gd_ptr); +} + +int print_cpuinfo (void ) +{ +puts ("CPU: M68040 (QEMU Virt)\n" ); + +return 0 ; +} + +int get_clocks (void ) +{ +return 0 ; +} + +int cpu_init_r (void ) +{ +return 0 ; +} + +/* +* Relocation Stub +* We skip actual relocation for this QEMU bring-up and jump directly +* to board_init_r. +*/ + +void relocate_code (ulong sp,struct global_data *new_gd,ulong relocaddr) +{ +board_init_r (new_gd, relocaddr); +} + +/* Stubs for Standard Facilities (Cache, Interrupts) */ + +int disable_interrupts (void ) {return 0 ; } +void enable_interrupts (void ) {return ; } +int interrupt_init (void ) {return 0 ; } + +void icache_enable (void ) {} +void icache_disable (void ) {} +int icache_status (void ) {return 0 ; } +void dcache_enable (void ) {} +void dcache_disable (void ) {} +int dcache_status (void ) {return 0 ; } +void flush_cache (unsigned long start,unsigned long size) {} +void flush_dcache_range (unsigned long start,unsigned long stop) {}arch/m68k/cpu/m680x0/start.S new file +73
-0@@ -0,0 +1,73 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Startup code for m68040 + * + * Copyright (C) 2025, Kuan-Wei Chiu <[email protected]> + */ + +#include <asm-offsets.h> +#include <config.h> +#include <linux/linkage.h> + +.section .text + +/* + * Vector Table + * m68k uses the first 1KB for the exception vector table. + */ +.balign 4 +.global _vectors +_vectors: + .long CFG_SYS_INIT_SP_ADDR /* 0x00: Initial SP */ + .long _start /* 0x04: Initial PC (Reset) */ + .long _fault /* 0x08: Bus Error */ + .long _fault /* 0x0C: Address Error */ + .long _fault /* 0x10: Illegal Instruction */ + .long _fault /* 0x14: Zero Divide */ + .long _fault /* 0x18: CHK */ + .long _fault /* 0x1C: TRAPV */ + .long _fault /* 0x20: Privilege */ + .long _fault /* 0x24: Trace */ + .long _fault /* 0x28: Line 1010 */ + .long _fault /* 0x2C: Line 1111 */ + .fill 0x400 - (.-_vectors), 1, 0 + +/* + * Entry Point + */ +ENTRY(_start) + /* Disable Interrupts */ + move.w #0x2700, %sr + + /* Setup initial stack pointer */ + move.l #CFG_SYS_INIT_SP_ADDR, %sp + + /* + * Allocate Global Data (GD) + * board_init_f_alloc_reserve(top) returns the new top of stack in %d0 + */ + move.l %sp, -(%sp) + bsr.l board_init_f_alloc_reserve + addq.l #4, %sp + + /* Update Stack Pointer and set GD register */ + move.l %d0, %sp + move.l %d0, %d7 /* %d7 is the gd register */ + + /* Initialize Reserved Memory. */ + move.l %d0, -(%sp) + bsr.l m68k_virt_init_reserve + addq.l #4, %sp + + /* Enter board_init_f(0) */ + clr.l -(%sp) + bsr.l board_init_f + addq.l #4, %sp + + /* Should not return */ +hang: + bra.s hang +ENDPROC(_start) + +_fault: + bra.s _faultarch/m68k/cpu/m680x0/u-boot.lds new file +47
-0@@ -0,0 +1,47 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Linker Script for m68040 + * + * Copyright (C) 2025, Kuan-Wei Chiu <[email protected]> + */ + +OUTPUT_ARCH(m68k) +ENTRY(_start) + +SECTIONS +{ + . = 0x00000000; + __text_start = .; + + .text : + { + arch/m68k/cpu/m680x0/start.o (.text*) + *(.text*) + } + + . = ALIGN(16); + .rodata : { *(.rodata*) } + + . = ALIGN(16); + .data : { *(.data*) } + + . = ALIGN(4); + .u_boot_list : { + KEEP(*(SORT(*u_boot_list*))); + } + + . = ALIGN(4); + __image_copy_end = .; + __init_end = .; + + . = ALIGN(16); + __bss_start = .; + .bss : + { + *(.bss*) + . = ALIGN(16); + } + __bss_end = .; + + _end = .; +}arch/m68k/include/asm/bootinfo.h new file +39
-0@@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* Copyright (C) 2025, Kuan-Wei Chiu <[email protected]> +* +* Definitions for the m68k bootinfo interface. +*/ + +#ifndef _ASM_M68K_BOOTINFO_H +#define _ASM_M68K_BOOTINFO_H + +#ifndef __ASSEMBLY__ + +struct bi_record { +unsigned short tag;/* tag ID */ +unsigned short size;/* size of record (in bytes) */ +unsigned long data[0 ];/* data */ +}; + +#endif /* __ASSEMBLY__ */ + +/* Bootinfo Tag IDs */ +#define BI_LAST 0x0000 +#define BI_MACHTYPE 0x0001 +#define BI_CPUTYPE 0x0002 +#define BI_FPUTYPE 0x0003 +#define BI_MMUTYPE 0x0004 +#define BI_MEMCHUNK 0x0005 +#define BI_RAMDISK 0x0006 +#define BI_COMMAND_LINE 0x0007 + +/* QEMU virt specific tags */ +#define BI_VIRT_QEMU_VERSION 0x8000 +#define BI_VIRT_GF_PIC_BASE 0x8001 +#define BI_VIRT_GF_RTC_BASE 0x8002 +#define BI_VIRT_GF_TTY_BASE 0x8003 +#define BI_VIRT_VIRTIO_BASE 0x8004 +#define BI_VIRT_CTRL_BASE 0x8005 + +#endif /* _ASM_M68K_BOOTINFO_H */ arch/m68k/lib/Makefile +0
-0@@ -7,10 +7,5 @@ ## if the user asked for it
arch/m68k/lib/Makefile line 11
Quoted 10 lines
arch/m68k/lib/Makefile +1
-6lib-$(CONFIG_USE_PRIVATE_LIBGCC) += lshrdi3.o muldi3.o ashldi3.o ashrdi3.o -obj-y += bdinfo.o obj-$(CONFIG_CMD_BOOTM) += bootm.o -obj-y += cache.o -obj-y += interrupts.o -obj-y += time.o -obj-y += traps.o -obj-y += fec.o +obj-$(CONFIG_ARCH_COLDFIRE) += cache.o interrupts.o time.o traps.o bdinfo.o fec.o
-- Angelo
PATCH v6 6/8 board: Add QEMU m68k virt board support
In reply to Kuan-Wei ChiuAdd support for the QEMU 'virt' machine on the m68k architecture. This board emulates a generic machine based on the Motorola 68040 CPU equipped with Goldfish virtual peripherals.
Introduce the necessary board configuration and initialization infrastructure. The implementation includes logic to parse the QEMU bootinfo interface, enabling dynamic detection of system RAM size to adapt to the virtual machine's configuration.
Enable the Goldfish TTY driver for serial console output. Additionally, enable Goldfish RTC and timer drivers to support real-time clock functionality and nanosecond-resolution delays. Include comprehensive documentation covering build instructions and usage examples.
---
Changes in v6:
- Move bootinfo parsing logic to a helper function called in board_early_init_f.
- Remove hardcoded MMIO address macros; use values parsed from bootinfo.
- Use the new sysreset driver via U_BOOT_DRVINFO.
- Use SZ_16M macro for default RAM size.
- Update header include order to match coding style.
- Fix blank line formatting in checkboard().
arch/m68k/Kconfig | 9 ++ board/emulation/qemu-m68k/Kconfig | 12 +++ board/emulation/qemu-m68k/MAINTAINERS | 8 ++ board/emulation/qemu-m68k/Makefile | 5 ++ board/emulation/qemu-m68k/qemu-m68k.c | 117 ++++++++++++++++++++++++++ configs/qemu-m68k_defconfig | 20 +++++ doc/board/emulation/index.rst | 1 + doc/board/emulation/qemu-m68k.rst | 39 +++++++++ include/configs/qemu-m68k.h | 18 ++++ 9 files changed, 229 insertions(+) create mode 100644 board/emulation/qemu-m68k/Kconfig create mode 100644 board/emulation/qemu-m68k/MAINTAINERS create mode 100644 board/emulation/qemu-m68k/Makefile create mode 100644 board/emulation/qemu-m68k/qemu-m68k.c create mode 100644 configs/qemu-m68k_defconfig create mode 100644 doc/board/emulation/qemu-m68k.rst create mode 100644 include/configs/qemu-m68k.h
arch/m68k/Kconfig +9 -0
@@ -194,6 +194,14 @@ config TARGET_STMARK2 select CF_DSPI select M54418 +config TARGET_QEMU_M68K + bool "Support QEMU m68k virt" + select M68040 + imply CMD_DM + help + This target supports the QEMU m68k virtual machine (-M virt). + It simulates a Motorola 68040 CPU with Goldfish peripherals. + endchoice config SYS_CPU
@@ -222,6 +230,7 @@ source "board/freescale/m5329evb/Kconfig" source "board/freescale/m5373evb/Kconfig" source "board/sysam/amcore/Kconfig" source "board/sysam/stmark2/Kconfig" +source "board/emulation/qemu-m68k/Kconfig" config M68K_QEMU bool "Build with workarounds for incomplete QEMU emulation"
board/emulation/qemu-m68k/Kconfig new file +12 -0
@@ -0,0 +1,12 @@ +if TARGET_QEMU_M68K + +config SYS_BOARD + default "qemu-m68k" + +config SYS_VENDOR + default "emulation" + +config SYS_CONFIG_NAME + default "qemu-m68k" + +endif
board/emulation/qemu-m68k/MAINTAINERS new file +8 -0
@@ -0,0 +1,8 @@ +QEMU M68K VIRT BOARD +M: Kuan-Wei Chiu <[email protected]> +S: Maintained +F: board/emulation/qemu-m68k/ +F: board/emulation/common/ +F: include/configs/qemu-m68k.h +F: configs/qemu-m68k_defconfig +F: doc/board/emulation/qemu-m68k.rst
board/emulation/qemu-m68k/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Copyright (C) 2025, Kuan-Wei Chiu <[email protected]> + +obj-y += qemu-m68k.o
board/emulation/qemu-m68k/qemu-m68k.c new file +117 -0
117 lines not on this page · raw message
configs/qemu-m68k_defconfig new file +20 -0
@@ -0,0 +1,20 @@ +CONFIG_M68K=y +CONFIG_TEXT_BASE=0x00000000 +CONFIG_SYS_MALLOC_LEN=0x20000 +CONFIG_SYS_MALLOC_F_LEN=0x2000 +CONFIG_SYS_MONITOR_LEN=262144 +CONFIG_SYS_BOOTM_LEN=0x1000000 +CONFIG_SYS_LOAD_ADDR=0x00000000 +CONFIG_TARGET_QEMU_M68K=y +# CONFIG_DISPLAY_BOARDINFO is not set +CONFIG_BOARD_EARLY_INIT_F=y +CONFIG_CMD_POWEROFF=y +CONFIG_DM_RTC=y +CONFIG_RTC_GOLDFISH=y +CONFIG_DM_SERIAL=y +CONFIG_SERIAL_GOLDFISH=y +CONFIG_SYSRESET=y +CONFIG_SYSRESET_CMD_POWEROFF=y +CONFIG_SYSRESET_QEMU_VIRT_CTRL=y +CONFIG_TIMER=y +CONFIG_GOLDFISH_TIMER=y
doc/board/emulation/index.rst +1 -0
@@ -15,6 +15,7 @@ Emulation qemu-sbsa qemu-x86 qemu-xtensa + qemu-m68k Also see
doc/board/emulation/qemu-m68k.rst new file +39 -0
@@ -0,0 +1,39 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later +.. Copyright (C) 2025, Kuan-Wei Chiu <[email protected]> + +QEMU m68k +========= + +QEMU for m68k supports a special 'virt' machine designed for emulation and +virtualization purposes. This document describes how to run U-Boot under it. + +The QEMU virt machine models a generic m68k virtual machine with Goldfish +interfaces. It supports the Motorola 68040 CPU architecture. + +Building U-Boot +--------------- +Set the CROSS_COMPILE environment variable to your m68k toolchain, and run: + +.. code-block:: bash + + export CROSS_COMPILE=m68k-linux-gnu- + make qemu-m68k_defconfig + make + +Running U-Boot +-------------- +The minimal QEMU command line to get U-Boot up and running is: + +.. code-block:: bash + + qemu-system-m68k -M virt -cpu m68040 -nographic -kernel u-boot + +Note that the `-nographic` option is used to redirect the console to stdio, +which connects to the emulated Goldfish TTY device. + +Hardware Support +---------------- +The following QEMU virt peripherals are supported in U-Boot: + +* Goldfish TTY (Serial Console) +* Goldfish RTC (Real Time Clock)
include/configs/qemu-m68k.h new file +18 -0
@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* Copyright (C) 2025, Kuan-Wei Chiu <[email protected]> +*/ + +#ifndef __QEMU_M68K_H +#define __QEMU_M68K_H + +/* Memory Configuration */ +#define CFG_SYS_SDRAM_BASE 0x00000000 + +/* +* Initial Stack Pointer: +* Place the stack at 4MB offset to avoid overwriting U-Boot code/data. +*/ +#define CFG_SYS_INIT_SP_ADDR (CFG_SYS_SDRAM_BASE + 0x400000) + +#endif /* __QEMU_M68K_H */
Signature · 1 line
2.52.0.457.g6b5491de43-goog
Re: [PATCH v6 6/8] board: Add QEMU m68k virt board support
Quoted 37 lines · Kuan-Wei Chiu
Add support for the QEMU 'virt' machine on the m68k architecture. This board emulates a generic machine based on the Motorola 68040 CPU equipped with Goldfish virtual peripherals.
Introduce the necessary board configuration and initialization infrastructure. The implementation includes logic to parse the QEMU bootinfo interface, enabling dynamic detection of system RAM size to adapt to the virtual machine's configuration.
Enable the Goldfish TTY driver for serial console output. Additionally, enable Goldfish RTC and timer drivers to support real-time clock functionality and nanosecond-resolution delays. Include comprehensive documentation covering build instructions and usage examples.
Signed-off-by Kuan-Wei Chiu <[email protected]>Tested-by Daniel Palmer <[email protected]>---
Changes in v6:
- Move bootinfo parsing logic to a helper function called inboard_early_init_f.
- Remove hardcoded MMIO address macros; use values parsed from bootinfo.
- Use the new sysreset driver viaU_BOOT_DRVINFO.
- UseSZ_16Mmacro for default RAM size.
- Update header include order to match coding style.
- Fix blank line formatting incheckboard().arch/m68k/Kconfig | 9 ++ board/emulation/qemu-m68k/Kconfig | 12 +++ board/emulation/qemu-m68k/MAINTAINERS | 8 ++ board/emulation/qemu-m68k/Makefile | 5 ++ board/emulation/qemu-m68k/qemu-m68k.c | 117 ++++++++++++++++++++++++++ configs/qemu-m68k_defconfig | 20 +++++ doc/board/emulation/index.rst | 1 + doc/board/emulation/qemu-m68k.rst | 39 +++++++++ include/configs/qemu-m68k.h | 18 ++++
Quoted 9 lines
9 files changed, 229 insertions(+) create mode 100644 board/emulation/qemu-m68k/Kconfig create mode 100644 board/emulation/qemu-m68k/MAINTAINERS create mode 100644 board/emulation/qemu-m68k/Makefile create mode 100644 board/emulation/qemu-m68k/qemu-m68k.c create mode 100644 configs/qemu-m68k_defconfig create mode 100644 doc/board/emulation/qemu-m68k.rst create mode 100644 include/configs/qemu-m68k.h
PATCH v6 7/8 CI: Add test jobs for QEMU m68k virt machine
In reply to Kuan-Wei ChiuEnable CI testing for the newly introduced QEMU m68k 'virt' board on both GitLab CI and Azure Pipelines. This ensures the new M68040 architecture support is built and booted correctly in the emulated environment.
---
Changes in v6:
- None.
.azure-pipelines.yml | 3 +++ .gitlab-ci.yml | 6 ++++++ 2 files changed, 9 insertions(+)
.azure-pipelines.yml +3 -0
@@ -520,6 +520,9 @@ stages: TEST_PY_ID: "--id qemu" TEST_PY_TEST_SPEC: "not sleep and not efi" OVERRIDE: "-a CONFIG_M68K_QEMU=y -a ~CONFIG_MCFTMR" + qemu_m68k_virt: + TEST_PY_BD: "qemu-m68k" + TEST_PY_TEST_SPEC: "not sleep" qemu_malta: TEST_PY_BD: "malta" TEST_PY_ID: "--id qemu"
.gitlab-ci.yml +6 -0
@@ -417,6 +417,12 @@ qemu_m68k test.py: OVERRIDE: "-a CONFIG_M68K_QEMU=y -a ~CONFIG_MCFTMR" <<: *buildman_and_testpy_dfn +qemu_m68k_virt test.py: + variables: + TEST_PY_BD: "qemu-m68k" + TEST_PY_TEST_SPEC: "not sleep" + <<: *buildman_and_testpy_dfn + qemu_malta test.py: variables: TEST_PY_BD: "malta"
Signature · 1 line
2.52.0.457.g6b5491de43-goog
PATCH v6 8/8 MAINTAINERS: Update m68k entry
In reply to Kuan-Wei ChiuRename the "COLDFIRE" entry to "M68K" to reflect that the architecture support now encompasses traditional m680x0 CPUs (e.g., M68040) in addition to ColdFire platforms.
Remove Huan Wang from the maintainers list as she is no longer active, as suggested by Angelo Dureghello.
Add myself as a co-maintainer to assist with reviewing and testing m68k-related patches.
---
Changes in v6:
- Remove Huan Wang from MAINTAINERS as suggested by Angelo Dureghello.
MAINTAINERS | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
MAINTAINERS +2 -2
@@ -1045,9 +1045,9 @@ T: git https://source.denx.de/u-boot/custodians/u-boot-clk.git F: drivers/clk/ F: drivers/clk/imx/ -COLDFIRE -M: Huan Wang <[email protected]> +M68K M: Angelo Dureghello <[email protected]> +M: Kuan-Wei Chiu <[email protected]> S: Maintained T: git https://source.denx.de/u-boot/custodians/u-boot-coldfire.git F: arch/m68k/
Signature · 1 line
2.52.0.457.g6b5491de43-goog
Quoted 10 lines · Kuan-Wei Chiu
Add support for the QEMU 'virt' machine on the m68k architecture. The QEMU virt machine models a generic system utilizing Goldfish virtual peripherals and is capable of emulating various classic 68k CPUs.
Currently, U-Boot's m68k architecture support focuses on ColdFire variants. This series expands support to include the classic M680x0 architecture, implementing the necessary exception vectors, startup code, and a bootinfo parser compatible with the QEMU interface.
[...]
Applied to u-boot/master, thanks!
[1/8] serial: Add Goldfish TTY driver
commit: bf55b84736d6b220dae11e3b1e7a670918d9daee
[2/8] timer: Add Goldfish timer driver
commit: 909f717eaf299a97fb87307e8606f3fdc6cb0c14
[3/8] rtc: goldfish: Support platform data for non-DT probing
commit: b41c54488f6f8263c8b38a6cf97d106c3f9a65bb
[4/8] sysreset: Add QEMU virtual system controller driver
commit: 0429298a1a76b971c0b0156918f927d6329e53bc
[5/8] m68k: Add support for M68040 CPU
commit: c69b6aeaa35550d386c142302b852d6b72aea76f
[6/8] board: Add QEMU m68k virt board support
commit: 516afc8f76268fceb98f6b891a653484e931b26a
[7/8] CI: Add test jobs for QEMU m68k virt machine
commit: b21d9acdff871d9113ec8b70d9b12e6dbc4bd0c5
[8/8] MAINTAINERS: Update m68k entry
commit: 838e3be9e1d39e38661a788ae3bcfb9f989450a8Signature · 1 line
Tom