48 #define ID_LED_RESERVED_F746 0xF746
49 #define ID_LED_DEFAULT_82573 ((ID_LED_DEF1_DEF2 << 12) | \
50 (ID_LED_OFF1_ON2 << 8) | \
51 (ID_LED_DEF1_DEF2 << 4) | \
54 #define E1000_GCR_L1_ACT_WITHOUT_L0S_RX 0x08000000
55 #define AN_RETRY_COUNT 5
56 #define E1000_BASE1000T_STATUS 10
57 #define E1000_IDLE_ERROR_COUNT_MASK 0xFF
58 #define E1000_RECEIVE_ERROR_COUNTER 21
59 #define E1000_RECEIVE_ERROR_MAX 0xFFFF
61 #define E1000_NVM_INIT_CTRL2_MNGM 0x6000
64 static s32 e1000_setup_copper_link_82571(
struct e1000_hw *
hw);
65 static s32 e1000_setup_fiber_serdes_link_82571(
struct e1000_hw *
hw);
66 static s32 e1000_check_for_serdes_link_82571(
struct e1000_hw *
hw);
70 static void e1000_initialize_hw_bits_82571(
struct e1000_hw *
hw);
72 static void e1000_clear_hw_cntrs_82571(
struct e1000_hw *
hw);
73 static void e1000_clear_vfta_82571(
struct e1000_hw *
hw);
74 static bool e1000_check_mng_mode_82574(
struct e1000_hw *
hw);
76 static void e1000_put_hw_semaphore_82571(
struct e1000_hw *
hw);
77 static void e1000_power_down_phy_copper_82571(
struct e1000_hw *
hw);
78 static void e1000_put_hw_semaphore_82573(
struct e1000_hw *
hw);
80 static void e1000_put_hw_semaphore_82574(
struct e1000_hw *
hw);
103 phy->
ops.power_down = e1000_power_down_phy_copper_82571;
105 switch (hw->
mac.type) {
116 phy->
ops.acquire = e1000_get_hw_semaphore_82574;
117 phy->
ops.release = e1000_put_hw_semaphore_82574;
118 phy->
ops.set_d0_lplu_state = e1000_set_d0_lplu_state_82574;
119 phy->
ops.set_d3_lplu_state = e1000_set_d3_lplu_state_82574;
127 ret_val = e1000_get_phy_id_82571(hw);
129 e_dbg(
"Error getting PHY ID\n");
134 switch (hw->
mac.type) {
155 e_dbg(
"PHY ID unknown: type = 0x%08x\n", phy->
id);
164 static s32 e1000_init_nvm_params_82571(
struct e1000_hw *hw)
187 switch (hw->
mac.type) {
191 if (((eecd >> 15) & 0x3) == 0x3) {
221 switch (hw->
mac.type) {
224 nvm->
ops.acquire = e1000_get_hw_semaphore_82574;
225 nvm->
ops.release = e1000_put_hw_semaphore_82574;
238 static s32 e1000_init_mac_params_82571(
struct e1000_hw *hw)
243 bool force_clear_smbi =
false;
246 switch (hw->
adapter->pdev->device) {
251 mac->
ops.setup_physical_interface =
252 e1000_setup_fiber_serdes_link_82571;
254 mac->
ops.get_link_up_info =
262 mac->
ops.setup_physical_interface =
263 e1000_setup_fiber_serdes_link_82571;
264 mac->
ops.check_for_link = e1000_check_for_serdes_link_82571;
265 mac->
ops.get_link_up_info =
270 mac->
ops.setup_physical_interface =
271 e1000_setup_copper_link_82571;
285 switch (hw->
mac.type) {
304 mac->
ops.check_mng_mode = e1000_check_mng_mode_82574;
305 mac->
ops.led_on = e1000_led_on_82574;
324 switch (hw->
mac.type) {
331 ew32(SWSM2, swsm2 | E1000_SWSM2_LOCK);
332 force_clear_smbi =
true;
334 force_clear_smbi =
false;
338 force_clear_smbi =
true;
342 if (force_clear_smbi) {
350 e_dbg(
"Please update your 82571 Bootagent\n");
352 ew32(SWSM, swsm & ~E1000_SWSM_SMBI);
367 static int global_quad_port_a;
372 rc = e1000_init_mac_params_82571(hw);
376 rc = e1000_init_nvm_params_82571(hw);
380 rc = e1000_init_phy_params_82571(hw);
392 if (global_quad_port_a == 0)
395 global_quad_port_a++;
396 if (global_quad_port_a == 4)
397 global_quad_port_a = 0;
403 switch (adapter->
hw.mac.type) {
439 static s32 e1000_get_phy_id_82571(
struct e1000_hw *hw)
445 switch (hw->
mac.type) {
461 ret_val = e1e_rphy(hw,
PHY_ID1, &phy_id);
465 phy->
id = (
u32)(phy_id << 16);
467 ret_val = e1e_rphy(hw,
PHY_ID2, &phy_id);
471 phy->
id |= (
u32)(phy_id);
488 static s32 e1000_get_hw_semaphore_82571(
struct e1000_hw *hw)
491 s32 sw_timeout = hw->
nvm.word_size + 1;
492 s32 fw_timeout = hw->
nvm.word_size + 1;
507 while (i < sw_timeout) {
516 if (i == sw_timeout) {
517 e_dbg(
"Driver can't access device - SMBI bit is set.\n");
521 for (i = 0; i < fw_timeout; i++) {
532 if (i == fw_timeout) {
534 e1000_put_hw_semaphore_82571(hw);
535 e_dbg(
"Driver can't access the NVM\n");
548 static void e1000_put_hw_semaphore_82571(
struct e1000_hw *hw)
563 static s32 e1000_get_hw_semaphore_82573(
struct e1000_hw *hw)
568 extcnf_ctrl =
er32(EXTCNF_CTRL);
571 ew32(EXTCNF_CTRL, extcnf_ctrl);
572 extcnf_ctrl =
er32(EXTCNF_CTRL);
585 e1000_put_hw_semaphore_82573(hw);
586 e_dbg(
"Driver can't access the PHY\n");
600 static void e1000_put_hw_semaphore_82573(
struct e1000_hw *hw)
604 extcnf_ctrl =
er32(EXTCNF_CTRL);
606 ew32(EXTCNF_CTRL, extcnf_ctrl);
618 static s32 e1000_get_hw_semaphore_82574(
struct e1000_hw *hw)
623 ret_val = e1000_get_hw_semaphore_82573(hw);
636 static void e1000_put_hw_semaphore_82574(
struct e1000_hw *hw)
638 e1000_put_hw_semaphore_82573(hw);
678 static s32 e1000_set_d3_lplu_state_82574(
struct e1000_hw *hw,
bool active)
703 static s32 e1000_acquire_nvm_82571(
struct e1000_hw *hw)
707 ret_val = e1000_get_hw_semaphore_82571(hw);
711 switch (hw->
mac.type) {
720 e1000_put_hw_semaphore_82571(hw);
731 static void e1000_release_nvm_82571(
struct e1000_hw *hw)
734 e1000_put_hw_semaphore_82571(hw);
754 switch (hw->
mac.type) {
758 ret_val = e1000_write_nvm_eewr_82571(hw, offset, words, data);
780 static s32 e1000_update_nvm_checksum_82571(
struct e1000_hw *hw)
804 if (i == E1000_FLASH_UPDATES)
828 if (i == E1000_FLASH_UPDATES)
841 static s32 e1000_validate_nvm_checksum_82571(
struct e1000_hw *hw)
844 e1000_fix_nvm_checksum_82571(hw);
863 static s32 e1000_write_nvm_eewr_82571(
struct e1000_hw *hw,
u16 offset,
876 e_dbg(
"nvm parameter(s) out of bounds\n");
880 for (i = 0; i < words; i++) {
905 static s32 e1000_get_cfg_done_82571(
struct e1000_hw *hw)
917 e_dbg(
"MNG configuration cycle has not completed.\n");
935 static s32 e1000_set_d0_lplu_state_82571(
struct e1000_hw *hw,
bool active)
1000 static s32 e1000_reset_hw_82571(
struct e1000_hw *hw)
1002 u32 ctrl, ctrl_ext, eecd, tctl;
1011 e_dbg(
"PCI-E Master disable polling has failed.\n");
1013 e_dbg(
"Masking off all interrupts\n");
1028 switch (hw->
mac.type) {
1030 ret_val = e1000_get_hw_semaphore_82573(hw);
1034 ret_val = e1000_get_hw_semaphore_82574(hw);
1040 e_dbg(
"Cannot acquire MDIO ownership\n");
1044 e_dbg(
"Issuing a global reset to MAC\n");
1048 switch (hw->
mac.type) {
1051 e1000_put_hw_semaphore_82574(hw);
1059 ctrl_ext =
er32(CTRL_EXT);
1061 ew32(CTRL_EXT, ctrl_ext);
1076 switch (hw->
mac.type) {
1122 static s32 e1000_init_hw_82571(
struct e1000_hw *hw)
1129 e1000_initialize_hw_bits_82571(hw);
1132 ret_val = mac->
ops.id_led_init(hw);
1134 e_dbg(
"Error initializing identification LED\n");
1138 e_dbg(
"Initializing the IEEE VLAN\n");
1139 mac->
ops.clear_vfta(hw);
1152 e_dbg(
"Zeroing the MTA\n");
1157 ret_val = mac->
ops.setup_link(hw);
1160 reg_data =
er32(TXDCTL(0));
1164 ew32(TXDCTL(0), reg_data);
1167 switch (mac->
type) {
1178 reg_data =
er32(TXDCTL(1));
1182 ew32(TXDCTL(1), reg_data);
1192 e1000_clear_hw_cntrs_82571(hw);
1203 static void e1000_initialize_hw_bits_82571(
struct e1000_hw *hw)
1208 reg =
er32(TXDCTL(0));
1210 ew32(TXDCTL(0), reg);
1213 reg =
er32(TXDCTL(1));
1215 ew32(TXDCTL(1), reg);
1218 reg =
er32(TARC(0));
1219 reg &= ~(0xF << 27);
1220 switch (hw->
mac.type) {
1223 reg |= (1 << 23) | (1 << 24) | (1 << 25) | (1 << 26);
1235 reg =
er32(TARC(1));
1236 switch (hw->
mac.type) {
1239 reg &= ~((1 << 29) | (1 << 30));
1240 reg |= (1 << 22) | (1 << 24) | (1 << 25) | (1 << 26);
1252 switch (hw->
mac.type) {
1265 switch (hw->
mac.type) {
1269 reg =
er32(CTRL_EXT);
1272 ew32(CTRL_EXT, reg);
1279 reg =
er32(PBA_ECC);
1289 reg =
er32(CTRL_EXT);
1291 ew32(CTRL_EXT, reg);
1305 switch (hw->
mac.type) {
1335 static void e1000_clear_vfta_82571(
struct e1000_hw *hw)
1339 u32 vfta_offset = 0;
1340 u32 vfta_bit_in_reg = 0;
1342 switch (hw->
mac.type) {
1357 vfta_bit_in_reg = 1 << (hw->
mng_cookie.vlan_id &
1370 vfta_value = (offset == vfta_offset) ? vfta_bit_in_reg : 0;
1383 static bool e1000_check_mng_mode_82574(
struct e1000_hw *hw)
1397 static s32 e1000_led_on_82574(
struct e1000_hw *hw)
1402 ctrl = hw->
mac.ledctl_mode2;
1408 for (i = 0; i < 4; i++)
1409 if (((hw->
mac.ledctl_mode2 >> (i * 8)) & 0xFF) ==
1426 u16 status_1kbt = 0;
1427 u16 receive_errors = 0;
1442 E1000_IDLE_ERROR_COUNT_MASK)
1459 static s32 e1000_setup_link_82571(
struct e1000_hw *hw)
1466 switch (hw->
mac.type) {
1488 static s32 e1000_setup_copper_link_82571(
struct e1000_hw *hw)
1498 switch (hw->
phy.type) {
1524 static s32 e1000_setup_fiber_serdes_link_82571(
struct e1000_hw *hw)
1526 switch (hw->
mac.type) {
1564 static s32 e1000_check_for_serdes_link_82571(
struct e1000_hw *hw)
1594 e_dbg(
"AN_UP -> AN_PROG\n");
1614 e_dbg(
"FORCED_UP -> AN_PROG\n");
1621 if (rxcw & E1000_RXCW_C) {
1627 if (status & E1000_STATUS_LU) {
1630 e_dbg(
"AN_PROG -> AN_UP\n");
1636 e_dbg(
"AN_PROG -> DOWN\n");
1651 e_dbg(
"Error config flow control\n");
1657 e_dbg(
"AN_PROG -> FORCED_UP\n");
1673 e_dbg(
"DOWN -> AN_PROG\n");
1677 if (!(rxcw & E1000_RXCW_SYNCH)) {
1680 e_dbg(
"ANYSTATE -> DOWN\n");
1690 if ((rxcw & E1000_RXCW_SYNCH) &&
1691 (rxcw & E1000_RXCW_C))
1694 if (rxcw & E1000_RXCW_IV) {
1698 e_dbg(
"ANYSTATE -> DOWN\n");
1703 if (i == AN_RETRY_COUNT) {
1710 e_dbg(
"ANYSTATE -> AN_PROG\n");
1726 static s32 e1000_valid_led_default_82571(
struct e1000_hw *hw,
u16 *data)
1732 e_dbg(
"NVM Read Error\n");
1736 switch (hw->
mac.type) {
1790 hw->
mac.ops.rar_set(hw, hw->
mac.addr,
1791 hw->
mac.rar_entry_count - 1);
1804 static s32 e1000_fix_nvm_checksum_82571(
struct e1000_hw *hw)
1817 ret_val = e1000_read_nvm(hw, 0x10, 1, &data);
1821 if (!(data & 0x10)) {
1830 ret_val = e1000_read_nvm(hw, 0x23, 1, &data);
1834 if (!(data & 0x8000)) {
1836 ret_val = e1000_write_nvm(hw, 0x23, 1, &data);
1839 ret_val = e1000e_update_nvm_checksum(hw);
1850 static s32 e1000_read_mac_addr_82571(
struct e1000_hw *hw)
1875 static void e1000_power_down_phy_copper_82571(
struct e1000_hw *hw)
1880 if (!phy->
ops.check_reset_block)
1884 if (!(mac->
ops.check_mng_mode(hw) || phy->
ops.check_reset_block(hw)))
1894 static void e1000_clear_hw_cntrs_82571(
struct e1000_hw *hw)
1939 .clear_hw_cntrs = e1000_clear_hw_cntrs_82571,
1947 .clear_vfta = e1000_clear_vfta_82571,
1948 .reset_hw = e1000_reset_hw_82571,
1949 .init_hw = e1000_init_hw_82571,
1950 .setup_link = e1000_setup_link_82571,
1954 .read_mac_addr = e1000_read_mac_addr_82571,
1959 .acquire = e1000_get_hw_semaphore_82571,
1964 .get_cfg_done = e1000_get_cfg_done_82571,
1968 .release = e1000_put_hw_semaphore_82571,
1970 .set_d0_lplu_state = e1000_set_d0_lplu_state_82571,
1973 .cfg_on_link_up =
NULL,
1977 .acquire = e1000_get_hw_semaphore_82571,
1986 .release = e1000_put_hw_semaphore_82571,
1988 .set_d0_lplu_state = e1000_set_d0_lplu_state_82571,
1991 .cfg_on_link_up =
NULL,
1995 .acquire = e1000_get_hw_semaphore_82571,
2004 .release = e1000_put_hw_semaphore_82571,
2006 .set_d0_lplu_state = e1000_set_d0_lplu_state_82571,
2009 .cfg_on_link_up =
NULL,
2013 .acquire = e1000_acquire_nvm_82571,
2015 .release = e1000_release_nvm_82571,
2017 .update = e1000_update_nvm_checksum_82571,
2018 .valid_led_default = e1000_valid_led_default_82571,
2019 .validate = e1000_validate_nvm_checksum_82571,
2020 .write = e1000_write_nvm_82571,
2038 .get_variants = e1000_get_variants_82571,
2039 .mac_ops = &e82571_mac_ops,
2040 .phy_ops = &e82_phy_ops_igp,
2041 .nvm_ops = &e82571_nvm_ops,
2056 .get_variants = e1000_get_variants_82571,
2057 .mac_ops = &e82571_mac_ops,
2058 .phy_ops = &e82_phy_ops_igp,
2059 .nvm_ops = &e82571_nvm_ops,
2074 .get_variants = e1000_get_variants_82571,
2075 .mac_ops = &e82571_mac_ops,
2076 .phy_ops = &e82_phy_ops_m88,
2077 .nvm_ops = &e82571_nvm_ops,
2097 .get_variants = e1000_get_variants_82571,
2098 .mac_ops = &e82571_mac_ops,
2099 .phy_ops = &e82_phy_ops_bm,
2100 .nvm_ops = &e82571_nvm_ops,
2116 .get_variants = e1000_get_variants_82571,
2117 .mac_ops = &e82571_mac_ops,
2118 .phy_ops = &e82_phy_ops_bm,
2119 .nvm_ops = &e82571_nvm_ops,