e1000_82542.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  * 82542 Gigabit Ethernet Controller
00033  */
00034 
00035 #include "e1000_api.h"
00036 
00037 static s32  e1000_init_phy_params_82542(struct e1000_hw *hw);
00038 static s32  e1000_init_nvm_params_82542(struct e1000_hw *hw);
00039 static s32  e1000_init_mac_params_82542(struct e1000_hw *hw);
00040 static s32  e1000_get_bus_info_82542(struct e1000_hw *hw);
00041 static s32  e1000_reset_hw_82542(struct e1000_hw *hw);
00042 static s32  e1000_init_hw_82542(struct e1000_hw *hw);
00043 static s32  e1000_setup_link_82542(struct e1000_hw *hw);
00044 static s32  e1000_led_on_82542(struct e1000_hw *hw);
00045 static s32  e1000_led_off_82542(struct e1000_hw *hw);
00046 static void e1000_rar_set_82542(struct e1000_hw *hw, u8 *addr, u32 index);
00047 static void e1000_clear_hw_cntrs_82542(struct e1000_hw *hw);
00048 
00049 /**
00050  *  e1000_init_phy_params_82542 - Init PHY func ptrs.
00051  *  @hw: pointer to the HW structure
00052  **/
00053 static s32 e1000_init_phy_params_82542(struct e1000_hw *hw)
00054 {
00055         struct e1000_phy_info *phy = &hw->phy;
00056         s32 ret_val = E1000_SUCCESS;
00057 
00058         DEBUGFUNC("e1000_init_phy_params_82542");
00059 
00060         phy->type               = e1000_phy_none;
00061 
00062         return ret_val;
00063 }
00064 
00065 /**
00066  *  e1000_init_nvm_params_82542 - Init NVM func ptrs.
00067  *  @hw: pointer to the HW structure
00068  **/
00069 static s32 e1000_init_nvm_params_82542(struct e1000_hw *hw)
00070 {
00071         struct e1000_nvm_info *nvm = &hw->nvm;
00072 
00073         DEBUGFUNC("e1000_init_nvm_params_82542");
00074 
00075         nvm->address_bits       =  6;
00076         nvm->delay_usec         = 50;
00077         nvm->opcode_bits        =  3;
00078         nvm->type               = e1000_nvm_eeprom_microwire;
00079         nvm->word_size          = 64;
00080 
00081         /* Function Pointers */
00082         nvm->ops.read           = e1000_read_nvm_microwire;
00083         nvm->ops.release        = e1000_stop_nvm;
00084         nvm->ops.write          = e1000_write_nvm_microwire;
00085         nvm->ops.update         = e1000_update_nvm_checksum_generic;
00086         nvm->ops.validate       = e1000_validate_nvm_checksum_generic;
00087 
00088         return E1000_SUCCESS;
00089 }
00090 
00091 /**
00092  *  e1000_init_mac_params_82542 - Init MAC func ptrs.
00093  *  @hw: pointer to the HW structure
00094  **/
00095 static s32 e1000_init_mac_params_82542(struct e1000_hw *hw)
00096 {
00097         struct e1000_mac_info *mac = &hw->mac;
00098 
00099         DEBUGFUNC("e1000_init_mac_params_82542");
00100 
00101         /* Set media type */
00102         hw->phy.media_type = e1000_media_type_fiber;
00103 
00104         /* Set mta register count */
00105         mac->mta_reg_count = 128;
00106         /* Set rar entry count */
00107         mac->rar_entry_count = E1000_RAR_ENTRIES;
00108 
00109         /* Function pointers */
00110 
00111         /* bus type/speed/width */
00112         mac->ops.get_bus_info = e1000_get_bus_info_82542;
00113         /* function id */
00114         mac->ops.set_lan_id = e1000_set_lan_id_multi_port_pci;
00115         /* reset */
00116         mac->ops.reset_hw = e1000_reset_hw_82542;
00117         /* hw initialization */
00118         mac->ops.init_hw = e1000_init_hw_82542;
00119         /* link setup */
00120         mac->ops.setup_link = e1000_setup_link_82542;
00121         /* phy/fiber/serdes setup */
00122         mac->ops.setup_physical_interface = e1000_setup_fiber_serdes_link_generic;
00123         /* check for link */
00124         mac->ops.check_for_link = e1000_check_for_fiber_link_generic;
00125         /* multicast address update */
00126         mac->ops.update_mc_addr_list = e1000_update_mc_addr_list_generic;
00127         /* writing VFTA */
00128         mac->ops.write_vfta = e1000_write_vfta_generic;
00129         /* clearing VFTA */
00130         mac->ops.clear_vfta = e1000_clear_vfta_generic;
00131         /* setting MTA */
00132         mac->ops.mta_set = e1000_mta_set_generic;
00133         /* set RAR */
00134         mac->ops.rar_set = e1000_rar_set_82542;
00135         /* turn on/off LED */
00136         mac->ops.led_on = e1000_led_on_82542;
00137         mac->ops.led_off = e1000_led_off_82542;
00138         /* clear hardware counters */
00139         mac->ops.clear_hw_cntrs = e1000_clear_hw_cntrs_82542;
00140         /* link info */
00141         mac->ops.get_link_up_info = e1000_get_speed_and_duplex_fiber_serdes_generic;
00142 
00143         return E1000_SUCCESS;
00144 }
00145 
00146 /**
00147  *  e1000_init_function_pointers_82542 - Init func ptrs.
00148  *  @hw: pointer to the HW structure
00149  *
00150  *  Called to initialize all function pointers and parameters.
00151  **/
00152 void e1000_init_function_pointers_82542(struct e1000_hw *hw)
00153 {
00154         DEBUGFUNC("e1000_init_function_pointers_82542");
00155 
00156         hw->mac.ops.init_params = e1000_init_mac_params_82542;
00157         hw->nvm.ops.init_params = e1000_init_nvm_params_82542;
00158         hw->phy.ops.init_params = e1000_init_phy_params_82542;
00159 }
00160 
00161 /**
00162  *  e1000_get_bus_info_82542 - Obtain bus information for adapter
00163  *  @hw: pointer to the HW structure
00164  *
00165  *  This will obtain information about the HW bus for which the
00166  *  adapter is attached and stores it in the hw structure.
00167  **/
00168 static s32 e1000_get_bus_info_82542(struct e1000_hw *hw)
00169 {
00170         DEBUGFUNC("e1000_get_bus_info_82542");
00171 
00172         hw->bus.type = e1000_bus_type_pci;
00173         hw->bus.speed = e1000_bus_speed_unknown;
00174         hw->bus.width = e1000_bus_width_unknown;
00175 
00176         return E1000_SUCCESS;
00177 }
00178 
00179 /**
00180  *  e1000_reset_hw_82542 - Reset hardware
00181  *  @hw: pointer to the HW structure
00182  *
00183  *  This resets the hardware into a known state.
00184  **/
00185 static s32 e1000_reset_hw_82542(struct e1000_hw *hw)
00186 {
00187         struct e1000_bus_info *bus = &hw->bus;
00188         s32 ret_val = E1000_SUCCESS;
00189         u32 ctrl, icr;
00190 
00191         DEBUGFUNC("e1000_reset_hw_82542");
00192 
00193         if (hw->revision_id == E1000_REVISION_2) {
00194                 DEBUGOUT("Disabling MWI on 82542 rev 2\n");
00195                 e1000_pci_clear_mwi(hw);
00196         }
00197 
00198         DEBUGOUT("Masking off all interrupts\n");
00199         E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
00200 
00201         E1000_WRITE_REG(hw, E1000_RCTL, 0);
00202         E1000_WRITE_REG(hw, E1000_TCTL, E1000_TCTL_PSP);
00203         E1000_WRITE_FLUSH(hw);
00204 
00205         /*
00206          * Delay to allow any outstanding PCI transactions to complete before
00207          * resetting the device
00208          */
00209         msec_delay(10);
00210 
00211         ctrl = E1000_READ_REG(hw, E1000_CTRL);
00212 
00213         DEBUGOUT("Issuing a global reset to 82542/82543 MAC\n");
00214         E1000_WRITE_REG(hw, E1000_CTRL, ctrl | E1000_CTRL_RST);
00215 
00216         hw->nvm.ops.reload(hw);
00217         msec_delay(2);
00218 
00219         E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
00220         icr = E1000_READ_REG(hw, E1000_ICR);
00221 
00222         if (hw->revision_id == E1000_REVISION_2) {
00223                 if (bus->pci_cmd_word & CMD_MEM_WRT_INVALIDATE)
00224                         e1000_pci_set_mwi(hw);
00225         }
00226 
00227         return ret_val;
00228 }
00229 
00230 /**
00231  *  e1000_init_hw_82542 - Initialize hardware
00232  *  @hw: pointer to the HW structure
00233  *
00234  *  This inits the hardware readying it for operation.
00235  **/
00236 static s32 e1000_init_hw_82542(struct e1000_hw *hw)
00237 {
00238         struct e1000_mac_info *mac = &hw->mac;
00239         struct e1000_dev_spec_82542 *dev_spec = &hw->dev_spec._82542;
00240         s32 ret_val = E1000_SUCCESS;
00241         u32 ctrl;
00242         u16 i;
00243 
00244         DEBUGFUNC("e1000_init_hw_82542");
00245 
00246         /* Disabling VLAN filtering */
00247         E1000_WRITE_REG(hw, E1000_VET, 0);
00248         mac->ops.clear_vfta(hw);
00249 
00250         /* For 82542 (rev 2.0), disable MWI and put the receiver into reset */
00251         if (hw->revision_id == E1000_REVISION_2) {
00252                 DEBUGOUT("Disabling MWI on 82542 rev 2.0\n");
00253                 e1000_pci_clear_mwi(hw);
00254                 E1000_WRITE_REG(hw, E1000_RCTL, E1000_RCTL_RST);
00255                 E1000_WRITE_FLUSH(hw);
00256                 msec_delay(5);
00257         }
00258 
00259         /* Setup the receive address. */
00260         e1000_init_rx_addrs_generic(hw, mac->rar_entry_count);
00261 
00262         /* For 82542 (rev 2.0), take the receiver out of reset and enable MWI */
00263         if (hw->revision_id == E1000_REVISION_2) {
00264                 E1000_WRITE_REG(hw, E1000_RCTL, 0);
00265                 E1000_WRITE_FLUSH(hw);
00266                 msec_delay(1);
00267                 if (hw->bus.pci_cmd_word & CMD_MEM_WRT_INVALIDATE)
00268                         e1000_pci_set_mwi(hw);
00269         }
00270 
00271         /* Zero out the Multicast HASH table */
00272         DEBUGOUT("Zeroing the MTA\n");
00273         for (i = 0; i < mac->mta_reg_count; i++)
00274                 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
00275 
00276         /*
00277          * Set the PCI priority bit correctly in the CTRL register.  This
00278          * determines if the adapter gives priority to receives, or if it
00279          * gives equal priority to transmits and receives.
00280          */
00281         if (dev_spec->dma_fairness) {
00282                 ctrl = E1000_READ_REG(hw, E1000_CTRL);
00283                 E1000_WRITE_REG(hw, E1000_CTRL, ctrl | E1000_CTRL_PRIOR);
00284         }
00285 
00286         /* Setup link and flow control */
00287         ret_val = e1000_setup_link_82542(hw);
00288 
00289         /*
00290          * Clear all of the statistics registers (clear on read).  It is
00291          * important that we do this after we have tried to establish link
00292          * because the symbol error count will increment wildly if there
00293          * is no link.
00294          */
00295         e1000_clear_hw_cntrs_82542(hw);
00296 
00297         return ret_val;
00298 }
00299 
00300 /**
00301  *  e1000_setup_link_82542 - Setup flow control and link settings
00302  *  @hw: pointer to the HW structure
00303  *
00304  *  Determines which flow control settings to use, then configures flow
00305  *  control.  Calls the appropriate media-specific link configuration
00306  *  function.  Assuming the adapter has a valid link partner, a valid link
00307  *  should be established.  Assumes the hardware has previously been reset
00308  *  and the transmitter and receiver are not enabled.
00309  **/
00310 static s32 e1000_setup_link_82542(struct e1000_hw *hw)
00311 {
00312         struct e1000_mac_info *mac = &hw->mac;
00313         s32 ret_val = E1000_SUCCESS;
00314 
00315         DEBUGFUNC("e1000_setup_link_82542");
00316 
00317         ret_val = e1000_set_default_fc_generic(hw);
00318         if (ret_val)
00319                 goto out;
00320 
00321         hw->fc.requested_mode &= ~e1000_fc_tx_pause;
00322 
00323         if (mac->report_tx_early == 1)
00324                 hw->fc.requested_mode &= ~e1000_fc_rx_pause;
00325 
00326         /*
00327          * Save off the requested flow control mode for use later.  Depending
00328          * on the link partner's capabilities, we may or may not use this mode.
00329          */
00330         hw->fc.current_mode = hw->fc.requested_mode;
00331 
00332         DEBUGOUT1("After fix-ups FlowControl is now = %x\n",
00333                                                      hw->fc.current_mode);
00334 
00335         /* Call the necessary subroutine to configure the link. */
00336         ret_val = mac->ops.setup_physical_interface(hw);
00337         if (ret_val)
00338                 goto out;
00339 
00340         /*
00341          * Initialize the flow control address, type, and PAUSE timer
00342          * registers to their default values.  This is done even if flow
00343          * control is disabled, because it does not hurt anything to
00344          * initialize these registers.
00345          */
00346         DEBUGOUT("Initializing Flow Control address, type and timer regs\n");
00347 
00348         E1000_WRITE_REG(hw, E1000_FCAL, FLOW_CONTROL_ADDRESS_LOW);
00349         E1000_WRITE_REG(hw, E1000_FCAH, FLOW_CONTROL_ADDRESS_HIGH);
00350         E1000_WRITE_REG(hw, E1000_FCT, FLOW_CONTROL_TYPE);
00351 
00352         E1000_WRITE_REG(hw, E1000_FCTTV, hw->fc.pause_time);
00353 
00354         ret_val = e1000_set_fc_watermarks_generic(hw);
00355 
00356 out:
00357         return ret_val;
00358 }
00359 
00360 /**
00361  *  e1000_led_on_82542 - Turn on SW controllable LED
00362  *  @hw: pointer to the HW structure
00363  *
00364  *  Turns the SW defined LED on.
00365  **/
00366 static s32 e1000_led_on_82542(struct e1000_hw *hw __unused)
00367 {
00368 #if 0
00369         u32 ctrl = E1000_READ_REG(hw, E1000_CTRL);
00370 
00371         DEBUGFUNC("e1000_led_on_82542");
00372 
00373         ctrl |= E1000_CTRL_SWDPIN0;
00374         ctrl |= E1000_CTRL_SWDPIO0;
00375         E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
00376 
00377         return E1000_SUCCESS;
00378 #endif
00379         return 0;
00380 }
00381 
00382 /**
00383  *  e1000_led_off_82542 - Turn off SW controllable LED
00384  *  @hw: pointer to the HW structure
00385  *
00386  *  Turns the SW defined LED off.
00387  **/
00388 static s32 e1000_led_off_82542(struct e1000_hw *hw __unused)
00389 {
00390 #if 0
00391         u32 ctrl = E1000_READ_REG(hw, E1000_CTRL);
00392 
00393         DEBUGFUNC("e1000_led_off_82542");
00394 
00395         ctrl &= ~E1000_CTRL_SWDPIN0;
00396         ctrl |= E1000_CTRL_SWDPIO0;
00397         E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
00398 
00399         return E1000_SUCCESS;
00400 #endif
00401         return 0;
00402 }
00403 
00404 /**
00405  *  e1000_rar_set_82542 - Set receive address register
00406  *  @hw: pointer to the HW structure
00407  *  @addr: pointer to the receive address
00408  *  @index: receive address array register
00409  *
00410  *  Sets the receive address array register at index to the address passed
00411  *  in by addr.
00412  **/
00413 static void e1000_rar_set_82542(struct e1000_hw *hw, u8 *addr, u32 index)
00414 {
00415         u32 rar_low, rar_high;
00416 
00417         DEBUGFUNC("e1000_rar_set_82542");
00418 
00419         /*
00420          * HW expects these in little endian so we reverse the byte order
00421          * from network order (big endian) to little endian
00422          */
00423         rar_low = ((u32) addr[0] |
00424                    ((u32) addr[1] << 8) |
00425                    ((u32) addr[2] << 16) | ((u32) addr[3] << 24));
00426 
00427         rar_high = ((u32) addr[4] | ((u32) addr[5] << 8));
00428 
00429         /* If MAC address zero, no need to set the AV bit */
00430         if (rar_low || rar_high)
00431                 rar_high |= E1000_RAH_AV;
00432 
00433         E1000_WRITE_REG_ARRAY(hw, E1000_RA, (index << 1), rar_low);
00434         E1000_WRITE_REG_ARRAY(hw, E1000_RA, ((index << 1) + 1), rar_high);
00435 }
00436 
00437 /**
00438  *  e1000_translate_register_82542 - Translate the proper register offset
00439  *  @reg: e1000 register to be read
00440  *
00441  *  Registers in 82542 are located in different offsets than other adapters
00442  *  even though they function in the same manner.  This function takes in
00443  *  the name of the register to read and returns the correct offset for
00444  *  82542 silicon.
00445  **/
00446 u32 e1000_translate_register_82542(u32 reg)
00447 {
00448         /*
00449          * Some of the 82542 registers are located at different
00450          * offsets than they are in newer adapters.
00451          * Despite the difference in location, the registers
00452          * function in the same manner.
00453          */
00454         switch (reg) {
00455         case E1000_RA:
00456                 reg = 0x00040;
00457                 break;
00458         case E1000_RDTR:
00459                 reg = 0x00108;
00460                 break;
00461         case E1000_RDBAL(0):
00462                 reg = 0x00110;
00463                 break;
00464         case E1000_RDBAH(0):
00465                 reg = 0x00114;
00466                 break;
00467         case E1000_RDLEN(0):
00468                 reg = 0x00118;
00469                 break;
00470         case E1000_RDH(0):
00471                 reg = 0x00120;
00472                 break;
00473         case E1000_RDT(0):
00474                 reg = 0x00128;
00475                 break;
00476         case E1000_RDBAL(1):
00477                 reg = 0x00138;
00478                 break;
00479         case E1000_RDBAH(1):
00480                 reg = 0x0013C;
00481                 break;
00482         case E1000_RDLEN(1):
00483                 reg = 0x00140;
00484                 break;
00485         case E1000_RDH(1):
00486                 reg = 0x00148;
00487                 break;
00488         case E1000_RDT(1):
00489                 reg = 0x00150;
00490                 break;
00491         case E1000_FCRTH:
00492                 reg = 0x00160;
00493                 break;
00494         case E1000_FCRTL:
00495                 reg = 0x00168;
00496                 break;
00497         case E1000_MTA:
00498                 reg = 0x00200;
00499                 break;
00500         case E1000_TDBAL(0):
00501                 reg = 0x00420;
00502                 break;
00503         case E1000_TDBAH(0):
00504                 reg = 0x00424;
00505                 break;
00506         case E1000_TDLEN(0):
00507                 reg = 0x00428;
00508                 break;
00509         case E1000_TDH(0):
00510                 reg = 0x00430;
00511                 break;
00512         case E1000_TDT(0):
00513                 reg = 0x00438;
00514                 break;
00515         case E1000_TIDV:
00516                 reg = 0x00440;
00517                 break;
00518         case E1000_VFTA:
00519                 reg = 0x00600;
00520                 break;
00521         case E1000_TDFH:
00522                 reg = 0x08010;
00523                 break;
00524         case E1000_TDFT:
00525                 reg = 0x08018;
00526                 break;
00527         default:
00528                 break;
00529         }
00530 
00531         return reg;
00532 }
00533 
00534 /**
00535  *  e1000_clear_hw_cntrs_82542 - Clear device specific hardware counters
00536  *  @hw: pointer to the HW structure
00537  *
00538  *  Clears the hardware counters by reading the counter registers.
00539  **/
00540 static void e1000_clear_hw_cntrs_82542(struct e1000_hw *hw)
00541 {
00542         DEBUGFUNC("e1000_clear_hw_cntrs_82542");
00543 
00544         e1000_clear_hw_cntrs_base_generic(hw);
00545 
00546 #if 0
00547         E1000_READ_REG(hw, E1000_PRC64);
00548         E1000_READ_REG(hw, E1000_PRC127);
00549         E1000_READ_REG(hw, E1000_PRC255);
00550         E1000_READ_REG(hw, E1000_PRC511);
00551         E1000_READ_REG(hw, E1000_PRC1023);
00552         E1000_READ_REG(hw, E1000_PRC1522);
00553         E1000_READ_REG(hw, E1000_PTC64);
00554         E1000_READ_REG(hw, E1000_PTC127);
00555         E1000_READ_REG(hw, E1000_PTC255);
00556         E1000_READ_REG(hw, E1000_PTC511);
00557         E1000_READ_REG(hw, E1000_PTC1023);
00558         E1000_READ_REG(hw, E1000_PTC1522);
00559 #endif
00560 }
00561 
00562 static struct pci_device_id e1000_82542_nics[] = {
00563      PCI_ROM(0x8086, 0x1000, "E1000_DEV_ID_82542", "E1000_DEV_ID_82542", e1000_82542),
00564 };
00565 
00566 struct pci_driver e1000_82542_driver __pci_driver = {
00567         .ids = e1000_82542_nics,
00568         .id_count = (sizeof (e1000_82542_nics) / sizeof (e1000_82542_nics[0])),
00569         .probe = e1000_probe,
00570         .remove = e1000_remove,
00571 };

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