diff options
author | Bruce Allan <bruce.w.allan@intel.com> | 2012-12-05 01:25:58 -0500 |
---|---|---|
committer | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2013-01-16 00:47:20 -0500 |
commit | 4ddc48a9a5f3352343eb4725eb75f9ca38fa1559 (patch) | |
tree | 78caa2906cef8854115d7a778e1cf0b5069e1cb5 | |
parent | 1cc7a3a14fa60f31ca4ff69f0dd31f369e0a51c2 (diff) |
e1000e: helper functions for accessing EMI registers
The Extended Management Interface (EMI) registers are accessed by first
writing the EMI register offset to the EMI_ADDR regiter and then either
reading or writing the data to/from the EMI_DATA register. Add helper
functions for performing these steps and convert existing EMI register
accesses accordingly.
Signed-off-by: Bruce Allan <bruce.w.allan@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
-rw-r--r-- | drivers/net/ethernet/intel/e1000e/ich8lan.c | 84 |
1 files changed, 65 insertions, 19 deletions
diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c index 7d5f6b7856e6..8004d7113c39 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c | |||
@@ -153,7 +153,7 @@ | |||
153 | #define I82579_LPI_CTRL_ENABLE_MASK 0x6000 | 153 | #define I82579_LPI_CTRL_ENABLE_MASK 0x6000 |
154 | #define I82579_LPI_CTRL_FORCE_PLL_LOCK_COUNT 0x80 | 154 | #define I82579_LPI_CTRL_FORCE_PLL_LOCK_COUNT 0x80 |
155 | 155 | ||
156 | /* EMI Registers */ | 156 | /* Extended Management Interface (EMI) Registers */ |
157 | #define I82579_EMI_ADDR 0x10 | 157 | #define I82579_EMI_ADDR 0x10 |
158 | #define I82579_EMI_DATA 0x11 | 158 | #define I82579_EMI_DATA 0x11 |
159 | #define I82579_LPI_UPDATE_TIMER 0x4805 /* in 40ns units + 40 ns base value */ | 159 | #define I82579_LPI_UPDATE_TIMER 0x4805 /* in 40ns units + 40 ns base value */ |
@@ -789,6 +789,58 @@ static s32 e1000_init_mac_params_ich8lan(struct e1000_hw *hw) | |||
789 | } | 789 | } |
790 | 790 | ||
791 | /** | 791 | /** |
792 | * __e1000_access_emi_reg_locked - Read/write EMI register | ||
793 | * @hw: pointer to the HW structure | ||
794 | * @addr: EMI address to program | ||
795 | * @data: pointer to value to read/write from/to the EMI address | ||
796 | * @read: boolean flag to indicate read or write | ||
797 | * | ||
798 | * This helper function assumes the SW/FW/HW Semaphore is already acquired. | ||
799 | **/ | ||
800 | static s32 __e1000_access_emi_reg_locked(struct e1000_hw *hw, u16 address, | ||
801 | u16 *data, bool read) | ||
802 | { | ||
803 | s32 ret_val = 0; | ||
804 | |||
805 | ret_val = e1e_wphy_locked(hw, I82579_EMI_ADDR, address); | ||
806 | if (ret_val) | ||
807 | return ret_val; | ||
808 | |||
809 | if (read) | ||
810 | ret_val = e1e_rphy_locked(hw, I82579_EMI_DATA, data); | ||
811 | else | ||
812 | ret_val = e1e_wphy_locked(hw, I82579_EMI_DATA, *data); | ||
813 | |||
814 | return ret_val; | ||
815 | } | ||
816 | |||
817 | /** | ||
818 | * e1000_read_emi_reg_locked - Read Extended Management Interface register | ||
819 | * @hw: pointer to the HW structure | ||
820 | * @addr: EMI address to program | ||
821 | * @data: value to be read from the EMI address | ||
822 | * | ||
823 | * Assumes the SW/FW/HW Semaphore is already acquired. | ||
824 | **/ | ||
825 | static s32 e1000_read_emi_reg_locked(struct e1000_hw *hw, u16 addr, u16 *data) | ||
826 | { | ||
827 | return __e1000_access_emi_reg_locked(hw, addr, data, true); | ||
828 | } | ||
829 | |||
830 | /** | ||
831 | * e1000_write_emi_reg_locked - Write Extended Management Interface register | ||
832 | * @hw: pointer to the HW structure | ||
833 | * @addr: EMI address to program | ||
834 | * @data: value to be written to the EMI address | ||
835 | * | ||
836 | * Assumes the SW/FW/HW Semaphore is already acquired. | ||
837 | **/ | ||
838 | static s32 e1000_write_emi_reg_locked(struct e1000_hw *hw, u16 addr, u16 data) | ||
839 | { | ||
840 | return __e1000_access_emi_reg_locked(hw, addr, &data, false); | ||
841 | } | ||
842 | |||
843 | /** | ||
792 | * e1000_set_eee_pchlan - Enable/disable EEE support | 844 | * e1000_set_eee_pchlan - Enable/disable EEE support |
793 | * @hw: pointer to the HW structure | 845 | * @hw: pointer to the HW structure |
794 | * | 846 | * |
@@ -823,11 +875,11 @@ static s32 e1000_set_eee_pchlan(struct e1000_hw *hw) | |||
823 | ret_val = hw->phy.ops.acquire(hw); | 875 | ret_val = hw->phy.ops.acquire(hw); |
824 | if (ret_val) | 876 | if (ret_val) |
825 | return ret_val; | 877 | return ret_val; |
826 | ret_val = e1e_wphy_locked(hw, I82579_EMI_ADDR, | 878 | ret_val = e1000_read_emi_reg_locked(hw, |
827 | I217_EEE_LP_ABILITY); | 879 | I217_EEE_LP_ABILITY, |
880 | &dev_spec->eee_lp_ability); | ||
828 | if (ret_val) | 881 | if (ret_val) |
829 | goto release; | 882 | goto release; |
830 | e1e_rphy_locked(hw, I82579_EMI_DATA, &dev_spec->eee_lp_ability); | ||
831 | 883 | ||
832 | /* EEE is not supported in 100Half, so ignore partner's EEE | 884 | /* EEE is not supported in 100Half, so ignore partner's EEE |
833 | * in 100 ability if full-duplex is not advertised. | 885 | * in 100 ability if full-duplex is not advertised. |
@@ -1987,18 +2039,12 @@ static s32 e1000_lv_phy_workarounds_ich8lan(struct e1000_hw *hw) | |||
1987 | ret_val = hw->phy.ops.acquire(hw); | 2039 | ret_val = hw->phy.ops.acquire(hw); |
1988 | if (ret_val) | 2040 | if (ret_val) |
1989 | return ret_val; | 2041 | return ret_val; |
1990 | ret_val = e1e_wphy_locked(hw, I82579_EMI_ADDR, I82579_MSE_THRESHOLD); | ||
1991 | if (ret_val) | ||
1992 | goto release; | ||
1993 | /* set MSE higher to enable link to stay up when noise is high */ | 2042 | /* set MSE higher to enable link to stay up when noise is high */ |
1994 | ret_val = e1e_wphy_locked(hw, I82579_EMI_DATA, 0x0034); | 2043 | ret_val = e1000_write_emi_reg_locked(hw, I82579_MSE_THRESHOLD, 0x0034); |
1995 | if (ret_val) | ||
1996 | goto release; | ||
1997 | ret_val = e1e_wphy_locked(hw, I82579_EMI_ADDR, I82579_MSE_LINK_DOWN); | ||
1998 | if (ret_val) | 2044 | if (ret_val) |
1999 | goto release; | 2045 | goto release; |
2000 | /* drop link after 5 times MSE threshold was reached */ | 2046 | /* drop link after 5 times MSE threshold was reached */ |
2001 | ret_val = e1e_wphy_locked(hw, I82579_EMI_DATA, 0x0005); | 2047 | ret_val = e1000_write_emi_reg_locked(hw, I82579_MSE_LINK_DOWN, 0x0005); |
2002 | release: | 2048 | release: |
2003 | hw->phy.ops.release(hw); | 2049 | hw->phy.ops.release(hw); |
2004 | 2050 | ||
@@ -2172,10 +2218,9 @@ static s32 e1000_post_phy_reset_ich8lan(struct e1000_hw *hw) | |||
2172 | ret_val = hw->phy.ops.acquire(hw); | 2218 | ret_val = hw->phy.ops.acquire(hw); |
2173 | if (ret_val) | 2219 | if (ret_val) |
2174 | return ret_val; | 2220 | return ret_val; |
2175 | ret_val = e1e_wphy_locked(hw, I82579_EMI_ADDR, | 2221 | ret_val = e1000_write_emi_reg_locked(hw, |
2176 | I82579_LPI_UPDATE_TIMER); | 2222 | I82579_LPI_UPDATE_TIMER, |
2177 | if (!ret_val) | 2223 | 0x1387); |
2178 | ret_val = e1e_wphy_locked(hw, I82579_EMI_DATA, 0x1387); | ||
2179 | hw->phy.ops.release(hw); | 2224 | hw->phy.ops.release(hw); |
2180 | } | 2225 | } |
2181 | 2226 | ||
@@ -4013,11 +4058,12 @@ void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw) | |||
4013 | if (!dev_spec->eee_disable) { | 4058 | if (!dev_spec->eee_disable) { |
4014 | u16 eee_advert; | 4059 | u16 eee_advert; |
4015 | 4060 | ||
4016 | ret_val = e1e_wphy_locked(hw, I82579_EMI_ADDR, | 4061 | ret_val = |
4017 | I217_EEE_ADVERTISEMENT); | 4062 | e1000_read_emi_reg_locked(hw, |
4063 | I217_EEE_ADVERTISEMENT, | ||
4064 | &eee_advert); | ||
4018 | if (ret_val) | 4065 | if (ret_val) |
4019 | goto release; | 4066 | goto release; |
4020 | e1e_rphy_locked(hw, I82579_EMI_DATA, &eee_advert); | ||
4021 | 4067 | ||
4022 | /* Disable LPLU if both link partners support 100BaseT | 4068 | /* Disable LPLU if both link partners support 100BaseT |
4023 | * EEE and 100Full is advertised on both ends of the | 4069 | * EEE and 100Full is advertised on both ends of the |