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