[PATCH v4 0/6] Add virtio-mmio support to m68k virt machine

Kuan-Wei Chiu visitorckw at gmail.com
Thu Apr 16 09:19:42 CEST 2026


Hi Daniel,

On Mon, Apr 13, 2026 at 06:22:34PM +0900, Daniel Palmer wrote:
> Lets start making the m68k virt machine support useful.
> 
> First we need to fix some m68k endian issues.
> 
> Then allow virtio mmio driver instances to be created with
> platform data and fix a minor endian issue.
> 
> Finally, add the code for the board to create the instances.
> 

While testing and playing around with it on the qemu m68k virt machine,
I noticed that the date and sleep commands are broken after applying
these changes.

We will need the following two fixes to address this issue by using
__raw_readl and __raw_writel in goldfish_rtc/timer driver.

Could you please include them in your patchset, placing them before the
io macro changes?

>From ffe017353f91e2a068f3a900e815cc11f388163c Mon Sep 17 00:00:00 2001
From: Kuan-Wei Chiu <visitorckw at gmail.com>
Date: Thu, 16 Apr 2026 06:45:09 +0000
Subject: [PATCH 1/2] rtc: goldfish: Use __raw_readl() and __raw_writel()

In QEMU, the Goldfish RTC is explicitly instantiated as a big-endian
device on the m68k virt machine (via the 'big-endian=true' property).
Currently, this driver uses ioread32() and iowrite32(), which works
by luck because the underlying readl() and writel() are currently
broken on m68k.

Use __raw_readl() and __raw_writel() instead to avoid breaking this
driver when the endianness of readl() and writel() is fixed.

Signed-off-by: Kuan-Wei Chiu <visitorckw at gmail.com>
---
 drivers/rtc/goldfish_rtc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/rtc/goldfish_rtc.c b/drivers/rtc/goldfish_rtc.c
index d2991ca6719..4892a63f8d8 100644
--- a/drivers/rtc/goldfish_rtc.c
+++ b/drivers/rtc/goldfish_rtc.c
@@ -40,8 +40,8 @@ static int goldfish_rtc_get(struct udevice *dev, struct rtc_time *time)
 	u64 time_low;
 	u64 now;

-	time_low = ioread32(base + GOLDFISH_TIME_LOW);
-	time_high = ioread32(base + GOLDFISH_TIME_HIGH);
+	time_low = __raw_readl(base + GOLDFISH_TIME_LOW);
+	time_high = __raw_readl(base + GOLDFISH_TIME_HIGH);
 	now = (time_high << 32) | time_low;

 	do_div(now, 1000000000U);
@@ -62,8 +62,8 @@ static int goldfish_rtc_set(struct udevice *dev, const struct rtc_time *time)
 		return -EINVAL;

 	now = rtc_mktime(time) * 1000000000ULL;
-	iowrite32(now >> 32, base + GOLDFISH_TIME_HIGH);
-	iowrite32(now, base + GOLDFISH_TIME_LOW);
+	__raw_writel(now >> 32, base + GOLDFISH_TIME_HIGH);
+	__raw_writel(now, base + GOLDFISH_TIME_LOW);

 	if (time->tm_isdst > 0)
 		priv->isdst = 1;
--
2.54.0.rc1.513.gad8abe7a5a-goog


>From 42f0b7a003be36c633cfcf37a90ebdb28e1b377e Mon Sep 17 00:00:00 2001
From: Kuan-Wei Chiu <visitorckw at gmail.com>
Date: Thu, 16 Apr 2026 06:45:42 +0000
Subject: [PATCH 2/2] timer: goldfish: Use __raw_readl()

The Goldfish timer registers are native endian, so they act as
big-endian on the m68k virt machine. Currently, this driver uses
readl(), which works by luck because it's currently broken on m68k.

Use __raw_readl() instead to avoid breaking this driver when the
endianness of readl() is fixed.

Signed-off-by: Kuan-Wei Chiu <visitorckw at gmail.com>
---
 drivers/timer/goldfish_timer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/timer/goldfish_timer.c b/drivers/timer/goldfish_timer.c
index 70673bbd93c..91277d7932a 100644
--- a/drivers/timer/goldfish_timer.c
+++ b/drivers/timer/goldfish_timer.c
@@ -31,8 +31,8 @@ static u64 goldfish_timer_get_count(struct udevice *dev)
 	 * We must read LOW before HIGH to latch the high 32-bit value
 	 * and ensure a consistent 64-bit timestamp.
 	 */
-	low = readl(priv->base + TIMER_TIME_LOW);
-	high = readl(priv->base + TIMER_TIME_HIGH);
+	low = __raw_readl(priv->base + TIMER_TIME_LOW);
+	high = __raw_readl(priv->base + TIMER_TIME_HIGH);

 	time = ((u64)high << 32) | low;

--
2.54.0.rc1.513.gad8abe7a5a-goog




More information about the U-Boot mailing list