ar8216: display flow control info in swconfig get_link in case of autonegatiation too
authorFelix Fietkau <nbd@openwrt.org>
Sun, 18 Jan 2015 00:54:06 +0000 (00:54 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Sun, 18 Jan 2015 00:54:06 +0000 (00:54 +0000)
The swconfig get_link attribute (at least) on AR8327/AR8337 doesn't
consider the autonegotiated flow control.
AR8327/AR8337 provide the info about autonegotiated rx/tx flow control
in bits 10 and 11 of the port status register.
Use these values to display info about autonegotiated rx/tx flow
control as part of the get_link attribute.

Successfully tested on TL-WDR4900 (AR8327 rev.4) and
TL-WDR4300 (AR8327 rev.2).

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
SVN-Revision: 44023

target/linux/generic/files/drivers/net/phy/ar8327.c
target/linux/generic/files/drivers/net/phy/ar8327.h

index c0262d71455a5db75d87ee27dd42d886a4bc5d9e..ea880bc9277c885e398b4dcdf34c8ed2700f8c1d 100644 (file)
@@ -710,7 +710,23 @@ ar8327_init_port(struct ar8xxx_priv *priv, int port)
 static u32
 ar8327_read_port_status(struct ar8xxx_priv *priv, int port)
 {
-       return ar8xxx_read(priv, AR8327_REG_PORT_STATUS(port));
+       u32 t;
+
+       t = ar8xxx_read(priv, AR8327_REG_PORT_STATUS(port));
+       /* map the flow control autoneg result bits to the flow control bits
+        * used in forced mode to allow ar8216_read_port_link detect
+        * flow control properly if autoneg is used
+        */
+       if (t & AR8216_PORT_STATUS_LINK_UP &&
+           t & AR8216_PORT_STATUS_LINK_AUTO) {
+               t &= ~(AR8216_PORT_STATUS_TXFLOW | AR8216_PORT_STATUS_RXFLOW);
+               if (t & AR8327_PORT_STATUS_TXFLOW_AUTO)
+                       t |= AR8216_PORT_STATUS_TXFLOW;
+               if (t & AR8327_PORT_STATUS_RXFLOW_AUTO)
+                       t |= AR8216_PORT_STATUS_RXFLOW;
+       }
+
+       return t;
 }
 
 static u32
index 1877f00c97912c57950d9ece6a1aa9b44b8f19e7..f0ef013cb65a43a1ba789ff52a2176fcacfce54e 100644 (file)
@@ -84,6 +84,8 @@
 #define   AR8327_MAX_FRAME_SIZE_MTU            BITS(0, 14)
 
 #define AR8327_REG_PORT_STATUS(_i)             (0x07c + (_i) * 4)
+#define   AR8327_PORT_STATUS_TXFLOW_AUTO       BIT(10)
+#define   AR8327_PORT_STATUS_RXFLOW_AUTO       BIT(11)
 
 #define AR8327_REG_HEADER_CTRL                 0x098
 #define AR8327_REG_PORT_HEADER(_i)             (0x09c + (_i) * 4)