Skip to content

Commit ea84c84

Browse files
committed
Merge branch 'net-ethernet-ti-k3-introduce-common-platform-time-sync-driver-cpts'
Grygorii Strashko says: ==================== net: ethernet: ti: k3: introduce common platform time sync driver - cpts This series introduced support for significantly upgraded TI A65x/J721E Common platform time sync (CPTS) modules which are part of AM65xx Time Synchronization Architecture [1]. The TI A65x/J721E now contain more than one CPTS instance: - MCU CPSW CPTS (IEEE 1588 compliant) - Main NAVSS CPTS (central) - PCIe CPTS(s) (PTM compliant) - J721E: Main CPSW9g CPTS (IEEE 1588 compliant) which can work as separately as interact to each other through Time Sync Router (TSR) and Compare Event Router (CER). In addition there are also ICSS-G IEP blocks which can perform similar timsync functions, but require FW support. More info also available in TRM [2][3]. Not all above modules are available to the Linux by as of now as some of them are reserved for RTOS/FW purposes. The scope of this submission is TI A65x/J721E CPSW CPTS and Main NAVSS CPTS, and TSR was used for testing purposes. +---------------------------+ | MCU CPSW | +-------------------+ +------------------------+ | TS | | Main Navss CPTS | | Time Sync Router (TSR) | | +-------------+ | | | | | | | | | | HW1_TS +<----------+ | | +--------v-----+ +--+--+ | | | | | | CPTS | |Port | | ... | | | X+-->HW1_TS | | | | HW8_TS <------------<---------+ | X|-->HW2_TS | +--^--+ | | | | +--------------->HW3_TS | | | | | | | +--------------->HW4_TS | | | | | | | | | | | | | | | | | | | | | | | | Genf0 +-----------> (A)---------+ +<--------------+Genf0 | | | | | | | | | | | | | | ... | | +-----------> <---------------+Genf1 ESTf+-------+ | | | | | | | | | | | | | | +--------------+ | | Genf8 +---------->+ | | | | | | SYNC0 ... SYNC3 | | | +-------------------+ +------+------------+----+ +---------------------------+ + + X X (A) shows possible routing path for MCU CPSW CPTS Genf0 signal as an example. Main features of the new TI A65x/J721E CPTS modules are: - 64-bit timestamp/counter mode support in ns by using add_val - implemented in HW PPM and nudge adjustment. - control of time sync events via interrupt or polling - selection of multiple external reference clock sources - hardware timestamp of ext. inputs events (HWx_TS_PUSH) - periodic generator function outputs (TS_GENFx) - (CPSW only) Ethernet Enhanced Scheduled Traffic Operations (CPTS_ESTFn), which drives TSN schedule - timestamping of all RX packets bypassing CPTS FIFO Patch 1 - DT bindings Patch 2 - the AM65x/J721E driver Patch 3 - enables packet timestamping support in TI AM65x/J721E MCU CPSW driver. Patches 4-7 - DT updates. === PTP Testing: phc2sys -s CLOCK_REALTIME -c eth0 -m -O 0 -u30 phc2sys[627.331]: eth0 rms 409912446712787392 max 1587584079521858304 freq -6665 +/- 35040 delay 832 +/- 27 phc2sys[657.335]: eth0 rms 33 max 66 freq -0 +/- 28 delay 820 +/- 30 phc2sys[687.339]: eth0 rms 37 max 70 freq -1 +/- 32 delay 830 +/- 29 phc2sys[717.343]: eth0 rms 33 max 71 freq -0 +/- 29 delay 828 +/- 23 phc2sys[747.346]: eth0 rms 35 max 75 freq -0 +/- 31 delay 829 +/- 26 phc2sys[777.350]: eth0 rms 37 max 68 freq -1 +/- 32 delay 825 +/- 25 phc2sys[807.354]: eth0 rms 28 max 57 freq -1 +/- 25 delay 824 +/- 21 phc2sys[837.358]: eth0 rms 43 max 81 freq -1 +/- 37 delay 836 +/- 23 phc2sys[867.361]: eth0 rms 33 max 74 freq +0 +/- 29 delay 828 +/- 24 phc2sys[897.365]: eth0 rms 35 max 77 freq -2 +/- 30 delay 824 +/- 25 phc2sys[927.369]: eth0 rms 28 max 50 freq +0 +/- 25 delay 825 +/- 25 ptp4l -P -2 -H -i eth0 -l 6 -m -q -p /dev/ptp1 -f ptp.cfg -s ptp4l[22095.754]: port 1: MASTER to UNCALIBRATED on RS_SLAVE ptp4l[22097.754]: port 1: UNCALIBRATED to SLAVE on MASTER_CLOCK_SELECTED ptp4l[22159.757]: rms 317 max 1418 freq +79 +/- 186 delay 410 +/- 1 ptp4l[22223.760]: rms 9 max 24 freq +42 +/- 12 delay 409 +/- 1 ptp4l[22287.763]: rms 10 max 28 freq +41 +/- 11 delay 410 +/- 1 ptp4l[22351.767]: rms 10 max 26 freq +34 +/- 12 delay 410 +/- 1 ptp4l[22415.770]: rms 10 max 26 freq +49 +/- 14 delay 410 +/- 1 === Ext. HW_TS and Genf testing: For testing purposes Time Sync Router (TSR) can be modeled in DT as pin controller + timesync_router: timesync_router@A40000 { + compatible = "pinctrl-single"; + reg = <0x0 0xA40000 0x0 0x800>; + #address-cells = <1>; + #size-cells = <0>; + #pinctrl-cells = <1>; + pinctrl-single,register-width = <32>; + pinctrl-single,function-mask = <0x800007ff>; + }; then signals routing can be done in board file, for example: +#define TS_OFFSET(pa, val) (0x4+(pa)*4) (0x80000000 | val) + +&timesync_router { + pinctrl-names = "default"; + pinctrl-0 = <&mcu_cpts>; + + /* Example of the timesync routing */ + mcu_cpts: mcu_cpts { + pinctrl-single,pins = < + /* [cpts genf1] in13 -> out25 [cpts hw4_push] */ + TS_OFFSET(25, 13) + /* [cpts genf1] in13 -> out0 [main cpts hw1_push] */ + TS_OFFSET(0, 13) + /* [main cpts genf0] in4 -> out1 [main cpts hw2_push] */ + TS_OFFSET(1, 4) + /* [main cpts genf0] in4 -> out24 [cpts hw3_push] */ + TS_OFFSET(24, 4) + >; + }; +}; will create link: cpsw cpts Genf1 -> main cpts hw1_push -> cpsw cpts hw4_push main cpts Genf0 -> main cpts hw2_push -> cpsw cpts hw3_push testptp -d /dev/ptp0 -i 0 -p 1000000000 periodic output request okay testptp -d /dev/ptp0 -i 1 -e 5 external time stamp request okay event index 1 at 22583.000000025 event index 1 at 22584.000000025 event index 1 at 22585.000000025 event index 1 at 22586.000000025 event index 1 at 22587.000000025 testptp -d /dev/ptp1 -i 2 -e 5 external time stamp request okay event index 2 at 1587606764.249304554 event index 2 at 1587606765.249304467 event index 2 at 1587606766.249304380 event index 2 at 1587606767.249304293 event index 2 at 1587606768.249304206 [1] https://www.ti.com/lit/pdf/spracp7 [2] https://www.ti.com/lit/pdf/sprz452 [3] https://www.ti.com/lit/pdf/spruil1 ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 1248dc0 + 461d6d0 commit ea84c84

File tree

13 files changed

+1528
-2
lines changed

13 files changed

+1528
-2
lines changed

Documentation/devicetree/bindings/net/ti,k3-am654-cpsw-nuss.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,13 @@ patternProperties:
144144
description:
145145
CPSW MDIO bus.
146146

147+
"^cpts$":
148+
type: object
149+
allOf:
150+
- $ref: "ti,am654-cpts.yaml#"
151+
description:
152+
CPSW Common Platform Time Sync (CPTS) module.
153+
147154
required:
148155
- compatible
149156
- reg
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/net/ti,am654-cpts.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: The TI AM654x/J721E Common Platform Time Sync (CPTS) module Device Tree Bindings
8+
9+
maintainers:
10+
- Grygorii Strashko <[email protected]>
11+
- Sekhar Nori <[email protected]>
12+
13+
description: |+
14+
The TI AM654x/J721E CPTS module is used to facilitate host control of time
15+
sync operations.
16+
Main features of CPTS module are
17+
- selection of multiple external clock sources
18+
- Software control of time sync events via interrupt or polling
19+
- 64-bit timestamp mode in ns with PPM and nudge adjustment.
20+
- hardware timestamp push inputs (HWx_TS_PUSH)
21+
- timestamp counter compare output (TS_COMP)
22+
- timestamp counter bit output (TS_SYNC)
23+
- periodic Generator function outputs (TS_GENFx)
24+
- Ethernet Enhanced Scheduled Traffic Operations (CPTS_ESTFn) (TSN)
25+
- external hardware timestamp push inputs (HWx_TS_PUSH) timestamping
26+
27+
Depending on integration it enables compliance with the IEEE 1588-2008
28+
standard for a precision clock synchronization protocol, Ethernet Enhanced
29+
Scheduled Traffic Operations (CPTS_ESTFn) and PCIe Subsystem Precision Time
30+
Measurement (PTM).
31+
32+
TI AM654x/J721E SoCs has several similar CPTS modules integrated into the
33+
different parts of the system which could be synchronized with each other
34+
- Main CPTS
35+
- MCU CPSW CPTS with IEEE 1588-2008 support
36+
- PCIe subsystem CPTS for PTM support
37+
38+
Depending on CPTS module integration and when CPTS is integral part of
39+
another module (MCU CPSW for example) "compatible" and "reg" can
40+
be omitted - parent module is fully responsible for CPTS enabling and
41+
configuration.
42+
43+
properties:
44+
$nodename:
45+
pattern: "^cpts(@.*|-[0-9a-f])*$"
46+
47+
compatible:
48+
oneOf:
49+
- const: ti,am65-cpts
50+
- const: ti,j721e-cpts
51+
52+
reg:
53+
maxItems: 1
54+
description:
55+
The physical base address and size of CPTS IO range
56+
57+
reg-names:
58+
items:
59+
- const: cpts
60+
61+
clocks:
62+
description: CPTS reference clock
63+
64+
clock-names:
65+
items:
66+
- const: cpts
67+
68+
interrupts-extended:
69+
items:
70+
- description: CPTS events interrupt
71+
72+
interrupt-names:
73+
items:
74+
- const: "cpts"
75+
76+
ti,cpts-ext-ts-inputs:
77+
allOf:
78+
- $ref: /schemas/types.yaml#/definitions/uint32
79+
maximum: 8
80+
description:
81+
Number of hardware timestamp push inputs (HWx_TS_PUSH)
82+
83+
ti,cpts-periodic-outputs:
84+
allOf:
85+
- $ref: /schemas/types.yaml#/definitions/uint32
86+
maximum: 8
87+
description:
88+
Number of timestamp Generator function outputs (TS_GENFx)
89+
90+
refclk-mux:
91+
type: object
92+
description: CPTS reference clock multiplexer clock
93+
properties:
94+
'#clock-cells':
95+
const: 0
96+
97+
clocks:
98+
maxItems: 8
99+
100+
assigned-clocks:
101+
maxItems: 1
102+
103+
assigned-clocks-parents:
104+
maxItems: 1
105+
106+
required:
107+
- clocks
108+
109+
required:
110+
- clocks
111+
- clock-names
112+
- interrupts-extended
113+
- interrupt-names
114+
115+
additionalProperties: false
116+
117+
examples:
118+
- |
119+
#include <dt-bindings/interrupt-controller/irq.h>
120+
#include <dt-bindings/interrupt-controller/arm-gic.h>
121+
122+
cpts@310d0000 {
123+
compatible = "ti,am65-cpts";
124+
reg = <0x0 0x310d0000 0x0 0x400>;
125+
reg-names = "cpts";
126+
clocks = <&main_cpts_mux>;
127+
clock-names = "cpts";
128+
interrupts-extended = <&k3_irq 163 0 IRQ_TYPE_LEVEL_HIGH>;
129+
interrupt-names = "cpts";
130+
ti,cpts-periodic-outputs = <6>;
131+
ti,cpts-ext-ts-inputs = <8>;
132+
133+
main_cpts_mux: refclk-mux {
134+
#clock-cells = <0>;
135+
clocks = <&k3_clks 118 5>, <&k3_clks 118 11>,
136+
<&k3_clks 157 91>, <&k3_clks 157 77>,
137+
<&k3_clks 157 102>, <&k3_clks 157 80>,
138+
<&k3_clks 120 3>, <&k3_clks 121 3>;
139+
assigned-clocks = <&main_cpts_mux>;
140+
assigned-clock-parents = <&k3_clks 118 11>;
141+
};
142+
};
143+
- |
144+
145+
cpts {
146+
clocks = <&k3_clks 18 2>;
147+
clock-names = "cpts";
148+
interrupts-extended = <&gic500 GIC_SPI 858 IRQ_TYPE_LEVEL_HIGH>;
149+
interrupt-names = "cpts";
150+
ti,cpts-ext-ts-inputs = <4>;
151+
ti,cpts-periodic-outputs = <2>;
152+
};

arch/arm64/boot/dts/ti/k3-am65-main.dtsi

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,28 @@
570570
<0x5>; /* RX_CHAN */
571571
ti,sci-rm-range-rflow = <0x6>; /* GP RFLOW */
572572
};
573+
574+
cpts@310d0000 {
575+
compatible = "ti,am65-cpts";
576+
reg = <0x0 0x310d0000 0x0 0x400>;
577+
reg-names = "cpts";
578+
clocks = <&main_cpts_mux>;
579+
clock-names = "cpts";
580+
interrupts-extended = <&intr_main_navss 163 0>;
581+
interrupt-names = "cpts";
582+
ti,cpts-periodic-outputs = <6>;
583+
ti,cpts-ext-ts-inputs = <8>;
584+
585+
main_cpts_mux: refclk-mux {
586+
#clock-cells = <0>;
587+
clocks = <&k3_clks 118 5>, <&k3_clks 118 11>,
588+
<&k3_clks 118 6>, <&k3_clks 118 3>,
589+
<&k3_clks 118 8>, <&k3_clks 118 14>,
590+
<&k3_clks 120 3>, <&k3_clks 121 3>;
591+
assigned-clocks = <&main_cpts_mux>;
592+
assigned-clock-parents = <&k3_clks 118 5>;
593+
};
594+
};
573595
};
574596

