e1000/base: fix link check for i354 88E1112 PHY
authorWenzhuo Lu <wenzhuo.lu@intel.com>
Fri, 16 Oct 2015 02:51:13 +0000 (10:51 +0800)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Tue, 27 Oct 2015 15:12:56 +0000 (16:12 +0100)
e1000_check_for_link_media_swap() is supposed to check PHY page 0 for
copper and PHY page 1 for "other" (fiber) link. We switched back from
page 1 to page 0 too soon, before e1000_check_for_link_82575() is
executed and we were never finding link on fiber (other).

Note: The precedence of link type is controlled by the PHY settings.

If the link is copper, as the M88E1112 page address is set to 1, it should be
set back to 0 before checking this link.

Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
drivers/net/e1000/base/e1000_82575.c

index 2df06bd..74c18fc 100644 (file)
@@ -1234,7 +1234,7 @@ STATIC s32 e1000_check_for_link_media_swap(struct e1000_hw *hw)
 
        DEBUGFUNC("e1000_check_for_link_media_swap");
 
-       /* Check the copper medium. */
+       /* Check for copper. */
        ret_val = phy->ops.write_reg(hw, E1000_M88E1112_PAGE_ADDR, 0);
        if (ret_val)
                return ret_val;
@@ -1246,7 +1246,7 @@ STATIC s32 e1000_check_for_link_media_swap(struct e1000_hw *hw)
        if (data & E1000_M88E1112_STATUS_LINK)
                port = E1000_MEDIA_PORT_COPPER;
 
-       /* Check the other medium. */
+       /* Check for other. */
        ret_val = phy->ops.write_reg(hw, E1000_M88E1112_PAGE_ADDR, 1);
        if (ret_val)
                return ret_val;
@@ -1255,11 +1255,6 @@ STATIC s32 e1000_check_for_link_media_swap(struct e1000_hw *hw)
        if (ret_val)
                return ret_val;
 
-       /* reset page to 0 */
-       ret_val = phy->ops.write_reg(hw, E1000_M88E1112_PAGE_ADDR, 0);
-       if (ret_val)
-               return ret_val;
-
        if (data & E1000_M88E1112_STATUS_LINK)
                port = E1000_MEDIA_PORT_OTHER;
 
@@ -1267,8 +1262,20 @@ STATIC s32 e1000_check_for_link_media_swap(struct e1000_hw *hw)
        if (port && (hw->dev_spec._82575.media_port != port)) {
                hw->dev_spec._82575.media_port = port;
                hw->dev_spec._82575.media_changed = true;
+       }
+
+       if (port == E1000_MEDIA_PORT_COPPER) {
+               /* reset page to 0 */
+               ret_val = phy->ops.write_reg(hw, E1000_M88E1112_PAGE_ADDR, 0);
+               if (ret_val)
+                       return ret_val;
+               e1000_check_for_link_82575(hw);
        } else {
-               ret_val = e1000_check_for_link_82575(hw);
+               e1000_check_for_link_82575(hw);
+               /* reset page to 0 */
+               ret_val = phy->ops.write_reg(hw, E1000_M88E1112_PAGE_ADDR, 0);
+               if (ret_val)
+                       return ret_val;
        }
 
        return E1000_SUCCESS;