Skip to contentSkip to conversation

drivers: net: stmmac: add blackfin support

PATCH In review Bob Liu 4 participants 14 messages May 22, 2012 – May 28, 2012

Subsystems (4)
lore
Share & tools
lore

Bob Liu

author
#0 lore raw

PATCH 1/3 drivers: net: stmmac: add blackfin support

Blackfin arch use stmmac on its reference board bf609-ezkit, the stmmac ip version is 3.61a.

But the spec seems a little different, some register addr and define are not the same with current code.

This patch add the support for blackfin arch following the spec.

---
 drivers/net/ethernet/stmicro/stmmac/dwmac100.h     |   29 ++++++++++++++++++++
 .../net/ethernet/stmicro/stmmac/dwmac100_core.c    |    6 +++-
 drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c |    3 ++
 drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h    |    5 +++
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c  |    2 +
 5 files changed, 44 insertions(+), 1 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac100.h +29 -0
index 7c6d857..cc3ac4f 100644
@@ -29,6 +29,18 @@
  *	 			MAC BLOCK defines
  *---------------------------------------------------------------------------*/
 /* MAC CSR offset */
+#ifdef CONFIG_BLACKFIN
+#define MAC_CONTROL		0x00000000	/* MAC Control */
+#define MAC_FRAME_FILTER	0x0000004	/* Frame filter */
+#define MAC_HASH_HIGH		0x00000008	/* Multicast Hash Table High */
+#define MAC_HASH_LOW		0x0000000c	/* Multicast Hash Table Low */
+#define MAC_MII_ADDR		0x00000010	/* MII Address */
+#define MAC_MII_DATA		0x00000014	/* MII Data */
+#define MAC_FLOW_CTRL		0x00000018	/* Flow Control */
+#define MAC_VLAN1		0x0000001c	/* VLAN1 Tag */
+#define MAC_ADDR_HIGH		0x00000040	/* MAC Address High */
+#define MAC_ADDR_LOW		0x00000044	/* MAC Address Low */
+#else
 #define MAC_CONTROL	0x00000000	/* MAC Control */
 #define MAC_ADDR_HIGH	0x00000004	/* MAC Address High */
 #define MAC_ADDR_LOW	0x00000008	/* MAC Address Low */
@@ -39,6 +51,18 @@
 #define MAC_FLOW_CTRL	0x0000001c	/* Flow Control */
 #define MAC_VLAN1	0x00000020	/* VLAN1 Tag */
 #define MAC_VLAN2	0x00000024	/* VLAN2 Tag */
+#endif
+
+#ifdef CONFIG_BLACKFIN
+/* MAC_FRAME_FILTER defines */
+#define MAC_FRAME_FILTER_RA  0x80000000
+#define MAC_FRAME_FILTER_PR  0x00000001
+#define MAC_FRAME_FILTER_HMC 0x00000004
+#define MAC_FRAME_FILTER_PM  0x00000010
+
+#define MAC_FRAME_FILTER_INIT (MAC_FRAME_FILTER_RA | MAC_FRAME_FILTER_PR | \
+		MAC_FRAME_FILTER_HMC | MAC_FRAME_FILTER_PM)
+#endif
 
 /* MAC CTRL defines */
 #define MAC_CONTROL_RA	0x80000000	/* Receive All Mode */
@@ -54,6 +78,7 @@
 #define MAC_CONTROL_IF	0x00020000	/* Inverse Filtering */
 #define MAC_CONTROL_PB	0x00010000	/* Pass Bad Frames */
 #define MAC_CONTROL_HO	0x00008000	/* Hash Only Filtering Mode */
+#define MAC_CONTROL_FES	0x00004000	/* Speed in Fast Ethernet Mode */
 #define MAC_CONTROL_HP	0x00002000	/* Hash/Perfect Filtering Mode */
 #define MAC_CONTROL_LCC	0x00001000	/* Late Collision Control */
 #define MAC_CONTROL_DBF	0x00000800	/* Disable Broadcast Frames */
@@ -67,7 +92,11 @@
 #define MAC_CONTROL_TE		0x00000008	/* Transmitter Enable */
 #define MAC_CONTROL_RE		0x00000004	/* Receiver Enable */
 
+#ifdef CONFIG_BLACKFIN
+#define MAC_CORE_INIT (MAC_CONTROL_FES | MAC_CONTROL_DBF)
+#else
 #define MAC_CORE_INIT (MAC_CONTROL_HBD | MAC_CONTROL_ASTP)
+#endif
 
 /* MAC FLOW CTRL defines */
 #define MAC_FLOW_CTRL_PT_MASK	0xffff0000	/* Pause Time Mask */
drivers/net/ethernet/stmicro/stmmac/dwmac100_core.c +5 -1
index 138fb8d..1c49d96 100644
@@ -35,7 +35,9 @@
 static void dwmac100_core_init(void __iomem *ioaddr)
 {
 	u32 value = readl(ioaddr + MAC_CONTROL);
-
+#ifdef CONFIG_BLACKFIN
+	writel(MAC_FRAME_FILTER_INIT, ioaddr + MAC_FRAME_FILTER);
+#endif
 	writel((value | MAC_CORE_INIT), ioaddr + MAC_CONTROL);
 
 #ifdef STMMAC_VLAN_TAG_USED
@@ -68,8 +70,10 @@ static void dwmac100_dump_mac_regs(void __iomem *ioaddr)
 		MAC_FLOW_CTRL, readl(ioaddr + MAC_FLOW_CTRL));
 	pr_info("\tVLAN1 tag (offset 0x%x): 0x%08x\n", MAC_VLAN1,
 		readl(ioaddr + MAC_VLAN1));
