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

📄 e1000_hw.c

📁 82546千兆网卡驱动程序,支持该系列所有芯片
💻 C
📖 第 1 页 / 共 5 页
字号:
    if (hw->mac_type == e1000_ich8lan) {        uint32_t kab = E1000_READ_REG(hw, KABGTXD);        kab |= E1000_KABGTXD_BGSQLBIAS;        E1000_WRITE_REG(hw, KABGTXD, kab);    }    return E1000_SUCCESS;}/****************************************************************************** * * Initialize a number of hardware-dependent bits * * hw: Struct containing variables accessed by shared code * *****************************************************************************/static voide1000_initialize_hardware_bits(struct e1000_hw *hw){    if ((hw->mac_type >= e1000_82571) && (!hw->initialize_hw_bits_disable)) {        /* Settings common to all silicon */        uint32_t reg_ctrl, reg_ctrl_ext;        uint32_t reg_tarc0, reg_tarc1;        uint32_t reg_tctl;        uint32_t reg_txdctl, reg_txdctl1;        reg_tarc0 = E1000_READ_REG(hw, TARC0);        reg_tarc0 &= ~0x78000000;           /* Clear bits 30, 29, 28, and 27 */        reg_txdctl = E1000_READ_REG(hw, TXDCTL);        reg_txdctl |= E1000_TXDCTL_COUNT_DESC;       /* Set bit 22 */        E1000_WRITE_REG(hw, TXDCTL, reg_txdctl);        reg_txdctl1 = E1000_READ_REG(hw, TXDCTL1);        reg_txdctl1 |= E1000_TXDCTL_COUNT_DESC;      /* Set bit 22 */        E1000_WRITE_REG(hw, TXDCTL1, reg_txdctl1);        switch (hw->mac_type) {            case e1000_82571:            case e1000_82572:                reg_tarc1 = E1000_READ_REG(hw, TARC1);                reg_tctl = E1000_READ_REG(hw, TCTL);                /* Set the phy Tx compatible mode bits */                reg_tarc1 &= ~0x60000000;   /* Clear bits 30 and 29 */                reg_tarc0 |= 0x07800000;    /* Set TARC0 bits 23-26 */                reg_tarc1 |= 0x07000000;    /* Set TARC1 bits 24-26 */                if (reg_tctl & E1000_TCTL_MULR)                    reg_tarc1 &= ~0x10000000;   /* Clear bit 28 if MULR is 1b */                else                    reg_tarc1 |= 0x10000000;    /* Set bit 28 if MULR is 0b */                E1000_WRITE_REG(hw, TARC1, reg_tarc1);                break;            case e1000_82573:                reg_ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);                reg_ctrl = E1000_READ_REG(hw, CTRL);                reg_ctrl_ext &= ~0x00800000;    /* Clear bit 23 */                reg_ctrl_ext |= 0x00400000;     /* Set bit 22 */                reg_ctrl &= ~0x20000000;        /* Clear bit 29 */                E1000_WRITE_REG(hw, CTRL_EXT, reg_ctrl_ext);                E1000_WRITE_REG(hw, CTRL, reg_ctrl);                break;            case e1000_80003es2lan:                if ((hw->media_type == e1000_media_type_fiber) ||                    (hw->media_type == e1000_media_type_internal_serdes)) {                    reg_tarc0 &= ~0x00100000;   /* Clear bit 20 */                }                reg_tctl = E1000_READ_REG(hw, TCTL);                reg_tarc1 = E1000_READ_REG(hw, TARC1);                if (reg_tctl & E1000_TCTL_MULR)                    reg_tarc1 &= ~0x10000000;   /* Clear bit 28 if MULR is 1b */                else                    reg_tarc1 |= 0x10000000;    /* Set bit 28 if MULR is 0b */                E1000_WRITE_REG(hw, TARC1, reg_tarc1);                break;            case e1000_ich8lan:                if ((hw->revision_id < 3) ||                    ((hw->device_id != E1000_DEV_ID_ICH8_IGP_M_AMT) &&                     (hw->device_id != E1000_DEV_ID_ICH8_IGP_M)))                    reg_tarc0 |= 0x30000000;    /* Set TARC0 bits 29 and 28 */                reg_ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);                reg_ctrl_ext |= 0x00400000;     /* Set bit 22 */                E1000_WRITE_REG(hw, CTRL_EXT, reg_ctrl_ext);                reg_tarc0 |= 0x0d800000;    /* Set TARC0 bits 23, 24, 26, 27 */                reg_tarc1 = E1000_READ_REG(hw, TARC1);                reg_tctl = E1000_READ_REG(hw, TCTL);                if (reg_tctl & E1000_TCTL_MULR)                    reg_tarc1 &= ~0x10000000;   /* Clear bit 28 if MULR is 1b */                else                    reg_tarc1 |= 0x10000000;    /* Set bit 28 if MULR is 0b */                reg_tarc1 |= 0x45000000;        /* Set bit 24, 26 and 30 */                E1000_WRITE_REG(hw, TARC1, reg_tarc1);                break;            default:                break;        }        E1000_WRITE_REG(hw, TARC0, reg_tarc0);    }}/****************************************************************************** * Performs basic configuration of the adapter. * * hw - Struct containing variables accessed by shared code * * Assumes that the controller has previously been reset and is in a * post-reset uninitialized state. Initializes the receive address registers, * multicast table, and VLAN filter table. Calls routines to setup link * configuration and flow control settings. Clears all on-chip counters. Leaves * the transmit and receive units disabled and uninitialized. *****************************************************************************/int32_te1000_init_hw(struct e1000_hw *hw){    uint32_t ctrl;    uint32_t i;    int32_t ret_val;    uint16_t pcix_cmd_word;    uint16_t pcix_stat_hi_word;    uint16_t cmd_mmrbc;    uint16_t stat_mmrbc;    uint32_t mta_size;    uint32_t reg_data;    uint32_t ctrl_ext;    DEBUGFUNC("e1000_init_hw");    /* force full DMA clock frequency for 10/100 on ICH8 A0-B0 */    if ((hw->mac_type == e1000_ich8lan) &&        ((hw->revision_id < 3) ||         ((hw->device_id != E1000_DEV_ID_ICH8_IGP_M_AMT) &&          (hw->device_id != E1000_DEV_ID_ICH8_IGP_M)))) {            reg_data = E1000_READ_REG(hw, STATUS);            reg_data &= ~0x80000000;            E1000_WRITE_REG(hw, STATUS, reg_data);    }    /* Initialize Identification LED */    ret_val = e1000_id_led_init(hw);    if (ret_val) {        DEBUGOUT("Error Initializing Identification LED\n");        return ret_val;    }    /* Set the media type and TBI compatibility */    e1000_set_media_type(hw);    /* Must be called after e1000_set_media_type because media_type is used */    e1000_initialize_hardware_bits(hw);    /* Disabling VLAN filtering. */    DEBUGOUT("Initializing the IEEE VLAN\n");    /* VET hardcoded to standard value and VFTA removed in ICH8 LAN */    if (hw->mac_type != e1000_ich8lan) {        if (hw->mac_type < e1000_82545_rev_3)            E1000_WRITE_REG(hw, VET, 0);        e1000_clear_vfta(hw);    }    /* For 82542 (rev 2.0), disable MWI and put the receiver into reset */    if (hw->mac_type == e1000_82542_rev2_0) {        DEBUGOUT("Disabling MWI on 82542 rev 2.0\n");        e1000_pci_clear_mwi(hw);        E1000_WRITE_REG(hw, RCTL, E1000_RCTL_RST);        E1000_WRITE_FLUSH(hw);        msec_delay(5);    }    /* Setup the receive address. This involves initializing all of the Receive     * Address Registers (RARs 0 - 15).     */    e1000_init_rx_addrs(hw);    /* For 82542 (rev 2.0), take the receiver out of reset and enable MWI */    if (hw->mac_type == e1000_82542_rev2_0) {        E1000_WRITE_REG(hw, RCTL, 0);        E1000_WRITE_FLUSH(hw);        msec_delay(1);        if (hw->pci_cmd_word & CMD_MEM_WRT_INVALIDATE)            e1000_pci_set_mwi(hw);    }    /* Zero out the Multicast HASH table */    DEBUGOUT("Zeroing the MTA\n");    mta_size = E1000_MC_TBL_SIZE;    if (hw->mac_type == e1000_ich8lan)        mta_size = E1000_MC_TBL_SIZE_ICH8LAN;    for (i = 0; i < mta_size; i++) {        E1000_WRITE_REG_ARRAY(hw, MTA, i, 0);        /* use write flush to prevent Memory Write Block (MWB) from         * occuring when accessing our register space */        E1000_WRITE_FLUSH(hw);    }    /* Set the PCI priority bit correctly in the CTRL register.  This     * determines if the adapter gives priority to receives, or if it     * gives equal priority to transmits and receives.  Valid only on     * 82542 and 82543 silicon.     */    if (hw->dma_fairness && hw->mac_type <= e1000_82543) {        ctrl = E1000_READ_REG(hw, CTRL);        E1000_WRITE_REG(hw, CTRL, ctrl | E1000_CTRL_PRIOR);    }    switch (hw->mac_type) {    case e1000_82545_rev_3:    case e1000_82546_rev_3:        break;    default:        /* Workaround for PCI-X problem when BIOS sets MMRBC incorrectly. */        if (hw->bus_type == e1000_bus_type_pcix) {            e1000_read_pci_cfg(hw, PCIX_COMMAND_REGISTER, &pcix_cmd_word);            e1000_read_pci_cfg(hw, PCIX_STATUS_REGISTER_HI,                &pcix_stat_hi_word);            cmd_mmrbc = (pcix_cmd_word & PCIX_COMMAND_MMRBC_MASK) >>                PCIX_COMMAND_MMRBC_SHIFT;            stat_mmrbc = (pcix_stat_hi_word & PCIX_STATUS_HI_MMRBC_MASK) >>                PCIX_STATUS_HI_MMRBC_SHIFT;            if (stat_mmrbc == PCIX_STATUS_HI_MMRBC_4K)                stat_mmrbc = PCIX_STATUS_HI_MMRBC_2K;            if (cmd_mmrbc > stat_mmrbc) {                pcix_cmd_word &= ~PCIX_COMMAND_MMRBC_MASK;                pcix_cmd_word |= stat_mmrbc << PCIX_COMMAND_MMRBC_SHIFT;                e1000_write_pci_cfg(hw, PCIX_COMMAND_REGISTER,                    &pcix_cmd_word);            }        }        break;    }    /* More time needed for PHY to initialize */    if (hw->mac_type == e1000_ich8lan)        msec_delay(15);    /* Call a subroutine to configure the link and setup flow control. */    ret_val = e1000_setup_link(hw);    /* Set the transmit descriptor write-back policy */    if (hw->mac_type > e1000_82544) {        ctrl = E1000_READ_REG(hw, TXDCTL);        ctrl = (ctrl & ~E1000_TXDCTL_WTHRESH) | E1000_TXDCTL_FULL_TX_DESC_WB;        E1000_WRITE_REG(hw, TXDCTL, ctrl);    }    if (hw->mac_type == e1000_82573) {        e1000_enable_tx_pkt_filtering(hw);    }    switch (hw->mac_type) {    default:        break;    case e1000_80003es2lan:        /* Enable retransmit on late collisions */        reg_data = E1000_READ_REG(hw, TCTL);        reg_data |= E1000_TCTL_RTLC;        E1000_WRITE_REG(hw, TCTL, reg_data);        /* Configure Gigabit Carry Extend Padding */        reg_data = E1000_READ_REG(hw, TCTL_EXT);        reg_data &= ~E1000_TCTL_EXT_GCEX_MASK;        reg_data |= DEFAULT_80003ES2LAN_TCTL_EXT_GCEX;        E1000_WRITE_REG(hw, TCTL_EXT, reg_data);        /* Configure Transmit Inter-Packet Gap */        reg_data = E1000_READ_REG(hw, TIPG);        reg_data &= ~E1000_TIPG_IPGT_MASK;        reg_data |= DEFAULT_80003ES2LAN_TIPG_IPGT_1000;        E1000_WRITE_REG(hw, TIPG, reg_data);        reg_data = E1000_READ_REG_ARRAY(hw, FFLT, 0x0001);        reg_data &= ~0x00100000;        E1000_WRITE_REG_ARRAY(hw, FFLT, 0x0001, reg_data);        /* Fall through */    case e1000_82571:    case e1000_82572:    case e1000_ich8lan:        ctrl = E1000_READ_REG(hw, TXDCTL1);        ctrl = (ctrl & ~E1000_TXDCTL_WTHRESH) | E1000_TXDCTL_FULL_TX_DESC_WB;        E1000_WRITE_REG(hw, TXDCTL1, ctrl);        break;    }    if (hw->mac_type == e1000_82573) {        uint32_t gcr = E1000_READ_REG(hw, GCR);        gcr |= E1000_GCR_L1_ACT_WITHOUT_L0S_RX;        E1000_WRITE_REG(hw, GCR, gcr);    }    /* 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(hw);    /* ICH8 No-snoop bits are opposite polarity.     * Set to snoop by default after reset. */    if (hw->mac_type == e1000_ich8lan)        e1000_set_pci_ex_no_snoop(hw, PCI_EX_82566_SNOOP_ALL);    if (hw->device_id == E1000_DEV_ID_82546GB_QUAD_COPPER ||        hw->device_id == E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3) {        ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);        /* Relaxed ordering must be disabled to avoid a parity         * error crash in a PCI slot. */        ctrl_ext |= E1000_CTRL_EXT_RO_DIS;        E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);    }    return ret_val;}/****************************************************************************** * Adjust SERDES output amplitude based on EEPROM setting. * * hw - Struct containing variables accessed by shared code. *****************************************************************************/static int32_te1000_adjust_serdes_amplitude(struct e1000_hw *hw){    uint16_t eeprom_data;    int32_t  ret_val;    DEBUGFUNC("e1000_adjust_serdes_amplitude");    if (hw->media_type != e1000_media_type_internal_serdes)        return E1000_SUCCESS;    switch (hw->mac_type) {    case e1000_82545_rev_3:    case e1000_82546_rev_3:        break;    default:        return E1000_SUCCESS;    }

⌨️ 快捷键说明

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