[PATCH v3 3/6] rtc: goldfish: Support platform data for non-DT probing
Kuan-Wei Chiu
visitorckw at gmail.com
Tue Dec 30 17:01:09 CET 2025
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. Update the
probe function to fall back to retrieving the base address from
struct goldfish_rtc_plat if the device tree address is unavailable.
Introduce a new header file include/goldfish_rtc.h to define the
platform data structure.
Signed-off-by: Kuan-Wei Chiu <visitorckw at gmail.com>
---
Changes in v3:
- New patch.
It appears there is no specific maintainer listed for this driver?
drivers/rtc/goldfish_rtc.c | 10 ++++++++--
include/goldfish_rtc.h | 15 +++++++++++++++
2 files changed, 23 insertions(+), 2 deletions(-)
create mode 100644 include/goldfish_rtc.h
diff --git a/drivers/rtc/goldfish_rtc.c b/drivers/rtc/goldfish_rtc.c
index e63a2766c76..900daabccb9 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>
@@ -77,11 +78,16 @@ static int goldfish_rtc_set(struct udevice *dev, const struct rtc_time *time)
static int goldfish_rtc_probe(struct udevice *dev)
{
struct goldfish_rtc *priv = dev_get_priv(dev);
+ struct goldfish_rtc_plat *plat;
fdt_addr_t addr;
addr = dev_read_addr(dev);
- if (addr == FDT_ADDR_T_NONE)
- return -EINVAL;
+ if (addr == FDT_ADDR_T_NONE) {
+ plat = dev_get_plat(dev);
+ if (!plat)
+ return -EINVAL;
+ addr = (fdt_addr_t)plat->base;
+ }
priv->base = map_sysmem(addr, 0x20);
return 0;
diff --git a/include/goldfish_rtc.h b/include/goldfish_rtc.h
new file mode 100644
index 00000000000..bb113a0bd79
--- /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 at gmail.com>
+ */
+
+#ifndef _GOLDFISH_RTC_H_
+#define _GOLDFISH_RTC_H_
+
+#include <linux/types.h>
+
+struct goldfish_rtc_plat {
+ void __iomem *base;
+};
+
+#endif /* _GOLDFISH_RTC_H_ */
--
2.52.0.358.g0dd7633a29-goog
More information about the U-Boot
mailing list