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

📄 e1000_ich8lan.c

📁 DELL755 Intel 网卡驱动
💻 C
📖 第 1 页 / 共 5 页
字号:
	/* bank size is in 16bit words - adjust to bytes */	u32 flash_bank_size = nvm->flash_bank_size * 2;	s32  ret_val = E1000_SUCCESS;	s32  count = 0;	s32  j, iteration, sector_size;	DEBUGFUNC("e1000_erase_flash_bank_ich8lan");	hsfsts.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFSTS);	/*	 * Determine HW Sector size: Read BERASE bits of hw flash status	 * register	 * 00: The Hw sector is 256 bytes, hence we need to erase 16	 *     consecutive sectors.  The start index for the nth Hw sector	 *     can be calculated as = bank * 4096 + n * 256	 * 01: The Hw sector is 4K bytes, hence we need to erase 1 sector.	 *     The start index for the nth Hw sector can be calculated	 *     as = bank * 4096	 * 10: The Hw sector is 8K bytes, nth sector = bank * 8192	 *     (ich9 only, otherwise error condition)	 * 11: The Hw sector is 64K bytes, nth sector = bank * 65536	 */	switch (hsfsts.hsf_status.berasesz) {	case 0:		/* Hw sector size 256 */		sector_size = ICH_FLASH_SEG_SIZE_256;		iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_256;		break;	case 1:		sector_size = ICH_FLASH_SEG_SIZE_4K;		iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_4K;		break;	case 2:		if (hw->mac.type == e1000_ich9lan) {			sector_size = ICH_FLASH_SEG_SIZE_8K;			iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_8K;		} else {			ret_val = -E1000_ERR_NVM;			goto out;		}		break;	case 3:		sector_size = ICH_FLASH_SEG_SIZE_64K;		iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_64K;		break;	default:		ret_val = -E1000_ERR_NVM;		goto out;	}	/* Start with the base address, then add the sector offset. */	flash_linear_addr = hw->nvm.flash_base_addr;	flash_linear_addr += (bank) ? (sector_size * iteration) : 0;	for (j = 0; j < iteration ; j++) {		do {			/* Steps */			ret_val = e1000_flash_cycle_init_ich8lan(hw);			if (ret_val)				goto out;			/*			 * Write a value 11 (block Erase) in Flash			 * Cycle field in hw flash control			 */			hsflctl.regval = E1000_READ_FLASH_REG16(hw,			                                      ICH_FLASH_HSFCTL);			hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_ERASE;			E1000_WRITE_FLASH_REG16(hw,			                        ICH_FLASH_HSFCTL,			                        hsflctl.regval);			/*			 * Write the last 24 bits of an index within the			 * block into Flash Linear address field in Flash			 * Address.			 */			flash_linear_addr += (j * sector_size);			E1000_WRITE_FLASH_REG(hw,			                      ICH_FLASH_FADDR,			                      flash_linear_addr);			ret_val = e1000_flash_cycle_ich8lan(hw,			                       ICH_FLASH_ERASE_COMMAND_TIMEOUT);			if (ret_val == E1000_SUCCESS) {				break;			} else {				/*				 * Check if FCERR is set to 1.  If 1,				 * clear it and try the whole sequence				 * a few more times else Done				 */				hsfsts.regval = E1000_READ_FLASH_REG16(hw,				                              ICH_FLASH_HSFSTS);				if (hsfsts.hsf_status.flcerr == 1) {					/*					 * repeat for some time before					 * giving up					 */					continue;				} else if (hsfsts.hsf_status.flcdone == 0)					goto out;			}		} while (++count < ICH_FLASH_CYCLE_REPEAT_COUNT);	}out:	return ret_val;}/** *  e1000_valid_led_default_ich8lan - Set the default LED settings *  @hw: pointer to the HW structure *  @data: Pointer to the LED settings * *  Reads the LED default settings from the NVM to data.  If the NVM LED *  settings is all 0's or F's, set the LED default to a valid LED default *  setting. **/static s32 e1000_valid_led_default_ich8lan(struct e1000_hw *hw, u16 *data){	s32 ret_val;	DEBUGFUNC("e1000_valid_led_default_ich8lan");	ret_val = hw->nvm.ops.read(hw, NVM_ID_LED_SETTINGS, 1, data);	if (ret_val) {		DEBUGOUT("NVM Read Error\n");		goto out;	}	if (*data == ID_LED_RESERVED_0000 ||	    *data == ID_LED_RESERVED_FFFF)		*data = ID_LED_DEFAULT_ICH8LAN;out:	return ret_val;}/** *  e1000_get_bus_info_ich8lan - Get/Set the bus type and width *  @hw: pointer to the HW structure * *  ICH8 use the PCI Express bus, but does not contain a PCI Express Capability *  register, so the the bus width is hard coded. **/static s32 e1000_get_bus_info_ich8lan(struct e1000_hw *hw){	struct e1000_bus_info *bus = &hw->bus;	s32 ret_val;	DEBUGFUNC("e1000_get_bus_info_ich8lan");	ret_val = e1000_get_bus_info_pcie_generic(hw);	/*	 * ICH devices are "PCI Express"-ish.  They have	 * a configuration space, but do not contain	 * PCI Express Capability registers, so bus width	 * must be hardcoded.	 */	if (bus->width == e1000_bus_width_unknown)		bus->width = e1000_bus_width_pcie_x1;	return ret_val;}/** *  e1000_reset_hw_ich8lan - Reset the hardware *  @hw: pointer to the HW structure * *  Does a full reset of the hardware which includes a reset of the PHY and *  MAC. **/static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw){	u32 ctrl, icr, kab;	s32 ret_val;	DEBUGFUNC("e1000_reset_hw_ich8lan");	/*	 * Prevent the PCI-E bus from sticking if there is no TLP connection	 * on the last TLP read/write transaction when MAC is reset.	 */	ret_val = e1000_disable_pcie_master_generic(hw);	if (ret_val) {		DEBUGOUT("PCI-E Master disable polling has failed.\n");	}	DEBUGOUT("Masking off all interrupts\n");	E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);	/*	 * Disable the Transmit and Receive units.  Then delay to allow	 * any pending transactions to complete before we hit the MAC	 * with the global reset.	 */	E1000_WRITE_REG(hw, E1000_RCTL, 0);	E1000_WRITE_REG(hw, E1000_TCTL, E1000_TCTL_PSP);	E1000_WRITE_FLUSH(hw);	msec_delay(10);	/* Workaround for ICH8 bit corruption issue in FIFO memory */	if (hw->mac.type == e1000_ich8lan) {		/* Set Tx and Rx buffer allocation to 8k apiece. */		E1000_WRITE_REG(hw, E1000_PBA, E1000_PBA_8K);		/* Set Packet Buffer Size to 16k. */		E1000_WRITE_REG(hw, E1000_PBS, E1000_PBS_16K);	}	ctrl = E1000_READ_REG(hw, E1000_CTRL);	if (!hw->phy.ops.check_reset_block(hw) && !hw->phy.reset_disable) {		/*		 * PHY HW reset requires MAC CORE reset at the same		 * time to make sure the interface between MAC and the		 * external PHY is reset.		 */		ctrl |= E1000_CTRL_PHY_RST;	}	ret_val = e1000_acquire_swflag_ich8lan(hw);	DEBUGOUT("Issuing a global reset to ich8lan");	E1000_WRITE_REG(hw, E1000_CTRL, (ctrl | E1000_CTRL_RST));	msec_delay(20);	ret_val = e1000_get_auto_rd_done_generic(hw);	if (ret_val) {		/*		 * When auto config read does not complete, do not		 * return with an error. This can happen in situations		 * where there is no eeprom and prevents getting link.		 */		DEBUGOUT("Auto Read Done did not complete\n");	}	E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);	icr = E1000_READ_REG(hw, E1000_ICR);	kab = E1000_READ_REG(hw, E1000_KABGTXD);	kab |= E1000_KABGTXD_BGSQLBIAS;	E1000_WRITE_REG(hw, E1000_KABGTXD, kab);	return ret_val;}/** *  e1000_init_hw_ich8lan - Initialize the hardware *  @hw: pointer to the HW structure * *  Prepares the hardware for transmit and receive by doing the following: *   - initialize hardware bits *   - initialize LED identification *   - setup receive address registers *   - setup flow control *   - setup transmit descriptors *   - clear statistics **/static s32 e1000_init_hw_ich8lan(struct e1000_hw *hw){	struct e1000_mac_info *mac = &hw->mac;	u32 ctrl_ext, txdctl, snoop;	s32 ret_val;	u16 i;	DEBUGFUNC("e1000_init_hw_ich8lan");	e1000_initialize_hw_bits_ich8lan(hw);	/* 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 */	}	/* Setup the receive address. */	e1000_init_rx_addrs_generic(hw, mac->rar_entry_count);	/* Zero out the Multicast HASH table */	DEBUGOUT("Zeroing the MTA\n");	for (i = 0; i < mac->mta_reg_count; i++)		E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);	/* Setup link and flow control */	ret_val = mac->ops.setup_link(hw);	/* Set the transmit descriptor write-back policy for both queues */	txdctl = E1000_READ_REG(hw, E1000_TXDCTL(0));	txdctl = (txdctl & ~E1000_TXDCTL_WTHRESH) |		 E1000_TXDCTL_FULL_TX_DESC_WB;	txdctl = (txdctl & ~E1000_TXDCTL_PTHRESH) |	         E1000_TXDCTL_MAX_TX_DESC_PREFETCH;	E1000_WRITE_REG(hw, E1000_TXDCTL(0), txdctl);	txdctl = E1000_READ_REG(hw, E1000_TXDCTL(1));	txdctl = (txdctl & ~E1000_TXDCTL_WTHRESH) |		 E1000_TXDCTL_FULL_TX_DESC_WB;	txdctl = (txdctl & ~E1000_TXDCTL_PTHRESH) |	         E1000_TXDCTL_MAX_TX_DESC_PREFETCH;	E1000_WRITE_REG(hw, E1000_TXDCTL(1), txdctl);	/*	 * ICH8 has opposite polarity of no_snoop bits.	 * By default, we should use snoop behavior.	 */	if (mac->type == e1000_ich8lan)		snoop = PCIE_ICH8_SNOOP_ALL;	else		snoop = (u32)~(PCIE_NO_SNOOP_ALL);	e1000_set_pcie_no_snoop_generic(hw, snoop);	ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);	ctrl_ext |= E1000_CTRL_EXT_RO_DIS;	E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);	/*	 * Clear all of the statistics registers (clear on read).  It is	 * important that we do this after we have tried to establish link	 * because the symbol error count will increment wildly if there	 * is no link.	 */	e1000_clear_hw_cntrs_ich8lan(hw);	return ret_val;}/** *  e1000_initialize_hw_bits_ich8lan - Initialize required hardware bits *  @hw: pointer to the HW structure * *  Sets/Clears required hardware bits necessary for correctly setting up the *  hardware for transmit and receive. **/static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw){	u32 reg;	DEBUGFUNC("e1000_initialize_hw_bits_ich8lan");	if (hw->mac.disable_hw_init_bits)		goto out;	/* Extended Device Control */	reg = E1000_READ_REG(hw, E1000_CTRL_EXT);	reg |= (1 << 22);	E1000_WRITE_REG(hw, E1000_CTRL_EXT, reg);	/* Transmit Descriptor Control 0 */	reg = E1000_READ_REG(hw, E1000_TXDCTL(0));	reg |= (1 << 22);	E1000_WRITE_REG(hw, E1000_TXDCTL(0), reg);	/* Transmit Descriptor Control 1 */	reg = E1000_READ_REG(hw, E1000_TXDCTL(1));	reg |= (1 << 22);	E1000_WRITE_REG(hw, E1000_TXDCTL(1), reg);	/* Transmit Arbitration Control 0 */	reg = E1000_READ_REG(hw, E1000_TARC(0));	if (hw->mac.type == e1000_ich8lan)		reg |= (1 << 28) | (1 << 29);	reg |= (1 << 23) | (1 << 24) | (1 << 26) | (1 << 27);	E1000_WRITE_REG(hw, E1000_TARC(0), reg);	/* Transmit Arbitration Control 1 */	reg = E1000_READ_REG(hw, E1000_TARC(1));	if (E1000_READ_REG(hw, E1000_TCTL) & E1000_TCTL_MULR)		reg &= ~(1 << 28);	else		reg |= (1 << 28);	reg |= (1 << 24) | (1 << 26) | (1 << 30);	E1000_WRITE_REG(hw, E1000_TARC(1), reg);	/* Device Status */	if (hw->mac.type == e1000_ich8lan) {		reg = E1000_READ_REG(hw, E1000_STATUS);		reg &= ~(1 << 31);		E1000_WRITE_REG(hw, E1000_STATUS, reg);	}out:	return;}/** *  e1000_setup_link_ich8lan - Setup flow control and link settings *  @hw: pointer to the HW structure * *  Determines which flow control settings to use, then configures flow *  control.  Calls the appropriate media-specific link configuration *  function.  Assuming the adapter has a valid link partner, a valid link *  should be established.  Assumes the hardware has previously been reset *  and the transmitter and receiver are not enabled. **/static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw){	s32 ret_val = E1000_SUCCESS;	DEBUGFUNC("e1000_setup_link_ich8lan");	if (hw->phy.ops.check_reset_block(hw))		goto out;	/*	 * ICH parts do not have a word in the NVM to determine	 * the default flow control setting, so we explicitly	 * set it to full.	 */	if (hw->fc.type == e1000_fc_default)		hw->fc.type = e1000_fc_full;	hw->fc.original_type = hw->fc.type;	DEBUGOUT1("After fix-ups FlowControl is now = %x\n", hw->fc.type);	/* Continue to configure the copper link. */	ret_val = hw->mac.ops.setup_physical_interface(hw);	if (ret_val)		goto out;	E1000_WRITE_REG(hw, E1000_FCTTV, hw->fc.pause_time);	ret_val = e1000_set_fc_watermarks_generic(hw);out:	return ret_val;}/** *  e1000_setup_copper_link_ich8lan - Configure MAC/PHY interface *  @hw: pointer to the HW structure * *  Configures the kumeran interface to the PHY to wait the appropriate time *  when polling the PHY, then call the generic setup_copper_link to finish *  configuring the copper link. **/static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw){	u32 ctrl;	s32 ret_val;	u16 reg_data;	DEBUGFUNC("e1000_setup

⌨️ 快捷键说明

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