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