575597
main_gpio0: main_gpio0@600000 {

arch/arm64/boot/dts/ti/k3-am65-mcu.dtsi

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,5 +247,24 @@
247247
clock-names = "fck";
248248
bus_freq = <1000000>;
249249
};
250+
251+
cpts {
252+
clocks = <&mcu_cpsw_cpts_mux>;
253+
clock-names = "cpts";
254+
interrupts-extended = <&gic500 GIC_SPI 570 IRQ_TYPE_LEVEL_HIGH>;
255+
interrupt-names = "cpts";
256+
ti,cpts-ext-ts-inputs = <4>;
257+
ti,cpts-periodic-outputs = <2>;
258+
259+
mcu_cpsw_cpts_mux: refclk-mux {
260+
#clock-cells = <0>;
261+
clocks = <&k3_clks 118 5>, <&k3_clks 118 11>,
262+
<&k3_clks 118 6>, <&k3_clks 118 3>,
263+
<&k3_clks 118 8>, <&k3_clks 118 14>,
264+
<&k3_clks 120 3>, <&k3_clks 121 3>;
265+
assigned-clocks = <&mcu_cpsw_cpts_mux>;
266+
assigned-clock-parents = <&k3_clks 118 5>;
267+
};
268+
};
250269
};
251270
};

