devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v4 0/5] Enable PTP timestamping/PPS for AM65x SR1.0 devices
@ 2024-06-17 15:21 Diogo Ivo
  2024-06-17 15:21 ` [PATCH net-next v4 1/5] net: ti: icssg-prueth: Enable PTP timestamping support for " Diogo Ivo
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Diogo Ivo @ 2024-06-17 15:21 UTC (permalink / raw)
  To: MD Danish Anwar, Roger Quadros, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Richard Cochran, Nishanth Menon,
	Vignesh Raghavendra, Tero Kristo, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jan Kiszka, Jacob Keller,
	Simon Horman
  Cc: linux-arm-kernel, netdev, linux-kernel, devicetree, Diogo Ivo,
	Wojciech Drewek

This patch series enables support for PTP in AM65x SR1.0 devices.

This feature relies heavily on the Industrial Ethernet Peripheral
(IEP) hardware module, which implements a hardware counter through
which time is kept. This hardware block is the basis for exposing
a PTP hardware clock to userspace and for issuing timestamps for
incoming/outgoing packets, allowing for time synchronization.

The IEP also has compare registers that fire an interrupt when the
counter reaches the value stored in a compare register. This feature
allows us to support PPS events in the kernel.

The changes are separated into five patches:
 - PATCH 01/05: Register SR1.0 devices with the IEP infrastructure to
		expose a PHC clock to userspace, allowing time to be
		adjusted using standard PTP tools. The code for issuing/
		collecting packet timestamps is already present in the
		current state of the driver, so only this needs to be
		done.
 - PATCH 02/05: Remove unnecessary spinlock synchronization.
 - PATCH 03/05: Document IEP interrupt in DT binding.
 - PATCH 04/05: Add support for IEP compare event/interrupt handling
		to enable PPS events.
 - PATCH 05/05: Add the interrupts to the IOT2050 device tree.

Currently every compare event generates two interrupts, the first
corresponding to the actual event and the second being a spurious
but otherwise harmless interrupt. The root cause of this has been
identified and has been solved in the platform's SDK. A forward port
of the SDK's patches also fixes the problem in upstream but is not
included here since it's upstreaming is out of the scope of this
series. If someone from TI would be willing to chime in and help
get the interrupt changes upstream that would be great!

Signed-off-by: Diogo Ivo <diogo.ivo@siemens.com>
---
Changes in v4:
- Remove unused 'flags' variables in patch 02/05
- Add patch 03/05 describing IEP interrupt in DT binding
- Link to v3: https://lore.kernel.org/r/20240607-iep-v3-0-4824224105bc@siemens.com

Changes in v3:
- Collect Reviewed-by tags
- Add patch 02/04 removing spinlocks from IEP driver
- Use mutex-based synchronization when accessing HW registers
- Link to v2: https://lore.kernel.org/r/20240604-iep-v2-0-ea8e1c0a5686@siemens.com

Changes in v2:
- Collect Reviewed-by tags
- PATCH 01/03: Limit line length to 80 characters
- PATCH 02/03: Proceed with limited functionality if getting IRQ fails,
	       limit line length to 80 characters
- Link to v1: https://lore.kernel.org/r/20240529-iep-v1-0-7273c07592d3@siemens.com

---
Diogo Ivo (5):
      net: ti: icssg-prueth: Enable PTP timestamping support for SR1.0 devices
      net: ti: icss-iep: Remove spinlock-based synchronization
      dt-bindings: net: Add IEP interrupt
      net: ti: icss-iep: Enable compare events
      arm64: dts: ti: iot2050: Add IEP interrupts for SR1.0 devices

 .../devicetree/bindings/net/ti,icss-iep.yaml       |  9 +++
 .../boot/dts/ti/k3-am65-iot2050-common-pg1.dtsi    | 12 +++
 drivers/net/ethernet/ti/icssg/icss_iep.c           | 88 ++++++++++++++++++----
 drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c   | 51 ++++++++++++-
 4 files changed, 145 insertions(+), 15 deletions(-)
---
base-commit: 2f0e3f6a6824dfda2759225326d9c69203c06bc8
change-id: 20240529-iep-8bb4a3cb9068

Best regards,
-- 
Diogo Ivo <diogo.ivo@siemens.com>


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH net-next v4 1/5] net: ti: icssg-prueth: Enable PTP timestamping support for SR1.0 devices
  2024-06-17 15:21 [PATCH net-next v4 0/5] Enable PTP timestamping/PPS for AM65x SR1.0 devices Diogo Ivo
@ 2024-06-17 15:21 ` Diogo Ivo
  2024-06-18 16:22   ` Simon Horman
  2024-06-17 15:21 ` [PATCH net-next v4 2/5] net: ti: icss-iep: Remove spinlock-based synchronization Diogo Ivo
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Diogo Ivo @ 2024-06-17 15:21 UTC (permalink / raw)
  To: MD Danish Anwar, Roger Quadros, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Richard Cochran, Nishanth Menon,
	Vignesh Raghavendra, Tero Kristo, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jan Kiszka, Jacob Keller,
	Simon Horman
  Cc: linux-arm-kernel, netdev, linux-kernel, devicetree, Diogo Ivo,
	Wojciech Drewek

