1 /*******************************************************************************
3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2013 Intel Corporation.
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.
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
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.
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
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
27 *******************************************************************************/
29 /* 82562G 10/100 Network Connection
30 * 82562G-2 10/100 Network Connection
31 * 82562GT 10/100 Network Connection
32 * 82562GT-2 10/100 Network Connection
33 * 82562V 10/100 Network Connection
34 * 82562V-2 10/100 Network Connection
35 * 82566DC-2 Gigabit Network Connection
36 * 82566DC Gigabit Network Connection
37 * 82566DM-2 Gigabit Network Connection
38 * 82566DM Gigabit Network Connection
39 * 82566MC Gigabit Network Connection
40 * 82566MM Gigabit Network Connection
41 * 82567LM Gigabit Network Connection
42 * 82567LF Gigabit Network Connection
43 * 82567V Gigabit Network Connection
44 * 82567LM-2 Gigabit Network Connection
45 * 82567LF-2 Gigabit Network Connection
46 * 82567V-2 Gigabit Network Connection
47 * 82567LF-3 Gigabit Network Connection
48 * 82567LM-3 Gigabit Network Connection
49 * 82567LM-4 Gigabit Network Connection
50 * 82577LM Gigabit Network Connection
51 * 82577LC Gigabit Network Connection
52 * 82578DM Gigabit Network Connection
53 * 82578DC Gigabit Network Connection
54 * 82579LM Gigabit Network Connection
55 * 82579V Gigabit Network Connection
60 /* ICH GbE Flash Hardware Sequencing Flash Status Register bit breakdown */
61 /* Offset 04h HSFSTS */
62 union ich8_hws_flash_status
{
64 u16 flcdone
:1; /* bit 0 Flash Cycle Done */
65 u16 flcerr
:1; /* bit 1 Flash Cycle Error */
66 u16 dael
:1; /* bit 2 Direct Access error Log */
67 u16 berasesz
:2; /* bit 4:3 Sector Erase Size */
68 u16 flcinprog
:1; /* bit 5 flash cycle in Progress */
69 u16 reserved1
:2; /* bit 13:6 Reserved */
70 u16 reserved2
:6; /* bit 13:6 Reserved */
71 u16 fldesvalid
:1; /* bit 14 Flash Descriptor Valid */
72 u16 flockdn
:1; /* bit 15 Flash Config Lock-Down */
77 /* ICH GbE Flash Hardware Sequencing Flash control Register bit breakdown */
78 /* Offset 06h FLCTL */
79 union ich8_hws_flash_ctrl
{
81 u16 flcgo
:1; /* 0 Flash Cycle Go */
82 u16 flcycle
:2; /* 2:1 Flash Cycle */
83 u16 reserved
:5; /* 7:3 Reserved */
84 u16 fldbcount
:2; /* 9:8 Flash Data Byte Count */
85 u16 flockdn
:6; /* 15:10 Reserved */
90 /* ICH Flash Region Access Permissions */
91 union ich8_hws_flash_regacc
{
93 u32 grra
:8; /* 0:7 GbE region Read Access */
94 u32 grwa
:8; /* 8:15 GbE region Write Access */
95 u32 gmrag
:8; /* 23:16 GbE Master Read Access Grant */
96 u32 gmwag
:8; /* 31:24 GbE Master Write Access Grant */
101 /* ICH Flash Protected Region */
102 union ich8_flash_protected_range
{
104 u32 base
:13; /* 0:12 Protected Range Base */
105 u32 reserved1
:2; /* 13:14 Reserved */
106 u32 rpe
:1; /* 15 Read Protection Enable */
107 u32 limit
:13; /* 16:28 Protected Range Limit */
108 u32 reserved2
:2; /* 29:30 Reserved */
109 u32 wpe
:1; /* 31 Write Protection Enable */
114 static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw
*hw
);
115 static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw
*hw
);
116 static s32
e1000_erase_flash_bank_ich8lan(struct e1000_hw
*hw
, u32 bank
);
117 static s32
e1000_retry_write_flash_byte_ich8lan(struct e1000_hw
*hw
,
118 u32 offset
, u8 byte
);
119 static s32
e1000_read_flash_byte_ich8lan(struct e1000_hw
*hw
, u32 offset
,
121 static s32
e1000_read_flash_word_ich8lan(struct e1000_hw
*hw
, u32 offset
,
123 static s32
e1000_read_flash_data_ich8lan(struct e1000_hw
*hw
, u32 offset
,
125 static s32
e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw
*hw
);
126 static s32
e1000_cleanup_led_ich8lan(struct e1000_hw
*hw
);
127 static s32
e1000_led_on_ich8lan(struct e1000_hw
*hw
);
128 static s32
e1000_led_off_ich8lan(struct e1000_hw
*hw
);
129 static s32
e1000_id_led_init_pchlan(struct e1000_hw
*hw
);
130 static s32
e1000_setup_led_pchlan(struct e1000_hw
*hw
);
131 static s32
e1000_cleanup_led_pchlan(struct e1000_hw
*hw
);
132 static s32
e1000_led_on_pchlan(struct e1000_hw
*hw
);
133 static s32
e1000_led_off_pchlan(struct e1000_hw
*hw
);
134 static s32
e1000_set_lplu_state_pchlan(struct e1000_hw
*hw
, bool active
);
135 static void e1000_power_down_phy_copper_ich8lan(struct e1000_hw
*hw
);
136 static void e1000_lan_init_done_ich8lan(struct e1000_hw
*hw
);
137 static s32
e1000_k1_gig_workaround_hv(struct e1000_hw
*hw
, bool link
);
138 static s32
e1000_set_mdio_slow_mode_hv(struct e1000_hw
*hw
);
139 static bool e1000_check_mng_mode_ich8lan(struct e1000_hw
*hw
);
140 static bool e1000_check_mng_mode_pchlan(struct e1000_hw
*hw
);
141 static void e1000_rar_set_pch2lan(struct e1000_hw
*hw
, u8
*addr
, u32 index
);
142 static void e1000_rar_set_pch_lpt(struct e1000_hw
*hw
, u8
*addr
, u32 index
);
143 static s32
e1000_k1_workaround_lv(struct e1000_hw
*hw
);
144 static void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw
*hw
, bool gate
);
146 static inline u16
__er16flash(struct e1000_hw
*hw
, unsigned long reg
)
148 return readw(hw
->flash_address
+ reg
);
151 static inline u32
__er32flash(struct e1000_hw
*hw
, unsigned long reg
)
153 return readl(hw
->flash_address
+ reg
);
156 static inline void __ew16flash(struct e1000_hw
*hw
, unsigned long reg
, u16 val
)
158 writew(val
, hw
->flash_address
+ reg
);
161 static inline void __ew32flash(struct e1000_hw
*hw
, unsigned long reg
, u32 val
)
163 writel(val
, hw
->flash_address
+ reg
);
166 #define er16flash(reg) __er16flash(hw, (reg))
167 #define er32flash(reg) __er32flash(hw, (reg))
168 #define ew16flash(reg, val) __ew16flash(hw, (reg), (val))
169 #define ew32flash(reg, val) __ew32flash(hw, (reg), (val))
172 * e1000_phy_is_accessible_pchlan - Check if able to access PHY registers
173 * @hw: pointer to the HW structure
175 * Test access to the PHY registers by reading the PHY ID registers. If
176 * the PHY ID is already known (e.g. resume path) compare it with known ID,
177 * otherwise assume the read PHY ID is correct if it is valid.
179 * Assumes the sw/fw/hw semaphore is already acquired.
181 static bool e1000_phy_is_accessible_pchlan(struct e1000_hw
*hw
)
188 for (retry_count
= 0; retry_count
< 2; retry_count
++) {
189 ret_val
= e1e_rphy_locked(hw
, MII_PHYSID1
, &phy_reg
);
190 if (ret_val
|| (phy_reg
== 0xFFFF))
192 phy_id
= (u32
)(phy_reg
<< 16);
194 ret_val
= e1e_rphy_locked(hw
, MII_PHYSID2
, &phy_reg
);
195 if (ret_val
|| (phy_reg
== 0xFFFF)) {
199 phy_id
|= (u32
)(phy_reg
& PHY_REVISION_MASK
);
204 if (hw
->phy
.id
== phy_id
)
208 hw
->phy
.revision
= (u32
)(phy_reg
& ~PHY_REVISION_MASK
);
212 /* In case the PHY needs to be in mdio slow mode,
213 * set slow mode and try to get the PHY id again.
215 hw
->phy
.ops
.release(hw
);
216 ret_val
= e1000_set_mdio_slow_mode_hv(hw
);
218 ret_val
= e1000e_get_phy_id(hw
);
219 hw
->phy
.ops
.acquire(hw
);
225 * e1000_init_phy_workarounds_pchlan - PHY initialization workarounds
226 * @hw: pointer to the HW structure
228 * Workarounds/flow necessary for PHY initialization during driver load
231 static s32
e1000_init_phy_workarounds_pchlan(struct e1000_hw
*hw
)
233 u32 mac_reg
, fwsm
= er32(FWSM
);
237 /* Gate automatic PHY configuration by hardware on managed and
238 * non-managed 82579 and newer adapters.
240 e1000_gate_hw_phy_config_ich8lan(hw
, true);
242 ret_val
= hw
->phy
.ops
.acquire(hw
);
244 e_dbg("Failed to initialize PHY flow\n");
248 /* The MAC-PHY interconnect may be in SMBus mode. If the PHY is
249 * inaccessible and resetting the PHY is not blocked, toggle the
250 * LANPHYPC Value bit to force the interconnect to PCIe mode.
252 switch (hw
->mac
.type
) {
254 if (e1000_phy_is_accessible_pchlan(hw
))
257 /* Before toggling LANPHYPC, see if PHY is accessible by
258 * forcing MAC to SMBus mode first.
260 mac_reg
= er32(CTRL_EXT
);
261 mac_reg
|= E1000_CTRL_EXT_FORCE_SMBUS
;
262 ew32(CTRL_EXT
, mac_reg
);
266 if (e1000_phy_is_accessible_pchlan(hw
)) {
267 if (hw
->mac
.type
== e1000_pch_lpt
) {
268 /* Unforce SMBus mode in PHY */
269 e1e_rphy_locked(hw
, CV_SMB_CTRL
, &phy_reg
);
270 phy_reg
&= ~CV_SMB_CTRL_FORCE_SMBUS
;
271 e1e_wphy_locked(hw
, CV_SMB_CTRL
, phy_reg
);
273 /* Unforce SMBus mode in MAC */
274 mac_reg
= er32(CTRL_EXT
);
275 mac_reg
&= ~E1000_CTRL_EXT_FORCE_SMBUS
;
276 ew32(CTRL_EXT
, mac_reg
);
283 if ((hw
->mac
.type
== e1000_pchlan
) &&
284 (fwsm
& E1000_ICH_FWSM_FW_VALID
))
287 if (hw
->phy
.ops
.check_reset_block(hw
)) {
288 e_dbg("Required LANPHYPC toggle blocked by ME\n");
292 e_dbg("Toggling LANPHYPC\n");
294 /* Set Phy Config Counter to 50msec */
295 mac_reg
= er32(FEXTNVM3
);
296 mac_reg
&= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK
;
297 mac_reg
|= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC
;
298 ew32(FEXTNVM3
, mac_reg
);
300 if (hw
->mac
.type
== e1000_pch_lpt
) {
301 /* Toggling LANPHYPC brings the PHY out of SMBus mode
302 * So ensure that the MAC is also out of SMBus mode
304 mac_reg
= er32(CTRL_EXT
);
305 mac_reg
&= ~E1000_CTRL_EXT_FORCE_SMBUS
;
306 ew32(CTRL_EXT
, mac_reg
);
309 /* Toggle LANPHYPC Value bit */
310 mac_reg
= er32(CTRL
);
311 mac_reg
|= E1000_CTRL_LANPHYPC_OVERRIDE
;
312 mac_reg
&= ~E1000_CTRL_LANPHYPC_VALUE
;
316 mac_reg
&= ~E1000_CTRL_LANPHYPC_OVERRIDE
;
319 if (hw
->mac
.type
< e1000_pch_lpt
) {
324 usleep_range(5000, 10000);
325 } while (!(er32(CTRL_EXT
) &
326 E1000_CTRL_EXT_LPCD
) && count
--);
333 hw
->phy
.ops
.release(hw
);
335 /* Reset the PHY before any access to it. Doing so, ensures
336 * that the PHY is in a known good state before we read/write
337 * PHY registers. The generic reset is sufficient here,
338 * because we haven't determined the PHY type yet.
340 ret_val
= e1000e_phy_hw_reset_generic(hw
);
343 /* Ungate automatic PHY configuration on non-managed 82579 */
344 if ((hw
->mac
.type
== e1000_pch2lan
) &&
345 !(fwsm
& E1000_ICH_FWSM_FW_VALID
)) {
346 usleep_range(10000, 20000);
347 e1000_gate_hw_phy_config_ich8lan(hw
, false);
354 * e1000_init_phy_params_pchlan - Initialize PHY function pointers
355 * @hw: pointer to the HW structure
357 * Initialize family-specific PHY parameters and function pointers.
359 static s32
e1000_init_phy_params_pchlan(struct e1000_hw
*hw
)
361 struct e1000_phy_info
*phy
= &hw
->phy
;
365 phy
->reset_delay_us
= 100;
367 phy
->ops
.set_page
= e1000_set_page_igp
;
368 phy
->ops
.read_reg
= e1000_read_phy_reg_hv
;
369 phy
->ops
.read_reg_locked
= e1000_read_phy_reg_hv_locked
;
370 phy
->ops
.read_reg_page
= e1000_read_phy_reg_page_hv
;
371 phy
->ops
.set_d0_lplu_state
= e1000_set_lplu_state_pchlan
;
372 phy
->ops
.set_d3_lplu_state
= e1000_set_lplu_state_pchlan
;
373 phy
->ops
.write_reg
= e1000_write_phy_reg_hv
;
374 phy
->ops
.write_reg_locked
= e1000_write_phy_reg_hv_locked
;
375 phy
->ops
.write_reg_page
= e1000_write_phy_reg_page_hv
;
376 phy
->ops
.power_up
= e1000_power_up_phy_copper
;
377 phy
->ops
.power_down
= e1000_power_down_phy_copper_ich8lan
;
378 phy
->autoneg_mask
= AUTONEG_ADVERTISE_SPEED_DEFAULT
;
380 phy
->id
= e1000_phy_unknown
;
382 ret_val
= e1000_init_phy_workarounds_pchlan(hw
);
386 if (phy
->id
== e1000_phy_unknown
)
387 switch (hw
->mac
.type
) {
389 ret_val
= e1000e_get_phy_id(hw
);
392 if ((phy
->id
!= 0) && (phy
->id
!= PHY_REVISION_MASK
))
397 /* In case the PHY needs to be in mdio slow mode,
398 * set slow mode and try to get the PHY id again.
400 ret_val
= e1000_set_mdio_slow_mode_hv(hw
);
403 ret_val
= e1000e_get_phy_id(hw
);
408 phy
->type
= e1000e_get_phy_type_from_id(phy
->id
);
411 case e1000_phy_82577
:
412 case e1000_phy_82579
:
414 phy
->ops
.check_polarity
= e1000_check_polarity_82577
;
415 phy
->ops
.force_speed_duplex
=
416 e1000_phy_force_speed_duplex_82577
;
417 phy
->ops
.get_cable_length
= e1000_get_cable_length_82577
;
418 phy
->ops
.get_info
= e1000_get_phy_info_82577
;
419 phy
->ops
.commit
= e1000e_phy_sw_reset
;
421 case e1000_phy_82578
:
422 phy
->ops
.check_polarity
= e1000_check_polarity_m88
;
423 phy
->ops
.force_speed_duplex
= e1000e_phy_force_speed_duplex_m88
;
424 phy
->ops
.get_cable_length
= e1000e_get_cable_length_m88
;
425 phy
->ops
.get_info
= e1000e_get_phy_info_m88
;
428 ret_val
= -E1000_ERR_PHY
;
436 * e1000_init_phy_params_ich8lan - Initialize PHY function pointers
437 * @hw: pointer to the HW structure
439 * Initialize family-specific PHY parameters and function pointers.
441 static s32
e1000_init_phy_params_ich8lan(struct e1000_hw
*hw
)
443 struct e1000_phy_info
*phy
= &hw
->phy
;
448 phy
->reset_delay_us
= 100;
450 phy
->ops
.power_up
= e1000_power_up_phy_copper
;
451 phy
->ops
.power_down
= e1000_power_down_phy_copper_ich8lan
;
453 /* We may need to do this twice - once for IGP and if that fails,
454 * we'll set BM func pointers and try again
456 ret_val
= e1000e_determine_phy_address(hw
);
458 phy
->ops
.write_reg
= e1000e_write_phy_reg_bm
;
459 phy
->ops
.read_reg
= e1000e_read_phy_reg_bm
;
460 ret_val
= e1000e_determine_phy_address(hw
);
462 e_dbg("Cannot determine PHY addr. Erroring out\n");
468 while ((e1000_phy_unknown
== e1000e_get_phy_type_from_id(phy
->id
)) &&
470 usleep_range(1000, 2000);
471 ret_val
= e1000e_get_phy_id(hw
);
478 case IGP03E1000_E_PHY_ID
:
479 phy
->type
= e1000_phy_igp_3
;
480 phy
->autoneg_mask
= AUTONEG_ADVERTISE_SPEED_DEFAULT
;
481 phy
->ops
.read_reg_locked
= e1000e_read_phy_reg_igp_locked
;
482 phy
->ops
.write_reg_locked
= e1000e_write_phy_reg_igp_locked
;
483 phy
->ops
.get_info
= e1000e_get_phy_info_igp
;
484 phy
->ops
.check_polarity
= e1000_check_polarity_igp
;
485 phy
->ops
.force_speed_duplex
= e1000e_phy_force_speed_duplex_igp
;
488 case IFE_PLUS_E_PHY_ID
:
490 phy
->type
= e1000_phy_ife
;
491 phy
->autoneg_mask
= E1000_ALL_NOT_GIG
;
492 phy
->ops
.get_info
= e1000_get_phy_info_ife
;
493 phy
->ops
.check_polarity
= e1000_check_polarity_ife
;
494 phy
->ops
.force_speed_duplex
= e1000_phy_force_speed_duplex_ife
;
496 case BME1000_E_PHY_ID
:
497 phy
->type
= e1000_phy_bm
;
498 phy
->autoneg_mask
= AUTONEG_ADVERTISE_SPEED_DEFAULT
;
499 phy
->ops
.read_reg
= e1000e_read_phy_reg_bm
;
500 phy
->ops
.write_reg
= e1000e_write_phy_reg_bm
;
501 phy
->ops
.commit
= e1000e_phy_sw_reset
;
502 phy
->ops
.get_info
= e1000e_get_phy_info_m88
;
503 phy
->ops
.check_polarity
= e1000_check_polarity_m88
;
504 phy
->ops
.force_speed_duplex
= e1000e_phy_force_speed_duplex_m88
;
507 return -E1000_ERR_PHY
;
515 * e1000_init_nvm_params_ich8lan - Initialize NVM function pointers
516 * @hw: pointer to the HW structure
518 * Initialize family-specific NVM parameters and function
521 static s32
e1000_init_nvm_params_ich8lan(struct e1000_hw
*hw
)
523 struct e1000_nvm_info
*nvm
= &hw
->nvm
;
524 struct e1000_dev_spec_ich8lan
*dev_spec
= &hw
->dev_spec
.ich8lan
;
525 u32 gfpreg
, sector_base_addr
, sector_end_addr
;
528 /* Can't read flash registers if the register set isn't mapped. */
529 if (!hw
->flash_address
) {
530 e_dbg("ERROR: Flash registers not mapped\n");
531 return -E1000_ERR_CONFIG
;
534 nvm
->type
= e1000_nvm_flash_sw
;
536 gfpreg
= er32flash(ICH_FLASH_GFPREG
);
538 /* sector_X_addr is a "sector"-aligned address (4096 bytes)
539 * Add 1 to sector_end_addr since this sector is included in
542 sector_base_addr
= gfpreg
& FLASH_GFPREG_BASE_MASK
;
543 sector_end_addr
= ((gfpreg
>> 16) & FLASH_GFPREG_BASE_MASK
) + 1;
545 /* flash_base_addr is byte-aligned */
546 nvm
->flash_base_addr
= sector_base_addr
<< FLASH_SECTOR_ADDR_SHIFT
;
548 /* find total size of the NVM, then cut in half since the total
549 * size represents two separate NVM banks.
551 nvm
->flash_bank_size
= (sector_end_addr
- sector_base_addr
)
552 << FLASH_SECTOR_ADDR_SHIFT
;
553 nvm
->flash_bank_size
/= 2;
554 /* Adjust to word count */
555 nvm
->flash_bank_size
/= sizeof(u16
);
557 nvm
->word_size
= E1000_ICH8_SHADOW_RAM_WORDS
;
559 /* Clear shadow ram */
560 for (i
= 0; i
< nvm
->word_size
; i
++) {
561 dev_spec
->shadow_ram
[i
].modified
= false;
562 dev_spec
->shadow_ram
[i
].value
= 0xFFFF;
569 * e1000_init_mac_params_ich8lan - Initialize MAC function pointers
570 * @hw: pointer to the HW structure
572 * Initialize family-specific MAC parameters and function
575 static s32
e1000_init_mac_params_ich8lan(struct e1000_hw
*hw
)
577 struct e1000_mac_info
*mac
= &hw
->mac
;
579 /* Set media type function pointer */
580 hw
->phy
.media_type
= e1000_media_type_copper
;
582 /* Set mta register count */
583 mac
->mta_reg_count
= 32;
584 /* Set rar entry count */
585 mac
->rar_entry_count
= E1000_ICH_RAR_ENTRIES
;
586 if (mac
->type
== e1000_ich8lan
)
587 mac
->rar_entry_count
--;
589 mac
->has_fwsm
= true;
590 /* ARC subsystem not supported */
591 mac
->arc_subsystem_valid
= false;
592 /* Adaptive IFS supported */
593 mac
->adaptive_ifs
= true;
595 /* LED and other operations */
600 /* check management mode */
601 mac
->ops
.check_mng_mode
= e1000_check_mng_mode_ich8lan
;
603 mac
->ops
.id_led_init
= e1000e_id_led_init_generic
;
605 mac
->ops
.blink_led
= e1000e_blink_led_generic
;
607 mac
->ops
.setup_led
= e1000e_setup_led_generic
;
609 mac
->ops
.cleanup_led
= e1000_cleanup_led_ich8lan
;
610 /* turn on/off LED */
611 mac
->ops
.led_on
= e1000_led_on_ich8lan
;
612 mac
->ops
.led_off
= e1000_led_off_ich8lan
;
615 mac
->rar_entry_count
= E1000_PCH2_RAR_ENTRIES
;
616 mac
->ops
.rar_set
= e1000_rar_set_pch2lan
;
620 /* check management mode */
621 mac
->ops
.check_mng_mode
= e1000_check_mng_mode_pchlan
;
623 mac
->ops
.id_led_init
= e1000_id_led_init_pchlan
;
625 mac
->ops
.setup_led
= e1000_setup_led_pchlan
;
627 mac
->ops
.cleanup_led
= e1000_cleanup_led_pchlan
;
628 /* turn on/off LED */
629 mac
->ops
.led_on
= e1000_led_on_pchlan
;
630 mac
->ops
.led_off
= e1000_led_off_pchlan
;
636 if (mac
->type
== e1000_pch_lpt
) {
637 mac
->rar_entry_count
= E1000_PCH_LPT_RAR_ENTRIES
;
638 mac
->ops
.rar_set
= e1000_rar_set_pch_lpt
;
641 /* Enable PCS Lock-loss workaround for ICH8 */
642 if (mac
->type
== e1000_ich8lan
)
643 e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw
, true);
649 * __e1000_access_emi_reg_locked - Read/write EMI register
650 * @hw: pointer to the HW structure
651 * @addr: EMI address to program
652 * @data: pointer to value to read/write from/to the EMI address
653 * @read: boolean flag to indicate read or write
655 * This helper function assumes the SW/FW/HW Semaphore is already acquired.
657 static s32
__e1000_access_emi_reg_locked(struct e1000_hw
*hw
, u16 address
,
658 u16
*data
, bool read
)
662 ret_val
= e1e_wphy_locked(hw
, I82579_EMI_ADDR
, address
);
667 ret_val
= e1e_rphy_locked(hw
, I82579_EMI_DATA
, data
);
669 ret_val
= e1e_wphy_locked(hw
, I82579_EMI_DATA
, *data
);
675 * e1000_read_emi_reg_locked - Read Extended Management Interface register
676 * @hw: pointer to the HW structure
677 * @addr: EMI address to program
678 * @data: value to be read from the EMI address
680 * Assumes the SW/FW/HW Semaphore is already acquired.
682 s32
e1000_read_emi_reg_locked(struct e1000_hw
*hw
, u16 addr
, u16
*data
)
684 return __e1000_access_emi_reg_locked(hw
, addr
, data
, true);
688 * e1000_write_emi_reg_locked - Write Extended Management Interface register
689 * @hw: pointer to the HW structure
690 * @addr: EMI address to program
691 * @data: value to be written to the EMI address
693 * Assumes the SW/FW/HW Semaphore is already acquired.
695 static s32
e1000_write_emi_reg_locked(struct e1000_hw
*hw
, u16 addr
, u16 data
)
697 return __e1000_access_emi_reg_locked(hw
, addr
, &data
, false);
701 * e1000_set_eee_pchlan - Enable/disable EEE support
702 * @hw: pointer to the HW structure
704 * Enable/disable EEE based on setting in dev_spec structure, the duplex of
705 * the link and the EEE capabilities of the link partner. The LPI Control
706 * register bits will remain set only if/when link is up.
708 static s32
e1000_set_eee_pchlan(struct e1000_hw
*hw
)
710 struct e1000_dev_spec_ich8lan
*dev_spec
= &hw
->dev_spec
.ich8lan
;
714 if ((hw
->phy
.type
!= e1000_phy_82579
) &&
715 (hw
->phy
.type
!= e1000_phy_i217
))
718 ret_val
= hw
->phy
.ops
.acquire(hw
);
722 ret_val
= e1e_rphy_locked(hw
, I82579_LPI_CTRL
, &lpi_ctrl
);
726 /* Clear bits that enable EEE in various speeds */
727 lpi_ctrl
&= ~I82579_LPI_CTRL_ENABLE_MASK
;
729 /* Enable EEE if not disabled by user */
730 if (!dev_spec
->eee_disable
) {
731 u16 lpa
, pcs_status
, data
;
733 /* Save off link partner's EEE ability */
734 switch (hw
->phy
.type
) {
735 case e1000_phy_82579
:
736 lpa
= I82579_EEE_LP_ABILITY
;
737 pcs_status
= I82579_EEE_PCS_STATUS
;
740 lpa
= I217_EEE_LP_ABILITY
;
741 pcs_status
= I217_EEE_PCS_STATUS
;
744 ret_val
= -E1000_ERR_PHY
;
747 ret_val
= e1000_read_emi_reg_locked(hw
, lpa
,
748 &dev_spec
->eee_lp_ability
);
752 /* Enable EEE only for speeds in which the link partner is
755 if (dev_spec
->eee_lp_ability
& I82579_EEE_1000_SUPPORTED
)
756 lpi_ctrl
|= I82579_LPI_CTRL_1000_ENABLE
;
758 if (dev_spec
->eee_lp_ability
& I82579_EEE_100_SUPPORTED
) {
759 e1e_rphy_locked(hw
, MII_LPA
, &data
);
760 if (data
& LPA_100FULL
)
761 lpi_ctrl
|= I82579_LPI_CTRL_100_ENABLE
;
763 /* EEE is not supported in 100Half, so ignore
764 * partner's EEE in 100 ability if full-duplex
767 dev_spec
->eee_lp_ability
&=
768 ~I82579_EEE_100_SUPPORTED
;
771 /* R/Clr IEEE MMD 3.1 bits 11:10 - Tx/Rx LPI Received */
772 ret_val
= e1000_read_emi_reg_locked(hw
, pcs_status
, &data
);
777 ret_val
= e1e_wphy_locked(hw
, I82579_LPI_CTRL
, lpi_ctrl
);
779 hw
->phy
.ops
.release(hw
);
785 * e1000_check_for_copper_link_ich8lan - Check for link (Copper)
786 * @hw: pointer to the HW structure
788 * Checks to see of the link status of the hardware has changed. If a
789 * change in link status has been detected, then we read the PHY registers
790 * to get the current speed/duplex if link exists.
792 static s32
e1000_check_for_copper_link_ich8lan(struct e1000_hw
*hw
)
794 struct e1000_mac_info
*mac
= &hw
->mac
;
799 /* We only want to go out to the PHY registers to see if Auto-Neg
800 * has completed and/or if our link status has changed. The
801 * get_link_status flag is set upon receiving a Link Status
802 * Change or Rx Sequence Error interrupt.
804 if (!mac
->get_link_status
)
807 /* First we want to see if the MII Status Register reports
808 * link. If so, then we want to get the current speed/duplex
811 ret_val
= e1000e_phy_has_link_generic(hw
, 1, 0, &link
);
815 if (hw
->mac
.type
== e1000_pchlan
) {
816 ret_val
= e1000_k1_gig_workaround_hv(hw
, link
);
821 /* Clear link partner's EEE ability */
822 hw
->dev_spec
.ich8lan
.eee_lp_ability
= 0;
825 return 0; /* No link detected */
827 mac
->get_link_status
= false;
829 switch (hw
->mac
.type
) {
831 ret_val
= e1000_k1_workaround_lv(hw
);
836 if (hw
->phy
.type
== e1000_phy_82578
) {
837 ret_val
= e1000_link_stall_workaround_hv(hw
);
842 /* Workaround for PCHx parts in half-duplex:
843 * Set the number of preambles removed from the packet
844 * when it is passed from the PHY to the MAC to prevent
845 * the MAC from misinterpreting the packet type.
847 e1e_rphy(hw
, HV_KMRN_FIFO_CTRLSTA
, &phy_reg
);
848 phy_reg
&= ~HV_KMRN_FIFO_CTRLSTA_PREAMBLE_MASK
;
850 if ((er32(STATUS
) & E1000_STATUS_FD
) != E1000_STATUS_FD
)
851 phy_reg
|= (1 << HV_KMRN_FIFO_CTRLSTA_PREAMBLE_SHIFT
);
853 e1e_wphy(hw
, HV_KMRN_FIFO_CTRLSTA
, phy_reg
);
859 /* Check if there was DownShift, must be checked
860 * immediately after link-up
862 e1000e_check_downshift(hw
);
864 /* Enable/Disable EEE after link up */
865 ret_val
= e1000_set_eee_pchlan(hw
);
869 /* If we are forcing speed/duplex, then we simply return since
870 * we have already determined whether we have link or not.
873 return -E1000_ERR_CONFIG
;
875 /* Auto-Neg is enabled. Auto Speed Detection takes care
876 * of MAC speed/duplex configuration. So we only need to
877 * configure Collision Distance in the MAC.
879 mac
->ops
.config_collision_dist(hw
);
881 /* Configure Flow Control now that Auto-Neg has completed.
882 * First, we need to restore the desired flow control
883 * settings because we may have had to re-autoneg with a
884 * different link partner.
886 ret_val
= e1000e_config_fc_after_link_up(hw
);
888 e_dbg("Error configuring flow control\n");
893 static s32
e1000_get_variants_ich8lan(struct e1000_adapter
*adapter
)
895 struct e1000_hw
*hw
= &adapter
->hw
;
898 rc
= e1000_init_mac_params_ich8lan(hw
);
902 rc
= e1000_init_nvm_params_ich8lan(hw
);
906 switch (hw
->mac
.type
) {
910 rc
= e1000_init_phy_params_ich8lan(hw
);
915 rc
= e1000_init_phy_params_pchlan(hw
);
923 /* Disable Jumbo Frame support on parts with Intel 10/100 PHY or
924 * on parts with MACsec enabled in NVM (reflected in CTRL_EXT).
926 if ((adapter
->hw
.phy
.type
== e1000_phy_ife
) ||
927 ((adapter
->hw
.mac
.type
>= e1000_pch2lan
) &&
928 (!(er32(CTRL_EXT
) & E1000_CTRL_EXT_LSECCK
)))) {
929 adapter
->flags
&= ~FLAG_HAS_JUMBO_FRAMES
;
930 adapter
->max_hw_frame_size
= ETH_FRAME_LEN
+ ETH_FCS_LEN
;
932 hw
->mac
.ops
.blink_led
= NULL
;
935 if ((adapter
->hw
.mac
.type
== e1000_ich8lan
) &&
936 (adapter
->hw
.phy
.type
!= e1000_phy_ife
))
937 adapter
->flags
|= FLAG_LSC_GIG_SPEED_DROP
;
939 /* Enable workaround for 82579 w/ ME enabled */
940 if ((adapter
->hw
.mac
.type
== e1000_pch2lan
) &&
941 (er32(FWSM
) & E1000_ICH_FWSM_FW_VALID
))
942 adapter
->flags2
|= FLAG2_PCIM2PCI_ARBITER_WA
;
944 /* Disable EEE by default until IEEE802.3az spec is finalized */
945 if (adapter
->flags2
& FLAG2_HAS_EEE
)
946 adapter
->hw
.dev_spec
.ich8lan
.eee_disable
= true;
951 static DEFINE_MUTEX(nvm_mutex
);
954 * e1000_acquire_nvm_ich8lan - Acquire NVM mutex
955 * @hw: pointer to the HW structure
957 * Acquires the mutex for performing NVM operations.
959 static s32
e1000_acquire_nvm_ich8lan(struct e1000_hw __always_unused
*hw
)
961 mutex_lock(&nvm_mutex
);
967 * e1000_release_nvm_ich8lan - Release NVM mutex
968 * @hw: pointer to the HW structure
970 * Releases the mutex used while performing NVM operations.
972 static void e1000_release_nvm_ich8lan(struct e1000_hw __always_unused
*hw
)
974 mutex_unlock(&nvm_mutex
);
978 * e1000_acquire_swflag_ich8lan - Acquire software control flag
979 * @hw: pointer to the HW structure
981 * Acquires the software control flag for performing PHY and select
984 static s32
e1000_acquire_swflag_ich8lan(struct e1000_hw
*hw
)
986 u32 extcnf_ctrl
, timeout
= PHY_CFG_TIMEOUT
;
989 if (test_and_set_bit(__E1000_ACCESS_SHARED_RESOURCE
,
990 &hw
->adapter
->state
)) {
991 e_dbg("contention for Phy access\n");
992 return -E1000_ERR_PHY
;
996 extcnf_ctrl
= er32(EXTCNF_CTRL
);
997 if (!(extcnf_ctrl
& E1000_EXTCNF_CTRL_SWFLAG
))
1005 e_dbg("SW has already locked the resource.\n");
1006 ret_val
= -E1000_ERR_CONFIG
;
1010 timeout
= SW_FLAG_TIMEOUT
;
1012 extcnf_ctrl
|= E1000_EXTCNF_CTRL_SWFLAG
;
1013 ew32(EXTCNF_CTRL
, extcnf_ctrl
);
1016 extcnf_ctrl
= er32(EXTCNF_CTRL
);
1017 if (extcnf_ctrl
& E1000_EXTCNF_CTRL_SWFLAG
)
1025 e_dbg("Failed to acquire the semaphore, FW or HW has it: FWSM=0x%8.8x EXTCNF_CTRL=0x%8.8x)\n",
1026 er32(FWSM
), extcnf_ctrl
);
1027 extcnf_ctrl
&= ~E1000_EXTCNF_CTRL_SWFLAG
;
1028 ew32(EXTCNF_CTRL
, extcnf_ctrl
);
1029 ret_val
= -E1000_ERR_CONFIG
;
1035 clear_bit(__E1000_ACCESS_SHARED_RESOURCE
, &hw
->adapter
->state
);
1041 * e1000_release_swflag_ich8lan - Release software control flag
1042 * @hw: pointer to the HW structure
1044 * Releases the software control flag for performing PHY and select
1047 static void e1000_release_swflag_ich8lan(struct e1000_hw
*hw
)
1051 extcnf_ctrl
= er32(EXTCNF_CTRL
);
1053 if (extcnf_ctrl
& E1000_EXTCNF_CTRL_SWFLAG
) {
1054 extcnf_ctrl
&= ~E1000_EXTCNF_CTRL_SWFLAG
;
1055 ew32(EXTCNF_CTRL
, extcnf_ctrl
);
1057 e_dbg("Semaphore unexpectedly released by sw/fw/hw\n");
1060 clear_bit(__E1000_ACCESS_SHARED_RESOURCE
, &hw
->adapter
->state
);
1064 * e1000_check_mng_mode_ich8lan - Checks management mode
1065 * @hw: pointer to the HW structure
1067 * This checks if the adapter has any manageability enabled.
1068 * This is a function pointer entry point only called by read/write
1069 * routines for the PHY and NVM parts.
1071 static bool e1000_check_mng_mode_ich8lan(struct e1000_hw
*hw
)
1076 return (fwsm
& E1000_ICH_FWSM_FW_VALID
) &&
1077 ((fwsm
& E1000_FWSM_MODE_MASK
) ==
1078 (E1000_ICH_MNG_IAMT_MODE
<< E1000_FWSM_MODE_SHIFT
));
1082 * e1000_check_mng_mode_pchlan - Checks management mode
1083 * @hw: pointer to the HW structure
1085 * This checks if the adapter has iAMT enabled.
1086 * This is a function pointer entry point only called by read/write
1087 * routines for the PHY and NVM parts.
1089 static bool e1000_check_mng_mode_pchlan(struct e1000_hw
*hw
)
1094 return (fwsm
& E1000_ICH_FWSM_FW_VALID
) &&
1095 (fwsm
& (E1000_ICH_MNG_IAMT_MODE
<< E1000_FWSM_MODE_SHIFT
));
1099 * e1000_rar_set_pch2lan - Set receive address register
1100 * @hw: pointer to the HW structure
1101 * @addr: pointer to the receive address
1102 * @index: receive address array register
1104 * Sets the receive address array register at index to the address passed
1105 * in by addr. For 82579, RAR[0] is the base address register that is to
1106 * contain the MAC address but RAR[1-6] are reserved for manageability (ME).
1107 * Use SHRA[0-3] in place of those reserved for ME.
1109 static void e1000_rar_set_pch2lan(struct e1000_hw
*hw
, u8
*addr
, u32 index
)
1111 u32 rar_low
, rar_high
;
1113 /* HW expects these in little endian so we reverse the byte order
1114 * from network order (big endian) to little endian
1116 rar_low
= ((u32
)addr
[0] |
1117 ((u32
)addr
[1] << 8) |
1118 ((u32
)addr
[2] << 16) | ((u32
)addr
[3] << 24));
1120 rar_high
= ((u32
)addr
[4] | ((u32
)addr
[5] << 8));
1122 /* If MAC address zero, no need to set the AV bit */
1123 if (rar_low
|| rar_high
)
1124 rar_high
|= E1000_RAH_AV
;
1127 ew32(RAL(index
), rar_low
);
1129 ew32(RAH(index
), rar_high
);
1134 if (index
< hw
->mac
.rar_entry_count
) {
1137 ret_val
= e1000_acquire_swflag_ich8lan(hw
);
1141 ew32(SHRAL(index
- 1), rar_low
);
1143 ew32(SHRAH(index
- 1), rar_high
);
1146 e1000_release_swflag_ich8lan(hw
);
1148 /* verify the register updates */
1149 if ((er32(SHRAL(index
- 1)) == rar_low
) &&
1150 (er32(SHRAH(index
- 1)) == rar_high
))
1153 e_dbg("SHRA[%d] might be locked by ME - FWSM=0x%8.8x\n",
1154 (index
- 1), er32(FWSM
));
1158 e_dbg("Failed to write receive address at index %d\n", index
);
1162 * e1000_rar_set_pch_lpt - Set receive address registers
1163 * @hw: pointer to the HW structure
1164 * @addr: pointer to the receive address
1165 * @index: receive address array register
1167 * Sets the receive address register array at index to the address passed
1168 * in by addr. For LPT, RAR[0] is the base address register that is to
1169 * contain the MAC address. SHRA[0-10] are the shared receive address
1170 * registers that are shared between the Host and manageability engine (ME).
1172 static void e1000_rar_set_pch_lpt(struct e1000_hw
*hw
, u8
*addr
, u32 index
)
1174 u32 rar_low
, rar_high
;
1177 /* HW expects these in little endian so we reverse the byte order
1178 * from network order (big endian) to little endian
1180 rar_low
= ((u32
)addr
[0] | ((u32
)addr
[1] << 8) |
1181 ((u32
)addr
[2] << 16) | ((u32
)addr
[3] << 24));
1183 rar_high
= ((u32
)addr
[4] | ((u32
)addr
[5] << 8));
1185 /* If MAC address zero, no need to set the AV bit */
1186 if (rar_low
|| rar_high
)
1187 rar_high
|= E1000_RAH_AV
;
1190 ew32(RAL(index
), rar_low
);
1192 ew32(RAH(index
), rar_high
);
1197 /* The manageability engine (ME) can lock certain SHRAR registers that
1198 * it is using - those registers are unavailable for use.
1200 if (index
< hw
->mac
.rar_entry_count
) {
1201 wlock_mac
= er32(FWSM
) & E1000_FWSM_WLOCK_MAC_MASK
;
1202 wlock_mac
>>= E1000_FWSM_WLOCK_MAC_SHIFT
;
1204 /* Check if all SHRAR registers are locked */
1208 if ((wlock_mac
== 0) || (index
<= wlock_mac
)) {
1211 ret_val
= e1000_acquire_swflag_ich8lan(hw
);
1216 ew32(SHRAL_PCH_LPT(index
- 1), rar_low
);
1218 ew32(SHRAH_PCH_LPT(index
- 1), rar_high
);
1221 e1000_release_swflag_ich8lan(hw
);
1223 /* verify the register updates */
1224 if ((er32(SHRAL_PCH_LPT(index
- 1)) == rar_low
) &&
1225 (er32(SHRAH_PCH_LPT(index
- 1)) == rar_high
))
1231 e_dbg("Failed to write receive address at index %d\n", index
);
1235 * e1000_check_reset_block_ich8lan - Check if PHY reset is blocked
1236 * @hw: pointer to the HW structure
1238 * Checks if firmware is blocking the reset of the PHY.
1239 * This is a function pointer entry point only called by
1242 static s32
e1000_check_reset_block_ich8lan(struct e1000_hw
*hw
)
1248 return (fwsm
& E1000_ICH_FWSM_RSPCIPHY
) ? 0 : E1000_BLK_PHY_RESET
;
1252 * e1000_write_smbus_addr - Write SMBus address to PHY needed during Sx states
1253 * @hw: pointer to the HW structure
1255 * Assumes semaphore already acquired.
1258 static s32
e1000_write_smbus_addr(struct e1000_hw
*hw
)
1261 u32 strap
= er32(STRAP
);
1262 u32 freq
= (strap
& E1000_STRAP_SMT_FREQ_MASK
) >>
1263 E1000_STRAP_SMT_FREQ_SHIFT
;
1266 strap
&= E1000_STRAP_SMBUS_ADDRESS_MASK
;
1268 ret_val
= e1000_read_phy_reg_hv_locked(hw
, HV_SMB_ADDR
, &phy_data
);
1272 phy_data
&= ~HV_SMB_ADDR_MASK
;
1273 phy_data
|= (strap
>> E1000_STRAP_SMBUS_ADDRESS_SHIFT
);
1274 phy_data
|= HV_SMB_ADDR_PEC_EN
| HV_SMB_ADDR_VALID
;
1276 if (hw
->phy
.type
== e1000_phy_i217
) {
1277 /* Restore SMBus frequency */
1279 phy_data
&= ~HV_SMB_ADDR_FREQ_MASK
;
1280 phy_data
|= (freq
& (1 << 0)) <<
1281 HV_SMB_ADDR_FREQ_LOW_SHIFT
;
1282 phy_data
|= (freq
& (1 << 1)) <<
1283 (HV_SMB_ADDR_FREQ_HIGH_SHIFT
- 1);
1285 e_dbg("Unsupported SMB frequency in PHY\n");
1289 return e1000_write_phy_reg_hv_locked(hw
, HV_SMB_ADDR
, phy_data
);
1293 * e1000_sw_lcd_config_ich8lan - SW-based LCD Configuration
1294 * @hw: pointer to the HW structure
1296 * SW should configure the LCD from the NVM extended configuration region
1297 * as a workaround for certain parts.
1299 static s32
e1000_sw_lcd_config_ich8lan(struct e1000_hw
*hw
)
1301 struct e1000_phy_info
*phy
= &hw
->phy
;
1302 u32 i
, data
, cnf_size
, cnf_base_addr
, sw_cfg_mask
;
1304 u16 word_addr
, reg_data
, reg_addr
, phy_page
= 0;
1306 /* Initialize the PHY from the NVM on ICH platforms. This
1307 * is needed due to an issue where the NVM configuration is
1308 * not properly autoloaded after power transitions.
1309 * Therefore, after each PHY reset, we will load the
1310 * configuration data out of the NVM manually.
1312 switch (hw
->mac
.type
) {
1314 if (phy
->type
!= e1000_phy_igp_3
)
1317 if ((hw
->adapter
->pdev
->device
== E1000_DEV_ID_ICH8_IGP_AMT
) ||
1318 (hw
->adapter
->pdev
->device
== E1000_DEV_ID_ICH8_IGP_C
)) {
1319 sw_cfg_mask
= E1000_FEXTNVM_SW_CONFIG
;
1326 sw_cfg_mask
= E1000_FEXTNVM_SW_CONFIG_ICH8M
;
1332 ret_val
= hw
->phy
.ops
.acquire(hw
);
1336 data
= er32(FEXTNVM
);
1337 if (!(data
& sw_cfg_mask
))
1340 /* Make sure HW does not configure LCD from PHY
1341 * extended configuration before SW configuration
1343 data
= er32(EXTCNF_CTRL
);
1344 if ((hw
->mac
.type
< e1000_pch2lan
) &&
1345 (data
& E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE
))
1348 cnf_size
= er32(EXTCNF_SIZE
);
1349 cnf_size
&= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_MASK
;
1350 cnf_size
>>= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_SHIFT
;
1354 cnf_base_addr
= data
& E1000_EXTCNF_CTRL_EXT_CNF_POINTER_MASK
;
1355 cnf_base_addr
>>= E1000_EXTCNF_CTRL_EXT_CNF_POINTER_SHIFT
;
1357 if (((hw
->mac
.type
== e1000_pchlan
) &&
1358 !(data
& E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE
)) ||
1359 (hw
->mac
.type
> e1000_pchlan
)) {
1360 /* HW configures the SMBus address and LEDs when the
1361 * OEM and LCD Write Enable bits are set in the NVM.
1362 * When both NVM bits are cleared, SW will configure
1365 ret_val
= e1000_write_smbus_addr(hw
);
1369 data
= er32(LEDCTL
);
1370 ret_val
= e1000_write_phy_reg_hv_locked(hw
, HV_LED_CONFIG
,
1376 /* Configure LCD from extended configuration region. */
1378 /* cnf_base_addr is in DWORD */
1379 word_addr
= (u16
)(cnf_base_addr
<< 1);
1381 for (i
= 0; i
< cnf_size
; i
++) {
1382 ret_val
= e1000_read_nvm(hw
, (word_addr
+ i
* 2), 1,
1387 ret_val
= e1000_read_nvm(hw
, (word_addr
+ i
* 2 + 1),
1392 /* Save off the PHY page for future writes. */
1393 if (reg_addr
== IGP01E1000_PHY_PAGE_SELECT
) {
1394 phy_page
= reg_data
;
1398 reg_addr
&= PHY_REG_MASK
;
1399 reg_addr
|= phy_page
;
1401 ret_val
= e1e_wphy_locked(hw
, (u32
)reg_addr
, reg_data
);
1407 hw
->phy
.ops
.release(hw
);
1412 * e1000_k1_gig_workaround_hv - K1 Si workaround
1413 * @hw: pointer to the HW structure
1414 * @link: link up bool flag
1416 * If K1 is enabled for 1Gbps, the MAC might stall when transitioning
1417 * from a lower speed. This workaround disables K1 whenever link is at 1Gig
1418 * If link is down, the function will restore the default K1 setting located
1421 static s32
e1000_k1_gig_workaround_hv(struct e1000_hw
*hw
, bool link
)
1425 bool k1_enable
= hw
->dev_spec
.ich8lan
.nvm_k1_enabled
;
1427 if (hw
->mac
.type
!= e1000_pchlan
)
1430 /* Wrap the whole flow with the sw flag */
1431 ret_val
= hw
->phy
.ops
.acquire(hw
);
1435 /* Disable K1 when link is 1Gbps, otherwise use the NVM setting */
1437 if (hw
->phy
.type
== e1000_phy_82578
) {
1438 ret_val
= e1e_rphy_locked(hw
, BM_CS_STATUS
,
1443 status_reg
&= BM_CS_STATUS_LINK_UP
|
1444 BM_CS_STATUS_RESOLVED
|
1445 BM_CS_STATUS_SPEED_MASK
;
1447 if (status_reg
== (BM_CS_STATUS_LINK_UP
|
1448 BM_CS_STATUS_RESOLVED
|
1449 BM_CS_STATUS_SPEED_1000
))
1453 if (hw
->phy
.type
== e1000_phy_82577
) {
1454 ret_val
= e1e_rphy_locked(hw
, HV_M_STATUS
, &status_reg
);
1458 status_reg
&= HV_M_STATUS_LINK_UP
|
1459 HV_M_STATUS_AUTONEG_COMPLETE
|
1460 HV_M_STATUS_SPEED_MASK
;
1462 if (status_reg
== (HV_M_STATUS_LINK_UP
|
1463 HV_M_STATUS_AUTONEG_COMPLETE
|
1464 HV_M_STATUS_SPEED_1000
))
1468 /* Link stall fix for link up */
1469 ret_val
= e1e_wphy_locked(hw
, PHY_REG(770, 19), 0x0100);
1474 /* Link stall fix for link down */
1475 ret_val
= e1e_wphy_locked(hw
, PHY_REG(770, 19), 0x4100);
1480 ret_val
= e1000_configure_k1_ich8lan(hw
, k1_enable
);
1483 hw
->phy
.ops
.release(hw
);
1489 * e1000_configure_k1_ich8lan - Configure K1 power state
1490 * @hw: pointer to the HW structure
1491 * @enable: K1 state to configure
1493 * Configure the K1 power state based on the provided parameter.
1494 * Assumes semaphore already acquired.
1496 * Success returns 0, Failure returns -E1000_ERR_PHY (-2)
1498 s32
e1000_configure_k1_ich8lan(struct e1000_hw
*hw
, bool k1_enable
)
1506 ret_val
= e1000e_read_kmrn_reg_locked(hw
, E1000_KMRNCTRLSTA_K1_CONFIG
,
1512 kmrn_reg
|= E1000_KMRNCTRLSTA_K1_ENABLE
;
1514 kmrn_reg
&= ~E1000_KMRNCTRLSTA_K1_ENABLE
;
1516 ret_val
= e1000e_write_kmrn_reg_locked(hw
, E1000_KMRNCTRLSTA_K1_CONFIG
,
1522 ctrl_ext
= er32(CTRL_EXT
);
1523 ctrl_reg
= er32(CTRL
);
1525 reg
= ctrl_reg
& ~(E1000_CTRL_SPD_1000
| E1000_CTRL_SPD_100
);
1526 reg
|= E1000_CTRL_FRCSPD
;
1529 ew32(CTRL_EXT
, ctrl_ext
| E1000_CTRL_EXT_SPD_BYPS
);
1532 ew32(CTRL
, ctrl_reg
);
1533 ew32(CTRL_EXT
, ctrl_ext
);
1541 * e1000_oem_bits_config_ich8lan - SW-based LCD Configuration
1542 * @hw: pointer to the HW structure
1543 * @d0_state: boolean if entering d0 or d3 device state
1545 * SW will configure Gbe Disable and LPLU based on the NVM. The four bits are
1546 * collectively called OEM bits. The OEM Write Enable bit and SW Config bit
1547 * in NVM determines whether HW should configure LPLU and Gbe Disable.
1549 static s32
e1000_oem_bits_config_ich8lan(struct e1000_hw
*hw
, bool d0_state
)
1555 if (hw
->mac
.type
< e1000_pchlan
)
1558 ret_val
= hw
->phy
.ops
.acquire(hw
);
1562 if (hw
->mac
.type
== e1000_pchlan
) {
1563 mac_reg
= er32(EXTCNF_CTRL
);
1564 if (mac_reg
& E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE
)
1568 mac_reg
= er32(FEXTNVM
);
1569 if (!(mac_reg
& E1000_FEXTNVM_SW_CONFIG_ICH8M
))
1572 mac_reg
= er32(PHY_CTRL
);
1574 ret_val
= e1e_rphy_locked(hw
, HV_OEM_BITS
, &oem_reg
);
1578 oem_reg
&= ~(HV_OEM_BITS_GBE_DIS
| HV_OEM_BITS_LPLU
);
1581 if (mac_reg
& E1000_PHY_CTRL_GBE_DISABLE
)
1582 oem_reg
|= HV_OEM_BITS_GBE_DIS
;
1584 if (mac_reg
& E1000_PHY_CTRL_D0A_LPLU
)
1585 oem_reg
|= HV_OEM_BITS_LPLU
;
1587 if (mac_reg
& (E1000_PHY_CTRL_GBE_DISABLE
|
1588 E1000_PHY_CTRL_NOND0A_GBE_DISABLE
))
1589 oem_reg
|= HV_OEM_BITS_GBE_DIS
;
1591 if (mac_reg
& (E1000_PHY_CTRL_D0A_LPLU
|
1592 E1000_PHY_CTRL_NOND0A_LPLU
))
1593 oem_reg
|= HV_OEM_BITS_LPLU
;
1596 /* Set Restart auto-neg to activate the bits */
1597 if ((d0_state
|| (hw
->mac
.type
!= e1000_pchlan
)) &&
1598 !hw
->phy
.ops
.check_reset_block(hw
))
1599 oem_reg
|= HV_OEM_BITS_RESTART_AN
;
1601 ret_val
= e1e_wphy_locked(hw
, HV_OEM_BITS
, oem_reg
);
1604 hw
->phy
.ops
.release(hw
);
1611 * e1000_set_mdio_slow_mode_hv - Set slow MDIO access mode
1612 * @hw: pointer to the HW structure
1614 static s32
e1000_set_mdio_slow_mode_hv(struct e1000_hw
*hw
)
1619 ret_val
= e1e_rphy(hw
, HV_KMRN_MODE_CTRL
, &data
);
1623 data
|= HV_KMRN_MDIO_SLOW
;
1625 ret_val
= e1e_wphy(hw
, HV_KMRN_MODE_CTRL
, data
);
1631 * e1000_hv_phy_workarounds_ich8lan - A series of Phy workarounds to be
1632 * done after every PHY reset.
1634 static s32
e1000_hv_phy_workarounds_ich8lan(struct e1000_hw
*hw
)
1639 if (hw
->mac
.type
!= e1000_pchlan
)
1642 /* Set MDIO slow mode before any other MDIO access */
1643 if (hw
->phy
.type
== e1000_phy_82577
) {
1644 ret_val
= e1000_set_mdio_slow_mode_hv(hw
);
1649 if (((hw
->phy
.type
== e1000_phy_82577
) &&
1650 ((hw
->phy
.revision
== 1) || (hw
->phy
.revision
== 2))) ||
1651 ((hw
->phy
.type
== e1000_phy_82578
) && (hw
->phy
.revision
== 1))) {
1652 /* Disable generation of early preamble */
1653 ret_val
= e1e_wphy(hw
, PHY_REG(769, 25), 0x4431);
1657 /* Preamble tuning for SSC */
1658 ret_val
= e1e_wphy(hw
, HV_KMRN_FIFO_CTRLSTA
, 0xA204);
1663 if (hw
->phy
.type
== e1000_phy_82578
) {
1664 /* Return registers to default by doing a soft reset then
1665 * writing 0x3140 to the control register.
1667 if (hw
->phy
.revision
< 2) {
1668 e1000e_phy_sw_reset(hw
);
1669 ret_val
= e1e_wphy(hw
, MII_BMCR
, 0x3140);
1674 ret_val
= hw
->phy
.ops
.acquire(hw
);
1679 ret_val
= e1000e_write_phy_reg_mdic(hw
, IGP01E1000_PHY_PAGE_SELECT
, 0);
1680 hw
->phy
.ops
.release(hw
);
1684 /* Configure the K1 Si workaround during phy reset assuming there is
1685 * link so that it disables K1 if link is in 1Gbps.
1687 ret_val
= e1000_k1_gig_workaround_hv(hw
, true);
1691 /* Workaround for link disconnects on a busy hub in half duplex */
1692 ret_val
= hw
->phy
.ops
.acquire(hw
);
1695 ret_val
= e1e_rphy_locked(hw
, BM_PORT_GEN_CFG
, &phy_data
);
1698 ret_val
= e1e_wphy_locked(hw
, BM_PORT_GEN_CFG
, phy_data
& 0x00FF);
1702 /* set MSE higher to enable link to stay up when noise is high */
1703 ret_val
= e1000_write_emi_reg_locked(hw
, I82577_MSE_THRESHOLD
, 0x0034);
1705 hw
->phy
.ops
.release(hw
);
1711 * e1000_copy_rx_addrs_to_phy_ich8lan - Copy Rx addresses from MAC to PHY
1712 * @hw: pointer to the HW structure
1714 void e1000_copy_rx_addrs_to_phy_ich8lan(struct e1000_hw
*hw
)
1720 ret_val
= hw
->phy
.ops
.acquire(hw
);
1723 ret_val
= e1000_enable_phy_wakeup_reg_access_bm(hw
, &phy_reg
);
1727 /* Copy both RAL/H (rar_entry_count) and SHRAL/H (+4) to PHY */
1728 for (i
= 0; i
< (hw
->mac
.rar_entry_count
+ 4); i
++) {
1729 mac_reg
= er32(RAL(i
));
1730 hw
->phy
.ops
.write_reg_page(hw
, BM_RAR_L(i
),
1731 (u16
)(mac_reg
& 0xFFFF));
1732 hw
->phy
.ops
.write_reg_page(hw
, BM_RAR_M(i
),
1733 (u16
)((mac_reg
>> 16) & 0xFFFF));
1735 mac_reg
= er32(RAH(i
));
1736 hw
->phy
.ops
.write_reg_page(hw
, BM_RAR_H(i
),
1737 (u16
)(mac_reg
& 0xFFFF));
1738 hw
->phy
.ops
.write_reg_page(hw
, BM_RAR_CTRL(i
),
1739 (u16
)((mac_reg
& E1000_RAH_AV
)
1743 e1000_disable_phy_wakeup_reg_access_bm(hw
, &phy_reg
);
1746 hw
->phy
.ops
.release(hw
);
1750 * e1000_lv_jumbo_workaround_ich8lan - required for jumbo frame operation
1752 * @hw: pointer to the HW structure
1753 * @enable: flag to enable/disable workaround when enabling/disabling jumbos
1755 s32
e1000_lv_jumbo_workaround_ich8lan(struct e1000_hw
*hw
, bool enable
)
1762 if (hw
->mac
.type
< e1000_pch2lan
)
1765 /* disable Rx path while enabling/disabling workaround */
1766 e1e_rphy(hw
, PHY_REG(769, 20), &phy_reg
);
1767 ret_val
= e1e_wphy(hw
, PHY_REG(769, 20), phy_reg
| (1 << 14));
1772 /* Write Rx addresses (rar_entry_count for RAL/H, +4 for
1773 * SHRAL/H) and initial CRC values to the MAC
1775 for (i
= 0; i
< (hw
->mac
.rar_entry_count
+ 4); i
++) {
1776 u8 mac_addr
[ETH_ALEN
] = {0};
1777 u32 addr_high
, addr_low
;
1779 addr_high
= er32(RAH(i
));
1780 if (!(addr_high
& E1000_RAH_AV
))
1782 addr_low
= er32(RAL(i
));
1783 mac_addr
[0] = (addr_low
& 0xFF);
1784 mac_addr
[1] = ((addr_low
>> 8) & 0xFF);
1785 mac_addr
[2] = ((addr_low
>> 16) & 0xFF);
1786 mac_addr
[3] = ((addr_low
>> 24) & 0xFF);
1787 mac_addr
[4] = (addr_high
& 0xFF);
1788 mac_addr
[5] = ((addr_high
>> 8) & 0xFF);
1790 ew32(PCH_RAICC(i
), ~ether_crc_le(ETH_ALEN
, mac_addr
));
1793 /* Write Rx addresses to the PHY */
1794 e1000_copy_rx_addrs_to_phy_ich8lan(hw
);
1796 /* Enable jumbo frame workaround in the MAC */
1797 mac_reg
= er32(FFLT_DBG
);
1798 mac_reg
&= ~(1 << 14);
1799 mac_reg
|= (7 << 15);
1800 ew32(FFLT_DBG
, mac_reg
);
1802 mac_reg
= er32(RCTL
);
1803 mac_reg
|= E1000_RCTL_SECRC
;
1804 ew32(RCTL
, mac_reg
);
1806 ret_val
= e1000e_read_kmrn_reg(hw
,
1807 E1000_KMRNCTRLSTA_CTRL_OFFSET
,
1811 ret_val
= e1000e_write_kmrn_reg(hw
,
1812 E1000_KMRNCTRLSTA_CTRL_OFFSET
,
1816 ret_val
= e1000e_read_kmrn_reg(hw
,
1817 E1000_KMRNCTRLSTA_HD_CTRL
,
1821 data
&= ~(0xF << 8);
1823 ret_val
= e1000e_write_kmrn_reg(hw
,
1824 E1000_KMRNCTRLSTA_HD_CTRL
,
1829 /* Enable jumbo frame workaround in the PHY */
1830 e1e_rphy(hw
, PHY_REG(769, 23), &data
);
1831 data
&= ~(0x7F << 5);
1832 data
|= (0x37 << 5);
1833 ret_val
= e1e_wphy(hw
, PHY_REG(769, 23), data
);
1836 e1e_rphy(hw
, PHY_REG(769, 16), &data
);
1838 ret_val
= e1e_wphy(hw
, PHY_REG(769, 16), data
);
1841 e1e_rphy(hw
, PHY_REG(776, 20), &data
);
1842 data
&= ~(0x3FF << 2);
1843 data
|= (0x1A << 2);
1844 ret_val
= e1e_wphy(hw
, PHY_REG(776, 20), data
);
1847 ret_val
= e1e_wphy(hw
, PHY_REG(776, 23), 0xF100);
1850 e1e_rphy(hw
, HV_PM_CTRL
, &data
);
1851 ret_val
= e1e_wphy(hw
, HV_PM_CTRL
, data
| (1 << 10));
1855 /* Write MAC register values back to h/w defaults */
1856 mac_reg
= er32(FFLT_DBG
);
1857 mac_reg
&= ~(0xF << 14);
1858 ew32(FFLT_DBG
, mac_reg
);
1860 mac_reg
= er32(RCTL
);
1861 mac_reg
&= ~E1000_RCTL_SECRC
;
1862 ew32(RCTL
, mac_reg
);
1864 ret_val
= e1000e_read_kmrn_reg(hw
,
1865 E1000_KMRNCTRLSTA_CTRL_OFFSET
,
1869 ret_val
= e1000e_write_kmrn_reg(hw
,
1870 E1000_KMRNCTRLSTA_CTRL_OFFSET
,
1874 ret_val
= e1000e_read_kmrn_reg(hw
,
1875 E1000_KMRNCTRLSTA_HD_CTRL
,
1879 data
&= ~(0xF << 8);
1881 ret_val
= e1000e_write_kmrn_reg(hw
,
1882 E1000_KMRNCTRLSTA_HD_CTRL
,
1887 /* Write PHY register values back to h/w defaults */
1888 e1e_rphy(hw
, PHY_REG(769, 23), &data
);
1889 data
&= ~(0x7F << 5);
1890 ret_val
= e1e_wphy(hw
, PHY_REG(769, 23), data
);
1893 e1e_rphy(hw
, PHY_REG(769, 16), &data
);
1895 ret_val
= e1e_wphy(hw
, PHY_REG(769, 16), data
);
1898 e1e_rphy(hw
, PHY_REG(776, 20), &data
);
1899 data
&= ~(0x3FF << 2);
1901 ret_val
= e1e_wphy(hw
, PHY_REG(776, 20), data
);
1904 ret_val
= e1e_wphy(hw
, PHY_REG(776, 23), 0x7E00);
1907 e1e_rphy(hw
, HV_PM_CTRL
, &data
);
1908 ret_val
= e1e_wphy(hw
, HV_PM_CTRL
, data
& ~(1 << 10));
1913 /* re-enable Rx path after enabling/disabling workaround */
1914 return e1e_wphy(hw
, PHY_REG(769, 20), phy_reg
& ~(1 << 14));
1918 * e1000_lv_phy_workarounds_ich8lan - A series of Phy workarounds to be
1919 * done after every PHY reset.
1921 static s32
e1000_lv_phy_workarounds_ich8lan(struct e1000_hw
*hw
)
1925 if (hw
->mac
.type
!= e1000_pch2lan
)
1928 /* Set MDIO slow mode before any other MDIO access */
1929 ret_val
= e1000_set_mdio_slow_mode_hv(hw
);
1933 ret_val
= hw
->phy
.ops
.acquire(hw
);
1936 /* set MSE higher to enable link to stay up when noise is high */
1937 ret_val
= e1000_write_emi_reg_locked(hw
, I82579_MSE_THRESHOLD
, 0x0034);
1940 /* drop link after 5 times MSE threshold was reached */
1941 ret_val
= e1000_write_emi_reg_locked(hw
, I82579_MSE_LINK_DOWN
, 0x0005);
1943 hw
->phy
.ops
.release(hw
);
1949 * e1000_k1_gig_workaround_lv - K1 Si workaround
1950 * @hw: pointer to the HW structure
1952 * Workaround to set the K1 beacon duration for 82579 parts
1954 static s32
e1000_k1_workaround_lv(struct e1000_hw
*hw
)
1961 if (hw
->mac
.type
!= e1000_pch2lan
)
1964 /* Set K1 beacon duration based on 1Gbps speed or otherwise */
1965 ret_val
= e1e_rphy(hw
, HV_M_STATUS
, &status_reg
);
1969 if ((status_reg
& (HV_M_STATUS_LINK_UP
| HV_M_STATUS_AUTONEG_COMPLETE
))
1970 == (HV_M_STATUS_LINK_UP
| HV_M_STATUS_AUTONEG_COMPLETE
)) {
1971 mac_reg
= er32(FEXTNVM4
);
1972 mac_reg
&= ~E1000_FEXTNVM4_BEACON_DURATION_MASK
;
1974 ret_val
= e1e_rphy(hw
, I82579_LPI_CTRL
, &phy_reg
);
1978 if (status_reg
& HV_M_STATUS_SPEED_1000
) {
1981 mac_reg
|= E1000_FEXTNVM4_BEACON_DURATION_8USEC
;
1982 phy_reg
&= ~I82579_LPI_CTRL_FORCE_PLL_LOCK_COUNT
;
1983 /* LV 1G Packet drop issue wa */
1984 ret_val
= e1e_rphy(hw
, HV_PM_CTRL
, &pm_phy_reg
);
1987 pm_phy_reg
&= ~HV_PM_CTRL_PLL_STOP_IN_K1_GIGA
;
1988 ret_val
= e1e_wphy(hw
, HV_PM_CTRL
, pm_phy_reg
);
1992 mac_reg
|= E1000_FEXTNVM4_BEACON_DURATION_16USEC
;
1993 phy_reg
|= I82579_LPI_CTRL_FORCE_PLL_LOCK_COUNT
;
1995 ew32(FEXTNVM4
, mac_reg
);
1996 ret_val
= e1e_wphy(hw
, I82579_LPI_CTRL
, phy_reg
);
2003 * e1000_gate_hw_phy_config_ich8lan - disable PHY config via hardware
2004 * @hw: pointer to the HW structure
2005 * @gate: boolean set to true to gate, false to ungate
2007 * Gate/ungate the automatic PHY configuration via hardware; perform
2008 * the configuration via software instead.
2010 static void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw
*hw
, bool gate
)
2014 if (hw
->mac
.type
< e1000_pch2lan
)
2017 extcnf_ctrl
= er32(EXTCNF_CTRL
);
2020 extcnf_ctrl
|= E1000_EXTCNF_CTRL_GATE_PHY_CFG
;
2022 extcnf_ctrl
&= ~E1000_EXTCNF_CTRL_GATE_PHY_CFG
;
2024 ew32(EXTCNF_CTRL
, extcnf_ctrl
);
2028 * e1000_lan_init_done_ich8lan - Check for PHY config completion
2029 * @hw: pointer to the HW structure
2031 * Check the appropriate indication the MAC has finished configuring the
2032 * PHY after a software reset.
2034 static void e1000_lan_init_done_ich8lan(struct e1000_hw
*hw
)
2036 u32 data
, loop
= E1000_ICH8_LAN_INIT_TIMEOUT
;
2038 /* Wait for basic configuration completes before proceeding */
2040 data
= er32(STATUS
);
2041 data
&= E1000_STATUS_LAN_INIT_DONE
;
2043 } while ((!data
) && --loop
);
2045 /* If basic configuration is incomplete before the above loop
2046 * count reaches 0, loading the configuration from NVM will
2047 * leave the PHY in a bad state possibly resulting in no link.
2050 e_dbg("LAN_INIT_DONE not set, increase timeout\n");
2052 /* Clear the Init Done bit for the next init event */
2053 data
= er32(STATUS
);
2054 data
&= ~E1000_STATUS_LAN_INIT_DONE
;
2059 * e1000_post_phy_reset_ich8lan - Perform steps required after a PHY reset
2060 * @hw: pointer to the HW structure
2062 static s32
e1000_post_phy_reset_ich8lan(struct e1000_hw
*hw
)
2067 if (hw
->phy
.ops
.check_reset_block(hw
))
2070 /* Allow time for h/w to get to quiescent state after reset */
2071 usleep_range(10000, 20000);
2073 /* Perform any necessary post-reset workarounds */
2074 switch (hw
->mac
.type
) {
2076 ret_val
= e1000_hv_phy_workarounds_ich8lan(hw
);
2081 ret_val
= e1000_lv_phy_workarounds_ich8lan(hw
);
2089 /* Clear the host wakeup bit after lcd reset */
2090 if (hw
->mac
.type
>= e1000_pchlan
) {
2091 e1e_rphy(hw
, BM_PORT_GEN_CFG
, ®
);
2092 reg
&= ~BM_WUC_HOST_WU_BIT
;
2093 e1e_wphy(hw
, BM_PORT_GEN_CFG
, reg
);
2096 /* Configure the LCD with the extended configuration region in NVM */
2097 ret_val
= e1000_sw_lcd_config_ich8lan(hw
);
2101 /* Configure the LCD with the OEM bits in NVM */
2102 ret_val
= e1000_oem_bits_config_ich8lan(hw
, true);
2104 if (hw
->mac
.type
== e1000_pch2lan
) {
2105 /* Ungate automatic PHY configuration on non-managed 82579 */
2106 if (!(er32(FWSM
) & E1000_ICH_FWSM_FW_VALID
)) {
2107 usleep_range(10000, 20000);
2108 e1000_gate_hw_phy_config_ich8lan(hw
, false);
2111 /* Set EEE LPI Update Timer to 200usec */
2112 ret_val
= hw
->phy
.ops
.acquire(hw
);
2115 ret_val
= e1000_write_emi_reg_locked(hw
,
2116 I82579_LPI_UPDATE_TIMER
,
2118 hw
->phy
.ops
.release(hw
);
2125 * e1000_phy_hw_reset_ich8lan - Performs a PHY reset
2126 * @hw: pointer to the HW structure
2129 * This is a function pointer entry point called by drivers
2130 * or other shared routines.
2132 static s32
e1000_phy_hw_reset_ich8lan(struct e1000_hw
*hw
)
2136 /* Gate automatic PHY configuration by hardware on non-managed 82579 */
2137 if ((hw
->mac
.type
== e1000_pch2lan
) &&
2138 !(er32(FWSM
) & E1000_ICH_FWSM_FW_VALID
))
2139 e1000_gate_hw_phy_config_ich8lan(hw
, true);
2141 ret_val
= e1000e_phy_hw_reset_generic(hw
);
2145 return e1000_post_phy_reset_ich8lan(hw
);
2149 * e1000_set_lplu_state_pchlan - Set Low Power Link Up state
2150 * @hw: pointer to the HW structure
2151 * @active: true to enable LPLU, false to disable
2153 * Sets the LPLU state according to the active flag. For PCH, if OEM write
2154 * bit are disabled in the NVM, writing the LPLU bits in the MAC will not set
2155 * the phy speed. This function will manually set the LPLU bit and restart
2156 * auto-neg as hw would do. D3 and D0 LPLU will call the same function
2157 * since it configures the same bit.
2159 static s32
e1000_set_lplu_state_pchlan(struct e1000_hw
*hw
, bool active
)
2164 ret_val
= e1e_rphy(hw
, HV_OEM_BITS
, &oem_reg
);
2169 oem_reg
|= HV_OEM_BITS_LPLU
;
2171 oem_reg
&= ~HV_OEM_BITS_LPLU
;
2173 if (!hw
->phy
.ops
.check_reset_block(hw
))
2174 oem_reg
|= HV_OEM_BITS_RESTART_AN
;
2176 return e1e_wphy(hw
, HV_OEM_BITS
, oem_reg
);
2180 * e1000_set_d0_lplu_state_ich8lan - Set Low Power Linkup D0 state
2181 * @hw: pointer to the HW structure
2182 * @active: true to enable LPLU, false to disable
2184 * Sets the LPLU D0 state according to the active flag. When
2185 * activating LPLU this function also disables smart speed
2186 * and vice versa. LPLU will not be activated unless the
2187 * device autonegotiation advertisement meets standards of
2188 * either 10 or 10/100 or 10/100/1000 at all duplexes.
2189 * This is a function pointer entry point only called by
2190 * PHY setup routines.
2192 static s32
e1000_set_d0_lplu_state_ich8lan(struct e1000_hw
*hw
, bool active
)
2194 struct e1000_phy_info
*phy
= &hw
->phy
;
2199 if (phy
->type
== e1000_phy_ife
)
2202 phy_ctrl
= er32(PHY_CTRL
);
2205 phy_ctrl
|= E1000_PHY_CTRL_D0A_LPLU
;
2206 ew32(PHY_CTRL
, phy_ctrl
);
2208 if (phy
->type
!= e1000_phy_igp_3
)
2211 /* Call gig speed drop workaround on LPLU before accessing
2214 if (hw
->mac
.type
== e1000_ich8lan
)
2215 e1000e_gig_downshift_workaround_ich8lan(hw
);
2217 /* When LPLU is enabled, we should disable SmartSpeed */
2218 ret_val
= e1e_rphy(hw
, IGP01E1000_PHY_PORT_CONFIG
, &data
);
2221 data
&= ~IGP01E1000_PSCFR_SMART_SPEED
;
2222 ret_val
= e1e_wphy(hw
, IGP01E1000_PHY_PORT_CONFIG
, data
);
2226 phy_ctrl
&= ~E1000_PHY_CTRL_D0A_LPLU
;
2227 ew32(PHY_CTRL
, phy_ctrl
);
2229 if (phy
->type
!= e1000_phy_igp_3
)
2232 /* LPLU and SmartSpeed are mutually exclusive. LPLU is used
2233 * during Dx states where the power conservation is most
2234 * important. During driver activity we should enable
2235 * SmartSpeed, so performance is maintained.
2237 if (phy
->smart_speed
== e1000_smart_speed_on
) {
2238 ret_val
= e1e_rphy(hw
, IGP01E1000_PHY_PORT_CONFIG
,
2243 data
|= IGP01E1000_PSCFR_SMART_SPEED
;
2244 ret_val
= e1e_wphy(hw
, IGP01E1000_PHY_PORT_CONFIG
,
2248 } else if (phy
->smart_speed
== e1000_smart_speed_off
) {
2249 ret_val
= e1e_rphy(hw
, IGP01E1000_PHY_PORT_CONFIG
,
2254 data
&= ~IGP01E1000_PSCFR_SMART_SPEED
;
2255 ret_val
= e1e_wphy(hw
, IGP01E1000_PHY_PORT_CONFIG
,
2266 * e1000_set_d3_lplu_state_ich8lan - Set Low Power Linkup D3 state
2267 * @hw: pointer to the HW structure
2268 * @active: true to enable LPLU, false to disable
2270 * Sets the LPLU D3 state according to the active flag. When
2271 * activating LPLU this function also disables smart speed
2272 * and vice versa. LPLU will not be activated unless the
2273 * device autonegotiation advertisement meets standards of
2274 * either 10 or 10/100 or 10/100/1000 at all duplexes.
2275 * This is a function pointer entry point only called by
2276 * PHY setup routines.
2278 static s32
e1000_set_d3_lplu_state_ich8lan(struct e1000_hw
*hw
, bool active
)
2280 struct e1000_phy_info
*phy
= &hw
->phy
;
2285 phy_ctrl
= er32(PHY_CTRL
);
2288 phy_ctrl
&= ~E1000_PHY_CTRL_NOND0A_LPLU
;
2289 ew32(PHY_CTRL
, phy_ctrl
);
2291 if (phy
->type
!= e1000_phy_igp_3
)
2294 /* LPLU and SmartSpeed are mutually exclusive. LPLU is used
2295 * during Dx states where the power conservation is most
2296 * important. During driver activity we should enable
2297 * SmartSpeed, so performance is maintained.
2299 if (phy
->smart_speed
== e1000_smart_speed_on
) {
2300 ret_val
= e1e_rphy(hw
, IGP01E1000_PHY_PORT_CONFIG
,
2305 data
|= IGP01E1000_PSCFR_SMART_SPEED
;
2306 ret_val
= e1e_wphy(hw
, IGP01E1000_PHY_PORT_CONFIG
,
2310 } else if (phy
->smart_speed
== e1000_smart_speed_off
) {
2311 ret_val
= e1e_rphy(hw
, IGP01E1000_PHY_PORT_CONFIG
,
2316 data
&= ~IGP01E1000_PSCFR_SMART_SPEED
;
2317 ret_val
= e1e_wphy(hw
, IGP01E1000_PHY_PORT_CONFIG
,
2322 } else if ((phy
->autoneg_advertised
== E1000_ALL_SPEED_DUPLEX
) ||
2323 (phy
->autoneg_advertised
== E1000_ALL_NOT_GIG
) ||
2324 (phy
->autoneg_advertised
== E1000_ALL_10_SPEED
)) {
2325 phy_ctrl
|= E1000_PHY_CTRL_NOND0A_LPLU
;
2326 ew32(PHY_CTRL
, phy_ctrl
);
2328 if (phy
->type
!= e1000_phy_igp_3
)
2331 /* Call gig speed drop workaround on LPLU before accessing
2334 if (hw
->mac
.type
== e1000_ich8lan
)
2335 e1000e_gig_downshift_workaround_ich8lan(hw
);
2337 /* When LPLU is enabled, we should disable SmartSpeed */
2338 ret_val
= e1e_rphy(hw
, IGP01E1000_PHY_PORT_CONFIG
, &data
);
2342 data
&= ~IGP01E1000_PSCFR_SMART_SPEED
;
2343 ret_val
= e1e_wphy(hw
, IGP01E1000_PHY_PORT_CONFIG
, data
);
2350 * e1000_valid_nvm_bank_detect_ich8lan - finds out the valid bank 0 or 1
2351 * @hw: pointer to the HW structure
2352 * @bank: pointer to the variable that returns the active bank
2354 * Reads signature byte from the NVM using the flash access registers.
2355 * Word 0x13 bits 15:14 = 10b indicate a valid signature for that bank.
2357 static s32
e1000_valid_nvm_bank_detect_ich8lan(struct e1000_hw
*hw
, u32
*bank
)
2360 struct e1000_nvm_info
*nvm
= &hw
->nvm
;
2361 u32 bank1_offset
= nvm
->flash_bank_size
* sizeof(u16
);
2362 u32 act_offset
= E1000_ICH_NVM_SIG_WORD
* 2 + 1;
2366 switch (hw
->mac
.type
) {
2370 if ((eecd
& E1000_EECD_SEC1VAL_VALID_MASK
) ==
2371 E1000_EECD_SEC1VAL_VALID_MASK
) {
2372 if (eecd
& E1000_EECD_SEC1VAL
)
2379 e_dbg("Unable to determine valid NVM bank via EEC - reading flash signature\n");
2382 /* set bank to 0 in case flash read fails */
2386 ret_val
= e1000_read_flash_byte_ich8lan(hw
, act_offset
,
2390 if ((sig_byte
& E1000_ICH_NVM_VALID_SIG_MASK
) ==
2391 E1000_ICH_NVM_SIG_VALUE
) {
2397 ret_val
= e1000_read_flash_byte_ich8lan(hw
, act_offset
+
2402 if ((sig_byte
& E1000_ICH_NVM_VALID_SIG_MASK
) ==
2403 E1000_ICH_NVM_SIG_VALUE
) {
2408 e_dbg("ERROR: No valid NVM bank present\n");
2409 return -E1000_ERR_NVM
;
2414 * e1000_read_nvm_ich8lan - Read word(s) from the NVM
2415 * @hw: pointer to the HW structure
2416 * @offset: The offset (in bytes) of the word(s) to read.
2417 * @words: Size of data to read in words
2418 * @data: Pointer to the word(s) to read at offset.
2420 * Reads a word(s) from the NVM using the flash access registers.
2422 static s32
e1000_read_nvm_ich8lan(struct e1000_hw
*hw
, u16 offset
, u16 words
,
2425 struct e1000_nvm_info
*nvm
= &hw
->nvm
;
2426 struct e1000_dev_spec_ich8lan
*dev_spec
= &hw
->dev_spec
.ich8lan
;
2432 if ((offset
>= nvm
->word_size
) || (words
> nvm
->word_size
- offset
) ||
2434 e_dbg("nvm parameter(s) out of bounds\n");
2435 ret_val
= -E1000_ERR_NVM
;
2439 nvm
->ops
.acquire(hw
);
2441 ret_val
= e1000_valid_nvm_bank_detect_ich8lan(hw
, &bank
);
2443 e_dbg("Could not detect valid bank, assuming bank 0\n");
2447 act_offset
= (bank
) ? nvm
->flash_bank_size
: 0;
2448 act_offset
+= offset
;
2451 for (i
= 0; i
< words
; i
++) {
2452 if (dev_spec
->shadow_ram
[offset
+i
].modified
) {
2453 data
[i
] = dev_spec
->shadow_ram
[offset
+i
].value
;
2455 ret_val
= e1000_read_flash_word_ich8lan(hw
,
2464 nvm
->ops
.release(hw
);
2468 e_dbg("NVM read error: %d\n", ret_val
);
2474 * e1000_flash_cycle_init_ich8lan - Initialize flash
2475 * @hw: pointer to the HW structure
2477 * This function does initial flash setup so that a new read/write/erase cycle
2480 static s32
e1000_flash_cycle_init_ich8lan(struct e1000_hw
*hw
)
2482 union ich8_hws_flash_status hsfsts
;
2483 s32 ret_val
= -E1000_ERR_NVM
;
2485 hsfsts
.regval
= er16flash(ICH_FLASH_HSFSTS
);
2487 /* Check if the flash descriptor is valid */
2488 if (!hsfsts
.hsf_status
.fldesvalid
) {
2489 e_dbg("Flash descriptor invalid. SW Sequencing must be used.\n");
2490 return -E1000_ERR_NVM
;
2493 /* Clear FCERR and DAEL in hw status by writing 1 */
2494 hsfsts
.hsf_status
.flcerr
= 1;
2495 hsfsts
.hsf_status
.dael
= 1;
2497 ew16flash(ICH_FLASH_HSFSTS
, hsfsts
.regval
);
2499 /* Either we should have a hardware SPI cycle in progress
2500 * bit to check against, in order to start a new cycle or
2501 * FDONE bit should be changed in the hardware so that it
2502 * is 1 after hardware reset, which can then be used as an
2503 * indication whether a cycle is in progress or has been
2507 if (!hsfsts
.hsf_status
.flcinprog
) {
2508 /* There is no cycle running at present,
2509 * so we can start a cycle.
2510 * Begin by setting Flash Cycle Done.
2512 hsfsts
.hsf_status
.flcdone
= 1;
2513 ew16flash(ICH_FLASH_HSFSTS
, hsfsts
.regval
);
2518 /* Otherwise poll for sometime so the current
2519 * cycle has a chance to end before giving up.
2521 for (i
= 0; i
< ICH_FLASH_READ_COMMAND_TIMEOUT
; i
++) {
2522 hsfsts
.regval
= er16flash(ICH_FLASH_HSFSTS
);
2523 if (!hsfsts
.hsf_status
.flcinprog
) {
2530 /* Successful in waiting for previous cycle to timeout,
2531 * now set the Flash Cycle Done.
2533 hsfsts
.hsf_status
.flcdone
= 1;
2534 ew16flash(ICH_FLASH_HSFSTS
, hsfsts
.regval
);
2536 e_dbg("Flash controller busy, cannot get access\n");
2544 * e1000_flash_cycle_ich8lan - Starts flash cycle (read/write/erase)
2545 * @hw: pointer to the HW structure
2546 * @timeout: maximum time to wait for completion
2548 * This function starts a flash cycle and waits for its completion.
2550 static s32
e1000_flash_cycle_ich8lan(struct e1000_hw
*hw
, u32 timeout
)
2552 union ich8_hws_flash_ctrl hsflctl
;
2553 union ich8_hws_flash_status hsfsts
;
2556 /* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */
2557 hsflctl
.regval
= er16flash(ICH_FLASH_HSFCTL
);
2558 hsflctl
.hsf_ctrl
.flcgo
= 1;
2559 ew16flash(ICH_FLASH_HSFCTL
, hsflctl
.regval
);
2561 /* wait till FDONE bit is set to 1 */
2563 hsfsts
.regval
= er16flash(ICH_FLASH_HSFSTS
);
2564 if (hsfsts
.hsf_status
.flcdone
)
2567 } while (i
++ < timeout
);
2569 if (hsfsts
.hsf_status
.flcdone
&& !hsfsts
.hsf_status
.flcerr
)
2572 return -E1000_ERR_NVM
;
2576 * e1000_read_flash_word_ich8lan - Read word from flash
2577 * @hw: pointer to the HW structure
2578 * @offset: offset to data location
2579 * @data: pointer to the location for storing the data
2581 * Reads the flash word at offset into data. Offset is converted
2582 * to bytes before read.
2584 static s32
e1000_read_flash_word_ich8lan(struct e1000_hw
*hw
, u32 offset
,
2587 /* Must convert offset into bytes. */
2590 return e1000_read_flash_data_ich8lan(hw
, offset
, 2, data
);
2594 * e1000_read_flash_byte_ich8lan - Read byte from flash
2595 * @hw: pointer to the HW structure
2596 * @offset: The offset of the byte to read.
2597 * @data: Pointer to a byte to store the value read.
2599 * Reads a single byte from the NVM using the flash access registers.
2601 static s32
e1000_read_flash_byte_ich8lan(struct e1000_hw
*hw
, u32 offset
,
2607 ret_val
= e1000_read_flash_data_ich8lan(hw
, offset
, 1, &word
);
2617 * e1000_read_flash_data_ich8lan - Read byte or word from NVM
2618 * @hw: pointer to the HW structure
2619 * @offset: The offset (in bytes) of the byte or word to read.
2620 * @size: Size of data to read, 1=byte 2=word
2621 * @data: Pointer to the word to store the value read.
2623 * Reads a byte or word from the NVM using the flash access registers.
2625 static s32
e1000_read_flash_data_ich8lan(struct e1000_hw
*hw
, u32 offset
,
2628 union ich8_hws_flash_status hsfsts
;
2629 union ich8_hws_flash_ctrl hsflctl
;
2630 u32 flash_linear_addr
;
2632 s32 ret_val
= -E1000_ERR_NVM
;
2635 if (size
< 1 || size
> 2 || offset
> ICH_FLASH_LINEAR_ADDR_MASK
)
2636 return -E1000_ERR_NVM
;
2638 flash_linear_addr
= (ICH_FLASH_LINEAR_ADDR_MASK
& offset
) +
2639 hw
->nvm
.flash_base_addr
;
2644 ret_val
= e1000_flash_cycle_init_ich8lan(hw
);
2648 hsflctl
.regval
= er16flash(ICH_FLASH_HSFCTL
);
2649 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
2650 hsflctl
.hsf_ctrl
.fldbcount
= size
- 1;
2651 hsflctl
.hsf_ctrl
.flcycle
= ICH_CYCLE_READ
;
2652 ew16flash(ICH_FLASH_HSFCTL
, hsflctl
.regval
);
2654 ew32flash(ICH_FLASH_FADDR
, flash_linear_addr
);
2656 ret_val
= e1000_flash_cycle_ich8lan(hw
,
2657 ICH_FLASH_READ_COMMAND_TIMEOUT
);
2659 /* Check if FCERR is set to 1, if set to 1, clear it
2660 * and try the whole sequence a few more times, else
2661 * read in (shift in) the Flash Data0, the order is
2662 * least significant byte first msb to lsb
2665 flash_data
= er32flash(ICH_FLASH_FDATA0
);
2667 *data
= (u8
)(flash_data
& 0x000000FF);
2669 *data
= (u16
)(flash_data
& 0x0000FFFF);
2672 /* If we've gotten here, then things are probably
2673 * completely hosed, but if the error condition is
2674 * detected, it won't hurt to give it another try...
2675 * ICH_FLASH_CYCLE_REPEAT_COUNT times.
2677 hsfsts
.regval
= er16flash(ICH_FLASH_HSFSTS
);
2678 if (hsfsts
.hsf_status
.flcerr
) {
2679 /* Repeat for some time before giving up. */
2681 } else if (!hsfsts
.hsf_status
.flcdone
) {
2682 e_dbg("Timeout error - flash cycle did not complete.\n");
2686 } while (count
++ < ICH_FLASH_CYCLE_REPEAT_COUNT
);
2692 * e1000_write_nvm_ich8lan - Write word(s) to the NVM
2693 * @hw: pointer to the HW structure
2694 * @offset: The offset (in bytes) of the word(s) to write.
2695 * @words: Size of data to write in words
2696 * @data: Pointer to the word(s) to write at offset.
2698 * Writes a byte or word to the NVM using the flash access registers.
2700 static s32
e1000_write_nvm_ich8lan(struct e1000_hw
*hw
, u16 offset
, u16 words
,
2703 struct e1000_nvm_info
*nvm
= &hw
->nvm
;
2704 struct e1000_dev_spec_ich8lan
*dev_spec
= &hw
->dev_spec
.ich8lan
;
2707 if ((offset
>= nvm
->word_size
) || (words
> nvm
->word_size
- offset
) ||
2709 e_dbg("nvm parameter(s) out of bounds\n");
2710 return -E1000_ERR_NVM
;
2713 nvm
->ops
.acquire(hw
);
2715 for (i
= 0; i
< words
; i
++) {
2716 dev_spec
->shadow_ram
[offset
+i
].modified
= true;
2717 dev_spec
->shadow_ram
[offset
+i
].value
= data
[i
];
2720 nvm
->ops
.release(hw
);
2726 * e1000_update_nvm_checksum_ich8lan - Update the checksum for NVM
2727 * @hw: pointer to the HW structure
2729 * The NVM checksum is updated by calling the generic update_nvm_checksum,
2730 * which writes the checksum to the shadow ram. The changes in the shadow
2731 * ram are then committed to the EEPROM by processing each bank at a time
2732 * checking for the modified bit and writing only the pending changes.
2733 * After a successful commit, the shadow ram is cleared and is ready for
2736 static s32
e1000_update_nvm_checksum_ich8lan(struct e1000_hw
*hw
)
2738 struct e1000_nvm_info
*nvm
= &hw
->nvm
;
2739 struct e1000_dev_spec_ich8lan
*dev_spec
= &hw
->dev_spec
.ich8lan
;
2740 u32 i
, act_offset
, new_bank_offset
, old_bank_offset
, bank
;
2744 ret_val
= e1000e_update_nvm_checksum_generic(hw
);
2748 if (nvm
->type
!= e1000_nvm_flash_sw
)
2751 nvm
->ops
.acquire(hw
);
2753 /* We're writing to the opposite bank so if we're on bank 1,
2754 * write to bank 0 etc. We also need to erase the segment that
2755 * is going to be written
2757 ret_val
= e1000_valid_nvm_bank_detect_ich8lan(hw
, &bank
);
2759 e_dbg("Could not detect valid bank, assuming bank 0\n");
2764 new_bank_offset
= nvm
->flash_bank_size
;
2765 old_bank_offset
= 0;
2766 ret_val
= e1000_erase_flash_bank_ich8lan(hw
, 1);
2770 old_bank_offset
= nvm
->flash_bank_size
;
2771 new_bank_offset
= 0;
2772 ret_val
= e1000_erase_flash_bank_ich8lan(hw
, 0);
2777 for (i
= 0; i
< E1000_ICH8_SHADOW_RAM_WORDS
; i
++) {
2778 /* Determine whether to write the value stored
2779 * in the other NVM bank or a modified value stored
2782 if (dev_spec
->shadow_ram
[i
].modified
) {
2783 data
= dev_spec
->shadow_ram
[i
].value
;
2785 ret_val
= e1000_read_flash_word_ich8lan(hw
, i
+
2792 /* If the word is 0x13, then make sure the signature bits
2793 * (15:14) are 11b until the commit has completed.
2794 * This will allow us to write 10b which indicates the
2795 * signature is valid. We want to do this after the write
2796 * has completed so that we don't mark the segment valid
2797 * while the write is still in progress
2799 if (i
== E1000_ICH_NVM_SIG_WORD
)
2800 data
|= E1000_ICH_NVM_SIG_MASK
;
2802 /* Convert offset to bytes. */
2803 act_offset
= (i
+ new_bank_offset
) << 1;
2806 /* Write the bytes to the new bank. */
2807 ret_val
= e1000_retry_write_flash_byte_ich8lan(hw
,
2814 ret_val
= e1000_retry_write_flash_byte_ich8lan(hw
,
2821 /* Don't bother writing the segment valid bits if sector
2822 * programming failed.
2825 /* Possibly read-only, see e1000e_write_protect_nvm_ich8lan() */
2826 e_dbg("Flash commit failed.\n");
2830 /* Finally validate the new segment by setting bit 15:14
2831 * to 10b in word 0x13 , this can be done without an
2832 * erase as well since these bits are 11 to start with
2833 * and we need to change bit 14 to 0b
2835 act_offset
= new_bank_offset
+ E1000_ICH_NVM_SIG_WORD
;
2836 ret_val
= e1000_read_flash_word_ich8lan(hw
, act_offset
, &data
);
2841 ret_val
= e1000_retry_write_flash_byte_ich8lan(hw
,
2847 /* And invalidate the previously valid segment by setting
2848 * its signature word (0x13) high_byte to 0b. This can be
2849 * done without an erase because flash erase sets all bits
2850 * to 1's. We can write 1's to 0's without an erase
2852 act_offset
= (old_bank_offset
+ E1000_ICH_NVM_SIG_WORD
) * 2 + 1;
2853 ret_val
= e1000_retry_write_flash_byte_ich8lan(hw
, act_offset
, 0);
2857 /* Great! Everything worked, we can now clear the cached entries. */
2858 for (i
= 0; i
< E1000_ICH8_SHADOW_RAM_WORDS
; i
++) {
2859 dev_spec
->shadow_ram
[i
].modified
= false;
2860 dev_spec
->shadow_ram
[i
].value
= 0xFFFF;
2864 nvm
->ops
.release(hw
);
2866 /* Reload the EEPROM, or else modifications will not appear
2867 * until after the next adapter reset.
2870 nvm
->ops
.reload(hw
);
2871 usleep_range(10000, 20000);
2876 e_dbg("NVM update error: %d\n", ret_val
);
2882 * e1000_validate_nvm_checksum_ich8lan - Validate EEPROM checksum
2883 * @hw: pointer to the HW structure
2885 * Check to see if checksum needs to be fixed by reading bit 6 in word 0x19.
2886 * If the bit is 0, that the EEPROM had been modified, but the checksum was not
2887 * calculated, in which case we need to calculate the checksum and set bit 6.
2889 static s32
e1000_validate_nvm_checksum_ich8lan(struct e1000_hw
*hw
)
2894 u16 valid_csum_mask
;
2896 /* Read NVM and check Invalid Image CSUM bit. If this bit is 0,
2897 * the checksum needs to be fixed. This bit is an indication that
2898 * the NVM was prepared by OEM software and did not calculate
2899 * the checksum...a likely scenario.
2901 switch (hw
->mac
.type
) {
2904 valid_csum_mask
= NVM_COMPAT_VALID_CSUM
;
2907 word
= NVM_FUTURE_INIT_WORD1
;
2908 valid_csum_mask
= NVM_FUTURE_INIT_WORD1_VALID_CSUM
;
2912 ret_val
= e1000_read_nvm(hw
, word
, 1, &data
);
2916 if (!(data
& valid_csum_mask
)) {
2917 data
|= valid_csum_mask
;
2918 ret_val
= e1000_write_nvm(hw
, word
, 1, &data
);
2921 ret_val
= e1000e_update_nvm_checksum(hw
);
2926 return e1000e_validate_nvm_checksum_generic(hw
);
2930 * e1000e_write_protect_nvm_ich8lan - Make the NVM read-only
2931 * @hw: pointer to the HW structure
2933 * To prevent malicious write/erase of the NVM, set it to be read-only
2934 * so that the hardware ignores all write/erase cycles of the NVM via
2935 * the flash control registers. The shadow-ram copy of the NVM will
2936 * still be updated, however any updates to this copy will not stick
2937 * across driver reloads.
2939 void e1000e_write_protect_nvm_ich8lan(struct e1000_hw
*hw
)
2941 struct e1000_nvm_info
*nvm
= &hw
->nvm
;
2942 union ich8_flash_protected_range pr0
;
2943 union ich8_hws_flash_status hsfsts
;
2946 nvm
->ops
.acquire(hw
);
2948 gfpreg
= er32flash(ICH_FLASH_GFPREG
);
2950 /* Write-protect GbE Sector of NVM */
2951 pr0
.regval
= er32flash(ICH_FLASH_PR0
);
2952 pr0
.range
.base
= gfpreg
& FLASH_GFPREG_BASE_MASK
;
2953 pr0
.range
.limit
= ((gfpreg
>> 16) & FLASH_GFPREG_BASE_MASK
);
2954 pr0
.range
.wpe
= true;
2955 ew32flash(ICH_FLASH_PR0
, pr0
.regval
);
2957 /* Lock down a subset of GbE Flash Control Registers, e.g.
2958 * PR0 to prevent the write-protection from being lifted.
2959 * Once FLOCKDN is set, the registers protected by it cannot
2960 * be written until FLOCKDN is cleared by a hardware reset.
2962 hsfsts
.regval
= er16flash(ICH_FLASH_HSFSTS
);
2963 hsfsts
.hsf_status
.flockdn
= true;
2964 ew32flash(ICH_FLASH_HSFSTS
, hsfsts
.regval
);
2966 nvm
->ops
.release(hw
);
2970 * e1000_write_flash_data_ich8lan - Writes bytes to the NVM
2971 * @hw: pointer to the HW structure
2972 * @offset: The offset (in bytes) of the byte/word to read.
2973 * @size: Size of data to read, 1=byte 2=word
2974 * @data: The byte(s) to write to the NVM.
2976 * Writes one/two bytes to the NVM using the flash access registers.
2978 static s32
e1000_write_flash_data_ich8lan(struct e1000_hw
*hw
, u32 offset
,
2981 union ich8_hws_flash_status hsfsts
;
2982 union ich8_hws_flash_ctrl hsflctl
;
2983 u32 flash_linear_addr
;
2988 if (size
< 1 || size
> 2 || data
> size
* 0xff ||
2989 offset
> ICH_FLASH_LINEAR_ADDR_MASK
)
2990 return -E1000_ERR_NVM
;
2992 flash_linear_addr
= (ICH_FLASH_LINEAR_ADDR_MASK
& offset
) +
2993 hw
->nvm
.flash_base_addr
;
2998 ret_val
= e1000_flash_cycle_init_ich8lan(hw
);
3002 hsflctl
.regval
= er16flash(ICH_FLASH_HSFCTL
);
3003 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
3004 hsflctl
.hsf_ctrl
.fldbcount
= size
-1;
3005 hsflctl
.hsf_ctrl
.flcycle
= ICH_CYCLE_WRITE
;
3006 ew16flash(ICH_FLASH_HSFCTL
, hsflctl
.regval
);
3008 ew32flash(ICH_FLASH_FADDR
, flash_linear_addr
);
3011 flash_data
= (u32
)data
& 0x00FF;
3013 flash_data
= (u32
)data
;
3015 ew32flash(ICH_FLASH_FDATA0
, flash_data
);
3017 /* check if FCERR is set to 1 , if set to 1, clear it
3018 * and try the whole sequence a few more times else done
3020 ret_val
= e1000_flash_cycle_ich8lan(hw
,
3021 ICH_FLASH_WRITE_COMMAND_TIMEOUT
);
3025 /* If we're here, then things are most likely
3026 * completely hosed, but if the error condition
3027 * is detected, it won't hurt to give it another
3028 * try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
3030 hsfsts
.regval
= er16flash(ICH_FLASH_HSFSTS
);
3031 if (hsfsts
.hsf_status
.flcerr
)
3032 /* Repeat for some time before giving up. */
3034 if (!hsfsts
.hsf_status
.flcdone
) {
3035 e_dbg("Timeout error - flash cycle did not complete.\n");
3038 } while (count
++ < ICH_FLASH_CYCLE_REPEAT_COUNT
);
3044 * e1000_write_flash_byte_ich8lan - Write a single byte to NVM
3045 * @hw: pointer to the HW structure
3046 * @offset: The index of the byte to read.
3047 * @data: The byte to write to the NVM.
3049 * Writes a single byte to the NVM using the flash access registers.
3051 static s32
e1000_write_flash_byte_ich8lan(struct e1000_hw
*hw
, u32 offset
,
3054 u16 word
= (u16
)data
;
3056 return e1000_write_flash_data_ich8lan(hw
, offset
, 1, word
);
3060 * e1000_retry_write_flash_byte_ich8lan - Writes a single byte to NVM
3061 * @hw: pointer to the HW structure
3062 * @offset: The offset of the byte to write.
3063 * @byte: The byte to write to the NVM.
3065 * Writes a single byte to the NVM using the flash access registers.
3066 * Goes through a retry algorithm before giving up.
3068 static s32
e1000_retry_write_flash_byte_ich8lan(struct e1000_hw
*hw
,
3069 u32 offset
, u8 byte
)
3072 u16 program_retries
;
3074 ret_val
= e1000_write_flash_byte_ich8lan(hw
, offset
, byte
);
3078 for (program_retries
= 0; program_retries
< 100; program_retries
++) {
3079 e_dbg("Retrying Byte %2.2X at offset %u\n", byte
, offset
);
3081 ret_val
= e1000_write_flash_byte_ich8lan(hw
, offset
, byte
);
3085 if (program_retries
== 100)
3086 return -E1000_ERR_NVM
;
3092 * e1000_erase_flash_bank_ich8lan - Erase a bank (4k) from NVM
3093 * @hw: pointer to the HW structure
3094 * @bank: 0 for first bank, 1 for second bank, etc.
3096 * Erases the bank specified. Each bank is a 4k block. Banks are 0 based.
3097 * bank N is 4096 * N + flash_reg_addr.
3099 static s32
e1000_erase_flash_bank_ich8lan(struct e1000_hw
*hw
, u32 bank
)
3101 struct e1000_nvm_info
*nvm
= &hw
->nvm
;
3102 union ich8_hws_flash_status hsfsts
;
3103 union ich8_hws_flash_ctrl hsflctl
;
3104 u32 flash_linear_addr
;
3105 /* bank size is in 16bit words - adjust to bytes */
3106 u32 flash_bank_size
= nvm
->flash_bank_size
* 2;
3109 s32 j
, iteration
, sector_size
;
3111 hsfsts
.regval
= er16flash(ICH_FLASH_HSFSTS
);
3113 /* Determine HW Sector size: Read BERASE bits of hw flash status
3115 * 00: The Hw sector is 256 bytes, hence we need to erase 16
3116 * consecutive sectors. The start index for the nth Hw sector
3117 * can be calculated as = bank * 4096 + n * 256
3118 * 01: The Hw sector is 4K bytes, hence we need to erase 1 sector.
3119 * The start index for the nth Hw sector can be calculated
3121 * 10: The Hw sector is 8K bytes, nth sector = bank * 8192
3122 * (ich9 only, otherwise error condition)
3123 * 11: The Hw sector is 64K bytes, nth sector = bank * 65536
3125 switch (hsfsts
.hsf_status
.berasesz
) {
3127 /* Hw sector size 256 */
3128 sector_size
= ICH_FLASH_SEG_SIZE_256
;
3129 iteration
= flash_bank_size
/ ICH_FLASH_SEG_SIZE_256
;
3132 sector_size
= ICH_FLASH_SEG_SIZE_4K
;
3136 sector_size
= ICH_FLASH_SEG_SIZE_8K
;
3140 sector_size
= ICH_FLASH_SEG_SIZE_64K
;
3144 return -E1000_ERR_NVM
;
3147 /* Start with the base address, then add the sector offset. */
3148 flash_linear_addr
= hw
->nvm
.flash_base_addr
;
3149 flash_linear_addr
+= (bank
) ? flash_bank_size
: 0;
3151 for (j
= 0; j
< iteration
; j
++) {
3154 ret_val
= e1000_flash_cycle_init_ich8lan(hw
);
3158 /* Write a value 11 (block Erase) in Flash
3159 * Cycle field in hw flash control
3161 hsflctl
.regval
= er16flash(ICH_FLASH_HSFCTL
);
3162 hsflctl
.hsf_ctrl
.flcycle
= ICH_CYCLE_ERASE
;
3163 ew16flash(ICH_FLASH_HSFCTL
, hsflctl
.regval
);
3165 /* Write the last 24 bits of an index within the
3166 * block into Flash Linear address field in Flash
3169 flash_linear_addr
+= (j
* sector_size
);
3170 ew32flash(ICH_FLASH_FADDR
, flash_linear_addr
);
3172 ret_val
= e1000_flash_cycle_ich8lan(hw
,
3173 ICH_FLASH_ERASE_COMMAND_TIMEOUT
);
3177 /* Check if FCERR is set to 1. If 1,
3178 * clear it and try the whole sequence
3179 * a few more times else Done
3181 hsfsts
.regval
= er16flash(ICH_FLASH_HSFSTS
);
3182 if (hsfsts
.hsf_status
.flcerr
)
3183 /* repeat for some time before giving up */
3185 else if (!hsfsts
.hsf_status
.flcdone
)
3187 } while (++count
< ICH_FLASH_CYCLE_REPEAT_COUNT
);
3194 * e1000_valid_led_default_ich8lan - Set the default LED settings
3195 * @hw: pointer to the HW structure
3196 * @data: Pointer to the LED settings
3198 * Reads the LED default settings from the NVM to data. If the NVM LED
3199 * settings is all 0's or F's, set the LED default to a valid LED default
3202 static s32
e1000_valid_led_default_ich8lan(struct e1000_hw
*hw
, u16
*data
)
3206 ret_val
= e1000_read_nvm(hw
, NVM_ID_LED_SETTINGS
, 1, data
);
3208 e_dbg("NVM Read Error\n");
3212 if (*data
== ID_LED_RESERVED_0000
||
3213 *data
== ID_LED_RESERVED_FFFF
)
3214 *data
= ID_LED_DEFAULT_ICH8LAN
;
3220 * e1000_id_led_init_pchlan - store LED configurations
3221 * @hw: pointer to the HW structure
3223 * PCH does not control LEDs via the LEDCTL register, rather it uses
3224 * the PHY LED configuration register.
3226 * PCH also does not have an "always on" or "always off" mode which
3227 * complicates the ID feature. Instead of using the "on" mode to indicate
3228 * in ledctl_mode2 the LEDs to use for ID (see e1000e_id_led_init_generic()),
3229 * use "link_up" mode. The LEDs will still ID on request if there is no
3230 * link based on logic in e1000_led_[on|off]_pchlan().
3232 static s32
e1000_id_led_init_pchlan(struct e1000_hw
*hw
)
3234 struct e1000_mac_info
*mac
= &hw
->mac
;
3236 const u32 ledctl_on
= E1000_LEDCTL_MODE_LINK_UP
;
3237 const u32 ledctl_off
= E1000_LEDCTL_MODE_LINK_UP
| E1000_PHY_LED0_IVRT
;
3238 u16 data
, i
, temp
, shift
;
3240 /* Get default ID LED modes */
3241 ret_val
= hw
->nvm
.ops
.valid_led_default(hw
, &data
);
3245 mac
->ledctl_default
= er32(LEDCTL
);
3246 mac
->ledctl_mode1
= mac
->ledctl_default
;
3247 mac
->ledctl_mode2
= mac
->ledctl_default
;
3249 for (i
= 0; i
< 4; i
++) {
3250 temp
= (data
>> (i
<< 2)) & E1000_LEDCTL_LED0_MODE_MASK
;
3253 case ID_LED_ON1_DEF2
:
3254 case ID_LED_ON1_ON2
:
3255 case ID_LED_ON1_OFF2
:
3256 mac
->ledctl_mode1
&= ~(E1000_PHY_LED0_MASK
<< shift
);
3257 mac
->ledctl_mode1
|= (ledctl_on
<< shift
);
3259 case ID_LED_OFF1_DEF2
:
3260 case ID_LED_OFF1_ON2
:
3261 case ID_LED_OFF1_OFF2
:
3262 mac
->ledctl_mode1
&= ~(E1000_PHY_LED0_MASK
<< shift
);
3263 mac
->ledctl_mode1
|= (ledctl_off
<< shift
);
3270 case ID_LED_DEF1_ON2
:
3271 case ID_LED_ON1_ON2
:
3272 case ID_LED_OFF1_ON2
:
3273 mac
->ledctl_mode2
&= ~(E1000_PHY_LED0_MASK
<< shift
);
3274 mac
->ledctl_mode2
|= (ledctl_on
<< shift
);
3276 case ID_LED_DEF1_OFF2
:
3277 case ID_LED_ON1_OFF2
:
3278 case ID_LED_OFF1_OFF2
:
3279 mac
->ledctl_mode2
&= ~(E1000_PHY_LED0_MASK
<< shift
);
3280 mac
->ledctl_mode2
|= (ledctl_off
<< shift
);
3292 * e1000_get_bus_info_ich8lan - Get/Set the bus type and width
3293 * @hw: pointer to the HW structure
3295 * ICH8 use the PCI Express bus, but does not contain a PCI Express Capability
3296 * register, so the the bus width is hard coded.
3298 static s32
e1000_get_bus_info_ich8lan(struct e1000_hw
*hw
)
3300 struct e1000_bus_info
*bus
= &hw
->bus
;
3303 ret_val
= e1000e_get_bus_info_pcie(hw
);
3305 /* ICH devices are "PCI Express"-ish. They have
3306 * a configuration space, but do not contain
3307 * PCI Express Capability registers, so bus width
3308 * must be hardcoded.
3310 if (bus
->width
== e1000_bus_width_unknown
)
3311 bus
->width
= e1000_bus_width_pcie_x1
;
3317 * e1000_reset_hw_ich8lan - Reset the hardware
3318 * @hw: pointer to the HW structure
3320 * Does a full reset of the hardware which includes a reset of the PHY and
3323 static s32
e1000_reset_hw_ich8lan(struct e1000_hw
*hw
)
3325 struct e1000_dev_spec_ich8lan
*dev_spec
= &hw
->dev_spec
.ich8lan
;
3330 /* Prevent the PCI-E bus from sticking if there is no TLP connection
3331 * on the last TLP read/write transaction when MAC is reset.
3333 ret_val
= e1000e_disable_pcie_master(hw
);
3335 e_dbg("PCI-E Master disable polling has failed.\n");
3337 e_dbg("Masking off all interrupts\n");
3338 ew32(IMC
, 0xffffffff);
3340 /* Disable the Transmit and Receive units. Then delay to allow
3341 * any pending transactions to complete before we hit the MAC
3342 * with the global reset.
3345 ew32(TCTL
, E1000_TCTL_PSP
);
3348 usleep_range(10000, 20000);
3350 /* Workaround for ICH8 bit corruption issue in FIFO memory */
3351 if (hw
->mac
.type
== e1000_ich8lan
) {
3352 /* Set Tx and Rx buffer allocation to 8k apiece. */
3353 ew32(PBA
, E1000_PBA_8K
);
3354 /* Set Packet Buffer Size to 16k. */
3355 ew32(PBS
, E1000_PBS_16K
);
3358 if (hw
->mac
.type
== e1000_pchlan
) {
3359 /* Save the NVM K1 bit setting */
3360 ret_val
= e1000_read_nvm(hw
, E1000_NVM_K1_CONFIG
, 1, &kum_cfg
);
3364 if (kum_cfg
& E1000_NVM_K1_ENABLE
)
3365 dev_spec
->nvm_k1_enabled
= true;
3367 dev_spec
->nvm_k1_enabled
= false;
3372 if (!hw
->phy
.ops
.check_reset_block(hw
)) {
3373 /* Full-chip reset requires MAC and PHY reset at the same
3374 * time to make sure the interface between MAC and the
3375 * external PHY is reset.
3377 ctrl
|= E1000_CTRL_PHY_RST
;
3379 /* Gate automatic PHY configuration by hardware on
3382 if ((hw
->mac
.type
== e1000_pch2lan
) &&
3383 !(er32(FWSM
) & E1000_ICH_FWSM_FW_VALID
))
3384 e1000_gate_hw_phy_config_ich8lan(hw
, true);
3386 ret_val
= e1000_acquire_swflag_ich8lan(hw
);
3387 e_dbg("Issuing a global reset to ich8lan\n");
3388 ew32(CTRL
, (ctrl
| E1000_CTRL_RST
));
3389 /* cannot issue a flush here because it hangs the hardware */
3392 /* Set Phy Config Counter to 50msec */
3393 if (hw
->mac
.type
== e1000_pch2lan
) {
3394 reg
= er32(FEXTNVM3
);
3395 reg
&= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK
;
3396 reg
|= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC
;
3397 ew32(FEXTNVM3
, reg
);
3401 clear_bit(__E1000_ACCESS_SHARED_RESOURCE
, &hw
->adapter
->state
);
3403 if (ctrl
& E1000_CTRL_PHY_RST
) {
3404 ret_val
= hw
->phy
.ops
.get_cfg_done(hw
);
3408 ret_val
= e1000_post_phy_reset_ich8lan(hw
);
3413 /* For PCH, this write will make sure that any noise
3414 * will be detected as a CRC error and be dropped rather than show up
3415 * as a bad packet to the DMA engine.
3417 if (hw
->mac
.type
== e1000_pchlan
)
3418 ew32(CRC_OFFSET
, 0x65656565);
3420 ew32(IMC
, 0xffffffff);
3423 reg
= er32(KABGTXD
);
3424 reg
|= E1000_KABGTXD_BGSQLBIAS
;
3431 * e1000_init_hw_ich8lan - Initialize the hardware
3432 * @hw: pointer to the HW structure
3434 * Prepares the hardware for transmit and receive by doing the following:
3435 * - initialize hardware bits
3436 * - initialize LED identification
3437 * - setup receive address registers
3438 * - setup flow control
3439 * - setup transmit descriptors
3440 * - clear statistics
3442 static s32
e1000_init_hw_ich8lan(struct e1000_hw
*hw
)
3444 struct e1000_mac_info
*mac
= &hw
->mac
;
3445 u32 ctrl_ext
, txdctl
, snoop
;
3449 e1000_initialize_hw_bits_ich8lan(hw
);
3451 /* Initialize identification LED */
3452 ret_val
= mac
->ops
.id_led_init(hw
);
3454 e_dbg("Error initializing identification LED\n");
3455 /* This is not fatal and we should not stop init due to this */
3457 /* Setup the receive address. */
3458 e1000e_init_rx_addrs(hw
, mac
->rar_entry_count
);
3460 /* Zero out the Multicast HASH table */
3461 e_dbg("Zeroing the MTA\n");
3462 for (i
= 0; i
< mac
->mta_reg_count
; i
++)
3463 E1000_WRITE_REG_ARRAY(hw
, E1000_MTA
, i
, 0);
3465 /* The 82578 Rx buffer will stall if wakeup is enabled in host and
3466 * the ME. Disable wakeup by clearing the host wakeup bit.
3467 * Reset the phy after disabling host wakeup to reset the Rx buffer.
3469 if (hw
->phy
.type
== e1000_phy_82578
) {
3470 e1e_rphy(hw
, BM_PORT_GEN_CFG
, &i
);
3471 i
&= ~BM_WUC_HOST_WU_BIT
;
3472 e1e_wphy(hw
, BM_PORT_GEN_CFG
, i
);
3473 ret_val
= e1000_phy_hw_reset_ich8lan(hw
);
3478 /* Setup link and flow control */
3479 ret_val
= mac
->ops
.setup_link(hw
);
3481 /* Set the transmit descriptor write-back policy for both queues */
3482 txdctl
= er32(TXDCTL(0));
3483 txdctl
= (txdctl
& ~E1000_TXDCTL_WTHRESH
) |
3484 E1000_TXDCTL_FULL_TX_DESC_WB
;
3485 txdctl
= (txdctl
& ~E1000_TXDCTL_PTHRESH
) |
3486 E1000_TXDCTL_MAX_TX_DESC_PREFETCH
;
3487 ew32(TXDCTL(0), txdctl
);
3488 txdctl
= er32(TXDCTL(1));
3489 txdctl
= (txdctl
& ~E1000_TXDCTL_WTHRESH
) |
3490 E1000_TXDCTL_FULL_TX_DESC_WB
;
3491 txdctl
= (txdctl
& ~E1000_TXDCTL_PTHRESH
) |
3492 E1000_TXDCTL_MAX_TX_DESC_PREFETCH
;
3493 ew32(TXDCTL(1), txdctl
);
3495 /* ICH8 has opposite polarity of no_snoop bits.
3496 * By default, we should use snoop behavior.
3498 if (mac
->type
== e1000_ich8lan
)
3499 snoop
= PCIE_ICH8_SNOOP_ALL
;
3501 snoop
= (u32
) ~(PCIE_NO_SNOOP_ALL
);
3502 e1000e_set_pcie_no_snoop(hw
, snoop
);
3504 ctrl_ext
= er32(CTRL_EXT
);
3505 ctrl_ext
|= E1000_CTRL_EXT_RO_DIS
;
3506 ew32(CTRL_EXT
, ctrl_ext
);
3508 /* Clear all of the statistics registers (clear on read). It is
3509 * important that we do this after we have tried to establish link
3510 * because the symbol error count will increment wildly if there
3513 e1000_clear_hw_cntrs_ich8lan(hw
);
3518 * e1000_initialize_hw_bits_ich8lan - Initialize required hardware bits
3519 * @hw: pointer to the HW structure
3521 * Sets/Clears required hardware bits necessary for correctly setting up the
3522 * hardware for transmit and receive.
3524 static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw
*hw
)
3528 /* Extended Device Control */
3529 reg
= er32(CTRL_EXT
);
3531 /* Enable PHY low-power state when MAC is at D3 w/o WoL */
3532 if (hw
->mac
.type
>= e1000_pchlan
)
3533 reg
|= E1000_CTRL_EXT_PHYPDEN
;
3534 ew32(CTRL_EXT
, reg
);
3536 /* Transmit Descriptor Control 0 */
3537 reg
= er32(TXDCTL(0));
3539 ew32(TXDCTL(0), reg
);
3541 /* Transmit Descriptor Control 1 */
3542 reg
= er32(TXDCTL(1));
3544 ew32(TXDCTL(1), reg
);
3546 /* Transmit Arbitration Control 0 */
3547 reg
= er32(TARC(0));
3548 if (hw
->mac
.type
== e1000_ich8lan
)
3549 reg
|= (1 << 28) | (1 << 29);
3550 reg
|= (1 << 23) | (1 << 24) | (1 << 26) | (1 << 27);
3553 /* Transmit Arbitration Control 1 */
3554 reg
= er32(TARC(1));
3555 if (er32(TCTL
) & E1000_TCTL_MULR
)
3559 reg
|= (1 << 24) | (1 << 26) | (1 << 30);
3563 if (hw
->mac
.type
== e1000_ich8lan
) {
3569 /* work-around descriptor data corruption issue during nfs v2 udp
3570 * traffic, just disable the nfs filtering capability
3573 reg
|= (E1000_RFCTL_NFSW_DIS
| E1000_RFCTL_NFSR_DIS
);
3575 /* Disable IPv6 extension header parsing because some malformed
3576 * IPv6 headers can hang the Rx.
3578 if (hw
->mac
.type
== e1000_ich8lan
)
3579 reg
|= (E1000_RFCTL_IPV6_EX_DIS
| E1000_RFCTL_NEW_IPV6_EXT_DIS
);
3582 /* Enable ECC on Lynxpoint */
3583 if (hw
->mac
.type
== e1000_pch_lpt
) {
3584 reg
= er32(PBECCSTS
);
3585 reg
|= E1000_PBECCSTS_ECC_ENABLE
;
3586 ew32(PBECCSTS
, reg
);
3589 reg
|= E1000_CTRL_MEHE
;
3595 * e1000_setup_link_ich8lan - Setup flow control and link settings
3596 * @hw: pointer to the HW structure
3598 * Determines which flow control settings to use, then configures flow
3599 * control. Calls the appropriate media-specific link configuration
3600 * function. Assuming the adapter has a valid link partner, a valid link
3601 * should be established. Assumes the hardware has previously been reset
3602 * and the transmitter and receiver are not enabled.
3604 static s32
e1000_setup_link_ich8lan(struct e1000_hw
*hw
)
3608 if (hw
->phy
.ops
.check_reset_block(hw
))
3611 /* ICH parts do not have a word in the NVM to determine
3612 * the default flow control setting, so we explicitly
3615 if (hw
->fc
.requested_mode
== e1000_fc_default
) {
3616 /* Workaround h/w hang when Tx flow control enabled */
3617 if (hw
->mac
.type
== e1000_pchlan
)
3618 hw
->fc
.requested_mode
= e1000_fc_rx_pause
;
3620 hw
->fc
.requested_mode
= e1000_fc_full
;
3623 /* Save off the requested flow control mode for use later. Depending
3624 * on the link partner's capabilities, we may or may not use this mode.
3626 hw
->fc
.current_mode
= hw
->fc
.requested_mode
;
3628 e_dbg("After fix-ups FlowControl is now = %x\n",
3629 hw
->fc
.current_mode
);
3631 /* Continue to configure the copper link. */
3632 ret_val
= hw
->mac
.ops
.setup_physical_interface(hw
);
3636 ew32(FCTTV
, hw
->fc
.pause_time
);
3637 if ((hw
->phy
.type
== e1000_phy_82578
) ||
3638 (hw
->phy
.type
== e1000_phy_82579
) ||
3639 (hw
->phy
.type
== e1000_phy_i217
) ||
3640 (hw
->phy
.type
== e1000_phy_82577
)) {
3641 ew32(FCRTV_PCH
, hw
->fc
.refresh_time
);
3643 ret_val
= e1e_wphy(hw
, PHY_REG(BM_PORT_CTRL_PAGE
, 27),
3649 return e1000e_set_fc_watermarks(hw
);
3653 * e1000_setup_copper_link_ich8lan - Configure MAC/PHY interface
3654 * @hw: pointer to the HW structure
3656 * Configures the kumeran interface to the PHY to wait the appropriate time
3657 * when polling the PHY, then call the generic setup_copper_link to finish
3658 * configuring the copper link.
3660 static s32
e1000_setup_copper_link_ich8lan(struct e1000_hw
*hw
)
3667 ctrl
|= E1000_CTRL_SLU
;
3668 ctrl
&= ~(E1000_CTRL_FRCSPD
| E1000_CTRL_FRCDPX
);
3671 /* Set the mac to wait the maximum time between each iteration
3672 * and increase the max iterations when polling the phy;
3673 * this fixes erroneous timeouts at 10Mbps.
3675 ret_val
= e1000e_write_kmrn_reg(hw
, E1000_KMRNCTRLSTA_TIMEOUTS
, 0xFFFF);
3678 ret_val
= e1000e_read_kmrn_reg(hw
, E1000_KMRNCTRLSTA_INBAND_PARAM
,
3683 ret_val
= e1000e_write_kmrn_reg(hw
, E1000_KMRNCTRLSTA_INBAND_PARAM
,
3688 switch (hw
->phy
.type
) {
3689 case e1000_phy_igp_3
:
3690 ret_val
= e1000e_copper_link_setup_igp(hw
);
3695 case e1000_phy_82578
:
3696 ret_val
= e1000e_copper_link_setup_m88(hw
);
3700 case e1000_phy_82577
:
3701 case e1000_phy_82579
:
3702 case e1000_phy_i217
:
3703 ret_val
= e1000_copper_link_setup_82577(hw
);
3708 ret_val
= e1e_rphy(hw
, IFE_PHY_MDIX_CONTROL
, ®_data
);
3712 reg_data
&= ~IFE_PMC_AUTO_MDIX
;
3714 switch (hw
->phy
.mdix
) {
3716 reg_data
&= ~IFE_PMC_FORCE_MDIX
;
3719 reg_data
|= IFE_PMC_FORCE_MDIX
;
3723 reg_data
|= IFE_PMC_AUTO_MDIX
;
3726 ret_val
= e1e_wphy(hw
, IFE_PHY_MDIX_CONTROL
, reg_data
);
3734 return e1000e_setup_copper_link(hw
);
3738 * e1000_get_link_up_info_ich8lan - Get current link speed and duplex
3739 * @hw: pointer to the HW structure
3740 * @speed: pointer to store current link speed
3741 * @duplex: pointer to store the current link duplex
3743 * Calls the generic get_speed_and_duplex to retrieve the current link
3744 * information and then calls the Kumeran lock loss workaround for links at
3747 static s32
e1000_get_link_up_info_ich8lan(struct e1000_hw
*hw
, u16
*speed
,
3752 ret_val
= e1000e_get_speed_and_duplex_copper(hw
, speed
, duplex
);
3756 if ((hw
->mac
.type
== e1000_ich8lan
) &&
3757 (hw
->phy
.type
== e1000_phy_igp_3
) &&
3758 (*speed
== SPEED_1000
)) {
3759 ret_val
= e1000_kmrn_lock_loss_workaround_ich8lan(hw
);
3766 * e1000_kmrn_lock_loss_workaround_ich8lan - Kumeran workaround
3767 * @hw: pointer to the HW structure
3769 * Work-around for 82566 Kumeran PCS lock loss:
3770 * On link status change (i.e. PCI reset, speed change) and link is up and
3772 * 0) if workaround is optionally disabled do nothing
3773 * 1) wait 1ms for Kumeran link to come up
3774 * 2) check Kumeran Diagnostic register PCS lock loss bit
3775 * 3) if not set the link is locked (all is good), otherwise...
3777 * 5) repeat up to 10 times
3778 * Note: this is only called for IGP3 copper when speed is 1gb.
3780 static s32
e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw
*hw
)
3782 struct e1000_dev_spec_ich8lan
*dev_spec
= &hw
->dev_spec
.ich8lan
;
3788 if (!dev_spec
->kmrn_lock_loss_workaround_enabled
)
3791 /* Make sure link is up before proceeding. If not just return.
3792 * Attempting this while link is negotiating fouled up link
3795 ret_val
= e1000e_phy_has_link_generic(hw
, 1, 0, &link
);
3799 for (i
= 0; i
< 10; i
++) {
3800 /* read once to clear */
3801 ret_val
= e1e_rphy(hw
, IGP3_KMRN_DIAG
, &data
);
3804 /* and again to get new status */
3805 ret_val
= e1e_rphy(hw
, IGP3_KMRN_DIAG
, &data
);
3809 /* check for PCS lock */
3810 if (!(data
& IGP3_KMRN_DIAG_PCS_LOCK_LOSS
))
3813 /* Issue PHY reset */
3814 e1000_phy_hw_reset(hw
);
3817 /* Disable GigE link negotiation */
3818 phy_ctrl
= er32(PHY_CTRL
);
3819 phy_ctrl
|= (E1000_PHY_CTRL_GBE_DISABLE
|
3820 E1000_PHY_CTRL_NOND0A_GBE_DISABLE
);
3821 ew32(PHY_CTRL
, phy_ctrl
);
3823 /* Call gig speed drop workaround on Gig disable before accessing
3826 e1000e_gig_downshift_workaround_ich8lan(hw
);
3828 /* unable to acquire PCS lock */
3829 return -E1000_ERR_PHY
;
3833 * e1000e_set_kmrn_lock_loss_workaround_ich8lan - Set Kumeran workaround state
3834 * @hw: pointer to the HW structure
3835 * @state: boolean value used to set the current Kumeran workaround state
3837 * If ICH8, set the current Kumeran workaround state (enabled - true
3838 * /disabled - false).
3840 void e1000e_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw
*hw
,
3843 struct e1000_dev_spec_ich8lan
*dev_spec
= &hw
->dev_spec
.ich8lan
;
3845 if (hw
->mac
.type
!= e1000_ich8lan
) {
3846 e_dbg("Workaround applies to ICH8 only.\n");
3850 dev_spec
->kmrn_lock_loss_workaround_enabled
= state
;
3854 * e1000_ipg3_phy_powerdown_workaround_ich8lan - Power down workaround on D3
3855 * @hw: pointer to the HW structure
3857 * Workaround for 82566 power-down on D3 entry:
3858 * 1) disable gigabit link
3859 * 2) write VR power-down enable
3861 * Continue if successful, else issue LCD reset and repeat
3863 void e1000e_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw
*hw
)
3869 if (hw
->phy
.type
!= e1000_phy_igp_3
)
3872 /* Try the workaround twice (if needed) */
3875 reg
= er32(PHY_CTRL
);
3876 reg
|= (E1000_PHY_CTRL_GBE_DISABLE
|
3877 E1000_PHY_CTRL_NOND0A_GBE_DISABLE
);
3878 ew32(PHY_CTRL
, reg
);
3880 /* Call gig speed drop workaround on Gig disable before
3881 * accessing any PHY registers
3883 if (hw
->mac
.type
== e1000_ich8lan
)
3884 e1000e_gig_downshift_workaround_ich8lan(hw
);
3886 /* Write VR power-down enable */
3887 e1e_rphy(hw
, IGP3_VR_CTRL
, &data
);
3888 data
&= ~IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK
;
3889 e1e_wphy(hw
, IGP3_VR_CTRL
, data
| IGP3_VR_CTRL_MODE_SHUTDOWN
);
3891 /* Read it back and test */
3892 e1e_rphy(hw
, IGP3_VR_CTRL
, &data
);
3893 data
&= IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK
;
3894 if ((data
== IGP3_VR_CTRL_MODE_SHUTDOWN
) || retry
)
3897 /* Issue PHY reset and repeat at most one more time */
3899 ew32(CTRL
, reg
| E1000_CTRL_PHY_RST
);
3905 * e1000e_gig_downshift_workaround_ich8lan - WoL from S5 stops working
3906 * @hw: pointer to the HW structure
3908 * Steps to take when dropping from 1Gb/s (eg. link cable removal (LSC),
3909 * LPLU, Gig disable, MDIC PHY reset):
3910 * 1) Set Kumeran Near-end loopback
3911 * 2) Clear Kumeran Near-end loopback
3912 * Should only be called for ICH8[m] devices with any 1G Phy.
3914 void e1000e_gig_downshift_workaround_ich8lan(struct e1000_hw
*hw
)
3919 if ((hw
->mac
.type
!= e1000_ich8lan
) || (hw
->phy
.type
== e1000_phy_ife
))
3922 ret_val
= e1000e_read_kmrn_reg(hw
, E1000_KMRNCTRLSTA_DIAG_OFFSET
,
3926 reg_data
|= E1000_KMRNCTRLSTA_DIAG_NELPBK
;
3927 ret_val
= e1000e_write_kmrn_reg(hw
, E1000_KMRNCTRLSTA_DIAG_OFFSET
,
3931 reg_data
&= ~E1000_KMRNCTRLSTA_DIAG_NELPBK
;
3932 e1000e_write_kmrn_reg(hw
, E1000_KMRNCTRLSTA_DIAG_OFFSET
, reg_data
);
3936 * e1000_suspend_workarounds_ich8lan - workarounds needed during S0->Sx
3937 * @hw: pointer to the HW structure
3939 * During S0 to Sx transition, it is possible the link remains at gig
3940 * instead of negotiating to a lower speed. Before going to Sx, set
3941 * 'Gig Disable' to force link speed negotiation to a lower speed based on
3942 * the LPLU setting in the NVM or custom setting. For PCH and newer parts,
3943 * the OEM bits PHY register (LED, GbE disable and LPLU configurations) also
3944 * needs to be written.
3945 * Parts that support (and are linked to a partner which support) EEE in
3946 * 100Mbps should disable LPLU since 100Mbps w/ EEE requires less power
3947 * than 10Mbps w/o EEE.
3949 void e1000_suspend_workarounds_ich8lan(struct e1000_hw
*hw
)
3951 struct e1000_dev_spec_ich8lan
*dev_spec
= &hw
->dev_spec
.ich8lan
;
3955 phy_ctrl
= er32(PHY_CTRL
);
3956 phy_ctrl
|= E1000_PHY_CTRL_GBE_DISABLE
;
3957 if (hw
->phy
.type
== e1000_phy_i217
) {
3960 ret_val
= hw
->phy
.ops
.acquire(hw
);
3964 if (!dev_spec
->eee_disable
) {
3968 e1000_read_emi_reg_locked(hw
,
3969 I217_EEE_ADVERTISEMENT
,
3974 /* Disable LPLU if both link partners support 100BaseT
3975 * EEE and 100Full is advertised on both ends of the
3978 if ((eee_advert
& I82579_EEE_100_SUPPORTED
) &&
3979 (dev_spec
->eee_lp_ability
&
3980 I82579_EEE_100_SUPPORTED
) &&
3981 (hw
->phy
.autoneg_advertised
& ADVERTISE_100_FULL
))
3982 phy_ctrl
&= ~(E1000_PHY_CTRL_D0A_LPLU
|
3983 E1000_PHY_CTRL_NOND0A_LPLU
);
3986 /* For i217 Intel Rapid Start Technology support,
3987 * when the system is going into Sx and no manageability engine
3988 * is present, the driver must configure proxy to reset only on
3989 * power good. LPI (Low Power Idle) state must also reset only
3990 * on power good, as well as the MTA (Multicast table array).
3991 * The SMBus release must also be disabled on LCD reset.
3993 if (!(er32(FWSM
) & E1000_ICH_FWSM_FW_VALID
)) {
3994 /* Enable proxy to reset only on power good. */
3995 e1e_rphy_locked(hw
, I217_PROXY_CTRL
, &phy_reg
);
3996 phy_reg
|= I217_PROXY_CTRL_AUTO_DISABLE
;
3997 e1e_wphy_locked(hw
, I217_PROXY_CTRL
, phy_reg
);
3999 /* Set bit enable LPI (EEE) to reset only on
4002 e1e_rphy_locked(hw
, I217_SxCTRL
, &phy_reg
);
4003 phy_reg
|= I217_SxCTRL_ENABLE_LPI_RESET
;
4004 e1e_wphy_locked(hw
, I217_SxCTRL
, phy_reg
);
4006 /* Disable the SMB release on LCD reset. */
4007 e1e_rphy_locked(hw
, I217_MEMPWR
, &phy_reg
);
4008 phy_reg
&= ~I217_MEMPWR_DISABLE_SMB_RELEASE
;
4009 e1e_wphy_locked(hw
, I217_MEMPWR
, phy_reg
);
4012 /* Enable MTA to reset for Intel Rapid Start Technology
4015 e1e_rphy_locked(hw
, I217_CGFREG
, &phy_reg
);
4016 phy_reg
|= I217_CGFREG_ENABLE_MTA_RESET
;
4017 e1e_wphy_locked(hw
, I217_CGFREG
, phy_reg
);
4020 hw
->phy
.ops
.release(hw
);
4023 ew32(PHY_CTRL
, phy_ctrl
);
4025 if (hw
->mac
.type
== e1000_ich8lan
)
4026 e1000e_gig_downshift_workaround_ich8lan(hw
);
4028 if (hw
->mac
.type
>= e1000_pchlan
) {
4029 e1000_oem_bits_config_ich8lan(hw
, false);
4031 /* Reset PHY to activate OEM bits on 82577/8 */
4032 if (hw
->mac
.type
== e1000_pchlan
)
4033 e1000e_phy_hw_reset_generic(hw
);
4035 ret_val
= hw
->phy
.ops
.acquire(hw
);
4038 e1000_write_smbus_addr(hw
);
4039 hw
->phy
.ops
.release(hw
);
4044 * e1000_resume_workarounds_pchlan - workarounds needed during Sx->S0
4045 * @hw: pointer to the HW structure
4047 * During Sx to S0 transitions on non-managed devices or managed devices
4048 * on which PHY resets are not blocked, if the PHY registers cannot be
4049 * accessed properly by the s/w toggle the LANPHYPC value to power cycle
4051 * On i217, setup Intel Rapid Start Technology.
4053 void e1000_resume_workarounds_pchlan(struct e1000_hw
*hw
)
4057 if (hw
->mac
.type
< e1000_pch2lan
)
4060 ret_val
= e1000_init_phy_workarounds_pchlan(hw
);
4062 e_dbg("Failed to init PHY flow ret_val=%d\n", ret_val
);
4066 /* For i217 Intel Rapid Start Technology support when the system
4067 * is transitioning from Sx and no manageability engine is present
4068 * configure SMBus to restore on reset, disable proxy, and enable
4069 * the reset on MTA (Multicast table array).
4071 if (hw
->phy
.type
== e1000_phy_i217
) {
4074 ret_val
= hw
->phy
.ops
.acquire(hw
);
4076 e_dbg("Failed to setup iRST\n");
4080 if (!(er32(FWSM
) & E1000_ICH_FWSM_FW_VALID
)) {
4081 /* Restore clear on SMB if no manageability engine
4084 ret_val
= e1e_rphy_locked(hw
, I217_MEMPWR
, &phy_reg
);
4087 phy_reg
|= I217_MEMPWR_DISABLE_SMB_RELEASE
;
4088 e1e_wphy_locked(hw
, I217_MEMPWR
, phy_reg
);
4091 e1e_wphy_locked(hw
, I217_PROXY_CTRL
, 0);
4093 /* Enable reset on MTA */
4094 ret_val
= e1e_rphy_locked(hw
, I217_CGFREG
, &phy_reg
);
4097 phy_reg
&= ~I217_CGFREG_ENABLE_MTA_RESET
;
4098 e1e_wphy_locked(hw
, I217_CGFREG
, phy_reg
);
4101 e_dbg("Error %d in resume workarounds\n", ret_val
);
4102 hw
->phy
.ops
.release(hw
);
4107 * e1000_cleanup_led_ich8lan - Restore the default LED operation
4108 * @hw: pointer to the HW structure
4110 * Return the LED back to the default configuration.
4112 static s32
e1000_cleanup_led_ich8lan(struct e1000_hw
*hw
)
4114 if (hw
->phy
.type
== e1000_phy_ife
)
4115 return e1e_wphy(hw
, IFE_PHY_SPECIAL_CONTROL_LED
, 0);
4117 ew32(LEDCTL
, hw
->mac
.ledctl_default
);
4122 * e1000_led_on_ich8lan - Turn LEDs on
4123 * @hw: pointer to the HW structure
4127 static s32
e1000_led_on_ich8lan(struct e1000_hw
*hw
)
4129 if (hw
->phy
.type
== e1000_phy_ife
)
4130 return e1e_wphy(hw
, IFE_PHY_SPECIAL_CONTROL_LED
,
4131 (IFE_PSCL_PROBE_MODE
| IFE_PSCL_PROBE_LEDS_ON
));
4133 ew32(LEDCTL
, hw
->mac
.ledctl_mode2
);
4138 * e1000_led_off_ich8lan - Turn LEDs off
4139 * @hw: pointer to the HW structure
4141 * Turn off the LEDs.
4143 static s32
e1000_led_off_ich8lan(struct e1000_hw
*hw
)
4145 if (hw
->phy
.type
== e1000_phy_ife
)
4146 return e1e_wphy(hw
, IFE_PHY_SPECIAL_CONTROL_LED
,
4147 (IFE_PSCL_PROBE_MODE
|
4148 IFE_PSCL_PROBE_LEDS_OFF
));
4150 ew32(LEDCTL
, hw
->mac
.ledctl_mode1
);
4155 * e1000_setup_led_pchlan - Configures SW controllable LED
4156 * @hw: pointer to the HW structure
4158 * This prepares the SW controllable LED for use.
4160 static s32
e1000_setup_led_pchlan(struct e1000_hw
*hw
)
4162 return e1e_wphy(hw
, HV_LED_CONFIG
, (u16
)hw
->mac
.ledctl_mode1
);
4166 * e1000_cleanup_led_pchlan - Restore the default LED operation
4167 * @hw: pointer to the HW structure
4169 * Return the LED back to the default configuration.
4171 static s32
e1000_cleanup_led_pchlan(struct e1000_hw
*hw
)
4173 return e1e_wphy(hw
, HV_LED_CONFIG
, (u16
)hw
->mac
.ledctl_default
);
4177 * e1000_led_on_pchlan - Turn LEDs on
4178 * @hw: pointer to the HW structure
4182 static s32
e1000_led_on_pchlan(struct e1000_hw
*hw
)
4184 u16 data
= (u16
)hw
->mac
.ledctl_mode2
;
4187 /* If no link, then turn LED on by setting the invert bit
4188 * for each LED that's mode is "link_up" in ledctl_mode2.
4190 if (!(er32(STATUS
) & E1000_STATUS_LU
)) {
4191 for (i
= 0; i
< 3; i
++) {
4192 led
= (data
>> (i
* 5)) & E1000_PHY_LED0_MASK
;
4193 if ((led
& E1000_PHY_LED0_MODE_MASK
) !=
4194 E1000_LEDCTL_MODE_LINK_UP
)
4196 if (led
& E1000_PHY_LED0_IVRT
)
4197 data
&= ~(E1000_PHY_LED0_IVRT
<< (i
* 5));
4199 data
|= (E1000_PHY_LED0_IVRT
<< (i
* 5));
4203 return e1e_wphy(hw
, HV_LED_CONFIG
, data
);
4207 * e1000_led_off_pchlan - Turn LEDs off
4208 * @hw: pointer to the HW structure
4210 * Turn off the LEDs.
4212 static s32
e1000_led_off_pchlan(struct e1000_hw
*hw
)
4214 u16 data
= (u16
)hw
->mac
.ledctl_mode1
;
4217 /* If no link, then turn LED off by clearing the invert bit
4218 * for each LED that's mode is "link_up" in ledctl_mode1.
4220 if (!(er32(STATUS
) & E1000_STATUS_LU
)) {
4221 for (i
= 0; i
< 3; i
++) {
4222 led
= (data
>> (i
* 5)) & E1000_PHY_LED0_MASK
;
4223 if ((led
& E1000_PHY_LED0_MODE_MASK
) !=
4224 E1000_LEDCTL_MODE_LINK_UP
)
4226 if (led
& E1000_PHY_LED0_IVRT
)
4227 data
&= ~(E1000_PHY_LED0_IVRT
<< (i
* 5));
4229 data
|= (E1000_PHY_LED0_IVRT
<< (i
* 5));
4233 return e1e_wphy(hw
, HV_LED_CONFIG
, data
);
4237 * e1000_get_cfg_done_ich8lan - Read config done bit after Full or PHY reset
4238 * @hw: pointer to the HW structure
4240 * Read appropriate register for the config done bit for completion status
4241 * and configure the PHY through s/w for EEPROM-less parts.
4243 * NOTE: some silicon which is EEPROM-less will fail trying to read the
4244 * config done bit, so only an error is logged and continues. If we were
4245 * to return with error, EEPROM-less silicon would not be able to be reset
4248 static s32
e1000_get_cfg_done_ich8lan(struct e1000_hw
*hw
)
4254 e1000e_get_cfg_done_generic(hw
);
4256 /* Wait for indication from h/w that it has completed basic config */
4257 if (hw
->mac
.type
>= e1000_ich10lan
) {
4258 e1000_lan_init_done_ich8lan(hw
);
4260 ret_val
= e1000e_get_auto_rd_done(hw
);
4262 /* When auto config read does not complete, do not
4263 * return with an error. This can happen in situations
4264 * where there is no eeprom and prevents getting link.
4266 e_dbg("Auto Read Done did not complete\n");
4271 /* Clear PHY Reset Asserted bit */
4272 status
= er32(STATUS
);
4273 if (status
& E1000_STATUS_PHYRA
)
4274 ew32(STATUS
, status
& ~E1000_STATUS_PHYRA
);
4276 e_dbg("PHY Reset Asserted not set - needs delay\n");
4278 /* If EEPROM is not marked present, init the IGP 3 PHY manually */
4279 if (hw
->mac
.type
<= e1000_ich9lan
) {
4280 if (!(er32(EECD
) & E1000_EECD_PRES
) &&
4281 (hw
->phy
.type
== e1000_phy_igp_3
)) {
4282 e1000e_phy_init_script_igp3(hw
);
4285 if (e1000_valid_nvm_bank_detect_ich8lan(hw
, &bank
)) {
4286 /* Maybe we should do a basic PHY config */
4287 e_dbg("EEPROM not present\n");
4288 ret_val
= -E1000_ERR_CONFIG
;
4296 * e1000_power_down_phy_copper_ich8lan - Remove link during PHY power down
4297 * @hw: pointer to the HW structure
4299 * In the case of a PHY power down to save power, or to turn off link during a
4300 * driver unload, or wake on lan is not enabled, remove the link.
4302 static void e1000_power_down_phy_copper_ich8lan(struct e1000_hw
*hw
)
4304 /* If the management interface is not enabled, then power down */
4305 if (!(hw
->mac
.ops
.check_mng_mode(hw
) ||
4306 hw
->phy
.ops
.check_reset_block(hw
)))
4307 e1000_power_down_phy_copper(hw
);
4311 * e1000_clear_hw_cntrs_ich8lan - Clear statistical counters
4312 * @hw: pointer to the HW structure
4314 * Clears hardware counters specific to the silicon family and calls
4315 * clear_hw_cntrs_generic to clear all general purpose counters.
4317 static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw
*hw
)
4322 e1000e_clear_hw_cntrs_base(hw
);
4338 /* Clear PHY statistics registers */
4339 if ((hw
->phy
.type
== e1000_phy_82578
) ||
4340 (hw
->phy
.type
== e1000_phy_82579
) ||
4341 (hw
->phy
.type
== e1000_phy_i217
) ||
4342 (hw
->phy
.type
== e1000_phy_82577
)) {
4343 ret_val
= hw
->phy
.ops
.acquire(hw
);
4346 ret_val
= hw
->phy
.ops
.set_page(hw
,
4347 HV_STATS_PAGE
<< IGP_PAGE_SHIFT
);
4350 hw
->phy
.ops
.read_reg_page(hw
, HV_SCC_UPPER
, &phy_data
);
4351 hw
->phy
.ops
.read_reg_page(hw
, HV_SCC_LOWER
, &phy_data
);
4352 hw
->phy
.ops
.read_reg_page(hw
, HV_ECOL_UPPER
, &phy_data
);
4353 hw
->phy
.ops
.read_reg_page(hw
, HV_ECOL_LOWER
, &phy_data
);
4354 hw
->phy
.ops
.read_reg_page(hw
, HV_MCC_UPPER
, &phy_data
);
4355 hw
->phy
.ops
.read_reg_page(hw
, HV_MCC_LOWER
, &phy_data
);
4356 hw
->phy
.ops
.read_reg_page(hw
, HV_LATECOL_UPPER
, &phy_data
);
4357 hw
->phy
.ops
.read_reg_page(hw
, HV_LATECOL_LOWER
, &phy_data
);
4358 hw
->phy
.ops
.read_reg_page(hw
, HV_COLC_UPPER
, &phy_data
);
4359 hw
->phy
.ops
.read_reg_page(hw
, HV_COLC_LOWER
, &phy_data
);
4360 hw
->phy
.ops
.read_reg_page(hw
, HV_DC_UPPER
, &phy_data
);
4361 hw
->phy
.ops
.read_reg_page(hw
, HV_DC_LOWER
, &phy_data
);
4362 hw
->phy
.ops
.read_reg_page(hw
, HV_TNCRS_UPPER
, &phy_data
);
4363 hw
->phy
.ops
.read_reg_page(hw
, HV_TNCRS_LOWER
, &phy_data
);
4365 hw
->phy
.ops
.release(hw
);
4369 static const struct e1000_mac_operations ich8_mac_ops
= {
4370 /* check_mng_mode dependent on mac type */
4371 .check_for_link
= e1000_check_for_copper_link_ich8lan
,
4372 /* cleanup_led dependent on mac type */
4373 .clear_hw_cntrs
= e1000_clear_hw_cntrs_ich8lan
,
4374 .get_bus_info
= e1000_get_bus_info_ich8lan
,
4375 .set_lan_id
= e1000_set_lan_id_single_port
,
4376 .get_link_up_info
= e1000_get_link_up_info_ich8lan
,
4377 /* led_on dependent on mac type */
4378 /* led_off dependent on mac type */
4379 .update_mc_addr_list
= e1000e_update_mc_addr_list_generic
,
4380 .reset_hw
= e1000_reset_hw_ich8lan
,
4381 .init_hw
= e1000_init_hw_ich8lan
,
4382 .setup_link
= e1000_setup_link_ich8lan
,
4383 .setup_physical_interface
= e1000_setup_copper_link_ich8lan
,
4384 /* id_led_init dependent on mac type */
4385 .config_collision_dist
= e1000e_config_collision_dist_generic
,
4386 .rar_set
= e1000e_rar_set_generic
,
4389 static const struct e1000_phy_operations ich8_phy_ops
= {
4390 .acquire
= e1000_acquire_swflag_ich8lan
,
4391 .check_reset_block
= e1000_check_reset_block_ich8lan
,
4393 .get_cfg_done
= e1000_get_cfg_done_ich8lan
,
4394 .get_cable_length
= e1000e_get_cable_length_igp_2
,
4395 .read_reg
= e1000e_read_phy_reg_igp
,
4396 .release
= e1000_release_swflag_ich8lan
,
4397 .reset
= e1000_phy_hw_reset_ich8lan
,
4398 .set_d0_lplu_state
= e1000_set_d0_lplu_state_ich8lan
,
4399 .set_d3_lplu_state
= e1000_set_d3_lplu_state_ich8lan
,
4400 .write_reg
= e1000e_write_phy_reg_igp
,
4403 static const struct e1000_nvm_operations ich8_nvm_ops
= {
4404 .acquire
= e1000_acquire_nvm_ich8lan
,
4405 .read
= e1000_read_nvm_ich8lan
,
4406 .release
= e1000_release_nvm_ich8lan
,
4407 .reload
= e1000e_reload_nvm_generic
,
4408 .update
= e1000_update_nvm_checksum_ich8lan
,
4409 .valid_led_default
= e1000_valid_led_default_ich8lan
,
4410 .validate
= e1000_validate_nvm_checksum_ich8lan
,
4411 .write
= e1000_write_nvm_ich8lan
,
4414 const struct e1000_info e1000_ich8_info
= {
4415 .mac
= e1000_ich8lan
,
4416 .flags
= FLAG_HAS_WOL
4418 | FLAG_HAS_CTRLEXT_ON_LOAD
4423 .max_hw_frame_size
= ETH_FRAME_LEN
+ ETH_FCS_LEN
,
4424 .get_variants
= e1000_get_variants_ich8lan
,
4425 .mac_ops
= &ich8_mac_ops
,
4426 .phy_ops
= &ich8_phy_ops
,
4427 .nvm_ops
= &ich8_nvm_ops
,
4430 const struct e1000_info e1000_ich9_info
= {
4431 .mac
= e1000_ich9lan
,
4432 .flags
= FLAG_HAS_JUMBO_FRAMES
4435 | FLAG_HAS_CTRLEXT_ON_LOAD
4440 .max_hw_frame_size
= DEFAULT_JUMBO
,
4441 .get_variants
= e1000_get_variants_ich8lan
,
4442 .mac_ops
= &ich8_mac_ops
,
4443 .phy_ops
= &ich8_phy_ops
,
4444 .nvm_ops
= &ich8_nvm_ops
,
4447 const struct e1000_info e1000_ich10_info
= {
4448 .mac
= e1000_ich10lan
,
4449 .flags
= FLAG_HAS_JUMBO_FRAMES
4452 | FLAG_HAS_CTRLEXT_ON_LOAD
4457 .max_hw_frame_size
= DEFAULT_JUMBO
,
4458 .get_variants
= e1000_get_variants_ich8lan
,
4459 .mac_ops
= &ich8_mac_ops
,
4460 .phy_ops
= &ich8_phy_ops
,
4461 .nvm_ops
= &ich8_nvm_ops
,
4464 const struct e1000_info e1000_pch_info
= {
4465 .mac
= e1000_pchlan
,
4466 .flags
= FLAG_IS_ICH
4468 | FLAG_HAS_CTRLEXT_ON_LOAD
4471 | FLAG_HAS_JUMBO_FRAMES
4472 | FLAG_DISABLE_FC_PAUSE_TIME
/* errata */
4474 .flags2
= FLAG2_HAS_PHY_STATS
,
4476 .max_hw_frame_size
= 4096,
4477 .get_variants
= e1000_get_variants_ich8lan
,
4478 .mac_ops
= &ich8_mac_ops
,
4479 .phy_ops
= &ich8_phy_ops
,
4480 .nvm_ops
= &ich8_nvm_ops
,
4483 const struct e1000_info e1000_pch2_info
= {
4484 .mac
= e1000_pch2lan
,
4485 .flags
= FLAG_IS_ICH
4487 | FLAG_HAS_HW_TIMESTAMP
4488 | FLAG_HAS_CTRLEXT_ON_LOAD
4491 | FLAG_HAS_JUMBO_FRAMES
4493 .flags2
= FLAG2_HAS_PHY_STATS
4496 .max_hw_frame_size
= 9018,
4497 .get_variants
= e1000_get_variants_ich8lan
,
4498 .mac_ops
= &ich8_mac_ops
,
4499 .phy_ops
= &ich8_phy_ops
,
4500 .nvm_ops
= &ich8_nvm_ops
,
4503 const struct e1000_info e1000_pch_lpt_info
= {
4504 .mac
= e1000_pch_lpt
,
4505 .flags
= FLAG_IS_ICH
4507 | FLAG_HAS_HW_TIMESTAMP
4508 | FLAG_HAS_CTRLEXT_ON_LOAD
4511 | FLAG_HAS_JUMBO_FRAMES
4513 .flags2
= FLAG2_HAS_PHY_STATS
4516 .max_hw_frame_size
= 9018,
4517 .get_variants
= e1000_get_variants_ich8lan
,
4518 .mac_ops
= &ich8_mac_ops
,
4519 .phy_ops
= &ich8_phy_ops
,
4520 .nvm_ops
= &ich8_nvm_ops
,