arch/arm64/boot/dts/ti/k3-j721e-main.dtsi

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,18 @@
254254
<0x0c>; /* RX_UHCHAN */
255255
ti,sci-rm-range-rflow = <0x00>; /* GP RFLOW */
256256
};
257+
258+
cpts@310d0000 {
259+
compatible = "ti,j721e-cpts";
260+
reg = <0x0 0x310d0000 0x0 0x400>;
261+
reg-names = "cpts";
262+
clocks = <&k3_clks 201 1>;
263+
clock-names = "cpts";
264+
interrupts-extended = <&main_navss_intr 201 0>;
265+
interrupt-names = "cpts";
266+
ti,cpts-periodic-outputs = <6>;
267+
ti,cpts-ext-ts-inputs = <8>;
268+
};
257269
};
258270

259271
main_pmx0: pinmux@11c000 {

arch/arm64/boot/dts/ti/k3-j721e-mcu-wakeup.dtsi

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,5 +338,14 @@
338338
clock-names = "fck";
339339
bus_freq = <1000000>;
340340
};
341+
342+
cpts {
343+
clocks = <&k3_clks 18 2>;
344+
clock-names = "cpts";
345+
interrupts-extended = <&gic500 GIC_SPI 858 IRQ_TYPE_LEVEL_HIGH>;
346+
interrupt-names = "cpts";
347+
ti,cpts-ext-ts-inputs = <4>;
348+
ti,cpts-periodic-outputs = <2>;
349+
};
341350
};
342351
};

