]> git.hungrycats.org Git - linux/commitdiff
[e1000] make function our of setting media type
authorScott Feldman <scott.feldman@intel.com>
Thu, 11 Sep 2003 11:11:10 +0000 (07:11 -0400)
committerStephen Hemminger <shemminger@osdl.org>
Thu, 11 Sep 2003 11:11:10 +0000 (07:11 -0400)
* Consolidate code and make function out of setting media type.

drivers/net/e1000/e1000_hw.c
drivers/net/e1000/e1000_main.c

index 70a5ad99fef787fbdec710010c5cff1af39879ac..ccc7dac6ef47dcd9837b10eaab4de9f577303fcf 100644 (file)
@@ -249,6 +249,46 @@ e1000_set_mac_type(struct e1000_hw *hw)
 
     return E1000_SUCCESS;
 }
+
+/*****************************************************************************
+ * Set media type and TBI compatibility.
+ *
+ * hw - Struct containing variables accessed by shared code
+ * **************************************************************************/
+void
+e1000_set_media_type(struct e1000_hw *hw)
+{
+    uint32_t status;
+
+    DEBUGFUNC("e1000_set_media_type");
+
+    if(hw->mac_type != e1000_82543) {
+        /* tbi_compatibility is only valid on 82543 */
+        hw->tbi_compatibility_en = FALSE;
+    }
+
+    switch (hw->device_id) {
+    case E1000_DEV_ID_82545GM_SERDES:
+    case E1000_DEV_ID_82546GB_SERDES:
+        hw->media_type = e1000_media_type_internal_serdes;
+        break;
+    default:
+        if(hw->mac_type >= e1000_82543) {
+            status = E1000_READ_REG(hw, STATUS);
+            if(status & E1000_STATUS_TBIMODE) {
+                hw->media_type = e1000_media_type_fiber;
+                /* tbi_compatibility not valid on fiber */
+                hw->tbi_compatibility_en = FALSE;
+            } else {
+                hw->media_type = e1000_media_type_copper;
+            }
+        } else {
+            /* This is an 82542 (fiber only) */
+            hw->media_type = e1000_media_type_fiber;
+        }
+    }
+}
+
 /******************************************************************************
  * Reset the transmit and receive units; mask and clear all interrupts.
  *
@@ -404,7 +444,7 @@ e1000_reset_hw(struct e1000_hw *hw)
 int32_t
 e1000_init_hw(struct e1000_hw *hw)
 {
-    uint32_t ctrl, status;
+    uint32_t ctrl;
     uint32_t i;
     int32_t ret_val;
     uint16_t pcix_cmd_word;
@@ -421,25 +461,8 @@ e1000_init_hw(struct e1000_hw *hw)
         return ret_val;
     }
 
-    /* Set the Media Type and exit with error if it is not valid. */
-    if(hw->mac_type != e1000_82543) {
-        /* tbi_compatibility is only valid on 82543 */
-        hw->tbi_compatibility_en = FALSE;
-    }
-
-    if(hw->mac_type >= e1000_82543) {
-        status = E1000_READ_REG(hw, STATUS);
-        if(status & E1000_STATUS_TBIMODE) {
-            hw->media_type = e1000_media_type_fiber;
-            /* tbi_compatibility not valid on fiber */
-            hw->tbi_compatibility_en = FALSE;
-        } else {
-            hw->media_type = e1000_media_type_copper;
-        }
-    } else {
-        /* This is an 82542 (fiber only) */
-        hw->media_type = e1000_media_type_fiber;
-    }
+    /* Set the media type and TBI compatibility */
+    e1000_set_media_type(hw);
 
     /* Disabling VLAN filtering. */
     DEBUGOUT("Initializing the IEEE VLAN\n");
index 2f7ea422ec94153780bd69e51db5419c9bbbfc40..228a462ac4e47168db215114856b4b784b2272eb 100644 (file)
@@ -625,18 +625,7 @@ e1000_sw_init(struct e1000_adapter *adapter)
           (hw->mac_type == e1000_82547_rev_2))
                hw->phy_init_script = 1;
 
-       /* Media type - copper or fiber */
-
-       if(hw->mac_type >= e1000_82543) {
-               uint32_t status = E1000_READ_REG(hw, STATUS);
-
-               if(status & E1000_STATUS_TBIMODE)
-                       hw->media_type = e1000_media_type_fiber;
-               else
-                       hw->media_type = e1000_media_type_copper;
-       } else {
-               hw->media_type = e1000_media_type_fiber;
-       }
+       e1000_set_media_type(hw);
 
        if(hw->mac_type < e1000_82543)
                hw->report_tx_early = 0;