Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ptp: qoriq: convert to use generic interfaces to set loopback mode

Since the generic debugfs interfaces for setting the periodic pulse
signal loopback have been added to the ptp_clock driver, so convert
the vendor-defined debugfs interfaces to the generic interfaces.

Signed-off-by: Wei Fang <wei.fang@nxp.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Link: https://patch.msgid.link/20250905030711.1509648-4-wei.fang@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Wei Fang and committed by
Jakub Kicinski
f3164840 67ac8363

+24 -118
-1
MAINTAINERS
··· 9817 9817 F: drivers/net/ethernet/freescale/dpaa2/dprtc* 9818 9818 F: drivers/net/ethernet/freescale/enetc/enetc_ptp.c 9819 9819 F: drivers/ptp/ptp_qoriq.c 9820 - F: drivers/ptp/ptp_qoriq_debugfs.c 9821 9820 F: include/linux/fsl/ptp_qoriq.h 9822 9821 9823 9822 FREESCALE QUAD SPI DRIVER
+1 -1
drivers/ptp/Kconfig
··· 67 67 packets using the SO_TIMESTAMPING API. 68 68 69 69 To compile this driver as a module, choose M here: the module 70 - will be called ptp-qoriq. 70 + will be called ptp_qoriq. 71 71 72 72 comment "Enable PHYLIB and NETWORK_PHY_TIMESTAMPING to see the additional clocks." 73 73 depends on PHYLIB=n || NETWORK_PHY_TIMESTAMPING=n
+1 -3
drivers/ptp/Makefile
··· 12 12 obj-$(CONFIG_PTP_1588_CLOCK_PCH) += ptp_pch.o 13 13 obj-$(CONFIG_PTP_1588_CLOCK_KVM) += ptp_kvm.o 14 14 obj-$(CONFIG_PTP_1588_CLOCK_VMCLOCK) += ptp_vmclock.o 15 - obj-$(CONFIG_PTP_1588_CLOCK_QORIQ) += ptp-qoriq.o 16 - ptp-qoriq-y += ptp_qoriq.o 17 - ptp-qoriq-$(CONFIG_DEBUG_FS) += ptp_qoriq_debugfs.o 15 + obj-$(CONFIG_PTP_1588_CLOCK_QORIQ) += ptp_qoriq.o 18 16 obj-$(CONFIG_PTP_1588_CLOCK_IDTCM) += ptp_clockmatrix.o 19 17 obj-$(CONFIG_PTP_1588_CLOCK_FC3W) += ptp_fc3.o 20 18 obj-$(CONFIG_PTP_1588_CLOCK_IDT82P33) += ptp_idt82p33.o
+22 -2
drivers/ptp/ptp_qoriq.c
··· 465 465 return 0; 466 466 } 467 467 468 + static int ptp_qoriq_perout_loopback(struct ptp_clock_info *ptp, 469 + unsigned int index, int on) 470 + { 471 + struct ptp_qoriq *ptp_qoriq = container_of(ptp, struct ptp_qoriq, caps); 472 + struct ptp_qoriq_registers *regs = &ptp_qoriq->regs; 473 + u32 loopback_bit = index ? PP2L : PP1L; 474 + u32 tmr_ctrl; 475 + 476 + tmr_ctrl = ptp_qoriq->read(&regs->ctrl_regs->tmr_ctrl); 477 + if (on) 478 + tmr_ctrl |= loopback_bit; 479 + else 480 + tmr_ctrl &= ~loopback_bit; 481 + 482 + ptp_qoriq->write(&regs->ctrl_regs->tmr_ctrl, tmr_ctrl); 483 + 484 + return 0; 485 + } 486 + 468 487 int ptp_qoriq_init(struct ptp_qoriq *ptp_qoriq, void __iomem *base, 469 488 const struct ptp_clock_info *caps) 470 489 { ··· 498 479 499 480 ptp_qoriq->base = base; 500 481 ptp_qoriq->caps = *caps; 482 + ptp_qoriq->caps.n_per_lp = 2; 483 + ptp_qoriq->caps.perout_loopback = ptp_qoriq_perout_loopback; 501 484 502 485 if (of_property_read_u32(node, "fsl,cksel", &ptp_qoriq->cksel)) 503 486 ptp_qoriq->cksel = DEFAULT_CKSEL; ··· 589 568 return PTR_ERR(ptp_qoriq->clock); 590 569 591 570 ptp_qoriq->phc_index = ptp_clock_index(ptp_qoriq->clock); 592 - ptp_qoriq_create_debugfs(ptp_qoriq); 571 + 593 572 return 0; 594 573 } 595 574 EXPORT_SYMBOL_GPL(ptp_qoriq_init); ··· 601 580 ptp_qoriq->write(&regs->ctrl_regs->tmr_temask, 0); 602 581 ptp_qoriq->write(&regs->ctrl_regs->tmr_ctrl, 0); 603 582 604 - ptp_qoriq_remove_debugfs(ptp_qoriq); 605 583 ptp_clock_unregister(ptp_qoriq->clock); 606 584 iounmap(ptp_qoriq->base); 607 585 free_irq(ptp_qoriq->irq, ptp_qoriq);
-101
drivers/ptp/ptp_qoriq_debugfs.c
··· 1 - // SPDX-License-Identifier: GPL-2.0+ 2 - /* Copyright 2019 NXP 3 - */ 4 - #include <linux/device.h> 5 - #include <linux/debugfs.h> 6 - #include <linux/fsl/ptp_qoriq.h> 7 - 8 - static int ptp_qoriq_fiper1_lpbk_get(void *data, u64 *val) 9 - { 10 - struct ptp_qoriq *ptp_qoriq = data; 11 - struct ptp_qoriq_registers *regs = &ptp_qoriq->regs; 12 - u32 ctrl; 13 - 14 - ctrl = ptp_qoriq->read(&regs->ctrl_regs->tmr_ctrl); 15 - *val = ctrl & PP1L ? 1 : 0; 16 - 17 - return 0; 18 - } 19 - 20 - static int ptp_qoriq_fiper1_lpbk_set(void *data, u64 val) 21 - { 22 - struct ptp_qoriq *ptp_qoriq = data; 23 - struct ptp_qoriq_registers *regs = &ptp_qoriq->regs; 24 - u32 ctrl; 25 - 26 - ctrl = ptp_qoriq->read(&regs->ctrl_regs->tmr_ctrl); 27 - if (val == 0) 28 - ctrl &= ~PP1L; 29 - else 30 - ctrl |= PP1L; 31 - 32 - ptp_qoriq->write(&regs->ctrl_regs->tmr_ctrl, ctrl); 33 - return 0; 34 - } 35 - 36 - DEFINE_DEBUGFS_ATTRIBUTE(ptp_qoriq_fiper1_fops, ptp_qoriq_fiper1_lpbk_get, 37 - ptp_qoriq_fiper1_lpbk_set, "%llu\n"); 38 - 39 - static int ptp_qoriq_fiper2_lpbk_get(void *data, u64 *val) 40 - { 41 - struct ptp_qoriq *ptp_qoriq = data; 42 - struct ptp_qoriq_registers *regs = &ptp_qoriq->regs; 43 - u32 ctrl; 44 - 45 - ctrl = ptp_qoriq->read(&regs->ctrl_regs->tmr_ctrl); 46 - *val = ctrl & PP2L ? 1 : 0; 47 - 48 - return 0; 49 - } 50 - 51 - static int ptp_qoriq_fiper2_lpbk_set(void *data, u64 val) 52 - { 53 - struct ptp_qoriq *ptp_qoriq = data; 54 - struct ptp_qoriq_registers *regs = &ptp_qoriq->regs; 55 - u32 ctrl; 56 - 57 - ctrl = ptp_qoriq->read(&regs->ctrl_regs->tmr_ctrl); 58 - if (val == 0) 59 - ctrl &= ~PP2L; 60 - else 61 - ctrl |= PP2L; 62 - 63 - ptp_qoriq->write(&regs->ctrl_regs->tmr_ctrl, ctrl); 64 - return 0; 65 - } 66 - 67 - DEFINE_DEBUGFS_ATTRIBUTE(ptp_qoriq_fiper2_fops, ptp_qoriq_fiper2_lpbk_get, 68 - ptp_qoriq_fiper2_lpbk_set, "%llu\n"); 69 - 70 - void ptp_qoriq_create_debugfs(struct ptp_qoriq *ptp_qoriq) 71 - { 72 - struct dentry *root; 73 - 74 - root = debugfs_create_dir(dev_name(ptp_qoriq->dev), NULL); 75 - if (IS_ERR(root)) 76 - return; 77 - if (!root) 78 - goto err_root; 79 - 80 - ptp_qoriq->debugfs_root = root; 81 - 82 - if (!debugfs_create_file_unsafe("fiper1-loopback", 0600, root, 83 - ptp_qoriq, &ptp_qoriq_fiper1_fops)) 84 - goto err_node; 85 - if (!debugfs_create_file_unsafe("fiper2-loopback", 0600, root, 86 - ptp_qoriq, &ptp_qoriq_fiper2_fops)) 87 - goto err_node; 88 - return; 89 - 90 - err_node: 91 - debugfs_remove_recursive(root); 92 - ptp_qoriq->debugfs_root = NULL; 93 - err_root: 94 - dev_err(ptp_qoriq->dev, "failed to initialize debugfs\n"); 95 - } 96 - 97 - void ptp_qoriq_remove_debugfs(struct ptp_qoriq *ptp_qoriq) 98 - { 99 - debugfs_remove_recursive(ptp_qoriq->debugfs_root); 100 - ptp_qoriq->debugfs_root = NULL; 101 - }
-10
include/linux/fsl/ptp_qoriq.h
··· 145 145 struct ptp_clock *clock; 146 146 struct ptp_clock_info caps; 147 147 struct resource *rsrc; 148 - struct dentry *debugfs_root; 149 148 struct device *dev; 150 149 bool extts_fifo_support; 151 150 bool fiper3_support; ··· 194 195 int ptp_qoriq_enable(struct ptp_clock_info *ptp, 195 196 struct ptp_clock_request *rq, int on); 196 197 int extts_clean_up(struct ptp_qoriq *ptp_qoriq, int index, bool update_event); 197 - #ifdef CONFIG_DEBUG_FS 198 - void ptp_qoriq_create_debugfs(struct ptp_qoriq *ptp_qoriq); 199 - void ptp_qoriq_remove_debugfs(struct ptp_qoriq *ptp_qoriq); 200 - #else 201 - static inline void ptp_qoriq_create_debugfs(struct ptp_qoriq *ptp_qoriq) 202 - { } 203 - static inline void ptp_qoriq_remove_debugfs(struct ptp_qoriq *ptp_qoriq) 204 - { } 205 - #endif 206 198 207 199 #endif