+#ifndef CONFIG_BLACKFIN
 	pr_info("\tVLAN2 tag (offset 0x%x): 0x%08x\n", MAC_VLAN2,
 		readl(ioaddr + MAC_VLAN2));
+#endif
 }
 
 static void dwmac100_irq_status(void __iomem *ioaddr)
drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c +3 -0
index bc17fd0..d682a0b 100644
@@ -50,6 +50,9 @@ static int dwmac100_dma_init(void __iomem *ioaddr, int pbl, u32 dma_tx,
 	if (limit < 0)
 		return -EBUSY;
 
+#ifdef CONFIG_BLACKFIN
+	writel(DMA_AXI_BUS_BLEN4 | DMA_AXI_BUS_UNDEF, ioaddr + DMA_AXI_BUS);
+#endif
 	/* Enable Application Access by writing to DMA CSR0 */
 	writel(DMA_BUS_MODE_DEFAULT | (pbl << DMA_BUS_MODE_PBL_SHIFT),
 	       ioaddr + DMA_BUS_MODE);
drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h +5 -0
index 437edac..e75269a 100644
@@ -32,6 +32,7 @@
 #define DMA_CONTROL		0x00001018	/* Ctrl (Operational Mode) */
 #define DMA_INTR_ENA		0x0000101c	/* Interrupt Enable */
 #define DMA_MISSED_FRAME_CTR	0x00001020	/* Missed Frame Counter */
+#define DMA_AXI_BUS		0x00001028	/* Axi Bus */
 #define DMA_CUR_TX_BUF_ADDR	0x00001050	/* Current Host Tx Buffer */
 #define DMA_CUR_RX_BUF_ADDR	0x00001054	/* Current Host Rx Buffer */
 #define DMA_HW_FEATURE		0x00001058	/* HW Feature Register */
@@ -40,6 +41,10 @@
 #define DMA_CONTROL_ST		0x00002000	/* Start/Stop Transmission */
 #define DMA_CONTROL_SR		0x00000002	/* Start/Stop Receive */
 
+/* DMA Axi bus register defines */
+#define DMA_AXI_BUS_UNDEF	0x00000001
+#define DMA_AXI_BUS_BLEN4	0x00000002
+
 /* DMA Normal interrupt */
 #define DMA_INTR_ENA_NIE 0x00010000	/* Normal Summary */
 #define DMA_INTR_ENA_TIE 0x00000001	/* Transmit Interrupt */
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -0
index 48d56da..714faa2 100644
@@ -1279,8 +1279,10 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit)
 			frame_len = priv->hw->desc->get_rx_frame_len(p);
 			/* ACS is set; GMAC core strips PAD/FCS for IEEE 802.3
 			 * Type frames (LLC/LLC-SNAP) */
+#ifndef CONFIG_BLACKFIN
 			if (unlikely(status != llc_snap))
 				frame_len -= ETH_FCS_LEN;
+#endif
 #ifdef STMMAC_RX_DEBUG
 			if (frame_len > ETH_FRAME_LEN)
 				pr_debug("\tRX frame size %d, COE status: %d\n",
Signature · 1 line
1.7.0.4
author
#1 lore raw

PATCH 2/3 drivers: net: ethernet: stmmac: fix failure in module test

Module can't be compiled and installed in current Makefile.

---
 drivers/net/ethernet/stmicro/stmmac/Makefile |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/ethernet/stmicro/stmmac/Makefile +6 -6
index bc965ac..4b50922 100644
@@ -1,10 +1,10 @@
 obj-$(CONFIG_STMMAC_ETH) += stmmac.o
-stmmac-$(CONFIG_STMMAC_TIMER) += stmmac_timer.o
-stmmac-$(CONFIG_STMMAC_RING) += ring_mode.o
-stmmac-$(CONFIG_STMMAC_CHAINED) += chain_mode.o
-stmmac-$(CONFIG_STMMAC_PLATFORM) += stmmac_platform.o
-stmmac-$(CONFIG_STMMAC_PCI) += stmmac_pci.o
+stmmac-$(CONFIG_STMMAC_TIMER:m=y) += stmmac_timer.o
+stmmac-$(CONFIG_STMMAC_RING:m=y) += ring_mode.o
+stmmac-$(CONFIG_STMMAC_CHAINED:m=y) += chain_mode.o
+stmmac-$(CONFIG_STMMAC_PLATFORM:m=y) += stmmac_platform.o
+stmmac-$(CONFIG_STMMAC_PCI:m=y) += stmmac_pci.o
 stmmac-objs:= stmmac_main.o stmmac_ethtool.o stmmac_mdio.o	\
 	      dwmac_lib.o dwmac1000_core.o  dwmac1000_dma.o	\
 	      dwmac100_core.o dwmac100_dma.o enh_desc.o  norm_desc.o \
-	      mmc_core.o $(stmmac-y)
+	      mmc_core.o
Signature · 1 line
1.7.0.4
#2 lore raw

Re: [PATCH 2/3] drivers: net: ethernet: stmmac: fix failure in module test

Quoted 1 line · Bob Liu

Module can't be compiled and installed in current Makefile.

[...]

That's because CONFIG_STMMAC_PLATFORM and CONFIG_STMMAC_PCI are wrongly declared as tristate in Kconfig. Change them to bool and it should work again.

Ben.

Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#3 lore raw

Re: [PATCH 2/3] drivers: net: ethernet: stmmac: fix failure in module test

In reply to Bob Liu
Quoted 1 line · Bob Liu

Module can't be compiled and installed in current Makefile.

I've just seen that I can generate the stmmac.ko on ARM and also on x86 with my configuration.

Can you post here you build failure?

In the meantime I'll test the module on ARM soon.

peppe

Quoted 27 lines
---
 drivers/net/ethernet/stmicro/stmmac/Makefile |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/ethernet/stmicro/stmmac/Makefile +6 -6
index bc965ac..4b50922 100644
@@ -1,10 +1,10 @@
 obj-$(CONFIG_STMMAC_ETH) += stmmac.o
-stmmac-$(CONFIG_STMMAC_TIMER) += stmmac_timer.o
-stmmac-$(CONFIG_STMMAC_RING) += ring_mode.o
-stmmac-$(CONFIG_STMMAC_CHAINED) += chain_mode.o
-stmmac-$(CONFIG_STMMAC_PLATFORM) += stmmac_platform.o
-stmmac-$(CONFIG_STMMAC_PCI) += stmmac_pci.o
+stmmac-$(CONFIG_STMMAC_TIMER:m=y) += stmmac_timer.o
+stmmac-$(CONFIG_STMMAC_RING:m=y) += ring_mode.o
+stmmac-$(CONFIG_STMMAC_CHAINED:m=y) += chain_mode.o
+stmmac-$(CONFIG_STMMAC_PLATFORM:m=y) += stmmac_platform.o
+stmmac-$(CONFIG_STMMAC_PCI:m=y) += stmmac_pci.o
 stmmac-objs:= stmmac_main.o stmmac_ethtool.o stmmac_mdio.o	\
 	      dwmac_lib.o dwmac1000_core.o  dwmac1000_dma.o	\
 	      dwmac100_core.o dwmac100_dma.o enh_desc.o  norm_desc.o \
-	      mmc_core.o $(stmmac-y)
+	      mmc_core.o
author
#4 lore raw

Re: [PATCH 2/3] drivers: net: ethernet: stmmac: fix failure in module test

Hi Peppe,

Quoted 9 lines · Giuseppe CAVALLARO
Quoted 1 line · Bob Liu

Module can't be compiled and installed in current Makefile.

I've just seen that I can generate the stmmac.ko on ARM and also on x86 with my configuration.

Can you post here you build failure?

In the meantime I'll test the module on ARM soon.

Yes, stmmac.ko can be generated, but stmmac_platform.c won't be built. which cause net device can't be probed.

Quoted 31 lines

peppe

Quoted 27 lines

---
 drivers/net/ethernet/stmicro/stmmac/Makefile |   12 ++++++------

 1 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/ethernet/stmicro/stmmac/Makefile +0 -0
index bc965ac..4b50922 100644
@@ -1,10 +1,10 @@

 obj-$(CONFIG_STMMAC_ETH) += stmmac.o

drivers/net/ethernet/stmicro/stmmac/Makefile +5 -5
-stmmac-$(CONFIG_STMMAC_TIMER) += stmmac_timer.o
-stmmac-$(CONFIG_STMMAC_RING) += ring_mode.o
-stmmac-$(CONFIG_STMMAC_CHAINED) += chain_mode.o
-stmmac-$(CONFIG_STMMAC_PLATFORM) += stmmac_platform.o
-stmmac-$(CONFIG_STMMAC_PCI) += stmmac_pci.o
+stmmac-$(CONFIG_STMMAC_TIMER:m=y) += stmmac_timer.o
+stmmac-$(CONFIG_STMMAC_RING:m=y) += ring_mode.o
+stmmac-$(CONFIG_STMMAC_CHAINED:m=y) += chain_mode.o
+stmmac-$(CONFIG_STMMAC_PLATFORM:m=y) += stmmac_platform.o
+stmmac-$(CONFIG_STMMAC_PCI:m=y) += stmmac_pci.o

 stmmac-objs:= stmmac_main.o stmmac_ethtool.o stmmac_mdio.o   \
            dwmac_lib.o dwmac1000_core.o  dwmac1000_dma.o     \
            dwmac100_core.o dwmac100_dma.o enh_desc.o  norm_desc.o \
-           mmc_core.o $(stmmac-y)
+           mmc_core.o

Signature · 2 lines
Thanks,
--Bob
#5 lore raw

Re: [PATCH 2/3] drivers: net: ethernet: stmmac: fix failure in module test

Quoted 10 lines · Bob Liu

Hi Peppe,

Quoted 6 lines · Giuseppe CAVALLARO
Quoted 1 line · Bob Liu

Module can't be compiled and installed in current Makefile.

I've just seen that I can generate the stmmac.ko on ARM and also on x86 with my configuration.

Quoted 6 lines
Quoted 3 lines

Can you post here you build failure?

In the meantime I'll test the module on ARM soon.

Yes, stmmac.ko can be generated, but stmmac_platform.c won't be built. which cause net device can't be probed.

Yes you are perfectly right!

I've just sent a patch following Ben's advice.

Also not clear if/how to build this as a system which supports both PCI and platform versions of the driver. So the patch makes them mutually exclusive.

Thanks a lot
peppe

Quoted 33 lines
Quoted 32 lines

peppe

Quoted 27 lines
---
 drivers/net/ethernet/stmicro/stmmac/Makefile |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/ethernet/stmicro/stmmac/Makefile +6 -6
index bc965ac..4b50922 100644
@@ -1,10 +1,10 @@
 obj-$(CONFIG_STMMAC_ETH) += stmmac.o
-stmmac-$(CONFIG_STMMAC_TIMER) += stmmac_timer.o
-stmmac-$(CONFIG_STMMAC_RING) += ring_mode.o
-stmmac-$(CONFIG_STMMAC_CHAINED) += chain_mode.o
-stmmac-$(CONFIG_STMMAC_PLATFORM) += stmmac_platform.o
-stmmac-$(CONFIG_STMMAC_PCI) += stmmac_pci.o
+stmmac-$(CONFIG_STMMAC_TIMER:m=y) += stmmac_timer.o
+stmmac-$(CONFIG_STMMAC_RING:m=y) += ring_mode.o
+stmmac-$(CONFIG_STMMAC_CHAINED:m=y) += chain_mode.o
+stmmac-$(CONFIG_STMMAC_PLATFORM:m=y) += stmmac_platform.o
+stmmac-$(CONFIG_STMMAC_PCI:m=y) += stmmac_pci.o
 stmmac-objs:= stmmac_main.o stmmac_ethtool.o stmmac_mdio.o   \
            dwmac_lib.o dwmac1000_core.o  dwmac1000_dma.o     \
            dwmac100_core.o dwmac100_dma.o enh_desc.o  norm_desc.o \
-           mmc_core.o $(stmmac-y)
+           mmc_core.o
#6 lore raw

[net] stmmac: fix driver Kconfig when built as module

In reply to Bob Liu

This patches fixes the driver when built as dyn module. In fact the platform part cannot be built and the probe fails (thanks to Bob Liu that reported this bug).
The patch also makes the selection of Platform and PCI parts mutually exclusive.

---
 drivers/net/ethernet/stmicro/stmmac/Kconfig |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
drivers/net/ethernet/stmicro/stmmac/Kconfig +6 -3
index 0364283..3318b32 100644
@@ -12,10 +12,12 @@ config STMMAC_ETH
 
 if STMMAC_ETH
 
+choice
+        prompt "STMMAC bus support"
+
 config STMMAC_PLATFORM
-	tristate "STMMAC platform bus support"
+	bool "Platform bus support"
 	depends on STMMAC_ETH
-	default y
 	---help---
 	  This selects the platform specific bus support for
 	  the stmmac device driver. This is the driver used
@@ -26,7 +28,7 @@ config STMMAC_PLATFORM
 	  If unsure, say N.
 
 config STMMAC_PCI
-	tristate "STMMAC support on PCI bus (EXPERIMENTAL)"
+	bool "PCI bus support (EXPERIMENTAL)"
 	depends on STMMAC_ETH && PCI && EXPERIMENTAL
 	---help---
 	  This is to select the Synopsys DWMAC available on PCI devices,
@@ -36,6 +38,7 @@ config STMMAC_PCI
 	  D1215994A VIRTEX FPGA board.
 
 	  If unsure, say N.
+endchoice
 
 config STMMAC_DEBUG_FS
 	bool "Enable monitoring via sysFS "
Signature · 1 line
1.7.4.4
maintainer
#7 lore raw

Re: [net] stmmac: fix driver Kconfig when built as module

From: Giuseppe CAVALLARO <[email protected]>
Date: Wed, 23 May 2012 08:05:42 +0200

Quoted 9 lines

This patches fixes the driver when built as dyn module. In fact the platform part cannot be built and the probe fails (thanks to Bob Liu that reported this bug).
The patch also makes the selection of Platform and PCI parts mutually exclusive.

We have drivers which support both OF (which is implemented as platform bus) and PCI at the same time. For example, drivers/net/ethernet/sun/niu.c

I do not see why stmmac cannot support both at the same time as well.

I absolutely do not want such segregation unless it is absolutely necessary. Because it means that no matter what is choosen, a piece of code is disabled and therefore not getting build and/or runtime validation.

#8 lore raw

Re: [net] stmmac: fix driver Kconfig when built as module

Quoted 17 lines · David Miller

From: Giuseppe CAVALLARO <[email protected]>
Date: Wed, 23 May 2012 08:05:42 +0200

Quoted 9 lines

This patches fixes the driver when built as dyn module. In fact the platform part cannot be built and the probe fails (thanks to Bob Liu that reported this bug).
The patch also makes the selection of Platform and PCI parts mutually exclusive.

We have drivers which support both OF (which is implemented as platform bus) and PCI at the same time. For example, drivers/net/ethernet/sun/niu.c

Quoted 6 lines

I do not see why stmmac cannot support both at the same time as well.

I absolutely do not want such segregation unless it is absolutely necessary. Because it means that no matter what is choosen, a piece of code is disabled and therefore not getting build and/or runtime validation.

Ok, I'll review it and resend all the patches asap.

Regards
Peppe

Quoted 5 lines

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

author
#9 lore raw

PATCH 3/3 drivers: net: ethernet: stmmac: fix resume function

In reply to Bob Liu

After wake up from mem, ping fails to work. This patch fix the resume function in stmmac driver.

---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +9 -0
index 714faa2..22243a5 100644
@@ -1952,6 +1952,15 @@ int stmmac_resume(struct net_device *ndev)
 		priv->hw->mac->pmt(priv->ioaddr, 0);
 
 	netif_device_attach(ndev);
+	priv->dirty_tx = 0;
+	priv->cur_tx = 0;
+	priv->cur_rx = 0;
+	priv->dirty_rx = 0;
+
+	/* DMA initialization and SW reset */
+	priv->hw->dma->init(priv->ioaddr, priv->plat->pbl,
+			priv->dma_tx_phy, priv->dma_rx_phy);
+	priv->hw->mac->core_init(priv->ioaddr);
 
 	/* Enable the MAC and DMA */
 	stmmac_set_mac(priv->ioaddr, true);
Signature · 1 line
1.7.0.4
#10 lore raw
In reply to Bob Liu

Hello Bob Liu

Quoted 7 lines · Bob Liu

Blackfin arch use stmmac on its reference board bf609-ezkit, the stmmac ip version is 3.61a.

But the spec seems a little different, some register addr and define are not the same with current code.

This patch add the support for blackfin arch following the spec.

The 3.61a is supported and you have to point to the dw1000.h header file.

To support this GMAC generation you only need to pass from the platform the field has_gmac (see stmmac.txt).
Also the 3.61a has the HW cap registers so many internal fields (e.g. rx coe, enhanced descr ...) will be fixed at run-time (although you can pass them from the platform).

Your patch adds the GMAC SPEC in the old MAC 10/100.

Also I am reluctant to have specific ifdef <ARCH> within the code. I do think the driver already has all the platform fields to run on your board. If you need extra conf pls feel free to enhance the plat_stmmacenet_data.

Peppe

Quoted 150 lines
---
 drivers/net/ethernet/stmicro/stmmac/dwmac100.h     |   29 ++++++++++++++++++++
 .../net/ethernet/stmicro/stmmac/dwmac100_core.c    |    6 +++-
 drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c |    3 ++
 drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h    |    5 +++
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c  |    2 +
 5 files changed, 44 insertions(+), 1 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac100.h +29 -0
index 7c6d857..cc3ac4f 100644
@@ -29,6 +29,18 @@
  *	 			MAC BLOCK defines
  *---------------------------------------------------------------------------*/
 /* MAC CSR offset */
+#ifdef CONFIG_BLACKFIN
+#define MAC_CONTROL		0x00000000	/* MAC Control */
+#define MAC_FRAME_FILTER	0x0000004	/* Frame filter */
+#define MAC_HASH_HIGH		0x00000008	/* Multicast Hash Table High */
+#define MAC_HASH_LOW		0x0000000c	/* Multicast Hash Table Low */
+#define MAC_MII_ADDR		0x00000010	/* MII Address */
+#define MAC_MII_DATA		0x00000014	/* MII Data */
+#define MAC_FLOW_CTRL		0x00000018	/* Flow Control */
+#define MAC_VLAN1		0x0000001c	/* VLAN1 Tag */
+#define MAC_ADDR_HIGH		0x00000040	/* MAC Address High */
+#define MAC_ADDR_LOW		0x00000044	/* MAC Address Low */
+#else
 #define MAC_CONTROL	0x00000000	/* MAC Control */
 #define MAC_ADDR_HIGH	0x00000004	/* MAC Address High */
 #define MAC_ADDR_LOW	0x00000008	/* MAC Address Low */
@@ -39,6 +51,18 @@
 #define MAC_FLOW_CTRL	0x0000001c	/* Flow Control */
 #define MAC_VLAN1	0x00000020	/* VLAN1 Tag */
 #define MAC_VLAN2	0x00000024	/* VLAN2 Tag */
+#endif
+
+#ifdef CONFIG_BLACKFIN
+/* MAC_FRAME_FILTER defines */
+#define MAC_FRAME_FILTER_RA  0x80000000
+#define MAC_FRAME_FILTER_PR  0x00000001
+#define MAC_FRAME_FILTER_HMC 0x00000004
+#define MAC_FRAME_FILTER_PM  0x00000010
+
+#define MAC_FRAME_FILTER_INIT (MAC_FRAME_FILTER_RA | MAC_FRAME_FILTER_PR | \
+		MAC_FRAME_FILTER_HMC | MAC_FRAME_FILTER_PM)
+#endif
 
 /* MAC CTRL defines */
 #define MAC_CONTROL_RA	0x80000000	/* Receive All Mode */
