Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | |
| 3 | Intel PRO/1000 Linux driver |
Bruce Allan | c7e54b1 | 2009-11-20 23:25:45 +0000 | [diff] [blame] | 4 | Copyright(c) 1999 - 2009 Intel Corporation. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 5 | |
| 6 | This program is free software; you can redistribute it and/or modify it |
| 7 | under the terms and conditions of the GNU General Public License, |
| 8 | version 2, as published by the Free Software Foundation. |
| 9 | |
| 10 | This program is distributed in the hope it will be useful, but WITHOUT |
| 11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 13 | more details. |
| 14 | |
| 15 | You should have received a copy of the GNU General Public License along with |
| 16 | this program; if not, write to the Free Software Foundation, Inc., |
| 17 | 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | |
| 19 | The full GNU General Public License is included in this distribution in |
| 20 | the file called "COPYING". |
| 21 | |
| 22 | Contact Information: |
| 23 | Linux NICS <linux.nics@intel.com> |
| 24 | e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> |
| 25 | Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 26 | |
| 27 | *******************************************************************************/ |
| 28 | |
| 29 | /* |
| 30 | * 80003ES2LAN Gigabit Ethernet Controller (Copper) |
| 31 | * 80003ES2LAN Gigabit Ethernet Controller (Serdes) |
| 32 | */ |
| 33 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 34 | #include "e1000.h" |
| 35 | |
| 36 | #define E1000_KMRNCTRLSTA_OFFSET_FIFO_CTRL 0x00 |
| 37 | #define E1000_KMRNCTRLSTA_OFFSET_INB_CTRL 0x02 |
| 38 | #define E1000_KMRNCTRLSTA_OFFSET_HD_CTRL 0x10 |
David Graham | 2d9498f | 2008-04-23 11:09:14 -0700 | [diff] [blame] | 39 | #define E1000_KMRNCTRLSTA_OFFSET_MAC2PHY_OPMODE 0x1F |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 40 | |
| 41 | #define E1000_KMRNCTRLSTA_FIFO_CTRL_RX_BYPASS 0x0008 |
| 42 | #define E1000_KMRNCTRLSTA_FIFO_CTRL_TX_BYPASS 0x0800 |
| 43 | #define E1000_KMRNCTRLSTA_INB_CTRL_DIS_PADDING 0x0010 |
| 44 | |
| 45 | #define E1000_KMRNCTRLSTA_HD_CTRL_10_100_DEFAULT 0x0004 |
| 46 | #define E1000_KMRNCTRLSTA_HD_CTRL_1000_DEFAULT 0x0000 |
David Graham | 2d9498f | 2008-04-23 11:09:14 -0700 | [diff] [blame] | 47 | #define E1000_KMRNCTRLSTA_OPMODE_E_IDLE 0x2000 |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 48 | |
| 49 | #define E1000_TCTL_EXT_GCEX_MASK 0x000FFC00 /* Gigabit Carry Extend Padding */ |
| 50 | #define DEFAULT_TCTL_EXT_GCEX_80003ES2LAN 0x00010000 |
| 51 | |
| 52 | #define DEFAULT_TIPG_IPGT_1000_80003ES2LAN 0x8 |
| 53 | #define DEFAULT_TIPG_IPGT_10_100_80003ES2LAN 0x9 |
| 54 | |
| 55 | /* GG82563 PHY Specific Status Register (Page 0, Register 16 */ |
| 56 | #define GG82563_PSCR_POLARITY_REVERSAL_DISABLE 0x0002 /* 1=Reversal Disab. */ |
| 57 | #define GG82563_PSCR_CROSSOVER_MODE_MASK 0x0060 |
| 58 | #define GG82563_PSCR_CROSSOVER_MODE_MDI 0x0000 /* 00=Manual MDI */ |
| 59 | #define GG82563_PSCR_CROSSOVER_MODE_MDIX 0x0020 /* 01=Manual MDIX */ |
| 60 | #define GG82563_PSCR_CROSSOVER_MODE_AUTO 0x0060 /* 11=Auto crossover */ |
| 61 | |
| 62 | /* PHY Specific Control Register 2 (Page 0, Register 26) */ |
| 63 | #define GG82563_PSCR2_REVERSE_AUTO_NEG 0x2000 |
| 64 | /* 1=Reverse Auto-Negotiation */ |
| 65 | |
| 66 | /* MAC Specific Control Register (Page 2, Register 21) */ |
| 67 | /* Tx clock speed for Link Down and 1000BASE-T for the following speeds */ |
| 68 | #define GG82563_MSCR_TX_CLK_MASK 0x0007 |
| 69 | #define GG82563_MSCR_TX_CLK_10MBPS_2_5 0x0004 |
| 70 | #define GG82563_MSCR_TX_CLK_100MBPS_25 0x0005 |
| 71 | #define GG82563_MSCR_TX_CLK_1000MBPS_25 0x0007 |
| 72 | |
| 73 | #define GG82563_MSCR_ASSERT_CRS_ON_TX 0x0010 /* 1=Assert */ |
| 74 | |
| 75 | /* DSP Distance Register (Page 5, Register 26) */ |
| 76 | #define GG82563_DSPD_CABLE_LENGTH 0x0007 /* 0 = <50M |
| 77 | 1 = 50-80M |
| 78 | 2 = 80-110M |
| 79 | 3 = 110-140M |
| 80 | 4 = >140M */ |
| 81 | |
| 82 | /* Kumeran Mode Control Register (Page 193, Register 16) */ |
| 83 | #define GG82563_KMCR_PASS_FALSE_CARRIER 0x0800 |
| 84 | |
David Graham | 2d9498f | 2008-04-23 11:09:14 -0700 | [diff] [blame] | 85 | /* Max number of times Kumeran read/write should be validated */ |
| 86 | #define GG82563_MAX_KMRN_RETRY 0x5 |
| 87 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 88 | /* Power Management Control Register (Page 193, Register 20) */ |
| 89 | #define GG82563_PMCR_ENABLE_ELECTRICAL_IDLE 0x0001 |
| 90 | /* 1=Enable SERDES Electrical Idle */ |
| 91 | |
| 92 | /* In-Band Control Register (Page 194, Register 18) */ |
| 93 | #define GG82563_ICR_DIS_PADDING 0x0010 /* Disable Padding */ |
| 94 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 95 | /* |
| 96 | * A table for the GG82563 cable length where the range is defined |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 97 | * with a lower bound at "index" and the upper bound at |
| 98 | * "index + 5". |
| 99 | */ |
| 100 | static const u16 e1000_gg82563_cable_length_table[] = |
| 101 | { 0, 60, 115, 150, 150, 60, 115, 150, 180, 180, 0xFF }; |
| 102 | |
| 103 | static s32 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw); |
| 104 | static s32 e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask); |
| 105 | static void e1000_release_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask); |
| 106 | static void e1000_initialize_hw_bits_80003es2lan(struct e1000_hw *hw); |
| 107 | static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw); |
| 108 | static s32 e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw); |
| 109 | static s32 e1000_cfg_kmrn_10_100_80003es2lan(struct e1000_hw *hw, u16 duplex); |
Bruce Allan | 75eb0fa | 2008-11-21 16:53:51 -0800 | [diff] [blame] | 110 | static s32 e1000_cfg_on_link_up_80003es2lan(struct e1000_hw *hw); |
| 111 | static s32 e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset, |
| 112 | u16 *data); |
| 113 | static s32 e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset, |
| 114 | u16 data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 115 | |
| 116 | /** |
| 117 | * e1000_init_phy_params_80003es2lan - Init ESB2 PHY func ptrs. |
| 118 | * @hw: pointer to the HW structure |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 119 | **/ |
| 120 | static s32 e1000_init_phy_params_80003es2lan(struct e1000_hw *hw) |
| 121 | { |
| 122 | struct e1000_phy_info *phy = &hw->phy; |
| 123 | s32 ret_val; |
| 124 | |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 125 | if (hw->phy.media_type != e1000_media_type_copper) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 126 | phy->type = e1000_phy_none; |
| 127 | return 0; |
| 128 | } |
| 129 | |
| 130 | phy->addr = 1; |
| 131 | phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT; |
| 132 | phy->reset_delay_us = 100; |
| 133 | phy->type = e1000_phy_gg82563; |
| 134 | |
| 135 | /* This can only be done after all function pointers are setup. */ |
| 136 | ret_val = e1000e_get_phy_id(hw); |
| 137 | |
| 138 | /* Verify phy id */ |
| 139 | if (phy->id != GG82563_E_PHY_ID) |
| 140 | return -E1000_ERR_PHY; |
| 141 | |
| 142 | return ret_val; |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * e1000_init_nvm_params_80003es2lan - Init ESB2 NVM func ptrs. |
| 147 | * @hw: pointer to the HW structure |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 148 | **/ |
| 149 | static s32 e1000_init_nvm_params_80003es2lan(struct e1000_hw *hw) |
| 150 | { |
| 151 | struct e1000_nvm_info *nvm = &hw->nvm; |
| 152 | u32 eecd = er32(EECD); |
| 153 | u16 size; |
| 154 | |
| 155 | nvm->opcode_bits = 8; |
| 156 | nvm->delay_usec = 1; |
| 157 | switch (nvm->override) { |
| 158 | case e1000_nvm_override_spi_large: |
| 159 | nvm->page_size = 32; |
| 160 | nvm->address_bits = 16; |
| 161 | break; |
| 162 | case e1000_nvm_override_spi_small: |
| 163 | nvm->page_size = 8; |
| 164 | nvm->address_bits = 8; |
| 165 | break; |
| 166 | default: |
| 167 | nvm->page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8; |
| 168 | nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ? 16 : 8; |
| 169 | break; |
| 170 | } |
| 171 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 172 | nvm->type = e1000_nvm_eeprom_spi; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 173 | |
| 174 | size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >> |
| 175 | E1000_EECD_SIZE_EX_SHIFT); |
| 176 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 177 | /* |
| 178 | * Added to a constant, "size" becomes the left-shift value |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 179 | * for setting word_size. |
| 180 | */ |
| 181 | size += NVM_WORD_SIZE_BASE_SHIFT; |
Jeff Kirsher | 8d7c294 | 2008-04-02 13:48:07 -0700 | [diff] [blame] | 182 | |
| 183 | /* EEPROM access above 16k is unsupported */ |
| 184 | if (size > 14) |
| 185 | size = 14; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 186 | nvm->word_size = 1 << size; |
| 187 | |
| 188 | return 0; |
| 189 | } |
| 190 | |
| 191 | /** |
| 192 | * e1000_init_mac_params_80003es2lan - Init ESB2 MAC func ptrs. |
| 193 | * @hw: pointer to the HW structure |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 194 | **/ |
| 195 | static s32 e1000_init_mac_params_80003es2lan(struct e1000_adapter *adapter) |
| 196 | { |
| 197 | struct e1000_hw *hw = &adapter->hw; |
| 198 | struct e1000_mac_info *mac = &hw->mac; |
| 199 | struct e1000_mac_operations *func = &mac->ops; |
| 200 | |
| 201 | /* Set media type */ |
| 202 | switch (adapter->pdev->device) { |
| 203 | case E1000_DEV_ID_80003ES2LAN_SERDES_DPT: |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 204 | hw->phy.media_type = e1000_media_type_internal_serdes; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 205 | break; |
| 206 | default: |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 207 | hw->phy.media_type = e1000_media_type_copper; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 208 | break; |
| 209 | } |
| 210 | |
| 211 | /* Set mta register count */ |
| 212 | mac->mta_reg_count = 128; |
| 213 | /* Set rar entry count */ |
| 214 | mac->rar_entry_count = E1000_RAR_ENTRIES; |
| 215 | /* Set if manageability features are enabled. */ |
Bruce Allan | 564ea9b | 2009-11-20 23:26:44 +0000 | [diff] [blame] | 216 | mac->arc_subsystem_valid = (er32(FWSM) & E1000_FWSM_MODE_MASK) |
| 217 | ? true : false; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 218 | |
| 219 | /* check for link */ |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 220 | switch (hw->phy.media_type) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 221 | case e1000_media_type_copper: |
| 222 | func->setup_physical_interface = e1000_setup_copper_link_80003es2lan; |
| 223 | func->check_for_link = e1000e_check_for_copper_link; |
| 224 | break; |
| 225 | case e1000_media_type_fiber: |
| 226 | func->setup_physical_interface = e1000e_setup_fiber_serdes_link; |
| 227 | func->check_for_link = e1000e_check_for_fiber_link; |
| 228 | break; |
| 229 | case e1000_media_type_internal_serdes: |
| 230 | func->setup_physical_interface = e1000e_setup_fiber_serdes_link; |
| 231 | func->check_for_link = e1000e_check_for_serdes_link; |
| 232 | break; |
| 233 | default: |
| 234 | return -E1000_ERR_CONFIG; |
| 235 | break; |
| 236 | } |
| 237 | |
| 238 | return 0; |
| 239 | } |
| 240 | |
Jeff Kirsher | 69e3fd8 | 2008-04-02 13:48:18 -0700 | [diff] [blame] | 241 | static s32 e1000_get_variants_80003es2lan(struct e1000_adapter *adapter) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 242 | { |
| 243 | struct e1000_hw *hw = &adapter->hw; |
| 244 | s32 rc; |
| 245 | |
| 246 | rc = e1000_init_mac_params_80003es2lan(adapter); |
| 247 | if (rc) |
| 248 | return rc; |
| 249 | |
| 250 | rc = e1000_init_nvm_params_80003es2lan(hw); |
| 251 | if (rc) |
| 252 | return rc; |
| 253 | |
| 254 | rc = e1000_init_phy_params_80003es2lan(hw); |
| 255 | if (rc) |
| 256 | return rc; |
| 257 | |
| 258 | return 0; |
| 259 | } |
| 260 | |
| 261 | /** |
| 262 | * e1000_acquire_phy_80003es2lan - Acquire rights to access PHY |
| 263 | * @hw: pointer to the HW structure |
| 264 | * |
Bruce Allan | fe40167 | 2009-11-20 23:26:05 +0000 | [diff] [blame] | 265 | * A wrapper to acquire access rights to the correct PHY. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 266 | **/ |
| 267 | static s32 e1000_acquire_phy_80003es2lan(struct e1000_hw *hw) |
| 268 | { |
| 269 | u16 mask; |
| 270 | |
| 271 | mask = hw->bus.func ? E1000_SWFW_PHY1_SM : E1000_SWFW_PHY0_SM; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 272 | return e1000_acquire_swfw_sync_80003es2lan(hw, mask); |
| 273 | } |
| 274 | |
| 275 | /** |
| 276 | * e1000_release_phy_80003es2lan - Release rights to access PHY |
| 277 | * @hw: pointer to the HW structure |
| 278 | * |
Bruce Allan | fe40167 | 2009-11-20 23:26:05 +0000 | [diff] [blame] | 279 | * A wrapper to release access rights to the correct PHY. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 280 | **/ |
| 281 | static void e1000_release_phy_80003es2lan(struct e1000_hw *hw) |
| 282 | { |
| 283 | u16 mask; |
| 284 | |
| 285 | mask = hw->bus.func ? E1000_SWFW_PHY1_SM : E1000_SWFW_PHY0_SM; |
Bruce Allan | 75eb0fa | 2008-11-21 16:53:51 -0800 | [diff] [blame] | 286 | e1000_release_swfw_sync_80003es2lan(hw, mask); |
| 287 | } |
| 288 | |
| 289 | /** |
| 290 | * e1000_acquire_mac_csr_80003es2lan - Acquire rights to access Kumeran register |
| 291 | * @hw: pointer to the HW structure |
| 292 | * |
| 293 | * Acquire the semaphore to access the Kumeran interface. |
| 294 | * |
| 295 | **/ |
| 296 | static s32 e1000_acquire_mac_csr_80003es2lan(struct e1000_hw *hw) |
| 297 | { |
| 298 | u16 mask; |
| 299 | |
| 300 | mask = E1000_SWFW_CSR_SM; |
| 301 | |
| 302 | return e1000_acquire_swfw_sync_80003es2lan(hw, mask); |
| 303 | } |
| 304 | |
| 305 | /** |
| 306 | * e1000_release_mac_csr_80003es2lan - Release rights to access Kumeran Register |
| 307 | * @hw: pointer to the HW structure |
| 308 | * |
| 309 | * Release the semaphore used to access the Kumeran interface |
| 310 | **/ |
| 311 | static void e1000_release_mac_csr_80003es2lan(struct e1000_hw *hw) |
| 312 | { |
| 313 | u16 mask; |
| 314 | |
| 315 | mask = E1000_SWFW_CSR_SM; |
David Graham | 2d9498f | 2008-04-23 11:09:14 -0700 | [diff] [blame] | 316 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 317 | e1000_release_swfw_sync_80003es2lan(hw, mask); |
| 318 | } |
| 319 | |
| 320 | /** |
| 321 | * e1000_acquire_nvm_80003es2lan - Acquire rights to access NVM |
| 322 | * @hw: pointer to the HW structure |
| 323 | * |
Bruce Allan | fe40167 | 2009-11-20 23:26:05 +0000 | [diff] [blame] | 324 | * Acquire the semaphore to access the EEPROM. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 325 | **/ |
| 326 | static s32 e1000_acquire_nvm_80003es2lan(struct e1000_hw *hw) |
| 327 | { |
| 328 | s32 ret_val; |
| 329 | |
| 330 | ret_val = e1000_acquire_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM); |
| 331 | if (ret_val) |
| 332 | return ret_val; |
| 333 | |
| 334 | ret_val = e1000e_acquire_nvm(hw); |
| 335 | |
| 336 | if (ret_val) |
| 337 | e1000_release_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM); |
| 338 | |
| 339 | return ret_val; |
| 340 | } |
| 341 | |
| 342 | /** |
| 343 | * e1000_release_nvm_80003es2lan - Relinquish rights to access NVM |
| 344 | * @hw: pointer to the HW structure |
| 345 | * |
Bruce Allan | fe40167 | 2009-11-20 23:26:05 +0000 | [diff] [blame] | 346 | * Release the semaphore used to access the EEPROM. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 347 | **/ |
| 348 | static void e1000_release_nvm_80003es2lan(struct e1000_hw *hw) |
| 349 | { |
| 350 | e1000e_release_nvm(hw); |
| 351 | e1000_release_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM); |
| 352 | } |
| 353 | |
| 354 | /** |
| 355 | * e1000_acquire_swfw_sync_80003es2lan - Acquire SW/FW semaphore |
| 356 | * @hw: pointer to the HW structure |
| 357 | * @mask: specifies which semaphore to acquire |
| 358 | * |
| 359 | * Acquire the SW/FW semaphore to access the PHY or NVM. The mask |
| 360 | * will also specify which port we're acquiring the lock for. |
| 361 | **/ |
| 362 | static s32 e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask) |
| 363 | { |
| 364 | u32 swfw_sync; |
| 365 | u32 swmask = mask; |
| 366 | u32 fwmask = mask << 16; |
| 367 | s32 i = 0; |
Bruce Allan | 75eb0fa | 2008-11-21 16:53:51 -0800 | [diff] [blame] | 368 | s32 timeout = 50; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 369 | |
| 370 | while (i < timeout) { |
| 371 | if (e1000e_get_hw_semaphore(hw)) |
| 372 | return -E1000_ERR_SWFW_SYNC; |
| 373 | |
| 374 | swfw_sync = er32(SW_FW_SYNC); |
| 375 | if (!(swfw_sync & (fwmask | swmask))) |
| 376 | break; |
| 377 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 378 | /* |
| 379 | * Firmware currently using resource (fwmask) |
| 380 | * or other software thread using resource (swmask) |
| 381 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 382 | e1000e_put_hw_semaphore(hw); |
| 383 | mdelay(5); |
| 384 | i++; |
| 385 | } |
| 386 | |
| 387 | if (i == timeout) { |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 388 | e_dbg("Driver can't access resource, SW_FW_SYNC timeout.\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 389 | return -E1000_ERR_SWFW_SYNC; |
| 390 | } |
| 391 | |
| 392 | swfw_sync |= swmask; |
| 393 | ew32(SW_FW_SYNC, swfw_sync); |
| 394 | |
| 395 | e1000e_put_hw_semaphore(hw); |
| 396 | |
| 397 | return 0; |
| 398 | } |
| 399 | |
| 400 | /** |
| 401 | * e1000_release_swfw_sync_80003es2lan - Release SW/FW semaphore |
| 402 | * @hw: pointer to the HW structure |
| 403 | * @mask: specifies which semaphore to acquire |
| 404 | * |
| 405 | * Release the SW/FW semaphore used to access the PHY or NVM. The mask |
| 406 | * will also specify which port we're releasing the lock for. |
| 407 | **/ |
| 408 | static void e1000_release_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask) |
| 409 | { |
| 410 | u32 swfw_sync; |
| 411 | |
| 412 | while (e1000e_get_hw_semaphore(hw) != 0); |
| 413 | /* Empty */ |
| 414 | |
| 415 | swfw_sync = er32(SW_FW_SYNC); |
| 416 | swfw_sync &= ~mask; |
| 417 | ew32(SW_FW_SYNC, swfw_sync); |
| 418 | |
| 419 | e1000e_put_hw_semaphore(hw); |
| 420 | } |
| 421 | |
| 422 | /** |
| 423 | * e1000_read_phy_reg_gg82563_80003es2lan - Read GG82563 PHY register |
| 424 | * @hw: pointer to the HW structure |
| 425 | * @offset: offset of the register to read |
| 426 | * @data: pointer to the data returned from the operation |
| 427 | * |
Bruce Allan | fe40167 | 2009-11-20 23:26:05 +0000 | [diff] [blame] | 428 | * Read the GG82563 PHY register. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 429 | **/ |
| 430 | static s32 e1000_read_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw, |
| 431 | u32 offset, u16 *data) |
| 432 | { |
| 433 | s32 ret_val; |
| 434 | u32 page_select; |
| 435 | u16 temp; |
| 436 | |
David Graham | 2d9498f | 2008-04-23 11:09:14 -0700 | [diff] [blame] | 437 | ret_val = e1000_acquire_phy_80003es2lan(hw); |
| 438 | if (ret_val) |
| 439 | return ret_val; |
| 440 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 441 | /* Select Configuration Page */ |
David Graham | 2d9498f | 2008-04-23 11:09:14 -0700 | [diff] [blame] | 442 | if ((offset & MAX_PHY_REG_ADDRESS) < GG82563_MIN_ALT_REG) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 443 | page_select = GG82563_PHY_PAGE_SELECT; |
David Graham | 2d9498f | 2008-04-23 11:09:14 -0700 | [diff] [blame] | 444 | } else { |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 445 | /* |
| 446 | * Use Alternative Page Select register to access |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 447 | * registers 30 and 31 |
| 448 | */ |
| 449 | page_select = GG82563_PHY_PAGE_SELECT_ALT; |
David Graham | 2d9498f | 2008-04-23 11:09:14 -0700 | [diff] [blame] | 450 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 451 | |
| 452 | temp = (u16)((u16)offset >> GG82563_PAGE_SHIFT); |
David Graham | 2d9498f | 2008-04-23 11:09:14 -0700 | [diff] [blame] | 453 | ret_val = e1000e_write_phy_reg_mdic(hw, page_select, temp); |
| 454 | if (ret_val) { |
| 455 | e1000_release_phy_80003es2lan(hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 456 | return ret_val; |
David Graham | 2d9498f | 2008-04-23 11:09:14 -0700 | [diff] [blame] | 457 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 458 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 459 | /* |
| 460 | * The "ready" bit in the MDIC register may be incorrectly set |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 461 | * before the device has completed the "Page Select" MDI |
| 462 | * transaction. So we wait 200us after each MDI command... |
| 463 | */ |
| 464 | udelay(200); |
| 465 | |
| 466 | /* ...and verify the command was successful. */ |
David Graham | 2d9498f | 2008-04-23 11:09:14 -0700 | [diff] [blame] | 467 | ret_val = e1000e_read_phy_reg_mdic(hw, page_select, &temp); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 468 | |
| 469 | if (((u16)offset >> GG82563_PAGE_SHIFT) != temp) { |
| 470 | ret_val = -E1000_ERR_PHY; |
David Graham | 2d9498f | 2008-04-23 11:09:14 -0700 | [diff] [blame] | 471 | e1000_release_phy_80003es2lan(hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 472 | return ret_val; |
| 473 | } |
| 474 | |
| 475 | udelay(200); |
| 476 | |
David Graham | 2d9498f | 2008-04-23 11:09:14 -0700 | [diff] [blame] | 477 | ret_val = e1000e_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, |
| 478 | data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 479 | |
| 480 | udelay(200); |
David Graham | 2d9498f | 2008-04-23 11:09:14 -0700 | [diff] [blame] | 481 | e1000_release_phy_80003es2lan(hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 482 | |
| 483 | return ret_val; |
| 484 | } |
| 485 | |
| 486 | /** |
| 487 | * e1000_write_phy_reg_gg82563_80003es2lan - Write GG82563 PHY register |
| 488 | * @hw: pointer to the HW structure |
| 489 | * @offset: offset of the register to read |
| 490 | * @data: value to write to the register |
| 491 | * |
Bruce Allan | fe40167 | 2009-11-20 23:26:05 +0000 | [diff] [blame] | 492 | * Write to the GG82563 PHY register. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 493 | **/ |
| 494 | static s32 e1000_write_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw, |
| 495 | u32 offset, u16 data) |
| 496 | { |
| 497 | s32 ret_val; |
| 498 | u32 page_select; |
| 499 | u16 temp; |
| 500 | |
David Graham | 2d9498f | 2008-04-23 11:09:14 -0700 | [diff] [blame] | 501 | ret_val = e1000_acquire_phy_80003es2lan(hw); |
| 502 | if (ret_val) |
| 503 | return ret_val; |
| 504 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 505 | /* Select Configuration Page */ |
David Graham | 2d9498f | 2008-04-23 11:09:14 -0700 | [diff] [blame] | 506 | if ((offset & MAX_PHY_REG_ADDRESS) < GG82563_MIN_ALT_REG) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 507 | page_select = GG82563_PHY_PAGE_SELECT; |
David Graham | 2d9498f | 2008-04-23 11:09:14 -0700 | [diff] [blame] | 508 | } else { |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 509 | /* |
| 510 | * Use Alternative Page Select register to access |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 511 | * registers 30 and 31 |
| 512 | */ |
| 513 | page_select = GG82563_PHY_PAGE_SELECT_ALT; |
David Graham | 2d9498f | 2008-04-23 11:09:14 -0700 | [diff] [blame] | 514 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 515 | |
| 516 | temp = (u16)((u16)offset >> GG82563_PAGE_SHIFT); |
David Graham | 2d9498f | 2008-04-23 11:09:14 -0700 | [diff] [blame] | 517 | ret_val = e1000e_write_phy_reg_mdic(hw, page_select, temp); |
| 518 | if (ret_val) { |
| 519 | e1000_release_phy_80003es2lan(hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 520 | return ret_val; |
David Graham | 2d9498f | 2008-04-23 11:09:14 -0700 | [diff] [blame] | 521 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 522 | |
| 523 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 524 | /* |
| 525 | * The "ready" bit in the MDIC register may be incorrectly set |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 526 | * before the device has completed the "Page Select" MDI |
| 527 | * transaction. So we wait 200us after each MDI command... |
| 528 | */ |
| 529 | udelay(200); |
| 530 | |
| 531 | /* ...and verify the command was successful. */ |
David Graham | 2d9498f | 2008-04-23 11:09:14 -0700 | [diff] [blame] | 532 | ret_val = e1000e_read_phy_reg_mdic(hw, page_select, &temp); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 533 | |
David Graham | 2d9498f | 2008-04-23 11:09:14 -0700 | [diff] [blame] | 534 | if (((u16)offset >> GG82563_PAGE_SHIFT) != temp) { |
| 535 | e1000_release_phy_80003es2lan(hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 536 | return -E1000_ERR_PHY; |
David Graham | 2d9498f | 2008-04-23 11:09:14 -0700 | [diff] [blame] | 537 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 538 | |
| 539 | udelay(200); |
| 540 | |
David Graham | 2d9498f | 2008-04-23 11:09:14 -0700 | [diff] [blame] | 541 | ret_val = e1000e_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, |
| 542 | data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 543 | |
| 544 | udelay(200); |
David Graham | 2d9498f | 2008-04-23 11:09:14 -0700 | [diff] [blame] | 545 | e1000_release_phy_80003es2lan(hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 546 | |
| 547 | return ret_val; |
| 548 | } |
| 549 | |
| 550 | /** |
| 551 | * e1000_write_nvm_80003es2lan - Write to ESB2 NVM |
| 552 | * @hw: pointer to the HW structure |
| 553 | * @offset: offset of the register to read |
| 554 | * @words: number of words to write |
| 555 | * @data: buffer of data to write to the NVM |
| 556 | * |
Bruce Allan | fe40167 | 2009-11-20 23:26:05 +0000 | [diff] [blame] | 557 | * Write "words" of data to the ESB2 NVM. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 558 | **/ |
| 559 | static s32 e1000_write_nvm_80003es2lan(struct e1000_hw *hw, u16 offset, |
| 560 | u16 words, u16 *data) |
| 561 | { |
| 562 | return e1000e_write_nvm_spi(hw, offset, words, data); |
| 563 | } |
| 564 | |
| 565 | /** |
| 566 | * e1000_get_cfg_done_80003es2lan - Wait for configuration to complete |
| 567 | * @hw: pointer to the HW structure |
| 568 | * |
| 569 | * Wait a specific amount of time for manageability processes to complete. |
| 570 | * This is a function pointer entry point called by the phy module. |
| 571 | **/ |
| 572 | static s32 e1000_get_cfg_done_80003es2lan(struct e1000_hw *hw) |
| 573 | { |
| 574 | s32 timeout = PHY_CFG_TIMEOUT; |
| 575 | u32 mask = E1000_NVM_CFG_DONE_PORT_0; |
| 576 | |
| 577 | if (hw->bus.func == 1) |
| 578 | mask = E1000_NVM_CFG_DONE_PORT_1; |
| 579 | |
| 580 | while (timeout) { |
| 581 | if (er32(EEMNGCTL) & mask) |
| 582 | break; |
| 583 | msleep(1); |
| 584 | timeout--; |
| 585 | } |
| 586 | if (!timeout) { |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 587 | e_dbg("MNG configuration cycle has not completed.\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 588 | return -E1000_ERR_RESET; |
| 589 | } |
| 590 | |
| 591 | return 0; |
| 592 | } |
| 593 | |
| 594 | /** |
| 595 | * e1000_phy_force_speed_duplex_80003es2lan - Force PHY speed and duplex |
| 596 | * @hw: pointer to the HW structure |
| 597 | * |
| 598 | * Force the speed and duplex settings onto the PHY. This is a |
| 599 | * function pointer entry point called by the phy module. |
| 600 | **/ |
| 601 | static s32 e1000_phy_force_speed_duplex_80003es2lan(struct e1000_hw *hw) |
| 602 | { |
| 603 | s32 ret_val; |
| 604 | u16 phy_data; |
| 605 | bool link; |
| 606 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 607 | /* |
| 608 | * Clear Auto-Crossover to force MDI manually. M88E1000 requires MDI |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 609 | * forced whenever speed and duplex are forced. |
| 610 | */ |
| 611 | ret_val = e1e_rphy(hw, M88E1000_PHY_SPEC_CTRL, &phy_data); |
| 612 | if (ret_val) |
| 613 | return ret_val; |
| 614 | |
| 615 | phy_data &= ~GG82563_PSCR_CROSSOVER_MODE_AUTO; |
| 616 | ret_val = e1e_wphy(hw, GG82563_PHY_SPEC_CTRL, phy_data); |
| 617 | if (ret_val) |
| 618 | return ret_val; |
| 619 | |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 620 | e_dbg("GG82563 PSCR: %X\n", phy_data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 621 | |
| 622 | ret_val = e1e_rphy(hw, PHY_CONTROL, &phy_data); |
| 623 | if (ret_val) |
| 624 | return ret_val; |
| 625 | |
| 626 | e1000e_phy_force_speed_duplex_setup(hw, &phy_data); |
| 627 | |
| 628 | /* Reset the phy to commit changes. */ |
| 629 | phy_data |= MII_CR_RESET; |
| 630 | |
| 631 | ret_val = e1e_wphy(hw, PHY_CONTROL, phy_data); |
| 632 | if (ret_val) |
| 633 | return ret_val; |
| 634 | |
| 635 | udelay(1); |
| 636 | |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 637 | if (hw->phy.autoneg_wait_to_complete) { |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 638 | e_dbg("Waiting for forced speed/duplex link " |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 639 | "on GG82563 phy.\n"); |
| 640 | |
| 641 | ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT, |
| 642 | 100000, &link); |
| 643 | if (ret_val) |
| 644 | return ret_val; |
| 645 | |
| 646 | if (!link) { |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 647 | /* |
| 648 | * We didn't get link. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 649 | * Reset the DSP and cross our fingers. |
| 650 | */ |
| 651 | ret_val = e1000e_phy_reset_dsp(hw); |
| 652 | if (ret_val) |
| 653 | return ret_val; |
| 654 | } |
| 655 | |
| 656 | /* Try once more */ |
| 657 | ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT, |
| 658 | 100000, &link); |
| 659 | if (ret_val) |
| 660 | return ret_val; |
| 661 | } |
| 662 | |
| 663 | ret_val = e1e_rphy(hw, GG82563_PHY_MAC_SPEC_CTRL, &phy_data); |
| 664 | if (ret_val) |
| 665 | return ret_val; |
| 666 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 667 | /* |
| 668 | * Resetting the phy means we need to verify the TX_CLK corresponds |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 669 | * to the link speed. 10Mbps -> 2.5MHz, else 25MHz. |
| 670 | */ |
| 671 | phy_data &= ~GG82563_MSCR_TX_CLK_MASK; |
| 672 | if (hw->mac.forced_speed_duplex & E1000_ALL_10_SPEED) |
| 673 | phy_data |= GG82563_MSCR_TX_CLK_10MBPS_2_5; |
| 674 | else |
| 675 | phy_data |= GG82563_MSCR_TX_CLK_100MBPS_25; |
| 676 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 677 | /* |
| 678 | * In addition, we must re-enable CRS on Tx for both half and full |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 679 | * duplex. |
| 680 | */ |
| 681 | phy_data |= GG82563_MSCR_ASSERT_CRS_ON_TX; |
| 682 | ret_val = e1e_wphy(hw, GG82563_PHY_MAC_SPEC_CTRL, phy_data); |
| 683 | |
| 684 | return ret_val; |
| 685 | } |
| 686 | |
| 687 | /** |
| 688 | * e1000_get_cable_length_80003es2lan - Set approximate cable length |
| 689 | * @hw: pointer to the HW structure |
| 690 | * |
| 691 | * Find the approximate cable length as measured by the GG82563 PHY. |
| 692 | * This is a function pointer entry point called by the phy module. |
| 693 | **/ |
| 694 | static s32 e1000_get_cable_length_80003es2lan(struct e1000_hw *hw) |
| 695 | { |
| 696 | struct e1000_phy_info *phy = &hw->phy; |
| 697 | s32 ret_val; |
| 698 | u16 phy_data; |
| 699 | u16 index; |
| 700 | |
| 701 | ret_val = e1e_rphy(hw, GG82563_PHY_DSP_DISTANCE, &phy_data); |
| 702 | if (ret_val) |
| 703 | return ret_val; |
| 704 | |
| 705 | index = phy_data & GG82563_DSPD_CABLE_LENGTH; |
| 706 | phy->min_cable_length = e1000_gg82563_cable_length_table[index]; |
| 707 | phy->max_cable_length = e1000_gg82563_cable_length_table[index+5]; |
| 708 | |
| 709 | phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2; |
| 710 | |
| 711 | return 0; |
| 712 | } |
| 713 | |
| 714 | /** |
| 715 | * e1000_get_link_up_info_80003es2lan - Report speed and duplex |
| 716 | * @hw: pointer to the HW structure |
| 717 | * @speed: pointer to speed buffer |
| 718 | * @duplex: pointer to duplex buffer |
| 719 | * |
| 720 | * Retrieve the current speed and duplex configuration. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 721 | **/ |
| 722 | static s32 e1000_get_link_up_info_80003es2lan(struct e1000_hw *hw, u16 *speed, |
| 723 | u16 *duplex) |
| 724 | { |
| 725 | s32 ret_val; |
| 726 | |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 727 | if (hw->phy.media_type == e1000_media_type_copper) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 728 | ret_val = e1000e_get_speed_and_duplex_copper(hw, |
| 729 | speed, |
| 730 | duplex); |
Bruce Allan | 75eb0fa | 2008-11-21 16:53:51 -0800 | [diff] [blame] | 731 | hw->phy.ops.cfg_on_link_up(hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 732 | } else { |
| 733 | ret_val = e1000e_get_speed_and_duplex_fiber_serdes(hw, |
| 734 | speed, |
| 735 | duplex); |
| 736 | } |
| 737 | |
| 738 | return ret_val; |
| 739 | } |
| 740 | |
| 741 | /** |
| 742 | * e1000_reset_hw_80003es2lan - Reset the ESB2 controller |
| 743 | * @hw: pointer to the HW structure |
| 744 | * |
| 745 | * Perform a global reset to the ESB2 controller. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 746 | **/ |
| 747 | static s32 e1000_reset_hw_80003es2lan(struct e1000_hw *hw) |
| 748 | { |
| 749 | u32 ctrl; |
| 750 | u32 icr; |
| 751 | s32 ret_val; |
| 752 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 753 | /* |
| 754 | * Prevent the PCI-E bus from sticking if there is no TLP connection |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 755 | * on the last TLP read/write transaction when MAC is reset. |
| 756 | */ |
| 757 | ret_val = e1000e_disable_pcie_master(hw); |
| 758 | if (ret_val) |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 759 | e_dbg("PCI-E Master disable polling has failed.\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 760 | |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 761 | e_dbg("Masking off all interrupts\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 762 | ew32(IMC, 0xffffffff); |
| 763 | |
| 764 | ew32(RCTL, 0); |
| 765 | ew32(TCTL, E1000_TCTL_PSP); |
| 766 | e1e_flush(); |
| 767 | |
| 768 | msleep(10); |
| 769 | |
| 770 | ctrl = er32(CTRL); |
| 771 | |
Bruce Allan | 75eb0fa | 2008-11-21 16:53:51 -0800 | [diff] [blame] | 772 | ret_val = e1000_acquire_phy_80003es2lan(hw); |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 773 | e_dbg("Issuing a global reset to MAC\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 774 | ew32(CTRL, ctrl | E1000_CTRL_RST); |
Bruce Allan | 75eb0fa | 2008-11-21 16:53:51 -0800 | [diff] [blame] | 775 | e1000_release_phy_80003es2lan(hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 776 | |
| 777 | ret_val = e1000e_get_auto_rd_done(hw); |
| 778 | if (ret_val) |
| 779 | /* We don't want to continue accessing MAC registers. */ |
| 780 | return ret_val; |
| 781 | |
| 782 | /* Clear any pending interrupt events. */ |
| 783 | ew32(IMC, 0xffffffff); |
| 784 | icr = er32(ICR); |
| 785 | |
| 786 | return 0; |
| 787 | } |
| 788 | |
| 789 | /** |
| 790 | * e1000_init_hw_80003es2lan - Initialize the ESB2 controller |
| 791 | * @hw: pointer to the HW structure |
| 792 | * |
| 793 | * Initialize the hw bits, LED, VFTA, MTA, link and hw counters. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 794 | **/ |
| 795 | static s32 e1000_init_hw_80003es2lan(struct e1000_hw *hw) |
| 796 | { |
| 797 | struct e1000_mac_info *mac = &hw->mac; |
| 798 | u32 reg_data; |
| 799 | s32 ret_val; |
| 800 | u16 i; |
| 801 | |
| 802 | e1000_initialize_hw_bits_80003es2lan(hw); |
| 803 | |
| 804 | /* Initialize identification LED */ |
| 805 | ret_val = e1000e_id_led_init(hw); |
Bruce Allan | de39b75 | 2009-11-20 23:27:59 +0000 | [diff] [blame^] | 806 | if (ret_val) |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 807 | e_dbg("Error initializing identification LED\n"); |
Bruce Allan | de39b75 | 2009-11-20 23:27:59 +0000 | [diff] [blame^] | 808 | /* This is not fatal and we should not stop init due to this */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 809 | |
| 810 | /* Disabling VLAN filtering */ |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 811 | e_dbg("Initializing the IEEE VLAN\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 812 | e1000e_clear_vfta(hw); |
| 813 | |
| 814 | /* Setup the receive address. */ |
| 815 | e1000e_init_rx_addrs(hw, mac->rar_entry_count); |
| 816 | |
| 817 | /* Zero out the Multicast HASH table */ |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 818 | e_dbg("Zeroing the MTA\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 819 | for (i = 0; i < mac->mta_reg_count; i++) |
| 820 | E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0); |
| 821 | |
| 822 | /* Setup link and flow control */ |
| 823 | ret_val = e1000e_setup_link(hw); |
| 824 | |
| 825 | /* Set the transmit descriptor write-back policy */ |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 826 | reg_data = er32(TXDCTL(0)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 827 | reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) | |
| 828 | E1000_TXDCTL_FULL_TX_DESC_WB | E1000_TXDCTL_COUNT_DESC; |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 829 | ew32(TXDCTL(0), reg_data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 830 | |
| 831 | /* ...for both queues. */ |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 832 | reg_data = er32(TXDCTL(1)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 833 | reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) | |
| 834 | E1000_TXDCTL_FULL_TX_DESC_WB | E1000_TXDCTL_COUNT_DESC; |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 835 | ew32(TXDCTL(1), reg_data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 836 | |
| 837 | /* Enable retransmit on late collisions */ |
| 838 | reg_data = er32(TCTL); |
| 839 | reg_data |= E1000_TCTL_RTLC; |
| 840 | ew32(TCTL, reg_data); |
| 841 | |
| 842 | /* Configure Gigabit Carry Extend Padding */ |
| 843 | reg_data = er32(TCTL_EXT); |
| 844 | reg_data &= ~E1000_TCTL_EXT_GCEX_MASK; |
| 845 | reg_data |= DEFAULT_TCTL_EXT_GCEX_80003ES2LAN; |
| 846 | ew32(TCTL_EXT, reg_data); |
| 847 | |
| 848 | /* Configure Transmit Inter-Packet Gap */ |
| 849 | reg_data = er32(TIPG); |
| 850 | reg_data &= ~E1000_TIPG_IPGT_MASK; |
| 851 | reg_data |= DEFAULT_TIPG_IPGT_1000_80003ES2LAN; |
| 852 | ew32(TIPG, reg_data); |
| 853 | |
| 854 | reg_data = E1000_READ_REG_ARRAY(hw, E1000_FFLT, 0x0001); |
| 855 | reg_data &= ~0x00100000; |
| 856 | E1000_WRITE_REG_ARRAY(hw, E1000_FFLT, 0x0001, reg_data); |
| 857 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 858 | /* |
| 859 | * Clear all of the statistics registers (clear on read). It is |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 860 | * important that we do this after we have tried to establish link |
| 861 | * because the symbol error count will increment wildly if there |
| 862 | * is no link. |
| 863 | */ |
| 864 | e1000_clear_hw_cntrs_80003es2lan(hw); |
| 865 | |
| 866 | return ret_val; |
| 867 | } |
| 868 | |
| 869 | /** |
| 870 | * e1000_initialize_hw_bits_80003es2lan - Init hw bits of ESB2 |
| 871 | * @hw: pointer to the HW structure |
| 872 | * |
| 873 | * Initializes required hardware-dependent bits needed for normal operation. |
| 874 | **/ |
| 875 | static void e1000_initialize_hw_bits_80003es2lan(struct e1000_hw *hw) |
| 876 | { |
| 877 | u32 reg; |
| 878 | |
| 879 | /* Transmit Descriptor Control 0 */ |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 880 | reg = er32(TXDCTL(0)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 881 | reg |= (1 << 22); |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 882 | ew32(TXDCTL(0), reg); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 883 | |
| 884 | /* Transmit Descriptor Control 1 */ |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 885 | reg = er32(TXDCTL(1)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 886 | reg |= (1 << 22); |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 887 | ew32(TXDCTL(1), reg); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 888 | |
| 889 | /* Transmit Arbitration Control 0 */ |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 890 | reg = er32(TARC(0)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 891 | reg &= ~(0xF << 27); /* 30:27 */ |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 892 | if (hw->phy.media_type != e1000_media_type_copper) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 893 | reg &= ~(1 << 20); |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 894 | ew32(TARC(0), reg); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 895 | |
| 896 | /* Transmit Arbitration Control 1 */ |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 897 | reg = er32(TARC(1)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 898 | if (er32(TCTL) & E1000_TCTL_MULR) |
| 899 | reg &= ~(1 << 28); |
| 900 | else |
| 901 | reg |= (1 << 28); |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 902 | ew32(TARC(1), reg); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 903 | } |
| 904 | |
| 905 | /** |
| 906 | * e1000_copper_link_setup_gg82563_80003es2lan - Configure GG82563 Link |
| 907 | * @hw: pointer to the HW structure |
| 908 | * |
| 909 | * Setup some GG82563 PHY registers for obtaining link |
| 910 | **/ |
| 911 | static s32 e1000_copper_link_setup_gg82563_80003es2lan(struct e1000_hw *hw) |
| 912 | { |
| 913 | struct e1000_phy_info *phy = &hw->phy; |
| 914 | s32 ret_val; |
| 915 | u32 ctrl_ext; |
Bruce Allan | 75eb0fa | 2008-11-21 16:53:51 -0800 | [diff] [blame] | 916 | u16 data; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 917 | |
David Graham | 2d9498f | 2008-04-23 11:09:14 -0700 | [diff] [blame] | 918 | ret_val = e1e_rphy(hw, GG82563_PHY_MAC_SPEC_CTRL, &data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 919 | if (ret_val) |
| 920 | return ret_val; |
| 921 | |
| 922 | data |= GG82563_MSCR_ASSERT_CRS_ON_TX; |
| 923 | /* Use 25MHz for both link down and 1000Base-T for Tx clock. */ |
| 924 | data |= GG82563_MSCR_TX_CLK_1000MBPS_25; |
| 925 | |
David Graham | 2d9498f | 2008-04-23 11:09:14 -0700 | [diff] [blame] | 926 | ret_val = e1e_wphy(hw, GG82563_PHY_MAC_SPEC_CTRL, data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 927 | if (ret_val) |
| 928 | return ret_val; |
| 929 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 930 | /* |
| 931 | * Options: |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 932 | * MDI/MDI-X = 0 (default) |
| 933 | * 0 - Auto for all speeds |
| 934 | * 1 - MDI mode |
| 935 | * 2 - MDI-X mode |
| 936 | * 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes) |
| 937 | */ |
| 938 | ret_val = e1e_rphy(hw, GG82563_PHY_SPEC_CTRL, &data); |
| 939 | if (ret_val) |
| 940 | return ret_val; |
| 941 | |
| 942 | data &= ~GG82563_PSCR_CROSSOVER_MODE_MASK; |
| 943 | |
| 944 | switch (phy->mdix) { |
| 945 | case 1: |
| 946 | data |= GG82563_PSCR_CROSSOVER_MODE_MDI; |
| 947 | break; |
| 948 | case 2: |
| 949 | data |= GG82563_PSCR_CROSSOVER_MODE_MDIX; |
| 950 | break; |
| 951 | case 0: |
| 952 | default: |
| 953 | data |= GG82563_PSCR_CROSSOVER_MODE_AUTO; |
| 954 | break; |
| 955 | } |
| 956 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 957 | /* |
| 958 | * Options: |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 959 | * disable_polarity_correction = 0 (default) |
| 960 | * Automatic Correction for Reversed Cable Polarity |
| 961 | * 0 - Disabled |
| 962 | * 1 - Enabled |
| 963 | */ |
| 964 | data &= ~GG82563_PSCR_POLARITY_REVERSAL_DISABLE; |
| 965 | if (phy->disable_polarity_correction) |
| 966 | data |= GG82563_PSCR_POLARITY_REVERSAL_DISABLE; |
| 967 | |
| 968 | ret_val = e1e_wphy(hw, GG82563_PHY_SPEC_CTRL, data); |
| 969 | if (ret_val) |
| 970 | return ret_val; |
| 971 | |
| 972 | /* SW Reset the PHY so all changes take effect */ |
| 973 | ret_val = e1000e_commit_phy(hw); |
| 974 | if (ret_val) { |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 975 | e_dbg("Error Resetting the PHY\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 976 | return ret_val; |
| 977 | } |
| 978 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 979 | /* Bypass Rx and Tx FIFO's */ |
Bruce Allan | 75eb0fa | 2008-11-21 16:53:51 -0800 | [diff] [blame] | 980 | ret_val = e1000_write_kmrn_reg_80003es2lan(hw, |
| 981 | E1000_KMRNCTRLSTA_OFFSET_FIFO_CTRL, |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 982 | E1000_KMRNCTRLSTA_FIFO_CTRL_RX_BYPASS | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 983 | E1000_KMRNCTRLSTA_FIFO_CTRL_TX_BYPASS); |
| 984 | if (ret_val) |
| 985 | return ret_val; |
| 986 | |
Bruce Allan | 75eb0fa | 2008-11-21 16:53:51 -0800 | [diff] [blame] | 987 | ret_val = e1000_read_kmrn_reg_80003es2lan(hw, |
David Graham | 2d9498f | 2008-04-23 11:09:14 -0700 | [diff] [blame] | 988 | E1000_KMRNCTRLSTA_OFFSET_MAC2PHY_OPMODE, |
| 989 | &data); |
| 990 | if (ret_val) |
| 991 | return ret_val; |
| 992 | data |= E1000_KMRNCTRLSTA_OPMODE_E_IDLE; |
Bruce Allan | 75eb0fa | 2008-11-21 16:53:51 -0800 | [diff] [blame] | 993 | ret_val = e1000_write_kmrn_reg_80003es2lan(hw, |
David Graham | 2d9498f | 2008-04-23 11:09:14 -0700 | [diff] [blame] | 994 | E1000_KMRNCTRLSTA_OFFSET_MAC2PHY_OPMODE, |
| 995 | data); |
| 996 | if (ret_val) |
| 997 | return ret_val; |
| 998 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 999 | ret_val = e1e_rphy(hw, GG82563_PHY_SPEC_CTRL_2, &data); |
| 1000 | if (ret_val) |
| 1001 | return ret_val; |
| 1002 | |
| 1003 | data &= ~GG82563_PSCR2_REVERSE_AUTO_NEG; |
| 1004 | ret_val = e1e_wphy(hw, GG82563_PHY_SPEC_CTRL_2, data); |
| 1005 | if (ret_val) |
| 1006 | return ret_val; |
| 1007 | |
| 1008 | ctrl_ext = er32(CTRL_EXT); |
| 1009 | ctrl_ext &= ~(E1000_CTRL_EXT_LINK_MODE_MASK); |
| 1010 | ew32(CTRL_EXT, ctrl_ext); |
| 1011 | |
| 1012 | ret_val = e1e_rphy(hw, GG82563_PHY_PWR_MGMT_CTRL, &data); |
| 1013 | if (ret_val) |
| 1014 | return ret_val; |
| 1015 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1016 | /* |
| 1017 | * Do not init these registers when the HW is in IAMT mode, since the |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1018 | * firmware will have already initialized them. We only initialize |
| 1019 | * them if the HW is not in IAMT mode. |
| 1020 | */ |
| 1021 | if (!e1000e_check_mng_mode(hw)) { |
| 1022 | /* Enable Electrical Idle on the PHY */ |
| 1023 | data |= GG82563_PMCR_ENABLE_ELECTRICAL_IDLE; |
| 1024 | ret_val = e1e_wphy(hw, GG82563_PHY_PWR_MGMT_CTRL, data); |
| 1025 | if (ret_val) |
| 1026 | return ret_val; |
| 1027 | |
Bruce Allan | 75eb0fa | 2008-11-21 16:53:51 -0800 | [diff] [blame] | 1028 | ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &data); |
| 1029 | if (ret_val) |
| 1030 | return ret_val; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1031 | |
| 1032 | data &= ~GG82563_KMCR_PASS_FALSE_CARRIER; |
| 1033 | ret_val = e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, data); |
| 1034 | if (ret_val) |
| 1035 | return ret_val; |
| 1036 | } |
| 1037 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1038 | /* |
| 1039 | * Workaround: Disable padding in Kumeran interface in the MAC |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1040 | * and in the PHY to avoid CRC errors. |
| 1041 | */ |
| 1042 | ret_val = e1e_rphy(hw, GG82563_PHY_INBAND_CTRL, &data); |
| 1043 | if (ret_val) |
| 1044 | return ret_val; |
| 1045 | |
| 1046 | data |= GG82563_ICR_DIS_PADDING; |
| 1047 | ret_val = e1e_wphy(hw, GG82563_PHY_INBAND_CTRL, data); |
| 1048 | if (ret_val) |
| 1049 | return ret_val; |
| 1050 | |
| 1051 | return 0; |
| 1052 | } |
| 1053 | |
| 1054 | /** |
| 1055 | * e1000_setup_copper_link_80003es2lan - Setup Copper Link for ESB2 |
| 1056 | * @hw: pointer to the HW structure |
| 1057 | * |
| 1058 | * Essentially a wrapper for setting up all things "copper" related. |
| 1059 | * This is a function pointer entry point called by the mac module. |
| 1060 | **/ |
| 1061 | static s32 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw) |
| 1062 | { |
| 1063 | u32 ctrl; |
| 1064 | s32 ret_val; |
| 1065 | u16 reg_data; |
| 1066 | |
| 1067 | ctrl = er32(CTRL); |
| 1068 | ctrl |= E1000_CTRL_SLU; |
| 1069 | ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX); |
| 1070 | ew32(CTRL, ctrl); |
| 1071 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1072 | /* |
| 1073 | * Set the mac to wait the maximum time between each |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1074 | * iteration and increase the max iterations when |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1075 | * polling the phy; this fixes erroneous timeouts at 10Mbps. |
| 1076 | */ |
Bruce Allan | 75eb0fa | 2008-11-21 16:53:51 -0800 | [diff] [blame] | 1077 | ret_val = e1000_write_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 4), |
| 1078 | 0xFFFF); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1079 | if (ret_val) |
| 1080 | return ret_val; |
Bruce Allan | 75eb0fa | 2008-11-21 16:53:51 -0800 | [diff] [blame] | 1081 | ret_val = e1000_read_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 9), |
| 1082 | ®_data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1083 | if (ret_val) |
| 1084 | return ret_val; |
| 1085 | reg_data |= 0x3F; |
Bruce Allan | 75eb0fa | 2008-11-21 16:53:51 -0800 | [diff] [blame] | 1086 | ret_val = e1000_write_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 9), |
| 1087 | reg_data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1088 | if (ret_val) |
| 1089 | return ret_val; |
Bruce Allan | 75eb0fa | 2008-11-21 16:53:51 -0800 | [diff] [blame] | 1090 | ret_val = e1000_read_kmrn_reg_80003es2lan(hw, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1091 | E1000_KMRNCTRLSTA_OFFSET_INB_CTRL, |
| 1092 | ®_data); |
| 1093 | if (ret_val) |
| 1094 | return ret_val; |
| 1095 | reg_data |= E1000_KMRNCTRLSTA_INB_CTRL_DIS_PADDING; |
Bruce Allan | 75eb0fa | 2008-11-21 16:53:51 -0800 | [diff] [blame] | 1096 | ret_val = e1000_write_kmrn_reg_80003es2lan(hw, |
| 1097 | E1000_KMRNCTRLSTA_OFFSET_INB_CTRL, |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1098 | reg_data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1099 | if (ret_val) |
| 1100 | return ret_val; |
| 1101 | |
| 1102 | ret_val = e1000_copper_link_setup_gg82563_80003es2lan(hw); |
| 1103 | if (ret_val) |
| 1104 | return ret_val; |
| 1105 | |
| 1106 | ret_val = e1000e_setup_copper_link(hw); |
| 1107 | |
| 1108 | return 0; |
| 1109 | } |
| 1110 | |
| 1111 | /** |
Bruce Allan | 75eb0fa | 2008-11-21 16:53:51 -0800 | [diff] [blame] | 1112 | * e1000_cfg_on_link_up_80003es2lan - es2 link configuration after link-up |
| 1113 | * @hw: pointer to the HW structure |
| 1114 | * @duplex: current duplex setting |
| 1115 | * |
| 1116 | * Configure the KMRN interface by applying last minute quirks for |
| 1117 | * 10/100 operation. |
| 1118 | **/ |
| 1119 | static s32 e1000_cfg_on_link_up_80003es2lan(struct e1000_hw *hw) |
| 1120 | { |
| 1121 | s32 ret_val = 0; |
| 1122 | u16 speed; |
| 1123 | u16 duplex; |
| 1124 | |
| 1125 | if (hw->phy.media_type == e1000_media_type_copper) { |
| 1126 | ret_val = e1000e_get_speed_and_duplex_copper(hw, &speed, |
| 1127 | &duplex); |
| 1128 | if (ret_val) |
| 1129 | return ret_val; |
| 1130 | |
| 1131 | if (speed == SPEED_1000) |
| 1132 | ret_val = e1000_cfg_kmrn_1000_80003es2lan(hw); |
| 1133 | else |
| 1134 | ret_val = e1000_cfg_kmrn_10_100_80003es2lan(hw, duplex); |
| 1135 | } |
| 1136 | |
| 1137 | return ret_val; |
| 1138 | } |
| 1139 | |
| 1140 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1141 | * e1000_cfg_kmrn_10_100_80003es2lan - Apply "quirks" for 10/100 operation |
| 1142 | * @hw: pointer to the HW structure |
| 1143 | * @duplex: current duplex setting |
| 1144 | * |
| 1145 | * Configure the KMRN interface by applying last minute quirks for |
| 1146 | * 10/100 operation. |
| 1147 | **/ |
| 1148 | static s32 e1000_cfg_kmrn_10_100_80003es2lan(struct e1000_hw *hw, u16 duplex) |
| 1149 | { |
| 1150 | s32 ret_val; |
| 1151 | u32 tipg; |
David Graham | 2d9498f | 2008-04-23 11:09:14 -0700 | [diff] [blame] | 1152 | u32 i = 0; |
| 1153 | u16 reg_data, reg_data2; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1154 | |
| 1155 | reg_data = E1000_KMRNCTRLSTA_HD_CTRL_10_100_DEFAULT; |
Bruce Allan | 75eb0fa | 2008-11-21 16:53:51 -0800 | [diff] [blame] | 1156 | ret_val = e1000_write_kmrn_reg_80003es2lan(hw, |
| 1157 | E1000_KMRNCTRLSTA_OFFSET_HD_CTRL, |
| 1158 | reg_data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1159 | if (ret_val) |
| 1160 | return ret_val; |
| 1161 | |
| 1162 | /* Configure Transmit Inter-Packet Gap */ |
| 1163 | tipg = er32(TIPG); |
| 1164 | tipg &= ~E1000_TIPG_IPGT_MASK; |
| 1165 | tipg |= DEFAULT_TIPG_IPGT_10_100_80003ES2LAN; |
| 1166 | ew32(TIPG, tipg); |
| 1167 | |
David Graham | 2d9498f | 2008-04-23 11:09:14 -0700 | [diff] [blame] | 1168 | do { |
| 1169 | ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, ®_data); |
| 1170 | if (ret_val) |
| 1171 | return ret_val; |
| 1172 | |
| 1173 | ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, ®_data2); |
| 1174 | if (ret_val) |
| 1175 | return ret_val; |
| 1176 | i++; |
| 1177 | } while ((reg_data != reg_data2) && (i < GG82563_MAX_KMRN_RETRY)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1178 | |
| 1179 | if (duplex == HALF_DUPLEX) |
| 1180 | reg_data |= GG82563_KMCR_PASS_FALSE_CARRIER; |
| 1181 | else |
| 1182 | reg_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER; |
| 1183 | |
| 1184 | ret_val = e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data); |
| 1185 | |
| 1186 | return 0; |
| 1187 | } |
| 1188 | |
| 1189 | /** |
| 1190 | * e1000_cfg_kmrn_1000_80003es2lan - Apply "quirks" for gigabit operation |
| 1191 | * @hw: pointer to the HW structure |
| 1192 | * |
| 1193 | * Configure the KMRN interface by applying last minute quirks for |
| 1194 | * gigabit operation. |
| 1195 | **/ |
| 1196 | static s32 e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw) |
| 1197 | { |
| 1198 | s32 ret_val; |
David Graham | 2d9498f | 2008-04-23 11:09:14 -0700 | [diff] [blame] | 1199 | u16 reg_data, reg_data2; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1200 | u32 tipg; |
David Graham | 2d9498f | 2008-04-23 11:09:14 -0700 | [diff] [blame] | 1201 | u32 i = 0; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1202 | |
| 1203 | reg_data = E1000_KMRNCTRLSTA_HD_CTRL_1000_DEFAULT; |
Bruce Allan | 75eb0fa | 2008-11-21 16:53:51 -0800 | [diff] [blame] | 1204 | ret_val = e1000_write_kmrn_reg_80003es2lan(hw, |
| 1205 | E1000_KMRNCTRLSTA_OFFSET_HD_CTRL, |
| 1206 | reg_data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1207 | if (ret_val) |
| 1208 | return ret_val; |
| 1209 | |
| 1210 | /* Configure Transmit Inter-Packet Gap */ |
| 1211 | tipg = er32(TIPG); |
| 1212 | tipg &= ~E1000_TIPG_IPGT_MASK; |
| 1213 | tipg |= DEFAULT_TIPG_IPGT_1000_80003ES2LAN; |
| 1214 | ew32(TIPG, tipg); |
| 1215 | |
David Graham | 2d9498f | 2008-04-23 11:09:14 -0700 | [diff] [blame] | 1216 | do { |
| 1217 | ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, ®_data); |
| 1218 | if (ret_val) |
| 1219 | return ret_val; |
| 1220 | |
| 1221 | ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, ®_data2); |
| 1222 | if (ret_val) |
| 1223 | return ret_val; |
| 1224 | i++; |
| 1225 | } while ((reg_data != reg_data2) && (i < GG82563_MAX_KMRN_RETRY)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1226 | |
| 1227 | reg_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER; |
| 1228 | ret_val = e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data); |
| 1229 | |
| 1230 | return ret_val; |
| 1231 | } |
| 1232 | |
| 1233 | /** |
Bruce Allan | 75eb0fa | 2008-11-21 16:53:51 -0800 | [diff] [blame] | 1234 | * e1000_read_kmrn_reg_80003es2lan - Read kumeran register |
| 1235 | * @hw: pointer to the HW structure |
| 1236 | * @offset: register offset to be read |
| 1237 | * @data: pointer to the read data |
| 1238 | * |
| 1239 | * Acquire semaphore, then read the PHY register at offset |
| 1240 | * using the kumeran interface. The information retrieved is stored in data. |
| 1241 | * Release the semaphore before exiting. |
| 1242 | **/ |
Hannes Eder | fa4c16d | 2008-12-22 09:16:13 +0000 | [diff] [blame] | 1243 | static s32 e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset, |
| 1244 | u16 *data) |
Bruce Allan | 75eb0fa | 2008-11-21 16:53:51 -0800 | [diff] [blame] | 1245 | { |
| 1246 | u32 kmrnctrlsta; |
| 1247 | s32 ret_val = 0; |
| 1248 | |
| 1249 | ret_val = e1000_acquire_mac_csr_80003es2lan(hw); |
| 1250 | if (ret_val) |
| 1251 | return ret_val; |
| 1252 | |
| 1253 | kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) & |
| 1254 | E1000_KMRNCTRLSTA_OFFSET) | E1000_KMRNCTRLSTA_REN; |
| 1255 | ew32(KMRNCTRLSTA, kmrnctrlsta); |
| 1256 | |
| 1257 | udelay(2); |
| 1258 | |
| 1259 | kmrnctrlsta = er32(KMRNCTRLSTA); |
| 1260 | *data = (u16)kmrnctrlsta; |
| 1261 | |
| 1262 | e1000_release_mac_csr_80003es2lan(hw); |
| 1263 | |
| 1264 | return ret_val; |
| 1265 | } |
| 1266 | |
| 1267 | /** |
| 1268 | * e1000_write_kmrn_reg_80003es2lan - Write kumeran register |
| 1269 | * @hw: pointer to the HW structure |
| 1270 | * @offset: register offset to write to |
| 1271 | * @data: data to write at register offset |
| 1272 | * |
| 1273 | * Acquire semaphore, then write the data to PHY register |
| 1274 | * at the offset using the kumeran interface. Release semaphore |
| 1275 | * before exiting. |
| 1276 | **/ |
Hannes Eder | fa4c16d | 2008-12-22 09:16:13 +0000 | [diff] [blame] | 1277 | static s32 e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset, |
| 1278 | u16 data) |
Bruce Allan | 75eb0fa | 2008-11-21 16:53:51 -0800 | [diff] [blame] | 1279 | { |
| 1280 | u32 kmrnctrlsta; |
| 1281 | s32 ret_val = 0; |
| 1282 | |
| 1283 | ret_val = e1000_acquire_mac_csr_80003es2lan(hw); |
| 1284 | if (ret_val) |
| 1285 | return ret_val; |
| 1286 | |
| 1287 | kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) & |
| 1288 | E1000_KMRNCTRLSTA_OFFSET) | data; |
| 1289 | ew32(KMRNCTRLSTA, kmrnctrlsta); |
| 1290 | |
| 1291 | udelay(2); |
| 1292 | |
| 1293 | e1000_release_mac_csr_80003es2lan(hw); |
| 1294 | |
| 1295 | return ret_val; |
| 1296 | } |
| 1297 | |
| 1298 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1299 | * e1000_clear_hw_cntrs_80003es2lan - Clear device specific hardware counters |
| 1300 | * @hw: pointer to the HW structure |
| 1301 | * |
| 1302 | * Clears the hardware counters by reading the counter registers. |
| 1303 | **/ |
| 1304 | static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw) |
| 1305 | { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1306 | e1000e_clear_hw_cntrs_base(hw); |
| 1307 | |
Bruce Allan | 99673d9 | 2009-11-20 23:27:21 +0000 | [diff] [blame] | 1308 | er32(PRC64); |
| 1309 | er32(PRC127); |
| 1310 | er32(PRC255); |
| 1311 | er32(PRC511); |
| 1312 | er32(PRC1023); |
| 1313 | er32(PRC1522); |
| 1314 | er32(PTC64); |
| 1315 | er32(PTC127); |
| 1316 | er32(PTC255); |
| 1317 | er32(PTC511); |
| 1318 | er32(PTC1023); |
| 1319 | er32(PTC1522); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1320 | |
Bruce Allan | 99673d9 | 2009-11-20 23:27:21 +0000 | [diff] [blame] | 1321 | er32(ALGNERRC); |
| 1322 | er32(RXERRC); |
| 1323 | er32(TNCRS); |
| 1324 | er32(CEXTERR); |
| 1325 | er32(TSCTC); |
| 1326 | er32(TSCTFC); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1327 | |
Bruce Allan | 99673d9 | 2009-11-20 23:27:21 +0000 | [diff] [blame] | 1328 | er32(MGTPRC); |
| 1329 | er32(MGTPDC); |
| 1330 | er32(MGTPTC); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1331 | |
Bruce Allan | 99673d9 | 2009-11-20 23:27:21 +0000 | [diff] [blame] | 1332 | er32(IAC); |
| 1333 | er32(ICRXOC); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1334 | |
Bruce Allan | 99673d9 | 2009-11-20 23:27:21 +0000 | [diff] [blame] | 1335 | er32(ICRXPTC); |
| 1336 | er32(ICRXATC); |
| 1337 | er32(ICTXPTC); |
| 1338 | er32(ICTXATC); |
| 1339 | er32(ICTXQEC); |
| 1340 | er32(ICTXQMTC); |
| 1341 | er32(ICRXDMTC); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1342 | } |
| 1343 | |
| 1344 | static struct e1000_mac_operations es2_mac_ops = { |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 1345 | .id_led_init = e1000e_id_led_init, |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 1346 | .check_mng_mode = e1000e_check_mng_mode_generic, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1347 | /* check_for_link dependent on media type */ |
| 1348 | .cleanup_led = e1000e_cleanup_led_generic, |
| 1349 | .clear_hw_cntrs = e1000_clear_hw_cntrs_80003es2lan, |
| 1350 | .get_bus_info = e1000e_get_bus_info_pcie, |
| 1351 | .get_link_up_info = e1000_get_link_up_info_80003es2lan, |
| 1352 | .led_on = e1000e_led_on_generic, |
| 1353 | .led_off = e1000e_led_off_generic, |
Jeff Kirsher | e2de3eb | 2008-03-28 09:15:11 -0700 | [diff] [blame] | 1354 | .update_mc_addr_list = e1000e_update_mc_addr_list_generic, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1355 | .reset_hw = e1000_reset_hw_80003es2lan, |
| 1356 | .init_hw = e1000_init_hw_80003es2lan, |
| 1357 | .setup_link = e1000e_setup_link, |
| 1358 | /* setup_physical_interface dependent on media type */ |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 1359 | .setup_led = e1000e_setup_led_generic, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1360 | }; |
| 1361 | |
| 1362 | static struct e1000_phy_operations es2_phy_ops = { |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 1363 | .acquire = e1000_acquire_phy_80003es2lan, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1364 | .check_reset_block = e1000e_check_reset_block_generic, |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 1365 | .commit = e1000e_phy_sw_reset, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1366 | .force_speed_duplex = e1000_phy_force_speed_duplex_80003es2lan, |
| 1367 | .get_cfg_done = e1000_get_cfg_done_80003es2lan, |
| 1368 | .get_cable_length = e1000_get_cable_length_80003es2lan, |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 1369 | .get_info = e1000e_get_phy_info_m88, |
| 1370 | .read_reg = e1000_read_phy_reg_gg82563_80003es2lan, |
| 1371 | .release = e1000_release_phy_80003es2lan, |
| 1372 | .reset = e1000e_phy_hw_reset_generic, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1373 | .set_d0_lplu_state = NULL, |
| 1374 | .set_d3_lplu_state = e1000e_set_d3_lplu_state, |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 1375 | .write_reg = e1000_write_phy_reg_gg82563_80003es2lan, |
Bruce Allan | 75eb0fa | 2008-11-21 16:53:51 -0800 | [diff] [blame] | 1376 | .cfg_on_link_up = e1000_cfg_on_link_up_80003es2lan, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1377 | }; |
| 1378 | |
| 1379 | static struct e1000_nvm_operations es2_nvm_ops = { |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 1380 | .acquire = e1000_acquire_nvm_80003es2lan, |
| 1381 | .read = e1000e_read_nvm_eerd, |
| 1382 | .release = e1000_release_nvm_80003es2lan, |
| 1383 | .update = e1000e_update_nvm_checksum_generic, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1384 | .valid_led_default = e1000e_valid_led_default, |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 1385 | .validate = e1000e_validate_nvm_checksum_generic, |
| 1386 | .write = e1000_write_nvm_80003es2lan, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1387 | }; |
| 1388 | |
| 1389 | struct e1000_info e1000_es2_info = { |
| 1390 | .mac = e1000_80003es2lan, |
| 1391 | .flags = FLAG_HAS_HW_VLAN_FILTER |
| 1392 | | FLAG_HAS_JUMBO_FRAMES |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1393 | | FLAG_HAS_WOL |
| 1394 | | FLAG_APME_IN_CTRL3 |
| 1395 | | FLAG_RX_CSUM_ENABLED |
| 1396 | | FLAG_HAS_CTRLEXT_ON_LOAD |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1397 | | FLAG_RX_NEEDS_RESTART /* errata */ |
| 1398 | | FLAG_TARC_SET_BIT_ZERO /* errata */ |
| 1399 | | FLAG_APME_CHECK_PORT_B |
| 1400 | | FLAG_DISABLE_FC_PAUSE_TIME /* errata */ |
| 1401 | | FLAG_TIPG_MEDIUM_FOR_80003ESLAN, |
| 1402 | .pba = 38, |
Bruce Allan | 2adc55c | 2009-06-02 11:28:58 +0000 | [diff] [blame] | 1403 | .max_hw_frame_size = DEFAULT_JUMBO, |
Jeff Kirsher | 69e3fd8 | 2008-04-02 13:48:18 -0700 | [diff] [blame] | 1404 | .get_variants = e1000_get_variants_80003es2lan, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1405 | .mac_ops = &es2_mac_ops, |
| 1406 | .phy_ops = &es2_phy_ops, |
| 1407 | .nvm_ops = &es2_nvm_ops, |
| 1408 | }; |
| 1409 | |