Skip to contentSkip to conversation

net: ethernet: ti: cpts: update and enable support on keystone 2 socs

PATCH Superseded Grygorii Strashko 5 participants 37 messages Nov 28, 2016 – Dec 9, 2016

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover net: ethernet: ti: cpts: update and enable support on keystone 2 socs

Time Synchronization (CPTS) submodule which is present on KeyStone 66AK2HK/E/L/Gx 1G Switch Subsystem provides the same basic functionality as OMAP CPSW CPTS, but with few additional features:
- CPTS rftclk selection (reg CPTS_RFTCLK_SEL). This feature is declared to be supported on am437x SoCs also.
- CPTS HW_TS_PUSH events which can be generated by external low frequency time stamp channels (66AK2E/L/Gx, am437x)
- one Time Stamp Compare (TS_COMP) output which is reused for PTP PPS feature implementation (66AK2E/L/Gx).
Hence, This series enables basic CPTS support on Keystone 2 SoCs by resuing current CPSW CPTS driver.

Links on docs:
66AK2H/kx http://www.ti.com/lit/pdf/sprugv9
66AK2E/Lx http://www.ti.com/lit/pdf/spruhz3
66AK2Gx http://www.ti.com/lit/pdf/spruhy8

Note. This series based on top of preparation series
"[PATCH v2 00/13] net: ethernet: ti: cpts: update and fixes"

Tested on am437x-idk, am57xx-evm, 66AK2HK, 66AK2E, 66AK2G Tests:
server: ptp4l -E -2 -H -i eth0 -l 6 -m -q -p /dev/ptp0
client: ptp4l -E -2 -H -i eth0 -l 6 -m -q -p /dev/ptp0 -s

   testptp -g && sleep X && testptp -g

testptp -c
testptp -g
testptp -s
testptp -k 25
testptp -e 3

   testptp -P 1 && .ppstest /dev/pps0

Grygorii Strashko (4):
net: ethernet: ti: cpts: add support for ext rftclk selection
net: ethernet: ti: cpts: add support of cpts HW_TS_PUSH
net: ethernet: ti: cpts: add ptp pps support
ARM: dts: keystone: enable time synchronization (cpts) submodule

Murali Karicheri (1):
ARM: keystone: dts: fix netcp clocks and add names

WingMan Kwok (1):
net: ethernet: ti: netcp: add support of cpts

 Documentation/devicetree/bindings/net/cpsw.txt     |   4 +
 .../devicetree/bindings/net/keystone-netcp.txt     |  25 ++
 arch/arm/boot/dts/keystone-k2e-netcp.dtsi          |   6 +-
 arch/arm/boot/dts/keystone-k2hk-netcp.dtsi         |   4 +-
 arch/arm/boot/dts/keystone-k2l-netcp.dtsi          |   6 +-
 drivers/net/ethernet/ti/Kconfig                    |   7 +-
 drivers/net/ethernet/ti/cpts.c                     | 343 +++++++++++++++-
 drivers/net/ethernet/ti/cpts.h                     |  28 +-
 drivers/net/ethernet/ti/netcp.h                    |   2 +-
 drivers/net/ethernet/ti/netcp_core.c               |  18 +-
 drivers/net/ethernet/ti/netcp_ethss.c              | 437 ++++++++++++++++++++-
 11 files changed, 853 insertions(+), 27 deletions(-)
Signature · 1 line
2.10.1
#1 lore raw

PATCH 1/6 net: ethernet: ti: netcp: add support of cpts

From: WingMan Kwok <[email protected]>

This patch adds support of the cpts device found in the gbe and 10gbe ethernet switches on the keystone 2 SoCs (66AK2E/L/Hx, 66AK2Gx).

---
 .../devicetree/bindings/net/keystone-netcp.txt     |   9 +
 drivers/net/ethernet/ti/Kconfig                    |   7 +-
 drivers/net/ethernet/ti/netcp.h                    |   2 +-
 drivers/net/ethernet/ti/netcp_core.c               |  18 +-
 drivers/net/ethernet/ti/netcp_ethss.c              | 437 ++++++++++++++++++++-
 5 files changed, 459 insertions(+), 14 deletions(-)
Documentation/devicetree/bindings/net/keystone-netcp.txt +9 -0
index 04ba1dc..c37b54e 100644
@@ -113,6 +113,15 @@ Optional properties:
 				will only initialize these ports and attach PHY
 				driver to them if needed.
 
+ Properties related to cpts configurations.
+	- cpts_clock_mult/cpts_clock_shift:
+		used for converting time counter cycles to ns as in
+
+		ns = (cycles * clock_mult) >> _shift
+
+		Defaults: clock_mult, clock_shift = calculated from
+		CPTS refclk
+
 NetCP interface properties: Interface specification for NetCP sub-modules.
 Required properties:
 - rx-channel:	the navigator packet dma channel name for rx.
drivers/net/ethernet/ti/Kconfig +4 -3
index ff7f518..dc217fd 100644
@@ -75,12 +75,13 @@ config TI_CPSW
 
 config TI_CPTS
 	tristate "TI Common Platform Time Sync (CPTS) Support"
-	depends on TI_CPSW
+	depends on TI_CPSW || TI_KEYSTONE_NETCP
 	select PTP_1588_CLOCK
 	---help---
 	  This driver supports the Common Platform Time Sync unit of
-	  the CPSW Ethernet Switch. The unit can time stamp PTP UDP/IPv4
-	  and Layer 2 packets, and the driver offers a PTP Hardware Clock.
+	  the CPSW Ethernet Switch and Keystone 2 1g/10g Switch Subsystem.
+	  The unit can time stamp PTP UDP/IPv4 and Layer 2 packets, and the
+	  driver offers a PTP Hardware Clock.
 
 config TI_KEYSTONE_NETCP
 	tristate "TI Keystone NETCP Core Support"
drivers/net/ethernet/ti/netcp.h +1 -1
index 17a26a4..0f58c58 100644
@@ -121,7 +121,7 @@ struct netcp_packet {
 	bool			rxtstamp_complete;
 	void			*ts_context;
 
-	int	(*txtstamp_complete)(void *ctx, struct netcp_packet *pkt);
+	void (*txtstamp)(void *ctx, struct sk_buff *skb);
 };
 
 static inline u32 *netcp_push_psdata(struct netcp_packet *p_info,
drivers/net/ethernet/ti/netcp_core.c +17 -1
index 3251666..a740e60 100644
@@ -100,6 +100,11 @@ struct netcp_intf_modpriv {
 	void			*module_priv;
 };
 
+struct netcp_tx_cb {
+	void	*ts_context;
+	void	(*txtstamp)(void *context, struct sk_buff *skb);
+};
+
 static LIST_HEAD(netcp_devices);
 static LIST_HEAD(netcp_modules);
 static DEFINE_MUTEX(netcp_modules_lock);
@@ -730,6 +735,7 @@ static int netcp_process_one_rx_packet(struct netcp_intf *netcp)
 
 	/* Call each of the RX hooks */
 	p_info.skb = skb;
+	skb->dev = netcp->ndev;
 	p_info.rxtstamp_complete = false;
 	list_for_each_entry(rx_hook, &netcp->rxhook_list_head, list) {
 		int ret;
@@ -987,6 +993,7 @@ static int netcp_process_tx_compl_packets(struct netcp_intf *netcp,
 					  unsigned int budget)
 {
 	struct knav_dma_desc *desc;
+	struct netcp_tx_cb *tx_cb;
 	struct sk_buff *skb;
 	unsigned int dma_sz;
 	dma_addr_t dma;
@@ -1014,6 +1021,10 @@ static int netcp_process_tx_compl_packets(struct netcp_intf *netcp,
 			continue;
 		}
 
+		tx_cb = (struct netcp_tx_cb *)skb->cb;
+		if (tx_cb->txtstamp)
+			tx_cb->txtstamp(tx_cb->ts_context, skb);
+
 		if (netif_subqueue_stopped(netcp->ndev, skb) &&
 		    netif_running(netcp->ndev) &&
 		    (knav_pool_count(netcp->tx_pool) >
@@ -1154,6 +1165,7 @@ static int netcp_tx_submit_skb(struct netcp_intf *netcp,
 	struct netcp_tx_pipe *tx_pipe = NULL;
 	struct netcp_hook_list *tx_hook;
 	struct netcp_packet p_info;
+	struct netcp_tx_cb *tx_cb;
 	unsigned int dma_sz;
 	dma_addr_t dma;
 	u32 tmp = 0;
@@ -1164,7 +1176,7 @@ static int netcp_tx_submit_skb(struct netcp_intf *netcp,
 	p_info.tx_pipe = NULL;
 	p_info.psdata_len = 0;
 	p_info.ts_context = NULL;
-	p_info.txtstamp_complete = NULL;
+	p_info.txtstamp = NULL;
 	p_info.epib = desc->epib;
 	p_info.psdata = (u32 __force *)desc->psdata;
 	memset(p_info.epib, 0, KNAV_DMA_NUM_EPIB_WORDS * sizeof(__le32));
@@ -1189,6 +1201,10 @@ static int netcp_tx_submit_skb(struct netcp_intf *netcp,
 		goto out;
 	}
 
+	tx_cb = (struct netcp_tx_cb *)skb->cb;
+	tx_cb->ts_context = p_info.ts_context;
+	tx_cb->txtstamp = p_info.txtstamp;
+
 	/* update descriptor */
 	if (p_info.psdata_len) {
 		/* psdata points to both native-endian and device-endian data */
drivers/net/ethernet/ti/netcp_ethss.c +428 -9

595 lines not on this page · raw message

Signature · 1 line
2.10.1
#8 lore raw

PATCH 2/6 net: ethernet: ti: cpts: add support for ext rftclk selection

In reply to Grygorii Strashko

Some CPTS instances, which can be found on KeyStone 2 1/10G Ethernet Switch Subsystems, can control an external multiplexer that selects one of up to 32 clocks for time sync reference (RFTCLK). This feature can be configured through CPTS_RFTCLK_SEL register (offset: x08).

Hence, introduce optional DT cpts_rftclk_sel poperty wich, if present, will specify CPTS reference clock. The cpts_rftclk_sel should be omitted in DT if HW doesn't support this feature. The external fixed rate clocks can be defined in board files as "fixed-clock".

---
 Documentation/devicetree/bindings/net/keystone-netcp.txt |  2 ++
 drivers/net/ethernet/ti/cpts.c                           | 12 ++++++++++++
 drivers/net/ethernet/ti/cpts.h                           |  8 +++++++-
 3 files changed, 21 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/net/keystone-netcp.txt +2 -0
index c37b54e..ec4a241 100644
@@ -114,6 +114,8 @@ Optional properties:
 				driver to them if needed.
 
  Properties related to cpts configurations.
+	- cpts-rftclk-sel: selects one of up to 32 clocks for time sync
+		reference.  Default = 0.
 	- cpts_clock_mult/cpts_clock_shift:
 		used for converting time counter cycles to ns as in
 
drivers/net/ethernet/ti/cpts.c +12 -0
index c96a94a..9c5b835 100644
@@ -459,6 +459,15 @@ static int cpts_of_parse(struct cpts *cpts, struct device_node *node)
 	    (!cpts->cc_mult && cpts->cc.shift))
 		goto of_error;
 
+	if (!of_property_read_u32(node, "cpts-rftclk-sel", &prop)) {
+		if (prop & ~CPTS_RFTCLK_SEL_MASK) {
+			dev_err(cpts->dev, "cpts: invalid cpts_rftclk_sel.\n");
+			goto of_error;
+		}
+		cpts->caps |= CPTS_CAP_RFTCLK_SEL;
+		cpts->rftclk_sel = prop & CPTS_RFTCLK_SEL_MASK;
+	}
+
 	return 0;
 
 of_error:
@@ -496,6 +505,9 @@ struct cpts *cpts_create(struct device *dev, void __iomem *regs,
 
 	clk_prepare(cpts->refclk);
 
+	if (cpts->caps & CPTS_CAP_RFTCLK_SEL)
+		cpts_write32(cpts, cpts->rftclk_sel, rftclk_sel);
+
 	cpts->cc.read = cpts_systim_read;
 	cpts->cc.mask = CLOCKSOURCE_MASK(32);
 	cpts->info = cpts_info;
drivers/net/ethernet/ti/cpts.h +7 -1
index c96eca2..c934b61 100644
@@ -35,7 +35,7 @@
 struct cpsw_cpts {
 	u32 idver;                /* Identification and version */
 	u32 control;              /* Time sync control */
-	u32 res1;
+	u32 rftclk_sel;		  /* Reference Clock Select Register */
 	u32 ts_push;              /* Time stamp event push */
 	u32 ts_load_val;          /* Time stamp load value */
 	u32 ts_load_en;           /* Time stamp load enable */
@@ -67,6 +67,8 @@ struct cpsw_cpts {
 #define INT_TEST             (1<<1)  /* Interrupt Test */
 #define CPTS_EN              (1<<0)  /* Time Sync Enable */
 
+#define CPTS_RFTCLK_SEL_MASK 0x1f
+
 /*
  * Definitions for the single bit resisters:
  * TS_PUSH TS_LOAD_EN  INTSTAT_RAW INTSTAT_MASKED INT_ENABLE EVENT_POP
@@ -107,6 +109,8 @@ struct cpts_event {
 	u32 low;
 };
 
+#define CPTS_CAP_RFTCLK_SEL BIT(0)
+
 struct cpts {
 	struct device *dev;
 	struct cpsw_cpts __iomem *reg;
@@ -125,6 +129,8 @@ struct cpts {
 	struct list_head pool;
 	struct cpts_event pool_data[CPTS_MAX_EVENTS];
 	unsigned long ov_check_period;
+	u32 rftclk_sel;
+	u32 caps;
 };
 
 void cpts_rx_timestamp(struct cpts *cpts, struct sk_buff *skb);
Signature · 1 line
2.10.1
#17 lore raw

PATCH 3/6 net: ethernet: ti: cpts: add support of cpts HW_TS_PUSH

In reply to Grygorii Strashko

This patch adds support of the CPTS HW_TS_PUSH events which are generated by external low frequency time stamp channels on TI's OMAP CPSW and Keystone 2 platforms. It supports up to 8 external time stamp channels for HW_TS_PUSH input pins (the number of supported channel is different for different SoCs and CPTS versions, check corresponding Data maual before enabling it). Therefore, new DT property "cpts-ext-ts-inputs" is introduced for specifying number of available external timestamp channels.

The PTP external timestamp (extts) infrastructure can be used for HW_TS_PUSH timestamp controlling and reporting.

This also change overflow polling period when HW_TS_PUSH feature is enabled - overflow check work will be scheduled more often (every 200ms) for proper HW_TS_PUSH events reporting.

---
 Documentation/devicetree/bindings/net/cpsw.txt     |   4 +
 .../devicetree/bindings/net/keystone-netcp.txt     |   4 +
 drivers/net/ethernet/ti/cpts.c                     | 104 ++++++++++++++++++++-
 drivers/net/ethernet/ti/cpts.h                     |   6 ++
 4 files changed, 114 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/net/cpsw.txt +4 -0
index ebda7c9..86a2f61 100644
@@ -38,6 +38,10 @@ Optional properties:
 			  Mult and shift will be calculated basing on CPTS
 			  rftclk frequency if both cpts_clock_shift and
 			  cpts_clock_mult properties are not provided.
+- cpts-ext-ts-inputs	: The number of external time stamp channels.
+			  The different CPTS versions might support up 8
+			  external time stamp channels.
+			  if absent - unsupported.
 
 Slave Properties:
 Required properties:
Documentation/devicetree/bindings/net/keystone-netcp.txt +4 -0
index ec4a241..1c805319 100644
@@ -123,6 +123,10 @@ Optional properties:
 
 		Defaults: clock_mult, clock_shift = calculated from
 		CPTS refclk
+	- cpts-ext-ts-inputs:
+		The number of external time stamp channels.
+		The different CPTS versions might support up 8
+		external time stamp channels. if absent - unsupported.
 
 NetCP interface properties: Interface specification for NetCP sub-modules.
 Required properties:
drivers/net/ethernet/ti/cpts.c +100 -4

161 lines not on this page · raw message

drivers/net/ethernet/ti/cpts.h +6 -0
index c934b61..ad80c95 100644
@@ -102,6 +102,9 @@ enum {
 #define CPTS_FIFO_DEPTH 16
 #define CPTS_MAX_EVENTS 32
 
+#define CPTS_EVENT_RX_TX_TIMEOUT 20 /* ms */
+#define CPTS_EVENT_HWSTAMP_TIMEOUT 200 /* ms */
+
 struct cpts_event {
 	struct list_head list;
 	unsigned long tmo;
@@ -129,7 +132,10 @@ struct cpts {
 	struct list_head pool;
 	struct cpts_event pool_data[CPTS_MAX_EVENTS];
 	unsigned long ov_check_period;
+	unsigned long ov_check_period_slow;
 	u32 rftclk_sel;
+	u32 ext_ts_inputs;
+	u32 hw_ts_enable;
 	u32 caps;
 };
 
Signature · 1 line
2.10.1
#24 lore raw

PATCH 4/6 net: ethernet: ti: cpts: add ptp pps support

In reply to Grygorii Strashko

The TS_COMP output in the CPSW CPTS module is asserted for ts_comp_length[15:0] RCLK periods when the time_stamp value compares with the ts_comp_val[31:0] and the length value is non-zero. The TS_COMP pulse edge occurs three RCLK periods after the values compare. A timestamp compare event is pushed into the event FIFO when TS_COMP is asserted.

This patch adds support of Pulse-Per-Second (PPS) by using the timestamp compare output. The CPTS driver adds one second of counter value to the ts_comp_val register after each assertion of the TS_COMP output. The TS_COMP pulse polarity and width are configurable in DT.

---
 .../devicetree/bindings/net/keystone-netcp.txt     |  10 +
 drivers/net/ethernet/ti/cpts.c                     | 237 ++++++++++++++++++++-
 drivers/net/ethernet/ti/cpts.h                     |  14 +-
 3 files changed, 251 insertions(+), 10 deletions(-)
Documentation/devicetree/bindings/net/keystone-netcp.txt +10 -0
index 1c805319..060af96 100644
@@ -127,6 +127,16 @@ Optional properties:
 		The number of external time stamp channels.
 		The different CPTS versions might support up 8
 		external time stamp channels. if absent - unsupported.
+	- cpts-ts-comp-length:
+		Enable time stamp comparison event and TS_COMP signal output
+		generation when CPTS counter reaches a value written to
+		the TS_COMP_VAL register.
+		The generated pulse width is 3 refclk cycles if this property
+		has no value (empty) or, otherwise, it should specify desired
+		pulse width in number of refclk periods - max value 2^16.
+		TS_COMP functionality will be disabled if not present.
+	- cpts-ts-comp-polarity-low:
+		Set polarity of TS_COMP signal to low. Default is hight.
 
 NetCP interface properties: Interface specification for NetCP sub-modules.
 Required properties:
drivers/net/ethernet/ti/cpts.c +228 -9

378 lines not on this page · raw message

drivers/net/ethernet/ti/cpts.h +13 -1
index ad80c95..a82520d 100644
@@ -39,7 +39,8 @@ struct cpsw_cpts {
 	u32 ts_push;              /* Time stamp event push */
 	u32 ts_load_val;          /* Time stamp load value */
 	u32 ts_load_en;           /* Time stamp load enable */
-	u32 res2[2];
+	u32 ts_comp_val;          /* Time stamp comparison value, v1.5 & up */
+	u32 ts_comp_length;       /* Time stamp comp assert len, v1.5 & up */
 	u32 intstat_raw;          /* Time sync interrupt status raw */
 	u32 intstat_masked;       /* Time sync interrupt status masked */
 	u32 int_enable;           /* Time sync interrupt enable */
@@ -64,11 +65,14 @@ struct cpsw_cpts {
 #define HW3_TS_PUSH_EN       (1<<10) /* Hardware push 3 enable */
 #define HW2_TS_PUSH_EN       (1<<9)  /* Hardware push 2 enable */
 #define HW1_TS_PUSH_EN       (1<<8)  /* Hardware push 1 enable */
+#define TS_COMP_POL	     BIT(2)  /* TS_COMP Polarity */
 #define INT_TEST             (1<<1)  /* Interrupt Test */
 #define CPTS_EN              (1<<0)  /* Time Sync Enable */
 
 #define CPTS_RFTCLK_SEL_MASK 0x1f
 
+#define CPTS_TS_COMP_LENGTH_MASK 0xffff
+
 /*
  * Definitions for the single bit resisters:
  * TS_PUSH TS_LOAD_EN  INTSTAT_RAW INTSTAT_MASKED INT_ENABLE EVENT_POP
@@ -97,6 +101,7 @@ enum {
 	CPTS_EV_HW,   /* Hardware Time Stamp Push Event */
 	CPTS_EV_RX,   /* Ethernet Receive Event */
 	CPTS_EV_TX,   /* Ethernet Transmit Event */
+	CPTS_EV_COMP, /* Time Stamp Compare Event */
 };
 
 #define CPTS_FIFO_DEPTH 16
@@ -113,6 +118,8 @@ struct cpts_event {
 };
 
 #define CPTS_CAP_RFTCLK_SEL BIT(0)
+#define CPTS_CAP_TS_COMP_EN BIT(1)
+#define CPTS_CAP_TS_COMP_POL_LOW_SEL BIT(2)
 
 struct cpts {
 	struct device *dev;
@@ -137,6 +144,11 @@ struct cpts {
 	u32 ext_ts_inputs;
 	u32 hw_ts_enable;
 	u32 caps;
+	u32 ts_comp_next;	/* next time_stamp value to compare with */
+	u32 ts_comp_length;	/* TS_COMP Output pulse width */
+	u32 ts_comp_one_sec_cycs; /* number of counter cycles in one sec */
+	int ts_comp_enabled;
+	struct mutex ptp_clk_mutex; /* sync PTP interface with overflow_work */
 };
 
 void cpts_rx_timestamp(struct cpts *cpts, struct sk_buff *skb);
Signature · 1 line
2.10.1
#35 lore raw

PATCH 5/6 ARM: keystone: dts: fix netcp clocks and add names

In reply to Grygorii Strashko

From: Murali Karicheri <[email protected]>

Fix the pa clock to point to the clkpa which has clock rate of 1/3 of PA PLL clock and add clock names.

---
 arch/arm/boot/dts/keystone-k2e-netcp.dtsi  | 3 ++-
 arch/arm/boot/dts/keystone-k2hk-netcp.dtsi | 3 ++-
 arch/arm/boot/dts/keystone-k2l-netcp.dtsi  | 3 ++-
 3 files changed, 6 insertions(+), 3 deletions(-)
arch/arm/boot/dts/keystone-k2e-netcp.dtsi +2 -1
index ac990f6..ba828cb 100644
@@ -138,7 +138,8 @@ netcp: netcp@24000000 {
 	/* NetCP address range */
 	ranges = <0 0x24000000 0x1000000>;
 
-	clocks = <&papllclk>, <&clkcpgmac>, <&chipclk12>;
+	clocks = <&clkpa>, <&clkcpgmac>, <&chipclk12>;
+	clock-names = "pa_clk", "ethss_clk", "cpts";
 	dma-coherent;
 
 	ti,navigator-dmas = <&dma_gbe 0>,
arch/arm/boot/dts/keystone-k2hk-netcp.dtsi +2 -1
index f86d6dd..a5ac845 100644
@@ -155,7 +155,8 @@ netcp: netcp@2000000 {
 	/* NetCP address range */
 	ranges  = <0 0x2000000 0x100000>;
 
-	clocks = <&papllclk>, <&clkcpgmac>, <&chipclk12>;
+	clocks = <&clkpa>, <&clkcpgmac>, <&chipclk12>;
+	clock-names = "pa_clk", "ethss_clk", "cpts";
 	dma-coherent;
 
 	ti,navigator-dmas = <&dma_gbe 22>,
arch/arm/boot/dts/keystone-k2l-netcp.dtsi +2 -1
index 5acbd0d..b6f2682 100644
@@ -137,7 +137,8 @@ netcp: netcp@26000000 {
 	/* NetCP address range */
 	ranges = <0 0x26000000 0x1000000>;
 
-	clocks = <&clkosr>, <&papllclk>, <&clkcpgmac>, <&chipclk12>;
+	clocks = <&clkpa>, <&clkcpgmac>, <&chipclk12>, <&clkosr>;
+	clock-names = "pa_clk", "ethss_clk", "cpts", "osr_clk";
 	dma-coherent;
 
 	ti,navigator-dmas = <&dma_gbe 0>,
Signature · 6 lines
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#36 lore raw

PATCH 6/6 ARM: dts: keystone: enable time synchronization (cpts) submodule

In reply to Grygorii Strashko

This patch adds DT configuration for Time Synchronization (CPTS) submodule which is present on KeyStone 66AK2HK/E/Lx 1G Switch Subsystem. The SYSCLK2 is selected as CPTS rftclk by default.
The ts_comp enabled for 66AK2E/L SoCs.

---
 arch/arm/boot/dts/keystone-k2e-netcp.dtsi  | 3 +++
 arch/arm/boot/dts/keystone-k2hk-netcp.dtsi | 1 +
 arch/arm/boot/dts/keystone-k2l-netcp.dtsi  | 3 +++
 3 files changed, 7 insertions(+)
arch/arm/boot/dts/keystone-k2e-netcp.dtsi +3 -0
index ba828cb..919e655 100644
@@ -158,6 +158,9 @@ netcp: netcp@24000000 {
 			/* enable-ale; */
 			tx-queue = <896>;
 			tx-channel = "nettx";
+			cpts-rftclk-sel = <0>;
+			cpts-ext-ts-inputs = <6>;
+			cpts-ts-comp-length;
 
 			interfaces {
 				gbe0: interface-0 {
arch/arm/boot/dts/keystone-k2hk-netcp.dtsi +1 -0
index a5ac845..772097b 100644
@@ -177,6 +177,7 @@ netcp: netcp@2000000 {
 			/* enable-ale; */
 			tx-queue = <648>;
 			tx-channel = "nettx";
+			cpts-rftclk-sel = <0>;
 
 			interfaces {
 				gbe0: interface-0 {
arch/arm/boot/dts/keystone-k2l-netcp.dtsi +3 -0
index b6f2682..580e2b2 100644
@@ -157,6 +157,9 @@ netcp: netcp@26000000 {
 			/* enable-ale; */
 			tx-queue = <896>;
 			tx-channel = "nettx";
+			cpts-rftclk-sel = <0>;
+			cpts-ext-ts-inputs = <6>;
+			cpts-ts-comp-length;
 
 			interfaces {
 				gbe0: interface-0 {
Signature · 1 line
2.10.1
#2 lore raw

Re: [PATCH 1/6] net: ethernet: ti: netcp: add support of cpts

In reply to Grygorii Strashko

drivers/net/ethernet/ti/netcp_ethss.c struct gbe_priv { · line 748

Quoted 6 lines · Grygorii Strashko
drivers/net/ethernet/ti/netcp_ethss.c +2 -0
@@ -678,6 +744,9 @@ struct gbe_priv {
 	int				num_et_stats;
 	/*  Lock for updating the hwstats */
 	spinlock_t			hw_stats_lock;
+
+	int                             cpts_registered;

The usage of this counter is racy.

drivers/net/ethernet/ti/netcp_ethss.c struct gbe_priv { · line 750

Quoted 2 lines
drivers/net/ethernet/ti/netcp_ethss.c +1 -0
+	struct cpts                     *cpts;
 };

This ++ and -- business ...

Quoted 17 lines
drivers/net/ethernet/ti/netcp_ethss.c +17 -0
+static void gbe_register_cpts(struct gbe_priv *gbe_dev)
+{
+	if (!gbe_dev->cpts)
+		return;
+
+	if (gbe_dev->cpts_registered > 0)
+		goto done;
+
+	if (cpts_register(gbe_dev->cpts)) {
+		dev_err(gbe_dev->dev, "error registering cpts device\n");
+		return;
+	}
+
+done:
+	++gbe_dev->cpts_registered;
+}
+

drivers/net/ethernet/ti/netcp_ethss.c static int gbe_del_vid(void *intf_priv, int vid) · line 2689

Quoted 10 lines
drivers/net/ethernet/ti/netcp_ethss.c +10 -0
+static void gbe_unregister_cpts(struct gbe_priv *gbe_dev)
+{
+	if (!gbe_dev->cpts || (gbe_dev->cpts_registered <= 0))
+		return;
+
+	if (--gbe_dev->cpts_registered)
+		return;
+
+	cpts_unregister(gbe_dev->cpts);
+}

is invoked from your open() and close() methods, but those methods are not serialized among multiple ports.

Thanks,
Richard

#9 lore raw

Re: [PATCH 2/6] net: ethernet: ti: cpts: add support for ext rftclk selection

In reply to Grygorii Strashko
Quoted 9 lines · Grygorii Strashko

Some CPTS instances, which can be found on KeyStone 2 1/10G Ethernet Switch Subsystems, can control an external multiplexer that selects one of up to 32 clocks for time sync reference (RFTCLK). This feature can be configured through CPTS_RFTCLK_SEL register (offset: x08).

Hence, introduce optional DT cpts_rftclk_sel poperty wich, if present, will specify CPTS reference clock. The cpts_rftclk_sel should be omitted in DT if HW doesn't support this feature. The external fixed rate clocks can be defined in board files as "fixed-clock".

Can't you implement this using the clock tree, rather than an ad-hoc DT property?

Thanks,
Richard
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#25 lore raw

Re: [PATCH 4/6] net: ethernet: ti: cpts: add ptp pps support

In reply to Grygorii Strashko
Quoted 11 lines · Grygorii Strashko

The TS_COMP output in the CPSW CPTS module is asserted for ts_comp_length[15:0] RCLK periods when the time_stamp value compares with the ts_comp_val[31:0] and the length value is non-zero. The TS_COMP pulse edge occurs three RCLK periods after the values compare. A timestamp compare event is pushed into the event FIFO when TS_COMP is asserted.

This patch adds support of Pulse-Per-Second (PPS) by using the timestamp compare output. The CPTS driver adds one second of counter value to the ts_comp_val register after each assertion of the TS_COMP output. The TS_COMP pulse polarity and width are configurable in DT.

I really dislike this patch. You go through contortions to get from the timecounter back to the raw HW counter. That is rather ugly.

Can you adjust the frequency of the keystone devices in hardware? If so, then please implement it, and just disable PPS for the CPSW.

The only reason I used the timecounter for frequency adjustment was because the am335x HW is broken. But this shouldn't hold back other newer HW without the same silicon flaws.

Thanks,
Richard

#18 lore raw

Re: [PATCH 3/6] net: ethernet: ti: cpts: add support of cpts HW_TS_PUSH

In reply to Grygorii Strashko
Quoted 18 lines · Grygorii Strashko
drivers/net/ethernet/ti/cpts.c +18 -0
+/* HW TS */
+static int cpts_extts_enable(struct cpts *cpts, u32 index, int on)
+{
+	unsigned long flags;
+	u32 v;
+
+	if (index >= cpts->info.n_ext_ts)
+		return -ENXIO;
+
+	if (((cpts->hw_ts_enable & BIT(index)) >> index) == on)
+		return 0;
+
+	spin_lock_irqsave(&cpts->lock, flags);
+
+	v = cpts_read32(cpts, control);
+	if (on) {
+		v |= BIT(8 + index);
+		cpts->hw_ts_enable |= BIT(index);

drivers/net/ethernet/ti/cpts.c static int cpts_ptp_settime(struct ptp_clock_info *ptp, · line 282

Quoted 10 lines
drivers/net/ethernet/ti/cpts.c +10 -0
+	} else {
+		v &= ~BIT(8 + index);
+		cpts->hw_ts_enable &= ~BIT(index);
+	}
+	cpts_write32(cpts, v, control);
+
+	spin_unlock_irqrestore(&cpts->lock, flags);
+
+	if (cpts->hw_ts_enable)
+		/* poll for events faster - evry 200 ms */

every

drivers/net/ethernet/ti/cpts.c static int cpts_ptp_settime(struct ptp_clock_info *ptp, · line 284

Quoted 2 lines
drivers/net/ethernet/ti/cpts.c +2 -0
+		cpts->ov_check_period =
+			msecs_to_jiffies(CPTS_EVENT_HWSTAMP_TIMEOUT);

Bad indentation. Use braces {} to contain the comment and assignment statement.

drivers/net/ethernet/ti/cpts.c static int cpts_ptp_settime(struct ptp_clock_info *ptp, · line 292

Quoted 8 lines
drivers/net/ethernet/ti/cpts.c +8 -0
+	else
+		cpts->ov_check_period = cpts->ov_check_period_slow;
+
+	mod_delayed_work(system_wq, &cpts->overflow_work,
+			 cpts->ov_check_period);
+
+	return 0;
+}

Thanks,
Richard
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#28 lore raw

Re: [PATCH 4/6] net: ethernet: ti: cpts: add ptp pps support

In reply to Grygorii Strashko
Quoted 6 lines · Grygorii Strashko
Documentation/devicetree/bindings/net/keystone-netcp.txt +0 -0
@@ -127,6 +127,16 @@ Optional properties:
                The number of external time stamp channels.
                The different CPTS versions might support up 8
                external time stamp channels. if absent - unsupported.

Documentation/devicetree/bindings/net/keystone-netcp.txt Optional properties: · line 139

Quoted 10 lines
Documentation/devicetree/bindings/net/keystone-netcp.txt +10 -0
+       - cpts-ts-comp-length:
+               Enable time stamp comparison event and TS_COMP signal output
+               generation when CPTS counter reaches a value written to
+               the TS_COMP_VAL register.
+               The generated pulse width is 3 refclk cycles if this property
+               has no value (empty) or, otherwise, it should specify desired
+               pulse width in number of refclk periods - max value 2^16.
+               TS_COMP functionality will be disabled if not present.
+       - cpts-ts-comp-polarity-low:
+               Set polarity of TS_COMP signal to low. Default is hight.

Why is this configured via DT? Are the values fixed for a given board, depending on external components? Couldn't this be configured somewhere else?

Regards,
Jan

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#19 lore raw

Re: [PATCH 3/6] net: ethernet: ti: cpts: add support of cpts HW_TS_PUSH

In reply to Grygorii Strashko
Quoted 7 lines · Grygorii Strashko

This patch adds support of the CPTS HW_TS_PUSH events which are generated by external low frequency time stamp channels on TI's OMAP CPSW and Keystone 2 platforms. It supports up to 8 external time stamp channels for HW_TS_PUSH input pins (the number of supported channel is different for different SoCs and CPTS versions, check corresponding Data maual before enabling it). Therefore, new DT property "cpts-ext-ts-inputs" is introduced for specifying number of available external timestamp channels.

If this only depends on SoC and CTPS, it should be possible to derive the correct value from the compatible value and possibly a CPTS version register? If the existing compatible strings are not specific enough, possible a new one should be added.

Regards,
Jan

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#3 lore raw

Re: [PATCH 1/6] net: ethernet: ti: netcp: add support of cpts

In reply to Richard Cochran
Quoted 37 lines · Richard Cochran

drivers/net/ethernet/ti/netcp_ethss.c struct gbe_priv { · line 748

Quoted 6 lines · Grygorii Strashko
drivers/net/ethernet/ti/netcp_ethss.c +2 -0
@@ -678,6 +744,9 @@ struct gbe_priv {
 	int				num_et_stats;
 	/*  Lock for updating the hwstats */
 	spinlock_t			hw_stats_lock;
+
+	int                             cpts_registered;

The usage of this counter is racy.

drivers/net/ethernet/ti/netcp_ethss.c struct gbe_priv { · line 750

Quoted 2 lines
drivers/net/ethernet/ti/netcp_ethss.c +1 -0
+	struct cpts                     *cpts;
 };

This ++ and -- business ...

Quoted 22 lines
drivers/net/ethernet/ti/netcp_ethss.c +22 -0
+static void gbe_register_cpts(struct gbe_priv *gbe_dev)
+{
+	if (!gbe_dev->cpts)
+		return;
+
+	if (gbe_dev->cpts_registered > 0)
+		goto done;
+
+	if (cpts_register(gbe_dev->cpts)) {
+		dev_err(gbe_dev->dev, "error registering cpts device\n");
+		return;
+	}
+
+done:
+	++gbe_dev->cpts_registered;
+}
+
+static void gbe_unregister_cpts(struct gbe_priv *gbe_dev)
+{
+	if (!gbe_dev->cpts || (gbe_dev->cpts_registered <= 0))
+		return;
+
Quoted 9 lines

drivers/net/ethernet/ti/netcp_ethss.c static int gbe_del_vid(void *intf_priv, int vid) · line 2689

Quoted 5 lines
drivers/net/ethernet/ti/netcp_ethss.c +5 -0
+	if (--gbe_dev->cpts_registered)
+		return;
+
+	cpts_unregister(gbe_dev->cpts);
+}

is invoked from your open() and close() methods, but those methods are not serialized among multiple ports.

ok. Seems my assumption that ndo_open/ndo_close serialized by rtnl_lock is incorrect. Right? net_device_ops.ndo_open ->
netcp_ndo_open
gbe_open
gbe_register_cpts

Signature · 6 lines
regards,
-grygorii
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#10 lore raw

Re: [PATCH 2/6] net: ethernet: ti: cpts: add support for ext rftclk selection

In reply to Richard Cochran
Quoted 6 lines · Richard Cochran
Quoted 5 lines · Grygorii Strashko

Some CPTS instances, which can be found on KeyStone 2 1/10G Ethernet Switch Subsystems, can control an external multiplexer that selects one of up to 32 clocks for time sync reference (RFTCLK). This feature can be configured through CPTS_RFTCLK_SEL register (offset: x08).

Quoted 8 lines
Quoted 4 lines

Hence, introduce optional DT cpts_rftclk_sel poperty wich, if present, will specify CPTS reference clock. The cpts_rftclk_sel should be omitted in DT if HW doesn't support this feature. The external fixed rate clocks can be defined in board files as "fixed-clock".

Can't you implement this using the clock tree, rather than an ad-hoc DT property?

I've thought about this, but decided to move forward with this impl
which is pretty simple. I will try.

Signature · 6 lines
regards,
-grygorii
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#4 lore raw

Re: [PATCH 1/6] net: ethernet: ti: netcp: add support of cpts

In reply to Grygorii Strashko
Quoted 2 lines · Grygorii Strashko

ok. Seems my assumption that ndo_open/ndo_close serialized by rtnl_lock is incorrect. Right?

No, you were right in the first place. The open/close are indeed serialized by the rtnl lock.

Sorry for the noise,
Richard

#29 lore raw

Re: [PATCH 4/6] net: ethernet: ti: cpts: add ptp pps support

In reply to Grygorii Strashko

drivers/net/ethernet/ti/cpts.c static cycle_t cpts_systim_read(const struct cyclecounter *cc) · line 168

Quoted 8 lines · Grygorii Strashko
drivers/net/ethernet/ti/cpts.c +8 -0
+static cycle_t cpts_cc_ns2cyc(struct cpts *cpts, u64 nsecs)
+{
+	cycle_t cyc = (nsecs << cpts->cc.shift) + nsecs;
+
+	do_div(cyc, cpts->cc.mult);
+
+	return cyc;
+}

So you set the comparison value once per second, based on cc.mult. But when the clock is being actively synchronized, user space calls to clock_adjtimex() will change cc.mult. This can happen several times per second, depending on the PTP Sync rate.

In order to produce the PPS edge correctly, you would have to adjust the comparison value whenever cc.mult changes, but of course this is unworkable.

So I'll have to say NAK for this patch.

Thanks,
Richard

#20 lore raw

Re: [PATCH 3/6] net: ethernet: ti: cpts: add support of cpts HW_TS_PUSH

In reply to Jan Lübbe
Quoted 9 lines · Jan Lübbe
Quoted 7 lines · Grygorii Strashko

This patch adds support of the CPTS HW_TS_PUSH events which are generated by external low frequency time stamp channels on TI's OMAP CPSW and Keystone 2 platforms. It supports up to 8 external time stamp channels for HW_TS_PUSH input pins (the number of supported channel is different for different SoCs and CPTS versions, check corresponding Data maual before enabling it). Therefore, new DT property "cpts-ext-ts-inputs" is introduced for specifying number of available external timestamp channels.

Quoted 5 lines

If this only depends on SoC and CTPS, it should be possible to derive the correct value from the compatible value and possibly a CPTS version register? If the existing compatible strings are not specific enough, possible a new one should be added.

In general, I can try to add and use new compat strings "ti,netcp-k2hk"
"ti,netcp-k2l"
"ti,netcp-k2e"
"ti,netcp-k2g"
for determining CPTS capabilities.

CPTS version is not the choice due to very poor documentation which do not allow identify relations between CPTS ver and supported features :(

Murali, what do you think?

Signature · 2 lines
regards,
-grygorii
#30 lore raw

Re: [PATCH 4/6] net: ethernet: ti: cpts: add ptp pps support

In reply to Richard Cochran
Quoted 15 lines · Richard Cochran

drivers/net/ethernet/ti/cpts.c static cycle_t cpts_systim_read(const struct cyclecounter *cc) · line 168

Quoted 8 lines · Grygorii Strashko
drivers/net/ethernet/ti/cpts.c +8 -0
+static cycle_t cpts_cc_ns2cyc(struct cpts *cpts, u64 nsecs)
+{
+	cycle_t cyc = (nsecs << cpts->cc.shift) + nsecs;
+
+	do_div(cyc, cpts->cc.mult);
+
+	return cyc;
+}

So you set the comparison value once per second, based on cc.mult. But when the clock is being actively synchronized, user space calls to clock_adjtimex() will change cc.mult. This can happen several times per second, depending on the PTP Sync rate.

Right.

Quoted 2 lines

In order to produce the PPS edge correctly, you would have to adjust the comparison value whenever cc.mult changes,

yes. And that is done in cpts_ptp_adjfreq()

	if (cpts->ts_comp_enabled)
		cpts->ts_comp_one_sec_cycs = cpts_cc_ns2cyc(cpts, NSEC_PER_SEC);
	^^^ re-calculate reload value for 
 
	cpts_ts_comp_settime(cpts, ns);
	^^^ adjust the ts_comp
Quoted 2 lines

but of course this is unworkable.

Sry, but this is questionable - code for pps comes from TI internal branches (SDK releases) where it survived for a pretty long time. I'm, of course, agree that without HW support for freq adjustment this PPS feature is not super precise and has some limitation, but that is what we agree to live with.

Murali, do you have any comments regarding usability of SW freq freq adjustment approach?

Quoted 2 lines

So I'll have to say NAK for this patch.

:)

Signature · 2 lines
regards,
-grygorii
#31 lore raw

Re: [PATCH 4/6] net: ethernet: ti: cpts: add ptp pps support

Quoted 10 lines · Grygorii Strashko
Quoted 2 lines

In order to produce the PPS edge correctly, you would have to adjust the comparison value whenever cc.mult changes,

yes. And that is done in cpts_ptp_adjfreq()

	if (cpts->ts_comp_enabled)
		cpts->ts_comp_one_sec_cycs = cpts_cc_ns2cyc(cpts, NSEC_PER_SEC);
	^^^ re-calculate reload value for 
 
	cpts_ts_comp_settime(cpts, ns);
	^^^ adjust the ts_comp

And it races with the pulse itself. You forgot about this part:

drivers/net/ethernet/ti/cpts.c static int cpts_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb) · line 239

Quoted 9 lines
drivers/net/ethernet/ti/cpts.c +4 -0
@@ -172,14 +232,31 @@ static int cpts_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb)
 	adj *= ppb;
 	diff = div_u64(adj, 1000000000ULL);
 
+	mutex_lock(&cpts->ptp_clk_mutex);
+
 	spin_lock_irqsave(&cpts->lock, flags);
+	if (cpts->ts_comp_enabled) {
+		cpts_ts_comp_disable(cpts);

Sorry, but this is a train wreck.

Quoted 5 lines
Quoted 2 lines

but of course this is unworkable.

Sry, but this is questionable - code for pps comes from TI internal branches (SDK releases) where it survived for a pretty long time.

That doesn't mean the code is any good. If you adjust at the right moment, then no pulse occurs at all!

Quoted 3 lines

I'm, of course, agree that without HW support for freq adjustment this PPS feature is not super precise and has some limitation, but that is what we agree to live with.

I do NOT agree to live with this. I am one who is going to have to explain to the world why their beagle bone PPS sucks.

Thanks,
Richard

#32 lore raw

Re: [PATCH 4/6] net: ethernet: ti: cpts: add ptp pps support

Quoted 3 lines · Richard Cochran
Quoted 2 lines · Grygorii Strashko

Sry, but this is questionable - code for pps comes from TI internal branches (SDK releases) where it survived for a pretty long time.

Actually, there is a way to get an accurate PPS from the am335x. See this recent thread:

https://www.mail-archive.com/[email protected]/msg01726.html

That is the way to go, and so, please drop this present patch.

Thanks,
Richard

#33 lore raw

Re: [PATCH 4/6] net: ethernet: ti: cpts: add ptp pps support

Hi Richard,

Quoted 5 lines · Richard Cochran
Quoted 3 lines · Richard Cochran
Quoted 2 lines · Grygorii Strashko

Sry, but this is questionable - code for pps comes from TI internal branches (SDK releases) where it survived for a pretty long time.

Quoted 7 lines

Actually, there is a way to get an accurate PPS from the am335x. See this recent thread:

https://www.mail-archive.com/[email protected]/msg01726.html

That is the way to go, and so, please drop this present patch.

thanks for the links - it sounds very interesting.

As I understood, people trying to enable PPS on am335 device with the goal to have PPS signal generated on some SoC pin and therefore they use DMtimer. Also, as i understood, the Timer Load Register (TLDR) is corrected once a second at each HW_TS_PUSH - as result, if freq was corrected during current sec there will be some HW_TS_PUSH generation jitter any way.

Above solution is a bit complex for keystone 2 SoCs, as CPTS itself on these SoCs has output pin (ts_comp) which can be used for PPS signal generation. So, I think, similar results can be achieved by removing PPS correction code from cpts_ptp_adjfreq() and updating CPTS_TS_LOAD_VAL once a sec in cpts_overflow_check().

or I missed smth?

Signature · 2 lines
regards,
-grygorii
#34 lore raw

Re: [PATCH 4/6] net: ethernet: ti: cpts: add ptp pps support

Quoted 1 line · Grygorii Strashko

or I missed smth?

You are missing three important points.

1. Unlike the code you posted, no edges will be lost.

2. The solution using the PWM is implemented in USER SPACE. If people use this way, then they will be forced to understand the inherit limitations. In addition, the behavior of servo will be under their control.

3. The update rate of the PHC is not once per second. It can be any rate at all, like 16 Hz for the telecom profile. You can't just blindly pick out an adjustment value once per second. Using the feedback from the time stamped PWM and adjusting THAT at the PWM rate (also not necessarily 1 PPS) is the right way. The second reply in that thread is an even better solution, leaving the PHC free running and adjusting the timer input clock (probably they used a VCO).

Just hacking in some kind of kernel PPS with unknown accuracy is just asking for trouble later, since people will expect HW accuracy.

So just get the input time stamps working, and make PWM control available to userspace in mainline (not sure about this, I guess it isn't), and leave the PPS part to a userspace utility.

Thanks,
Richard

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#21 lore raw

Re: [PATCH 3/6] net: ethernet: ti: cpts: add support of cpts HW_TS_PUSH

In reply to Grygorii Strashko
Quoted 3 lines · Grygorii Strashko

This also change overflow polling period when HW_TS_PUSH feature is enabled - overflow check work will be scheduled more often (every 200ms) for proper HW_TS_PUSH events reporting.

For proper reporting, you should make use of the interrupt. The small fifo (16 iirc) could very well overflow in 200 ms. The interrupt handler should read out the entire fifo at each interrupt.

Thanks,
Richard

maintainer
#5 lore raw

Re: [PATCH 1/6] net: ethernet: ti: netcp: add support of cpts

In reply to Grygorii Strashko
Quoted 21 lines · Grygorii Strashko

From: WingMan Kwok <[email protected]>

This patch adds support of the cpts device found in the gbe and 10gbe ethernet switches on the keystone 2 SoCs (66AK2E/L/Hx, 66AK2Gx).

---
 .../devicetree/bindings/net/keystone-netcp.txt     |   9 +
 drivers/net/ethernet/ti/Kconfig                    |   7 +-
 drivers/net/ethernet/ti/netcp.h                    |   2 +-
 drivers/net/ethernet/ti/netcp_core.c               |  18 +-
 drivers/net/ethernet/ti/netcp_ethss.c              | 437 ++++++++++++++++++++-
 5 files changed, 459 insertions(+), 14 deletions(-)
Documentation/devicetree/bindings/net/keystone-netcp.txt +0 -0
index 04ba1dc..c37b54e 100644

Documentation/devicetree/bindings/net/keystone-netcp.txt Optional properties: · line 117

Quoted 5 lines
Documentation/devicetree/bindings/net/keystone-netcp.txt +2 -0
@@ -113,6 +113,15 @@ Optional properties:
 				will only initialize these ports and attach PHY
 				driver to them if needed.
 
+ Properties related to cpts configurations.
+	- cpts_clock_mult/cpts_clock_shift:

Needs vendor prefix. Don't use '_'.

Documentation/devicetree/bindings/net/keystone-netcp.txt Optional properties: · line 123

Quoted 6 lines
Documentation/devicetree/bindings/net/keystone-netcp.txt +6 -0
+		used for converting time counter cycles to ns as in
+
+		ns = (cycles * clock_mult) >> _shift
+
+		Defaults: clock_mult, clock_shift = calculated from
+		CPTS refclk

What does this mean?

Quoted 4 lines
Documentation/devicetree/bindings/net/keystone-netcp.txt +1 -0
+
 NetCP interface properties: Interface specification for NetCP sub-modules.
 Required properties:
 - rx-channel:	the navigator packet dma channel name for rx.
maintainer
#16 lore raw

Re: [PATCH 2/6] net: ethernet: ti: cpts: add support for ext rftclk selection

In reply to Grygorii Strashko
Quoted 5 lines · Grygorii Strashko

Some CPTS instances, which can be found on KeyStone 2 1/10G Ethernet Switch Subsystems, can control an external multiplexer that selects one of up to 32 clocks for time sync reference (RFTCLK). This feature can be configured through CPTS_RFTCLK_SEL register (offset: x08).

Quoted 8 lines

Hence, introduce optional DT cpts_rftclk_sel poperty wich, if present, will specify CPTS reference clock. The cpts_rftclk_sel should be omitted in DT if HW doesn't support this feature. The external fixed rate clocks can be defined in board files as "fixed-clock".

---
 Documentation/devicetree/bindings/net/keystone-netcp.txt |  2 ++

Please group binding changes into a single patch.

Quoted 9 lines
 drivers/net/ethernet/ti/cpts.c                           | 12 ++++++++++++
 drivers/net/ethernet/ti/cpts.h                           |  8 +++++++-
 3 files changed, 21 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/net/keystone-netcp.txt +0 -0
index c37b54e..ec4a241 100644

Documentation/devicetree/bindings/net/keystone-netcp.txt Optional properties: · line 118

Quoted 5 lines
Documentation/devicetree/bindings/net/keystone-netcp.txt +2 -0
@@ -114,6 +114,8 @@ Optional properties:
 				driver to them if needed.
 
  Properties related to cpts configurations.
+	- cpts-rftclk-sel: selects one of up to 32 clocks for time sync
+		reference.  Default = 0.

Vendor prefix.

Quoted 3 lines
Documentation/devicetree/bindings/net/keystone-netcp.txt +0 -0
 	- cpts_clock_mult/cpts_clock_shift:
 		used for converting time counter cycles to ns as in
 
#6 lore raw

Re: [PATCH 1/6] net: ethernet: ti: netcp: add support of cpts

In reply to Rob Herring
Quoted 25 lines · Rob Herring
Quoted 24 lines · Grygorii Strashko

From: WingMan Kwok <[email protected]>

This patch adds support of the cpts device found in the gbe and 10gbe ethernet switches on the keystone 2 SoCs (66AK2E/L/Hx, 66AK2Gx).

---
 .../devicetree/bindings/net/keystone-netcp.txt     |   9 +
 drivers/net/ethernet/ti/Kconfig                    |   7 +-
 drivers/net/ethernet/ti/netcp.h                    |   2 +-
 drivers/net/ethernet/ti/netcp_core.c               |  18 +-
 drivers/net/ethernet/ti/netcp_ethss.c              | 437 ++++++++++++++++++++-
 5 files changed, 459 insertions(+), 14 deletions(-)
Documentation/devicetree/bindings/net/keystone-netcp.txt +0 -0
index 04ba1dc..c37b54e 100644
@@ -113,6 +113,15 @@ Optional properties:
 				will only initialize these ports and attach PHY
 				driver to them if needed.
 
Quoted 4 lines

Documentation/devicetree/bindings/net/keystone-netcp.txt Optional properties: · line 117

Quoted 2 lines
Documentation/devicetree/bindings/net/keystone-netcp.txt +2 -0
+ Properties related to cpts configurations.
+	- cpts_clock_mult/cpts_clock_shift:

Needs vendor prefix. Don't use '_'.

This module is used as part of OMAP and Keystone SoCs, so names for this props is ABI already :(

Quoted 10 lines

Documentation/devicetree/bindings/net/keystone-netcp.txt Optional properties: · line 123

Quoted 7 lines
Documentation/devicetree/bindings/net/keystone-netcp.txt +6 -0
+		used for converting time counter cycles to ns as in
+
+		ns = (cycles * clock_mult) >> _shift
+
+		Defaults: clock_mult, clock_shift = calculated from
+		CPTS refclk

What does this mean?

I'll add more description here.

Quoted 4 lines
Quoted 4 lines
Documentation/devicetree/bindings/net/keystone-netcp.txt +1 -0
+
 NetCP interface properties: Interface specification for NetCP sub-modules.
 Required properties:
 - rx-channel:	the navigator packet dma channel name for rx.
Signature · 2 lines
regards,
-grygorii
#7 lore raw

Re: [PATCH 1/6] net: ethernet: ti: netcp: add support of cpts

Quoted 6 lines · Grygorii Strashko
Quoted 6 lines
Quoted 6 lines
Documentation/devicetree/bindings/net/keystone-netcp.txt +0 -0
@@ -113,6 +113,15 @@ Optional properties:
 				will only initialize these ports and attach PHY
 				driver to them if needed.
 
Quoted 7 lines
Quoted 4 lines

Documentation/devicetree/bindings/net/keystone-netcp.txt Optional properties: · line 117

Quoted 2 lines
Documentation/devicetree/bindings/net/keystone-netcp.txt +2 -0
+ Properties related to cpts configurations.
+	- cpts_clock_mult/cpts_clock_shift:

Needs vendor prefix. Don't use '_'.

This module is used as part of OMAP and Keystone SoCs, so names for this props is ABI already :(

Your automatic calculation makes these unnecessary, and so you can drop these altogether.

Also, maybe you should mark them as deprecated in cpsw.txt?

(The underscores were my fault, sorry)

Thanks,
Richard

#26 lore raw

Re: [PATCH 4/6] net: ethernet: ti: cpts: add ptp pps support

In reply to Richard Cochran
Quoted 6 lines · Richard Cochran

Can you adjust the frequency of the keystone devices in hardware? If so, then please implement it, and just disable PPS for the CPSW.

The only reason I used the timecounter for frequency adjustment was because the am335x HW is broken. But this shouldn't hold back other newer HW without the same silicon flaws.

I am talking here about the ADPLLLJ units. Are they usable on the keystone?

If so, please implement the frequency adjustment with them.

Thanks,
Richard
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#11 lore raw

Re: [PATCH 2/6] net: ethernet: ti: cpts: add support for ext rftclk selection

In reply to Grygorii Strashko
Quoted 14 lines · Grygorii Strashko
Quoted 11 lines · Richard Cochran
Quoted 9 lines · Grygorii Strashko

Some CPTS instances, which can be found on KeyStone 2 1/10G Ethernet Switch Subsystems, can control an external multiplexer that selects one of up to 32 clocks for time sync reference (RFTCLK). This feature can be configured through CPTS_RFTCLK_SEL register (offset: x08).

Hence, introduce optional DT cpts_rftclk_sel poperty wich, if present, will specify CPTS reference clock. The cpts_rftclk_sel should be omitted in DT if HW doesn't support this feature. The external fixed rate clocks can be defined in board files as "fixed-clock".

Quoted 8 lines
Quoted 3 lines

Can't you implement this using the clock tree, rather than an ad-hoc DT property?

I've thought about this, but decided to move forward with this impl
which is pretty simple. I will try.

I come with below RFC patch. if no objection I'll move forward with it.

According to Keystone 2 66AK2e DM there are 7 possible ref clocks:
0000 = SYSCLK2
0001 = SYSCLK3
0010 = TIMI0
0011 = TIMI1
0100 = TSIPCLKA
1000 = TSREFCLK
1100 = TSIPCLKB
Others = Reserved

2 from above clocks are internal SYSCLK2 and SYSCLK3 - other external (board specific). So default definition of cpts_mux will have only two parents. If ext clock is going to be use as cpts rftclk then it should be defined in board file and cpts_refclk_mux definition updated to support this ext clock:

timi1clk: timi1clk {
	#clock-cells = <0>;
	compatible = "fixed-clock";
	clock-frequency = <xxxxxxxxxx>;
	clock-output-names = "timi1";
};
&cpts_mux {
	clocks = <&chipclk12>, <&chipclk13>, <timi1clk>;
	cpts-mux-tbl = <0>, <1>, <3>;
	assigned-clocks = <&cpts_mux>;
	assigned-clock-parents = <&timi1clk>;
};
Quoted 1 line

From ec5c7bed0e021c2ca7e9392173bf67bb9a45d0f4 Mon Sep 17 00:00:00 2001

From: Grygorii Strashko <[email protected]>
Date: Mon, 5 Dec 2016 12:34:45 -0600
Subject: [PATCH] cpts refclk sel

---
 arch/arm/boot/dts/keystone-k2e-netcp.dtsi | 10 +++++-
 drivers/net/ethernet/ti/cpts.c            | 52 ++++++++++++++++++++++++++++++-
 2 files changed, 60 insertions(+), 2 deletions(-)
arch/arm/boot/dts/keystone-k2e-netcp.dtsi +9 -1
index 919e655..b27aa22 100644
@@ -138,7 +138,7 @@ netcp: netcp@24000000 {
 	/* NetCP address range */
 	ranges = <0 0x24000000 0x1000000>;
 
-	clocks = <&clkpa>, <&clkcpgmac>, <&chipclk12>;
+	clocks = <&clkpa>, <&clkcpgmac>, <&cpts_mux>;
 	clock-names = "pa_clk", "ethss_clk", "cpts";
 	dma-coherent;
 
@@ -162,6 +162,14 @@ netcp: netcp@24000000 {
 			cpts-ext-ts-inputs = <6>;
 			cpts-ts-comp-length;
 
+			cpts_mux: cpts_refclk_mux {
+				#clock-cells = <0>;
+				clocks = <&chipclk12>, <&chipclk13>;
+				cpts-mux-tbl = <0>, <1>;
+				assigned-clocks = <&cpts_mux>;
+				assigned-clock-parents = <&chipclk12>;
+			};
+
 			interfaces {
 				gbe0: interface-0 {
 					slave-port = <0>;
drivers/net/ethernet/ti/cpts.c +51 -1

76 lines not on this page · raw message

Signature · 7 lines
2.10.1



-- 
regards,
-grygorii
#12 lore raw

Re: [PATCH 2/6] net: ethernet: ti: cpts: add support for ext rftclk selection

Quoted 1 line · Grygorii Strashko

I come with below RFC patch. if no objection I'll move forward with it.

Thanks for following through with this!

The am335x will also need the MUX in its clock tree, won't it?

Thanks,
Richard

#13 lore raw

Re: [PATCH 2/6] net: ethernet: ti: cpts: add support for ext rftclk selection

Quoted 7 lines · Richard Cochran
Quoted 1 line · Grygorii Strashko

I come with below RFC patch. if no objection I'll move forward with it.

Thanks for following through with this!

The am335x will also need the MUX in its clock tree, won't it?

Not exactly. I do not see CPTS_RFTCLK_SEL register in trm, but looks like it's already implemented in am335 clock tree:

	cpsw_cpts_rft_clk: cpsw_cpts_rft_clk@520 {
		#clock-cells = <0>;
		compatible = "ti,mux-clock";
		clocks = <&dpll_core_m5_ck>, <&dpll_core_m4_ck>;
		reg = <0x0520>;
	};

and ssigned-clock-xx can be used to change parent in board file:

&cpsw_cpts_rft_clk {
assigned-clocks = <&cpsw_cpts_rft_clk>;
assigned-clock-parents = <&dpll_core_m4_ck>;
};

Signature · 6 lines
regards,
-grygorii
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#27 lore raw

Re: [PATCH 4/6] net: ethernet: ti: cpts: add ptp pps support

In reply to Richard Cochran
Quoted 4 lines · Richard Cochran
Quoted 3 lines · Richard Cochran

Can you adjust the frequency of the keystone devices in hardware? If so, then please implement it, and just disable PPS for the CPSW.

Quoted 9 lines
Quoted 3 lines

The only reason I used the timecounter for frequency adjustment was because the am335x HW is broken. But this shouldn't hold back other newer HW without the same silicon flaws.

I am talking here about the ADPLLLJ units. Are they usable on the keystone?

If so, please implement the frequency adjustment with them.

No, I think it's not impossible (at least as I know now). i'll drop this patch for now.

By the way, I've tested am335 (BBB)+ HW_TS_PUSH + PWM. Seems works.

Signature · 2 lines
regards,
-grygorii
#22 lore raw

Re: [PATCH 3/6] net: ethernet: ti: cpts: add support of cpts HW_TS_PUSH

In reply to Richard Cochran
Quoted 9 lines · Richard Cochran
Quoted 3 lines · Grygorii Strashko

This also change overflow polling period when HW_TS_PUSH feature is enabled - overflow check work will be scheduled more often (every 200ms) for proper HW_TS_PUSH events reporting.

For proper reporting, you should make use of the interrupt. The small fifo (16 iirc) could very well overflow in 200 ms. The interrupt handler should read out the entire fifo at each interrupt.

huh. Seems this is not really good idea, because MISC Irq will be triggered for *any* CPTS event and there is no way to enable it just for HW_TS_PUSH. So, this doesn't work will with current code for RX/TX timestamping (which uses polling mode). + runtime overhead in net RX/TX caused by triggering more interrupts.

May be, overflow check/polling timeout can be made configurable (module parameter).

Signature · 6 lines
regards,
-grygorii
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#14 lore raw

Re: [PATCH 2/6] net: ethernet: ti: cpts: add support for ext rftclk selection

In reply to Grygorii Strashko
Quoted 22 lines · Grygorii Strashko

Subject: [PATCH] cpts refclk sel

---
 arch/arm/boot/dts/keystone-k2e-netcp.dtsi | 10 +++++-
 drivers/net/ethernet/ti/cpts.c            | 52 ++++++++++++++++++++++++++++++-
 2 files changed, 60 insertions(+), 2 deletions(-)
arch/arm/boot/dts/keystone-k2e-netcp.dtsi +1 -1
index 919e655..b27aa22 100644
@@ -138,7 +138,7 @@ netcp: netcp@24000000 {
 	/* NetCP address range */
 	ranges = <0 0x24000000 0x1000000>;
 
-	clocks = <&clkpa>, <&clkcpgmac>, <&chipclk12>;
+	clocks = <&clkpa>, <&clkcpgmac>, <&cpts_mux>;
 	clock-names = "pa_clk", "ethss_clk", "cpts";
 	dma-coherent;
 

arch/arm/boot/dts/keystone-k2e-netcp.dtsi netcp: netcp@24000000 { · line 170

Quoted 9 lines
arch/arm/boot/dts/keystone-k2e-netcp.dtsi +6 -0
@@ -162,6 +162,14 @@ netcp: netcp@24000000 {
 			cpts-ext-ts-inputs = <6>;
 			cpts-ts-comp-length;
 
+			cpts_mux: cpts_refclk_mux {
+				#clock-cells = <0>;
+				clocks = <&chipclk12>, <&chipclk13>;
+				cpts-mux-tbl = <0>, <1>;
+				assigned-clocks = <&cpts_mux>;
+				assigned-clock-parents = <&chipclk12>;

Is there a binding update? Why the subnode? Why not have it as part of the netcp node? Does the cpts-mux-tbl property change?

Quoted 18 lines
arch/arm/boot/dts/keystone-k2e-netcp.dtsi +2 -0
+			};
+
 			interfaces {
 				gbe0: interface-0 {
 					slave-port = <0>;
drivers/net/ethernet/ti/cpts.c +1 -0
index 938de22..ef94316 100644
@@ -17,6 +17,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
  */
+#include <linux/clk-provider.h>
 #include <linux/err.h>
 #include <linux/if.h>
 #include <linux/hrtimer.h>

drivers/net/ethernet/ti/cpts.c int cpts_register(struct cpts *cpts) · line 676

Quoted 4 lines
drivers/net/ethernet/ti/cpts.c +1 -0
@@ -672,6 +673,7 @@ int cpts_register(struct cpts *cpts)
 	cpts->phc_index = ptp_clock_index(cpts->clock);
 
 	schedule_delayed_work(&cpts->overflow_work, cpts->ov_check_period);
+

Maybe in another patch.

Quoted 43 lines
drivers/net/ethernet/ti/cpts.c +36 -0
 	return 0;
 
 err_ptp:
@@ -741,6 +743,54 @@ static void cpts_calc_mult_shift(struct cpts *cpts)
 		 freq, cpts->cc_mult, cpts->cc.shift, (ns - NSEC_PER_SEC));
 }
 
+static int cpts_of_mux_clk_setup(struct cpts *cpts, struct device_node *node)
+{
+	unsigned int num_parents;
+	const char **parent_names;
+	struct device_node *refclk_np;
+	void __iomem *reg;
+	struct clk *clk;
+	u32 *mux_table;
+	int ret;
+
+	refclk_np = of_get_child_by_name(node, "cpts_refclk_mux");
+	if (!refclk_np)
+		return -EINVAL;
+
+	num_parents = of_clk_get_parent_count(refclk_np);
+	if (num_parents < 1) {
+		dev_err(cpts->dev, "mux-clock %s must have parents\n",
+			refclk_np->name);
+		return -EINVAL;
+	}
+	parent_names = devm_kzalloc(cpts->dev, (sizeof(char *) * num_parents),
+				    GFP_KERNEL);
+	if (!parent_names)
+		return -ENOMEM;
+
+	of_clk_parent_fill(refclk_np, parent_names, num_parents);
+
+	mux_table = devm_kzalloc(cpts->dev, sizeof(*mux_table) * (32 + 1),
+				 GFP_KERNEL);
+	if (!mux_table)
+		return -ENOMEM;
+
+	ret = of_property_read_variable_u32_array(refclk_np, "cpts-mux-tbl",
+						  mux_table, 1, 32);
+	if (ret < 0)
+		return ret;

drivers/net/ethernet/ti/cpts.c static void cpts_calc_mult_shift(struct cpts *cpts) · line 791

Quoted 10 lines
drivers/net/ethernet/ti/cpts.c +10 -0
+
+	reg = &cpts->reg->rftclk_sel;
+
+	clk = clk_register_mux_table(cpts->dev, refclk_np->name,
+				     parent_names, num_parents,
+				     0, reg, 0, 0x1F, 0, mux_table, NULL);
+	if (IS_ERR(clk))
+		return PTR_ERR(clk);
+
+	return of_clk_add_provider(refclk_np, of_clk_src_simple_get, clk);

Can you please use the clk_hw APIs instead?

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#23 lore raw

Re: [PATCH 3/6] net: ethernet: ti: cpts: add support of cpts HW_TS_PUSH

In reply to Grygorii Strashko
Quoted 3 lines · Grygorii Strashko

huh. Seems this is not really good idea, because MISC Irq will be triggered for *any* CPTS event and there is no way to enable it just for HW_TS_PUSH.

So what? That is not a problem.

Quoted 2 lines

So, this doesn't work will with current code for RX/TX timestamping (which uses polling mode).

Why doesn't it work?

Quoted 2 lines

+ runtime overhead in net RX/TX caused by
triggering more interrupts.

This is not relevant. Without HW_TS_PUSH, there is no need for enabling the interrupt simply because we don't need it. Now, with HW_TS_PUSH, we do need it.

Quoted 1 line

May be, overflow check/polling timeout can be made configurable (module parameter).

No, it should just work without any user space fiddling.

I getting a bit tired of your half-baked implementations of the ancillary clock functions. Either do it right, or just leave it unsupported.

Thanks,
Richard

#15 lore raw

Re: [PATCH 2/6] net: ethernet: ti: cpts: add support for ext rftclk selection

In reply to Stephen Boyd
Quoted 17 lines · Stephen Boyd
Quoted 16 lines · Grygorii Strashko

Subject: [PATCH] cpts refclk sel

---
 arch/arm/boot/dts/keystone-k2e-netcp.dtsi | 10 +++++-
 drivers/net/ethernet/ti/cpts.c            | 52 ++++++++++++++++++++++++++++++-
 2 files changed, 60 insertions(+), 2 deletions(-)
arch/arm/boot/dts/keystone-k2e-netcp.dtsi +0 -0
index 919e655..b27aa22 100644
@@ -138,7 +138,7 @@ netcp: netcp@24000000 {
 	/* NetCP address range */
 	ranges = <0 0x24000000 0x1000000>;
 
Quoted 2 lines

arch/arm/boot/dts/keystone-k2e-netcp.dtsi netcp: netcp@24000000 { · line 141

Quoted 2 lines
arch/arm/boot/dts/keystone-k2e-netcp.dtsi +1 -1
-	clocks = <&clkpa>, <&clkcpgmac>, <&chipclk12>;
+	clocks = <&clkpa>, <&clkcpgmac>, <&cpts_mux>;

^^ mux clock used here

Quoted 7 lines
Quoted 7 lines
arch/arm/boot/dts/keystone-k2e-netcp.dtsi +0 -0
 	clock-names = "pa_clk", "ethss_clk", "cpts";
 	dma-coherent;
 
@@ -162,6 +162,14 @@ netcp: netcp@24000000 {
 			cpts-ext-ts-inputs = <6>;
 			cpts-ts-comp-length;
 
Quoted 8 lines

arch/arm/boot/dts/keystone-k2e-netcp.dtsi netcp: netcp@24000000 { · line 170

Quoted 6 lines
arch/arm/boot/dts/keystone-k2e-netcp.dtsi +6 -0
+			cpts_mux: cpts_refclk_mux {
+				#clock-cells = <0>;
+				clocks = <&chipclk12>, <&chipclk13>;
+				cpts-mux-tbl = <0>, <1>;
+				assigned-clocks = <&cpts_mux>;
+				assigned-clock-parents = <&chipclk12>;

Is there a binding update?

this was pure RFC-DEV patch just to check the possibility of modeling CPTS_RFTCLK_SEL register as mux clock.
Original patch:
https://lkml.org/lkml/2016/11/28/780

I've plan to resend it using clk framework.

Why the subnode?

Sry, I did not get this question - is there another way to pas phandle on clock in clocks list property? Am I missing smth.?

Sry, this is my first clock :)

Quoted 1 line

Why not have it as part of the netcp node?

cpts is part of gbe ethss, which is part of netcp.

Only netcp is modeled as DD - cpts and gbe ethss implemented without using DD model, so generic resources acquired by netcp and then passed to cpts and gbe ethss.

CPTS has register to control an external multiplexer that selects one of up to 32 clocks for time sync reference (RFTCLK)

Quoted 1 line

Does the cpts-mux-tbl property change?

On Keystone 2 66AK2e (as example) the following list of clocks can be selected as ref clocks (list is different for other SoCs):
0000 = SYSCLK2
0001 = SYSCLK3
0010 = TIMI0
0011 = TIMI1
0100 = TSIPCLKA
1000 = TSREFCLK
1100 = TSIPCLKB
Others = Reserved

and only 0 and 1 are internal, other external and board specific (parameters unknown and corresponding inputs can be used for other purposes), so I can't define all parent clocks, only internal:

clocks = <&chipclk12>, <&chipclk13>;
cpts-mux-tbl = <0>, <1>;

to use another, external, clock - it should be explicitly defined in board file the board file

timi1clk: timi1clk {
	#clock-cells = <0>;
	compatible = "fixed-clock";

...

&cpts_mux {
	clocks = <&chipclk12>, <&chipclk13>, <timi1clk>;
						^^^ i can't predict value here
	cpts-mux-tbl = <0>, <1>, <3>;
				^^i can't predict value here
	assigned-clocks = <&cpts_mux>;
	assigned-clock-parents = <&timi1clk>;
};

or I understood your question wrongly?

Quoted 21 lines
Quoted 21 lines
arch/arm/boot/dts/keystone-k2e-netcp.dtsi +2 -0
+			};
+
 			interfaces {
 				gbe0: interface-0 {
 					slave-port = <0>;
drivers/net/ethernet/ti/cpts.c +1 -0
index 938de22..ef94316 100644
@@ -17,6 +17,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
  */
+#include <linux/clk-provider.h>
 #include <linux/err.h>
 #include <linux/if.h>
 #include <linux/hrtimer.h>
@@ -672,6 +673,7 @@ int cpts_register(struct cpts *cpts)
 	cpts->phc_index = ptp_clock_index(cpts->clock);
 
Quoted 5 lines

drivers/net/ethernet/ti/cpts.c int cpts_register(struct cpts *cpts) · line 676

Quoted 2 lines
drivers/net/ethernet/ti/cpts.c +1 -0
 	schedule_delayed_work(&cpts->overflow_work, cpts->ov_check_period);
+

Maybe in another patch.

sure

Quoted 7 lines
Quoted 7 lines
drivers/net/ethernet/ti/cpts.c +0 -0
 	return 0;
 
 err_ptp:
@@ -741,6 +743,54 @@ static void cpts_calc_mult_shift(struct cpts *cpts)
 		 freq, cpts->cc_mult, cpts->cc.shift, (ns - NSEC_PER_SEC));
 }
 

...

Quoted 4 lines
Quoted 4 lines
drivers/net/ethernet/ti/cpts.c +4 -0
+
+	reg = &cpts->reg->rftclk_sel;
+
+	clk = clk_register_mux_table(cpts->dev, refclk_np->name,
Quoted 9 lines

drivers/net/ethernet/ti/cpts.c static void cpts_calc_mult_shift(struct cpts *cpts) · line 791

Quoted 6 lines
drivers/net/ethernet/ti/cpts.c +6 -0
+				     parent_names, num_parents,
+				     0, reg, 0, 0x1F, 0, mux_table, NULL);
+	if (IS_ERR(clk))
+		return PTR_ERR(clk);
+
+	return of_clk_add_provider(refclk_np, of_clk_src_simple_get, clk);

Can you please use the clk_hw APIs instead?

ok

Signature · 6 lines
regards,
-grygorii
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html