diff options
| author | Kuan-Wei Chiu <[email protected]> | 2026-01-07 20:18:32 +0000 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2026-02-02 14:24:40 -0600 |
| commit | b41c54488f6f8263c8b38a6cf97d106c3f9a65bb (patch) | |
| tree | f22f03f4d4cfd65d1d350a65089df1ffdf96d7e7 /drivers/rtc | |
| parent | 909f717eaf299a97fb87307e8606f3fdc6cb0c14 (diff) | |
rtc: goldfish: Support platform data for non-DT probing
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 <[email protected]>
Reviewed-by: Heinrich Schuchardt <[email protected]>
Diffstat (limited to 'drivers/rtc')
| -rw-r--r-- | drivers/rtc/goldfish_rtc.c | 23 |
1 files changed, 19 insertions, 4 deletions
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), }; |