Enable PTP support for AM65x SR1.0 devices by registering with the IEP
infrastructure in order to expose a PTP clock to userspace.

Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>
Signed-off-by: Diogo Ivo <diogo.ivo@siemens.com>
---
 drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c | 51 +++++++++++++++++++++++-
 1 file changed, 50 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c b/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c
index 7b3304bbd7fc..fa98bdb11ece 100644
--- a/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c
+++ b/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c
@@ -1011,16 +1011,44 @@ static int prueth_probe(struct platform_device *pdev)
 	dev_dbg(dev, "sram: pa %llx va %p size %zx\n", prueth->msmcram.pa,
 		prueth->msmcram.va, prueth->msmcram.size);
 
+	prueth->iep0 = icss_iep_get_idx(np, 0);
+	if (IS_ERR(prueth->iep0)) {
+		ret = dev_err_probe(dev, PTR_ERR(prueth->iep0),
+				    "iep0 get failed\n");
+		goto free_pool;
+	}
+
+	prueth->iep1 = icss_iep_get_idx(np, 1);
+	if (IS_ERR(prueth->iep1)) {
+		ret = dev_err_probe(dev, PTR_ERR(prueth->iep1),
+				    "iep1 get failed\n");
+		goto put_iep0;
+	}
+
+	ret = icss_iep_init(prueth->iep0, NULL, NULL, 0);
+	if (ret) {
+		dev_err_probe(dev, ret, "failed to init iep0\n");
+		goto put_iep;
+	}
+
+	ret = icss_iep_init(prueth->iep1, NULL, NULL, 0);
+	if (ret) {
+		dev_err_probe(dev, ret, "failed to init iep1\n");
+		goto exit_iep0;
+	}
+
 	if (eth0_node) {
 		ret = prueth_netdev_init(prueth, eth0_node);
 		if (ret) {
 			dev_err_probe(dev, ret, "netdev init %s failed\n",
 				      eth0_node->name);
-			goto free_pool;
+			goto exit_iep;
 		}
 
 		if (of_find_property(eth0_node, "ti,half-duplex-capable", NULL))
 			prueth->emac[PRUETH_MAC0]->half_duplex = 1;
+
+		prueth->emac[PRUETH_MAC0]->iep = prueth->iep0;
 	}
 
 	if (eth1_node) {
@@ -1033,6 +1061,8 @@ static int prueth_probe(struct platform_device *pdev)
 
 		if (of_find_property(eth1_node, "ti,half-duplex-capable", NULL))
 			prueth->emac[PRUETH_MAC1]->half_duplex = 1;
+
+		prueth->emac[PRUETH_MAC1]->iep = prueth->iep1;
 	}
 
 	/* register the network devices */
@@ -1091,6 +1121,19 @@ static int prueth_probe(struct platform_device *pdev)
 		prueth_netdev_exit(prueth, eth_node);
 	}
 
+exit_iep:
+	icss_iep_exit(prueth->iep1);
+exit_iep0:
+	icss_iep_exit(prueth->iep0);
+
+put_iep:
+	icss_iep_put(prueth->iep1);
+
+put_iep0:
+	icss_iep_put(prueth->iep0);
+	prueth->iep0 = NULL;
+	prueth->iep1 = NULL;
+
 free_pool:
 	gen_pool_free(prueth->sram_pool,
 		      (unsigned long)prueth->msmcram.va, msmc_ram_size);
@@ -1138,6 +1181,12 @@ static void prueth_remove(struct platform_device *pdev)
 		prueth_netdev_exit(prueth, eth_node);
 	}
 
+	icss_iep_exit(prueth->iep1);
+	icss_iep_exit(prueth->iep0);
+
+	icss_iep_put(prueth->iep1);
+	icss_iep_put(prueth->iep0);
+
 	gen_pool_free(prueth->sram_pool,
 		      (unsigned long)prueth->msmcram.va,
 		      MSMC_RAM_SIZE_SR1);