@@ -54,6 +78,7 @@
 #define MAC_CONTROL_IF	0x00020000	/* Inverse Filtering */
 #define MAC_CONTROL_PB	0x00010000	/* Pass Bad Frames */
 #define MAC_CONTROL_HO	0x00008000	/* Hash Only Filtering Mode */
+#define MAC_CONTROL_FES	0x00004000	/* Speed in Fast Ethernet Mode */
 #define MAC_CONTROL_HP	0x00002000	/* Hash/Perfect Filtering Mode */
 #define MAC_CONTROL_LCC	0x00001000	/* Late Collision Control */
 #define MAC_CONTROL_DBF	0x00000800	/* Disable Broadcast Frames */
@@ -67,7 +92,11 @@
 #define MAC_CONTROL_TE		0x00000008	/* Transmitter Enable */
 #define MAC_CONTROL_RE		0x00000004	/* Receiver Enable */
 
+#ifdef CONFIG_BLACKFIN
+#define MAC_CORE_INIT (MAC_CONTROL_FES | MAC_CONTROL_DBF)
+#else
 #define MAC_CORE_INIT (MAC_CONTROL_HBD | MAC_CONTROL_ASTP)
+#endif
 
 /* MAC FLOW CTRL defines */
 #define MAC_FLOW_CTRL_PT_MASK	0xffff0000	/* Pause Time Mask */
drivers/net/ethernet/stmicro/stmmac/dwmac100_core.c +5 -1
index 138fb8d..1c49d96 100644
@@ -35,7 +35,9 @@
 static void dwmac100_core_init(void __iomem *ioaddr)
 {
 	u32 value = readl(ioaddr + MAC_CONTROL);
-
+#ifdef CONFIG_BLACKFIN
+	writel(MAC_FRAME_FILTER_INIT, ioaddr + MAC_FRAME_FILTER);
+#endif
 	writel((value | MAC_CORE_INIT), ioaddr + MAC_CONTROL);
 
 #ifdef STMMAC_VLAN_TAG_USED
@@ -68,8 +70,10 @@ static void dwmac100_dump_mac_regs(void __iomem *ioaddr)
 		MAC_FLOW_CTRL, readl(ioaddr + MAC_FLOW_CTRL));
 	pr_info("\tVLAN1 tag (offset 0x%x): 0x%08x\n", MAC_VLAN1,
 		readl(ioaddr + MAC_VLAN1));
+#ifndef CONFIG_BLACKFIN
 	pr_info("\tVLAN2 tag (offset 0x%x): 0x%08x\n", MAC_VLAN2,
 		readl(ioaddr + MAC_VLAN2));
+#endif
 }
 
 static void dwmac100_irq_status(void __iomem *ioaddr)
drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c +3 -0
index bc17fd0..d682a0b 100644
@@ -50,6 +50,9 @@ static int dwmac100_dma_init(void __iomem *ioaddr, int pbl, u32 dma_tx,
 	if (limit < 0)
 		return -EBUSY;
 
+#ifdef CONFIG_BLACKFIN
+	writel(DMA_AXI_BUS_BLEN4 | DMA_AXI_BUS_UNDEF, ioaddr + DMA_AXI_BUS);
+#endif
 	/* Enable Application Access by writing to DMA CSR0 */
 	writel(DMA_BUS_MODE_DEFAULT | (pbl << DMA_BUS_MODE_PBL_SHIFT),
 	       ioaddr + DMA_BUS_MODE);
drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h +5 -0
index 437edac..e75269a 100644
@@ -32,6 +32,7 @@
 #define DMA_CONTROL		0x00001018	/* Ctrl (Operational Mode) */
 #define DMA_INTR_ENA		0x0000101c	/* Interrupt Enable */
 #define DMA_MISSED_FRAME_CTR	0x00001020	/* Missed Frame Counter */
+#define DMA_AXI_BUS		0x00001028	/* Axi Bus */
 #define DMA_CUR_TX_BUF_ADDR	0x00001050	/* Current Host Tx Buffer */
 #define DMA_CUR_RX_BUF_ADDR	0x00001054	/* Current Host Rx Buffer */
 #define DMA_HW_FEATURE		0x00001058	/* HW Feature Register */
@@ -40,6 +41,10 @@
 #define DMA_CONTROL_ST		0x00002000	/* Start/Stop Transmission */
 #define DMA_CONTROL_SR		0x00000002	/* Start/Stop Receive */
 
+/* DMA Axi bus register defines */
+#define DMA_AXI_BUS_UNDEF	0x00000001
+#define DMA_AXI_BUS_BLEN4	0x00000002
+
 /* DMA Normal interrupt */
 #define DMA_INTR_ENA_NIE 0x00010000	/* Normal Summary */
 #define DMA_INTR_ENA_TIE 0x00000001	/* Transmit Interrupt */
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -0
index 48d56da..714faa2 100644
@@ -1279,8 +1279,10 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit)
 			frame_len = priv->hw->desc->get_rx_frame_len(p);
 			/* ACS is set; GMAC core strips PAD/FCS for IEEE 802.3
 			 * Type frames (LLC/LLC-SNAP) */
+#ifndef CONFIG_BLACKFIN
 			if (unlikely(status != llc_snap))
 				frame_len -= ETH_FCS_LEN;