drivers/net/ethernet/ti/Kconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ config TI_K3_AM65_CPSW_NUSS
100100
depends on ARCH_K3 && OF && TI_K3_UDMA_GLUE_LAYER
101101
select TI_DAVINCI_MDIO
102102
imply PHY_TI_GMII_SEL
103+
imply TI_AM65_CPTS
103104
help
104105
This driver supports TI K3 AM654/J721E CPSW2G Ethernet SubSystem.
105106
The two-port Gigabit Ethernet MAC (MCU_CPSW0) subsystem provides
@@ -110,6 +111,20 @@ config TI_K3_AM65_CPSW_NUSS
110111
To compile this driver as a module, choose M here: the module
111112
will be called ti-am65-cpsw-nuss.
112113

114+
config TI_K3_AM65_CPTS
115+
tristate "TI K3 AM65x CPTS"
116+
depends on ARCH_K3 && OF && PTP_1588_CLOCK
117+
depends on PTP_1588_CLOCK
118+
select NET_PTP_CLASSIFY
119+
help
120+
Say y here to support the TI K3 AM65x CPTS with 1588 features such as
121+
PTP hardware clock for each CPTS device and network packets
122+
timestamping where applicable.
123+
Depending on integration CPTS blocks enable compliance with
124+
the IEEE 1588-2008 standard for a precision clock synchronization
125+
protocol, Ethernet Enhanced Scheduled Traffic Operations (CPTS_ESTFn)
126+
and PCIe Subsystem Precision Time Measurement (PTM).
127+
113128
config TI_KEYSTONE_NETCP
114129
tristate "TI Keystone NETCP Core Support"
115130
select TI_DAVINCI_MDIO