-- 
2.45.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH net-next v4 2/5] net: ti: icss-iep: Remove spinlock-based synchronization
  2024-06-17 15:21 [PATCH net-next v4 0/5] Enable PTP timestamping/PPS for AM65x SR1.0 devices Diogo Ivo
  2024-06-17 15:21 ` [PATCH net-next v4 1/5] net: ti: icssg-prueth: Enable PTP timestamping support for " Diogo Ivo
@ 2024-06-17 15:21 ` Diogo Ivo
  2024-06-18 16:23   ` Simon Horman
  2024-06-17 15:21 ` [PATCH net-next v4 3/5] dt-bindings: net: Add IEP interrupt Diogo Ivo
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Diogo Ivo @ 2024-06-17 15:21 UTC (permalink / raw)
  To: MD Danish Anwar, Roger Quadros, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Richard Cochran, Nishanth Menon,
	Vignesh Raghavendra, Tero Kristo, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jan Kiszka, Jacob Keller,
	Simon Horman
  Cc: linux-arm-kernel, netdev, linux-kernel, devicetree, Diogo Ivo

As all sources of concurrency in hardware register access occur in
non-interrupt context eliminate spinlock-based synchronization and
rely on the mutex-based synchronization that is already present.

Signed-off-by: Diogo Ivo <diogo.ivo@siemens.com>
---
 drivers/net/ethernet/ti/icssg/icss_iep.c | 14 --------------
 1 file changed, 14 deletions(-)