+#endif
 #ifdef STMMAC_RX_DEBUG
 			if (frame_len > ETH_FRAME_LEN)
 				pr_debug("\tRX frame size %d, COE status: %d\n",
author
#11 lore raw

Hi Peppe,

Quoted 21 lines · Giuseppe CAVALLARO

Hello Bob Liu

Quoted 9 lines · Bob Liu

Blackfin arch use stmmac on its reference board bf609-ezkit, the stmmac ip
version is 3.61a.

But the spec seems a little different, some register addr and define are not
the same with current code.

This patch add the support for blackfin arch following the spec.

The 3.61a is supported and you have to point to the dw1000.h header file.

To support this GMAC generation you only need to pass from the platform the field has_gmac (see stmmac.txt).
Also the 3.61a has the HW cap registers so many internal fields (e.g. rx coe, enhanced descr ...) will be fixed at run-time (although you can pass them from the platform).

Quoted 7 lines

Your patch adds the GMAC SPEC in the old MAC 10/100.

Also I am reluctant to have specific ifdef <ARCH> within the code. I do think the driver already has all the platform fields to run on your board. If you need extra conf pls feel free to enhance the plat_stmmacenet_data.

Thank you for your reply.
I tried to use driver dwmac1000 by setting .has_gmac = 1 today. Ping can finish with no error but when rcp a file or telnet it will hang.

Using below patch without setting .has_gmac, everything works fine. Any ideas? Thank you.

(quoted diff) +0 -0

b/drivers/net/ethernet/stmicro/stmmac/dwmac100.h
index 7c6d857..00499b8 100644

drivers/net/ethernet/stmicro/stmmac/dwmac100.h +17 -0
@@ -29,6 +29,18 @@
  *                             MAC BLOCK defines
  *---------------------------------------------------------------------------*/
 /* MAC CSR offset */
+#if defined(CONFIG_BLACKFIN)
+#define MAC_CONTROL    0x00000000      /* MAC Control */
+#define MAC_FRAME_FILTER       0x0000004       /* Frame filter */
+#define MAC_HASH_HIGH  0x00000008      /* Multicast Hash Table High */
+#define MAC_HASH_LOW   0x0000000c      /* Multicast Hash Table Low */
+#define MAC_MII_ADDR   0x00000010      /* MII Address */
+#define MAC_MII_DATA   0x00000014      /* MII Data */
+#define MAC_FLOW_CTRL  0x00000018      /* Flow Control */
+#define MAC_VLAN1      0x0000001c      /* VLAN1 Tag */
+#define MAC_ADDR_HIGH  0x00000040      /* MAC Address High */
+#define MAC_ADDR_LOW   0x00000044      /* MAC Address Low */
+#else
 #define MAC_CONTROL    0x00000000      /* MAC Control */
 #define MAC_ADDR_HIGH  0x00000004      /* MAC Address High */
 #define MAC_ADDR_LOW   0x00000008      /* MAC Address Low */
@@ -39,6 +51,7 @@
 #define MAC_FLOW_CTRL  0x0000001c      /* Flow Control */
 #define MAC_VLAN1      0x00000020      /* VLAN1 Tag */
 #define MAC_VLAN2      0x00000024      /* VLAN2 Tag */
+#endif
 
 /* MAC CTRL defines */
 #define MAC_CONTROL_RA 0x80000000      /* Receive All Mode */
@@ -67,7 +80,11 @@
 #define MAC_CONTROL_TE         0x00000008      /* Transmitter Enable */
 #define MAC_CONTROL_RE         0x00000004      /* Receiver Enable */
 
+#ifdef CONFIG_BLACKFIN
+#define MAC_CORE_INIT ((1 << 14) | MAC_CONTROL_DBF)
+#else
 #define MAC_CORE_INIT (MAC_CONTROL_HBD | MAC_CONTROL_ASTP)
+#endif
 
 /* MAC FLOW CTRL defines */
 #define MAC_FLOW_CTRL_PT_MASK  0xffff0000      /* Pause Time Mask */
Signature · 2 lines
Regards,
--Bob
#12 lore raw

Hello Bob Liu

Quoted 32 lines · Bob Liu

Hi Peppe,

Quoted 21 lines · Giuseppe CAVALLARO

Hello Bob Liu

Quoted 9 lines · Bob Liu

Blackfin arch use stmmac on its reference board bf609-ezkit, the stmmac ip
version is 3.61a.

But the spec seems a little different, some register addr and define are not
the same with current code.

This patch add the support for blackfin arch following the spec.

The 3.61a is supported and you have to point to the dw1000.h header file.

To support this GMAC generation you only need to pass from the platform the field has_gmac (see stmmac.txt).
Also the 3.61a has the HW cap registers so many internal fields (e.g. rx coe, enhanced descr ...) will be fixed at run-time (although you can pass them from the platform).

Quoted 7 lines

Your patch adds the GMAC SPEC in the old MAC 10/100.

Also I am reluctant to have specific ifdef <ARCH> within the code. I do think the driver already has all the platform fields to run on your board. If you need extra conf pls feel free to enhance the plat_stmmacenet_data.

Quoted 3 lines

Thank you for your reply.
I tried to use driver dwmac1000 by setting .has_gmac = 1 today. Ping can finish with no error but when rcp a file or telnet it will hang.

Hmm this should be debugged ... maybe you can verify the tx / rx checksum. I mean if your IP has these modules or if, for somereason, the HW cap register is not present and there are not properly fixed

Quoted 2 lines

Using below patch without setting .has_gmac, everything works fine.

With your patch (that added the dwmac1000 into the dwmac100) you are indeed using the MAC100 setting where by default there is no HW checksumming ;-)

Quoted 1 line

Any ideas? Thank you.

you are welcome

Peppe

Quoted 45 lines
drivers/net/ethernet/stmicro/stmmac/dwmac100.h +17 -0
index 7c6d857..00499b8 100644
@@ -29,6 +29,18 @@
  *                             MAC BLOCK defines
  *---------------------------------------------------------------------------*/
 /* MAC CSR offset */
+#if defined(CONFIG_BLACKFIN)
+#define MAC_CONTROL    0x00000000      /* MAC Control */
+#define MAC_FRAME_FILTER       0x0000004       /* Frame filter */
+#define MAC_HASH_HIGH  0x00000008      /* Multicast Hash Table High */
+#define MAC_HASH_LOW   0x0000000c      /* Multicast Hash Table Low */
+#define MAC_MII_ADDR   0x00000010      /* MII Address */
+#define MAC_MII_DATA   0x00000014      /* MII Data */
+#define MAC_FLOW_CTRL  0x00000018      /* Flow Control */
+#define MAC_VLAN1      0x0000001c      /* VLAN1 Tag */
+#define MAC_ADDR_HIGH  0x00000040      /* MAC Address High */
+#define MAC_ADDR_LOW   0x00000044      /* MAC Address Low */
+#else
 #define MAC_CONTROL    0x00000000      /* MAC Control */
 #define MAC_ADDR_HIGH  0x00000004      /* MAC Address High */
 #define MAC_ADDR_LOW   0x00000008      /* MAC Address Low */
