1 /*******************************************************************************
3 Copyright (c) 2001-2015, Intel Corporation
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
9 1. Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
12 2. Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
16 3. Neither the name of the Intel Corporation nor the names of its
17 contributors may be used to endorse or promote products derived from
18 this software without specific prior written permission.
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
32 ***************************************************************************/
34 /* 82562G 10/100 Network Connection
35 * 82562G-2 10/100 Network Connection
36 * 82562GT 10/100 Network Connection
37 * 82562GT-2 10/100 Network Connection
38 * 82562V 10/100 Network Connection
39 * 82562V-2 10/100 Network Connection
40 * 82566DC-2 Gigabit Network Connection
41 * 82566DC Gigabit Network Connection
42 * 82566DM-2 Gigabit Network Connection
43 * 82566DM Gigabit Network Connection
44 * 82566MC Gigabit Network Connection
45 * 82566MM Gigabit Network Connection
46 * 82567LM Gigabit Network Connection
47 * 82567LF Gigabit Network Connection
48 * 82567V Gigabit Network Connection
49 * 82567LM-2 Gigabit Network Connection
50 * 82567LF-2 Gigabit Network Connection
51 * 82567V-2 Gigabit Network Connection
52 * 82567LF-3 Gigabit Network Connection
53 * 82567LM-3 Gigabit Network Connection
54 * 82567LM-4 Gigabit Network Connection
55 * 82577LM Gigabit Network Connection
56 * 82577LC Gigabit Network Connection
57 * 82578DM Gigabit Network Connection
58 * 82578DC Gigabit Network Connection
59 * 82579LM Gigabit Network Connection
60 * 82579V Gigabit Network Connection
61 * Ethernet Connection I217-LM
62 * Ethernet Connection I217-V
63 * Ethernet Connection I218-V
64 * Ethernet Connection I218-LM
65 * Ethernet Connection (2) I218-LM
66 * Ethernet Connection (2) I218-V
67 * Ethernet Connection (3) I218-LM
68 * Ethernet Connection (3) I218-V
71 #include "e1000_api.h"
73 STATIC s32 e1000_oem_bits_config_ich8lan(struct e1000_hw *hw, bool d0_state);
74 STATIC s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw);
75 STATIC void e1000_release_swflag_ich8lan(struct e1000_hw *hw);
76 STATIC s32 e1000_acquire_nvm_ich8lan(struct e1000_hw *hw);
77 STATIC void e1000_release_nvm_ich8lan(struct e1000_hw *hw);
78 STATIC bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw);
79 STATIC bool e1000_check_mng_mode_pchlan(struct e1000_hw *hw);
80 STATIC int e1000_rar_set_pch2lan(struct e1000_hw *hw, u8 *addr, u32 index);
81 STATIC int e1000_rar_set_pch_lpt(struct e1000_hw *hw, u8 *addr, u32 index);
82 STATIC s32 e1000_sw_lcd_config_ich8lan(struct e1000_hw *hw);
83 #ifndef NO_NON_BLOCKING_PHY_MTA_UPDATE_SUPPORT
84 STATIC void e1000_update_mc_addr_list_pch2lan(struct e1000_hw *hw,
87 #endif /* NO_NON_BLOCKING_PHY_MTA_UPDATE_SUPPORT */
88 STATIC s32 e1000_check_reset_block_ich8lan(struct e1000_hw *hw);
89 STATIC s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw);
90 STATIC s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active);
91 STATIC s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw,
93 STATIC s32 e1000_set_d3_lplu_state_ich8lan(struct e1000_hw *hw,
95 STATIC s32 e1000_read_nvm_ich8lan(struct e1000_hw *hw, u16 offset,
96 u16 words, u16 *data);
97 STATIC s32 e1000_write_nvm_ich8lan(struct e1000_hw *hw, u16 offset,
98 u16 words, u16 *data);
99 STATIC s32 e1000_validate_nvm_checksum_ich8lan(struct e1000_hw *hw);
100 STATIC s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw);
101 STATIC s32 e1000_valid_led_default_ich8lan(struct e1000_hw *hw,
103 STATIC s32 e1000_id_led_init_pchlan(struct e1000_hw *hw);
104 STATIC s32 e1000_get_bus_info_ich8lan(struct e1000_hw *hw);
105 STATIC s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw);
106 STATIC s32 e1000_init_hw_ich8lan(struct e1000_hw *hw);
107 STATIC s32 e1000_setup_link_ich8lan(struct e1000_hw *hw);
108 STATIC s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw);
109 STATIC s32 e1000_setup_copper_link_pch_lpt(struct e1000_hw *hw);
110 STATIC s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw,
111 u16 *speed, u16 *duplex);
112 STATIC s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw);
113 STATIC s32 e1000_led_on_ich8lan(struct e1000_hw *hw);
114 STATIC s32 e1000_led_off_ich8lan(struct e1000_hw *hw);
115 STATIC s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link);
116 STATIC s32 e1000_setup_led_pchlan(struct e1000_hw *hw);
117 STATIC s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw);
118 STATIC s32 e1000_led_on_pchlan(struct e1000_hw *hw);
119 STATIC s32 e1000_led_off_pchlan(struct e1000_hw *hw);
120 STATIC void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw);
121 STATIC s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank);
122 STATIC void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw);
123 STATIC s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw);
124 STATIC s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw,
125 u32 offset, u8 *data);
126 STATIC s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
128 STATIC s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw,
129 u32 offset, u16 *data);
130 STATIC s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw,
131 u32 offset, u8 byte);
132 STATIC s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw);
133 STATIC void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw);
134 STATIC s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw);
135 STATIC s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw);
136 STATIC s32 e1000_k1_workaround_lv(struct e1000_hw *hw);
137 STATIC void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate);
139 /* ICH GbE Flash Hardware Sequencing Flash Status Register bit breakdown */
140 /* Offset 04h HSFSTS */
141 union ich8_hws_flash_status {
143 u16 flcdone:1; /* bit 0 Flash Cycle Done */
144 u16 flcerr:1; /* bit 1 Flash Cycle Error */
145 u16 dael:1; /* bit 2 Direct Access error Log */
146 u16 berasesz:2; /* bit 4:3 Sector Erase Size */
147 u16 flcinprog:1; /* bit 5 flash cycle in Progress */
148 u16 reserved1:2; /* bit 13:6 Reserved */
149 u16 reserved2:6; /* bit 13:6 Reserved */
150 u16 fldesvalid:1; /* bit 14 Flash Descriptor Valid */
151 u16 flockdn:1; /* bit 15 Flash Config Lock-Down */
156 /* ICH GbE Flash Hardware Sequencing Flash control Register bit breakdown */
157 /* Offset 06h FLCTL */
158 union ich8_hws_flash_ctrl {
159 struct ich8_hsflctl {
160 u16 flcgo:1; /* 0 Flash Cycle Go */
161 u16 flcycle:2; /* 2:1 Flash Cycle */
162 u16 reserved:5; /* 7:3 Reserved */
163 u16 fldbcount:2; /* 9:8 Flash Data Byte Count */
164 u16 flockdn:6; /* 15:10 Reserved */
169 /* ICH Flash Region Access Permissions */
170 union ich8_hws_flash_regacc {
172 u32 grra:8; /* 0:7 GbE region Read Access */
173 u32 grwa:8; /* 8:15 GbE region Write Access */
174 u32 gmrag:8; /* 23:16 GbE Master Read Access Grant */
175 u32 gmwag:8; /* 31:24 GbE Master Write Access Grant */
181 * e1000_phy_is_accessible_pchlan - Check if able to access PHY registers
182 * @hw: pointer to the HW structure
184 * Test access to the PHY registers by reading the PHY ID registers. If
185 * the PHY ID is already known (e.g. resume path) compare it with known ID,
186 * otherwise assume the read PHY ID is correct if it is valid.
188 * Assumes the sw/fw/hw semaphore is already acquired.
190 STATIC bool e1000_phy_is_accessible_pchlan(struct e1000_hw *hw)
198 for (retry_count = 0; retry_count < 2; retry_count++) {
199 ret_val = hw->phy.ops.read_reg_locked(hw, PHY_ID1, &phy_reg);
200 if (ret_val || (phy_reg == 0xFFFF))
202 phy_id = (u32)(phy_reg << 16);
204 ret_val = hw->phy.ops.read_reg_locked(hw, PHY_ID2, &phy_reg);
205 if (ret_val || (phy_reg == 0xFFFF)) {
209 phy_id |= (u32)(phy_reg & PHY_REVISION_MASK);
214 if (hw->phy.id == phy_id)
218 hw->phy.revision = (u32)(phy_reg & ~PHY_REVISION_MASK);
222 /* In case the PHY needs to be in mdio slow mode,
223 * set slow mode and try to get the PHY id again.
225 if (hw->mac.type < e1000_pch_lpt) {
226 hw->phy.ops.release(hw);
227 ret_val = e1000_set_mdio_slow_mode_hv(hw);
229 ret_val = e1000_get_phy_id(hw);
230 hw->phy.ops.acquire(hw);
236 if (hw->mac.type == e1000_pch_lpt) {
237 /* Unforce SMBus mode in PHY */
238 hw->phy.ops.read_reg_locked(hw, CV_SMB_CTRL, &phy_reg);
239 phy_reg &= ~CV_SMB_CTRL_FORCE_SMBUS;
240 hw->phy.ops.write_reg_locked(hw, CV_SMB_CTRL, phy_reg);
242 /* Unforce SMBus mode in MAC */
243 mac_reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
244 mac_reg &= ~E1000_CTRL_EXT_FORCE_SMBUS;
245 E1000_WRITE_REG(hw, E1000_CTRL_EXT, mac_reg);
252 * e1000_toggle_lanphypc_pch_lpt - toggle the LANPHYPC pin value
253 * @hw: pointer to the HW structure
255 * Toggling the LANPHYPC pin value fully power-cycles the PHY and is
256 * used to reset the PHY to a quiescent state when necessary.
258 STATIC void e1000_toggle_lanphypc_pch_lpt(struct e1000_hw *hw)
262 DEBUGFUNC("e1000_toggle_lanphypc_pch_lpt");
264 /* Set Phy Config Counter to 50msec */
265 mac_reg = E1000_READ_REG(hw, E1000_FEXTNVM3);
266 mac_reg &= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK;
267 mac_reg |= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC;
268 E1000_WRITE_REG(hw, E1000_FEXTNVM3, mac_reg);
270 /* Toggle LANPHYPC Value bit */
271 mac_reg = E1000_READ_REG(hw, E1000_CTRL);
272 mac_reg |= E1000_CTRL_LANPHYPC_OVERRIDE;
273 mac_reg &= ~E1000_CTRL_LANPHYPC_VALUE;
274 E1000_WRITE_REG(hw, E1000_CTRL, mac_reg);
275 E1000_WRITE_FLUSH(hw);
277 mac_reg &= ~E1000_CTRL_LANPHYPC_OVERRIDE;
278 E1000_WRITE_REG(hw, E1000_CTRL, mac_reg);
279 E1000_WRITE_FLUSH(hw);
281 if (hw->mac.type < e1000_pch_lpt) {
288 } while (!(E1000_READ_REG(hw, E1000_CTRL_EXT) &
289 E1000_CTRL_EXT_LPCD) && count--);
296 * e1000_init_phy_workarounds_pchlan - PHY initialization workarounds
297 * @hw: pointer to the HW structure
299 * Workarounds/flow necessary for PHY initialization during driver load
302 STATIC s32 e1000_init_phy_workarounds_pchlan(struct e1000_hw *hw)
304 u32 mac_reg, fwsm = E1000_READ_REG(hw, E1000_FWSM);
307 DEBUGFUNC("e1000_init_phy_workarounds_pchlan");
309 /* Gate automatic PHY configuration by hardware on managed and
310 * non-managed 82579 and newer adapters.
312 e1000_gate_hw_phy_config_ich8lan(hw, true);
315 /* It is not possible to be certain of the current state of ULP
316 * so forcibly disable it.
318 hw->dev_spec.ich8lan.ulp_state = e1000_ulp_state_unknown;
320 #endif /* ULP_SUPPORT */
321 ret_val = hw->phy.ops.acquire(hw);
323 DEBUGOUT("Failed to initialize PHY flow\n");
327 /* The MAC-PHY interconnect may be in SMBus mode. If the PHY is
328 * inaccessible and resetting the PHY is not blocked, toggle the
329 * LANPHYPC Value bit to force the interconnect to PCIe mode.
331 switch (hw->mac.type) {
333 if (e1000_phy_is_accessible_pchlan(hw))
336 /* Before toggling LANPHYPC, see if PHY is accessible by
337 * forcing MAC to SMBus mode first.
339 mac_reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
340 mac_reg |= E1000_CTRL_EXT_FORCE_SMBUS;
341 E1000_WRITE_REG(hw, E1000_CTRL_EXT, mac_reg);
343 /* Wait 50 milliseconds for MAC to finish any retries
344 * that it might be trying to perform from previous
345 * attempts to acknowledge any phy read requests.
351 if (e1000_phy_is_accessible_pchlan(hw))
356 if ((hw->mac.type == e1000_pchlan) &&
357 (fwsm & E1000_ICH_FWSM_FW_VALID))
360 if (hw->phy.ops.check_reset_block(hw)) {
361 DEBUGOUT("Required LANPHYPC toggle blocked by ME\n");
362 ret_val = -E1000_ERR_PHY;
366 /* Toggle LANPHYPC Value bit */
367 e1000_toggle_lanphypc_pch_lpt(hw);
368 if (hw->mac.type >= e1000_pch_lpt) {
369 if (e1000_phy_is_accessible_pchlan(hw))
372 /* Toggling LANPHYPC brings the PHY out of SMBus mode
373 * so ensure that the MAC is also out of SMBus mode
375 mac_reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
376 mac_reg &= ~E1000_CTRL_EXT_FORCE_SMBUS;
377 E1000_WRITE_REG(hw, E1000_CTRL_EXT, mac_reg);
379 if (e1000_phy_is_accessible_pchlan(hw))
382 ret_val = -E1000_ERR_PHY;
389 hw->phy.ops.release(hw);
392 /* Check to see if able to reset PHY. Print error if not */
393 if (hw->phy.ops.check_reset_block(hw)) {
394 ERROR_REPORT("Reset blocked by ME\n");
398 /* Reset the PHY before any access to it. Doing so, ensures
399 * that the PHY is in a known good state before we read/write
400 * PHY registers. The generic reset is sufficient here,
401 * because we haven't determined the PHY type yet.
403 ret_val = e1000_phy_hw_reset_generic(hw);
407 /* On a successful reset, possibly need to wait for the PHY
408 * to quiesce to an accessible state before returning control
409 * to the calling function. If the PHY does not quiesce, then
410 * return E1000E_BLK_PHY_RESET, as this is the condition that
413 ret_val = hw->phy.ops.check_reset_block(hw);
415 ERROR_REPORT("ME blocked access to PHY after reset\n");
419 /* Ungate automatic PHY configuration on non-managed 82579 */
420 if ((hw->mac.type == e1000_pch2lan) &&
421 !(fwsm & E1000_ICH_FWSM_FW_VALID)) {
423 e1000_gate_hw_phy_config_ich8lan(hw, false);
430 * e1000_init_phy_params_pchlan - Initialize PHY function pointers
431 * @hw: pointer to the HW structure
433 * Initialize family-specific PHY parameters and function pointers.
435 STATIC s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw)
437 struct e1000_phy_info *phy = &hw->phy;
440 DEBUGFUNC("e1000_init_phy_params_pchlan");
443 phy->reset_delay_us = 100;
445 phy->ops.acquire = e1000_acquire_swflag_ich8lan;
446 phy->ops.check_reset_block = e1000_check_reset_block_ich8lan;
447 phy->ops.get_cfg_done = e1000_get_cfg_done_ich8lan;
448 phy->ops.set_page = e1000_set_page_igp;
449 phy->ops.read_reg = e1000_read_phy_reg_hv;
450 phy->ops.read_reg_locked = e1000_read_phy_reg_hv_locked;
451 phy->ops.read_reg_page = e1000_read_phy_reg_page_hv;
452 phy->ops.release = e1000_release_swflag_ich8lan;
453 phy->ops.reset = e1000_phy_hw_reset_ich8lan;
454 phy->ops.set_d0_lplu_state = e1000_set_lplu_state_pchlan;
455 phy->ops.set_d3_lplu_state = e1000_set_lplu_state_pchlan;
456 phy->ops.write_reg = e1000_write_phy_reg_hv;
457 phy->ops.write_reg_locked = e1000_write_phy_reg_hv_locked;
458 phy->ops.write_reg_page = e1000_write_phy_reg_page_hv;
459 phy->ops.power_up = e1000_power_up_phy_copper;
460 phy->ops.power_down = e1000_power_down_phy_copper_ich8lan;
461 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
463 phy->id = e1000_phy_unknown;
465 ret_val = e1000_init_phy_workarounds_pchlan(hw);
469 if (phy->id == e1000_phy_unknown)
470 switch (hw->mac.type) {
472 ret_val = e1000_get_phy_id(hw);
475 if ((phy->id != 0) && (phy->id != PHY_REVISION_MASK))
480 /* In case the PHY needs to be in mdio slow mode,
481 * set slow mode and try to get the PHY id again.
483 ret_val = e1000_set_mdio_slow_mode_hv(hw);
486 ret_val = e1000_get_phy_id(hw);
491 phy->type = e1000_get_phy_type_from_id(phy->id);
494 case e1000_phy_82577:
495 case e1000_phy_82579:
497 phy->ops.check_polarity = e1000_check_polarity_82577;
498 phy->ops.force_speed_duplex =
499 e1000_phy_force_speed_duplex_82577;
500 phy->ops.get_cable_length = e1000_get_cable_length_82577;
501 phy->ops.get_info = e1000_get_phy_info_82577;
502 phy->ops.commit = e1000_phy_sw_reset_generic;
504 case e1000_phy_82578:
505 phy->ops.check_polarity = e1000_check_polarity_m88;
506 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_m88;
507 phy->ops.get_cable_length = e1000_get_cable_length_m88;
508 phy->ops.get_info = e1000_get_phy_info_m88;
511 ret_val = -E1000_ERR_PHY;
519 * e1000_init_phy_params_ich8lan - Initialize PHY function pointers
520 * @hw: pointer to the HW structure
522 * Initialize family-specific PHY parameters and function pointers.
524 STATIC s32 e1000_init_phy_params_ich8lan(struct e1000_hw *hw)
526 struct e1000_phy_info *phy = &hw->phy;
530 DEBUGFUNC("e1000_init_phy_params_ich8lan");
533 phy->reset_delay_us = 100;
535 phy->ops.acquire = e1000_acquire_swflag_ich8lan;
536 phy->ops.check_reset_block = e1000_check_reset_block_ich8lan;
537 phy->ops.get_cable_length = e1000_get_cable_length_igp_2;
538 phy->ops.get_cfg_done = e1000_get_cfg_done_ich8lan;
539 phy->ops.read_reg = e1000_read_phy_reg_igp;
540 phy->ops.release = e1000_release_swflag_ich8lan;
541 phy->ops.reset = e1000_phy_hw_reset_ich8lan;
542 phy->ops.set_d0_lplu_state = e1000_set_d0_lplu_state_ich8lan;
543 phy->ops.set_d3_lplu_state = e1000_set_d3_lplu_state_ich8lan;
544 phy->ops.write_reg = e1000_write_phy_reg_igp;
545 phy->ops.power_up = e1000_power_up_phy_copper;
546 phy->ops.power_down = e1000_power_down_phy_copper_ich8lan;
548 /* We may need to do this twice - once for IGP and if that fails,
549 * we'll set BM func pointers and try again
551 ret_val = e1000_determine_phy_address(hw);
553 phy->ops.write_reg = e1000_write_phy_reg_bm;
554 phy->ops.read_reg = e1000_read_phy_reg_bm;
555 ret_val = e1000_determine_phy_address(hw);
557 DEBUGOUT("Cannot determine PHY addr. Erroring out\n");
563 while ((e1000_phy_unknown == e1000_get_phy_type_from_id(phy->id)) &&
566 ret_val = e1000_get_phy_id(hw);
573 case IGP03E1000_E_PHY_ID:
574 phy->type = e1000_phy_igp_3;
575 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
576 phy->ops.read_reg_locked = e1000_read_phy_reg_igp_locked;
577 phy->ops.write_reg_locked = e1000_write_phy_reg_igp_locked;
578 phy->ops.get_info = e1000_get_phy_info_igp;
579 phy->ops.check_polarity = e1000_check_polarity_igp;
580 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_igp;
583 case IFE_PLUS_E_PHY_ID:
585 phy->type = e1000_phy_ife;
586 phy->autoneg_mask = E1000_ALL_NOT_GIG;
587 phy->ops.get_info = e1000_get_phy_info_ife;
588 phy->ops.check_polarity = e1000_check_polarity_ife;
589 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_ife;
591 case BME1000_E_PHY_ID:
592 phy->type = e1000_phy_bm;
593 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
594 phy->ops.read_reg = e1000_read_phy_reg_bm;
595 phy->ops.write_reg = e1000_write_phy_reg_bm;
596 phy->ops.commit = e1000_phy_sw_reset_generic;
597 phy->ops.get_info = e1000_get_phy_info_m88;
598 phy->ops.check_polarity = e1000_check_polarity_m88;
599 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_m88;
602 return -E1000_ERR_PHY;
606 return E1000_SUCCESS;
610 * e1000_init_nvm_params_ich8lan - Initialize NVM function pointers
611 * @hw: pointer to the HW structure
613 * Initialize family-specific NVM parameters and function
616 STATIC s32 e1000_init_nvm_params_ich8lan(struct e1000_hw *hw)
618 struct e1000_nvm_info *nvm = &hw->nvm;
619 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
620 u32 gfpreg, sector_base_addr, sector_end_addr;
623 DEBUGFUNC("e1000_init_nvm_params_ich8lan");
625 /* Can't read flash registers if the register set isn't mapped. */
626 nvm->type = e1000_nvm_flash_sw;
627 if (!hw->flash_address) {
628 DEBUGOUT("ERROR: Flash registers not mapped\n");
629 return -E1000_ERR_CONFIG;
632 gfpreg = E1000_READ_FLASH_REG(hw, ICH_FLASH_GFPREG);
634 /* sector_X_addr is a "sector"-aligned address (4096 bytes)
635 * Add 1 to sector_end_addr since this sector is included in
638 sector_base_addr = gfpreg & FLASH_GFPREG_BASE_MASK;
639 sector_end_addr = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK) + 1;
641 /* flash_base_addr is byte-aligned */
642 nvm->flash_base_addr = sector_base_addr << FLASH_SECTOR_ADDR_SHIFT;
644 /* find total size of the NVM, then cut in half since the total
645 * size represents two separate NVM banks.
647 nvm->flash_bank_size = ((sector_end_addr - sector_base_addr)
648 << FLASH_SECTOR_ADDR_SHIFT);
649 nvm->flash_bank_size /= 2;
650 /* Adjust to word count */
651 nvm->flash_bank_size /= sizeof(u16);
653 nvm->word_size = E1000_SHADOW_RAM_WORDS;
655 /* Clear shadow ram */
656 for (i = 0; i < nvm->word_size; i++) {
657 dev_spec->shadow_ram[i].modified = false;
658 dev_spec->shadow_ram[i].value = 0xFFFF;
661 E1000_MUTEX_INIT(&dev_spec->nvm_mutex);
662 E1000_MUTEX_INIT(&dev_spec->swflag_mutex);
664 /* Function Pointers */
665 nvm->ops.acquire = e1000_acquire_nvm_ich8lan;
666 nvm->ops.release = e1000_release_nvm_ich8lan;
667 nvm->ops.read = e1000_read_nvm_ich8lan;
668 nvm->ops.update = e1000_update_nvm_checksum_ich8lan;
669 nvm->ops.valid_led_default = e1000_valid_led_default_ich8lan;
670 nvm->ops.validate = e1000_validate_nvm_checksum_ich8lan;
671 nvm->ops.write = e1000_write_nvm_ich8lan;
673 return E1000_SUCCESS;
677 * e1000_init_mac_params_ich8lan - Initialize MAC function pointers
678 * @hw: pointer to the HW structure
680 * Initialize family-specific MAC parameters and function
683 STATIC s32 e1000_init_mac_params_ich8lan(struct e1000_hw *hw)
685 struct e1000_mac_info *mac = &hw->mac;
686 #if defined(QV_RELEASE) || !defined(NO_PCH_LPT_B0_SUPPORT)
688 #endif /* QV_RELEASE || !defined(NO_PCH_LPT_B0_SUPPORT) */
690 DEBUGFUNC("e1000_init_mac_params_ich8lan");
692 /* Set media type function pointer */
693 hw->phy.media_type = e1000_media_type_copper;
695 /* Set mta register count */
696 mac->mta_reg_count = 32;
697 /* Set rar entry count */
698 mac->rar_entry_count = E1000_ICH_RAR_ENTRIES;
699 if (mac->type == e1000_ich8lan)
700 mac->rar_entry_count--;
701 /* Set if part includes ASF firmware */
702 mac->asf_firmware_present = true;
704 mac->has_fwsm = true;
705 /* ARC subsystem not supported */
706 mac->arc_subsystem_valid = false;
707 /* Adaptive IFS supported */
708 mac->adaptive_ifs = true;
710 /* Function pointers */
712 /* bus type/speed/width */
713 mac->ops.get_bus_info = e1000_get_bus_info_ich8lan;
715 mac->ops.set_lan_id = e1000_set_lan_id_single_port;
717 mac->ops.reset_hw = e1000_reset_hw_ich8lan;
718 /* hw initialization */
719 mac->ops.init_hw = e1000_init_hw_ich8lan;
721 mac->ops.setup_link = e1000_setup_link_ich8lan;
722 /* physical interface setup */
723 mac->ops.setup_physical_interface = e1000_setup_copper_link_ich8lan;
725 mac->ops.check_for_link = e1000_check_for_copper_link_ich8lan;
727 mac->ops.get_link_up_info = e1000_get_link_up_info_ich8lan;
728 /* multicast address update */
729 mac->ops.update_mc_addr_list = e1000_update_mc_addr_list_generic;
730 /* clear hardware counters */
731 mac->ops.clear_hw_cntrs = e1000_clear_hw_cntrs_ich8lan;
733 /* LED and other operations */
738 /* check management mode */
739 mac->ops.check_mng_mode = e1000_check_mng_mode_ich8lan;
741 mac->ops.id_led_init = e1000_id_led_init_generic;
743 mac->ops.blink_led = e1000_blink_led_generic;
745 mac->ops.setup_led = e1000_setup_led_generic;
747 mac->ops.cleanup_led = e1000_cleanup_led_ich8lan;
748 /* turn on/off LED */
749 mac->ops.led_on = e1000_led_on_ich8lan;
750 mac->ops.led_off = e1000_led_off_ich8lan;
753 mac->rar_entry_count = E1000_PCH2_RAR_ENTRIES;
754 mac->ops.rar_set = e1000_rar_set_pch2lan;
757 #ifndef NO_NON_BLOCKING_PHY_MTA_UPDATE_SUPPORT
758 /* multicast address update for pch2 */
759 mac->ops.update_mc_addr_list =
760 e1000_update_mc_addr_list_pch2lan;
764 #if defined(QV_RELEASE) || !defined(NO_PCH_LPT_B0_SUPPORT)
765 /* save PCH revision_id */
766 e1000_read_pci_cfg(hw, E1000_PCI_REVISION_ID_REG, &pci_cfg);
767 hw->revision_id = (u8)(pci_cfg &= 0x000F);
768 #endif /* QV_RELEASE || !defined(NO_PCH_LPT_B0_SUPPORT) */
769 /* check management mode */
770 mac->ops.check_mng_mode = e1000_check_mng_mode_pchlan;
772 mac->ops.id_led_init = e1000_id_led_init_pchlan;
774 mac->ops.setup_led = e1000_setup_led_pchlan;
776 mac->ops.cleanup_led = e1000_cleanup_led_pchlan;
777 /* turn on/off LED */
778 mac->ops.led_on = e1000_led_on_pchlan;
779 mac->ops.led_off = e1000_led_off_pchlan;
785 if (mac->type == e1000_pch_lpt) {
786 mac->rar_entry_count = E1000_PCH_LPT_RAR_ENTRIES;
787 mac->ops.rar_set = e1000_rar_set_pch_lpt;
788 mac->ops.setup_physical_interface = e1000_setup_copper_link_pch_lpt;
791 /* Enable PCS Lock-loss workaround for ICH8 */
792 if (mac->type == e1000_ich8lan)
793 e1000_set_kmrn_lock_loss_workaround_ich8lan(hw, true);
795 return E1000_SUCCESS;
799 * __e1000_access_emi_reg_locked - Read/write EMI register
800 * @hw: pointer to the HW structure
801 * @addr: EMI address to program
802 * @data: pointer to value to read/write from/to the EMI address
803 * @read: boolean flag to indicate read or write
805 * This helper function assumes the SW/FW/HW Semaphore is already acquired.
807 STATIC s32 __e1000_access_emi_reg_locked(struct e1000_hw *hw, u16 address,
808 u16 *data, bool read)
812 DEBUGFUNC("__e1000_access_emi_reg_locked");
814 ret_val = hw->phy.ops.write_reg_locked(hw, I82579_EMI_ADDR, address);
819 ret_val = hw->phy.ops.read_reg_locked(hw, I82579_EMI_DATA,
822 ret_val = hw->phy.ops.write_reg_locked(hw, I82579_EMI_DATA,
829 * e1000_read_emi_reg_locked - Read Extended Management Interface register
830 * @hw: pointer to the HW structure
831 * @addr: EMI address to program
832 * @data: value to be read from the EMI address
834 * Assumes the SW/FW/HW Semaphore is already acquired.
836 s32 e1000_read_emi_reg_locked(struct e1000_hw *hw, u16 addr, u16 *data)
838 DEBUGFUNC("e1000_read_emi_reg_locked");
840 return __e1000_access_emi_reg_locked(hw, addr, data, true);
844 * e1000_write_emi_reg_locked - Write Extended Management Interface register
845 * @hw: pointer to the HW structure
846 * @addr: EMI address to program
847 * @data: value to be written to the EMI address
849 * Assumes the SW/FW/HW Semaphore is already acquired.
851 s32 e1000_write_emi_reg_locked(struct e1000_hw *hw, u16 addr, u16 data)
853 DEBUGFUNC("e1000_read_emi_reg_locked");
855 return __e1000_access_emi_reg_locked(hw, addr, &data, false);
859 * e1000_set_eee_pchlan - Enable/disable EEE support
860 * @hw: pointer to the HW structure
862 * Enable/disable EEE based on setting in dev_spec structure, the duplex of
863 * the link and the EEE capabilities of the link partner. The LPI Control
864 * register bits will remain set only if/when link is up.
866 * EEE LPI must not be asserted earlier than one second after link is up.
867 * On 82579, EEE LPI should not be enabled until such time otherwise there
868 * can be link issues with some switches. Other devices can have EEE LPI
869 * enabled immediately upon link up since they have a timer in hardware which
870 * prevents LPI from being asserted too early.
872 s32 e1000_set_eee_pchlan(struct e1000_hw *hw)
874 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
876 u16 lpa, pcs_status, adv, adv_addr, lpi_ctrl, data;
878 DEBUGFUNC("e1000_set_eee_pchlan");
880 switch (hw->phy.type) {
881 case e1000_phy_82579:
882 lpa = I82579_EEE_LP_ABILITY;
883 pcs_status = I82579_EEE_PCS_STATUS;
884 adv_addr = I82579_EEE_ADVERTISEMENT;
887 lpa = I217_EEE_LP_ABILITY;
888 pcs_status = I217_EEE_PCS_STATUS;
889 adv_addr = I217_EEE_ADVERTISEMENT;
892 return E1000_SUCCESS;
895 ret_val = hw->phy.ops.acquire(hw);
899 ret_val = hw->phy.ops.read_reg_locked(hw, I82579_LPI_CTRL, &lpi_ctrl);
903 /* Clear bits that enable EEE in various speeds */
904 lpi_ctrl &= ~I82579_LPI_CTRL_ENABLE_MASK;
906 /* Enable EEE if not disabled by user */
907 if (!dev_spec->eee_disable) {
908 /* Save off link partner's EEE ability */
909 ret_val = e1000_read_emi_reg_locked(hw, lpa,
910 &dev_spec->eee_lp_ability);
914 /* Read EEE advertisement */
915 ret_val = e1000_read_emi_reg_locked(hw, adv_addr, &adv);
919 /* Enable EEE only for speeds in which the link partner is
920 * EEE capable and for which we advertise EEE.
922 if (adv & dev_spec->eee_lp_ability & I82579_EEE_1000_SUPPORTED)
923 lpi_ctrl |= I82579_LPI_CTRL_1000_ENABLE;
925 if (adv & dev_spec->eee_lp_ability & I82579_EEE_100_SUPPORTED) {
926 hw->phy.ops.read_reg_locked(hw, PHY_LP_ABILITY, &data);
927 if (data & NWAY_LPAR_100TX_FD_CAPS)
928 lpi_ctrl |= I82579_LPI_CTRL_100_ENABLE;
930 /* EEE is not supported in 100Half, so ignore
931 * partner's EEE in 100 ability if full-duplex
934 dev_spec->eee_lp_ability &=
935 ~I82579_EEE_100_SUPPORTED;
939 if (hw->phy.type == e1000_phy_82579) {
940 ret_val = e1000_read_emi_reg_locked(hw, I82579_LPI_PLL_SHUT,
945 data &= ~I82579_LPI_100_PLL_SHUT;
946 ret_val = e1000_write_emi_reg_locked(hw, I82579_LPI_PLL_SHUT,
950 /* R/Clr IEEE MMD 3.1 bits 11:10 - Tx/Rx LPI Received */
951 ret_val = e1000_read_emi_reg_locked(hw, pcs_status, &data);
955 ret_val = hw->phy.ops.write_reg_locked(hw, I82579_LPI_CTRL, lpi_ctrl);
957 hw->phy.ops.release(hw);
963 * e1000_k1_workaround_lpt_lp - K1 workaround on Lynxpoint-LP
964 * @hw: pointer to the HW structure
965 * @link: link up bool flag
967 * When K1 is enabled for 1Gbps, the MAC can miss 2 DMA completion indications
968 * preventing further DMA write requests. Workaround the issue by disabling
969 * the de-assertion of the clock request when in 1Gpbs mode.
970 * Also, set appropriate Tx re-transmission timeouts for 10 and 100Half link
971 * speeds in order to avoid Tx hangs.
973 STATIC s32 e1000_k1_workaround_lpt_lp(struct e1000_hw *hw, bool link)
975 u32 fextnvm6 = E1000_READ_REG(hw, E1000_FEXTNVM6);
976 u32 status = E1000_READ_REG(hw, E1000_STATUS);
977 s32 ret_val = E1000_SUCCESS;
980 if (link && (status & E1000_STATUS_SPEED_1000)) {
981 ret_val = hw->phy.ops.acquire(hw);
986 e1000_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
992 e1000_write_kmrn_reg_locked(hw,
993 E1000_KMRNCTRLSTA_K1_CONFIG,
995 ~E1000_KMRNCTRLSTA_K1_ENABLE);
1001 E1000_WRITE_REG(hw, E1000_FEXTNVM6,
1002 fextnvm6 | E1000_FEXTNVM6_REQ_PLL_CLK);
1005 e1000_write_kmrn_reg_locked(hw,
1006 E1000_KMRNCTRLSTA_K1_CONFIG,
1009 hw->phy.ops.release(hw);
1011 /* clear FEXTNVM6 bit 8 on link down or 10/100 */
1012 fextnvm6 &= ~E1000_FEXTNVM6_REQ_PLL_CLK;
1014 if (!link || ((status & E1000_STATUS_SPEED_100) &&
1015 (status & E1000_STATUS_FD)))
1016 goto update_fextnvm6;
1018 ret_val = hw->phy.ops.read_reg(hw, I217_INBAND_CTRL, ®);
1022 /* Clear link status transmit timeout */
1023 reg &= ~I217_INBAND_CTRL_LINK_STAT_TX_TIMEOUT_MASK;
1025 if (status & E1000_STATUS_SPEED_100) {
1026 /* Set inband Tx timeout to 5x10us for 100Half */
1027 reg |= 5 << I217_INBAND_CTRL_LINK_STAT_TX_TIMEOUT_SHIFT;
1029 /* Do not extend the K1 entry latency for 100Half */
1030 fextnvm6 &= ~E1000_FEXTNVM6_ENABLE_K1_ENTRY_CONDITION;
1032 /* Set inband Tx timeout to 50x10us for 10Full/Half */
1034 I217_INBAND_CTRL_LINK_STAT_TX_TIMEOUT_SHIFT;
1036 /* Extend the K1 entry latency for 10 Mbps */
1037 fextnvm6 |= E1000_FEXTNVM6_ENABLE_K1_ENTRY_CONDITION;
1040 ret_val = hw->phy.ops.write_reg(hw, I217_INBAND_CTRL, reg);
1045 E1000_WRITE_REG(hw, E1000_FEXTNVM6, fextnvm6);
1053 * e1000_enable_ulp_lpt_lp - configure Ultra Low Power mode for LynxPoint-LP
1054 * @hw: pointer to the HW structure
1055 * @to_sx: boolean indicating a system power state transition to Sx
1057 * When link is down, configure ULP mode to significantly reduce the power
1058 * to the PHY. If on a Manageability Engine (ME) enabled system, tell the
1059 * ME firmware to start the ULP configuration. If not on an ME enabled
1060 * system, configure the ULP mode by software.
1062 s32 e1000_enable_ulp_lpt_lp(struct e1000_hw *hw, bool to_sx)
1065 s32 ret_val = E1000_SUCCESS;
1068 if ((hw->mac.type < e1000_pch_lpt) ||
1069 (hw->device_id == E1000_DEV_ID_PCH_LPT_I217_LM) ||
1070 (hw->device_id == E1000_DEV_ID_PCH_LPT_I217_V) ||
1071 (hw->device_id == E1000_DEV_ID_PCH_I218_LM2) ||
1072 (hw->device_id == E1000_DEV_ID_PCH_I218_V2) ||
1073 (hw->dev_spec.ich8lan.ulp_state == e1000_ulp_state_on))
1078 /* Poll up to 5 seconds for Cable Disconnected indication */
1079 while (!(E1000_READ_REG(hw, E1000_FEXT) &
1080 E1000_FEXT_PHY_CABLE_DISCONNECTED)) {
1081 /* Bail if link is re-acquired */
1082 if (E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU)
1083 return -E1000_ERR_PHY;
1089 DEBUGOUT2("CABLE_DISCONNECTED %s set after %dmsec\n",
1090 (E1000_READ_REG(hw, E1000_FEXT) &
1091 E1000_FEXT_PHY_CABLE_DISCONNECTED) ? "" : "not",
1095 if (E1000_READ_REG(hw, E1000_FWSM) & E1000_ICH_FWSM_FW_VALID) {
1096 /* Request ME configure ULP mode in the PHY */
1097 mac_reg = E1000_READ_REG(hw, E1000_H2ME);
1098 mac_reg |= E1000_H2ME_ULP | E1000_H2ME_ENFORCE_SETTINGS;
1099 E1000_WRITE_REG(hw, E1000_H2ME, mac_reg);
1104 ret_val = hw->phy.ops.acquire(hw);
1108 /* During S0 Idle keep the phy in PCI-E mode */
1109 if (hw->dev_spec.ich8lan.smbus_disable)
1112 /* Force SMBus mode in PHY */
1113 ret_val = e1000_read_phy_reg_hv_locked(hw, CV_SMB_CTRL, &phy_reg);
1116 phy_reg |= CV_SMB_CTRL_FORCE_SMBUS;
1117 e1000_write_phy_reg_hv_locked(hw, CV_SMB_CTRL, phy_reg);
1119 /* Force SMBus mode in MAC */
1120 mac_reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
1121 mac_reg |= E1000_CTRL_EXT_FORCE_SMBUS;
1122 E1000_WRITE_REG(hw, E1000_CTRL_EXT, mac_reg);
1126 /* Change the 'Link Status Change' interrupt to trigger
1127 * on 'Cable Status Change'
1129 ret_val = e1000_read_kmrn_reg_locked(hw,
1130 E1000_KMRNCTRLSTA_OP_MODES,
1134 phy_reg |= E1000_KMRNCTRLSTA_OP_MODES_LSC2CSC;
1135 e1000_write_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_OP_MODES,
1139 /* Set Inband ULP Exit, Reset to SMBus mode and
1140 * Disable SMBus Release on PERST# in PHY
1142 ret_val = e1000_read_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, &phy_reg);
1145 phy_reg |= (I218_ULP_CONFIG1_RESET_TO_SMBUS |
1146 I218_ULP_CONFIG1_DISABLE_SMB_PERST);
1148 if (E1000_READ_REG(hw, E1000_WUFC) & E1000_WUFC_LNKC)
1149 phy_reg |= I218_ULP_CONFIG1_WOL_HOST;
1151 phy_reg |= I218_ULP_CONFIG1_STICKY_ULP;
1153 phy_reg |= I218_ULP_CONFIG1_INBAND_EXIT;
1155 e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
1157 /* Set Disable SMBus Release on PERST# in MAC */
1158 mac_reg = E1000_READ_REG(hw, E1000_FEXTNVM7);
1159 mac_reg |= E1000_FEXTNVM7_DISABLE_SMB_PERST;
1160 E1000_WRITE_REG(hw, E1000_FEXTNVM7, mac_reg);
1162 /* Commit ULP changes in PHY by starting auto ULP configuration */
1163 phy_reg |= I218_ULP_CONFIG1_START;
1164 e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
1167 /* Disable Tx so that the MAC doesn't send any (buffered)
1168 * packets to the PHY.
1170 mac_reg = E1000_READ_REG(hw, E1000_TCTL);
1171 mac_reg &= ~E1000_TCTL_EN;
1172 E1000_WRITE_REG(hw, E1000_TCTL, mac_reg);
1175 hw->phy.ops.release(hw);
1178 DEBUGOUT1("Error in ULP enable flow: %d\n", ret_val);
1180 hw->dev_spec.ich8lan.ulp_state = e1000_ulp_state_on;
1186 * e1000_disable_ulp_lpt_lp - unconfigure Ultra Low Power mode for LynxPoint-LP
1187 * @hw: pointer to the HW structure
1188 * @force: boolean indicating whether or not to force disabling ULP
1190 * Un-configure ULP mode when link is up, the system is transitioned from
1191 * Sx or the driver is unloaded. If on a Manageability Engine (ME) enabled
1192 * system, poll for an indication from ME that ULP has been un-configured.
1193 * If not on an ME enabled system, un-configure the ULP mode by software.
1195 * During nominal operation, this function is called when link is acquired
1196 * to disable ULP mode (force=false); otherwise, for example when unloading
1197 * the driver or during Sx->S0 transitions, this is called with force=true
1198 * to forcibly disable ULP.
1200 * When the cable is plugged in while the device is in D0, a Cable Status
1201 * Change interrupt is generated which causes this function to be called
1202 * to partially disable ULP mode and restart autonegotiation. This function
1203 * is then called again due to the resulting Link Status Change interrupt
1204 * to finish cleaning up after the ULP flow.
1206 s32 e1000_disable_ulp_lpt_lp(struct e1000_hw *hw, bool force)
1208 s32 ret_val = E1000_SUCCESS;
1213 if ((hw->mac.type < e1000_pch_lpt) ||
1214 (hw->device_id == E1000_DEV_ID_PCH_LPT_I217_LM) ||
1215 (hw->device_id == E1000_DEV_ID_PCH_LPT_I217_V) ||
1216 (hw->device_id == E1000_DEV_ID_PCH_I218_LM2) ||
1217 (hw->device_id == E1000_DEV_ID_PCH_I218_V2) ||
1218 (hw->dev_spec.ich8lan.ulp_state == e1000_ulp_state_off))
1221 if (E1000_READ_REG(hw, E1000_FWSM) & E1000_ICH_FWSM_FW_VALID) {
1223 /* Request ME un-configure ULP mode in the PHY */
1224 mac_reg = E1000_READ_REG(hw, E1000_H2ME);
1225 mac_reg &= ~E1000_H2ME_ULP;
1226 mac_reg |= E1000_H2ME_ENFORCE_SETTINGS;
1227 E1000_WRITE_REG(hw, E1000_H2ME, mac_reg);
1230 /* Poll up to 100msec for ME to clear ULP_CFG_DONE */
1231 while (E1000_READ_REG(hw, E1000_FWSM) &
1232 E1000_FWSM_ULP_CFG_DONE) {
1234 ret_val = -E1000_ERR_PHY;
1240 DEBUGOUT1("ULP_CONFIG_DONE cleared after %dmsec\n", i * 10);
1243 mac_reg = E1000_READ_REG(hw, E1000_H2ME);
1244 mac_reg &= ~E1000_H2ME_ENFORCE_SETTINGS;
1245 E1000_WRITE_REG(hw, E1000_H2ME, mac_reg);
1247 /* Clear H2ME.ULP after ME ULP configuration */
1248 mac_reg = E1000_READ_REG(hw, E1000_H2ME);
1249 mac_reg &= ~E1000_H2ME_ULP;
1250 E1000_WRITE_REG(hw, E1000_H2ME, mac_reg);
1252 /* Restore link speed advertisements and restart
1255 ret_val = e1000_phy_setup_autoneg(hw);
1259 ret_val = e1000_oem_bits_config_ich8lan(hw, true);
1265 ret_val = hw->phy.ops.acquire(hw);
1269 /* Revert the change to the 'Link Status Change'
1270 * interrupt to trigger on 'Cable Status Change'
1272 ret_val = e1000_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_OP_MODES,
1276 phy_reg &= ~E1000_KMRNCTRLSTA_OP_MODES_LSC2CSC;
1277 e1000_write_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_OP_MODES, phy_reg);
1280 /* Toggle LANPHYPC Value bit */
1281 e1000_toggle_lanphypc_pch_lpt(hw);
1283 /* Unforce SMBus mode in PHY */
1284 ret_val = e1000_read_phy_reg_hv_locked(hw, CV_SMB_CTRL, &phy_reg);
1286 /* The MAC might be in PCIe mode, so temporarily force to
1287 * SMBus mode in order to access the PHY.
1289 mac_reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
1290 mac_reg |= E1000_CTRL_EXT_FORCE_SMBUS;
1291 E1000_WRITE_REG(hw, E1000_CTRL_EXT, mac_reg);
1295 ret_val = e1000_read_phy_reg_hv_locked(hw, CV_SMB_CTRL,
1300 phy_reg &= ~CV_SMB_CTRL_FORCE_SMBUS;
1301 e1000_write_phy_reg_hv_locked(hw, CV_SMB_CTRL, phy_reg);
1303 /* Unforce SMBus mode in MAC */
1304 mac_reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
1305 mac_reg &= ~E1000_CTRL_EXT_FORCE_SMBUS;
1306 E1000_WRITE_REG(hw, E1000_CTRL_EXT, mac_reg);
1308 /* When ULP mode was previously entered, K1 was disabled by the
1309 * hardware. Re-Enable K1 in the PHY when exiting ULP.
1311 ret_val = e1000_read_phy_reg_hv_locked(hw, HV_PM_CTRL, &phy_reg);
1314 phy_reg |= HV_PM_CTRL_K1_ENABLE;
1315 e1000_write_phy_reg_hv_locked(hw, HV_PM_CTRL, phy_reg);
1317 /* Clear ULP enabled configuration */
1318 ret_val = e1000_read_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, &phy_reg);
1321 /* CSC interrupt received due to ULP Indication */
1322 if ((phy_reg & I218_ULP_CONFIG1_IND) || force) {
1323 phy_reg &= ~(I218_ULP_CONFIG1_IND |
1324 I218_ULP_CONFIG1_STICKY_ULP |
1325 I218_ULP_CONFIG1_RESET_TO_SMBUS |
1326 I218_ULP_CONFIG1_WOL_HOST |
1327 I218_ULP_CONFIG1_INBAND_EXIT |
1328 I218_ULP_CONFIG1_DISABLE_SMB_PERST);
1329 e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
1331 /* Commit ULP changes by starting auto ULP configuration */
1332 phy_reg |= I218_ULP_CONFIG1_START;
1333 e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
1335 /* Clear Disable SMBus Release on PERST# in MAC */
1336 mac_reg = E1000_READ_REG(hw, E1000_FEXTNVM7);
1337 mac_reg &= ~E1000_FEXTNVM7_DISABLE_SMB_PERST;
1338 E1000_WRITE_REG(hw, E1000_FEXTNVM7, mac_reg);
1341 hw->phy.ops.release(hw);
1343 if (hw->mac.autoneg)
1344 e1000_phy_setup_autoneg(hw);
1346 e1000_sw_lcd_config_ich8lan(hw);
1348 e1000_oem_bits_config_ich8lan(hw, true);
1350 /* Set ULP state to unknown and return non-zero to
1351 * indicate no link (yet) and re-enter on the next LSC
1352 * to finish disabling ULP flow.
1354 hw->dev_spec.ich8lan.ulp_state =
1355 e1000_ulp_state_unknown;
1362 mac_reg = E1000_READ_REG(hw, E1000_TCTL);
1363 mac_reg |= E1000_TCTL_EN;
1364 E1000_WRITE_REG(hw, E1000_TCTL, mac_reg);
1367 hw->phy.ops.release(hw);
1369 hw->phy.ops.reset(hw);
1374 DEBUGOUT1("Error in ULP disable flow: %d\n", ret_val);
1376 hw->dev_spec.ich8lan.ulp_state = e1000_ulp_state_off;
1381 #endif /* ULP_SUPPORT */
1383 * e1000_check_for_copper_link_ich8lan - Check for link (Copper)
1384 * @hw: pointer to the HW structure
1386 * Checks to see of the link status of the hardware has changed. If a
1387 * change in link status has been detected, then we read the PHY registers
1388 * to get the current speed/duplex if link exists.
1390 STATIC s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw)
1392 struct e1000_mac_info *mac = &hw->mac;
1393 s32 ret_val, tipg_reg = 0;
1394 u16 emi_addr, emi_val = 0;
1398 DEBUGFUNC("e1000_check_for_copper_link_ich8lan");
1400 /* We only want to go out to the PHY registers to see if Auto-Neg
1401 * has completed and/or if our link status has changed. The
1402 * get_link_status flag is set upon receiving a Link Status
1403 * Change or Rx Sequence Error interrupt.
1405 if (!mac->get_link_status)
1406 return E1000_SUCCESS;
1408 if ((hw->mac.type < e1000_pch_lpt) ||
1409 (hw->device_id == E1000_DEV_ID_PCH_LPT_I217_LM) ||
1410 (hw->device_id == E1000_DEV_ID_PCH_LPT_I217_V)) {
1411 /* First we want to see if the MII Status Register reports
1412 * link. If so, then we want to get the current speed/duplex
1415 ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link);
1419 /* Check the MAC's STATUS register to determine link state
1420 * since the PHY could be inaccessible while in ULP mode.
1422 link = !!(E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU);
1424 ret_val = e1000_disable_ulp_lpt_lp(hw, false);
1426 ret_val = e1000_enable_ulp_lpt_lp(hw, false);
1432 if (hw->mac.type == e1000_pchlan) {
1433 ret_val = e1000_k1_gig_workaround_hv(hw, link);
1438 /* When connected at 10Mbps half-duplex, some parts are excessively
1439 * aggressive resulting in many collisions. To avoid this, increase
1440 * the IPG and reduce Rx latency in the PHY.
1442 if (((hw->mac.type == e1000_pch2lan) ||
1443 (hw->mac.type == e1000_pch_lpt)) && link) {
1446 e1000_get_speed_and_duplex_copper_generic(hw, &speed, &duplex);
1447 tipg_reg = E1000_READ_REG(hw, E1000_TIPG);
1448 tipg_reg &= ~E1000_TIPG_IPGT_MASK;
1450 if (duplex == HALF_DUPLEX && speed == SPEED_10) {
1452 /* Reduce Rx latency in analog PHY */
1455 /* Roll back the default values */
1460 E1000_WRITE_REG(hw, E1000_TIPG, tipg_reg);
1462 ret_val = hw->phy.ops.acquire(hw);
1466 if (hw->mac.type == e1000_pch2lan)
1467 emi_addr = I82579_RX_CONFIG;
1469 emi_addr = I217_RX_CONFIG;
1470 ret_val = e1000_write_emi_reg_locked(hw, emi_addr, emi_val);
1472 hw->phy.ops.release(hw);
1478 /* Work-around I218 hang issue */
1479 if ((hw->device_id == E1000_DEV_ID_PCH_LPTLP_I218_LM) ||
1480 (hw->device_id == E1000_DEV_ID_PCH_LPTLP_I218_V) ||
1481 (hw->device_id == E1000_DEV_ID_PCH_I218_LM3) ||
1482 (hw->device_id == E1000_DEV_ID_PCH_I218_V3)) {
1483 ret_val = e1000_k1_workaround_lpt_lp(hw, link);
1488 /* Clear link partner's EEE ability */
1489 hw->dev_spec.ich8lan.eee_lp_ability = 0;
1492 return E1000_SUCCESS; /* No link detected */
1494 mac->get_link_status = false;
1496 switch (hw->mac.type) {
1498 ret_val = e1000_k1_workaround_lv(hw);
1503 if (hw->phy.type == e1000_phy_82578) {
1504 ret_val = e1000_link_stall_workaround_hv(hw);
1509 /* Workaround for PCHx parts in half-duplex:
1510 * Set the number of preambles removed from the packet
1511 * when it is passed from the PHY to the MAC to prevent
1512 * the MAC from misinterpreting the packet type.
1514 hw->phy.ops.read_reg(hw, HV_KMRN_FIFO_CTRLSTA, &phy_reg);
1515 phy_reg &= ~HV_KMRN_FIFO_CTRLSTA_PREAMBLE_MASK;
1517 if ((E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_FD) !=
1519 phy_reg |= (1 << HV_KMRN_FIFO_CTRLSTA_PREAMBLE_SHIFT);
1521 hw->phy.ops.write_reg(hw, HV_KMRN_FIFO_CTRLSTA, phy_reg);
1527 /* Check if there was DownShift, must be checked
1528 * immediately after link-up
1530 e1000_check_downshift_generic(hw);
1532 /* Enable/Disable EEE after link up */
1533 if (hw->phy.type > e1000_phy_82579) {
1534 ret_val = e1000_set_eee_pchlan(hw);
1539 /* If we are forcing speed/duplex, then we simply return since
1540 * we have already determined whether we have link or not.
1543 return -E1000_ERR_CONFIG;
1545 /* Auto-Neg is enabled. Auto Speed Detection takes care
1546 * of MAC speed/duplex configuration. So we only need to
1547 * configure Collision Distance in the MAC.
1549 mac->ops.config_collision_dist(hw);
1551 /* Configure Flow Control now that Auto-Neg has completed.
1552 * First, we need to restore the desired flow control
1553 * settings because we may have had to re-autoneg with a
1554 * different link partner.
1556 ret_val = e1000_config_fc_after_link_up_generic(hw);
1558 DEBUGOUT("Error configuring flow control\n");
1564 * e1000_init_function_pointers_ich8lan - Initialize ICH8 function pointers
1565 * @hw: pointer to the HW structure
1567 * Initialize family-specific function pointers for PHY, MAC, and NVM.
1569 void e1000_init_function_pointers_ich8lan(struct e1000_hw *hw)
1571 DEBUGFUNC("e1000_init_function_pointers_ich8lan");
1573 hw->mac.ops.init_params = e1000_init_mac_params_ich8lan;
1574 hw->nvm.ops.init_params = e1000_init_nvm_params_ich8lan;
1575 switch (hw->mac.type) {
1578 case e1000_ich10lan:
1579 hw->phy.ops.init_params = e1000_init_phy_params_ich8lan;
1584 hw->phy.ops.init_params = e1000_init_phy_params_pchlan;
1592 * e1000_acquire_nvm_ich8lan - Acquire NVM mutex
1593 * @hw: pointer to the HW structure
1595 * Acquires the mutex for performing NVM operations.
1597 STATIC s32 e1000_acquire_nvm_ich8lan(struct e1000_hw *hw)
1599 DEBUGFUNC("e1000_acquire_nvm_ich8lan");
1601 E1000_MUTEX_LOCK(&hw->dev_spec.ich8lan.nvm_mutex);
1603 return E1000_SUCCESS;
1607 * e1000_release_nvm_ich8lan - Release NVM mutex
1608 * @hw: pointer to the HW structure
1610 * Releases the mutex used while performing NVM operations.
1612 STATIC void e1000_release_nvm_ich8lan(struct e1000_hw *hw)
1614 DEBUGFUNC("e1000_release_nvm_ich8lan");
1616 E1000_MUTEX_UNLOCK(&hw->dev_spec.ich8lan.nvm_mutex);
1622 * e1000_acquire_swflag_ich8lan - Acquire software control flag
1623 * @hw: pointer to the HW structure
1625 * Acquires the software control flag for performing PHY and select
1628 STATIC s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw)
1630 u32 extcnf_ctrl, timeout = PHY_CFG_TIMEOUT;
1631 s32 ret_val = E1000_SUCCESS;
1633 DEBUGFUNC("e1000_acquire_swflag_ich8lan");
1635 E1000_MUTEX_LOCK(&hw->dev_spec.ich8lan.swflag_mutex);
1638 extcnf_ctrl = E1000_READ_REG(hw, E1000_EXTCNF_CTRL);
1639 if (!(extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG))
1647 DEBUGOUT("SW has already locked the resource.\n");
1648 ret_val = -E1000_ERR_CONFIG;
1652 timeout = SW_FLAG_TIMEOUT;
1654 extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG;
1655 E1000_WRITE_REG(hw, E1000_EXTCNF_CTRL, extcnf_ctrl);
1658 extcnf_ctrl = E1000_READ_REG(hw, E1000_EXTCNF_CTRL);
1659 if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG)
1667 DEBUGOUT2("Failed to acquire the semaphore, FW or HW has it: FWSM=0x%8.8x EXTCNF_CTRL=0x%8.8x)\n",
1668 E1000_READ_REG(hw, E1000_FWSM), extcnf_ctrl);
1669 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
1670 E1000_WRITE_REG(hw, E1000_EXTCNF_CTRL, extcnf_ctrl);
1671 ret_val = -E1000_ERR_CONFIG;
1677 E1000_MUTEX_UNLOCK(&hw->dev_spec.ich8lan.swflag_mutex);
1683 * e1000_release_swflag_ich8lan - Release software control flag
1684 * @hw: pointer to the HW structure
1686 * Releases the software control flag for performing PHY and select
1689 STATIC void e1000_release_swflag_ich8lan(struct e1000_hw *hw)
1693 DEBUGFUNC("e1000_release_swflag_ich8lan");
1695 extcnf_ctrl = E1000_READ_REG(hw, E1000_EXTCNF_CTRL);
1697 if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG) {
1698 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
1699 E1000_WRITE_REG(hw, E1000_EXTCNF_CTRL, extcnf_ctrl);
1701 DEBUGOUT("Semaphore unexpectedly released by sw/fw/hw\n");
1704 E1000_MUTEX_UNLOCK(&hw->dev_spec.ich8lan.swflag_mutex);
1710 * e1000_check_mng_mode_ich8lan - Checks management mode
1711 * @hw: pointer to the HW structure
1713 * This checks if the adapter has any manageability enabled.
1714 * This is a function pointer entry point only called by read/write
1715 * routines for the PHY and NVM parts.
1717 STATIC bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw)
1721 DEBUGFUNC("e1000_check_mng_mode_ich8lan");
1723 fwsm = E1000_READ_REG(hw, E1000_FWSM);
1725 return (fwsm & E1000_ICH_FWSM_FW_VALID) &&
1726 ((fwsm & E1000_FWSM_MODE_MASK) ==
1727 (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT));
1731 * e1000_check_mng_mode_pchlan - Checks management mode
1732 * @hw: pointer to the HW structure
1734 * This checks if the adapter has iAMT enabled.
1735 * This is a function pointer entry point only called by read/write
1736 * routines for the PHY and NVM parts.
1738 STATIC bool e1000_check_mng_mode_pchlan(struct e1000_hw *hw)
1742 DEBUGFUNC("e1000_check_mng_mode_pchlan");
1744 fwsm = E1000_READ_REG(hw, E1000_FWSM);
1746 return (fwsm & E1000_ICH_FWSM_FW_VALID) &&
1747 (fwsm & (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT));
1751 * e1000_rar_set_pch2lan - Set receive address register
1752 * @hw: pointer to the HW structure
1753 * @addr: pointer to the receive address
1754 * @index: receive address array register
1756 * Sets the receive address array register at index to the address passed
1757 * in by addr. For 82579, RAR[0] is the base address register that is to
1758 * contain the MAC address but RAR[1-6] are reserved for manageability (ME).
1759 * Use SHRA[0-3] in place of those reserved for ME.
1761 STATIC int e1000_rar_set_pch2lan(struct e1000_hw *hw, u8 *addr, u32 index)
1763 u32 rar_low, rar_high;
1765 DEBUGFUNC("e1000_rar_set_pch2lan");
1767 /* HW expects these in little endian so we reverse the byte order
1768 * from network order (big endian) to little endian
1770 rar_low = ((u32) addr[0] |
1771 ((u32) addr[1] << 8) |
1772 ((u32) addr[2] << 16) | ((u32) addr[3] << 24));
1774 rar_high = ((u32) addr[4] | ((u32) addr[5] << 8));
1776 /* If MAC address zero, no need to set the AV bit */
1777 if (rar_low || rar_high)
1778 rar_high |= E1000_RAH_AV;
1781 E1000_WRITE_REG(hw, E1000_RAL(index), rar_low);
1782 E1000_WRITE_FLUSH(hw);
1783 E1000_WRITE_REG(hw, E1000_RAH(index), rar_high);
1784 E1000_WRITE_FLUSH(hw);
1785 return E1000_SUCCESS;
1788 /* RAR[1-6] are owned by manageability. Skip those and program the
1789 * next address into the SHRA register array.
1791 if (index < (u32) (hw->mac.rar_entry_count)) {
1794 ret_val = e1000_acquire_swflag_ich8lan(hw);
1798 E1000_WRITE_REG(hw, E1000_SHRAL(index - 1), rar_low);
1799 E1000_WRITE_FLUSH(hw);
1800 E1000_WRITE_REG(hw, E1000_SHRAH(index - 1), rar_high);
1801 E1000_WRITE_FLUSH(hw);
1803 e1000_release_swflag_ich8lan(hw);
1805 /* verify the register updates */
1806 if ((E1000_READ_REG(hw, E1000_SHRAL(index - 1)) == rar_low) &&
1807 (E1000_READ_REG(hw, E1000_SHRAH(index - 1)) == rar_high))
1808 return E1000_SUCCESS;
1810 DEBUGOUT2("SHRA[%d] might be locked by ME - FWSM=0x%8.8x\n",
1811 (index - 1), E1000_READ_REG(hw, E1000_FWSM));
1815 DEBUGOUT1("Failed to write receive address at index %d\n", index);
1816 return -E1000_ERR_CONFIG;
1820 * e1000_rar_set_pch_lpt - Set receive address registers
1821 * @hw: pointer to the HW structure
1822 * @addr: pointer to the receive address
1823 * @index: receive address array register
1825 * Sets the receive address register array at index to the address passed
1826 * in by addr. For LPT, RAR[0] is the base address register that is to
1827 * contain the MAC address. SHRA[0-10] are the shared receive address
1828 * registers that are shared between the Host and manageability engine (ME).
1830 STATIC int e1000_rar_set_pch_lpt(struct e1000_hw *hw, u8 *addr, u32 index)
1832 u32 rar_low, rar_high;
1835 DEBUGFUNC("e1000_rar_set_pch_lpt");
1837 /* HW expects these in little endian so we reverse the byte order
1838 * from network order (big endian) to little endian
1840 rar_low = ((u32) addr[0] | ((u32) addr[1] << 8) |
1841 ((u32) addr[2] << 16) | ((u32) addr[3] << 24));
1843 rar_high = ((u32) addr[4] | ((u32) addr[5] << 8));
1845 /* If MAC address zero, no need to set the AV bit */
1846 if (rar_low || rar_high)
1847 rar_high |= E1000_RAH_AV;
1850 E1000_WRITE_REG(hw, E1000_RAL(index), rar_low);
1851 E1000_WRITE_FLUSH(hw);
1852 E1000_WRITE_REG(hw, E1000_RAH(index), rar_high);
1853 E1000_WRITE_FLUSH(hw);
1854 return E1000_SUCCESS;
1857 /* The manageability engine (ME) can lock certain SHRAR registers that
1858 * it is using - those registers are unavailable for use.
1860 if (index < hw->mac.rar_entry_count) {
1861 wlock_mac = E1000_READ_REG(hw, E1000_FWSM) &
1862 E1000_FWSM_WLOCK_MAC_MASK;
1863 wlock_mac >>= E1000_FWSM_WLOCK_MAC_SHIFT;
1865 /* Check if all SHRAR registers are locked */
1869 if ((wlock_mac == 0) || (index <= wlock_mac)) {
1872 ret_val = e1000_acquire_swflag_ich8lan(hw);
1877 E1000_WRITE_REG(hw, E1000_SHRAL_PCH_LPT(index - 1),
1879 E1000_WRITE_FLUSH(hw);
1880 E1000_WRITE_REG(hw, E1000_SHRAH_PCH_LPT(index - 1),
1882 E1000_WRITE_FLUSH(hw);
1884 e1000_release_swflag_ich8lan(hw);
1886 /* verify the register updates */
1887 if ((E1000_READ_REG(hw, E1000_SHRAL_PCH_LPT(index - 1)) == rar_low) &&
1888 (E1000_READ_REG(hw, E1000_SHRAH_PCH_LPT(index - 1)) == rar_high))
1889 return E1000_SUCCESS;
1894 DEBUGOUT1("Failed to write receive address at index %d\n", index);
1895 return -E1000_ERR_CONFIG;
1898 #ifndef NO_NON_BLOCKING_PHY_MTA_UPDATE_SUPPORT
1900 * e1000_update_mc_addr_list_pch2lan - Update Multicast addresses
1901 * @hw: pointer to the HW structure
1902 * @mc_addr_list: array of multicast addresses to program
1903 * @mc_addr_count: number of multicast addresses to program
1905 * Updates entire Multicast Table Array of the PCH2 MAC and PHY.
1906 * The caller must have a packed mc_addr_list of multicast addresses.
1908 STATIC void e1000_update_mc_addr_list_pch2lan(struct e1000_hw *hw,
1916 DEBUGFUNC("e1000_update_mc_addr_list_pch2lan");
1918 e1000_update_mc_addr_list_generic(hw, mc_addr_list, mc_addr_count);
1920 ret_val = hw->phy.ops.acquire(hw);
1924 ret_val = e1000_enable_phy_wakeup_reg_access_bm(hw, &phy_reg);
1928 for (i = 0; i < hw->mac.mta_reg_count; i++) {
1929 hw->phy.ops.write_reg_page(hw, BM_MTA(i),
1930 (u16)(hw->mac.mta_shadow[i] &
1932 hw->phy.ops.write_reg_page(hw, (BM_MTA(i) + 1),
1933 (u16)((hw->mac.mta_shadow[i] >> 16) &
1937 e1000_disable_phy_wakeup_reg_access_bm(hw, &phy_reg);
1940 hw->phy.ops.release(hw);
1943 #endif /* NO_NON_BLOCKING_PHY_MTA_UPDATE_SUPPORT */
1945 * e1000_check_reset_block_ich8lan - Check if PHY reset is blocked
1946 * @hw: pointer to the HW structure
1948 * Checks if firmware is blocking the reset of the PHY.
1949 * This is a function pointer entry point only called by
1952 STATIC s32 e1000_check_reset_block_ich8lan(struct e1000_hw *hw)
1955 bool blocked = false;
1958 DEBUGFUNC("e1000_check_reset_block_ich8lan");
1961 fwsm = E1000_READ_REG(hw, E1000_FWSM);
1962 if (!(fwsm & E1000_ICH_FWSM_RSPCIPHY)) {
1968 } while (blocked && (i++ < 10));
1969 return blocked ? E1000_BLK_PHY_RESET : E1000_SUCCESS;
1973 * e1000_write_smbus_addr - Write SMBus address to PHY needed during Sx states
1974 * @hw: pointer to the HW structure
1976 * Assumes semaphore already acquired.
1979 STATIC s32 e1000_write_smbus_addr(struct e1000_hw *hw)
1982 u32 strap = E1000_READ_REG(hw, E1000_STRAP);
1983 u32 freq = (strap & E1000_STRAP_SMT_FREQ_MASK) >>
1984 E1000_STRAP_SMT_FREQ_SHIFT;
1987 strap &= E1000_STRAP_SMBUS_ADDRESS_MASK;
1989 ret_val = e1000_read_phy_reg_hv_locked(hw, HV_SMB_ADDR, &phy_data);
1993 phy_data &= ~HV_SMB_ADDR_MASK;
1994 phy_data |= (strap >> E1000_STRAP_SMBUS_ADDRESS_SHIFT);
1995 phy_data |= HV_SMB_ADDR_PEC_EN | HV_SMB_ADDR_VALID;
1997 if (hw->phy.type == e1000_phy_i217) {
1998 /* Restore SMBus frequency */
2000 phy_data &= ~HV_SMB_ADDR_FREQ_MASK;
2001 phy_data |= (freq & (1 << 0)) <<
2002 HV_SMB_ADDR_FREQ_LOW_SHIFT;
2003 phy_data |= (freq & (1 << 1)) <<
2004 (HV_SMB_ADDR_FREQ_HIGH_SHIFT - 1);
2006 DEBUGOUT("Unsupported SMB frequency in PHY\n");
2010 return e1000_write_phy_reg_hv_locked(hw, HV_SMB_ADDR, phy_data);
2014 * e1000_sw_lcd_config_ich8lan - SW-based LCD Configuration
2015 * @hw: pointer to the HW structure
2017 * SW should configure the LCD from the NVM extended configuration region
2018 * as a workaround for certain parts.
2020 STATIC s32 e1000_sw_lcd_config_ich8lan(struct e1000_hw *hw)
2022 struct e1000_phy_info *phy = &hw->phy;
2023 u32 i, data, cnf_size, cnf_base_addr, sw_cfg_mask;
2024 s32 ret_val = E1000_SUCCESS;
2025 u16 word_addr, reg_data, reg_addr, phy_page = 0;
2027 DEBUGFUNC("e1000_sw_lcd_config_ich8lan");
2029 /* Initialize the PHY from the NVM on ICH platforms. This
2030 * is needed due to an issue where the NVM configuration is
2031 * not properly autoloaded after power transitions.
2032 * Therefore, after each PHY reset, we will load the
2033 * configuration data out of the NVM manually.
2035 switch (hw->mac.type) {
2037 if (phy->type != e1000_phy_igp_3)
2040 if ((hw->device_id == E1000_DEV_ID_ICH8_IGP_AMT) ||
2041 (hw->device_id == E1000_DEV_ID_ICH8_IGP_C)) {
2042 sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG;
2049 sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG_ICH8M;
2055 ret_val = hw->phy.ops.acquire(hw);
2059 data = E1000_READ_REG(hw, E1000_FEXTNVM);
2060 if (!(data & sw_cfg_mask))
2063 /* Make sure HW does not configure LCD from PHY
2064 * extended configuration before SW configuration
2066 data = E1000_READ_REG(hw, E1000_EXTCNF_CTRL);
2067 if ((hw->mac.type < e1000_pch2lan) &&
2068 (data & E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE))
2071 cnf_size = E1000_READ_REG(hw, E1000_EXTCNF_SIZE);
2072 cnf_size &= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_MASK;
2073 cnf_size >>= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_SHIFT;
2077 cnf_base_addr = data & E1000_EXTCNF_CTRL_EXT_CNF_POINTER_MASK;
2078 cnf_base_addr >>= E1000_EXTCNF_CTRL_EXT_CNF_POINTER_SHIFT;
2080 if (((hw->mac.type == e1000_pchlan) &&
2081 !(data & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE)) ||
2082 (hw->mac.type > e1000_pchlan)) {
2083 /* HW configures the SMBus address and LEDs when the
2084 * OEM and LCD Write Enable bits are set in the NVM.
2085 * When both NVM bits are cleared, SW will configure
2088 ret_val = e1000_write_smbus_addr(hw);
2092 data = E1000_READ_REG(hw, E1000_LEDCTL);
2093 ret_val = e1000_write_phy_reg_hv_locked(hw, HV_LED_CONFIG,
2099 /* Configure LCD from extended configuration region. */
2101 /* cnf_base_addr is in DWORD */
2102 word_addr = (u16)(cnf_base_addr << 1);
2104 for (i = 0; i < cnf_size; i++) {
2105 ret_val = hw->nvm.ops.read(hw, (word_addr + i * 2), 1,
2110 ret_val = hw->nvm.ops.read(hw, (word_addr + i * 2 + 1),
2115 /* Save off the PHY page for future writes. */
2116 if (reg_addr == IGP01E1000_PHY_PAGE_SELECT) {
2117 phy_page = reg_data;
2121 reg_addr &= PHY_REG_MASK;
2122 reg_addr |= phy_page;
2124 ret_val = phy->ops.write_reg_locked(hw, (u32)reg_addr,
2131 hw->phy.ops.release(hw);
2136 * e1000_k1_gig_workaround_hv - K1 Si workaround
2137 * @hw: pointer to the HW structure
2138 * @link: link up bool flag
2140 * If K1 is enabled for 1Gbps, the MAC might stall when transitioning
2141 * from a lower speed. This workaround disables K1 whenever link is at 1Gig
2142 * If link is down, the function will restore the default K1 setting located
2145 STATIC s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link)
2147 s32 ret_val = E1000_SUCCESS;
2149 bool k1_enable = hw->dev_spec.ich8lan.nvm_k1_enabled;
2151 DEBUGFUNC("e1000_k1_gig_workaround_hv");
2153 if (hw->mac.type != e1000_pchlan)
2154 return E1000_SUCCESS;
2156 /* Wrap the whole flow with the sw flag */
2157 ret_val = hw->phy.ops.acquire(hw);
2161 /* Disable K1 when link is 1Gbps, otherwise use the NVM setting */
2163 if (hw->phy.type == e1000_phy_82578) {
2164 ret_val = hw->phy.ops.read_reg_locked(hw, BM_CS_STATUS,
2169 status_reg &= (BM_CS_STATUS_LINK_UP |
2170 BM_CS_STATUS_RESOLVED |
2171 BM_CS_STATUS_SPEED_MASK);
2173 if (status_reg == (BM_CS_STATUS_LINK_UP |
2174 BM_CS_STATUS_RESOLVED |
2175 BM_CS_STATUS_SPEED_1000))
2179 if (hw->phy.type == e1000_phy_82577) {
2180 ret_val = hw->phy.ops.read_reg_locked(hw, HV_M_STATUS,
2185 status_reg &= (HV_M_STATUS_LINK_UP |
2186 HV_M_STATUS_AUTONEG_COMPLETE |
2187 HV_M_STATUS_SPEED_MASK);
2189 if (status_reg == (HV_M_STATUS_LINK_UP |
2190 HV_M_STATUS_AUTONEG_COMPLETE |
2191 HV_M_STATUS_SPEED_1000))
2195 /* Link stall fix for link up */
2196 ret_val = hw->phy.ops.write_reg_locked(hw, PHY_REG(770, 19),
2202 /* Link stall fix for link down */
2203 ret_val = hw->phy.ops.write_reg_locked(hw, PHY_REG(770, 19),
2209 ret_val = e1000_configure_k1_ich8lan(hw, k1_enable);
2212 hw->phy.ops.release(hw);
2218 * e1000_configure_k1_ich8lan - Configure K1 power state
2219 * @hw: pointer to the HW structure
2220 * @enable: K1 state to configure
2222 * Configure the K1 power state based on the provided parameter.
2223 * Assumes semaphore already acquired.
2225 * Success returns 0, Failure returns -E1000_ERR_PHY (-2)
2227 s32 e1000_configure_k1_ich8lan(struct e1000_hw *hw, bool k1_enable)
2235 DEBUGFUNC("e1000_configure_k1_ich8lan");
2237 ret_val = e1000_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
2243 kmrn_reg |= E1000_KMRNCTRLSTA_K1_ENABLE;
2245 kmrn_reg &= ~E1000_KMRNCTRLSTA_K1_ENABLE;
2247 ret_val = e1000_write_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
2253 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
2254 ctrl_reg = E1000_READ_REG(hw, E1000_CTRL);
2256 reg = ctrl_reg & ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100);
2257 reg |= E1000_CTRL_FRCSPD;
2258 E1000_WRITE_REG(hw, E1000_CTRL, reg);
2260 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext | E1000_CTRL_EXT_SPD_BYPS);
2261 E1000_WRITE_FLUSH(hw);
2263 E1000_WRITE_REG(hw, E1000_CTRL, ctrl_reg);
2264 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
2265 E1000_WRITE_FLUSH(hw);
2268 return E1000_SUCCESS;
2272 * e1000_oem_bits_config_ich8lan - SW-based LCD Configuration
2273 * @hw: pointer to the HW structure
2274 * @d0_state: boolean if entering d0 or d3 device state
2276 * SW will configure Gbe Disable and LPLU based on the NVM. The four bits are
2277 * collectively called OEM bits. The OEM Write Enable bit and SW Config bit
2278 * in NVM determines whether HW should configure LPLU and Gbe Disable.
2280 STATIC s32 e1000_oem_bits_config_ich8lan(struct e1000_hw *hw, bool d0_state)
2286 DEBUGFUNC("e1000_oem_bits_config_ich8lan");
2288 if (hw->mac.type < e1000_pchlan)
2291 ret_val = hw->phy.ops.acquire(hw);
2295 if (hw->mac.type == e1000_pchlan) {
2296 mac_reg = E1000_READ_REG(hw, E1000_EXTCNF_CTRL);
2297 if (mac_reg & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE)
2301 mac_reg = E1000_READ_REG(hw, E1000_FEXTNVM);
2302 if (!(mac_reg & E1000_FEXTNVM_SW_CONFIG_ICH8M))
2305 mac_reg = E1000_READ_REG(hw, E1000_PHY_CTRL);
2307 ret_val = hw->phy.ops.read_reg_locked(hw, HV_OEM_BITS, &oem_reg);
2311 oem_reg &= ~(HV_OEM_BITS_GBE_DIS | HV_OEM_BITS_LPLU);
2314 if (mac_reg & E1000_PHY_CTRL_GBE_DISABLE)
2315 oem_reg |= HV_OEM_BITS_GBE_DIS;
2317 if (mac_reg & E1000_PHY_CTRL_D0A_LPLU)
2318 oem_reg |= HV_OEM_BITS_LPLU;
2320 if (mac_reg & (E1000_PHY_CTRL_GBE_DISABLE |
2321 E1000_PHY_CTRL_NOND0A_GBE_DISABLE))
2322 oem_reg |= HV_OEM_BITS_GBE_DIS;
2324 if (mac_reg & (E1000_PHY_CTRL_D0A_LPLU |
2325 E1000_PHY_CTRL_NOND0A_LPLU))
2326 oem_reg |= HV_OEM_BITS_LPLU;
2329 /* Set Restart auto-neg to activate the bits */
2330 if ((d0_state || (hw->mac.type != e1000_pchlan)) &&
2331 !hw->phy.ops.check_reset_block(hw))
2332 oem_reg |= HV_OEM_BITS_RESTART_AN;
2334 ret_val = hw->phy.ops.write_reg_locked(hw, HV_OEM_BITS, oem_reg);
2337 hw->phy.ops.release(hw);
2344 * e1000_set_mdio_slow_mode_hv - Set slow MDIO access mode
2345 * @hw: pointer to the HW structure
2347 STATIC s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw)
2352 DEBUGFUNC("e1000_set_mdio_slow_mode_hv");
2354 ret_val = hw->phy.ops.read_reg(hw, HV_KMRN_MODE_CTRL, &data);
2358 data |= HV_KMRN_MDIO_SLOW;
2360 ret_val = hw->phy.ops.write_reg(hw, HV_KMRN_MODE_CTRL, data);
2366 * e1000_hv_phy_workarounds_ich8lan - A series of Phy workarounds to be
2367 * done after every PHY reset.
2369 STATIC s32 e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw)
2371 s32 ret_val = E1000_SUCCESS;
2374 DEBUGFUNC("e1000_hv_phy_workarounds_ich8lan");
2376 if (hw->mac.type != e1000_pchlan)
2377 return E1000_SUCCESS;
2379 /* Set MDIO slow mode before any other MDIO access */
2380 if (hw->phy.type == e1000_phy_82577) {
2381 ret_val = e1000_set_mdio_slow_mode_hv(hw);
2386 if (((hw->phy.type == e1000_phy_82577) &&
2387 ((hw->phy.revision == 1) || (hw->phy.revision == 2))) ||
2388 ((hw->phy.type == e1000_phy_82578) && (hw->phy.revision == 1))) {
2389 /* Disable generation of early preamble */
2390 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(769, 25), 0x4431);
2394 /* Preamble tuning for SSC */
2395 ret_val = hw->phy.ops.write_reg(hw, HV_KMRN_FIFO_CTRLSTA,
2401 if (hw->phy.type == e1000_phy_82578) {
2402 /* Return registers to default by doing a soft reset then
2403 * writing 0x3140 to the control register.
2405 if (hw->phy.revision < 2) {
2406 e1000_phy_sw_reset_generic(hw);
2407 ret_val = hw->phy.ops.write_reg(hw, PHY_CONTROL,
2413 ret_val = hw->phy.ops.acquire(hw);
2418 ret_val = e1000_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT, 0);
2419 hw->phy.ops.release(hw);
2423 /* Configure the K1 Si workaround during phy reset assuming there is
2424 * link so that it disables K1 if link is in 1Gbps.
2426 ret_val = e1000_k1_gig_workaround_hv(hw, true);
2430 /* Workaround for link disconnects on a busy hub in half duplex */
2431 ret_val = hw->phy.ops.acquire(hw);
2434 ret_val = hw->phy.ops.read_reg_locked(hw, BM_PORT_GEN_CFG, &phy_data);
2437 ret_val = hw->phy.ops.write_reg_locked(hw, BM_PORT_GEN_CFG,
2442 /* set MSE higher to enable link to stay up when noise is high */
2443 ret_val = e1000_write_emi_reg_locked(hw, I82577_MSE_THRESHOLD, 0x0034);
2445 hw->phy.ops.release(hw);
2451 * e1000_copy_rx_addrs_to_phy_ich8lan - Copy Rx addresses from MAC to PHY
2452 * @hw: pointer to the HW structure
2454 void e1000_copy_rx_addrs_to_phy_ich8lan(struct e1000_hw *hw)
2460 DEBUGFUNC("e1000_copy_rx_addrs_to_phy_ich8lan");
2462 ret_val = hw->phy.ops.acquire(hw);
2465 ret_val = e1000_enable_phy_wakeup_reg_access_bm(hw, &phy_reg);
2469 /* Copy both RAL/H (rar_entry_count) and SHRAL/H to PHY */
2470 for (i = 0; i < (hw->mac.rar_entry_count); i++) {
2471 mac_reg = E1000_READ_REG(hw, E1000_RAL(i));
2472 hw->phy.ops.write_reg_page(hw, BM_RAR_L(i),
2473 (u16)(mac_reg & 0xFFFF));
2474 hw->phy.ops.write_reg_page(hw, BM_RAR_M(i),
2475 (u16)((mac_reg >> 16) & 0xFFFF));
2477 mac_reg = E1000_READ_REG(hw, E1000_RAH(i));
2478 hw->phy.ops.write_reg_page(hw, BM_RAR_H(i),
2479 (u16)(mac_reg & 0xFFFF));
2480 hw->phy.ops.write_reg_page(hw, BM_RAR_CTRL(i),
2481 (u16)((mac_reg & E1000_RAH_AV)
2485 e1000_disable_phy_wakeup_reg_access_bm(hw, &phy_reg);
2488 hw->phy.ops.release(hw);
2491 #ifndef CRC32_OS_SUPPORT
2492 STATIC u32 e1000_calc_rx_da_crc(u8 mac[])
2494 u32 poly = 0xEDB88320; /* Polynomial for 802.3 CRC calculation */
2495 u32 i, j, mask, crc;
2497 DEBUGFUNC("e1000_calc_rx_da_crc");
2500 for (i = 0; i < 6; i++) {
2502 for (j = 8; j > 0; j--) {
2503 mask = (crc & 1) * (-1);
2504 crc = (crc >> 1) ^ (poly & mask);
2510 #endif /* CRC32_OS_SUPPORT */
2512 * e1000_lv_jumbo_workaround_ich8lan - required for jumbo frame operation
2514 * @hw: pointer to the HW structure
2515 * @enable: flag to enable/disable workaround when enabling/disabling jumbos
2517 s32 e1000_lv_jumbo_workaround_ich8lan(struct e1000_hw *hw, bool enable)
2519 s32 ret_val = E1000_SUCCESS;
2524 DEBUGFUNC("e1000_lv_jumbo_workaround_ich8lan");
2526 if (hw->mac.type < e1000_pch2lan)
2527 return E1000_SUCCESS;
2529 /* disable Rx path while enabling/disabling workaround */
2530 hw->phy.ops.read_reg(hw, PHY_REG(769, 20), &phy_reg);
2531 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(769, 20),
2532 phy_reg | (1 << 14));
2537 /* Write Rx addresses (rar_entry_count for RAL/H, and
2538 * SHRAL/H) and initial CRC values to the MAC
2540 for (i = 0; i < hw->mac.rar_entry_count; i++) {
2541 u8 mac_addr[ETH_ADDR_LEN] = {0};
2542 u32 addr_high, addr_low;
2544 addr_high = E1000_READ_REG(hw, E1000_RAH(i));
2545 if (!(addr_high & E1000_RAH_AV))
2547 addr_low = E1000_READ_REG(hw, E1000_RAL(i));
2548 mac_addr[0] = (addr_low & 0xFF);
2549 mac_addr[1] = ((addr_low >> 8) & 0xFF);
2550 mac_addr[2] = ((addr_low >> 16) & 0xFF);
2551 mac_addr[3] = ((addr_low >> 24) & 0xFF);
2552 mac_addr[4] = (addr_high & 0xFF);
2553 mac_addr[5] = ((addr_high >> 8) & 0xFF);
2555 #ifndef CRC32_OS_SUPPORT
2556 E1000_WRITE_REG(hw, E1000_PCH_RAICC(i),
2557 e1000_calc_rx_da_crc(mac_addr));
2558 #else /* CRC32_OS_SUPPORT */
2559 E1000_WRITE_REG(hw, E1000_PCH_RAICC(i),
2560 E1000_CRC32(ETH_ADDR_LEN, mac_addr));
2561 #endif /* CRC32_OS_SUPPORT */
2564 /* Write Rx addresses to the PHY */
2565 e1000_copy_rx_addrs_to_phy_ich8lan(hw);
2567 /* Enable jumbo frame workaround in the MAC */
2568 mac_reg = E1000_READ_REG(hw, E1000_FFLT_DBG);
2569 mac_reg &= ~(1 << 14);
2570 mac_reg |= (7 << 15);
2571 E1000_WRITE_REG(hw, E1000_FFLT_DBG, mac_reg);
2573 mac_reg = E1000_READ_REG(hw, E1000_RCTL);
2574 mac_reg |= E1000_RCTL_SECRC;
2575 E1000_WRITE_REG(hw, E1000_RCTL, mac_reg);
2577 ret_val = e1000_read_kmrn_reg_generic(hw,
2578 E1000_KMRNCTRLSTA_CTRL_OFFSET,
2582 ret_val = e1000_write_kmrn_reg_generic(hw,
2583 E1000_KMRNCTRLSTA_CTRL_OFFSET,
2587 ret_val = e1000_read_kmrn_reg_generic(hw,
2588 E1000_KMRNCTRLSTA_HD_CTRL,
2592 data &= ~(0xF << 8);
2594 ret_val = e1000_write_kmrn_reg_generic(hw,
2595 E1000_KMRNCTRLSTA_HD_CTRL,
2600 /* Enable jumbo frame workaround in the PHY */
2601 hw->phy.ops.read_reg(hw, PHY_REG(769, 23), &data);
2602 data &= ~(0x7F << 5);
2603 data |= (0x37 << 5);
2604 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(769, 23), data);
2607 hw->phy.ops.read_reg(hw, PHY_REG(769, 16), &data);
2609 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(769, 16), data);
2612 hw->phy.ops.read_reg(hw, PHY_REG(776, 20), &data);
2613 data &= ~(0x3FF << 2);
2614 data |= (E1000_TX_PTR_GAP << 2);
2615 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(776, 20), data);
2618 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(776, 23), 0xF100);
2621 hw->phy.ops.read_reg(hw, HV_PM_CTRL, &data);
2622 ret_val = hw->phy.ops.write_reg(hw, HV_PM_CTRL, data |
2627 /* Write MAC register values back to h/w defaults */
2628 mac_reg = E1000_READ_REG(hw, E1000_FFLT_DBG);
2629 mac_reg &= ~(0xF << 14);
2630 E1000_WRITE_REG(hw, E1000_FFLT_DBG, mac_reg);
2632 mac_reg = E1000_READ_REG(hw, E1000_RCTL);
2633 mac_reg &= ~E1000_RCTL_SECRC;
2634 E1000_WRITE_REG(hw, E1000_RCTL, mac_reg);
2636 ret_val = e1000_read_kmrn_reg_generic(hw,
2637 E1000_KMRNCTRLSTA_CTRL_OFFSET,
2641 ret_val = e1000_write_kmrn_reg_generic(hw,
2642 E1000_KMRNCTRLSTA_CTRL_OFFSET,
2646 ret_val = e1000_read_kmrn_reg_generic(hw,
2647 E1000_KMRNCTRLSTA_HD_CTRL,
2651 data &= ~(0xF << 8);
2653 ret_val = e1000_write_kmrn_reg_generic(hw,
2654 E1000_KMRNCTRLSTA_HD_CTRL,
2659 /* Write PHY register values back to h/w defaults */
2660 hw->phy.ops.read_reg(hw, PHY_REG(769, 23), &data);
2661 data &= ~(0x7F << 5);
2662 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(769, 23), data);
2665 hw->phy.ops.read_reg(hw, PHY_REG(769, 16), &data);
2667 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(769, 16), data);
2670 hw->phy.ops.read_reg(hw, PHY_REG(776, 20), &data);
2671 data &= ~(0x3FF << 2);
2673 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(776, 20), data);
2676 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(776, 23), 0x7E00);
2679 hw->phy.ops.read_reg(hw, HV_PM_CTRL, &data);
2680 ret_val = hw->phy.ops.write_reg(hw, HV_PM_CTRL, data &
2686 /* re-enable Rx path after enabling/disabling workaround */
2687 return hw->phy.ops.write_reg(hw, PHY_REG(769, 20), phy_reg &
2692 * e1000_lv_phy_workarounds_ich8lan - A series of Phy workarounds to be
2693 * done after every PHY reset.
2695 STATIC s32 e1000_lv_phy_workarounds_ich8lan(struct e1000_hw *hw)
2697 s32 ret_val = E1000_SUCCESS;
2699 DEBUGFUNC("e1000_lv_phy_workarounds_ich8lan");
2701 if (hw->mac.type != e1000_pch2lan)
2702 return E1000_SUCCESS;
2704 /* Set MDIO slow mode before any other MDIO access */
2705 ret_val = e1000_set_mdio_slow_mode_hv(hw);
2709 ret_val = hw->phy.ops.acquire(hw);
2712 /* set MSE higher to enable link to stay up when noise is high */
2713 ret_val = e1000_write_emi_reg_locked(hw, I82579_MSE_THRESHOLD, 0x0034);
2716 /* drop link after 5 times MSE threshold was reached */
2717 ret_val = e1000_write_emi_reg_locked(hw, I82579_MSE_LINK_DOWN, 0x0005);
2719 hw->phy.ops.release(hw);
2725 * e1000_k1_gig_workaround_lv - K1 Si workaround
2726 * @hw: pointer to the HW structure
2728 * Workaround to set the K1 beacon duration for 82579 parts in 10Mbps
2729 * Disable K1 for 1000 and 100 speeds
2731 STATIC s32 e1000_k1_workaround_lv(struct e1000_hw *hw)
2733 s32 ret_val = E1000_SUCCESS;
2736 DEBUGFUNC("e1000_k1_workaround_lv");
2738 if (hw->mac.type != e1000_pch2lan)
2739 return E1000_SUCCESS;
2741 /* Set K1 beacon duration based on 10Mbs speed */
2742 ret_val = hw->phy.ops.read_reg(hw, HV_M_STATUS, &status_reg);
2746 if ((status_reg & (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE))
2747 == (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE)) {
2749 (HV_M_STATUS_SPEED_1000 | HV_M_STATUS_SPEED_100)) {
2752 /* LV 1G/100 Packet drop issue wa */
2753 ret_val = hw->phy.ops.read_reg(hw, HV_PM_CTRL,
2757 pm_phy_reg &= ~HV_PM_CTRL_K1_ENABLE;
2758 ret_val = hw->phy.ops.write_reg(hw, HV_PM_CTRL,
2764 mac_reg = E1000_READ_REG(hw, E1000_FEXTNVM4);
2765 mac_reg &= ~E1000_FEXTNVM4_BEACON_DURATION_MASK;
2766 mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_16USEC;
2767 E1000_WRITE_REG(hw, E1000_FEXTNVM4, mac_reg);
2775 * e1000_gate_hw_phy_config_ich8lan - disable PHY config via hardware
2776 * @hw: pointer to the HW structure
2777 * @gate: boolean set to true to gate, false to ungate
2779 * Gate/ungate the automatic PHY configuration via hardware; perform
2780 * the configuration via software instead.
2782 STATIC void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate)
2786 DEBUGFUNC("e1000_gate_hw_phy_config_ich8lan");
2788 if (hw->mac.type < e1000_pch2lan)
2791 extcnf_ctrl = E1000_READ_REG(hw, E1000_EXTCNF_CTRL);
2794 extcnf_ctrl |= E1000_EXTCNF_CTRL_GATE_PHY_CFG;
2796 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_GATE_PHY_CFG;
2798 E1000_WRITE_REG(hw, E1000_EXTCNF_CTRL, extcnf_ctrl);
2802 * e1000_lan_init_done_ich8lan - Check for PHY config completion
2803 * @hw: pointer to the HW structure
2805 * Check the appropriate indication the MAC has finished configuring the
2806 * PHY after a software reset.
2808 STATIC void e1000_lan_init_done_ich8lan(struct e1000_hw *hw)
2810 u32 data, loop = E1000_ICH8_LAN_INIT_TIMEOUT;
2812 DEBUGFUNC("e1000_lan_init_done_ich8lan");
2814 /* Wait for basic configuration completes before proceeding */
2816 data = E1000_READ_REG(hw, E1000_STATUS);
2817 data &= E1000_STATUS_LAN_INIT_DONE;
2819 } while ((!data) && --loop);
2821 /* If basic configuration is incomplete before the above loop
2822 * count reaches 0, loading the configuration from NVM will
2823 * leave the PHY in a bad state possibly resulting in no link.
2826 DEBUGOUT("LAN_INIT_DONE not set, increase timeout\n");
2828 /* Clear the Init Done bit for the next init event */
2829 data = E1000_READ_REG(hw, E1000_STATUS);
2830 data &= ~E1000_STATUS_LAN_INIT_DONE;
2831 E1000_WRITE_REG(hw, E1000_STATUS, data);
2835 * e1000_post_phy_reset_ich8lan - Perform steps required after a PHY reset
2836 * @hw: pointer to the HW structure
2838 STATIC s32 e1000_post_phy_reset_ich8lan(struct e1000_hw *hw)
2840 s32 ret_val = E1000_SUCCESS;
2843 DEBUGFUNC("e1000_post_phy_reset_ich8lan");
2845 if (hw->phy.ops.check_reset_block(hw))
2846 return E1000_SUCCESS;
2848 /* Allow time for h/w to get to quiescent state after reset */
2851 /* Perform any necessary post-reset workarounds */
2852 switch (hw->mac.type) {
2854 ret_val = e1000_hv_phy_workarounds_ich8lan(hw);
2859 ret_val = e1000_lv_phy_workarounds_ich8lan(hw);
2867 /* Clear the host wakeup bit after lcd reset */
2868 if (hw->mac.type >= e1000_pchlan) {
2869 hw->phy.ops.read_reg(hw, BM_PORT_GEN_CFG, ®);
2870 reg &= ~BM_WUC_HOST_WU_BIT;
2871 hw->phy.ops.write_reg(hw, BM_PORT_GEN_CFG, reg);
2874 /* Configure the LCD with the extended configuration region in NVM */
2875 ret_val = e1000_sw_lcd_config_ich8lan(hw);
2879 /* Configure the LCD with the OEM bits in NVM */
2880 ret_val = e1000_oem_bits_config_ich8lan(hw, true);
2882 if (hw->mac.type == e1000_pch2lan) {
2883 /* Ungate automatic PHY configuration on non-managed 82579 */
2884 if (!(E1000_READ_REG(hw, E1000_FWSM) &
2885 E1000_ICH_FWSM_FW_VALID)) {
2887 e1000_gate_hw_phy_config_ich8lan(hw, false);
2890 /* Set EEE LPI Update Timer to 200usec */
2891 ret_val = hw->phy.ops.acquire(hw);
2894 ret_val = e1000_write_emi_reg_locked(hw,
2895 I82579_LPI_UPDATE_TIMER,
2897 hw->phy.ops.release(hw);
2904 * e1000_phy_hw_reset_ich8lan - Performs a PHY reset
2905 * @hw: pointer to the HW structure
2908 * This is a function pointer entry point called by drivers
2909 * or other shared routines.
2911 STATIC s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw)
2913 s32 ret_val = E1000_SUCCESS;
2915 DEBUGFUNC("e1000_phy_hw_reset_ich8lan");
2917 /* Gate automatic PHY configuration by hardware on non-managed 82579 */
2918 if ((hw->mac.type == e1000_pch2lan) &&
2919 !(E1000_READ_REG(hw, E1000_FWSM) & E1000_ICH_FWSM_FW_VALID))
2920 e1000_gate_hw_phy_config_ich8lan(hw, true);
2922 ret_val = e1000_phy_hw_reset_generic(hw);
2926 return e1000_post_phy_reset_ich8lan(hw);
2930 * e1000_set_lplu_state_pchlan - Set Low Power Link Up state
2931 * @hw: pointer to the HW structure
2932 * @active: true to enable LPLU, false to disable
2934 * Sets the LPLU state according to the active flag. For PCH, if OEM write
2935 * bit are disabled in the NVM, writing the LPLU bits in the MAC will not set
2936 * the phy speed. This function will manually set the LPLU bit and restart
2937 * auto-neg as hw would do. D3 and D0 LPLU will call the same function
2938 * since it configures the same bit.
2940 STATIC s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active)
2945 DEBUGFUNC("e1000_set_lplu_state_pchlan");
2947 ret_val = hw->phy.ops.read_reg(hw, HV_OEM_BITS, &oem_reg);
2952 oem_reg |= HV_OEM_BITS_LPLU;
2954 oem_reg &= ~HV_OEM_BITS_LPLU;
2956 if (!hw->phy.ops.check_reset_block(hw))
2957 oem_reg |= HV_OEM_BITS_RESTART_AN;
2959 return hw->phy.ops.write_reg(hw, HV_OEM_BITS, oem_reg);
2963 * e1000_set_d0_lplu_state_ich8lan - Set Low Power Linkup D0 state
2964 * @hw: pointer to the HW structure
2965 * @active: true to enable LPLU, false to disable
2967 * Sets the LPLU D0 state according to the active flag. When
2968 * activating LPLU this function also disables smart speed
2969 * and vice versa. LPLU will not be activated unless the
2970 * device autonegotiation advertisement meets standards of
2971 * either 10 or 10/100 or 10/100/1000 at all duplexes.
2972 * This is a function pointer entry point only called by
2973 * PHY setup routines.
2975 STATIC s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
2977 struct e1000_phy_info *phy = &hw->phy;
2979 s32 ret_val = E1000_SUCCESS;
2982 DEBUGFUNC("e1000_set_d0_lplu_state_ich8lan");
2984 if (phy->type == e1000_phy_ife)
2985 return E1000_SUCCESS;
2987 phy_ctrl = E1000_READ_REG(hw, E1000_PHY_CTRL);
2990 phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU;
2991 E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl);
2993 if (phy->type != e1000_phy_igp_3)
2994 return E1000_SUCCESS;
2996 /* Call gig speed drop workaround on LPLU before accessing
2999 if (hw->mac.type == e1000_ich8lan)
3000 e1000_gig_downshift_workaround_ich8lan(hw);
3002 /* When LPLU is enabled, we should disable SmartSpeed */
3003 ret_val = phy->ops.read_reg(hw,
3004 IGP01E1000_PHY_PORT_CONFIG,
3008 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
3009 ret_val = phy->ops.write_reg(hw,
3010 IGP01E1000_PHY_PORT_CONFIG,
3015 phy_ctrl &= ~E1000_PHY_CTRL_D0A_LPLU;
3016 E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl);
3018 if (phy->type != e1000_phy_igp_3)
3019 return E1000_SUCCESS;
3021 /* LPLU and SmartSpeed are mutually exclusive. LPLU is used
3022 * during Dx states where the power conservation is most
3023 * important. During driver activity we should enable
3024 * SmartSpeed, so performance is maintained.
3026 if (phy->smart_speed == e1000_smart_speed_on) {
3027 ret_val = phy->ops.read_reg(hw,
3028 IGP01E1000_PHY_PORT_CONFIG,
3033 data |= IGP01E1000_PSCFR_SMART_SPEED;
3034 ret_val = phy->ops.write_reg(hw,
3035 IGP01E1000_PHY_PORT_CONFIG,
3039 } else if (phy->smart_speed == e1000_smart_speed_off) {
3040 ret_val = phy->ops.read_reg(hw,
3041 IGP01E1000_PHY_PORT_CONFIG,
3046 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
3047 ret_val = phy->ops.write_reg(hw,
3048 IGP01E1000_PHY_PORT_CONFIG,
3055 return E1000_SUCCESS;
3059 * e1000_set_d3_lplu_state_ich8lan - Set Low Power Linkup D3 state
3060 * @hw: pointer to the HW structure
3061 * @active: true to enable LPLU, false to disable
3063 * Sets the LPLU D3 state according to the active flag. When
3064 * activating LPLU this function also disables smart speed
3065 * and vice versa. LPLU will not be activated unless the
3066 * device autonegotiation advertisement meets standards of
3067 * either 10 or 10/100 or 10/100/1000 at all duplexes.
3068 * This is a function pointer entry point only called by
3069 * PHY setup routines.
3071 STATIC s32 e1000_set_d3_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
3073 struct e1000_phy_info *phy = &hw->phy;
3075 s32 ret_val = E1000_SUCCESS;
3078 DEBUGFUNC("e1000_set_d3_lplu_state_ich8lan");
3080 phy_ctrl = E1000_READ_REG(hw, E1000_PHY_CTRL);
3083 phy_ctrl &= ~E1000_PHY_CTRL_NOND0A_LPLU;
3084 E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl);
3086 if (phy->type != e1000_phy_igp_3)
3087 return E1000_SUCCESS;
3089 /* LPLU and SmartSpeed are mutually exclusive. LPLU is used
3090 * during Dx states where the power conservation is most
3091 * important. During driver activity we should enable
3092 * SmartSpeed, so performance is maintained.
3094 if (phy->smart_speed == e1000_smart_speed_on) {
3095 ret_val = phy->ops.read_reg(hw,
3096 IGP01E1000_PHY_PORT_CONFIG,
3101 data |= IGP01E1000_PSCFR_SMART_SPEED;
3102 ret_val = phy->ops.write_reg(hw,
3103 IGP01E1000_PHY_PORT_CONFIG,
3107 } else if (phy->smart_speed == e1000_smart_speed_off) {
3108 ret_val = phy->ops.read_reg(hw,
3109 IGP01E1000_PHY_PORT_CONFIG,
3114 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
3115 ret_val = phy->ops.write_reg(hw,
3116 IGP01E1000_PHY_PORT_CONFIG,
3121 } else if ((phy->autoneg_advertised == E1000_ALL_SPEED_DUPLEX) ||
3122 (phy->autoneg_advertised == E1000_ALL_NOT_GIG) ||
3123 (phy->autoneg_advertised == E1000_ALL_10_SPEED)) {
3124 phy_ctrl |= E1000_PHY_CTRL_NOND0A_LPLU;
3125 E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl);
3127 if (phy->type != e1000_phy_igp_3)
3128 return E1000_SUCCESS;
3130 /* Call gig speed drop workaround on LPLU before accessing
3133 if (hw->mac.type == e1000_ich8lan)
3134 e1000_gig_downshift_workaround_ich8lan(hw);
3136 /* When LPLU is enabled, we should disable SmartSpeed */
3137 ret_val = phy->ops.read_reg(hw,
3138 IGP01E1000_PHY_PORT_CONFIG,
3143 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
3144 ret_val = phy->ops.write_reg(hw,
3145 IGP01E1000_PHY_PORT_CONFIG,
3153 * e1000_valid_nvm_bank_detect_ich8lan - finds out the valid bank 0 or 1
3154 * @hw: pointer to the HW structure
3155 * @bank: pointer to the variable that returns the active bank
3157 * Reads signature byte from the NVM using the flash access registers.
3158 * Word 0x13 bits 15:14 = 10b indicate a valid signature for that bank.
3160 STATIC s32 e1000_valid_nvm_bank_detect_ich8lan(struct e1000_hw *hw, u32 *bank)
3163 struct e1000_nvm_info *nvm = &hw->nvm;
3164 u32 bank1_offset = nvm->flash_bank_size * sizeof(u16);
3165 u32 act_offset = E1000_ICH_NVM_SIG_WORD * 2 + 1;
3169 DEBUGFUNC("e1000_valid_nvm_bank_detect_ich8lan");
3171 switch (hw->mac.type) {
3174 eecd = E1000_READ_REG(hw, E1000_EECD);
3175 if ((eecd & E1000_EECD_SEC1VAL_VALID_MASK) ==
3176 E1000_EECD_SEC1VAL_VALID_MASK) {
3177 if (eecd & E1000_EECD_SEC1VAL)
3182 return E1000_SUCCESS;
3184 DEBUGOUT("Unable to determine valid NVM bank via EEC - reading flash signature\n");
3187 /* set bank to 0 in case flash read fails */
3191 ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset,
3195 if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
3196 E1000_ICH_NVM_SIG_VALUE) {
3198 return E1000_SUCCESS;
3202 ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset +
3207 if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
3208 E1000_ICH_NVM_SIG_VALUE) {
3210 return E1000_SUCCESS;
3213 DEBUGOUT("ERROR: No valid NVM bank present\n");
3214 return -E1000_ERR_NVM;
3219 * e1000_read_nvm_ich8lan - Read word(s) from the NVM
3220 * @hw: pointer to the HW structure
3221 * @offset: The offset (in bytes) of the word(s) to read.
3222 * @words: Size of data to read in words
3223 * @data: Pointer to the word(s) to read at offset.
3225 * Reads a word(s) from the NVM using the flash access registers.
3227 STATIC s32 e1000_read_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
3230 struct e1000_nvm_info *nvm = &hw->nvm;
3231 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
3233 s32 ret_val = E1000_SUCCESS;
3237 DEBUGFUNC("e1000_read_nvm_ich8lan");
3239 if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
3241 DEBUGOUT("nvm parameter(s) out of bounds\n");
3242 ret_val = -E1000_ERR_NVM;
3246 nvm->ops.acquire(hw);
3248 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
3249 if (ret_val != E1000_SUCCESS) {
3250 DEBUGOUT("Could not detect valid bank, assuming bank 0\n");
3254 act_offset = (bank) ? nvm->flash_bank_size : 0;
3255 act_offset += offset;
3257 ret_val = E1000_SUCCESS;
3258 for (i = 0; i < words; i++) {
3259 if (dev_spec->shadow_ram[offset+i].modified) {
3260 data[i] = dev_spec->shadow_ram[offset+i].value;
3262 ret_val = e1000_read_flash_word_ich8lan(hw,
3271 nvm->ops.release(hw);
3275 DEBUGOUT1("NVM read error: %d\n", ret_val);
3281 * e1000_flash_cycle_init_ich8lan - Initialize flash
3282 * @hw: pointer to the HW structure
3284 * This function does initial flash setup so that a new read/write/erase cycle
3287 STATIC s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw)
3289 union ich8_hws_flash_status hsfsts;
3290 s32 ret_val = -E1000_ERR_NVM;
3292 DEBUGFUNC("e1000_flash_cycle_init_ich8lan");
3294 hsfsts.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
3296 /* Check if the flash descriptor is valid */
3297 if (!hsfsts.hsf_status.fldesvalid) {
3298 DEBUGOUT("Flash descriptor invalid. SW Sequencing must be used.\n");
3299 return -E1000_ERR_NVM;
3302 /* Clear FCERR and DAEL in hw status by writing 1 */
3303 hsfsts.hsf_status.flcerr = 1;
3304 hsfsts.hsf_status.dael = 1;
3305 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFSTS, hsfsts.regval);
3307 /* Either we should have a hardware SPI cycle in progress
3308 * bit to check against, in order to start a new cycle or
3309 * FDONE bit should be changed in the hardware so that it
3310 * is 1 after hardware reset, which can then be used as an
3311 * indication whether a cycle is in progress or has been
3315 if (!hsfsts.hsf_status.flcinprog) {
3316 /* There is no cycle running at present,
3317 * so we can start a cycle.
3318 * Begin by setting Flash Cycle Done.
3320 hsfsts.hsf_status.flcdone = 1;
3321 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFSTS, hsfsts.regval);
3322 ret_val = E1000_SUCCESS;
3326 /* Otherwise poll for sometime so the current
3327 * cycle has a chance to end before giving up.
3329 for (i = 0; i < ICH_FLASH_READ_COMMAND_TIMEOUT; i++) {
3330 hsfsts.regval = E1000_READ_FLASH_REG16(hw,
3332 if (!hsfsts.hsf_status.flcinprog) {
3333 ret_val = E1000_SUCCESS;
3338 if (ret_val == E1000_SUCCESS) {
3339 /* Successful in waiting for previous cycle to timeout,
3340 * now set the Flash Cycle Done.
3342 hsfsts.hsf_status.flcdone = 1;
3343 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFSTS,
3346 DEBUGOUT("Flash controller busy, cannot get access\n");
3354 * e1000_flash_cycle_ich8lan - Starts flash cycle (read/write/erase)
3355 * @hw: pointer to the HW structure
3356 * @timeout: maximum time to wait for completion
3358 * This function starts a flash cycle and waits for its completion.
3360 STATIC s32 e1000_flash_cycle_ich8lan(struct e1000_hw *hw, u32 timeout)
3362 union ich8_hws_flash_ctrl hsflctl;
3363 union ich8_hws_flash_status hsfsts;
3366 DEBUGFUNC("e1000_flash_cycle_ich8lan");
3368 /* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */
3369 hsflctl.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFCTL);
3370 hsflctl.hsf_ctrl.flcgo = 1;
3372 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFCTL, hsflctl.regval);
3374 /* wait till FDONE bit is set to 1 */
3376 hsfsts.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
3377 if (hsfsts.hsf_status.flcdone)
3380 } while (i++ < timeout);
3382 if (hsfsts.hsf_status.flcdone && !hsfsts.hsf_status.flcerr)
3383 return E1000_SUCCESS;
3385 return -E1000_ERR_NVM;
3389 * e1000_read_flash_word_ich8lan - Read word from flash
3390 * @hw: pointer to the HW structure
3391 * @offset: offset to data location
3392 * @data: pointer to the location for storing the data
3394 * Reads the flash word at offset into data. Offset is converted
3395 * to bytes before read.
3397 STATIC s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset,
3400 DEBUGFUNC("e1000_read_flash_word_ich8lan");
3403 return -E1000_ERR_NVM;
3405 /* Must convert offset into bytes. */
3408 return e1000_read_flash_data_ich8lan(hw, offset, 2, data);
3412 * e1000_read_flash_byte_ich8lan - Read byte from flash
3413 * @hw: pointer to the HW structure
3414 * @offset: The offset of the byte to read.
3415 * @data: Pointer to a byte to store the value read.
3417 * Reads a single byte from the NVM using the flash access registers.
3419 STATIC s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
3425 ret_val = e1000_read_flash_data_ich8lan(hw, offset, 1, &word);
3432 return E1000_SUCCESS;
3436 * e1000_read_flash_data_ich8lan - Read byte or word from NVM
3437 * @hw: pointer to the HW structure
3438 * @offset: The offset (in bytes) of the byte or word to read.
3439 * @size: Size of data to read, 1=byte 2=word
3440 * @data: Pointer to the word to store the value read.
3442 * Reads a byte or word from the NVM using the flash access registers.
3444 STATIC s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
3447 union ich8_hws_flash_status hsfsts;
3448 union ich8_hws_flash_ctrl hsflctl;
3449 u32 flash_linear_addr;
3451 s32 ret_val = -E1000_ERR_NVM;
3454 DEBUGFUNC("e1000_read_flash_data_ich8lan");
3456 if (size < 1 || size > 2 || offset > ICH_FLASH_LINEAR_ADDR_MASK)
3457 return -E1000_ERR_NVM;
3458 flash_linear_addr = ((ICH_FLASH_LINEAR_ADDR_MASK & offset) +
3459 hw->nvm.flash_base_addr);
3464 ret_val = e1000_flash_cycle_init_ich8lan(hw);
3465 if (ret_val != E1000_SUCCESS)
3467 hsflctl.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFCTL);
3469 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
3470 hsflctl.hsf_ctrl.fldbcount = size - 1;
3471 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_READ;
3472 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFCTL, hsflctl.regval);
3474 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FADDR, flash_linear_addr);
3477 e1000_flash_cycle_ich8lan(hw,
3478 ICH_FLASH_READ_COMMAND_TIMEOUT);
3480 /* Check if FCERR is set to 1, if set to 1, clear it
3481 * and try the whole sequence a few more times, else
3482 * read in (shift in) the Flash Data0, the order is
3483 * least significant byte first msb to lsb
3485 if (ret_val == E1000_SUCCESS) {
3486 flash_data = E1000_READ_FLASH_REG(hw, ICH_FLASH_FDATA0);
3488 *data = (u8)(flash_data & 0x000000FF);
3490 *data = (u16)(flash_data & 0x0000FFFF);
3493 /* If we've gotten here, then things are probably
3494 * completely hosed, but if the error condition is
3495 * detected, it won't hurt to give it another try...
3496 * ICH_FLASH_CYCLE_REPEAT_COUNT times.
3498 hsfsts.regval = E1000_READ_FLASH_REG16(hw,
3500 if (hsfsts.hsf_status.flcerr) {
3501 /* Repeat for some time before giving up. */
3503 } else if (!hsfsts.hsf_status.flcdone) {
3504 DEBUGOUT("Timeout error - flash cycle did not complete.\n");
3508 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
3514 * e1000_write_nvm_ich8lan - Write word(s) to the NVM
3515 * @hw: pointer to the HW structure
3516 * @offset: The offset (in bytes) of the word(s) to write.
3517 * @words: Size of data to write in words
3518 * @data: Pointer to the word(s) to write at offset.
3520 * Writes a byte or word to the NVM using the flash access registers.
3522 STATIC s32 e1000_write_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
3525 struct e1000_nvm_info *nvm = &hw->nvm;
3526 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
3529 DEBUGFUNC("e1000_write_nvm_ich8lan");
3531 if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
3533 DEBUGOUT("nvm parameter(s) out of bounds\n");
3534 return -E1000_ERR_NVM;
3537 nvm->ops.acquire(hw);
3539 for (i = 0; i < words; i++) {
3540 dev_spec->shadow_ram[offset+i].modified = true;
3541 dev_spec->shadow_ram[offset+i].value = data[i];
3544 nvm->ops.release(hw);
3546 return E1000_SUCCESS;
3550 * e1000_update_nvm_checksum_ich8lan - Update the checksum for NVM
3551 * @hw: pointer to the HW structure
3553 * The NVM checksum is updated by calling the generic update_nvm_checksum,
3554 * which writes the checksum to the shadow ram. The changes in the shadow
3555 * ram are then committed to the EEPROM by processing each bank at a time
3556 * checking for the modified bit and writing only the pending changes.
3557 * After a successful commit, the shadow ram is cleared and is ready for
3560 STATIC s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw)
3562 struct e1000_nvm_info *nvm = &hw->nvm;
3563 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
3564 u32 i, act_offset, new_bank_offset, old_bank_offset, bank;
3568 DEBUGFUNC("e1000_update_nvm_checksum_ich8lan");
3570 ret_val = e1000_update_nvm_checksum_generic(hw);
3574 if (nvm->type != e1000_nvm_flash_sw)
3577 nvm->ops.acquire(hw);
3579 /* We're writing to the opposite bank so if we're on bank 1,
3580 * write to bank 0 etc. We also need to erase the segment that
3581 * is going to be written
3583 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
3584 if (ret_val != E1000_SUCCESS) {
3585 DEBUGOUT("Could not detect valid bank, assuming bank 0\n");
3590 new_bank_offset = nvm->flash_bank_size;
3591 old_bank_offset = 0;
3592 ret_val = e1000_erase_flash_bank_ich8lan(hw, 1);
3596 old_bank_offset = nvm->flash_bank_size;
3597 new_bank_offset = 0;
3598 ret_val = e1000_erase_flash_bank_ich8lan(hw, 0);
3603 for (i = 0; i < E1000_SHADOW_RAM_WORDS; i++) {
3604 /* Determine whether to write the value stored
3605 * in the other NVM bank or a modified value stored
3608 if (dev_spec->shadow_ram[i].modified) {
3609 data = dev_spec->shadow_ram[i].value;
3611 ret_val = e1000_read_flash_word_ich8lan(hw, i +
3618 /* If the word is 0x13, then make sure the signature bits
3619 * (15:14) are 11b until the commit has completed.
3620 * This will allow us to write 10b which indicates the
3621 * signature is valid. We want to do this after the write
3622 * has completed so that we don't mark the segment valid
3623 * while the write is still in progress
3625 if (i == E1000_ICH_NVM_SIG_WORD)
3626 data |= E1000_ICH_NVM_SIG_MASK;
3628 /* Convert offset to bytes. */
3629 act_offset = (i + new_bank_offset) << 1;
3632 /* Write the bytes to the new bank. */
3633 ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
3640 ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
3647 /* Don't bother writing the segment valid bits if sector
3648 * programming failed.
3651 DEBUGOUT("Flash commit failed.\n");
3655 /* Finally validate the new segment by setting bit 15:14
3656 * to 10b in word 0x13 , this can be done without an
3657 * erase as well since these bits are 11 to start with
3658 * and we need to change bit 14 to 0b
3660 act_offset = new_bank_offset + E1000_ICH_NVM_SIG_WORD;
3661 ret_val = e1000_read_flash_word_ich8lan(hw, act_offset, &data);
3666 ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
3672 /* And invalidate the previously valid segment by setting
3673 * its signature word (0x13) high_byte to 0b. This can be
3674 * done without an erase because flash erase sets all bits
3675 * to 1's. We can write 1's to 0's without an erase
3677 act_offset = (old_bank_offset + E1000_ICH_NVM_SIG_WORD) * 2 + 1;
3678 ret_val = e1000_retry_write_flash_byte_ich8lan(hw, act_offset, 0);
3682 /* Great! Everything worked, we can now clear the cached entries. */
3683 for (i = 0; i < E1000_SHADOW_RAM_WORDS; i++) {
3684 dev_spec->shadow_ram[i].modified = false;
3685 dev_spec->shadow_ram[i].value = 0xFFFF;
3689 nvm->ops.release(hw);
3691 /* Reload the EEPROM, or else modifications will not appear
3692 * until after the next adapter reset.
3695 nvm->ops.reload(hw);
3701 DEBUGOUT1("NVM update error: %d\n", ret_val);
3707 * e1000_validate_nvm_checksum_ich8lan - Validate EEPROM checksum
3708 * @hw: pointer to the HW structure
3710 * Check to see if checksum needs to be fixed by reading bit 6 in word 0x19.
3711 * If the bit is 0, that the EEPROM had been modified, but the checksum was not
3712 * calculated, in which case we need to calculate the checksum and set bit 6.
3714 STATIC s32 e1000_validate_nvm_checksum_ich8lan(struct e1000_hw *hw)
3719 u16 valid_csum_mask;
3721 DEBUGFUNC("e1000_validate_nvm_checksum_ich8lan");
3723 /* Read NVM and check Invalid Image CSUM bit. If this bit is 0,
3724 * the checksum needs to be fixed. This bit is an indication that
3725 * the NVM was prepared by OEM software and did not calculate
3726 * the checksum...a likely scenario.
3728 switch (hw->mac.type) {
3731 valid_csum_mask = NVM_COMPAT_VALID_CSUM;
3734 word = NVM_FUTURE_INIT_WORD1;
3735 valid_csum_mask = NVM_FUTURE_INIT_WORD1_VALID_CSUM;
3739 ret_val = hw->nvm.ops.read(hw, word, 1, &data);
3743 if (!(data & valid_csum_mask)) {
3744 data |= valid_csum_mask;
3745 ret_val = hw->nvm.ops.write(hw, word, 1, &data);
3748 ret_val = hw->nvm.ops.update(hw);
3753 return e1000_validate_nvm_checksum_generic(hw);
3757 * e1000_write_flash_data_ich8lan - Writes bytes to the NVM
3758 * @hw: pointer to the HW structure
3759 * @offset: The offset (in bytes) of the byte/word to read.
3760 * @size: Size of data to read, 1=byte 2=word
3761 * @data: The byte(s) to write to the NVM.
3763 * Writes one/two bytes to the NVM using the flash access registers.
3765 STATIC s32 e1000_write_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
3768 union ich8_hws_flash_status hsfsts;
3769 union ich8_hws_flash_ctrl hsflctl;
3770 u32 flash_linear_addr;
3775 DEBUGFUNC("e1000_write_ich8_data");
3777 if (size < 1 || size > 2 || offset > ICH_FLASH_LINEAR_ADDR_MASK)
3778 return -E1000_ERR_NVM;
3780 flash_linear_addr = ((ICH_FLASH_LINEAR_ADDR_MASK & offset) +
3781 hw->nvm.flash_base_addr);
3786 ret_val = e1000_flash_cycle_init_ich8lan(hw);
3787 if (ret_val != E1000_SUCCESS)
3789 hsflctl.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFCTL);
3791 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
3792 hsflctl.hsf_ctrl.fldbcount = size - 1;
3793 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_WRITE;
3794 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFCTL, hsflctl.regval);
3796 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FADDR, flash_linear_addr);
3799 flash_data = (u32)data & 0x00FF;
3801 flash_data = (u32)data;
3803 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FDATA0, flash_data);
3805 /* check if FCERR is set to 1 , if set to 1, clear it
3806 * and try the whole sequence a few more times else done
3809 e1000_flash_cycle_ich8lan(hw,
3810 ICH_FLASH_WRITE_COMMAND_TIMEOUT);
3811 if (ret_val == E1000_SUCCESS)
3814 /* If we're here, then things are most likely
3815 * completely hosed, but if the error condition
3816 * is detected, it won't hurt to give it another
3817 * try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
3819 hsfsts.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
3820 if (hsfsts.hsf_status.flcerr)
3821 /* Repeat for some time before giving up. */
3823 if (!hsfsts.hsf_status.flcdone) {
3824 DEBUGOUT("Timeout error - flash cycle did not complete.\n");
3827 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
3833 * e1000_write_flash_byte_ich8lan - Write a single byte to NVM
3834 * @hw: pointer to the HW structure
3835 * @offset: The index of the byte to read.
3836 * @data: The byte to write to the NVM.
3838 * Writes a single byte to the NVM using the flash access registers.
3840 STATIC s32 e1000_write_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
3843 u16 word = (u16)data;
3845 DEBUGFUNC("e1000_write_flash_byte_ich8lan");
3847 return e1000_write_flash_data_ich8lan(hw, offset, 1, word);
3851 * e1000_retry_write_flash_byte_ich8lan - Writes a single byte to NVM
3852 * @hw: pointer to the HW structure
3853 * @offset: The offset of the byte to write.
3854 * @byte: The byte to write to the NVM.
3856 * Writes a single byte to the NVM using the flash access registers.
3857 * Goes through a retry algorithm before giving up.
3859 STATIC s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw,
3860 u32 offset, u8 byte)
3863 u16 program_retries;
3865 DEBUGFUNC("e1000_retry_write_flash_byte_ich8lan");
3867 ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
3871 for (program_retries = 0; program_retries < 100; program_retries++) {
3872 DEBUGOUT2("Retrying Byte %2.2X at offset %u\n", byte, offset);
3874 ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
3875 if (ret_val == E1000_SUCCESS)
3878 if (program_retries == 100)
3879 return -E1000_ERR_NVM;
3881 return E1000_SUCCESS;
3885 * e1000_erase_flash_bank_ich8lan - Erase a bank (4k) from NVM
3886 * @hw: pointer to the HW structure
3887 * @bank: 0 for first bank, 1 for second bank, etc.
3889 * Erases the bank specified. Each bank is a 4k block. Banks are 0 based.
3890 * bank N is 4096 * N + flash_reg_addr.
3892 STATIC s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank)
3894 struct e1000_nvm_info *nvm = &hw->nvm;
3895 union ich8_hws_flash_status hsfsts;
3896 union ich8_hws_flash_ctrl hsflctl;
3897 u32 flash_linear_addr;
3898 /* bank size is in 16bit words - adjust to bytes */
3899 u32 flash_bank_size = nvm->flash_bank_size * 2;
3902 s32 j, iteration, sector_size;
3904 DEBUGFUNC("e1000_erase_flash_bank_ich8lan");
3906 hsfsts.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
3908 /* Determine HW Sector size: Read BERASE bits of hw flash status
3910 * 00: The Hw sector is 256 bytes, hence we need to erase 16
3911 * consecutive sectors. The start index for the nth Hw sector
3912 * can be calculated as = bank * 4096 + n * 256
3913 * 01: The Hw sector is 4K bytes, hence we need to erase 1 sector.
3914 * The start index for the nth Hw sector can be calculated
3916 * 10: The Hw sector is 8K bytes, nth sector = bank * 8192
3917 * (ich9 only, otherwise error condition)
3918 * 11: The Hw sector is 64K bytes, nth sector = bank * 65536
3920 switch (hsfsts.hsf_status.berasesz) {
3922 /* Hw sector size 256 */
3923 sector_size = ICH_FLASH_SEG_SIZE_256;
3924 iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_256;
3927 sector_size = ICH_FLASH_SEG_SIZE_4K;
3931 sector_size = ICH_FLASH_SEG_SIZE_8K;
3935 sector_size = ICH_FLASH_SEG_SIZE_64K;
3939 return -E1000_ERR_NVM;
3942 /* Start with the base address, then add the sector offset. */
3943 flash_linear_addr = hw->nvm.flash_base_addr;
3944 flash_linear_addr += (bank) ? flash_bank_size : 0;
3946 for (j = 0; j < iteration; j++) {
3948 u32 timeout = ICH_FLASH_ERASE_COMMAND_TIMEOUT;
3951 ret_val = e1000_flash_cycle_init_ich8lan(hw);
3955 /* Write a value 11 (block Erase) in Flash
3956 * Cycle field in hw flash control
3959 E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFCTL);
3961 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_ERASE;
3962 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFCTL,
3965 /* Write the last 24 bits of an index within the
3966 * block into Flash Linear address field in Flash
3969 flash_linear_addr += (j * sector_size);
3970 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FADDR,
3973 ret_val = e1000_flash_cycle_ich8lan(hw, timeout);
3974 if (ret_val == E1000_SUCCESS)
3977 /* Check if FCERR is set to 1. If 1,
3978 * clear it and try the whole sequence
3979 * a few more times else Done
3981 hsfsts.regval = E1000_READ_FLASH_REG16(hw,
3983 if (hsfsts.hsf_status.flcerr)
3984 /* repeat for some time before giving up */
3986 else if (!hsfsts.hsf_status.flcdone)
3988 } while (++count < ICH_FLASH_CYCLE_REPEAT_COUNT);
3991 return E1000_SUCCESS;
3995 * e1000_valid_led_default_ich8lan - Set the default LED settings
3996 * @hw: pointer to the HW structure
3997 * @data: Pointer to the LED settings
3999 * Reads the LED default settings from the NVM to data. If the NVM LED
4000 * settings is all 0's or F's, set the LED default to a valid LED default
4003 STATIC s32 e1000_valid_led_default_ich8lan(struct e1000_hw *hw, u16 *data)
4007 DEBUGFUNC("e1000_valid_led_default_ich8lan");
4009 ret_val = hw->nvm.ops.read(hw, NVM_ID_LED_SETTINGS, 1, data);
4011 DEBUGOUT("NVM Read Error\n");
4015 if (*data == ID_LED_RESERVED_0000 || *data == ID_LED_RESERVED_FFFF)
4016 *data = ID_LED_DEFAULT_ICH8LAN;
4018 return E1000_SUCCESS;
4022 * e1000_id_led_init_pchlan - store LED configurations
4023 * @hw: pointer to the HW structure
4025 * PCH does not control LEDs via the LEDCTL register, rather it uses
4026 * the PHY LED configuration register.
4028 * PCH also does not have an "always on" or "always off" mode which
4029 * complicates the ID feature. Instead of using the "on" mode to indicate
4030 * in ledctl_mode2 the LEDs to use for ID (see e1000_id_led_init_generic()),
4031 * use "link_up" mode. The LEDs will still ID on request if there is no
4032 * link based on logic in e1000_led_[on|off]_pchlan().
4034 STATIC s32 e1000_id_led_init_pchlan(struct e1000_hw *hw)
4036 struct e1000_mac_info *mac = &hw->mac;
4038 const u32 ledctl_on = E1000_LEDCTL_MODE_LINK_UP;
4039 const u32 ledctl_off = E1000_LEDCTL_MODE_LINK_UP | E1000_PHY_LED0_IVRT;
4040 u16 data, i, temp, shift;
4042 DEBUGFUNC("e1000_id_led_init_pchlan");
4044 /* Get default ID LED modes */
4045 ret_val = hw->nvm.ops.valid_led_default(hw, &data);
4049 mac->ledctl_default = E1000_READ_REG(hw, E1000_LEDCTL);
4050 mac->ledctl_mode1 = mac->ledctl_default;
4051 mac->ledctl_mode2 = mac->ledctl_default;
4053 for (i = 0; i < 4; i++) {
4054 temp = (data >> (i << 2)) & E1000_LEDCTL_LED0_MODE_MASK;
4057 case ID_LED_ON1_DEF2:
4058 case ID_LED_ON1_ON2:
4059 case ID_LED_ON1_OFF2:
4060 mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
4061 mac->ledctl_mode1 |= (ledctl_on << shift);
4063 case ID_LED_OFF1_DEF2:
4064 case ID_LED_OFF1_ON2:
4065 case ID_LED_OFF1_OFF2:
4066 mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
4067 mac->ledctl_mode1 |= (ledctl_off << shift);
4074 case ID_LED_DEF1_ON2:
4075 case ID_LED_ON1_ON2:
4076 case ID_LED_OFF1_ON2:
4077 mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
4078 mac->ledctl_mode2 |= (ledctl_on << shift);
4080 case ID_LED_DEF1_OFF2:
4081 case ID_LED_ON1_OFF2:
4082 case ID_LED_OFF1_OFF2:
4083 mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
4084 mac->ledctl_mode2 |= (ledctl_off << shift);
4092 return E1000_SUCCESS;
4096 * e1000_get_bus_info_ich8lan - Get/Set the bus type and width
4097 * @hw: pointer to the HW structure
4099 * ICH8 use the PCI Express bus, but does not contain a PCI Express Capability
4100 * register, so the the bus width is hard coded.
4102 STATIC s32 e1000_get_bus_info_ich8lan(struct e1000_hw *hw)
4104 struct e1000_bus_info *bus = &hw->bus;
4107 DEBUGFUNC("e1000_get_bus_info_ich8lan");
4109 ret_val = e1000_get_bus_info_pcie_generic(hw);
4111 /* ICH devices are "PCI Express"-ish. They have
4112 * a configuration space, but do not contain
4113 * PCI Express Capability registers, so bus width
4114 * must be hardcoded.
4116 if (bus->width == e1000_bus_width_unknown)
4117 bus->width = e1000_bus_width_pcie_x1;
4123 * e1000_reset_hw_ich8lan - Reset the hardware
4124 * @hw: pointer to the HW structure
4126 * Does a full reset of the hardware which includes a reset of the PHY and
4129 STATIC s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
4131 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
4136 DEBUGFUNC("e1000_reset_hw_ich8lan");
4138 /* Prevent the PCI-E bus from sticking if there is no TLP connection
4139 * on the last TLP read/write transaction when MAC is reset.
4141 ret_val = e1000_disable_pcie_master_generic(hw);
4143 DEBUGOUT("PCI-E Master disable polling has failed.\n");
4145 DEBUGOUT("Masking off all interrupts\n");
4146 E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
4148 /* Disable the Transmit and Receive units. Then delay to allow
4149 * any pending transactions to complete before we hit the MAC
4150 * with the global reset.
4152 E1000_WRITE_REG(hw, E1000_RCTL, 0);
4153 E1000_WRITE_REG(hw, E1000_TCTL, E1000_TCTL_PSP);
4154 E1000_WRITE_FLUSH(hw);
4158 /* Workaround for ICH8 bit corruption issue in FIFO memory */
4159 if (hw->mac.type == e1000_ich8lan) {
4160 /* Set Tx and Rx buffer allocation to 8k apiece. */
4161 E1000_WRITE_REG(hw, E1000_PBA, E1000_PBA_8K);
4162 /* Set Packet Buffer Size to 16k. */
4163 E1000_WRITE_REG(hw, E1000_PBS, E1000_PBS_16K);
4166 if (hw->mac.type == e1000_pchlan) {
4167 /* Save the NVM K1 bit setting*/
4168 ret_val = e1000_read_nvm(hw, E1000_NVM_K1_CONFIG, 1, &kum_cfg);
4172 if (kum_cfg & E1000_NVM_K1_ENABLE)
4173 dev_spec->nvm_k1_enabled = true;
4175 dev_spec->nvm_k1_enabled = false;
4178 ctrl = E1000_READ_REG(hw, E1000_CTRL);
4180 if (!hw->phy.ops.check_reset_block(hw)) {
4181 /* Full-chip reset requires MAC and PHY reset at the same
4182 * time to make sure the interface between MAC and the
4183 * external PHY is reset.
4185 ctrl |= E1000_CTRL_PHY_RST;
4187 /* Gate automatic PHY configuration by hardware on
4190 if ((hw->mac.type == e1000_pch2lan) &&
4191 !(E1000_READ_REG(hw, E1000_FWSM) & E1000_ICH_FWSM_FW_VALID))
4192 e1000_gate_hw_phy_config_ich8lan(hw, true);
4194 ret_val = e1000_acquire_swflag_ich8lan(hw);
4195 DEBUGOUT("Issuing a global reset to ich8lan\n");
4196 E1000_WRITE_REG(hw, E1000_CTRL, (ctrl | E1000_CTRL_RST));
4197 /* cannot issue a flush here because it hangs the hardware */
4200 /* Set Phy Config Counter to 50msec */
4201 if (hw->mac.type == e1000_pch2lan) {
4202 reg = E1000_READ_REG(hw, E1000_FEXTNVM3);
4203 reg &= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK;
4204 reg |= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC;
4205 E1000_WRITE_REG(hw, E1000_FEXTNVM3, reg);
4209 E1000_MUTEX_UNLOCK(&hw->dev_spec.ich8lan.swflag_mutex);
4211 if (ctrl & E1000_CTRL_PHY_RST) {
4212 ret_val = hw->phy.ops.get_cfg_done(hw);
4216 ret_val = e1000_post_phy_reset_ich8lan(hw);
4221 /* For PCH, this write will make sure that any noise
4222 * will be detected as a CRC error and be dropped rather than show up
4223 * as a bad packet to the DMA engine.
4225 if (hw->mac.type == e1000_pchlan)
4226 E1000_WRITE_REG(hw, E1000_CRC_OFFSET, 0x65656565);
4228 E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
4229 E1000_READ_REG(hw, E1000_ICR);
4231 reg = E1000_READ_REG(hw, E1000_KABGTXD);
4232 reg |= E1000_KABGTXD_BGSQLBIAS;
4233 E1000_WRITE_REG(hw, E1000_KABGTXD, reg);
4235 return E1000_SUCCESS;
4239 * e1000_init_hw_ich8lan - Initialize the hardware
4240 * @hw: pointer to the HW structure
4242 * Prepares the hardware for transmit and receive by doing the following:
4243 * - initialize hardware bits
4244 * - initialize LED identification
4245 * - setup receive address registers
4246 * - setup flow control
4247 * - setup transmit descriptors
4248 * - clear statistics
4250 STATIC s32 e1000_init_hw_ich8lan(struct e1000_hw *hw)
4252 struct e1000_mac_info *mac = &hw->mac;
4253 u32 ctrl_ext, txdctl, snoop;
4257 DEBUGFUNC("e1000_init_hw_ich8lan");
4259 e1000_initialize_hw_bits_ich8lan(hw);
4261 /* Initialize identification LED */
4262 ret_val = mac->ops.id_led_init(hw);
4263 /* An error is not fatal and we should not stop init due to this */
4265 DEBUGOUT("Error initializing identification LED\n");
4267 /* Setup the receive address. */
4268 e1000_init_rx_addrs_generic(hw, mac->rar_entry_count);
4270 /* Zero out the Multicast HASH table */
4271 DEBUGOUT("Zeroing the MTA\n");
4272 for (i = 0; i < mac->mta_reg_count; i++)
4273 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
4275 /* The 82578 Rx buffer will stall if wakeup is enabled in host and
4276 * the ME. Disable wakeup by clearing the host wakeup bit.
4277 * Reset the phy after disabling host wakeup to reset the Rx buffer.
4279 if (hw->phy.type == e1000_phy_82578) {
4280 hw->phy.ops.read_reg(hw, BM_PORT_GEN_CFG, &i);
4281 i &= ~BM_WUC_HOST_WU_BIT;
4282 hw->phy.ops.write_reg(hw, BM_PORT_GEN_CFG, i);
4283 ret_val = e1000_phy_hw_reset_ich8lan(hw);
4288 /* Setup link and flow control */
4289 ret_val = mac->ops.setup_link(hw);
4291 /* Set the transmit descriptor write-back policy for both queues */
4292 txdctl = E1000_READ_REG(hw, E1000_TXDCTL(0));
4293 txdctl = ((txdctl & ~E1000_TXDCTL_WTHRESH) |
4294 E1000_TXDCTL_FULL_TX_DESC_WB);
4295 txdctl = ((txdctl & ~E1000_TXDCTL_PTHRESH) |
4296 E1000_TXDCTL_MAX_TX_DESC_PREFETCH);
4297 E1000_WRITE_REG(hw, E1000_TXDCTL(0), txdctl);
4298 txdctl = E1000_READ_REG(hw, E1000_TXDCTL(1));
4299 txdctl = ((txdctl & ~E1000_TXDCTL_WTHRESH) |
4300 E1000_TXDCTL_FULL_TX_DESC_WB);
4301 txdctl = ((txdctl & ~E1000_TXDCTL_PTHRESH) |
4302 E1000_TXDCTL_MAX_TX_DESC_PREFETCH);
4303 E1000_WRITE_REG(hw, E1000_TXDCTL(1), txdctl);
4305 /* ICH8 has opposite polarity of no_snoop bits.
4306 * By default, we should use snoop behavior.
4308 if (mac->type == e1000_ich8lan)
4309 snoop = PCIE_ICH8_SNOOP_ALL;
4311 snoop = (u32) ~(PCIE_NO_SNOOP_ALL);
4312 e1000_set_pcie_no_snoop_generic(hw, snoop);
4314 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
4315 ctrl_ext |= E1000_CTRL_EXT_RO_DIS;
4316 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
4318 /* Clear all of the statistics registers (clear on read). It is
4319 * important that we do this after we have tried to establish link
4320 * because the symbol error count will increment wildly if there
4323 e1000_clear_hw_cntrs_ich8lan(hw);
4329 * e1000_initialize_hw_bits_ich8lan - Initialize required hardware bits
4330 * @hw: pointer to the HW structure
4332 * Sets/Clears required hardware bits necessary for correctly setting up the
4333 * hardware for transmit and receive.
4335 STATIC void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw)
4339 DEBUGFUNC("e1000_initialize_hw_bits_ich8lan");
4341 /* Extended Device Control */
4342 reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
4344 /* Enable PHY low-power state when MAC is at D3 w/o WoL */
4345 if (hw->mac.type >= e1000_pchlan)
4346 reg |= E1000_CTRL_EXT_PHYPDEN;
4347 E1000_WRITE_REG(hw, E1000_CTRL_EXT, reg);
4349 /* Transmit Descriptor Control 0 */
4350 reg = E1000_READ_REG(hw, E1000_TXDCTL(0));
4352 E1000_WRITE_REG(hw, E1000_TXDCTL(0), reg);
4354 /* Transmit Descriptor Control 1 */
4355 reg = E1000_READ_REG(hw, E1000_TXDCTL(1));
4357 E1000_WRITE_REG(hw, E1000_TXDCTL(1), reg);
4359 /* Transmit Arbitration Control 0 */
4360 reg = E1000_READ_REG(hw, E1000_TARC(0));
4361 if (hw->mac.type == e1000_ich8lan)
4362 reg |= (1 << 28) | (1 << 29);
4363 reg |= (1 << 23) | (1 << 24) | (1 << 26) | (1 << 27);
4364 E1000_WRITE_REG(hw, E1000_TARC(0), reg);
4366 /* Transmit Arbitration Control 1 */
4367 reg = E1000_READ_REG(hw, E1000_TARC(1));
4368 if (E1000_READ_REG(hw, E1000_TCTL) & E1000_TCTL_MULR)
4372 reg |= (1 << 24) | (1 << 26) | (1 << 30);
4373 E1000_WRITE_REG(hw, E1000_TARC(1), reg);
4376 if (hw->mac.type == e1000_ich8lan) {
4377 reg = E1000_READ_REG(hw, E1000_STATUS);
4379 E1000_WRITE_REG(hw, E1000_STATUS, reg);
4382 /* work-around descriptor data corruption issue during nfs v2 udp
4383 * traffic, just disable the nfs filtering capability
4385 reg = E1000_READ_REG(hw, E1000_RFCTL);
4386 reg |= (E1000_RFCTL_NFSW_DIS | E1000_RFCTL_NFSR_DIS);
4388 /* Disable IPv6 extension header parsing because some malformed
4389 * IPv6 headers can hang the Rx.
4391 if (hw->mac.type == e1000_ich8lan)
4392 reg |= (E1000_RFCTL_IPV6_EX_DIS | E1000_RFCTL_NEW_IPV6_EXT_DIS);
4393 E1000_WRITE_REG(hw, E1000_RFCTL, reg);
4395 /* Enable ECC on Lynxpoint */
4396 if (hw->mac.type == e1000_pch_lpt) {
4397 reg = E1000_READ_REG(hw, E1000_PBECCSTS);
4398 reg |= E1000_PBECCSTS_ECC_ENABLE;
4399 E1000_WRITE_REG(hw, E1000_PBECCSTS, reg);
4401 reg = E1000_READ_REG(hw, E1000_CTRL);
4402 reg |= E1000_CTRL_MEHE;
4403 E1000_WRITE_REG(hw, E1000_CTRL, reg);
4410 * e1000_setup_link_ich8lan - Setup flow control and link settings
4411 * @hw: pointer to the HW structure
4413 * Determines which flow control settings to use, then configures flow
4414 * control. Calls the appropriate media-specific link configuration
4415 * function. Assuming the adapter has a valid link partner, a valid link
4416 * should be established. Assumes the hardware has previously been reset
4417 * and the transmitter and receiver are not enabled.
4419 STATIC s32 e1000_setup_link_ich8lan(struct e1000_hw *hw)
4423 DEBUGFUNC("e1000_setup_link_ich8lan");
4425 if (hw->phy.ops.check_reset_block(hw))
4426 return E1000_SUCCESS;
4428 /* ICH parts do not have a word in the NVM to determine
4429 * the default flow control setting, so we explicitly
4432 if (hw->fc.requested_mode == e1000_fc_default)
4433 hw->fc.requested_mode = e1000_fc_full;
4435 /* Save off the requested flow control mode for use later. Depending
4436 * on the link partner's capabilities, we may or may not use this mode.
4438 hw->fc.current_mode = hw->fc.requested_mode;
4440 DEBUGOUT1("After fix-ups FlowControl is now = %x\n",
4441 hw->fc.current_mode);
4443 /* Continue to configure the copper link. */
4444 ret_val = hw->mac.ops.setup_physical_interface(hw);
4448 E1000_WRITE_REG(hw, E1000_FCTTV, hw->fc.pause_time);
4449 if ((hw->phy.type == e1000_phy_82578) ||
4450 (hw->phy.type == e1000_phy_82579) ||
4451 (hw->phy.type == e1000_phy_i217) ||
4452 (hw->phy.type == e1000_phy_82577)) {
4453 E1000_WRITE_REG(hw, E1000_FCRTV_PCH, hw->fc.refresh_time);
4455 ret_val = hw->phy.ops.write_reg(hw,
4456 PHY_REG(BM_PORT_CTRL_PAGE, 27),
4462 return e1000_set_fc_watermarks_generic(hw);
4466 * e1000_setup_copper_link_ich8lan - Configure MAC/PHY interface
4467 * @hw: pointer to the HW structure
4469 * Configures the kumeran interface to the PHY to wait the appropriate time
4470 * when polling the PHY, then call the generic setup_copper_link to finish
4471 * configuring the copper link.
4473 STATIC s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw)
4479 DEBUGFUNC("e1000_setup_copper_link_ich8lan");
4481 ctrl = E1000_READ_REG(hw, E1000_CTRL);
4482 ctrl |= E1000_CTRL_SLU;
4483 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
4484 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
4486 /* Set the mac to wait the maximum time between each iteration
4487 * and increase the max iterations when polling the phy;
4488 * this fixes erroneous timeouts at 10Mbps.
4490 ret_val = e1000_write_kmrn_reg_generic(hw, E1000_KMRNCTRLSTA_TIMEOUTS,
4494 ret_val = e1000_read_kmrn_reg_generic(hw,
4495 E1000_KMRNCTRLSTA_INBAND_PARAM,
4500 ret_val = e1000_write_kmrn_reg_generic(hw,
4501 E1000_KMRNCTRLSTA_INBAND_PARAM,
4506 switch (hw->phy.type) {
4507 case e1000_phy_igp_3:
4508 ret_val = e1000_copper_link_setup_igp(hw);
4513 case e1000_phy_82578:
4514 ret_val = e1000_copper_link_setup_m88(hw);
4518 case e1000_phy_82577:
4519 case e1000_phy_82579:
4520 ret_val = e1000_copper_link_setup_82577(hw);
4525 ret_val = hw->phy.ops.read_reg(hw, IFE_PHY_MDIX_CONTROL,
4530 reg_data &= ~IFE_PMC_AUTO_MDIX;
4532 switch (hw->phy.mdix) {
4534 reg_data &= ~IFE_PMC_FORCE_MDIX;
4537 reg_data |= IFE_PMC_FORCE_MDIX;
4541 reg_data |= IFE_PMC_AUTO_MDIX;
4544 ret_val = hw->phy.ops.write_reg(hw, IFE_PHY_MDIX_CONTROL,
4553 return e1000_setup_copper_link_generic(hw);
4557 * e1000_setup_copper_link_pch_lpt - Configure MAC/PHY interface
4558 * @hw: pointer to the HW structure
4560 * Calls the PHY specific link setup function and then calls the
4561 * generic setup_copper_link to finish configuring the link for
4562 * Lynxpoint PCH devices
4564 STATIC s32 e1000_setup_copper_link_pch_lpt(struct e1000_hw *hw)
4569 DEBUGFUNC("e1000_setup_copper_link_pch_lpt");
4571 ctrl = E1000_READ_REG(hw, E1000_CTRL);
4572 ctrl |= E1000_CTRL_SLU;
4573 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
4574 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
4576 ret_val = e1000_copper_link_setup_82577(hw);
4580 return e1000_setup_copper_link_generic(hw);
4584 * e1000_get_link_up_info_ich8lan - Get current link speed and duplex
4585 * @hw: pointer to the HW structure
4586 * @speed: pointer to store current link speed
4587 * @duplex: pointer to store the current link duplex
4589 * Calls the generic get_speed_and_duplex to retrieve the current link
4590 * information and then calls the Kumeran lock loss workaround for links at
4593 STATIC s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw, u16 *speed,
4598 DEBUGFUNC("e1000_get_link_up_info_ich8lan");
4600 ret_val = e1000_get_speed_and_duplex_copper_generic(hw, speed, duplex);
4604 if ((hw->mac.type == e1000_ich8lan) &&
4605 (hw->phy.type == e1000_phy_igp_3) &&
4606 (*speed == SPEED_1000)) {
4607 ret_val = e1000_kmrn_lock_loss_workaround_ich8lan(hw);
4614 * e1000_kmrn_lock_loss_workaround_ich8lan - Kumeran workaround
4615 * @hw: pointer to the HW structure
4617 * Work-around for 82566 Kumeran PCS lock loss:
4618 * On link status change (i.e. PCI reset, speed change) and link is up and
4620 * 0) if workaround is optionally disabled do nothing
4621 * 1) wait 1ms for Kumeran link to come up
4622 * 2) check Kumeran Diagnostic register PCS lock loss bit
4623 * 3) if not set the link is locked (all is good), otherwise...
4625 * 5) repeat up to 10 times
4626 * Note: this is only called for IGP3 copper when speed is 1gb.
4628 STATIC s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw)
4630 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
4636 DEBUGFUNC("e1000_kmrn_lock_loss_workaround_ich8lan");
4638 if (!dev_spec->kmrn_lock_loss_workaround_enabled)
4639 return E1000_SUCCESS;
4641 /* Make sure link is up before proceeding. If not just return.
4642 * Attempting this while link is negotiating fouled up link
4645 ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link);
4647 return E1000_SUCCESS;
4649 for (i = 0; i < 10; i++) {
4650 /* read once to clear */
4651 ret_val = hw->phy.ops.read_reg(hw, IGP3_KMRN_DIAG, &data);
4654 /* and again to get new status */
4655 ret_val = hw->phy.ops.read_reg(hw, IGP3_KMRN_DIAG, &data);
4659 /* check for PCS lock */
4660 if (!(data & IGP3_KMRN_DIAG_PCS_LOCK_LOSS))
4661 return E1000_SUCCESS;
4663 /* Issue PHY reset */
4664 hw->phy.ops.reset(hw);
4667 /* Disable GigE link negotiation */
4668 phy_ctrl = E1000_READ_REG(hw, E1000_PHY_CTRL);
4669 phy_ctrl |= (E1000_PHY_CTRL_GBE_DISABLE |
4670 E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
4671 E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl);
4673 /* Call gig speed drop workaround on Gig disable before accessing
4676 e1000_gig_downshift_workaround_ich8lan(hw);
4678 /* unable to acquire PCS lock */
4679 return -E1000_ERR_PHY;
4683 * e1000_set_kmrn_lock_loss_workaround_ich8lan - Set Kumeran workaround state
4684 * @hw: pointer to the HW structure
4685 * @state: boolean value used to set the current Kumeran workaround state
4687 * If ICH8, set the current Kumeran workaround state (enabled - true
4688 * /disabled - false).
4690 void e1000_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw,
4693 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
4695 DEBUGFUNC("e1000_set_kmrn_lock_loss_workaround_ich8lan");
4697 if (hw->mac.type != e1000_ich8lan) {
4698 DEBUGOUT("Workaround applies to ICH8 only.\n");
4702 dev_spec->kmrn_lock_loss_workaround_enabled = state;
4708 * e1000_ipg3_phy_powerdown_workaround_ich8lan - Power down workaround on D3
4709 * @hw: pointer to the HW structure
4711 * Workaround for 82566 power-down on D3 entry:
4712 * 1) disable gigabit link
4713 * 2) write VR power-down enable
4715 * Continue if successful, else issue LCD reset and repeat
4717 void e1000_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw)
4723 DEBUGFUNC("e1000_igp3_phy_powerdown_workaround_ich8lan");
4725 if (hw->phy.type != e1000_phy_igp_3)
4728 /* Try the workaround twice (if needed) */
4731 reg = E1000_READ_REG(hw, E1000_PHY_CTRL);
4732 reg |= (E1000_PHY_CTRL_GBE_DISABLE |
4733 E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
4734 E1000_WRITE_REG(hw, E1000_PHY_CTRL, reg);
4736 /* Call gig speed drop workaround on Gig disable before
4737 * accessing any PHY registers
4739 if (hw->mac.type == e1000_ich8lan)
4740 e1000_gig_downshift_workaround_ich8lan(hw);
4742 /* Write VR power-down enable */
4743 hw->phy.ops.read_reg(hw, IGP3_VR_CTRL, &data);
4744 data &= ~IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
4745 hw->phy.ops.write_reg(hw, IGP3_VR_CTRL,
4746 data | IGP3_VR_CTRL_MODE_SHUTDOWN);
4748 /* Read it back and test */
4749 hw->phy.ops.read_reg(hw, IGP3_VR_CTRL, &data);
4750 data &= IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
4751 if ((data == IGP3_VR_CTRL_MODE_SHUTDOWN) || retry)
4754 /* Issue PHY reset and repeat at most one more time */
4755 reg = E1000_READ_REG(hw, E1000_CTRL);
4756 E1000_WRITE_REG(hw, E1000_CTRL, reg | E1000_CTRL_PHY_RST);
4762 * e1000_gig_downshift_workaround_ich8lan - WoL from S5 stops working
4763 * @hw: pointer to the HW structure
4765 * Steps to take when dropping from 1Gb/s (eg. link cable removal (LSC),
4766 * LPLU, Gig disable, MDIC PHY reset):
4767 * 1) Set Kumeran Near-end loopback
4768 * 2) Clear Kumeran Near-end loopback
4769 * Should only be called for ICH8[m] devices with any 1G Phy.
4771 void e1000_gig_downshift_workaround_ich8lan(struct e1000_hw *hw)
4776 DEBUGFUNC("e1000_gig_downshift_workaround_ich8lan");
4778 if ((hw->mac.type != e1000_ich8lan) ||
4779 (hw->phy.type == e1000_phy_ife))
4782 ret_val = e1000_read_kmrn_reg_generic(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
4786 reg_data |= E1000_KMRNCTRLSTA_DIAG_NELPBK;
4787 ret_val = e1000_write_kmrn_reg_generic(hw,
4788 E1000_KMRNCTRLSTA_DIAG_OFFSET,
4792 reg_data &= ~E1000_KMRNCTRLSTA_DIAG_NELPBK;
4793 e1000_write_kmrn_reg_generic(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
4798 * e1000_suspend_workarounds_ich8lan - workarounds needed during S0->Sx
4799 * @hw: pointer to the HW structure
4801 * During S0 to Sx transition, it is possible the link remains at gig
4802 * instead of negotiating to a lower speed. Before going to Sx, set
4803 * 'Gig Disable' to force link speed negotiation to a lower speed based on
4804 * the LPLU setting in the NVM or custom setting. For PCH and newer parts,
4805 * the OEM bits PHY register (LED, GbE disable and LPLU configurations) also
4806 * needs to be written.
4807 * Parts that support (and are linked to a partner which support) EEE in
4808 * 100Mbps should disable LPLU since 100Mbps w/ EEE requires less power
4809 * than 10Mbps w/o EEE.
4811 void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw)
4813 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
4817 DEBUGFUNC("e1000_suspend_workarounds_ich8lan");
4819 phy_ctrl = E1000_READ_REG(hw, E1000_PHY_CTRL);
4820 phy_ctrl |= E1000_PHY_CTRL_GBE_DISABLE;
4822 if (hw->phy.type == e1000_phy_i217) {
4823 u16 phy_reg, device_id = hw->device_id;
4825 if ((device_id == E1000_DEV_ID_PCH_LPTLP_I218_LM) ||
4826 (device_id == E1000_DEV_ID_PCH_LPTLP_I218_V) ||
4827 (device_id == E1000_DEV_ID_PCH_I218_LM3) ||
4828 (device_id == E1000_DEV_ID_PCH_I218_V3)) {
4829 u32 fextnvm6 = E1000_READ_REG(hw, E1000_FEXTNVM6);
4831 E1000_WRITE_REG(hw, E1000_FEXTNVM6,
4832 fextnvm6 & ~E1000_FEXTNVM6_REQ_PLL_CLK);
4835 ret_val = hw->phy.ops.acquire(hw);
4839 if (!dev_spec->eee_disable) {
4843 e1000_read_emi_reg_locked(hw,
4844 I217_EEE_ADVERTISEMENT,
4849 /* Disable LPLU if both link partners support 100BaseT
4850 * EEE and 100Full is advertised on both ends of the
4851 * link, and enable Auto Enable LPI since there will
4852 * be no driver to enable LPI while in Sx.
4854 if ((eee_advert & I82579_EEE_100_SUPPORTED) &&
4855 (dev_spec->eee_lp_ability &
4856 I82579_EEE_100_SUPPORTED) &&
4857 (hw->phy.autoneg_advertised & ADVERTISE_100_FULL)) {
4858 phy_ctrl &= ~(E1000_PHY_CTRL_D0A_LPLU |
4859 E1000_PHY_CTRL_NOND0A_LPLU);
4861 /* Set Auto Enable LPI after link up */
4862 hw->phy.ops.read_reg_locked(hw,
4865 phy_reg |= I217_LPI_GPIO_CTRL_AUTO_EN_LPI;
4866 hw->phy.ops.write_reg_locked(hw,
4872 /* For i217 Intel Rapid Start Technology support,
4873 * when the system is going into Sx and no manageability engine
4874 * is present, the driver must configure proxy to reset only on
4875 * power good. LPI (Low Power Idle) state must also reset only
4876 * on power good, as well as the MTA (Multicast table array).
4877 * The SMBus release must also be disabled on LCD reset.
4879 if (!(E1000_READ_REG(hw, E1000_FWSM) &
4880 E1000_ICH_FWSM_FW_VALID)) {
4881 /* Enable proxy to reset only on power good. */
4882 hw->phy.ops.read_reg_locked(hw, I217_PROXY_CTRL,
4884 phy_reg |= I217_PROXY_CTRL_AUTO_DISABLE;
4885 hw->phy.ops.write_reg_locked(hw, I217_PROXY_CTRL,
4888 /* Set bit enable LPI (EEE) to reset only on
4891 hw->phy.ops.read_reg_locked(hw, I217_SxCTRL, &phy_reg);
4892 phy_reg |= I217_SxCTRL_ENABLE_LPI_RESET;
4893 hw->phy.ops.write_reg_locked(hw, I217_SxCTRL, phy_reg);
4895 /* Disable the SMB release on LCD reset. */
4896 hw->phy.ops.read_reg_locked(hw, I217_MEMPWR, &phy_reg);
4897 phy_reg &= ~I217_MEMPWR_DISABLE_SMB_RELEASE;
4898 hw->phy.ops.write_reg_locked(hw, I217_MEMPWR, phy_reg);
4901 /* Enable MTA to reset for Intel Rapid Start Technology
4904 hw->phy.ops.read_reg_locked(hw, I217_CGFREG, &phy_reg);
4905 phy_reg |= I217_CGFREG_ENABLE_MTA_RESET;
4906 hw->phy.ops.write_reg_locked(hw, I217_CGFREG, phy_reg);
4909 hw->phy.ops.release(hw);
4912 E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl);
4914 if (hw->mac.type == e1000_ich8lan)
4915 e1000_gig_downshift_workaround_ich8lan(hw);
4917 if (hw->mac.type >= e1000_pchlan) {
4918 e1000_oem_bits_config_ich8lan(hw, false);
4920 /* Reset PHY to activate OEM bits on 82577/8 */
4921 if (hw->mac.type == e1000_pchlan)
4922 e1000_phy_hw_reset_generic(hw);
4924 ret_val = hw->phy.ops.acquire(hw);
4927 e1000_write_smbus_addr(hw);
4928 hw->phy.ops.release(hw);
4935 * e1000_resume_workarounds_pchlan - workarounds needed during Sx->S0
4936 * @hw: pointer to the HW structure
4938 * During Sx to S0 transitions on non-managed devices or managed devices
4939 * on which PHY resets are not blocked, if the PHY registers cannot be
4940 * accessed properly by the s/w toggle the LANPHYPC value to power cycle
4942 * On i217, setup Intel Rapid Start Technology.
4944 u32 e1000_resume_workarounds_pchlan(struct e1000_hw *hw)
4948 DEBUGFUNC("e1000_resume_workarounds_pchlan");
4949 if (hw->mac.type < e1000_pch2lan)
4950 return E1000_SUCCESS;
4952 ret_val = e1000_init_phy_workarounds_pchlan(hw);
4954 DEBUGOUT1("Failed to init PHY flow ret_val=%d\n", ret_val);
4958 /* For i217 Intel Rapid Start Technology support when the system
4959 * is transitioning from Sx and no manageability engine is present
4960 * configure SMBus to restore on reset, disable proxy, and enable
4961 * the reset on MTA (Multicast table array).
4963 if (hw->phy.type == e1000_phy_i217) {
4966 ret_val = hw->phy.ops.acquire(hw);
4968 DEBUGOUT("Failed to setup iRST\n");
4972 /* Clear Auto Enable LPI after link up */
4973 hw->phy.ops.read_reg_locked(hw, I217_LPI_GPIO_CTRL, &phy_reg);
4974 phy_reg &= ~I217_LPI_GPIO_CTRL_AUTO_EN_LPI;
4975 hw->phy.ops.write_reg_locked(hw, I217_LPI_GPIO_CTRL, phy_reg);
4977 if (!(E1000_READ_REG(hw, E1000_FWSM) &
4978 E1000_ICH_FWSM_FW_VALID)) {
4979 /* Restore clear on SMB if no manageability engine
4982 ret_val = hw->phy.ops.read_reg_locked(hw, I217_MEMPWR,
4986 phy_reg |= I217_MEMPWR_DISABLE_SMB_RELEASE;
4987 hw->phy.ops.write_reg_locked(hw, I217_MEMPWR, phy_reg);
4990 hw->phy.ops.write_reg_locked(hw, I217_PROXY_CTRL, 0);
4992 /* Enable reset on MTA */
4993 ret_val = hw->phy.ops.read_reg_locked(hw, I217_CGFREG,
4997 phy_reg &= ~I217_CGFREG_ENABLE_MTA_RESET;
4998 hw->phy.ops.write_reg_locked(hw, I217_CGFREG, phy_reg);
5001 DEBUGOUT1("Error %d in resume workarounds\n", ret_val);
5002 hw->phy.ops.release(hw);
5005 return E1000_SUCCESS;
5009 * e1000_cleanup_led_ich8lan - Restore the default LED operation
5010 * @hw: pointer to the HW structure
5012 * Return the LED back to the default configuration.
5014 STATIC s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw)
5016 DEBUGFUNC("e1000_cleanup_led_ich8lan");
5018 if (hw->phy.type == e1000_phy_ife)
5019 return hw->phy.ops.write_reg(hw, IFE_PHY_SPECIAL_CONTROL_LED,
5022 E1000_WRITE_REG(hw, E1000_LEDCTL, hw->mac.ledctl_default);
5023 return E1000_SUCCESS;
5027 * e1000_led_on_ich8lan - Turn LEDs on
5028 * @hw: pointer to the HW structure
5032 STATIC s32 e1000_led_on_ich8lan(struct e1000_hw *hw)
5034 DEBUGFUNC("e1000_led_on_ich8lan");
5036 if (hw->phy.type == e1000_phy_ife)
5037 return hw->phy.ops.write_reg(hw, IFE_PHY_SPECIAL_CONTROL_LED,
5038 (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_ON));
5040 E1000_WRITE_REG(hw, E1000_LEDCTL, hw->mac.ledctl_mode2);
5041 return E1000_SUCCESS;
5045 * e1000_led_off_ich8lan - Turn LEDs off
5046 * @hw: pointer to the HW structure
5048 * Turn off the LEDs.
5050 STATIC s32 e1000_led_off_ich8lan(struct e1000_hw *hw)
5052 DEBUGFUNC("e1000_led_off_ich8lan");
5054 if (hw->phy.type == e1000_phy_ife)
5055 return hw->phy.ops.write_reg(hw, IFE_PHY_SPECIAL_CONTROL_LED,
5056 (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_OFF));
5058 E1000_WRITE_REG(hw, E1000_LEDCTL, hw->mac.ledctl_mode1);
5059 return E1000_SUCCESS;
5063 * e1000_setup_led_pchlan - Configures SW controllable LED
5064 * @hw: pointer to the HW structure
5066 * This prepares the SW controllable LED for use.
5068 STATIC s32 e1000_setup_led_pchlan(struct e1000_hw *hw)
5070 DEBUGFUNC("e1000_setup_led_pchlan");
5072 return hw->phy.ops.write_reg(hw, HV_LED_CONFIG,
5073 (u16)hw->mac.ledctl_mode1);
5077 * e1000_cleanup_led_pchlan - Restore the default LED operation
5078 * @hw: pointer to the HW structure
5080 * Return the LED back to the default configuration.
5082 STATIC s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw)
5084 DEBUGFUNC("e1000_cleanup_led_pchlan");
5086 return hw->phy.ops.write_reg(hw, HV_LED_CONFIG,
5087 (u16)hw->mac.ledctl_default);
5091 * e1000_led_on_pchlan - Turn LEDs on
5092 * @hw: pointer to the HW structure
5096 STATIC s32 e1000_led_on_pchlan(struct e1000_hw *hw)
5098 u16 data = (u16)hw->mac.ledctl_mode2;
5101 DEBUGFUNC("e1000_led_on_pchlan");
5103 /* If no link, then turn LED on by setting the invert bit
5104 * for each LED that's mode is "link_up" in ledctl_mode2.
5106 if (!(E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU)) {
5107 for (i = 0; i < 3; i++) {
5108 led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
5109 if ((led & E1000_PHY_LED0_MODE_MASK) !=
5110 E1000_LEDCTL_MODE_LINK_UP)
5112 if (led & E1000_PHY_LED0_IVRT)
5113 data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
5115 data |= (E1000_PHY_LED0_IVRT << (i * 5));
5119 return hw->phy.ops.write_reg(hw, HV_LED_CONFIG, data);
5123 * e1000_led_off_pchlan - Turn LEDs off
5124 * @hw: pointer to the HW structure
5126 * Turn off the LEDs.
5128 STATIC s32 e1000_led_off_pchlan(struct e1000_hw *hw)
5130 u16 data = (u16)hw->mac.ledctl_mode1;
5133 DEBUGFUNC("e1000_led_off_pchlan");
5135 /* If no link, then turn LED off by clearing the invert bit
5136 * for each LED that's mode is "link_up" in ledctl_mode1.
5138 if (!(E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU)) {
5139 for (i = 0; i < 3; i++) {
5140 led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
5141 if ((led & E1000_PHY_LED0_MODE_MASK) !=
5142 E1000_LEDCTL_MODE_LINK_UP)
5144 if (led & E1000_PHY_LED0_IVRT)
5145 data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
5147 data |= (E1000_PHY_LED0_IVRT << (i * 5));
5151 return hw->phy.ops.write_reg(hw, HV_LED_CONFIG, data);
5155 * e1000_get_cfg_done_ich8lan - Read config done bit after Full or PHY reset
5156 * @hw: pointer to the HW structure
5158 * Read appropriate register for the config done bit for completion status
5159 * and configure the PHY through s/w for EEPROM-less parts.
5161 * NOTE: some silicon which is EEPROM-less will fail trying to read the
5162 * config done bit, so only an error is logged and continues. If we were
5163 * to return with error, EEPROM-less silicon would not be able to be reset
5166 STATIC s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw)
5168 s32 ret_val = E1000_SUCCESS;
5172 DEBUGFUNC("e1000_get_cfg_done_ich8lan");
5174 e1000_get_cfg_done_generic(hw);
5176 /* Wait for indication from h/w that it has completed basic config */
5177 if (hw->mac.type >= e1000_ich10lan) {
5178 e1000_lan_init_done_ich8lan(hw);
5180 ret_val = e1000_get_auto_rd_done_generic(hw);
5182 /* When auto config read does not complete, do not
5183 * return with an error. This can happen in situations
5184 * where there is no eeprom and prevents getting link.
5186 DEBUGOUT("Auto Read Done did not complete\n");
5187 ret_val = E1000_SUCCESS;
5191 /* Clear PHY Reset Asserted bit */
5192 status = E1000_READ_REG(hw, E1000_STATUS);
5193 if (status & E1000_STATUS_PHYRA)
5194 E1000_WRITE_REG(hw, E1000_STATUS, status & ~E1000_STATUS_PHYRA);
5196 DEBUGOUT("PHY Reset Asserted not set - needs delay\n");
5198 /* If EEPROM is not marked present, init the IGP 3 PHY manually */
5199 if (hw->mac.type <= e1000_ich9lan) {
5200 if (!(E1000_READ_REG(hw, E1000_EECD) & E1000_EECD_PRES) &&
5201 (hw->phy.type == e1000_phy_igp_3)) {
5202 e1000_phy_init_script_igp3(hw);
5205 if (e1000_valid_nvm_bank_detect_ich8lan(hw, &bank)) {
5206 /* Maybe we should do a basic PHY config */
5207 DEBUGOUT("EEPROM not present\n");
5208 ret_val = -E1000_ERR_CONFIG;
5216 * e1000_power_down_phy_copper_ich8lan - Remove link during PHY power down
5217 * @hw: pointer to the HW structure
5219 * In the case of a PHY power down to save power, or to turn off link during a
5220 * driver unload, or wake on lan is not enabled, remove the link.
5222 STATIC void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw)
5224 /* If the management interface is not enabled, then power down */
5225 if (!(hw->mac.ops.check_mng_mode(hw) ||
5226 hw->phy.ops.check_reset_block(hw)))
5227 e1000_power_down_phy_copper(hw);
5233 * e1000_clear_hw_cntrs_ich8lan - Clear statistical counters
5234 * @hw: pointer to the HW structure
5236 * Clears hardware counters specific to the silicon family and calls
5237 * clear_hw_cntrs_generic to clear all general purpose counters.
5239 STATIC void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw)
5244 DEBUGFUNC("e1000_clear_hw_cntrs_ich8lan");
5246 e1000_clear_hw_cntrs_base_generic(hw);
5248 E1000_READ_REG(hw, E1000_ALGNERRC);
5249 E1000_READ_REG(hw, E1000_RXERRC);
5250 E1000_READ_REG(hw, E1000_TNCRS);
5251 E1000_READ_REG(hw, E1000_CEXTERR);
5252 E1000_READ_REG(hw, E1000_TSCTC);
5253 E1000_READ_REG(hw, E1000_TSCTFC);
5255 E1000_READ_REG(hw, E1000_MGTPRC);
5256 E1000_READ_REG(hw, E1000_MGTPDC);
5257 E1000_READ_REG(hw, E1000_MGTPTC);
5259 E1000_READ_REG(hw, E1000_IAC);
5260 E1000_READ_REG(hw, E1000_ICRXOC);
5262 /* Clear PHY statistics registers */
5263 if ((hw->phy.type == e1000_phy_82578) ||
5264 (hw->phy.type == e1000_phy_82579) ||
5265 (hw->phy.type == e1000_phy_i217) ||
5266 (hw->phy.type == e1000_phy_82577)) {
5267 ret_val = hw->phy.ops.acquire(hw);
5270 ret_val = hw->phy.ops.set_page(hw,
5271 HV_STATS_PAGE << IGP_PAGE_SHIFT);
5274 hw->phy.ops.read_reg_page(hw, HV_SCC_UPPER, &phy_data);
5275 hw->phy.ops.read_reg_page(hw, HV_SCC_LOWER, &phy_data);
5276 hw->phy.ops.read_reg_page(hw, HV_ECOL_UPPER, &phy_data);
5277 hw->phy.ops.read_reg_page(hw, HV_ECOL_LOWER, &phy_data);
5278 hw->phy.ops.read_reg_page(hw, HV_MCC_UPPER, &phy_data);
5279 hw->phy.ops.read_reg_page(hw, HV_MCC_LOWER, &phy_data);
5280 hw->phy.ops.read_reg_page(hw, HV_LATECOL_UPPER, &phy_data);
5281 hw->phy.ops.read_reg_page(hw, HV_LATECOL_LOWER, &phy_data);
5282 hw->phy.ops.read_reg_page(hw, HV_COLC_UPPER, &phy_data);
5283 hw->phy.ops.read_reg_page(hw, HV_COLC_LOWER, &phy_data);
5284 hw->phy.ops.read_reg_page(hw, HV_DC_UPPER, &phy_data);
5285 hw->phy.ops.read_reg_page(hw, HV_DC_LOWER, &phy_data);
5286 hw->phy.ops.read_reg_page(hw, HV_TNCRS_UPPER, &phy_data);
5287 hw->phy.ops.read_reg_page(hw, HV_TNCRS_LOWER, &phy_data);
5289 hw->phy.ops.release(hw);