blob: 6ff7ff5f2c76d29ca5267aa575c64734685a9c0b [file] [log] [blame]
Auke Kokbc7f75f2007-09-17 12:30:59 -07001/*******************************************************************************
2
3 Intel PRO/1000 Linux driver
Bruce Allanbf670442013-01-01 16:00:01 +00004 Copyright(c) 1999 - 2013 Intel Corporation.
Auke Kokbc7f75f2007-09-17 12:30:59 -07005
6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License,
8 version 2, as published by the Free Software Foundation.
9
10 This program is distributed in the hope it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 more details.
14
15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
21
22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
27*******************************************************************************/
28
Bruce Allane921eb12012-11-28 09:28:37 +000029/* 82562G 10/100 Network Connection
Auke Kokbc7f75f2007-09-17 12:30:59 -070030 * 82562G-2 10/100 Network Connection
31 * 82562GT 10/100 Network Connection
32 * 82562GT-2 10/100 Network Connection
33 * 82562V 10/100 Network Connection
34 * 82562V-2 10/100 Network Connection
35 * 82566DC-2 Gigabit Network Connection
36 * 82566DC Gigabit Network Connection
37 * 82566DM-2 Gigabit Network Connection
38 * 82566DM Gigabit Network Connection
39 * 82566MC Gigabit Network Connection
40 * 82566MM Gigabit Network Connection
Bruce Allan97ac8ca2008-04-29 09:16:05 -070041 * 82567LM Gigabit Network Connection
42 * 82567LF Gigabit Network Connection
Bruce Allan16059272008-11-21 16:51:06 -080043 * 82567V Gigabit Network Connection
Bruce Allan97ac8ca2008-04-29 09:16:05 -070044 * 82567LM-2 Gigabit Network Connection
45 * 82567LF-2 Gigabit Network Connection
46 * 82567V-2 Gigabit Network Connection
Bruce Allanf4187b52008-08-26 18:36:50 -070047 * 82567LF-3 Gigabit Network Connection
48 * 82567LM-3 Gigabit Network Connection
Bruce Allan2f15f9d2008-08-26 18:36:36 -070049 * 82567LM-4 Gigabit Network Connection
Bruce Allana4f58f52009-06-02 11:29:18 +000050 * 82577LM Gigabit Network Connection
51 * 82577LC Gigabit Network Connection
52 * 82578DM Gigabit Network Connection
53 * 82578DC Gigabit Network Connection
Bruce Alland3738bb2010-06-16 13:27:28 +000054 * 82579LM Gigabit Network Connection
55 * 82579V Gigabit Network Connection
Auke Kokbc7f75f2007-09-17 12:30:59 -070056 */
57
Auke Kokbc7f75f2007-09-17 12:30:59 -070058#include "e1000.h"
59
Auke Kokbc7f75f2007-09-17 12:30:59 -070060/* ICH GbE Flash Hardware Sequencing Flash Status Register bit breakdown */
61/* Offset 04h HSFSTS */
62union ich8_hws_flash_status {
63 struct ich8_hsfsts {
Bruce Allan362e20c2013-02-20 04:05:45 +000064 u16 flcdone:1; /* bit 0 Flash Cycle Done */
65 u16 flcerr:1; /* bit 1 Flash Cycle Error */
66 u16 dael:1; /* bit 2 Direct Access error Log */
67 u16 berasesz:2; /* bit 4:3 Sector Erase Size */
68 u16 flcinprog:1; /* bit 5 flash cycle in Progress */
69 u16 reserved1:2; /* bit 13:6 Reserved */
70 u16 reserved2:6; /* bit 13:6 Reserved */
71 u16 fldesvalid:1; /* bit 14 Flash Descriptor Valid */
72 u16 flockdn:1; /* bit 15 Flash Config Lock-Down */
Auke Kokbc7f75f2007-09-17 12:30:59 -070073 } hsf_status;
74 u16 regval;
75};
76
77/* ICH GbE Flash Hardware Sequencing Flash control Register bit breakdown */
78/* Offset 06h FLCTL */
79union ich8_hws_flash_ctrl {
80 struct ich8_hsflctl {
Bruce Allan362e20c2013-02-20 04:05:45 +000081 u16 flcgo:1; /* 0 Flash Cycle Go */
82 u16 flcycle:2; /* 2:1 Flash Cycle */
83 u16 reserved:5; /* 7:3 Reserved */
84 u16 fldbcount:2; /* 9:8 Flash Data Byte Count */
85 u16 flockdn:6; /* 15:10 Reserved */
Auke Kokbc7f75f2007-09-17 12:30:59 -070086 } hsf_ctrl;
87 u16 regval;
88};
89
90/* ICH Flash Region Access Permissions */
91union ich8_hws_flash_regacc {
92 struct ich8_flracc {
Bruce Allan362e20c2013-02-20 04:05:45 +000093 u32 grra:8; /* 0:7 GbE region Read Access */
94 u32 grwa:8; /* 8:15 GbE region Write Access */
95 u32 gmrag:8; /* 23:16 GbE Master Read Access Grant */
96 u32 gmwag:8; /* 31:24 GbE Master Write Access Grant */
Auke Kokbc7f75f2007-09-17 12:30:59 -070097 } hsf_flregacc;
98 u16 regval;
99};
100
Bruce Allan4a770352008-10-01 17:18:35 -0700101/* ICH Flash Protected Region */
102union ich8_flash_protected_range {
103 struct ich8_pr {
104 u32 base:13; /* 0:12 Protected Range Base */
105 u32 reserved1:2; /* 13:14 Reserved */
106 u32 rpe:1; /* 15 Read Protection Enable */
107 u32 limit:13; /* 16:28 Protected Range Limit */
108 u32 reserved2:2; /* 29:30 Reserved */
109 u32 wpe:1; /* 31 Write Protection Enable */
110 } range;
111 u32 regval;
112};
113
Auke Kokbc7f75f2007-09-17 12:30:59 -0700114static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw);
115static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700116static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank);
117static s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw,
118 u32 offset, u8 byte);
Bruce Allanf4187b52008-08-26 18:36:50 -0700119static s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
120 u8 *data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700121static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset,
122 u16 *data);
123static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
124 u8 size, u16 *data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700125static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw);
Bruce Allana4f58f52009-06-02 11:29:18 +0000126static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw);
127static s32 e1000_led_on_ich8lan(struct e1000_hw *hw);
128static s32 e1000_led_off_ich8lan(struct e1000_hw *hw);
129static s32 e1000_id_led_init_pchlan(struct e1000_hw *hw);
130static s32 e1000_setup_led_pchlan(struct e1000_hw *hw);
131static s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw);
132static s32 e1000_led_on_pchlan(struct e1000_hw *hw);
133static s32 e1000_led_off_pchlan(struct e1000_hw *hw);
Bruce Allanfa2ce132009-10-26 11:23:25 +0000134static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active);
Bruce Allan17f208d2009-12-01 15:47:22 +0000135static void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw);
Bruce Allanf523d212009-10-29 13:45:45 +0000136static void e1000_lan_init_done_ich8lan(struct e1000_hw *hw);
Bruce Allan1f96012d2013-01-05 03:06:54 +0000137static s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link);
Bruce Allanfddaa1a2010-01-13 01:52:49 +0000138static s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw);
Bruce Allaneb7700d2010-06-16 13:27:05 +0000139static bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw);
140static bool e1000_check_mng_mode_pchlan(struct e1000_hw *hw);
Bruce Allan69e1e012012-04-14 03:28:50 +0000141static void e1000_rar_set_pch2lan(struct e1000_hw *hw, u8 *addr, u32 index);
Bruce Allan2fbe4522012-04-19 03:21:47 +0000142static void e1000_rar_set_pch_lpt(struct e1000_hw *hw, u8 *addr, u32 index);
Bruce Allan831bd2e2010-09-22 17:16:18 +0000143static s32 e1000_k1_workaround_lv(struct e1000_hw *hw);
Bruce Allan605c82b2010-09-22 17:17:01 +0000144static void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700145
146static inline u16 __er16flash(struct e1000_hw *hw, unsigned long reg)
147{
148 return readw(hw->flash_address + reg);
149}
150
151static inline u32 __er32flash(struct e1000_hw *hw, unsigned long reg)
152{
153 return readl(hw->flash_address + reg);
154}
155
156static inline void __ew16flash(struct e1000_hw *hw, unsigned long reg, u16 val)
157{
158 writew(val, hw->flash_address + reg);
159}
160
161static inline void __ew32flash(struct e1000_hw *hw, unsigned long reg, u32 val)
162{
163 writel(val, hw->flash_address + reg);
164}
165
166#define er16flash(reg) __er16flash(hw, (reg))
167#define er32flash(reg) __er32flash(hw, (reg))
Bruce Allan0e15df42012-01-31 06:37:11 +0000168#define ew16flash(reg, val) __ew16flash(hw, (reg), (val))
169#define ew32flash(reg, val) __ew32flash(hw, (reg), (val))
Auke Kokbc7f75f2007-09-17 12:30:59 -0700170
Bruce Allancb17aab2012-04-13 03:16:22 +0000171/**
172 * e1000_phy_is_accessible_pchlan - Check if able to access PHY registers
173 * @hw: pointer to the HW structure
174 *
175 * Test access to the PHY registers by reading the PHY ID registers. If
176 * the PHY ID is already known (e.g. resume path) compare it with known ID,
177 * otherwise assume the read PHY ID is correct if it is valid.
178 *
179 * Assumes the sw/fw/hw semaphore is already acquired.
180 **/
181static bool e1000_phy_is_accessible_pchlan(struct e1000_hw *hw)
Bruce Allan99730e42011-05-13 07:19:48 +0000182{
Bruce Allana52359b2012-07-14 04:23:58 +0000183 u16 phy_reg = 0;
184 u32 phy_id = 0;
185 s32 ret_val;
186 u16 retry_count;
Bruce Allan99730e42011-05-13 07:19:48 +0000187
Bruce Allana52359b2012-07-14 04:23:58 +0000188 for (retry_count = 0; retry_count < 2; retry_count++) {
Bruce Allanc2ade1a2013-01-16 08:54:35 +0000189 ret_val = e1e_rphy_locked(hw, MII_PHYSID1, &phy_reg);
Bruce Allana52359b2012-07-14 04:23:58 +0000190 if (ret_val || (phy_reg == 0xFFFF))
191 continue;
192 phy_id = (u32)(phy_reg << 16);
193
Bruce Allanc2ade1a2013-01-16 08:54:35 +0000194 ret_val = e1e_rphy_locked(hw, MII_PHYSID2, &phy_reg);
Bruce Allana52359b2012-07-14 04:23:58 +0000195 if (ret_val || (phy_reg == 0xFFFF)) {
196 phy_id = 0;
197 continue;
198 }
199 phy_id |= (u32)(phy_reg & PHY_REVISION_MASK);
200 break;
201 }
Bruce Allan62bc8132012-03-20 03:47:57 +0000202
Bruce Allancb17aab2012-04-13 03:16:22 +0000203 if (hw->phy.id) {
204 if (hw->phy.id == phy_id)
205 return true;
Bruce Allana52359b2012-07-14 04:23:58 +0000206 } else if (phy_id) {
207 hw->phy.id = phy_id;
208 hw->phy.revision = (u32)(phy_reg & ~PHY_REVISION_MASK);
Bruce Allancb17aab2012-04-13 03:16:22 +0000209 return true;
210 }
211
Bruce Allane921eb12012-11-28 09:28:37 +0000212 /* In case the PHY needs to be in mdio slow mode,
Bruce Allana52359b2012-07-14 04:23:58 +0000213 * set slow mode and try to get the PHY id again.
214 */
215 hw->phy.ops.release(hw);
216 ret_val = e1000_set_mdio_slow_mode_hv(hw);
217 if (!ret_val)
218 ret_val = e1000e_get_phy_id(hw);
219 hw->phy.ops.acquire(hw);
220
221 return !ret_val;
Bruce Allancb17aab2012-04-13 03:16:22 +0000222}
223
224/**
225 * e1000_init_phy_workarounds_pchlan - PHY initialization workarounds
226 * @hw: pointer to the HW structure
227 *
228 * Workarounds/flow necessary for PHY initialization during driver load
229 * and resume paths.
230 **/
231static s32 e1000_init_phy_workarounds_pchlan(struct e1000_hw *hw)
232{
233 u32 mac_reg, fwsm = er32(FWSM);
234 s32 ret_val;
Bruce Allan2fbe4522012-04-19 03:21:47 +0000235 u16 phy_reg;
Bruce Allancb17aab2012-04-13 03:16:22 +0000236
Bruce Allan6e928b72012-12-12 04:45:51 +0000237 /* Gate automatic PHY configuration by hardware on managed and
238 * non-managed 82579 and newer adapters.
239 */
240 e1000_gate_hw_phy_config_ich8lan(hw, true);
241
Bruce Allancb17aab2012-04-13 03:16:22 +0000242 ret_val = hw->phy.ops.acquire(hw);
243 if (ret_val) {
244 e_dbg("Failed to initialize PHY flow\n");
Bruce Allan6e928b72012-12-12 04:45:51 +0000245 goto out;
Bruce Allancb17aab2012-04-13 03:16:22 +0000246 }
247
Bruce Allane921eb12012-11-28 09:28:37 +0000248 /* The MAC-PHY interconnect may be in SMBus mode. If the PHY is
Bruce Allancb17aab2012-04-13 03:16:22 +0000249 * inaccessible and resetting the PHY is not blocked, toggle the
250 * LANPHYPC Value bit to force the interconnect to PCIe mode.
251 */
252 switch (hw->mac.type) {
Bruce Allan2fbe4522012-04-19 03:21:47 +0000253 case e1000_pch_lpt:
254 if (e1000_phy_is_accessible_pchlan(hw))
255 break;
256
Bruce Allane921eb12012-11-28 09:28:37 +0000257 /* Before toggling LANPHYPC, see if PHY is accessible by
Bruce Allan2fbe4522012-04-19 03:21:47 +0000258 * forcing MAC to SMBus mode first.
259 */
260 mac_reg = er32(CTRL_EXT);
261 mac_reg |= E1000_CTRL_EXT_FORCE_SMBUS;
262 ew32(CTRL_EXT, mac_reg);
263
264 /* fall-through */
Bruce Allancb17aab2012-04-13 03:16:22 +0000265 case e1000_pch2lan:
Bruce Allan2fbe4522012-04-19 03:21:47 +0000266 if (e1000_phy_is_accessible_pchlan(hw)) {
267 if (hw->mac.type == e1000_pch_lpt) {
268 /* Unforce SMBus mode in PHY */
269 e1e_rphy_locked(hw, CV_SMB_CTRL, &phy_reg);
270 phy_reg &= ~CV_SMB_CTRL_FORCE_SMBUS;
271 e1e_wphy_locked(hw, CV_SMB_CTRL, phy_reg);
272
273 /* Unforce SMBus mode in MAC */
274 mac_reg = er32(CTRL_EXT);
275 mac_reg &= ~E1000_CTRL_EXT_FORCE_SMBUS;
276 ew32(CTRL_EXT, mac_reg);
277 }
Bruce Allancb17aab2012-04-13 03:16:22 +0000278 break;
Bruce Allan2fbe4522012-04-19 03:21:47 +0000279 }
Bruce Allancb17aab2012-04-13 03:16:22 +0000280
281 /* fall-through */
282 case e1000_pchlan:
283 if ((hw->mac.type == e1000_pchlan) &&
284 (fwsm & E1000_ICH_FWSM_FW_VALID))
285 break;
286
287 if (hw->phy.ops.check_reset_block(hw)) {
288 e_dbg("Required LANPHYPC toggle blocked by ME\n");
289 break;
290 }
291
292 e_dbg("Toggling LANPHYPC\n");
293
294 /* Set Phy Config Counter to 50msec */
295 mac_reg = er32(FEXTNVM3);
296 mac_reg &= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK;
297 mac_reg |= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC;
298 ew32(FEXTNVM3, mac_reg);
299
Bruce Allan4e035102013-01-04 09:53:19 +0000300 if (hw->mac.type == e1000_pch_lpt) {
301 /* Toggling LANPHYPC brings the PHY out of SMBus mode
302 * So ensure that the MAC is also out of SMBus mode
303 */
304 mac_reg = er32(CTRL_EXT);
305 mac_reg &= ~E1000_CTRL_EXT_FORCE_SMBUS;
306 ew32(CTRL_EXT, mac_reg);
307 }
308
Bruce Allancb17aab2012-04-13 03:16:22 +0000309 /* Toggle LANPHYPC Value bit */
310 mac_reg = er32(CTRL);
311 mac_reg |= E1000_CTRL_LANPHYPC_OVERRIDE;
312 mac_reg &= ~E1000_CTRL_LANPHYPC_VALUE;
313 ew32(CTRL, mac_reg);
314 e1e_flush();
315 udelay(10);
316 mac_reg &= ~E1000_CTRL_LANPHYPC_OVERRIDE;
317 ew32(CTRL, mac_reg);
318 e1e_flush();
Bruce Allan2fbe4522012-04-19 03:21:47 +0000319 if (hw->mac.type < e1000_pch_lpt) {
320 msleep(50);
321 } else {
322 u16 count = 20;
323 do {
324 usleep_range(5000, 10000);
325 } while (!(er32(CTRL_EXT) &
326 E1000_CTRL_EXT_LPCD) && count--);
327 }
Bruce Allancb17aab2012-04-13 03:16:22 +0000328 break;
329 default:
330 break;
331 }
332
333 hw->phy.ops.release(hw);
334
Bruce Allane921eb12012-11-28 09:28:37 +0000335 /* Reset the PHY before any access to it. Doing so, ensures
Bruce Allancb17aab2012-04-13 03:16:22 +0000336 * that the PHY is in a known good state before we read/write
337 * PHY registers. The generic reset is sufficient here,
338 * because we haven't determined the PHY type yet.
339 */
340 ret_val = e1000e_phy_hw_reset_generic(hw);
341
Bruce Allan6e928b72012-12-12 04:45:51 +0000342out:
Bruce Allancb17aab2012-04-13 03:16:22 +0000343 /* Ungate automatic PHY configuration on non-managed 82579 */
344 if ((hw->mac.type == e1000_pch2lan) &&
345 !(fwsm & E1000_ICH_FWSM_FW_VALID)) {
346 usleep_range(10000, 20000);
347 e1000_gate_hw_phy_config_ich8lan(hw, false);
348 }
349
350 return ret_val;
Bruce Allan99730e42011-05-13 07:19:48 +0000351}
352
Auke Kokbc7f75f2007-09-17 12:30:59 -0700353/**
Bruce Allana4f58f52009-06-02 11:29:18 +0000354 * e1000_init_phy_params_pchlan - Initialize PHY function pointers
355 * @hw: pointer to the HW structure
356 *
357 * Initialize family-specific PHY parameters and function pointers.
358 **/
359static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw)
360{
361 struct e1000_phy_info *phy = &hw->phy;
Bruce Allan70806a72013-01-05 05:08:37 +0000362 s32 ret_val;
Bruce Allana4f58f52009-06-02 11:29:18 +0000363
364 phy->addr = 1;
365 phy->reset_delay_us = 100;
366
Bruce Allan2b6b1682011-05-13 07:20:09 +0000367 phy->ops.set_page = e1000_set_page_igp;
Bruce Allan94d81862009-11-20 23:25:26 +0000368 phy->ops.read_reg = e1000_read_phy_reg_hv;
369 phy->ops.read_reg_locked = e1000_read_phy_reg_hv_locked;
Bruce Allan2b6b1682011-05-13 07:20:09 +0000370 phy->ops.read_reg_page = e1000_read_phy_reg_page_hv;
Bruce Allanfa2ce132009-10-26 11:23:25 +0000371 phy->ops.set_d0_lplu_state = e1000_set_lplu_state_pchlan;
372 phy->ops.set_d3_lplu_state = e1000_set_lplu_state_pchlan;
Bruce Allan94d81862009-11-20 23:25:26 +0000373 phy->ops.write_reg = e1000_write_phy_reg_hv;
374 phy->ops.write_reg_locked = e1000_write_phy_reg_hv_locked;
Bruce Allan2b6b1682011-05-13 07:20:09 +0000375 phy->ops.write_reg_page = e1000_write_phy_reg_page_hv;
Bruce Allan17f208d2009-12-01 15:47:22 +0000376 phy->ops.power_up = e1000_power_up_phy_copper;
377 phy->ops.power_down = e1000_power_down_phy_copper_ich8lan;
Bruce Allana4f58f52009-06-02 11:29:18 +0000378 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
379
380 phy->id = e1000_phy_unknown;
Bruce Allancb17aab2012-04-13 03:16:22 +0000381
382 ret_val = e1000_init_phy_workarounds_pchlan(hw);
383 if (ret_val)
384 return ret_val;
385
386 if (phy->id == e1000_phy_unknown)
387 switch (hw->mac.type) {
388 default:
389 ret_val = e1000e_get_phy_id(hw);
390 if (ret_val)
391 return ret_val;
392 if ((phy->id != 0) && (phy->id != PHY_REVISION_MASK))
393 break;
394 /* fall-through */
395 case e1000_pch2lan:
Bruce Allan2fbe4522012-04-19 03:21:47 +0000396 case e1000_pch_lpt:
Bruce Allane921eb12012-11-28 09:28:37 +0000397 /* In case the PHY needs to be in mdio slow mode,
Bruce Allancb17aab2012-04-13 03:16:22 +0000398 * set slow mode and try to get the PHY id again.
399 */
400 ret_val = e1000_set_mdio_slow_mode_hv(hw);
401 if (ret_val)
402 return ret_val;
403 ret_val = e1000e_get_phy_id(hw);
404 if (ret_val)
405 return ret_val;
Bruce Allan664dc872010-11-24 06:01:46 +0000406 break;
Bruce Allancb17aab2012-04-13 03:16:22 +0000407 }
Bruce Allana4f58f52009-06-02 11:29:18 +0000408 phy->type = e1000e_get_phy_type_from_id(phy->id);
409
Bruce Allan0be84012009-12-02 17:03:18 +0000410 switch (phy->type) {
411 case e1000_phy_82577:
Bruce Alland3738bb2010-06-16 13:27:28 +0000412 case e1000_phy_82579:
Bruce Allan2fbe4522012-04-19 03:21:47 +0000413 case e1000_phy_i217:
Bruce Allana4f58f52009-06-02 11:29:18 +0000414 phy->ops.check_polarity = e1000_check_polarity_82577;
415 phy->ops.force_speed_duplex =
Bruce Allan6cc7aae2011-02-25 06:25:18 +0000416 e1000_phy_force_speed_duplex_82577;
Bruce Allan0be84012009-12-02 17:03:18 +0000417 phy->ops.get_cable_length = e1000_get_cable_length_82577;
Bruce Allan94d81862009-11-20 23:25:26 +0000418 phy->ops.get_info = e1000_get_phy_info_82577;
419 phy->ops.commit = e1000e_phy_sw_reset;
Bruce Allaneab50ff2010-05-10 15:01:30 +0000420 break;
Bruce Allan0be84012009-12-02 17:03:18 +0000421 case e1000_phy_82578:
422 phy->ops.check_polarity = e1000_check_polarity_m88;
423 phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_m88;
424 phy->ops.get_cable_length = e1000e_get_cable_length_m88;
425 phy->ops.get_info = e1000e_get_phy_info_m88;
426 break;
427 default:
428 ret_val = -E1000_ERR_PHY;
429 break;
Bruce Allana4f58f52009-06-02 11:29:18 +0000430 }
431
432 return ret_val;
433}
434
435/**
Auke Kokbc7f75f2007-09-17 12:30:59 -0700436 * e1000_init_phy_params_ich8lan - Initialize PHY function pointers
437 * @hw: pointer to the HW structure
438 *
439 * Initialize family-specific PHY parameters and function pointers.
440 **/
441static s32 e1000_init_phy_params_ich8lan(struct e1000_hw *hw)
442{
443 struct e1000_phy_info *phy = &hw->phy;
444 s32 ret_val;
445 u16 i = 0;
446
447 phy->addr = 1;
448 phy->reset_delay_us = 100;
449
Bruce Allan17f208d2009-12-01 15:47:22 +0000450 phy->ops.power_up = e1000_power_up_phy_copper;
451 phy->ops.power_down = e1000_power_down_phy_copper_ich8lan;
452
Bruce Allane921eb12012-11-28 09:28:37 +0000453 /* We may need to do this twice - once for IGP and if that fails,
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700454 * we'll set BM func pointers and try again
455 */
456 ret_val = e1000e_determine_phy_address(hw);
457 if (ret_val) {
Bruce Allan94d81862009-11-20 23:25:26 +0000458 phy->ops.write_reg = e1000e_write_phy_reg_bm;
459 phy->ops.read_reg = e1000e_read_phy_reg_bm;
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700460 ret_val = e1000e_determine_phy_address(hw);
Bruce Allan9b71b412009-12-01 15:53:07 +0000461 if (ret_val) {
462 e_dbg("Cannot determine PHY addr. Erroring out\n");
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700463 return ret_val;
Bruce Allan9b71b412009-12-01 15:53:07 +0000464 }
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700465 }
466
Auke Kokbc7f75f2007-09-17 12:30:59 -0700467 phy->id = 0;
468 while ((e1000_phy_unknown == e1000e_get_phy_type_from_id(phy->id)) &&
469 (i++ < 100)) {
Bruce Allan1bba4382011-03-19 00:27:20 +0000470 usleep_range(1000, 2000);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700471 ret_val = e1000e_get_phy_id(hw);
472 if (ret_val)
473 return ret_val;
474 }
475
476 /* Verify phy id */
477 switch (phy->id) {
478 case IGP03E1000_E_PHY_ID:
479 phy->type = e1000_phy_igp_3;
480 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
Bruce Allan94d81862009-11-20 23:25:26 +0000481 phy->ops.read_reg_locked = e1000e_read_phy_reg_igp_locked;
482 phy->ops.write_reg_locked = e1000e_write_phy_reg_igp_locked;
Bruce Allan0be84012009-12-02 17:03:18 +0000483 phy->ops.get_info = e1000e_get_phy_info_igp;
484 phy->ops.check_polarity = e1000_check_polarity_igp;
485 phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_igp;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700486 break;
487 case IFE_E_PHY_ID:
488 case IFE_PLUS_E_PHY_ID:
489 case IFE_C_E_PHY_ID:
490 phy->type = e1000_phy_ife;
491 phy->autoneg_mask = E1000_ALL_NOT_GIG;
Bruce Allan0be84012009-12-02 17:03:18 +0000492 phy->ops.get_info = e1000_get_phy_info_ife;
493 phy->ops.check_polarity = e1000_check_polarity_ife;
494 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_ife;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700495 break;
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700496 case BME1000_E_PHY_ID:
497 phy->type = e1000_phy_bm;
498 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
Bruce Allan94d81862009-11-20 23:25:26 +0000499 phy->ops.read_reg = e1000e_read_phy_reg_bm;
500 phy->ops.write_reg = e1000e_write_phy_reg_bm;
501 phy->ops.commit = e1000e_phy_sw_reset;
Bruce Allan0be84012009-12-02 17:03:18 +0000502 phy->ops.get_info = e1000e_get_phy_info_m88;
503 phy->ops.check_polarity = e1000_check_polarity_m88;
504 phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_m88;
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700505 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700506 default:
507 return -E1000_ERR_PHY;
508 break;
509 }
510
511 return 0;
512}
513
514/**
515 * e1000_init_nvm_params_ich8lan - Initialize NVM function pointers
516 * @hw: pointer to the HW structure
517 *
518 * Initialize family-specific NVM parameters and function
519 * pointers.
520 **/
521static s32 e1000_init_nvm_params_ich8lan(struct e1000_hw *hw)
522{
523 struct e1000_nvm_info *nvm = &hw->nvm;
524 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
Bruce Allan148675a2009-08-07 07:41:56 +0000525 u32 gfpreg, sector_base_addr, sector_end_addr;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700526 u16 i;
527
Bruce Allanad680762008-03-28 09:15:03 -0700528 /* Can't read flash registers if the register set isn't mapped. */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700529 if (!hw->flash_address) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000530 e_dbg("ERROR: Flash registers not mapped\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700531 return -E1000_ERR_CONFIG;
532 }
533
534 nvm->type = e1000_nvm_flash_sw;
535
536 gfpreg = er32flash(ICH_FLASH_GFPREG);
537
Bruce Allane921eb12012-11-28 09:28:37 +0000538 /* sector_X_addr is a "sector"-aligned address (4096 bytes)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700539 * Add 1 to sector_end_addr since this sector is included in
Bruce Allanad680762008-03-28 09:15:03 -0700540 * the overall size.
541 */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700542 sector_base_addr = gfpreg & FLASH_GFPREG_BASE_MASK;
543 sector_end_addr = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK) + 1;
544
545 /* flash_base_addr is byte-aligned */
546 nvm->flash_base_addr = sector_base_addr << FLASH_SECTOR_ADDR_SHIFT;
547
Bruce Allane921eb12012-11-28 09:28:37 +0000548 /* find total size of the NVM, then cut in half since the total
Bruce Allanad680762008-03-28 09:15:03 -0700549 * size represents two separate NVM banks.
550 */
Bruce Allanf0ff4392013-02-20 04:05:39 +0000551 nvm->flash_bank_size = ((sector_end_addr - sector_base_addr)
552 << FLASH_SECTOR_ADDR_SHIFT);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700553 nvm->flash_bank_size /= 2;
554 /* Adjust to word count */
555 nvm->flash_bank_size /= sizeof(u16);
556
557 nvm->word_size = E1000_ICH8_SHADOW_RAM_WORDS;
558
559 /* Clear shadow ram */
560 for (i = 0; i < nvm->word_size; i++) {
Bruce Allan564ea9b2009-11-20 23:26:44 +0000561 dev_spec->shadow_ram[i].modified = false;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700562 dev_spec->shadow_ram[i].value = 0xFFFF;
563 }
564
565 return 0;
566}
567
568/**
569 * e1000_init_mac_params_ich8lan - Initialize MAC function pointers
570 * @hw: pointer to the HW structure
571 *
572 * Initialize family-specific MAC parameters and function
573 * pointers.
574 **/
Bruce Allanec34c172012-02-01 10:53:05 +0000575static s32 e1000_init_mac_params_ich8lan(struct e1000_hw *hw)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700576{
Auke Kokbc7f75f2007-09-17 12:30:59 -0700577 struct e1000_mac_info *mac = &hw->mac;
578
579 /* Set media type function pointer */
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700580 hw->phy.media_type = e1000_media_type_copper;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700581
582 /* Set mta register count */
583 mac->mta_reg_count = 32;
584 /* Set rar entry count */
585 mac->rar_entry_count = E1000_ICH_RAR_ENTRIES;
586 if (mac->type == e1000_ich8lan)
587 mac->rar_entry_count--;
Bruce Allana65a4a02010-05-10 15:01:51 +0000588 /* FWSM register */
589 mac->has_fwsm = true;
590 /* ARC subsystem not supported */
591 mac->arc_subsystem_valid = false;
Bruce Allanf464ba82010-01-07 16:31:35 +0000592 /* Adaptive IFS supported */
593 mac->adaptive_ifs = true;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700594
Bruce Allan2fbe4522012-04-19 03:21:47 +0000595 /* LED and other operations */
Bruce Allana4f58f52009-06-02 11:29:18 +0000596 switch (mac->type) {
597 case e1000_ich8lan:
598 case e1000_ich9lan:
599 case e1000_ich10lan:
Bruce Allaneb7700d2010-06-16 13:27:05 +0000600 /* check management mode */
601 mac->ops.check_mng_mode = e1000_check_mng_mode_ich8lan;
Bruce Allana4f58f52009-06-02 11:29:18 +0000602 /* ID LED init */
Bruce Alland1964eb2012-02-22 09:02:21 +0000603 mac->ops.id_led_init = e1000e_id_led_init_generic;
Bruce Allandbf80dc2011-04-16 00:34:40 +0000604 /* blink LED */
605 mac->ops.blink_led = e1000e_blink_led_generic;
Bruce Allana4f58f52009-06-02 11:29:18 +0000606 /* setup LED */
607 mac->ops.setup_led = e1000e_setup_led_generic;
608 /* cleanup LED */
609 mac->ops.cleanup_led = e1000_cleanup_led_ich8lan;
610 /* turn on/off LED */
611 mac->ops.led_on = e1000_led_on_ich8lan;
612 mac->ops.led_off = e1000_led_off_ich8lan;
613 break;
Bruce Alland3738bb2010-06-16 13:27:28 +0000614 case e1000_pch2lan:
Bruce Allan69e1e012012-04-14 03:28:50 +0000615 mac->rar_entry_count = E1000_PCH2_RAR_ENTRIES;
616 mac->ops.rar_set = e1000_rar_set_pch2lan;
617 /* fall-through */
Bruce Allan2fbe4522012-04-19 03:21:47 +0000618 case e1000_pch_lpt:
Bruce Allan69e1e012012-04-14 03:28:50 +0000619 case e1000_pchlan:
Bruce Allaneb7700d2010-06-16 13:27:05 +0000620 /* check management mode */
621 mac->ops.check_mng_mode = e1000_check_mng_mode_pchlan;
Bruce Allana4f58f52009-06-02 11:29:18 +0000622 /* ID LED init */
623 mac->ops.id_led_init = e1000_id_led_init_pchlan;
624 /* setup LED */
625 mac->ops.setup_led = e1000_setup_led_pchlan;
626 /* cleanup LED */
627 mac->ops.cleanup_led = e1000_cleanup_led_pchlan;
628 /* turn on/off LED */
629 mac->ops.led_on = e1000_led_on_pchlan;
630 mac->ops.led_off = e1000_led_off_pchlan;
631 break;
632 default:
633 break;
634 }
635
Bruce Allan2fbe4522012-04-19 03:21:47 +0000636 if (mac->type == e1000_pch_lpt) {
637 mac->rar_entry_count = E1000_PCH_LPT_RAR_ENTRIES;
638 mac->ops.rar_set = e1000_rar_set_pch_lpt;
639 }
640
Auke Kokbc7f75f2007-09-17 12:30:59 -0700641 /* Enable PCS Lock-loss workaround for ICH8 */
642 if (mac->type == e1000_ich8lan)
Bruce Allan564ea9b2009-11-20 23:26:44 +0000643 e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw, true);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700644
645 return 0;
646}
647
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000648/**
Bruce Allan4ddc48a2012-12-05 06:25:58 +0000649 * __e1000_access_emi_reg_locked - Read/write EMI register
650 * @hw: pointer to the HW structure
651 * @addr: EMI address to program
652 * @data: pointer to value to read/write from/to the EMI address
653 * @read: boolean flag to indicate read or write
654 *
655 * This helper function assumes the SW/FW/HW Semaphore is already acquired.
656 **/
657static s32 __e1000_access_emi_reg_locked(struct e1000_hw *hw, u16 address,
658 u16 *data, bool read)
659{
Bruce Allan70806a72013-01-05 05:08:37 +0000660 s32 ret_val;
Bruce Allan4ddc48a2012-12-05 06:25:58 +0000661
662 ret_val = e1e_wphy_locked(hw, I82579_EMI_ADDR, address);
663 if (ret_val)
664 return ret_val;
665
666 if (read)
667 ret_val = e1e_rphy_locked(hw, I82579_EMI_DATA, data);
668 else
669 ret_val = e1e_wphy_locked(hw, I82579_EMI_DATA, *data);
670
671 return ret_val;
672}
673
674/**
675 * e1000_read_emi_reg_locked - Read Extended Management Interface register
676 * @hw: pointer to the HW structure
677 * @addr: EMI address to program
678 * @data: value to be read from the EMI address
679 *
680 * Assumes the SW/FW/HW Semaphore is already acquired.
681 **/
Bruce Allan203e4152012-12-05 08:40:59 +0000682s32 e1000_read_emi_reg_locked(struct e1000_hw *hw, u16 addr, u16 *data)
Bruce Allan4ddc48a2012-12-05 06:25:58 +0000683{
684 return __e1000_access_emi_reg_locked(hw, addr, data, true);
685}
686
687/**
688 * e1000_write_emi_reg_locked - Write Extended Management Interface register
689 * @hw: pointer to the HW structure
690 * @addr: EMI address to program
691 * @data: value to be written to the EMI address
692 *
693 * Assumes the SW/FW/HW Semaphore is already acquired.
694 **/
695static s32 e1000_write_emi_reg_locked(struct e1000_hw *hw, u16 addr, u16 data)
696{
697 return __e1000_access_emi_reg_locked(hw, addr, &data, false);
698}
699
700/**
Bruce Allane52997f2010-06-16 13:27:49 +0000701 * e1000_set_eee_pchlan - Enable/disable EEE support
702 * @hw: pointer to the HW structure
703 *
Bruce Allan3d4d5752012-12-05 06:26:08 +0000704 * Enable/disable EEE based on setting in dev_spec structure, the duplex of
705 * the link and the EEE capabilities of the link partner. The LPI Control
706 * register bits will remain set only if/when link is up.
Bruce Allane52997f2010-06-16 13:27:49 +0000707 **/
708static s32 e1000_set_eee_pchlan(struct e1000_hw *hw)
709{
Bruce Allan2fbe4522012-04-19 03:21:47 +0000710 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
Bruce Allan3d4d5752012-12-05 06:26:08 +0000711 s32 ret_val;
712 u16 lpi_ctrl;
Bruce Allane52997f2010-06-16 13:27:49 +0000713
Bruce Allan2fbe4522012-04-19 03:21:47 +0000714 if ((hw->phy.type != e1000_phy_82579) &&
715 (hw->phy.type != e1000_phy_i217))
Bruce Allan5015e532012-02-08 02:55:56 +0000716 return 0;
Bruce Allane52997f2010-06-16 13:27:49 +0000717
Bruce Allan3d4d5752012-12-05 06:26:08 +0000718 ret_val = hw->phy.ops.acquire(hw);
Bruce Allane52997f2010-06-16 13:27:49 +0000719 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +0000720 return ret_val;
Bruce Allane52997f2010-06-16 13:27:49 +0000721
Bruce Allan3d4d5752012-12-05 06:26:08 +0000722 ret_val = e1e_rphy_locked(hw, I82579_LPI_CTRL, &lpi_ctrl);
Bruce Allan2fbe4522012-04-19 03:21:47 +0000723 if (ret_val)
Bruce Allan3d4d5752012-12-05 06:26:08 +0000724 goto release;
Bruce Allan2fbe4522012-04-19 03:21:47 +0000725
Bruce Allan3d4d5752012-12-05 06:26:08 +0000726 /* Clear bits that enable EEE in various speeds */
727 lpi_ctrl &= ~I82579_LPI_CTRL_ENABLE_MASK;
728
729 /* Enable EEE if not disabled by user */
730 if (!dev_spec->eee_disable) {
731 u16 lpa, pcs_status, data;
732
Bruce Allan2fbe4522012-04-19 03:21:47 +0000733 /* Save off link partner's EEE ability */
Bruce Allan3d4d5752012-12-05 06:26:08 +0000734 switch (hw->phy.type) {
735 case e1000_phy_82579:
736 lpa = I82579_EEE_LP_ABILITY;
737 pcs_status = I82579_EEE_PCS_STATUS;
738 break;
739 case e1000_phy_i217:
740 lpa = I217_EEE_LP_ABILITY;
741 pcs_status = I217_EEE_PCS_STATUS;
742 break;
743 default:
744 ret_val = -E1000_ERR_PHY;
745 goto release;
746 }
747 ret_val = e1000_read_emi_reg_locked(hw, lpa,
Bruce Allan4ddc48a2012-12-05 06:25:58 +0000748 &dev_spec->eee_lp_ability);
Bruce Allan2fbe4522012-04-19 03:21:47 +0000749 if (ret_val)
750 goto release;
Bruce Allan2fbe4522012-04-19 03:21:47 +0000751
Bruce Allan3d4d5752012-12-05 06:26:08 +0000752 /* Enable EEE only for speeds in which the link partner is
753 * EEE capable.
Bruce Allan2fbe4522012-04-19 03:21:47 +0000754 */
Bruce Allan3d4d5752012-12-05 06:26:08 +0000755 if (dev_spec->eee_lp_ability & I82579_EEE_1000_SUPPORTED)
756 lpi_ctrl |= I82579_LPI_CTRL_1000_ENABLE;
757
758 if (dev_spec->eee_lp_ability & I82579_EEE_100_SUPPORTED) {
Bruce Allanc2ade1a2013-01-16 08:54:35 +0000759 e1e_rphy_locked(hw, MII_LPA, &data);
760 if (data & LPA_100FULL)
Bruce Allan3d4d5752012-12-05 06:26:08 +0000761 lpi_ctrl |= I82579_LPI_CTRL_100_ENABLE;
762 else
763 /* EEE is not supported in 100Half, so ignore
764 * partner's EEE in 100 ability if full-duplex
765 * is not advertised.
766 */
767 dev_spec->eee_lp_ability &=
768 ~I82579_EEE_100_SUPPORTED;
769 }
770
771 /* R/Clr IEEE MMD 3.1 bits 11:10 - Tx/Rx LPI Received */
772 ret_val = e1000_read_emi_reg_locked(hw, pcs_status, &data);
773 if (ret_val)
774 goto release;
Bruce Allan2fbe4522012-04-19 03:21:47 +0000775 }
776
Bruce Allan3d4d5752012-12-05 06:26:08 +0000777 ret_val = e1e_wphy_locked(hw, I82579_LPI_CTRL, lpi_ctrl);
778release:
779 hw->phy.ops.release(hw);
780
781 return ret_val;
Bruce Allane52997f2010-06-16 13:27:49 +0000782}
783
784/**
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000785 * e1000_check_for_copper_link_ich8lan - Check for link (Copper)
786 * @hw: pointer to the HW structure
787 *
788 * Checks to see of the link status of the hardware has changed. If a
789 * change in link status has been detected, then we read the PHY registers
790 * to get the current speed/duplex if link exists.
791 **/
792static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw)
793{
794 struct e1000_mac_info *mac = &hw->mac;
795 s32 ret_val;
796 bool link;
Bruce Allan1d2101a72011-07-22 06:21:56 +0000797 u16 phy_reg;
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000798
Bruce Allane921eb12012-11-28 09:28:37 +0000799 /* We only want to go out to the PHY registers to see if Auto-Neg
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000800 * has completed and/or if our link status has changed. The
801 * get_link_status flag is set upon receiving a Link Status
802 * Change or Rx Sequence Error interrupt.
803 */
Bruce Allan5015e532012-02-08 02:55:56 +0000804 if (!mac->get_link_status)
805 return 0;
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000806
Bruce Allane921eb12012-11-28 09:28:37 +0000807 /* First we want to see if the MII Status Register reports
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000808 * link. If so, then we want to get the current speed/duplex
809 * of the PHY.
810 */
811 ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link);
812 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +0000813 return ret_val;
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000814
Bruce Allan1d5846b2009-10-29 13:46:05 +0000815 if (hw->mac.type == e1000_pchlan) {
816 ret_val = e1000_k1_gig_workaround_hv(hw, link);
817 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +0000818 return ret_val;
Bruce Allan1d5846b2009-10-29 13:46:05 +0000819 }
820
Bruce Allan2fbe4522012-04-19 03:21:47 +0000821 /* Clear link partner's EEE ability */
822 hw->dev_spec.ich8lan.eee_lp_ability = 0;
823
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000824 if (!link)
Bruce Allan5015e532012-02-08 02:55:56 +0000825 return 0; /* No link detected */
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000826
827 mac->get_link_status = false;
828
Bruce Allan1d2101a72011-07-22 06:21:56 +0000829 switch (hw->mac.type) {
830 case e1000_pch2lan:
Bruce Allan831bd2e2010-09-22 17:16:18 +0000831 ret_val = e1000_k1_workaround_lv(hw);
832 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +0000833 return ret_val;
Bruce Allan1d2101a72011-07-22 06:21:56 +0000834 /* fall-thru */
835 case e1000_pchlan:
836 if (hw->phy.type == e1000_phy_82578) {
837 ret_val = e1000_link_stall_workaround_hv(hw);
838 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +0000839 return ret_val;
Bruce Allan1d2101a72011-07-22 06:21:56 +0000840 }
841
Bruce Allane921eb12012-11-28 09:28:37 +0000842 /* Workaround for PCHx parts in half-duplex:
Bruce Allan1d2101a72011-07-22 06:21:56 +0000843 * Set the number of preambles removed from the packet
844 * when it is passed from the PHY to the MAC to prevent
845 * the MAC from misinterpreting the packet type.
846 */
847 e1e_rphy(hw, HV_KMRN_FIFO_CTRLSTA, &phy_reg);
848 phy_reg &= ~HV_KMRN_FIFO_CTRLSTA_PREAMBLE_MASK;
849
850 if ((er32(STATUS) & E1000_STATUS_FD) != E1000_STATUS_FD)
851 phy_reg |= (1 << HV_KMRN_FIFO_CTRLSTA_PREAMBLE_SHIFT);
852
853 e1e_wphy(hw, HV_KMRN_FIFO_CTRLSTA, phy_reg);
854 break;
855 default:
856 break;
Bruce Allan831bd2e2010-09-22 17:16:18 +0000857 }
858
Bruce Allane921eb12012-11-28 09:28:37 +0000859 /* Check if there was DownShift, must be checked
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000860 * immediately after link-up
861 */
862 e1000e_check_downshift(hw);
863
Bruce Allane52997f2010-06-16 13:27:49 +0000864 /* Enable/Disable EEE after link up */
865 ret_val = e1000_set_eee_pchlan(hw);
866 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +0000867 return ret_val;
Bruce Allane52997f2010-06-16 13:27:49 +0000868
Bruce Allane921eb12012-11-28 09:28:37 +0000869 /* If we are forcing speed/duplex, then we simply return since
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000870 * we have already determined whether we have link or not.
871 */
Bruce Allan5015e532012-02-08 02:55:56 +0000872 if (!mac->autoneg)
873 return -E1000_ERR_CONFIG;
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000874
Bruce Allane921eb12012-11-28 09:28:37 +0000875 /* Auto-Neg is enabled. Auto Speed Detection takes care
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000876 * of MAC speed/duplex configuration. So we only need to
877 * configure Collision Distance in the MAC.
878 */
Bruce Allan57cde762012-02-22 09:02:58 +0000879 mac->ops.config_collision_dist(hw);
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000880
Bruce Allane921eb12012-11-28 09:28:37 +0000881 /* Configure Flow Control now that Auto-Neg has completed.
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000882 * First, we need to restore the desired flow control
883 * settings because we may have had to re-autoneg with a
884 * different link partner.
885 */
886 ret_val = e1000e_config_fc_after_link_up(hw);
887 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000888 e_dbg("Error configuring flow control\n");
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000889
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000890 return ret_val;
891}
892
Jeff Kirsher69e3fd82008-04-02 13:48:18 -0700893static s32 e1000_get_variants_ich8lan(struct e1000_adapter *adapter)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700894{
895 struct e1000_hw *hw = &adapter->hw;
896 s32 rc;
897
Bruce Allanec34c172012-02-01 10:53:05 +0000898 rc = e1000_init_mac_params_ich8lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700899 if (rc)
900 return rc;
901
902 rc = e1000_init_nvm_params_ich8lan(hw);
903 if (rc)
904 return rc;
905
Bruce Alland3738bb2010-06-16 13:27:28 +0000906 switch (hw->mac.type) {
907 case e1000_ich8lan:
908 case e1000_ich9lan:
909 case e1000_ich10lan:
Bruce Allana4f58f52009-06-02 11:29:18 +0000910 rc = e1000_init_phy_params_ich8lan(hw);
Bruce Alland3738bb2010-06-16 13:27:28 +0000911 break;
912 case e1000_pchlan:
913 case e1000_pch2lan:
Bruce Allan2fbe4522012-04-19 03:21:47 +0000914 case e1000_pch_lpt:
Bruce Alland3738bb2010-06-16 13:27:28 +0000915 rc = e1000_init_phy_params_pchlan(hw);
916 break;
917 default:
918 break;
919 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700920 if (rc)
921 return rc;
922
Bruce Allane921eb12012-11-28 09:28:37 +0000923 /* Disable Jumbo Frame support on parts with Intel 10/100 PHY or
Bruce Allan23e4f062011-02-25 07:44:51 +0000924 * on parts with MACsec enabled in NVM (reflected in CTRL_EXT).
925 */
926 if ((adapter->hw.phy.type == e1000_phy_ife) ||
927 ((adapter->hw.mac.type >= e1000_pch2lan) &&
928 (!(er32(CTRL_EXT) & E1000_CTRL_EXT_LSECCK)))) {
Bruce Allan2adc55c2009-06-02 11:28:58 +0000929 adapter->flags &= ~FLAG_HAS_JUMBO_FRAMES;
930 adapter->max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN;
Bruce Allandbf80dc2011-04-16 00:34:40 +0000931
932 hw->mac.ops.blink_led = NULL;
Bruce Allan2adc55c2009-06-02 11:28:58 +0000933 }
934
Auke Kokbc7f75f2007-09-17 12:30:59 -0700935 if ((adapter->hw.mac.type == e1000_ich8lan) &&
Bruce Allan462d5992011-09-30 08:07:11 +0000936 (adapter->hw.phy.type != e1000_phy_ife))
Auke Kokbc7f75f2007-09-17 12:30:59 -0700937 adapter->flags |= FLAG_LSC_GIG_SPEED_DROP;
938
Bruce Allanc6e7f512011-07-29 05:53:02 +0000939 /* Enable workaround for 82579 w/ ME enabled */
940 if ((adapter->hw.mac.type == e1000_pch2lan) &&
941 (er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
942 adapter->flags2 |= FLAG2_PCIM2PCI_ARBITER_WA;
943
Bruce Allan5a86f282010-06-29 18:13:13 +0000944 /* Disable EEE by default until IEEE802.3az spec is finalized */
945 if (adapter->flags2 & FLAG2_HAS_EEE)
946 adapter->hw.dev_spec.ich8lan.eee_disable = true;
947
Auke Kokbc7f75f2007-09-17 12:30:59 -0700948 return 0;
949}
950
Thomas Gleixner717d4382008-10-02 16:33:40 -0700951static DEFINE_MUTEX(nvm_mutex);
Thomas Gleixner717d4382008-10-02 16:33:40 -0700952
Auke Kokbc7f75f2007-09-17 12:30:59 -0700953/**
Bruce Allanca15df52009-10-26 11:23:43 +0000954 * e1000_acquire_nvm_ich8lan - Acquire NVM mutex
955 * @hw: pointer to the HW structure
956 *
957 * Acquires the mutex for performing NVM operations.
958 **/
Bruce Allan8bb62862013-01-16 08:46:49 +0000959static s32 e1000_acquire_nvm_ich8lan(struct e1000_hw __always_unused *hw)
Bruce Allanca15df52009-10-26 11:23:43 +0000960{
961 mutex_lock(&nvm_mutex);
962
963 return 0;
964}
965
966/**
967 * e1000_release_nvm_ich8lan - Release NVM mutex
968 * @hw: pointer to the HW structure
969 *
970 * Releases the mutex used while performing NVM operations.
971 **/
Bruce Allan8bb62862013-01-16 08:46:49 +0000972static void e1000_release_nvm_ich8lan(struct e1000_hw __always_unused *hw)
Bruce Allanca15df52009-10-26 11:23:43 +0000973{
974 mutex_unlock(&nvm_mutex);
Bruce Allanca15df52009-10-26 11:23:43 +0000975}
976
Bruce Allanca15df52009-10-26 11:23:43 +0000977/**
Auke Kokbc7f75f2007-09-17 12:30:59 -0700978 * e1000_acquire_swflag_ich8lan - Acquire software control flag
979 * @hw: pointer to the HW structure
980 *
Bruce Allanca15df52009-10-26 11:23:43 +0000981 * Acquires the software control flag for performing PHY and select
982 * MAC CSR accesses.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700983 **/
984static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw)
985{
Bruce Allan373a88d2009-08-07 07:41:37 +0000986 u32 extcnf_ctrl, timeout = PHY_CFG_TIMEOUT;
987 s32 ret_val = 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700988
Bruce Allana90b4122011-10-07 03:50:38 +0000989 if (test_and_set_bit(__E1000_ACCESS_SHARED_RESOURCE,
990 &hw->adapter->state)) {
Bruce Allan34c9ef82011-10-21 04:33:47 +0000991 e_dbg("contention for Phy access\n");
Bruce Allana90b4122011-10-07 03:50:38 +0000992 return -E1000_ERR_PHY;
993 }
Thomas Gleixner717d4382008-10-02 16:33:40 -0700994
Auke Kokbc7f75f2007-09-17 12:30:59 -0700995 while (timeout) {
996 extcnf_ctrl = er32(EXTCNF_CTRL);
Bruce Allan373a88d2009-08-07 07:41:37 +0000997 if (!(extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG))
998 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700999
Auke Kokbc7f75f2007-09-17 12:30:59 -07001000 mdelay(1);
1001 timeout--;
1002 }
1003
1004 if (!timeout) {
Bruce Allana90b4122011-10-07 03:50:38 +00001005 e_dbg("SW has already locked the resource.\n");
Bruce Allan373a88d2009-08-07 07:41:37 +00001006 ret_val = -E1000_ERR_CONFIG;
1007 goto out;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001008 }
1009
Bruce Allan53ac5a82009-10-26 11:23:06 +00001010 timeout = SW_FLAG_TIMEOUT;
Bruce Allan373a88d2009-08-07 07:41:37 +00001011
1012 extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG;
1013 ew32(EXTCNF_CTRL, extcnf_ctrl);
1014
1015 while (timeout) {
1016 extcnf_ctrl = er32(EXTCNF_CTRL);
1017 if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG)
1018 break;
1019
1020 mdelay(1);
1021 timeout--;
1022 }
1023
1024 if (!timeout) {
Bruce Allan434f1392011-12-16 00:46:54 +00001025 e_dbg("Failed to acquire the semaphore, FW or HW has it: FWSM=0x%8.8x EXTCNF_CTRL=0x%8.8x)\n",
Bruce Allana90b4122011-10-07 03:50:38 +00001026 er32(FWSM), extcnf_ctrl);
Bruce Allan373a88d2009-08-07 07:41:37 +00001027 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
1028 ew32(EXTCNF_CTRL, extcnf_ctrl);
1029 ret_val = -E1000_ERR_CONFIG;
1030 goto out;
1031 }
1032
1033out:
1034 if (ret_val)
Bruce Allana90b4122011-10-07 03:50:38 +00001035 clear_bit(__E1000_ACCESS_SHARED_RESOURCE, &hw->adapter->state);
Bruce Allan373a88d2009-08-07 07:41:37 +00001036
1037 return ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001038}
1039
1040/**
1041 * e1000_release_swflag_ich8lan - Release software control flag
1042 * @hw: pointer to the HW structure
1043 *
Bruce Allanca15df52009-10-26 11:23:43 +00001044 * Releases the software control flag for performing PHY and select
1045 * MAC CSR accesses.
Auke Kokbc7f75f2007-09-17 12:30:59 -07001046 **/
1047static void e1000_release_swflag_ich8lan(struct e1000_hw *hw)
1048{
1049 u32 extcnf_ctrl;
1050
1051 extcnf_ctrl = er32(EXTCNF_CTRL);
Bruce Allanc5caf482011-05-13 07:19:53 +00001052
1053 if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG) {
1054 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
1055 ew32(EXTCNF_CTRL, extcnf_ctrl);
1056 } else {
1057 e_dbg("Semaphore unexpectedly released by sw/fw/hw\n");
1058 }
Thomas Gleixner717d4382008-10-02 16:33:40 -07001059
Bruce Allana90b4122011-10-07 03:50:38 +00001060 clear_bit(__E1000_ACCESS_SHARED_RESOURCE, &hw->adapter->state);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001061}
1062
1063/**
Bruce Allan4662e822008-08-26 18:37:06 -07001064 * e1000_check_mng_mode_ich8lan - Checks management mode
1065 * @hw: pointer to the HW structure
1066 *
Bruce Allaneb7700d2010-06-16 13:27:05 +00001067 * This checks if the adapter has any manageability enabled.
Bruce Allan4662e822008-08-26 18:37:06 -07001068 * This is a function pointer entry point only called by read/write
1069 * routines for the PHY and NVM parts.
1070 **/
1071static bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw)
1072{
Bruce Allana708dd82009-11-20 23:28:37 +00001073 u32 fwsm;
1074
1075 fwsm = er32(FWSM);
Bruce Allanf0ff4392013-02-20 04:05:39 +00001076 return ((fwsm & E1000_ICH_FWSM_FW_VALID) &&
1077 ((fwsm & E1000_FWSM_MODE_MASK) ==
1078 (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT)));
Bruce Allaneb7700d2010-06-16 13:27:05 +00001079}
Bruce Allan4662e822008-08-26 18:37:06 -07001080
Bruce Allaneb7700d2010-06-16 13:27:05 +00001081/**
1082 * e1000_check_mng_mode_pchlan - Checks management mode
1083 * @hw: pointer to the HW structure
1084 *
1085 * This checks if the adapter has iAMT enabled.
1086 * This is a function pointer entry point only called by read/write
1087 * routines for the PHY and NVM parts.
1088 **/
1089static bool e1000_check_mng_mode_pchlan(struct e1000_hw *hw)
1090{
1091 u32 fwsm;
1092
1093 fwsm = er32(FWSM);
1094 return (fwsm & E1000_ICH_FWSM_FW_VALID) &&
Bruce Allanf0ff4392013-02-20 04:05:39 +00001095 (fwsm & (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT));
Bruce Allan4662e822008-08-26 18:37:06 -07001096}
1097
1098/**
Bruce Allan69e1e012012-04-14 03:28:50 +00001099 * e1000_rar_set_pch2lan - Set receive address register
1100 * @hw: pointer to the HW structure
1101 * @addr: pointer to the receive address
1102 * @index: receive address array register
1103 *
1104 * Sets the receive address array register at index to the address passed
1105 * in by addr. For 82579, RAR[0] is the base address register that is to
1106 * contain the MAC address but RAR[1-6] are reserved for manageability (ME).
1107 * Use SHRA[0-3] in place of those reserved for ME.
1108 **/
1109static void e1000_rar_set_pch2lan(struct e1000_hw *hw, u8 *addr, u32 index)
1110{
1111 u32 rar_low, rar_high;
1112
Bruce Allane921eb12012-11-28 09:28:37 +00001113 /* HW expects these in little endian so we reverse the byte order
Bruce Allan69e1e012012-04-14 03:28:50 +00001114 * from network order (big endian) to little endian
1115 */
1116 rar_low = ((u32)addr[0] |
1117 ((u32)addr[1] << 8) |
1118 ((u32)addr[2] << 16) | ((u32)addr[3] << 24));
1119
1120 rar_high = ((u32)addr[4] | ((u32)addr[5] << 8));
1121
1122 /* If MAC address zero, no need to set the AV bit */
1123 if (rar_low || rar_high)
1124 rar_high |= E1000_RAH_AV;
1125
1126 if (index == 0) {
1127 ew32(RAL(index), rar_low);
1128 e1e_flush();
1129 ew32(RAH(index), rar_high);
1130 e1e_flush();
1131 return;
1132 }
1133
1134 if (index < hw->mac.rar_entry_count) {
1135 s32 ret_val;
1136
1137 ret_val = e1000_acquire_swflag_ich8lan(hw);
1138 if (ret_val)
1139 goto out;
1140
1141 ew32(SHRAL(index - 1), rar_low);
1142 e1e_flush();
1143 ew32(SHRAH(index - 1), rar_high);
1144 e1e_flush();
1145
1146 e1000_release_swflag_ich8lan(hw);
1147
1148 /* verify the register updates */
1149 if ((er32(SHRAL(index - 1)) == rar_low) &&
1150 (er32(SHRAH(index - 1)) == rar_high))
1151 return;
1152
1153 e_dbg("SHRA[%d] might be locked by ME - FWSM=0x%8.8x\n",
1154 (index - 1), er32(FWSM));
1155 }
1156
1157out:
1158 e_dbg("Failed to write receive address at index %d\n", index);
1159}
1160
1161/**
Bruce Allan2fbe4522012-04-19 03:21:47 +00001162 * e1000_rar_set_pch_lpt - Set receive address registers
1163 * @hw: pointer to the HW structure
1164 * @addr: pointer to the receive address
1165 * @index: receive address array register
1166 *
1167 * Sets the receive address register array at index to the address passed
1168 * in by addr. For LPT, RAR[0] is the base address register that is to
1169 * contain the MAC address. SHRA[0-10] are the shared receive address
1170 * registers that are shared between the Host and manageability engine (ME).
1171 **/
1172static void e1000_rar_set_pch_lpt(struct e1000_hw *hw, u8 *addr, u32 index)
1173{
1174 u32 rar_low, rar_high;
1175 u32 wlock_mac;
1176
Bruce Allane921eb12012-11-28 09:28:37 +00001177 /* HW expects these in little endian so we reverse the byte order
Bruce Allan2fbe4522012-04-19 03:21:47 +00001178 * from network order (big endian) to little endian
1179 */
1180 rar_low = ((u32)addr[0] | ((u32)addr[1] << 8) |
1181 ((u32)addr[2] << 16) | ((u32)addr[3] << 24));
1182
1183 rar_high = ((u32)addr[4] | ((u32)addr[5] << 8));
1184
1185 /* If MAC address zero, no need to set the AV bit */
1186 if (rar_low || rar_high)
1187 rar_high |= E1000_RAH_AV;
1188
1189 if (index == 0) {
1190 ew32(RAL(index), rar_low);
1191 e1e_flush();
1192 ew32(RAH(index), rar_high);
1193 e1e_flush();
1194 return;
1195 }
1196
Bruce Allane921eb12012-11-28 09:28:37 +00001197 /* The manageability engine (ME) can lock certain SHRAR registers that
Bruce Allan2fbe4522012-04-19 03:21:47 +00001198 * it is using - those registers are unavailable for use.
1199 */
1200 if (index < hw->mac.rar_entry_count) {
1201 wlock_mac = er32(FWSM) & E1000_FWSM_WLOCK_MAC_MASK;
1202 wlock_mac >>= E1000_FWSM_WLOCK_MAC_SHIFT;
1203
1204 /* Check if all SHRAR registers are locked */
1205 if (wlock_mac == 1)
1206 goto out;
1207
1208 if ((wlock_mac == 0) || (index <= wlock_mac)) {
1209 s32 ret_val;
1210
1211 ret_val = e1000_acquire_swflag_ich8lan(hw);
1212
1213 if (ret_val)
1214 goto out;
1215
1216 ew32(SHRAL_PCH_LPT(index - 1), rar_low);
1217 e1e_flush();
1218 ew32(SHRAH_PCH_LPT(index - 1), rar_high);
1219 e1e_flush();
1220
1221 e1000_release_swflag_ich8lan(hw);
1222
1223 /* verify the register updates */
1224 if ((er32(SHRAL_PCH_LPT(index - 1)) == rar_low) &&
1225 (er32(SHRAH_PCH_LPT(index - 1)) == rar_high))
1226 return;
1227 }
1228 }
1229
1230out:
1231 e_dbg("Failed to write receive address at index %d\n", index);
1232}
1233
1234/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07001235 * e1000_check_reset_block_ich8lan - Check if PHY reset is blocked
1236 * @hw: pointer to the HW structure
1237 *
1238 * Checks if firmware is blocking the reset of the PHY.
1239 * This is a function pointer entry point only called by
1240 * reset routines.
1241 **/
1242static s32 e1000_check_reset_block_ich8lan(struct e1000_hw *hw)
1243{
1244 u32 fwsm;
1245
1246 fwsm = er32(FWSM);
1247
1248 return (fwsm & E1000_ICH_FWSM_RSPCIPHY) ? 0 : E1000_BLK_PHY_RESET;
1249}
1250
1251/**
Bruce Allan8395ae82010-09-22 17:15:08 +00001252 * e1000_write_smbus_addr - Write SMBus address to PHY needed during Sx states
1253 * @hw: pointer to the HW structure
1254 *
1255 * Assumes semaphore already acquired.
1256 *
1257 **/
1258static s32 e1000_write_smbus_addr(struct e1000_hw *hw)
1259{
1260 u16 phy_data;
1261 u32 strap = er32(STRAP);
Bruce Allan2fbe4522012-04-19 03:21:47 +00001262 u32 freq = (strap & E1000_STRAP_SMT_FREQ_MASK) >>
1263 E1000_STRAP_SMT_FREQ_SHIFT;
Bruce Allan70806a72013-01-05 05:08:37 +00001264 s32 ret_val;
Bruce Allan8395ae82010-09-22 17:15:08 +00001265
1266 strap &= E1000_STRAP_SMBUS_ADDRESS_MASK;
1267
1268 ret_val = e1000_read_phy_reg_hv_locked(hw, HV_SMB_ADDR, &phy_data);
1269 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001270 return ret_val;
Bruce Allan8395ae82010-09-22 17:15:08 +00001271
1272 phy_data &= ~HV_SMB_ADDR_MASK;
1273 phy_data |= (strap >> E1000_STRAP_SMBUS_ADDRESS_SHIFT);
1274 phy_data |= HV_SMB_ADDR_PEC_EN | HV_SMB_ADDR_VALID;
Bruce Allan8395ae82010-09-22 17:15:08 +00001275
Bruce Allan2fbe4522012-04-19 03:21:47 +00001276 if (hw->phy.type == e1000_phy_i217) {
1277 /* Restore SMBus frequency */
1278 if (freq--) {
1279 phy_data &= ~HV_SMB_ADDR_FREQ_MASK;
1280 phy_data |= (freq & (1 << 0)) <<
1281 HV_SMB_ADDR_FREQ_LOW_SHIFT;
1282 phy_data |= (freq & (1 << 1)) <<
1283 (HV_SMB_ADDR_FREQ_HIGH_SHIFT - 1);
1284 } else {
1285 e_dbg("Unsupported SMB frequency in PHY\n");
1286 }
1287 }
1288
Bruce Allan5015e532012-02-08 02:55:56 +00001289 return e1000_write_phy_reg_hv_locked(hw, HV_SMB_ADDR, phy_data);
Bruce Allan8395ae82010-09-22 17:15:08 +00001290}
1291
1292/**
Bruce Allanf523d212009-10-29 13:45:45 +00001293 * e1000_sw_lcd_config_ich8lan - SW-based LCD Configuration
1294 * @hw: pointer to the HW structure
1295 *
1296 * SW should configure the LCD from the NVM extended configuration region
1297 * as a workaround for certain parts.
1298 **/
1299static s32 e1000_sw_lcd_config_ich8lan(struct e1000_hw *hw)
1300{
1301 struct e1000_phy_info *phy = &hw->phy;
1302 u32 i, data, cnf_size, cnf_base_addr, sw_cfg_mask;
Bruce Allan8b802a72010-05-10 15:01:10 +00001303 s32 ret_val = 0;
Bruce Allanf523d212009-10-29 13:45:45 +00001304 u16 word_addr, reg_data, reg_addr, phy_page = 0;
1305
Bruce Allane921eb12012-11-28 09:28:37 +00001306 /* Initialize the PHY from the NVM on ICH platforms. This
Bruce Allanf523d212009-10-29 13:45:45 +00001307 * is needed due to an issue where the NVM configuration is
1308 * not properly autoloaded after power transitions.
1309 * Therefore, after each PHY reset, we will load the
1310 * configuration data out of the NVM manually.
1311 */
Bruce Allan3f0c16e2010-06-16 13:26:17 +00001312 switch (hw->mac.type) {
1313 case e1000_ich8lan:
1314 if (phy->type != e1000_phy_igp_3)
1315 return ret_val;
1316
Bruce Allan5f3eed62010-09-22 17:15:54 +00001317 if ((hw->adapter->pdev->device == E1000_DEV_ID_ICH8_IGP_AMT) ||
1318 (hw->adapter->pdev->device == E1000_DEV_ID_ICH8_IGP_C)) {
Bruce Allan3f0c16e2010-06-16 13:26:17 +00001319 sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG;
1320 break;
1321 }
1322 /* Fall-thru */
1323 case e1000_pchlan:
Bruce Alland3738bb2010-06-16 13:27:28 +00001324 case e1000_pch2lan:
Bruce Allan2fbe4522012-04-19 03:21:47 +00001325 case e1000_pch_lpt:
Bruce Allan8b802a72010-05-10 15:01:10 +00001326 sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG_ICH8M;
Bruce Allan3f0c16e2010-06-16 13:26:17 +00001327 break;
1328 default:
1329 return ret_val;
1330 }
1331
1332 ret_val = hw->phy.ops.acquire(hw);
1333 if (ret_val)
1334 return ret_val;
Bruce Allanf523d212009-10-29 13:45:45 +00001335
Bruce Allan8b802a72010-05-10 15:01:10 +00001336 data = er32(FEXTNVM);
1337 if (!(data & sw_cfg_mask))
Bruce Allan75ce1532012-02-08 02:54:48 +00001338 goto release;
Bruce Allanf523d212009-10-29 13:45:45 +00001339
Bruce Allane921eb12012-11-28 09:28:37 +00001340 /* Make sure HW does not configure LCD from PHY
Bruce Allan8b802a72010-05-10 15:01:10 +00001341 * extended configuration before SW configuration
1342 */
1343 data = er32(EXTCNF_CTRL);
Bruce Allan2fbe4522012-04-19 03:21:47 +00001344 if ((hw->mac.type < e1000_pch2lan) &&
1345 (data & E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE))
1346 goto release;
Bruce Allanf523d212009-10-29 13:45:45 +00001347
Bruce Allan8b802a72010-05-10 15:01:10 +00001348 cnf_size = er32(EXTCNF_SIZE);
1349 cnf_size &= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_MASK;
1350 cnf_size >>= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_SHIFT;
1351 if (!cnf_size)
Bruce Allan75ce1532012-02-08 02:54:48 +00001352 goto release;
Bruce Allan8b802a72010-05-10 15:01:10 +00001353
1354 cnf_base_addr = data & E1000_EXTCNF_CTRL_EXT_CNF_POINTER_MASK;
1355 cnf_base_addr >>= E1000_EXTCNF_CTRL_EXT_CNF_POINTER_SHIFT;
1356
Bruce Allan2fbe4522012-04-19 03:21:47 +00001357 if (((hw->mac.type == e1000_pchlan) &&
1358 !(data & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE)) ||
1359 (hw->mac.type > e1000_pchlan)) {
Bruce Allane921eb12012-11-28 09:28:37 +00001360 /* HW configures the SMBus address and LEDs when the
Bruce Allan8b802a72010-05-10 15:01:10 +00001361 * OEM and LCD Write Enable bits are set in the NVM.
1362 * When both NVM bits are cleared, SW will configure
1363 * them instead.
Bruce Allanf523d212009-10-29 13:45:45 +00001364 */
Bruce Allan8395ae82010-09-22 17:15:08 +00001365 ret_val = e1000_write_smbus_addr(hw);
Bruce Allan8b802a72010-05-10 15:01:10 +00001366 if (ret_val)
Bruce Allan75ce1532012-02-08 02:54:48 +00001367 goto release;
Bruce Allanf523d212009-10-29 13:45:45 +00001368
Bruce Allan8b802a72010-05-10 15:01:10 +00001369 data = er32(LEDCTL);
1370 ret_val = e1000_write_phy_reg_hv_locked(hw, HV_LED_CONFIG,
1371 (u16)data);
1372 if (ret_val)
Bruce Allan75ce1532012-02-08 02:54:48 +00001373 goto release;
Bruce Allan8b802a72010-05-10 15:01:10 +00001374 }
1375
1376 /* Configure LCD from extended configuration region. */
1377
1378 /* cnf_base_addr is in DWORD */
1379 word_addr = (u16)(cnf_base_addr << 1);
1380
1381 for (i = 0; i < cnf_size; i++) {
1382 ret_val = e1000_read_nvm(hw, (word_addr + i * 2), 1,
1383 &reg_data);
1384 if (ret_val)
Bruce Allan75ce1532012-02-08 02:54:48 +00001385 goto release;
Bruce Allanf523d212009-10-29 13:45:45 +00001386
Bruce Allan8b802a72010-05-10 15:01:10 +00001387 ret_val = e1000_read_nvm(hw, (word_addr + i * 2 + 1),
1388 1, &reg_addr);
1389 if (ret_val)
Bruce Allan75ce1532012-02-08 02:54:48 +00001390 goto release;
Bruce Allanf523d212009-10-29 13:45:45 +00001391
Bruce Allan8b802a72010-05-10 15:01:10 +00001392 /* Save off the PHY page for future writes. */
1393 if (reg_addr == IGP01E1000_PHY_PAGE_SELECT) {
1394 phy_page = reg_data;
1395 continue;
Bruce Allanf523d212009-10-29 13:45:45 +00001396 }
Bruce Allanf523d212009-10-29 13:45:45 +00001397
Bruce Allan8b802a72010-05-10 15:01:10 +00001398 reg_addr &= PHY_REG_MASK;
1399 reg_addr |= phy_page;
Bruce Allanf523d212009-10-29 13:45:45 +00001400
Bruce Allanf1430d62012-04-14 04:21:52 +00001401 ret_val = e1e_wphy_locked(hw, (u32)reg_addr, reg_data);
Bruce Allan8b802a72010-05-10 15:01:10 +00001402 if (ret_val)
Bruce Allan75ce1532012-02-08 02:54:48 +00001403 goto release;
Bruce Allanf523d212009-10-29 13:45:45 +00001404 }
1405
Bruce Allan75ce1532012-02-08 02:54:48 +00001406release:
Bruce Allan94d81862009-11-20 23:25:26 +00001407 hw->phy.ops.release(hw);
Bruce Allanf523d212009-10-29 13:45:45 +00001408 return ret_val;
1409}
1410
1411/**
Bruce Allan1d5846b2009-10-29 13:46:05 +00001412 * e1000_k1_gig_workaround_hv - K1 Si workaround
1413 * @hw: pointer to the HW structure
1414 * @link: link up bool flag
1415 *
1416 * If K1 is enabled for 1Gbps, the MAC might stall when transitioning
1417 * from a lower speed. This workaround disables K1 whenever link is at 1Gig
1418 * If link is down, the function will restore the default K1 setting located
1419 * in the NVM.
1420 **/
1421static s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link)
1422{
1423 s32 ret_val = 0;
1424 u16 status_reg = 0;
1425 bool k1_enable = hw->dev_spec.ich8lan.nvm_k1_enabled;
1426
1427 if (hw->mac.type != e1000_pchlan)
Bruce Allan5015e532012-02-08 02:55:56 +00001428 return 0;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001429
1430 /* Wrap the whole flow with the sw flag */
Bruce Allan94d81862009-11-20 23:25:26 +00001431 ret_val = hw->phy.ops.acquire(hw);
Bruce Allan1d5846b2009-10-29 13:46:05 +00001432 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001433 return ret_val;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001434
1435 /* Disable K1 when link is 1Gbps, otherwise use the NVM setting */
1436 if (link) {
1437 if (hw->phy.type == e1000_phy_82578) {
Bruce Allanf1430d62012-04-14 04:21:52 +00001438 ret_val = e1e_rphy_locked(hw, BM_CS_STATUS,
1439 &status_reg);
Bruce Allan1d5846b2009-10-29 13:46:05 +00001440 if (ret_val)
1441 goto release;
1442
Bruce Allanf0ff4392013-02-20 04:05:39 +00001443 status_reg &= (BM_CS_STATUS_LINK_UP |
1444 BM_CS_STATUS_RESOLVED |
1445 BM_CS_STATUS_SPEED_MASK);
Bruce Allan1d5846b2009-10-29 13:46:05 +00001446
1447 if (status_reg == (BM_CS_STATUS_LINK_UP |
Bruce Allanf0ff4392013-02-20 04:05:39 +00001448 BM_CS_STATUS_RESOLVED |
1449 BM_CS_STATUS_SPEED_1000))
Bruce Allan1d5846b2009-10-29 13:46:05 +00001450 k1_enable = false;
1451 }
1452
1453 if (hw->phy.type == e1000_phy_82577) {
Bruce Allanf1430d62012-04-14 04:21:52 +00001454 ret_val = e1e_rphy_locked(hw, HV_M_STATUS, &status_reg);
Bruce Allan1d5846b2009-10-29 13:46:05 +00001455 if (ret_val)
1456 goto release;
1457
Bruce Allanf0ff4392013-02-20 04:05:39 +00001458 status_reg &= (HV_M_STATUS_LINK_UP |
1459 HV_M_STATUS_AUTONEG_COMPLETE |
1460 HV_M_STATUS_SPEED_MASK);
Bruce Allan1d5846b2009-10-29 13:46:05 +00001461
1462 if (status_reg == (HV_M_STATUS_LINK_UP |
Bruce Allanf0ff4392013-02-20 04:05:39 +00001463 HV_M_STATUS_AUTONEG_COMPLETE |
1464 HV_M_STATUS_SPEED_1000))
Bruce Allan1d5846b2009-10-29 13:46:05 +00001465 k1_enable = false;
1466 }
1467
1468 /* Link stall fix for link up */
Bruce Allanf1430d62012-04-14 04:21:52 +00001469 ret_val = e1e_wphy_locked(hw, PHY_REG(770, 19), 0x0100);
Bruce Allan1d5846b2009-10-29 13:46:05 +00001470 if (ret_val)
1471 goto release;
1472
1473 } else {
1474 /* Link stall fix for link down */
Bruce Allanf1430d62012-04-14 04:21:52 +00001475 ret_val = e1e_wphy_locked(hw, PHY_REG(770, 19), 0x4100);
Bruce Allan1d5846b2009-10-29 13:46:05 +00001476 if (ret_val)
1477 goto release;
1478 }
1479
1480 ret_val = e1000_configure_k1_ich8lan(hw, k1_enable);
1481
1482release:
Bruce Allan94d81862009-11-20 23:25:26 +00001483 hw->phy.ops.release(hw);
Bruce Allan5015e532012-02-08 02:55:56 +00001484
Bruce Allan1d5846b2009-10-29 13:46:05 +00001485 return ret_val;
1486}
1487
1488/**
1489 * e1000_configure_k1_ich8lan - Configure K1 power state
1490 * @hw: pointer to the HW structure
1491 * @enable: K1 state to configure
1492 *
1493 * Configure the K1 power state based on the provided parameter.
1494 * Assumes semaphore already acquired.
1495 *
1496 * Success returns 0, Failure returns -E1000_ERR_PHY (-2)
1497 **/
Bruce Allanbb436b22009-11-20 23:24:11 +00001498s32 e1000_configure_k1_ich8lan(struct e1000_hw *hw, bool k1_enable)
Bruce Allan1d5846b2009-10-29 13:46:05 +00001499{
Bruce Allan70806a72013-01-05 05:08:37 +00001500 s32 ret_val;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001501 u32 ctrl_reg = 0;
1502 u32 ctrl_ext = 0;
1503 u32 reg = 0;
1504 u16 kmrn_reg = 0;
1505
Bruce Allan3d3a1672012-02-23 03:13:18 +00001506 ret_val = e1000e_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
1507 &kmrn_reg);
Bruce Allan1d5846b2009-10-29 13:46:05 +00001508 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001509 return ret_val;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001510
1511 if (k1_enable)
1512 kmrn_reg |= E1000_KMRNCTRLSTA_K1_ENABLE;
1513 else
1514 kmrn_reg &= ~E1000_KMRNCTRLSTA_K1_ENABLE;
1515
Bruce Allan3d3a1672012-02-23 03:13:18 +00001516 ret_val = e1000e_write_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
1517 kmrn_reg);
Bruce Allan1d5846b2009-10-29 13:46:05 +00001518 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001519 return ret_val;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001520
1521 udelay(20);
1522 ctrl_ext = er32(CTRL_EXT);
1523 ctrl_reg = er32(CTRL);
1524
1525 reg = ctrl_reg & ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100);
1526 reg |= E1000_CTRL_FRCSPD;
1527 ew32(CTRL, reg);
1528
1529 ew32(CTRL_EXT, ctrl_ext | E1000_CTRL_EXT_SPD_BYPS);
Jesse Brandeburg945a5152011-07-20 00:56:21 +00001530 e1e_flush();
Bruce Allan1d5846b2009-10-29 13:46:05 +00001531 udelay(20);
1532 ew32(CTRL, ctrl_reg);
1533 ew32(CTRL_EXT, ctrl_ext);
Jesse Brandeburg945a5152011-07-20 00:56:21 +00001534 e1e_flush();
Bruce Allan1d5846b2009-10-29 13:46:05 +00001535 udelay(20);
1536
Bruce Allan5015e532012-02-08 02:55:56 +00001537 return 0;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001538}
1539
1540/**
Bruce Allanf523d212009-10-29 13:45:45 +00001541 * e1000_oem_bits_config_ich8lan - SW-based LCD Configuration
1542 * @hw: pointer to the HW structure
1543 * @d0_state: boolean if entering d0 or d3 device state
1544 *
1545 * SW will configure Gbe Disable and LPLU based on the NVM. The four bits are
1546 * collectively called OEM bits. The OEM Write Enable bit and SW Config bit
1547 * in NVM determines whether HW should configure LPLU and Gbe Disable.
1548 **/
1549static s32 e1000_oem_bits_config_ich8lan(struct e1000_hw *hw, bool d0_state)
1550{
1551 s32 ret_val = 0;
1552 u32 mac_reg;
1553 u16 oem_reg;
1554
Bruce Allan2fbe4522012-04-19 03:21:47 +00001555 if (hw->mac.type < e1000_pchlan)
Bruce Allanf523d212009-10-29 13:45:45 +00001556 return ret_val;
1557
Bruce Allan94d81862009-11-20 23:25:26 +00001558 ret_val = hw->phy.ops.acquire(hw);
Bruce Allanf523d212009-10-29 13:45:45 +00001559 if (ret_val)
1560 return ret_val;
1561
Bruce Allan2fbe4522012-04-19 03:21:47 +00001562 if (hw->mac.type == e1000_pchlan) {
Bruce Alland3738bb2010-06-16 13:27:28 +00001563 mac_reg = er32(EXTCNF_CTRL);
1564 if (mac_reg & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE)
Bruce Allan75ce1532012-02-08 02:54:48 +00001565 goto release;
Bruce Alland3738bb2010-06-16 13:27:28 +00001566 }
Bruce Allanf523d212009-10-29 13:45:45 +00001567
1568 mac_reg = er32(FEXTNVM);
1569 if (!(mac_reg & E1000_FEXTNVM_SW_CONFIG_ICH8M))
Bruce Allan75ce1532012-02-08 02:54:48 +00001570 goto release;
Bruce Allanf523d212009-10-29 13:45:45 +00001571
1572 mac_reg = er32(PHY_CTRL);
1573
Bruce Allanf1430d62012-04-14 04:21:52 +00001574 ret_val = e1e_rphy_locked(hw, HV_OEM_BITS, &oem_reg);
Bruce Allanf523d212009-10-29 13:45:45 +00001575 if (ret_val)
Bruce Allan75ce1532012-02-08 02:54:48 +00001576 goto release;
Bruce Allanf523d212009-10-29 13:45:45 +00001577
1578 oem_reg &= ~(HV_OEM_BITS_GBE_DIS | HV_OEM_BITS_LPLU);
1579
1580 if (d0_state) {
1581 if (mac_reg & E1000_PHY_CTRL_GBE_DISABLE)
1582 oem_reg |= HV_OEM_BITS_GBE_DIS;
1583
1584 if (mac_reg & E1000_PHY_CTRL_D0A_LPLU)
1585 oem_reg |= HV_OEM_BITS_LPLU;
1586 } else {
Bruce Allan03299e42011-09-30 08:07:05 +00001587 if (mac_reg & (E1000_PHY_CTRL_GBE_DISABLE |
1588 E1000_PHY_CTRL_NOND0A_GBE_DISABLE))
Bruce Allanf523d212009-10-29 13:45:45 +00001589 oem_reg |= HV_OEM_BITS_GBE_DIS;
1590
Bruce Allan03299e42011-09-30 08:07:05 +00001591 if (mac_reg & (E1000_PHY_CTRL_D0A_LPLU |
1592 E1000_PHY_CTRL_NOND0A_LPLU))
Bruce Allanf523d212009-10-29 13:45:45 +00001593 oem_reg |= HV_OEM_BITS_LPLU;
1594 }
Bruce Allan03299e42011-09-30 08:07:05 +00001595
Bruce Allan92fe1732012-04-12 06:27:03 +00001596 /* Set Restart auto-neg to activate the bits */
1597 if ((d0_state || (hw->mac.type != e1000_pchlan)) &&
1598 !hw->phy.ops.check_reset_block(hw))
1599 oem_reg |= HV_OEM_BITS_RESTART_AN;
1600
Bruce Allanf1430d62012-04-14 04:21:52 +00001601 ret_val = e1e_wphy_locked(hw, HV_OEM_BITS, oem_reg);
Bruce Allanf523d212009-10-29 13:45:45 +00001602
Bruce Allan75ce1532012-02-08 02:54:48 +00001603release:
Bruce Allan94d81862009-11-20 23:25:26 +00001604 hw->phy.ops.release(hw);
Bruce Allanf523d212009-10-29 13:45:45 +00001605
1606 return ret_val;
1607}
1608
Bruce Allanf523d212009-10-29 13:45:45 +00001609/**
Bruce Allanfddaa1a2010-01-13 01:52:49 +00001610 * e1000_set_mdio_slow_mode_hv - Set slow MDIO access mode
1611 * @hw: pointer to the HW structure
1612 **/
1613static s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw)
1614{
1615 s32 ret_val;
1616 u16 data;
1617
1618 ret_val = e1e_rphy(hw, HV_KMRN_MODE_CTRL, &data);
1619 if (ret_val)
1620 return ret_val;
1621
1622 data |= HV_KMRN_MDIO_SLOW;
1623
1624 ret_val = e1e_wphy(hw, HV_KMRN_MODE_CTRL, data);
1625
1626 return ret_val;
1627}
1628
1629/**
Bruce Allana4f58f52009-06-02 11:29:18 +00001630 * e1000_hv_phy_workarounds_ich8lan - A series of Phy workarounds to be
1631 * done after every PHY reset.
1632 **/
1633static s32 e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw)
1634{
1635 s32 ret_val = 0;
Bruce Allanbaf86c92010-01-13 01:53:08 +00001636 u16 phy_data;
Bruce Allana4f58f52009-06-02 11:29:18 +00001637
1638 if (hw->mac.type != e1000_pchlan)
Bruce Allan5015e532012-02-08 02:55:56 +00001639 return 0;
Bruce Allana4f58f52009-06-02 11:29:18 +00001640
Bruce Allanfddaa1a2010-01-13 01:52:49 +00001641 /* Set MDIO slow mode before any other MDIO access */
1642 if (hw->phy.type == e1000_phy_82577) {
1643 ret_val = e1000_set_mdio_slow_mode_hv(hw);
1644 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001645 return ret_val;
Bruce Allanfddaa1a2010-01-13 01:52:49 +00001646 }
1647
Bruce Allana4f58f52009-06-02 11:29:18 +00001648 if (((hw->phy.type == e1000_phy_82577) &&
1649 ((hw->phy.revision == 1) || (hw->phy.revision == 2))) ||
1650 ((hw->phy.type == e1000_phy_82578) && (hw->phy.revision == 1))) {
1651 /* Disable generation of early preamble */
1652 ret_val = e1e_wphy(hw, PHY_REG(769, 25), 0x4431);
1653 if (ret_val)
1654 return ret_val;
1655
1656 /* Preamble tuning for SSC */
Bruce Allan1d2101a72011-07-22 06:21:56 +00001657 ret_val = e1e_wphy(hw, HV_KMRN_FIFO_CTRLSTA, 0xA204);
Bruce Allana4f58f52009-06-02 11:29:18 +00001658 if (ret_val)
1659 return ret_val;
1660 }
1661
1662 if (hw->phy.type == e1000_phy_82578) {
Bruce Allane921eb12012-11-28 09:28:37 +00001663 /* Return registers to default by doing a soft reset then
Bruce Allana4f58f52009-06-02 11:29:18 +00001664 * writing 0x3140 to the control register.
1665 */
1666 if (hw->phy.revision < 2) {
1667 e1000e_phy_sw_reset(hw);
Bruce Allanc2ade1a2013-01-16 08:54:35 +00001668 ret_val = e1e_wphy(hw, MII_BMCR, 0x3140);
Bruce Allana4f58f52009-06-02 11:29:18 +00001669 }
1670 }
1671
1672 /* Select page 0 */
Bruce Allan94d81862009-11-20 23:25:26 +00001673 ret_val = hw->phy.ops.acquire(hw);
Bruce Allana4f58f52009-06-02 11:29:18 +00001674 if (ret_val)
1675 return ret_val;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001676
Bruce Allana4f58f52009-06-02 11:29:18 +00001677 hw->phy.addr = 1;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001678 ret_val = e1000e_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT, 0);
Bruce Allanbaf86c92010-01-13 01:53:08 +00001679 hw->phy.ops.release(hw);
Bruce Allan1d5846b2009-10-29 13:46:05 +00001680 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001681 return ret_val;
Bruce Allana4f58f52009-06-02 11:29:18 +00001682
Bruce Allane921eb12012-11-28 09:28:37 +00001683 /* Configure the K1 Si workaround during phy reset assuming there is
Bruce Allan1d5846b2009-10-29 13:46:05 +00001684 * link so that it disables K1 if link is in 1Gbps.
1685 */
1686 ret_val = e1000_k1_gig_workaround_hv(hw, true);
Bruce Allanbaf86c92010-01-13 01:53:08 +00001687 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001688 return ret_val;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001689
Bruce Allanbaf86c92010-01-13 01:53:08 +00001690 /* Workaround for link disconnects on a busy hub in half duplex */
1691 ret_val = hw->phy.ops.acquire(hw);
1692 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001693 return ret_val;
Bruce Allanf1430d62012-04-14 04:21:52 +00001694 ret_val = e1e_rphy_locked(hw, BM_PORT_GEN_CFG, &phy_data);
Bruce Allanbaf86c92010-01-13 01:53:08 +00001695 if (ret_val)
1696 goto release;
Bruce Allanf1430d62012-04-14 04:21:52 +00001697 ret_val = e1e_wphy_locked(hw, BM_PORT_GEN_CFG, phy_data & 0x00FF);
Bruce Allan651fb102012-12-05 06:26:03 +00001698 if (ret_val)
1699 goto release;
1700
1701 /* set MSE higher to enable link to stay up when noise is high */
1702 ret_val = e1000_write_emi_reg_locked(hw, I82577_MSE_THRESHOLD, 0x0034);
Bruce Allanbaf86c92010-01-13 01:53:08 +00001703release:
1704 hw->phy.ops.release(hw);
Bruce Allan5015e532012-02-08 02:55:56 +00001705
Bruce Allana4f58f52009-06-02 11:29:18 +00001706 return ret_val;
1707}
1708
1709/**
Bruce Alland3738bb2010-06-16 13:27:28 +00001710 * e1000_copy_rx_addrs_to_phy_ich8lan - Copy Rx addresses from MAC to PHY
1711 * @hw: pointer to the HW structure
1712 **/
1713void e1000_copy_rx_addrs_to_phy_ich8lan(struct e1000_hw *hw)
1714{
1715 u32 mac_reg;
Bruce Allan2b6b1682011-05-13 07:20:09 +00001716 u16 i, phy_reg = 0;
1717 s32 ret_val;
1718
1719 ret_val = hw->phy.ops.acquire(hw);
1720 if (ret_val)
1721 return;
1722 ret_val = e1000_enable_phy_wakeup_reg_access_bm(hw, &phy_reg);
1723 if (ret_val)
1724 goto release;
Bruce Alland3738bb2010-06-16 13:27:28 +00001725
1726 /* Copy both RAL/H (rar_entry_count) and SHRAL/H (+4) to PHY */
1727 for (i = 0; i < (hw->mac.rar_entry_count + 4); i++) {
1728 mac_reg = er32(RAL(i));
Bruce Allan2b6b1682011-05-13 07:20:09 +00001729 hw->phy.ops.write_reg_page(hw, BM_RAR_L(i),
1730 (u16)(mac_reg & 0xFFFF));
1731 hw->phy.ops.write_reg_page(hw, BM_RAR_M(i),
1732 (u16)((mac_reg >> 16) & 0xFFFF));
1733
Bruce Alland3738bb2010-06-16 13:27:28 +00001734 mac_reg = er32(RAH(i));
Bruce Allan2b6b1682011-05-13 07:20:09 +00001735 hw->phy.ops.write_reg_page(hw, BM_RAR_H(i),
1736 (u16)(mac_reg & 0xFFFF));
1737 hw->phy.ops.write_reg_page(hw, BM_RAR_CTRL(i),
1738 (u16)((mac_reg & E1000_RAH_AV)
1739 >> 16));
Bruce Alland3738bb2010-06-16 13:27:28 +00001740 }
Bruce Allan2b6b1682011-05-13 07:20:09 +00001741
1742 e1000_disable_phy_wakeup_reg_access_bm(hw, &phy_reg);
1743
1744release:
1745 hw->phy.ops.release(hw);
Bruce Alland3738bb2010-06-16 13:27:28 +00001746}
1747
Bruce Alland3738bb2010-06-16 13:27:28 +00001748/**
1749 * e1000_lv_jumbo_workaround_ich8lan - required for jumbo frame operation
1750 * with 82579 PHY
1751 * @hw: pointer to the HW structure
1752 * @enable: flag to enable/disable workaround when enabling/disabling jumbos
1753 **/
1754s32 e1000_lv_jumbo_workaround_ich8lan(struct e1000_hw *hw, bool enable)
1755{
1756 s32 ret_val = 0;
1757 u16 phy_reg, data;
1758 u32 mac_reg;
1759 u16 i;
1760
Bruce Allan2fbe4522012-04-19 03:21:47 +00001761 if (hw->mac.type < e1000_pch2lan)
Bruce Allan5015e532012-02-08 02:55:56 +00001762 return 0;
Bruce Alland3738bb2010-06-16 13:27:28 +00001763
1764 /* disable Rx path while enabling/disabling workaround */
1765 e1e_rphy(hw, PHY_REG(769, 20), &phy_reg);
1766 ret_val = e1e_wphy(hw, PHY_REG(769, 20), phy_reg | (1 << 14));
1767 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001768 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001769
1770 if (enable) {
Bruce Allane921eb12012-11-28 09:28:37 +00001771 /* Write Rx addresses (rar_entry_count for RAL/H, +4 for
Bruce Alland3738bb2010-06-16 13:27:28 +00001772 * SHRAL/H) and initial CRC values to the MAC
1773 */
1774 for (i = 0; i < (hw->mac.rar_entry_count + 4); i++) {
Bruce Allan362e20c2013-02-20 04:05:45 +00001775 u8 mac_addr[ETH_ALEN] = { 0 };
Bruce Alland3738bb2010-06-16 13:27:28 +00001776 u32 addr_high, addr_low;
1777
1778 addr_high = er32(RAH(i));
1779 if (!(addr_high & E1000_RAH_AV))
1780 continue;
1781 addr_low = er32(RAL(i));
1782 mac_addr[0] = (addr_low & 0xFF);
1783 mac_addr[1] = ((addr_low >> 8) & 0xFF);
1784 mac_addr[2] = ((addr_low >> 16) & 0xFF);
1785 mac_addr[3] = ((addr_low >> 24) & 0xFF);
1786 mac_addr[4] = (addr_high & 0xFF);
1787 mac_addr[5] = ((addr_high >> 8) & 0xFF);
1788
Bruce Allanfe46f582011-01-06 14:29:51 +00001789 ew32(PCH_RAICC(i), ~ether_crc_le(ETH_ALEN, mac_addr));
Bruce Alland3738bb2010-06-16 13:27:28 +00001790 }
1791
1792 /* Write Rx addresses to the PHY */
1793 e1000_copy_rx_addrs_to_phy_ich8lan(hw);
1794
1795 /* Enable jumbo frame workaround in the MAC */
1796 mac_reg = er32(FFLT_DBG);
1797 mac_reg &= ~(1 << 14);
1798 mac_reg |= (7 << 15);
1799 ew32(FFLT_DBG, mac_reg);
1800
1801 mac_reg = er32(RCTL);
1802 mac_reg |= E1000_RCTL_SECRC;
1803 ew32(RCTL, mac_reg);
1804
1805 ret_val = e1000e_read_kmrn_reg(hw,
Bruce Allan17e813e2013-02-20 04:06:01 +00001806 E1000_KMRNCTRLSTA_CTRL_OFFSET,
1807 &data);
Bruce Alland3738bb2010-06-16 13:27:28 +00001808 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001809 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001810 ret_val = e1000e_write_kmrn_reg(hw,
1811 E1000_KMRNCTRLSTA_CTRL_OFFSET,
1812 data | (1 << 0));
1813 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001814 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001815 ret_val = e1000e_read_kmrn_reg(hw,
Bruce Allan17e813e2013-02-20 04:06:01 +00001816 E1000_KMRNCTRLSTA_HD_CTRL,
1817 &data);
Bruce Alland3738bb2010-06-16 13:27:28 +00001818 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001819 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001820 data &= ~(0xF << 8);
1821 data |= (0xB << 8);
1822 ret_val = e1000e_write_kmrn_reg(hw,
1823 E1000_KMRNCTRLSTA_HD_CTRL,
1824 data);
1825 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001826 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001827
1828 /* Enable jumbo frame workaround in the PHY */
Bruce Alland3738bb2010-06-16 13:27:28 +00001829 e1e_rphy(hw, PHY_REG(769, 23), &data);
1830 data &= ~(0x7F << 5);
1831 data |= (0x37 << 5);
1832 ret_val = e1e_wphy(hw, PHY_REG(769, 23), data);
1833 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001834 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001835 e1e_rphy(hw, PHY_REG(769, 16), &data);
1836 data &= ~(1 << 13);
Bruce Alland3738bb2010-06-16 13:27:28 +00001837 ret_val = e1e_wphy(hw, PHY_REG(769, 16), data);
1838 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001839 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001840 e1e_rphy(hw, PHY_REG(776, 20), &data);
1841 data &= ~(0x3FF << 2);
1842 data |= (0x1A << 2);
1843 ret_val = e1e_wphy(hw, PHY_REG(776, 20), data);
1844 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001845 return ret_val;
Bruce Allanb64e9dd2011-09-30 08:07:00 +00001846 ret_val = e1e_wphy(hw, PHY_REG(776, 23), 0xF100);
Bruce Alland3738bb2010-06-16 13:27:28 +00001847 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001848 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001849 e1e_rphy(hw, HV_PM_CTRL, &data);
1850 ret_val = e1e_wphy(hw, HV_PM_CTRL, data | (1 << 10));
1851 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001852 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001853 } else {
1854 /* Write MAC register values back to h/w defaults */
1855 mac_reg = er32(FFLT_DBG);
1856 mac_reg &= ~(0xF << 14);
1857 ew32(FFLT_DBG, mac_reg);
1858
1859 mac_reg = er32(RCTL);
1860 mac_reg &= ~E1000_RCTL_SECRC;
Bruce Allana1ce6472010-09-22 17:16:40 +00001861 ew32(RCTL, mac_reg);
Bruce Alland3738bb2010-06-16 13:27:28 +00001862
1863 ret_val = e1000e_read_kmrn_reg(hw,
Bruce Allan17e813e2013-02-20 04:06:01 +00001864 E1000_KMRNCTRLSTA_CTRL_OFFSET,
1865 &data);
Bruce Alland3738bb2010-06-16 13:27:28 +00001866 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001867 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001868 ret_val = e1000e_write_kmrn_reg(hw,
1869 E1000_KMRNCTRLSTA_CTRL_OFFSET,
1870 data & ~(1 << 0));
1871 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001872 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001873 ret_val = e1000e_read_kmrn_reg(hw,
Bruce Allan17e813e2013-02-20 04:06:01 +00001874 E1000_KMRNCTRLSTA_HD_CTRL,
1875 &data);
Bruce Alland3738bb2010-06-16 13:27:28 +00001876 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001877 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001878 data &= ~(0xF << 8);
1879 data |= (0xB << 8);
1880 ret_val = e1000e_write_kmrn_reg(hw,
1881 E1000_KMRNCTRLSTA_HD_CTRL,
1882 data);
1883 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001884 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001885
1886 /* Write PHY register values back to h/w defaults */
Bruce Alland3738bb2010-06-16 13:27:28 +00001887 e1e_rphy(hw, PHY_REG(769, 23), &data);
1888 data &= ~(0x7F << 5);
1889 ret_val = e1e_wphy(hw, PHY_REG(769, 23), data);
1890 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001891 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001892 e1e_rphy(hw, PHY_REG(769, 16), &data);
Bruce Alland3738bb2010-06-16 13:27:28 +00001893 data |= (1 << 13);
1894 ret_val = e1e_wphy(hw, PHY_REG(769, 16), data);
1895 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001896 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001897 e1e_rphy(hw, PHY_REG(776, 20), &data);
1898 data &= ~(0x3FF << 2);
1899 data |= (0x8 << 2);
1900 ret_val = e1e_wphy(hw, PHY_REG(776, 20), data);
1901 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001902 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001903 ret_val = e1e_wphy(hw, PHY_REG(776, 23), 0x7E00);
1904 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001905 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001906 e1e_rphy(hw, HV_PM_CTRL, &data);
1907 ret_val = e1e_wphy(hw, HV_PM_CTRL, data & ~(1 << 10));
1908 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001909 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001910 }
1911
1912 /* re-enable Rx path after enabling/disabling workaround */
Bruce Allan5015e532012-02-08 02:55:56 +00001913 return e1e_wphy(hw, PHY_REG(769, 20), phy_reg & ~(1 << 14));
Bruce Alland3738bb2010-06-16 13:27:28 +00001914}
1915
1916/**
1917 * e1000_lv_phy_workarounds_ich8lan - A series of Phy workarounds to be
1918 * done after every PHY reset.
1919 **/
1920static s32 e1000_lv_phy_workarounds_ich8lan(struct e1000_hw *hw)
1921{
1922 s32 ret_val = 0;
1923
1924 if (hw->mac.type != e1000_pch2lan)
Bruce Allan5015e532012-02-08 02:55:56 +00001925 return 0;
Bruce Alland3738bb2010-06-16 13:27:28 +00001926
1927 /* Set MDIO slow mode before any other MDIO access */
1928 ret_val = e1000_set_mdio_slow_mode_hv(hw);
Bruce Allan8e5ab422012-12-05 06:26:19 +00001929 if (ret_val)
1930 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001931
Bruce Allan4d241362011-12-16 00:46:06 +00001932 ret_val = hw->phy.ops.acquire(hw);
1933 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001934 return ret_val;
Bruce Allan4d241362011-12-16 00:46:06 +00001935 /* set MSE higher to enable link to stay up when noise is high */
Bruce Allan4ddc48a2012-12-05 06:25:58 +00001936 ret_val = e1000_write_emi_reg_locked(hw, I82579_MSE_THRESHOLD, 0x0034);
Bruce Allan4d241362011-12-16 00:46:06 +00001937 if (ret_val)
1938 goto release;
1939 /* drop link after 5 times MSE threshold was reached */
Bruce Allan4ddc48a2012-12-05 06:25:58 +00001940 ret_val = e1000_write_emi_reg_locked(hw, I82579_MSE_LINK_DOWN, 0x0005);
Bruce Allan4d241362011-12-16 00:46:06 +00001941release:
1942 hw->phy.ops.release(hw);
1943
Bruce Alland3738bb2010-06-16 13:27:28 +00001944 return ret_val;
1945}
1946
1947/**
Bruce Allan831bd2e2010-09-22 17:16:18 +00001948 * e1000_k1_gig_workaround_lv - K1 Si workaround
1949 * @hw: pointer to the HW structure
1950 *
1951 * Workaround to set the K1 beacon duration for 82579 parts
1952 **/
1953static s32 e1000_k1_workaround_lv(struct e1000_hw *hw)
1954{
1955 s32 ret_val = 0;
1956 u16 status_reg = 0;
1957 u32 mac_reg;
Bruce Allan0ed013e2011-07-29 05:52:56 +00001958 u16 phy_reg;
Bruce Allan831bd2e2010-09-22 17:16:18 +00001959
1960 if (hw->mac.type != e1000_pch2lan)
Bruce Allan5015e532012-02-08 02:55:56 +00001961 return 0;
Bruce Allan831bd2e2010-09-22 17:16:18 +00001962
1963 /* Set K1 beacon duration based on 1Gbps speed or otherwise */
1964 ret_val = e1e_rphy(hw, HV_M_STATUS, &status_reg);
1965 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001966 return ret_val;
Bruce Allan831bd2e2010-09-22 17:16:18 +00001967
1968 if ((status_reg & (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE))
1969 == (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE)) {
1970 mac_reg = er32(FEXTNVM4);
1971 mac_reg &= ~E1000_FEXTNVM4_BEACON_DURATION_MASK;
1972
Bruce Allan0ed013e2011-07-29 05:52:56 +00001973 ret_val = e1e_rphy(hw, I82579_LPI_CTRL, &phy_reg);
1974 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001975 return ret_val;
Bruce Allan831bd2e2010-09-22 17:16:18 +00001976
Bruce Allan0ed013e2011-07-29 05:52:56 +00001977 if (status_reg & HV_M_STATUS_SPEED_1000) {
Bruce Allan36ceeb42012-03-20 03:47:47 +00001978 u16 pm_phy_reg;
1979
Bruce Allan0ed013e2011-07-29 05:52:56 +00001980 mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_8USEC;
1981 phy_reg &= ~I82579_LPI_CTRL_FORCE_PLL_LOCK_COUNT;
Bruce Allan36ceeb42012-03-20 03:47:47 +00001982 /* LV 1G Packet drop issue wa */
1983 ret_val = e1e_rphy(hw, HV_PM_CTRL, &pm_phy_reg);
1984 if (ret_val)
1985 return ret_val;
1986 pm_phy_reg &= ~HV_PM_CTRL_PLL_STOP_IN_K1_GIGA;
1987 ret_val = e1e_wphy(hw, HV_PM_CTRL, pm_phy_reg);
1988 if (ret_val)
1989 return ret_val;
Bruce Allan0ed013e2011-07-29 05:52:56 +00001990 } else {
1991 mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_16USEC;
1992 phy_reg |= I82579_LPI_CTRL_FORCE_PLL_LOCK_COUNT;
1993 }
Bruce Allan831bd2e2010-09-22 17:16:18 +00001994 ew32(FEXTNVM4, mac_reg);
Bruce Allan0ed013e2011-07-29 05:52:56 +00001995 ret_val = e1e_wphy(hw, I82579_LPI_CTRL, phy_reg);
Bruce Allan831bd2e2010-09-22 17:16:18 +00001996 }
1997
Bruce Allan831bd2e2010-09-22 17:16:18 +00001998 return ret_val;
1999}
2000
2001/**
Bruce Allan605c82b2010-09-22 17:17:01 +00002002 * e1000_gate_hw_phy_config_ich8lan - disable PHY config via hardware
2003 * @hw: pointer to the HW structure
2004 * @gate: boolean set to true to gate, false to ungate
2005 *
2006 * Gate/ungate the automatic PHY configuration via hardware; perform
2007 * the configuration via software instead.
2008 **/
2009static void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate)
2010{
2011 u32 extcnf_ctrl;
2012
Bruce Allan2fbe4522012-04-19 03:21:47 +00002013 if (hw->mac.type < e1000_pch2lan)
Bruce Allan605c82b2010-09-22 17:17:01 +00002014 return;
2015
2016 extcnf_ctrl = er32(EXTCNF_CTRL);
2017
2018 if (gate)
2019 extcnf_ctrl |= E1000_EXTCNF_CTRL_GATE_PHY_CFG;
2020 else
2021 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_GATE_PHY_CFG;
2022
2023 ew32(EXTCNF_CTRL, extcnf_ctrl);
Bruce Allan605c82b2010-09-22 17:17:01 +00002024}
2025
2026/**
Bruce Allanfc0c7762009-07-01 13:27:55 +00002027 * e1000_lan_init_done_ich8lan - Check for PHY config completion
2028 * @hw: pointer to the HW structure
2029 *
2030 * Check the appropriate indication the MAC has finished configuring the
2031 * PHY after a software reset.
2032 **/
2033static void e1000_lan_init_done_ich8lan(struct e1000_hw *hw)
2034{
2035 u32 data, loop = E1000_ICH8_LAN_INIT_TIMEOUT;
2036
2037 /* Wait for basic configuration completes before proceeding */
2038 do {
2039 data = er32(STATUS);
2040 data &= E1000_STATUS_LAN_INIT_DONE;
2041 udelay(100);
2042 } while ((!data) && --loop);
2043
Bruce Allane921eb12012-11-28 09:28:37 +00002044 /* If basic configuration is incomplete before the above loop
Bruce Allanfc0c7762009-07-01 13:27:55 +00002045 * count reaches 0, loading the configuration from NVM will
2046 * leave the PHY in a bad state possibly resulting in no link.
2047 */
2048 if (loop == 0)
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002049 e_dbg("LAN_INIT_DONE not set, increase timeout\n");
Bruce Allanfc0c7762009-07-01 13:27:55 +00002050
2051 /* Clear the Init Done bit for the next init event */
2052 data = er32(STATUS);
2053 data &= ~E1000_STATUS_LAN_INIT_DONE;
2054 ew32(STATUS, data);
2055}
2056
2057/**
Bruce Allane98cac42010-05-10 15:02:32 +00002058 * e1000_post_phy_reset_ich8lan - Perform steps required after a PHY reset
Auke Kokbc7f75f2007-09-17 12:30:59 -07002059 * @hw: pointer to the HW structure
Auke Kokbc7f75f2007-09-17 12:30:59 -07002060 **/
Bruce Allane98cac42010-05-10 15:02:32 +00002061static s32 e1000_post_phy_reset_ich8lan(struct e1000_hw *hw)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002062{
Bruce Allanf523d212009-10-29 13:45:45 +00002063 s32 ret_val = 0;
2064 u16 reg;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002065
Bruce Allan44abd5c2012-02-22 09:02:37 +00002066 if (hw->phy.ops.check_reset_block(hw))
Bruce Allan5015e532012-02-08 02:55:56 +00002067 return 0;
Bruce Allanfc0c7762009-07-01 13:27:55 +00002068
Bruce Allan5f3eed62010-09-22 17:15:54 +00002069 /* Allow time for h/w to get to quiescent state after reset */
Bruce Allan1bba4382011-03-19 00:27:20 +00002070 usleep_range(10000, 20000);
Bruce Allan5f3eed62010-09-22 17:15:54 +00002071
Bruce Allanfddaa1a2010-01-13 01:52:49 +00002072 /* Perform any necessary post-reset workarounds */
Bruce Allane98cac42010-05-10 15:02:32 +00002073 switch (hw->mac.type) {
2074 case e1000_pchlan:
Bruce Allana4f58f52009-06-02 11:29:18 +00002075 ret_val = e1000_hv_phy_workarounds_ich8lan(hw);
2076 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00002077 return ret_val;
Bruce Allane98cac42010-05-10 15:02:32 +00002078 break;
Bruce Alland3738bb2010-06-16 13:27:28 +00002079 case e1000_pch2lan:
2080 ret_val = e1000_lv_phy_workarounds_ich8lan(hw);
2081 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00002082 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00002083 break;
Bruce Allane98cac42010-05-10 15:02:32 +00002084 default:
2085 break;
Bruce Allana4f58f52009-06-02 11:29:18 +00002086 }
2087
Bruce Allan3ebfc7c2011-05-13 07:20:14 +00002088 /* Clear the host wakeup bit after lcd reset */
2089 if (hw->mac.type >= e1000_pchlan) {
2090 e1e_rphy(hw, BM_PORT_GEN_CFG, &reg);
2091 reg &= ~BM_WUC_HOST_WU_BIT;
2092 e1e_wphy(hw, BM_PORT_GEN_CFG, reg);
2093 }
Bruce Allandb2932e2009-10-26 11:22:47 +00002094
Bruce Allanf523d212009-10-29 13:45:45 +00002095 /* Configure the LCD with the extended configuration region in NVM */
2096 ret_val = e1000_sw_lcd_config_ich8lan(hw);
2097 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00002098 return ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002099
Bruce Allanf523d212009-10-29 13:45:45 +00002100 /* Configure the LCD with the OEM bits in NVM */
Bruce Allane98cac42010-05-10 15:02:32 +00002101 ret_val = e1000_oem_bits_config_ich8lan(hw, true);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002102
Bruce Allan1effb452011-02-25 06:58:03 +00002103 if (hw->mac.type == e1000_pch2lan) {
2104 /* Ungate automatic PHY configuration on non-managed 82579 */
2105 if (!(er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) {
Bruce Allan1bba4382011-03-19 00:27:20 +00002106 usleep_range(10000, 20000);
Bruce Allan1effb452011-02-25 06:58:03 +00002107 e1000_gate_hw_phy_config_ich8lan(hw, false);
2108 }
2109
2110 /* Set EEE LPI Update Timer to 200usec */
2111 ret_val = hw->phy.ops.acquire(hw);
2112 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00002113 return ret_val;
Bruce Allan4ddc48a2012-12-05 06:25:58 +00002114 ret_val = e1000_write_emi_reg_locked(hw,
2115 I82579_LPI_UPDATE_TIMER,
2116 0x1387);
Bruce Allan1effb452011-02-25 06:58:03 +00002117 hw->phy.ops.release(hw);
Bruce Allan605c82b2010-09-22 17:17:01 +00002118 }
2119
Bruce Allane98cac42010-05-10 15:02:32 +00002120 return ret_val;
2121}
2122
2123/**
2124 * e1000_phy_hw_reset_ich8lan - Performs a PHY reset
2125 * @hw: pointer to the HW structure
2126 *
2127 * Resets the PHY
2128 * This is a function pointer entry point called by drivers
2129 * or other shared routines.
2130 **/
2131static s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw)
2132{
2133 s32 ret_val = 0;
2134
Bruce Allan605c82b2010-09-22 17:17:01 +00002135 /* Gate automatic PHY configuration by hardware on non-managed 82579 */
2136 if ((hw->mac.type == e1000_pch2lan) &&
2137 !(er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
2138 e1000_gate_hw_phy_config_ich8lan(hw, true);
2139
Bruce Allane98cac42010-05-10 15:02:32 +00002140 ret_val = e1000e_phy_hw_reset_generic(hw);
2141 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00002142 return ret_val;
Bruce Allane98cac42010-05-10 15:02:32 +00002143
Bruce Allan5015e532012-02-08 02:55:56 +00002144 return e1000_post_phy_reset_ich8lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002145}
2146
2147/**
Bruce Allanfa2ce132009-10-26 11:23:25 +00002148 * e1000_set_lplu_state_pchlan - Set Low Power Link Up state
2149 * @hw: pointer to the HW structure
2150 * @active: true to enable LPLU, false to disable
2151 *
2152 * Sets the LPLU state according to the active flag. For PCH, if OEM write
2153 * bit are disabled in the NVM, writing the LPLU bits in the MAC will not set
2154 * the phy speed. This function will manually set the LPLU bit and restart
2155 * auto-neg as hw would do. D3 and D0 LPLU will call the same function
2156 * since it configures the same bit.
2157 **/
2158static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active)
2159{
Bruce Allan70806a72013-01-05 05:08:37 +00002160 s32 ret_val;
Bruce Allanfa2ce132009-10-26 11:23:25 +00002161 u16 oem_reg;
2162
2163 ret_val = e1e_rphy(hw, HV_OEM_BITS, &oem_reg);
2164 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00002165 return ret_val;
Bruce Allanfa2ce132009-10-26 11:23:25 +00002166
2167 if (active)
2168 oem_reg |= HV_OEM_BITS_LPLU;
2169 else
2170 oem_reg &= ~HV_OEM_BITS_LPLU;
2171
Bruce Allan44abd5c2012-02-22 09:02:37 +00002172 if (!hw->phy.ops.check_reset_block(hw))
Bruce Allan464c85e2011-12-16 00:46:49 +00002173 oem_reg |= HV_OEM_BITS_RESTART_AN;
2174
Bruce Allan5015e532012-02-08 02:55:56 +00002175 return e1e_wphy(hw, HV_OEM_BITS, oem_reg);
Bruce Allanfa2ce132009-10-26 11:23:25 +00002176}
2177
2178/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07002179 * e1000_set_d0_lplu_state_ich8lan - Set Low Power Linkup D0 state
2180 * @hw: pointer to the HW structure
Bruce Allan564ea9b2009-11-20 23:26:44 +00002181 * @active: true to enable LPLU, false to disable
Auke Kokbc7f75f2007-09-17 12:30:59 -07002182 *
2183 * Sets the LPLU D0 state according to the active flag. When
2184 * activating LPLU this function also disables smart speed
2185 * and vice versa. LPLU will not be activated unless the
2186 * device autonegotiation advertisement meets standards of
2187 * either 10 or 10/100 or 10/100/1000 at all duplexes.
2188 * This is a function pointer entry point only called by
2189 * PHY setup routines.
2190 **/
2191static s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
2192{
2193 struct e1000_phy_info *phy = &hw->phy;
2194 u32 phy_ctrl;
2195 s32 ret_val = 0;
2196 u16 data;
2197
Bruce Allan97ac8ca2008-04-29 09:16:05 -07002198 if (phy->type == e1000_phy_ife)
Bruce Allan82607252012-02-08 02:55:09 +00002199 return 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002200
2201 phy_ctrl = er32(PHY_CTRL);
2202
2203 if (active) {
2204 phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU;
2205 ew32(PHY_CTRL, phy_ctrl);
2206
Bruce Allan60f12922009-07-01 13:28:14 +00002207 if (phy->type != e1000_phy_igp_3)
2208 return 0;
2209
Bruce Allane921eb12012-11-28 09:28:37 +00002210 /* Call gig speed drop workaround on LPLU before accessing
Bruce Allanad680762008-03-28 09:15:03 -07002211 * any PHY registers
2212 */
Bruce Allan60f12922009-07-01 13:28:14 +00002213 if (hw->mac.type == e1000_ich8lan)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002214 e1000e_gig_downshift_workaround_ich8lan(hw);
2215
2216 /* When LPLU is enabled, we should disable SmartSpeed */
2217 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data);
Bruce Allan7dbbe5d2013-01-05 05:08:31 +00002218 if (ret_val)
2219 return ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002220 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
2221 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);
2222 if (ret_val)
2223 return ret_val;
2224 } else {
2225 phy_ctrl &= ~E1000_PHY_CTRL_D0A_LPLU;
2226 ew32(PHY_CTRL, phy_ctrl);
2227
Bruce Allan60f12922009-07-01 13:28:14 +00002228 if (phy->type != e1000_phy_igp_3)
2229 return 0;
2230
Bruce Allane921eb12012-11-28 09:28:37 +00002231 /* LPLU and SmartSpeed are mutually exclusive. LPLU is used
Auke Kokbc7f75f2007-09-17 12:30:59 -07002232 * during Dx states where the power conservation is most
2233 * important. During driver activity we should enable
Bruce Allanad680762008-03-28 09:15:03 -07002234 * SmartSpeed, so performance is maintained.
2235 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002236 if (phy->smart_speed == e1000_smart_speed_on) {
2237 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
Bruce Allanad680762008-03-28 09:15:03 -07002238 &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002239 if (ret_val)
2240 return ret_val;
2241
2242 data |= IGP01E1000_PSCFR_SMART_SPEED;
2243 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
Bruce Allanad680762008-03-28 09:15:03 -07002244 data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002245 if (ret_val)
2246 return ret_val;
2247 } else if (phy->smart_speed == e1000_smart_speed_off) {
2248 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
Bruce Allanad680762008-03-28 09:15:03 -07002249 &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002250 if (ret_val)
2251 return ret_val;
2252
2253 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
2254 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
Bruce Allanad680762008-03-28 09:15:03 -07002255 data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002256 if (ret_val)
2257 return ret_val;
2258 }
2259 }
2260
2261 return 0;
2262}
2263
2264/**
2265 * e1000_set_d3_lplu_state_ich8lan - Set Low Power Linkup D3 state
2266 * @hw: pointer to the HW structure
Bruce Allan564ea9b2009-11-20 23:26:44 +00002267 * @active: true to enable LPLU, false to disable
Auke Kokbc7f75f2007-09-17 12:30:59 -07002268 *
2269 * Sets the LPLU D3 state according to the active flag. When
2270 * activating LPLU this function also disables smart speed
2271 * and vice versa. LPLU will not be activated unless the
2272 * device autonegotiation advertisement meets standards of
2273 * either 10 or 10/100 or 10/100/1000 at all duplexes.
2274 * This is a function pointer entry point only called by
2275 * PHY setup routines.
2276 **/
2277static s32 e1000_set_d3_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
2278{
2279 struct e1000_phy_info *phy = &hw->phy;
2280 u32 phy_ctrl;
Bruce Alland7eb3382012-02-08 02:55:14 +00002281 s32 ret_val = 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002282 u16 data;
2283
2284 phy_ctrl = er32(PHY_CTRL);
2285
2286 if (!active) {
2287 phy_ctrl &= ~E1000_PHY_CTRL_NOND0A_LPLU;
2288 ew32(PHY_CTRL, phy_ctrl);
Bruce Allan60f12922009-07-01 13:28:14 +00002289
2290 if (phy->type != e1000_phy_igp_3)
2291 return 0;
2292
Bruce Allane921eb12012-11-28 09:28:37 +00002293 /* LPLU and SmartSpeed are mutually exclusive. LPLU is used
Auke Kokbc7f75f2007-09-17 12:30:59 -07002294 * during Dx states where the power conservation is most
2295 * important. During driver activity we should enable
Bruce Allanad680762008-03-28 09:15:03 -07002296 * SmartSpeed, so performance is maintained.
2297 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002298 if (phy->smart_speed == e1000_smart_speed_on) {
Bruce Allanad680762008-03-28 09:15:03 -07002299 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
2300 &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002301 if (ret_val)
2302 return ret_val;
2303
2304 data |= IGP01E1000_PSCFR_SMART_SPEED;
Bruce Allanad680762008-03-28 09:15:03 -07002305 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
2306 data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002307 if (ret_val)
2308 return ret_val;
2309 } else if (phy->smart_speed == e1000_smart_speed_off) {
Bruce Allanad680762008-03-28 09:15:03 -07002310 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
2311 &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002312 if (ret_val)
2313 return ret_val;
2314
2315 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
Bruce Allanad680762008-03-28 09:15:03 -07002316 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
2317 data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002318 if (ret_val)
2319 return ret_val;
2320 }
2321 } else if ((phy->autoneg_advertised == E1000_ALL_SPEED_DUPLEX) ||
2322 (phy->autoneg_advertised == E1000_ALL_NOT_GIG) ||
2323 (phy->autoneg_advertised == E1000_ALL_10_SPEED)) {
2324 phy_ctrl |= E1000_PHY_CTRL_NOND0A_LPLU;
2325 ew32(PHY_CTRL, phy_ctrl);
2326
Bruce Allan60f12922009-07-01 13:28:14 +00002327 if (phy->type != e1000_phy_igp_3)
2328 return 0;
2329
Bruce Allane921eb12012-11-28 09:28:37 +00002330 /* Call gig speed drop workaround on LPLU before accessing
Bruce Allanad680762008-03-28 09:15:03 -07002331 * any PHY registers
2332 */
Bruce Allan60f12922009-07-01 13:28:14 +00002333 if (hw->mac.type == e1000_ich8lan)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002334 e1000e_gig_downshift_workaround_ich8lan(hw);
2335
2336 /* When LPLU is enabled, we should disable SmartSpeed */
Bruce Allanad680762008-03-28 09:15:03 -07002337 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002338 if (ret_val)
2339 return ret_val;
2340
2341 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
Bruce Allanad680762008-03-28 09:15:03 -07002342 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002343 }
2344
Bruce Alland7eb3382012-02-08 02:55:14 +00002345 return ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002346}
2347
2348/**
Bruce Allanf4187b52008-08-26 18:36:50 -07002349 * e1000_valid_nvm_bank_detect_ich8lan - finds out the valid bank 0 or 1
2350 * @hw: pointer to the HW structure
2351 * @bank: pointer to the variable that returns the active bank
2352 *
2353 * Reads signature byte from the NVM using the flash access registers.
Bruce Allane2434552008-11-21 17:02:41 -08002354 * Word 0x13 bits 15:14 = 10b indicate a valid signature for that bank.
Bruce Allanf4187b52008-08-26 18:36:50 -07002355 **/
2356static s32 e1000_valid_nvm_bank_detect_ich8lan(struct e1000_hw *hw, u32 *bank)
2357{
Bruce Allane2434552008-11-21 17:02:41 -08002358 u32 eecd;
Bruce Allanf4187b52008-08-26 18:36:50 -07002359 struct e1000_nvm_info *nvm = &hw->nvm;
Bruce Allanf4187b52008-08-26 18:36:50 -07002360 u32 bank1_offset = nvm->flash_bank_size * sizeof(u16);
2361 u32 act_offset = E1000_ICH_NVM_SIG_WORD * 2 + 1;
Bruce Allane2434552008-11-21 17:02:41 -08002362 u8 sig_byte = 0;
Bruce Allanf71dde62012-02-08 02:55:35 +00002363 s32 ret_val;
Bruce Allanf4187b52008-08-26 18:36:50 -07002364
Bruce Allane2434552008-11-21 17:02:41 -08002365 switch (hw->mac.type) {
2366 case e1000_ich8lan:
2367 case e1000_ich9lan:
2368 eecd = er32(EECD);
2369 if ((eecd & E1000_EECD_SEC1VAL_VALID_MASK) ==
2370 E1000_EECD_SEC1VAL_VALID_MASK) {
2371 if (eecd & E1000_EECD_SEC1VAL)
Bruce Allanf4187b52008-08-26 18:36:50 -07002372 *bank = 1;
Bruce Allane2434552008-11-21 17:02:41 -08002373 else
2374 *bank = 0;
2375
2376 return 0;
Bruce Allanf4187b52008-08-26 18:36:50 -07002377 }
Bruce Allan434f1392011-12-16 00:46:54 +00002378 e_dbg("Unable to determine valid NVM bank via EEC - reading flash signature\n");
Bruce Allane2434552008-11-21 17:02:41 -08002379 /* fall-thru */
2380 default:
2381 /* set bank to 0 in case flash read fails */
2382 *bank = 0;
2383
2384 /* Check bank 0 */
2385 ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset,
Bruce Allanf0ff4392013-02-20 04:05:39 +00002386 &sig_byte);
Bruce Allane2434552008-11-21 17:02:41 -08002387 if (ret_val)
2388 return ret_val;
2389 if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
2390 E1000_ICH_NVM_SIG_VALUE) {
2391 *bank = 0;
2392 return 0;
2393 }
2394
2395 /* Check bank 1 */
2396 ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset +
Bruce Allanf0ff4392013-02-20 04:05:39 +00002397 bank1_offset,
2398 &sig_byte);
Bruce Allane2434552008-11-21 17:02:41 -08002399 if (ret_val)
2400 return ret_val;
2401 if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
2402 E1000_ICH_NVM_SIG_VALUE) {
2403 *bank = 1;
2404 return 0;
2405 }
2406
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002407 e_dbg("ERROR: No valid NVM bank present\n");
Bruce Allane2434552008-11-21 17:02:41 -08002408 return -E1000_ERR_NVM;
Bruce Allanf4187b52008-08-26 18:36:50 -07002409 }
Bruce Allanf4187b52008-08-26 18:36:50 -07002410}
2411
2412/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07002413 * e1000_read_nvm_ich8lan - Read word(s) from the NVM
2414 * @hw: pointer to the HW structure
2415 * @offset: The offset (in bytes) of the word(s) to read.
2416 * @words: Size of data to read in words
2417 * @data: Pointer to the word(s) to read at offset.
2418 *
2419 * Reads a word(s) from the NVM using the flash access registers.
2420 **/
2421static s32 e1000_read_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
2422 u16 *data)
2423{
2424 struct e1000_nvm_info *nvm = &hw->nvm;
2425 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
2426 u32 act_offset;
Bruce Allan148675a2009-08-07 07:41:56 +00002427 s32 ret_val = 0;
Bruce Allanf4187b52008-08-26 18:36:50 -07002428 u32 bank = 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002429 u16 i, word;
2430
2431 if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
2432 (words == 0)) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002433 e_dbg("nvm parameter(s) out of bounds\n");
Bruce Allanca15df52009-10-26 11:23:43 +00002434 ret_val = -E1000_ERR_NVM;
2435 goto out;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002436 }
2437
Bruce Allan94d81862009-11-20 23:25:26 +00002438 nvm->ops.acquire(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002439
Bruce Allanf4187b52008-08-26 18:36:50 -07002440 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
Bruce Allan148675a2009-08-07 07:41:56 +00002441 if (ret_val) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002442 e_dbg("Could not detect valid bank, assuming bank 0\n");
Bruce Allan148675a2009-08-07 07:41:56 +00002443 bank = 0;
2444 }
Bruce Allanf4187b52008-08-26 18:36:50 -07002445
2446 act_offset = (bank) ? nvm->flash_bank_size : 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002447 act_offset += offset;
2448
Bruce Allan148675a2009-08-07 07:41:56 +00002449 ret_val = 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002450 for (i = 0; i < words; i++) {
Bruce Allan362e20c2013-02-20 04:05:45 +00002451 if (dev_spec->shadow_ram[offset + i].modified) {
2452 data[i] = dev_spec->shadow_ram[offset + i].value;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002453 } else {
2454 ret_val = e1000_read_flash_word_ich8lan(hw,
2455 act_offset + i,
2456 &word);
2457 if (ret_val)
2458 break;
2459 data[i] = word;
2460 }
2461 }
2462
Bruce Allan94d81862009-11-20 23:25:26 +00002463 nvm->ops.release(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002464
Bruce Allane2434552008-11-21 17:02:41 -08002465out:
2466 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002467 e_dbg("NVM read error: %d\n", ret_val);
Bruce Allane2434552008-11-21 17:02:41 -08002468
Auke Kokbc7f75f2007-09-17 12:30:59 -07002469 return ret_val;
2470}
2471
2472/**
2473 * e1000_flash_cycle_init_ich8lan - Initialize flash
2474 * @hw: pointer to the HW structure
2475 *
2476 * This function does initial flash setup so that a new read/write/erase cycle
2477 * can be started.
2478 **/
2479static s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw)
2480{
2481 union ich8_hws_flash_status hsfsts;
2482 s32 ret_val = -E1000_ERR_NVM;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002483
2484 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
2485
2486 /* Check if the flash descriptor is valid */
Bruce Allan04499ec2012-04-13 00:08:31 +00002487 if (!hsfsts.hsf_status.fldesvalid) {
Bruce Allan434f1392011-12-16 00:46:54 +00002488 e_dbg("Flash descriptor invalid. SW Sequencing must be used.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07002489 return -E1000_ERR_NVM;
2490 }
2491
2492 /* Clear FCERR and DAEL in hw status by writing 1 */
2493 hsfsts.hsf_status.flcerr = 1;
2494 hsfsts.hsf_status.dael = 1;
2495
2496 ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
2497
Bruce Allane921eb12012-11-28 09:28:37 +00002498 /* Either we should have a hardware SPI cycle in progress
Auke Kokbc7f75f2007-09-17 12:30:59 -07002499 * bit to check against, in order to start a new cycle or
2500 * FDONE bit should be changed in the hardware so that it
Auke Kok489815c2008-02-21 15:11:07 -08002501 * is 1 after hardware reset, which can then be used as an
Auke Kokbc7f75f2007-09-17 12:30:59 -07002502 * indication whether a cycle is in progress or has been
2503 * completed.
2504 */
2505
Bruce Allan04499ec2012-04-13 00:08:31 +00002506 if (!hsfsts.hsf_status.flcinprog) {
Bruce Allane921eb12012-11-28 09:28:37 +00002507 /* There is no cycle running at present,
Bruce Allan5ff5b662009-12-01 15:51:11 +00002508 * so we can start a cycle.
Bruce Allanad680762008-03-28 09:15:03 -07002509 * Begin by setting Flash Cycle Done.
2510 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002511 hsfsts.hsf_status.flcdone = 1;
2512 ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
2513 ret_val = 0;
2514 } else {
Bruce Allanf71dde62012-02-08 02:55:35 +00002515 s32 i;
Bruce Allan90da0662011-01-06 07:02:53 +00002516
Bruce Allane921eb12012-11-28 09:28:37 +00002517 /* Otherwise poll for sometime so the current
Bruce Allanad680762008-03-28 09:15:03 -07002518 * cycle has a chance to end before giving up.
2519 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002520 for (i = 0; i < ICH_FLASH_READ_COMMAND_TIMEOUT; i++) {
Bruce Allanc8243ee2011-12-17 08:32:57 +00002521 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
Bruce Allan04499ec2012-04-13 00:08:31 +00002522 if (!hsfsts.hsf_status.flcinprog) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07002523 ret_val = 0;
2524 break;
2525 }
2526 udelay(1);
2527 }
Bruce Allan9e2d7652012-01-31 06:37:27 +00002528 if (!ret_val) {
Bruce Allane921eb12012-11-28 09:28:37 +00002529 /* Successful in waiting for previous cycle to timeout,
Bruce Allanad680762008-03-28 09:15:03 -07002530 * now set the Flash Cycle Done.
2531 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002532 hsfsts.hsf_status.flcdone = 1;
2533 ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
2534 } else {
Joe Perches2c73e1f2010-03-26 20:16:59 +00002535 e_dbg("Flash controller busy, cannot get access\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07002536 }
2537 }
2538
2539 return ret_val;
2540}
2541
2542/**
2543 * e1000_flash_cycle_ich8lan - Starts flash cycle (read/write/erase)
2544 * @hw: pointer to the HW structure
2545 * @timeout: maximum time to wait for completion
2546 *
2547 * This function starts a flash cycle and waits for its completion.
2548 **/
2549static s32 e1000_flash_cycle_ich8lan(struct e1000_hw *hw, u32 timeout)
2550{
2551 union ich8_hws_flash_ctrl hsflctl;
2552 union ich8_hws_flash_status hsfsts;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002553 u32 i = 0;
2554
2555 /* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */
2556 hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
2557 hsflctl.hsf_ctrl.flcgo = 1;
2558 ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
2559
2560 /* wait till FDONE bit is set to 1 */
2561 do {
2562 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
Bruce Allan04499ec2012-04-13 00:08:31 +00002563 if (hsfsts.hsf_status.flcdone)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002564 break;
2565 udelay(1);
2566 } while (i++ < timeout);
2567
Bruce Allan04499ec2012-04-13 00:08:31 +00002568 if (hsfsts.hsf_status.flcdone && !hsfsts.hsf_status.flcerr)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002569 return 0;
2570
Bruce Allan55920b52012-02-08 02:55:25 +00002571 return -E1000_ERR_NVM;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002572}
2573
2574/**
2575 * e1000_read_flash_word_ich8lan - Read word from flash
2576 * @hw: pointer to the HW structure
2577 * @offset: offset to data location
2578 * @data: pointer to the location for storing the data
2579 *
2580 * Reads the flash word at offset into data. Offset is converted
2581 * to bytes before read.
2582 **/
2583static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset,
2584 u16 *data)
2585{
2586 /* Must convert offset into bytes. */
2587 offset <<= 1;
2588
2589 return e1000_read_flash_data_ich8lan(hw, offset, 2, data);
2590}
2591
2592/**
Bruce Allanf4187b52008-08-26 18:36:50 -07002593 * e1000_read_flash_byte_ich8lan - Read byte from flash
2594 * @hw: pointer to the HW structure
2595 * @offset: The offset of the byte to read.
2596 * @data: Pointer to a byte to store the value read.
2597 *
2598 * Reads a single byte from the NVM using the flash access registers.
2599 **/
2600static s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
2601 u8 *data)
2602{
2603 s32 ret_val;
2604 u16 word = 0;
2605
2606 ret_val = e1000_read_flash_data_ich8lan(hw, offset, 1, &word);
2607 if (ret_val)
2608 return ret_val;
2609
2610 *data = (u8)word;
2611
2612 return 0;
2613}
2614
2615/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07002616 * e1000_read_flash_data_ich8lan - Read byte or word from NVM
2617 * @hw: pointer to the HW structure
2618 * @offset: The offset (in bytes) of the byte or word to read.
2619 * @size: Size of data to read, 1=byte 2=word
2620 * @data: Pointer to the word to store the value read.
2621 *
2622 * Reads a byte or word from the NVM using the flash access registers.
2623 **/
2624static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
2625 u8 size, u16 *data)
2626{
2627 union ich8_hws_flash_status hsfsts;
2628 union ich8_hws_flash_ctrl hsflctl;
2629 u32 flash_linear_addr;
2630 u32 flash_data = 0;
2631 s32 ret_val = -E1000_ERR_NVM;
2632 u8 count = 0;
2633
2634 if (size < 1 || size > 2 || offset > ICH_FLASH_LINEAR_ADDR_MASK)
2635 return -E1000_ERR_NVM;
2636
Bruce Allanf0ff4392013-02-20 04:05:39 +00002637 flash_linear_addr = ((ICH_FLASH_LINEAR_ADDR_MASK & offset) +
2638 hw->nvm.flash_base_addr);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002639
2640 do {
2641 udelay(1);
2642 /* Steps */
2643 ret_val = e1000_flash_cycle_init_ich8lan(hw);
Bruce Allan9e2d7652012-01-31 06:37:27 +00002644 if (ret_val)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002645 break;
2646
2647 hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
2648 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
2649 hsflctl.hsf_ctrl.fldbcount = size - 1;
2650 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_READ;
2651 ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
2652
2653 ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
2654
Bruce Allan17e813e2013-02-20 04:06:01 +00002655 ret_val =
2656 e1000_flash_cycle_ich8lan(hw,
2657 ICH_FLASH_READ_COMMAND_TIMEOUT);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002658
Bruce Allane921eb12012-11-28 09:28:37 +00002659 /* Check if FCERR is set to 1, if set to 1, clear it
Auke Kokbc7f75f2007-09-17 12:30:59 -07002660 * and try the whole sequence a few more times, else
2661 * read in (shift in) the Flash Data0, the order is
Bruce Allanad680762008-03-28 09:15:03 -07002662 * least significant byte first msb to lsb
2663 */
Bruce Allan9e2d7652012-01-31 06:37:27 +00002664 if (!ret_val) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07002665 flash_data = er32flash(ICH_FLASH_FDATA0);
Bruce Allanb1cdfea2010-12-11 05:53:47 +00002666 if (size == 1)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002667 *data = (u8)(flash_data & 0x000000FF);
Bruce Allanb1cdfea2010-12-11 05:53:47 +00002668 else if (size == 2)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002669 *data = (u16)(flash_data & 0x0000FFFF);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002670 break;
2671 } else {
Bruce Allane921eb12012-11-28 09:28:37 +00002672 /* If we've gotten here, then things are probably
Auke Kokbc7f75f2007-09-17 12:30:59 -07002673 * completely hosed, but if the error condition is
2674 * detected, it won't hurt to give it another try...
2675 * ICH_FLASH_CYCLE_REPEAT_COUNT times.
2676 */
2677 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
Bruce Allan04499ec2012-04-13 00:08:31 +00002678 if (hsfsts.hsf_status.flcerr) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07002679 /* Repeat for some time before giving up. */
2680 continue;
Bruce Allan04499ec2012-04-13 00:08:31 +00002681 } else if (!hsfsts.hsf_status.flcdone) {
Bruce Allan434f1392011-12-16 00:46:54 +00002682 e_dbg("Timeout error - flash cycle did not complete.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07002683 break;
2684 }
2685 }
2686 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
2687
2688 return ret_val;
2689}
2690
2691/**
2692 * e1000_write_nvm_ich8lan - Write word(s) to the NVM
2693 * @hw: pointer to the HW structure
2694 * @offset: The offset (in bytes) of the word(s) to write.
2695 * @words: Size of data to write in words
2696 * @data: Pointer to the word(s) to write at offset.
2697 *
2698 * Writes a byte or word to the NVM using the flash access registers.
2699 **/
2700static s32 e1000_write_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
2701 u16 *data)
2702{
2703 struct e1000_nvm_info *nvm = &hw->nvm;
2704 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002705 u16 i;
2706
2707 if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
2708 (words == 0)) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002709 e_dbg("nvm parameter(s) out of bounds\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07002710 return -E1000_ERR_NVM;
2711 }
2712
Bruce Allan94d81862009-11-20 23:25:26 +00002713 nvm->ops.acquire(hw);
Bruce Allanca15df52009-10-26 11:23:43 +00002714
Auke Kokbc7f75f2007-09-17 12:30:59 -07002715 for (i = 0; i < words; i++) {
Bruce Allan362e20c2013-02-20 04:05:45 +00002716 dev_spec->shadow_ram[offset + i].modified = true;
2717 dev_spec->shadow_ram[offset + i].value = data[i];
Auke Kokbc7f75f2007-09-17 12:30:59 -07002718 }
2719
Bruce Allan94d81862009-11-20 23:25:26 +00002720 nvm->ops.release(hw);
Bruce Allanca15df52009-10-26 11:23:43 +00002721
Auke Kokbc7f75f2007-09-17 12:30:59 -07002722 return 0;
2723}
2724
2725/**
2726 * e1000_update_nvm_checksum_ich8lan - Update the checksum for NVM
2727 * @hw: pointer to the HW structure
2728 *
2729 * The NVM checksum is updated by calling the generic update_nvm_checksum,
2730 * which writes the checksum to the shadow ram. The changes in the shadow
2731 * ram are then committed to the EEPROM by processing each bank at a time
2732 * checking for the modified bit and writing only the pending changes.
Auke Kok489815c2008-02-21 15:11:07 -08002733 * After a successful commit, the shadow ram is cleared and is ready for
Auke Kokbc7f75f2007-09-17 12:30:59 -07002734 * future writes.
2735 **/
2736static s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw)
2737{
2738 struct e1000_nvm_info *nvm = &hw->nvm;
2739 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
Bruce Allanf4187b52008-08-26 18:36:50 -07002740 u32 i, act_offset, new_bank_offset, old_bank_offset, bank;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002741 s32 ret_val;
2742 u16 data;
2743
2744 ret_val = e1000e_update_nvm_checksum_generic(hw);
2745 if (ret_val)
Bruce Allane2434552008-11-21 17:02:41 -08002746 goto out;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002747
2748 if (nvm->type != e1000_nvm_flash_sw)
Bruce Allane2434552008-11-21 17:02:41 -08002749 goto out;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002750
Bruce Allan94d81862009-11-20 23:25:26 +00002751 nvm->ops.acquire(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002752
Bruce Allane921eb12012-11-28 09:28:37 +00002753 /* We're writing to the opposite bank so if we're on bank 1,
Auke Kokbc7f75f2007-09-17 12:30:59 -07002754 * write to bank 0 etc. We also need to erase the segment that
Bruce Allanad680762008-03-28 09:15:03 -07002755 * is going to be written
2756 */
Bruce Allanf4187b52008-08-26 18:36:50 -07002757 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
Bruce Allane2434552008-11-21 17:02:41 -08002758 if (ret_val) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002759 e_dbg("Could not detect valid bank, assuming bank 0\n");
Bruce Allan148675a2009-08-07 07:41:56 +00002760 bank = 0;
Bruce Allane2434552008-11-21 17:02:41 -08002761 }
Bruce Allanf4187b52008-08-26 18:36:50 -07002762
2763 if (bank == 0) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07002764 new_bank_offset = nvm->flash_bank_size;
2765 old_bank_offset = 0;
Bruce Allane2434552008-11-21 17:02:41 -08002766 ret_val = e1000_erase_flash_bank_ich8lan(hw, 1);
Bruce Allan9c5e2092010-05-10 15:00:31 +00002767 if (ret_val)
2768 goto release;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002769 } else {
2770 old_bank_offset = nvm->flash_bank_size;
2771 new_bank_offset = 0;
Bruce Allane2434552008-11-21 17:02:41 -08002772 ret_val = e1000_erase_flash_bank_ich8lan(hw, 0);
Bruce Allan9c5e2092010-05-10 15:00:31 +00002773 if (ret_val)
2774 goto release;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002775 }
2776
2777 for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i++) {
Bruce Allane921eb12012-11-28 09:28:37 +00002778 /* Determine whether to write the value stored
Auke Kokbc7f75f2007-09-17 12:30:59 -07002779 * in the other NVM bank or a modified value stored
Bruce Allanad680762008-03-28 09:15:03 -07002780 * in the shadow RAM
2781 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002782 if (dev_spec->shadow_ram[i].modified) {
2783 data = dev_spec->shadow_ram[i].value;
2784 } else {
Bruce Allane2434552008-11-21 17:02:41 -08002785 ret_val = e1000_read_flash_word_ich8lan(hw, i +
Bruce Allanf0ff4392013-02-20 04:05:39 +00002786 old_bank_offset,
2787 &data);
Bruce Allane2434552008-11-21 17:02:41 -08002788 if (ret_val)
2789 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002790 }
2791
Bruce Allane921eb12012-11-28 09:28:37 +00002792 /* If the word is 0x13, then make sure the signature bits
Auke Kokbc7f75f2007-09-17 12:30:59 -07002793 * (15:14) are 11b until the commit has completed.
2794 * This will allow us to write 10b which indicates the
2795 * signature is valid. We want to do this after the write
2796 * has completed so that we don't mark the segment valid
Bruce Allanad680762008-03-28 09:15:03 -07002797 * while the write is still in progress
2798 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002799 if (i == E1000_ICH_NVM_SIG_WORD)
2800 data |= E1000_ICH_NVM_SIG_MASK;
2801
2802 /* Convert offset to bytes. */
2803 act_offset = (i + new_bank_offset) << 1;
2804
2805 udelay(100);
2806 /* Write the bytes to the new bank. */
2807 ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
2808 act_offset,
2809 (u8)data);
2810 if (ret_val)
2811 break;
2812
2813 udelay(100);
2814 ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
Bruce Allanf0ff4392013-02-20 04:05:39 +00002815 act_offset + 1,
2816 (u8)(data >> 8));
Auke Kokbc7f75f2007-09-17 12:30:59 -07002817 if (ret_val)
2818 break;
2819 }
2820
Bruce Allane921eb12012-11-28 09:28:37 +00002821 /* Don't bother writing the segment valid bits if sector
Bruce Allanad680762008-03-28 09:15:03 -07002822 * programming failed.
2823 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002824 if (ret_val) {
Bruce Allan4a770352008-10-01 17:18:35 -07002825 /* Possibly read-only, see e1000e_write_protect_nvm_ich8lan() */
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002826 e_dbg("Flash commit failed.\n");
Bruce Allan9c5e2092010-05-10 15:00:31 +00002827 goto release;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002828 }
2829
Bruce Allane921eb12012-11-28 09:28:37 +00002830 /* Finally validate the new segment by setting bit 15:14
Auke Kokbc7f75f2007-09-17 12:30:59 -07002831 * to 10b in word 0x13 , this can be done without an
2832 * erase as well since these bits are 11 to start with
Bruce Allanad680762008-03-28 09:15:03 -07002833 * and we need to change bit 14 to 0b
2834 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002835 act_offset = new_bank_offset + E1000_ICH_NVM_SIG_WORD;
Bruce Allane2434552008-11-21 17:02:41 -08002836 ret_val = e1000_read_flash_word_ich8lan(hw, act_offset, &data);
Bruce Allan9c5e2092010-05-10 15:00:31 +00002837 if (ret_val)
2838 goto release;
2839
Auke Kokbc7f75f2007-09-17 12:30:59 -07002840 data &= 0xBFFF;
2841 ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
2842 act_offset * 2 + 1,
2843 (u8)(data >> 8));
Bruce Allan9c5e2092010-05-10 15:00:31 +00002844 if (ret_val)
2845 goto release;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002846
Bruce Allane921eb12012-11-28 09:28:37 +00002847 /* And invalidate the previously valid segment by setting
Auke Kokbc7f75f2007-09-17 12:30:59 -07002848 * its signature word (0x13) high_byte to 0b. This can be
2849 * done without an erase because flash erase sets all bits
Bruce Allanad680762008-03-28 09:15:03 -07002850 * to 1's. We can write 1's to 0's without an erase
2851 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002852 act_offset = (old_bank_offset + E1000_ICH_NVM_SIG_WORD) * 2 + 1;
2853 ret_val = e1000_retry_write_flash_byte_ich8lan(hw, act_offset, 0);
Bruce Allan9c5e2092010-05-10 15:00:31 +00002854 if (ret_val)
2855 goto release;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002856
2857 /* Great! Everything worked, we can now clear the cached entries. */
2858 for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i++) {
Bruce Allan564ea9b2009-11-20 23:26:44 +00002859 dev_spec->shadow_ram[i].modified = false;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002860 dev_spec->shadow_ram[i].value = 0xFFFF;
2861 }
2862
Bruce Allan9c5e2092010-05-10 15:00:31 +00002863release:
Bruce Allan94d81862009-11-20 23:25:26 +00002864 nvm->ops.release(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002865
Bruce Allane921eb12012-11-28 09:28:37 +00002866 /* Reload the EEPROM, or else modifications will not appear
Auke Kokbc7f75f2007-09-17 12:30:59 -07002867 * until after the next adapter reset.
2868 */
Bruce Allan9c5e2092010-05-10 15:00:31 +00002869 if (!ret_val) {
Bruce Allane85e3632012-02-22 09:03:14 +00002870 nvm->ops.reload(hw);
Bruce Allan1bba4382011-03-19 00:27:20 +00002871 usleep_range(10000, 20000);
Bruce Allan9c5e2092010-05-10 15:00:31 +00002872 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07002873
Bruce Allane2434552008-11-21 17:02:41 -08002874out:
2875 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002876 e_dbg("NVM update error: %d\n", ret_val);
Bruce Allane2434552008-11-21 17:02:41 -08002877
Auke Kokbc7f75f2007-09-17 12:30:59 -07002878 return ret_val;
2879}
2880
2881/**
2882 * e1000_validate_nvm_checksum_ich8lan - Validate EEPROM checksum
2883 * @hw: pointer to the HW structure
2884 *
2885 * Check to see if checksum needs to be fixed by reading bit 6 in word 0x19.
2886 * If the bit is 0, that the EEPROM had been modified, but the checksum was not
2887 * calculated, in which case we need to calculate the checksum and set bit 6.
2888 **/
2889static s32 e1000_validate_nvm_checksum_ich8lan(struct e1000_hw *hw)
2890{
2891 s32 ret_val;
2892 u16 data;
Bruce Allan1cc7a3a2013-01-09 08:15:42 +00002893 u16 word;
2894 u16 valid_csum_mask;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002895
Bruce Allan1cc7a3a2013-01-09 08:15:42 +00002896 /* Read NVM and check Invalid Image CSUM bit. If this bit is 0,
2897 * the checksum needs to be fixed. This bit is an indication that
2898 * the NVM was prepared by OEM software and did not calculate
2899 * the checksum...a likely scenario.
Auke Kokbc7f75f2007-09-17 12:30:59 -07002900 */
Bruce Allan1cc7a3a2013-01-09 08:15:42 +00002901 switch (hw->mac.type) {
2902 case e1000_pch_lpt:
2903 word = NVM_COMPAT;
2904 valid_csum_mask = NVM_COMPAT_VALID_CSUM;
2905 break;
2906 default:
2907 word = NVM_FUTURE_INIT_WORD1;
2908 valid_csum_mask = NVM_FUTURE_INIT_WORD1_VALID_CSUM;
2909 break;
2910 }
2911
2912 ret_val = e1000_read_nvm(hw, word, 1, &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002913 if (ret_val)
2914 return ret_val;
2915
Bruce Allan1cc7a3a2013-01-09 08:15:42 +00002916 if (!(data & valid_csum_mask)) {
2917 data |= valid_csum_mask;
2918 ret_val = e1000_write_nvm(hw, word, 1, &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002919 if (ret_val)
2920 return ret_val;
2921 ret_val = e1000e_update_nvm_checksum(hw);
2922 if (ret_val)
2923 return ret_val;
2924 }
2925
2926 return e1000e_validate_nvm_checksum_generic(hw);
2927}
2928
2929/**
Bruce Allan4a770352008-10-01 17:18:35 -07002930 * e1000e_write_protect_nvm_ich8lan - Make the NVM read-only
2931 * @hw: pointer to the HW structure
2932 *
2933 * To prevent malicious write/erase of the NVM, set it to be read-only
2934 * so that the hardware ignores all write/erase cycles of the NVM via
2935 * the flash control registers. The shadow-ram copy of the NVM will
2936 * still be updated, however any updates to this copy will not stick
2937 * across driver reloads.
2938 **/
2939void e1000e_write_protect_nvm_ich8lan(struct e1000_hw *hw)
2940{
Bruce Allanca15df52009-10-26 11:23:43 +00002941 struct e1000_nvm_info *nvm = &hw->nvm;
Bruce Allan4a770352008-10-01 17:18:35 -07002942 union ich8_flash_protected_range pr0;
2943 union ich8_hws_flash_status hsfsts;
2944 u32 gfpreg;
Bruce Allan4a770352008-10-01 17:18:35 -07002945
Bruce Allan94d81862009-11-20 23:25:26 +00002946 nvm->ops.acquire(hw);
Bruce Allan4a770352008-10-01 17:18:35 -07002947
2948 gfpreg = er32flash(ICH_FLASH_GFPREG);
2949
2950 /* Write-protect GbE Sector of NVM */
2951 pr0.regval = er32flash(ICH_FLASH_PR0);
2952 pr0.range.base = gfpreg & FLASH_GFPREG_BASE_MASK;
2953 pr0.range.limit = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK);
2954 pr0.range.wpe = true;
2955 ew32flash(ICH_FLASH_PR0, pr0.regval);
2956
Bruce Allane921eb12012-11-28 09:28:37 +00002957 /* Lock down a subset of GbE Flash Control Registers, e.g.
Bruce Allan4a770352008-10-01 17:18:35 -07002958 * PR0 to prevent the write-protection from being lifted.
2959 * Once FLOCKDN is set, the registers protected by it cannot
2960 * be written until FLOCKDN is cleared by a hardware reset.
2961 */
2962 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
2963 hsfsts.hsf_status.flockdn = true;
2964 ew32flash(ICH_FLASH_HSFSTS, hsfsts.regval);
2965
Bruce Allan94d81862009-11-20 23:25:26 +00002966 nvm->ops.release(hw);
Bruce Allan4a770352008-10-01 17:18:35 -07002967}
2968
2969/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07002970 * e1000_write_flash_data_ich8lan - Writes bytes to the NVM
2971 * @hw: pointer to the HW structure
2972 * @offset: The offset (in bytes) of the byte/word to read.
2973 * @size: Size of data to read, 1=byte 2=word
2974 * @data: The byte(s) to write to the NVM.
2975 *
2976 * Writes one/two bytes to the NVM using the flash access registers.
2977 **/
2978static s32 e1000_write_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
2979 u8 size, u16 data)
2980{
2981 union ich8_hws_flash_status hsfsts;
2982 union ich8_hws_flash_ctrl hsflctl;
2983 u32 flash_linear_addr;
2984 u32 flash_data = 0;
2985 s32 ret_val;
2986 u8 count = 0;
2987
2988 if (size < 1 || size > 2 || data > size * 0xff ||
2989 offset > ICH_FLASH_LINEAR_ADDR_MASK)
2990 return -E1000_ERR_NVM;
2991
Bruce Allanf0ff4392013-02-20 04:05:39 +00002992 flash_linear_addr = ((ICH_FLASH_LINEAR_ADDR_MASK & offset) +
2993 hw->nvm.flash_base_addr);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002994
2995 do {
2996 udelay(1);
2997 /* Steps */
2998 ret_val = e1000_flash_cycle_init_ich8lan(hw);
2999 if (ret_val)
3000 break;
3001
3002 hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
3003 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
Bruce Allan362e20c2013-02-20 04:05:45 +00003004 hsflctl.hsf_ctrl.fldbcount = size - 1;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003005 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_WRITE;
3006 ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
3007
3008 ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
3009
3010 if (size == 1)
3011 flash_data = (u32)data & 0x00FF;
3012 else
3013 flash_data = (u32)data;
3014
3015 ew32flash(ICH_FLASH_FDATA0, flash_data);
3016
Bruce Allane921eb12012-11-28 09:28:37 +00003017 /* check if FCERR is set to 1 , if set to 1, clear it
Bruce Allanad680762008-03-28 09:15:03 -07003018 * and try the whole sequence a few more times else done
3019 */
Bruce Allan17e813e2013-02-20 04:06:01 +00003020 ret_val =
3021 e1000_flash_cycle_ich8lan(hw,
3022 ICH_FLASH_WRITE_COMMAND_TIMEOUT);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003023 if (!ret_val)
3024 break;
3025
Bruce Allane921eb12012-11-28 09:28:37 +00003026 /* If we're here, then things are most likely
Auke Kokbc7f75f2007-09-17 12:30:59 -07003027 * completely hosed, but if the error condition
3028 * is detected, it won't hurt to give it another
3029 * try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
3030 */
3031 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
Bruce Allan04499ec2012-04-13 00:08:31 +00003032 if (hsfsts.hsf_status.flcerr)
Auke Kokbc7f75f2007-09-17 12:30:59 -07003033 /* Repeat for some time before giving up. */
3034 continue;
Bruce Allan04499ec2012-04-13 00:08:31 +00003035 if (!hsfsts.hsf_status.flcdone) {
Bruce Allan434f1392011-12-16 00:46:54 +00003036 e_dbg("Timeout error - flash cycle did not complete.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07003037 break;
3038 }
3039 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
3040
3041 return ret_val;
3042}
3043
3044/**
3045 * e1000_write_flash_byte_ich8lan - Write a single byte to NVM
3046 * @hw: pointer to the HW structure
3047 * @offset: The index of the byte to read.
3048 * @data: The byte to write to the NVM.
3049 *
3050 * Writes a single byte to the NVM using the flash access registers.
3051 **/
3052static s32 e1000_write_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
3053 u8 data)
3054{
3055 u16 word = (u16)data;
3056
3057 return e1000_write_flash_data_ich8lan(hw, offset, 1, word);
3058}
3059
3060/**
3061 * e1000_retry_write_flash_byte_ich8lan - Writes a single byte to NVM
3062 * @hw: pointer to the HW structure
3063 * @offset: The offset of the byte to write.
3064 * @byte: The byte to write to the NVM.
3065 *
3066 * Writes a single byte to the NVM using the flash access registers.
3067 * Goes through a retry algorithm before giving up.
3068 **/
3069static s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw,
3070 u32 offset, u8 byte)
3071{
3072 s32 ret_val;
3073 u16 program_retries;
3074
3075 ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
3076 if (!ret_val)
3077 return ret_val;
3078
3079 for (program_retries = 0; program_retries < 100; program_retries++) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003080 e_dbg("Retrying Byte %2.2X at offset %u\n", byte, offset);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003081 udelay(100);
3082 ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
3083 if (!ret_val)
3084 break;
3085 }
3086 if (program_retries == 100)
3087 return -E1000_ERR_NVM;
3088
3089 return 0;
3090}
3091
3092/**
3093 * e1000_erase_flash_bank_ich8lan - Erase a bank (4k) from NVM
3094 * @hw: pointer to the HW structure
3095 * @bank: 0 for first bank, 1 for second bank, etc.
3096 *
3097 * Erases the bank specified. Each bank is a 4k block. Banks are 0 based.
3098 * bank N is 4096 * N + flash_reg_addr.
3099 **/
3100static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank)
3101{
3102 struct e1000_nvm_info *nvm = &hw->nvm;
3103 union ich8_hws_flash_status hsfsts;
3104 union ich8_hws_flash_ctrl hsflctl;
3105 u32 flash_linear_addr;
3106 /* bank size is in 16bit words - adjust to bytes */
3107 u32 flash_bank_size = nvm->flash_bank_size * 2;
3108 s32 ret_val;
3109 s32 count = 0;
Bruce Allana708dd82009-11-20 23:28:37 +00003110 s32 j, iteration, sector_size;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003111
3112 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
3113
Bruce Allane921eb12012-11-28 09:28:37 +00003114 /* Determine HW Sector size: Read BERASE bits of hw flash status
Bruce Allanad680762008-03-28 09:15:03 -07003115 * register
3116 * 00: The Hw sector is 256 bytes, hence we need to erase 16
Auke Kokbc7f75f2007-09-17 12:30:59 -07003117 * consecutive sectors. The start index for the nth Hw sector
3118 * can be calculated as = bank * 4096 + n * 256
3119 * 01: The Hw sector is 4K bytes, hence we need to erase 1 sector.
3120 * The start index for the nth Hw sector can be calculated
3121 * as = bank * 4096
3122 * 10: The Hw sector is 8K bytes, nth sector = bank * 8192
3123 * (ich9 only, otherwise error condition)
3124 * 11: The Hw sector is 64K bytes, nth sector = bank * 65536
3125 */
3126 switch (hsfsts.hsf_status.berasesz) {
3127 case 0:
3128 /* Hw sector size 256 */
3129 sector_size = ICH_FLASH_SEG_SIZE_256;
3130 iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_256;
3131 break;
3132 case 1:
3133 sector_size = ICH_FLASH_SEG_SIZE_4K;
Bruce Allan28c91952009-07-01 13:28:32 +00003134 iteration = 1;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003135 break;
3136 case 2:
Bruce Allan148675a2009-08-07 07:41:56 +00003137 sector_size = ICH_FLASH_SEG_SIZE_8K;
3138 iteration = 1;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003139 break;
3140 case 3:
3141 sector_size = ICH_FLASH_SEG_SIZE_64K;
Bruce Allan28c91952009-07-01 13:28:32 +00003142 iteration = 1;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003143 break;
3144 default:
3145 return -E1000_ERR_NVM;
3146 }
3147
3148 /* Start with the base address, then add the sector offset. */
3149 flash_linear_addr = hw->nvm.flash_base_addr;
Bruce Allan148675a2009-08-07 07:41:56 +00003150 flash_linear_addr += (bank) ? flash_bank_size : 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003151
Bruce Allan53aa82d2013-02-20 04:06:06 +00003152 for (j = 0; j < iteration; j++) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07003153 do {
Bruce Allan17e813e2013-02-20 04:06:01 +00003154 u32 timeout = ICH_FLASH_ERASE_COMMAND_TIMEOUT;
3155
Auke Kokbc7f75f2007-09-17 12:30:59 -07003156 /* Steps */
3157 ret_val = e1000_flash_cycle_init_ich8lan(hw);
3158 if (ret_val)
3159 return ret_val;
3160
Bruce Allane921eb12012-11-28 09:28:37 +00003161 /* Write a value 11 (block Erase) in Flash
Bruce Allanad680762008-03-28 09:15:03 -07003162 * Cycle field in hw flash control
3163 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003164 hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
3165 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_ERASE;
3166 ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
3167
Bruce Allane921eb12012-11-28 09:28:37 +00003168 /* Write the last 24 bits of an index within the
Auke Kokbc7f75f2007-09-17 12:30:59 -07003169 * block into Flash Linear address field in Flash
3170 * Address.
3171 */
3172 flash_linear_addr += (j * sector_size);
3173 ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
3174
Bruce Allan17e813e2013-02-20 04:06:01 +00003175 ret_val = e1000_flash_cycle_ich8lan(hw, timeout);
Bruce Allan9e2d7652012-01-31 06:37:27 +00003176 if (!ret_val)
Auke Kokbc7f75f2007-09-17 12:30:59 -07003177 break;
3178
Bruce Allane921eb12012-11-28 09:28:37 +00003179 /* Check if FCERR is set to 1. If 1,
Auke Kokbc7f75f2007-09-17 12:30:59 -07003180 * clear it and try the whole sequence
Bruce Allanad680762008-03-28 09:15:03 -07003181 * a few more times else Done
3182 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003183 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
Bruce Allan04499ec2012-04-13 00:08:31 +00003184 if (hsfsts.hsf_status.flcerr)
Bruce Allanad680762008-03-28 09:15:03 -07003185 /* repeat for some time before giving up */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003186 continue;
Bruce Allan04499ec2012-04-13 00:08:31 +00003187 else if (!hsfsts.hsf_status.flcdone)
Auke Kokbc7f75f2007-09-17 12:30:59 -07003188 return ret_val;
3189 } while (++count < ICH_FLASH_CYCLE_REPEAT_COUNT);
3190 }
3191
3192 return 0;
3193}
3194
3195/**
3196 * e1000_valid_led_default_ich8lan - Set the default LED settings
3197 * @hw: pointer to the HW structure
3198 * @data: Pointer to the LED settings
3199 *
3200 * Reads the LED default settings from the NVM to data. If the NVM LED
3201 * settings is all 0's or F's, set the LED default to a valid LED default
3202 * setting.
3203 **/
3204static s32 e1000_valid_led_default_ich8lan(struct e1000_hw *hw, u16 *data)
3205{
3206 s32 ret_val;
3207
3208 ret_val = e1000_read_nvm(hw, NVM_ID_LED_SETTINGS, 1, data);
3209 if (ret_val) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003210 e_dbg("NVM Read Error\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07003211 return ret_val;
3212 }
3213
3214 if (*data == ID_LED_RESERVED_0000 ||
3215 *data == ID_LED_RESERVED_FFFF)
3216 *data = ID_LED_DEFAULT_ICH8LAN;
3217
3218 return 0;
3219}
3220
3221/**
Bruce Allana4f58f52009-06-02 11:29:18 +00003222 * e1000_id_led_init_pchlan - store LED configurations
3223 * @hw: pointer to the HW structure
3224 *
3225 * PCH does not control LEDs via the LEDCTL register, rather it uses
3226 * the PHY LED configuration register.
3227 *
3228 * PCH also does not have an "always on" or "always off" mode which
3229 * complicates the ID feature. Instead of using the "on" mode to indicate
Bruce Alland1964eb2012-02-22 09:02:21 +00003230 * in ledctl_mode2 the LEDs to use for ID (see e1000e_id_led_init_generic()),
Bruce Allana4f58f52009-06-02 11:29:18 +00003231 * use "link_up" mode. The LEDs will still ID on request if there is no
3232 * link based on logic in e1000_led_[on|off]_pchlan().
3233 **/
3234static s32 e1000_id_led_init_pchlan(struct e1000_hw *hw)
3235{
3236 struct e1000_mac_info *mac = &hw->mac;
3237 s32 ret_val;
3238 const u32 ledctl_on = E1000_LEDCTL_MODE_LINK_UP;
3239 const u32 ledctl_off = E1000_LEDCTL_MODE_LINK_UP | E1000_PHY_LED0_IVRT;
3240 u16 data, i, temp, shift;
3241
3242 /* Get default ID LED modes */
3243 ret_val = hw->nvm.ops.valid_led_default(hw, &data);
3244 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00003245 return ret_val;
Bruce Allana4f58f52009-06-02 11:29:18 +00003246
3247 mac->ledctl_default = er32(LEDCTL);
3248 mac->ledctl_mode1 = mac->ledctl_default;
3249 mac->ledctl_mode2 = mac->ledctl_default;
3250
3251 for (i = 0; i < 4; i++) {
3252 temp = (data >> (i << 2)) & E1000_LEDCTL_LED0_MODE_MASK;
3253 shift = (i * 5);
3254 switch (temp) {
3255 case ID_LED_ON1_DEF2:
3256 case ID_LED_ON1_ON2:
3257 case ID_LED_ON1_OFF2:
3258 mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
3259 mac->ledctl_mode1 |= (ledctl_on << shift);
3260 break;
3261 case ID_LED_OFF1_DEF2:
3262 case ID_LED_OFF1_ON2:
3263 case ID_LED_OFF1_OFF2:
3264 mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
3265 mac->ledctl_mode1 |= (ledctl_off << shift);
3266 break;
3267 default:
3268 /* Do nothing */
3269 break;
3270 }
3271 switch (temp) {
3272 case ID_LED_DEF1_ON2:
3273 case ID_LED_ON1_ON2:
3274 case ID_LED_OFF1_ON2:
3275 mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
3276 mac->ledctl_mode2 |= (ledctl_on << shift);
3277 break;
3278 case ID_LED_DEF1_OFF2:
3279 case ID_LED_ON1_OFF2:
3280 case ID_LED_OFF1_OFF2:
3281 mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
3282 mac->ledctl_mode2 |= (ledctl_off << shift);
3283 break;
3284 default:
3285 /* Do nothing */
3286 break;
3287 }
3288 }
3289
Bruce Allan5015e532012-02-08 02:55:56 +00003290 return 0;
Bruce Allana4f58f52009-06-02 11:29:18 +00003291}
3292
3293/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07003294 * e1000_get_bus_info_ich8lan - Get/Set the bus type and width
3295 * @hw: pointer to the HW structure
3296 *
3297 * ICH8 use the PCI Express bus, but does not contain a PCI Express Capability
3298 * register, so the the bus width is hard coded.
3299 **/
3300static s32 e1000_get_bus_info_ich8lan(struct e1000_hw *hw)
3301{
3302 struct e1000_bus_info *bus = &hw->bus;
3303 s32 ret_val;
3304
3305 ret_val = e1000e_get_bus_info_pcie(hw);
3306
Bruce Allane921eb12012-11-28 09:28:37 +00003307 /* ICH devices are "PCI Express"-ish. They have
Auke Kokbc7f75f2007-09-17 12:30:59 -07003308 * a configuration space, but do not contain
3309 * PCI Express Capability registers, so bus width
3310 * must be hardcoded.
3311 */
3312 if (bus->width == e1000_bus_width_unknown)
3313 bus->width = e1000_bus_width_pcie_x1;
3314
3315 return ret_val;
3316}
3317
3318/**
3319 * e1000_reset_hw_ich8lan - Reset the hardware
3320 * @hw: pointer to the HW structure
3321 *
3322 * Does a full reset of the hardware which includes a reset of the PHY and
3323 * MAC.
3324 **/
3325static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
3326{
Bruce Allan1d5846b2009-10-29 13:46:05 +00003327 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
Bruce Allan62bc8132012-03-20 03:47:57 +00003328 u16 kum_cfg;
3329 u32 ctrl, reg;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003330 s32 ret_val;
3331
Bruce Allane921eb12012-11-28 09:28:37 +00003332 /* Prevent the PCI-E bus from sticking if there is no TLP connection
Auke Kokbc7f75f2007-09-17 12:30:59 -07003333 * on the last TLP read/write transaction when MAC is reset.
3334 */
3335 ret_val = e1000e_disable_pcie_master(hw);
Bruce Allane98cac42010-05-10 15:02:32 +00003336 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003337 e_dbg("PCI-E Master disable polling has failed.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07003338
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003339 e_dbg("Masking off all interrupts\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07003340 ew32(IMC, 0xffffffff);
3341
Bruce Allane921eb12012-11-28 09:28:37 +00003342 /* Disable the Transmit and Receive units. Then delay to allow
Auke Kokbc7f75f2007-09-17 12:30:59 -07003343 * any pending transactions to complete before we hit the MAC
3344 * with the global reset.
3345 */
3346 ew32(RCTL, 0);
3347 ew32(TCTL, E1000_TCTL_PSP);
3348 e1e_flush();
3349
Bruce Allan1bba4382011-03-19 00:27:20 +00003350 usleep_range(10000, 20000);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003351
3352 /* Workaround for ICH8 bit corruption issue in FIFO memory */
3353 if (hw->mac.type == e1000_ich8lan) {
3354 /* Set Tx and Rx buffer allocation to 8k apiece. */
3355 ew32(PBA, E1000_PBA_8K);
3356 /* Set Packet Buffer Size to 16k. */
3357 ew32(PBS, E1000_PBS_16K);
3358 }
3359
Bruce Allan1d5846b2009-10-29 13:46:05 +00003360 if (hw->mac.type == e1000_pchlan) {
Bruce Allan62bc8132012-03-20 03:47:57 +00003361 /* Save the NVM K1 bit setting */
3362 ret_val = e1000_read_nvm(hw, E1000_NVM_K1_CONFIG, 1, &kum_cfg);
Bruce Allan1d5846b2009-10-29 13:46:05 +00003363 if (ret_val)
3364 return ret_val;
3365
Bruce Allan62bc8132012-03-20 03:47:57 +00003366 if (kum_cfg & E1000_NVM_K1_ENABLE)
Bruce Allan1d5846b2009-10-29 13:46:05 +00003367 dev_spec->nvm_k1_enabled = true;
3368 else
3369 dev_spec->nvm_k1_enabled = false;
3370 }
3371
Auke Kokbc7f75f2007-09-17 12:30:59 -07003372 ctrl = er32(CTRL);
3373
Bruce Allan44abd5c2012-02-22 09:02:37 +00003374 if (!hw->phy.ops.check_reset_block(hw)) {
Bruce Allane921eb12012-11-28 09:28:37 +00003375 /* Full-chip reset requires MAC and PHY reset at the same
Auke Kokbc7f75f2007-09-17 12:30:59 -07003376 * time to make sure the interface between MAC and the
3377 * external PHY is reset.
3378 */
3379 ctrl |= E1000_CTRL_PHY_RST;
Bruce Allan605c82b2010-09-22 17:17:01 +00003380
Bruce Allane921eb12012-11-28 09:28:37 +00003381 /* Gate automatic PHY configuration by hardware on
Bruce Allan605c82b2010-09-22 17:17:01 +00003382 * non-managed 82579
3383 */
3384 if ((hw->mac.type == e1000_pch2lan) &&
3385 !(er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
3386 e1000_gate_hw_phy_config_ich8lan(hw, true);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003387 }
3388 ret_val = e1000_acquire_swflag_ich8lan(hw);
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003389 e_dbg("Issuing a global reset to ich8lan\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07003390 ew32(CTRL, (ctrl | E1000_CTRL_RST));
Jesse Brandeburg945a5152011-07-20 00:56:21 +00003391 /* cannot issue a flush here because it hangs the hardware */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003392 msleep(20);
3393
Bruce Allan62bc8132012-03-20 03:47:57 +00003394 /* Set Phy Config Counter to 50msec */
3395 if (hw->mac.type == e1000_pch2lan) {
3396 reg = er32(FEXTNVM3);
3397 reg &= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK;
3398 reg |= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC;
3399 ew32(FEXTNVM3, reg);
3400 }
3401
Bruce Allanfc0c7762009-07-01 13:27:55 +00003402 if (!ret_val)
Bruce Allana90b4122011-10-07 03:50:38 +00003403 clear_bit(__E1000_ACCESS_SHARED_RESOURCE, &hw->adapter->state);
Jesse Brandeburg37f40232008-10-02 16:33:20 -07003404
Bruce Allane98cac42010-05-10 15:02:32 +00003405 if (ctrl & E1000_CTRL_PHY_RST) {
Bruce Allanfc0c7762009-07-01 13:27:55 +00003406 ret_val = hw->phy.ops.get_cfg_done(hw);
Bruce Allane98cac42010-05-10 15:02:32 +00003407 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00003408 return ret_val;
Bruce Allanfc0c7762009-07-01 13:27:55 +00003409
Bruce Allane98cac42010-05-10 15:02:32 +00003410 ret_val = e1000_post_phy_reset_ich8lan(hw);
Bruce Allanf523d212009-10-29 13:45:45 +00003411 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00003412 return ret_val;
Bruce Allanf523d212009-10-29 13:45:45 +00003413 }
Bruce Allane98cac42010-05-10 15:02:32 +00003414
Bruce Allane921eb12012-11-28 09:28:37 +00003415 /* For PCH, this write will make sure that any noise
Bruce Allan7d3cabb2009-07-01 13:29:08 +00003416 * will be detected as a CRC error and be dropped rather than show up
3417 * as a bad packet to the DMA engine.
3418 */
3419 if (hw->mac.type == e1000_pchlan)
3420 ew32(CRC_OFFSET, 0x65656565);
3421
Auke Kokbc7f75f2007-09-17 12:30:59 -07003422 ew32(IMC, 0xffffffff);
Bruce Allandd93f952011-01-06 14:29:48 +00003423 er32(ICR);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003424
Bruce Allan62bc8132012-03-20 03:47:57 +00003425 reg = er32(KABGTXD);
3426 reg |= E1000_KABGTXD_BGSQLBIAS;
3427 ew32(KABGTXD, reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003428
Bruce Allan5015e532012-02-08 02:55:56 +00003429 return 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003430}
3431
3432/**
3433 * e1000_init_hw_ich8lan - Initialize the hardware
3434 * @hw: pointer to the HW structure
3435 *
3436 * Prepares the hardware for transmit and receive by doing the following:
3437 * - initialize hardware bits
3438 * - initialize LED identification
3439 * - setup receive address registers
3440 * - setup flow control
Auke Kok489815c2008-02-21 15:11:07 -08003441 * - setup transmit descriptors
Auke Kokbc7f75f2007-09-17 12:30:59 -07003442 * - clear statistics
3443 **/
3444static s32 e1000_init_hw_ich8lan(struct e1000_hw *hw)
3445{
3446 struct e1000_mac_info *mac = &hw->mac;
3447 u32 ctrl_ext, txdctl, snoop;
3448 s32 ret_val;
3449 u16 i;
3450
3451 e1000_initialize_hw_bits_ich8lan(hw);
3452
3453 /* Initialize identification LED */
Bruce Allana4f58f52009-06-02 11:29:18 +00003454 ret_val = mac->ops.id_led_init(hw);
Bruce Allande39b752009-11-20 23:27:59 +00003455 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003456 e_dbg("Error initializing identification LED\n");
Bruce Allande39b752009-11-20 23:27:59 +00003457 /* This is not fatal and we should not stop init due to this */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003458
3459 /* Setup the receive address. */
3460 e1000e_init_rx_addrs(hw, mac->rar_entry_count);
3461
3462 /* Zero out the Multicast HASH table */
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003463 e_dbg("Zeroing the MTA\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07003464 for (i = 0; i < mac->mta_reg_count; i++)
3465 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
3466
Bruce Allane921eb12012-11-28 09:28:37 +00003467 /* The 82578 Rx buffer will stall if wakeup is enabled in host and
Bruce Allan3ebfc7c2011-05-13 07:20:14 +00003468 * the ME. Disable wakeup by clearing the host wakeup bit.
Bruce Allanfc0c7762009-07-01 13:27:55 +00003469 * Reset the phy after disabling host wakeup to reset the Rx buffer.
3470 */
3471 if (hw->phy.type == e1000_phy_82578) {
Bruce Allan3ebfc7c2011-05-13 07:20:14 +00003472 e1e_rphy(hw, BM_PORT_GEN_CFG, &i);
3473 i &= ~BM_WUC_HOST_WU_BIT;
3474 e1e_wphy(hw, BM_PORT_GEN_CFG, i);
Bruce Allanfc0c7762009-07-01 13:27:55 +00003475 ret_val = e1000_phy_hw_reset_ich8lan(hw);
3476 if (ret_val)
3477 return ret_val;
3478 }
3479
Auke Kokbc7f75f2007-09-17 12:30:59 -07003480 /* Setup link and flow control */
Bruce Allan1a46b402012-02-22 09:02:26 +00003481 ret_val = mac->ops.setup_link(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003482
3483 /* Set the transmit descriptor write-back policy for both queues */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003484 txdctl = er32(TXDCTL(0));
Bruce Allanf0ff4392013-02-20 04:05:39 +00003485 txdctl = ((txdctl & ~E1000_TXDCTL_WTHRESH) |
3486 E1000_TXDCTL_FULL_TX_DESC_WB);
3487 txdctl = ((txdctl & ~E1000_TXDCTL_PTHRESH) |
3488 E1000_TXDCTL_MAX_TX_DESC_PREFETCH);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003489 ew32(TXDCTL(0), txdctl);
3490 txdctl = er32(TXDCTL(1));
Bruce Allanf0ff4392013-02-20 04:05:39 +00003491 txdctl = ((txdctl & ~E1000_TXDCTL_WTHRESH) |
3492 E1000_TXDCTL_FULL_TX_DESC_WB);
3493 txdctl = ((txdctl & ~E1000_TXDCTL_PTHRESH) |
3494 E1000_TXDCTL_MAX_TX_DESC_PREFETCH);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003495 ew32(TXDCTL(1), txdctl);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003496
Bruce Allane921eb12012-11-28 09:28:37 +00003497 /* ICH8 has opposite polarity of no_snoop bits.
Bruce Allanad680762008-03-28 09:15:03 -07003498 * By default, we should use snoop behavior.
3499 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003500 if (mac->type == e1000_ich8lan)
3501 snoop = PCIE_ICH8_SNOOP_ALL;
3502 else
Bruce Allan53aa82d2013-02-20 04:06:06 +00003503 snoop = (u32)~(PCIE_NO_SNOOP_ALL);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003504 e1000e_set_pcie_no_snoop(hw, snoop);
3505
3506 ctrl_ext = er32(CTRL_EXT);
3507 ctrl_ext |= E1000_CTRL_EXT_RO_DIS;
3508 ew32(CTRL_EXT, ctrl_ext);
3509
Bruce Allane921eb12012-11-28 09:28:37 +00003510 /* Clear all of the statistics registers (clear on read). It is
Auke Kokbc7f75f2007-09-17 12:30:59 -07003511 * important that we do this after we have tried to establish link
3512 * because the symbol error count will increment wildly if there
3513 * is no link.
3514 */
3515 e1000_clear_hw_cntrs_ich8lan(hw);
3516
Bruce Allane561a702012-02-08 02:55:46 +00003517 return ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003518}
Bruce Allanfc830b72013-02-20 04:06:11 +00003519
Auke Kokbc7f75f2007-09-17 12:30:59 -07003520/**
3521 * e1000_initialize_hw_bits_ich8lan - Initialize required hardware bits
3522 * @hw: pointer to the HW structure
3523 *
3524 * Sets/Clears required hardware bits necessary for correctly setting up the
3525 * hardware for transmit and receive.
3526 **/
3527static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw)
3528{
3529 u32 reg;
3530
3531 /* Extended Device Control */
3532 reg = er32(CTRL_EXT);
3533 reg |= (1 << 22);
Bruce Allana4f58f52009-06-02 11:29:18 +00003534 /* Enable PHY low-power state when MAC is at D3 w/o WoL */
3535 if (hw->mac.type >= e1000_pchlan)
3536 reg |= E1000_CTRL_EXT_PHYPDEN;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003537 ew32(CTRL_EXT, reg);
3538
3539 /* Transmit Descriptor Control 0 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003540 reg = er32(TXDCTL(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -07003541 reg |= (1 << 22);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003542 ew32(TXDCTL(0), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003543
3544 /* Transmit Descriptor Control 1 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003545 reg = er32(TXDCTL(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -07003546 reg |= (1 << 22);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003547 ew32(TXDCTL(1), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003548
3549 /* Transmit Arbitration Control 0 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003550 reg = er32(TARC(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -07003551 if (hw->mac.type == e1000_ich8lan)
3552 reg |= (1 << 28) | (1 << 29);
3553 reg |= (1 << 23) | (1 << 24) | (1 << 26) | (1 << 27);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003554 ew32(TARC(0), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003555
3556 /* Transmit Arbitration Control 1 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003557 reg = er32(TARC(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -07003558 if (er32(TCTL) & E1000_TCTL_MULR)
3559 reg &= ~(1 << 28);
3560 else
3561 reg |= (1 << 28);
3562 reg |= (1 << 24) | (1 << 26) | (1 << 30);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003563 ew32(TARC(1), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003564
3565 /* Device Status */
3566 if (hw->mac.type == e1000_ich8lan) {
3567 reg = er32(STATUS);
3568 reg &= ~(1 << 31);
3569 ew32(STATUS, reg);
3570 }
Jesse Brandeburga80483d2010-03-05 02:21:44 +00003571
Bruce Allane921eb12012-11-28 09:28:37 +00003572 /* work-around descriptor data corruption issue during nfs v2 udp
Jesse Brandeburga80483d2010-03-05 02:21:44 +00003573 * traffic, just disable the nfs filtering capability
3574 */
3575 reg = er32(RFCTL);
3576 reg |= (E1000_RFCTL_NFSW_DIS | E1000_RFCTL_NFSR_DIS);
Matthew Vickf6bd5572012-04-25 08:01:05 +00003577
Bruce Allane921eb12012-11-28 09:28:37 +00003578 /* Disable IPv6 extension header parsing because some malformed
Matthew Vickf6bd5572012-04-25 08:01:05 +00003579 * IPv6 headers can hang the Rx.
3580 */
3581 if (hw->mac.type == e1000_ich8lan)
3582 reg |= (E1000_RFCTL_IPV6_EX_DIS | E1000_RFCTL_NEW_IPV6_EXT_DIS);
Jesse Brandeburga80483d2010-03-05 02:21:44 +00003583 ew32(RFCTL, reg);
Bruce Allan94fb8482013-01-23 09:00:03 +00003584
3585 /* Enable ECC on Lynxpoint */
3586 if (hw->mac.type == e1000_pch_lpt) {
3587 reg = er32(PBECCSTS);
3588 reg |= E1000_PBECCSTS_ECC_ENABLE;
3589 ew32(PBECCSTS, reg);
3590
3591 reg = er32(CTRL);
3592 reg |= E1000_CTRL_MEHE;
3593 ew32(CTRL, reg);
3594 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07003595}
3596
3597/**
3598 * e1000_setup_link_ich8lan - Setup flow control and link settings
3599 * @hw: pointer to the HW structure
3600 *
3601 * Determines which flow control settings to use, then configures flow
3602 * control. Calls the appropriate media-specific link configuration
3603 * function. Assuming the adapter has a valid link partner, a valid link
3604 * should be established. Assumes the hardware has previously been reset
3605 * and the transmitter and receiver are not enabled.
3606 **/
3607static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw)
3608{
Auke Kokbc7f75f2007-09-17 12:30:59 -07003609 s32 ret_val;
3610
Bruce Allan44abd5c2012-02-22 09:02:37 +00003611 if (hw->phy.ops.check_reset_block(hw))
Auke Kokbc7f75f2007-09-17 12:30:59 -07003612 return 0;
3613
Bruce Allane921eb12012-11-28 09:28:37 +00003614 /* ICH parts do not have a word in the NVM to determine
Auke Kokbc7f75f2007-09-17 12:30:59 -07003615 * the default flow control setting, so we explicitly
3616 * set it to full.
3617 */
Bruce Allan37289d92009-06-02 11:29:37 +00003618 if (hw->fc.requested_mode == e1000_fc_default) {
3619 /* Workaround h/w hang when Tx flow control enabled */
3620 if (hw->mac.type == e1000_pchlan)
3621 hw->fc.requested_mode = e1000_fc_rx_pause;
3622 else
3623 hw->fc.requested_mode = e1000_fc_full;
3624 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07003625
Bruce Allane921eb12012-11-28 09:28:37 +00003626 /* Save off the requested flow control mode for use later. Depending
Bruce Allan5c48ef3e22008-11-21 16:57:36 -08003627 * on the link partner's capabilities, we may or may not use this mode.
3628 */
3629 hw->fc.current_mode = hw->fc.requested_mode;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003630
Bruce Allan17e813e2013-02-20 04:06:01 +00003631 e_dbg("After fix-ups FlowControl is now = %x\n", hw->fc.current_mode);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003632
3633 /* Continue to configure the copper link. */
Bruce Allan944ce012012-02-22 09:02:42 +00003634 ret_val = hw->mac.ops.setup_physical_interface(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003635 if (ret_val)
3636 return ret_val;
3637
Jeff Kirsher318a94d2008-03-28 09:15:16 -07003638 ew32(FCTTV, hw->fc.pause_time);
Bruce Allana4f58f52009-06-02 11:29:18 +00003639 if ((hw->phy.type == e1000_phy_82578) ||
Bruce Alland3738bb2010-06-16 13:27:28 +00003640 (hw->phy.type == e1000_phy_82579) ||
Bruce Allan2fbe4522012-04-19 03:21:47 +00003641 (hw->phy.type == e1000_phy_i217) ||
Bruce Allana4f58f52009-06-02 11:29:18 +00003642 (hw->phy.type == e1000_phy_82577)) {
Bruce Allana3055952010-05-10 15:02:12 +00003643 ew32(FCRTV_PCH, hw->fc.refresh_time);
3644
Bruce Allan482fed82011-01-06 14:29:49 +00003645 ret_val = e1e_wphy(hw, PHY_REG(BM_PORT_CTRL_PAGE, 27),
3646 hw->fc.pause_time);
Bruce Allana4f58f52009-06-02 11:29:18 +00003647 if (ret_val)
3648 return ret_val;
3649 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07003650
3651 return e1000e_set_fc_watermarks(hw);
3652}
3653
3654/**
3655 * e1000_setup_copper_link_ich8lan - Configure MAC/PHY interface
3656 * @hw: pointer to the HW structure
3657 *
3658 * Configures the kumeran interface to the PHY to wait the appropriate time
3659 * when polling the PHY, then call the generic setup_copper_link to finish
3660 * configuring the copper link.
3661 **/
3662static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw)
3663{
3664 u32 ctrl;
3665 s32 ret_val;
3666 u16 reg_data;
3667
3668 ctrl = er32(CTRL);
3669 ctrl |= E1000_CTRL_SLU;
3670 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
3671 ew32(CTRL, ctrl);
3672
Bruce Allane921eb12012-11-28 09:28:37 +00003673 /* Set the mac to wait the maximum time between each iteration
Auke Kokbc7f75f2007-09-17 12:30:59 -07003674 * and increase the max iterations when polling the phy;
Bruce Allanad680762008-03-28 09:15:03 -07003675 * this fixes erroneous timeouts at 10Mbps.
3676 */
Bruce Allan07818952009-12-08 07:28:01 +00003677 ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_TIMEOUTS, 0xFFFF);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003678 if (ret_val)
3679 return ret_val;
Bruce Allan07818952009-12-08 07:28:01 +00003680 ret_val = e1000e_read_kmrn_reg(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
Bruce Allanf0ff4392013-02-20 04:05:39 +00003681 &reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003682 if (ret_val)
3683 return ret_val;
3684 reg_data |= 0x3F;
Bruce Allan07818952009-12-08 07:28:01 +00003685 ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
Bruce Allanf0ff4392013-02-20 04:05:39 +00003686 reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003687 if (ret_val)
3688 return ret_val;
3689
Bruce Allana4f58f52009-06-02 11:29:18 +00003690 switch (hw->phy.type) {
3691 case e1000_phy_igp_3:
Auke Kokbc7f75f2007-09-17 12:30:59 -07003692 ret_val = e1000e_copper_link_setup_igp(hw);
3693 if (ret_val)
3694 return ret_val;
Bruce Allana4f58f52009-06-02 11:29:18 +00003695 break;
3696 case e1000_phy_bm:
3697 case e1000_phy_82578:
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003698 ret_val = e1000e_copper_link_setup_m88(hw);
3699 if (ret_val)
3700 return ret_val;
Bruce Allana4f58f52009-06-02 11:29:18 +00003701 break;
3702 case e1000_phy_82577:
Bruce Alland3738bb2010-06-16 13:27:28 +00003703 case e1000_phy_82579:
Bruce Allan2fbe4522012-04-19 03:21:47 +00003704 case e1000_phy_i217:
Bruce Allana4f58f52009-06-02 11:29:18 +00003705 ret_val = e1000_copper_link_setup_82577(hw);
3706 if (ret_val)
3707 return ret_val;
3708 break;
3709 case e1000_phy_ife:
Bruce Allan482fed82011-01-06 14:29:49 +00003710 ret_val = e1e_rphy(hw, IFE_PHY_MDIX_CONTROL, &reg_data);
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003711 if (ret_val)
3712 return ret_val;
3713
3714 reg_data &= ~IFE_PMC_AUTO_MDIX;
3715
3716 switch (hw->phy.mdix) {
3717 case 1:
3718 reg_data &= ~IFE_PMC_FORCE_MDIX;
3719 break;
3720 case 2:
3721 reg_data |= IFE_PMC_FORCE_MDIX;
3722 break;
3723 case 0:
3724 default:
3725 reg_data |= IFE_PMC_AUTO_MDIX;
3726 break;
3727 }
Bruce Allan482fed82011-01-06 14:29:49 +00003728 ret_val = e1e_wphy(hw, IFE_PHY_MDIX_CONTROL, reg_data);
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003729 if (ret_val)
3730 return ret_val;
Bruce Allana4f58f52009-06-02 11:29:18 +00003731 break;
3732 default:
3733 break;
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003734 }
Bruce Allan3fa8293632012-02-08 02:55:40 +00003735
Auke Kokbc7f75f2007-09-17 12:30:59 -07003736 return e1000e_setup_copper_link(hw);
3737}
3738
3739/**
3740 * e1000_get_link_up_info_ich8lan - Get current link speed and duplex
3741 * @hw: pointer to the HW structure
3742 * @speed: pointer to store current link speed
3743 * @duplex: pointer to store the current link duplex
3744 *
Bruce Allanad680762008-03-28 09:15:03 -07003745 * Calls the generic get_speed_and_duplex to retrieve the current link
Auke Kokbc7f75f2007-09-17 12:30:59 -07003746 * information and then calls the Kumeran lock loss workaround for links at
3747 * gigabit speeds.
3748 **/
3749static s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw, u16 *speed,
3750 u16 *duplex)
3751{
3752 s32 ret_val;
3753
3754 ret_val = e1000e_get_speed_and_duplex_copper(hw, speed, duplex);
3755 if (ret_val)
3756 return ret_val;
3757
3758 if ((hw->mac.type == e1000_ich8lan) &&
3759 (hw->phy.type == e1000_phy_igp_3) &&
3760 (*speed == SPEED_1000)) {
3761 ret_val = e1000_kmrn_lock_loss_workaround_ich8lan(hw);
3762 }
3763
3764 return ret_val;
3765}
3766
3767/**
3768 * e1000_kmrn_lock_loss_workaround_ich8lan - Kumeran workaround
3769 * @hw: pointer to the HW structure
3770 *
3771 * Work-around for 82566 Kumeran PCS lock loss:
3772 * On link status change (i.e. PCI reset, speed change) and link is up and
3773 * speed is gigabit-
3774 * 0) if workaround is optionally disabled do nothing
3775 * 1) wait 1ms for Kumeran link to come up
3776 * 2) check Kumeran Diagnostic register PCS lock loss bit
3777 * 3) if not set the link is locked (all is good), otherwise...
3778 * 4) reset the PHY
3779 * 5) repeat up to 10 times
3780 * Note: this is only called for IGP3 copper when speed is 1gb.
3781 **/
3782static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw)
3783{
3784 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
3785 u32 phy_ctrl;
3786 s32 ret_val;
3787 u16 i, data;
3788 bool link;
3789
3790 if (!dev_spec->kmrn_lock_loss_workaround_enabled)
3791 return 0;
3792
Bruce Allane921eb12012-11-28 09:28:37 +00003793 /* Make sure link is up before proceeding. If not just return.
Auke Kokbc7f75f2007-09-17 12:30:59 -07003794 * Attempting this while link is negotiating fouled up link
Bruce Allanad680762008-03-28 09:15:03 -07003795 * stability
3796 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003797 ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link);
3798 if (!link)
3799 return 0;
3800
3801 for (i = 0; i < 10; i++) {
3802 /* read once to clear */
3803 ret_val = e1e_rphy(hw, IGP3_KMRN_DIAG, &data);
3804 if (ret_val)
3805 return ret_val;
3806 /* and again to get new status */
3807 ret_val = e1e_rphy(hw, IGP3_KMRN_DIAG, &data);
3808 if (ret_val)
3809 return ret_val;
3810
3811 /* check for PCS lock */
3812 if (!(data & IGP3_KMRN_DIAG_PCS_LOCK_LOSS))
3813 return 0;
3814
3815 /* Issue PHY reset */
3816 e1000_phy_hw_reset(hw);
3817 mdelay(5);
3818 }
3819 /* Disable GigE link negotiation */
3820 phy_ctrl = er32(PHY_CTRL);
3821 phy_ctrl |= (E1000_PHY_CTRL_GBE_DISABLE |
3822 E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
3823 ew32(PHY_CTRL, phy_ctrl);
3824
Bruce Allane921eb12012-11-28 09:28:37 +00003825 /* Call gig speed drop workaround on Gig disable before accessing
Bruce Allanad680762008-03-28 09:15:03 -07003826 * any PHY registers
3827 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003828 e1000e_gig_downshift_workaround_ich8lan(hw);
3829
3830 /* unable to acquire PCS lock */
3831 return -E1000_ERR_PHY;
3832}
3833
3834/**
Bruce Allan6e3c8072012-02-22 09:02:47 +00003835 * e1000e_set_kmrn_lock_loss_workaround_ich8lan - Set Kumeran workaround state
Auke Kokbc7f75f2007-09-17 12:30:59 -07003836 * @hw: pointer to the HW structure
Auke Kok489815c2008-02-21 15:11:07 -08003837 * @state: boolean value used to set the current Kumeran workaround state
Auke Kokbc7f75f2007-09-17 12:30:59 -07003838 *
Bruce Allan564ea9b2009-11-20 23:26:44 +00003839 * If ICH8, set the current Kumeran workaround state (enabled - true
3840 * /disabled - false).
Auke Kokbc7f75f2007-09-17 12:30:59 -07003841 **/
3842void e1000e_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw,
Bruce Allan17e813e2013-02-20 04:06:01 +00003843 bool state)
Auke Kokbc7f75f2007-09-17 12:30:59 -07003844{
3845 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
3846
3847 if (hw->mac.type != e1000_ich8lan) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003848 e_dbg("Workaround applies to ICH8 only.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07003849 return;
3850 }
3851
3852 dev_spec->kmrn_lock_loss_workaround_enabled = state;
3853}
3854
3855/**
3856 * e1000_ipg3_phy_powerdown_workaround_ich8lan - Power down workaround on D3
3857 * @hw: pointer to the HW structure
3858 *
3859 * Workaround for 82566 power-down on D3 entry:
3860 * 1) disable gigabit link
3861 * 2) write VR power-down enable
3862 * 3) read it back
3863 * Continue if successful, else issue LCD reset and repeat
3864 **/
3865void e1000e_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw)
3866{
3867 u32 reg;
3868 u16 data;
3869 u8 retry = 0;
3870
3871 if (hw->phy.type != e1000_phy_igp_3)
3872 return;
3873
3874 /* Try the workaround twice (if needed) */
3875 do {
3876 /* Disable link */
3877 reg = er32(PHY_CTRL);
3878 reg |= (E1000_PHY_CTRL_GBE_DISABLE |
3879 E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
3880 ew32(PHY_CTRL, reg);
3881
Bruce Allane921eb12012-11-28 09:28:37 +00003882 /* Call gig speed drop workaround on Gig disable before
Bruce Allanad680762008-03-28 09:15:03 -07003883 * accessing any PHY registers
3884 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003885 if (hw->mac.type == e1000_ich8lan)
3886 e1000e_gig_downshift_workaround_ich8lan(hw);
3887
3888 /* Write VR power-down enable */
3889 e1e_rphy(hw, IGP3_VR_CTRL, &data);
3890 data &= ~IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
3891 e1e_wphy(hw, IGP3_VR_CTRL, data | IGP3_VR_CTRL_MODE_SHUTDOWN);
3892
3893 /* Read it back and test */
3894 e1e_rphy(hw, IGP3_VR_CTRL, &data);
3895 data &= IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
3896 if ((data == IGP3_VR_CTRL_MODE_SHUTDOWN) || retry)
3897 break;
3898
3899 /* Issue PHY reset and repeat at most one more time */
3900 reg = er32(CTRL);
3901 ew32(CTRL, reg | E1000_CTRL_PHY_RST);
3902 retry++;
3903 } while (retry);
3904}
3905
3906/**
3907 * e1000e_gig_downshift_workaround_ich8lan - WoL from S5 stops working
3908 * @hw: pointer to the HW structure
3909 *
3910 * Steps to take when dropping from 1Gb/s (eg. link cable removal (LSC),
Auke Kok489815c2008-02-21 15:11:07 -08003911 * LPLU, Gig disable, MDIC PHY reset):
Auke Kokbc7f75f2007-09-17 12:30:59 -07003912 * 1) Set Kumeran Near-end loopback
3913 * 2) Clear Kumeran Near-end loopback
Bruce Allan462d5992011-09-30 08:07:11 +00003914 * Should only be called for ICH8[m] devices with any 1G Phy.
Auke Kokbc7f75f2007-09-17 12:30:59 -07003915 **/
3916void e1000e_gig_downshift_workaround_ich8lan(struct e1000_hw *hw)
3917{
3918 s32 ret_val;
3919 u16 reg_data;
3920
Bruce Allan462d5992011-09-30 08:07:11 +00003921 if ((hw->mac.type != e1000_ich8lan) || (hw->phy.type == e1000_phy_ife))
Auke Kokbc7f75f2007-09-17 12:30:59 -07003922 return;
3923
3924 ret_val = e1000e_read_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
Bruce Allan17e813e2013-02-20 04:06:01 +00003925 &reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003926 if (ret_val)
3927 return;
3928 reg_data |= E1000_KMRNCTRLSTA_DIAG_NELPBK;
3929 ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
Bruce Allan17e813e2013-02-20 04:06:01 +00003930 reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003931 if (ret_val)
3932 return;
3933 reg_data &= ~E1000_KMRNCTRLSTA_DIAG_NELPBK;
Bruce Allan7dbbe5d2013-01-05 05:08:31 +00003934 e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET, reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003935}
3936
3937/**
Bruce Allan99730e42011-05-13 07:19:48 +00003938 * e1000_suspend_workarounds_ich8lan - workarounds needed during S0->Sx
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003939 * @hw: pointer to the HW structure
3940 *
3941 * During S0 to Sx transition, it is possible the link remains at gig
3942 * instead of negotiating to a lower speed. Before going to Sx, set
Bruce Allanc077a902011-12-16 00:46:38 +00003943 * 'Gig Disable' to force link speed negotiation to a lower speed based on
3944 * the LPLU setting in the NVM or custom setting. For PCH and newer parts,
3945 * the OEM bits PHY register (LED, GbE disable and LPLU configurations) also
3946 * needs to be written.
Bruce Allan2fbe4522012-04-19 03:21:47 +00003947 * Parts that support (and are linked to a partner which support) EEE in
3948 * 100Mbps should disable LPLU since 100Mbps w/ EEE requires less power
3949 * than 10Mbps w/o EEE.
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003950 **/
Bruce Allan99730e42011-05-13 07:19:48 +00003951void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw)
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003952{
Bruce Allan2fbe4522012-04-19 03:21:47 +00003953 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003954 u32 phy_ctrl;
Bruce Allan8395ae82010-09-22 17:15:08 +00003955 s32 ret_val;
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003956
Bruce Allan17f085d2010-06-17 18:59:48 +00003957 phy_ctrl = er32(PHY_CTRL);
Bruce Allanc077a902011-12-16 00:46:38 +00003958 phy_ctrl |= E1000_PHY_CTRL_GBE_DISABLE;
Bruce Allan2fbe4522012-04-19 03:21:47 +00003959 if (hw->phy.type == e1000_phy_i217) {
3960 u16 phy_reg;
3961
3962 ret_val = hw->phy.ops.acquire(hw);
3963 if (ret_val)
3964 goto out;
3965
3966 if (!dev_spec->eee_disable) {
3967 u16 eee_advert;
3968
Bruce Allan4ddc48a2012-12-05 06:25:58 +00003969 ret_val =
3970 e1000_read_emi_reg_locked(hw,
3971 I217_EEE_ADVERTISEMENT,
3972 &eee_advert);
Bruce Allan2fbe4522012-04-19 03:21:47 +00003973 if (ret_val)
3974 goto release;
Bruce Allan2fbe4522012-04-19 03:21:47 +00003975
Bruce Allane921eb12012-11-28 09:28:37 +00003976 /* Disable LPLU if both link partners support 100BaseT
Bruce Allan2fbe4522012-04-19 03:21:47 +00003977 * EEE and 100Full is advertised on both ends of the
3978 * link.
3979 */
Bruce Allan3d4d5752012-12-05 06:26:08 +00003980 if ((eee_advert & I82579_EEE_100_SUPPORTED) &&
Bruce Allan2fbe4522012-04-19 03:21:47 +00003981 (dev_spec->eee_lp_ability &
Bruce Allan3d4d5752012-12-05 06:26:08 +00003982 I82579_EEE_100_SUPPORTED) &&
Bruce Allan2fbe4522012-04-19 03:21:47 +00003983 (hw->phy.autoneg_advertised & ADVERTISE_100_FULL))
3984 phy_ctrl &= ~(E1000_PHY_CTRL_D0A_LPLU |
3985 E1000_PHY_CTRL_NOND0A_LPLU);
3986 }
3987
Bruce Allane921eb12012-11-28 09:28:37 +00003988 /* For i217 Intel Rapid Start Technology support,
Bruce Allan2fbe4522012-04-19 03:21:47 +00003989 * when the system is going into Sx and no manageability engine
3990 * is present, the driver must configure proxy to reset only on
3991 * power good. LPI (Low Power Idle) state must also reset only
3992 * on power good, as well as the MTA (Multicast table array).
3993 * The SMBus release must also be disabled on LCD reset.
3994 */
3995 if (!(er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) {
Bruce Allan2fbe4522012-04-19 03:21:47 +00003996 /* Enable proxy to reset only on power good. */
3997 e1e_rphy_locked(hw, I217_PROXY_CTRL, &phy_reg);
3998 phy_reg |= I217_PROXY_CTRL_AUTO_DISABLE;
3999 e1e_wphy_locked(hw, I217_PROXY_CTRL, phy_reg);
4000
Bruce Allane921eb12012-11-28 09:28:37 +00004001 /* Set bit enable LPI (EEE) to reset only on
Bruce Allan2fbe4522012-04-19 03:21:47 +00004002 * power good.
4003 */
4004 e1e_rphy_locked(hw, I217_SxCTRL, &phy_reg);
Bruce Allan6d7407b2012-05-10 02:51:17 +00004005 phy_reg |= I217_SxCTRL_ENABLE_LPI_RESET;
Bruce Allan2fbe4522012-04-19 03:21:47 +00004006 e1e_wphy_locked(hw, I217_SxCTRL, phy_reg);
4007
4008 /* Disable the SMB release on LCD reset. */
4009 e1e_rphy_locked(hw, I217_MEMPWR, &phy_reg);
Bruce Allan6d7407b2012-05-10 02:51:17 +00004010 phy_reg &= ~I217_MEMPWR_DISABLE_SMB_RELEASE;
Bruce Allan2fbe4522012-04-19 03:21:47 +00004011 e1e_wphy_locked(hw, I217_MEMPWR, phy_reg);
4012 }
4013
Bruce Allane921eb12012-11-28 09:28:37 +00004014 /* Enable MTA to reset for Intel Rapid Start Technology
Bruce Allan2fbe4522012-04-19 03:21:47 +00004015 * Support
4016 */
4017 e1e_rphy_locked(hw, I217_CGFREG, &phy_reg);
Bruce Allan6d7407b2012-05-10 02:51:17 +00004018 phy_reg |= I217_CGFREG_ENABLE_MTA_RESET;
Bruce Allan2fbe4522012-04-19 03:21:47 +00004019 e1e_wphy_locked(hw, I217_CGFREG, phy_reg);
4020
4021release:
4022 hw->phy.ops.release(hw);
4023 }
4024out:
Bruce Allan17f085d2010-06-17 18:59:48 +00004025 ew32(PHY_CTRL, phy_ctrl);
Bruce Allana4f58f52009-06-02 11:29:18 +00004026
Bruce Allan462d5992011-09-30 08:07:11 +00004027 if (hw->mac.type == e1000_ich8lan)
4028 e1000e_gig_downshift_workaround_ich8lan(hw);
4029
Bruce Allan8395ae82010-09-22 17:15:08 +00004030 if (hw->mac.type >= e1000_pchlan) {
Bruce Allance54afd2010-11-24 06:01:41 +00004031 e1000_oem_bits_config_ich8lan(hw, false);
Bruce Allan92fe1732012-04-12 06:27:03 +00004032
4033 /* Reset PHY to activate OEM bits on 82577/8 */
4034 if (hw->mac.type == e1000_pchlan)
4035 e1000e_phy_hw_reset_generic(hw);
4036
Bruce Allan8395ae82010-09-22 17:15:08 +00004037 ret_val = hw->phy.ops.acquire(hw);
4038 if (ret_val)
4039 return;
4040 e1000_write_smbus_addr(hw);
4041 hw->phy.ops.release(hw);
4042 }
Bruce Allan97ac8ca2008-04-29 09:16:05 -07004043}
4044
4045/**
Bruce Allan99730e42011-05-13 07:19:48 +00004046 * e1000_resume_workarounds_pchlan - workarounds needed during Sx->S0
4047 * @hw: pointer to the HW structure
4048 *
4049 * During Sx to S0 transitions on non-managed devices or managed devices
4050 * on which PHY resets are not blocked, if the PHY registers cannot be
4051 * accessed properly by the s/w toggle the LANPHYPC value to power cycle
4052 * the PHY.
Bruce Allan2fbe4522012-04-19 03:21:47 +00004053 * On i217, setup Intel Rapid Start Technology.
Bruce Allan99730e42011-05-13 07:19:48 +00004054 **/
4055void e1000_resume_workarounds_pchlan(struct e1000_hw *hw)
4056{
Bruce Allan90b82982011-12-16 00:46:33 +00004057 s32 ret_val;
Bruce Allan99730e42011-05-13 07:19:48 +00004058
Bruce Allancb17aab2012-04-13 03:16:22 +00004059 if (hw->mac.type < e1000_pch2lan)
Bruce Allan99730e42011-05-13 07:19:48 +00004060 return;
4061
Bruce Allancb17aab2012-04-13 03:16:22 +00004062 ret_val = e1000_init_phy_workarounds_pchlan(hw);
Bruce Allan90b82982011-12-16 00:46:33 +00004063 if (ret_val) {
Bruce Allancb17aab2012-04-13 03:16:22 +00004064 e_dbg("Failed to init PHY flow ret_val=%d\n", ret_val);
Bruce Allan99730e42011-05-13 07:19:48 +00004065 return;
4066 }
Bruce Allan2fbe4522012-04-19 03:21:47 +00004067
Bruce Allane921eb12012-11-28 09:28:37 +00004068 /* For i217 Intel Rapid Start Technology support when the system
Bruce Allan2fbe4522012-04-19 03:21:47 +00004069 * is transitioning from Sx and no manageability engine is present
4070 * configure SMBus to restore on reset, disable proxy, and enable
4071 * the reset on MTA (Multicast table array).
4072 */
4073 if (hw->phy.type == e1000_phy_i217) {
4074 u16 phy_reg;
4075
4076 ret_val = hw->phy.ops.acquire(hw);
4077 if (ret_val) {
4078 e_dbg("Failed to setup iRST\n");
4079 return;
4080 }
4081
4082 if (!(er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) {
Bruce Allane921eb12012-11-28 09:28:37 +00004083 /* Restore clear on SMB if no manageability engine
Bruce Allan2fbe4522012-04-19 03:21:47 +00004084 * is present
4085 */
4086 ret_val = e1e_rphy_locked(hw, I217_MEMPWR, &phy_reg);
4087 if (ret_val)
4088 goto release;
Bruce Allan6d7407b2012-05-10 02:51:17 +00004089 phy_reg |= I217_MEMPWR_DISABLE_SMB_RELEASE;
Bruce Allan2fbe4522012-04-19 03:21:47 +00004090 e1e_wphy_locked(hw, I217_MEMPWR, phy_reg);
4091
4092 /* Disable Proxy */
4093 e1e_wphy_locked(hw, I217_PROXY_CTRL, 0);
4094 }
4095 /* Enable reset on MTA */
4096 ret_val = e1e_rphy_locked(hw, I217_CGFREG, &phy_reg);
4097 if (ret_val)
4098 goto release;
Bruce Allan6d7407b2012-05-10 02:51:17 +00004099 phy_reg &= ~I217_CGFREG_ENABLE_MTA_RESET;
Bruce Allan2fbe4522012-04-19 03:21:47 +00004100 e1e_wphy_locked(hw, I217_CGFREG, phy_reg);
4101release:
4102 if (ret_val)
4103 e_dbg("Error %d in resume workarounds\n", ret_val);
4104 hw->phy.ops.release(hw);
4105 }
Bruce Allan99730e42011-05-13 07:19:48 +00004106}
4107
4108/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07004109 * e1000_cleanup_led_ich8lan - Restore the default LED operation
4110 * @hw: pointer to the HW structure
4111 *
4112 * Return the LED back to the default configuration.
4113 **/
4114static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw)
4115{
4116 if (hw->phy.type == e1000_phy_ife)
4117 return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED, 0);
4118
4119 ew32(LEDCTL, hw->mac.ledctl_default);
4120 return 0;
4121}
4122
4123/**
Auke Kok489815c2008-02-21 15:11:07 -08004124 * e1000_led_on_ich8lan - Turn LEDs on
Auke Kokbc7f75f2007-09-17 12:30:59 -07004125 * @hw: pointer to the HW structure
4126 *
Auke Kok489815c2008-02-21 15:11:07 -08004127 * Turn on the LEDs.
Auke Kokbc7f75f2007-09-17 12:30:59 -07004128 **/
4129static s32 e1000_led_on_ich8lan(struct e1000_hw *hw)
4130{
4131 if (hw->phy.type == e1000_phy_ife)
4132 return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED,
4133 (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_ON));
4134
4135 ew32(LEDCTL, hw->mac.ledctl_mode2);
4136 return 0;
4137}
4138
4139/**
Auke Kok489815c2008-02-21 15:11:07 -08004140 * e1000_led_off_ich8lan - Turn LEDs off
Auke Kokbc7f75f2007-09-17 12:30:59 -07004141 * @hw: pointer to the HW structure
4142 *
Auke Kok489815c2008-02-21 15:11:07 -08004143 * Turn off the LEDs.
Auke Kokbc7f75f2007-09-17 12:30:59 -07004144 **/
4145static s32 e1000_led_off_ich8lan(struct e1000_hw *hw)
4146{
4147 if (hw->phy.type == e1000_phy_ife)
4148 return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED,
Bruce Allan482fed82011-01-06 14:29:49 +00004149 (IFE_PSCL_PROBE_MODE |
4150 IFE_PSCL_PROBE_LEDS_OFF));
Auke Kokbc7f75f2007-09-17 12:30:59 -07004151
4152 ew32(LEDCTL, hw->mac.ledctl_mode1);
4153 return 0;
4154}
4155
4156/**
Bruce Allana4f58f52009-06-02 11:29:18 +00004157 * e1000_setup_led_pchlan - Configures SW controllable LED
4158 * @hw: pointer to the HW structure
4159 *
4160 * This prepares the SW controllable LED for use.
4161 **/
4162static s32 e1000_setup_led_pchlan(struct e1000_hw *hw)
4163{
Bruce Allan482fed82011-01-06 14:29:49 +00004164 return e1e_wphy(hw, HV_LED_CONFIG, (u16)hw->mac.ledctl_mode1);
Bruce Allana4f58f52009-06-02 11:29:18 +00004165}
4166
4167/**
4168 * e1000_cleanup_led_pchlan - Restore the default LED operation
4169 * @hw: pointer to the HW structure
4170 *
4171 * Return the LED back to the default configuration.
4172 **/
4173static s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw)
4174{
Bruce Allan482fed82011-01-06 14:29:49 +00004175 return e1e_wphy(hw, HV_LED_CONFIG, (u16)hw->mac.ledctl_default);
Bruce Allana4f58f52009-06-02 11:29:18 +00004176}
4177
4178/**
4179 * e1000_led_on_pchlan - Turn LEDs on
4180 * @hw: pointer to the HW structure
4181 *
4182 * Turn on the LEDs.
4183 **/
4184static s32 e1000_led_on_pchlan(struct e1000_hw *hw)
4185{
4186 u16 data = (u16)hw->mac.ledctl_mode2;
4187 u32 i, led;
4188
Bruce Allane921eb12012-11-28 09:28:37 +00004189 /* If no link, then turn LED on by setting the invert bit
Bruce Allana4f58f52009-06-02 11:29:18 +00004190 * for each LED that's mode is "link_up" in ledctl_mode2.
4191 */
4192 if (!(er32(STATUS) & E1000_STATUS_LU)) {
4193 for (i = 0; i < 3; i++) {
4194 led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
4195 if ((led & E1000_PHY_LED0_MODE_MASK) !=
4196 E1000_LEDCTL_MODE_LINK_UP)
4197 continue;
4198 if (led & E1000_PHY_LED0_IVRT)
4199 data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
4200 else
4201 data |= (E1000_PHY_LED0_IVRT << (i * 5));
4202 }
4203 }
4204
Bruce Allan482fed82011-01-06 14:29:49 +00004205 return e1e_wphy(hw, HV_LED_CONFIG, data);
Bruce Allana4f58f52009-06-02 11:29:18 +00004206}
4207
4208/**
4209 * e1000_led_off_pchlan - Turn LEDs off
4210 * @hw: pointer to the HW structure
4211 *
4212 * Turn off the LEDs.
4213 **/
4214static s32 e1000_led_off_pchlan(struct e1000_hw *hw)
4215{
4216 u16 data = (u16)hw->mac.ledctl_mode1;
4217 u32 i, led;
4218
Bruce Allane921eb12012-11-28 09:28:37 +00004219 /* If no link, then turn LED off by clearing the invert bit
Bruce Allana4f58f52009-06-02 11:29:18 +00004220 * for each LED that's mode is "link_up" in ledctl_mode1.
4221 */
4222 if (!(er32(STATUS) & E1000_STATUS_LU)) {
4223 for (i = 0; i < 3; i++) {
4224 led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
4225 if ((led & E1000_PHY_LED0_MODE_MASK) !=
4226 E1000_LEDCTL_MODE_LINK_UP)
4227 continue;
4228 if (led & E1000_PHY_LED0_IVRT)
4229 data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
4230 else
4231 data |= (E1000_PHY_LED0_IVRT << (i * 5));
4232 }
4233 }
4234
Bruce Allan482fed82011-01-06 14:29:49 +00004235 return e1e_wphy(hw, HV_LED_CONFIG, data);
Bruce Allana4f58f52009-06-02 11:29:18 +00004236}
4237
4238/**
Bruce Allane98cac42010-05-10 15:02:32 +00004239 * e1000_get_cfg_done_ich8lan - Read config done bit after Full or PHY reset
Bruce Allanf4187b52008-08-26 18:36:50 -07004240 * @hw: pointer to the HW structure
4241 *
Bruce Allane98cac42010-05-10 15:02:32 +00004242 * Read appropriate register for the config done bit for completion status
4243 * and configure the PHY through s/w for EEPROM-less parts.
4244 *
4245 * NOTE: some silicon which is EEPROM-less will fail trying to read the
4246 * config done bit, so only an error is logged and continues. If we were
4247 * to return with error, EEPROM-less silicon would not be able to be reset
4248 * or change link.
Bruce Allanf4187b52008-08-26 18:36:50 -07004249 **/
4250static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw)
4251{
Bruce Allane98cac42010-05-10 15:02:32 +00004252 s32 ret_val = 0;
Bruce Allanf4187b52008-08-26 18:36:50 -07004253 u32 bank = 0;
Bruce Allane98cac42010-05-10 15:02:32 +00004254 u32 status;
Bruce Allanfc0c7762009-07-01 13:27:55 +00004255
Bruce Allanfe908492013-01-05 08:06:14 +00004256 e1000e_get_cfg_done_generic(hw);
Bruce Allanf4187b52008-08-26 18:36:50 -07004257
Bruce Allane98cac42010-05-10 15:02:32 +00004258 /* Wait for indication from h/w that it has completed basic config */
4259 if (hw->mac.type >= e1000_ich10lan) {
4260 e1000_lan_init_done_ich8lan(hw);
4261 } else {
4262 ret_val = e1000e_get_auto_rd_done(hw);
4263 if (ret_val) {
Bruce Allane921eb12012-11-28 09:28:37 +00004264 /* When auto config read does not complete, do not
Bruce Allane98cac42010-05-10 15:02:32 +00004265 * return with an error. This can happen in situations
4266 * where there is no eeprom and prevents getting link.
4267 */
4268 e_dbg("Auto Read Done did not complete\n");
4269 ret_val = 0;
4270 }
4271 }
4272
4273 /* Clear PHY Reset Asserted bit */
4274 status = er32(STATUS);
4275 if (status & E1000_STATUS_PHYRA)
4276 ew32(STATUS, status & ~E1000_STATUS_PHYRA);
4277 else
4278 e_dbg("PHY Reset Asserted not set - needs delay\n");
4279
Bruce Allanf4187b52008-08-26 18:36:50 -07004280 /* If EEPROM is not marked present, init the IGP 3 PHY manually */
Bruce Allane98cac42010-05-10 15:02:32 +00004281 if (hw->mac.type <= e1000_ich9lan) {
Bruce Allan04499ec2012-04-13 00:08:31 +00004282 if (!(er32(EECD) & E1000_EECD_PRES) &&
Bruce Allanf4187b52008-08-26 18:36:50 -07004283 (hw->phy.type == e1000_phy_igp_3)) {
4284 e1000e_phy_init_script_igp3(hw);
4285 }
4286 } else {
4287 if (e1000_valid_nvm_bank_detect_ich8lan(hw, &bank)) {
4288 /* Maybe we should do a basic PHY config */
Bruce Allan3bb99fe2009-11-20 23:25:07 +00004289 e_dbg("EEPROM not present\n");
Bruce Allane98cac42010-05-10 15:02:32 +00004290 ret_val = -E1000_ERR_CONFIG;
Bruce Allanf4187b52008-08-26 18:36:50 -07004291 }
4292 }
4293
Bruce Allane98cac42010-05-10 15:02:32 +00004294 return ret_val;
Bruce Allanf4187b52008-08-26 18:36:50 -07004295}
4296
4297/**
Bruce Allan17f208d2009-12-01 15:47:22 +00004298 * e1000_power_down_phy_copper_ich8lan - Remove link during PHY power down
4299 * @hw: pointer to the HW structure
4300 *
4301 * In the case of a PHY power down to save power, or to turn off link during a
4302 * driver unload, or wake on lan is not enabled, remove the link.
4303 **/
4304static void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw)
4305{
4306 /* If the management interface is not enabled, then power down */
4307 if (!(hw->mac.ops.check_mng_mode(hw) ||
4308 hw->phy.ops.check_reset_block(hw)))
4309 e1000_power_down_phy_copper(hw);
Bruce Allan17f208d2009-12-01 15:47:22 +00004310}
4311
4312/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07004313 * e1000_clear_hw_cntrs_ich8lan - Clear statistical counters
4314 * @hw: pointer to the HW structure
4315 *
4316 * Clears hardware counters specific to the silicon family and calls
4317 * clear_hw_cntrs_generic to clear all general purpose counters.
4318 **/
4319static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw)
4320{
Bruce Allana4f58f52009-06-02 11:29:18 +00004321 u16 phy_data;
Bruce Allan2b6b1682011-05-13 07:20:09 +00004322 s32 ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -07004323
4324 e1000e_clear_hw_cntrs_base(hw);
4325
Bruce Allan99673d92009-11-20 23:27:21 +00004326 er32(ALGNERRC);
4327 er32(RXERRC);
4328 er32(TNCRS);
4329 er32(CEXTERR);
4330 er32(TSCTC);
4331 er32(TSCTFC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07004332
Bruce Allan99673d92009-11-20 23:27:21 +00004333 er32(MGTPRC);
4334 er32(MGTPDC);
4335 er32(MGTPTC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07004336
Bruce Allan99673d92009-11-20 23:27:21 +00004337 er32(IAC);
4338 er32(ICRXOC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07004339
Bruce Allana4f58f52009-06-02 11:29:18 +00004340 /* Clear PHY statistics registers */
4341 if ((hw->phy.type == e1000_phy_82578) ||
Bruce Alland3738bb2010-06-16 13:27:28 +00004342 (hw->phy.type == e1000_phy_82579) ||
Bruce Allan2fbe4522012-04-19 03:21:47 +00004343 (hw->phy.type == e1000_phy_i217) ||
Bruce Allana4f58f52009-06-02 11:29:18 +00004344 (hw->phy.type == e1000_phy_82577)) {
Bruce Allan2b6b1682011-05-13 07:20:09 +00004345 ret_val = hw->phy.ops.acquire(hw);
4346 if (ret_val)
4347 return;
4348 ret_val = hw->phy.ops.set_page(hw,
4349 HV_STATS_PAGE << IGP_PAGE_SHIFT);
4350 if (ret_val)
4351 goto release;
4352 hw->phy.ops.read_reg_page(hw, HV_SCC_UPPER, &phy_data);
4353 hw->phy.ops.read_reg_page(hw, HV_SCC_LOWER, &phy_data);
4354 hw->phy.ops.read_reg_page(hw, HV_ECOL_UPPER, &phy_data);
4355 hw->phy.ops.read_reg_page(hw, HV_ECOL_LOWER, &phy_data);
4356 hw->phy.ops.read_reg_page(hw, HV_MCC_UPPER, &phy_data);
4357 hw->phy.ops.read_reg_page(hw, HV_MCC_LOWER, &phy_data);
4358 hw->phy.ops.read_reg_page(hw, HV_LATECOL_UPPER, &phy_data);
4359 hw->phy.ops.read_reg_page(hw, HV_LATECOL_LOWER, &phy_data);
4360 hw->phy.ops.read_reg_page(hw, HV_COLC_UPPER, &phy_data);
4361 hw->phy.ops.read_reg_page(hw, HV_COLC_LOWER, &phy_data);
4362 hw->phy.ops.read_reg_page(hw, HV_DC_UPPER, &phy_data);
4363 hw->phy.ops.read_reg_page(hw, HV_DC_LOWER, &phy_data);
4364 hw->phy.ops.read_reg_page(hw, HV_TNCRS_UPPER, &phy_data);
4365 hw->phy.ops.read_reg_page(hw, HV_TNCRS_LOWER, &phy_data);
4366release:
4367 hw->phy.ops.release(hw);
Bruce Allana4f58f52009-06-02 11:29:18 +00004368 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07004369}
4370
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00004371static const struct e1000_mac_operations ich8_mac_ops = {
Bruce Allaneb7700d2010-06-16 13:27:05 +00004372 /* check_mng_mode dependent on mac type */
Bruce Allan7d3cabb2009-07-01 13:29:08 +00004373 .check_for_link = e1000_check_for_copper_link_ich8lan,
Bruce Allana4f58f52009-06-02 11:29:18 +00004374 /* cleanup_led dependent on mac type */
Auke Kokbc7f75f2007-09-17 12:30:59 -07004375 .clear_hw_cntrs = e1000_clear_hw_cntrs_ich8lan,
4376 .get_bus_info = e1000_get_bus_info_ich8lan,
Bruce Allanf4d2dd42010-01-13 02:05:18 +00004377 .set_lan_id = e1000_set_lan_id_single_port,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004378 .get_link_up_info = e1000_get_link_up_info_ich8lan,
Bruce Allana4f58f52009-06-02 11:29:18 +00004379 /* led_on dependent on mac type */
4380 /* led_off dependent on mac type */
Jeff Kirshere2de3eb2008-03-28 09:15:11 -07004381 .update_mc_addr_list = e1000e_update_mc_addr_list_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004382 .reset_hw = e1000_reset_hw_ich8lan,
4383 .init_hw = e1000_init_hw_ich8lan,
4384 .setup_link = e1000_setup_link_ich8lan,
Bruce Allan55c5f552013-01-12 07:28:24 +00004385 .setup_physical_interface = e1000_setup_copper_link_ich8lan,
Bruce Allana4f58f52009-06-02 11:29:18 +00004386 /* id_led_init dependent on mac type */
Bruce Allan57cde762012-02-22 09:02:58 +00004387 .config_collision_dist = e1000e_config_collision_dist_generic,
Bruce Allan69e1e012012-04-14 03:28:50 +00004388 .rar_set = e1000e_rar_set_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004389};
4390
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00004391static const struct e1000_phy_operations ich8_phy_ops = {
Bruce Allan94d81862009-11-20 23:25:26 +00004392 .acquire = e1000_acquire_swflag_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004393 .check_reset_block = e1000_check_reset_block_ich8lan,
Bruce Allan94d81862009-11-20 23:25:26 +00004394 .commit = NULL,
Bruce Allanf4187b52008-08-26 18:36:50 -07004395 .get_cfg_done = e1000_get_cfg_done_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004396 .get_cable_length = e1000e_get_cable_length_igp_2,
Bruce Allan94d81862009-11-20 23:25:26 +00004397 .read_reg = e1000e_read_phy_reg_igp,
4398 .release = e1000_release_swflag_ich8lan,
4399 .reset = e1000_phy_hw_reset_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004400 .set_d0_lplu_state = e1000_set_d0_lplu_state_ich8lan,
4401 .set_d3_lplu_state = e1000_set_d3_lplu_state_ich8lan,
Bruce Allan94d81862009-11-20 23:25:26 +00004402 .write_reg = e1000e_write_phy_reg_igp,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004403};
4404
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00004405static const struct e1000_nvm_operations ich8_nvm_ops = {
Bruce Allan94d81862009-11-20 23:25:26 +00004406 .acquire = e1000_acquire_nvm_ich8lan,
Bruce Allan55c5f552013-01-12 07:28:24 +00004407 .read = e1000_read_nvm_ich8lan,
Bruce Allan94d81862009-11-20 23:25:26 +00004408 .release = e1000_release_nvm_ich8lan,
Bruce Allane85e3632012-02-22 09:03:14 +00004409 .reload = e1000e_reload_nvm_generic,
Bruce Allan94d81862009-11-20 23:25:26 +00004410 .update = e1000_update_nvm_checksum_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004411 .valid_led_default = e1000_valid_led_default_ich8lan,
Bruce Allan94d81862009-11-20 23:25:26 +00004412 .validate = e1000_validate_nvm_checksum_ich8lan,
4413 .write = e1000_write_nvm_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004414};
4415
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00004416const struct e1000_info e1000_ich8_info = {
Auke Kokbc7f75f2007-09-17 12:30:59 -07004417 .mac = e1000_ich8lan,
4418 .flags = FLAG_HAS_WOL
Bruce Allan97ac8ca2008-04-29 09:16:05 -07004419 | FLAG_IS_ICH
Auke Kokbc7f75f2007-09-17 12:30:59 -07004420 | FLAG_HAS_CTRLEXT_ON_LOAD
4421 | FLAG_HAS_AMT
4422 | FLAG_HAS_FLASH
4423 | FLAG_APME_IN_WUC,
4424 .pba = 8,
Bruce Allan2adc55c2009-06-02 11:28:58 +00004425 .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN,
Jeff Kirsher69e3fd82008-04-02 13:48:18 -07004426 .get_variants = e1000_get_variants_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004427 .mac_ops = &ich8_mac_ops,
4428 .phy_ops = &ich8_phy_ops,
4429 .nvm_ops = &ich8_nvm_ops,
4430};
4431
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00004432const struct e1000_info e1000_ich9_info = {
Auke Kokbc7f75f2007-09-17 12:30:59 -07004433 .mac = e1000_ich9lan,
4434 .flags = FLAG_HAS_JUMBO_FRAMES
Bruce Allan97ac8ca2008-04-29 09:16:05 -07004435 | FLAG_IS_ICH
Auke Kokbc7f75f2007-09-17 12:30:59 -07004436 | FLAG_HAS_WOL
Auke Kokbc7f75f2007-09-17 12:30:59 -07004437 | FLAG_HAS_CTRLEXT_ON_LOAD
4438 | FLAG_HAS_AMT
Auke Kokbc7f75f2007-09-17 12:30:59 -07004439 | FLAG_HAS_FLASH
4440 | FLAG_APME_IN_WUC,
Bruce Allan7f1557e2011-12-16 00:46:43 +00004441 .pba = 18,
Bruce Allan2adc55c2009-06-02 11:28:58 +00004442 .max_hw_frame_size = DEFAULT_JUMBO,
Jeff Kirsher69e3fd82008-04-02 13:48:18 -07004443 .get_variants = e1000_get_variants_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004444 .mac_ops = &ich8_mac_ops,
4445 .phy_ops = &ich8_phy_ops,
4446 .nvm_ops = &ich8_nvm_ops,
4447};
4448
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00004449const struct e1000_info e1000_ich10_info = {
Bruce Allanf4187b52008-08-26 18:36:50 -07004450 .mac = e1000_ich10lan,
4451 .flags = FLAG_HAS_JUMBO_FRAMES
4452 | FLAG_IS_ICH
4453 | FLAG_HAS_WOL
Bruce Allanf4187b52008-08-26 18:36:50 -07004454 | FLAG_HAS_CTRLEXT_ON_LOAD
4455 | FLAG_HAS_AMT
Bruce Allanf4187b52008-08-26 18:36:50 -07004456 | FLAG_HAS_FLASH
4457 | FLAG_APME_IN_WUC,
Bruce Allan7f1557e2011-12-16 00:46:43 +00004458 .pba = 18,
Bruce Allan2adc55c2009-06-02 11:28:58 +00004459 .max_hw_frame_size = DEFAULT_JUMBO,
Bruce Allanf4187b52008-08-26 18:36:50 -07004460 .get_variants = e1000_get_variants_ich8lan,
4461 .mac_ops = &ich8_mac_ops,
4462 .phy_ops = &ich8_phy_ops,
4463 .nvm_ops = &ich8_nvm_ops,
4464};
Bruce Allana4f58f52009-06-02 11:29:18 +00004465
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00004466const struct e1000_info e1000_pch_info = {
Bruce Allana4f58f52009-06-02 11:29:18 +00004467 .mac = e1000_pchlan,
4468 .flags = FLAG_IS_ICH
4469 | FLAG_HAS_WOL
Bruce Allana4f58f52009-06-02 11:29:18 +00004470 | FLAG_HAS_CTRLEXT_ON_LOAD
4471 | FLAG_HAS_AMT
4472 | FLAG_HAS_FLASH
4473 | FLAG_HAS_JUMBO_FRAMES
Bruce Allan38eb3942009-11-19 12:34:20 +00004474 | FLAG_DISABLE_FC_PAUSE_TIME /* errata */
Bruce Allana4f58f52009-06-02 11:29:18 +00004475 | FLAG_APME_IN_WUC,
Bruce Allan8c7bbb92010-06-16 13:26:41 +00004476 .flags2 = FLAG2_HAS_PHY_STATS,
Bruce Allana4f58f52009-06-02 11:29:18 +00004477 .pba = 26,
4478 .max_hw_frame_size = 4096,
4479 .get_variants = e1000_get_variants_ich8lan,
4480 .mac_ops = &ich8_mac_ops,
4481 .phy_ops = &ich8_phy_ops,
4482 .nvm_ops = &ich8_nvm_ops,
4483};
Bruce Alland3738bb2010-06-16 13:27:28 +00004484
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00004485const struct e1000_info e1000_pch2_info = {
Bruce Alland3738bb2010-06-16 13:27:28 +00004486 .mac = e1000_pch2lan,
4487 .flags = FLAG_IS_ICH
4488 | FLAG_HAS_WOL
Bruce Allanb67e1912012-12-27 08:32:33 +00004489 | FLAG_HAS_HW_TIMESTAMP
Bruce Alland3738bb2010-06-16 13:27:28 +00004490 | FLAG_HAS_CTRLEXT_ON_LOAD
4491 | FLAG_HAS_AMT
4492 | FLAG_HAS_FLASH
4493 | FLAG_HAS_JUMBO_FRAMES
4494 | FLAG_APME_IN_WUC,
Bruce Allane52997f2010-06-16 13:27:49 +00004495 .flags2 = FLAG2_HAS_PHY_STATS
4496 | FLAG2_HAS_EEE,
Bruce Allan828bac82010-09-29 21:39:37 +00004497 .pba = 26,
Bruce Allanc3d2dbf2013-01-09 01:20:46 +00004498 .max_hw_frame_size = 9018,
Bruce Alland3738bb2010-06-16 13:27:28 +00004499 .get_variants = e1000_get_variants_ich8lan,
4500 .mac_ops = &ich8_mac_ops,
4501 .phy_ops = &ich8_phy_ops,
4502 .nvm_ops = &ich8_nvm_ops,
4503};
Bruce Allan2fbe4522012-04-19 03:21:47 +00004504
4505const struct e1000_info e1000_pch_lpt_info = {
4506 .mac = e1000_pch_lpt,
4507 .flags = FLAG_IS_ICH
4508 | FLAG_HAS_WOL
Bruce Allanb67e1912012-12-27 08:32:33 +00004509 | FLAG_HAS_HW_TIMESTAMP
Bruce Allan2fbe4522012-04-19 03:21:47 +00004510 | FLAG_HAS_CTRLEXT_ON_LOAD
4511 | FLAG_HAS_AMT
4512 | FLAG_HAS_FLASH
4513 | FLAG_HAS_JUMBO_FRAMES
4514 | FLAG_APME_IN_WUC,
4515 .flags2 = FLAG2_HAS_PHY_STATS
4516 | FLAG2_HAS_EEE,
4517 .pba = 26,
Bruce Allaned1a4262013-01-04 09:51:36 +00004518 .max_hw_frame_size = 9018,
Bruce Allan2fbe4522012-04-19 03:21:47 +00004519 .get_variants = e1000_get_variants_ich8lan,
4520 .mac_ops = &ich8_mac_ops,
4521 .phy_ops = &ich8_phy_ops,
4522 .nvm_ops = &ich8_nvm_ops,
4523};