ixgbe/base: check MAC type when setting X550 callbacks
[dpdk.git] / drivers / net / ixgbe / base / ixgbe_x550.c
index 3b6f517..311d98b 100644 (file)
@@ -117,7 +117,9 @@ STATIC s32 ixgbe_write_cs4227(struct ixgbe_hw *hw, u16 reg, u16 value)
  * ixgbe_get_cs4227_status - Return CS4227 status
  * @hw: pointer to hardware structure
  *
- * Returns error if CS4227 not successfully initialized
+ * Performs a diagnostic on the CS4227 chip. Returns an error if it is
+ * not operating correctly.
+ * This function assumes that the caller has acquired the proper semaphore.
  **/
 STATIC s32 ixgbe_get_cs4227_status(struct ixgbe_hw *hw)
 {
@@ -126,6 +128,7 @@ STATIC s32 ixgbe_get_cs4227_status(struct ixgbe_hw *hw)
        u16 reg_slice, reg_val;
        u8 retry;
 
+       /* Check register reads. */
        for (retry = 0; retry < IXGBE_CS4227_RETRIES; ++retry) {
                status = ixgbe_read_cs4227(hw, IXGBE_CS4227_GLOBAL_ID_LSB,
                                           &value);
@@ -146,8 +149,16 @@ STATIC s32 ixgbe_get_cs4227_status(struct ixgbe_hw *hw)
         * Otherwise, this will disrupt link on all ports. Because we
         * can only do this the first time, we must check all ports,
         * not just our own.
+        * While we are at it, set the LINE side to 10G SR, which is
+        * what it needs to be regardless of the actual link.
         */
        if (value != IXGBE_CS4227_SCRATCH_VALUE) {
+               reg_slice = IXGBE_CS4227_LINE_SPARE22_MSB;
+               reg_val = IXGBE_CS4227_SPEED_10G;
+               status = ixgbe_write_cs4227(hw, reg_slice, reg_val);
+               if (status != IXGBE_SUCCESS)
+                       return status;
+
                reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB;
                reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
                status = ixgbe_write_cs4227(hw, reg_slice, reg_val);
@@ -160,6 +171,12 @@ STATIC s32 ixgbe_get_cs4227_status(struct ixgbe_hw *hw)
                if (status != IXGBE_SUCCESS)
                        return status;
 
+               reg_slice = IXGBE_CS4227_LINE_SPARE22_MSB + (1 << 12);
+               reg_val = IXGBE_CS4227_SPEED_10G;
+               status = ixgbe_write_cs4227(hw, reg_slice, reg_val);
+               if (status != IXGBE_SUCCESS)
+                       return status;
+
                reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB + (1 << 12);
                reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
                status = ixgbe_write_cs4227(hw, reg_slice, reg_val);
@@ -451,8 +468,13 @@ s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw)
        hw->bus.type = ixgbe_bus_type_internal;
        mac->ops.get_bus_info = ixgbe_get_bus_info_X550em;
 
-       mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550;
-       mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550;
+       if (hw->mac.type == ixgbe_mac_X550EM_x) {
+               mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550;
+               mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550;
+               mac->ops.acquire_swfw_sync = ixgbe_acquire_swfw_sync_X550em;
+               mac->ops.release_swfw_sync = ixgbe_release_swfw_sync_X550em;
+       }
+
        mac->ops.get_media_type = ixgbe_get_media_type_X550em;
        mac->ops.setup_sfp = ixgbe_setup_sfp_modules_X550em;
        mac->ops.get_link_capabilities = ixgbe_get_link_capabilities_X550em;
@@ -465,8 +487,6 @@ s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw)
        else
                mac->ops.setup_fc = ixgbe_setup_fc_X550em;
 
-       mac->ops.acquire_swfw_sync = ixgbe_acquire_swfw_sync_X550em;
-       mac->ops.release_swfw_sync = ixgbe_release_swfw_sync_X550em;
 
        if (hw->device_id != IXGBE_DEV_ID_X550EM_X_KR)
                mac->ops.setup_eee = NULL;
@@ -1764,6 +1784,67 @@ s32 ixgbe_setup_kx4_x550em(struct ixgbe_hw *hw)
        return status;
 }
 
