e1000_82541.c

Go to the documentation of this file.
00001 /*******************************************************************************
00002 
00003   Intel PRO/1000 Linux driver
00004   Copyright(c) 1999 - 2008 Intel Corporation.
00005 
00006   This program is free software; you can redistribute it and/or modify it
00007   under the terms and conditions of the GNU General Public License,
00008   version 2, as published by the Free Software Foundation.
00009 
00010   This program is distributed in the hope it will be useful, but WITHOUT
00011   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
00013   more details.
00014 
00015   You should have received a copy of the GNU General Public License along with
00016   this program; if not, write to the Free Software Foundation, Inc.,
00017   51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
00018 
00019   The full GNU General Public License is included in this distribution in
00020   the file called "COPYING".
00021 
00022   Contact Information:
00023   Linux NICS <linux.nics@intel.com>
00024   e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
00025   Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
00026 
00027 *******************************************************************************/
00028 
00029 FILE_LICENCE ( GPL2_OR_LATER );
00030 
00031 /*
00032  * 82541EI Gigabit Ethernet Controller
00033  * 82541ER Gigabit Ethernet Controller
00034  * 82541GI Gigabit Ethernet Controller
00035  * 82541PI Gigabit Ethernet Controller
00036  * 82547EI Gigabit Ethernet Controller
00037  * 82547GI Gigabit Ethernet Controller
00038  */
00039 
00040 #include "e1000_api.h"
00041 
00042 static s32  e1000_init_phy_params_82541(struct e1000_hw *hw);
00043 static s32  e1000_init_nvm_params_82541(struct e1000_hw *hw);
00044 static s32  e1000_init_mac_params_82541(struct e1000_hw *hw);
00045 static s32  e1000_reset_hw_82541(struct e1000_hw *hw);
00046 static s32  e1000_init_hw_82541(struct e1000_hw *hw);
00047 static s32  e1000_get_link_up_info_82541(struct e1000_hw *hw, u16 *speed,
00048                                          u16 *duplex);
00049 static s32  e1000_phy_hw_reset_82541(struct e1000_hw *hw);
00050 static s32  e1000_setup_copper_link_82541(struct e1000_hw *hw);
00051 static s32  e1000_check_for_link_82541(struct e1000_hw *hw);
00052 #if 0
00053 static s32  e1000_get_cable_length_igp_82541(struct e1000_hw *hw);
00054 #endif
00055 static s32  e1000_set_d3_lplu_state_82541(struct e1000_hw *hw,
00056                                           bool active);
00057 static s32  e1000_setup_led_82541(struct e1000_hw *hw);
00058 static s32  e1000_cleanup_led_82541(struct e1000_hw *hw);
00059 static void e1000_clear_hw_cntrs_82541(struct e1000_hw *hw);
00060 #if 0
00061 static s32  e1000_config_dsp_after_link_change_82541(struct e1000_hw *hw,
00062                                                      bool link_up);
00063 #endif
00064 static s32  e1000_phy_init_script_82541(struct e1000_hw *hw);
00065 static void e1000_power_down_phy_copper_82541(struct e1000_hw *hw);
00066 
00067 #if 0
00068 static const u16 e1000_igp_cable_length_table[] =
00069     { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
00070       5, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 25, 25, 25,
00071       25, 25, 25, 25, 30, 30, 30, 30, 40, 40, 40, 40, 40, 40, 40, 40,
00072       40, 50, 50, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60, 60, 60,
00073       60, 70, 70, 70, 70, 70, 70, 80, 80, 80, 80, 80, 80, 90, 90, 90,
00074       90, 90, 90, 90, 90, 90, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
00075       100, 100, 100, 100, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110,
00076       110, 110, 110, 110, 110, 110, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120};
00077 #define IGP01E1000_AGC_LENGTH_TABLE_SIZE \
00078                 (sizeof(e1000_igp_cable_length_table) / \
00079                  sizeof(e1000_igp_cable_length_table[0]))
00080 #endif
00081 /**
00082  *  e1000_init_phy_params_82541 - Init PHY func ptrs.
00083  *  @hw: pointer to the HW structure
00084  **/
00085 static s32 e1000_init_phy_params_82541(struct e1000_hw *hw)
00086 {
00087         struct e1000_phy_info *phy = &hw->phy;
00088         s32 ret_val = E1000_SUCCESS;
00089 
00090         DEBUGFUNC("e1000_init_phy_params_82541");
00091 
00092         phy->addr                      = 1;
00093         phy->autoneg_mask              = AUTONEG_ADVERTISE_SPEED_DEFAULT;
00094         phy->reset_delay_us            = 10000;
00095         phy->type                      = e1000_phy_igp;
00096 
00097         /* Function Pointers */
00098         phy->ops.check_polarity        = e1000_check_polarity_igp;
00099 #if 0
00100         phy->ops.force_speed_duplex    = e1000_phy_force_speed_duplex_igp;
00101 #endif
00102 #if 0
00103         phy->ops.get_cable_length      = e1000_get_cable_length_igp_82541;
00104 #endif
00105         phy->ops.get_cfg_done          = e1000_get_cfg_done_generic;
00106         phy->ops.get_info              = e1000_get_phy_info_igp;
00107         phy->ops.read_reg              = e1000_read_phy_reg_igp;
00108         phy->ops.reset                 = e1000_phy_hw_reset_82541;
00109         phy->ops.set_d3_lplu_state     = e1000_set_d3_lplu_state_82541;
00110         phy->ops.write_reg             = e1000_write_phy_reg_igp;
00111         phy->ops.power_up              = e1000_power_up_phy_copper;
00112         phy->ops.power_down            = e1000_power_down_phy_copper_82541;
00113 
00114         ret_val = e1000_get_phy_id(hw);
00115         if (ret_val)
00116                 goto out;
00117 
00118         /* Verify phy id */
00119         if (phy->id != IGP01E1000_I_PHY_ID) {
00120                 ret_val = -E1000_ERR_PHY;
00121                 goto out;
00122         }
00123 
00124 out:
00125         return ret_val;
00126 }
00127 
00128 /**
00129  *  e1000_init_nvm_params_82541 - Init NVM func ptrs.
00130  *  @hw: pointer to the HW structure
00131  **/
00132 static s32 e1000_init_nvm_params_82541(struct e1000_hw *hw)
00133 {
00134         struct   e1000_nvm_info *nvm = &hw->nvm;
00135         s32  ret_val = E1000_SUCCESS;
00136         u32 eecd = E1000_READ_REG(hw, E1000_EECD);
00137         u16 size;
00138 
00139         DEBUGFUNC("e1000_init_nvm_params_82541");
00140 
00141         switch (nvm->override) {
00142         case e1000_nvm_override_spi_large:
00143                 nvm->type = e1000_nvm_eeprom_spi;
00144                 eecd |= E1000_EECD_ADDR_BITS;
00145                 break;
00146         case e1000_nvm_override_spi_small:
00147                 nvm->type = e1000_nvm_eeprom_spi;
00148                 eecd &= ~E1000_EECD_ADDR_BITS;
00149                 break;
00150         case e1000_nvm_override_microwire_large:
00151                 nvm->type = e1000_nvm_eeprom_microwire;
00152                 eecd |= E1000_EECD_SIZE;
00153                 break;
00154         case e1000_nvm_override_microwire_small:
00155                 nvm->type = e1000_nvm_eeprom_microwire;
00156                 eecd &= ~E1000_EECD_SIZE;
00157                 break;
00158         default:
00159                 nvm->type = eecd & E1000_EECD_TYPE
00160                             ? e1000_nvm_eeprom_spi
00161                             : e1000_nvm_eeprom_microwire;
00162                 break;
00163         }
00164 
00165         if (nvm->type == e1000_nvm_eeprom_spi) {
00166                 nvm->address_bits       = (eecd & E1000_EECD_ADDR_BITS)
00167                                           ? 16 : 8;
00168                 nvm->delay_usec         = 1;
00169                 nvm->opcode_bits        = 8;
00170                 nvm->page_size          = (eecd & E1000_EECD_ADDR_BITS)
00171                                           ? 32 : 8;
00172 
00173                 /* Function Pointers */
00174                 nvm->ops.acquire        = e1000_acquire_nvm_generic;
00175                 nvm->ops.read           = e1000_read_nvm_spi;
00176                 nvm->ops.release        = e1000_release_nvm_generic;
00177                 nvm->ops.update         = e1000_update_nvm_checksum_generic;
00178                 nvm->ops.valid_led_default = e1000_valid_led_default_generic;
00179                 nvm->ops.validate       = e1000_validate_nvm_checksum_generic;
00180                 nvm->ops.write          = e1000_write_nvm_spi;
00181 
00182                 /*
00183                  * nvm->word_size must be discovered after the pointers
00184                  * are set so we can verify the size from the nvm image
00185                  * itself.  Temporarily set it to a dummy value so the
00186                  * read will work.
00187                  */
00188                 nvm->word_size = 64;
00189                 ret_val = nvm->ops.read(hw, NVM_CFG, 1, &size);
00190                 if (ret_val)
00191                         goto out;
00192                 size = (size & NVM_SIZE_MASK) >> NVM_SIZE_SHIFT;
00193                 /*
00194                  * if size != 0, it can be added to a constant and become
00195                  * the left-shift value to set the word_size.  Otherwise,
00196                  * word_size stays at 64.
00197                  */
00198                 if (size) {
00199                         size += NVM_WORD_SIZE_BASE_SHIFT_82541;
00200                         nvm->word_size = 1 << size;
00201                 }
00202         } else {
00203                 nvm->address_bits       = (eecd & E1000_EECD_ADDR_BITS)
00204                                           ? 8 : 6;
00205                 nvm->delay_usec         = 50;
00206                 nvm->opcode_bits        = 3;
00207                 nvm->word_size          = (eecd & E1000_EECD_ADDR_BITS)
00208                                           ? 256 : 64;
00209 
00210                 /* Function Pointers */
00211                 nvm->ops.acquire        = e1000_acquire_nvm_generic;
00212                 nvm->ops.read           = e1000_read_nvm_microwire;
00213                 nvm->ops.release        = e1000_release_nvm_generic;
00214                 nvm->ops.update         = e1000_update_nvm_checksum_generic;
00215                 nvm->ops.valid_led_default = e1000_valid_led_default_generic;
00216                 nvm->ops.validate       = e1000_validate_nvm_checksum_generic;
00217                 nvm->ops.write          = e1000_write_nvm_microwire;
00218         }
00219 
00220 out:
00221         return ret_val;
00222 }
00223 
00224 /**
00225  *  e1000_init_mac_params_82541 - Init MAC func ptrs.
00226  *  @hw: pointer to the HW structure
00227  **/
00228 static s32 e1000_init_mac_params_82541(struct e1000_hw *hw)
00229 {
00230         struct e1000_mac_info *mac = &hw->mac;
00231 
00232         DEBUGFUNC("e1000_init_mac_params_82541");
00233 
00234         /* Set media type */
00235         hw->phy.media_type = e1000_media_type_copper;
00236         /* Set mta register count */
00237         mac->mta_reg_count = 128;
00238         /* Set rar entry count */
00239         mac->rar_entry_count = E1000_RAR_ENTRIES;
00240         /* Set if part includes ASF firmware */
00241         mac->asf_firmware_present = true;
00242 
00243         /* Function Pointers */
00244 
00245         /* bus type/speed/width */
00246         mac->ops.get_bus_info = e1000_get_bus_info_pci_generic;
00247         /* function id */
00248         mac->ops.set_lan_id = e1000_set_lan_id_single_port;
00249         /* reset */
00250         mac->ops.reset_hw = e1000_reset_hw_82541;
00251         /* hw initialization */
00252         mac->ops.init_hw = e1000_init_hw_82541;
00253         /* link setup */
00254         mac->ops.setup_link = e1000_setup_link_generic;
00255         /* physical interface link setup */
00256         mac->ops.setup_physical_interface = e1000_setup_copper_link_82541;
00257         /* check for link */
00258         mac->ops.check_for_link = e1000_check_for_link_82541;
00259         /* link info */
00260         mac->ops.get_link_up_info = e1000_get_link_up_info_82541;
00261         /* multicast address update */
00262         mac->ops.update_mc_addr_list = e1000_update_mc_addr_list_generic;
00263         /* writing VFTA */
00264         mac->ops.write_vfta = e1000_write_vfta_generic;
00265         /* clearing VFTA */
00266         mac->ops.clear_vfta = e1000_clear_vfta_generic;
00267         /* setting MTA */
00268         mac->ops.mta_set = e1000_mta_set_generic;
00269         /* ID LED init */
00270         mac->ops.id_led_init = e1000_id_led_init_generic;
00271         /* setup LED */
00272         mac->ops.setup_led = e1000_setup_led_82541;
00273         /* cleanup LED */
00274         mac->ops.cleanup_led = e1000_cleanup_led_82541;
00275         /* turn on/off LED */
00276         mac->ops.led_on = e1000_led_on_generic;
00277         mac->ops.led_off = e1000_led_off_generic;
00278         /* clear hardware counters */
00279         mac->ops.clear_hw_cntrs = e1000_clear_hw_cntrs_82541;
00280 
00281         return E1000_SUCCESS;
00282 }
00283 
00284 /**
00285  *  e1000_init_function_pointers_82541 - Init func ptrs.
00286  *  @hw: pointer to the HW structure
00287  *
00288  *  Called to initialize all function pointers and parameters.
00289  **/
00290 void e1000_init_function_pointers_82541(struct e1000_hw *hw)
00291 {
00292         DEBUGFUNC("e1000_init_function_pointers_82541");
00293 
00294         hw->mac.ops.init_params = e1000_init_mac_params_82541;
00295         hw->nvm.ops.init_params = e1000_init_nvm_params_82541;
00296         hw->phy.ops.init_params = e1000_init_phy_params_82541;
00297 }
00298 
00299 /**
00300  *  e1000_reset_hw_82541 - Reset hardware
00301  *  @hw: pointer to the HW structure
00302  *
00303  *  This resets the hardware into a known state.
00304  **/
00305 static s32 e1000_reset_hw_82541(struct e1000_hw *hw)
00306 {
00307         u32 ledctl, ctrl, icr, manc;
00308 
00309         DEBUGFUNC("e1000_reset_hw_82541");
00310 
00311         DEBUGOUT("Masking off all interrupts\n");
00312         E1000_WRITE_REG(hw, E1000_IMC, 0xFFFFFFFF);
00313 
00314         E1000_WRITE_REG(hw, E1000_RCTL, 0);
00315         E1000_WRITE_REG(hw, E1000_TCTL, E1000_TCTL_PSP);
00316         E1000_WRITE_FLUSH(hw);
00317 
00318         /*
00319          * Delay to allow any outstanding PCI transactions to complete
00320          * before resetting the device.
00321          */
00322         msec_delay(10);
00323 
00324         ctrl = E1000_READ_REG(hw, E1000_CTRL);
00325 
00326         /* Must reset the Phy before resetting the MAC */
00327         if ((hw->mac.type == e1000_82541) || (hw->mac.type == e1000_82547)) {
00328                 E1000_WRITE_REG(hw, E1000_CTRL, (ctrl | E1000_CTRL_PHY_RST));
00329                 msec_delay(5);
00330         }
00331 
00332         DEBUGOUT("Issuing a global reset to 82541/82547 MAC\n");
00333         switch (hw->mac.type) {
00334         case e1000_82541:
00335         case e1000_82541_rev_2:
00336                 /*
00337                  * These controllers can't ack the 64-bit write when
00338                  * issuing the reset, so we use IO-mapping as a
00339                  * workaround to issue the reset.
00340                  */
00341                 E1000_WRITE_REG_IO(hw, E1000_CTRL, ctrl | E1000_CTRL_RST);
00342                 break;
00343         default:
00344                 E1000_WRITE_REG(hw, E1000_CTRL, ctrl | E1000_CTRL_RST);
00345                 break;
00346         }
00347 
00348         /* Wait for NVM reload */
00349         msec_delay(20);
00350 
00351         /* Disable HW ARPs on ASF enabled adapters */
00352         manc = E1000_READ_REG(hw, E1000_MANC);
00353         manc &= ~E1000_MANC_ARP_EN;
00354         E1000_WRITE_REG(hw, E1000_MANC, manc);
00355 
00356         if ((hw->mac.type == e1000_82541) || (hw->mac.type == e1000_82547)) {
00357                 e1000_phy_init_script_82541(hw);
00358 
00359                 /* Configure activity LED after Phy reset */
00360                 ledctl = E1000_READ_REG(hw, E1000_LEDCTL);
00361                 ledctl &= IGP_ACTIVITY_LED_MASK;
00362                 ledctl |= (IGP_ACTIVITY_LED_ENABLE | IGP_LED3_MODE);
00363                 E1000_WRITE_REG(hw, E1000_LEDCTL, ledctl);
00364         }
00365 
00366         /* Once again, mask the interrupts */
00367         DEBUGOUT("Masking off all interrupts\n");
00368         E1000_WRITE_REG(hw, E1000_IMC, 0xFFFFFFFF);
00369 
00370         /* Clear any pending interrupt events. */
00371         icr = E1000_READ_REG(hw, E1000_ICR);
00372 
00373         return E1000_SUCCESS;
00374 }
00375 
00376 /**
00377  *  e1000_init_hw_82541 - Initialize hardware
00378  *  @hw: pointer to the HW structure
00379  *
00380  *  This inits the hardware readying it for operation.
00381  **/
00382 static s32 e1000_init_hw_82541(struct e1000_hw *hw)
00383 {
00384         struct e1000_mac_info *mac = &hw->mac;
00385         struct e1000_dev_spec_82541 *dev_spec = &hw->dev_spec._82541;
00386         u32 i, txdctl;
00387         s32 ret_val;
00388 
00389         DEBUGFUNC("e1000_init_hw_82541");
00390 
00391         /* Initialize identification LED */
00392         ret_val = mac->ops.id_led_init(hw);
00393         if (ret_val) {
00394                 DEBUGOUT("Error initializing identification LED\n");
00395                 /* This is not fatal and we should not stop init due to this */
00396         }
00397 
00398         /* Storing the Speed Power Down  value for later use */
00399         ret_val = hw->phy.ops.read_reg(hw,
00400                                        IGP01E1000_GMII_FIFO,
00401                                        &dev_spec->spd_default);
00402         if (ret_val)
00403                 goto out;
00404 
00405         /* Disabling VLAN filtering */
00406         DEBUGOUT("Initializing the IEEE VLAN\n");
00407         mac->ops.clear_vfta(hw);
00408 
00409         /* Setup the receive address. */
00410         e1000_init_rx_addrs_generic(hw, mac->rar_entry_count);
00411 
00412         /* Zero out the Multicast HASH table */
00413         DEBUGOUT("Zeroing the MTA\n");
00414         for (i = 0; i < mac->mta_reg_count; i++) {
00415                 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
00416                 /*
00417                  * Avoid back to back register writes by adding the register
00418                  * read (flush).  This is to protect against some strange
00419                  * bridge configurations that may issue Memory Write Block
00420                  * (MWB) to our register space.
00421                  */
00422                 E1000_WRITE_FLUSH(hw);
00423         }
00424 
00425         /* Setup link and flow control */
00426         ret_val = mac->ops.setup_link(hw);
00427 
00428         txdctl = E1000_READ_REG(hw, E1000_TXDCTL(0));
00429         txdctl = (txdctl & ~E1000_TXDCTL_WTHRESH) |
00430                  E1000_TXDCTL_FULL_TX_DESC_WB;
00431         E1000_WRITE_REG(hw, E1000_TXDCTL(0), txdctl);
00432 
00433         /*
00434          * Clear all of the statistics registers (clear on read).  It is
00435          * important that we do this after we have tried to establish link
00436          * because the symbol error count will increment wildly if there
00437          * is no link.
00438          */
00439         e1000_clear_hw_cntrs_82541(hw);
00440 
00441 out:
00442         return ret_val;
00443 }
00444 
00445 /**
00446  * e1000_get_link_up_info_82541 - Report speed and duplex
00447  * @hw: pointer to the HW structure
00448  * @speed: pointer to speed buffer
00449  * @duplex: pointer to duplex buffer
00450  *
00451  * Retrieve the current speed and duplex configuration.
00452  **/
00453 static s32 e1000_get_link_up_info_82541(struct e1000_hw *hw, u16 *speed,
00454                                         u16 *duplex)
00455 {
00456         struct e1000_phy_info *phy = &hw->phy;
00457         s32 ret_val;
00458         u16 data;
00459 
00460         DEBUGFUNC("e1000_get_link_up_info_82541");
00461 
00462         ret_val = e1000_get_speed_and_duplex_copper_generic(hw, speed, duplex);
00463         if (ret_val)
00464                 goto out;
00465 
00466         if (!phy->speed_downgraded)
00467                 goto out;
00468 
00469         /*
00470          * IGP01 PHY may advertise full duplex operation after speed
00471          * downgrade even if it is operating at half duplex.
00472          * Here we set the duplex settings to match the duplex in the
00473          * link partner's capabilities.
00474          */
00475         ret_val = phy->ops.read_reg(hw, PHY_AUTONEG_EXP, &data);
00476         if (ret_val)
00477                 goto out;
00478 
00479         if (!(data & NWAY_ER_LP_NWAY_CAPS)) {
00480                 *duplex = HALF_DUPLEX;
00481         } else {
00482                 ret_val = phy->ops.read_reg(hw, PHY_LP_ABILITY, &data);
00483                 if (ret_val)
00484                         goto out;
00485 
00486                 if (*speed == SPEED_100) {
00487                         if (!(data & NWAY_LPAR_100TX_FD_CAPS))
00488                                 *duplex = HALF_DUPLEX;
00489                 } else if (*speed == SPEED_10) {
00490                         if (!(data & NWAY_LPAR_10T_FD_CAPS))
00491                                 *duplex = HALF_DUPLEX;
00492                 }
00493         }
00494 
00495 out:
00496         return ret_val;
00497 }
00498 
00499 /**
00500  *  e1000_phy_hw_reset_82541 - PHY hardware reset
00501  *  @hw: pointer to the HW structure
00502  *
00503  *  Verify the reset block is not blocking us from resetting.  Acquire
00504  *  semaphore (if necessary) and read/set/write the device control reset
00505  *  bit in the PHY.  Wait the appropriate delay time for the device to
00506  *  reset and release the semaphore (if necessary).
00507  **/
00508 static s32 e1000_phy_hw_reset_82541(struct e1000_hw *hw)
00509 {
00510         s32 ret_val;
00511         u32 ledctl;
00512 
00513         DEBUGFUNC("e1000_phy_hw_reset_82541");
00514 
00515         ret_val = e1000_phy_hw_reset_generic(hw);
00516         if (ret_val)
00517                 goto out;
00518 
00519         e1000_phy_init_script_82541(hw);
00520 
00521         if ((hw->mac.type == e1000_82541) || (hw->mac.type == e1000_82547)) {
00522                 /* Configure activity LED after PHY reset */
00523                 ledctl = E1000_READ_REG(hw, E1000_LEDCTL);
00524                 ledctl &= IGP_ACTIVITY_LED_MASK;
00525                 ledctl |= (IGP_ACTIVITY_LED_ENABLE | IGP_LED3_MODE);
00526                 E1000_WRITE_REG(hw, E1000_LEDCTL, ledctl);
00527         }
00528 
00529 out:
00530         return ret_val;
00531 }
00532 
00533 /**
00534  *  e1000_setup_copper_link_82541 - Configure copper link settings
00535  *  @hw: pointer to the HW structure
00536  *
00537  *  Calls the appropriate function to configure the link for auto-neg or forced
00538  *  speed and duplex.  Then we check for link, once link is established calls
00539  *  to configure collision distance and flow control are called.  If link is
00540  *  not established, we return -E1000_ERR_PHY (-2).
00541  **/
00542 static s32 e1000_setup_copper_link_82541(struct e1000_hw *hw)
00543 {
00544         struct e1000_phy_info *phy = &hw->phy;
00545         struct e1000_dev_spec_82541 *dev_spec = &hw->dev_spec._82541;
00546         s32  ret_val;
00547         u32 ctrl, ledctl;
00548 
00549         DEBUGFUNC("e1000_setup_copper_link_82541");
00550 
00551         ctrl = E1000_READ_REG(hw, E1000_CTRL);
00552         ctrl |= E1000_CTRL_SLU;
00553         ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
00554         E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
00555 
00556         hw->phy.reset_disable = false;
00557 
00558         /* Earlier revs of the IGP phy require us to force MDI. */
00559         if (hw->mac.type == e1000_82541 || hw->mac.type == e1000_82547) {
00560                 dev_spec->dsp_config = e1000_dsp_config_disabled;
00561                 phy->mdix = 1;
00562         } else {
00563                 dev_spec->dsp_config = e1000_dsp_config_enabled;
00564         }
00565 
00566         ret_val = e1000_copper_link_setup_igp(hw);
00567         if (ret_val)
00568                 goto out;
00569 
00570         if (hw->mac.autoneg) {
00571                 if (dev_spec->ffe_config == e1000_ffe_config_active)
00572                         dev_spec->ffe_config = e1000_ffe_config_enabled;
00573         }
00574 
00575         /* Configure activity LED after Phy reset */
00576         ledctl = E1000_READ_REG(hw, E1000_LEDCTL);
00577         ledctl &= IGP_ACTIVITY_LED_MASK;
00578         ledctl |= (IGP_ACTIVITY_LED_ENABLE | IGP_LED3_MODE);
00579         E1000_WRITE_REG(hw, E1000_LEDCTL, ledctl);
00580 
00581         ret_val = e1000_setup_copper_link_generic(hw);
00582 
00583 out:
00584         return ret_val;
00585 }
00586 
00587 /**
00588  *  e1000_check_for_link_82541 - Check/Store link connection
00589  *  @hw: pointer to the HW structure
00590  *
00591  *  This checks the link condition of the adapter and stores the
00592  *  results in the hw->mac structure.
00593  **/
00594 static s32 e1000_check_for_link_82541(struct e1000_hw *hw)
00595 {
00596         struct e1000_mac_info *mac = &hw->mac;
00597         s32 ret_val;
00598         bool link;
00599 
00600         DEBUGFUNC("e1000_check_for_link_82541");
00601 
00602         /*
00603          * We only want to go out to the PHY registers to see if Auto-Neg
00604          * has completed and/or if our link status has changed.  The
00605          * get_link_status flag is set upon receiving a Link Status
00606          * Change or Rx Sequence Error interrupt.
00607          */
00608         if (!mac->get_link_status) {
00609                 ret_val = E1000_SUCCESS;
00610                 goto out;
00611         }
00612 
00613         /*
00614          * First we want to see if the MII Status Register reports
00615          * link.  If so, then we want to get the current speed/duplex
00616          * of the PHY.
00617          */
00618         ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link);
00619         if (ret_val)
00620                 goto out;
00621 
00622         if (!link) {
00623                 ret_val = -E1000_ERR_CONFIG;
00624 #if 0
00625                 ret_val = e1000_config_dsp_after_link_change_82541(hw, false);
00626 #endif
00627                 goto out; /* No link detected */
00628         }
00629 
00630         mac->get_link_status = false;
00631 
00632         /*
00633          * Check if there was DownShift, must be checked
00634          * immediately after link-up
00635          */
00636         e1000_check_downshift_generic(hw);
00637 
00638         /*
00639          * If we are forcing speed/duplex, then we simply return since
00640          * we have already determined whether we have link or not.
00641          */
00642         if (!mac->autoneg) {
00643                 ret_val = -E1000_ERR_CONFIG;
00644                 goto out;
00645         }
00646 
00647 #if 0
00648         ret_val = e1000_config_dsp_after_link_change_82541(hw, true);
00649 #endif
00650 
00651         /*
00652          * Auto-Neg is enabled.  Auto Speed Detection takes care
00653          * of MAC speed/duplex configuration.  So we only need to
00654          * configure Collision Distance in the MAC.
00655          */
00656         e1000_config_collision_dist_generic(hw);
00657 
00658         /*
00659          * Configure Flow Control now that Auto-Neg has completed.
00660          * First, we need to restore the desired flow control
00661          * settings because we may have had to re-autoneg with a
00662          * different link partner.
00663          */
00664         ret_val = e1000_config_fc_after_link_up_generic(hw);
00665         if (ret_val) {
00666                 DEBUGOUT("Error configuring flow control\n");
00667         }
00668 
00669 out:
00670         return ret_val;
00671 }
00672 
00673 #if 0
00674 /**
00675  *  e1000_config_dsp_after_link_change_82541 - Config DSP after link
00676  *  @hw: pointer to the HW structure
00677  *  @link_up: boolean flag for link up status
00678  *
00679  *  Return E1000_ERR_PHY when failing to read/write the PHY, else E1000_SUCCESS
00680  *  at any other case.
00681  *
00682  *  82541_rev_2 & 82547_rev_2 have the capability to configure the DSP when a
00683  *  gigabit link is achieved to improve link quality.
00684  **/
00685 static s32 e1000_config_dsp_after_link_change_82541(struct e1000_hw *hw,
00686                                                     bool link_up)
00687 {
00688         struct e1000_phy_info *phy = &hw->phy;
00689         struct e1000_dev_spec_82541 *dev_spec = &hw->dev_spec._82541;
00690         s32 ret_val;
00691         u32 idle_errs = 0;
00692         u16 phy_data, phy_saved_data, speed, duplex, i;
00693         u16 ffe_idle_err_timeout = FFE_IDLE_ERR_COUNT_TIMEOUT_20;
00694         u16 dsp_reg_array[IGP01E1000_PHY_CHANNEL_NUM] =
00695                                                    {IGP01E1000_PHY_AGC_PARAM_A,
00696                                                     IGP01E1000_PHY_AGC_PARAM_B,
00697                                                     IGP01E1000_PHY_AGC_PARAM_C,
00698                                                     IGP01E1000_PHY_AGC_PARAM_D};
00699 
00700         DEBUGFUNC("e1000_config_dsp_after_link_change_82541");
00701 
00702         if (link_up) {
00703                 ret_val = hw->mac.ops.get_link_up_info(hw, &speed, &duplex);
00704                 if (ret_val) {
00705                         DEBUGOUT("Error getting link speed and duplex\n");
00706                         goto out;
00707                 }
00708 
00709                 if (speed != SPEED_1000) {
00710                         ret_val = E1000_SUCCESS;
00711                         goto out;
00712                 }
00713 
00714 #if 0
00715                 ret_val = phy->ops.get_cable_length(hw);
00716 #endif
00717                 ret_val = -E1000_ERR_CONFIG;
00718                 if (ret_val)
00719                         goto out;
00720 
00721                 if ((dev_spec->dsp_config == e1000_dsp_config_enabled) &&
00722                     phy->min_cable_length >= 50) {
00723 
00724                         for (i = 0; i < IGP01E1000_PHY_CHANNEL_NUM; i++) {
00725                                 ret_val = phy->ops.read_reg(hw,
00726                                                             dsp_reg_array[i],
00727                                                             &phy_data);
00728                                 if (ret_val)
00729                                         goto out;
00730 
00731                                 phy_data &= ~IGP01E1000_PHY_EDAC_MU_INDEX;
00732 
00733                                 ret_val = phy->ops.write_reg(hw,
00734                                                              dsp_reg_array[i],
00735                                                              phy_data);
00736                                 if (ret_val)
00737                                         goto out;
00738                         }
00739                         dev_spec->dsp_config = e1000_dsp_config_activated;
00740                 }
00741 
00742                 if ((dev_spec->ffe_config != e1000_ffe_config_enabled) ||
00743                     (phy->min_cable_length >= 50)) {
00744                         ret_val = E1000_SUCCESS;
00745                         goto out;
00746                 }
00747 
00748                 /* clear previous idle error counts */
00749                 ret_val = phy->ops.read_reg(hw, PHY_1000T_STATUS, &phy_data);
00750                 if (ret_val)
00751                         goto out;
00752 
00753                 for (i = 0; i < ffe_idle_err_timeout; i++) {
00754                         usec_delay(1000);
00755                         ret_val = phy->ops.read_reg(hw,
00756                                                     PHY_1000T_STATUS,
00757                                                     &phy_data);
00758                         if (ret_val)
00759                                 goto out;
00760 
00761                         idle_errs += (phy_data & SR_1000T_IDLE_ERROR_CNT);
00762                         if (idle_errs > SR_1000T_PHY_EXCESSIVE_IDLE_ERR_COUNT) {
00763                                 dev_spec->ffe_config = e1000_ffe_config_active;
00764 
00765                                 ret_val = phy->ops.write_reg(hw,
00766                                                   IGP01E1000_PHY_DSP_FFE,
00767                                                   IGP01E1000_PHY_DSP_FFE_CM_CP);
00768                                 if (ret_val)
00769                                         goto out;
00770                                 break;
00771                         }
00772 
00773                         if (idle_errs)
00774                                 ffe_idle_err_timeout =
00775                                                  FFE_IDLE_ERR_COUNT_TIMEOUT_100;
00776                 }
00777         } else {
00778                 if (dev_spec->dsp_config == e1000_dsp_config_activated) {
00779                         /*
00780                          * Save off the current value of register 0x2F5B
00781                          * to be restored at the end of the routines.
00782                          */
00783                         ret_val = phy->ops.read_reg(hw,
00784                                                     0x2F5B,
00785                                                     &phy_saved_data);
00786                         if (ret_val)
00787                                 goto out;
00788 
00789                         /* Disable the PHY transmitter */
00790                         ret_val = phy->ops.write_reg(hw, 0x2F5B, 0x0003);
00791                         if (ret_val)
00792                                 goto out;
00793 
00794                         msec_delay_irq(20);
00795 
00796                         ret_val = phy->ops.write_reg(hw,
00797                                                      0x0000,
00798                                                      IGP01E1000_IEEE_FORCE_GIG);
00799                         if (ret_val)
00800                                 goto out;
00801                         for (i = 0; i < IGP01E1000_PHY_CHANNEL_NUM; i++) {
00802                                 ret_val = phy->ops.read_reg(hw,
00803                                                             dsp_reg_array[i],
00804                                                             &phy_data);
00805                                 if (ret_val)
00806                                         goto out;
00807 
00808                                 phy_data &= ~IGP01E1000_PHY_EDAC_MU_INDEX;
00809                                 phy_data |= IGP01E1000_PHY_EDAC_SIGN_EXT_9_BITS;
00810 
00811                                 ret_val = phy->ops.write_reg(hw,
00812                                                              dsp_reg_array[i],
00813                                                              phy_data);
00814                                 if (ret_val)
00815                                         goto out;
00816                         }
00817 
00818                         ret_val = phy->ops.write_reg(hw,
00819                                                0x0000,
00820                                                IGP01E1000_IEEE_RESTART_AUTONEG);
00821                         if (ret_val)
00822                                 goto out;
00823 
00824                         msec_delay_irq(20);
00825 
00826                         /* Now enable the transmitter */
00827                         ret_val = phy->ops.write_reg(hw,
00828                                                      0x2F5B,
00829                                                      phy_saved_data);
00830                         if (ret_val)
00831                                 goto out;
00832 
00833                         dev_spec->dsp_config = e1000_dsp_config_enabled;
00834                 }
00835 
00836                 if (dev_spec->ffe_config != e1000_ffe_config_active) {
00837                         ret_val = E1000_SUCCESS;
00838                         goto out;
00839                 }
00840 
00841                 /*
00842                  * Save off the current value of register 0x2F5B
00843                  * to be restored at the end of the routines.
00844                  */
00845                 ret_val = phy->ops.read_reg(hw, 0x2F5B, &phy_saved_data);
00846                 if (ret_val)
00847                         goto out;
00848 
00849                 /* Disable the PHY transmitter */
00850                 ret_val = phy->ops.write_reg(hw, 0x2F5B, 0x0003);
00851                 if (ret_val)
00852                         goto out;
00853 
00854                 msec_delay_irq(20);
00855 
00856                 ret_val = phy->ops.write_reg(hw,
00857                                              0x0000,
00858                                              IGP01E1000_IEEE_FORCE_GIG);
00859                 if (ret_val)
00860                         goto out;
00861 
00862                 ret_val = phy->ops.write_reg(hw,
00863                                              IGP01E1000_PHY_DSP_FFE,
00864                                              IGP01E1000_PHY_DSP_FFE_DEFAULT);
00865                 if (ret_val)
00866                         goto out;
00867 
00868                 ret_val = phy->ops.write_reg(hw,
00869                                              0x0000,
00870                                              IGP01E1000_IEEE_RESTART_AUTONEG);
00871                 if (ret_val)
00872                         goto out;
00873 
00874                 msec_delay_irq(20);
00875 
00876                 /* Now enable the transmitter */
00877                 ret_val = phy->ops.write_reg(hw, 0x2F5B, phy_saved_data);
00878 
00879                 if (ret_val)
00880                         goto out;
00881 
00882                 dev_spec->ffe_config = e1000_ffe_config_enabled;
00883         }
00884 
00885 out:
00886         return ret_val;
00887 }
00888 #endif
00889 
00890 #if 0
00891 /**
00892  *  e1000_get_cable_length_igp_82541 - Determine cable length for igp PHY
00893  *  @hw: pointer to the HW structure
00894  *
00895  *  The automatic gain control (agc) normalizes the amplitude of the
00896  *  received signal, adjusting for the attenuation produced by the
00897  *  cable.  By reading the AGC registers, which represent the
00898  *  combination of coarse and fine gain value, the value can be put
00899  *  into a lookup table to obtain the approximate cable length
00900  *  for each channel.
00901  **/
00902 static s32 e1000_get_cable_length_igp_82541(struct e1000_hw *hw)
00903 {
00904         struct e1000_phy_info *phy = &hw->phy;
00905         s32 ret_val = E1000_SUCCESS;
00906         u16 i, data;
00907         u16 cur_agc_value, agc_value = 0;
00908         u16 min_agc_value = IGP01E1000_AGC_LENGTH_TABLE_SIZE;
00909         u16 agc_reg_array[IGP01E1000_PHY_CHANNEL_NUM] =
00910                                                          {IGP01E1000_PHY_AGC_A,
00911                                                           IGP01E1000_PHY_AGC_B,
00912                                                           IGP01E1000_PHY_AGC_C,
00913                                                           IGP01E1000_PHY_AGC_D};
00914 
00915         DEBUGFUNC("e1000_get_cable_length_igp_82541");
00916 
00917         /* Read the AGC registers for all channels */
00918         for (i = 0; i < IGP01E1000_PHY_CHANNEL_NUM; i++) {
00919                 ret_val = phy->ops.read_reg(hw, agc_reg_array[i], &data);
00920                 if (ret_val)
00921                         goto out;
00922 
00923                 cur_agc_value = data >> IGP01E1000_AGC_LENGTH_SHIFT;
00924 
00925                 /* Bounds checking */
00926                 if ((cur_agc_value >= IGP01E1000_AGC_LENGTH_TABLE_SIZE - 1) ||
00927                     (cur_agc_value == 0)) {
00928                         ret_val = -E1000_ERR_PHY;
00929                         goto out;
00930                 }
00931 
00932                 agc_value += cur_agc_value;
00933 
00934                 if (min_agc_value > cur_agc_value)
00935                         min_agc_value = cur_agc_value;
00936         }
00937 
00938         /* Remove the minimal AGC result for length < 50m */
00939         if (agc_value < IGP01E1000_PHY_CHANNEL_NUM * 50) {
00940                 agc_value -= min_agc_value;
00941                 /* Average the three remaining channels for the length. */
00942                 agc_value /= (IGP01E1000_PHY_CHANNEL_NUM - 1);
00943         } else {
00944                 /* Average the channels for the length. */
00945                 agc_value /= IGP01E1000_PHY_CHANNEL_NUM;
00946         }
00947 
00948         phy->min_cable_length = (e1000_igp_cable_length_table[agc_value] >
00949                                  IGP01E1000_AGC_RANGE)
00950                                 ? (e1000_igp_cable_length_table[agc_value] -
00951                                    IGP01E1000_AGC_RANGE)
00952                                 : 0;
00953         phy->max_cable_length = e1000_igp_cable_length_table[agc_value] +
00954                                 IGP01E1000_AGC_RANGE;
00955 
00956         phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2;
00957 
00958 out:
00959         return ret_val;
00960 }
00961 #endif
00962 
00963 /**
00964  *  e1000_set_d3_lplu_state_82541 - Sets low power link up state for D3
00965  *  @hw: pointer to the HW structure
00966  *  @active: boolean used to enable/disable lplu
00967  *
00968  *  Success returns 0, Failure returns 1
00969  *
00970  *  The low power link up (lplu) state is set to the power management level D3
00971  *  and SmartSpeed is disabled when active is true, else clear lplu for D3
00972  *  and enable Smartspeed.  LPLU and Smartspeed are mutually exclusive.  LPLU
00973  *  is used during Dx states where the power conservation is most important.
00974  *  During driver activity, SmartSpeed should be enabled so performance is
00975  *  maintained.
00976  **/
00977 static s32 e1000_set_d3_lplu_state_82541(struct e1000_hw *hw, bool active)
00978 {
00979         struct e1000_phy_info *phy = &hw->phy;
00980         s32 ret_val;
00981         u16 data;
00982 
00983         DEBUGFUNC("e1000_set_d3_lplu_state_82541");
00984 
00985         switch (hw->mac.type) {
00986         case e1000_82541_rev_2:
00987         case e1000_82547_rev_2:
00988                 break;
00989         default:
00990                 ret_val = e1000_set_d3_lplu_state_generic(hw, active);
00991                 goto out;
00992                 break;
00993         }
00994 
00995         ret_val = phy->ops.read_reg(hw, IGP01E1000_GMII_FIFO, &data);
00996         if (ret_val)
00997                 goto out;
00998 
00999         if (!active) {
01000                 data &= ~IGP01E1000_GMII_FLEX_SPD;
01001                 ret_val = phy->ops.write_reg(hw, IGP01E1000_GMII_FIFO, data);
01002                 if (ret_val)
01003                         goto out;
01004 
01005                 /*
01006                  * LPLU and SmartSpeed are mutually exclusive.  LPLU is used
01007                  * during Dx states where the power conservation is most
01008                  * important.  During driver activity we should enable
01009                  * SmartSpeed, so performance is maintained.
01010                  */
01011                 if (phy->smart_speed == e1000_smart_speed_on) {
01012                         ret_val = phy->ops.read_reg(hw,
01013                                                     IGP01E1000_PHY_PORT_CONFIG,
01014                                                     &data);
01015                         if (ret_val)
01016                                 goto out;
01017 
01018                         data |= IGP01E1000_PSCFR_SMART_SPEED;
01019                         ret_val = phy->ops.write_reg(hw,
01020                                                      IGP01E1000_PHY_PORT_CONFIG,
01021                                                      data);
01022                         if (ret_val)
01023                                 goto out;
01024                 } else if (phy->smart_speed == e1000_smart_speed_off) {
01025                         ret_val = phy->ops.read_reg(hw,
01026                                                     IGP01E1000_PHY_PORT_CONFIG,
01027                                                     &data);
01028                         if (ret_val)
01029                                 goto out;
01030 
01031                         data &= ~IGP01E1000_PSCFR_SMART_SPEED;
01032                         ret_val = phy->ops.write_reg(hw,
01033                                                      IGP01E1000_PHY_PORT_CONFIG,
01034                                                      data);
01035                         if (ret_val)
01036                                 goto out;
01037                 }
01038         } else if ((phy->autoneg_advertised == E1000_ALL_SPEED_DUPLEX) ||
01039                    (phy->autoneg_advertised == E1000_ALL_NOT_GIG) ||
01040                    (phy->autoneg_advertised == E1000_ALL_10_SPEED)) {
01041                 data |= IGP01E1000_GMII_FLEX_SPD;
01042                 ret_val = phy->ops.write_reg(hw, IGP01E1000_GMII_FIFO, data);
01043                 if (ret_val)
01044                         goto out;
01045 
01046                 /* When LPLU is enabled, we should disable SmartSpeed */
01047                 ret_val = phy->ops.read_reg(hw,
01048                                             IGP01E1000_PHY_PORT_CONFIG,
01049                                             &data);
01050                 if (ret_val)
01051                         goto out;
01052 
01053                 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
01054                 ret_val = phy->ops.write_reg(hw,
01055                                              IGP01E1000_PHY_PORT_CONFIG,
01056                                              data);
01057         }
01058 
01059 out:
01060         return ret_val;
01061 }
01062 
01063 /**
01064  *  e1000_setup_led_82541 - Configures SW controllable LED
01065  *  @hw: pointer to the HW structure
01066  *
01067  *  This prepares the SW controllable LED for use and saves the current state
01068  *  of the LED so it can be later restored.
01069  **/
01070 static s32 e1000_setup_led_82541(struct e1000_hw *hw __unused)
01071 {
01072 #if 0
01073         struct e1000_dev_spec_82541 *dev_spec = &hw->dev_spec._82541;
01074         s32 ret_val;
01075 
01076         DEBUGFUNC("e1000_setup_led_82541");
01077 
01078         ret_val = hw->phy.ops.read_reg(hw,
01079                                        IGP01E1000_GMII_FIFO,
01080                                        &dev_spec->spd_default);
01081         if (ret_val)
01082                 goto out;
01083 
01084         ret_val = hw->phy.ops.write_reg(hw,
01085                                         IGP01E1000_GMII_FIFO,
01086                                         (u16)(dev_spec->spd_default &
01087                                                 ~IGP01E1000_GMII_SPD));
01088         if (ret_val)
01089                 goto out;
01090 
01091         E1000_WRITE_REG(hw, E1000_LEDCTL, hw->mac.ledctl_mode1);
01092 
01093 out:
01094         return ret_val;
01095 #endif
01096         return 0;
01097 }
01098 
01099 /**
01100  *  e1000_cleanup_led_82541 - Set LED config to default operation
01101  *  @hw: pointer to the HW structure
01102  *
01103  *  Remove the current LED configuration and set the LED configuration
01104  *  to the default value, saved from the EEPROM.
01105  **/
01106 static s32 e1000_cleanup_led_82541(struct e1000_hw *hw __unused)
01107 {
01108 #if 0
01109         struct e1000_dev_spec_82541 *dev_spec = &hw->dev_spec._82541;
01110         s32 ret_val;
01111 
01112         DEBUGFUNC("e1000_cleanup_led_82541");
01113 
01114         ret_val = hw->phy.ops.write_reg(hw,
01115                                         IGP01E1000_GMII_FIFO,
01116                                         dev_spec->spd_default);
01117         if (ret_val)
01118                 goto out;
01119 
01120         E1000_WRITE_REG(hw, E1000_LEDCTL, hw->mac.ledctl_default);
01121 
01122 out:
01123         return ret_val;
01124 #endif
01125         return 0;
01126 }
01127 
01128 /**
01129  *  e1000_phy_init_script_82541 - Initialize GbE PHY
01130  *  @hw: pointer to the HW structure
01131  *
01132  *  Initializes the IGP PHY.
01133  **/
01134 static s32 e1000_phy_init_script_82541(struct e1000_hw *hw)
01135 {
01136         struct e1000_dev_spec_82541 *dev_spec = &hw->dev_spec._82541;
01137         u32 ret_val;
01138         u16 phy_saved_data;
01139 
01140         DEBUGFUNC("e1000_phy_init_script_82541");
01141 
01142         if (!dev_spec->phy_init_script) {
01143                 ret_val = E1000_SUCCESS;
01144                 goto out;
01145         }
01146 
01147         /* Delay after phy reset to enable NVM configuration to load */
01148         msec_delay(20);
01149 
01150         /*
01151          * Save off the current value of register 0x2F5B to be restored at
01152          * the end of this routine.
01153          */
01154         ret_val = hw->phy.ops.read_reg(hw, 0x2F5B, &phy_saved_data);
01155 
01156         /* Disabled the PHY transmitter */
01157         hw->phy.ops.write_reg(hw, 0x2F5B, 0x0003);
01158 
01159         msec_delay(20);
01160 
01161         hw->phy.ops.write_reg(hw, 0x0000, 0x0140);
01162 
01163         msec_delay(5);
01164 
01165         switch (hw->mac.type) {
01166         case e1000_82541:
01167         case e1000_82547:
01168                 hw->phy.ops.write_reg(hw, 0x1F95, 0x0001);
01169 
01170                 hw->phy.ops.write_reg(hw, 0x1F71, 0xBD21);
01171 
01172                 hw->phy.ops.write_reg(hw, 0x1F79, 0x0018);
01173 
01174                 hw->phy.ops.write_reg(hw, 0x1F30, 0x1600);
01175 
01176                 hw->phy.ops.write_reg(hw, 0x1F31, 0x0014);
01177 
01178                 hw->phy.ops.write_reg(hw, 0x1F32, 0x161C);
01179 
01180                 hw->phy.ops.write_reg(hw, 0x1F94, 0x0003);
01181 
01182                 hw->phy.ops.write_reg(hw, 0x1F96, 0x003F);
01183 
01184                 hw->phy.ops.write_reg(hw, 0x2010, 0x0008);
01185                 break;
01186         case e1000_82541_rev_2:
01187         case e1000_82547_rev_2:
01188                 hw->phy.ops.write_reg(hw, 0x1F73, 0x0099);
01189                 break;
01190         default:
01191                 break;
01192         }
01193 
01194         hw->phy.ops.write_reg(hw, 0x0000, 0x3300);
01195 
01196         msec_delay(20);
01197 
01198         /* Now enable the transmitter */
01199         hw->phy.ops.write_reg(hw, 0x2F5B, phy_saved_data);
01200 
01201         if (hw->mac.type == e1000_82547) {
01202                 u16 fused, fine, coarse;
01203 
01204                 /* Move to analog registers page */
01205                 hw->phy.ops.read_reg(hw,
01206                                   IGP01E1000_ANALOG_SPARE_FUSE_STATUS,
01207                                   &fused);
01208 
01209                 if (!(fused & IGP01E1000_ANALOG_SPARE_FUSE_ENABLED)) {
01210                         hw->phy.ops.read_reg(hw,
01211                                           IGP01E1000_ANALOG_FUSE_STATUS,
01212                                           &fused);
01213 
01214                         fine = fused & IGP01E1000_ANALOG_FUSE_FINE_MASK;
01215                         coarse = fused & IGP01E1000_ANALOG_FUSE_COARSE_MASK;
01216 
01217                         if (coarse > IGP01E1000_ANALOG_FUSE_COARSE_THRESH) {
01218                                 coarse -= IGP01E1000_ANALOG_FUSE_COARSE_10;
01219                                 fine -= IGP01E1000_ANALOG_FUSE_FINE_1;
01220                         } else if (coarse ==
01221                                    IGP01E1000_ANALOG_FUSE_COARSE_THRESH)
01222                                 fine -= IGP01E1000_ANALOG_FUSE_FINE_10;
01223 
01224                         fused = (fused & IGP01E1000_ANALOG_FUSE_POLY_MASK) |
01225                                 (fine & IGP01E1000_ANALOG_FUSE_FINE_MASK) |
01226                                 (coarse & IGP01E1000_ANALOG_FUSE_COARSE_MASK);
01227 
01228                         hw->phy.ops.write_reg(hw,
01229                                            IGP01E1000_ANALOG_FUSE_CONTROL,
01230                                            fused);
01231                         hw->phy.ops.write_reg(hw,
01232                                       IGP01E1000_ANALOG_FUSE_BYPASS,
01233                                       IGP01E1000_ANALOG_FUSE_ENABLE_SW_CONTROL);
01234                 }
01235         }
01236 
01237 out:
01238         return ret_val;
01239 }
01240 
01241 /**
01242  * e1000_power_down_phy_copper_82541 - Remove link in case of PHY power down
01243  * @hw: pointer to the HW structure
01244  *
01245  * In the case of a PHY power down to save power, or to turn off link during a
01246  * driver unload, or wake on lan is not enabled, remove the link.
01247  **/
01248 static void e1000_power_down_phy_copper_82541(struct e1000_hw *hw)
01249 {
01250         /* If the management interface is not enabled, then power down */
01251         if (!(E1000_READ_REG(hw, E1000_MANC) & E1000_MANC_SMBUS_EN))
01252                 e1000_power_down_phy_copper(hw);
01253 
01254         return;
01255 }
01256 
01257 /**
01258  *  e1000_clear_hw_cntrs_82541 - Clear device specific hardware counters
01259  *  @hw: pointer to the HW structure
01260  *
01261  *  Clears the hardware counters by reading the counter registers.
01262  **/
01263 static void e1000_clear_hw_cntrs_82541(struct e1000_hw *hw)
01264 {
01265         DEBUGFUNC("e1000_clear_hw_cntrs_82541");
01266 
01267         e1000_clear_hw_cntrs_base_generic(hw);
01268 
01269 #if 0
01270         E1000_READ_REG(hw, E1000_PRC64);
01271         E1000_READ_REG(hw, E1000_PRC127);
01272         E1000_READ_REG(hw, E1000_PRC255);
01273         E1000_READ_REG(hw, E1000_PRC511);
01274         E1000_READ_REG(hw, E1000_PRC1023);
01275         E1000_READ_REG(hw, E1000_PRC1522);
01276         E1000_READ_REG(hw, E1000_PTC64);
01277         E1000_READ_REG(hw, E1000_PTC127);
01278         E1000_READ_REG(hw, E1000_PTC255);
01279         E1000_READ_REG(hw, E1000_PTC511);
01280         E1000_READ_REG(hw, E1000_PTC1023);
01281         E1000_READ_REG(hw, E1000_PTC1522);
01282 
01283         E1000_READ_REG(hw, E1000_ALGNERRC);
01284         E1000_READ_REG(hw, E1000_RXERRC);
01285         E1000_READ_REG(hw, E1000_TNCRS);
01286         E1000_READ_REG(hw, E1000_CEXTERR);
01287         E1000_READ_REG(hw, E1000_TSCTC);
01288         E1000_READ_REG(hw, E1000_TSCTFC);
01289 
01290         E1000_READ_REG(hw, E1000_MGTPRC);
01291         E1000_READ_REG(hw, E1000_MGTPDC);
01292         E1000_READ_REG(hw, E1000_MGTPTC);
01293 #endif
01294 }
01295 
01296 static struct pci_device_id e1000_82541_nics[] = {
01297      PCI_ROM(0x8086, 0x1013, "E1000_DEV_ID_82541EI", "E1000_DEV_ID_82541EI", e1000_82541),
01298      PCI_ROM(0x8086, 0x1014, "E1000_DEV_ID_82541ER_LOM", "E1000_DEV_ID_82541ER_LOM", e1000_82541),
01299      PCI_ROM(0x8086, 0x1018, "E1000_DEV_ID_82541EI_MOBILE", "E1000_DEV_ID_82541EI_MOBILE", e1000_82541),
01300      PCI_ROM(0x8086, 0x1019, "E1000_DEV_ID_82547EI", "E1000_DEV_ID_82547EI", e1000_82547),
01301      PCI_ROM(0x8086, 0x101A, "E1000_DEV_ID_82547EI_MOBILE", "E1000_DEV_ID_82547EI_MOBILE", e1000_82547),
01302      PCI_ROM(0x8086, 0x1075, "E1000_DEV_ID_82547GI", "E1000_DEV_ID_82547GI", e1000_82547_rev_2),
01303      PCI_ROM(0x8086, 0x1076, "E1000_DEV_ID_82541GI", "E1000_DEV_ID_82541GI", e1000_82541_rev_2),
01304      PCI_ROM(0x8086, 0x1077, "E1000_DEV_ID_82541GI_MOBILE", "E1000_DEV_ID_82541GI_MOBILE", e1000_82541_rev_2),
01305      PCI_ROM(0x8086, 0x1078, "E1000_DEV_ID_82541ER", "E1000_DEV_ID_82541ER", e1000_82541_rev_2),
01306      PCI_ROM(0x8086, 0x107C, "E1000_DEV_ID_82541GI_LF", "E1000_DEV_ID_82541GI_LF", e1000_82541_rev_2),
01307 };
01308 
01309 struct pci_driver e1000_82541_driver __pci_driver = {
01310         .ids = e1000_82541_nics,
01311         .id_count = (sizeof (e1000_82541_nics) / sizeof (e1000_82541_nics[0])),
01312         .probe = e1000_probe,
01313         .remove = e1000_remove,
01314 };

Generated on Tue Apr 6 20:00:57 2010 for gPXE by  doxygen 1.5.7.1