Skip to content

net: ethernet: ti: am65-cpts: add PTP_SYS_OFFSET_PRECISE support

James Clark linux-arm-kernel linux-devicetree lkml netdev 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 0 repliesNew
  2. v13 patches 5 repliesApplied

Changes in v2 from the cover letter

- Rebased on net-next
- Dropped the syscon compatible patch, applied to mfd by Lee Jones
- Made a failed ti,gtc-push lookup a warning; the probe continues without PTP_SYS_OFFSET_PRECISE (Rob Herring)
- Three smaller fixes to the driver, listed in patch 2
- Link to v1: https://lore.kernel.org/all/[email protected]/

[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/179511436097.97786.7515300839199702588.b4-ty@b4/

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2dt-bindings: net: ti,k3-am654-cpts: add ti,gtc-pushDocumentation/devicetree/bindings/net/ti,k3-am654-cpts.yaml+17 -00 replies
2/2net: ethernet: ti: am65-cpts: implement PTP_SYS_OFFSET_PRECISEdrivers/net/ethernet/ti/am65-cpts.c+313 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH net-next v2 0/2] net: ethernet: ti: am65-cpts: add PTP_SYS_OFFSET_PRECISE support

This series adds PTP_SYS_OFFSET_PRECISE to the CPTS driver for TI K3 SoCs. This brings a similar hardware-supported level of precision to the transfer of time from the PHC to the system clock as already exists for the transfer of time into the PHC, whether over the network using hardware timestamping of packets, or from a GNSS receiver using hardware timestamping of its PPS signal.

The system counter of these SoCs, the Global Timebase Counter (GTC), can export one of its bits on a push event output. The Time Sync Router can route that output to a CPTS hardware timestamp input. The CPTS then timestamps edges that fall at known counter values, so each timestamp gives an exact pair of PHC time and system counter value. This is similar to the PCIe PTM integration on these SoCs, where a selected bit of the PTM timer drives a push input of the PCIe CPTS.

v2 drops patch 1 of v1, since it has been applied to the mfd tree [2]; it added a syscon compatible for the GTC register frame that selects the bit. In v2, patch 1 adds a ti,gtc-push property to the CPTS binding, which names that syscon and the CPTS input; patch 2 implements getcrosststamp.

The series does not set up the Time Sync Router. Mainline has no binding for it on the J722S, so for now a board overlay sets the route, as it does for ti,pps. With Rahul Sharma's proposed binding for the router [1], the CPTS node could select the route itself. ti,gtc-push would stay the same.

Tested on a BeagleY-AI (AM67A / J722S), a BeagleBone AI-64 (TDA4VM / J721E) and a BeaglePlay (AM625).

With this series, phc2sys steering the system clock from a free-running PHC sees an offset that never varies by more than 1ns, whether idle or under memory load. Since the PHC and the system counter run from the same oscillator, this is the noise of PTP_SYS_OFFSET_PRECISE itself. Without this series, phc2sys falls back to PTP_SYS_OFFSET_EXTENDED and the offset has a standard deviation of 2.5 to 10ns when idle and 22 to 31ns under load, with excursions of up to 200ns.

When the PHC is disciplined (by ptp4l or ts2phc, to within 4 to 7ns rms of its reference), the offset seen by phc2sys with this series has a standard deviation of 2 to 5ns, whether idle or under memory load. Without this series, it has a standard deviation of 5 to 12ns when idle and 22 to 29ns under load, again with excursions of up to 200ns.

PTP_SYS_OFFSET_PRECISE has a fixed bias, the capture delay of the push event through the Time Sync Router and the CPTS input (about 11ns, plus an undocumented delay in the GTC), which did not measurably change under any load or CPU clock. This series does not correct for this bias. The driver similarly does not correct for timestamping delay on extts inputs, nor for ingress/egress latency in hardware timestamping of packets. It turns out that the bias in PTP_SYS_OFFSET_PRECISE and the delay in extts timestamping largely cancel each other out. The offset of PTP_SYS_OFFSET_EXTENDED relative to PTP_SYS_OFFSET_PRECISE is about -50ns when idle, and moves by up to 40ns with memory load and by up to 60ns with CPU clock frequency.

The implementation was also stress tested by using ntpperf to load the CPTS (-D 0 -M at 15,000/s and -N 0 at 5,000/s). No errors or wrong pairs were seen.

To try it on a BeagleY-AI, apply this overlay:

	// SPDX-License-Identifier: GPL-2.0-only OR MIT
	/dts-v1/;
	/plugin/;

	&{/} {
		#address-cells = <2>;
		#size-cells = <2>;

		wkup_gtc: syscon@a80000 {
			compatible = "ti,am654-gtc", "syscon";
			reg = <0x0 0xa80000 0x0 0x400>;
		};
	};

	&cbass_main {
		#address-cells = <2>;
		#size-cells = <2>;

		timesync_router: pinctrl@a40000 {
			compatible = "pinctrl-single";
			reg = <0x0 0xa40000 0x0 0x400>;
			#pinctrl-cells = <1>;
			pinctrl-single,register-width = <32>;
			pinctrl-single,function-mask = <0x000107ff>;
			pinctrl-names = "default";
			pinctrl-0 = <&gtc_push_route>;

			gtc_push_route: gtc-push-route {
				/* input 11 (GTC push event) -> output 14 (CPTS HW5_TS_PUSH) */
				pinctrl-single,pins = <0x3c 0x1000b>;
			};
		};
	};

	&{/bus@f0000/ethernet@8000000/cpts@3d000} {
		ti,gtc-push = <&wkup_gtc 4>;
	};

I used an LLM coding assistant to help prepare this series.

Changes in v2:
- Rebased on net-next
- Dropped the syscon compatible patch, applied to mfd by Lee Jones
- Made a failed ti,gtc-push lookup a warning; the probe continues without PTP_SYS_OFFSET_PRECISE (Rob Herring)
- Three smaller fixes to the driver, listed in patch 2
- Link to v1: https://lore.kernel.org/all/[email protected]/

[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/179511436097.97786.7515300839199702588.b4-ty@b4/

James Clark (2):
dt-bindings: net: ti,k3-am654-cpts: add ti,gtc-push
net: ethernet: ti: am65-cpts: implement PTP_SYS_OFFSET_PRECISE

 .../bindings/net/ti,k3-am654-cpts.yaml        |  17 +
 drivers/net/ethernet/ti/am65-cpts.c           | 313 ++++++++++++++++++
 2 files changed, 330 insertions(+)

base-commit: 5b87a11b1547c39da01718044b9f99fd85948b9c

Signature · 1 line
2.56.0