Commit 0623c759 authored by Peter Hilber's avatar Peter Hilber Committed by Michael S. Tsirkin
Browse files

virtio_rtc: Add module and driver core



Add the virtio_rtc module and driver core. The virtio_rtc module implements
a driver compatible with the proposed Virtio RTC device specification.
The Virtio RTC (Real Time Clock) device provides information about current
time. The device can provide different clocks, e.g. for the UTC or TAI time
standards, or for physical time elapsed since some past epoch. The driver
can read the clocks with simple or more accurate methods.

Implement the core, which interacts with the Virtio RTC device. Apart from
this, the core does not expose functionality outside of the virtio_rtc
module. Follow-up patches will expose PTP clocks and an RTC Class device.

Provide synchronous messaging, which is enough for the expected time
synchronization use cases through PTP clocks (similar to ptp_kvm) or RTC
Class device.

Signed-off-by: default avatarPeter Hilber <quic_philber@quicinc.com>
Message-Id: <20250509160734.1772-2-quic_philber@quicinc.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent 169294a1
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -25827,6 +25827,13 @@ S: Maintained
F:	drivers/nvdimm/nd_virtio.c
F:	drivers/nvdimm/virtio_pmem.c
VIRTIO RTC DRIVER
M:	Peter Hilber <quic_philber@quicinc.com>
L:	virtualization@lists.linux.dev
S:	Maintained
F:	drivers/virtio/virtio_rtc_*
F:	include/uapi/linux/virtio_rtc.h
VIRTIO SOUND DRIVER
M:	Anton Yakovlev <anton.yakovlev@opensynergy.com>
M:	"Michael S. Tsirkin" <mst@redhat.com>
+13 −0
Original line number Diff line number Diff line
@@ -188,4 +188,17 @@ config VIRTIO_DEBUG

	  If unsure, say N.

config VIRTIO_RTC
	tristate "Virtio RTC driver"
	depends on VIRTIO
	depends on PTP_1588_CLOCK_OPTIONAL
	help
	 This driver provides current time from a Virtio RTC device. The driver
	 provides the time through one or more clocks.

	 To compile this code as a module, choose M here: the module will be
	 called virtio_rtc.

	 If unsure, say M.

endif # VIRTIO_MENU
+2 −0
Original line number Diff line number Diff line
@@ -14,3 +14,5 @@ obj-$(CONFIG_VIRTIO_VDPA) += virtio_vdpa.o
obj-$(CONFIG_VIRTIO_MEM) += virtio_mem.o
obj-$(CONFIG_VIRTIO_DMA_SHARED_BUFFER) += virtio_dma_buf.o
obj-$(CONFIG_VIRTIO_DEBUG) += virtio_debug.o
obj-$(CONFIG_VIRTIO_RTC) += virtio_rtc.o
virtio_rtc-y := virtio_rtc_driver.o
+786 −0

File added.

Preview size limit exceeded, changes collapsed.

+24 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * virtio_rtc internal interfaces
 *
 * Copyright (C) 2022-2023 OpenSynergy GmbH
 * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
 */

#ifndef _VIRTIO_RTC_INTERNAL_H_
#define _VIRTIO_RTC_INTERNAL_H_

#include <linux/types.h>

/* driver core IFs */

struct viortc_dev;

int viortc_read(struct viortc_dev *viortc, u16 vio_clk_id, u64 *reading);
int viortc_read_cross(struct viortc_dev *viortc, u16 vio_clk_id, u8 hw_counter,
		      u64 *reading, u64 *cycles);
int viortc_cross_cap(struct viortc_dev *viortc, u16 vio_clk_id, u8 hw_counter,
		     bool *supported);

#endif /* _VIRTIO_RTC_INTERNAL_H_ */
Loading