U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] virtio: Add a virtio RTC driver
@ 2026-10-14 19:06 Hung-Chun Tseng
  2026-10-14 19:06 ` [PATCH v2 1/3] virtio: rtc: Add " Hung-Chun Tseng
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Hung-Chun Tseng @ 2026-10-14 19:06 UTC (permalink / raw)
  To: Bin Meng, Tom Rini
  Cc: Kuan-Wei Chiu, Simon Glass, Heinrich Schuchardt, u-boot

QEMU v11.1.0 added a virtio RTC device (virtio-rtc-pci and
virtio-rtc-device), but U-Boot has no driver for it. This series adds
one: it finds the first UTC clock on the device and reads it through
the RTC uclass, so "date" and anything else using dm_rtc_get() work on
any virtio-capable QEMU target, not only on machines that also have a
goldfish or PL031 RTC.

Patch 1 adds the driver, patch 2 updates the virtio documentation, and
patch 3 adds a MAINTAINERS entry.

Tested on QEMU v11.1.2 with qemu-riscv64_smode_defconfig:

- With -device virtio-rtc-pci and with -device virtio-rtc-device, the
  driver probes. As "date" uses the first RTC, which is the goldfish
  RTC on this machine, I also built with RTC_GOLDFISH disabled: "date"
  then read the host time from the virtio RTC, advancing between reads.
- Setting the time fails with -ENOSYS, as the clocks are read-only.
- With RTC_GOLDFISH disabled and no virtio RTC device, "date" fails
  cleanly with err=-19.

qemu-riscv32_defconfig also builds the driver without libgcc helpers
for the 64-bit division. On sandbox, where VIRTIO_RTC now defaults to y,
"ut dm rtc*" and "ut dm virtio*" pass.

The alarm feature is not supported. I have not added a pytest because
the CI Docker image builds QEMU v10.1.2, which does not have the
device yet.

Changes in v2:
- Patch 1: look for the UTC clock on the first read instead of in
  probe(), as the virtqueue must not be used before DRIVER_OK (Bin)
- Patches 2 and 3: add Bin's Reviewed-by

v1: https://lore.kernel.org/u-boot/20261014140716.1181882-1-alan.tseng.cs@gmail.com/

Hung-Chun Tseng (3):
  virtio: rtc: Add virtio RTC driver
  doc: virtio: Mention the RTC device
  MAINTAINERS: Add entry for virtio RTC

 MAINTAINERS                         |   5 +
 doc/develop/driver-model/virtio.rst |   4 +-
 drivers/virtio/Kconfig              |   9 ++
 drivers/virtio/Makefile             |   1 +
 drivers/virtio/virtio-uclass.c      |   1 +
 drivers/virtio/virtio_rtc.c         | 213 ++++++++++++++++++++++++++++
 include/virtio.h                    |   4 +-
 7 files changed, 235 insertions(+), 2 deletions(-)
 create mode 100644 drivers/virtio/virtio_rtc.c

-- 
2.43.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-10-14 19:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-14 19:06 [PATCH v2 0/3] virtio: Add a virtio RTC driver Hung-Chun Tseng
2026-10-14 19:06 ` [PATCH v2 1/3] virtio: rtc: Add " Hung-Chun Tseng
2026-10-14 19:46   ` Kuan-Wei Chiu
2026-10-14 19:06 ` [PATCH v2 2/3] doc: virtio: Mention the RTC device Hung-Chun Tseng
2026-10-14 19:30   ` Kuan-Wei Chiu
2026-10-14 19:06 ` [PATCH v2 3/3] MAINTAINERS: Add entry for virtio RTC Hung-Chun Tseng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox