e1000_82571.c revision 177867
1/****************************************************************************** 2 3 Copyright (c) 2001-2008, Intel Corporation 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without 7 modification, are permitted provided that the following conditions are met: 8 9 1. Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 12 2. Redistributions in binary form must reproduce the above copyright 13 notice, this list of conditions and the following disclaimer in the 14 documentation and/or other materials provided with the distribution. 15 16 3. Neither the name of the Intel Corporation nor the names of its 17 contributors may be used to endorse or promote products derived from 18 this software without specific prior written permission. 19 20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 POSSIBILITY OF SUCH DAMAGE. 31 32******************************************************************************/ 33/*$FreeBSD: head/sys/dev/em/e1000_82571.c 177867 2008-04-02 22:00:36Z jfv $*/ 34 35/* e1000_82571 36 * e1000_82572 37 * e1000_82573 38 * e1000_82574 39 */ 40 41#include "e1000_api.h" 42#include "e1000_82571.h" 43 44static s32 e1000_init_phy_params_82571(struct e1000_hw *hw); 45static s32 e1000_init_nvm_params_82571(struct e1000_hw *hw); 46static s32 e1000_init_mac_params_82571(struct e1000_hw *hw); 47static s32 e1000_acquire_nvm_82571(struct e1000_hw *hw); 48static void e1000_release_nvm_82571(struct e1000_hw *hw); 49static s32 e1000_write_nvm_82571(struct e1000_hw *hw, u16 offset, 50 u16 words, u16 *data); 51static s32 e1000_update_nvm_checksum_82571(struct e1000_hw *hw); 52static s32 e1000_validate_nvm_checksum_82571(struct e1000_hw *hw); 53static s32 e1000_get_cfg_done_82571(struct e1000_hw *hw); 54static s32 e1000_set_d0_lplu_state_82571(struct e1000_hw *hw, 55 bool active); 56static s32 e1000_reset_hw_82571(struct e1000_hw *hw); 57static s32 e1000_init_hw_82571(struct e1000_hw *hw); 58static void e1000_clear_vfta_82571(struct e1000_hw *hw); 59static void e1000_update_mc_addr_list_82571(struct e1000_hw *hw, 60 u8 *mc_addr_list, u32 mc_addr_count, 61 u32 rar_used_count, u32 rar_count); 62static s32 e1000_setup_link_82571(struct e1000_hw *hw); 63static s32 e1000_setup_copper_link_82571(struct e1000_hw *hw); 64static s32 e1000_setup_fiber_serdes_link_82571(struct e1000_hw *hw); 65static s32 e1000_valid_led_default_82571(struct e1000_hw *hw, u16 *data); 66static void e1000_clear_hw_cntrs_82571(struct e1000_hw *hw); 67static s32 e1000_get_hw_semaphore_82571(struct e1000_hw *hw); 68static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw); 69static s32 e1000_get_phy_id_82571(struct e1000_hw *hw); 70static void e1000_put_hw_semaphore_82571(struct e1000_hw *hw); 71static void e1000_initialize_hw_bits_82571(struct e1000_hw *hw); 72static s32 e1000_write_nvm_eewr_82571(struct e1000_hw *hw, u16 offset, 73 u16 words, u16 *data); 74static s32 e1000_read_mac_addr_82571(struct e1000_hw *hw); 75static void e1000_power_down_phy_copper_82571(struct e1000_hw *hw); 76 77struct e1000_dev_spec_82571 { 78 bool laa_is_present; 79}; 80 81/** 82 * e1000_init_phy_params_82571 - Init PHY func ptrs. 83 * @hw: pointer to the HW structure 84 * 85 * This is a function pointer entry point called by the api module. 86 **/ 87static s32 e1000_init_phy_params_82571(struct e1000_hw *hw) 88{ 89 struct e1000_phy_info *phy = &hw->phy; 90 s32 ret_val = E1000_SUCCESS; 91 92 DEBUGFUNC("e1000_init_phy_params_82571"); 93 94 if (hw->phy.media_type != e1000_media_type_copper) { 95 phy->type = e1000_phy_none; 96 goto out; 97 } 98 99 phy->addr = 1; 100 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT; 101 phy->reset_delay_us = 100; 102 103 phy->ops.acquire = e1000_get_hw_semaphore_82571; 104 phy->ops.check_polarity = e1000_check_polarity_igp; 105 phy->ops.check_reset_block = e1000_check_reset_block_generic; 106 phy->ops.release = e1000_put_hw_semaphore_82571; 107 phy->ops.reset = e1000_phy_hw_reset_generic; 108 phy->ops.set_d0_lplu_state = e1000_set_d0_lplu_state_82571; 109 phy->ops.set_d3_lplu_state = e1000_set_d3_lplu_state_generic; 110 phy->ops.power_up = e1000_power_up_phy_copper; 111 phy->ops.power_down = e1000_power_down_phy_copper_82571; 112 113 switch (hw->mac.type) { 114 case e1000_82571: 115 case e1000_82572: 116 phy->type = e1000_phy_igp_2; 117 phy->ops.get_cfg_done = e1000_get_cfg_done_82571; 118 phy->ops.get_info = e1000_get_phy_info_igp; 119 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_igp; 120 phy->ops.get_cable_length = e1000_get_cable_length_igp_2; 121 phy->ops.read_reg = e1000_read_phy_reg_igp; 122 phy->ops.write_reg = e1000_write_phy_reg_igp; 123 124 /* This uses above function pointers */ 125 ret_val = e1000_get_phy_id_82571(hw); 126 127 /* Verify PHY ID */ 128 if (phy->id != IGP01E1000_I_PHY_ID) { 129 ret_val = -E1000_ERR_PHY; 130 goto out; 131 } 132 break; 133 case e1000_82573: 134 phy->type = e1000_phy_m88; 135 phy->ops.get_cfg_done = e1000_get_cfg_done_generic; 136 phy->ops.get_info = e1000_get_phy_info_m88; 137 phy->ops.commit = e1000_phy_sw_reset_generic; 138 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_m88; 139 phy->ops.get_cable_length = e1000_get_cable_length_m88; 140 phy->ops.read_reg = e1000_read_phy_reg_m88; 141 phy->ops.write_reg = e1000_write_phy_reg_m88; 142 143 /* This uses above function pointers */ 144 ret_val = e1000_get_phy_id_82571(hw); 145 146 /* Verify PHY ID */ 147 if (phy->id != M88E1111_I_PHY_ID) { 148 ret_val = -E1000_ERR_PHY; 149 DEBUGOUT1("PHY ID unknown: type = 0x%08x\n", phy->id); 150 goto out; 151 } 152 break; 153 default: 154 ret_val = -E1000_ERR_PHY; 155 goto out; 156 break; 157 } 158 159out: 160 return ret_val; 161} 162 163/** 164 * e1000_init_nvm_params_82571 - Init NVM func ptrs. 165 * @hw: pointer to the HW structure 166 * 167 * This is a function pointer entry point called by the api module. 168 **/ 169static s32 e1000_init_nvm_params_82571(struct e1000_hw *hw) 170{ 171 struct e1000_nvm_info *nvm = &hw->nvm; 172 u32 eecd = E1000_READ_REG(hw, E1000_EECD); 173 u16 size; 174 175 DEBUGFUNC("e1000_init_nvm_params_82571"); 176 177 nvm->opcode_bits = 8; 178 nvm->delay_usec = 1; 179 switch (nvm->override) { 180 case e1000_nvm_override_spi_large: 181 nvm->page_size = 32; 182 nvm->address_bits = 16; 183 break; 184 case e1000_nvm_override_spi_small: 185 nvm->page_size = 8; 186 nvm->address_bits = 8; 187 break; 188 default: 189 nvm->page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8; 190 nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ? 16 : 8; 191 break; 192 } 193 194 switch (hw->mac.type) { 195 case e1000_82573: 196 if (((eecd >> 15) & 0x3) == 0x3) { 197 nvm->type = e1000_nvm_flash_hw; 198 nvm->word_size = 2048; 199 /* 200 * Autonomous Flash update bit must be cleared due 201 * to Flash update issue. 202 */ 203 eecd &= ~E1000_EECD_AUPDEN; 204 E1000_WRITE_REG(hw, E1000_EECD, eecd); 205 break; 206 } 207 /* Fall Through */ 208 default: 209 nvm->type = e1000_nvm_eeprom_spi; 210 size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >> 211 E1000_EECD_SIZE_EX_SHIFT); 212 /* 213 * Added to a constant, "size" becomes the left-shift value 214 * for setting word_size. 215 */ 216 size += NVM_WORD_SIZE_BASE_SHIFT; 217 218 /* EEPROM access above 16k is unsupported */ 219 if (size > 14) 220 size = 14; 221 nvm->word_size = 1 << size; 222 break; 223 } 224 225 /* Function Pointers */ 226 nvm->ops.acquire = e1000_acquire_nvm_82571; 227 nvm->ops.read = e1000_read_nvm_eerd; 228 nvm->ops.release = e1000_release_nvm_82571; 229 nvm->ops.update = e1000_update_nvm_checksum_82571; 230 nvm->ops.validate = e1000_validate_nvm_checksum_82571; 231 nvm->ops.valid_led_default = e1000_valid_led_default_82571; 232 nvm->ops.write = e1000_write_nvm_82571; 233 234 return E1000_SUCCESS; 235} 236 237/** 238 * e1000_init_mac_params_82571 - Init MAC func ptrs. 239 * @hw: pointer to the HW structure 240 * 241 * This is a function pointer entry point called by the api module. 242 **/ 243static s32 e1000_init_mac_params_82571(struct e1000_hw *hw) 244{ 245 struct e1000_mac_info *mac = &hw->mac; 246 s32 ret_val = E1000_SUCCESS; 247 248 DEBUGFUNC("e1000_init_mac_params_82571"); 249 250 /* Set media type */ 251 switch (hw->device_id) { 252 case E1000_DEV_ID_82571EB_FIBER: 253 case E1000_DEV_ID_82572EI_FIBER: 254 case E1000_DEV_ID_82571EB_QUAD_FIBER: 255 hw->phy.media_type = e1000_media_type_fiber; 256 break; 257 case E1000_DEV_ID_82571EB_SERDES: 258 case E1000_DEV_ID_82571EB_SERDES_DUAL: 259 case E1000_DEV_ID_82571EB_SERDES_QUAD: 260 case E1000_DEV_ID_82572EI_SERDES: 261 hw->phy.media_type = e1000_media_type_internal_serdes; 262 break; 263 default: 264 hw->phy.media_type = e1000_media_type_copper; 265 break; 266 } 267 268 /* Set mta register count */ 269 mac->mta_reg_count = 128; 270 /* Set rar entry count */ 271 mac->rar_entry_count = E1000_RAR_ENTRIES; 272 /* Set if part includes ASF firmware */ 273 mac->asf_firmware_present = TRUE; 274 /* Set if manageability features are enabled. */ 275 mac->arc_subsystem_valid = 276 (E1000_READ_REG(hw, E1000_FWSM) & E1000_FWSM_MODE_MASK) 277 ? TRUE : FALSE; 278 279 /* Function pointers */ 280 281 /* bus type/speed/width */ 282 mac->ops.get_bus_info = e1000_get_bus_info_pcie_generic; 283 /* reset */ 284 mac->ops.reset_hw = e1000_reset_hw_82571; 285 /* hw initialization */ 286 mac->ops.init_hw = e1000_init_hw_82571; 287 /* link setup */ 288 mac->ops.setup_link = e1000_setup_link_82571; 289 /* physical interface link setup */ 290 mac->ops.setup_physical_interface = 291 (hw->phy.media_type == e1000_media_type_copper) 292 ? e1000_setup_copper_link_82571 293 : e1000_setup_fiber_serdes_link_82571; 294 /* check for link */ 295 switch (hw->phy.media_type) { 296 case e1000_media_type_copper: 297 mac->ops.check_for_link = e1000_check_for_copper_link_generic; 298 break; 299 case e1000_media_type_fiber: 300 mac->ops.check_for_link = e1000_check_for_fiber_link_generic; 301 break; 302 case e1000_media_type_internal_serdes: 303 mac->ops.check_for_link = e1000_check_for_serdes_link_generic; 304 break; 305 default: 306 ret_val = -E1000_ERR_CONFIG; 307 goto out; 308 break; 309 } 310 /* check management mode */ 311 mac->ops.check_mng_mode = e1000_check_mng_mode_generic; 312 /* multicast address update */ 313 mac->ops.update_mc_addr_list = e1000_update_mc_addr_list_82571; 314 /* writing VFTA */ 315 mac->ops.write_vfta = e1000_write_vfta_generic; 316 /* clearing VFTA */ 317 mac->ops.clear_vfta = e1000_clear_vfta_82571; 318 /* setting MTA */ 319 mac->ops.mta_set = e1000_mta_set_generic; 320 /* read mac address */ 321 mac->ops.read_mac_addr = e1000_read_mac_addr_82571; 322 /* blink LED */ 323 mac->ops.blink_led = e1000_blink_led_generic; 324 /* setup LED */ 325 mac->ops.setup_led = e1000_setup_led_generic; 326 /* cleanup LED */ 327 mac->ops.cleanup_led = e1000_cleanup_led_generic; 328 /* turn on/off LED */ 329 mac->ops.led_on = e1000_led_on_generic; 330 mac->ops.led_off = e1000_led_off_generic; 331 /* remove device */ 332 mac->ops.remove_device = e1000_remove_device_generic; 333 /* clear hardware counters */ 334 mac->ops.clear_hw_cntrs = e1000_clear_hw_cntrs_82571; 335 /* link info */ 336 mac->ops.get_link_up_info = 337 (hw->phy.media_type == e1000_media_type_copper) 338 ? e1000_get_speed_and_duplex_copper_generic 339 : e1000_get_speed_and_duplex_fiber_serdes_generic; 340 341 hw->dev_spec_size = sizeof(struct e1000_dev_spec_82571); 342 343 /* Device-specific structure allocation */ 344 ret_val = e1000_alloc_zeroed_dev_spec_struct(hw, hw->dev_spec_size); 345 346out: 347 return ret_val; 348} 349 350/** 351 * e1000_init_function_pointers_82571 - Init func ptrs. 352 * @hw: pointer to the HW structure 353 * 354 * The only function explicitly called by the api module to initialize 355 * all function pointers and parameters. 356 **/ 357void e1000_init_function_pointers_82571(struct e1000_hw *hw) 358{ 359 DEBUGFUNC("e1000_init_function_pointers_82571"); 360 361 hw->mac.ops.init_params = e1000_init_mac_params_82571; 362 hw->nvm.ops.init_params = e1000_init_nvm_params_82571; 363 hw->phy.ops.init_params = e1000_init_phy_params_82571; 364} 365 366/** 367 * e1000_get_phy_id_82571 - Retrieve the PHY ID and revision 368 * @hw: pointer to the HW structure 369 * 370 * Reads the PHY registers and stores the PHY ID and possibly the PHY 371 * revision in the hardware structure. 372 **/ 373static s32 e1000_get_phy_id_82571(struct e1000_hw *hw) 374{ 375 struct e1000_phy_info *phy = &hw->phy; 376 s32 ret_val = E1000_SUCCESS; 377 378 DEBUGFUNC("e1000_get_phy_id_82571"); 379 380 switch (hw->mac.type) { 381 case e1000_82571: 382 case e1000_82572: 383 /* 384 * The 82571 firmware may still be configuring the PHY. 385 * In this case, we cannot access the PHY until the 386 * configuration is done. So we explicitly set the 387 * PHY ID. 388 */ 389 phy->id = IGP01E1000_I_PHY_ID; 390 break; 391 case e1000_82573: 392 ret_val = e1000_get_phy_id(hw); 393 break; 394 default: 395 ret_val = -E1000_ERR_PHY; 396 break; 397 } 398 399 return ret_val; 400} 401 402/** 403 * e1000_get_hw_semaphore_82571 - Acquire hardware semaphore 404 * @hw: pointer to the HW structure 405 * 406 * Acquire the HW semaphore to access the PHY or NVM 407 **/ 408static s32 e1000_get_hw_semaphore_82571(struct e1000_hw *hw) 409{ 410 u32 swsm; 411 s32 ret_val = E1000_SUCCESS; 412 s32 timeout = hw->nvm.word_size + 1; 413 s32 i = 0; 414 415 DEBUGFUNC("e1000_get_hw_semaphore_82571"); 416 417 /* Get the FW semaphore. */ 418 for (i = 0; i < timeout; i++) { 419 swsm = E1000_READ_REG(hw, E1000_SWSM); 420 E1000_WRITE_REG(hw, E1000_SWSM, swsm | E1000_SWSM_SWESMBI); 421 422 /* Semaphore acquired if bit latched */ 423 if (E1000_READ_REG(hw, E1000_SWSM) & E1000_SWSM_SWESMBI) 424 break; 425 426 usec_delay(50); 427 } 428 429 if (i == timeout) { 430 /* Release semaphores */ 431 e1000_put_hw_semaphore_generic(hw); 432 DEBUGOUT("Driver can't access the NVM\n"); 433 ret_val = -E1000_ERR_NVM; 434 goto out; 435 } 436 437out: 438 return ret_val; 439} 440 441/** 442 * e1000_put_hw_semaphore_82571 - Release hardware semaphore 443 * @hw: pointer to the HW structure 444 * 445 * Release hardware semaphore used to access the PHY or NVM 446 **/ 447static void e1000_put_hw_semaphore_82571(struct e1000_hw *hw) 448{ 449 u32 swsm; 450 451 DEBUGFUNC("e1000_put_hw_semaphore_82571"); 452 453 swsm = E1000_READ_REG(hw, E1000_SWSM); 454 455 swsm &= ~E1000_SWSM_SWESMBI; 456 457 E1000_WRITE_REG(hw, E1000_SWSM, swsm); 458} 459 460/** 461 * e1000_acquire_nvm_82571 - Request for access to the EEPROM 462 * @hw: pointer to the HW structure 463 * 464 * To gain access to the EEPROM, first we must obtain a hardware semaphore. 465 * Then for non-82573 hardware, set the EEPROM access request bit and wait 466 * for EEPROM access grant bit. If the access grant bit is not set, release 467 * hardware semaphore. 468 **/ 469static s32 e1000_acquire_nvm_82571(struct e1000_hw *hw) 470{ 471 s32 ret_val; 472 473 DEBUGFUNC("e1000_acquire_nvm_82571"); 474 475 ret_val = e1000_get_hw_semaphore_82571(hw); 476 if (ret_val) 477 goto out; 478 479 if (hw->mac.type != e1000_82573) 480 ret_val = e1000_acquire_nvm_generic(hw); 481 482 if (ret_val) 483 e1000_put_hw_semaphore_82571(hw); 484 485out: 486 return ret_val; 487} 488 489/** 490 * e1000_release_nvm_82571 - Release exclusive access to EEPROM 491 * @hw: pointer to the HW structure 492 * 493 * Stop any current commands to the EEPROM and clear the EEPROM request bit. 494 **/ 495static void e1000_release_nvm_82571(struct e1000_hw *hw) 496{ 497 DEBUGFUNC("e1000_release_nvm_82571"); 498 499 e1000_release_nvm_generic(hw); 500 e1000_put_hw_semaphore_82571(hw); 501} 502 503/** 504 * e1000_write_nvm_82571 - Write to EEPROM using appropriate interface 505 * @hw: pointer to the HW structure 506 * @offset: offset within the EEPROM to be written to 507 * @words: number of words to write 508 * @data: 16 bit word(s) to be written to the EEPROM 509 * 510 * For non-82573 silicon, write data to EEPROM at offset using SPI interface. 511 * 512 * If e1000_update_nvm_checksum is not called after this function, the 513 * EEPROM will most likely contain an invalid checksum. 514 **/ 515static s32 e1000_write_nvm_82571(struct e1000_hw *hw, u16 offset, u16 words, 516 u16 *data) 517{ 518 s32 ret_val = E1000_SUCCESS; 519 520 DEBUGFUNC("e1000_write_nvm_82571"); 521 522 switch (hw->mac.type) { 523 case e1000_82573: 524 ret_val = e1000_write_nvm_eewr_82571(hw, offset, words, data); 525 break; 526 case e1000_82571: 527 case e1000_82572: 528 ret_val = e1000_write_nvm_spi(hw, offset, words, data); 529 break; 530 default: 531 ret_val = -E1000_ERR_NVM; 532 break; 533 } 534 535 return ret_val; 536} 537 538/** 539 * e1000_update_nvm_checksum_82571 - Update EEPROM checksum 540 * @hw: pointer to the HW structure 541 * 542 * Updates the EEPROM checksum by reading/adding each word of the EEPROM 543 * up to the checksum. Then calculates the EEPROM checksum and writes the 544 * value to the EEPROM. 545 **/ 546static s32 e1000_update_nvm_checksum_82571(struct e1000_hw *hw) 547{ 548 u32 eecd; 549 s32 ret_val; 550 u16 i; 551 552 DEBUGFUNC("e1000_update_nvm_checksum_82571"); 553 554 ret_val = e1000_update_nvm_checksum_generic(hw); 555 if (ret_val) 556 goto out; 557 558 /* 559 * If our nvm is an EEPROM, then we're done 560 * otherwise, commit the checksum to the flash NVM. 561 */ 562 if (hw->nvm.type != e1000_nvm_flash_hw) 563 goto out; 564 565 /* Check for pending operations. */ 566 for (i = 0; i < E1000_FLASH_UPDATES; i++) { 567 msec_delay(1); 568 if ((E1000_READ_REG(hw, E1000_EECD) & E1000_EECD_FLUPD) == 0) 569 break; 570 } 571 572 if (i == E1000_FLASH_UPDATES) { 573 ret_val = -E1000_ERR_NVM; 574 goto out; 575 } 576 577 /* Reset the firmware if using STM opcode. */ 578 if ((E1000_READ_REG(hw, E1000_FLOP) & 0xFF00) == E1000_STM_OPCODE) { 579 /* 580 * The enabling of and the actual reset must be done 581 * in two write cycles. 582 */ 583 E1000_WRITE_REG(hw, E1000_HICR, E1000_HICR_FW_RESET_ENABLE); 584 E1000_WRITE_FLUSH(hw); 585 E1000_WRITE_REG(hw, E1000_HICR, E1000_HICR_FW_RESET); 586 } 587 588 /* Commit the write to flash */ 589 eecd = E1000_READ_REG(hw, E1000_EECD) | E1000_EECD_FLUPD; 590 E1000_WRITE_REG(hw, E1000_EECD, eecd); 591 592 for (i = 0; i < E1000_FLASH_UPDATES; i++) { 593 msec_delay(1); 594 if ((E1000_READ_REG(hw, E1000_EECD) & E1000_EECD_FLUPD) == 0) 595 break; 596 } 597 598 if (i == E1000_FLASH_UPDATES) { 599 ret_val = -E1000_ERR_NVM; 600 goto out; 601 } 602 603out: 604 return ret_val; 605} 606 607/** 608 * e1000_validate_nvm_checksum_82571 - Validate EEPROM checksum 609 * @hw: pointer to the HW structure 610 * 611 * Calculates the EEPROM checksum by reading/adding each word of the EEPROM 612 * and then verifies that the sum of the EEPROM is equal to 0xBABA. 613 **/ 614static s32 e1000_validate_nvm_checksum_82571(struct e1000_hw *hw) 615{ 616 DEBUGFUNC("e1000_validate_nvm_checksum_82571"); 617 618 if (hw->nvm.type == e1000_nvm_flash_hw) 619 e1000_fix_nvm_checksum_82571(hw); 620 621 return e1000_validate_nvm_checksum_generic(hw); 622} 623 624/** 625 * e1000_write_nvm_eewr_82571 - Write to EEPROM for 82573 silicon 626 * @hw: pointer to the HW structure 627 * @offset: offset within the EEPROM to be written to 628 * @words: number of words to write 629 * @data: 16 bit word(s) to be written to the EEPROM 630 * 631 * After checking for invalid values, poll the EEPROM to ensure the previous 632 * command has completed before trying to write the next word. After write 633 * poll for completion. 634 * 635 * If e1000_update_nvm_checksum is not called after this function, the 636 * EEPROM will most likely contain an invalid checksum. 637 **/ 638static s32 e1000_write_nvm_eewr_82571(struct e1000_hw *hw, u16 offset, 639 u16 words, u16 *data) 640{ 641 struct e1000_nvm_info *nvm = &hw->nvm; 642 u32 i, eewr = 0; 643 s32 ret_val = 0; 644 645 DEBUGFUNC("e1000_write_nvm_eewr_82571"); 646 647 /* 648 * A check for invalid values: offset too large, too many words, 649 * and not enough words. 650 */ 651 if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) || 652 (words == 0)) { 653 DEBUGOUT("nvm parameter(s) out of bounds\n"); 654 ret_val = -E1000_ERR_NVM; 655 goto out; 656 } 657 658 for (i = 0; i < words; i++) { 659 eewr = (data[i] << E1000_NVM_RW_REG_DATA) | 660 ((offset+i) << E1000_NVM_RW_ADDR_SHIFT) | 661 E1000_NVM_RW_REG_START; 662 663 ret_val = e1000_poll_eerd_eewr_done(hw, E1000_NVM_POLL_WRITE); 664 if (ret_val) 665 break; 666 667 E1000_WRITE_REG(hw, E1000_EEWR, eewr); 668 669 ret_val = e1000_poll_eerd_eewr_done(hw, E1000_NVM_POLL_WRITE); 670 if (ret_val) 671 break; 672 } 673 674out: 675 return ret_val; 676} 677 678/** 679 * e1000_get_cfg_done_82571 - Poll for configuration done 680 * @hw: pointer to the HW structure 681 * 682 * Reads the management control register for the config done bit to be set. 683 **/ 684static s32 e1000_get_cfg_done_82571(struct e1000_hw *hw) 685{ 686 s32 timeout = PHY_CFG_TIMEOUT; 687 s32 ret_val = E1000_SUCCESS; 688 689 DEBUGFUNC("e1000_get_cfg_done_82571"); 690 691 while (timeout) { 692 if (E1000_READ_REG(hw, E1000_EEMNGCTL) & E1000_NVM_CFG_DONE_PORT_0) 693 break; 694 msec_delay(1); 695 timeout--; 696 } 697 if (!timeout) { 698 DEBUGOUT("MNG configuration cycle has not completed.\n"); 699 ret_val = -E1000_ERR_RESET; 700 goto out; 701 } 702 703out: 704 return ret_val; 705} 706 707/** 708 * e1000_set_d0_lplu_state_82571 - Set Low Power Linkup D0 state 709 * @hw: pointer to the HW structure 710 * @active: TRUE to enable LPLU, FALSE to disable 711 * 712 * Sets the LPLU D0 state according to the active flag. When activating LPLU 713 * this function also disables smart speed and vice versa. LPLU will not be 714 * activated unless the device autonegotiation advertisement meets standards 715 * of either 10 or 10/100 or 10/100/1000 at all duplexes. This is a function 716 * pointer entry point only called by PHY setup routines. 717 **/ 718static s32 e1000_set_d0_lplu_state_82571(struct e1000_hw *hw, bool active) 719{ 720 struct e1000_phy_info *phy = &hw->phy; 721 s32 ret_val = E1000_SUCCESS; 722 u16 data; 723 724 DEBUGFUNC("e1000_set_d0_lplu_state_82571"); 725 726 if (!(phy->ops.read_reg)) 727 goto out; 728 729 ret_val = phy->ops.read_reg(hw, IGP02E1000_PHY_POWER_MGMT, &data); 730 if (ret_val) 731 goto out; 732 733 if (active) { 734 data |= IGP02E1000_PM_D0_LPLU; 735 ret_val = phy->ops.write_reg(hw, IGP02E1000_PHY_POWER_MGMT, 736 data); 737 if (ret_val) 738 goto out; 739 740 /* When LPLU is enabled, we should disable SmartSpeed */ 741 ret_val = phy->ops.read_reg(hw, IGP01E1000_PHY_PORT_CONFIG, 742 &data); 743 data &= ~IGP01E1000_PSCFR_SMART_SPEED; 744 ret_val = phy->ops.write_reg(hw, IGP01E1000_PHY_PORT_CONFIG, 745 data); 746 if (ret_val) 747 goto out; 748 } else { 749 data &= ~IGP02E1000_PM_D0_LPLU; 750 ret_val = phy->ops.write_reg(hw, IGP02E1000_PHY_POWER_MGMT, 751 data); 752 /* 753 * LPLU and SmartSpeed are mutually exclusive. LPLU is used 754 * during Dx states where the power conservation is most 755 * important. During driver activity we should enable 756 * SmartSpeed, so performance is maintained. 757 */ 758 if (phy->smart_speed == e1000_smart_speed_on) { 759 ret_val = phy->ops.read_reg(hw, 760 IGP01E1000_PHY_PORT_CONFIG, 761 &data); 762 if (ret_val) 763 goto out; 764 765 data |= IGP01E1000_PSCFR_SMART_SPEED; 766 ret_val = phy->ops.write_reg(hw, 767 IGP01E1000_PHY_PORT_CONFIG, 768 data); 769 if (ret_val) 770 goto out; 771 } else if (phy->smart_speed == e1000_smart_speed_off) { 772 ret_val = phy->ops.read_reg(hw, 773 IGP01E1000_PHY_PORT_CONFIG, 774 &data); 775 if (ret_val) 776 goto out; 777 778 data &= ~IGP01E1000_PSCFR_SMART_SPEED; 779 ret_val = phy->ops.write_reg(hw, 780 IGP01E1000_PHY_PORT_CONFIG, 781 data); 782 if (ret_val) 783 goto out; 784 } 785 } 786 787out: 788 return ret_val; 789} 790 791/** 792 * e1000_reset_hw_82571 - Reset hardware 793 * @hw: pointer to the HW structure 794 * 795 * This resets the hardware into a known state. This is a 796 * function pointer entry point called by the api module. 797 **/ 798static s32 e1000_reset_hw_82571(struct e1000_hw *hw) 799{ 800 u32 ctrl, extcnf_ctrl, ctrl_ext, icr; 801 s32 ret_val; 802 u16 i = 0; 803 804 DEBUGFUNC("e1000_reset_hw_82571"); 805 806 /* 807 * Prevent the PCI-E bus from sticking if there is no TLP connection 808 * on the last TLP read/write transaction when MAC is reset. 809 */ 810 ret_val = e1000_disable_pcie_master_generic(hw); 811 if (ret_val) { 812 DEBUGOUT("PCI-E Master disable polling has failed.\n"); 813 } 814 815 DEBUGOUT("Masking off all interrupts\n"); 816 E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff); 817 818 E1000_WRITE_REG(hw, E1000_RCTL, 0); 819 E1000_WRITE_REG(hw, E1000_TCTL, E1000_TCTL_PSP); 820 E1000_WRITE_FLUSH(hw); 821 822 msec_delay(10); 823 824 /* 825 * Must acquire the MDIO ownership before MAC reset. 826 * Ownership defaults to firmware after a reset. 827 */ 828 if (hw->mac.type == e1000_82573) { 829 extcnf_ctrl = E1000_READ_REG(hw, E1000_EXTCNF_CTRL); 830 extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP; 831 832 do { 833 E1000_WRITE_REG(hw, E1000_EXTCNF_CTRL, extcnf_ctrl); 834 extcnf_ctrl = E1000_READ_REG(hw, E1000_EXTCNF_CTRL); 835 836 if (extcnf_ctrl & E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP) 837 break; 838 839 extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP; 840 841 msec_delay(2); 842 i++; 843 } while (i < MDIO_OWNERSHIP_TIMEOUT); 844 } 845 846 ctrl = E1000_READ_REG(hw, E1000_CTRL); 847 848 DEBUGOUT("Issuing a global reset to MAC\n"); 849 E1000_WRITE_REG(hw, E1000_CTRL, ctrl | E1000_CTRL_RST); 850 851 if (hw->nvm.type == e1000_nvm_flash_hw) { 852 usec_delay(10); 853 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT); 854 ctrl_ext |= E1000_CTRL_EXT_EE_RST; 855 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext); 856 E1000_WRITE_FLUSH(hw); 857 } 858 859 ret_val = e1000_get_auto_rd_done_generic(hw); 860 if (ret_val) 861 /* We don't want to continue accessing MAC registers. */ 862 goto out; 863 864 /* 865 * Phy configuration from NVM just starts after EECD_AUTO_RD is set. 866 * Need to wait for Phy configuration completion before accessing 867 * NVM and Phy. 868 */ 869 if (hw->mac.type == e1000_82573) 870 msec_delay(25); 871 872 /* Clear any pending interrupt events. */ 873 E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff); 874 icr = E1000_READ_REG(hw, E1000_ICR); 875 876 if (!(e1000_check_alt_mac_addr_generic(hw))) 877 e1000_set_laa_state_82571(hw, TRUE); 878 879out: 880 return ret_val; 881} 882 883/** 884 * e1000_init_hw_82571 - Initialize hardware 885 * @hw: pointer to the HW structure 886 * 887 * This inits the hardware readying it for operation. 888 **/ 889static s32 e1000_init_hw_82571(struct e1000_hw *hw) 890{ 891 struct e1000_mac_info *mac = &hw->mac; 892 u32 reg_data; 893 s32 ret_val; 894 u16 i, rar_count = mac->rar_entry_count; 895 896 DEBUGFUNC("e1000_init_hw_82571"); 897 898 e1000_initialize_hw_bits_82571(hw); 899 900 /* Initialize identification LED */ 901 ret_val = e1000_id_led_init_generic(hw); 902 if (ret_val) { 903 DEBUGOUT("Error initializing identification LED\n"); 904 /* This is not fatal and we should not stop init due to this */ 905 } 906 907 /* Disabling VLAN filtering */ 908 DEBUGOUT("Initializing the IEEE VLAN\n"); 909 mac->ops.clear_vfta(hw); 910 911 /* Setup the receive address. */ 912 /* 913 * If, however, a locally administered address was assigned to the 914 * 82571, we must reserve a RAR for it to work around an issue where 915 * resetting one port will reload the MAC on the other port. 916 */ 917 if (e1000_get_laa_state_82571(hw)) 918 rar_count--; 919 e1000_init_rx_addrs_generic(hw, rar_count); 920 921 /* Zero out the Multicast HASH table */ 922 DEBUGOUT("Zeroing the MTA\n"); 923 for (i = 0; i < mac->mta_reg_count; i++) 924 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0); 925 926 /* Setup link and flow control */ 927 ret_val = mac->ops.setup_link(hw); 928 929 /* Set the transmit descriptor write-back policy */ 930 reg_data = E1000_READ_REG(hw, E1000_TXDCTL(0)); 931 reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) | 932 E1000_TXDCTL_FULL_TX_DESC_WB | 933 E1000_TXDCTL_COUNT_DESC; 934 E1000_WRITE_REG(hw, E1000_TXDCTL(0), reg_data); 935 936 /* ...for both queues. */ 937 if (mac->type != e1000_82573) { 938 reg_data = E1000_READ_REG(hw, E1000_TXDCTL(1)); 939 reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) | 940 E1000_TXDCTL_FULL_TX_DESC_WB | 941 E1000_TXDCTL_COUNT_DESC; 942 E1000_WRITE_REG(hw, E1000_TXDCTL(1), reg_data); 943 } else { 944 e1000_enable_tx_pkt_filtering(hw); 945 reg_data = E1000_READ_REG(hw, E1000_GCR); 946 reg_data |= E1000_GCR_L1_ACT_WITHOUT_L0S_RX; 947 E1000_WRITE_REG(hw, E1000_GCR, reg_data); 948 } 949 950 /* 951 * Clear all of the statistics registers (clear on read). It is 952 * important that we do this after we have tried to establish link 953 * because the symbol error count will increment wildly if there 954 * is no link. 955 */ 956 e1000_clear_hw_cntrs_82571(hw); 957 958 return ret_val; 959} 960 961/** 962 * e1000_initialize_hw_bits_82571 - Initialize hardware-dependent bits 963 * @hw: pointer to the HW structure 964 * 965 * Initializes required hardware-dependent bits needed for normal operation. 966 **/ 967static void e1000_initialize_hw_bits_82571(struct e1000_hw *hw) 968{ 969 u32 reg; 970 971 DEBUGFUNC("e1000_initialize_hw_bits_82571"); 972 973 if (hw->mac.disable_hw_init_bits) 974 goto out; 975 976 /* Transmit Descriptor Control 0 */ 977 reg = E1000_READ_REG(hw, E1000_TXDCTL(0)); 978 reg |= (1 << 22); 979 E1000_WRITE_REG(hw, E1000_TXDCTL(0), reg); 980 981 /* Transmit Descriptor Control 1 */ 982 reg = E1000_READ_REG(hw, E1000_TXDCTL(1)); 983 reg |= (1 << 22); 984 E1000_WRITE_REG(hw, E1000_TXDCTL(1), reg); 985 986 /* Transmit Arbitration Control 0 */ 987 reg = E1000_READ_REG(hw, E1000_TARC(0)); 988 reg &= ~(0xF << 27); /* 30:27 */ 989 switch (hw->mac.type) { 990 case e1000_82571: 991 case e1000_82572: 992 reg |= (1 << 23) | (1 << 24) | (1 << 25) | (1 << 26); 993 break; 994 default: 995 break; 996 } 997 E1000_WRITE_REG(hw, E1000_TARC(0), reg); 998 999 /* Transmit Arbitration Control 1 */ 1000 reg = E1000_READ_REG(hw, E1000_TARC(1)); 1001 switch (hw->mac.type) { 1002 case e1000_82571: 1003 case e1000_82572: 1004 reg &= ~((1 << 29) | (1 << 30)); 1005 reg |= (1 << 22) | (1 << 24) | (1 << 25) | (1 << 26); 1006 if (E1000_READ_REG(hw, E1000_TCTL) & E1000_TCTL_MULR) 1007 reg &= ~(1 << 28); 1008 else 1009 reg |= (1 << 28); 1010 E1000_WRITE_REG(hw, E1000_TARC(1), reg); 1011 break; 1012 default: 1013 break; 1014 } 1015 1016 /* Device Control */ 1017 if (hw->mac.type == e1000_82573) { 1018 reg = E1000_READ_REG(hw, E1000_CTRL); 1019 reg &= ~(1 << 29); 1020 E1000_WRITE_REG(hw, E1000_CTRL, reg); 1021 } 1022 1023 /* Extended Device Control */ 1024 if (hw->mac.type == e1000_82573) { 1025 reg = E1000_READ_REG(hw, E1000_CTRL_EXT); 1026 reg &= ~(1 << 23); 1027 reg |= (1 << 22); 1028 E1000_WRITE_REG(hw, E1000_CTRL_EXT, reg); 1029 } 1030 1031out: 1032 return; 1033} 1034 1035/** 1036 * e1000_clear_vfta_82571 - Clear VLAN filter table 1037 * @hw: pointer to the HW structure 1038 * 1039 * Clears the register array which contains the VLAN filter table by 1040 * setting all the values to 0. 1041 **/ 1042static void e1000_clear_vfta_82571(struct e1000_hw *hw) 1043{ 1044 u32 offset; 1045 u32 vfta_value = 0; 1046 u32 vfta_offset = 0; 1047 u32 vfta_bit_in_reg = 0; 1048 1049 DEBUGFUNC("e1000_clear_vfta_82571"); 1050 1051 if (hw->mac.type == e1000_82573) { 1052 if (hw->mng_cookie.vlan_id != 0) { 1053 /* 1054 * The VFTA is a 4096b bit-field, each identifying 1055 * a single VLAN ID. The following operations 1056 * determine which 32b entry (i.e. offset) into the 1057 * array we want to set the VLAN ID (i.e. bit) of 1058 * the manageability unit. 1059 */ 1060 vfta_offset = (hw->mng_cookie.vlan_id >> 1061 E1000_VFTA_ENTRY_SHIFT) & 1062 E1000_VFTA_ENTRY_MASK; 1063 vfta_bit_in_reg = 1 << (hw->mng_cookie.vlan_id & 1064 E1000_VFTA_ENTRY_BIT_SHIFT_MASK); 1065 } 1066 } 1067 for (offset = 0; offset < E1000_VLAN_FILTER_TBL_SIZE; offset++) { 1068 /* 1069 * If the offset we want to clear is the same offset of the 1070 * manageability VLAN ID, then clear all bits except that of 1071 * the manageability unit. 1072 */ 1073 vfta_value = (offset == vfta_offset) ? vfta_bit_in_reg : 0; 1074 E1000_WRITE_REG_ARRAY(hw, E1000_VFTA, offset, vfta_value); 1075 E1000_WRITE_FLUSH(hw); 1076 } 1077} 1078 1079/** 1080 * e1000_update_mc_addr_list_82571 - Update Multicast addresses 1081 * @hw: pointer to the HW structure 1082 * @mc_addr_list: array of multicast addresses to program 1083 * @mc_addr_count: number of multicast addresses to program 1084 * @rar_used_count: the first RAR register free to program 1085 * @rar_count: total number of supported Receive Address Registers 1086 * 1087 * Updates the Receive Address Registers and Multicast Table Array. 1088 * The caller must have a packed mc_addr_list of multicast addresses. 1089 * The parameter rar_count will usually be hw->mac.rar_entry_count 1090 * unless there are workarounds that change this. 1091 **/ 1092static void e1000_update_mc_addr_list_82571(struct e1000_hw *hw, 1093 u8 *mc_addr_list, u32 mc_addr_count, 1094 u32 rar_used_count, u32 rar_count) 1095{ 1096 DEBUGFUNC("e1000_update_mc_addr_list_82571"); 1097 1098 if (e1000_get_laa_state_82571(hw)) 1099 rar_count--; 1100 1101 e1000_update_mc_addr_list_generic(hw, mc_addr_list, mc_addr_count, 1102 rar_used_count, rar_count); 1103} 1104 1105/** 1106 * e1000_setup_link_82571 - Setup flow control and link settings 1107 * @hw: pointer to the HW structure 1108 * 1109 * Determines which flow control settings to use, then configures flow 1110 * control. Calls the appropriate media-specific link configuration 1111 * function. Assuming the adapter has a valid link partner, a valid link 1112 * should be established. Assumes the hardware has previously been reset 1113 * and the transmitter and receiver are not enabled. 1114 **/ 1115static s32 e1000_setup_link_82571(struct e1000_hw *hw) 1116{ 1117 DEBUGFUNC("e1000_setup_link_82571"); 1118 1119 /* 1120 * 82573 does not have a word in the NVM to determine 1121 * the default flow control setting, so we explicitly 1122 * set it to full. 1123 */ 1124 if (hw->mac.type == e1000_82573 && hw->fc.type == e1000_fc_default) 1125 hw->fc.type = e1000_fc_full; 1126 1127 return e1000_setup_link_generic(hw); 1128} 1129 1130/** 1131 * e1000_setup_copper_link_82571 - Configure copper link settings 1132 * @hw: pointer to the HW structure 1133 * 1134 * Configures the link for auto-neg or forced speed and duplex. Then we check 1135 * for link, once link is established calls to configure collision distance 1136 * and flow control are called. 1137 **/ 1138static s32 e1000_setup_copper_link_82571(struct e1000_hw *hw) 1139{ 1140 u32 ctrl, led_ctrl; 1141 s32 ret_val; 1142 1143 DEBUGFUNC("e1000_setup_copper_link_82571"); 1144 1145 ctrl = E1000_READ_REG(hw, E1000_CTRL); 1146 ctrl |= E1000_CTRL_SLU; 1147 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX); 1148 E1000_WRITE_REG(hw, E1000_CTRL, ctrl); 1149 1150 switch (hw->phy.type) { 1151 case e1000_phy_m88: 1152 case e1000_phy_bm: 1153 ret_val = e1000_copper_link_setup_m88(hw); 1154 break; 1155 case e1000_phy_igp_2: 1156 ret_val = e1000_copper_link_setup_igp(hw); 1157 /* Setup activity LED */ 1158 led_ctrl = E1000_READ_REG(hw, E1000_LEDCTL); 1159 led_ctrl &= IGP_ACTIVITY_LED_MASK; 1160 led_ctrl |= (IGP_ACTIVITY_LED_ENABLE | IGP_LED3_MODE); 1161 E1000_WRITE_REG(hw, E1000_LEDCTL, led_ctrl); 1162 break; 1163 default: 1164 ret_val = -E1000_ERR_PHY; 1165 break; 1166 } 1167 1168 if (ret_val) 1169 goto out; 1170 1171 ret_val = e1000_setup_copper_link_generic(hw); 1172 1173out: 1174 return ret_val; 1175} 1176 1177/** 1178 * e1000_setup_fiber_serdes_link_82571 - Setup link for fiber/serdes 1179 * @hw: pointer to the HW structure 1180 * 1181 * Configures collision distance and flow control for fiber and serdes links. 1182 * Upon successful setup, poll for link. 1183 **/ 1184static s32 e1000_setup_fiber_serdes_link_82571(struct e1000_hw *hw) 1185{ 1186 DEBUGFUNC("e1000_setup_fiber_serdes_link_82571"); 1187 1188 switch (hw->mac.type) { 1189 case e1000_82571: 1190 case e1000_82572: 1191 /* 1192 * If SerDes loopback mode is entered, there is no form 1193 * of reset to take the adapter out of that mode. So we 1194 * have to explicitly take the adapter out of loopback 1195 * mode. This prevents drivers from twiddling their thumbs 1196 * if another tool failed to take it out of loopback mode. 1197 */ 1198 E1000_WRITE_REG(hw, E1000_SCTL, E1000_SCTL_DISABLE_SERDES_LOOPBACK); 1199 break; 1200 default: 1201 break; 1202 } 1203 1204 return e1000_setup_fiber_serdes_link_generic(hw); 1205} 1206 1207/** 1208 * e1000_valid_led_default_82571 - Verify a valid default LED config 1209 * @hw: pointer to the HW structure 1210 * @data: pointer to the NVM (EEPROM) 1211 * 1212 * Read the EEPROM for the current default LED configuration. If the 1213 * LED configuration is not valid, set to a valid LED configuration. 1214 **/ 1215static s32 e1000_valid_led_default_82571(struct e1000_hw *hw, u16 *data) 1216{ 1217 s32 ret_val; 1218 1219 DEBUGFUNC("e1000_valid_led_default_82571"); 1220 1221 ret_val = hw->nvm.ops.read(hw, NVM_ID_LED_SETTINGS, 1, data); 1222 if (ret_val) { 1223 DEBUGOUT("NVM Read Error\n"); 1224 goto out; 1225 } 1226 1227 if (hw->mac.type == e1000_82573 && 1228 *data == ID_LED_RESERVED_F746) 1229 *data = ID_LED_DEFAULT_82573; 1230 else if (*data == ID_LED_RESERVED_0000 || 1231 *data == ID_LED_RESERVED_FFFF) 1232 *data = ID_LED_DEFAULT; 1233out: 1234 return ret_val; 1235} 1236 1237/** 1238 * e1000_get_laa_state_82571 - Get locally administered address state 1239 * @hw: pointer to the HW structure 1240 * 1241 * Retrieve and return the current locally administered address state. 1242 **/ 1243bool e1000_get_laa_state_82571(struct e1000_hw *hw) 1244{ 1245 struct e1000_dev_spec_82571 *dev_spec; 1246 bool state = FALSE; 1247 1248 DEBUGFUNC("e1000_get_laa_state_82571"); 1249 1250 if (hw->mac.type != e1000_82571) 1251 goto out; 1252 1253 dev_spec = (struct e1000_dev_spec_82571 *)hw->dev_spec; 1254 1255 state = dev_spec->laa_is_present; 1256 1257out: 1258 return state; 1259} 1260 1261/** 1262 * e1000_set_laa_state_82571 - Set locally administered address state 1263 * @hw: pointer to the HW structure 1264 * @state: enable/disable locally administered address 1265 * 1266 * Enable/Disable the current locally administered address state. 1267 **/ 1268void e1000_set_laa_state_82571(struct e1000_hw *hw, bool state) 1269{ 1270 struct e1000_dev_spec_82571 *dev_spec; 1271 1272 DEBUGFUNC("e1000_set_laa_state_82571"); 1273 1274 if (hw->mac.type != e1000_82571) 1275 goto out; 1276 1277 dev_spec = (struct e1000_dev_spec_82571 *)hw->dev_spec; 1278 1279 dev_spec->laa_is_present = state; 1280 1281 /* If workaround is activated... */ 1282 if (state) { 1283 /* 1284 * Hold a copy of the LAA in RAR[14] This is done so that 1285 * between the time RAR[0] gets clobbered and the time it 1286 * gets fixed, the actual LAA is in one of the RARs and no 1287 * incoming packets directed to this port are dropped. 1288 * Eventually the LAA will be in RAR[0] and RAR[14]. 1289 */ 1290 e1000_rar_set_generic(hw, hw->mac.addr, 1291 hw->mac.rar_entry_count - 1); 1292 } 1293 1294out: 1295 return; 1296} 1297 1298/** 1299 * e1000_fix_nvm_checksum_82571 - Fix EEPROM checksum 1300 * @hw: pointer to the HW structure 1301 * 1302 * Verifies that the EEPROM has completed the update. After updating the 1303 * EEPROM, we need to check bit 15 in work 0x23 for the checksum fix. If 1304 * the checksum fix is not implemented, we need to set the bit and update 1305 * the checksum. Otherwise, if bit 15 is set and the checksum is incorrect, 1306 * we need to return bad checksum. 1307 **/ 1308static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw) 1309{ 1310 struct e1000_nvm_info *nvm = &hw->nvm; 1311 s32 ret_val = E1000_SUCCESS; 1312 u16 data; 1313 1314 DEBUGFUNC("e1000_fix_nvm_checksum_82571"); 1315 1316 if (nvm->type != e1000_nvm_flash_hw) 1317 goto out; 1318 1319 /* 1320 * Check bit 4 of word 10h. If it is 0, firmware is done updating 1321 * 10h-12h. Checksum may need to be fixed. 1322 */ 1323 ret_val = nvm->ops.read(hw, 0x10, 1, &data); 1324 if (ret_val) 1325 goto out; 1326 1327 if (!(data & 0x10)) { 1328 /* 1329 * Read 0x23 and check bit 15. This bit is a 1 1330 * when the checksum has already been fixed. If 1331 * the checksum is still wrong and this bit is a 1332 * 1, we need to return bad checksum. Otherwise, 1333 * we need to set this bit to a 1 and update the 1334 * checksum. 1335 */ 1336 ret_val = nvm->ops.read(hw, 0x23, 1, &data); 1337 if (ret_val) 1338 goto out; 1339 1340 if (!(data & 0x8000)) { 1341 data |= 0x8000; 1342 ret_val = nvm->ops.write(hw, 0x23, 1, &data); 1343 if (ret_val) 1344 goto out; 1345 ret_val = nvm->ops.update(hw); 1346 } 1347 } 1348 1349out: 1350 return ret_val; 1351} 1352 1353/** 1354 * e1000_read_mac_addr_82571 - Read device MAC address 1355 * @hw: pointer to the HW structure 1356 **/ 1357static s32 e1000_read_mac_addr_82571(struct e1000_hw *hw) 1358{ 1359 s32 ret_val = E1000_SUCCESS; 1360 1361 DEBUGFUNC("e1000_read_mac_addr_82571"); 1362 if (e1000_check_alt_mac_addr_generic(hw)) 1363 ret_val = e1000_read_mac_addr_generic(hw); 1364 1365 return ret_val; 1366} 1367 1368/** 1369 * e1000_power_down_phy_copper_82571 - Remove link during PHY power down 1370 * @hw: pointer to the HW structure 1371 * 1372 * In the case of a PHY power down to save power, or to turn off link during a 1373 * driver unload, or wake on lan is not enabled, remove the link. 1374 **/ 1375static void e1000_power_down_phy_copper_82571(struct e1000_hw *hw) 1376{ 1377 struct e1000_phy_info *phy = &hw->phy; 1378 struct e1000_mac_info *mac = &hw->mac; 1379 1380 if (!(phy->ops.check_reset_block)) 1381 return; 1382 1383 /* If the management interface is not enabled, then power down */ 1384 if (!(mac->ops.check_mng_mode(hw) || phy->ops.check_reset_block(hw))) 1385 e1000_power_down_phy_copper(hw); 1386 1387 return; 1388} 1389 1390/** 1391 * e1000_clear_hw_cntrs_82571 - Clear device specific hardware counters 1392 * @hw: pointer to the HW structure 1393 * 1394 * Clears the hardware counters by reading the counter registers. 1395 **/ 1396static void e1000_clear_hw_cntrs_82571(struct e1000_hw *hw) 1397{ 1398 volatile u32 temp; 1399 1400 DEBUGFUNC("e1000_clear_hw_cntrs_82571"); 1401 1402 e1000_clear_hw_cntrs_base_generic(hw); 1403 temp = E1000_READ_REG(hw, E1000_PRC64); 1404 temp = E1000_READ_REG(hw, E1000_PRC127); 1405 temp = E1000_READ_REG(hw, E1000_PRC255); 1406 temp = E1000_READ_REG(hw, E1000_PRC511); 1407 temp = E1000_READ_REG(hw, E1000_PRC1023); 1408 temp = E1000_READ_REG(hw, E1000_PRC1522); 1409 temp = E1000_READ_REG(hw, E1000_PTC64); 1410 temp = E1000_READ_REG(hw, E1000_PTC127); 1411 temp = E1000_READ_REG(hw, E1000_PTC255); 1412 temp = E1000_READ_REG(hw, E1000_PTC511); 1413 temp = E1000_READ_REG(hw, E1000_PTC1023); 1414 temp = E1000_READ_REG(hw, E1000_PTC1522); 1415 1416 temp = E1000_READ_REG(hw, E1000_ALGNERRC); 1417 temp = E1000_READ_REG(hw, E1000_RXERRC); 1418 temp = E1000_READ_REG(hw, E1000_TNCRS); 1419 temp = E1000_READ_REG(hw, E1000_CEXTERR); 1420 temp = E1000_READ_REG(hw, E1000_TSCTC); 1421 temp = E1000_READ_REG(hw, E1000_TSCTFC); 1422 1423 temp = E1000_READ_REG(hw, E1000_MGTPRC); 1424 temp = E1000_READ_REG(hw, E1000_MGTPDC); 1425 temp = E1000_READ_REG(hw, E1000_MGTPTC); 1426 1427 temp = E1000_READ_REG(hw, E1000_IAC); 1428 temp = E1000_READ_REG(hw, E1000_ICRXOC); 1429 1430 temp = E1000_READ_REG(hw, E1000_ICRXPTC); 1431 temp = E1000_READ_REG(hw, E1000_ICRXATC); 1432 temp = E1000_READ_REG(hw, E1000_ICTXPTC); 1433 temp = E1000_READ_REG(hw, E1000_ICTXATC); 1434 temp = E1000_READ_REG(hw, E1000_ICTXQEC); 1435 temp = E1000_READ_REG(hw, E1000_ICTXQMTC); 1436 temp = E1000_READ_REG(hw, E1000_ICRXDMTC); 1437} 1438