public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Kuan-Wei Chiu <visitorckw@gmail.com>
To: alison.wang@nxp.com, angelo@kernel-space.org, trini@konsulko.com
Cc: me@ziyao.cc, daniel@0x0f.com, heinrich.schuchardt@canonical.com,
	sjg@chromium.org, jserv@ccns.ncku.edu.tw, eleanor15x@gmail.com,
	u-boot@lists.denx.de, Kuan-Wei Chiu <visitorckw@gmail.com>
Subject: [PATCH v6 3/8] rtc: goldfish: Support platform data for non-DT probing
Date: Wed,  7 Jan 2026 20:18:32 +0000	[thread overview]
Message-ID: <20260107201838.3448806-4-visitorckw@gmail.com> (raw)
In-Reply-To: <20260107201838.3448806-1-visitorckw@gmail.com>

Currently, 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.

Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
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

diff --git a/drivers/rtc/goldfish_rtc.c b/drivers/rtc/goldfish_rtc.c
index e63a2766c76..d2991ca6719 100644
--- a/drivers/rtc/goldfish_rtc.c
+++ b/drivers/rtc/goldfish_rtc.c
@@ -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),
 };
diff --git a/include/goldfish_rtc.h b/include/goldfish_rtc.h
new file mode 100644
index 00000000000..f0e6ba3d543
--- /dev/null
+++ b/include/goldfish_rtc.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2025, Kuan-Wei Chiu <visitorckw@gmail.com>
+ */
+
+#ifndef _GOLDFISH_RTC_H_
+#define _GOLDFISH_RTC_H_
+
+#include <linux/types.h>
+
+struct goldfish_rtc_plat {
+	phys_addr_t reg;
+};
+
+#endif /* _GOLDFISH_RTC_H_ */
-- 
2.52.0.457.g6b5491de43-goog


  parent reply	other threads:[~2026-01-07 20:20 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-07 20:18 [PATCH v6 0/8] m68k: Add support for QEMU virt machine Kuan-Wei Chiu
2026-01-07 20:18 ` [PATCH v6 1/8] serial: Add Goldfish TTY driver Kuan-Wei Chiu
2026-01-07 20:18 ` [PATCH v6 2/8] timer: Add Goldfish timer driver Kuan-Wei Chiu
2026-01-07 20:18 ` Kuan-Wei Chiu [this message]
2026-01-07 20:18 ` [PATCH v6 4/8] sysreset: Add QEMU virtual system controller driver Kuan-Wei Chiu
2026-01-09 11:31   ` Simon Glass
2026-01-30 11:23   ` Heinrich Schuchardt
2026-02-02  8:11     ` Kuan-Wei Chiu
2026-01-07 20:18 ` [PATCH v6 5/8] m68k: Add support for M68040 CPU Kuan-Wei Chiu
2026-01-09 11:31   ` Simon Glass
2026-01-24  8:29   ` Angelo Dureghello
2026-01-07 20:18 ` [PATCH v6 6/8] board: Add QEMU m68k virt board support Kuan-Wei Chiu
2026-01-09 11:31   ` Simon Glass
2026-01-07 20:18 ` [PATCH v6 7/8] CI: Add test jobs for QEMU m68k virt machine Kuan-Wei Chiu
2026-01-07 20:18 ` [PATCH v6 8/8] MAINTAINERS: Update m68k entry Kuan-Wei Chiu
2026-02-02 23:58 ` [PATCH v6 0/8] m68k: Add support for QEMU virt machine Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260107201838.3448806-4-visitorckw@gmail.com \
    --to=visitorckw@gmail.com \
    --cc=alison.wang@nxp.com \
    --cc=angelo@kernel-space.org \
    --cc=daniel@0x0f.com \
    --cc=eleanor15x@gmail.com \
    --cc=heinrich.schuchardt@canonical.com \
    --cc=jserv@ccns.ncku.edu.tw \
    --cc=me@ziyao.cc \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox