fp@2219: /*******************************************************************************
fp@2219: 
fp@2219:   Intel PRO/1000 Linux driver
fp@2219:   Copyright(c) 1999 - 2010 Intel Corporation.
fp@2219: 
fp@2219:   This program is free software; you can redistribute it and/or modify it
fp@2219:   under the terms and conditions of the GNU General Public License,
fp@2219:   version 2, as published by the Free Software Foundation.
fp@2219: 
fp@2219:   This program is distributed in the hope it will be useful, but WITHOUT
fp@2219:   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
fp@2219:   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
fp@2219:   more details.
fp@2219: 
fp@2219:   You should have received a copy of the GNU General Public License along with
fp@2219:   this program; if not, write to the Free Software Foundation, Inc.,
fp@2219:   51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
fp@2219: 
fp@2219:   The full GNU General Public License is included in this distribution in
fp@2219:   the file called "COPYING".
fp@2219: 
fp@2219:   Contact Information:
fp@2219:   Linux NICS <linux.nics@intel.com>
fp@2219:   e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
fp@2219:   Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
fp@2219: 
fp@2219: *******************************************************************************/
fp@2219: 
fp@2219: /*
fp@2219:  * 80003ES2LAN Gigabit Ethernet Controller (Copper)
fp@2219:  * 80003ES2LAN Gigabit Ethernet Controller (Serdes)
fp@2219:  */
fp@2219: 
fp@2219: #include "e1000-2.6.37-ethercat.h"
fp@2219: 
fp@2219: #define E1000_KMRNCTRLSTA_OFFSET_FIFO_CTRL	 0x00
fp@2219: #define E1000_KMRNCTRLSTA_OFFSET_INB_CTRL	 0x02
fp@2219: #define E1000_KMRNCTRLSTA_OFFSET_HD_CTRL	 0x10
fp@2219: #define E1000_KMRNCTRLSTA_OFFSET_MAC2PHY_OPMODE	 0x1F
fp@2219: 
fp@2219: #define E1000_KMRNCTRLSTA_FIFO_CTRL_RX_BYPASS	 0x0008
fp@2219: #define E1000_KMRNCTRLSTA_FIFO_CTRL_TX_BYPASS	 0x0800
fp@2219: #define E1000_KMRNCTRLSTA_INB_CTRL_DIS_PADDING	 0x0010
fp@2219: 
fp@2219: #define E1000_KMRNCTRLSTA_HD_CTRL_10_100_DEFAULT 0x0004
fp@2219: #define E1000_KMRNCTRLSTA_HD_CTRL_1000_DEFAULT	 0x0000
fp@2219: #define E1000_KMRNCTRLSTA_OPMODE_E_IDLE		 0x2000
fp@2219: 
fp@2219: #define E1000_KMRNCTRLSTA_OPMODE_MASK		 0x000C
fp@2219: #define E1000_KMRNCTRLSTA_OPMODE_INBAND_MDIO	 0x0004
fp@2219: 
fp@2219: #define E1000_TCTL_EXT_GCEX_MASK 0x000FFC00 /* Gigabit Carry Extend Padding */
fp@2219: #define DEFAULT_TCTL_EXT_GCEX_80003ES2LAN	 0x00010000
fp@2219: 
fp@2219: #define DEFAULT_TIPG_IPGT_1000_80003ES2LAN	 0x8
fp@2219: #define DEFAULT_TIPG_IPGT_10_100_80003ES2LAN	 0x9
fp@2219: 
fp@2219: /* GG82563 PHY Specific Status Register (Page 0, Register 16 */
fp@2219: #define GG82563_PSCR_POLARITY_REVERSAL_DISABLE	 0x0002 /* 1=Reversal Disab. */
fp@2219: #define GG82563_PSCR_CROSSOVER_MODE_MASK	 0x0060
fp@2219: #define GG82563_PSCR_CROSSOVER_MODE_MDI		 0x0000 /* 00=Manual MDI */
fp@2219: #define GG82563_PSCR_CROSSOVER_MODE_MDIX	 0x0020 /* 01=Manual MDIX */
fp@2219: #define GG82563_PSCR_CROSSOVER_MODE_AUTO	 0x0060 /* 11=Auto crossover */
fp@2219: 
fp@2219: /* PHY Specific Control Register 2 (Page 0, Register 26) */
fp@2219: #define GG82563_PSCR2_REVERSE_AUTO_NEG		 0x2000
fp@2219: 						/* 1=Reverse Auto-Negotiation */
fp@2219: 
fp@2219: /* MAC Specific Control Register (Page 2, Register 21) */
fp@2219: /* Tx clock speed for Link Down and 1000BASE-T for the following speeds */
fp@2219: #define GG82563_MSCR_TX_CLK_MASK		 0x0007
fp@2219: #define GG82563_MSCR_TX_CLK_10MBPS_2_5		 0x0004
fp@2219: #define GG82563_MSCR_TX_CLK_100MBPS_25		 0x0005
fp@2219: #define GG82563_MSCR_TX_CLK_1000MBPS_25		 0x0007
fp@2219: 
fp@2219: #define GG82563_MSCR_ASSERT_CRS_ON_TX		 0x0010 /* 1=Assert */
fp@2219: 
fp@2219: /* DSP Distance Register (Page 5, Register 26) */
fp@2219: #define GG82563_DSPD_CABLE_LENGTH		 0x0007 /* 0 = <50M
fp@2219: 							   1 = 50-80M
fp@2219: 							   2 = 80-110M
fp@2219: 							   3 = 110-140M
fp@2219: 							   4 = >140M */
fp@2219: 
fp@2219: /* Kumeran Mode Control Register (Page 193, Register 16) */
fp@2219: #define GG82563_KMCR_PASS_FALSE_CARRIER		 0x0800
fp@2219: 
fp@2219: /* Max number of times Kumeran read/write should be validated */
fp@2219: #define GG82563_MAX_KMRN_RETRY  0x5
fp@2219: 
fp@2219: /* Power Management Control Register (Page 193, Register 20) */
fp@2219: #define GG82563_PMCR_ENABLE_ELECTRICAL_IDLE	 0x0001
fp@2219: 					   /* 1=Enable SERDES Electrical Idle */
fp@2219: 
fp@2219: /* In-Band Control Register (Page 194, Register 18) */
fp@2219: #define GG82563_ICR_DIS_PADDING			 0x0010 /* Disable Padding */
fp@2219: 
fp@2219: /*
fp@2219:  * A table for the GG82563 cable length where the range is defined
fp@2219:  * with a lower bound at "index" and the upper bound at
fp@2219:  * "index + 5".
fp@2219:  */
fp@2219: static const u16 e1000_gg82563_cable_length_table[] =
fp@2219: 	 { 0, 60, 115, 150, 150, 60, 115, 150, 180, 180, 0xFF };
fp@2219: #define GG82563_CABLE_LENGTH_TABLE_SIZE \
fp@2219: 		ARRAY_SIZE(e1000_gg82563_cable_length_table)
fp@2219: 
fp@2219: static s32 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw);
fp@2219: static s32 e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask);
fp@2219: static void e1000_release_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask);
fp@2219: static void e1000_initialize_hw_bits_80003es2lan(struct e1000_hw *hw);
fp@2219: static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw);
fp@2219: static s32 e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw);
fp@2219: static s32 e1000_cfg_kmrn_10_100_80003es2lan(struct e1000_hw *hw, u16 duplex);
fp@2219: static s32 e1000_cfg_on_link_up_80003es2lan(struct e1000_hw *hw);
fp@2219: static s32  e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
fp@2219:                                             u16 *data);
fp@2219: static s32  e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
fp@2219:                                              u16 data);
fp@2219: static void e1000_power_down_phy_copper_80003es2lan(struct e1000_hw *hw);
fp@2219: 
fp@2219: /**
fp@2219:  *  e1000_init_phy_params_80003es2lan - Init ESB2 PHY func ptrs.
fp@2219:  *  @hw: pointer to the HW structure
fp@2219:  **/
fp@2219: static s32 e1000_init_phy_params_80003es2lan(struct e1000_hw *hw)
fp@2219: {
fp@2219: 	struct e1000_phy_info *phy = &hw->phy;
fp@2219: 	s32 ret_val;
fp@2219: 
fp@2219: 	if (hw->phy.media_type != e1000_media_type_copper) {
fp@2219: 		phy->type	= e1000_phy_none;
fp@2219: 		return 0;
fp@2219: 	} else {
fp@2219: 		phy->ops.power_up = e1000_power_up_phy_copper;
fp@2219: 		phy->ops.power_down = e1000_power_down_phy_copper_80003es2lan;
fp@2219: 	}
fp@2219: 
fp@2219: 	phy->addr		= 1;
fp@2219: 	phy->autoneg_mask	= AUTONEG_ADVERTISE_SPEED_DEFAULT;
fp@2219: 	phy->reset_delay_us      = 100;
fp@2219: 	phy->type		= e1000_phy_gg82563;
fp@2219: 
fp@2219: 	/* This can only be done after all function pointers are setup. */
fp@2219: 	ret_val = e1000e_get_phy_id(hw);
fp@2219: 
fp@2219: 	/* Verify phy id */
fp@2219: 	if (phy->id != GG82563_E_PHY_ID)
fp@2219: 		return -E1000_ERR_PHY;
fp@2219: 
fp@2219: 	return ret_val;
fp@2219: }
fp@2219: 
fp@2219: /**
fp@2219:  *  e1000_init_nvm_params_80003es2lan - Init ESB2 NVM func ptrs.
fp@2219:  *  @hw: pointer to the HW structure
fp@2219:  **/
fp@2219: static s32 e1000_init_nvm_params_80003es2lan(struct e1000_hw *hw)
fp@2219: {
fp@2219: 	struct e1000_nvm_info *nvm = &hw->nvm;
fp@2219: 	u32 eecd = er32(EECD);
fp@2219: 	u16 size;
fp@2219: 
fp@2219: 	nvm->opcode_bits	= 8;
fp@2219: 	nvm->delay_usec	 = 1;
fp@2219: 	switch (nvm->override) {
fp@2219: 	case e1000_nvm_override_spi_large:
fp@2219: 		nvm->page_size    = 32;
fp@2219: 		nvm->address_bits = 16;
fp@2219: 		break;
fp@2219: 	case e1000_nvm_override_spi_small:
fp@2219: 		nvm->page_size    = 8;
fp@2219: 		nvm->address_bits = 8;
fp@2219: 		break;
fp@2219: 	default:
fp@2219: 		nvm->page_size    = eecd & E1000_EECD_ADDR_BITS ? 32 : 8;
fp@2219: 		nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ? 16 : 8;
fp@2219: 		break;
fp@2219: 	}
fp@2219: 
fp@2219: 	nvm->type = e1000_nvm_eeprom_spi;
fp@2219: 
fp@2219: 	size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >>
fp@2219: 			  E1000_EECD_SIZE_EX_SHIFT);
fp@2219: 
fp@2219: 	/*
fp@2219: 	 * Added to a constant, "size" becomes the left-shift value
fp@2219: 	 * for setting word_size.
fp@2219: 	 */
fp@2219: 	size += NVM_WORD_SIZE_BASE_SHIFT;
fp@2219: 
fp@2219: 	/* EEPROM access above 16k is unsupported */
fp@2219: 	if (size > 14)
fp@2219: 		size = 14;
fp@2219: 	nvm->word_size	= 1 << size;
fp@2219: 
fp@2219: 	return 0;
fp@2219: }
fp@2219: 
fp@2219: /**
fp@2219:  *  e1000_init_mac_params_80003es2lan - Init ESB2 MAC func ptrs.
fp@2219:  *  @hw: pointer to the HW structure
fp@2219:  **/
fp@2219: static s32 e1000_init_mac_params_80003es2lan(struct e1000_adapter *adapter)
fp@2219: {
fp@2219: 	struct e1000_hw *hw = &adapter->hw;
fp@2219: 	struct e1000_mac_info *mac = &hw->mac;
fp@2219: 	struct e1000_mac_operations *func = &mac->ops;
fp@2219: 
fp@2219: 	/* Set media type */
fp@2219: 	switch (adapter->pdev->device) {
fp@2219: 	case E1000_DEV_ID_80003ES2LAN_SERDES_DPT:
fp@2219: 		hw->phy.media_type = e1000_media_type_internal_serdes;
fp@2219: 		break;
fp@2219: 	default:
fp@2219: 		hw->phy.media_type = e1000_media_type_copper;
fp@2219: 		break;
fp@2219: 	}
fp@2219: 
fp@2219: 	/* Set mta register count */
fp@2219: 	mac->mta_reg_count = 128;
fp@2219: 	/* Set rar entry count */
fp@2219: 	mac->rar_entry_count = E1000_RAR_ENTRIES;
fp@2219: 	/* FWSM register */
fp@2219: 	mac->has_fwsm = true;
fp@2219: 	/* ARC supported; valid only if manageability features are enabled. */
fp@2219: 	mac->arc_subsystem_valid =
fp@2219: 	        (er32(FWSM) & E1000_FWSM_MODE_MASK)
fp@2219: 	                ? true : false;
fp@2219: 	/* Adaptive IFS not supported */
fp@2219: 	mac->adaptive_ifs = false;
fp@2219: 
fp@2219: 	/* check for link */
fp@2219: 	switch (hw->phy.media_type) {
fp@2219: 	case e1000_media_type_copper:
fp@2219: 		func->setup_physical_interface = e1000_setup_copper_link_80003es2lan;
fp@2219: 		func->check_for_link = e1000e_check_for_copper_link;
fp@2219: 		break;
fp@2219: 	case e1000_media_type_fiber:
fp@2219: 		func->setup_physical_interface = e1000e_setup_fiber_serdes_link;
fp@2219: 		func->check_for_link = e1000e_check_for_fiber_link;
fp@2219: 		break;
fp@2219: 	case e1000_media_type_internal_serdes:
fp@2219: 		func->setup_physical_interface = e1000e_setup_fiber_serdes_link;
fp@2219: 		func->check_for_link = e1000e_check_for_serdes_link;
fp@2219: 		break;
fp@2219: 	default:
fp@2219: 		return -E1000_ERR_CONFIG;
fp@2219: 		break;
fp@2219: 	}
fp@2219: 
fp@2219: 	/* set lan id for port to determine which phy lock to use */
fp@2219: 	hw->mac.ops.set_lan_id(hw);
fp@2219: 
fp@2219: 	return 0;
fp@2219: }
fp@2219: 
fp@2219: static s32 e1000_get_variants_80003es2lan(struct e1000_adapter *adapter)
fp@2219: {
fp@2219: 	struct e1000_hw *hw = &adapter->hw;
fp@2219: 	s32 rc;
fp@2219: 
fp@2219: 	rc = e1000_init_mac_params_80003es2lan(adapter);
fp@2219: 	if (rc)
fp@2219: 		return rc;
fp@2219: 
fp@2219: 	rc = e1000_init_nvm_params_80003es2lan(hw);
fp@2219: 	if (rc)
fp@2219: 		return rc;
fp@2219: 
fp@2219: 	rc = e1000_init_phy_params_80003es2lan(hw);
fp@2219: 	if (rc)
fp@2219: 		return rc;
fp@2219: 
fp@2219: 	return 0;
fp@2219: }
fp@2219: 
fp@2219: /**
fp@2219:  *  e1000_acquire_phy_80003es2lan - Acquire rights to access PHY
fp@2219:  *  @hw: pointer to the HW structure
fp@2219:  *
fp@2219:  *  A wrapper to acquire access rights to the correct PHY.
fp@2219:  **/
fp@2219: static s32 e1000_acquire_phy_80003es2lan(struct e1000_hw *hw)
fp@2219: {
fp@2219: 	u16 mask;
fp@2219: 
fp@2219: 	mask = hw->bus.func ? E1000_SWFW_PHY1_SM : E1000_SWFW_PHY0_SM;
fp@2219: 	return e1000_acquire_swfw_sync_80003es2lan(hw, mask);
fp@2219: }
fp@2219: 
fp@2219: /**
fp@2219:  *  e1000_release_phy_80003es2lan - Release rights to access PHY
fp@2219:  *  @hw: pointer to the HW structure
fp@2219:  *
fp@2219:  *  A wrapper to release access rights to the correct PHY.
fp@2219:  **/
fp@2219: static void e1000_release_phy_80003es2lan(struct e1000_hw *hw)
fp@2219: {
fp@2219: 	u16 mask;
fp@2219: 
fp@2219: 	mask = hw->bus.func ? E1000_SWFW_PHY1_SM : E1000_SWFW_PHY0_SM;
fp@2219: 	e1000_release_swfw_sync_80003es2lan(hw, mask);
fp@2219: }
fp@2219: 
fp@2219: /**
fp@2219:  *  e1000_acquire_mac_csr_80003es2lan - Acquire rights to access Kumeran register
fp@2219:  *  @hw: pointer to the HW structure
fp@2219:  *
fp@2219:  *  Acquire the semaphore to access the Kumeran interface.
fp@2219:  *
fp@2219:  **/
fp@2219: static s32 e1000_acquire_mac_csr_80003es2lan(struct e1000_hw *hw)
fp@2219: {
fp@2219: 	u16 mask;
fp@2219: 
fp@2219: 	mask = E1000_SWFW_CSR_SM;
fp@2219: 
fp@2219: 	return e1000_acquire_swfw_sync_80003es2lan(hw, mask);
fp@2219: }
fp@2219: 
fp@2219: /**
fp@2219:  *  e1000_release_mac_csr_80003es2lan - Release rights to access Kumeran Register
fp@2219:  *  @hw: pointer to the HW structure
fp@2219:  *
fp@2219:  *  Release the semaphore used to access the Kumeran interface
fp@2219:  **/
fp@2219: static void e1000_release_mac_csr_80003es2lan(struct e1000_hw *hw)
fp@2219: {
fp@2219: 	u16 mask;
fp@2219: 
fp@2219: 	mask = E1000_SWFW_CSR_SM;
fp@2219: 
fp@2219: 	e1000_release_swfw_sync_80003es2lan(hw, mask);
fp@2219: }
fp@2219: 
fp@2219: /**
fp@2219:  *  e1000_acquire_nvm_80003es2lan - Acquire rights to access NVM
fp@2219:  *  @hw: pointer to the HW structure
fp@2219:  *
fp@2219:  *  Acquire the semaphore to access the EEPROM.
fp@2219:  **/
fp@2219: static s32 e1000_acquire_nvm_80003es2lan(struct e1000_hw *hw)
fp@2219: {
fp@2219: 	s32 ret_val;
fp@2219: 
fp@2219: 	ret_val = e1000_acquire_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM);
fp@2219: 	if (ret_val)
fp@2219: 		return ret_val;
fp@2219: 
fp@2219: 	ret_val = e1000e_acquire_nvm(hw);
fp@2219: 
fp@2219: 	if (ret_val)
fp@2219: 		e1000_release_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM);
fp@2219: 
fp@2219: 	return ret_val;
fp@2219: }
fp@2219: 
fp@2219: /**
fp@2219:  *  e1000_release_nvm_80003es2lan - Relinquish rights to access NVM
fp@2219:  *  @hw: pointer to the HW structure
fp@2219:  *
fp@2219:  *  Release the semaphore used to access the EEPROM.
fp@2219:  **/
fp@2219: static void e1000_release_nvm_80003es2lan(struct e1000_hw *hw)
fp@2219: {
fp@2219: 	e1000e_release_nvm(hw);
fp@2219: 	e1000_release_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM);
fp@2219: }
fp@2219: 
fp@2219: /**
fp@2219:  *  e1000_acquire_swfw_sync_80003es2lan - Acquire SW/FW semaphore
fp@2219:  *  @hw: pointer to the HW structure
fp@2219:  *  @mask: specifies which semaphore to acquire
fp@2219:  *
fp@2219:  *  Acquire the SW/FW semaphore to access the PHY or NVM.  The mask
fp@2219:  *  will also specify which port we're acquiring the lock for.
fp@2219:  **/
fp@2219: static s32 e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask)
fp@2219: {
fp@2219: 	u32 swfw_sync;
fp@2219: 	u32 swmask = mask;
fp@2219: 	u32 fwmask = mask << 16;
fp@2219: 	s32 i = 0;
fp@2219: 	s32 timeout = 50;
fp@2219: 
fp@2219: 	while (i < timeout) {
fp@2219: 		if (e1000e_get_hw_semaphore(hw))
fp@2219: 			return -E1000_ERR_SWFW_SYNC;
fp@2219: 
fp@2219: 		swfw_sync = er32(SW_FW_SYNC);
fp@2219: 		if (!(swfw_sync & (fwmask | swmask)))
fp@2219: 			break;
fp@2219: 
fp@2219: 		/*
fp@2219: 		 * Firmware currently using resource (fwmask)
fp@2219: 		 * or other software thread using resource (swmask)
fp@2219: 		 */
fp@2219: 		e1000e_put_hw_semaphore(hw);
fp@2219: 		mdelay(5);
fp@2219: 		i++;
fp@2219: 	}
fp@2219: 
fp@2219: 	if (i == timeout) {
fp@2219: 		e_dbg("Driver can't access resource, SW_FW_SYNC timeout.\n");
fp@2219: 		return -E1000_ERR_SWFW_SYNC;
fp@2219: 	}
fp@2219: 
fp@2219: 	swfw_sync |= swmask;
fp@2219: 	ew32(SW_FW_SYNC, swfw_sync);
fp@2219: 
fp@2219: 	e1000e_put_hw_semaphore(hw);
fp@2219: 
fp@2219: 	return 0;
fp@2219: }
fp@2219: 
fp@2219: /**
fp@2219:  *  e1000_release_swfw_sync_80003es2lan - Release SW/FW semaphore
fp@2219:  *  @hw: pointer to the HW structure
fp@2219:  *  @mask: specifies which semaphore to acquire
fp@2219:  *
fp@2219:  *  Release the SW/FW semaphore used to access the PHY or NVM.  The mask
fp@2219:  *  will also specify which port we're releasing the lock for.
fp@2219:  **/
fp@2219: static void e1000_release_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask)
fp@2219: {
fp@2219: 	u32 swfw_sync;
fp@2219: 
fp@2219: 	while (e1000e_get_hw_semaphore(hw) != 0);
fp@2219: 	/* Empty */
fp@2219: 
fp@2219: 	swfw_sync = er32(SW_FW_SYNC);
fp@2219: 	swfw_sync &= ~mask;
fp@2219: 	ew32(SW_FW_SYNC, swfw_sync);
fp@2219: 
fp@2219: 	e1000e_put_hw_semaphore(hw);
fp@2219: }
fp@2219: 
fp@2219: /**
fp@2219:  *  e1000_read_phy_reg_gg82563_80003es2lan - Read GG82563 PHY register
fp@2219:  *  @hw: pointer to the HW structure
fp@2219:  *  @offset: offset of the register to read
fp@2219:  *  @data: pointer to the data returned from the operation
fp@2219:  *
fp@2219:  *  Read the GG82563 PHY register.
fp@2219:  **/
fp@2219: static s32 e1000_read_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw,
fp@2219: 						  u32 offset, u16 *data)
fp@2219: {
fp@2219: 	s32 ret_val;
fp@2219: 	u32 page_select;
fp@2219: 	u16 temp;
fp@2219: 
fp@2219: 	ret_val = e1000_acquire_phy_80003es2lan(hw);
fp@2219: 	if (ret_val)
fp@2219: 		return ret_val;
fp@2219: 
fp@2219: 	/* Select Configuration Page */
fp@2219: 	if ((offset & MAX_PHY_REG_ADDRESS) < GG82563_MIN_ALT_REG) {
fp@2219: 		page_select = GG82563_PHY_PAGE_SELECT;
fp@2219: 	} else {
fp@2219: 		/*
fp@2219: 		 * Use Alternative Page Select register to access
fp@2219: 		 * registers 30 and 31
fp@2219: 		 */
fp@2219: 		page_select = GG82563_PHY_PAGE_SELECT_ALT;
fp@2219: 	}
fp@2219: 
fp@2219: 	temp = (u16)((u16)offset >> GG82563_PAGE_SHIFT);
fp@2219: 	ret_val = e1000e_write_phy_reg_mdic(hw, page_select, temp);
fp@2219: 	if (ret_val) {
fp@2219: 		e1000_release_phy_80003es2lan(hw);
fp@2219: 		return ret_val;
fp@2219: 	}
fp@2219: 
fp@2219: 	if (hw->dev_spec.e80003es2lan.mdic_wa_enable == true) {
fp@2219: 		/*
fp@2219: 		 * The "ready" bit in the MDIC register may be incorrectly set
fp@2219: 		 * before the device has completed the "Page Select" MDI
fp@2219: 		 * transaction.  So we wait 200us after each MDI command...
fp@2219: 		 */
fp@2219: 		udelay(200);
fp@2219: 
fp@2219: 		/* ...and verify the command was successful. */
fp@2219: 		ret_val = e1000e_read_phy_reg_mdic(hw, page_select, &temp);
fp@2219: 
fp@2219: 		if (((u16)offset >> GG82563_PAGE_SHIFT) != temp) {
fp@2219: 			ret_val = -E1000_ERR_PHY;
fp@2219: 			e1000_release_phy_80003es2lan(hw);
fp@2219: 			return ret_val;
fp@2219: 		}
fp@2219: 
fp@2219: 		udelay(200);
fp@2219: 
fp@2219: 		ret_val = e1000e_read_phy_reg_mdic(hw,
fp@2219: 		                                  MAX_PHY_REG_ADDRESS & offset,
fp@2219: 		                                  data);
fp@2219: 
fp@2219: 		udelay(200);
fp@2219: 	} else {
fp@2219: 		ret_val = e1000e_read_phy_reg_mdic(hw,
fp@2219: 		                                  MAX_PHY_REG_ADDRESS & offset,
fp@2219: 		                                  data);
fp@2219: 	}
fp@2219: 
fp@2219: 	e1000_release_phy_80003es2lan(hw);
fp@2219: 
fp@2219: 	return ret_val;
fp@2219: }
fp@2219: 
fp@2219: /**
fp@2219:  *  e1000_write_phy_reg_gg82563_80003es2lan - Write GG82563 PHY register
fp@2219:  *  @hw: pointer to the HW structure
fp@2219:  *  @offset: offset of the register to read
fp@2219:  *  @data: value to write to the register
fp@2219:  *
fp@2219:  *  Write to the GG82563 PHY register.
fp@2219:  **/
fp@2219: static s32 e1000_write_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw,
fp@2219: 						   u32 offset, u16 data)
fp@2219: {
fp@2219: 	s32 ret_val;
fp@2219: 	u32 page_select;
fp@2219: 	u16 temp;
fp@2219: 
fp@2219: 	ret_val = e1000_acquire_phy_80003es2lan(hw);
fp@2219: 	if (ret_val)
fp@2219: 		return ret_val;
fp@2219: 
fp@2219: 	/* Select Configuration Page */
fp@2219: 	if ((offset & MAX_PHY_REG_ADDRESS) < GG82563_MIN_ALT_REG) {
fp@2219: 		page_select = GG82563_PHY_PAGE_SELECT;
fp@2219: 	} else {
fp@2219: 		/*
fp@2219: 		 * Use Alternative Page Select register to access
fp@2219: 		 * registers 30 and 31
fp@2219: 		 */
fp@2219: 		page_select = GG82563_PHY_PAGE_SELECT_ALT;
fp@2219: 	}
fp@2219: 
fp@2219: 	temp = (u16)((u16)offset >> GG82563_PAGE_SHIFT);
fp@2219: 	ret_val = e1000e_write_phy_reg_mdic(hw, page_select, temp);
fp@2219: 	if (ret_val) {
fp@2219: 		e1000_release_phy_80003es2lan(hw);
fp@2219: 		return ret_val;
fp@2219: 	}
fp@2219: 
fp@2219: 	if (hw->dev_spec.e80003es2lan.mdic_wa_enable == true) {
fp@2219: 		/*
fp@2219: 		 * The "ready" bit in the MDIC register may be incorrectly set
fp@2219: 		 * before the device has completed the "Page Select" MDI
fp@2219: 		 * transaction.  So we wait 200us after each MDI command...
fp@2219: 		 */
fp@2219: 		udelay(200);
fp@2219: 
fp@2219: 		/* ...and verify the command was successful. */
fp@2219: 		ret_val = e1000e_read_phy_reg_mdic(hw, page_select, &temp);
fp@2219: 
fp@2219: 		if (((u16)offset >> GG82563_PAGE_SHIFT) != temp) {
fp@2219: 			e1000_release_phy_80003es2lan(hw);
fp@2219: 			return -E1000_ERR_PHY;
fp@2219: 		}
fp@2219: 
fp@2219: 		udelay(200);
fp@2219: 
fp@2219: 		ret_val = e1000e_write_phy_reg_mdic(hw,
fp@2219: 		                                  MAX_PHY_REG_ADDRESS & offset,
fp@2219: 		                                  data);
fp@2219: 
fp@2219: 		udelay(200);
fp@2219: 	} else {
fp@2219: 		ret_val = e1000e_write_phy_reg_mdic(hw,
fp@2219: 		                                  MAX_PHY_REG_ADDRESS & offset,
fp@2219: 		                                  data);
fp@2219: 	}
fp@2219: 
fp@2219: 	e1000_release_phy_80003es2lan(hw);
fp@2219: 
fp@2219: 	return ret_val;
fp@2219: }
fp@2219: 
fp@2219: /**
fp@2219:  *  e1000_write_nvm_80003es2lan - Write to ESB2 NVM
fp@2219:  *  @hw: pointer to the HW structure
fp@2219:  *  @offset: offset of the register to read
fp@2219:  *  @words: number of words to write
fp@2219:  *  @data: buffer of data to write to the NVM
fp@2219:  *
fp@2219:  *  Write "words" of data to the ESB2 NVM.
fp@2219:  **/
fp@2219: static s32 e1000_write_nvm_80003es2lan(struct e1000_hw *hw, u16 offset,
fp@2219: 				       u16 words, u16 *data)
fp@2219: {
fp@2219: 	return e1000e_write_nvm_spi(hw, offset, words, data);
fp@2219: }
fp@2219: 
fp@2219: /**
fp@2219:  *  e1000_get_cfg_done_80003es2lan - Wait for configuration to complete
fp@2219:  *  @hw: pointer to the HW structure
fp@2219:  *
fp@2219:  *  Wait a specific amount of time for manageability processes to complete.
fp@2219:  *  This is a function pointer entry point called by the phy module.
fp@2219:  **/
fp@2219: static s32 e1000_get_cfg_done_80003es2lan(struct e1000_hw *hw)
fp@2219: {
fp@2219: 	s32 timeout = PHY_CFG_TIMEOUT;
fp@2219: 	u32 mask = E1000_NVM_CFG_DONE_PORT_0;
fp@2219: 
fp@2219: 	if (hw->bus.func == 1)
fp@2219: 		mask = E1000_NVM_CFG_DONE_PORT_1;
fp@2219: 
fp@2219: 	while (timeout) {
fp@2219: 		if (er32(EEMNGCTL) & mask)
fp@2219: 			break;
fp@2219: 		msleep(1);
fp@2219: 		timeout--;
fp@2219: 	}
fp@2219: 	if (!timeout) {
fp@2219: 		e_dbg("MNG configuration cycle has not completed.\n");
fp@2219: 		return -E1000_ERR_RESET;
fp@2219: 	}
fp@2219: 
fp@2219: 	return 0;
fp@2219: }
fp@2219: 
fp@2219: /**
fp@2219:  *  e1000_phy_force_speed_duplex_80003es2lan - Force PHY speed and duplex
fp@2219:  *  @hw: pointer to the HW structure
fp@2219:  *
fp@2219:  *  Force the speed and duplex settings onto the PHY.  This is a
fp@2219:  *  function pointer entry point called by the phy module.
fp@2219:  **/
fp@2219: static s32 e1000_phy_force_speed_duplex_80003es2lan(struct e1000_hw *hw)
fp@2219: {
fp@2219: 	s32 ret_val;
fp@2219: 	u16 phy_data;
fp@2219: 	bool link;
fp@2219: 
fp@2219: 	/*
fp@2219: 	 * Clear Auto-Crossover to force MDI manually.  M88E1000 requires MDI
fp@2219: 	 * forced whenever speed and duplex are forced.
fp@2219: 	 */
fp@2219: 	ret_val = e1e_rphy(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
fp@2219: 	if (ret_val)
fp@2219: 		return ret_val;
fp@2219: 
fp@2219: 	phy_data &= ~GG82563_PSCR_CROSSOVER_MODE_AUTO;
fp@2219: 	ret_val = e1e_wphy(hw, GG82563_PHY_SPEC_CTRL, phy_data);
fp@2219: 	if (ret_val)
fp@2219: 		return ret_val;
fp@2219: 
fp@2219: 	e_dbg("GG82563 PSCR: %X\n", phy_data);
fp@2219: 
fp@2219: 	ret_val = e1e_rphy(hw, PHY_CONTROL, &phy_data);
fp@2219: 	if (ret_val)
fp@2219: 		return ret_val;
fp@2219: 
fp@2219: 	e1000e_phy_force_speed_duplex_setup(hw, &phy_data);
fp@2219: 
fp@2219: 	/* Reset the phy to commit changes. */
fp@2219: 	phy_data |= MII_CR_RESET;
fp@2219: 
fp@2219: 	ret_val = e1e_wphy(hw, PHY_CONTROL, phy_data);
fp@2219: 	if (ret_val)
fp@2219: 		return ret_val;
fp@2219: 
fp@2219: 	udelay(1);
fp@2219: 
fp@2219: 	if (hw->phy.autoneg_wait_to_complete) {
fp@2219: 		e_dbg("Waiting for forced speed/duplex link "
fp@2219: 			 "on GG82563 phy.\n");
fp@2219: 
fp@2219: 		ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT,
fp@2219: 						     100000, &link);
fp@2219: 		if (ret_val)
fp@2219: 			return ret_val;
fp@2219: 
fp@2219: 		if (!link) {
fp@2219: 			/*
fp@2219: 			 * We didn't get link.
fp@2219: 			 * Reset the DSP and cross our fingers.
fp@2219: 			 */
fp@2219: 			ret_val = e1000e_phy_reset_dsp(hw);
fp@2219: 			if (ret_val)
fp@2219: 				return ret_val;
fp@2219: 		}
fp@2219: 
fp@2219: 		/* Try once more */
fp@2219: 		ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT,
fp@2219: 						     100000, &link);
fp@2219: 		if (ret_val)
fp@2219: 			return ret_val;
fp@2219: 	}
fp@2219: 
fp@2219: 	ret_val = e1e_rphy(hw, GG82563_PHY_MAC_SPEC_CTRL, &phy_data);
fp@2219: 	if (ret_val)
fp@2219: 		return ret_val;
fp@2219: 
fp@2219: 	/*
fp@2219: 	 * Resetting the phy means we need to verify the TX_CLK corresponds
fp@2219: 	 * to the link speed.  10Mbps -> 2.5MHz, else 25MHz.
fp@2219: 	 */
fp@2219: 	phy_data &= ~GG82563_MSCR_TX_CLK_MASK;
fp@2219: 	if (hw->mac.forced_speed_duplex & E1000_ALL_10_SPEED)
fp@2219: 		phy_data |= GG82563_MSCR_TX_CLK_10MBPS_2_5;
fp@2219: 	else
fp@2219: 		phy_data |= GG82563_MSCR_TX_CLK_100MBPS_25;
fp@2219: 
fp@2219: 	/*
fp@2219: 	 * In addition, we must re-enable CRS on Tx for both half and full
fp@2219: 	 * duplex.
fp@2219: 	 */
fp@2219: 	phy_data |= GG82563_MSCR_ASSERT_CRS_ON_TX;
fp@2219: 	ret_val = e1e_wphy(hw, GG82563_PHY_MAC_SPEC_CTRL, phy_data);
fp@2219: 
fp@2219: 	return ret_val;
fp@2219: }
fp@2219: 
fp@2219: /**
fp@2219:  *  e1000_get_cable_length_80003es2lan - Set approximate cable length
fp@2219:  *  @hw: pointer to the HW structure
fp@2219:  *
fp@2219:  *  Find the approximate cable length as measured by the GG82563 PHY.
fp@2219:  *  This is a function pointer entry point called by the phy module.
fp@2219:  **/
fp@2219: static s32 e1000_get_cable_length_80003es2lan(struct e1000_hw *hw)
fp@2219: {
fp@2219: 	struct e1000_phy_info *phy = &hw->phy;
fp@2219: 	s32 ret_val = 0;
fp@2219: 	u16 phy_data, index;
fp@2219: 
fp@2219: 	ret_val = e1e_rphy(hw, GG82563_PHY_DSP_DISTANCE, &phy_data);
fp@2219: 	if (ret_val)
fp@2219: 		goto out;
fp@2219: 
fp@2219: 	index = phy_data & GG82563_DSPD_CABLE_LENGTH;
fp@2219: 
fp@2219: 	if (index >= GG82563_CABLE_LENGTH_TABLE_SIZE - 5) {
fp@2219: 		ret_val = -E1000_ERR_PHY;
fp@2219: 		goto out;
fp@2219: 	}
fp@2219: 
fp@2219: 	phy->min_cable_length = e1000_gg82563_cable_length_table[index];
fp@2219: 	phy->max_cable_length = e1000_gg82563_cable_length_table[index + 5];
fp@2219: 
fp@2219: 	phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2;
fp@2219: 
fp@2219: out:
fp@2219: 	return ret_val;
fp@2219: }
fp@2219: 
fp@2219: /**
fp@2219:  *  e1000_get_link_up_info_80003es2lan - Report speed and duplex
fp@2219:  *  @hw: pointer to the HW structure
fp@2219:  *  @speed: pointer to speed buffer
fp@2219:  *  @duplex: pointer to duplex buffer
fp@2219:  *
fp@2219:  *  Retrieve the current speed and duplex configuration.
fp@2219:  **/
fp@2219: static s32 e1000_get_link_up_info_80003es2lan(struct e1000_hw *hw, u16 *speed,
fp@2219: 					      u16 *duplex)
fp@2219: {
fp@2219: 	s32 ret_val;
fp@2219: 
fp@2219: 	if (hw->phy.media_type == e1000_media_type_copper) {
fp@2219: 		ret_val = e1000e_get_speed_and_duplex_copper(hw,
fp@2219: 								    speed,
fp@2219: 								    duplex);
fp@2219: 		hw->phy.ops.cfg_on_link_up(hw);
fp@2219: 	} else {
fp@2219: 		ret_val = e1000e_get_speed_and_duplex_fiber_serdes(hw,
fp@2219: 								  speed,
fp@2219: 								  duplex);
fp@2219: 	}
fp@2219: 
fp@2219: 	return ret_val;
fp@2219: }
fp@2219: 
fp@2219: /**
fp@2219:  *  e1000_reset_hw_80003es2lan - Reset the ESB2 controller
fp@2219:  *  @hw: pointer to the HW structure
fp@2219:  *
fp@2219:  *  Perform a global reset to the ESB2 controller.
fp@2219:  **/
fp@2219: static s32 e1000_reset_hw_80003es2lan(struct e1000_hw *hw)
fp@2219: {
fp@2234: 	u32 ctrl, icr __attribute__ ((unused));
fp@2219: 	s32 ret_val;
fp@2219: 
fp@2219: 	/*
fp@2219: 	 * Prevent the PCI-E bus from sticking if there is no TLP connection
fp@2219: 	 * on the last TLP read/write transaction when MAC is reset.
fp@2219: 	 */
fp@2219: 	ret_val = e1000e_disable_pcie_master(hw);
fp@2219: 	if (ret_val)
fp@2219: 		e_dbg("PCI-E Master disable polling has failed.\n");
fp@2219: 
fp@2219: 	e_dbg("Masking off all interrupts\n");
fp@2219: 	ew32(IMC, 0xffffffff);
fp@2219: 
fp@2219: 	ew32(RCTL, 0);
fp@2219: 	ew32(TCTL, E1000_TCTL_PSP);
fp@2219: 	e1e_flush();
fp@2219: 
fp@2219: 	msleep(10);
fp@2219: 
fp@2219: 	ctrl = er32(CTRL);
fp@2219: 
fp@2219: 	ret_val = e1000_acquire_phy_80003es2lan(hw);
fp@2219: 	e_dbg("Issuing a global reset to MAC\n");
fp@2219: 	ew32(CTRL, ctrl | E1000_CTRL_RST);
fp@2219: 	e1000_release_phy_80003es2lan(hw);
fp@2219: 
fp@2219: 	ret_val = e1000e_get_auto_rd_done(hw);
fp@2219: 	if (ret_val)
fp@2219: 		/* We don't want to continue accessing MAC registers. */
fp@2219: 		return ret_val;
fp@2219: 
fp@2219: 	/* Clear any pending interrupt events. */
fp@2219: 	ew32(IMC, 0xffffffff);
fp@2219: 	icr = er32(ICR);
fp@2219: 
fp@2219: 	ret_val = e1000_check_alt_mac_addr_generic(hw);
fp@2219: 
fp@2219: 	return ret_val;
fp@2219: }
fp@2219: 
fp@2219: /**
fp@2219:  *  e1000_init_hw_80003es2lan - Initialize the ESB2 controller
fp@2219:  *  @hw: pointer to the HW structure
fp@2219:  *
fp@2219:  *  Initialize the hw bits, LED, VFTA, MTA, link and hw counters.
fp@2219:  **/
fp@2219: static s32 e1000_init_hw_80003es2lan(struct e1000_hw *hw)
fp@2219: {
fp@2219: 	struct e1000_mac_info *mac = &hw->mac;
fp@2219: 	u32 reg_data;
fp@2219: 	s32 ret_val;
fp@2219: 	u16 i;
fp@2219: 
fp@2219: 	e1000_initialize_hw_bits_80003es2lan(hw);
fp@2219: 
fp@2219: 	/* Initialize identification LED */
fp@2219: 	ret_val = e1000e_id_led_init(hw);
fp@2219: 	if (ret_val)
fp@2219: 		e_dbg("Error initializing identification LED\n");
fp@2219: 		/* This is not fatal and we should not stop init due to this */
fp@2219: 
fp@2219: 	/* Disabling VLAN filtering */
fp@2219: 	e_dbg("Initializing the IEEE VLAN\n");
fp@2219: 	mac->ops.clear_vfta(hw);
fp@2219: 
fp@2219: 	/* Setup the receive address. */
fp@2219: 	e1000e_init_rx_addrs(hw, mac->rar_entry_count);
fp@2219: 
fp@2219: 	/* Zero out the Multicast HASH table */
fp@2219: 	e_dbg("Zeroing the MTA\n");
fp@2219: 	for (i = 0; i < mac->mta_reg_count; i++)
fp@2219: 		E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
fp@2219: 
fp@2219: 	/* Setup link and flow control */
fp@2219: 	ret_val = e1000e_setup_link(hw);
fp@2219: 
fp@2219: 	/* Set the transmit descriptor write-back policy */
fp@2219: 	reg_data = er32(TXDCTL(0));
fp@2219: 	reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) |
fp@2219: 		   E1000_TXDCTL_FULL_TX_DESC_WB | E1000_TXDCTL_COUNT_DESC;
fp@2219: 	ew32(TXDCTL(0), reg_data);
fp@2219: 
fp@2219: 	/* ...for both queues. */
fp@2219: 	reg_data = er32(TXDCTL(1));
fp@2219: 	reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) |
fp@2219: 		   E1000_TXDCTL_FULL_TX_DESC_WB | E1000_TXDCTL_COUNT_DESC;
fp@2219: 	ew32(TXDCTL(1), reg_data);
fp@2219: 
fp@2219: 	/* Enable retransmit on late collisions */
fp@2219: 	reg_data = er32(TCTL);
fp@2219: 	reg_data |= E1000_TCTL_RTLC;
fp@2219: 	ew32(TCTL, reg_data);
fp@2219: 
fp@2219: 	/* Configure Gigabit Carry Extend Padding */
fp@2219: 	reg_data = er32(TCTL_EXT);
fp@2219: 	reg_data &= ~E1000_TCTL_EXT_GCEX_MASK;
fp@2219: 	reg_data |= DEFAULT_TCTL_EXT_GCEX_80003ES2LAN;
fp@2219: 	ew32(TCTL_EXT, reg_data);
fp@2219: 
fp@2219: 	/* Configure Transmit Inter-Packet Gap */
fp@2219: 	reg_data = er32(TIPG);
fp@2219: 	reg_data &= ~E1000_TIPG_IPGT_MASK;
fp@2219: 	reg_data |= DEFAULT_TIPG_IPGT_1000_80003ES2LAN;
fp@2219: 	ew32(TIPG, reg_data);
fp@2219: 
fp@2219: 	reg_data = E1000_READ_REG_ARRAY(hw, E1000_FFLT, 0x0001);
fp@2219: 	reg_data &= ~0x00100000;
fp@2219: 	E1000_WRITE_REG_ARRAY(hw, E1000_FFLT, 0x0001, reg_data);
fp@2219: 
fp@2219: 	/* default to true to enable the MDIC W/A */
fp@2219: 	hw->dev_spec.e80003es2lan.mdic_wa_enable = true;
fp@2219: 
fp@2219: 	ret_val = e1000_read_kmrn_reg_80003es2lan(hw,
fp@2219: 	                              E1000_KMRNCTRLSTA_OFFSET >>
fp@2219: 	                              E1000_KMRNCTRLSTA_OFFSET_SHIFT,
fp@2219: 	                              &i);
fp@2219: 	if (!ret_val) {
fp@2219: 		if ((i & E1000_KMRNCTRLSTA_OPMODE_MASK) ==
fp@2219: 		     E1000_KMRNCTRLSTA_OPMODE_INBAND_MDIO)
fp@2219: 			hw->dev_spec.e80003es2lan.mdic_wa_enable = false;
fp@2219: 	}
fp@2219: 
fp@2219: 	/*
fp@2219: 	 * Clear all of the statistics registers (clear on read).  It is
fp@2219: 	 * important that we do this after we have tried to establish link
fp@2219: 	 * because the symbol error count will increment wildly if there
fp@2219: 	 * is no link.
fp@2219: 	 */
fp@2219: 	e1000_clear_hw_cntrs_80003es2lan(hw);
fp@2219: 
fp@2219: 	return ret_val;
fp@2219: }
fp@2219: 
fp@2219: /**
fp@2219:  *  e1000_initialize_hw_bits_80003es2lan - Init hw bits of ESB2
fp@2219:  *  @hw: pointer to the HW structure
fp@2219:  *
fp@2219:  *  Initializes required hardware-dependent bits needed for normal operation.
fp@2219:  **/
fp@2219: static void e1000_initialize_hw_bits_80003es2lan(struct e1000_hw *hw)
fp@2219: {
fp@2219: 	u32 reg;
fp@2219: 
fp@2219: 	/* Transmit Descriptor Control 0 */
fp@2219: 	reg = er32(TXDCTL(0));
fp@2219: 	reg |= (1 << 22);
fp@2219: 	ew32(TXDCTL(0), reg);
fp@2219: 
fp@2219: 	/* Transmit Descriptor Control 1 */
fp@2219: 	reg = er32(TXDCTL(1));
fp@2219: 	reg |= (1 << 22);
fp@2219: 	ew32(TXDCTL(1), reg);
fp@2219: 
fp@2219: 	/* Transmit Arbitration Control 0 */
fp@2219: 	reg = er32(TARC(0));
fp@2219: 	reg &= ~(0xF << 27); /* 30:27 */
fp@2219: 	if (hw->phy.media_type != e1000_media_type_copper)
fp@2219: 		reg &= ~(1 << 20);
fp@2219: 	ew32(TARC(0), reg);
fp@2219: 
fp@2219: 	/* Transmit Arbitration Control 1 */
fp@2219: 	reg = er32(TARC(1));
fp@2219: 	if (er32(TCTL) & E1000_TCTL_MULR)
fp@2219: 		reg &= ~(1 << 28);
fp@2219: 	else
fp@2219: 		reg |= (1 << 28);
fp@2219: 	ew32(TARC(1), reg);
fp@2219: }
fp@2219: 
fp@2219: /**
fp@2219:  *  e1000_copper_link_setup_gg82563_80003es2lan - Configure GG82563 Link
fp@2219:  *  @hw: pointer to the HW structure
fp@2219:  *
fp@2219:  *  Setup some GG82563 PHY registers for obtaining link
fp@2219:  **/
fp@2219: static s32 e1000_copper_link_setup_gg82563_80003es2lan(struct e1000_hw *hw)
fp@2219: {
fp@2219: 	struct e1000_phy_info *phy = &hw->phy;
fp@2219: 	s32 ret_val;
fp@2219: 	u32 ctrl_ext;
fp@2219: 	u16 data;
fp@2219: 
fp@2219: 	ret_val = e1e_rphy(hw, GG82563_PHY_MAC_SPEC_CTRL, &data);
fp@2219: 	if (ret_val)
fp@2219: 		return ret_val;
fp@2219: 
fp@2219: 	data |= GG82563_MSCR_ASSERT_CRS_ON_TX;
fp@2219: 	/* Use 25MHz for both link down and 1000Base-T for Tx clock. */
fp@2219: 	data |= GG82563_MSCR_TX_CLK_1000MBPS_25;
fp@2219: 
fp@2219: 	ret_val = e1e_wphy(hw, GG82563_PHY_MAC_SPEC_CTRL, data);
fp@2219: 	if (ret_val)
fp@2219: 		return ret_val;
fp@2219: 
fp@2219: 	/*
fp@2219: 	 * Options:
fp@2219: 	 *   MDI/MDI-X = 0 (default)
fp@2219: 	 *   0 - Auto for all speeds
fp@2219: 	 *   1 - MDI mode
fp@2219: 	 *   2 - MDI-X mode
fp@2219: 	 *   3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes)
fp@2219: 	 */
fp@2219: 	ret_val = e1e_rphy(hw, GG82563_PHY_SPEC_CTRL, &data);
fp@2219: 	if (ret_val)
fp@2219: 		return ret_val;
fp@2219: 
fp@2219: 	data &= ~GG82563_PSCR_CROSSOVER_MODE_MASK;
fp@2219: 
fp@2219: 	switch (phy->mdix) {
fp@2219: 	case 1:
fp@2219: 		data |= GG82563_PSCR_CROSSOVER_MODE_MDI;
fp@2219: 		break;
fp@2219: 	case 2:
fp@2219: 		data |= GG82563_PSCR_CROSSOVER_MODE_MDIX;
fp@2219: 		break;
fp@2219: 	case 0:
fp@2219: 	default:
fp@2219: 		data |= GG82563_PSCR_CROSSOVER_MODE_AUTO;
fp@2219: 		break;
fp@2219: 	}
fp@2219: 
fp@2219: 	/*
fp@2219: 	 * Options:
fp@2219: 	 *   disable_polarity_correction = 0 (default)
fp@2219: 	 *       Automatic Correction for Reversed Cable Polarity
fp@2219: 	 *   0 - Disabled
fp@2219: 	 *   1 - Enabled
fp@2219: 	 */
fp@2219: 	data &= ~GG82563_PSCR_POLARITY_REVERSAL_DISABLE;
fp@2219: 	if (phy->disable_polarity_correction)
fp@2219: 		data |= GG82563_PSCR_POLARITY_REVERSAL_DISABLE;
fp@2219: 
fp@2219: 	ret_val = e1e_wphy(hw, GG82563_PHY_SPEC_CTRL, data);
fp@2219: 	if (ret_val)
fp@2219: 		return ret_val;
fp@2219: 
fp@2219: 	/* SW Reset the PHY so all changes take effect */
fp@2219: 	ret_val = e1000e_commit_phy(hw);
fp@2219: 	if (ret_val) {
fp@2219: 		e_dbg("Error Resetting the PHY\n");
fp@2219: 		return ret_val;
fp@2219: 	}
fp@2219: 
fp@2219: 	/* Bypass Rx and Tx FIFO's */
fp@2219: 	ret_val = e1000_write_kmrn_reg_80003es2lan(hw,
fp@2219: 					E1000_KMRNCTRLSTA_OFFSET_FIFO_CTRL,
fp@2219: 					E1000_KMRNCTRLSTA_FIFO_CTRL_RX_BYPASS |
fp@2219: 					E1000_KMRNCTRLSTA_FIFO_CTRL_TX_BYPASS);
fp@2219: 	if (ret_val)
fp@2219: 		return ret_val;
fp@2219: 
fp@2219: 	ret_val = e1000_read_kmrn_reg_80003es2lan(hw,
fp@2219: 				       E1000_KMRNCTRLSTA_OFFSET_MAC2PHY_OPMODE,
fp@2219: 				       &data);
fp@2219: 	if (ret_val)
fp@2219: 		return ret_val;
fp@2219: 	data |= E1000_KMRNCTRLSTA_OPMODE_E_IDLE;
fp@2219: 	ret_val = e1000_write_kmrn_reg_80003es2lan(hw,
fp@2219: 					E1000_KMRNCTRLSTA_OFFSET_MAC2PHY_OPMODE,
fp@2219: 					data);
fp@2219: 	if (ret_val)
fp@2219: 		return ret_val;
fp@2219: 
fp@2219: 	ret_val = e1e_rphy(hw, GG82563_PHY_SPEC_CTRL_2, &data);
fp@2219: 	if (ret_val)
fp@2219: 		return ret_val;
fp@2219: 
fp@2219: 	data &= ~GG82563_PSCR2_REVERSE_AUTO_NEG;
fp@2219: 	ret_val = e1e_wphy(hw, GG82563_PHY_SPEC_CTRL_2, data);
fp@2219: 	if (ret_val)
fp@2219: 		return ret_val;
fp@2219: 
fp@2219: 	ctrl_ext = er32(CTRL_EXT);
fp@2219: 	ctrl_ext &= ~(E1000_CTRL_EXT_LINK_MODE_MASK);
fp@2219: 	ew32(CTRL_EXT, ctrl_ext);
fp@2219: 
fp@2219: 	ret_val = e1e_rphy(hw, GG82563_PHY_PWR_MGMT_CTRL, &data);
fp@2219: 	if (ret_val)
fp@2219: 		return ret_val;
fp@2219: 
fp@2219: 	/*
fp@2219: 	 * Do not init these registers when the HW is in IAMT mode, since the
fp@2219: 	 * firmware will have already initialized them.  We only initialize
fp@2219: 	 * them if the HW is not in IAMT mode.
fp@2219: 	 */
fp@2219: 	if (!e1000e_check_mng_mode(hw)) {
fp@2219: 		/* Enable Electrical Idle on the PHY */
fp@2219: 		data |= GG82563_PMCR_ENABLE_ELECTRICAL_IDLE;
fp@2219: 		ret_val = e1e_wphy(hw, GG82563_PHY_PWR_MGMT_CTRL, data);
fp@2219: 		if (ret_val)
fp@2219: 			return ret_val;
fp@2219: 
fp@2219: 		ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &data);
fp@2219: 		if (ret_val)
fp@2219: 			return ret_val;
fp@2219: 
fp@2219: 		data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
fp@2219: 		ret_val = e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, data);
fp@2219: 		if (ret_val)
fp@2219: 			return ret_val;
fp@2219: 	}
fp@2219: 
fp@2219: 	/*
fp@2219: 	 * Workaround: Disable padding in Kumeran interface in the MAC
fp@2219: 	 * and in the PHY to avoid CRC errors.
fp@2219: 	 */
fp@2219: 	ret_val = e1e_rphy(hw, GG82563_PHY_INBAND_CTRL, &data);
fp@2219: 	if (ret_val)
fp@2219: 		return ret_val;
fp@2219: 
fp@2219: 	data |= GG82563_ICR_DIS_PADDING;
fp@2219: 	ret_val = e1e_wphy(hw, GG82563_PHY_INBAND_CTRL, data);
fp@2219: 	if (ret_val)
fp@2219: 		return ret_val;
fp@2219: 
fp@2219: 	return 0;
fp@2219: }
fp@2219: 
fp@2219: /**
fp@2219:  *  e1000_setup_copper_link_80003es2lan - Setup Copper Link for ESB2
fp@2219:  *  @hw: pointer to the HW structure
fp@2219:  *
fp@2219:  *  Essentially a wrapper for setting up all things "copper" related.
fp@2219:  *  This is a function pointer entry point called by the mac module.
fp@2219:  **/
fp@2219: static s32 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw)
fp@2219: {
fp@2219: 	u32 ctrl;
fp@2219: 	s32 ret_val;
fp@2219: 	u16 reg_data;
fp@2219: 
fp@2219: 	ctrl = er32(CTRL);
fp@2219: 	ctrl |= E1000_CTRL_SLU;
fp@2219: 	ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
fp@2219: 	ew32(CTRL, ctrl);
fp@2219: 
fp@2219: 	/*
fp@2219: 	 * Set the mac to wait the maximum time between each
fp@2219: 	 * iteration and increase the max iterations when
fp@2219: 	 * polling the phy; this fixes erroneous timeouts at 10Mbps.
fp@2219: 	 */
fp@2219: 	ret_val = e1000_write_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 4),
fp@2219: 	                                           0xFFFF);
fp@2219: 	if (ret_val)
fp@2219: 		return ret_val;
fp@2219: 	ret_val = e1000_read_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 9),
fp@2219: 	                                          &reg_data);
fp@2219: 	if (ret_val)
fp@2219: 		return ret_val;
fp@2219: 	reg_data |= 0x3F;
fp@2219: 	ret_val = e1000_write_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 9),
fp@2219: 	                                           reg_data);
fp@2219: 	if (ret_val)
fp@2219: 		return ret_val;
fp@2219: 	ret_val = e1000_read_kmrn_reg_80003es2lan(hw,
fp@2219: 				      E1000_KMRNCTRLSTA_OFFSET_INB_CTRL,
fp@2219: 				      &reg_data);
fp@2219: 	if (ret_val)
fp@2219: 		return ret_val;
fp@2219: 	reg_data |= E1000_KMRNCTRLSTA_INB_CTRL_DIS_PADDING;
fp@2219: 	ret_val = e1000_write_kmrn_reg_80003es2lan(hw,
fp@2219: 					E1000_KMRNCTRLSTA_OFFSET_INB_CTRL,
fp@2219: 					reg_data);
fp@2219: 	if (ret_val)
fp@2219: 		return ret_val;
fp@2219: 
fp@2219: 	ret_val = e1000_copper_link_setup_gg82563_80003es2lan(hw);
fp@2219: 	if (ret_val)
fp@2219: 		return ret_val;
fp@2219: 
fp@2219: 	ret_val = e1000e_setup_copper_link(hw);
fp@2219: 
fp@2219: 	return 0;
fp@2219: }
fp@2219: 
fp@2219: /**
fp@2219:  *  e1000_cfg_on_link_up_80003es2lan - es2 link configuration after link-up
fp@2219:  *  @hw: pointer to the HW structure
fp@2219:  *  @duplex: current duplex setting
fp@2219:  *
fp@2219:  *  Configure the KMRN interface by applying last minute quirks for
fp@2219:  *  10/100 operation.
fp@2219:  **/
fp@2219: static s32 e1000_cfg_on_link_up_80003es2lan(struct e1000_hw *hw)
fp@2219: {
fp@2219: 	s32 ret_val = 0;
fp@2219: 	u16 speed;
fp@2219: 	u16 duplex;
fp@2219: 
fp@2219: 	if (hw->phy.media_type == e1000_media_type_copper) {
fp@2219: 		ret_val = e1000e_get_speed_and_duplex_copper(hw, &speed,
fp@2219: 		                                             &duplex);
fp@2219: 		if (ret_val)
fp@2219: 			return ret_val;
fp@2219: 
fp@2219: 		if (speed == SPEED_1000)
fp@2219: 			ret_val = e1000_cfg_kmrn_1000_80003es2lan(hw);
fp@2219: 		else
fp@2219: 			ret_val = e1000_cfg_kmrn_10_100_80003es2lan(hw, duplex);
fp@2219: 	}
fp@2219: 
fp@2219: 	return ret_val;
fp@2219: }
fp@2219: 
fp@2219: /**
fp@2219:  *  e1000_cfg_kmrn_10_100_80003es2lan - Apply "quirks" for 10/100 operation
fp@2219:  *  @hw: pointer to the HW structure
fp@2219:  *  @duplex: current duplex setting
fp@2219:  *
fp@2219:  *  Configure the KMRN interface by applying last minute quirks for
fp@2219:  *  10/100 operation.
fp@2219:  **/
fp@2219: static s32 e1000_cfg_kmrn_10_100_80003es2lan(struct e1000_hw *hw, u16 duplex)
fp@2219: {
fp@2219: 	s32 ret_val;
fp@2219: 	u32 tipg;
fp@2219: 	u32 i = 0;
fp@2219: 	u16 reg_data, reg_data2;
fp@2219: 
fp@2219: 	reg_data = E1000_KMRNCTRLSTA_HD_CTRL_10_100_DEFAULT;
fp@2219: 	ret_val = e1000_write_kmrn_reg_80003es2lan(hw,
fp@2219: 	                               E1000_KMRNCTRLSTA_OFFSET_HD_CTRL,
fp@2219: 	                               reg_data);
fp@2219: 	if (ret_val)
fp@2219: 		return ret_val;
fp@2219: 
fp@2219: 	/* Configure Transmit Inter-Packet Gap */
fp@2219: 	tipg = er32(TIPG);
fp@2219: 	tipg &= ~E1000_TIPG_IPGT_MASK;
fp@2219: 	tipg |= DEFAULT_TIPG_IPGT_10_100_80003ES2LAN;
fp@2219: 	ew32(TIPG, tipg);
fp@2219: 
fp@2219: 	do {
fp@2219: 		ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &reg_data);
fp@2219: 		if (ret_val)
fp@2219: 			return ret_val;
fp@2219: 
fp@2219: 		ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &reg_data2);
fp@2219: 		if (ret_val)
fp@2219: 			return ret_val;
fp@2219: 		i++;
fp@2219: 	} while ((reg_data != reg_data2) && (i < GG82563_MAX_KMRN_RETRY));
fp@2219: 
fp@2219: 	if (duplex == HALF_DUPLEX)
fp@2219: 		reg_data |= GG82563_KMCR_PASS_FALSE_CARRIER;
fp@2219: 	else
fp@2219: 		reg_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
fp@2219: 
fp@2219: 	ret_val = e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data);
fp@2219: 
fp@2219: 	return 0;
fp@2219: }
fp@2219: 
fp@2219: /**
fp@2219:  *  e1000_cfg_kmrn_1000_80003es2lan - Apply "quirks" for gigabit operation
fp@2219:  *  @hw: pointer to the HW structure
fp@2219:  *
fp@2219:  *  Configure the KMRN interface by applying last minute quirks for
fp@2219:  *  gigabit operation.
fp@2219:  **/
fp@2219: static s32 e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw)
fp@2219: {
fp@2219: 	s32 ret_val;
fp@2219: 	u16 reg_data, reg_data2;
fp@2219: 	u32 tipg;
fp@2219: 	u32 i = 0;
fp@2219: 
fp@2219: 	reg_data = E1000_KMRNCTRLSTA_HD_CTRL_1000_DEFAULT;
fp@2219: 	ret_val = e1000_write_kmrn_reg_80003es2lan(hw,
fp@2219: 	                               E1000_KMRNCTRLSTA_OFFSET_HD_CTRL,
fp@2219: 	                               reg_data);
fp@2219: 	if (ret_val)
fp@2219: 		return ret_val;
fp@2219: 
fp@2219: 	/* Configure Transmit Inter-Packet Gap */
fp@2219: 	tipg = er32(TIPG);
fp@2219: 	tipg &= ~E1000_TIPG_IPGT_MASK;
fp@2219: 	tipg |= DEFAULT_TIPG_IPGT_1000_80003ES2LAN;
fp@2219: 	ew32(TIPG, tipg);
fp@2219: 
fp@2219: 	do {
fp@2219: 		ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &reg_data);
fp@2219: 		if (ret_val)
fp@2219: 			return ret_val;
fp@2219: 
fp@2219: 		ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &reg_data2);
fp@2219: 		if (ret_val)
fp@2219: 			return ret_val;
fp@2219: 		i++;
fp@2219: 	} while ((reg_data != reg_data2) && (i < GG82563_MAX_KMRN_RETRY));
fp@2219: 
fp@2219: 	reg_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
fp@2219: 	ret_val = e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data);
fp@2219: 
fp@2219: 	return ret_val;
fp@2219: }
fp@2219: 
fp@2219: /**
fp@2219:  *  e1000_read_kmrn_reg_80003es2lan - Read kumeran register
fp@2219:  *  @hw: pointer to the HW structure
fp@2219:  *  @offset: register offset to be read
fp@2219:  *  @data: pointer to the read data
fp@2219:  *
fp@2219:  *  Acquire semaphore, then read the PHY register at offset
fp@2219:  *  using the kumeran interface.  The information retrieved is stored in data.
fp@2219:  *  Release the semaphore before exiting.
fp@2219:  **/
fp@2219: static s32 e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
fp@2219: 					   u16 *data)
fp@2219: {
fp@2219: 	u32 kmrnctrlsta;
fp@2219: 	s32 ret_val = 0;
fp@2219: 
fp@2219: 	ret_val = e1000_acquire_mac_csr_80003es2lan(hw);
fp@2219: 	if (ret_val)
fp@2219: 		return ret_val;
fp@2219: 
fp@2219: 	kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) &
fp@2219: 	               E1000_KMRNCTRLSTA_OFFSET) | E1000_KMRNCTRLSTA_REN;
fp@2219: 	ew32(KMRNCTRLSTA, kmrnctrlsta);
fp@2219: 
fp@2219: 	udelay(2);
fp@2219: 
fp@2219: 	kmrnctrlsta = er32(KMRNCTRLSTA);
fp@2219: 	*data = (u16)kmrnctrlsta;
fp@2219: 
fp@2219: 	e1000_release_mac_csr_80003es2lan(hw);
fp@2219: 
fp@2219: 	return ret_val;
fp@2219: }
fp@2219: 
fp@2219: /**
fp@2219:  *  e1000_write_kmrn_reg_80003es2lan - Write kumeran register
fp@2219:  *  @hw: pointer to the HW structure
fp@2219:  *  @offset: register offset to write to
fp@2219:  *  @data: data to write at register offset
fp@2219:  *
fp@2219:  *  Acquire semaphore, then write the data to PHY register
fp@2219:  *  at the offset using the kumeran interface.  Release semaphore
fp@2219:  *  before exiting.
fp@2219:  **/
fp@2219: static s32 e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
fp@2219: 					    u16 data)
fp@2219: {
fp@2219: 	u32 kmrnctrlsta;
fp@2219: 	s32 ret_val = 0;
fp@2219: 
fp@2219: 	ret_val = e1000_acquire_mac_csr_80003es2lan(hw);
fp@2219: 	if (ret_val)
fp@2219: 		return ret_val;
fp@2219: 
fp@2219: 	kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) &
fp@2219: 	               E1000_KMRNCTRLSTA_OFFSET) | data;
fp@2219: 	ew32(KMRNCTRLSTA, kmrnctrlsta);
fp@2219: 
fp@2219: 	udelay(2);
fp@2219: 
fp@2219: 	e1000_release_mac_csr_80003es2lan(hw);
fp@2219: 
fp@2219: 	return ret_val;
fp@2219: }
fp@2219: 
fp@2219: /**
fp@2219:  *  e1000_read_mac_addr_80003es2lan - Read device MAC address
fp@2219:  *  @hw: pointer to the HW structure
fp@2219:  **/
fp@2219: static s32 e1000_read_mac_addr_80003es2lan(struct e1000_hw *hw)
fp@2219: {
fp@2219: 	s32 ret_val = 0;
fp@2219: 
fp@2219: 	/*
fp@2219: 	 * If there's an alternate MAC address place it in RAR0
fp@2219: 	 * so that it will override the Si installed default perm
fp@2219: 	 * address.
fp@2219: 	 */
fp@2219: 	ret_val = e1000_check_alt_mac_addr_generic(hw);
fp@2219: 	if (ret_val)
fp@2219: 		goto out;
fp@2219: 
fp@2219: 	ret_val = e1000_read_mac_addr_generic(hw);
fp@2219: 
fp@2219: out:
fp@2219: 	return ret_val;
fp@2219: }
fp@2219: 
fp@2219: /**
fp@2219:  * e1000_power_down_phy_copper_80003es2lan - Remove link during PHY power down
fp@2219:  * @hw: pointer to the HW structure
fp@2219:  *
fp@2219:  * In the case of a PHY power down to save power, or to turn off link during a
fp@2219:  * driver unload, or wake on lan is not enabled, remove the link.
fp@2219:  **/
fp@2219: static void e1000_power_down_phy_copper_80003es2lan(struct e1000_hw *hw)
fp@2219: {
fp@2219: 	/* If the management interface is not enabled, then power down */
fp@2219: 	if (!(hw->mac.ops.check_mng_mode(hw) ||
fp@2219: 	      hw->phy.ops.check_reset_block(hw)))
fp@2219: 		e1000_power_down_phy_copper(hw);
fp@2219: }
fp@2219: 
fp@2219: /**
fp@2219:  *  e1000_clear_hw_cntrs_80003es2lan - Clear device specific hardware counters
fp@2219:  *  @hw: pointer to the HW structure
fp@2219:  *
fp@2219:  *  Clears the hardware counters by reading the counter registers.
fp@2219:  **/
fp@2219: static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw)
fp@2219: {
fp@2219: 	e1000e_clear_hw_cntrs_base(hw);
fp@2219: 
fp@2219: 	er32(PRC64);
fp@2219: 	er32(PRC127);
fp@2219: 	er32(PRC255);
fp@2219: 	er32(PRC511);
fp@2219: 	er32(PRC1023);
fp@2219: 	er32(PRC1522);
fp@2219: 	er32(PTC64);
fp@2219: 	er32(PTC127);
fp@2219: 	er32(PTC255);
fp@2219: 	er32(PTC511);
fp@2219: 	er32(PTC1023);
fp@2219: 	er32(PTC1522);
fp@2219: 
fp@2219: 	er32(ALGNERRC);
fp@2219: 	er32(RXERRC);
fp@2219: 	er32(TNCRS);
fp@2219: 	er32(CEXTERR);
fp@2219: 	er32(TSCTC);
fp@2219: 	er32(TSCTFC);
fp@2219: 
fp@2219: 	er32(MGTPRC);
fp@2219: 	er32(MGTPDC);
fp@2219: 	er32(MGTPTC);
fp@2219: 
fp@2219: 	er32(IAC);
fp@2219: 	er32(ICRXOC);
fp@2219: 
fp@2219: 	er32(ICRXPTC);
fp@2219: 	er32(ICRXATC);
fp@2219: 	er32(ICTXPTC);
fp@2219: 	er32(ICTXATC);
fp@2219: 	er32(ICTXQEC);
fp@2219: 	er32(ICTXQMTC);
fp@2219: 	er32(ICRXDMTC);
fp@2219: }
fp@2219: 
fp@2219: static struct e1000_mac_operations es2_mac_ops = {
fp@2219: 	.read_mac_addr		= e1000_read_mac_addr_80003es2lan,
fp@2219: 	.id_led_init		= e1000e_id_led_init,
fp@2219: 	.check_mng_mode		= e1000e_check_mng_mode_generic,
fp@2219: 	/* check_for_link dependent on media type */
fp@2219: 	.cleanup_led		= e1000e_cleanup_led_generic,
fp@2219: 	.clear_hw_cntrs		= e1000_clear_hw_cntrs_80003es2lan,
fp@2219: 	.get_bus_info		= e1000e_get_bus_info_pcie,
fp@2219: 	.set_lan_id		= e1000_set_lan_id_multi_port_pcie,
fp@2219: 	.get_link_up_info	= e1000_get_link_up_info_80003es2lan,
fp@2219: 	.led_on			= e1000e_led_on_generic,
fp@2219: 	.led_off		= e1000e_led_off_generic,
fp@2219: 	.update_mc_addr_list	= e1000e_update_mc_addr_list_generic,
fp@2219: 	.write_vfta		= e1000_write_vfta_generic,
fp@2219: 	.clear_vfta		= e1000_clear_vfta_generic,
fp@2219: 	.reset_hw		= e1000_reset_hw_80003es2lan,
fp@2219: 	.init_hw		= e1000_init_hw_80003es2lan,
fp@2219: 	.setup_link		= e1000e_setup_link,
fp@2219: 	/* setup_physical_interface dependent on media type */
fp@2219: 	.setup_led		= e1000e_setup_led_generic,
fp@2219: };
fp@2219: 
fp@2219: static struct e1000_phy_operations es2_phy_ops = {
fp@2219: 	.acquire		= e1000_acquire_phy_80003es2lan,
fp@2219: 	.check_polarity		= e1000_check_polarity_m88,
fp@2219: 	.check_reset_block	= e1000e_check_reset_block_generic,
fp@2219: 	.commit		 	= e1000e_phy_sw_reset,
fp@2219: 	.force_speed_duplex 	= e1000_phy_force_speed_duplex_80003es2lan,
fp@2219: 	.get_cfg_done       	= e1000_get_cfg_done_80003es2lan,
fp@2219: 	.get_cable_length   	= e1000_get_cable_length_80003es2lan,
fp@2219: 	.get_info       	= e1000e_get_phy_info_m88,
fp@2219: 	.read_reg       	= e1000_read_phy_reg_gg82563_80003es2lan,
fp@2219: 	.release		= e1000_release_phy_80003es2lan,
fp@2219: 	.reset		  	= e1000e_phy_hw_reset_generic,
fp@2219: 	.set_d0_lplu_state  	= NULL,
fp@2219: 	.set_d3_lplu_state  	= e1000e_set_d3_lplu_state,
fp@2219: 	.write_reg      	= e1000_write_phy_reg_gg82563_80003es2lan,
fp@2219: 	.cfg_on_link_up      	= e1000_cfg_on_link_up_80003es2lan,
fp@2219: };
fp@2219: 
fp@2219: static struct e1000_nvm_operations es2_nvm_ops = {
fp@2219: 	.acquire		= e1000_acquire_nvm_80003es2lan,
fp@2219: 	.read			= e1000e_read_nvm_eerd,
fp@2219: 	.release		= e1000_release_nvm_80003es2lan,
fp@2219: 	.update			= e1000e_update_nvm_checksum_generic,
fp@2219: 	.valid_led_default	= e1000e_valid_led_default,
fp@2219: 	.validate		= e1000e_validate_nvm_checksum_generic,
fp@2219: 	.write			= e1000_write_nvm_80003es2lan,
fp@2219: };
fp@2219: 
fp@2219: struct e1000_info e1000_es2_info = {
fp@2219: 	.mac			= e1000_80003es2lan,
fp@2219: 	.flags			= FLAG_HAS_HW_VLAN_FILTER
fp@2219: 				  | FLAG_HAS_JUMBO_FRAMES
fp@2219: 				  | FLAG_HAS_WOL
fp@2219: 				  | FLAG_APME_IN_CTRL3
fp@2219: 				  | FLAG_RX_CSUM_ENABLED
fp@2219: 				  | FLAG_HAS_CTRLEXT_ON_LOAD
fp@2219: 				  | FLAG_RX_NEEDS_RESTART /* errata */
fp@2219: 				  | FLAG_TARC_SET_BIT_ZERO /* errata */
fp@2219: 				  | FLAG_APME_CHECK_PORT_B
fp@2219: 				  | FLAG_DISABLE_FC_PAUSE_TIME /* errata */
fp@2219: 				  | FLAG_TIPG_MEDIUM_FOR_80003ESLAN,
fp@2219: 	.flags2			= FLAG2_DMA_BURST,
fp@2219: 	.pba			= 38,
fp@2219: 	.max_hw_frame_size	= DEFAULT_JUMBO,
fp@2219: 	.get_variants		= e1000_get_variants_80003es2lan,
fp@2219: 	.mac_ops		= &es2_mac_ops,
fp@2219: 	.phy_ops		= &es2_phy_ops,
fp@2219: 	.nvm_ops		= &es2_nvm_ops,
fp@2219: };
fp@2219: