ptp_kvm_arm.c 533 B

12345678910111213141516171819202122232425262728
  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. #include <linux/arm-smccc.h>
  8. #include <linux/ptp_kvm.h>
  9. #include <asm/arch_timer.h>
  10. #include <asm/hypervisor.h>
  11. int kvm_arch_ptp_init(void)
  12. {
  13. int ret;
  14. ret = kvm_arm_hyp_service_available(ARM_SMCCC_KVM_FUNC_PTP);
  15. if (ret <= 0)
  16. return -EOPNOTSUPP;
  17. return 0;
  18. }
  19. int kvm_arch_ptp_get_clock(struct timespec64 *ts)
  20. {
  21. return kvm_arch_ptp_get_crosststamp(NULL, ts, NULL);
  22. }