diff --git a/drivers/net/ethernet/ti/icssg/icss_iep.c b/drivers/net/ethernet/ti/icssg/icss_iep.c
index 3025e9c18970..d52e42fa64f2 100644
--- a/drivers/net/ethernet/ti/icssg/icss_iep.c
+++ b/drivers/net/ethernet/ti/icssg/icss_iep.c
@@ -110,7 +110,6 @@ struct icss_iep {
 	struct ptp_clock_info ptp_info;
 	struct ptp_clock *ptp_clock;
 	struct mutex ptp_clk_mutex;	/* PHC access serializer */
-	spinlock_t irq_lock; /* CMP IRQ vs icss_iep_ptp_enable access */
 	u32 def_inc;
 	s16 slow_cmp_inc;
 	u32 slow_cmp_count;
@@ -192,14 +191,11 @@ static void icss_iep_update_to_next_boundary(struct icss_iep *iep, u64 start_ns)
  */
 static void icss_iep_settime(struct icss_iep *iep, u64 ns)
 {
-	unsigned long flags;
-
 	if (iep->ops && iep->ops->settime) {
 		iep->ops->settime(iep->clockops_data, ns);
 		return;
 	}
 
-	spin_lock_irqsave(&iep->irq_lock, flags);
 	if (iep->pps_enabled || iep->perout_enabled)
 		writel(0, iep->base + iep->plat_data->reg_offs[ICSS_IEP_SYNC_CTRL_REG]);
 
@@ -210,7 +206,6 @@ static void icss_iep_settime(struct icss_iep *iep, u64 ns)
 		writel(IEP_SYNC_CTRL_SYNC_N_EN(0) | IEP_SYNC_CTRL_SYNC_EN,
 		       iep->base + iep->plat_data->reg_offs[ICSS_IEP_SYNC_CTRL_REG]);
 	}
-	spin_unlock_irqrestore(&iep->irq_lock, flags);
 }
 
 /**
@@ -546,7 +541,6 @@ static int icss_iep_perout_enable_hw(struct icss_iep *iep,
 static int icss_iep_perout_enable(struct icss_iep *iep,
 				  struct ptp_perout_request *req, int on)
 {
-	unsigned long flags;
 	int ret = 0;
 
 	mutex_lock(&iep->ptp_clk_mutex);
@@ -559,11 +553,9 @@ static int icss_iep_perout_enable(struct icss_iep *iep,
 	if (iep->perout_enabled == !!on)
 		goto exit;
 
-	spin_lock_irqsave(&iep->irq_lock, flags);
 	ret = icss_iep_perout_enable_hw(iep, req, on);
 	if (!ret)
 		iep->perout_enabled = !!on;
-	spin_unlock_irqrestore(&iep->irq_lock, flags);
 
 exit:
 	mutex_unlock(&iep->ptp_clk_mutex);
@@ -575,7 +567,6 @@ static int icss_iep_pps_enable(struct icss_iep *iep, int on)
 {
 	struct ptp_clock_request rq;
 	struct timespec64 ts;
-	unsigned long flags;
 	int ret = 0;
 	u64 ns;
 
@@ -589,8 +580,6 @@ static int icss_iep_pps_enable(struct icss_iep *iep, int on)
 	if (iep->pps_enabled == !!on)
 		goto exit;
 
-	spin_lock_irqsave(&iep->irq_lock, flags);
-
 	rq.perout.index = 0;
 	if (on) {
 		ns = icss_iep_gettime(iep, NULL);
@@ -607,8 +596,6 @@ static int icss_iep_pps_enable(struct icss_iep *iep, int on)
 	if (!ret)
 		iep->pps_enabled = !!on;
 
-	spin_unlock_irqrestore(&iep->irq_lock, flags);
-
 exit:
 	mutex_unlock(&iep->ptp_clk_mutex);
 
@@ -853,7 +840,6 @@ static int icss_iep_probe(struct platform_device *pdev)
 
 	iep->ptp_info = icss_iep_ptp_info;
 	mutex_init(&iep->ptp_clk_mutex);
-	spin_lock_init(&iep->irq_lock);
 	dev_set_drvdata(dev, iep);
 	icss_iep_disable(iep);
 

-- 
2.45.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH net-next v4 3/5] dt-bindings: net: Add IEP interrupt
  2024-06-17 15:21 [PATCH net-next v4 0/5] Enable PTP timestamping/PPS for AM65x SR1.0 devices Diogo Ivo
  2024-06-17 15:21 ` [PATCH net-next v4 1/5] net: ti: icssg-prueth: Enable PTP timestamping support for " Diogo Ivo
  2024-06-17 15:21 ` [PATCH net-next v4 2/5] net: ti: icss-iep: Remove spinlock-based synchronization Diogo Ivo
@ 2024-06-17 15:21 ` Diogo Ivo
  2024-06-17 15:35   ` Conor Dooley
  2024-06-17 15:21 ` [PATCH net-next v4 4/5] net: ti: icss-iep: Enable compare events Diogo Ivo
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Diogo Ivo @ 2024-06-17 15:21 UTC (permalink / raw)
  To: MD Danish Anwar, Roger Quadros, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Richard Cochran, Nishanth Menon,
	Vignesh Raghavendra, Tero Kristo, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jan Kiszka, Jacob Keller,
	Simon Horman
  Cc: linux-arm-kernel, netdev, linux-kernel, devicetree, Diogo Ivo

The IEP interrupt is used in order to support both capture events, where
an incoming external signal gets timestamped on arrival, and compare
events, where an interrupt is generated internally when the IEP counter
reaches a programmed value.

Signed-off-by: Diogo Ivo <diogo.ivo@siemens.com>
---
 Documentation/devicetree/bindings/net/ti,icss-iep.yaml | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/ti,icss-iep.yaml b/Documentation/devicetree/bindings/net/ti,icss-iep.yaml
index f5c22d6dcaee..e36e3a622904 100644
--- a/Documentation/devicetree/bindings/net/ti,icss-iep.yaml
+++ b/Documentation/devicetree/bindings/net/ti,icss-iep.yaml
@@ -28,6 +28,15 @@ properties:
     maxItems: 1
     description: phandle to the IEP source clock
 
+  interrupts:
+    maxItems: 1
+    description:
+      Interrupt specifier for capture/compare IRQ.
+
+  interrupt-names:
+    items:
+      - const: iep_cap_cmp
+
 required:
   - compatible
   - reg

-- 
2.45.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH net-next v4 4/5] net: ti: icss-iep: Enable compare events
  2024-06-17 15:21 [PATCH net-next v4 0/5] Enable PTP timestamping/PPS for AM65x SR1.0 devices Diogo Ivo
                   ` (2 preceding siblings ...)
  2024-06-17 15:21 ` [PATCH net-next v4 3/5] dt-bindings: net: Add IEP interrupt Diogo Ivo
@ 2024-06-17 15:21 ` Diogo Ivo
  2024-06-18 16:23   ` Simon Horman
  2024-06-17 15:21 ` [PATCH net-next v4 5/5] arm64: dts: ti: iot2050: Add IEP interrupts for SR1.0 devices Diogo Ivo
  2024-06-19 10:00 ` [PATCH net-next v4 0/5] Enable PTP timestamping/PPS for AM65x " patchwork-bot+netdevbpf
  5 siblings, 1 reply; 12+ messages in thread
From: Diogo Ivo @ 2024-06-17 15:21 UTC (permalink / raw)
  To: MD Danish Anwar, Roger Quadros, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Richard Cochran, Nishanth Menon,
	Vignesh Raghavendra, Tero Kristo, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jan Kiszka, Jacob Keller,
	Simon Horman
  Cc: linux-arm-kernel, netdev, linux-kernel, devicetree, Diogo Ivo,
	Wojciech Drewek

The IEP module supports compare events, in which a value is written to a
hardware register and when the IEP counter reaches the written value an
interrupt is generated. Add handling for this interrupt in order to
support PPS events.

Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Diogo Ivo <diogo.ivo@siemens.com>
---
 drivers/net/ethernet/ti/icssg/icss_iep.c | 74 ++++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)

diff --git a/drivers/net/ethernet/ti/icssg/icss_iep.c b/drivers/net/ethernet/ti/icssg/icss_iep.c
index d52e42fa64f2..003668dee738 100644
--- a/drivers/net/ethernet/ti/icssg/icss_iep.c
+++ b/drivers/net/ethernet/ti/icssg/icss_iep.c
@@ -17,6 +17,7 @@
 #include <linux/timekeeping.h>
 #include <linux/interrupt.h>
 #include <linux/of_irq.h>
+#include <linux/workqueue.h>
 
 #include "icss_iep.h"
 
@@ -121,6 +122,7 @@ struct icss_iep {
 	int cap_cmp_irq;
 	u64 period;
 	u32 latch_enable;
+	struct work_struct work;
 };
 
 /**
@@ -563,6 +565,57 @@ static int icss_iep_perout_enable(struct icss_iep *iep,
 	return ret;
 }
 
+static void icss_iep_cap_cmp_work(struct work_struct *work)
+{
+	struct icss_iep *iep = container_of(work, struct icss_iep, work);
+	const u32 *reg_offs = iep->plat_data->reg_offs;
+	struct ptp_clock_event pevent;
+	unsigned int val;
+	u64 ns, ns_next;
+
+	mutex_lock(&iep->ptp_clk_mutex);
+
+	ns = readl(iep->base + reg_offs[ICSS_IEP_CMP1_REG0]);
+	if (iep->plat_data->flags & ICSS_IEP_64BIT_COUNTER_SUPPORT) {
+		val = readl(iep->base + reg_offs[ICSS_IEP_CMP1_REG1]);
+		ns |= (u64)val << 32;
+	}
+	/* set next event */
+	ns_next = ns + iep->period;
+	writel(lower_32_bits(ns_next),
+	       iep->base + reg_offs[ICSS_IEP_CMP1_REG0]);
+	if (iep->plat_data->flags & ICSS_IEP_64BIT_COUNTER_SUPPORT)
+		writel(upper_32_bits(ns_next),
+		       iep->base + reg_offs[ICSS_IEP_CMP1_REG1]);
+
+	pevent.pps_times.ts_real = ns_to_timespec64(ns);
+	pevent.type = PTP_CLOCK_PPSUSR;
+	pevent.index = 0;
+	ptp_clock_event(iep->ptp_clock, &pevent);
+	dev_dbg(iep->dev, "IEP:pps ts: %llu next:%llu:\n", ns, ns_next);
+
+	mutex_unlock(&iep->ptp_clk_mutex);
+}
+
+static irqreturn_t icss_iep_cap_cmp_irq(int irq, void *dev_id)
+{
+	struct icss_iep *iep = (struct icss_iep *)dev_id;
+	const u32 *reg_offs = iep->plat_data->reg_offs;
+	unsigned int val;
+
+	val = readl(iep->base + reg_offs[ICSS_IEP_CMP_STAT_REG]);
+	/* The driver only enables CMP1 */
+	if (val & BIT(1)) {
+		/* Clear the event */
+		writel(BIT(1), iep->base + reg_offs[ICSS_IEP_CMP_STAT_REG]);
+		if (iep->pps_enabled || iep->perout_enabled)
+			schedule_work(&iep->work);
+		return IRQ_HANDLED;
+	}
+
+	return IRQ_NONE;
+}
+
 static int icss_iep_pps_enable(struct icss_iep *iep, int on)
 {
 	struct ptp_clock_request rq;
@@ -591,6 +644,8 @@ static int icss_iep_pps_enable(struct icss_iep *iep, int on)
 		ret = icss_iep_perout_enable_hw(iep, &rq.perout, on);
 	} else {
 		ret = icss_iep_perout_enable_hw(iep, &rq.perout, on);
+		if (iep->cap_cmp_irq)
+			cancel_work_sync(&iep->work);
 	}
 
 	if (!ret)
