xref: /linux/drivers/ptp/ptp_kvm_arm.c (revision b152688c91313ab4073cff4a5e63ff4cc491c358)
1300bb1feSJianyong Wu // SPDX-License-Identifier: GPL-2.0-only
2300bb1feSJianyong Wu /*
3300bb1feSJianyong Wu  *  Virtual PTP 1588 clock for use with KVM guests
4300bb1feSJianyong Wu  *  Copyright (C) 2019 ARM Ltd.
5300bb1feSJianyong Wu  *  All Rights Reserved
6300bb1feSJianyong Wu  */
7300bb1feSJianyong Wu 
8300bb1feSJianyong Wu #include <linux/arm-smccc.h>
9300bb1feSJianyong Wu #include <linux/ptp_kvm.h>
10300bb1feSJianyong Wu 
11300bb1feSJianyong Wu #include <asm/arch_timer.h>
12300bb1feSJianyong Wu #include <asm/hypervisor.h>
13300bb1feSJianyong Wu 
kvm_arch_ptp_init(void)14300bb1feSJianyong Wu int kvm_arch_ptp_init(void)
15300bb1feSJianyong Wu {
16300bb1feSJianyong Wu 	int ret;
17300bb1feSJianyong Wu 
18300bb1feSJianyong Wu 	ret = kvm_arm_hyp_service_available(ARM_SMCCC_KVM_FUNC_PTP);
19300bb1feSJianyong Wu 	if (ret <= 0)
20300bb1feSJianyong Wu 		return -EOPNOTSUPP;
21300bb1feSJianyong Wu 
22300bb1feSJianyong Wu 	return 0;
23300bb1feSJianyong Wu }
24300bb1feSJianyong Wu 
kvm_arch_ptp_exit(void)256365ba64SJeremi Piotrowski void kvm_arch_ptp_exit(void)
266365ba64SJeremi Piotrowski {
276365ba64SJeremi Piotrowski }
286365ba64SJeremi Piotrowski 
kvm_arch_ptp_get_clock(struct timespec64 * ts)29300bb1feSJianyong Wu int kvm_arch_ptp_get_clock(struct timespec64 *ts)
30300bb1feSJianyong Wu {
31*b152688cSPeter Hilber 	return kvm_arch_ptp_get_crosststamp(NULL, ts, NULL);
32300bb1feSJianyong Wu }
33