ixgbe/base: set X540 phy power
authorOuyang Changchun <changchun.ouyang@intel.com>
Thu, 12 Feb 2015 12:00:40 +0000 (20:00 +0800)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Mon, 27 Apr 2015 08:05:59 +0000 (10:05 +0200)
Define the function of setting phy power;
Set copper phy power for x540.

Signed-off-by: Changchun Ouyang <changchun.ouyang@intel.com>
Acked-by: Jijiang Liu <jijiang.liu@intel.com>
lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.c
lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.h
lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c
lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.h
lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
lib/librte_pmd_ixgbe/ixgbe/ixgbe_x540.c
lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c

index 9b760cd..9c34058 100644 (file)
@@ -565,6 +565,17 @@ s32 ixgbe_setup_phy_link_speed(struct ixgbe_hw *hw, ixgbe_link_speed speed,
                               IXGBE_NOT_IMPLEMENTED);
 }
 
+/**
+ * ixgbe_set_phy_power - Control the phy power state
+ * @hw: pointer to hardware structure
+ * @on: true for on, false for off
+ */
+s32 ixgbe_set_phy_power(struct ixgbe_hw *hw, bool on)
+{
+       return ixgbe_call_func(hw, hw->phy.ops.set_phy_power, (hw, on),
+                              IXGBE_NOT_IMPLEMENTED);
+}
+
 /**
  *  ixgbe_check_link - Get link and speed status
  *  @hw: pointer to hardware structure
index dfa45a2..f0f36a2 100644 (file)
@@ -76,6 +76,7 @@ s32 ixgbe_check_phy_link(struct ixgbe_hw *hw,
 s32 ixgbe_setup_phy_link_speed(struct ixgbe_hw *hw,
                               ixgbe_link_speed speed,
                               bool autoneg_wait_to_complete);
+s32 ixgbe_set_phy_power(struct ixgbe_hw *, bool on);
 void ixgbe_disable_tx_laser(struct ixgbe_hw *hw);
 void ixgbe_enable_tx_laser(struct ixgbe_hw *hw);
 void ixgbe_flap_tx_laser(struct ixgbe_hw *hw);
index 38c9909..58a1be0 100644 (file)
@@ -2550,3 +2550,33 @@ s32 ixgbe_tn_check_overtemp(struct ixgbe_hw *hw)
 out:
        return status;
 }
+
+/**
+ * ixgbe_set_copper_phy_power - Control power for copper phy
+ * @hw: pointer to hardware structure
+ * @on: true for on, false for off
+ */
+s32 ixgbe_set_copper_phy_power(struct ixgbe_hw *hw, bool on)
+{
+       u32 status;
+       u16 reg;
+
+       status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_VENDOR_SPECIFIC_1_CONTROL,
+                                     IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
+                                     &reg);
+       if (status)
+               return status;
+
+       if (on) {
+               reg &= ~IXGBE_MDIO_PHY_SET_LOW_POWER_MODE;
+       } else {
+               if (ixgbe_check_reset_blocked(hw))
+                       return 0;
+               reg |= IXGBE_MDIO_PHY_SET_LOW_POWER_MODE;
+       }
+
+       status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_VENDOR_SPECIFIC_1_CONTROL,
+                                      IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
+                                      reg);
+       return status;
+}
index 892517c..21d88f7 100644 (file)
@@ -160,6 +160,7 @@ s32 ixgbe_get_phy_firmware_version_generic(struct ixgbe_hw *hw,
                                           u16 *firmware_version);
 
 s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw);
+s32 ixgbe_set_copper_phy_power(struct ixgbe_hw *hw, bool on);
 s32 ixgbe_identify_module_generic(struct ixgbe_hw *hw);
 s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw);
 s32 ixgbe_get_supported_phy_sfp_layer_generic(struct ixgbe_hw *hw);
index 2e36dee..376f00c 100644 (file)
@@ -3548,6 +3548,7 @@ struct ixgbe_phy_operations {
        s32 (*read_i2c_combined)(struct ixgbe_hw *, u8 addr, u16 reg, u16 *val);
        s32 (*write_i2c_combined)(struct ixgbe_hw *, u8 addr, u16 reg, u16 val);
        s32 (*check_overtemp)(struct ixgbe_hw *);
+       s32 (*set_phy_power)(struct ixgbe_hw *, bool on);
 };
 
 struct ixgbe_eeprom_info {
index 3ab2184..c2d685f 100644 (file)
@@ -81,6 +81,8 @@ s32 ixgbe_init_ops_X540(struct ixgbe_hw *hw)
        /* PHY */
        phy->ops.init = ixgbe_init_phy_ops_generic;
        phy->ops.reset = NULL;
+       if (!ixgbe_mng_present(hw))
+               phy->ops.set_phy_power = ixgbe_set_copper_phy_power;
 
        /* MAC */
        mac->ops.reset_hw = ixgbe_reset_hw_X540;
index 7d7bf9f..67e119c 100644 (file)
@@ -187,11 +187,12 @@ s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw)
                                    ixgbe_get_supported_physical_layer_X550em;
 
        /* PHY */
-       phy->ops.init = &ixgbe_init_phy_ops_X550em;
-       phy->ops.identify = &ixgbe_identify_phy_x550em;
        phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
        phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
-       phy->ops.setup_link = ixgbe_setup_kr_x550em;
+       phy->ops.init = ixgbe_init_phy_ops_X550em;
+       phy->ops.identify = ixgbe_identify_phy_x550em;
+       if (mac->ops.get_media_type(hw) != ixgbe_media_type_copper)
+               phy->ops.set_phy_power = NULL;
 
 
        /* EEPROM */