@@ -764,6 +819,8 @@ int icss_iep_init(struct icss_iep *iep, const struct icss_iep_clockops *clkops,
 	if (iep->ops && iep->ops->perout_enable) {
 		iep->ptp_info.n_per_out = 1;
 		iep->ptp_info.pps = 1;
+	} else if (iep->cap_cmp_irq) {
+		iep->ptp_info.pps = 1;
 	}
 
 	if (iep->ops && iep->ops->extts_enable)
@@ -804,6 +861,7 @@ static int icss_iep_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct icss_iep *iep;
 	struct clk *iep_clk;
+	int ret, irq;
 
 	iep = devm_kzalloc(dev, sizeof(*iep), GFP_KERNEL);
 	if (!iep)
@@ -814,6 +872,22 @@ static int icss_iep_probe(struct platform_device *pdev)
 	if (IS_ERR(iep->base))
 		return -ENODEV;
 
+	irq = platform_get_irq_byname_optional(pdev, "iep_cap_cmp");
+	if (irq == -EPROBE_DEFER)
+		return irq;
+
+	if (irq > 0) {
+		ret = devm_request_irq(dev, irq, icss_iep_cap_cmp_irq,
+				       IRQF_TRIGGER_HIGH, "iep_cap_cmp", iep);
+		if (ret) {
+			dev_info(iep->dev, "cap_cmp irq request failed: %x\n",
+				 ret);
+		} else {
+			iep->cap_cmp_irq = irq;
+			INIT_WORK(&iep->work, icss_iep_cap_cmp_work);
+		}
+	}
+
 	iep_clk = devm_clk_get(dev, NULL);
 	if (IS_ERR(iep_clk))
 		return PTR_ERR(iep_clk);

-- 
2.45.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH net-next v4 5/5] arm64: dts: ti: iot2050: Add IEP interrupts for SR1.0 devices
  2024-06-17 15:21 [PATCH net-next v4 0/5] Enable PTP timestamping/PPS for AM65x SR1.0 devices Diogo Ivo
                   ` (3 preceding siblings ...)
  2024-06-17 15:21 ` [PATCH net-next v4 4/5] net: ti: icss-iep: Enable compare events Diogo Ivo
