Skip to contentSkip to conversation

net: ethernet: bgmac: Add platform device support

PATCH Superseded Jon Mason 5 participants 20 messages Jun 30, 2016 – Jul 7, 2016

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jon Mason

author
#0 lore raw

cover net: ethernet: bgmac: Add platform device support

Well, no compilained too loudly at the RFC version of this patch series (see https://lkml.org/lkml/2016/6/28/863). So, I'm officially sending this out for inclusion. All comments from the RFC were addressed in this version.

This patch series adds support for other, non-bcma iProc SoC's to the bgmac driver. This series only adds NSP support, but we are interested in adding support for the Cygnus and NS2 families (with more possible down the road).

To support non-bcma enabled SoCs, we need to add the standard device tree "platform device" support. Unfortunately, this driver is very tighly coupled with the bcma bus and much unwinding is needed. I tried to break this up into a number of patches to make it more obvious what was being done to add platform device support. I was able to verify that the bcma code still works using a 53012K board (NS SoC), and that the platform code works using a 58625K board (NSP SoC).

Thanks,
Jon

Jon Mason (7):
net: ethernet: bgmac: change bgmac_* prints to dev_* prints
net: ethernet: bgmac: add dma_dev pointer
net: ethernet: bgmac: move BCMA MDIO Phy code into a separate file
net: ethernet: bgmac: convert to feature flags
net: ethernet: bgmac: Add platform device support
dt-bindings: net: bgmac: add bindings documentation for bgmac
ARM: dts: NSP: Add bgmac entries

 .../devicetree/bindings/net/brcm,bgmac-nsp.txt     |  24 +
 arch/arm/boot/dts/bcm-nsp.dtsi                     |  18 +
 arch/arm/boot/dts/bcm958625k.dts                   |   8 +
 drivers/net/ethernet/broadcom/Kconfig              |  23 +-
 drivers/net/ethernet/broadcom/Makefile             |   2 +
 drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c    | 266 +++++++++
 drivers/net/ethernet/broadcom/bgmac-bcma.c         | 315 ++++++++++
 drivers/net/ethernet/broadcom/bgmac-platform.c     | 210 +++++++
 drivers/net/ethernet/broadcom/bgmac.c              | 658 +++++----------------
 drivers/net/ethernet/broadcom/bgmac.h              | 112 +++-
 10 files changed, 1120 insertions(+), 516 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/brcm,bgmac-nsp.txt
 create mode 100644 drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c
 create mode 100644 drivers/net/ethernet/broadcom/bgmac-bcma.c
 create mode 100644 drivers/net/ethernet/broadcom/bgmac-platform.c
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH 1/7 net: ethernet: bgmac: change bgmac_* prints to dev_* prints

The bgmac_* print wrappers call dev_* prints with the dev pointer from the bcma core. In anticipation of removing the bcma requirement for this driver, these must be changed to not reference that struct. So, simply change all of the bgmac_* prints to their dev_* counterparts. In some cases netdev_* prints are more appropriate, so change those as well.

---
 drivers/net/ethernet/broadcom/bgmac.c | 103 +++++++++++++++++-----------------
 drivers/net/ethernet/broadcom/bgmac.h |  14 +----
 2 files changed, 55 insertions(+), 62 deletions(-)
drivers/net/ethernet/broadcom/bgmac.c +53 -50
index e6e74ca..37b3b68 100644
@@ -50,7 +50,7 @@ static bool bgmac_wait_value(struct bcma_device *core, u16 reg, u32 mask,
 			return true;
 		udelay(10);
 	}
-	pr_err("Timeout waiting for reg 0x%X\n", reg);
+	dev_err(&core->dev, "Timeout waiting for reg 0x%X\n", reg);
 	return false;
 }
 
@@ -84,8 +84,8 @@ static void bgmac_dma_tx_reset(struct bgmac *bgmac, struct bgmac_dma_ring *ring)
 		udelay(10);
 	}
 	if (i)
-		bgmac_err(bgmac, "Timeout suspending DMA TX ring 0x%X (BGMAC_DMA_TX_STAT: 0x%08X)\n",
-			  ring->mmio_base, val);
+		dev_err(bgmac->dev, "Timeout suspending DMA TX ring 0x%X (BGMAC_DMA_TX_STAT: 0x%08X)\n",
+			ring->mmio_base, val);
 
 	/* Remove SUSPEND bit */
 	bgmac_write(bgmac, ring->mmio_base + BGMAC_DMA_TX_CTL, 0);
@@ -93,13 +93,13 @@ static void bgmac_dma_tx_reset(struct bgmac *bgmac, struct bgmac_dma_ring *ring)
 			      ring->mmio_base + BGMAC_DMA_TX_STATUS,
 			      BGMAC_DMA_TX_STAT, BGMAC_DMA_TX_STAT_DISABLED,
 			      10000)) {
-		bgmac_warn(bgmac, "DMA TX ring 0x%X wasn't disabled on time, waiting additional 300us\n",
-			   ring->mmio_base);
+		dev_warn(bgmac->dev, "DMA TX ring 0x%X wasn't disabled on time, waiting additional 300us\n",
+			 ring->mmio_base);
 		udelay(300);
 		val = bgmac_read(bgmac, ring->mmio_base + BGMAC_DMA_TX_STATUS);
 		if ((val & BGMAC_DMA_TX_STAT) != BGMAC_DMA_TX_STAT_DISABLED)
-			bgmac_err(bgmac, "Reset of DMA TX ring 0x%X failed\n",
-				  ring->mmio_base);
+			dev_err(bgmac->dev, "Reset of DMA TX ring 0x%X failed\n",
+				ring->mmio_base);
 	}
 }
 
@@ -161,7 +161,7 @@ static netdev_tx_t bgmac_dma_tx_add(struct bgmac *bgmac,
 	int i;
 
 	if (skb->len > BGMAC_DESC_CTL1_LEN) {
-		bgmac_err(bgmac, "Too long skb (%d)\n", skb->len);
+		netdev_err(bgmac->net_dev, "Too long skb (%d)\n", skb->len);
 		goto err_drop;
 	}
 
@@ -174,7 +174,7 @@ static netdev_tx_t bgmac_dma_tx_add(struct bgmac *bgmac,
 	 * even when ring->end overflows
 	 */
 	if (ring->end - ring->start + nr_frags + 1 >= BGMAC_TX_RING_SLOTS) {
-		bgmac_err(bgmac, "TX ring is full, queue should be stopped!\n");
+		netdev_err(bgmac->net_dev, "TX ring is full, queue should be stopped!\n");
 		netif_stop_queue(net_dev);
 		return NETDEV_TX_BUSY;
 	}
@@ -241,8 +241,8 @@ err_dma:
 	}
 
 err_dma_head:
-	bgmac_err(bgmac, "Mapping error of skb on ring 0x%X\n",
-		  ring->mmio_base);
+	netdev_err(bgmac->net_dev, "Mapping error of skb on ring 0x%X\n",
+		   ring->mmio_base);
 
 err_drop:
 	dev_kfree_skb(skb);
@@ -320,8 +320,8 @@ static void bgmac_dma_rx_reset(struct bgmac *bgmac, struct bgmac_dma_ring *ring)
 			      ring->mmio_base + BGMAC_DMA_RX_STATUS,
 			      BGMAC_DMA_RX_STAT, BGMAC_DMA_RX_STAT_DISABLED,
 			      10000))
-		bgmac_err(bgmac, "Reset of ring 0x%X RX failed\n",
-			  ring->mmio_base);
+		dev_err(bgmac->dev, "Reset of ring 0x%X RX failed\n",
+			ring->mmio_base);
 }
 
 static void bgmac_dma_rx_enable(struct bgmac *bgmac,
@@ -370,7 +370,7 @@ static int bgmac_dma_rx_skb_for_slot(struct bgmac *bgmac,
 	dma_addr = dma_map_single(dma_dev, buf + BGMAC_RX_BUF_OFFSET,
 				  BGMAC_RX_BUF_SIZE, DMA_FROM_DEVICE);
 	if (dma_mapping_error(dma_dev, dma_addr)) {
-		bgmac_err(bgmac, "DMA mapping error\n");
+		netdev_err(bgmac->net_dev, "DMA mapping error\n");
 		put_page(virt_to_head_page(buf));
 		return -ENOMEM;
 	}
@@ -465,16 +465,16 @@ static int bgmac_dma_rx_read(struct bgmac *bgmac, struct bgmac_dma_ring *ring,
 
 			/* Check for poison and drop or pass the packet */
 			if (len == 0xdead && flags == 0xbeef) {
-				bgmac_err(bgmac, "Found poisoned packet at slot %d, DMA issue!\n",
-					  ring->start);
+				netdev_err(bgmac->net_dev, "Found poisoned packet at slot %d, DMA issue!\n",
+					   ring->start);
 				put_page(virt_to_head_page(buf));
 				bgmac->net_dev->stats.rx_errors++;
 				break;
 			}
 
 			if (len > BGMAC_RX_ALLOC_SIZE) {
-				bgmac_err(bgmac, "Found oversized packet at slot %d, DMA issue!\n",
-					  ring->start);
+				netdev_err(bgmac->net_dev, "Found oversized packet at slot %d, DMA issue!\n",
+					   ring->start);
 				put_page(virt_to_head_page(buf));
 				bgmac->net_dev->stats.rx_length_errors++;
 				bgmac->net_dev->stats.rx_errors++;
@@ -486,7 +486,7 @@ static int bgmac_dma_rx_read(struct bgmac *bgmac, struct bgmac_dma_ring *ring,
 
 			skb = build_skb(buf, BGMAC_RX_ALLOC_SIZE);
 			if (unlikely(!skb)) {
-				bgmac_err(bgmac, "build_skb failed\n");
+				netdev_err(bgmac->net_dev, "build_skb failed\n");
 				put_page(virt_to_head_page(buf));
 				bgmac->net_dev->stats.rx_errors++;
 				break;
@@ -640,7 +640,7 @@ static int bgmac_dma_alloc(struct bgmac *bgmac)
 	BUILD_BUG_ON(BGMAC_MAX_RX_RINGS > ARRAY_SIZE(ring_base));
 
 	if (!(bcma_aread32(bgmac->core, BCMA_IOST) & BCMA_IOST_DMA64)) {
-		bgmac_err(bgmac, "Core does not report 64-bit DMA\n");
+		dev_err(bgmac->dev, "Core does not report 64-bit DMA\n");
 		return -ENOTSUPP;
 	}
 
@@ -654,8 +654,8 @@ static int bgmac_dma_alloc(struct bgmac *bgmac)
 						     &ring->dma_base,
 						     GFP_KERNEL);
 		if (!ring->cpu_base) {
-			bgmac_err(bgmac, "Allocation of TX ring 0x%X failed\n",
-				  ring->mmio_base);
+			dev_err(bgmac->dev, "Allocation of TX ring 0x%X failed\n",
+				ring->mmio_base);
 			goto err_dma_free;
 		}
 
@@ -679,8 +679,8 @@ static int bgmac_dma_alloc(struct bgmac *bgmac)
 						     &ring->dma_base,
 						     GFP_KERNEL);
 		if (!ring->cpu_base) {
-			bgmac_err(bgmac, "Allocation of RX ring 0x%X failed\n",
-				  ring->mmio_base);
+			dev_err(bgmac->dev, "Allocation of RX ring 0x%X failed\n",
+				ring->mmio_base);
 			err = -ENOMEM;
 			goto err_dma_free;
 		}
@@ -799,8 +799,8 @@ static u16 bgmac_phy_read(struct bgmac *bgmac, u8 phyaddr, u8 reg)
 	bcma_write32(core, phy_access_addr, tmp);
 
 	if (!bgmac_wait_value(core, phy_access_addr, BGMAC_PA_START, 0, 1000)) {
-		bgmac_err(bgmac, "Reading PHY %d register 0x%X failed\n",
-			  phyaddr, reg);
+		dev_err(bgmac->dev, "Reading PHY %d register 0x%X failed\n",
+			phyaddr, reg);
 		return 0xffff;
 	}
 
@@ -832,7 +832,7 @@ static int bgmac_phy_write(struct bgmac *bgmac, u8 phyaddr, u8 reg, u16 value)
 
 	bgmac_write(bgmac, BGMAC_INT_STATUS, BGMAC_IS_MDIO);
 	if (bgmac_read(bgmac, BGMAC_INT_STATUS) & BGMAC_IS_MDIO)
-		bgmac_warn(bgmac, "Error setting MDIO int\n");
+		dev_warn(bgmac->dev, "Error setting MDIO int\n");
 
 	tmp = BGMAC_PA_START;
 	tmp |= BGMAC_PA_WRITE;
@@ -842,8 +842,8 @@ static int bgmac_phy_write(struct bgmac *bgmac, u8 phyaddr, u8 reg, u16 value)
 	bcma_write32(core, phy_access_addr, tmp);
 
 	if (!bgmac_wait_value(core, phy_access_addr, BGMAC_PA_START, 0, 1000)) {
-		bgmac_err(bgmac, "Writing to PHY %d register 0x%X failed\n",
-			  phyaddr, reg);
+		dev_err(bgmac->dev, "Writing to PHY %d register 0x%X failed\n",
+			phyaddr, reg);
 		return -ETIMEDOUT;
 	}
 
@@ -896,7 +896,7 @@ static void bgmac_phy_reset(struct bgmac *bgmac)
 	bgmac_phy_write(bgmac, bgmac->phyaddr, MII_BMCR, BMCR_RESET);
 	udelay(100);
 	if (bgmac_phy_read(bgmac, bgmac->phyaddr, MII_BMCR) & BMCR_RESET)
-		bgmac_err(bgmac, "PHY reset failed\n");
+		dev_err(bgmac->dev, "PHY reset failed\n");
 	bgmac_phy_init(bgmac);
 }
 
@@ -997,7 +997,8 @@ static void bgmac_mac_speed(struct bgmac *bgmac)
 		set |= BGMAC_CMDCFG_ES_2500;
 		break;
 	default:
-		bgmac_err(bgmac, "Unsupported speed: %d\n", bgmac->mac_speed);
+		dev_err(bgmac->dev, "Unsupported speed: %d\n",
+			bgmac->mac_speed);
 	}
 
 	if (bgmac->mac_duplex == DUPLEX_HALF)
@@ -1096,8 +1097,8 @@ static void bgmac_chip_reset(struct bgmac *bgmac)
 
 		if (bcm47xx_nvram_getenv("et_swtype", buf, sizeof(buf)) > 0) {
 			if (kstrtou8(buf, 0, &et_swtype))
-				bgmac_err(bgmac, "Failed to parse et_swtype (%s)\n",
-					  buf);
+				dev_err(bgmac->dev, "Failed to parse et_swtype (%s)\n",
+					buf);
 			et_swtype &= 0x0f;
 			et_swtype <<= 4;
 			sw_type = et_swtype;
@@ -1260,7 +1261,7 @@ static irqreturn_t bgmac_interrupt(int irq, void *dev_id)
 
 	int_status &= ~(BGMAC_IS_TX0 | BGMAC_IS_RX);
 	if (int_status)
-		bgmac_err(bgmac, "Unknown IRQs: 0x%08X\n", int_status);
+		dev_err(bgmac->dev, "Unknown IRQs: 0x%08X\n", int_status);
 
 	/* Disable new interrupts until handling existing ones */
 	bgmac_chip_intrs_off(bgmac);
@@ -1314,7 +1315,7 @@ static int bgmac_open(struct net_device *net_dev)
 	err = request_irq(bgmac->core->irq, bgmac_interrupt, IRQF_SHARED,
 			  KBUILD_MODNAME, net_dev);
 	if (err < 0) {
-		bgmac_err(bgmac, "IRQ request error: %d!\n", err);
+		dev_err(bgmac->dev, "IRQ request error: %d!\n", err);
 		bgmac_dma_cleanup(bgmac);
 		return err;
 	}
@@ -1578,14 +1579,14 @@ static int bgmac_fixed_phy_register(struct bgmac *bgmac)
 
 	phy_dev = fixed_phy_register(PHY_POLL, &fphy_status, -1, NULL);
 	if (!phy_dev || IS_ERR(phy_dev)) {
-		bgmac_err(bgmac, "Failed to register fixed PHY device\n");
+		dev_err(bgmac->dev, "Failed to register fixed PHY device\n");
 		return -ENODEV;
 	}
 
 	err = phy_connect_direct(bgmac->net_dev, phy_dev, bgmac_adjust_link,
 				 PHY_INTERFACE_MODE_MII);
 	if (err) {
-		bgmac_err(bgmac, "Connecting PHY failed\n");
+		dev_err(bgmac->dev, "Connecting PHY failed\n");
 		return err;
 	}
 
@@ -1617,7 +1618,7 @@ static int bgmac_mii_register(struct bgmac *bgmac)
 
 	err = mdiobus_register(mii_bus);
 	if (err) {
-		bgmac_err(bgmac, "Registration of mii bus failed\n");
+		dev_err(bgmac->dev, "Registration of mii bus failed\n");
 		goto err_free_bus;
 	}
 
@@ -1629,7 +1630,7 @@ static int bgmac_mii_register(struct bgmac *bgmac)
 	phy_dev = phy_connect(bgmac->net_dev, bus_id, &bgmac_adjust_link,
 			      PHY_INTERFACE_MODE_MII);
 	if (IS_ERR(phy_dev)) {
-		bgmac_err(bgmac, "PHY connection failed\n");
+		dev_err(bgmac->dev, "PHY connecton failed\n");
 		err = PTR_ERR(phy_dev);
 		goto err_unregister_bus;
 	}
@@ -1675,7 +1676,8 @@ static int bgmac_probe(struct bcma_device *core)
 		mac = sprom->et2mac;
 		break;
 	default:
-		pr_err("Unsupported core_unit %d\n", core->core_unit);
+		dev_err(&core->dev, "Unsupported core_unit %d\n",
+			core->core_unit);
 		return -ENOTSUPP;
 	}
 
@@ -1698,6 +1700,7 @@ static int bgmac_probe(struct bcma_device *core)
 	net_dev->irq = core->irq;
 	net_dev->ethtool_ops = &bgmac_ethtool_ops;
 	bgmac = netdev_priv(net_dev);
+	bgmac->dev = &core->dev;
 	bgmac->net_dev = net_dev;
 	bgmac->core = core;
 	bcma_set_drvdata(core, bgmac);
@@ -1709,7 +1712,7 @@ static int bgmac_probe(struct bcma_device *core)
 	/* On BCM4706 we need common core to access PHY */
 	if (core->id.id == BCMA_CORE_4706_MAC_GBIT &&
 	    !core->bus->drv_gmac_cmn.core) {
-		bgmac_err(bgmac, "GMAC CMN core not found (required for BCM4706)\n");
+		dev_err(bgmac->dev, "GMAC CMN core not found (required for BCM4706)\n");
 		err = -ENODEV;
 		goto err_netdev_free;
 	}
@@ -1728,15 +1731,15 @@ static int bgmac_probe(struct bcma_device *core)
 	}
 	bgmac->phyaddr &= BGMAC_PHY_MASK;
 	if (bgmac->phyaddr == BGMAC_PHY_MASK) {
-		bgmac_err(bgmac, "No PHY found\n");
+		dev_err(bgmac->dev, "No PHY found\n");
 		err = -ENODEV;
 		goto err_netdev_free;
 	}
-	bgmac_info(bgmac, "Found PHY addr: %d%s\n", bgmac->phyaddr,
-		   bgmac->phyaddr == BGMAC_PHY_NOREGS ? " (NOREGS)" : "");
+	dev_info(bgmac->dev, "Found PHY addr: %d%s\n", bgmac->phyaddr,
+		 bgmac->phyaddr == BGMAC_PHY_NOREGS ? " (NOREGS)" : "");
 
 	if (core->bus->hosttype == BCMA_HOSTTYPE_PCI) {
-		bgmac_err(bgmac, "PCI setup not implemented\n");
+		dev_err(bgmac->dev, "PCI setup not implemented\n");
 		err = -ENOTSUPP;
 		goto err_netdev_free;
 	}
@@ -1765,7 +1768,7 @@ static int bgmac_probe(struct bcma_device *core)
 
 	err = bgmac_dma_alloc(bgmac);
 	if (err) {
-		bgmac_err(bgmac, "Unable to alloc memory for DMA\n");
+		dev_err(bgmac->dev, "Unable to alloc memory for DMA\n");
 		goto err_netdev_free;
 	}
 
@@ -1779,16 +1782,16 @@ static int bgmac_probe(struct bcma_device *core)
 	bgmac->has_robosw = !!(core->bus->sprom.boardflags_lo &
 			       BGMAC_BFL_ENETROBO);
 	if (bgmac->has_robosw)
-		bgmac_warn(bgmac, "Support for Roboswitch not implemented\n");
+		dev_warn(bgmac->dev, "Support for Roboswitch not implemented\n");
 
 	if (core->bus->sprom.boardflags_lo & BGMAC_BFL_ENETADM)
-		bgmac_warn(bgmac, "Support for ADMtek ethernet switch not implemented\n");
+		dev_warn(bgmac->dev, "Support for ADMtek ethernet switch not implemented\n");
 
 	netif_napi_add(net_dev, &bgmac->napi, bgmac_poll, BGMAC_WEIGHT);
 
 	err = bgmac_mii_register(bgmac);
 	if (err) {
-		bgmac_err(bgmac, "Cannot register MDIO\n");
+		dev_err(bgmac->dev, "Cannot connect to phy\n");
 		goto err_dma_free;
 	}
 
@@ -1798,7 +1801,7 @@ static int bgmac_probe(struct bcma_device *core)
 
 	err = register_netdev(bgmac->net_dev);
 	if (err) {
-		bgmac_err(bgmac, "Cannot register net device\n");
+		dev_err(bgmac->dev, "Cannot register net device\n");
 		goto err_mii_unregister;
 	}
 
drivers/net/ethernet/broadcom/bgmac.h +2 -12
index 99beb18..abb9dd8 100644
@@ -1,17 +1,6 @@
 #ifndef _BGMAC_H
 #define _BGMAC_H
 
-#define pr_fmt(fmt)		KBUILD_MODNAME ": " fmt
-
-#define bgmac_err(bgmac, fmt, ...) \
-	dev_err(&(bgmac)->core->dev, fmt, ##__VA_ARGS__)
-#define bgmac_warn(bgmac, fmt, ...) \
-	dev_warn(&(bgmac)->core->dev, fmt,  ##__VA_ARGS__)
-#define bgmac_info(bgmac, fmt, ...) \
-	dev_info(&(bgmac)->core->dev, fmt,  ##__VA_ARGS__)
-#define bgmac_dbg(bgmac, fmt, ...) \
-	dev_dbg(&(bgmac)->core->dev, fmt, ##__VA_ARGS__)
-
 #include <linux/bcma/bcma.h>
 #include <linux/brcmphy.h>
 #include <linux/netdevice.h>
@@ -438,6 +427,8 @@ struct bgmac_rx_header {
 struct bgmac {
 	struct bcma_device *core;
 	struct bcma_device *cmn; /* Reference to CMN core for BCM4706 */
+
+	struct device *dev;
 	struct net_device *net_dev;
 	struct napi_struct napi;
 	struct mii_bus *mii_bus;
@@ -489,5 +480,4 @@ static inline void bgmac_set(struct bgmac *bgmac, u16 offset, u32 set)
 {
 	bgmac_maskset(bgmac, offset, ~0, set);
 }
-
 #endif /* _BGMAC_H */
Signature · 1 line
1.9.1
author
#2 lore raw

PATCH 2/7 net: ethernet: bgmac: add dma_dev pointer

In reply to Jon Mason

The dma buffer allocation, etc references a dma_dev device pointer from the bcma core. In anticipation of removing the bcma requirement for this driver, these must be changed to not reference that struct. Add a dma_dev device pointer to the bgmac stuct and reference that instead.

---
 drivers/net/ethernet/broadcom/bgmac.c | 17 +++++++++--------
 drivers/net/ethernet/broadcom/bgmac.h |  1 +
 2 files changed, 10 insertions(+), 8 deletions(-)
drivers/net/ethernet/broadcom/bgmac.c +9 -8
index 37b3b68..3614bd8 100644
@@ -152,7 +152,7 @@ static netdev_tx_t bgmac_dma_tx_add(struct bgmac *bgmac,
 				    struct bgmac_dma_ring *ring,
 				    struct sk_buff *skb)
 {
-	struct device *dma_dev = bgmac->core->dma_dev;
+	struct device *dma_dev = bgmac->dma_dev;
 	struct net_device *net_dev = bgmac->net_dev;
 	int index = ring->end % BGMAC_TX_RING_SLOTS;
 	struct bgmac_slot_info *slot = &ring->slots[index];
@@ -254,7 +254,7 @@ err_drop:
 /* Free transmitted packets */
 static void bgmac_dma_tx_free(struct bgmac *bgmac, struct bgmac_dma_ring *ring)
 {
-	struct device *dma_dev = bgmac->core->dma_dev;
+	struct device *dma_dev = bgmac->dma_dev;
 	int empty_slot;
 	bool freed = false;
 	unsigned bytes_compl = 0, pkts_compl = 0;
@@ -351,7 +351,7 @@ static void bgmac_dma_rx_enable(struct bgmac *bgmac,
 static int bgmac_dma_rx_skb_for_slot(struct bgmac *bgmac,
 				     struct bgmac_slot_info *slot)
 {
-	struct device *dma_dev = bgmac->core->dma_dev;
+	struct device *dma_dev = bgmac->dma_dev;
 	dma_addr_t dma_addr;
 	struct bgmac_rx_header *rx;
 	void *buf;
@@ -440,7 +440,7 @@ static int bgmac_dma_rx_read(struct bgmac *bgmac, struct bgmac_dma_ring *ring,
 	end_slot /= sizeof(struct bgmac_dma_desc);
 
 	while (ring->start != end_slot) {
-		struct device *dma_dev = bgmac->core->dma_dev;
+		struct device *dma_dev = bgmac->dma_dev;
 		struct bgmac_slot_info *slot = &ring->slots[ring->start];
 		struct bgmac_rx_header *rx = slot->buf + BGMAC_RX_BUF_OFFSET;
 		struct sk_buff *skb;
@@ -543,7 +543,7 @@ static bool bgmac_dma_unaligned(struct bgmac *bgmac,
 static void bgmac_dma_tx_ring_free(struct bgmac *bgmac,
 				   struct bgmac_dma_ring *ring)
 {
-	struct device *dma_dev = bgmac->core->dma_dev;
+	struct device *dma_dev = bgmac->dma_dev;
 	struct bgmac_dma_desc *dma_desc = ring->cpu_base;
 	struct bgmac_slot_info *slot;
 	int i;
@@ -569,7 +569,7 @@ static void bgmac_dma_tx_ring_free(struct bgmac *bgmac,
 static void bgmac_dma_rx_ring_free(struct bgmac *bgmac,
 				   struct bgmac_dma_ring *ring)
 {
-	struct device *dma_dev = bgmac->core->dma_dev;
+	struct device *dma_dev = bgmac->dma_dev;
 	struct bgmac_slot_info *slot;
 	int i;
 
@@ -590,7 +590,7 @@ static void bgmac_dma_ring_desc_free(struct bgmac *bgmac,
 				     struct bgmac_dma_ring *ring,
 				     int num_slots)
 {
-	struct device *dma_dev = bgmac->core->dma_dev;
+	struct device *dma_dev = bgmac->dma_dev;
 	int size;
 
 	if (!ring->cpu_base)
@@ -628,7 +628,7 @@ static void bgmac_dma_free(struct bgmac *bgmac)
 
 static int bgmac_dma_alloc(struct bgmac *bgmac)
 {
-	struct device *dma_dev = bgmac->core->dma_dev;
+	struct device *dma_dev = bgmac->dma_dev;
 	struct bgmac_dma_ring *ring;
 	static const u16 ring_base[] = { BGMAC_DMA_BASE0, BGMAC_DMA_BASE1,
 					 BGMAC_DMA_BASE2, BGMAC_DMA_BASE3, };
@@ -1701,6 +1701,7 @@ static int bgmac_probe(struct bcma_device *core)
 	net_dev->ethtool_ops = &bgmac_ethtool_ops;
 	bgmac = netdev_priv(net_dev);
 	bgmac->dev = &core->dev;
+	bgmac->dma_dev = core->dma_dev;
 	bgmac->net_dev = net_dev;
 	bgmac->core = core;
 	bcma_set_drvdata(core, bgmac);
drivers/net/ethernet/broadcom/bgmac.h +1 -0
index abb9dd8..fd20018 100644
@@ -429,6 +429,7 @@ struct bgmac {
 	struct bcma_device *cmn; /* Reference to CMN core for BCM4706 */
 
 	struct device *dev;
+	struct device *dma_dev;
 	struct net_device *net_dev;
 	struct napi_struct napi;
 	struct mii_bus *mii_bus;
Signature · 1 line
1.9.1
author
#3 lore raw

PATCH 3/7 net: ethernet: bgmac: move BCMA MDIO Phy code into a separate file

In reply to Jon Mason

Move the BCMA MDIO phy into a separate file, as it is very tightly coupled with the BCMA bus. This will help with the upcoming BCMA removal from the bgmac driver. Optimally, this should be moved into phy drivers, but it is too tightly coupled with the bgmac driver to effectively move it without more changes to the driver.

Note: the phy_reset was intentionally removed, as the mdio phy subsystem automatically resets the phy if a reset function pointer is present. In addition to the moving of the driver, this reset function is added.

---
 drivers/net/ethernet/broadcom/Makefile          |   2 +-
 drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c | 264 ++++++++++++++++++++++++
 drivers/net/ethernet/broadcom/bgmac.c           | 246 +++-------------------
 drivers/net/ethernet/broadcom/bgmac.h           |   3 +
 4 files changed, 298 insertions(+), 217 deletions(-)
 create mode 100644 drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c
drivers/net/ethernet/broadcom/Makefile +1 -1
index 00584d7..f559794 100644
@@ -10,6 +10,6 @@ obj-$(CONFIG_CNIC) += cnic.o
 obj-$(CONFIG_BNX2X) += bnx2x/
 obj-$(CONFIG_SB1250_MAC) += sb1250-mac.o
 obj-$(CONFIG_TIGON3) += tg3.o
-obj-$(CONFIG_BGMAC) += bgmac.o
+obj-$(CONFIG_BGMAC) += bgmac.o bgmac-bcma-mdio.o
 obj-$(CONFIG_SYSTEMPORT) += bcmsysport.o
 obj-$(CONFIG_BNXT) += bnxt/
drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c new file +264 -0

264 lines not on this page · raw message

drivers/net/ethernet/broadcom/bgmac.c +30 -216

325 lines not on this page · raw message

drivers/net/ethernet/broadcom/bgmac.h +3 -0
index fd20018..191e64a 100644
@@ -456,6 +456,9 @@ struct bgmac {
 	bool loopback;
 };
 
+struct mii_bus *bcma_mdio_mii_register(struct bcma_device *core, u8 phyaddr);
+void bcma_mdio_mii_unregister(struct mii_bus *mii_bus);
+
 static inline u32 bgmac_read(struct bgmac *bgmac, u16 offset)
 {
 	return bcma_read32(bgmac->core, offset);
Signature · 1 line
1.9.1
author
#4 lore raw

PATCH 4/7 net: ethernet: bgmac: convert to feature flags

In reply to Jon Mason

The bgmac driver is using the bcma provides device ID and revision, as well as the SoC ID and package, to determine which features are
necessary to enable, reset, etc in the driver. In anticipation of
removing the bcma requirement for this driver, these must be changed to not reference that struct. In place of that, each "feature" has been given a flag, and the flags are enabled for their respective device and SoC.

---
 drivers/net/ethernet/broadcom/bgmac.c | 167 ++++++++++++++++++++++++----------
 drivers/net/ethernet/broadcom/bgmac.h |  21 ++++-
 2 files changed, 140 insertions(+), 48 deletions(-)
drivers/net/ethernet/broadcom/bgmac.c +120 -47
index 6c6bb18..b85e39a 100644
@@ -109,7 +109,7 @@ static void bgmac_dma_tx_enable(struct bgmac *bgmac,
 	u32 ctl;
 
 	ctl = bgmac_read(bgmac, ring->mmio_base + BGMAC_DMA_TX_CTL);
-	if (bgmac->core->id.rev >= 4) {
+	if (bgmac->feature_flags & BGMAC_FEAT_TX_MASK_SETUP) {
 		ctl &= ~BGMAC_DMA_TX_BL_MASK;
 		ctl |= BGMAC_DMA_TX_BL_128 << BGMAC_DMA_TX_BL_SHIFT;
 
@@ -330,7 +330,7 @@ static void bgmac_dma_rx_enable(struct bgmac *bgmac,
 	u32 ctl;
 
 	ctl = bgmac_read(bgmac, ring->mmio_base + BGMAC_DMA_RX_CTL);
-	if (bgmac->core->id.rev >= 4) {
+	if (bgmac->feature_flags & BGMAC_FEAT_RX_MASK_SETUP) {
 		ctl &= ~BGMAC_DMA_RX_BL_MASK;
 		ctl |= BGMAC_DMA_RX_BL_128 << BGMAC_DMA_RX_BL_SHIFT;
 
@@ -768,14 +768,20 @@ static void bgmac_cmdcfg_maskset(struct bgmac *bgmac, u32 mask, u32 set,
 {
 	u32 cmdcfg = bgmac_read(bgmac, BGMAC_CMDCFG);
 	u32 new_val = (cmdcfg & mask) | set;
+	u32 cmdcfg_sr;
 
-	bgmac_set(bgmac, BGMAC_CMDCFG, BGMAC_CMDCFG_SR(bgmac->core->id.rev));
+	if (bgmac->feature_flags & BGMAC_FEAT_CMDCFG_SR_REV4)
+		cmdcfg_sr = BGMAC_CMDCFG_SR_REV4;
+	else
+		cmdcfg_sr = BGMAC_CMDCFG_SR_REV0;
+
+	bgmac_set(bgmac, BGMAC_CMDCFG, cmdcfg_sr);
 	udelay(2);
 
 	if (new_val != cmdcfg || force)
 		bgmac_write(bgmac, BGMAC_CMDCFG, new_val);
 
-	bgmac_mask(bgmac, BGMAC_CMDCFG, ~BGMAC_CMDCFG_SR(bgmac->core->id.rev));
+	bgmac_mask(bgmac, BGMAC_CMDCFG, ~cmdcfg_sr);
 	udelay(2);
 }
 
@@ -804,7 +810,7 @@ static void bgmac_chip_stats_update(struct bgmac *bgmac)
 {
 	int i;
 
-	if (bgmac->core->id.id != BCMA_CORE_4706_MAC_GBIT) {
+	if (!(bgmac->feature_flags & BGMAC_FEAT_NO_CLR_MIB)) {
 		for (i = 0; i < BGMAC_NUM_MIB_TX_REGS; i++)
 			bgmac->mib_tx_regs[i] =
 				bgmac_read(bgmac,
@@ -823,7 +829,7 @@ static void bgmac_clear_mib(struct bgmac *bgmac)
 {
 	int i;
 
-	if (bgmac->core->id.id == BCMA_CORE_4706_MAC_GBIT)
+	if (bgmac->feature_flags & BGMAC_FEAT_NO_CLR_MIB)
 		return;
 
 	bgmac_set(bgmac, BGMAC_DEV_CTL, BGMAC_DC_MROR);
@@ -866,9 +872,8 @@ static void bgmac_mac_speed(struct bgmac *bgmac)
 static void bgmac_miiconfig(struct bgmac *bgmac)
 {
 	struct bcma_device *core = bgmac->core;
-	u8 imode;
 
-	if (bgmac_is_bcm4707_family(bgmac)) {
+	if (bgmac->feature_flags & BGMAC_FEAT_FORCE_SPEED_2500) {
 		bcma_awrite32(core, BCMA_IOCTL,
 			      bcma_aread32(core, BCMA_IOCTL) | 0x40 |
 			      BGMAC_BCMA_IOCTL_SW_CLKEN);
@@ -876,6 +881,8 @@ static void bgmac_miiconfig(struct bgmac *bgmac)
 		bgmac->mac_duplex = DUPLEX_FULL;
 		bgmac_mac_speed(bgmac);
 	} else {
+		u8 imode;
+
 		imode = (bgmac_read(bgmac, BGMAC_DEV_STATUS) &
 			BGMAC_DS_MM_MASK) >> BGMAC_DS_MM_SHIFT;
 		if (imode == 0 || imode == 1) {
@@ -890,9 +897,7 @@ static void bgmac_miiconfig(struct bgmac *bgmac)
 static void bgmac_chip_reset(struct bgmac *bgmac)
 {
 	struct bcma_device *core = bgmac->core;
-	struct bcma_bus *bus = core->bus;
-	struct bcma_chipinfo *ci = &bus->chipinfo;
-	u32 flags;
+	u32 cmdcfg_sr;
 	u32 iost;
 	int i;
 
@@ -915,15 +920,12 @@ static void bgmac_chip_reset(struct bgmac *bgmac)
 	}
 
 	iost = bcma_aread32(core, BCMA_IOST);
-	if ((ci->id == BCMA_CHIP_ID_BCM5357 && ci->pkg == BCMA_PKG_ID_BCM47186) ||
-	    (ci->id == BCMA_CHIP_ID_BCM4749 && ci->pkg == 10) ||
-	    (ci->id == BCMA_CHIP_ID_BCM53572 && ci->pkg == BCMA_PKG_ID_BCM47188))
+	if (bgmac->feature_flags & BGMAC_FEAT_IOST_ATTACHED)
 		iost &= ~BGMAC_BCMA_IOST_ATTACHED;
 
 	/* 3GMAC: for BCM4707 & BCM47094, only do core reset at bgmac_probe() */
-	if (ci->id != BCMA_CHIP_ID_BCM4707 &&
-	    ci->id != BCMA_CHIP_ID_BCM47094) {
-		flags = 0;
+	if (!(bgmac->feature_flags & BGMAC_FEAT_NO_RESET)) {
+		u32 flags = 0;
 		if (iost & BGMAC_BCMA_IOST_ATTACHED) {
 			flags = BGMAC_BCMA_IOCTL_SW_CLKEN;
 			if (!bgmac->has_robosw)
@@ -933,7 +935,7 @@ static void bgmac_chip_reset(struct bgmac *bgmac)
 	}
 
 	/* Request Misc PLL for corerev > 2 */
-	if (core->id.rev > 2 && !bgmac_is_bcm4707_family(bgmac)) {
+	if (bgmac->feature_flags & BGMAC_FEAT_MISC_PLL_REQ) {
 		bgmac_set(bgmac, BCMA_CLKCTLST,
 			  BGMAC_BCMA_CLKCTLST_MISC_PLL_REQ);
 		bgmac_wait_value(bgmac->core, BCMA_CLKCTLST,
@@ -942,9 +944,7 @@ static void bgmac_chip_reset(struct bgmac *bgmac)
 				 1000);
 	}
 
-	if (ci->id == BCMA_CHIP_ID_BCM5357 ||
-	    ci->id == BCMA_CHIP_ID_BCM4749 ||
-	    ci->id == BCMA_CHIP_ID_BCM53572) {
+	if (bgmac->feature_flags & BGMAC_FEAT_SW_TYPE_PHY) {
 		struct bcma_drv_cc *cc = &bgmac->core->bus->drv_cc;
 		u8 et_swtype = 0;
 		u8 sw_type = BGMAC_CHIPCTL_1_SW_TYPE_EPHY |
@@ -958,11 +958,9 @@ static void bgmac_chip_reset(struct bgmac *bgmac)
 			et_swtype &= 0x0f;
 			et_swtype <<= 4;
 			sw_type = et_swtype;
-		} else if (ci->id == BCMA_CHIP_ID_BCM5357 && ci->pkg == BCMA_PKG_ID_BCM5358) {
+		} else if (bgmac->feature_flags & BGMAC_FEAT_SW_TYPE_EPHYRMII) {
 			sw_type = BGMAC_CHIPCTL_1_SW_TYPE_EPHYRMII;
-		} else if ((ci->id == BCMA_CHIP_ID_BCM5357 && ci->pkg == BCMA_PKG_ID_BCM47186) ||
-			   (ci->id == BCMA_CHIP_ID_BCM4749 && ci->pkg == 10) ||
-			   (ci->id == BCMA_CHIP_ID_BCM53572 && ci->pkg == BCMA_PKG_ID_BCM47188)) {
+		} else if (bgmac->feature_flags & BGMAC_FEAT_SW_TYPE_RGMII) {
 			sw_type = BGMAC_CHIPCTL_1_IF_TYPE_RGMII |
 				  BGMAC_CHIPCTL_1_SW_TYPE_RGMII;
 		}
@@ -982,6 +980,11 @@ static void bgmac_chip_reset(struct bgmac *bgmac)
 	 * BGMAC_CMDCFG is read _after_ putting chip in a reset. So it has to
 	 * be keps until taking MAC out of the reset.
 	 */
+	if (bgmac->feature_flags & BGMAC_FEAT_CMDCFG_SR_REV4)
+		cmdcfg_sr = BGMAC_CMDCFG_SR_REV4;
+	else
+		cmdcfg_sr = BGMAC_CMDCFG_SR_REV0;
+
 	bgmac_cmdcfg_maskset(bgmac,
 			     ~(BGMAC_CMDCFG_TE |
 			       BGMAC_CMDCFG_RE |
@@ -999,13 +1002,13 @@ static void bgmac_chip_reset(struct bgmac *bgmac)
 			     BGMAC_CMDCFG_PROM |
 			     BGMAC_CMDCFG_NLC |
 			     BGMAC_CMDCFG_CFE |
-			     BGMAC_CMDCFG_SR(core->id.rev),
+			     cmdcfg_sr,
 			     false);
 	bgmac->mac_speed = SPEED_UNKNOWN;
 	bgmac->mac_duplex = DUPLEX_UNKNOWN;
 
 	bgmac_clear_mib(bgmac);
-	if (core->id.id == BCMA_CORE_4706_MAC_GBIT)
+	if (bgmac->feature_flags & BGMAC_FEAT_CMN_PHY_CTL)
 		bcma_maskset32(bgmac->cmn, BCMA_GMAC_CMN_PHY_CTL, ~0,
 			       BCMA_GMAC_CMN_PC_MTE);
 	else
@@ -1031,46 +1034,48 @@ static void bgmac_chip_intrs_off(struct bgmac *bgmac)
 /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/gmac_enable */
 static void bgmac_enable(struct bgmac *bgmac)
 {
-	struct bcma_chipinfo *ci = &bgmac->core->bus->chipinfo;
+	u32 cmdcfg_sr;
 	u32 cmdcfg;
 	u32 mode;
-	u32 rxq_ctl;
-	u32 fl_ctl;
-	u16 bp_clk;
-	u8 mdp;
+
+	if (bgmac->feature_flags & BGMAC_FEAT_CMDCFG_SR_REV4)
+		cmdcfg_sr = BGMAC_CMDCFG_SR_REV4;
+	else
+		cmdcfg_sr = BGMAC_CMDCFG_SR_REV0;
 
 	cmdcfg = bgmac_read(bgmac, BGMAC_CMDCFG);
 	bgmac_cmdcfg_maskset(bgmac, ~(BGMAC_CMDCFG_TE | BGMAC_CMDCFG_RE),
-			     BGMAC_CMDCFG_SR(bgmac->core->id.rev), true);
+			     cmdcfg_sr, true);
 	udelay(2);
 	cmdcfg |= BGMAC_CMDCFG_TE | BGMAC_CMDCFG_RE;
 	bgmac_write(bgmac, BGMAC_CMDCFG, cmdcfg);
 
 	mode = (bgmac_read(bgmac, BGMAC_DEV_STATUS) & BGMAC_DS_MM_MASK) >>
 		BGMAC_DS_MM_SHIFT;
-	if (ci->id != BCMA_CHIP_ID_BCM47162 || mode != 0)
+	if (bgmac->feature_flags & BGMAC_FEAT_CLKCTLST || mode != 0)
 		bgmac_set(bgmac, BCMA_CLKCTLST, BCMA_CLKCTLST_FORCEHT);
-	if (ci->id == BCMA_CHIP_ID_BCM47162 && mode == 2)
+	if (bgmac->feature_flags & BGMAC_FEAT_CLKCTLST && mode == 2)
 		bcma_chipco_chipctl_maskset(&bgmac->core->bus->drv_cc, 1, ~0,
 					    BGMAC_CHIPCTL_1_RXC_DLL_BYPASS);
 
-	switch (ci->id) {
-	case BCMA_CHIP_ID_BCM5357:
-	case BCMA_CHIP_ID_BCM4749:
-	case BCMA_CHIP_ID_BCM53572:
-	case BCMA_CHIP_ID_BCM4716:
-	case BCMA_CHIP_ID_BCM47162:
-		fl_ctl = 0x03cb04cb;
-		if (ci->id == BCMA_CHIP_ID_BCM5357 ||
-		    ci->id == BCMA_CHIP_ID_BCM4749 ||
-		    ci->id == BCMA_CHIP_ID_BCM53572)
+	if (bgmac->feature_flags & (BGMAC_FEAT_FLW_CTRL1 |
+				    BGMAC_FEAT_FLW_CTRL2)) {
+		u32 fl_ctl;
+
+		if (bgmac->feature_flags & BGMAC_FEAT_FLW_CTRL1)
 			fl_ctl = 0x2300e1;
+		else
+			fl_ctl = 0x03cb04cb;
+
 		bgmac_write(bgmac, BGMAC_FLOW_CTL_THRESH, fl_ctl);
 		bgmac_write(bgmac, BGMAC_PAUSE_CTL, 0x27fff);
-		break;
 	}
 
-	if (!bgmac_is_bcm4707_family(bgmac)) {
+	if (bgmac->feature_flags & BGMAC_FEAT_SET_RXQ_CLK) {
+		u32 rxq_ctl;
+		u16 bp_clk;
+		u8 mdp;
+
 		rxq_ctl = bgmac_read(bgmac, BGMAC_RXQ_CTL);
 		rxq_ctl &= ~BGMAC_RXQ_CTL_MDP_MASK;
 		bp_clk = bcma_pmu_get_bus_clock(&bgmac->core->bus->drv_cc) /
@@ -1585,6 +1590,74 @@ static int bgmac_probe(struct bcma_device *core)
 	if (core->bus->sprom.boardflags_lo & BGMAC_BFL_ENETADM)
 		dev_warn(bgmac->dev, "Support for ADMtek ethernet switch not implemented\n");
 
+	/* Feature Flags */
+	switch (core->bus->chipinfo.id) {
+	case BCMA_CHIP_ID_BCM5357:
+		bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
+		bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
+		bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL1;
+		bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_PHY;
+		if (core->bus->chipinfo.pkg == BCMA_PKG_ID_BCM47186) {
+			bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED;
+			bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_RGMII;
+		}
+		if (core->bus->chipinfo.pkg == BCMA_PKG_ID_BCM5358)
+			bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_EPHYRMII;
+		break;
+	case BCMA_CHIP_ID_BCM53572:
+		bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
+		bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
+		bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL1;
+		bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_PHY;
+		if (core->bus->chipinfo.pkg == BCMA_PKG_ID_BCM47188) {
+			bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_RGMII;
+			bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED;
+		}
+		break;
+	case BCMA_CHIP_ID_BCM4749:
+		bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
+		bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
+		bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL1;
+		bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_PHY;
+		if (core->bus->chipinfo.pkg == 10) {
+			bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_RGMII;
+			bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED;
+		}
+		break;
+	case BCMA_CHIP_ID_BCM4716:
+		bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
+		/* fallthrough */
+	case BCMA_CHIP_ID_BCM47162:
+		bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL2;
+		bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
+		break;
+	/* bcm4707_family */
+	case BCMA_CHIP_ID_BCM4707:
+	case BCMA_CHIP_ID_BCM47094:
+	case BCMA_CHIP_ID_BCM53018:
+		bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
+		bgmac->feature_flags |= BGMAC_FEAT_NO_RESET;
+		bgmac->feature_flags |= BGMAC_FEAT_FORCE_SPEED_2500;
+		break;
+	default:
+		bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
+		bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
+	}
+
+	if (!bgmac_is_bcm4707_family(bgmac) && core->id.rev > 2)
+		bgmac->feature_flags |= BGMAC_FEAT_MISC_PLL_REQ;
+
+	if (core->id.id == BCMA_CORE_4706_MAC_GBIT) {
+		bgmac->feature_flags |= BGMAC_FEAT_CMN_PHY_CTL;
+		bgmac->feature_flags |= BGMAC_FEAT_NO_CLR_MIB;
+	}
+
+	if (core->id.rev >= 4) {
+		bgmac->feature_flags |= BGMAC_FEAT_CMDCFG_SR_REV4;
+		bgmac->feature_flags |= BGMAC_FEAT_TX_MASK_SETUP;
+		bgmac->feature_flags |= BGMAC_FEAT_RX_MASK_SETUP;
+	}
+
 	netif_napi_add(net_dev, &bgmac->napi, bgmac_poll, BGMAC_WEIGHT);
 
 	if (!bgmac_is_bcm4707_family(bgmac)) {
drivers/net/ethernet/broadcom/bgmac.h +20 -1
index 191e64a..89dfee1 100644
@@ -190,7 +190,6 @@
 #define  BGMAC_CMDCFG_HD_SHIFT			10
 #define  BGMAC_CMDCFG_SR_REV0			0x00000800	/* Set to reset mode, for core rev 0-3 */
 #define  BGMAC_CMDCFG_SR_REV4			0x00002000	/* Set to reset mode, for core rev >= 4 */
-#define  BGMAC_CMDCFG_SR(rev)  ((rev >= 4) ? BGMAC_CMDCFG_SR_REV4 : BGMAC_CMDCFG_SR_REV0)
 #define  BGMAC_CMDCFG_ML			0x00008000	/* Set to activate mac loopback mode */
 #define  BGMAC_CMDCFG_AE			0x00400000
 #define  BGMAC_CMDCFG_CFE			0x00800000
@@ -376,6 +375,24 @@
 
 #define ETHER_MAX_LEN   1518
 
+/* Feature Flags */
+#define BGMAC_FEAT_TX_MASK_SETUP	BIT(0)
+#define BGMAC_FEAT_RX_MASK_SETUP	BIT(1)
+#define BGMAC_FEAT_IOST_ATTACHED	BIT(2)
+#define BGMAC_FEAT_NO_RESET		BIT(3)
+#define BGMAC_FEAT_MISC_PLL_REQ		BIT(4)
+#define BGMAC_FEAT_SW_TYPE_PHY		BIT(5)
+#define BGMAC_FEAT_SW_TYPE_EPHYRMII	BIT(6)
+#define BGMAC_FEAT_SW_TYPE_RGMII	BIT(7)
+#define BGMAC_FEAT_CMN_PHY_CTL		BIT(8)
+#define BGMAC_FEAT_FLW_CTRL1		BIT(9)
+#define BGMAC_FEAT_FLW_CTRL2		BIT(10)
+#define BGMAC_FEAT_SET_RXQ_CLK		BIT(11)
+#define BGMAC_FEAT_CLKCTLST		BIT(12)
+#define BGMAC_FEAT_NO_CLR_MIB		BIT(13)
+#define BGMAC_FEAT_FORCE_SPEED_2500	BIT(14)
+#define BGMAC_FEAT_CMDCFG_SR_REV4	BIT(15)
+
 struct bgmac_slot_info {
 	union {
 		struct sk_buff *skb;
@@ -430,6 +447,8 @@ struct bgmac {
 
 	struct device *dev;
 	struct device *dma_dev;
+	u32 feature_flags;
+
 	struct net_device *net_dev;
 	struct napi_struct napi;
 	struct mii_bus *mii_bus;
Signature · 1 line
1.9.1
author
#5 lore raw

PATCH 5/7 net: ethernet: bgmac: Add platform device support

In reply to Jon Mason

The bcma portion of the driver has been split off into a bcma specific driver. This has been mirrored for the platform driver. The last references to the bcma core struct have been changed into a generic function call. These function calls are wrappers to either the original bcma code or new platform functions that access the same areas via MMIO. This necessitated adding function pointers for both platform and bcma to hide which backend is being used from the generic bgmac code.

---
 drivers/net/ethernet/broadcom/Kconfig           |  23 +-
 drivers/net/ethernet/broadcom/Makefile          |   4 +-
 drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c |   2 +
 drivers/net/ethernet/broadcom/bgmac-bcma.c      | 315 +++++++++++++++++++++++
 drivers/net/ethernet/broadcom/bgmac-platform.c  | 210 +++++++++++++++
 drivers/net/ethernet/broadcom/bgmac.c           | 329 ++++--------------------
 drivers/net/ethernet/broadcom/bgmac.h           |  73 +++++-
 7 files changed, 671 insertions(+), 285 deletions(-)
 create mode 100644 drivers/net/ethernet/broadcom/bgmac-bcma.c
 create mode 100644 drivers/net/ethernet/broadcom/bgmac-platform.c
drivers/net/ethernet/broadcom/Kconfig +22 -1
index d74a92e..bd8c80c 100644
@@ -140,10 +140,18 @@ config BNX2X_SRIOV
 	  allows for virtual function acceleration in virtual environments.
 
 config BGMAC
-	tristate "BCMA bus GBit core support"
+	tristate
+	help
+	  This enables the integrated ethernet controller support for many
+	  Broadcom (mostly iProc) SoCs. An appropriate bus interface driver
+	  needs to be enabled to select this.
+
+config BGMAC_BCMA
+	tristate "Broadcom iProc GBit BCMA support"
 	depends on BCMA && BCMA_HOST_SOC
 	depends on HAS_DMA
 	depends on BCM47XX || ARCH_BCM_5301X || COMPILE_TEST
+	select BGMAC
 	select PHYLIB
 	select FIXED_PHY
 	---help---
@@ -152,6 +160,19 @@ config BGMAC
 	  In case of using this driver on BCM4706 it's also requires to enable
 	  BCMA_DRIVER_GMAC_CMN to make it work.
 
+config BGMAC_PLATFORM
+	tristate "Broadcom iProc GBit platform support"
+	depends on HAS_DMA
+	depends on ARCH_BCM_IPROC || COMPILE_TEST
+	depends on OF
+	select BGMAC
+	select PHYLIB
+	select FIXED_PHY
+	default ARCH_BCM_IPROC
+	---help---
+	  Say Y here if you want to use the Broadcom iProc Gigabit Ethernet
+	  controller through the generic platform interface
+
 config SYSTEMPORT
 	tristate "Broadcom SYSTEMPORT internal MAC support"
 	depends on OF
drivers/net/ethernet/broadcom/Makefile +3 -1
index f559794..79f2372 100644
@@ -10,6 +10,8 @@ obj-$(CONFIG_CNIC) += cnic.o
 obj-$(CONFIG_BNX2X) += bnx2x/
 obj-$(CONFIG_SB1250_MAC) += sb1250-mac.o
 obj-$(CONFIG_TIGON3) += tg3.o
-obj-$(CONFIG_BGMAC) += bgmac.o bgmac-bcma-mdio.o
+obj-$(CONFIG_BGMAC) += bgmac.o
+obj-$(CONFIG_BGMAC_BCMA) += bgmac-bcma.o bgmac-bcma-mdio.o
+obj-$(CONFIG_BGMAC_PLATFORM) += bgmac-platform.o
 obj-$(CONFIG_SYSTEMPORT) += bcmsysport.o
 obj-$(CONFIG_BNXT) += bnxt/
drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c +2 -0
index 1e65349..7c19c8e 100644
@@ -245,6 +245,7 @@ err:
 	kfree(bcma_mdio);
 	return ERR_PTR(err);
 }
+EXPORT_SYMBOL_GPL(bcma_mdio_mii_register);
 
 void bcma_mdio_mii_unregister(struct mii_bus *mii_bus)
 {
@@ -259,6 +260,7 @@ void bcma_mdio_mii_unregister(struct mii_bus *mii_bus)
 	mdiobus_free(mii_bus);
 	kfree(bcma_mdio);
 }
+EXPORT_SYMBOL_GPL(bcma_mdio_mii_unregister);
 
 MODULE_AUTHOR("Rafa? Mi?ecki");
 MODULE_LICENSE("GPL");
drivers/net/ethernet/broadcom/bgmac-bcma.c new file +315 -0

315 lines not on this page · raw message

drivers/net/ethernet/broadcom/bgmac-platform.c new file +210 -0

210 lines not on this page · raw message

drivers/net/ethernet/broadcom/bgmac.c +52 -277

512 lines not on this page · raw message

drivers/net/ethernet/broadcom/bgmac.h +67 -6

111 lines not on this page · raw message

Signature · 1 line
1.9.1
#6 lore raw

[snip]

+

drivers/net/ethernet/broadcom/bgmac-platform.c line 176

Quoted 8 lines
drivers/net/ethernet/broadcom/bgmac-platform.c new file +8 -0
+	return 0;
+
+err2:
+	devm_iounmap(&pdev->dev, bgmac->plat.idm_base);
+err1:
+	devm_iounmap(&pdev->dev, bgmac->plat.base);
+err:
+	devm_kfree(&pdev->dev, bgmac);

This is not needed actually, now that you use the device managed helper functions.

drivers/net/ethernet/broadcom/bgmac-platform.c line 188

Quoted 12 lines
drivers/net/ethernet/broadcom/bgmac-platform.c new file +12 -0
+
+	return rc;
+}
+
+static int bgmac_remove(struct platform_device *pdev)
+{
+	struct bgmac *bgmac = platform_get_drvdata(pdev);
+
+	bgmac_enet_remove(bgmac);
+	devm_iounmap(&pdev->dev, bgmac->plat.idm_base);
+	devm_iounmap(&pdev->dev, bgmac->plat.base);
+	devm_kfree(&pdev->dev, bgmac);

Same here.

Signature · 1 line
Florian
author
#7 lore raw

PATCH 6/7 dt-bindings: net: bgmac: add bindings documentation for bgmac

In reply to Jon Mason
---
 .../devicetree/bindings/net/brcm,bgmac-nsp.txt     | 24 ++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/brcm,bgmac-nsp.txt
Documentation/devicetree/bindings/net/brcm,bgmac-nsp.txt new file +24 -0
new file mode 100644
index 0000000..022946c
@@ -0,0 +1,24 @@
+Broadcom GMAC Ethernet Controller Device Tree Bindings
+-------------------------------------------------------------
+
+Required properties:
+ - compatible:	"brcm,bgmac-nsp"
+ - reg:		Address and length of the GMAC registers,
+		Address and length of the GMAC IDM registers
+ - reg-names:	Names of the registers.  Must have both "gmac_base" and
+		"idm_base"
+ - interrupts:	Interrupt number
+
+Optional properties:
+- mac-address:	See ethernet.txt file in the same directory
+
+Examples:
+
+gmac0: ethernet at 18022000 {
+	compatible = "brcm,bgmac-nsp";
+	reg = <0x18022000 0x1000>,
+	      <0x18110000 0x1000>;
+	reg-names = "gmac_base", "idm_base";
+	interrupts = <GIC_SPI 147 IRQ_TYPE_LEVEL_HIGH>;
+	status = "disabled";
+};
Signature · 1 line
1.9.1
maintainer
#8 lore raw

Re: [PATCH 6/7] dt-bindings: net: bgmac: add bindings documentation for bgmac

Quoted 12 lines · Jon Mason
---
 .../devicetree/bindings/net/brcm,bgmac-nsp.txt     | 24 ++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/brcm,bgmac-nsp.txt
Documentation/devicetree/bindings/net/brcm,bgmac-nsp.txt new file +0 -0
new file mode 100644
index 0000000..022946c

Documentation/devicetree/bindings/net/brcm,bgmac-nsp.txt line 5

Quoted 5 lines
Documentation/devicetree/bindings/net/brcm,bgmac-nsp.txt new file +5 -0
@@ -0,0 +1,24 @@
+Broadcom GMAC Ethernet Controller Device Tree Bindings
+-------------------------------------------------------------
+
+Required properties:
+ - compatible:	"brcm,bgmac-nsp"

Usually we do <soc>-<block> order.

Quoted 22 lines
Documentation/devicetree/bindings/net/brcm,bgmac-nsp.txt new file +19 -0
+ - reg:		Address and length of the GMAC registers,
+		Address and length of the GMAC IDM registers
+ - reg-names:	Names of the registers.  Must have both "gmac_base" and
+		"idm_base"
+ - interrupts:	Interrupt number
+
+Optional properties:
+- mac-address:	See ethernet.txt file in the same directory
+
+Examples:
+
+gmac0: ethernet at 18022000 {
+	compatible = "brcm,bgmac-nsp";
+	reg = <0x18022000 0x1000>,
+	      <0x18110000 0x1000>;
+	reg-names = "gmac_base", "idm_base";
+	interrupts = <GIC_SPI 147 IRQ_TYPE_LEVEL_HIGH>;
+	status = "disabled";
+};
Signature · 1 line
1.9.1
author
#9 lore raw

Re: [PATCH 6/7] dt-bindings: net: bgmac: add bindings documentation for bgmac

Quoted 7 lines · Rob Herring
Quoted 6 lines · Jon Mason
---
 .../devicetree/bindings/net/brcm,bgmac-nsp.txt     | 24 ++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/brcm,bgmac-nsp.txt
Quoted 13 lines

Documentation/devicetree/bindings/net/brcm,bgmac-nsp.txt line 5

Quoted 11 lines
Documentation/devicetree/bindings/net/brcm,bgmac-nsp.txt new file +5 -0
new file mode 100644
index 0000000..022946c
@@ -0,0 +1,24 @@
+Broadcom GMAC Ethernet Controller Device Tree Bindings
+-------------------------------------------------------------
+
+Required properties:
+ - compatible:       "brcm,bgmac-nsp"

Usually we do <soc>-<block> order.

Thanks, I'll make the necessary changes and push out a v2.

Quoted 23 lines
Quoted 23 lines
Documentation/devicetree/bindings/net/brcm,bgmac-nsp.txt new file +19 -1
+ - reg:              Address and length of the GMAC registers,
+             Address and length of the GMAC IDM registers
+ - reg-names:        Names of the registers.  Must have both "gmac_base" and
+             "idm_base"
+ - interrupts:       Interrupt number
+
+Optional properties:
+- mac-address:       See ethernet.txt file in the same directory
+
+Examples:
+
+gmac0: ethernet at 18022000 {
+     compatible = "brcm,bgmac-nsp";
+     reg = <0x18022000 0x1000>,
+           <0x18110000 0x1000>;
+     reg-names = "gmac_base", "idm_base";
+     interrupts = <GIC_SPI 147 IRQ_TYPE_LEVEL_HIGH>;
+     status = "disabled";
+};
--

1.9.1

#10 lore raw

Re: [PATCH 6/7] dt-bindings: net: bgmac: add bindings documentation for bgmac

In reply to Jon Mason

Documentation/devicetree/bindings/net/brcm,bgmac-nsp.txt line 11

Quoted 9 lines · CEST Jon Mason
Documentation/devicetree/bindings/net/brcm,bgmac-nsp.txt new file +9 -0
+
+Required properties:
+ - compatible: "brcm,bgmac-nsp"
+ - reg:                Address and length of the GMAC registers,
+               Address and length of the GMAC IDM registers
+ - reg-names:  Names of the registers.  Must have both "gmac_base" and
+               "idm_base"
+ - interrupts: Interrupt number
+

"brcm,bgmac-nsp" sounds a bit too general. As I understand, this is a family of SoCs that might not all have the exact same implementation of this ethernet device, as we can see from the long lookup table in bgmac_probe().

Please document the specific product numbers here that are publically known already. Having the driver match just on "brcm,bgmac-nsp" as a fallback is fine, so you can document that one as required for all users.

Arnd

author
#11 lore raw

Re: [PATCH 6/7] dt-bindings: net: bgmac: add bindings documentation for bgmac

Quoted 15 lines · Arnd Bergmann

Documentation/devicetree/bindings/net/brcm,bgmac-nsp.txt line 11

Quoted 9 lines · CEST Jon Mason
Documentation/devicetree/bindings/net/brcm,bgmac-nsp.txt new file +9 -0
+
+Required properties:
+ - compatible: "brcm,bgmac-nsp"
+ - reg:                Address and length of the GMAC registers,
+               Address and length of the GMAC IDM registers
+ - reg-names:  Names of the registers.  Must have both "gmac_base" and
+               "idm_base"
+ - interrupts: Interrupt number
+

"brcm,bgmac-nsp" sounds a bit too general. As I understand, this is a family of SoCs that might not all have the exact same implementation of this ethernet device, as we can see from the long lookup table in bgmac_probe().

The Broadcom iProc family of SoCs contains:
Northstar
Northstar Plus
Cygnus
Northstar 2
a few SoCs that are under development
and a number of ethernet switches (which might never be officially supported)

Each one of these SoCs could have a different revision of the gmac IP block, but they should be uniform within each SoC (though there might be a A0/B0 change necessary). The Northstar Plus product family has a number of different implementations, but the SoC is unchanged. So, I think this might be too specific, when we really need a general compat string.

Broadcom has a history of sharing IP blocks amongst the different divisions. So, this driver might be used on other SoC families (as it apparently has been done in the past, based on the code you reference). I do not know of any way to know what legacy, non-iProc chips have used this IP block. I can make this "brcm,iproc-bgmac", and add "brcm,iproc-nsp-bgmac" as an alternative compatible string in this file (which I believe you are suggesting), but there might be non-iProc SoCs that use this driver. Is this acceptable?

Thanks,
Jon

Quoted 5 lines

Please document the specific product numbers here that are publically known already. Having the driver match just on "brcm,bgmac-nsp" as a fallback is fine, so you can document that one as required for all users.

Arnd

#12 lore raw

Re: [PATCH 6/7] dt-bindings: net: bgmac: add bindings documentation for bgmac

Quoted 25 lines · CEST Jon Mason
Quoted 15 lines · Arnd Bergmann

Documentation/devicetree/bindings/net/brcm,bgmac-nsp.txt line 11

Quoted 9 lines · CEST Jon Mason
Documentation/devicetree/bindings/net/brcm,bgmac-nsp.txt new file +9 -0
+
+Required properties:
+ - compatible: "brcm,bgmac-nsp"
+ - reg:                Address and length of the GMAC registers,
+               Address and length of the GMAC IDM registers
+ - reg-names:  Names of the registers.  Must have both "gmac_base" and
+               "idm_base"
+ - interrupts: Interrupt number
+

"brcm,bgmac-nsp" sounds a bit too general. As I understand, this is a family of SoCs that might not all have the exact same implementation of this ethernet device, as we can see from the long lookup table in bgmac_probe().

The Broadcom iProc family of SoCs contains:
Northstar
Northstar Plus
Cygnus
Northstar 2
a few SoCs that are under development
and a number of ethernet switches (which might never be officially supported)

Quoted 6 lines

Each one of these SoCs could have a different revision of the gmac IP block, but they should be uniform within each SoC (though there might be a A0/B0 change necessary). The Northstar Plus product family has a number of different implementations, but the SoC is unchanged. So, I think this might be too specific, when we really need a general compat string.

Ok, thanks for the clarification, that sounds good enough.

Quoted 8 lines

Broadcom has a history of sharing IP blocks amongst the different divisions. So, this driver might be used on other SoC families (as it apparently has been done in the past, based on the code you reference). I do not know of any way to know what legacy, non-iProc chips have used this IP block. I can make this "brcm,iproc-bgmac", and add "brcm,iproc-nsp-bgmac" as an alternative compatible string in this file (which I believe you are suggesting), but there might be non-iProc SoCs that use this driver. Is this acceptable?

If it is also used outside of iProc, then I see no need for the extra compatible string, although it would not do any harm either.

Ideally we should name it whatever the name for this IP block is inside of the company, with "nsp" as the designation for the variant in Northstar Plus. A lot of Broadcom IP blocks themselves seem to have some four-digit or five-digit number, maybe this one does too?

Arnd

#13 lore raw

Re: [PATCH 6/7] dt-bindings: net: bgmac: add bindings documentation for bgmac

Quoted 47 lines · Arnd Bergmann
Quoted 25 lines · CEST Jon Mason
Quoted 15 lines · Arnd Bergmann

Documentation/devicetree/bindings/net/brcm,bgmac-nsp.txt line 11

Quoted 9 lines · CEST Jon Mason
Documentation/devicetree/bindings/net/brcm,bgmac-nsp.txt new file +9 -0
+
+Required properties:
+ - compatible: "brcm,bgmac-nsp"
+ - reg:                Address and length of the GMAC registers,
+               Address and length of the GMAC IDM registers
+ - reg-names:  Names of the registers.  Must have both "gmac_base" and
+               "idm_base"
+ - interrupts: Interrupt number
+

"brcm,bgmac-nsp" sounds a bit too general. As I understand, this is a family of SoCs that might not all have the exact same implementation of this ethernet device, as we can see from the long lookup table in bgmac_probe().

The Broadcom iProc family of SoCs contains:
Northstar
Northstar Plus
Cygnus
Northstar 2
a few SoCs that are under development
and a number of ethernet switches (which might never be officially supported)

Quoted 6 lines

Each one of these SoCs could have a different revision of the gmac IP block, but they should be uniform within each SoC (though there might be a A0/B0 change necessary). The Northstar Plus product family has a number of different implementations, but the SoC is unchanged. So, I think this might be too specific, when we really need a general compat string.

Ok, thanks for the clarification, that sounds good enough.

Quoted 8 lines

Broadcom has a history of sharing IP blocks amongst the different divisions. So, this driver might be used on other SoC families (as it apparently has been done in the past, based on the code you reference). I do not know of any way to know what legacy, non-iProc chips have used this IP block. I can make this "brcm,iproc-bgmac", and add "brcm,iproc-nsp-bgmac" as an alternative compatible string in this file (which I believe you are suggesting), but there might be non-iProc SoCs that use this driver. Is this acceptable?

If it is also used outside of iProc, then I see no need for the extra compatible string, although it would not do any harm either.

Quoted 7 lines

Ideally we should name it whatever the name for this IP block is inside of the company, with "nsp" as the designation for the variant in Northstar Plus. A lot of Broadcom IP blocks themselves seem to have some four-digit or five-digit number, maybe this one does too?

Arnd

Note this IP block has an official IP controller name of "amac" from the ASIC team.

Thanks,

Ray

#14 lore raw

Re: [PATCH 6/7] dt-bindings: net: bgmac: add bindings documentation for bgmac

Quoted 53 lines · CEST Ray Jui
Quoted 52 lines · Arnd Bergmann
Quoted 25 lines · CEST Jon Mason
Quoted 15 lines · Arnd Bergmann

Documentation/devicetree/bindings/net/brcm,bgmac-nsp.txt line 11

Quoted 9 lines · CEST Jon Mason
Documentation/devicetree/bindings/net/brcm,bgmac-nsp.txt new file +9 -0
+
+Required properties:
+ - compatible: "brcm,bgmac-nsp"
+ - reg:                Address and length of the GMAC registers,
+               Address and length of the GMAC IDM registers
+ - reg-names:  Names of the registers.  Must have both "gmac_base" and
+               "idm_base"
+ - interrupts: Interrupt number
+

"brcm,bgmac-nsp" sounds a bit too general. As I understand, this is a family of SoCs that might not all have the exact same implementation of this ethernet device, as we can see from the long lookup table in bgmac_probe().

The Broadcom iProc family of SoCs contains:
Northstar
Northstar Plus
Cygnus
Northstar 2
a few SoCs that are under development
and a number of ethernet switches (which might never be officially supported)

Quoted 6 lines

Each one of these SoCs could have a different revision of the gmac IP block, but they should be uniform within each SoC (though there might be a A0/B0 change necessary). The Northstar Plus product family has a number of different implementations, but the SoC is unchanged. So, I think this might be too specific, when we really need a general compat string.

Ok, thanks for the clarification, that sounds good enough.

Quoted 8 lines

Broadcom has a history of sharing IP blocks amongst the different divisions. So, this driver might be used on other SoC families (as it apparently has been done in the past, based on the code you reference). I do not know of any way to know what legacy, non-iProc chips have used this IP block. I can make this "brcm,iproc-bgmac", and add "brcm,iproc-nsp-bgmac" as an alternative compatible string in this file (which I believe you are suggesting), but there might be non-iProc SoCs that use this driver. Is this acceptable?

If it is also used outside of iProc, then I see no need for the extra compatible string, although it would not do any harm either.

Ideally we should name it whatever the name for this IP block is inside of the company, with "nsp" as the designation for the variant in Northstar Plus. A lot of Broadcom IP blocks themselves seem to have some four-digit or five-digit number, maybe this one does too?

Quoted 5 lines
Quoted 2 lines

Arnd

Note this IP block has an official IP controller name of "amac" from the ASIC team.

Ok, then I'd suggest making the compatible string here

	compatible = "brcm,nsp-amac", "brcm,amac";

or even better if you have a version number associated with it, make that

	compatible = "brcm,nsp-amac", "brcm,amac-1.234", "brcm,amac";

replacing 1.234 with the actual version of course.

Arnd

author
#15 lore raw

Re: [PATCH 6/7] dt-bindings: net: bgmac: add bindings documentation for bgmac

Quoted 57 lines · Arnd Bergmann
Quoted 56 lines · CEST Ray Jui
Quoted 54 lines · Arnd Bergmann
Quoted 25 lines · CEST Jon Mason
Quoted 15 lines · Arnd Bergmann

Documentation/devicetree/bindings/net/brcm,bgmac-nsp.txt line 11

Quoted 9 lines · CEST Jon Mason
Documentation/devicetree/bindings/net/brcm,bgmac-nsp.txt new file +9 -0
+
+Required properties:
+ - compatible: "brcm,bgmac-nsp"
+ - reg:                Address and length of the GMAC registers,
+               Address and length of the GMAC IDM registers
+ - reg-names:  Names of the registers.  Must have both "gmac_base" and
+               "idm_base"
+ - interrupts: Interrupt number
+

"brcm,bgmac-nsp" sounds a bit too general. As I understand, this is a family of SoCs that might not all have the exact same implementation of this ethernet device, as we can see from the long lookup table in bgmac_probe().

The Broadcom iProc family of SoCs contains:
Northstar
Northstar Plus
Cygnus
Northstar 2
a few SoCs that are under development
and a number of ethernet switches (which might never be officially supported)

Quoted 6 lines

Each one of these SoCs could have a different revision of the gmac IP block, but they should be uniform within each SoC (though there might be a A0/B0 change necessary). The Northstar Plus product family has a number of different implementations, but the SoC is unchanged. So, I think this might be too specific, when we really need a general compat string.

Ok, thanks for the clarification, that sounds good enough.

Quoted 8 lines

Broadcom has a history of sharing IP blocks amongst the different divisions. So, this driver might be used on other SoC families (as it apparently has been done in the past, based on the code you reference). I do not know of any way to know what legacy, non-iProc chips have used this IP block. I can make this "brcm,iproc-bgmac", and add "brcm,iproc-nsp-bgmac" as an alternative compatible string in this file (which I believe you are suggesting), but there might be non-iProc SoCs that use this driver. Is this acceptable?

If it is also used outside of iProc, then I see no need for the extra compatible string, although it would not do any harm either.

Ideally we should name it whatever the name for this IP block is inside of the company, with "nsp" as the designation for the variant in Northstar Plus. A lot of Broadcom IP blocks themselves seem to have some four-digit or five-digit number, maybe this one does too?

Arnd

Quoted 6 lines
Quoted 2 lines

Note this IP block has an official IP controller name of "amac" from the ASIC team.

Ok, then I'd suggest making the compatible string here

        compatible = "brcm,nsp-amac", "brcm,amac";

It is called GMAC in the NS and NSP documentation, but AMAC is fine with me (as it is called this in the NS2 documentation). I'll make the necessary change and repush.

Thanks for all of the input.

Quoted 8 lines

or even better if you have a version number associated with it, make that

        compatible = "brcm,nsp-amac", "brcm,amac-1.234", "brcm,amac";

replacing 1.234 with the actual version of course.

Arnd

#16 lore raw

Re: [PATCH 6/7] dt-bindings: net: bgmac: add bindings documentation for bgmac

Quoted 8 lines · CEST Jon Mason
Quoted 4 lines

Ok, then I'd suggest making the compatible string here

        compatible = "brcm,nsp-amac", "brcm,amac";

It is called GMAC in the NS and NSP documentation, but AMAC is fine with me (as it is called this in the NS2 documentation). I'll make the necessary change and repush.

Ok, then we can use

	compatible = "brcm,nsp-gmac", "brcm,amac";

to be consistent with that documentation and have the generic name as the fallback.

Arnd

author
#17 lore raw

Re: [PATCH 6/7] dt-bindings: net: bgmac: add bindings documentation for bgmac

Quoted 10 lines · Arnd Bergmann
Quoted 8 lines · CEST Jon Mason
Quoted 4 lines

Ok, then I'd suggest making the compatible string here

        compatible = "brcm,nsp-amac", "brcm,amac";

It is called GMAC in the NS and NSP documentation, but AMAC is fine with me (as it is called this in the NS2 documentation). I'll make the necessary change and repush.

Quoted 6 lines

Ok, then we can use

        compatible = "brcm,nsp-gmac", "brcm,amac";

to be consistent with that documentation and have the generic name as the fallback.

After looking at the docs again, I see the blocks being referred to as "AXI MAC" (while the registers are being called GMAC). To keep it consistent, I'll just change everything to be "amac".

Thanks,
Jon

Quoted 2 lines

Arnd

author
#18 lore raw

PATCH 7/7 ARM: dts: NSP: Add bgmac entries

In reply to Jon Mason

Add device tree entries for the ethernet devices present on the Broadcom Northstar Plus SoCs

---
 arch/arm/boot/dts/bcm-nsp.dtsi   | 18 ++++++++++++++++++
 arch/arm/boot/dts/bcm958625k.dts |  8 ++++++++
 2 files changed, 26 insertions(+)
arch/arm/boot/dts/bcm-nsp.dtsi +18 -0
index def9e78..8f4343b 100644
@@ -192,6 +192,24 @@
 			status = "disabled";
 		};
 
+		gmac0: ethernet at 22000 {
+			compatible = "brcm,bgmac-nsp";
+			reg = <0x022000 0x1000>,
+			      <0x110000 0x1000>;
+			reg-names = "gmac_base", "idm_base";
+			interrupts = <GIC_SPI 147 IRQ_TYPE_LEVEL_HIGH>;
+			status = "disabled";
+		};
+
+		gmac1: ethernet at 23000 {
+			compatible = "brcm,bgmac-nsp";
+			reg = <0x023000 0x1000>,
+			      <0x111000 0x1000>;
+			reg-names = "gmac_base", "idm_base";
+			interrupts = <GIC_SPI 148 IRQ_TYPE_LEVEL_HIGH>;
+			status = "disabled";
+		};
+
 		nand: nand at 26000 {
 			compatible = "brcm,nand-iproc", "brcm,brcmnand-v6.1";
 			reg = <0x026000 0x600>,
arch/arm/boot/dts/bcm958625k.dts +8 -0
index e298450..d16ab53 100644
@@ -56,6 +56,14 @@
 	status = "okay";
 };
 
+&gmac0 {
+	status = "okay";
+};
+
+&gmac1 {
+	status = "okay";
+};
+
 &pcie0 {
 	status = "okay";
 };
Signature · 1 line
1.9.1
Acked-by on the v1 series
#19 lore raw
In reply to Jon Mason
Quoted 10 lines · CEST Jon Mason

Well, no compilained too loudly at the RFC version of this patch series (see https://lkml.org/lkml/2016/6/28/863). So, I'm officially sending this out for inclusion. All comments from the RFC were addressed in this version.

This patch series adds support for other, non-bcma iProc SoC's to the bgmac driver. This series only adds NSP support, but we are interested in adding support for the Cygnus and NS2 families (with more possible down the road).

Quoted 7 lines

To support non-bcma enabled SoCs, we need to add the standard device tree "platform device" support. Unfortunately, this driver is very tighly coupled with the bcma bus and much unwinding is needed. I tried to break this up into a number of patches to make it more obvious what was being done to add platform device support. I was able to verify that the bcma code still works using a 53012K board (NS SoC), and that the platform code works using a 58625K board (NSP SoC).

Looks reasonable overall. I have one comment for the binding, but we can handle them separately. I think the first five patches can just get merged through net-next if there are no other concerns, and feel free to add my

For the last two patches, once we have worked out the right compatible strings, please send them to Florian for merging through the arm-soc next/dt branch.

Arnd