Skip to contentSkip to conversation

MABC RTNet driver to work with GEM hardware

PATCH In review François Legal 2 participants 2 messages Oct 2, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MABC RTNet driver to work with GEM hardware

From: François LEGAL <[email protected]>

Make MACB driver compliant with GEM hardware (as mainline linux driver does). Main fix is about interrupt flag that is never cleared (write 1 to clear)

Subject: [PATCH] Make MACB driver compliant with GEM hardware

---
 kernel/drivers/net/drivers/Kconfig  |  7 +++++++
 kernel/drivers/net/drivers/Makefile |  1 +
 kernel/drivers/net/drivers/macb.c   | 23 ++++++++++++++++++++---
 3 files changed, 28 insertions(+), 3 deletions(-)
kernel/drivers/net/drivers/Kconfig +7 -0
index 65f0855..39c976f 100644
@@ -131,6 +131,13 @@ config XENO_DRIVERS_NET_DRV_MACB
     Driver for internal MAC-controller on AT91SAM926x microcontrollers.
     Porting by Cristiano Mantovani and Stefano Banzi (Marposs SpA).
 
+config XENO_DRIVERS_NET_DRV_GEM
+    depends on XENO_DRIVERS_NET
+    tristate "GEM devices"
+    ---help---
+    Driver for internal MAC-controller on Zynq 7000 SoCs.
+    Porting by Cristiano Mantovani and Stefano Banzi (Marposs SpA).
+
 endif
 
 source "drivers/xenomai/net/drivers/experimental/Kconfig"
kernel/drivers/net/drivers/Makefile +1 -0
index d95c5a8..9da1a56 100644
@@ -57,6 +57,7 @@ obj-$(CONFIG_XENO_DRIVERS_NET_DRV_SMC91111) += rt_smc91111.o
 rt_smc91111-y := smc91111.o
 
 obj-$(CONFIG_XENO_DRIVERS_NET_DRV_MACB) += rt_macb.o
+obj-$(CONFIG_XENO_DRIVERS_NET_DRV_GEM) += rt_macb.o
 
 rt_macb-y := macb.o
 
kernel/drivers/net/drivers/macb.c +20 -3
index fc5b667..ccda6ae 100644
@@ -679,7 +679,13 @@ static int gem_rx(struct macb *bp, int budget, nanosecs_abs_t *time_stamp)
 	unsigned int		entry;
 	struct rtskb		*skb;
 	struct macb_dma_desc	*desc;
-	int			count = 0;
+	int			count = 0, status;
+
+	status = macb_readl(bp, RSR);
+	macb_writel(bp, RSR, status);
+
+	if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE)
+		macb_writel(bp, ISR, MACB_BIT(RCOMP));
 
 	while (count < budget) {
 		u32 addr, ctrl;
@@ -877,7 +883,7 @@ static int macb_interrupt(rtdm_irq_t *irq_handle)
 	struct rtnet_device *dev = dev_id;
 	struct macb *bp = rtnetdev_priv(dev);
 	unsigned received = 0;
-	u32 status;
+	u32 status, ctrl;
 
 	status = macb_readl(bp, ISR);
 
@@ -895,9 +901,10 @@ static int macb_interrupt(rtdm_irq_t *irq_handle)
 
 		rtdev_vdbg(bp->dev, "isr = 0x%08lx\n", (unsigned long)status);
 
-		if (status & MACB_RX_INT_FLAGS)
+		if (status & MACB_BIT(RCOMP)) {
 			received += bp->macbgem_ops.mog_rx(bp, 100 - received,
 							&time_stamp);
+		}
 
 		if (unlikely(status & (MACB_TX_ERR_FLAGS))) {
 			macb_writel(bp, IDR, MACB_TX_INT_FLAGS);
@@ -917,6 +924,15 @@ static int macb_interrupt(rtdm_irq_t *irq_handle)
 		 * add that if/when we get our hands on a full-blown MII PHY.
 		 */
 
+		if (status & MACB_BIT(RXUBR)) {
+			ctrl = macb_readl(bp, NCR);
+			macb_writel(bp, NCR, ctrl & ~MACB_BIT(RE));
+			macb_writel(bp, NCR, ctrl | MACB_BIT(RE));
+
+			if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE)
+				macb_writel(bp, ISR, MACB_BIT(RXUBR));
+		}
+
 		if (status & MACB_BIT(ISR_ROVR)) {
 			/* We missed at least one packet */
 			if (macb_is_gem(bp))
@@ -1320,6 +1336,7 @@ static void macb_configure_caps(struct macb *bp)
 		if (GEM_BFEXT(IRQCOR, gem_readl(bp, DCFG1)) == 0)
 			bp->caps |= MACB_CAPS_ISR_CLEAR_ON_WRITE;
 	}
+	rtdev_vdbg(bp->dev, "Capabilities : %X\n", bp->caps);
 }
 
 static void macb_init_hw(struct macb *bp)

--
2.1.4

#1 lore raw
Quoted 9 lines · François Legal via Xenomai

From: François LEGAL <[email protected]>

Make MACB driver compliant with GEM hardware (as mainline linux driver does). Main fix is about interrupt flag that is never cleared (write 1 to clear)

Subject: [PATCH] Make MACB driver compliant with GEM hardware

Hmm, two subject lines - which one should I use? Would be better get the first one right already ;).

Quoted 30 lines
---
  kernel/drivers/net/drivers/Kconfig  |  7 +++++++
  kernel/drivers/net/drivers/Makefile |  1 +
  kernel/drivers/net/drivers/macb.c   | 23 ++++++++++++++++++++---
  3 files changed, 28 insertions(+), 3 deletions(-)
kernel/drivers/net/drivers/Kconfig +7 -0
index 65f0855..39c976f 100644
@@ -131,6 +131,13 @@ config XENO_DRIVERS_NET_DRV_MACB
      Driver for internal MAC-controller on AT91SAM926x microcontrollers.
      Porting by Cristiano Mantovani and Stefano Banzi (Marposs SpA).
 
+config XENO_DRIVERS_NET_DRV_GEM
+    depends on XENO_DRIVERS_NET
+    tristate "GEM devices"
+    ---help---
+    Driver for internal MAC-controller on Zynq 7000 SoCs.
+    Porting by Cristiano Mantovani and Stefano Banzi (Marposs SpA).
+
  endif
 
  source "drivers/xenomai/net/drivers/experimental/Kconfig"
kernel/drivers/net/drivers/Makefile +0 -0
index d95c5a8..9da1a56 100644

kernel/drivers/net/drivers/Makefile obj-$(CONFIG_XENO_DRIVERS_NET_DRV_SMC91111) += rt_smc91111.o · line 60

Quoted 4 lines
kernel/drivers/net/drivers/Makefile +1 -0
@@ -57,6 +57,7 @@ obj-$(CONFIG_XENO_DRIVERS_NET_DRV_SMC91111) += rt_smc91111.o
  rt_smc91111-y := smc91111.o
 
  obj-$(CONFIG_XENO_DRIVERS_NET_DRV_MACB) += rt_macb.o
+obj-$(CONFIG_XENO_DRIVERS_NET_DRV_GEM) += rt_macb.o

Only saw this now: What's the idea behind adding XENO_DRIVERS_NET_DRV_GEM when there is XENO_DRIVERS_NET_DRV_MACB already? If a selects both, the build will fail.

Quoted 61 lines
kernel/drivers/net/drivers/Makefile +0 -0
  rt_macb-y := macb.o
 
kernel/drivers/net/drivers/macb.c +19 -3
index fc5b667..ccda6ae 100644
@@ -679,7 +679,13 @@ static int gem_rx(struct macb *bp, int budget, nanosecs_abs_t *time_stamp)
  	unsigned int		entry;
  	struct rtskb		*skb;
  	struct macb_dma_desc	*desc;
-	int			count = 0;
+	int			count = 0, status;
+
+	status = macb_readl(bp, RSR);
+	macb_writel(bp, RSR, status);
+
+	if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE)
+		macb_writel(bp, ISR, MACB_BIT(RCOMP));
 
  	while (count < budget) {
  		u32 addr, ctrl;
@@ -877,7 +883,7 @@ static int macb_interrupt(rtdm_irq_t *irq_handle)
  	struct rtnet_device *dev = dev_id;
  	struct macb *bp = rtnetdev_priv(dev);
  	unsigned received = 0;
-	u32 status;
+	u32 status, ctrl;
 
  	status = macb_readl(bp, ISR);
 
@@ -895,9 +901,10 @@ static int macb_interrupt(rtdm_irq_t *irq_handle)
 
  		rtdev_vdbg(bp->dev, "isr = 0x%08lx\n", (unsigned long)status);
 
-		if (status & MACB_RX_INT_FLAGS)
+		if (status & MACB_BIT(RCOMP)) {
  			received += bp->macbgem_ops.mog_rx(bp, 100 - received,
  							&time_stamp);
+		}
 
  		if (unlikely(status & (MACB_TX_ERR_FLAGS))) {
  			macb_writel(bp, IDR, MACB_TX_INT_FLAGS);
@@ -917,6 +924,15 @@ static int macb_interrupt(rtdm_irq_t *irq_handle)
  		 * add that if/when we get our hands on a full-blown MII PHY.
  		 */
 
+		if (status & MACB_BIT(RXUBR)) {
+			ctrl = macb_readl(bp, NCR);
+			macb_writel(bp, NCR, ctrl & ~MACB_BIT(RE));
+			macb_writel(bp, NCR, ctrl | MACB_BIT(RE));
+
+			if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE)
+				macb_writel(bp, ISR, MACB_BIT(RXUBR));
+		}
+
  		if (status & MACB_BIT(ISR_ROVR)) {
  			/* We missed at least one packet */
  			if (macb_is_gem(bp))

kernel/drivers/net/drivers/macb.c static void macb_configure_caps(struct macb *bp) · line 1342

Quoted 7 lines
kernel/drivers/net/drivers/macb.c +1 -0
@@ -1320,6 +1336,7 @@ static void macb_configure_caps(struct macb *bp)
  		if (GEM_BFEXT(IRQCOR, gem_readl(bp, DCFG1)) == 0)
  			bp->caps |= MACB_CAPS_ISR_CLEAR_ON_WRITE;
  	}
+	rtdev_vdbg(bp->dev, "Capabilities : %X\n", bp->caps);
  }
 
  static void macb_init_hw(struct macb *bp)

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux