// SPDX-License-Identifier: GPL-2.0 /* * PCI Express Precision Time Measurement * Copyright (c) 2016, Intel Corporation. */ #include <linux/bitfield.h> #include <linux/module.h> #include <linux/init.h> #include <linux/pci.h> #include "../pci.h" /* * If the next upstream device supports PTM, return it; otherwise return * NULL. PTM Messages are local, so both link partners must support it. */ static struct pci_dev *pci_upstream_ptm(struct pci_dev *dev) { … } /* * Find the PTM Capability (if present) and extract the information we need * to use it. */ void pci_ptm_init(struct pci_dev *dev) { … } void pci_save_ptm_state(struct pci_dev *dev) { … } void pci_restore_ptm_state(struct pci_dev *dev) { … } /* Enable PTM in the Control register if possible */ static int __pci_enable_ptm(struct pci_dev *dev) { … } /** * pci_enable_ptm() - Enable Precision Time Measurement * @dev: PCI device * @granularity: pointer to return granularity * * Enable Precision Time Measurement for @dev. If successful and * @granularity is non-NULL, return the Effective Granularity. * * Return: zero if successful, or -EINVAL if @dev lacks a PTM Capability or * is not a PTM Root and lacks an upstream path of PTM-enabled devices. */ int pci_enable_ptm(struct pci_dev *dev, u8 *granularity) { … } EXPORT_SYMBOL(…); static void __pci_disable_ptm(struct pci_dev *dev) { … } /** * pci_disable_ptm() - Disable Precision Time Measurement * @dev: PCI device * * Disable Precision Time Measurement for @dev. */ void pci_disable_ptm(struct pci_dev *dev) { … } EXPORT_SYMBOL(…); /* * Disable PTM, but preserve dev->ptm_enabled so we silently re-enable it on * resume if necessary. */ void pci_suspend_ptm(struct pci_dev *dev) { … } /* If PTM was enabled before suspend, re-enable it when resuming */ void pci_resume_ptm(struct pci_dev *dev) { … } bool pcie_ptm_enabled(struct pci_dev *dev) { … } EXPORT_SYMBOL(…);