blob: 7525e372720cfd6b2b9b1417de15cd1310a69d3e [file] [log] [blame]
Auke Kokbc7f75f2007-09-17 12:30:59 -07001/*******************************************************************************
2
3 Intel PRO/1000 Linux driver
Bruce Allan0d6057e2011-01-04 01:16:44 +00004 Copyright(c) 1999 - 2011 Intel Corporation.
Auke Kokbc7f75f2007-09-17 12:30:59 -07005
6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License,
8 version 2, as published by the Free Software Foundation.
9
10 This program is distributed in the hope it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 more details.
14
15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
21
22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
27*******************************************************************************/
28
29/*
Bruce Allan16059272008-11-21 16:51:06 -080030 * 82562G 10/100 Network Connection
Auke Kokbc7f75f2007-09-17 12:30:59 -070031 * 82562G-2 10/100 Network Connection
32 * 82562GT 10/100 Network Connection
33 * 82562GT-2 10/100 Network Connection
34 * 82562V 10/100 Network Connection
35 * 82562V-2 10/100 Network Connection
36 * 82566DC-2 Gigabit Network Connection
37 * 82566DC Gigabit Network Connection
38 * 82566DM-2 Gigabit Network Connection
39 * 82566DM Gigabit Network Connection
40 * 82566MC Gigabit Network Connection
41 * 82566MM Gigabit Network Connection
Bruce Allan97ac8ca2008-04-29 09:16:05 -070042 * 82567LM Gigabit Network Connection
43 * 82567LF Gigabit Network Connection
Bruce Allan16059272008-11-21 16:51:06 -080044 * 82567V Gigabit Network Connection
Bruce Allan97ac8ca2008-04-29 09:16:05 -070045 * 82567LM-2 Gigabit Network Connection
46 * 82567LF-2 Gigabit Network Connection
47 * 82567V-2 Gigabit Network Connection
Bruce Allanf4187b52008-08-26 18:36:50 -070048 * 82567LF-3 Gigabit Network Connection
49 * 82567LM-3 Gigabit Network Connection
Bruce Allan2f15f9d2008-08-26 18:36:36 -070050 * 82567LM-4 Gigabit Network Connection
Bruce Allana4f58f52009-06-02 11:29:18 +000051 * 82577LM Gigabit Network Connection
52 * 82577LC Gigabit Network Connection
53 * 82578DM Gigabit Network Connection
54 * 82578DC Gigabit Network Connection
Bruce Alland3738bb2010-06-16 13:27:28 +000055 * 82579LM Gigabit Network Connection
56 * 82579V Gigabit Network Connection
Auke Kokbc7f75f2007-09-17 12:30:59 -070057 */
58
Auke Kokbc7f75f2007-09-17 12:30:59 -070059#include "e1000.h"
60
61#define ICH_FLASH_GFPREG 0x0000
62#define ICH_FLASH_HSFSTS 0x0004
63#define ICH_FLASH_HSFCTL 0x0006
64#define ICH_FLASH_FADDR 0x0008
65#define ICH_FLASH_FDATA0 0x0010
Bruce Allan4a770352008-10-01 17:18:35 -070066#define ICH_FLASH_PR0 0x0074
Auke Kokbc7f75f2007-09-17 12:30:59 -070067
68#define ICH_FLASH_READ_COMMAND_TIMEOUT 500
69#define ICH_FLASH_WRITE_COMMAND_TIMEOUT 500
70#define ICH_FLASH_ERASE_COMMAND_TIMEOUT 3000000
71#define ICH_FLASH_LINEAR_ADDR_MASK 0x00FFFFFF
72#define ICH_FLASH_CYCLE_REPEAT_COUNT 10
73
74#define ICH_CYCLE_READ 0
75#define ICH_CYCLE_WRITE 2
76#define ICH_CYCLE_ERASE 3
77
78#define FLASH_GFPREG_BASE_MASK 0x1FFF
79#define FLASH_SECTOR_ADDR_SHIFT 12
80
81#define ICH_FLASH_SEG_SIZE_256 256
82#define ICH_FLASH_SEG_SIZE_4K 4096
83#define ICH_FLASH_SEG_SIZE_8K 8192
84#define ICH_FLASH_SEG_SIZE_64K 65536
85
86
87#define E1000_ICH_FWSM_RSPCIPHY 0x00000040 /* Reset PHY on PCI Reset */
Bruce Allan6dfaa762010-05-05 22:00:06 +000088/* FW established a valid mode */
89#define E1000_ICH_FWSM_FW_VALID 0x00008000
Auke Kokbc7f75f2007-09-17 12:30:59 -070090
91#define E1000_ICH_MNG_IAMT_MODE 0x2
92
93#define ID_LED_DEFAULT_ICH8LAN ((ID_LED_DEF1_DEF2 << 12) | \
94 (ID_LED_DEF1_OFF2 << 8) | \
95 (ID_LED_DEF1_ON2 << 4) | \
96 (ID_LED_DEF1_DEF2))
97
98#define E1000_ICH_NVM_SIG_WORD 0x13
99#define E1000_ICH_NVM_SIG_MASK 0xC000
Bruce Allane2434552008-11-21 17:02:41 -0800100#define E1000_ICH_NVM_VALID_SIG_MASK 0xC0
101#define E1000_ICH_NVM_SIG_VALUE 0x80
Auke Kokbc7f75f2007-09-17 12:30:59 -0700102
103#define E1000_ICH8_LAN_INIT_TIMEOUT 1500
104
105#define E1000_FEXTNVM_SW_CONFIG 1
106#define E1000_FEXTNVM_SW_CONFIG_ICH8M (1 << 27) /* Bit redefined for ICH8M :/ */
107
Bruce Allan831bd2e2010-09-22 17:16:18 +0000108#define E1000_FEXTNVM4_BEACON_DURATION_MASK 0x7
109#define E1000_FEXTNVM4_BEACON_DURATION_8USEC 0x7
110#define E1000_FEXTNVM4_BEACON_DURATION_16USEC 0x3
111
Auke Kokbc7f75f2007-09-17 12:30:59 -0700112#define PCIE_ICH8_SNOOP_ALL PCIE_NO_SNOOP_ALL
113
114#define E1000_ICH_RAR_ENTRIES 7
115
116#define PHY_PAGE_SHIFT 5
117#define PHY_REG(page, reg) (((page) << PHY_PAGE_SHIFT) | \
118 ((reg) & MAX_PHY_REG_ADDRESS))
119#define IGP3_KMRN_DIAG PHY_REG(770, 19) /* KMRN Diagnostic */
120#define IGP3_VR_CTRL PHY_REG(776, 18) /* Voltage Regulator Control */
121
122#define IGP3_KMRN_DIAG_PCS_LOCK_LOSS 0x0002
123#define IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK 0x0300
124#define IGP3_VR_CTRL_MODE_SHUTDOWN 0x0200
125
Bruce Allana4f58f52009-06-02 11:29:18 +0000126#define HV_LED_CONFIG PHY_REG(768, 30) /* LED Configuration */
127
Bruce Allan53ac5a82009-10-26 11:23:06 +0000128#define SW_FLAG_TIMEOUT 1000 /* SW Semaphore flag timeout in milliseconds */
129
Bruce Allanf523d212009-10-29 13:45:45 +0000130/* SMBus Address Phy Register */
131#define HV_SMB_ADDR PHY_REG(768, 26)
Bruce Allan8395ae82010-09-22 17:15:08 +0000132#define HV_SMB_ADDR_MASK 0x007F
Bruce Allanf523d212009-10-29 13:45:45 +0000133#define HV_SMB_ADDR_PEC_EN 0x0200
134#define HV_SMB_ADDR_VALID 0x0080
135
Bruce Alland3738bb2010-06-16 13:27:28 +0000136/* PHY Power Management Control */
137#define HV_PM_CTRL PHY_REG(770, 17)
138
Bruce Allane52997f2010-06-16 13:27:49 +0000139/* PHY Low Power Idle Control */
140#define I82579_LPI_CTRL PHY_REG(772, 20)
141#define I82579_LPI_CTRL_ENABLE_MASK 0x6000
142
Bruce Allan1effb452011-02-25 06:58:03 +0000143/* EMI Registers */
144#define I82579_EMI_ADDR 0x10
145#define I82579_EMI_DATA 0x11
146#define I82579_LPI_UPDATE_TIMER 0x4805 /* in 40ns units + 40 ns base value */
147
Bruce Allanf523d212009-10-29 13:45:45 +0000148/* Strapping Option Register - RO */
149#define E1000_STRAP 0x0000C
150#define E1000_STRAP_SMBUS_ADDRESS_MASK 0x00FE0000
151#define E1000_STRAP_SMBUS_ADDRESS_SHIFT 17
152
Bruce Allanfa2ce132009-10-26 11:23:25 +0000153/* OEM Bits Phy Register */
154#define HV_OEM_BITS PHY_REG(768, 25)
155#define HV_OEM_BITS_LPLU 0x0004 /* Low Power Link Up */
Bruce Allanf523d212009-10-29 13:45:45 +0000156#define HV_OEM_BITS_GBE_DIS 0x0040 /* Gigabit Disable */
Bruce Allanfa2ce132009-10-26 11:23:25 +0000157#define HV_OEM_BITS_RESTART_AN 0x0400 /* Restart Auto-negotiation */
158
Bruce Allan1d5846b2009-10-29 13:46:05 +0000159#define E1000_NVM_K1_CONFIG 0x1B /* NVM K1 Config Word */
160#define E1000_NVM_K1_ENABLE 0x1 /* NVM Enable K1 bit */
161
Bruce Allanfddaa1a2010-01-13 01:52:49 +0000162/* KMRN Mode Control */
163#define HV_KMRN_MODE_CTRL PHY_REG(769, 16)
164#define HV_KMRN_MDIO_SLOW 0x0400
165
Bruce Allan1d2101a2011-07-22 06:21:56 +0000166/* KMRN FIFO Control and Status */
167#define HV_KMRN_FIFO_CTRLSTA PHY_REG(770, 16)
168#define HV_KMRN_FIFO_CTRLSTA_PREAMBLE_MASK 0x7000
169#define HV_KMRN_FIFO_CTRLSTA_PREAMBLE_SHIFT 12
170
Auke Kokbc7f75f2007-09-17 12:30:59 -0700171/* ICH GbE Flash Hardware Sequencing Flash Status Register bit breakdown */
172/* Offset 04h HSFSTS */
173union ich8_hws_flash_status {
174 struct ich8_hsfsts {
175 u16 flcdone :1; /* bit 0 Flash Cycle Done */
176 u16 flcerr :1; /* bit 1 Flash Cycle Error */
177 u16 dael :1; /* bit 2 Direct Access error Log */
178 u16 berasesz :2; /* bit 4:3 Sector Erase Size */
179 u16 flcinprog :1; /* bit 5 flash cycle in Progress */
180 u16 reserved1 :2; /* bit 13:6 Reserved */
181 u16 reserved2 :6; /* bit 13:6 Reserved */
182 u16 fldesvalid :1; /* bit 14 Flash Descriptor Valid */
183 u16 flockdn :1; /* bit 15 Flash Config Lock-Down */
184 } hsf_status;
185 u16 regval;
186};
187
188/* ICH GbE Flash Hardware Sequencing Flash control Register bit breakdown */
189/* Offset 06h FLCTL */
190union ich8_hws_flash_ctrl {
191 struct ich8_hsflctl {
192 u16 flcgo :1; /* 0 Flash Cycle Go */
193 u16 flcycle :2; /* 2:1 Flash Cycle */
194 u16 reserved :5; /* 7:3 Reserved */
195 u16 fldbcount :2; /* 9:8 Flash Data Byte Count */
196 u16 flockdn :6; /* 15:10 Reserved */
197 } hsf_ctrl;
198 u16 regval;
199};
200
201/* ICH Flash Region Access Permissions */
202union ich8_hws_flash_regacc {
203 struct ich8_flracc {
204 u32 grra :8; /* 0:7 GbE region Read Access */
205 u32 grwa :8; /* 8:15 GbE region Write Access */
206 u32 gmrag :8; /* 23:16 GbE Master Read Access Grant */
207 u32 gmwag :8; /* 31:24 GbE Master Write Access Grant */
208 } hsf_flregacc;
209 u16 regval;
210};
211
Bruce Allan4a770352008-10-01 17:18:35 -0700212/* ICH Flash Protected Region */
213union ich8_flash_protected_range {
214 struct ich8_pr {
215 u32 base:13; /* 0:12 Protected Range Base */
216 u32 reserved1:2; /* 13:14 Reserved */
217 u32 rpe:1; /* 15 Read Protection Enable */
218 u32 limit:13; /* 16:28 Protected Range Limit */
219 u32 reserved2:2; /* 29:30 Reserved */
220 u32 wpe:1; /* 31 Write Protection Enable */
221 } range;
222 u32 regval;
223};
224
Auke Kokbc7f75f2007-09-17 12:30:59 -0700225static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw);
226static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw);
227static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700228static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank);
229static s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw,
230 u32 offset, u8 byte);
Bruce Allanf4187b52008-08-26 18:36:50 -0700231static s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
232 u8 *data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700233static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset,
234 u16 *data);
235static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
236 u8 size, u16 *data);
237static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw);
238static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw);
Bruce Allanf4187b52008-08-26 18:36:50 -0700239static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw);
Bruce Allana4f58f52009-06-02 11:29:18 +0000240static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw);
241static s32 e1000_led_on_ich8lan(struct e1000_hw *hw);
242static s32 e1000_led_off_ich8lan(struct e1000_hw *hw);
243static s32 e1000_id_led_init_pchlan(struct e1000_hw *hw);
244static s32 e1000_setup_led_pchlan(struct e1000_hw *hw);
245static s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw);
246static s32 e1000_led_on_pchlan(struct e1000_hw *hw);
247static s32 e1000_led_off_pchlan(struct e1000_hw *hw);
Bruce Allanfa2ce132009-10-26 11:23:25 +0000248static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active);
Bruce Allan17f208d2009-12-01 15:47:22 +0000249static void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw);
Bruce Allanf523d212009-10-29 13:45:45 +0000250static void e1000_lan_init_done_ich8lan(struct e1000_hw *hw);
Bruce Allan1d5846b2009-10-29 13:46:05 +0000251static s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link);
Bruce Allanfddaa1a2010-01-13 01:52:49 +0000252static s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw);
Bruce Allaneb7700d2010-06-16 13:27:05 +0000253static bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw);
254static bool e1000_check_mng_mode_pchlan(struct e1000_hw *hw);
Bruce Allan831bd2e2010-09-22 17:16:18 +0000255static s32 e1000_k1_workaround_lv(struct e1000_hw *hw);
Bruce Allan605c82b2010-09-22 17:17:01 +0000256static void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700257
258static inline u16 __er16flash(struct e1000_hw *hw, unsigned long reg)
259{
260 return readw(hw->flash_address + reg);
261}
262
263static inline u32 __er32flash(struct e1000_hw *hw, unsigned long reg)
264{
265 return readl(hw->flash_address + reg);
266}
267
268static inline void __ew16flash(struct e1000_hw *hw, unsigned long reg, u16 val)
269{
270 writew(val, hw->flash_address + reg);
271}
272
273static inline void __ew32flash(struct e1000_hw *hw, unsigned long reg, u32 val)
274{
275 writel(val, hw->flash_address + reg);
276}
277
278#define er16flash(reg) __er16flash(hw, (reg))
279#define er32flash(reg) __er32flash(hw, (reg))
280#define ew16flash(reg,val) __ew16flash(hw, (reg), (val))
281#define ew32flash(reg,val) __ew32flash(hw, (reg), (val))
282
Bruce Allan99730e42011-05-13 07:19:48 +0000283static void e1000_toggle_lanphypc_value_ich8lan(struct e1000_hw *hw)
284{
285 u32 ctrl;
286
287 ctrl = er32(CTRL);
288 ctrl |= E1000_CTRL_LANPHYPC_OVERRIDE;
289 ctrl &= ~E1000_CTRL_LANPHYPC_VALUE;
290 ew32(CTRL, ctrl);
Jesse Brandeburg945a5152011-07-20 00:56:21 +0000291 e1e_flush();
Bruce Allan99730e42011-05-13 07:19:48 +0000292 udelay(10);
293 ctrl &= ~E1000_CTRL_LANPHYPC_OVERRIDE;
294 ew32(CTRL, ctrl);
295}
296
Auke Kokbc7f75f2007-09-17 12:30:59 -0700297/**
Bruce Allana4f58f52009-06-02 11:29:18 +0000298 * e1000_init_phy_params_pchlan - Initialize PHY function pointers
299 * @hw: pointer to the HW structure
300 *
301 * Initialize family-specific PHY parameters and function pointers.
302 **/
303static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw)
304{
305 struct e1000_phy_info *phy = &hw->phy;
Bruce Allan99730e42011-05-13 07:19:48 +0000306 u32 fwsm;
Bruce Allana4f58f52009-06-02 11:29:18 +0000307 s32 ret_val = 0;
308
309 phy->addr = 1;
310 phy->reset_delay_us = 100;
311
Bruce Allan2b6b1682011-05-13 07:20:09 +0000312 phy->ops.set_page = e1000_set_page_igp;
Bruce Allan94d81862009-11-20 23:25:26 +0000313 phy->ops.read_reg = e1000_read_phy_reg_hv;
314 phy->ops.read_reg_locked = e1000_read_phy_reg_hv_locked;
Bruce Allan2b6b1682011-05-13 07:20:09 +0000315 phy->ops.read_reg_page = e1000_read_phy_reg_page_hv;
Bruce Allanfa2ce132009-10-26 11:23:25 +0000316 phy->ops.set_d0_lplu_state = e1000_set_lplu_state_pchlan;
317 phy->ops.set_d3_lplu_state = e1000_set_lplu_state_pchlan;
Bruce Allan94d81862009-11-20 23:25:26 +0000318 phy->ops.write_reg = e1000_write_phy_reg_hv;
319 phy->ops.write_reg_locked = e1000_write_phy_reg_hv_locked;
Bruce Allan2b6b1682011-05-13 07:20:09 +0000320 phy->ops.write_reg_page = e1000_write_phy_reg_page_hv;
Bruce Allan17f208d2009-12-01 15:47:22 +0000321 phy->ops.power_up = e1000_power_up_phy_copper;
322 phy->ops.power_down = e1000_power_down_phy_copper_ich8lan;
Bruce Allana4f58f52009-06-02 11:29:18 +0000323 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
324
Bruce Alland3738bb2010-06-16 13:27:28 +0000325 /*
326 * The MAC-PHY interconnect may still be in SMBus mode
327 * after Sx->S0. If the manageability engine (ME) is
328 * disabled, then toggle the LANPHYPC Value bit to force
329 * the interconnect to PCIe mode.
330 */
Bruce Allan605c82b2010-09-22 17:17:01 +0000331 fwsm = er32(FWSM);
Bruce Allan6cc7aae2011-02-25 06:25:18 +0000332 if (!(fwsm & E1000_ICH_FWSM_FW_VALID) && !e1000_check_reset_block(hw)) {
Bruce Allan99730e42011-05-13 07:19:48 +0000333 e1000_toggle_lanphypc_value_ich8lan(hw);
Bruce Allan6dfaa762010-05-05 22:00:06 +0000334 msleep(50);
Bruce Allan605c82b2010-09-22 17:17:01 +0000335
336 /*
337 * Gate automatic PHY configuration by hardware on
338 * non-managed 82579
339 */
340 if (hw->mac.type == e1000_pch2lan)
341 e1000_gate_hw_phy_config_ich8lan(hw, true);
Bruce Allan6dfaa762010-05-05 22:00:06 +0000342 }
343
Bruce Allan627c8a02010-05-05 22:00:27 +0000344 /*
Uwe Kleine-Königb5950762010-11-01 15:38:34 -0400345 * Reset the PHY before any access to it. Doing so, ensures that
Bruce Allan627c8a02010-05-05 22:00:27 +0000346 * the PHY is in a known good state before we read/write PHY registers.
347 * The generic reset is sufficient here, because we haven't determined
348 * the PHY type yet.
349 */
350 ret_val = e1000e_phy_hw_reset_generic(hw);
351 if (ret_val)
352 goto out;
353
Bruce Allan605c82b2010-09-22 17:17:01 +0000354 /* Ungate automatic PHY configuration on non-managed 82579 */
Bruce Allan6cc7aae2011-02-25 06:25:18 +0000355 if ((hw->mac.type == e1000_pch2lan) &&
Bruce Allan605c82b2010-09-22 17:17:01 +0000356 !(fwsm & E1000_ICH_FWSM_FW_VALID)) {
Bruce Allan1bba4382011-03-19 00:27:20 +0000357 usleep_range(10000, 20000);
Bruce Allan605c82b2010-09-22 17:17:01 +0000358 e1000_gate_hw_phy_config_ich8lan(hw, false);
359 }
360
Bruce Allana4f58f52009-06-02 11:29:18 +0000361 phy->id = e1000_phy_unknown;
Bruce Allan664dc872010-11-24 06:01:46 +0000362 switch (hw->mac.type) {
363 default:
364 ret_val = e1000e_get_phy_id(hw);
365 if (ret_val)
366 goto out;
367 if ((phy->id != 0) && (phy->id != PHY_REVISION_MASK))
368 break;
369 /* fall-through */
370 case e1000_pch2lan:
Bruce Allanfddaa1a2010-01-13 01:52:49 +0000371 /*
Bruce Allan664dc872010-11-24 06:01:46 +0000372 * In case the PHY needs to be in mdio slow mode,
Bruce Allanfddaa1a2010-01-13 01:52:49 +0000373 * set slow mode and try to get the PHY id again.
374 */
375 ret_val = e1000_set_mdio_slow_mode_hv(hw);
376 if (ret_val)
377 goto out;
378 ret_val = e1000e_get_phy_id(hw);
379 if (ret_val)
380 goto out;
Bruce Allan664dc872010-11-24 06:01:46 +0000381 break;
Bruce Allanfddaa1a2010-01-13 01:52:49 +0000382 }
Bruce Allana4f58f52009-06-02 11:29:18 +0000383 phy->type = e1000e_get_phy_type_from_id(phy->id);
384
Bruce Allan0be84012009-12-02 17:03:18 +0000385 switch (phy->type) {
386 case e1000_phy_82577:
Bruce Alland3738bb2010-06-16 13:27:28 +0000387 case e1000_phy_82579:
Bruce Allana4f58f52009-06-02 11:29:18 +0000388 phy->ops.check_polarity = e1000_check_polarity_82577;
389 phy->ops.force_speed_duplex =
Bruce Allan6cc7aae2011-02-25 06:25:18 +0000390 e1000_phy_force_speed_duplex_82577;
Bruce Allan0be84012009-12-02 17:03:18 +0000391 phy->ops.get_cable_length = e1000_get_cable_length_82577;
Bruce Allan94d81862009-11-20 23:25:26 +0000392 phy->ops.get_info = e1000_get_phy_info_82577;
393 phy->ops.commit = e1000e_phy_sw_reset;
Bruce Allaneab50ff2010-05-10 15:01:30 +0000394 break;
Bruce Allan0be84012009-12-02 17:03:18 +0000395 case e1000_phy_82578:
396 phy->ops.check_polarity = e1000_check_polarity_m88;
397 phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_m88;
398 phy->ops.get_cable_length = e1000e_get_cable_length_m88;
399 phy->ops.get_info = e1000e_get_phy_info_m88;
400 break;
401 default:
402 ret_val = -E1000_ERR_PHY;
403 break;
Bruce Allana4f58f52009-06-02 11:29:18 +0000404 }
405
Bruce Allanfddaa1a2010-01-13 01:52:49 +0000406out:
Bruce Allana4f58f52009-06-02 11:29:18 +0000407 return ret_val;
408}
409
410/**
Auke Kokbc7f75f2007-09-17 12:30:59 -0700411 * e1000_init_phy_params_ich8lan - Initialize PHY function pointers
412 * @hw: pointer to the HW structure
413 *
414 * Initialize family-specific PHY parameters and function pointers.
415 **/
416static s32 e1000_init_phy_params_ich8lan(struct e1000_hw *hw)
417{
418 struct e1000_phy_info *phy = &hw->phy;
419 s32 ret_val;
420 u16 i = 0;
421
422 phy->addr = 1;
423 phy->reset_delay_us = 100;
424
Bruce Allan17f208d2009-12-01 15:47:22 +0000425 phy->ops.power_up = e1000_power_up_phy_copper;
426 phy->ops.power_down = e1000_power_down_phy_copper_ich8lan;
427
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700428 /*
429 * We may need to do this twice - once for IGP and if that fails,
430 * we'll set BM func pointers and try again
431 */
432 ret_val = e1000e_determine_phy_address(hw);
433 if (ret_val) {
Bruce Allan94d81862009-11-20 23:25:26 +0000434 phy->ops.write_reg = e1000e_write_phy_reg_bm;
435 phy->ops.read_reg = e1000e_read_phy_reg_bm;
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700436 ret_val = e1000e_determine_phy_address(hw);
Bruce Allan9b71b412009-12-01 15:53:07 +0000437 if (ret_val) {
438 e_dbg("Cannot determine PHY addr. Erroring out\n");
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700439 return ret_val;
Bruce Allan9b71b412009-12-01 15:53:07 +0000440 }
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700441 }
442
Auke Kokbc7f75f2007-09-17 12:30:59 -0700443 phy->id = 0;
444 while ((e1000_phy_unknown == e1000e_get_phy_type_from_id(phy->id)) &&
445 (i++ < 100)) {
Bruce Allan1bba4382011-03-19 00:27:20 +0000446 usleep_range(1000, 2000);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700447 ret_val = e1000e_get_phy_id(hw);
448 if (ret_val)
449 return ret_val;
450 }
451
452 /* Verify phy id */
453 switch (phy->id) {
454 case IGP03E1000_E_PHY_ID:
455 phy->type = e1000_phy_igp_3;
456 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
Bruce Allan94d81862009-11-20 23:25:26 +0000457 phy->ops.read_reg_locked = e1000e_read_phy_reg_igp_locked;
458 phy->ops.write_reg_locked = e1000e_write_phy_reg_igp_locked;
Bruce Allan0be84012009-12-02 17:03:18 +0000459 phy->ops.get_info = e1000e_get_phy_info_igp;
460 phy->ops.check_polarity = e1000_check_polarity_igp;
461 phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_igp;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700462 break;
463 case IFE_E_PHY_ID:
464 case IFE_PLUS_E_PHY_ID:
465 case IFE_C_E_PHY_ID:
466 phy->type = e1000_phy_ife;
467 phy->autoneg_mask = E1000_ALL_NOT_GIG;
Bruce Allan0be84012009-12-02 17:03:18 +0000468 phy->ops.get_info = e1000_get_phy_info_ife;
469 phy->ops.check_polarity = e1000_check_polarity_ife;
470 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_ife;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700471 break;
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700472 case BME1000_E_PHY_ID:
473 phy->type = e1000_phy_bm;
474 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
Bruce Allan94d81862009-11-20 23:25:26 +0000475 phy->ops.read_reg = e1000e_read_phy_reg_bm;
476 phy->ops.write_reg = e1000e_write_phy_reg_bm;
477 phy->ops.commit = e1000e_phy_sw_reset;
Bruce Allan0be84012009-12-02 17:03:18 +0000478 phy->ops.get_info = e1000e_get_phy_info_m88;
479 phy->ops.check_polarity = e1000_check_polarity_m88;
480 phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_m88;
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700481 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700482 default:
483 return -E1000_ERR_PHY;
484 break;
485 }
486
487 return 0;
488}
489
490/**
491 * e1000_init_nvm_params_ich8lan - Initialize NVM function pointers
492 * @hw: pointer to the HW structure
493 *
494 * Initialize family-specific NVM parameters and function
495 * pointers.
496 **/
497static s32 e1000_init_nvm_params_ich8lan(struct e1000_hw *hw)
498{
499 struct e1000_nvm_info *nvm = &hw->nvm;
500 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
Bruce Allan148675a2009-08-07 07:41:56 +0000501 u32 gfpreg, sector_base_addr, sector_end_addr;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700502 u16 i;
503
Bruce Allanad680762008-03-28 09:15:03 -0700504 /* Can't read flash registers if the register set isn't mapped. */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700505 if (!hw->flash_address) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000506 e_dbg("ERROR: Flash registers not mapped\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700507 return -E1000_ERR_CONFIG;
508 }
509
510 nvm->type = e1000_nvm_flash_sw;
511
512 gfpreg = er32flash(ICH_FLASH_GFPREG);
513
Bruce Allanad680762008-03-28 09:15:03 -0700514 /*
515 * sector_X_addr is a "sector"-aligned address (4096 bytes)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700516 * Add 1 to sector_end_addr since this sector is included in
Bruce Allanad680762008-03-28 09:15:03 -0700517 * the overall size.
518 */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700519 sector_base_addr = gfpreg & FLASH_GFPREG_BASE_MASK;
520 sector_end_addr = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK) + 1;
521
522 /* flash_base_addr is byte-aligned */
523 nvm->flash_base_addr = sector_base_addr << FLASH_SECTOR_ADDR_SHIFT;
524
Bruce Allanad680762008-03-28 09:15:03 -0700525 /*
526 * find total size of the NVM, then cut in half since the total
527 * size represents two separate NVM banks.
528 */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700529 nvm->flash_bank_size = (sector_end_addr - sector_base_addr)
530 << FLASH_SECTOR_ADDR_SHIFT;
531 nvm->flash_bank_size /= 2;
532 /* Adjust to word count */
533 nvm->flash_bank_size /= sizeof(u16);
534
535 nvm->word_size = E1000_ICH8_SHADOW_RAM_WORDS;
536
537 /* Clear shadow ram */
538 for (i = 0; i < nvm->word_size; i++) {
Bruce Allan564ea9b2009-11-20 23:26:44 +0000539 dev_spec->shadow_ram[i].modified = false;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700540 dev_spec->shadow_ram[i].value = 0xFFFF;
541 }
542
543 return 0;
544}
545
546/**
547 * e1000_init_mac_params_ich8lan - Initialize MAC function pointers
548 * @hw: pointer to the HW structure
549 *
550 * Initialize family-specific MAC parameters and function
551 * pointers.
552 **/
553static s32 e1000_init_mac_params_ich8lan(struct e1000_adapter *adapter)
554{
555 struct e1000_hw *hw = &adapter->hw;
556 struct e1000_mac_info *mac = &hw->mac;
557
558 /* Set media type function pointer */
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700559 hw->phy.media_type = e1000_media_type_copper;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700560
561 /* Set mta register count */
562 mac->mta_reg_count = 32;
563 /* Set rar entry count */
564 mac->rar_entry_count = E1000_ICH_RAR_ENTRIES;
565 if (mac->type == e1000_ich8lan)
566 mac->rar_entry_count--;
Bruce Allana65a4a02010-05-10 15:01:51 +0000567 /* FWSM register */
568 mac->has_fwsm = true;
569 /* ARC subsystem not supported */
570 mac->arc_subsystem_valid = false;
Bruce Allanf464ba82010-01-07 16:31:35 +0000571 /* Adaptive IFS supported */
572 mac->adaptive_ifs = true;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700573
Bruce Allana4f58f52009-06-02 11:29:18 +0000574 /* LED operations */
575 switch (mac->type) {
576 case e1000_ich8lan:
577 case e1000_ich9lan:
578 case e1000_ich10lan:
Bruce Allaneb7700d2010-06-16 13:27:05 +0000579 /* check management mode */
580 mac->ops.check_mng_mode = e1000_check_mng_mode_ich8lan;
Bruce Allana4f58f52009-06-02 11:29:18 +0000581 /* ID LED init */
582 mac->ops.id_led_init = e1000e_id_led_init;
Bruce Allandbf80dc2011-04-16 00:34:40 +0000583 /* blink LED */
584 mac->ops.blink_led = e1000e_blink_led_generic;
Bruce Allana4f58f52009-06-02 11:29:18 +0000585 /* setup LED */
586 mac->ops.setup_led = e1000e_setup_led_generic;
587 /* cleanup LED */
588 mac->ops.cleanup_led = e1000_cleanup_led_ich8lan;
589 /* turn on/off LED */
590 mac->ops.led_on = e1000_led_on_ich8lan;
591 mac->ops.led_off = e1000_led_off_ich8lan;
592 break;
593 case e1000_pchlan:
Bruce Alland3738bb2010-06-16 13:27:28 +0000594 case e1000_pch2lan:
Bruce Allaneb7700d2010-06-16 13:27:05 +0000595 /* check management mode */
596 mac->ops.check_mng_mode = e1000_check_mng_mode_pchlan;
Bruce Allana4f58f52009-06-02 11:29:18 +0000597 /* ID LED init */
598 mac->ops.id_led_init = e1000_id_led_init_pchlan;
599 /* setup LED */
600 mac->ops.setup_led = e1000_setup_led_pchlan;
601 /* cleanup LED */
602 mac->ops.cleanup_led = e1000_cleanup_led_pchlan;
603 /* turn on/off LED */
604 mac->ops.led_on = e1000_led_on_pchlan;
605 mac->ops.led_off = e1000_led_off_pchlan;
606 break;
607 default:
608 break;
609 }
610
Auke Kokbc7f75f2007-09-17 12:30:59 -0700611 /* Enable PCS Lock-loss workaround for ICH8 */
612 if (mac->type == e1000_ich8lan)
Bruce Allan564ea9b2009-11-20 23:26:44 +0000613 e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw, true);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700614
Bruce Allan605c82b2010-09-22 17:17:01 +0000615 /* Gate automatic PHY configuration by hardware on managed 82579 */
616 if ((mac->type == e1000_pch2lan) &&
617 (er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
618 e1000_gate_hw_phy_config_ich8lan(hw, true);
Bruce Alland3738bb2010-06-16 13:27:28 +0000619
Auke Kokbc7f75f2007-09-17 12:30:59 -0700620 return 0;
621}
622
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000623/**
Bruce Allane52997f2010-06-16 13:27:49 +0000624 * e1000_set_eee_pchlan - Enable/disable EEE support
625 * @hw: pointer to the HW structure
626 *
627 * Enable/disable EEE based on setting in dev_spec structure. The bits in
628 * the LPI Control register will remain set only if/when link is up.
629 **/
630static s32 e1000_set_eee_pchlan(struct e1000_hw *hw)
631{
632 s32 ret_val = 0;
633 u16 phy_reg;
634
635 if (hw->phy.type != e1000_phy_82579)
636 goto out;
637
638 ret_val = e1e_rphy(hw, I82579_LPI_CTRL, &phy_reg);
639 if (ret_val)
640 goto out;
641
642 if (hw->dev_spec.ich8lan.eee_disable)
643 phy_reg &= ~I82579_LPI_CTRL_ENABLE_MASK;
644 else
645 phy_reg |= I82579_LPI_CTRL_ENABLE_MASK;
646
647 ret_val = e1e_wphy(hw, I82579_LPI_CTRL, phy_reg);
648out:
649 return ret_val;
650}
651
652/**
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000653 * e1000_check_for_copper_link_ich8lan - Check for link (Copper)
654 * @hw: pointer to the HW structure
655 *
656 * Checks to see of the link status of the hardware has changed. If a
657 * change in link status has been detected, then we read the PHY registers
658 * to get the current speed/duplex if link exists.
659 **/
660static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw)
661{
662 struct e1000_mac_info *mac = &hw->mac;
663 s32 ret_val;
664 bool link;
Bruce Allan1d2101a2011-07-22 06:21:56 +0000665 u16 phy_reg;
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000666
667 /*
668 * We only want to go out to the PHY registers to see if Auto-Neg
669 * has completed and/or if our link status has changed. The
670 * get_link_status flag is set upon receiving a Link Status
671 * Change or Rx Sequence Error interrupt.
672 */
673 if (!mac->get_link_status) {
674 ret_val = 0;
675 goto out;
676 }
677
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000678 /*
679 * First we want to see if the MII Status Register reports
680 * link. If so, then we want to get the current speed/duplex
681 * of the PHY.
682 */
683 ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link);
684 if (ret_val)
685 goto out;
686
Bruce Allan1d5846b2009-10-29 13:46:05 +0000687 if (hw->mac.type == e1000_pchlan) {
688 ret_val = e1000_k1_gig_workaround_hv(hw, link);
689 if (ret_val)
690 goto out;
691 }
692
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000693 if (!link)
694 goto out; /* No link detected */
695
696 mac->get_link_status = false;
697
Bruce Allan1d2101a2011-07-22 06:21:56 +0000698 switch (hw->mac.type) {
699 case e1000_pch2lan:
Bruce Allan831bd2e2010-09-22 17:16:18 +0000700 ret_val = e1000_k1_workaround_lv(hw);
701 if (ret_val)
702 goto out;
Bruce Allan1d2101a2011-07-22 06:21:56 +0000703 /* fall-thru */
704 case e1000_pchlan:
705 if (hw->phy.type == e1000_phy_82578) {
706 ret_val = e1000_link_stall_workaround_hv(hw);
707 if (ret_val)
708 goto out;
709 }
710
711 /*
712 * Workaround for PCHx parts in half-duplex:
713 * Set the number of preambles removed from the packet
714 * when it is passed from the PHY to the MAC to prevent
715 * the MAC from misinterpreting the packet type.
716 */
717 e1e_rphy(hw, HV_KMRN_FIFO_CTRLSTA, &phy_reg);
718 phy_reg &= ~HV_KMRN_FIFO_CTRLSTA_PREAMBLE_MASK;
719
720 if ((er32(STATUS) & E1000_STATUS_FD) != E1000_STATUS_FD)
721 phy_reg |= (1 << HV_KMRN_FIFO_CTRLSTA_PREAMBLE_SHIFT);
722
723 e1e_wphy(hw, HV_KMRN_FIFO_CTRLSTA, phy_reg);
724 break;
725 default:
726 break;
Bruce Allan831bd2e2010-09-22 17:16:18 +0000727 }
728
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000729 /*
730 * Check if there was DownShift, must be checked
731 * immediately after link-up
732 */
733 e1000e_check_downshift(hw);
734
Bruce Allane52997f2010-06-16 13:27:49 +0000735 /* Enable/Disable EEE after link up */
736 ret_val = e1000_set_eee_pchlan(hw);
737 if (ret_val)
738 goto out;
739
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000740 /*
741 * If we are forcing speed/duplex, then we simply return since
742 * we have already determined whether we have link or not.
743 */
744 if (!mac->autoneg) {
745 ret_val = -E1000_ERR_CONFIG;
746 goto out;
747 }
748
749 /*
750 * Auto-Neg is enabled. Auto Speed Detection takes care
751 * of MAC speed/duplex configuration. So we only need to
752 * configure Collision Distance in the MAC.
753 */
754 e1000e_config_collision_dist(hw);
755
756 /*
757 * Configure Flow Control now that Auto-Neg has completed.
758 * First, we need to restore the desired flow control
759 * settings because we may have had to re-autoneg with a
760 * different link partner.
761 */
762 ret_val = e1000e_config_fc_after_link_up(hw);
763 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000764 e_dbg("Error configuring flow control\n");
Bruce Allan7d3cabb2009-07-01 13:29:08 +0000765
766out:
767 return ret_val;
768}
769
Jeff Kirsher69e3fd82008-04-02 13:48:18 -0700770static s32 e1000_get_variants_ich8lan(struct e1000_adapter *adapter)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700771{
772 struct e1000_hw *hw = &adapter->hw;
773 s32 rc;
774
775 rc = e1000_init_mac_params_ich8lan(adapter);
776 if (rc)
777 return rc;
778
779 rc = e1000_init_nvm_params_ich8lan(hw);
780 if (rc)
781 return rc;
782
Bruce Alland3738bb2010-06-16 13:27:28 +0000783 switch (hw->mac.type) {
784 case e1000_ich8lan:
785 case e1000_ich9lan:
786 case e1000_ich10lan:
Bruce Allana4f58f52009-06-02 11:29:18 +0000787 rc = e1000_init_phy_params_ich8lan(hw);
Bruce Alland3738bb2010-06-16 13:27:28 +0000788 break;
789 case e1000_pchlan:
790 case e1000_pch2lan:
791 rc = e1000_init_phy_params_pchlan(hw);
792 break;
793 default:
794 break;
795 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700796 if (rc)
797 return rc;
798
Bruce Allan23e4f062011-02-25 07:44:51 +0000799 /*
800 * Disable Jumbo Frame support on parts with Intel 10/100 PHY or
801 * on parts with MACsec enabled in NVM (reflected in CTRL_EXT).
802 */
803 if ((adapter->hw.phy.type == e1000_phy_ife) ||
804 ((adapter->hw.mac.type >= e1000_pch2lan) &&
805 (!(er32(CTRL_EXT) & E1000_CTRL_EXT_LSECCK)))) {
Bruce Allan2adc55c2009-06-02 11:28:58 +0000806 adapter->flags &= ~FLAG_HAS_JUMBO_FRAMES;
807 adapter->max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN;
Bruce Allandbf80dc2011-04-16 00:34:40 +0000808
809 hw->mac.ops.blink_led = NULL;
Bruce Allan2adc55c2009-06-02 11:28:58 +0000810 }
811
Auke Kokbc7f75f2007-09-17 12:30:59 -0700812 if ((adapter->hw.mac.type == e1000_ich8lan) &&
813 (adapter->hw.phy.type == e1000_phy_igp_3))
814 adapter->flags |= FLAG_LSC_GIG_SPEED_DROP;
815
Bruce Allan5a86f282010-06-29 18:13:13 +0000816 /* Disable EEE by default until IEEE802.3az spec is finalized */
817 if (adapter->flags2 & FLAG2_HAS_EEE)
818 adapter->hw.dev_spec.ich8lan.eee_disable = true;
819
Auke Kokbc7f75f2007-09-17 12:30:59 -0700820 return 0;
821}
822
Thomas Gleixner717d4382008-10-02 16:33:40 -0700823static DEFINE_MUTEX(nvm_mutex);
Thomas Gleixner717d4382008-10-02 16:33:40 -0700824
Auke Kokbc7f75f2007-09-17 12:30:59 -0700825/**
Bruce Allanca15df52009-10-26 11:23:43 +0000826 * e1000_acquire_nvm_ich8lan - Acquire NVM mutex
827 * @hw: pointer to the HW structure
828 *
829 * Acquires the mutex for performing NVM operations.
830 **/
831static s32 e1000_acquire_nvm_ich8lan(struct e1000_hw *hw)
832{
833 mutex_lock(&nvm_mutex);
834
835 return 0;
836}
837
838/**
839 * e1000_release_nvm_ich8lan - Release NVM mutex
840 * @hw: pointer to the HW structure
841 *
842 * Releases the mutex used while performing NVM operations.
843 **/
844static void e1000_release_nvm_ich8lan(struct e1000_hw *hw)
845{
846 mutex_unlock(&nvm_mutex);
Bruce Allanca15df52009-10-26 11:23:43 +0000847}
848
849static DEFINE_MUTEX(swflag_mutex);
850
851/**
Auke Kokbc7f75f2007-09-17 12:30:59 -0700852 * e1000_acquire_swflag_ich8lan - Acquire software control flag
853 * @hw: pointer to the HW structure
854 *
Bruce Allanca15df52009-10-26 11:23:43 +0000855 * Acquires the software control flag for performing PHY and select
856 * MAC CSR accesses.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700857 **/
858static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw)
859{
Bruce Allan373a88d2009-08-07 07:41:37 +0000860 u32 extcnf_ctrl, timeout = PHY_CFG_TIMEOUT;
861 s32 ret_val = 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700862
Bruce Allanca15df52009-10-26 11:23:43 +0000863 mutex_lock(&swflag_mutex);
Thomas Gleixner717d4382008-10-02 16:33:40 -0700864
Auke Kokbc7f75f2007-09-17 12:30:59 -0700865 while (timeout) {
866 extcnf_ctrl = er32(EXTCNF_CTRL);
Bruce Allan373a88d2009-08-07 07:41:37 +0000867 if (!(extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG))
868 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700869
Auke Kokbc7f75f2007-09-17 12:30:59 -0700870 mdelay(1);
871 timeout--;
872 }
873
874 if (!timeout) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000875 e_dbg("SW/FW/HW has locked the resource for too long.\n");
Bruce Allan373a88d2009-08-07 07:41:37 +0000876 ret_val = -E1000_ERR_CONFIG;
877 goto out;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700878 }
879
Bruce Allan53ac5a82009-10-26 11:23:06 +0000880 timeout = SW_FLAG_TIMEOUT;
Bruce Allan373a88d2009-08-07 07:41:37 +0000881
882 extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG;
883 ew32(EXTCNF_CTRL, extcnf_ctrl);
884
885 while (timeout) {
886 extcnf_ctrl = er32(EXTCNF_CTRL);
887 if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG)
888 break;
889
890 mdelay(1);
891 timeout--;
892 }
893
894 if (!timeout) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000895 e_dbg("Failed to acquire the semaphore.\n");
Bruce Allan373a88d2009-08-07 07:41:37 +0000896 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
897 ew32(EXTCNF_CTRL, extcnf_ctrl);
898 ret_val = -E1000_ERR_CONFIG;
899 goto out;
900 }
901
902out:
903 if (ret_val)
Bruce Allanca15df52009-10-26 11:23:43 +0000904 mutex_unlock(&swflag_mutex);
Bruce Allan373a88d2009-08-07 07:41:37 +0000905
906 return ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700907}
908
909/**
910 * e1000_release_swflag_ich8lan - Release software control flag
911 * @hw: pointer to the HW structure
912 *
Bruce Allanca15df52009-10-26 11:23:43 +0000913 * Releases the software control flag for performing PHY and select
914 * MAC CSR accesses.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700915 **/
916static void e1000_release_swflag_ich8lan(struct e1000_hw *hw)
917{
918 u32 extcnf_ctrl;
919
920 extcnf_ctrl = er32(EXTCNF_CTRL);
Bruce Allanc5caf482011-05-13 07:19:53 +0000921
922 if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG) {
923 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
924 ew32(EXTCNF_CTRL, extcnf_ctrl);
925 } else {
926 e_dbg("Semaphore unexpectedly released by sw/fw/hw\n");
927 }
Thomas Gleixner717d4382008-10-02 16:33:40 -0700928
Bruce Allanca15df52009-10-26 11:23:43 +0000929 mutex_unlock(&swflag_mutex);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700930}
931
932/**
Bruce Allan4662e822008-08-26 18:37:06 -0700933 * e1000_check_mng_mode_ich8lan - Checks management mode
934 * @hw: pointer to the HW structure
935 *
Bruce Allaneb7700d2010-06-16 13:27:05 +0000936 * This checks if the adapter has any manageability enabled.
Bruce Allan4662e822008-08-26 18:37:06 -0700937 * This is a function pointer entry point only called by read/write
938 * routines for the PHY and NVM parts.
939 **/
940static bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw)
941{
Bruce Allana708dd82009-11-20 23:28:37 +0000942 u32 fwsm;
943
944 fwsm = er32(FWSM);
Bruce Allaneb7700d2010-06-16 13:27:05 +0000945 return (fwsm & E1000_ICH_FWSM_FW_VALID) &&
946 ((fwsm & E1000_FWSM_MODE_MASK) ==
947 (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT));
948}
Bruce Allan4662e822008-08-26 18:37:06 -0700949
Bruce Allaneb7700d2010-06-16 13:27:05 +0000950/**
951 * e1000_check_mng_mode_pchlan - Checks management mode
952 * @hw: pointer to the HW structure
953 *
954 * This checks if the adapter has iAMT enabled.
955 * This is a function pointer entry point only called by read/write
956 * routines for the PHY and NVM parts.
957 **/
958static bool e1000_check_mng_mode_pchlan(struct e1000_hw *hw)
959{
960 u32 fwsm;
961
962 fwsm = er32(FWSM);
963 return (fwsm & E1000_ICH_FWSM_FW_VALID) &&
964 (fwsm & (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT));
Bruce Allan4662e822008-08-26 18:37:06 -0700965}
966
967/**
Auke Kokbc7f75f2007-09-17 12:30:59 -0700968 * e1000_check_reset_block_ich8lan - Check if PHY reset is blocked
969 * @hw: pointer to the HW structure
970 *
971 * Checks if firmware is blocking the reset of the PHY.
972 * This is a function pointer entry point only called by
973 * reset routines.
974 **/
975static s32 e1000_check_reset_block_ich8lan(struct e1000_hw *hw)
976{
977 u32 fwsm;
978
979 fwsm = er32(FWSM);
980
981 return (fwsm & E1000_ICH_FWSM_RSPCIPHY) ? 0 : E1000_BLK_PHY_RESET;
982}
983
984/**
Bruce Allan8395ae82010-09-22 17:15:08 +0000985 * e1000_write_smbus_addr - Write SMBus address to PHY needed during Sx states
986 * @hw: pointer to the HW structure
987 *
988 * Assumes semaphore already acquired.
989 *
990 **/
991static s32 e1000_write_smbus_addr(struct e1000_hw *hw)
992{
993 u16 phy_data;
994 u32 strap = er32(STRAP);
995 s32 ret_val = 0;
996
997 strap &= E1000_STRAP_SMBUS_ADDRESS_MASK;
998
999 ret_val = e1000_read_phy_reg_hv_locked(hw, HV_SMB_ADDR, &phy_data);
1000 if (ret_val)
1001 goto out;
1002
1003 phy_data &= ~HV_SMB_ADDR_MASK;
1004 phy_data |= (strap >> E1000_STRAP_SMBUS_ADDRESS_SHIFT);
1005 phy_data |= HV_SMB_ADDR_PEC_EN | HV_SMB_ADDR_VALID;
1006 ret_val = e1000_write_phy_reg_hv_locked(hw, HV_SMB_ADDR, phy_data);
1007
1008out:
1009 return ret_val;
1010}
1011
1012/**
Bruce Allanf523d212009-10-29 13:45:45 +00001013 * e1000_sw_lcd_config_ich8lan - SW-based LCD Configuration
1014 * @hw: pointer to the HW structure
1015 *
1016 * SW should configure the LCD from the NVM extended configuration region
1017 * as a workaround for certain parts.
1018 **/
1019static s32 e1000_sw_lcd_config_ich8lan(struct e1000_hw *hw)
1020{
1021 struct e1000_phy_info *phy = &hw->phy;
1022 u32 i, data, cnf_size, cnf_base_addr, sw_cfg_mask;
Bruce Allan8b802a72010-05-10 15:01:10 +00001023 s32 ret_val = 0;
Bruce Allanf523d212009-10-29 13:45:45 +00001024 u16 word_addr, reg_data, reg_addr, phy_page = 0;
1025
Bruce Allanf523d212009-10-29 13:45:45 +00001026 /*
1027 * Initialize the PHY from the NVM on ICH platforms. This
1028 * is needed due to an issue where the NVM configuration is
1029 * not properly autoloaded after power transitions.
1030 * Therefore, after each PHY reset, we will load the
1031 * configuration data out of the NVM manually.
1032 */
Bruce Allan3f0c16e2010-06-16 13:26:17 +00001033 switch (hw->mac.type) {
1034 case e1000_ich8lan:
1035 if (phy->type != e1000_phy_igp_3)
1036 return ret_val;
1037
Bruce Allan5f3eed62010-09-22 17:15:54 +00001038 if ((hw->adapter->pdev->device == E1000_DEV_ID_ICH8_IGP_AMT) ||
1039 (hw->adapter->pdev->device == E1000_DEV_ID_ICH8_IGP_C)) {
Bruce Allan3f0c16e2010-06-16 13:26:17 +00001040 sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG;
1041 break;
1042 }
1043 /* Fall-thru */
1044 case e1000_pchlan:
Bruce Alland3738bb2010-06-16 13:27:28 +00001045 case e1000_pch2lan:
Bruce Allan8b802a72010-05-10 15:01:10 +00001046 sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG_ICH8M;
Bruce Allan3f0c16e2010-06-16 13:26:17 +00001047 break;
1048 default:
1049 return ret_val;
1050 }
1051
1052 ret_val = hw->phy.ops.acquire(hw);
1053 if (ret_val)
1054 return ret_val;
Bruce Allanf523d212009-10-29 13:45:45 +00001055
Bruce Allan8b802a72010-05-10 15:01:10 +00001056 data = er32(FEXTNVM);
1057 if (!(data & sw_cfg_mask))
1058 goto out;
Bruce Allanf523d212009-10-29 13:45:45 +00001059
Bruce Allan8b802a72010-05-10 15:01:10 +00001060 /*
1061 * Make sure HW does not configure LCD from PHY
1062 * extended configuration before SW configuration
1063 */
1064 data = er32(EXTCNF_CTRL);
Bruce Alland3738bb2010-06-16 13:27:28 +00001065 if (!(hw->mac.type == e1000_pch2lan)) {
1066 if (data & E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE)
1067 goto out;
1068 }
Bruce Allanf523d212009-10-29 13:45:45 +00001069
Bruce Allan8b802a72010-05-10 15:01:10 +00001070 cnf_size = er32(EXTCNF_SIZE);
1071 cnf_size &= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_MASK;
1072 cnf_size >>= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_SHIFT;
1073 if (!cnf_size)
1074 goto out;
1075
1076 cnf_base_addr = data & E1000_EXTCNF_CTRL_EXT_CNF_POINTER_MASK;
1077 cnf_base_addr >>= E1000_EXTCNF_CTRL_EXT_CNF_POINTER_SHIFT;
1078
Bruce Allan87fb7412010-09-22 17:15:33 +00001079 if ((!(data & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE) &&
1080 (hw->mac.type == e1000_pchlan)) ||
1081 (hw->mac.type == e1000_pch2lan)) {
Bruce Allanf523d212009-10-29 13:45:45 +00001082 /*
Bruce Allan8b802a72010-05-10 15:01:10 +00001083 * HW configures the SMBus address and LEDs when the
1084 * OEM and LCD Write Enable bits are set in the NVM.
1085 * When both NVM bits are cleared, SW will configure
1086 * them instead.
Bruce Allanf523d212009-10-29 13:45:45 +00001087 */
Bruce Allan8395ae82010-09-22 17:15:08 +00001088 ret_val = e1000_write_smbus_addr(hw);
Bruce Allan8b802a72010-05-10 15:01:10 +00001089 if (ret_val)
Bruce Allanf523d212009-10-29 13:45:45 +00001090 goto out;
1091
Bruce Allan8b802a72010-05-10 15:01:10 +00001092 data = er32(LEDCTL);
1093 ret_val = e1000_write_phy_reg_hv_locked(hw, HV_LED_CONFIG,
1094 (u16)data);
1095 if (ret_val)
1096 goto out;
1097 }
1098
1099 /* Configure LCD from extended configuration region. */
1100
1101 /* cnf_base_addr is in DWORD */
1102 word_addr = (u16)(cnf_base_addr << 1);
1103
1104 for (i = 0; i < cnf_size; i++) {
1105 ret_val = e1000_read_nvm(hw, (word_addr + i * 2), 1,
1106 &reg_data);
1107 if (ret_val)
Bruce Allanf523d212009-10-29 13:45:45 +00001108 goto out;
1109
Bruce Allan8b802a72010-05-10 15:01:10 +00001110 ret_val = e1000_read_nvm(hw, (word_addr + i * 2 + 1),
1111 1, &reg_addr);
1112 if (ret_val)
1113 goto out;
Bruce Allanf523d212009-10-29 13:45:45 +00001114
Bruce Allan8b802a72010-05-10 15:01:10 +00001115 /* Save off the PHY page for future writes. */
1116 if (reg_addr == IGP01E1000_PHY_PAGE_SELECT) {
1117 phy_page = reg_data;
1118 continue;
Bruce Allanf523d212009-10-29 13:45:45 +00001119 }
Bruce Allanf523d212009-10-29 13:45:45 +00001120
Bruce Allan8b802a72010-05-10 15:01:10 +00001121 reg_addr &= PHY_REG_MASK;
1122 reg_addr |= phy_page;
Bruce Allanf523d212009-10-29 13:45:45 +00001123
Bruce Allan8b802a72010-05-10 15:01:10 +00001124 ret_val = phy->ops.write_reg_locked(hw, (u32)reg_addr,
1125 reg_data);
1126 if (ret_val)
1127 goto out;
Bruce Allanf523d212009-10-29 13:45:45 +00001128 }
1129
1130out:
Bruce Allan94d81862009-11-20 23:25:26 +00001131 hw->phy.ops.release(hw);
Bruce Allanf523d212009-10-29 13:45:45 +00001132 return ret_val;
1133}
1134
1135/**
Bruce Allan1d5846b2009-10-29 13:46:05 +00001136 * e1000_k1_gig_workaround_hv - K1 Si workaround
1137 * @hw: pointer to the HW structure
1138 * @link: link up bool flag
1139 *
1140 * If K1 is enabled for 1Gbps, the MAC might stall when transitioning
1141 * from a lower speed. This workaround disables K1 whenever link is at 1Gig
1142 * If link is down, the function will restore the default K1 setting located
1143 * in the NVM.
1144 **/
1145static s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link)
1146{
1147 s32 ret_val = 0;
1148 u16 status_reg = 0;
1149 bool k1_enable = hw->dev_spec.ich8lan.nvm_k1_enabled;
1150
1151 if (hw->mac.type != e1000_pchlan)
1152 goto out;
1153
1154 /* Wrap the whole flow with the sw flag */
Bruce Allan94d81862009-11-20 23:25:26 +00001155 ret_val = hw->phy.ops.acquire(hw);
Bruce Allan1d5846b2009-10-29 13:46:05 +00001156 if (ret_val)
1157 goto out;
1158
1159 /* Disable K1 when link is 1Gbps, otherwise use the NVM setting */
1160 if (link) {
1161 if (hw->phy.type == e1000_phy_82578) {
Bruce Allan94d81862009-11-20 23:25:26 +00001162 ret_val = hw->phy.ops.read_reg_locked(hw, BM_CS_STATUS,
Bruce Allan1d5846b2009-10-29 13:46:05 +00001163 &status_reg);
1164 if (ret_val)
1165 goto release;
1166
1167 status_reg &= BM_CS_STATUS_LINK_UP |
1168 BM_CS_STATUS_RESOLVED |
1169 BM_CS_STATUS_SPEED_MASK;
1170
1171 if (status_reg == (BM_CS_STATUS_LINK_UP |
1172 BM_CS_STATUS_RESOLVED |
1173 BM_CS_STATUS_SPEED_1000))
1174 k1_enable = false;
1175 }
1176
1177 if (hw->phy.type == e1000_phy_82577) {
Bruce Allan94d81862009-11-20 23:25:26 +00001178 ret_val = hw->phy.ops.read_reg_locked(hw, HV_M_STATUS,
Bruce Allan1d5846b2009-10-29 13:46:05 +00001179 &status_reg);
1180 if (ret_val)
1181 goto release;
1182
1183 status_reg &= HV_M_STATUS_LINK_UP |
1184 HV_M_STATUS_AUTONEG_COMPLETE |
1185 HV_M_STATUS_SPEED_MASK;
1186
1187 if (status_reg == (HV_M_STATUS_LINK_UP |
1188 HV_M_STATUS_AUTONEG_COMPLETE |
1189 HV_M_STATUS_SPEED_1000))
1190 k1_enable = false;
1191 }
1192
1193 /* Link stall fix for link up */
Bruce Allan94d81862009-11-20 23:25:26 +00001194 ret_val = hw->phy.ops.write_reg_locked(hw, PHY_REG(770, 19),
Bruce Allan1d5846b2009-10-29 13:46:05 +00001195 0x0100);
1196 if (ret_val)
1197 goto release;
1198
1199 } else {
1200 /* Link stall fix for link down */
Bruce Allan94d81862009-11-20 23:25:26 +00001201 ret_val = hw->phy.ops.write_reg_locked(hw, PHY_REG(770, 19),
Bruce Allan1d5846b2009-10-29 13:46:05 +00001202 0x4100);
1203 if (ret_val)
1204 goto release;
1205 }
1206
1207 ret_val = e1000_configure_k1_ich8lan(hw, k1_enable);
1208
1209release:
Bruce Allan94d81862009-11-20 23:25:26 +00001210 hw->phy.ops.release(hw);
Bruce Allan1d5846b2009-10-29 13:46:05 +00001211out:
1212 return ret_val;
1213}
1214
1215/**
1216 * e1000_configure_k1_ich8lan - Configure K1 power state
1217 * @hw: pointer to the HW structure
1218 * @enable: K1 state to configure
1219 *
1220 * Configure the K1 power state based on the provided parameter.
1221 * Assumes semaphore already acquired.
1222 *
1223 * Success returns 0, Failure returns -E1000_ERR_PHY (-2)
1224 **/
Bruce Allanbb436b22009-11-20 23:24:11 +00001225s32 e1000_configure_k1_ich8lan(struct e1000_hw *hw, bool k1_enable)
Bruce Allan1d5846b2009-10-29 13:46:05 +00001226{
1227 s32 ret_val = 0;
1228 u32 ctrl_reg = 0;
1229 u32 ctrl_ext = 0;
1230 u32 reg = 0;
1231 u16 kmrn_reg = 0;
1232
1233 ret_val = e1000e_read_kmrn_reg_locked(hw,
1234 E1000_KMRNCTRLSTA_K1_CONFIG,
1235 &kmrn_reg);
1236 if (ret_val)
1237 goto out;
1238
1239 if (k1_enable)
1240 kmrn_reg |= E1000_KMRNCTRLSTA_K1_ENABLE;
1241 else
1242 kmrn_reg &= ~E1000_KMRNCTRLSTA_K1_ENABLE;
1243
1244 ret_val = e1000e_write_kmrn_reg_locked(hw,
1245 E1000_KMRNCTRLSTA_K1_CONFIG,
1246 kmrn_reg);
1247 if (ret_val)
1248 goto out;
1249
1250 udelay(20);
1251 ctrl_ext = er32(CTRL_EXT);
1252 ctrl_reg = er32(CTRL);
1253
1254 reg = ctrl_reg & ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100);
1255 reg |= E1000_CTRL_FRCSPD;
1256 ew32(CTRL, reg);
1257
1258 ew32(CTRL_EXT, ctrl_ext | E1000_CTRL_EXT_SPD_BYPS);
Jesse Brandeburg945a5152011-07-20 00:56:21 +00001259 e1e_flush();
Bruce Allan1d5846b2009-10-29 13:46:05 +00001260 udelay(20);
1261 ew32(CTRL, ctrl_reg);
1262 ew32(CTRL_EXT, ctrl_ext);
Jesse Brandeburg945a5152011-07-20 00:56:21 +00001263 e1e_flush();
Bruce Allan1d5846b2009-10-29 13:46:05 +00001264 udelay(20);
1265
1266out:
1267 return ret_val;
1268}
1269
1270/**
Bruce Allanf523d212009-10-29 13:45:45 +00001271 * e1000_oem_bits_config_ich8lan - SW-based LCD Configuration
1272 * @hw: pointer to the HW structure
1273 * @d0_state: boolean if entering d0 or d3 device state
1274 *
1275 * SW will configure Gbe Disable and LPLU based on the NVM. The four bits are
1276 * collectively called OEM bits. The OEM Write Enable bit and SW Config bit
1277 * in NVM determines whether HW should configure LPLU and Gbe Disable.
1278 **/
1279static s32 e1000_oem_bits_config_ich8lan(struct e1000_hw *hw, bool d0_state)
1280{
1281 s32 ret_val = 0;
1282 u32 mac_reg;
1283 u16 oem_reg;
1284
Bruce Alland3738bb2010-06-16 13:27:28 +00001285 if ((hw->mac.type != e1000_pch2lan) && (hw->mac.type != e1000_pchlan))
Bruce Allanf523d212009-10-29 13:45:45 +00001286 return ret_val;
1287
Bruce Allan94d81862009-11-20 23:25:26 +00001288 ret_val = hw->phy.ops.acquire(hw);
Bruce Allanf523d212009-10-29 13:45:45 +00001289 if (ret_val)
1290 return ret_val;
1291
Bruce Alland3738bb2010-06-16 13:27:28 +00001292 if (!(hw->mac.type == e1000_pch2lan)) {
1293 mac_reg = er32(EXTCNF_CTRL);
1294 if (mac_reg & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE)
1295 goto out;
1296 }
Bruce Allanf523d212009-10-29 13:45:45 +00001297
1298 mac_reg = er32(FEXTNVM);
1299 if (!(mac_reg & E1000_FEXTNVM_SW_CONFIG_ICH8M))
1300 goto out;
1301
1302 mac_reg = er32(PHY_CTRL);
1303
Bruce Allan94d81862009-11-20 23:25:26 +00001304 ret_val = hw->phy.ops.read_reg_locked(hw, HV_OEM_BITS, &oem_reg);
Bruce Allanf523d212009-10-29 13:45:45 +00001305 if (ret_val)
1306 goto out;
1307
1308 oem_reg &= ~(HV_OEM_BITS_GBE_DIS | HV_OEM_BITS_LPLU);
1309
1310 if (d0_state) {
1311 if (mac_reg & E1000_PHY_CTRL_GBE_DISABLE)
1312 oem_reg |= HV_OEM_BITS_GBE_DIS;
1313
1314 if (mac_reg & E1000_PHY_CTRL_D0A_LPLU)
1315 oem_reg |= HV_OEM_BITS_LPLU;
1316 } else {
1317 if (mac_reg & E1000_PHY_CTRL_NOND0A_GBE_DISABLE)
1318 oem_reg |= HV_OEM_BITS_GBE_DIS;
1319
1320 if (mac_reg & E1000_PHY_CTRL_NOND0A_LPLU)
1321 oem_reg |= HV_OEM_BITS_LPLU;
1322 }
1323 /* Restart auto-neg to activate the bits */
Bruce Allan818f3332009-11-19 14:17:30 +00001324 if (!e1000_check_reset_block(hw))
1325 oem_reg |= HV_OEM_BITS_RESTART_AN;
Bruce Allan94d81862009-11-20 23:25:26 +00001326 ret_val = hw->phy.ops.write_reg_locked(hw, HV_OEM_BITS, oem_reg);
Bruce Allanf523d212009-10-29 13:45:45 +00001327
1328out:
Bruce Allan94d81862009-11-20 23:25:26 +00001329 hw->phy.ops.release(hw);
Bruce Allanf523d212009-10-29 13:45:45 +00001330
1331 return ret_val;
1332}
1333
1334
1335/**
Bruce Allanfddaa1a2010-01-13 01:52:49 +00001336 * e1000_set_mdio_slow_mode_hv - Set slow MDIO access mode
1337 * @hw: pointer to the HW structure
1338 **/
1339static s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw)
1340{
1341 s32 ret_val;
1342 u16 data;
1343
1344 ret_val = e1e_rphy(hw, HV_KMRN_MODE_CTRL, &data);
1345 if (ret_val)
1346 return ret_val;
1347
1348 data |= HV_KMRN_MDIO_SLOW;
1349
1350 ret_val = e1e_wphy(hw, HV_KMRN_MODE_CTRL, data);
1351
1352 return ret_val;
1353}
1354
1355/**
Bruce Allana4f58f52009-06-02 11:29:18 +00001356 * e1000_hv_phy_workarounds_ich8lan - A series of Phy workarounds to be
1357 * done after every PHY reset.
1358 **/
1359static s32 e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw)
1360{
1361 s32 ret_val = 0;
Bruce Allanbaf86c92010-01-13 01:53:08 +00001362 u16 phy_data;
Bruce Allana4f58f52009-06-02 11:29:18 +00001363
1364 if (hw->mac.type != e1000_pchlan)
1365 return ret_val;
1366
Bruce Allanfddaa1a2010-01-13 01:52:49 +00001367 /* Set MDIO slow mode before any other MDIO access */
1368 if (hw->phy.type == e1000_phy_82577) {
1369 ret_val = e1000_set_mdio_slow_mode_hv(hw);
1370 if (ret_val)
1371 goto out;
1372 }
1373
Bruce Allana4f58f52009-06-02 11:29:18 +00001374 if (((hw->phy.type == e1000_phy_82577) &&
1375 ((hw->phy.revision == 1) || (hw->phy.revision == 2))) ||
1376 ((hw->phy.type == e1000_phy_82578) && (hw->phy.revision == 1))) {
1377 /* Disable generation of early preamble */
1378 ret_val = e1e_wphy(hw, PHY_REG(769, 25), 0x4431);
1379 if (ret_val)
1380 return ret_val;
1381
1382 /* Preamble tuning for SSC */
Bruce Allan1d2101a2011-07-22 06:21:56 +00001383 ret_val = e1e_wphy(hw, HV_KMRN_FIFO_CTRLSTA, 0xA204);
Bruce Allana4f58f52009-06-02 11:29:18 +00001384 if (ret_val)
1385 return ret_val;
1386 }
1387
1388 if (hw->phy.type == e1000_phy_82578) {
1389 /*
1390 * Return registers to default by doing a soft reset then
1391 * writing 0x3140 to the control register.
1392 */
1393 if (hw->phy.revision < 2) {
1394 e1000e_phy_sw_reset(hw);
1395 ret_val = e1e_wphy(hw, PHY_CONTROL, 0x3140);
1396 }
1397 }
1398
1399 /* Select page 0 */
Bruce Allan94d81862009-11-20 23:25:26 +00001400 ret_val = hw->phy.ops.acquire(hw);
Bruce Allana4f58f52009-06-02 11:29:18 +00001401 if (ret_val)
1402 return ret_val;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001403
Bruce Allana4f58f52009-06-02 11:29:18 +00001404 hw->phy.addr = 1;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001405 ret_val = e1000e_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT, 0);
Bruce Allanbaf86c92010-01-13 01:53:08 +00001406 hw->phy.ops.release(hw);
Bruce Allan1d5846b2009-10-29 13:46:05 +00001407 if (ret_val)
1408 goto out;
Bruce Allana4f58f52009-06-02 11:29:18 +00001409
Bruce Allan1d5846b2009-10-29 13:46:05 +00001410 /*
1411 * Configure the K1 Si workaround during phy reset assuming there is
1412 * link so that it disables K1 if link is in 1Gbps.
1413 */
1414 ret_val = e1000_k1_gig_workaround_hv(hw, true);
Bruce Allanbaf86c92010-01-13 01:53:08 +00001415 if (ret_val)
1416 goto out;
Bruce Allan1d5846b2009-10-29 13:46:05 +00001417
Bruce Allanbaf86c92010-01-13 01:53:08 +00001418 /* Workaround for link disconnects on a busy hub in half duplex */
1419 ret_val = hw->phy.ops.acquire(hw);
1420 if (ret_val)
1421 goto out;
Bruce Allan3ebfc7c2011-05-13 07:20:14 +00001422 ret_val = hw->phy.ops.read_reg_locked(hw, BM_PORT_GEN_CFG, &phy_data);
Bruce Allanbaf86c92010-01-13 01:53:08 +00001423 if (ret_val)
1424 goto release;
Bruce Allan3ebfc7c2011-05-13 07:20:14 +00001425 ret_val = hw->phy.ops.write_reg_locked(hw, BM_PORT_GEN_CFG,
1426 phy_data & 0x00FF);
Bruce Allanbaf86c92010-01-13 01:53:08 +00001427release:
1428 hw->phy.ops.release(hw);
Bruce Allan1d5846b2009-10-29 13:46:05 +00001429out:
Bruce Allana4f58f52009-06-02 11:29:18 +00001430 return ret_val;
1431}
1432
1433/**
Bruce Alland3738bb2010-06-16 13:27:28 +00001434 * e1000_copy_rx_addrs_to_phy_ich8lan - Copy Rx addresses from MAC to PHY
1435 * @hw: pointer to the HW structure
1436 **/
1437void e1000_copy_rx_addrs_to_phy_ich8lan(struct e1000_hw *hw)
1438{
1439 u32 mac_reg;
Bruce Allan2b6b1682011-05-13 07:20:09 +00001440 u16 i, phy_reg = 0;
1441 s32 ret_val;
1442
1443 ret_val = hw->phy.ops.acquire(hw);
1444 if (ret_val)
1445 return;
1446 ret_val = e1000_enable_phy_wakeup_reg_access_bm(hw, &phy_reg);
1447 if (ret_val)
1448 goto release;
Bruce Alland3738bb2010-06-16 13:27:28 +00001449
1450 /* Copy both RAL/H (rar_entry_count) and SHRAL/H (+4) to PHY */
1451 for (i = 0; i < (hw->mac.rar_entry_count + 4); i++) {
1452 mac_reg = er32(RAL(i));
Bruce Allan2b6b1682011-05-13 07:20:09 +00001453 hw->phy.ops.write_reg_page(hw, BM_RAR_L(i),
1454 (u16)(mac_reg & 0xFFFF));
1455 hw->phy.ops.write_reg_page(hw, BM_RAR_M(i),
1456 (u16)((mac_reg >> 16) & 0xFFFF));
1457
Bruce Alland3738bb2010-06-16 13:27:28 +00001458 mac_reg = er32(RAH(i));
Bruce Allan2b6b1682011-05-13 07:20:09 +00001459 hw->phy.ops.write_reg_page(hw, BM_RAR_H(i),
1460 (u16)(mac_reg & 0xFFFF));
1461 hw->phy.ops.write_reg_page(hw, BM_RAR_CTRL(i),
1462 (u16)((mac_reg & E1000_RAH_AV)
1463 >> 16));
Bruce Alland3738bb2010-06-16 13:27:28 +00001464 }
Bruce Allan2b6b1682011-05-13 07:20:09 +00001465
1466 e1000_disable_phy_wakeup_reg_access_bm(hw, &phy_reg);
1467
1468release:
1469 hw->phy.ops.release(hw);
Bruce Alland3738bb2010-06-16 13:27:28 +00001470}
1471
Bruce Alland3738bb2010-06-16 13:27:28 +00001472/**
1473 * e1000_lv_jumbo_workaround_ich8lan - required for jumbo frame operation
1474 * with 82579 PHY
1475 * @hw: pointer to the HW structure
1476 * @enable: flag to enable/disable workaround when enabling/disabling jumbos
1477 **/
1478s32 e1000_lv_jumbo_workaround_ich8lan(struct e1000_hw *hw, bool enable)
1479{
1480 s32 ret_val = 0;
1481 u16 phy_reg, data;
1482 u32 mac_reg;
1483 u16 i;
1484
1485 if (hw->mac.type != e1000_pch2lan)
1486 goto out;
1487
1488 /* disable Rx path while enabling/disabling workaround */
1489 e1e_rphy(hw, PHY_REG(769, 20), &phy_reg);
1490 ret_val = e1e_wphy(hw, PHY_REG(769, 20), phy_reg | (1 << 14));
1491 if (ret_val)
1492 goto out;
1493
1494 if (enable) {
1495 /*
1496 * Write Rx addresses (rar_entry_count for RAL/H, +4 for
1497 * SHRAL/H) and initial CRC values to the MAC
1498 */
1499 for (i = 0; i < (hw->mac.rar_entry_count + 4); i++) {
1500 u8 mac_addr[ETH_ALEN] = {0};
1501 u32 addr_high, addr_low;
1502
1503 addr_high = er32(RAH(i));
1504 if (!(addr_high & E1000_RAH_AV))
1505 continue;
1506 addr_low = er32(RAL(i));
1507 mac_addr[0] = (addr_low & 0xFF);
1508 mac_addr[1] = ((addr_low >> 8) & 0xFF);
1509 mac_addr[2] = ((addr_low >> 16) & 0xFF);
1510 mac_addr[3] = ((addr_low >> 24) & 0xFF);
1511 mac_addr[4] = (addr_high & 0xFF);
1512 mac_addr[5] = ((addr_high >> 8) & 0xFF);
1513
Bruce Allanfe46f582011-01-06 14:29:51 +00001514 ew32(PCH_RAICC(i), ~ether_crc_le(ETH_ALEN, mac_addr));
Bruce Alland3738bb2010-06-16 13:27:28 +00001515 }
1516
1517 /* Write Rx addresses to the PHY */
1518 e1000_copy_rx_addrs_to_phy_ich8lan(hw);
1519
1520 /* Enable jumbo frame workaround in the MAC */
1521 mac_reg = er32(FFLT_DBG);
1522 mac_reg &= ~(1 << 14);
1523 mac_reg |= (7 << 15);
1524 ew32(FFLT_DBG, mac_reg);
1525
1526 mac_reg = er32(RCTL);
1527 mac_reg |= E1000_RCTL_SECRC;
1528 ew32(RCTL, mac_reg);
1529
1530 ret_val = e1000e_read_kmrn_reg(hw,
1531 E1000_KMRNCTRLSTA_CTRL_OFFSET,
1532 &data);
1533 if (ret_val)
1534 goto out;
1535 ret_val = e1000e_write_kmrn_reg(hw,
1536 E1000_KMRNCTRLSTA_CTRL_OFFSET,
1537 data | (1 << 0));
1538 if (ret_val)
1539 goto out;
1540 ret_val = e1000e_read_kmrn_reg(hw,
1541 E1000_KMRNCTRLSTA_HD_CTRL,
1542 &data);
1543 if (ret_val)
1544 goto out;
1545 data &= ~(0xF << 8);
1546 data |= (0xB << 8);
1547 ret_val = e1000e_write_kmrn_reg(hw,
1548 E1000_KMRNCTRLSTA_HD_CTRL,
1549 data);
1550 if (ret_val)
1551 goto out;
1552
1553 /* Enable jumbo frame workaround in the PHY */
Bruce Alland3738bb2010-06-16 13:27:28 +00001554 e1e_rphy(hw, PHY_REG(769, 23), &data);
1555 data &= ~(0x7F << 5);
1556 data |= (0x37 << 5);
1557 ret_val = e1e_wphy(hw, PHY_REG(769, 23), data);
1558 if (ret_val)
1559 goto out;
1560 e1e_rphy(hw, PHY_REG(769, 16), &data);
1561 data &= ~(1 << 13);
Bruce Alland3738bb2010-06-16 13:27:28 +00001562 ret_val = e1e_wphy(hw, PHY_REG(769, 16), data);
1563 if (ret_val)
1564 goto out;
1565 e1e_rphy(hw, PHY_REG(776, 20), &data);
1566 data &= ~(0x3FF << 2);
1567 data |= (0x1A << 2);
1568 ret_val = e1e_wphy(hw, PHY_REG(776, 20), data);
1569 if (ret_val)
1570 goto out;
1571 ret_val = e1e_wphy(hw, PHY_REG(776, 23), 0xFE00);
1572 if (ret_val)
1573 goto out;
1574 e1e_rphy(hw, HV_PM_CTRL, &data);
1575 ret_val = e1e_wphy(hw, HV_PM_CTRL, data | (1 << 10));
1576 if (ret_val)
1577 goto out;
1578 } else {
1579 /* Write MAC register values back to h/w defaults */
1580 mac_reg = er32(FFLT_DBG);
1581 mac_reg &= ~(0xF << 14);
1582 ew32(FFLT_DBG, mac_reg);
1583
1584 mac_reg = er32(RCTL);
1585 mac_reg &= ~E1000_RCTL_SECRC;
Bruce Allana1ce6472010-09-22 17:16:40 +00001586 ew32(RCTL, mac_reg);
Bruce Alland3738bb2010-06-16 13:27:28 +00001587
1588 ret_val = e1000e_read_kmrn_reg(hw,
1589 E1000_KMRNCTRLSTA_CTRL_OFFSET,
1590 &data);
1591 if (ret_val)
1592 goto out;
1593 ret_val = e1000e_write_kmrn_reg(hw,
1594 E1000_KMRNCTRLSTA_CTRL_OFFSET,
1595 data & ~(1 << 0));
1596 if (ret_val)
1597 goto out;
1598 ret_val = e1000e_read_kmrn_reg(hw,
1599 E1000_KMRNCTRLSTA_HD_CTRL,
1600 &data);
1601 if (ret_val)
1602 goto out;
1603 data &= ~(0xF << 8);
1604 data |= (0xB << 8);
1605 ret_val = e1000e_write_kmrn_reg(hw,
1606 E1000_KMRNCTRLSTA_HD_CTRL,
1607 data);
1608 if (ret_val)
1609 goto out;
1610
1611 /* Write PHY register values back to h/w defaults */
Bruce Alland3738bb2010-06-16 13:27:28 +00001612 e1e_rphy(hw, PHY_REG(769, 23), &data);
1613 data &= ~(0x7F << 5);
1614 ret_val = e1e_wphy(hw, PHY_REG(769, 23), data);
1615 if (ret_val)
1616 goto out;
1617 e1e_rphy(hw, PHY_REG(769, 16), &data);
Bruce Alland3738bb2010-06-16 13:27:28 +00001618 data |= (1 << 13);
1619 ret_val = e1e_wphy(hw, PHY_REG(769, 16), data);
1620 if (ret_val)
1621 goto out;
1622 e1e_rphy(hw, PHY_REG(776, 20), &data);
1623 data &= ~(0x3FF << 2);
1624 data |= (0x8 << 2);
1625 ret_val = e1e_wphy(hw, PHY_REG(776, 20), data);
1626 if (ret_val)
1627 goto out;
1628 ret_val = e1e_wphy(hw, PHY_REG(776, 23), 0x7E00);
1629 if (ret_val)
1630 goto out;
1631 e1e_rphy(hw, HV_PM_CTRL, &data);
1632 ret_val = e1e_wphy(hw, HV_PM_CTRL, data & ~(1 << 10));
1633 if (ret_val)
1634 goto out;
1635 }
1636
1637 /* re-enable Rx path after enabling/disabling workaround */
1638 ret_val = e1e_wphy(hw, PHY_REG(769, 20), phy_reg & ~(1 << 14));
1639
1640out:
1641 return ret_val;
1642}
1643
1644/**
1645 * e1000_lv_phy_workarounds_ich8lan - A series of Phy workarounds to be
1646 * done after every PHY reset.
1647 **/
1648static s32 e1000_lv_phy_workarounds_ich8lan(struct e1000_hw *hw)
1649{
1650 s32 ret_val = 0;
1651
1652 if (hw->mac.type != e1000_pch2lan)
1653 goto out;
1654
1655 /* Set MDIO slow mode before any other MDIO access */
1656 ret_val = e1000_set_mdio_slow_mode_hv(hw);
1657
1658out:
1659 return ret_val;
1660}
1661
1662/**
Bruce Allan831bd2e2010-09-22 17:16:18 +00001663 * e1000_k1_gig_workaround_lv - K1 Si workaround
1664 * @hw: pointer to the HW structure
1665 *
1666 * Workaround to set the K1 beacon duration for 82579 parts
1667 **/
1668static s32 e1000_k1_workaround_lv(struct e1000_hw *hw)
1669{
1670 s32 ret_val = 0;
1671 u16 status_reg = 0;
1672 u32 mac_reg;
1673
1674 if (hw->mac.type != e1000_pch2lan)
1675 goto out;
1676
1677 /* Set K1 beacon duration based on 1Gbps speed or otherwise */
1678 ret_val = e1e_rphy(hw, HV_M_STATUS, &status_reg);
1679 if (ret_val)
1680 goto out;
1681
1682 if ((status_reg & (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE))
1683 == (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE)) {
1684 mac_reg = er32(FEXTNVM4);
1685 mac_reg &= ~E1000_FEXTNVM4_BEACON_DURATION_MASK;
1686
1687 if (status_reg & HV_M_STATUS_SPEED_1000)
1688 mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_8USEC;
1689 else
1690 mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_16USEC;
1691
1692 ew32(FEXTNVM4, mac_reg);
1693 }
1694
1695out:
1696 return ret_val;
1697}
1698
1699/**
Bruce Allan605c82b2010-09-22 17:17:01 +00001700 * e1000_gate_hw_phy_config_ich8lan - disable PHY config via hardware
1701 * @hw: pointer to the HW structure
1702 * @gate: boolean set to true to gate, false to ungate
1703 *
1704 * Gate/ungate the automatic PHY configuration via hardware; perform
1705 * the configuration via software instead.
1706 **/
1707static void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate)
1708{
1709 u32 extcnf_ctrl;
1710
1711 if (hw->mac.type != e1000_pch2lan)
1712 return;
1713
1714 extcnf_ctrl = er32(EXTCNF_CTRL);
1715
1716 if (gate)
1717 extcnf_ctrl |= E1000_EXTCNF_CTRL_GATE_PHY_CFG;
1718 else
1719 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_GATE_PHY_CFG;
1720
1721 ew32(EXTCNF_CTRL, extcnf_ctrl);
1722 return;
1723}
1724
1725/**
Bruce Allanfc0c7762009-07-01 13:27:55 +00001726 * e1000_lan_init_done_ich8lan - Check for PHY config completion
1727 * @hw: pointer to the HW structure
1728 *
1729 * Check the appropriate indication the MAC has finished configuring the
1730 * PHY after a software reset.
1731 **/
1732static void e1000_lan_init_done_ich8lan(struct e1000_hw *hw)
1733{
1734 u32 data, loop = E1000_ICH8_LAN_INIT_TIMEOUT;
1735
1736 /* Wait for basic configuration completes before proceeding */
1737 do {
1738 data = er32(STATUS);
1739 data &= E1000_STATUS_LAN_INIT_DONE;
1740 udelay(100);
1741 } while ((!data) && --loop);
1742
1743 /*
1744 * If basic configuration is incomplete before the above loop
1745 * count reaches 0, loading the configuration from NVM will
1746 * leave the PHY in a bad state possibly resulting in no link.
1747 */
1748 if (loop == 0)
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001749 e_dbg("LAN_INIT_DONE not set, increase timeout\n");
Bruce Allanfc0c7762009-07-01 13:27:55 +00001750
1751 /* Clear the Init Done bit for the next init event */
1752 data = er32(STATUS);
1753 data &= ~E1000_STATUS_LAN_INIT_DONE;
1754 ew32(STATUS, data);
1755}
1756
1757/**
Bruce Allane98cac42010-05-10 15:02:32 +00001758 * e1000_post_phy_reset_ich8lan - Perform steps required after a PHY reset
Auke Kokbc7f75f2007-09-17 12:30:59 -07001759 * @hw: pointer to the HW structure
Auke Kokbc7f75f2007-09-17 12:30:59 -07001760 **/
Bruce Allane98cac42010-05-10 15:02:32 +00001761static s32 e1000_post_phy_reset_ich8lan(struct e1000_hw *hw)
Auke Kokbc7f75f2007-09-17 12:30:59 -07001762{
Bruce Allanf523d212009-10-29 13:45:45 +00001763 s32 ret_val = 0;
1764 u16 reg;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001765
Bruce Allane98cac42010-05-10 15:02:32 +00001766 if (e1000_check_reset_block(hw))
1767 goto out;
Bruce Allanfc0c7762009-07-01 13:27:55 +00001768
Bruce Allan5f3eed62010-09-22 17:15:54 +00001769 /* Allow time for h/w to get to quiescent state after reset */
Bruce Allan1bba4382011-03-19 00:27:20 +00001770 usleep_range(10000, 20000);
Bruce Allan5f3eed62010-09-22 17:15:54 +00001771
Bruce Allanfddaa1a2010-01-13 01:52:49 +00001772 /* Perform any necessary post-reset workarounds */
Bruce Allane98cac42010-05-10 15:02:32 +00001773 switch (hw->mac.type) {
1774 case e1000_pchlan:
Bruce Allana4f58f52009-06-02 11:29:18 +00001775 ret_val = e1000_hv_phy_workarounds_ich8lan(hw);
1776 if (ret_val)
Bruce Allane98cac42010-05-10 15:02:32 +00001777 goto out;
1778 break;
Bruce Alland3738bb2010-06-16 13:27:28 +00001779 case e1000_pch2lan:
1780 ret_val = e1000_lv_phy_workarounds_ich8lan(hw);
1781 if (ret_val)
1782 goto out;
1783 break;
Bruce Allane98cac42010-05-10 15:02:32 +00001784 default:
1785 break;
Bruce Allana4f58f52009-06-02 11:29:18 +00001786 }
1787
Bruce Allan3ebfc7c2011-05-13 07:20:14 +00001788 /* Clear the host wakeup bit after lcd reset */
1789 if (hw->mac.type >= e1000_pchlan) {
1790 e1e_rphy(hw, BM_PORT_GEN_CFG, &reg);
1791 reg &= ~BM_WUC_HOST_WU_BIT;
1792 e1e_wphy(hw, BM_PORT_GEN_CFG, reg);
1793 }
Bruce Allandb2932e2009-10-26 11:22:47 +00001794
Bruce Allanf523d212009-10-29 13:45:45 +00001795 /* Configure the LCD with the extended configuration region in NVM */
1796 ret_val = e1000_sw_lcd_config_ich8lan(hw);
1797 if (ret_val)
1798 goto out;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001799
Bruce Allanf523d212009-10-29 13:45:45 +00001800 /* Configure the LCD with the OEM bits in NVM */
Bruce Allane98cac42010-05-10 15:02:32 +00001801 ret_val = e1000_oem_bits_config_ich8lan(hw, true);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001802
Bruce Allan1effb452011-02-25 06:58:03 +00001803 if (hw->mac.type == e1000_pch2lan) {
1804 /* Ungate automatic PHY configuration on non-managed 82579 */
1805 if (!(er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) {
Bruce Allan1bba4382011-03-19 00:27:20 +00001806 usleep_range(10000, 20000);
Bruce Allan1effb452011-02-25 06:58:03 +00001807 e1000_gate_hw_phy_config_ich8lan(hw, false);
1808 }
1809
1810 /* Set EEE LPI Update Timer to 200usec */
1811 ret_val = hw->phy.ops.acquire(hw);
1812 if (ret_val)
1813 goto out;
1814 ret_val = hw->phy.ops.write_reg_locked(hw, I82579_EMI_ADDR,
1815 I82579_LPI_UPDATE_TIMER);
1816 if (ret_val)
1817 goto release;
1818 ret_val = hw->phy.ops.write_reg_locked(hw, I82579_EMI_DATA,
1819 0x1387);
1820release:
1821 hw->phy.ops.release(hw);
Bruce Allan605c82b2010-09-22 17:17:01 +00001822 }
1823
Bruce Allanf523d212009-10-29 13:45:45 +00001824out:
Bruce Allane98cac42010-05-10 15:02:32 +00001825 return ret_val;
1826}
1827
1828/**
1829 * e1000_phy_hw_reset_ich8lan - Performs a PHY reset
1830 * @hw: pointer to the HW structure
1831 *
1832 * Resets the PHY
1833 * This is a function pointer entry point called by drivers
1834 * or other shared routines.
1835 **/
1836static s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw)
1837{
1838 s32 ret_val = 0;
1839
Bruce Allan605c82b2010-09-22 17:17:01 +00001840 /* Gate automatic PHY configuration by hardware on non-managed 82579 */
1841 if ((hw->mac.type == e1000_pch2lan) &&
1842 !(er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
1843 e1000_gate_hw_phy_config_ich8lan(hw, true);
1844
Bruce Allane98cac42010-05-10 15:02:32 +00001845 ret_val = e1000e_phy_hw_reset_generic(hw);
1846 if (ret_val)
1847 goto out;
1848
1849 ret_val = e1000_post_phy_reset_ich8lan(hw);
1850
1851out:
1852 return ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001853}
1854
1855/**
Bruce Allanfa2ce132009-10-26 11:23:25 +00001856 * e1000_set_lplu_state_pchlan - Set Low Power Link Up state
1857 * @hw: pointer to the HW structure
1858 * @active: true to enable LPLU, false to disable
1859 *
1860 * Sets the LPLU state according to the active flag. For PCH, if OEM write
1861 * bit are disabled in the NVM, writing the LPLU bits in the MAC will not set
1862 * the phy speed. This function will manually set the LPLU bit and restart
1863 * auto-neg as hw would do. D3 and D0 LPLU will call the same function
1864 * since it configures the same bit.
1865 **/
1866static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active)
1867{
1868 s32 ret_val = 0;
1869 u16 oem_reg;
1870
1871 ret_val = e1e_rphy(hw, HV_OEM_BITS, &oem_reg);
1872 if (ret_val)
1873 goto out;
1874
1875 if (active)
1876 oem_reg |= HV_OEM_BITS_LPLU;
1877 else
1878 oem_reg &= ~HV_OEM_BITS_LPLU;
1879
1880 oem_reg |= HV_OEM_BITS_RESTART_AN;
1881 ret_val = e1e_wphy(hw, HV_OEM_BITS, oem_reg);
1882
1883out:
1884 return ret_val;
1885}
1886
1887/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07001888 * e1000_set_d0_lplu_state_ich8lan - Set Low Power Linkup D0 state
1889 * @hw: pointer to the HW structure
Bruce Allan564ea9b2009-11-20 23:26:44 +00001890 * @active: true to enable LPLU, false to disable
Auke Kokbc7f75f2007-09-17 12:30:59 -07001891 *
1892 * Sets the LPLU D0 state according to the active flag. When
1893 * activating LPLU this function also disables smart speed
1894 * and vice versa. LPLU will not be activated unless the
1895 * device autonegotiation advertisement meets standards of
1896 * either 10 or 10/100 or 10/100/1000 at all duplexes.
1897 * This is a function pointer entry point only called by
1898 * PHY setup routines.
1899 **/
1900static s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
1901{
1902 struct e1000_phy_info *phy = &hw->phy;
1903 u32 phy_ctrl;
1904 s32 ret_val = 0;
1905 u16 data;
1906
Bruce Allan97ac8ca2008-04-29 09:16:05 -07001907 if (phy->type == e1000_phy_ife)
Auke Kokbc7f75f2007-09-17 12:30:59 -07001908 return ret_val;
1909
1910 phy_ctrl = er32(PHY_CTRL);
1911
1912 if (active) {
1913 phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU;
1914 ew32(PHY_CTRL, phy_ctrl);
1915
Bruce Allan60f12922009-07-01 13:28:14 +00001916 if (phy->type != e1000_phy_igp_3)
1917 return 0;
1918
Bruce Allanad680762008-03-28 09:15:03 -07001919 /*
1920 * Call gig speed drop workaround on LPLU before accessing
1921 * any PHY registers
1922 */
Bruce Allan60f12922009-07-01 13:28:14 +00001923 if (hw->mac.type == e1000_ich8lan)
Auke Kokbc7f75f2007-09-17 12:30:59 -07001924 e1000e_gig_downshift_workaround_ich8lan(hw);
1925
1926 /* When LPLU is enabled, we should disable SmartSpeed */
1927 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data);
1928 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
1929 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);
1930 if (ret_val)
1931 return ret_val;
1932 } else {
1933 phy_ctrl &= ~E1000_PHY_CTRL_D0A_LPLU;
1934 ew32(PHY_CTRL, phy_ctrl);
1935
Bruce Allan60f12922009-07-01 13:28:14 +00001936 if (phy->type != e1000_phy_igp_3)
1937 return 0;
1938
Bruce Allanad680762008-03-28 09:15:03 -07001939 /*
1940 * LPLU and SmartSpeed are mutually exclusive. LPLU is used
Auke Kokbc7f75f2007-09-17 12:30:59 -07001941 * during Dx states where the power conservation is most
1942 * important. During driver activity we should enable
Bruce Allanad680762008-03-28 09:15:03 -07001943 * SmartSpeed, so performance is maintained.
1944 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07001945 if (phy->smart_speed == e1000_smart_speed_on) {
1946 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
Bruce Allanad680762008-03-28 09:15:03 -07001947 &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001948 if (ret_val)
1949 return ret_val;
1950
1951 data |= IGP01E1000_PSCFR_SMART_SPEED;
1952 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
Bruce Allanad680762008-03-28 09:15:03 -07001953 data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001954 if (ret_val)
1955 return ret_val;
1956 } else if (phy->smart_speed == e1000_smart_speed_off) {
1957 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
Bruce Allanad680762008-03-28 09:15:03 -07001958 &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001959 if (ret_val)
1960 return ret_val;
1961
1962 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
1963 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
Bruce Allanad680762008-03-28 09:15:03 -07001964 data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001965 if (ret_val)
1966 return ret_val;
1967 }
1968 }
1969
1970 return 0;
1971}
1972
1973/**
1974 * e1000_set_d3_lplu_state_ich8lan - Set Low Power Linkup D3 state
1975 * @hw: pointer to the HW structure
Bruce Allan564ea9b2009-11-20 23:26:44 +00001976 * @active: true to enable LPLU, false to disable
Auke Kokbc7f75f2007-09-17 12:30:59 -07001977 *
1978 * Sets the LPLU D3 state according to the active flag. When
1979 * activating LPLU this function also disables smart speed
1980 * and vice versa. LPLU will not be activated unless the
1981 * device autonegotiation advertisement meets standards of
1982 * either 10 or 10/100 or 10/100/1000 at all duplexes.
1983 * This is a function pointer entry point only called by
1984 * PHY setup routines.
1985 **/
1986static s32 e1000_set_d3_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
1987{
1988 struct e1000_phy_info *phy = &hw->phy;
1989 u32 phy_ctrl;
1990 s32 ret_val;
1991 u16 data;
1992
1993 phy_ctrl = er32(PHY_CTRL);
1994
1995 if (!active) {
1996 phy_ctrl &= ~E1000_PHY_CTRL_NOND0A_LPLU;
1997 ew32(PHY_CTRL, phy_ctrl);
Bruce Allan60f12922009-07-01 13:28:14 +00001998
1999 if (phy->type != e1000_phy_igp_3)
2000 return 0;
2001
Bruce Allanad680762008-03-28 09:15:03 -07002002 /*
2003 * LPLU and SmartSpeed are mutually exclusive. LPLU is used
Auke Kokbc7f75f2007-09-17 12:30:59 -07002004 * during Dx states where the power conservation is most
2005 * important. During driver activity we should enable
Bruce Allanad680762008-03-28 09:15:03 -07002006 * SmartSpeed, so performance is maintained.
2007 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002008 if (phy->smart_speed == e1000_smart_speed_on) {
Bruce Allanad680762008-03-28 09:15:03 -07002009 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
2010 &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002011 if (ret_val)
2012 return ret_val;
2013
2014 data |= IGP01E1000_PSCFR_SMART_SPEED;
Bruce Allanad680762008-03-28 09:15:03 -07002015 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
2016 data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002017 if (ret_val)
2018 return ret_val;
2019 } else if (phy->smart_speed == e1000_smart_speed_off) {
Bruce Allanad680762008-03-28 09:15:03 -07002020 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
2021 &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002022 if (ret_val)
2023 return ret_val;
2024
2025 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
Bruce Allanad680762008-03-28 09:15:03 -07002026 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
2027 data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002028 if (ret_val)
2029 return ret_val;
2030 }
2031 } else if ((phy->autoneg_advertised == E1000_ALL_SPEED_DUPLEX) ||
2032 (phy->autoneg_advertised == E1000_ALL_NOT_GIG) ||
2033 (phy->autoneg_advertised == E1000_ALL_10_SPEED)) {
2034 phy_ctrl |= E1000_PHY_CTRL_NOND0A_LPLU;
2035 ew32(PHY_CTRL, phy_ctrl);
2036
Bruce Allan60f12922009-07-01 13:28:14 +00002037 if (phy->type != e1000_phy_igp_3)
2038 return 0;
2039
Bruce Allanad680762008-03-28 09:15:03 -07002040 /*
2041 * Call gig speed drop workaround on LPLU before accessing
2042 * any PHY registers
2043 */
Bruce Allan60f12922009-07-01 13:28:14 +00002044 if (hw->mac.type == e1000_ich8lan)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002045 e1000e_gig_downshift_workaround_ich8lan(hw);
2046
2047 /* When LPLU is enabled, we should disable SmartSpeed */
Bruce Allanad680762008-03-28 09:15:03 -07002048 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002049 if (ret_val)
2050 return ret_val;
2051
2052 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
Bruce Allanad680762008-03-28 09:15:03 -07002053 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002054 }
2055
2056 return 0;
2057}
2058
2059/**
Bruce Allanf4187b52008-08-26 18:36:50 -07002060 * e1000_valid_nvm_bank_detect_ich8lan - finds out the valid bank 0 or 1
2061 * @hw: pointer to the HW structure
2062 * @bank: pointer to the variable that returns the active bank
2063 *
2064 * Reads signature byte from the NVM using the flash access registers.
Bruce Allane2434552008-11-21 17:02:41 -08002065 * Word 0x13 bits 15:14 = 10b indicate a valid signature for that bank.
Bruce Allanf4187b52008-08-26 18:36:50 -07002066 **/
2067static s32 e1000_valid_nvm_bank_detect_ich8lan(struct e1000_hw *hw, u32 *bank)
2068{
Bruce Allane2434552008-11-21 17:02:41 -08002069 u32 eecd;
Bruce Allanf4187b52008-08-26 18:36:50 -07002070 struct e1000_nvm_info *nvm = &hw->nvm;
Bruce Allanf4187b52008-08-26 18:36:50 -07002071 u32 bank1_offset = nvm->flash_bank_size * sizeof(u16);
2072 u32 act_offset = E1000_ICH_NVM_SIG_WORD * 2 + 1;
Bruce Allane2434552008-11-21 17:02:41 -08002073 u8 sig_byte = 0;
2074 s32 ret_val = 0;
Bruce Allanf4187b52008-08-26 18:36:50 -07002075
Bruce Allane2434552008-11-21 17:02:41 -08002076 switch (hw->mac.type) {
2077 case e1000_ich8lan:
2078 case e1000_ich9lan:
2079 eecd = er32(EECD);
2080 if ((eecd & E1000_EECD_SEC1VAL_VALID_MASK) ==
2081 E1000_EECD_SEC1VAL_VALID_MASK) {
2082 if (eecd & E1000_EECD_SEC1VAL)
Bruce Allanf4187b52008-08-26 18:36:50 -07002083 *bank = 1;
Bruce Allane2434552008-11-21 17:02:41 -08002084 else
2085 *bank = 0;
2086
2087 return 0;
Bruce Allanf4187b52008-08-26 18:36:50 -07002088 }
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002089 e_dbg("Unable to determine valid NVM bank via EEC - "
Bruce Allane2434552008-11-21 17:02:41 -08002090 "reading flash signature\n");
2091 /* fall-thru */
2092 default:
2093 /* set bank to 0 in case flash read fails */
2094 *bank = 0;
2095
2096 /* Check bank 0 */
2097 ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset,
2098 &sig_byte);
2099 if (ret_val)
2100 return ret_val;
2101 if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
2102 E1000_ICH_NVM_SIG_VALUE) {
2103 *bank = 0;
2104 return 0;
2105 }
2106
2107 /* Check bank 1 */
2108 ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset +
2109 bank1_offset,
2110 &sig_byte);
2111 if (ret_val)
2112 return ret_val;
2113 if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
2114 E1000_ICH_NVM_SIG_VALUE) {
2115 *bank = 1;
2116 return 0;
2117 }
2118
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002119 e_dbg("ERROR: No valid NVM bank present\n");
Bruce Allane2434552008-11-21 17:02:41 -08002120 return -E1000_ERR_NVM;
Bruce Allanf4187b52008-08-26 18:36:50 -07002121 }
2122
2123 return 0;
2124}
2125
2126/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07002127 * e1000_read_nvm_ich8lan - Read word(s) from the NVM
2128 * @hw: pointer to the HW structure
2129 * @offset: The offset (in bytes) of the word(s) to read.
2130 * @words: Size of data to read in words
2131 * @data: Pointer to the word(s) to read at offset.
2132 *
2133 * Reads a word(s) from the NVM using the flash access registers.
2134 **/
2135static s32 e1000_read_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
2136 u16 *data)
2137{
2138 struct e1000_nvm_info *nvm = &hw->nvm;
2139 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
2140 u32 act_offset;
Bruce Allan148675a2009-08-07 07:41:56 +00002141 s32 ret_val = 0;
Bruce Allanf4187b52008-08-26 18:36:50 -07002142 u32 bank = 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002143 u16 i, word;
2144
2145 if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
2146 (words == 0)) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002147 e_dbg("nvm parameter(s) out of bounds\n");
Bruce Allanca15df52009-10-26 11:23:43 +00002148 ret_val = -E1000_ERR_NVM;
2149 goto out;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002150 }
2151
Bruce Allan94d81862009-11-20 23:25:26 +00002152 nvm->ops.acquire(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002153
Bruce Allanf4187b52008-08-26 18:36:50 -07002154 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
Bruce Allan148675a2009-08-07 07:41:56 +00002155 if (ret_val) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002156 e_dbg("Could not detect valid bank, assuming bank 0\n");
Bruce Allan148675a2009-08-07 07:41:56 +00002157 bank = 0;
2158 }
Bruce Allanf4187b52008-08-26 18:36:50 -07002159
2160 act_offset = (bank) ? nvm->flash_bank_size : 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002161 act_offset += offset;
2162
Bruce Allan148675a2009-08-07 07:41:56 +00002163 ret_val = 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002164 for (i = 0; i < words; i++) {
Bruce Allanb9e06f72011-07-22 06:21:41 +00002165 if (dev_spec->shadow_ram[offset+i].modified) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07002166 data[i] = dev_spec->shadow_ram[offset+i].value;
2167 } else {
2168 ret_val = e1000_read_flash_word_ich8lan(hw,
2169 act_offset + i,
2170 &word);
2171 if (ret_val)
2172 break;
2173 data[i] = word;
2174 }
2175 }
2176
Bruce Allan94d81862009-11-20 23:25:26 +00002177 nvm->ops.release(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002178
Bruce Allane2434552008-11-21 17:02:41 -08002179out:
2180 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002181 e_dbg("NVM read error: %d\n", ret_val);
Bruce Allane2434552008-11-21 17:02:41 -08002182
Auke Kokbc7f75f2007-09-17 12:30:59 -07002183 return ret_val;
2184}
2185
2186/**
2187 * e1000_flash_cycle_init_ich8lan - Initialize flash
2188 * @hw: pointer to the HW structure
2189 *
2190 * This function does initial flash setup so that a new read/write/erase cycle
2191 * can be started.
2192 **/
2193static s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw)
2194{
2195 union ich8_hws_flash_status hsfsts;
2196 s32 ret_val = -E1000_ERR_NVM;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002197
2198 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
2199
2200 /* Check if the flash descriptor is valid */
2201 if (hsfsts.hsf_status.fldesvalid == 0) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002202 e_dbg("Flash descriptor invalid. "
Joe Perches2c73e1f2010-03-26 20:16:59 +00002203 "SW Sequencing must be used.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07002204 return -E1000_ERR_NVM;
2205 }
2206
2207 /* Clear FCERR and DAEL in hw status by writing 1 */
2208 hsfsts.hsf_status.flcerr = 1;
2209 hsfsts.hsf_status.dael = 1;
2210
2211 ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
2212
Bruce Allanad680762008-03-28 09:15:03 -07002213 /*
2214 * Either we should have a hardware SPI cycle in progress
Auke Kokbc7f75f2007-09-17 12:30:59 -07002215 * bit to check against, in order to start a new cycle or
2216 * FDONE bit should be changed in the hardware so that it
Auke Kok489815c2008-02-21 15:11:07 -08002217 * is 1 after hardware reset, which can then be used as an
Auke Kokbc7f75f2007-09-17 12:30:59 -07002218 * indication whether a cycle is in progress or has been
2219 * completed.
2220 */
2221
2222 if (hsfsts.hsf_status.flcinprog == 0) {
Bruce Allanad680762008-03-28 09:15:03 -07002223 /*
2224 * There is no cycle running at present,
Bruce Allan5ff5b662009-12-01 15:51:11 +00002225 * so we can start a cycle.
Bruce Allanad680762008-03-28 09:15:03 -07002226 * Begin by setting Flash Cycle Done.
2227 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002228 hsfsts.hsf_status.flcdone = 1;
2229 ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
2230 ret_val = 0;
2231 } else {
Bruce Allan90da0662011-01-06 07:02:53 +00002232 s32 i = 0;
2233
Bruce Allanad680762008-03-28 09:15:03 -07002234 /*
Bruce Allan5ff5b662009-12-01 15:51:11 +00002235 * Otherwise poll for sometime so the current
Bruce Allanad680762008-03-28 09:15:03 -07002236 * cycle has a chance to end before giving up.
2237 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002238 for (i = 0; i < ICH_FLASH_READ_COMMAND_TIMEOUT; i++) {
2239 hsfsts.regval = __er16flash(hw, ICH_FLASH_HSFSTS);
2240 if (hsfsts.hsf_status.flcinprog == 0) {
2241 ret_val = 0;
2242 break;
2243 }
2244 udelay(1);
2245 }
2246 if (ret_val == 0) {
Bruce Allanad680762008-03-28 09:15:03 -07002247 /*
2248 * Successful in waiting for previous cycle to timeout,
2249 * now set the Flash Cycle Done.
2250 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002251 hsfsts.hsf_status.flcdone = 1;
2252 ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
2253 } else {
Joe Perches2c73e1f2010-03-26 20:16:59 +00002254 e_dbg("Flash controller busy, cannot get access\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07002255 }
2256 }
2257
2258 return ret_val;
2259}
2260
2261/**
2262 * e1000_flash_cycle_ich8lan - Starts flash cycle (read/write/erase)
2263 * @hw: pointer to the HW structure
2264 * @timeout: maximum time to wait for completion
2265 *
2266 * This function starts a flash cycle and waits for its completion.
2267 **/
2268static s32 e1000_flash_cycle_ich8lan(struct e1000_hw *hw, u32 timeout)
2269{
2270 union ich8_hws_flash_ctrl hsflctl;
2271 union ich8_hws_flash_status hsfsts;
2272 s32 ret_val = -E1000_ERR_NVM;
2273 u32 i = 0;
2274
2275 /* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */
2276 hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
2277 hsflctl.hsf_ctrl.flcgo = 1;
2278 ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
2279
2280 /* wait till FDONE bit is set to 1 */
2281 do {
2282 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
2283 if (hsfsts.hsf_status.flcdone == 1)
2284 break;
2285 udelay(1);
2286 } while (i++ < timeout);
2287
2288 if (hsfsts.hsf_status.flcdone == 1 && hsfsts.hsf_status.flcerr == 0)
2289 return 0;
2290
2291 return ret_val;
2292}
2293
2294/**
2295 * e1000_read_flash_word_ich8lan - Read word from flash
2296 * @hw: pointer to the HW structure
2297 * @offset: offset to data location
2298 * @data: pointer to the location for storing the data
2299 *
2300 * Reads the flash word at offset into data. Offset is converted
2301 * to bytes before read.
2302 **/
2303static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset,
2304 u16 *data)
2305{
2306 /* Must convert offset into bytes. */
2307 offset <<= 1;
2308
2309 return e1000_read_flash_data_ich8lan(hw, offset, 2, data);
2310}
2311
2312/**
Bruce Allanf4187b52008-08-26 18:36:50 -07002313 * e1000_read_flash_byte_ich8lan - Read byte from flash
2314 * @hw: pointer to the HW structure
2315 * @offset: The offset of the byte to read.
2316 * @data: Pointer to a byte to store the value read.
2317 *
2318 * Reads a single byte from the NVM using the flash access registers.
2319 **/
2320static s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
2321 u8 *data)
2322{
2323 s32 ret_val;
2324 u16 word = 0;
2325
2326 ret_val = e1000_read_flash_data_ich8lan(hw, offset, 1, &word);
2327 if (ret_val)
2328 return ret_val;
2329
2330 *data = (u8)word;
2331
2332 return 0;
2333}
2334
2335/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07002336 * e1000_read_flash_data_ich8lan - Read byte or word from NVM
2337 * @hw: pointer to the HW structure
2338 * @offset: The offset (in bytes) of the byte or word to read.
2339 * @size: Size of data to read, 1=byte 2=word
2340 * @data: Pointer to the word to store the value read.
2341 *
2342 * Reads a byte or word from the NVM using the flash access registers.
2343 **/
2344static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
2345 u8 size, u16 *data)
2346{
2347 union ich8_hws_flash_status hsfsts;
2348 union ich8_hws_flash_ctrl hsflctl;
2349 u32 flash_linear_addr;
2350 u32 flash_data = 0;
2351 s32 ret_val = -E1000_ERR_NVM;
2352 u8 count = 0;
2353
2354 if (size < 1 || size > 2 || offset > ICH_FLASH_LINEAR_ADDR_MASK)
2355 return -E1000_ERR_NVM;
2356
2357 flash_linear_addr = (ICH_FLASH_LINEAR_ADDR_MASK & offset) +
2358 hw->nvm.flash_base_addr;
2359
2360 do {
2361 udelay(1);
2362 /* Steps */
2363 ret_val = e1000_flash_cycle_init_ich8lan(hw);
2364 if (ret_val != 0)
2365 break;
2366
2367 hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
2368 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
2369 hsflctl.hsf_ctrl.fldbcount = size - 1;
2370 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_READ;
2371 ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
2372
2373 ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
2374
2375 ret_val = e1000_flash_cycle_ich8lan(hw,
2376 ICH_FLASH_READ_COMMAND_TIMEOUT);
2377
Bruce Allanad680762008-03-28 09:15:03 -07002378 /*
2379 * Check if FCERR is set to 1, if set to 1, clear it
Auke Kokbc7f75f2007-09-17 12:30:59 -07002380 * and try the whole sequence a few more times, else
2381 * read in (shift in) the Flash Data0, the order is
Bruce Allanad680762008-03-28 09:15:03 -07002382 * least significant byte first msb to lsb
2383 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002384 if (ret_val == 0) {
2385 flash_data = er32flash(ICH_FLASH_FDATA0);
Bruce Allanb1cdfea2010-12-11 05:53:47 +00002386 if (size == 1)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002387 *data = (u8)(flash_data & 0x000000FF);
Bruce Allanb1cdfea2010-12-11 05:53:47 +00002388 else if (size == 2)
Auke Kokbc7f75f2007-09-17 12:30:59 -07002389 *data = (u16)(flash_data & 0x0000FFFF);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002390 break;
2391 } else {
Bruce Allanad680762008-03-28 09:15:03 -07002392 /*
2393 * If we've gotten here, then things are probably
Auke Kokbc7f75f2007-09-17 12:30:59 -07002394 * completely hosed, but if the error condition is
2395 * detected, it won't hurt to give it another try...
2396 * ICH_FLASH_CYCLE_REPEAT_COUNT times.
2397 */
2398 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
2399 if (hsfsts.hsf_status.flcerr == 1) {
2400 /* Repeat for some time before giving up. */
2401 continue;
2402 } else if (hsfsts.hsf_status.flcdone == 0) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002403 e_dbg("Timeout error - flash cycle "
Joe Perches2c73e1f2010-03-26 20:16:59 +00002404 "did not complete.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07002405 break;
2406 }
2407 }
2408 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
2409
2410 return ret_val;
2411}
2412
2413/**
2414 * e1000_write_nvm_ich8lan - Write word(s) to the NVM
2415 * @hw: pointer to the HW structure
2416 * @offset: The offset (in bytes) of the word(s) to write.
2417 * @words: Size of data to write in words
2418 * @data: Pointer to the word(s) to write at offset.
2419 *
2420 * Writes a byte or word to the NVM using the flash access registers.
2421 **/
2422static s32 e1000_write_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
2423 u16 *data)
2424{
2425 struct e1000_nvm_info *nvm = &hw->nvm;
2426 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002427 u16 i;
2428
2429 if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
2430 (words == 0)) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002431 e_dbg("nvm parameter(s) out of bounds\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07002432 return -E1000_ERR_NVM;
2433 }
2434
Bruce Allan94d81862009-11-20 23:25:26 +00002435 nvm->ops.acquire(hw);
Bruce Allanca15df52009-10-26 11:23:43 +00002436
Auke Kokbc7f75f2007-09-17 12:30:59 -07002437 for (i = 0; i < words; i++) {
Bruce Allan564ea9b2009-11-20 23:26:44 +00002438 dev_spec->shadow_ram[offset+i].modified = true;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002439 dev_spec->shadow_ram[offset+i].value = data[i];
2440 }
2441
Bruce Allan94d81862009-11-20 23:25:26 +00002442 nvm->ops.release(hw);
Bruce Allanca15df52009-10-26 11:23:43 +00002443
Auke Kokbc7f75f2007-09-17 12:30:59 -07002444 return 0;
2445}
2446
2447/**
2448 * e1000_update_nvm_checksum_ich8lan - Update the checksum for NVM
2449 * @hw: pointer to the HW structure
2450 *
2451 * The NVM checksum is updated by calling the generic update_nvm_checksum,
2452 * which writes the checksum to the shadow ram. The changes in the shadow
2453 * ram are then committed to the EEPROM by processing each bank at a time
2454 * checking for the modified bit and writing only the pending changes.
Auke Kok489815c2008-02-21 15:11:07 -08002455 * After a successful commit, the shadow ram is cleared and is ready for
Auke Kokbc7f75f2007-09-17 12:30:59 -07002456 * future writes.
2457 **/
2458static s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw)
2459{
2460 struct e1000_nvm_info *nvm = &hw->nvm;
2461 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
Bruce Allanf4187b52008-08-26 18:36:50 -07002462 u32 i, act_offset, new_bank_offset, old_bank_offset, bank;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002463 s32 ret_val;
2464 u16 data;
2465
2466 ret_val = e1000e_update_nvm_checksum_generic(hw);
2467 if (ret_val)
Bruce Allane2434552008-11-21 17:02:41 -08002468 goto out;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002469
2470 if (nvm->type != e1000_nvm_flash_sw)
Bruce Allane2434552008-11-21 17:02:41 -08002471 goto out;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002472
Bruce Allan94d81862009-11-20 23:25:26 +00002473 nvm->ops.acquire(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002474
Bruce Allanad680762008-03-28 09:15:03 -07002475 /*
2476 * We're writing to the opposite bank so if we're on bank 1,
Auke Kokbc7f75f2007-09-17 12:30:59 -07002477 * write to bank 0 etc. We also need to erase the segment that
Bruce Allanad680762008-03-28 09:15:03 -07002478 * is going to be written
2479 */
Bruce Allanf4187b52008-08-26 18:36:50 -07002480 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
Bruce Allane2434552008-11-21 17:02:41 -08002481 if (ret_val) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002482 e_dbg("Could not detect valid bank, assuming bank 0\n");
Bruce Allan148675a2009-08-07 07:41:56 +00002483 bank = 0;
Bruce Allane2434552008-11-21 17:02:41 -08002484 }
Bruce Allanf4187b52008-08-26 18:36:50 -07002485
2486 if (bank == 0) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07002487 new_bank_offset = nvm->flash_bank_size;
2488 old_bank_offset = 0;
Bruce Allane2434552008-11-21 17:02:41 -08002489 ret_val = e1000_erase_flash_bank_ich8lan(hw, 1);
Bruce Allan9c5e2092010-05-10 15:00:31 +00002490 if (ret_val)
2491 goto release;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002492 } else {
2493 old_bank_offset = nvm->flash_bank_size;
2494 new_bank_offset = 0;
Bruce Allane2434552008-11-21 17:02:41 -08002495 ret_val = e1000_erase_flash_bank_ich8lan(hw, 0);
Bruce Allan9c5e2092010-05-10 15:00:31 +00002496 if (ret_val)
2497 goto release;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002498 }
2499
2500 for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i++) {
Bruce Allanad680762008-03-28 09:15:03 -07002501 /*
2502 * Determine whether to write the value stored
Auke Kokbc7f75f2007-09-17 12:30:59 -07002503 * in the other NVM bank or a modified value stored
Bruce Allanad680762008-03-28 09:15:03 -07002504 * in the shadow RAM
2505 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002506 if (dev_spec->shadow_ram[i].modified) {
2507 data = dev_spec->shadow_ram[i].value;
2508 } else {
Bruce Allane2434552008-11-21 17:02:41 -08002509 ret_val = e1000_read_flash_word_ich8lan(hw, i +
2510 old_bank_offset,
2511 &data);
2512 if (ret_val)
2513 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002514 }
2515
Bruce Allanad680762008-03-28 09:15:03 -07002516 /*
2517 * If the word is 0x13, then make sure the signature bits
Auke Kokbc7f75f2007-09-17 12:30:59 -07002518 * (15:14) are 11b until the commit has completed.
2519 * This will allow us to write 10b which indicates the
2520 * signature is valid. We want to do this after the write
2521 * has completed so that we don't mark the segment valid
Bruce Allanad680762008-03-28 09:15:03 -07002522 * while the write is still in progress
2523 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002524 if (i == E1000_ICH_NVM_SIG_WORD)
2525 data |= E1000_ICH_NVM_SIG_MASK;
2526
2527 /* Convert offset to bytes. */
2528 act_offset = (i + new_bank_offset) << 1;
2529
2530 udelay(100);
2531 /* Write the bytes to the new bank. */
2532 ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
2533 act_offset,
2534 (u8)data);
2535 if (ret_val)
2536 break;
2537
2538 udelay(100);
2539 ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
2540 act_offset + 1,
2541 (u8)(data >> 8));
2542 if (ret_val)
2543 break;
2544 }
2545
Bruce Allanad680762008-03-28 09:15:03 -07002546 /*
2547 * Don't bother writing the segment valid bits if sector
2548 * programming failed.
2549 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002550 if (ret_val) {
Bruce Allan4a770352008-10-01 17:18:35 -07002551 /* Possibly read-only, see e1000e_write_protect_nvm_ich8lan() */
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002552 e_dbg("Flash commit failed.\n");
Bruce Allan9c5e2092010-05-10 15:00:31 +00002553 goto release;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002554 }
2555
Bruce Allanad680762008-03-28 09:15:03 -07002556 /*
2557 * Finally validate the new segment by setting bit 15:14
Auke Kokbc7f75f2007-09-17 12:30:59 -07002558 * to 10b in word 0x13 , this can be done without an
2559 * erase as well since these bits are 11 to start with
Bruce Allanad680762008-03-28 09:15:03 -07002560 * and we need to change bit 14 to 0b
2561 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002562 act_offset = new_bank_offset + E1000_ICH_NVM_SIG_WORD;
Bruce Allane2434552008-11-21 17:02:41 -08002563 ret_val = e1000_read_flash_word_ich8lan(hw, act_offset, &data);
Bruce Allan9c5e2092010-05-10 15:00:31 +00002564 if (ret_val)
2565 goto release;
2566
Auke Kokbc7f75f2007-09-17 12:30:59 -07002567 data &= 0xBFFF;
2568 ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
2569 act_offset * 2 + 1,
2570 (u8)(data >> 8));
Bruce Allan9c5e2092010-05-10 15:00:31 +00002571 if (ret_val)
2572 goto release;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002573
Bruce Allanad680762008-03-28 09:15:03 -07002574 /*
2575 * And invalidate the previously valid segment by setting
Auke Kokbc7f75f2007-09-17 12:30:59 -07002576 * its signature word (0x13) high_byte to 0b. This can be
2577 * done without an erase because flash erase sets all bits
Bruce Allanad680762008-03-28 09:15:03 -07002578 * to 1's. We can write 1's to 0's without an erase
2579 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002580 act_offset = (old_bank_offset + E1000_ICH_NVM_SIG_WORD) * 2 + 1;
2581 ret_val = e1000_retry_write_flash_byte_ich8lan(hw, act_offset, 0);
Bruce Allan9c5e2092010-05-10 15:00:31 +00002582 if (ret_val)
2583 goto release;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002584
2585 /* Great! Everything worked, we can now clear the cached entries. */
2586 for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i++) {
Bruce Allan564ea9b2009-11-20 23:26:44 +00002587 dev_spec->shadow_ram[i].modified = false;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002588 dev_spec->shadow_ram[i].value = 0xFFFF;
2589 }
2590
Bruce Allan9c5e2092010-05-10 15:00:31 +00002591release:
Bruce Allan94d81862009-11-20 23:25:26 +00002592 nvm->ops.release(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002593
Bruce Allanad680762008-03-28 09:15:03 -07002594 /*
2595 * Reload the EEPROM, or else modifications will not appear
Auke Kokbc7f75f2007-09-17 12:30:59 -07002596 * until after the next adapter reset.
2597 */
Bruce Allan9c5e2092010-05-10 15:00:31 +00002598 if (!ret_val) {
2599 e1000e_reload_nvm(hw);
Bruce Allan1bba4382011-03-19 00:27:20 +00002600 usleep_range(10000, 20000);
Bruce Allan9c5e2092010-05-10 15:00:31 +00002601 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07002602
Bruce Allane2434552008-11-21 17:02:41 -08002603out:
2604 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002605 e_dbg("NVM update error: %d\n", ret_val);
Bruce Allane2434552008-11-21 17:02:41 -08002606
Auke Kokbc7f75f2007-09-17 12:30:59 -07002607 return ret_val;
2608}
2609
2610/**
2611 * e1000_validate_nvm_checksum_ich8lan - Validate EEPROM checksum
2612 * @hw: pointer to the HW structure
2613 *
2614 * Check to see if checksum needs to be fixed by reading bit 6 in word 0x19.
2615 * If the bit is 0, that the EEPROM had been modified, but the checksum was not
2616 * calculated, in which case we need to calculate the checksum and set bit 6.
2617 **/
2618static s32 e1000_validate_nvm_checksum_ich8lan(struct e1000_hw *hw)
2619{
2620 s32 ret_val;
2621 u16 data;
2622
Bruce Allanad680762008-03-28 09:15:03 -07002623 /*
2624 * Read 0x19 and check bit 6. If this bit is 0, the checksum
Auke Kokbc7f75f2007-09-17 12:30:59 -07002625 * needs to be fixed. This bit is an indication that the NVM
2626 * was prepared by OEM software and did not calculate the
2627 * checksum...a likely scenario.
2628 */
2629 ret_val = e1000_read_nvm(hw, 0x19, 1, &data);
2630 if (ret_val)
2631 return ret_val;
2632
2633 if ((data & 0x40) == 0) {
2634 data |= 0x40;
2635 ret_val = e1000_write_nvm(hw, 0x19, 1, &data);
2636 if (ret_val)
2637 return ret_val;
2638 ret_val = e1000e_update_nvm_checksum(hw);
2639 if (ret_val)
2640 return ret_val;
2641 }
2642
2643 return e1000e_validate_nvm_checksum_generic(hw);
2644}
2645
2646/**
Bruce Allan4a770352008-10-01 17:18:35 -07002647 * e1000e_write_protect_nvm_ich8lan - Make the NVM read-only
2648 * @hw: pointer to the HW structure
2649 *
2650 * To prevent malicious write/erase of the NVM, set it to be read-only
2651 * so that the hardware ignores all write/erase cycles of the NVM via
2652 * the flash control registers. The shadow-ram copy of the NVM will
2653 * still be updated, however any updates to this copy will not stick
2654 * across driver reloads.
2655 **/
2656void e1000e_write_protect_nvm_ich8lan(struct e1000_hw *hw)
2657{
Bruce Allanca15df52009-10-26 11:23:43 +00002658 struct e1000_nvm_info *nvm = &hw->nvm;
Bruce Allan4a770352008-10-01 17:18:35 -07002659 union ich8_flash_protected_range pr0;
2660 union ich8_hws_flash_status hsfsts;
2661 u32 gfpreg;
Bruce Allan4a770352008-10-01 17:18:35 -07002662
Bruce Allan94d81862009-11-20 23:25:26 +00002663 nvm->ops.acquire(hw);
Bruce Allan4a770352008-10-01 17:18:35 -07002664
2665 gfpreg = er32flash(ICH_FLASH_GFPREG);
2666
2667 /* Write-protect GbE Sector of NVM */
2668 pr0.regval = er32flash(ICH_FLASH_PR0);
2669 pr0.range.base = gfpreg & FLASH_GFPREG_BASE_MASK;
2670 pr0.range.limit = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK);
2671 pr0.range.wpe = true;
2672 ew32flash(ICH_FLASH_PR0, pr0.regval);
2673
2674 /*
2675 * Lock down a subset of GbE Flash Control Registers, e.g.
2676 * PR0 to prevent the write-protection from being lifted.
2677 * Once FLOCKDN is set, the registers protected by it cannot
2678 * be written until FLOCKDN is cleared by a hardware reset.
2679 */
2680 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
2681 hsfsts.hsf_status.flockdn = true;
2682 ew32flash(ICH_FLASH_HSFSTS, hsfsts.regval);
2683
Bruce Allan94d81862009-11-20 23:25:26 +00002684 nvm->ops.release(hw);
Bruce Allan4a770352008-10-01 17:18:35 -07002685}
2686
2687/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07002688 * e1000_write_flash_data_ich8lan - Writes bytes to the NVM
2689 * @hw: pointer to the HW structure
2690 * @offset: The offset (in bytes) of the byte/word to read.
2691 * @size: Size of data to read, 1=byte 2=word
2692 * @data: The byte(s) to write to the NVM.
2693 *
2694 * Writes one/two bytes to the NVM using the flash access registers.
2695 **/
2696static s32 e1000_write_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
2697 u8 size, u16 data)
2698{
2699 union ich8_hws_flash_status hsfsts;
2700 union ich8_hws_flash_ctrl hsflctl;
2701 u32 flash_linear_addr;
2702 u32 flash_data = 0;
2703 s32 ret_val;
2704 u8 count = 0;
2705
2706 if (size < 1 || size > 2 || data > size * 0xff ||
2707 offset > ICH_FLASH_LINEAR_ADDR_MASK)
2708 return -E1000_ERR_NVM;
2709
2710 flash_linear_addr = (ICH_FLASH_LINEAR_ADDR_MASK & offset) +
2711 hw->nvm.flash_base_addr;
2712
2713 do {
2714 udelay(1);
2715 /* Steps */
2716 ret_val = e1000_flash_cycle_init_ich8lan(hw);
2717 if (ret_val)
2718 break;
2719
2720 hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
2721 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
2722 hsflctl.hsf_ctrl.fldbcount = size -1;
2723 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_WRITE;
2724 ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
2725
2726 ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
2727
2728 if (size == 1)
2729 flash_data = (u32)data & 0x00FF;
2730 else
2731 flash_data = (u32)data;
2732
2733 ew32flash(ICH_FLASH_FDATA0, flash_data);
2734
Bruce Allanad680762008-03-28 09:15:03 -07002735 /*
2736 * check if FCERR is set to 1 , if set to 1, clear it
2737 * and try the whole sequence a few more times else done
2738 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002739 ret_val = e1000_flash_cycle_ich8lan(hw,
2740 ICH_FLASH_WRITE_COMMAND_TIMEOUT);
2741 if (!ret_val)
2742 break;
2743
Bruce Allanad680762008-03-28 09:15:03 -07002744 /*
2745 * If we're here, then things are most likely
Auke Kokbc7f75f2007-09-17 12:30:59 -07002746 * completely hosed, but if the error condition
2747 * is detected, it won't hurt to give it another
2748 * try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
2749 */
2750 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
2751 if (hsfsts.hsf_status.flcerr == 1)
2752 /* Repeat for some time before giving up. */
2753 continue;
2754 if (hsfsts.hsf_status.flcdone == 0) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002755 e_dbg("Timeout error - flash cycle "
Auke Kokbc7f75f2007-09-17 12:30:59 -07002756 "did not complete.");
2757 break;
2758 }
2759 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
2760
2761 return ret_val;
2762}
2763
2764/**
2765 * e1000_write_flash_byte_ich8lan - Write a single byte to NVM
2766 * @hw: pointer to the HW structure
2767 * @offset: The index of the byte to read.
2768 * @data: The byte to write to the NVM.
2769 *
2770 * Writes a single byte to the NVM using the flash access registers.
2771 **/
2772static s32 e1000_write_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
2773 u8 data)
2774{
2775 u16 word = (u16)data;
2776
2777 return e1000_write_flash_data_ich8lan(hw, offset, 1, word);
2778}
2779
2780/**
2781 * e1000_retry_write_flash_byte_ich8lan - Writes a single byte to NVM
2782 * @hw: pointer to the HW structure
2783 * @offset: The offset of the byte to write.
2784 * @byte: The byte to write to the NVM.
2785 *
2786 * Writes a single byte to the NVM using the flash access registers.
2787 * Goes through a retry algorithm before giving up.
2788 **/
2789static s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw,
2790 u32 offset, u8 byte)
2791{
2792 s32 ret_val;
2793 u16 program_retries;
2794
2795 ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
2796 if (!ret_val)
2797 return ret_val;
2798
2799 for (program_retries = 0; program_retries < 100; program_retries++) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002800 e_dbg("Retrying Byte %2.2X at offset %u\n", byte, offset);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002801 udelay(100);
2802 ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
2803 if (!ret_val)
2804 break;
2805 }
2806 if (program_retries == 100)
2807 return -E1000_ERR_NVM;
2808
2809 return 0;
2810}
2811
2812/**
2813 * e1000_erase_flash_bank_ich8lan - Erase a bank (4k) from NVM
2814 * @hw: pointer to the HW structure
2815 * @bank: 0 for first bank, 1 for second bank, etc.
2816 *
2817 * Erases the bank specified. Each bank is a 4k block. Banks are 0 based.
2818 * bank N is 4096 * N + flash_reg_addr.
2819 **/
2820static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank)
2821{
2822 struct e1000_nvm_info *nvm = &hw->nvm;
2823 union ich8_hws_flash_status hsfsts;
2824 union ich8_hws_flash_ctrl hsflctl;
2825 u32 flash_linear_addr;
2826 /* bank size is in 16bit words - adjust to bytes */
2827 u32 flash_bank_size = nvm->flash_bank_size * 2;
2828 s32 ret_val;
2829 s32 count = 0;
Bruce Allana708dd82009-11-20 23:28:37 +00002830 s32 j, iteration, sector_size;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002831
2832 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
2833
Bruce Allanad680762008-03-28 09:15:03 -07002834 /*
2835 * Determine HW Sector size: Read BERASE bits of hw flash status
2836 * register
2837 * 00: The Hw sector is 256 bytes, hence we need to erase 16
Auke Kokbc7f75f2007-09-17 12:30:59 -07002838 * consecutive sectors. The start index for the nth Hw sector
2839 * can be calculated as = bank * 4096 + n * 256
2840 * 01: The Hw sector is 4K bytes, hence we need to erase 1 sector.
2841 * The start index for the nth Hw sector can be calculated
2842 * as = bank * 4096
2843 * 10: The Hw sector is 8K bytes, nth sector = bank * 8192
2844 * (ich9 only, otherwise error condition)
2845 * 11: The Hw sector is 64K bytes, nth sector = bank * 65536
2846 */
2847 switch (hsfsts.hsf_status.berasesz) {
2848 case 0:
2849 /* Hw sector size 256 */
2850 sector_size = ICH_FLASH_SEG_SIZE_256;
2851 iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_256;
2852 break;
2853 case 1:
2854 sector_size = ICH_FLASH_SEG_SIZE_4K;
Bruce Allan28c91952009-07-01 13:28:32 +00002855 iteration = 1;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002856 break;
2857 case 2:
Bruce Allan148675a2009-08-07 07:41:56 +00002858 sector_size = ICH_FLASH_SEG_SIZE_8K;
2859 iteration = 1;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002860 break;
2861 case 3:
2862 sector_size = ICH_FLASH_SEG_SIZE_64K;
Bruce Allan28c91952009-07-01 13:28:32 +00002863 iteration = 1;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002864 break;
2865 default:
2866 return -E1000_ERR_NVM;
2867 }
2868
2869 /* Start with the base address, then add the sector offset. */
2870 flash_linear_addr = hw->nvm.flash_base_addr;
Bruce Allan148675a2009-08-07 07:41:56 +00002871 flash_linear_addr += (bank) ? flash_bank_size : 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002872
2873 for (j = 0; j < iteration ; j++) {
2874 do {
2875 /* Steps */
2876 ret_val = e1000_flash_cycle_init_ich8lan(hw);
2877 if (ret_val)
2878 return ret_val;
2879
Bruce Allanad680762008-03-28 09:15:03 -07002880 /*
2881 * Write a value 11 (block Erase) in Flash
2882 * Cycle field in hw flash control
2883 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002884 hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
2885 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_ERASE;
2886 ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
2887
Bruce Allanad680762008-03-28 09:15:03 -07002888 /*
2889 * Write the last 24 bits of an index within the
Auke Kokbc7f75f2007-09-17 12:30:59 -07002890 * block into Flash Linear address field in Flash
2891 * Address.
2892 */
2893 flash_linear_addr += (j * sector_size);
2894 ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
2895
2896 ret_val = e1000_flash_cycle_ich8lan(hw,
2897 ICH_FLASH_ERASE_COMMAND_TIMEOUT);
2898 if (ret_val == 0)
2899 break;
2900
Bruce Allanad680762008-03-28 09:15:03 -07002901 /*
2902 * Check if FCERR is set to 1. If 1,
Auke Kokbc7f75f2007-09-17 12:30:59 -07002903 * clear it and try the whole sequence
Bruce Allanad680762008-03-28 09:15:03 -07002904 * a few more times else Done
2905 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002906 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
2907 if (hsfsts.hsf_status.flcerr == 1)
Bruce Allanad680762008-03-28 09:15:03 -07002908 /* repeat for some time before giving up */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002909 continue;
2910 else if (hsfsts.hsf_status.flcdone == 0)
2911 return ret_val;
2912 } while (++count < ICH_FLASH_CYCLE_REPEAT_COUNT);
2913 }
2914
2915 return 0;
2916}
2917
2918/**
2919 * e1000_valid_led_default_ich8lan - Set the default LED settings
2920 * @hw: pointer to the HW structure
2921 * @data: Pointer to the LED settings
2922 *
2923 * Reads the LED default settings from the NVM to data. If the NVM LED
2924 * settings is all 0's or F's, set the LED default to a valid LED default
2925 * setting.
2926 **/
2927static s32 e1000_valid_led_default_ich8lan(struct e1000_hw *hw, u16 *data)
2928{
2929 s32 ret_val;
2930
2931 ret_val = e1000_read_nvm(hw, NVM_ID_LED_SETTINGS, 1, data);
2932 if (ret_val) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00002933 e_dbg("NVM Read Error\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07002934 return ret_val;
2935 }
2936
2937 if (*data == ID_LED_RESERVED_0000 ||
2938 *data == ID_LED_RESERVED_FFFF)
2939 *data = ID_LED_DEFAULT_ICH8LAN;
2940
2941 return 0;
2942}
2943
2944/**
Bruce Allana4f58f52009-06-02 11:29:18 +00002945 * e1000_id_led_init_pchlan - store LED configurations
2946 * @hw: pointer to the HW structure
2947 *
2948 * PCH does not control LEDs via the LEDCTL register, rather it uses
2949 * the PHY LED configuration register.
2950 *
2951 * PCH also does not have an "always on" or "always off" mode which
2952 * complicates the ID feature. Instead of using the "on" mode to indicate
2953 * in ledctl_mode2 the LEDs to use for ID (see e1000e_id_led_init()),
2954 * use "link_up" mode. The LEDs will still ID on request if there is no
2955 * link based on logic in e1000_led_[on|off]_pchlan().
2956 **/
2957static s32 e1000_id_led_init_pchlan(struct e1000_hw *hw)
2958{
2959 struct e1000_mac_info *mac = &hw->mac;
2960 s32 ret_val;
2961 const u32 ledctl_on = E1000_LEDCTL_MODE_LINK_UP;
2962 const u32 ledctl_off = E1000_LEDCTL_MODE_LINK_UP | E1000_PHY_LED0_IVRT;
2963 u16 data, i, temp, shift;
2964
2965 /* Get default ID LED modes */
2966 ret_val = hw->nvm.ops.valid_led_default(hw, &data);
2967 if (ret_val)
2968 goto out;
2969
2970 mac->ledctl_default = er32(LEDCTL);
2971 mac->ledctl_mode1 = mac->ledctl_default;
2972 mac->ledctl_mode2 = mac->ledctl_default;
2973
2974 for (i = 0; i < 4; i++) {
2975 temp = (data >> (i << 2)) & E1000_LEDCTL_LED0_MODE_MASK;
2976 shift = (i * 5);
2977 switch (temp) {
2978 case ID_LED_ON1_DEF2:
2979 case ID_LED_ON1_ON2:
2980 case ID_LED_ON1_OFF2:
2981 mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
2982 mac->ledctl_mode1 |= (ledctl_on << shift);
2983 break;
2984 case ID_LED_OFF1_DEF2:
2985 case ID_LED_OFF1_ON2:
2986 case ID_LED_OFF1_OFF2:
2987 mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
2988 mac->ledctl_mode1 |= (ledctl_off << shift);
2989 break;
2990 default:
2991 /* Do nothing */
2992 break;
2993 }
2994 switch (temp) {
2995 case ID_LED_DEF1_ON2:
2996 case ID_LED_ON1_ON2:
2997 case ID_LED_OFF1_ON2:
2998 mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
2999 mac->ledctl_mode2 |= (ledctl_on << shift);
3000 break;
3001 case ID_LED_DEF1_OFF2:
3002 case ID_LED_ON1_OFF2:
3003 case ID_LED_OFF1_OFF2:
3004 mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
3005 mac->ledctl_mode2 |= (ledctl_off << shift);
3006 break;
3007 default:
3008 /* Do nothing */
3009 break;
3010 }
3011 }
3012
3013out:
3014 return ret_val;
3015}
3016
3017/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07003018 * e1000_get_bus_info_ich8lan - Get/Set the bus type and width
3019 * @hw: pointer to the HW structure
3020 *
3021 * ICH8 use the PCI Express bus, but does not contain a PCI Express Capability
3022 * register, so the the bus width is hard coded.
3023 **/
3024static s32 e1000_get_bus_info_ich8lan(struct e1000_hw *hw)
3025{
3026 struct e1000_bus_info *bus = &hw->bus;
3027 s32 ret_val;
3028
3029 ret_val = e1000e_get_bus_info_pcie(hw);
3030
Bruce Allanad680762008-03-28 09:15:03 -07003031 /*
3032 * ICH devices are "PCI Express"-ish. They have
Auke Kokbc7f75f2007-09-17 12:30:59 -07003033 * a configuration space, but do not contain
3034 * PCI Express Capability registers, so bus width
3035 * must be hardcoded.
3036 */
3037 if (bus->width == e1000_bus_width_unknown)
3038 bus->width = e1000_bus_width_pcie_x1;
3039
3040 return ret_val;
3041}
3042
3043/**
3044 * e1000_reset_hw_ich8lan - Reset the hardware
3045 * @hw: pointer to the HW structure
3046 *
3047 * Does a full reset of the hardware which includes a reset of the PHY and
3048 * MAC.
3049 **/
3050static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
3051{
Bruce Allan1d5846b2009-10-29 13:46:05 +00003052 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
Bruce Allandb2932e2009-10-26 11:22:47 +00003053 u16 reg;
Bruce Allandd93f952011-01-06 14:29:48 +00003054 u32 ctrl, kab;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003055 s32 ret_val;
3056
Bruce Allanad680762008-03-28 09:15:03 -07003057 /*
3058 * Prevent the PCI-E bus from sticking if there is no TLP connection
Auke Kokbc7f75f2007-09-17 12:30:59 -07003059 * on the last TLP read/write transaction when MAC is reset.
3060 */
3061 ret_val = e1000e_disable_pcie_master(hw);
Bruce Allane98cac42010-05-10 15:02:32 +00003062 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003063 e_dbg("PCI-E Master disable polling has failed.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07003064
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003065 e_dbg("Masking off all interrupts\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07003066 ew32(IMC, 0xffffffff);
3067
Bruce Allanad680762008-03-28 09:15:03 -07003068 /*
3069 * Disable the Transmit and Receive units. Then delay to allow
Auke Kokbc7f75f2007-09-17 12:30:59 -07003070 * any pending transactions to complete before we hit the MAC
3071 * with the global reset.
3072 */
3073 ew32(RCTL, 0);
3074 ew32(TCTL, E1000_TCTL_PSP);
3075 e1e_flush();
3076
Bruce Allan1bba4382011-03-19 00:27:20 +00003077 usleep_range(10000, 20000);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003078
3079 /* Workaround for ICH8 bit corruption issue in FIFO memory */
3080 if (hw->mac.type == e1000_ich8lan) {
3081 /* Set Tx and Rx buffer allocation to 8k apiece. */
3082 ew32(PBA, E1000_PBA_8K);
3083 /* Set Packet Buffer Size to 16k. */
3084 ew32(PBS, E1000_PBS_16K);
3085 }
3086
Bruce Allan1d5846b2009-10-29 13:46:05 +00003087 if (hw->mac.type == e1000_pchlan) {
3088 /* Save the NVM K1 bit setting*/
3089 ret_val = e1000_read_nvm(hw, E1000_NVM_K1_CONFIG, 1, &reg);
3090 if (ret_val)
3091 return ret_val;
3092
3093 if (reg & E1000_NVM_K1_ENABLE)
3094 dev_spec->nvm_k1_enabled = true;
3095 else
3096 dev_spec->nvm_k1_enabled = false;
3097 }
3098
Auke Kokbc7f75f2007-09-17 12:30:59 -07003099 ctrl = er32(CTRL);
3100
3101 if (!e1000_check_reset_block(hw)) {
Bruce Allanad680762008-03-28 09:15:03 -07003102 /*
Bruce Allane98cac42010-05-10 15:02:32 +00003103 * Full-chip reset requires MAC and PHY reset at the same
Auke Kokbc7f75f2007-09-17 12:30:59 -07003104 * time to make sure the interface between MAC and the
3105 * external PHY is reset.
3106 */
3107 ctrl |= E1000_CTRL_PHY_RST;
Bruce Allan605c82b2010-09-22 17:17:01 +00003108
3109 /*
3110 * Gate automatic PHY configuration by hardware on
3111 * non-managed 82579
3112 */
3113 if ((hw->mac.type == e1000_pch2lan) &&
3114 !(er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
3115 e1000_gate_hw_phy_config_ich8lan(hw, true);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003116 }
3117 ret_val = e1000_acquire_swflag_ich8lan(hw);
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003118 e_dbg("Issuing a global reset to ich8lan\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07003119 ew32(CTRL, (ctrl | E1000_CTRL_RST));
Jesse Brandeburg945a5152011-07-20 00:56:21 +00003120 /* cannot issue a flush here because it hangs the hardware */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003121 msleep(20);
3122
Bruce Allanfc0c7762009-07-01 13:27:55 +00003123 if (!ret_val)
Bruce Allanc5caf482011-05-13 07:19:53 +00003124 mutex_unlock(&swflag_mutex);
Jesse Brandeburg37f40232008-10-02 16:33:20 -07003125
Bruce Allane98cac42010-05-10 15:02:32 +00003126 if (ctrl & E1000_CTRL_PHY_RST) {
Bruce Allanfc0c7762009-07-01 13:27:55 +00003127 ret_val = hw->phy.ops.get_cfg_done(hw);
Bruce Allane98cac42010-05-10 15:02:32 +00003128 if (ret_val)
3129 goto out;
Bruce Allanfc0c7762009-07-01 13:27:55 +00003130
Bruce Allane98cac42010-05-10 15:02:32 +00003131 ret_val = e1000_post_phy_reset_ich8lan(hw);
Bruce Allanf523d212009-10-29 13:45:45 +00003132 if (ret_val)
3133 goto out;
3134 }
Bruce Allane98cac42010-05-10 15:02:32 +00003135
Bruce Allan7d3cabb2009-07-01 13:29:08 +00003136 /*
3137 * For PCH, this write will make sure that any noise
3138 * will be detected as a CRC error and be dropped rather than show up
3139 * as a bad packet to the DMA engine.
3140 */
3141 if (hw->mac.type == e1000_pchlan)
3142 ew32(CRC_OFFSET, 0x65656565);
3143
Auke Kokbc7f75f2007-09-17 12:30:59 -07003144 ew32(IMC, 0xffffffff);
Bruce Allandd93f952011-01-06 14:29:48 +00003145 er32(ICR);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003146
3147 kab = er32(KABGTXD);
3148 kab |= E1000_KABGTXD_BGSQLBIAS;
3149 ew32(KABGTXD, kab);
3150
Bruce Allanf523d212009-10-29 13:45:45 +00003151out:
Auke Kokbc7f75f2007-09-17 12:30:59 -07003152 return ret_val;
3153}
3154
3155/**
3156 * e1000_init_hw_ich8lan - Initialize the hardware
3157 * @hw: pointer to the HW structure
3158 *
3159 * Prepares the hardware for transmit and receive by doing the following:
3160 * - initialize hardware bits
3161 * - initialize LED identification
3162 * - setup receive address registers
3163 * - setup flow control
Auke Kok489815c2008-02-21 15:11:07 -08003164 * - setup transmit descriptors
Auke Kokbc7f75f2007-09-17 12:30:59 -07003165 * - clear statistics
3166 **/
3167static s32 e1000_init_hw_ich8lan(struct e1000_hw *hw)
3168{
3169 struct e1000_mac_info *mac = &hw->mac;
3170 u32 ctrl_ext, txdctl, snoop;
3171 s32 ret_val;
3172 u16 i;
3173
3174 e1000_initialize_hw_bits_ich8lan(hw);
3175
3176 /* Initialize identification LED */
Bruce Allana4f58f52009-06-02 11:29:18 +00003177 ret_val = mac->ops.id_led_init(hw);
Bruce Allande39b752009-11-20 23:27:59 +00003178 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003179 e_dbg("Error initializing identification LED\n");
Bruce Allande39b752009-11-20 23:27:59 +00003180 /* This is not fatal and we should not stop init due to this */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003181
3182 /* Setup the receive address. */
3183 e1000e_init_rx_addrs(hw, mac->rar_entry_count);
3184
3185 /* Zero out the Multicast HASH table */
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003186 e_dbg("Zeroing the MTA\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07003187 for (i = 0; i < mac->mta_reg_count; i++)
3188 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
3189
Bruce Allanfc0c7762009-07-01 13:27:55 +00003190 /*
3191 * The 82578 Rx buffer will stall if wakeup is enabled in host and
Bruce Allan3ebfc7c2011-05-13 07:20:14 +00003192 * the ME. Disable wakeup by clearing the host wakeup bit.
Bruce Allanfc0c7762009-07-01 13:27:55 +00003193 * Reset the phy after disabling host wakeup to reset the Rx buffer.
3194 */
3195 if (hw->phy.type == e1000_phy_82578) {
Bruce Allan3ebfc7c2011-05-13 07:20:14 +00003196 e1e_rphy(hw, BM_PORT_GEN_CFG, &i);
3197 i &= ~BM_WUC_HOST_WU_BIT;
3198 e1e_wphy(hw, BM_PORT_GEN_CFG, i);
Bruce Allanfc0c7762009-07-01 13:27:55 +00003199 ret_val = e1000_phy_hw_reset_ich8lan(hw);
3200 if (ret_val)
3201 return ret_val;
3202 }
3203
Auke Kokbc7f75f2007-09-17 12:30:59 -07003204 /* Setup link and flow control */
3205 ret_val = e1000_setup_link_ich8lan(hw);
3206
3207 /* Set the transmit descriptor write-back policy for both queues */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003208 txdctl = er32(TXDCTL(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -07003209 txdctl = (txdctl & ~E1000_TXDCTL_WTHRESH) |
3210 E1000_TXDCTL_FULL_TX_DESC_WB;
3211 txdctl = (txdctl & ~E1000_TXDCTL_PTHRESH) |
3212 E1000_TXDCTL_MAX_TX_DESC_PREFETCH;
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003213 ew32(TXDCTL(0), txdctl);
3214 txdctl = er32(TXDCTL(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -07003215 txdctl = (txdctl & ~E1000_TXDCTL_WTHRESH) |
3216 E1000_TXDCTL_FULL_TX_DESC_WB;
3217 txdctl = (txdctl & ~E1000_TXDCTL_PTHRESH) |
3218 E1000_TXDCTL_MAX_TX_DESC_PREFETCH;
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003219 ew32(TXDCTL(1), txdctl);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003220
Bruce Allanad680762008-03-28 09:15:03 -07003221 /*
3222 * ICH8 has opposite polarity of no_snoop bits.
3223 * By default, we should use snoop behavior.
3224 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003225 if (mac->type == e1000_ich8lan)
3226 snoop = PCIE_ICH8_SNOOP_ALL;
3227 else
3228 snoop = (u32) ~(PCIE_NO_SNOOP_ALL);
3229 e1000e_set_pcie_no_snoop(hw, snoop);
3230
3231 ctrl_ext = er32(CTRL_EXT);
3232 ctrl_ext |= E1000_CTRL_EXT_RO_DIS;
3233 ew32(CTRL_EXT, ctrl_ext);
3234
Bruce Allanad680762008-03-28 09:15:03 -07003235 /*
3236 * Clear all of the statistics registers (clear on read). It is
Auke Kokbc7f75f2007-09-17 12:30:59 -07003237 * important that we do this after we have tried to establish link
3238 * because the symbol error count will increment wildly if there
3239 * is no link.
3240 */
3241 e1000_clear_hw_cntrs_ich8lan(hw);
3242
3243 return 0;
3244}
3245/**
3246 * e1000_initialize_hw_bits_ich8lan - Initialize required hardware bits
3247 * @hw: pointer to the HW structure
3248 *
3249 * Sets/Clears required hardware bits necessary for correctly setting up the
3250 * hardware for transmit and receive.
3251 **/
3252static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw)
3253{
3254 u32 reg;
3255
3256 /* Extended Device Control */
3257 reg = er32(CTRL_EXT);
3258 reg |= (1 << 22);
Bruce Allana4f58f52009-06-02 11:29:18 +00003259 /* Enable PHY low-power state when MAC is at D3 w/o WoL */
3260 if (hw->mac.type >= e1000_pchlan)
3261 reg |= E1000_CTRL_EXT_PHYPDEN;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003262 ew32(CTRL_EXT, reg);
3263
3264 /* Transmit Descriptor Control 0 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003265 reg = er32(TXDCTL(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -07003266 reg |= (1 << 22);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003267 ew32(TXDCTL(0), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003268
3269 /* Transmit Descriptor Control 1 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003270 reg = er32(TXDCTL(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -07003271 reg |= (1 << 22);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003272 ew32(TXDCTL(1), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003273
3274 /* Transmit Arbitration Control 0 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003275 reg = er32(TARC(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -07003276 if (hw->mac.type == e1000_ich8lan)
3277 reg |= (1 << 28) | (1 << 29);
3278 reg |= (1 << 23) | (1 << 24) | (1 << 26) | (1 << 27);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003279 ew32(TARC(0), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003280
3281 /* Transmit Arbitration Control 1 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003282 reg = er32(TARC(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -07003283 if (er32(TCTL) & E1000_TCTL_MULR)
3284 reg &= ~(1 << 28);
3285 else
3286 reg |= (1 << 28);
3287 reg |= (1 << 24) | (1 << 26) | (1 << 30);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07003288 ew32(TARC(1), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003289
3290 /* Device Status */
3291 if (hw->mac.type == e1000_ich8lan) {
3292 reg = er32(STATUS);
3293 reg &= ~(1 << 31);
3294 ew32(STATUS, reg);
3295 }
Jesse Brandeburga80483d2010-03-05 02:21:44 +00003296
3297 /*
3298 * work-around descriptor data corruption issue during nfs v2 udp
3299 * traffic, just disable the nfs filtering capability
3300 */
3301 reg = er32(RFCTL);
3302 reg |= (E1000_RFCTL_NFSW_DIS | E1000_RFCTL_NFSR_DIS);
3303 ew32(RFCTL, reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003304}
3305
3306/**
3307 * e1000_setup_link_ich8lan - Setup flow control and link settings
3308 * @hw: pointer to the HW structure
3309 *
3310 * Determines which flow control settings to use, then configures flow
3311 * control. Calls the appropriate media-specific link configuration
3312 * function. Assuming the adapter has a valid link partner, a valid link
3313 * should be established. Assumes the hardware has previously been reset
3314 * and the transmitter and receiver are not enabled.
3315 **/
3316static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw)
3317{
Auke Kokbc7f75f2007-09-17 12:30:59 -07003318 s32 ret_val;
3319
3320 if (e1000_check_reset_block(hw))
3321 return 0;
3322
Bruce Allanad680762008-03-28 09:15:03 -07003323 /*
3324 * ICH parts do not have a word in the NVM to determine
Auke Kokbc7f75f2007-09-17 12:30:59 -07003325 * the default flow control setting, so we explicitly
3326 * set it to full.
3327 */
Bruce Allan37289d92009-06-02 11:29:37 +00003328 if (hw->fc.requested_mode == e1000_fc_default) {
3329 /* Workaround h/w hang when Tx flow control enabled */
3330 if (hw->mac.type == e1000_pchlan)
3331 hw->fc.requested_mode = e1000_fc_rx_pause;
3332 else
3333 hw->fc.requested_mode = e1000_fc_full;
3334 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07003335
Bruce Allan5c48ef3e22008-11-21 16:57:36 -08003336 /*
3337 * Save off the requested flow control mode for use later. Depending
3338 * on the link partner's capabilities, we may or may not use this mode.
3339 */
3340 hw->fc.current_mode = hw->fc.requested_mode;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003341
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003342 e_dbg("After fix-ups FlowControl is now = %x\n",
Bruce Allan5c48ef3e22008-11-21 16:57:36 -08003343 hw->fc.current_mode);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003344
3345 /* Continue to configure the copper link. */
3346 ret_val = e1000_setup_copper_link_ich8lan(hw);
3347 if (ret_val)
3348 return ret_val;
3349
Jeff Kirsher318a94d2008-03-28 09:15:16 -07003350 ew32(FCTTV, hw->fc.pause_time);
Bruce Allana4f58f52009-06-02 11:29:18 +00003351 if ((hw->phy.type == e1000_phy_82578) ||
Bruce Alland3738bb2010-06-16 13:27:28 +00003352 (hw->phy.type == e1000_phy_82579) ||
Bruce Allana4f58f52009-06-02 11:29:18 +00003353 (hw->phy.type == e1000_phy_82577)) {
Bruce Allana3055952010-05-10 15:02:12 +00003354 ew32(FCRTV_PCH, hw->fc.refresh_time);
3355
Bruce Allan482fed82011-01-06 14:29:49 +00003356 ret_val = e1e_wphy(hw, PHY_REG(BM_PORT_CTRL_PAGE, 27),
3357 hw->fc.pause_time);
Bruce Allana4f58f52009-06-02 11:29:18 +00003358 if (ret_val)
3359 return ret_val;
3360 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07003361
3362 return e1000e_set_fc_watermarks(hw);
3363}
3364
3365/**
3366 * e1000_setup_copper_link_ich8lan - Configure MAC/PHY interface
3367 * @hw: pointer to the HW structure
3368 *
3369 * Configures the kumeran interface to the PHY to wait the appropriate time
3370 * when polling the PHY, then call the generic setup_copper_link to finish
3371 * configuring the copper link.
3372 **/
3373static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw)
3374{
3375 u32 ctrl;
3376 s32 ret_val;
3377 u16 reg_data;
3378
3379 ctrl = er32(CTRL);
3380 ctrl |= E1000_CTRL_SLU;
3381 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
3382 ew32(CTRL, ctrl);
3383
Bruce Allanad680762008-03-28 09:15:03 -07003384 /*
3385 * Set the mac to wait the maximum time between each iteration
Auke Kokbc7f75f2007-09-17 12:30:59 -07003386 * and increase the max iterations when polling the phy;
Bruce Allanad680762008-03-28 09:15:03 -07003387 * this fixes erroneous timeouts at 10Mbps.
3388 */
Bruce Allan07818952009-12-08 07:28:01 +00003389 ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_TIMEOUTS, 0xFFFF);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003390 if (ret_val)
3391 return ret_val;
Bruce Allan07818952009-12-08 07:28:01 +00003392 ret_val = e1000e_read_kmrn_reg(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
3393 &reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003394 if (ret_val)
3395 return ret_val;
3396 reg_data |= 0x3F;
Bruce Allan07818952009-12-08 07:28:01 +00003397 ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
3398 reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003399 if (ret_val)
3400 return ret_val;
3401
Bruce Allana4f58f52009-06-02 11:29:18 +00003402 switch (hw->phy.type) {
3403 case e1000_phy_igp_3:
Auke Kokbc7f75f2007-09-17 12:30:59 -07003404 ret_val = e1000e_copper_link_setup_igp(hw);
3405 if (ret_val)
3406 return ret_val;
Bruce Allana4f58f52009-06-02 11:29:18 +00003407 break;
3408 case e1000_phy_bm:
3409 case e1000_phy_82578:
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003410 ret_val = e1000e_copper_link_setup_m88(hw);
3411 if (ret_val)
3412 return ret_val;
Bruce Allana4f58f52009-06-02 11:29:18 +00003413 break;
3414 case e1000_phy_82577:
Bruce Alland3738bb2010-06-16 13:27:28 +00003415 case e1000_phy_82579:
Bruce Allana4f58f52009-06-02 11:29:18 +00003416 ret_val = e1000_copper_link_setup_82577(hw);
3417 if (ret_val)
3418 return ret_val;
3419 break;
3420 case e1000_phy_ife:
Bruce Allan482fed82011-01-06 14:29:49 +00003421 ret_val = e1e_rphy(hw, IFE_PHY_MDIX_CONTROL, &reg_data);
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003422 if (ret_val)
3423 return ret_val;
3424
3425 reg_data &= ~IFE_PMC_AUTO_MDIX;
3426
3427 switch (hw->phy.mdix) {
3428 case 1:
3429 reg_data &= ~IFE_PMC_FORCE_MDIX;
3430 break;
3431 case 2:
3432 reg_data |= IFE_PMC_FORCE_MDIX;
3433 break;
3434 case 0:
3435 default:
3436 reg_data |= IFE_PMC_AUTO_MDIX;
3437 break;
3438 }
Bruce Allan482fed82011-01-06 14:29:49 +00003439 ret_val = e1e_wphy(hw, IFE_PHY_MDIX_CONTROL, reg_data);
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003440 if (ret_val)
3441 return ret_val;
Bruce Allana4f58f52009-06-02 11:29:18 +00003442 break;
3443 default:
3444 break;
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003445 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07003446 return e1000e_setup_copper_link(hw);
3447}
3448
3449/**
3450 * e1000_get_link_up_info_ich8lan - Get current link speed and duplex
3451 * @hw: pointer to the HW structure
3452 * @speed: pointer to store current link speed
3453 * @duplex: pointer to store the current link duplex
3454 *
Bruce Allanad680762008-03-28 09:15:03 -07003455 * Calls the generic get_speed_and_duplex to retrieve the current link
Auke Kokbc7f75f2007-09-17 12:30:59 -07003456 * information and then calls the Kumeran lock loss workaround for links at
3457 * gigabit speeds.
3458 **/
3459static s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw, u16 *speed,
3460 u16 *duplex)
3461{
3462 s32 ret_val;
3463
3464 ret_val = e1000e_get_speed_and_duplex_copper(hw, speed, duplex);
3465 if (ret_val)
3466 return ret_val;
3467
3468 if ((hw->mac.type == e1000_ich8lan) &&
3469 (hw->phy.type == e1000_phy_igp_3) &&
3470 (*speed == SPEED_1000)) {
3471 ret_val = e1000_kmrn_lock_loss_workaround_ich8lan(hw);
3472 }
3473
3474 return ret_val;
3475}
3476
3477/**
3478 * e1000_kmrn_lock_loss_workaround_ich8lan - Kumeran workaround
3479 * @hw: pointer to the HW structure
3480 *
3481 * Work-around for 82566 Kumeran PCS lock loss:
3482 * On link status change (i.e. PCI reset, speed change) and link is up and
3483 * speed is gigabit-
3484 * 0) if workaround is optionally disabled do nothing
3485 * 1) wait 1ms for Kumeran link to come up
3486 * 2) check Kumeran Diagnostic register PCS lock loss bit
3487 * 3) if not set the link is locked (all is good), otherwise...
3488 * 4) reset the PHY
3489 * 5) repeat up to 10 times
3490 * Note: this is only called for IGP3 copper when speed is 1gb.
3491 **/
3492static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw)
3493{
3494 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
3495 u32 phy_ctrl;
3496 s32 ret_val;
3497 u16 i, data;
3498 bool link;
3499
3500 if (!dev_spec->kmrn_lock_loss_workaround_enabled)
3501 return 0;
3502
Bruce Allanad680762008-03-28 09:15:03 -07003503 /*
3504 * Make sure link is up before proceeding. If not just return.
Auke Kokbc7f75f2007-09-17 12:30:59 -07003505 * Attempting this while link is negotiating fouled up link
Bruce Allanad680762008-03-28 09:15:03 -07003506 * stability
3507 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003508 ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link);
3509 if (!link)
3510 return 0;
3511
3512 for (i = 0; i < 10; i++) {
3513 /* read once to clear */
3514 ret_val = e1e_rphy(hw, IGP3_KMRN_DIAG, &data);
3515 if (ret_val)
3516 return ret_val;
3517 /* and again to get new status */
3518 ret_val = e1e_rphy(hw, IGP3_KMRN_DIAG, &data);
3519 if (ret_val)
3520 return ret_val;
3521
3522 /* check for PCS lock */
3523 if (!(data & IGP3_KMRN_DIAG_PCS_LOCK_LOSS))
3524 return 0;
3525
3526 /* Issue PHY reset */
3527 e1000_phy_hw_reset(hw);
3528 mdelay(5);
3529 }
3530 /* Disable GigE link negotiation */
3531 phy_ctrl = er32(PHY_CTRL);
3532 phy_ctrl |= (E1000_PHY_CTRL_GBE_DISABLE |
3533 E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
3534 ew32(PHY_CTRL, phy_ctrl);
3535
Bruce Allanad680762008-03-28 09:15:03 -07003536 /*
3537 * Call gig speed drop workaround on Gig disable before accessing
3538 * any PHY registers
3539 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003540 e1000e_gig_downshift_workaround_ich8lan(hw);
3541
3542 /* unable to acquire PCS lock */
3543 return -E1000_ERR_PHY;
3544}
3545
3546/**
Bruce Allanad680762008-03-28 09:15:03 -07003547 * e1000_set_kmrn_lock_loss_workaround_ich8lan - Set Kumeran workaround state
Auke Kokbc7f75f2007-09-17 12:30:59 -07003548 * @hw: pointer to the HW structure
Auke Kok489815c2008-02-21 15:11:07 -08003549 * @state: boolean value used to set the current Kumeran workaround state
Auke Kokbc7f75f2007-09-17 12:30:59 -07003550 *
Bruce Allan564ea9b2009-11-20 23:26:44 +00003551 * If ICH8, set the current Kumeran workaround state (enabled - true
3552 * /disabled - false).
Auke Kokbc7f75f2007-09-17 12:30:59 -07003553 **/
3554void e1000e_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw,
3555 bool state)
3556{
3557 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
3558
3559 if (hw->mac.type != e1000_ich8lan) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003560 e_dbg("Workaround applies to ICH8 only.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07003561 return;
3562 }
3563
3564 dev_spec->kmrn_lock_loss_workaround_enabled = state;
3565}
3566
3567/**
3568 * e1000_ipg3_phy_powerdown_workaround_ich8lan - Power down workaround on D3
3569 * @hw: pointer to the HW structure
3570 *
3571 * Workaround for 82566 power-down on D3 entry:
3572 * 1) disable gigabit link
3573 * 2) write VR power-down enable
3574 * 3) read it back
3575 * Continue if successful, else issue LCD reset and repeat
3576 **/
3577void e1000e_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw)
3578{
3579 u32 reg;
3580 u16 data;
3581 u8 retry = 0;
3582
3583 if (hw->phy.type != e1000_phy_igp_3)
3584 return;
3585
3586 /* Try the workaround twice (if needed) */
3587 do {
3588 /* Disable link */
3589 reg = er32(PHY_CTRL);
3590 reg |= (E1000_PHY_CTRL_GBE_DISABLE |
3591 E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
3592 ew32(PHY_CTRL, reg);
3593
Bruce Allanad680762008-03-28 09:15:03 -07003594 /*
3595 * Call gig speed drop workaround on Gig disable before
3596 * accessing any PHY registers
3597 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07003598 if (hw->mac.type == e1000_ich8lan)
3599 e1000e_gig_downshift_workaround_ich8lan(hw);
3600
3601 /* Write VR power-down enable */
3602 e1e_rphy(hw, IGP3_VR_CTRL, &data);
3603 data &= ~IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
3604 e1e_wphy(hw, IGP3_VR_CTRL, data | IGP3_VR_CTRL_MODE_SHUTDOWN);
3605
3606 /* Read it back and test */
3607 e1e_rphy(hw, IGP3_VR_CTRL, &data);
3608 data &= IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
3609 if ((data == IGP3_VR_CTRL_MODE_SHUTDOWN) || retry)
3610 break;
3611
3612 /* Issue PHY reset and repeat at most one more time */
3613 reg = er32(CTRL);
3614 ew32(CTRL, reg | E1000_CTRL_PHY_RST);
3615 retry++;
3616 } while (retry);
3617}
3618
3619/**
3620 * e1000e_gig_downshift_workaround_ich8lan - WoL from S5 stops working
3621 * @hw: pointer to the HW structure
3622 *
3623 * Steps to take when dropping from 1Gb/s (eg. link cable removal (LSC),
Auke Kok489815c2008-02-21 15:11:07 -08003624 * LPLU, Gig disable, MDIC PHY reset):
Auke Kokbc7f75f2007-09-17 12:30:59 -07003625 * 1) Set Kumeran Near-end loopback
3626 * 2) Clear Kumeran Near-end loopback
3627 * Should only be called for ICH8[m] devices with IGP_3 Phy.
3628 **/
3629void e1000e_gig_downshift_workaround_ich8lan(struct e1000_hw *hw)
3630{
3631 s32 ret_val;
3632 u16 reg_data;
3633
3634 if ((hw->mac.type != e1000_ich8lan) ||
3635 (hw->phy.type != e1000_phy_igp_3))
3636 return;
3637
3638 ret_val = e1000e_read_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
3639 &reg_data);
3640 if (ret_val)
3641 return;
3642 reg_data |= E1000_KMRNCTRLSTA_DIAG_NELPBK;
3643 ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
3644 reg_data);
3645 if (ret_val)
3646 return;
3647 reg_data &= ~E1000_KMRNCTRLSTA_DIAG_NELPBK;
3648 ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
3649 reg_data);
3650}
3651
3652/**
Bruce Allan99730e42011-05-13 07:19:48 +00003653 * e1000_suspend_workarounds_ich8lan - workarounds needed during S0->Sx
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003654 * @hw: pointer to the HW structure
3655 *
3656 * During S0 to Sx transition, it is possible the link remains at gig
3657 * instead of negotiating to a lower speed. Before going to Sx, set
3658 * 'LPLU Enabled' and 'Gig Disable' to force link speed negotiation
Bruce Allan99730e42011-05-13 07:19:48 +00003659 * to a lower speed. For PCH and newer parts, the OEM bits PHY register
3660 * (LED, GbE disable and LPLU configurations) also needs to be written.
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003661 **/
Bruce Allan99730e42011-05-13 07:19:48 +00003662void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw)
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003663{
3664 u32 phy_ctrl;
Bruce Allan8395ae82010-09-22 17:15:08 +00003665 s32 ret_val;
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003666
Bruce Allan17f085d2010-06-17 18:59:48 +00003667 phy_ctrl = er32(PHY_CTRL);
3668 phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU | E1000_PHY_CTRL_GBE_DISABLE;
3669 ew32(PHY_CTRL, phy_ctrl);
Bruce Allana4f58f52009-06-02 11:29:18 +00003670
Bruce Allan8395ae82010-09-22 17:15:08 +00003671 if (hw->mac.type >= e1000_pchlan) {
Bruce Allance54afd2010-11-24 06:01:41 +00003672 e1000_oem_bits_config_ich8lan(hw, false);
Bruce Allan8395ae82010-09-22 17:15:08 +00003673 ret_val = hw->phy.ops.acquire(hw);
3674 if (ret_val)
3675 return;
3676 e1000_write_smbus_addr(hw);
3677 hw->phy.ops.release(hw);
3678 }
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003679}
3680
3681/**
Bruce Allan99730e42011-05-13 07:19:48 +00003682 * e1000_resume_workarounds_pchlan - workarounds needed during Sx->S0
3683 * @hw: pointer to the HW structure
3684 *
3685 * During Sx to S0 transitions on non-managed devices or managed devices
3686 * on which PHY resets are not blocked, if the PHY registers cannot be
3687 * accessed properly by the s/w toggle the LANPHYPC value to power cycle
3688 * the PHY.
3689 **/
3690void e1000_resume_workarounds_pchlan(struct e1000_hw *hw)
3691{
3692 u32 fwsm;
3693
3694 if (hw->mac.type != e1000_pch2lan)
3695 return;
3696
3697 fwsm = er32(FWSM);
3698 if (!(fwsm & E1000_ICH_FWSM_FW_VALID) || !e1000_check_reset_block(hw)) {
3699 u16 phy_id1, phy_id2;
3700 s32 ret_val;
3701
3702 ret_val = hw->phy.ops.acquire(hw);
3703 if (ret_val) {
3704 e_dbg("Failed to acquire PHY semaphore in resume\n");
3705 return;
3706 }
3707
3708 /* Test access to the PHY registers by reading the ID regs */
3709 ret_val = hw->phy.ops.read_reg_locked(hw, PHY_ID1, &phy_id1);
3710 if (ret_val)
3711 goto release;
3712 ret_val = hw->phy.ops.read_reg_locked(hw, PHY_ID2, &phy_id2);
3713 if (ret_val)
3714 goto release;
3715
3716 if (hw->phy.id == ((u32)(phy_id1 << 16) |
3717 (u32)(phy_id2 & PHY_REVISION_MASK)))
3718 goto release;
3719
3720 e1000_toggle_lanphypc_value_ich8lan(hw);
3721
3722 hw->phy.ops.release(hw);
3723 msleep(50);
3724 e1000_phy_hw_reset(hw);
3725 msleep(50);
3726 return;
3727 }
3728
3729release:
3730 hw->phy.ops.release(hw);
3731
3732 return;
3733}
3734
3735/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07003736 * e1000_cleanup_led_ich8lan - Restore the default LED operation
3737 * @hw: pointer to the HW structure
3738 *
3739 * Return the LED back to the default configuration.
3740 **/
3741static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw)
3742{
3743 if (hw->phy.type == e1000_phy_ife)
3744 return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED, 0);
3745
3746 ew32(LEDCTL, hw->mac.ledctl_default);
3747 return 0;
3748}
3749
3750/**
Auke Kok489815c2008-02-21 15:11:07 -08003751 * e1000_led_on_ich8lan - Turn LEDs on
Auke Kokbc7f75f2007-09-17 12:30:59 -07003752 * @hw: pointer to the HW structure
3753 *
Auke Kok489815c2008-02-21 15:11:07 -08003754 * Turn on the LEDs.
Auke Kokbc7f75f2007-09-17 12:30:59 -07003755 **/
3756static s32 e1000_led_on_ich8lan(struct e1000_hw *hw)
3757{
3758 if (hw->phy.type == e1000_phy_ife)
3759 return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED,
3760 (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_ON));
3761
3762 ew32(LEDCTL, hw->mac.ledctl_mode2);
3763 return 0;
3764}
3765
3766/**
Auke Kok489815c2008-02-21 15:11:07 -08003767 * e1000_led_off_ich8lan - Turn LEDs off
Auke Kokbc7f75f2007-09-17 12:30:59 -07003768 * @hw: pointer to the HW structure
3769 *
Auke Kok489815c2008-02-21 15:11:07 -08003770 * Turn off the LEDs.
Auke Kokbc7f75f2007-09-17 12:30:59 -07003771 **/
3772static s32 e1000_led_off_ich8lan(struct e1000_hw *hw)
3773{
3774 if (hw->phy.type == e1000_phy_ife)
3775 return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED,
Bruce Allan482fed82011-01-06 14:29:49 +00003776 (IFE_PSCL_PROBE_MODE |
3777 IFE_PSCL_PROBE_LEDS_OFF));
Auke Kokbc7f75f2007-09-17 12:30:59 -07003778
3779 ew32(LEDCTL, hw->mac.ledctl_mode1);
3780 return 0;
3781}
3782
3783/**
Bruce Allana4f58f52009-06-02 11:29:18 +00003784 * e1000_setup_led_pchlan - Configures SW controllable LED
3785 * @hw: pointer to the HW structure
3786 *
3787 * This prepares the SW controllable LED for use.
3788 **/
3789static s32 e1000_setup_led_pchlan(struct e1000_hw *hw)
3790{
Bruce Allan482fed82011-01-06 14:29:49 +00003791 return e1e_wphy(hw, HV_LED_CONFIG, (u16)hw->mac.ledctl_mode1);
Bruce Allana4f58f52009-06-02 11:29:18 +00003792}
3793
3794/**
3795 * e1000_cleanup_led_pchlan - Restore the default LED operation
3796 * @hw: pointer to the HW structure
3797 *
3798 * Return the LED back to the default configuration.
3799 **/
3800static s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw)
3801{
Bruce Allan482fed82011-01-06 14:29:49 +00003802 return e1e_wphy(hw, HV_LED_CONFIG, (u16)hw->mac.ledctl_default);
Bruce Allana4f58f52009-06-02 11:29:18 +00003803}
3804
3805/**
3806 * e1000_led_on_pchlan - Turn LEDs on
3807 * @hw: pointer to the HW structure
3808 *
3809 * Turn on the LEDs.
3810 **/
3811static s32 e1000_led_on_pchlan(struct e1000_hw *hw)
3812{
3813 u16 data = (u16)hw->mac.ledctl_mode2;
3814 u32 i, led;
3815
3816 /*
3817 * If no link, then turn LED on by setting the invert bit
3818 * for each LED that's mode is "link_up" in ledctl_mode2.
3819 */
3820 if (!(er32(STATUS) & E1000_STATUS_LU)) {
3821 for (i = 0; i < 3; i++) {
3822 led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
3823 if ((led & E1000_PHY_LED0_MODE_MASK) !=
3824 E1000_LEDCTL_MODE_LINK_UP)
3825 continue;
3826 if (led & E1000_PHY_LED0_IVRT)
3827 data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
3828 else
3829 data |= (E1000_PHY_LED0_IVRT << (i * 5));
3830 }
3831 }
3832
Bruce Allan482fed82011-01-06 14:29:49 +00003833 return e1e_wphy(hw, HV_LED_CONFIG, data);
Bruce Allana4f58f52009-06-02 11:29:18 +00003834}
3835
3836/**
3837 * e1000_led_off_pchlan - Turn LEDs off
3838 * @hw: pointer to the HW structure
3839 *
3840 * Turn off the LEDs.
3841 **/
3842static s32 e1000_led_off_pchlan(struct e1000_hw *hw)
3843{
3844 u16 data = (u16)hw->mac.ledctl_mode1;
3845 u32 i, led;
3846
3847 /*
3848 * If no link, then turn LED off by clearing the invert bit
3849 * for each LED that's mode is "link_up" in ledctl_mode1.
3850 */
3851 if (!(er32(STATUS) & E1000_STATUS_LU)) {
3852 for (i = 0; i < 3; i++) {
3853 led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
3854 if ((led & E1000_PHY_LED0_MODE_MASK) !=
3855 E1000_LEDCTL_MODE_LINK_UP)
3856 continue;
3857 if (led & E1000_PHY_LED0_IVRT)
3858 data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
3859 else
3860 data |= (E1000_PHY_LED0_IVRT << (i * 5));
3861 }
3862 }
3863
Bruce Allan482fed82011-01-06 14:29:49 +00003864 return e1e_wphy(hw, HV_LED_CONFIG, data);
Bruce Allana4f58f52009-06-02 11:29:18 +00003865}
3866
3867/**
Bruce Allane98cac42010-05-10 15:02:32 +00003868 * e1000_get_cfg_done_ich8lan - Read config done bit after Full or PHY reset
Bruce Allanf4187b52008-08-26 18:36:50 -07003869 * @hw: pointer to the HW structure
3870 *
Bruce Allane98cac42010-05-10 15:02:32 +00003871 * Read appropriate register for the config done bit for completion status
3872 * and configure the PHY through s/w for EEPROM-less parts.
3873 *
3874 * NOTE: some silicon which is EEPROM-less will fail trying to read the
3875 * config done bit, so only an error is logged and continues. If we were
3876 * to return with error, EEPROM-less silicon would not be able to be reset
3877 * or change link.
Bruce Allanf4187b52008-08-26 18:36:50 -07003878 **/
3879static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw)
3880{
Bruce Allane98cac42010-05-10 15:02:32 +00003881 s32 ret_val = 0;
Bruce Allanf4187b52008-08-26 18:36:50 -07003882 u32 bank = 0;
Bruce Allane98cac42010-05-10 15:02:32 +00003883 u32 status;
Bruce Allanfc0c7762009-07-01 13:27:55 +00003884
Bruce Allanf4187b52008-08-26 18:36:50 -07003885 e1000e_get_cfg_done(hw);
3886
Bruce Allane98cac42010-05-10 15:02:32 +00003887 /* Wait for indication from h/w that it has completed basic config */
3888 if (hw->mac.type >= e1000_ich10lan) {
3889 e1000_lan_init_done_ich8lan(hw);
3890 } else {
3891 ret_val = e1000e_get_auto_rd_done(hw);
3892 if (ret_val) {
3893 /*
3894 * When auto config read does not complete, do not
3895 * return with an error. This can happen in situations
3896 * where there is no eeprom and prevents getting link.
3897 */
3898 e_dbg("Auto Read Done did not complete\n");
3899 ret_val = 0;
3900 }
3901 }
3902
3903 /* Clear PHY Reset Asserted bit */
3904 status = er32(STATUS);
3905 if (status & E1000_STATUS_PHYRA)
3906 ew32(STATUS, status & ~E1000_STATUS_PHYRA);
3907 else
3908 e_dbg("PHY Reset Asserted not set - needs delay\n");
3909
Bruce Allanf4187b52008-08-26 18:36:50 -07003910 /* If EEPROM is not marked present, init the IGP 3 PHY manually */
Bruce Allane98cac42010-05-10 15:02:32 +00003911 if (hw->mac.type <= e1000_ich9lan) {
Bruce Allanf4187b52008-08-26 18:36:50 -07003912 if (((er32(EECD) & E1000_EECD_PRES) == 0) &&
3913 (hw->phy.type == e1000_phy_igp_3)) {
3914 e1000e_phy_init_script_igp3(hw);
3915 }
3916 } else {
3917 if (e1000_valid_nvm_bank_detect_ich8lan(hw, &bank)) {
3918 /* Maybe we should do a basic PHY config */
Bruce Allan3bb99fe2009-11-20 23:25:07 +00003919 e_dbg("EEPROM not present\n");
Bruce Allane98cac42010-05-10 15:02:32 +00003920 ret_val = -E1000_ERR_CONFIG;
Bruce Allanf4187b52008-08-26 18:36:50 -07003921 }
3922 }
3923
Bruce Allane98cac42010-05-10 15:02:32 +00003924 return ret_val;
Bruce Allanf4187b52008-08-26 18:36:50 -07003925}
3926
3927/**
Bruce Allan17f208d2009-12-01 15:47:22 +00003928 * e1000_power_down_phy_copper_ich8lan - Remove link during PHY power down
3929 * @hw: pointer to the HW structure
3930 *
3931 * In the case of a PHY power down to save power, or to turn off link during a
3932 * driver unload, or wake on lan is not enabled, remove the link.
3933 **/
3934static void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw)
3935{
3936 /* If the management interface is not enabled, then power down */
3937 if (!(hw->mac.ops.check_mng_mode(hw) ||
3938 hw->phy.ops.check_reset_block(hw)))
3939 e1000_power_down_phy_copper(hw);
Bruce Allan17f208d2009-12-01 15:47:22 +00003940}
3941
3942/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07003943 * e1000_clear_hw_cntrs_ich8lan - Clear statistical counters
3944 * @hw: pointer to the HW structure
3945 *
3946 * Clears hardware counters specific to the silicon family and calls
3947 * clear_hw_cntrs_generic to clear all general purpose counters.
3948 **/
3949static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw)
3950{
Bruce Allana4f58f52009-06-02 11:29:18 +00003951 u16 phy_data;
Bruce Allan2b6b1682011-05-13 07:20:09 +00003952 s32 ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -07003953
3954 e1000e_clear_hw_cntrs_base(hw);
3955
Bruce Allan99673d92009-11-20 23:27:21 +00003956 er32(ALGNERRC);
3957 er32(RXERRC);
3958 er32(TNCRS);
3959 er32(CEXTERR);
3960 er32(TSCTC);
3961 er32(TSCTFC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003962
Bruce Allan99673d92009-11-20 23:27:21 +00003963 er32(MGTPRC);
3964 er32(MGTPDC);
3965 er32(MGTPTC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003966
Bruce Allan99673d92009-11-20 23:27:21 +00003967 er32(IAC);
3968 er32(ICRXOC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07003969
Bruce Allana4f58f52009-06-02 11:29:18 +00003970 /* Clear PHY statistics registers */
3971 if ((hw->phy.type == e1000_phy_82578) ||
Bruce Alland3738bb2010-06-16 13:27:28 +00003972 (hw->phy.type == e1000_phy_82579) ||
Bruce Allana4f58f52009-06-02 11:29:18 +00003973 (hw->phy.type == e1000_phy_82577)) {
Bruce Allan2b6b1682011-05-13 07:20:09 +00003974 ret_val = hw->phy.ops.acquire(hw);
3975 if (ret_val)
3976 return;
3977 ret_val = hw->phy.ops.set_page(hw,
3978 HV_STATS_PAGE << IGP_PAGE_SHIFT);
3979 if (ret_val)
3980 goto release;
3981 hw->phy.ops.read_reg_page(hw, HV_SCC_UPPER, &phy_data);
3982 hw->phy.ops.read_reg_page(hw, HV_SCC_LOWER, &phy_data);
3983 hw->phy.ops.read_reg_page(hw, HV_ECOL_UPPER, &phy_data);
3984 hw->phy.ops.read_reg_page(hw, HV_ECOL_LOWER, &phy_data);
3985 hw->phy.ops.read_reg_page(hw, HV_MCC_UPPER, &phy_data);
3986 hw->phy.ops.read_reg_page(hw, HV_MCC_LOWER, &phy_data);
3987 hw->phy.ops.read_reg_page(hw, HV_LATECOL_UPPER, &phy_data);
3988 hw->phy.ops.read_reg_page(hw, HV_LATECOL_LOWER, &phy_data);
3989 hw->phy.ops.read_reg_page(hw, HV_COLC_UPPER, &phy_data);
3990 hw->phy.ops.read_reg_page(hw, HV_COLC_LOWER, &phy_data);
3991 hw->phy.ops.read_reg_page(hw, HV_DC_UPPER, &phy_data);
3992 hw->phy.ops.read_reg_page(hw, HV_DC_LOWER, &phy_data);
3993 hw->phy.ops.read_reg_page(hw, HV_TNCRS_UPPER, &phy_data);
3994 hw->phy.ops.read_reg_page(hw, HV_TNCRS_LOWER, &phy_data);
3995release:
3996 hw->phy.ops.release(hw);
Bruce Allana4f58f52009-06-02 11:29:18 +00003997 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07003998}
3999
4000static struct e1000_mac_operations ich8_mac_ops = {
Bruce Allana4f58f52009-06-02 11:29:18 +00004001 .id_led_init = e1000e_id_led_init,
Bruce Allaneb7700d2010-06-16 13:27:05 +00004002 /* check_mng_mode dependent on mac type */
Bruce Allan7d3cabb2009-07-01 13:29:08 +00004003 .check_for_link = e1000_check_for_copper_link_ich8lan,
Bruce Allana4f58f52009-06-02 11:29:18 +00004004 /* cleanup_led dependent on mac type */
Auke Kokbc7f75f2007-09-17 12:30:59 -07004005 .clear_hw_cntrs = e1000_clear_hw_cntrs_ich8lan,
4006 .get_bus_info = e1000_get_bus_info_ich8lan,
Bruce Allanf4d2dd42010-01-13 02:05:18 +00004007 .set_lan_id = e1000_set_lan_id_single_port,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004008 .get_link_up_info = e1000_get_link_up_info_ich8lan,
Bruce Allana4f58f52009-06-02 11:29:18 +00004009 /* led_on dependent on mac type */
4010 /* led_off dependent on mac type */
Jeff Kirshere2de3eb2008-03-28 09:15:11 -07004011 .update_mc_addr_list = e1000e_update_mc_addr_list_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004012 .reset_hw = e1000_reset_hw_ich8lan,
4013 .init_hw = e1000_init_hw_ich8lan,
4014 .setup_link = e1000_setup_link_ich8lan,
4015 .setup_physical_interface= e1000_setup_copper_link_ich8lan,
Bruce Allana4f58f52009-06-02 11:29:18 +00004016 /* id_led_init dependent on mac type */
Auke Kokbc7f75f2007-09-17 12:30:59 -07004017};
4018
4019static struct e1000_phy_operations ich8_phy_ops = {
Bruce Allan94d81862009-11-20 23:25:26 +00004020 .acquire = e1000_acquire_swflag_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004021 .check_reset_block = e1000_check_reset_block_ich8lan,
Bruce Allan94d81862009-11-20 23:25:26 +00004022 .commit = NULL,
Bruce Allanf4187b52008-08-26 18:36:50 -07004023 .get_cfg_done = e1000_get_cfg_done_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004024 .get_cable_length = e1000e_get_cable_length_igp_2,
Bruce Allan94d81862009-11-20 23:25:26 +00004025 .read_reg = e1000e_read_phy_reg_igp,
4026 .release = e1000_release_swflag_ich8lan,
4027 .reset = e1000_phy_hw_reset_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004028 .set_d0_lplu_state = e1000_set_d0_lplu_state_ich8lan,
4029 .set_d3_lplu_state = e1000_set_d3_lplu_state_ich8lan,
Bruce Allan94d81862009-11-20 23:25:26 +00004030 .write_reg = e1000e_write_phy_reg_igp,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004031};
4032
4033static struct e1000_nvm_operations ich8_nvm_ops = {
Bruce Allan94d81862009-11-20 23:25:26 +00004034 .acquire = e1000_acquire_nvm_ich8lan,
4035 .read = e1000_read_nvm_ich8lan,
4036 .release = e1000_release_nvm_ich8lan,
4037 .update = e1000_update_nvm_checksum_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004038 .valid_led_default = e1000_valid_led_default_ich8lan,
Bruce Allan94d81862009-11-20 23:25:26 +00004039 .validate = e1000_validate_nvm_checksum_ich8lan,
4040 .write = e1000_write_nvm_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004041};
4042
4043struct e1000_info e1000_ich8_info = {
4044 .mac = e1000_ich8lan,
4045 .flags = FLAG_HAS_WOL
Bruce Allan97ac8ca2008-04-29 09:16:05 -07004046 | FLAG_IS_ICH
Auke Kokbc7f75f2007-09-17 12:30:59 -07004047 | FLAG_RX_CSUM_ENABLED
4048 | FLAG_HAS_CTRLEXT_ON_LOAD
4049 | FLAG_HAS_AMT
4050 | FLAG_HAS_FLASH
4051 | FLAG_APME_IN_WUC,
4052 .pba = 8,
Bruce Allan2adc55c2009-06-02 11:28:58 +00004053 .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN,
Jeff Kirsher69e3fd82008-04-02 13:48:18 -07004054 .get_variants = e1000_get_variants_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004055 .mac_ops = &ich8_mac_ops,
4056 .phy_ops = &ich8_phy_ops,
4057 .nvm_ops = &ich8_nvm_ops,
4058};
4059
4060struct e1000_info e1000_ich9_info = {
4061 .mac = e1000_ich9lan,
4062 .flags = FLAG_HAS_JUMBO_FRAMES
Bruce Allan97ac8ca2008-04-29 09:16:05 -07004063 | FLAG_IS_ICH
Auke Kokbc7f75f2007-09-17 12:30:59 -07004064 | FLAG_HAS_WOL
4065 | FLAG_RX_CSUM_ENABLED
4066 | FLAG_HAS_CTRLEXT_ON_LOAD
4067 | FLAG_HAS_AMT
4068 | FLAG_HAS_ERT
4069 | FLAG_HAS_FLASH
4070 | FLAG_APME_IN_WUC,
4071 .pba = 10,
Bruce Allan2adc55c2009-06-02 11:28:58 +00004072 .max_hw_frame_size = DEFAULT_JUMBO,
Jeff Kirsher69e3fd82008-04-02 13:48:18 -07004073 .get_variants = e1000_get_variants_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07004074 .mac_ops = &ich8_mac_ops,
4075 .phy_ops = &ich8_phy_ops,
4076 .nvm_ops = &ich8_nvm_ops,
4077};
4078
Bruce Allanf4187b52008-08-26 18:36:50 -07004079struct e1000_info e1000_ich10_info = {
4080 .mac = e1000_ich10lan,
4081 .flags = FLAG_HAS_JUMBO_FRAMES
4082 | FLAG_IS_ICH
4083 | FLAG_HAS_WOL
4084 | FLAG_RX_CSUM_ENABLED
4085 | FLAG_HAS_CTRLEXT_ON_LOAD
4086 | FLAG_HAS_AMT
4087 | FLAG_HAS_ERT
4088 | FLAG_HAS_FLASH
4089 | FLAG_APME_IN_WUC,
4090 .pba = 10,
Bruce Allan2adc55c2009-06-02 11:28:58 +00004091 .max_hw_frame_size = DEFAULT_JUMBO,
Bruce Allanf4187b52008-08-26 18:36:50 -07004092 .get_variants = e1000_get_variants_ich8lan,
4093 .mac_ops = &ich8_mac_ops,
4094 .phy_ops = &ich8_phy_ops,
4095 .nvm_ops = &ich8_nvm_ops,
4096};
Bruce Allana4f58f52009-06-02 11:29:18 +00004097
4098struct e1000_info e1000_pch_info = {
4099 .mac = e1000_pchlan,
4100 .flags = FLAG_IS_ICH
4101 | FLAG_HAS_WOL
4102 | FLAG_RX_CSUM_ENABLED
4103 | FLAG_HAS_CTRLEXT_ON_LOAD
4104 | FLAG_HAS_AMT
4105 | FLAG_HAS_FLASH
4106 | FLAG_HAS_JUMBO_FRAMES
Bruce Allan38eb3942009-11-19 12:34:20 +00004107 | FLAG_DISABLE_FC_PAUSE_TIME /* errata */
Bruce Allana4f58f52009-06-02 11:29:18 +00004108 | FLAG_APME_IN_WUC,
Bruce Allan8c7bbb92010-06-16 13:26:41 +00004109 .flags2 = FLAG2_HAS_PHY_STATS,
Bruce Allana4f58f52009-06-02 11:29:18 +00004110 .pba = 26,
4111 .max_hw_frame_size = 4096,
4112 .get_variants = e1000_get_variants_ich8lan,
4113 .mac_ops = &ich8_mac_ops,
4114 .phy_ops = &ich8_phy_ops,
4115 .nvm_ops = &ich8_nvm_ops,
4116};
Bruce Alland3738bb2010-06-16 13:27:28 +00004117
4118struct e1000_info e1000_pch2_info = {
4119 .mac = e1000_pch2lan,
4120 .flags = FLAG_IS_ICH
4121 | FLAG_HAS_WOL
4122 | FLAG_RX_CSUM_ENABLED
4123 | FLAG_HAS_CTRLEXT_ON_LOAD
4124 | FLAG_HAS_AMT
4125 | FLAG_HAS_FLASH
4126 | FLAG_HAS_JUMBO_FRAMES
4127 | FLAG_APME_IN_WUC,
Bruce Allane52997f2010-06-16 13:27:49 +00004128 .flags2 = FLAG2_HAS_PHY_STATS
4129 | FLAG2_HAS_EEE,
Bruce Allan828bac82010-09-29 21:39:37 +00004130 .pba = 26,
Bruce Alland3738bb2010-06-16 13:27:28 +00004131 .max_hw_frame_size = DEFAULT_JUMBO,
4132 .get_variants = e1000_get_variants_ich8lan,
4133 .mac_ops = &ich8_mac_ops,
4134 .phy_ops = &ich8_phy_ops,
4135 .nvm_ops = &ich8_nvm_ops,
4136};