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, so that "date" and anything else using dm_rtc_get() work on any virtio-capable QEMU target.
Patch 1 adds the driver, patch 2 updates the virtio documentation and patch 3 adds a MAINTAINERS entry. Patch 4 lets sandbox tests answer virtqueue requests as the device would, which patch 5 uses to test the driver. v5 only changes the documentation in patch 2, following Kuan-Wei's review, and adds his Reviewed-by to patch 1. The code is unchanged from v4. Tested with qemu-riscv64_smode_defconfig and RTC_GOLDFISH disabled, on QEMU v11.1.2, which reports a UTC clock, and on QEMU master, which reports a smeared UTC clock: - With -device virtio-rtc-pci and with -device virtio-rtc-device, "date" reads the host time and advances between reads. - Setting the time fails, as the clocks are read-only. - With no virtio RTC device, "date" fails cleanly with err=-19. On sandbox, "ut dm virtio_rtc*" passes. Hung-Chun Tseng (5): virtio: rtc: Add virtio RTC driver doc: virtio: List the supported device types MAINTAINERS: Add entry for virtio RTC virtio: sandbox: Let tests emulate the device side of a virtqueue test: dm: Add tests for the virtio RTC driver MAINTAINERS | 6 + arch/sandbox/dts/test.dts | 5 + arch/sandbox/include/asm/test.h | 25 +++ doc/develop/driver-model/virtio.rst | 15 +- drivers/virtio/Kconfig | 11 + drivers/virtio/Makefile | 1 + drivers/virtio/virtio-uclass.c | 1 + drivers/virtio/virtio_rtc.c | 244 ++++++++++++++++++++++ drivers/virtio/virtio_sandbox.c | 15 ++ include/virtio.h | 4 +- test/dm/Makefile | 1 + test/dm/virtio_rtc.c | 306 ++++++++++++++++++++++++++++ 12 files changed, 629 insertions(+), 5 deletions(-) create mode 100644 drivers/virtio/virtio_rtc.c create mode 100644 test/dm/virtio_rtc.c -- 2.43.0