@ 2024-06-17 15:21 ` Diogo Ivo
  2024-06-27 13:19   ` Anwar, Md Danish
  2024-06-19 10:00 ` [PATCH net-next v4 0/5] Enable PTP timestamping/PPS for AM65x " patchwork-bot+netdevbpf
  5 siblings, 1 reply; 12+ messages in thread
From: Diogo Ivo @ 2024-06-17 15:21 UTC (permalink / raw)
  To: MD Danish Anwar, Roger Quadros, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Richard Cochran, Nishanth Menon,
	Vignesh Raghavendra, Tero Kristo, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jan Kiszka, Jacob Keller,
	Simon Horman
  Cc: linux-arm-kernel, netdev, linux-kernel, devicetree, Diogo Ivo

Add the interrupts needed for PTP Hardware Clock support via IEP
in SR1.0 devices.

Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Diogo Ivo <diogo.ivo@siemens.com>
---
 arch/arm64/boot/dts/ti/k3-am65-iot2050-common-pg1.dtsi | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-am65-iot2050-common-pg1.dtsi b/arch/arm64/boot/dts/ti/k3-am65-iot2050-common-pg1.dtsi
index ef7897763ef8..0a29ed172215 100644
--- a/arch/arm64/boot/dts/ti/k3-am65-iot2050-common-pg1.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-am65-iot2050-common-pg1.dtsi
@@ -73,3 +73,15 @@ &icssg0_eth {
 		    "rx0", "rx1",
 		    "rxmgm0", "rxmgm1";
 };
+
+&icssg0_iep0 {
+	interrupt-parent = <&icssg0_intc>;
+	interrupts = <7 7 7>;
+	interrupt-names = "iep_cap_cmp";
+};
+
+&icssg0_iep1 {
+	interrupt-parent = <&icssg0_intc>;
+	interrupts = <56 8 8>;
+	interrupt-names = "iep_cap_cmp";
+};

-- 
2.45.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH net-next v4 3/5] dt-bindings: net: Add IEP interrupt
  2024-06-17 15:21 ` [PATCH net-next v4 3/5] dt-bindings: net: Add IEP interrupt Diogo Ivo
@ 2024-06-17 15:35   ` Conor Dooley
  0 siblings, 0 replies; 12+ messages in thread
From: Conor Dooley @ 2024-06-17 15:35 UTC (permalink / raw)
  To: Diogo Ivo
  Cc: MD Danish Anwar, Roger Quadros, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Richard Cochran, Nishanth Menon,
	Vignesh Raghavendra, Tero Kristo, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jan Kiszka, Jacob Keller,
	Simon Horman, linux-arm-kernel, netdev, linux-kernel, devicetree

[-- Attachment #1: Type: text/plain, Size: 425 bytes --]

On Mon, Jun 17, 2024 at 04:21:42PM +0100, Diogo Ivo wrote:
> The IEP interrupt is used in order to support both capture events, where
> an incoming external signal gets timestamped on arrival, and compare
> events, where an interrupt is generated internally when the IEP counter
> reaches a programmed value.
> 
> Signed-off-by: Diogo Ivo <diogo.ivo@siemens.com>

Acked-by: Conor Dooley <conor.dooley@microchip.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH net-next v4 1/5] net: ti: icssg-prueth: Enable PTP timestamping support for SR1.0 devices
  2024-06-17 15:21 ` [PATCH net-next v4 1/5] net: ti: icssg-prueth: Enable PTP timestamping support for " Diogo Ivo
