]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
phylib: Detect link on 10G devices correctly
authorAndy Fleming <afleming@freescale.com>
Wed, 18 May 2011 13:44:19 +0000 (13:44 +0000)
committerWolfgang Denk <wd@denx.de>
Wed, 27 Jul 2011 21:21:25 +0000 (23:21 +0200)
gen10g_startup() had 2 bugs:

1) It had a boolean logic error in checking the MMD mask, and
always checked all of them.

2) It checked devices which don't actually report link state, which
meant that it would never believe the link was fully up.

Fix the boolean logic, and then mask the MMD mask so only link-reporting
devices are checked.

Signed-off-by: Andy Fleming <afleming@freescale.com>
Reported-by: Ed Swarthout <Ed.Swarthout@freescale.com>
drivers/net/phy/generic_10g.c
include/linux/mdio.h

index 60dec457bf78717039c264a74d7e3e74129f5799..e4a499d461701fd4c5dcb4deec33a95034a1e11c 100644 (file)
@@ -36,7 +36,7 @@ int gen10g_shutdown(struct phy_device *phydev)
 int gen10g_startup(struct phy_device *phydev)
 {
        int devad, reg;
-       u32 mmd_mask = phydev->mmds;
+       u32 mmd_mask = phydev->mmds & MDIO_DEVS_LINK;
 
        phydev->link = 1;
 
@@ -44,8 +44,12 @@ int gen10g_startup(struct phy_device *phydev)
        phydev->speed = SPEED_10000;
        phydev->duplex = DUPLEX_FULL;
 
+       /*
+        * Go through all the link-reporting devices, and make sure
+        * they're all up and happy
+        */
        for (devad = 0; mmd_mask; devad++, mmd_mask = mmd_mask >> 1) {
-               if (!mmd_mask & 1)
+               if (!(mmd_mask & 1))
                        continue;
 
                /* Read twice because link state is latched and a
index 022d77214e2012a88fa4f5bc5c47d5bdb8ccdcce..be80f91476058edfc8dd7f32d54c81936446e337 100644 (file)
 #define MDIO_DEVS_VEND1                        MDIO_DEVS_PRESENT(MDIO_MMD_VEND1)
 #define MDIO_DEVS_VEND2                        MDIO_DEVS_PRESENT(MDIO_MMD_VEND2)
 
+#define MDIO_DEVS_LINK                 (MDIO_DEVS_PMAPMD | \
+                                       MDIO_DEVS_WIS | \
+                                       MDIO_DEVS_PCS | \
+                                       MDIO_DEVS_PHYXS | \
+                                       MDIO_DEVS_DTEXS | \
+                                       MDIO_DEVS_AN)
+
+
 
 /* Control register 2. */
 #define MDIO_PMA_CTRL2_TYPE            0x000f  /* PMA/PMD type selection */