Commit 542c3f4e authored by Joe Perches's avatar Joe Perches Committed by Jeff Kirsher

e1000: Neaten e1000_config_dsp_after_link_change

Separate a complicated bit of e1000_config_dsp_after_link_change
into a new static function e1000_1000Mb_check_cable_length.

Reduces indentation and adds a bit of clarity.
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Tested-by: default avatarAaron Brown <aaron.f.brown@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent dffcdde7
...@@ -5253,109 +5253,62 @@ static s32 e1000_check_downshift(struct e1000_hw *hw) ...@@ -5253,109 +5253,62 @@ static s32 e1000_check_downshift(struct e1000_hw *hw)
return E1000_SUCCESS; return E1000_SUCCESS;
} }
/** static const u16 dsp_reg_array[IGP01E1000_PHY_CHANNEL_NUM] = {
* e1000_config_dsp_after_link_change
* @hw: Struct containing variables accessed by shared code
* @link_up: was link up at the time this was called
*
* returns: - E1000_ERR_PHY if fail to read/write the PHY
* E1000_SUCCESS at any other case.
*
* 82541_rev_2 & 82547_rev_2 have the capability to configure the DSP when a
* gigabit link is achieved to improve link quality.
*/
static s32 e1000_config_dsp_after_link_change(struct e1000_hw *hw, bool link_up)
{
s32 ret_val;
u16 phy_data, phy_saved_data, speed, duplex, i;
static const u16 dsp_reg_array[IGP01E1000_PHY_CHANNEL_NUM] = {
IGP01E1000_PHY_AGC_PARAM_A, IGP01E1000_PHY_AGC_PARAM_A,
IGP01E1000_PHY_AGC_PARAM_B, IGP01E1000_PHY_AGC_PARAM_B,
IGP01E1000_PHY_AGC_PARAM_C, IGP01E1000_PHY_AGC_PARAM_C,
IGP01E1000_PHY_AGC_PARAM_D IGP01E1000_PHY_AGC_PARAM_D
}; };
u16 min_length, max_length;
e_dbg("e1000_config_dsp_after_link_change");
if (hw->phy_type != e1000_phy_igp)
return E1000_SUCCESS;
if (link_up) {
ret_val = e1000_get_speed_and_duplex(hw, &speed, &duplex);
if (ret_val) {
e_dbg("Error getting link speed and duplex\n");
return ret_val;
}
if (speed == SPEED_1000) { static s32 e1000_1000Mb_check_cable_length(struct e1000_hw *hw)
{
u16 min_length, max_length;
u16 phy_data, i;
s32 ret_val;
ret_val = ret_val = e1000_get_cable_length(hw, &min_length, &max_length);
e1000_get_cable_length(hw, &min_length,
&max_length);
if (ret_val) if (ret_val)
return ret_val; return ret_val;
if ((hw->dsp_config_state == e1000_dsp_config_enabled) if (hw->dsp_config_state != e1000_dsp_config_enabled)
&& min_length >= e1000_igp_cable_length_50) { return 0;
if (min_length >= e1000_igp_cable_length_50) {
for (i = 0; i < IGP01E1000_PHY_CHANNEL_NUM; i++) { for (i = 0; i < IGP01E1000_PHY_CHANNEL_NUM; i++) {
ret_val = ret_val = e1000_read_phy_reg(hw, dsp_reg_array[i],
e1000_read_phy_reg(hw,
dsp_reg_array[i],
&phy_data); &phy_data);
if (ret_val) if (ret_val)
return ret_val; return ret_val;
phy_data &= phy_data &= ~IGP01E1000_PHY_EDAC_MU_INDEX;
~IGP01E1000_PHY_EDAC_MU_INDEX;
ret_val = ret_val = e1000_write_phy_reg(hw, dsp_reg_array[i],
e1000_write_phy_reg(hw, phy_data);
dsp_reg_array
[i], phy_data);
if (ret_val) if (ret_val)
return ret_val; return ret_val;
} }
hw->dsp_config_state = hw->dsp_config_state = e1000_dsp_config_activated;
e1000_dsp_config_activated; } else {
} u16 ffe_idle_err_timeout = FFE_IDLE_ERR_COUNT_TIMEOUT_20;
if ((hw->ffe_config_state == e1000_ffe_config_enabled)
&& (min_length < e1000_igp_cable_length_50)) {
u16 ffe_idle_err_timeout =
FFE_IDLE_ERR_COUNT_TIMEOUT_20;
u32 idle_errs = 0; u32 idle_errs = 0;
/* clear previous idle error counts */ /* clear previous idle error counts */
ret_val = ret_val = e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_data);
e1000_read_phy_reg(hw, PHY_1000T_STATUS,
&phy_data);
if (ret_val) if (ret_val)
return ret_val; return ret_val;
for (i = 0; i < ffe_idle_err_timeout; i++) { for (i = 0; i < ffe_idle_err_timeout; i++) {
udelay(1000); udelay(1000);
ret_val = ret_val = e1000_read_phy_reg(hw, PHY_1000T_STATUS,
e1000_read_phy_reg(hw,
PHY_1000T_STATUS,
&phy_data); &phy_data);
if (ret_val) if (ret_val)
return ret_val; return ret_val;
idle_errs += idle_errs += (phy_data & SR_1000T_IDLE_ERROR_CNT);
(phy_data & if (idle_errs > SR_1000T_PHY_EXCESSIVE_IDLE_ERR_COUNT) {
SR_1000T_IDLE_ERROR_CNT); hw->ffe_config_state = e1000_ffe_config_active;
if (idle_errs >
SR_1000T_PHY_EXCESSIVE_IDLE_ERR_COUNT)
{
hw->ffe_config_state =
e1000_ffe_config_active;
ret_val = ret_val = e1000_write_phy_reg(hw,
e1000_write_phy_reg(hw,
IGP01E1000_PHY_DSP_FFE, IGP01E1000_PHY_DSP_FFE,
IGP01E1000_PHY_DSP_FFE_CM_CP); IGP01E1000_PHY_DSP_FFE_CM_CP);
if (ret_val) if (ret_val)
...@@ -5368,6 +5321,43 @@ static s32 e1000_config_dsp_after_link_change(struct e1000_hw *hw, bool link_up) ...@@ -5368,6 +5321,43 @@ static s32 e1000_config_dsp_after_link_change(struct e1000_hw *hw, bool link_up)
FFE_IDLE_ERR_COUNT_TIMEOUT_100; FFE_IDLE_ERR_COUNT_TIMEOUT_100;
} }
} }
return 0;
}
/**
* e1000_config_dsp_after_link_change
* @hw: Struct containing variables accessed by shared code
* @link_up: was link up at the time this was called
*
* returns: - E1000_ERR_PHY if fail to read/write the PHY
* E1000_SUCCESS at any other case.
*
* 82541_rev_2 & 82547_rev_2 have the capability to configure the DSP when a
* gigabit link is achieved to improve link quality.
*/
static s32 e1000_config_dsp_after_link_change(struct e1000_hw *hw, bool link_up)
{
s32 ret_val;
u16 phy_data, phy_saved_data, speed, duplex, i;
e_dbg("e1000_config_dsp_after_link_change");
if (hw->phy_type != e1000_phy_igp)
return E1000_SUCCESS;
if (link_up) {
ret_val = e1000_get_speed_and_duplex(hw, &speed, &duplex);
if (ret_val) {
e_dbg("Error getting link speed and duplex\n");
return ret_val;
}
if (speed == SPEED_1000) {
ret_val = e1000_1000Mb_check_cable_length(hw);
if (ret_val)
return ret_val;
} }
} else { } else {
if (hw->dsp_config_state == e1000_dsp_config_activated) { if (hw->dsp_config_state == e1000_dsp_config_activated) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment