* [PATCH 1/3] serial: Add Goldfish TTY driver
2025-12-18 18:52 [PATCH 0/3] m68k: Add support for QEMU virt machine Kuan-Wei Chiu
@ 2025-12-18 18:52 ` Kuan-Wei Chiu
2025-12-19 3:14 ` Yao Zi
2025-12-18 18:52 ` [PATCH 2/3] m68k: Add support for M68040 CPU Kuan-Wei Chiu
` (2 subsequent siblings)
3 siblings, 1 reply; 22+ messages in thread
From: Kuan-Wei Chiu @ 2025-12-18 18:52 UTC (permalink / raw)
To: alison.wang, angelo; +Cc: trini, jserv, eleanor15x, u-boot, Kuan-Wei Chiu
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.
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
---
MAINTAINERS | 6 ++
drivers/serial/Kconfig | 8 +++
drivers/serial/Makefile | 1 +
drivers/serial/serial_goldfish.c | 112 +++++++++++++++++++++++++++++++
include/goldfish_tty.h | 18 +++++
5 files changed, 145 insertions(+)
create mode 100644 drivers/serial/serial_goldfish.c
create mode 100644 include/goldfish_tty.h
diff --git a/MAINTAINERS b/MAINTAINERS
index 6ce0bbce13d..da4a6e4d518 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1259,6 +1259,12 @@ S: Maintained
F: drivers/misc/gsc.c
F: include/gsc.h
+GOLDFISH SERIAL DRIVER
+M: Kuan-Wei Chiu <visitorckw@gmail.com>
+S: Maintained
+F: drivers/serial/serial_goldfish.c
+F: include/goldfish_tty.h
+
I2C
M: Heiko Schocher <hs@nabladev.com>
S: Maintained
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 371d7aa5bba..b84cb9ec781 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -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
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index 8eaae62b0fc..fe8d23be512 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -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
diff --git a/drivers/serial/serial_goldfish.c b/drivers/serial/serial_goldfish.c
new file mode 100644
index 00000000000..85d2a93b6ff
--- /dev/null
+++ b/drivers/serial/serial_goldfish.c
@@ -0,0 +1,112 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2025, Kuan-Wei Chiu <visitorckw@gmail.com>
+ * Goldfish TTY driver for U-Boot
+ */
+
+#include <dm.h>
+#include <serial.h>
+#include <goldfish_tty.h>
+#include <asm/io.h>
+#include <linux/types.h>
+
+/* Goldfish TTY Register Offsets */
+#define GOLDFISH_TTY_PUT_CHAR 0x00
+#define GOLDFISH_TTY_BYTES_READY 0x04
+#define GOLDFISH_TTY_CMD 0x08
+#define GOLDFISH_TTY_DATA_PTR 0x10
+#define GOLDFISH_TTY_DATA_LEN 0x14
+#define GOLDFISH_TTY_DATA_PTR_HIGH 0x18
+#define GOLDFISH_TTY_VERSION 0x20
+
+/* Commands */
+#define CMD_WRITE_BUFFER 2
+#define CMD_READ_BUFFER 3
+
+struct goldfish_tty_priv {
+ void __iomem *base;
+};
+
+static int goldfish_serial_getc(struct udevice *dev)
+{
+ static u8 rx_buf[4];
+ struct goldfish_tty_priv *priv = dev_get_priv(dev);
+ unsigned long base = (unsigned long)priv->base;
+ unsigned long paddr;
+ u32 count;
+
+ count = __raw_readl((void *)(base + GOLDFISH_TTY_BYTES_READY));
+ if (count == 0)
+ return -EAGAIN;
+
+ if (count > sizeof(rx_buf))
+ count = sizeof(rx_buf);
+
+ paddr = virt_to_phys((void *)rx_buf);
+
+ rx_buf[0] = 0xAA;
+
+ __raw_writel(0, (void *)(base + GOLDFISH_TTY_DATA_PTR_HIGH));
+ __raw_writel(paddr, (void *)(base + GOLDFISH_TTY_DATA_PTR));
+ __raw_writel(count, (void *)(base + GOLDFISH_TTY_DATA_LEN));
+
+ __raw_writel(CMD_READ_BUFFER, (void *)(base + GOLDFISH_TTY_CMD));
+
+ if (rx_buf[0] == 0xAA)
+ return -EAGAIN;
+
+ return rx_buf[0];
+}
+
+static int goldfish_serial_putc(struct udevice *dev, const char ch)
+{
+ struct goldfish_tty_priv *priv = dev_get_priv(dev);
+
+ __raw_writel(ch, priv->base + GOLDFISH_TTY_PUT_CHAR);
+
+ return 0;
+}
+
+static int goldfish_serial_pending(struct udevice *dev, bool input)
+{
+ struct goldfish_tty_priv *priv = dev_get_priv(dev);
+
+ if (input)
+ return __raw_readl(priv->base + GOLDFISH_TTY_BYTES_READY);
+
+ return 0;
+}
+
+static int goldfish_serial_probe(struct udevice *dev)
+{
+ struct goldfish_tty_priv *priv = dev_get_priv(dev);
+ struct goldfish_tty_plat *plat = dev_get_plat(dev);
+
+ if (!plat)
+ return -EINVAL;
+
+ priv->base = plat->base;
+
+ return 0;
+}
+
+static const struct dm_serial_ops goldfish_serial_ops = {
+ .putc = goldfish_serial_putc,
+ .pending = goldfish_serial_pending,
+ .getc = goldfish_serial_getc,
+};
+
+static const struct udevice_id goldfish_serial_ids[] = {
+ { .compatible = "google,goldfish-tty" },
+ { }
+};
+
+U_BOOT_DRIVER(serial_goldfish) = {
+ .name = "serial_goldfish",
+ .id = UCLASS_SERIAL,
+ .of_match = goldfish_serial_ids,
+ .probe = goldfish_serial_probe,
+ .ops = &goldfish_serial_ops,
+ .priv_auto = sizeof(struct goldfish_tty_priv),
+ .flags = DM_FLAG_PRE_RELOC,
+};
diff --git a/include/goldfish_tty.h b/include/goldfish_tty.h
new file mode 100644
index 00000000000..5a74bdcd87d
--- /dev/null
+++ b/include/goldfish_tty.h
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2025, Kuan-Wei Chiu <visitorckw@gmail.com>
+ */
+
+#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 {
+ void __iomem *base;
+};
+
+#endif /* _GOLDFISH_TTY_H_ */
--
2.52.0.322.g1dd061c0dc-goog
^ permalink raw reply related [flat|nested] 22+ messages in thread* Re: [PATCH 1/3] serial: Add Goldfish TTY driver
2025-12-18 18:52 ` [PATCH 1/3] serial: Add Goldfish TTY driver Kuan-Wei Chiu
@ 2025-12-19 3:14 ` Yao Zi
2025-12-20 16:28 ` Kuan-Wei Chiu
0 siblings, 1 reply; 22+ messages in thread
From: Yao Zi @ 2025-12-19 3:14 UTC (permalink / raw)
To: Kuan-Wei Chiu, alison.wang, angelo; +Cc: trini, jserv, eleanor15x, u-boot
On Thu, Dec 18, 2025 at 06:52:50PM +0000, Kuan-Wei Chiu wrote:
> 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.
>
> Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
> ---
> MAINTAINERS | 6 ++
> drivers/serial/Kconfig | 8 +++
> drivers/serial/Makefile | 1 +
> drivers/serial/serial_goldfish.c | 112 +++++++++++++++++++++++++++++++
> include/goldfish_tty.h | 18 +++++
> 5 files changed, 145 insertions(+)
> create mode 100644 drivers/serial/serial_goldfish.c
> create mode 100644 include/goldfish_tty.h
...
> diff --git a/drivers/serial/serial_goldfish.c b/drivers/serial/serial_goldfish.c
> new file mode 100644
> index 00000000000..85d2a93b6ff
> --- /dev/null
> +++ b/drivers/serial/serial_goldfish.c
> @@ -0,0 +1,112 @@
> +// SPDX-License-Identifier: GPL-2.0+
GPL-2.0+ has been deprecated as a SPDX license identifier.
GPL-2.0-or-later should probably be used instead[1].
> +/*
> + * Copyright (C) 2025, Kuan-Wei Chiu <visitorckw@gmail.com>
> + * Goldfish TTY driver for U-Boot
> + */
> +
> +#include <dm.h>
> +#include <serial.h>
> +#include <goldfish_tty.h>
> +#include <asm/io.h>
> +#include <linux/types.h>
It looks better if you sort the headers :)
...
> +static int goldfish_serial_getc(struct udevice *dev)
> +{
> + static u8 rx_buf[4];
> + struct goldfish_tty_priv *priv = dev_get_priv(dev);
> + unsigned long base = (unsigned long)priv->base;
> + unsigned long paddr;
> + u32 count;
> +
> + count = __raw_readl((void *)(base + GOLDFISH_TTY_BYTES_READY));
> + if (count == 0)
> + return -EAGAIN;
> +
> + if (count > sizeof(rx_buf))
> + count = sizeof(rx_buf);
> +
> + paddr = virt_to_phys((void *)rx_buf);
> +
> + rx_buf[0] = 0xAA;
> +
> + __raw_writel(0, (void *)(base + GOLDFISH_TTY_DATA_PTR_HIGH));
> + __raw_writel(paddr, (void *)(base + GOLDFISH_TTY_DATA_PTR));
> + __raw_writel(count, (void *)(base + GOLDFISH_TTY_DATA_LEN));
You send a command that reads count bytes, where count represents the
maximum of bytes available in the buffer and sizeof(rx_buf), so it's
possible to read more than one character...
> + __raw_writel(CMD_READ_BUFFER, (void *)(base + GOLDFISH_TTY_CMD));
> +
> + if (rx_buf[0] == 0xAA)
> + return -EAGAIN;
> +
> + return rx_buf[0];
But only the first character in the buffer is finally returned. Isn't
the following characters (if present) are incorrectly discarded?
rx_buf is declared as static in this case. Are you originally intended
to do some type of buffering here?
Additionally, I don't get the point of setting rx_buf[0] to 0xaa then
checks whether it changes after sending CMD_READ_BUFFER. Is there a case
that CMD_READ_BUFFER would fail even when reading TTY_BYTES_READY
returns non-zero? I had a brief look at qemu's goldfish tty
implementation, but didn't find such situation.
> +}
Best regards,
Yao Zi
[1]: https://lore.kernel.org/u-boot/20251212142859.GQ303283@bill-the-cat
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH 1/3] serial: Add Goldfish TTY driver
2025-12-19 3:14 ` Yao Zi
@ 2025-12-20 16:28 ` Kuan-Wei Chiu
2025-12-21 2:58 ` Yao Zi
0 siblings, 1 reply; 22+ messages in thread
From: Kuan-Wei Chiu @ 2025-12-20 16:28 UTC (permalink / raw)
To: Yao Zi; +Cc: alison.wang, angelo, trini, jserv, eleanor15x, u-boot
Hi Yao,
On Fri, Dec 19, 2025 at 03:14:03AM +0000, Yao Zi wrote:
> On Thu, Dec 18, 2025 at 06:52:50PM +0000, Kuan-Wei Chiu wrote:
> > 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.
> >
> > Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
> > ---
> > MAINTAINERS | 6 ++
> > drivers/serial/Kconfig | 8 +++
> > drivers/serial/Makefile | 1 +
> > drivers/serial/serial_goldfish.c | 112 +++++++++++++++++++++++++++++++
> > include/goldfish_tty.h | 18 +++++
> > 5 files changed, 145 insertions(+)
> > create mode 100644 drivers/serial/serial_goldfish.c
> > create mode 100644 include/goldfish_tty.h
>
> ...
>
> > diff --git a/drivers/serial/serial_goldfish.c b/drivers/serial/serial_goldfish.c
> > new file mode 100644
> > index 00000000000..85d2a93b6ff
> > --- /dev/null
> > +++ b/drivers/serial/serial_goldfish.c
> > @@ -0,0 +1,112 @@
> > +// SPDX-License-Identifier: GPL-2.0+
>
> GPL-2.0+ has been deprecated as a SPDX license identifier.
> GPL-2.0-or-later should probably be used instead[1].
Thanks for the pointer. I wasn't aware of that.
I will update it in all the other files as well in v2.
>
> > +/*
> > + * Copyright (C) 2025, Kuan-Wei Chiu <visitorckw@gmail.com>
> > + * Goldfish TTY driver for U-Boot
> > + */
> > +
> > +#include <dm.h>
> > +#include <serial.h>
> > +#include <goldfish_tty.h>
> > +#include <asm/io.h>
> > +#include <linux/types.h>
>
> It looks better if you sort the headers :)
Sure. Will do. :)
>
> ...
>
> > +static int goldfish_serial_getc(struct udevice *dev)
> > +{
> > + static u8 rx_buf[4];
> > + struct goldfish_tty_priv *priv = dev_get_priv(dev);
> > + unsigned long base = (unsigned long)priv->base;
> > + unsigned long paddr;
> > + u32 count;
> > +
> > + count = __raw_readl((void *)(base + GOLDFISH_TTY_BYTES_READY));
> > + if (count == 0)
> > + return -EAGAIN;
> > +
> > + if (count > sizeof(rx_buf))
> > + count = sizeof(rx_buf);
> > +
> > + paddr = virt_to_phys((void *)rx_buf);
> > +
> > + rx_buf[0] = 0xAA;
> > +
> > + __raw_writel(0, (void *)(base + GOLDFISH_TTY_DATA_PTR_HIGH));
> > + __raw_writel(paddr, (void *)(base + GOLDFISH_TTY_DATA_PTR));
> > + __raw_writel(count, (void *)(base + GOLDFISH_TTY_DATA_LEN));
>
> You send a command that reads count bytes, where count represents the
> maximum of bytes available in the buffer and sizeof(rx_buf), so it's
> possible to read more than one character...
>
> > + __raw_writel(CMD_READ_BUFFER, (void *)(base + GOLDFISH_TTY_CMD));
> > +
> > + if (rx_buf[0] == 0xAA)
> > + return -EAGAIN;
> > +
> > + return rx_buf[0];
>
> But only the first character in the buffer is finally returned. Isn't
> the following characters (if present) are incorrectly discarded?
You're right. Requesting multiple bytes causes the hardware to drop
subsequent characters since getc only consumes one.
I will set the read length to 1 in v2.
>
> rx_buf is declared as static in this case. Are you originally intended
> to do some type of buffering here?
Originally, I used static to avoid performing DMA on the stack.
However, I realize that this introduces re-entrancy issues, which
prevents supporting multiple device instances properly.
In v2, I will move the buffer into struct goldfish_tty_priv.
>
> Additionally, I don't get the point of setting rx_buf[0] to 0xaa then
> checks whether it changes after sending CMD_READ_BUFFER. Is there a case
> that CMD_READ_BUFFER would fail even when reading TTY_BYTES_READY
> returns non-zero? I had a brief look at qemu's goldfish tty
> implementation, but didn't find such situation.
TBH, this is debug code used during development that I should have
removed before submitting. I will remove it in v2.
For reference, here is the planned update for v2:
struct goldfish_tty_priv {
void __iomem *base;
u8 rx_buf;
};
static int goldfish_serial_getc(struct udevice *dev)
{
struct goldfish_tty_priv *priv = dev_get_priv(dev);
unsigned long base = (unsigned long)priv->base;
unsigned long paddr;
u32 count;
count = __raw_readl((void *)(base + GOLDFISH_TTY_BYTES_READY));
if (count == 0)
return -EAGAIN;
paddr = virt_to_phys((void *)&priv->rx_buf);
__raw_writel(0, (void *)(base + GOLDFISH_TTY_DATA_PTR_HIGH));
__raw_writel(paddr, (void *)(base + GOLDFISH_TTY_DATA_PTR));
__raw_writel(1, (void *)(base + GOLDFISH_TTY_DATA_LEN));
__raw_writel(CMD_READ_BUFFER, (void *)(base + GOLDFISH_TTY_CMD));
return priv->rx_buf;
}
Regards,
Kuan-Wei
>
> > +}
>
> Best regards,
> Yao Zi
>
> [1]: https://lore.kernel.org/u-boot/20251212142859.GQ303283@bill-the-cat
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH 1/3] serial: Add Goldfish TTY driver
2025-12-20 16:28 ` Kuan-Wei Chiu
@ 2025-12-21 2:58 ` Yao Zi
0 siblings, 0 replies; 22+ messages in thread
From: Yao Zi @ 2025-12-21 2:58 UTC (permalink / raw)
To: Kuan-Wei Chiu; +Cc: alison.wang, angelo, trini, jserv, eleanor15x, u-boot
On Sun, Dec 21, 2025 at 12:28:49AM +0800, Kuan-Wei Chiu wrote:
> Hi Yao,
>
> On Fri, Dec 19, 2025 at 03:14:03AM +0000, Yao Zi wrote:
> > On Thu, Dec 18, 2025 at 06:52:50PM +0000, Kuan-Wei Chiu wrote:
> > > 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.
> > >
> > > Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
> > > ---
> > > MAINTAINERS | 6 ++
> > > drivers/serial/Kconfig | 8 +++
> > > drivers/serial/Makefile | 1 +
> > > drivers/serial/serial_goldfish.c | 112 +++++++++++++++++++++++++++++++
> > > include/goldfish_tty.h | 18 +++++
> > > 5 files changed, 145 insertions(+)
> > > create mode 100644 drivers/serial/serial_goldfish.c
> > > create mode 100644 include/goldfish_tty.h
...
> For reference, here is the planned update for v2:
>
> struct goldfish_tty_priv {
> void __iomem *base;
> u8 rx_buf;
> };
>
> static int goldfish_serial_getc(struct udevice *dev)
> {
> struct goldfish_tty_priv *priv = dev_get_priv(dev);
> unsigned long base = (unsigned long)priv->base;
> unsigned long paddr;
> u32 count;
>
> count = __raw_readl((void *)(base + GOLDFISH_TTY_BYTES_READY));
> if (count == 0)
> return -EAGAIN;
>
> paddr = virt_to_phys((void *)&priv->rx_buf);
>
> __raw_writel(0, (void *)(base + GOLDFISH_TTY_DATA_PTR_HIGH));
> __raw_writel(paddr, (void *)(base + GOLDFISH_TTY_DATA_PTR));
> __raw_writel(1, (void *)(base + GOLDFISH_TTY_DATA_LEN));
>
> __raw_writel(CMD_READ_BUFFER, (void *)(base + GOLDFISH_TTY_CMD));
>
> return priv->rx_buf;
> }
Thanks for the explanation, this version looks fine to me.
> Regards,
> Kuan-Wei
Regards,
Yao Zi
> > > +}
> >
> > Best regards,
> > Yao Zi
> >
> > [1]: https://lore.kernel.org/u-boot/20251212142859.GQ303283@bill-the-cat
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 2/3] m68k: Add support for M68040 CPU
2025-12-18 18:52 [PATCH 0/3] m68k: Add support for QEMU virt machine Kuan-Wei Chiu
2025-12-18 18:52 ` [PATCH 1/3] serial: Add Goldfish TTY driver Kuan-Wei Chiu
@ 2025-12-18 18:52 ` Kuan-Wei Chiu
2025-12-18 19:00 ` Tom Rini
2025-12-21 4:53 ` Daniel Palmer
2025-12-18 18:52 ` [PATCH 3/3] board: Add QEMU m68k virt board support Kuan-Wei Chiu
2025-12-18 19:00 ` [PATCH 0/3] m68k: Add support for QEMU virt machine Tom Rini
3 siblings, 2 replies; 22+ messages in thread
From: Kuan-Wei Chiu @ 2025-12-18 18:52 UTC (permalink / raw)
To: alison.wang, angelo; +Cc: trini, jserv, eleanor15x, u-boot, Kuan-Wei Chiu
Add support for the Motorola 68040 architecture. Currently, m68k
support in U-Boot is primarily focused on ColdFire (MCF5xxx) 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.
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
---
arch/m68k/Kconfig | 15 ++++++
arch/m68k/Makefile | 1 +
arch/m68k/config.mk | 10 +++-
arch/m68k/cpu/m68040/Makefile | 6 +++
arch/m68k/cpu/m68040/cpu.c | 77 +++++++++++++++++++++++++++++
arch/m68k/cpu/m68040/start.S | 83 ++++++++++++++++++++++++++++++++
arch/m68k/cpu/m68040/u-boot.lds | 47 ++++++++++++++++++
arch/m68k/include/asm/bootinfo.h | 31 ++++++++++++
arch/m68k/lib/Makefile | 9 ++--
9 files changed, 271 insertions(+), 8 deletions(-)
create mode 100644 arch/m68k/cpu/m68040/Makefile
create mode 100644 arch/m68k/cpu/m68040/cpu.c
create mode 100644 arch/m68k/cpu/m68040/start.S
create mode 100644 arch/m68k/cpu/m68040/u-boot.lds
create mode 100644 arch/m68k/include/asm/bootinfo.h
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 8ade6f7b9d1..a41c375f6be 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -56,6 +56,9 @@ config MCF5441x
select DM_SERIAL
bool
+config M68040
+ bool
+
# processor type
config M5208
bool
@@ -178,6 +181,18 @@ config TARGET_STMARK2
endchoice
+config SYS_CPU
+ string
+ default "mcf52x2" if MCF52x2
+ default "mcf520x" if MCF520x
+ default "mcf523x" if MCF523x
+ default "mcf530x" if MCF530x
+ default "mcf5301x" if MCF5301x
+ default "mcf532x" if MCF532x
+ default "mcf537x" if MCF537x
+ default "mcf5441x" if MCF5441x
+ default "m68040" if M68040
+
source "board/BuS/eb_cpu5282/Kconfig"
source "board/cobra5272/Kconfig"
source "board/freescale/m5208evbe/Kconfig"
diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile
index 4a7960bbeb4..8a1a7944443 100644
--- a/arch/m68k/Makefile
+++ b/arch/m68k/Makefile
@@ -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)
diff --git a/arch/m68k/config.mk b/arch/m68k/config.mk
index 643b7d1d35d..3f0ae51e75b 100644
--- a/arch/m68k/config.mk
+++ b/arch/m68k/config.mk
@@ -3,8 +3,14 @@
# (C) Copyright 2000-2002
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
-PLATFORM_CPPFLAGS += -D__M68K__ -fPIC
+PLATFORM_CPPFLAGS += -D__M68K__
+ifneq ($(CONFIG_M68040),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_M68040),y)
+PLATFORM_RELFLAGS += -msep-data
+endif
LDFLAGS_FINAL += --gc-sections -pie
diff --git a/arch/m68k/cpu/m68040/Makefile b/arch/m68k/cpu/m68040/Makefile
new file mode 100644
index 00000000000..c65ae5381d0
--- /dev/null
+++ b/arch/m68k/cpu/m68040/Makefile
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (C) 2025, Kuan-Wei Chiu <visitorckw@gmail.com>
+
+extra-y += start.o
+obj-y += cpu.o
diff --git a/arch/m68k/cpu/m68040/cpu.c b/arch/m68k/cpu/m68040/cpu.c
new file mode 100644
index 00000000000..1b5e35d0a12
--- /dev/null
+++ b/arch/m68k/cpu/m68040/cpu.c
@@ -0,0 +1,77 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * CPU specific code for QEMU M68040
+ *
+ * Copyright (C) 2025, Kuan-Wei Chiu <visitorckw@gmail.com>
+ */
+
+#include <config.h>
+#include <init.h>
+#include <asm/global_data.h>
+#include <linux/types.h>
+#include <cpu_func.h>
+#include <stdio.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, Timer) */
+
+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) {}
+
+int timer_init(void) { return 0; }
+unsigned long timer_read_counter(void) { return 0; }
+ulong get_tbclk(void) { return 1000000; }
+void __udelay(unsigned long usec) {}
diff --git a/arch/m68k/cpu/m68040/start.S b/arch/m68k/cpu/m68040/start.S
new file mode 100644
index 00000000000..3ede70863ad
--- /dev/null
+++ b/arch/m68k/cpu/m68040/start.S
@@ -0,0 +1,83 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Startup code for QEMU m68k virt board
+ *
+ * Copyright (C) 2025, Kuan-Wei Chiu <visitorckw@gmail.com>
+ */
+
+#include <config.h>
+#include <linux/linkage.h>
+#include <asm-offsets.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
+
+ /* Get relocaddr from GD */
+ move.l GD_RELOCADDR(%d7), %d0
+
+ /* Push arguments */
+ move.l %d0, -(%sp) /* Arg3: relocaddr */
+ move.l %d7, -(%sp) /* Arg2: new_gd */
+ move.l %sp, -(%sp) /* Arg1: sp (Current Stack Pointer) */
+
+ bsr.l relocate_code
+
+ /* Should not return */
+hang:
+ bra.s hang
+ENDPROC(_start)
+
+_fault:
+ bra.s _fault
diff --git a/arch/m68k/cpu/m68040/u-boot.lds b/arch/m68k/cpu/m68040/u-boot.lds
new file mode 100644
index 00000000000..e44ad4465e6
--- /dev/null
+++ b/arch/m68k/cpu/m68040/u-boot.lds
@@ -0,0 +1,47 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Linker Script for QEMU m68k virt board
+ *
+ * Copyright (C) 2025, Kuan-Wei Chiu <visitorckw@gmail.com>
+ */
+
+OUTPUT_ARCH(m68k)
+ENTRY(_start)
+
+SECTIONS
+{
+ . = 0x00000000;
+ __text_start = .;
+
+ .text :
+ {
+ arch/m68k/cpu/m68040/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 = .;
+}
diff --git a/arch/m68k/include/asm/bootinfo.h b/arch/m68k/include/asm/bootinfo.h
new file mode 100644
index 00000000000..14fbf62387b
--- /dev/null
+++ b/arch/m68k/include/asm/bootinfo.h
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2025, Kuan-Wei Chiu <visitorckw@gmail.com>
+ *
+ * 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
+
+#endif /* _ASM_M68K_BOOTINFO_H */
diff --git a/arch/m68k/lib/Makefile b/arch/m68k/lib/Makefile
index 6e1fd938f52..d6a1b3546c1 100644
--- a/arch/m68k/lib/Makefile
+++ b/arch/m68k/lib/Makefile
@@ -7,10 +7,7 @@
## 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
+ifndef CONFIG_M68040
+obj-y += cache.o interrupts.o time.o traps.o bdinfo.o fec.o
+endif
--
2.52.0.322.g1dd061c0dc-goog
^ permalink raw reply related [flat|nested] 22+ messages in thread* Re: [PATCH 2/3] m68k: Add support for M68040 CPU
2025-12-18 18:52 ` [PATCH 2/3] m68k: Add support for M68040 CPU Kuan-Wei Chiu
@ 2025-12-18 19:00 ` Tom Rini
2025-12-20 16:43 ` Kuan-Wei Chiu
2025-12-21 4:53 ` Daniel Palmer
1 sibling, 1 reply; 22+ messages in thread
From: Tom Rini @ 2025-12-18 19:00 UTC (permalink / raw)
To: Kuan-Wei Chiu; +Cc: alison.wang, angelo, jserv, eleanor15x, u-boot
[-- Attachment #1: Type: text/plain, Size: 1523 bytes --]
On Thu, Dec 18, 2025 at 06:52:51PM +0000, Kuan-Wei Chiu wrote:
> Add support for the Motorola 68040 architecture. Currently, m68k
> support in U-Boot is primarily focused on ColdFire (MCF5xxx) 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.
>
> Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
[snip]
> diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
> index 8ade6f7b9d1..a41c375f6be 100644
> --- a/arch/m68k/Kconfig
> +++ b/arch/m68k/Kconfig
> @@ -56,6 +56,9 @@ config MCF5441x
> select DM_SERIAL
> bool
>
> +config M68040
> + bool
> +
The file is unfortunately inconsistent about tabs vs spaces, but all the
new options should be tab-indent only, and no extra blank lines added.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 2/3] m68k: Add support for M68040 CPU
2025-12-18 19:00 ` Tom Rini
@ 2025-12-20 16:43 ` Kuan-Wei Chiu
2025-12-22 16:20 ` Tom Rini
0 siblings, 1 reply; 22+ messages in thread
From: Kuan-Wei Chiu @ 2025-12-20 16:43 UTC (permalink / raw)
To: Tom Rini; +Cc: alison.wang, angelo, jserv, eleanor15x, u-boot
Hi Tom,
On Thu, Dec 18, 2025 at 01:00:32PM -0600, Tom Rini wrote:
> On Thu, Dec 18, 2025 at 06:52:51PM +0000, Kuan-Wei Chiu wrote:
> > Add support for the Motorola 68040 architecture. Currently, m68k
> > support in U-Boot is primarily focused on ColdFire (MCF5xxx) 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.
> >
> > Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
> [snip]
> > diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
> > index 8ade6f7b9d1..a41c375f6be 100644
> > --- a/arch/m68k/Kconfig
> > +++ b/arch/m68k/Kconfig
> > @@ -56,6 +56,9 @@ config MCF5441x
> > select DM_SERIAL
> > bool
> >
> > +config M68040
> > + bool
> > +
>
> The file is unfortunately inconsistent about tabs vs spaces, but all the
> new options should be tab-indent only, and no extra blank lines added.
I'll fix this in v2.
BTW, do you think it would be helpful to add a check in checkpatch.pl
to warn about space indentation in Kconfig files?
Regards,
Kuan-Wei
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 2/3] m68k: Add support for M68040 CPU
2025-12-20 16:43 ` Kuan-Wei Chiu
@ 2025-12-22 16:20 ` Tom Rini
0 siblings, 0 replies; 22+ messages in thread
From: Tom Rini @ 2025-12-22 16:20 UTC (permalink / raw)
To: Kuan-Wei Chiu; +Cc: alison.wang, angelo, jserv, eleanor15x, u-boot
[-- Attachment #1: Type: text/plain, Size: 2167 bytes --]
On Sun, Dec 21, 2025 at 12:43:08AM +0800, Kuan-Wei Chiu wrote:
> Hi Tom,
>
> On Thu, Dec 18, 2025 at 01:00:32PM -0600, Tom Rini wrote:
> > On Thu, Dec 18, 2025 at 06:52:51PM +0000, Kuan-Wei Chiu wrote:
> > > Add support for the Motorola 68040 architecture. Currently, m68k
> > > support in U-Boot is primarily focused on ColdFire (MCF5xxx) 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.
> > >
> > > Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
> > [snip]
> > > diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
> > > index 8ade6f7b9d1..a41c375f6be 100644
> > > --- a/arch/m68k/Kconfig
> > > +++ b/arch/m68k/Kconfig
> > > @@ -56,6 +56,9 @@ config MCF5441x
> > > select DM_SERIAL
> > > bool
> > >
> > > +config M68040
> > > + bool
> > > +
> >
> > The file is unfortunately inconsistent about tabs vs spaces, but all the
> > new options should be tab-indent only, and no extra blank lines added.
>
> I'll fix this in v2.
>
> BTW, do you think it would be helpful to add a check in checkpatch.pl
> to warn about space indentation in Kconfig files?
I checked and the linux kernel has many space-not-tab in Kconfig files,
so it would be a change to add it to the U-Boot specific tests part of
checkpatch.pl, and a patch to do so would be welcome, thanks!
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 2/3] m68k: Add support for M68040 CPU
2025-12-18 18:52 ` [PATCH 2/3] m68k: Add support for M68040 CPU Kuan-Wei Chiu
2025-12-18 19:00 ` Tom Rini
@ 2025-12-21 4:53 ` Daniel Palmer
2025-12-21 7:25 ` Angelo Dureghello
2025-12-22 9:21 ` Kuan-Wei Chiu
1 sibling, 2 replies; 22+ messages in thread
From: Daniel Palmer @ 2025-12-21 4:53 UTC (permalink / raw)
To: Kuan-Wei Chiu; +Cc: alison.wang, angelo, trini, jserv, eleanor15x, u-boot
Hi Kuan-Wei
On Fri, 19 Dec 2025 at 04:06, Kuan-Wei Chiu <visitorckw@gmail.com> wrote:
>
> Add support for the Motorola 68040 architecture. Currently, m68k
> support in U-Boot is primarily focused on ColdFire (MCF5xxx) variants.
> Introduce the necessary infrastructure to support the classic M680x0
> series, specifically targeting the M68040 as emulated by QEMU.
For all of this: It really needs to be split into the bits for all
classic 68K and then the supplemental bits for 040 (basically the
cache stuff that you only have stubs for).
That way if your parts get merged I can rework my support for 000, 030
etc on top of that.
Cheers,
Daniel
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 2/3] m68k: Add support for M68040 CPU
2025-12-21 4:53 ` Daniel Palmer
@ 2025-12-21 7:25 ` Angelo Dureghello
2025-12-22 9:21 ` Kuan-Wei Chiu
1 sibling, 0 replies; 22+ messages in thread
From: Angelo Dureghello @ 2025-12-21 7:25 UTC (permalink / raw)
To: Daniel Palmer, Kuan-Wei Chiu
Cc: alison.wang, trini, jserv, eleanor15x, u-boot
On 12/21/25 05:53, Daniel Palmer wrote:
> Hi Kuan-Wei
>
> On Fri, 19 Dec 2025 at 04:06, Kuan-Wei Chiu <visitorckw@gmail.com> wrote:
>> Add support for the Motorola 68040 architecture. Currently, m68k
>> support in U-Boot is primarily focused on ColdFire (MCF5xxx) variants.
>> Introduce the necessary infrastructure to support the classic M680x0
>> series, specifically targeting the M68040 as emulated by QEMU.
> For all of this: It really needs to be split into the bits for all
> classic 68K and then the supplemental bits for 040 (basically the
> cache stuff that you only have stubs for).
> That way if your parts get merged I can rework my support for 000, 030
> etc on top of that.
>
> Cheers,
> Daniel
Looks good to me, even if i can't test any of them here.
Angelo
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 2/3] m68k: Add support for M68040 CPU
2025-12-21 4:53 ` Daniel Palmer
2025-12-21 7:25 ` Angelo Dureghello
@ 2025-12-22 9:21 ` Kuan-Wei Chiu
1 sibling, 0 replies; 22+ messages in thread
From: Kuan-Wei Chiu @ 2025-12-22 9:21 UTC (permalink / raw)
To: Daniel Palmer; +Cc: alison.wang, angelo, trini, jserv, eleanor15x, u-boot
Hi Daniel,
On Sun, Dec 21, 2025 at 01:53:40PM +0900, Daniel Palmer wrote:
> Hi Kuan-Wei
>
> On Fri, 19 Dec 2025 at 04:06, Kuan-Wei Chiu <visitorckw@gmail.com> wrote:
> >
> > Add support for the Motorola 68040 architecture. Currently, m68k
> > support in U-Boot is primarily focused on ColdFire (MCF5xxx) variants.
> > Introduce the necessary infrastructure to support the classic M680x0
> > series, specifically targeting the M68040 as emulated by QEMU.
>
> For all of this: It really needs to be split into the bits for all
> classic 68K and then the supplemental bits for 040 (basically the
> cache stuff that you only have stubs for).
> That way if your parts get merged I can rework my support for 000, 030
> etc on top of that.
Yeah, proper split is definitely needed for the long term.
Here is my plan for v2 to address this. Could you let me know if this
structure matches what you have in mind?
1. Create a common directory for Classic m68k (non-ColdFire):
Possible path: arch/m68k/cpu/classic/
I plan to move the following generic parts there:
- start.S: The entry point, basic stack setup, and exception vector
definitions (likely shared across 000-060).
- bootinfo.h: Since this is standard for m68k Linux.
2. Keep 040-specific code in arch/m68k/cpu/classic/m68040/:
- cpu.c: Containing 040-specific cache handling (or stubs for
now) and specific initialization.
3. Refactor arch/m68k/lib/Makefile:
Instead of using ifndef CONFIG_M68040 to exclude ColdFire files, I
should probably restructure it to clearly distinguish between
"ColdFire common" and "Classic m68k common" libraries.
Does this separation align with your requirements for layering 000/030
support on top of it later?
Regards,
Kuan-Wei
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 3/3] board: Add QEMU m68k virt board support
2025-12-18 18:52 [PATCH 0/3] m68k: Add support for QEMU virt machine Kuan-Wei Chiu
2025-12-18 18:52 ` [PATCH 1/3] serial: Add Goldfish TTY driver Kuan-Wei Chiu
2025-12-18 18:52 ` [PATCH 2/3] m68k: Add support for M68040 CPU Kuan-Wei Chiu
@ 2025-12-18 18:52 ` Kuan-Wei Chiu
2025-12-18 19:04 ` Tom Rini
2025-12-21 4:37 ` Daniel Palmer
2025-12-18 19:00 ` [PATCH 0/3] m68k: Add support for QEMU virt machine Tom Rini
3 siblings, 2 replies; 22+ messages in thread
From: Kuan-Wei Chiu @ 2025-12-18 18:52 UTC (permalink / raw)
To: alison.wang, angelo; +Cc: trini, jserv, eleanor15x, u-boot, 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 to provide a serial console, which
facilitates interaction when running QEMU with the -nographic option.
Additionally, include comprehensive documentation covering build
instructions and usage examples to guide users in deploying U-Boot
within the virtualization environment.
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
---
arch/m68k/Kconfig | 8 +++
board/emulation/qemu-m68k/Kconfig | 12 ++++
board/emulation/qemu-m68k/MAINTAINERS | 10 ++++
board/emulation/qemu-m68k/Makefile | 5 ++
board/emulation/qemu-m68k/qemu-m68k.c | 84 +++++++++++++++++++++++++++
configs/qemu-m68k_defconfig | 17 ++++++
doc/board/emulation/qemu-m68k.rst | 38 ++++++++++++
include/configs/qemu-m68k.h | 18 ++++++
8 files changed, 192 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
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index a41c375f6be..afc21dc2bc3 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -179,6 +179,13 @@ config TARGET_STMARK2
select CF_DSPI
select M54418
+config TARGET_QEMU_M68K
+ bool "Support QEMU m68k virt"
+ select M68040
+ help
+ This target supports the QEMU m68k virtual machine (-M virt).
+ It simulates a Motorola 68040 CPU with Goldfish peripherals.
+
endchoice
config SYS_CPU
@@ -207,6 +214,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"
diff --git a/board/emulation/qemu-m68k/Kconfig b/board/emulation/qemu-m68k/Kconfig
new file mode 100644
index 00000000000..e4001d67288
--- /dev/null
+++ b/board/emulation/qemu-m68k/Kconfig
@@ -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
diff --git a/board/emulation/qemu-m68k/MAINTAINERS b/board/emulation/qemu-m68k/MAINTAINERS
new file mode 100644
index 00000000000..c2f4cc40a56
--- /dev/null
+++ b/board/emulation/qemu-m68k/MAINTAINERS
@@ -0,0 +1,10 @@
+QEMU M68K VIRT BOARD
+M: Kuan-Wei Chiu <visitorckw@gmail.com>
+S: Maintained
+F: board/emulation/qemu-m68k/
+F: board/emulation/common/
+F: include/configs/qemu-m68k.h
+F: configs/qemu-m68k_defconfig
+F: arch/m68k/cpu/m68040/
+F: arch/m68k/include/asm/bootinfo.h
+F: doc/board/emulation/qemu-m68k.rst
diff --git a/board/emulation/qemu-m68k/Makefile b/board/emulation/qemu-m68k/Makefile
new file mode 100644
index 00000000000..036b7596c18
--- /dev/null
+++ b/board/emulation/qemu-m68k/Makefile
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (C) 2025, Kuan-Wei Chiu <visitorckw@gmail.com>
+
+obj-y += qemu-m68k.o
diff --git a/board/emulation/qemu-m68k/qemu-m68k.c b/board/emulation/qemu-m68k/qemu-m68k.c
new file mode 100644
index 00000000000..92da828eed3
--- /dev/null
+++ b/board/emulation/qemu-m68k/qemu-m68k.c
@@ -0,0 +1,84 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2025, Kuan-Wei Chiu <visitorckw@gmail.com>
+ */
+
+#include <config.h>
+#include <init.h>
+#include <asm/global_data.h>
+#include <asm-generic/sections.h>
+#include <linux/errno.h>
+#include <asm/io.h>
+#include <dm/platdata.h>
+#include <serial.h>
+#include <goldfish_tty.h>
+#include <asm/bootinfo.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/* QEMU Virt Machine Hardware Map */
+#define VIRT_GF_TTY_MMIO_BASE 0xff008000
+#define VIRT_CTRL_MMIO_BASE 0xff009000
+#define VIRT_CTRL_RESET 0x01
+
+int board_early_init_f(void)
+{
+ return 0;
+}
+
+int checkboard(void)
+{
+ puts("Board: QEMU m68k virt\n");
+ return 0;
+}
+
+int dram_init(void)
+{
+ struct bi_record *record;
+ ulong addr;
+
+ /* Default: 16MB */
+ gd->ram_size = 0x01000000;
+
+ /* QEMU places bootinfo after _end, aligned to 2 bytes */
+ addr = (ulong)&_end;
+ if (addr & 1)
+ addr++;
+
+ record = (struct bi_record *)addr;
+
+ if (record->tag != BI_MACHTYPE)
+ return 0;
+
+ while (record->tag != BI_LAST) {
+ if (record->tag == BI_MEMCHUNK) {
+ gd->ram_size = record->data[1];
+ break;
+ }
+ record = (struct bi_record *)((ulong)record + record->size);
+ }
+
+ return 0;
+}
+
+void reset_cpu(unsigned long addr)
+{
+ writel(VIRT_CTRL_RESET, VIRT_CTRL_MMIO_BASE);
+ while (1)
+ ;
+}
+
+int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
+{
+ reset_cpu(0);
+ return 0;
+}
+
+static const struct goldfish_tty_plat serial_plat = {
+ .base = (void __iomem *)VIRT_GF_TTY_MMIO_BASE,
+};
+
+U_BOOT_DRVINFO(goldfish_serial) = {
+ .name = "serial_goldfish",
+ .plat = &serial_plat,
+};
diff --git a/configs/qemu-m68k_defconfig b/configs/qemu-m68k_defconfig
new file mode 100644
index 00000000000..765ed9b7424
--- /dev/null
+++ b/configs/qemu-m68k_defconfig
@@ -0,0 +1,17 @@
+CONFIG_M68K=y
+CONFIG_TARGET_QEMU_M68K=y
+CONFIG_TEXT_BASE=0x00000000
+CONFIG_SYS_LOAD_ADDR=0x00000000
+CONFIG_SYS_MONITOR_LEN=262144
+CONFIG_SYS_BOOTM_LEN=0x1000000
+CONFIG_SYS_MALLOC_LEN=0x20000
+# CONFIG_DISPLAY_BOARDINFO is not set
+CONFIG_BAUDRATE=115200
+
+# CONFIG_OF_CONTROL is not set
+CONFIG_DM=y
+CONFIG_DM_SERIAL=y
+CONFIG_SERIAL_GOLDFISH=y
+CONFIG_SYS_MALLOC_F_LEN=0x2000
+CONFIG_SYS_LDSCRIPT="arch/m68k/cpu/m68040/u-boot.lds"
+CONFIG_BOARD_EARLY_INIT_F=y
diff --git a/doc/board/emulation/qemu-m68k.rst b/doc/board/emulation/qemu-m68k.rst
new file mode 100644
index 00000000000..19898e17cfc
--- /dev/null
+++ b/doc/board/emulation/qemu-m68k.rst
@@ -0,0 +1,38 @@
+.. SPDX-License-Identifier: GPL-2.0+
+.. Copyright (C) 2025, Kuan-Wei Chiu <visitorckw@gmail.com>
+
+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)
diff --git a/include/configs/qemu-m68k.h b/include/configs/qemu-m68k.h
new file mode 100644
index 00000000000..90f59c7b850
--- /dev/null
+++ b/include/configs/qemu-m68k.h
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2025, Kuan-Wei Chiu <visitorckw@gmail.com>
+ */
+
+#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 */
--
2.52.0.322.g1dd061c0dc-goog
^ permalink raw reply related [flat|nested] 22+ messages in thread* Re: [PATCH 3/3] board: Add QEMU m68k virt board support
2025-12-18 18:52 ` [PATCH 3/3] board: Add QEMU m68k virt board support Kuan-Wei Chiu
@ 2025-12-18 19:04 ` Tom Rini
2025-12-20 16:48 ` Kuan-Wei Chiu
2025-12-21 4:37 ` Daniel Palmer
1 sibling, 1 reply; 22+ messages in thread
From: Tom Rini @ 2025-12-18 19:04 UTC (permalink / raw)
To: Kuan-Wei Chiu; +Cc: alison.wang, angelo, jserv, eleanor15x, u-boot
[-- Attachment #1: Type: text/plain, Size: 2746 bytes --]
On Thu, Dec 18, 2025 at 06:52:52PM +0000, Kuan-Wei Chiu wrote:
> 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 to provide a serial console, which
> facilitates interaction when running QEMU with the -nographic option.
> Additionally, include comprehensive documentation covering build
> instructions and usage examples to guide users in deploying U-Boot
> within the virtualization environment.
>
> Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
[snip]
> diff --git a/board/emulation/qemu-m68k/MAINTAINERS b/board/emulation/qemu-m68k/MAINTAINERS
> new file mode 100644
> index 00000000000..c2f4cc40a56
> --- /dev/null
> +++ b/board/emulation/qemu-m68k/MAINTAINERS
> @@ -0,0 +1,10 @@
> +QEMU M68K VIRT BOARD
> +M: Kuan-Wei Chiu <visitorckw@gmail.com>
> +S: Maintained
> +F: board/emulation/qemu-m68k/
> +F: board/emulation/common/
> +F: include/configs/qemu-m68k.h
> +F: configs/qemu-m68k_defconfig
> +F: arch/m68k/cpu/m68040/
> +F: arch/m68k/include/asm/bootinfo.h
> +F: doc/board/emulation/qemu-m68k.rst
There was Kconfig spacing issues here as well, but also MAINTAINERS
files are usually tab not spaces. But if get_maintainer.pl is fine, OK.
> diff --git a/configs/qemu-m68k_defconfig b/configs/qemu-m68k_defconfig
> new file mode 100644
> index 00000000000..765ed9b7424
> --- /dev/null
> +++ b/configs/qemu-m68k_defconfig
> @@ -0,0 +1,17 @@
> +CONFIG_M68K=y
> +CONFIG_TARGET_QEMU_M68K=y
> +CONFIG_TEXT_BASE=0x00000000
> +CONFIG_SYS_LOAD_ADDR=0x00000000
> +CONFIG_SYS_MONITOR_LEN=262144
> +CONFIG_SYS_BOOTM_LEN=0x1000000
> +CONFIG_SYS_MALLOC_LEN=0x20000
> +# CONFIG_DISPLAY_BOARDINFO is not set
> +CONFIG_BAUDRATE=115200
> +
> +# CONFIG_OF_CONTROL is not set
This wasn't made with "make savedefconfig" and needs to be, please
generate it that way.
> diff --git a/doc/board/emulation/qemu-m68k.rst b/doc/board/emulation/qemu-m68k.rst
> new file mode 100644
> index 00000000000..19898e17cfc
> --- /dev/null
> +++ b/doc/board/emulation/qemu-m68k.rst
> @@ -0,0 +1,38 @@
> +.. SPDX-License-Identifier: GPL-2.0+
> +.. Copyright (C) 2025, Kuan-Wei Chiu <visitorckw@gmail.com>
Docs are good, thank you. But it needs to update the index.rst file too
to be included and also not trigger CI failure when building docs.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 3/3] board: Add QEMU m68k virt board support
2025-12-18 19:04 ` Tom Rini
@ 2025-12-20 16:48 ` Kuan-Wei Chiu
0 siblings, 0 replies; 22+ messages in thread
From: Kuan-Wei Chiu @ 2025-12-20 16:48 UTC (permalink / raw)
To: Tom Rini; +Cc: alison.wang, angelo, jserv, eleanor15x, u-boot
Hi Tom,
On Thu, Dec 18, 2025 at 01:04:15PM -0600, Tom Rini wrote:
> On Thu, Dec 18, 2025 at 06:52:52PM +0000, Kuan-Wei Chiu wrote:
>
> > 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 to provide a serial console, which
> > facilitates interaction when running QEMU with the -nographic option.
> > Additionally, include comprehensive documentation covering build
> > instructions and usage examples to guide users in deploying U-Boot
> > within the virtualization environment.
> >
> > Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
> [snip]
> > diff --git a/board/emulation/qemu-m68k/MAINTAINERS b/board/emulation/qemu-m68k/MAINTAINERS
> > new file mode 100644
> > index 00000000000..c2f4cc40a56
> > --- /dev/null
> > +++ b/board/emulation/qemu-m68k/MAINTAINERS
> > @@ -0,0 +1,10 @@
> > +QEMU M68K VIRT BOARD
> > +M: Kuan-Wei Chiu <visitorckw@gmail.com>
> > +S: Maintained
> > +F: board/emulation/qemu-m68k/
> > +F: board/emulation/common/
> > +F: include/configs/qemu-m68k.h
> > +F: configs/qemu-m68k_defconfig
> > +F: arch/m68k/cpu/m68040/
> > +F: arch/m68k/include/asm/bootinfo.h
> > +F: doc/board/emulation/qemu-m68k.rst
>
> There was Kconfig spacing issues here as well, but also MAINTAINERS
> files are usually tab not spaces. But if get_maintainer.pl is fine, OK.
Will convert them to tabs in v2.
>
> > diff --git a/configs/qemu-m68k_defconfig b/configs/qemu-m68k_defconfig
> > new file mode 100644
> > index 00000000000..765ed9b7424
> > --- /dev/null
> > +++ b/configs/qemu-m68k_defconfig
> > @@ -0,0 +1,17 @@
> > +CONFIG_M68K=y
> > +CONFIG_TARGET_QEMU_M68K=y
> > +CONFIG_TEXT_BASE=0x00000000
> > +CONFIG_SYS_LOAD_ADDR=0x00000000
> > +CONFIG_SYS_MONITOR_LEN=262144
> > +CONFIG_SYS_BOOTM_LEN=0x1000000
> > +CONFIG_SYS_MALLOC_LEN=0x20000
> > +# CONFIG_DISPLAY_BOARDINFO is not set
> > +CONFIG_BAUDRATE=115200
> > +
> > +# CONFIG_OF_CONTROL is not set
>
> This wasn't made with "make savedefconfig" and needs to be, please
> generate it that way.
Will rectify that in v2.
>
> > diff --git a/doc/board/emulation/qemu-m68k.rst b/doc/board/emulation/qemu-m68k.rst
> > new file mode 100644
> > index 00000000000..19898e17cfc
> > --- /dev/null
> > +++ b/doc/board/emulation/qemu-m68k.rst
> > @@ -0,0 +1,38 @@
> > +.. SPDX-License-Identifier: GPL-2.0+
> > +.. Copyright (C) 2025, Kuan-Wei Chiu <visitorckw@gmail.com>
>
> Docs are good, thank you. But it needs to update the index.rst file too
> to be included and also not trigger CI failure when building docs.
Sorry for missing that. I will fix it in v2 and ensure the docs build
successfully before respinning.
Regards,
Kuan-Wei
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 3/3] board: Add QEMU m68k virt board support
2025-12-18 18:52 ` [PATCH 3/3] board: Add QEMU m68k virt board support Kuan-Wei Chiu
2025-12-18 19:04 ` Tom Rini
@ 2025-12-21 4:37 ` Daniel Palmer
2025-12-22 9:03 ` Kuan-Wei Chiu
1 sibling, 1 reply; 22+ messages in thread
From: Daniel Palmer @ 2025-12-21 4:37 UTC (permalink / raw)
To: Kuan-Wei Chiu; +Cc: alison.wang, angelo, trini, jserv, eleanor15x, u-boot
Hi Kuan-Wei,
On Fri, 19 Dec 2025 at 04:06, Kuan-Wei Chiu <visitorckw@gmail.com> wrote:
>
> 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.
Since I already have this setup working and able to boot linux I will
add some input:
- The virt machine can use any supported CPU type, even 000 without
mmu, you should really handle that.
- m68k linux for mmu machines uses "bootinfo" that is a structure
after the kernel image that the bootloader prepares so linux can work
out what CPU etc is present. QEMU does this as well but it will be
after the u-boot image now, so to boot linux you must save it before
it gets destroyed and when the kernel is loaded copy it to after the
kernel. I use ELF images to boot linux. I have a hack in bootelf to
put the bootinfo in place just before jumping to the entry point.
- Since QEMU gives you the bootinfo and you need to parse it to work
out how much to save either way you should use it to detect the
selected CPU in u-boot. If the code is built for 000 it will run on
anything and just needs to handle the differences in the caches. In my
setup I fixup the cpu compatible string in u-boot's devicetree and
then use that to work out what cache function to call for the current
CPU.
Glad to see I'm not alone in messing around with this. :)
Cheers,
Daniel
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 3/3] board: Add QEMU m68k virt board support
2025-12-21 4:37 ` Daniel Palmer
@ 2025-12-22 9:03 ` Kuan-Wei Chiu
0 siblings, 0 replies; 22+ messages in thread
From: Kuan-Wei Chiu @ 2025-12-22 9:03 UTC (permalink / raw)
To: Daniel Palmer; +Cc: alison.wang, angelo, trini, jserv, eleanor15x, u-boot
Hi Daniel,
On Sun, Dec 21, 2025 at 01:37:24PM +0900, Daniel Palmer wrote:
> Hi Kuan-Wei,
>
> On Fri, 19 Dec 2025 at 04:06, Kuan-Wei Chiu <visitorckw@gmail.com> wrote:
> >
> > 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.
>
> Since I already have this setup working and able to boot linux I will
> add some input:
> - The virt machine can use any supported CPU type, even 000 without
> mmu, you should really handle that.
You're right. Regarding the support for other 680x0 CPUs, would you
prefer to see them included in v2, or would you think that it is better
to integrate them incrementally after this baseline series is merged?
> - m68k linux for mmu machines uses "bootinfo" that is a structure
> after the kernel image that the bootloader prepares so linux can work
> out what CPU etc is present. QEMU does this as well but it will be
> after the u-boot image now, so to boot linux you must save it before
> it gets destroyed and when the kernel is loaded copy it to after the
> kernel. I use ELF images to boot linux. I have a hack in bootelf to
> put the bootinfo in place just before jumping to the entry point.
> - Since QEMU gives you the bootinfo and you need to parse it to work
> out how much to save either way you should use it to detect the
> selected CPU in u-boot. If the code is built for 000 it will run on
> anything and just needs to handle the differences in the caches. In my
> setup I fixup the cpu compatible string in u-boot's devicetree and
> then use that to work out what cache function to call for the current
> CPU.
Currently, I only parse the bootinfo to retrieve the RAM size and
haven't looked into the specific requirements for booting Linux yet.
If full Linux boot support isn't a blocker for this initial series,
could you advise on any specific structural adjustments I should make
now to facilitate that integration later?
>
> Glad to see I'm not alone in messing around with this. :)
Same here! Glad to know I'm not the only one. :)
Regards,
Kuan-Wei
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 0/3] m68k: Add support for QEMU virt machine
2025-12-18 18:52 [PATCH 0/3] m68k: Add support for QEMU virt machine Kuan-Wei Chiu
` (2 preceding siblings ...)
2025-12-18 18:52 ` [PATCH 3/3] board: Add QEMU m68k virt board support Kuan-Wei Chiu
@ 2025-12-18 19:00 ` Tom Rini
2025-12-20 16:39 ` Kuan-Wei Chiu
2025-12-21 4:15 ` Daniel Palmer
3 siblings, 2 replies; 22+ messages in thread
From: Tom Rini @ 2025-12-18 19:00 UTC (permalink / raw)
To: Kuan-Wei Chiu; +Cc: alison.wang, angelo, jserv, eleanor15x, u-boot
[-- Attachment #1: Type: text/plain, Size: 1133 bytes --]
On Thu, Dec 18, 2025 at 06:52:49PM +0000, Kuan-Wei Chiu wrote:
> Add support for the QEMU 'virt' machine on the m68k architecture. The
> QEMU virt machine models a generic system based on the Motorola 68040
> CPU and utilizes Goldfish virtual peripherals.
>
> Currently, U-Boot's m68k architecture support focuses on ColdFire
> variants. Expand this to include the classic M680x0 architecture,
> implementing the necessary exception vectors, startup code, and a
> bootinfo parser compatible with the QEMU interface. A driver for the
> Goldfish TTY is also added to enable serial console output.
>
> The implementation has been verified on QEMU targeting the M68040 CPU,
> confirming successful hardware initialization and boot to the U-Boot
> command shell.
>
> Kuan-Wei Chiu (3):
> serial: Add Goldfish TTY driver
> m68k: Add support for M68040 CPU
> board: Add QEMU m68k virt board support
Well this is neat. The next step for v2 is to update both .gitlab-ci.yml
and .azure-pipeslines.yml to run this target in the QEMU sections by
where we already test another m68k platform via QEMU.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH 0/3] m68k: Add support for QEMU virt machine
2025-12-18 19:00 ` [PATCH 0/3] m68k: Add support for QEMU virt machine Tom Rini
@ 2025-12-20 16:39 ` Kuan-Wei Chiu
2025-12-21 4:15 ` Daniel Palmer
1 sibling, 0 replies; 22+ messages in thread
From: Kuan-Wei Chiu @ 2025-12-20 16:39 UTC (permalink / raw)
To: Tom Rini; +Cc: alison.wang, angelo, jserv, eleanor15x, u-boot
Hi Tom,
On Thu, Dec 18, 2025 at 01:00:59PM -0600, Tom Rini wrote:
> On Thu, Dec 18, 2025 at 06:52:49PM +0000, Kuan-Wei Chiu wrote:
> > Add support for the QEMU 'virt' machine on the m68k architecture. The
> > QEMU virt machine models a generic system based on the Motorola 68040
> > CPU and utilizes Goldfish virtual peripherals.
> >
> > Currently, U-Boot's m68k architecture support focuses on ColdFire
> > variants. Expand this to include the classic M680x0 architecture,
> > implementing the necessary exception vectors, startup code, and a
> > bootinfo parser compatible with the QEMU interface. A driver for the
> > Goldfish TTY is also added to enable serial console output.
> >
> > The implementation has been verified on QEMU targeting the M68040 CPU,
> > confirming successful hardware initialization and boot to the U-Boot
> > command shell.
> >
> > Kuan-Wei Chiu (3):
> > serial: Add Goldfish TTY driver
> > m68k: Add support for M68040 CPU
> > board: Add QEMU m68k virt board support
>
> Well this is neat. The next step for v2 is to update both .gitlab-ci.yml
> and .azure-pipeslines.yml to run this target in the QEMU sections by
> where we already test another m68k platform via QEMU.
Thanks for pointing this out. :)
I'll take a look at those CI files.
I'm not sure how to verify the CI config changes locally, but I'll try.
Regards,
Kuan-Wei
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 0/3] m68k: Add support for QEMU virt machine
2025-12-18 19:00 ` [PATCH 0/3] m68k: Add support for QEMU virt machine Tom Rini
2025-12-20 16:39 ` Kuan-Wei Chiu
@ 2025-12-21 4:15 ` Daniel Palmer
2025-12-22 8:44 ` Kuan-Wei Chiu
1 sibling, 1 reply; 22+ messages in thread
From: Daniel Palmer @ 2025-12-21 4:15 UTC (permalink / raw)
To: Tom Rini; +Cc: Kuan-Wei Chiu, alison.wang, angelo, jserv, eleanor15x, u-boot
Hi Tom, Kuan-Wei,
On Fri, 19 Dec 2025 at 04:01, Tom Rini <trini@konsulko.com> wrote:
>
> On Thu, Dec 18, 2025 at 06:52:49PM +0000, Kuan-Wei Chiu wrote:
> > Add support for the QEMU 'virt' machine on the m68k architecture. The
> > QEMU virt machine models a generic system based on the Motorola 68040
> > CPU and utilizes Goldfish virtual peripherals.
> Well this is neat.
I have had a messy version[0] of this that runs on 68000, 68030 and
68040 real hardware and virt for years..
I thought no one would want it so never sent it.
I have devicetree for 000 and code to create bootinfo so that linux
can boot on 020+ machines.
Gist of probably the oldest cpu that can run the latest u-boot[1]
Can we work on this together to reduce duplication?
0 - https://github.com/fifteenhex/u-boot/tree/mc68000
1 - https://gist.github.com/fifteenhex/eed03b250b6a0113ab08b69be0375aa1
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 0/3] m68k: Add support for QEMU virt machine
2025-12-21 4:15 ` Daniel Palmer
@ 2025-12-22 8:44 ` Kuan-Wei Chiu
2025-12-22 9:20 ` Daniel Palmer
0 siblings, 1 reply; 22+ messages in thread
From: Kuan-Wei Chiu @ 2025-12-22 8:44 UTC (permalink / raw)
To: Daniel Palmer; +Cc: Tom Rini, alison.wang, angelo, jserv, eleanor15x, u-boot
Hi Daniel,
On Sun, Dec 21, 2025 at 01:15:18PM +0900, Daniel Palmer wrote:
> Hi Tom, Kuan-Wei,
>
> On Fri, 19 Dec 2025 at 04:01, Tom Rini <trini@konsulko.com> wrote:
> >
> > On Thu, Dec 18, 2025 at 06:52:49PM +0000, Kuan-Wei Chiu wrote:
> > > Add support for the QEMU 'virt' machine on the m68k architecture. The
> > > QEMU virt machine models a generic system based on the Motorola 68040
> > > CPU and utilizes Goldfish virtual peripherals.
>
> > Well this is neat.
>
> I have had a messy version[0] of this that runs on 68000, 68030 and
> 68040 real hardware and virt for years..
> I thought no one would want it so never sent it.
>
> I have devicetree for 000 and code to create bootinfo so that linux
> can boot on 020+ machines.
> Gist of probably the oldest cpu that can run the latest u-boot[1]
>
> Can we work on this together to reduce duplication?
>
> 0 - https://github.com/fifteenhex/u-boot/tree/mc68000
> 1 - https://gist.github.com/fifteenhex/eed03b250b6a0113ab08b69be0375aa1
Wow, this is fantastic! I wasn't aware that you had already done so
much work on this. I would love to collaborate.
However, I noticed that your branch contains over 100+ commits with a
diff exceeding 15k+ lines. Attempting to integrate such a massive
amount of code directly into this v2 series would be extremely
difficult and likely overwhelming for the review process.
My current goal with this patch series is to establish a minimal
baseline support for m68k in U-Boot (targeting QEMU 040 first). I think
the best approach would be to get this foundational series merged first
to serve as a minimal base, and I am more than willing to make
adjustments in this series to facilitate the future integration of your
work (000/030 support, Linux bootinfo handling, etc.) incrementally.
What do you think?
Regards,
Kuan-Wei
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 0/3] m68k: Add support for QEMU virt machine
2025-12-22 8:44 ` Kuan-Wei Chiu
@ 2025-12-22 9:20 ` Daniel Palmer
0 siblings, 0 replies; 22+ messages in thread
From: Daniel Palmer @ 2025-12-22 9:20 UTC (permalink / raw)
To: Kuan-Wei Chiu; +Cc: Tom Rini, alison.wang, angelo, jserv, eleanor15x, u-boot
Hi Kuan-Wei,
On Mon, 22 Dec 2025 at 17:44, Kuan-Wei Chiu <visitorckw@gmail.com> wrote:
> However, I noticed that your branch contains over 100+ commits with a
> diff exceeding 15k+ lines. Attempting to integrate such a massive
> amount of code directly into this v2 series would be extremely
> difficult and likely overwhelming for the review process.
Yeah, my branch is something like 4 years worth of tinkering so there
is no way it can be merged.
But if you get your goldfish serial driver merged I can delete mine
from my tree and it'll get smaller.
If you take my goldfish rtc/timer driver or write one and get that
merged that's another thing I can delete from my tree...
I think working incrementally is the way to go.
> My current goal with this patch series is to establish a minimal
> baseline support for m68k in U-Boot (targeting QEMU 040 first). I think
> the best approach would be to get this foundational series merged first
> to serve as a minimal base,
I think this is the correct approach. If you get your 040 parts merged
as a first step I can rework my tree to work on top of that and we can
pick what to do next.
> and I am more than willing to make
> adjustments in this series to facilitate the future integration of your
> work (000/030 support, Linux bootinfo handling, etc.) incrementally.
I think for now do what is needed to get your changes merged and we
can go from there.
Thanks,
Daniel
^ permalink raw reply [flat|nested] 22+ messages in thread