blob: 4c8b0fb6534f5dd032c99ed5f1e550fb93782ab0 [file] [log] [blame]
Auke Kokbc7f75f2007-09-17 12:30:59 -07001/*******************************************************************************
2
3 Intel PRO/1000 Linux driver
Bruce Allanf5e261e2012-01-01 16:00:03 +00004 Copyright(c) 1999 - 2012 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
29/*
Bruce Allan16059272008-11-21 16:51:06 -080030 * 82562G 10/100 Network Connection
Auke Kokbc7f75f2007-09-17 12:30:59 -070031 * 82562G-2 10/100 Network Connection
32 * 82562GT 10/100 Network Connection
33 * 82562GT-2 10/100 Network Connection
34 * 82562V 10/100 Network Connection
35 * 82562V-2 10/100 Network Connection
36 * 82566DC-2 Gigabit Network Connection
37 * 82566DC Gigabit Network Connection
38 * 82566DM-2 Gigabit Network Connection
39 * 82566DM Gigabit Network Connection
40 * 82566MC Gigabit Network Connection
41 * 82566MM Gigabit Network Connection
Bruce Allan97ac8ca2008-04-29 09:16:05 -070042 * 82567LM Gigabit Network Connection
43 * 82567LF Gigabit Network Connection
Bruce Allan16059272008-11-21 16:51:06 -080044 * 82567V Gigabit Network Connection
Bruce Allan97ac8ca2008-04-29 09:16:05 -070045 * 82567LM-2 Gigabit Network Connection
46 * 82567LF-2 Gigabit Network Connection
47 * 82567V-2 Gigabit Network Connection
Bruce Allanf4187b52008-08-26 18:36:50 -070048 * 82567LF-3 Gigabit Network Connection
49 * 82567LM-3 Gigabit Network Connection
Bruce Allan2f15f9d2008-08-26 18:36:36 -070050 * 82567LM-4 Gigabit Network Connection
Bruce Allana4f58f52009-06-02 11:29:18 +000051 * 82577LM Gigabit Network Connection
52 * 82577LC Gigabit Network Connection
53 * 82578DM Gigabit Network Connection
54 * 82578DC Gigabit Network Connection
Bruce Alland3738bb2010-06-16 13:27:28 +000055 * 82579LM Gigabit Network Connection
56 * 82579V Gigabit Network Connection
Auke Kokbc7f75f2007-09-17 12:30:59 -070057 */
58
Auke Kokbc7f75f2007-09-17 12:30:59 -070059#include "e1000.h"
60
61#define ICH_FLASH_GFPREG 0x0000
62#define ICH_FLASH_HSFSTS 0x0004
63#define ICH_FLASH_HSFCTL 0x0006
64#define ICH_FLASH_FADDR 0x0008
65#define ICH_FLASH_FDATA0 0x0010
Bruce Allan4a770352008-10-01 17:18:35 -070066#define ICH_FLASH_PR0 0x0074
Auke Kokbc7f75f2007-09-17 12:30:59 -070067
68#define ICH_FLASH_READ_COMMAND_TIMEOUT 500
69#define ICH_FLASH_WRITE_COMMAND_TIMEOUT 500
70#define ICH_FLASH_ERASE_COMMAND_TIMEOUT 3000000
71#define ICH_FLASH_LINEAR_ADDR_MASK 0x00FFFFFF
72#define ICH_FLASH_CYCLE_REPEAT_COUNT 10
73
74#define ICH_CYCLE_READ 0
75#define ICH_CYCLE_WRITE 2
76#define ICH_CYCLE_ERASE 3
77
78#define FLASH_GFPREG_BASE_MASK 0x1FFF
79#define FLASH_SECTOR_ADDR_SHIFT 12
80
81#define ICH_FLASH_SEG_SIZE_256 256
82#define ICH_FLASH_SEG_SIZE_4K 4096
83#define ICH_FLASH_SEG_SIZE_8K 8192
84#define ICH_FLASH_SEG_SIZE_64K 65536
85
86
87#define E1000_ICH_FWSM_RSPCIPHY 0x00000040 /* Reset PHY on PCI Reset */
Bruce Allan6dfaa762010-05-05 22:00:06 +000088/* FW established a valid mode */
89#define E1000_ICH_FWSM_FW_VALID 0x00008000
Auke Kokbc7f75f2007-09-17 12:30:59 -070090
91#define E1000_ICH_MNG_IAMT_MODE 0x2
92
93#define ID_LED_DEFAULT_ICH8LAN ((ID_LED_DEF1_DEF2 << 12) | \
94 (ID_LED_DEF1_OFF2 << 8) | \
95 (ID_LED_DEF1_ON2 << 4) | \
96 (ID_LED_DEF1_DEF2))
97
98#define E1000_ICH_NVM_SIG_WORD 0x13
99#define E1000_ICH_NVM_SIG_MASK 0xC000
Bruce Allane2434552008-11-21 17:02:41 -0800100#define E1000_ICH_NVM_VALID_SIG_MASK 0xC0
101#define E1000_ICH_NVM_SIG_VALUE 0x80
Auke Kokbc7f75f2007-09-17 12:30:59 -0700102
103#define E1000_ICH8_LAN_INIT_TIMEOUT 1500
104
105#define E1000_FEXTNVM_SW_CONFIG 1
106#define E1000_FEXTNVM_SW_CONFIG_ICH8M (1 << 27) /* Bit redefined for ICH8M :/ */
107
Bruce Allan62bc8132012-03-20 03:47:57 +0000108#define E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK 0x0C000000
109#define E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC 0x08000000
110
Bruce Allan831bd2e2010-09-22 17:16:18 +0000111#define E1000_FEXTNVM4_BEACON_DURATION_MASK 0x7
112#define E1000_FEXTNVM4_BEACON_DURATION_8USEC 0x7
113#define E1000_FEXTNVM4_BEACON_DURATION_16USEC 0x3
114
Auke Kokbc7f75f2007-09-17 12:30:59 -0700115#define PCIE_ICH8_SNOOP_ALL PCIE_NO_SNOOP_ALL
116
117#define E1000_ICH_RAR_ENTRIES 7
118
119#define PHY_PAGE_SHIFT 5
120#define PHY_REG(page, reg) (((page) << PHY_PAGE_SHIFT) | \
121 ((reg) & MAX_PHY_REG_ADDRESS))
122#define IGP3_KMRN_DIAG PHY_REG(770, 19) /* KMRN Diagnostic */
123#define IGP3_VR_CTRL PHY_REG(776, 18) /* Voltage Regulator Control */
124
125#define IGP3_KMRN_DIAG_PCS_LOCK_LOSS 0x0002
126#define IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK 0x0300
127#define IGP3_VR_CTRL_MODE_SHUTDOWN 0x0200
128
Bruce Allana4f58f52009-06-02 11:29:18 +0000129#define HV_LED_CONFIG PHY_REG(768, 30) /* LED Configuration */
130
Bruce Allan53ac5a82009-10-26 11:23:06 +0000131#define SW_FLAG_TIMEOUT 1000 /* SW Semaphore flag timeout in milliseconds */
132
Bruce Allanf523d212009-10-29 13:45:45 +0000133/* SMBus Address Phy Register */
134#define HV_SMB_ADDR PHY_REG(768, 26)
Bruce Allan8395ae82010-09-22 17:15:08 +0000135#define HV_SMB_ADDR_MASK 0x007F
Bruce Allanf523d212009-10-29 13:45:45 +0000136#define HV_SMB_ADDR_PEC_EN 0x0200
137#define HV_SMB_ADDR_VALID 0x0080
138
Bruce Alland3738bb2010-06-16 13:27:28 +0000139/* PHY Power Management Control */
140#define HV_PM_CTRL PHY_REG(770, 17)
Bruce Allan36ceeb42012-03-20 03:47:47 +0000141#define HV_PM_CTRL_PLL_STOP_IN_K1_GIGA 0x100
Bruce Alland3738bb2010-06-16 13:27:28 +0000142
Bruce Allane52997f2010-06-16 13:27:49 +0000143/* PHY Low Power Idle Control */
Bruce Allan0ed013e2011-07-29 05:52:56 +0000144#define I82579_LPI_CTRL PHY_REG(772, 20)
145#define I82579_LPI_CTRL_ENABLE_MASK 0x6000
146#define I82579_LPI_CTRL_FORCE_PLL_LOCK_COUNT 0x80
Bruce Allane52997f2010-06-16 13:27:49 +0000147
Bruce Allan1effb452011-02-25 06:58:03 +0000148/* EMI Registers */
149#define I82579_EMI_ADDR 0x10
150#define I82579_EMI_DATA 0x11
151#define I82579_LPI_UPDATE_TIMER 0x4805 /* in 40ns units + 40 ns base value */
Bruce Allan4d241362011-12-16 00:46:06 +0000152#define I82579_MSE_THRESHOLD 0x084F /* Mean Square Error Threshold */
153#define I82579_MSE_LINK_DOWN 0x2411 /* MSE count before dropping link */
Bruce Allan1effb452011-02-25 06:58:03 +0000154
Bruce Allanf523d212009-10-29 13:45:45 +0000155/* Strapping Option Register - RO */
156#define E1000_STRAP 0x0000C
157#define E1000_STRAP_SMBUS_ADDRESS_MASK 0x00FE0000
158#define E1000_STRAP_SMBUS_ADDRESS_SHIFT 17
159
Bruce Allanfa2ce132009-10-26 11:23:25 +0000160/* OEM Bits Phy Register */
161#define HV_OEM_BITS PHY_REG(768, 25)
162#define HV_OEM_BITS_LPLU 0x0004 /* Low Power Link Up */
Bruce Allanf523d212009-10-29 13:45:45 +0000163#define HV_OEM_BITS_GBE_DIS 0x0040 /* Gigabit Disable */
Bruce Allanfa2ce132009-10-26 11:23:25 +0000164#define HV_OEM_BITS_RESTART_AN 0x0400 /* Restart Auto-negotiation */
165
Bruce Allan1d5846b2009-10-29 13:46:05 +0000166#define E1000_NVM_K1_CONFIG 0x1B /* NVM K1 Config Word */
167#define E1000_NVM_K1_ENABLE 0x1 /* NVM Enable K1 bit */
168
Bruce Allanfddaa1a2010-01-13 01:52:49 +0000169/* KMRN Mode Control */
170#define HV_KMRN_MODE_CTRL PHY_REG(769, 16)
171#define HV_KMRN_MDIO_SLOW 0x0400
172
Bruce Allan1d2101a72011-07-22 06:21:56 +0000173/* KMRN FIFO Control and Status */
174#define HV_KMRN_FIFO_CTRLSTA PHY_REG(770, 16)
175#define HV_KMRN_FIFO_CTRLSTA_PREAMBLE_MASK 0x7000
176#define HV_KMRN_FIFO_CTRLSTA_PREAMBLE_SHIFT 12
177
Auke Kokbc7f75f2007-09-17 12:30:59 -0700178/* ICH GbE Flash Hardware Sequencing Flash Status Register bit breakdown */
179/* Offset 04h HSFSTS */
180union ich8_hws_flash_status {
181 struct ich8_hsfsts {
182 u16 flcdone :1; /* bit 0 Flash Cycle Done */
183 u16 flcerr :1; /* bit 1 Flash Cycle Error */
184 u16 dael :1; /* bit 2 Direct Access error Log */
185 u16 berasesz :2; /* bit 4:3 Sector Erase Size */
186 u16 flcinprog :1; /* bit 5 flash cycle in Progress */
187 u16 reserved1 :2; /* bit 13:6 Reserved */
188 u16 reserved2 :6; /* bit 13:6 Reserved */
189 u16 fldesvalid :1; /* bit 14 Flash Descriptor Valid */
190 u16 flockdn :1; /* bit 15 Flash Config Lock-Down */
191 } hsf_status;
192 u16 regval;
193};
194
195/* ICH GbE Flash Hardware Sequencing Flash control Register bit breakdown */
196/* Offset 06h FLCTL */
197union ich8_hws_flash_ctrl {
198 struct ich8_hsflctl {
199 u16 flcgo :1; /* 0 Flash Cycle Go */
200 u16 flcycle :2; /* 2:1 Flash Cycle */
201 u16 reserved :5; /* 7:3 Reserved */
202 u16 fldbcount :2; /* 9:8 Flash Data Byte Count */
203 u16 flockdn :6; /* 15:10 Reserved */
204 } hsf_ctrl;
205 u16 regval;
206};
207
208/* ICH Flash Region Access Permissions */
209union ich8_hws_flash_regacc {
210 struct ich8_flracc {
211 u32 grra :8; /* 0:7 GbE region Read Access */
212 u32 grwa :8; /* 8:15 GbE region Write Access */
213 u32 gmrag :8; /* 23:16 GbE Master Read Access Grant */
214 u32 gmwag :8; /* 31:24 GbE Master Write Access Grant */
215 } hsf_flregacc;
216 u16 regval;
217};
218
Bruce Allan4a770352008-10-01 17:18:35 -0700219/* ICH Flash Protected Region */
220union ich8_flash_protected_range {
221 struct ich8_pr {
222 u32 base:13; /* 0:12 Protected Range Base */
223 u32 reserved1:2; /* 13:14 Reserved */
224 u32 rpe:1; /* 15 Read Protection Enable */
225 u32 limit:13; /* 16:28 Protected Range Limit */
226 u32 reserved2:2; /* 29:30 Reserved */
227 u32 wpe:1; /* 31 Write Protection Enable */
228 } range;
229 u32 regval;
230};
231
Auke Kokbc7f75f2007-09-17 12:30:59 -0700232static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw);
233static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw);
234static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700235static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank);
236static s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw,
237 u32 offset, u8 byte);
Bruce Allanf4187b52008-08-26 18:36:50 -0700238static s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
239 u8 *data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700240static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset,
241 u16 *data);
242static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
243 u8 size, u16 *data);
244static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw);
245static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw);
Bruce Allanf4187b52008-08-26 18:36:50 -0700246static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw);
Bruce Allana4f58f52009-06-02 11:29:18 +0000247static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw);
248static s32 e1000_led_on_ich8lan(struct e1000_hw *hw);
249static s32 e1000_led_off_ich8lan(struct e1000_hw *hw);
250static s32 e1000_id_led_init_pchlan(struct e1000_hw *hw);
251static s32 e1000_setup_led_pchlan(struct e1000_hw *hw);
252static s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw);
253static s32 e1000_led_on_pchlan(struct e1000_hw *hw);
254static s32 e1000_led_off_pchlan(struct e1000_hw *hw);
Bruce Allanfa2ce132009-10-26 11:23:25 +0000255static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active);
Bruce Allan17f208d2009-12-01 15:47:22 +0000256static void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw);
Bruce Allanf523d212009-10-29 13:45:45 +0000257static void e1000_lan_init_done_ich8lan(struct e1000_hw *hw);
Bruce Allan1d5846b2009-10-29 13:46:05 +0000258static s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link);
Bruce Allanfddaa1a2010-01-13 01:52:49 +0000259static s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw);
Bruce Allaneb7700d2010-06-16 13:27:05 +0000260static bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw);
261static bool e1000_check_mng_mode_pchlan(struct e1000_hw *hw);
Bruce Allan831bd2e2010-09-22 17:16:18 +0000262static s32 e1000_k1_workaround_lv(struct e1000_hw *hw);
Bruce Allan605c82b2010-09-22 17:17:01 +0000263static void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700264
265static inline u16 __er16flash(struct e1000_hw *hw, unsigned long reg)
266{
267 return readw(hw->flash_address + reg);
268}
269
270static inline u32 __er32flash(struct e1000_hw *hw, unsigned long reg)
271{
272 return readl(hw->flash_address + reg);
273}
274
275static inline void __ew16flash(struct e1000_hw *hw, unsigned long reg, u16 val)
276{
277 writew(val, hw->flash_address + reg);
278}
279
280static inline void __ew32flash(struct e1000_hw *hw, unsigned long reg, u32 val)
281{
282 writel(val, hw->flash_address + reg);
283}
284
285#define er16flash(reg) __er16flash(hw, (reg))
286#define er32flash(reg) __er32flash(hw, (reg))
Bruce Allan0e15df42012-01-31 06:37:11 +0000287#define ew16flash(reg, val) __ew16flash(hw, (reg), (val))
288#define ew32flash(reg, val) __ew32flash(hw, (reg), (val))
Auke Kokbc7f75f2007-09-17 12:30:59 -0700289
Bruce Allancb17aab2012-04-13 03:16:22 +0000290/**
291 * e1000_phy_is_accessible_pchlan - Check if able to access PHY registers
292 * @hw: pointer to the HW structure
293 *
294 * Test access to the PHY registers by reading the PHY ID registers. If
295 * the PHY ID is already known (e.g. resume path) compare it with known ID,
296 * otherwise assume the read PHY ID is correct if it is valid.
297 *
298 * Assumes the sw/fw/hw semaphore is already acquired.
299 **/
300static bool e1000_phy_is_accessible_pchlan(struct e1000_hw *hw)
Bruce Allan99730e42011-05-13 07:19:48 +0000301{
Bruce Allancb17aab2012-04-13 03:16:22 +0000302 u16 phy_reg;
303 u32 phy_id;
Bruce Allan99730e42011-05-13 07:19:48 +0000304
Bruce Allancb17aab2012-04-13 03:16:22 +0000305 hw->phy.ops.read_reg_locked(hw, PHY_ID1, &phy_reg);
306 phy_id = (u32)(phy_reg << 16);
307 hw->phy.ops.read_reg_locked(hw, PHY_ID2, &phy_reg);
308 phy_id |= (u32)(phy_reg & PHY_REVISION_MASK);
Bruce Allan62bc8132012-03-20 03:47:57 +0000309
Bruce Allancb17aab2012-04-13 03:16:22 +0000310 if (hw->phy.id) {
311 if (hw->phy.id == phy_id)
312 return true;
313 } else {
314 if ((phy_id != 0) && (phy_id != PHY_REVISION_MASK))
315 hw->phy.id = phy_id;
316 return true;
317 }
318
319 return false;
320}
321
322/**
323 * e1000_init_phy_workarounds_pchlan - PHY initialization workarounds
324 * @hw: pointer to the HW structure
325 *
326 * Workarounds/flow necessary for PHY initialization during driver load
327 * and resume paths.
328 **/
329static s32 e1000_init_phy_workarounds_pchlan(struct e1000_hw *hw)
330{
331 u32 mac_reg, fwsm = er32(FWSM);
332 s32 ret_val;
333
334 ret_val = hw->phy.ops.acquire(hw);
335 if (ret_val) {
336 e_dbg("Failed to initialize PHY flow\n");
337 return ret_val;
338 }
339
340 /*
341 * The MAC-PHY interconnect may be in SMBus mode. If the PHY is
342 * inaccessible and resetting the PHY is not blocked, toggle the
343 * LANPHYPC Value bit to force the interconnect to PCIe mode.
344 */
345 switch (hw->mac.type) {
346 case e1000_pch2lan:
347 /*
348 * Gate automatic PHY configuration by hardware on
349 * non-managed 82579
350 */
351 if (!(fwsm & E1000_ICH_FWSM_FW_VALID))
352 e1000_gate_hw_phy_config_ich8lan(hw, true);
353
354 if (e1000_phy_is_accessible_pchlan(hw))
355 break;
356
357 /* fall-through */
358 case e1000_pchlan:
359 if ((hw->mac.type == e1000_pchlan) &&
360 (fwsm & E1000_ICH_FWSM_FW_VALID))
361 break;
362
363 if (hw->phy.ops.check_reset_block(hw)) {
364 e_dbg("Required LANPHYPC toggle blocked by ME\n");
365 break;
366 }
367
368 e_dbg("Toggling LANPHYPC\n");
369
370 /* Set Phy Config Counter to 50msec */
371 mac_reg = er32(FEXTNVM3);
372 mac_reg &= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK;
373 mac_reg |= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC;
374 ew32(FEXTNVM3, mac_reg);
375
376 /* Toggle LANPHYPC Value bit */
377 mac_reg = er32(CTRL);
378 mac_reg |= E1000_CTRL_LANPHYPC_OVERRIDE;
379 mac_reg &= ~E1000_CTRL_LANPHYPC_VALUE;
380 ew32(CTRL, mac_reg);
381 e1e_flush();
382 udelay(10);
383 mac_reg &= ~E1000_CTRL_LANPHYPC_OVERRIDE;
384 ew32(CTRL, mac_reg);
385 e1e_flush();
386 msleep(50);
387 break;
388 default:
389 break;
390 }
391
392 hw->phy.ops.release(hw);
393
394 /*
395 * Reset the PHY before any access to it. Doing so, ensures
396 * that the PHY is in a known good state before we read/write
397 * PHY registers. The generic reset is sufficient here,
398 * because we haven't determined the PHY type yet.
399 */
400 ret_val = e1000e_phy_hw_reset_generic(hw);
401
402 /* Ungate automatic PHY configuration on non-managed 82579 */
403 if ((hw->mac.type == e1000_pch2lan) &&
404 !(fwsm & E1000_ICH_FWSM_FW_VALID)) {
405 usleep_range(10000, 20000);
406 e1000_gate_hw_phy_config_ich8lan(hw, false);
407 }
408
409 return ret_val;
Bruce Allan99730e42011-05-13 07:19:48 +0000410}
411
Auke Kokbc7f75f2007-09-17 12:30:59 -0700412/**
Bruce Allana4f58f52009-06-02 11:29:18 +0000413 * e1000_init_phy_params_pchlan - Initialize PHY function pointers
414 * @hw: pointer to the HW structure
415 *
416 * Initialize family-specific PHY parameters and function pointers.
417 **/
418static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw)
419{
420 struct e1000_phy_info *phy = &hw->phy;
421 s32 ret_val = 0;
422
423 phy->addr = 1;
424 phy->reset_delay_us = 100;
425
Bruce Allan2b6b1682011-05-13 07:20:09 +0000426 phy->ops.set_page = e1000_set_page_igp;
Bruce Allan94d81862009-11-20 23:25:26 +0000427 phy->ops.read_reg = e1000_read_phy_reg_hv;
428 phy->ops.read_reg_locked = e1000_read_phy_reg_hv_locked;
Bruce Allan2b6b1682011-05-13 07:20:09 +0000429 phy->ops.read_reg_page = e1000_read_phy_reg_page_hv;
Bruce Allanfa2ce132009-10-26 11:23:25 +0000430 phy->ops.set_d0_lplu_state = e1000_set_lplu_state_pchlan;
431 phy->ops.set_d3_lplu_state = e1000_set_lplu_state_pchlan;
Bruce Allan94d81862009-11-20 23:25:26 +0000432 phy->ops.write_reg = e1000_write_phy_reg_hv;
433 phy->ops.write_reg_locked = e1000_write_phy_reg_hv_locked;
Bruce Allan2b6b1682011-05-13 07:20:09 +0000434 phy->ops.write_reg_page = e1000_write_phy_reg_page_hv;
Bruce Allan17f208d2009-12-01 15:47:22 +0000435 phy->ops.power_up = e1000_power_up_phy_copper;
436 phy->ops.power_down = e1000_power_down_phy_copper_ich8lan;
Bruce Allana4f58f52009-06-02 11:29:18 +0000437 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
438
439 phy->id = e1000_phy_unknown;
Bruce Allancb17aab2012-04-13 03:16:22 +0000440
441 ret_val = e1000_init_phy_workarounds_pchlan(hw);
442 if (ret_val)
443 return ret_val;
444
445 if (phy->id == e1000_phy_unknown)
446 switch (hw->mac.type) {
447 default:
448 ret_val = e1000e_get_phy_id(hw);
449 if (ret_val)
450 return ret_val;
451 if ((phy->id != 0) && (phy->id != PHY_REVISION_MASK))
452 break;
453 /* fall-through */
454 case e1000_pch2lan:
455 /*
456 * In case the PHY needs to be in mdio slow mode,
457 * set slow mode and try to get the PHY id again.
458 */
459 ret_val = e1000_set_mdio_slow_mode_hv(hw);
460 if (ret_val)
461 return ret_val;
462 ret_val = e1000e_get_phy_id(hw);
463 if (ret_val)
464 return ret_val;
Bruce Allan664dc872010-11-24 06:01:46 +0000465 break;
Bruce Allancb17aab2012-04-13 03:16:22 +0000466 }
Bruce Allana4f58f52009-06-02 11:29:18 +0000467 phy->type = e1000e_get_phy_type_from_id(phy->id);
468
Bruce Allan0be84012009-12-02 17:03:18 +0000469 switch (phy->type) {
470 case e1000_phy_82577:
Bruce Alland3738bb2010-06-16 13:27:28 +0000471 case e1000_phy_82579:
Bruce Allana4f58f52009-06-02 11:29:18 +0000472 phy->ops.check_polarity = e1000_check_polarity_82577;
473 phy->ops.force_speed_duplex =
Bruce Allan6cc7aae2011-02-25 06:25:18 +0000474 e1000_phy_force_speed_duplex_82577;
Bruce Allan0be84012009-12-02 17:03:18 +0000475 phy->ops.get_cable_length = e1000_get_cable_length_82577;
Bruce Allan94d81862009-11-20 23:25:26 +0000476 phy->ops.get_info = e1000_get_phy_info_82577;
477 phy->ops.commit = e1000e_phy_sw_reset;
Bruce Allaneab50ff2010-05-10 15:01:30 +0000478 break;
Bruce Allan0be84012009-12-02 17:03:18 +0000479 case e1000_phy_82578:
480 phy->ops.check_polarity = e1000_check_polarity_m88;
481 phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_m88;
482 phy->ops.get_cable_length = e1000e_get_cable_length_m88;
483 phy->ops.get_info = e1000e_get_phy_info_m88;
484 break;
485 default:
486 ret_val = -E1000_ERR_PHY;
487 break;
Bruce Allana4f58f52009-06-02 11:29:18 +0000488 }
489
490 return ret_val;
491}
492
493/**
Auke Kokbc7f75f2007-09-17 12:30:59 -0700494 * e1000_init_phy_params_ich8lan - Initialize PHY function pointers
495 * @hw: pointer to the HW structure
496 *
497 * Initialize family-specific PHY parameters and function pointers.
498 **/
499static s32 e1000_init_phy_params_ich8lan(struct e1000_hw *hw)
500{
501 struct e1000_phy_info *phy = &hw->phy;
502 s32 ret_val;
503 u16 i = 0;
504
505 phy->addr = 1;
506 phy->reset_delay_us = 100;
507
Bruce Allan17f208d2009-12-01 15:47:22 +0000508 phy->ops.power_up = e1000_power_up_phy_copper;
509 phy->ops.power_down = e1000_power_down_phy_copper_ich8lan;
510
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700511 /*
512 * We may need to do this twice - once for IGP and if that fails,
513 * we'll set BM func pointers and try again
514 */
515 ret_val = e1000e_determine_phy_address(hw);
516 if (ret_val) {
Bruce Allan94d81862009-11-20 23:25:26 +0000517 phy->ops.write_reg = e1000e_write_phy_reg_bm;
518 phy->ops.read_reg = e1000e_read_phy_reg_bm;
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700519 ret_val = e1000e_determine_phy_address(hw);
Bruce Allan9b71b412009-12-01 15:53:07 +0000520 if (ret_val) {
521 e_dbg("Cannot determine PHY addr. Erroring out\n");
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700522 return ret_val;
Bruce Allan9b71b412009-12-01 15:53:07 +0000523 }
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700524 }
525
Auke Kokbc7f75f2007-09-17 12:30:59 -0700526 phy->id = 0;
527 while ((e1000_phy_unknown == e1000e_get_phy_type_from_id(phy->id)) &&
528 (i++ < 100)) {
Bruce Allan1bba4382011-03-19 00:27:20 +0000529 usleep_range(1000, 2000);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700530 ret_val = e1000e_get_phy_id(hw);
531 if (ret_val)
532 return ret_val;
533 }
534
535 /* Verify phy id */
536 switch (phy->id) {
537 case IGP03E1000_E_PHY_ID:
538 phy->type = e1000_phy_igp_3;
539 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
Bruce Allan94d81862009-11-20 23:25:26 +0000540 phy->ops.read_reg_locked = e1000e_read_phy_reg_igp_locked;
541 phy->ops.write_reg_locked = e1000e_write_phy_reg_igp_locked;
Bruce Allan0be84012009-12-02 17:03:18 +0000542 phy->ops.get_info = e1000e_get_phy_info_igp;
543 phy->ops.check_polarity = e1000_check_polarity_igp;
544 phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_igp;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700545 break;
546 case IFE_E_PHY_ID:
547 case IFE_PLUS_E_PHY_ID:
548 case IFE_C_E_PHY_ID:
549 phy->type = e1000_phy_ife;
550 phy->autoneg_mask = E1000_ALL_NOT_GIG;
Bruce Allan0be84012009-12-02 17:03:18 +0000551 phy->ops.get_info = e1000_get_phy_info_ife;
552 phy->ops.check_polarity = e1000_check_polarity_ife;
553 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_ife;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700554 break;
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700555 case BME1000_E_PHY_ID:
556 phy->type = e1000_phy_bm;
557 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
Bruce Allan94d81862009-11-20 23:25:26 +0000558 phy->ops.read_reg = e1000e_read_phy_reg_bm;
559 phy->ops.write_reg = e1000e_write_phy_reg_bm;
560 phy->ops.commit = e1000e_phy_sw_reset;
Bruce Allan0be84012009-12-02 17:03:18 +0000561 phy->ops.get_info = e1000e_get_phy_info_m88;
562 phy->ops.check_polarity = e1000_check_polarity_m88;
563 phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_m88;
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700564 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700565 default:
566 return -E1000_ERR_PHY;
567 break;
568 }
569
570 return 0;
571}
572
573/**
574 * e1000_init_nvm_params_ich8lan - Initialize NVM function pointers
575 * @hw: pointer to the HW structure
576 *
577 * Initialize family-specific NVM parameters and function
578 * pointers.
579 **/
580static s32 e1000_init_nvm_params_ich8lan(struct e1000_hw *hw)
581{
582 struct e1000_nvm_info *nvm = &hw->nvm;
583 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
Bruce Allan148675a2009-08-07 07:41:56 +0000584 u32 gfpreg, sector_base_addr, sector_end_addr;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700585 u16 i;
586
Bruce Allanad680762008-03-28 09:15:03 -0700587 /* Can't read flash registers if the register set isn't mapped. */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700588 if (!hw->flash_address) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000589 e_dbg("ERROR: Flash registers not mapped\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700590 return -E1000_ERR_CONFIG;
591 }
592
593 nvm->type = e1000_nvm_flash_sw;
594
595 gfpreg = er32flash(ICH_FLASH_GFPREG);
596
Bruce Allanad680762008-03-28 09:15:03 -0700597 /*
598 * sector_X_addr is a "sector"-aligned address (4096 bytes)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700599 * Add 1 to sector_end_addr since this sector is included in
Bruce Allanad680762008-03-28 09:15:03 -0700600 * the overall size.
601 */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700602 sector_base_addr = gfpreg & FLASH_GFPREG_BASE_MASK;
603 sector_end_addr = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK) + 1;
604
605 /* flash_base_addr is byte-aligned */
606 nvm->flash_base_addr = sector_base_addr << FLASH_SECTOR_ADDR_SHIFT;
607
Bruce Allanad680762008-03-28 09:15:03 -0700608 /*
609 * find total size of the NVM, then cut in half since the total
610 * size represents two separate NVM banks.
611 */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700612 nvm->flash_bank_size = (sector_end_addr - sector_base_addr)
613 << FLASH_SECTOR_ADDR_SHIFT;
614 nvm->flash_bank_size /= 2;
615 /* Adjust to word count */
616 nvm->flash_bank_size /= sizeof(u16);
617
618 nvm->word_size = E1000_ICH8_SHADOW_RAM_WORDS;
619
620 /* Clear shadow ram */
621 for (i = 0; i < nvm->word_size; i++) {
Bruce Allan564ea9b2009-11-20 23:26:44 +0000622 dev_spec->shadow_ram[i].modified = false;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700623 dev_spec->shadow_ram[i].value = 0xFFFF;
624 }
625
626 return 0;
627}
628
629/**
630 * e1000_init_mac_params_ich8lan - Initialize MAC function pointers
631 * @hw: pointer to the HW structure
632 *
633 * Initialize family-specific MAC parameters and function
634 * pointers.
635 **/
Bruce Allanec34c172012-02-01 10:53:05 +0000636static s32 e1000_init_mac_params_ich8lan(struct e1000_hw *hw)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700637{
Auke Kokbc7f75f2007-09-17 12:30:59 -0700638 struct e1000_mac_info *mac = &hw->mac;
639
640 /* Set media type function pointer */
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700641 hw->phy.media_type = e1000_media_type_copper;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700642
643 /* Set mta register count */
644 mac->mta_reg_count = 32;
645 /* Set rar entry count */
646 mac->rar_entry_count = E1000_ICH_RAR_ENTRIES;
647 if (mac->type == e1000_ich8lan)
648 mac->rar_entry_count--;
Bruce Allana65a4a02010-05-10 15:01:51 +0000649 /* FWSM register */
650 mac->has_fwsm = true;
651 /* ARC subsystem not supported */
652 mac->arc_subsystem_valid = false;
Bruce Allanf464ba82010-01-07 16:31:35 +0000653 /* Adaptive IFS supported */
654 mac->adaptive_ifs = true;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700655
Bruce Allana4f58f52009-06-02 11:29:18 +0000656 /* LED operations */
657 switch (mac->type) {
658 case e1000_ich8lan:
659 case e1000_ich9lan:
660 case e1000_ich10lan:
Bruce Allaneb7700d2010-06-16 13:27:05 +0000661 /* check management mode */
662 mac->ops.check_mng_mode = e1000_check_mng_mode_ich8lan;
Bruce Allana4f58f52009-06-02 11:29:18 +0000663 /* ID LED init */
Bruce Alland1964eb2012-02-22 09:02:21 +0000664 mac->ops.id_led_init = e1000e_id_led_init_generic;
Bruce Allandbf80dc2011-04-16 00:34:40 +0000665 /* blink LED */
666 mac->ops.blink_led = e1000e_blink_led_generic;
Bruce Allana4f58f52009-06-02 11:29:18 +0000667 /* setup LED */
668 mac->ops.setup_led = e1000e_setup_led_generic;
669 /* cleanup LED */
670 mac->ops.cleanup_led = e1000_cleanup_led_ich8lan;
671 /* turn on/off LED */
672 mac->ops.led_on = e1000_led_on_ich8lan;
673 mac->ops.led_off = e1000_led_off_ich8lan;
674 break;
675 case e1000_pchlan:
Bruce Alland3738bb2010-06-16 13:27:28 +0000676 case e1000_pch2lan:
Bruce Allaneb7700d2010-06-16 13:27:05 +0000677 /* check management mode */
678 mac->ops.check_mng_mode = e1000_check_mng_mode_pchlan;
Bruce Allana4f58f52009-06-02 11:29:18 +0000679 /* ID LED init */
680 mac->ops.id_led_init = e1000_id_led_init_pchlan;
681 /* setup LED */
682 mac->ops.setup_led = e1000_setup_led_pchlan;
683 /* cleanup LED */
684 mac->ops.cleanup_led = e1000_cleanup_led_pchlan;
685 /* turn on/off LED */
686 mac->ops.led_on = e1000_led_on_pchlan;
687 mac->ops.led_off = e1000_led_off_pchlan;
688 break;
689 default:
690 break;
691 }
692
Auke Kokbc7f75f2007-09-17 12:30:59 -0700693 /* Enable PCS Lock-loss workaround for ICH8 */
694 if (mac->type == e1000_ich8lan)
Bruce Allan564ea9b2009-11-20 23:26:44 +0000695 e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw, true);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700696
Bruce Allan605c82b2010-09-22 17:17:01 +0000697 /* Gate automatic PHY configuration by hardware on managed 82579 */
698 if ((mac->type == e1000_pch2lan) &&
699 (er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
700 e1000_gate_hw_phy_config_ich8lan(hw, true);
Bruce Alland3738bb2010-06-16 13:27:28 +0000701
Auke Kokbc7f75f2007-09-17 12:30:59 -0700702 return 0;
703}
704
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000705/**
Bruce Allane52997f2010-06-16 13:27:49 +0000706 * e1000_set_eee_pchlan - Enable/disable EEE support
707 * @hw: pointer to the HW structure
708 *
709 * Enable/disable EEE based on setting in dev_spec structure. The bits in
710 * the LPI Control register will remain set only if/when link is up.
711 **/
712static s32 e1000_set_eee_pchlan(struct e1000_hw *hw)
713{
714 s32 ret_val = 0;
715 u16 phy_reg;
716
717 if (hw->phy.type != e1000_phy_82579)
Bruce Allan5015e532012-02-08 02:55:56 +0000718 return 0;
Bruce Allane52997f2010-06-16 13:27:49 +0000719
720 ret_val = e1e_rphy(hw, I82579_LPI_CTRL, &phy_reg);
721 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +0000722 return ret_val;
Bruce Allane52997f2010-06-16 13:27:49 +0000723
724 if (hw->dev_spec.ich8lan.eee_disable)
725 phy_reg &= ~I82579_LPI_CTRL_ENABLE_MASK;
726 else
727 phy_reg |= I82579_LPI_CTRL_ENABLE_MASK;
728
Bruce Allan5015e532012-02-08 02:55:56 +0000729 return e1e_wphy(hw, I82579_LPI_CTRL, phy_reg);
Bruce Allane52997f2010-06-16 13:27:49 +0000730}
731
732/**
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000733 * e1000_check_for_copper_link_ich8lan - Check for link (Copper)
734 * @hw: pointer to the HW structure
735 *
736 * Checks to see of the link status of the hardware has changed. If a
737 * change in link status has been detected, then we read the PHY registers
738 * to get the current speed/duplex if link exists.
739 **/
740static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw)
741{
742 struct e1000_mac_info *mac = &hw->mac;
743 s32 ret_val;
744 bool link;
Bruce Allan1d2101a72011-07-22 06:21:56 +0000745 u16 phy_reg;
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000746
747 /*
748 * We only want to go out to the PHY registers to see if Auto-Neg
749 * has completed and/or if our link status has changed. The
750 * get_link_status flag is set upon receiving a Link Status
751 * Change or Rx Sequence Error interrupt.
752 */
Bruce Allan5015e532012-02-08 02:55:56 +0000753 if (!mac->get_link_status)
754 return 0;
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000755
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000756 /*
757 * First we want to see if the MII Status Register reports
758 * link. If so, then we want to get the current speed/duplex
759 * of the PHY.
760 */
761 ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link);
762 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +0000763 return ret_val;
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000764
Bruce Allan1d5846b2009-10-29 13:46:05 +0000765 if (hw->mac.type == e1000_pchlan) {
766 ret_val = e1000_k1_gig_workaround_hv(hw, link);
767 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +0000768 return ret_val;
Bruce Allan1d5846b2009-10-29 13:46:05 +0000769 }
770
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000771 if (!link)
Bruce Allan5015e532012-02-08 02:55:56 +0000772 return 0; /* No link detected */
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000773
774 mac->get_link_status = false;
775
Bruce Allan1d2101a72011-07-22 06:21:56 +0000776 switch (hw->mac.type) {
777 case e1000_pch2lan:
Bruce Allan831bd2e2010-09-22 17:16:18 +0000778 ret_val = e1000_k1_workaround_lv(hw);
779 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +0000780 return ret_val;
Bruce Allan1d2101a72011-07-22 06:21:56 +0000781 /* fall-thru */
782 case e1000_pchlan:
783 if (hw->phy.type == e1000_phy_82578) {
784 ret_val = e1000_link_stall_workaround_hv(hw);
785 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +0000786 return ret_val;
Bruce Allan1d2101a72011-07-22 06:21:56 +0000787 }
788
789 /*
790 * Workaround for PCHx parts in half-duplex:
791 * Set the number of preambles removed from the packet
792 * when it is passed from the PHY to the MAC to prevent
793 * the MAC from misinterpreting the packet type.
794 */
795 e1e_rphy(hw, HV_KMRN_FIFO_CTRLSTA, &phy_reg);
796 phy_reg &= ~HV_KMRN_FIFO_CTRLSTA_PREAMBLE_MASK;
797
798 if ((er32(STATUS) & E1000_STATUS_FD) != E1000_STATUS_FD)
799 phy_reg |= (1 << HV_KMRN_FIFO_CTRLSTA_PREAMBLE_SHIFT);
800
801 e1e_wphy(hw, HV_KMRN_FIFO_CTRLSTA, phy_reg);
802 break;
803 default:
804 break;
Bruce Allan831bd2e2010-09-22 17:16:18 +0000805 }
806
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000807 /*
808 * Check if there was DownShift, must be checked
809 * immediately after link-up
810 */
811 e1000e_check_downshift(hw);
812
Bruce Allane52997f2010-06-16 13:27:49 +0000813 /* Enable/Disable EEE after link up */
814 ret_val = e1000_set_eee_pchlan(hw);
815 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +0000816 return ret_val;
Bruce Allane52997f2010-06-16 13:27:49 +0000817
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000818 /*
819 * If we are forcing speed/duplex, then we simply return since
820 * we have already determined whether we have link or not.
821 */
Bruce Allan5015e532012-02-08 02:55:56 +0000822 if (!mac->autoneg)
823 return -E1000_ERR_CONFIG;
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000824
825 /*
826 * Auto-Neg is enabled. Auto Speed Detection takes care
827 * of MAC speed/duplex configuration. So we only need to
828 * configure Collision Distance in the MAC.
829 */
Bruce Allan57cde762012-02-22 09:02:58 +0000830 mac->ops.config_collision_dist(hw);
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000831
832 /*
833 * Configure Flow Control now that Auto-Neg has completed.
834 * First, we need to restore the desired flow control
835 * settings because we may have had to re-autoneg with a
836 * different link partner.
837 */
838 ret_val = e1000e_config_fc_after_link_up(hw);
839 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000840 e_dbg("Error configuring flow control\n");
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000841
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000842 return ret_val;
843}
844
Jeff Kirsher69e3fd82008-04-02 13:48:18 -0700845static s32 e1000_get_variants_ich8lan(struct e1000_adapter *adapter)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700846{
847 struct e1000_hw *hw = &adapter->hw;
848 s32 rc;
849
Bruce Allanec34c172012-02-01 10:53:05 +0000850 rc = e1000_init_mac_params_ich8lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700851 if (rc)
852 return rc;
853
854 rc = e1000_init_nvm_params_ich8lan(hw);
855 if (rc)
856 return rc;
857
Bruce Alland3738bb2010-06-16 13:27:28 +0000858 switch (hw->mac.type) {
859 case e1000_ich8lan:
860 case e1000_ich9lan:
861 case e1000_ich10lan:
Bruce Allana4f58f52009-06-02 11:29:18 +0000862 rc = e1000_init_phy_params_ich8lan(hw);
Bruce Alland3738bb2010-06-16 13:27:28 +0000863 break;
864 case e1000_pchlan:
865 case e1000_pch2lan:
866 rc = e1000_init_phy_params_pchlan(hw);
867 break;
868 default:
869 break;
870 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700871 if (rc)
872 return rc;
873
Bruce Allan23e4f062011-02-25 07:44:51 +0000874 /*
875 * Disable Jumbo Frame support on parts with Intel 10/100 PHY or
876 * on parts with MACsec enabled in NVM (reflected in CTRL_EXT).
877 */
878 if ((adapter->hw.phy.type == e1000_phy_ife) ||
879 ((adapter->hw.mac.type >= e1000_pch2lan) &&
880 (!(er32(CTRL_EXT) & E1000_CTRL_EXT_LSECCK)))) {
Bruce Allan2adc55c2009-06-02 11:28:58 +0000881 adapter->flags &= ~FLAG_HAS_JUMBO_FRAMES;
882 adapter->max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN;
Bruce Allandbf80dc2011-04-16 00:34:40 +0000883
884 hw->mac.ops.blink_led = NULL;
Bruce Allan2adc55c2009-06-02 11:28:58 +0000885 }
886
Auke Kokbc7f75f2007-09-17 12:30:59 -0700887 if ((adapter->hw.mac.type == e1000_ich8lan) &&
Bruce Allan462d5992011-09-30 08:07:11 +0000888 (adapter->hw.phy.type != e1000_phy_ife))
Auke Kokbc7f75f2007-09-17 12:30:59 -0700889 adapter->flags |= FLAG_LSC_GIG_SPEED_DROP;
890
Bruce Allanc6e7f512011-07-29 05:53:02 +0000891 /* Enable workaround for 82579 w/ ME enabled */
892 if ((adapter->hw.mac.type == e1000_pch2lan) &&
893 (er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
894 adapter->flags2 |= FLAG2_PCIM2PCI_ARBITER_WA;
895
Bruce Allan5a86f282010-06-29 18:13:13 +0000896 /* Disable EEE by default until IEEE802.3az spec is finalized */
897 if (adapter->flags2 & FLAG2_HAS_EEE)
898 adapter->hw.dev_spec.ich8lan.eee_disable = true;
899
Auke Kokbc7f75f2007-09-17 12:30:59 -0700900 return 0;
901}
902
Thomas Gleixner717d4382008-10-02 16:33:40 -0700903static DEFINE_MUTEX(nvm_mutex);
Thomas Gleixner717d4382008-10-02 16:33:40 -0700904
Auke Kokbc7f75f2007-09-17 12:30:59 -0700905/**
Bruce Allanca15df52009-10-26 11:23:43 +0000906 * e1000_acquire_nvm_ich8lan - Acquire NVM mutex
907 * @hw: pointer to the HW structure
908 *
909 * Acquires the mutex for performing NVM operations.
910 **/
911static s32 e1000_acquire_nvm_ich8lan(struct e1000_hw *hw)
912{
913 mutex_lock(&nvm_mutex);
914
915 return 0;
916}
917
918/**
919 * e1000_release_nvm_ich8lan - Release NVM mutex
920 * @hw: pointer to the HW structure
921 *
922 * Releases the mutex used while performing NVM operations.
923 **/
924static void e1000_release_nvm_ich8lan(struct e1000_hw *hw)
925{
926 mutex_unlock(&nvm_mutex);
Bruce Allanca15df52009-10-26 11:23:43 +0000927}
928
Bruce Allanca15df52009-10-26 11:23:43 +0000929/**
Auke Kokbc7f75f2007-09-17 12:30:59 -0700930 * e1000_acquire_swflag_ich8lan - Acquire software control flag
931 * @hw: pointer to the HW structure
932 *
Bruce Allanca15df52009-10-26 11:23:43 +0000933 * Acquires the software control flag for performing PHY and select
934 * MAC CSR accesses.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700935 **/
936static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw)
937{
Bruce Allan373a88d2009-08-07 07:41:37 +0000938 u32 extcnf_ctrl, timeout = PHY_CFG_TIMEOUT;
939 s32 ret_val = 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700940
Bruce Allana90b4122011-10-07 03:50:38 +0000941 if (test_and_set_bit(__E1000_ACCESS_SHARED_RESOURCE,
942 &hw->adapter->state)) {
Bruce Allan34c9ef82011-10-21 04:33:47 +0000943 e_dbg("contention for Phy access\n");
Bruce Allana90b4122011-10-07 03:50:38 +0000944 return -E1000_ERR_PHY;
945 }
Thomas Gleixner717d4382008-10-02 16:33:40 -0700946
Auke Kokbc7f75f2007-09-17 12:30:59 -0700947 while (timeout) {
948 extcnf_ctrl = er32(EXTCNF_CTRL);
Bruce Allan373a88d2009-08-07 07:41:37 +0000949 if (!(extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG))
950 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700951
Auke Kokbc7f75f2007-09-17 12:30:59 -0700952 mdelay(1);
953 timeout--;
954 }
955
956 if (!timeout) {
Bruce Allana90b4122011-10-07 03:50:38 +0000957 e_dbg("SW has already locked the resource.\n");
Bruce Allan373a88d2009-08-07 07:41:37 +0000958 ret_val = -E1000_ERR_CONFIG;
959 goto out;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700960 }
961
Bruce Allan53ac5a82009-10-26 11:23:06 +0000962 timeout = SW_FLAG_TIMEOUT;
Bruce Allan373a88d2009-08-07 07:41:37 +0000963
964 extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG;
965 ew32(EXTCNF_CTRL, extcnf_ctrl);
966
967 while (timeout) {
968 extcnf_ctrl = er32(EXTCNF_CTRL);
969 if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG)
970 break;
971
972 mdelay(1);
973 timeout--;
974 }
975
976 if (!timeout) {
Bruce Allan434f1392011-12-16 00:46:54 +0000977 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 +0000978 er32(FWSM), extcnf_ctrl);
Bruce Allan373a88d2009-08-07 07:41:37 +0000979 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
980 ew32(EXTCNF_CTRL, extcnf_ctrl);
981 ret_val = -E1000_ERR_CONFIG;
982 goto out;
983 }
984
985out:
986 if (ret_val)
Bruce Allana90b4122011-10-07 03:50:38 +0000987 clear_bit(__E1000_ACCESS_SHARED_RESOURCE, &hw->adapter->state);
Bruce Allan373a88d2009-08-07 07:41:37 +0000988
989 return ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700990}
991
992/**
993 * e1000_release_swflag_ich8lan - Release software control flag
994 * @hw: pointer to the HW structure
995 *
Bruce Allanca15df52009-10-26 11:23:43 +0000996 * Releases the software control flag for performing PHY and select
997 * MAC CSR accesses.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700998 **/
999static void e1000_release_swflag_ich8lan(struct e1000_hw *hw)
1000{
1001 u32 extcnf_ctrl;
1002
1003 extcnf_ctrl = er32(EXTCNF_CTRL);
Bruce Allanc5caf482011-05-13 07:19:53 +00001004
1005 if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG) {
1006 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
1007 ew32(EXTCNF_CTRL, extcnf_ctrl);
1008 } else {
1009 e_dbg("Semaphore unexpectedly released by sw/fw/hw\n");
1010 }
Thomas Gleixner717d4382008-10-02 16:33:40 -07001011
Bruce Allana90b4122011-10-07 03:50:38 +00001012 clear_bit(__E1000_ACCESS_SHARED_RESOURCE, &hw->adapter->state);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001013}
1014
1015/**
Bruce Allan4662e822008-08-26 18:37:06 -07001016 * e1000_check_mng_mode_ich8lan - Checks management mode
1017 * @hw: pointer to the HW structure
1018 *
Bruce Allaneb7700d2010-06-16 13:27:05 +00001019 * This checks if the adapter has any manageability enabled.
Bruce Allan4662e822008-08-26 18:37:06 -07001020 * This is a function pointer entry point only called by read/write
1021 * routines for the PHY and NVM parts.
1022 **/
1023static bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw)
1024{
Bruce Allana708dd82009-11-20 23:28:37 +00001025 u32 fwsm;
1026
1027 fwsm = er32(FWSM);
Bruce Allaneb7700d2010-06-16 13:27:05 +00001028 return (fwsm & E1000_ICH_FWSM_FW_VALID) &&
1029 ((fwsm & E1000_FWSM_MODE_MASK) ==
1030 (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT));
1031}
Bruce Allan4662e822008-08-26 18:37:06 -07001032
Bruce Allaneb7700d2010-06-16 13:27:05 +00001033/**
1034 * e1000_check_mng_mode_pchlan - Checks management mode
1035 * @hw: pointer to the HW structure
1036 *
1037 * This checks if the adapter has iAMT enabled.
1038 * This is a function pointer entry point only called by read/write
1039 * routines for the PHY and NVM parts.
1040 **/
1041static bool e1000_check_mng_mode_pchlan(struct e1000_hw *hw)
1042{
1043 u32 fwsm;
1044
1045 fwsm = er32(FWSM);
1046 return (fwsm & E1000_ICH_FWSM_FW_VALID) &&
1047 (fwsm & (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT));
Bruce Allan4662e822008-08-26 18:37:06 -07001048}
1049
1050/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07001051 * e1000_check_reset_block_ich8lan - Check if PHY reset is blocked
1052 * @hw: pointer to the HW structure
1053 *
1054 * Checks if firmware is blocking the reset of the PHY.
1055 * This is a function pointer entry point only called by
1056 * reset routines.
1057 **/
1058static s32 e1000_check_reset_block_ich8lan(struct e1000_hw *hw)
1059{
1060 u32 fwsm;
1061
1062 fwsm = er32(FWSM);
1063
1064 return (fwsm & E1000_ICH_FWSM_RSPCIPHY) ? 0 : E1000_BLK_PHY_RESET;
1065}
1066
1067/**
Bruce Allan8395ae82010-09-22 17:15:08 +00001068 * e1000_write_smbus_addr - Write SMBus address to PHY needed during Sx states
1069 * @hw: pointer to the HW structure
1070 *
1071 * Assumes semaphore already acquired.
1072 *
1073 **/
1074static s32 e1000_write_smbus_addr(struct e1000_hw *hw)
1075{
1076 u16 phy_data;
1077 u32 strap = er32(STRAP);
1078 s32 ret_val = 0;
1079
1080 strap &= E1000_STRAP_SMBUS_ADDRESS_MASK;
1081
1082 ret_val = e1000_read_phy_reg_hv_locked(hw, HV_SMB_ADDR, &phy_data);
1083 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001084 return ret_val;
Bruce Allan8395ae82010-09-22 17:15:08 +00001085
1086 phy_data &= ~HV_SMB_ADDR_MASK;
1087 phy_data |= (strap >> E1000_STRAP_SMBUS_ADDRESS_SHIFT);
1088 phy_data |= HV_SMB_ADDR_PEC_EN | HV_SMB_ADDR_VALID;
Bruce Allan8395ae82010-09-22 17:15:08 +00001089
Bruce Allan5015e532012-02-08 02:55:56 +00001090 return e1000_write_phy_reg_hv_locked(hw, HV_SMB_ADDR, phy_data);
Bruce Allan8395ae82010-09-22 17:15:08 +00001091}
1092
1093/**
Bruce Allanf523d212009-10-29 13:45:45 +00001094 * e1000_sw_lcd_config_ich8lan - SW-based LCD Configuration
1095 * @hw: pointer to the HW structure
1096 *
1097 * SW should configure the LCD from the NVM extended configuration region
1098 * as a workaround for certain parts.
1099 **/
1100static s32 e1000_sw_lcd_config_ich8lan(struct e1000_hw *hw)
1101{
1102 struct e1000_phy_info *phy = &hw->phy;
1103 u32 i, data, cnf_size, cnf_base_addr, sw_cfg_mask;
Bruce Allan8b802a72010-05-10 15:01:10 +00001104 s32 ret_val = 0;
Bruce Allanf523d212009-10-29 13:45:45 +00001105 u16 word_addr, reg_data, reg_addr, phy_page = 0;
1106
Bruce Allanf523d212009-10-29 13:45:45 +00001107 /*
1108 * Initialize the PHY from the NVM on ICH platforms. This
1109 * is needed due to an issue where the NVM configuration is
1110 * not properly autoloaded after power transitions.
1111 * Therefore, after each PHY reset, we will load the
1112 * configuration data out of the NVM manually.
1113 */
Bruce Allan3f0c16e2010-06-16 13:26:17 +00001114 switch (hw->mac.type) {
1115 case e1000_ich8lan:
1116 if (phy->type != e1000_phy_igp_3)
1117 return ret_val;
1118
Bruce Allan5f3eed62010-09-22 17:15:54 +00001119 if ((hw->adapter->pdev->device == E1000_DEV_ID_ICH8_IGP_AMT) ||
1120 (hw->adapter->pdev->device == E1000_DEV_ID_ICH8_IGP_C)) {
Bruce Allan3f0c16e2010-06-16 13:26:17 +00001121 sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG;
1122 break;
1123 }
1124 /* Fall-thru */
1125 case e1000_pchlan:
Bruce Alland3738bb2010-06-16 13:27:28 +00001126 case e1000_pch2lan:
Bruce Allan8b802a72010-05-10 15:01:10 +00001127 sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG_ICH8M;
Bruce Allan3f0c16e2010-06-16 13:26:17 +00001128 break;
1129 default:
1130 return ret_val;
1131 }
1132
1133 ret_val = hw->phy.ops.acquire(hw);
1134 if (ret_val)
1135 return ret_val;
Bruce Allanf523d212009-10-29 13:45:45 +00001136
Bruce Allan8b802a72010-05-10 15:01:10 +00001137 data = er32(FEXTNVM);
1138 if (!(data & sw_cfg_mask))
Bruce Allan75ce1532012-02-08 02:54:48 +00001139 goto release;
Bruce Allanf523d212009-10-29 13:45:45 +00001140
Bruce Allan8b802a72010-05-10 15:01:10 +00001141 /*
1142 * Make sure HW does not configure LCD from PHY
1143 * extended configuration before SW configuration
1144 */
1145 data = er32(EXTCNF_CTRL);
Bruce Alland3738bb2010-06-16 13:27:28 +00001146 if (!(hw->mac.type == e1000_pch2lan)) {
1147 if (data & E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE)
Bruce Allan75ce1532012-02-08 02:54:48 +00001148 goto release;
Bruce Alland3738bb2010-06-16 13:27:28 +00001149 }
Bruce Allanf523d212009-10-29 13:45:45 +00001150
Bruce Allan8b802a72010-05-10 15:01:10 +00001151 cnf_size = er32(EXTCNF_SIZE);
1152 cnf_size &= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_MASK;
1153 cnf_size >>= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_SHIFT;
1154 if (!cnf_size)
Bruce Allan75ce1532012-02-08 02:54:48 +00001155 goto release;
Bruce Allan8b802a72010-05-10 15:01:10 +00001156
1157 cnf_base_addr = data & E1000_EXTCNF_CTRL_EXT_CNF_POINTER_MASK;
1158 cnf_base_addr >>= E1000_EXTCNF_CTRL_EXT_CNF_POINTER_SHIFT;
1159
Bruce Allan87fb7412010-09-22 17:15:33 +00001160 if ((!(data & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE) &&
1161 (hw->mac.type == e1000_pchlan)) ||
1162 (hw->mac.type == e1000_pch2lan)) {
Bruce Allanf523d212009-10-29 13:45:45 +00001163 /*
Bruce Allan8b802a72010-05-10 15:01:10 +00001164 * HW configures the SMBus address and LEDs when the
1165 * OEM and LCD Write Enable bits are set in the NVM.
1166 * When both NVM bits are cleared, SW will configure
1167 * them instead.
Bruce Allanf523d212009-10-29 13:45:45 +00001168 */
Bruce Allan8395ae82010-09-22 17:15:08 +00001169 ret_val = e1000_write_smbus_addr(hw);
Bruce Allan8b802a72010-05-10 15:01:10 +00001170 if (ret_val)
Bruce Allan75ce1532012-02-08 02:54:48 +00001171 goto release;
Bruce Allanf523d212009-10-29 13:45:45 +00001172
Bruce Allan8b802a72010-05-10 15:01:10 +00001173 data = er32(LEDCTL);
1174 ret_val = e1000_write_phy_reg_hv_locked(hw, HV_LED_CONFIG,
1175 (u16)data);
1176 if (ret_val)
Bruce Allan75ce1532012-02-08 02:54:48 +00001177 goto release;
Bruce Allan8b802a72010-05-10 15:01:10 +00001178 }
1179
1180 /* Configure LCD from extended configuration region. */
1181
1182 /* cnf_base_addr is in DWORD */
1183 word_addr = (u16)(cnf_base_addr << 1);
1184
1185 for (i = 0; i < cnf_size; i++) {
1186 ret_val = e1000_read_nvm(hw, (word_addr + i * 2), 1,
1187 &reg_data);
1188 if (ret_val)
Bruce Allan75ce1532012-02-08 02:54:48 +00001189 goto release;
Bruce Allanf523d212009-10-29 13:45:45 +00001190
Bruce Allan8b802a72010-05-10 15:01:10 +00001191 ret_val = e1000_read_nvm(hw, (word_addr + i * 2 + 1),
1192 1, &reg_addr);
1193 if (ret_val)
Bruce Allan75ce1532012-02-08 02:54:48 +00001194 goto release;
Bruce Allanf523d212009-10-29 13:45:45 +00001195
Bruce Allan8b802a72010-05-10 15:01:10 +00001196 /* Save off the PHY page for future writes. */
1197 if (reg_addr == IGP01E1000_PHY_PAGE_SELECT) {
1198 phy_page = reg_data;
1199 continue;
Bruce Allanf523d212009-10-29 13:45:45 +00001200 }
Bruce Allanf523d212009-10-29 13:45:45 +00001201
Bruce Allan8b802a72010-05-10 15:01:10 +00001202 reg_addr &= PHY_REG_MASK;
1203 reg_addr |= phy_page;
Bruce Allanf523d212009-10-29 13:45:45 +00001204
Bruce Allan8b802a72010-05-10 15:01:10 +00001205 ret_val = phy->ops.write_reg_locked(hw, (u32)reg_addr,
1206 reg_data);
1207 if (ret_val)
Bruce Allan75ce1532012-02-08 02:54:48 +00001208 goto release;
Bruce Allanf523d212009-10-29 13:45:45 +00001209 }
1210
Bruce Allan75ce1532012-02-08 02:54:48 +00001211release:
Bruce Allan94d81862009-11-20 23:25:26 +00001212 hw->phy.ops.release(hw);
Bruce Allanf523d212009-10-29 13:45:45 +00001213 return ret_val;
1214}
1215
1216/**
Bruce Allan1d5846b2009-10-29 13:46:05 +00001217 * e1000_k1_gig_workaround_hv - K1 Si workaround
1218 * @hw: pointer to the HW structure
1219 * @link: link up bool flag
1220 *
1221 * If K1 is enabled for 1Gbps, the MAC might stall when transitioning
1222 * from a lower speed. This workaround disables K1 whenever link is at 1Gig
1223 * If link is down, the function will restore the default K1 setting located
1224 * in the NVM.
1225 **/
1226static s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link)
1227{
1228 s32 ret_val = 0;
1229 u16 status_reg = 0;
1230 bool k1_enable = hw->dev_spec.ich8lan.nvm_k1_enabled;
1231
1232 if (hw->mac.type != e1000_pchlan)
Bruce Allan5015e532012-02-08 02:55:56 +00001233 return 0;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001234
1235 /* Wrap the whole flow with the sw flag */
Bruce Allan94d81862009-11-20 23:25:26 +00001236 ret_val = hw->phy.ops.acquire(hw);
Bruce Allan1d5846b2009-10-29 13:46:05 +00001237 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001238 return ret_val;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001239
1240 /* Disable K1 when link is 1Gbps, otherwise use the NVM setting */
1241 if (link) {
1242 if (hw->phy.type == e1000_phy_82578) {
Bruce Allan94d81862009-11-20 23:25:26 +00001243 ret_val = hw->phy.ops.read_reg_locked(hw, BM_CS_STATUS,
Bruce Allan1d5846b2009-10-29 13:46:05 +00001244 &status_reg);
1245 if (ret_val)
1246 goto release;
1247
1248 status_reg &= BM_CS_STATUS_LINK_UP |
1249 BM_CS_STATUS_RESOLVED |
1250 BM_CS_STATUS_SPEED_MASK;
1251
1252 if (status_reg == (BM_CS_STATUS_LINK_UP |
1253 BM_CS_STATUS_RESOLVED |
1254 BM_CS_STATUS_SPEED_1000))
1255 k1_enable = false;
1256 }
1257
1258 if (hw->phy.type == e1000_phy_82577) {
Bruce Allan94d81862009-11-20 23:25:26 +00001259 ret_val = hw->phy.ops.read_reg_locked(hw, HV_M_STATUS,
Bruce Allan1d5846b2009-10-29 13:46:05 +00001260 &status_reg);
1261 if (ret_val)
1262 goto release;
1263
1264 status_reg &= HV_M_STATUS_LINK_UP |
1265 HV_M_STATUS_AUTONEG_COMPLETE |
1266 HV_M_STATUS_SPEED_MASK;
1267
1268 if (status_reg == (HV_M_STATUS_LINK_UP |
1269 HV_M_STATUS_AUTONEG_COMPLETE |
1270 HV_M_STATUS_SPEED_1000))
1271 k1_enable = false;
1272 }
1273
1274 /* Link stall fix for link up */
Bruce Allan94d81862009-11-20 23:25:26 +00001275 ret_val = hw->phy.ops.write_reg_locked(hw, PHY_REG(770, 19),
Bruce Allan1d5846b2009-10-29 13:46:05 +00001276 0x0100);
1277 if (ret_val)
1278 goto release;
1279
1280 } else {
1281 /* Link stall fix for link down */
Bruce Allan94d81862009-11-20 23:25:26 +00001282 ret_val = hw->phy.ops.write_reg_locked(hw, PHY_REG(770, 19),
Bruce Allan1d5846b2009-10-29 13:46:05 +00001283 0x4100);
1284 if (ret_val)
1285 goto release;
1286 }
1287
1288 ret_val = e1000_configure_k1_ich8lan(hw, k1_enable);
1289
1290release:
Bruce Allan94d81862009-11-20 23:25:26 +00001291 hw->phy.ops.release(hw);
Bruce Allan5015e532012-02-08 02:55:56 +00001292
Bruce Allan1d5846b2009-10-29 13:46:05 +00001293 return ret_val;
1294}
1295
1296/**
1297 * e1000_configure_k1_ich8lan - Configure K1 power state
1298 * @hw: pointer to the HW structure
1299 * @enable: K1 state to configure
1300 *
1301 * Configure the K1 power state based on the provided parameter.
1302 * Assumes semaphore already acquired.
1303 *
1304 * Success returns 0, Failure returns -E1000_ERR_PHY (-2)
1305 **/
Bruce Allanbb436b22009-11-20 23:24:11 +00001306s32 e1000_configure_k1_ich8lan(struct e1000_hw *hw, bool k1_enable)
Bruce Allan1d5846b2009-10-29 13:46:05 +00001307{
1308 s32 ret_val = 0;
1309 u32 ctrl_reg = 0;
1310 u32 ctrl_ext = 0;
1311 u32 reg = 0;
1312 u16 kmrn_reg = 0;
1313
Bruce Allan3d3a1672012-02-23 03:13:18 +00001314 ret_val = e1000e_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
1315 &kmrn_reg);
Bruce Allan1d5846b2009-10-29 13:46:05 +00001316 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001317 return ret_val;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001318
1319 if (k1_enable)
1320 kmrn_reg |= E1000_KMRNCTRLSTA_K1_ENABLE;
1321 else
1322 kmrn_reg &= ~E1000_KMRNCTRLSTA_K1_ENABLE;
1323
Bruce Allan3d3a1672012-02-23 03:13:18 +00001324 ret_val = e1000e_write_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
1325 kmrn_reg);
Bruce Allan1d5846b2009-10-29 13:46:05 +00001326 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001327 return ret_val;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001328
1329 udelay(20);
1330 ctrl_ext = er32(CTRL_EXT);
1331 ctrl_reg = er32(CTRL);
1332
1333 reg = ctrl_reg & ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100);
1334 reg |= E1000_CTRL_FRCSPD;
1335 ew32(CTRL, reg);
1336
1337 ew32(CTRL_EXT, ctrl_ext | E1000_CTRL_EXT_SPD_BYPS);
Jesse Brandeburg945a5152011-07-20 00:56:21 +00001338 e1e_flush();
Bruce Allan1d5846b2009-10-29 13:46:05 +00001339 udelay(20);
1340 ew32(CTRL, ctrl_reg);
1341 ew32(CTRL_EXT, ctrl_ext);
Jesse Brandeburg945a5152011-07-20 00:56:21 +00001342 e1e_flush();
Bruce Allan1d5846b2009-10-29 13:46:05 +00001343 udelay(20);
1344
Bruce Allan5015e532012-02-08 02:55:56 +00001345 return 0;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001346}
1347
1348/**
Bruce Allanf523d212009-10-29 13:45:45 +00001349 * e1000_oem_bits_config_ich8lan - SW-based LCD Configuration
1350 * @hw: pointer to the HW structure
1351 * @d0_state: boolean if entering d0 or d3 device state
1352 *
1353 * SW will configure Gbe Disable and LPLU based on the NVM. The four bits are
1354 * collectively called OEM bits. The OEM Write Enable bit and SW Config bit
1355 * in NVM determines whether HW should configure LPLU and Gbe Disable.
1356 **/
1357static s32 e1000_oem_bits_config_ich8lan(struct e1000_hw *hw, bool d0_state)
1358{
1359 s32 ret_val = 0;
1360 u32 mac_reg;
1361 u16 oem_reg;
1362
Bruce Alland3738bb2010-06-16 13:27:28 +00001363 if ((hw->mac.type != e1000_pch2lan) && (hw->mac.type != e1000_pchlan))
Bruce Allanf523d212009-10-29 13:45:45 +00001364 return ret_val;
1365
Bruce Allan94d81862009-11-20 23:25:26 +00001366 ret_val = hw->phy.ops.acquire(hw);
Bruce Allanf523d212009-10-29 13:45:45 +00001367 if (ret_val)
1368 return ret_val;
1369
Bruce Alland3738bb2010-06-16 13:27:28 +00001370 if (!(hw->mac.type == e1000_pch2lan)) {
1371 mac_reg = er32(EXTCNF_CTRL);
1372 if (mac_reg & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE)
Bruce Allan75ce1532012-02-08 02:54:48 +00001373 goto release;
Bruce Alland3738bb2010-06-16 13:27:28 +00001374 }
Bruce Allanf523d212009-10-29 13:45:45 +00001375
1376 mac_reg = er32(FEXTNVM);
1377 if (!(mac_reg & E1000_FEXTNVM_SW_CONFIG_ICH8M))
Bruce Allan75ce1532012-02-08 02:54:48 +00001378 goto release;
Bruce Allanf523d212009-10-29 13:45:45 +00001379
1380 mac_reg = er32(PHY_CTRL);
1381
Bruce Allan94d81862009-11-20 23:25:26 +00001382 ret_val = hw->phy.ops.read_reg_locked(hw, HV_OEM_BITS, &oem_reg);
Bruce Allanf523d212009-10-29 13:45:45 +00001383 if (ret_val)
Bruce Allan75ce1532012-02-08 02:54:48 +00001384 goto release;
Bruce Allanf523d212009-10-29 13:45:45 +00001385
1386 oem_reg &= ~(HV_OEM_BITS_GBE_DIS | HV_OEM_BITS_LPLU);
1387
1388 if (d0_state) {
1389 if (mac_reg & E1000_PHY_CTRL_GBE_DISABLE)
1390 oem_reg |= HV_OEM_BITS_GBE_DIS;
1391
1392 if (mac_reg & E1000_PHY_CTRL_D0A_LPLU)
1393 oem_reg |= HV_OEM_BITS_LPLU;
1394 } else {
Bruce Allan03299e42011-09-30 08:07:05 +00001395 if (mac_reg & (E1000_PHY_CTRL_GBE_DISABLE |
1396 E1000_PHY_CTRL_NOND0A_GBE_DISABLE))
Bruce Allanf523d212009-10-29 13:45:45 +00001397 oem_reg |= HV_OEM_BITS_GBE_DIS;
1398
Bruce Allan03299e42011-09-30 08:07:05 +00001399 if (mac_reg & (E1000_PHY_CTRL_D0A_LPLU |
1400 E1000_PHY_CTRL_NOND0A_LPLU))
Bruce Allanf523d212009-10-29 13:45:45 +00001401 oem_reg |= HV_OEM_BITS_LPLU;
1402 }
Bruce Allan03299e42011-09-30 08:07:05 +00001403
Bruce Allan92fe1732012-04-12 06:27:03 +00001404 /* Set Restart auto-neg to activate the bits */
1405 if ((d0_state || (hw->mac.type != e1000_pchlan)) &&
1406 !hw->phy.ops.check_reset_block(hw))
1407 oem_reg |= HV_OEM_BITS_RESTART_AN;
1408
Bruce Allan94d81862009-11-20 23:25:26 +00001409 ret_val = hw->phy.ops.write_reg_locked(hw, HV_OEM_BITS, oem_reg);
Bruce Allanf523d212009-10-29 13:45:45 +00001410
Bruce Allan75ce1532012-02-08 02:54:48 +00001411release:
Bruce Allan94d81862009-11-20 23:25:26 +00001412 hw->phy.ops.release(hw);
Bruce Allanf523d212009-10-29 13:45:45 +00001413
1414 return ret_val;
1415}
1416
1417
1418/**
Bruce Allanfddaa1a2010-01-13 01:52:49 +00001419 * e1000_set_mdio_slow_mode_hv - Set slow MDIO access mode
1420 * @hw: pointer to the HW structure
1421 **/
1422static s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw)
1423{
1424 s32 ret_val;
1425 u16 data;
1426
1427 ret_val = e1e_rphy(hw, HV_KMRN_MODE_CTRL, &data);
1428 if (ret_val)
1429 return ret_val;
1430
1431 data |= HV_KMRN_MDIO_SLOW;
1432
1433 ret_val = e1e_wphy(hw, HV_KMRN_MODE_CTRL, data);
1434
1435 return ret_val;
1436}
1437
1438/**
Bruce Allana4f58f52009-06-02 11:29:18 +00001439 * e1000_hv_phy_workarounds_ich8lan - A series of Phy workarounds to be
1440 * done after every PHY reset.
1441 **/
1442static s32 e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw)
1443{
1444 s32 ret_val = 0;
Bruce Allanbaf86c92010-01-13 01:53:08 +00001445 u16 phy_data;
Bruce Allana4f58f52009-06-02 11:29:18 +00001446
1447 if (hw->mac.type != e1000_pchlan)
Bruce Allan5015e532012-02-08 02:55:56 +00001448 return 0;
Bruce Allana4f58f52009-06-02 11:29:18 +00001449
Bruce Allanfddaa1a2010-01-13 01:52:49 +00001450 /* Set MDIO slow mode before any other MDIO access */
1451 if (hw->phy.type == e1000_phy_82577) {
1452 ret_val = e1000_set_mdio_slow_mode_hv(hw);
1453 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001454 return ret_val;
Bruce Allanfddaa1a2010-01-13 01:52:49 +00001455 }
1456
Bruce Allana4f58f52009-06-02 11:29:18 +00001457 if (((hw->phy.type == e1000_phy_82577) &&
1458 ((hw->phy.revision == 1) || (hw->phy.revision == 2))) ||
1459 ((hw->phy.type == e1000_phy_82578) && (hw->phy.revision == 1))) {
1460 /* Disable generation of early preamble */
1461 ret_val = e1e_wphy(hw, PHY_REG(769, 25), 0x4431);
1462 if (ret_val)
1463 return ret_val;
1464
1465 /* Preamble tuning for SSC */
Bruce Allan1d2101a72011-07-22 06:21:56 +00001466 ret_val = e1e_wphy(hw, HV_KMRN_FIFO_CTRLSTA, 0xA204);
Bruce Allana4f58f52009-06-02 11:29:18 +00001467 if (ret_val)
1468 return ret_val;
1469 }
1470
1471 if (hw->phy.type == e1000_phy_82578) {
1472 /*
1473 * Return registers to default by doing a soft reset then
1474 * writing 0x3140 to the control register.
1475 */
1476 if (hw->phy.revision < 2) {
1477 e1000e_phy_sw_reset(hw);
1478 ret_val = e1e_wphy(hw, PHY_CONTROL, 0x3140);
1479 }
1480 }
1481
1482 /* Select page 0 */
Bruce Allan94d81862009-11-20 23:25:26 +00001483 ret_val = hw->phy.ops.acquire(hw);
Bruce Allana4f58f52009-06-02 11:29:18 +00001484 if (ret_val)
1485 return ret_val;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001486
Bruce Allana4f58f52009-06-02 11:29:18 +00001487 hw->phy.addr = 1;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001488 ret_val = e1000e_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT, 0);
Bruce Allanbaf86c92010-01-13 01:53:08 +00001489 hw->phy.ops.release(hw);
Bruce Allan1d5846b2009-10-29 13:46:05 +00001490 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001491 return ret_val;
Bruce Allana4f58f52009-06-02 11:29:18 +00001492
Bruce Allan1d5846b2009-10-29 13:46:05 +00001493 /*
1494 * Configure the K1 Si workaround during phy reset assuming there is
1495 * link so that it disables K1 if link is in 1Gbps.
1496 */
1497 ret_val = e1000_k1_gig_workaround_hv(hw, true);
Bruce Allanbaf86c92010-01-13 01:53:08 +00001498 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001499 return ret_val;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001500
Bruce Allanbaf86c92010-01-13 01:53:08 +00001501 /* Workaround for link disconnects on a busy hub in half duplex */
1502 ret_val = hw->phy.ops.acquire(hw);
1503 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001504 return ret_val;
Bruce Allan3ebfc7c2011-05-13 07:20:14 +00001505 ret_val = hw->phy.ops.read_reg_locked(hw, BM_PORT_GEN_CFG, &phy_data);
Bruce Allanbaf86c92010-01-13 01:53:08 +00001506 if (ret_val)
1507 goto release;
Bruce Allan3ebfc7c2011-05-13 07:20:14 +00001508 ret_val = hw->phy.ops.write_reg_locked(hw, BM_PORT_GEN_CFG,
1509 phy_data & 0x00FF);
Bruce Allanbaf86c92010-01-13 01:53:08 +00001510release:
1511 hw->phy.ops.release(hw);
Bruce Allan5015e532012-02-08 02:55:56 +00001512
Bruce Allana4f58f52009-06-02 11:29:18 +00001513 return ret_val;
1514}
1515
1516/**
Bruce Alland3738bb2010-06-16 13:27:28 +00001517 * e1000_copy_rx_addrs_to_phy_ich8lan - Copy Rx addresses from MAC to PHY
1518 * @hw: pointer to the HW structure
1519 **/
1520void e1000_copy_rx_addrs_to_phy_ich8lan(struct e1000_hw *hw)
1521{
1522 u32 mac_reg;
Bruce Allan2b6b1682011-05-13 07:20:09 +00001523 u16 i, phy_reg = 0;
1524 s32 ret_val;
1525
1526 ret_val = hw->phy.ops.acquire(hw);
1527 if (ret_val)
1528 return;
1529 ret_val = e1000_enable_phy_wakeup_reg_access_bm(hw, &phy_reg);
1530 if (ret_val)
1531 goto release;
Bruce Alland3738bb2010-06-16 13:27:28 +00001532
1533 /* Copy both RAL/H (rar_entry_count) and SHRAL/H (+4) to PHY */
1534 for (i = 0; i < (hw->mac.rar_entry_count + 4); i++) {
1535 mac_reg = er32(RAL(i));
Bruce Allan2b6b1682011-05-13 07:20:09 +00001536 hw->phy.ops.write_reg_page(hw, BM_RAR_L(i),
1537 (u16)(mac_reg & 0xFFFF));
1538 hw->phy.ops.write_reg_page(hw, BM_RAR_M(i),
1539 (u16)((mac_reg >> 16) & 0xFFFF));
1540
Bruce Alland3738bb2010-06-16 13:27:28 +00001541 mac_reg = er32(RAH(i));
Bruce Allan2b6b1682011-05-13 07:20:09 +00001542 hw->phy.ops.write_reg_page(hw, BM_RAR_H(i),
1543 (u16)(mac_reg & 0xFFFF));
1544 hw->phy.ops.write_reg_page(hw, BM_RAR_CTRL(i),
1545 (u16)((mac_reg & E1000_RAH_AV)
1546 >> 16));
Bruce Alland3738bb2010-06-16 13:27:28 +00001547 }
Bruce Allan2b6b1682011-05-13 07:20:09 +00001548
1549 e1000_disable_phy_wakeup_reg_access_bm(hw, &phy_reg);
1550
1551release:
1552 hw->phy.ops.release(hw);
Bruce Alland3738bb2010-06-16 13:27:28 +00001553}
1554
Bruce Alland3738bb2010-06-16 13:27:28 +00001555/**
1556 * e1000_lv_jumbo_workaround_ich8lan - required for jumbo frame operation
1557 * with 82579 PHY
1558 * @hw: pointer to the HW structure
1559 * @enable: flag to enable/disable workaround when enabling/disabling jumbos
1560 **/
1561s32 e1000_lv_jumbo_workaround_ich8lan(struct e1000_hw *hw, bool enable)
1562{
1563 s32 ret_val = 0;
1564 u16 phy_reg, data;
1565 u32 mac_reg;
1566 u16 i;
1567
1568 if (hw->mac.type != e1000_pch2lan)
Bruce Allan5015e532012-02-08 02:55:56 +00001569 return 0;
Bruce Alland3738bb2010-06-16 13:27:28 +00001570
1571 /* disable Rx path while enabling/disabling workaround */
1572 e1e_rphy(hw, PHY_REG(769, 20), &phy_reg);
1573 ret_val = e1e_wphy(hw, PHY_REG(769, 20), phy_reg | (1 << 14));
1574 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001575 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001576
1577 if (enable) {
1578 /*
1579 * Write Rx addresses (rar_entry_count for RAL/H, +4 for
1580 * SHRAL/H) and initial CRC values to the MAC
1581 */
1582 for (i = 0; i < (hw->mac.rar_entry_count + 4); i++) {
1583 u8 mac_addr[ETH_ALEN] = {0};
1584 u32 addr_high, addr_low;
1585
1586 addr_high = er32(RAH(i));
1587 if (!(addr_high & E1000_RAH_AV))
1588 continue;
1589 addr_low = er32(RAL(i));
1590 mac_addr[0] = (addr_low & 0xFF);
1591 mac_addr[1] = ((addr_low >> 8) & 0xFF);
1592 mac_addr[2] = ((addr_low >> 16) & 0xFF);
1593 mac_addr[3] = ((addr_low >> 24) & 0xFF);
1594 mac_addr[4] = (addr_high & 0xFF);
1595 mac_addr[5] = ((addr_high >> 8) & 0xFF);
1596
Bruce Allanfe46f582011-01-06 14:29:51 +00001597 ew32(PCH_RAICC(i), ~ether_crc_le(ETH_ALEN, mac_addr));
Bruce Alland3738bb2010-06-16 13:27:28 +00001598 }
1599
1600 /* Write Rx addresses to the PHY */
1601 e1000_copy_rx_addrs_to_phy_ich8lan(hw);
1602
1603 /* Enable jumbo frame workaround in the MAC */
1604 mac_reg = er32(FFLT_DBG);
1605 mac_reg &= ~(1 << 14);
1606 mac_reg |= (7 << 15);
1607 ew32(FFLT_DBG, mac_reg);
1608
1609 mac_reg = er32(RCTL);
1610 mac_reg |= E1000_RCTL_SECRC;
1611 ew32(RCTL, mac_reg);
1612
1613 ret_val = e1000e_read_kmrn_reg(hw,
1614 E1000_KMRNCTRLSTA_CTRL_OFFSET,
1615 &data);
1616 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001617 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001618 ret_val = e1000e_write_kmrn_reg(hw,
1619 E1000_KMRNCTRLSTA_CTRL_OFFSET,
1620 data | (1 << 0));
1621 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001622 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001623 ret_val = e1000e_read_kmrn_reg(hw,
1624 E1000_KMRNCTRLSTA_HD_CTRL,
1625 &data);
1626 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001627 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001628 data &= ~(0xF << 8);
1629 data |= (0xB << 8);
1630 ret_val = e1000e_write_kmrn_reg(hw,
1631 E1000_KMRNCTRLSTA_HD_CTRL,
1632 data);
1633 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001634 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001635
1636 /* Enable jumbo frame workaround in the PHY */
Bruce Alland3738bb2010-06-16 13:27:28 +00001637 e1e_rphy(hw, PHY_REG(769, 23), &data);
1638 data &= ~(0x7F << 5);
1639 data |= (0x37 << 5);
1640 ret_val = e1e_wphy(hw, PHY_REG(769, 23), data);
1641 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001642 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001643 e1e_rphy(hw, PHY_REG(769, 16), &data);
1644 data &= ~(1 << 13);
Bruce Alland3738bb2010-06-16 13:27:28 +00001645 ret_val = e1e_wphy(hw, PHY_REG(769, 16), data);
1646 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001647 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001648 e1e_rphy(hw, PHY_REG(776, 20), &data);
1649 data &= ~(0x3FF << 2);
1650 data |= (0x1A << 2);
1651 ret_val = e1e_wphy(hw, PHY_REG(776, 20), data);
1652 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001653 return ret_val;
Bruce Allanb64e9dd2011-09-30 08:07:00 +00001654 ret_val = e1e_wphy(hw, PHY_REG(776, 23), 0xF100);
Bruce Alland3738bb2010-06-16 13:27:28 +00001655 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001656 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001657 e1e_rphy(hw, HV_PM_CTRL, &data);
1658 ret_val = e1e_wphy(hw, HV_PM_CTRL, data | (1 << 10));
1659 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001660 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001661 } else {
1662 /* Write MAC register values back to h/w defaults */
1663 mac_reg = er32(FFLT_DBG);
1664 mac_reg &= ~(0xF << 14);
1665 ew32(FFLT_DBG, mac_reg);
1666
1667 mac_reg = er32(RCTL);
1668 mac_reg &= ~E1000_RCTL_SECRC;
Bruce Allana1ce6472010-09-22 17:16:40 +00001669 ew32(RCTL, mac_reg);
Bruce Alland3738bb2010-06-16 13:27:28 +00001670
1671 ret_val = e1000e_read_kmrn_reg(hw,
1672 E1000_KMRNCTRLSTA_CTRL_OFFSET,
1673 &data);
1674 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001675 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001676 ret_val = e1000e_write_kmrn_reg(hw,
1677 E1000_KMRNCTRLSTA_CTRL_OFFSET,
1678 data & ~(1 << 0));
1679 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001680 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001681 ret_val = e1000e_read_kmrn_reg(hw,
1682 E1000_KMRNCTRLSTA_HD_CTRL,
1683 &data);
1684 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001685 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001686 data &= ~(0xF << 8);
1687 data |= (0xB << 8);
1688 ret_val = e1000e_write_kmrn_reg(hw,
1689 E1000_KMRNCTRLSTA_HD_CTRL,
1690 data);
1691 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001692 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001693
1694 /* Write PHY register values back to h/w defaults */
Bruce Alland3738bb2010-06-16 13:27:28 +00001695 e1e_rphy(hw, PHY_REG(769, 23), &data);
1696 data &= ~(0x7F << 5);
1697 ret_val = e1e_wphy(hw, PHY_REG(769, 23), data);
1698 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001699 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001700 e1e_rphy(hw, PHY_REG(769, 16), &data);
Bruce Alland3738bb2010-06-16 13:27:28 +00001701 data |= (1 << 13);
1702 ret_val = e1e_wphy(hw, PHY_REG(769, 16), data);
1703 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001704 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001705 e1e_rphy(hw, PHY_REG(776, 20), &data);
1706 data &= ~(0x3FF << 2);
1707 data |= (0x8 << 2);
1708 ret_val = e1e_wphy(hw, PHY_REG(776, 20), data);
1709 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001710 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001711 ret_val = e1e_wphy(hw, PHY_REG(776, 23), 0x7E00);
1712 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001713 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001714 e1e_rphy(hw, HV_PM_CTRL, &data);
1715 ret_val = e1e_wphy(hw, HV_PM_CTRL, data & ~(1 << 10));
1716 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001717 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001718 }
1719
1720 /* re-enable Rx path after enabling/disabling workaround */
Bruce Allan5015e532012-02-08 02:55:56 +00001721 return e1e_wphy(hw, PHY_REG(769, 20), phy_reg & ~(1 << 14));
Bruce Alland3738bb2010-06-16 13:27:28 +00001722}
1723
1724/**
1725 * e1000_lv_phy_workarounds_ich8lan - A series of Phy workarounds to be
1726 * done after every PHY reset.
1727 **/
1728static s32 e1000_lv_phy_workarounds_ich8lan(struct e1000_hw *hw)
1729{
1730 s32 ret_val = 0;
1731
1732 if (hw->mac.type != e1000_pch2lan)
Bruce Allan5015e532012-02-08 02:55:56 +00001733 return 0;
Bruce Alland3738bb2010-06-16 13:27:28 +00001734
1735 /* Set MDIO slow mode before any other MDIO access */
1736 ret_val = e1000_set_mdio_slow_mode_hv(hw);
1737
Bruce Allan4d241362011-12-16 00:46:06 +00001738 ret_val = hw->phy.ops.acquire(hw);
1739 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001740 return ret_val;
Bruce Allan4d241362011-12-16 00:46:06 +00001741 ret_val = hw->phy.ops.write_reg_locked(hw, I82579_EMI_ADDR,
1742 I82579_MSE_THRESHOLD);
1743 if (ret_val)
1744 goto release;
1745 /* set MSE higher to enable link to stay up when noise is high */
1746 ret_val = hw->phy.ops.write_reg_locked(hw, I82579_EMI_DATA, 0x0034);
1747 if (ret_val)
1748 goto release;
1749 ret_val = hw->phy.ops.write_reg_locked(hw, I82579_EMI_ADDR,
1750 I82579_MSE_LINK_DOWN);
1751 if (ret_val)
1752 goto release;
1753 /* drop link after 5 times MSE threshold was reached */
1754 ret_val = hw->phy.ops.write_reg_locked(hw, I82579_EMI_DATA, 0x0005);
1755release:
1756 hw->phy.ops.release(hw);
1757
Bruce Alland3738bb2010-06-16 13:27:28 +00001758 return ret_val;
1759}
1760
1761/**
Bruce Allan831bd2e2010-09-22 17:16:18 +00001762 * e1000_k1_gig_workaround_lv - K1 Si workaround
1763 * @hw: pointer to the HW structure
1764 *
1765 * Workaround to set the K1 beacon duration for 82579 parts
1766 **/
1767static s32 e1000_k1_workaround_lv(struct e1000_hw *hw)
1768{
1769 s32 ret_val = 0;
1770 u16 status_reg = 0;
1771 u32 mac_reg;
Bruce Allan0ed013e2011-07-29 05:52:56 +00001772 u16 phy_reg;
Bruce Allan831bd2e2010-09-22 17:16:18 +00001773
1774 if (hw->mac.type != e1000_pch2lan)
Bruce Allan5015e532012-02-08 02:55:56 +00001775 return 0;
Bruce Allan831bd2e2010-09-22 17:16:18 +00001776
1777 /* Set K1 beacon duration based on 1Gbps speed or otherwise */
1778 ret_val = e1e_rphy(hw, HV_M_STATUS, &status_reg);
1779 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001780 return ret_val;
Bruce Allan831bd2e2010-09-22 17:16:18 +00001781
1782 if ((status_reg & (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE))
1783 == (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE)) {
1784 mac_reg = er32(FEXTNVM4);
1785 mac_reg &= ~E1000_FEXTNVM4_BEACON_DURATION_MASK;
1786
Bruce Allan0ed013e2011-07-29 05:52:56 +00001787 ret_val = e1e_rphy(hw, I82579_LPI_CTRL, &phy_reg);
1788 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001789 return ret_val;
Bruce Allan831bd2e2010-09-22 17:16:18 +00001790
Bruce Allan0ed013e2011-07-29 05:52:56 +00001791 if (status_reg & HV_M_STATUS_SPEED_1000) {
Bruce Allan36ceeb42012-03-20 03:47:47 +00001792 u16 pm_phy_reg;
1793
Bruce Allan0ed013e2011-07-29 05:52:56 +00001794 mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_8USEC;
1795 phy_reg &= ~I82579_LPI_CTRL_FORCE_PLL_LOCK_COUNT;
Bruce Allan36ceeb42012-03-20 03:47:47 +00001796 /* LV 1G Packet drop issue wa */
1797 ret_val = e1e_rphy(hw, HV_PM_CTRL, &pm_phy_reg);
1798 if (ret_val)
1799 return ret_val;
1800 pm_phy_reg &= ~HV_PM_CTRL_PLL_STOP_IN_K1_GIGA;
1801 ret_val = e1e_wphy(hw, HV_PM_CTRL, pm_phy_reg);
1802 if (ret_val)
1803 return ret_val;
Bruce Allan0ed013e2011-07-29 05:52:56 +00001804 } else {
1805 mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_16USEC;
1806 phy_reg |= I82579_LPI_CTRL_FORCE_PLL_LOCK_COUNT;
1807 }
Bruce Allan831bd2e2010-09-22 17:16:18 +00001808 ew32(FEXTNVM4, mac_reg);
Bruce Allan0ed013e2011-07-29 05:52:56 +00001809 ret_val = e1e_wphy(hw, I82579_LPI_CTRL, phy_reg);
Bruce Allan831bd2e2010-09-22 17:16:18 +00001810 }
1811
Bruce Allan831bd2e2010-09-22 17:16:18 +00001812 return ret_val;
1813}
1814
1815/**
Bruce Allan605c82b2010-09-22 17:17:01 +00001816 * e1000_gate_hw_phy_config_ich8lan - disable PHY config via hardware
1817 * @hw: pointer to the HW structure
1818 * @gate: boolean set to true to gate, false to ungate
1819 *
1820 * Gate/ungate the automatic PHY configuration via hardware; perform
1821 * the configuration via software instead.
1822 **/
1823static void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate)
1824{
1825 u32 extcnf_ctrl;
1826
1827 if (hw->mac.type != e1000_pch2lan)
1828 return;
1829
1830 extcnf_ctrl = er32(EXTCNF_CTRL);
1831
1832 if (gate)
1833 extcnf_ctrl |= E1000_EXTCNF_CTRL_GATE_PHY_CFG;
1834 else
1835 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_GATE_PHY_CFG;
1836
1837 ew32(EXTCNF_CTRL, extcnf_ctrl);
Bruce Allan605c82b2010-09-22 17:17:01 +00001838}
1839
1840/**
Bruce Allanfc0c7762009-07-01 13:27:55 +00001841 * e1000_lan_init_done_ich8lan - Check for PHY config completion
1842 * @hw: pointer to the HW structure
1843 *
1844 * Check the appropriate indication the MAC has finished configuring the
1845 * PHY after a software reset.
1846 **/
1847static void e1000_lan_init_done_ich8lan(struct e1000_hw *hw)
1848{
1849 u32 data, loop = E1000_ICH8_LAN_INIT_TIMEOUT;
1850
1851 /* Wait for basic configuration completes before proceeding */
1852 do {
1853 data = er32(STATUS);
1854 data &= E1000_STATUS_LAN_INIT_DONE;
1855 udelay(100);
1856 } while ((!data) && --loop);
1857
1858 /*
1859 * If basic configuration is incomplete before the above loop
1860 * count reaches 0, loading the configuration from NVM will
1861 * leave the PHY in a bad state possibly resulting in no link.
1862 */
1863 if (loop == 0)
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001864 e_dbg("LAN_INIT_DONE not set, increase timeout\n");
Bruce Allanfc0c7762009-07-01 13:27:55 +00001865
1866 /* Clear the Init Done bit for the next init event */
1867 data = er32(STATUS);
1868 data &= ~E1000_STATUS_LAN_INIT_DONE;
1869 ew32(STATUS, data);
1870}
1871
1872/**
Bruce Allane98cac42010-05-10 15:02:32 +00001873 * e1000_post_phy_reset_ich8lan - Perform steps required after a PHY reset
Auke Kokbc7f75f2007-09-17 12:30:59 -07001874 * @hw: pointer to the HW structure
Auke Kokbc7f75f2007-09-17 12:30:59 -07001875 **/
Bruce Allane98cac42010-05-10 15:02:32 +00001876static s32 e1000_post_phy_reset_ich8lan(struct e1000_hw *hw)
Auke Kokbc7f75f2007-09-17 12:30:59 -07001877{
Bruce Allanf523d212009-10-29 13:45:45 +00001878 s32 ret_val = 0;
1879 u16 reg;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001880
Bruce Allan44abd5c2012-02-22 09:02:37 +00001881 if (hw->phy.ops.check_reset_block(hw))
Bruce Allan5015e532012-02-08 02:55:56 +00001882 return 0;
Bruce Allanfc0c7762009-07-01 13:27:55 +00001883
Bruce Allan5f3eed62010-09-22 17:15:54 +00001884 /* Allow time for h/w to get to quiescent state after reset */
Bruce Allan1bba4382011-03-19 00:27:20 +00001885 usleep_range(10000, 20000);
Bruce Allan5f3eed62010-09-22 17:15:54 +00001886
Bruce Allanfddaa1a2010-01-13 01:52:49 +00001887 /* Perform any necessary post-reset workarounds */
Bruce Allane98cac42010-05-10 15:02:32 +00001888 switch (hw->mac.type) {
1889 case e1000_pchlan:
Bruce Allana4f58f52009-06-02 11:29:18 +00001890 ret_val = e1000_hv_phy_workarounds_ich8lan(hw);
1891 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001892 return ret_val;
Bruce Allane98cac42010-05-10 15:02:32 +00001893 break;
Bruce Alland3738bb2010-06-16 13:27:28 +00001894 case e1000_pch2lan:
1895 ret_val = e1000_lv_phy_workarounds_ich8lan(hw);
1896 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001897 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001898 break;
Bruce Allane98cac42010-05-10 15:02:32 +00001899 default:
1900 break;
Bruce Allana4f58f52009-06-02 11:29:18 +00001901 }
1902
Bruce Allan3ebfc7c2011-05-13 07:20:14 +00001903 /* Clear the host wakeup bit after lcd reset */
1904 if (hw->mac.type >= e1000_pchlan) {
1905 e1e_rphy(hw, BM_PORT_GEN_CFG, &reg);
1906 reg &= ~BM_WUC_HOST_WU_BIT;
1907 e1e_wphy(hw, BM_PORT_GEN_CFG, reg);
1908 }
Bruce Allandb2932e2009-10-26 11:22:47 +00001909
Bruce Allanf523d212009-10-29 13:45:45 +00001910 /* Configure the LCD with the extended configuration region in NVM */
1911 ret_val = e1000_sw_lcd_config_ich8lan(hw);
1912 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001913 return ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001914
Bruce Allanf523d212009-10-29 13:45:45 +00001915 /* Configure the LCD with the OEM bits in NVM */
Bruce Allane98cac42010-05-10 15:02:32 +00001916 ret_val = e1000_oem_bits_config_ich8lan(hw, true);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001917
Bruce Allan1effb452011-02-25 06:58:03 +00001918 if (hw->mac.type == e1000_pch2lan) {
1919 /* Ungate automatic PHY configuration on non-managed 82579 */
1920 if (!(er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) {
Bruce Allan1bba4382011-03-19 00:27:20 +00001921 usleep_range(10000, 20000);
Bruce Allan1effb452011-02-25 06:58:03 +00001922 e1000_gate_hw_phy_config_ich8lan(hw, false);
1923 }
1924
1925 /* Set EEE LPI Update Timer to 200usec */
1926 ret_val = hw->phy.ops.acquire(hw);
1927 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001928 return ret_val;
Bruce Allan1effb452011-02-25 06:58:03 +00001929 ret_val = hw->phy.ops.write_reg_locked(hw, I82579_EMI_ADDR,
1930 I82579_LPI_UPDATE_TIMER);
Bruce Allan5015e532012-02-08 02:55:56 +00001931 if (!ret_val)
1932 ret_val = hw->phy.ops.write_reg_locked(hw,
1933 I82579_EMI_DATA,
1934 0x1387);
Bruce Allan1effb452011-02-25 06:58:03 +00001935 hw->phy.ops.release(hw);
Bruce Allan605c82b2010-09-22 17:17:01 +00001936 }
1937
Bruce Allane98cac42010-05-10 15:02:32 +00001938 return ret_val;
1939}
1940
1941/**
1942 * e1000_phy_hw_reset_ich8lan - Performs a PHY reset
1943 * @hw: pointer to the HW structure
1944 *
1945 * Resets the PHY
1946 * This is a function pointer entry point called by drivers
1947 * or other shared routines.
1948 **/
1949static s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw)
1950{
1951 s32 ret_val = 0;
1952
Bruce Allan605c82b2010-09-22 17:17:01 +00001953 /* Gate automatic PHY configuration by hardware on non-managed 82579 */
1954 if ((hw->mac.type == e1000_pch2lan) &&
1955 !(er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
1956 e1000_gate_hw_phy_config_ich8lan(hw, true);
1957
Bruce Allane98cac42010-05-10 15:02:32 +00001958 ret_val = e1000e_phy_hw_reset_generic(hw);
1959 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001960 return ret_val;
Bruce Allane98cac42010-05-10 15:02:32 +00001961
Bruce Allan5015e532012-02-08 02:55:56 +00001962 return e1000_post_phy_reset_ich8lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001963}
1964
1965/**
Bruce Allanfa2ce132009-10-26 11:23:25 +00001966 * e1000_set_lplu_state_pchlan - Set Low Power Link Up state
1967 * @hw: pointer to the HW structure
1968 * @active: true to enable LPLU, false to disable
1969 *
1970 * Sets the LPLU state according to the active flag. For PCH, if OEM write
1971 * bit are disabled in the NVM, writing the LPLU bits in the MAC will not set
1972 * the phy speed. This function will manually set the LPLU bit and restart
1973 * auto-neg as hw would do. D3 and D0 LPLU will call the same function
1974 * since it configures the same bit.
1975 **/
1976static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active)
1977{
1978 s32 ret_val = 0;
1979 u16 oem_reg;
1980
1981 ret_val = e1e_rphy(hw, HV_OEM_BITS, &oem_reg);
1982 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001983 return ret_val;
Bruce Allanfa2ce132009-10-26 11:23:25 +00001984
1985 if (active)
1986 oem_reg |= HV_OEM_BITS_LPLU;
1987 else
1988 oem_reg &= ~HV_OEM_BITS_LPLU;
1989
Bruce Allan44abd5c2012-02-22 09:02:37 +00001990 if (!hw->phy.ops.check_reset_block(hw))
Bruce Allan464c85e2011-12-16 00:46:49 +00001991 oem_reg |= HV_OEM_BITS_RESTART_AN;
1992
Bruce Allan5015e532012-02-08 02:55:56 +00001993 return e1e_wphy(hw, HV_OEM_BITS, oem_reg);
Bruce Allanfa2ce132009-10-26 11:23:25 +00001994}
1995
1996/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07001997 * e1000_set_d0_lplu_state_ich8lan - Set Low Power Linkup D0 state
1998 * @hw: pointer to the HW structure
Bruce Allan564ea9b2009-11-20 23:26:44 +00001999 * @active: true to enable LPLU, false to disable
Auke Kokbc7f75f2007-09-17 12:30:59 -07002000 *
2001 * Sets the LPLU D0 state according to the active flag. When
2002 * activating LPLU this function also disables smart speed
2003 * and vice versa. LPLU will not be activated unless the
2004 * device autonegotiation advertisement meets standards of
2005 * either 10 or 10/100 or 10/100/1000 at all duplexes.
2006 * This is a function pointer entry point only called by
2007 * PHY setup routines.
2008 **/
2009static s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
2010{
2011 struct e1000_phy_info *phy = &hw->phy;
2012 u32 phy_ctrl;
2013 s32 ret_val = 0;
2014 u16 data;
2015
Bruce Allan97ac8ca2008-04-29 09:16:05 -07002016 if (phy->type == e1000_phy_ife)
Bruce Allan82607252012-02-08 02:55:09 +00002017 return 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002018
2019 phy_ctrl = er32(PHY_CTRL);
2020
2021 if (active) {
2022 phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU;
2023 ew32(PHY_CTRL, phy_ctrl);
2024
Bruce Allan60f12922009-07-01 13:28:14 +00002025 if (phy->type != e1000_phy_igp_3)
2026 return 0;
2027
Bruce Allanad680762008-03-28 09:15:03 -07002028 /*
2029 * Call gig speed drop workaround on LPLU before accessing
2030 * any PHY registers
2031 */
Bruce Allan60f12922009-07-01 13:28:14 +00002032 if (hw->mac.type == e1000_ich8lan)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002033 e1000e_gig_downshift_workaround_ich8lan(hw);
2034
2035 /* When LPLU is enabled, we should disable SmartSpeed */
2036 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data);
2037 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
2038 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);
2039 if (ret_val)
2040 return ret_val;
2041 } else {
2042 phy_ctrl &= ~E1000_PHY_CTRL_D0A_LPLU;
2043 ew32(PHY_CTRL, phy_ctrl);
2044
Bruce Allan60f12922009-07-01 13:28:14 +00002045 if (phy->type != e1000_phy_igp_3)
2046 return 0;
2047
Bruce Allanad680762008-03-28 09:15:03 -07002048 /*
2049 * LPLU and SmartSpeed are mutually exclusive. LPLU is used
Auke Kokbc7f75f2007-09-17 12:30:59 -07002050 * during Dx states where the power conservation is most
2051 * important. During driver activity we should enable
Bruce Allanad680762008-03-28 09:15:03 -07002052 * SmartSpeed, so performance is maintained.
2053 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002054 if (phy->smart_speed == e1000_smart_speed_on) {
2055 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
Bruce Allanad680762008-03-28 09:15:03 -07002056 &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002057 if (ret_val)
2058 return ret_val;
2059
2060 data |= IGP01E1000_PSCFR_SMART_SPEED;
2061 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
Bruce Allanad680762008-03-28 09:15:03 -07002062 data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002063 if (ret_val)
2064 return ret_val;
2065 } else if (phy->smart_speed == e1000_smart_speed_off) {
2066 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
Bruce Allanad680762008-03-28 09:15:03 -07002067 &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002068 if (ret_val)
2069 return ret_val;
2070
2071 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
2072 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
Bruce Allanad680762008-03-28 09:15:03 -07002073 data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002074 if (ret_val)
2075 return ret_val;
2076 }
2077 }
2078
2079 return 0;
2080}
2081
2082/**
2083 * e1000_set_d3_lplu_state_ich8lan - Set Low Power Linkup D3 state
2084 * @hw: pointer to the HW structure
Bruce Allan564ea9b2009-11-20 23:26:44 +00002085 * @active: true to enable LPLU, false to disable
Auke Kokbc7f75f2007-09-17 12:30:59 -07002086 *
2087 * Sets the LPLU D3 state according to the active flag. When
2088 * activating LPLU this function also disables smart speed
2089 * and vice versa. LPLU will not be activated unless the
2090 * device autonegotiation advertisement meets standards of
2091 * either 10 or 10/100 or 10/100/1000 at all duplexes.
2092 * This is a function pointer entry point only called by
2093 * PHY setup routines.
2094 **/
2095static s32 e1000_set_d3_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
2096{
2097 struct e1000_phy_info *phy = &hw->phy;
2098 u32 phy_ctrl;
Bruce Alland7eb3382012-02-08 02:55:14 +00002099 s32 ret_val = 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002100 u16 data;
2101
2102 phy_ctrl = er32(PHY_CTRL);
2103
2104 if (!active) {
2105 phy_ctrl &= ~E1000_PHY_CTRL_NOND0A_LPLU;
2106 ew32(PHY_CTRL, phy_ctrl);
Bruce Allan60f12922009-07-01 13:28:14 +00002107
2108 if (phy->type != e1000_phy_igp_3)
2109 return 0;
2110
Bruce Allanad680762008-03-28 09:15:03 -07002111 /*
2112 * LPLU and SmartSpeed are mutually exclusive. LPLU is used
Auke Kokbc7f75f2007-09-17 12:30:59 -07002113 * during Dx states where the power conservation is most
2114 * important. During driver activity we should enable
Bruce Allanad680762008-03-28 09:15:03 -07002115 * SmartSpeed, so performance is maintained.
2116 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002117 if (phy->smart_speed == e1000_smart_speed_on) {
Bruce Allanad680762008-03-28 09:15:03 -07002118 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
2119 &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002120 if (ret_val)
2121 return ret_val;
2122
2123 data |= IGP01E1000_PSCFR_SMART_SPEED;
Bruce Allanad680762008-03-28 09:15:03 -07002124 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
2125 data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002126 if (ret_val)
2127 return ret_val;
2128 } else if (phy->smart_speed == e1000_smart_speed_off) {
Bruce Allanad680762008-03-28 09:15:03 -07002129 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
2130 &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002131 if (ret_val)
2132 return ret_val;
2133
2134 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
Bruce Allanad680762008-03-28 09:15:03 -07002135 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
2136 data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002137 if (ret_val)
2138 return ret_val;
2139 }
2140 } else if ((phy->autoneg_advertised == E1000_ALL_SPEED_DUPLEX) ||
2141 (phy->autoneg_advertised == E1000_ALL_NOT_GIG) ||
2142 (phy->autoneg_advertised == E1000_ALL_10_SPEED)) {
2143 phy_ctrl |= E1000_PHY_CTRL_NOND0A_LPLU;
2144 ew32(PHY_CTRL, phy_ctrl);
2145
Bruce Allan60f12922009-07-01 13:28:14 +00002146 if (phy->type != e1000_phy_igp_3)
2147 return 0;
2148
Bruce Allanad680762008-03-28 09:15:03 -07002149 /*
2150 * Call gig speed drop workaround on LPLU before accessing
2151 * any PHY registers
2152 */
Bruce Allan60f12922009-07-01 13:28:14 +00002153 if (hw->mac.type == e1000_ich8lan)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002154 e1000e_gig_downshift_workaround_ich8lan(hw);
2155
2156 /* When LPLU is enabled, we should disable SmartSpeed */
Bruce Allanad680762008-03-28 09:15:03 -07002157 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002158 if (ret_val)
2159 return ret_val;
2160
2161 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
Bruce Allanad680762008-03-28 09:15:03 -07002162 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002163 }
2164
Bruce Alland7eb3382012-02-08 02:55:14 +00002165 return ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002166}
2167
2168/**
Bruce Allanf4187b52008-08-26 18:36:50 -07002169 * e1000_valid_nvm_bank_detect_ich8lan - finds out the valid bank 0 or 1
2170 * @hw: pointer to the HW structure
2171 * @bank: pointer to the variable that returns the active bank
2172 *
2173 * Reads signature byte from the NVM using the flash access registers.
Bruce Allane2434552008-11-21 17:02:41 -08002174 * Word 0x13 bits 15:14 = 10b indicate a valid signature for that bank.
Bruce Allanf4187b52008-08-26 18:36:50 -07002175 **/
2176static s32 e1000_valid_nvm_bank_detect_ich8lan(struct e1000_hw *hw, u32 *bank)
2177{
Bruce Allane2434552008-11-21 17:02:41 -08002178 u32 eecd;
Bruce Allanf4187b52008-08-26 18:36:50 -07002179 struct e1000_nvm_info *nvm = &hw->nvm;
Bruce Allanf4187b52008-08-26 18:36:50 -07002180 u32 bank1_offset = nvm->flash_bank_size * sizeof(u16);
2181 u32 act_offset = E1000_ICH_NVM_SIG_WORD * 2 + 1;
Bruce Allane2434552008-11-21 17:02:41 -08002182 u8 sig_byte = 0;
Bruce Allanf71dde62012-02-08 02:55:35 +00002183 s32 ret_val;
Bruce Allanf4187b52008-08-26 18:36:50 -07002184
Bruce Allane2434552008-11-21 17:02:41 -08002185 switch (hw->mac.type) {
2186 case e1000_ich8lan:
2187 case e1000_ich9lan:
2188 eecd = er32(EECD);
2189 if ((eecd & E1000_EECD_SEC1VAL_VALID_MASK) ==
2190 E1000_EECD_SEC1VAL_VALID_MASK) {
2191 if (eecd & E1000_EECD_SEC1VAL)
Bruce Allanf4187b52008-08-26 18:36:50 -07002192 *bank = 1;
Bruce Allane2434552008-11-21 17:02:41 -08002193 else
2194 *bank = 0;
2195
2196 return 0;
Bruce Allanf4187b52008-08-26 18:36:50 -07002197 }
Bruce Allan434f1392011-12-16 00:46:54 +00002198 e_dbg("Unable to determine valid NVM bank via EEC - reading flash signature\n");
Bruce Allane2434552008-11-21 17:02:41 -08002199 /* fall-thru */
2200 default:
2201 /* set bank to 0 in case flash read fails */
2202 *bank = 0;
2203
2204 /* Check bank 0 */
2205 ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset,
2206 &sig_byte);
2207 if (ret_val)
2208 return ret_val;
2209 if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
2210 E1000_ICH_NVM_SIG_VALUE) {
2211 *bank = 0;
2212 return 0;
2213 }
2214
2215 /* Check bank 1 */
2216 ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset +
2217 bank1_offset,
2218 &sig_byte);
2219 if (ret_val)
2220 return ret_val;
2221 if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
2222 E1000_ICH_NVM_SIG_VALUE) {
2223 *bank = 1;
2224 return 0;
2225 }
2226
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002227 e_dbg("ERROR: No valid NVM bank present\n");
Bruce Allane2434552008-11-21 17:02:41 -08002228 return -E1000_ERR_NVM;
Bruce Allanf4187b52008-08-26 18:36:50 -07002229 }
Bruce Allanf4187b52008-08-26 18:36:50 -07002230}
2231
2232/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07002233 * e1000_read_nvm_ich8lan - Read word(s) from the NVM
2234 * @hw: pointer to the HW structure
2235 * @offset: The offset (in bytes) of the word(s) to read.
2236 * @words: Size of data to read in words
2237 * @data: Pointer to the word(s) to read at offset.
2238 *
2239 * Reads a word(s) from the NVM using the flash access registers.
2240 **/
2241static s32 e1000_read_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
2242 u16 *data)
2243{
2244 struct e1000_nvm_info *nvm = &hw->nvm;
2245 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
2246 u32 act_offset;
Bruce Allan148675a2009-08-07 07:41:56 +00002247 s32 ret_val = 0;
Bruce Allanf4187b52008-08-26 18:36:50 -07002248 u32 bank = 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002249 u16 i, word;
2250
2251 if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
2252 (words == 0)) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002253 e_dbg("nvm parameter(s) out of bounds\n");
Bruce Allanca15df52009-10-26 11:23:43 +00002254 ret_val = -E1000_ERR_NVM;
2255 goto out;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002256 }
2257
Bruce Allan94d81862009-11-20 23:25:26 +00002258 nvm->ops.acquire(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002259
Bruce Allanf4187b52008-08-26 18:36:50 -07002260 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
Bruce Allan148675a2009-08-07 07:41:56 +00002261 if (ret_val) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002262 e_dbg("Could not detect valid bank, assuming bank 0\n");
Bruce Allan148675a2009-08-07 07:41:56 +00002263 bank = 0;
2264 }
Bruce Allanf4187b52008-08-26 18:36:50 -07002265
2266 act_offset = (bank) ? nvm->flash_bank_size : 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002267 act_offset += offset;
2268
Bruce Allan148675a2009-08-07 07:41:56 +00002269 ret_val = 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002270 for (i = 0; i < words; i++) {
Bruce Allanb9e06f72011-07-22 06:21:41 +00002271 if (dev_spec->shadow_ram[offset+i].modified) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07002272 data[i] = dev_spec->shadow_ram[offset+i].value;
2273 } else {
2274 ret_val = e1000_read_flash_word_ich8lan(hw,
2275 act_offset + i,
2276 &word);
2277 if (ret_val)
2278 break;
2279 data[i] = word;
2280 }
2281 }
2282
Bruce Allan94d81862009-11-20 23:25:26 +00002283 nvm->ops.release(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002284
Bruce Allane2434552008-11-21 17:02:41 -08002285out:
2286 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002287 e_dbg("NVM read error: %d\n", ret_val);
Bruce Allane2434552008-11-21 17:02:41 -08002288
Auke Kokbc7f75f2007-09-17 12:30:59 -07002289 return ret_val;
2290}
2291
2292/**
2293 * e1000_flash_cycle_init_ich8lan - Initialize flash
2294 * @hw: pointer to the HW structure
2295 *
2296 * This function does initial flash setup so that a new read/write/erase cycle
2297 * can be started.
2298 **/
2299static s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw)
2300{
2301 union ich8_hws_flash_status hsfsts;
2302 s32 ret_val = -E1000_ERR_NVM;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002303
2304 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
2305
2306 /* Check if the flash descriptor is valid */
Bruce Allan04499ec2012-04-13 00:08:31 +00002307 if (!hsfsts.hsf_status.fldesvalid) {
Bruce Allan434f1392011-12-16 00:46:54 +00002308 e_dbg("Flash descriptor invalid. SW Sequencing must be used.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07002309 return -E1000_ERR_NVM;
2310 }
2311
2312 /* Clear FCERR and DAEL in hw status by writing 1 */
2313 hsfsts.hsf_status.flcerr = 1;
2314 hsfsts.hsf_status.dael = 1;
2315
2316 ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
2317
Bruce Allanad680762008-03-28 09:15:03 -07002318 /*
2319 * Either we should have a hardware SPI cycle in progress
Auke Kokbc7f75f2007-09-17 12:30:59 -07002320 * bit to check against, in order to start a new cycle or
2321 * FDONE bit should be changed in the hardware so that it
Auke Kok489815c2008-02-21 15:11:07 -08002322 * is 1 after hardware reset, which can then be used as an
Auke Kokbc7f75f2007-09-17 12:30:59 -07002323 * indication whether a cycle is in progress or has been
2324 * completed.
2325 */
2326
Bruce Allan04499ec2012-04-13 00:08:31 +00002327 if (!hsfsts.hsf_status.flcinprog) {
Bruce Allanad680762008-03-28 09:15:03 -07002328 /*
2329 * There is no cycle running at present,
Bruce Allan5ff5b662009-12-01 15:51:11 +00002330 * so we can start a cycle.
Bruce Allanad680762008-03-28 09:15:03 -07002331 * Begin by setting Flash Cycle Done.
2332 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002333 hsfsts.hsf_status.flcdone = 1;
2334 ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
2335 ret_val = 0;
2336 } else {
Bruce Allanf71dde62012-02-08 02:55:35 +00002337 s32 i;
Bruce Allan90da0662011-01-06 07:02:53 +00002338
Bruce Allanad680762008-03-28 09:15:03 -07002339 /*
Bruce Allan5ff5b662009-12-01 15:51:11 +00002340 * Otherwise poll for sometime so the current
Bruce Allanad680762008-03-28 09:15:03 -07002341 * cycle has a chance to end before giving up.
2342 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002343 for (i = 0; i < ICH_FLASH_READ_COMMAND_TIMEOUT; i++) {
Bruce Allanc8243ee2011-12-17 08:32:57 +00002344 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
Bruce Allan04499ec2012-04-13 00:08:31 +00002345 if (!hsfsts.hsf_status.flcinprog) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07002346 ret_val = 0;
2347 break;
2348 }
2349 udelay(1);
2350 }
Bruce Allan9e2d7652012-01-31 06:37:27 +00002351 if (!ret_val) {
Bruce Allanad680762008-03-28 09:15:03 -07002352 /*
2353 * Successful in waiting for previous cycle to timeout,
2354 * now set the Flash Cycle Done.
2355 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002356 hsfsts.hsf_status.flcdone = 1;
2357 ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
2358 } else {
Joe Perches2c73e1f2010-03-26 20:16:59 +00002359 e_dbg("Flash controller busy, cannot get access\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07002360 }
2361 }
2362
2363 return ret_val;
2364}
2365
2366/**
2367 * e1000_flash_cycle_ich8lan - Starts flash cycle (read/write/erase)
2368 * @hw: pointer to the HW structure
2369 * @timeout: maximum time to wait for completion
2370 *
2371 * This function starts a flash cycle and waits for its completion.
2372 **/
2373static s32 e1000_flash_cycle_ich8lan(struct e1000_hw *hw, u32 timeout)
2374{
2375 union ich8_hws_flash_ctrl hsflctl;
2376 union ich8_hws_flash_status hsfsts;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002377 u32 i = 0;
2378
2379 /* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */
2380 hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
2381 hsflctl.hsf_ctrl.flcgo = 1;
2382 ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
2383
2384 /* wait till FDONE bit is set to 1 */
2385 do {
2386 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
Bruce Allan04499ec2012-04-13 00:08:31 +00002387 if (hsfsts.hsf_status.flcdone)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002388 break;
2389 udelay(1);
2390 } while (i++ < timeout);
2391
Bruce Allan04499ec2012-04-13 00:08:31 +00002392 if (hsfsts.hsf_status.flcdone && !hsfsts.hsf_status.flcerr)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002393 return 0;
2394
Bruce Allan55920b52012-02-08 02:55:25 +00002395 return -E1000_ERR_NVM;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002396}
2397
2398/**
2399 * e1000_read_flash_word_ich8lan - Read word from flash
2400 * @hw: pointer to the HW structure
2401 * @offset: offset to data location
2402 * @data: pointer to the location for storing the data
2403 *
2404 * Reads the flash word at offset into data. Offset is converted
2405 * to bytes before read.
2406 **/
2407static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset,
2408 u16 *data)
2409{
2410 /* Must convert offset into bytes. */
2411 offset <<= 1;
2412
2413 return e1000_read_flash_data_ich8lan(hw, offset, 2, data);
2414}
2415
2416/**
Bruce Allanf4187b52008-08-26 18:36:50 -07002417 * e1000_read_flash_byte_ich8lan - Read byte from flash
2418 * @hw: pointer to the HW structure
2419 * @offset: The offset of the byte to read.
2420 * @data: Pointer to a byte to store the value read.
2421 *
2422 * Reads a single byte from the NVM using the flash access registers.
2423 **/
2424static s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
2425 u8 *data)
2426{
2427 s32 ret_val;
2428 u16 word = 0;
2429
2430 ret_val = e1000_read_flash_data_ich8lan(hw, offset, 1, &word);
2431 if (ret_val)
2432 return ret_val;
2433
2434 *data = (u8)word;
2435
2436 return 0;
2437}
2438
2439/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07002440 * e1000_read_flash_data_ich8lan - Read byte or word from NVM
2441 * @hw: pointer to the HW structure
2442 * @offset: The offset (in bytes) of the byte or word to read.
2443 * @size: Size of data to read, 1=byte 2=word
2444 * @data: Pointer to the word to store the value read.
2445 *
2446 * Reads a byte or word from the NVM using the flash access registers.
2447 **/
2448static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
2449 u8 size, u16 *data)
2450{
2451 union ich8_hws_flash_status hsfsts;
2452 union ich8_hws_flash_ctrl hsflctl;
2453 u32 flash_linear_addr;
2454 u32 flash_data = 0;
2455 s32 ret_val = -E1000_ERR_NVM;
2456 u8 count = 0;
2457
2458 if (size < 1 || size > 2 || offset > ICH_FLASH_LINEAR_ADDR_MASK)
2459 return -E1000_ERR_NVM;
2460
2461 flash_linear_addr = (ICH_FLASH_LINEAR_ADDR_MASK & offset) +
2462 hw->nvm.flash_base_addr;
2463
2464 do {
2465 udelay(1);
2466 /* Steps */
2467 ret_val = e1000_flash_cycle_init_ich8lan(hw);
Bruce Allan9e2d7652012-01-31 06:37:27 +00002468 if (ret_val)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002469 break;
2470
2471 hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
2472 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
2473 hsflctl.hsf_ctrl.fldbcount = size - 1;
2474 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_READ;
2475 ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
2476
2477 ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
2478
2479 ret_val = e1000_flash_cycle_ich8lan(hw,
2480 ICH_FLASH_READ_COMMAND_TIMEOUT);
2481
Bruce Allanad680762008-03-28 09:15:03 -07002482 /*
2483 * Check if FCERR is set to 1, if set to 1, clear it
Auke Kokbc7f75f2007-09-17 12:30:59 -07002484 * and try the whole sequence a few more times, else
2485 * read in (shift in) the Flash Data0, the order is
Bruce Allanad680762008-03-28 09:15:03 -07002486 * least significant byte first msb to lsb
2487 */
Bruce Allan9e2d7652012-01-31 06:37:27 +00002488 if (!ret_val) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07002489 flash_data = er32flash(ICH_FLASH_FDATA0);
Bruce Allanb1cdfea2010-12-11 05:53:47 +00002490 if (size == 1)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002491 *data = (u8)(flash_data & 0x000000FF);
Bruce Allanb1cdfea2010-12-11 05:53:47 +00002492 else if (size == 2)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002493 *data = (u16)(flash_data & 0x0000FFFF);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002494 break;
2495 } else {
Bruce Allanad680762008-03-28 09:15:03 -07002496 /*
2497 * If we've gotten here, then things are probably
Auke Kokbc7f75f2007-09-17 12:30:59 -07002498 * completely hosed, but if the error condition is
2499 * detected, it won't hurt to give it another try...
2500 * ICH_FLASH_CYCLE_REPEAT_COUNT times.
2501 */
2502 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
Bruce Allan04499ec2012-04-13 00:08:31 +00002503 if (hsfsts.hsf_status.flcerr) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07002504 /* Repeat for some time before giving up. */
2505 continue;
Bruce Allan04499ec2012-04-13 00:08:31 +00002506 } else if (!hsfsts.hsf_status.flcdone) {
Bruce Allan434f1392011-12-16 00:46:54 +00002507 e_dbg("Timeout error - flash cycle did not complete.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07002508 break;
2509 }
2510 }
2511 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
2512
2513 return ret_val;
2514}
2515
2516/**
2517 * e1000_write_nvm_ich8lan - Write word(s) to the NVM
2518 * @hw: pointer to the HW structure
2519 * @offset: The offset (in bytes) of the word(s) to write.
2520 * @words: Size of data to write in words
2521 * @data: Pointer to the word(s) to write at offset.
2522 *
2523 * Writes a byte or word to the NVM using the flash access registers.
2524 **/
2525static s32 e1000_write_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
2526 u16 *data)
2527{
2528 struct e1000_nvm_info *nvm = &hw->nvm;
2529 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002530 u16 i;
2531
2532 if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
2533 (words == 0)) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002534 e_dbg("nvm parameter(s) out of bounds\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07002535 return -E1000_ERR_NVM;
2536 }
2537
Bruce Allan94d81862009-11-20 23:25:26 +00002538 nvm->ops.acquire(hw);
Bruce Allanca15df52009-10-26 11:23:43 +00002539
Auke Kokbc7f75f2007-09-17 12:30:59 -07002540 for (i = 0; i < words; i++) {
Bruce Allan564ea9b2009-11-20 23:26:44 +00002541 dev_spec->shadow_ram[offset+i].modified = true;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002542 dev_spec->shadow_ram[offset+i].value = data[i];
2543 }
2544
Bruce Allan94d81862009-11-20 23:25:26 +00002545 nvm->ops.release(hw);
Bruce Allanca15df52009-10-26 11:23:43 +00002546
Auke Kokbc7f75f2007-09-17 12:30:59 -07002547 return 0;
2548}
2549
2550/**
2551 * e1000_update_nvm_checksum_ich8lan - Update the checksum for NVM
2552 * @hw: pointer to the HW structure
2553 *
2554 * The NVM checksum is updated by calling the generic update_nvm_checksum,
2555 * which writes the checksum to the shadow ram. The changes in the shadow
2556 * ram are then committed to the EEPROM by processing each bank at a time
2557 * checking for the modified bit and writing only the pending changes.
Auke Kok489815c2008-02-21 15:11:07 -08002558 * After a successful commit, the shadow ram is cleared and is ready for
Auke Kokbc7f75f2007-09-17 12:30:59 -07002559 * future writes.
2560 **/
2561static s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw)
2562{
2563 struct e1000_nvm_info *nvm = &hw->nvm;
2564 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
Bruce Allanf4187b52008-08-26 18:36:50 -07002565 u32 i, act_offset, new_bank_offset, old_bank_offset, bank;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002566 s32 ret_val;
2567 u16 data;
2568
2569 ret_val = e1000e_update_nvm_checksum_generic(hw);
2570 if (ret_val)
Bruce Allane2434552008-11-21 17:02:41 -08002571 goto out;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002572
2573 if (nvm->type != e1000_nvm_flash_sw)
Bruce Allane2434552008-11-21 17:02:41 -08002574 goto out;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002575
Bruce Allan94d81862009-11-20 23:25:26 +00002576 nvm->ops.acquire(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002577
Bruce Allanad680762008-03-28 09:15:03 -07002578 /*
2579 * We're writing to the opposite bank so if we're on bank 1,
Auke Kokbc7f75f2007-09-17 12:30:59 -07002580 * write to bank 0 etc. We also need to erase the segment that
Bruce Allanad680762008-03-28 09:15:03 -07002581 * is going to be written
2582 */
Bruce Allanf4187b52008-08-26 18:36:50 -07002583 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
Bruce Allane2434552008-11-21 17:02:41 -08002584 if (ret_val) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002585 e_dbg("Could not detect valid bank, assuming bank 0\n");
Bruce Allan148675a2009-08-07 07:41:56 +00002586 bank = 0;
Bruce Allane2434552008-11-21 17:02:41 -08002587 }
Bruce Allanf4187b52008-08-26 18:36:50 -07002588
2589 if (bank == 0) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07002590 new_bank_offset = nvm->flash_bank_size;
2591 old_bank_offset = 0;
Bruce Allane2434552008-11-21 17:02:41 -08002592 ret_val = e1000_erase_flash_bank_ich8lan(hw, 1);
Bruce Allan9c5e2092010-05-10 15:00:31 +00002593 if (ret_val)
2594 goto release;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002595 } else {
2596 old_bank_offset = nvm->flash_bank_size;
2597 new_bank_offset = 0;
Bruce Allane2434552008-11-21 17:02:41 -08002598 ret_val = e1000_erase_flash_bank_ich8lan(hw, 0);
Bruce Allan9c5e2092010-05-10 15:00:31 +00002599 if (ret_val)
2600 goto release;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002601 }
2602
2603 for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i++) {
Bruce Allanad680762008-03-28 09:15:03 -07002604 /*
2605 * Determine whether to write the value stored
Auke Kokbc7f75f2007-09-17 12:30:59 -07002606 * in the other NVM bank or a modified value stored
Bruce Allanad680762008-03-28 09:15:03 -07002607 * in the shadow RAM
2608 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002609 if (dev_spec->shadow_ram[i].modified) {
2610 data = dev_spec->shadow_ram[i].value;
2611 } else {
Bruce Allane2434552008-11-21 17:02:41 -08002612 ret_val = e1000_read_flash_word_ich8lan(hw, i +
2613 old_bank_offset,
2614 &data);
2615 if (ret_val)
2616 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002617 }
2618
Bruce Allanad680762008-03-28 09:15:03 -07002619 /*
2620 * If the word is 0x13, then make sure the signature bits
Auke Kokbc7f75f2007-09-17 12:30:59 -07002621 * (15:14) are 11b until the commit has completed.
2622 * This will allow us to write 10b which indicates the
2623 * signature is valid. We want to do this after the write
2624 * has completed so that we don't mark the segment valid
Bruce Allanad680762008-03-28 09:15:03 -07002625 * while the write is still in progress
2626 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002627 if (i == E1000_ICH_NVM_SIG_WORD)
2628 data |= E1000_ICH_NVM_SIG_MASK;
2629
2630 /* Convert offset to bytes. */
2631 act_offset = (i + new_bank_offset) << 1;
2632
2633 udelay(100);
2634 /* Write the bytes to the new bank. */
2635 ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
2636 act_offset,
2637 (u8)data);
2638 if (ret_val)
2639 break;
2640
2641 udelay(100);
2642 ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
2643 act_offset + 1,
2644 (u8)(data >> 8));
2645 if (ret_val)
2646 break;
2647 }
2648
Bruce Allanad680762008-03-28 09:15:03 -07002649 /*
2650 * Don't bother writing the segment valid bits if sector
2651 * programming failed.
2652 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002653 if (ret_val) {
Bruce Allan4a770352008-10-01 17:18:35 -07002654 /* Possibly read-only, see e1000e_write_protect_nvm_ich8lan() */
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002655 e_dbg("Flash commit failed.\n");
Bruce Allan9c5e2092010-05-10 15:00:31 +00002656 goto release;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002657 }
2658
Bruce Allanad680762008-03-28 09:15:03 -07002659 /*
2660 * Finally validate the new segment by setting bit 15:14
Auke Kokbc7f75f2007-09-17 12:30:59 -07002661 * to 10b in word 0x13 , this can be done without an
2662 * erase as well since these bits are 11 to start with
Bruce Allanad680762008-03-28 09:15:03 -07002663 * and we need to change bit 14 to 0b
2664 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002665 act_offset = new_bank_offset + E1000_ICH_NVM_SIG_WORD;
Bruce Allane2434552008-11-21 17:02:41 -08002666 ret_val = e1000_read_flash_word_ich8lan(hw, act_offset, &data);
Bruce Allan9c5e2092010-05-10 15:00:31 +00002667 if (ret_val)
2668 goto release;
2669
Auke Kokbc7f75f2007-09-17 12:30:59 -07002670 data &= 0xBFFF;
2671 ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
2672 act_offset * 2 + 1,
2673 (u8)(data >> 8));
Bruce Allan9c5e2092010-05-10 15:00:31 +00002674 if (ret_val)
2675 goto release;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002676
Bruce Allanad680762008-03-28 09:15:03 -07002677 /*
2678 * And invalidate the previously valid segment by setting
Auke Kokbc7f75f2007-09-17 12:30:59 -07002679 * its signature word (0x13) high_byte to 0b. This can be
2680 * done without an erase because flash erase sets all bits
Bruce Allanad680762008-03-28 09:15:03 -07002681 * to 1's. We can write 1's to 0's without an erase
2682 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002683 act_offset = (old_bank_offset + E1000_ICH_NVM_SIG_WORD) * 2 + 1;
2684 ret_val = e1000_retry_write_flash_byte_ich8lan(hw, act_offset, 0);
Bruce Allan9c5e2092010-05-10 15:00:31 +00002685 if (ret_val)
2686 goto release;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002687
2688 /* Great! Everything worked, we can now clear the cached entries. */
2689 for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i++) {
Bruce Allan564ea9b2009-11-20 23:26:44 +00002690 dev_spec->shadow_ram[i].modified = false;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002691 dev_spec->shadow_ram[i].value = 0xFFFF;
2692 }
2693
Bruce Allan9c5e2092010-05-10 15:00:31 +00002694release:
Bruce Allan94d81862009-11-20 23:25:26 +00002695 nvm->ops.release(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002696
Bruce Allanad680762008-03-28 09:15:03 -07002697 /*
2698 * Reload the EEPROM, or else modifications will not appear
Auke Kokbc7f75f2007-09-17 12:30:59 -07002699 * until after the next adapter reset.
2700 */
Bruce Allan9c5e2092010-05-10 15:00:31 +00002701 if (!ret_val) {
Bruce Allane85e3632012-02-22 09:03:14 +00002702 nvm->ops.reload(hw);
Bruce Allan1bba4382011-03-19 00:27:20 +00002703 usleep_range(10000, 20000);
Bruce Allan9c5e2092010-05-10 15:00:31 +00002704 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07002705
Bruce Allane2434552008-11-21 17:02:41 -08002706out:
2707 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002708 e_dbg("NVM update error: %d\n", ret_val);
Bruce Allane2434552008-11-21 17:02:41 -08002709
Auke Kokbc7f75f2007-09-17 12:30:59 -07002710 return ret_val;
2711}
2712
2713/**
2714 * e1000_validate_nvm_checksum_ich8lan - Validate EEPROM checksum
2715 * @hw: pointer to the HW structure
2716 *
2717 * Check to see if checksum needs to be fixed by reading bit 6 in word 0x19.
2718 * If the bit is 0, that the EEPROM had been modified, but the checksum was not
2719 * calculated, in which case we need to calculate the checksum and set bit 6.
2720 **/
2721static s32 e1000_validate_nvm_checksum_ich8lan(struct e1000_hw *hw)
2722{
2723 s32 ret_val;
2724 u16 data;
2725
Bruce Allanad680762008-03-28 09:15:03 -07002726 /*
2727 * Read 0x19 and check bit 6. If this bit is 0, the checksum
Auke Kokbc7f75f2007-09-17 12:30:59 -07002728 * needs to be fixed. This bit is an indication that the NVM
2729 * was prepared by OEM software and did not calculate the
2730 * checksum...a likely scenario.
2731 */
2732 ret_val = e1000_read_nvm(hw, 0x19, 1, &data);
2733 if (ret_val)
2734 return ret_val;
2735
Bruce Allan04499ec2012-04-13 00:08:31 +00002736 if (!(data & 0x40)) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07002737 data |= 0x40;
2738 ret_val = e1000_write_nvm(hw, 0x19, 1, &data);
2739 if (ret_val)
2740 return ret_val;
2741 ret_val = e1000e_update_nvm_checksum(hw);
2742 if (ret_val)
2743 return ret_val;
2744 }
2745
2746 return e1000e_validate_nvm_checksum_generic(hw);
2747}
2748
2749/**
Bruce Allan4a770352008-10-01 17:18:35 -07002750 * e1000e_write_protect_nvm_ich8lan - Make the NVM read-only
2751 * @hw: pointer to the HW structure
2752 *
2753 * To prevent malicious write/erase of the NVM, set it to be read-only
2754 * so that the hardware ignores all write/erase cycles of the NVM via
2755 * the flash control registers. The shadow-ram copy of the NVM will
2756 * still be updated, however any updates to this copy will not stick
2757 * across driver reloads.
2758 **/
2759void e1000e_write_protect_nvm_ich8lan(struct e1000_hw *hw)
2760{
Bruce Allanca15df52009-10-26 11:23:43 +00002761 struct e1000_nvm_info *nvm = &hw->nvm;
Bruce Allan4a770352008-10-01 17:18:35 -07002762 union ich8_flash_protected_range pr0;
2763 union ich8_hws_flash_status hsfsts;
2764 u32 gfpreg;
Bruce Allan4a770352008-10-01 17:18:35 -07002765
Bruce Allan94d81862009-11-20 23:25:26 +00002766 nvm->ops.acquire(hw);
Bruce Allan4a770352008-10-01 17:18:35 -07002767
2768 gfpreg = er32flash(ICH_FLASH_GFPREG);
2769
2770 /* Write-protect GbE Sector of NVM */
2771 pr0.regval = er32flash(ICH_FLASH_PR0);
2772 pr0.range.base = gfpreg & FLASH_GFPREG_BASE_MASK;
2773 pr0.range.limit = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK);
2774 pr0.range.wpe = true;
2775 ew32flash(ICH_FLASH_PR0, pr0.regval);
2776
2777 /*
2778 * Lock down a subset of GbE Flash Control Registers, e.g.
2779 * PR0 to prevent the write-protection from being lifted.
2780 * Once FLOCKDN is set, the registers protected by it cannot
2781 * be written until FLOCKDN is cleared by a hardware reset.
2782 */
2783 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
2784 hsfsts.hsf_status.flockdn = true;
2785 ew32flash(ICH_FLASH_HSFSTS, hsfsts.regval);
2786
Bruce Allan94d81862009-11-20 23:25:26 +00002787 nvm->ops.release(hw);
Bruce Allan4a770352008-10-01 17:18:35 -07002788}
2789
2790/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07002791 * e1000_write_flash_data_ich8lan - Writes bytes to the NVM
2792 * @hw: pointer to the HW structure
2793 * @offset: The offset (in bytes) of the byte/word to read.
2794 * @size: Size of data to read, 1=byte 2=word
2795 * @data: The byte(s) to write to the NVM.
2796 *
2797 * Writes one/two bytes to the NVM using the flash access registers.
2798 **/
2799static s32 e1000_write_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
2800 u8 size, u16 data)
2801{
2802 union ich8_hws_flash_status hsfsts;
2803 union ich8_hws_flash_ctrl hsflctl;
2804 u32 flash_linear_addr;
2805 u32 flash_data = 0;
2806 s32 ret_val;
2807 u8 count = 0;
2808
2809 if (size < 1 || size > 2 || data > size * 0xff ||
2810 offset > ICH_FLASH_LINEAR_ADDR_MASK)
2811 return -E1000_ERR_NVM;
2812
2813 flash_linear_addr = (ICH_FLASH_LINEAR_ADDR_MASK & offset) +
2814 hw->nvm.flash_base_addr;
2815
2816 do {
2817 udelay(1);
2818 /* Steps */
2819 ret_val = e1000_flash_cycle_init_ich8lan(hw);
2820 if (ret_val)
2821 break;
2822
2823 hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
2824 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
2825 hsflctl.hsf_ctrl.fldbcount = size -1;
2826 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_WRITE;
2827 ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
2828
2829 ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
2830
2831 if (size == 1)
2832 flash_data = (u32)data & 0x00FF;
2833 else
2834 flash_data = (u32)data;
2835
2836 ew32flash(ICH_FLASH_FDATA0, flash_data);
2837
Bruce Allanad680762008-03-28 09:15:03 -07002838 /*
2839 * check if FCERR is set to 1 , if set to 1, clear it
2840 * and try the whole sequence a few more times else done
2841 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002842 ret_val = e1000_flash_cycle_ich8lan(hw,
2843 ICH_FLASH_WRITE_COMMAND_TIMEOUT);
2844 if (!ret_val)
2845 break;
2846
Bruce Allanad680762008-03-28 09:15:03 -07002847 /*
2848 * If we're here, then things are most likely
Auke Kokbc7f75f2007-09-17 12:30:59 -07002849 * completely hosed, but if the error condition
2850 * is detected, it won't hurt to give it another
2851 * try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
2852 */
2853 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
Bruce Allan04499ec2012-04-13 00:08:31 +00002854 if (hsfsts.hsf_status.flcerr)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002855 /* Repeat for some time before giving up. */
2856 continue;
Bruce Allan04499ec2012-04-13 00:08:31 +00002857 if (!hsfsts.hsf_status.flcdone) {
Bruce Allan434f1392011-12-16 00:46:54 +00002858 e_dbg("Timeout error - flash cycle did not complete.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07002859 break;
2860 }
2861 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
2862
2863 return ret_val;
2864}
2865
2866/**
2867 * e1000_write_flash_byte_ich8lan - Write a single byte to NVM
2868 * @hw: pointer to the HW structure
2869 * @offset: The index of the byte to read.
2870 * @data: The byte to write to the NVM.
2871 *
2872 * Writes a single byte to the NVM using the flash access registers.
2873 **/
2874static s32 e1000_write_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
2875 u8 data)
2876{
2877 u16 word = (u16)data;
2878
2879 return e1000_write_flash_data_ich8lan(hw, offset, 1, word);
2880}
2881
2882/**
2883 * e1000_retry_write_flash_byte_ich8lan - Writes a single byte to NVM
2884 * @hw: pointer to the HW structure
2885 * @offset: The offset of the byte to write.
2886 * @byte: The byte to write to the NVM.
2887 *
2888 * Writes a single byte to the NVM using the flash access registers.
2889 * Goes through a retry algorithm before giving up.
2890 **/
2891static s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw,
2892 u32 offset, u8 byte)
2893{
2894 s32 ret_val;
2895 u16 program_retries;
2896
2897 ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
2898 if (!ret_val)
2899 return ret_val;
2900
2901 for (program_retries = 0; program_retries < 100; program_retries++) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002902 e_dbg("Retrying Byte %2.2X at offset %u\n", byte, offset);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002903 udelay(100);
2904 ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
2905 if (!ret_val)
2906 break;
2907 }
2908 if (program_retries == 100)
2909 return -E1000_ERR_NVM;
2910
2911 return 0;
2912}
2913
2914/**
2915 * e1000_erase_flash_bank_ich8lan - Erase a bank (4k) from NVM
2916 * @hw: pointer to the HW structure
2917 * @bank: 0 for first bank, 1 for second bank, etc.
2918 *
2919 * Erases the bank specified. Each bank is a 4k block. Banks are 0 based.
2920 * bank N is 4096 * N + flash_reg_addr.
2921 **/
2922static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank)
2923{
2924 struct e1000_nvm_info *nvm = &hw->nvm;
2925 union ich8_hws_flash_status hsfsts;
2926 union ich8_hws_flash_ctrl hsflctl;
2927 u32 flash_linear_addr;
2928 /* bank size is in 16bit words - adjust to bytes */
2929 u32 flash_bank_size = nvm->flash_bank_size * 2;
2930 s32 ret_val;
2931 s32 count = 0;
Bruce Allana708dd82009-11-20 23:28:37 +00002932 s32 j, iteration, sector_size;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002933
2934 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
2935
Bruce Allanad680762008-03-28 09:15:03 -07002936 /*
2937 * Determine HW Sector size: Read BERASE bits of hw flash status
2938 * register
2939 * 00: The Hw sector is 256 bytes, hence we need to erase 16
Auke Kokbc7f75f2007-09-17 12:30:59 -07002940 * consecutive sectors. The start index for the nth Hw sector
2941 * can be calculated as = bank * 4096 + n * 256
2942 * 01: The Hw sector is 4K bytes, hence we need to erase 1 sector.
2943 * The start index for the nth Hw sector can be calculated
2944 * as = bank * 4096
2945 * 10: The Hw sector is 8K bytes, nth sector = bank * 8192
2946 * (ich9 only, otherwise error condition)
2947 * 11: The Hw sector is 64K bytes, nth sector = bank * 65536
2948 */
2949 switch (hsfsts.hsf_status.berasesz) {
2950 case 0:
2951 /* Hw sector size 256 */
2952 sector_size = ICH_FLASH_SEG_SIZE_256;
2953 iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_256;
2954 break;
2955 case 1:
2956 sector_size = ICH_FLASH_SEG_SIZE_4K;
Bruce Allan28c91952009-07-01 13:28:32 +00002957 iteration = 1;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002958 break;
2959 case 2:
Bruce Allan148675a2009-08-07 07:41:56 +00002960 sector_size = ICH_FLASH_SEG_SIZE_8K;
2961 iteration = 1;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002962 break;
2963 case 3:
2964 sector_size = ICH_FLASH_SEG_SIZE_64K;
Bruce Allan28c91952009-07-01 13:28:32 +00002965 iteration = 1;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002966 break;
2967 default:
2968 return -E1000_ERR_NVM;
2969 }
2970
2971 /* Start with the base address, then add the sector offset. */
2972 flash_linear_addr = hw->nvm.flash_base_addr;
Bruce Allan148675a2009-08-07 07:41:56 +00002973 flash_linear_addr += (bank) ? flash_bank_size : 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002974
2975 for (j = 0; j < iteration ; j++) {
2976 do {
2977 /* Steps */
2978 ret_val = e1000_flash_cycle_init_ich8lan(hw);
2979 if (ret_val)
2980 return ret_val;
2981
Bruce Allanad680762008-03-28 09:15:03 -07002982 /*
2983 * Write a value 11 (block Erase) in Flash
2984 * Cycle field in hw flash control
2985 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002986 hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
2987 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_ERASE;
2988 ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
2989
Bruce Allanad680762008-03-28 09:15:03 -07002990 /*
2991 * Write the last 24 bits of an index within the
Auke Kokbc7f75f2007-09-17 12:30:59 -07002992 * block into Flash Linear address field in Flash
2993 * Address.
2994 */
2995 flash_linear_addr += (j * sector_size);
2996 ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
2997
2998 ret_val = e1000_flash_cycle_ich8lan(hw,
2999 ICH_FLASH_ERASE_COMMAND_TIMEOUT);
Bruce Allan9e2d7652012-01-31 06:37:27 +00003000 if (!ret_val)
Auke Kokbc7f75f2007-09-17 12:30:59 -07003001 break;
3002
Bruce Allanad680762008-03-28 09:15:03 -07003003 /*
3004 * Check if FCERR is set to 1. If 1,
Auke Kokbc7f75f2007-09-17 12:30:59 -07003005 * clear it and try the whole sequence
Bruce Allanad680762008-03-28 09:15:03 -07003006 * a few more times else Done
3007 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003008 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
Bruce Allan04499ec2012-04-13 00:08:31 +00003009 if (hsfsts.hsf_status.flcerr)
Bruce Allanad680762008-03-28 09:15:03 -07003010 /* repeat for some time before giving up */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003011 continue;
Bruce Allan04499ec2012-04-13 00:08:31 +00003012 else if (!hsfsts.hsf_status.flcdone)
Auke Kokbc7f75f2007-09-17 12:30:59 -07003013 return ret_val;
3014 } while (++count < ICH_FLASH_CYCLE_REPEAT_COUNT);
3015 }
3016
3017 return 0;
3018}
3019
3020/**
3021 * e1000_valid_led_default_ich8lan - Set the default LED settings
3022 * @hw: pointer to the HW structure
3023 * @data: Pointer to the LED settings
3024 *
3025 * Reads the LED default settings from the NVM to data. If the NVM LED
3026 * settings is all 0's or F's, set the LED default to a valid LED default
3027 * setting.
3028 **/
3029static s32 e1000_valid_led_default_ich8lan(struct e1000_hw *hw, u16 *data)
3030{
3031 s32 ret_val;
3032
3033 ret_val = e1000_read_nvm(hw, NVM_ID_LED_SETTINGS, 1, data);
3034 if (ret_val) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003035 e_dbg("NVM Read Error\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07003036 return ret_val;
3037 }
3038
3039 if (*data == ID_LED_RESERVED_0000 ||
3040 *data == ID_LED_RESERVED_FFFF)
3041 *data = ID_LED_DEFAULT_ICH8LAN;
3042
3043 return 0;
3044}
3045
3046/**
Bruce Allana4f58f52009-06-02 11:29:18 +00003047 * e1000_id_led_init_pchlan - store LED configurations
3048 * @hw: pointer to the HW structure
3049 *
3050 * PCH does not control LEDs via the LEDCTL register, rather it uses
3051 * the PHY LED configuration register.
3052 *
3053 * PCH also does not have an "always on" or "always off" mode which
3054 * complicates the ID feature. Instead of using the "on" mode to indicate
Bruce Alland1964eb2012-02-22 09:02:21 +00003055 * in ledctl_mode2 the LEDs to use for ID (see e1000e_id_led_init_generic()),
Bruce Allana4f58f52009-06-02 11:29:18 +00003056 * use "link_up" mode. The LEDs will still ID on request if there is no
3057 * link based on logic in e1000_led_[on|off]_pchlan().
3058 **/
3059static s32 e1000_id_led_init_pchlan(struct e1000_hw *hw)
3060{
3061 struct e1000_mac_info *mac = &hw->mac;
3062 s32 ret_val;
3063 const u32 ledctl_on = E1000_LEDCTL_MODE_LINK_UP;
3064 const u32 ledctl_off = E1000_LEDCTL_MODE_LINK_UP | E1000_PHY_LED0_IVRT;
3065 u16 data, i, temp, shift;
3066
3067 /* Get default ID LED modes */
3068 ret_val = hw->nvm.ops.valid_led_default(hw, &data);
3069 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00003070 return ret_val;
Bruce Allana4f58f52009-06-02 11:29:18 +00003071
3072 mac->ledctl_default = er32(LEDCTL);
3073 mac->ledctl_mode1 = mac->ledctl_default;
3074 mac->ledctl_mode2 = mac->ledctl_default;
3075
3076 for (i = 0; i < 4; i++) {
3077 temp = (data >> (i << 2)) & E1000_LEDCTL_LED0_MODE_MASK;
3078 shift = (i * 5);
3079 switch (temp) {
3080 case ID_LED_ON1_DEF2:
3081 case ID_LED_ON1_ON2:
3082 case ID_LED_ON1_OFF2:
3083 mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
3084 mac->ledctl_mode1 |= (ledctl_on << shift);
3085 break;
3086 case ID_LED_OFF1_DEF2:
3087 case ID_LED_OFF1_ON2:
3088 case ID_LED_OFF1_OFF2:
3089 mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
3090 mac->ledctl_mode1 |= (ledctl_off << shift);
3091 break;
3092 default:
3093 /* Do nothing */
3094 break;
3095 }
3096 switch (temp) {
3097 case ID_LED_DEF1_ON2:
3098 case ID_LED_ON1_ON2:
3099 case ID_LED_OFF1_ON2:
3100 mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
3101 mac->ledctl_mode2 |= (ledctl_on << shift);
3102 break;
3103 case ID_LED_DEF1_OFF2:
3104 case ID_LED_ON1_OFF2:
3105 case ID_LED_OFF1_OFF2:
3106 mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
3107 mac->ledctl_mode2 |= (ledctl_off << shift);
3108 break;
3109 default:
3110 /* Do nothing */
3111 break;
3112 }
3113 }
3114
Bruce Allan5015e532012-02-08 02:55:56 +00003115 return 0;
Bruce Allana4f58f52009-06-02 11:29:18 +00003116}
3117
3118/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07003119 * e1000_get_bus_info_ich8lan - Get/Set the bus type and width
3120 * @hw: pointer to the HW structure
3121 *
3122 * ICH8 use the PCI Express bus, but does not contain a PCI Express Capability
3123 * register, so the the bus width is hard coded.
3124 **/
3125static s32 e1000_get_bus_info_ich8lan(struct e1000_hw *hw)
3126{
3127 struct e1000_bus_info *bus = &hw->bus;
3128 s32 ret_val;
3129
3130 ret_val = e1000e_get_bus_info_pcie(hw);
3131
Bruce Allanad680762008-03-28 09:15:03 -07003132 /*
3133 * ICH devices are "PCI Express"-ish. They have
Auke Kokbc7f75f2007-09-17 12:30:59 -07003134 * a configuration space, but do not contain
3135 * PCI Express Capability registers, so bus width
3136 * must be hardcoded.
3137 */
3138 if (bus->width == e1000_bus_width_unknown)
3139 bus->width = e1000_bus_width_pcie_x1;
3140
3141 return ret_val;
3142}
3143
3144/**
3145 * e1000_reset_hw_ich8lan - Reset the hardware
3146 * @hw: pointer to the HW structure
3147 *
3148 * Does a full reset of the hardware which includes a reset of the PHY and
3149 * MAC.
3150 **/
3151static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
3152{
Bruce Allan1d5846b2009-10-29 13:46:05 +00003153 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
Bruce Allan62bc8132012-03-20 03:47:57 +00003154 u16 kum_cfg;
3155 u32 ctrl, reg;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003156 s32 ret_val;
3157
Bruce Allanad680762008-03-28 09:15:03 -07003158 /*
3159 * Prevent the PCI-E bus from sticking if there is no TLP connection
Auke Kokbc7f75f2007-09-17 12:30:59 -07003160 * on the last TLP read/write transaction when MAC is reset.
3161 */
3162 ret_val = e1000e_disable_pcie_master(hw);
Bruce Allane98cac42010-05-10 15:02:32 +00003163 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003164 e_dbg("PCI-E Master disable polling has failed.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07003165
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003166 e_dbg("Masking off all interrupts\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07003167 ew32(IMC, 0xffffffff);
3168
Bruce Allanad680762008-03-28 09:15:03 -07003169 /*
3170 * Disable the Transmit and Receive units. Then delay to allow
Auke Kokbc7f75f2007-09-17 12:30:59 -07003171 * any pending transactions to complete before we hit the MAC
3172 * with the global reset.
3173 */
3174 ew32(RCTL, 0);
3175 ew32(TCTL, E1000_TCTL_PSP);
3176 e1e_flush();
3177
Bruce Allan1bba4382011-03-19 00:27:20 +00003178 usleep_range(10000, 20000);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003179
3180 /* Workaround for ICH8 bit corruption issue in FIFO memory */
3181 if (hw->mac.type == e1000_ich8lan) {
3182 /* Set Tx and Rx buffer allocation to 8k apiece. */
3183 ew32(PBA, E1000_PBA_8K);
3184 /* Set Packet Buffer Size to 16k. */
3185 ew32(PBS, E1000_PBS_16K);
3186 }
3187
Bruce Allan1d5846b2009-10-29 13:46:05 +00003188 if (hw->mac.type == e1000_pchlan) {
Bruce Allan62bc8132012-03-20 03:47:57 +00003189 /* Save the NVM K1 bit setting */
3190 ret_val = e1000_read_nvm(hw, E1000_NVM_K1_CONFIG, 1, &kum_cfg);
Bruce Allan1d5846b2009-10-29 13:46:05 +00003191 if (ret_val)
3192 return ret_val;
3193
Bruce Allan62bc8132012-03-20 03:47:57 +00003194 if (kum_cfg & E1000_NVM_K1_ENABLE)
Bruce Allan1d5846b2009-10-29 13:46:05 +00003195 dev_spec->nvm_k1_enabled = true;
3196 else
3197 dev_spec->nvm_k1_enabled = false;
3198 }
3199
Auke Kokbc7f75f2007-09-17 12:30:59 -07003200 ctrl = er32(CTRL);
3201
Bruce Allan44abd5c2012-02-22 09:02:37 +00003202 if (!hw->phy.ops.check_reset_block(hw)) {
Bruce Allanad680762008-03-28 09:15:03 -07003203 /*
Bruce Allane98cac42010-05-10 15:02:32 +00003204 * Full-chip reset requires MAC and PHY reset at the same
Auke Kokbc7f75f2007-09-17 12:30:59 -07003205 * time to make sure the interface between MAC and the
3206 * external PHY is reset.
3207 */
3208 ctrl |= E1000_CTRL_PHY_RST;
Bruce Allan605c82b2010-09-22 17:17:01 +00003209
3210 /*
3211 * Gate automatic PHY configuration by hardware on
3212 * non-managed 82579
3213 */
3214 if ((hw->mac.type == e1000_pch2lan) &&
3215 !(er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
3216 e1000_gate_hw_phy_config_ich8lan(hw, true);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003217 }
3218 ret_val = e1000_acquire_swflag_ich8lan(hw);
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003219 e_dbg("Issuing a global reset to ich8lan\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07003220 ew32(CTRL, (ctrl | E1000_CTRL_RST));
Jesse Brandeburg945a5152011-07-20 00:56:21 +00003221 /* cannot issue a flush here because it hangs the hardware */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003222 msleep(20);
3223
Bruce Allan62bc8132012-03-20 03:47:57 +00003224 /* Set Phy Config Counter to 50msec */
3225 if (hw->mac.type == e1000_pch2lan) {
3226 reg = er32(FEXTNVM3);
3227 reg &= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK;
3228 reg |= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC;
3229 ew32(FEXTNVM3, reg);
3230 }
3231
Bruce Allanfc0c7762009-07-01 13:27:55 +00003232 if (!ret_val)
Bruce Allana90b4122011-10-07 03:50:38 +00003233 clear_bit(__E1000_ACCESS_SHARED_RESOURCE, &hw->adapter->state);
Jesse Brandeburg37f40232008-10-02 16:33:20 -07003234
Bruce Allane98cac42010-05-10 15:02:32 +00003235 if (ctrl & E1000_CTRL_PHY_RST) {
Bruce Allanfc0c7762009-07-01 13:27:55 +00003236 ret_val = hw->phy.ops.get_cfg_done(hw);
Bruce Allane98cac42010-05-10 15:02:32 +00003237 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00003238 return ret_val;
Bruce Allanfc0c7762009-07-01 13:27:55 +00003239
Bruce Allane98cac42010-05-10 15:02:32 +00003240 ret_val = e1000_post_phy_reset_ich8lan(hw);
Bruce Allanf523d212009-10-29 13:45:45 +00003241 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00003242 return ret_val;
Bruce Allanf523d212009-10-29 13:45:45 +00003243 }
Bruce Allane98cac42010-05-10 15:02:32 +00003244
Bruce Allan7d3cabb2009-07-01 13:29:08 +00003245 /*
3246 * For PCH, this write will make sure that any noise
3247 * will be detected as a CRC error and be dropped rather than show up
3248 * as a bad packet to the DMA engine.
3249 */
3250 if (hw->mac.type == e1000_pchlan)
3251 ew32(CRC_OFFSET, 0x65656565);
3252
Auke Kokbc7f75f2007-09-17 12:30:59 -07003253 ew32(IMC, 0xffffffff);
Bruce Allandd93f952011-01-06 14:29:48 +00003254 er32(ICR);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003255
Bruce Allan62bc8132012-03-20 03:47:57 +00003256 reg = er32(KABGTXD);
3257 reg |= E1000_KABGTXD_BGSQLBIAS;
3258 ew32(KABGTXD, reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003259
Bruce Allan5015e532012-02-08 02:55:56 +00003260 return 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003261}
3262
3263/**
3264 * e1000_init_hw_ich8lan - Initialize the hardware
3265 * @hw: pointer to the HW structure
3266 *
3267 * Prepares the hardware for transmit and receive by doing the following:
3268 * - initialize hardware bits
3269 * - initialize LED identification
3270 * - setup receive address registers
3271 * - setup flow control
Auke Kok489815c2008-02-21 15:11:07 -08003272 * - setup transmit descriptors
Auke Kokbc7f75f2007-09-17 12:30:59 -07003273 * - clear statistics
3274 **/
3275static s32 e1000_init_hw_ich8lan(struct e1000_hw *hw)
3276{
3277 struct e1000_mac_info *mac = &hw->mac;
3278 u32 ctrl_ext, txdctl, snoop;
3279 s32 ret_val;
3280 u16 i;
3281
3282 e1000_initialize_hw_bits_ich8lan(hw);
3283
3284 /* Initialize identification LED */
Bruce Allana4f58f52009-06-02 11:29:18 +00003285 ret_val = mac->ops.id_led_init(hw);
Bruce Allande39b752009-11-20 23:27:59 +00003286 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003287 e_dbg("Error initializing identification LED\n");
Bruce Allande39b752009-11-20 23:27:59 +00003288 /* This is not fatal and we should not stop init due to this */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003289
3290 /* Setup the receive address. */
3291 e1000e_init_rx_addrs(hw, mac->rar_entry_count);
3292
3293 /* Zero out the Multicast HASH table */
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003294 e_dbg("Zeroing the MTA\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07003295 for (i = 0; i < mac->mta_reg_count; i++)
3296 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
3297
Bruce Allanfc0c7762009-07-01 13:27:55 +00003298 /*
3299 * The 82578 Rx buffer will stall if wakeup is enabled in host and
Bruce Allan3ebfc7c2011-05-13 07:20:14 +00003300 * the ME. Disable wakeup by clearing the host wakeup bit.
Bruce Allanfc0c7762009-07-01 13:27:55 +00003301 * Reset the phy after disabling host wakeup to reset the Rx buffer.
3302 */
3303 if (hw->phy.type == e1000_phy_82578) {
Bruce Allan3ebfc7c2011-05-13 07:20:14 +00003304 e1e_rphy(hw, BM_PORT_GEN_CFG, &i);
3305 i &= ~BM_WUC_HOST_WU_BIT;
3306 e1e_wphy(hw, BM_PORT_GEN_CFG, i);
Bruce Allanfc0c7762009-07-01 13:27:55 +00003307 ret_val = e1000_phy_hw_reset_ich8lan(hw);
3308 if (ret_val)
3309 return ret_val;
3310 }
3311
Auke Kokbc7f75f2007-09-17 12:30:59 -07003312 /* Setup link and flow control */
Bruce Allan1a46b402012-02-22 09:02:26 +00003313 ret_val = mac->ops.setup_link(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003314
3315 /* Set the transmit descriptor write-back policy for both queues */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003316 txdctl = er32(TXDCTL(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -07003317 txdctl = (txdctl & ~E1000_TXDCTL_WTHRESH) |
3318 E1000_TXDCTL_FULL_TX_DESC_WB;
3319 txdctl = (txdctl & ~E1000_TXDCTL_PTHRESH) |
3320 E1000_TXDCTL_MAX_TX_DESC_PREFETCH;
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003321 ew32(TXDCTL(0), txdctl);
3322 txdctl = er32(TXDCTL(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -07003323 txdctl = (txdctl & ~E1000_TXDCTL_WTHRESH) |
3324 E1000_TXDCTL_FULL_TX_DESC_WB;
3325 txdctl = (txdctl & ~E1000_TXDCTL_PTHRESH) |
3326 E1000_TXDCTL_MAX_TX_DESC_PREFETCH;
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003327 ew32(TXDCTL(1), txdctl);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003328
Bruce Allanad680762008-03-28 09:15:03 -07003329 /*
3330 * ICH8 has opposite polarity of no_snoop bits.
3331 * By default, we should use snoop behavior.
3332 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003333 if (mac->type == e1000_ich8lan)
3334 snoop = PCIE_ICH8_SNOOP_ALL;
3335 else
3336 snoop = (u32) ~(PCIE_NO_SNOOP_ALL);
3337 e1000e_set_pcie_no_snoop(hw, snoop);
3338
3339 ctrl_ext = er32(CTRL_EXT);
3340 ctrl_ext |= E1000_CTRL_EXT_RO_DIS;
3341 ew32(CTRL_EXT, ctrl_ext);
3342
Bruce Allanad680762008-03-28 09:15:03 -07003343 /*
3344 * Clear all of the statistics registers (clear on read). It is
Auke Kokbc7f75f2007-09-17 12:30:59 -07003345 * important that we do this after we have tried to establish link
3346 * because the symbol error count will increment wildly if there
3347 * is no link.
3348 */
3349 e1000_clear_hw_cntrs_ich8lan(hw);
3350
Bruce Allane561a702012-02-08 02:55:46 +00003351 return ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003352}
3353/**
3354 * e1000_initialize_hw_bits_ich8lan - Initialize required hardware bits
3355 * @hw: pointer to the HW structure
3356 *
3357 * Sets/Clears required hardware bits necessary for correctly setting up the
3358 * hardware for transmit and receive.
3359 **/
3360static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw)
3361{
3362 u32 reg;
3363
3364 /* Extended Device Control */
3365 reg = er32(CTRL_EXT);
3366 reg |= (1 << 22);
Bruce Allana4f58f52009-06-02 11:29:18 +00003367 /* Enable PHY low-power state when MAC is at D3 w/o WoL */
3368 if (hw->mac.type >= e1000_pchlan)
3369 reg |= E1000_CTRL_EXT_PHYPDEN;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003370 ew32(CTRL_EXT, reg);
3371
3372 /* Transmit Descriptor Control 0 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003373 reg = er32(TXDCTL(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -07003374 reg |= (1 << 22);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003375 ew32(TXDCTL(0), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003376
3377 /* Transmit Descriptor Control 1 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003378 reg = er32(TXDCTL(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -07003379 reg |= (1 << 22);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003380 ew32(TXDCTL(1), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003381
3382 /* Transmit Arbitration Control 0 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003383 reg = er32(TARC(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -07003384 if (hw->mac.type == e1000_ich8lan)
3385 reg |= (1 << 28) | (1 << 29);
3386 reg |= (1 << 23) | (1 << 24) | (1 << 26) | (1 << 27);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003387 ew32(TARC(0), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003388
3389 /* Transmit Arbitration Control 1 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003390 reg = er32(TARC(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -07003391 if (er32(TCTL) & E1000_TCTL_MULR)
3392 reg &= ~(1 << 28);
3393 else
3394 reg |= (1 << 28);
3395 reg |= (1 << 24) | (1 << 26) | (1 << 30);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003396 ew32(TARC(1), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003397
3398 /* Device Status */
3399 if (hw->mac.type == e1000_ich8lan) {
3400 reg = er32(STATUS);
3401 reg &= ~(1 << 31);
3402 ew32(STATUS, reg);
3403 }
Jesse Brandeburga80483d2010-03-05 02:21:44 +00003404
3405 /*
3406 * work-around descriptor data corruption issue during nfs v2 udp
3407 * traffic, just disable the nfs filtering capability
3408 */
3409 reg = er32(RFCTL);
3410 reg |= (E1000_RFCTL_NFSW_DIS | E1000_RFCTL_NFSR_DIS);
3411 ew32(RFCTL, reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003412}
3413
3414/**
3415 * e1000_setup_link_ich8lan - Setup flow control and link settings
3416 * @hw: pointer to the HW structure
3417 *
3418 * Determines which flow control settings to use, then configures flow
3419 * control. Calls the appropriate media-specific link configuration
3420 * function. Assuming the adapter has a valid link partner, a valid link
3421 * should be established. Assumes the hardware has previously been reset
3422 * and the transmitter and receiver are not enabled.
3423 **/
3424static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw)
3425{
Auke Kokbc7f75f2007-09-17 12:30:59 -07003426 s32 ret_val;
3427
Bruce Allan44abd5c2012-02-22 09:02:37 +00003428 if (hw->phy.ops.check_reset_block(hw))
Auke Kokbc7f75f2007-09-17 12:30:59 -07003429 return 0;
3430
Bruce Allanad680762008-03-28 09:15:03 -07003431 /*
3432 * ICH parts do not have a word in the NVM to determine
Auke Kokbc7f75f2007-09-17 12:30:59 -07003433 * the default flow control setting, so we explicitly
3434 * set it to full.
3435 */
Bruce Allan37289d92009-06-02 11:29:37 +00003436 if (hw->fc.requested_mode == e1000_fc_default) {
3437 /* Workaround h/w hang when Tx flow control enabled */
3438 if (hw->mac.type == e1000_pchlan)
3439 hw->fc.requested_mode = e1000_fc_rx_pause;
3440 else
3441 hw->fc.requested_mode = e1000_fc_full;
3442 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07003443
Bruce Allan5c48ef3e22008-11-21 16:57:36 -08003444 /*
3445 * Save off the requested flow control mode for use later. Depending
3446 * on the link partner's capabilities, we may or may not use this mode.
3447 */
3448 hw->fc.current_mode = hw->fc.requested_mode;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003449
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003450 e_dbg("After fix-ups FlowControl is now = %x\n",
Bruce Allan5c48ef3e22008-11-21 16:57:36 -08003451 hw->fc.current_mode);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003452
3453 /* Continue to configure the copper link. */
Bruce Allan944ce012012-02-22 09:02:42 +00003454 ret_val = hw->mac.ops.setup_physical_interface(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003455 if (ret_val)
3456 return ret_val;
3457
Jeff Kirsher318a94d2008-03-28 09:15:16 -07003458 ew32(FCTTV, hw->fc.pause_time);
Bruce Allana4f58f52009-06-02 11:29:18 +00003459 if ((hw->phy.type == e1000_phy_82578) ||
Bruce Alland3738bb2010-06-16 13:27:28 +00003460 (hw->phy.type == e1000_phy_82579) ||
Bruce Allana4f58f52009-06-02 11:29:18 +00003461 (hw->phy.type == e1000_phy_82577)) {
Bruce Allana3055952010-05-10 15:02:12 +00003462 ew32(FCRTV_PCH, hw->fc.refresh_time);
3463
Bruce Allan482fed82011-01-06 14:29:49 +00003464 ret_val = e1e_wphy(hw, PHY_REG(BM_PORT_CTRL_PAGE, 27),
3465 hw->fc.pause_time);
Bruce Allana4f58f52009-06-02 11:29:18 +00003466 if (ret_val)
3467 return ret_val;
3468 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07003469
3470 return e1000e_set_fc_watermarks(hw);
3471}
3472
3473/**
3474 * e1000_setup_copper_link_ich8lan - Configure MAC/PHY interface
3475 * @hw: pointer to the HW structure
3476 *
3477 * Configures the kumeran interface to the PHY to wait the appropriate time
3478 * when polling the PHY, then call the generic setup_copper_link to finish
3479 * configuring the copper link.
3480 **/
3481static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw)
3482{
3483 u32 ctrl;
3484 s32 ret_val;
3485 u16 reg_data;
3486
3487 ctrl = er32(CTRL);
3488 ctrl |= E1000_CTRL_SLU;
3489 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
3490 ew32(CTRL, ctrl);
3491
Bruce Allanad680762008-03-28 09:15:03 -07003492 /*
3493 * Set the mac to wait the maximum time between each iteration
Auke Kokbc7f75f2007-09-17 12:30:59 -07003494 * and increase the max iterations when polling the phy;
Bruce Allanad680762008-03-28 09:15:03 -07003495 * this fixes erroneous timeouts at 10Mbps.
3496 */
Bruce Allan07818952009-12-08 07:28:01 +00003497 ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_TIMEOUTS, 0xFFFF);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003498 if (ret_val)
3499 return ret_val;
Bruce Allan07818952009-12-08 07:28:01 +00003500 ret_val = e1000e_read_kmrn_reg(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
3501 &reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003502 if (ret_val)
3503 return ret_val;
3504 reg_data |= 0x3F;
Bruce Allan07818952009-12-08 07:28:01 +00003505 ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
3506 reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003507 if (ret_val)
3508 return ret_val;
3509
Bruce Allana4f58f52009-06-02 11:29:18 +00003510 switch (hw->phy.type) {
3511 case e1000_phy_igp_3:
Auke Kokbc7f75f2007-09-17 12:30:59 -07003512 ret_val = e1000e_copper_link_setup_igp(hw);
3513 if (ret_val)
3514 return ret_val;
Bruce Allana4f58f52009-06-02 11:29:18 +00003515 break;
3516 case e1000_phy_bm:
3517 case e1000_phy_82578:
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003518 ret_val = e1000e_copper_link_setup_m88(hw);
3519 if (ret_val)
3520 return ret_val;
Bruce Allana4f58f52009-06-02 11:29:18 +00003521 break;
3522 case e1000_phy_82577:
Bruce Alland3738bb2010-06-16 13:27:28 +00003523 case e1000_phy_82579:
Bruce Allana4f58f52009-06-02 11:29:18 +00003524 ret_val = e1000_copper_link_setup_82577(hw);
3525 if (ret_val)
3526 return ret_val;
3527 break;
3528 case e1000_phy_ife:
Bruce Allan482fed82011-01-06 14:29:49 +00003529 ret_val = e1e_rphy(hw, IFE_PHY_MDIX_CONTROL, &reg_data);
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003530 if (ret_val)
3531 return ret_val;
3532
3533 reg_data &= ~IFE_PMC_AUTO_MDIX;
3534
3535 switch (hw->phy.mdix) {
3536 case 1:
3537 reg_data &= ~IFE_PMC_FORCE_MDIX;
3538 break;
3539 case 2:
3540 reg_data |= IFE_PMC_FORCE_MDIX;
3541 break;
3542 case 0:
3543 default:
3544 reg_data |= IFE_PMC_AUTO_MDIX;
3545 break;
3546 }
Bruce Allan482fed82011-01-06 14:29:49 +00003547 ret_val = e1e_wphy(hw, IFE_PHY_MDIX_CONTROL, reg_data);
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003548 if (ret_val)
3549 return ret_val;
Bruce Allana4f58f52009-06-02 11:29:18 +00003550 break;
3551 default:
3552 break;
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003553 }
Bruce Allan3fa8293632012-02-08 02:55:40 +00003554
Auke Kokbc7f75f2007-09-17 12:30:59 -07003555 return e1000e_setup_copper_link(hw);
3556}
3557
3558/**
3559 * e1000_get_link_up_info_ich8lan - Get current link speed and duplex
3560 * @hw: pointer to the HW structure
3561 * @speed: pointer to store current link speed
3562 * @duplex: pointer to store the current link duplex
3563 *
Bruce Allanad680762008-03-28 09:15:03 -07003564 * Calls the generic get_speed_and_duplex to retrieve the current link
Auke Kokbc7f75f2007-09-17 12:30:59 -07003565 * information and then calls the Kumeran lock loss workaround for links at
3566 * gigabit speeds.
3567 **/
3568static s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw, u16 *speed,
3569 u16 *duplex)
3570{
3571 s32 ret_val;
3572
3573 ret_val = e1000e_get_speed_and_duplex_copper(hw, speed, duplex);
3574 if (ret_val)
3575 return ret_val;
3576
3577 if ((hw->mac.type == e1000_ich8lan) &&
3578 (hw->phy.type == e1000_phy_igp_3) &&
3579 (*speed == SPEED_1000)) {
3580 ret_val = e1000_kmrn_lock_loss_workaround_ich8lan(hw);
3581 }
3582
3583 return ret_val;
3584}
3585
3586/**
3587 * e1000_kmrn_lock_loss_workaround_ich8lan - Kumeran workaround
3588 * @hw: pointer to the HW structure
3589 *
3590 * Work-around for 82566 Kumeran PCS lock loss:
3591 * On link status change (i.e. PCI reset, speed change) and link is up and
3592 * speed is gigabit-
3593 * 0) if workaround is optionally disabled do nothing
3594 * 1) wait 1ms for Kumeran link to come up
3595 * 2) check Kumeran Diagnostic register PCS lock loss bit
3596 * 3) if not set the link is locked (all is good), otherwise...
3597 * 4) reset the PHY
3598 * 5) repeat up to 10 times
3599 * Note: this is only called for IGP3 copper when speed is 1gb.
3600 **/
3601static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw)
3602{
3603 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
3604 u32 phy_ctrl;
3605 s32 ret_val;
3606 u16 i, data;
3607 bool link;
3608
3609 if (!dev_spec->kmrn_lock_loss_workaround_enabled)
3610 return 0;
3611
Bruce Allanad680762008-03-28 09:15:03 -07003612 /*
3613 * Make sure link is up before proceeding. If not just return.
Auke Kokbc7f75f2007-09-17 12:30:59 -07003614 * Attempting this while link is negotiating fouled up link
Bruce Allanad680762008-03-28 09:15:03 -07003615 * stability
3616 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003617 ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link);
3618 if (!link)
3619 return 0;
3620
3621 for (i = 0; i < 10; i++) {
3622 /* read once to clear */
3623 ret_val = e1e_rphy(hw, IGP3_KMRN_DIAG, &data);
3624 if (ret_val)
3625 return ret_val;
3626 /* and again to get new status */
3627 ret_val = e1e_rphy(hw, IGP3_KMRN_DIAG, &data);
3628 if (ret_val)
3629 return ret_val;
3630
3631 /* check for PCS lock */
3632 if (!(data & IGP3_KMRN_DIAG_PCS_LOCK_LOSS))
3633 return 0;
3634
3635 /* Issue PHY reset */
3636 e1000_phy_hw_reset(hw);
3637 mdelay(5);
3638 }
3639 /* Disable GigE link negotiation */
3640 phy_ctrl = er32(PHY_CTRL);
3641 phy_ctrl |= (E1000_PHY_CTRL_GBE_DISABLE |
3642 E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
3643 ew32(PHY_CTRL, phy_ctrl);
3644
Bruce Allanad680762008-03-28 09:15:03 -07003645 /*
3646 * Call gig speed drop workaround on Gig disable before accessing
3647 * any PHY registers
3648 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003649 e1000e_gig_downshift_workaround_ich8lan(hw);
3650
3651 /* unable to acquire PCS lock */
3652 return -E1000_ERR_PHY;
3653}
3654
3655/**
Bruce Allan6e3c8072012-02-22 09:02:47 +00003656 * e1000e_set_kmrn_lock_loss_workaround_ich8lan - Set Kumeran workaround state
Auke Kokbc7f75f2007-09-17 12:30:59 -07003657 * @hw: pointer to the HW structure
Auke Kok489815c2008-02-21 15:11:07 -08003658 * @state: boolean value used to set the current Kumeran workaround state
Auke Kokbc7f75f2007-09-17 12:30:59 -07003659 *
Bruce Allan564ea9b2009-11-20 23:26:44 +00003660 * If ICH8, set the current Kumeran workaround state (enabled - true
3661 * /disabled - false).
Auke Kokbc7f75f2007-09-17 12:30:59 -07003662 **/
3663void e1000e_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw,
3664 bool state)
3665{
3666 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
3667
3668 if (hw->mac.type != e1000_ich8lan) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003669 e_dbg("Workaround applies to ICH8 only.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07003670 return;
3671 }
3672
3673 dev_spec->kmrn_lock_loss_workaround_enabled = state;
3674}
3675
3676/**
3677 * e1000_ipg3_phy_powerdown_workaround_ich8lan - Power down workaround on D3
3678 * @hw: pointer to the HW structure
3679 *
3680 * Workaround for 82566 power-down on D3 entry:
3681 * 1) disable gigabit link
3682 * 2) write VR power-down enable
3683 * 3) read it back
3684 * Continue if successful, else issue LCD reset and repeat
3685 **/
3686void e1000e_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw)
3687{
3688 u32 reg;
3689 u16 data;
3690 u8 retry = 0;
3691
3692 if (hw->phy.type != e1000_phy_igp_3)
3693 return;
3694
3695 /* Try the workaround twice (if needed) */
3696 do {
3697 /* Disable link */
3698 reg = er32(PHY_CTRL);
3699 reg |= (E1000_PHY_CTRL_GBE_DISABLE |
3700 E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
3701 ew32(PHY_CTRL, reg);
3702
Bruce Allanad680762008-03-28 09:15:03 -07003703 /*
3704 * Call gig speed drop workaround on Gig disable before
3705 * accessing any PHY registers
3706 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003707 if (hw->mac.type == e1000_ich8lan)
3708 e1000e_gig_downshift_workaround_ich8lan(hw);
3709
3710 /* Write VR power-down enable */
3711 e1e_rphy(hw, IGP3_VR_CTRL, &data);
3712 data &= ~IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
3713 e1e_wphy(hw, IGP3_VR_CTRL, data | IGP3_VR_CTRL_MODE_SHUTDOWN);
3714
3715 /* Read it back and test */
3716 e1e_rphy(hw, IGP3_VR_CTRL, &data);
3717 data &= IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
3718 if ((data == IGP3_VR_CTRL_MODE_SHUTDOWN) || retry)
3719 break;
3720
3721 /* Issue PHY reset and repeat at most one more time */
3722 reg = er32(CTRL);
3723 ew32(CTRL, reg | E1000_CTRL_PHY_RST);
3724 retry++;
3725 } while (retry);
3726}
3727
3728/**
3729 * e1000e_gig_downshift_workaround_ich8lan - WoL from S5 stops working
3730 * @hw: pointer to the HW structure
3731 *
3732 * Steps to take when dropping from 1Gb/s (eg. link cable removal (LSC),
Auke Kok489815c2008-02-21 15:11:07 -08003733 * LPLU, Gig disable, MDIC PHY reset):
Auke Kokbc7f75f2007-09-17 12:30:59 -07003734 * 1) Set Kumeran Near-end loopback
3735 * 2) Clear Kumeran Near-end loopback
Bruce Allan462d5992011-09-30 08:07:11 +00003736 * Should only be called for ICH8[m] devices with any 1G Phy.
Auke Kokbc7f75f2007-09-17 12:30:59 -07003737 **/
3738void e1000e_gig_downshift_workaround_ich8lan(struct e1000_hw *hw)
3739{
3740 s32 ret_val;
3741 u16 reg_data;
3742
Bruce Allan462d5992011-09-30 08:07:11 +00003743 if ((hw->mac.type != e1000_ich8lan) || (hw->phy.type == e1000_phy_ife))
Auke Kokbc7f75f2007-09-17 12:30:59 -07003744 return;
3745
3746 ret_val = e1000e_read_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
3747 &reg_data);
3748 if (ret_val)
3749 return;
3750 reg_data |= E1000_KMRNCTRLSTA_DIAG_NELPBK;
3751 ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
3752 reg_data);
3753 if (ret_val)
3754 return;
3755 reg_data &= ~E1000_KMRNCTRLSTA_DIAG_NELPBK;
3756 ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
3757 reg_data);
3758}
3759
3760/**
Bruce Allan99730e42011-05-13 07:19:48 +00003761 * e1000_suspend_workarounds_ich8lan - workarounds needed during S0->Sx
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003762 * @hw: pointer to the HW structure
3763 *
3764 * During S0 to Sx transition, it is possible the link remains at gig
3765 * instead of negotiating to a lower speed. Before going to Sx, set
Bruce Allanc077a902011-12-16 00:46:38 +00003766 * 'Gig Disable' to force link speed negotiation to a lower speed based on
3767 * the LPLU setting in the NVM or custom setting. For PCH and newer parts,
3768 * the OEM bits PHY register (LED, GbE disable and LPLU configurations) also
3769 * needs to be written.
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003770 **/
Bruce Allan99730e42011-05-13 07:19:48 +00003771void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw)
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003772{
3773 u32 phy_ctrl;
Bruce Allan8395ae82010-09-22 17:15:08 +00003774 s32 ret_val;
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003775
Bruce Allan17f085d2010-06-17 18:59:48 +00003776 phy_ctrl = er32(PHY_CTRL);
Bruce Allanc077a902011-12-16 00:46:38 +00003777 phy_ctrl |= E1000_PHY_CTRL_GBE_DISABLE;
Bruce Allan17f085d2010-06-17 18:59:48 +00003778 ew32(PHY_CTRL, phy_ctrl);
Bruce Allana4f58f52009-06-02 11:29:18 +00003779
Bruce Allan462d5992011-09-30 08:07:11 +00003780 if (hw->mac.type == e1000_ich8lan)
3781 e1000e_gig_downshift_workaround_ich8lan(hw);
3782
Bruce Allan8395ae82010-09-22 17:15:08 +00003783 if (hw->mac.type >= e1000_pchlan) {
Bruce Allance54afd2010-11-24 06:01:41 +00003784 e1000_oem_bits_config_ich8lan(hw, false);
Bruce Allan92fe1732012-04-12 06:27:03 +00003785
3786 /* Reset PHY to activate OEM bits on 82577/8 */
3787 if (hw->mac.type == e1000_pchlan)
3788 e1000e_phy_hw_reset_generic(hw);
3789
Bruce Allan8395ae82010-09-22 17:15:08 +00003790 ret_val = hw->phy.ops.acquire(hw);
3791 if (ret_val)
3792 return;
3793 e1000_write_smbus_addr(hw);
3794 hw->phy.ops.release(hw);
3795 }
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003796}
3797
3798/**
Bruce Allan99730e42011-05-13 07:19:48 +00003799 * e1000_resume_workarounds_pchlan - workarounds needed during Sx->S0
3800 * @hw: pointer to the HW structure
3801 *
3802 * During Sx to S0 transitions on non-managed devices or managed devices
3803 * on which PHY resets are not blocked, if the PHY registers cannot be
3804 * accessed properly by the s/w toggle the LANPHYPC value to power cycle
3805 * the PHY.
3806 **/
3807void e1000_resume_workarounds_pchlan(struct e1000_hw *hw)
3808{
Bruce Allan90b82982011-12-16 00:46:33 +00003809 s32 ret_val;
Bruce Allan99730e42011-05-13 07:19:48 +00003810
Bruce Allancb17aab2012-04-13 03:16:22 +00003811 if (hw->mac.type < e1000_pch2lan)
Bruce Allan99730e42011-05-13 07:19:48 +00003812 return;
3813
Bruce Allancb17aab2012-04-13 03:16:22 +00003814 ret_val = e1000_init_phy_workarounds_pchlan(hw);
Bruce Allan90b82982011-12-16 00:46:33 +00003815 if (ret_val) {
Bruce Allancb17aab2012-04-13 03:16:22 +00003816 e_dbg("Failed to init PHY flow ret_val=%d\n", ret_val);
Bruce Allan99730e42011-05-13 07:19:48 +00003817 return;
3818 }
Bruce Allan99730e42011-05-13 07:19:48 +00003819}
3820
3821/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07003822 * e1000_cleanup_led_ich8lan - Restore the default LED operation
3823 * @hw: pointer to the HW structure
3824 *
3825 * Return the LED back to the default configuration.
3826 **/
3827static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw)
3828{
3829 if (hw->phy.type == e1000_phy_ife)
3830 return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED, 0);
3831
3832 ew32(LEDCTL, hw->mac.ledctl_default);
3833 return 0;
3834}
3835
3836/**
Auke Kok489815c2008-02-21 15:11:07 -08003837 * e1000_led_on_ich8lan - Turn LEDs on
Auke Kokbc7f75f2007-09-17 12:30:59 -07003838 * @hw: pointer to the HW structure
3839 *
Auke Kok489815c2008-02-21 15:11:07 -08003840 * Turn on the LEDs.
Auke Kokbc7f75f2007-09-17 12:30:59 -07003841 **/
3842static s32 e1000_led_on_ich8lan(struct e1000_hw *hw)
3843{
3844 if (hw->phy.type == e1000_phy_ife)
3845 return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED,
3846 (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_ON));
3847
3848 ew32(LEDCTL, hw->mac.ledctl_mode2);
3849 return 0;
3850}
3851
3852/**
Auke Kok489815c2008-02-21 15:11:07 -08003853 * e1000_led_off_ich8lan - Turn LEDs off
Auke Kokbc7f75f2007-09-17 12:30:59 -07003854 * @hw: pointer to the HW structure
3855 *
Auke Kok489815c2008-02-21 15:11:07 -08003856 * Turn off the LEDs.
Auke Kokbc7f75f2007-09-17 12:30:59 -07003857 **/
3858static s32 e1000_led_off_ich8lan(struct e1000_hw *hw)
3859{
3860 if (hw->phy.type == e1000_phy_ife)
3861 return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED,
Bruce Allan482fed82011-01-06 14:29:49 +00003862 (IFE_PSCL_PROBE_MODE |
3863 IFE_PSCL_PROBE_LEDS_OFF));
Auke Kokbc7f75f2007-09-17 12:30:59 -07003864
3865 ew32(LEDCTL, hw->mac.ledctl_mode1);
3866 return 0;
3867}
3868
3869/**
Bruce Allana4f58f52009-06-02 11:29:18 +00003870 * e1000_setup_led_pchlan - Configures SW controllable LED
3871 * @hw: pointer to the HW structure
3872 *
3873 * This prepares the SW controllable LED for use.
3874 **/
3875static s32 e1000_setup_led_pchlan(struct e1000_hw *hw)
3876{
Bruce Allan482fed82011-01-06 14:29:49 +00003877 return e1e_wphy(hw, HV_LED_CONFIG, (u16)hw->mac.ledctl_mode1);
Bruce Allana4f58f52009-06-02 11:29:18 +00003878}
3879
3880/**
3881 * e1000_cleanup_led_pchlan - Restore the default LED operation
3882 * @hw: pointer to the HW structure
3883 *
3884 * Return the LED back to the default configuration.
3885 **/
3886static s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw)
3887{
Bruce Allan482fed82011-01-06 14:29:49 +00003888 return e1e_wphy(hw, HV_LED_CONFIG, (u16)hw->mac.ledctl_default);
Bruce Allana4f58f52009-06-02 11:29:18 +00003889}
3890
3891/**
3892 * e1000_led_on_pchlan - Turn LEDs on
3893 * @hw: pointer to the HW structure
3894 *
3895 * Turn on the LEDs.
3896 **/
3897static s32 e1000_led_on_pchlan(struct e1000_hw *hw)
3898{
3899 u16 data = (u16)hw->mac.ledctl_mode2;
3900 u32 i, led;
3901
3902 /*
3903 * If no link, then turn LED on by setting the invert bit
3904 * for each LED that's mode is "link_up" in ledctl_mode2.
3905 */
3906 if (!(er32(STATUS) & E1000_STATUS_LU)) {
3907 for (i = 0; i < 3; i++) {
3908 led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
3909 if ((led & E1000_PHY_LED0_MODE_MASK) !=
3910 E1000_LEDCTL_MODE_LINK_UP)
3911 continue;
3912 if (led & E1000_PHY_LED0_IVRT)
3913 data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
3914 else
3915 data |= (E1000_PHY_LED0_IVRT << (i * 5));
3916 }
3917 }
3918
Bruce Allan482fed82011-01-06 14:29:49 +00003919 return e1e_wphy(hw, HV_LED_CONFIG, data);
Bruce Allana4f58f52009-06-02 11:29:18 +00003920}
3921
3922/**
3923 * e1000_led_off_pchlan - Turn LEDs off
3924 * @hw: pointer to the HW structure
3925 *
3926 * Turn off the LEDs.
3927 **/
3928static s32 e1000_led_off_pchlan(struct e1000_hw *hw)
3929{
3930 u16 data = (u16)hw->mac.ledctl_mode1;
3931 u32 i, led;
3932
3933 /*
3934 * If no link, then turn LED off by clearing the invert bit
3935 * for each LED that's mode is "link_up" in ledctl_mode1.
3936 */
3937 if (!(er32(STATUS) & E1000_STATUS_LU)) {
3938 for (i = 0; i < 3; i++) {
3939 led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
3940 if ((led & E1000_PHY_LED0_MODE_MASK) !=
3941 E1000_LEDCTL_MODE_LINK_UP)
3942 continue;
3943 if (led & E1000_PHY_LED0_IVRT)
3944 data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
3945 else
3946 data |= (E1000_PHY_LED0_IVRT << (i * 5));
3947 }
3948 }
3949
Bruce Allan482fed82011-01-06 14:29:49 +00003950 return e1e_wphy(hw, HV_LED_CONFIG, data);
Bruce Allana4f58f52009-06-02 11:29:18 +00003951}
3952
3953/**
Bruce Allane98cac42010-05-10 15:02:32 +00003954 * e1000_get_cfg_done_ich8lan - Read config done bit after Full or PHY reset
Bruce Allanf4187b52008-08-26 18:36:50 -07003955 * @hw: pointer to the HW structure
3956 *
Bruce Allane98cac42010-05-10 15:02:32 +00003957 * Read appropriate register for the config done bit for completion status
3958 * and configure the PHY through s/w for EEPROM-less parts.
3959 *
3960 * NOTE: some silicon which is EEPROM-less will fail trying to read the
3961 * config done bit, so only an error is logged and continues. If we were
3962 * to return with error, EEPROM-less silicon would not be able to be reset
3963 * or change link.
Bruce Allanf4187b52008-08-26 18:36:50 -07003964 **/
3965static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw)
3966{
Bruce Allane98cac42010-05-10 15:02:32 +00003967 s32 ret_val = 0;
Bruce Allanf4187b52008-08-26 18:36:50 -07003968 u32 bank = 0;
Bruce Allane98cac42010-05-10 15:02:32 +00003969 u32 status;
Bruce Allanfc0c7762009-07-01 13:27:55 +00003970
Bruce Allanf4187b52008-08-26 18:36:50 -07003971 e1000e_get_cfg_done(hw);
3972
Bruce Allane98cac42010-05-10 15:02:32 +00003973 /* Wait for indication from h/w that it has completed basic config */
3974 if (hw->mac.type >= e1000_ich10lan) {
3975 e1000_lan_init_done_ich8lan(hw);
3976 } else {
3977 ret_val = e1000e_get_auto_rd_done(hw);
3978 if (ret_val) {
3979 /*
3980 * When auto config read does not complete, do not
3981 * return with an error. This can happen in situations
3982 * where there is no eeprom and prevents getting link.
3983 */
3984 e_dbg("Auto Read Done did not complete\n");
3985 ret_val = 0;
3986 }
3987 }
3988
3989 /* Clear PHY Reset Asserted bit */
3990 status = er32(STATUS);
3991 if (status & E1000_STATUS_PHYRA)
3992 ew32(STATUS, status & ~E1000_STATUS_PHYRA);
3993 else
3994 e_dbg("PHY Reset Asserted not set - needs delay\n");
3995
Bruce Allanf4187b52008-08-26 18:36:50 -07003996 /* If EEPROM is not marked present, init the IGP 3 PHY manually */
Bruce Allane98cac42010-05-10 15:02:32 +00003997 if (hw->mac.type <= e1000_ich9lan) {
Bruce Allan04499ec2012-04-13 00:08:31 +00003998 if (!(er32(EECD) & E1000_EECD_PRES) &&
Bruce Allanf4187b52008-08-26 18:36:50 -07003999 (hw->phy.type == e1000_phy_igp_3)) {
4000 e1000e_phy_init_script_igp3(hw);
4001 }
4002 } else {
4003 if (e1000_valid_nvm_bank_detect_ich8lan(hw, &bank)) {
4004 /* Maybe we should do a basic PHY config */
Bruce Allan3bb99fe2009-11-20 23:25:07 +00004005 e_dbg("EEPROM not present\n");
Bruce Allane98cac42010-05-10 15:02:32 +00004006 ret_val = -E1000_ERR_CONFIG;
Bruce Allanf4187b52008-08-26 18:36:50 -07004007 }
4008 }
4009
Bruce Allane98cac42010-05-10 15:02:32 +00004010 return ret_val;
Bruce Allanf4187b52008-08-26 18:36:50 -07004011}
4012
4013/**
Bruce Allan17f208d2009-12-01 15:47:22 +00004014 * e1000_power_down_phy_copper_ich8lan - Remove link during PHY power down
4015 * @hw: pointer to the HW structure
4016 *
4017 * In the case of a PHY power down to save power, or to turn off link during a
4018 * driver unload, or wake on lan is not enabled, remove the link.
4019 **/
4020static void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw)
4021{
4022 /* If the management interface is not enabled, then power down */
4023 if (!(hw->mac.ops.check_mng_mode(hw) ||
4024 hw->phy.ops.check_reset_block(hw)))
4025 e1000_power_down_phy_copper(hw);
Bruce Allan17f208d2009-12-01 15:47:22 +00004026}
4027
4028/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07004029 * e1000_clear_hw_cntrs_ich8lan - Clear statistical counters
4030 * @hw: pointer to the HW structure
4031 *
4032 * Clears hardware counters specific to the silicon family and calls
4033 * clear_hw_cntrs_generic to clear all general purpose counters.
4034 **/
4035static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw)
4036{
Bruce Allana4f58f52009-06-02 11:29:18 +00004037 u16 phy_data;
Bruce Allan2b6b1682011-05-13 07:20:09 +00004038 s32 ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -07004039
4040 e1000e_clear_hw_cntrs_base(hw);
4041
Bruce Allan99673d92009-11-20 23:27:21 +00004042 er32(ALGNERRC);
4043 er32(RXERRC);
4044 er32(TNCRS);
4045 er32(CEXTERR);
4046 er32(TSCTC);
4047 er32(TSCTFC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07004048
Bruce Allan99673d92009-11-20 23:27:21 +00004049 er32(MGTPRC);
4050 er32(MGTPDC);
4051 er32(MGTPTC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07004052
Bruce Allan99673d92009-11-20 23:27:21 +00004053 er32(IAC);
4054 er32(ICRXOC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07004055
Bruce Allana4f58f52009-06-02 11:29:18 +00004056 /* Clear PHY statistics registers */
4057 if ((hw->phy.type == e1000_phy_82578) ||
Bruce Alland3738bb2010-06-16 13:27:28 +00004058 (hw->phy.type == e1000_phy_82579) ||
Bruce Allana4f58f52009-06-02 11:29:18 +00004059 (hw->phy.type == e1000_phy_82577)) {
Bruce Allan2b6b1682011-05-13 07:20:09 +00004060 ret_val = hw->phy.ops.acquire(hw);
4061 if (ret_val)
4062 return;
4063 ret_val = hw->phy.ops.set_page(hw,
4064 HV_STATS_PAGE << IGP_PAGE_SHIFT);
4065 if (ret_val)
4066 goto release;
4067 hw->phy.ops.read_reg_page(hw, HV_SCC_UPPER, &phy_data);
4068 hw->phy.ops.read_reg_page(hw, HV_SCC_LOWER, &phy_data);
4069 hw->phy.ops.read_reg_page(hw, HV_ECOL_UPPER, &phy_data);
4070 hw->phy.ops.read_reg_page(hw, HV_ECOL_LOWER, &phy_data);
4071 hw->phy.ops.read_reg_page(hw, HV_MCC_UPPER, &phy_data);
4072 hw->phy.ops.read_reg_page(hw, HV_MCC_LOWER, &phy_data);
4073 hw->phy.ops.read_reg_page(hw, HV_LATECOL_UPPER, &phy_data);
4074 hw->phy.ops.read_reg_page(hw, HV_LATECOL_LOWER, &phy_data);
4075 hw->phy.ops.read_reg_page(hw, HV_COLC_UPPER, &phy_data);
4076 hw->phy.ops.read_reg_page(hw, HV_COLC_LOWER, &phy_data);
4077 hw->phy.ops.read_reg_page(hw, HV_DC_UPPER, &phy_data);
4078 hw->phy.ops.read_reg_page(hw, HV_DC_LOWER, &phy_data);
4079 hw->phy.ops.read_reg_page(hw, HV_TNCRS_UPPER, &phy_data);
4080 hw->phy.ops.read_reg_page(hw, HV_TNCRS_LOWER, &phy_data);
4081release:
4082 hw->phy.ops.release(hw);
Bruce Allana4f58f52009-06-02 11:29:18 +00004083 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07004084}
4085
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00004086static const struct e1000_mac_operations ich8_mac_ops = {
Bruce Allaneb7700d2010-06-16 13:27:05 +00004087 /* check_mng_mode dependent on mac type */
Bruce Allan7d3cabb2009-07-01 13:29:08 +00004088 .check_for_link = e1000_check_for_copper_link_ich8lan,
Bruce Allana4f58f52009-06-02 11:29:18 +00004089 /* cleanup_led dependent on mac type */
Auke Kokbc7f75f2007-09-17 12:30:59 -07004090 .clear_hw_cntrs = e1000_clear_hw_cntrs_ich8lan,
4091 .get_bus_info = e1000_get_bus_info_ich8lan,
Bruce Allanf4d2dd42010-01-13 02:05:18 +00004092 .set_lan_id = e1000_set_lan_id_single_port,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004093 .get_link_up_info = e1000_get_link_up_info_ich8lan,
Bruce Allana4f58f52009-06-02 11:29:18 +00004094 /* led_on dependent on mac type */
4095 /* led_off dependent on mac type */
Jeff Kirshere2de3eb2008-03-28 09:15:11 -07004096 .update_mc_addr_list = e1000e_update_mc_addr_list_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004097 .reset_hw = e1000_reset_hw_ich8lan,
4098 .init_hw = e1000_init_hw_ich8lan,
4099 .setup_link = e1000_setup_link_ich8lan,
4100 .setup_physical_interface= e1000_setup_copper_link_ich8lan,
Bruce Allana4f58f52009-06-02 11:29:18 +00004101 /* id_led_init dependent on mac type */
Bruce Allan57cde762012-02-22 09:02:58 +00004102 .config_collision_dist = e1000e_config_collision_dist_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004103};
4104
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00004105static const struct e1000_phy_operations ich8_phy_ops = {
Bruce Allan94d81862009-11-20 23:25:26 +00004106 .acquire = e1000_acquire_swflag_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004107 .check_reset_block = e1000_check_reset_block_ich8lan,
Bruce Allan94d81862009-11-20 23:25:26 +00004108 .commit = NULL,
Bruce Allanf4187b52008-08-26 18:36:50 -07004109 .get_cfg_done = e1000_get_cfg_done_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004110 .get_cable_length = e1000e_get_cable_length_igp_2,
Bruce Allan94d81862009-11-20 23:25:26 +00004111 .read_reg = e1000e_read_phy_reg_igp,
4112 .release = e1000_release_swflag_ich8lan,
4113 .reset = e1000_phy_hw_reset_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004114 .set_d0_lplu_state = e1000_set_d0_lplu_state_ich8lan,
4115 .set_d3_lplu_state = e1000_set_d3_lplu_state_ich8lan,
Bruce Allan94d81862009-11-20 23:25:26 +00004116 .write_reg = e1000e_write_phy_reg_igp,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004117};
4118
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00004119static const struct e1000_nvm_operations ich8_nvm_ops = {
Bruce Allan94d81862009-11-20 23:25:26 +00004120 .acquire = e1000_acquire_nvm_ich8lan,
4121 .read = e1000_read_nvm_ich8lan,
4122 .release = e1000_release_nvm_ich8lan,
Bruce Allane85e3632012-02-22 09:03:14 +00004123 .reload = e1000e_reload_nvm_generic,
Bruce Allan94d81862009-11-20 23:25:26 +00004124 .update = e1000_update_nvm_checksum_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004125 .valid_led_default = e1000_valid_led_default_ich8lan,
Bruce Allan94d81862009-11-20 23:25:26 +00004126 .validate = e1000_validate_nvm_checksum_ich8lan,
4127 .write = e1000_write_nvm_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004128};
4129
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00004130const struct e1000_info e1000_ich8_info = {
Auke Kokbc7f75f2007-09-17 12:30:59 -07004131 .mac = e1000_ich8lan,
4132 .flags = FLAG_HAS_WOL
Bruce Allan97ac8ca2008-04-29 09:16:05 -07004133 | FLAG_IS_ICH
Auke Kokbc7f75f2007-09-17 12:30:59 -07004134 | FLAG_HAS_CTRLEXT_ON_LOAD
4135 | FLAG_HAS_AMT
4136 | FLAG_HAS_FLASH
4137 | FLAG_APME_IN_WUC,
4138 .pba = 8,
Bruce Allan2adc55c2009-06-02 11:28:58 +00004139 .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN,
Jeff Kirsher69e3fd82008-04-02 13:48:18 -07004140 .get_variants = e1000_get_variants_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004141 .mac_ops = &ich8_mac_ops,
4142 .phy_ops = &ich8_phy_ops,
4143 .nvm_ops = &ich8_nvm_ops,
4144};
4145
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00004146const struct e1000_info e1000_ich9_info = {
Auke Kokbc7f75f2007-09-17 12:30:59 -07004147 .mac = e1000_ich9lan,
4148 .flags = FLAG_HAS_JUMBO_FRAMES
Bruce Allan97ac8ca2008-04-29 09:16:05 -07004149 | FLAG_IS_ICH
Auke Kokbc7f75f2007-09-17 12:30:59 -07004150 | FLAG_HAS_WOL
Auke Kokbc7f75f2007-09-17 12:30:59 -07004151 | FLAG_HAS_CTRLEXT_ON_LOAD
4152 | FLAG_HAS_AMT
Auke Kokbc7f75f2007-09-17 12:30:59 -07004153 | FLAG_HAS_FLASH
4154 | FLAG_APME_IN_WUC,
Bruce Allan7f1557e2011-12-16 00:46:43 +00004155 .pba = 18,
Bruce Allan2adc55c2009-06-02 11:28:58 +00004156 .max_hw_frame_size = DEFAULT_JUMBO,
Jeff Kirsher69e3fd82008-04-02 13:48:18 -07004157 .get_variants = e1000_get_variants_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004158 .mac_ops = &ich8_mac_ops,
4159 .phy_ops = &ich8_phy_ops,
4160 .nvm_ops = &ich8_nvm_ops,
4161};
4162
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00004163const struct e1000_info e1000_ich10_info = {
Bruce Allanf4187b52008-08-26 18:36:50 -07004164 .mac = e1000_ich10lan,
4165 .flags = FLAG_HAS_JUMBO_FRAMES
4166 | FLAG_IS_ICH
4167 | FLAG_HAS_WOL
Bruce Allanf4187b52008-08-26 18:36:50 -07004168 | FLAG_HAS_CTRLEXT_ON_LOAD
4169 | FLAG_HAS_AMT
Bruce Allanf4187b52008-08-26 18:36:50 -07004170 | FLAG_HAS_FLASH
4171 | FLAG_APME_IN_WUC,
Bruce Allan7f1557e2011-12-16 00:46:43 +00004172 .pba = 18,
Bruce Allan2adc55c2009-06-02 11:28:58 +00004173 .max_hw_frame_size = DEFAULT_JUMBO,
Bruce Allanf4187b52008-08-26 18:36:50 -07004174 .get_variants = e1000_get_variants_ich8lan,
4175 .mac_ops = &ich8_mac_ops,
4176 .phy_ops = &ich8_phy_ops,
4177 .nvm_ops = &ich8_nvm_ops,
4178};
Bruce Allana4f58f52009-06-02 11:29:18 +00004179
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00004180const struct e1000_info e1000_pch_info = {
Bruce Allana4f58f52009-06-02 11:29:18 +00004181 .mac = e1000_pchlan,
4182 .flags = FLAG_IS_ICH
4183 | FLAG_HAS_WOL
Bruce Allana4f58f52009-06-02 11:29:18 +00004184 | FLAG_HAS_CTRLEXT_ON_LOAD
4185 | FLAG_HAS_AMT
4186 | FLAG_HAS_FLASH
4187 | FLAG_HAS_JUMBO_FRAMES
Bruce Allan38eb3942009-11-19 12:34:20 +00004188 | FLAG_DISABLE_FC_PAUSE_TIME /* errata */
Bruce Allana4f58f52009-06-02 11:29:18 +00004189 | FLAG_APME_IN_WUC,
Bruce Allan8c7bbb92010-06-16 13:26:41 +00004190 .flags2 = FLAG2_HAS_PHY_STATS,
Bruce Allana4f58f52009-06-02 11:29:18 +00004191 .pba = 26,
4192 .max_hw_frame_size = 4096,
4193 .get_variants = e1000_get_variants_ich8lan,
4194 .mac_ops = &ich8_mac_ops,
4195 .phy_ops = &ich8_phy_ops,
4196 .nvm_ops = &ich8_nvm_ops,
4197};
Bruce Alland3738bb2010-06-16 13:27:28 +00004198
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00004199const struct e1000_info e1000_pch2_info = {
Bruce Alland3738bb2010-06-16 13:27:28 +00004200 .mac = e1000_pch2lan,
4201 .flags = FLAG_IS_ICH
4202 | FLAG_HAS_WOL
Bruce Alland3738bb2010-06-16 13:27:28 +00004203 | FLAG_HAS_CTRLEXT_ON_LOAD
4204 | FLAG_HAS_AMT
4205 | FLAG_HAS_FLASH
4206 | FLAG_HAS_JUMBO_FRAMES
4207 | FLAG_APME_IN_WUC,
Bruce Allane52997f2010-06-16 13:27:49 +00004208 .flags2 = FLAG2_HAS_PHY_STATS
4209 | FLAG2_HAS_EEE,
Bruce Allan828bac82010-09-29 21:39:37 +00004210 .pba = 26,
Bruce Alland3738bb2010-06-16 13:27:28 +00004211 .max_hw_frame_size = DEFAULT_JUMBO,
4212 .get_variants = e1000_get_variants_ich8lan,
4213 .mac_ops = &ich8_mac_ops,
4214 .phy_ops = &ich8_phy_ops,
4215 .nvm_ops = &ich8_nvm_ops,
4216};