⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e1000_82540.c

📁 linux系统的网卡驱动包
💻 C
📖 第 1 页 / 共 2 页
字号:
/*******************************************************************************  Intel PRO/1000 Linux driver  Copyright(c) 1999 - 2008 Intel Corporation.  This program is free software; you can redistribute it and/or modify it  under the terms and conditions of the GNU General Public License,  version 2, as published by the Free Software Foundation.  This program is distributed in the hope it will be useful, but WITHOUT  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for  more details.  You should have received a copy of the GNU General Public License along with  this program; if not, write to the Free Software Foundation, Inc.,  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.  The full GNU General Public License is included in this distribution in  the file called "COPYING".  Contact Information:  Linux NICS <linux.nics@intel.com>  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497*******************************************************************************//* e1000_82540 * e1000_82545 * e1000_82546 * e1000_82545_rev_3 * e1000_82546_rev_3 */#include "e1000_api.h"static s32  e1000_init_phy_params_82540(struct e1000_hw *hw);static s32  e1000_init_nvm_params_82540(struct e1000_hw *hw);static s32  e1000_init_mac_params_82540(struct e1000_hw *hw);static s32  e1000_adjust_serdes_amplitude_82540(struct e1000_hw *hw);static void e1000_clear_hw_cntrs_82540(struct e1000_hw *hw);static s32  e1000_init_hw_82540(struct e1000_hw *hw);static s32  e1000_reset_hw_82540(struct e1000_hw *hw);static s32  e1000_set_phy_mode_82540(struct e1000_hw *hw);static s32  e1000_set_vco_speed_82540(struct e1000_hw *hw);static s32  e1000_setup_copper_link_82540(struct e1000_hw *hw);static s32  e1000_setup_fiber_serdes_link_82540(struct e1000_hw *hw);static void e1000_power_down_phy_copper_82540(struct e1000_hw *hw);/** * e1000_init_phy_params_82540 - Init PHY func ptrs. * @hw: pointer to the HW structure * * This is a function pointer entry point called by the api module. **/static s32 e1000_init_phy_params_82540(struct e1000_hw *hw){	struct e1000_phy_info *phy = &hw->phy;	struct e1000_functions *func = &hw->func;	s32 ret_val = E1000_SUCCESS;	phy->addr                       = 1;	phy->autoneg_mask               = AUTONEG_ADVERTISE_SPEED_DEFAULT;	phy->reset_delay_us             = 10000;	phy->type                       = e1000_phy_m88;	/* Function Pointers */	func->check_polarity            = e1000_check_polarity_m88;	func->commit_phy                = e1000_phy_sw_reset_generic;	func->force_speed_duplex        = e1000_phy_force_speed_duplex_m88;	func->get_cable_length          = e1000_get_cable_length_m88;	func->get_cfg_done              = e1000_get_cfg_done_generic;	func->read_phy_reg              = e1000_read_phy_reg_m88;	func->reset_phy                 = e1000_phy_hw_reset_generic;	func->write_phy_reg             = e1000_write_phy_reg_m88;	func->get_phy_info              = e1000_get_phy_info_m88;	func->power_up_phy              = e1000_power_up_phy_copper;	func->power_down_phy            = e1000_power_down_phy_copper_82540;	ret_val = e1000_get_phy_id(hw);	if (ret_val)		goto out;	/* Verify phy id */	switch (hw->mac.type) {	case e1000_82540:	case e1000_82545:	case e1000_82545_rev_3:	case e1000_82546:	case e1000_82546_rev_3:		if (phy->id == M88E1011_I_PHY_ID)			break;		/* Fall Through */	default:		ret_val = -E1000_ERR_PHY;		goto out;		break;	}out:	return ret_val;}/** * e1000_init_nvm_params_82540 - Init NVM func ptrs. * @hw: pointer to the HW structure * * This is a function pointer entry point called by the api module. **/static s32 e1000_init_nvm_params_82540(struct e1000_hw *hw){	struct e1000_nvm_info *nvm = &hw->nvm;	struct e1000_functions *func = &hw->func;	u32 eecd = E1000_READ_REG(hw, E1000_EECD);	DEBUGFUNC("e1000_init_nvm_params_82540");	nvm->type               = e1000_nvm_eeprom_microwire;	nvm->delay_usec         = 50;	nvm->opcode_bits        = 3;	switch (nvm->override) {	case e1000_nvm_override_microwire_large:		nvm->address_bits       = 8;		nvm->word_size          = 256;		break;	case e1000_nvm_override_microwire_small:		nvm->address_bits       = 6;		nvm->word_size          = 64;		break;	default:		nvm->address_bits       = eecd & E1000_EECD_SIZE ? 8 : 6;		nvm->word_size          = eecd & E1000_EECD_SIZE ? 256 : 64;		break;	}	/* Function Pointers */	func->acquire_nvm        = e1000_acquire_nvm_generic;	func->read_nvm           = e1000_read_nvm_microwire;	func->release_nvm        = e1000_release_nvm_generic;	func->update_nvm         = e1000_update_nvm_checksum_generic;	func->valid_led_default  = e1000_valid_led_default_generic;	func->validate_nvm       = e1000_validate_nvm_checksum_generic;	func->write_nvm          = e1000_write_nvm_microwire;	return E1000_SUCCESS;}/** * e1000_init_mac_params_82540 - Init MAC func ptrs. * @hw: pointer to the HW structure * * This is a function pointer entry point called by the api module. **/static s32 e1000_init_mac_params_82540(struct e1000_hw *hw){	struct e1000_mac_info *mac = &hw->mac;	struct e1000_functions *func = &hw->func;	s32 ret_val = E1000_SUCCESS;	DEBUGFUNC("e1000_init_mac_params_82540");	/* Set media type */	switch (hw->device_id) {	case E1000_DEV_ID_82545EM_FIBER:	case E1000_DEV_ID_82545GM_FIBER:	case E1000_DEV_ID_82546EB_FIBER:	case E1000_DEV_ID_82546GB_FIBER:		hw->phy.media_type = e1000_media_type_fiber;		break;	case E1000_DEV_ID_82545GM_SERDES:	case E1000_DEV_ID_82546GB_SERDES:		hw->phy.media_type = e1000_media_type_internal_serdes;		break;	default:		hw->phy.media_type = e1000_media_type_copper;		break;	}	/* Set mta register count */	mac->mta_reg_count = 128;	/* Set rar entry count */	mac->rar_entry_count = E1000_RAR_ENTRIES;	/* Function pointers */	/* bus type/speed/width */	func->get_bus_info = e1000_get_bus_info_pci_generic;	/* reset */	func->reset_hw = e1000_reset_hw_82540;	/* hw initialization */	func->init_hw = e1000_init_hw_82540;	/* link setup */	func->setup_link = e1000_setup_link_generic;	/* physical interface setup */	func->setup_physical_interface =	        (hw->phy.media_type == e1000_media_type_copper)	                ? e1000_setup_copper_link_82540	                : e1000_setup_fiber_serdes_link_82540;	/* check for link */	switch (hw->phy.media_type) {	case e1000_media_type_copper:		func->check_for_link = e1000_check_for_copper_link_generic;		break;	case e1000_media_type_fiber:		func->check_for_link = e1000_check_for_fiber_link_generic;		break;	case e1000_media_type_internal_serdes:		func->check_for_link = e1000_check_for_serdes_link_generic;		break;	default:		ret_val = -E1000_ERR_CONFIG;		goto out;		break;	}	/* link info */	func->get_link_up_info =	        (hw->phy.media_type == e1000_media_type_copper)	                ? e1000_get_speed_and_duplex_copper_generic	                : e1000_get_speed_and_duplex_fiber_serdes_generic;	/* multicast address update */	func->update_mc_addr_list = e1000_update_mc_addr_list_generic;	/* writing VFTA */	func->write_vfta = e1000_write_vfta_generic;	/* clearing VFTA */	func->clear_vfta = e1000_clear_vfta_generic;	/* setting MTA */	func->mta_set = e1000_mta_set_generic;	/* setup LED */	func->setup_led = e1000_setup_led_generic;	/* cleanup LED */	func->cleanup_led = e1000_cleanup_led_generic;	/* turn on/off LED */	func->led_on = e1000_led_on_generic;	func->led_off = e1000_led_off_generic;	/* clear hardware counters */	func->clear_hw_cntrs = e1000_clear_hw_cntrs_82540;out:	return ret_val;}/** * e1000_init_function_pointers_82540 - Init func ptrs. * @hw: pointer to the HW structure * * The only function explicitly called by the api module to initialize * all function pointers and parameters. **/void e1000_init_function_pointers_82540(struct e1000_hw *hw){	DEBUGFUNC("e1000_init_function_pointers_82540");	hw->func.init_mac_params = e1000_init_mac_params_82540;	hw->func.init_nvm_params = e1000_init_nvm_params_82540;	hw->func.init_phy_params = e1000_init_phy_params_82540;}/** *  e1000_reset_hw_82540 - Reset hardware *  @hw: pointer to the HW structure * *  This resets the hardware into a known state.  This is a *  function pointer entry point called by the api module. **/static s32 e1000_reset_hw_82540(struct e1000_hw *hw){	u32 ctrl, icr, manc;	s32 ret_val = E1000_SUCCESS;	DEBUGFUNC("e1000_reset_hw_82540");	DEBUGOUT("Masking off all interrupts\n");	E1000_WRITE_REG(hw, E1000_IMC, 0xFFFFFFFF);	E1000_WRITE_REG(hw, E1000_RCTL, 0);	E1000_WRITE_REG(hw, E1000_TCTL, E1000_TCTL_PSP);	E1000_WRITE_FLUSH(hw);	/*	 * Delay to allow any outstanding PCI transactions to complete	 * before resetting the device.	 */	msec_delay(10);	ctrl = E1000_READ_REG(hw, E1000_CTRL);	DEBUGOUT("Issuing a global reset to 82540/82545/82546 MAC\n");	switch (hw->mac.type) {	case e1000_82545_rev_3:	case e1000_82546_rev_3:		E1000_WRITE_REG(hw, E1000_CTRL_DUP, ctrl | E1000_CTRL_RST);		break;	default:		/*		 * These controllers can't ack the 64-bit write when		 * issuing the reset, so we use IO-mapping as a		 * workaround to issue the reset.		 */		E1000_WRITE_REG_IO(hw, E1000_CTRL, ctrl | E1000_CTRL_RST);		break;	}	/* Wait for EEPROM reload */	msec_delay(5);	/* Disable HW ARPs on ASF enabled adapters */	manc = E1000_READ_REG(hw, E1000_MANC);	manc &= ~E1000_MANC_ARP_EN;	E1000_WRITE_REG(hw, E1000_MANC, manc);	E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);	icr = E1000_READ_REG(hw, E1000_ICR);	return ret_val;}/** *  e1000_init_hw_82540 - Initialize hardware *  @hw: pointer to the HW structure * *  This inits the hardware readying it for operation.  This is a *  function pointer entry point called by the api module. **/static s32 e1000_init_hw_82540(struct e1000_hw *hw){	struct e1000_mac_info *mac = &hw->mac;	u32 txdctl, ctrl_ext;	s32 ret_val = E1000_SUCCESS;	u16 i;	DEBUGFUNC("e1000_init_hw_82540");	/* Initialize identification LED */	ret_val = e1000_id_led_init_generic(hw);	if (ret_val) {		DEBUGOUT("Error initializing identification LED\n");		/* This is not fatal and we should not stop init due to this */	}	/* Disabling VLAN filtering */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -