b53: improve overriding CPU port state on BCM5301X
authorRafał Miłecki <zajec5@gmail.com>
Sun, 12 Apr 2015 20:00:42 +0000 (20:00 +0000)
committerRafał Miłecki <zajec5@gmail.com>
Sun, 12 Apr 2015 20:00:42 +0000 (20:00 +0000)
On BCM5301X there are two different cases to handle: CPU port 8 vs. any
other one. Support for CPU port 8 was already partially implemented but
it lacked setting some extra bit for 2G speed. It also will need to be
extended to implement "SMP dual core 3 GMAC setup". That's the reason
for handling it in separated code block.
This patch also adds overriding CPU port state for port other than 8. It
requires using recently defined GMII_PORT registers.
It was tested for regressions on BCM53011 revs 2 & 3. It was also
confirmed to fix switch on some internal Broadcom board.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Acked-by: Jonas Gorski <jogo@openwrt.org>
SVN-Revision: 45402

target/linux/generic/files/drivers/net/phy/b53/b53_common.c
target/linux/generic/files/drivers/net/phy/b53/b53_regs.h

index d2bb51ab4aaa0bed783fd5ddd576c1b032040b42..ac7c10cadcc6197daa67c0e785180c8ce8ad3f19 100644 (file)
@@ -480,6 +480,7 @@ static void b53_switch_reset_gpio(struct b53_device *dev)
 
 static int b53_switch_reset(struct b53_device *dev)
 {
+       u8 cpu_port = dev->sw_dev.cpu_port;
        u8 mgmt;
 
        b53_switch_reset_gpio(dev);
@@ -525,8 +526,7 @@ static int b53_switch_reset(struct b53_device *dev)
                                return -EINVAL;
                        }
                }
-       } else if ((is531x5(dev) || is5301x(dev)) &&
-                  dev->sw_dev.cpu_port == B53_CPU_PORT) {
+       } else if (is531x5(dev) && cpu_port == B53_CPU_PORT) {
                u8 mii_port_override;
 
                b53_read8(dev, B53_CTRL_PAGE, B53_PORT_OVERRIDE_CTRL,
@@ -534,6 +534,33 @@ static int b53_switch_reset(struct b53_device *dev)
                b53_write8(dev, B53_CTRL_PAGE, B53_PORT_OVERRIDE_CTRL,
                           mii_port_override | PORT_OVERRIDE_EN |
                           PORT_OVERRIDE_LINK);
+       } else if (is5301x(dev)) {
+               if (cpu_port == 8) {
+                       u8 mii_port_override;
+
+                       b53_read8(dev, B53_CTRL_PAGE, B53_PORT_OVERRIDE_CTRL,
+                                 &mii_port_override);
+                       mii_port_override |= PORT_OVERRIDE_LINK |
+                                            PORT_OVERRIDE_RX_FLOW |
+                                            PORT_OVERRIDE_TX_FLOW |
+                                            PORT_OVERRIDE_SPEED_2000M |
+                                            PORT_OVERRIDE_EN;
+                       b53_write8(dev, B53_CTRL_PAGE, B53_PORT_OVERRIDE_CTRL,
+                                  mii_port_override);
+
+                       /* TODO: Ports 5 & 7 require some extra handling */
+               } 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_enable_mib(dev);
index 534170832a22c837ebddf637d249dbf34e6ca8f1..eef5c8177952c48623cad722993089cf06ce2e6c 100644 (file)
@@ -86,6 +86,7 @@
 #define   PORT_OVERRIDE_RV_MII_25      BIT(4) /* BCM5325 only */
 #define   PORT_OVERRIDE_RX_FLOW                BIT(4)
 #define   PORT_OVERRIDE_TX_FLOW                BIT(5)
+#define   PORT_OVERRIDE_SPEED_2000M    BIT(6) /* BCM5301X only, requires setting 1000M */
 #define   PORT_OVERRIDE_EN             BIT(7) /* Use the register contents */
 
 /* Power-down mode control */