[U-Boot] [RFC PATCH v2 3/3] net: ag7xxx: No longer ignore link status

Joe Hershberger joe.hershberger at ni.com
Mon Jun 26 19:40:10 UTC 2017


In the case of the WAN port, pay attention to the link status.
In the case of LAN ports, stop reading the link status since we don't
care.

Signed-off-by: Joe Hershberger <joe.hershberger at ni.com>

---
This is a pass at improving the code quality.
This has not been tested in any way.

Changes in v2:
- New - Split link status change into its own patch (so it can be dropped if it affects behavior)

 drivers/net/ag7xxx.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ag7xxx.c b/drivers/net/ag7xxx.c
index 00e6806..c8352d1 100644
--- a/drivers/net/ag7xxx.c
+++ b/drivers/net/ag7xxx.c
@@ -100,6 +100,12 @@ enum ag7xxx_model {
 /* Rx Status */
 #define AG7XXX_ETH_DMA_RX_STATUS		0x194
 
+/* PHY Control Registers */
+
+/* PHY Specific Status Register */
+#define AG7XXX_PHY_PSSR				0x11
+#define AG7XXX_PHY_PSSR_LINK_UP			BIT(10)
+
 /* Custom register at 0x18070000 */
 #define AG7XXX_GMAC_ETH_CFG			0x00
 #define AG7XXX_ETH_CFG_SW_PHY_ADDR_SWAP		BIT(8)
@@ -758,10 +764,13 @@ static int ag933x_phy_setup_common(struct udevice *dev)
 			return ret;
 
 		/* Read out link status */
-		ret = ag7xxx_mdio_read(priv->bus, phymax, 0, MII_MIPSCR);
+		ret = ag7xxx_mdio_read(priv->bus, phymax, 0, AG7XXX_PHY_PSSR);
 		if (ret < 0)
 			return ret;
 
+		if (!(ret & AG7XXX_PHY_PSSR_LINK_UP))
+			return -ENOLINK;
+
 		return 0;
 	}
 
@@ -778,13 +787,6 @@ static int ag933x_phy_setup_common(struct udevice *dev)
 			return ret;
 	}
 
-	for (i = 0; i < phymax; i++) {
-		/* Read out link status */
-		ret = ag7xxx_mdio_read(priv->bus, i, 0, MII_MIPSCR);
-		if (ret < 0)
-			return ret;
-	}
-
 	return 0;
 }
 
-- 
1.7.11.5



More information about the U-Boot mailing list