@@ -39,6 +51,7 @@
 #define MAC_FLOW_CTRL  0x0000001c      /* Flow Control */
 #define MAC_VLAN1      0x00000020      /* VLAN1 Tag */
 #define MAC_VLAN2      0x00000024      /* VLAN2 Tag */
+#endif
 
 /* MAC CTRL defines */
 #define MAC_CONTROL_RA 0x80000000      /* Receive All Mode */
@@ -67,7 +80,11 @@
 #define MAC_CONTROL_TE         0x00000008      /* Transmitter Enable */
 #define MAC_CONTROL_RE         0x00000004      /* Receiver Enable */
 
+#ifdef CONFIG_BLACKFIN
+#define MAC_CORE_INIT ((1 << 14) | MAC_CONTROL_DBF)
+#else
 #define MAC_CORE_INIT (MAC_CONTROL_HBD | MAC_CONTROL_ASTP)
+#endif
 
 /* MAC FLOW CTRL defines */
 #define MAC_FLOW_CTRL_PT_MASK  0xffff0000      /* Pause Time Mask */
#13 lore raw
Quoted 44 lines · Giuseppe CAVALLARO

Hello Bob Liu

Quoted 32 lines · Bob Liu

Hi Peppe,

Quoted 21 lines · Giuseppe CAVALLARO

Hello Bob Liu

Quoted 9 lines · Bob Liu

Blackfin arch use stmmac on its reference board bf609-ezkit, the stmmac ip
version is 3.61a.

But the spec seems a little different, some register addr and define are not
the same with current code.

This patch add the support for blackfin arch following the spec.

The 3.61a is supported and you have to point to the dw1000.h header file.

To support this GMAC generation you only need to pass from the platform the field has_gmac (see stmmac.txt).
Also the 3.61a has the HW cap registers so many internal fields (e.g. rx coe, enhanced descr ...) will be fixed at run-time (although you can pass them from the platform).

Quoted 7 lines

Your patch adds the GMAC SPEC in the old MAC 10/100.

Also I am reluctant to have specific ifdef <ARCH> within the code. I do think the driver already has all the platform fields to run on your board. If you need extra conf pls feel free to enhance the plat_stmmacenet_data.

Quoted 3 lines

Thank you for your reply.
I tried to use driver dwmac1000 by setting .has_gmac = 1 today. Ping can finish with no error but when rcp a file or telnet it will hang.

Hmm this should be debugged ... maybe you can verify the tx / rx checksum. I mean if your IP has these modules or if, for somereason, the HW cap register is not present and there are not properly fixed

Quoted 1 line
Quoted 5 lines
Quoted 1 line

Using below patch without setting .has_gmac, everything works fine.

With your patch (that added the dwmac1000 into the dwmac100) you are indeed using the MAC100 setting where by default there is no HW checksumming ;-)

platform fields to use are: tx_coe and rx_coe.

Peppe

Quoted 58 lines
Quoted 1 line

Any ideas? Thank you.

you are welcome

Peppe

Quoted 35 lines
drivers/net/ethernet/stmicro/stmmac/dwmac100.h +13 -0
index 7c6d857..00499b8 100644
@@ -29,6 +29,18 @@
  *                             MAC BLOCK defines
  *---------------------------------------------------------------------------*/
 /* MAC CSR offset */
+#if defined(CONFIG_BLACKFIN)
+#define MAC_CONTROL    0x00000000      /* MAC Control */
+#define MAC_FRAME_FILTER       0x0000004       /* Frame filter */
+#define MAC_HASH_HIGH  0x00000008      /* Multicast Hash Table High */
+#define MAC_HASH_LOW   0x0000000c      /* Multicast Hash Table Low */
+#define MAC_MII_ADDR   0x00000010      /* MII Address */
+#define MAC_MII_DATA   0x00000014      /* MII Data */
+#define MAC_FLOW_CTRL  0x00000018      /* Flow Control */
+#define MAC_VLAN1      0x0000001c      /* VLAN1 Tag */
+#define MAC_ADDR_HIGH  0x00000040      /* MAC Address High */
+#define MAC_ADDR_LOW   0x00000044      /* MAC Address Low */
+#else
 #define MAC_CONTROL    0x00000000      /* MAC Control */
 #define MAC_ADDR_HIGH  0x00000004      /* MAC Address High */
 #define MAC_ADDR_LOW   0x00000008      /* MAC Address Low */
@@ -39,6 +51,7 @@
 #define MAC_FLOW_CTRL  0x0000001c      /* Flow Control */
 #define MAC_VLAN1      0x00000020      /* VLAN1 Tag */
 #define MAC_VLAN2      0x00000024      /* VLAN2 Tag */
+#endif
 
 /* MAC CTRL defines */
 #define MAC_CONTROL_RA 0x80000000      /* Receive All Mode */
@@ -67,7 +80,11 @@
 #define MAC_CONTROL_TE         0x00000008      /* Transmitter Enable */

drivers/net/ethernet/stmicro/stmmac/dwmac100.h line 90

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac100.h +4 -0
 #define MAC_CONTROL_RE         0x00000004      /* Receiver Enable */
 
+#ifdef CONFIG_BLACKFIN
+#define MAC_CORE_INIT ((1 << 14) | MAC_CONTROL_DBF)
+#else
 #define MAC_CORE_INIT (MAC_CONTROL_HBD | MAC_CONTROL_ASTP)
+#endif
 
 /* MAC FLOW CTRL defines */
 #define MAC_FLOW_CTRL_PT_MASK  0xffff0000      /* Pause Time Mask */

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