+/**
+ *  ixgbe_setup_mac_link_sfp_x550em - Setup internal/external the PHY for SFP
+ *  @hw: pointer to hardware structure
+ *
+ *  Configure the external PHY and the integrated KR PHY for SFP support.
+ **/
+s32 ixgbe_setup_mac_link_sfp_x550em(struct ixgbe_hw *hw,
+                                   ixgbe_link_speed speed,
+                                   bool autoneg_wait_to_complete)
+{
+       s32 ret_val;
+       u16 reg_slice, reg_val;
+       bool setup_linear = false;
+       UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
+
+       /* Check if SFP module is supported and linear */
+       ret_val = ixgbe_supported_sfp_modules_X550em(hw, &setup_linear);
+
+       /* If no SFP module present, then return success. Return success since
+        * there is no reason to configure CS4227 and SFP not present error is
+        * not excepted in the setup MAC link flow.
+        */
+       if (ret_val == IXGBE_ERR_SFP_NOT_PRESENT)
+               return IXGBE_SUCCESS;
+
+       if (ret_val != IXGBE_SUCCESS)
+               return ret_val;
+
+       /* Configure CS4227 LINE side to 10G SR. */
+       reg_slice = IXGBE_CS4227_LINE_SPARE22_MSB + (hw->bus.lan_id << 12);
+       reg_val = IXGBE_CS4227_SPEED_10G;
+       ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
+               reg_val);
+
+       reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB + (hw->bus.lan_id << 12);
+       reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
+       ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
+               reg_val);
+
+       /* Configure CS4227 for HOST connection rate then type. */
+       reg_slice = IXGBE_CS4227_HOST_SPARE22_MSB + (hw->bus.lan_id << 12);
+       reg_val = (speed & IXGBE_LINK_SPEED_10GB_FULL) ?
+               IXGBE_CS4227_SPEED_10G : IXGBE_CS4227_SPEED_1G;
+       ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
+                                          reg_val);
+
+       reg_slice = IXGBE_CS4227_HOST_SPARE24_LSB + (hw->bus.lan_id << 12);
+       if (setup_linear)
+               reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
+       else
+               reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
+       ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
+                                          reg_val);
+
+       /* If internal link mode is XFI, then setup XFI internal link. */
+       if (!(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE))
+               ret_val = ixgbe_setup_ixfi_x550em(hw, &speed);
+
+       return ret_val;
+}
+
 /**
  *  ixgbe_setup_ixfi_x550em - Configure the KR PHY for iXFI mode.
  *  @hw: pointer to hardware structure
@@ -1909,69 +1990,6 @@ STATIC s32 ixgbe_ext_phy_t_x550em_get_link(struct ixgbe_hw *hw, bool *link_up)
        return IXGBE_SUCCESS;
 }
 
-/**
- *  ixgbe_setup_mac_link_sfp_x550em - Setup internal/external the PHY for SFP
- *  @hw: pointer to hardware structure
- *
- *  Configure the external PHY and the integrated KR PHY for SFP support.
- **/
-s32 ixgbe_setup_mac_link_sfp_x550em(struct ixgbe_hw *hw,
-                                   ixgbe_link_speed speed,
-                                   bool autoneg_wait_to_complete)
-{
-       s32 ret_val;
-       u16 reg_slice, reg_val;
-       bool setup_linear = false;
-       UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
-
-       /* Check if SFP module is supported and linear */
-       ret_val = ixgbe_supported_sfp_modules_X550em(hw, &setup_linear);
-
-       /* If no SFP module present, then return success. Return success since
-        * there is no reason to configure CS4227 and SFP not present error is
-        * not excepted in the setup MAC link flow.
-        */
-       if (ret_val == IXGBE_ERR_SFP_NOT_PRESENT)
-               return IXGBE_SUCCESS;
-
-       if (ret_val != IXGBE_SUCCESS)
-               return ret_val;
-
-       /* Configure CS4227 for LINE connection rate then type. */
-       reg_slice = IXGBE_CS4227_LINE_SPARE22_MSB + (hw->bus.lan_id << 12);
-       reg_val = (speed & IXGBE_LINK_SPEED_10GB_FULL) ? 0 : 0x8000;
-       ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
-                                          reg_val);
-
-       reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB + (hw->bus.lan_id << 12);
-       if (setup_linear)
-               reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
-       else
-               reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
-       ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
-                                          reg_val);
-
-       /* Configure CS4227 for HOST connection rate then type. */
-       reg_slice = IXGBE_CS4227_HOST_SPARE22_MSB + (hw->bus.lan_id << 12);
-       reg_val = (speed & IXGBE_LINK_SPEED_10GB_FULL) ? 0 : 0x8000;
-       ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
-                                          reg_val);
-
-       reg_slice = IXGBE_CS4227_HOST_SPARE24_LSB + (hw->bus.lan_id << 12);
-       if (setup_linear)
-               reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
-       else
-               reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
-       ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
-                                          reg_val);
-
-       /* If internal link mode is XFI, then setup XFI internal link. */
-       if (!(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE))
-               ret_val = ixgbe_setup_ixfi_x550em(hw, &speed);
-
-       return ret_val;
-}
-
 /**
  * ixgbe_setup_internal_phy_t_x550em - Configure KR PHY to X557 link
  * @hw: point to hardware structure
@@ -2929,7 +2947,7 @@ s32 ixgbe_setup_fc_X550em(struct ixgbe_hw *hw)
                goto out;
        }
 
-       if (hw->phy.media_type == ixgbe_media_type_backplane) {
+       if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
                ret_val = ixgbe_read_iosf_sb_reg_x550(hw,
                        IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
                        IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
@@ -2945,9 +2963,8 @@ s32 ixgbe_setup_fc_X550em(struct ixgbe_hw *hw)
                        IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
                        IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
 
-               /* Not all devices fully support AN. */
-               if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR)
-                       hw->fc.disable_fc_autoneg = true;
+               /* This device does not fully support AN. */
+               hw->fc.disable_fc_autoneg = true;
        }
 
 out: