From: Wei Fang <wei.fang@nxp.com>
To: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
richardcochran@gmail.com, claudiu.manoil@nxp.com,
vladimir.oltean@nxp.com, xiaoning.wang@nxp.com,
andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, vadim.fedorenko@linux.dev,
Frank.Li@nxp.com, shawnguo@kernel.org
Cc: fushi.peng@nxp.com, devicetree@vger.kernel.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
imx@lists.linux.dev
Subject: [PATCH v6 net-next 09/17] ptp: netc: add the periodic output signal loopback support
Date: Wed, 27 Aug 2025 14:33:24 +0800 [thread overview]
Message-ID: <20250827063332.1217664-10-wei.fang@nxp.com> (raw)
In-Reply-To: <20250827063332.1217664-1-wei.fang@nxp.com>
The NETC Timer supports looping back the output pulse signal of Fiper-n
into Trigger-n input, so that users can leverage this feature to validate
some other features without external hardware support. For example, users
can use it to test external trigger stamp (EXTTS). And users can combine
EXTTS with loopback mode to check whether the generation time of PPS is
aligned with an integral second of PHC, or the periodic output signal
(PTP_CLK_REQ_PEROUT) whether is generated at the specified time.
Since ptp_clock_info::perout_loopback() has been added to the ptp_clock
driver as a generic interface to enable or disable the periodic output
signal loopback, therefore, netc_timer_perout_loopback() is added as a
callback of ptp_clock_info::perout_loopback().
Test the generation time of PPS event:
$ echo 0 1 > /sys/kernel/debug/ptp0/perout_loopback
$ echo 1 > /sys/class/ptp/ptp0/pps_enable
$ testptp -d /dev/ptp0 -e 3
external time stamp request okay
event index 0 at 63.000000017
event index 0 at 64.000000017
event index 0 at 65.000000017
Test the generation time of the periodic output signal:
$ echo 0 1 > /sys/kernel/debug/ptp0/perout_loopback
$ echo 0 150 0 1 500000000 > /sys/class/ptp/ptp0/period
$ testptp -d /dev/ptp0 -e 3
external time stamp request okay
event index 0 at 150.000000014
event index 0 at 151.500000015
event index 0 at 153.000000014
Signed-off-by: Wei Fang <wei.fang@nxp.com>
---
v6 changes:
1. Change the subject and modify the commit message
2. Remove the debugfs interfaces from the ptp_netc driver and use
the generic ptp_clock_info::perout_loopback() instead
v5 no changes
v4 changes:
1. Slightly modify the commit message and add Reviewed-by tag
v3 changes:
1. Rename TMR_CTRL_PP1L and TMR_CTRL_PP2L to TMR_CTRL_PPL(i)
2. Remove switch statement from netc_timer_get_fiper_loopback() and
netc_timer_set_fiper_loopback()
v2 changes:
1. Remove the check of the return value of debugfs_create_dir()
---
drivers/ptp/ptp_netc.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/drivers/ptp/ptp_netc.c b/drivers/ptp/ptp_netc.c
index 8c5fea1f43fa..75594f47807d 100644
--- a/drivers/ptp/ptp_netc.c
+++ b/drivers/ptp/ptp_netc.c
@@ -21,6 +21,7 @@
#define TMR_ETEP(i) BIT(8 + (i))
#define TMR_COMP_MODE BIT(15)
#define TMR_CTRL_TCLK_PERIOD GENMASK(25, 16)
+#define TMR_CTRL_PPL(i) BIT(27 - (i))
#define TMR_CTRL_FS BIT(28)
#define NETC_TMR_TEVENT 0x0084
@@ -609,6 +610,28 @@ static int netc_timer_enable(struct ptp_clock_info *ptp,
}
}
+static int netc_timer_perout_loopback(struct ptp_clock_info *ptp,
+ unsigned int index, int on)
+{
+ struct netc_timer *priv = ptp_to_netc_timer(ptp);
+ unsigned long flags;
+ u32 tmr_ctrl;
+
+ spin_lock_irqsave(&priv->lock, flags);
+
+ tmr_ctrl = netc_timer_rd(priv, NETC_TMR_CTRL);
+ if (on)
+ tmr_ctrl |= TMR_CTRL_PPL(index);
+ else
+ tmr_ctrl &= ~TMR_CTRL_PPL(index);
+
+ netc_timer_wr(priv, NETC_TMR_CTRL, tmr_ctrl);
+
+ spin_unlock_irqrestore(&priv->lock, flags);
+
+ return 0;
+}
+
static void netc_timer_adjust_period(struct netc_timer *priv, u64 period)
{
u32 fractional_period = lower_32_bits(period);
@@ -717,6 +740,7 @@ static const struct ptp_clock_info netc_timer_ptp_caps = {
.pps = 1,
.n_per_out = 3,
.n_ext_ts = 2,
+ .n_per_lp = 2,
.supported_extts_flags = PTP_RISING_EDGE | PTP_FALLING_EDGE |
PTP_STRICT_FLAGS,
.adjfine = netc_timer_adjfine,
@@ -724,6 +748,7 @@ static const struct ptp_clock_info netc_timer_ptp_caps = {
.gettimex64 = netc_timer_gettimex64,
.settime64 = netc_timer_settime64,
.enable = netc_timer_enable,
+ .perout_loopback = netc_timer_perout_loopback,
};
static void netc_timer_init(struct netc_timer *priv)
--
2.34.1
next prev parent reply other threads:[~2025-08-27 6:55 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-27 6:33 [PATCH v6 net-next 00/17] Add NETC Timer PTP driver and add PTP support for i.MX95 Wei Fang
2025-08-27 6:33 ` [PATCH v6 net-next 01/17] dt-bindings: ptp: add NETC Timer PTP clock Wei Fang
2025-08-27 12:15 ` Krzysztof Kozlowski
2025-08-27 6:33 ` [PATCH v6 net-next 02/17] dt-bindings: net: move ptp-timer property to ethernet-controller.yaml Wei Fang
2025-08-27 6:33 ` [PATCH v6 net-next 03/17] ptp: add helpers to get the phc_index by of_node or dev Wei Fang
2025-09-04 13:21 ` Richard Cochran
2025-08-27 6:33 ` [PATCH v6 net-next 04/17] ptp: add debugfs interfaces to loop back the periodic output signal Wei Fang
2025-08-27 15:11 ` Frank Li
2025-08-28 2:04 ` Wei Fang
2025-08-28 0:00 ` Jakub Kicinski
2025-08-28 2:10 ` Wei Fang
2025-08-27 6:33 ` [PATCH v6 net-next 05/17] ptp: netc: add NETC V4 Timer PTP driver support Wei Fang
2025-08-27 6:33 ` [PATCH v6 net-next 06/17] ptp: netc: add PTP_CLK_REQ_PPS support Wei Fang
2025-08-27 6:33 ` [PATCH v6 net-next 07/17] ptp: netc: add periodic pulse output support Wei Fang
2025-08-27 6:33 ` [PATCH v6 net-next 08/17] ptp: netc: add external trigger stamp support Wei Fang
2025-08-27 6:33 ` Wei Fang [this message]
2025-08-27 6:33 ` [PATCH v6 net-next 10/17] MAINTAINERS: add NETC Timer PTP clock driver section Wei Fang
2025-08-27 6:33 ` [PATCH v6 net-next 11/17] net: enetc: save the parsed information of PTP packet to skb->cb Wei Fang
2025-08-27 6:33 ` [PATCH v6 net-next 12/17] net: enetc: extract enetc_update_ptp_sync_msg() to handle PTP Sync packets Wei Fang
2025-08-27 6:33 ` [PATCH v6 net-next 13/17] net: enetc: remove unnecessary CONFIG_FSL_ENETC_PTP_CLOCK check Wei Fang
2025-08-27 6:33 ` [PATCH v6 net-next 14/17] net: enetc: move sync packet modification before dma_map_single() Wei Fang
2025-08-27 14:49 ` Frank Li
2025-08-27 6:33 ` [PATCH v6 net-next 15/17] net: enetc: add PTP synchronization support for ENETC v4 Wei Fang
2025-08-27 15:02 ` Frank Li
2025-08-27 6:33 ` [PATCH v6 net-next 16/17] net: enetc: don't update sync packet checksum if checksum offload is used Wei Fang
2025-08-27 6:33 ` [PATCH v6 17/17] arm64: dts: imx95: add standard PCI device compatible string to NETC Timer Wei Fang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250827063332.1217664-10-wei.fang@nxp.com \
--to=wei.fang@nxp.com \
--cc=Frank.Li@nxp.com \
--cc=andrew+netdev@lunn.ch \
--cc=claudiu.manoil@nxp.com \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=fushi.peng@nxp.com \
--cc=imx@lists.linux.dev \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=robh@kernel.org \
--cc=shawnguo@kernel.org \
--cc=vadim.fedorenko@linux.dev \
--cc=vladimir.oltean@nxp.com \
--cc=xiaoning.wang@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®