xref: /openbmc/linux/drivers/ptp/ptp_kvm_arm.c (revision da1d9caf)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  *  Virtual PTP 1588 clock for use with KVM guests
4  *  Copyright (C) 2019 ARM Ltd.
5  *  All Rights Reserved
6  */
7 
8 #include <linux/arm-smccc.h>
9 #include <linux/ptp_kvm.h>
10 
11 #include <asm/arch_timer.h>
12 #include <asm/hypervisor.h>
13 
14 int kvm_arch_ptp_init(void)
15 {
16 	int ret;
17 
18 	ret = kvm_arm_hyp_service_available(ARM_SMCCC_KVM_FUNC_PTP);
19 	if (ret <= 0)
20 		return -EOPNOTSUPP;
21 
22 	return 0;
23 }
24 
25 int kvm_arch_ptp_get_clock(struct timespec64 *ts)
26 {
27 	return kvm_arch_ptp_get_crosststamp(NULL, ts, NULL);
28 }
29