drivers/net/ethernet/ti/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ keystone_netcp_ethss-y := netcp_ethss.o netcp_sgmii.o netcp_xgbepcsr.o cpsw_ale.
2626

2727
obj-$(CONFIG_TI_K3_AM65_CPSW_NUSS) += ti-am65-cpsw-nuss.o
2828
ti-am65-cpsw-nuss-y := am65-cpsw-nuss.o cpsw_sl.o am65-cpsw-ethtool.o cpsw_ale.o k3-cppi-desc-pool.o
29+
obj-$(CONFIG_TI_K3_AM65_CPTS) += am65-cpts.o

drivers/net/ethernet/ti/am65-cpsw-ethtool.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include "am65-cpsw-nuss.h"
1414
#include "cpsw_ale.h"
15+
#include "am65-cpts.h"
1516

1617
#define AM65_CPSW_REGDUMP_VER 0x1
1718

@@ -694,6 +695,27 @@ static void am65_cpsw_get_ethtool_stats(struct net_device *ndev,
694695
hw_stats[i].offset);
695696
}
696697

698+
static int am65_cpsw_get_ethtool_ts_info(struct net_device *ndev,
699+
struct ethtool_ts_info *info)
700+
{
701+
struct am65_cpsw_common *common = am65_ndev_to_common(ndev);
702+
703+
if (!IS_ENABLED(CONFIG_TI_K3_AM65_CPTS))
704+
return ethtool_op_get_ts_info(ndev, info);
705+
706+
info->so_timestamping =
707+
SOF_TIMESTAMPING_TX_HARDWARE |
708+
SOF_TIMESTAMPING_TX_SOFTWARE |
709+
SOF_TIMESTAMPING_RX_HARDWARE |
710+
SOF_TIMESTAMPING_RX_SOFTWARE |
711+
SOF_TIMESTAMPING_SOFTWARE |
712+
SOF_TIMESTAMPING_RAW_HARDWARE;
713+
info->phc_index = am65_cpts_phc_index(common->cpts);
714+
info->tx_types = BIT(HWTSTAMP_TX_OFF) | BIT(HWTSTAMP_TX_ON);
715+
info->rx_filters = BIT(HWTSTAMP_FILTER_NONE) | BIT(HWTSTAMP_FILTER_ALL);
716+
return 0;
717+
}
718+
697719
static u32 am65_cpsw_get_ethtool_priv_flags(struct net_device *ndev)
698720
{
699721
struct am65_cpsw_common *common = am65_ndev_to_common(ndev);
@@ -730,7 +752,7 @@ const struct ethtool_ops am65_cpsw_ethtool_ops_slave = {
730752
.get_sset_count = am65_cpsw_get_sset_count,
731753
.get_strings = am65_cpsw_get_strings,
732754
.get_ethtool_stats = am65_cpsw_get_ethtool_stats,
733-
.get_ts_info = ethtool_op_get_ts_info,
755+
.get_ts_info = am65_cpsw_get_ethtool_ts_info,
734756
.get_priv_flags = am65_cpsw_get_ethtool_priv_flags,
735757
.set_priv_flags = am65_cpsw_set_ethtool_priv_flags,
736758

0 commit comments

Comments
 (0)