Lines Matching +full:mode +full:- +full:capable

1 // SPDX-License-Identifier: GPL-2.0
31 if (ups && ups->ptm_cap) in pci_upstream_ptm()
54 dev->ptm_cap = ptm; in pci_ptm_init()
58 dev->ptm_granularity = FIELD_GET(PCI_PTM_GRANULARITY_MASK, cap); in pci_ptm_init()
68 if (ups->ptm_granularity == 0) in pci_ptm_init()
69 dev->ptm_granularity = 0; in pci_ptm_init()
70 else if (ups->ptm_granularity > dev->ptm_granularity) in pci_ptm_init()
71 dev->ptm_granularity = ups->ptm_granularity; in pci_ptm_init()
73 dev->ptm_root = 1; in pci_ptm_init()
81 dev->ptm_granularity = 0; in pci_ptm_init()
91 u16 ptm = dev->ptm_cap; in pci_save_ptm_state()
102 cap = (u32 *)&save_state->cap.data[0]; in pci_save_ptm_state()
108 u16 ptm = dev->ptm_cap; in pci_restore_ptm_state()
119 cap = (u32 *)&save_state->cap.data[0]; in pci_restore_ptm_state()
126 u16 ptm = dev->ptm_cap; in __pci_enable_ptm()
131 return -EINVAL; in __pci_enable_ptm()
141 if (!dev->ptm_root) { in __pci_enable_ptm()
143 if (!ups || !ups->ptm_enabled) in __pci_enable_ptm()
144 return -EINVAL; in __pci_enable_ptm()
151 ctrl |= FIELD_PREP(PCI_PTM_GRANULARITY_MASK, dev->ptm_granularity); in __pci_enable_ptm()
152 if (dev->ptm_root) in __pci_enable_ptm()
160 * pci_enable_ptm() - Enable Precision Time Measurement
165 * @granularity is non-NULL, return the Effective Granularity.
167 * Return: zero if successful, or -EINVAL if @dev lacks a PTM Capability or
168 * is not a PTM Root and lacks an upstream path of PTM-enabled devices.
179 dev->ptm_enabled = 1; in pci_enable_ptm()
182 *granularity = dev->ptm_granularity; in pci_enable_ptm()
184 switch (dev->ptm_granularity) { in pci_enable_ptm()
193 dev->ptm_granularity); in pci_enable_ptm()
197 dev->ptm_root ? " (root)" : "", clock_desc); in pci_enable_ptm()
205 u16 ptm = dev->ptm_cap; in __pci_disable_ptm()
217 * pci_disable_ptm() - Disable Precision Time Measurement
224 if (dev->ptm_enabled) { in pci_disable_ptm()
226 dev->ptm_enabled = 0; in pci_disable_ptm()
232 * Disable PTM, but preserve dev->ptm_enabled so we silently re-enable it on
237 if (dev->ptm_enabled) in pci_suspend_ptm()
241 /* If PTM was enabled before suspend, re-enable it when resuming */
244 if (dev->ptm_enabled) in pci_resume_ptm()
253 return dev->ptm_enabled; in pcie_ptm_enabled()
261 struct pci_ptm_debugfs *ptm_debugfs = file->private_data; in context_update_write()
264 u8 mode; in context_update_write() local
266 if (!ptm_debugfs->ops->context_update_write) in context_update_write()
267 return -EOPNOTSUPP; in context_update_write()
270 return -EINVAL; in context_update_write()
274 return -EFAULT; in context_update_write()
279 mode = PCIE_PTM_CONTEXT_UPDATE_AUTO; in context_update_write()
281 mode = PCIE_PTM_CONTEXT_UPDATE_MANUAL; in context_update_write()
283 return -EINVAL; in context_update_write()
285 mutex_lock(&ptm_debugfs->lock); in context_update_write()
286 ret = ptm_debugfs->ops->context_update_write(ptm_debugfs->pdata, mode); in context_update_write()
287 mutex_unlock(&ptm_debugfs->lock); in context_update_write()
297 struct pci_ptm_debugfs *ptm_debugfs = file->private_data; in context_update_read()
300 u8 mode; in context_update_read() local
302 if (!ptm_debugfs->ops->context_update_read) in context_update_read()
303 return -EOPNOTSUPP; in context_update_read()
305 mutex_lock(&ptm_debugfs->lock); in context_update_read()
306 ptm_debugfs->ops->context_update_read(ptm_debugfs->pdata, &mode); in context_update_read()
307 mutex_unlock(&ptm_debugfs->lock); in context_update_read()
309 if (mode == PCIE_PTM_CONTEXT_UPDATE_AUTO) in context_update_read()
329 if (!ptm_debugfs->ops->context_valid_read) in context_valid_get()
330 return -EOPNOTSUPP; in context_valid_get()
332 mutex_lock(&ptm_debugfs->lock); in context_valid_get()
333 ret = ptm_debugfs->ops->context_valid_read(ptm_debugfs->pdata, &valid); in context_valid_get()
334 mutex_unlock(&ptm_debugfs->lock); in context_valid_get()
348 if (!ptm_debugfs->ops->context_valid_write) in context_valid_set()
349 return -EOPNOTSUPP; in context_valid_set()
351 mutex_lock(&ptm_debugfs->lock); in context_valid_set()
352 ret = ptm_debugfs->ops->context_valid_write(ptm_debugfs->pdata, !!val); in context_valid_set()
353 mutex_unlock(&ptm_debugfs->lock); in context_valid_set()
367 if (!ptm_debugfs->ops->local_clock_read) in local_clock_get()
368 return -EOPNOTSUPP; in local_clock_get()
370 ret = ptm_debugfs->ops->local_clock_read(ptm_debugfs->pdata, &clock); in local_clock_get()
387 if (!ptm_debugfs->ops->master_clock_read) in master_clock_get()
388 return -EOPNOTSUPP; in master_clock_get()
390 ret = ptm_debugfs->ops->master_clock_read(ptm_debugfs->pdata, &clock); in master_clock_get()
407 if (!ptm_debugfs->ops->t1_read) in t1_get()
408 return -EOPNOTSUPP; in t1_get()
410 ret = ptm_debugfs->ops->t1_read(ptm_debugfs->pdata, &clock); in t1_get()
427 if (!ptm_debugfs->ops->t2_read) in t2_get()
428 return -EOPNOTSUPP; in t2_get()
430 ret = ptm_debugfs->ops->t2_read(ptm_debugfs->pdata, &clock); in t2_get()
447 if (!ptm_debugfs->ops->t3_read) in t3_get()
448 return -EOPNOTSUPP; in t3_get()
450 ret = ptm_debugfs->ops->t3_read(ptm_debugfs->pdata, &clock); in t3_get()
467 if (!ptm_debugfs->ops->t4_read) in t4_get()
468 return -EOPNOTSUPP; in t4_get()
470 ret = ptm_debugfs->ops->t4_read(ptm_debugfs->pdata, &clock); in t4_get()
481 #define pcie_ptm_create_debugfs_file(pdata, mode, attr) \ argument
483 if (ops->attr##_visible && ops->attr##_visible(pdata)) \
484 debugfs_create_file(#attr, mode, ptm_debugfs->debugfs, \
489 * pcie_ptm_create_debugfs() - Create debugfs entries for the PTM context
490 * @dev: PTM capable component device
491 * @pdata: Private data of the PTM capable component device
494 * Create debugfs entries for exposing the PTM context of the PTM capable
507 if (!ops->check_capability) in pcie_ptm_create_debugfs()
511 ret = ops->check_capability(pdata); in pcie_ptm_create_debugfs()
525 ptm_debugfs->debugfs = debugfs_create_dir(dirname, NULL); in pcie_ptm_create_debugfs()
526 ptm_debugfs->pdata = pdata; in pcie_ptm_create_debugfs()
527 ptm_debugfs->ops = ops; in pcie_ptm_create_debugfs()
528 mutex_init(&ptm_debugfs->lock); in pcie_ptm_create_debugfs()
544 * pcie_ptm_destroy_debugfs() - Destroy debugfs entries for the PTM context
552 mutex_destroy(&ptm_debugfs->lock); in pcie_ptm_destroy_debugfs()
553 debugfs_remove_recursive(ptm_debugfs->debugfs); in pcie_ptm_destroy_debugfs()