e1000_82540.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  * 82540EM Gigabit Ethernet Controller
00033  * 82540EP Gigabit Ethernet Controller
00034  * 82545EM Gigabit Ethernet Controller (Copper)
00035  * 82545EM Gigabit Ethernet Controller (Fiber)
00036  * 82545GM Gigabit Ethernet Controller
00037  * 82546EB Gigabit Ethernet Controller (Copper)
00038  * 82546EB Gigabit Ethernet Controller (Fiber)
00039  * 82546GB Gigabit Ethernet Controller
00040  */
00041 
00042 #include "e1000_api.h"
00043 
00044 static s32  e1000_init_phy_params_82540(struct e1000_hw *hw);
00045 static s32  e1000_init_nvm_params_82540(struct e1000_hw *hw);
00046 static s32  e1000_init_mac_params_82540(struct e1000_hw *hw);
00047 static s32  e1000_adjust_serdes_amplitude_82540(struct e1000_hw *hw);
00048 static void e1000_clear_hw_cntrs_82540(struct e1000_hw *hw);
00049 static s32  e1000_init_hw_82540(struct e1000_hw *hw);
00050 static s32  e1000_reset_hw_82540(struct e1000_hw *hw);
00051 static s32  e1000_set_phy_mode_82540(struct e1000_hw *hw);
00052 static s32  e1000_set_vco_speed_82540(struct e1000_hw *hw);
00053 static s32  e1000_setup_copper_link_82540(struct e1000_hw *hw);
00054 static s32  e1000_setup_fiber_serdes_link_82540(struct e1000_hw *hw);
00055 static void e1000_power_down_phy_copper_82540(struct e1000_hw *hw);
00056 static s32  e1000_read_mac_addr_82540(struct e1000_hw *hw);
00057 
00058 /**
00059  * e1000_init_phy_params_82540 - Init PHY func ptrs.
00060  * @hw: pointer to the HW structure
00061  **/
00062 static s32 e1000_init_phy_params_82540(struct e1000_hw *hw)
00063 {
00064         struct e1000_phy_info *phy = &hw->phy;
00065         s32 ret_val = E1000_SUCCESS;
00066 
00067         phy->addr                      = 1;
00068         phy->autoneg_mask              = AUTONEG_ADVERTISE_SPEED_DEFAULT;
00069         phy->reset_delay_us            = 10000;
00070         phy->type                      = e1000_phy_m88;
00071 
00072         /* Function Pointers */
00073         phy->ops.check_polarity        = e1000_check_polarity_m88;
00074         phy->ops.commit                = e1000_phy_sw_reset_generic;
00075 #if 0
00076         phy->ops.force_speed_duplex    = e1000_phy_force_speed_duplex_m88;
00077 #endif
00078 #if 0
00079         phy->ops.get_cable_length      = e1000_get_cable_length_m88;
00080 #endif
00081         phy->ops.get_cfg_done          = e1000_get_cfg_done_generic;
00082         phy->ops.read_reg              = e1000_read_phy_reg_m88;
00083         phy->ops.reset                 = e1000_phy_hw_reset_generic;
00084         phy->ops.write_reg             = e1000_write_phy_reg_m88;
00085         phy->ops.get_info              = e1000_get_phy_info_m88;
00086         phy->ops.power_up              = e1000_power_up_phy_copper;
00087         phy->ops.power_down            = e1000_power_down_phy_copper_82540;
00088 
00089         ret_val = e1000_get_phy_id(hw);
00090         if (ret_val)
00091                 goto out;
00092 
00093         /* Verify phy id */
00094         switch (hw->mac.type) {
00095         case e1000_82540:
00096         case e1000_82545:
00097         case e1000_82545_rev_3:
00098         case e1000_82546:
00099         case e1000_82546_rev_3:
00100                 if (phy->id == M88E1011_I_PHY_ID)
00101                         break;
00102                 /* Fall Through */
00103         default:
00104                 ret_val = -E1000_ERR_PHY;
00105                 goto out;
00106                 break;
00107         }
00108 
00109 out:
00110         return ret_val;
00111 }
00112 
00113 /**
00114  * e1000_init_nvm_params_82540 - Init NVM func ptrs.
00115  * @hw: pointer to the HW structure
00116  **/
00117 static s32 e1000_init_nvm_params_82540(struct e1000_hw *hw)
00118 {
00119         struct e1000_nvm_info *nvm = &hw->nvm;
00120         u32 eecd = E1000_READ_REG(hw, E1000_EECD);
00121 
00122         DEBUGFUNC("e1000_init_nvm_params_82540");
00123 
00124         nvm->type               = e1000_nvm_eeprom_microwire;
00125         nvm->delay_usec         = 50;
00126         nvm->opcode_bits        = 3;
00127         switch (nvm->override) {
00128         case e1000_nvm_override_microwire_large:
00129                 nvm->address_bits       = 8;
00130                 nvm->word_size          = 256;
00131                 break;
00132         case e1000_nvm_override_microwire_small:
00133                 nvm->address_bits       = 6;
00134                 nvm->word_size          = 64;
00135                 break;
00136         default:
00137                 nvm->address_bits       = eecd & E1000_EECD_SIZE ? 8 : 6;
00138                 nvm->word_size          = eecd & E1000_EECD_SIZE ? 256 : 64;
00139                 break;
00140         }
00141 
00142         /* Function Pointers */
00143         nvm->ops.acquire            = e1000_acquire_nvm_generic;
00144         nvm->ops.read               = e1000_read_nvm_microwire;
00145         nvm->ops.release            = e1000_release_nvm_generic;
00146         nvm->ops.update             = e1000_update_nvm_checksum_generic;
00147         nvm->ops.valid_led_default  = e1000_valid_led_default_generic;
00148         nvm->ops.validate           = e1000_validate_nvm_checksum_generic;
00149         nvm->ops.write              = e1000_write_nvm_microwire;
00150 
00151         return E1000_SUCCESS;
00152 }
00153 
00154 /**
00155  * e1000_init_mac_params_82540 - Init MAC func ptrs.
00156  * @hw: pointer to the HW structure
00157  **/
00158 static s32 e1000_init_mac_params_82540(struct e1000_hw *hw)
00159 {
00160         struct e1000_mac_info *mac = &hw->mac;
00161         s32 ret_val = E1000_SUCCESS;
00162 
00163         DEBUGFUNC("e1000_init_mac_params_82540");
00164 
00165         /* Set media type */
00166         switch (hw->device_id) {
00167         case E1000_DEV_ID_82545EM_FIBER:
00168         case E1000_DEV_ID_82545GM_FIBER:
00169         case E1000_DEV_ID_82546EB_FIBER:
00170         case E1000_DEV_ID_82546GB_FIBER:
00171                 hw->phy.media_type = e1000_media_type_fiber;
00172                 break;
00173         case E1000_DEV_ID_82545GM_SERDES:
00174         case E1000_DEV_ID_82546GB_SERDES:
00175                 hw->phy.media_type = e1000_media_type_internal_serdes;
00176                 break;
00177         default:
00178                 hw->phy.media_type = e1000_media_type_copper;
00179                 break;
00180         }
00181 
00182         /* Set mta register count */
00183         mac->mta_reg_count = 128;
00184         /* Set rar entry count */
00185         mac->rar_entry_count = E1000_RAR_ENTRIES;
00186 
00187         /* Function pointers */
00188 
00189         /* bus type/speed/width */
00190         mac->ops.get_bus_info = e1000_get_bus_info_pci_generic;
00191         /* function id */
00192         mac->ops.set_lan_id = e1000_set_lan_id_multi_port_pci;
00193         /* reset */
00194         mac->ops.reset_hw = e1000_reset_hw_82540;
00195         /* hw initialization */
00196         mac->ops.init_hw = e1000_init_hw_82540;
00197         /* link setup */
00198         mac->ops.setup_link = e1000_setup_link_generic;
00199         /* physical interface setup */
00200         mac->ops.setup_physical_interface =
00201                 (hw->phy.media_type == e1000_media_type_copper)
00202                         ? e1000_setup_copper_link_82540
00203                         : e1000_setup_fiber_serdes_link_82540;
00204         /* check for link */
00205         switch (hw->phy.media_type) {
00206         case e1000_media_type_copper:
00207                 mac->ops.check_for_link = e1000_check_for_copper_link_generic;
00208                 break;
00209         case e1000_media_type_fiber:
00210                 mac->ops.check_for_link = e1000_check_for_fiber_link_generic;
00211                 break;
00212         case e1000_media_type_internal_serdes:
00213                 mac->ops.check_for_link = e1000_check_for_serdes_link_generic;
00214                 break;
00215         default:
00216                 ret_val = -E1000_ERR_CONFIG;
00217                 goto out;
00218                 break;
00219         }
00220         /* link info */
00221         mac->ops.get_link_up_info =
00222                 (hw->phy.media_type == e1000_media_type_copper)
00223                         ? e1000_get_speed_and_duplex_copper_generic
00224                         : e1000_get_speed_and_duplex_fiber_serdes_generic;
00225         /* multicast address update */
00226         mac->ops.update_mc_addr_list = e1000_update_mc_addr_list_generic;
00227         /* writing VFTA */
00228         mac->ops.write_vfta = e1000_write_vfta_generic;
00229         /* clearing VFTA */
00230         mac->ops.clear_vfta = e1000_clear_vfta_generic;
00231         /* setting MTA */
00232         mac->ops.mta_set = e1000_mta_set_generic;
00233         /* read mac address */
00234         mac->ops.read_mac_addr = e1000_read_mac_addr_82540;
00235         /* ID LED init */
00236         mac->ops.id_led_init = e1000_id_led_init_generic;
00237         /* setup LED */
00238         mac->ops.setup_led = e1000_setup_led_generic;
00239         /* cleanup LED */
00240         mac->ops.cleanup_led = e1000_cleanup_led_generic;
00241         /* turn on/off LED */
00242         mac->ops.led_on = e1000_led_on_generic;
00243         mac->ops.led_off = e1000_led_off_generic;
00244         /* clear hardware counters */
00245         mac->ops.clear_hw_cntrs = e1000_clear_hw_cntrs_82540;
00246 
00247 out:
00248         return ret_val;
00249 }
00250 
00251 /**
00252  * e1000_init_function_pointers_82540 - Init func ptrs.
00253  * @hw: pointer to the HW structure
00254  *
00255  * Called to initialize all function pointers and parameters.
00256  **/
00257 void e1000_init_function_pointers_82540(struct e1000_hw *hw)
00258 {
00259         DEBUGFUNC("e1000_init_function_pointers_82540");
00260 
00261         hw->mac.ops.init_params = e1000_init_mac_params_82540;
00262         hw->nvm.ops.init_params = e1000_init_nvm_params_82540;
00263         hw->phy.ops.init_params = e1000_init_phy_params_82540;
00264 }
00265 
00266 /**
00267  *  e1000_reset_hw_82540 - Reset hardware
00268  *  @hw: pointer to the HW structure
00269  *
00270  *  This resets the hardware into a known state.
00271  **/
00272 static s32 e1000_reset_hw_82540(struct e1000_hw *hw)
00273 {
00274         u32 ctrl, icr, manc;
00275         s32 ret_val = E1000_SUCCESS;
00276 
00277         DEBUGFUNC("e1000_reset_hw_82540");
00278 
00279         DEBUGOUT("Masking off all interrupts\n");
00280         E1000_WRITE_REG(hw, E1000_IMC, 0xFFFFFFFF);
00281 
00282         E1000_WRITE_REG(hw, E1000_RCTL, 0);
00283         E1000_WRITE_REG(hw, E1000_TCTL, E1000_TCTL_PSP);
00284         E1000_WRITE_FLUSH(hw);
00285 
00286         /*
00287          * Delay to allow any outstanding PCI transactions to complete
00288          * before resetting the device.
00289          */
00290         msec_delay(10);
00291 
00292         ctrl = E1000_READ_REG(hw, E1000_CTRL);
00293 
00294         DEBUGOUT("Issuing a global reset to 82540/82545/82546 MAC\n");
00295         switch (hw->mac.type) {
00296         case e1000_82545_rev_3:
00297         case e1000_82546_rev_3:
00298                 E1000_WRITE_REG(hw, E1000_CTRL_DUP, ctrl | E1000_CTRL_RST);
00299                 break;
00300         default:
00301                 /*
00302                  * These controllers can't ack the 64-bit write when
00303                  * issuing the reset, so we use IO-mapping as a
00304                  * workaround to issue the reset.
00305                  */
00306                 E1000_WRITE_REG_IO(hw, E1000_CTRL, ctrl | E1000_CTRL_RST);
00307                 break;
00308         }
00309 
00310         /* Wait for EEPROM reload */
00311         msec_delay(5);
00312 
00313         /* Disable HW ARPs on ASF enabled adapters */
00314         manc = E1000_READ_REG(hw, E1000_MANC);
00315         manc &= ~E1000_MANC_ARP_EN;
00316         E1000_WRITE_REG(hw, E1000_MANC, manc);
00317 
00318         E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
00319         icr = E1000_READ_REG(hw, E1000_ICR);
00320 
00321         return ret_val;
00322 }
00323 
00324 /**
00325  *  e1000_init_hw_82540 - Initialize hardware
00326  *  @hw: pointer to the HW structure
00327  *
00328  *  This inits the hardware readying it for operation.
00329  **/
00330 static s32 e1000_init_hw_82540(struct e1000_hw *hw)
00331 {
00332         struct e1000_mac_info *mac = &hw->mac;
00333         u32 txdctl, ctrl_ext;
00334         s32 ret_val = E1000_SUCCESS;
00335         u16 i;
00336 
00337         DEBUGFUNC("e1000_init_hw_82540");
00338 
00339         /* Initialize identification LED */
00340         ret_val = mac->ops.id_led_init(hw);
00341         if (ret_val) {
00342                 DEBUGOUT("Error initializing identification LED\n");
00343                 /* This is not fatal and we should not stop init due to this */
00344         }
00345 
00346         /* Disabling VLAN filtering */
00347         DEBUGOUT("Initializing the IEEE VLAN\n");
00348         if (mac->type < e1000_82545_rev_3)
00349                 E1000_WRITE_REG(hw, E1000_VET, 0);
00350 
00351         mac->ops.clear_vfta(hw);
00352 
00353         /* Setup the receive address. */
00354         e1000_init_rx_addrs_generic(hw, mac->rar_entry_count);
00355 
00356         /* Zero out the Multicast HASH table */
00357         DEBUGOUT("Zeroing the MTA\n");
00358         for (i = 0; i < mac->mta_reg_count; i++) {
00359                 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
00360                 /*
00361                  * Avoid back to back register writes by adding the register
00362                  * read (flush).  This is to protect against some strange
00363                  * bridge configurations that may issue Memory Write Block
00364                  * (MWB) to our register space.  The *_rev_3 hardware at
00365                  * least doesn't respond correctly to every other dword in an
00366                  * MWB to our register space.
00367                  */
00368                 E1000_WRITE_FLUSH(hw);
00369         }
00370 
00371         if (mac->type < e1000_82545_rev_3)
00372                 e1000_pcix_mmrbc_workaround_generic(hw);
00373 
00374         /* Setup link and flow control */
00375         ret_val = mac->ops.setup_link(hw);
00376 
00377         txdctl = E1000_READ_REG(hw, E1000_TXDCTL(0));
00378         txdctl = (txdctl & ~E1000_TXDCTL_WTHRESH) |
00379                  E1000_TXDCTL_FULL_TX_DESC_WB;
00380         E1000_WRITE_REG(hw, E1000_TXDCTL(0), txdctl);
00381 
00382         /*
00383          * Clear all of the statistics registers (clear on read).  It is
00384          * important that we do this after we have tried to establish link
00385          * because the symbol error count will increment wildly if there
00386          * is no link.
00387          */
00388         e1000_clear_hw_cntrs_82540(hw);
00389 
00390         if ((hw->device_id == E1000_DEV_ID_82546GB_QUAD_COPPER) ||
00391             (hw->device_id == E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3)) {
00392                 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
00393                 /*
00394                  * Relaxed ordering must be disabled to avoid a parity
00395                  * error crash in a PCI slot.
00396                  */
00397                 ctrl_ext |= E1000_CTRL_EXT_RO_DIS;
00398                 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
00399         }
00400 
00401         return ret_val;
00402 }
00403 
00404 /**
00405  *  e1000_setup_copper_link_82540 - Configure copper link settings
00406  *  @hw: pointer to the HW structure
00407  *
00408  *  Calls the appropriate function to configure the link for auto-neg or forced
00409  *  speed and duplex.  Then we check for link, once link is established calls
00410  *  to configure collision distance and flow control are called.  If link is
00411  *  not established, we return -E1000_ERR_PHY (-2).
00412  **/
00413 static s32 e1000_setup_copper_link_82540(struct e1000_hw *hw)
00414 {
00415         u32 ctrl;
00416         s32 ret_val = E1000_SUCCESS;
00417         u16 data;
00418 
00419         DEBUGFUNC("e1000_setup_copper_link_82540");
00420 
00421         ctrl = E1000_READ_REG(hw, E1000_CTRL);
00422         ctrl |= E1000_CTRL_SLU;
00423         ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
00424         E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
00425 
00426         ret_val = e1000_set_phy_mode_82540(hw);
00427         if (ret_val)
00428                 goto out;
00429 
00430         if (hw->mac.type == e1000_82545_rev_3 ||
00431             hw->mac.type == e1000_82546_rev_3) {
00432                 ret_val = hw->phy.ops.read_reg(hw, M88E1000_PHY_SPEC_CTRL, &data);
00433                 if (ret_val)
00434                         goto out;
00435                 data |= 0x00000008;
00436                 ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_SPEC_CTRL, data);
00437                 if (ret_val)
00438                         goto out;
00439         }
00440 
00441         ret_val = e1000_copper_link_setup_m88(hw);
00442         if (ret_val)
00443                 goto out;
00444 
00445         ret_val = e1000_setup_copper_link_generic(hw);
00446 
00447 out:
00448         return ret_val;
00449 }
00450 
00451 /**
00452  *  e1000_setup_fiber_serdes_link_82540 - Setup link for fiber/serdes
00453  *  @hw: pointer to the HW structure
00454  *
00455  *  Set the output amplitude to the value in the EEPROM and adjust the VCO
00456  *  speed to improve Bit Error Rate (BER) performance.  Configures collision
00457  *  distance and flow control for fiber and serdes links.  Upon successful
00458  *  setup, poll for link.
00459  **/
00460 static s32 e1000_setup_fiber_serdes_link_82540(struct e1000_hw *hw)
00461 {
00462         struct e1000_mac_info *mac = &hw->mac;
00463         s32 ret_val = E1000_SUCCESS;
00464 
00465         DEBUGFUNC("e1000_setup_fiber_serdes_link_82540");
00466 
00467         switch (mac->type) {
00468         case e1000_82545_rev_3:
00469         case e1000_82546_rev_3:
00470                 if (hw->phy.media_type == e1000_media_type_internal_serdes) {
00471                         /*
00472                          * If we're on serdes media, adjust the output
00473                          * amplitude to value set in the EEPROM.
00474                          */
00475                         ret_val = e1000_adjust_serdes_amplitude_82540(hw);
00476                         if (ret_val)
00477                                 goto out;
00478                 }
00479                 /* Adjust VCO speed to improve BER performance */
00480                 ret_val = e1000_set_vco_speed_82540(hw);
00481                 if (ret_val)
00482                         goto out;
00483         default:
00484                 break;
00485         }
00486 
00487         ret_val = e1000_setup_fiber_serdes_link_generic(hw);
00488 
00489 out:
00490         return ret_val;
00491 }
00492 
00493 /**
00494  *  e1000_adjust_serdes_amplitude_82540 - Adjust amplitude based on EEPROM
00495  *  @hw: pointer to the HW structure
00496  *
00497  *  Adjust the SERDES output amplitude based on the EEPROM settings.
00498  **/
00499 static s32 e1000_adjust_serdes_amplitude_82540(struct e1000_hw *hw)
00500 {
00501         s32 ret_val = E1000_SUCCESS;
00502         u16 nvm_data;
00503 
00504         DEBUGFUNC("e1000_adjust_serdes_amplitude_82540");
00505 
00506         ret_val = hw->nvm.ops.read(hw, NVM_SERDES_AMPLITUDE, 1, &nvm_data);
00507         if (ret_val)
00508                 goto out;
00509 
00510         if (nvm_data != NVM_RESERVED_WORD) {
00511                 /* Adjust serdes output amplitude only. */
00512                 nvm_data &= NVM_SERDES_AMPLITUDE_MASK;
00513                 ret_val = hw->phy.ops.write_reg(hw,
00514                                              M88E1000_PHY_EXT_CTRL,
00515                                              nvm_data);
00516                 if (ret_val)
00517                         goto out;
00518         }
00519 
00520 out:
00521         return ret_val;
00522 }
00523 
00524 /**
00525  *  e1000_set_vco_speed_82540 - Set VCO speed for better performance
00526  *  @hw: pointer to the HW structure
00527  *
00528  *  Set the VCO speed to improve Bit Error Rate (BER) performance.
00529  **/
00530 static s32 e1000_set_vco_speed_82540(struct e1000_hw *hw)
00531 {
00532         s32  ret_val = E1000_SUCCESS;
00533         u16 default_page = 0;
00534         u16 phy_data;
00535 
00536         DEBUGFUNC("e1000_set_vco_speed_82540");
00537 
00538         /* Set PHY register 30, page 5, bit 8 to 0 */
00539 
00540         ret_val = hw->phy.ops.read_reg(hw,
00541                                     M88E1000_PHY_PAGE_SELECT,
00542                                     &default_page);
00543         if (ret_val)
00544                 goto out;
00545 
00546         ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_PAGE_SELECT, 0x0005);
00547         if (ret_val)
00548                 goto out;
00549 
00550         ret_val = hw->phy.ops.read_reg(hw, M88E1000_PHY_GEN_CONTROL, &phy_data);
00551         if (ret_val)
00552                 goto out;
00553 
00554         phy_data &= ~M88E1000_PHY_VCO_REG_BIT8;
00555         ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_GEN_CONTROL, phy_data);
00556         if (ret_val)
00557                 goto out;
00558 
00559         /* Set PHY register 30, page 4, bit 11 to 1 */
00560 
00561         ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_PAGE_SELECT, 0x0004);
00562         if (ret_val)
00563                 goto out;
00564 
00565         ret_val = hw->phy.ops.read_reg(hw, M88E1000_PHY_GEN_CONTROL, &phy_data);
00566         if (ret_val)
00567                 goto out;
00568 
00569         phy_data |= M88E1000_PHY_VCO_REG_BIT11;
00570         ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_GEN_CONTROL, phy_data);
00571         if (ret_val)
00572                 goto out;
00573 
00574         ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_PAGE_SELECT,
00575                                       default_page);
00576 
00577 out:
00578         return ret_val;
00579 }
00580 
00581 /**
00582  *  e1000_set_phy_mode_82540 - Set PHY to class A mode
00583  *  @hw: pointer to the HW structure
00584  *
00585  *  Sets the PHY to class A mode and assumes the following operations will
00586  *  follow to enable the new class mode:
00587  *    1.  Do a PHY soft reset.
00588  *    2.  Restart auto-negotiation or force link.
00589  **/
00590 static s32 e1000_set_phy_mode_82540(struct e1000_hw *hw)
00591 {
00592         struct e1000_phy_info *phy = &hw->phy;
00593         s32 ret_val = E1000_SUCCESS;
00594         u16 nvm_data;
00595 
00596         DEBUGFUNC("e1000_set_phy_mode_82540");
00597 
00598         if (hw->mac.type != e1000_82545_rev_3)
00599                 goto out;
00600 
00601         ret_val = hw->nvm.ops.read(hw, NVM_PHY_CLASS_WORD, 1, &nvm_data);
00602         if (ret_val) {
00603                 ret_val = -E1000_ERR_PHY;
00604                 goto out;
00605         }
00606 
00607         if ((nvm_data != NVM_RESERVED_WORD) && (nvm_data & NVM_PHY_CLASS_A)) {
00608                 ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_PAGE_SELECT,
00609                                               0x000B);
00610                 if (ret_val) {
00611                         ret_val = -E1000_ERR_PHY;
00612                         goto out;
00613                 }
00614                 ret_val = hw->phy.ops.write_reg(hw,
00615                                               M88E1000_PHY_GEN_CONTROL,
00616                                               0x8104);
00617                 if (ret_val) {
00618                         ret_val = -E1000_ERR_PHY;
00619                         goto out;
00620                 }
00621 
00622                 phy->reset_disable = false;
00623         }
00624 
00625 out:
00626         return ret_val;
00627 }
00628 
00629 /**
00630  * e1000_power_down_phy_copper_82540 - Remove link in case of PHY power down
00631  * @hw: pointer to the HW structure
00632  *
00633  * In the case of a PHY power down to save power, or to turn off link during a
00634  * driver unload, or wake on lan is not enabled, remove the link.
00635  **/
00636 static void e1000_power_down_phy_copper_82540(struct e1000_hw *hw)
00637 {
00638         /* If the management interface is not enabled, then power down */
00639         if (!(E1000_READ_REG(hw, E1000_MANC) & E1000_MANC_SMBUS_EN))
00640                 e1000_power_down_phy_copper(hw);
00641 
00642         return;
00643 }
00644 
00645 /**
00646  *  e1000_clear_hw_cntrs_82540 - Clear device specific hardware counters
00647  *  @hw: pointer to the HW structure
00648  *
00649  *  Clears the hardware counters by reading the counter registers.
00650  **/
00651 static void e1000_clear_hw_cntrs_82540(struct e1000_hw *hw)
00652 {
00653         DEBUGFUNC("e1000_clear_hw_cntrs_82540");
00654 
00655         e1000_clear_hw_cntrs_base_generic(hw);
00656 
00657 #if 0
00658         E1000_READ_REG(hw, E1000_PRC64);
00659         E1000_READ_REG(hw, E1000_PRC127);
00660         E1000_READ_REG(hw, E1000_PRC255);
00661         E1000_READ_REG(hw, E1000_PRC511);
00662         E1000_READ_REG(hw, E1000_PRC1023);
00663         E1000_READ_REG(hw, E1000_PRC1522);
00664         E1000_READ_REG(hw, E1000_PTC64);
00665         E1000_READ_REG(hw, E1000_PTC127);
00666         E1000_READ_REG(hw, E1000_PTC255);
00667         E1000_READ_REG(hw, E1000_PTC511);
00668         E1000_READ_REG(hw, E1000_PTC1023);
00669         E1000_READ_REG(hw, E1000_PTC1522);
00670 
00671         E1000_READ_REG(hw, E1000_ALGNERRC);
00672         E1000_READ_REG(hw, E1000_RXERRC);
00673         E1000_READ_REG(hw, E1000_TNCRS);
00674         E1000_READ_REG(hw, E1000_CEXTERR);
00675         E1000_READ_REG(hw, E1000_TSCTC);
00676         E1000_READ_REG(hw, E1000_TSCTFC);
00677 
00678         E1000_READ_REG(hw, E1000_MGTPRC);
00679         E1000_READ_REG(hw, E1000_MGTPDC);
00680         E1000_READ_REG(hw, E1000_MGTPTC);
00681 #endif
00682 }
00683 
00684 /**
00685  *  e1000_read_mac_addr_82540 - Read device MAC address
00686  *  @hw: pointer to the HW structure
00687  *
00688  *  Reads the device MAC address from the EEPROM and stores the value.
00689  *  Since devices with two ports use the same EEPROM, we increment the
00690  *  last bit in the MAC address for the second port.
00691  *
00692  *  This version is being used over generic because of customer issues
00693  *  with VmWare and Virtual Box when using generic. It seems in
00694  *  the emulated 82545, RAR[0] does NOT have a valid address after a
00695  *  reset, this older method works and using this breaks nothing for
00696  *  these legacy adapters.
00697  **/
00698 s32 e1000_read_mac_addr_82540(struct e1000_hw *hw)
00699 {
00700         s32  ret_val = E1000_SUCCESS;
00701         u16 offset, nvm_data, i;
00702 
00703         DEBUGFUNC("e1000_read_mac_addr");
00704 
00705         for (i = 0; i < ETH_ADDR_LEN; i += 2) {
00706                 offset = i >> 1;
00707                 ret_val = hw->nvm.ops.read(hw, offset, 1, &nvm_data);
00708                 if (ret_val) {
00709                         DEBUGOUT("NVM Read Error\n");
00710                         goto out;
00711                 }
00712                 hw->mac.perm_addr[i] = (u8)(nvm_data & 0xFF);
00713                 hw->mac.perm_addr[i+1] = (u8)(nvm_data >> 8);
00714         }
00715 
00716         /* Flip last bit of mac address if we're on second port */
00717         if (hw->bus.func == E1000_FUNC_1)
00718                 hw->mac.perm_addr[5] ^= 1;
00719 
00720         for (i = 0; i < ETH_ADDR_LEN; i++)
00721                 hw->mac.addr[i] = hw->mac.perm_addr[i];
00722 
00723 out:
00724         return ret_val;
00725 }
00726 
00727 static struct pci_device_id e1000_82540_nics[] = {
00728      PCI_ROM(0x8086, 0x100E, "E1000_DEV_ID_82540EM", "E1000_DEV_ID_82540EM", e1000_82540),
00729      PCI_ROM(0x8086, 0x1015, "E1000_DEV_ID_82540EM_LOM", "E1000_DEV_ID_82540EM_LOM", e1000_82540),
00730      PCI_ROM(0x8086, 0x1016, "E1000_DEV_ID_82540EP_LOM", "E1000_DEV_ID_82540EP_LOM", e1000_82540),
00731      PCI_ROM(0x8086, 0x1017, "E1000_DEV_ID_82540EP", "E1000_DEV_ID_82540EP", e1000_82540),
00732      PCI_ROM(0x8086, 0x101E, "E1000_DEV_ID_82540EP_LP", "E1000_DEV_ID_82540EP_LP", e1000_82540),
00733      PCI_ROM(0x8086, 0x100F, "E1000_DEV_ID_82545EM_COPPER", "E1000_DEV_ID_82545EM_COPPER", e1000_82545),
00734      PCI_ROM(0x8086, 0x1011, "E1000_DEV_ID_82545EM_FIBER", "E1000_DEV_ID_82545EM_FIBER", e1000_82545),
00735      PCI_ROM(0x8086, 0x1026, "E1000_DEV_ID_82545GM_COPPER", "E1000_DEV_ID_82545GM_COPPER", e1000_82545_rev_3),
00736      PCI_ROM(0x8086, 0x1027, "E1000_DEV_ID_82545GM_FIBER", "E1000_DEV_ID_82545GM_FIBER", e1000_82545_rev_3),
00737      PCI_ROM(0x8086, 0x1028, "E1000_DEV_ID_82545GM_SERDES", "E1000_DEV_ID_82545GM_SERDES", e1000_82545_rev_3),
00738      PCI_ROM(0x8086, 0x1010, "E1000_DEV_ID_82546EB_COPPER", "E1000_DEV_ID_82546EB_COPPER", e1000_82546),
00739      PCI_ROM(0x8086, 0x1012, "E1000_DEV_ID_82546EB_FIBER", "E1000_DEV_ID_82546EB_FIBER", e1000_82546),
00740      PCI_ROM(0x8086, 0x101D, "E1000_DEV_ID_82546EB_QUAD_COPPER", "E1000_DEV_ID_82546EB_QUAD_COPPER", e1000_82546),
00741      PCI_ROM(0x8086, 0x1079, "E1000_DEV_ID_82546GB_COPPER", "E1000_DEV_ID_82546GB_COPPER", e1000_82546_rev_3),
00742      PCI_ROM(0x8086, 0x107A, "E1000_DEV_ID_82546GB_FIBER", "E1000_DEV_ID_82546GB_FIBER", e1000_82546_rev_3),
00743      PCI_ROM(0x8086, 0x107B, "E1000_DEV_ID_82546GB_SERDES", "E1000_DEV_ID_82546GB_SERDES", e1000_82546_rev_3),
00744      PCI_ROM(0x8086, 0x108A, "E1000_DEV_ID_82546GB_PCIE", "E1000_DEV_ID_82546GB_PCIE", e1000_82546_rev_3),
00745      PCI_ROM(0x8086, 0x1099, "E1000_DEV_ID_82546GB_QUAD_COPPER", "E1000_DEV_ID_82546GB_QUAD_COPPER", e1000_82546_rev_3),
00746      PCI_ROM(0x8086, 0x10B5, "E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3", "E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3", e1000_82546_rev_3),
00747 };
00748 
00749 struct pci_driver e1000_82540_driver __pci_driver = {
00750         .ids = e1000_82540_nics,
00751         .id_count = (sizeof (e1000_82540_nics) / sizeof (e1000_82540_nics[0])),
00752         .probe = e1000_probe,
00753         .remove = e1000_remove,
00754 };

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