blob: 8004d7113c396541139226248139a8a6e4f6d650 [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
Bruce Allane921eb12012-11-28 09:28:37 +000029/* 82562G 10/100 Network Connection
Auke Kokbc7f75f2007-09-17 12:30:59 -070030 * 82562G-2 10/100 Network Connection
31 * 82562GT 10/100 Network Connection
32 * 82562GT-2 10/100 Network Connection
33 * 82562V 10/100 Network Connection
34 * 82562V-2 10/100 Network Connection
35 * 82566DC-2 Gigabit Network Connection
36 * 82566DC Gigabit Network Connection
37 * 82566DM-2 Gigabit Network Connection
38 * 82566DM Gigabit Network Connection
39 * 82566MC Gigabit Network Connection
40 * 82566MM Gigabit Network Connection
Bruce Allan97ac8ca2008-04-29 09:16:05 -070041 * 82567LM Gigabit Network Connection
42 * 82567LF Gigabit Network Connection
Bruce Allan16059272008-11-21 16:51:06 -080043 * 82567V Gigabit Network Connection
Bruce Allan97ac8ca2008-04-29 09:16:05 -070044 * 82567LM-2 Gigabit Network Connection
45 * 82567LF-2 Gigabit Network Connection
46 * 82567V-2 Gigabit Network Connection
Bruce Allanf4187b52008-08-26 18:36:50 -070047 * 82567LF-3 Gigabit Network Connection
48 * 82567LM-3 Gigabit Network Connection
Bruce Allan2f15f9d2008-08-26 18:36:36 -070049 * 82567LM-4 Gigabit Network Connection
Bruce Allana4f58f52009-06-02 11:29:18 +000050 * 82577LM Gigabit Network Connection
51 * 82577LC Gigabit Network Connection
52 * 82578DM Gigabit Network Connection
53 * 82578DC Gigabit Network Connection
Bruce Alland3738bb2010-06-16 13:27:28 +000054 * 82579LM Gigabit Network Connection
55 * 82579V Gigabit Network Connection
Auke Kokbc7f75f2007-09-17 12:30:59 -070056 */
57
Auke Kokbc7f75f2007-09-17 12:30:59 -070058#include "e1000.h"
59
60#define ICH_FLASH_GFPREG 0x0000
61#define ICH_FLASH_HSFSTS 0x0004
62#define ICH_FLASH_HSFCTL 0x0006
63#define ICH_FLASH_FADDR 0x0008
64#define ICH_FLASH_FDATA0 0x0010
Bruce Allan4a770352008-10-01 17:18:35 -070065#define ICH_FLASH_PR0 0x0074
Auke Kokbc7f75f2007-09-17 12:30:59 -070066
67#define ICH_FLASH_READ_COMMAND_TIMEOUT 500
68#define ICH_FLASH_WRITE_COMMAND_TIMEOUT 500
69#define ICH_FLASH_ERASE_COMMAND_TIMEOUT 3000000
70#define ICH_FLASH_LINEAR_ADDR_MASK 0x00FFFFFF
71#define ICH_FLASH_CYCLE_REPEAT_COUNT 10
72
73#define ICH_CYCLE_READ 0
74#define ICH_CYCLE_WRITE 2
75#define ICH_CYCLE_ERASE 3
76
77#define FLASH_GFPREG_BASE_MASK 0x1FFF
78#define FLASH_SECTOR_ADDR_SHIFT 12
79
80#define ICH_FLASH_SEG_SIZE_256 256
81#define ICH_FLASH_SEG_SIZE_4K 4096
82#define ICH_FLASH_SEG_SIZE_8K 8192
83#define ICH_FLASH_SEG_SIZE_64K 65536
84
85
86#define E1000_ICH_FWSM_RSPCIPHY 0x00000040 /* Reset PHY on PCI Reset */
Bruce Allan6dfaa762010-05-05 22:00:06 +000087/* FW established a valid mode */
88#define E1000_ICH_FWSM_FW_VALID 0x00008000
Auke Kokbc7f75f2007-09-17 12:30:59 -070089
90#define E1000_ICH_MNG_IAMT_MODE 0x2
91
92#define ID_LED_DEFAULT_ICH8LAN ((ID_LED_DEF1_DEF2 << 12) | \
93 (ID_LED_DEF1_OFF2 << 8) | \
94 (ID_LED_DEF1_ON2 << 4) | \
95 (ID_LED_DEF1_DEF2))
96
97#define E1000_ICH_NVM_SIG_WORD 0x13
98#define E1000_ICH_NVM_SIG_MASK 0xC000
Bruce Allane2434552008-11-21 17:02:41 -080099#define E1000_ICH_NVM_VALID_SIG_MASK 0xC0
100#define E1000_ICH_NVM_SIG_VALUE 0x80
Auke Kokbc7f75f2007-09-17 12:30:59 -0700101
102#define E1000_ICH8_LAN_INIT_TIMEOUT 1500
103
104#define E1000_FEXTNVM_SW_CONFIG 1
105#define E1000_FEXTNVM_SW_CONFIG_ICH8M (1 << 27) /* Bit redefined for ICH8M :/ */
106
Bruce Allan62bc8132012-03-20 03:47:57 +0000107#define E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK 0x0C000000
108#define E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC 0x08000000
109
Bruce Allan831bd2e2010-09-22 17:16:18 +0000110#define E1000_FEXTNVM4_BEACON_DURATION_MASK 0x7
111#define E1000_FEXTNVM4_BEACON_DURATION_8USEC 0x7
112#define E1000_FEXTNVM4_BEACON_DURATION_16USEC 0x3
113
Auke Kokbc7f75f2007-09-17 12:30:59 -0700114#define PCIE_ICH8_SNOOP_ALL PCIE_NO_SNOOP_ALL
115
116#define E1000_ICH_RAR_ENTRIES 7
Bruce Allan69e1e012012-04-14 03:28:50 +0000117#define E1000_PCH2_RAR_ENTRIES 5 /* RAR[0], SHRA[0-3] */
Bruce Allan2fbe4522012-04-19 03:21:47 +0000118#define E1000_PCH_LPT_RAR_ENTRIES 12 /* RAR[0], SHRA[0-10] */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700119
120#define PHY_PAGE_SHIFT 5
121#define PHY_REG(page, reg) (((page) << PHY_PAGE_SHIFT) | \
122 ((reg) & MAX_PHY_REG_ADDRESS))
123#define IGP3_KMRN_DIAG PHY_REG(770, 19) /* KMRN Diagnostic */
124#define IGP3_VR_CTRL PHY_REG(776, 18) /* Voltage Regulator Control */
125
126#define IGP3_KMRN_DIAG_PCS_LOCK_LOSS 0x0002
127#define IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK 0x0300
128#define IGP3_VR_CTRL_MODE_SHUTDOWN 0x0200
129
Bruce Allana4f58f52009-06-02 11:29:18 +0000130#define HV_LED_CONFIG PHY_REG(768, 30) /* LED Configuration */
131
Bruce Allan53ac5a82009-10-26 11:23:06 +0000132#define SW_FLAG_TIMEOUT 1000 /* SW Semaphore flag timeout in milliseconds */
133
Bruce Allan2fbe4522012-04-19 03:21:47 +0000134/* SMBus Control Phy Register */
135#define CV_SMB_CTRL PHY_REG(769, 23)
136#define CV_SMB_CTRL_FORCE_SMBUS 0x0001
137
Bruce Allanf523d212009-10-29 13:45:45 +0000138/* SMBus Address Phy Register */
139#define HV_SMB_ADDR PHY_REG(768, 26)
Bruce Allan8395ae82010-09-22 17:15:08 +0000140#define HV_SMB_ADDR_MASK 0x007F
Bruce Allanf523d212009-10-29 13:45:45 +0000141#define HV_SMB_ADDR_PEC_EN 0x0200
142#define HV_SMB_ADDR_VALID 0x0080
Bruce Allan2fbe4522012-04-19 03:21:47 +0000143#define HV_SMB_ADDR_FREQ_MASK 0x1100
144#define HV_SMB_ADDR_FREQ_LOW_SHIFT 8
145#define HV_SMB_ADDR_FREQ_HIGH_SHIFT 12
Bruce Allanf523d212009-10-29 13:45:45 +0000146
Bruce Alland3738bb2010-06-16 13:27:28 +0000147/* PHY Power Management Control */
148#define HV_PM_CTRL PHY_REG(770, 17)
Bruce Allan36ceeb42012-03-20 03:47:47 +0000149#define HV_PM_CTRL_PLL_STOP_IN_K1_GIGA 0x100
Bruce Alland3738bb2010-06-16 13:27:28 +0000150
Bruce Allane52997f2010-06-16 13:27:49 +0000151/* PHY Low Power Idle Control */
Bruce Allan0ed013e2011-07-29 05:52:56 +0000152#define I82579_LPI_CTRL PHY_REG(772, 20)
153#define I82579_LPI_CTRL_ENABLE_MASK 0x6000
154#define I82579_LPI_CTRL_FORCE_PLL_LOCK_COUNT 0x80
Bruce Allane52997f2010-06-16 13:27:49 +0000155
Bruce Allan4ddc48a2012-12-05 06:25:58 +0000156/* Extended Management Interface (EMI) Registers */
Bruce Allan1effb452011-02-25 06:58:03 +0000157#define I82579_EMI_ADDR 0x10
158#define I82579_EMI_DATA 0x11
159#define I82579_LPI_UPDATE_TIMER 0x4805 /* in 40ns units + 40 ns base value */
Bruce Allan4d241362011-12-16 00:46:06 +0000160#define I82579_MSE_THRESHOLD 0x084F /* Mean Square Error Threshold */
161#define I82579_MSE_LINK_DOWN 0x2411 /* MSE count before dropping link */
Bruce Allan2fbe4522012-04-19 03:21:47 +0000162#define I217_EEE_ADVERTISEMENT 0x8001 /* IEEE MMD Register 7.60 */
163#define I217_EEE_LP_ABILITY 0x8002 /* IEEE MMD Register 7.61 */
164#define I217_EEE_100_SUPPORTED (1 << 1) /* 100BaseTx EEE supported */
165
166/* Intel Rapid Start Technology Support */
Bruce Allan6d7407b2012-05-10 02:51:17 +0000167#define I217_PROXY_CTRL BM_PHY_REG(BM_WUC_PAGE, 70)
Bruce Allan2fbe4522012-04-19 03:21:47 +0000168#define I217_PROXY_CTRL_AUTO_DISABLE 0x0080
169#define I217_SxCTRL PHY_REG(BM_PORT_CTRL_PAGE, 28)
Bruce Allan6d7407b2012-05-10 02:51:17 +0000170#define I217_SxCTRL_ENABLE_LPI_RESET 0x1000
Bruce Allan2fbe4522012-04-19 03:21:47 +0000171#define I217_CGFREG PHY_REG(772, 29)
Bruce Allan6d7407b2012-05-10 02:51:17 +0000172#define I217_CGFREG_ENABLE_MTA_RESET 0x0002
Bruce Allan2fbe4522012-04-19 03:21:47 +0000173#define I217_MEMPWR PHY_REG(772, 26)
Bruce Allan6d7407b2012-05-10 02:51:17 +0000174#define I217_MEMPWR_DISABLE_SMB_RELEASE 0x0010
Bruce Allan1effb452011-02-25 06:58:03 +0000175
Bruce Allanf523d212009-10-29 13:45:45 +0000176/* Strapping Option Register - RO */
177#define E1000_STRAP 0x0000C
178#define E1000_STRAP_SMBUS_ADDRESS_MASK 0x00FE0000
179#define E1000_STRAP_SMBUS_ADDRESS_SHIFT 17
Bruce Allan2fbe4522012-04-19 03:21:47 +0000180#define E1000_STRAP_SMT_FREQ_MASK 0x00003000
181#define E1000_STRAP_SMT_FREQ_SHIFT 12
Bruce Allanf523d212009-10-29 13:45:45 +0000182
Bruce Allanfa2ce132009-10-26 11:23:25 +0000183/* OEM Bits Phy Register */
184#define HV_OEM_BITS PHY_REG(768, 25)
185#define HV_OEM_BITS_LPLU 0x0004 /* Low Power Link Up */
Bruce Allanf523d212009-10-29 13:45:45 +0000186#define HV_OEM_BITS_GBE_DIS 0x0040 /* Gigabit Disable */
Bruce Allanfa2ce132009-10-26 11:23:25 +0000187#define HV_OEM_BITS_RESTART_AN 0x0400 /* Restart Auto-negotiation */
188
Bruce Allan1d5846b2009-10-29 13:46:05 +0000189#define E1000_NVM_K1_CONFIG 0x1B /* NVM K1 Config Word */
190#define E1000_NVM_K1_ENABLE 0x1 /* NVM Enable K1 bit */
191
Bruce Allanfddaa1a2010-01-13 01:52:49 +0000192/* KMRN Mode Control */
193#define HV_KMRN_MODE_CTRL PHY_REG(769, 16)
194#define HV_KMRN_MDIO_SLOW 0x0400
195
Bruce Allan1d2101a72011-07-22 06:21:56 +0000196/* KMRN FIFO Control and Status */
197#define HV_KMRN_FIFO_CTRLSTA PHY_REG(770, 16)
198#define HV_KMRN_FIFO_CTRLSTA_PREAMBLE_MASK 0x7000
199#define HV_KMRN_FIFO_CTRLSTA_PREAMBLE_SHIFT 12
200
Auke Kokbc7f75f2007-09-17 12:30:59 -0700201/* ICH GbE Flash Hardware Sequencing Flash Status Register bit breakdown */
202/* Offset 04h HSFSTS */
203union ich8_hws_flash_status {
204 struct ich8_hsfsts {
205 u16 flcdone :1; /* bit 0 Flash Cycle Done */
206 u16 flcerr :1; /* bit 1 Flash Cycle Error */
207 u16 dael :1; /* bit 2 Direct Access error Log */
208 u16 berasesz :2; /* bit 4:3 Sector Erase Size */
209 u16 flcinprog :1; /* bit 5 flash cycle in Progress */
210 u16 reserved1 :2; /* bit 13:6 Reserved */
211 u16 reserved2 :6; /* bit 13:6 Reserved */
212 u16 fldesvalid :1; /* bit 14 Flash Descriptor Valid */
213 u16 flockdn :1; /* bit 15 Flash Config Lock-Down */
214 } hsf_status;
215 u16 regval;
216};
217
218/* ICH GbE Flash Hardware Sequencing Flash control Register bit breakdown */
219/* Offset 06h FLCTL */
220union ich8_hws_flash_ctrl {
221 struct ich8_hsflctl {
222 u16 flcgo :1; /* 0 Flash Cycle Go */
223 u16 flcycle :2; /* 2:1 Flash Cycle */
224 u16 reserved :5; /* 7:3 Reserved */
225 u16 fldbcount :2; /* 9:8 Flash Data Byte Count */
226 u16 flockdn :6; /* 15:10 Reserved */
227 } hsf_ctrl;
228 u16 regval;
229};
230
231/* ICH Flash Region Access Permissions */
232union ich8_hws_flash_regacc {
233 struct ich8_flracc {
234 u32 grra :8; /* 0:7 GbE region Read Access */
235 u32 grwa :8; /* 8:15 GbE region Write Access */
236 u32 gmrag :8; /* 23:16 GbE Master Read Access Grant */
237 u32 gmwag :8; /* 31:24 GbE Master Write Access Grant */
238 } hsf_flregacc;
239 u16 regval;
240};
241
Bruce Allan4a770352008-10-01 17:18:35 -0700242/* ICH Flash Protected Region */
243union ich8_flash_protected_range {
244 struct ich8_pr {
245 u32 base:13; /* 0:12 Protected Range Base */
246 u32 reserved1:2; /* 13:14 Reserved */
247 u32 rpe:1; /* 15 Read Protection Enable */
248 u32 limit:13; /* 16:28 Protected Range Limit */
249 u32 reserved2:2; /* 29:30 Reserved */
250 u32 wpe:1; /* 31 Write Protection Enable */
251 } range;
252 u32 regval;
253};
254
Auke Kokbc7f75f2007-09-17 12:30:59 -0700255static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw);
256static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw);
257static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700258static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank);
259static s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw,
260 u32 offset, u8 byte);
Bruce Allanf4187b52008-08-26 18:36:50 -0700261static s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
262 u8 *data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700263static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset,
264 u16 *data);
265static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
266 u8 size, u16 *data);
267static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw);
268static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw);
Bruce Allanf4187b52008-08-26 18:36:50 -0700269static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw);
Bruce Allana4f58f52009-06-02 11:29:18 +0000270static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw);
271static s32 e1000_led_on_ich8lan(struct e1000_hw *hw);
272static s32 e1000_led_off_ich8lan(struct e1000_hw *hw);
273static s32 e1000_id_led_init_pchlan(struct e1000_hw *hw);
274static s32 e1000_setup_led_pchlan(struct e1000_hw *hw);
275static s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw);
276static s32 e1000_led_on_pchlan(struct e1000_hw *hw);
277static s32 e1000_led_off_pchlan(struct e1000_hw *hw);
Bruce Allanfa2ce132009-10-26 11:23:25 +0000278static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active);
Bruce Allan17f208d2009-12-01 15:47:22 +0000279static void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw);
Bruce Allanf523d212009-10-29 13:45:45 +0000280static void e1000_lan_init_done_ich8lan(struct e1000_hw *hw);
Bruce Allan1d5846b2009-10-29 13:46:05 +0000281static s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link);
Bruce Allanfddaa1a2010-01-13 01:52:49 +0000282static s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw);
Bruce Allaneb7700d2010-06-16 13:27:05 +0000283static bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw);
284static bool e1000_check_mng_mode_pchlan(struct e1000_hw *hw);
Bruce Allan69e1e012012-04-14 03:28:50 +0000285static void e1000_rar_set_pch2lan(struct e1000_hw *hw, u8 *addr, u32 index);
Bruce Allan2fbe4522012-04-19 03:21:47 +0000286static void e1000_rar_set_pch_lpt(struct e1000_hw *hw, u8 *addr, u32 index);
Bruce Allan831bd2e2010-09-22 17:16:18 +0000287static s32 e1000_k1_workaround_lv(struct e1000_hw *hw);
Bruce Allan605c82b2010-09-22 17:17:01 +0000288static void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700289
290static inline u16 __er16flash(struct e1000_hw *hw, unsigned long reg)
291{
292 return readw(hw->flash_address + reg);
293}
294
295static inline u32 __er32flash(struct e1000_hw *hw, unsigned long reg)
296{
297 return readl(hw->flash_address + reg);
298}
299
300static inline void __ew16flash(struct e1000_hw *hw, unsigned long reg, u16 val)
301{
302 writew(val, hw->flash_address + reg);
303}
304
305static inline void __ew32flash(struct e1000_hw *hw, unsigned long reg, u32 val)
306{
307 writel(val, hw->flash_address + reg);
308}
309
310#define er16flash(reg) __er16flash(hw, (reg))
311#define er32flash(reg) __er32flash(hw, (reg))
Bruce Allan0e15df42012-01-31 06:37:11 +0000312#define ew16flash(reg, val) __ew16flash(hw, (reg), (val))
313#define ew32flash(reg, val) __ew32flash(hw, (reg), (val))
Auke Kokbc7f75f2007-09-17 12:30:59 -0700314
Bruce Allancb17aab2012-04-13 03:16:22 +0000315/**
316 * e1000_phy_is_accessible_pchlan - Check if able to access PHY registers
317 * @hw: pointer to the HW structure
318 *
319 * Test access to the PHY registers by reading the PHY ID registers. If
320 * the PHY ID is already known (e.g. resume path) compare it with known ID,
321 * otherwise assume the read PHY ID is correct if it is valid.
322 *
323 * Assumes the sw/fw/hw semaphore is already acquired.
324 **/
325static bool e1000_phy_is_accessible_pchlan(struct e1000_hw *hw)
Bruce Allan99730e42011-05-13 07:19:48 +0000326{
Bruce Allana52359b2012-07-14 04:23:58 +0000327 u16 phy_reg = 0;
328 u32 phy_id = 0;
329 s32 ret_val;
330 u16 retry_count;
Bruce Allan99730e42011-05-13 07:19:48 +0000331
Bruce Allana52359b2012-07-14 04:23:58 +0000332 for (retry_count = 0; retry_count < 2; retry_count++) {
333 ret_val = e1e_rphy_locked(hw, PHY_ID1, &phy_reg);
334 if (ret_val || (phy_reg == 0xFFFF))
335 continue;
336 phy_id = (u32)(phy_reg << 16);
337
338 ret_val = e1e_rphy_locked(hw, PHY_ID2, &phy_reg);
339 if (ret_val || (phy_reg == 0xFFFF)) {
340 phy_id = 0;
341 continue;
342 }
343 phy_id |= (u32)(phy_reg & PHY_REVISION_MASK);
344 break;
345 }
Bruce Allan62bc8132012-03-20 03:47:57 +0000346
Bruce Allancb17aab2012-04-13 03:16:22 +0000347 if (hw->phy.id) {
348 if (hw->phy.id == phy_id)
349 return true;
Bruce Allana52359b2012-07-14 04:23:58 +0000350 } else if (phy_id) {
351 hw->phy.id = phy_id;
352 hw->phy.revision = (u32)(phy_reg & ~PHY_REVISION_MASK);
Bruce Allancb17aab2012-04-13 03:16:22 +0000353 return true;
354 }
355
Bruce Allane921eb12012-11-28 09:28:37 +0000356 /* In case the PHY needs to be in mdio slow mode,
Bruce Allana52359b2012-07-14 04:23:58 +0000357 * set slow mode and try to get the PHY id again.
358 */
359 hw->phy.ops.release(hw);
360 ret_val = e1000_set_mdio_slow_mode_hv(hw);
361 if (!ret_val)
362 ret_val = e1000e_get_phy_id(hw);
363 hw->phy.ops.acquire(hw);
364
365 return !ret_val;
Bruce Allancb17aab2012-04-13 03:16:22 +0000366}
367
368/**
369 * e1000_init_phy_workarounds_pchlan - PHY initialization workarounds
370 * @hw: pointer to the HW structure
371 *
372 * Workarounds/flow necessary for PHY initialization during driver load
373 * and resume paths.
374 **/
375static s32 e1000_init_phy_workarounds_pchlan(struct e1000_hw *hw)
376{
377 u32 mac_reg, fwsm = er32(FWSM);
378 s32 ret_val;
Bruce Allan2fbe4522012-04-19 03:21:47 +0000379 u16 phy_reg;
Bruce Allancb17aab2012-04-13 03:16:22 +0000380
381 ret_val = hw->phy.ops.acquire(hw);
382 if (ret_val) {
383 e_dbg("Failed to initialize PHY flow\n");
384 return ret_val;
385 }
386
Bruce Allane921eb12012-11-28 09:28:37 +0000387 /* The MAC-PHY interconnect may be in SMBus mode. If the PHY is
Bruce Allancb17aab2012-04-13 03:16:22 +0000388 * inaccessible and resetting the PHY is not blocked, toggle the
389 * LANPHYPC Value bit to force the interconnect to PCIe mode.
390 */
391 switch (hw->mac.type) {
Bruce Allan2fbe4522012-04-19 03:21:47 +0000392 case e1000_pch_lpt:
393 if (e1000_phy_is_accessible_pchlan(hw))
394 break;
395
Bruce Allane921eb12012-11-28 09:28:37 +0000396 /* Before toggling LANPHYPC, see if PHY is accessible by
Bruce Allan2fbe4522012-04-19 03:21:47 +0000397 * forcing MAC to SMBus mode first.
398 */
399 mac_reg = er32(CTRL_EXT);
400 mac_reg |= E1000_CTRL_EXT_FORCE_SMBUS;
401 ew32(CTRL_EXT, mac_reg);
402
403 /* fall-through */
Bruce Allancb17aab2012-04-13 03:16:22 +0000404 case e1000_pch2lan:
Bruce Allane921eb12012-11-28 09:28:37 +0000405 /* Gate automatic PHY configuration by hardware on
Bruce Allancb17aab2012-04-13 03:16:22 +0000406 * non-managed 82579
407 */
Bruce Allan2fbe4522012-04-19 03:21:47 +0000408 if ((hw->mac.type == e1000_pch2lan) &&
409 !(fwsm & E1000_ICH_FWSM_FW_VALID))
Bruce Allancb17aab2012-04-13 03:16:22 +0000410 e1000_gate_hw_phy_config_ich8lan(hw, true);
411
Bruce Allan2fbe4522012-04-19 03:21:47 +0000412 if (e1000_phy_is_accessible_pchlan(hw)) {
413 if (hw->mac.type == e1000_pch_lpt) {
414 /* Unforce SMBus mode in PHY */
415 e1e_rphy_locked(hw, CV_SMB_CTRL, &phy_reg);
416 phy_reg &= ~CV_SMB_CTRL_FORCE_SMBUS;
417 e1e_wphy_locked(hw, CV_SMB_CTRL, phy_reg);
418
419 /* Unforce SMBus mode in MAC */
420 mac_reg = er32(CTRL_EXT);
421 mac_reg &= ~E1000_CTRL_EXT_FORCE_SMBUS;
422 ew32(CTRL_EXT, mac_reg);
423 }
Bruce Allancb17aab2012-04-13 03:16:22 +0000424 break;
Bruce Allan2fbe4522012-04-19 03:21:47 +0000425 }
Bruce Allancb17aab2012-04-13 03:16:22 +0000426
427 /* fall-through */
428 case e1000_pchlan:
429 if ((hw->mac.type == e1000_pchlan) &&
430 (fwsm & E1000_ICH_FWSM_FW_VALID))
431 break;
432
433 if (hw->phy.ops.check_reset_block(hw)) {
434 e_dbg("Required LANPHYPC toggle blocked by ME\n");
435 break;
436 }
437
438 e_dbg("Toggling LANPHYPC\n");
439
440 /* Set Phy Config Counter to 50msec */
441 mac_reg = er32(FEXTNVM3);
442 mac_reg &= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK;
443 mac_reg |= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC;
444 ew32(FEXTNVM3, mac_reg);
445
446 /* Toggle LANPHYPC Value bit */
447 mac_reg = er32(CTRL);
448 mac_reg |= E1000_CTRL_LANPHYPC_OVERRIDE;
449 mac_reg &= ~E1000_CTRL_LANPHYPC_VALUE;
450 ew32(CTRL, mac_reg);
451 e1e_flush();
452 udelay(10);
453 mac_reg &= ~E1000_CTRL_LANPHYPC_OVERRIDE;
454 ew32(CTRL, mac_reg);
455 e1e_flush();
Bruce Allan2fbe4522012-04-19 03:21:47 +0000456 if (hw->mac.type < e1000_pch_lpt) {
457 msleep(50);
458 } else {
459 u16 count = 20;
460 do {
461 usleep_range(5000, 10000);
462 } while (!(er32(CTRL_EXT) &
463 E1000_CTRL_EXT_LPCD) && count--);
464 }
Bruce Allancb17aab2012-04-13 03:16:22 +0000465 break;
466 default:
467 break;
468 }
469
470 hw->phy.ops.release(hw);
471
Bruce Allane921eb12012-11-28 09:28:37 +0000472 /* Reset the PHY before any access to it. Doing so, ensures
Bruce Allancb17aab2012-04-13 03:16:22 +0000473 * that the PHY is in a known good state before we read/write
474 * PHY registers. The generic reset is sufficient here,
475 * because we haven't determined the PHY type yet.
476 */
477 ret_val = e1000e_phy_hw_reset_generic(hw);
478
479 /* Ungate automatic PHY configuration on non-managed 82579 */
480 if ((hw->mac.type == e1000_pch2lan) &&
481 !(fwsm & E1000_ICH_FWSM_FW_VALID)) {
482 usleep_range(10000, 20000);
483 e1000_gate_hw_phy_config_ich8lan(hw, false);
484 }
485
486 return ret_val;
Bruce Allan99730e42011-05-13 07:19:48 +0000487}
488
Auke Kokbc7f75f2007-09-17 12:30:59 -0700489/**
Bruce Allana4f58f52009-06-02 11:29:18 +0000490 * e1000_init_phy_params_pchlan - Initialize PHY function pointers
491 * @hw: pointer to the HW structure
492 *
493 * Initialize family-specific PHY parameters and function pointers.
494 **/
495static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw)
496{
497 struct e1000_phy_info *phy = &hw->phy;
498 s32 ret_val = 0;
499
500 phy->addr = 1;
501 phy->reset_delay_us = 100;
502
Bruce Allan2b6b1682011-05-13 07:20:09 +0000503 phy->ops.set_page = e1000_set_page_igp;
Bruce Allan94d81862009-11-20 23:25:26 +0000504 phy->ops.read_reg = e1000_read_phy_reg_hv;
505 phy->ops.read_reg_locked = e1000_read_phy_reg_hv_locked;
Bruce Allan2b6b1682011-05-13 07:20:09 +0000506 phy->ops.read_reg_page = e1000_read_phy_reg_page_hv;
Bruce Allanfa2ce132009-10-26 11:23:25 +0000507 phy->ops.set_d0_lplu_state = e1000_set_lplu_state_pchlan;
508 phy->ops.set_d3_lplu_state = e1000_set_lplu_state_pchlan;
Bruce Allan94d81862009-11-20 23:25:26 +0000509 phy->ops.write_reg = e1000_write_phy_reg_hv;
510 phy->ops.write_reg_locked = e1000_write_phy_reg_hv_locked;
Bruce Allan2b6b1682011-05-13 07:20:09 +0000511 phy->ops.write_reg_page = e1000_write_phy_reg_page_hv;
Bruce Allan17f208d2009-12-01 15:47:22 +0000512 phy->ops.power_up = e1000_power_up_phy_copper;
513 phy->ops.power_down = e1000_power_down_phy_copper_ich8lan;
Bruce Allana4f58f52009-06-02 11:29:18 +0000514 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
515
516 phy->id = e1000_phy_unknown;
Bruce Allancb17aab2012-04-13 03:16:22 +0000517
518 ret_val = e1000_init_phy_workarounds_pchlan(hw);
519 if (ret_val)
520 return ret_val;
521
522 if (phy->id == e1000_phy_unknown)
523 switch (hw->mac.type) {
524 default:
525 ret_val = e1000e_get_phy_id(hw);
526 if (ret_val)
527 return ret_val;
528 if ((phy->id != 0) && (phy->id != PHY_REVISION_MASK))
529 break;
530 /* fall-through */
531 case e1000_pch2lan:
Bruce Allan2fbe4522012-04-19 03:21:47 +0000532 case e1000_pch_lpt:
Bruce Allane921eb12012-11-28 09:28:37 +0000533 /* In case the PHY needs to be in mdio slow mode,
Bruce Allancb17aab2012-04-13 03:16:22 +0000534 * set slow mode and try to get the PHY id again.
535 */
536 ret_val = e1000_set_mdio_slow_mode_hv(hw);
537 if (ret_val)
538 return ret_val;
539 ret_val = e1000e_get_phy_id(hw);
540 if (ret_val)
541 return ret_val;
Bruce Allan664dc872010-11-24 06:01:46 +0000542 break;
Bruce Allancb17aab2012-04-13 03:16:22 +0000543 }
Bruce Allana4f58f52009-06-02 11:29:18 +0000544 phy->type = e1000e_get_phy_type_from_id(phy->id);
545
Bruce Allan0be84012009-12-02 17:03:18 +0000546 switch (phy->type) {
547 case e1000_phy_82577:
Bruce Alland3738bb2010-06-16 13:27:28 +0000548 case e1000_phy_82579:
Bruce Allan2fbe4522012-04-19 03:21:47 +0000549 case e1000_phy_i217:
Bruce Allana4f58f52009-06-02 11:29:18 +0000550 phy->ops.check_polarity = e1000_check_polarity_82577;
551 phy->ops.force_speed_duplex =
Bruce Allan6cc7aae2011-02-25 06:25:18 +0000552 e1000_phy_force_speed_duplex_82577;
Bruce Allan0be84012009-12-02 17:03:18 +0000553 phy->ops.get_cable_length = e1000_get_cable_length_82577;
Bruce Allan94d81862009-11-20 23:25:26 +0000554 phy->ops.get_info = e1000_get_phy_info_82577;
555 phy->ops.commit = e1000e_phy_sw_reset;
Bruce Allaneab50ff2010-05-10 15:01:30 +0000556 break;
Bruce Allan0be84012009-12-02 17:03:18 +0000557 case e1000_phy_82578:
558 phy->ops.check_polarity = e1000_check_polarity_m88;
559 phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_m88;
560 phy->ops.get_cable_length = e1000e_get_cable_length_m88;
561 phy->ops.get_info = e1000e_get_phy_info_m88;
562 break;
563 default:
564 ret_val = -E1000_ERR_PHY;
565 break;
Bruce Allana4f58f52009-06-02 11:29:18 +0000566 }
567
568 return ret_val;
569}
570
571/**
Auke Kokbc7f75f2007-09-17 12:30:59 -0700572 * e1000_init_phy_params_ich8lan - Initialize PHY function pointers
573 * @hw: pointer to the HW structure
574 *
575 * Initialize family-specific PHY parameters and function pointers.
576 **/
577static s32 e1000_init_phy_params_ich8lan(struct e1000_hw *hw)
578{
579 struct e1000_phy_info *phy = &hw->phy;
580 s32 ret_val;
581 u16 i = 0;
582
583 phy->addr = 1;
584 phy->reset_delay_us = 100;
585
Bruce Allan17f208d2009-12-01 15:47:22 +0000586 phy->ops.power_up = e1000_power_up_phy_copper;
587 phy->ops.power_down = e1000_power_down_phy_copper_ich8lan;
588
Bruce Allane921eb12012-11-28 09:28:37 +0000589 /* We may need to do this twice - once for IGP and if that fails,
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700590 * we'll set BM func pointers and try again
591 */
592 ret_val = e1000e_determine_phy_address(hw);
593 if (ret_val) {
Bruce Allan94d81862009-11-20 23:25:26 +0000594 phy->ops.write_reg = e1000e_write_phy_reg_bm;
595 phy->ops.read_reg = e1000e_read_phy_reg_bm;
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700596 ret_val = e1000e_determine_phy_address(hw);
Bruce Allan9b71b412009-12-01 15:53:07 +0000597 if (ret_val) {
598 e_dbg("Cannot determine PHY addr. Erroring out\n");
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700599 return ret_val;
Bruce Allan9b71b412009-12-01 15:53:07 +0000600 }
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700601 }
602
Auke Kokbc7f75f2007-09-17 12:30:59 -0700603 phy->id = 0;
604 while ((e1000_phy_unknown == e1000e_get_phy_type_from_id(phy->id)) &&
605 (i++ < 100)) {
Bruce Allan1bba4382011-03-19 00:27:20 +0000606 usleep_range(1000, 2000);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700607 ret_val = e1000e_get_phy_id(hw);
608 if (ret_val)
609 return ret_val;
610 }
611
612 /* Verify phy id */
613 switch (phy->id) {
614 case IGP03E1000_E_PHY_ID:
615 phy->type = e1000_phy_igp_3;
616 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
Bruce Allan94d81862009-11-20 23:25:26 +0000617 phy->ops.read_reg_locked = e1000e_read_phy_reg_igp_locked;
618 phy->ops.write_reg_locked = e1000e_write_phy_reg_igp_locked;
Bruce Allan0be84012009-12-02 17:03:18 +0000619 phy->ops.get_info = e1000e_get_phy_info_igp;
620 phy->ops.check_polarity = e1000_check_polarity_igp;
621 phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_igp;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700622 break;
623 case IFE_E_PHY_ID:
624 case IFE_PLUS_E_PHY_ID:
625 case IFE_C_E_PHY_ID:
626 phy->type = e1000_phy_ife;
627 phy->autoneg_mask = E1000_ALL_NOT_GIG;
Bruce Allan0be84012009-12-02 17:03:18 +0000628 phy->ops.get_info = e1000_get_phy_info_ife;
629 phy->ops.check_polarity = e1000_check_polarity_ife;
630 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_ife;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700631 break;
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700632 case BME1000_E_PHY_ID:
633 phy->type = e1000_phy_bm;
634 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
Bruce Allan94d81862009-11-20 23:25:26 +0000635 phy->ops.read_reg = e1000e_read_phy_reg_bm;
636 phy->ops.write_reg = e1000e_write_phy_reg_bm;
637 phy->ops.commit = e1000e_phy_sw_reset;
Bruce Allan0be84012009-12-02 17:03:18 +0000638 phy->ops.get_info = e1000e_get_phy_info_m88;
639 phy->ops.check_polarity = e1000_check_polarity_m88;
640 phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_m88;
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700641 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700642 default:
643 return -E1000_ERR_PHY;
644 break;
645 }
646
647 return 0;
648}
649
650/**
651 * e1000_init_nvm_params_ich8lan - Initialize NVM function pointers
652 * @hw: pointer to the HW structure
653 *
654 * Initialize family-specific NVM parameters and function
655 * pointers.
656 **/
657static s32 e1000_init_nvm_params_ich8lan(struct e1000_hw *hw)
658{
659 struct e1000_nvm_info *nvm = &hw->nvm;
660 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
Bruce Allan148675a2009-08-07 07:41:56 +0000661 u32 gfpreg, sector_base_addr, sector_end_addr;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700662 u16 i;
663
Bruce Allanad680762008-03-28 09:15:03 -0700664 /* Can't read flash registers if the register set isn't mapped. */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700665 if (!hw->flash_address) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000666 e_dbg("ERROR: Flash registers not mapped\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700667 return -E1000_ERR_CONFIG;
668 }
669
670 nvm->type = e1000_nvm_flash_sw;
671
672 gfpreg = er32flash(ICH_FLASH_GFPREG);
673
Bruce Allane921eb12012-11-28 09:28:37 +0000674 /* sector_X_addr is a "sector"-aligned address (4096 bytes)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700675 * Add 1 to sector_end_addr since this sector is included in
Bruce Allanad680762008-03-28 09:15:03 -0700676 * the overall size.
677 */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700678 sector_base_addr = gfpreg & FLASH_GFPREG_BASE_MASK;
679 sector_end_addr = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK) + 1;
680
681 /* flash_base_addr is byte-aligned */
682 nvm->flash_base_addr = sector_base_addr << FLASH_SECTOR_ADDR_SHIFT;
683
Bruce Allane921eb12012-11-28 09:28:37 +0000684 /* find total size of the NVM, then cut in half since the total
Bruce Allanad680762008-03-28 09:15:03 -0700685 * size represents two separate NVM banks.
686 */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700687 nvm->flash_bank_size = (sector_end_addr - sector_base_addr)
688 << FLASH_SECTOR_ADDR_SHIFT;
689 nvm->flash_bank_size /= 2;
690 /* Adjust to word count */
691 nvm->flash_bank_size /= sizeof(u16);
692
693 nvm->word_size = E1000_ICH8_SHADOW_RAM_WORDS;
694
695 /* Clear shadow ram */
696 for (i = 0; i < nvm->word_size; i++) {
Bruce Allan564ea9b2009-11-20 23:26:44 +0000697 dev_spec->shadow_ram[i].modified = false;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700698 dev_spec->shadow_ram[i].value = 0xFFFF;
699 }
700
701 return 0;
702}
703
704/**
705 * e1000_init_mac_params_ich8lan - Initialize MAC function pointers
706 * @hw: pointer to the HW structure
707 *
708 * Initialize family-specific MAC parameters and function
709 * pointers.
710 **/
Bruce Allanec34c172012-02-01 10:53:05 +0000711static s32 e1000_init_mac_params_ich8lan(struct e1000_hw *hw)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700712{
Auke Kokbc7f75f2007-09-17 12:30:59 -0700713 struct e1000_mac_info *mac = &hw->mac;
714
715 /* Set media type function pointer */
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700716 hw->phy.media_type = e1000_media_type_copper;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700717
718 /* Set mta register count */
719 mac->mta_reg_count = 32;
720 /* Set rar entry count */
721 mac->rar_entry_count = E1000_ICH_RAR_ENTRIES;
722 if (mac->type == e1000_ich8lan)
723 mac->rar_entry_count--;
Bruce Allana65a4a02010-05-10 15:01:51 +0000724 /* FWSM register */
725 mac->has_fwsm = true;
726 /* ARC subsystem not supported */
727 mac->arc_subsystem_valid = false;
Bruce Allanf464ba82010-01-07 16:31:35 +0000728 /* Adaptive IFS supported */
729 mac->adaptive_ifs = true;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700730
Bruce Allan2fbe4522012-04-19 03:21:47 +0000731 /* LED and other operations */
Bruce Allana4f58f52009-06-02 11:29:18 +0000732 switch (mac->type) {
733 case e1000_ich8lan:
734 case e1000_ich9lan:
735 case e1000_ich10lan:
Bruce Allaneb7700d2010-06-16 13:27:05 +0000736 /* check management mode */
737 mac->ops.check_mng_mode = e1000_check_mng_mode_ich8lan;
Bruce Allana4f58f52009-06-02 11:29:18 +0000738 /* ID LED init */
Bruce Alland1964eb2012-02-22 09:02:21 +0000739 mac->ops.id_led_init = e1000e_id_led_init_generic;
Bruce Allandbf80dc2011-04-16 00:34:40 +0000740 /* blink LED */
741 mac->ops.blink_led = e1000e_blink_led_generic;
Bruce Allana4f58f52009-06-02 11:29:18 +0000742 /* setup LED */
743 mac->ops.setup_led = e1000e_setup_led_generic;
744 /* cleanup LED */
745 mac->ops.cleanup_led = e1000_cleanup_led_ich8lan;
746 /* turn on/off LED */
747 mac->ops.led_on = e1000_led_on_ich8lan;
748 mac->ops.led_off = e1000_led_off_ich8lan;
749 break;
Bruce Alland3738bb2010-06-16 13:27:28 +0000750 case e1000_pch2lan:
Bruce Allan69e1e012012-04-14 03:28:50 +0000751 mac->rar_entry_count = E1000_PCH2_RAR_ENTRIES;
752 mac->ops.rar_set = e1000_rar_set_pch2lan;
753 /* fall-through */
Bruce Allan2fbe4522012-04-19 03:21:47 +0000754 case e1000_pch_lpt:
Bruce Allan69e1e012012-04-14 03:28:50 +0000755 case e1000_pchlan:
Bruce Allaneb7700d2010-06-16 13:27:05 +0000756 /* check management mode */
757 mac->ops.check_mng_mode = e1000_check_mng_mode_pchlan;
Bruce Allana4f58f52009-06-02 11:29:18 +0000758 /* ID LED init */
759 mac->ops.id_led_init = e1000_id_led_init_pchlan;
760 /* setup LED */
761 mac->ops.setup_led = e1000_setup_led_pchlan;
762 /* cleanup LED */
763 mac->ops.cleanup_led = e1000_cleanup_led_pchlan;
764 /* turn on/off LED */
765 mac->ops.led_on = e1000_led_on_pchlan;
766 mac->ops.led_off = e1000_led_off_pchlan;
767 break;
768 default:
769 break;
770 }
771
Bruce Allan2fbe4522012-04-19 03:21:47 +0000772 if (mac->type == e1000_pch_lpt) {
773 mac->rar_entry_count = E1000_PCH_LPT_RAR_ENTRIES;
774 mac->ops.rar_set = e1000_rar_set_pch_lpt;
775 }
776
Auke Kokbc7f75f2007-09-17 12:30:59 -0700777 /* Enable PCS Lock-loss workaround for ICH8 */
778 if (mac->type == e1000_ich8lan)
Bruce Allan564ea9b2009-11-20 23:26:44 +0000779 e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw, true);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700780
Bruce Allane921eb12012-11-28 09:28:37 +0000781 /* Gate automatic PHY configuration by hardware on managed
Bruce Allan2fbe4522012-04-19 03:21:47 +0000782 * 82579 and i217
783 */
784 if ((mac->type == e1000_pch2lan || mac->type == e1000_pch_lpt) &&
Bruce Allan605c82b2010-09-22 17:17:01 +0000785 (er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
786 e1000_gate_hw_phy_config_ich8lan(hw, true);
Bruce Alland3738bb2010-06-16 13:27:28 +0000787
Auke Kokbc7f75f2007-09-17 12:30:59 -0700788 return 0;
789}
790
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000791/**
Bruce Allan4ddc48a2012-12-05 06:25:58 +0000792 * __e1000_access_emi_reg_locked - Read/write EMI register
793 * @hw: pointer to the HW structure
794 * @addr: EMI address to program
795 * @data: pointer to value to read/write from/to the EMI address
796 * @read: boolean flag to indicate read or write
797 *
798 * This helper function assumes the SW/FW/HW Semaphore is already acquired.
799 **/
800static s32 __e1000_access_emi_reg_locked(struct e1000_hw *hw, u16 address,
801 u16 *data, bool read)
802{
803 s32 ret_val = 0;
804
805 ret_val = e1e_wphy_locked(hw, I82579_EMI_ADDR, address);
806 if (ret_val)
807 return ret_val;
808
809 if (read)
810 ret_val = e1e_rphy_locked(hw, I82579_EMI_DATA, data);
811 else
812 ret_val = e1e_wphy_locked(hw, I82579_EMI_DATA, *data);
813
814 return ret_val;
815}
816
817/**
818 * e1000_read_emi_reg_locked - Read Extended Management Interface register
819 * @hw: pointer to the HW structure
820 * @addr: EMI address to program
821 * @data: value to be read from the EMI address
822 *
823 * Assumes the SW/FW/HW Semaphore is already acquired.
824 **/
825static s32 e1000_read_emi_reg_locked(struct e1000_hw *hw, u16 addr, u16 *data)
826{
827 return __e1000_access_emi_reg_locked(hw, addr, data, true);
828}
829
830/**
831 * e1000_write_emi_reg_locked - Write Extended Management Interface register
832 * @hw: pointer to the HW structure
833 * @addr: EMI address to program
834 * @data: value to be written to the EMI address
835 *
836 * Assumes the SW/FW/HW Semaphore is already acquired.
837 **/
838static s32 e1000_write_emi_reg_locked(struct e1000_hw *hw, u16 addr, u16 data)
839{
840 return __e1000_access_emi_reg_locked(hw, addr, &data, false);
841}
842
843/**
Bruce Allane52997f2010-06-16 13:27:49 +0000844 * e1000_set_eee_pchlan - Enable/disable EEE support
845 * @hw: pointer to the HW structure
846 *
847 * Enable/disable EEE based on setting in dev_spec structure. The bits in
848 * the LPI Control register will remain set only if/when link is up.
849 **/
850static s32 e1000_set_eee_pchlan(struct e1000_hw *hw)
851{
Bruce Allan2fbe4522012-04-19 03:21:47 +0000852 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
Bruce Allane52997f2010-06-16 13:27:49 +0000853 s32 ret_val = 0;
854 u16 phy_reg;
855
Bruce Allan2fbe4522012-04-19 03:21:47 +0000856 if ((hw->phy.type != e1000_phy_82579) &&
857 (hw->phy.type != e1000_phy_i217))
Bruce Allan5015e532012-02-08 02:55:56 +0000858 return 0;
Bruce Allane52997f2010-06-16 13:27:49 +0000859
860 ret_val = e1e_rphy(hw, I82579_LPI_CTRL, &phy_reg);
861 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +0000862 return ret_val;
Bruce Allane52997f2010-06-16 13:27:49 +0000863
Bruce Allan2fbe4522012-04-19 03:21:47 +0000864 if (dev_spec->eee_disable)
Bruce Allane52997f2010-06-16 13:27:49 +0000865 phy_reg &= ~I82579_LPI_CTRL_ENABLE_MASK;
866 else
867 phy_reg |= I82579_LPI_CTRL_ENABLE_MASK;
868
Bruce Allan2fbe4522012-04-19 03:21:47 +0000869 ret_val = e1e_wphy(hw, I82579_LPI_CTRL, phy_reg);
870 if (ret_val)
871 return ret_val;
872
873 if ((hw->phy.type == e1000_phy_i217) && !dev_spec->eee_disable) {
874 /* Save off link partner's EEE ability */
875 ret_val = hw->phy.ops.acquire(hw);
876 if (ret_val)
877 return ret_val;
Bruce Allan4ddc48a2012-12-05 06:25:58 +0000878 ret_val = e1000_read_emi_reg_locked(hw,
879 I217_EEE_LP_ABILITY,
880 &dev_spec->eee_lp_ability);
Bruce Allan2fbe4522012-04-19 03:21:47 +0000881 if (ret_val)
882 goto release;
Bruce Allan2fbe4522012-04-19 03:21:47 +0000883
Bruce Allane921eb12012-11-28 09:28:37 +0000884 /* EEE is not supported in 100Half, so ignore partner's EEE
Bruce Allan2fbe4522012-04-19 03:21:47 +0000885 * in 100 ability if full-duplex is not advertised.
886 */
887 e1e_rphy_locked(hw, PHY_LP_ABILITY, &phy_reg);
888 if (!(phy_reg & NWAY_LPAR_100TX_FD_CAPS))
889 dev_spec->eee_lp_ability &= ~I217_EEE_100_SUPPORTED;
890release:
891 hw->phy.ops.release(hw);
892 }
893
894 return 0;
Bruce Allane52997f2010-06-16 13:27:49 +0000895}
896
897/**
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000898 * e1000_check_for_copper_link_ich8lan - Check for link (Copper)
899 * @hw: pointer to the HW structure
900 *
901 * Checks to see of the link status of the hardware has changed. If a
902 * change in link status has been detected, then we read the PHY registers
903 * to get the current speed/duplex if link exists.
904 **/
905static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw)
906{
907 struct e1000_mac_info *mac = &hw->mac;
908 s32 ret_val;
909 bool link;
Bruce Allan1d2101a72011-07-22 06:21:56 +0000910 u16 phy_reg;
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000911
Bruce Allane921eb12012-11-28 09:28:37 +0000912 /* We only want to go out to the PHY registers to see if Auto-Neg
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000913 * has completed and/or if our link status has changed. The
914 * get_link_status flag is set upon receiving a Link Status
915 * Change or Rx Sequence Error interrupt.
916 */
Bruce Allan5015e532012-02-08 02:55:56 +0000917 if (!mac->get_link_status)
918 return 0;
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000919
Bruce Allane921eb12012-11-28 09:28:37 +0000920 /* First we want to see if the MII Status Register reports
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000921 * link. If so, then we want to get the current speed/duplex
922 * of the PHY.
923 */
924 ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link);
925 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +0000926 return ret_val;
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000927
Bruce Allan1d5846b2009-10-29 13:46:05 +0000928 if (hw->mac.type == e1000_pchlan) {
929 ret_val = e1000_k1_gig_workaround_hv(hw, link);
930 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +0000931 return ret_val;
Bruce Allan1d5846b2009-10-29 13:46:05 +0000932 }
933
Bruce Allan2fbe4522012-04-19 03:21:47 +0000934 /* Clear link partner's EEE ability */
935 hw->dev_spec.ich8lan.eee_lp_ability = 0;
936
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000937 if (!link)
Bruce Allan5015e532012-02-08 02:55:56 +0000938 return 0; /* No link detected */
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000939
940 mac->get_link_status = false;
941
Bruce Allan1d2101a72011-07-22 06:21:56 +0000942 switch (hw->mac.type) {
943 case e1000_pch2lan:
Bruce Allan831bd2e2010-09-22 17:16:18 +0000944 ret_val = e1000_k1_workaround_lv(hw);
945 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +0000946 return ret_val;
Bruce Allan1d2101a72011-07-22 06:21:56 +0000947 /* fall-thru */
948 case e1000_pchlan:
949 if (hw->phy.type == e1000_phy_82578) {
950 ret_val = e1000_link_stall_workaround_hv(hw);
951 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +0000952 return ret_val;
Bruce Allan1d2101a72011-07-22 06:21:56 +0000953 }
954
Bruce Allane921eb12012-11-28 09:28:37 +0000955 /* Workaround for PCHx parts in half-duplex:
Bruce Allan1d2101a72011-07-22 06:21:56 +0000956 * Set the number of preambles removed from the packet
957 * when it is passed from the PHY to the MAC to prevent
958 * the MAC from misinterpreting the packet type.
959 */
960 e1e_rphy(hw, HV_KMRN_FIFO_CTRLSTA, &phy_reg);
961 phy_reg &= ~HV_KMRN_FIFO_CTRLSTA_PREAMBLE_MASK;
962
963 if ((er32(STATUS) & E1000_STATUS_FD) != E1000_STATUS_FD)
964 phy_reg |= (1 << HV_KMRN_FIFO_CTRLSTA_PREAMBLE_SHIFT);
965
966 e1e_wphy(hw, HV_KMRN_FIFO_CTRLSTA, phy_reg);
967 break;
968 default:
969 break;
Bruce Allan831bd2e2010-09-22 17:16:18 +0000970 }
971
Bruce Allane921eb12012-11-28 09:28:37 +0000972 /* Check if there was DownShift, must be checked
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000973 * immediately after link-up
974 */
975 e1000e_check_downshift(hw);
976
Bruce Allane52997f2010-06-16 13:27:49 +0000977 /* Enable/Disable EEE after link up */
978 ret_val = e1000_set_eee_pchlan(hw);
979 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +0000980 return ret_val;
Bruce Allane52997f2010-06-16 13:27:49 +0000981
Bruce Allane921eb12012-11-28 09:28:37 +0000982 /* If we are forcing speed/duplex, then we simply return since
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000983 * we have already determined whether we have link or not.
984 */
Bruce Allan5015e532012-02-08 02:55:56 +0000985 if (!mac->autoneg)
986 return -E1000_ERR_CONFIG;
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000987
Bruce Allane921eb12012-11-28 09:28:37 +0000988 /* Auto-Neg is enabled. Auto Speed Detection takes care
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000989 * of MAC speed/duplex configuration. So we only need to
990 * configure Collision Distance in the MAC.
991 */
Bruce Allan57cde762012-02-22 09:02:58 +0000992 mac->ops.config_collision_dist(hw);
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000993
Bruce Allane921eb12012-11-28 09:28:37 +0000994 /* Configure Flow Control now that Auto-Neg has completed.
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000995 * First, we need to restore the desired flow control
996 * settings because we may have had to re-autoneg with a
997 * different link partner.
998 */
999 ret_val = e1000e_config_fc_after_link_up(hw);
1000 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001001 e_dbg("Error configuring flow control\n");
Bruce Allan7d3cabb2009-07-01 13:29:08 +00001002
Bruce Allan7d3cabb2009-07-01 13:29:08 +00001003 return ret_val;
1004}
1005
Jeff Kirsher69e3fd82008-04-02 13:48:18 -07001006static s32 e1000_get_variants_ich8lan(struct e1000_adapter *adapter)
Auke Kokbc7f75f2007-09-17 12:30:59 -07001007{
1008 struct e1000_hw *hw = &adapter->hw;
1009 s32 rc;
1010
Bruce Allanec34c172012-02-01 10:53:05 +00001011 rc = e1000_init_mac_params_ich8lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001012 if (rc)
1013 return rc;
1014
1015 rc = e1000_init_nvm_params_ich8lan(hw);
1016 if (rc)
1017 return rc;
1018
Bruce Alland3738bb2010-06-16 13:27:28 +00001019 switch (hw->mac.type) {
1020 case e1000_ich8lan:
1021 case e1000_ich9lan:
1022 case e1000_ich10lan:
Bruce Allana4f58f52009-06-02 11:29:18 +00001023 rc = e1000_init_phy_params_ich8lan(hw);
Bruce Alland3738bb2010-06-16 13:27:28 +00001024 break;
1025 case e1000_pchlan:
1026 case e1000_pch2lan:
Bruce Allan2fbe4522012-04-19 03:21:47 +00001027 case e1000_pch_lpt:
Bruce Alland3738bb2010-06-16 13:27:28 +00001028 rc = e1000_init_phy_params_pchlan(hw);
1029 break;
1030 default:
1031 break;
1032 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07001033 if (rc)
1034 return rc;
1035
Bruce Allane921eb12012-11-28 09:28:37 +00001036 /* Disable Jumbo Frame support on parts with Intel 10/100 PHY or
Bruce Allan23e4f062011-02-25 07:44:51 +00001037 * on parts with MACsec enabled in NVM (reflected in CTRL_EXT).
1038 */
1039 if ((adapter->hw.phy.type == e1000_phy_ife) ||
1040 ((adapter->hw.mac.type >= e1000_pch2lan) &&
1041 (!(er32(CTRL_EXT) & E1000_CTRL_EXT_LSECCK)))) {
Bruce Allan2adc55c2009-06-02 11:28:58 +00001042 adapter->flags &= ~FLAG_HAS_JUMBO_FRAMES;
1043 adapter->max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN;
Bruce Allandbf80dc2011-04-16 00:34:40 +00001044
1045 hw->mac.ops.blink_led = NULL;
Bruce Allan2adc55c2009-06-02 11:28:58 +00001046 }
1047
Auke Kokbc7f75f2007-09-17 12:30:59 -07001048 if ((adapter->hw.mac.type == e1000_ich8lan) &&
Bruce Allan462d5992011-09-30 08:07:11 +00001049 (adapter->hw.phy.type != e1000_phy_ife))
Auke Kokbc7f75f2007-09-17 12:30:59 -07001050 adapter->flags |= FLAG_LSC_GIG_SPEED_DROP;
1051
Bruce Allanc6e7f512011-07-29 05:53:02 +00001052 /* Enable workaround for 82579 w/ ME enabled */
1053 if ((adapter->hw.mac.type == e1000_pch2lan) &&
1054 (er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
1055 adapter->flags2 |= FLAG2_PCIM2PCI_ARBITER_WA;
1056
Bruce Allan5a86f282010-06-29 18:13:13 +00001057 /* Disable EEE by default until IEEE802.3az spec is finalized */
1058 if (adapter->flags2 & FLAG2_HAS_EEE)
1059 adapter->hw.dev_spec.ich8lan.eee_disable = true;
1060
Auke Kokbc7f75f2007-09-17 12:30:59 -07001061 return 0;
1062}
1063
Thomas Gleixner717d4382008-10-02 16:33:40 -07001064static DEFINE_MUTEX(nvm_mutex);
Thomas Gleixner717d4382008-10-02 16:33:40 -07001065
Auke Kokbc7f75f2007-09-17 12:30:59 -07001066/**
Bruce Allanca15df52009-10-26 11:23:43 +00001067 * e1000_acquire_nvm_ich8lan - Acquire NVM mutex
1068 * @hw: pointer to the HW structure
1069 *
1070 * Acquires the mutex for performing NVM operations.
1071 **/
1072static s32 e1000_acquire_nvm_ich8lan(struct e1000_hw *hw)
1073{
1074 mutex_lock(&nvm_mutex);
1075
1076 return 0;
1077}
1078
1079/**
1080 * e1000_release_nvm_ich8lan - Release NVM mutex
1081 * @hw: pointer to the HW structure
1082 *
1083 * Releases the mutex used while performing NVM operations.
1084 **/
1085static void e1000_release_nvm_ich8lan(struct e1000_hw *hw)
1086{
1087 mutex_unlock(&nvm_mutex);
Bruce Allanca15df52009-10-26 11:23:43 +00001088}
1089
Bruce Allanca15df52009-10-26 11:23:43 +00001090/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07001091 * e1000_acquire_swflag_ich8lan - Acquire software control flag
1092 * @hw: pointer to the HW structure
1093 *
Bruce Allanca15df52009-10-26 11:23:43 +00001094 * Acquires the software control flag for performing PHY and select
1095 * MAC CSR accesses.
Auke Kokbc7f75f2007-09-17 12:30:59 -07001096 **/
1097static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw)
1098{
Bruce Allan373a88d2009-08-07 07:41:37 +00001099 u32 extcnf_ctrl, timeout = PHY_CFG_TIMEOUT;
1100 s32 ret_val = 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001101
Bruce Allana90b4122011-10-07 03:50:38 +00001102 if (test_and_set_bit(__E1000_ACCESS_SHARED_RESOURCE,
1103 &hw->adapter->state)) {
Bruce Allan34c9ef82011-10-21 04:33:47 +00001104 e_dbg("contention for Phy access\n");
Bruce Allana90b4122011-10-07 03:50:38 +00001105 return -E1000_ERR_PHY;
1106 }
Thomas Gleixner717d4382008-10-02 16:33:40 -07001107
Auke Kokbc7f75f2007-09-17 12:30:59 -07001108 while (timeout) {
1109 extcnf_ctrl = er32(EXTCNF_CTRL);
Bruce Allan373a88d2009-08-07 07:41:37 +00001110 if (!(extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG))
1111 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001112
Auke Kokbc7f75f2007-09-17 12:30:59 -07001113 mdelay(1);
1114 timeout--;
1115 }
1116
1117 if (!timeout) {
Bruce Allana90b4122011-10-07 03:50:38 +00001118 e_dbg("SW has already locked the resource.\n");
Bruce Allan373a88d2009-08-07 07:41:37 +00001119 ret_val = -E1000_ERR_CONFIG;
1120 goto out;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001121 }
1122
Bruce Allan53ac5a82009-10-26 11:23:06 +00001123 timeout = SW_FLAG_TIMEOUT;
Bruce Allan373a88d2009-08-07 07:41:37 +00001124
1125 extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG;
1126 ew32(EXTCNF_CTRL, extcnf_ctrl);
1127
1128 while (timeout) {
1129 extcnf_ctrl = er32(EXTCNF_CTRL);
1130 if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG)
1131 break;
1132
1133 mdelay(1);
1134 timeout--;
1135 }
1136
1137 if (!timeout) {
Bruce Allan434f1392011-12-16 00:46:54 +00001138 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 +00001139 er32(FWSM), extcnf_ctrl);
Bruce Allan373a88d2009-08-07 07:41:37 +00001140 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
1141 ew32(EXTCNF_CTRL, extcnf_ctrl);
1142 ret_val = -E1000_ERR_CONFIG;
1143 goto out;
1144 }
1145
1146out:
1147 if (ret_val)
Bruce Allana90b4122011-10-07 03:50:38 +00001148 clear_bit(__E1000_ACCESS_SHARED_RESOURCE, &hw->adapter->state);
Bruce Allan373a88d2009-08-07 07:41:37 +00001149
1150 return ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001151}
1152
1153/**
1154 * e1000_release_swflag_ich8lan - Release software control flag
1155 * @hw: pointer to the HW structure
1156 *
Bruce Allanca15df52009-10-26 11:23:43 +00001157 * Releases the software control flag for performing PHY and select
1158 * MAC CSR accesses.
Auke Kokbc7f75f2007-09-17 12:30:59 -07001159 **/
1160static void e1000_release_swflag_ich8lan(struct e1000_hw *hw)
1161{
1162 u32 extcnf_ctrl;
1163
1164 extcnf_ctrl = er32(EXTCNF_CTRL);
Bruce Allanc5caf482011-05-13 07:19:53 +00001165
1166 if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG) {
1167 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
1168 ew32(EXTCNF_CTRL, extcnf_ctrl);
1169 } else {
1170 e_dbg("Semaphore unexpectedly released by sw/fw/hw\n");
1171 }
Thomas Gleixner717d4382008-10-02 16:33:40 -07001172
Bruce Allana90b4122011-10-07 03:50:38 +00001173 clear_bit(__E1000_ACCESS_SHARED_RESOURCE, &hw->adapter->state);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001174}
1175
1176/**
Bruce Allan4662e822008-08-26 18:37:06 -07001177 * e1000_check_mng_mode_ich8lan - Checks management mode
1178 * @hw: pointer to the HW structure
1179 *
Bruce Allaneb7700d2010-06-16 13:27:05 +00001180 * This checks if the adapter has any manageability enabled.
Bruce Allan4662e822008-08-26 18:37:06 -07001181 * This is a function pointer entry point only called by read/write
1182 * routines for the PHY and NVM parts.
1183 **/
1184static bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw)
1185{
Bruce Allana708dd82009-11-20 23:28:37 +00001186 u32 fwsm;
1187
1188 fwsm = er32(FWSM);
Bruce Allaneb7700d2010-06-16 13:27:05 +00001189 return (fwsm & E1000_ICH_FWSM_FW_VALID) &&
1190 ((fwsm & E1000_FWSM_MODE_MASK) ==
1191 (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT));
1192}
Bruce Allan4662e822008-08-26 18:37:06 -07001193
Bruce Allaneb7700d2010-06-16 13:27:05 +00001194/**
1195 * e1000_check_mng_mode_pchlan - Checks management mode
1196 * @hw: pointer to the HW structure
1197 *
1198 * This checks if the adapter has iAMT enabled.
1199 * This is a function pointer entry point only called by read/write
1200 * routines for the PHY and NVM parts.
1201 **/
1202static bool e1000_check_mng_mode_pchlan(struct e1000_hw *hw)
1203{
1204 u32 fwsm;
1205
1206 fwsm = er32(FWSM);
1207 return (fwsm & E1000_ICH_FWSM_FW_VALID) &&
1208 (fwsm & (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT));
Bruce Allan4662e822008-08-26 18:37:06 -07001209}
1210
1211/**
Bruce Allan69e1e012012-04-14 03:28:50 +00001212 * e1000_rar_set_pch2lan - Set receive address register
1213 * @hw: pointer to the HW structure
1214 * @addr: pointer to the receive address
1215 * @index: receive address array register
1216 *
1217 * Sets the receive address array register at index to the address passed
1218 * in by addr. For 82579, RAR[0] is the base address register that is to
1219 * contain the MAC address but RAR[1-6] are reserved for manageability (ME).
1220 * Use SHRA[0-3] in place of those reserved for ME.
1221 **/
1222static void e1000_rar_set_pch2lan(struct e1000_hw *hw, u8 *addr, u32 index)
1223{
1224 u32 rar_low, rar_high;
1225
Bruce Allane921eb12012-11-28 09:28:37 +00001226 /* HW expects these in little endian so we reverse the byte order
Bruce Allan69e1e012012-04-14 03:28:50 +00001227 * from network order (big endian) to little endian
1228 */
1229 rar_low = ((u32)addr[0] |
1230 ((u32)addr[1] << 8) |
1231 ((u32)addr[2] << 16) | ((u32)addr[3] << 24));
1232
1233 rar_high = ((u32)addr[4] | ((u32)addr[5] << 8));
1234
1235 /* If MAC address zero, no need to set the AV bit */
1236 if (rar_low || rar_high)
1237 rar_high |= E1000_RAH_AV;
1238
1239 if (index == 0) {
1240 ew32(RAL(index), rar_low);
1241 e1e_flush();
1242 ew32(RAH(index), rar_high);
1243 e1e_flush();
1244 return;
1245 }
1246
1247 if (index < hw->mac.rar_entry_count) {
1248 s32 ret_val;
1249
1250 ret_val = e1000_acquire_swflag_ich8lan(hw);
1251 if (ret_val)
1252 goto out;
1253
1254 ew32(SHRAL(index - 1), rar_low);
1255 e1e_flush();
1256 ew32(SHRAH(index - 1), rar_high);
1257 e1e_flush();
1258
1259 e1000_release_swflag_ich8lan(hw);
1260
1261 /* verify the register updates */
1262 if ((er32(SHRAL(index - 1)) == rar_low) &&
1263 (er32(SHRAH(index - 1)) == rar_high))
1264 return;
1265
1266 e_dbg("SHRA[%d] might be locked by ME - FWSM=0x%8.8x\n",
1267 (index - 1), er32(FWSM));
1268 }
1269
1270out:
1271 e_dbg("Failed to write receive address at index %d\n", index);
1272}
1273
1274/**
Bruce Allan2fbe4522012-04-19 03:21:47 +00001275 * e1000_rar_set_pch_lpt - Set receive address registers
1276 * @hw: pointer to the HW structure
1277 * @addr: pointer to the receive address
1278 * @index: receive address array register
1279 *
1280 * Sets the receive address register array at index to the address passed
1281 * in by addr. For LPT, RAR[0] is the base address register that is to
1282 * contain the MAC address. SHRA[0-10] are the shared receive address
1283 * registers that are shared between the Host and manageability engine (ME).
1284 **/
1285static void e1000_rar_set_pch_lpt(struct e1000_hw *hw, u8 *addr, u32 index)
1286{
1287 u32 rar_low, rar_high;
1288 u32 wlock_mac;
1289
Bruce Allane921eb12012-11-28 09:28:37 +00001290 /* HW expects these in little endian so we reverse the byte order
Bruce Allan2fbe4522012-04-19 03:21:47 +00001291 * from network order (big endian) to little endian
1292 */
1293 rar_low = ((u32)addr[0] | ((u32)addr[1] << 8) |
1294 ((u32)addr[2] << 16) | ((u32)addr[3] << 24));
1295
1296 rar_high = ((u32)addr[4] | ((u32)addr[5] << 8));
1297
1298 /* If MAC address zero, no need to set the AV bit */
1299 if (rar_low || rar_high)
1300 rar_high |= E1000_RAH_AV;
1301
1302 if (index == 0) {
1303 ew32(RAL(index), rar_low);
1304 e1e_flush();
1305 ew32(RAH(index), rar_high);
1306 e1e_flush();
1307 return;
1308 }
1309
Bruce Allane921eb12012-11-28 09:28:37 +00001310 /* The manageability engine (ME) can lock certain SHRAR registers that
Bruce Allan2fbe4522012-04-19 03:21:47 +00001311 * it is using - those registers are unavailable for use.
1312 */
1313 if (index < hw->mac.rar_entry_count) {
1314 wlock_mac = er32(FWSM) & E1000_FWSM_WLOCK_MAC_MASK;
1315 wlock_mac >>= E1000_FWSM_WLOCK_MAC_SHIFT;
1316
1317 /* Check if all SHRAR registers are locked */
1318 if (wlock_mac == 1)
1319 goto out;
1320
1321 if ((wlock_mac == 0) || (index <= wlock_mac)) {
1322 s32 ret_val;
1323
1324 ret_val = e1000_acquire_swflag_ich8lan(hw);
1325
1326 if (ret_val)
1327 goto out;
1328
1329 ew32(SHRAL_PCH_LPT(index - 1), rar_low);
1330 e1e_flush();
1331 ew32(SHRAH_PCH_LPT(index - 1), rar_high);
1332 e1e_flush();
1333
1334 e1000_release_swflag_ich8lan(hw);
1335
1336 /* verify the register updates */
1337 if ((er32(SHRAL_PCH_LPT(index - 1)) == rar_low) &&
1338 (er32(SHRAH_PCH_LPT(index - 1)) == rar_high))
1339 return;
1340 }
1341 }
1342
1343out:
1344 e_dbg("Failed to write receive address at index %d\n", index);
1345}
1346
1347/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07001348 * e1000_check_reset_block_ich8lan - Check if PHY reset is blocked
1349 * @hw: pointer to the HW structure
1350 *
1351 * Checks if firmware is blocking the reset of the PHY.
1352 * This is a function pointer entry point only called by
1353 * reset routines.
1354 **/
1355static s32 e1000_check_reset_block_ich8lan(struct e1000_hw *hw)
1356{
1357 u32 fwsm;
1358
1359 fwsm = er32(FWSM);
1360
1361 return (fwsm & E1000_ICH_FWSM_RSPCIPHY) ? 0 : E1000_BLK_PHY_RESET;
1362}
1363
1364/**
Bruce Allan8395ae82010-09-22 17:15:08 +00001365 * e1000_write_smbus_addr - Write SMBus address to PHY needed during Sx states
1366 * @hw: pointer to the HW structure
1367 *
1368 * Assumes semaphore already acquired.
1369 *
1370 **/
1371static s32 e1000_write_smbus_addr(struct e1000_hw *hw)
1372{
1373 u16 phy_data;
1374 u32 strap = er32(STRAP);
Bruce Allan2fbe4522012-04-19 03:21:47 +00001375 u32 freq = (strap & E1000_STRAP_SMT_FREQ_MASK) >>
1376 E1000_STRAP_SMT_FREQ_SHIFT;
Bruce Allan8395ae82010-09-22 17:15:08 +00001377 s32 ret_val = 0;
1378
1379 strap &= E1000_STRAP_SMBUS_ADDRESS_MASK;
1380
1381 ret_val = e1000_read_phy_reg_hv_locked(hw, HV_SMB_ADDR, &phy_data);
1382 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001383 return ret_val;
Bruce Allan8395ae82010-09-22 17:15:08 +00001384
1385 phy_data &= ~HV_SMB_ADDR_MASK;
1386 phy_data |= (strap >> E1000_STRAP_SMBUS_ADDRESS_SHIFT);
1387 phy_data |= HV_SMB_ADDR_PEC_EN | HV_SMB_ADDR_VALID;
Bruce Allan8395ae82010-09-22 17:15:08 +00001388
Bruce Allan2fbe4522012-04-19 03:21:47 +00001389 if (hw->phy.type == e1000_phy_i217) {
1390 /* Restore SMBus frequency */
1391 if (freq--) {
1392 phy_data &= ~HV_SMB_ADDR_FREQ_MASK;
1393 phy_data |= (freq & (1 << 0)) <<
1394 HV_SMB_ADDR_FREQ_LOW_SHIFT;
1395 phy_data |= (freq & (1 << 1)) <<
1396 (HV_SMB_ADDR_FREQ_HIGH_SHIFT - 1);
1397 } else {
1398 e_dbg("Unsupported SMB frequency in PHY\n");
1399 }
1400 }
1401
Bruce Allan5015e532012-02-08 02:55:56 +00001402 return e1000_write_phy_reg_hv_locked(hw, HV_SMB_ADDR, phy_data);
Bruce Allan8395ae82010-09-22 17:15:08 +00001403}
1404
1405/**
Bruce Allanf523d212009-10-29 13:45:45 +00001406 * e1000_sw_lcd_config_ich8lan - SW-based LCD Configuration
1407 * @hw: pointer to the HW structure
1408 *
1409 * SW should configure the LCD from the NVM extended configuration region
1410 * as a workaround for certain parts.
1411 **/
1412static s32 e1000_sw_lcd_config_ich8lan(struct e1000_hw *hw)
1413{
1414 struct e1000_phy_info *phy = &hw->phy;
1415 u32 i, data, cnf_size, cnf_base_addr, sw_cfg_mask;
Bruce Allan8b802a72010-05-10 15:01:10 +00001416 s32 ret_val = 0;
Bruce Allanf523d212009-10-29 13:45:45 +00001417 u16 word_addr, reg_data, reg_addr, phy_page = 0;
1418
Bruce Allane921eb12012-11-28 09:28:37 +00001419 /* Initialize the PHY from the NVM on ICH platforms. This
Bruce Allanf523d212009-10-29 13:45:45 +00001420 * is needed due to an issue where the NVM configuration is
1421 * not properly autoloaded after power transitions.
1422 * Therefore, after each PHY reset, we will load the
1423 * configuration data out of the NVM manually.
1424 */
Bruce Allan3f0c16e2010-06-16 13:26:17 +00001425 switch (hw->mac.type) {
1426 case e1000_ich8lan:
1427 if (phy->type != e1000_phy_igp_3)
1428 return ret_val;
1429
Bruce Allan5f3eed62010-09-22 17:15:54 +00001430 if ((hw->adapter->pdev->device == E1000_DEV_ID_ICH8_IGP_AMT) ||
1431 (hw->adapter->pdev->device == E1000_DEV_ID_ICH8_IGP_C)) {
Bruce Allan3f0c16e2010-06-16 13:26:17 +00001432 sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG;
1433 break;
1434 }
1435 /* Fall-thru */
1436 case e1000_pchlan:
Bruce Alland3738bb2010-06-16 13:27:28 +00001437 case e1000_pch2lan:
Bruce Allan2fbe4522012-04-19 03:21:47 +00001438 case e1000_pch_lpt:
Bruce Allan8b802a72010-05-10 15:01:10 +00001439 sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG_ICH8M;
Bruce Allan3f0c16e2010-06-16 13:26:17 +00001440 break;
1441 default:
1442 return ret_val;
1443 }
1444
1445 ret_val = hw->phy.ops.acquire(hw);
1446 if (ret_val)
1447 return ret_val;
Bruce Allanf523d212009-10-29 13:45:45 +00001448
Bruce Allan8b802a72010-05-10 15:01:10 +00001449 data = er32(FEXTNVM);
1450 if (!(data & sw_cfg_mask))
Bruce Allan75ce1532012-02-08 02:54:48 +00001451 goto release;
Bruce Allanf523d212009-10-29 13:45:45 +00001452
Bruce Allane921eb12012-11-28 09:28:37 +00001453 /* Make sure HW does not configure LCD from PHY
Bruce Allan8b802a72010-05-10 15:01:10 +00001454 * extended configuration before SW configuration
1455 */
1456 data = er32(EXTCNF_CTRL);
Bruce Allan2fbe4522012-04-19 03:21:47 +00001457 if ((hw->mac.type < e1000_pch2lan) &&
1458 (data & E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE))
1459 goto release;
Bruce Allanf523d212009-10-29 13:45:45 +00001460
Bruce Allan8b802a72010-05-10 15:01:10 +00001461 cnf_size = er32(EXTCNF_SIZE);
1462 cnf_size &= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_MASK;
1463 cnf_size >>= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_SHIFT;
1464 if (!cnf_size)
Bruce Allan75ce1532012-02-08 02:54:48 +00001465 goto release;
Bruce Allan8b802a72010-05-10 15:01:10 +00001466
1467 cnf_base_addr = data & E1000_EXTCNF_CTRL_EXT_CNF_POINTER_MASK;
1468 cnf_base_addr >>= E1000_EXTCNF_CTRL_EXT_CNF_POINTER_SHIFT;
1469
Bruce Allan2fbe4522012-04-19 03:21:47 +00001470 if (((hw->mac.type == e1000_pchlan) &&
1471 !(data & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE)) ||
1472 (hw->mac.type > e1000_pchlan)) {
Bruce Allane921eb12012-11-28 09:28:37 +00001473 /* HW configures the SMBus address and LEDs when the
Bruce Allan8b802a72010-05-10 15:01:10 +00001474 * OEM and LCD Write Enable bits are set in the NVM.
1475 * When both NVM bits are cleared, SW will configure
1476 * them instead.
Bruce Allanf523d212009-10-29 13:45:45 +00001477 */
Bruce Allan8395ae82010-09-22 17:15:08 +00001478 ret_val = e1000_write_smbus_addr(hw);
Bruce Allan8b802a72010-05-10 15:01:10 +00001479 if (ret_val)
Bruce Allan75ce1532012-02-08 02:54:48 +00001480 goto release;
Bruce Allanf523d212009-10-29 13:45:45 +00001481
Bruce Allan8b802a72010-05-10 15:01:10 +00001482 data = er32(LEDCTL);
1483 ret_val = e1000_write_phy_reg_hv_locked(hw, HV_LED_CONFIG,
1484 (u16)data);
1485 if (ret_val)
Bruce Allan75ce1532012-02-08 02:54:48 +00001486 goto release;
Bruce Allan8b802a72010-05-10 15:01:10 +00001487 }
1488
1489 /* Configure LCD from extended configuration region. */
1490
1491 /* cnf_base_addr is in DWORD */
1492 word_addr = (u16)(cnf_base_addr << 1);
1493
1494 for (i = 0; i < cnf_size; i++) {
1495 ret_val = e1000_read_nvm(hw, (word_addr + i * 2), 1,
1496 &reg_data);
1497 if (ret_val)
Bruce Allan75ce1532012-02-08 02:54:48 +00001498 goto release;
Bruce Allanf523d212009-10-29 13:45:45 +00001499
Bruce Allan8b802a72010-05-10 15:01:10 +00001500 ret_val = e1000_read_nvm(hw, (word_addr + i * 2 + 1),
1501 1, &reg_addr);
1502 if (ret_val)
Bruce Allan75ce1532012-02-08 02:54:48 +00001503 goto release;
Bruce Allanf523d212009-10-29 13:45:45 +00001504
Bruce Allan8b802a72010-05-10 15:01:10 +00001505 /* Save off the PHY page for future writes. */
1506 if (reg_addr == IGP01E1000_PHY_PAGE_SELECT) {
1507 phy_page = reg_data;
1508 continue;
Bruce Allanf523d212009-10-29 13:45:45 +00001509 }
Bruce Allanf523d212009-10-29 13:45:45 +00001510
Bruce Allan8b802a72010-05-10 15:01:10 +00001511 reg_addr &= PHY_REG_MASK;
1512 reg_addr |= phy_page;
Bruce Allanf523d212009-10-29 13:45:45 +00001513
Bruce Allanf1430d62012-04-14 04:21:52 +00001514 ret_val = e1e_wphy_locked(hw, (u32)reg_addr, reg_data);
Bruce Allan8b802a72010-05-10 15:01:10 +00001515 if (ret_val)
Bruce Allan75ce1532012-02-08 02:54:48 +00001516 goto release;
Bruce Allanf523d212009-10-29 13:45:45 +00001517 }
1518
Bruce Allan75ce1532012-02-08 02:54:48 +00001519release:
Bruce Allan94d81862009-11-20 23:25:26 +00001520 hw->phy.ops.release(hw);
Bruce Allanf523d212009-10-29 13:45:45 +00001521 return ret_val;
1522}
1523
1524/**
Bruce Allan1d5846b2009-10-29 13:46:05 +00001525 * e1000_k1_gig_workaround_hv - K1 Si workaround
1526 * @hw: pointer to the HW structure
1527 * @link: link up bool flag
1528 *
1529 * If K1 is enabled for 1Gbps, the MAC might stall when transitioning
1530 * from a lower speed. This workaround disables K1 whenever link is at 1Gig
1531 * If link is down, the function will restore the default K1 setting located
1532 * in the NVM.
1533 **/
1534static s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link)
1535{
1536 s32 ret_val = 0;
1537 u16 status_reg = 0;
1538 bool k1_enable = hw->dev_spec.ich8lan.nvm_k1_enabled;
1539
1540 if (hw->mac.type != e1000_pchlan)
Bruce Allan5015e532012-02-08 02:55:56 +00001541 return 0;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001542
1543 /* Wrap the whole flow with the sw flag */
Bruce Allan94d81862009-11-20 23:25:26 +00001544 ret_val = hw->phy.ops.acquire(hw);
Bruce Allan1d5846b2009-10-29 13:46:05 +00001545 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001546 return ret_val;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001547
1548 /* Disable K1 when link is 1Gbps, otherwise use the NVM setting */
1549 if (link) {
1550 if (hw->phy.type == e1000_phy_82578) {
Bruce Allanf1430d62012-04-14 04:21:52 +00001551 ret_val = e1e_rphy_locked(hw, BM_CS_STATUS,
1552 &status_reg);
Bruce Allan1d5846b2009-10-29 13:46:05 +00001553 if (ret_val)
1554 goto release;
1555
1556 status_reg &= BM_CS_STATUS_LINK_UP |
1557 BM_CS_STATUS_RESOLVED |
1558 BM_CS_STATUS_SPEED_MASK;
1559
1560 if (status_reg == (BM_CS_STATUS_LINK_UP |
1561 BM_CS_STATUS_RESOLVED |
1562 BM_CS_STATUS_SPEED_1000))
1563 k1_enable = false;
1564 }
1565
1566 if (hw->phy.type == e1000_phy_82577) {
Bruce Allanf1430d62012-04-14 04:21:52 +00001567 ret_val = e1e_rphy_locked(hw, HV_M_STATUS, &status_reg);
Bruce Allan1d5846b2009-10-29 13:46:05 +00001568 if (ret_val)
1569 goto release;
1570
1571 status_reg &= HV_M_STATUS_LINK_UP |
1572 HV_M_STATUS_AUTONEG_COMPLETE |
1573 HV_M_STATUS_SPEED_MASK;
1574
1575 if (status_reg == (HV_M_STATUS_LINK_UP |
1576 HV_M_STATUS_AUTONEG_COMPLETE |
1577 HV_M_STATUS_SPEED_1000))
1578 k1_enable = false;
1579 }
1580
1581 /* Link stall fix for link up */
Bruce Allanf1430d62012-04-14 04:21:52 +00001582 ret_val = e1e_wphy_locked(hw, PHY_REG(770, 19), 0x0100);
Bruce Allan1d5846b2009-10-29 13:46:05 +00001583 if (ret_val)
1584 goto release;
1585
1586 } else {
1587 /* Link stall fix for link down */
Bruce Allanf1430d62012-04-14 04:21:52 +00001588 ret_val = e1e_wphy_locked(hw, PHY_REG(770, 19), 0x4100);
Bruce Allan1d5846b2009-10-29 13:46:05 +00001589 if (ret_val)
1590 goto release;
1591 }
1592
1593 ret_val = e1000_configure_k1_ich8lan(hw, k1_enable);
1594
1595release:
Bruce Allan94d81862009-11-20 23:25:26 +00001596 hw->phy.ops.release(hw);
Bruce Allan5015e532012-02-08 02:55:56 +00001597
Bruce Allan1d5846b2009-10-29 13:46:05 +00001598 return ret_val;
1599}
1600
1601/**
1602 * e1000_configure_k1_ich8lan - Configure K1 power state
1603 * @hw: pointer to the HW structure
1604 * @enable: K1 state to configure
1605 *
1606 * Configure the K1 power state based on the provided parameter.
1607 * Assumes semaphore already acquired.
1608 *
1609 * Success returns 0, Failure returns -E1000_ERR_PHY (-2)
1610 **/
Bruce Allanbb436b22009-11-20 23:24:11 +00001611s32 e1000_configure_k1_ich8lan(struct e1000_hw *hw, bool k1_enable)
Bruce Allan1d5846b2009-10-29 13:46:05 +00001612{
1613 s32 ret_val = 0;
1614 u32 ctrl_reg = 0;
1615 u32 ctrl_ext = 0;
1616 u32 reg = 0;
1617 u16 kmrn_reg = 0;
1618
Bruce Allan3d3a1672012-02-23 03:13:18 +00001619 ret_val = e1000e_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
1620 &kmrn_reg);
Bruce Allan1d5846b2009-10-29 13:46:05 +00001621 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001622 return ret_val;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001623
1624 if (k1_enable)
1625 kmrn_reg |= E1000_KMRNCTRLSTA_K1_ENABLE;
1626 else
1627 kmrn_reg &= ~E1000_KMRNCTRLSTA_K1_ENABLE;
1628
Bruce Allan3d3a1672012-02-23 03:13:18 +00001629 ret_val = e1000e_write_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
1630 kmrn_reg);
Bruce Allan1d5846b2009-10-29 13:46:05 +00001631 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001632 return ret_val;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001633
1634 udelay(20);
1635 ctrl_ext = er32(CTRL_EXT);
1636 ctrl_reg = er32(CTRL);
1637
1638 reg = ctrl_reg & ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100);
1639 reg |= E1000_CTRL_FRCSPD;
1640 ew32(CTRL, reg);
1641
1642 ew32(CTRL_EXT, ctrl_ext | E1000_CTRL_EXT_SPD_BYPS);
Jesse Brandeburg945a5152011-07-20 00:56:21 +00001643 e1e_flush();
Bruce Allan1d5846b2009-10-29 13:46:05 +00001644 udelay(20);
1645 ew32(CTRL, ctrl_reg);
1646 ew32(CTRL_EXT, ctrl_ext);
Jesse Brandeburg945a5152011-07-20 00:56:21 +00001647 e1e_flush();
Bruce Allan1d5846b2009-10-29 13:46:05 +00001648 udelay(20);
1649
Bruce Allan5015e532012-02-08 02:55:56 +00001650 return 0;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001651}
1652
1653/**
Bruce Allanf523d212009-10-29 13:45:45 +00001654 * e1000_oem_bits_config_ich8lan - SW-based LCD Configuration
1655 * @hw: pointer to the HW structure
1656 * @d0_state: boolean if entering d0 or d3 device state
1657 *
1658 * SW will configure Gbe Disable and LPLU based on the NVM. The four bits are
1659 * collectively called OEM bits. The OEM Write Enable bit and SW Config bit
1660 * in NVM determines whether HW should configure LPLU and Gbe Disable.
1661 **/
1662static s32 e1000_oem_bits_config_ich8lan(struct e1000_hw *hw, bool d0_state)
1663{
1664 s32 ret_val = 0;
1665 u32 mac_reg;
1666 u16 oem_reg;
1667
Bruce Allan2fbe4522012-04-19 03:21:47 +00001668 if (hw->mac.type < e1000_pchlan)
Bruce Allanf523d212009-10-29 13:45:45 +00001669 return ret_val;
1670
Bruce Allan94d81862009-11-20 23:25:26 +00001671 ret_val = hw->phy.ops.acquire(hw);
Bruce Allanf523d212009-10-29 13:45:45 +00001672 if (ret_val)
1673 return ret_val;
1674
Bruce Allan2fbe4522012-04-19 03:21:47 +00001675 if (hw->mac.type == e1000_pchlan) {
Bruce Alland3738bb2010-06-16 13:27:28 +00001676 mac_reg = er32(EXTCNF_CTRL);
1677 if (mac_reg & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE)
Bruce Allan75ce1532012-02-08 02:54:48 +00001678 goto release;
Bruce Alland3738bb2010-06-16 13:27:28 +00001679 }
Bruce Allanf523d212009-10-29 13:45:45 +00001680
1681 mac_reg = er32(FEXTNVM);
1682 if (!(mac_reg & E1000_FEXTNVM_SW_CONFIG_ICH8M))
Bruce Allan75ce1532012-02-08 02:54:48 +00001683 goto release;
Bruce Allanf523d212009-10-29 13:45:45 +00001684
1685 mac_reg = er32(PHY_CTRL);
1686
Bruce Allanf1430d62012-04-14 04:21:52 +00001687 ret_val = e1e_rphy_locked(hw, HV_OEM_BITS, &oem_reg);
Bruce Allanf523d212009-10-29 13:45:45 +00001688 if (ret_val)
Bruce Allan75ce1532012-02-08 02:54:48 +00001689 goto release;
Bruce Allanf523d212009-10-29 13:45:45 +00001690
1691 oem_reg &= ~(HV_OEM_BITS_GBE_DIS | HV_OEM_BITS_LPLU);
1692
1693 if (d0_state) {
1694 if (mac_reg & E1000_PHY_CTRL_GBE_DISABLE)
1695 oem_reg |= HV_OEM_BITS_GBE_DIS;
1696
1697 if (mac_reg & E1000_PHY_CTRL_D0A_LPLU)
1698 oem_reg |= HV_OEM_BITS_LPLU;
1699 } else {
Bruce Allan03299e42011-09-30 08:07:05 +00001700 if (mac_reg & (E1000_PHY_CTRL_GBE_DISABLE |
1701 E1000_PHY_CTRL_NOND0A_GBE_DISABLE))
Bruce Allanf523d212009-10-29 13:45:45 +00001702 oem_reg |= HV_OEM_BITS_GBE_DIS;
1703
Bruce Allan03299e42011-09-30 08:07:05 +00001704 if (mac_reg & (E1000_PHY_CTRL_D0A_LPLU |
1705 E1000_PHY_CTRL_NOND0A_LPLU))
Bruce Allanf523d212009-10-29 13:45:45 +00001706 oem_reg |= HV_OEM_BITS_LPLU;
1707 }
Bruce Allan03299e42011-09-30 08:07:05 +00001708
Bruce Allan92fe1732012-04-12 06:27:03 +00001709 /* Set Restart auto-neg to activate the bits */
1710 if ((d0_state || (hw->mac.type != e1000_pchlan)) &&
1711 !hw->phy.ops.check_reset_block(hw))
1712 oem_reg |= HV_OEM_BITS_RESTART_AN;
1713
Bruce Allanf1430d62012-04-14 04:21:52 +00001714 ret_val = e1e_wphy_locked(hw, HV_OEM_BITS, oem_reg);
Bruce Allanf523d212009-10-29 13:45:45 +00001715
Bruce Allan75ce1532012-02-08 02:54:48 +00001716release:
Bruce Allan94d81862009-11-20 23:25:26 +00001717 hw->phy.ops.release(hw);
Bruce Allanf523d212009-10-29 13:45:45 +00001718
1719 return ret_val;
1720}
1721
1722
1723/**
Bruce Allanfddaa1a2010-01-13 01:52:49 +00001724 * e1000_set_mdio_slow_mode_hv - Set slow MDIO access mode
1725 * @hw: pointer to the HW structure
1726 **/
1727static s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw)
1728{
1729 s32 ret_val;
1730 u16 data;
1731
1732 ret_val = e1e_rphy(hw, HV_KMRN_MODE_CTRL, &data);
1733 if (ret_val)
1734 return ret_val;
1735
1736 data |= HV_KMRN_MDIO_SLOW;
1737
1738 ret_val = e1e_wphy(hw, HV_KMRN_MODE_CTRL, data);
1739
1740 return ret_val;
1741}
1742
1743/**
Bruce Allana4f58f52009-06-02 11:29:18 +00001744 * e1000_hv_phy_workarounds_ich8lan - A series of Phy workarounds to be
1745 * done after every PHY reset.
1746 **/
1747static s32 e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw)
1748{
1749 s32 ret_val = 0;
Bruce Allanbaf86c92010-01-13 01:53:08 +00001750 u16 phy_data;
Bruce Allana4f58f52009-06-02 11:29:18 +00001751
1752 if (hw->mac.type != e1000_pchlan)
Bruce Allan5015e532012-02-08 02:55:56 +00001753 return 0;
Bruce Allana4f58f52009-06-02 11:29:18 +00001754
Bruce Allanfddaa1a2010-01-13 01:52:49 +00001755 /* Set MDIO slow mode before any other MDIO access */
1756 if (hw->phy.type == e1000_phy_82577) {
1757 ret_val = e1000_set_mdio_slow_mode_hv(hw);
1758 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001759 return ret_val;
Bruce Allanfddaa1a2010-01-13 01:52:49 +00001760 }
1761
Bruce Allana4f58f52009-06-02 11:29:18 +00001762 if (((hw->phy.type == e1000_phy_82577) &&
1763 ((hw->phy.revision == 1) || (hw->phy.revision == 2))) ||
1764 ((hw->phy.type == e1000_phy_82578) && (hw->phy.revision == 1))) {
1765 /* Disable generation of early preamble */
1766 ret_val = e1e_wphy(hw, PHY_REG(769, 25), 0x4431);
1767 if (ret_val)
1768 return ret_val;
1769
1770 /* Preamble tuning for SSC */
Bruce Allan1d2101a72011-07-22 06:21:56 +00001771 ret_val = e1e_wphy(hw, HV_KMRN_FIFO_CTRLSTA, 0xA204);
Bruce Allana4f58f52009-06-02 11:29:18 +00001772 if (ret_val)
1773 return ret_val;
1774 }
1775
1776 if (hw->phy.type == e1000_phy_82578) {
Bruce Allane921eb12012-11-28 09:28:37 +00001777 /* Return registers to default by doing a soft reset then
Bruce Allana4f58f52009-06-02 11:29:18 +00001778 * writing 0x3140 to the control register.
1779 */
1780 if (hw->phy.revision < 2) {
1781 e1000e_phy_sw_reset(hw);
1782 ret_val = e1e_wphy(hw, PHY_CONTROL, 0x3140);
1783 }
1784 }
1785
1786 /* Select page 0 */
Bruce Allan94d81862009-11-20 23:25:26 +00001787 ret_val = hw->phy.ops.acquire(hw);
Bruce Allana4f58f52009-06-02 11:29:18 +00001788 if (ret_val)
1789 return ret_val;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001790
Bruce Allana4f58f52009-06-02 11:29:18 +00001791 hw->phy.addr = 1;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001792 ret_val = e1000e_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT, 0);
Bruce Allanbaf86c92010-01-13 01:53:08 +00001793 hw->phy.ops.release(hw);
Bruce Allan1d5846b2009-10-29 13:46:05 +00001794 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001795 return ret_val;
Bruce Allana4f58f52009-06-02 11:29:18 +00001796
Bruce Allane921eb12012-11-28 09:28:37 +00001797 /* Configure the K1 Si workaround during phy reset assuming there is
Bruce Allan1d5846b2009-10-29 13:46:05 +00001798 * link so that it disables K1 if link is in 1Gbps.
1799 */
1800 ret_val = e1000_k1_gig_workaround_hv(hw, true);
Bruce Allanbaf86c92010-01-13 01:53:08 +00001801 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001802 return ret_val;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001803
Bruce Allanbaf86c92010-01-13 01:53:08 +00001804 /* Workaround for link disconnects on a busy hub in half duplex */
1805 ret_val = hw->phy.ops.acquire(hw);
1806 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001807 return ret_val;
Bruce Allanf1430d62012-04-14 04:21:52 +00001808 ret_val = e1e_rphy_locked(hw, BM_PORT_GEN_CFG, &phy_data);
Bruce Allanbaf86c92010-01-13 01:53:08 +00001809 if (ret_val)
1810 goto release;
Bruce Allanf1430d62012-04-14 04:21:52 +00001811 ret_val = e1e_wphy_locked(hw, BM_PORT_GEN_CFG, phy_data & 0x00FF);
Bruce Allanbaf86c92010-01-13 01:53:08 +00001812release:
1813 hw->phy.ops.release(hw);
Bruce Allan5015e532012-02-08 02:55:56 +00001814
Bruce Allana4f58f52009-06-02 11:29:18 +00001815 return ret_val;
1816}
1817
1818/**
Bruce Alland3738bb2010-06-16 13:27:28 +00001819 * e1000_copy_rx_addrs_to_phy_ich8lan - Copy Rx addresses from MAC to PHY
1820 * @hw: pointer to the HW structure
1821 **/
1822void e1000_copy_rx_addrs_to_phy_ich8lan(struct e1000_hw *hw)
1823{
1824 u32 mac_reg;
Bruce Allan2b6b1682011-05-13 07:20:09 +00001825 u16 i, phy_reg = 0;
1826 s32 ret_val;
1827
1828 ret_val = hw->phy.ops.acquire(hw);
1829 if (ret_val)
1830 return;
1831 ret_val = e1000_enable_phy_wakeup_reg_access_bm(hw, &phy_reg);
1832 if (ret_val)
1833 goto release;
Bruce Alland3738bb2010-06-16 13:27:28 +00001834
1835 /* Copy both RAL/H (rar_entry_count) and SHRAL/H (+4) to PHY */
1836 for (i = 0; i < (hw->mac.rar_entry_count + 4); i++) {
1837 mac_reg = er32(RAL(i));
Bruce Allan2b6b1682011-05-13 07:20:09 +00001838 hw->phy.ops.write_reg_page(hw, BM_RAR_L(i),
1839 (u16)(mac_reg & 0xFFFF));
1840 hw->phy.ops.write_reg_page(hw, BM_RAR_M(i),
1841 (u16)((mac_reg >> 16) & 0xFFFF));
1842
Bruce Alland3738bb2010-06-16 13:27:28 +00001843 mac_reg = er32(RAH(i));
Bruce Allan2b6b1682011-05-13 07:20:09 +00001844 hw->phy.ops.write_reg_page(hw, BM_RAR_H(i),
1845 (u16)(mac_reg & 0xFFFF));
1846 hw->phy.ops.write_reg_page(hw, BM_RAR_CTRL(i),
1847 (u16)((mac_reg & E1000_RAH_AV)
1848 >> 16));
Bruce Alland3738bb2010-06-16 13:27:28 +00001849 }
Bruce Allan2b6b1682011-05-13 07:20:09 +00001850
1851 e1000_disable_phy_wakeup_reg_access_bm(hw, &phy_reg);
1852
1853release:
1854 hw->phy.ops.release(hw);
Bruce Alland3738bb2010-06-16 13:27:28 +00001855}
1856
Bruce Alland3738bb2010-06-16 13:27:28 +00001857/**
1858 * e1000_lv_jumbo_workaround_ich8lan - required for jumbo frame operation
1859 * with 82579 PHY
1860 * @hw: pointer to the HW structure
1861 * @enable: flag to enable/disable workaround when enabling/disabling jumbos
1862 **/
1863s32 e1000_lv_jumbo_workaround_ich8lan(struct e1000_hw *hw, bool enable)
1864{
1865 s32 ret_val = 0;
1866 u16 phy_reg, data;
1867 u32 mac_reg;
1868 u16 i;
1869
Bruce Allan2fbe4522012-04-19 03:21:47 +00001870 if (hw->mac.type < e1000_pch2lan)
Bruce Allan5015e532012-02-08 02:55:56 +00001871 return 0;
Bruce Alland3738bb2010-06-16 13:27:28 +00001872
1873 /* disable Rx path while enabling/disabling workaround */
1874 e1e_rphy(hw, PHY_REG(769, 20), &phy_reg);
1875 ret_val = e1e_wphy(hw, PHY_REG(769, 20), phy_reg | (1 << 14));
1876 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001877 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001878
1879 if (enable) {
Bruce Allane921eb12012-11-28 09:28:37 +00001880 /* Write Rx addresses (rar_entry_count for RAL/H, +4 for
Bruce Alland3738bb2010-06-16 13:27:28 +00001881 * SHRAL/H) and initial CRC values to the MAC
1882 */
1883 for (i = 0; i < (hw->mac.rar_entry_count + 4); i++) {
1884 u8 mac_addr[ETH_ALEN] = {0};
1885 u32 addr_high, addr_low;
1886
1887 addr_high = er32(RAH(i));
1888 if (!(addr_high & E1000_RAH_AV))
1889 continue;
1890 addr_low = er32(RAL(i));
1891 mac_addr[0] = (addr_low & 0xFF);
1892 mac_addr[1] = ((addr_low >> 8) & 0xFF);
1893 mac_addr[2] = ((addr_low >> 16) & 0xFF);
1894 mac_addr[3] = ((addr_low >> 24) & 0xFF);
1895 mac_addr[4] = (addr_high & 0xFF);
1896 mac_addr[5] = ((addr_high >> 8) & 0xFF);
1897
Bruce Allanfe46f582011-01-06 14:29:51 +00001898 ew32(PCH_RAICC(i), ~ether_crc_le(ETH_ALEN, mac_addr));
Bruce Alland3738bb2010-06-16 13:27:28 +00001899 }
1900
1901 /* Write Rx addresses to the PHY */
1902 e1000_copy_rx_addrs_to_phy_ich8lan(hw);
1903
1904 /* Enable jumbo frame workaround in the MAC */
1905 mac_reg = er32(FFLT_DBG);
1906 mac_reg &= ~(1 << 14);
1907 mac_reg |= (7 << 15);
1908 ew32(FFLT_DBG, mac_reg);
1909
1910 mac_reg = er32(RCTL);
1911 mac_reg |= E1000_RCTL_SECRC;
1912 ew32(RCTL, mac_reg);
1913
1914 ret_val = e1000e_read_kmrn_reg(hw,
1915 E1000_KMRNCTRLSTA_CTRL_OFFSET,
1916 &data);
1917 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001918 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001919 ret_val = e1000e_write_kmrn_reg(hw,
1920 E1000_KMRNCTRLSTA_CTRL_OFFSET,
1921 data | (1 << 0));
1922 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001923 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001924 ret_val = e1000e_read_kmrn_reg(hw,
1925 E1000_KMRNCTRLSTA_HD_CTRL,
1926 &data);
1927 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001928 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001929 data &= ~(0xF << 8);
1930 data |= (0xB << 8);
1931 ret_val = e1000e_write_kmrn_reg(hw,
1932 E1000_KMRNCTRLSTA_HD_CTRL,
1933 data);
1934 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001935 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001936
1937 /* Enable jumbo frame workaround in the PHY */
Bruce Alland3738bb2010-06-16 13:27:28 +00001938 e1e_rphy(hw, PHY_REG(769, 23), &data);
1939 data &= ~(0x7F << 5);
1940 data |= (0x37 << 5);
1941 ret_val = e1e_wphy(hw, PHY_REG(769, 23), data);
1942 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001943 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001944 e1e_rphy(hw, PHY_REG(769, 16), &data);
1945 data &= ~(1 << 13);
Bruce Alland3738bb2010-06-16 13:27:28 +00001946 ret_val = e1e_wphy(hw, PHY_REG(769, 16), data);
1947 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001948 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001949 e1e_rphy(hw, PHY_REG(776, 20), &data);
1950 data &= ~(0x3FF << 2);
1951 data |= (0x1A << 2);
1952 ret_val = e1e_wphy(hw, PHY_REG(776, 20), data);
1953 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001954 return ret_val;
Bruce Allanb64e9dd2011-09-30 08:07:00 +00001955 ret_val = e1e_wphy(hw, PHY_REG(776, 23), 0xF100);
Bruce Alland3738bb2010-06-16 13:27:28 +00001956 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001957 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001958 e1e_rphy(hw, HV_PM_CTRL, &data);
1959 ret_val = e1e_wphy(hw, HV_PM_CTRL, data | (1 << 10));
1960 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001961 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001962 } else {
1963 /* Write MAC register values back to h/w defaults */
1964 mac_reg = er32(FFLT_DBG);
1965 mac_reg &= ~(0xF << 14);
1966 ew32(FFLT_DBG, mac_reg);
1967
1968 mac_reg = er32(RCTL);
1969 mac_reg &= ~E1000_RCTL_SECRC;
Bruce Allana1ce6472010-09-22 17:16:40 +00001970 ew32(RCTL, mac_reg);
Bruce Alland3738bb2010-06-16 13:27:28 +00001971
1972 ret_val = e1000e_read_kmrn_reg(hw,
1973 E1000_KMRNCTRLSTA_CTRL_OFFSET,
1974 &data);
1975 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001976 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001977 ret_val = e1000e_write_kmrn_reg(hw,
1978 E1000_KMRNCTRLSTA_CTRL_OFFSET,
1979 data & ~(1 << 0));
1980 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001981 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001982 ret_val = e1000e_read_kmrn_reg(hw,
1983 E1000_KMRNCTRLSTA_HD_CTRL,
1984 &data);
1985 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001986 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001987 data &= ~(0xF << 8);
1988 data |= (0xB << 8);
1989 ret_val = e1000e_write_kmrn_reg(hw,
1990 E1000_KMRNCTRLSTA_HD_CTRL,
1991 data);
1992 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001993 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00001994
1995 /* Write PHY register values back to h/w defaults */
Bruce Alland3738bb2010-06-16 13:27:28 +00001996 e1e_rphy(hw, PHY_REG(769, 23), &data);
1997 data &= ~(0x7F << 5);
1998 ret_val = e1e_wphy(hw, PHY_REG(769, 23), data);
1999 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00002000 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00002001 e1e_rphy(hw, PHY_REG(769, 16), &data);
Bruce Alland3738bb2010-06-16 13:27:28 +00002002 data |= (1 << 13);
2003 ret_val = e1e_wphy(hw, PHY_REG(769, 16), data);
2004 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00002005 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00002006 e1e_rphy(hw, PHY_REG(776, 20), &data);
2007 data &= ~(0x3FF << 2);
2008 data |= (0x8 << 2);
2009 ret_val = e1e_wphy(hw, PHY_REG(776, 20), data);
2010 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00002011 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00002012 ret_val = e1e_wphy(hw, PHY_REG(776, 23), 0x7E00);
2013 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00002014 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00002015 e1e_rphy(hw, HV_PM_CTRL, &data);
2016 ret_val = e1e_wphy(hw, HV_PM_CTRL, data & ~(1 << 10));
2017 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00002018 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00002019 }
2020
2021 /* re-enable Rx path after enabling/disabling workaround */
Bruce Allan5015e532012-02-08 02:55:56 +00002022 return e1e_wphy(hw, PHY_REG(769, 20), phy_reg & ~(1 << 14));
Bruce Alland3738bb2010-06-16 13:27:28 +00002023}
2024
2025/**
2026 * e1000_lv_phy_workarounds_ich8lan - A series of Phy workarounds to be
2027 * done after every PHY reset.
2028 **/
2029static s32 e1000_lv_phy_workarounds_ich8lan(struct e1000_hw *hw)
2030{
2031 s32 ret_val = 0;
2032
2033 if (hw->mac.type != e1000_pch2lan)
Bruce Allan5015e532012-02-08 02:55:56 +00002034 return 0;
Bruce Alland3738bb2010-06-16 13:27:28 +00002035
2036 /* Set MDIO slow mode before any other MDIO access */
2037 ret_val = e1000_set_mdio_slow_mode_hv(hw);
2038
Bruce Allan4d241362011-12-16 00:46:06 +00002039 ret_val = hw->phy.ops.acquire(hw);
2040 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00002041 return ret_val;
Bruce Allan4d241362011-12-16 00:46:06 +00002042 /* set MSE higher to enable link to stay up when noise is high */
Bruce Allan4ddc48a2012-12-05 06:25:58 +00002043 ret_val = e1000_write_emi_reg_locked(hw, I82579_MSE_THRESHOLD, 0x0034);
Bruce Allan4d241362011-12-16 00:46:06 +00002044 if (ret_val)
2045 goto release;
2046 /* drop link after 5 times MSE threshold was reached */
Bruce Allan4ddc48a2012-12-05 06:25:58 +00002047 ret_val = e1000_write_emi_reg_locked(hw, I82579_MSE_LINK_DOWN, 0x0005);
Bruce Allan4d241362011-12-16 00:46:06 +00002048release:
2049 hw->phy.ops.release(hw);
2050
Bruce Alland3738bb2010-06-16 13:27:28 +00002051 return ret_val;
2052}
2053
2054/**
Bruce Allan831bd2e2010-09-22 17:16:18 +00002055 * e1000_k1_gig_workaround_lv - K1 Si workaround
2056 * @hw: pointer to the HW structure
2057 *
2058 * Workaround to set the K1 beacon duration for 82579 parts
2059 **/
2060static s32 e1000_k1_workaround_lv(struct e1000_hw *hw)
2061{
2062 s32 ret_val = 0;
2063 u16 status_reg = 0;
2064 u32 mac_reg;
Bruce Allan0ed013e2011-07-29 05:52:56 +00002065 u16 phy_reg;
Bruce Allan831bd2e2010-09-22 17:16:18 +00002066
2067 if (hw->mac.type != e1000_pch2lan)
Bruce Allan5015e532012-02-08 02:55:56 +00002068 return 0;
Bruce Allan831bd2e2010-09-22 17:16:18 +00002069
2070 /* Set K1 beacon duration based on 1Gbps speed or otherwise */
2071 ret_val = e1e_rphy(hw, HV_M_STATUS, &status_reg);
2072 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00002073 return ret_val;
Bruce Allan831bd2e2010-09-22 17:16:18 +00002074
2075 if ((status_reg & (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE))
2076 == (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE)) {
2077 mac_reg = er32(FEXTNVM4);
2078 mac_reg &= ~E1000_FEXTNVM4_BEACON_DURATION_MASK;
2079
Bruce Allan0ed013e2011-07-29 05:52:56 +00002080 ret_val = e1e_rphy(hw, I82579_LPI_CTRL, &phy_reg);
2081 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00002082 return ret_val;
Bruce Allan831bd2e2010-09-22 17:16:18 +00002083
Bruce Allan0ed013e2011-07-29 05:52:56 +00002084 if (status_reg & HV_M_STATUS_SPEED_1000) {
Bruce Allan36ceeb42012-03-20 03:47:47 +00002085 u16 pm_phy_reg;
2086
Bruce Allan0ed013e2011-07-29 05:52:56 +00002087 mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_8USEC;
2088 phy_reg &= ~I82579_LPI_CTRL_FORCE_PLL_LOCK_COUNT;
Bruce Allan36ceeb42012-03-20 03:47:47 +00002089 /* LV 1G Packet drop issue wa */
2090 ret_val = e1e_rphy(hw, HV_PM_CTRL, &pm_phy_reg);
2091 if (ret_val)
2092 return ret_val;
2093 pm_phy_reg &= ~HV_PM_CTRL_PLL_STOP_IN_K1_GIGA;
2094 ret_val = e1e_wphy(hw, HV_PM_CTRL, pm_phy_reg);
2095 if (ret_val)
2096 return ret_val;
Bruce Allan0ed013e2011-07-29 05:52:56 +00002097 } else {
2098 mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_16USEC;
2099 phy_reg |= I82579_LPI_CTRL_FORCE_PLL_LOCK_COUNT;
2100 }
Bruce Allan831bd2e2010-09-22 17:16:18 +00002101 ew32(FEXTNVM4, mac_reg);
Bruce Allan0ed013e2011-07-29 05:52:56 +00002102 ret_val = e1e_wphy(hw, I82579_LPI_CTRL, phy_reg);
Bruce Allan831bd2e2010-09-22 17:16:18 +00002103 }
2104
Bruce Allan831bd2e2010-09-22 17:16:18 +00002105 return ret_val;
2106}
2107
2108/**
Bruce Allan605c82b2010-09-22 17:17:01 +00002109 * e1000_gate_hw_phy_config_ich8lan - disable PHY config via hardware
2110 * @hw: pointer to the HW structure
2111 * @gate: boolean set to true to gate, false to ungate
2112 *
2113 * Gate/ungate the automatic PHY configuration via hardware; perform
2114 * the configuration via software instead.
2115 **/
2116static void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate)
2117{
2118 u32 extcnf_ctrl;
2119
Bruce Allan2fbe4522012-04-19 03:21:47 +00002120 if (hw->mac.type < e1000_pch2lan)
Bruce Allan605c82b2010-09-22 17:17:01 +00002121 return;
2122
2123 extcnf_ctrl = er32(EXTCNF_CTRL);
2124
2125 if (gate)
2126 extcnf_ctrl |= E1000_EXTCNF_CTRL_GATE_PHY_CFG;
2127 else
2128 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_GATE_PHY_CFG;
2129
2130 ew32(EXTCNF_CTRL, extcnf_ctrl);
Bruce Allan605c82b2010-09-22 17:17:01 +00002131}
2132
2133/**
Bruce Allanfc0c7762009-07-01 13:27:55 +00002134 * e1000_lan_init_done_ich8lan - Check for PHY config completion
2135 * @hw: pointer to the HW structure
2136 *
2137 * Check the appropriate indication the MAC has finished configuring the
2138 * PHY after a software reset.
2139 **/
2140static void e1000_lan_init_done_ich8lan(struct e1000_hw *hw)
2141{
2142 u32 data, loop = E1000_ICH8_LAN_INIT_TIMEOUT;
2143
2144 /* Wait for basic configuration completes before proceeding */
2145 do {
2146 data = er32(STATUS);
2147 data &= E1000_STATUS_LAN_INIT_DONE;
2148 udelay(100);
2149 } while ((!data) && --loop);
2150
Bruce Allane921eb12012-11-28 09:28:37 +00002151 /* If basic configuration is incomplete before the above loop
Bruce Allanfc0c7762009-07-01 13:27:55 +00002152 * count reaches 0, loading the configuration from NVM will
2153 * leave the PHY in a bad state possibly resulting in no link.
2154 */
2155 if (loop == 0)
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002156 e_dbg("LAN_INIT_DONE not set, increase timeout\n");
Bruce Allanfc0c7762009-07-01 13:27:55 +00002157
2158 /* Clear the Init Done bit for the next init event */
2159 data = er32(STATUS);
2160 data &= ~E1000_STATUS_LAN_INIT_DONE;
2161 ew32(STATUS, data);
2162}
2163
2164/**
Bruce Allane98cac42010-05-10 15:02:32 +00002165 * e1000_post_phy_reset_ich8lan - Perform steps required after a PHY reset
Auke Kokbc7f75f2007-09-17 12:30:59 -07002166 * @hw: pointer to the HW structure
Auke Kokbc7f75f2007-09-17 12:30:59 -07002167 **/
Bruce Allane98cac42010-05-10 15:02:32 +00002168static s32 e1000_post_phy_reset_ich8lan(struct e1000_hw *hw)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002169{
Bruce Allanf523d212009-10-29 13:45:45 +00002170 s32 ret_val = 0;
2171 u16 reg;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002172
Bruce Allan44abd5c2012-02-22 09:02:37 +00002173 if (hw->phy.ops.check_reset_block(hw))
Bruce Allan5015e532012-02-08 02:55:56 +00002174 return 0;
Bruce Allanfc0c7762009-07-01 13:27:55 +00002175
Bruce Allan5f3eed62010-09-22 17:15:54 +00002176 /* Allow time for h/w to get to quiescent state after reset */
Bruce Allan1bba4382011-03-19 00:27:20 +00002177 usleep_range(10000, 20000);
Bruce Allan5f3eed62010-09-22 17:15:54 +00002178
Bruce Allanfddaa1a2010-01-13 01:52:49 +00002179 /* Perform any necessary post-reset workarounds */
Bruce Allane98cac42010-05-10 15:02:32 +00002180 switch (hw->mac.type) {
2181 case e1000_pchlan:
Bruce Allana4f58f52009-06-02 11:29:18 +00002182 ret_val = e1000_hv_phy_workarounds_ich8lan(hw);
2183 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00002184 return ret_val;
Bruce Allane98cac42010-05-10 15:02:32 +00002185 break;
Bruce Alland3738bb2010-06-16 13:27:28 +00002186 case e1000_pch2lan:
2187 ret_val = e1000_lv_phy_workarounds_ich8lan(hw);
2188 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00002189 return ret_val;
Bruce Alland3738bb2010-06-16 13:27:28 +00002190 break;
Bruce Allane98cac42010-05-10 15:02:32 +00002191 default:
2192 break;
Bruce Allana4f58f52009-06-02 11:29:18 +00002193 }
2194
Bruce Allan3ebfc7c2011-05-13 07:20:14 +00002195 /* Clear the host wakeup bit after lcd reset */
2196 if (hw->mac.type >= e1000_pchlan) {
2197 e1e_rphy(hw, BM_PORT_GEN_CFG, &reg);
2198 reg &= ~BM_WUC_HOST_WU_BIT;
2199 e1e_wphy(hw, BM_PORT_GEN_CFG, reg);
2200 }
Bruce Allandb2932e2009-10-26 11:22:47 +00002201
Bruce Allanf523d212009-10-29 13:45:45 +00002202 /* Configure the LCD with the extended configuration region in NVM */
2203 ret_val = e1000_sw_lcd_config_ich8lan(hw);
2204 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00002205 return ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002206
Bruce Allanf523d212009-10-29 13:45:45 +00002207 /* Configure the LCD with the OEM bits in NVM */
Bruce Allane98cac42010-05-10 15:02:32 +00002208 ret_val = e1000_oem_bits_config_ich8lan(hw, true);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002209
Bruce Allan1effb452011-02-25 06:58:03 +00002210 if (hw->mac.type == e1000_pch2lan) {
2211 /* Ungate automatic PHY configuration on non-managed 82579 */
2212 if (!(er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) {
Bruce Allan1bba4382011-03-19 00:27:20 +00002213 usleep_range(10000, 20000);
Bruce Allan1effb452011-02-25 06:58:03 +00002214 e1000_gate_hw_phy_config_ich8lan(hw, false);
2215 }
2216
2217 /* Set EEE LPI Update Timer to 200usec */
2218 ret_val = hw->phy.ops.acquire(hw);
2219 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00002220 return ret_val;
Bruce Allan4ddc48a2012-12-05 06:25:58 +00002221 ret_val = e1000_write_emi_reg_locked(hw,
2222 I82579_LPI_UPDATE_TIMER,
2223 0x1387);
Bruce Allan1effb452011-02-25 06:58:03 +00002224 hw->phy.ops.release(hw);
Bruce Allan605c82b2010-09-22 17:17:01 +00002225 }
2226
Bruce Allane98cac42010-05-10 15:02:32 +00002227 return ret_val;
2228}
2229
2230/**
2231 * e1000_phy_hw_reset_ich8lan - Performs a PHY reset
2232 * @hw: pointer to the HW structure
2233 *
2234 * Resets the PHY
2235 * This is a function pointer entry point called by drivers
2236 * or other shared routines.
2237 **/
2238static s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw)
2239{
2240 s32 ret_val = 0;
2241
Bruce Allan605c82b2010-09-22 17:17:01 +00002242 /* Gate automatic PHY configuration by hardware on non-managed 82579 */
2243 if ((hw->mac.type == e1000_pch2lan) &&
2244 !(er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
2245 e1000_gate_hw_phy_config_ich8lan(hw, true);
2246
Bruce Allane98cac42010-05-10 15:02:32 +00002247 ret_val = e1000e_phy_hw_reset_generic(hw);
2248 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00002249 return ret_val;
Bruce Allane98cac42010-05-10 15:02:32 +00002250
Bruce Allan5015e532012-02-08 02:55:56 +00002251 return e1000_post_phy_reset_ich8lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002252}
2253
2254/**
Bruce Allanfa2ce132009-10-26 11:23:25 +00002255 * e1000_set_lplu_state_pchlan - Set Low Power Link Up state
2256 * @hw: pointer to the HW structure
2257 * @active: true to enable LPLU, false to disable
2258 *
2259 * Sets the LPLU state according to the active flag. For PCH, if OEM write
2260 * bit are disabled in the NVM, writing the LPLU bits in the MAC will not set
2261 * the phy speed. This function will manually set the LPLU bit and restart
2262 * auto-neg as hw would do. D3 and D0 LPLU will call the same function
2263 * since it configures the same bit.
2264 **/
2265static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active)
2266{
2267 s32 ret_val = 0;
2268 u16 oem_reg;
2269
2270 ret_val = e1e_rphy(hw, HV_OEM_BITS, &oem_reg);
2271 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00002272 return ret_val;
Bruce Allanfa2ce132009-10-26 11:23:25 +00002273
2274 if (active)
2275 oem_reg |= HV_OEM_BITS_LPLU;
2276 else
2277 oem_reg &= ~HV_OEM_BITS_LPLU;
2278
Bruce Allan44abd5c2012-02-22 09:02:37 +00002279 if (!hw->phy.ops.check_reset_block(hw))
Bruce Allan464c85e2011-12-16 00:46:49 +00002280 oem_reg |= HV_OEM_BITS_RESTART_AN;
2281
Bruce Allan5015e532012-02-08 02:55:56 +00002282 return e1e_wphy(hw, HV_OEM_BITS, oem_reg);
Bruce Allanfa2ce132009-10-26 11:23:25 +00002283}
2284
2285/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07002286 * e1000_set_d0_lplu_state_ich8lan - Set Low Power Linkup D0 state
2287 * @hw: pointer to the HW structure
Bruce Allan564ea9b2009-11-20 23:26:44 +00002288 * @active: true to enable LPLU, false to disable
Auke Kokbc7f75f2007-09-17 12:30:59 -07002289 *
2290 * Sets the LPLU D0 state according to the active flag. When
2291 * activating LPLU this function also disables smart speed
2292 * and vice versa. LPLU will not be activated unless the
2293 * device autonegotiation advertisement meets standards of
2294 * either 10 or 10/100 or 10/100/1000 at all duplexes.
2295 * This is a function pointer entry point only called by
2296 * PHY setup routines.
2297 **/
2298static s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
2299{
2300 struct e1000_phy_info *phy = &hw->phy;
2301 u32 phy_ctrl;
2302 s32 ret_val = 0;
2303 u16 data;
2304
Bruce Allan97ac8ca2008-04-29 09:16:05 -07002305 if (phy->type == e1000_phy_ife)
Bruce Allan82607252012-02-08 02:55:09 +00002306 return 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002307
2308 phy_ctrl = er32(PHY_CTRL);
2309
2310 if (active) {
2311 phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU;
2312 ew32(PHY_CTRL, phy_ctrl);
2313
Bruce Allan60f12922009-07-01 13:28:14 +00002314 if (phy->type != e1000_phy_igp_3)
2315 return 0;
2316
Bruce Allane921eb12012-11-28 09:28:37 +00002317 /* Call gig speed drop workaround on LPLU before accessing
Bruce Allanad680762008-03-28 09:15:03 -07002318 * any PHY registers
2319 */
Bruce Allan60f12922009-07-01 13:28:14 +00002320 if (hw->mac.type == e1000_ich8lan)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002321 e1000e_gig_downshift_workaround_ich8lan(hw);
2322
2323 /* When LPLU is enabled, we should disable SmartSpeed */
2324 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data);
2325 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
2326 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);
2327 if (ret_val)
2328 return ret_val;
2329 } else {
2330 phy_ctrl &= ~E1000_PHY_CTRL_D0A_LPLU;
2331 ew32(PHY_CTRL, phy_ctrl);
2332
Bruce Allan60f12922009-07-01 13:28:14 +00002333 if (phy->type != e1000_phy_igp_3)
2334 return 0;
2335
Bruce Allane921eb12012-11-28 09:28:37 +00002336 /* LPLU and SmartSpeed are mutually exclusive. LPLU is used
Auke Kokbc7f75f2007-09-17 12:30:59 -07002337 * during Dx states where the power conservation is most
2338 * important. During driver activity we should enable
Bruce Allanad680762008-03-28 09:15:03 -07002339 * SmartSpeed, so performance is maintained.
2340 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002341 if (phy->smart_speed == e1000_smart_speed_on) {
2342 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
Bruce Allanad680762008-03-28 09:15:03 -07002343 &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002344 if (ret_val)
2345 return ret_val;
2346
2347 data |= IGP01E1000_PSCFR_SMART_SPEED;
2348 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
Bruce Allanad680762008-03-28 09:15:03 -07002349 data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002350 if (ret_val)
2351 return ret_val;
2352 } else if (phy->smart_speed == e1000_smart_speed_off) {
2353 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
Bruce Allanad680762008-03-28 09:15:03 -07002354 &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002355 if (ret_val)
2356 return ret_val;
2357
2358 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
2359 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
Bruce Allanad680762008-03-28 09:15:03 -07002360 data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002361 if (ret_val)
2362 return ret_val;
2363 }
2364 }
2365
2366 return 0;
2367}
2368
2369/**
2370 * e1000_set_d3_lplu_state_ich8lan - Set Low Power Linkup D3 state
2371 * @hw: pointer to the HW structure
Bruce Allan564ea9b2009-11-20 23:26:44 +00002372 * @active: true to enable LPLU, false to disable
Auke Kokbc7f75f2007-09-17 12:30:59 -07002373 *
2374 * Sets the LPLU D3 state according to the active flag. When
2375 * activating LPLU this function also disables smart speed
2376 * and vice versa. LPLU will not be activated unless the
2377 * device autonegotiation advertisement meets standards of
2378 * either 10 or 10/100 or 10/100/1000 at all duplexes.
2379 * This is a function pointer entry point only called by
2380 * PHY setup routines.
2381 **/
2382static s32 e1000_set_d3_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
2383{
2384 struct e1000_phy_info *phy = &hw->phy;
2385 u32 phy_ctrl;
Bruce Alland7eb3382012-02-08 02:55:14 +00002386 s32 ret_val = 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002387 u16 data;
2388
2389 phy_ctrl = er32(PHY_CTRL);
2390
2391 if (!active) {
2392 phy_ctrl &= ~E1000_PHY_CTRL_NOND0A_LPLU;
2393 ew32(PHY_CTRL, phy_ctrl);
Bruce Allan60f12922009-07-01 13:28:14 +00002394
2395 if (phy->type != e1000_phy_igp_3)
2396 return 0;
2397
Bruce Allane921eb12012-11-28 09:28:37 +00002398 /* LPLU and SmartSpeed are mutually exclusive. LPLU is used
Auke Kokbc7f75f2007-09-17 12:30:59 -07002399 * during Dx states where the power conservation is most
2400 * important. During driver activity we should enable
Bruce Allanad680762008-03-28 09:15:03 -07002401 * SmartSpeed, so performance is maintained.
2402 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002403 if (phy->smart_speed == e1000_smart_speed_on) {
Bruce Allanad680762008-03-28 09:15:03 -07002404 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
2405 &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002406 if (ret_val)
2407 return ret_val;
2408
2409 data |= IGP01E1000_PSCFR_SMART_SPEED;
Bruce Allanad680762008-03-28 09:15:03 -07002410 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
2411 data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002412 if (ret_val)
2413 return ret_val;
2414 } else if (phy->smart_speed == e1000_smart_speed_off) {
Bruce Allanad680762008-03-28 09:15:03 -07002415 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
2416 &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002417 if (ret_val)
2418 return ret_val;
2419
2420 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
Bruce Allanad680762008-03-28 09:15:03 -07002421 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
2422 data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002423 if (ret_val)
2424 return ret_val;
2425 }
2426 } else if ((phy->autoneg_advertised == E1000_ALL_SPEED_DUPLEX) ||
2427 (phy->autoneg_advertised == E1000_ALL_NOT_GIG) ||
2428 (phy->autoneg_advertised == E1000_ALL_10_SPEED)) {
2429 phy_ctrl |= E1000_PHY_CTRL_NOND0A_LPLU;
2430 ew32(PHY_CTRL, phy_ctrl);
2431
Bruce Allan60f12922009-07-01 13:28:14 +00002432 if (phy->type != e1000_phy_igp_3)
2433 return 0;
2434
Bruce Allane921eb12012-11-28 09:28:37 +00002435 /* Call gig speed drop workaround on LPLU before accessing
Bruce Allanad680762008-03-28 09:15:03 -07002436 * any PHY registers
2437 */
Bruce Allan60f12922009-07-01 13:28:14 +00002438 if (hw->mac.type == e1000_ich8lan)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002439 e1000e_gig_downshift_workaround_ich8lan(hw);
2440
2441 /* When LPLU is enabled, we should disable SmartSpeed */
Bruce Allanad680762008-03-28 09:15:03 -07002442 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002443 if (ret_val)
2444 return ret_val;
2445
2446 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
Bruce Allanad680762008-03-28 09:15:03 -07002447 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002448 }
2449
Bruce Alland7eb3382012-02-08 02:55:14 +00002450 return ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002451}
2452
2453/**
Bruce Allanf4187b52008-08-26 18:36:50 -07002454 * e1000_valid_nvm_bank_detect_ich8lan - finds out the valid bank 0 or 1
2455 * @hw: pointer to the HW structure
2456 * @bank: pointer to the variable that returns the active bank
2457 *
2458 * Reads signature byte from the NVM using the flash access registers.
Bruce Allane2434552008-11-21 17:02:41 -08002459 * Word 0x13 bits 15:14 = 10b indicate a valid signature for that bank.
Bruce Allanf4187b52008-08-26 18:36:50 -07002460 **/
2461static s32 e1000_valid_nvm_bank_detect_ich8lan(struct e1000_hw *hw, u32 *bank)
2462{
Bruce Allane2434552008-11-21 17:02:41 -08002463 u32 eecd;
Bruce Allanf4187b52008-08-26 18:36:50 -07002464 struct e1000_nvm_info *nvm = &hw->nvm;
Bruce Allanf4187b52008-08-26 18:36:50 -07002465 u32 bank1_offset = nvm->flash_bank_size * sizeof(u16);
2466 u32 act_offset = E1000_ICH_NVM_SIG_WORD * 2 + 1;
Bruce Allane2434552008-11-21 17:02:41 -08002467 u8 sig_byte = 0;
Bruce Allanf71dde62012-02-08 02:55:35 +00002468 s32 ret_val;
Bruce Allanf4187b52008-08-26 18:36:50 -07002469
Bruce Allane2434552008-11-21 17:02:41 -08002470 switch (hw->mac.type) {
2471 case e1000_ich8lan:
2472 case e1000_ich9lan:
2473 eecd = er32(EECD);
2474 if ((eecd & E1000_EECD_SEC1VAL_VALID_MASK) ==
2475 E1000_EECD_SEC1VAL_VALID_MASK) {
2476 if (eecd & E1000_EECD_SEC1VAL)
Bruce Allanf4187b52008-08-26 18:36:50 -07002477 *bank = 1;
Bruce Allane2434552008-11-21 17:02:41 -08002478 else
2479 *bank = 0;
2480
2481 return 0;
Bruce Allanf4187b52008-08-26 18:36:50 -07002482 }
Bruce Allan434f1392011-12-16 00:46:54 +00002483 e_dbg("Unable to determine valid NVM bank via EEC - reading flash signature\n");
Bruce Allane2434552008-11-21 17:02:41 -08002484 /* fall-thru */
2485 default:
2486 /* set bank to 0 in case flash read fails */
2487 *bank = 0;
2488
2489 /* Check bank 0 */
2490 ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset,
2491 &sig_byte);
2492 if (ret_val)
2493 return ret_val;
2494 if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
2495 E1000_ICH_NVM_SIG_VALUE) {
2496 *bank = 0;
2497 return 0;
2498 }
2499
2500 /* Check bank 1 */
2501 ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset +
2502 bank1_offset,
2503 &sig_byte);
2504 if (ret_val)
2505 return ret_val;
2506 if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
2507 E1000_ICH_NVM_SIG_VALUE) {
2508 *bank = 1;
2509 return 0;
2510 }
2511
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002512 e_dbg("ERROR: No valid NVM bank present\n");
Bruce Allane2434552008-11-21 17:02:41 -08002513 return -E1000_ERR_NVM;
Bruce Allanf4187b52008-08-26 18:36:50 -07002514 }
Bruce Allanf4187b52008-08-26 18:36:50 -07002515}
2516
2517/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07002518 * e1000_read_nvm_ich8lan - Read word(s) from the NVM
2519 * @hw: pointer to the HW structure
2520 * @offset: The offset (in bytes) of the word(s) to read.
2521 * @words: Size of data to read in words
2522 * @data: Pointer to the word(s) to read at offset.
2523 *
2524 * Reads a word(s) from the NVM using the flash access registers.
2525 **/
2526static s32 e1000_read_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
2527 u16 *data)
2528{
2529 struct e1000_nvm_info *nvm = &hw->nvm;
2530 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
2531 u32 act_offset;
Bruce Allan148675a2009-08-07 07:41:56 +00002532 s32 ret_val = 0;
Bruce Allanf4187b52008-08-26 18:36:50 -07002533 u32 bank = 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002534 u16 i, word;
2535
2536 if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
2537 (words == 0)) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002538 e_dbg("nvm parameter(s) out of bounds\n");
Bruce Allanca15df52009-10-26 11:23:43 +00002539 ret_val = -E1000_ERR_NVM;
2540 goto out;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002541 }
2542
Bruce Allan94d81862009-11-20 23:25:26 +00002543 nvm->ops.acquire(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002544
Bruce Allanf4187b52008-08-26 18:36:50 -07002545 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
Bruce Allan148675a2009-08-07 07:41:56 +00002546 if (ret_val) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002547 e_dbg("Could not detect valid bank, assuming bank 0\n");
Bruce Allan148675a2009-08-07 07:41:56 +00002548 bank = 0;
2549 }
Bruce Allanf4187b52008-08-26 18:36:50 -07002550
2551 act_offset = (bank) ? nvm->flash_bank_size : 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002552 act_offset += offset;
2553
Bruce Allan148675a2009-08-07 07:41:56 +00002554 ret_val = 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002555 for (i = 0; i < words; i++) {
Bruce Allanb9e06f72011-07-22 06:21:41 +00002556 if (dev_spec->shadow_ram[offset+i].modified) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07002557 data[i] = dev_spec->shadow_ram[offset+i].value;
2558 } else {
2559 ret_val = e1000_read_flash_word_ich8lan(hw,
2560 act_offset + i,
2561 &word);
2562 if (ret_val)
2563 break;
2564 data[i] = word;
2565 }
2566 }
2567
Bruce Allan94d81862009-11-20 23:25:26 +00002568 nvm->ops.release(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002569
Bruce Allane2434552008-11-21 17:02:41 -08002570out:
2571 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002572 e_dbg("NVM read error: %d\n", ret_val);
Bruce Allane2434552008-11-21 17:02:41 -08002573
Auke Kokbc7f75f2007-09-17 12:30:59 -07002574 return ret_val;
2575}
2576
2577/**
2578 * e1000_flash_cycle_init_ich8lan - Initialize flash
2579 * @hw: pointer to the HW structure
2580 *
2581 * This function does initial flash setup so that a new read/write/erase cycle
2582 * can be started.
2583 **/
2584static s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw)
2585{
2586 union ich8_hws_flash_status hsfsts;
2587 s32 ret_val = -E1000_ERR_NVM;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002588
2589 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
2590
2591 /* Check if the flash descriptor is valid */
Bruce Allan04499ec2012-04-13 00:08:31 +00002592 if (!hsfsts.hsf_status.fldesvalid) {
Bruce Allan434f1392011-12-16 00:46:54 +00002593 e_dbg("Flash descriptor invalid. SW Sequencing must be used.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07002594 return -E1000_ERR_NVM;
2595 }
2596
2597 /* Clear FCERR and DAEL in hw status by writing 1 */
2598 hsfsts.hsf_status.flcerr = 1;
2599 hsfsts.hsf_status.dael = 1;
2600
2601 ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
2602
Bruce Allane921eb12012-11-28 09:28:37 +00002603 /* Either we should have a hardware SPI cycle in progress
Auke Kokbc7f75f2007-09-17 12:30:59 -07002604 * bit to check against, in order to start a new cycle or
2605 * FDONE bit should be changed in the hardware so that it
Auke Kok489815c2008-02-21 15:11:07 -08002606 * is 1 after hardware reset, which can then be used as an
Auke Kokbc7f75f2007-09-17 12:30:59 -07002607 * indication whether a cycle is in progress or has been
2608 * completed.
2609 */
2610
Bruce Allan04499ec2012-04-13 00:08:31 +00002611 if (!hsfsts.hsf_status.flcinprog) {
Bruce Allane921eb12012-11-28 09:28:37 +00002612 /* There is no cycle running at present,
Bruce Allan5ff5b662009-12-01 15:51:11 +00002613 * so we can start a cycle.
Bruce Allanad680762008-03-28 09:15:03 -07002614 * Begin by setting Flash Cycle Done.
2615 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002616 hsfsts.hsf_status.flcdone = 1;
2617 ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
2618 ret_val = 0;
2619 } else {
Bruce Allanf71dde62012-02-08 02:55:35 +00002620 s32 i;
Bruce Allan90da0662011-01-06 07:02:53 +00002621
Bruce Allane921eb12012-11-28 09:28:37 +00002622 /* Otherwise poll for sometime so the current
Bruce Allanad680762008-03-28 09:15:03 -07002623 * cycle has a chance to end before giving up.
2624 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002625 for (i = 0; i < ICH_FLASH_READ_COMMAND_TIMEOUT; i++) {
Bruce Allanc8243ee2011-12-17 08:32:57 +00002626 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
Bruce Allan04499ec2012-04-13 00:08:31 +00002627 if (!hsfsts.hsf_status.flcinprog) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07002628 ret_val = 0;
2629 break;
2630 }
2631 udelay(1);
2632 }
Bruce Allan9e2d7652012-01-31 06:37:27 +00002633 if (!ret_val) {
Bruce Allane921eb12012-11-28 09:28:37 +00002634 /* Successful in waiting for previous cycle to timeout,
Bruce Allanad680762008-03-28 09:15:03 -07002635 * now set the Flash Cycle Done.
2636 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002637 hsfsts.hsf_status.flcdone = 1;
2638 ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
2639 } else {
Joe Perches2c73e1f2010-03-26 20:16:59 +00002640 e_dbg("Flash controller busy, cannot get access\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07002641 }
2642 }
2643
2644 return ret_val;
2645}
2646
2647/**
2648 * e1000_flash_cycle_ich8lan - Starts flash cycle (read/write/erase)
2649 * @hw: pointer to the HW structure
2650 * @timeout: maximum time to wait for completion
2651 *
2652 * This function starts a flash cycle and waits for its completion.
2653 **/
2654static s32 e1000_flash_cycle_ich8lan(struct e1000_hw *hw, u32 timeout)
2655{
2656 union ich8_hws_flash_ctrl hsflctl;
2657 union ich8_hws_flash_status hsfsts;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002658 u32 i = 0;
2659
2660 /* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */
2661 hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
2662 hsflctl.hsf_ctrl.flcgo = 1;
2663 ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
2664
2665 /* wait till FDONE bit is set to 1 */
2666 do {
2667 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
Bruce Allan04499ec2012-04-13 00:08:31 +00002668 if (hsfsts.hsf_status.flcdone)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002669 break;
2670 udelay(1);
2671 } while (i++ < timeout);
2672
Bruce Allan04499ec2012-04-13 00:08:31 +00002673 if (hsfsts.hsf_status.flcdone && !hsfsts.hsf_status.flcerr)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002674 return 0;
2675
Bruce Allan55920b52012-02-08 02:55:25 +00002676 return -E1000_ERR_NVM;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002677}
2678
2679/**
2680 * e1000_read_flash_word_ich8lan - Read word from flash
2681 * @hw: pointer to the HW structure
2682 * @offset: offset to data location
2683 * @data: pointer to the location for storing the data
2684 *
2685 * Reads the flash word at offset into data. Offset is converted
2686 * to bytes before read.
2687 **/
2688static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset,
2689 u16 *data)
2690{
2691 /* Must convert offset into bytes. */
2692 offset <<= 1;
2693
2694 return e1000_read_flash_data_ich8lan(hw, offset, 2, data);
2695}
2696
2697/**
Bruce Allanf4187b52008-08-26 18:36:50 -07002698 * e1000_read_flash_byte_ich8lan - Read byte from flash
2699 * @hw: pointer to the HW structure
2700 * @offset: The offset of the byte to read.
2701 * @data: Pointer to a byte to store the value read.
2702 *
2703 * Reads a single byte from the NVM using the flash access registers.
2704 **/
2705static s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
2706 u8 *data)
2707{
2708 s32 ret_val;
2709 u16 word = 0;
2710
2711 ret_val = e1000_read_flash_data_ich8lan(hw, offset, 1, &word);
2712 if (ret_val)
2713 return ret_val;
2714
2715 *data = (u8)word;
2716
2717 return 0;
2718}
2719
2720/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07002721 * e1000_read_flash_data_ich8lan - Read byte or word from NVM
2722 * @hw: pointer to the HW structure
2723 * @offset: The offset (in bytes) of the byte or word to read.
2724 * @size: Size of data to read, 1=byte 2=word
2725 * @data: Pointer to the word to store the value read.
2726 *
2727 * Reads a byte or word from the NVM using the flash access registers.
2728 **/
2729static s32 e1000_read_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 = -E1000_ERR_NVM;
2737 u8 count = 0;
2738
2739 if (size < 1 || size > 2 || offset > ICH_FLASH_LINEAR_ADDR_MASK)
2740 return -E1000_ERR_NVM;
2741
2742 flash_linear_addr = (ICH_FLASH_LINEAR_ADDR_MASK & offset) +
2743 hw->nvm.flash_base_addr;
2744
2745 do {
2746 udelay(1);
2747 /* Steps */
2748 ret_val = e1000_flash_cycle_init_ich8lan(hw);
Bruce Allan9e2d7652012-01-31 06:37:27 +00002749 if (ret_val)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002750 break;
2751
2752 hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
2753 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
2754 hsflctl.hsf_ctrl.fldbcount = size - 1;
2755 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_READ;
2756 ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
2757
2758 ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
2759
2760 ret_val = e1000_flash_cycle_ich8lan(hw,
2761 ICH_FLASH_READ_COMMAND_TIMEOUT);
2762
Bruce Allane921eb12012-11-28 09:28:37 +00002763 /* Check if FCERR is set to 1, if set to 1, clear it
Auke Kokbc7f75f2007-09-17 12:30:59 -07002764 * and try the whole sequence a few more times, else
2765 * read in (shift in) the Flash Data0, the order is
Bruce Allanad680762008-03-28 09:15:03 -07002766 * least significant byte first msb to lsb
2767 */
Bruce Allan9e2d7652012-01-31 06:37:27 +00002768 if (!ret_val) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07002769 flash_data = er32flash(ICH_FLASH_FDATA0);
Bruce Allanb1cdfea2010-12-11 05:53:47 +00002770 if (size == 1)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002771 *data = (u8)(flash_data & 0x000000FF);
Bruce Allanb1cdfea2010-12-11 05:53:47 +00002772 else if (size == 2)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002773 *data = (u16)(flash_data & 0x0000FFFF);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002774 break;
2775 } else {
Bruce Allane921eb12012-11-28 09:28:37 +00002776 /* If we've gotten here, then things are probably
Auke Kokbc7f75f2007-09-17 12:30:59 -07002777 * completely hosed, but if the error condition is
2778 * detected, it won't hurt to give it another try...
2779 * ICH_FLASH_CYCLE_REPEAT_COUNT times.
2780 */
2781 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
Bruce Allan04499ec2012-04-13 00:08:31 +00002782 if (hsfsts.hsf_status.flcerr) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07002783 /* Repeat for some time before giving up. */
2784 continue;
Bruce Allan04499ec2012-04-13 00:08:31 +00002785 } else if (!hsfsts.hsf_status.flcdone) {
Bruce Allan434f1392011-12-16 00:46:54 +00002786 e_dbg("Timeout error - flash cycle did not complete.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07002787 break;
2788 }
2789 }
2790 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
2791
2792 return ret_val;
2793}
2794
2795/**
2796 * e1000_write_nvm_ich8lan - Write word(s) to the NVM
2797 * @hw: pointer to the HW structure
2798 * @offset: The offset (in bytes) of the word(s) to write.
2799 * @words: Size of data to write in words
2800 * @data: Pointer to the word(s) to write at offset.
2801 *
2802 * Writes a byte or word to the NVM using the flash access registers.
2803 **/
2804static s32 e1000_write_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
2805 u16 *data)
2806{
2807 struct e1000_nvm_info *nvm = &hw->nvm;
2808 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002809 u16 i;
2810
2811 if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
2812 (words == 0)) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002813 e_dbg("nvm parameter(s) out of bounds\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07002814 return -E1000_ERR_NVM;
2815 }
2816
Bruce Allan94d81862009-11-20 23:25:26 +00002817 nvm->ops.acquire(hw);
Bruce Allanca15df52009-10-26 11:23:43 +00002818
Auke Kokbc7f75f2007-09-17 12:30:59 -07002819 for (i = 0; i < words; i++) {
Bruce Allan564ea9b2009-11-20 23:26:44 +00002820 dev_spec->shadow_ram[offset+i].modified = true;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002821 dev_spec->shadow_ram[offset+i].value = data[i];
2822 }
2823
Bruce Allan94d81862009-11-20 23:25:26 +00002824 nvm->ops.release(hw);
Bruce Allanca15df52009-10-26 11:23:43 +00002825
Auke Kokbc7f75f2007-09-17 12:30:59 -07002826 return 0;
2827}
2828
2829/**
2830 * e1000_update_nvm_checksum_ich8lan - Update the checksum for NVM
2831 * @hw: pointer to the HW structure
2832 *
2833 * The NVM checksum is updated by calling the generic update_nvm_checksum,
2834 * which writes the checksum to the shadow ram. The changes in the shadow
2835 * ram are then committed to the EEPROM by processing each bank at a time
2836 * checking for the modified bit and writing only the pending changes.
Auke Kok489815c2008-02-21 15:11:07 -08002837 * After a successful commit, the shadow ram is cleared and is ready for
Auke Kokbc7f75f2007-09-17 12:30:59 -07002838 * future writes.
2839 **/
2840static s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw)
2841{
2842 struct e1000_nvm_info *nvm = &hw->nvm;
2843 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
Bruce Allanf4187b52008-08-26 18:36:50 -07002844 u32 i, act_offset, new_bank_offset, old_bank_offset, bank;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002845 s32 ret_val;
2846 u16 data;
2847
2848 ret_val = e1000e_update_nvm_checksum_generic(hw);
2849 if (ret_val)
Bruce Allane2434552008-11-21 17:02:41 -08002850 goto out;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002851
2852 if (nvm->type != e1000_nvm_flash_sw)
Bruce Allane2434552008-11-21 17:02:41 -08002853 goto out;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002854
Bruce Allan94d81862009-11-20 23:25:26 +00002855 nvm->ops.acquire(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002856
Bruce Allane921eb12012-11-28 09:28:37 +00002857 /* We're writing to the opposite bank so if we're on bank 1,
Auke Kokbc7f75f2007-09-17 12:30:59 -07002858 * write to bank 0 etc. We also need to erase the segment that
Bruce Allanad680762008-03-28 09:15:03 -07002859 * is going to be written
2860 */
Bruce Allanf4187b52008-08-26 18:36:50 -07002861 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
Bruce Allane2434552008-11-21 17:02:41 -08002862 if (ret_val) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002863 e_dbg("Could not detect valid bank, assuming bank 0\n");
Bruce Allan148675a2009-08-07 07:41:56 +00002864 bank = 0;
Bruce Allane2434552008-11-21 17:02:41 -08002865 }
Bruce Allanf4187b52008-08-26 18:36:50 -07002866
2867 if (bank == 0) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07002868 new_bank_offset = nvm->flash_bank_size;
2869 old_bank_offset = 0;
Bruce Allane2434552008-11-21 17:02:41 -08002870 ret_val = e1000_erase_flash_bank_ich8lan(hw, 1);
Bruce Allan9c5e2092010-05-10 15:00:31 +00002871 if (ret_val)
2872 goto release;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002873 } else {
2874 old_bank_offset = nvm->flash_bank_size;
2875 new_bank_offset = 0;
Bruce Allane2434552008-11-21 17:02:41 -08002876 ret_val = e1000_erase_flash_bank_ich8lan(hw, 0);
Bruce Allan9c5e2092010-05-10 15:00:31 +00002877 if (ret_val)
2878 goto release;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002879 }
2880
2881 for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i++) {
Bruce Allane921eb12012-11-28 09:28:37 +00002882 /* Determine whether to write the value stored
Auke Kokbc7f75f2007-09-17 12:30:59 -07002883 * in the other NVM bank or a modified value stored
Bruce Allanad680762008-03-28 09:15:03 -07002884 * in the shadow RAM
2885 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002886 if (dev_spec->shadow_ram[i].modified) {
2887 data = dev_spec->shadow_ram[i].value;
2888 } else {
Bruce Allane2434552008-11-21 17:02:41 -08002889 ret_val = e1000_read_flash_word_ich8lan(hw, i +
2890 old_bank_offset,
2891 &data);
2892 if (ret_val)
2893 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002894 }
2895
Bruce Allane921eb12012-11-28 09:28:37 +00002896 /* If the word is 0x13, then make sure the signature bits
Auke Kokbc7f75f2007-09-17 12:30:59 -07002897 * (15:14) are 11b until the commit has completed.
2898 * This will allow us to write 10b which indicates the
2899 * signature is valid. We want to do this after the write
2900 * has completed so that we don't mark the segment valid
Bruce Allanad680762008-03-28 09:15:03 -07002901 * while the write is still in progress
2902 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002903 if (i == E1000_ICH_NVM_SIG_WORD)
2904 data |= E1000_ICH_NVM_SIG_MASK;
2905
2906 /* Convert offset to bytes. */
2907 act_offset = (i + new_bank_offset) << 1;
2908
2909 udelay(100);
2910 /* Write the bytes to the new bank. */
2911 ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
2912 act_offset,
2913 (u8)data);
2914 if (ret_val)
2915 break;
2916
2917 udelay(100);
2918 ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
2919 act_offset + 1,
2920 (u8)(data >> 8));
2921 if (ret_val)
2922 break;
2923 }
2924
Bruce Allane921eb12012-11-28 09:28:37 +00002925 /* Don't bother writing the segment valid bits if sector
Bruce Allanad680762008-03-28 09:15:03 -07002926 * programming failed.
2927 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002928 if (ret_val) {
Bruce Allan4a770352008-10-01 17:18:35 -07002929 /* Possibly read-only, see e1000e_write_protect_nvm_ich8lan() */
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002930 e_dbg("Flash commit failed.\n");
Bruce Allan9c5e2092010-05-10 15:00:31 +00002931 goto release;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002932 }
2933
Bruce Allane921eb12012-11-28 09:28:37 +00002934 /* Finally validate the new segment by setting bit 15:14
Auke Kokbc7f75f2007-09-17 12:30:59 -07002935 * to 10b in word 0x13 , this can be done without an
2936 * erase as well since these bits are 11 to start with
Bruce Allanad680762008-03-28 09:15:03 -07002937 * and we need to change bit 14 to 0b
2938 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002939 act_offset = new_bank_offset + E1000_ICH_NVM_SIG_WORD;
Bruce Allane2434552008-11-21 17:02:41 -08002940 ret_val = e1000_read_flash_word_ich8lan(hw, act_offset, &data);
Bruce Allan9c5e2092010-05-10 15:00:31 +00002941 if (ret_val)
2942 goto release;
2943
Auke Kokbc7f75f2007-09-17 12:30:59 -07002944 data &= 0xBFFF;
2945 ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
2946 act_offset * 2 + 1,
2947 (u8)(data >> 8));
Bruce Allan9c5e2092010-05-10 15:00:31 +00002948 if (ret_val)
2949 goto release;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002950
Bruce Allane921eb12012-11-28 09:28:37 +00002951 /* And invalidate the previously valid segment by setting
Auke Kokbc7f75f2007-09-17 12:30:59 -07002952 * its signature word (0x13) high_byte to 0b. This can be
2953 * done without an erase because flash erase sets all bits
Bruce Allanad680762008-03-28 09:15:03 -07002954 * to 1's. We can write 1's to 0's without an erase
2955 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002956 act_offset = (old_bank_offset + E1000_ICH_NVM_SIG_WORD) * 2 + 1;
2957 ret_val = e1000_retry_write_flash_byte_ich8lan(hw, act_offset, 0);
Bruce Allan9c5e2092010-05-10 15:00:31 +00002958 if (ret_val)
2959 goto release;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002960
2961 /* Great! Everything worked, we can now clear the cached entries. */
2962 for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i++) {
Bruce Allan564ea9b2009-11-20 23:26:44 +00002963 dev_spec->shadow_ram[i].modified = false;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002964 dev_spec->shadow_ram[i].value = 0xFFFF;
2965 }
2966
Bruce Allan9c5e2092010-05-10 15:00:31 +00002967release:
Bruce Allan94d81862009-11-20 23:25:26 +00002968 nvm->ops.release(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002969
Bruce Allane921eb12012-11-28 09:28:37 +00002970 /* Reload the EEPROM, or else modifications will not appear
Auke Kokbc7f75f2007-09-17 12:30:59 -07002971 * until after the next adapter reset.
2972 */
Bruce Allan9c5e2092010-05-10 15:00:31 +00002973 if (!ret_val) {
Bruce Allane85e3632012-02-22 09:03:14 +00002974 nvm->ops.reload(hw);
Bruce Allan1bba4382011-03-19 00:27:20 +00002975 usleep_range(10000, 20000);
Bruce Allan9c5e2092010-05-10 15:00:31 +00002976 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07002977
Bruce Allane2434552008-11-21 17:02:41 -08002978out:
2979 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002980 e_dbg("NVM update error: %d\n", ret_val);
Bruce Allane2434552008-11-21 17:02:41 -08002981
Auke Kokbc7f75f2007-09-17 12:30:59 -07002982 return ret_val;
2983}
2984
2985/**
2986 * e1000_validate_nvm_checksum_ich8lan - Validate EEPROM checksum
2987 * @hw: pointer to the HW structure
2988 *
2989 * Check to see if checksum needs to be fixed by reading bit 6 in word 0x19.
2990 * If the bit is 0, that the EEPROM had been modified, but the checksum was not
2991 * calculated, in which case we need to calculate the checksum and set bit 6.
2992 **/
2993static s32 e1000_validate_nvm_checksum_ich8lan(struct e1000_hw *hw)
2994{
2995 s32 ret_val;
2996 u16 data;
Bruce Allan1cc7a3a2013-01-09 08:15:42 +00002997 u16 word;
2998 u16 valid_csum_mask;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002999
Bruce Allan1cc7a3a2013-01-09 08:15:42 +00003000 /* Read NVM and check Invalid Image CSUM bit. If this bit is 0,
3001 * the checksum needs to be fixed. This bit is an indication that
3002 * the NVM was prepared by OEM software and did not calculate
3003 * the checksum...a likely scenario.
Auke Kokbc7f75f2007-09-17 12:30:59 -07003004 */
Bruce Allan1cc7a3a2013-01-09 08:15:42 +00003005 switch (hw->mac.type) {
3006 case e1000_pch_lpt:
3007 word = NVM_COMPAT;
3008 valid_csum_mask = NVM_COMPAT_VALID_CSUM;
3009 break;
3010 default:
3011 word = NVM_FUTURE_INIT_WORD1;
3012 valid_csum_mask = NVM_FUTURE_INIT_WORD1_VALID_CSUM;
3013 break;
3014 }
3015
3016 ret_val = e1000_read_nvm(hw, word, 1, &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003017 if (ret_val)
3018 return ret_val;
3019
Bruce Allan1cc7a3a2013-01-09 08:15:42 +00003020 if (!(data & valid_csum_mask)) {
3021 data |= valid_csum_mask;
3022 ret_val = e1000_write_nvm(hw, word, 1, &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003023 if (ret_val)
3024 return ret_val;
3025 ret_val = e1000e_update_nvm_checksum(hw);
3026 if (ret_val)
3027 return ret_val;
3028 }
3029
3030 return e1000e_validate_nvm_checksum_generic(hw);
3031}
3032
3033/**
Bruce Allan4a770352008-10-01 17:18:35 -07003034 * e1000e_write_protect_nvm_ich8lan - Make the NVM read-only
3035 * @hw: pointer to the HW structure
3036 *
3037 * To prevent malicious write/erase of the NVM, set it to be read-only
3038 * so that the hardware ignores all write/erase cycles of the NVM via
3039 * the flash control registers. The shadow-ram copy of the NVM will
3040 * still be updated, however any updates to this copy will not stick
3041 * across driver reloads.
3042 **/
3043void e1000e_write_protect_nvm_ich8lan(struct e1000_hw *hw)
3044{
Bruce Allanca15df52009-10-26 11:23:43 +00003045 struct e1000_nvm_info *nvm = &hw->nvm;
Bruce Allan4a770352008-10-01 17:18:35 -07003046 union ich8_flash_protected_range pr0;
3047 union ich8_hws_flash_status hsfsts;
3048 u32 gfpreg;
Bruce Allan4a770352008-10-01 17:18:35 -07003049
Bruce Allan94d81862009-11-20 23:25:26 +00003050 nvm->ops.acquire(hw);
Bruce Allan4a770352008-10-01 17:18:35 -07003051
3052 gfpreg = er32flash(ICH_FLASH_GFPREG);
3053
3054 /* Write-protect GbE Sector of NVM */
3055 pr0.regval = er32flash(ICH_FLASH_PR0);
3056 pr0.range.base = gfpreg & FLASH_GFPREG_BASE_MASK;
3057 pr0.range.limit = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK);
3058 pr0.range.wpe = true;
3059 ew32flash(ICH_FLASH_PR0, pr0.regval);
3060
Bruce Allane921eb12012-11-28 09:28:37 +00003061 /* Lock down a subset of GbE Flash Control Registers, e.g.
Bruce Allan4a770352008-10-01 17:18:35 -07003062 * PR0 to prevent the write-protection from being lifted.
3063 * Once FLOCKDN is set, the registers protected by it cannot
3064 * be written until FLOCKDN is cleared by a hardware reset.
3065 */
3066 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
3067 hsfsts.hsf_status.flockdn = true;
3068 ew32flash(ICH_FLASH_HSFSTS, hsfsts.regval);
3069
Bruce Allan94d81862009-11-20 23:25:26 +00003070 nvm->ops.release(hw);
Bruce Allan4a770352008-10-01 17:18:35 -07003071}
3072
3073/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07003074 * e1000_write_flash_data_ich8lan - Writes bytes to the NVM
3075 * @hw: pointer to the HW structure
3076 * @offset: The offset (in bytes) of the byte/word to read.
3077 * @size: Size of data to read, 1=byte 2=word
3078 * @data: The byte(s) to write to the NVM.
3079 *
3080 * Writes one/two bytes to the NVM using the flash access registers.
3081 **/
3082static s32 e1000_write_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
3083 u8 size, u16 data)
3084{
3085 union ich8_hws_flash_status hsfsts;
3086 union ich8_hws_flash_ctrl hsflctl;
3087 u32 flash_linear_addr;
3088 u32 flash_data = 0;
3089 s32 ret_val;
3090 u8 count = 0;
3091
3092 if (size < 1 || size > 2 || data > size * 0xff ||
3093 offset > ICH_FLASH_LINEAR_ADDR_MASK)
3094 return -E1000_ERR_NVM;
3095
3096 flash_linear_addr = (ICH_FLASH_LINEAR_ADDR_MASK & offset) +
3097 hw->nvm.flash_base_addr;
3098
3099 do {
3100 udelay(1);
3101 /* Steps */
3102 ret_val = e1000_flash_cycle_init_ich8lan(hw);
3103 if (ret_val)
3104 break;
3105
3106 hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
3107 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
3108 hsflctl.hsf_ctrl.fldbcount = size -1;
3109 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_WRITE;
3110 ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
3111
3112 ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
3113
3114 if (size == 1)
3115 flash_data = (u32)data & 0x00FF;
3116 else
3117 flash_data = (u32)data;
3118
3119 ew32flash(ICH_FLASH_FDATA0, flash_data);
3120
Bruce Allane921eb12012-11-28 09:28:37 +00003121 /* check if FCERR is set to 1 , if set to 1, clear it
Bruce Allanad680762008-03-28 09:15:03 -07003122 * and try the whole sequence a few more times else done
3123 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003124 ret_val = e1000_flash_cycle_ich8lan(hw,
3125 ICH_FLASH_WRITE_COMMAND_TIMEOUT);
3126 if (!ret_val)
3127 break;
3128
Bruce Allane921eb12012-11-28 09:28:37 +00003129 /* If we're here, then things are most likely
Auke Kokbc7f75f2007-09-17 12:30:59 -07003130 * completely hosed, but if the error condition
3131 * is detected, it won't hurt to give it another
3132 * try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
3133 */
3134 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
Bruce Allan04499ec2012-04-13 00:08:31 +00003135 if (hsfsts.hsf_status.flcerr)
Auke Kokbc7f75f2007-09-17 12:30:59 -07003136 /* Repeat for some time before giving up. */
3137 continue;
Bruce Allan04499ec2012-04-13 00:08:31 +00003138 if (!hsfsts.hsf_status.flcdone) {
Bruce Allan434f1392011-12-16 00:46:54 +00003139 e_dbg("Timeout error - flash cycle did not complete.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07003140 break;
3141 }
3142 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
3143
3144 return ret_val;
3145}
3146
3147/**
3148 * e1000_write_flash_byte_ich8lan - Write a single byte to NVM
3149 * @hw: pointer to the HW structure
3150 * @offset: The index of the byte to read.
3151 * @data: The byte to write to the NVM.
3152 *
3153 * Writes a single byte to the NVM using the flash access registers.
3154 **/
3155static s32 e1000_write_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
3156 u8 data)
3157{
3158 u16 word = (u16)data;
3159
3160 return e1000_write_flash_data_ich8lan(hw, offset, 1, word);
3161}
3162
3163/**
3164 * e1000_retry_write_flash_byte_ich8lan - Writes a single byte to NVM
3165 * @hw: pointer to the HW structure
3166 * @offset: The offset of the byte to write.
3167 * @byte: The byte to write to the NVM.
3168 *
3169 * Writes a single byte to the NVM using the flash access registers.
3170 * Goes through a retry algorithm before giving up.
3171 **/
3172static s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw,
3173 u32 offset, u8 byte)
3174{
3175 s32 ret_val;
3176 u16 program_retries;
3177
3178 ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
3179 if (!ret_val)
3180 return ret_val;
3181
3182 for (program_retries = 0; program_retries < 100; program_retries++) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003183 e_dbg("Retrying Byte %2.2X at offset %u\n", byte, offset);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003184 udelay(100);
3185 ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
3186 if (!ret_val)
3187 break;
3188 }
3189 if (program_retries == 100)
3190 return -E1000_ERR_NVM;
3191
3192 return 0;
3193}
3194
3195/**
3196 * e1000_erase_flash_bank_ich8lan - Erase a bank (4k) from NVM
3197 * @hw: pointer to the HW structure
3198 * @bank: 0 for first bank, 1 for second bank, etc.
3199 *
3200 * Erases the bank specified. Each bank is a 4k block. Banks are 0 based.
3201 * bank N is 4096 * N + flash_reg_addr.
3202 **/
3203static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank)
3204{
3205 struct e1000_nvm_info *nvm = &hw->nvm;
3206 union ich8_hws_flash_status hsfsts;
3207 union ich8_hws_flash_ctrl hsflctl;
3208 u32 flash_linear_addr;
3209 /* bank size is in 16bit words - adjust to bytes */
3210 u32 flash_bank_size = nvm->flash_bank_size * 2;
3211 s32 ret_val;
3212 s32 count = 0;
Bruce Allana708dd82009-11-20 23:28:37 +00003213 s32 j, iteration, sector_size;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003214
3215 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
3216
Bruce Allane921eb12012-11-28 09:28:37 +00003217 /* Determine HW Sector size: Read BERASE bits of hw flash status
Bruce Allanad680762008-03-28 09:15:03 -07003218 * register
3219 * 00: The Hw sector is 256 bytes, hence we need to erase 16
Auke Kokbc7f75f2007-09-17 12:30:59 -07003220 * consecutive sectors. The start index for the nth Hw sector
3221 * can be calculated as = bank * 4096 + n * 256
3222 * 01: The Hw sector is 4K bytes, hence we need to erase 1 sector.
3223 * The start index for the nth Hw sector can be calculated
3224 * as = bank * 4096
3225 * 10: The Hw sector is 8K bytes, nth sector = bank * 8192
3226 * (ich9 only, otherwise error condition)
3227 * 11: The Hw sector is 64K bytes, nth sector = bank * 65536
3228 */
3229 switch (hsfsts.hsf_status.berasesz) {
3230 case 0:
3231 /* Hw sector size 256 */
3232 sector_size = ICH_FLASH_SEG_SIZE_256;
3233 iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_256;
3234 break;
3235 case 1:
3236 sector_size = ICH_FLASH_SEG_SIZE_4K;
Bruce Allan28c91952009-07-01 13:28:32 +00003237 iteration = 1;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003238 break;
3239 case 2:
Bruce Allan148675a2009-08-07 07:41:56 +00003240 sector_size = ICH_FLASH_SEG_SIZE_8K;
3241 iteration = 1;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003242 break;
3243 case 3:
3244 sector_size = ICH_FLASH_SEG_SIZE_64K;
Bruce Allan28c91952009-07-01 13:28:32 +00003245 iteration = 1;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003246 break;
3247 default:
3248 return -E1000_ERR_NVM;
3249 }
3250
3251 /* Start with the base address, then add the sector offset. */
3252 flash_linear_addr = hw->nvm.flash_base_addr;
Bruce Allan148675a2009-08-07 07:41:56 +00003253 flash_linear_addr += (bank) ? flash_bank_size : 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003254
3255 for (j = 0; j < iteration ; j++) {
3256 do {
3257 /* Steps */
3258 ret_val = e1000_flash_cycle_init_ich8lan(hw);
3259 if (ret_val)
3260 return ret_val;
3261
Bruce Allane921eb12012-11-28 09:28:37 +00003262 /* Write a value 11 (block Erase) in Flash
Bruce Allanad680762008-03-28 09:15:03 -07003263 * Cycle field in hw flash control
3264 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003265 hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
3266 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_ERASE;
3267 ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
3268
Bruce Allane921eb12012-11-28 09:28:37 +00003269 /* Write the last 24 bits of an index within the
Auke Kokbc7f75f2007-09-17 12:30:59 -07003270 * block into Flash Linear address field in Flash
3271 * Address.
3272 */
3273 flash_linear_addr += (j * sector_size);
3274 ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
3275
3276 ret_val = e1000_flash_cycle_ich8lan(hw,
3277 ICH_FLASH_ERASE_COMMAND_TIMEOUT);
Bruce Allan9e2d7652012-01-31 06:37:27 +00003278 if (!ret_val)
Auke Kokbc7f75f2007-09-17 12:30:59 -07003279 break;
3280
Bruce Allane921eb12012-11-28 09:28:37 +00003281 /* Check if FCERR is set to 1. If 1,
Auke Kokbc7f75f2007-09-17 12:30:59 -07003282 * clear it and try the whole sequence
Bruce Allanad680762008-03-28 09:15:03 -07003283 * a few more times else Done
3284 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003285 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
Bruce Allan04499ec2012-04-13 00:08:31 +00003286 if (hsfsts.hsf_status.flcerr)
Bruce Allanad680762008-03-28 09:15:03 -07003287 /* repeat for some time before giving up */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003288 continue;
Bruce Allan04499ec2012-04-13 00:08:31 +00003289 else if (!hsfsts.hsf_status.flcdone)
Auke Kokbc7f75f2007-09-17 12:30:59 -07003290 return ret_val;
3291 } while (++count < ICH_FLASH_CYCLE_REPEAT_COUNT);
3292 }
3293
3294 return 0;
3295}
3296
3297/**
3298 * e1000_valid_led_default_ich8lan - Set the default LED settings
3299 * @hw: pointer to the HW structure
3300 * @data: Pointer to the LED settings
3301 *
3302 * Reads the LED default settings from the NVM to data. If the NVM LED
3303 * settings is all 0's or F's, set the LED default to a valid LED default
3304 * setting.
3305 **/
3306static s32 e1000_valid_led_default_ich8lan(struct e1000_hw *hw, u16 *data)
3307{
3308 s32 ret_val;
3309
3310 ret_val = e1000_read_nvm(hw, NVM_ID_LED_SETTINGS, 1, data);
3311 if (ret_val) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003312 e_dbg("NVM Read Error\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07003313 return ret_val;
3314 }
3315
3316 if (*data == ID_LED_RESERVED_0000 ||
3317 *data == ID_LED_RESERVED_FFFF)
3318 *data = ID_LED_DEFAULT_ICH8LAN;
3319
3320 return 0;
3321}
3322
3323/**
Bruce Allana4f58f52009-06-02 11:29:18 +00003324 * e1000_id_led_init_pchlan - store LED configurations
3325 * @hw: pointer to the HW structure
3326 *
3327 * PCH does not control LEDs via the LEDCTL register, rather it uses
3328 * the PHY LED configuration register.
3329 *
3330 * PCH also does not have an "always on" or "always off" mode which
3331 * complicates the ID feature. Instead of using the "on" mode to indicate
Bruce Alland1964eb2012-02-22 09:02:21 +00003332 * in ledctl_mode2 the LEDs to use for ID (see e1000e_id_led_init_generic()),
Bruce Allana4f58f52009-06-02 11:29:18 +00003333 * use "link_up" mode. The LEDs will still ID on request if there is no
3334 * link based on logic in e1000_led_[on|off]_pchlan().
3335 **/
3336static s32 e1000_id_led_init_pchlan(struct e1000_hw *hw)
3337{
3338 struct e1000_mac_info *mac = &hw->mac;
3339 s32 ret_val;
3340 const u32 ledctl_on = E1000_LEDCTL_MODE_LINK_UP;
3341 const u32 ledctl_off = E1000_LEDCTL_MODE_LINK_UP | E1000_PHY_LED0_IVRT;
3342 u16 data, i, temp, shift;
3343
3344 /* Get default ID LED modes */
3345 ret_val = hw->nvm.ops.valid_led_default(hw, &data);
3346 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00003347 return ret_val;
Bruce Allana4f58f52009-06-02 11:29:18 +00003348
3349 mac->ledctl_default = er32(LEDCTL);
3350 mac->ledctl_mode1 = mac->ledctl_default;
3351 mac->ledctl_mode2 = mac->ledctl_default;
3352
3353 for (i = 0; i < 4; i++) {
3354 temp = (data >> (i << 2)) & E1000_LEDCTL_LED0_MODE_MASK;
3355 shift = (i * 5);
3356 switch (temp) {
3357 case ID_LED_ON1_DEF2:
3358 case ID_LED_ON1_ON2:
3359 case ID_LED_ON1_OFF2:
3360 mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
3361 mac->ledctl_mode1 |= (ledctl_on << shift);
3362 break;
3363 case ID_LED_OFF1_DEF2:
3364 case ID_LED_OFF1_ON2:
3365 case ID_LED_OFF1_OFF2:
3366 mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
3367 mac->ledctl_mode1 |= (ledctl_off << shift);
3368 break;
3369 default:
3370 /* Do nothing */
3371 break;
3372 }
3373 switch (temp) {
3374 case ID_LED_DEF1_ON2:
3375 case ID_LED_ON1_ON2:
3376 case ID_LED_OFF1_ON2:
3377 mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
3378 mac->ledctl_mode2 |= (ledctl_on << shift);
3379 break;
3380 case ID_LED_DEF1_OFF2:
3381 case ID_LED_ON1_OFF2:
3382 case ID_LED_OFF1_OFF2:
3383 mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
3384 mac->ledctl_mode2 |= (ledctl_off << shift);
3385 break;
3386 default:
3387 /* Do nothing */
3388 break;
3389 }
3390 }
3391
Bruce Allan5015e532012-02-08 02:55:56 +00003392 return 0;
Bruce Allana4f58f52009-06-02 11:29:18 +00003393}
3394
3395/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07003396 * e1000_get_bus_info_ich8lan - Get/Set the bus type and width
3397 * @hw: pointer to the HW structure
3398 *
3399 * ICH8 use the PCI Express bus, but does not contain a PCI Express Capability
3400 * register, so the the bus width is hard coded.
3401 **/
3402static s32 e1000_get_bus_info_ich8lan(struct e1000_hw *hw)
3403{
3404 struct e1000_bus_info *bus = &hw->bus;
3405 s32 ret_val;
3406
3407 ret_val = e1000e_get_bus_info_pcie(hw);
3408
Bruce Allane921eb12012-11-28 09:28:37 +00003409 /* ICH devices are "PCI Express"-ish. They have
Auke Kokbc7f75f2007-09-17 12:30:59 -07003410 * a configuration space, but do not contain
3411 * PCI Express Capability registers, so bus width
3412 * must be hardcoded.
3413 */
3414 if (bus->width == e1000_bus_width_unknown)
3415 bus->width = e1000_bus_width_pcie_x1;
3416
3417 return ret_val;
3418}
3419
3420/**
3421 * e1000_reset_hw_ich8lan - Reset the hardware
3422 * @hw: pointer to the HW structure
3423 *
3424 * Does a full reset of the hardware which includes a reset of the PHY and
3425 * MAC.
3426 **/
3427static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
3428{
Bruce Allan1d5846b2009-10-29 13:46:05 +00003429 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
Bruce Allan62bc8132012-03-20 03:47:57 +00003430 u16 kum_cfg;
3431 u32 ctrl, reg;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003432 s32 ret_val;
3433
Bruce Allane921eb12012-11-28 09:28:37 +00003434 /* Prevent the PCI-E bus from sticking if there is no TLP connection
Auke Kokbc7f75f2007-09-17 12:30:59 -07003435 * on the last TLP read/write transaction when MAC is reset.
3436 */
3437 ret_val = e1000e_disable_pcie_master(hw);
Bruce Allane98cac42010-05-10 15:02:32 +00003438 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003439 e_dbg("PCI-E Master disable polling has failed.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07003440
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003441 e_dbg("Masking off all interrupts\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07003442 ew32(IMC, 0xffffffff);
3443
Bruce Allane921eb12012-11-28 09:28:37 +00003444 /* Disable the Transmit and Receive units. Then delay to allow
Auke Kokbc7f75f2007-09-17 12:30:59 -07003445 * any pending transactions to complete before we hit the MAC
3446 * with the global reset.
3447 */
3448 ew32(RCTL, 0);
3449 ew32(TCTL, E1000_TCTL_PSP);
3450 e1e_flush();
3451
Bruce Allan1bba4382011-03-19 00:27:20 +00003452 usleep_range(10000, 20000);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003453
3454 /* Workaround for ICH8 bit corruption issue in FIFO memory */
3455 if (hw->mac.type == e1000_ich8lan) {
3456 /* Set Tx and Rx buffer allocation to 8k apiece. */
3457 ew32(PBA, E1000_PBA_8K);
3458 /* Set Packet Buffer Size to 16k. */
3459 ew32(PBS, E1000_PBS_16K);
3460 }
3461
Bruce Allan1d5846b2009-10-29 13:46:05 +00003462 if (hw->mac.type == e1000_pchlan) {
Bruce Allan62bc8132012-03-20 03:47:57 +00003463 /* Save the NVM K1 bit setting */
3464 ret_val = e1000_read_nvm(hw, E1000_NVM_K1_CONFIG, 1, &kum_cfg);
Bruce Allan1d5846b2009-10-29 13:46:05 +00003465 if (ret_val)
3466 return ret_val;
3467
Bruce Allan62bc8132012-03-20 03:47:57 +00003468 if (kum_cfg & E1000_NVM_K1_ENABLE)
Bruce Allan1d5846b2009-10-29 13:46:05 +00003469 dev_spec->nvm_k1_enabled = true;
3470 else
3471 dev_spec->nvm_k1_enabled = false;
3472 }
3473
Auke Kokbc7f75f2007-09-17 12:30:59 -07003474 ctrl = er32(CTRL);
3475
Bruce Allan44abd5c2012-02-22 09:02:37 +00003476 if (!hw->phy.ops.check_reset_block(hw)) {
Bruce Allane921eb12012-11-28 09:28:37 +00003477 /* Full-chip reset requires MAC and PHY reset at the same
Auke Kokbc7f75f2007-09-17 12:30:59 -07003478 * time to make sure the interface between MAC and the
3479 * external PHY is reset.
3480 */
3481 ctrl |= E1000_CTRL_PHY_RST;
Bruce Allan605c82b2010-09-22 17:17:01 +00003482
Bruce Allane921eb12012-11-28 09:28:37 +00003483 /* Gate automatic PHY configuration by hardware on
Bruce Allan605c82b2010-09-22 17:17:01 +00003484 * non-managed 82579
3485 */
3486 if ((hw->mac.type == e1000_pch2lan) &&
3487 !(er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
3488 e1000_gate_hw_phy_config_ich8lan(hw, true);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003489 }
3490 ret_val = e1000_acquire_swflag_ich8lan(hw);
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003491 e_dbg("Issuing a global reset to ich8lan\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07003492 ew32(CTRL, (ctrl | E1000_CTRL_RST));
Jesse Brandeburg945a5152011-07-20 00:56:21 +00003493 /* cannot issue a flush here because it hangs the hardware */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003494 msleep(20);
3495
Bruce Allan62bc8132012-03-20 03:47:57 +00003496 /* Set Phy Config Counter to 50msec */
3497 if (hw->mac.type == e1000_pch2lan) {
3498 reg = er32(FEXTNVM3);
3499 reg &= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK;
3500 reg |= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC;
3501 ew32(FEXTNVM3, reg);
3502 }
3503
Bruce Allanfc0c7762009-07-01 13:27:55 +00003504 if (!ret_val)
Bruce Allana90b4122011-10-07 03:50:38 +00003505 clear_bit(__E1000_ACCESS_SHARED_RESOURCE, &hw->adapter->state);
Jesse Brandeburg37f40232008-10-02 16:33:20 -07003506
Bruce Allane98cac42010-05-10 15:02:32 +00003507 if (ctrl & E1000_CTRL_PHY_RST) {
Bruce Allanfc0c7762009-07-01 13:27:55 +00003508 ret_val = hw->phy.ops.get_cfg_done(hw);
Bruce Allane98cac42010-05-10 15:02:32 +00003509 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00003510 return ret_val;
Bruce Allanfc0c7762009-07-01 13:27:55 +00003511
Bruce Allane98cac42010-05-10 15:02:32 +00003512 ret_val = e1000_post_phy_reset_ich8lan(hw);
Bruce Allanf523d212009-10-29 13:45:45 +00003513 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00003514 return ret_val;
Bruce Allanf523d212009-10-29 13:45:45 +00003515 }
Bruce Allane98cac42010-05-10 15:02:32 +00003516
Bruce Allane921eb12012-11-28 09:28:37 +00003517 /* For PCH, this write will make sure that any noise
Bruce Allan7d3cabb2009-07-01 13:29:08 +00003518 * will be detected as a CRC error and be dropped rather than show up
3519 * as a bad packet to the DMA engine.
3520 */
3521 if (hw->mac.type == e1000_pchlan)
3522 ew32(CRC_OFFSET, 0x65656565);
3523
Auke Kokbc7f75f2007-09-17 12:30:59 -07003524 ew32(IMC, 0xffffffff);
Bruce Allandd93f952011-01-06 14:29:48 +00003525 er32(ICR);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003526
Bruce Allan62bc8132012-03-20 03:47:57 +00003527 reg = er32(KABGTXD);
3528 reg |= E1000_KABGTXD_BGSQLBIAS;
3529 ew32(KABGTXD, reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003530
Bruce Allan5015e532012-02-08 02:55:56 +00003531 return 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003532}
3533
3534/**
3535 * e1000_init_hw_ich8lan - Initialize the hardware
3536 * @hw: pointer to the HW structure
3537 *
3538 * Prepares the hardware for transmit and receive by doing the following:
3539 * - initialize hardware bits
3540 * - initialize LED identification
3541 * - setup receive address registers
3542 * - setup flow control
Auke Kok489815c2008-02-21 15:11:07 -08003543 * - setup transmit descriptors
Auke Kokbc7f75f2007-09-17 12:30:59 -07003544 * - clear statistics
3545 **/
3546static s32 e1000_init_hw_ich8lan(struct e1000_hw *hw)
3547{
3548 struct e1000_mac_info *mac = &hw->mac;
3549 u32 ctrl_ext, txdctl, snoop;
3550 s32 ret_val;
3551 u16 i;
3552
3553 e1000_initialize_hw_bits_ich8lan(hw);
3554
3555 /* Initialize identification LED */
Bruce Allana4f58f52009-06-02 11:29:18 +00003556 ret_val = mac->ops.id_led_init(hw);
Bruce Allande39b752009-11-20 23:27:59 +00003557 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003558 e_dbg("Error initializing identification LED\n");
Bruce Allande39b752009-11-20 23:27:59 +00003559 /* This is not fatal and we should not stop init due to this */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003560
3561 /* Setup the receive address. */
3562 e1000e_init_rx_addrs(hw, mac->rar_entry_count);
3563
3564 /* Zero out the Multicast HASH table */
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003565 e_dbg("Zeroing the MTA\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07003566 for (i = 0; i < mac->mta_reg_count; i++)
3567 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
3568
Bruce Allane921eb12012-11-28 09:28:37 +00003569 /* The 82578 Rx buffer will stall if wakeup is enabled in host and
Bruce Allan3ebfc7c2011-05-13 07:20:14 +00003570 * the ME. Disable wakeup by clearing the host wakeup bit.
Bruce Allanfc0c7762009-07-01 13:27:55 +00003571 * Reset the phy after disabling host wakeup to reset the Rx buffer.
3572 */
3573 if (hw->phy.type == e1000_phy_82578) {
Bruce Allan3ebfc7c2011-05-13 07:20:14 +00003574 e1e_rphy(hw, BM_PORT_GEN_CFG, &i);
3575 i &= ~BM_WUC_HOST_WU_BIT;
3576 e1e_wphy(hw, BM_PORT_GEN_CFG, i);
Bruce Allanfc0c7762009-07-01 13:27:55 +00003577 ret_val = e1000_phy_hw_reset_ich8lan(hw);
3578 if (ret_val)
3579 return ret_val;
3580 }
3581
Auke Kokbc7f75f2007-09-17 12:30:59 -07003582 /* Setup link and flow control */
Bruce Allan1a46b402012-02-22 09:02:26 +00003583 ret_val = mac->ops.setup_link(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003584
3585 /* Set the transmit descriptor write-back policy for both queues */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003586 txdctl = er32(TXDCTL(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -07003587 txdctl = (txdctl & ~E1000_TXDCTL_WTHRESH) |
3588 E1000_TXDCTL_FULL_TX_DESC_WB;
3589 txdctl = (txdctl & ~E1000_TXDCTL_PTHRESH) |
3590 E1000_TXDCTL_MAX_TX_DESC_PREFETCH;
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003591 ew32(TXDCTL(0), txdctl);
3592 txdctl = er32(TXDCTL(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -07003593 txdctl = (txdctl & ~E1000_TXDCTL_WTHRESH) |
3594 E1000_TXDCTL_FULL_TX_DESC_WB;
3595 txdctl = (txdctl & ~E1000_TXDCTL_PTHRESH) |
3596 E1000_TXDCTL_MAX_TX_DESC_PREFETCH;
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003597 ew32(TXDCTL(1), txdctl);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003598
Bruce Allane921eb12012-11-28 09:28:37 +00003599 /* ICH8 has opposite polarity of no_snoop bits.
Bruce Allanad680762008-03-28 09:15:03 -07003600 * By default, we should use snoop behavior.
3601 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003602 if (mac->type == e1000_ich8lan)
3603 snoop = PCIE_ICH8_SNOOP_ALL;
3604 else
3605 snoop = (u32) ~(PCIE_NO_SNOOP_ALL);
3606 e1000e_set_pcie_no_snoop(hw, snoop);
3607
3608 ctrl_ext = er32(CTRL_EXT);
3609 ctrl_ext |= E1000_CTRL_EXT_RO_DIS;
3610 ew32(CTRL_EXT, ctrl_ext);
3611
Bruce Allane921eb12012-11-28 09:28:37 +00003612 /* Clear all of the statistics registers (clear on read). It is
Auke Kokbc7f75f2007-09-17 12:30:59 -07003613 * important that we do this after we have tried to establish link
3614 * because the symbol error count will increment wildly if there
3615 * is no link.
3616 */
3617 e1000_clear_hw_cntrs_ich8lan(hw);
3618
Bruce Allane561a702012-02-08 02:55:46 +00003619 return ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003620}
3621/**
3622 * e1000_initialize_hw_bits_ich8lan - Initialize required hardware bits
3623 * @hw: pointer to the HW structure
3624 *
3625 * Sets/Clears required hardware bits necessary for correctly setting up the
3626 * hardware for transmit and receive.
3627 **/
3628static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw)
3629{
3630 u32 reg;
3631
3632 /* Extended Device Control */
3633 reg = er32(CTRL_EXT);
3634 reg |= (1 << 22);
Bruce Allana4f58f52009-06-02 11:29:18 +00003635 /* Enable PHY low-power state when MAC is at D3 w/o WoL */
3636 if (hw->mac.type >= e1000_pchlan)
3637 reg |= E1000_CTRL_EXT_PHYPDEN;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003638 ew32(CTRL_EXT, reg);
3639
3640 /* Transmit Descriptor Control 0 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003641 reg = er32(TXDCTL(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -07003642 reg |= (1 << 22);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003643 ew32(TXDCTL(0), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003644
3645 /* Transmit Descriptor Control 1 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003646 reg = er32(TXDCTL(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -07003647 reg |= (1 << 22);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003648 ew32(TXDCTL(1), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003649
3650 /* Transmit Arbitration Control 0 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003651 reg = er32(TARC(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -07003652 if (hw->mac.type == e1000_ich8lan)
3653 reg |= (1 << 28) | (1 << 29);
3654 reg |= (1 << 23) | (1 << 24) | (1 << 26) | (1 << 27);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003655 ew32(TARC(0), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003656
3657 /* Transmit Arbitration Control 1 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003658 reg = er32(TARC(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -07003659 if (er32(TCTL) & E1000_TCTL_MULR)
3660 reg &= ~(1 << 28);
3661 else
3662 reg |= (1 << 28);
3663 reg |= (1 << 24) | (1 << 26) | (1 << 30);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003664 ew32(TARC(1), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003665
3666 /* Device Status */
3667 if (hw->mac.type == e1000_ich8lan) {
3668 reg = er32(STATUS);
3669 reg &= ~(1 << 31);
3670 ew32(STATUS, reg);
3671 }
Jesse Brandeburga80483d2010-03-05 02:21:44 +00003672
Bruce Allane921eb12012-11-28 09:28:37 +00003673 /* work-around descriptor data corruption issue during nfs v2 udp
Jesse Brandeburga80483d2010-03-05 02:21:44 +00003674 * traffic, just disable the nfs filtering capability
3675 */
3676 reg = er32(RFCTL);
3677 reg |= (E1000_RFCTL_NFSW_DIS | E1000_RFCTL_NFSR_DIS);
Matthew Vickf6bd5572012-04-25 08:01:05 +00003678
Bruce Allane921eb12012-11-28 09:28:37 +00003679 /* Disable IPv6 extension header parsing because some malformed
Matthew Vickf6bd5572012-04-25 08:01:05 +00003680 * IPv6 headers can hang the Rx.
3681 */
3682 if (hw->mac.type == e1000_ich8lan)
3683 reg |= (E1000_RFCTL_IPV6_EX_DIS | E1000_RFCTL_NEW_IPV6_EXT_DIS);
Jesse Brandeburga80483d2010-03-05 02:21:44 +00003684 ew32(RFCTL, reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003685}
3686
3687/**
3688 * e1000_setup_link_ich8lan - Setup flow control and link settings
3689 * @hw: pointer to the HW structure
3690 *
3691 * Determines which flow control settings to use, then configures flow
3692 * control. Calls the appropriate media-specific link configuration
3693 * function. Assuming the adapter has a valid link partner, a valid link
3694 * should be established. Assumes the hardware has previously been reset
3695 * and the transmitter and receiver are not enabled.
3696 **/
3697static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw)
3698{
Auke Kokbc7f75f2007-09-17 12:30:59 -07003699 s32 ret_val;
3700
Bruce Allan44abd5c2012-02-22 09:02:37 +00003701 if (hw->phy.ops.check_reset_block(hw))
Auke Kokbc7f75f2007-09-17 12:30:59 -07003702 return 0;
3703
Bruce Allane921eb12012-11-28 09:28:37 +00003704 /* ICH parts do not have a word in the NVM to determine
Auke Kokbc7f75f2007-09-17 12:30:59 -07003705 * the default flow control setting, so we explicitly
3706 * set it to full.
3707 */
Bruce Allan37289d92009-06-02 11:29:37 +00003708 if (hw->fc.requested_mode == e1000_fc_default) {
3709 /* Workaround h/w hang when Tx flow control enabled */
3710 if (hw->mac.type == e1000_pchlan)
3711 hw->fc.requested_mode = e1000_fc_rx_pause;
3712 else
3713 hw->fc.requested_mode = e1000_fc_full;
3714 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07003715
Bruce Allane921eb12012-11-28 09:28:37 +00003716 /* Save off the requested flow control mode for use later. Depending
Bruce Allan5c48ef3e22008-11-21 16:57:36 -08003717 * on the link partner's capabilities, we may or may not use this mode.
3718 */
3719 hw->fc.current_mode = hw->fc.requested_mode;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003720
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003721 e_dbg("After fix-ups FlowControl is now = %x\n",
Bruce Allan5c48ef3e22008-11-21 16:57:36 -08003722 hw->fc.current_mode);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003723
3724 /* Continue to configure the copper link. */
Bruce Allan944ce012012-02-22 09:02:42 +00003725 ret_val = hw->mac.ops.setup_physical_interface(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003726 if (ret_val)
3727 return ret_val;
3728
Jeff Kirsher318a94d2008-03-28 09:15:16 -07003729 ew32(FCTTV, hw->fc.pause_time);
Bruce Allana4f58f52009-06-02 11:29:18 +00003730 if ((hw->phy.type == e1000_phy_82578) ||
Bruce Alland3738bb2010-06-16 13:27:28 +00003731 (hw->phy.type == e1000_phy_82579) ||
Bruce Allan2fbe4522012-04-19 03:21:47 +00003732 (hw->phy.type == e1000_phy_i217) ||
Bruce Allana4f58f52009-06-02 11:29:18 +00003733 (hw->phy.type == e1000_phy_82577)) {
Bruce Allana3055952010-05-10 15:02:12 +00003734 ew32(FCRTV_PCH, hw->fc.refresh_time);
3735
Bruce Allan482fed82011-01-06 14:29:49 +00003736 ret_val = e1e_wphy(hw, PHY_REG(BM_PORT_CTRL_PAGE, 27),
3737 hw->fc.pause_time);
Bruce Allana4f58f52009-06-02 11:29:18 +00003738 if (ret_val)
3739 return ret_val;
3740 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07003741
3742 return e1000e_set_fc_watermarks(hw);
3743}
3744
3745/**
3746 * e1000_setup_copper_link_ich8lan - Configure MAC/PHY interface
3747 * @hw: pointer to the HW structure
3748 *
3749 * Configures the kumeran interface to the PHY to wait the appropriate time
3750 * when polling the PHY, then call the generic setup_copper_link to finish
3751 * configuring the copper link.
3752 **/
3753static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw)
3754{
3755 u32 ctrl;
3756 s32 ret_val;
3757 u16 reg_data;
3758
3759 ctrl = er32(CTRL);
3760 ctrl |= E1000_CTRL_SLU;
3761 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
3762 ew32(CTRL, ctrl);
3763
Bruce Allane921eb12012-11-28 09:28:37 +00003764 /* Set the mac to wait the maximum time between each iteration
Auke Kokbc7f75f2007-09-17 12:30:59 -07003765 * and increase the max iterations when polling the phy;
Bruce Allanad680762008-03-28 09:15:03 -07003766 * this fixes erroneous timeouts at 10Mbps.
3767 */
Bruce Allan07818952009-12-08 07:28:01 +00003768 ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_TIMEOUTS, 0xFFFF);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003769 if (ret_val)
3770 return ret_val;
Bruce Allan07818952009-12-08 07:28:01 +00003771 ret_val = e1000e_read_kmrn_reg(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
3772 &reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003773 if (ret_val)
3774 return ret_val;
3775 reg_data |= 0x3F;
Bruce Allan07818952009-12-08 07:28:01 +00003776 ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
3777 reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003778 if (ret_val)
3779 return ret_val;
3780
Bruce Allana4f58f52009-06-02 11:29:18 +00003781 switch (hw->phy.type) {
3782 case e1000_phy_igp_3:
Auke Kokbc7f75f2007-09-17 12:30:59 -07003783 ret_val = e1000e_copper_link_setup_igp(hw);
3784 if (ret_val)
3785 return ret_val;
Bruce Allana4f58f52009-06-02 11:29:18 +00003786 break;
3787 case e1000_phy_bm:
3788 case e1000_phy_82578:
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003789 ret_val = e1000e_copper_link_setup_m88(hw);
3790 if (ret_val)
3791 return ret_val;
Bruce Allana4f58f52009-06-02 11:29:18 +00003792 break;
3793 case e1000_phy_82577:
Bruce Alland3738bb2010-06-16 13:27:28 +00003794 case e1000_phy_82579:
Bruce Allan2fbe4522012-04-19 03:21:47 +00003795 case e1000_phy_i217:
Bruce Allana4f58f52009-06-02 11:29:18 +00003796 ret_val = e1000_copper_link_setup_82577(hw);
3797 if (ret_val)
3798 return ret_val;
3799 break;
3800 case e1000_phy_ife:
Bruce Allan482fed82011-01-06 14:29:49 +00003801 ret_val = e1e_rphy(hw, IFE_PHY_MDIX_CONTROL, &reg_data);
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003802 if (ret_val)
3803 return ret_val;
3804
3805 reg_data &= ~IFE_PMC_AUTO_MDIX;
3806
3807 switch (hw->phy.mdix) {
3808 case 1:
3809 reg_data &= ~IFE_PMC_FORCE_MDIX;
3810 break;
3811 case 2:
3812 reg_data |= IFE_PMC_FORCE_MDIX;
3813 break;
3814 case 0:
3815 default:
3816 reg_data |= IFE_PMC_AUTO_MDIX;
3817 break;
3818 }
Bruce Allan482fed82011-01-06 14:29:49 +00003819 ret_val = e1e_wphy(hw, IFE_PHY_MDIX_CONTROL, reg_data);
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003820 if (ret_val)
3821 return ret_val;
Bruce Allana4f58f52009-06-02 11:29:18 +00003822 break;
3823 default:
3824 break;
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003825 }
Bruce Allan3fa8293632012-02-08 02:55:40 +00003826
Auke Kokbc7f75f2007-09-17 12:30:59 -07003827 return e1000e_setup_copper_link(hw);
3828}
3829
3830/**
3831 * e1000_get_link_up_info_ich8lan - Get current link speed and duplex
3832 * @hw: pointer to the HW structure
3833 * @speed: pointer to store current link speed
3834 * @duplex: pointer to store the current link duplex
3835 *
Bruce Allanad680762008-03-28 09:15:03 -07003836 * Calls the generic get_speed_and_duplex to retrieve the current link
Auke Kokbc7f75f2007-09-17 12:30:59 -07003837 * information and then calls the Kumeran lock loss workaround for links at
3838 * gigabit speeds.
3839 **/
3840static s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw, u16 *speed,
3841 u16 *duplex)
3842{
3843 s32 ret_val;
3844
3845 ret_val = e1000e_get_speed_and_duplex_copper(hw, speed, duplex);
3846 if (ret_val)
3847 return ret_val;
3848
3849 if ((hw->mac.type == e1000_ich8lan) &&
3850 (hw->phy.type == e1000_phy_igp_3) &&
3851 (*speed == SPEED_1000)) {
3852 ret_val = e1000_kmrn_lock_loss_workaround_ich8lan(hw);
3853 }
3854
3855 return ret_val;
3856}
3857
3858/**
3859 * e1000_kmrn_lock_loss_workaround_ich8lan - Kumeran workaround
3860 * @hw: pointer to the HW structure
3861 *
3862 * Work-around for 82566 Kumeran PCS lock loss:
3863 * On link status change (i.e. PCI reset, speed change) and link is up and
3864 * speed is gigabit-
3865 * 0) if workaround is optionally disabled do nothing
3866 * 1) wait 1ms for Kumeran link to come up
3867 * 2) check Kumeran Diagnostic register PCS lock loss bit
3868 * 3) if not set the link is locked (all is good), otherwise...
3869 * 4) reset the PHY
3870 * 5) repeat up to 10 times
3871 * Note: this is only called for IGP3 copper when speed is 1gb.
3872 **/
3873static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw)
3874{
3875 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
3876 u32 phy_ctrl;
3877 s32 ret_val;
3878 u16 i, data;
3879 bool link;
3880
3881 if (!dev_spec->kmrn_lock_loss_workaround_enabled)
3882 return 0;
3883
Bruce Allane921eb12012-11-28 09:28:37 +00003884 /* Make sure link is up before proceeding. If not just return.
Auke Kokbc7f75f2007-09-17 12:30:59 -07003885 * Attempting this while link is negotiating fouled up link
Bruce Allanad680762008-03-28 09:15:03 -07003886 * stability
3887 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003888 ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link);
3889 if (!link)
3890 return 0;
3891
3892 for (i = 0; i < 10; i++) {
3893 /* read once to clear */
3894 ret_val = e1e_rphy(hw, IGP3_KMRN_DIAG, &data);
3895 if (ret_val)
3896 return ret_val;
3897 /* and again to get new status */
3898 ret_val = e1e_rphy(hw, IGP3_KMRN_DIAG, &data);
3899 if (ret_val)
3900 return ret_val;
3901
3902 /* check for PCS lock */
3903 if (!(data & IGP3_KMRN_DIAG_PCS_LOCK_LOSS))
3904 return 0;
3905
3906 /* Issue PHY reset */
3907 e1000_phy_hw_reset(hw);
3908 mdelay(5);
3909 }
3910 /* Disable GigE link negotiation */
3911 phy_ctrl = er32(PHY_CTRL);
3912 phy_ctrl |= (E1000_PHY_CTRL_GBE_DISABLE |
3913 E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
3914 ew32(PHY_CTRL, phy_ctrl);
3915
Bruce Allane921eb12012-11-28 09:28:37 +00003916 /* Call gig speed drop workaround on Gig disable before accessing
Bruce Allanad680762008-03-28 09:15:03 -07003917 * any PHY registers
3918 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003919 e1000e_gig_downshift_workaround_ich8lan(hw);
3920
3921 /* unable to acquire PCS lock */
3922 return -E1000_ERR_PHY;
3923}
3924
3925/**
Bruce Allan6e3c8072012-02-22 09:02:47 +00003926 * e1000e_set_kmrn_lock_loss_workaround_ich8lan - Set Kumeran workaround state
Auke Kokbc7f75f2007-09-17 12:30:59 -07003927 * @hw: pointer to the HW structure
Auke Kok489815c2008-02-21 15:11:07 -08003928 * @state: boolean value used to set the current Kumeran workaround state
Auke Kokbc7f75f2007-09-17 12:30:59 -07003929 *
Bruce Allan564ea9b2009-11-20 23:26:44 +00003930 * If ICH8, set the current Kumeran workaround state (enabled - true
3931 * /disabled - false).
Auke Kokbc7f75f2007-09-17 12:30:59 -07003932 **/
3933void e1000e_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw,
3934 bool state)
3935{
3936 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
3937
3938 if (hw->mac.type != e1000_ich8lan) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003939 e_dbg("Workaround applies to ICH8 only.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07003940 return;
3941 }
3942
3943 dev_spec->kmrn_lock_loss_workaround_enabled = state;
3944}
3945
3946/**
3947 * e1000_ipg3_phy_powerdown_workaround_ich8lan - Power down workaround on D3
3948 * @hw: pointer to the HW structure
3949 *
3950 * Workaround for 82566 power-down on D3 entry:
3951 * 1) disable gigabit link
3952 * 2) write VR power-down enable
3953 * 3) read it back
3954 * Continue if successful, else issue LCD reset and repeat
3955 **/
3956void e1000e_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw)
3957{
3958 u32 reg;
3959 u16 data;
3960 u8 retry = 0;
3961
3962 if (hw->phy.type != e1000_phy_igp_3)
3963 return;
3964
3965 /* Try the workaround twice (if needed) */
3966 do {
3967 /* Disable link */
3968 reg = er32(PHY_CTRL);
3969 reg |= (E1000_PHY_CTRL_GBE_DISABLE |
3970 E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
3971 ew32(PHY_CTRL, reg);
3972
Bruce Allane921eb12012-11-28 09:28:37 +00003973 /* Call gig speed drop workaround on Gig disable before
Bruce Allanad680762008-03-28 09:15:03 -07003974 * accessing any PHY registers
3975 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003976 if (hw->mac.type == e1000_ich8lan)
3977 e1000e_gig_downshift_workaround_ich8lan(hw);
3978
3979 /* Write VR power-down enable */
3980 e1e_rphy(hw, IGP3_VR_CTRL, &data);
3981 data &= ~IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
3982 e1e_wphy(hw, IGP3_VR_CTRL, data | IGP3_VR_CTRL_MODE_SHUTDOWN);
3983
3984 /* Read it back and test */
3985 e1e_rphy(hw, IGP3_VR_CTRL, &data);
3986 data &= IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
3987 if ((data == IGP3_VR_CTRL_MODE_SHUTDOWN) || retry)
3988 break;
3989
3990 /* Issue PHY reset and repeat at most one more time */
3991 reg = er32(CTRL);
3992 ew32(CTRL, reg | E1000_CTRL_PHY_RST);
3993 retry++;
3994 } while (retry);
3995}
3996
3997/**
3998 * e1000e_gig_downshift_workaround_ich8lan - WoL from S5 stops working
3999 * @hw: pointer to the HW structure
4000 *
4001 * Steps to take when dropping from 1Gb/s (eg. link cable removal (LSC),
Auke Kok489815c2008-02-21 15:11:07 -08004002 * LPLU, Gig disable, MDIC PHY reset):
Auke Kokbc7f75f2007-09-17 12:30:59 -07004003 * 1) Set Kumeran Near-end loopback
4004 * 2) Clear Kumeran Near-end loopback
Bruce Allan462d5992011-09-30 08:07:11 +00004005 * Should only be called for ICH8[m] devices with any 1G Phy.
Auke Kokbc7f75f2007-09-17 12:30:59 -07004006 **/
4007void e1000e_gig_downshift_workaround_ich8lan(struct e1000_hw *hw)
4008{
4009 s32 ret_val;
4010 u16 reg_data;
4011
Bruce Allan462d5992011-09-30 08:07:11 +00004012 if ((hw->mac.type != e1000_ich8lan) || (hw->phy.type == e1000_phy_ife))
Auke Kokbc7f75f2007-09-17 12:30:59 -07004013 return;
4014
4015 ret_val = e1000e_read_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
4016 &reg_data);
4017 if (ret_val)
4018 return;
4019 reg_data |= E1000_KMRNCTRLSTA_DIAG_NELPBK;
4020 ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
4021 reg_data);
4022 if (ret_val)
4023 return;
4024 reg_data &= ~E1000_KMRNCTRLSTA_DIAG_NELPBK;
4025 ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
4026 reg_data);
4027}
4028
4029/**
Bruce Allan99730e42011-05-13 07:19:48 +00004030 * e1000_suspend_workarounds_ich8lan - workarounds needed during S0->Sx
Bruce Allan97ac8ca2008-04-29 09:16:05 -07004031 * @hw: pointer to the HW structure
4032 *
4033 * During S0 to Sx transition, it is possible the link remains at gig
4034 * instead of negotiating to a lower speed. Before going to Sx, set
Bruce Allanc077a902011-12-16 00:46:38 +00004035 * 'Gig Disable' to force link speed negotiation to a lower speed based on
4036 * the LPLU setting in the NVM or custom setting. For PCH and newer parts,
4037 * the OEM bits PHY register (LED, GbE disable and LPLU configurations) also
4038 * needs to be written.
Bruce Allan2fbe4522012-04-19 03:21:47 +00004039 * Parts that support (and are linked to a partner which support) EEE in
4040 * 100Mbps should disable LPLU since 100Mbps w/ EEE requires less power
4041 * than 10Mbps w/o EEE.
Bruce Allan97ac8ca2008-04-29 09:16:05 -07004042 **/
Bruce Allan99730e42011-05-13 07:19:48 +00004043void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw)
Bruce Allan97ac8ca2008-04-29 09:16:05 -07004044{
Bruce Allan2fbe4522012-04-19 03:21:47 +00004045 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
Bruce Allan97ac8ca2008-04-29 09:16:05 -07004046 u32 phy_ctrl;
Bruce Allan8395ae82010-09-22 17:15:08 +00004047 s32 ret_val;
Bruce Allan97ac8ca2008-04-29 09:16:05 -07004048
Bruce Allan17f085d2010-06-17 18:59:48 +00004049 phy_ctrl = er32(PHY_CTRL);
Bruce Allanc077a902011-12-16 00:46:38 +00004050 phy_ctrl |= E1000_PHY_CTRL_GBE_DISABLE;
Bruce Allan2fbe4522012-04-19 03:21:47 +00004051 if (hw->phy.type == e1000_phy_i217) {
4052 u16 phy_reg;
4053
4054 ret_val = hw->phy.ops.acquire(hw);
4055 if (ret_val)
4056 goto out;
4057
4058 if (!dev_spec->eee_disable) {
4059 u16 eee_advert;
4060
Bruce Allan4ddc48a2012-12-05 06:25:58 +00004061 ret_val =
4062 e1000_read_emi_reg_locked(hw,
4063 I217_EEE_ADVERTISEMENT,
4064 &eee_advert);
Bruce Allan2fbe4522012-04-19 03:21:47 +00004065 if (ret_val)
4066 goto release;
Bruce Allan2fbe4522012-04-19 03:21:47 +00004067
Bruce Allane921eb12012-11-28 09:28:37 +00004068 /* Disable LPLU if both link partners support 100BaseT
Bruce Allan2fbe4522012-04-19 03:21:47 +00004069 * EEE and 100Full is advertised on both ends of the
4070 * link.
4071 */
4072 if ((eee_advert & I217_EEE_100_SUPPORTED) &&
4073 (dev_spec->eee_lp_ability &
4074 I217_EEE_100_SUPPORTED) &&
4075 (hw->phy.autoneg_advertised & ADVERTISE_100_FULL))
4076 phy_ctrl &= ~(E1000_PHY_CTRL_D0A_LPLU |
4077 E1000_PHY_CTRL_NOND0A_LPLU);
4078 }
4079
Bruce Allane921eb12012-11-28 09:28:37 +00004080 /* For i217 Intel Rapid Start Technology support,
Bruce Allan2fbe4522012-04-19 03:21:47 +00004081 * when the system is going into Sx and no manageability engine
4082 * is present, the driver must configure proxy to reset only on
4083 * power good. LPI (Low Power Idle) state must also reset only
4084 * on power good, as well as the MTA (Multicast table array).
4085 * The SMBus release must also be disabled on LCD reset.
4086 */
4087 if (!(er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) {
4088
4089 /* Enable proxy to reset only on power good. */
4090 e1e_rphy_locked(hw, I217_PROXY_CTRL, &phy_reg);
4091 phy_reg |= I217_PROXY_CTRL_AUTO_DISABLE;
4092 e1e_wphy_locked(hw, I217_PROXY_CTRL, phy_reg);
4093
Bruce Allane921eb12012-11-28 09:28:37 +00004094 /* Set bit enable LPI (EEE) to reset only on
Bruce Allan2fbe4522012-04-19 03:21:47 +00004095 * power good.
4096 */
4097 e1e_rphy_locked(hw, I217_SxCTRL, &phy_reg);
Bruce Allan6d7407b2012-05-10 02:51:17 +00004098 phy_reg |= I217_SxCTRL_ENABLE_LPI_RESET;
Bruce Allan2fbe4522012-04-19 03:21:47 +00004099 e1e_wphy_locked(hw, I217_SxCTRL, phy_reg);
4100
4101 /* Disable the SMB release on LCD reset. */
4102 e1e_rphy_locked(hw, I217_MEMPWR, &phy_reg);
Bruce Allan6d7407b2012-05-10 02:51:17 +00004103 phy_reg &= ~I217_MEMPWR_DISABLE_SMB_RELEASE;
Bruce Allan2fbe4522012-04-19 03:21:47 +00004104 e1e_wphy_locked(hw, I217_MEMPWR, phy_reg);
4105 }
4106
Bruce Allane921eb12012-11-28 09:28:37 +00004107 /* Enable MTA to reset for Intel Rapid Start Technology
Bruce Allan2fbe4522012-04-19 03:21:47 +00004108 * Support
4109 */
4110 e1e_rphy_locked(hw, I217_CGFREG, &phy_reg);
Bruce Allan6d7407b2012-05-10 02:51:17 +00004111 phy_reg |= I217_CGFREG_ENABLE_MTA_RESET;
Bruce Allan2fbe4522012-04-19 03:21:47 +00004112 e1e_wphy_locked(hw, I217_CGFREG, phy_reg);
4113
4114release:
4115 hw->phy.ops.release(hw);
4116 }
4117out:
Bruce Allan17f085d2010-06-17 18:59:48 +00004118 ew32(PHY_CTRL, phy_ctrl);
Bruce Allana4f58f52009-06-02 11:29:18 +00004119
Bruce Allan462d5992011-09-30 08:07:11 +00004120 if (hw->mac.type == e1000_ich8lan)
4121 e1000e_gig_downshift_workaround_ich8lan(hw);
4122
Bruce Allan8395ae82010-09-22 17:15:08 +00004123 if (hw->mac.type >= e1000_pchlan) {
Bruce Allance54afd2010-11-24 06:01:41 +00004124 e1000_oem_bits_config_ich8lan(hw, false);
Bruce Allan92fe1732012-04-12 06:27:03 +00004125
4126 /* Reset PHY to activate OEM bits on 82577/8 */
4127 if (hw->mac.type == e1000_pchlan)
4128 e1000e_phy_hw_reset_generic(hw);
4129
Bruce Allan8395ae82010-09-22 17:15:08 +00004130 ret_val = hw->phy.ops.acquire(hw);
4131 if (ret_val)
4132 return;
4133 e1000_write_smbus_addr(hw);
4134 hw->phy.ops.release(hw);
4135 }
Bruce Allan97ac8ca2008-04-29 09:16:05 -07004136}
4137
4138/**
Bruce Allan99730e42011-05-13 07:19:48 +00004139 * e1000_resume_workarounds_pchlan - workarounds needed during Sx->S0
4140 * @hw: pointer to the HW structure
4141 *
4142 * During Sx to S0 transitions on non-managed devices or managed devices
4143 * on which PHY resets are not blocked, if the PHY registers cannot be
4144 * accessed properly by the s/w toggle the LANPHYPC value to power cycle
4145 * the PHY.
Bruce Allan2fbe4522012-04-19 03:21:47 +00004146 * On i217, setup Intel Rapid Start Technology.
Bruce Allan99730e42011-05-13 07:19:48 +00004147 **/
4148void e1000_resume_workarounds_pchlan(struct e1000_hw *hw)
4149{
Bruce Allan90b82982011-12-16 00:46:33 +00004150 s32 ret_val;
Bruce Allan99730e42011-05-13 07:19:48 +00004151
Bruce Allancb17aab2012-04-13 03:16:22 +00004152 if (hw->mac.type < e1000_pch2lan)
Bruce Allan99730e42011-05-13 07:19:48 +00004153 return;
4154
Bruce Allancb17aab2012-04-13 03:16:22 +00004155 ret_val = e1000_init_phy_workarounds_pchlan(hw);
Bruce Allan90b82982011-12-16 00:46:33 +00004156 if (ret_val) {
Bruce Allancb17aab2012-04-13 03:16:22 +00004157 e_dbg("Failed to init PHY flow ret_val=%d\n", ret_val);
Bruce Allan99730e42011-05-13 07:19:48 +00004158 return;
4159 }
Bruce Allan2fbe4522012-04-19 03:21:47 +00004160
Bruce Allane921eb12012-11-28 09:28:37 +00004161 /* For i217 Intel Rapid Start Technology support when the system
Bruce Allan2fbe4522012-04-19 03:21:47 +00004162 * is transitioning from Sx and no manageability engine is present
4163 * configure SMBus to restore on reset, disable proxy, and enable
4164 * the reset on MTA (Multicast table array).
4165 */
4166 if (hw->phy.type == e1000_phy_i217) {
4167 u16 phy_reg;
4168
4169 ret_val = hw->phy.ops.acquire(hw);
4170 if (ret_val) {
4171 e_dbg("Failed to setup iRST\n");
4172 return;
4173 }
4174
4175 if (!(er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) {
Bruce Allane921eb12012-11-28 09:28:37 +00004176 /* Restore clear on SMB if no manageability engine
Bruce Allan2fbe4522012-04-19 03:21:47 +00004177 * is present
4178 */
4179 ret_val = e1e_rphy_locked(hw, I217_MEMPWR, &phy_reg);
4180 if (ret_val)
4181 goto release;
Bruce Allan6d7407b2012-05-10 02:51:17 +00004182 phy_reg |= I217_MEMPWR_DISABLE_SMB_RELEASE;
Bruce Allan2fbe4522012-04-19 03:21:47 +00004183 e1e_wphy_locked(hw, I217_MEMPWR, phy_reg);
4184
4185 /* Disable Proxy */
4186 e1e_wphy_locked(hw, I217_PROXY_CTRL, 0);
4187 }
4188 /* Enable reset on MTA */
4189 ret_val = e1e_rphy_locked(hw, I217_CGFREG, &phy_reg);
4190 if (ret_val)
4191 goto release;
Bruce Allan6d7407b2012-05-10 02:51:17 +00004192 phy_reg &= ~I217_CGFREG_ENABLE_MTA_RESET;
Bruce Allan2fbe4522012-04-19 03:21:47 +00004193 e1e_wphy_locked(hw, I217_CGFREG, phy_reg);
4194release:
4195 if (ret_val)
4196 e_dbg("Error %d in resume workarounds\n", ret_val);
4197 hw->phy.ops.release(hw);
4198 }
Bruce Allan99730e42011-05-13 07:19:48 +00004199}
4200
4201/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07004202 * e1000_cleanup_led_ich8lan - Restore the default LED operation
4203 * @hw: pointer to the HW structure
4204 *
4205 * Return the LED back to the default configuration.
4206 **/
4207static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw)
4208{
4209 if (hw->phy.type == e1000_phy_ife)
4210 return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED, 0);
4211
4212 ew32(LEDCTL, hw->mac.ledctl_default);
4213 return 0;
4214}
4215
4216/**
Auke Kok489815c2008-02-21 15:11:07 -08004217 * e1000_led_on_ich8lan - Turn LEDs on
Auke Kokbc7f75f2007-09-17 12:30:59 -07004218 * @hw: pointer to the HW structure
4219 *
Auke Kok489815c2008-02-21 15:11:07 -08004220 * Turn on the LEDs.
Auke Kokbc7f75f2007-09-17 12:30:59 -07004221 **/
4222static s32 e1000_led_on_ich8lan(struct e1000_hw *hw)
4223{
4224 if (hw->phy.type == e1000_phy_ife)
4225 return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED,
4226 (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_ON));
4227
4228 ew32(LEDCTL, hw->mac.ledctl_mode2);
4229 return 0;
4230}
4231
4232/**
Auke Kok489815c2008-02-21 15:11:07 -08004233 * e1000_led_off_ich8lan - Turn LEDs off
Auke Kokbc7f75f2007-09-17 12:30:59 -07004234 * @hw: pointer to the HW structure
4235 *
Auke Kok489815c2008-02-21 15:11:07 -08004236 * Turn off the LEDs.
Auke Kokbc7f75f2007-09-17 12:30:59 -07004237 **/
4238static s32 e1000_led_off_ich8lan(struct e1000_hw *hw)
4239{
4240 if (hw->phy.type == e1000_phy_ife)
4241 return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED,
Bruce Allan482fed82011-01-06 14:29:49 +00004242 (IFE_PSCL_PROBE_MODE |
4243 IFE_PSCL_PROBE_LEDS_OFF));
Auke Kokbc7f75f2007-09-17 12:30:59 -07004244
4245 ew32(LEDCTL, hw->mac.ledctl_mode1);
4246 return 0;
4247}
4248
4249/**
Bruce Allana4f58f52009-06-02 11:29:18 +00004250 * e1000_setup_led_pchlan - Configures SW controllable LED
4251 * @hw: pointer to the HW structure
4252 *
4253 * This prepares the SW controllable LED for use.
4254 **/
4255static s32 e1000_setup_led_pchlan(struct e1000_hw *hw)
4256{
Bruce Allan482fed82011-01-06 14:29:49 +00004257 return e1e_wphy(hw, HV_LED_CONFIG, (u16)hw->mac.ledctl_mode1);
Bruce Allana4f58f52009-06-02 11:29:18 +00004258}
4259
4260/**
4261 * e1000_cleanup_led_pchlan - Restore the default LED operation
4262 * @hw: pointer to the HW structure
4263 *
4264 * Return the LED back to the default configuration.
4265 **/
4266static s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw)
4267{
Bruce Allan482fed82011-01-06 14:29:49 +00004268 return e1e_wphy(hw, HV_LED_CONFIG, (u16)hw->mac.ledctl_default);
Bruce Allana4f58f52009-06-02 11:29:18 +00004269}
4270
4271/**
4272 * e1000_led_on_pchlan - Turn LEDs on
4273 * @hw: pointer to the HW structure
4274 *
4275 * Turn on the LEDs.
4276 **/
4277static s32 e1000_led_on_pchlan(struct e1000_hw *hw)
4278{
4279 u16 data = (u16)hw->mac.ledctl_mode2;
4280 u32 i, led;
4281
Bruce Allane921eb12012-11-28 09:28:37 +00004282 /* If no link, then turn LED on by setting the invert bit
Bruce Allana4f58f52009-06-02 11:29:18 +00004283 * for each LED that's mode is "link_up" in ledctl_mode2.
4284 */
4285 if (!(er32(STATUS) & E1000_STATUS_LU)) {
4286 for (i = 0; i < 3; i++) {
4287 led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
4288 if ((led & E1000_PHY_LED0_MODE_MASK) !=
4289 E1000_LEDCTL_MODE_LINK_UP)
4290 continue;
4291 if (led & E1000_PHY_LED0_IVRT)
4292 data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
4293 else
4294 data |= (E1000_PHY_LED0_IVRT << (i * 5));
4295 }
4296 }
4297
Bruce Allan482fed82011-01-06 14:29:49 +00004298 return e1e_wphy(hw, HV_LED_CONFIG, data);
Bruce Allana4f58f52009-06-02 11:29:18 +00004299}
4300
4301/**
4302 * e1000_led_off_pchlan - Turn LEDs off
4303 * @hw: pointer to the HW structure
4304 *
4305 * Turn off the LEDs.
4306 **/
4307static s32 e1000_led_off_pchlan(struct e1000_hw *hw)
4308{
4309 u16 data = (u16)hw->mac.ledctl_mode1;
4310 u32 i, led;
4311
Bruce Allane921eb12012-11-28 09:28:37 +00004312 /* If no link, then turn LED off by clearing the invert bit
Bruce Allana4f58f52009-06-02 11:29:18 +00004313 * for each LED that's mode is "link_up" in ledctl_mode1.
4314 */
4315 if (!(er32(STATUS) & E1000_STATUS_LU)) {
4316 for (i = 0; i < 3; i++) {
4317 led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
4318 if ((led & E1000_PHY_LED0_MODE_MASK) !=
4319 E1000_LEDCTL_MODE_LINK_UP)
4320 continue;
4321 if (led & E1000_PHY_LED0_IVRT)
4322 data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
4323 else
4324 data |= (E1000_PHY_LED0_IVRT << (i * 5));
4325 }
4326 }
4327
Bruce Allan482fed82011-01-06 14:29:49 +00004328 return e1e_wphy(hw, HV_LED_CONFIG, data);
Bruce Allana4f58f52009-06-02 11:29:18 +00004329}
4330
4331/**
Bruce Allane98cac42010-05-10 15:02:32 +00004332 * e1000_get_cfg_done_ich8lan - Read config done bit after Full or PHY reset
Bruce Allanf4187b52008-08-26 18:36:50 -07004333 * @hw: pointer to the HW structure
4334 *
Bruce Allane98cac42010-05-10 15:02:32 +00004335 * Read appropriate register for the config done bit for completion status
4336 * and configure the PHY through s/w for EEPROM-less parts.
4337 *
4338 * NOTE: some silicon which is EEPROM-less will fail trying to read the
4339 * config done bit, so only an error is logged and continues. If we were
4340 * to return with error, EEPROM-less silicon would not be able to be reset
4341 * or change link.
Bruce Allanf4187b52008-08-26 18:36:50 -07004342 **/
4343static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw)
4344{
Bruce Allane98cac42010-05-10 15:02:32 +00004345 s32 ret_val = 0;
Bruce Allanf4187b52008-08-26 18:36:50 -07004346 u32 bank = 0;
Bruce Allane98cac42010-05-10 15:02:32 +00004347 u32 status;
Bruce Allanfc0c7762009-07-01 13:27:55 +00004348
Bruce Allanf4187b52008-08-26 18:36:50 -07004349 e1000e_get_cfg_done(hw);
4350
Bruce Allane98cac42010-05-10 15:02:32 +00004351 /* Wait for indication from h/w that it has completed basic config */
4352 if (hw->mac.type >= e1000_ich10lan) {
4353 e1000_lan_init_done_ich8lan(hw);
4354 } else {
4355 ret_val = e1000e_get_auto_rd_done(hw);
4356 if (ret_val) {
Bruce Allane921eb12012-11-28 09:28:37 +00004357 /* When auto config read does not complete, do not
Bruce Allane98cac42010-05-10 15:02:32 +00004358 * return with an error. This can happen in situations
4359 * where there is no eeprom and prevents getting link.
4360 */
4361 e_dbg("Auto Read Done did not complete\n");
4362 ret_val = 0;
4363 }
4364 }
4365
4366 /* Clear PHY Reset Asserted bit */
4367 status = er32(STATUS);
4368 if (status & E1000_STATUS_PHYRA)
4369 ew32(STATUS, status & ~E1000_STATUS_PHYRA);
4370 else
4371 e_dbg("PHY Reset Asserted not set - needs delay\n");
4372
Bruce Allanf4187b52008-08-26 18:36:50 -07004373 /* If EEPROM is not marked present, init the IGP 3 PHY manually */
Bruce Allane98cac42010-05-10 15:02:32 +00004374 if (hw->mac.type <= e1000_ich9lan) {
Bruce Allan04499ec2012-04-13 00:08:31 +00004375 if (!(er32(EECD) & E1000_EECD_PRES) &&
Bruce Allanf4187b52008-08-26 18:36:50 -07004376 (hw->phy.type == e1000_phy_igp_3)) {
4377 e1000e_phy_init_script_igp3(hw);
4378 }
4379 } else {
4380 if (e1000_valid_nvm_bank_detect_ich8lan(hw, &bank)) {
4381 /* Maybe we should do a basic PHY config */
Bruce Allan3bb99fe2009-11-20 23:25:07 +00004382 e_dbg("EEPROM not present\n");
Bruce Allane98cac42010-05-10 15:02:32 +00004383 ret_val = -E1000_ERR_CONFIG;
Bruce Allanf4187b52008-08-26 18:36:50 -07004384 }
4385 }
4386
Bruce Allane98cac42010-05-10 15:02:32 +00004387 return ret_val;
Bruce Allanf4187b52008-08-26 18:36:50 -07004388}
4389
4390/**
Bruce Allan17f208d2009-12-01 15:47:22 +00004391 * e1000_power_down_phy_copper_ich8lan - Remove link during PHY power down
4392 * @hw: pointer to the HW structure
4393 *
4394 * In the case of a PHY power down to save power, or to turn off link during a
4395 * driver unload, or wake on lan is not enabled, remove the link.
4396 **/
4397static void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw)
4398{
4399 /* If the management interface is not enabled, then power down */
4400 if (!(hw->mac.ops.check_mng_mode(hw) ||
4401 hw->phy.ops.check_reset_block(hw)))
4402 e1000_power_down_phy_copper(hw);
Bruce Allan17f208d2009-12-01 15:47:22 +00004403}
4404
4405/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07004406 * e1000_clear_hw_cntrs_ich8lan - Clear statistical counters
4407 * @hw: pointer to the HW structure
4408 *
4409 * Clears hardware counters specific to the silicon family and calls
4410 * clear_hw_cntrs_generic to clear all general purpose counters.
4411 **/
4412static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw)
4413{
Bruce Allana4f58f52009-06-02 11:29:18 +00004414 u16 phy_data;
Bruce Allan2b6b1682011-05-13 07:20:09 +00004415 s32 ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -07004416
4417 e1000e_clear_hw_cntrs_base(hw);
4418
Bruce Allan99673d92009-11-20 23:27:21 +00004419 er32(ALGNERRC);
4420 er32(RXERRC);
4421 er32(TNCRS);
4422 er32(CEXTERR);
4423 er32(TSCTC);
4424 er32(TSCTFC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07004425
Bruce Allan99673d92009-11-20 23:27:21 +00004426 er32(MGTPRC);
4427 er32(MGTPDC);
4428 er32(MGTPTC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07004429
Bruce Allan99673d92009-11-20 23:27:21 +00004430 er32(IAC);
4431 er32(ICRXOC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07004432
Bruce Allana4f58f52009-06-02 11:29:18 +00004433 /* Clear PHY statistics registers */
4434 if ((hw->phy.type == e1000_phy_82578) ||
Bruce Alland3738bb2010-06-16 13:27:28 +00004435 (hw->phy.type == e1000_phy_82579) ||
Bruce Allan2fbe4522012-04-19 03:21:47 +00004436 (hw->phy.type == e1000_phy_i217) ||
Bruce Allana4f58f52009-06-02 11:29:18 +00004437 (hw->phy.type == e1000_phy_82577)) {
Bruce Allan2b6b1682011-05-13 07:20:09 +00004438 ret_val = hw->phy.ops.acquire(hw);
4439 if (ret_val)
4440 return;
4441 ret_val = hw->phy.ops.set_page(hw,
4442 HV_STATS_PAGE << IGP_PAGE_SHIFT);
4443 if (ret_val)
4444 goto release;
4445 hw->phy.ops.read_reg_page(hw, HV_SCC_UPPER, &phy_data);
4446 hw->phy.ops.read_reg_page(hw, HV_SCC_LOWER, &phy_data);
4447 hw->phy.ops.read_reg_page(hw, HV_ECOL_UPPER, &phy_data);
4448 hw->phy.ops.read_reg_page(hw, HV_ECOL_LOWER, &phy_data);
4449 hw->phy.ops.read_reg_page(hw, HV_MCC_UPPER, &phy_data);
4450 hw->phy.ops.read_reg_page(hw, HV_MCC_LOWER, &phy_data);
4451 hw->phy.ops.read_reg_page(hw, HV_LATECOL_UPPER, &phy_data);
4452 hw->phy.ops.read_reg_page(hw, HV_LATECOL_LOWER, &phy_data);
4453 hw->phy.ops.read_reg_page(hw, HV_COLC_UPPER, &phy_data);
4454 hw->phy.ops.read_reg_page(hw, HV_COLC_LOWER, &phy_data);
4455 hw->phy.ops.read_reg_page(hw, HV_DC_UPPER, &phy_data);
4456 hw->phy.ops.read_reg_page(hw, HV_DC_LOWER, &phy_data);
4457 hw->phy.ops.read_reg_page(hw, HV_TNCRS_UPPER, &phy_data);
4458 hw->phy.ops.read_reg_page(hw, HV_TNCRS_LOWER, &phy_data);
4459release:
4460 hw->phy.ops.release(hw);
Bruce Allana4f58f52009-06-02 11:29:18 +00004461 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07004462}
4463
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00004464static const struct e1000_mac_operations ich8_mac_ops = {
Bruce Allaneb7700d2010-06-16 13:27:05 +00004465 /* check_mng_mode dependent on mac type */
Bruce Allan7d3cabb2009-07-01 13:29:08 +00004466 .check_for_link = e1000_check_for_copper_link_ich8lan,
Bruce Allana4f58f52009-06-02 11:29:18 +00004467 /* cleanup_led dependent on mac type */
Auke Kokbc7f75f2007-09-17 12:30:59 -07004468 .clear_hw_cntrs = e1000_clear_hw_cntrs_ich8lan,
4469 .get_bus_info = e1000_get_bus_info_ich8lan,
Bruce Allanf4d2dd42010-01-13 02:05:18 +00004470 .set_lan_id = e1000_set_lan_id_single_port,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004471 .get_link_up_info = e1000_get_link_up_info_ich8lan,
Bruce Allana4f58f52009-06-02 11:29:18 +00004472 /* led_on dependent on mac type */
4473 /* led_off dependent on mac type */
Jeff Kirshere2de3eb2008-03-28 09:15:11 -07004474 .update_mc_addr_list = e1000e_update_mc_addr_list_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004475 .reset_hw = e1000_reset_hw_ich8lan,
4476 .init_hw = e1000_init_hw_ich8lan,
4477 .setup_link = e1000_setup_link_ich8lan,
4478 .setup_physical_interface= e1000_setup_copper_link_ich8lan,
Bruce Allana4f58f52009-06-02 11:29:18 +00004479 /* id_led_init dependent on mac type */
Bruce Allan57cde762012-02-22 09:02:58 +00004480 .config_collision_dist = e1000e_config_collision_dist_generic,
Bruce Allan69e1e012012-04-14 03:28:50 +00004481 .rar_set = e1000e_rar_set_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004482};
4483
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00004484static const struct e1000_phy_operations ich8_phy_ops = {
Bruce Allan94d81862009-11-20 23:25:26 +00004485 .acquire = e1000_acquire_swflag_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004486 .check_reset_block = e1000_check_reset_block_ich8lan,
Bruce Allan94d81862009-11-20 23:25:26 +00004487 .commit = NULL,
Bruce Allanf4187b52008-08-26 18:36:50 -07004488 .get_cfg_done = e1000_get_cfg_done_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004489 .get_cable_length = e1000e_get_cable_length_igp_2,
Bruce Allan94d81862009-11-20 23:25:26 +00004490 .read_reg = e1000e_read_phy_reg_igp,
4491 .release = e1000_release_swflag_ich8lan,
4492 .reset = e1000_phy_hw_reset_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004493 .set_d0_lplu_state = e1000_set_d0_lplu_state_ich8lan,
4494 .set_d3_lplu_state = e1000_set_d3_lplu_state_ich8lan,
Bruce Allan94d81862009-11-20 23:25:26 +00004495 .write_reg = e1000e_write_phy_reg_igp,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004496};
4497
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00004498static const struct e1000_nvm_operations ich8_nvm_ops = {
Bruce Allan94d81862009-11-20 23:25:26 +00004499 .acquire = e1000_acquire_nvm_ich8lan,
4500 .read = e1000_read_nvm_ich8lan,
4501 .release = e1000_release_nvm_ich8lan,
Bruce Allane85e3632012-02-22 09:03:14 +00004502 .reload = e1000e_reload_nvm_generic,
Bruce Allan94d81862009-11-20 23:25:26 +00004503 .update = e1000_update_nvm_checksum_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004504 .valid_led_default = e1000_valid_led_default_ich8lan,
Bruce Allan94d81862009-11-20 23:25:26 +00004505 .validate = e1000_validate_nvm_checksum_ich8lan,
4506 .write = e1000_write_nvm_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004507};
4508
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00004509const struct e1000_info e1000_ich8_info = {
Auke Kokbc7f75f2007-09-17 12:30:59 -07004510 .mac = e1000_ich8lan,
4511 .flags = FLAG_HAS_WOL
Bruce Allan97ac8ca2008-04-29 09:16:05 -07004512 | FLAG_IS_ICH
Auke Kokbc7f75f2007-09-17 12:30:59 -07004513 | FLAG_HAS_CTRLEXT_ON_LOAD
4514 | FLAG_HAS_AMT
4515 | FLAG_HAS_FLASH
4516 | FLAG_APME_IN_WUC,
4517 .pba = 8,
Bruce Allan2adc55c2009-06-02 11:28:58 +00004518 .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN,
Jeff Kirsher69e3fd82008-04-02 13:48:18 -07004519 .get_variants = e1000_get_variants_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004520 .mac_ops = &ich8_mac_ops,
4521 .phy_ops = &ich8_phy_ops,
4522 .nvm_ops = &ich8_nvm_ops,
4523};
4524
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00004525const struct e1000_info e1000_ich9_info = {
Auke Kokbc7f75f2007-09-17 12:30:59 -07004526 .mac = e1000_ich9lan,
4527 .flags = FLAG_HAS_JUMBO_FRAMES
Bruce Allan97ac8ca2008-04-29 09:16:05 -07004528 | FLAG_IS_ICH
Auke Kokbc7f75f2007-09-17 12:30:59 -07004529 | FLAG_HAS_WOL
Auke Kokbc7f75f2007-09-17 12:30:59 -07004530 | FLAG_HAS_CTRLEXT_ON_LOAD
4531 | FLAG_HAS_AMT
Auke Kokbc7f75f2007-09-17 12:30:59 -07004532 | FLAG_HAS_FLASH
4533 | FLAG_APME_IN_WUC,
Bruce Allan7f1557e2011-12-16 00:46:43 +00004534 .pba = 18,
Bruce Allan2adc55c2009-06-02 11:28:58 +00004535 .max_hw_frame_size = DEFAULT_JUMBO,
Jeff Kirsher69e3fd82008-04-02 13:48:18 -07004536 .get_variants = e1000_get_variants_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004537 .mac_ops = &ich8_mac_ops,
4538 .phy_ops = &ich8_phy_ops,
4539 .nvm_ops = &ich8_nvm_ops,
4540};
4541
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00004542const struct e1000_info e1000_ich10_info = {
Bruce Allanf4187b52008-08-26 18:36:50 -07004543 .mac = e1000_ich10lan,
4544 .flags = FLAG_HAS_JUMBO_FRAMES
4545 | FLAG_IS_ICH
4546 | FLAG_HAS_WOL
Bruce Allanf4187b52008-08-26 18:36:50 -07004547 | FLAG_HAS_CTRLEXT_ON_LOAD
4548 | FLAG_HAS_AMT
Bruce Allanf4187b52008-08-26 18:36:50 -07004549 | FLAG_HAS_FLASH
4550 | FLAG_APME_IN_WUC,
Bruce Allan7f1557e2011-12-16 00:46:43 +00004551 .pba = 18,
Bruce Allan2adc55c2009-06-02 11:28:58 +00004552 .max_hw_frame_size = DEFAULT_JUMBO,
Bruce Allanf4187b52008-08-26 18:36:50 -07004553 .get_variants = e1000_get_variants_ich8lan,
4554 .mac_ops = &ich8_mac_ops,
4555 .phy_ops = &ich8_phy_ops,
4556 .nvm_ops = &ich8_nvm_ops,
4557};
Bruce Allana4f58f52009-06-02 11:29:18 +00004558
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00004559const struct e1000_info e1000_pch_info = {
Bruce Allana4f58f52009-06-02 11:29:18 +00004560 .mac = e1000_pchlan,
4561 .flags = FLAG_IS_ICH
4562 | FLAG_HAS_WOL
Bruce Allana4f58f52009-06-02 11:29:18 +00004563 | FLAG_HAS_CTRLEXT_ON_LOAD
4564 | FLAG_HAS_AMT
4565 | FLAG_HAS_FLASH
4566 | FLAG_HAS_JUMBO_FRAMES
Bruce Allan38eb3942009-11-19 12:34:20 +00004567 | FLAG_DISABLE_FC_PAUSE_TIME /* errata */
Bruce Allana4f58f52009-06-02 11:29:18 +00004568 | FLAG_APME_IN_WUC,
Bruce Allan8c7bbb92010-06-16 13:26:41 +00004569 .flags2 = FLAG2_HAS_PHY_STATS,
Bruce Allana4f58f52009-06-02 11:29:18 +00004570 .pba = 26,
4571 .max_hw_frame_size = 4096,
4572 .get_variants = e1000_get_variants_ich8lan,
4573 .mac_ops = &ich8_mac_ops,
4574 .phy_ops = &ich8_phy_ops,
4575 .nvm_ops = &ich8_nvm_ops,
4576};
Bruce Alland3738bb2010-06-16 13:27:28 +00004577
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00004578const struct e1000_info e1000_pch2_info = {
Bruce Alland3738bb2010-06-16 13:27:28 +00004579 .mac = e1000_pch2lan,
4580 .flags = FLAG_IS_ICH
4581 | FLAG_HAS_WOL
Bruce Alland3738bb2010-06-16 13:27:28 +00004582 | FLAG_HAS_CTRLEXT_ON_LOAD
4583 | FLAG_HAS_AMT
4584 | FLAG_HAS_FLASH
4585 | FLAG_HAS_JUMBO_FRAMES
4586 | FLAG_APME_IN_WUC,
Bruce Allane52997f2010-06-16 13:27:49 +00004587 .flags2 = FLAG2_HAS_PHY_STATS
4588 | FLAG2_HAS_EEE,
Bruce Allan828bac82010-09-29 21:39:37 +00004589 .pba = 26,
Bruce Alland3738bb2010-06-16 13:27:28 +00004590 .max_hw_frame_size = DEFAULT_JUMBO,
4591 .get_variants = e1000_get_variants_ich8lan,
4592 .mac_ops = &ich8_mac_ops,
4593 .phy_ops = &ich8_phy_ops,
4594 .nvm_ops = &ich8_nvm_ops,
4595};
Bruce Allan2fbe4522012-04-19 03:21:47 +00004596
4597const struct e1000_info e1000_pch_lpt_info = {
4598 .mac = e1000_pch_lpt,
4599 .flags = FLAG_IS_ICH
4600 | FLAG_HAS_WOL
4601 | FLAG_HAS_CTRLEXT_ON_LOAD
4602 | FLAG_HAS_AMT
4603 | FLAG_HAS_FLASH
4604 | FLAG_HAS_JUMBO_FRAMES
4605 | FLAG_APME_IN_WUC,
4606 .flags2 = FLAG2_HAS_PHY_STATS
4607 | FLAG2_HAS_EEE,
4608 .pba = 26,
4609 .max_hw_frame_size = DEFAULT_JUMBO,
4610 .get_variants = e1000_get_variants_ich8lan,
4611 .mac_ops = &ich8_mac_ops,
4612 .phy_ops = &ich8_phy_ops,
4613 .nvm_ops = &ich8_nvm_ops,
4614};