Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | |
| 3 | Intel PRO/1000 Linux driver |
Bruce Allan | bf67044 | 2013-01-01 16:00:01 +0000 | [diff] [blame] | 4 | Copyright(c) 1999 - 2013 Intel Corporation. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 5 | |
| 6 | This program is free software; you can redistribute it and/or modify it |
| 7 | under the terms and conditions of the GNU General Public License, |
| 8 | version 2, as published by the Free Software Foundation. |
| 9 | |
| 10 | This program is distributed in the hope it will be useful, but WITHOUT |
| 11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 13 | more details. |
| 14 | |
| 15 | You should have received a copy of the GNU General Public License along with |
| 16 | this program; if not, write to the Free Software Foundation, Inc., |
| 17 | 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | |
| 19 | The full GNU General Public License is included in this distribution in |
| 20 | the file called "COPYING". |
| 21 | |
| 22 | Contact Information: |
| 23 | Linux NICS <linux.nics@intel.com> |
| 24 | e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> |
| 25 | Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 26 | |
| 27 | *******************************************************************************/ |
| 28 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 29 | /* 82562G 10/100 Network Connection |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 30 | * 82562G-2 10/100 Network Connection |
| 31 | * 82562GT 10/100 Network Connection |
| 32 | * 82562GT-2 10/100 Network Connection |
| 33 | * 82562V 10/100 Network Connection |
| 34 | * 82562V-2 10/100 Network Connection |
| 35 | * 82566DC-2 Gigabit Network Connection |
| 36 | * 82566DC Gigabit Network Connection |
| 37 | * 82566DM-2 Gigabit Network Connection |
| 38 | * 82566DM Gigabit Network Connection |
| 39 | * 82566MC Gigabit Network Connection |
| 40 | * 82566MM Gigabit Network Connection |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 41 | * 82567LM Gigabit Network Connection |
| 42 | * 82567LF Gigabit Network Connection |
Bruce Allan | 1605927 | 2008-11-21 16:51:06 -0800 | [diff] [blame] | 43 | * 82567V Gigabit Network Connection |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 44 | * 82567LM-2 Gigabit Network Connection |
| 45 | * 82567LF-2 Gigabit Network Connection |
| 46 | * 82567V-2 Gigabit Network Connection |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 47 | * 82567LF-3 Gigabit Network Connection |
| 48 | * 82567LM-3 Gigabit Network Connection |
Bruce Allan | 2f15f9d | 2008-08-26 18:36:36 -0700 | [diff] [blame] | 49 | * 82567LM-4 Gigabit Network Connection |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 50 | * 82577LM Gigabit Network Connection |
| 51 | * 82577LC Gigabit Network Connection |
| 52 | * 82578DM Gigabit Network Connection |
| 53 | * 82578DC Gigabit Network Connection |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 54 | * 82579LM Gigabit Network Connection |
| 55 | * 82579V Gigabit Network Connection |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 56 | */ |
| 57 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 58 | #include "e1000.h" |
| 59 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 60 | /* ICH GbE Flash Hardware Sequencing Flash Status Register bit breakdown */ |
| 61 | /* Offset 04h HSFSTS */ |
| 62 | union ich8_hws_flash_status { |
| 63 | struct ich8_hsfsts { |
Bruce Allan | 362e20c | 2013-02-20 04:05:45 +0000 | [diff] [blame] | 64 | u16 flcdone:1; /* bit 0 Flash Cycle Done */ |
| 65 | u16 flcerr:1; /* bit 1 Flash Cycle Error */ |
| 66 | u16 dael:1; /* bit 2 Direct Access error Log */ |
| 67 | u16 berasesz:2; /* bit 4:3 Sector Erase Size */ |
| 68 | u16 flcinprog:1; /* bit 5 flash cycle in Progress */ |
| 69 | u16 reserved1:2; /* bit 13:6 Reserved */ |
| 70 | u16 reserved2:6; /* bit 13:6 Reserved */ |
| 71 | u16 fldesvalid:1; /* bit 14 Flash Descriptor Valid */ |
| 72 | u16 flockdn:1; /* bit 15 Flash Config Lock-Down */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 73 | } hsf_status; |
| 74 | u16 regval; |
| 75 | }; |
| 76 | |
| 77 | /* ICH GbE Flash Hardware Sequencing Flash control Register bit breakdown */ |
| 78 | /* Offset 06h FLCTL */ |
| 79 | union ich8_hws_flash_ctrl { |
| 80 | struct ich8_hsflctl { |
Bruce Allan | 362e20c | 2013-02-20 04:05:45 +0000 | [diff] [blame] | 81 | u16 flcgo:1; /* 0 Flash Cycle Go */ |
| 82 | u16 flcycle:2; /* 2:1 Flash Cycle */ |
| 83 | u16 reserved:5; /* 7:3 Reserved */ |
| 84 | u16 fldbcount:2; /* 9:8 Flash Data Byte Count */ |
| 85 | u16 flockdn:6; /* 15:10 Reserved */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 86 | } hsf_ctrl; |
| 87 | u16 regval; |
| 88 | }; |
| 89 | |
| 90 | /* ICH Flash Region Access Permissions */ |
| 91 | union ich8_hws_flash_regacc { |
| 92 | struct ich8_flracc { |
Bruce Allan | 362e20c | 2013-02-20 04:05:45 +0000 | [diff] [blame] | 93 | u32 grra:8; /* 0:7 GbE region Read Access */ |
| 94 | u32 grwa:8; /* 8:15 GbE region Write Access */ |
| 95 | u32 gmrag:8; /* 23:16 GbE Master Read Access Grant */ |
| 96 | u32 gmwag:8; /* 31:24 GbE Master Write Access Grant */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 97 | } hsf_flregacc; |
| 98 | u16 regval; |
| 99 | }; |
| 100 | |
Bruce Allan | 4a77035 | 2008-10-01 17:18:35 -0700 | [diff] [blame] | 101 | /* ICH Flash Protected Region */ |
| 102 | union ich8_flash_protected_range { |
| 103 | struct ich8_pr { |
| 104 | u32 base:13; /* 0:12 Protected Range Base */ |
| 105 | u32 reserved1:2; /* 13:14 Reserved */ |
| 106 | u32 rpe:1; /* 15 Read Protection Enable */ |
| 107 | u32 limit:13; /* 16:28 Protected Range Limit */ |
| 108 | u32 reserved2:2; /* 29:30 Reserved */ |
| 109 | u32 wpe:1; /* 31 Write Protection Enable */ |
| 110 | } range; |
| 111 | u32 regval; |
| 112 | }; |
| 113 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 114 | static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw); |
| 115 | static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 116 | static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank); |
| 117 | static s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw, |
| 118 | u32 offset, u8 byte); |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 119 | static s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset, |
| 120 | u8 *data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 121 | static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset, |
| 122 | u16 *data); |
| 123 | static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset, |
| 124 | u8 size, u16 *data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 125 | static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw); |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 126 | static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw); |
| 127 | static s32 e1000_led_on_ich8lan(struct e1000_hw *hw); |
| 128 | static s32 e1000_led_off_ich8lan(struct e1000_hw *hw); |
| 129 | static s32 e1000_id_led_init_pchlan(struct e1000_hw *hw); |
| 130 | static s32 e1000_setup_led_pchlan(struct e1000_hw *hw); |
| 131 | static s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw); |
| 132 | static s32 e1000_led_on_pchlan(struct e1000_hw *hw); |
| 133 | static s32 e1000_led_off_pchlan(struct e1000_hw *hw); |
Bruce Allan | fa2ce13 | 2009-10-26 11:23:25 +0000 | [diff] [blame] | 134 | static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active); |
Bruce Allan | 17f208d | 2009-12-01 15:47:22 +0000 | [diff] [blame] | 135 | static void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw); |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 136 | static void e1000_lan_init_done_ich8lan(struct e1000_hw *hw); |
Bruce Allan | 1f96012d | 2013-01-05 03:06:54 +0000 | [diff] [blame] | 137 | static s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link); |
Bruce Allan | fddaa1a | 2010-01-13 01:52:49 +0000 | [diff] [blame] | 138 | static s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw); |
Bruce Allan | eb7700d | 2010-06-16 13:27:05 +0000 | [diff] [blame] | 139 | static bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw); |
| 140 | static bool e1000_check_mng_mode_pchlan(struct e1000_hw *hw); |
Bruce Allan | 69e1e01 | 2012-04-14 03:28:50 +0000 | [diff] [blame] | 141 | static void e1000_rar_set_pch2lan(struct e1000_hw *hw, u8 *addr, u32 index); |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 142 | static void e1000_rar_set_pch_lpt(struct e1000_hw *hw, u8 *addr, u32 index); |
Bruce Allan | 831bd2e | 2010-09-22 17:16:18 +0000 | [diff] [blame] | 143 | static s32 e1000_k1_workaround_lv(struct e1000_hw *hw); |
Bruce Allan | 605c82b | 2010-09-22 17:17:01 +0000 | [diff] [blame] | 144 | static void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate); |
Bruce Allan | ea8179a | 2013-03-06 09:02:47 +0000 | [diff] [blame^] | 145 | static s32 e1000_setup_copper_link_pch_lpt(struct e1000_hw *hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 146 | |
| 147 | static inline u16 __er16flash(struct e1000_hw *hw, unsigned long reg) |
| 148 | { |
| 149 | return readw(hw->flash_address + reg); |
| 150 | } |
| 151 | |
| 152 | static inline u32 __er32flash(struct e1000_hw *hw, unsigned long reg) |
| 153 | { |
| 154 | return readl(hw->flash_address + reg); |
| 155 | } |
| 156 | |
| 157 | static inline void __ew16flash(struct e1000_hw *hw, unsigned long reg, u16 val) |
| 158 | { |
| 159 | writew(val, hw->flash_address + reg); |
| 160 | } |
| 161 | |
| 162 | static inline void __ew32flash(struct e1000_hw *hw, unsigned long reg, u32 val) |
| 163 | { |
| 164 | writel(val, hw->flash_address + reg); |
| 165 | } |
| 166 | |
| 167 | #define er16flash(reg) __er16flash(hw, (reg)) |
| 168 | #define er32flash(reg) __er32flash(hw, (reg)) |
Bruce Allan | 0e15df4 | 2012-01-31 06:37:11 +0000 | [diff] [blame] | 169 | #define ew16flash(reg, val) __ew16flash(hw, (reg), (val)) |
| 170 | #define ew32flash(reg, val) __ew32flash(hw, (reg), (val)) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 171 | |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 172 | /** |
| 173 | * e1000_phy_is_accessible_pchlan - Check if able to access PHY registers |
| 174 | * @hw: pointer to the HW structure |
| 175 | * |
| 176 | * Test access to the PHY registers by reading the PHY ID registers. If |
| 177 | * the PHY ID is already known (e.g. resume path) compare it with known ID, |
| 178 | * otherwise assume the read PHY ID is correct if it is valid. |
| 179 | * |
| 180 | * Assumes the sw/fw/hw semaphore is already acquired. |
| 181 | **/ |
| 182 | static bool e1000_phy_is_accessible_pchlan(struct e1000_hw *hw) |
Bruce Allan | 99730e4 | 2011-05-13 07:19:48 +0000 | [diff] [blame] | 183 | { |
Bruce Allan | a52359b | 2012-07-14 04:23:58 +0000 | [diff] [blame] | 184 | u16 phy_reg = 0; |
| 185 | u32 phy_id = 0; |
| 186 | s32 ret_val; |
| 187 | u16 retry_count; |
Bruce Allan | 99730e4 | 2011-05-13 07:19:48 +0000 | [diff] [blame] | 188 | |
Bruce Allan | a52359b | 2012-07-14 04:23:58 +0000 | [diff] [blame] | 189 | for (retry_count = 0; retry_count < 2; retry_count++) { |
Bruce Allan | c2ade1a | 2013-01-16 08:54:35 +0000 | [diff] [blame] | 190 | ret_val = e1e_rphy_locked(hw, MII_PHYSID1, &phy_reg); |
Bruce Allan | a52359b | 2012-07-14 04:23:58 +0000 | [diff] [blame] | 191 | if (ret_val || (phy_reg == 0xFFFF)) |
| 192 | continue; |
| 193 | phy_id = (u32)(phy_reg << 16); |
| 194 | |
Bruce Allan | c2ade1a | 2013-01-16 08:54:35 +0000 | [diff] [blame] | 195 | ret_val = e1e_rphy_locked(hw, MII_PHYSID2, &phy_reg); |
Bruce Allan | a52359b | 2012-07-14 04:23:58 +0000 | [diff] [blame] | 196 | if (ret_val || (phy_reg == 0xFFFF)) { |
| 197 | phy_id = 0; |
| 198 | continue; |
| 199 | } |
| 200 | phy_id |= (u32)(phy_reg & PHY_REVISION_MASK); |
| 201 | break; |
| 202 | } |
Bruce Allan | 62bc813 | 2012-03-20 03:47:57 +0000 | [diff] [blame] | 203 | |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 204 | if (hw->phy.id) { |
| 205 | if (hw->phy.id == phy_id) |
| 206 | return true; |
Bruce Allan | a52359b | 2012-07-14 04:23:58 +0000 | [diff] [blame] | 207 | } else if (phy_id) { |
| 208 | hw->phy.id = phy_id; |
| 209 | hw->phy.revision = (u32)(phy_reg & ~PHY_REVISION_MASK); |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 210 | return true; |
| 211 | } |
| 212 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 213 | /* In case the PHY needs to be in mdio slow mode, |
Bruce Allan | a52359b | 2012-07-14 04:23:58 +0000 | [diff] [blame] | 214 | * set slow mode and try to get the PHY id again. |
| 215 | */ |
| 216 | hw->phy.ops.release(hw); |
| 217 | ret_val = e1000_set_mdio_slow_mode_hv(hw); |
| 218 | if (!ret_val) |
| 219 | ret_val = e1000e_get_phy_id(hw); |
| 220 | hw->phy.ops.acquire(hw); |
| 221 | |
| 222 | return !ret_val; |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | /** |
| 226 | * e1000_init_phy_workarounds_pchlan - PHY initialization workarounds |
| 227 | * @hw: pointer to the HW structure |
| 228 | * |
| 229 | * Workarounds/flow necessary for PHY initialization during driver load |
| 230 | * and resume paths. |
| 231 | **/ |
| 232 | static s32 e1000_init_phy_workarounds_pchlan(struct e1000_hw *hw) |
| 233 | { |
| 234 | u32 mac_reg, fwsm = er32(FWSM); |
| 235 | s32 ret_val; |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 236 | u16 phy_reg; |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 237 | |
Bruce Allan | 6e928b7 | 2012-12-12 04:45:51 +0000 | [diff] [blame] | 238 | /* Gate automatic PHY configuration by hardware on managed and |
| 239 | * non-managed 82579 and newer adapters. |
| 240 | */ |
| 241 | e1000_gate_hw_phy_config_ich8lan(hw, true); |
| 242 | |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 243 | ret_val = hw->phy.ops.acquire(hw); |
| 244 | if (ret_val) { |
| 245 | e_dbg("Failed to initialize PHY flow\n"); |
Bruce Allan | 6e928b7 | 2012-12-12 04:45:51 +0000 | [diff] [blame] | 246 | goto out; |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 247 | } |
| 248 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 249 | /* The MAC-PHY interconnect may be in SMBus mode. If the PHY is |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 250 | * inaccessible and resetting the PHY is not blocked, toggle the |
| 251 | * LANPHYPC Value bit to force the interconnect to PCIe mode. |
| 252 | */ |
| 253 | switch (hw->mac.type) { |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 254 | case e1000_pch_lpt: |
| 255 | if (e1000_phy_is_accessible_pchlan(hw)) |
| 256 | break; |
| 257 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 258 | /* Before toggling LANPHYPC, see if PHY is accessible by |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 259 | * forcing MAC to SMBus mode first. |
| 260 | */ |
| 261 | mac_reg = er32(CTRL_EXT); |
| 262 | mac_reg |= E1000_CTRL_EXT_FORCE_SMBUS; |
| 263 | ew32(CTRL_EXT, mac_reg); |
| 264 | |
| 265 | /* fall-through */ |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 266 | case e1000_pch2lan: |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 267 | if (e1000_phy_is_accessible_pchlan(hw)) { |
| 268 | if (hw->mac.type == e1000_pch_lpt) { |
| 269 | /* Unforce SMBus mode in PHY */ |
| 270 | e1e_rphy_locked(hw, CV_SMB_CTRL, &phy_reg); |
| 271 | phy_reg &= ~CV_SMB_CTRL_FORCE_SMBUS; |
| 272 | e1e_wphy_locked(hw, CV_SMB_CTRL, phy_reg); |
| 273 | |
| 274 | /* Unforce SMBus mode in MAC */ |
| 275 | mac_reg = er32(CTRL_EXT); |
| 276 | mac_reg &= ~E1000_CTRL_EXT_FORCE_SMBUS; |
| 277 | ew32(CTRL_EXT, mac_reg); |
| 278 | } |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 279 | break; |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 280 | } |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 281 | |
| 282 | /* fall-through */ |
| 283 | case e1000_pchlan: |
| 284 | if ((hw->mac.type == e1000_pchlan) && |
| 285 | (fwsm & E1000_ICH_FWSM_FW_VALID)) |
| 286 | break; |
| 287 | |
| 288 | if (hw->phy.ops.check_reset_block(hw)) { |
| 289 | e_dbg("Required LANPHYPC toggle blocked by ME\n"); |
| 290 | break; |
| 291 | } |
| 292 | |
| 293 | e_dbg("Toggling LANPHYPC\n"); |
| 294 | |
| 295 | /* Set Phy Config Counter to 50msec */ |
| 296 | mac_reg = er32(FEXTNVM3); |
| 297 | mac_reg &= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK; |
| 298 | mac_reg |= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC; |
| 299 | ew32(FEXTNVM3, mac_reg); |
| 300 | |
Bruce Allan | 4e03510 | 2013-01-04 09:53:19 +0000 | [diff] [blame] | 301 | if (hw->mac.type == e1000_pch_lpt) { |
| 302 | /* Toggling LANPHYPC brings the PHY out of SMBus mode |
| 303 | * So ensure that the MAC is also out of SMBus mode |
| 304 | */ |
| 305 | mac_reg = er32(CTRL_EXT); |
| 306 | mac_reg &= ~E1000_CTRL_EXT_FORCE_SMBUS; |
| 307 | ew32(CTRL_EXT, mac_reg); |
| 308 | } |
| 309 | |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 310 | /* Toggle LANPHYPC Value bit */ |
| 311 | mac_reg = er32(CTRL); |
| 312 | mac_reg |= E1000_CTRL_LANPHYPC_OVERRIDE; |
| 313 | mac_reg &= ~E1000_CTRL_LANPHYPC_VALUE; |
| 314 | ew32(CTRL, mac_reg); |
| 315 | e1e_flush(); |
Bruce Allan | ce43a21 | 2013-02-20 04:06:32 +0000 | [diff] [blame] | 316 | usleep_range(10, 20); |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 317 | mac_reg &= ~E1000_CTRL_LANPHYPC_OVERRIDE; |
| 318 | ew32(CTRL, mac_reg); |
| 319 | e1e_flush(); |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 320 | if (hw->mac.type < e1000_pch_lpt) { |
| 321 | msleep(50); |
| 322 | } else { |
| 323 | u16 count = 20; |
| 324 | do { |
| 325 | usleep_range(5000, 10000); |
| 326 | } while (!(er32(CTRL_EXT) & |
| 327 | E1000_CTRL_EXT_LPCD) && count--); |
| 328 | } |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 329 | break; |
| 330 | default: |
| 331 | break; |
| 332 | } |
| 333 | |
| 334 | hw->phy.ops.release(hw); |
| 335 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 336 | /* Reset the PHY before any access to it. Doing so, ensures |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 337 | * that the PHY is in a known good state before we read/write |
| 338 | * PHY registers. The generic reset is sufficient here, |
| 339 | * because we haven't determined the PHY type yet. |
| 340 | */ |
| 341 | ret_val = e1000e_phy_hw_reset_generic(hw); |
| 342 | |
Bruce Allan | 6e928b7 | 2012-12-12 04:45:51 +0000 | [diff] [blame] | 343 | out: |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 344 | /* Ungate automatic PHY configuration on non-managed 82579 */ |
| 345 | if ((hw->mac.type == e1000_pch2lan) && |
| 346 | !(fwsm & E1000_ICH_FWSM_FW_VALID)) { |
| 347 | usleep_range(10000, 20000); |
| 348 | e1000_gate_hw_phy_config_ich8lan(hw, false); |
| 349 | } |
| 350 | |
| 351 | return ret_val; |
Bruce Allan | 99730e4 | 2011-05-13 07:19:48 +0000 | [diff] [blame] | 352 | } |
| 353 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 354 | /** |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 355 | * e1000_init_phy_params_pchlan - Initialize PHY function pointers |
| 356 | * @hw: pointer to the HW structure |
| 357 | * |
| 358 | * Initialize family-specific PHY parameters and function pointers. |
| 359 | **/ |
| 360 | static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw) |
| 361 | { |
| 362 | struct e1000_phy_info *phy = &hw->phy; |
Bruce Allan | 70806a7 | 2013-01-05 05:08:37 +0000 | [diff] [blame] | 363 | s32 ret_val; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 364 | |
| 365 | phy->addr = 1; |
| 366 | phy->reset_delay_us = 100; |
| 367 | |
Bruce Allan | 2b6b168 | 2011-05-13 07:20:09 +0000 | [diff] [blame] | 368 | phy->ops.set_page = e1000_set_page_igp; |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 369 | phy->ops.read_reg = e1000_read_phy_reg_hv; |
| 370 | phy->ops.read_reg_locked = e1000_read_phy_reg_hv_locked; |
Bruce Allan | 2b6b168 | 2011-05-13 07:20:09 +0000 | [diff] [blame] | 371 | phy->ops.read_reg_page = e1000_read_phy_reg_page_hv; |
Bruce Allan | fa2ce13 | 2009-10-26 11:23:25 +0000 | [diff] [blame] | 372 | phy->ops.set_d0_lplu_state = e1000_set_lplu_state_pchlan; |
| 373 | phy->ops.set_d3_lplu_state = e1000_set_lplu_state_pchlan; |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 374 | phy->ops.write_reg = e1000_write_phy_reg_hv; |
| 375 | phy->ops.write_reg_locked = e1000_write_phy_reg_hv_locked; |
Bruce Allan | 2b6b168 | 2011-05-13 07:20:09 +0000 | [diff] [blame] | 376 | phy->ops.write_reg_page = e1000_write_phy_reg_page_hv; |
Bruce Allan | 17f208d | 2009-12-01 15:47:22 +0000 | [diff] [blame] | 377 | phy->ops.power_up = e1000_power_up_phy_copper; |
| 378 | phy->ops.power_down = e1000_power_down_phy_copper_ich8lan; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 379 | phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT; |
| 380 | |
| 381 | phy->id = e1000_phy_unknown; |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 382 | |
| 383 | ret_val = e1000_init_phy_workarounds_pchlan(hw); |
| 384 | if (ret_val) |
| 385 | return ret_val; |
| 386 | |
| 387 | if (phy->id == e1000_phy_unknown) |
| 388 | switch (hw->mac.type) { |
| 389 | default: |
| 390 | ret_val = e1000e_get_phy_id(hw); |
| 391 | if (ret_val) |
| 392 | return ret_val; |
| 393 | if ((phy->id != 0) && (phy->id != PHY_REVISION_MASK)) |
| 394 | break; |
| 395 | /* fall-through */ |
| 396 | case e1000_pch2lan: |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 397 | case e1000_pch_lpt: |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 398 | /* In case the PHY needs to be in mdio slow mode, |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 399 | * set slow mode and try to get the PHY id again. |
| 400 | */ |
| 401 | ret_val = e1000_set_mdio_slow_mode_hv(hw); |
| 402 | if (ret_val) |
| 403 | return ret_val; |
| 404 | ret_val = e1000e_get_phy_id(hw); |
| 405 | if (ret_val) |
| 406 | return ret_val; |
Bruce Allan | 664dc87 | 2010-11-24 06:01:46 +0000 | [diff] [blame] | 407 | break; |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 408 | } |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 409 | phy->type = e1000e_get_phy_type_from_id(phy->id); |
| 410 | |
Bruce Allan | 0be8401 | 2009-12-02 17:03:18 +0000 | [diff] [blame] | 411 | switch (phy->type) { |
| 412 | case e1000_phy_82577: |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 413 | case e1000_phy_82579: |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 414 | case e1000_phy_i217: |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 415 | phy->ops.check_polarity = e1000_check_polarity_82577; |
| 416 | phy->ops.force_speed_duplex = |
Bruce Allan | 6cc7aae | 2011-02-25 06:25:18 +0000 | [diff] [blame] | 417 | e1000_phy_force_speed_duplex_82577; |
Bruce Allan | 0be8401 | 2009-12-02 17:03:18 +0000 | [diff] [blame] | 418 | phy->ops.get_cable_length = e1000_get_cable_length_82577; |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 419 | phy->ops.get_info = e1000_get_phy_info_82577; |
| 420 | phy->ops.commit = e1000e_phy_sw_reset; |
Bruce Allan | eab50ff | 2010-05-10 15:01:30 +0000 | [diff] [blame] | 421 | break; |
Bruce Allan | 0be8401 | 2009-12-02 17:03:18 +0000 | [diff] [blame] | 422 | case e1000_phy_82578: |
| 423 | phy->ops.check_polarity = e1000_check_polarity_m88; |
| 424 | phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_m88; |
| 425 | phy->ops.get_cable_length = e1000e_get_cable_length_m88; |
| 426 | phy->ops.get_info = e1000e_get_phy_info_m88; |
| 427 | break; |
| 428 | default: |
| 429 | ret_val = -E1000_ERR_PHY; |
| 430 | break; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 431 | } |
| 432 | |
| 433 | return ret_val; |
| 434 | } |
| 435 | |
| 436 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 437 | * e1000_init_phy_params_ich8lan - Initialize PHY function pointers |
| 438 | * @hw: pointer to the HW structure |
| 439 | * |
| 440 | * Initialize family-specific PHY parameters and function pointers. |
| 441 | **/ |
| 442 | static s32 e1000_init_phy_params_ich8lan(struct e1000_hw *hw) |
| 443 | { |
| 444 | struct e1000_phy_info *phy = &hw->phy; |
| 445 | s32 ret_val; |
| 446 | u16 i = 0; |
| 447 | |
| 448 | phy->addr = 1; |
| 449 | phy->reset_delay_us = 100; |
| 450 | |
Bruce Allan | 17f208d | 2009-12-01 15:47:22 +0000 | [diff] [blame] | 451 | phy->ops.power_up = e1000_power_up_phy_copper; |
| 452 | phy->ops.power_down = e1000_power_down_phy_copper_ich8lan; |
| 453 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 454 | /* We may need to do this twice - once for IGP and if that fails, |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 455 | * we'll set BM func pointers and try again |
| 456 | */ |
| 457 | ret_val = e1000e_determine_phy_address(hw); |
| 458 | if (ret_val) { |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 459 | phy->ops.write_reg = e1000e_write_phy_reg_bm; |
| 460 | phy->ops.read_reg = e1000e_read_phy_reg_bm; |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 461 | ret_val = e1000e_determine_phy_address(hw); |
Bruce Allan | 9b71b41 | 2009-12-01 15:53:07 +0000 | [diff] [blame] | 462 | if (ret_val) { |
| 463 | e_dbg("Cannot determine PHY addr. Erroring out\n"); |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 464 | return ret_val; |
Bruce Allan | 9b71b41 | 2009-12-01 15:53:07 +0000 | [diff] [blame] | 465 | } |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 466 | } |
| 467 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 468 | phy->id = 0; |
| 469 | while ((e1000_phy_unknown == e1000e_get_phy_type_from_id(phy->id)) && |
| 470 | (i++ < 100)) { |
Bruce Allan | 1bba438 | 2011-03-19 00:27:20 +0000 | [diff] [blame] | 471 | usleep_range(1000, 2000); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 472 | ret_val = e1000e_get_phy_id(hw); |
| 473 | if (ret_val) |
| 474 | return ret_val; |
| 475 | } |
| 476 | |
| 477 | /* Verify phy id */ |
| 478 | switch (phy->id) { |
| 479 | case IGP03E1000_E_PHY_ID: |
| 480 | phy->type = e1000_phy_igp_3; |
| 481 | phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT; |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 482 | phy->ops.read_reg_locked = e1000e_read_phy_reg_igp_locked; |
| 483 | phy->ops.write_reg_locked = e1000e_write_phy_reg_igp_locked; |
Bruce Allan | 0be8401 | 2009-12-02 17:03:18 +0000 | [diff] [blame] | 484 | phy->ops.get_info = e1000e_get_phy_info_igp; |
| 485 | phy->ops.check_polarity = e1000_check_polarity_igp; |
| 486 | phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_igp; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 487 | break; |
| 488 | case IFE_E_PHY_ID: |
| 489 | case IFE_PLUS_E_PHY_ID: |
| 490 | case IFE_C_E_PHY_ID: |
| 491 | phy->type = e1000_phy_ife; |
| 492 | phy->autoneg_mask = E1000_ALL_NOT_GIG; |
Bruce Allan | 0be8401 | 2009-12-02 17:03:18 +0000 | [diff] [blame] | 493 | phy->ops.get_info = e1000_get_phy_info_ife; |
| 494 | phy->ops.check_polarity = e1000_check_polarity_ife; |
| 495 | phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_ife; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 496 | break; |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 497 | case BME1000_E_PHY_ID: |
| 498 | phy->type = e1000_phy_bm; |
| 499 | phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT; |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 500 | phy->ops.read_reg = e1000e_read_phy_reg_bm; |
| 501 | phy->ops.write_reg = e1000e_write_phy_reg_bm; |
| 502 | phy->ops.commit = e1000e_phy_sw_reset; |
Bruce Allan | 0be8401 | 2009-12-02 17:03:18 +0000 | [diff] [blame] | 503 | phy->ops.get_info = e1000e_get_phy_info_m88; |
| 504 | phy->ops.check_polarity = e1000_check_polarity_m88; |
| 505 | phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_m88; |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 506 | break; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 507 | default: |
| 508 | return -E1000_ERR_PHY; |
| 509 | break; |
| 510 | } |
| 511 | |
| 512 | return 0; |
| 513 | } |
| 514 | |
| 515 | /** |
| 516 | * e1000_init_nvm_params_ich8lan - Initialize NVM function pointers |
| 517 | * @hw: pointer to the HW structure |
| 518 | * |
| 519 | * Initialize family-specific NVM parameters and function |
| 520 | * pointers. |
| 521 | **/ |
| 522 | static s32 e1000_init_nvm_params_ich8lan(struct e1000_hw *hw) |
| 523 | { |
| 524 | struct e1000_nvm_info *nvm = &hw->nvm; |
| 525 | struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; |
Bruce Allan | 148675a | 2009-08-07 07:41:56 +0000 | [diff] [blame] | 526 | u32 gfpreg, sector_base_addr, sector_end_addr; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 527 | u16 i; |
| 528 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 529 | /* Can't read flash registers if the register set isn't mapped. */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 530 | if (!hw->flash_address) { |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 531 | e_dbg("ERROR: Flash registers not mapped\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 532 | return -E1000_ERR_CONFIG; |
| 533 | } |
| 534 | |
| 535 | nvm->type = e1000_nvm_flash_sw; |
| 536 | |
| 537 | gfpreg = er32flash(ICH_FLASH_GFPREG); |
| 538 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 539 | /* sector_X_addr is a "sector"-aligned address (4096 bytes) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 540 | * Add 1 to sector_end_addr since this sector is included in |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 541 | * the overall size. |
| 542 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 543 | sector_base_addr = gfpreg & FLASH_GFPREG_BASE_MASK; |
| 544 | sector_end_addr = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK) + 1; |
| 545 | |
| 546 | /* flash_base_addr is byte-aligned */ |
| 547 | nvm->flash_base_addr = sector_base_addr << FLASH_SECTOR_ADDR_SHIFT; |
| 548 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 549 | /* find total size of the NVM, then cut in half since the total |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 550 | * size represents two separate NVM banks. |
| 551 | */ |
Bruce Allan | f0ff439 | 2013-02-20 04:05:39 +0000 | [diff] [blame] | 552 | nvm->flash_bank_size = ((sector_end_addr - sector_base_addr) |
| 553 | << FLASH_SECTOR_ADDR_SHIFT); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 554 | nvm->flash_bank_size /= 2; |
| 555 | /* Adjust to word count */ |
| 556 | nvm->flash_bank_size /= sizeof(u16); |
| 557 | |
| 558 | nvm->word_size = E1000_ICH8_SHADOW_RAM_WORDS; |
| 559 | |
| 560 | /* Clear shadow ram */ |
| 561 | for (i = 0; i < nvm->word_size; i++) { |
Bruce Allan | 564ea9b | 2009-11-20 23:26:44 +0000 | [diff] [blame] | 562 | dev_spec->shadow_ram[i].modified = false; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 563 | dev_spec->shadow_ram[i].value = 0xFFFF; |
| 564 | } |
| 565 | |
| 566 | return 0; |
| 567 | } |
| 568 | |
| 569 | /** |
| 570 | * e1000_init_mac_params_ich8lan - Initialize MAC function pointers |
| 571 | * @hw: pointer to the HW structure |
| 572 | * |
| 573 | * Initialize family-specific MAC parameters and function |
| 574 | * pointers. |
| 575 | **/ |
Bruce Allan | ec34c17 | 2012-02-01 10:53:05 +0000 | [diff] [blame] | 576 | static s32 e1000_init_mac_params_ich8lan(struct e1000_hw *hw) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 577 | { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 578 | struct e1000_mac_info *mac = &hw->mac; |
| 579 | |
| 580 | /* Set media type function pointer */ |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 581 | hw->phy.media_type = e1000_media_type_copper; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 582 | |
| 583 | /* Set mta register count */ |
| 584 | mac->mta_reg_count = 32; |
| 585 | /* Set rar entry count */ |
| 586 | mac->rar_entry_count = E1000_ICH_RAR_ENTRIES; |
| 587 | if (mac->type == e1000_ich8lan) |
| 588 | mac->rar_entry_count--; |
Bruce Allan | a65a4a0 | 2010-05-10 15:01:51 +0000 | [diff] [blame] | 589 | /* FWSM register */ |
| 590 | mac->has_fwsm = true; |
| 591 | /* ARC subsystem not supported */ |
| 592 | mac->arc_subsystem_valid = false; |
Bruce Allan | f464ba8 | 2010-01-07 16:31:35 +0000 | [diff] [blame] | 593 | /* Adaptive IFS supported */ |
| 594 | mac->adaptive_ifs = true; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 595 | |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 596 | /* LED and other operations */ |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 597 | switch (mac->type) { |
| 598 | case e1000_ich8lan: |
| 599 | case e1000_ich9lan: |
| 600 | case e1000_ich10lan: |
Bruce Allan | eb7700d | 2010-06-16 13:27:05 +0000 | [diff] [blame] | 601 | /* check management mode */ |
| 602 | mac->ops.check_mng_mode = e1000_check_mng_mode_ich8lan; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 603 | /* ID LED init */ |
Bruce Allan | d1964eb | 2012-02-22 09:02:21 +0000 | [diff] [blame] | 604 | mac->ops.id_led_init = e1000e_id_led_init_generic; |
Bruce Allan | dbf80dc | 2011-04-16 00:34:40 +0000 | [diff] [blame] | 605 | /* blink LED */ |
| 606 | mac->ops.blink_led = e1000e_blink_led_generic; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 607 | /* setup LED */ |
| 608 | mac->ops.setup_led = e1000e_setup_led_generic; |
| 609 | /* cleanup LED */ |
| 610 | mac->ops.cleanup_led = e1000_cleanup_led_ich8lan; |
| 611 | /* turn on/off LED */ |
| 612 | mac->ops.led_on = e1000_led_on_ich8lan; |
| 613 | mac->ops.led_off = e1000_led_off_ich8lan; |
| 614 | break; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 615 | case e1000_pch2lan: |
Bruce Allan | 69e1e01 | 2012-04-14 03:28:50 +0000 | [diff] [blame] | 616 | mac->rar_entry_count = E1000_PCH2_RAR_ENTRIES; |
| 617 | mac->ops.rar_set = e1000_rar_set_pch2lan; |
| 618 | /* fall-through */ |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 619 | case e1000_pch_lpt: |
Bruce Allan | 69e1e01 | 2012-04-14 03:28:50 +0000 | [diff] [blame] | 620 | case e1000_pchlan: |
Bruce Allan | eb7700d | 2010-06-16 13:27:05 +0000 | [diff] [blame] | 621 | /* check management mode */ |
| 622 | mac->ops.check_mng_mode = e1000_check_mng_mode_pchlan; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 623 | /* ID LED init */ |
| 624 | mac->ops.id_led_init = e1000_id_led_init_pchlan; |
| 625 | /* setup LED */ |
| 626 | mac->ops.setup_led = e1000_setup_led_pchlan; |
| 627 | /* cleanup LED */ |
| 628 | mac->ops.cleanup_led = e1000_cleanup_led_pchlan; |
| 629 | /* turn on/off LED */ |
| 630 | mac->ops.led_on = e1000_led_on_pchlan; |
| 631 | mac->ops.led_off = e1000_led_off_pchlan; |
| 632 | break; |
| 633 | default: |
| 634 | break; |
| 635 | } |
| 636 | |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 637 | if (mac->type == e1000_pch_lpt) { |
| 638 | mac->rar_entry_count = E1000_PCH_LPT_RAR_ENTRIES; |
| 639 | mac->ops.rar_set = e1000_rar_set_pch_lpt; |
Bruce Allan | ea8179a | 2013-03-06 09:02:47 +0000 | [diff] [blame^] | 640 | mac->ops.setup_physical_interface = |
| 641 | e1000_setup_copper_link_pch_lpt; |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 642 | } |
| 643 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 644 | /* Enable PCS Lock-loss workaround for ICH8 */ |
| 645 | if (mac->type == e1000_ich8lan) |
Bruce Allan | 564ea9b | 2009-11-20 23:26:44 +0000 | [diff] [blame] | 646 | e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw, true); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 647 | |
| 648 | return 0; |
| 649 | } |
| 650 | |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 651 | /** |
Bruce Allan | 4ddc48a | 2012-12-05 06:25:58 +0000 | [diff] [blame] | 652 | * __e1000_access_emi_reg_locked - Read/write EMI register |
| 653 | * @hw: pointer to the HW structure |
| 654 | * @addr: EMI address to program |
| 655 | * @data: pointer to value to read/write from/to the EMI address |
| 656 | * @read: boolean flag to indicate read or write |
| 657 | * |
| 658 | * This helper function assumes the SW/FW/HW Semaphore is already acquired. |
| 659 | **/ |
| 660 | static s32 __e1000_access_emi_reg_locked(struct e1000_hw *hw, u16 address, |
| 661 | u16 *data, bool read) |
| 662 | { |
Bruce Allan | 70806a7 | 2013-01-05 05:08:37 +0000 | [diff] [blame] | 663 | s32 ret_val; |
Bruce Allan | 4ddc48a | 2012-12-05 06:25:58 +0000 | [diff] [blame] | 664 | |
| 665 | ret_val = e1e_wphy_locked(hw, I82579_EMI_ADDR, address); |
| 666 | if (ret_val) |
| 667 | return ret_val; |
| 668 | |
| 669 | if (read) |
| 670 | ret_val = e1e_rphy_locked(hw, I82579_EMI_DATA, data); |
| 671 | else |
| 672 | ret_val = e1e_wphy_locked(hw, I82579_EMI_DATA, *data); |
| 673 | |
| 674 | return ret_val; |
| 675 | } |
| 676 | |
| 677 | /** |
| 678 | * e1000_read_emi_reg_locked - Read Extended Management Interface register |
| 679 | * @hw: pointer to the HW structure |
| 680 | * @addr: EMI address to program |
| 681 | * @data: value to be read from the EMI address |
| 682 | * |
| 683 | * Assumes the SW/FW/HW Semaphore is already acquired. |
| 684 | **/ |
Bruce Allan | 203e4151 | 2012-12-05 08:40:59 +0000 | [diff] [blame] | 685 | s32 e1000_read_emi_reg_locked(struct e1000_hw *hw, u16 addr, u16 *data) |
Bruce Allan | 4ddc48a | 2012-12-05 06:25:58 +0000 | [diff] [blame] | 686 | { |
| 687 | return __e1000_access_emi_reg_locked(hw, addr, data, true); |
| 688 | } |
| 689 | |
| 690 | /** |
| 691 | * e1000_write_emi_reg_locked - Write Extended Management Interface register |
| 692 | * @hw: pointer to the HW structure |
| 693 | * @addr: EMI address to program |
| 694 | * @data: value to be written to the EMI address |
| 695 | * |
| 696 | * Assumes the SW/FW/HW Semaphore is already acquired. |
| 697 | **/ |
| 698 | static s32 e1000_write_emi_reg_locked(struct e1000_hw *hw, u16 addr, u16 data) |
| 699 | { |
| 700 | return __e1000_access_emi_reg_locked(hw, addr, &data, false); |
| 701 | } |
| 702 | |
| 703 | /** |
Bruce Allan | e52997f | 2010-06-16 13:27:49 +0000 | [diff] [blame] | 704 | * e1000_set_eee_pchlan - Enable/disable EEE support |
| 705 | * @hw: pointer to the HW structure |
| 706 | * |
Bruce Allan | 3d4d575 | 2012-12-05 06:26:08 +0000 | [diff] [blame] | 707 | * Enable/disable EEE based on setting in dev_spec structure, the duplex of |
| 708 | * the link and the EEE capabilities of the link partner. The LPI Control |
| 709 | * register bits will remain set only if/when link is up. |
Bruce Allan | e52997f | 2010-06-16 13:27:49 +0000 | [diff] [blame] | 710 | **/ |
| 711 | static s32 e1000_set_eee_pchlan(struct e1000_hw *hw) |
| 712 | { |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 713 | struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; |
Bruce Allan | 3d4d575 | 2012-12-05 06:26:08 +0000 | [diff] [blame] | 714 | s32 ret_val; |
| 715 | u16 lpi_ctrl; |
Bruce Allan | e52997f | 2010-06-16 13:27:49 +0000 | [diff] [blame] | 716 | |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 717 | if ((hw->phy.type != e1000_phy_82579) && |
| 718 | (hw->phy.type != e1000_phy_i217)) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 719 | return 0; |
Bruce Allan | e52997f | 2010-06-16 13:27:49 +0000 | [diff] [blame] | 720 | |
Bruce Allan | 3d4d575 | 2012-12-05 06:26:08 +0000 | [diff] [blame] | 721 | ret_val = hw->phy.ops.acquire(hw); |
Bruce Allan | e52997f | 2010-06-16 13:27:49 +0000 | [diff] [blame] | 722 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 723 | return ret_val; |
Bruce Allan | e52997f | 2010-06-16 13:27:49 +0000 | [diff] [blame] | 724 | |
Bruce Allan | 3d4d575 | 2012-12-05 06:26:08 +0000 | [diff] [blame] | 725 | ret_val = e1e_rphy_locked(hw, I82579_LPI_CTRL, &lpi_ctrl); |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 726 | if (ret_val) |
Bruce Allan | 3d4d575 | 2012-12-05 06:26:08 +0000 | [diff] [blame] | 727 | goto release; |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 728 | |
Bruce Allan | 3d4d575 | 2012-12-05 06:26:08 +0000 | [diff] [blame] | 729 | /* Clear bits that enable EEE in various speeds */ |
| 730 | lpi_ctrl &= ~I82579_LPI_CTRL_ENABLE_MASK; |
| 731 | |
| 732 | /* Enable EEE if not disabled by user */ |
| 733 | if (!dev_spec->eee_disable) { |
| 734 | u16 lpa, pcs_status, data; |
| 735 | |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 736 | /* Save off link partner's EEE ability */ |
Bruce Allan | 3d4d575 | 2012-12-05 06:26:08 +0000 | [diff] [blame] | 737 | switch (hw->phy.type) { |
| 738 | case e1000_phy_82579: |
| 739 | lpa = I82579_EEE_LP_ABILITY; |
| 740 | pcs_status = I82579_EEE_PCS_STATUS; |
| 741 | break; |
| 742 | case e1000_phy_i217: |
| 743 | lpa = I217_EEE_LP_ABILITY; |
| 744 | pcs_status = I217_EEE_PCS_STATUS; |
| 745 | break; |
| 746 | default: |
| 747 | ret_val = -E1000_ERR_PHY; |
| 748 | goto release; |
| 749 | } |
| 750 | ret_val = e1000_read_emi_reg_locked(hw, lpa, |
Bruce Allan | 4ddc48a | 2012-12-05 06:25:58 +0000 | [diff] [blame] | 751 | &dev_spec->eee_lp_ability); |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 752 | if (ret_val) |
| 753 | goto release; |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 754 | |
Bruce Allan | 3d4d575 | 2012-12-05 06:26:08 +0000 | [diff] [blame] | 755 | /* Enable EEE only for speeds in which the link partner is |
| 756 | * EEE capable. |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 757 | */ |
Bruce Allan | 3d4d575 | 2012-12-05 06:26:08 +0000 | [diff] [blame] | 758 | if (dev_spec->eee_lp_ability & I82579_EEE_1000_SUPPORTED) |
| 759 | lpi_ctrl |= I82579_LPI_CTRL_1000_ENABLE; |
| 760 | |
| 761 | if (dev_spec->eee_lp_ability & I82579_EEE_100_SUPPORTED) { |
Bruce Allan | c2ade1a | 2013-01-16 08:54:35 +0000 | [diff] [blame] | 762 | e1e_rphy_locked(hw, MII_LPA, &data); |
| 763 | if (data & LPA_100FULL) |
Bruce Allan | 3d4d575 | 2012-12-05 06:26:08 +0000 | [diff] [blame] | 764 | lpi_ctrl |= I82579_LPI_CTRL_100_ENABLE; |
| 765 | else |
| 766 | /* EEE is not supported in 100Half, so ignore |
| 767 | * partner's EEE in 100 ability if full-duplex |
| 768 | * is not advertised. |
| 769 | */ |
| 770 | dev_spec->eee_lp_ability &= |
| 771 | ~I82579_EEE_100_SUPPORTED; |
| 772 | } |
| 773 | |
| 774 | /* R/Clr IEEE MMD 3.1 bits 11:10 - Tx/Rx LPI Received */ |
| 775 | ret_val = e1000_read_emi_reg_locked(hw, pcs_status, &data); |
| 776 | if (ret_val) |
| 777 | goto release; |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 778 | } |
| 779 | |
Bruce Allan | 3d4d575 | 2012-12-05 06:26:08 +0000 | [diff] [blame] | 780 | ret_val = e1e_wphy_locked(hw, I82579_LPI_CTRL, lpi_ctrl); |
| 781 | release: |
| 782 | hw->phy.ops.release(hw); |
| 783 | |
| 784 | return ret_val; |
Bruce Allan | e52997f | 2010-06-16 13:27:49 +0000 | [diff] [blame] | 785 | } |
| 786 | |
| 787 | /** |
Bruce Allan | e08f626 | 2013-02-20 03:06:34 +0000 | [diff] [blame] | 788 | * e1000_k1_workaround_lpt_lp - K1 workaround on Lynxpoint-LP |
| 789 | * @hw: pointer to the HW structure |
| 790 | * @link: link up bool flag |
| 791 | * |
| 792 | * When K1 is enabled for 1Gbps, the MAC can miss 2 DMA completion indications |
| 793 | * preventing further DMA write requests. Workaround the issue by disabling |
| 794 | * the de-assertion of the clock request when in 1Gpbs mode. |
| 795 | **/ |
| 796 | static s32 e1000_k1_workaround_lpt_lp(struct e1000_hw *hw, bool link) |
| 797 | { |
| 798 | u32 fextnvm6 = er32(FEXTNVM6); |
| 799 | s32 ret_val = 0; |
| 800 | |
| 801 | if (link && (er32(STATUS) & E1000_STATUS_SPEED_1000)) { |
| 802 | u16 kmrn_reg; |
| 803 | |
| 804 | ret_val = hw->phy.ops.acquire(hw); |
| 805 | if (ret_val) |
| 806 | return ret_val; |
| 807 | |
| 808 | ret_val = |
| 809 | e1000e_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG, |
| 810 | &kmrn_reg); |
| 811 | if (ret_val) |
| 812 | goto release; |
| 813 | |
| 814 | ret_val = |
| 815 | e1000e_write_kmrn_reg_locked(hw, |
| 816 | E1000_KMRNCTRLSTA_K1_CONFIG, |
| 817 | kmrn_reg & |
| 818 | ~E1000_KMRNCTRLSTA_K1_ENABLE); |
| 819 | if (ret_val) |
| 820 | goto release; |
| 821 | |
| 822 | usleep_range(10, 20); |
| 823 | |
| 824 | ew32(FEXTNVM6, fextnvm6 | E1000_FEXTNVM6_REQ_PLL_CLK); |
| 825 | |
| 826 | ret_val = |
| 827 | e1000e_write_kmrn_reg_locked(hw, |
| 828 | E1000_KMRNCTRLSTA_K1_CONFIG, |
| 829 | kmrn_reg); |
| 830 | release: |
| 831 | hw->phy.ops.release(hw); |
| 832 | } else { |
| 833 | /* clear FEXTNVM6 bit 8 on link down or 10/100 */ |
| 834 | ew32(FEXTNVM6, fextnvm6 & ~E1000_FEXTNVM6_REQ_PLL_CLK); |
| 835 | } |
| 836 | |
| 837 | return ret_val; |
| 838 | } |
| 839 | |
| 840 | /** |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 841 | * e1000_check_for_copper_link_ich8lan - Check for link (Copper) |
| 842 | * @hw: pointer to the HW structure |
| 843 | * |
| 844 | * Checks to see of the link status of the hardware has changed. If a |
| 845 | * change in link status has been detected, then we read the PHY registers |
| 846 | * to get the current speed/duplex if link exists. |
| 847 | **/ |
| 848 | static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw) |
| 849 | { |
| 850 | struct e1000_mac_info *mac = &hw->mac; |
| 851 | s32 ret_val; |
| 852 | bool link; |
Bruce Allan | 1d2101a7 | 2011-07-22 06:21:56 +0000 | [diff] [blame] | 853 | u16 phy_reg; |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 854 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 855 | /* We only want to go out to the PHY registers to see if Auto-Neg |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 856 | * has completed and/or if our link status has changed. The |
| 857 | * get_link_status flag is set upon receiving a Link Status |
| 858 | * Change or Rx Sequence Error interrupt. |
| 859 | */ |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 860 | if (!mac->get_link_status) |
| 861 | return 0; |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 862 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 863 | /* First we want to see if the MII Status Register reports |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 864 | * link. If so, then we want to get the current speed/duplex |
| 865 | * of the PHY. |
| 866 | */ |
| 867 | ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link); |
| 868 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 869 | return ret_val; |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 870 | |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 871 | if (hw->mac.type == e1000_pchlan) { |
| 872 | ret_val = e1000_k1_gig_workaround_hv(hw, link); |
| 873 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 874 | return ret_val; |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 875 | } |
| 876 | |
Bruce Allan | 772d05c | 2013-03-06 09:02:36 +0000 | [diff] [blame] | 877 | /* When connected at 10Mbps half-duplex, 82579 parts are excessively |
| 878 | * aggressive resulting in many collisions. To avoid this, increase |
| 879 | * the IPG and reduce Rx latency in the PHY. |
| 880 | */ |
| 881 | if ((hw->mac.type == e1000_pch2lan) && link) { |
| 882 | u32 reg; |
| 883 | reg = er32(STATUS); |
| 884 | if (!(reg & (E1000_STATUS_FD | E1000_STATUS_SPEED_MASK))) { |
| 885 | reg = er32(TIPG); |
| 886 | reg &= ~E1000_TIPG_IPGT_MASK; |
| 887 | reg |= 0xFF; |
| 888 | ew32(TIPG, reg); |
| 889 | |
| 890 | /* Reduce Rx latency in analog PHY */ |
| 891 | ret_val = hw->phy.ops.acquire(hw); |
| 892 | if (ret_val) |
| 893 | return ret_val; |
| 894 | |
| 895 | ret_val = |
| 896 | e1000_write_emi_reg_locked(hw, I82579_RX_CONFIG, 0); |
| 897 | |
| 898 | hw->phy.ops.release(hw); |
| 899 | |
| 900 | if (ret_val) |
| 901 | return ret_val; |
| 902 | } |
| 903 | } |
| 904 | |
Bruce Allan | e08f626 | 2013-02-20 03:06:34 +0000 | [diff] [blame] | 905 | /* Work-around I218 hang issue */ |
| 906 | if ((hw->adapter->pdev->device == E1000_DEV_ID_PCH_LPTLP_I218_LM) || |
| 907 | (hw->adapter->pdev->device == E1000_DEV_ID_PCH_LPTLP_I218_V)) { |
| 908 | ret_val = e1000_k1_workaround_lpt_lp(hw, link); |
| 909 | if (ret_val) |
| 910 | return ret_val; |
| 911 | } |
| 912 | |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 913 | /* Clear link partner's EEE ability */ |
| 914 | hw->dev_spec.ich8lan.eee_lp_ability = 0; |
| 915 | |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 916 | if (!link) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 917 | return 0; /* No link detected */ |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 918 | |
| 919 | mac->get_link_status = false; |
| 920 | |
Bruce Allan | 1d2101a7 | 2011-07-22 06:21:56 +0000 | [diff] [blame] | 921 | switch (hw->mac.type) { |
| 922 | case e1000_pch2lan: |
Bruce Allan | 831bd2e | 2010-09-22 17:16:18 +0000 | [diff] [blame] | 923 | ret_val = e1000_k1_workaround_lv(hw); |
| 924 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 925 | return ret_val; |
Bruce Allan | 1d2101a7 | 2011-07-22 06:21:56 +0000 | [diff] [blame] | 926 | /* fall-thru */ |
| 927 | case e1000_pchlan: |
| 928 | if (hw->phy.type == e1000_phy_82578) { |
| 929 | ret_val = e1000_link_stall_workaround_hv(hw); |
| 930 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 931 | return ret_val; |
Bruce Allan | 1d2101a7 | 2011-07-22 06:21:56 +0000 | [diff] [blame] | 932 | } |
| 933 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 934 | /* Workaround for PCHx parts in half-duplex: |
Bruce Allan | 1d2101a7 | 2011-07-22 06:21:56 +0000 | [diff] [blame] | 935 | * Set the number of preambles removed from the packet |
| 936 | * when it is passed from the PHY to the MAC to prevent |
| 937 | * the MAC from misinterpreting the packet type. |
| 938 | */ |
| 939 | e1e_rphy(hw, HV_KMRN_FIFO_CTRLSTA, &phy_reg); |
| 940 | phy_reg &= ~HV_KMRN_FIFO_CTRLSTA_PREAMBLE_MASK; |
| 941 | |
| 942 | if ((er32(STATUS) & E1000_STATUS_FD) != E1000_STATUS_FD) |
| 943 | phy_reg |= (1 << HV_KMRN_FIFO_CTRLSTA_PREAMBLE_SHIFT); |
| 944 | |
| 945 | e1e_wphy(hw, HV_KMRN_FIFO_CTRLSTA, phy_reg); |
| 946 | break; |
| 947 | default: |
| 948 | break; |
Bruce Allan | 831bd2e | 2010-09-22 17:16:18 +0000 | [diff] [blame] | 949 | } |
| 950 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 951 | /* Check if there was DownShift, must be checked |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 952 | * immediately after link-up |
| 953 | */ |
| 954 | e1000e_check_downshift(hw); |
| 955 | |
Bruce Allan | e52997f | 2010-06-16 13:27:49 +0000 | [diff] [blame] | 956 | /* Enable/Disable EEE after link up */ |
| 957 | ret_val = e1000_set_eee_pchlan(hw); |
| 958 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 959 | return ret_val; |
Bruce Allan | e52997f | 2010-06-16 13:27:49 +0000 | [diff] [blame] | 960 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 961 | /* If we are forcing speed/duplex, then we simply return since |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 962 | * we have already determined whether we have link or not. |
| 963 | */ |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 964 | if (!mac->autoneg) |
| 965 | return -E1000_ERR_CONFIG; |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 966 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 967 | /* Auto-Neg is enabled. Auto Speed Detection takes care |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 968 | * of MAC speed/duplex configuration. So we only need to |
| 969 | * configure Collision Distance in the MAC. |
| 970 | */ |
Bruce Allan | 57cde76 | 2012-02-22 09:02:58 +0000 | [diff] [blame] | 971 | mac->ops.config_collision_dist(hw); |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 972 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 973 | /* Configure Flow Control now that Auto-Neg has completed. |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 974 | * First, we need to restore the desired flow control |
| 975 | * settings because we may have had to re-autoneg with a |
| 976 | * different link partner. |
| 977 | */ |
| 978 | ret_val = e1000e_config_fc_after_link_up(hw); |
| 979 | if (ret_val) |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 980 | e_dbg("Error configuring flow control\n"); |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 981 | |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 982 | return ret_val; |
| 983 | } |
| 984 | |
Jeff Kirsher | 69e3fd8 | 2008-04-02 13:48:18 -0700 | [diff] [blame] | 985 | static s32 e1000_get_variants_ich8lan(struct e1000_adapter *adapter) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 986 | { |
| 987 | struct e1000_hw *hw = &adapter->hw; |
| 988 | s32 rc; |
| 989 | |
Bruce Allan | ec34c17 | 2012-02-01 10:53:05 +0000 | [diff] [blame] | 990 | rc = e1000_init_mac_params_ich8lan(hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 991 | if (rc) |
| 992 | return rc; |
| 993 | |
| 994 | rc = e1000_init_nvm_params_ich8lan(hw); |
| 995 | if (rc) |
| 996 | return rc; |
| 997 | |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 998 | switch (hw->mac.type) { |
| 999 | case e1000_ich8lan: |
| 1000 | case e1000_ich9lan: |
| 1001 | case e1000_ich10lan: |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 1002 | rc = e1000_init_phy_params_ich8lan(hw); |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1003 | break; |
| 1004 | case e1000_pchlan: |
| 1005 | case e1000_pch2lan: |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 1006 | case e1000_pch_lpt: |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1007 | rc = e1000_init_phy_params_pchlan(hw); |
| 1008 | break; |
| 1009 | default: |
| 1010 | break; |
| 1011 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1012 | if (rc) |
| 1013 | return rc; |
| 1014 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 1015 | /* Disable Jumbo Frame support on parts with Intel 10/100 PHY or |
Bruce Allan | 23e4f06 | 2011-02-25 07:44:51 +0000 | [diff] [blame] | 1016 | * on parts with MACsec enabled in NVM (reflected in CTRL_EXT). |
| 1017 | */ |
| 1018 | if ((adapter->hw.phy.type == e1000_phy_ife) || |
| 1019 | ((adapter->hw.mac.type >= e1000_pch2lan) && |
| 1020 | (!(er32(CTRL_EXT) & E1000_CTRL_EXT_LSECCK)))) { |
Bruce Allan | 2adc55c | 2009-06-02 11:28:58 +0000 | [diff] [blame] | 1021 | adapter->flags &= ~FLAG_HAS_JUMBO_FRAMES; |
| 1022 | adapter->max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN; |
Bruce Allan | dbf80dc | 2011-04-16 00:34:40 +0000 | [diff] [blame] | 1023 | |
| 1024 | hw->mac.ops.blink_led = NULL; |
Bruce Allan | 2adc55c | 2009-06-02 11:28:58 +0000 | [diff] [blame] | 1025 | } |
| 1026 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1027 | if ((adapter->hw.mac.type == e1000_ich8lan) && |
Bruce Allan | 462d599 | 2011-09-30 08:07:11 +0000 | [diff] [blame] | 1028 | (adapter->hw.phy.type != e1000_phy_ife)) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1029 | adapter->flags |= FLAG_LSC_GIG_SPEED_DROP; |
| 1030 | |
Bruce Allan | c6e7f51 | 2011-07-29 05:53:02 +0000 | [diff] [blame] | 1031 | /* Enable workaround for 82579 w/ ME enabled */ |
| 1032 | if ((adapter->hw.mac.type == e1000_pch2lan) && |
| 1033 | (er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) |
| 1034 | adapter->flags2 |= FLAG2_PCIM2PCI_ARBITER_WA; |
| 1035 | |
Bruce Allan | 5a86f28 | 2010-06-29 18:13:13 +0000 | [diff] [blame] | 1036 | /* Disable EEE by default until IEEE802.3az spec is finalized */ |
| 1037 | if (adapter->flags2 & FLAG2_HAS_EEE) |
| 1038 | adapter->hw.dev_spec.ich8lan.eee_disable = true; |
| 1039 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1040 | return 0; |
| 1041 | } |
| 1042 | |
Thomas Gleixner | 717d438 | 2008-10-02 16:33:40 -0700 | [diff] [blame] | 1043 | static DEFINE_MUTEX(nvm_mutex); |
Thomas Gleixner | 717d438 | 2008-10-02 16:33:40 -0700 | [diff] [blame] | 1044 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1045 | /** |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 1046 | * e1000_acquire_nvm_ich8lan - Acquire NVM mutex |
| 1047 | * @hw: pointer to the HW structure |
| 1048 | * |
| 1049 | * Acquires the mutex for performing NVM operations. |
| 1050 | **/ |
Bruce Allan | 8bb6286 | 2013-01-16 08:46:49 +0000 | [diff] [blame] | 1051 | static s32 e1000_acquire_nvm_ich8lan(struct e1000_hw __always_unused *hw) |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 1052 | { |
| 1053 | mutex_lock(&nvm_mutex); |
| 1054 | |
| 1055 | return 0; |
| 1056 | } |
| 1057 | |
| 1058 | /** |
| 1059 | * e1000_release_nvm_ich8lan - Release NVM mutex |
| 1060 | * @hw: pointer to the HW structure |
| 1061 | * |
| 1062 | * Releases the mutex used while performing NVM operations. |
| 1063 | **/ |
Bruce Allan | 8bb6286 | 2013-01-16 08:46:49 +0000 | [diff] [blame] | 1064 | static void e1000_release_nvm_ich8lan(struct e1000_hw __always_unused *hw) |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 1065 | { |
| 1066 | mutex_unlock(&nvm_mutex); |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 1067 | } |
| 1068 | |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 1069 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1070 | * e1000_acquire_swflag_ich8lan - Acquire software control flag |
| 1071 | * @hw: pointer to the HW structure |
| 1072 | * |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 1073 | * Acquires the software control flag for performing PHY and select |
| 1074 | * MAC CSR accesses. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1075 | **/ |
| 1076 | static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw) |
| 1077 | { |
Bruce Allan | 373a88d | 2009-08-07 07:41:37 +0000 | [diff] [blame] | 1078 | u32 extcnf_ctrl, timeout = PHY_CFG_TIMEOUT; |
| 1079 | s32 ret_val = 0; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1080 | |
Bruce Allan | a90b412 | 2011-10-07 03:50:38 +0000 | [diff] [blame] | 1081 | if (test_and_set_bit(__E1000_ACCESS_SHARED_RESOURCE, |
| 1082 | &hw->adapter->state)) { |
Bruce Allan | 34c9ef8 | 2011-10-21 04:33:47 +0000 | [diff] [blame] | 1083 | e_dbg("contention for Phy access\n"); |
Bruce Allan | a90b412 | 2011-10-07 03:50:38 +0000 | [diff] [blame] | 1084 | return -E1000_ERR_PHY; |
| 1085 | } |
Thomas Gleixner | 717d438 | 2008-10-02 16:33:40 -0700 | [diff] [blame] | 1086 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1087 | while (timeout) { |
| 1088 | extcnf_ctrl = er32(EXTCNF_CTRL); |
Bruce Allan | 373a88d | 2009-08-07 07:41:37 +0000 | [diff] [blame] | 1089 | if (!(extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG)) |
| 1090 | break; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1091 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1092 | mdelay(1); |
| 1093 | timeout--; |
| 1094 | } |
| 1095 | |
| 1096 | if (!timeout) { |
Bruce Allan | a90b412 | 2011-10-07 03:50:38 +0000 | [diff] [blame] | 1097 | e_dbg("SW has already locked the resource.\n"); |
Bruce Allan | 373a88d | 2009-08-07 07:41:37 +0000 | [diff] [blame] | 1098 | ret_val = -E1000_ERR_CONFIG; |
| 1099 | goto out; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1100 | } |
| 1101 | |
Bruce Allan | 53ac5a8 | 2009-10-26 11:23:06 +0000 | [diff] [blame] | 1102 | timeout = SW_FLAG_TIMEOUT; |
Bruce Allan | 373a88d | 2009-08-07 07:41:37 +0000 | [diff] [blame] | 1103 | |
| 1104 | extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG; |
| 1105 | ew32(EXTCNF_CTRL, extcnf_ctrl); |
| 1106 | |
| 1107 | while (timeout) { |
| 1108 | extcnf_ctrl = er32(EXTCNF_CTRL); |
| 1109 | if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG) |
| 1110 | break; |
| 1111 | |
| 1112 | mdelay(1); |
| 1113 | timeout--; |
| 1114 | } |
| 1115 | |
| 1116 | if (!timeout) { |
Bruce Allan | 434f139 | 2011-12-16 00:46:54 +0000 | [diff] [blame] | 1117 | e_dbg("Failed to acquire the semaphore, FW or HW has it: FWSM=0x%8.8x EXTCNF_CTRL=0x%8.8x)\n", |
Bruce Allan | a90b412 | 2011-10-07 03:50:38 +0000 | [diff] [blame] | 1118 | er32(FWSM), extcnf_ctrl); |
Bruce Allan | 373a88d | 2009-08-07 07:41:37 +0000 | [diff] [blame] | 1119 | extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG; |
| 1120 | ew32(EXTCNF_CTRL, extcnf_ctrl); |
| 1121 | ret_val = -E1000_ERR_CONFIG; |
| 1122 | goto out; |
| 1123 | } |
| 1124 | |
| 1125 | out: |
| 1126 | if (ret_val) |
Bruce Allan | a90b412 | 2011-10-07 03:50:38 +0000 | [diff] [blame] | 1127 | clear_bit(__E1000_ACCESS_SHARED_RESOURCE, &hw->adapter->state); |
Bruce Allan | 373a88d | 2009-08-07 07:41:37 +0000 | [diff] [blame] | 1128 | |
| 1129 | return ret_val; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1130 | } |
| 1131 | |
| 1132 | /** |
| 1133 | * e1000_release_swflag_ich8lan - Release software control flag |
| 1134 | * @hw: pointer to the HW structure |
| 1135 | * |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 1136 | * Releases the software control flag for performing PHY and select |
| 1137 | * MAC CSR accesses. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1138 | **/ |
| 1139 | static void e1000_release_swflag_ich8lan(struct e1000_hw *hw) |
| 1140 | { |
| 1141 | u32 extcnf_ctrl; |
| 1142 | |
| 1143 | extcnf_ctrl = er32(EXTCNF_CTRL); |
Bruce Allan | c5caf48 | 2011-05-13 07:19:53 +0000 | [diff] [blame] | 1144 | |
| 1145 | if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG) { |
| 1146 | extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG; |
| 1147 | ew32(EXTCNF_CTRL, extcnf_ctrl); |
| 1148 | } else { |
| 1149 | e_dbg("Semaphore unexpectedly released by sw/fw/hw\n"); |
| 1150 | } |
Thomas Gleixner | 717d438 | 2008-10-02 16:33:40 -0700 | [diff] [blame] | 1151 | |
Bruce Allan | a90b412 | 2011-10-07 03:50:38 +0000 | [diff] [blame] | 1152 | clear_bit(__E1000_ACCESS_SHARED_RESOURCE, &hw->adapter->state); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1153 | } |
| 1154 | |
| 1155 | /** |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 1156 | * e1000_check_mng_mode_ich8lan - Checks management mode |
| 1157 | * @hw: pointer to the HW structure |
| 1158 | * |
Bruce Allan | eb7700d | 2010-06-16 13:27:05 +0000 | [diff] [blame] | 1159 | * This checks if the adapter has any manageability enabled. |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 1160 | * This is a function pointer entry point only called by read/write |
| 1161 | * routines for the PHY and NVM parts. |
| 1162 | **/ |
| 1163 | static bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw) |
| 1164 | { |
Bruce Allan | a708dd8 | 2009-11-20 23:28:37 +0000 | [diff] [blame] | 1165 | u32 fwsm; |
| 1166 | |
| 1167 | fwsm = er32(FWSM); |
Bruce Allan | f0ff439 | 2013-02-20 04:05:39 +0000 | [diff] [blame] | 1168 | return ((fwsm & E1000_ICH_FWSM_FW_VALID) && |
| 1169 | ((fwsm & E1000_FWSM_MODE_MASK) == |
| 1170 | (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT))); |
Bruce Allan | eb7700d | 2010-06-16 13:27:05 +0000 | [diff] [blame] | 1171 | } |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 1172 | |
Bruce Allan | eb7700d | 2010-06-16 13:27:05 +0000 | [diff] [blame] | 1173 | /** |
| 1174 | * e1000_check_mng_mode_pchlan - Checks management mode |
| 1175 | * @hw: pointer to the HW structure |
| 1176 | * |
| 1177 | * This checks if the adapter has iAMT enabled. |
| 1178 | * This is a function pointer entry point only called by read/write |
| 1179 | * routines for the PHY and NVM parts. |
| 1180 | **/ |
| 1181 | static bool e1000_check_mng_mode_pchlan(struct e1000_hw *hw) |
| 1182 | { |
| 1183 | u32 fwsm; |
| 1184 | |
| 1185 | fwsm = er32(FWSM); |
| 1186 | return (fwsm & E1000_ICH_FWSM_FW_VALID) && |
Bruce Allan | f0ff439 | 2013-02-20 04:05:39 +0000 | [diff] [blame] | 1187 | (fwsm & (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT)); |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 1188 | } |
| 1189 | |
| 1190 | /** |
Bruce Allan | 69e1e01 | 2012-04-14 03:28:50 +0000 | [diff] [blame] | 1191 | * e1000_rar_set_pch2lan - Set receive address register |
| 1192 | * @hw: pointer to the HW structure |
| 1193 | * @addr: pointer to the receive address |
| 1194 | * @index: receive address array register |
| 1195 | * |
| 1196 | * Sets the receive address array register at index to the address passed |
| 1197 | * in by addr. For 82579, RAR[0] is the base address register that is to |
| 1198 | * contain the MAC address but RAR[1-6] are reserved for manageability (ME). |
| 1199 | * Use SHRA[0-3] in place of those reserved for ME. |
| 1200 | **/ |
| 1201 | static void e1000_rar_set_pch2lan(struct e1000_hw *hw, u8 *addr, u32 index) |
| 1202 | { |
| 1203 | u32 rar_low, rar_high; |
| 1204 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 1205 | /* HW expects these in little endian so we reverse the byte order |
Bruce Allan | 69e1e01 | 2012-04-14 03:28:50 +0000 | [diff] [blame] | 1206 | * from network order (big endian) to little endian |
| 1207 | */ |
| 1208 | rar_low = ((u32)addr[0] | |
| 1209 | ((u32)addr[1] << 8) | |
| 1210 | ((u32)addr[2] << 16) | ((u32)addr[3] << 24)); |
| 1211 | |
| 1212 | rar_high = ((u32)addr[4] | ((u32)addr[5] << 8)); |
| 1213 | |
| 1214 | /* If MAC address zero, no need to set the AV bit */ |
| 1215 | if (rar_low || rar_high) |
| 1216 | rar_high |= E1000_RAH_AV; |
| 1217 | |
| 1218 | if (index == 0) { |
| 1219 | ew32(RAL(index), rar_low); |
| 1220 | e1e_flush(); |
| 1221 | ew32(RAH(index), rar_high); |
| 1222 | e1e_flush(); |
| 1223 | return; |
| 1224 | } |
| 1225 | |
| 1226 | if (index < hw->mac.rar_entry_count) { |
| 1227 | s32 ret_val; |
| 1228 | |
| 1229 | ret_val = e1000_acquire_swflag_ich8lan(hw); |
| 1230 | if (ret_val) |
| 1231 | goto out; |
| 1232 | |
| 1233 | ew32(SHRAL(index - 1), rar_low); |
| 1234 | e1e_flush(); |
| 1235 | ew32(SHRAH(index - 1), rar_high); |
| 1236 | e1e_flush(); |
| 1237 | |
| 1238 | e1000_release_swflag_ich8lan(hw); |
| 1239 | |
| 1240 | /* verify the register updates */ |
| 1241 | if ((er32(SHRAL(index - 1)) == rar_low) && |
| 1242 | (er32(SHRAH(index - 1)) == rar_high)) |
| 1243 | return; |
| 1244 | |
| 1245 | e_dbg("SHRA[%d] might be locked by ME - FWSM=0x%8.8x\n", |
| 1246 | (index - 1), er32(FWSM)); |
| 1247 | } |
| 1248 | |
| 1249 | out: |
| 1250 | e_dbg("Failed to write receive address at index %d\n", index); |
| 1251 | } |
| 1252 | |
| 1253 | /** |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 1254 | * e1000_rar_set_pch_lpt - Set receive address registers |
| 1255 | * @hw: pointer to the HW structure |
| 1256 | * @addr: pointer to the receive address |
| 1257 | * @index: receive address array register |
| 1258 | * |
| 1259 | * Sets the receive address register array at index to the address passed |
| 1260 | * in by addr. For LPT, RAR[0] is the base address register that is to |
| 1261 | * contain the MAC address. SHRA[0-10] are the shared receive address |
| 1262 | * registers that are shared between the Host and manageability engine (ME). |
| 1263 | **/ |
| 1264 | static void e1000_rar_set_pch_lpt(struct e1000_hw *hw, u8 *addr, u32 index) |
| 1265 | { |
| 1266 | u32 rar_low, rar_high; |
| 1267 | u32 wlock_mac; |
| 1268 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 1269 | /* HW expects these in little endian so we reverse the byte order |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 1270 | * from network order (big endian) to little endian |
| 1271 | */ |
| 1272 | rar_low = ((u32)addr[0] | ((u32)addr[1] << 8) | |
| 1273 | ((u32)addr[2] << 16) | ((u32)addr[3] << 24)); |
| 1274 | |
| 1275 | rar_high = ((u32)addr[4] | ((u32)addr[5] << 8)); |
| 1276 | |
| 1277 | /* If MAC address zero, no need to set the AV bit */ |
| 1278 | if (rar_low || rar_high) |
| 1279 | rar_high |= E1000_RAH_AV; |
| 1280 | |
| 1281 | if (index == 0) { |
| 1282 | ew32(RAL(index), rar_low); |
| 1283 | e1e_flush(); |
| 1284 | ew32(RAH(index), rar_high); |
| 1285 | e1e_flush(); |
| 1286 | return; |
| 1287 | } |
| 1288 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 1289 | /* The manageability engine (ME) can lock certain SHRAR registers that |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 1290 | * it is using - those registers are unavailable for use. |
| 1291 | */ |
| 1292 | if (index < hw->mac.rar_entry_count) { |
| 1293 | wlock_mac = er32(FWSM) & E1000_FWSM_WLOCK_MAC_MASK; |
| 1294 | wlock_mac >>= E1000_FWSM_WLOCK_MAC_SHIFT; |
| 1295 | |
| 1296 | /* Check if all SHRAR registers are locked */ |
| 1297 | if (wlock_mac == 1) |
| 1298 | goto out; |
| 1299 | |
| 1300 | if ((wlock_mac == 0) || (index <= wlock_mac)) { |
| 1301 | s32 ret_val; |
| 1302 | |
| 1303 | ret_val = e1000_acquire_swflag_ich8lan(hw); |
| 1304 | |
| 1305 | if (ret_val) |
| 1306 | goto out; |
| 1307 | |
| 1308 | ew32(SHRAL_PCH_LPT(index - 1), rar_low); |
| 1309 | e1e_flush(); |
| 1310 | ew32(SHRAH_PCH_LPT(index - 1), rar_high); |
| 1311 | e1e_flush(); |
| 1312 | |
| 1313 | e1000_release_swflag_ich8lan(hw); |
| 1314 | |
| 1315 | /* verify the register updates */ |
| 1316 | if ((er32(SHRAL_PCH_LPT(index - 1)) == rar_low) && |
| 1317 | (er32(SHRAH_PCH_LPT(index - 1)) == rar_high)) |
| 1318 | return; |
| 1319 | } |
| 1320 | } |
| 1321 | |
| 1322 | out: |
| 1323 | e_dbg("Failed to write receive address at index %d\n", index); |
| 1324 | } |
| 1325 | |
| 1326 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1327 | * e1000_check_reset_block_ich8lan - Check if PHY reset is blocked |
| 1328 | * @hw: pointer to the HW structure |
| 1329 | * |
| 1330 | * Checks if firmware is blocking the reset of the PHY. |
| 1331 | * This is a function pointer entry point only called by |
| 1332 | * reset routines. |
| 1333 | **/ |
| 1334 | static s32 e1000_check_reset_block_ich8lan(struct e1000_hw *hw) |
| 1335 | { |
| 1336 | u32 fwsm; |
| 1337 | |
| 1338 | fwsm = er32(FWSM); |
| 1339 | |
| 1340 | return (fwsm & E1000_ICH_FWSM_RSPCIPHY) ? 0 : E1000_BLK_PHY_RESET; |
| 1341 | } |
| 1342 | |
| 1343 | /** |
Bruce Allan | 8395ae8 | 2010-09-22 17:15:08 +0000 | [diff] [blame] | 1344 | * e1000_write_smbus_addr - Write SMBus address to PHY needed during Sx states |
| 1345 | * @hw: pointer to the HW structure |
| 1346 | * |
| 1347 | * Assumes semaphore already acquired. |
| 1348 | * |
| 1349 | **/ |
| 1350 | static s32 e1000_write_smbus_addr(struct e1000_hw *hw) |
| 1351 | { |
| 1352 | u16 phy_data; |
| 1353 | u32 strap = er32(STRAP); |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 1354 | u32 freq = (strap & E1000_STRAP_SMT_FREQ_MASK) >> |
| 1355 | E1000_STRAP_SMT_FREQ_SHIFT; |
Bruce Allan | 70806a7 | 2013-01-05 05:08:37 +0000 | [diff] [blame] | 1356 | s32 ret_val; |
Bruce Allan | 8395ae8 | 2010-09-22 17:15:08 +0000 | [diff] [blame] | 1357 | |
| 1358 | strap &= E1000_STRAP_SMBUS_ADDRESS_MASK; |
| 1359 | |
| 1360 | ret_val = e1000_read_phy_reg_hv_locked(hw, HV_SMB_ADDR, &phy_data); |
| 1361 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1362 | return ret_val; |
Bruce Allan | 8395ae8 | 2010-09-22 17:15:08 +0000 | [diff] [blame] | 1363 | |
| 1364 | phy_data &= ~HV_SMB_ADDR_MASK; |
| 1365 | phy_data |= (strap >> E1000_STRAP_SMBUS_ADDRESS_SHIFT); |
| 1366 | phy_data |= HV_SMB_ADDR_PEC_EN | HV_SMB_ADDR_VALID; |
Bruce Allan | 8395ae8 | 2010-09-22 17:15:08 +0000 | [diff] [blame] | 1367 | |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 1368 | if (hw->phy.type == e1000_phy_i217) { |
| 1369 | /* Restore SMBus frequency */ |
| 1370 | if (freq--) { |
| 1371 | phy_data &= ~HV_SMB_ADDR_FREQ_MASK; |
| 1372 | phy_data |= (freq & (1 << 0)) << |
| 1373 | HV_SMB_ADDR_FREQ_LOW_SHIFT; |
| 1374 | phy_data |= (freq & (1 << 1)) << |
| 1375 | (HV_SMB_ADDR_FREQ_HIGH_SHIFT - 1); |
| 1376 | } else { |
| 1377 | e_dbg("Unsupported SMB frequency in PHY\n"); |
| 1378 | } |
| 1379 | } |
| 1380 | |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1381 | return e1000_write_phy_reg_hv_locked(hw, HV_SMB_ADDR, phy_data); |
Bruce Allan | 8395ae8 | 2010-09-22 17:15:08 +0000 | [diff] [blame] | 1382 | } |
| 1383 | |
| 1384 | /** |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1385 | * e1000_sw_lcd_config_ich8lan - SW-based LCD Configuration |
| 1386 | * @hw: pointer to the HW structure |
| 1387 | * |
| 1388 | * SW should configure the LCD from the NVM extended configuration region |
| 1389 | * as a workaround for certain parts. |
| 1390 | **/ |
| 1391 | static s32 e1000_sw_lcd_config_ich8lan(struct e1000_hw *hw) |
| 1392 | { |
| 1393 | struct e1000_phy_info *phy = &hw->phy; |
| 1394 | u32 i, data, cnf_size, cnf_base_addr, sw_cfg_mask; |
Bruce Allan | 8b802a7 | 2010-05-10 15:01:10 +0000 | [diff] [blame] | 1395 | s32 ret_val = 0; |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1396 | u16 word_addr, reg_data, reg_addr, phy_page = 0; |
| 1397 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 1398 | /* Initialize the PHY from the NVM on ICH platforms. This |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1399 | * is needed due to an issue where the NVM configuration is |
| 1400 | * not properly autoloaded after power transitions. |
| 1401 | * Therefore, after each PHY reset, we will load the |
| 1402 | * configuration data out of the NVM manually. |
| 1403 | */ |
Bruce Allan | 3f0c16e | 2010-06-16 13:26:17 +0000 | [diff] [blame] | 1404 | switch (hw->mac.type) { |
| 1405 | case e1000_ich8lan: |
| 1406 | if (phy->type != e1000_phy_igp_3) |
| 1407 | return ret_val; |
| 1408 | |
Bruce Allan | 5f3eed6 | 2010-09-22 17:15:54 +0000 | [diff] [blame] | 1409 | if ((hw->adapter->pdev->device == E1000_DEV_ID_ICH8_IGP_AMT) || |
| 1410 | (hw->adapter->pdev->device == E1000_DEV_ID_ICH8_IGP_C)) { |
Bruce Allan | 3f0c16e | 2010-06-16 13:26:17 +0000 | [diff] [blame] | 1411 | sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG; |
| 1412 | break; |
| 1413 | } |
| 1414 | /* Fall-thru */ |
| 1415 | case e1000_pchlan: |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1416 | case e1000_pch2lan: |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 1417 | case e1000_pch_lpt: |
Bruce Allan | 8b802a7 | 2010-05-10 15:01:10 +0000 | [diff] [blame] | 1418 | sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG_ICH8M; |
Bruce Allan | 3f0c16e | 2010-06-16 13:26:17 +0000 | [diff] [blame] | 1419 | break; |
| 1420 | default: |
| 1421 | return ret_val; |
| 1422 | } |
| 1423 | |
| 1424 | ret_val = hw->phy.ops.acquire(hw); |
| 1425 | if (ret_val) |
| 1426 | return ret_val; |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1427 | |
Bruce Allan | 8b802a7 | 2010-05-10 15:01:10 +0000 | [diff] [blame] | 1428 | data = er32(FEXTNVM); |
| 1429 | if (!(data & sw_cfg_mask)) |
Bruce Allan | 75ce153 | 2012-02-08 02:54:48 +0000 | [diff] [blame] | 1430 | goto release; |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1431 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 1432 | /* Make sure HW does not configure LCD from PHY |
Bruce Allan | 8b802a7 | 2010-05-10 15:01:10 +0000 | [diff] [blame] | 1433 | * extended configuration before SW configuration |
| 1434 | */ |
| 1435 | data = er32(EXTCNF_CTRL); |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 1436 | if ((hw->mac.type < e1000_pch2lan) && |
| 1437 | (data & E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE)) |
| 1438 | goto release; |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1439 | |
Bruce Allan | 8b802a7 | 2010-05-10 15:01:10 +0000 | [diff] [blame] | 1440 | cnf_size = er32(EXTCNF_SIZE); |
| 1441 | cnf_size &= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_MASK; |
| 1442 | cnf_size >>= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_SHIFT; |
| 1443 | if (!cnf_size) |
Bruce Allan | 75ce153 | 2012-02-08 02:54:48 +0000 | [diff] [blame] | 1444 | goto release; |
Bruce Allan | 8b802a7 | 2010-05-10 15:01:10 +0000 | [diff] [blame] | 1445 | |
| 1446 | cnf_base_addr = data & E1000_EXTCNF_CTRL_EXT_CNF_POINTER_MASK; |
| 1447 | cnf_base_addr >>= E1000_EXTCNF_CTRL_EXT_CNF_POINTER_SHIFT; |
| 1448 | |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 1449 | if (((hw->mac.type == e1000_pchlan) && |
| 1450 | !(data & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE)) || |
| 1451 | (hw->mac.type > e1000_pchlan)) { |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 1452 | /* HW configures the SMBus address and LEDs when the |
Bruce Allan | 8b802a7 | 2010-05-10 15:01:10 +0000 | [diff] [blame] | 1453 | * OEM and LCD Write Enable bits are set in the NVM. |
| 1454 | * When both NVM bits are cleared, SW will configure |
| 1455 | * them instead. |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1456 | */ |
Bruce Allan | 8395ae8 | 2010-09-22 17:15:08 +0000 | [diff] [blame] | 1457 | ret_val = e1000_write_smbus_addr(hw); |
Bruce Allan | 8b802a7 | 2010-05-10 15:01:10 +0000 | [diff] [blame] | 1458 | if (ret_val) |
Bruce Allan | 75ce153 | 2012-02-08 02:54:48 +0000 | [diff] [blame] | 1459 | goto release; |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1460 | |
Bruce Allan | 8b802a7 | 2010-05-10 15:01:10 +0000 | [diff] [blame] | 1461 | data = er32(LEDCTL); |
| 1462 | ret_val = e1000_write_phy_reg_hv_locked(hw, HV_LED_CONFIG, |
| 1463 | (u16)data); |
| 1464 | if (ret_val) |
Bruce Allan | 75ce153 | 2012-02-08 02:54:48 +0000 | [diff] [blame] | 1465 | goto release; |
Bruce Allan | 8b802a7 | 2010-05-10 15:01:10 +0000 | [diff] [blame] | 1466 | } |
| 1467 | |
| 1468 | /* Configure LCD from extended configuration region. */ |
| 1469 | |
| 1470 | /* cnf_base_addr is in DWORD */ |
| 1471 | word_addr = (u16)(cnf_base_addr << 1); |
| 1472 | |
| 1473 | for (i = 0; i < cnf_size; i++) { |
Bruce Allan | e5fe254 | 2013-02-20 04:06:27 +0000 | [diff] [blame] | 1474 | ret_val = e1000_read_nvm(hw, (word_addr + i * 2), 1, ®_data); |
Bruce Allan | 8b802a7 | 2010-05-10 15:01:10 +0000 | [diff] [blame] | 1475 | if (ret_val) |
Bruce Allan | 75ce153 | 2012-02-08 02:54:48 +0000 | [diff] [blame] | 1476 | goto release; |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1477 | |
Bruce Allan | 8b802a7 | 2010-05-10 15:01:10 +0000 | [diff] [blame] | 1478 | ret_val = e1000_read_nvm(hw, (word_addr + i * 2 + 1), |
| 1479 | 1, ®_addr); |
| 1480 | if (ret_val) |
Bruce Allan | 75ce153 | 2012-02-08 02:54:48 +0000 | [diff] [blame] | 1481 | goto release; |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1482 | |
Bruce Allan | 8b802a7 | 2010-05-10 15:01:10 +0000 | [diff] [blame] | 1483 | /* Save off the PHY page for future writes. */ |
| 1484 | if (reg_addr == IGP01E1000_PHY_PAGE_SELECT) { |
| 1485 | phy_page = reg_data; |
| 1486 | continue; |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1487 | } |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1488 | |
Bruce Allan | 8b802a7 | 2010-05-10 15:01:10 +0000 | [diff] [blame] | 1489 | reg_addr &= PHY_REG_MASK; |
| 1490 | reg_addr |= phy_page; |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1491 | |
Bruce Allan | f1430d6 | 2012-04-14 04:21:52 +0000 | [diff] [blame] | 1492 | ret_val = e1e_wphy_locked(hw, (u32)reg_addr, reg_data); |
Bruce Allan | 8b802a7 | 2010-05-10 15:01:10 +0000 | [diff] [blame] | 1493 | if (ret_val) |
Bruce Allan | 75ce153 | 2012-02-08 02:54:48 +0000 | [diff] [blame] | 1494 | goto release; |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1495 | } |
| 1496 | |
Bruce Allan | 75ce153 | 2012-02-08 02:54:48 +0000 | [diff] [blame] | 1497 | release: |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 1498 | hw->phy.ops.release(hw); |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1499 | return ret_val; |
| 1500 | } |
| 1501 | |
| 1502 | /** |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1503 | * e1000_k1_gig_workaround_hv - K1 Si workaround |
| 1504 | * @hw: pointer to the HW structure |
| 1505 | * @link: link up bool flag |
| 1506 | * |
| 1507 | * If K1 is enabled for 1Gbps, the MAC might stall when transitioning |
| 1508 | * from a lower speed. This workaround disables K1 whenever link is at 1Gig |
| 1509 | * If link is down, the function will restore the default K1 setting located |
| 1510 | * in the NVM. |
| 1511 | **/ |
| 1512 | static s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link) |
| 1513 | { |
| 1514 | s32 ret_val = 0; |
| 1515 | u16 status_reg = 0; |
| 1516 | bool k1_enable = hw->dev_spec.ich8lan.nvm_k1_enabled; |
| 1517 | |
| 1518 | if (hw->mac.type != e1000_pchlan) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1519 | return 0; |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1520 | |
| 1521 | /* Wrap the whole flow with the sw flag */ |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 1522 | ret_val = hw->phy.ops.acquire(hw); |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1523 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1524 | return ret_val; |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1525 | |
| 1526 | /* Disable K1 when link is 1Gbps, otherwise use the NVM setting */ |
| 1527 | if (link) { |
| 1528 | if (hw->phy.type == e1000_phy_82578) { |
Bruce Allan | f1430d6 | 2012-04-14 04:21:52 +0000 | [diff] [blame] | 1529 | ret_val = e1e_rphy_locked(hw, BM_CS_STATUS, |
| 1530 | &status_reg); |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1531 | if (ret_val) |
| 1532 | goto release; |
| 1533 | |
Bruce Allan | f0ff439 | 2013-02-20 04:05:39 +0000 | [diff] [blame] | 1534 | status_reg &= (BM_CS_STATUS_LINK_UP | |
| 1535 | BM_CS_STATUS_RESOLVED | |
| 1536 | BM_CS_STATUS_SPEED_MASK); |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1537 | |
| 1538 | if (status_reg == (BM_CS_STATUS_LINK_UP | |
Bruce Allan | f0ff439 | 2013-02-20 04:05:39 +0000 | [diff] [blame] | 1539 | BM_CS_STATUS_RESOLVED | |
| 1540 | BM_CS_STATUS_SPEED_1000)) |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1541 | k1_enable = false; |
| 1542 | } |
| 1543 | |
| 1544 | if (hw->phy.type == e1000_phy_82577) { |
Bruce Allan | f1430d6 | 2012-04-14 04:21:52 +0000 | [diff] [blame] | 1545 | ret_val = e1e_rphy_locked(hw, HV_M_STATUS, &status_reg); |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1546 | if (ret_val) |
| 1547 | goto release; |
| 1548 | |
Bruce Allan | f0ff439 | 2013-02-20 04:05:39 +0000 | [diff] [blame] | 1549 | status_reg &= (HV_M_STATUS_LINK_UP | |
| 1550 | HV_M_STATUS_AUTONEG_COMPLETE | |
| 1551 | HV_M_STATUS_SPEED_MASK); |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1552 | |
| 1553 | if (status_reg == (HV_M_STATUS_LINK_UP | |
Bruce Allan | f0ff439 | 2013-02-20 04:05:39 +0000 | [diff] [blame] | 1554 | HV_M_STATUS_AUTONEG_COMPLETE | |
| 1555 | HV_M_STATUS_SPEED_1000)) |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1556 | k1_enable = false; |
| 1557 | } |
| 1558 | |
| 1559 | /* Link stall fix for link up */ |
Bruce Allan | f1430d6 | 2012-04-14 04:21:52 +0000 | [diff] [blame] | 1560 | ret_val = e1e_wphy_locked(hw, PHY_REG(770, 19), 0x0100); |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1561 | if (ret_val) |
| 1562 | goto release; |
| 1563 | |
| 1564 | } else { |
| 1565 | /* Link stall fix for link down */ |
Bruce Allan | f1430d6 | 2012-04-14 04:21:52 +0000 | [diff] [blame] | 1566 | ret_val = e1e_wphy_locked(hw, PHY_REG(770, 19), 0x4100); |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1567 | if (ret_val) |
| 1568 | goto release; |
| 1569 | } |
| 1570 | |
| 1571 | ret_val = e1000_configure_k1_ich8lan(hw, k1_enable); |
| 1572 | |
| 1573 | release: |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 1574 | hw->phy.ops.release(hw); |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1575 | |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1576 | return ret_val; |
| 1577 | } |
| 1578 | |
| 1579 | /** |
| 1580 | * e1000_configure_k1_ich8lan - Configure K1 power state |
| 1581 | * @hw: pointer to the HW structure |
| 1582 | * @enable: K1 state to configure |
| 1583 | * |
| 1584 | * Configure the K1 power state based on the provided parameter. |
| 1585 | * Assumes semaphore already acquired. |
| 1586 | * |
| 1587 | * Success returns 0, Failure returns -E1000_ERR_PHY (-2) |
| 1588 | **/ |
Bruce Allan | bb436b2 | 2009-11-20 23:24:11 +0000 | [diff] [blame] | 1589 | s32 e1000_configure_k1_ich8lan(struct e1000_hw *hw, bool k1_enable) |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1590 | { |
Bruce Allan | 70806a7 | 2013-01-05 05:08:37 +0000 | [diff] [blame] | 1591 | s32 ret_val; |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1592 | u32 ctrl_reg = 0; |
| 1593 | u32 ctrl_ext = 0; |
| 1594 | u32 reg = 0; |
| 1595 | u16 kmrn_reg = 0; |
| 1596 | |
Bruce Allan | 3d3a167 | 2012-02-23 03:13:18 +0000 | [diff] [blame] | 1597 | ret_val = e1000e_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG, |
| 1598 | &kmrn_reg); |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1599 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1600 | return ret_val; |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1601 | |
| 1602 | if (k1_enable) |
| 1603 | kmrn_reg |= E1000_KMRNCTRLSTA_K1_ENABLE; |
| 1604 | else |
| 1605 | kmrn_reg &= ~E1000_KMRNCTRLSTA_K1_ENABLE; |
| 1606 | |
Bruce Allan | 3d3a167 | 2012-02-23 03:13:18 +0000 | [diff] [blame] | 1607 | ret_val = e1000e_write_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG, |
| 1608 | kmrn_reg); |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1609 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1610 | return ret_val; |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1611 | |
Bruce Allan | ce43a21 | 2013-02-20 04:06:32 +0000 | [diff] [blame] | 1612 | usleep_range(20, 40); |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1613 | ctrl_ext = er32(CTRL_EXT); |
| 1614 | ctrl_reg = er32(CTRL); |
| 1615 | |
| 1616 | reg = ctrl_reg & ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100); |
| 1617 | reg |= E1000_CTRL_FRCSPD; |
| 1618 | ew32(CTRL, reg); |
| 1619 | |
| 1620 | ew32(CTRL_EXT, ctrl_ext | E1000_CTRL_EXT_SPD_BYPS); |
Jesse Brandeburg | 945a515 | 2011-07-20 00:56:21 +0000 | [diff] [blame] | 1621 | e1e_flush(); |
Bruce Allan | ce43a21 | 2013-02-20 04:06:32 +0000 | [diff] [blame] | 1622 | usleep_range(20, 40); |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1623 | ew32(CTRL, ctrl_reg); |
| 1624 | ew32(CTRL_EXT, ctrl_ext); |
Jesse Brandeburg | 945a515 | 2011-07-20 00:56:21 +0000 | [diff] [blame] | 1625 | e1e_flush(); |
Bruce Allan | ce43a21 | 2013-02-20 04:06:32 +0000 | [diff] [blame] | 1626 | usleep_range(20, 40); |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1627 | |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1628 | return 0; |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1629 | } |
| 1630 | |
| 1631 | /** |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1632 | * e1000_oem_bits_config_ich8lan - SW-based LCD Configuration |
| 1633 | * @hw: pointer to the HW structure |
| 1634 | * @d0_state: boolean if entering d0 or d3 device state |
| 1635 | * |
| 1636 | * SW will configure Gbe Disable and LPLU based on the NVM. The four bits are |
| 1637 | * collectively called OEM bits. The OEM Write Enable bit and SW Config bit |
| 1638 | * in NVM determines whether HW should configure LPLU and Gbe Disable. |
| 1639 | **/ |
| 1640 | static s32 e1000_oem_bits_config_ich8lan(struct e1000_hw *hw, bool d0_state) |
| 1641 | { |
| 1642 | s32 ret_val = 0; |
| 1643 | u32 mac_reg; |
| 1644 | u16 oem_reg; |
| 1645 | |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 1646 | if (hw->mac.type < e1000_pchlan) |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1647 | return ret_val; |
| 1648 | |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 1649 | ret_val = hw->phy.ops.acquire(hw); |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1650 | if (ret_val) |
| 1651 | return ret_val; |
| 1652 | |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 1653 | if (hw->mac.type == e1000_pchlan) { |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1654 | mac_reg = er32(EXTCNF_CTRL); |
| 1655 | if (mac_reg & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE) |
Bruce Allan | 75ce153 | 2012-02-08 02:54:48 +0000 | [diff] [blame] | 1656 | goto release; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1657 | } |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1658 | |
| 1659 | mac_reg = er32(FEXTNVM); |
| 1660 | if (!(mac_reg & E1000_FEXTNVM_SW_CONFIG_ICH8M)) |
Bruce Allan | 75ce153 | 2012-02-08 02:54:48 +0000 | [diff] [blame] | 1661 | goto release; |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1662 | |
| 1663 | mac_reg = er32(PHY_CTRL); |
| 1664 | |
Bruce Allan | f1430d6 | 2012-04-14 04:21:52 +0000 | [diff] [blame] | 1665 | ret_val = e1e_rphy_locked(hw, HV_OEM_BITS, &oem_reg); |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1666 | if (ret_val) |
Bruce Allan | 75ce153 | 2012-02-08 02:54:48 +0000 | [diff] [blame] | 1667 | goto release; |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1668 | |
| 1669 | oem_reg &= ~(HV_OEM_BITS_GBE_DIS | HV_OEM_BITS_LPLU); |
| 1670 | |
| 1671 | if (d0_state) { |
| 1672 | if (mac_reg & E1000_PHY_CTRL_GBE_DISABLE) |
| 1673 | oem_reg |= HV_OEM_BITS_GBE_DIS; |
| 1674 | |
| 1675 | if (mac_reg & E1000_PHY_CTRL_D0A_LPLU) |
| 1676 | oem_reg |= HV_OEM_BITS_LPLU; |
| 1677 | } else { |
Bruce Allan | 03299e4 | 2011-09-30 08:07:05 +0000 | [diff] [blame] | 1678 | if (mac_reg & (E1000_PHY_CTRL_GBE_DISABLE | |
| 1679 | E1000_PHY_CTRL_NOND0A_GBE_DISABLE)) |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1680 | oem_reg |= HV_OEM_BITS_GBE_DIS; |
| 1681 | |
Bruce Allan | 03299e4 | 2011-09-30 08:07:05 +0000 | [diff] [blame] | 1682 | if (mac_reg & (E1000_PHY_CTRL_D0A_LPLU | |
| 1683 | E1000_PHY_CTRL_NOND0A_LPLU)) |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1684 | oem_reg |= HV_OEM_BITS_LPLU; |
| 1685 | } |
Bruce Allan | 03299e4 | 2011-09-30 08:07:05 +0000 | [diff] [blame] | 1686 | |
Bruce Allan | 92fe173 | 2012-04-12 06:27:03 +0000 | [diff] [blame] | 1687 | /* Set Restart auto-neg to activate the bits */ |
| 1688 | if ((d0_state || (hw->mac.type != e1000_pchlan)) && |
| 1689 | !hw->phy.ops.check_reset_block(hw)) |
| 1690 | oem_reg |= HV_OEM_BITS_RESTART_AN; |
| 1691 | |
Bruce Allan | f1430d6 | 2012-04-14 04:21:52 +0000 | [diff] [blame] | 1692 | ret_val = e1e_wphy_locked(hw, HV_OEM_BITS, oem_reg); |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1693 | |
Bruce Allan | 75ce153 | 2012-02-08 02:54:48 +0000 | [diff] [blame] | 1694 | release: |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 1695 | hw->phy.ops.release(hw); |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1696 | |
| 1697 | return ret_val; |
| 1698 | } |
| 1699 | |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1700 | /** |
Bruce Allan | fddaa1a | 2010-01-13 01:52:49 +0000 | [diff] [blame] | 1701 | * e1000_set_mdio_slow_mode_hv - Set slow MDIO access mode |
| 1702 | * @hw: pointer to the HW structure |
| 1703 | **/ |
| 1704 | static s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw) |
| 1705 | { |
| 1706 | s32 ret_val; |
| 1707 | u16 data; |
| 1708 | |
| 1709 | ret_val = e1e_rphy(hw, HV_KMRN_MODE_CTRL, &data); |
| 1710 | if (ret_val) |
| 1711 | return ret_val; |
| 1712 | |
| 1713 | data |= HV_KMRN_MDIO_SLOW; |
| 1714 | |
| 1715 | ret_val = e1e_wphy(hw, HV_KMRN_MODE_CTRL, data); |
| 1716 | |
| 1717 | return ret_val; |
| 1718 | } |
| 1719 | |
| 1720 | /** |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 1721 | * e1000_hv_phy_workarounds_ich8lan - A series of Phy workarounds to be |
| 1722 | * done after every PHY reset. |
| 1723 | **/ |
| 1724 | static s32 e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw) |
| 1725 | { |
| 1726 | s32 ret_val = 0; |
Bruce Allan | baf86c9 | 2010-01-13 01:53:08 +0000 | [diff] [blame] | 1727 | u16 phy_data; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 1728 | |
| 1729 | if (hw->mac.type != e1000_pchlan) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1730 | return 0; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 1731 | |
Bruce Allan | fddaa1a | 2010-01-13 01:52:49 +0000 | [diff] [blame] | 1732 | /* Set MDIO slow mode before any other MDIO access */ |
| 1733 | if (hw->phy.type == e1000_phy_82577) { |
| 1734 | ret_val = e1000_set_mdio_slow_mode_hv(hw); |
| 1735 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1736 | return ret_val; |
Bruce Allan | fddaa1a | 2010-01-13 01:52:49 +0000 | [diff] [blame] | 1737 | } |
| 1738 | |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 1739 | if (((hw->phy.type == e1000_phy_82577) && |
| 1740 | ((hw->phy.revision == 1) || (hw->phy.revision == 2))) || |
| 1741 | ((hw->phy.type == e1000_phy_82578) && (hw->phy.revision == 1))) { |
| 1742 | /* Disable generation of early preamble */ |
| 1743 | ret_val = e1e_wphy(hw, PHY_REG(769, 25), 0x4431); |
| 1744 | if (ret_val) |
| 1745 | return ret_val; |
| 1746 | |
| 1747 | /* Preamble tuning for SSC */ |
Bruce Allan | 1d2101a7 | 2011-07-22 06:21:56 +0000 | [diff] [blame] | 1748 | ret_val = e1e_wphy(hw, HV_KMRN_FIFO_CTRLSTA, 0xA204); |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 1749 | if (ret_val) |
| 1750 | return ret_val; |
| 1751 | } |
| 1752 | |
| 1753 | if (hw->phy.type == e1000_phy_82578) { |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 1754 | /* Return registers to default by doing a soft reset then |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 1755 | * writing 0x3140 to the control register. |
| 1756 | */ |
| 1757 | if (hw->phy.revision < 2) { |
| 1758 | e1000e_phy_sw_reset(hw); |
Bruce Allan | c2ade1a | 2013-01-16 08:54:35 +0000 | [diff] [blame] | 1759 | ret_val = e1e_wphy(hw, MII_BMCR, 0x3140); |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 1760 | } |
| 1761 | } |
| 1762 | |
| 1763 | /* Select page 0 */ |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 1764 | ret_val = hw->phy.ops.acquire(hw); |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 1765 | if (ret_val) |
| 1766 | return ret_val; |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1767 | |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 1768 | hw->phy.addr = 1; |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1769 | ret_val = e1000e_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT, 0); |
Bruce Allan | baf86c9 | 2010-01-13 01:53:08 +0000 | [diff] [blame] | 1770 | hw->phy.ops.release(hw); |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1771 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1772 | return ret_val; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 1773 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 1774 | /* Configure the K1 Si workaround during phy reset assuming there is |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1775 | * link so that it disables K1 if link is in 1Gbps. |
| 1776 | */ |
| 1777 | ret_val = e1000_k1_gig_workaround_hv(hw, true); |
Bruce Allan | baf86c9 | 2010-01-13 01:53:08 +0000 | [diff] [blame] | 1778 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1779 | return ret_val; |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1780 | |
Bruce Allan | baf86c9 | 2010-01-13 01:53:08 +0000 | [diff] [blame] | 1781 | /* Workaround for link disconnects on a busy hub in half duplex */ |
| 1782 | ret_val = hw->phy.ops.acquire(hw); |
| 1783 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1784 | return ret_val; |
Bruce Allan | f1430d6 | 2012-04-14 04:21:52 +0000 | [diff] [blame] | 1785 | ret_val = e1e_rphy_locked(hw, BM_PORT_GEN_CFG, &phy_data); |
Bruce Allan | baf86c9 | 2010-01-13 01:53:08 +0000 | [diff] [blame] | 1786 | if (ret_val) |
| 1787 | goto release; |
Bruce Allan | f1430d6 | 2012-04-14 04:21:52 +0000 | [diff] [blame] | 1788 | ret_val = e1e_wphy_locked(hw, BM_PORT_GEN_CFG, phy_data & 0x00FF); |
Bruce Allan | 651fb10 | 2012-12-05 06:26:03 +0000 | [diff] [blame] | 1789 | if (ret_val) |
| 1790 | goto release; |
| 1791 | |
| 1792 | /* set MSE higher to enable link to stay up when noise is high */ |
| 1793 | ret_val = e1000_write_emi_reg_locked(hw, I82577_MSE_THRESHOLD, 0x0034); |
Bruce Allan | baf86c9 | 2010-01-13 01:53:08 +0000 | [diff] [blame] | 1794 | release: |
| 1795 | hw->phy.ops.release(hw); |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1796 | |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 1797 | return ret_val; |
| 1798 | } |
| 1799 | |
| 1800 | /** |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1801 | * e1000_copy_rx_addrs_to_phy_ich8lan - Copy Rx addresses from MAC to PHY |
| 1802 | * @hw: pointer to the HW structure |
| 1803 | **/ |
| 1804 | void e1000_copy_rx_addrs_to_phy_ich8lan(struct e1000_hw *hw) |
| 1805 | { |
| 1806 | u32 mac_reg; |
Bruce Allan | 2b6b168 | 2011-05-13 07:20:09 +0000 | [diff] [blame] | 1807 | u16 i, phy_reg = 0; |
| 1808 | s32 ret_val; |
| 1809 | |
| 1810 | ret_val = hw->phy.ops.acquire(hw); |
| 1811 | if (ret_val) |
| 1812 | return; |
| 1813 | ret_val = e1000_enable_phy_wakeup_reg_access_bm(hw, &phy_reg); |
| 1814 | if (ret_val) |
| 1815 | goto release; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1816 | |
| 1817 | /* Copy both RAL/H (rar_entry_count) and SHRAL/H (+4) to PHY */ |
| 1818 | for (i = 0; i < (hw->mac.rar_entry_count + 4); i++) { |
| 1819 | mac_reg = er32(RAL(i)); |
Bruce Allan | 2b6b168 | 2011-05-13 07:20:09 +0000 | [diff] [blame] | 1820 | hw->phy.ops.write_reg_page(hw, BM_RAR_L(i), |
| 1821 | (u16)(mac_reg & 0xFFFF)); |
| 1822 | hw->phy.ops.write_reg_page(hw, BM_RAR_M(i), |
| 1823 | (u16)((mac_reg >> 16) & 0xFFFF)); |
| 1824 | |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1825 | mac_reg = er32(RAH(i)); |
Bruce Allan | 2b6b168 | 2011-05-13 07:20:09 +0000 | [diff] [blame] | 1826 | hw->phy.ops.write_reg_page(hw, BM_RAR_H(i), |
| 1827 | (u16)(mac_reg & 0xFFFF)); |
| 1828 | hw->phy.ops.write_reg_page(hw, BM_RAR_CTRL(i), |
| 1829 | (u16)((mac_reg & E1000_RAH_AV) |
| 1830 | >> 16)); |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1831 | } |
Bruce Allan | 2b6b168 | 2011-05-13 07:20:09 +0000 | [diff] [blame] | 1832 | |
| 1833 | e1000_disable_phy_wakeup_reg_access_bm(hw, &phy_reg); |
| 1834 | |
| 1835 | release: |
| 1836 | hw->phy.ops.release(hw); |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1837 | } |
| 1838 | |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1839 | /** |
| 1840 | * e1000_lv_jumbo_workaround_ich8lan - required for jumbo frame operation |
| 1841 | * with 82579 PHY |
| 1842 | * @hw: pointer to the HW structure |
| 1843 | * @enable: flag to enable/disable workaround when enabling/disabling jumbos |
| 1844 | **/ |
| 1845 | s32 e1000_lv_jumbo_workaround_ich8lan(struct e1000_hw *hw, bool enable) |
| 1846 | { |
| 1847 | s32 ret_val = 0; |
| 1848 | u16 phy_reg, data; |
| 1849 | u32 mac_reg; |
| 1850 | u16 i; |
| 1851 | |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 1852 | if (hw->mac.type < e1000_pch2lan) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1853 | return 0; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1854 | |
| 1855 | /* disable Rx path while enabling/disabling workaround */ |
| 1856 | e1e_rphy(hw, PHY_REG(769, 20), &phy_reg); |
| 1857 | ret_val = e1e_wphy(hw, PHY_REG(769, 20), phy_reg | (1 << 14)); |
| 1858 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1859 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1860 | |
| 1861 | if (enable) { |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 1862 | /* Write Rx addresses (rar_entry_count for RAL/H, +4 for |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1863 | * SHRAL/H) and initial CRC values to the MAC |
| 1864 | */ |
| 1865 | for (i = 0; i < (hw->mac.rar_entry_count + 4); i++) { |
Bruce Allan | 362e20c | 2013-02-20 04:05:45 +0000 | [diff] [blame] | 1866 | u8 mac_addr[ETH_ALEN] = { 0 }; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1867 | u32 addr_high, addr_low; |
| 1868 | |
| 1869 | addr_high = er32(RAH(i)); |
| 1870 | if (!(addr_high & E1000_RAH_AV)) |
| 1871 | continue; |
| 1872 | addr_low = er32(RAL(i)); |
| 1873 | mac_addr[0] = (addr_low & 0xFF); |
| 1874 | mac_addr[1] = ((addr_low >> 8) & 0xFF); |
| 1875 | mac_addr[2] = ((addr_low >> 16) & 0xFF); |
| 1876 | mac_addr[3] = ((addr_low >> 24) & 0xFF); |
| 1877 | mac_addr[4] = (addr_high & 0xFF); |
| 1878 | mac_addr[5] = ((addr_high >> 8) & 0xFF); |
| 1879 | |
Bruce Allan | fe46f58 | 2011-01-06 14:29:51 +0000 | [diff] [blame] | 1880 | ew32(PCH_RAICC(i), ~ether_crc_le(ETH_ALEN, mac_addr)); |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1881 | } |
| 1882 | |
| 1883 | /* Write Rx addresses to the PHY */ |
| 1884 | e1000_copy_rx_addrs_to_phy_ich8lan(hw); |
| 1885 | |
| 1886 | /* Enable jumbo frame workaround in the MAC */ |
| 1887 | mac_reg = er32(FFLT_DBG); |
| 1888 | mac_reg &= ~(1 << 14); |
| 1889 | mac_reg |= (7 << 15); |
| 1890 | ew32(FFLT_DBG, mac_reg); |
| 1891 | |
| 1892 | mac_reg = er32(RCTL); |
| 1893 | mac_reg |= E1000_RCTL_SECRC; |
| 1894 | ew32(RCTL, mac_reg); |
| 1895 | |
| 1896 | ret_val = e1000e_read_kmrn_reg(hw, |
Bruce Allan | 17e813e | 2013-02-20 04:06:01 +0000 | [diff] [blame] | 1897 | E1000_KMRNCTRLSTA_CTRL_OFFSET, |
| 1898 | &data); |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1899 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1900 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1901 | ret_val = e1000e_write_kmrn_reg(hw, |
| 1902 | E1000_KMRNCTRLSTA_CTRL_OFFSET, |
| 1903 | data | (1 << 0)); |
| 1904 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1905 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1906 | ret_val = e1000e_read_kmrn_reg(hw, |
Bruce Allan | 17e813e | 2013-02-20 04:06:01 +0000 | [diff] [blame] | 1907 | E1000_KMRNCTRLSTA_HD_CTRL, |
| 1908 | &data); |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1909 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1910 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1911 | data &= ~(0xF << 8); |
| 1912 | data |= (0xB << 8); |
| 1913 | ret_val = e1000e_write_kmrn_reg(hw, |
| 1914 | E1000_KMRNCTRLSTA_HD_CTRL, |
| 1915 | data); |
| 1916 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1917 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1918 | |
| 1919 | /* Enable jumbo frame workaround in the PHY */ |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1920 | e1e_rphy(hw, PHY_REG(769, 23), &data); |
| 1921 | data &= ~(0x7F << 5); |
| 1922 | data |= (0x37 << 5); |
| 1923 | ret_val = e1e_wphy(hw, PHY_REG(769, 23), data); |
| 1924 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1925 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1926 | e1e_rphy(hw, PHY_REG(769, 16), &data); |
| 1927 | data &= ~(1 << 13); |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1928 | ret_val = e1e_wphy(hw, PHY_REG(769, 16), data); |
| 1929 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1930 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1931 | e1e_rphy(hw, PHY_REG(776, 20), &data); |
| 1932 | data &= ~(0x3FF << 2); |
| 1933 | data |= (0x1A << 2); |
| 1934 | ret_val = e1e_wphy(hw, PHY_REG(776, 20), data); |
| 1935 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1936 | return ret_val; |
Bruce Allan | b64e9dd | 2011-09-30 08:07:00 +0000 | [diff] [blame] | 1937 | ret_val = e1e_wphy(hw, PHY_REG(776, 23), 0xF100); |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1938 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1939 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1940 | e1e_rphy(hw, HV_PM_CTRL, &data); |
| 1941 | ret_val = e1e_wphy(hw, HV_PM_CTRL, data | (1 << 10)); |
| 1942 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1943 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1944 | } else { |
| 1945 | /* Write MAC register values back to h/w defaults */ |
| 1946 | mac_reg = er32(FFLT_DBG); |
| 1947 | mac_reg &= ~(0xF << 14); |
| 1948 | ew32(FFLT_DBG, mac_reg); |
| 1949 | |
| 1950 | mac_reg = er32(RCTL); |
| 1951 | mac_reg &= ~E1000_RCTL_SECRC; |
Bruce Allan | a1ce647 | 2010-09-22 17:16:40 +0000 | [diff] [blame] | 1952 | ew32(RCTL, mac_reg); |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1953 | |
| 1954 | ret_val = e1000e_read_kmrn_reg(hw, |
Bruce Allan | 17e813e | 2013-02-20 04:06:01 +0000 | [diff] [blame] | 1955 | E1000_KMRNCTRLSTA_CTRL_OFFSET, |
| 1956 | &data); |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1957 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1958 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1959 | ret_val = e1000e_write_kmrn_reg(hw, |
| 1960 | E1000_KMRNCTRLSTA_CTRL_OFFSET, |
| 1961 | data & ~(1 << 0)); |
| 1962 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1963 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1964 | ret_val = e1000e_read_kmrn_reg(hw, |
Bruce Allan | 17e813e | 2013-02-20 04:06:01 +0000 | [diff] [blame] | 1965 | E1000_KMRNCTRLSTA_HD_CTRL, |
| 1966 | &data); |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1967 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1968 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1969 | data &= ~(0xF << 8); |
| 1970 | data |= (0xB << 8); |
| 1971 | ret_val = e1000e_write_kmrn_reg(hw, |
| 1972 | E1000_KMRNCTRLSTA_HD_CTRL, |
| 1973 | data); |
| 1974 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1975 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1976 | |
| 1977 | /* Write PHY register values back to h/w defaults */ |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1978 | e1e_rphy(hw, PHY_REG(769, 23), &data); |
| 1979 | data &= ~(0x7F << 5); |
| 1980 | ret_val = e1e_wphy(hw, PHY_REG(769, 23), data); |
| 1981 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1982 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1983 | e1e_rphy(hw, PHY_REG(769, 16), &data); |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1984 | data |= (1 << 13); |
| 1985 | ret_val = e1e_wphy(hw, PHY_REG(769, 16), data); |
| 1986 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1987 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1988 | e1e_rphy(hw, PHY_REG(776, 20), &data); |
| 1989 | data &= ~(0x3FF << 2); |
| 1990 | data |= (0x8 << 2); |
| 1991 | ret_val = e1e_wphy(hw, PHY_REG(776, 20), data); |
| 1992 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1993 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1994 | ret_val = e1e_wphy(hw, PHY_REG(776, 23), 0x7E00); |
| 1995 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1996 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1997 | e1e_rphy(hw, HV_PM_CTRL, &data); |
| 1998 | ret_val = e1e_wphy(hw, HV_PM_CTRL, data & ~(1 << 10)); |
| 1999 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 2000 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 2001 | } |
| 2002 | |
| 2003 | /* re-enable Rx path after enabling/disabling workaround */ |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 2004 | return e1e_wphy(hw, PHY_REG(769, 20), phy_reg & ~(1 << 14)); |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 2005 | } |
| 2006 | |
| 2007 | /** |
| 2008 | * e1000_lv_phy_workarounds_ich8lan - A series of Phy workarounds to be |
| 2009 | * done after every PHY reset. |
| 2010 | **/ |
| 2011 | static s32 e1000_lv_phy_workarounds_ich8lan(struct e1000_hw *hw) |
| 2012 | { |
| 2013 | s32 ret_val = 0; |
| 2014 | |
| 2015 | if (hw->mac.type != e1000_pch2lan) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 2016 | return 0; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 2017 | |
| 2018 | /* Set MDIO slow mode before any other MDIO access */ |
| 2019 | ret_val = e1000_set_mdio_slow_mode_hv(hw); |
Bruce Allan | 8e5ab42 | 2012-12-05 06:26:19 +0000 | [diff] [blame] | 2020 | if (ret_val) |
| 2021 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 2022 | |
Bruce Allan | 4d24136 | 2011-12-16 00:46:06 +0000 | [diff] [blame] | 2023 | ret_val = hw->phy.ops.acquire(hw); |
| 2024 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 2025 | return ret_val; |
Bruce Allan | 4d24136 | 2011-12-16 00:46:06 +0000 | [diff] [blame] | 2026 | /* set MSE higher to enable link to stay up when noise is high */ |
Bruce Allan | 4ddc48a | 2012-12-05 06:25:58 +0000 | [diff] [blame] | 2027 | ret_val = e1000_write_emi_reg_locked(hw, I82579_MSE_THRESHOLD, 0x0034); |
Bruce Allan | 4d24136 | 2011-12-16 00:46:06 +0000 | [diff] [blame] | 2028 | if (ret_val) |
| 2029 | goto release; |
| 2030 | /* drop link after 5 times MSE threshold was reached */ |
Bruce Allan | 4ddc48a | 2012-12-05 06:25:58 +0000 | [diff] [blame] | 2031 | ret_val = e1000_write_emi_reg_locked(hw, I82579_MSE_LINK_DOWN, 0x0005); |
Bruce Allan | 4d24136 | 2011-12-16 00:46:06 +0000 | [diff] [blame] | 2032 | release: |
| 2033 | hw->phy.ops.release(hw); |
| 2034 | |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 2035 | return ret_val; |
| 2036 | } |
| 2037 | |
| 2038 | /** |
Bruce Allan | 831bd2e | 2010-09-22 17:16:18 +0000 | [diff] [blame] | 2039 | * e1000_k1_gig_workaround_lv - K1 Si workaround |
| 2040 | * @hw: pointer to the HW structure |
| 2041 | * |
| 2042 | * Workaround to set the K1 beacon duration for 82579 parts |
| 2043 | **/ |
| 2044 | static s32 e1000_k1_workaround_lv(struct e1000_hw *hw) |
| 2045 | { |
| 2046 | s32 ret_val = 0; |
| 2047 | u16 status_reg = 0; |
| 2048 | u32 mac_reg; |
Bruce Allan | 0ed013e | 2011-07-29 05:52:56 +0000 | [diff] [blame] | 2049 | u16 phy_reg; |
Bruce Allan | 831bd2e | 2010-09-22 17:16:18 +0000 | [diff] [blame] | 2050 | |
| 2051 | if (hw->mac.type != e1000_pch2lan) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 2052 | return 0; |
Bruce Allan | 831bd2e | 2010-09-22 17:16:18 +0000 | [diff] [blame] | 2053 | |
| 2054 | /* Set K1 beacon duration based on 1Gbps speed or otherwise */ |
| 2055 | ret_val = e1e_rphy(hw, HV_M_STATUS, &status_reg); |
| 2056 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 2057 | return ret_val; |
Bruce Allan | 831bd2e | 2010-09-22 17:16:18 +0000 | [diff] [blame] | 2058 | |
| 2059 | if ((status_reg & (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE)) |
| 2060 | == (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE)) { |
| 2061 | mac_reg = er32(FEXTNVM4); |
| 2062 | mac_reg &= ~E1000_FEXTNVM4_BEACON_DURATION_MASK; |
| 2063 | |
Bruce Allan | 0ed013e | 2011-07-29 05:52:56 +0000 | [diff] [blame] | 2064 | ret_val = e1e_rphy(hw, I82579_LPI_CTRL, &phy_reg); |
| 2065 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 2066 | return ret_val; |
Bruce Allan | 831bd2e | 2010-09-22 17:16:18 +0000 | [diff] [blame] | 2067 | |
Bruce Allan | 0ed013e | 2011-07-29 05:52:56 +0000 | [diff] [blame] | 2068 | if (status_reg & HV_M_STATUS_SPEED_1000) { |
Bruce Allan | 36ceeb4 | 2012-03-20 03:47:47 +0000 | [diff] [blame] | 2069 | u16 pm_phy_reg; |
| 2070 | |
Bruce Allan | 0ed013e | 2011-07-29 05:52:56 +0000 | [diff] [blame] | 2071 | mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_8USEC; |
| 2072 | phy_reg &= ~I82579_LPI_CTRL_FORCE_PLL_LOCK_COUNT; |
Bruce Allan | 36ceeb4 | 2012-03-20 03:47:47 +0000 | [diff] [blame] | 2073 | /* LV 1G Packet drop issue wa */ |
| 2074 | ret_val = e1e_rphy(hw, HV_PM_CTRL, &pm_phy_reg); |
| 2075 | if (ret_val) |
| 2076 | return ret_val; |
| 2077 | pm_phy_reg &= ~HV_PM_CTRL_PLL_STOP_IN_K1_GIGA; |
| 2078 | ret_val = e1e_wphy(hw, HV_PM_CTRL, pm_phy_reg); |
| 2079 | if (ret_val) |
| 2080 | return ret_val; |
Bruce Allan | 0ed013e | 2011-07-29 05:52:56 +0000 | [diff] [blame] | 2081 | } else { |
| 2082 | mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_16USEC; |
| 2083 | phy_reg |= I82579_LPI_CTRL_FORCE_PLL_LOCK_COUNT; |
| 2084 | } |
Bruce Allan | 831bd2e | 2010-09-22 17:16:18 +0000 | [diff] [blame] | 2085 | ew32(FEXTNVM4, mac_reg); |
Bruce Allan | 0ed013e | 2011-07-29 05:52:56 +0000 | [diff] [blame] | 2086 | ret_val = e1e_wphy(hw, I82579_LPI_CTRL, phy_reg); |
Bruce Allan | 831bd2e | 2010-09-22 17:16:18 +0000 | [diff] [blame] | 2087 | } |
| 2088 | |
Bruce Allan | 831bd2e | 2010-09-22 17:16:18 +0000 | [diff] [blame] | 2089 | return ret_val; |
| 2090 | } |
| 2091 | |
| 2092 | /** |
Bruce Allan | 605c82b | 2010-09-22 17:17:01 +0000 | [diff] [blame] | 2093 | * e1000_gate_hw_phy_config_ich8lan - disable PHY config via hardware |
| 2094 | * @hw: pointer to the HW structure |
| 2095 | * @gate: boolean set to true to gate, false to ungate |
| 2096 | * |
| 2097 | * Gate/ungate the automatic PHY configuration via hardware; perform |
| 2098 | * the configuration via software instead. |
| 2099 | **/ |
| 2100 | static void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate) |
| 2101 | { |
| 2102 | u32 extcnf_ctrl; |
| 2103 | |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 2104 | if (hw->mac.type < e1000_pch2lan) |
Bruce Allan | 605c82b | 2010-09-22 17:17:01 +0000 | [diff] [blame] | 2105 | return; |
| 2106 | |
| 2107 | extcnf_ctrl = er32(EXTCNF_CTRL); |
| 2108 | |
| 2109 | if (gate) |
| 2110 | extcnf_ctrl |= E1000_EXTCNF_CTRL_GATE_PHY_CFG; |
| 2111 | else |
| 2112 | extcnf_ctrl &= ~E1000_EXTCNF_CTRL_GATE_PHY_CFG; |
| 2113 | |
| 2114 | ew32(EXTCNF_CTRL, extcnf_ctrl); |
Bruce Allan | 605c82b | 2010-09-22 17:17:01 +0000 | [diff] [blame] | 2115 | } |
| 2116 | |
| 2117 | /** |
Bruce Allan | fc0c776 | 2009-07-01 13:27:55 +0000 | [diff] [blame] | 2118 | * e1000_lan_init_done_ich8lan - Check for PHY config completion |
| 2119 | * @hw: pointer to the HW structure |
| 2120 | * |
| 2121 | * Check the appropriate indication the MAC has finished configuring the |
| 2122 | * PHY after a software reset. |
| 2123 | **/ |
| 2124 | static void e1000_lan_init_done_ich8lan(struct e1000_hw *hw) |
| 2125 | { |
| 2126 | u32 data, loop = E1000_ICH8_LAN_INIT_TIMEOUT; |
| 2127 | |
| 2128 | /* Wait for basic configuration completes before proceeding */ |
| 2129 | do { |
| 2130 | data = er32(STATUS); |
| 2131 | data &= E1000_STATUS_LAN_INIT_DONE; |
Bruce Allan | ce43a21 | 2013-02-20 04:06:32 +0000 | [diff] [blame] | 2132 | usleep_range(100, 200); |
Bruce Allan | fc0c776 | 2009-07-01 13:27:55 +0000 | [diff] [blame] | 2133 | } while ((!data) && --loop); |
| 2134 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2135 | /* If basic configuration is incomplete before the above loop |
Bruce Allan | fc0c776 | 2009-07-01 13:27:55 +0000 | [diff] [blame] | 2136 | * count reaches 0, loading the configuration from NVM will |
| 2137 | * leave the PHY in a bad state possibly resulting in no link. |
| 2138 | */ |
| 2139 | if (loop == 0) |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 2140 | e_dbg("LAN_INIT_DONE not set, increase timeout\n"); |
Bruce Allan | fc0c776 | 2009-07-01 13:27:55 +0000 | [diff] [blame] | 2141 | |
| 2142 | /* Clear the Init Done bit for the next init event */ |
| 2143 | data = er32(STATUS); |
| 2144 | data &= ~E1000_STATUS_LAN_INIT_DONE; |
| 2145 | ew32(STATUS, data); |
| 2146 | } |
| 2147 | |
| 2148 | /** |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 2149 | * e1000_post_phy_reset_ich8lan - Perform steps required after a PHY reset |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2150 | * @hw: pointer to the HW structure |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2151 | **/ |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 2152 | static s32 e1000_post_phy_reset_ich8lan(struct e1000_hw *hw) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2153 | { |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 2154 | s32 ret_val = 0; |
| 2155 | u16 reg; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2156 | |
Bruce Allan | 44abd5c | 2012-02-22 09:02:37 +0000 | [diff] [blame] | 2157 | if (hw->phy.ops.check_reset_block(hw)) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 2158 | return 0; |
Bruce Allan | fc0c776 | 2009-07-01 13:27:55 +0000 | [diff] [blame] | 2159 | |
Bruce Allan | 5f3eed6 | 2010-09-22 17:15:54 +0000 | [diff] [blame] | 2160 | /* Allow time for h/w to get to quiescent state after reset */ |
Bruce Allan | 1bba438 | 2011-03-19 00:27:20 +0000 | [diff] [blame] | 2161 | usleep_range(10000, 20000); |
Bruce Allan | 5f3eed6 | 2010-09-22 17:15:54 +0000 | [diff] [blame] | 2162 | |
Bruce Allan | fddaa1a | 2010-01-13 01:52:49 +0000 | [diff] [blame] | 2163 | /* Perform any necessary post-reset workarounds */ |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 2164 | switch (hw->mac.type) { |
| 2165 | case e1000_pchlan: |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 2166 | ret_val = e1000_hv_phy_workarounds_ich8lan(hw); |
| 2167 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 2168 | return ret_val; |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 2169 | break; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 2170 | case e1000_pch2lan: |
| 2171 | ret_val = e1000_lv_phy_workarounds_ich8lan(hw); |
| 2172 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 2173 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 2174 | break; |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 2175 | default: |
| 2176 | break; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 2177 | } |
| 2178 | |
Bruce Allan | 3ebfc7c | 2011-05-13 07:20:14 +0000 | [diff] [blame] | 2179 | /* Clear the host wakeup bit after lcd reset */ |
| 2180 | if (hw->mac.type >= e1000_pchlan) { |
| 2181 | e1e_rphy(hw, BM_PORT_GEN_CFG, ®); |
| 2182 | reg &= ~BM_WUC_HOST_WU_BIT; |
| 2183 | e1e_wphy(hw, BM_PORT_GEN_CFG, reg); |
| 2184 | } |
Bruce Allan | db2932e | 2009-10-26 11:22:47 +0000 | [diff] [blame] | 2185 | |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 2186 | /* Configure the LCD with the extended configuration region in NVM */ |
| 2187 | ret_val = e1000_sw_lcd_config_ich8lan(hw); |
| 2188 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 2189 | return ret_val; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2190 | |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 2191 | /* Configure the LCD with the OEM bits in NVM */ |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 2192 | ret_val = e1000_oem_bits_config_ich8lan(hw, true); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2193 | |
Bruce Allan | 1effb45 | 2011-02-25 06:58:03 +0000 | [diff] [blame] | 2194 | if (hw->mac.type == e1000_pch2lan) { |
| 2195 | /* Ungate automatic PHY configuration on non-managed 82579 */ |
| 2196 | if (!(er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) { |
Bruce Allan | 1bba438 | 2011-03-19 00:27:20 +0000 | [diff] [blame] | 2197 | usleep_range(10000, 20000); |
Bruce Allan | 1effb45 | 2011-02-25 06:58:03 +0000 | [diff] [blame] | 2198 | e1000_gate_hw_phy_config_ich8lan(hw, false); |
| 2199 | } |
| 2200 | |
| 2201 | /* Set EEE LPI Update Timer to 200usec */ |
| 2202 | ret_val = hw->phy.ops.acquire(hw); |
| 2203 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 2204 | return ret_val; |
Bruce Allan | 4ddc48a | 2012-12-05 06:25:58 +0000 | [diff] [blame] | 2205 | ret_val = e1000_write_emi_reg_locked(hw, |
| 2206 | I82579_LPI_UPDATE_TIMER, |
| 2207 | 0x1387); |
Bruce Allan | 1effb45 | 2011-02-25 06:58:03 +0000 | [diff] [blame] | 2208 | hw->phy.ops.release(hw); |
Bruce Allan | 605c82b | 2010-09-22 17:17:01 +0000 | [diff] [blame] | 2209 | } |
| 2210 | |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 2211 | return ret_val; |
| 2212 | } |
| 2213 | |
| 2214 | /** |
| 2215 | * e1000_phy_hw_reset_ich8lan - Performs a PHY reset |
| 2216 | * @hw: pointer to the HW structure |
| 2217 | * |
| 2218 | * Resets the PHY |
| 2219 | * This is a function pointer entry point called by drivers |
| 2220 | * or other shared routines. |
| 2221 | **/ |
| 2222 | static s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw) |
| 2223 | { |
| 2224 | s32 ret_val = 0; |
| 2225 | |
Bruce Allan | 605c82b | 2010-09-22 17:17:01 +0000 | [diff] [blame] | 2226 | /* Gate automatic PHY configuration by hardware on non-managed 82579 */ |
| 2227 | if ((hw->mac.type == e1000_pch2lan) && |
| 2228 | !(er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) |
| 2229 | e1000_gate_hw_phy_config_ich8lan(hw, true); |
| 2230 | |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 2231 | ret_val = e1000e_phy_hw_reset_generic(hw); |
| 2232 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 2233 | return ret_val; |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 2234 | |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 2235 | return e1000_post_phy_reset_ich8lan(hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2236 | } |
| 2237 | |
| 2238 | /** |
Bruce Allan | fa2ce13 | 2009-10-26 11:23:25 +0000 | [diff] [blame] | 2239 | * e1000_set_lplu_state_pchlan - Set Low Power Link Up state |
| 2240 | * @hw: pointer to the HW structure |
| 2241 | * @active: true to enable LPLU, false to disable |
| 2242 | * |
| 2243 | * Sets the LPLU state according to the active flag. For PCH, if OEM write |
| 2244 | * bit are disabled in the NVM, writing the LPLU bits in the MAC will not set |
| 2245 | * the phy speed. This function will manually set the LPLU bit and restart |
| 2246 | * auto-neg as hw would do. D3 and D0 LPLU will call the same function |
| 2247 | * since it configures the same bit. |
| 2248 | **/ |
| 2249 | static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active) |
| 2250 | { |
Bruce Allan | 70806a7 | 2013-01-05 05:08:37 +0000 | [diff] [blame] | 2251 | s32 ret_val; |
Bruce Allan | fa2ce13 | 2009-10-26 11:23:25 +0000 | [diff] [blame] | 2252 | u16 oem_reg; |
| 2253 | |
| 2254 | ret_val = e1e_rphy(hw, HV_OEM_BITS, &oem_reg); |
| 2255 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 2256 | return ret_val; |
Bruce Allan | fa2ce13 | 2009-10-26 11:23:25 +0000 | [diff] [blame] | 2257 | |
| 2258 | if (active) |
| 2259 | oem_reg |= HV_OEM_BITS_LPLU; |
| 2260 | else |
| 2261 | oem_reg &= ~HV_OEM_BITS_LPLU; |
| 2262 | |
Bruce Allan | 44abd5c | 2012-02-22 09:02:37 +0000 | [diff] [blame] | 2263 | if (!hw->phy.ops.check_reset_block(hw)) |
Bruce Allan | 464c85e | 2011-12-16 00:46:49 +0000 | [diff] [blame] | 2264 | oem_reg |= HV_OEM_BITS_RESTART_AN; |
| 2265 | |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 2266 | return e1e_wphy(hw, HV_OEM_BITS, oem_reg); |
Bruce Allan | fa2ce13 | 2009-10-26 11:23:25 +0000 | [diff] [blame] | 2267 | } |
| 2268 | |
| 2269 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2270 | * e1000_set_d0_lplu_state_ich8lan - Set Low Power Linkup D0 state |
| 2271 | * @hw: pointer to the HW structure |
Bruce Allan | 564ea9b | 2009-11-20 23:26:44 +0000 | [diff] [blame] | 2272 | * @active: true to enable LPLU, false to disable |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2273 | * |
| 2274 | * Sets the LPLU D0 state according to the active flag. When |
| 2275 | * activating LPLU this function also disables smart speed |
| 2276 | * and vice versa. LPLU will not be activated unless the |
| 2277 | * device autonegotiation advertisement meets standards of |
| 2278 | * either 10 or 10/100 or 10/100/1000 at all duplexes. |
| 2279 | * This is a function pointer entry point only called by |
| 2280 | * PHY setup routines. |
| 2281 | **/ |
| 2282 | static s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw, bool active) |
| 2283 | { |
| 2284 | struct e1000_phy_info *phy = &hw->phy; |
| 2285 | u32 phy_ctrl; |
| 2286 | s32 ret_val = 0; |
| 2287 | u16 data; |
| 2288 | |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 2289 | if (phy->type == e1000_phy_ife) |
Bruce Allan | 8260725 | 2012-02-08 02:55:09 +0000 | [diff] [blame] | 2290 | return 0; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2291 | |
| 2292 | phy_ctrl = er32(PHY_CTRL); |
| 2293 | |
| 2294 | if (active) { |
| 2295 | phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU; |
| 2296 | ew32(PHY_CTRL, phy_ctrl); |
| 2297 | |
Bruce Allan | 60f1292 | 2009-07-01 13:28:14 +0000 | [diff] [blame] | 2298 | if (phy->type != e1000_phy_igp_3) |
| 2299 | return 0; |
| 2300 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2301 | /* Call gig speed drop workaround on LPLU before accessing |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2302 | * any PHY registers |
| 2303 | */ |
Bruce Allan | 60f1292 | 2009-07-01 13:28:14 +0000 | [diff] [blame] | 2304 | if (hw->mac.type == e1000_ich8lan) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2305 | e1000e_gig_downshift_workaround_ich8lan(hw); |
| 2306 | |
| 2307 | /* When LPLU is enabled, we should disable SmartSpeed */ |
| 2308 | ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data); |
Bruce Allan | 7dbbe5d | 2013-01-05 05:08:31 +0000 | [diff] [blame] | 2309 | if (ret_val) |
| 2310 | return ret_val; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2311 | data &= ~IGP01E1000_PSCFR_SMART_SPEED; |
| 2312 | ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data); |
| 2313 | if (ret_val) |
| 2314 | return ret_val; |
| 2315 | } else { |
| 2316 | phy_ctrl &= ~E1000_PHY_CTRL_D0A_LPLU; |
| 2317 | ew32(PHY_CTRL, phy_ctrl); |
| 2318 | |
Bruce Allan | 60f1292 | 2009-07-01 13:28:14 +0000 | [diff] [blame] | 2319 | if (phy->type != e1000_phy_igp_3) |
| 2320 | return 0; |
| 2321 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2322 | /* LPLU and SmartSpeed are mutually exclusive. LPLU is used |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2323 | * during Dx states where the power conservation is most |
| 2324 | * important. During driver activity we should enable |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2325 | * SmartSpeed, so performance is maintained. |
| 2326 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2327 | if (phy->smart_speed == e1000_smart_speed_on) { |
| 2328 | ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2329 | &data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2330 | if (ret_val) |
| 2331 | return ret_val; |
| 2332 | |
| 2333 | data |= IGP01E1000_PSCFR_SMART_SPEED; |
| 2334 | ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2335 | data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2336 | if (ret_val) |
| 2337 | return ret_val; |
| 2338 | } else if (phy->smart_speed == e1000_smart_speed_off) { |
| 2339 | ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2340 | &data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2341 | if (ret_val) |
| 2342 | return ret_val; |
| 2343 | |
| 2344 | data &= ~IGP01E1000_PSCFR_SMART_SPEED; |
| 2345 | ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2346 | data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2347 | if (ret_val) |
| 2348 | return ret_val; |
| 2349 | } |
| 2350 | } |
| 2351 | |
| 2352 | return 0; |
| 2353 | } |
| 2354 | |
| 2355 | /** |
| 2356 | * e1000_set_d3_lplu_state_ich8lan - Set Low Power Linkup D3 state |
| 2357 | * @hw: pointer to the HW structure |
Bruce Allan | 564ea9b | 2009-11-20 23:26:44 +0000 | [diff] [blame] | 2358 | * @active: true to enable LPLU, false to disable |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2359 | * |
| 2360 | * Sets the LPLU D3 state according to the active flag. When |
| 2361 | * activating LPLU this function also disables smart speed |
| 2362 | * and vice versa. LPLU will not be activated unless the |
| 2363 | * device autonegotiation advertisement meets standards of |
| 2364 | * either 10 or 10/100 or 10/100/1000 at all duplexes. |
| 2365 | * This is a function pointer entry point only called by |
| 2366 | * PHY setup routines. |
| 2367 | **/ |
| 2368 | static s32 e1000_set_d3_lplu_state_ich8lan(struct e1000_hw *hw, bool active) |
| 2369 | { |
| 2370 | struct e1000_phy_info *phy = &hw->phy; |
| 2371 | u32 phy_ctrl; |
Bruce Allan | d7eb338 | 2012-02-08 02:55:14 +0000 | [diff] [blame] | 2372 | s32 ret_val = 0; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2373 | u16 data; |
| 2374 | |
| 2375 | phy_ctrl = er32(PHY_CTRL); |
| 2376 | |
| 2377 | if (!active) { |
| 2378 | phy_ctrl &= ~E1000_PHY_CTRL_NOND0A_LPLU; |
| 2379 | ew32(PHY_CTRL, phy_ctrl); |
Bruce Allan | 60f1292 | 2009-07-01 13:28:14 +0000 | [diff] [blame] | 2380 | |
| 2381 | if (phy->type != e1000_phy_igp_3) |
| 2382 | return 0; |
| 2383 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2384 | /* LPLU and SmartSpeed are mutually exclusive. LPLU is used |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2385 | * during Dx states where the power conservation is most |
| 2386 | * important. During driver activity we should enable |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2387 | * SmartSpeed, so performance is maintained. |
| 2388 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2389 | if (phy->smart_speed == e1000_smart_speed_on) { |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2390 | ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, |
| 2391 | &data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2392 | if (ret_val) |
| 2393 | return ret_val; |
| 2394 | |
| 2395 | data |= IGP01E1000_PSCFR_SMART_SPEED; |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2396 | ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, |
| 2397 | data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2398 | if (ret_val) |
| 2399 | return ret_val; |
| 2400 | } else if (phy->smart_speed == e1000_smart_speed_off) { |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2401 | ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, |
| 2402 | &data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2403 | if (ret_val) |
| 2404 | return ret_val; |
| 2405 | |
| 2406 | data &= ~IGP01E1000_PSCFR_SMART_SPEED; |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2407 | ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, |
| 2408 | data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2409 | if (ret_val) |
| 2410 | return ret_val; |
| 2411 | } |
| 2412 | } else if ((phy->autoneg_advertised == E1000_ALL_SPEED_DUPLEX) || |
| 2413 | (phy->autoneg_advertised == E1000_ALL_NOT_GIG) || |
| 2414 | (phy->autoneg_advertised == E1000_ALL_10_SPEED)) { |
| 2415 | phy_ctrl |= E1000_PHY_CTRL_NOND0A_LPLU; |
| 2416 | ew32(PHY_CTRL, phy_ctrl); |
| 2417 | |
Bruce Allan | 60f1292 | 2009-07-01 13:28:14 +0000 | [diff] [blame] | 2418 | if (phy->type != e1000_phy_igp_3) |
| 2419 | return 0; |
| 2420 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2421 | /* Call gig speed drop workaround on LPLU before accessing |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2422 | * any PHY registers |
| 2423 | */ |
Bruce Allan | 60f1292 | 2009-07-01 13:28:14 +0000 | [diff] [blame] | 2424 | if (hw->mac.type == e1000_ich8lan) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2425 | e1000e_gig_downshift_workaround_ich8lan(hw); |
| 2426 | |
| 2427 | /* When LPLU is enabled, we should disable SmartSpeed */ |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2428 | ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2429 | if (ret_val) |
| 2430 | return ret_val; |
| 2431 | |
| 2432 | data &= ~IGP01E1000_PSCFR_SMART_SPEED; |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2433 | ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2434 | } |
| 2435 | |
Bruce Allan | d7eb338 | 2012-02-08 02:55:14 +0000 | [diff] [blame] | 2436 | return ret_val; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2437 | } |
| 2438 | |
| 2439 | /** |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 2440 | * e1000_valid_nvm_bank_detect_ich8lan - finds out the valid bank 0 or 1 |
| 2441 | * @hw: pointer to the HW structure |
| 2442 | * @bank: pointer to the variable that returns the active bank |
| 2443 | * |
| 2444 | * Reads signature byte from the NVM using the flash access registers. |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2445 | * Word 0x13 bits 15:14 = 10b indicate a valid signature for that bank. |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 2446 | **/ |
| 2447 | static s32 e1000_valid_nvm_bank_detect_ich8lan(struct e1000_hw *hw, u32 *bank) |
| 2448 | { |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2449 | u32 eecd; |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 2450 | struct e1000_nvm_info *nvm = &hw->nvm; |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 2451 | u32 bank1_offset = nvm->flash_bank_size * sizeof(u16); |
| 2452 | u32 act_offset = E1000_ICH_NVM_SIG_WORD * 2 + 1; |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2453 | u8 sig_byte = 0; |
Bruce Allan | f71dde6 | 2012-02-08 02:55:35 +0000 | [diff] [blame] | 2454 | s32 ret_val; |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 2455 | |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2456 | switch (hw->mac.type) { |
| 2457 | case e1000_ich8lan: |
| 2458 | case e1000_ich9lan: |
| 2459 | eecd = er32(EECD); |
| 2460 | if ((eecd & E1000_EECD_SEC1VAL_VALID_MASK) == |
| 2461 | E1000_EECD_SEC1VAL_VALID_MASK) { |
| 2462 | if (eecd & E1000_EECD_SEC1VAL) |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 2463 | *bank = 1; |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2464 | else |
| 2465 | *bank = 0; |
| 2466 | |
| 2467 | return 0; |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 2468 | } |
Bruce Allan | 434f139 | 2011-12-16 00:46:54 +0000 | [diff] [blame] | 2469 | e_dbg("Unable to determine valid NVM bank via EEC - reading flash signature\n"); |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2470 | /* fall-thru */ |
| 2471 | default: |
| 2472 | /* set bank to 0 in case flash read fails */ |
| 2473 | *bank = 0; |
| 2474 | |
| 2475 | /* Check bank 0 */ |
| 2476 | ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset, |
Bruce Allan | f0ff439 | 2013-02-20 04:05:39 +0000 | [diff] [blame] | 2477 | &sig_byte); |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2478 | if (ret_val) |
| 2479 | return ret_val; |
| 2480 | if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) == |
| 2481 | E1000_ICH_NVM_SIG_VALUE) { |
| 2482 | *bank = 0; |
| 2483 | return 0; |
| 2484 | } |
| 2485 | |
| 2486 | /* Check bank 1 */ |
| 2487 | ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset + |
Bruce Allan | f0ff439 | 2013-02-20 04:05:39 +0000 | [diff] [blame] | 2488 | bank1_offset, |
| 2489 | &sig_byte); |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2490 | if (ret_val) |
| 2491 | return ret_val; |
| 2492 | if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) == |
| 2493 | E1000_ICH_NVM_SIG_VALUE) { |
| 2494 | *bank = 1; |
| 2495 | return 0; |
| 2496 | } |
| 2497 | |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 2498 | e_dbg("ERROR: No valid NVM bank present\n"); |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2499 | return -E1000_ERR_NVM; |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 2500 | } |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 2501 | } |
| 2502 | |
| 2503 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2504 | * e1000_read_nvm_ich8lan - Read word(s) from the NVM |
| 2505 | * @hw: pointer to the HW structure |
| 2506 | * @offset: The offset (in bytes) of the word(s) to read. |
| 2507 | * @words: Size of data to read in words |
| 2508 | * @data: Pointer to the word(s) to read at offset. |
| 2509 | * |
| 2510 | * Reads a word(s) from the NVM using the flash access registers. |
| 2511 | **/ |
| 2512 | static s32 e1000_read_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words, |
| 2513 | u16 *data) |
| 2514 | { |
| 2515 | struct e1000_nvm_info *nvm = &hw->nvm; |
| 2516 | struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; |
| 2517 | u32 act_offset; |
Bruce Allan | 148675a | 2009-08-07 07:41:56 +0000 | [diff] [blame] | 2518 | s32 ret_val = 0; |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 2519 | u32 bank = 0; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2520 | u16 i, word; |
| 2521 | |
| 2522 | if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) || |
| 2523 | (words == 0)) { |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 2524 | e_dbg("nvm parameter(s) out of bounds\n"); |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 2525 | ret_val = -E1000_ERR_NVM; |
| 2526 | goto out; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2527 | } |
| 2528 | |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 2529 | nvm->ops.acquire(hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2530 | |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 2531 | ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank); |
Bruce Allan | 148675a | 2009-08-07 07:41:56 +0000 | [diff] [blame] | 2532 | if (ret_val) { |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 2533 | e_dbg("Could not detect valid bank, assuming bank 0\n"); |
Bruce Allan | 148675a | 2009-08-07 07:41:56 +0000 | [diff] [blame] | 2534 | bank = 0; |
| 2535 | } |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 2536 | |
| 2537 | act_offset = (bank) ? nvm->flash_bank_size : 0; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2538 | act_offset += offset; |
| 2539 | |
Bruce Allan | 148675a | 2009-08-07 07:41:56 +0000 | [diff] [blame] | 2540 | ret_val = 0; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2541 | for (i = 0; i < words; i++) { |
Bruce Allan | 362e20c | 2013-02-20 04:05:45 +0000 | [diff] [blame] | 2542 | if (dev_spec->shadow_ram[offset + i].modified) { |
| 2543 | data[i] = dev_spec->shadow_ram[offset + i].value; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2544 | } else { |
| 2545 | ret_val = e1000_read_flash_word_ich8lan(hw, |
| 2546 | act_offset + i, |
| 2547 | &word); |
| 2548 | if (ret_val) |
| 2549 | break; |
| 2550 | data[i] = word; |
| 2551 | } |
| 2552 | } |
| 2553 | |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 2554 | nvm->ops.release(hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2555 | |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2556 | out: |
| 2557 | if (ret_val) |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 2558 | e_dbg("NVM read error: %d\n", ret_val); |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2559 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2560 | return ret_val; |
| 2561 | } |
| 2562 | |
| 2563 | /** |
| 2564 | * e1000_flash_cycle_init_ich8lan - Initialize flash |
| 2565 | * @hw: pointer to the HW structure |
| 2566 | * |
| 2567 | * This function does initial flash setup so that a new read/write/erase cycle |
| 2568 | * can be started. |
| 2569 | **/ |
| 2570 | static s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw) |
| 2571 | { |
| 2572 | union ich8_hws_flash_status hsfsts; |
| 2573 | s32 ret_val = -E1000_ERR_NVM; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2574 | |
| 2575 | hsfsts.regval = er16flash(ICH_FLASH_HSFSTS); |
| 2576 | |
| 2577 | /* Check if the flash descriptor is valid */ |
Bruce Allan | 04499ec | 2012-04-13 00:08:31 +0000 | [diff] [blame] | 2578 | if (!hsfsts.hsf_status.fldesvalid) { |
Bruce Allan | 434f139 | 2011-12-16 00:46:54 +0000 | [diff] [blame] | 2579 | e_dbg("Flash descriptor invalid. SW Sequencing must be used.\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2580 | return -E1000_ERR_NVM; |
| 2581 | } |
| 2582 | |
| 2583 | /* Clear FCERR and DAEL in hw status by writing 1 */ |
| 2584 | hsfsts.hsf_status.flcerr = 1; |
| 2585 | hsfsts.hsf_status.dael = 1; |
| 2586 | |
| 2587 | ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval); |
| 2588 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2589 | /* Either we should have a hardware SPI cycle in progress |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2590 | * bit to check against, in order to start a new cycle or |
| 2591 | * FDONE bit should be changed in the hardware so that it |
Auke Kok | 489815c | 2008-02-21 15:11:07 -0800 | [diff] [blame] | 2592 | * is 1 after hardware reset, which can then be used as an |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2593 | * indication whether a cycle is in progress or has been |
| 2594 | * completed. |
| 2595 | */ |
| 2596 | |
Bruce Allan | 04499ec | 2012-04-13 00:08:31 +0000 | [diff] [blame] | 2597 | if (!hsfsts.hsf_status.flcinprog) { |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2598 | /* There is no cycle running at present, |
Bruce Allan | 5ff5b66 | 2009-12-01 15:51:11 +0000 | [diff] [blame] | 2599 | * so we can start a cycle. |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2600 | * Begin by setting Flash Cycle Done. |
| 2601 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2602 | hsfsts.hsf_status.flcdone = 1; |
| 2603 | ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval); |
| 2604 | ret_val = 0; |
| 2605 | } else { |
Bruce Allan | f71dde6 | 2012-02-08 02:55:35 +0000 | [diff] [blame] | 2606 | s32 i; |
Bruce Allan | 90da066 | 2011-01-06 07:02:53 +0000 | [diff] [blame] | 2607 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2608 | /* Otherwise poll for sometime so the current |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2609 | * cycle has a chance to end before giving up. |
| 2610 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2611 | for (i = 0; i < ICH_FLASH_READ_COMMAND_TIMEOUT; i++) { |
Bruce Allan | c8243ee | 2011-12-17 08:32:57 +0000 | [diff] [blame] | 2612 | hsfsts.regval = er16flash(ICH_FLASH_HSFSTS); |
Bruce Allan | 04499ec | 2012-04-13 00:08:31 +0000 | [diff] [blame] | 2613 | if (!hsfsts.hsf_status.flcinprog) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2614 | ret_val = 0; |
| 2615 | break; |
| 2616 | } |
| 2617 | udelay(1); |
| 2618 | } |
Bruce Allan | 9e2d765 | 2012-01-31 06:37:27 +0000 | [diff] [blame] | 2619 | if (!ret_val) { |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2620 | /* Successful in waiting for previous cycle to timeout, |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2621 | * now set the Flash Cycle Done. |
| 2622 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2623 | hsfsts.hsf_status.flcdone = 1; |
| 2624 | ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval); |
| 2625 | } else { |
Joe Perches | 2c73e1f | 2010-03-26 20:16:59 +0000 | [diff] [blame] | 2626 | e_dbg("Flash controller busy, cannot get access\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2627 | } |
| 2628 | } |
| 2629 | |
| 2630 | return ret_val; |
| 2631 | } |
| 2632 | |
| 2633 | /** |
| 2634 | * e1000_flash_cycle_ich8lan - Starts flash cycle (read/write/erase) |
| 2635 | * @hw: pointer to the HW structure |
| 2636 | * @timeout: maximum time to wait for completion |
| 2637 | * |
| 2638 | * This function starts a flash cycle and waits for its completion. |
| 2639 | **/ |
| 2640 | static s32 e1000_flash_cycle_ich8lan(struct e1000_hw *hw, u32 timeout) |
| 2641 | { |
| 2642 | union ich8_hws_flash_ctrl hsflctl; |
| 2643 | union ich8_hws_flash_status hsfsts; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2644 | u32 i = 0; |
| 2645 | |
| 2646 | /* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */ |
| 2647 | hsflctl.regval = er16flash(ICH_FLASH_HSFCTL); |
| 2648 | hsflctl.hsf_ctrl.flcgo = 1; |
| 2649 | ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval); |
| 2650 | |
| 2651 | /* wait till FDONE bit is set to 1 */ |
| 2652 | do { |
| 2653 | hsfsts.regval = er16flash(ICH_FLASH_HSFSTS); |
Bruce Allan | 04499ec | 2012-04-13 00:08:31 +0000 | [diff] [blame] | 2654 | if (hsfsts.hsf_status.flcdone) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2655 | break; |
| 2656 | udelay(1); |
| 2657 | } while (i++ < timeout); |
| 2658 | |
Bruce Allan | 04499ec | 2012-04-13 00:08:31 +0000 | [diff] [blame] | 2659 | if (hsfsts.hsf_status.flcdone && !hsfsts.hsf_status.flcerr) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2660 | return 0; |
| 2661 | |
Bruce Allan | 55920b5 | 2012-02-08 02:55:25 +0000 | [diff] [blame] | 2662 | return -E1000_ERR_NVM; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2663 | } |
| 2664 | |
| 2665 | /** |
| 2666 | * e1000_read_flash_word_ich8lan - Read word from flash |
| 2667 | * @hw: pointer to the HW structure |
| 2668 | * @offset: offset to data location |
| 2669 | * @data: pointer to the location for storing the data |
| 2670 | * |
| 2671 | * Reads the flash word at offset into data. Offset is converted |
| 2672 | * to bytes before read. |
| 2673 | **/ |
| 2674 | static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset, |
| 2675 | u16 *data) |
| 2676 | { |
| 2677 | /* Must convert offset into bytes. */ |
| 2678 | offset <<= 1; |
| 2679 | |
| 2680 | return e1000_read_flash_data_ich8lan(hw, offset, 2, data); |
| 2681 | } |
| 2682 | |
| 2683 | /** |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 2684 | * e1000_read_flash_byte_ich8lan - Read byte from flash |
| 2685 | * @hw: pointer to the HW structure |
| 2686 | * @offset: The offset of the byte to read. |
| 2687 | * @data: Pointer to a byte to store the value read. |
| 2688 | * |
| 2689 | * Reads a single byte from the NVM using the flash access registers. |
| 2690 | **/ |
| 2691 | static s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset, |
| 2692 | u8 *data) |
| 2693 | { |
| 2694 | s32 ret_val; |
| 2695 | u16 word = 0; |
| 2696 | |
| 2697 | ret_val = e1000_read_flash_data_ich8lan(hw, offset, 1, &word); |
| 2698 | if (ret_val) |
| 2699 | return ret_val; |
| 2700 | |
| 2701 | *data = (u8)word; |
| 2702 | |
| 2703 | return 0; |
| 2704 | } |
| 2705 | |
| 2706 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2707 | * e1000_read_flash_data_ich8lan - Read byte or word from NVM |
| 2708 | * @hw: pointer to the HW structure |
| 2709 | * @offset: The offset (in bytes) of the byte or word to read. |
| 2710 | * @size: Size of data to read, 1=byte 2=word |
| 2711 | * @data: Pointer to the word to store the value read. |
| 2712 | * |
| 2713 | * Reads a byte or word from the NVM using the flash access registers. |
| 2714 | **/ |
| 2715 | static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset, |
| 2716 | u8 size, u16 *data) |
| 2717 | { |
| 2718 | union ich8_hws_flash_status hsfsts; |
| 2719 | union ich8_hws_flash_ctrl hsflctl; |
| 2720 | u32 flash_linear_addr; |
| 2721 | u32 flash_data = 0; |
| 2722 | s32 ret_val = -E1000_ERR_NVM; |
| 2723 | u8 count = 0; |
| 2724 | |
| 2725 | if (size < 1 || size > 2 || offset > ICH_FLASH_LINEAR_ADDR_MASK) |
| 2726 | return -E1000_ERR_NVM; |
| 2727 | |
Bruce Allan | f0ff439 | 2013-02-20 04:05:39 +0000 | [diff] [blame] | 2728 | flash_linear_addr = ((ICH_FLASH_LINEAR_ADDR_MASK & offset) + |
| 2729 | hw->nvm.flash_base_addr); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2730 | |
| 2731 | do { |
| 2732 | udelay(1); |
| 2733 | /* Steps */ |
| 2734 | ret_val = e1000_flash_cycle_init_ich8lan(hw); |
Bruce Allan | 9e2d765 | 2012-01-31 06:37:27 +0000 | [diff] [blame] | 2735 | if (ret_val) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2736 | break; |
| 2737 | |
| 2738 | hsflctl.regval = er16flash(ICH_FLASH_HSFCTL); |
| 2739 | /* 0b/1b corresponds to 1 or 2 byte size, respectively. */ |
| 2740 | hsflctl.hsf_ctrl.fldbcount = size - 1; |
| 2741 | hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_READ; |
| 2742 | ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval); |
| 2743 | |
| 2744 | ew32flash(ICH_FLASH_FADDR, flash_linear_addr); |
| 2745 | |
Bruce Allan | 17e813e | 2013-02-20 04:06:01 +0000 | [diff] [blame] | 2746 | ret_val = |
| 2747 | e1000_flash_cycle_ich8lan(hw, |
| 2748 | ICH_FLASH_READ_COMMAND_TIMEOUT); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2749 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2750 | /* Check if FCERR is set to 1, if set to 1, clear it |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2751 | * and try the whole sequence a few more times, else |
| 2752 | * read in (shift in) the Flash Data0, the order is |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2753 | * least significant byte first msb to lsb |
| 2754 | */ |
Bruce Allan | 9e2d765 | 2012-01-31 06:37:27 +0000 | [diff] [blame] | 2755 | if (!ret_val) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2756 | flash_data = er32flash(ICH_FLASH_FDATA0); |
Bruce Allan | b1cdfea | 2010-12-11 05:53:47 +0000 | [diff] [blame] | 2757 | if (size == 1) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2758 | *data = (u8)(flash_data & 0x000000FF); |
Bruce Allan | b1cdfea | 2010-12-11 05:53:47 +0000 | [diff] [blame] | 2759 | else if (size == 2) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2760 | *data = (u16)(flash_data & 0x0000FFFF); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2761 | break; |
| 2762 | } else { |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2763 | /* If we've gotten here, then things are probably |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2764 | * completely hosed, but if the error condition is |
| 2765 | * detected, it won't hurt to give it another try... |
| 2766 | * ICH_FLASH_CYCLE_REPEAT_COUNT times. |
| 2767 | */ |
| 2768 | hsfsts.regval = er16flash(ICH_FLASH_HSFSTS); |
Bruce Allan | 04499ec | 2012-04-13 00:08:31 +0000 | [diff] [blame] | 2769 | if (hsfsts.hsf_status.flcerr) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2770 | /* Repeat for some time before giving up. */ |
| 2771 | continue; |
Bruce Allan | 04499ec | 2012-04-13 00:08:31 +0000 | [diff] [blame] | 2772 | } else if (!hsfsts.hsf_status.flcdone) { |
Bruce Allan | 434f139 | 2011-12-16 00:46:54 +0000 | [diff] [blame] | 2773 | e_dbg("Timeout error - flash cycle did not complete.\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2774 | break; |
| 2775 | } |
| 2776 | } |
| 2777 | } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT); |
| 2778 | |
| 2779 | return ret_val; |
| 2780 | } |
| 2781 | |
| 2782 | /** |
| 2783 | * e1000_write_nvm_ich8lan - Write word(s) to the NVM |
| 2784 | * @hw: pointer to the HW structure |
| 2785 | * @offset: The offset (in bytes) of the word(s) to write. |
| 2786 | * @words: Size of data to write in words |
| 2787 | * @data: Pointer to the word(s) to write at offset. |
| 2788 | * |
| 2789 | * Writes a byte or word to the NVM using the flash access registers. |
| 2790 | **/ |
| 2791 | static s32 e1000_write_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words, |
| 2792 | u16 *data) |
| 2793 | { |
| 2794 | struct e1000_nvm_info *nvm = &hw->nvm; |
| 2795 | struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2796 | u16 i; |
| 2797 | |
| 2798 | if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) || |
| 2799 | (words == 0)) { |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 2800 | e_dbg("nvm parameter(s) out of bounds\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2801 | return -E1000_ERR_NVM; |
| 2802 | } |
| 2803 | |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 2804 | nvm->ops.acquire(hw); |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 2805 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2806 | for (i = 0; i < words; i++) { |
Bruce Allan | 362e20c | 2013-02-20 04:05:45 +0000 | [diff] [blame] | 2807 | dev_spec->shadow_ram[offset + i].modified = true; |
| 2808 | dev_spec->shadow_ram[offset + i].value = data[i]; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2809 | } |
| 2810 | |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 2811 | nvm->ops.release(hw); |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 2812 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2813 | return 0; |
| 2814 | } |
| 2815 | |
| 2816 | /** |
| 2817 | * e1000_update_nvm_checksum_ich8lan - Update the checksum for NVM |
| 2818 | * @hw: pointer to the HW structure |
| 2819 | * |
| 2820 | * The NVM checksum is updated by calling the generic update_nvm_checksum, |
| 2821 | * which writes the checksum to the shadow ram. The changes in the shadow |
| 2822 | * ram are then committed to the EEPROM by processing each bank at a time |
| 2823 | * checking for the modified bit and writing only the pending changes. |
Auke Kok | 489815c | 2008-02-21 15:11:07 -0800 | [diff] [blame] | 2824 | * After a successful commit, the shadow ram is cleared and is ready for |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2825 | * future writes. |
| 2826 | **/ |
| 2827 | static s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw) |
| 2828 | { |
| 2829 | struct e1000_nvm_info *nvm = &hw->nvm; |
| 2830 | struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 2831 | u32 i, act_offset, new_bank_offset, old_bank_offset, bank; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2832 | s32 ret_val; |
| 2833 | u16 data; |
| 2834 | |
| 2835 | ret_val = e1000e_update_nvm_checksum_generic(hw); |
| 2836 | if (ret_val) |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2837 | goto out; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2838 | |
| 2839 | if (nvm->type != e1000_nvm_flash_sw) |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2840 | goto out; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2841 | |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 2842 | nvm->ops.acquire(hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2843 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2844 | /* We're writing to the opposite bank so if we're on bank 1, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2845 | * write to bank 0 etc. We also need to erase the segment that |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2846 | * is going to be written |
| 2847 | */ |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 2848 | ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank); |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2849 | if (ret_val) { |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 2850 | e_dbg("Could not detect valid bank, assuming bank 0\n"); |
Bruce Allan | 148675a | 2009-08-07 07:41:56 +0000 | [diff] [blame] | 2851 | bank = 0; |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2852 | } |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 2853 | |
| 2854 | if (bank == 0) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2855 | new_bank_offset = nvm->flash_bank_size; |
| 2856 | old_bank_offset = 0; |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2857 | ret_val = e1000_erase_flash_bank_ich8lan(hw, 1); |
Bruce Allan | 9c5e209 | 2010-05-10 15:00:31 +0000 | [diff] [blame] | 2858 | if (ret_val) |
| 2859 | goto release; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2860 | } else { |
| 2861 | old_bank_offset = nvm->flash_bank_size; |
| 2862 | new_bank_offset = 0; |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2863 | ret_val = e1000_erase_flash_bank_ich8lan(hw, 0); |
Bruce Allan | 9c5e209 | 2010-05-10 15:00:31 +0000 | [diff] [blame] | 2864 | if (ret_val) |
| 2865 | goto release; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2866 | } |
| 2867 | |
| 2868 | for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i++) { |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2869 | /* Determine whether to write the value stored |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2870 | * in the other NVM bank or a modified value stored |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2871 | * in the shadow RAM |
| 2872 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2873 | if (dev_spec->shadow_ram[i].modified) { |
| 2874 | data = dev_spec->shadow_ram[i].value; |
| 2875 | } else { |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2876 | ret_val = e1000_read_flash_word_ich8lan(hw, i + |
Bruce Allan | f0ff439 | 2013-02-20 04:05:39 +0000 | [diff] [blame] | 2877 | old_bank_offset, |
| 2878 | &data); |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2879 | if (ret_val) |
| 2880 | break; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2881 | } |
| 2882 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2883 | /* If the word is 0x13, then make sure the signature bits |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2884 | * (15:14) are 11b until the commit has completed. |
| 2885 | * This will allow us to write 10b which indicates the |
| 2886 | * signature is valid. We want to do this after the write |
| 2887 | * has completed so that we don't mark the segment valid |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2888 | * while the write is still in progress |
| 2889 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2890 | if (i == E1000_ICH_NVM_SIG_WORD) |
| 2891 | data |= E1000_ICH_NVM_SIG_MASK; |
| 2892 | |
| 2893 | /* Convert offset to bytes. */ |
| 2894 | act_offset = (i + new_bank_offset) << 1; |
| 2895 | |
Bruce Allan | ce43a21 | 2013-02-20 04:06:32 +0000 | [diff] [blame] | 2896 | usleep_range(100, 200); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2897 | /* Write the bytes to the new bank. */ |
| 2898 | ret_val = e1000_retry_write_flash_byte_ich8lan(hw, |
| 2899 | act_offset, |
| 2900 | (u8)data); |
| 2901 | if (ret_val) |
| 2902 | break; |
| 2903 | |
Bruce Allan | ce43a21 | 2013-02-20 04:06:32 +0000 | [diff] [blame] | 2904 | usleep_range(100, 200); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2905 | ret_val = e1000_retry_write_flash_byte_ich8lan(hw, |
Bruce Allan | f0ff439 | 2013-02-20 04:05:39 +0000 | [diff] [blame] | 2906 | act_offset + 1, |
| 2907 | (u8)(data >> 8)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2908 | if (ret_val) |
| 2909 | break; |
| 2910 | } |
| 2911 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2912 | /* Don't bother writing the segment valid bits if sector |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2913 | * programming failed. |
| 2914 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2915 | if (ret_val) { |
Bruce Allan | 4a77035 | 2008-10-01 17:18:35 -0700 | [diff] [blame] | 2916 | /* Possibly read-only, see e1000e_write_protect_nvm_ich8lan() */ |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 2917 | e_dbg("Flash commit failed.\n"); |
Bruce Allan | 9c5e209 | 2010-05-10 15:00:31 +0000 | [diff] [blame] | 2918 | goto release; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2919 | } |
| 2920 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2921 | /* Finally validate the new segment by setting bit 15:14 |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2922 | * to 10b in word 0x13 , this can be done without an |
| 2923 | * erase as well since these bits are 11 to start with |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2924 | * and we need to change bit 14 to 0b |
| 2925 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2926 | act_offset = new_bank_offset + E1000_ICH_NVM_SIG_WORD; |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2927 | ret_val = e1000_read_flash_word_ich8lan(hw, act_offset, &data); |
Bruce Allan | 9c5e209 | 2010-05-10 15:00:31 +0000 | [diff] [blame] | 2928 | if (ret_val) |
| 2929 | goto release; |
| 2930 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2931 | data &= 0xBFFF; |
| 2932 | ret_val = e1000_retry_write_flash_byte_ich8lan(hw, |
| 2933 | act_offset * 2 + 1, |
| 2934 | (u8)(data >> 8)); |
Bruce Allan | 9c5e209 | 2010-05-10 15:00:31 +0000 | [diff] [blame] | 2935 | if (ret_val) |
| 2936 | goto release; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2937 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2938 | /* And invalidate the previously valid segment by setting |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2939 | * its signature word (0x13) high_byte to 0b. This can be |
| 2940 | * done without an erase because flash erase sets all bits |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2941 | * to 1's. We can write 1's to 0's without an erase |
| 2942 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2943 | act_offset = (old_bank_offset + E1000_ICH_NVM_SIG_WORD) * 2 + 1; |
| 2944 | ret_val = e1000_retry_write_flash_byte_ich8lan(hw, act_offset, 0); |
Bruce Allan | 9c5e209 | 2010-05-10 15:00:31 +0000 | [diff] [blame] | 2945 | if (ret_val) |
| 2946 | goto release; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2947 | |
| 2948 | /* Great! Everything worked, we can now clear the cached entries. */ |
| 2949 | for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i++) { |
Bruce Allan | 564ea9b | 2009-11-20 23:26:44 +0000 | [diff] [blame] | 2950 | dev_spec->shadow_ram[i].modified = false; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2951 | dev_spec->shadow_ram[i].value = 0xFFFF; |
| 2952 | } |
| 2953 | |
Bruce Allan | 9c5e209 | 2010-05-10 15:00:31 +0000 | [diff] [blame] | 2954 | release: |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 2955 | nvm->ops.release(hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2956 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2957 | /* Reload the EEPROM, or else modifications will not appear |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2958 | * until after the next adapter reset. |
| 2959 | */ |
Bruce Allan | 9c5e209 | 2010-05-10 15:00:31 +0000 | [diff] [blame] | 2960 | if (!ret_val) { |
Bruce Allan | e85e363 | 2012-02-22 09:03:14 +0000 | [diff] [blame] | 2961 | nvm->ops.reload(hw); |
Bruce Allan | 1bba438 | 2011-03-19 00:27:20 +0000 | [diff] [blame] | 2962 | usleep_range(10000, 20000); |
Bruce Allan | 9c5e209 | 2010-05-10 15:00:31 +0000 | [diff] [blame] | 2963 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2964 | |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2965 | out: |
| 2966 | if (ret_val) |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 2967 | e_dbg("NVM update error: %d\n", ret_val); |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2968 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2969 | return ret_val; |
| 2970 | } |
| 2971 | |
| 2972 | /** |
| 2973 | * e1000_validate_nvm_checksum_ich8lan - Validate EEPROM checksum |
| 2974 | * @hw: pointer to the HW structure |
| 2975 | * |
| 2976 | * Check to see if checksum needs to be fixed by reading bit 6 in word 0x19. |
| 2977 | * If the bit is 0, that the EEPROM had been modified, but the checksum was not |
| 2978 | * calculated, in which case we need to calculate the checksum and set bit 6. |
| 2979 | **/ |
| 2980 | static s32 e1000_validate_nvm_checksum_ich8lan(struct e1000_hw *hw) |
| 2981 | { |
| 2982 | s32 ret_val; |
| 2983 | u16 data; |
Bruce Allan | 1cc7a3a | 2013-01-09 08:15:42 +0000 | [diff] [blame] | 2984 | u16 word; |
| 2985 | u16 valid_csum_mask; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2986 | |
Bruce Allan | 1cc7a3a | 2013-01-09 08:15:42 +0000 | [diff] [blame] | 2987 | /* Read NVM and check Invalid Image CSUM bit. If this bit is 0, |
| 2988 | * the checksum needs to be fixed. This bit is an indication that |
| 2989 | * the NVM was prepared by OEM software and did not calculate |
| 2990 | * the checksum...a likely scenario. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2991 | */ |
Bruce Allan | 1cc7a3a | 2013-01-09 08:15:42 +0000 | [diff] [blame] | 2992 | switch (hw->mac.type) { |
| 2993 | case e1000_pch_lpt: |
| 2994 | word = NVM_COMPAT; |
| 2995 | valid_csum_mask = NVM_COMPAT_VALID_CSUM; |
| 2996 | break; |
| 2997 | default: |
| 2998 | word = NVM_FUTURE_INIT_WORD1; |
| 2999 | valid_csum_mask = NVM_FUTURE_INIT_WORD1_VALID_CSUM; |
| 3000 | break; |
| 3001 | } |
| 3002 | |
| 3003 | ret_val = e1000_read_nvm(hw, word, 1, &data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3004 | if (ret_val) |
| 3005 | return ret_val; |
| 3006 | |
Bruce Allan | 1cc7a3a | 2013-01-09 08:15:42 +0000 | [diff] [blame] | 3007 | if (!(data & valid_csum_mask)) { |
| 3008 | data |= valid_csum_mask; |
| 3009 | ret_val = e1000_write_nvm(hw, word, 1, &data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3010 | if (ret_val) |
| 3011 | return ret_val; |
| 3012 | ret_val = e1000e_update_nvm_checksum(hw); |
| 3013 | if (ret_val) |
| 3014 | return ret_val; |
| 3015 | } |
| 3016 | |
| 3017 | return e1000e_validate_nvm_checksum_generic(hw); |
| 3018 | } |
| 3019 | |
| 3020 | /** |
Bruce Allan | 4a77035 | 2008-10-01 17:18:35 -0700 | [diff] [blame] | 3021 | * e1000e_write_protect_nvm_ich8lan - Make the NVM read-only |
| 3022 | * @hw: pointer to the HW structure |
| 3023 | * |
| 3024 | * To prevent malicious write/erase of the NVM, set it to be read-only |
| 3025 | * so that the hardware ignores all write/erase cycles of the NVM via |
| 3026 | * the flash control registers. The shadow-ram copy of the NVM will |
| 3027 | * still be updated, however any updates to this copy will not stick |
| 3028 | * across driver reloads. |
| 3029 | **/ |
| 3030 | void e1000e_write_protect_nvm_ich8lan(struct e1000_hw *hw) |
| 3031 | { |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 3032 | struct e1000_nvm_info *nvm = &hw->nvm; |
Bruce Allan | 4a77035 | 2008-10-01 17:18:35 -0700 | [diff] [blame] | 3033 | union ich8_flash_protected_range pr0; |
| 3034 | union ich8_hws_flash_status hsfsts; |
| 3035 | u32 gfpreg; |
Bruce Allan | 4a77035 | 2008-10-01 17:18:35 -0700 | [diff] [blame] | 3036 | |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 3037 | nvm->ops.acquire(hw); |
Bruce Allan | 4a77035 | 2008-10-01 17:18:35 -0700 | [diff] [blame] | 3038 | |
| 3039 | gfpreg = er32flash(ICH_FLASH_GFPREG); |
| 3040 | |
| 3041 | /* Write-protect GbE Sector of NVM */ |
| 3042 | pr0.regval = er32flash(ICH_FLASH_PR0); |
| 3043 | pr0.range.base = gfpreg & FLASH_GFPREG_BASE_MASK; |
| 3044 | pr0.range.limit = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK); |
| 3045 | pr0.range.wpe = true; |
| 3046 | ew32flash(ICH_FLASH_PR0, pr0.regval); |
| 3047 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3048 | /* Lock down a subset of GbE Flash Control Registers, e.g. |
Bruce Allan | 4a77035 | 2008-10-01 17:18:35 -0700 | [diff] [blame] | 3049 | * PR0 to prevent the write-protection from being lifted. |
| 3050 | * Once FLOCKDN is set, the registers protected by it cannot |
| 3051 | * be written until FLOCKDN is cleared by a hardware reset. |
| 3052 | */ |
| 3053 | hsfsts.regval = er16flash(ICH_FLASH_HSFSTS); |
| 3054 | hsfsts.hsf_status.flockdn = true; |
| 3055 | ew32flash(ICH_FLASH_HSFSTS, hsfsts.regval); |
| 3056 | |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 3057 | nvm->ops.release(hw); |
Bruce Allan | 4a77035 | 2008-10-01 17:18:35 -0700 | [diff] [blame] | 3058 | } |
| 3059 | |
| 3060 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3061 | * e1000_write_flash_data_ich8lan - Writes bytes to the NVM |
| 3062 | * @hw: pointer to the HW structure |
| 3063 | * @offset: The offset (in bytes) of the byte/word to read. |
| 3064 | * @size: Size of data to read, 1=byte 2=word |
| 3065 | * @data: The byte(s) to write to the NVM. |
| 3066 | * |
| 3067 | * Writes one/two bytes to the NVM using the flash access registers. |
| 3068 | **/ |
| 3069 | static s32 e1000_write_flash_data_ich8lan(struct e1000_hw *hw, u32 offset, |
| 3070 | u8 size, u16 data) |
| 3071 | { |
| 3072 | union ich8_hws_flash_status hsfsts; |
| 3073 | union ich8_hws_flash_ctrl hsflctl; |
| 3074 | u32 flash_linear_addr; |
| 3075 | u32 flash_data = 0; |
| 3076 | s32 ret_val; |
| 3077 | u8 count = 0; |
| 3078 | |
| 3079 | if (size < 1 || size > 2 || data > size * 0xff || |
| 3080 | offset > ICH_FLASH_LINEAR_ADDR_MASK) |
| 3081 | return -E1000_ERR_NVM; |
| 3082 | |
Bruce Allan | f0ff439 | 2013-02-20 04:05:39 +0000 | [diff] [blame] | 3083 | flash_linear_addr = ((ICH_FLASH_LINEAR_ADDR_MASK & offset) + |
| 3084 | hw->nvm.flash_base_addr); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3085 | |
| 3086 | do { |
| 3087 | udelay(1); |
| 3088 | /* Steps */ |
| 3089 | ret_val = e1000_flash_cycle_init_ich8lan(hw); |
| 3090 | if (ret_val) |
| 3091 | break; |
| 3092 | |
| 3093 | hsflctl.regval = er16flash(ICH_FLASH_HSFCTL); |
| 3094 | /* 0b/1b corresponds to 1 or 2 byte size, respectively. */ |
Bruce Allan | 362e20c | 2013-02-20 04:05:45 +0000 | [diff] [blame] | 3095 | hsflctl.hsf_ctrl.fldbcount = size - 1; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3096 | hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_WRITE; |
| 3097 | ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval); |
| 3098 | |
| 3099 | ew32flash(ICH_FLASH_FADDR, flash_linear_addr); |
| 3100 | |
| 3101 | if (size == 1) |
| 3102 | flash_data = (u32)data & 0x00FF; |
| 3103 | else |
| 3104 | flash_data = (u32)data; |
| 3105 | |
| 3106 | ew32flash(ICH_FLASH_FDATA0, flash_data); |
| 3107 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3108 | /* check if FCERR is set to 1 , if set to 1, clear it |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 3109 | * and try the whole sequence a few more times else done |
| 3110 | */ |
Bruce Allan | 17e813e | 2013-02-20 04:06:01 +0000 | [diff] [blame] | 3111 | ret_val = |
| 3112 | e1000_flash_cycle_ich8lan(hw, |
| 3113 | ICH_FLASH_WRITE_COMMAND_TIMEOUT); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3114 | if (!ret_val) |
| 3115 | break; |
| 3116 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3117 | /* If we're here, then things are most likely |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3118 | * completely hosed, but if the error condition |
| 3119 | * is detected, it won't hurt to give it another |
| 3120 | * try...ICH_FLASH_CYCLE_REPEAT_COUNT times. |
| 3121 | */ |
| 3122 | hsfsts.regval = er16flash(ICH_FLASH_HSFSTS); |
Bruce Allan | 04499ec | 2012-04-13 00:08:31 +0000 | [diff] [blame] | 3123 | if (hsfsts.hsf_status.flcerr) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3124 | /* Repeat for some time before giving up. */ |
| 3125 | continue; |
Bruce Allan | 04499ec | 2012-04-13 00:08:31 +0000 | [diff] [blame] | 3126 | if (!hsfsts.hsf_status.flcdone) { |
Bruce Allan | 434f139 | 2011-12-16 00:46:54 +0000 | [diff] [blame] | 3127 | e_dbg("Timeout error - flash cycle did not complete.\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3128 | break; |
| 3129 | } |
| 3130 | } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT); |
| 3131 | |
| 3132 | return ret_val; |
| 3133 | } |
| 3134 | |
| 3135 | /** |
| 3136 | * e1000_write_flash_byte_ich8lan - Write a single byte to NVM |
| 3137 | * @hw: pointer to the HW structure |
| 3138 | * @offset: The index of the byte to read. |
| 3139 | * @data: The byte to write to the NVM. |
| 3140 | * |
| 3141 | * Writes a single byte to the NVM using the flash access registers. |
| 3142 | **/ |
| 3143 | static s32 e1000_write_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset, |
| 3144 | u8 data) |
| 3145 | { |
| 3146 | u16 word = (u16)data; |
| 3147 | |
| 3148 | return e1000_write_flash_data_ich8lan(hw, offset, 1, word); |
| 3149 | } |
| 3150 | |
| 3151 | /** |
| 3152 | * e1000_retry_write_flash_byte_ich8lan - Writes a single byte to NVM |
| 3153 | * @hw: pointer to the HW structure |
| 3154 | * @offset: The offset of the byte to write. |
| 3155 | * @byte: The byte to write to the NVM. |
| 3156 | * |
| 3157 | * Writes a single byte to the NVM using the flash access registers. |
| 3158 | * Goes through a retry algorithm before giving up. |
| 3159 | **/ |
| 3160 | static s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw, |
| 3161 | u32 offset, u8 byte) |
| 3162 | { |
| 3163 | s32 ret_val; |
| 3164 | u16 program_retries; |
| 3165 | |
| 3166 | ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte); |
| 3167 | if (!ret_val) |
| 3168 | return ret_val; |
| 3169 | |
| 3170 | for (program_retries = 0; program_retries < 100; program_retries++) { |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 3171 | e_dbg("Retrying Byte %2.2X at offset %u\n", byte, offset); |
Bruce Allan | ce43a21 | 2013-02-20 04:06:32 +0000 | [diff] [blame] | 3172 | usleep_range(100, 200); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3173 | ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte); |
| 3174 | if (!ret_val) |
| 3175 | break; |
| 3176 | } |
| 3177 | if (program_retries == 100) |
| 3178 | return -E1000_ERR_NVM; |
| 3179 | |
| 3180 | return 0; |
| 3181 | } |
| 3182 | |
| 3183 | /** |
| 3184 | * e1000_erase_flash_bank_ich8lan - Erase a bank (4k) from NVM |
| 3185 | * @hw: pointer to the HW structure |
| 3186 | * @bank: 0 for first bank, 1 for second bank, etc. |
| 3187 | * |
| 3188 | * Erases the bank specified. Each bank is a 4k block. Banks are 0 based. |
| 3189 | * bank N is 4096 * N + flash_reg_addr. |
| 3190 | **/ |
| 3191 | static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank) |
| 3192 | { |
| 3193 | struct e1000_nvm_info *nvm = &hw->nvm; |
| 3194 | union ich8_hws_flash_status hsfsts; |
| 3195 | union ich8_hws_flash_ctrl hsflctl; |
| 3196 | u32 flash_linear_addr; |
| 3197 | /* bank size is in 16bit words - adjust to bytes */ |
| 3198 | u32 flash_bank_size = nvm->flash_bank_size * 2; |
| 3199 | s32 ret_val; |
| 3200 | s32 count = 0; |
Bruce Allan | a708dd8 | 2009-11-20 23:28:37 +0000 | [diff] [blame] | 3201 | s32 j, iteration, sector_size; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3202 | |
| 3203 | hsfsts.regval = er16flash(ICH_FLASH_HSFSTS); |
| 3204 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3205 | /* Determine HW Sector size: Read BERASE bits of hw flash status |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 3206 | * register |
| 3207 | * 00: The Hw sector is 256 bytes, hence we need to erase 16 |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3208 | * consecutive sectors. The start index for the nth Hw sector |
| 3209 | * can be calculated as = bank * 4096 + n * 256 |
| 3210 | * 01: The Hw sector is 4K bytes, hence we need to erase 1 sector. |
| 3211 | * The start index for the nth Hw sector can be calculated |
| 3212 | * as = bank * 4096 |
| 3213 | * 10: The Hw sector is 8K bytes, nth sector = bank * 8192 |
| 3214 | * (ich9 only, otherwise error condition) |
| 3215 | * 11: The Hw sector is 64K bytes, nth sector = bank * 65536 |
| 3216 | */ |
| 3217 | switch (hsfsts.hsf_status.berasesz) { |
| 3218 | case 0: |
| 3219 | /* Hw sector size 256 */ |
| 3220 | sector_size = ICH_FLASH_SEG_SIZE_256; |
| 3221 | iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_256; |
| 3222 | break; |
| 3223 | case 1: |
| 3224 | sector_size = ICH_FLASH_SEG_SIZE_4K; |
Bruce Allan | 28c9195 | 2009-07-01 13:28:32 +0000 | [diff] [blame] | 3225 | iteration = 1; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3226 | break; |
| 3227 | case 2: |
Bruce Allan | 148675a | 2009-08-07 07:41:56 +0000 | [diff] [blame] | 3228 | sector_size = ICH_FLASH_SEG_SIZE_8K; |
| 3229 | iteration = 1; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3230 | break; |
| 3231 | case 3: |
| 3232 | sector_size = ICH_FLASH_SEG_SIZE_64K; |
Bruce Allan | 28c9195 | 2009-07-01 13:28:32 +0000 | [diff] [blame] | 3233 | iteration = 1; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3234 | break; |
| 3235 | default: |
| 3236 | return -E1000_ERR_NVM; |
| 3237 | } |
| 3238 | |
| 3239 | /* Start with the base address, then add the sector offset. */ |
| 3240 | flash_linear_addr = hw->nvm.flash_base_addr; |
Bruce Allan | 148675a | 2009-08-07 07:41:56 +0000 | [diff] [blame] | 3241 | flash_linear_addr += (bank) ? flash_bank_size : 0; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3242 | |
Bruce Allan | 53aa82d | 2013-02-20 04:06:06 +0000 | [diff] [blame] | 3243 | for (j = 0; j < iteration; j++) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3244 | do { |
Bruce Allan | 17e813e | 2013-02-20 04:06:01 +0000 | [diff] [blame] | 3245 | u32 timeout = ICH_FLASH_ERASE_COMMAND_TIMEOUT; |
| 3246 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3247 | /* Steps */ |
| 3248 | ret_val = e1000_flash_cycle_init_ich8lan(hw); |
| 3249 | if (ret_val) |
| 3250 | return ret_val; |
| 3251 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3252 | /* Write a value 11 (block Erase) in Flash |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 3253 | * Cycle field in hw flash control |
| 3254 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3255 | hsflctl.regval = er16flash(ICH_FLASH_HSFCTL); |
| 3256 | hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_ERASE; |
| 3257 | ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval); |
| 3258 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3259 | /* Write the last 24 bits of an index within the |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3260 | * block into Flash Linear address field in Flash |
| 3261 | * Address. |
| 3262 | */ |
| 3263 | flash_linear_addr += (j * sector_size); |
| 3264 | ew32flash(ICH_FLASH_FADDR, flash_linear_addr); |
| 3265 | |
Bruce Allan | 17e813e | 2013-02-20 04:06:01 +0000 | [diff] [blame] | 3266 | ret_val = e1000_flash_cycle_ich8lan(hw, timeout); |
Bruce Allan | 9e2d765 | 2012-01-31 06:37:27 +0000 | [diff] [blame] | 3267 | if (!ret_val) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3268 | break; |
| 3269 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3270 | /* Check if FCERR is set to 1. If 1, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3271 | * clear it and try the whole sequence |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 3272 | * a few more times else Done |
| 3273 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3274 | hsfsts.regval = er16flash(ICH_FLASH_HSFSTS); |
Bruce Allan | 04499ec | 2012-04-13 00:08:31 +0000 | [diff] [blame] | 3275 | if (hsfsts.hsf_status.flcerr) |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 3276 | /* repeat for some time before giving up */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3277 | continue; |
Bruce Allan | 04499ec | 2012-04-13 00:08:31 +0000 | [diff] [blame] | 3278 | else if (!hsfsts.hsf_status.flcdone) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3279 | return ret_val; |
| 3280 | } while (++count < ICH_FLASH_CYCLE_REPEAT_COUNT); |
| 3281 | } |
| 3282 | |
| 3283 | return 0; |
| 3284 | } |
| 3285 | |
| 3286 | /** |
| 3287 | * e1000_valid_led_default_ich8lan - Set the default LED settings |
| 3288 | * @hw: pointer to the HW structure |
| 3289 | * @data: Pointer to the LED settings |
| 3290 | * |
| 3291 | * Reads the LED default settings from the NVM to data. If the NVM LED |
| 3292 | * settings is all 0's or F's, set the LED default to a valid LED default |
| 3293 | * setting. |
| 3294 | **/ |
| 3295 | static s32 e1000_valid_led_default_ich8lan(struct e1000_hw *hw, u16 *data) |
| 3296 | { |
| 3297 | s32 ret_val; |
| 3298 | |
| 3299 | ret_val = e1000_read_nvm(hw, NVM_ID_LED_SETTINGS, 1, data); |
| 3300 | if (ret_val) { |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 3301 | e_dbg("NVM Read Error\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3302 | return ret_val; |
| 3303 | } |
| 3304 | |
Bruce Allan | e5fe254 | 2013-02-20 04:06:27 +0000 | [diff] [blame] | 3305 | if (*data == ID_LED_RESERVED_0000 || *data == ID_LED_RESERVED_FFFF) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3306 | *data = ID_LED_DEFAULT_ICH8LAN; |
| 3307 | |
| 3308 | return 0; |
| 3309 | } |
| 3310 | |
| 3311 | /** |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3312 | * e1000_id_led_init_pchlan - store LED configurations |
| 3313 | * @hw: pointer to the HW structure |
| 3314 | * |
| 3315 | * PCH does not control LEDs via the LEDCTL register, rather it uses |
| 3316 | * the PHY LED configuration register. |
| 3317 | * |
| 3318 | * PCH also does not have an "always on" or "always off" mode which |
| 3319 | * complicates the ID feature. Instead of using the "on" mode to indicate |
Bruce Allan | d1964eb | 2012-02-22 09:02:21 +0000 | [diff] [blame] | 3320 | * in ledctl_mode2 the LEDs to use for ID (see e1000e_id_led_init_generic()), |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3321 | * use "link_up" mode. The LEDs will still ID on request if there is no |
| 3322 | * link based on logic in e1000_led_[on|off]_pchlan(). |
| 3323 | **/ |
| 3324 | static s32 e1000_id_led_init_pchlan(struct e1000_hw *hw) |
| 3325 | { |
| 3326 | struct e1000_mac_info *mac = &hw->mac; |
| 3327 | s32 ret_val; |
| 3328 | const u32 ledctl_on = E1000_LEDCTL_MODE_LINK_UP; |
| 3329 | const u32 ledctl_off = E1000_LEDCTL_MODE_LINK_UP | E1000_PHY_LED0_IVRT; |
| 3330 | u16 data, i, temp, shift; |
| 3331 | |
| 3332 | /* Get default ID LED modes */ |
| 3333 | ret_val = hw->nvm.ops.valid_led_default(hw, &data); |
| 3334 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 3335 | return ret_val; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3336 | |
| 3337 | mac->ledctl_default = er32(LEDCTL); |
| 3338 | mac->ledctl_mode1 = mac->ledctl_default; |
| 3339 | mac->ledctl_mode2 = mac->ledctl_default; |
| 3340 | |
| 3341 | for (i = 0; i < 4; i++) { |
| 3342 | temp = (data >> (i << 2)) & E1000_LEDCTL_LED0_MODE_MASK; |
| 3343 | shift = (i * 5); |
| 3344 | switch (temp) { |
| 3345 | case ID_LED_ON1_DEF2: |
| 3346 | case ID_LED_ON1_ON2: |
| 3347 | case ID_LED_ON1_OFF2: |
| 3348 | mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift); |
| 3349 | mac->ledctl_mode1 |= (ledctl_on << shift); |
| 3350 | break; |
| 3351 | case ID_LED_OFF1_DEF2: |
| 3352 | case ID_LED_OFF1_ON2: |
| 3353 | case ID_LED_OFF1_OFF2: |
| 3354 | mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift); |
| 3355 | mac->ledctl_mode1 |= (ledctl_off << shift); |
| 3356 | break; |
| 3357 | default: |
| 3358 | /* Do nothing */ |
| 3359 | break; |
| 3360 | } |
| 3361 | switch (temp) { |
| 3362 | case ID_LED_DEF1_ON2: |
| 3363 | case ID_LED_ON1_ON2: |
| 3364 | case ID_LED_OFF1_ON2: |
| 3365 | mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift); |
| 3366 | mac->ledctl_mode2 |= (ledctl_on << shift); |
| 3367 | break; |
| 3368 | case ID_LED_DEF1_OFF2: |
| 3369 | case ID_LED_ON1_OFF2: |
| 3370 | case ID_LED_OFF1_OFF2: |
| 3371 | mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift); |
| 3372 | mac->ledctl_mode2 |= (ledctl_off << shift); |
| 3373 | break; |
| 3374 | default: |
| 3375 | /* Do nothing */ |
| 3376 | break; |
| 3377 | } |
| 3378 | } |
| 3379 | |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 3380 | return 0; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3381 | } |
| 3382 | |
| 3383 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3384 | * e1000_get_bus_info_ich8lan - Get/Set the bus type and width |
| 3385 | * @hw: pointer to the HW structure |
| 3386 | * |
| 3387 | * ICH8 use the PCI Express bus, but does not contain a PCI Express Capability |
| 3388 | * register, so the the bus width is hard coded. |
| 3389 | **/ |
| 3390 | static s32 e1000_get_bus_info_ich8lan(struct e1000_hw *hw) |
| 3391 | { |
| 3392 | struct e1000_bus_info *bus = &hw->bus; |
| 3393 | s32 ret_val; |
| 3394 | |
| 3395 | ret_val = e1000e_get_bus_info_pcie(hw); |
| 3396 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3397 | /* ICH devices are "PCI Express"-ish. They have |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3398 | * a configuration space, but do not contain |
| 3399 | * PCI Express Capability registers, so bus width |
| 3400 | * must be hardcoded. |
| 3401 | */ |
| 3402 | if (bus->width == e1000_bus_width_unknown) |
| 3403 | bus->width = e1000_bus_width_pcie_x1; |
| 3404 | |
| 3405 | return ret_val; |
| 3406 | } |
| 3407 | |
| 3408 | /** |
| 3409 | * e1000_reset_hw_ich8lan - Reset the hardware |
| 3410 | * @hw: pointer to the HW structure |
| 3411 | * |
| 3412 | * Does a full reset of the hardware which includes a reset of the PHY and |
| 3413 | * MAC. |
| 3414 | **/ |
| 3415 | static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw) |
| 3416 | { |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 3417 | struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; |
Bruce Allan | 62bc813 | 2012-03-20 03:47:57 +0000 | [diff] [blame] | 3418 | u16 kum_cfg; |
| 3419 | u32 ctrl, reg; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3420 | s32 ret_val; |
| 3421 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3422 | /* Prevent the PCI-E bus from sticking if there is no TLP connection |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3423 | * on the last TLP read/write transaction when MAC is reset. |
| 3424 | */ |
| 3425 | ret_val = e1000e_disable_pcie_master(hw); |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 3426 | if (ret_val) |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 3427 | e_dbg("PCI-E Master disable polling has failed.\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3428 | |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 3429 | e_dbg("Masking off all interrupts\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3430 | ew32(IMC, 0xffffffff); |
| 3431 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3432 | /* Disable the Transmit and Receive units. Then delay to allow |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3433 | * any pending transactions to complete before we hit the MAC |
| 3434 | * with the global reset. |
| 3435 | */ |
| 3436 | ew32(RCTL, 0); |
| 3437 | ew32(TCTL, E1000_TCTL_PSP); |
| 3438 | e1e_flush(); |
| 3439 | |
Bruce Allan | 1bba438 | 2011-03-19 00:27:20 +0000 | [diff] [blame] | 3440 | usleep_range(10000, 20000); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3441 | |
| 3442 | /* Workaround for ICH8 bit corruption issue in FIFO memory */ |
| 3443 | if (hw->mac.type == e1000_ich8lan) { |
| 3444 | /* Set Tx and Rx buffer allocation to 8k apiece. */ |
| 3445 | ew32(PBA, E1000_PBA_8K); |
| 3446 | /* Set Packet Buffer Size to 16k. */ |
| 3447 | ew32(PBS, E1000_PBS_16K); |
| 3448 | } |
| 3449 | |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 3450 | if (hw->mac.type == e1000_pchlan) { |
Bruce Allan | 62bc813 | 2012-03-20 03:47:57 +0000 | [diff] [blame] | 3451 | /* Save the NVM K1 bit setting */ |
| 3452 | ret_val = e1000_read_nvm(hw, E1000_NVM_K1_CONFIG, 1, &kum_cfg); |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 3453 | if (ret_val) |
| 3454 | return ret_val; |
| 3455 | |
Bruce Allan | 62bc813 | 2012-03-20 03:47:57 +0000 | [diff] [blame] | 3456 | if (kum_cfg & E1000_NVM_K1_ENABLE) |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 3457 | dev_spec->nvm_k1_enabled = true; |
| 3458 | else |
| 3459 | dev_spec->nvm_k1_enabled = false; |
| 3460 | } |
| 3461 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3462 | ctrl = er32(CTRL); |
| 3463 | |
Bruce Allan | 44abd5c | 2012-02-22 09:02:37 +0000 | [diff] [blame] | 3464 | if (!hw->phy.ops.check_reset_block(hw)) { |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3465 | /* Full-chip reset requires MAC and PHY reset at the same |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3466 | * time to make sure the interface between MAC and the |
| 3467 | * external PHY is reset. |
| 3468 | */ |
| 3469 | ctrl |= E1000_CTRL_PHY_RST; |
Bruce Allan | 605c82b | 2010-09-22 17:17:01 +0000 | [diff] [blame] | 3470 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3471 | /* Gate automatic PHY configuration by hardware on |
Bruce Allan | 605c82b | 2010-09-22 17:17:01 +0000 | [diff] [blame] | 3472 | * non-managed 82579 |
| 3473 | */ |
| 3474 | if ((hw->mac.type == e1000_pch2lan) && |
| 3475 | !(er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) |
| 3476 | e1000_gate_hw_phy_config_ich8lan(hw, true); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3477 | } |
| 3478 | ret_val = e1000_acquire_swflag_ich8lan(hw); |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 3479 | e_dbg("Issuing a global reset to ich8lan\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3480 | ew32(CTRL, (ctrl | E1000_CTRL_RST)); |
Jesse Brandeburg | 945a515 | 2011-07-20 00:56:21 +0000 | [diff] [blame] | 3481 | /* cannot issue a flush here because it hangs the hardware */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3482 | msleep(20); |
| 3483 | |
Bruce Allan | 62bc813 | 2012-03-20 03:47:57 +0000 | [diff] [blame] | 3484 | /* Set Phy Config Counter to 50msec */ |
| 3485 | if (hw->mac.type == e1000_pch2lan) { |
| 3486 | reg = er32(FEXTNVM3); |
| 3487 | reg &= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK; |
| 3488 | reg |= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC; |
| 3489 | ew32(FEXTNVM3, reg); |
| 3490 | } |
| 3491 | |
Bruce Allan | fc0c776 | 2009-07-01 13:27:55 +0000 | [diff] [blame] | 3492 | if (!ret_val) |
Bruce Allan | a90b412 | 2011-10-07 03:50:38 +0000 | [diff] [blame] | 3493 | clear_bit(__E1000_ACCESS_SHARED_RESOURCE, &hw->adapter->state); |
Jesse Brandeburg | 37f4023 | 2008-10-02 16:33:20 -0700 | [diff] [blame] | 3494 | |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 3495 | if (ctrl & E1000_CTRL_PHY_RST) { |
Bruce Allan | fc0c776 | 2009-07-01 13:27:55 +0000 | [diff] [blame] | 3496 | ret_val = hw->phy.ops.get_cfg_done(hw); |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 3497 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 3498 | return ret_val; |
Bruce Allan | fc0c776 | 2009-07-01 13:27:55 +0000 | [diff] [blame] | 3499 | |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 3500 | ret_val = e1000_post_phy_reset_ich8lan(hw); |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 3501 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 3502 | return ret_val; |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 3503 | } |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 3504 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3505 | /* For PCH, this write will make sure that any noise |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 3506 | * will be detected as a CRC error and be dropped rather than show up |
| 3507 | * as a bad packet to the DMA engine. |
| 3508 | */ |
| 3509 | if (hw->mac.type == e1000_pchlan) |
| 3510 | ew32(CRC_OFFSET, 0x65656565); |
| 3511 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3512 | ew32(IMC, 0xffffffff); |
Bruce Allan | dd93f95 | 2011-01-06 14:29:48 +0000 | [diff] [blame] | 3513 | er32(ICR); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3514 | |
Bruce Allan | 62bc813 | 2012-03-20 03:47:57 +0000 | [diff] [blame] | 3515 | reg = er32(KABGTXD); |
| 3516 | reg |= E1000_KABGTXD_BGSQLBIAS; |
| 3517 | ew32(KABGTXD, reg); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3518 | |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 3519 | return 0; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3520 | } |
| 3521 | |
| 3522 | /** |
| 3523 | * e1000_init_hw_ich8lan - Initialize the hardware |
| 3524 | * @hw: pointer to the HW structure |
| 3525 | * |
| 3526 | * Prepares the hardware for transmit and receive by doing the following: |
| 3527 | * - initialize hardware bits |
| 3528 | * - initialize LED identification |
| 3529 | * - setup receive address registers |
| 3530 | * - setup flow control |
Auke Kok | 489815c | 2008-02-21 15:11:07 -0800 | [diff] [blame] | 3531 | * - setup transmit descriptors |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3532 | * - clear statistics |
| 3533 | **/ |
| 3534 | static s32 e1000_init_hw_ich8lan(struct e1000_hw *hw) |
| 3535 | { |
| 3536 | struct e1000_mac_info *mac = &hw->mac; |
| 3537 | u32 ctrl_ext, txdctl, snoop; |
| 3538 | s32 ret_val; |
| 3539 | u16 i; |
| 3540 | |
| 3541 | e1000_initialize_hw_bits_ich8lan(hw); |
| 3542 | |
| 3543 | /* Initialize identification LED */ |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3544 | ret_val = mac->ops.id_led_init(hw); |
Bruce Allan | 33550ce | 2013-02-20 04:06:16 +0000 | [diff] [blame] | 3545 | /* An error is not fatal and we should not stop init due to this */ |
Bruce Allan | de39b75 | 2009-11-20 23:27:59 +0000 | [diff] [blame] | 3546 | if (ret_val) |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 3547 | e_dbg("Error initializing identification LED\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3548 | |
| 3549 | /* Setup the receive address. */ |
| 3550 | e1000e_init_rx_addrs(hw, mac->rar_entry_count); |
| 3551 | |
| 3552 | /* Zero out the Multicast HASH table */ |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 3553 | e_dbg("Zeroing the MTA\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3554 | for (i = 0; i < mac->mta_reg_count; i++) |
| 3555 | E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0); |
| 3556 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3557 | /* The 82578 Rx buffer will stall if wakeup is enabled in host and |
Bruce Allan | 3ebfc7c | 2011-05-13 07:20:14 +0000 | [diff] [blame] | 3558 | * the ME. Disable wakeup by clearing the host wakeup bit. |
Bruce Allan | fc0c776 | 2009-07-01 13:27:55 +0000 | [diff] [blame] | 3559 | * Reset the phy after disabling host wakeup to reset the Rx buffer. |
| 3560 | */ |
| 3561 | if (hw->phy.type == e1000_phy_82578) { |
Bruce Allan | 3ebfc7c | 2011-05-13 07:20:14 +0000 | [diff] [blame] | 3562 | e1e_rphy(hw, BM_PORT_GEN_CFG, &i); |
| 3563 | i &= ~BM_WUC_HOST_WU_BIT; |
| 3564 | e1e_wphy(hw, BM_PORT_GEN_CFG, i); |
Bruce Allan | fc0c776 | 2009-07-01 13:27:55 +0000 | [diff] [blame] | 3565 | ret_val = e1000_phy_hw_reset_ich8lan(hw); |
| 3566 | if (ret_val) |
| 3567 | return ret_val; |
| 3568 | } |
| 3569 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3570 | /* Setup link and flow control */ |
Bruce Allan | 1a46b40 | 2012-02-22 09:02:26 +0000 | [diff] [blame] | 3571 | ret_val = mac->ops.setup_link(hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3572 | |
| 3573 | /* Set the transmit descriptor write-back policy for both queues */ |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 3574 | txdctl = er32(TXDCTL(0)); |
Bruce Allan | f0ff439 | 2013-02-20 04:05:39 +0000 | [diff] [blame] | 3575 | txdctl = ((txdctl & ~E1000_TXDCTL_WTHRESH) | |
| 3576 | E1000_TXDCTL_FULL_TX_DESC_WB); |
| 3577 | txdctl = ((txdctl & ~E1000_TXDCTL_PTHRESH) | |
| 3578 | E1000_TXDCTL_MAX_TX_DESC_PREFETCH); |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 3579 | ew32(TXDCTL(0), txdctl); |
| 3580 | txdctl = er32(TXDCTL(1)); |
Bruce Allan | f0ff439 | 2013-02-20 04:05:39 +0000 | [diff] [blame] | 3581 | txdctl = ((txdctl & ~E1000_TXDCTL_WTHRESH) | |
| 3582 | E1000_TXDCTL_FULL_TX_DESC_WB); |
| 3583 | txdctl = ((txdctl & ~E1000_TXDCTL_PTHRESH) | |
| 3584 | E1000_TXDCTL_MAX_TX_DESC_PREFETCH); |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 3585 | ew32(TXDCTL(1), txdctl); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3586 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3587 | /* ICH8 has opposite polarity of no_snoop bits. |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 3588 | * By default, we should use snoop behavior. |
| 3589 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3590 | if (mac->type == e1000_ich8lan) |
| 3591 | snoop = PCIE_ICH8_SNOOP_ALL; |
| 3592 | else |
Bruce Allan | 53aa82d | 2013-02-20 04:06:06 +0000 | [diff] [blame] | 3593 | snoop = (u32)~(PCIE_NO_SNOOP_ALL); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3594 | e1000e_set_pcie_no_snoop(hw, snoop); |
| 3595 | |
| 3596 | ctrl_ext = er32(CTRL_EXT); |
| 3597 | ctrl_ext |= E1000_CTRL_EXT_RO_DIS; |
| 3598 | ew32(CTRL_EXT, ctrl_ext); |
| 3599 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3600 | /* Clear all of the statistics registers (clear on read). It is |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3601 | * important that we do this after we have tried to establish link |
| 3602 | * because the symbol error count will increment wildly if there |
| 3603 | * is no link. |
| 3604 | */ |
| 3605 | e1000_clear_hw_cntrs_ich8lan(hw); |
| 3606 | |
Bruce Allan | e561a70 | 2012-02-08 02:55:46 +0000 | [diff] [blame] | 3607 | return ret_val; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3608 | } |
Bruce Allan | fc830b7 | 2013-02-20 04:06:11 +0000 | [diff] [blame] | 3609 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3610 | /** |
| 3611 | * e1000_initialize_hw_bits_ich8lan - Initialize required hardware bits |
| 3612 | * @hw: pointer to the HW structure |
| 3613 | * |
| 3614 | * Sets/Clears required hardware bits necessary for correctly setting up the |
| 3615 | * hardware for transmit and receive. |
| 3616 | **/ |
| 3617 | static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw) |
| 3618 | { |
| 3619 | u32 reg; |
| 3620 | |
| 3621 | /* Extended Device Control */ |
| 3622 | reg = er32(CTRL_EXT); |
| 3623 | reg |= (1 << 22); |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3624 | /* Enable PHY low-power state when MAC is at D3 w/o WoL */ |
| 3625 | if (hw->mac.type >= e1000_pchlan) |
| 3626 | reg |= E1000_CTRL_EXT_PHYPDEN; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3627 | ew32(CTRL_EXT, reg); |
| 3628 | |
| 3629 | /* Transmit Descriptor Control 0 */ |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 3630 | reg = er32(TXDCTL(0)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3631 | reg |= (1 << 22); |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 3632 | ew32(TXDCTL(0), reg); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3633 | |
| 3634 | /* Transmit Descriptor Control 1 */ |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 3635 | reg = er32(TXDCTL(1)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3636 | reg |= (1 << 22); |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 3637 | ew32(TXDCTL(1), reg); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3638 | |
| 3639 | /* Transmit Arbitration Control 0 */ |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 3640 | reg = er32(TARC(0)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3641 | if (hw->mac.type == e1000_ich8lan) |
| 3642 | reg |= (1 << 28) | (1 << 29); |
| 3643 | reg |= (1 << 23) | (1 << 24) | (1 << 26) | (1 << 27); |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 3644 | ew32(TARC(0), reg); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3645 | |
| 3646 | /* Transmit Arbitration Control 1 */ |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 3647 | reg = er32(TARC(1)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3648 | if (er32(TCTL) & E1000_TCTL_MULR) |
| 3649 | reg &= ~(1 << 28); |
| 3650 | else |
| 3651 | reg |= (1 << 28); |
| 3652 | reg |= (1 << 24) | (1 << 26) | (1 << 30); |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 3653 | ew32(TARC(1), reg); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3654 | |
| 3655 | /* Device Status */ |
| 3656 | if (hw->mac.type == e1000_ich8lan) { |
| 3657 | reg = er32(STATUS); |
| 3658 | reg &= ~(1 << 31); |
| 3659 | ew32(STATUS, reg); |
| 3660 | } |
Jesse Brandeburg | a80483d | 2010-03-05 02:21:44 +0000 | [diff] [blame] | 3661 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3662 | /* work-around descriptor data corruption issue during nfs v2 udp |
Jesse Brandeburg | a80483d | 2010-03-05 02:21:44 +0000 | [diff] [blame] | 3663 | * traffic, just disable the nfs filtering capability |
| 3664 | */ |
| 3665 | reg = er32(RFCTL); |
| 3666 | reg |= (E1000_RFCTL_NFSW_DIS | E1000_RFCTL_NFSR_DIS); |
Matthew Vick | f6bd557 | 2012-04-25 08:01:05 +0000 | [diff] [blame] | 3667 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3668 | /* Disable IPv6 extension header parsing because some malformed |
Matthew Vick | f6bd557 | 2012-04-25 08:01:05 +0000 | [diff] [blame] | 3669 | * IPv6 headers can hang the Rx. |
| 3670 | */ |
| 3671 | if (hw->mac.type == e1000_ich8lan) |
| 3672 | reg |= (E1000_RFCTL_IPV6_EX_DIS | E1000_RFCTL_NEW_IPV6_EXT_DIS); |
Jesse Brandeburg | a80483d | 2010-03-05 02:21:44 +0000 | [diff] [blame] | 3673 | ew32(RFCTL, reg); |
Bruce Allan | 94fb848 | 2013-01-23 09:00:03 +0000 | [diff] [blame] | 3674 | |
| 3675 | /* Enable ECC on Lynxpoint */ |
| 3676 | if (hw->mac.type == e1000_pch_lpt) { |
| 3677 | reg = er32(PBECCSTS); |
| 3678 | reg |= E1000_PBECCSTS_ECC_ENABLE; |
| 3679 | ew32(PBECCSTS, reg); |
| 3680 | |
| 3681 | reg = er32(CTRL); |
| 3682 | reg |= E1000_CTRL_MEHE; |
| 3683 | ew32(CTRL, reg); |
| 3684 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3685 | } |
| 3686 | |
| 3687 | /** |
| 3688 | * e1000_setup_link_ich8lan - Setup flow control and link settings |
| 3689 | * @hw: pointer to the HW structure |
| 3690 | * |
| 3691 | * Determines which flow control settings to use, then configures flow |
| 3692 | * control. Calls the appropriate media-specific link configuration |
| 3693 | * function. Assuming the adapter has a valid link partner, a valid link |
| 3694 | * should be established. Assumes the hardware has previously been reset |
| 3695 | * and the transmitter and receiver are not enabled. |
| 3696 | **/ |
| 3697 | static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw) |
| 3698 | { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3699 | s32 ret_val; |
| 3700 | |
Bruce Allan | 44abd5c | 2012-02-22 09:02:37 +0000 | [diff] [blame] | 3701 | if (hw->phy.ops.check_reset_block(hw)) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3702 | return 0; |
| 3703 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3704 | /* ICH parts do not have a word in the NVM to determine |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3705 | * the default flow control setting, so we explicitly |
| 3706 | * set it to full. |
| 3707 | */ |
Bruce Allan | 37289d9 | 2009-06-02 11:29:37 +0000 | [diff] [blame] | 3708 | if (hw->fc.requested_mode == e1000_fc_default) { |
| 3709 | /* Workaround h/w hang when Tx flow control enabled */ |
| 3710 | if (hw->mac.type == e1000_pchlan) |
| 3711 | hw->fc.requested_mode = e1000_fc_rx_pause; |
| 3712 | else |
| 3713 | hw->fc.requested_mode = e1000_fc_full; |
| 3714 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3715 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3716 | /* Save off the requested flow control mode for use later. Depending |
Bruce Allan | 5c48ef3e2 | 2008-11-21 16:57:36 -0800 | [diff] [blame] | 3717 | * on the link partner's capabilities, we may or may not use this mode. |
| 3718 | */ |
| 3719 | hw->fc.current_mode = hw->fc.requested_mode; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3720 | |
Bruce Allan | 17e813e | 2013-02-20 04:06:01 +0000 | [diff] [blame] | 3721 | e_dbg("After fix-ups FlowControl is now = %x\n", hw->fc.current_mode); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3722 | |
| 3723 | /* Continue to configure the copper link. */ |
Bruce Allan | 944ce01 | 2012-02-22 09:02:42 +0000 | [diff] [blame] | 3724 | ret_val = hw->mac.ops.setup_physical_interface(hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3725 | if (ret_val) |
| 3726 | return ret_val; |
| 3727 | |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 3728 | ew32(FCTTV, hw->fc.pause_time); |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3729 | if ((hw->phy.type == e1000_phy_82578) || |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 3730 | (hw->phy.type == e1000_phy_82579) || |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 3731 | (hw->phy.type == e1000_phy_i217) || |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3732 | (hw->phy.type == e1000_phy_82577)) { |
Bruce Allan | a305595 | 2010-05-10 15:02:12 +0000 | [diff] [blame] | 3733 | ew32(FCRTV_PCH, hw->fc.refresh_time); |
| 3734 | |
Bruce Allan | 482fed8 | 2011-01-06 14:29:49 +0000 | [diff] [blame] | 3735 | ret_val = e1e_wphy(hw, PHY_REG(BM_PORT_CTRL_PAGE, 27), |
| 3736 | hw->fc.pause_time); |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3737 | if (ret_val) |
| 3738 | return ret_val; |
| 3739 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3740 | |
| 3741 | return e1000e_set_fc_watermarks(hw); |
| 3742 | } |
| 3743 | |
| 3744 | /** |
| 3745 | * e1000_setup_copper_link_ich8lan - Configure MAC/PHY interface |
| 3746 | * @hw: pointer to the HW structure |
| 3747 | * |
| 3748 | * Configures the kumeran interface to the PHY to wait the appropriate time |
| 3749 | * when polling the PHY, then call the generic setup_copper_link to finish |
| 3750 | * configuring the copper link. |
| 3751 | **/ |
| 3752 | static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw) |
| 3753 | { |
| 3754 | u32 ctrl; |
| 3755 | s32 ret_val; |
| 3756 | u16 reg_data; |
| 3757 | |
| 3758 | ctrl = er32(CTRL); |
| 3759 | ctrl |= E1000_CTRL_SLU; |
| 3760 | ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX); |
| 3761 | ew32(CTRL, ctrl); |
| 3762 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3763 | /* Set the mac to wait the maximum time between each iteration |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3764 | * and increase the max iterations when polling the phy; |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 3765 | * this fixes erroneous timeouts at 10Mbps. |
| 3766 | */ |
Bruce Allan | 0781895 | 2009-12-08 07:28:01 +0000 | [diff] [blame] | 3767 | ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_TIMEOUTS, 0xFFFF); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3768 | if (ret_val) |
| 3769 | return ret_val; |
Bruce Allan | 0781895 | 2009-12-08 07:28:01 +0000 | [diff] [blame] | 3770 | ret_val = e1000e_read_kmrn_reg(hw, E1000_KMRNCTRLSTA_INBAND_PARAM, |
Bruce Allan | f0ff439 | 2013-02-20 04:05:39 +0000 | [diff] [blame] | 3771 | ®_data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3772 | if (ret_val) |
| 3773 | return ret_val; |
| 3774 | reg_data |= 0x3F; |
Bruce Allan | 0781895 | 2009-12-08 07:28:01 +0000 | [diff] [blame] | 3775 | ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_INBAND_PARAM, |
Bruce Allan | f0ff439 | 2013-02-20 04:05:39 +0000 | [diff] [blame] | 3776 | reg_data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3777 | if (ret_val) |
| 3778 | return ret_val; |
| 3779 | |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3780 | switch (hw->phy.type) { |
| 3781 | case e1000_phy_igp_3: |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3782 | ret_val = e1000e_copper_link_setup_igp(hw); |
| 3783 | if (ret_val) |
| 3784 | return ret_val; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3785 | break; |
| 3786 | case e1000_phy_bm: |
| 3787 | case e1000_phy_82578: |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 3788 | ret_val = e1000e_copper_link_setup_m88(hw); |
| 3789 | if (ret_val) |
| 3790 | return ret_val; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3791 | break; |
| 3792 | case e1000_phy_82577: |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 3793 | case e1000_phy_82579: |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3794 | ret_val = e1000_copper_link_setup_82577(hw); |
| 3795 | if (ret_val) |
| 3796 | return ret_val; |
| 3797 | break; |
| 3798 | case e1000_phy_ife: |
Bruce Allan | 482fed8 | 2011-01-06 14:29:49 +0000 | [diff] [blame] | 3799 | ret_val = e1e_rphy(hw, IFE_PHY_MDIX_CONTROL, ®_data); |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 3800 | if (ret_val) |
| 3801 | return ret_val; |
| 3802 | |
| 3803 | reg_data &= ~IFE_PMC_AUTO_MDIX; |
| 3804 | |
| 3805 | switch (hw->phy.mdix) { |
| 3806 | case 1: |
| 3807 | reg_data &= ~IFE_PMC_FORCE_MDIX; |
| 3808 | break; |
| 3809 | case 2: |
| 3810 | reg_data |= IFE_PMC_FORCE_MDIX; |
| 3811 | break; |
| 3812 | case 0: |
| 3813 | default: |
| 3814 | reg_data |= IFE_PMC_AUTO_MDIX; |
| 3815 | break; |
| 3816 | } |
Bruce Allan | 482fed8 | 2011-01-06 14:29:49 +0000 | [diff] [blame] | 3817 | ret_val = e1e_wphy(hw, IFE_PHY_MDIX_CONTROL, reg_data); |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 3818 | if (ret_val) |
| 3819 | return ret_val; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3820 | break; |
| 3821 | default: |
| 3822 | break; |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 3823 | } |
Bruce Allan | 3fa829363 | 2012-02-08 02:55:40 +0000 | [diff] [blame] | 3824 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3825 | return e1000e_setup_copper_link(hw); |
| 3826 | } |
| 3827 | |
| 3828 | /** |
Bruce Allan | ea8179a | 2013-03-06 09:02:47 +0000 | [diff] [blame^] | 3829 | * e1000_setup_copper_link_pch_lpt - Configure MAC/PHY interface |
| 3830 | * @hw: pointer to the HW structure |
| 3831 | * |
| 3832 | * Calls the PHY specific link setup function and then calls the |
| 3833 | * generic setup_copper_link to finish configuring the link for |
| 3834 | * Lynxpoint PCH devices |
| 3835 | **/ |
| 3836 | static s32 e1000_setup_copper_link_pch_lpt(struct e1000_hw *hw) |
| 3837 | { |
| 3838 | u32 ctrl; |
| 3839 | s32 ret_val; |
| 3840 | |
| 3841 | ctrl = er32(CTRL); |
| 3842 | ctrl |= E1000_CTRL_SLU; |
| 3843 | ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX); |
| 3844 | ew32(CTRL, ctrl); |
| 3845 | |
| 3846 | ret_val = e1000_copper_link_setup_82577(hw); |
| 3847 | if (ret_val) |
| 3848 | return ret_val; |
| 3849 | |
| 3850 | return e1000e_setup_copper_link(hw); |
| 3851 | } |
| 3852 | |
| 3853 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3854 | * e1000_get_link_up_info_ich8lan - Get current link speed and duplex |
| 3855 | * @hw: pointer to the HW structure |
| 3856 | * @speed: pointer to store current link speed |
| 3857 | * @duplex: pointer to store the current link duplex |
| 3858 | * |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 3859 | * Calls the generic get_speed_and_duplex to retrieve the current link |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3860 | * information and then calls the Kumeran lock loss workaround for links at |
| 3861 | * gigabit speeds. |
| 3862 | **/ |
| 3863 | static s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw, u16 *speed, |
| 3864 | u16 *duplex) |
| 3865 | { |
| 3866 | s32 ret_val; |
| 3867 | |
| 3868 | ret_val = e1000e_get_speed_and_duplex_copper(hw, speed, duplex); |
| 3869 | if (ret_val) |
| 3870 | return ret_val; |
| 3871 | |
| 3872 | if ((hw->mac.type == e1000_ich8lan) && |
Bruce Allan | e5fe254 | 2013-02-20 04:06:27 +0000 | [diff] [blame] | 3873 | (hw->phy.type == e1000_phy_igp_3) && (*speed == SPEED_1000)) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3874 | ret_val = e1000_kmrn_lock_loss_workaround_ich8lan(hw); |
| 3875 | } |
| 3876 | |
| 3877 | return ret_val; |
| 3878 | } |
| 3879 | |
| 3880 | /** |
| 3881 | * e1000_kmrn_lock_loss_workaround_ich8lan - Kumeran workaround |
| 3882 | * @hw: pointer to the HW structure |
| 3883 | * |
| 3884 | * Work-around for 82566 Kumeran PCS lock loss: |
| 3885 | * On link status change (i.e. PCI reset, speed change) and link is up and |
| 3886 | * speed is gigabit- |
| 3887 | * 0) if workaround is optionally disabled do nothing |
| 3888 | * 1) wait 1ms for Kumeran link to come up |
| 3889 | * 2) check Kumeran Diagnostic register PCS lock loss bit |
| 3890 | * 3) if not set the link is locked (all is good), otherwise... |
| 3891 | * 4) reset the PHY |
| 3892 | * 5) repeat up to 10 times |
| 3893 | * Note: this is only called for IGP3 copper when speed is 1gb. |
| 3894 | **/ |
| 3895 | static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw) |
| 3896 | { |
| 3897 | struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; |
| 3898 | u32 phy_ctrl; |
| 3899 | s32 ret_val; |
| 3900 | u16 i, data; |
| 3901 | bool link; |
| 3902 | |
| 3903 | if (!dev_spec->kmrn_lock_loss_workaround_enabled) |
| 3904 | return 0; |
| 3905 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3906 | /* Make sure link is up before proceeding. If not just return. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3907 | * Attempting this while link is negotiating fouled up link |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 3908 | * stability |
| 3909 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3910 | ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link); |
| 3911 | if (!link) |
| 3912 | return 0; |
| 3913 | |
| 3914 | for (i = 0; i < 10; i++) { |
| 3915 | /* read once to clear */ |
| 3916 | ret_val = e1e_rphy(hw, IGP3_KMRN_DIAG, &data); |
| 3917 | if (ret_val) |
| 3918 | return ret_val; |
| 3919 | /* and again to get new status */ |
| 3920 | ret_val = e1e_rphy(hw, IGP3_KMRN_DIAG, &data); |
| 3921 | if (ret_val) |
| 3922 | return ret_val; |
| 3923 | |
| 3924 | /* check for PCS lock */ |
| 3925 | if (!(data & IGP3_KMRN_DIAG_PCS_LOCK_LOSS)) |
| 3926 | return 0; |
| 3927 | |
| 3928 | /* Issue PHY reset */ |
| 3929 | e1000_phy_hw_reset(hw); |
| 3930 | mdelay(5); |
| 3931 | } |
| 3932 | /* Disable GigE link negotiation */ |
| 3933 | phy_ctrl = er32(PHY_CTRL); |
| 3934 | phy_ctrl |= (E1000_PHY_CTRL_GBE_DISABLE | |
| 3935 | E1000_PHY_CTRL_NOND0A_GBE_DISABLE); |
| 3936 | ew32(PHY_CTRL, phy_ctrl); |
| 3937 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3938 | /* Call gig speed drop workaround on Gig disable before accessing |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 3939 | * any PHY registers |
| 3940 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3941 | e1000e_gig_downshift_workaround_ich8lan(hw); |
| 3942 | |
| 3943 | /* unable to acquire PCS lock */ |
| 3944 | return -E1000_ERR_PHY; |
| 3945 | } |
| 3946 | |
| 3947 | /** |
Bruce Allan | 6e3c807 | 2012-02-22 09:02:47 +0000 | [diff] [blame] | 3948 | * e1000e_set_kmrn_lock_loss_workaround_ich8lan - Set Kumeran workaround state |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3949 | * @hw: pointer to the HW structure |
Auke Kok | 489815c | 2008-02-21 15:11:07 -0800 | [diff] [blame] | 3950 | * @state: boolean value used to set the current Kumeran workaround state |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3951 | * |
Bruce Allan | 564ea9b | 2009-11-20 23:26:44 +0000 | [diff] [blame] | 3952 | * If ICH8, set the current Kumeran workaround state (enabled - true |
| 3953 | * /disabled - false). |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3954 | **/ |
| 3955 | void e1000e_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw, |
Bruce Allan | 17e813e | 2013-02-20 04:06:01 +0000 | [diff] [blame] | 3956 | bool state) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3957 | { |
| 3958 | struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; |
| 3959 | |
| 3960 | if (hw->mac.type != e1000_ich8lan) { |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 3961 | e_dbg("Workaround applies to ICH8 only.\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3962 | return; |
| 3963 | } |
| 3964 | |
| 3965 | dev_spec->kmrn_lock_loss_workaround_enabled = state; |
| 3966 | } |
| 3967 | |
| 3968 | /** |
| 3969 | * e1000_ipg3_phy_powerdown_workaround_ich8lan - Power down workaround on D3 |
| 3970 | * @hw: pointer to the HW structure |
| 3971 | * |
| 3972 | * Workaround for 82566 power-down on D3 entry: |
| 3973 | * 1) disable gigabit link |
| 3974 | * 2) write VR power-down enable |
| 3975 | * 3) read it back |
| 3976 | * Continue if successful, else issue LCD reset and repeat |
| 3977 | **/ |
| 3978 | void e1000e_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw) |
| 3979 | { |
| 3980 | u32 reg; |
| 3981 | u16 data; |
| 3982 | u8 retry = 0; |
| 3983 | |
| 3984 | if (hw->phy.type != e1000_phy_igp_3) |
| 3985 | return; |
| 3986 | |
| 3987 | /* Try the workaround twice (if needed) */ |
| 3988 | do { |
| 3989 | /* Disable link */ |
| 3990 | reg = er32(PHY_CTRL); |
| 3991 | reg |= (E1000_PHY_CTRL_GBE_DISABLE | |
| 3992 | E1000_PHY_CTRL_NOND0A_GBE_DISABLE); |
| 3993 | ew32(PHY_CTRL, reg); |
| 3994 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3995 | /* Call gig speed drop workaround on Gig disable before |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 3996 | * accessing any PHY registers |
| 3997 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3998 | if (hw->mac.type == e1000_ich8lan) |
| 3999 | e1000e_gig_downshift_workaround_ich8lan(hw); |
| 4000 | |
| 4001 | /* Write VR power-down enable */ |
| 4002 | e1e_rphy(hw, IGP3_VR_CTRL, &data); |
| 4003 | data &= ~IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK; |
| 4004 | e1e_wphy(hw, IGP3_VR_CTRL, data | IGP3_VR_CTRL_MODE_SHUTDOWN); |
| 4005 | |
| 4006 | /* Read it back and test */ |
| 4007 | e1e_rphy(hw, IGP3_VR_CTRL, &data); |
| 4008 | data &= IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK; |
| 4009 | if ((data == IGP3_VR_CTRL_MODE_SHUTDOWN) || retry) |
| 4010 | break; |
| 4011 | |
| 4012 | /* Issue PHY reset and repeat at most one more time */ |
| 4013 | reg = er32(CTRL); |
| 4014 | ew32(CTRL, reg | E1000_CTRL_PHY_RST); |
| 4015 | retry++; |
| 4016 | } while (retry); |
| 4017 | } |
| 4018 | |
| 4019 | /** |
| 4020 | * e1000e_gig_downshift_workaround_ich8lan - WoL from S5 stops working |
| 4021 | * @hw: pointer to the HW structure |
| 4022 | * |
| 4023 | * Steps to take when dropping from 1Gb/s (eg. link cable removal (LSC), |
Auke Kok | 489815c | 2008-02-21 15:11:07 -0800 | [diff] [blame] | 4024 | * LPLU, Gig disable, MDIC PHY reset): |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4025 | * 1) Set Kumeran Near-end loopback |
| 4026 | * 2) Clear Kumeran Near-end loopback |
Bruce Allan | 462d599 | 2011-09-30 08:07:11 +0000 | [diff] [blame] | 4027 | * Should only be called for ICH8[m] devices with any 1G Phy. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4028 | **/ |
| 4029 | void e1000e_gig_downshift_workaround_ich8lan(struct e1000_hw *hw) |
| 4030 | { |
| 4031 | s32 ret_val; |
| 4032 | u16 reg_data; |
| 4033 | |
Bruce Allan | 462d599 | 2011-09-30 08:07:11 +0000 | [diff] [blame] | 4034 | if ((hw->mac.type != e1000_ich8lan) || (hw->phy.type == e1000_phy_ife)) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4035 | return; |
| 4036 | |
| 4037 | ret_val = e1000e_read_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET, |
Bruce Allan | 17e813e | 2013-02-20 04:06:01 +0000 | [diff] [blame] | 4038 | ®_data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4039 | if (ret_val) |
| 4040 | return; |
| 4041 | reg_data |= E1000_KMRNCTRLSTA_DIAG_NELPBK; |
| 4042 | ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET, |
Bruce Allan | 17e813e | 2013-02-20 04:06:01 +0000 | [diff] [blame] | 4043 | reg_data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4044 | if (ret_val) |
| 4045 | return; |
| 4046 | reg_data &= ~E1000_KMRNCTRLSTA_DIAG_NELPBK; |
Bruce Allan | 7dbbe5d | 2013-01-05 05:08:31 +0000 | [diff] [blame] | 4047 | e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET, reg_data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4048 | } |
| 4049 | |
| 4050 | /** |
Bruce Allan | 99730e4 | 2011-05-13 07:19:48 +0000 | [diff] [blame] | 4051 | * e1000_suspend_workarounds_ich8lan - workarounds needed during S0->Sx |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 4052 | * @hw: pointer to the HW structure |
| 4053 | * |
| 4054 | * During S0 to Sx transition, it is possible the link remains at gig |
| 4055 | * instead of negotiating to a lower speed. Before going to Sx, set |
Bruce Allan | c077a90 | 2011-12-16 00:46:38 +0000 | [diff] [blame] | 4056 | * 'Gig Disable' to force link speed negotiation to a lower speed based on |
| 4057 | * the LPLU setting in the NVM or custom setting. For PCH and newer parts, |
| 4058 | * the OEM bits PHY register (LED, GbE disable and LPLU configurations) also |
| 4059 | * needs to be written. |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4060 | * Parts that support (and are linked to a partner which support) EEE in |
| 4061 | * 100Mbps should disable LPLU since 100Mbps w/ EEE requires less power |
| 4062 | * than 10Mbps w/o EEE. |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 4063 | **/ |
Bruce Allan | 99730e4 | 2011-05-13 07:19:48 +0000 | [diff] [blame] | 4064 | void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw) |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 4065 | { |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4066 | struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 4067 | u32 phy_ctrl; |
Bruce Allan | 8395ae8 | 2010-09-22 17:15:08 +0000 | [diff] [blame] | 4068 | s32 ret_val; |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 4069 | |
Bruce Allan | 17f085d | 2010-06-17 18:59:48 +0000 | [diff] [blame] | 4070 | phy_ctrl = er32(PHY_CTRL); |
Bruce Allan | c077a90 | 2011-12-16 00:46:38 +0000 | [diff] [blame] | 4071 | phy_ctrl |= E1000_PHY_CTRL_GBE_DISABLE; |
Bruce Allan | e08f626 | 2013-02-20 03:06:34 +0000 | [diff] [blame] | 4072 | |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4073 | if (hw->phy.type == e1000_phy_i217) { |
Bruce Allan | e08f626 | 2013-02-20 03:06:34 +0000 | [diff] [blame] | 4074 | u16 phy_reg, device_id = hw->adapter->pdev->device; |
| 4075 | |
| 4076 | if ((device_id == E1000_DEV_ID_PCH_LPTLP_I218_LM) || |
| 4077 | (device_id == E1000_DEV_ID_PCH_LPTLP_I218_V)) { |
| 4078 | u32 fextnvm6 = er32(FEXTNVM6); |
| 4079 | |
| 4080 | ew32(FEXTNVM6, fextnvm6 & ~E1000_FEXTNVM6_REQ_PLL_CLK); |
| 4081 | } |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4082 | |
| 4083 | ret_val = hw->phy.ops.acquire(hw); |
| 4084 | if (ret_val) |
| 4085 | goto out; |
| 4086 | |
| 4087 | if (!dev_spec->eee_disable) { |
| 4088 | u16 eee_advert; |
| 4089 | |
Bruce Allan | 4ddc48a | 2012-12-05 06:25:58 +0000 | [diff] [blame] | 4090 | ret_val = |
| 4091 | e1000_read_emi_reg_locked(hw, |
| 4092 | I217_EEE_ADVERTISEMENT, |
| 4093 | &eee_advert); |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4094 | if (ret_val) |
| 4095 | goto release; |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4096 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 4097 | /* Disable LPLU if both link partners support 100BaseT |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4098 | * EEE and 100Full is advertised on both ends of the |
| 4099 | * link. |
| 4100 | */ |
Bruce Allan | 3d4d575 | 2012-12-05 06:26:08 +0000 | [diff] [blame] | 4101 | if ((eee_advert & I82579_EEE_100_SUPPORTED) && |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4102 | (dev_spec->eee_lp_ability & |
Bruce Allan | 3d4d575 | 2012-12-05 06:26:08 +0000 | [diff] [blame] | 4103 | I82579_EEE_100_SUPPORTED) && |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4104 | (hw->phy.autoneg_advertised & ADVERTISE_100_FULL)) |
| 4105 | phy_ctrl &= ~(E1000_PHY_CTRL_D0A_LPLU | |
| 4106 | E1000_PHY_CTRL_NOND0A_LPLU); |
| 4107 | } |
| 4108 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 4109 | /* For i217 Intel Rapid Start Technology support, |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4110 | * when the system is going into Sx and no manageability engine |
| 4111 | * is present, the driver must configure proxy to reset only on |
| 4112 | * power good. LPI (Low Power Idle) state must also reset only |
| 4113 | * on power good, as well as the MTA (Multicast table array). |
| 4114 | * The SMBus release must also be disabled on LCD reset. |
| 4115 | */ |
| 4116 | if (!(er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) { |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4117 | /* Enable proxy to reset only on power good. */ |
| 4118 | e1e_rphy_locked(hw, I217_PROXY_CTRL, &phy_reg); |
| 4119 | phy_reg |= I217_PROXY_CTRL_AUTO_DISABLE; |
| 4120 | e1e_wphy_locked(hw, I217_PROXY_CTRL, phy_reg); |
| 4121 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 4122 | /* Set bit enable LPI (EEE) to reset only on |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4123 | * power good. |
| 4124 | */ |
| 4125 | e1e_rphy_locked(hw, I217_SxCTRL, &phy_reg); |
Bruce Allan | 6d7407b | 2012-05-10 02:51:17 +0000 | [diff] [blame] | 4126 | phy_reg |= I217_SxCTRL_ENABLE_LPI_RESET; |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4127 | e1e_wphy_locked(hw, I217_SxCTRL, phy_reg); |
| 4128 | |
| 4129 | /* Disable the SMB release on LCD reset. */ |
| 4130 | e1e_rphy_locked(hw, I217_MEMPWR, &phy_reg); |
Bruce Allan | 6d7407b | 2012-05-10 02:51:17 +0000 | [diff] [blame] | 4131 | phy_reg &= ~I217_MEMPWR_DISABLE_SMB_RELEASE; |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4132 | e1e_wphy_locked(hw, I217_MEMPWR, phy_reg); |
| 4133 | } |
| 4134 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 4135 | /* Enable MTA to reset for Intel Rapid Start Technology |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4136 | * Support |
| 4137 | */ |
| 4138 | e1e_rphy_locked(hw, I217_CGFREG, &phy_reg); |
Bruce Allan | 6d7407b | 2012-05-10 02:51:17 +0000 | [diff] [blame] | 4139 | phy_reg |= I217_CGFREG_ENABLE_MTA_RESET; |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4140 | e1e_wphy_locked(hw, I217_CGFREG, phy_reg); |
| 4141 | |
| 4142 | release: |
| 4143 | hw->phy.ops.release(hw); |
| 4144 | } |
| 4145 | out: |
Bruce Allan | 17f085d | 2010-06-17 18:59:48 +0000 | [diff] [blame] | 4146 | ew32(PHY_CTRL, phy_ctrl); |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4147 | |
Bruce Allan | 462d599 | 2011-09-30 08:07:11 +0000 | [diff] [blame] | 4148 | if (hw->mac.type == e1000_ich8lan) |
| 4149 | e1000e_gig_downshift_workaround_ich8lan(hw); |
| 4150 | |
Bruce Allan | 8395ae8 | 2010-09-22 17:15:08 +0000 | [diff] [blame] | 4151 | if (hw->mac.type >= e1000_pchlan) { |
Bruce Allan | ce54afd | 2010-11-24 06:01:41 +0000 | [diff] [blame] | 4152 | e1000_oem_bits_config_ich8lan(hw, false); |
Bruce Allan | 92fe173 | 2012-04-12 06:27:03 +0000 | [diff] [blame] | 4153 | |
| 4154 | /* Reset PHY to activate OEM bits on 82577/8 */ |
| 4155 | if (hw->mac.type == e1000_pchlan) |
| 4156 | e1000e_phy_hw_reset_generic(hw); |
| 4157 | |
Bruce Allan | 8395ae8 | 2010-09-22 17:15:08 +0000 | [diff] [blame] | 4158 | ret_val = hw->phy.ops.acquire(hw); |
| 4159 | if (ret_val) |
| 4160 | return; |
| 4161 | e1000_write_smbus_addr(hw); |
| 4162 | hw->phy.ops.release(hw); |
| 4163 | } |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 4164 | } |
| 4165 | |
| 4166 | /** |
Bruce Allan | 99730e4 | 2011-05-13 07:19:48 +0000 | [diff] [blame] | 4167 | * e1000_resume_workarounds_pchlan - workarounds needed during Sx->S0 |
| 4168 | * @hw: pointer to the HW structure |
| 4169 | * |
| 4170 | * During Sx to S0 transitions on non-managed devices or managed devices |
| 4171 | * on which PHY resets are not blocked, if the PHY registers cannot be |
| 4172 | * accessed properly by the s/w toggle the LANPHYPC value to power cycle |
| 4173 | * the PHY. |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4174 | * On i217, setup Intel Rapid Start Technology. |
Bruce Allan | 99730e4 | 2011-05-13 07:19:48 +0000 | [diff] [blame] | 4175 | **/ |
| 4176 | void e1000_resume_workarounds_pchlan(struct e1000_hw *hw) |
| 4177 | { |
Bruce Allan | 90b8298 | 2011-12-16 00:46:33 +0000 | [diff] [blame] | 4178 | s32 ret_val; |
Bruce Allan | 99730e4 | 2011-05-13 07:19:48 +0000 | [diff] [blame] | 4179 | |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 4180 | if (hw->mac.type < e1000_pch2lan) |
Bruce Allan | 99730e4 | 2011-05-13 07:19:48 +0000 | [diff] [blame] | 4181 | return; |
| 4182 | |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 4183 | ret_val = e1000_init_phy_workarounds_pchlan(hw); |
Bruce Allan | 90b8298 | 2011-12-16 00:46:33 +0000 | [diff] [blame] | 4184 | if (ret_val) { |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 4185 | e_dbg("Failed to init PHY flow ret_val=%d\n", ret_val); |
Bruce Allan | 99730e4 | 2011-05-13 07:19:48 +0000 | [diff] [blame] | 4186 | return; |
| 4187 | } |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4188 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 4189 | /* For i217 Intel Rapid Start Technology support when the system |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4190 | * is transitioning from Sx and no manageability engine is present |
| 4191 | * configure SMBus to restore on reset, disable proxy, and enable |
| 4192 | * the reset on MTA (Multicast table array). |
| 4193 | */ |
| 4194 | if (hw->phy.type == e1000_phy_i217) { |
| 4195 | u16 phy_reg; |
| 4196 | |
| 4197 | ret_val = hw->phy.ops.acquire(hw); |
| 4198 | if (ret_val) { |
| 4199 | e_dbg("Failed to setup iRST\n"); |
| 4200 | return; |
| 4201 | } |
| 4202 | |
| 4203 | if (!(er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) { |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 4204 | /* Restore clear on SMB if no manageability engine |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4205 | * is present |
| 4206 | */ |
| 4207 | ret_val = e1e_rphy_locked(hw, I217_MEMPWR, &phy_reg); |
| 4208 | if (ret_val) |
| 4209 | goto release; |
Bruce Allan | 6d7407b | 2012-05-10 02:51:17 +0000 | [diff] [blame] | 4210 | phy_reg |= I217_MEMPWR_DISABLE_SMB_RELEASE; |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4211 | e1e_wphy_locked(hw, I217_MEMPWR, phy_reg); |
| 4212 | |
| 4213 | /* Disable Proxy */ |
| 4214 | e1e_wphy_locked(hw, I217_PROXY_CTRL, 0); |
| 4215 | } |
| 4216 | /* Enable reset on MTA */ |
| 4217 | ret_val = e1e_rphy_locked(hw, I217_CGFREG, &phy_reg); |
| 4218 | if (ret_val) |
| 4219 | goto release; |
Bruce Allan | 6d7407b | 2012-05-10 02:51:17 +0000 | [diff] [blame] | 4220 | phy_reg &= ~I217_CGFREG_ENABLE_MTA_RESET; |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4221 | e1e_wphy_locked(hw, I217_CGFREG, phy_reg); |
| 4222 | release: |
| 4223 | if (ret_val) |
| 4224 | e_dbg("Error %d in resume workarounds\n", ret_val); |
| 4225 | hw->phy.ops.release(hw); |
| 4226 | } |
Bruce Allan | 99730e4 | 2011-05-13 07:19:48 +0000 | [diff] [blame] | 4227 | } |
| 4228 | |
| 4229 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4230 | * e1000_cleanup_led_ich8lan - Restore the default LED operation |
| 4231 | * @hw: pointer to the HW structure |
| 4232 | * |
| 4233 | * Return the LED back to the default configuration. |
| 4234 | **/ |
| 4235 | static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw) |
| 4236 | { |
| 4237 | if (hw->phy.type == e1000_phy_ife) |
| 4238 | return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED, 0); |
| 4239 | |
| 4240 | ew32(LEDCTL, hw->mac.ledctl_default); |
| 4241 | return 0; |
| 4242 | } |
| 4243 | |
| 4244 | /** |
Auke Kok | 489815c | 2008-02-21 15:11:07 -0800 | [diff] [blame] | 4245 | * e1000_led_on_ich8lan - Turn LEDs on |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4246 | * @hw: pointer to the HW structure |
| 4247 | * |
Auke Kok | 489815c | 2008-02-21 15:11:07 -0800 | [diff] [blame] | 4248 | * Turn on the LEDs. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4249 | **/ |
| 4250 | static s32 e1000_led_on_ich8lan(struct e1000_hw *hw) |
| 4251 | { |
| 4252 | if (hw->phy.type == e1000_phy_ife) |
| 4253 | return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED, |
| 4254 | (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_ON)); |
| 4255 | |
| 4256 | ew32(LEDCTL, hw->mac.ledctl_mode2); |
| 4257 | return 0; |
| 4258 | } |
| 4259 | |
| 4260 | /** |
Auke Kok | 489815c | 2008-02-21 15:11:07 -0800 | [diff] [blame] | 4261 | * e1000_led_off_ich8lan - Turn LEDs off |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4262 | * @hw: pointer to the HW structure |
| 4263 | * |
Auke Kok | 489815c | 2008-02-21 15:11:07 -0800 | [diff] [blame] | 4264 | * Turn off the LEDs. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4265 | **/ |
| 4266 | static s32 e1000_led_off_ich8lan(struct e1000_hw *hw) |
| 4267 | { |
| 4268 | if (hw->phy.type == e1000_phy_ife) |
| 4269 | return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED, |
Bruce Allan | 482fed8 | 2011-01-06 14:29:49 +0000 | [diff] [blame] | 4270 | (IFE_PSCL_PROBE_MODE | |
| 4271 | IFE_PSCL_PROBE_LEDS_OFF)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4272 | |
| 4273 | ew32(LEDCTL, hw->mac.ledctl_mode1); |
| 4274 | return 0; |
| 4275 | } |
| 4276 | |
| 4277 | /** |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4278 | * e1000_setup_led_pchlan - Configures SW controllable LED |
| 4279 | * @hw: pointer to the HW structure |
| 4280 | * |
| 4281 | * This prepares the SW controllable LED for use. |
| 4282 | **/ |
| 4283 | static s32 e1000_setup_led_pchlan(struct e1000_hw *hw) |
| 4284 | { |
Bruce Allan | 482fed8 | 2011-01-06 14:29:49 +0000 | [diff] [blame] | 4285 | return e1e_wphy(hw, HV_LED_CONFIG, (u16)hw->mac.ledctl_mode1); |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4286 | } |
| 4287 | |
| 4288 | /** |
| 4289 | * e1000_cleanup_led_pchlan - Restore the default LED operation |
| 4290 | * @hw: pointer to the HW structure |
| 4291 | * |
| 4292 | * Return the LED back to the default configuration. |
| 4293 | **/ |
| 4294 | static s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw) |
| 4295 | { |
Bruce Allan | 482fed8 | 2011-01-06 14:29:49 +0000 | [diff] [blame] | 4296 | return e1e_wphy(hw, HV_LED_CONFIG, (u16)hw->mac.ledctl_default); |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4297 | } |
| 4298 | |
| 4299 | /** |
| 4300 | * e1000_led_on_pchlan - Turn LEDs on |
| 4301 | * @hw: pointer to the HW structure |
| 4302 | * |
| 4303 | * Turn on the LEDs. |
| 4304 | **/ |
| 4305 | static s32 e1000_led_on_pchlan(struct e1000_hw *hw) |
| 4306 | { |
| 4307 | u16 data = (u16)hw->mac.ledctl_mode2; |
| 4308 | u32 i, led; |
| 4309 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 4310 | /* If no link, then turn LED on by setting the invert bit |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4311 | * for each LED that's mode is "link_up" in ledctl_mode2. |
| 4312 | */ |
| 4313 | if (!(er32(STATUS) & E1000_STATUS_LU)) { |
| 4314 | for (i = 0; i < 3; i++) { |
| 4315 | led = (data >> (i * 5)) & E1000_PHY_LED0_MASK; |
| 4316 | if ((led & E1000_PHY_LED0_MODE_MASK) != |
| 4317 | E1000_LEDCTL_MODE_LINK_UP) |
| 4318 | continue; |
| 4319 | if (led & E1000_PHY_LED0_IVRT) |
| 4320 | data &= ~(E1000_PHY_LED0_IVRT << (i * 5)); |
| 4321 | else |
| 4322 | data |= (E1000_PHY_LED0_IVRT << (i * 5)); |
| 4323 | } |
| 4324 | } |
| 4325 | |
Bruce Allan | 482fed8 | 2011-01-06 14:29:49 +0000 | [diff] [blame] | 4326 | return e1e_wphy(hw, HV_LED_CONFIG, data); |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4327 | } |
| 4328 | |
| 4329 | /** |
| 4330 | * e1000_led_off_pchlan - Turn LEDs off |
| 4331 | * @hw: pointer to the HW structure |
| 4332 | * |
| 4333 | * Turn off the LEDs. |
| 4334 | **/ |
| 4335 | static s32 e1000_led_off_pchlan(struct e1000_hw *hw) |
| 4336 | { |
| 4337 | u16 data = (u16)hw->mac.ledctl_mode1; |
| 4338 | u32 i, led; |
| 4339 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 4340 | /* If no link, then turn LED off by clearing the invert bit |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4341 | * for each LED that's mode is "link_up" in ledctl_mode1. |
| 4342 | */ |
| 4343 | if (!(er32(STATUS) & E1000_STATUS_LU)) { |
| 4344 | for (i = 0; i < 3; i++) { |
| 4345 | led = (data >> (i * 5)) & E1000_PHY_LED0_MASK; |
| 4346 | if ((led & E1000_PHY_LED0_MODE_MASK) != |
| 4347 | E1000_LEDCTL_MODE_LINK_UP) |
| 4348 | continue; |
| 4349 | if (led & E1000_PHY_LED0_IVRT) |
| 4350 | data &= ~(E1000_PHY_LED0_IVRT << (i * 5)); |
| 4351 | else |
| 4352 | data |= (E1000_PHY_LED0_IVRT << (i * 5)); |
| 4353 | } |
| 4354 | } |
| 4355 | |
Bruce Allan | 482fed8 | 2011-01-06 14:29:49 +0000 | [diff] [blame] | 4356 | return e1e_wphy(hw, HV_LED_CONFIG, data); |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4357 | } |
| 4358 | |
| 4359 | /** |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 4360 | * e1000_get_cfg_done_ich8lan - Read config done bit after Full or PHY reset |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 4361 | * @hw: pointer to the HW structure |
| 4362 | * |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 4363 | * Read appropriate register for the config done bit for completion status |
| 4364 | * and configure the PHY through s/w for EEPROM-less parts. |
| 4365 | * |
| 4366 | * NOTE: some silicon which is EEPROM-less will fail trying to read the |
| 4367 | * config done bit, so only an error is logged and continues. If we were |
| 4368 | * to return with error, EEPROM-less silicon would not be able to be reset |
| 4369 | * or change link. |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 4370 | **/ |
| 4371 | static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw) |
| 4372 | { |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 4373 | s32 ret_val = 0; |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 4374 | u32 bank = 0; |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 4375 | u32 status; |
Bruce Allan | fc0c776 | 2009-07-01 13:27:55 +0000 | [diff] [blame] | 4376 | |
Bruce Allan | fe90849 | 2013-01-05 08:06:14 +0000 | [diff] [blame] | 4377 | e1000e_get_cfg_done_generic(hw); |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 4378 | |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 4379 | /* Wait for indication from h/w that it has completed basic config */ |
| 4380 | if (hw->mac.type >= e1000_ich10lan) { |
| 4381 | e1000_lan_init_done_ich8lan(hw); |
| 4382 | } else { |
| 4383 | ret_val = e1000e_get_auto_rd_done(hw); |
| 4384 | if (ret_val) { |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 4385 | /* When auto config read does not complete, do not |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 4386 | * return with an error. This can happen in situations |
| 4387 | * where there is no eeprom and prevents getting link. |
| 4388 | */ |
| 4389 | e_dbg("Auto Read Done did not complete\n"); |
| 4390 | ret_val = 0; |
| 4391 | } |
| 4392 | } |
| 4393 | |
| 4394 | /* Clear PHY Reset Asserted bit */ |
| 4395 | status = er32(STATUS); |
| 4396 | if (status & E1000_STATUS_PHYRA) |
| 4397 | ew32(STATUS, status & ~E1000_STATUS_PHYRA); |
| 4398 | else |
| 4399 | e_dbg("PHY Reset Asserted not set - needs delay\n"); |
| 4400 | |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 4401 | /* If EEPROM is not marked present, init the IGP 3 PHY manually */ |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 4402 | if (hw->mac.type <= e1000_ich9lan) { |
Bruce Allan | 04499ec | 2012-04-13 00:08:31 +0000 | [diff] [blame] | 4403 | if (!(er32(EECD) & E1000_EECD_PRES) && |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 4404 | (hw->phy.type == e1000_phy_igp_3)) { |
| 4405 | e1000e_phy_init_script_igp3(hw); |
| 4406 | } |
| 4407 | } else { |
| 4408 | if (e1000_valid_nvm_bank_detect_ich8lan(hw, &bank)) { |
| 4409 | /* Maybe we should do a basic PHY config */ |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 4410 | e_dbg("EEPROM not present\n"); |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 4411 | ret_val = -E1000_ERR_CONFIG; |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 4412 | } |
| 4413 | } |
| 4414 | |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 4415 | return ret_val; |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 4416 | } |
| 4417 | |
| 4418 | /** |
Bruce Allan | 17f208d | 2009-12-01 15:47:22 +0000 | [diff] [blame] | 4419 | * e1000_power_down_phy_copper_ich8lan - Remove link during PHY power down |
| 4420 | * @hw: pointer to the HW structure |
| 4421 | * |
| 4422 | * In the case of a PHY power down to save power, or to turn off link during a |
| 4423 | * driver unload, or wake on lan is not enabled, remove the link. |
| 4424 | **/ |
| 4425 | static void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw) |
| 4426 | { |
| 4427 | /* If the management interface is not enabled, then power down */ |
| 4428 | if (!(hw->mac.ops.check_mng_mode(hw) || |
| 4429 | hw->phy.ops.check_reset_block(hw))) |
| 4430 | e1000_power_down_phy_copper(hw); |
Bruce Allan | 17f208d | 2009-12-01 15:47:22 +0000 | [diff] [blame] | 4431 | } |
| 4432 | |
| 4433 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4434 | * e1000_clear_hw_cntrs_ich8lan - Clear statistical counters |
| 4435 | * @hw: pointer to the HW structure |
| 4436 | * |
| 4437 | * Clears hardware counters specific to the silicon family and calls |
| 4438 | * clear_hw_cntrs_generic to clear all general purpose counters. |
| 4439 | **/ |
| 4440 | static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw) |
| 4441 | { |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4442 | u16 phy_data; |
Bruce Allan | 2b6b168 | 2011-05-13 07:20:09 +0000 | [diff] [blame] | 4443 | s32 ret_val; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4444 | |
| 4445 | e1000e_clear_hw_cntrs_base(hw); |
| 4446 | |
Bruce Allan | 99673d9 | 2009-11-20 23:27:21 +0000 | [diff] [blame] | 4447 | er32(ALGNERRC); |
| 4448 | er32(RXERRC); |
| 4449 | er32(TNCRS); |
| 4450 | er32(CEXTERR); |
| 4451 | er32(TSCTC); |
| 4452 | er32(TSCTFC); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4453 | |
Bruce Allan | 99673d9 | 2009-11-20 23:27:21 +0000 | [diff] [blame] | 4454 | er32(MGTPRC); |
| 4455 | er32(MGTPDC); |
| 4456 | er32(MGTPTC); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4457 | |
Bruce Allan | 99673d9 | 2009-11-20 23:27:21 +0000 | [diff] [blame] | 4458 | er32(IAC); |
| 4459 | er32(ICRXOC); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4460 | |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4461 | /* Clear PHY statistics registers */ |
| 4462 | if ((hw->phy.type == e1000_phy_82578) || |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 4463 | (hw->phy.type == e1000_phy_82579) || |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4464 | (hw->phy.type == e1000_phy_i217) || |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4465 | (hw->phy.type == e1000_phy_82577)) { |
Bruce Allan | 2b6b168 | 2011-05-13 07:20:09 +0000 | [diff] [blame] | 4466 | ret_val = hw->phy.ops.acquire(hw); |
| 4467 | if (ret_val) |
| 4468 | return; |
| 4469 | ret_val = hw->phy.ops.set_page(hw, |
| 4470 | HV_STATS_PAGE << IGP_PAGE_SHIFT); |
| 4471 | if (ret_val) |
| 4472 | goto release; |
| 4473 | hw->phy.ops.read_reg_page(hw, HV_SCC_UPPER, &phy_data); |
| 4474 | hw->phy.ops.read_reg_page(hw, HV_SCC_LOWER, &phy_data); |
| 4475 | hw->phy.ops.read_reg_page(hw, HV_ECOL_UPPER, &phy_data); |
| 4476 | hw->phy.ops.read_reg_page(hw, HV_ECOL_LOWER, &phy_data); |
| 4477 | hw->phy.ops.read_reg_page(hw, HV_MCC_UPPER, &phy_data); |
| 4478 | hw->phy.ops.read_reg_page(hw, HV_MCC_LOWER, &phy_data); |
| 4479 | hw->phy.ops.read_reg_page(hw, HV_LATECOL_UPPER, &phy_data); |
| 4480 | hw->phy.ops.read_reg_page(hw, HV_LATECOL_LOWER, &phy_data); |
| 4481 | hw->phy.ops.read_reg_page(hw, HV_COLC_UPPER, &phy_data); |
| 4482 | hw->phy.ops.read_reg_page(hw, HV_COLC_LOWER, &phy_data); |
| 4483 | hw->phy.ops.read_reg_page(hw, HV_DC_UPPER, &phy_data); |
| 4484 | hw->phy.ops.read_reg_page(hw, HV_DC_LOWER, &phy_data); |
| 4485 | hw->phy.ops.read_reg_page(hw, HV_TNCRS_UPPER, &phy_data); |
| 4486 | hw->phy.ops.read_reg_page(hw, HV_TNCRS_LOWER, &phy_data); |
| 4487 | release: |
| 4488 | hw->phy.ops.release(hw); |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4489 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4490 | } |
| 4491 | |
Jeff Kirsher | 8ce9d6c | 2011-09-24 13:23:52 +0000 | [diff] [blame] | 4492 | static const struct e1000_mac_operations ich8_mac_ops = { |
Bruce Allan | eb7700d | 2010-06-16 13:27:05 +0000 | [diff] [blame] | 4493 | /* check_mng_mode dependent on mac type */ |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 4494 | .check_for_link = e1000_check_for_copper_link_ich8lan, |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4495 | /* cleanup_led dependent on mac type */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4496 | .clear_hw_cntrs = e1000_clear_hw_cntrs_ich8lan, |
| 4497 | .get_bus_info = e1000_get_bus_info_ich8lan, |
Bruce Allan | f4d2dd4 | 2010-01-13 02:05:18 +0000 | [diff] [blame] | 4498 | .set_lan_id = e1000_set_lan_id_single_port, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4499 | .get_link_up_info = e1000_get_link_up_info_ich8lan, |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4500 | /* led_on dependent on mac type */ |
| 4501 | /* led_off dependent on mac type */ |
Jeff Kirsher | e2de3eb | 2008-03-28 09:15:11 -0700 | [diff] [blame] | 4502 | .update_mc_addr_list = e1000e_update_mc_addr_list_generic, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4503 | .reset_hw = e1000_reset_hw_ich8lan, |
| 4504 | .init_hw = e1000_init_hw_ich8lan, |
| 4505 | .setup_link = e1000_setup_link_ich8lan, |
Bruce Allan | 55c5f55 | 2013-01-12 07:28:24 +0000 | [diff] [blame] | 4506 | .setup_physical_interface = e1000_setup_copper_link_ich8lan, |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4507 | /* id_led_init dependent on mac type */ |
Bruce Allan | 57cde76 | 2012-02-22 09:02:58 +0000 | [diff] [blame] | 4508 | .config_collision_dist = e1000e_config_collision_dist_generic, |
Bruce Allan | 69e1e01 | 2012-04-14 03:28:50 +0000 | [diff] [blame] | 4509 | .rar_set = e1000e_rar_set_generic, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4510 | }; |
| 4511 | |
Jeff Kirsher | 8ce9d6c | 2011-09-24 13:23:52 +0000 | [diff] [blame] | 4512 | static const struct e1000_phy_operations ich8_phy_ops = { |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 4513 | .acquire = e1000_acquire_swflag_ich8lan, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4514 | .check_reset_block = e1000_check_reset_block_ich8lan, |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 4515 | .commit = NULL, |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 4516 | .get_cfg_done = e1000_get_cfg_done_ich8lan, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4517 | .get_cable_length = e1000e_get_cable_length_igp_2, |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 4518 | .read_reg = e1000e_read_phy_reg_igp, |
| 4519 | .release = e1000_release_swflag_ich8lan, |
| 4520 | .reset = e1000_phy_hw_reset_ich8lan, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4521 | .set_d0_lplu_state = e1000_set_d0_lplu_state_ich8lan, |
| 4522 | .set_d3_lplu_state = e1000_set_d3_lplu_state_ich8lan, |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 4523 | .write_reg = e1000e_write_phy_reg_igp, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4524 | }; |
| 4525 | |
Jeff Kirsher | 8ce9d6c | 2011-09-24 13:23:52 +0000 | [diff] [blame] | 4526 | static const struct e1000_nvm_operations ich8_nvm_ops = { |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 4527 | .acquire = e1000_acquire_nvm_ich8lan, |
Bruce Allan | 55c5f55 | 2013-01-12 07:28:24 +0000 | [diff] [blame] | 4528 | .read = e1000_read_nvm_ich8lan, |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 4529 | .release = e1000_release_nvm_ich8lan, |
Bruce Allan | e85e363 | 2012-02-22 09:03:14 +0000 | [diff] [blame] | 4530 | .reload = e1000e_reload_nvm_generic, |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 4531 | .update = e1000_update_nvm_checksum_ich8lan, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4532 | .valid_led_default = e1000_valid_led_default_ich8lan, |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 4533 | .validate = e1000_validate_nvm_checksum_ich8lan, |
| 4534 | .write = e1000_write_nvm_ich8lan, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4535 | }; |
| 4536 | |
Jeff Kirsher | 8ce9d6c | 2011-09-24 13:23:52 +0000 | [diff] [blame] | 4537 | const struct e1000_info e1000_ich8_info = { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4538 | .mac = e1000_ich8lan, |
| 4539 | .flags = FLAG_HAS_WOL |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 4540 | | FLAG_IS_ICH |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4541 | | FLAG_HAS_CTRLEXT_ON_LOAD |
| 4542 | | FLAG_HAS_AMT |
| 4543 | | FLAG_HAS_FLASH |
| 4544 | | FLAG_APME_IN_WUC, |
| 4545 | .pba = 8, |
Bruce Allan | 2adc55c | 2009-06-02 11:28:58 +0000 | [diff] [blame] | 4546 | .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN, |
Jeff Kirsher | 69e3fd8 | 2008-04-02 13:48:18 -0700 | [diff] [blame] | 4547 | .get_variants = e1000_get_variants_ich8lan, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4548 | .mac_ops = &ich8_mac_ops, |
| 4549 | .phy_ops = &ich8_phy_ops, |
| 4550 | .nvm_ops = &ich8_nvm_ops, |
| 4551 | }; |
| 4552 | |
Jeff Kirsher | 8ce9d6c | 2011-09-24 13:23:52 +0000 | [diff] [blame] | 4553 | const struct e1000_info e1000_ich9_info = { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4554 | .mac = e1000_ich9lan, |
| 4555 | .flags = FLAG_HAS_JUMBO_FRAMES |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 4556 | | FLAG_IS_ICH |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4557 | | FLAG_HAS_WOL |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4558 | | FLAG_HAS_CTRLEXT_ON_LOAD |
| 4559 | | FLAG_HAS_AMT |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4560 | | FLAG_HAS_FLASH |
| 4561 | | FLAG_APME_IN_WUC, |
Bruce Allan | 7f1557e | 2011-12-16 00:46:43 +0000 | [diff] [blame] | 4562 | .pba = 18, |
Bruce Allan | 2adc55c | 2009-06-02 11:28:58 +0000 | [diff] [blame] | 4563 | .max_hw_frame_size = DEFAULT_JUMBO, |
Jeff Kirsher | 69e3fd8 | 2008-04-02 13:48:18 -0700 | [diff] [blame] | 4564 | .get_variants = e1000_get_variants_ich8lan, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4565 | .mac_ops = &ich8_mac_ops, |
| 4566 | .phy_ops = &ich8_phy_ops, |
| 4567 | .nvm_ops = &ich8_nvm_ops, |
| 4568 | }; |
| 4569 | |
Jeff Kirsher | 8ce9d6c | 2011-09-24 13:23:52 +0000 | [diff] [blame] | 4570 | const struct e1000_info e1000_ich10_info = { |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 4571 | .mac = e1000_ich10lan, |
| 4572 | .flags = FLAG_HAS_JUMBO_FRAMES |
| 4573 | | FLAG_IS_ICH |
| 4574 | | FLAG_HAS_WOL |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 4575 | | FLAG_HAS_CTRLEXT_ON_LOAD |
| 4576 | | FLAG_HAS_AMT |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 4577 | | FLAG_HAS_FLASH |
| 4578 | | FLAG_APME_IN_WUC, |
Bruce Allan | 7f1557e | 2011-12-16 00:46:43 +0000 | [diff] [blame] | 4579 | .pba = 18, |
Bruce Allan | 2adc55c | 2009-06-02 11:28:58 +0000 | [diff] [blame] | 4580 | .max_hw_frame_size = DEFAULT_JUMBO, |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 4581 | .get_variants = e1000_get_variants_ich8lan, |
| 4582 | .mac_ops = &ich8_mac_ops, |
| 4583 | .phy_ops = &ich8_phy_ops, |
| 4584 | .nvm_ops = &ich8_nvm_ops, |
| 4585 | }; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4586 | |
Jeff Kirsher | 8ce9d6c | 2011-09-24 13:23:52 +0000 | [diff] [blame] | 4587 | const struct e1000_info e1000_pch_info = { |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4588 | .mac = e1000_pchlan, |
| 4589 | .flags = FLAG_IS_ICH |
| 4590 | | FLAG_HAS_WOL |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4591 | | FLAG_HAS_CTRLEXT_ON_LOAD |
| 4592 | | FLAG_HAS_AMT |
| 4593 | | FLAG_HAS_FLASH |
| 4594 | | FLAG_HAS_JUMBO_FRAMES |
Bruce Allan | 38eb394 | 2009-11-19 12:34:20 +0000 | [diff] [blame] | 4595 | | FLAG_DISABLE_FC_PAUSE_TIME /* errata */ |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4596 | | FLAG_APME_IN_WUC, |
Bruce Allan | 8c7bbb9 | 2010-06-16 13:26:41 +0000 | [diff] [blame] | 4597 | .flags2 = FLAG2_HAS_PHY_STATS, |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4598 | .pba = 26, |
| 4599 | .max_hw_frame_size = 4096, |
| 4600 | .get_variants = e1000_get_variants_ich8lan, |
| 4601 | .mac_ops = &ich8_mac_ops, |
| 4602 | .phy_ops = &ich8_phy_ops, |
| 4603 | .nvm_ops = &ich8_nvm_ops, |
| 4604 | }; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 4605 | |
Jeff Kirsher | 8ce9d6c | 2011-09-24 13:23:52 +0000 | [diff] [blame] | 4606 | const struct e1000_info e1000_pch2_info = { |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 4607 | .mac = e1000_pch2lan, |
| 4608 | .flags = FLAG_IS_ICH |
| 4609 | | FLAG_HAS_WOL |
Bruce Allan | b67e191 | 2012-12-27 08:32:33 +0000 | [diff] [blame] | 4610 | | FLAG_HAS_HW_TIMESTAMP |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 4611 | | FLAG_HAS_CTRLEXT_ON_LOAD |
| 4612 | | FLAG_HAS_AMT |
| 4613 | | FLAG_HAS_FLASH |
| 4614 | | FLAG_HAS_JUMBO_FRAMES |
| 4615 | | FLAG_APME_IN_WUC, |
Bruce Allan | e52997f | 2010-06-16 13:27:49 +0000 | [diff] [blame] | 4616 | .flags2 = FLAG2_HAS_PHY_STATS |
| 4617 | | FLAG2_HAS_EEE, |
Bruce Allan | 828bac8 | 2010-09-29 21:39:37 +0000 | [diff] [blame] | 4618 | .pba = 26, |
Bruce Allan | c3d2dbf | 2013-01-09 01:20:46 +0000 | [diff] [blame] | 4619 | .max_hw_frame_size = 9018, |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 4620 | .get_variants = e1000_get_variants_ich8lan, |
| 4621 | .mac_ops = &ich8_mac_ops, |
| 4622 | .phy_ops = &ich8_phy_ops, |
| 4623 | .nvm_ops = &ich8_nvm_ops, |
| 4624 | }; |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4625 | |
| 4626 | const struct e1000_info e1000_pch_lpt_info = { |
| 4627 | .mac = e1000_pch_lpt, |
| 4628 | .flags = FLAG_IS_ICH |
| 4629 | | FLAG_HAS_WOL |
Bruce Allan | b67e191 | 2012-12-27 08:32:33 +0000 | [diff] [blame] | 4630 | | FLAG_HAS_HW_TIMESTAMP |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4631 | | FLAG_HAS_CTRLEXT_ON_LOAD |
| 4632 | | FLAG_HAS_AMT |
| 4633 | | FLAG_HAS_FLASH |
| 4634 | | FLAG_HAS_JUMBO_FRAMES |
| 4635 | | FLAG_APME_IN_WUC, |
| 4636 | .flags2 = FLAG2_HAS_PHY_STATS |
| 4637 | | FLAG2_HAS_EEE, |
| 4638 | .pba = 26, |
Bruce Allan | ed1a426 | 2013-01-04 09:51:36 +0000 | [diff] [blame] | 4639 | .max_hw_frame_size = 9018, |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4640 | .get_variants = e1000_get_variants_ich8lan, |
| 4641 | .mac_ops = &ich8_mac_ops, |
| 4642 | .phy_ops = &ich8_phy_ops, |
| 4643 | .nvm_ops = &ich8_nvm_ops, |
| 4644 | }; |