blob: 2506ee275312f9e6f239b7cb37721a25573ec11f [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 Allan99730e42011-05-13 07:19:48 +0000290static void e1000_toggle_lanphypc_value_ich8lan(struct e1000_hw *hw)
291{
Bruce Allan62bc8132012-03-20 03:47:57 +0000292 u32 reg;
Bruce Allan99730e42011-05-13 07:19:48 +0000293
Bruce Allan62bc8132012-03-20 03:47:57 +0000294 /* Set Phy Config Counter to 50msec */
295 reg = er32(FEXTNVM3);
296 reg &= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK;
297 reg |= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC;
298 ew32(FEXTNVM3, reg);
299
300 /* Toggle LANPHYPC Value bit */
301 reg = er32(CTRL);
302 reg |= E1000_CTRL_LANPHYPC_OVERRIDE;
303 reg &= ~E1000_CTRL_LANPHYPC_VALUE;
304 ew32(CTRL, reg);
Jesse Brandeburg945a5152011-07-20 00:56:21 +0000305 e1e_flush();
Bruce Allan99730e42011-05-13 07:19:48 +0000306 udelay(10);
Bruce Allan62bc8132012-03-20 03:47:57 +0000307 reg &= ~E1000_CTRL_LANPHYPC_OVERRIDE;
308 ew32(CTRL, reg);
Bruce Allan99730e42011-05-13 07:19:48 +0000309}
310
Auke Kokbc7f75f2007-09-17 12:30:59 -0700311/**
Bruce Allana4f58f52009-06-02 11:29:18 +0000312 * e1000_init_phy_params_pchlan - Initialize PHY function pointers
313 * @hw: pointer to the HW structure
314 *
315 * Initialize family-specific PHY parameters and function pointers.
316 **/
317static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw)
318{
319 struct e1000_phy_info *phy = &hw->phy;
320 s32 ret_val = 0;
321
322 phy->addr = 1;
323 phy->reset_delay_us = 100;
324
Bruce Allan2b6b1682011-05-13 07:20:09 +0000325 phy->ops.set_page = e1000_set_page_igp;
Bruce Allan94d81862009-11-20 23:25:26 +0000326 phy->ops.read_reg = e1000_read_phy_reg_hv;
327 phy->ops.read_reg_locked = e1000_read_phy_reg_hv_locked;
Bruce Allan2b6b1682011-05-13 07:20:09 +0000328 phy->ops.read_reg_page = e1000_read_phy_reg_page_hv;
Bruce Allanfa2ce132009-10-26 11:23:25 +0000329 phy->ops.set_d0_lplu_state = e1000_set_lplu_state_pchlan;
330 phy->ops.set_d3_lplu_state = e1000_set_lplu_state_pchlan;
Bruce Allan94d81862009-11-20 23:25:26 +0000331 phy->ops.write_reg = e1000_write_phy_reg_hv;
332 phy->ops.write_reg_locked = e1000_write_phy_reg_hv_locked;
Bruce Allan2b6b1682011-05-13 07:20:09 +0000333 phy->ops.write_reg_page = e1000_write_phy_reg_page_hv;
Bruce Allan17f208d2009-12-01 15:47:22 +0000334 phy->ops.power_up = e1000_power_up_phy_copper;
335 phy->ops.power_down = e1000_power_down_phy_copper_ich8lan;
Bruce Allana4f58f52009-06-02 11:29:18 +0000336 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
337
Bruce Allan44abd5c2012-02-22 09:02:37 +0000338 if (!hw->phy.ops.check_reset_block(hw)) {
Bruce Allan90b82982011-12-16 00:46:33 +0000339 u32 fwsm = er32(FWSM);
340
341 /*
342 * The MAC-PHY interconnect may still be in SMBus mode after
343 * Sx->S0. If resetting the PHY is not blocked, toggle the
344 * LANPHYPC Value bit to force the interconnect to PCIe mode.
345 */
Bruce Allan99730e42011-05-13 07:19:48 +0000346 e1000_toggle_lanphypc_value_ich8lan(hw);
Bruce Allan6dfaa762010-05-05 22:00:06 +0000347 msleep(50);
Bruce Allan605c82b2010-09-22 17:17:01 +0000348
349 /*
350 * Gate automatic PHY configuration by hardware on
351 * non-managed 82579
352 */
Bruce Allan90b82982011-12-16 00:46:33 +0000353 if ((hw->mac.type == e1000_pch2lan) &&
354 !(fwsm & E1000_ICH_FWSM_FW_VALID))
Bruce Allan605c82b2010-09-22 17:17:01 +0000355 e1000_gate_hw_phy_config_ich8lan(hw, true);
Bruce Allan6dfaa762010-05-05 22:00:06 +0000356
Bruce Allan90b82982011-12-16 00:46:33 +0000357 /*
358 * Reset the PHY before any access to it. Doing so, ensures
359 * that the PHY is in a known good state before we read/write
360 * PHY registers. The generic reset is sufficient here,
361 * because we haven't determined the PHY type yet.
362 */
363 ret_val = e1000e_phy_hw_reset_generic(hw);
364 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +0000365 return ret_val;
Bruce Allan627c8a02010-05-05 22:00:27 +0000366
Bruce Allan90b82982011-12-16 00:46:33 +0000367 /* Ungate automatic PHY configuration on non-managed 82579 */
368 if ((hw->mac.type == e1000_pch2lan) &&
369 !(fwsm & E1000_ICH_FWSM_FW_VALID)) {
370 usleep_range(10000, 20000);
371 e1000_gate_hw_phy_config_ich8lan(hw, false);
372 }
Bruce Allan605c82b2010-09-22 17:17:01 +0000373 }
374
Bruce Allana4f58f52009-06-02 11:29:18 +0000375 phy->id = e1000_phy_unknown;
Bruce Allan664dc872010-11-24 06:01:46 +0000376 switch (hw->mac.type) {
377 default:
378 ret_val = e1000e_get_phy_id(hw);
379 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +0000380 return ret_val;
Bruce Allan664dc872010-11-24 06:01:46 +0000381 if ((phy->id != 0) && (phy->id != PHY_REVISION_MASK))
382 break;
383 /* fall-through */
384 case e1000_pch2lan:
Bruce Allanfddaa1a2010-01-13 01:52:49 +0000385 /*
Bruce Allan664dc872010-11-24 06:01:46 +0000386 * In case the PHY needs to be in mdio slow mode,
Bruce Allanfddaa1a2010-01-13 01:52:49 +0000387 * set slow mode and try to get the PHY id again.
388 */
389 ret_val = e1000_set_mdio_slow_mode_hv(hw);
390 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +0000391 return ret_val;
Bruce Allanfddaa1a2010-01-13 01:52:49 +0000392 ret_val = e1000e_get_phy_id(hw);
393 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +0000394 return ret_val;
Bruce Allan664dc872010-11-24 06:01:46 +0000395 break;
Bruce Allanfddaa1a2010-01-13 01:52:49 +0000396 }
Bruce Allana4f58f52009-06-02 11:29:18 +0000397 phy->type = e1000e_get_phy_type_from_id(phy->id);
398
Bruce Allan0be84012009-12-02 17:03:18 +0000399 switch (phy->type) {
400 case e1000_phy_82577:
Bruce Alland3738bb2010-06-16 13:27:28 +0000401 case e1000_phy_82579:
Bruce Allana4f58f52009-06-02 11:29:18 +0000402 phy->ops.check_polarity = e1000_check_polarity_82577;
403 phy->ops.force_speed_duplex =
Bruce Allan6cc7aae2011-02-25 06:25:18 +0000404 e1000_phy_force_speed_duplex_82577;
Bruce Allan0be84012009-12-02 17:03:18 +0000405 phy->ops.get_cable_length = e1000_get_cable_length_82577;
Bruce Allan94d81862009-11-20 23:25:26 +0000406 phy->ops.get_info = e1000_get_phy_info_82577;
407 phy->ops.commit = e1000e_phy_sw_reset;
Bruce Allaneab50ff2010-05-10 15:01:30 +0000408 break;
Bruce Allan0be84012009-12-02 17:03:18 +0000409 case e1000_phy_82578:
410 phy->ops.check_polarity = e1000_check_polarity_m88;
411 phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_m88;
412 phy->ops.get_cable_length = e1000e_get_cable_length_m88;
413 phy->ops.get_info = e1000e_get_phy_info_m88;
414 break;
415 default:
416 ret_val = -E1000_ERR_PHY;
417 break;
Bruce Allana4f58f52009-06-02 11:29:18 +0000418 }
419
420 return ret_val;
421}
422
423/**
Auke Kokbc7f75f2007-09-17 12:30:59 -0700424 * e1000_init_phy_params_ich8lan - Initialize PHY function pointers
425 * @hw: pointer to the HW structure
426 *
427 * Initialize family-specific PHY parameters and function pointers.
428 **/
429static s32 e1000_init_phy_params_ich8lan(struct e1000_hw *hw)
430{
431 struct e1000_phy_info *phy = &hw->phy;
432 s32 ret_val;
433 u16 i = 0;
434
435 phy->addr = 1;
436 phy->reset_delay_us = 100;
437
Bruce Allan17f208d2009-12-01 15:47:22 +0000438 phy->ops.power_up = e1000_power_up_phy_copper;
439 phy->ops.power_down = e1000_power_down_phy_copper_ich8lan;
440
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700441 /*
442 * We may need to do this twice - once for IGP and if that fails,
443 * we'll set BM func pointers and try again
444 */
445 ret_val = e1000e_determine_phy_address(hw);
446 if (ret_val) {
Bruce Allan94d81862009-11-20 23:25:26 +0000447 phy->ops.write_reg = e1000e_write_phy_reg_bm;
448 phy->ops.read_reg = e1000e_read_phy_reg_bm;
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700449 ret_val = e1000e_determine_phy_address(hw);
Bruce Allan9b71b412009-12-01 15:53:07 +0000450 if (ret_val) {
451 e_dbg("Cannot determine PHY addr. Erroring out\n");
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700452 return ret_val;
Bruce Allan9b71b412009-12-01 15:53:07 +0000453 }
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700454 }
455
Auke Kokbc7f75f2007-09-17 12:30:59 -0700456 phy->id = 0;
457 while ((e1000_phy_unknown == e1000e_get_phy_type_from_id(phy->id)) &&
458 (i++ < 100)) {
Bruce Allan1bba4382011-03-19 00:27:20 +0000459 usleep_range(1000, 2000);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700460 ret_val = e1000e_get_phy_id(hw);
461 if (ret_val)
462 return ret_val;
463 }
464
465 /* Verify phy id */
466 switch (phy->id) {
467 case IGP03E1000_E_PHY_ID:
468 phy->type = e1000_phy_igp_3;
469 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
Bruce Allan94d81862009-11-20 23:25:26 +0000470 phy->ops.read_reg_locked = e1000e_read_phy_reg_igp_locked;
471 phy->ops.write_reg_locked = e1000e_write_phy_reg_igp_locked;
Bruce Allan0be84012009-12-02 17:03:18 +0000472 phy->ops.get_info = e1000e_get_phy_info_igp;
473 phy->ops.check_polarity = e1000_check_polarity_igp;
474 phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_igp;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700475 break;
476 case IFE_E_PHY_ID:
477 case IFE_PLUS_E_PHY_ID:
478 case IFE_C_E_PHY_ID:
479 phy->type = e1000_phy_ife;
480 phy->autoneg_mask = E1000_ALL_NOT_GIG;
Bruce Allan0be84012009-12-02 17:03:18 +0000481 phy->ops.get_info = e1000_get_phy_info_ife;
482 phy->ops.check_polarity = e1000_check_polarity_ife;
483 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_ife;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700484 break;
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700485 case BME1000_E_PHY_ID:
486 phy->type = e1000_phy_bm;
487 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
Bruce Allan94d81862009-11-20 23:25:26 +0000488 phy->ops.read_reg = e1000e_read_phy_reg_bm;
489 phy->ops.write_reg = e1000e_write_phy_reg_bm;
490 phy->ops.commit = e1000e_phy_sw_reset;
Bruce Allan0be84012009-12-02 17:03:18 +0000491 phy->ops.get_info = e1000e_get_phy_info_m88;
492 phy->ops.check_polarity = e1000_check_polarity_m88;
493 phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_m88;
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700494 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700495 default:
496 return -E1000_ERR_PHY;
497 break;
498 }
499
500 return 0;
501}
502
503/**
504 * e1000_init_nvm_params_ich8lan - Initialize NVM function pointers
505 * @hw: pointer to the HW structure
506 *
507 * Initialize family-specific NVM parameters and function
508 * pointers.
509 **/
510static s32 e1000_init_nvm_params_ich8lan(struct e1000_hw *hw)
511{
512 struct e1000_nvm_info *nvm = &hw->nvm;
513 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
Bruce Allan148675a2009-08-07 07:41:56 +0000514 u32 gfpreg, sector_base_addr, sector_end_addr;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700515 u16 i;
516
Bruce Allanad680762008-03-28 09:15:03 -0700517 /* Can't read flash registers if the register set isn't mapped. */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700518 if (!hw->flash_address) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000519 e_dbg("ERROR: Flash registers not mapped\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700520 return -E1000_ERR_CONFIG;
521 }
522
523 nvm->type = e1000_nvm_flash_sw;
524
525 gfpreg = er32flash(ICH_FLASH_GFPREG);
526
Bruce Allanad680762008-03-28 09:15:03 -0700527 /*
528 * sector_X_addr is a "sector"-aligned address (4096 bytes)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700529 * Add 1 to sector_end_addr since this sector is included in
Bruce Allanad680762008-03-28 09:15:03 -0700530 * the overall size.
531 */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700532 sector_base_addr = gfpreg & FLASH_GFPREG_BASE_MASK;
533 sector_end_addr = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK) + 1;
534
535 /* flash_base_addr is byte-aligned */
536 nvm->flash_base_addr = sector_base_addr << FLASH_SECTOR_ADDR_SHIFT;
537
Bruce Allanad680762008-03-28 09:15:03 -0700538 /*
539 * find total size of the NVM, then cut in half since the total
540 * size represents two separate NVM banks.
541 */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700542 nvm->flash_bank_size = (sector_end_addr - sector_base_addr)
543 << FLASH_SECTOR_ADDR_SHIFT;
544 nvm->flash_bank_size /= 2;
545 /* Adjust to word count */
546 nvm->flash_bank_size /= sizeof(u16);
547
548 nvm->word_size = E1000_ICH8_SHADOW_RAM_WORDS;
549
550 /* Clear shadow ram */
551 for (i = 0; i < nvm->word_size; i++) {
Bruce Allan564ea9b2009-11-20 23:26:44 +0000552 dev_spec->shadow_ram[i].modified = false;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700553 dev_spec->shadow_ram[i].value = 0xFFFF;
554 }
555
556 return 0;
557}
558
559/**
560 * e1000_init_mac_params_ich8lan - Initialize MAC function pointers
561 * @hw: pointer to the HW structure
562 *
563 * Initialize family-specific MAC parameters and function
564 * pointers.
565 **/
Bruce Allanec34c172012-02-01 10:53:05 +0000566static s32 e1000_init_mac_params_ich8lan(struct e1000_hw *hw)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700567{
Auke Kokbc7f75f2007-09-17 12:30:59 -0700568 struct e1000_mac_info *mac = &hw->mac;
569
570 /* Set media type function pointer */
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700571 hw->phy.media_type = e1000_media_type_copper;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700572
573 /* Set mta register count */
574 mac->mta_reg_count = 32;
575 /* Set rar entry count */
576 mac->rar_entry_count = E1000_ICH_RAR_ENTRIES;
577 if (mac->type == e1000_ich8lan)
578 mac->rar_entry_count--;
Bruce Allana65a4a02010-05-10 15:01:51 +0000579 /* FWSM register */
580 mac->has_fwsm = true;
581 /* ARC subsystem not supported */
582 mac->arc_subsystem_valid = false;
Bruce Allanf464ba82010-01-07 16:31:35 +0000583 /* Adaptive IFS supported */
584 mac->adaptive_ifs = true;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700585
Bruce Allana4f58f52009-06-02 11:29:18 +0000586 /* LED operations */
587 switch (mac->type) {
588 case e1000_ich8lan:
589 case e1000_ich9lan:
590 case e1000_ich10lan:
Bruce Allaneb7700d2010-06-16 13:27:05 +0000591 /* check management mode */
592 mac->ops.check_mng_mode = e1000_check_mng_mode_ich8lan;
Bruce Allana4f58f52009-06-02 11:29:18 +0000593 /* ID LED init */
Bruce Alland1964eb2012-02-22 09:02:21 +0000594 mac->ops.id_led_init = e1000e_id_led_init_generic;
Bruce Allandbf80dc2011-04-16 00:34:40 +0000595 /* blink LED */
596 mac->ops.blink_led = e1000e_blink_led_generic;
Bruce Allana4f58f52009-06-02 11:29:18 +0000597 /* setup LED */
598 mac->ops.setup_led = e1000e_setup_led_generic;
599 /* cleanup LED */
600 mac->ops.cleanup_led = e1000_cleanup_led_ich8lan;
601 /* turn on/off LED */
602 mac->ops.led_on = e1000_led_on_ich8lan;
603 mac->ops.led_off = e1000_led_off_ich8lan;
604 break;
605 case e1000_pchlan:
Bruce Alland3738bb2010-06-16 13:27:28 +0000606 case e1000_pch2lan:
Bruce Allaneb7700d2010-06-16 13:27:05 +0000607 /* check management mode */
608 mac->ops.check_mng_mode = e1000_check_mng_mode_pchlan;
Bruce Allana4f58f52009-06-02 11:29:18 +0000609 /* ID LED init */
610 mac->ops.id_led_init = e1000_id_led_init_pchlan;
611 /* setup LED */
612 mac->ops.setup_led = e1000_setup_led_pchlan;
613 /* cleanup LED */
614 mac->ops.cleanup_led = e1000_cleanup_led_pchlan;
615 /* turn on/off LED */
616 mac->ops.led_on = e1000_led_on_pchlan;
617 mac->ops.led_off = e1000_led_off_pchlan;
618 break;
619 default:
620 break;
621 }
622
Auke Kokbc7f75f2007-09-17 12:30:59 -0700623 /* Enable PCS Lock-loss workaround for ICH8 */
624 if (mac->type == e1000_ich8lan)
Bruce Allan564ea9b2009-11-20 23:26:44 +0000625 e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw, true);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700626
Bruce Allan605c82b2010-09-22 17:17:01 +0000627 /* Gate automatic PHY configuration by hardware on managed 82579 */
628 if ((mac->type == e1000_pch2lan) &&
629 (er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
630 e1000_gate_hw_phy_config_ich8lan(hw, true);
Bruce Alland3738bb2010-06-16 13:27:28 +0000631
Auke Kokbc7f75f2007-09-17 12:30:59 -0700632 return 0;
633}
634
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000635/**
Bruce Allane52997f2010-06-16 13:27:49 +0000636 * e1000_set_eee_pchlan - Enable/disable EEE support
637 * @hw: pointer to the HW structure
638 *
639 * Enable/disable EEE based on setting in dev_spec structure. The bits in
640 * the LPI Control register will remain set only if/when link is up.
641 **/
642static s32 e1000_set_eee_pchlan(struct e1000_hw *hw)
643{
644 s32 ret_val = 0;
645 u16 phy_reg;
646
647 if (hw->phy.type != e1000_phy_82579)
Bruce Allan5015e532012-02-08 02:55:56 +0000648 return 0;
Bruce Allane52997f2010-06-16 13:27:49 +0000649
650 ret_val = e1e_rphy(hw, I82579_LPI_CTRL, &phy_reg);
651 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +0000652 return ret_val;
Bruce Allane52997f2010-06-16 13:27:49 +0000653
654 if (hw->dev_spec.ich8lan.eee_disable)
655 phy_reg &= ~I82579_LPI_CTRL_ENABLE_MASK;
656 else
657 phy_reg |= I82579_LPI_CTRL_ENABLE_MASK;
658
Bruce Allan5015e532012-02-08 02:55:56 +0000659 return e1e_wphy(hw, I82579_LPI_CTRL, phy_reg);
Bruce Allane52997f2010-06-16 13:27:49 +0000660}
661
662/**
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000663 * e1000_check_for_copper_link_ich8lan - Check for link (Copper)
664 * @hw: pointer to the HW structure
665 *
666 * Checks to see of the link status of the hardware has changed. If a
667 * change in link status has been detected, then we read the PHY registers
668 * to get the current speed/duplex if link exists.
669 **/
670static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw)
671{
672 struct e1000_mac_info *mac = &hw->mac;
673 s32 ret_val;
674 bool link;
Bruce Allan1d2101a72011-07-22 06:21:56 +0000675 u16 phy_reg;
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000676
677 /*
678 * We only want to go out to the PHY registers to see if Auto-Neg
679 * has completed and/or if our link status has changed. The
680 * get_link_status flag is set upon receiving a Link Status
681 * Change or Rx Sequence Error interrupt.
682 */
Bruce Allan5015e532012-02-08 02:55:56 +0000683 if (!mac->get_link_status)
684 return 0;
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000685
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000686 /*
687 * First we want to see if the MII Status Register reports
688 * link. If so, then we want to get the current speed/duplex
689 * of the PHY.
690 */
691 ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link);
692 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +0000693 return ret_val;
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000694
Bruce Allan1d5846b2009-10-29 13:46:05 +0000695 if (hw->mac.type == e1000_pchlan) {
696 ret_val = e1000_k1_gig_workaround_hv(hw, link);
697 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +0000698 return ret_val;
Bruce Allan1d5846b2009-10-29 13:46:05 +0000699 }
700
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000701 if (!link)
Bruce Allan5015e532012-02-08 02:55:56 +0000702 return 0; /* No link detected */
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000703
704 mac->get_link_status = false;
705
Bruce Allan1d2101a72011-07-22 06:21:56 +0000706 switch (hw->mac.type) {
707 case e1000_pch2lan:
Bruce Allan831bd2e2010-09-22 17:16:18 +0000708 ret_val = e1000_k1_workaround_lv(hw);
709 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +0000710 return ret_val;
Bruce Allan1d2101a72011-07-22 06:21:56 +0000711 /* fall-thru */
712 case e1000_pchlan:
713 if (hw->phy.type == e1000_phy_82578) {
714 ret_val = e1000_link_stall_workaround_hv(hw);
715 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +0000716 return ret_val;
Bruce Allan1d2101a72011-07-22 06:21:56 +0000717 }
718
719 /*
720 * Workaround for PCHx parts in half-duplex:
721 * Set the number of preambles removed from the packet
722 * when it is passed from the PHY to the MAC to prevent
723 * the MAC from misinterpreting the packet type.
724 */
725 e1e_rphy(hw, HV_KMRN_FIFO_CTRLSTA, &phy_reg);
726 phy_reg &= ~HV_KMRN_FIFO_CTRLSTA_PREAMBLE_MASK;
727
728 if ((er32(STATUS) & E1000_STATUS_FD) != E1000_STATUS_FD)
729 phy_reg |= (1 << HV_KMRN_FIFO_CTRLSTA_PREAMBLE_SHIFT);
730
731 e1e_wphy(hw, HV_KMRN_FIFO_CTRLSTA, phy_reg);
732 break;
733 default:
734 break;
Bruce Allan831bd2e2010-09-22 17:16:18 +0000735 }
736
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000737 /*
738 * Check if there was DownShift, must be checked
739 * immediately after link-up
740 */
741 e1000e_check_downshift(hw);
742
Bruce Allane52997f2010-06-16 13:27:49 +0000743 /* Enable/Disable EEE after link up */
744 ret_val = e1000_set_eee_pchlan(hw);
745 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +0000746 return ret_val;
Bruce Allane52997f2010-06-16 13:27:49 +0000747
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000748 /*
749 * If we are forcing speed/duplex, then we simply return since
750 * we have already determined whether we have link or not.
751 */
Bruce Allan5015e532012-02-08 02:55:56 +0000752 if (!mac->autoneg)
753 return -E1000_ERR_CONFIG;
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000754
755 /*
756 * Auto-Neg is enabled. Auto Speed Detection takes care
757 * of MAC speed/duplex configuration. So we only need to
758 * configure Collision Distance in the MAC.
759 */
Bruce Allan57cde762012-02-22 09:02:58 +0000760 mac->ops.config_collision_dist(hw);
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000761
762 /*
763 * Configure Flow Control now that Auto-Neg has completed.
764 * First, we need to restore the desired flow control
765 * settings because we may have had to re-autoneg with a
766 * different link partner.
767 */
768 ret_val = e1000e_config_fc_after_link_up(hw);
769 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000770 e_dbg("Error configuring flow control\n");
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000771
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000772 return ret_val;
773}
774
Jeff Kirsher69e3fd82008-04-02 13:48:18 -0700775static s32 e1000_get_variants_ich8lan(struct e1000_adapter *adapter)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700776{
777 struct e1000_hw *hw = &adapter->hw;
778 s32 rc;
779
Bruce Allanec34c172012-02-01 10:53:05 +0000780 rc = e1000_init_mac_params_ich8lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700781 if (rc)
782 return rc;
783
784 rc = e1000_init_nvm_params_ich8lan(hw);
785 if (rc)
786 return rc;
787
Bruce Alland3738bb2010-06-16 13:27:28 +0000788 switch (hw->mac.type) {
789 case e1000_ich8lan:
790 case e1000_ich9lan:
791 case e1000_ich10lan:
Bruce Allana4f58f52009-06-02 11:29:18 +0000792 rc = e1000_init_phy_params_ich8lan(hw);
Bruce Alland3738bb2010-06-16 13:27:28 +0000793 break;
794 case e1000_pchlan:
795 case e1000_pch2lan:
796 rc = e1000_init_phy_params_pchlan(hw);
797 break;
798 default:
799 break;
800 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700801 if (rc)
802 return rc;
803
Bruce Allan23e4f062011-02-25 07:44:51 +0000804 /*
805 * Disable Jumbo Frame support on parts with Intel 10/100 PHY or
806 * on parts with MACsec enabled in NVM (reflected in CTRL_EXT).
807 */
808 if ((adapter->hw.phy.type == e1000_phy_ife) ||
809 ((adapter->hw.mac.type >= e1000_pch2lan) &&
810 (!(er32(CTRL_EXT) & E1000_CTRL_EXT_LSECCK)))) {
Bruce Allan2adc55c2009-06-02 11:28:58 +0000811 adapter->flags &= ~FLAG_HAS_JUMBO_FRAMES;
812 adapter->max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN;
Bruce Allandbf80dc2011-04-16 00:34:40 +0000813
814 hw->mac.ops.blink_led = NULL;
Bruce Allan2adc55c2009-06-02 11:28:58 +0000815 }
816
Auke Kokbc7f75f2007-09-17 12:30:59 -0700817 if ((adapter->hw.mac.type == e1000_ich8lan) &&
Bruce Allan462d5992011-09-30 08:07:11 +0000818 (adapter->hw.phy.type != e1000_phy_ife))
Auke Kokbc7f75f2007-09-17 12:30:59 -0700819 adapter->flags |= FLAG_LSC_GIG_SPEED_DROP;
820
Bruce Allanc6e7f512011-07-29 05:53:02 +0000821 /* Enable workaround for 82579 w/ ME enabled */
822 if ((adapter->hw.mac.type == e1000_pch2lan) &&
823 (er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
824 adapter->flags2 |= FLAG2_PCIM2PCI_ARBITER_WA;
825
Bruce Allan5a86f282010-06-29 18:13:13 +0000826 /* Disable EEE by default until IEEE802.3az spec is finalized */
827 if (adapter->flags2 & FLAG2_HAS_EEE)
828 adapter->hw.dev_spec.ich8lan.eee_disable = true;
829
Auke Kokbc7f75f2007-09-17 12:30:59 -0700830 return 0;
831}
832
Thomas Gleixner717d4382008-10-02 16:33:40 -0700833static DEFINE_MUTEX(nvm_mutex);
Thomas Gleixner717d4382008-10-02 16:33:40 -0700834
Auke Kokbc7f75f2007-09-17 12:30:59 -0700835/**
Bruce Allanca15df52009-10-26 11:23:43 +0000836 * e1000_acquire_nvm_ich8lan - Acquire NVM mutex
837 * @hw: pointer to the HW structure
838 *
839 * Acquires the mutex for performing NVM operations.
840 **/
841static s32 e1000_acquire_nvm_ich8lan(struct e1000_hw *hw)
842{
843 mutex_lock(&nvm_mutex);
844
845 return 0;
846}
847
848/**
849 * e1000_release_nvm_ich8lan - Release NVM mutex
850 * @hw: pointer to the HW structure
851 *
852 * Releases the mutex used while performing NVM operations.
853 **/
854static void e1000_release_nvm_ich8lan(struct e1000_hw *hw)
855{
856 mutex_unlock(&nvm_mutex);
Bruce Allanca15df52009-10-26 11:23:43 +0000857}
858
Bruce Allanca15df52009-10-26 11:23:43 +0000859/**
Auke Kokbc7f75f2007-09-17 12:30:59 -0700860 * e1000_acquire_swflag_ich8lan - Acquire software control flag
861 * @hw: pointer to the HW structure
862 *
Bruce Allanca15df52009-10-26 11:23:43 +0000863 * Acquires the software control flag for performing PHY and select
864 * MAC CSR accesses.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700865 **/
866static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw)
867{
Bruce Allan373a88d2009-08-07 07:41:37 +0000868 u32 extcnf_ctrl, timeout = PHY_CFG_TIMEOUT;
869 s32 ret_val = 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700870
Bruce Allana90b4122011-10-07 03:50:38 +0000871 if (test_and_set_bit(__E1000_ACCESS_SHARED_RESOURCE,
872 &hw->adapter->state)) {
Bruce Allan34c9ef82011-10-21 04:33:47 +0000873 e_dbg("contention for Phy access\n");
Bruce Allana90b4122011-10-07 03:50:38 +0000874 return -E1000_ERR_PHY;
875 }
Thomas Gleixner717d4382008-10-02 16:33:40 -0700876
Auke Kokbc7f75f2007-09-17 12:30:59 -0700877 while (timeout) {
878 extcnf_ctrl = er32(EXTCNF_CTRL);
Bruce Allan373a88d2009-08-07 07:41:37 +0000879 if (!(extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG))
880 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700881
Auke Kokbc7f75f2007-09-17 12:30:59 -0700882 mdelay(1);
883 timeout--;
884 }
885
886 if (!timeout) {
Bruce Allana90b4122011-10-07 03:50:38 +0000887 e_dbg("SW has already locked the resource.\n");
Bruce Allan373a88d2009-08-07 07:41:37 +0000888 ret_val = -E1000_ERR_CONFIG;
889 goto out;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700890 }
891
Bruce Allan53ac5a82009-10-26 11:23:06 +0000892 timeout = SW_FLAG_TIMEOUT;
Bruce Allan373a88d2009-08-07 07:41:37 +0000893
894 extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG;
895 ew32(EXTCNF_CTRL, extcnf_ctrl);
896
897 while (timeout) {
898 extcnf_ctrl = er32(EXTCNF_CTRL);
899 if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG)
900 break;
901
902 mdelay(1);
903 timeout--;
904 }
905
906 if (!timeout) {
Bruce Allan434f1392011-12-16 00:46:54 +0000907 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 +0000908 er32(FWSM), extcnf_ctrl);
Bruce Allan373a88d2009-08-07 07:41:37 +0000909 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
910 ew32(EXTCNF_CTRL, extcnf_ctrl);
911 ret_val = -E1000_ERR_CONFIG;
912 goto out;
913 }
914
915out:
916 if (ret_val)
Bruce Allana90b4122011-10-07 03:50:38 +0000917 clear_bit(__E1000_ACCESS_SHARED_RESOURCE, &hw->adapter->state);
Bruce Allan373a88d2009-08-07 07:41:37 +0000918
919 return ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700920}
921
922/**
923 * e1000_release_swflag_ich8lan - Release software control flag
924 * @hw: pointer to the HW structure
925 *
Bruce Allanca15df52009-10-26 11:23:43 +0000926 * Releases the software control flag for performing PHY and select
927 * MAC CSR accesses.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700928 **/
929static void e1000_release_swflag_ich8lan(struct e1000_hw *hw)
930{
931 u32 extcnf_ctrl;
932
933 extcnf_ctrl = er32(EXTCNF_CTRL);
Bruce Allanc5caf482011-05-13 07:19:53 +0000934
935 if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG) {
936 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
937 ew32(EXTCNF_CTRL, extcnf_ctrl);
938 } else {
939 e_dbg("Semaphore unexpectedly released by sw/fw/hw\n");
940 }
Thomas Gleixner717d4382008-10-02 16:33:40 -0700941
Bruce Allana90b4122011-10-07 03:50:38 +0000942 clear_bit(__E1000_ACCESS_SHARED_RESOURCE, &hw->adapter->state);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700943}
944
945/**
Bruce Allan4662e822008-08-26 18:37:06 -0700946 * e1000_check_mng_mode_ich8lan - Checks management mode
947 * @hw: pointer to the HW structure
948 *
Bruce Allaneb7700d2010-06-16 13:27:05 +0000949 * This checks if the adapter has any manageability enabled.
Bruce Allan4662e822008-08-26 18:37:06 -0700950 * This is a function pointer entry point only called by read/write
951 * routines for the PHY and NVM parts.
952 **/
953static bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw)
954{
Bruce Allana708dd82009-11-20 23:28:37 +0000955 u32 fwsm;
956
957 fwsm = er32(FWSM);
Bruce Allaneb7700d2010-06-16 13:27:05 +0000958 return (fwsm & E1000_ICH_FWSM_FW_VALID) &&
959 ((fwsm & E1000_FWSM_MODE_MASK) ==
960 (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT));
961}
Bruce Allan4662e822008-08-26 18:37:06 -0700962
Bruce Allaneb7700d2010-06-16 13:27:05 +0000963/**
964 * e1000_check_mng_mode_pchlan - Checks management mode
965 * @hw: pointer to the HW structure
966 *
967 * This checks if the adapter has iAMT enabled.
968 * This is a function pointer entry point only called by read/write
969 * routines for the PHY and NVM parts.
970 **/
971static bool e1000_check_mng_mode_pchlan(struct e1000_hw *hw)
972{
973 u32 fwsm;
974
975 fwsm = er32(FWSM);
976 return (fwsm & E1000_ICH_FWSM_FW_VALID) &&
977 (fwsm & (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT));
Bruce Allan4662e822008-08-26 18:37:06 -0700978}
979
980/**
Auke Kokbc7f75f2007-09-17 12:30:59 -0700981 * e1000_check_reset_block_ich8lan - Check if PHY reset is blocked
982 * @hw: pointer to the HW structure
983 *
984 * Checks if firmware is blocking the reset of the PHY.
985 * This is a function pointer entry point only called by
986 * reset routines.
987 **/
988static s32 e1000_check_reset_block_ich8lan(struct e1000_hw *hw)
989{
990 u32 fwsm;
991
992 fwsm = er32(FWSM);
993
994 return (fwsm & E1000_ICH_FWSM_RSPCIPHY) ? 0 : E1000_BLK_PHY_RESET;
995}
996
997/**
Bruce Allan8395ae82010-09-22 17:15:08 +0000998 * e1000_write_smbus_addr - Write SMBus address to PHY needed during Sx states
999 * @hw: pointer to the HW structure
1000 *
1001 * Assumes semaphore already acquired.
1002 *
1003 **/
1004static s32 e1000_write_smbus_addr(struct e1000_hw *hw)
1005{
1006 u16 phy_data;
1007 u32 strap = er32(STRAP);
1008 s32 ret_val = 0;
1009
1010 strap &= E1000_STRAP_SMBUS_ADDRESS_MASK;
1011
1012 ret_val = e1000_read_phy_reg_hv_locked(hw, HV_SMB_ADDR, &phy_data);
1013 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001014 return ret_val;
Bruce Allan8395ae82010-09-22 17:15:08 +00001015
1016 phy_data &= ~HV_SMB_ADDR_MASK;
1017 phy_data |= (strap >> E1000_STRAP_SMBUS_ADDRESS_SHIFT);
1018 phy_data |= HV_SMB_ADDR_PEC_EN | HV_SMB_ADDR_VALID;
Bruce Allan8395ae82010-09-22 17:15:08 +00001019
Bruce Allan5015e532012-02-08 02:55:56 +00001020 return e1000_write_phy_reg_hv_locked(hw, HV_SMB_ADDR, phy_data);
Bruce Allan8395ae82010-09-22 17:15:08 +00001021}
1022
1023/**
Bruce Allanf523d212009-10-29 13:45:45 +00001024 * e1000_sw_lcd_config_ich8lan - SW-based LCD Configuration
1025 * @hw: pointer to the HW structure
1026 *
1027 * SW should configure the LCD from the NVM extended configuration region
1028 * as a workaround for certain parts.
1029 **/
1030static s32 e1000_sw_lcd_config_ich8lan(struct e1000_hw *hw)
1031{
1032 struct e1000_phy_info *phy = &hw->phy;
1033 u32 i, data, cnf_size, cnf_base_addr, sw_cfg_mask;
Bruce Allan8b802a72010-05-10 15:01:10 +00001034 s32 ret_val = 0;
Bruce Allanf523d212009-10-29 13:45:45 +00001035 u16 word_addr, reg_data, reg_addr, phy_page = 0;
1036
Bruce Allanf523d212009-10-29 13:45:45 +00001037 /*
1038 * Initialize the PHY from the NVM on ICH platforms. This
1039 * is needed due to an issue where the NVM configuration is
1040 * not properly autoloaded after power transitions.
1041 * Therefore, after each PHY reset, we will load the
1042 * configuration data out of the NVM manually.
1043 */
Bruce Allan3f0c16e2010-06-16 13:26:17 +00001044 switch (hw->mac.type) {
1045 case e1000_ich8lan:
1046 if (phy->type != e1000_phy_igp_3)
1047 return ret_val;
1048
Bruce Allan5f3eed62010-09-22 17:15:54 +00001049 if ((hw->adapter->pdev->device == E1000_DEV_ID_ICH8_IGP_AMT) ||
1050 (hw->adapter->pdev->device == E1000_DEV_ID_ICH8_IGP_C)) {
Bruce Allan3f0c16e2010-06-16 13:26:17 +00001051 sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG;
1052 break;
1053 }
1054 /* Fall-thru */
1055 case e1000_pchlan:
Bruce Alland3738bb2010-06-16 13:27:28 +00001056 case e1000_pch2lan:
Bruce Allan8b802a72010-05-10 15:01:10 +00001057 sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG_ICH8M;
Bruce Allan3f0c16e2010-06-16 13:26:17 +00001058 break;
1059 default:
1060 return ret_val;
1061 }
1062
1063 ret_val = hw->phy.ops.acquire(hw);
1064 if (ret_val)
1065 return ret_val;
Bruce Allanf523d212009-10-29 13:45:45 +00001066
Bruce Allan8b802a72010-05-10 15:01:10 +00001067 data = er32(FEXTNVM);
1068 if (!(data & sw_cfg_mask))
Bruce Allan75ce1532012-02-08 02:54:48 +00001069 goto release;
Bruce Allanf523d212009-10-29 13:45:45 +00001070
Bruce Allan8b802a72010-05-10 15:01:10 +00001071 /*
1072 * Make sure HW does not configure LCD from PHY
1073 * extended configuration before SW configuration
1074 */
1075 data = er32(EXTCNF_CTRL);
Bruce Alland3738bb2010-06-16 13:27:28 +00001076 if (!(hw->mac.type == e1000_pch2lan)) {
1077 if (data & E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE)
Bruce Allan75ce1532012-02-08 02:54:48 +00001078 goto release;
Bruce Alland3738bb2010-06-16 13:27:28 +00001079 }
Bruce Allanf523d212009-10-29 13:45:45 +00001080
Bruce Allan8b802a72010-05-10 15:01:10 +00001081 cnf_size = er32(EXTCNF_SIZE);
1082 cnf_size &= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_MASK;
1083 cnf_size >>= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_SHIFT;
1084 if (!cnf_size)
Bruce Allan75ce1532012-02-08 02:54:48 +00001085 goto release;
Bruce Allan8b802a72010-05-10 15:01:10 +00001086
1087 cnf_base_addr = data & E1000_EXTCNF_CTRL_EXT_CNF_POINTER_MASK;
1088 cnf_base_addr >>= E1000_EXTCNF_CTRL_EXT_CNF_POINTER_SHIFT;
1089
Bruce Allan87fb7412010-09-22 17:15:33 +00001090 if ((!(data & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE) &&
1091 (hw->mac.type == e1000_pchlan)) ||
1092 (hw->mac.type == e1000_pch2lan)) {
Bruce Allanf523d212009-10-29 13:45:45 +00001093 /*
Bruce Allan8b802a72010-05-10 15:01:10 +00001094 * HW configures the SMBus address and LEDs when the
1095 * OEM and LCD Write Enable bits are set in the NVM.
1096 * When both NVM bits are cleared, SW will configure
1097 * them instead.
Bruce Allanf523d212009-10-29 13:45:45 +00001098 */
Bruce Allan8395ae82010-09-22 17:15:08 +00001099 ret_val = e1000_write_smbus_addr(hw);
Bruce Allan8b802a72010-05-10 15:01:10 +00001100 if (ret_val)
Bruce Allan75ce1532012-02-08 02:54:48 +00001101 goto release;
Bruce Allanf523d212009-10-29 13:45:45 +00001102
Bruce Allan8b802a72010-05-10 15:01:10 +00001103 data = er32(LEDCTL);
1104 ret_val = e1000_write_phy_reg_hv_locked(hw, HV_LED_CONFIG,
1105 (u16)data);
1106 if (ret_val)
Bruce Allan75ce1532012-02-08 02:54:48 +00001107 goto release;
Bruce Allan8b802a72010-05-10 15:01:10 +00001108 }
1109
1110 /* Configure LCD from extended configuration region. */
1111
1112 /* cnf_base_addr is in DWORD */
1113 word_addr = (u16)(cnf_base_addr << 1);
1114
1115 for (i = 0; i < cnf_size; i++) {
1116 ret_val = e1000_read_nvm(hw, (word_addr + i * 2), 1,
1117 &reg_data);
1118 if (ret_val)
Bruce Allan75ce1532012-02-08 02:54:48 +00001119 goto release;
Bruce Allanf523d212009-10-29 13:45:45 +00001120
Bruce Allan8b802a72010-05-10 15:01:10 +00001121 ret_val = e1000_read_nvm(hw, (word_addr + i * 2 + 1),
1122 1, &reg_addr);
1123 if (ret_val)
Bruce Allan75ce1532012-02-08 02:54:48 +00001124 goto release;
Bruce Allanf523d212009-10-29 13:45:45 +00001125
Bruce Allan8b802a72010-05-10 15:01:10 +00001126 /* Save off the PHY page for future writes. */
1127 if (reg_addr == IGP01E1000_PHY_PAGE_SELECT) {
1128 phy_page = reg_data;
1129 continue;
Bruce Allanf523d212009-10-29 13:45:45 +00001130 }
Bruce Allanf523d212009-10-29 13:45:45 +00001131
Bruce Allan8b802a72010-05-10 15:01:10 +00001132 reg_addr &= PHY_REG_MASK;
1133 reg_addr |= phy_page;
Bruce Allanf523d212009-10-29 13:45:45 +00001134
Bruce Allan8b802a72010-05-10 15:01:10 +00001135 ret_val = phy->ops.write_reg_locked(hw, (u32)reg_addr,
1136 reg_data);
1137 if (ret_val)
Bruce Allan75ce1532012-02-08 02:54:48 +00001138 goto release;
Bruce Allanf523d212009-10-29 13:45:45 +00001139 }
1140
Bruce Allan75ce1532012-02-08 02:54:48 +00001141release:
Bruce Allan94d81862009-11-20 23:25:26 +00001142 hw->phy.ops.release(hw);
Bruce Allanf523d212009-10-29 13:45:45 +00001143 return ret_val;
1144}
1145
1146/**
Bruce Allan1d5846b2009-10-29 13:46:05 +00001147 * e1000_k1_gig_workaround_hv - K1 Si workaround
1148 * @hw: pointer to the HW structure
1149 * @link: link up bool flag
1150 *
1151 * If K1 is enabled for 1Gbps, the MAC might stall when transitioning
1152 * from a lower speed. This workaround disables K1 whenever link is at 1Gig
1153 * If link is down, the function will restore the default K1 setting located
1154 * in the NVM.
1155 **/
1156static s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link)
1157{
1158 s32 ret_val = 0;
1159 u16 status_reg = 0;
1160 bool k1_enable = hw->dev_spec.ich8lan.nvm_k1_enabled;
1161
1162 if (hw->mac.type != e1000_pchlan)
Bruce Allan5015e532012-02-08 02:55:56 +00001163 return 0;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001164
1165 /* Wrap the whole flow with the sw flag */
Bruce Allan94d81862009-11-20 23:25:26 +00001166 ret_val = hw->phy.ops.acquire(hw);
Bruce Allan1d5846b2009-10-29 13:46:05 +00001167 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001168 return ret_val;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001169
1170 /* Disable K1 when link is 1Gbps, otherwise use the NVM setting */
1171 if (link) {
1172 if (hw->phy.type == e1000_phy_82578) {
Bruce Allan94d81862009-11-20 23:25:26 +00001173 ret_val = hw->phy.ops.read_reg_locked(hw, BM_CS_STATUS,
Bruce Allan1d5846b2009-10-29 13:46:05 +00001174 &status_reg);
1175 if (ret_val)
1176 goto release;
1177
1178 status_reg &= BM_CS_STATUS_LINK_UP |
1179 BM_CS_STATUS_RESOLVED |
1180 BM_CS_STATUS_SPEED_MASK;
1181
1182 if (status_reg == (BM_CS_STATUS_LINK_UP |
1183 BM_CS_STATUS_RESOLVED |
1184 BM_CS_STATUS_SPEED_1000))
1185 k1_enable = false;
1186 }
1187
1188 if (hw->phy.type == e1000_phy_82577) {
Bruce Allan94d81862009-11-20 23:25:26 +00001189 ret_val = hw->phy.ops.read_reg_locked(hw, HV_M_STATUS,
Bruce Allan1d5846b2009-10-29 13:46:05 +00001190 &status_reg);
1191 if (ret_val)
1192 goto release;
1193
1194 status_reg &= HV_M_STATUS_LINK_UP |
1195 HV_M_STATUS_AUTONEG_COMPLETE |
1196 HV_M_STATUS_SPEED_MASK;
1197
1198 if (status_reg == (HV_M_STATUS_LINK_UP |
1199 HV_M_STATUS_AUTONEG_COMPLETE |
1200 HV_M_STATUS_SPEED_1000))
1201 k1_enable = false;
1202 }
1203
1204 /* Link stall fix for link up */
Bruce Allan94d81862009-11-20 23:25:26 +00001205 ret_val = hw->phy.ops.write_reg_locked(hw, PHY_REG(770, 19),
Bruce Allan1d5846b2009-10-29 13:46:05 +00001206 0x0100);
1207 if (ret_val)
1208 goto release;
1209
1210 } else {
1211 /* Link stall fix for link down */
Bruce Allan94d81862009-11-20 23:25:26 +00001212 ret_val = hw->phy.ops.write_reg_locked(hw, PHY_REG(770, 19),
Bruce Allan1d5846b2009-10-29 13:46:05 +00001213 0x4100);
1214 if (ret_val)
1215 goto release;
1216 }
1217
1218 ret_val = e1000_configure_k1_ich8lan(hw, k1_enable);
1219
1220release:
Bruce Allan94d81862009-11-20 23:25:26 +00001221 hw->phy.ops.release(hw);
Bruce Allan5015e532012-02-08 02:55:56 +00001222
Bruce Allan1d5846b2009-10-29 13:46:05 +00001223 return ret_val;
1224}
1225
1226/**
1227 * e1000_configure_k1_ich8lan - Configure K1 power state
1228 * @hw: pointer to the HW structure
1229 * @enable: K1 state to configure
1230 *
1231 * Configure the K1 power state based on the provided parameter.
1232 * Assumes semaphore already acquired.
1233 *
1234 * Success returns 0, Failure returns -E1000_ERR_PHY (-2)
1235 **/
Bruce Allanbb436b22009-11-20 23:24:11 +00001236s32 e1000_configure_k1_ich8lan(struct e1000_hw *hw, bool k1_enable)
Bruce Allan1d5846b2009-10-29 13:46:05 +00001237{
1238 s32 ret_val = 0;
1239 u32 ctrl_reg = 0;
1240 u32 ctrl_ext = 0;
1241 u32 reg = 0;
1242 u16 kmrn_reg = 0;
1243
Bruce Allan3d3a1672012-02-23 03:13:18 +00001244 ret_val = e1000e_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
1245 &kmrn_reg);
Bruce Allan1d5846b2009-10-29 13:46:05 +00001246 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001247 return ret_val;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001248
1249 if (k1_enable)
1250 kmrn_reg |= E1000_KMRNCTRLSTA_K1_ENABLE;
1251 else
1252 kmrn_reg &= ~E1000_KMRNCTRLSTA_K1_ENABLE;
1253
Bruce Allan3d3a1672012-02-23 03:13:18 +00001254 ret_val = e1000e_write_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
1255 kmrn_reg);
Bruce Allan1d5846b2009-10-29 13:46:05 +00001256 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001257 return ret_val;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001258
1259 udelay(20);
1260 ctrl_ext = er32(CTRL_EXT);
1261 ctrl_reg = er32(CTRL);
1262
1263 reg = ctrl_reg & ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100);
1264 reg |= E1000_CTRL_FRCSPD;
1265 ew32(CTRL, reg);
1266
1267 ew32(CTRL_EXT, ctrl_ext | E1000_CTRL_EXT_SPD_BYPS);
Jesse Brandeburg945a5152011-07-20 00:56:21 +00001268 e1e_flush();
Bruce Allan1d5846b2009-10-29 13:46:05 +00001269 udelay(20);
1270 ew32(CTRL, ctrl_reg);
1271 ew32(CTRL_EXT, ctrl_ext);
Jesse Brandeburg945a5152011-07-20 00:56:21 +00001272 e1e_flush();
Bruce Allan1d5846b2009-10-29 13:46:05 +00001273 udelay(20);
1274
Bruce Allan5015e532012-02-08 02:55:56 +00001275 return 0;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001276}
1277
1278/**
Bruce Allanf523d212009-10-29 13:45:45 +00001279 * e1000_oem_bits_config_ich8lan - SW-based LCD Configuration
1280 * @hw: pointer to the HW structure
1281 * @d0_state: boolean if entering d0 or d3 device state
1282 *
1283 * SW will configure Gbe Disable and LPLU based on the NVM. The four bits are
1284 * collectively called OEM bits. The OEM Write Enable bit and SW Config bit
1285 * in NVM determines whether HW should configure LPLU and Gbe Disable.
1286 **/
1287static s32 e1000_oem_bits_config_ich8lan(struct e1000_hw *hw, bool d0_state)
1288{
1289 s32 ret_val = 0;
1290 u32 mac_reg;
1291 u16 oem_reg;
1292
Bruce Alland3738bb2010-06-16 13:27:28 +00001293 if ((hw->mac.type != e1000_pch2lan) && (hw->mac.type != e1000_pchlan))
Bruce Allanf523d212009-10-29 13:45:45 +00001294 return ret_val;
1295
Bruce Allan94d81862009-11-20 23:25:26 +00001296 ret_val = hw->phy.ops.acquire(hw);
Bruce Allanf523d212009-10-29 13:45:45 +00001297 if (ret_val)
1298 return ret_val;
1299
Bruce Alland3738bb2010-06-16 13:27:28 +00001300 if (!(hw->mac.type == e1000_pch2lan)) {
1301 mac_reg = er32(EXTCNF_CTRL);
1302 if (mac_reg & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE)
Bruce Allan75ce1532012-02-08 02:54:48 +00001303 goto release;
Bruce Alland3738bb2010-06-16 13:27:28 +00001304 }
Bruce Allanf523d212009-10-29 13:45:45 +00001305
1306 mac_reg = er32(FEXTNVM);
1307 if (!(mac_reg & E1000_FEXTNVM_SW_CONFIG_ICH8M))
Bruce Allan75ce1532012-02-08 02:54:48 +00001308 goto release;
Bruce Allanf523d212009-10-29 13:45:45 +00001309
1310 mac_reg = er32(PHY_CTRL);
1311
Bruce Allan94d81862009-11-20 23:25:26 +00001312 ret_val = hw->phy.ops.read_reg_locked(hw, HV_OEM_BITS, &oem_reg);
Bruce Allanf523d212009-10-29 13:45:45 +00001313 if (ret_val)
Bruce Allan75ce1532012-02-08 02:54:48 +00001314 goto release;
Bruce Allanf523d212009-10-29 13:45:45 +00001315
1316 oem_reg &= ~(HV_OEM_BITS_GBE_DIS | HV_OEM_BITS_LPLU);
1317
1318 if (d0_state) {
1319 if (mac_reg & E1000_PHY_CTRL_GBE_DISABLE)
1320 oem_reg |= HV_OEM_BITS_GBE_DIS;
1321
1322 if (mac_reg & E1000_PHY_CTRL_D0A_LPLU)
1323 oem_reg |= HV_OEM_BITS_LPLU;
1324 } else {
Bruce Allan03299e42011-09-30 08:07:05 +00001325 if (mac_reg & (E1000_PHY_CTRL_GBE_DISABLE |
1326 E1000_PHY_CTRL_NOND0A_GBE_DISABLE))
Bruce Allanf523d212009-10-29 13:45:45 +00001327 oem_reg |= HV_OEM_BITS_GBE_DIS;
1328
Bruce Allan03299e42011-09-30 08:07:05 +00001329 if (mac_reg & (E1000_PHY_CTRL_D0A_LPLU |
1330 E1000_PHY_CTRL_NOND0A_LPLU))
Bruce Allanf523d212009-10-29 13:45:45 +00001331 oem_reg |= HV_OEM_BITS_LPLU;
1332 }
Bruce Allan03299e42011-09-30 08:07:05 +00001333
Bruce Allan92fe1732012-04-12 06:27:03 +00001334 /* Set Restart auto-neg to activate the bits */
1335 if ((d0_state || (hw->mac.type != e1000_pchlan)) &&
1336 !hw->phy.ops.check_reset_block(hw))
1337 oem_reg |= HV_OEM_BITS_RESTART_AN;
1338
Bruce Allan94d81862009-11-20 23:25:26 +00001339 ret_val = hw->phy.ops.write_reg_locked(hw, HV_OEM_BITS, oem_reg);
Bruce Allanf523d212009-10-29 13:45:45 +00001340
Bruce Allan75ce1532012-02-08 02:54:48 +00001341release:
Bruce Allan94d81862009-11-20 23:25:26 +00001342 hw->phy.ops.release(hw);
Bruce Allanf523d212009-10-29 13:45:45 +00001343
1344 return ret_val;
1345}
1346
1347
1348/**
Bruce Allanfddaa1a2010-01-13 01:52:49 +00001349 * e1000_set_mdio_slow_mode_hv - Set slow MDIO access mode
1350 * @hw: pointer to the HW structure
1351 **/
1352static s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw)
1353{
1354 s32 ret_val;
1355 u16 data;
1356
1357 ret_val = e1e_rphy(hw, HV_KMRN_MODE_CTRL, &data);
1358 if (ret_val)
1359 return ret_val;
1360
1361 data |= HV_KMRN_MDIO_SLOW;
1362
1363 ret_val = e1e_wphy(hw, HV_KMRN_MODE_CTRL, data);
1364
1365 return ret_val;
1366}
1367
1368/**
Bruce Allana4f58f52009-06-02 11:29:18 +00001369 * e1000_hv_phy_workarounds_ich8lan - A series of Phy workarounds to be
1370 * done after every PHY reset.
1371 **/
1372static s32 e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw)
1373{
1374 s32 ret_val = 0;
Bruce Allanbaf86c92010-01-13 01:53:08 +00001375 u16 phy_data;
Bruce Allana4f58f52009-06-02 11:29:18 +00001376
1377 if (hw->mac.type != e1000_pchlan)
Bruce Allan5015e532012-02-08 02:55:56 +00001378 return 0;
Bruce Allana4f58f52009-06-02 11:29:18 +00001379
Bruce Allanfddaa1a2010-01-13 01:52:49 +00001380 /* Set MDIO slow mode before any other MDIO access */
1381 if (hw->phy.type == e1000_phy_82577) {
1382 ret_val = e1000_set_mdio_slow_mode_hv(hw);
1383 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001384 return ret_val;
Bruce Allanfddaa1a2010-01-13 01:52:49 +00001385 }
1386
Bruce Allana4f58f52009-06-02 11:29:18 +00001387 if (((hw->phy.type == e1000_phy_82577) &&
1388 ((hw->phy.revision == 1) || (hw->phy.revision == 2))) ||
1389 ((hw->phy.type == e1000_phy_82578) && (hw->phy.revision == 1))) {
1390 /* Disable generation of early preamble */
1391 ret_val = e1e_wphy(hw, PHY_REG(769, 25), 0x4431);
1392 if (ret_val)
1393 return ret_val;
1394
1395 /* Preamble tuning for SSC */
Bruce Allan1d2101a72011-07-22 06:21:56 +00001396 ret_val = e1e_wphy(hw, HV_KMRN_FIFO_CTRLSTA, 0xA204);
Bruce Allana4f58f52009-06-02 11:29:18 +00001397 if (ret_val)
1398 return ret_val;
1399 }
1400
1401 if (hw->phy.type == e1000_phy_82578) {
1402 /*
1403 * Return registers to default by doing a soft reset then
1404 * writing 0x3140 to the control register.
1405 */
1406 if (hw->phy.revision < 2) {
1407 e1000e_phy_sw_reset(hw);
1408 ret_val = e1e_wphy(hw, PHY_CONTROL, 0x3140);
1409 }
1410 }
1411
1412 /* Select page 0 */
Bruce Allan94d81862009-11-20 23:25:26 +00001413 ret_val = hw->phy.ops.acquire(hw);
Bruce Allana4f58f52009-06-02 11:29:18 +00001414 if (ret_val)
1415 return ret_val;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001416
Bruce Allana4f58f52009-06-02 11:29:18 +00001417 hw->phy.addr = 1;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001418 ret_val = e1000e_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT, 0);
Bruce Allanbaf86c92010-01-13 01:53:08 +00001419 hw->phy.ops.release(hw);
Bruce Allan1d5846b2009-10-29 13:46:05 +00001420 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001421 return ret_val;
Bruce Allana4f58f52009-06-02 11:29:18 +00001422
Bruce Allan1d5846b2009-10-29 13:46:05 +00001423 /*
1424 * Configure the K1 Si workaround during phy reset assuming there is
1425 * link so that it disables K1 if link is in 1Gbps.
1426 */
1427 ret_val = e1000_k1_gig_workaround_hv(hw, true);
Bruce Allanbaf86c92010-01-13 01:53:08 +00001428 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001429 return ret_val;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001430
Bruce Allanbaf86c92010-01-13 01:53:08 +00001431 /* Workaround for link disconnects on a busy hub in half duplex */
1432 ret_val = hw->phy.ops.acquire(hw);
1433 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001434 return ret_val;
Bruce Allan3ebfc7c2011-05-13 07:20:14 +00001435 ret_val = hw->phy.ops.read_reg_locked(hw, BM_PORT_GEN_CFG, &phy_data);
Bruce Allanbaf86c92010-01-13 01:53:08 +00001436 if (ret_val)
1437 goto release;
Bruce Allan3ebfc7c2011-05-13 07:20:14 +00001438 ret_val = hw->phy.ops.write_reg_locked(hw, BM_PORT_GEN_CFG,
1439 phy_data & 0x00FF);
Bruce Allanbaf86c92010-01-13 01:53:08 +00001440release:
1441 hw->phy.ops.release(hw);
Bruce Allan5015e532012-02-08 02:55:56 +00001442
Bruce Allana4f58f52009-06-02 11:29:18 +00001443 return ret_val;
1444}
1445
1446/**
Bruce Alland3738bb2010-06-16 13:27:28 +00001447 * e1000_copy_rx_addrs_to_phy_ich8lan - Copy Rx addresses from MAC to PHY
1448 * @hw: pointer to the HW structure
1449 **/
1450void e1000_copy_rx_addrs_to_phy_ich8lan(struct e1000_hw *hw)
1451{
1452 u32 mac_reg;
Bruce Allan2b6b1682011-05-13 07:20:09 +00001453 u16 i, phy_reg = 0;
1454 s32 ret_val;
1455
1456 ret_val = hw->phy.ops.acquire(hw);
1457 if (ret_val)
1458 return;
1459 ret_val = e1000_enable_phy_wakeup_reg_access_bm(hw, &phy_reg);
1460 if (ret_val)
1461 goto release;
Bruce Alland3738bb2010-06-16 13:27:28 +00001462
1463 /* Copy both RAL/H (rar_entry_count) and SHRAL/H (+4) to PHY */
1464 for (i = 0; i < (hw->mac.rar_entry_count + 4); i++) {
1465 mac_reg = er32(RAL(i));
Bruce Allan2b6b1682011-05-13 07:20:09 +00001466 hw->phy.ops.write_reg_page(hw, BM_RAR_L(i),
1467 (u16)(mac_reg & 0xFFFF));
1468 hw->phy.ops.write_reg_page(hw, BM_RAR_M(i),
1469 (u16)((mac_reg >> 16) & 0xFFFF));
1470
Bruce Alland3738bb2010-06-16 13:27:28 +00001471 mac_reg = er32(RAH(i));
Bruce Allan2b6b1682011-05-13 07:20:09 +00001472 hw->phy.ops.write_reg_page(hw, BM_RAR_H(i),
1473 (u16)(mac_reg & 0xFFFF));
1474 hw->phy.ops.write_reg_page(hw, BM_RAR_CTRL(i),
1475 (u16)((mac_reg & E1000_RAH_AV)
1476 >> 16));
Bruce Alland3738bb2010-06-16 13:27:28 +00001477 }
Bruce Allan2b6b1682011-05-13 07:20:09 +00001478
1479 e1000_disable_phy_wakeup_reg_access_bm(hw, &phy_reg);
1480
1481release:
1482 hw->phy.ops.release(hw);
Bruce Alland3738bb2010-06-16 13:27:28 +00001483}
1484
Bruce Alland3738bb2010-06-16 13:27:28 +00001485/**
1486 * e1000_lv_jumbo_workaround_ich8lan - required for jumbo frame operation
1487 * with 82579 PHY
1488 * @hw: pointer to the HW structure
1489 * @enable: flag to enable/disable workaround when enabling/disabling jumbos
1490 **/
1491s32 e1000_lv_jumbo_workaround_ich8lan(struct e1000_hw *hw, bool enable)
1492{
1493 s32 ret_val = 0;
1494 u16 phy_reg, data;
1495 u32 mac_reg;
1496 u16 i;
1497
1498 if (hw->mac.type != e1000_pch2lan)
Bruce Allan5015e532012-02-08 02:55:56 +00001499 return 0;
Bruce Alland3738bb2010-06-16 13:27:28 +00001500
1501 /* disable Rx path while enabling/disabling workaround */
1502 e1e_rphy(hw, PHY_REG(769, 20), &phy_reg);
1503 ret_val = e1e_wphy(hw, PHY_REG(769, 20), phy_reg | (1 << 14));
1504 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001505 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001506
1507 if (enable) {
1508 /*
1509 * Write Rx addresses (rar_entry_count for RAL/H, +4 for
1510 * SHRAL/H) and initial CRC values to the MAC
1511 */
1512 for (i = 0; i < (hw->mac.rar_entry_count + 4); i++) {
1513 u8 mac_addr[ETH_ALEN] = {0};
1514 u32 addr_high, addr_low;
1515
1516 addr_high = er32(RAH(i));
1517 if (!(addr_high & E1000_RAH_AV))
1518 continue;
1519 addr_low = er32(RAL(i));
1520 mac_addr[0] = (addr_low & 0xFF);
1521 mac_addr[1] = ((addr_low >> 8) & 0xFF);
1522 mac_addr[2] = ((addr_low >> 16) & 0xFF);
1523 mac_addr[3] = ((addr_low >> 24) & 0xFF);
1524 mac_addr[4] = (addr_high & 0xFF);
1525 mac_addr[5] = ((addr_high >> 8) & 0xFF);
1526
Bruce Allanfe46f582011-01-06 14:29:51 +00001527 ew32(PCH_RAICC(i), ~ether_crc_le(ETH_ALEN, mac_addr));
Bruce Alland3738bb2010-06-16 13:27:28 +00001528 }
1529
1530 /* Write Rx addresses to the PHY */
1531 e1000_copy_rx_addrs_to_phy_ich8lan(hw);
1532
1533 /* Enable jumbo frame workaround in the MAC */
1534 mac_reg = er32(FFLT_DBG);
1535 mac_reg &= ~(1 << 14);
1536 mac_reg |= (7 << 15);
1537 ew32(FFLT_DBG, mac_reg);
1538
1539 mac_reg = er32(RCTL);
1540 mac_reg |= E1000_RCTL_SECRC;
1541 ew32(RCTL, mac_reg);
1542
1543 ret_val = e1000e_read_kmrn_reg(hw,
1544 E1000_KMRNCTRLSTA_CTRL_OFFSET,
1545 &data);
1546 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001547 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001548 ret_val = e1000e_write_kmrn_reg(hw,
1549 E1000_KMRNCTRLSTA_CTRL_OFFSET,
1550 data | (1 << 0));
1551 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001552 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001553 ret_val = e1000e_read_kmrn_reg(hw,
1554 E1000_KMRNCTRLSTA_HD_CTRL,
1555 &data);
1556 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001557 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001558 data &= ~(0xF << 8);
1559 data |= (0xB << 8);
1560 ret_val = e1000e_write_kmrn_reg(hw,
1561 E1000_KMRNCTRLSTA_HD_CTRL,
1562 data);
1563 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001564 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001565
1566 /* Enable jumbo frame workaround in the PHY */
Bruce Alland3738bb2010-06-16 13:27:28 +00001567 e1e_rphy(hw, PHY_REG(769, 23), &data);
1568 data &= ~(0x7F << 5);
1569 data |= (0x37 << 5);
1570 ret_val = e1e_wphy(hw, PHY_REG(769, 23), data);
1571 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001572 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001573 e1e_rphy(hw, PHY_REG(769, 16), &data);
1574 data &= ~(1 << 13);
Bruce Alland3738bb2010-06-16 13:27:28 +00001575 ret_val = e1e_wphy(hw, PHY_REG(769, 16), data);
1576 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001577 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001578 e1e_rphy(hw, PHY_REG(776, 20), &data);
1579 data &= ~(0x3FF << 2);
1580 data |= (0x1A << 2);
1581 ret_val = e1e_wphy(hw, PHY_REG(776, 20), data);
1582 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001583 return ret_val;
Bruce Allanb64e9dd2011-09-30 08:07:00 +00001584 ret_val = e1e_wphy(hw, PHY_REG(776, 23), 0xF100);
Bruce Alland3738bb2010-06-16 13:27:28 +00001585 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001586 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001587 e1e_rphy(hw, HV_PM_CTRL, &data);
1588 ret_val = e1e_wphy(hw, HV_PM_CTRL, data | (1 << 10));
1589 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001590 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001591 } else {
1592 /* Write MAC register values back to h/w defaults */
1593 mac_reg = er32(FFLT_DBG);
1594 mac_reg &= ~(0xF << 14);
1595 ew32(FFLT_DBG, mac_reg);
1596
1597 mac_reg = er32(RCTL);
1598 mac_reg &= ~E1000_RCTL_SECRC;
Bruce Allana1ce6472010-09-22 17:16:40 +00001599 ew32(RCTL, mac_reg);
Bruce Alland3738bb2010-06-16 13:27:28 +00001600
1601 ret_val = e1000e_read_kmrn_reg(hw,
1602 E1000_KMRNCTRLSTA_CTRL_OFFSET,
1603 &data);
1604 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001605 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001606 ret_val = e1000e_write_kmrn_reg(hw,
1607 E1000_KMRNCTRLSTA_CTRL_OFFSET,
1608 data & ~(1 << 0));
1609 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001610 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001611 ret_val = e1000e_read_kmrn_reg(hw,
1612 E1000_KMRNCTRLSTA_HD_CTRL,
1613 &data);
1614 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001615 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001616 data &= ~(0xF << 8);
1617 data |= (0xB << 8);
1618 ret_val = e1000e_write_kmrn_reg(hw,
1619 E1000_KMRNCTRLSTA_HD_CTRL,
1620 data);
1621 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001622 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001623
1624 /* Write PHY register values back to h/w defaults */
Bruce Alland3738bb2010-06-16 13:27:28 +00001625 e1e_rphy(hw, PHY_REG(769, 23), &data);
1626 data &= ~(0x7F << 5);
1627 ret_val = e1e_wphy(hw, PHY_REG(769, 23), data);
1628 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001629 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001630 e1e_rphy(hw, PHY_REG(769, 16), &data);
Bruce Alland3738bb2010-06-16 13:27:28 +00001631 data |= (1 << 13);
1632 ret_val = e1e_wphy(hw, PHY_REG(769, 16), data);
1633 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001634 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001635 e1e_rphy(hw, PHY_REG(776, 20), &data);
1636 data &= ~(0x3FF << 2);
1637 data |= (0x8 << 2);
1638 ret_val = e1e_wphy(hw, PHY_REG(776, 20), data);
1639 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001640 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001641 ret_val = e1e_wphy(hw, PHY_REG(776, 23), 0x7E00);
1642 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001643 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001644 e1e_rphy(hw, HV_PM_CTRL, &data);
1645 ret_val = e1e_wphy(hw, HV_PM_CTRL, data & ~(1 << 10));
1646 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001647 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001648 }
1649
1650 /* re-enable Rx path after enabling/disabling workaround */
Bruce Allan5015e532012-02-08 02:55:56 +00001651 return e1e_wphy(hw, PHY_REG(769, 20), phy_reg & ~(1 << 14));
Bruce Alland3738bb2010-06-16 13:27:28 +00001652}
1653
1654/**
1655 * e1000_lv_phy_workarounds_ich8lan - A series of Phy workarounds to be
1656 * done after every PHY reset.
1657 **/
1658static s32 e1000_lv_phy_workarounds_ich8lan(struct e1000_hw *hw)
1659{
1660 s32 ret_val = 0;
1661
1662 if (hw->mac.type != e1000_pch2lan)
Bruce Allan5015e532012-02-08 02:55:56 +00001663 return 0;
Bruce Alland3738bb2010-06-16 13:27:28 +00001664
1665 /* Set MDIO slow mode before any other MDIO access */
1666 ret_val = e1000_set_mdio_slow_mode_hv(hw);
1667
Bruce Allan4d241362011-12-16 00:46:06 +00001668 ret_val = hw->phy.ops.acquire(hw);
1669 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001670 return ret_val;
Bruce Allan4d241362011-12-16 00:46:06 +00001671 ret_val = hw->phy.ops.write_reg_locked(hw, I82579_EMI_ADDR,
1672 I82579_MSE_THRESHOLD);
1673 if (ret_val)
1674 goto release;
1675 /* set MSE higher to enable link to stay up when noise is high */
1676 ret_val = hw->phy.ops.write_reg_locked(hw, I82579_EMI_DATA, 0x0034);
1677 if (ret_val)
1678 goto release;
1679 ret_val = hw->phy.ops.write_reg_locked(hw, I82579_EMI_ADDR,
1680 I82579_MSE_LINK_DOWN);
1681 if (ret_val)
1682 goto release;
1683 /* drop link after 5 times MSE threshold was reached */
1684 ret_val = hw->phy.ops.write_reg_locked(hw, I82579_EMI_DATA, 0x0005);
1685release:
1686 hw->phy.ops.release(hw);
1687
Bruce Alland3738bb2010-06-16 13:27:28 +00001688 return ret_val;
1689}
1690
1691/**
Bruce Allan831bd2e2010-09-22 17:16:18 +00001692 * e1000_k1_gig_workaround_lv - K1 Si workaround
1693 * @hw: pointer to the HW structure
1694 *
1695 * Workaround to set the K1 beacon duration for 82579 parts
1696 **/
1697static s32 e1000_k1_workaround_lv(struct e1000_hw *hw)
1698{
1699 s32 ret_val = 0;
1700 u16 status_reg = 0;
1701 u32 mac_reg;
Bruce Allan0ed013e2011-07-29 05:52:56 +00001702 u16 phy_reg;
Bruce Allan831bd2e2010-09-22 17:16:18 +00001703
1704 if (hw->mac.type != e1000_pch2lan)
Bruce Allan5015e532012-02-08 02:55:56 +00001705 return 0;
Bruce Allan831bd2e2010-09-22 17:16:18 +00001706
1707 /* Set K1 beacon duration based on 1Gbps speed or otherwise */
1708 ret_val = e1e_rphy(hw, HV_M_STATUS, &status_reg);
1709 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001710 return ret_val;
Bruce Allan831bd2e2010-09-22 17:16:18 +00001711
1712 if ((status_reg & (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE))
1713 == (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE)) {
1714 mac_reg = er32(FEXTNVM4);
1715 mac_reg &= ~E1000_FEXTNVM4_BEACON_DURATION_MASK;
1716
Bruce Allan0ed013e2011-07-29 05:52:56 +00001717 ret_val = e1e_rphy(hw, I82579_LPI_CTRL, &phy_reg);
1718 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001719 return ret_val;
Bruce Allan831bd2e2010-09-22 17:16:18 +00001720
Bruce Allan0ed013e2011-07-29 05:52:56 +00001721 if (status_reg & HV_M_STATUS_SPEED_1000) {
Bruce Allan36ceeb42012-03-20 03:47:47 +00001722 u16 pm_phy_reg;
1723
Bruce Allan0ed013e2011-07-29 05:52:56 +00001724 mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_8USEC;
1725 phy_reg &= ~I82579_LPI_CTRL_FORCE_PLL_LOCK_COUNT;
Bruce Allan36ceeb42012-03-20 03:47:47 +00001726 /* LV 1G Packet drop issue wa */
1727 ret_val = e1e_rphy(hw, HV_PM_CTRL, &pm_phy_reg);
1728 if (ret_val)
1729 return ret_val;
1730 pm_phy_reg &= ~HV_PM_CTRL_PLL_STOP_IN_K1_GIGA;
1731 ret_val = e1e_wphy(hw, HV_PM_CTRL, pm_phy_reg);
1732 if (ret_val)
1733 return ret_val;
Bruce Allan0ed013e2011-07-29 05:52:56 +00001734 } else {
1735 mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_16USEC;
1736 phy_reg |= I82579_LPI_CTRL_FORCE_PLL_LOCK_COUNT;
1737 }
Bruce Allan831bd2e2010-09-22 17:16:18 +00001738 ew32(FEXTNVM4, mac_reg);
Bruce Allan0ed013e2011-07-29 05:52:56 +00001739 ret_val = e1e_wphy(hw, I82579_LPI_CTRL, phy_reg);
Bruce Allan831bd2e2010-09-22 17:16:18 +00001740 }
1741
Bruce Allan831bd2e2010-09-22 17:16:18 +00001742 return ret_val;
1743}
1744
1745/**
Bruce Allan605c82b2010-09-22 17:17:01 +00001746 * e1000_gate_hw_phy_config_ich8lan - disable PHY config via hardware
1747 * @hw: pointer to the HW structure
1748 * @gate: boolean set to true to gate, false to ungate
1749 *
1750 * Gate/ungate the automatic PHY configuration via hardware; perform
1751 * the configuration via software instead.
1752 **/
1753static void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate)
1754{
1755 u32 extcnf_ctrl;
1756
1757 if (hw->mac.type != e1000_pch2lan)
1758 return;
1759
1760 extcnf_ctrl = er32(EXTCNF_CTRL);
1761
1762 if (gate)
1763 extcnf_ctrl |= E1000_EXTCNF_CTRL_GATE_PHY_CFG;
1764 else
1765 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_GATE_PHY_CFG;
1766
1767 ew32(EXTCNF_CTRL, extcnf_ctrl);
Bruce Allan605c82b2010-09-22 17:17:01 +00001768}
1769
1770/**
Bruce Allanfc0c7762009-07-01 13:27:55 +00001771 * e1000_lan_init_done_ich8lan - Check for PHY config completion
1772 * @hw: pointer to the HW structure
1773 *
1774 * Check the appropriate indication the MAC has finished configuring the
1775 * PHY after a software reset.
1776 **/
1777static void e1000_lan_init_done_ich8lan(struct e1000_hw *hw)
1778{
1779 u32 data, loop = E1000_ICH8_LAN_INIT_TIMEOUT;
1780
1781 /* Wait for basic configuration completes before proceeding */
1782 do {
1783 data = er32(STATUS);
1784 data &= E1000_STATUS_LAN_INIT_DONE;
1785 udelay(100);
1786 } while ((!data) && --loop);
1787
1788 /*
1789 * If basic configuration is incomplete before the above loop
1790 * count reaches 0, loading the configuration from NVM will
1791 * leave the PHY in a bad state possibly resulting in no link.
1792 */
1793 if (loop == 0)
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001794 e_dbg("LAN_INIT_DONE not set, increase timeout\n");
Bruce Allanfc0c7762009-07-01 13:27:55 +00001795
1796 /* Clear the Init Done bit for the next init event */
1797 data = er32(STATUS);
1798 data &= ~E1000_STATUS_LAN_INIT_DONE;
1799 ew32(STATUS, data);
1800}
1801
1802/**
Bruce Allane98cac42010-05-10 15:02:32 +00001803 * e1000_post_phy_reset_ich8lan - Perform steps required after a PHY reset
Auke Kokbc7f75f2007-09-17 12:30:59 -07001804 * @hw: pointer to the HW structure
Auke Kokbc7f75f2007-09-17 12:30:59 -07001805 **/
Bruce Allane98cac42010-05-10 15:02:32 +00001806static s32 e1000_post_phy_reset_ich8lan(struct e1000_hw *hw)
Auke Kokbc7f75f2007-09-17 12:30:59 -07001807{
Bruce Allanf523d212009-10-29 13:45:45 +00001808 s32 ret_val = 0;
1809 u16 reg;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001810
Bruce Allan44abd5c2012-02-22 09:02:37 +00001811 if (hw->phy.ops.check_reset_block(hw))
Bruce Allan5015e532012-02-08 02:55:56 +00001812 return 0;
Bruce Allanfc0c7762009-07-01 13:27:55 +00001813
Bruce Allan5f3eed62010-09-22 17:15:54 +00001814 /* Allow time for h/w to get to quiescent state after reset */
Bruce Allan1bba4382011-03-19 00:27:20 +00001815 usleep_range(10000, 20000);
Bruce Allan5f3eed62010-09-22 17:15:54 +00001816
Bruce Allanfddaa1a2010-01-13 01:52:49 +00001817 /* Perform any necessary post-reset workarounds */
Bruce Allane98cac42010-05-10 15:02:32 +00001818 switch (hw->mac.type) {
1819 case e1000_pchlan:
Bruce Allana4f58f52009-06-02 11:29:18 +00001820 ret_val = e1000_hv_phy_workarounds_ich8lan(hw);
1821 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001822 return ret_val;
Bruce Allane98cac42010-05-10 15:02:32 +00001823 break;
Bruce Alland3738bb2010-06-16 13:27:28 +00001824 case e1000_pch2lan:
1825 ret_val = e1000_lv_phy_workarounds_ich8lan(hw);
1826 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001827 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001828 break;
Bruce Allane98cac42010-05-10 15:02:32 +00001829 default:
1830 break;
Bruce Allana4f58f52009-06-02 11:29:18 +00001831 }
1832
Bruce Allan3ebfc7c2011-05-13 07:20:14 +00001833 /* Clear the host wakeup bit after lcd reset */
1834 if (hw->mac.type >= e1000_pchlan) {
1835 e1e_rphy(hw, BM_PORT_GEN_CFG, &reg);
1836 reg &= ~BM_WUC_HOST_WU_BIT;
1837 e1e_wphy(hw, BM_PORT_GEN_CFG, reg);
1838 }
Bruce Allandb2932e2009-10-26 11:22:47 +00001839
Bruce Allanf523d212009-10-29 13:45:45 +00001840 /* Configure the LCD with the extended configuration region in NVM */
1841 ret_val = e1000_sw_lcd_config_ich8lan(hw);
1842 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001843 return ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001844
Bruce Allanf523d212009-10-29 13:45:45 +00001845 /* Configure the LCD with the OEM bits in NVM */
Bruce Allane98cac42010-05-10 15:02:32 +00001846 ret_val = e1000_oem_bits_config_ich8lan(hw, true);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001847
Bruce Allan1effb452011-02-25 06:58:03 +00001848 if (hw->mac.type == e1000_pch2lan) {
1849 /* Ungate automatic PHY configuration on non-managed 82579 */
1850 if (!(er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) {
Bruce Allan1bba4382011-03-19 00:27:20 +00001851 usleep_range(10000, 20000);
Bruce Allan1effb452011-02-25 06:58:03 +00001852 e1000_gate_hw_phy_config_ich8lan(hw, false);
1853 }
1854
1855 /* Set EEE LPI Update Timer to 200usec */
1856 ret_val = hw->phy.ops.acquire(hw);
1857 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001858 return ret_val;
Bruce Allan1effb452011-02-25 06:58:03 +00001859 ret_val = hw->phy.ops.write_reg_locked(hw, I82579_EMI_ADDR,
1860 I82579_LPI_UPDATE_TIMER);
Bruce Allan5015e532012-02-08 02:55:56 +00001861 if (!ret_val)
1862 ret_val = hw->phy.ops.write_reg_locked(hw,
1863 I82579_EMI_DATA,
1864 0x1387);
Bruce Allan1effb452011-02-25 06:58:03 +00001865 hw->phy.ops.release(hw);
Bruce Allan605c82b2010-09-22 17:17:01 +00001866 }
1867
Bruce Allane98cac42010-05-10 15:02:32 +00001868 return ret_val;
1869}
1870
1871/**
1872 * e1000_phy_hw_reset_ich8lan - Performs a PHY reset
1873 * @hw: pointer to the HW structure
1874 *
1875 * Resets the PHY
1876 * This is a function pointer entry point called by drivers
1877 * or other shared routines.
1878 **/
1879static s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw)
1880{
1881 s32 ret_val = 0;
1882
Bruce Allan605c82b2010-09-22 17:17:01 +00001883 /* Gate automatic PHY configuration by hardware on non-managed 82579 */
1884 if ((hw->mac.type == e1000_pch2lan) &&
1885 !(er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
1886 e1000_gate_hw_phy_config_ich8lan(hw, true);
1887
Bruce Allane98cac42010-05-10 15:02:32 +00001888 ret_val = e1000e_phy_hw_reset_generic(hw);
1889 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001890 return ret_val;
Bruce Allane98cac42010-05-10 15:02:32 +00001891
Bruce Allan5015e532012-02-08 02:55:56 +00001892 return e1000_post_phy_reset_ich8lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001893}
1894
1895/**
Bruce Allanfa2ce132009-10-26 11:23:25 +00001896 * e1000_set_lplu_state_pchlan - Set Low Power Link Up state
1897 * @hw: pointer to the HW structure
1898 * @active: true to enable LPLU, false to disable
1899 *
1900 * Sets the LPLU state according to the active flag. For PCH, if OEM write
1901 * bit are disabled in the NVM, writing the LPLU bits in the MAC will not set
1902 * the phy speed. This function will manually set the LPLU bit and restart
1903 * auto-neg as hw would do. D3 and D0 LPLU will call the same function
1904 * since it configures the same bit.
1905 **/
1906static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active)
1907{
1908 s32 ret_val = 0;
1909 u16 oem_reg;
1910
1911 ret_val = e1e_rphy(hw, HV_OEM_BITS, &oem_reg);
1912 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001913 return ret_val;
Bruce Allanfa2ce132009-10-26 11:23:25 +00001914
1915 if (active)
1916 oem_reg |= HV_OEM_BITS_LPLU;
1917 else
1918 oem_reg &= ~HV_OEM_BITS_LPLU;
1919
Bruce Allan44abd5c2012-02-22 09:02:37 +00001920 if (!hw->phy.ops.check_reset_block(hw))
Bruce Allan464c85e2011-12-16 00:46:49 +00001921 oem_reg |= HV_OEM_BITS_RESTART_AN;
1922
Bruce Allan5015e532012-02-08 02:55:56 +00001923 return e1e_wphy(hw, HV_OEM_BITS, oem_reg);
Bruce Allanfa2ce132009-10-26 11:23:25 +00001924}
1925
1926/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07001927 * e1000_set_d0_lplu_state_ich8lan - Set Low Power Linkup D0 state
1928 * @hw: pointer to the HW structure
Bruce Allan564ea9b2009-11-20 23:26:44 +00001929 * @active: true to enable LPLU, false to disable
Auke Kokbc7f75f2007-09-17 12:30:59 -07001930 *
1931 * Sets the LPLU D0 state according to the active flag. When
1932 * activating LPLU this function also disables smart speed
1933 * and vice versa. LPLU will not be activated unless the
1934 * device autonegotiation advertisement meets standards of
1935 * either 10 or 10/100 or 10/100/1000 at all duplexes.
1936 * This is a function pointer entry point only called by
1937 * PHY setup routines.
1938 **/
1939static s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
1940{
1941 struct e1000_phy_info *phy = &hw->phy;
1942 u32 phy_ctrl;
1943 s32 ret_val = 0;
1944 u16 data;
1945
Bruce Allan97ac8ca2008-04-29 09:16:05 -07001946 if (phy->type == e1000_phy_ife)
Bruce Allan82607252012-02-08 02:55:09 +00001947 return 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001948
1949 phy_ctrl = er32(PHY_CTRL);
1950
1951 if (active) {
1952 phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU;
1953 ew32(PHY_CTRL, phy_ctrl);
1954
Bruce Allan60f12922009-07-01 13:28:14 +00001955 if (phy->type != e1000_phy_igp_3)
1956 return 0;
1957
Bruce Allanad680762008-03-28 09:15:03 -07001958 /*
1959 * Call gig speed drop workaround on LPLU before accessing
1960 * any PHY registers
1961 */
Bruce Allan60f12922009-07-01 13:28:14 +00001962 if (hw->mac.type == e1000_ich8lan)
Auke Kokbc7f75f2007-09-17 12:30:59 -07001963 e1000e_gig_downshift_workaround_ich8lan(hw);
1964
1965 /* When LPLU is enabled, we should disable SmartSpeed */
1966 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data);
1967 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
1968 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);
1969 if (ret_val)
1970 return ret_val;
1971 } else {
1972 phy_ctrl &= ~E1000_PHY_CTRL_D0A_LPLU;
1973 ew32(PHY_CTRL, phy_ctrl);
1974
Bruce Allan60f12922009-07-01 13:28:14 +00001975 if (phy->type != e1000_phy_igp_3)
1976 return 0;
1977
Bruce Allanad680762008-03-28 09:15:03 -07001978 /*
1979 * LPLU and SmartSpeed are mutually exclusive. LPLU is used
Auke Kokbc7f75f2007-09-17 12:30:59 -07001980 * during Dx states where the power conservation is most
1981 * important. During driver activity we should enable
Bruce Allanad680762008-03-28 09:15:03 -07001982 * SmartSpeed, so performance is maintained.
1983 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07001984 if (phy->smart_speed == e1000_smart_speed_on) {
1985 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
Bruce Allanad680762008-03-28 09:15:03 -07001986 &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001987 if (ret_val)
1988 return ret_val;
1989
1990 data |= IGP01E1000_PSCFR_SMART_SPEED;
1991 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
Bruce Allanad680762008-03-28 09:15:03 -07001992 data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001993 if (ret_val)
1994 return ret_val;
1995 } else if (phy->smart_speed == e1000_smart_speed_off) {
1996 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
Bruce Allanad680762008-03-28 09:15:03 -07001997 &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001998 if (ret_val)
1999 return ret_val;
2000
2001 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
2002 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
Bruce Allanad680762008-03-28 09:15:03 -07002003 data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002004 if (ret_val)
2005 return ret_val;
2006 }
2007 }
2008
2009 return 0;
2010}
2011
2012/**
2013 * e1000_set_d3_lplu_state_ich8lan - Set Low Power Linkup D3 state
2014 * @hw: pointer to the HW structure
Bruce Allan564ea9b2009-11-20 23:26:44 +00002015 * @active: true to enable LPLU, false to disable
Auke Kokbc7f75f2007-09-17 12:30:59 -07002016 *
2017 * Sets the LPLU D3 state according to the active flag. When
2018 * activating LPLU this function also disables smart speed
2019 * and vice versa. LPLU will not be activated unless the
2020 * device autonegotiation advertisement meets standards of
2021 * either 10 or 10/100 or 10/100/1000 at all duplexes.
2022 * This is a function pointer entry point only called by
2023 * PHY setup routines.
2024 **/
2025static s32 e1000_set_d3_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
2026{
2027 struct e1000_phy_info *phy = &hw->phy;
2028 u32 phy_ctrl;
Bruce Alland7eb3382012-02-08 02:55:14 +00002029 s32 ret_val = 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002030 u16 data;
2031
2032 phy_ctrl = er32(PHY_CTRL);
2033
2034 if (!active) {
2035 phy_ctrl &= ~E1000_PHY_CTRL_NOND0A_LPLU;
2036 ew32(PHY_CTRL, phy_ctrl);
Bruce Allan60f12922009-07-01 13:28:14 +00002037
2038 if (phy->type != e1000_phy_igp_3)
2039 return 0;
2040
Bruce Allanad680762008-03-28 09:15:03 -07002041 /*
2042 * LPLU and SmartSpeed are mutually exclusive. LPLU is used
Auke Kokbc7f75f2007-09-17 12:30:59 -07002043 * during Dx states where the power conservation is most
2044 * important. During driver activity we should enable
Bruce Allanad680762008-03-28 09:15:03 -07002045 * SmartSpeed, so performance is maintained.
2046 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002047 if (phy->smart_speed == e1000_smart_speed_on) {
Bruce Allanad680762008-03-28 09:15:03 -07002048 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
2049 &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002050 if (ret_val)
2051 return ret_val;
2052
2053 data |= IGP01E1000_PSCFR_SMART_SPEED;
Bruce Allanad680762008-03-28 09:15:03 -07002054 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
2055 data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002056 if (ret_val)
2057 return ret_val;
2058 } else if (phy->smart_speed == e1000_smart_speed_off) {
Bruce Allanad680762008-03-28 09:15:03 -07002059 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
2060 &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002061 if (ret_val)
2062 return ret_val;
2063
2064 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
Bruce Allanad680762008-03-28 09:15:03 -07002065 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
2066 data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002067 if (ret_val)
2068 return ret_val;
2069 }
2070 } else if ((phy->autoneg_advertised == E1000_ALL_SPEED_DUPLEX) ||
2071 (phy->autoneg_advertised == E1000_ALL_NOT_GIG) ||
2072 (phy->autoneg_advertised == E1000_ALL_10_SPEED)) {
2073 phy_ctrl |= E1000_PHY_CTRL_NOND0A_LPLU;
2074 ew32(PHY_CTRL, phy_ctrl);
2075
Bruce Allan60f12922009-07-01 13:28:14 +00002076 if (phy->type != e1000_phy_igp_3)
2077 return 0;
2078
Bruce Allanad680762008-03-28 09:15:03 -07002079 /*
2080 * Call gig speed drop workaround on LPLU before accessing
2081 * any PHY registers
2082 */
Bruce Allan60f12922009-07-01 13:28:14 +00002083 if (hw->mac.type == e1000_ich8lan)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002084 e1000e_gig_downshift_workaround_ich8lan(hw);
2085
2086 /* When LPLU is enabled, we should disable SmartSpeed */
Bruce Allanad680762008-03-28 09:15:03 -07002087 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002088 if (ret_val)
2089 return ret_val;
2090
2091 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
Bruce Allanad680762008-03-28 09:15:03 -07002092 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002093 }
2094
Bruce Alland7eb3382012-02-08 02:55:14 +00002095 return ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002096}
2097
2098/**
Bruce Allanf4187b52008-08-26 18:36:50 -07002099 * e1000_valid_nvm_bank_detect_ich8lan - finds out the valid bank 0 or 1
2100 * @hw: pointer to the HW structure
2101 * @bank: pointer to the variable that returns the active bank
2102 *
2103 * Reads signature byte from the NVM using the flash access registers.
Bruce Allane2434552008-11-21 17:02:41 -08002104 * Word 0x13 bits 15:14 = 10b indicate a valid signature for that bank.
Bruce Allanf4187b52008-08-26 18:36:50 -07002105 **/
2106static s32 e1000_valid_nvm_bank_detect_ich8lan(struct e1000_hw *hw, u32 *bank)
2107{
Bruce Allane2434552008-11-21 17:02:41 -08002108 u32 eecd;
Bruce Allanf4187b52008-08-26 18:36:50 -07002109 struct e1000_nvm_info *nvm = &hw->nvm;
Bruce Allanf4187b52008-08-26 18:36:50 -07002110 u32 bank1_offset = nvm->flash_bank_size * sizeof(u16);
2111 u32 act_offset = E1000_ICH_NVM_SIG_WORD * 2 + 1;
Bruce Allane2434552008-11-21 17:02:41 -08002112 u8 sig_byte = 0;
Bruce Allanf71dde62012-02-08 02:55:35 +00002113 s32 ret_val;
Bruce Allanf4187b52008-08-26 18:36:50 -07002114
Bruce Allane2434552008-11-21 17:02:41 -08002115 switch (hw->mac.type) {
2116 case e1000_ich8lan:
2117 case e1000_ich9lan:
2118 eecd = er32(EECD);
2119 if ((eecd & E1000_EECD_SEC1VAL_VALID_MASK) ==
2120 E1000_EECD_SEC1VAL_VALID_MASK) {
2121 if (eecd & E1000_EECD_SEC1VAL)
Bruce Allanf4187b52008-08-26 18:36:50 -07002122 *bank = 1;
Bruce Allane2434552008-11-21 17:02:41 -08002123 else
2124 *bank = 0;
2125
2126 return 0;
Bruce Allanf4187b52008-08-26 18:36:50 -07002127 }
Bruce Allan434f1392011-12-16 00:46:54 +00002128 e_dbg("Unable to determine valid NVM bank via EEC - reading flash signature\n");
Bruce Allane2434552008-11-21 17:02:41 -08002129 /* fall-thru */
2130 default:
2131 /* set bank to 0 in case flash read fails */
2132 *bank = 0;
2133
2134 /* Check bank 0 */
2135 ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset,
2136 &sig_byte);
2137 if (ret_val)
2138 return ret_val;
2139 if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
2140 E1000_ICH_NVM_SIG_VALUE) {
2141 *bank = 0;
2142 return 0;
2143 }
2144
2145 /* Check bank 1 */
2146 ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset +
2147 bank1_offset,
2148 &sig_byte);
2149 if (ret_val)
2150 return ret_val;
2151 if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
2152 E1000_ICH_NVM_SIG_VALUE) {
2153 *bank = 1;
2154 return 0;
2155 }
2156
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002157 e_dbg("ERROR: No valid NVM bank present\n");
Bruce Allane2434552008-11-21 17:02:41 -08002158 return -E1000_ERR_NVM;
Bruce Allanf4187b52008-08-26 18:36:50 -07002159 }
Bruce Allanf4187b52008-08-26 18:36:50 -07002160}
2161
2162/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07002163 * e1000_read_nvm_ich8lan - Read word(s) from the NVM
2164 * @hw: pointer to the HW structure
2165 * @offset: The offset (in bytes) of the word(s) to read.
2166 * @words: Size of data to read in words
2167 * @data: Pointer to the word(s) to read at offset.
2168 *
2169 * Reads a word(s) from the NVM using the flash access registers.
2170 **/
2171static s32 e1000_read_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
2172 u16 *data)
2173{
2174 struct e1000_nvm_info *nvm = &hw->nvm;
2175 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
2176 u32 act_offset;
Bruce Allan148675a2009-08-07 07:41:56 +00002177 s32 ret_val = 0;
Bruce Allanf4187b52008-08-26 18:36:50 -07002178 u32 bank = 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002179 u16 i, word;
2180
2181 if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
2182 (words == 0)) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002183 e_dbg("nvm parameter(s) out of bounds\n");
Bruce Allanca15df52009-10-26 11:23:43 +00002184 ret_val = -E1000_ERR_NVM;
2185 goto out;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002186 }
2187
Bruce Allan94d81862009-11-20 23:25:26 +00002188 nvm->ops.acquire(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002189
Bruce Allanf4187b52008-08-26 18:36:50 -07002190 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
Bruce Allan148675a2009-08-07 07:41:56 +00002191 if (ret_val) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002192 e_dbg("Could not detect valid bank, assuming bank 0\n");
Bruce Allan148675a2009-08-07 07:41:56 +00002193 bank = 0;
2194 }
Bruce Allanf4187b52008-08-26 18:36:50 -07002195
2196 act_offset = (bank) ? nvm->flash_bank_size : 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002197 act_offset += offset;
2198
Bruce Allan148675a2009-08-07 07:41:56 +00002199 ret_val = 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002200 for (i = 0; i < words; i++) {
Bruce Allanb9e06f72011-07-22 06:21:41 +00002201 if (dev_spec->shadow_ram[offset+i].modified) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07002202 data[i] = dev_spec->shadow_ram[offset+i].value;
2203 } else {
2204 ret_val = e1000_read_flash_word_ich8lan(hw,
2205 act_offset + i,
2206 &word);
2207 if (ret_val)
2208 break;
2209 data[i] = word;
2210 }
2211 }
2212
Bruce Allan94d81862009-11-20 23:25:26 +00002213 nvm->ops.release(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002214
Bruce Allane2434552008-11-21 17:02:41 -08002215out:
2216 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002217 e_dbg("NVM read error: %d\n", ret_val);
Bruce Allane2434552008-11-21 17:02:41 -08002218
Auke Kokbc7f75f2007-09-17 12:30:59 -07002219 return ret_val;
2220}
2221
2222/**
2223 * e1000_flash_cycle_init_ich8lan - Initialize flash
2224 * @hw: pointer to the HW structure
2225 *
2226 * This function does initial flash setup so that a new read/write/erase cycle
2227 * can be started.
2228 **/
2229static s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw)
2230{
2231 union ich8_hws_flash_status hsfsts;
2232 s32 ret_val = -E1000_ERR_NVM;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002233
2234 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
2235
2236 /* Check if the flash descriptor is valid */
Bruce Allan04499ec2012-04-13 00:08:31 +00002237 if (!hsfsts.hsf_status.fldesvalid) {
Bruce Allan434f1392011-12-16 00:46:54 +00002238 e_dbg("Flash descriptor invalid. SW Sequencing must be used.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07002239 return -E1000_ERR_NVM;
2240 }
2241
2242 /* Clear FCERR and DAEL in hw status by writing 1 */
2243 hsfsts.hsf_status.flcerr = 1;
2244 hsfsts.hsf_status.dael = 1;
2245
2246 ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
2247
Bruce Allanad680762008-03-28 09:15:03 -07002248 /*
2249 * Either we should have a hardware SPI cycle in progress
Auke Kokbc7f75f2007-09-17 12:30:59 -07002250 * bit to check against, in order to start a new cycle or
2251 * FDONE bit should be changed in the hardware so that it
Auke Kok489815c2008-02-21 15:11:07 -08002252 * is 1 after hardware reset, which can then be used as an
Auke Kokbc7f75f2007-09-17 12:30:59 -07002253 * indication whether a cycle is in progress or has been
2254 * completed.
2255 */
2256
Bruce Allan04499ec2012-04-13 00:08:31 +00002257 if (!hsfsts.hsf_status.flcinprog) {
Bruce Allanad680762008-03-28 09:15:03 -07002258 /*
2259 * There is no cycle running at present,
Bruce Allan5ff5b662009-12-01 15:51:11 +00002260 * so we can start a cycle.
Bruce Allanad680762008-03-28 09:15:03 -07002261 * Begin by setting Flash Cycle Done.
2262 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002263 hsfsts.hsf_status.flcdone = 1;
2264 ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
2265 ret_val = 0;
2266 } else {
Bruce Allanf71dde62012-02-08 02:55:35 +00002267 s32 i;
Bruce Allan90da0662011-01-06 07:02:53 +00002268
Bruce Allanad680762008-03-28 09:15:03 -07002269 /*
Bruce Allan5ff5b662009-12-01 15:51:11 +00002270 * Otherwise poll for sometime so the current
Bruce Allanad680762008-03-28 09:15:03 -07002271 * cycle has a chance to end before giving up.
2272 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002273 for (i = 0; i < ICH_FLASH_READ_COMMAND_TIMEOUT; i++) {
Bruce Allanc8243ee2011-12-17 08:32:57 +00002274 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
Bruce Allan04499ec2012-04-13 00:08:31 +00002275 if (!hsfsts.hsf_status.flcinprog) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07002276 ret_val = 0;
2277 break;
2278 }
2279 udelay(1);
2280 }
Bruce Allan9e2d7652012-01-31 06:37:27 +00002281 if (!ret_val) {
Bruce Allanad680762008-03-28 09:15:03 -07002282 /*
2283 * Successful in waiting for previous cycle to timeout,
2284 * now set the Flash Cycle Done.
2285 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002286 hsfsts.hsf_status.flcdone = 1;
2287 ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
2288 } else {
Joe Perches2c73e1f2010-03-26 20:16:59 +00002289 e_dbg("Flash controller busy, cannot get access\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07002290 }
2291 }
2292
2293 return ret_val;
2294}
2295
2296/**
2297 * e1000_flash_cycle_ich8lan - Starts flash cycle (read/write/erase)
2298 * @hw: pointer to the HW structure
2299 * @timeout: maximum time to wait for completion
2300 *
2301 * This function starts a flash cycle and waits for its completion.
2302 **/
2303static s32 e1000_flash_cycle_ich8lan(struct e1000_hw *hw, u32 timeout)
2304{
2305 union ich8_hws_flash_ctrl hsflctl;
2306 union ich8_hws_flash_status hsfsts;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002307 u32 i = 0;
2308
2309 /* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */
2310 hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
2311 hsflctl.hsf_ctrl.flcgo = 1;
2312 ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
2313
2314 /* wait till FDONE bit is set to 1 */
2315 do {
2316 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
Bruce Allan04499ec2012-04-13 00:08:31 +00002317 if (hsfsts.hsf_status.flcdone)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002318 break;
2319 udelay(1);
2320 } while (i++ < timeout);
2321
Bruce Allan04499ec2012-04-13 00:08:31 +00002322 if (hsfsts.hsf_status.flcdone && !hsfsts.hsf_status.flcerr)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002323 return 0;
2324
Bruce Allan55920b52012-02-08 02:55:25 +00002325 return -E1000_ERR_NVM;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002326}
2327
2328/**
2329 * e1000_read_flash_word_ich8lan - Read word from flash
2330 * @hw: pointer to the HW structure
2331 * @offset: offset to data location
2332 * @data: pointer to the location for storing the data
2333 *
2334 * Reads the flash word at offset into data. Offset is converted
2335 * to bytes before read.
2336 **/
2337static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset,
2338 u16 *data)
2339{
2340 /* Must convert offset into bytes. */
2341 offset <<= 1;
2342
2343 return e1000_read_flash_data_ich8lan(hw, offset, 2, data);
2344}
2345
2346/**
Bruce Allanf4187b52008-08-26 18:36:50 -07002347 * e1000_read_flash_byte_ich8lan - Read byte from flash
2348 * @hw: pointer to the HW structure
2349 * @offset: The offset of the byte to read.
2350 * @data: Pointer to a byte to store the value read.
2351 *
2352 * Reads a single byte from the NVM using the flash access registers.
2353 **/
2354static s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
2355 u8 *data)
2356{
2357 s32 ret_val;
2358 u16 word = 0;
2359
2360 ret_val = e1000_read_flash_data_ich8lan(hw, offset, 1, &word);
2361 if (ret_val)
2362 return ret_val;
2363
2364 *data = (u8)word;
2365
2366 return 0;
2367}
2368
2369/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07002370 * e1000_read_flash_data_ich8lan - Read byte or word from NVM
2371 * @hw: pointer to the HW structure
2372 * @offset: The offset (in bytes) of the byte or word to read.
2373 * @size: Size of data to read, 1=byte 2=word
2374 * @data: Pointer to the word to store the value read.
2375 *
2376 * Reads a byte or word from the NVM using the flash access registers.
2377 **/
2378static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
2379 u8 size, u16 *data)
2380{
2381 union ich8_hws_flash_status hsfsts;
2382 union ich8_hws_flash_ctrl hsflctl;
2383 u32 flash_linear_addr;
2384 u32 flash_data = 0;
2385 s32 ret_val = -E1000_ERR_NVM;
2386 u8 count = 0;
2387
2388 if (size < 1 || size > 2 || offset > ICH_FLASH_LINEAR_ADDR_MASK)
2389 return -E1000_ERR_NVM;
2390
2391 flash_linear_addr = (ICH_FLASH_LINEAR_ADDR_MASK & offset) +
2392 hw->nvm.flash_base_addr;
2393
2394 do {
2395 udelay(1);
2396 /* Steps */
2397 ret_val = e1000_flash_cycle_init_ich8lan(hw);
Bruce Allan9e2d7652012-01-31 06:37:27 +00002398 if (ret_val)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002399 break;
2400
2401 hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
2402 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
2403 hsflctl.hsf_ctrl.fldbcount = size - 1;
2404 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_READ;
2405 ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
2406
2407 ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
2408
2409 ret_val = e1000_flash_cycle_ich8lan(hw,
2410 ICH_FLASH_READ_COMMAND_TIMEOUT);
2411
Bruce Allanad680762008-03-28 09:15:03 -07002412 /*
2413 * Check if FCERR is set to 1, if set to 1, clear it
Auke Kokbc7f75f2007-09-17 12:30:59 -07002414 * and try the whole sequence a few more times, else
2415 * read in (shift in) the Flash Data0, the order is
Bruce Allanad680762008-03-28 09:15:03 -07002416 * least significant byte first msb to lsb
2417 */
Bruce Allan9e2d7652012-01-31 06:37:27 +00002418 if (!ret_val) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07002419 flash_data = er32flash(ICH_FLASH_FDATA0);
Bruce Allanb1cdfea2010-12-11 05:53:47 +00002420 if (size == 1)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002421 *data = (u8)(flash_data & 0x000000FF);
Bruce Allanb1cdfea2010-12-11 05:53:47 +00002422 else if (size == 2)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002423 *data = (u16)(flash_data & 0x0000FFFF);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002424 break;
2425 } else {
Bruce Allanad680762008-03-28 09:15:03 -07002426 /*
2427 * If we've gotten here, then things are probably
Auke Kokbc7f75f2007-09-17 12:30:59 -07002428 * completely hosed, but if the error condition is
2429 * detected, it won't hurt to give it another try...
2430 * ICH_FLASH_CYCLE_REPEAT_COUNT times.
2431 */
2432 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
Bruce Allan04499ec2012-04-13 00:08:31 +00002433 if (hsfsts.hsf_status.flcerr) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07002434 /* Repeat for some time before giving up. */
2435 continue;
Bruce Allan04499ec2012-04-13 00:08:31 +00002436 } else if (!hsfsts.hsf_status.flcdone) {
Bruce Allan434f1392011-12-16 00:46:54 +00002437 e_dbg("Timeout error - flash cycle did not complete.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07002438 break;
2439 }
2440 }
2441 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
2442
2443 return ret_val;
2444}
2445
2446/**
2447 * e1000_write_nvm_ich8lan - Write word(s) to the NVM
2448 * @hw: pointer to the HW structure
2449 * @offset: The offset (in bytes) of the word(s) to write.
2450 * @words: Size of data to write in words
2451 * @data: Pointer to the word(s) to write at offset.
2452 *
2453 * Writes a byte or word to the NVM using the flash access registers.
2454 **/
2455static s32 e1000_write_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
2456 u16 *data)
2457{
2458 struct e1000_nvm_info *nvm = &hw->nvm;
2459 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002460 u16 i;
2461
2462 if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
2463 (words == 0)) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002464 e_dbg("nvm parameter(s) out of bounds\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07002465 return -E1000_ERR_NVM;
2466 }
2467
Bruce Allan94d81862009-11-20 23:25:26 +00002468 nvm->ops.acquire(hw);
Bruce Allanca15df52009-10-26 11:23:43 +00002469
Auke Kokbc7f75f2007-09-17 12:30:59 -07002470 for (i = 0; i < words; i++) {
Bruce Allan564ea9b2009-11-20 23:26:44 +00002471 dev_spec->shadow_ram[offset+i].modified = true;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002472 dev_spec->shadow_ram[offset+i].value = data[i];
2473 }
2474
Bruce Allan94d81862009-11-20 23:25:26 +00002475 nvm->ops.release(hw);
Bruce Allanca15df52009-10-26 11:23:43 +00002476
Auke Kokbc7f75f2007-09-17 12:30:59 -07002477 return 0;
2478}
2479
2480/**
2481 * e1000_update_nvm_checksum_ich8lan - Update the checksum for NVM
2482 * @hw: pointer to the HW structure
2483 *
2484 * The NVM checksum is updated by calling the generic update_nvm_checksum,
2485 * which writes the checksum to the shadow ram. The changes in the shadow
2486 * ram are then committed to the EEPROM by processing each bank at a time
2487 * checking for the modified bit and writing only the pending changes.
Auke Kok489815c2008-02-21 15:11:07 -08002488 * After a successful commit, the shadow ram is cleared and is ready for
Auke Kokbc7f75f2007-09-17 12:30:59 -07002489 * future writes.
2490 **/
2491static s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw)
2492{
2493 struct e1000_nvm_info *nvm = &hw->nvm;
2494 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
Bruce Allanf4187b52008-08-26 18:36:50 -07002495 u32 i, act_offset, new_bank_offset, old_bank_offset, bank;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002496 s32 ret_val;
2497 u16 data;
2498
2499 ret_val = e1000e_update_nvm_checksum_generic(hw);
2500 if (ret_val)
Bruce Allane2434552008-11-21 17:02:41 -08002501 goto out;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002502
2503 if (nvm->type != e1000_nvm_flash_sw)
Bruce Allane2434552008-11-21 17:02:41 -08002504 goto out;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002505
Bruce Allan94d81862009-11-20 23:25:26 +00002506 nvm->ops.acquire(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002507
Bruce Allanad680762008-03-28 09:15:03 -07002508 /*
2509 * We're writing to the opposite bank so if we're on bank 1,
Auke Kokbc7f75f2007-09-17 12:30:59 -07002510 * write to bank 0 etc. We also need to erase the segment that
Bruce Allanad680762008-03-28 09:15:03 -07002511 * is going to be written
2512 */
Bruce Allanf4187b52008-08-26 18:36:50 -07002513 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
Bruce Allane2434552008-11-21 17:02:41 -08002514 if (ret_val) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002515 e_dbg("Could not detect valid bank, assuming bank 0\n");
Bruce Allan148675a2009-08-07 07:41:56 +00002516 bank = 0;
Bruce Allane2434552008-11-21 17:02:41 -08002517 }
Bruce Allanf4187b52008-08-26 18:36:50 -07002518
2519 if (bank == 0) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07002520 new_bank_offset = nvm->flash_bank_size;
2521 old_bank_offset = 0;
Bruce Allane2434552008-11-21 17:02:41 -08002522 ret_val = e1000_erase_flash_bank_ich8lan(hw, 1);
Bruce Allan9c5e2092010-05-10 15:00:31 +00002523 if (ret_val)
2524 goto release;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002525 } else {
2526 old_bank_offset = nvm->flash_bank_size;
2527 new_bank_offset = 0;
Bruce Allane2434552008-11-21 17:02:41 -08002528 ret_val = e1000_erase_flash_bank_ich8lan(hw, 0);
Bruce Allan9c5e2092010-05-10 15:00:31 +00002529 if (ret_val)
2530 goto release;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002531 }
2532
2533 for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i++) {
Bruce Allanad680762008-03-28 09:15:03 -07002534 /*
2535 * Determine whether to write the value stored
Auke Kokbc7f75f2007-09-17 12:30:59 -07002536 * in the other NVM bank or a modified value stored
Bruce Allanad680762008-03-28 09:15:03 -07002537 * in the shadow RAM
2538 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002539 if (dev_spec->shadow_ram[i].modified) {
2540 data = dev_spec->shadow_ram[i].value;
2541 } else {
Bruce Allane2434552008-11-21 17:02:41 -08002542 ret_val = e1000_read_flash_word_ich8lan(hw, i +
2543 old_bank_offset,
2544 &data);
2545 if (ret_val)
2546 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002547 }
2548
Bruce Allanad680762008-03-28 09:15:03 -07002549 /*
2550 * If the word is 0x13, then make sure the signature bits
Auke Kokbc7f75f2007-09-17 12:30:59 -07002551 * (15:14) are 11b until the commit has completed.
2552 * This will allow us to write 10b which indicates the
2553 * signature is valid. We want to do this after the write
2554 * has completed so that we don't mark the segment valid
Bruce Allanad680762008-03-28 09:15:03 -07002555 * while the write is still in progress
2556 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002557 if (i == E1000_ICH_NVM_SIG_WORD)
2558 data |= E1000_ICH_NVM_SIG_MASK;
2559
2560 /* Convert offset to bytes. */
2561 act_offset = (i + new_bank_offset) << 1;
2562
2563 udelay(100);
2564 /* Write the bytes to the new bank. */
2565 ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
2566 act_offset,
2567 (u8)data);
2568 if (ret_val)
2569 break;
2570
2571 udelay(100);
2572 ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
2573 act_offset + 1,
2574 (u8)(data >> 8));
2575 if (ret_val)
2576 break;
2577 }
2578
Bruce Allanad680762008-03-28 09:15:03 -07002579 /*
2580 * Don't bother writing the segment valid bits if sector
2581 * programming failed.
2582 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002583 if (ret_val) {
Bruce Allan4a770352008-10-01 17:18:35 -07002584 /* Possibly read-only, see e1000e_write_protect_nvm_ich8lan() */
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002585 e_dbg("Flash commit failed.\n");
Bruce Allan9c5e2092010-05-10 15:00:31 +00002586 goto release;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002587 }
2588
Bruce Allanad680762008-03-28 09:15:03 -07002589 /*
2590 * Finally validate the new segment by setting bit 15:14
Auke Kokbc7f75f2007-09-17 12:30:59 -07002591 * to 10b in word 0x13 , this can be done without an
2592 * erase as well since these bits are 11 to start with
Bruce Allanad680762008-03-28 09:15:03 -07002593 * and we need to change bit 14 to 0b
2594 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002595 act_offset = new_bank_offset + E1000_ICH_NVM_SIG_WORD;
Bruce Allane2434552008-11-21 17:02:41 -08002596 ret_val = e1000_read_flash_word_ich8lan(hw, act_offset, &data);
Bruce Allan9c5e2092010-05-10 15:00:31 +00002597 if (ret_val)
2598 goto release;
2599
Auke Kokbc7f75f2007-09-17 12:30:59 -07002600 data &= 0xBFFF;
2601 ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
2602 act_offset * 2 + 1,
2603 (u8)(data >> 8));
Bruce Allan9c5e2092010-05-10 15:00:31 +00002604 if (ret_val)
2605 goto release;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002606
Bruce Allanad680762008-03-28 09:15:03 -07002607 /*
2608 * And invalidate the previously valid segment by setting
Auke Kokbc7f75f2007-09-17 12:30:59 -07002609 * its signature word (0x13) high_byte to 0b. This can be
2610 * done without an erase because flash erase sets all bits
Bruce Allanad680762008-03-28 09:15:03 -07002611 * to 1's. We can write 1's to 0's without an erase
2612 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002613 act_offset = (old_bank_offset + E1000_ICH_NVM_SIG_WORD) * 2 + 1;
2614 ret_val = e1000_retry_write_flash_byte_ich8lan(hw, act_offset, 0);
Bruce Allan9c5e2092010-05-10 15:00:31 +00002615 if (ret_val)
2616 goto release;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002617
2618 /* Great! Everything worked, we can now clear the cached entries. */
2619 for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i++) {
Bruce Allan564ea9b2009-11-20 23:26:44 +00002620 dev_spec->shadow_ram[i].modified = false;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002621 dev_spec->shadow_ram[i].value = 0xFFFF;
2622 }
2623
Bruce Allan9c5e2092010-05-10 15:00:31 +00002624release:
Bruce Allan94d81862009-11-20 23:25:26 +00002625 nvm->ops.release(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002626
Bruce Allanad680762008-03-28 09:15:03 -07002627 /*
2628 * Reload the EEPROM, or else modifications will not appear
Auke Kokbc7f75f2007-09-17 12:30:59 -07002629 * until after the next adapter reset.
2630 */
Bruce Allan9c5e2092010-05-10 15:00:31 +00002631 if (!ret_val) {
Bruce Allane85e3632012-02-22 09:03:14 +00002632 nvm->ops.reload(hw);
Bruce Allan1bba4382011-03-19 00:27:20 +00002633 usleep_range(10000, 20000);
Bruce Allan9c5e2092010-05-10 15:00:31 +00002634 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07002635
Bruce Allane2434552008-11-21 17:02:41 -08002636out:
2637 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002638 e_dbg("NVM update error: %d\n", ret_val);
Bruce Allane2434552008-11-21 17:02:41 -08002639
Auke Kokbc7f75f2007-09-17 12:30:59 -07002640 return ret_val;
2641}
2642
2643/**
2644 * e1000_validate_nvm_checksum_ich8lan - Validate EEPROM checksum
2645 * @hw: pointer to the HW structure
2646 *
2647 * Check to see if checksum needs to be fixed by reading bit 6 in word 0x19.
2648 * If the bit is 0, that the EEPROM had been modified, but the checksum was not
2649 * calculated, in which case we need to calculate the checksum and set bit 6.
2650 **/
2651static s32 e1000_validate_nvm_checksum_ich8lan(struct e1000_hw *hw)
2652{
2653 s32 ret_val;
2654 u16 data;
2655
Bruce Allanad680762008-03-28 09:15:03 -07002656 /*
2657 * Read 0x19 and check bit 6. If this bit is 0, the checksum
Auke Kokbc7f75f2007-09-17 12:30:59 -07002658 * needs to be fixed. This bit is an indication that the NVM
2659 * was prepared by OEM software and did not calculate the
2660 * checksum...a likely scenario.
2661 */
2662 ret_val = e1000_read_nvm(hw, 0x19, 1, &data);
2663 if (ret_val)
2664 return ret_val;
2665
Bruce Allan04499ec2012-04-13 00:08:31 +00002666 if (!(data & 0x40)) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07002667 data |= 0x40;
2668 ret_val = e1000_write_nvm(hw, 0x19, 1, &data);
2669 if (ret_val)
2670 return ret_val;
2671 ret_val = e1000e_update_nvm_checksum(hw);
2672 if (ret_val)
2673 return ret_val;
2674 }
2675
2676 return e1000e_validate_nvm_checksum_generic(hw);
2677}
2678
2679/**
Bruce Allan4a770352008-10-01 17:18:35 -07002680 * e1000e_write_protect_nvm_ich8lan - Make the NVM read-only
2681 * @hw: pointer to the HW structure
2682 *
2683 * To prevent malicious write/erase of the NVM, set it to be read-only
2684 * so that the hardware ignores all write/erase cycles of the NVM via
2685 * the flash control registers. The shadow-ram copy of the NVM will
2686 * still be updated, however any updates to this copy will not stick
2687 * across driver reloads.
2688 **/
2689void e1000e_write_protect_nvm_ich8lan(struct e1000_hw *hw)
2690{
Bruce Allanca15df52009-10-26 11:23:43 +00002691 struct e1000_nvm_info *nvm = &hw->nvm;
Bruce Allan4a770352008-10-01 17:18:35 -07002692 union ich8_flash_protected_range pr0;
2693 union ich8_hws_flash_status hsfsts;
2694 u32 gfpreg;
Bruce Allan4a770352008-10-01 17:18:35 -07002695
Bruce Allan94d81862009-11-20 23:25:26 +00002696 nvm->ops.acquire(hw);
Bruce Allan4a770352008-10-01 17:18:35 -07002697
2698 gfpreg = er32flash(ICH_FLASH_GFPREG);
2699
2700 /* Write-protect GbE Sector of NVM */
2701 pr0.regval = er32flash(ICH_FLASH_PR0);
2702 pr0.range.base = gfpreg & FLASH_GFPREG_BASE_MASK;
2703 pr0.range.limit = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK);
2704 pr0.range.wpe = true;
2705 ew32flash(ICH_FLASH_PR0, pr0.regval);
2706
2707 /*
2708 * Lock down a subset of GbE Flash Control Registers, e.g.
2709 * PR0 to prevent the write-protection from being lifted.
2710 * Once FLOCKDN is set, the registers protected by it cannot
2711 * be written until FLOCKDN is cleared by a hardware reset.
2712 */
2713 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
2714 hsfsts.hsf_status.flockdn = true;
2715 ew32flash(ICH_FLASH_HSFSTS, hsfsts.regval);
2716
Bruce Allan94d81862009-11-20 23:25:26 +00002717 nvm->ops.release(hw);
Bruce Allan4a770352008-10-01 17:18:35 -07002718}
2719
2720/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07002721 * e1000_write_flash_data_ich8lan - Writes bytes to the NVM
2722 * @hw: pointer to the HW structure
2723 * @offset: The offset (in bytes) of the byte/word to read.
2724 * @size: Size of data to read, 1=byte 2=word
2725 * @data: The byte(s) to write to the NVM.
2726 *
2727 * Writes one/two bytes to the NVM using the flash access registers.
2728 **/
2729static s32 e1000_write_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
2730 u8 size, u16 data)
2731{
2732 union ich8_hws_flash_status hsfsts;
2733 union ich8_hws_flash_ctrl hsflctl;
2734 u32 flash_linear_addr;
2735 u32 flash_data = 0;
2736 s32 ret_val;
2737 u8 count = 0;
2738
2739 if (size < 1 || size > 2 || data > size * 0xff ||
2740 offset > ICH_FLASH_LINEAR_ADDR_MASK)
2741 return -E1000_ERR_NVM;
2742
2743 flash_linear_addr = (ICH_FLASH_LINEAR_ADDR_MASK & offset) +
2744 hw->nvm.flash_base_addr;
2745
2746 do {
2747 udelay(1);
2748 /* Steps */
2749 ret_val = e1000_flash_cycle_init_ich8lan(hw);
2750 if (ret_val)
2751 break;
2752
2753 hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
2754 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
2755 hsflctl.hsf_ctrl.fldbcount = size -1;
2756 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_WRITE;
2757 ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
2758
2759 ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
2760
2761 if (size == 1)
2762 flash_data = (u32)data & 0x00FF;
2763 else
2764 flash_data = (u32)data;
2765
2766 ew32flash(ICH_FLASH_FDATA0, flash_data);
2767
Bruce Allanad680762008-03-28 09:15:03 -07002768 /*
2769 * check if FCERR is set to 1 , if set to 1, clear it
2770 * and try the whole sequence a few more times else done
2771 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002772 ret_val = e1000_flash_cycle_ich8lan(hw,
2773 ICH_FLASH_WRITE_COMMAND_TIMEOUT);
2774 if (!ret_val)
2775 break;
2776
Bruce Allanad680762008-03-28 09:15:03 -07002777 /*
2778 * If we're here, then things are most likely
Auke Kokbc7f75f2007-09-17 12:30:59 -07002779 * completely hosed, but if the error condition
2780 * is detected, it won't hurt to give it another
2781 * try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
2782 */
2783 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
Bruce Allan04499ec2012-04-13 00:08:31 +00002784 if (hsfsts.hsf_status.flcerr)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002785 /* Repeat for some time before giving up. */
2786 continue;
Bruce Allan04499ec2012-04-13 00:08:31 +00002787 if (!hsfsts.hsf_status.flcdone) {
Bruce Allan434f1392011-12-16 00:46:54 +00002788 e_dbg("Timeout error - flash cycle did not complete.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07002789 break;
2790 }
2791 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
2792
2793 return ret_val;
2794}
2795
2796/**
2797 * e1000_write_flash_byte_ich8lan - Write a single byte to NVM
2798 * @hw: pointer to the HW structure
2799 * @offset: The index of the byte to read.
2800 * @data: The byte to write to the NVM.
2801 *
2802 * Writes a single byte to the NVM using the flash access registers.
2803 **/
2804static s32 e1000_write_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
2805 u8 data)
2806{
2807 u16 word = (u16)data;
2808
2809 return e1000_write_flash_data_ich8lan(hw, offset, 1, word);
2810}
2811
2812/**
2813 * e1000_retry_write_flash_byte_ich8lan - Writes a single byte to NVM
2814 * @hw: pointer to the HW structure
2815 * @offset: The offset of the byte to write.
2816 * @byte: The byte to write to the NVM.
2817 *
2818 * Writes a single byte to the NVM using the flash access registers.
2819 * Goes through a retry algorithm before giving up.
2820 **/
2821static s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw,
2822 u32 offset, u8 byte)
2823{
2824 s32 ret_val;
2825 u16 program_retries;
2826
2827 ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
2828 if (!ret_val)
2829 return ret_val;
2830
2831 for (program_retries = 0; program_retries < 100; program_retries++) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002832 e_dbg("Retrying Byte %2.2X at offset %u\n", byte, offset);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002833 udelay(100);
2834 ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
2835 if (!ret_val)
2836 break;
2837 }
2838 if (program_retries == 100)
2839 return -E1000_ERR_NVM;
2840
2841 return 0;
2842}
2843
2844/**
2845 * e1000_erase_flash_bank_ich8lan - Erase a bank (4k) from NVM
2846 * @hw: pointer to the HW structure
2847 * @bank: 0 for first bank, 1 for second bank, etc.
2848 *
2849 * Erases the bank specified. Each bank is a 4k block. Banks are 0 based.
2850 * bank N is 4096 * N + flash_reg_addr.
2851 **/
2852static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank)
2853{
2854 struct e1000_nvm_info *nvm = &hw->nvm;
2855 union ich8_hws_flash_status hsfsts;
2856 union ich8_hws_flash_ctrl hsflctl;
2857 u32 flash_linear_addr;
2858 /* bank size is in 16bit words - adjust to bytes */
2859 u32 flash_bank_size = nvm->flash_bank_size * 2;
2860 s32 ret_val;
2861 s32 count = 0;
Bruce Allana708dd82009-11-20 23:28:37 +00002862 s32 j, iteration, sector_size;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002863
2864 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
2865
Bruce Allanad680762008-03-28 09:15:03 -07002866 /*
2867 * Determine HW Sector size: Read BERASE bits of hw flash status
2868 * register
2869 * 00: The Hw sector is 256 bytes, hence we need to erase 16
Auke Kokbc7f75f2007-09-17 12:30:59 -07002870 * consecutive sectors. The start index for the nth Hw sector
2871 * can be calculated as = bank * 4096 + n * 256
2872 * 01: The Hw sector is 4K bytes, hence we need to erase 1 sector.
2873 * The start index for the nth Hw sector can be calculated
2874 * as = bank * 4096
2875 * 10: The Hw sector is 8K bytes, nth sector = bank * 8192
2876 * (ich9 only, otherwise error condition)
2877 * 11: The Hw sector is 64K bytes, nth sector = bank * 65536
2878 */
2879 switch (hsfsts.hsf_status.berasesz) {
2880 case 0:
2881 /* Hw sector size 256 */
2882 sector_size = ICH_FLASH_SEG_SIZE_256;
2883 iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_256;
2884 break;
2885 case 1:
2886 sector_size = ICH_FLASH_SEG_SIZE_4K;
Bruce Allan28c91952009-07-01 13:28:32 +00002887 iteration = 1;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002888 break;
2889 case 2:
Bruce Allan148675a2009-08-07 07:41:56 +00002890 sector_size = ICH_FLASH_SEG_SIZE_8K;
2891 iteration = 1;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002892 break;
2893 case 3:
2894 sector_size = ICH_FLASH_SEG_SIZE_64K;
Bruce Allan28c91952009-07-01 13:28:32 +00002895 iteration = 1;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002896 break;
2897 default:
2898 return -E1000_ERR_NVM;
2899 }
2900
2901 /* Start with the base address, then add the sector offset. */
2902 flash_linear_addr = hw->nvm.flash_base_addr;
Bruce Allan148675a2009-08-07 07:41:56 +00002903 flash_linear_addr += (bank) ? flash_bank_size : 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002904
2905 for (j = 0; j < iteration ; j++) {
2906 do {
2907 /* Steps */
2908 ret_val = e1000_flash_cycle_init_ich8lan(hw);
2909 if (ret_val)
2910 return ret_val;
2911
Bruce Allanad680762008-03-28 09:15:03 -07002912 /*
2913 * Write a value 11 (block Erase) in Flash
2914 * Cycle field in hw flash control
2915 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002916 hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
2917 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_ERASE;
2918 ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
2919
Bruce Allanad680762008-03-28 09:15:03 -07002920 /*
2921 * Write the last 24 bits of an index within the
Auke Kokbc7f75f2007-09-17 12:30:59 -07002922 * block into Flash Linear address field in Flash
2923 * Address.
2924 */
2925 flash_linear_addr += (j * sector_size);
2926 ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
2927
2928 ret_val = e1000_flash_cycle_ich8lan(hw,
2929 ICH_FLASH_ERASE_COMMAND_TIMEOUT);
Bruce Allan9e2d7652012-01-31 06:37:27 +00002930 if (!ret_val)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002931 break;
2932
Bruce Allanad680762008-03-28 09:15:03 -07002933 /*
2934 * Check if FCERR is set to 1. If 1,
Auke Kokbc7f75f2007-09-17 12:30:59 -07002935 * clear it and try the whole sequence
Bruce Allanad680762008-03-28 09:15:03 -07002936 * a few more times else Done
2937 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002938 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
Bruce Allan04499ec2012-04-13 00:08:31 +00002939 if (hsfsts.hsf_status.flcerr)
Bruce Allanad680762008-03-28 09:15:03 -07002940 /* repeat for some time before giving up */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002941 continue;
Bruce Allan04499ec2012-04-13 00:08:31 +00002942 else if (!hsfsts.hsf_status.flcdone)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002943 return ret_val;
2944 } while (++count < ICH_FLASH_CYCLE_REPEAT_COUNT);
2945 }
2946
2947 return 0;
2948}
2949
2950/**
2951 * e1000_valid_led_default_ich8lan - Set the default LED settings
2952 * @hw: pointer to the HW structure
2953 * @data: Pointer to the LED settings
2954 *
2955 * Reads the LED default settings from the NVM to data. If the NVM LED
2956 * settings is all 0's or F's, set the LED default to a valid LED default
2957 * setting.
2958 **/
2959static s32 e1000_valid_led_default_ich8lan(struct e1000_hw *hw, u16 *data)
2960{
2961 s32 ret_val;
2962
2963 ret_val = e1000_read_nvm(hw, NVM_ID_LED_SETTINGS, 1, data);
2964 if (ret_val) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002965 e_dbg("NVM Read Error\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07002966 return ret_val;
2967 }
2968
2969 if (*data == ID_LED_RESERVED_0000 ||
2970 *data == ID_LED_RESERVED_FFFF)
2971 *data = ID_LED_DEFAULT_ICH8LAN;
2972
2973 return 0;
2974}
2975
2976/**
Bruce Allana4f58f52009-06-02 11:29:18 +00002977 * e1000_id_led_init_pchlan - store LED configurations
2978 * @hw: pointer to the HW structure
2979 *
2980 * PCH does not control LEDs via the LEDCTL register, rather it uses
2981 * the PHY LED configuration register.
2982 *
2983 * PCH also does not have an "always on" or "always off" mode which
2984 * complicates the ID feature. Instead of using the "on" mode to indicate
Bruce Alland1964eb2012-02-22 09:02:21 +00002985 * in ledctl_mode2 the LEDs to use for ID (see e1000e_id_led_init_generic()),
Bruce Allana4f58f52009-06-02 11:29:18 +00002986 * use "link_up" mode. The LEDs will still ID on request if there is no
2987 * link based on logic in e1000_led_[on|off]_pchlan().
2988 **/
2989static s32 e1000_id_led_init_pchlan(struct e1000_hw *hw)
2990{
2991 struct e1000_mac_info *mac = &hw->mac;
2992 s32 ret_val;
2993 const u32 ledctl_on = E1000_LEDCTL_MODE_LINK_UP;
2994 const u32 ledctl_off = E1000_LEDCTL_MODE_LINK_UP | E1000_PHY_LED0_IVRT;
2995 u16 data, i, temp, shift;
2996
2997 /* Get default ID LED modes */
2998 ret_val = hw->nvm.ops.valid_led_default(hw, &data);
2999 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00003000 return ret_val;
Bruce Allana4f58f52009-06-02 11:29:18 +00003001
3002 mac->ledctl_default = er32(LEDCTL);
3003 mac->ledctl_mode1 = mac->ledctl_default;
3004 mac->ledctl_mode2 = mac->ledctl_default;
3005
3006 for (i = 0; i < 4; i++) {
3007 temp = (data >> (i << 2)) & E1000_LEDCTL_LED0_MODE_MASK;
3008 shift = (i * 5);
3009 switch (temp) {
3010 case ID_LED_ON1_DEF2:
3011 case ID_LED_ON1_ON2:
3012 case ID_LED_ON1_OFF2:
3013 mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
3014 mac->ledctl_mode1 |= (ledctl_on << shift);
3015 break;
3016 case ID_LED_OFF1_DEF2:
3017 case ID_LED_OFF1_ON2:
3018 case ID_LED_OFF1_OFF2:
3019 mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
3020 mac->ledctl_mode1 |= (ledctl_off << shift);
3021 break;
3022 default:
3023 /* Do nothing */
3024 break;
3025 }
3026 switch (temp) {
3027 case ID_LED_DEF1_ON2:
3028 case ID_LED_ON1_ON2:
3029 case ID_LED_OFF1_ON2:
3030 mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
3031 mac->ledctl_mode2 |= (ledctl_on << shift);
3032 break;
3033 case ID_LED_DEF1_OFF2:
3034 case ID_LED_ON1_OFF2:
3035 case ID_LED_OFF1_OFF2:
3036 mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
3037 mac->ledctl_mode2 |= (ledctl_off << shift);
3038 break;
3039 default:
3040 /* Do nothing */
3041 break;
3042 }
3043 }
3044
Bruce Allan5015e532012-02-08 02:55:56 +00003045 return 0;
Bruce Allana4f58f52009-06-02 11:29:18 +00003046}
3047
3048/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07003049 * e1000_get_bus_info_ich8lan - Get/Set the bus type and width
3050 * @hw: pointer to the HW structure
3051 *
3052 * ICH8 use the PCI Express bus, but does not contain a PCI Express Capability
3053 * register, so the the bus width is hard coded.
3054 **/
3055static s32 e1000_get_bus_info_ich8lan(struct e1000_hw *hw)
3056{
3057 struct e1000_bus_info *bus = &hw->bus;
3058 s32 ret_val;
3059
3060 ret_val = e1000e_get_bus_info_pcie(hw);
3061
Bruce Allanad680762008-03-28 09:15:03 -07003062 /*
3063 * ICH devices are "PCI Express"-ish. They have
Auke Kokbc7f75f2007-09-17 12:30:59 -07003064 * a configuration space, but do not contain
3065 * PCI Express Capability registers, so bus width
3066 * must be hardcoded.
3067 */
3068 if (bus->width == e1000_bus_width_unknown)
3069 bus->width = e1000_bus_width_pcie_x1;
3070
3071 return ret_val;
3072}
3073
3074/**
3075 * e1000_reset_hw_ich8lan - Reset the hardware
3076 * @hw: pointer to the HW structure
3077 *
3078 * Does a full reset of the hardware which includes a reset of the PHY and
3079 * MAC.
3080 **/
3081static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
3082{
Bruce Allan1d5846b2009-10-29 13:46:05 +00003083 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
Bruce Allan62bc8132012-03-20 03:47:57 +00003084 u16 kum_cfg;
3085 u32 ctrl, reg;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003086 s32 ret_val;
3087
Bruce Allanad680762008-03-28 09:15:03 -07003088 /*
3089 * Prevent the PCI-E bus from sticking if there is no TLP connection
Auke Kokbc7f75f2007-09-17 12:30:59 -07003090 * on the last TLP read/write transaction when MAC is reset.
3091 */
3092 ret_val = e1000e_disable_pcie_master(hw);
Bruce Allane98cac42010-05-10 15:02:32 +00003093 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003094 e_dbg("PCI-E Master disable polling has failed.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07003095
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003096 e_dbg("Masking off all interrupts\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07003097 ew32(IMC, 0xffffffff);
3098
Bruce Allanad680762008-03-28 09:15:03 -07003099 /*
3100 * Disable the Transmit and Receive units. Then delay to allow
Auke Kokbc7f75f2007-09-17 12:30:59 -07003101 * any pending transactions to complete before we hit the MAC
3102 * with the global reset.
3103 */
3104 ew32(RCTL, 0);
3105 ew32(TCTL, E1000_TCTL_PSP);
3106 e1e_flush();
3107
Bruce Allan1bba4382011-03-19 00:27:20 +00003108 usleep_range(10000, 20000);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003109
3110 /* Workaround for ICH8 bit corruption issue in FIFO memory */
3111 if (hw->mac.type == e1000_ich8lan) {
3112 /* Set Tx and Rx buffer allocation to 8k apiece. */
3113 ew32(PBA, E1000_PBA_8K);
3114 /* Set Packet Buffer Size to 16k. */
3115 ew32(PBS, E1000_PBS_16K);
3116 }
3117
Bruce Allan1d5846b2009-10-29 13:46:05 +00003118 if (hw->mac.type == e1000_pchlan) {
Bruce Allan62bc8132012-03-20 03:47:57 +00003119 /* Save the NVM K1 bit setting */
3120 ret_val = e1000_read_nvm(hw, E1000_NVM_K1_CONFIG, 1, &kum_cfg);
Bruce Allan1d5846b2009-10-29 13:46:05 +00003121 if (ret_val)
3122 return ret_val;
3123
Bruce Allan62bc8132012-03-20 03:47:57 +00003124 if (kum_cfg & E1000_NVM_K1_ENABLE)
Bruce Allan1d5846b2009-10-29 13:46:05 +00003125 dev_spec->nvm_k1_enabled = true;
3126 else
3127 dev_spec->nvm_k1_enabled = false;
3128 }
3129
Auke Kokbc7f75f2007-09-17 12:30:59 -07003130 ctrl = er32(CTRL);
3131
Bruce Allan44abd5c2012-02-22 09:02:37 +00003132 if (!hw->phy.ops.check_reset_block(hw)) {
Bruce Allanad680762008-03-28 09:15:03 -07003133 /*
Bruce Allane98cac42010-05-10 15:02:32 +00003134 * Full-chip reset requires MAC and PHY reset at the same
Auke Kokbc7f75f2007-09-17 12:30:59 -07003135 * time to make sure the interface between MAC and the
3136 * external PHY is reset.
3137 */
3138 ctrl |= E1000_CTRL_PHY_RST;
Bruce Allan605c82b2010-09-22 17:17:01 +00003139
3140 /*
3141 * Gate automatic PHY configuration by hardware on
3142 * non-managed 82579
3143 */
3144 if ((hw->mac.type == e1000_pch2lan) &&
3145 !(er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
3146 e1000_gate_hw_phy_config_ich8lan(hw, true);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003147 }
3148 ret_val = e1000_acquire_swflag_ich8lan(hw);
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003149 e_dbg("Issuing a global reset to ich8lan\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07003150 ew32(CTRL, (ctrl | E1000_CTRL_RST));
Jesse Brandeburg945a5152011-07-20 00:56:21 +00003151 /* cannot issue a flush here because it hangs the hardware */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003152 msleep(20);
3153
Bruce Allan62bc8132012-03-20 03:47:57 +00003154 /* Set Phy Config Counter to 50msec */
3155 if (hw->mac.type == e1000_pch2lan) {
3156 reg = er32(FEXTNVM3);
3157 reg &= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK;
3158 reg |= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC;
3159 ew32(FEXTNVM3, reg);
3160 }
3161
Bruce Allanfc0c7762009-07-01 13:27:55 +00003162 if (!ret_val)
Bruce Allana90b4122011-10-07 03:50:38 +00003163 clear_bit(__E1000_ACCESS_SHARED_RESOURCE, &hw->adapter->state);
Jesse Brandeburg37f40232008-10-02 16:33:20 -07003164
Bruce Allane98cac42010-05-10 15:02:32 +00003165 if (ctrl & E1000_CTRL_PHY_RST) {
Bruce Allanfc0c7762009-07-01 13:27:55 +00003166 ret_val = hw->phy.ops.get_cfg_done(hw);
Bruce Allane98cac42010-05-10 15:02:32 +00003167 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00003168 return ret_val;
Bruce Allanfc0c7762009-07-01 13:27:55 +00003169
Bruce Allane98cac42010-05-10 15:02:32 +00003170 ret_val = e1000_post_phy_reset_ich8lan(hw);
Bruce Allanf523d212009-10-29 13:45:45 +00003171 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00003172 return ret_val;
Bruce Allanf523d212009-10-29 13:45:45 +00003173 }
Bruce Allane98cac42010-05-10 15:02:32 +00003174
Bruce Allan7d3cabb2009-07-01 13:29:08 +00003175 /*
3176 * For PCH, this write will make sure that any noise
3177 * will be detected as a CRC error and be dropped rather than show up
3178 * as a bad packet to the DMA engine.
3179 */
3180 if (hw->mac.type == e1000_pchlan)
3181 ew32(CRC_OFFSET, 0x65656565);
3182
Auke Kokbc7f75f2007-09-17 12:30:59 -07003183 ew32(IMC, 0xffffffff);
Bruce Allandd93f952011-01-06 14:29:48 +00003184 er32(ICR);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003185
Bruce Allan62bc8132012-03-20 03:47:57 +00003186 reg = er32(KABGTXD);
3187 reg |= E1000_KABGTXD_BGSQLBIAS;
3188 ew32(KABGTXD, reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003189
Bruce Allan5015e532012-02-08 02:55:56 +00003190 return 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003191}
3192
3193/**
3194 * e1000_init_hw_ich8lan - Initialize the hardware
3195 * @hw: pointer to the HW structure
3196 *
3197 * Prepares the hardware for transmit and receive by doing the following:
3198 * - initialize hardware bits
3199 * - initialize LED identification
3200 * - setup receive address registers
3201 * - setup flow control
Auke Kok489815c2008-02-21 15:11:07 -08003202 * - setup transmit descriptors
Auke Kokbc7f75f2007-09-17 12:30:59 -07003203 * - clear statistics
3204 **/
3205static s32 e1000_init_hw_ich8lan(struct e1000_hw *hw)
3206{
3207 struct e1000_mac_info *mac = &hw->mac;
3208 u32 ctrl_ext, txdctl, snoop;
3209 s32 ret_val;
3210 u16 i;
3211
3212 e1000_initialize_hw_bits_ich8lan(hw);
3213
3214 /* Initialize identification LED */
Bruce Allana4f58f52009-06-02 11:29:18 +00003215 ret_val = mac->ops.id_led_init(hw);
Bruce Allande39b752009-11-20 23:27:59 +00003216 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003217 e_dbg("Error initializing identification LED\n");
Bruce Allande39b752009-11-20 23:27:59 +00003218 /* This is not fatal and we should not stop init due to this */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003219
3220 /* Setup the receive address. */
3221 e1000e_init_rx_addrs(hw, mac->rar_entry_count);
3222
3223 /* Zero out the Multicast HASH table */
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003224 e_dbg("Zeroing the MTA\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07003225 for (i = 0; i < mac->mta_reg_count; i++)
3226 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
3227
Bruce Allanfc0c7762009-07-01 13:27:55 +00003228 /*
3229 * The 82578 Rx buffer will stall if wakeup is enabled in host and
Bruce Allan3ebfc7c2011-05-13 07:20:14 +00003230 * the ME. Disable wakeup by clearing the host wakeup bit.
Bruce Allanfc0c7762009-07-01 13:27:55 +00003231 * Reset the phy after disabling host wakeup to reset the Rx buffer.
3232 */
3233 if (hw->phy.type == e1000_phy_82578) {
Bruce Allan3ebfc7c2011-05-13 07:20:14 +00003234 e1e_rphy(hw, BM_PORT_GEN_CFG, &i);
3235 i &= ~BM_WUC_HOST_WU_BIT;
3236 e1e_wphy(hw, BM_PORT_GEN_CFG, i);
Bruce Allanfc0c7762009-07-01 13:27:55 +00003237 ret_val = e1000_phy_hw_reset_ich8lan(hw);
3238 if (ret_val)
3239 return ret_val;
3240 }
3241
Auke Kokbc7f75f2007-09-17 12:30:59 -07003242 /* Setup link and flow control */
Bruce Allan1a46b402012-02-22 09:02:26 +00003243 ret_val = mac->ops.setup_link(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003244
3245 /* Set the transmit descriptor write-back policy for both queues */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003246 txdctl = er32(TXDCTL(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -07003247 txdctl = (txdctl & ~E1000_TXDCTL_WTHRESH) |
3248 E1000_TXDCTL_FULL_TX_DESC_WB;
3249 txdctl = (txdctl & ~E1000_TXDCTL_PTHRESH) |
3250 E1000_TXDCTL_MAX_TX_DESC_PREFETCH;
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003251 ew32(TXDCTL(0), txdctl);
3252 txdctl = er32(TXDCTL(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -07003253 txdctl = (txdctl & ~E1000_TXDCTL_WTHRESH) |
3254 E1000_TXDCTL_FULL_TX_DESC_WB;
3255 txdctl = (txdctl & ~E1000_TXDCTL_PTHRESH) |
3256 E1000_TXDCTL_MAX_TX_DESC_PREFETCH;
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003257 ew32(TXDCTL(1), txdctl);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003258
Bruce Allanad680762008-03-28 09:15:03 -07003259 /*
3260 * ICH8 has opposite polarity of no_snoop bits.
3261 * By default, we should use snoop behavior.
3262 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003263 if (mac->type == e1000_ich8lan)
3264 snoop = PCIE_ICH8_SNOOP_ALL;
3265 else
3266 snoop = (u32) ~(PCIE_NO_SNOOP_ALL);
3267 e1000e_set_pcie_no_snoop(hw, snoop);
3268
3269 ctrl_ext = er32(CTRL_EXT);
3270 ctrl_ext |= E1000_CTRL_EXT_RO_DIS;
3271 ew32(CTRL_EXT, ctrl_ext);
3272
Bruce Allanad680762008-03-28 09:15:03 -07003273 /*
3274 * Clear all of the statistics registers (clear on read). It is
Auke Kokbc7f75f2007-09-17 12:30:59 -07003275 * important that we do this after we have tried to establish link
3276 * because the symbol error count will increment wildly if there
3277 * is no link.
3278 */
3279 e1000_clear_hw_cntrs_ich8lan(hw);
3280
Bruce Allane561a702012-02-08 02:55:46 +00003281 return ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003282}
3283/**
3284 * e1000_initialize_hw_bits_ich8lan - Initialize required hardware bits
3285 * @hw: pointer to the HW structure
3286 *
3287 * Sets/Clears required hardware bits necessary for correctly setting up the
3288 * hardware for transmit and receive.
3289 **/
3290static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw)
3291{
3292 u32 reg;
3293
3294 /* Extended Device Control */
3295 reg = er32(CTRL_EXT);
3296 reg |= (1 << 22);
Bruce Allana4f58f52009-06-02 11:29:18 +00003297 /* Enable PHY low-power state when MAC is at D3 w/o WoL */
3298 if (hw->mac.type >= e1000_pchlan)
3299 reg |= E1000_CTRL_EXT_PHYPDEN;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003300 ew32(CTRL_EXT, reg);
3301
3302 /* Transmit Descriptor Control 0 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003303 reg = er32(TXDCTL(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -07003304 reg |= (1 << 22);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003305 ew32(TXDCTL(0), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003306
3307 /* Transmit Descriptor Control 1 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003308 reg = er32(TXDCTL(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -07003309 reg |= (1 << 22);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003310 ew32(TXDCTL(1), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003311
3312 /* Transmit Arbitration Control 0 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003313 reg = er32(TARC(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -07003314 if (hw->mac.type == e1000_ich8lan)
3315 reg |= (1 << 28) | (1 << 29);
3316 reg |= (1 << 23) | (1 << 24) | (1 << 26) | (1 << 27);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003317 ew32(TARC(0), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003318
3319 /* Transmit Arbitration Control 1 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003320 reg = er32(TARC(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -07003321 if (er32(TCTL) & E1000_TCTL_MULR)
3322 reg &= ~(1 << 28);
3323 else
3324 reg |= (1 << 28);
3325 reg |= (1 << 24) | (1 << 26) | (1 << 30);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003326 ew32(TARC(1), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003327
3328 /* Device Status */
3329 if (hw->mac.type == e1000_ich8lan) {
3330 reg = er32(STATUS);
3331 reg &= ~(1 << 31);
3332 ew32(STATUS, reg);
3333 }
Jesse Brandeburga80483d2010-03-05 02:21:44 +00003334
3335 /*
3336 * work-around descriptor data corruption issue during nfs v2 udp
3337 * traffic, just disable the nfs filtering capability
3338 */
3339 reg = er32(RFCTL);
3340 reg |= (E1000_RFCTL_NFSW_DIS | E1000_RFCTL_NFSR_DIS);
3341 ew32(RFCTL, reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003342}
3343
3344/**
3345 * e1000_setup_link_ich8lan - Setup flow control and link settings
3346 * @hw: pointer to the HW structure
3347 *
3348 * Determines which flow control settings to use, then configures flow
3349 * control. Calls the appropriate media-specific link configuration
3350 * function. Assuming the adapter has a valid link partner, a valid link
3351 * should be established. Assumes the hardware has previously been reset
3352 * and the transmitter and receiver are not enabled.
3353 **/
3354static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw)
3355{
Auke Kokbc7f75f2007-09-17 12:30:59 -07003356 s32 ret_val;
3357
Bruce Allan44abd5c2012-02-22 09:02:37 +00003358 if (hw->phy.ops.check_reset_block(hw))
Auke Kokbc7f75f2007-09-17 12:30:59 -07003359 return 0;
3360
Bruce Allanad680762008-03-28 09:15:03 -07003361 /*
3362 * ICH parts do not have a word in the NVM to determine
Auke Kokbc7f75f2007-09-17 12:30:59 -07003363 * the default flow control setting, so we explicitly
3364 * set it to full.
3365 */
Bruce Allan37289d92009-06-02 11:29:37 +00003366 if (hw->fc.requested_mode == e1000_fc_default) {
3367 /* Workaround h/w hang when Tx flow control enabled */
3368 if (hw->mac.type == e1000_pchlan)
3369 hw->fc.requested_mode = e1000_fc_rx_pause;
3370 else
3371 hw->fc.requested_mode = e1000_fc_full;
3372 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07003373
Bruce Allan5c48ef3e22008-11-21 16:57:36 -08003374 /*
3375 * Save off the requested flow control mode for use later. Depending
3376 * on the link partner's capabilities, we may or may not use this mode.
3377 */
3378 hw->fc.current_mode = hw->fc.requested_mode;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003379
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003380 e_dbg("After fix-ups FlowControl is now = %x\n",
Bruce Allan5c48ef3e22008-11-21 16:57:36 -08003381 hw->fc.current_mode);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003382
3383 /* Continue to configure the copper link. */
Bruce Allan944ce012012-02-22 09:02:42 +00003384 ret_val = hw->mac.ops.setup_physical_interface(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003385 if (ret_val)
3386 return ret_val;
3387
Jeff Kirsher318a94d2008-03-28 09:15:16 -07003388 ew32(FCTTV, hw->fc.pause_time);
Bruce Allana4f58f52009-06-02 11:29:18 +00003389 if ((hw->phy.type == e1000_phy_82578) ||
Bruce Alland3738bb2010-06-16 13:27:28 +00003390 (hw->phy.type == e1000_phy_82579) ||
Bruce Allana4f58f52009-06-02 11:29:18 +00003391 (hw->phy.type == e1000_phy_82577)) {
Bruce Allana3055952010-05-10 15:02:12 +00003392 ew32(FCRTV_PCH, hw->fc.refresh_time);
3393
Bruce Allan482fed82011-01-06 14:29:49 +00003394 ret_val = e1e_wphy(hw, PHY_REG(BM_PORT_CTRL_PAGE, 27),
3395 hw->fc.pause_time);
Bruce Allana4f58f52009-06-02 11:29:18 +00003396 if (ret_val)
3397 return ret_val;
3398 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07003399
3400 return e1000e_set_fc_watermarks(hw);
3401}
3402
3403/**
3404 * e1000_setup_copper_link_ich8lan - Configure MAC/PHY interface
3405 * @hw: pointer to the HW structure
3406 *
3407 * Configures the kumeran interface to the PHY to wait the appropriate time
3408 * when polling the PHY, then call the generic setup_copper_link to finish
3409 * configuring the copper link.
3410 **/
3411static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw)
3412{
3413 u32 ctrl;
3414 s32 ret_val;
3415 u16 reg_data;
3416
3417 ctrl = er32(CTRL);
3418 ctrl |= E1000_CTRL_SLU;
3419 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
3420 ew32(CTRL, ctrl);
3421
Bruce Allanad680762008-03-28 09:15:03 -07003422 /*
3423 * Set the mac to wait the maximum time between each iteration
Auke Kokbc7f75f2007-09-17 12:30:59 -07003424 * and increase the max iterations when polling the phy;
Bruce Allanad680762008-03-28 09:15:03 -07003425 * this fixes erroneous timeouts at 10Mbps.
3426 */
Bruce Allan07818952009-12-08 07:28:01 +00003427 ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_TIMEOUTS, 0xFFFF);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003428 if (ret_val)
3429 return ret_val;
Bruce Allan07818952009-12-08 07:28:01 +00003430 ret_val = e1000e_read_kmrn_reg(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
3431 &reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003432 if (ret_val)
3433 return ret_val;
3434 reg_data |= 0x3F;
Bruce Allan07818952009-12-08 07:28:01 +00003435 ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
3436 reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003437 if (ret_val)
3438 return ret_val;
3439
Bruce Allana4f58f52009-06-02 11:29:18 +00003440 switch (hw->phy.type) {
3441 case e1000_phy_igp_3:
Auke Kokbc7f75f2007-09-17 12:30:59 -07003442 ret_val = e1000e_copper_link_setup_igp(hw);
3443 if (ret_val)
3444 return ret_val;
Bruce Allana4f58f52009-06-02 11:29:18 +00003445 break;
3446 case e1000_phy_bm:
3447 case e1000_phy_82578:
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003448 ret_val = e1000e_copper_link_setup_m88(hw);
3449 if (ret_val)
3450 return ret_val;
Bruce Allana4f58f52009-06-02 11:29:18 +00003451 break;
3452 case e1000_phy_82577:
Bruce Alland3738bb2010-06-16 13:27:28 +00003453 case e1000_phy_82579:
Bruce Allana4f58f52009-06-02 11:29:18 +00003454 ret_val = e1000_copper_link_setup_82577(hw);
3455 if (ret_val)
3456 return ret_val;
3457 break;
3458 case e1000_phy_ife:
Bruce Allan482fed82011-01-06 14:29:49 +00003459 ret_val = e1e_rphy(hw, IFE_PHY_MDIX_CONTROL, &reg_data);
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003460 if (ret_val)
3461 return ret_val;
3462
3463 reg_data &= ~IFE_PMC_AUTO_MDIX;
3464
3465 switch (hw->phy.mdix) {
3466 case 1:
3467 reg_data &= ~IFE_PMC_FORCE_MDIX;
3468 break;
3469 case 2:
3470 reg_data |= IFE_PMC_FORCE_MDIX;
3471 break;
3472 case 0:
3473 default:
3474 reg_data |= IFE_PMC_AUTO_MDIX;
3475 break;
3476 }
Bruce Allan482fed82011-01-06 14:29:49 +00003477 ret_val = e1e_wphy(hw, IFE_PHY_MDIX_CONTROL, reg_data);
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003478 if (ret_val)
3479 return ret_val;
Bruce Allana4f58f52009-06-02 11:29:18 +00003480 break;
3481 default:
3482 break;
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003483 }
Bruce Allan3fa8293632012-02-08 02:55:40 +00003484
Auke Kokbc7f75f2007-09-17 12:30:59 -07003485 return e1000e_setup_copper_link(hw);
3486}
3487
3488/**
3489 * e1000_get_link_up_info_ich8lan - Get current link speed and duplex
3490 * @hw: pointer to the HW structure
3491 * @speed: pointer to store current link speed
3492 * @duplex: pointer to store the current link duplex
3493 *
Bruce Allanad680762008-03-28 09:15:03 -07003494 * Calls the generic get_speed_and_duplex to retrieve the current link
Auke Kokbc7f75f2007-09-17 12:30:59 -07003495 * information and then calls the Kumeran lock loss workaround for links at
3496 * gigabit speeds.
3497 **/
3498static s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw, u16 *speed,
3499 u16 *duplex)
3500{
3501 s32 ret_val;
3502
3503 ret_val = e1000e_get_speed_and_duplex_copper(hw, speed, duplex);
3504 if (ret_val)
3505 return ret_val;
3506
3507 if ((hw->mac.type == e1000_ich8lan) &&
3508 (hw->phy.type == e1000_phy_igp_3) &&
3509 (*speed == SPEED_1000)) {
3510 ret_val = e1000_kmrn_lock_loss_workaround_ich8lan(hw);
3511 }
3512
3513 return ret_val;
3514}
3515
3516/**
3517 * e1000_kmrn_lock_loss_workaround_ich8lan - Kumeran workaround
3518 * @hw: pointer to the HW structure
3519 *
3520 * Work-around for 82566 Kumeran PCS lock loss:
3521 * On link status change (i.e. PCI reset, speed change) and link is up and
3522 * speed is gigabit-
3523 * 0) if workaround is optionally disabled do nothing
3524 * 1) wait 1ms for Kumeran link to come up
3525 * 2) check Kumeran Diagnostic register PCS lock loss bit
3526 * 3) if not set the link is locked (all is good), otherwise...
3527 * 4) reset the PHY
3528 * 5) repeat up to 10 times
3529 * Note: this is only called for IGP3 copper when speed is 1gb.
3530 **/
3531static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw)
3532{
3533 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
3534 u32 phy_ctrl;
3535 s32 ret_val;
3536 u16 i, data;
3537 bool link;
3538
3539 if (!dev_spec->kmrn_lock_loss_workaround_enabled)
3540 return 0;
3541
Bruce Allanad680762008-03-28 09:15:03 -07003542 /*
3543 * Make sure link is up before proceeding. If not just return.
Auke Kokbc7f75f2007-09-17 12:30:59 -07003544 * Attempting this while link is negotiating fouled up link
Bruce Allanad680762008-03-28 09:15:03 -07003545 * stability
3546 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003547 ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link);
3548 if (!link)
3549 return 0;
3550
3551 for (i = 0; i < 10; i++) {
3552 /* read once to clear */
3553 ret_val = e1e_rphy(hw, IGP3_KMRN_DIAG, &data);
3554 if (ret_val)
3555 return ret_val;
3556 /* and again to get new status */
3557 ret_val = e1e_rphy(hw, IGP3_KMRN_DIAG, &data);
3558 if (ret_val)
3559 return ret_val;
3560
3561 /* check for PCS lock */
3562 if (!(data & IGP3_KMRN_DIAG_PCS_LOCK_LOSS))
3563 return 0;
3564
3565 /* Issue PHY reset */
3566 e1000_phy_hw_reset(hw);
3567 mdelay(5);
3568 }
3569 /* Disable GigE link negotiation */
3570 phy_ctrl = er32(PHY_CTRL);
3571 phy_ctrl |= (E1000_PHY_CTRL_GBE_DISABLE |
3572 E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
3573 ew32(PHY_CTRL, phy_ctrl);
3574
Bruce Allanad680762008-03-28 09:15:03 -07003575 /*
3576 * Call gig speed drop workaround on Gig disable before accessing
3577 * any PHY registers
3578 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003579 e1000e_gig_downshift_workaround_ich8lan(hw);
3580
3581 /* unable to acquire PCS lock */
3582 return -E1000_ERR_PHY;
3583}
3584
3585/**
Bruce Allan6e3c8072012-02-22 09:02:47 +00003586 * e1000e_set_kmrn_lock_loss_workaround_ich8lan - Set Kumeran workaround state
Auke Kokbc7f75f2007-09-17 12:30:59 -07003587 * @hw: pointer to the HW structure
Auke Kok489815c2008-02-21 15:11:07 -08003588 * @state: boolean value used to set the current Kumeran workaround state
Auke Kokbc7f75f2007-09-17 12:30:59 -07003589 *
Bruce Allan564ea9b2009-11-20 23:26:44 +00003590 * If ICH8, set the current Kumeran workaround state (enabled - true
3591 * /disabled - false).
Auke Kokbc7f75f2007-09-17 12:30:59 -07003592 **/
3593void e1000e_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw,
3594 bool state)
3595{
3596 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
3597
3598 if (hw->mac.type != e1000_ich8lan) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003599 e_dbg("Workaround applies to ICH8 only.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07003600 return;
3601 }
3602
3603 dev_spec->kmrn_lock_loss_workaround_enabled = state;
3604}
3605
3606/**
3607 * e1000_ipg3_phy_powerdown_workaround_ich8lan - Power down workaround on D3
3608 * @hw: pointer to the HW structure
3609 *
3610 * Workaround for 82566 power-down on D3 entry:
3611 * 1) disable gigabit link
3612 * 2) write VR power-down enable
3613 * 3) read it back
3614 * Continue if successful, else issue LCD reset and repeat
3615 **/
3616void e1000e_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw)
3617{
3618 u32 reg;
3619 u16 data;
3620 u8 retry = 0;
3621
3622 if (hw->phy.type != e1000_phy_igp_3)
3623 return;
3624
3625 /* Try the workaround twice (if needed) */
3626 do {
3627 /* Disable link */
3628 reg = er32(PHY_CTRL);
3629 reg |= (E1000_PHY_CTRL_GBE_DISABLE |
3630 E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
3631 ew32(PHY_CTRL, reg);
3632
Bruce Allanad680762008-03-28 09:15:03 -07003633 /*
3634 * Call gig speed drop workaround on Gig disable before
3635 * accessing any PHY registers
3636 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003637 if (hw->mac.type == e1000_ich8lan)
3638 e1000e_gig_downshift_workaround_ich8lan(hw);
3639
3640 /* Write VR power-down enable */
3641 e1e_rphy(hw, IGP3_VR_CTRL, &data);
3642 data &= ~IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
3643 e1e_wphy(hw, IGP3_VR_CTRL, data | IGP3_VR_CTRL_MODE_SHUTDOWN);
3644
3645 /* Read it back and test */
3646 e1e_rphy(hw, IGP3_VR_CTRL, &data);
3647 data &= IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
3648 if ((data == IGP3_VR_CTRL_MODE_SHUTDOWN) || retry)
3649 break;
3650
3651 /* Issue PHY reset and repeat at most one more time */
3652 reg = er32(CTRL);
3653 ew32(CTRL, reg | E1000_CTRL_PHY_RST);
3654 retry++;
3655 } while (retry);
3656}
3657
3658/**
3659 * e1000e_gig_downshift_workaround_ich8lan - WoL from S5 stops working
3660 * @hw: pointer to the HW structure
3661 *
3662 * Steps to take when dropping from 1Gb/s (eg. link cable removal (LSC),
Auke Kok489815c2008-02-21 15:11:07 -08003663 * LPLU, Gig disable, MDIC PHY reset):
Auke Kokbc7f75f2007-09-17 12:30:59 -07003664 * 1) Set Kumeran Near-end loopback
3665 * 2) Clear Kumeran Near-end loopback
Bruce Allan462d5992011-09-30 08:07:11 +00003666 * Should only be called for ICH8[m] devices with any 1G Phy.
Auke Kokbc7f75f2007-09-17 12:30:59 -07003667 **/
3668void e1000e_gig_downshift_workaround_ich8lan(struct e1000_hw *hw)
3669{
3670 s32 ret_val;
3671 u16 reg_data;
3672
Bruce Allan462d5992011-09-30 08:07:11 +00003673 if ((hw->mac.type != e1000_ich8lan) || (hw->phy.type == e1000_phy_ife))
Auke Kokbc7f75f2007-09-17 12:30:59 -07003674 return;
3675
3676 ret_val = e1000e_read_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
3677 &reg_data);
3678 if (ret_val)
3679 return;
3680 reg_data |= E1000_KMRNCTRLSTA_DIAG_NELPBK;
3681 ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
3682 reg_data);
3683 if (ret_val)
3684 return;
3685 reg_data &= ~E1000_KMRNCTRLSTA_DIAG_NELPBK;
3686 ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
3687 reg_data);
3688}
3689
3690/**
Bruce Allan99730e42011-05-13 07:19:48 +00003691 * e1000_suspend_workarounds_ich8lan - workarounds needed during S0->Sx
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003692 * @hw: pointer to the HW structure
3693 *
3694 * During S0 to Sx transition, it is possible the link remains at gig
3695 * instead of negotiating to a lower speed. Before going to Sx, set
Bruce Allanc077a902011-12-16 00:46:38 +00003696 * 'Gig Disable' to force link speed negotiation to a lower speed based on
3697 * the LPLU setting in the NVM or custom setting. For PCH and newer parts,
3698 * the OEM bits PHY register (LED, GbE disable and LPLU configurations) also
3699 * needs to be written.
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003700 **/
Bruce Allan99730e42011-05-13 07:19:48 +00003701void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw)
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003702{
3703 u32 phy_ctrl;
Bruce Allan8395ae82010-09-22 17:15:08 +00003704 s32 ret_val;
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003705
Bruce Allan17f085d2010-06-17 18:59:48 +00003706 phy_ctrl = er32(PHY_CTRL);
Bruce Allanc077a902011-12-16 00:46:38 +00003707 phy_ctrl |= E1000_PHY_CTRL_GBE_DISABLE;
Bruce Allan17f085d2010-06-17 18:59:48 +00003708 ew32(PHY_CTRL, phy_ctrl);
Bruce Allana4f58f52009-06-02 11:29:18 +00003709
Bruce Allan462d5992011-09-30 08:07:11 +00003710 if (hw->mac.type == e1000_ich8lan)
3711 e1000e_gig_downshift_workaround_ich8lan(hw);
3712
Bruce Allan8395ae82010-09-22 17:15:08 +00003713 if (hw->mac.type >= e1000_pchlan) {
Bruce Allance54afd2010-11-24 06:01:41 +00003714 e1000_oem_bits_config_ich8lan(hw, false);
Bruce Allan92fe1732012-04-12 06:27:03 +00003715
3716 /* Reset PHY to activate OEM bits on 82577/8 */
3717 if (hw->mac.type == e1000_pchlan)
3718 e1000e_phy_hw_reset_generic(hw);
3719
Bruce Allan8395ae82010-09-22 17:15:08 +00003720 ret_val = hw->phy.ops.acquire(hw);
3721 if (ret_val)
3722 return;
3723 e1000_write_smbus_addr(hw);
3724 hw->phy.ops.release(hw);
3725 }
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003726}
3727
3728/**
Bruce Allan99730e42011-05-13 07:19:48 +00003729 * e1000_resume_workarounds_pchlan - workarounds needed during Sx->S0
3730 * @hw: pointer to the HW structure
3731 *
3732 * During Sx to S0 transitions on non-managed devices or managed devices
3733 * on which PHY resets are not blocked, if the PHY registers cannot be
3734 * accessed properly by the s/w toggle the LANPHYPC value to power cycle
3735 * the PHY.
3736 **/
3737void e1000_resume_workarounds_pchlan(struct e1000_hw *hw)
3738{
Bruce Allan90b82982011-12-16 00:46:33 +00003739 u16 phy_id1, phy_id2;
3740 s32 ret_val;
Bruce Allan99730e42011-05-13 07:19:48 +00003741
Bruce Allan44abd5c2012-02-22 09:02:37 +00003742 if ((hw->mac.type != e1000_pch2lan) ||
3743 hw->phy.ops.check_reset_block(hw))
Bruce Allan99730e42011-05-13 07:19:48 +00003744 return;
3745
Bruce Allan90b82982011-12-16 00:46:33 +00003746 ret_val = hw->phy.ops.acquire(hw);
3747 if (ret_val) {
3748 e_dbg("Failed to acquire PHY semaphore in resume\n");
Bruce Allan99730e42011-05-13 07:19:48 +00003749 return;
3750 }
3751
Bruce Allan90b82982011-12-16 00:46:33 +00003752 /* Test access to the PHY registers by reading the ID regs */
3753 ret_val = hw->phy.ops.read_reg_locked(hw, PHY_ID1, &phy_id1);
3754 if (ret_val)
3755 goto release;
3756 ret_val = hw->phy.ops.read_reg_locked(hw, PHY_ID2, &phy_id2);
3757 if (ret_val)
3758 goto release;
3759
3760 if (hw->phy.id == ((u32)(phy_id1 << 16) |
3761 (u32)(phy_id2 & PHY_REVISION_MASK)))
3762 goto release;
3763
3764 e1000_toggle_lanphypc_value_ich8lan(hw);
3765
3766 hw->phy.ops.release(hw);
3767 msleep(50);
3768 e1000_phy_hw_reset(hw);
3769 msleep(50);
3770 return;
3771
Bruce Allan99730e42011-05-13 07:19:48 +00003772release:
3773 hw->phy.ops.release(hw);
Bruce Allan99730e42011-05-13 07:19:48 +00003774}
3775
3776/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07003777 * e1000_cleanup_led_ich8lan - Restore the default LED operation
3778 * @hw: pointer to the HW structure
3779 *
3780 * Return the LED back to the default configuration.
3781 **/
3782static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw)
3783{
3784 if (hw->phy.type == e1000_phy_ife)
3785 return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED, 0);
3786
3787 ew32(LEDCTL, hw->mac.ledctl_default);
3788 return 0;
3789}
3790
3791/**
Auke Kok489815c2008-02-21 15:11:07 -08003792 * e1000_led_on_ich8lan - Turn LEDs on
Auke Kokbc7f75f2007-09-17 12:30:59 -07003793 * @hw: pointer to the HW structure
3794 *
Auke Kok489815c2008-02-21 15:11:07 -08003795 * Turn on the LEDs.
Auke Kokbc7f75f2007-09-17 12:30:59 -07003796 **/
3797static s32 e1000_led_on_ich8lan(struct e1000_hw *hw)
3798{
3799 if (hw->phy.type == e1000_phy_ife)
3800 return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED,
3801 (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_ON));
3802
3803 ew32(LEDCTL, hw->mac.ledctl_mode2);
3804 return 0;
3805}
3806
3807/**
Auke Kok489815c2008-02-21 15:11:07 -08003808 * e1000_led_off_ich8lan - Turn LEDs off
Auke Kokbc7f75f2007-09-17 12:30:59 -07003809 * @hw: pointer to the HW structure
3810 *
Auke Kok489815c2008-02-21 15:11:07 -08003811 * Turn off the LEDs.
Auke Kokbc7f75f2007-09-17 12:30:59 -07003812 **/
3813static s32 e1000_led_off_ich8lan(struct e1000_hw *hw)
3814{
3815 if (hw->phy.type == e1000_phy_ife)
3816 return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED,
Bruce Allan482fed82011-01-06 14:29:49 +00003817 (IFE_PSCL_PROBE_MODE |
3818 IFE_PSCL_PROBE_LEDS_OFF));
Auke Kokbc7f75f2007-09-17 12:30:59 -07003819
3820 ew32(LEDCTL, hw->mac.ledctl_mode1);
3821 return 0;
3822}
3823
3824/**
Bruce Allana4f58f52009-06-02 11:29:18 +00003825 * e1000_setup_led_pchlan - Configures SW controllable LED
3826 * @hw: pointer to the HW structure
3827 *
3828 * This prepares the SW controllable LED for use.
3829 **/
3830static s32 e1000_setup_led_pchlan(struct e1000_hw *hw)
3831{
Bruce Allan482fed82011-01-06 14:29:49 +00003832 return e1e_wphy(hw, HV_LED_CONFIG, (u16)hw->mac.ledctl_mode1);
Bruce Allana4f58f52009-06-02 11:29:18 +00003833}
3834
3835/**
3836 * e1000_cleanup_led_pchlan - Restore the default LED operation
3837 * @hw: pointer to the HW structure
3838 *
3839 * Return the LED back to the default configuration.
3840 **/
3841static s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw)
3842{
Bruce Allan482fed82011-01-06 14:29:49 +00003843 return e1e_wphy(hw, HV_LED_CONFIG, (u16)hw->mac.ledctl_default);
Bruce Allana4f58f52009-06-02 11:29:18 +00003844}
3845
3846/**
3847 * e1000_led_on_pchlan - Turn LEDs on
3848 * @hw: pointer to the HW structure
3849 *
3850 * Turn on the LEDs.
3851 **/
3852static s32 e1000_led_on_pchlan(struct e1000_hw *hw)
3853{
3854 u16 data = (u16)hw->mac.ledctl_mode2;
3855 u32 i, led;
3856
3857 /*
3858 * If no link, then turn LED on by setting the invert bit
3859 * for each LED that's mode is "link_up" in ledctl_mode2.
3860 */
3861 if (!(er32(STATUS) & E1000_STATUS_LU)) {
3862 for (i = 0; i < 3; i++) {
3863 led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
3864 if ((led & E1000_PHY_LED0_MODE_MASK) !=
3865 E1000_LEDCTL_MODE_LINK_UP)
3866 continue;
3867 if (led & E1000_PHY_LED0_IVRT)
3868 data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
3869 else
3870 data |= (E1000_PHY_LED0_IVRT << (i * 5));
3871 }
3872 }
3873
Bruce Allan482fed82011-01-06 14:29:49 +00003874 return e1e_wphy(hw, HV_LED_CONFIG, data);
Bruce Allana4f58f52009-06-02 11:29:18 +00003875}
3876
3877/**
3878 * e1000_led_off_pchlan - Turn LEDs off
3879 * @hw: pointer to the HW structure
3880 *
3881 * Turn off the LEDs.
3882 **/
3883static s32 e1000_led_off_pchlan(struct e1000_hw *hw)
3884{
3885 u16 data = (u16)hw->mac.ledctl_mode1;
3886 u32 i, led;
3887
3888 /*
3889 * If no link, then turn LED off by clearing the invert bit
3890 * for each LED that's mode is "link_up" in ledctl_mode1.
3891 */
3892 if (!(er32(STATUS) & E1000_STATUS_LU)) {
3893 for (i = 0; i < 3; i++) {
3894 led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
3895 if ((led & E1000_PHY_LED0_MODE_MASK) !=
3896 E1000_LEDCTL_MODE_LINK_UP)
3897 continue;
3898 if (led & E1000_PHY_LED0_IVRT)
3899 data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
3900 else
3901 data |= (E1000_PHY_LED0_IVRT << (i * 5));
3902 }
3903 }
3904
Bruce Allan482fed82011-01-06 14:29:49 +00003905 return e1e_wphy(hw, HV_LED_CONFIG, data);
Bruce Allana4f58f52009-06-02 11:29:18 +00003906}
3907
3908/**
Bruce Allane98cac42010-05-10 15:02:32 +00003909 * e1000_get_cfg_done_ich8lan - Read config done bit after Full or PHY reset
Bruce Allanf4187b52008-08-26 18:36:50 -07003910 * @hw: pointer to the HW structure
3911 *
Bruce Allane98cac42010-05-10 15:02:32 +00003912 * Read appropriate register for the config done bit for completion status
3913 * and configure the PHY through s/w for EEPROM-less parts.
3914 *
3915 * NOTE: some silicon which is EEPROM-less will fail trying to read the
3916 * config done bit, so only an error is logged and continues. If we were
3917 * to return with error, EEPROM-less silicon would not be able to be reset
3918 * or change link.
Bruce Allanf4187b52008-08-26 18:36:50 -07003919 **/
3920static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw)
3921{
Bruce Allane98cac42010-05-10 15:02:32 +00003922 s32 ret_val = 0;
Bruce Allanf4187b52008-08-26 18:36:50 -07003923 u32 bank = 0;
Bruce Allane98cac42010-05-10 15:02:32 +00003924 u32 status;
Bruce Allanfc0c7762009-07-01 13:27:55 +00003925
Bruce Allanf4187b52008-08-26 18:36:50 -07003926 e1000e_get_cfg_done(hw);
3927
Bruce Allane98cac42010-05-10 15:02:32 +00003928 /* Wait for indication from h/w that it has completed basic config */
3929 if (hw->mac.type >= e1000_ich10lan) {
3930 e1000_lan_init_done_ich8lan(hw);
3931 } else {
3932 ret_val = e1000e_get_auto_rd_done(hw);
3933 if (ret_val) {
3934 /*
3935 * When auto config read does not complete, do not
3936 * return with an error. This can happen in situations
3937 * where there is no eeprom and prevents getting link.
3938 */
3939 e_dbg("Auto Read Done did not complete\n");
3940 ret_val = 0;
3941 }
3942 }
3943
3944 /* Clear PHY Reset Asserted bit */
3945 status = er32(STATUS);
3946 if (status & E1000_STATUS_PHYRA)
3947 ew32(STATUS, status & ~E1000_STATUS_PHYRA);
3948 else
3949 e_dbg("PHY Reset Asserted not set - needs delay\n");
3950
Bruce Allanf4187b52008-08-26 18:36:50 -07003951 /* If EEPROM is not marked present, init the IGP 3 PHY manually */
Bruce Allane98cac42010-05-10 15:02:32 +00003952 if (hw->mac.type <= e1000_ich9lan) {
Bruce Allan04499ec2012-04-13 00:08:31 +00003953 if (!(er32(EECD) & E1000_EECD_PRES) &&
Bruce Allanf4187b52008-08-26 18:36:50 -07003954 (hw->phy.type == e1000_phy_igp_3)) {
3955 e1000e_phy_init_script_igp3(hw);
3956 }
3957 } else {
3958 if (e1000_valid_nvm_bank_detect_ich8lan(hw, &bank)) {
3959 /* Maybe we should do a basic PHY config */
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003960 e_dbg("EEPROM not present\n");
Bruce Allane98cac42010-05-10 15:02:32 +00003961 ret_val = -E1000_ERR_CONFIG;
Bruce Allanf4187b52008-08-26 18:36:50 -07003962 }
3963 }
3964
Bruce Allane98cac42010-05-10 15:02:32 +00003965 return ret_val;
Bruce Allanf4187b52008-08-26 18:36:50 -07003966}
3967
3968/**
Bruce Allan17f208d2009-12-01 15:47:22 +00003969 * e1000_power_down_phy_copper_ich8lan - Remove link during PHY power down
3970 * @hw: pointer to the HW structure
3971 *
3972 * In the case of a PHY power down to save power, or to turn off link during a
3973 * driver unload, or wake on lan is not enabled, remove the link.
3974 **/
3975static void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw)
3976{
3977 /* If the management interface is not enabled, then power down */
3978 if (!(hw->mac.ops.check_mng_mode(hw) ||
3979 hw->phy.ops.check_reset_block(hw)))
3980 e1000_power_down_phy_copper(hw);
Bruce Allan17f208d2009-12-01 15:47:22 +00003981}
3982
3983/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07003984 * e1000_clear_hw_cntrs_ich8lan - Clear statistical counters
3985 * @hw: pointer to the HW structure
3986 *
3987 * Clears hardware counters specific to the silicon family and calls
3988 * clear_hw_cntrs_generic to clear all general purpose counters.
3989 **/
3990static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw)
3991{
Bruce Allana4f58f52009-06-02 11:29:18 +00003992 u16 phy_data;
Bruce Allan2b6b1682011-05-13 07:20:09 +00003993 s32 ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003994
3995 e1000e_clear_hw_cntrs_base(hw);
3996
Bruce Allan99673d92009-11-20 23:27:21 +00003997 er32(ALGNERRC);
3998 er32(RXERRC);
3999 er32(TNCRS);
4000 er32(CEXTERR);
4001 er32(TSCTC);
4002 er32(TSCTFC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07004003
Bruce Allan99673d92009-11-20 23:27:21 +00004004 er32(MGTPRC);
4005 er32(MGTPDC);
4006 er32(MGTPTC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07004007
Bruce Allan99673d92009-11-20 23:27:21 +00004008 er32(IAC);
4009 er32(ICRXOC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07004010
Bruce Allana4f58f52009-06-02 11:29:18 +00004011 /* Clear PHY statistics registers */
4012 if ((hw->phy.type == e1000_phy_82578) ||
Bruce Alland3738bb2010-06-16 13:27:28 +00004013 (hw->phy.type == e1000_phy_82579) ||
Bruce Allana4f58f52009-06-02 11:29:18 +00004014 (hw->phy.type == e1000_phy_82577)) {
Bruce Allan2b6b1682011-05-13 07:20:09 +00004015 ret_val = hw->phy.ops.acquire(hw);
4016 if (ret_val)
4017 return;
4018 ret_val = hw->phy.ops.set_page(hw,
4019 HV_STATS_PAGE << IGP_PAGE_SHIFT);
4020 if (ret_val)
4021 goto release;
4022 hw->phy.ops.read_reg_page(hw, HV_SCC_UPPER, &phy_data);
4023 hw->phy.ops.read_reg_page(hw, HV_SCC_LOWER, &phy_data);
4024 hw->phy.ops.read_reg_page(hw, HV_ECOL_UPPER, &phy_data);
4025 hw->phy.ops.read_reg_page(hw, HV_ECOL_LOWER, &phy_data);
4026 hw->phy.ops.read_reg_page(hw, HV_MCC_UPPER, &phy_data);
4027 hw->phy.ops.read_reg_page(hw, HV_MCC_LOWER, &phy_data);
4028 hw->phy.ops.read_reg_page(hw, HV_LATECOL_UPPER, &phy_data);
4029 hw->phy.ops.read_reg_page(hw, HV_LATECOL_LOWER, &phy_data);
4030 hw->phy.ops.read_reg_page(hw, HV_COLC_UPPER, &phy_data);
4031 hw->phy.ops.read_reg_page(hw, HV_COLC_LOWER, &phy_data);
4032 hw->phy.ops.read_reg_page(hw, HV_DC_UPPER, &phy_data);
4033 hw->phy.ops.read_reg_page(hw, HV_DC_LOWER, &phy_data);
4034 hw->phy.ops.read_reg_page(hw, HV_TNCRS_UPPER, &phy_data);
4035 hw->phy.ops.read_reg_page(hw, HV_TNCRS_LOWER, &phy_data);
4036release:
4037 hw->phy.ops.release(hw);
Bruce Allana4f58f52009-06-02 11:29:18 +00004038 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07004039}
4040
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00004041static const struct e1000_mac_operations ich8_mac_ops = {
Bruce Allaneb7700d2010-06-16 13:27:05 +00004042 /* check_mng_mode dependent on mac type */
Bruce Allan7d3cabb2009-07-01 13:29:08 +00004043 .check_for_link = e1000_check_for_copper_link_ich8lan,
Bruce Allana4f58f52009-06-02 11:29:18 +00004044 /* cleanup_led dependent on mac type */
Auke Kokbc7f75f2007-09-17 12:30:59 -07004045 .clear_hw_cntrs = e1000_clear_hw_cntrs_ich8lan,
4046 .get_bus_info = e1000_get_bus_info_ich8lan,
Bruce Allanf4d2dd42010-01-13 02:05:18 +00004047 .set_lan_id = e1000_set_lan_id_single_port,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004048 .get_link_up_info = e1000_get_link_up_info_ich8lan,
Bruce Allana4f58f52009-06-02 11:29:18 +00004049 /* led_on dependent on mac type */
4050 /* led_off dependent on mac type */
Jeff Kirshere2de3eb2008-03-28 09:15:11 -07004051 .update_mc_addr_list = e1000e_update_mc_addr_list_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004052 .reset_hw = e1000_reset_hw_ich8lan,
4053 .init_hw = e1000_init_hw_ich8lan,
4054 .setup_link = e1000_setup_link_ich8lan,
4055 .setup_physical_interface= e1000_setup_copper_link_ich8lan,
Bruce Allana4f58f52009-06-02 11:29:18 +00004056 /* id_led_init dependent on mac type */
Bruce Allan57cde762012-02-22 09:02:58 +00004057 .config_collision_dist = e1000e_config_collision_dist_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004058};
4059
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00004060static const struct e1000_phy_operations ich8_phy_ops = {
Bruce Allan94d81862009-11-20 23:25:26 +00004061 .acquire = e1000_acquire_swflag_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004062 .check_reset_block = e1000_check_reset_block_ich8lan,
Bruce Allan94d81862009-11-20 23:25:26 +00004063 .commit = NULL,
Bruce Allanf4187b52008-08-26 18:36:50 -07004064 .get_cfg_done = e1000_get_cfg_done_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004065 .get_cable_length = e1000e_get_cable_length_igp_2,
Bruce Allan94d81862009-11-20 23:25:26 +00004066 .read_reg = e1000e_read_phy_reg_igp,
4067 .release = e1000_release_swflag_ich8lan,
4068 .reset = e1000_phy_hw_reset_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004069 .set_d0_lplu_state = e1000_set_d0_lplu_state_ich8lan,
4070 .set_d3_lplu_state = e1000_set_d3_lplu_state_ich8lan,
Bruce Allan94d81862009-11-20 23:25:26 +00004071 .write_reg = e1000e_write_phy_reg_igp,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004072};
4073
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00004074static const struct e1000_nvm_operations ich8_nvm_ops = {
Bruce Allan94d81862009-11-20 23:25:26 +00004075 .acquire = e1000_acquire_nvm_ich8lan,
4076 .read = e1000_read_nvm_ich8lan,
4077 .release = e1000_release_nvm_ich8lan,
Bruce Allane85e3632012-02-22 09:03:14 +00004078 .reload = e1000e_reload_nvm_generic,
Bruce Allan94d81862009-11-20 23:25:26 +00004079 .update = e1000_update_nvm_checksum_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004080 .valid_led_default = e1000_valid_led_default_ich8lan,
Bruce Allan94d81862009-11-20 23:25:26 +00004081 .validate = e1000_validate_nvm_checksum_ich8lan,
4082 .write = e1000_write_nvm_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004083};
4084
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00004085const struct e1000_info e1000_ich8_info = {
Auke Kokbc7f75f2007-09-17 12:30:59 -07004086 .mac = e1000_ich8lan,
4087 .flags = FLAG_HAS_WOL
Bruce Allan97ac8ca2008-04-29 09:16:05 -07004088 | FLAG_IS_ICH
Auke Kokbc7f75f2007-09-17 12:30:59 -07004089 | FLAG_HAS_CTRLEXT_ON_LOAD
4090 | FLAG_HAS_AMT
4091 | FLAG_HAS_FLASH
4092 | FLAG_APME_IN_WUC,
4093 .pba = 8,
Bruce Allan2adc55c2009-06-02 11:28:58 +00004094 .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN,
Jeff Kirsher69e3fd82008-04-02 13:48:18 -07004095 .get_variants = e1000_get_variants_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004096 .mac_ops = &ich8_mac_ops,
4097 .phy_ops = &ich8_phy_ops,
4098 .nvm_ops = &ich8_nvm_ops,
4099};
4100
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00004101const struct e1000_info e1000_ich9_info = {
Auke Kokbc7f75f2007-09-17 12:30:59 -07004102 .mac = e1000_ich9lan,
4103 .flags = FLAG_HAS_JUMBO_FRAMES
Bruce Allan97ac8ca2008-04-29 09:16:05 -07004104 | FLAG_IS_ICH
Auke Kokbc7f75f2007-09-17 12:30:59 -07004105 | FLAG_HAS_WOL
Auke Kokbc7f75f2007-09-17 12:30:59 -07004106 | FLAG_HAS_CTRLEXT_ON_LOAD
4107 | FLAG_HAS_AMT
Auke Kokbc7f75f2007-09-17 12:30:59 -07004108 | FLAG_HAS_FLASH
4109 | FLAG_APME_IN_WUC,
Bruce Allan7f1557e2011-12-16 00:46:43 +00004110 .pba = 18,
Bruce Allan2adc55c2009-06-02 11:28:58 +00004111 .max_hw_frame_size = DEFAULT_JUMBO,
Jeff Kirsher69e3fd82008-04-02 13:48:18 -07004112 .get_variants = e1000_get_variants_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004113 .mac_ops = &ich8_mac_ops,
4114 .phy_ops = &ich8_phy_ops,
4115 .nvm_ops = &ich8_nvm_ops,
4116};
4117
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00004118const struct e1000_info e1000_ich10_info = {
Bruce Allanf4187b52008-08-26 18:36:50 -07004119 .mac = e1000_ich10lan,
4120 .flags = FLAG_HAS_JUMBO_FRAMES
4121 | FLAG_IS_ICH
4122 | FLAG_HAS_WOL
Bruce Allanf4187b52008-08-26 18:36:50 -07004123 | FLAG_HAS_CTRLEXT_ON_LOAD
4124 | FLAG_HAS_AMT
Bruce Allanf4187b52008-08-26 18:36:50 -07004125 | FLAG_HAS_FLASH
4126 | FLAG_APME_IN_WUC,
Bruce Allan7f1557e2011-12-16 00:46:43 +00004127 .pba = 18,
Bruce Allan2adc55c2009-06-02 11:28:58 +00004128 .max_hw_frame_size = DEFAULT_JUMBO,
Bruce Allanf4187b52008-08-26 18:36:50 -07004129 .get_variants = e1000_get_variants_ich8lan,
4130 .mac_ops = &ich8_mac_ops,
4131 .phy_ops = &ich8_phy_ops,
4132 .nvm_ops = &ich8_nvm_ops,
4133};
Bruce Allana4f58f52009-06-02 11:29:18 +00004134
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00004135const struct e1000_info e1000_pch_info = {
Bruce Allana4f58f52009-06-02 11:29:18 +00004136 .mac = e1000_pchlan,
4137 .flags = FLAG_IS_ICH
4138 | FLAG_HAS_WOL
Bruce Allana4f58f52009-06-02 11:29:18 +00004139 | FLAG_HAS_CTRLEXT_ON_LOAD
4140 | FLAG_HAS_AMT
4141 | FLAG_HAS_FLASH
4142 | FLAG_HAS_JUMBO_FRAMES
Bruce Allan38eb3942009-11-19 12:34:20 +00004143 | FLAG_DISABLE_FC_PAUSE_TIME /* errata */
Bruce Allana4f58f52009-06-02 11:29:18 +00004144 | FLAG_APME_IN_WUC,
Bruce Allan8c7bbb92010-06-16 13:26:41 +00004145 .flags2 = FLAG2_HAS_PHY_STATS,
Bruce Allana4f58f52009-06-02 11:29:18 +00004146 .pba = 26,
4147 .max_hw_frame_size = 4096,
4148 .get_variants = e1000_get_variants_ich8lan,
4149 .mac_ops = &ich8_mac_ops,
4150 .phy_ops = &ich8_phy_ops,
4151 .nvm_ops = &ich8_nvm_ops,
4152};
Bruce Alland3738bb2010-06-16 13:27:28 +00004153
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00004154const struct e1000_info e1000_pch2_info = {
Bruce Alland3738bb2010-06-16 13:27:28 +00004155 .mac = e1000_pch2lan,
4156 .flags = FLAG_IS_ICH
4157 | FLAG_HAS_WOL
Bruce Alland3738bb2010-06-16 13:27:28 +00004158 | FLAG_HAS_CTRLEXT_ON_LOAD
4159 | FLAG_HAS_AMT
4160 | FLAG_HAS_FLASH
4161 | FLAG_HAS_JUMBO_FRAMES
4162 | FLAG_APME_IN_WUC,
Bruce Allane52997f2010-06-16 13:27:49 +00004163 .flags2 = FLAG2_HAS_PHY_STATS
4164 | FLAG2_HAS_EEE,
Bruce Allan828bac82010-09-29 21:39:37 +00004165 .pba = 26,
Bruce Alland3738bb2010-06-16 13:27:28 +00004166 .max_hw_frame_size = DEFAULT_JUMBO,
4167 .get_variants = e1000_get_variants_ich8lan,
4168 .mac_ops = &ich8_mac_ops,
4169 .phy_ops = &ich8_phy_ops,
4170 .nvm_ops = &ich8_nvm_ops,
4171};