ixgbe/base: move i2c mux function for X550em
authorWenzhuo Lu <wenzhuo.lu@intel.com>
Fri, 5 Jun 2015 05:21:50 +0000 (13:21 +0800)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Mon, 15 Jun 2015 20:44:53 +0000 (22:44 +0200)
The following patch moves the handling of the I2C MUX (which is only
used for x550em SFP+ devices) out of the ixgbe_x540.c file and
into the ixgbe_x550.c file where it belongs.

Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
Acked-by: Helin Zhang <helin.zhang@intel.com>
drivers/net/ixgbe/base/ixgbe_x540.c
drivers/net/ixgbe/base/ixgbe_x550.c
drivers/net/ixgbe/base/ixgbe_x550.h

index 1462689..af29b13 100644 (file)
@@ -738,26 +738,6 @@ STATIC s32 ixgbe_poll_flash_update_done_X540(struct ixgbe_hw *hw)
        return status;
 }
 
-/**
- * ixgbe_set_mux - Set mux for port 1 access with CS4227
- * @hw: pointer to hardware structure
- * @state: set mux if 1, clear if 0
- */
-STATIC void ixgbe_set_mux(struct ixgbe_hw *hw, u8 state)
-{
-       u32 esdp;
-
-       if (!hw->bus.lan_id)
-               return;
-       esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
-       if (state)
-               esdp |= IXGBE_ESDP_SDP1;
-       else
-               esdp &= ~IXGBE_ESDP_SDP1;
-       IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
-       IXGBE_WRITE_FLUSH(hw);
-}
-
 /**
  *  ixgbe_acquire_swfw_sync_X540 - Acquire SWFW semaphore
  *  @hw: pointer to hardware structure
@@ -800,8 +780,6 @@ s32 ixgbe_acquire_swfw_sync_X540(struct ixgbe_hw *hw, u32 mask)
                        IXGBE_WRITE_REG(hw, IXGBE_SWFW_SYNC, swfw_sync);
                        ixgbe_release_swfw_sync_semaphore(hw);
                        msec_delay(5);
-                       if (swi2c_mask)
-                               ixgbe_set_mux(hw, 1);
                        return IXGBE_SUCCESS;
                }
                /* Firmware currently using resource (fwmask), hardware
@@ -832,8 +810,6 @@ s32 ixgbe_acquire_swfw_sync_X540(struct ixgbe_hw *hw, u32 mask)
                IXGBE_WRITE_REG(hw, IXGBE_SWFW_SYNC, swfw_sync);
                ixgbe_release_swfw_sync_semaphore(hw);
                msec_delay(5);
-               if (swi2c_mask)
-                       ixgbe_set_mux(hw, 1);
                return IXGBE_SUCCESS;
        }
        /* If the resource is not released by other SW the SW can assume that
@@ -871,10 +847,8 @@ void ixgbe_release_swfw_sync_X540(struct ixgbe_hw *hw, u32 mask)
 
        DEBUGFUNC("ixgbe_release_swfw_sync_X540");
 
-       if (mask & IXGBE_GSSR_I2C_MASK) {
+       if (mask & IXGBE_GSSR_I2C_MASK)
                swmask |= mask & IXGBE_GSSR_I2C_MASK;
-               ixgbe_set_mux(hw, 0);
-       }
        ixgbe_get_swfw_sync_semaphore(hw);
 
        swfw_sync = IXGBE_READ_REG(hw, IXGBE_SWFW_SYNC);
@@ -1036,5 +1010,3 @@ s32 ixgbe_blink_led_stop_X540(struct ixgbe_hw *hw, u32 index)
 
        return IXGBE_SUCCESS;
 }
-
-
index 21273d4..2c8abce 100644 (file)
@@ -383,6 +383,9 @@ s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw)
                                    ixgbe_get_supported_physical_layer_X550em;
 
                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;
+
        /* PHY */
        phy->ops.init = ixgbe_init_phy_ops_X550em;
        phy->ops.identify = ixgbe_identify_phy_x550em;
@@ -2547,3 +2550,63 @@ s32 ixgbe_setup_fc_X550em(struct ixgbe_hw *hw)
 out:
        return ret_val;
 }
+
+/**
+ * ixgbe_set_mux - Set mux for port 1 access with CS4227
+ * @hw: pointer to hardware structure
+ * @state: set mux if 1, clear if 0
+ */
+STATIC void ixgbe_set_mux(struct ixgbe_hw *hw, u8 state)
+{
+       u32 esdp;
+
+       if (!hw->bus.lan_id)
+               return;
+       esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
+       if (state)
+               esdp |= IXGBE_ESDP_SDP1;
+       else
+               esdp &= ~IXGBE_ESDP_SDP1;
+       IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
+       IXGBE_WRITE_FLUSH(hw);
+}
+
+/**
+ *  ixgbe_acquire_swfw_sync_X550em - Acquire SWFW semaphore
+ *  @hw: pointer to hardware structure
+ *  @mask: Mask to specify which semaphore to acquire
+ *
+ *  Acquires the SWFW semaphore and sets the I2C MUX
+ **/
+s32 ixgbe_acquire_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask)
+{
+       s32 status;
+
+       DEBUGFUNC("ixgbe_acquire_swfw_sync_X550em");
+
+       status = ixgbe_acquire_swfw_sync_X540(hw, mask);
+       if (status)
+               return status;
+
+       if (mask & IXGBE_GSSR_I2C_MASK)
+               ixgbe_set_mux(hw, 1);
+
+       return IXGBE_SUCCESS;
+}
+
+/**
+ *  ixgbe_release_swfw_sync_X550em - Release SWFW semaphore
+ *  @hw: pointer to hardware structure
+ *  @mask: Mask to specify which semaphore to release
+ *
+ *  Releases the SWFW semaphore and sets the I2C MUX
+ **/
+void ixgbe_release_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask)
+{
+       DEBUGFUNC("ixgbe_release_swfw_sync_X550em");
+
+       if (mask & IXGBE_GSSR_I2C_MASK)
+               ixgbe_set_mux(hw, 0);
+
+       ixgbe_release_swfw_sync_X540(hw, mask);
+}
index a922f93..a60c7ce 100644 (file)
@@ -89,6 +89,8 @@ u32 ixgbe_get_supported_physical_layer_X550em(struct ixgbe_hw *hw);
 void ixgbe_disable_rx_x550(struct ixgbe_hw *hw);
 s32 ixgbe_get_lcd_t_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *lcd_speed);
 s32 ixgbe_enter_lplu_t_x550em(struct ixgbe_hw *hw);
+s32 ixgbe_acquire_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask);
+void ixgbe_release_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask);
 s32 ixgbe_setup_fc_X550em(struct ixgbe_hw *hw);
 s32 ixgbe_setup_mac_link_sfp_x550em(struct ixgbe_hw *hw,
                                    ixgbe_link_speed speed,