@ 2024-06-18 16:22   ` Simon Horman
  0 siblings, 0 replies; 12+ messages in thread
From: Simon Horman @ 2024-06-18 16:22 UTC (permalink / raw)
  To: Diogo Ivo
  Cc: MD Danish Anwar, Roger Quadros, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Richard Cochran, Nishanth Menon,
	Vignesh Raghavendra, Tero Kristo, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jan Kiszka, Jacob Keller,
	linux-arm-kernel, netdev, linux-kernel, devicetree,
	Wojciech Drewek

On Mon, Jun 17, 2024 at 04:21:40PM +0100, Diogo Ivo wrote:
> Enable PTP support for AM65x SR1.0 devices by registering with the IEP
> infrastructure in order to expose a PTP clock to userspace.
> 
> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
> Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>
> Signed-off-by: Diogo Ivo <diogo.ivo@siemens.com>

Reviewed-by: Simon Horman <horms@kernel.org>


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH net-next v4 2/5] net: ti: icss-iep: Remove spinlock-based synchronization
  2024-06-17 15:21 ` [PATCH net-next v4 2/5] net: ti: icss-iep: Remove spinlock-based synchronization Diogo Ivo
@ 2024-06-18 16:23   ` Simon Horman
  0 siblings, 0 replies; 12+ messages in thread
From: Simon Horman @ 2024-06-18 16:23 UTC (permalink / raw)
  To: Diogo Ivo
  Cc: MD Danish Anwar, Roger Quadros, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Richard Cochran, Nishanth Menon,
	Vignesh Raghavendra, Tero Kristo, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jan Kiszka, Jacob Keller,
	linux-arm-kernel, netdev, linux-kernel, devicetree

On Mon, Jun 17, 2024 at 04:21:41PM +0100, Diogo Ivo wrote:
> As all sources of concurrency in hardware register access occur in
> non-interrupt context eliminate spinlock-based synchronization and
> rely on the mutex-based synchronization that is already present.
> 
> Signed-off-by: Diogo Ivo <diogo.ivo@siemens.com>

Reviewed-by: Simon Horman <horms@kernel.org>


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH net-next v4 4/5] net: ti: icss-iep: Enable compare events
  2024-06-17 15:21 ` [PATCH net-next v4 4/5] net: ti: icss-iep: Enable compare events Diogo Ivo
@ 2024-06-18 16:23   ` Simon Horman
  0 siblings, 0 replies; 12+ messages in thread
From: Simon Horman @ 2024-06-18 16:23 UTC (permalink / raw)
  To: Diogo Ivo
  Cc: MD Danish Anwar, Roger Quadros, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Richard Cochran, Nishanth Menon,
	Vignesh Raghavendra, Tero Kristo, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jan Kiszka, Jacob Keller,
	linux-arm-kernel, netdev, linux-kernel, devicetree,
	Wojciech Drewek

On Mon, Jun 17, 2024 at 04:21:43PM +0100, Diogo Ivo wrote:
> The IEP module supports compare events, in which a value is written to a
> hardware register and when the IEP counter reaches the written value an
> interrupt is generated. Add handling for this interrupt in order to
> support PPS events.
> 
> Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>
> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
> Signed-off-by: Diogo Ivo <diogo.ivo@siemens.com>

Reviewed-by: Simon Horman <horms@kernel.org>


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH net-next v4 0/5] Enable PTP timestamping/PPS for AM65x SR1.0 devices
  2024-06-17 15:21 [PATCH net-next v4 0/5] Enable PTP timestamping/PPS for AM65x SR1.0 devices Diogo Ivo
                   ` (4 preceding siblings ...)
  2024-06-17 15:21 ` [PATCH net-next v4 5/5] arm64: dts: ti: iot2050: Add IEP interrupts for SR1.0 devices Diogo Ivo
@ 2024-06-19 10:00 ` patchwork-bot+netdevbpf
  5 siblings, 0 replies; 12+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-06-19 10:00 UTC (permalink / raw)
  To: Diogo Ivo
  Cc: danishanwar, rogerq, davem, edumazet, kuba, pabeni,
	richardcochran, nm, vigneshr, kristo, robh, krzk+dt, conor+dt,
	jan.kiszka, jacob.e.keller, horms, linux-arm-kernel, netdev,
	linux-kernel, devicetree, wojciech.drewek

Hello:

This series was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:

On Mon, 17 Jun 2024 16:21:39 +0100 you wrote:
> This patch series enables support for PTP in AM65x SR1.0 devices.
> 
> This feature relies heavily on the Industrial Ethernet Peripheral
> (IEP) hardware module, which implements a hardware counter through
> which time is kept. This hardware block is the basis for exposing
> a PTP hardware clock to userspace and for issuing timestamps for
> incoming/outgoing packets, allowing for time synchronization.
> 
> [...]

Here is the summary with links:
  - [net-next,v4,1/5] net: ti: icssg-prueth: Enable PTP timestamping support for SR1.0 devices
    https://git.kernel.org/netdev/net-next/c/5e1e43893be2
  - [net-next,v4,2/5] net: ti: icss-iep: Remove spinlock-based synchronization
    https://git.kernel.org/netdev/net-next/c/5758e03cf604
  - [net-next,v4,3/5] dt-bindings: net: Add IEP interrupt
    https://git.kernel.org/netdev/net-next/c/5056860cf8ea
  - [net-next,v4,4/5] net: ti: icss-iep: Enable compare events
    https://git.kernel.org/netdev/net-next/c/f18ad402cd8b
  - [net-next,v4,5/5] arm64: dts: ti: iot2050: Add IEP interrupts for SR1.0 devices
    https://git.kernel.org/netdev/net-next/c/71be1189c92b

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH net-next v4 5/5] arm64: dts: ti: iot2050: Add IEP interrupts for SR1.0 devices
  2024-06-17 15:21 ` [PATCH net-next v4 5/5] arm64: dts: ti: iot2050: Add IEP interrupts for SR1.0 devices Diogo Ivo
@ 2024-06-27 13:19   ` Anwar, Md Danish
  0 siblings, 0 replies; 12+ messages in thread
From: Anwar, Md Danish @ 2024-06-27 13:19 UTC (permalink / raw)
  To: Diogo Ivo, MD Danish Anwar, Roger Quadros, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Richard Cochran,
	Nishanth Menon, Vignesh Raghavendra, Tero Kristo, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jan Kiszka, Jacob Keller,
	Simon Horman
  Cc: linux-arm-kernel, netdev, linux-kernel, devicetree



On 6/17/2024 8:51 PM, Diogo Ivo wrote:
> Add the interrupts needed for PTP Hardware Clock support via IEP
> in SR1.0 devices.
> 
> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
> Signed-off-by: Diogo Ivo <diogo.ivo@siemens.com>
> ---
>  arch/arm64/boot/dts/ti/k3-am65-iot2050-common-pg1.dtsi | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/arch/arm64/boot/dts/ti/k3-am65-iot2050-common-pg1.dtsi b/arch/arm64/boot/dts/ti/k3-am65-iot2050-common-pg1.dtsi
> index ef7897763ef8..0a29ed172215 100644
> --- a/arch/arm64/boot/dts/ti/k3-am65-iot2050-common-pg1.dtsi
> +++ b/arch/arm64/boot/dts/ti/k3-am65-iot2050-common-pg1.dtsi
> @@ -73,3 +73,15 @@ &icssg0_eth {
>  		    "rx0", "rx1",
>  		    "rxmgm0", "rxmgm1";
>  };
> +
> +&icssg0_iep0 {
> +	interrupt-parent = <&icssg0_intc>;
> +	interrupts = <7 7 7>;
> +	interrupt-names = "iep_cap_cmp";
> +};
> +
> +&icssg0_iep1 {
> +	interrupt-parent = <&icssg0_intc>;
> +	interrupts = <56 8 8>;
> +	interrupt-names = "iep_cap_cmp";
> +};
> 

Reviewed-by: MD Danish Anwar <danishanwar@ti.com>

-- 
Thanks and Regards,
Md Danish Anwar

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2024-06-27 13:20 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-17 15:21 [PATCH net-next v4 0/5] Enable PTP timestamping/PPS for AM65x SR1.0 devices Diogo Ivo
2024-06-17 15:21 ` [PATCH net-next v4 1/5] net: ti: icssg-prueth: Enable PTP timestamping support for " Diogo Ivo
2024-06-18 16:22   ` Simon Horman
2024-06-17 15:21 ` [PATCH net-next v4 2/5] net: ti: icss-iep: Remove spinlock-based synchronization Diogo Ivo
2024-06-18 16:23   ` Simon Horman
2024-06-17 15:21 ` [PATCH net-next v4 3/5] dt-bindings: net: Add IEP interrupt Diogo Ivo
2024-06-17 15:35   ` Conor Dooley
2024-06-17 15:21 ` [PATCH net-next v4 4/5] net: ti: icss-iep: Enable compare events Diogo Ivo
2024-06-18 16:23   ` Simon Horman
2024-06-17 15:21 ` [PATCH net-next v4 5/5] arm64: dts: ti: iot2050: Add IEP interrupts for SR1.0 devices Diogo Ivo
2024-06-27 13:19   ` Anwar, Md Danish
2024-06-19 10:00 ` [PATCH net-next v4 0/5] Enable PTP timestamping/PPS for AM65x " patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).