diff options
author | Alexander Duyck <alexander.h.duyck@intel.com> | 2009-11-19 07:42:01 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-11-20 13:00:11 -0500 |
commit | bb2ac47bcfd47ed9431ff1676ec8d79250c941c9 (patch) | |
tree | 2c717135feb469a84382f9532ed6dd70b1ef024c /drivers/net/igb/e1000_82575.c | |
parent | 2909c3f79d933b55bf2485addb1dca762210b6af (diff) |
igb: add support for 82580 MAC
This patch adds support for the 82580 MAC.
Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/igb/e1000_82575.c')
-rw-r--r-- | drivers/net/igb/e1000_82575.c | 302 |
1 files changed, 266 insertions, 36 deletions
diff --git a/drivers/net/igb/e1000_82575.c b/drivers/net/igb/e1000_82575.c index 5d345e3036a4..e8e9e9194a88 100644 --- a/drivers/net/igb/e1000_82575.c +++ b/drivers/net/igb/e1000_82575.c | |||
@@ -46,7 +46,10 @@ static s32 igb_get_cfg_done_82575(struct e1000_hw *); | |||
46 | static s32 igb_init_hw_82575(struct e1000_hw *); | 46 | static s32 igb_init_hw_82575(struct e1000_hw *); |
47 | static s32 igb_phy_hw_reset_sgmii_82575(struct e1000_hw *); | 47 | static s32 igb_phy_hw_reset_sgmii_82575(struct e1000_hw *); |
48 | static s32 igb_read_phy_reg_sgmii_82575(struct e1000_hw *, u32, u16 *); | 48 | static s32 igb_read_phy_reg_sgmii_82575(struct e1000_hw *, u32, u16 *); |
49 | static s32 igb_read_phy_reg_82580(struct e1000_hw *, u32, u16 *); | ||
50 | static s32 igb_write_phy_reg_82580(struct e1000_hw *, u32, u16); | ||
49 | static s32 igb_reset_hw_82575(struct e1000_hw *); | 51 | static s32 igb_reset_hw_82575(struct e1000_hw *); |
52 | static s32 igb_reset_hw_82580(struct e1000_hw *); | ||
50 | static s32 igb_set_d0_lplu_state_82575(struct e1000_hw *, bool); | 53 | static s32 igb_set_d0_lplu_state_82575(struct e1000_hw *, bool); |
51 | static s32 igb_setup_copper_link_82575(struct e1000_hw *); | 54 | static s32 igb_setup_copper_link_82575(struct e1000_hw *); |
52 | static s32 igb_setup_serdes_link_82575(struct e1000_hw *); | 55 | static s32 igb_setup_serdes_link_82575(struct e1000_hw *); |
@@ -62,6 +65,12 @@ static s32 igb_reset_init_script_82575(struct e1000_hw *); | |||
62 | static s32 igb_read_mac_addr_82575(struct e1000_hw *); | 65 | static s32 igb_read_mac_addr_82575(struct e1000_hw *); |
63 | static s32 igb_set_pcie_completion_timeout(struct e1000_hw *hw); | 66 | static s32 igb_set_pcie_completion_timeout(struct e1000_hw *hw); |
64 | 67 | ||
68 | static const u16 e1000_82580_rxpbs_table[] = | ||
69 | { 36, 72, 144, 1, 2, 4, 8, 16, | ||
70 | 35, 70, 140 }; | ||
71 | #define E1000_82580_RXPBS_TABLE_SIZE \ | ||
72 | (sizeof(e1000_82580_rxpbs_table)/sizeof(u16)) | ||
73 | |||
65 | static s32 igb_get_invariants_82575(struct e1000_hw *hw) | 74 | static s32 igb_get_invariants_82575(struct e1000_hw *hw) |
66 | { | 75 | { |
67 | struct e1000_phy_info *phy = &hw->phy; | 76 | struct e1000_phy_info *phy = &hw->phy; |
@@ -88,6 +97,13 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw) | |||
88 | case E1000_DEV_ID_82576_SERDES_QUAD: | 97 | case E1000_DEV_ID_82576_SERDES_QUAD: |
89 | mac->type = e1000_82576; | 98 | mac->type = e1000_82576; |
90 | break; | 99 | break; |
100 | case E1000_DEV_ID_82580_COPPER: | ||
101 | case E1000_DEV_ID_82580_FIBER: | ||
102 | case E1000_DEV_ID_82580_SERDES: | ||
103 | case E1000_DEV_ID_82580_SGMII: | ||
104 | case E1000_DEV_ID_82580_COPPER_DUAL: | ||
105 | mac->type = e1000_82580; | ||
106 | break; | ||
91 | default: | 107 | default: |
92 | return -E1000_ERR_MAC_INIT; | 108 | return -E1000_ERR_MAC_INIT; |
93 | break; | 109 | break; |
@@ -110,6 +126,7 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw) | |||
110 | dev_spec->sgmii_active = true; | 126 | dev_spec->sgmii_active = true; |
111 | ctrl_ext |= E1000_CTRL_I2C_ENA; | 127 | ctrl_ext |= E1000_CTRL_I2C_ENA; |
112 | break; | 128 | break; |
129 | case E1000_CTRL_EXT_LINK_MODE_1000BASE_KX: | ||
113 | case E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES: | 130 | case E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES: |
114 | hw->phy.media_type = e1000_media_type_internal_serdes; | 131 | hw->phy.media_type = e1000_media_type_internal_serdes; |
115 | ctrl_ext |= E1000_CTRL_I2C_ENA; | 132 | ctrl_ext |= E1000_CTRL_I2C_ENA; |
@@ -121,12 +138,26 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw) | |||
121 | 138 | ||
122 | wr32(E1000_CTRL_EXT, ctrl_ext); | 139 | wr32(E1000_CTRL_EXT, ctrl_ext); |
123 | 140 | ||
141 | /* | ||
142 | * if using i2c make certain the MDICNFG register is cleared to prevent | ||
143 | * communications from being misrouted to the mdic registers | ||
144 | */ | ||
145 | if ((ctrl_ext & E1000_CTRL_I2C_ENA) && (hw->mac.type == e1000_82580)) | ||
146 | wr32(E1000_MDICNFG, 0); | ||
147 | |||
124 | /* Set mta register count */ | 148 | /* Set mta register count */ |
125 | mac->mta_reg_count = 128; | 149 | mac->mta_reg_count = 128; |
126 | /* Set rar entry count */ | 150 | /* Set rar entry count */ |
127 | mac->rar_entry_count = E1000_RAR_ENTRIES_82575; | 151 | mac->rar_entry_count = E1000_RAR_ENTRIES_82575; |
128 | if (mac->type == e1000_82576) | 152 | if (mac->type == e1000_82576) |
129 | mac->rar_entry_count = E1000_RAR_ENTRIES_82576; | 153 | mac->rar_entry_count = E1000_RAR_ENTRIES_82576; |
154 | if (mac->type == e1000_82580) | ||
155 | mac->rar_entry_count = E1000_RAR_ENTRIES_82580; | ||
156 | /* reset */ | ||
157 | if (mac->type == e1000_82580) | ||
158 | mac->ops.reset_hw = igb_reset_hw_82580; | ||
159 | else | ||
160 | mac->ops.reset_hw = igb_reset_hw_82575; | ||
130 | /* Set if part includes ASF firmware */ | 161 | /* Set if part includes ASF firmware */ |
131 | mac->asf_firmware_present = true; | 162 | mac->asf_firmware_present = true; |
132 | /* Set if manageability features are enabled. */ | 163 | /* Set if manageability features are enabled. */ |
@@ -194,6 +225,10 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw) | |||
194 | phy->ops.reset = igb_phy_hw_reset_sgmii_82575; | 225 | phy->ops.reset = igb_phy_hw_reset_sgmii_82575; |
195 | phy->ops.read_reg = igb_read_phy_reg_sgmii_82575; | 226 | phy->ops.read_reg = igb_read_phy_reg_sgmii_82575; |
196 | phy->ops.write_reg = igb_write_phy_reg_sgmii_82575; | 227 | phy->ops.write_reg = igb_write_phy_reg_sgmii_82575; |
228 | } else if (hw->mac.type == e1000_82580) { | ||
229 | phy->ops.reset = igb_phy_hw_reset; | ||
230 | phy->ops.read_reg = igb_read_phy_reg_82580; | ||
231 | phy->ops.write_reg = igb_write_phy_reg_82580; | ||
197 | } else { | 232 | } else { |
198 | phy->ops.reset = igb_phy_hw_reset; | 233 | phy->ops.reset = igb_phy_hw_reset; |
199 | phy->ops.read_reg = igb_read_phy_reg_igp; | 234 | phy->ops.read_reg = igb_read_phy_reg_igp; |
@@ -225,6 +260,12 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw) | |||
225 | phy->ops.set_d0_lplu_state = igb_set_d0_lplu_state_82575; | 260 | phy->ops.set_d0_lplu_state = igb_set_d0_lplu_state_82575; |
226 | phy->ops.set_d3_lplu_state = igb_set_d3_lplu_state; | 261 | phy->ops.set_d3_lplu_state = igb_set_d3_lplu_state; |
227 | break; | 262 | break; |
263 | case I82580_I_PHY_ID: | ||
264 | phy->type = e1000_phy_82580; | ||
265 | phy->ops.force_speed_duplex = igb_phy_force_speed_duplex_82580; | ||
266 | phy->ops.get_cable_length = igb_get_cable_length_82580; | ||
267 | phy->ops.get_phy_info = igb_get_phy_info_82580; | ||
268 | break; | ||
228 | default: | 269 | default: |
229 | return -E1000_ERR_PHY; | 270 | return -E1000_ERR_PHY; |
230 | } | 271 | } |
@@ -635,6 +676,10 @@ static s32 igb_get_cfg_done_82575(struct e1000_hw *hw) | |||
635 | 676 | ||
636 | if (hw->bus.func == 1) | 677 | if (hw->bus.func == 1) |
637 | mask = E1000_NVM_CFG_DONE_PORT_1; | 678 | mask = E1000_NVM_CFG_DONE_PORT_1; |
679 | else if (hw->bus.func == E1000_FUNC_2) | ||
680 | mask = E1000_NVM_CFG_DONE_PORT_2; | ||
681 | else if (hw->bus.func == E1000_FUNC_3) | ||
682 | mask = E1000_NVM_CFG_DONE_PORT_3; | ||
638 | 683 | ||
639 | while (timeout) { | 684 | while (timeout) { |
640 | if (rd32(E1000_EEMNGCTL) & mask) | 685 | if (rd32(E1000_EEMNGCTL) & mask) |
@@ -754,6 +799,10 @@ void igb_shutdown_serdes_link_82575(struct e1000_hw *hw) | |||
754 | 799 | ||
755 | if (hw->bus.func == E1000_FUNC_0) | 800 | if (hw->bus.func == E1000_FUNC_0) |
756 | hw->nvm.ops.read(hw, NVM_INIT_CONTROL3_PORT_A, 1, &eeprom_data); | 801 | hw->nvm.ops.read(hw, NVM_INIT_CONTROL3_PORT_A, 1, &eeprom_data); |
802 | else if (hw->mac.type == e1000_82580) | ||
803 | hw->nvm.ops.read(hw, NVM_INIT_CONTROL3_PORT_A + | ||
804 | NVM_82580_LAN_FUNC_OFFSET(hw->bus.func), 1, | ||
805 | &eeprom_data); | ||
757 | else if (hw->bus.func == E1000_FUNC_1) | 806 | else if (hw->bus.func == E1000_FUNC_1) |
758 | hw->nvm.ops.read(hw, NVM_INIT_CONTROL3_PORT_B, 1, &eeprom_data); | 807 | hw->nvm.ops.read(hw, NVM_INIT_CONTROL3_PORT_B, 1, &eeprom_data); |
759 | 808 | ||
@@ -918,6 +967,9 @@ static s32 igb_setup_copper_link_82575(struct e1000_hw *hw) | |||
918 | goto out; | 967 | goto out; |
919 | 968 | ||
920 | if (igb_sgmii_active_82575(hw) && !hw->phy.reset_disable) { | 969 | if (igb_sgmii_active_82575(hw) && !hw->phy.reset_disable) { |
970 | /* allow time for SFP cage time to power up phy */ | ||
971 | msleep(300); | ||
972 | |||
921 | ret_val = hw->phy.ops.reset(hw); | 973 | ret_val = hw->phy.ops.reset(hw); |
922 | if (ret_val) { | 974 | if (ret_val) { |
923 | hw_dbg("Error resetting the PHY.\n"); | 975 | hw_dbg("Error resetting the PHY.\n"); |
@@ -931,6 +983,9 @@ static s32 igb_setup_copper_link_82575(struct e1000_hw *hw) | |||
931 | case e1000_phy_igp_3: | 983 | case e1000_phy_igp_3: |
932 | ret_val = igb_copper_link_setup_igp(hw); | 984 | ret_val = igb_copper_link_setup_igp(hw); |
933 | break; | 985 | break; |
986 | case e1000_phy_82580: | ||
987 | ret_val = igb_copper_link_setup_82580(hw); | ||
988 | break; | ||
934 | default: | 989 | default: |
935 | ret_val = -E1000_ERR_PHY; | 990 | ret_val = -E1000_ERR_PHY; |
936 | break; | 991 | break; |
@@ -955,7 +1010,8 @@ out: | |||
955 | **/ | 1010 | **/ |
956 | static s32 igb_setup_serdes_link_82575(struct e1000_hw *hw) | 1011 | static s32 igb_setup_serdes_link_82575(struct e1000_hw *hw) |
957 | { | 1012 | { |
958 | u32 ctrl_reg, reg; | 1013 | u32 ctrl_ext, ctrl_reg, reg; |
1014 | bool pcs_autoneg; | ||
959 | 1015 | ||
960 | if ((hw->phy.media_type != e1000_media_type_internal_serdes) && | 1016 | if ((hw->phy.media_type != e1000_media_type_internal_serdes) && |
961 | !igb_sgmii_active_82575(hw)) | 1017 | !igb_sgmii_active_82575(hw)) |
@@ -970,9 +1026,9 @@ static s32 igb_setup_serdes_link_82575(struct e1000_hw *hw) | |||
970 | wr32(E1000_SCTL, E1000_SCTL_DISABLE_SERDES_LOOPBACK); | 1026 | wr32(E1000_SCTL, E1000_SCTL_DISABLE_SERDES_LOOPBACK); |
971 | 1027 | ||
972 | /* power on the sfp cage if present */ | 1028 | /* power on the sfp cage if present */ |
973 | reg = rd32(E1000_CTRL_EXT); | 1029 | ctrl_ext = rd32(E1000_CTRL_EXT); |
974 | reg &= ~E1000_CTRL_EXT_SDP3_DATA; | 1030 | ctrl_ext &= ~E1000_CTRL_EXT_SDP3_DATA; |
975 | wr32(E1000_CTRL_EXT, reg); | 1031 | wr32(E1000_CTRL_EXT, ctrl_ext); |
976 | 1032 | ||
977 | ctrl_reg = rd32(E1000_CTRL); | 1033 | ctrl_reg = rd32(E1000_CTRL); |
978 | ctrl_reg |= E1000_CTRL_SLU; | 1034 | ctrl_reg |= E1000_CTRL_SLU; |
@@ -989,15 +1045,31 @@ static s32 igb_setup_serdes_link_82575(struct e1000_hw *hw) | |||
989 | 1045 | ||
990 | reg = rd32(E1000_PCS_LCTL); | 1046 | reg = rd32(E1000_PCS_LCTL); |
991 | 1047 | ||
992 | if (igb_sgmii_active_82575(hw)) { | 1048 | /* default pcs_autoneg to the same setting as mac autoneg */ |
993 | /* allow time for SFP cage to power up phy */ | 1049 | pcs_autoneg = hw->mac.autoneg; |
994 | msleep(300); | ||
995 | 1050 | ||
996 | /* AN time out should be disabled for SGMII mode */ | 1051 | switch (ctrl_ext & E1000_CTRL_EXT_LINK_MODE_MASK) { |
1052 | case E1000_CTRL_EXT_LINK_MODE_SGMII: | ||
1053 | /* sgmii mode lets the phy handle forcing speed/duplex */ | ||
1054 | pcs_autoneg = true; | ||
1055 | /* autoneg time out should be disabled for SGMII mode */ | ||
997 | reg &= ~(E1000_PCS_LCTL_AN_TIMEOUT); | 1056 | reg &= ~(E1000_PCS_LCTL_AN_TIMEOUT); |
998 | } else { | 1057 | break; |
1058 | case E1000_CTRL_EXT_LINK_MODE_1000BASE_KX: | ||
1059 | /* disable PCS autoneg and support parallel detect only */ | ||
1060 | pcs_autoneg = false; | ||
1061 | default: | ||
1062 | /* | ||
1063 | * non-SGMII modes only supports a speed of 1000/Full for the | ||
1064 | * link so it is best to just force the MAC and let the pcs | ||
1065 | * link either autoneg or be forced to 1000/Full | ||
1066 | */ | ||
999 | ctrl_reg |= E1000_CTRL_SPD_1000 | E1000_CTRL_FRCSPD | | 1067 | ctrl_reg |= E1000_CTRL_SPD_1000 | E1000_CTRL_FRCSPD | |
1000 | E1000_CTRL_FD | E1000_CTRL_FRCDPX; | 1068 | E1000_CTRL_FD | E1000_CTRL_FRCDPX; |
1069 | |||
1070 | /* set speed of 1000/Full if speed/duplex is forced */ | ||
1071 | reg |= E1000_PCS_LCTL_FSV_1000 | E1000_PCS_LCTL_FDV_FULL; | ||
1072 | break; | ||
1001 | } | 1073 | } |
1002 | 1074 | ||
1003 | wr32(E1000_CTRL, ctrl_reg); | 1075 | wr32(E1000_CTRL, ctrl_reg); |
@@ -1008,7 +1080,6 @@ static s32 igb_setup_serdes_link_82575(struct e1000_hw *hw) | |||
1008 | * mode that will be compatible with older link partners and switches. | 1080 | * mode that will be compatible with older link partners and switches. |
1009 | * However, both are supported by the hardware and some drivers/tools. | 1081 | * However, both are supported by the hardware and some drivers/tools. |
1010 | */ | 1082 | */ |
1011 | |||
1012 | reg &= ~(E1000_PCS_LCTL_AN_ENABLE | E1000_PCS_LCTL_FLV_LINK_UP | | 1083 | reg &= ~(E1000_PCS_LCTL_AN_ENABLE | E1000_PCS_LCTL_FLV_LINK_UP | |
1013 | E1000_PCS_LCTL_FSD | E1000_PCS_LCTL_FORCE_LINK); | 1084 | E1000_PCS_LCTL_FSD | E1000_PCS_LCTL_FORCE_LINK); |
1014 | 1085 | ||
@@ -1018,34 +1089,18 @@ static s32 igb_setup_serdes_link_82575(struct e1000_hw *hw) | |||
1018 | */ | 1089 | */ |
1019 | reg |= E1000_PCS_LCTL_FORCE_FCTRL; | 1090 | reg |= E1000_PCS_LCTL_FORCE_FCTRL; |
1020 | 1091 | ||
1021 | /* | 1092 | if (pcs_autoneg) { |
1022 | * we always set sgmii to autoneg since it is the phy that will be | ||
1023 | * forcing the link and the serdes is just a go-between | ||
1024 | */ | ||
1025 | if (hw->mac.autoneg || igb_sgmii_active_82575(hw)) { | ||
1026 | /* Set PCS register for autoneg */ | 1093 | /* Set PCS register for autoneg */ |
1027 | reg |= E1000_PCS_LCTL_FSV_1000 | /* Force 1000 */ | 1094 | reg |= E1000_PCS_LCTL_AN_ENABLE | /* Enable Autoneg */ |
1028 | E1000_PCS_LCTL_FDV_FULL | /* SerDes Full dplx */ | ||
1029 | E1000_PCS_LCTL_AN_ENABLE | /* Enable Autoneg */ | ||
1030 | E1000_PCS_LCTL_AN_RESTART; /* Restart autoneg */ | 1095 | E1000_PCS_LCTL_AN_RESTART; /* Restart autoneg */ |
1031 | hw_dbg("Configuring Autoneg; PCS_LCTL = 0x%08X\n", reg); | 1096 | hw_dbg("Configuring Autoneg:PCS_LCTL=0x%08X\n", reg); |
1032 | } else { | 1097 | } else { |
1033 | /* Check for duplex first */ | 1098 | /* Set PCS register for forced link */ |
1034 | if (hw->mac.forced_speed_duplex & E1000_ALL_FULL_DUPLEX) | 1099 | reg |= E1000_PCS_LCTL_FSD | /* Force Speed */ |
1035 | reg |= E1000_PCS_LCTL_FDV_FULL; | 1100 | E1000_PCS_LCTL_FORCE_LINK | /* Force Link */ |
1036 | 1101 | E1000_PCS_LCTL_FLV_LINK_UP; /* Force link value up */ | |
1037 | /* No need to check for 1000/full since the spec states that | 1102 | |
1038 | * it requires autoneg to be enabled */ | 1103 | hw_dbg("Configuring Forced Link:PCS_LCTL=0x%08X\n", reg); |
1039 | /* Now set speed */ | ||
1040 | if (hw->mac.forced_speed_duplex & E1000_ALL_100_SPEED) | ||
1041 | reg |= E1000_PCS_LCTL_FSV_100; | ||
1042 | |||
1043 | /* Force speed and force link */ | ||
1044 | reg |= E1000_PCS_LCTL_FSD | | ||
1045 | E1000_PCS_LCTL_FORCE_LINK | | ||
1046 | E1000_PCS_LCTL_FLV_LINK_UP; | ||
1047 | |||
1048 | hw_dbg("Configuring Forced Link; PCS_LCTL = 0x%08X\n", reg); | ||
1049 | } | 1104 | } |
1050 | 1105 | ||
1051 | wr32(E1000_PCS_LCTL, reg); | 1106 | wr32(E1000_PCS_LCTL, reg); |
@@ -1354,8 +1409,183 @@ void igb_vmdq_set_replication_pf(struct e1000_hw *hw, bool enable) | |||
1354 | wr32(E1000_VT_CTL, vt_ctl); | 1409 | wr32(E1000_VT_CTL, vt_ctl); |
1355 | } | 1410 | } |
1356 | 1411 | ||
1412 | /** | ||
1413 | * igb_read_phy_reg_82580 - Read 82580 MDI control register | ||
1414 | * @hw: pointer to the HW structure | ||
1415 | * @offset: register offset to be read | ||
1416 | * @data: pointer to the read data | ||
1417 | * | ||
1418 | * Reads the MDI control register in the PHY at offset and stores the | ||
1419 | * information read to data. | ||
1420 | **/ | ||
1421 | static s32 igb_read_phy_reg_82580(struct e1000_hw *hw, u32 offset, u16 *data) | ||
1422 | { | ||
1423 | u32 mdicnfg = 0; | ||
1424 | s32 ret_val; | ||
1425 | |||
1426 | |||
1427 | ret_val = hw->phy.ops.acquire(hw); | ||
1428 | if (ret_val) | ||
1429 | goto out; | ||
1430 | |||
1431 | /* | ||
1432 | * We config the phy address in MDICNFG register now. Same bits | ||
1433 | * as before. The values in MDIC can be written but will be | ||
1434 | * ignored. This allows us to call the old function after | ||
1435 | * configuring the PHY address in the new register | ||
1436 | */ | ||
1437 | mdicnfg = (hw->phy.addr << E1000_MDIC_PHY_SHIFT); | ||
1438 | wr32(E1000_MDICNFG, mdicnfg); | ||
1439 | |||
1440 | ret_val = igb_read_phy_reg_mdic(hw, offset, data); | ||
1441 | |||
1442 | hw->phy.ops.release(hw); | ||
1443 | |||
1444 | out: | ||
1445 | return ret_val; | ||
1446 | } | ||
1447 | |||
1448 | /** | ||
1449 | * igb_write_phy_reg_82580 - Write 82580 MDI control register | ||
1450 | * @hw: pointer to the HW structure | ||
1451 | * @offset: register offset to write to | ||
1452 | * @data: data to write to register at offset | ||
1453 | * | ||
1454 | * Writes data to MDI control register in the PHY at offset. | ||
1455 | **/ | ||
1456 | static s32 igb_write_phy_reg_82580(struct e1000_hw *hw, u32 offset, u16 data) | ||
1457 | { | ||
1458 | u32 mdicnfg = 0; | ||
1459 | s32 ret_val; | ||
1460 | |||
1461 | |||
1462 | ret_val = hw->phy.ops.acquire(hw); | ||
1463 | if (ret_val) | ||
1464 | goto out; | ||
1465 | |||
1466 | /* | ||
1467 | * We config the phy address in MDICNFG register now. Same bits | ||
1468 | * as before. The values in MDIC can be written but will be | ||
1469 | * ignored. This allows us to call the old function after | ||
1470 | * configuring the PHY address in the new register | ||
1471 | */ | ||
1472 | mdicnfg = (hw->phy.addr << E1000_MDIC_PHY_SHIFT); | ||
1473 | wr32(E1000_MDICNFG, mdicnfg); | ||
1474 | |||
1475 | ret_val = igb_write_phy_reg_mdic(hw, offset, data); | ||
1476 | |||
1477 | hw->phy.ops.release(hw); | ||
1478 | |||
1479 | out: | ||
1480 | return ret_val; | ||
1481 | } | ||
1482 | |||
1483 | /** | ||
1484 | * igb_reset_hw_82580 - Reset hardware | ||
1485 | * @hw: pointer to the HW structure | ||
1486 | * | ||
1487 | * This resets function or entire device (all ports, etc.) | ||
1488 | * to a known state. | ||
1489 | **/ | ||
1490 | static s32 igb_reset_hw_82580(struct e1000_hw *hw) | ||
1491 | { | ||
1492 | s32 ret_val = 0; | ||
1493 | /* BH SW mailbox bit in SW_FW_SYNC */ | ||
1494 | u16 swmbsw_mask = E1000_SW_SYNCH_MB; | ||
1495 | u32 ctrl, icr; | ||
1496 | bool global_device_reset = hw->dev_spec._82575.global_device_reset; | ||
1497 | |||
1498 | |||
1499 | hw->dev_spec._82575.global_device_reset = false; | ||
1500 | |||
1501 | /* Get current control state. */ | ||
1502 | ctrl = rd32(E1000_CTRL); | ||
1503 | |||
1504 | /* | ||
1505 | * Prevent the PCI-E bus from sticking if there is no TLP connection | ||
1506 | * on the last TLP read/write transaction when MAC is reset. | ||
1507 | */ | ||
1508 | ret_val = igb_disable_pcie_master(hw); | ||
1509 | if (ret_val) | ||
1510 | hw_dbg("PCI-E Master disable polling has failed.\n"); | ||
1511 | |||
1512 | hw_dbg("Masking off all interrupts\n"); | ||
1513 | wr32(E1000_IMC, 0xffffffff); | ||
1514 | wr32(E1000_RCTL, 0); | ||
1515 | wr32(E1000_TCTL, E1000_TCTL_PSP); | ||
1516 | wrfl(); | ||
1517 | |||
1518 | msleep(10); | ||
1519 | |||
1520 | /* Determine whether or not a global dev reset is requested */ | ||
1521 | if (global_device_reset && | ||
1522 | igb_acquire_swfw_sync_82575(hw, swmbsw_mask)) | ||
1523 | global_device_reset = false; | ||
1524 | |||
1525 | if (global_device_reset && | ||
1526 | !(rd32(E1000_STATUS) & E1000_STAT_DEV_RST_SET)) | ||
1527 | ctrl |= E1000_CTRL_DEV_RST; | ||
1528 | else | ||
1529 | ctrl |= E1000_CTRL_RST; | ||
1530 | |||
1531 | wr32(E1000_CTRL, ctrl); | ||
1532 | |||
1533 | /* Add delay to insure DEV_RST has time to complete */ | ||
1534 | if (global_device_reset) | ||
1535 | msleep(5); | ||
1536 | |||
1537 | ret_val = igb_get_auto_rd_done(hw); | ||
1538 | if (ret_val) { | ||
1539 | /* | ||
1540 | * When auto config read does not complete, do not | ||
1541 | * return with an error. This can happen in situations | ||
1542 | * where there is no eeprom and prevents getting link. | ||
1543 | */ | ||
1544 | hw_dbg("Auto Read Done did not complete\n"); | ||
1545 | } | ||
1546 | |||
1547 | /* If EEPROM is not present, run manual init scripts */ | ||
1548 | if ((rd32(E1000_EECD) & E1000_EECD_PRES) == 0) | ||
1549 | igb_reset_init_script_82575(hw); | ||
1550 | |||
1551 | /* clear global device reset status bit */ | ||
1552 | wr32(E1000_STATUS, E1000_STAT_DEV_RST_SET); | ||
1553 | |||
1554 | /* Clear any pending interrupt events. */ | ||
1555 | wr32(E1000_IMC, 0xffffffff); | ||
1556 | icr = rd32(E1000_ICR); | ||
1557 | |||
1558 | /* Install any alternate MAC address into RAR0 */ | ||
1559 | ret_val = igb_check_alt_mac_addr(hw); | ||
1560 | |||
1561 | /* Release semaphore */ | ||
1562 | if (global_device_reset) | ||
1563 | igb_release_swfw_sync_82575(hw, swmbsw_mask); | ||
1564 | |||
1565 | return ret_val; | ||
1566 | } | ||
1567 | |||
1568 | /** | ||
1569 | * igb_rxpbs_adjust_82580 - adjust RXPBS value to reflect actual RX PBA size | ||
1570 | * @data: data received by reading RXPBS register | ||
1571 | * | ||
1572 | * The 82580 uses a table based approach for packet buffer allocation sizes. | ||
1573 | * This function converts the retrieved value into the correct table value | ||
1574 | * 0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 | ||
1575 | * 0x0 36 72 144 1 2 4 8 16 | ||
1576 | * 0x8 35 70 140 rsv rsv rsv rsv rsv | ||
1577 | */ | ||
1578 | u16 igb_rxpbs_adjust_82580(u32 data) | ||
1579 | { | ||
1580 | u16 ret_val = 0; | ||
1581 | |||
1582 | if (data < E1000_82580_RXPBS_TABLE_SIZE) | ||
1583 | ret_val = e1000_82580_rxpbs_table[data]; | ||
1584 | |||
1585 | return ret_val; | ||
1586 | } | ||
1587 | |||
1357 | static struct e1000_mac_operations e1000_mac_ops_82575 = { | 1588 | static struct e1000_mac_operations e1000_mac_ops_82575 = { |
1358 | .reset_hw = igb_reset_hw_82575, | ||
1359 | .init_hw = igb_init_hw_82575, | 1589 | .init_hw = igb_init_hw_82575, |
1360 | .check_for_link = igb_check_for_link_82575, | 1590 | .check_for_link = igb_check_for_link_82575, |
1361 | .rar_set = igb_rar_set, | 1591 | .rar_set = igb_rar_set, |