blob: bf9b97db76b965ea05948c147c1345b1959df214 [file] [log] [blame]
Auke Kokbc7f75f2007-09-17 12:30:59 -07001/*******************************************************************************
2
3 Intel PRO/1000 Linux driver
Bruce Allanad680762008-03-28 09:15:03 -07004 Copyright(c) 1999 - 2008 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
Auke Kokbc7f75f2007-09-17 12:30:59 -070055 */
56
57#include <linux/netdevice.h>
58#include <linux/ethtool.h>
59#include <linux/delay.h>
60#include <linux/pci.h>
61
62#include "e1000.h"
63
64#define ICH_FLASH_GFPREG 0x0000
65#define ICH_FLASH_HSFSTS 0x0004
66#define ICH_FLASH_HSFCTL 0x0006
67#define ICH_FLASH_FADDR 0x0008
68#define ICH_FLASH_FDATA0 0x0010
Bruce Allan4a770352008-10-01 17:18:35 -070069#define ICH_FLASH_PR0 0x0074
Auke Kokbc7f75f2007-09-17 12:30:59 -070070
71#define ICH_FLASH_READ_COMMAND_TIMEOUT 500
72#define ICH_FLASH_WRITE_COMMAND_TIMEOUT 500
73#define ICH_FLASH_ERASE_COMMAND_TIMEOUT 3000000
74#define ICH_FLASH_LINEAR_ADDR_MASK 0x00FFFFFF
75#define ICH_FLASH_CYCLE_REPEAT_COUNT 10
76
77#define ICH_CYCLE_READ 0
78#define ICH_CYCLE_WRITE 2
79#define ICH_CYCLE_ERASE 3
80
81#define FLASH_GFPREG_BASE_MASK 0x1FFF
82#define FLASH_SECTOR_ADDR_SHIFT 12
83
84#define ICH_FLASH_SEG_SIZE_256 256
85#define ICH_FLASH_SEG_SIZE_4K 4096
86#define ICH_FLASH_SEG_SIZE_8K 8192
87#define ICH_FLASH_SEG_SIZE_64K 65536
88
89
90#define E1000_ICH_FWSM_RSPCIPHY 0x00000040 /* Reset PHY on PCI Reset */
91
92#define E1000_ICH_MNG_IAMT_MODE 0x2
93
94#define ID_LED_DEFAULT_ICH8LAN ((ID_LED_DEF1_DEF2 << 12) | \
95 (ID_LED_DEF1_OFF2 << 8) | \
96 (ID_LED_DEF1_ON2 << 4) | \
97 (ID_LED_DEF1_DEF2))
98
99#define E1000_ICH_NVM_SIG_WORD 0x13
100#define E1000_ICH_NVM_SIG_MASK 0xC000
Bruce Allane2434552008-11-21 17:02:41 -0800101#define E1000_ICH_NVM_VALID_SIG_MASK 0xC0
102#define E1000_ICH_NVM_SIG_VALUE 0x80
Auke Kokbc7f75f2007-09-17 12:30:59 -0700103
104#define E1000_ICH8_LAN_INIT_TIMEOUT 1500
105
106#define E1000_FEXTNVM_SW_CONFIG 1
107#define E1000_FEXTNVM_SW_CONFIG_ICH8M (1 << 27) /* Bit redefined for ICH8M :/ */
108
109#define PCIE_ICH8_SNOOP_ALL PCIE_NO_SNOOP_ALL
110
111#define E1000_ICH_RAR_ENTRIES 7
112
113#define PHY_PAGE_SHIFT 5
114#define PHY_REG(page, reg) (((page) << PHY_PAGE_SHIFT) | \
115 ((reg) & MAX_PHY_REG_ADDRESS))
116#define IGP3_KMRN_DIAG PHY_REG(770, 19) /* KMRN Diagnostic */
117#define IGP3_VR_CTRL PHY_REG(776, 18) /* Voltage Regulator Control */
118
119#define IGP3_KMRN_DIAG_PCS_LOCK_LOSS 0x0002
120#define IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK 0x0300
121#define IGP3_VR_CTRL_MODE_SHUTDOWN 0x0200
122
Bruce Allana4f58f52009-06-02 11:29:18 +0000123#define HV_LED_CONFIG PHY_REG(768, 30) /* LED Configuration */
124
Auke Kokbc7f75f2007-09-17 12:30:59 -0700125/* ICH GbE Flash Hardware Sequencing Flash Status Register bit breakdown */
126/* Offset 04h HSFSTS */
127union ich8_hws_flash_status {
128 struct ich8_hsfsts {
129 u16 flcdone :1; /* bit 0 Flash Cycle Done */
130 u16 flcerr :1; /* bit 1 Flash Cycle Error */
131 u16 dael :1; /* bit 2 Direct Access error Log */
132 u16 berasesz :2; /* bit 4:3 Sector Erase Size */
133 u16 flcinprog :1; /* bit 5 flash cycle in Progress */
134 u16 reserved1 :2; /* bit 13:6 Reserved */
135 u16 reserved2 :6; /* bit 13:6 Reserved */
136 u16 fldesvalid :1; /* bit 14 Flash Descriptor Valid */
137 u16 flockdn :1; /* bit 15 Flash Config Lock-Down */
138 } hsf_status;
139 u16 regval;
140};
141
142/* ICH GbE Flash Hardware Sequencing Flash control Register bit breakdown */
143/* Offset 06h FLCTL */
144union ich8_hws_flash_ctrl {
145 struct ich8_hsflctl {
146 u16 flcgo :1; /* 0 Flash Cycle Go */
147 u16 flcycle :2; /* 2:1 Flash Cycle */
148 u16 reserved :5; /* 7:3 Reserved */
149 u16 fldbcount :2; /* 9:8 Flash Data Byte Count */
150 u16 flockdn :6; /* 15:10 Reserved */
151 } hsf_ctrl;
152 u16 regval;
153};
154
155/* ICH Flash Region Access Permissions */
156union ich8_hws_flash_regacc {
157 struct ich8_flracc {
158 u32 grra :8; /* 0:7 GbE region Read Access */
159 u32 grwa :8; /* 8:15 GbE region Write Access */
160 u32 gmrag :8; /* 23:16 GbE Master Read Access Grant */
161 u32 gmwag :8; /* 31:24 GbE Master Write Access Grant */
162 } hsf_flregacc;
163 u16 regval;
164};
165
Bruce Allan4a770352008-10-01 17:18:35 -0700166/* ICH Flash Protected Region */
167union ich8_flash_protected_range {
168 struct ich8_pr {
169 u32 base:13; /* 0:12 Protected Range Base */
170 u32 reserved1:2; /* 13:14 Reserved */
171 u32 rpe:1; /* 15 Read Protection Enable */
172 u32 limit:13; /* 16:28 Protected Range Limit */
173 u32 reserved2:2; /* 29:30 Reserved */
174 u32 wpe:1; /* 31 Write Protection Enable */
175 } range;
176 u32 regval;
177};
178
Auke Kokbc7f75f2007-09-17 12:30:59 -0700179static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw);
180static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw);
181static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw);
182static s32 e1000_check_polarity_ife_ich8lan(struct e1000_hw *hw);
183static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank);
184static s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw,
185 u32 offset, u8 byte);
Bruce Allanf4187b52008-08-26 18:36:50 -0700186static s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
187 u8 *data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700188static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset,
189 u16 *data);
190static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
191 u8 size, u16 *data);
192static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw);
193static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw);
Bruce Allanf4187b52008-08-26 18:36:50 -0700194static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw);
Bruce Allana4f58f52009-06-02 11:29:18 +0000195static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw);
196static s32 e1000_led_on_ich8lan(struct e1000_hw *hw);
197static s32 e1000_led_off_ich8lan(struct e1000_hw *hw);
198static s32 e1000_id_led_init_pchlan(struct e1000_hw *hw);
199static s32 e1000_setup_led_pchlan(struct e1000_hw *hw);
200static s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw);
201static s32 e1000_led_on_pchlan(struct e1000_hw *hw);
202static s32 e1000_led_off_pchlan(struct e1000_hw *hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700203
204static inline u16 __er16flash(struct e1000_hw *hw, unsigned long reg)
205{
206 return readw(hw->flash_address + reg);
207}
208
209static inline u32 __er32flash(struct e1000_hw *hw, unsigned long reg)
210{
211 return readl(hw->flash_address + reg);
212}
213
214static inline void __ew16flash(struct e1000_hw *hw, unsigned long reg, u16 val)
215{
216 writew(val, hw->flash_address + reg);
217}
218
219static inline void __ew32flash(struct e1000_hw *hw, unsigned long reg, u32 val)
220{
221 writel(val, hw->flash_address + reg);
222}
223
224#define er16flash(reg) __er16flash(hw, (reg))
225#define er32flash(reg) __er32flash(hw, (reg))
226#define ew16flash(reg,val) __ew16flash(hw, (reg), (val))
227#define ew32flash(reg,val) __ew32flash(hw, (reg), (val))
228
229/**
Bruce Allana4f58f52009-06-02 11:29:18 +0000230 * e1000_init_phy_params_pchlan - Initialize PHY function pointers
231 * @hw: pointer to the HW structure
232 *
233 * Initialize family-specific PHY parameters and function pointers.
234 **/
235static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw)
236{
237 struct e1000_phy_info *phy = &hw->phy;
238 s32 ret_val = 0;
239
240 phy->addr = 1;
241 phy->reset_delay_us = 100;
242
243 phy->ops.check_polarity = e1000_check_polarity_ife_ich8lan;
244 phy->ops.read_phy_reg = e1000_read_phy_reg_hv;
245 phy->ops.write_phy_reg = e1000_write_phy_reg_hv;
246 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
247
248 phy->id = e1000_phy_unknown;
249 e1000e_get_phy_id(hw);
250 phy->type = e1000e_get_phy_type_from_id(phy->id);
251
252 if (phy->type == e1000_phy_82577) {
253 phy->ops.check_polarity = e1000_check_polarity_82577;
254 phy->ops.force_speed_duplex =
255 e1000_phy_force_speed_duplex_82577;
256 phy->ops.get_cable_length = e1000_get_cable_length_82577;
257 phy->ops.get_phy_info = e1000_get_phy_info_82577;
258 phy->ops.commit_phy = e1000e_phy_sw_reset;
259 }
260
261 return ret_val;
262}
263
264/**
Auke Kokbc7f75f2007-09-17 12:30:59 -0700265 * e1000_init_phy_params_ich8lan - Initialize PHY function pointers
266 * @hw: pointer to the HW structure
267 *
268 * Initialize family-specific PHY parameters and function pointers.
269 **/
270static s32 e1000_init_phy_params_ich8lan(struct e1000_hw *hw)
271{
272 struct e1000_phy_info *phy = &hw->phy;
273 s32 ret_val;
274 u16 i = 0;
275
276 phy->addr = 1;
277 phy->reset_delay_us = 100;
278
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700279 /*
280 * We may need to do this twice - once for IGP and if that fails,
281 * we'll set BM func pointers and try again
282 */
283 ret_val = e1000e_determine_phy_address(hw);
284 if (ret_val) {
285 hw->phy.ops.write_phy_reg = e1000e_write_phy_reg_bm;
286 hw->phy.ops.read_phy_reg = e1000e_read_phy_reg_bm;
287 ret_val = e1000e_determine_phy_address(hw);
288 if (ret_val)
289 return ret_val;
290 }
291
Auke Kokbc7f75f2007-09-17 12:30:59 -0700292 phy->id = 0;
293 while ((e1000_phy_unknown == e1000e_get_phy_type_from_id(phy->id)) &&
294 (i++ < 100)) {
295 msleep(1);
296 ret_val = e1000e_get_phy_id(hw);
297 if (ret_val)
298 return ret_val;
299 }
300
301 /* Verify phy id */
302 switch (phy->id) {
303 case IGP03E1000_E_PHY_ID:
304 phy->type = e1000_phy_igp_3;
305 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
306 break;
307 case IFE_E_PHY_ID:
308 case IFE_PLUS_E_PHY_ID:
309 case IFE_C_E_PHY_ID:
310 phy->type = e1000_phy_ife;
311 phy->autoneg_mask = E1000_ALL_NOT_GIG;
312 break;
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700313 case BME1000_E_PHY_ID:
314 phy->type = e1000_phy_bm;
315 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
316 hw->phy.ops.read_phy_reg = e1000e_read_phy_reg_bm;
317 hw->phy.ops.write_phy_reg = e1000e_write_phy_reg_bm;
318 hw->phy.ops.commit_phy = e1000e_phy_sw_reset;
319 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700320 default:
321 return -E1000_ERR_PHY;
322 break;
323 }
324
Bruce Allana4f58f52009-06-02 11:29:18 +0000325 phy->ops.check_polarity = e1000_check_polarity_ife_ich8lan;
326
Auke Kokbc7f75f2007-09-17 12:30:59 -0700327 return 0;
328}
329
330/**
331 * e1000_init_nvm_params_ich8lan - Initialize NVM function pointers
332 * @hw: pointer to the HW structure
333 *
334 * Initialize family-specific NVM parameters and function
335 * pointers.
336 **/
337static s32 e1000_init_nvm_params_ich8lan(struct e1000_hw *hw)
338{
339 struct e1000_nvm_info *nvm = &hw->nvm;
340 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
341 u32 gfpreg;
342 u32 sector_base_addr;
343 u32 sector_end_addr;
344 u16 i;
345
Bruce Allanad680762008-03-28 09:15:03 -0700346 /* Can't read flash registers if the register set isn't mapped. */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700347 if (!hw->flash_address) {
348 hw_dbg(hw, "ERROR: Flash registers not mapped\n");
349 return -E1000_ERR_CONFIG;
350 }
351
352 nvm->type = e1000_nvm_flash_sw;
353
354 gfpreg = er32flash(ICH_FLASH_GFPREG);
355
Bruce Allanad680762008-03-28 09:15:03 -0700356 /*
357 * sector_X_addr is a "sector"-aligned address (4096 bytes)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700358 * Add 1 to sector_end_addr since this sector is included in
Bruce Allanad680762008-03-28 09:15:03 -0700359 * the overall size.
360 */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700361 sector_base_addr = gfpreg & FLASH_GFPREG_BASE_MASK;
362 sector_end_addr = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK) + 1;
363
364 /* flash_base_addr is byte-aligned */
365 nvm->flash_base_addr = sector_base_addr << FLASH_SECTOR_ADDR_SHIFT;
366
Bruce Allanad680762008-03-28 09:15:03 -0700367 /*
368 * find total size of the NVM, then cut in half since the total
369 * size represents two separate NVM banks.
370 */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700371 nvm->flash_bank_size = (sector_end_addr - sector_base_addr)
372 << FLASH_SECTOR_ADDR_SHIFT;
373 nvm->flash_bank_size /= 2;
374 /* Adjust to word count */
375 nvm->flash_bank_size /= sizeof(u16);
376
377 nvm->word_size = E1000_ICH8_SHADOW_RAM_WORDS;
378
379 /* Clear shadow ram */
380 for (i = 0; i < nvm->word_size; i++) {
381 dev_spec->shadow_ram[i].modified = 0;
382 dev_spec->shadow_ram[i].value = 0xFFFF;
383 }
384
385 return 0;
386}
387
388/**
389 * e1000_init_mac_params_ich8lan - Initialize MAC function pointers
390 * @hw: pointer to the HW structure
391 *
392 * Initialize family-specific MAC parameters and function
393 * pointers.
394 **/
395static s32 e1000_init_mac_params_ich8lan(struct e1000_adapter *adapter)
396{
397 struct e1000_hw *hw = &adapter->hw;
398 struct e1000_mac_info *mac = &hw->mac;
399
400 /* Set media type function pointer */
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700401 hw->phy.media_type = e1000_media_type_copper;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700402
403 /* Set mta register count */
404 mac->mta_reg_count = 32;
405 /* Set rar entry count */
406 mac->rar_entry_count = E1000_ICH_RAR_ENTRIES;
407 if (mac->type == e1000_ich8lan)
408 mac->rar_entry_count--;
409 /* Set if manageability features are enabled. */
410 mac->arc_subsystem_valid = 1;
411
Bruce Allana4f58f52009-06-02 11:29:18 +0000412 /* LED operations */
413 switch (mac->type) {
414 case e1000_ich8lan:
415 case e1000_ich9lan:
416 case e1000_ich10lan:
417 /* ID LED init */
418 mac->ops.id_led_init = e1000e_id_led_init;
419 /* setup LED */
420 mac->ops.setup_led = e1000e_setup_led_generic;
421 /* cleanup LED */
422 mac->ops.cleanup_led = e1000_cleanup_led_ich8lan;
423 /* turn on/off LED */
424 mac->ops.led_on = e1000_led_on_ich8lan;
425 mac->ops.led_off = e1000_led_off_ich8lan;
426 break;
427 case e1000_pchlan:
428 /* ID LED init */
429 mac->ops.id_led_init = e1000_id_led_init_pchlan;
430 /* setup LED */
431 mac->ops.setup_led = e1000_setup_led_pchlan;
432 /* cleanup LED */
433 mac->ops.cleanup_led = e1000_cleanup_led_pchlan;
434 /* turn on/off LED */
435 mac->ops.led_on = e1000_led_on_pchlan;
436 mac->ops.led_off = e1000_led_off_pchlan;
437 break;
438 default:
439 break;
440 }
441
Auke Kokbc7f75f2007-09-17 12:30:59 -0700442 /* Enable PCS Lock-loss workaround for ICH8 */
443 if (mac->type == e1000_ich8lan)
444 e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw, 1);
445
446 return 0;
447}
448
Jeff Kirsher69e3fd82008-04-02 13:48:18 -0700449static s32 e1000_get_variants_ich8lan(struct e1000_adapter *adapter)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700450{
451 struct e1000_hw *hw = &adapter->hw;
452 s32 rc;
453
454 rc = e1000_init_mac_params_ich8lan(adapter);
455 if (rc)
456 return rc;
457
458 rc = e1000_init_nvm_params_ich8lan(hw);
459 if (rc)
460 return rc;
461
Bruce Allana4f58f52009-06-02 11:29:18 +0000462 if (hw->mac.type == e1000_pchlan)
463 rc = e1000_init_phy_params_pchlan(hw);
464 else
465 rc = e1000_init_phy_params_ich8lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700466 if (rc)
467 return rc;
468
Bruce Allan2adc55c2009-06-02 11:28:58 +0000469 if (adapter->hw.phy.type == e1000_phy_ife) {
470 adapter->flags &= ~FLAG_HAS_JUMBO_FRAMES;
471 adapter->max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN;
472 }
473
Auke Kokbc7f75f2007-09-17 12:30:59 -0700474 if ((adapter->hw.mac.type == e1000_ich8lan) &&
475 (adapter->hw.phy.type == e1000_phy_igp_3))
476 adapter->flags |= FLAG_LSC_GIG_SPEED_DROP;
477
478 return 0;
479}
480
Thomas Gleixner717d4382008-10-02 16:33:40 -0700481static DEFINE_MUTEX(nvm_mutex);
Thomas Gleixner717d4382008-10-02 16:33:40 -0700482
Auke Kokbc7f75f2007-09-17 12:30:59 -0700483/**
484 * e1000_acquire_swflag_ich8lan - Acquire software control flag
485 * @hw: pointer to the HW structure
486 *
487 * Acquires the software control flag for performing NVM and PHY
488 * operations. This is a function pointer entry point only called by
489 * read/write routines for the PHY and NVM parts.
490 **/
491static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw)
492{
493 u32 extcnf_ctrl;
494 u32 timeout = PHY_CFG_TIMEOUT;
495
Linus Torvalds95b866d2008-10-03 09:18:17 -0700496 might_sleep();
Thomas Gleixner717d4382008-10-02 16:33:40 -0700497
dave graham0a834a32009-02-14 23:46:10 -0800498 mutex_lock(&nvm_mutex);
Thomas Gleixner717d4382008-10-02 16:33:40 -0700499
Auke Kokbc7f75f2007-09-17 12:30:59 -0700500 while (timeout) {
501 extcnf_ctrl = er32(EXTCNF_CTRL);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700502
Bruce Allana4f58f52009-06-02 11:29:18 +0000503 if (!(extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG)) {
504 extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG;
505 ew32(EXTCNF_CTRL, extcnf_ctrl);
506
507 extcnf_ctrl = er32(EXTCNF_CTRL);
508 if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG)
509 break;
510 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700511 mdelay(1);
512 timeout--;
513 }
514
515 if (!timeout) {
516 hw_dbg(hw, "FW or HW has locked the resource for too long.\n");
Bruce Allan2e2e8d52008-09-23 15:46:38 -0700517 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
518 ew32(EXTCNF_CTRL, extcnf_ctrl);
Thomas Gleixner717d4382008-10-02 16:33:40 -0700519 mutex_unlock(&nvm_mutex);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700520 return -E1000_ERR_CONFIG;
521 }
522
523 return 0;
524}
525
526/**
527 * e1000_release_swflag_ich8lan - Release software control flag
528 * @hw: pointer to the HW structure
529 *
530 * Releases the software control flag for performing NVM and PHY operations.
531 * This is a function pointer entry point only called by read/write
532 * routines for the PHY and NVM parts.
533 **/
534static void e1000_release_swflag_ich8lan(struct e1000_hw *hw)
535{
536 u32 extcnf_ctrl;
537
538 extcnf_ctrl = er32(EXTCNF_CTRL);
539 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
540 ew32(EXTCNF_CTRL, extcnf_ctrl);
Thomas Gleixner717d4382008-10-02 16:33:40 -0700541
Thomas Gleixner717d4382008-10-02 16:33:40 -0700542 mutex_unlock(&nvm_mutex);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700543}
544
545/**
Bruce Allan4662e822008-08-26 18:37:06 -0700546 * e1000_check_mng_mode_ich8lan - Checks management mode
547 * @hw: pointer to the HW structure
548 *
549 * This checks if the adapter has manageability enabled.
550 * This is a function pointer entry point only called by read/write
551 * routines for the PHY and NVM parts.
552 **/
553static bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw)
554{
555 u32 fwsm = er32(FWSM);
556
557 return (fwsm & E1000_FWSM_MODE_MASK) ==
558 (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT);
559}
560
561/**
Auke Kokbc7f75f2007-09-17 12:30:59 -0700562 * e1000_check_reset_block_ich8lan - Check if PHY reset is blocked
563 * @hw: pointer to the HW structure
564 *
565 * Checks if firmware is blocking the reset of the PHY.
566 * This is a function pointer entry point only called by
567 * reset routines.
568 **/
569static s32 e1000_check_reset_block_ich8lan(struct e1000_hw *hw)
570{
571 u32 fwsm;
572
573 fwsm = er32(FWSM);
574
575 return (fwsm & E1000_ICH_FWSM_RSPCIPHY) ? 0 : E1000_BLK_PHY_RESET;
576}
577
578/**
579 * e1000_phy_force_speed_duplex_ich8lan - Force PHY speed & duplex
580 * @hw: pointer to the HW structure
581 *
582 * Forces the speed and duplex settings of the PHY.
583 * This is a function pointer entry point only called by
584 * PHY setup routines.
585 **/
586static s32 e1000_phy_force_speed_duplex_ich8lan(struct e1000_hw *hw)
587{
588 struct e1000_phy_info *phy = &hw->phy;
589 s32 ret_val;
590 u16 data;
591 bool link;
592
593 if (phy->type != e1000_phy_ife) {
594 ret_val = e1000e_phy_force_speed_duplex_igp(hw);
595 return ret_val;
596 }
597
598 ret_val = e1e_rphy(hw, PHY_CONTROL, &data);
599 if (ret_val)
600 return ret_val;
601
602 e1000e_phy_force_speed_duplex_setup(hw, &data);
603
604 ret_val = e1e_wphy(hw, PHY_CONTROL, data);
605 if (ret_val)
606 return ret_val;
607
608 /* Disable MDI-X support for 10/100 */
609 ret_val = e1e_rphy(hw, IFE_PHY_MDIX_CONTROL, &data);
610 if (ret_val)
611 return ret_val;
612
613 data &= ~IFE_PMC_AUTO_MDIX;
614 data &= ~IFE_PMC_FORCE_MDIX;
615
616 ret_val = e1e_wphy(hw, IFE_PHY_MDIX_CONTROL, data);
617 if (ret_val)
618 return ret_val;
619
620 hw_dbg(hw, "IFE PMC: %X\n", data);
621
622 udelay(1);
623
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700624 if (phy->autoneg_wait_to_complete) {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700625 hw_dbg(hw, "Waiting for forced speed/duplex link on IFE phy.\n");
626
627 ret_val = e1000e_phy_has_link_generic(hw,
628 PHY_FORCE_LIMIT,
629 100000,
630 &link);
631 if (ret_val)
632 return ret_val;
633
634 if (!link)
635 hw_dbg(hw, "Link taking longer than expected.\n");
636
637 /* Try once more */
638 ret_val = e1000e_phy_has_link_generic(hw,
639 PHY_FORCE_LIMIT,
640 100000,
641 &link);
642 if (ret_val)
643 return ret_val;
644 }
645
646 return 0;
647}
648
649/**
Bruce Allana4f58f52009-06-02 11:29:18 +0000650 * e1000_hv_phy_workarounds_ich8lan - A series of Phy workarounds to be
651 * done after every PHY reset.
652 **/
653static s32 e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw)
654{
655 s32 ret_val = 0;
656
657 if (hw->mac.type != e1000_pchlan)
658 return ret_val;
659
660 if (((hw->phy.type == e1000_phy_82577) &&
661 ((hw->phy.revision == 1) || (hw->phy.revision == 2))) ||
662 ((hw->phy.type == e1000_phy_82578) && (hw->phy.revision == 1))) {
663 /* Disable generation of early preamble */
664 ret_val = e1e_wphy(hw, PHY_REG(769, 25), 0x4431);
665 if (ret_val)
666 return ret_val;
667
668 /* Preamble tuning for SSC */
669 ret_val = e1e_wphy(hw, PHY_REG(770, 16), 0xA204);
670 if (ret_val)
671 return ret_val;
672 }
673
674 if (hw->phy.type == e1000_phy_82578) {
675 /*
676 * Return registers to default by doing a soft reset then
677 * writing 0x3140 to the control register.
678 */
679 if (hw->phy.revision < 2) {
680 e1000e_phy_sw_reset(hw);
681 ret_val = e1e_wphy(hw, PHY_CONTROL, 0x3140);
682 }
683 }
684
685 /* Select page 0 */
686 ret_val = hw->phy.ops.acquire_phy(hw);
687 if (ret_val)
688 return ret_val;
689 hw->phy.addr = 1;
690 e1000e_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT, 0);
691 hw->phy.ops.release_phy(hw);
692
693 return ret_val;
694}
695
696/**
Bruce Allanfc0c7762009-07-01 13:27:55 +0000697 * e1000_lan_init_done_ich8lan - Check for PHY config completion
698 * @hw: pointer to the HW structure
699 *
700 * Check the appropriate indication the MAC has finished configuring the
701 * PHY after a software reset.
702 **/
703static void e1000_lan_init_done_ich8lan(struct e1000_hw *hw)
704{
705 u32 data, loop = E1000_ICH8_LAN_INIT_TIMEOUT;
706
707 /* Wait for basic configuration completes before proceeding */
708 do {
709 data = er32(STATUS);
710 data &= E1000_STATUS_LAN_INIT_DONE;
711 udelay(100);
712 } while ((!data) && --loop);
713
714 /*
715 * If basic configuration is incomplete before the above loop
716 * count reaches 0, loading the configuration from NVM will
717 * leave the PHY in a bad state possibly resulting in no link.
718 */
719 if (loop == 0)
720 hw_dbg(hw, "LAN_INIT_DONE not set, increase timeout\n");
721
722 /* Clear the Init Done bit for the next init event */
723 data = er32(STATUS);
724 data &= ~E1000_STATUS_LAN_INIT_DONE;
725 ew32(STATUS, data);
726}
727
728/**
Auke Kokbc7f75f2007-09-17 12:30:59 -0700729 * e1000_phy_hw_reset_ich8lan - Performs a PHY reset
730 * @hw: pointer to the HW structure
731 *
732 * Resets the PHY
733 * This is a function pointer entry point called by drivers
734 * or other shared routines.
735 **/
736static s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw)
737{
738 struct e1000_phy_info *phy = &hw->phy;
739 u32 i;
740 u32 data, cnf_size, cnf_base_addr, sw_cfg_mask;
741 s32 ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700742 u16 word_addr, reg_data, reg_addr, phy_page = 0;
743
744 ret_val = e1000e_phy_hw_reset_generic(hw);
745 if (ret_val)
746 return ret_val;
747
Bruce Allanfc0c7762009-07-01 13:27:55 +0000748 /* Allow time for h/w to get to a quiescent state after reset */
749 mdelay(10);
750
Bruce Allana4f58f52009-06-02 11:29:18 +0000751 if (hw->mac.type == e1000_pchlan) {
752 ret_val = e1000_hv_phy_workarounds_ich8lan(hw);
753 if (ret_val)
754 return ret_val;
755 }
756
Bruce Allanad680762008-03-28 09:15:03 -0700757 /*
758 * Initialize the PHY from the NVM on ICH platforms. This
Auke Kokbc7f75f2007-09-17 12:30:59 -0700759 * is needed due to an issue where the NVM configuration is
760 * not properly autoloaded after power transitions.
761 * Therefore, after each PHY reset, we will load the
762 * configuration data out of the NVM manually.
763 */
764 if (hw->mac.type == e1000_ich8lan && phy->type == e1000_phy_igp_3) {
765 struct e1000_adapter *adapter = hw->adapter;
766
767 /* Check if SW needs configure the PHY */
768 if ((adapter->pdev->device == E1000_DEV_ID_ICH8_IGP_M_AMT) ||
769 (adapter->pdev->device == E1000_DEV_ID_ICH8_IGP_M))
770 sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG_ICH8M;
771 else
772 sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG;
773
774 data = er32(FEXTNVM);
775 if (!(data & sw_cfg_mask))
776 return 0;
777
Bruce Allanfc0c7762009-07-01 13:27:55 +0000778 /* Wait for basic configuration completes before proceeding */
779 e1000_lan_init_done_ich8lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700780
Bruce Allanad680762008-03-28 09:15:03 -0700781 /*
782 * Make sure HW does not configure LCD from PHY
783 * extended configuration before SW configuration
784 */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700785 data = er32(EXTCNF_CTRL);
786 if (data & E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE)
787 return 0;
788
789 cnf_size = er32(EXTCNF_SIZE);
790 cnf_size &= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_MASK;
791 cnf_size >>= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_SHIFT;
792 if (!cnf_size)
793 return 0;
794
795 cnf_base_addr = data & E1000_EXTCNF_CTRL_EXT_CNF_POINTER_MASK;
796 cnf_base_addr >>= E1000_EXTCNF_CTRL_EXT_CNF_POINTER_SHIFT;
797
Bruce Allanad680762008-03-28 09:15:03 -0700798 /* Configure LCD from extended configuration region. */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700799
800 /* cnf_base_addr is in DWORD */
801 word_addr = (u16)(cnf_base_addr << 1);
802
803 for (i = 0; i < cnf_size; i++) {
804 ret_val = e1000_read_nvm(hw,
805 (word_addr + i * 2),
806 1,
807 &reg_data);
808 if (ret_val)
809 return ret_val;
810
811 ret_val = e1000_read_nvm(hw,
812 (word_addr + i * 2 + 1),
813 1,
814 &reg_addr);
815 if (ret_val)
816 return ret_val;
817
818 /* Save off the PHY page for future writes. */
819 if (reg_addr == IGP01E1000_PHY_PAGE_SELECT) {
820 phy_page = reg_data;
821 continue;
822 }
823
824 reg_addr |= phy_page;
825
826 ret_val = e1e_wphy(hw, (u32)reg_addr, reg_data);
827 if (ret_val)
828 return ret_val;
829 }
830 }
831
832 return 0;
833}
834
835/**
836 * e1000_get_phy_info_ife_ich8lan - Retrieves various IFE PHY states
837 * @hw: pointer to the HW structure
838 *
839 * Populates "phy" structure with various feature states.
840 * This function is only called by other family-specific
841 * routines.
842 **/
843static s32 e1000_get_phy_info_ife_ich8lan(struct e1000_hw *hw)
844{
845 struct e1000_phy_info *phy = &hw->phy;
846 s32 ret_val;
847 u16 data;
848 bool link;
849
850 ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link);
851 if (ret_val)
852 return ret_val;
853
854 if (!link) {
855 hw_dbg(hw, "Phy info is only valid if link is up\n");
856 return -E1000_ERR_CONFIG;
857 }
858
859 ret_val = e1e_rphy(hw, IFE_PHY_SPECIAL_CONTROL, &data);
860 if (ret_val)
861 return ret_val;
862 phy->polarity_correction = (!(data & IFE_PSC_AUTO_POLARITY_DISABLE));
863
864 if (phy->polarity_correction) {
Bruce Allana4f58f52009-06-02 11:29:18 +0000865 ret_val = phy->ops.check_polarity(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700866 if (ret_val)
867 return ret_val;
868 } else {
869 /* Polarity is forced */
870 phy->cable_polarity = (data & IFE_PSC_FORCE_POLARITY)
871 ? e1000_rev_polarity_reversed
872 : e1000_rev_polarity_normal;
873 }
874
875 ret_val = e1e_rphy(hw, IFE_PHY_MDIX_CONTROL, &data);
876 if (ret_val)
877 return ret_val;
878
879 phy->is_mdix = (data & IFE_PMC_MDIX_STATUS);
880
881 /* The following parameters are undefined for 10/100 operation. */
882 phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED;
883 phy->local_rx = e1000_1000t_rx_status_undefined;
884 phy->remote_rx = e1000_1000t_rx_status_undefined;
885
886 return 0;
887}
888
889/**
890 * e1000_get_phy_info_ich8lan - Calls appropriate PHY type get_phy_info
891 * @hw: pointer to the HW structure
892 *
893 * Wrapper for calling the get_phy_info routines for the appropriate phy type.
894 * This is a function pointer entry point called by drivers
895 * or other shared routines.
896 **/
897static s32 e1000_get_phy_info_ich8lan(struct e1000_hw *hw)
898{
899 switch (hw->phy.type) {
900 case e1000_phy_ife:
901 return e1000_get_phy_info_ife_ich8lan(hw);
902 break;
903 case e1000_phy_igp_3:
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700904 case e1000_phy_bm:
Bruce Allana4f58f52009-06-02 11:29:18 +0000905 case e1000_phy_82578:
906 case e1000_phy_82577:
Auke Kokbc7f75f2007-09-17 12:30:59 -0700907 return e1000e_get_phy_info_igp(hw);
908 break;
909 default:
910 break;
911 }
912
913 return -E1000_ERR_PHY_TYPE;
914}
915
916/**
917 * e1000_check_polarity_ife_ich8lan - Check cable polarity for IFE PHY
918 * @hw: pointer to the HW structure
919 *
Auke Kok489815c2008-02-21 15:11:07 -0800920 * Polarity is determined on the polarity reversal feature being enabled.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700921 * This function is only called by other family-specific
922 * routines.
923 **/
924static s32 e1000_check_polarity_ife_ich8lan(struct e1000_hw *hw)
925{
926 struct e1000_phy_info *phy = &hw->phy;
927 s32 ret_val;
928 u16 phy_data, offset, mask;
929
Bruce Allanad680762008-03-28 09:15:03 -0700930 /*
931 * Polarity is determined based on the reversal feature being enabled.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700932 */
933 if (phy->polarity_correction) {
934 offset = IFE_PHY_EXTENDED_STATUS_CONTROL;
935 mask = IFE_PESC_POLARITY_REVERSED;
936 } else {
937 offset = IFE_PHY_SPECIAL_CONTROL;
938 mask = IFE_PSC_FORCE_POLARITY;
939 }
940
941 ret_val = e1e_rphy(hw, offset, &phy_data);
942
943 if (!ret_val)
944 phy->cable_polarity = (phy_data & mask)
945 ? e1000_rev_polarity_reversed
946 : e1000_rev_polarity_normal;
947
948 return ret_val;
949}
950
951/**
952 * e1000_set_d0_lplu_state_ich8lan - Set Low Power Linkup D0 state
953 * @hw: pointer to the HW structure
954 * @active: TRUE to enable LPLU, FALSE to disable
955 *
956 * Sets the LPLU D0 state according to the active flag. When
957 * activating LPLU this function also disables smart speed
958 * and vice versa. LPLU will not be activated unless the
959 * device autonegotiation advertisement meets standards of
960 * either 10 or 10/100 or 10/100/1000 at all duplexes.
961 * This is a function pointer entry point only called by
962 * PHY setup routines.
963 **/
964static s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
965{
966 struct e1000_phy_info *phy = &hw->phy;
967 u32 phy_ctrl;
968 s32 ret_val = 0;
969 u16 data;
970
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700971 if (phy->type == e1000_phy_ife)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700972 return ret_val;
973
974 phy_ctrl = er32(PHY_CTRL);
975
976 if (active) {
977 phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU;
978 ew32(PHY_CTRL, phy_ctrl);
979
Bruce Allan60f12922009-07-01 13:28:14 +0000980 if (phy->type != e1000_phy_igp_3)
981 return 0;
982
Bruce Allanad680762008-03-28 09:15:03 -0700983 /*
984 * Call gig speed drop workaround on LPLU before accessing
985 * any PHY registers
986 */
Bruce Allan60f12922009-07-01 13:28:14 +0000987 if (hw->mac.type == e1000_ich8lan)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700988 e1000e_gig_downshift_workaround_ich8lan(hw);
989
990 /* When LPLU is enabled, we should disable SmartSpeed */
991 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data);
992 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
993 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);
994 if (ret_val)
995 return ret_val;
996 } else {
997 phy_ctrl &= ~E1000_PHY_CTRL_D0A_LPLU;
998 ew32(PHY_CTRL, phy_ctrl);
999
Bruce Allan60f12922009-07-01 13:28:14 +00001000 if (phy->type != e1000_phy_igp_3)
1001 return 0;
1002
Bruce Allanad680762008-03-28 09:15:03 -07001003 /*
1004 * LPLU and SmartSpeed are mutually exclusive. LPLU is used
Auke Kokbc7f75f2007-09-17 12:30:59 -07001005 * during Dx states where the power conservation is most
1006 * important. During driver activity we should enable
Bruce Allanad680762008-03-28 09:15:03 -07001007 * SmartSpeed, so performance is maintained.
1008 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07001009 if (phy->smart_speed == e1000_smart_speed_on) {
1010 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
Bruce Allanad680762008-03-28 09:15:03 -07001011 &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001012 if (ret_val)
1013 return ret_val;
1014
1015 data |= IGP01E1000_PSCFR_SMART_SPEED;
1016 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
Bruce Allanad680762008-03-28 09:15:03 -07001017 data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001018 if (ret_val)
1019 return ret_val;
1020 } else if (phy->smart_speed == e1000_smart_speed_off) {
1021 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
Bruce Allanad680762008-03-28 09:15:03 -07001022 &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001023 if (ret_val)
1024 return ret_val;
1025
1026 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
1027 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
Bruce Allanad680762008-03-28 09:15:03 -07001028 data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001029 if (ret_val)
1030 return ret_val;
1031 }
1032 }
1033
1034 return 0;
1035}
1036
1037/**
1038 * e1000_set_d3_lplu_state_ich8lan - Set Low Power Linkup D3 state
1039 * @hw: pointer to the HW structure
1040 * @active: TRUE to enable LPLU, FALSE to disable
1041 *
1042 * Sets the LPLU D3 state according to the active flag. When
1043 * activating LPLU this function also disables smart speed
1044 * and vice versa. LPLU will not be activated unless the
1045 * device autonegotiation advertisement meets standards of
1046 * either 10 or 10/100 or 10/100/1000 at all duplexes.
1047 * This is a function pointer entry point only called by
1048 * PHY setup routines.
1049 **/
1050static s32 e1000_set_d3_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
1051{
1052 struct e1000_phy_info *phy = &hw->phy;
1053 u32 phy_ctrl;
1054 s32 ret_val;
1055 u16 data;
1056
1057 phy_ctrl = er32(PHY_CTRL);
1058
1059 if (!active) {
1060 phy_ctrl &= ~E1000_PHY_CTRL_NOND0A_LPLU;
1061 ew32(PHY_CTRL, phy_ctrl);
Bruce Allan60f12922009-07-01 13:28:14 +00001062
1063 if (phy->type != e1000_phy_igp_3)
1064 return 0;
1065
Bruce Allanad680762008-03-28 09:15:03 -07001066 /*
1067 * LPLU and SmartSpeed are mutually exclusive. LPLU is used
Auke Kokbc7f75f2007-09-17 12:30:59 -07001068 * during Dx states where the power conservation is most
1069 * important. During driver activity we should enable
Bruce Allanad680762008-03-28 09:15:03 -07001070 * SmartSpeed, so performance is maintained.
1071 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07001072 if (phy->smart_speed == e1000_smart_speed_on) {
Bruce Allanad680762008-03-28 09:15:03 -07001073 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
1074 &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001075 if (ret_val)
1076 return ret_val;
1077
1078 data |= IGP01E1000_PSCFR_SMART_SPEED;
Bruce Allanad680762008-03-28 09:15:03 -07001079 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
1080 data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001081 if (ret_val)
1082 return ret_val;
1083 } else if (phy->smart_speed == e1000_smart_speed_off) {
Bruce Allanad680762008-03-28 09:15:03 -07001084 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
1085 &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001086 if (ret_val)
1087 return ret_val;
1088
1089 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
Bruce Allanad680762008-03-28 09:15:03 -07001090 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
1091 data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001092 if (ret_val)
1093 return ret_val;
1094 }
1095 } else if ((phy->autoneg_advertised == E1000_ALL_SPEED_DUPLEX) ||
1096 (phy->autoneg_advertised == E1000_ALL_NOT_GIG) ||
1097 (phy->autoneg_advertised == E1000_ALL_10_SPEED)) {
1098 phy_ctrl |= E1000_PHY_CTRL_NOND0A_LPLU;
1099 ew32(PHY_CTRL, phy_ctrl);
1100
Bruce Allan60f12922009-07-01 13:28:14 +00001101 if (phy->type != e1000_phy_igp_3)
1102 return 0;
1103
Bruce Allanad680762008-03-28 09:15:03 -07001104 /*
1105 * Call gig speed drop workaround on LPLU before accessing
1106 * any PHY registers
1107 */
Bruce Allan60f12922009-07-01 13:28:14 +00001108 if (hw->mac.type == e1000_ich8lan)
Auke Kokbc7f75f2007-09-17 12:30:59 -07001109 e1000e_gig_downshift_workaround_ich8lan(hw);
1110
1111 /* When LPLU is enabled, we should disable SmartSpeed */
Bruce Allanad680762008-03-28 09:15:03 -07001112 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001113 if (ret_val)
1114 return ret_val;
1115
1116 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
Bruce Allanad680762008-03-28 09:15:03 -07001117 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001118 }
1119
1120 return 0;
1121}
1122
1123/**
Bruce Allanf4187b52008-08-26 18:36:50 -07001124 * e1000_valid_nvm_bank_detect_ich8lan - finds out the valid bank 0 or 1
1125 * @hw: pointer to the HW structure
1126 * @bank: pointer to the variable that returns the active bank
1127 *
1128 * Reads signature byte from the NVM using the flash access registers.
Bruce Allane2434552008-11-21 17:02:41 -08001129 * Word 0x13 bits 15:14 = 10b indicate a valid signature for that bank.
Bruce Allanf4187b52008-08-26 18:36:50 -07001130 **/
1131static s32 e1000_valid_nvm_bank_detect_ich8lan(struct e1000_hw *hw, u32 *bank)
1132{
Bruce Allane2434552008-11-21 17:02:41 -08001133 u32 eecd;
Bruce Allanf4187b52008-08-26 18:36:50 -07001134 struct e1000_nvm_info *nvm = &hw->nvm;
Bruce Allanf4187b52008-08-26 18:36:50 -07001135 u32 bank1_offset = nvm->flash_bank_size * sizeof(u16);
1136 u32 act_offset = E1000_ICH_NVM_SIG_WORD * 2 + 1;
Bruce Allane2434552008-11-21 17:02:41 -08001137 u8 sig_byte = 0;
1138 s32 ret_val = 0;
Bruce Allanf4187b52008-08-26 18:36:50 -07001139
Bruce Allane2434552008-11-21 17:02:41 -08001140 switch (hw->mac.type) {
1141 case e1000_ich8lan:
1142 case e1000_ich9lan:
1143 eecd = er32(EECD);
1144 if ((eecd & E1000_EECD_SEC1VAL_VALID_MASK) ==
1145 E1000_EECD_SEC1VAL_VALID_MASK) {
1146 if (eecd & E1000_EECD_SEC1VAL)
Bruce Allanf4187b52008-08-26 18:36:50 -07001147 *bank = 1;
Bruce Allane2434552008-11-21 17:02:41 -08001148 else
1149 *bank = 0;
1150
1151 return 0;
Bruce Allanf4187b52008-08-26 18:36:50 -07001152 }
Bruce Allane2434552008-11-21 17:02:41 -08001153 hw_dbg(hw, "Unable to determine valid NVM bank via EEC - "
1154 "reading flash signature\n");
1155 /* fall-thru */
1156 default:
1157 /* set bank to 0 in case flash read fails */
1158 *bank = 0;
1159
1160 /* Check bank 0 */
1161 ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset,
1162 &sig_byte);
1163 if (ret_val)
1164 return ret_val;
1165 if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
1166 E1000_ICH_NVM_SIG_VALUE) {
1167 *bank = 0;
1168 return 0;
1169 }
1170
1171 /* Check bank 1 */
1172 ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset +
1173 bank1_offset,
1174 &sig_byte);
1175 if (ret_val)
1176 return ret_val;
1177 if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
1178 E1000_ICH_NVM_SIG_VALUE) {
1179 *bank = 1;
1180 return 0;
1181 }
1182
1183 hw_dbg(hw, "ERROR: No valid NVM bank present\n");
1184 return -E1000_ERR_NVM;
Bruce Allanf4187b52008-08-26 18:36:50 -07001185 }
1186
1187 return 0;
1188}
1189
1190/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07001191 * e1000_read_nvm_ich8lan - Read word(s) from the NVM
1192 * @hw: pointer to the HW structure
1193 * @offset: The offset (in bytes) of the word(s) to read.
1194 * @words: Size of data to read in words
1195 * @data: Pointer to the word(s) to read at offset.
1196 *
1197 * Reads a word(s) from the NVM using the flash access registers.
1198 **/
1199static s32 e1000_read_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
1200 u16 *data)
1201{
1202 struct e1000_nvm_info *nvm = &hw->nvm;
1203 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
1204 u32 act_offset;
1205 s32 ret_val;
Bruce Allanf4187b52008-08-26 18:36:50 -07001206 u32 bank = 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001207 u16 i, word;
1208
1209 if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
1210 (words == 0)) {
1211 hw_dbg(hw, "nvm parameter(s) out of bounds\n");
1212 return -E1000_ERR_NVM;
1213 }
1214
1215 ret_val = e1000_acquire_swflag_ich8lan(hw);
1216 if (ret_val)
Bruce Allane2434552008-11-21 17:02:41 -08001217 goto out;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001218
Bruce Allanf4187b52008-08-26 18:36:50 -07001219 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
1220 if (ret_val)
Bruce Allane2434552008-11-21 17:02:41 -08001221 goto release;
Bruce Allanf4187b52008-08-26 18:36:50 -07001222
1223 act_offset = (bank) ? nvm->flash_bank_size : 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001224 act_offset += offset;
1225
1226 for (i = 0; i < words; i++) {
1227 if ((dev_spec->shadow_ram) &&
1228 (dev_spec->shadow_ram[offset+i].modified)) {
1229 data[i] = dev_spec->shadow_ram[offset+i].value;
1230 } else {
1231 ret_val = e1000_read_flash_word_ich8lan(hw,
1232 act_offset + i,
1233 &word);
1234 if (ret_val)
1235 break;
1236 data[i] = word;
1237 }
1238 }
1239
Bruce Allane2434552008-11-21 17:02:41 -08001240release:
Auke Kokbc7f75f2007-09-17 12:30:59 -07001241 e1000_release_swflag_ich8lan(hw);
1242
Bruce Allane2434552008-11-21 17:02:41 -08001243out:
1244 if (ret_val)
1245 hw_dbg(hw, "NVM read error: %d\n", ret_val);
1246
Auke Kokbc7f75f2007-09-17 12:30:59 -07001247 return ret_val;
1248}
1249
1250/**
1251 * e1000_flash_cycle_init_ich8lan - Initialize flash
1252 * @hw: pointer to the HW structure
1253 *
1254 * This function does initial flash setup so that a new read/write/erase cycle
1255 * can be started.
1256 **/
1257static s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw)
1258{
1259 union ich8_hws_flash_status hsfsts;
1260 s32 ret_val = -E1000_ERR_NVM;
1261 s32 i = 0;
1262
1263 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
1264
1265 /* Check if the flash descriptor is valid */
1266 if (hsfsts.hsf_status.fldesvalid == 0) {
1267 hw_dbg(hw, "Flash descriptor invalid. "
1268 "SW Sequencing must be used.");
1269 return -E1000_ERR_NVM;
1270 }
1271
1272 /* Clear FCERR and DAEL in hw status by writing 1 */
1273 hsfsts.hsf_status.flcerr = 1;
1274 hsfsts.hsf_status.dael = 1;
1275
1276 ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
1277
Bruce Allanad680762008-03-28 09:15:03 -07001278 /*
1279 * Either we should have a hardware SPI cycle in progress
Auke Kokbc7f75f2007-09-17 12:30:59 -07001280 * bit to check against, in order to start a new cycle or
1281 * FDONE bit should be changed in the hardware so that it
Auke Kok489815c2008-02-21 15:11:07 -08001282 * is 1 after hardware reset, which can then be used as an
Auke Kokbc7f75f2007-09-17 12:30:59 -07001283 * indication whether a cycle is in progress or has been
1284 * completed.
1285 */
1286
1287 if (hsfsts.hsf_status.flcinprog == 0) {
Bruce Allanad680762008-03-28 09:15:03 -07001288 /*
1289 * There is no cycle running at present,
1290 * so we can start a cycle
1291 * Begin by setting Flash Cycle Done.
1292 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07001293 hsfsts.hsf_status.flcdone = 1;
1294 ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
1295 ret_val = 0;
1296 } else {
Bruce Allanad680762008-03-28 09:15:03 -07001297 /*
1298 * otherwise poll for sometime so the current
1299 * cycle has a chance to end before giving up.
1300 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07001301 for (i = 0; i < ICH_FLASH_READ_COMMAND_TIMEOUT; i++) {
1302 hsfsts.regval = __er16flash(hw, ICH_FLASH_HSFSTS);
1303 if (hsfsts.hsf_status.flcinprog == 0) {
1304 ret_val = 0;
1305 break;
1306 }
1307 udelay(1);
1308 }
1309 if (ret_val == 0) {
Bruce Allanad680762008-03-28 09:15:03 -07001310 /*
1311 * Successful in waiting for previous cycle to timeout,
1312 * now set the Flash Cycle Done.
1313 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07001314 hsfsts.hsf_status.flcdone = 1;
1315 ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
1316 } else {
1317 hw_dbg(hw, "Flash controller busy, cannot get access");
1318 }
1319 }
1320
1321 return ret_val;
1322}
1323
1324/**
1325 * e1000_flash_cycle_ich8lan - Starts flash cycle (read/write/erase)
1326 * @hw: pointer to the HW structure
1327 * @timeout: maximum time to wait for completion
1328 *
1329 * This function starts a flash cycle and waits for its completion.
1330 **/
1331static s32 e1000_flash_cycle_ich8lan(struct e1000_hw *hw, u32 timeout)
1332{
1333 union ich8_hws_flash_ctrl hsflctl;
1334 union ich8_hws_flash_status hsfsts;
1335 s32 ret_val = -E1000_ERR_NVM;
1336 u32 i = 0;
1337
1338 /* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */
1339 hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
1340 hsflctl.hsf_ctrl.flcgo = 1;
1341 ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
1342
1343 /* wait till FDONE bit is set to 1 */
1344 do {
1345 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
1346 if (hsfsts.hsf_status.flcdone == 1)
1347 break;
1348 udelay(1);
1349 } while (i++ < timeout);
1350
1351 if (hsfsts.hsf_status.flcdone == 1 && hsfsts.hsf_status.flcerr == 0)
1352 return 0;
1353
1354 return ret_val;
1355}
1356
1357/**
1358 * e1000_read_flash_word_ich8lan - Read word from flash
1359 * @hw: pointer to the HW structure
1360 * @offset: offset to data location
1361 * @data: pointer to the location for storing the data
1362 *
1363 * Reads the flash word at offset into data. Offset is converted
1364 * to bytes before read.
1365 **/
1366static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset,
1367 u16 *data)
1368{
1369 /* Must convert offset into bytes. */
1370 offset <<= 1;
1371
1372 return e1000_read_flash_data_ich8lan(hw, offset, 2, data);
1373}
1374
1375/**
Bruce Allanf4187b52008-08-26 18:36:50 -07001376 * e1000_read_flash_byte_ich8lan - Read byte from flash
1377 * @hw: pointer to the HW structure
1378 * @offset: The offset of the byte to read.
1379 * @data: Pointer to a byte to store the value read.
1380 *
1381 * Reads a single byte from the NVM using the flash access registers.
1382 **/
1383static s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
1384 u8 *data)
1385{
1386 s32 ret_val;
1387 u16 word = 0;
1388
1389 ret_val = e1000_read_flash_data_ich8lan(hw, offset, 1, &word);
1390 if (ret_val)
1391 return ret_val;
1392
1393 *data = (u8)word;
1394
1395 return 0;
1396}
1397
1398/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07001399 * e1000_read_flash_data_ich8lan - Read byte or word from NVM
1400 * @hw: pointer to the HW structure
1401 * @offset: The offset (in bytes) of the byte or word to read.
1402 * @size: Size of data to read, 1=byte 2=word
1403 * @data: Pointer to the word to store the value read.
1404 *
1405 * Reads a byte or word from the NVM using the flash access registers.
1406 **/
1407static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
1408 u8 size, u16 *data)
1409{
1410 union ich8_hws_flash_status hsfsts;
1411 union ich8_hws_flash_ctrl hsflctl;
1412 u32 flash_linear_addr;
1413 u32 flash_data = 0;
1414 s32 ret_val = -E1000_ERR_NVM;
1415 u8 count = 0;
1416
1417 if (size < 1 || size > 2 || offset > ICH_FLASH_LINEAR_ADDR_MASK)
1418 return -E1000_ERR_NVM;
1419
1420 flash_linear_addr = (ICH_FLASH_LINEAR_ADDR_MASK & offset) +
1421 hw->nvm.flash_base_addr;
1422
1423 do {
1424 udelay(1);
1425 /* Steps */
1426 ret_val = e1000_flash_cycle_init_ich8lan(hw);
1427 if (ret_val != 0)
1428 break;
1429
1430 hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
1431 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
1432 hsflctl.hsf_ctrl.fldbcount = size - 1;
1433 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_READ;
1434 ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
1435
1436 ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
1437
1438 ret_val = e1000_flash_cycle_ich8lan(hw,
1439 ICH_FLASH_READ_COMMAND_TIMEOUT);
1440
Bruce Allanad680762008-03-28 09:15:03 -07001441 /*
1442 * Check if FCERR is set to 1, if set to 1, clear it
Auke Kokbc7f75f2007-09-17 12:30:59 -07001443 * and try the whole sequence a few more times, else
1444 * read in (shift in) the Flash Data0, the order is
Bruce Allanad680762008-03-28 09:15:03 -07001445 * least significant byte first msb to lsb
1446 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07001447 if (ret_val == 0) {
1448 flash_data = er32flash(ICH_FLASH_FDATA0);
1449 if (size == 1) {
1450 *data = (u8)(flash_data & 0x000000FF);
1451 } else if (size == 2) {
1452 *data = (u16)(flash_data & 0x0000FFFF);
1453 }
1454 break;
1455 } else {
Bruce Allanad680762008-03-28 09:15:03 -07001456 /*
1457 * If we've gotten here, then things are probably
Auke Kokbc7f75f2007-09-17 12:30:59 -07001458 * completely hosed, but if the error condition is
1459 * detected, it won't hurt to give it another try...
1460 * ICH_FLASH_CYCLE_REPEAT_COUNT times.
1461 */
1462 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
1463 if (hsfsts.hsf_status.flcerr == 1) {
1464 /* Repeat for some time before giving up. */
1465 continue;
1466 } else if (hsfsts.hsf_status.flcdone == 0) {
1467 hw_dbg(hw, "Timeout error - flash cycle "
1468 "did not complete.");
1469 break;
1470 }
1471 }
1472 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
1473
1474 return ret_val;
1475}
1476
1477/**
1478 * e1000_write_nvm_ich8lan - Write word(s) to the NVM
1479 * @hw: pointer to the HW structure
1480 * @offset: The offset (in bytes) of the word(s) to write.
1481 * @words: Size of data to write in words
1482 * @data: Pointer to the word(s) to write at offset.
1483 *
1484 * Writes a byte or word to the NVM using the flash access registers.
1485 **/
1486static s32 e1000_write_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
1487 u16 *data)
1488{
1489 struct e1000_nvm_info *nvm = &hw->nvm;
1490 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
1491 s32 ret_val;
1492 u16 i;
1493
1494 if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
1495 (words == 0)) {
1496 hw_dbg(hw, "nvm parameter(s) out of bounds\n");
1497 return -E1000_ERR_NVM;
1498 }
1499
1500 ret_val = e1000_acquire_swflag_ich8lan(hw);
1501 if (ret_val)
1502 return ret_val;
1503
1504 for (i = 0; i < words; i++) {
1505 dev_spec->shadow_ram[offset+i].modified = 1;
1506 dev_spec->shadow_ram[offset+i].value = data[i];
1507 }
1508
1509 e1000_release_swflag_ich8lan(hw);
1510
1511 return 0;
1512}
1513
1514/**
1515 * e1000_update_nvm_checksum_ich8lan - Update the checksum for NVM
1516 * @hw: pointer to the HW structure
1517 *
1518 * The NVM checksum is updated by calling the generic update_nvm_checksum,
1519 * which writes the checksum to the shadow ram. The changes in the shadow
1520 * ram are then committed to the EEPROM by processing each bank at a time
1521 * checking for the modified bit and writing only the pending changes.
Auke Kok489815c2008-02-21 15:11:07 -08001522 * After a successful commit, the shadow ram is cleared and is ready for
Auke Kokbc7f75f2007-09-17 12:30:59 -07001523 * future writes.
1524 **/
1525static s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw)
1526{
1527 struct e1000_nvm_info *nvm = &hw->nvm;
1528 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
Bruce Allanf4187b52008-08-26 18:36:50 -07001529 u32 i, act_offset, new_bank_offset, old_bank_offset, bank;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001530 s32 ret_val;
1531 u16 data;
1532
1533 ret_val = e1000e_update_nvm_checksum_generic(hw);
1534 if (ret_val)
Bruce Allane2434552008-11-21 17:02:41 -08001535 goto out;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001536
1537 if (nvm->type != e1000_nvm_flash_sw)
Bruce Allane2434552008-11-21 17:02:41 -08001538 goto out;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001539
1540 ret_val = e1000_acquire_swflag_ich8lan(hw);
1541 if (ret_val)
Bruce Allane2434552008-11-21 17:02:41 -08001542 goto out;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001543
Bruce Allanad680762008-03-28 09:15:03 -07001544 /*
1545 * We're writing to the opposite bank so if we're on bank 1,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001546 * write to bank 0 etc. We also need to erase the segment that
Bruce Allanad680762008-03-28 09:15:03 -07001547 * is going to be written
1548 */
Bruce Allanf4187b52008-08-26 18:36:50 -07001549 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
Bruce Allane2434552008-11-21 17:02:41 -08001550 if (ret_val) {
1551 e1000_release_swflag_ich8lan(hw);
1552 goto out;
1553 }
Bruce Allanf4187b52008-08-26 18:36:50 -07001554
1555 if (bank == 0) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07001556 new_bank_offset = nvm->flash_bank_size;
1557 old_bank_offset = 0;
Bruce Allane2434552008-11-21 17:02:41 -08001558 ret_val = e1000_erase_flash_bank_ich8lan(hw, 1);
1559 if (ret_val) {
1560 e1000_release_swflag_ich8lan(hw);
1561 goto out;
1562 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07001563 } else {
1564 old_bank_offset = nvm->flash_bank_size;
1565 new_bank_offset = 0;
Bruce Allane2434552008-11-21 17:02:41 -08001566 ret_val = e1000_erase_flash_bank_ich8lan(hw, 0);
1567 if (ret_val) {
1568 e1000_release_swflag_ich8lan(hw);
1569 goto out;
1570 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07001571 }
1572
1573 for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i++) {
Bruce Allanad680762008-03-28 09:15:03 -07001574 /*
1575 * Determine whether to write the value stored
Auke Kokbc7f75f2007-09-17 12:30:59 -07001576 * in the other NVM bank or a modified value stored
Bruce Allanad680762008-03-28 09:15:03 -07001577 * in the shadow RAM
1578 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07001579 if (dev_spec->shadow_ram[i].modified) {
1580 data = dev_spec->shadow_ram[i].value;
1581 } else {
Bruce Allane2434552008-11-21 17:02:41 -08001582 ret_val = e1000_read_flash_word_ich8lan(hw, i +
1583 old_bank_offset,
1584 &data);
1585 if (ret_val)
1586 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001587 }
1588
Bruce Allanad680762008-03-28 09:15:03 -07001589 /*
1590 * If the word is 0x13, then make sure the signature bits
Auke Kokbc7f75f2007-09-17 12:30:59 -07001591 * (15:14) are 11b until the commit has completed.
1592 * This will allow us to write 10b which indicates the
1593 * signature is valid. We want to do this after the write
1594 * has completed so that we don't mark the segment valid
Bruce Allanad680762008-03-28 09:15:03 -07001595 * while the write is still in progress
1596 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07001597 if (i == E1000_ICH_NVM_SIG_WORD)
1598 data |= E1000_ICH_NVM_SIG_MASK;
1599
1600 /* Convert offset to bytes. */
1601 act_offset = (i + new_bank_offset) << 1;
1602
1603 udelay(100);
1604 /* Write the bytes to the new bank. */
1605 ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
1606 act_offset,
1607 (u8)data);
1608 if (ret_val)
1609 break;
1610
1611 udelay(100);
1612 ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
1613 act_offset + 1,
1614 (u8)(data >> 8));
1615 if (ret_val)
1616 break;
1617 }
1618
Bruce Allanad680762008-03-28 09:15:03 -07001619 /*
1620 * Don't bother writing the segment valid bits if sector
1621 * programming failed.
1622 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07001623 if (ret_val) {
Bruce Allan4a770352008-10-01 17:18:35 -07001624 /* Possibly read-only, see e1000e_write_protect_nvm_ich8lan() */
Auke Kokbc7f75f2007-09-17 12:30:59 -07001625 hw_dbg(hw, "Flash commit failed.\n");
1626 e1000_release_swflag_ich8lan(hw);
Bruce Allane2434552008-11-21 17:02:41 -08001627 goto out;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001628 }
1629
Bruce Allanad680762008-03-28 09:15:03 -07001630 /*
1631 * Finally validate the new segment by setting bit 15:14
Auke Kokbc7f75f2007-09-17 12:30:59 -07001632 * to 10b in word 0x13 , this can be done without an
1633 * erase as well since these bits are 11 to start with
Bruce Allanad680762008-03-28 09:15:03 -07001634 * and we need to change bit 14 to 0b
1635 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07001636 act_offset = new_bank_offset + E1000_ICH_NVM_SIG_WORD;
Bruce Allane2434552008-11-21 17:02:41 -08001637 ret_val = e1000_read_flash_word_ich8lan(hw, act_offset, &data);
1638 if (ret_val) {
1639 e1000_release_swflag_ich8lan(hw);
1640 goto out;
1641 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07001642 data &= 0xBFFF;
1643 ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
1644 act_offset * 2 + 1,
1645 (u8)(data >> 8));
1646 if (ret_val) {
1647 e1000_release_swflag_ich8lan(hw);
Bruce Allane2434552008-11-21 17:02:41 -08001648 goto out;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001649 }
1650
Bruce Allanad680762008-03-28 09:15:03 -07001651 /*
1652 * And invalidate the previously valid segment by setting
Auke Kokbc7f75f2007-09-17 12:30:59 -07001653 * its signature word (0x13) high_byte to 0b. This can be
1654 * done without an erase because flash erase sets all bits
Bruce Allanad680762008-03-28 09:15:03 -07001655 * to 1's. We can write 1's to 0's without an erase
1656 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07001657 act_offset = (old_bank_offset + E1000_ICH_NVM_SIG_WORD) * 2 + 1;
1658 ret_val = e1000_retry_write_flash_byte_ich8lan(hw, act_offset, 0);
1659 if (ret_val) {
1660 e1000_release_swflag_ich8lan(hw);
Bruce Allane2434552008-11-21 17:02:41 -08001661 goto out;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001662 }
1663
1664 /* Great! Everything worked, we can now clear the cached entries. */
1665 for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i++) {
1666 dev_spec->shadow_ram[i].modified = 0;
1667 dev_spec->shadow_ram[i].value = 0xFFFF;
1668 }
1669
1670 e1000_release_swflag_ich8lan(hw);
1671
Bruce Allanad680762008-03-28 09:15:03 -07001672 /*
1673 * Reload the EEPROM, or else modifications will not appear
Auke Kokbc7f75f2007-09-17 12:30:59 -07001674 * until after the next adapter reset.
1675 */
1676 e1000e_reload_nvm(hw);
1677 msleep(10);
1678
Bruce Allane2434552008-11-21 17:02:41 -08001679out:
1680 if (ret_val)
1681 hw_dbg(hw, "NVM update error: %d\n", ret_val);
1682
Auke Kokbc7f75f2007-09-17 12:30:59 -07001683 return ret_val;
1684}
1685
1686/**
1687 * e1000_validate_nvm_checksum_ich8lan - Validate EEPROM checksum
1688 * @hw: pointer to the HW structure
1689 *
1690 * Check to see if checksum needs to be fixed by reading bit 6 in word 0x19.
1691 * If the bit is 0, that the EEPROM had been modified, but the checksum was not
1692 * calculated, in which case we need to calculate the checksum and set bit 6.
1693 **/
1694static s32 e1000_validate_nvm_checksum_ich8lan(struct e1000_hw *hw)
1695{
1696 s32 ret_val;
1697 u16 data;
1698
Bruce Allanad680762008-03-28 09:15:03 -07001699 /*
1700 * Read 0x19 and check bit 6. If this bit is 0, the checksum
Auke Kokbc7f75f2007-09-17 12:30:59 -07001701 * needs to be fixed. This bit is an indication that the NVM
1702 * was prepared by OEM software and did not calculate the
1703 * checksum...a likely scenario.
1704 */
1705 ret_val = e1000_read_nvm(hw, 0x19, 1, &data);
1706 if (ret_val)
1707 return ret_val;
1708
1709 if ((data & 0x40) == 0) {
1710 data |= 0x40;
1711 ret_val = e1000_write_nvm(hw, 0x19, 1, &data);
1712 if (ret_val)
1713 return ret_val;
1714 ret_val = e1000e_update_nvm_checksum(hw);
1715 if (ret_val)
1716 return ret_val;
1717 }
1718
1719 return e1000e_validate_nvm_checksum_generic(hw);
1720}
1721
1722/**
Bruce Allan4a770352008-10-01 17:18:35 -07001723 * e1000e_write_protect_nvm_ich8lan - Make the NVM read-only
1724 * @hw: pointer to the HW structure
1725 *
1726 * To prevent malicious write/erase of the NVM, set it to be read-only
1727 * so that the hardware ignores all write/erase cycles of the NVM via
1728 * the flash control registers. The shadow-ram copy of the NVM will
1729 * still be updated, however any updates to this copy will not stick
1730 * across driver reloads.
1731 **/
1732void e1000e_write_protect_nvm_ich8lan(struct e1000_hw *hw)
1733{
1734 union ich8_flash_protected_range pr0;
1735 union ich8_hws_flash_status hsfsts;
1736 u32 gfpreg;
1737 s32 ret_val;
1738
1739 ret_val = e1000_acquire_swflag_ich8lan(hw);
1740 if (ret_val)
1741 return;
1742
1743 gfpreg = er32flash(ICH_FLASH_GFPREG);
1744
1745 /* Write-protect GbE Sector of NVM */
1746 pr0.regval = er32flash(ICH_FLASH_PR0);
1747 pr0.range.base = gfpreg & FLASH_GFPREG_BASE_MASK;
1748 pr0.range.limit = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK);
1749 pr0.range.wpe = true;
1750 ew32flash(ICH_FLASH_PR0, pr0.regval);
1751
1752 /*
1753 * Lock down a subset of GbE Flash Control Registers, e.g.
1754 * PR0 to prevent the write-protection from being lifted.
1755 * Once FLOCKDN is set, the registers protected by it cannot
1756 * be written until FLOCKDN is cleared by a hardware reset.
1757 */
1758 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
1759 hsfsts.hsf_status.flockdn = true;
1760 ew32flash(ICH_FLASH_HSFSTS, hsfsts.regval);
1761
1762 e1000_release_swflag_ich8lan(hw);
1763}
1764
1765/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07001766 * e1000_write_flash_data_ich8lan - Writes bytes to the NVM
1767 * @hw: pointer to the HW structure
1768 * @offset: The offset (in bytes) of the byte/word to read.
1769 * @size: Size of data to read, 1=byte 2=word
1770 * @data: The byte(s) to write to the NVM.
1771 *
1772 * Writes one/two bytes to the NVM using the flash access registers.
1773 **/
1774static s32 e1000_write_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
1775 u8 size, u16 data)
1776{
1777 union ich8_hws_flash_status hsfsts;
1778 union ich8_hws_flash_ctrl hsflctl;
1779 u32 flash_linear_addr;
1780 u32 flash_data = 0;
1781 s32 ret_val;
1782 u8 count = 0;
1783
1784 if (size < 1 || size > 2 || data > size * 0xff ||
1785 offset > ICH_FLASH_LINEAR_ADDR_MASK)
1786 return -E1000_ERR_NVM;
1787
1788 flash_linear_addr = (ICH_FLASH_LINEAR_ADDR_MASK & offset) +
1789 hw->nvm.flash_base_addr;
1790
1791 do {
1792 udelay(1);
1793 /* Steps */
1794 ret_val = e1000_flash_cycle_init_ich8lan(hw);
1795 if (ret_val)
1796 break;
1797
1798 hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
1799 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
1800 hsflctl.hsf_ctrl.fldbcount = size -1;
1801 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_WRITE;
1802 ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
1803
1804 ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
1805
1806 if (size == 1)
1807 flash_data = (u32)data & 0x00FF;
1808 else
1809 flash_data = (u32)data;
1810
1811 ew32flash(ICH_FLASH_FDATA0, flash_data);
1812
Bruce Allanad680762008-03-28 09:15:03 -07001813 /*
1814 * check if FCERR is set to 1 , if set to 1, clear it
1815 * and try the whole sequence a few more times else done
1816 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07001817 ret_val = e1000_flash_cycle_ich8lan(hw,
1818 ICH_FLASH_WRITE_COMMAND_TIMEOUT);
1819 if (!ret_val)
1820 break;
1821
Bruce Allanad680762008-03-28 09:15:03 -07001822 /*
1823 * If we're here, then things are most likely
Auke Kokbc7f75f2007-09-17 12:30:59 -07001824 * completely hosed, but if the error condition
1825 * is detected, it won't hurt to give it another
1826 * try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
1827 */
1828 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
1829 if (hsfsts.hsf_status.flcerr == 1)
1830 /* Repeat for some time before giving up. */
1831 continue;
1832 if (hsfsts.hsf_status.flcdone == 0) {
1833 hw_dbg(hw, "Timeout error - flash cycle "
1834 "did not complete.");
1835 break;
1836 }
1837 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
1838
1839 return ret_val;
1840}
1841
1842/**
1843 * e1000_write_flash_byte_ich8lan - Write a single byte to NVM
1844 * @hw: pointer to the HW structure
1845 * @offset: The index of the byte to read.
1846 * @data: The byte to write to the NVM.
1847 *
1848 * Writes a single byte to the NVM using the flash access registers.
1849 **/
1850static s32 e1000_write_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
1851 u8 data)
1852{
1853 u16 word = (u16)data;
1854
1855 return e1000_write_flash_data_ich8lan(hw, offset, 1, word);
1856}
1857
1858/**
1859 * e1000_retry_write_flash_byte_ich8lan - Writes a single byte to NVM
1860 * @hw: pointer to the HW structure
1861 * @offset: The offset of the byte to write.
1862 * @byte: The byte to write to the NVM.
1863 *
1864 * Writes a single byte to the NVM using the flash access registers.
1865 * Goes through a retry algorithm before giving up.
1866 **/
1867static s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw,
1868 u32 offset, u8 byte)
1869{
1870 s32 ret_val;
1871 u16 program_retries;
1872
1873 ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
1874 if (!ret_val)
1875 return ret_val;
1876
1877 for (program_retries = 0; program_retries < 100; program_retries++) {
1878 hw_dbg(hw, "Retrying Byte %2.2X at offset %u\n", byte, offset);
1879 udelay(100);
1880 ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
1881 if (!ret_val)
1882 break;
1883 }
1884 if (program_retries == 100)
1885 return -E1000_ERR_NVM;
1886
1887 return 0;
1888}
1889
1890/**
1891 * e1000_erase_flash_bank_ich8lan - Erase a bank (4k) from NVM
1892 * @hw: pointer to the HW structure
1893 * @bank: 0 for first bank, 1 for second bank, etc.
1894 *
1895 * Erases the bank specified. Each bank is a 4k block. Banks are 0 based.
1896 * bank N is 4096 * N + flash_reg_addr.
1897 **/
1898static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank)
1899{
1900 struct e1000_nvm_info *nvm = &hw->nvm;
1901 union ich8_hws_flash_status hsfsts;
1902 union ich8_hws_flash_ctrl hsflctl;
1903 u32 flash_linear_addr;
1904 /* bank size is in 16bit words - adjust to bytes */
1905 u32 flash_bank_size = nvm->flash_bank_size * 2;
1906 s32 ret_val;
1907 s32 count = 0;
1908 s32 iteration;
1909 s32 sector_size;
1910 s32 j;
1911
1912 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
1913
Bruce Allanad680762008-03-28 09:15:03 -07001914 /*
1915 * Determine HW Sector size: Read BERASE bits of hw flash status
1916 * register
1917 * 00: The Hw sector is 256 bytes, hence we need to erase 16
Auke Kokbc7f75f2007-09-17 12:30:59 -07001918 * consecutive sectors. The start index for the nth Hw sector
1919 * can be calculated as = bank * 4096 + n * 256
1920 * 01: The Hw sector is 4K bytes, hence we need to erase 1 sector.
1921 * The start index for the nth Hw sector can be calculated
1922 * as = bank * 4096
1923 * 10: The Hw sector is 8K bytes, nth sector = bank * 8192
1924 * (ich9 only, otherwise error condition)
1925 * 11: The Hw sector is 64K bytes, nth sector = bank * 65536
1926 */
1927 switch (hsfsts.hsf_status.berasesz) {
1928 case 0:
1929 /* Hw sector size 256 */
1930 sector_size = ICH_FLASH_SEG_SIZE_256;
1931 iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_256;
1932 break;
1933 case 1:
1934 sector_size = ICH_FLASH_SEG_SIZE_4K;
1935 iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_4K;
1936 break;
1937 case 2:
1938 if (hw->mac.type == e1000_ich9lan) {
1939 sector_size = ICH_FLASH_SEG_SIZE_8K;
1940 iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_8K;
1941 } else {
1942 return -E1000_ERR_NVM;
1943 }
1944 break;
1945 case 3:
1946 sector_size = ICH_FLASH_SEG_SIZE_64K;
1947 iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_64K;
1948 break;
1949 default:
1950 return -E1000_ERR_NVM;
1951 }
1952
1953 /* Start with the base address, then add the sector offset. */
1954 flash_linear_addr = hw->nvm.flash_base_addr;
1955 flash_linear_addr += (bank) ? (sector_size * iteration) : 0;
1956
1957 for (j = 0; j < iteration ; j++) {
1958 do {
1959 /* Steps */
1960 ret_val = e1000_flash_cycle_init_ich8lan(hw);
1961 if (ret_val)
1962 return ret_val;
1963
Bruce Allanad680762008-03-28 09:15:03 -07001964 /*
1965 * Write a value 11 (block Erase) in Flash
1966 * Cycle field in hw flash control
1967 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07001968 hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
1969 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_ERASE;
1970 ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
1971
Bruce Allanad680762008-03-28 09:15:03 -07001972 /*
1973 * Write the last 24 bits of an index within the
Auke Kokbc7f75f2007-09-17 12:30:59 -07001974 * block into Flash Linear address field in Flash
1975 * Address.
1976 */
1977 flash_linear_addr += (j * sector_size);
1978 ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
1979
1980 ret_val = e1000_flash_cycle_ich8lan(hw,
1981 ICH_FLASH_ERASE_COMMAND_TIMEOUT);
1982 if (ret_val == 0)
1983 break;
1984
Bruce Allanad680762008-03-28 09:15:03 -07001985 /*
1986 * Check if FCERR is set to 1. If 1,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001987 * clear it and try the whole sequence
Bruce Allanad680762008-03-28 09:15:03 -07001988 * a few more times else Done
1989 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07001990 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
1991 if (hsfsts.hsf_status.flcerr == 1)
Bruce Allanad680762008-03-28 09:15:03 -07001992 /* repeat for some time before giving up */
Auke Kokbc7f75f2007-09-17 12:30:59 -07001993 continue;
1994 else if (hsfsts.hsf_status.flcdone == 0)
1995 return ret_val;
1996 } while (++count < ICH_FLASH_CYCLE_REPEAT_COUNT);
1997 }
1998
1999 return 0;
2000}
2001
2002/**
2003 * e1000_valid_led_default_ich8lan - Set the default LED settings
2004 * @hw: pointer to the HW structure
2005 * @data: Pointer to the LED settings
2006 *
2007 * Reads the LED default settings from the NVM to data. If the NVM LED
2008 * settings is all 0's or F's, set the LED default to a valid LED default
2009 * setting.
2010 **/
2011static s32 e1000_valid_led_default_ich8lan(struct e1000_hw *hw, u16 *data)
2012{
2013 s32 ret_val;
2014
2015 ret_val = e1000_read_nvm(hw, NVM_ID_LED_SETTINGS, 1, data);
2016 if (ret_val) {
2017 hw_dbg(hw, "NVM Read Error\n");
2018 return ret_val;
2019 }
2020
2021 if (*data == ID_LED_RESERVED_0000 ||
2022 *data == ID_LED_RESERVED_FFFF)
2023 *data = ID_LED_DEFAULT_ICH8LAN;
2024
2025 return 0;
2026}
2027
2028/**
Bruce Allana4f58f52009-06-02 11:29:18 +00002029 * e1000_id_led_init_pchlan - store LED configurations
2030 * @hw: pointer to the HW structure
2031 *
2032 * PCH does not control LEDs via the LEDCTL register, rather it uses
2033 * the PHY LED configuration register.
2034 *
2035 * PCH also does not have an "always on" or "always off" mode which
2036 * complicates the ID feature. Instead of using the "on" mode to indicate
2037 * in ledctl_mode2 the LEDs to use for ID (see e1000e_id_led_init()),
2038 * use "link_up" mode. The LEDs will still ID on request if there is no
2039 * link based on logic in e1000_led_[on|off]_pchlan().
2040 **/
2041static s32 e1000_id_led_init_pchlan(struct e1000_hw *hw)
2042{
2043 struct e1000_mac_info *mac = &hw->mac;
2044 s32 ret_val;
2045 const u32 ledctl_on = E1000_LEDCTL_MODE_LINK_UP;
2046 const u32 ledctl_off = E1000_LEDCTL_MODE_LINK_UP | E1000_PHY_LED0_IVRT;
2047 u16 data, i, temp, shift;
2048
2049 /* Get default ID LED modes */
2050 ret_val = hw->nvm.ops.valid_led_default(hw, &data);
2051 if (ret_val)
2052 goto out;
2053
2054 mac->ledctl_default = er32(LEDCTL);
2055 mac->ledctl_mode1 = mac->ledctl_default;
2056 mac->ledctl_mode2 = mac->ledctl_default;
2057
2058 for (i = 0; i < 4; i++) {
2059 temp = (data >> (i << 2)) & E1000_LEDCTL_LED0_MODE_MASK;
2060 shift = (i * 5);
2061 switch (temp) {
2062 case ID_LED_ON1_DEF2:
2063 case ID_LED_ON1_ON2:
2064 case ID_LED_ON1_OFF2:
2065 mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
2066 mac->ledctl_mode1 |= (ledctl_on << shift);
2067 break;
2068 case ID_LED_OFF1_DEF2:
2069 case ID_LED_OFF1_ON2:
2070 case ID_LED_OFF1_OFF2:
2071 mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
2072 mac->ledctl_mode1 |= (ledctl_off << shift);
2073 break;
2074 default:
2075 /* Do nothing */
2076 break;
2077 }
2078 switch (temp) {
2079 case ID_LED_DEF1_ON2:
2080 case ID_LED_ON1_ON2:
2081 case ID_LED_OFF1_ON2:
2082 mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
2083 mac->ledctl_mode2 |= (ledctl_on << shift);
2084 break;
2085 case ID_LED_DEF1_OFF2:
2086 case ID_LED_ON1_OFF2:
2087 case ID_LED_OFF1_OFF2:
2088 mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
2089 mac->ledctl_mode2 |= (ledctl_off << shift);
2090 break;
2091 default:
2092 /* Do nothing */
2093 break;
2094 }
2095 }
2096
2097out:
2098 return ret_val;
2099}
2100
2101/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07002102 * e1000_get_bus_info_ich8lan - Get/Set the bus type and width
2103 * @hw: pointer to the HW structure
2104 *
2105 * ICH8 use the PCI Express bus, but does not contain a PCI Express Capability
2106 * register, so the the bus width is hard coded.
2107 **/
2108static s32 e1000_get_bus_info_ich8lan(struct e1000_hw *hw)
2109{
2110 struct e1000_bus_info *bus = &hw->bus;
2111 s32 ret_val;
2112
2113 ret_val = e1000e_get_bus_info_pcie(hw);
2114
Bruce Allanad680762008-03-28 09:15:03 -07002115 /*
2116 * ICH devices are "PCI Express"-ish. They have
Auke Kokbc7f75f2007-09-17 12:30:59 -07002117 * a configuration space, but do not contain
2118 * PCI Express Capability registers, so bus width
2119 * must be hardcoded.
2120 */
2121 if (bus->width == e1000_bus_width_unknown)
2122 bus->width = e1000_bus_width_pcie_x1;
2123
2124 return ret_val;
2125}
2126
2127/**
2128 * e1000_reset_hw_ich8lan - Reset the hardware
2129 * @hw: pointer to the HW structure
2130 *
2131 * Does a full reset of the hardware which includes a reset of the PHY and
2132 * MAC.
2133 **/
2134static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
2135{
2136 u32 ctrl, icr, kab;
2137 s32 ret_val;
2138
Bruce Allanad680762008-03-28 09:15:03 -07002139 /*
2140 * Prevent the PCI-E bus from sticking if there is no TLP connection
Auke Kokbc7f75f2007-09-17 12:30:59 -07002141 * on the last TLP read/write transaction when MAC is reset.
2142 */
2143 ret_val = e1000e_disable_pcie_master(hw);
2144 if (ret_val) {
2145 hw_dbg(hw, "PCI-E Master disable polling has failed.\n");
2146 }
2147
2148 hw_dbg(hw, "Masking off all interrupts\n");
2149 ew32(IMC, 0xffffffff);
2150
Bruce Allanad680762008-03-28 09:15:03 -07002151 /*
2152 * Disable the Transmit and Receive units. Then delay to allow
Auke Kokbc7f75f2007-09-17 12:30:59 -07002153 * any pending transactions to complete before we hit the MAC
2154 * with the global reset.
2155 */
2156 ew32(RCTL, 0);
2157 ew32(TCTL, E1000_TCTL_PSP);
2158 e1e_flush();
2159
2160 msleep(10);
2161
2162 /* Workaround for ICH8 bit corruption issue in FIFO memory */
2163 if (hw->mac.type == e1000_ich8lan) {
2164 /* Set Tx and Rx buffer allocation to 8k apiece. */
2165 ew32(PBA, E1000_PBA_8K);
2166 /* Set Packet Buffer Size to 16k. */
2167 ew32(PBS, E1000_PBS_16K);
2168 }
2169
2170 ctrl = er32(CTRL);
2171
2172 if (!e1000_check_reset_block(hw)) {
Bruce Allanfc0c7762009-07-01 13:27:55 +00002173 /* Clear PHY Reset Asserted bit */
2174 if (hw->mac.type >= e1000_pchlan) {
2175 u32 status = er32(STATUS);
2176 ew32(STATUS, status & ~E1000_STATUS_PHYRA);
2177 }
2178
Bruce Allanad680762008-03-28 09:15:03 -07002179 /*
2180 * PHY HW reset requires MAC CORE reset at the same
Auke Kokbc7f75f2007-09-17 12:30:59 -07002181 * time to make sure the interface between MAC and the
2182 * external PHY is reset.
2183 */
2184 ctrl |= E1000_CTRL_PHY_RST;
2185 }
2186 ret_val = e1000_acquire_swflag_ich8lan(hw);
Jeff Kirsher30bb0e02008-12-11 21:28:11 -08002187 /* Whether or not the swflag was acquired, we need to reset the part */
Bruce Allan0285c8d2008-11-21 16:59:54 -08002188 hw_dbg(hw, "Issuing a global reset to ich8lan\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07002189 ew32(CTRL, (ctrl | E1000_CTRL_RST));
2190 msleep(20);
2191
Bruce Allanfc0c7762009-07-01 13:27:55 +00002192 if (!ret_val)
Jeff Kirsher30bb0e02008-12-11 21:28:11 -08002193 e1000_release_swflag_ich8lan(hw);
Jesse Brandeburg37f40232008-10-02 16:33:20 -07002194
Bruce Allanfc0c7762009-07-01 13:27:55 +00002195 if (ctrl & E1000_CTRL_PHY_RST)
2196 ret_val = hw->phy.ops.get_cfg_done(hw);
2197
2198 if (hw->mac.type >= e1000_ich10lan) {
2199 e1000_lan_init_done_ich8lan(hw);
2200 } else {
2201 ret_val = e1000e_get_auto_rd_done(hw);
2202 if (ret_val) {
2203 /*
2204 * When auto config read does not complete, do not
2205 * return with an error. This can happen in situations
2206 * where there is no eeprom and prevents getting link.
2207 */
2208 hw_dbg(hw, "Auto Read Done did not complete\n");
2209 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07002210 }
2211
2212 ew32(IMC, 0xffffffff);
2213 icr = er32(ICR);
2214
2215 kab = er32(KABGTXD);
2216 kab |= E1000_KABGTXD_BGSQLBIAS;
2217 ew32(KABGTXD, kab);
2218
Bruce Allana4f58f52009-06-02 11:29:18 +00002219 if (hw->mac.type == e1000_pchlan)
2220 ret_val = e1000_hv_phy_workarounds_ich8lan(hw);
2221
Auke Kokbc7f75f2007-09-17 12:30:59 -07002222 return ret_val;
2223}
2224
2225/**
2226 * e1000_init_hw_ich8lan - Initialize the hardware
2227 * @hw: pointer to the HW structure
2228 *
2229 * Prepares the hardware for transmit and receive by doing the following:
2230 * - initialize hardware bits
2231 * - initialize LED identification
2232 * - setup receive address registers
2233 * - setup flow control
Auke Kok489815c2008-02-21 15:11:07 -08002234 * - setup transmit descriptors
Auke Kokbc7f75f2007-09-17 12:30:59 -07002235 * - clear statistics
2236 **/
2237static s32 e1000_init_hw_ich8lan(struct e1000_hw *hw)
2238{
2239 struct e1000_mac_info *mac = &hw->mac;
2240 u32 ctrl_ext, txdctl, snoop;
2241 s32 ret_val;
2242 u16 i;
2243
2244 e1000_initialize_hw_bits_ich8lan(hw);
2245
2246 /* Initialize identification LED */
Bruce Allana4f58f52009-06-02 11:29:18 +00002247 ret_val = mac->ops.id_led_init(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002248 if (ret_val) {
2249 hw_dbg(hw, "Error initializing identification LED\n");
2250 return ret_val;
2251 }
2252
2253 /* Setup the receive address. */
2254 e1000e_init_rx_addrs(hw, mac->rar_entry_count);
2255
2256 /* Zero out the Multicast HASH table */
2257 hw_dbg(hw, "Zeroing the MTA\n");
2258 for (i = 0; i < mac->mta_reg_count; i++)
2259 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
2260
Bruce Allanfc0c7762009-07-01 13:27:55 +00002261 /*
2262 * The 82578 Rx buffer will stall if wakeup is enabled in host and
2263 * the ME. Reading the BM_WUC register will clear the host wakeup bit.
2264 * Reset the phy after disabling host wakeup to reset the Rx buffer.
2265 */
2266 if (hw->phy.type == e1000_phy_82578) {
2267 hw->phy.ops.read_phy_reg(hw, BM_WUC, &i);
2268 ret_val = e1000_phy_hw_reset_ich8lan(hw);
2269 if (ret_val)
2270 return ret_val;
2271 }
2272
Auke Kokbc7f75f2007-09-17 12:30:59 -07002273 /* Setup link and flow control */
2274 ret_val = e1000_setup_link_ich8lan(hw);
2275
2276 /* Set the transmit descriptor write-back policy for both queues */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07002277 txdctl = er32(TXDCTL(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -07002278 txdctl = (txdctl & ~E1000_TXDCTL_WTHRESH) |
2279 E1000_TXDCTL_FULL_TX_DESC_WB;
2280 txdctl = (txdctl & ~E1000_TXDCTL_PTHRESH) |
2281 E1000_TXDCTL_MAX_TX_DESC_PREFETCH;
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07002282 ew32(TXDCTL(0), txdctl);
2283 txdctl = er32(TXDCTL(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -07002284 txdctl = (txdctl & ~E1000_TXDCTL_WTHRESH) |
2285 E1000_TXDCTL_FULL_TX_DESC_WB;
2286 txdctl = (txdctl & ~E1000_TXDCTL_PTHRESH) |
2287 E1000_TXDCTL_MAX_TX_DESC_PREFETCH;
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07002288 ew32(TXDCTL(1), txdctl);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002289
Bruce Allanad680762008-03-28 09:15:03 -07002290 /*
2291 * ICH8 has opposite polarity of no_snoop bits.
2292 * By default, we should use snoop behavior.
2293 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002294 if (mac->type == e1000_ich8lan)
2295 snoop = PCIE_ICH8_SNOOP_ALL;
2296 else
2297 snoop = (u32) ~(PCIE_NO_SNOOP_ALL);
2298 e1000e_set_pcie_no_snoop(hw, snoop);
2299
2300 ctrl_ext = er32(CTRL_EXT);
2301 ctrl_ext |= E1000_CTRL_EXT_RO_DIS;
2302 ew32(CTRL_EXT, ctrl_ext);
2303
Bruce Allanad680762008-03-28 09:15:03 -07002304 /*
2305 * Clear all of the statistics registers (clear on read). It is
Auke Kokbc7f75f2007-09-17 12:30:59 -07002306 * important that we do this after we have tried to establish link
2307 * because the symbol error count will increment wildly if there
2308 * is no link.
2309 */
2310 e1000_clear_hw_cntrs_ich8lan(hw);
2311
2312 return 0;
2313}
2314/**
2315 * e1000_initialize_hw_bits_ich8lan - Initialize required hardware bits
2316 * @hw: pointer to the HW structure
2317 *
2318 * Sets/Clears required hardware bits necessary for correctly setting up the
2319 * hardware for transmit and receive.
2320 **/
2321static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw)
2322{
2323 u32 reg;
2324
2325 /* Extended Device Control */
2326 reg = er32(CTRL_EXT);
2327 reg |= (1 << 22);
Bruce Allana4f58f52009-06-02 11:29:18 +00002328 /* Enable PHY low-power state when MAC is at D3 w/o WoL */
2329 if (hw->mac.type >= e1000_pchlan)
2330 reg |= E1000_CTRL_EXT_PHYPDEN;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002331 ew32(CTRL_EXT, reg);
2332
2333 /* Transmit Descriptor Control 0 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07002334 reg = er32(TXDCTL(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -07002335 reg |= (1 << 22);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07002336 ew32(TXDCTL(0), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002337
2338 /* Transmit Descriptor Control 1 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07002339 reg = er32(TXDCTL(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -07002340 reg |= (1 << 22);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07002341 ew32(TXDCTL(1), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002342
2343 /* Transmit Arbitration Control 0 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07002344 reg = er32(TARC(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -07002345 if (hw->mac.type == e1000_ich8lan)
2346 reg |= (1 << 28) | (1 << 29);
2347 reg |= (1 << 23) | (1 << 24) | (1 << 26) | (1 << 27);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07002348 ew32(TARC(0), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002349
2350 /* Transmit Arbitration Control 1 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07002351 reg = er32(TARC(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -07002352 if (er32(TCTL) & E1000_TCTL_MULR)
2353 reg &= ~(1 << 28);
2354 else
2355 reg |= (1 << 28);
2356 reg |= (1 << 24) | (1 << 26) | (1 << 30);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07002357 ew32(TARC(1), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002358
2359 /* Device Status */
2360 if (hw->mac.type == e1000_ich8lan) {
2361 reg = er32(STATUS);
2362 reg &= ~(1 << 31);
2363 ew32(STATUS, reg);
2364 }
2365}
2366
2367/**
2368 * e1000_setup_link_ich8lan - Setup flow control and link settings
2369 * @hw: pointer to the HW structure
2370 *
2371 * Determines which flow control settings to use, then configures flow
2372 * control. Calls the appropriate media-specific link configuration
2373 * function. Assuming the adapter has a valid link partner, a valid link
2374 * should be established. Assumes the hardware has previously been reset
2375 * and the transmitter and receiver are not enabled.
2376 **/
2377static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw)
2378{
Auke Kokbc7f75f2007-09-17 12:30:59 -07002379 s32 ret_val;
2380
2381 if (e1000_check_reset_block(hw))
2382 return 0;
2383
Bruce Allanad680762008-03-28 09:15:03 -07002384 /*
2385 * ICH parts do not have a word in the NVM to determine
Auke Kokbc7f75f2007-09-17 12:30:59 -07002386 * the default flow control setting, so we explicitly
2387 * set it to full.
2388 */
Bruce Allan37289d92009-06-02 11:29:37 +00002389 if (hw->fc.requested_mode == e1000_fc_default) {
2390 /* Workaround h/w hang when Tx flow control enabled */
2391 if (hw->mac.type == e1000_pchlan)
2392 hw->fc.requested_mode = e1000_fc_rx_pause;
2393 else
2394 hw->fc.requested_mode = e1000_fc_full;
2395 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07002396
Bruce Allan5c48ef3e22008-11-21 16:57:36 -08002397 /*
2398 * Save off the requested flow control mode for use later. Depending
2399 * on the link partner's capabilities, we may or may not use this mode.
2400 */
2401 hw->fc.current_mode = hw->fc.requested_mode;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002402
Bruce Allan5c48ef3e22008-11-21 16:57:36 -08002403 hw_dbg(hw, "After fix-ups FlowControl is now = %x\n",
2404 hw->fc.current_mode);
Auke Kokbc7f75f2007-09-17 12:30:59 -07002405
2406 /* Continue to configure the copper link. */
2407 ret_val = e1000_setup_copper_link_ich8lan(hw);
2408 if (ret_val)
2409 return ret_val;
2410
Jeff Kirsher318a94d2008-03-28 09:15:16 -07002411 ew32(FCTTV, hw->fc.pause_time);
Bruce Allana4f58f52009-06-02 11:29:18 +00002412 if ((hw->phy.type == e1000_phy_82578) ||
2413 (hw->phy.type == e1000_phy_82577)) {
2414 ret_val = hw->phy.ops.write_phy_reg(hw,
2415 PHY_REG(BM_PORT_CTRL_PAGE, 27),
2416 hw->fc.pause_time);
2417 if (ret_val)
2418 return ret_val;
2419 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07002420
2421 return e1000e_set_fc_watermarks(hw);
2422}
2423
2424/**
2425 * e1000_setup_copper_link_ich8lan - Configure MAC/PHY interface
2426 * @hw: pointer to the HW structure
2427 *
2428 * Configures the kumeran interface to the PHY to wait the appropriate time
2429 * when polling the PHY, then call the generic setup_copper_link to finish
2430 * configuring the copper link.
2431 **/
2432static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw)
2433{
2434 u32 ctrl;
2435 s32 ret_val;
2436 u16 reg_data;
2437
2438 ctrl = er32(CTRL);
2439 ctrl |= E1000_CTRL_SLU;
2440 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
2441 ew32(CTRL, ctrl);
2442
Bruce Allanad680762008-03-28 09:15:03 -07002443 /*
2444 * Set the mac to wait the maximum time between each iteration
Auke Kokbc7f75f2007-09-17 12:30:59 -07002445 * and increase the max iterations when polling the phy;
Bruce Allanad680762008-03-28 09:15:03 -07002446 * this fixes erroneous timeouts at 10Mbps.
2447 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002448 ret_val = e1000e_write_kmrn_reg(hw, GG82563_REG(0x34, 4), 0xFFFF);
2449 if (ret_val)
2450 return ret_val;
2451 ret_val = e1000e_read_kmrn_reg(hw, GG82563_REG(0x34, 9), &reg_data);
2452 if (ret_val)
2453 return ret_val;
2454 reg_data |= 0x3F;
2455 ret_val = e1000e_write_kmrn_reg(hw, GG82563_REG(0x34, 9), reg_data);
2456 if (ret_val)
2457 return ret_val;
2458
Bruce Allana4f58f52009-06-02 11:29:18 +00002459 switch (hw->phy.type) {
2460 case e1000_phy_igp_3:
Auke Kokbc7f75f2007-09-17 12:30:59 -07002461 ret_val = e1000e_copper_link_setup_igp(hw);
2462 if (ret_val)
2463 return ret_val;
Bruce Allana4f58f52009-06-02 11:29:18 +00002464 break;
2465 case e1000_phy_bm:
2466 case e1000_phy_82578:
Bruce Allan97ac8ca2008-04-29 09:16:05 -07002467 ret_val = e1000e_copper_link_setup_m88(hw);
2468 if (ret_val)
2469 return ret_val;
Bruce Allana4f58f52009-06-02 11:29:18 +00002470 break;
2471 case e1000_phy_82577:
2472 ret_val = e1000_copper_link_setup_82577(hw);
2473 if (ret_val)
2474 return ret_val;
2475 break;
2476 case e1000_phy_ife:
2477 ret_val = hw->phy.ops.read_phy_reg(hw, IFE_PHY_MDIX_CONTROL,
2478 &reg_data);
Bruce Allan97ac8ca2008-04-29 09:16:05 -07002479 if (ret_val)
2480 return ret_val;
2481
2482 reg_data &= ~IFE_PMC_AUTO_MDIX;
2483
2484 switch (hw->phy.mdix) {
2485 case 1:
2486 reg_data &= ~IFE_PMC_FORCE_MDIX;
2487 break;
2488 case 2:
2489 reg_data |= IFE_PMC_FORCE_MDIX;
2490 break;
2491 case 0:
2492 default:
2493 reg_data |= IFE_PMC_AUTO_MDIX;
2494 break;
2495 }
Bruce Allana4f58f52009-06-02 11:29:18 +00002496 ret_val = hw->phy.ops.write_phy_reg(hw, IFE_PHY_MDIX_CONTROL,
2497 reg_data);
Bruce Allan97ac8ca2008-04-29 09:16:05 -07002498 if (ret_val)
2499 return ret_val;
Bruce Allana4f58f52009-06-02 11:29:18 +00002500 break;
2501 default:
2502 break;
Bruce Allan97ac8ca2008-04-29 09:16:05 -07002503 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07002504 return e1000e_setup_copper_link(hw);
2505}
2506
2507/**
2508 * e1000_get_link_up_info_ich8lan - Get current link speed and duplex
2509 * @hw: pointer to the HW structure
2510 * @speed: pointer to store current link speed
2511 * @duplex: pointer to store the current link duplex
2512 *
Bruce Allanad680762008-03-28 09:15:03 -07002513 * Calls the generic get_speed_and_duplex to retrieve the current link
Auke Kokbc7f75f2007-09-17 12:30:59 -07002514 * information and then calls the Kumeran lock loss workaround for links at
2515 * gigabit speeds.
2516 **/
2517static s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw, u16 *speed,
2518 u16 *duplex)
2519{
2520 s32 ret_val;
2521
2522 ret_val = e1000e_get_speed_and_duplex_copper(hw, speed, duplex);
2523 if (ret_val)
2524 return ret_val;
2525
2526 if ((hw->mac.type == e1000_ich8lan) &&
2527 (hw->phy.type == e1000_phy_igp_3) &&
2528 (*speed == SPEED_1000)) {
2529 ret_val = e1000_kmrn_lock_loss_workaround_ich8lan(hw);
2530 }
2531
2532 return ret_val;
2533}
2534
2535/**
2536 * e1000_kmrn_lock_loss_workaround_ich8lan - Kumeran workaround
2537 * @hw: pointer to the HW structure
2538 *
2539 * Work-around for 82566 Kumeran PCS lock loss:
2540 * On link status change (i.e. PCI reset, speed change) and link is up and
2541 * speed is gigabit-
2542 * 0) if workaround is optionally disabled do nothing
2543 * 1) wait 1ms for Kumeran link to come up
2544 * 2) check Kumeran Diagnostic register PCS lock loss bit
2545 * 3) if not set the link is locked (all is good), otherwise...
2546 * 4) reset the PHY
2547 * 5) repeat up to 10 times
2548 * Note: this is only called for IGP3 copper when speed is 1gb.
2549 **/
2550static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw)
2551{
2552 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
2553 u32 phy_ctrl;
2554 s32 ret_val;
2555 u16 i, data;
2556 bool link;
2557
2558 if (!dev_spec->kmrn_lock_loss_workaround_enabled)
2559 return 0;
2560
Bruce Allanad680762008-03-28 09:15:03 -07002561 /*
2562 * Make sure link is up before proceeding. If not just return.
Auke Kokbc7f75f2007-09-17 12:30:59 -07002563 * Attempting this while link is negotiating fouled up link
Bruce Allanad680762008-03-28 09:15:03 -07002564 * stability
2565 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002566 ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link);
2567 if (!link)
2568 return 0;
2569
2570 for (i = 0; i < 10; i++) {
2571 /* read once to clear */
2572 ret_val = e1e_rphy(hw, IGP3_KMRN_DIAG, &data);
2573 if (ret_val)
2574 return ret_val;
2575 /* and again to get new status */
2576 ret_val = e1e_rphy(hw, IGP3_KMRN_DIAG, &data);
2577 if (ret_val)
2578 return ret_val;
2579
2580 /* check for PCS lock */
2581 if (!(data & IGP3_KMRN_DIAG_PCS_LOCK_LOSS))
2582 return 0;
2583
2584 /* Issue PHY reset */
2585 e1000_phy_hw_reset(hw);
2586 mdelay(5);
2587 }
2588 /* Disable GigE link negotiation */
2589 phy_ctrl = er32(PHY_CTRL);
2590 phy_ctrl |= (E1000_PHY_CTRL_GBE_DISABLE |
2591 E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
2592 ew32(PHY_CTRL, phy_ctrl);
2593
Bruce Allanad680762008-03-28 09:15:03 -07002594 /*
2595 * Call gig speed drop workaround on Gig disable before accessing
2596 * any PHY registers
2597 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002598 e1000e_gig_downshift_workaround_ich8lan(hw);
2599
2600 /* unable to acquire PCS lock */
2601 return -E1000_ERR_PHY;
2602}
2603
2604/**
Bruce Allanad680762008-03-28 09:15:03 -07002605 * e1000_set_kmrn_lock_loss_workaround_ich8lan - Set Kumeran workaround state
Auke Kokbc7f75f2007-09-17 12:30:59 -07002606 * @hw: pointer to the HW structure
Auke Kok489815c2008-02-21 15:11:07 -08002607 * @state: boolean value used to set the current Kumeran workaround state
Auke Kokbc7f75f2007-09-17 12:30:59 -07002608 *
2609 * If ICH8, set the current Kumeran workaround state (enabled - TRUE
2610 * /disabled - FALSE).
2611 **/
2612void e1000e_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw,
2613 bool state)
2614{
2615 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
2616
2617 if (hw->mac.type != e1000_ich8lan) {
2618 hw_dbg(hw, "Workaround applies to ICH8 only.\n");
2619 return;
2620 }
2621
2622 dev_spec->kmrn_lock_loss_workaround_enabled = state;
2623}
2624
2625/**
2626 * e1000_ipg3_phy_powerdown_workaround_ich8lan - Power down workaround on D3
2627 * @hw: pointer to the HW structure
2628 *
2629 * Workaround for 82566 power-down on D3 entry:
2630 * 1) disable gigabit link
2631 * 2) write VR power-down enable
2632 * 3) read it back
2633 * Continue if successful, else issue LCD reset and repeat
2634 **/
2635void e1000e_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw)
2636{
2637 u32 reg;
2638 u16 data;
2639 u8 retry = 0;
2640
2641 if (hw->phy.type != e1000_phy_igp_3)
2642 return;
2643
2644 /* Try the workaround twice (if needed) */
2645 do {
2646 /* Disable link */
2647 reg = er32(PHY_CTRL);
2648 reg |= (E1000_PHY_CTRL_GBE_DISABLE |
2649 E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
2650 ew32(PHY_CTRL, reg);
2651
Bruce Allanad680762008-03-28 09:15:03 -07002652 /*
2653 * Call gig speed drop workaround on Gig disable before
2654 * accessing any PHY registers
2655 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002656 if (hw->mac.type == e1000_ich8lan)
2657 e1000e_gig_downshift_workaround_ich8lan(hw);
2658
2659 /* Write VR power-down enable */
2660 e1e_rphy(hw, IGP3_VR_CTRL, &data);
2661 data &= ~IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
2662 e1e_wphy(hw, IGP3_VR_CTRL, data | IGP3_VR_CTRL_MODE_SHUTDOWN);
2663
2664 /* Read it back and test */
2665 e1e_rphy(hw, IGP3_VR_CTRL, &data);
2666 data &= IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
2667 if ((data == IGP3_VR_CTRL_MODE_SHUTDOWN) || retry)
2668 break;
2669
2670 /* Issue PHY reset and repeat at most one more time */
2671 reg = er32(CTRL);
2672 ew32(CTRL, reg | E1000_CTRL_PHY_RST);
2673 retry++;
2674 } while (retry);
2675}
2676
2677/**
2678 * e1000e_gig_downshift_workaround_ich8lan - WoL from S5 stops working
2679 * @hw: pointer to the HW structure
2680 *
2681 * Steps to take when dropping from 1Gb/s (eg. link cable removal (LSC),
Auke Kok489815c2008-02-21 15:11:07 -08002682 * LPLU, Gig disable, MDIC PHY reset):
Auke Kokbc7f75f2007-09-17 12:30:59 -07002683 * 1) Set Kumeran Near-end loopback
2684 * 2) Clear Kumeran Near-end loopback
2685 * Should only be called for ICH8[m] devices with IGP_3 Phy.
2686 **/
2687void e1000e_gig_downshift_workaround_ich8lan(struct e1000_hw *hw)
2688{
2689 s32 ret_val;
2690 u16 reg_data;
2691
2692 if ((hw->mac.type != e1000_ich8lan) ||
2693 (hw->phy.type != e1000_phy_igp_3))
2694 return;
2695
2696 ret_val = e1000e_read_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
2697 &reg_data);
2698 if (ret_val)
2699 return;
2700 reg_data |= E1000_KMRNCTRLSTA_DIAG_NELPBK;
2701 ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
2702 reg_data);
2703 if (ret_val)
2704 return;
2705 reg_data &= ~E1000_KMRNCTRLSTA_DIAG_NELPBK;
2706 ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
2707 reg_data);
2708}
2709
2710/**
Bruce Allan97ac8ca2008-04-29 09:16:05 -07002711 * e1000e_disable_gig_wol_ich8lan - disable gig during WoL
2712 * @hw: pointer to the HW structure
2713 *
2714 * During S0 to Sx transition, it is possible the link remains at gig
2715 * instead of negotiating to a lower speed. Before going to Sx, set
2716 * 'LPLU Enabled' and 'Gig Disable' to force link speed negotiation
2717 * to a lower speed.
2718 *
Bruce Allana4f58f52009-06-02 11:29:18 +00002719 * Should only be called for applicable parts.
Bruce Allan97ac8ca2008-04-29 09:16:05 -07002720 **/
2721void e1000e_disable_gig_wol_ich8lan(struct e1000_hw *hw)
2722{
2723 u32 phy_ctrl;
2724
Bruce Allana4f58f52009-06-02 11:29:18 +00002725 switch (hw->mac.type) {
2726 case e1000_ich9lan:
2727 case e1000_ich10lan:
2728 case e1000_pchlan:
Bruce Allan97ac8ca2008-04-29 09:16:05 -07002729 phy_ctrl = er32(PHY_CTRL);
2730 phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU |
2731 E1000_PHY_CTRL_GBE_DISABLE;
2732 ew32(PHY_CTRL, phy_ctrl);
Bruce Allana4f58f52009-06-02 11:29:18 +00002733
2734 /* Workaround SWFLAG unexpectedly set during S0->Sx */
2735 if (hw->mac.type == e1000_pchlan)
2736 udelay(500);
2737 default:
2738 break;
Bruce Allan97ac8ca2008-04-29 09:16:05 -07002739 }
2740
2741 return;
2742}
2743
2744/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07002745 * e1000_cleanup_led_ich8lan - Restore the default LED operation
2746 * @hw: pointer to the HW structure
2747 *
2748 * Return the LED back to the default configuration.
2749 **/
2750static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw)
2751{
2752 if (hw->phy.type == e1000_phy_ife)
2753 return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED, 0);
2754
2755 ew32(LEDCTL, hw->mac.ledctl_default);
2756 return 0;
2757}
2758
2759/**
Auke Kok489815c2008-02-21 15:11:07 -08002760 * e1000_led_on_ich8lan - Turn LEDs on
Auke Kokbc7f75f2007-09-17 12:30:59 -07002761 * @hw: pointer to the HW structure
2762 *
Auke Kok489815c2008-02-21 15:11:07 -08002763 * Turn on the LEDs.
Auke Kokbc7f75f2007-09-17 12:30:59 -07002764 **/
2765static s32 e1000_led_on_ich8lan(struct e1000_hw *hw)
2766{
2767 if (hw->phy.type == e1000_phy_ife)
2768 return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED,
2769 (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_ON));
2770
2771 ew32(LEDCTL, hw->mac.ledctl_mode2);
2772 return 0;
2773}
2774
2775/**
Auke Kok489815c2008-02-21 15:11:07 -08002776 * e1000_led_off_ich8lan - Turn LEDs off
Auke Kokbc7f75f2007-09-17 12:30:59 -07002777 * @hw: pointer to the HW structure
2778 *
Auke Kok489815c2008-02-21 15:11:07 -08002779 * Turn off the LEDs.
Auke Kokbc7f75f2007-09-17 12:30:59 -07002780 **/
2781static s32 e1000_led_off_ich8lan(struct e1000_hw *hw)
2782{
2783 if (hw->phy.type == e1000_phy_ife)
2784 return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED,
2785 (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_OFF));
2786
2787 ew32(LEDCTL, hw->mac.ledctl_mode1);
2788 return 0;
2789}
2790
2791/**
Bruce Allana4f58f52009-06-02 11:29:18 +00002792 * e1000_setup_led_pchlan - Configures SW controllable LED
2793 * @hw: pointer to the HW structure
2794 *
2795 * This prepares the SW controllable LED for use.
2796 **/
2797static s32 e1000_setup_led_pchlan(struct e1000_hw *hw)
2798{
2799 return hw->phy.ops.write_phy_reg(hw, HV_LED_CONFIG,
2800 (u16)hw->mac.ledctl_mode1);
2801}
2802
2803/**
2804 * e1000_cleanup_led_pchlan - Restore the default LED operation
2805 * @hw: pointer to the HW structure
2806 *
2807 * Return the LED back to the default configuration.
2808 **/
2809static s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw)
2810{
2811 return hw->phy.ops.write_phy_reg(hw, HV_LED_CONFIG,
2812 (u16)hw->mac.ledctl_default);
2813}
2814
2815/**
2816 * e1000_led_on_pchlan - Turn LEDs on
2817 * @hw: pointer to the HW structure
2818 *
2819 * Turn on the LEDs.
2820 **/
2821static s32 e1000_led_on_pchlan(struct e1000_hw *hw)
2822{
2823 u16 data = (u16)hw->mac.ledctl_mode2;
2824 u32 i, led;
2825
2826 /*
2827 * If no link, then turn LED on by setting the invert bit
2828 * for each LED that's mode is "link_up" in ledctl_mode2.
2829 */
2830 if (!(er32(STATUS) & E1000_STATUS_LU)) {
2831 for (i = 0; i < 3; i++) {
2832 led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
2833 if ((led & E1000_PHY_LED0_MODE_MASK) !=
2834 E1000_LEDCTL_MODE_LINK_UP)
2835 continue;
2836 if (led & E1000_PHY_LED0_IVRT)
2837 data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
2838 else
2839 data |= (E1000_PHY_LED0_IVRT << (i * 5));
2840 }
2841 }
2842
2843 return hw->phy.ops.write_phy_reg(hw, HV_LED_CONFIG, data);
2844}
2845
2846/**
2847 * e1000_led_off_pchlan - Turn LEDs off
2848 * @hw: pointer to the HW structure
2849 *
2850 * Turn off the LEDs.
2851 **/
2852static s32 e1000_led_off_pchlan(struct e1000_hw *hw)
2853{
2854 u16 data = (u16)hw->mac.ledctl_mode1;
2855 u32 i, led;
2856
2857 /*
2858 * If no link, then turn LED off by clearing the invert bit
2859 * for each LED that's mode is "link_up" in ledctl_mode1.
2860 */
2861 if (!(er32(STATUS) & E1000_STATUS_LU)) {
2862 for (i = 0; i < 3; i++) {
2863 led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
2864 if ((led & E1000_PHY_LED0_MODE_MASK) !=
2865 E1000_LEDCTL_MODE_LINK_UP)
2866 continue;
2867 if (led & E1000_PHY_LED0_IVRT)
2868 data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
2869 else
2870 data |= (E1000_PHY_LED0_IVRT << (i * 5));
2871 }
2872 }
2873
2874 return hw->phy.ops.write_phy_reg(hw, HV_LED_CONFIG, data);
2875}
2876
2877/**
Bruce Allanf4187b52008-08-26 18:36:50 -07002878 * e1000_get_cfg_done_ich8lan - Read config done bit
2879 * @hw: pointer to the HW structure
2880 *
2881 * Read the management control register for the config done bit for
2882 * completion status. NOTE: silicon which is EEPROM-less will fail trying
2883 * to read the config done bit, so an error is *ONLY* logged and returns
Bruce Allana4f58f52009-06-02 11:29:18 +00002884 * 0. If we were to return with error, EEPROM-less silicon
Bruce Allanf4187b52008-08-26 18:36:50 -07002885 * would not be able to be reset or change link.
2886 **/
2887static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw)
2888{
2889 u32 bank = 0;
2890
Bruce Allanfc0c7762009-07-01 13:27:55 +00002891 if (hw->mac.type >= e1000_pchlan) {
2892 u32 status = er32(STATUS);
2893
2894 if (status & E1000_STATUS_PHYRA)
2895 ew32(STATUS, status & ~E1000_STATUS_PHYRA);
2896 else
2897 hw_dbg(hw,
2898 "PHY Reset Asserted not set - needs delay\n");
2899 }
2900
Bruce Allanf4187b52008-08-26 18:36:50 -07002901 e1000e_get_cfg_done(hw);
2902
2903 /* If EEPROM is not marked present, init the IGP 3 PHY manually */
Bruce Allana4f58f52009-06-02 11:29:18 +00002904 if ((hw->mac.type != e1000_ich10lan) &&
2905 (hw->mac.type != e1000_pchlan)) {
Bruce Allanf4187b52008-08-26 18:36:50 -07002906 if (((er32(EECD) & E1000_EECD_PRES) == 0) &&
2907 (hw->phy.type == e1000_phy_igp_3)) {
2908 e1000e_phy_init_script_igp3(hw);
2909 }
2910 } else {
2911 if (e1000_valid_nvm_bank_detect_ich8lan(hw, &bank)) {
2912 /* Maybe we should do a basic PHY config */
2913 hw_dbg(hw, "EEPROM not present\n");
2914 return -E1000_ERR_CONFIG;
2915 }
2916 }
2917
2918 return 0;
2919}
2920
2921/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07002922 * e1000_clear_hw_cntrs_ich8lan - Clear statistical counters
2923 * @hw: pointer to the HW structure
2924 *
2925 * Clears hardware counters specific to the silicon family and calls
2926 * clear_hw_cntrs_generic to clear all general purpose counters.
2927 **/
2928static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw)
2929{
2930 u32 temp;
Bruce Allana4f58f52009-06-02 11:29:18 +00002931 u16 phy_data;
Auke Kokbc7f75f2007-09-17 12:30:59 -07002932
2933 e1000e_clear_hw_cntrs_base(hw);
2934
2935 temp = er32(ALGNERRC);
2936 temp = er32(RXERRC);
2937 temp = er32(TNCRS);
2938 temp = er32(CEXTERR);
2939 temp = er32(TSCTC);
2940 temp = er32(TSCTFC);
2941
2942 temp = er32(MGTPRC);
2943 temp = er32(MGTPDC);
2944 temp = er32(MGTPTC);
2945
2946 temp = er32(IAC);
2947 temp = er32(ICRXOC);
2948
Bruce Allana4f58f52009-06-02 11:29:18 +00002949 /* Clear PHY statistics registers */
2950 if ((hw->phy.type == e1000_phy_82578) ||
2951 (hw->phy.type == e1000_phy_82577)) {
2952 hw->phy.ops.read_phy_reg(hw, HV_SCC_UPPER, &phy_data);
2953 hw->phy.ops.read_phy_reg(hw, HV_SCC_LOWER, &phy_data);
2954 hw->phy.ops.read_phy_reg(hw, HV_ECOL_UPPER, &phy_data);
2955 hw->phy.ops.read_phy_reg(hw, HV_ECOL_LOWER, &phy_data);
2956 hw->phy.ops.read_phy_reg(hw, HV_MCC_UPPER, &phy_data);
2957 hw->phy.ops.read_phy_reg(hw, HV_MCC_LOWER, &phy_data);
2958 hw->phy.ops.read_phy_reg(hw, HV_LATECOL_UPPER, &phy_data);
2959 hw->phy.ops.read_phy_reg(hw, HV_LATECOL_LOWER, &phy_data);
2960 hw->phy.ops.read_phy_reg(hw, HV_COLC_UPPER, &phy_data);
2961 hw->phy.ops.read_phy_reg(hw, HV_COLC_LOWER, &phy_data);
2962 hw->phy.ops.read_phy_reg(hw, HV_DC_UPPER, &phy_data);
2963 hw->phy.ops.read_phy_reg(hw, HV_DC_LOWER, &phy_data);
2964 hw->phy.ops.read_phy_reg(hw, HV_TNCRS_UPPER, &phy_data);
2965 hw->phy.ops.read_phy_reg(hw, HV_TNCRS_LOWER, &phy_data);
2966 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07002967}
2968
2969static struct e1000_mac_operations ich8_mac_ops = {
Bruce Allana4f58f52009-06-02 11:29:18 +00002970 .id_led_init = e1000e_id_led_init,
Bruce Allan4662e822008-08-26 18:37:06 -07002971 .check_mng_mode = e1000_check_mng_mode_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07002972 .check_for_link = e1000e_check_for_copper_link,
Bruce Allana4f58f52009-06-02 11:29:18 +00002973 /* cleanup_led dependent on mac type */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002974 .clear_hw_cntrs = e1000_clear_hw_cntrs_ich8lan,
2975 .get_bus_info = e1000_get_bus_info_ich8lan,
2976 .get_link_up_info = e1000_get_link_up_info_ich8lan,
Bruce Allana4f58f52009-06-02 11:29:18 +00002977 /* led_on dependent on mac type */
2978 /* led_off dependent on mac type */
Jeff Kirshere2de3eb2008-03-28 09:15:11 -07002979 .update_mc_addr_list = e1000e_update_mc_addr_list_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07002980 .reset_hw = e1000_reset_hw_ich8lan,
2981 .init_hw = e1000_init_hw_ich8lan,
2982 .setup_link = e1000_setup_link_ich8lan,
2983 .setup_physical_interface= e1000_setup_copper_link_ich8lan,
Bruce Allana4f58f52009-06-02 11:29:18 +00002984 /* id_led_init dependent on mac type */
Auke Kokbc7f75f2007-09-17 12:30:59 -07002985};
2986
2987static struct e1000_phy_operations ich8_phy_ops = {
2988 .acquire_phy = e1000_acquire_swflag_ich8lan,
2989 .check_reset_block = e1000_check_reset_block_ich8lan,
2990 .commit_phy = NULL,
2991 .force_speed_duplex = e1000_phy_force_speed_duplex_ich8lan,
Bruce Allanf4187b52008-08-26 18:36:50 -07002992 .get_cfg_done = e1000_get_cfg_done_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07002993 .get_cable_length = e1000e_get_cable_length_igp_2,
2994 .get_phy_info = e1000_get_phy_info_ich8lan,
2995 .read_phy_reg = e1000e_read_phy_reg_igp,
2996 .release_phy = e1000_release_swflag_ich8lan,
2997 .reset_phy = e1000_phy_hw_reset_ich8lan,
2998 .set_d0_lplu_state = e1000_set_d0_lplu_state_ich8lan,
2999 .set_d3_lplu_state = e1000_set_d3_lplu_state_ich8lan,
3000 .write_phy_reg = e1000e_write_phy_reg_igp,
3001};
3002
3003static struct e1000_nvm_operations ich8_nvm_ops = {
3004 .acquire_nvm = e1000_acquire_swflag_ich8lan,
3005 .read_nvm = e1000_read_nvm_ich8lan,
3006 .release_nvm = e1000_release_swflag_ich8lan,
3007 .update_nvm = e1000_update_nvm_checksum_ich8lan,
3008 .valid_led_default = e1000_valid_led_default_ich8lan,
3009 .validate_nvm = e1000_validate_nvm_checksum_ich8lan,
3010 .write_nvm = e1000_write_nvm_ich8lan,
3011};
3012
3013struct e1000_info e1000_ich8_info = {
3014 .mac = e1000_ich8lan,
3015 .flags = FLAG_HAS_WOL
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003016 | FLAG_IS_ICH
Auke Kokbc7f75f2007-09-17 12:30:59 -07003017 | FLAG_RX_CSUM_ENABLED
3018 | FLAG_HAS_CTRLEXT_ON_LOAD
3019 | FLAG_HAS_AMT
3020 | FLAG_HAS_FLASH
3021 | FLAG_APME_IN_WUC,
3022 .pba = 8,
Bruce Allan2adc55c2009-06-02 11:28:58 +00003023 .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN,
Jeff Kirsher69e3fd82008-04-02 13:48:18 -07003024 .get_variants = e1000_get_variants_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07003025 .mac_ops = &ich8_mac_ops,
3026 .phy_ops = &ich8_phy_ops,
3027 .nvm_ops = &ich8_nvm_ops,
3028};
3029
3030struct e1000_info e1000_ich9_info = {
3031 .mac = e1000_ich9lan,
3032 .flags = FLAG_HAS_JUMBO_FRAMES
Bruce Allan97ac8ca2008-04-29 09:16:05 -07003033 | FLAG_IS_ICH
Auke Kokbc7f75f2007-09-17 12:30:59 -07003034 | FLAG_HAS_WOL
3035 | FLAG_RX_CSUM_ENABLED
3036 | FLAG_HAS_CTRLEXT_ON_LOAD
3037 | FLAG_HAS_AMT
3038 | FLAG_HAS_ERT
3039 | FLAG_HAS_FLASH
3040 | FLAG_APME_IN_WUC,
3041 .pba = 10,
Bruce Allan2adc55c2009-06-02 11:28:58 +00003042 .max_hw_frame_size = DEFAULT_JUMBO,
Jeff Kirsher69e3fd82008-04-02 13:48:18 -07003043 .get_variants = e1000_get_variants_ich8lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07003044 .mac_ops = &ich8_mac_ops,
3045 .phy_ops = &ich8_phy_ops,
3046 .nvm_ops = &ich8_nvm_ops,
3047};
3048
Bruce Allanf4187b52008-08-26 18:36:50 -07003049struct e1000_info e1000_ich10_info = {
3050 .mac = e1000_ich10lan,
3051 .flags = FLAG_HAS_JUMBO_FRAMES
3052 | FLAG_IS_ICH
3053 | FLAG_HAS_WOL
3054 | FLAG_RX_CSUM_ENABLED
3055 | FLAG_HAS_CTRLEXT_ON_LOAD
3056 | FLAG_HAS_AMT
3057 | FLAG_HAS_ERT
3058 | FLAG_HAS_FLASH
3059 | FLAG_APME_IN_WUC,
3060 .pba = 10,
Bruce Allan2adc55c2009-06-02 11:28:58 +00003061 .max_hw_frame_size = DEFAULT_JUMBO,
Bruce Allanf4187b52008-08-26 18:36:50 -07003062 .get_variants = e1000_get_variants_ich8lan,
3063 .mac_ops = &ich8_mac_ops,
3064 .phy_ops = &ich8_phy_ops,
3065 .nvm_ops = &ich8_nvm_ops,
3066};
Bruce Allana4f58f52009-06-02 11:29:18 +00003067
3068struct e1000_info e1000_pch_info = {
3069 .mac = e1000_pchlan,
3070 .flags = FLAG_IS_ICH
3071 | FLAG_HAS_WOL
3072 | FLAG_RX_CSUM_ENABLED
3073 | FLAG_HAS_CTRLEXT_ON_LOAD
3074 | FLAG_HAS_AMT
3075 | FLAG_HAS_FLASH
3076 | FLAG_HAS_JUMBO_FRAMES
3077 | FLAG_APME_IN_WUC,
3078 .pba = 26,
3079 .max_hw_frame_size = 4096,
3080 .get_variants = e1000_get_variants_ich8lan,
3081 .mac_ops = &ich8_mac_ops,
3082 .phy_ops = &ich8_phy_ops,
3083 .nvm_ops = &ich8_nvm_ops,
3084};