e1000e_80003es2lan.c

Go to the documentation of this file.
00001 /*******************************************************************************
00002 
00003   Intel PRO/1000 Linux driver
00004   Copyright(c) 1999 - 2009 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  * 80003ES2LAN Gigabit Ethernet Controller (Copper)
00033  * 80003ES2LAN Gigabit Ethernet Controller (Serdes)
00034  */
00035 
00036 #include "e1000e.h"
00037 
00038 static s32  e1000e_init_phy_params_80003es2lan(struct e1000_hw *hw);
00039 static s32  e1000e_init_nvm_params_80003es2lan(struct e1000_hw *hw);
00040 static s32  e1000e_init_mac_params_80003es2lan(struct e1000_hw *hw);
00041 static s32  e1000e_acquire_phy_80003es2lan(struct e1000_hw *hw);
00042 static void e1000e_release_phy_80003es2lan(struct e1000_hw *hw);
00043 static s32  e1000e_acquire_nvm_80003es2lan(struct e1000_hw *hw);
00044 static void e1000e_release_nvm_80003es2lan(struct e1000_hw *hw);
00045 static s32  e1000e_read_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw,
00046                                                    u32 offset,
00047                                                    u16 *data);
00048 static s32  e1000e_write_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw,
00049                                                     u32 offset,
00050                                                     u16 data);
00051 static s32  e1000e_write_nvm_80003es2lan(struct e1000_hw *hw, u16 offset,
00052                                         u16 words, u16 *data);
00053 static s32  e1000e_get_cfg_done_80003es2lan(struct e1000_hw *hw);
00054 #if 0
00055 static s32  e1000e_phy_force_speed_duplex_80003es2lan(struct e1000_hw *hw);
00056 #endif
00057 #if 0
00058 static s32  e1000e_get_cable_length_80003es2lan(struct e1000_hw *hw);
00059 #endif
00060 static s32  e1000e_get_link_up_info_80003es2lan(struct e1000_hw *hw, u16 *speed,
00061                                                u16 *duplex);
00062 static s32  e1000e_reset_hw_80003es2lan(struct e1000_hw *hw);
00063 static s32  e1000e_init_hw_80003es2lan(struct e1000_hw *hw);
00064 static s32  e1000e_setup_copper_link_80003es2lan(struct e1000_hw *hw);
00065 static void e1000e_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw);
00066 static s32  e1000e_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask);
00067 static s32  e1000e_cfg_kmrn_10_100_80003es2lan(struct e1000_hw *hw, u16 duplex);
00068 static s32  e1000e_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw);
00069 static s32  e1000e_cfg_on_link_up_80003es2lan(struct e1000_hw *hw);
00070 static s32  e1000e_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
00071                                             u16 *data);
00072 static s32  e1000e_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
00073                                              u16 data);
00074 static s32  e1000e_copper_link_setup_gg82563_80003es2lan(struct e1000_hw *hw);
00075 static void e1000e_initialize_hw_bits_80003es2lan(struct e1000_hw *hw);
00076 static void e1000e_release_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask);
00077 static s32  e1000e_read_mac_addr_80003es2lan(struct e1000_hw *hw);
00078 static void e1000e_power_down_phy_copper_80003es2lan(struct e1000_hw *hw);
00079 
00080 #if 0
00081 /*
00082  * A table for the GG82563 cable length where the range is defined
00083  * with a lower bound at "index" and the upper bound at
00084  * "index + 5".
00085  */
00086 static const u16 e1000_gg82563_cable_length_table[] =
00087          { 0, 60, 115, 150, 150, 60, 115, 150, 180, 180, 0xFF };
00088 #define GG82563_CABLE_LENGTH_TABLE_SIZE \
00089                 (sizeof(e1000_gg82563_cable_length_table) / \
00090                  sizeof(e1000_gg82563_cable_length_table[0]))
00091 #endif
00092 
00093 /**
00094  *  e1000e_init_phy_params_80003es2lan - Init ESB2 PHY func ptrs.
00095  *  @hw: pointer to the HW structure
00096  **/
00097 static s32 e1000e_init_phy_params_80003es2lan(struct e1000_hw *hw)
00098 {
00099         struct e1000_phy_info *phy = &hw->phy;
00100         s32 ret_val = E1000_SUCCESS;
00101 
00102         if (hw->phy.media_type != e1000_media_type_copper) {
00103                 phy->type        = e1000_phy_none;
00104                 goto out;
00105         } else {
00106                 phy->ops.power_up = e1000e_power_up_phy_copper;
00107                 phy->ops.power_down = e1000e_power_down_phy_copper_80003es2lan;
00108         }
00109 
00110         phy->addr                = 1;
00111         phy->autoneg_mask        = AUTONEG_ADVERTISE_SPEED_DEFAULT;
00112         phy->reset_delay_us      = 100;
00113         phy->type                = e1000_phy_gg82563;
00114 
00115         phy->ops.acquire            = e1000e_acquire_phy_80003es2lan;
00116         phy->ops.check_polarity     = e1000e_check_polarity_m88;
00117         phy->ops.check_reset_block  = e1000e_check_reset_block_generic;
00118         phy->ops.commit             = e1000e_phy_sw_reset;
00119         phy->ops.get_cfg_done       = e1000e_get_cfg_done_80003es2lan;
00120         phy->ops.get_info           = e1000e_get_phy_info_m88;
00121         phy->ops.release            = e1000e_release_phy_80003es2lan;
00122         phy->ops.reset              = e1000e_phy_hw_reset_generic;
00123         phy->ops.set_d3_lplu_state  = e1000e_set_d3_lplu_state;
00124 #if 0
00125         phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_80003es2lan;
00126 #endif
00127 #if 0
00128         phy->ops.get_cable_length   = e1000e_get_cable_length_80003es2lan;
00129 #endif
00130         phy->ops.read_reg           = e1000e_read_phy_reg_gg82563_80003es2lan;
00131         phy->ops.write_reg          = e1000e_write_phy_reg_gg82563_80003es2lan;
00132 
00133         phy->ops.cfg_on_link_up    = e1000e_cfg_on_link_up_80003es2lan;
00134 
00135         /* This can only be done after all function pointers are setup. */
00136         ret_val = e1000e_get_phy_id(hw);
00137 
00138         /* Verify phy id */
00139         if (phy->id != GG82563_E_PHY_ID) {
00140                 ret_val = -E1000_ERR_PHY;
00141                 goto out;
00142         }
00143 
00144 out:
00145         return ret_val;
00146 }
00147 
00148 /**
00149  *  e1000e_init_nvm_params_80003es2lan - Init ESB2 NVM func ptrs.
00150  *  @hw: pointer to the HW structure
00151  **/
00152 static s32 e1000e_init_nvm_params_80003es2lan(struct e1000_hw *hw)
00153 {
00154         struct e1000_nvm_info *nvm = &hw->nvm;
00155         u32 eecd = er32(EECD);
00156         u16 size;
00157 
00158         nvm->opcode_bits        = 8;
00159         nvm->delay_usec         = 1;
00160         switch (nvm->override) {
00161         case e1000_nvm_override_spi_large:
00162                 nvm->page_size    = 32;
00163                 nvm->address_bits = 16;
00164                 break;
00165         case e1000_nvm_override_spi_small:
00166                 nvm->page_size    = 8;
00167                 nvm->address_bits = 8;
00168                 break;
00169         default:
00170                 nvm->page_size    = eecd & E1000_EECD_ADDR_BITS ? 32 : 8;
00171                 nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ? 16 : 8;
00172                 break;
00173         }
00174 
00175         nvm->type               = e1000_nvm_eeprom_spi;
00176 
00177         size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >>
00178                           E1000_EECD_SIZE_EX_SHIFT);
00179 
00180         /*
00181          * Added to a constant, "size" becomes the left-shift value
00182          * for setting word_size.
00183          */
00184         size += NVM_WORD_SIZE_BASE_SHIFT;
00185 
00186         /* EEPROM access above 16k is unsupported */
00187         if (size > 14)
00188                 size = 14;
00189         nvm->word_size  = 1 << size;
00190 
00191         /* Function Pointers */
00192         nvm->ops.acquire           = e1000e_acquire_nvm_80003es2lan;
00193         nvm->ops.read              = e1000e_read_nvm_eerd;
00194         nvm->ops.release           = e1000e_release_nvm_80003es2lan;
00195         nvm->ops.update            = e1000e_update_nvm_checksum_generic;
00196         nvm->ops.valid_led_default = e1000e_valid_led_default;
00197         nvm->ops.validate          = e1000e_validate_nvm_checksum_generic;
00198         nvm->ops.write             = e1000e_write_nvm_80003es2lan;
00199 
00200         return E1000_SUCCESS;
00201 }
00202 
00203 /**
00204  *  e1000e_init_mac_params_80003es2lan - Init ESB2 MAC func ptrs.
00205  *  @hw: pointer to the HW structure
00206  **/
00207 static s32 e1000e_init_mac_params_80003es2lan(struct e1000_hw *hw)
00208 {
00209         struct e1000_mac_info *mac = &hw->mac;
00210         s32 ret_val = E1000_SUCCESS;
00211 
00212         /* Set media type */
00213         switch (hw->device_id) {
00214         case E1000_DEV_ID_80003ES2LAN_SERDES_DPT:
00215                 hw->phy.media_type = e1000_media_type_internal_serdes;
00216                 break;
00217         default:
00218                 hw->phy.media_type = e1000_media_type_copper;
00219                 break;
00220         }
00221 
00222         /* Set mta register count */
00223         mac->mta_reg_count = 128;
00224         /* Set rar entry count */
00225         mac->rar_entry_count = E1000_RAR_ENTRIES;
00226         /* Set if part includes ASF firmware */
00227         mac->asf_firmware_present = true;
00228         /* Set if manageability features are enabled. */
00229         mac->arc_subsystem_valid =
00230                 (er32(FWSM) & E1000_FWSM_MODE_MASK)
00231                         ? true : false;
00232 
00233         /* Function pointers */
00234 
00235         /* bus type/speed/width */
00236         mac->ops.get_bus_info = e1000e_get_bus_info_pcie;
00237         /* reset */
00238         mac->ops.reset_hw = e1000e_reset_hw_80003es2lan;
00239         /* hw initialization */
00240         mac->ops.init_hw = e1000e_init_hw_80003es2lan;
00241         /* link setup */
00242         mac->ops.setup_link = e1000e_setup_link;
00243         /* physical interface link setup */
00244         mac->ops.setup_physical_interface =
00245                 (hw->phy.media_type == e1000_media_type_copper)
00246                         ? e1000e_setup_copper_link_80003es2lan
00247                         : e1000e_setup_fiber_serdes_link;
00248         /* check for link */
00249         switch (hw->phy.media_type) {
00250         case e1000_media_type_copper:
00251                 mac->ops.check_for_link = e1000e_check_for_copper_link;
00252                 break;
00253         case e1000_media_type_fiber:
00254                 mac->ops.check_for_link = e1000e_check_for_fiber_link;
00255                 break;
00256         case e1000_media_type_internal_serdes:
00257                 mac->ops.check_for_link = e1000e_check_for_serdes_link;
00258                 break;
00259         default:
00260                 ret_val = -E1000_ERR_CONFIG;
00261                 goto out;
00262                 break;
00263         }
00264         /* check management mode */
00265 #if 0
00266         mac->ops.check_mng_mode = e1000e_check_mng_mode_generic;
00267 #endif
00268         /* multicast address update */
00269         mac->ops.update_mc_addr_list = e1000e_update_mc_addr_list_generic;
00270         /* writing VFTA */
00271         mac->ops.write_vfta = e1000e_write_vfta_generic;
00272         /* clearing VFTA */
00273         mac->ops.clear_vfta = e1000e_clear_vfta_generic;
00274         /* setting MTA */
00275         mac->ops.mta_set = e1000e_mta_set_generic;
00276         /* read mac address */
00277         mac->ops.read_mac_addr = e1000e_read_mac_addr_80003es2lan;
00278         /* ID LED init */
00279         mac->ops.id_led_init = e1000e_id_led_init;
00280         /* blink LED */
00281         mac->ops.blink_led = e1000e_blink_led;
00282         /* setup LED */
00283         mac->ops.setup_led = e1000e_setup_led_generic;
00284         /* cleanup LED */
00285         mac->ops.cleanup_led = e1000e_cleanup_led_generic;
00286         /* turn on/off LED */
00287         mac->ops.led_on = e1000e_led_on_generic;
00288         mac->ops.led_off = e1000e_led_off_generic;
00289         /* clear hardware counters */
00290         mac->ops.clear_hw_cntrs = e1000e_clear_hw_cntrs_80003es2lan;
00291         /* link info */
00292         mac->ops.get_link_up_info = e1000e_get_link_up_info_80003es2lan;
00293 
00294         /* set lan id for port to determine which phy lock to use */
00295         hw->mac.ops.set_lan_id(hw);
00296 
00297 out:
00298         return ret_val;
00299 }
00300 
00301 /**
00302  *  e1000e_init_function_pointers_80003es2lan - Init ESB2 func ptrs.
00303  *  @hw: pointer to the HW structure
00304  *
00305  *  Called to initialize all function pointers and parameters.
00306  **/
00307 void e1000e_init_function_pointers_80003es2lan(struct e1000_hw *hw)
00308 {
00309         e1000e_init_mac_ops_generic(hw);
00310         e1000e_init_nvm_ops_generic(hw);
00311         hw->mac.ops.init_params = e1000e_init_mac_params_80003es2lan;
00312         hw->nvm.ops.init_params = e1000e_init_nvm_params_80003es2lan;
00313         hw->phy.ops.init_params = e1000e_init_phy_params_80003es2lan;
00314 }
00315 
00316 /**
00317  *  e1000e_acquire_phy_80003es2lan - Acquire rights to access PHY
00318  *  @hw: pointer to the HW structure
00319  *
00320  *  A wrapper to acquire access rights to the correct PHY.
00321  **/
00322 static s32 e1000e_acquire_phy_80003es2lan(struct e1000_hw *hw)
00323 {
00324         u16 mask;
00325 
00326         mask = hw->bus.func ? E1000_SWFW_PHY1_SM : E1000_SWFW_PHY0_SM;
00327         return e1000e_acquire_swfw_sync_80003es2lan(hw, mask);
00328 }
00329 
00330 /**
00331  *  e1000e_release_phy_80003es2lan - Release rights to access PHY
00332  *  @hw: pointer to the HW structure
00333  *
00334  *  A wrapper to release access rights to the correct PHY.
00335  **/
00336 static void e1000e_release_phy_80003es2lan(struct e1000_hw *hw)
00337 {
00338         u16 mask;
00339 
00340         mask = hw->bus.func ? E1000_SWFW_PHY1_SM : E1000_SWFW_PHY0_SM;
00341         e1000e_release_swfw_sync_80003es2lan(hw, mask);
00342 }
00343 
00344 /**
00345  *  e1000e_acquire_mac_csr_80003es2lan - Acquire rights to access Kumeran register
00346  *  @hw: pointer to the HW structure
00347  *
00348  *  Acquire the semaphore to access the Kumeran interface.
00349  *
00350  **/
00351 static s32 e1000e_acquire_mac_csr_80003es2lan(struct e1000_hw *hw)
00352 {
00353         u16 mask;
00354 
00355         mask = E1000_SWFW_CSR_SM;
00356 
00357         return e1000e_acquire_swfw_sync_80003es2lan(hw, mask);
00358 }
00359 
00360 /**
00361  *  e1000e_release_mac_csr_80003es2lan - Release rights to access Kumeran Register
00362  *  @hw: pointer to the HW structure
00363  *
00364  *  Release the semaphore used to access the Kumeran interface
00365  **/
00366 static void e1000e_release_mac_csr_80003es2lan(struct e1000_hw *hw)
00367 {
00368         u16 mask;
00369 
00370         mask = E1000_SWFW_CSR_SM;
00371 
00372         e1000e_release_swfw_sync_80003es2lan(hw, mask);
00373 }
00374 
00375 /**
00376  *  e1000e_acquire_nvm_80003es2lan - Acquire rights to access NVM
00377  *  @hw: pointer to the HW structure
00378  *
00379  *  Acquire the semaphore to access the EEPROM.
00380  **/
00381 static s32 e1000e_acquire_nvm_80003es2lan(struct e1000_hw *hw)
00382 {
00383         s32 ret_val;
00384 
00385         ret_val = e1000e_acquire_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM);
00386         if (ret_val)
00387                 goto out;
00388 
00389         ret_val = e1000e_acquire_nvm(hw);
00390 
00391         if (ret_val)
00392                 e1000e_release_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM);
00393 
00394 out:
00395         return ret_val;
00396 }
00397 
00398 /**
00399  *  e1000e_release_nvm_80003es2lan - Relinquish rights to access NVM
00400  *  @hw: pointer to the HW structure
00401  *
00402  *  Release the semaphore used to access the EEPROM.
00403  **/
00404 static void e1000e_release_nvm_80003es2lan(struct e1000_hw *hw)
00405 {
00406         e1000e_release_nvm(hw);
00407         e1000e_release_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM);
00408 }
00409 
00410 /**
00411  *  e1000e_acquire_swfw_sync_80003es2lan - Acquire SW/FW semaphore
00412  *  @hw: pointer to the HW structure
00413  *  @mask: specifies which semaphore to acquire
00414  *
00415  *  Acquire the SW/FW semaphore to access the PHY or NVM.  The mask
00416  *  will also specify which port we're acquiring the lock for.
00417  **/
00418 static s32 e1000e_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask)
00419 {
00420         u32 swfw_sync;
00421         u32 swmask = mask;
00422         u32 fwmask = mask << 16;
00423         s32 ret_val = E1000_SUCCESS;
00424         s32 i = 0, timeout = 50;
00425 
00426         while (i < timeout) {
00427                 if (e1000e_get_hw_semaphore(hw)) {
00428                         ret_val = -E1000_ERR_SWFW_SYNC;
00429                         goto out;
00430                 }
00431 
00432                 swfw_sync = er32(SW_FW_SYNC);
00433                 if (!(swfw_sync & (fwmask | swmask)))
00434                         break;
00435 
00436                 /*
00437                  * Firmware currently using resource (fwmask)
00438                  * or other software thread using resource (swmask)
00439                  */
00440                 e1000e_put_hw_semaphore(hw);
00441                 mdelay(5);
00442                 i++;
00443         }
00444 
00445         if (i == timeout) {
00446                 e_dbg("Driver can't access resource, SW_FW_SYNC timeout.\n");
00447                 ret_val = -E1000_ERR_SWFW_SYNC;
00448                 goto out;
00449         }
00450 
00451         swfw_sync |= swmask;
00452         ew32(SW_FW_SYNC, swfw_sync);
00453 
00454         e1000e_put_hw_semaphore(hw);
00455 
00456 out:
00457         return ret_val;
00458 }
00459 
00460 /**
00461  *  e1000e_release_swfw_sync_80003es2lan - Release SW/FW semaphore
00462  *  @hw: pointer to the HW structure
00463  *  @mask: specifies which semaphore to acquire
00464  *
00465  *  Release the SW/FW semaphore used to access the PHY or NVM.  The mask
00466  *  will also specify which port we're releasing the lock for.
00467  **/
00468 static void e1000e_release_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask)
00469 {
00470         u32 swfw_sync;
00471 
00472         while (e1000e_get_hw_semaphore(hw) != E1000_SUCCESS)
00473                 ; /* Empty */
00474 
00475         swfw_sync = er32(SW_FW_SYNC);
00476         swfw_sync &= ~mask;
00477         ew32(SW_FW_SYNC, swfw_sync);
00478 
00479         e1000e_put_hw_semaphore(hw);
00480 }
00481 
00482 /**
00483  *  e1000e_read_phy_reg_gg82563_80003es2lan - Read GG82563 PHY register
00484  *  @hw: pointer to the HW structure
00485  *  @offset: offset of the register to read
00486  *  @data: pointer to the data returned from the operation
00487  *
00488  *  Read the GG82563 PHY register.
00489  **/
00490 static s32 e1000e_read_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw,
00491                                                   u32 offset, u16 *data)
00492 {
00493         s32 ret_val;
00494         u32 page_select;
00495         u16 temp;
00496 
00497         ret_val = e1000e_acquire_phy_80003es2lan(hw);
00498         if (ret_val)
00499                 goto out;
00500 
00501         /* Select Configuration Page */
00502         if ((offset & MAX_PHY_REG_ADDRESS) < GG82563_MIN_ALT_REG) {
00503                 page_select = GG82563_PHY_PAGE_SELECT;
00504         } else {
00505                 /*
00506                  * Use Alternative Page Select register to access
00507                  * registers 30 and 31
00508                  */
00509                 page_select = GG82563_PHY_PAGE_SELECT_ALT;
00510         }
00511 
00512         temp = (u16)((u16)offset >> GG82563_PAGE_SHIFT);
00513         ret_val = e1000e_write_phy_reg_mdic(hw, page_select, temp);
00514         if (ret_val) {
00515                 e1000e_release_phy_80003es2lan(hw);
00516                 goto out;
00517         }
00518 
00519         if (hw->dev_spec._80003es2lan.mdic_wa_enable == true) {
00520                 /*
00521                  * The "ready" bit in the MDIC register may be incorrectly set
00522                  * before the device has completed the "Page Select" MDI
00523                  * transaction.  So we wait 200us after each MDI command...
00524                  */
00525                 udelay(200);
00526 
00527                 /* ...and verify the command was successful. */
00528                 ret_val = e1000e_read_phy_reg_mdic(hw, page_select, &temp);
00529 
00530                 if (((u16)offset >> GG82563_PAGE_SHIFT) != temp) {
00531                         ret_val = -E1000_ERR_PHY;
00532                         e1000e_release_phy_80003es2lan(hw);
00533                         goto out;
00534                 }
00535 
00536                 udelay(200);
00537 
00538                 ret_val = e1000e_read_phy_reg_mdic(hw,
00539                                                   MAX_PHY_REG_ADDRESS & offset,
00540                                                   data);
00541 
00542                 udelay(200);
00543         } else
00544                 ret_val = e1000e_read_phy_reg_mdic(hw,
00545                                                   MAX_PHY_REG_ADDRESS & offset,
00546                                                   data);
00547 
00548         e1000e_release_phy_80003es2lan(hw);
00549 
00550 out:
00551         return ret_val;
00552 }
00553 
00554 /**
00555  *  e1000e_write_phy_reg_gg82563_80003es2lan - Write GG82563 PHY register
00556  *  @hw: pointer to the HW structure
00557  *  @offset: offset of the register to read
00558  *  @data: value to write to the register
00559  *
00560  *  Write to the GG82563 PHY register.
00561  **/
00562 static s32 e1000e_write_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw,
00563                                                    u32 offset, u16 data)
00564 {
00565         s32 ret_val;
00566         u32 page_select;
00567         u16 temp;
00568 
00569         ret_val = e1000e_acquire_phy_80003es2lan(hw);
00570         if (ret_val)
00571                 goto out;
00572 
00573         /* Select Configuration Page */
00574         if ((offset & MAX_PHY_REG_ADDRESS) < GG82563_MIN_ALT_REG) {
00575                 page_select = GG82563_PHY_PAGE_SELECT;
00576         } else {
00577                 /*
00578                  * Use Alternative Page Select register to access
00579                  * registers 30 and 31
00580                  */
00581                 page_select = GG82563_PHY_PAGE_SELECT_ALT;
00582         }
00583 
00584         temp = (u16)((u16)offset >> GG82563_PAGE_SHIFT);
00585         ret_val = e1000e_write_phy_reg_mdic(hw, page_select, temp);
00586         if (ret_val) {
00587                 e1000e_release_phy_80003es2lan(hw);
00588                 goto out;
00589         }
00590 
00591         if (hw->dev_spec._80003es2lan.mdic_wa_enable == true) {
00592                 /*
00593                  * The "ready" bit in the MDIC register may be incorrectly set
00594                  * before the device has completed the "Page Select" MDI
00595                  * transaction.  So we wait 200us after each MDI command...
00596                  */
00597                 udelay(200);
00598 
00599                 /* ...and verify the command was successful. */
00600                 ret_val = e1000e_read_phy_reg_mdic(hw, page_select, &temp);
00601 
00602                 if (((u16)offset >> GG82563_PAGE_SHIFT) != temp) {
00603                         ret_val = -E1000_ERR_PHY;
00604                         e1000e_release_phy_80003es2lan(hw);
00605                         goto out;
00606                 }
00607 
00608                 udelay(200);
00609 
00610                 ret_val = e1000e_write_phy_reg_mdic(hw,
00611                                                   MAX_PHY_REG_ADDRESS & offset,
00612                                                   data);
00613 
00614                 udelay(200);
00615         } else
00616                 ret_val = e1000e_write_phy_reg_mdic(hw,
00617                                                   MAX_PHY_REG_ADDRESS & offset,
00618                 data);
00619 
00620         e1000e_release_phy_80003es2lan(hw);
00621 
00622 out:
00623         return ret_val;
00624 }
00625 
00626 /**
00627  *  e1000e_write_nvm_80003es2lan - Write to ESB2 NVM
00628  *  @hw: pointer to the HW structure
00629  *  @offset: offset of the register to read
00630  *  @words: number of words to write
00631  *  @data: buffer of data to write to the NVM
00632  *
00633  *  Write "words" of data to the ESB2 NVM.
00634  **/
00635 static s32 e1000e_write_nvm_80003es2lan(struct e1000_hw *hw, u16 offset,
00636                             u16 words, u16 *data)
00637 {
00638         return e1000e_write_nvm_spi(hw, offset, words, data);
00639 }
00640 
00641 /**
00642  *  e1000e_get_cfg_done_80003es2lan - Wait for configuration to complete
00643  *  @hw: pointer to the HW structure
00644  *
00645  *  Wait a specific amount of time for manageability processes to complete.
00646  *  This is a function pointer entry point called by the phy module.
00647  **/
00648 static s32 e1000e_get_cfg_done_80003es2lan(struct e1000_hw *hw)
00649 {
00650         s32 timeout = PHY_CFG_TIMEOUT;
00651         s32 ret_val = E1000_SUCCESS;
00652         u32 mask = E1000_NVM_CFG_DONE_PORT_0;
00653 
00654         if (hw->bus.func == 1)
00655                 mask = E1000_NVM_CFG_DONE_PORT_1;
00656 
00657         while (timeout) {
00658                 if (er32(EEMNGCTL) & mask)
00659                         break;
00660                 msleep(1);
00661                 timeout--;
00662         }
00663         if (!timeout) {
00664                 e_dbg("MNG configuration cycle has not completed.\n");
00665                 ret_val = -E1000_ERR_RESET;
00666                 goto out;
00667         }
00668 
00669 out:
00670         return ret_val;
00671 }
00672 #if 0
00673 /**
00674  *  e1000e_phy_force_speed_duplex_80003es2lan - Force PHY speed and duplex
00675  *  @hw: pointer to the HW structure
00676  *
00677  *  Force the speed and duplex settings onto the PHY.  This is a
00678  *  function pointer entry point called by the phy module.
00679  **/
00680 static s32 e1000e_phy_force_speed_duplex_80003es2lan(struct e1000_hw *hw)
00681 {
00682         s32 ret_val = E1000_SUCCESS;
00683         u16 phy_data;
00684         bool link;
00685 
00686         if (!(hw->phy.ops.read_reg))
00687                 goto out;
00688 
00689         /*
00690          * Clear Auto-Crossover to force MDI manually.  M88E1000 requires MDI
00691          * forced whenever speed and duplex are forced.
00692          */
00693         ret_val = e1e_rphy(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
00694         if (ret_val)
00695                 goto out;
00696 
00697         phy_data &= ~GG82563_PSCR_CROSSOVER_MODE_AUTO;
00698         ret_val = e1e_wphy(hw, GG82563_PHY_SPEC_CTRL, phy_data);
00699         if (ret_val)
00700                 goto out;
00701 
00702         e_dbg("GG82563 PSCR: %X\n", phy_data);
00703 
00704         ret_val = e1e_rphy(hw, PHY_CONTROL, &phy_data);
00705         if (ret_val)
00706                 goto out;
00707 
00708         e1000e_phy_force_speed_duplex_setup(hw, &phy_data);
00709 
00710         /* Reset the phy to commit changes. */
00711         phy_data |= MII_CR_RESET;
00712 
00713         ret_val = e1e_wphy(hw, PHY_CONTROL, phy_data);
00714         if (ret_val)
00715                 goto out;
00716 
00717         udelay(1);
00718 
00719         if (hw->phy.autoneg_wait_to_complete) {
00720                 e_dbg("Waiting for forced speed/duplex link "
00721                          "on GG82563 phy.\n");
00722 
00723                 ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT,
00724                                                      100000, &link);
00725                 if (ret_val)
00726                         goto out;
00727 
00728                 if (!link) {
00729                         /*
00730                          * We didn't get link.
00731                          * Reset the DSP and cross our fingers.
00732                          */
00733                         ret_val = e1000e_phy_reset_dsp(hw);
00734                         if (ret_val)
00735                                 goto out;
00736                 }
00737 
00738                 /* Try once more */
00739                 ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT,
00740                                                      100000, &link);
00741                 if (ret_val)
00742                         goto out;
00743         }
00744 
00745         ret_val = e1e_rphy(hw, GG82563_PHY_MAC_SPEC_CTRL, &phy_data);
00746         if (ret_val)
00747                 goto out;
00748 
00749         /*
00750          * Resetting the phy means we need to verify the TX_CLK corresponds
00751          * to the link speed.  10Mbps -> 2.5MHz, else 25MHz.
00752          */
00753         phy_data &= ~GG82563_MSCR_TX_CLK_MASK;
00754         if (hw->mac.forced_speed_duplex & E1000_ALL_10_SPEED)
00755                 phy_data |= GG82563_MSCR_TX_CLK_10MBPS_2_5;
00756         else
00757                 phy_data |= GG82563_MSCR_TX_CLK_100MBPS_25;
00758 
00759         /*
00760          * In addition, we must re-enable CRS on Tx for both half and full
00761          * duplex.
00762          */
00763         phy_data |= GG82563_MSCR_ASSERT_CRS_ON_TX;
00764         ret_val = e1e_wphy(hw, GG82563_PHY_MAC_SPEC_CTRL, phy_data);
00765 
00766 out:
00767         return ret_val;
00768 }
00769 #endif
00770 
00771 #if 0
00772 /**
00773  *  e1000e_get_cable_length_80003es2lan - Set approximate cable length
00774  *  @hw: pointer to the HW structure
00775  *
00776  *  Find the approximate cable length as measured by the GG82563 PHY.
00777  *  This is a function pointer entry point called by the phy module.
00778  **/
00779 static s32 e1000e_get_cable_length_80003es2lan(struct e1000_hw *hw)
00780 {
00781         struct e1000_phy_info *phy = &hw->phy;
00782         s32 ret_val = E1000_SUCCESS;
00783         u16 phy_data, index;
00784 
00785         if (!(hw->phy.ops.read_reg))
00786                 goto out;
00787 
00788         ret_val = e1e_rphy(hw, GG82563_PHY_DSP_DISTANCE, &phy_data);
00789         if (ret_val)
00790                 goto out;
00791 
00792         index = phy_data & GG82563_DSPD_CABLE_LENGTH;
00793 
00794         if (index >= GG82563_CABLE_LENGTH_TABLE_SIZE - 5) {
00795                 ret_val = -E1000_ERR_PHY;
00796                 goto out;
00797         }
00798 
00799         phy->min_cable_length = e1000_gg82563_cable_length_table[index];
00800         phy->max_cable_length = e1000_gg82563_cable_length_table[index + 5];
00801 
00802         phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2;
00803 
00804 out:
00805         return ret_val;
00806 }
00807 #endif
00808 
00809 /**
00810  *  e1000e_get_link_up_info_80003es2lan - Report speed and duplex
00811  *  @hw: pointer to the HW structure
00812  *  @speed: pointer to speed buffer
00813  *  @duplex: pointer to duplex buffer
00814  *
00815  *  Retrieve the current speed and duplex configuration.
00816  **/
00817 static s32 e1000e_get_link_up_info_80003es2lan(struct e1000_hw *hw, u16 *speed,
00818                                               u16 *duplex)
00819 {
00820         s32 ret_val;
00821 
00822         if (hw->phy.media_type == e1000_media_type_copper) {
00823                 ret_val = e1000e_get_speed_and_duplex_copper(hw,
00824                                                                     speed,
00825                                                                     duplex);
00826                 hw->phy.ops.cfg_on_link_up(hw);
00827         } else {
00828                 ret_val = e1000e_get_speed_and_duplex_fiber_serdes(hw,
00829                                                                   speed,
00830                                                                   duplex);
00831         }
00832 
00833         return ret_val;
00834 }
00835 
00836 /**
00837  *  e1000e_reset_hw_80003es2lan - Reset the ESB2 controller
00838  *  @hw: pointer to the HW structure
00839  *
00840  *  Perform a global reset to the ESB2 controller.
00841  **/
00842 static s32 e1000e_reset_hw_80003es2lan(struct e1000_hw *hw)
00843 {
00844         u32 ctrl, icr;
00845         s32 ret_val;
00846 
00847         /*
00848          * Prevent the PCI-E bus from sticking if there is no TLP connection
00849          * on the last TLP read/write transaction when MAC is reset.
00850          */
00851         ret_val = e1000e_disable_pcie_master(hw);
00852         if (ret_val)
00853                 e_dbg("PCI-E Master disable polling has failed.\n");
00854 
00855         e_dbg("Masking off all interrupts\n");
00856         ew32(IMC, 0xffffffff);
00857 
00858         ew32(RCTL, 0);
00859         ew32(TCTL, E1000_TCTL_PSP);
00860         e1e_flush();
00861 
00862         msleep(10);
00863 
00864         ctrl = er32(CTRL);
00865 
00866         ret_val = e1000e_acquire_phy_80003es2lan(hw);
00867         e_dbg("Issuing a global reset to MAC\n");
00868         ew32(CTRL, ctrl | E1000_CTRL_RST);
00869         e1000e_release_phy_80003es2lan(hw);
00870 
00871         ret_val = e1000e_get_auto_rd_done(hw);
00872         if (ret_val)
00873                 /* We don't want to continue accessing MAC registers. */
00874                 goto out;
00875 
00876         /* Clear any pending interrupt events. */
00877         ew32(IMC, 0xffffffff);
00878         icr = er32(ICR);
00879 
00880         ret_val = e1000e_check_alt_mac_addr_generic(hw);
00881 
00882 out:
00883         return ret_val;
00884 }
00885 
00886 /**
00887  *  e1000e_init_hw_80003es2lan - Initialize the ESB2 controller
00888  *  @hw: pointer to the HW structure
00889  *
00890  *  Initialize the hw bits, LED, VFTA, MTA, link and hw counters.
00891  **/
00892 static s32 e1000e_init_hw_80003es2lan(struct e1000_hw *hw)
00893 {
00894         struct e1000_mac_info *mac = &hw->mac;
00895         u32 reg_data;
00896         s32 ret_val;
00897         u16 i;
00898 
00899         e1000e_initialize_hw_bits_80003es2lan(hw);
00900 
00901         /* Initialize identification LED */
00902         ret_val = mac->ops.id_led_init(hw);
00903         if (ret_val) {
00904                 e_dbg("Error initializing identification LED\n");
00905                 /* This is not fatal and we should not stop init due to this */
00906         }
00907 
00908         /* Disabling VLAN filtering */
00909         e_dbg("Initializing the IEEE VLAN\n");
00910         e1000e_clear_vfta(hw);
00911 
00912         /* Setup the receive address. */
00913         e1000e_init_rx_addrs(hw, mac->rar_entry_count);
00914 
00915         /* Zero out the Multicast HASH table */
00916         e_dbg("Zeroing the MTA\n");
00917         for (i = 0; i < mac->mta_reg_count; i++)
00918                 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
00919 
00920         /* Setup link and flow control */
00921         ret_val = mac->ops.setup_link(hw);
00922 
00923         /* Set the transmit descriptor write-back policy */
00924         reg_data = er32(TXDCTL(0));
00925         reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) |
00926                    E1000_TXDCTL_FULL_TX_DESC_WB | E1000_TXDCTL_COUNT_DESC;
00927         ew32(TXDCTL(0), reg_data);
00928 
00929         /* ...for both queues. */
00930         reg_data = er32(TXDCTL(1));
00931         reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) |
00932                    E1000_TXDCTL_FULL_TX_DESC_WB | E1000_TXDCTL_COUNT_DESC;
00933         ew32(TXDCTL(1), reg_data);
00934 
00935         /* Enable retransmit on late collisions */
00936         reg_data = er32(TCTL);
00937         reg_data |= E1000_TCTL_RTLC;
00938         ew32(TCTL, reg_data);
00939 
00940         /* Configure Gigabit Carry Extend Padding */
00941         reg_data = er32(TCTL_EXT);
00942         reg_data &= ~E1000_TCTL_EXT_GCEX_MASK;
00943         reg_data |= DEFAULT_TCTL_EXT_GCEX_80003ES2LAN;
00944         ew32(TCTL_EXT, reg_data);
00945 
00946         /* Configure Transmit Inter-Packet Gap */
00947         reg_data = er32(TIPG);
00948         reg_data &= ~E1000_TIPG_IPGT_MASK;
00949         reg_data |= DEFAULT_TIPG_IPGT_1000_80003ES2LAN;
00950         ew32(TIPG, reg_data);
00951 
00952         reg_data = E1000_READ_REG_ARRAY(hw, E1000_FFLT, 0x0001);
00953         reg_data &= ~0x00100000;
00954         E1000_WRITE_REG_ARRAY(hw, E1000_FFLT, 0x0001, reg_data);
00955 
00956         /* default to true to enable the MDIC W/A */
00957         hw->dev_spec._80003es2lan.mdic_wa_enable = true;
00958 
00959         ret_val = e1000e_read_kmrn_reg_80003es2lan(hw,
00960                                       E1000_KMRNCTRLSTA_OFFSET >>
00961                                       E1000_KMRNCTRLSTA_OFFSET_SHIFT,
00962                                       &i);
00963         if (!ret_val) {
00964                 if ((i & E1000_KMRNCTRLSTA_OPMODE_MASK) ==
00965                      E1000_KMRNCTRLSTA_OPMODE_INBAND_MDIO)
00966                         hw->dev_spec._80003es2lan.mdic_wa_enable = false;
00967         }
00968 
00969         /*
00970          * Clear all of the statistics registers (clear on read).  It is
00971          * important that we do this after we have tried to establish link
00972          * because the symbol error count will increment wildly if there
00973          * is no link.
00974          */
00975         e1000e_clear_hw_cntrs_80003es2lan(hw);
00976 
00977         return ret_val;
00978 }
00979 
00980 /**
00981  *  e1000e_initialize_hw_bits_80003es2lan - Init hw bits of ESB2
00982  *  @hw: pointer to the HW structure
00983  *
00984  *  Initializes required hardware-dependent bits needed for normal operation.
00985  **/
00986 static void e1000e_initialize_hw_bits_80003es2lan(struct e1000_hw *hw)
00987 {
00988         u32 reg;
00989 
00990         /* Transmit Descriptor Control 0 */
00991         reg = er32(TXDCTL(0));
00992         reg |= (1 << 22);
00993         ew32(TXDCTL(0), reg);
00994 
00995         /* Transmit Descriptor Control 1 */
00996         reg = er32(TXDCTL(1));
00997         reg |= (1 << 22);
00998         ew32(TXDCTL(1), reg);
00999 
01000         /* Transmit Arbitration Control 0 */
01001         reg = er32(TARC(0));
01002         reg &= ~(0xF << 27); /* 30:27 */
01003         if (hw->phy.media_type != e1000_media_type_copper)
01004                 reg &= ~(1 << 20);
01005         ew32(TARC(0), reg);
01006 
01007         /* Transmit Arbitration Control 1 */
01008         reg = er32(TARC(1));
01009         if (er32(TCTL) & E1000_TCTL_MULR)
01010                 reg &= ~(1 << 28);
01011         else
01012                 reg |= (1 << 28);
01013         ew32(TARC(1), reg);
01014 
01015         return;
01016 }
01017 
01018 /**
01019  *  e1000e_copper_link_setup_gg82563_80003es2lan - Configure GG82563 Link
01020  *  @hw: pointer to the HW structure
01021  *
01022  *  Setup some GG82563 PHY registers for obtaining link
01023  **/
01024 static s32 e1000e_copper_link_setup_gg82563_80003es2lan(struct e1000_hw *hw)
01025 {
01026         struct e1000_phy_info *phy = &hw->phy;
01027         s32 ret_val;
01028         u32 ctrl_ext;
01029         u16 data;
01030 
01031         if (!phy->reset_disable) {
01032                 ret_val = e1e_rphy(hw, GG82563_PHY_MAC_SPEC_CTRL,
01033                                              &data);
01034                 if (ret_val)
01035                         goto out;
01036 
01037                 data |= GG82563_MSCR_ASSERT_CRS_ON_TX;
01038                 /* Use 25MHz for both link down and 1000Base-T for Tx clock. */
01039                 data |= GG82563_MSCR_TX_CLK_1000MBPS_25;
01040 
01041                 ret_val = e1e_wphy(hw, GG82563_PHY_MAC_SPEC_CTRL,
01042                                               data);
01043                 if (ret_val)
01044                         goto out;
01045 
01046                 /*
01047                  * Options:
01048                  *   MDI/MDI-X = 0 (default)
01049                  *   0 - Auto for all speeds
01050                  *   1 - MDI mode
01051                  *   2 - MDI-X mode
01052                  *   3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes)
01053                  */
01054                 ret_val = e1e_rphy(hw, GG82563_PHY_SPEC_CTRL, &data);
01055                 if (ret_val)
01056                         goto out;
01057 
01058                 data &= ~GG82563_PSCR_CROSSOVER_MODE_MASK;
01059 
01060                 switch (phy->mdix) {
01061                 case 1:
01062                         data |= GG82563_PSCR_CROSSOVER_MODE_MDI;
01063                         break;
01064                 case 2:
01065                         data |= GG82563_PSCR_CROSSOVER_MODE_MDIX;
01066                         break;
01067                 case 0:
01068                 default:
01069                         data |= GG82563_PSCR_CROSSOVER_MODE_AUTO;
01070                         break;
01071                 }
01072 
01073                 /*
01074                  * Options:
01075                  *   disable_polarity_correction = 0 (default)
01076                  *       Automatic Correction for Reversed Cable Polarity
01077                  *   0 - Disabled
01078                  *   1 - Enabled
01079                  */
01080                 data &= ~GG82563_PSCR_POLARITY_REVERSAL_DISABLE;
01081                 if (phy->disable_polarity_correction)
01082                         data |= GG82563_PSCR_POLARITY_REVERSAL_DISABLE;
01083 
01084                 ret_val = e1e_wphy(hw, GG82563_PHY_SPEC_CTRL, data);
01085                 if (ret_val)
01086                         goto out;
01087 
01088                 /* SW Reset the PHY so all changes take effect */
01089                 ret_val = e1000e_commit_phy(hw);
01090                 if (ret_val) {
01091                         e_dbg("Error Resetting the PHY\n");
01092                         goto out;
01093                 }
01094 
01095         }
01096 
01097         /* Bypass Rx and Tx FIFO's */
01098         ret_val = e1000e_write_kmrn_reg_80003es2lan(hw,
01099                                         E1000_KMRNCTRLSTA_OFFSET_FIFO_CTRL,
01100                                         E1000_KMRNCTRLSTA_FIFO_CTRL_RX_BYPASS |
01101                                         E1000_KMRNCTRLSTA_FIFO_CTRL_TX_BYPASS);
01102         if (ret_val)
01103                 goto out;
01104 
01105         ret_val = e1000e_read_kmrn_reg_80003es2lan(hw,
01106                                       E1000_KMRNCTRLSTA_OFFSET_MAC2PHY_OPMODE,
01107                                       &data);
01108         if (ret_val)
01109                 goto out;
01110         data |= E1000_KMRNCTRLSTA_OPMODE_E_IDLE;
01111         ret_val = e1000e_write_kmrn_reg_80003es2lan(hw,
01112                                        E1000_KMRNCTRLSTA_OFFSET_MAC2PHY_OPMODE,
01113                                        data);
01114         if (ret_val)
01115                 goto out;
01116 
01117         ret_val = e1e_rphy(hw, GG82563_PHY_SPEC_CTRL_2, &data);
01118         if (ret_val)
01119                 goto out;
01120 
01121         data &= ~GG82563_PSCR2_REVERSE_AUTO_NEG;
01122         ret_val = e1e_wphy(hw, GG82563_PHY_SPEC_CTRL_2, data);
01123         if (ret_val)
01124                 goto out;
01125 
01126         ctrl_ext = er32(CTRL_EXT);
01127         ctrl_ext &= ~(E1000_CTRL_EXT_LINK_MODE_MASK);
01128         ew32(CTRL_EXT, ctrl_ext);
01129 
01130         ret_val = e1e_rphy(hw, GG82563_PHY_PWR_MGMT_CTRL, &data);
01131         if (ret_val)
01132                 goto out;
01133 
01134         /*
01135          * Do not init these registers when the HW is in IAMT mode, since the
01136          * firmware will have already initialized them.  We only initialize
01137          * them if the HW is not in IAMT mode.
01138          */
01139         if (!(hw->mac.ops.check_mng_mode(hw))) {
01140                 /* Enable Electrical Idle on the PHY */
01141                 data |= GG82563_PMCR_ENABLE_ELECTRICAL_IDLE;
01142                 ret_val = e1e_wphy(hw, GG82563_PHY_PWR_MGMT_CTRL,
01143                                                 data);
01144                 if (ret_val)
01145                         goto out;
01146 
01147                 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL,
01148                                                &data);
01149                 if (ret_val)
01150                         goto out;
01151 
01152                 data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
01153                 ret_val = e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL,
01154                                                 data);
01155                 if (ret_val)
01156                         goto out;
01157         }
01158 
01159         /*
01160          * Workaround: Disable padding in Kumeran interface in the MAC
01161          * and in the PHY to avoid CRC errors.
01162          */
01163         ret_val = e1e_rphy(hw, GG82563_PHY_INBAND_CTRL, &data);
01164         if (ret_val)
01165                 goto out;
01166 
01167         data |= GG82563_ICR_DIS_PADDING;
01168         ret_val = e1e_wphy(hw, GG82563_PHY_INBAND_CTRL, data);
01169         if (ret_val)
01170                 goto out;
01171 
01172 out:
01173         return ret_val;
01174 }
01175 
01176 /**
01177  *  e1000e_setup_copper_link_80003es2lan - Setup Copper Link for ESB2
01178  *  @hw: pointer to the HW structure
01179  *
01180  *  Essentially a wrapper for setting up all things "copper" related.
01181  *  This is a function pointer entry point called by the mac module.
01182  **/
01183 static s32 e1000e_setup_copper_link_80003es2lan(struct e1000_hw *hw)
01184 {
01185         u32 ctrl;
01186         s32 ret_val;
01187         u16 reg_data;
01188 
01189         ctrl = er32(CTRL);
01190         ctrl |= E1000_CTRL_SLU;
01191         ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
01192         ew32(CTRL, ctrl);
01193 
01194         /*
01195          * Set the mac to wait the maximum time between each
01196          * iteration and increase the max iterations when
01197          * polling the phy; this fixes erroneous timeouts at 10Mbps.
01198          */
01199         ret_val = e1000e_write_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 4),
01200                                                    0xFFFF);
01201         if (ret_val)
01202                 goto out;
01203         ret_val = e1000e_read_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 9),
01204                                                   &reg_data);
01205         if (ret_val)
01206                 goto out;
01207         reg_data |= 0x3F;
01208         ret_val = e1000e_write_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 9),
01209                                                    reg_data);
01210         if (ret_val)
01211                 goto out;
01212         ret_val = e1000e_read_kmrn_reg_80003es2lan(hw,
01213                                       E1000_KMRNCTRLSTA_OFFSET_INB_CTRL,
01214                                       &reg_data);
01215         if (ret_val)
01216                 goto out;
01217         reg_data |= E1000_KMRNCTRLSTA_INB_CTRL_DIS_PADDING;
01218         ret_val = e1000e_write_kmrn_reg_80003es2lan(hw,
01219                                        E1000_KMRNCTRLSTA_OFFSET_INB_CTRL,
01220                                        reg_data);
01221         if (ret_val)
01222                 goto out;
01223 
01224         ret_val = e1000e_copper_link_setup_gg82563_80003es2lan(hw);
01225         if (ret_val)
01226                 goto out;
01227 
01228         ret_val = e1000e_setup_copper_link(hw);
01229 
01230 out:
01231         return ret_val;
01232 }
01233 
01234 /**
01235  *  e1000e_cfg_on_link_up_80003es2lan - es2 link configuration after link-up
01236  *  @hw: pointer to the HW structure
01237  *  @duplex: current duplex setting
01238  *
01239  *  Configure the KMRN interface by applying last minute quirks for
01240  *  10/100 operation.
01241  **/
01242 static s32 e1000e_cfg_on_link_up_80003es2lan(struct e1000_hw *hw)
01243 {
01244         s32 ret_val = E1000_SUCCESS;
01245         u16 speed;
01246         u16 duplex;
01247 
01248         if (hw->phy.media_type == e1000_media_type_copper) {
01249                 ret_val = e1000e_get_speed_and_duplex_copper(hw,
01250                                                                     &speed,
01251                                                                     &duplex);
01252                 if (ret_val)
01253                         goto out;
01254 
01255                 if (speed == SPEED_1000)
01256                         ret_val = e1000e_cfg_kmrn_1000_80003es2lan(hw);
01257                 else
01258                         ret_val = e1000e_cfg_kmrn_10_100_80003es2lan(hw, duplex);
01259         }
01260 
01261 out:
01262         return ret_val;
01263 }
01264 
01265 /**
01266  *  e1000e_cfg_kmrn_10_100_80003es2lan - Apply "quirks" for 10/100 operation
01267  *  @hw: pointer to the HW structure
01268  *  @duplex: current duplex setting
01269  *
01270  *  Configure the KMRN interface by applying last minute quirks for
01271  *  10/100 operation.
01272  **/
01273 static s32 e1000e_cfg_kmrn_10_100_80003es2lan(struct e1000_hw *hw, u16 duplex)
01274 {
01275         s32 ret_val = E1000_SUCCESS;
01276         u32 tipg;
01277         u32 i = 0;
01278         u16 reg_data, reg_data2;
01279 
01280         reg_data = E1000_KMRNCTRLSTA_HD_CTRL_10_100_DEFAULT;
01281         ret_val = e1000e_write_kmrn_reg_80003es2lan(hw,
01282                                        E1000_KMRNCTRLSTA_OFFSET_HD_CTRL,
01283                                        reg_data);
01284         if (ret_val)
01285                 goto out;
01286 
01287         /* Configure Transmit Inter-Packet Gap */
01288         tipg = er32(TIPG);
01289         tipg &= ~E1000_TIPG_IPGT_MASK;
01290         tipg |= DEFAULT_TIPG_IPGT_10_100_80003ES2LAN;
01291         ew32(TIPG, tipg);
01292 
01293 
01294         do {
01295                 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL,
01296                                                &reg_data);
01297                 if (ret_val)
01298                         goto out;
01299 
01300                 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL,
01301                                                &reg_data2);
01302                 if (ret_val)
01303                         goto out;
01304                 i++;
01305         } while ((reg_data != reg_data2) && (i < GG82563_MAX_KMRN_RETRY));
01306 
01307         if (duplex == HALF_DUPLEX)
01308                 reg_data |= GG82563_KMCR_PASS_FALSE_CARRIER;
01309         else
01310                 reg_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
01311 
01312         ret_val = e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data);
01313 
01314 out:
01315         return ret_val;
01316 }
01317 
01318 /**
01319  *  e1000e_cfg_kmrn_1000_80003es2lan - Apply "quirks" for gigabit operation
01320  *  @hw: pointer to the HW structure
01321  *
01322  *  Configure the KMRN interface by applying last minute quirks for
01323  *  gigabit operation.
01324  **/
01325 static s32 e1000e_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw)
01326 {
01327         s32 ret_val = E1000_SUCCESS;
01328         u16 reg_data, reg_data2;
01329         u32 tipg;
01330         u32 i = 0;
01331 
01332         reg_data = E1000_KMRNCTRLSTA_HD_CTRL_1000_DEFAULT;
01333         ret_val = e1000e_write_kmrn_reg_80003es2lan(hw,
01334                                        E1000_KMRNCTRLSTA_OFFSET_HD_CTRL,
01335                                        reg_data);
01336         if (ret_val)
01337                 goto out;
01338 
01339         /* Configure Transmit Inter-Packet Gap */
01340         tipg = er32(TIPG);
01341         tipg &= ~E1000_TIPG_IPGT_MASK;
01342         tipg |= DEFAULT_TIPG_IPGT_1000_80003ES2LAN;
01343         ew32(TIPG, tipg);
01344 
01345 
01346         do {
01347                 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL,
01348                                                &reg_data);
01349                 if (ret_val)
01350                         goto out;
01351 
01352                 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL,
01353                                                &reg_data2);
01354                 if (ret_val)
01355                         goto out;
01356                 i++;
01357         } while ((reg_data != reg_data2) && (i < GG82563_MAX_KMRN_RETRY));
01358 
01359         reg_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
01360         ret_val = e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data);
01361 
01362 out:
01363         return ret_val;
01364 }
01365 
01366 /**
01367  *  e1000e_read_kmrn_reg_80003es2lan - Read kumeran register
01368  *  @hw: pointer to the HW structure
01369  *  @offset: register offset to be read
01370  *  @data: pointer to the read data
01371  *
01372  *  Acquire semaphore, then read the PHY register at offset
01373  *  using the kumeran interface.  The information retrieved is stored in data.
01374  *  Release the semaphore before exiting.
01375  **/
01376 static s32 e1000e_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
01377                                            u16 *data)
01378 {
01379         u32 kmrnctrlsta;
01380         s32 ret_val = E1000_SUCCESS;
01381 
01382         ret_val = e1000e_acquire_mac_csr_80003es2lan(hw);
01383         if (ret_val)
01384                 goto out;
01385 
01386         kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) &
01387                        E1000_KMRNCTRLSTA_OFFSET) | E1000_KMRNCTRLSTA_REN;
01388         ew32(KMRNCTRLSTA, kmrnctrlsta);
01389 
01390         udelay(2);
01391 
01392         kmrnctrlsta = er32(KMRNCTRLSTA);
01393         *data = (u16)kmrnctrlsta;
01394 
01395         e1000e_release_mac_csr_80003es2lan(hw);
01396 
01397 out:
01398         return ret_val;
01399 }
01400 
01401 /**
01402  *  e1000e_write_kmrn_reg_80003es2lan - Write kumeran register
01403  *  @hw: pointer to the HW structure
01404  *  @offset: register offset to write to
01405  *  @data: data to write at register offset
01406  *
01407  *  Acquire semaphore, then write the data to PHY register
01408  *  at the offset using the kumeran interface.  Release semaphore
01409  *  before exiting.
01410  **/
01411 static s32 e1000e_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
01412                                             u16 data)
01413 {
01414         u32 kmrnctrlsta;
01415         s32 ret_val = E1000_SUCCESS;
01416 
01417         ret_val = e1000e_acquire_mac_csr_80003es2lan(hw);
01418         if (ret_val)
01419                 goto out;
01420 
01421         kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) &
01422                        E1000_KMRNCTRLSTA_OFFSET) | data;
01423         ew32(KMRNCTRLSTA, kmrnctrlsta);
01424 
01425         udelay(2);
01426 
01427         e1000e_release_mac_csr_80003es2lan(hw);
01428 
01429 out:
01430         return ret_val;
01431 }
01432 
01433 /**
01434  *  e1000e_read_mac_addr_80003es2lan - Read device MAC address
01435  *  @hw: pointer to the HW structure
01436  **/
01437 static s32 e1000e_read_mac_addr_80003es2lan(struct e1000_hw *hw)
01438 {
01439         s32 ret_val = E1000_SUCCESS;
01440 
01441         /*
01442          * If there's an alternate MAC address place it in RAR0
01443          * so that it will override the Si installed default perm
01444          * address.
01445          */
01446         ret_val = e1000e_check_alt_mac_addr_generic(hw);
01447         if (ret_val)
01448                 goto out;
01449 
01450         ret_val = e1000e_read_mac_addr_generic(hw);
01451 
01452 out:
01453         return ret_val;
01454 }
01455 
01456 /**
01457  * e1000e_power_down_phy_copper_80003es2lan - Remove link during PHY power down
01458  * @hw: pointer to the HW structure
01459  *
01460  * In the case of a PHY power down to save power, or to turn off link during a
01461  * driver unload, or wake on lan is not enabled, remove the link.
01462  **/
01463 static void e1000e_power_down_phy_copper_80003es2lan(struct e1000_hw *hw)
01464 {
01465         /* If the management interface is not enabled, then power down */
01466         if (!(hw->mac.ops.check_mng_mode(hw) ||
01467               e1000e_check_reset_block(hw)))
01468              e1000e_power_down_phy_copper(hw);
01469 
01470         return;
01471 }
01472 
01473 /**
01474  *  e1000e_clear_hw_cntrs_80003es2lan - Clear device specific hardware counters
01475  *  @hw: pointer to the HW structure
01476  *
01477  *  Clears the hardware counters by reading the counter registers.
01478  **/
01479 static void e1000e_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw __unused)
01480 {
01481 #if 0
01482         e1000e_clear_hw_cntrs_base(hw);
01483 
01484         er32(PRC64);
01485         er32(PRC127);
01486         er32(PRC255);
01487         er32(PRC511);
01488         er32(PRC1023);
01489         er32(PRC1522);
01490         er32(PTC64);
01491         er32(PTC127);
01492         er32(PTC255);
01493         er32(PTC511);
01494         er32(PTC1023);
01495         er32(PTC1522);
01496 
01497         er32(ALGNERRC);
01498         er32(RXERRC);
01499         er32(TNCRS);
01500         er32(CEXTERR);
01501         er32(TSCTC);
01502         er32(TSCTFC);
01503 
01504         er32(MGTPRC);
01505         er32(MGTPDC);
01506         er32(MGTPTC);
01507 
01508         er32(IAC);
01509         er32(ICRXOC);
01510 
01511         er32(ICRXPTC);
01512         er32(ICRXATC);
01513         er32(ICTXPTC);
01514         er32(ICTXATC);
01515         er32(ICTXQEC);
01516         er32(ICTXQMTC);
01517         er32(ICRXDMTC);
01518 #endif
01519 }
01520 
01521 static struct pci_device_id e1000e_80003es2lan_nics[] = {
01522      PCI_ROM(0x8086, 0x1096, "E1000_DEV_ID_80003ES2LAN_COPPER_DPT", "E1000_DEV_ID_80003ES2LAN_COPPER_DPT", board_80003es2lan),
01523      PCI_ROM(0x8086, 0x10BA, "E1000_DEV_ID_80003ES2LAN_COPPER_SPT", "E1000_DEV_ID_80003ES2LAN_COPPER_SPT", board_80003es2lan),
01524      PCI_ROM(0x8086, 0x1098, "E1000_DEV_ID_80003ES2LAN_SERDES_DPT", "E1000_DEV_ID_80003ES2LAN_SERDES_DPT", board_80003es2lan),
01525      PCI_ROM(0x8086, 0x10BB, "E1000_DEV_ID_80003ES2LAN_SERDES_SPT", "E1000_DEV_ID_80003ES2LAN_SERDES_SPT", board_80003es2lan),
01526 };
01527 
01528 struct pci_driver e1000e_80003es2lan_driver __pci_driver = {
01529         .ids = e1000e_80003es2lan_nics,
01530         .id_count = (sizeof (e1000e_80003es2lan_nics) / sizeof (e1000e_80003es2lan_nics[0])),
01531         .probe = e1000e_probe,
01532         .remove = e1000e_remove,
01533 };

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