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