[OpenWrt-Devel] [PATCH] b53: override ports 5 and 7 if using CPU port 8 on BCM5301x switch

Rafał Miłecki zajec5 at gmail.com
Sat Apr 9 11:32:10 EDT 2016


These ports are also used in GMAC3 configuration, just for radios
rather than physical Ethernet ports.

Signed-off-by: Rafał Miłecki <zajec5 at gmail.com>
---
People interested in more details of GMAC3 configuration may take a look
at bcmfwd.h from Broadcom's SDK.
---
 .../generic/files/drivers/net/phy/b53/b53_common.c | 38 +++++++++++++++-------
 1 file changed, 27 insertions(+), 11 deletions(-)

diff --git a/target/linux/generic/files/drivers/net/phy/b53/b53_common.c b/target/linux/generic/files/drivers/net/phy/b53/b53_common.c
index 676e301..fa137ab 100644
--- a/target/linux/generic/files/drivers/net/phy/b53/b53_common.c
+++ b/target/linux/generic/files/drivers/net/phy/b53/b53_common.c
@@ -478,6 +478,23 @@ static void b53_switch_reset_gpio(struct b53_device *dev)
 	dev->current_page = 0xff;
 }
 
+static void b53_gmii_port_override(struct b53_device *dev, int port)
+{
+	u8 po_reg = B53_GMII_PORT_OVERRIDE_CTRL(port);
+	u8 gmii_po = 0;
+
+	if (WARN_ON(port > 7))
+		return;
+
+	b53_read8(dev, B53_CTRL_PAGE, po_reg, &gmii_po);
+	gmii_po |= GMII_PO_LINK |
+		   GMII_PO_RX_FLOW |
+		   GMII_PO_TX_FLOW |
+		   GMII_PO_EN |
+		   GMII_PO_SPEED_2000M;
+	b53_write8(dev, B53_CTRL_PAGE, po_reg, gmii_po);
+}
+
 static int b53_switch_reset(struct b53_device *dev)
 {
 	u8 cpu_port = dev->sw_dev.cpu_port;
@@ -548,18 +565,17 @@ static int b53_switch_reset(struct b53_device *dev)
 			b53_write8(dev, B53_CTRL_PAGE, B53_PORT_OVERRIDE_CTRL,
 				   mii_port_override);
 
-			/* TODO: Ports 5 & 7 require some extra handling */
+			/*
+			 * Port 8 is used as CPU in GMAC3 configuration. In such
+			 * case ports 5 and 7 are connected to wireless radios.
+			 * With proper drivers it's possible to make hw switch
+			 * handle wlan <-> lan bridging.
+			 * Both ports need overriding to be usable.
+			 */
+			b53_gmii_port_override(dev, 5);
+			b53_gmii_port_override(dev, 7);
 		} else {
-			u8 po_reg = B53_GMII_PORT_OVERRIDE_CTRL(cpu_port);
-			u8 gmii_po;
-
-			b53_read8(dev, B53_CTRL_PAGE, po_reg, &gmii_po);
-			gmii_po |= GMII_PO_LINK |
-				   GMII_PO_RX_FLOW |
-				   GMII_PO_TX_FLOW |
-				   GMII_PO_EN |
-				   GMII_PO_SPEED_2000M;
-			b53_write8(dev, B53_CTRL_PAGE, po_reg, gmii_po);
+			b53_gmii_port_override(dev, cpu_port);
 		}
 	}
 
-- 
1.8.4.5
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list