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 /* Only unforce SMBus if ME is not active */
238 if (!(E1000_READ_REG(hw, E1000_FWSM) &
239 E1000_ICH_FWSM_FW_VALID)) {
240 /* Unforce SMBus mode in PHY */
241 hw->phy.ops.read_reg_locked(hw, CV_SMB_CTRL, &phy_reg);
242 phy_reg &= ~CV_SMB_CTRL_FORCE_SMBUS;
243 hw->phy.ops.write_reg_locked(hw, CV_SMB_CTRL, phy_reg);
245 /* Unforce SMBus mode in MAC */
246 mac_reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
247 mac_reg &= ~E1000_CTRL_EXT_FORCE_SMBUS;
248 E1000_WRITE_REG(hw, E1000_CTRL_EXT, mac_reg);
256 * e1000_toggle_lanphypc_pch_lpt - toggle the LANPHYPC pin value
257 * @hw: pointer to the HW structure
259 * Toggling the LANPHYPC pin value fully power-cycles the PHY and is
260 * used to reset the PHY to a quiescent state when necessary.
262 STATIC void e1000_toggle_lanphypc_pch_lpt(struct e1000_hw *hw)
266 DEBUGFUNC("e1000_toggle_lanphypc_pch_lpt");
268 /* Set Phy Config Counter to 50msec */
269 mac_reg = E1000_READ_REG(hw, E1000_FEXTNVM3);
270 mac_reg &= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK;
271 mac_reg |= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC;
272 E1000_WRITE_REG(hw, E1000_FEXTNVM3, mac_reg);
274 /* Toggle LANPHYPC Value bit */
275 mac_reg = E1000_READ_REG(hw, E1000_CTRL);
276 mac_reg |= E1000_CTRL_LANPHYPC_OVERRIDE;
277 mac_reg &= ~E1000_CTRL_LANPHYPC_VALUE;
278 E1000_WRITE_REG(hw, E1000_CTRL, mac_reg);
279 E1000_WRITE_FLUSH(hw);
281 mac_reg &= ~E1000_CTRL_LANPHYPC_OVERRIDE;
282 E1000_WRITE_REG(hw, E1000_CTRL, mac_reg);
283 E1000_WRITE_FLUSH(hw);
285 if (hw->mac.type < e1000_pch_lpt) {
292 } while (!(E1000_READ_REG(hw, E1000_CTRL_EXT) &
293 E1000_CTRL_EXT_LPCD) && count--);
300 * e1000_init_phy_workarounds_pchlan - PHY initialization workarounds
301 * @hw: pointer to the HW structure
303 * Workarounds/flow necessary for PHY initialization during driver load
306 STATIC s32 e1000_init_phy_workarounds_pchlan(struct e1000_hw *hw)
308 u32 mac_reg, fwsm = E1000_READ_REG(hw, E1000_FWSM);
311 DEBUGFUNC("e1000_init_phy_workarounds_pchlan");
313 /* Gate automatic PHY configuration by hardware on managed and
314 * non-managed 82579 and newer adapters.
316 e1000_gate_hw_phy_config_ich8lan(hw, true);
319 /* It is not possible to be certain of the current state of ULP
320 * so forcibly disable it.
322 hw->dev_spec.ich8lan.ulp_state = e1000_ulp_state_unknown;
324 #endif /* ULP_SUPPORT */
325 ret_val = hw->phy.ops.acquire(hw);
327 DEBUGOUT("Failed to initialize PHY flow\n");
331 /* The MAC-PHY interconnect may be in SMBus mode. If the PHY is
332 * inaccessible and resetting the PHY is not blocked, toggle the
333 * LANPHYPC Value bit to force the interconnect to PCIe mode.
335 switch (hw->mac.type) {
337 if (e1000_phy_is_accessible_pchlan(hw))
340 /* Before toggling LANPHYPC, see if PHY is accessible by
341 * forcing MAC to SMBus mode first.
343 mac_reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
344 mac_reg |= E1000_CTRL_EXT_FORCE_SMBUS;
345 E1000_WRITE_REG(hw, E1000_CTRL_EXT, mac_reg);
347 /* Wait 50 milliseconds for MAC to finish any retries
348 * that it might be trying to perform from previous
349 * attempts to acknowledge any phy read requests.
355 if (e1000_phy_is_accessible_pchlan(hw))
360 if ((hw->mac.type == e1000_pchlan) &&
361 (fwsm & E1000_ICH_FWSM_FW_VALID))
364 if (hw->phy.ops.check_reset_block(hw)) {
365 DEBUGOUT("Required LANPHYPC toggle blocked by ME\n");
366 ret_val = -E1000_ERR_PHY;
370 /* Toggle LANPHYPC Value bit */
371 e1000_toggle_lanphypc_pch_lpt(hw);
372 if (hw->mac.type >= e1000_pch_lpt) {
373 if (e1000_phy_is_accessible_pchlan(hw))
376 /* Toggling LANPHYPC brings the PHY out of SMBus mode
377 * so ensure that the MAC is also out of SMBus mode
379 mac_reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
380 mac_reg &= ~E1000_CTRL_EXT_FORCE_SMBUS;
381 E1000_WRITE_REG(hw, E1000_CTRL_EXT, mac_reg);
383 if (e1000_phy_is_accessible_pchlan(hw))
386 ret_val = -E1000_ERR_PHY;
393 hw->phy.ops.release(hw);
396 /* Check to see if able to reset PHY. Print error if not */
397 if (hw->phy.ops.check_reset_block(hw)) {
398 ERROR_REPORT("Reset blocked by ME\n");
402 /* Reset the PHY before any access to it. Doing so, ensures
403 * that the PHY is in a known good state before we read/write
404 * PHY registers. The generic reset is sufficient here,
405 * because we haven't determined the PHY type yet.
407 ret_val = e1000_phy_hw_reset_generic(hw);
411 /* On a successful reset, possibly need to wait for the PHY
412 * to quiesce to an accessible state before returning control
413 * to the calling function. If the PHY does not quiesce, then
414 * return E1000E_BLK_PHY_RESET, as this is the condition that
417 ret_val = hw->phy.ops.check_reset_block(hw);
419 ERROR_REPORT("ME blocked access to PHY after reset\n");
423 /* Ungate automatic PHY configuration on non-managed 82579 */
424 if ((hw->mac.type == e1000_pch2lan) &&
425 !(fwsm & E1000_ICH_FWSM_FW_VALID)) {
427 e1000_gate_hw_phy_config_ich8lan(hw, false);
434 * e1000_init_phy_params_pchlan - Initialize PHY function pointers
435 * @hw: pointer to the HW structure
437 * Initialize family-specific PHY parameters and function pointers.
439 STATIC s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw)
441 struct e1000_phy_info *phy = &hw->phy;
444 DEBUGFUNC("e1000_init_phy_params_pchlan");
447 phy->reset_delay_us = 100;
449 phy->ops.acquire = e1000_acquire_swflag_ich8lan;
450 phy->ops.check_reset_block = e1000_check_reset_block_ich8lan;
451 phy->ops.get_cfg_done = e1000_get_cfg_done_ich8lan;
452 phy->ops.set_page = e1000_set_page_igp;
453 phy->ops.read_reg = e1000_read_phy_reg_hv;
454 phy->ops.read_reg_locked = e1000_read_phy_reg_hv_locked;
455 phy->ops.read_reg_page = e1000_read_phy_reg_page_hv;
456 phy->ops.release = e1000_release_swflag_ich8lan;
457 phy->ops.reset = e1000_phy_hw_reset_ich8lan;
458 phy->ops.set_d0_lplu_state = e1000_set_lplu_state_pchlan;
459 phy->ops.set_d3_lplu_state = e1000_set_lplu_state_pchlan;
460 phy->ops.write_reg = e1000_write_phy_reg_hv;
461 phy->ops.write_reg_locked = e1000_write_phy_reg_hv_locked;
462 phy->ops.write_reg_page = e1000_write_phy_reg_page_hv;
463 phy->ops.power_up = e1000_power_up_phy_copper;
464 phy->ops.power_down = e1000_power_down_phy_copper_ich8lan;
465 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
467 phy->id = e1000_phy_unknown;
469 ret_val = e1000_init_phy_workarounds_pchlan(hw);
473 if (phy->id == e1000_phy_unknown)
474 switch (hw->mac.type) {
476 ret_val = e1000_get_phy_id(hw);
479 if ((phy->id != 0) && (phy->id != PHY_REVISION_MASK))
484 /* In case the PHY needs to be in mdio slow mode,
485 * set slow mode and try to get the PHY id again.
487 ret_val = e1000_set_mdio_slow_mode_hv(hw);
490 ret_val = e1000_get_phy_id(hw);
495 phy->type = e1000_get_phy_type_from_id(phy->id);
498 case e1000_phy_82577:
499 case e1000_phy_82579:
501 phy->ops.check_polarity = e1000_check_polarity_82577;
502 phy->ops.force_speed_duplex =
503 e1000_phy_force_speed_duplex_82577;
504 phy->ops.get_cable_length = e1000_get_cable_length_82577;
505 phy->ops.get_info = e1000_get_phy_info_82577;
506 phy->ops.commit = e1000_phy_sw_reset_generic;
508 case e1000_phy_82578:
509 phy->ops.check_polarity = e1000_check_polarity_m88;
510 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_m88;
511 phy->ops.get_cable_length = e1000_get_cable_length_m88;
512 phy->ops.get_info = e1000_get_phy_info_m88;
515 ret_val = -E1000_ERR_PHY;
523 * e1000_init_phy_params_ich8lan - Initialize PHY function pointers
524 * @hw: pointer to the HW structure
526 * Initialize family-specific PHY parameters and function pointers.
528 STATIC s32 e1000_init_phy_params_ich8lan(struct e1000_hw *hw)
530 struct e1000_phy_info *phy = &hw->phy;
534 DEBUGFUNC("e1000_init_phy_params_ich8lan");
537 phy->reset_delay_us = 100;
539 phy->ops.acquire = e1000_acquire_swflag_ich8lan;
540 phy->ops.check_reset_block = e1000_check_reset_block_ich8lan;
541 phy->ops.get_cable_length = e1000_get_cable_length_igp_2;
542 phy->ops.get_cfg_done = e1000_get_cfg_done_ich8lan;
543 phy->ops.read_reg = e1000_read_phy_reg_igp;
544 phy->ops.release = e1000_release_swflag_ich8lan;
545 phy->ops.reset = e1000_phy_hw_reset_ich8lan;
546 phy->ops.set_d0_lplu_state = e1000_set_d0_lplu_state_ich8lan;
547 phy->ops.set_d3_lplu_state = e1000_set_d3_lplu_state_ich8lan;
548 phy->ops.write_reg = e1000_write_phy_reg_igp;
549 phy->ops.power_up = e1000_power_up_phy_copper;
550 phy->ops.power_down = e1000_power_down_phy_copper_ich8lan;
552 /* We may need to do this twice - once for IGP and if that fails,
553 * we'll set BM func pointers and try again
555 ret_val = e1000_determine_phy_address(hw);
557 phy->ops.write_reg = e1000_write_phy_reg_bm;
558 phy->ops.read_reg = e1000_read_phy_reg_bm;
559 ret_val = e1000_determine_phy_address(hw);
561 DEBUGOUT("Cannot determine PHY addr. Erroring out\n");
567 while ((e1000_phy_unknown == e1000_get_phy_type_from_id(phy->id)) &&
570 ret_val = e1000_get_phy_id(hw);
577 case IGP03E1000_E_PHY_ID:
578 phy->type = e1000_phy_igp_3;
579 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
580 phy->ops.read_reg_locked = e1000_read_phy_reg_igp_locked;
581 phy->ops.write_reg_locked = e1000_write_phy_reg_igp_locked;
582 phy->ops.get_info = e1000_get_phy_info_igp;
583 phy->ops.check_polarity = e1000_check_polarity_igp;
584 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_igp;
587 case IFE_PLUS_E_PHY_ID:
589 phy->type = e1000_phy_ife;
590 phy->autoneg_mask = E1000_ALL_NOT_GIG;
591 phy->ops.get_info = e1000_get_phy_info_ife;
592 phy->ops.check_polarity = e1000_check_polarity_ife;
593 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_ife;
595 case BME1000_E_PHY_ID:
596 phy->type = e1000_phy_bm;
597 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
598 phy->ops.read_reg = e1000_read_phy_reg_bm;
599 phy->ops.write_reg = e1000_write_phy_reg_bm;
600 phy->ops.commit = e1000_phy_sw_reset_generic;
601 phy->ops.get_info = e1000_get_phy_info_m88;
602 phy->ops.check_polarity = e1000_check_polarity_m88;
603 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_m88;
606 return -E1000_ERR_PHY;
610 return E1000_SUCCESS;
614 * e1000_init_nvm_params_ich8lan - Initialize NVM function pointers
615 * @hw: pointer to the HW structure
617 * Initialize family-specific NVM parameters and function
620 STATIC s32 e1000_init_nvm_params_ich8lan(struct e1000_hw *hw)
622 struct e1000_nvm_info *nvm = &hw->nvm;
623 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
624 u32 gfpreg, sector_base_addr, sector_end_addr;
627 DEBUGFUNC("e1000_init_nvm_params_ich8lan");
629 /* Can't read flash registers if the register set isn't mapped. */
630 nvm->type = e1000_nvm_flash_sw;
631 if (!hw->flash_address) {
632 DEBUGOUT("ERROR: Flash registers not mapped\n");
633 return -E1000_ERR_CONFIG;
636 gfpreg = E1000_READ_FLASH_REG(hw, ICH_FLASH_GFPREG);
638 /* sector_X_addr is a "sector"-aligned address (4096 bytes)
639 * Add 1 to sector_end_addr since this sector is included in
642 sector_base_addr = gfpreg & FLASH_GFPREG_BASE_MASK;
643 sector_end_addr = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK) + 1;
645 /* flash_base_addr is byte-aligned */
646 nvm->flash_base_addr = sector_base_addr << FLASH_SECTOR_ADDR_SHIFT;
648 /* find total size of the NVM, then cut in half since the total
649 * size represents two separate NVM banks.
651 nvm->flash_bank_size = ((sector_end_addr - sector_base_addr)
652 << FLASH_SECTOR_ADDR_SHIFT);
653 nvm->flash_bank_size /= 2;
654 /* Adjust to word count */
655 nvm->flash_bank_size /= sizeof(u16);
657 nvm->word_size = E1000_SHADOW_RAM_WORDS;
659 /* Clear shadow ram */
660 for (i = 0; i < nvm->word_size; i++) {
661 dev_spec->shadow_ram[i].modified = false;
662 dev_spec->shadow_ram[i].value = 0xFFFF;
665 E1000_MUTEX_INIT(&dev_spec->nvm_mutex);
666 E1000_MUTEX_INIT(&dev_spec->swflag_mutex);
668 /* Function Pointers */
669 nvm->ops.acquire = e1000_acquire_nvm_ich8lan;
670 nvm->ops.release = e1000_release_nvm_ich8lan;
671 nvm->ops.read = e1000_read_nvm_ich8lan;
672 nvm->ops.update = e1000_update_nvm_checksum_ich8lan;
673 nvm->ops.valid_led_default = e1000_valid_led_default_ich8lan;
674 nvm->ops.validate = e1000_validate_nvm_checksum_ich8lan;
675 nvm->ops.write = e1000_write_nvm_ich8lan;
677 return E1000_SUCCESS;
681 * e1000_init_mac_params_ich8lan - Initialize MAC function pointers
682 * @hw: pointer to the HW structure
684 * Initialize family-specific MAC parameters and function
687 STATIC s32 e1000_init_mac_params_ich8lan(struct e1000_hw *hw)
689 struct e1000_mac_info *mac = &hw->mac;
690 #if defined(QV_RELEASE) || !defined(NO_PCH_LPT_B0_SUPPORT)
692 #endif /* QV_RELEASE || !defined(NO_PCH_LPT_B0_SUPPORT) */
694 DEBUGFUNC("e1000_init_mac_params_ich8lan");
696 /* Set media type function pointer */
697 hw->phy.media_type = e1000_media_type_copper;
699 /* Set mta register count */
700 mac->mta_reg_count = 32;
701 /* Set rar entry count */
702 mac->rar_entry_count = E1000_ICH_RAR_ENTRIES;
703 if (mac->type == e1000_ich8lan)
704 mac->rar_entry_count--;
705 /* Set if part includes ASF firmware */
706 mac->asf_firmware_present = true;
708 mac->has_fwsm = true;
709 /* ARC subsystem not supported */
710 mac->arc_subsystem_valid = false;
711 /* Adaptive IFS supported */
712 mac->adaptive_ifs = true;
714 /* Function pointers */
716 /* bus type/speed/width */
717 mac->ops.get_bus_info = e1000_get_bus_info_ich8lan;
719 mac->ops.set_lan_id = e1000_set_lan_id_single_port;
721 mac->ops.reset_hw = e1000_reset_hw_ich8lan;
722 /* hw initialization */
723 mac->ops.init_hw = e1000_init_hw_ich8lan;
725 mac->ops.setup_link = e1000_setup_link_ich8lan;
726 /* physical interface setup */
727 mac->ops.setup_physical_interface = e1000_setup_copper_link_ich8lan;
729 mac->ops.check_for_link = e1000_check_for_copper_link_ich8lan;
731 mac->ops.get_link_up_info = e1000_get_link_up_info_ich8lan;
732 /* multicast address update */
733 mac->ops.update_mc_addr_list = e1000_update_mc_addr_list_generic;
734 /* clear hardware counters */
735 mac->ops.clear_hw_cntrs = e1000_clear_hw_cntrs_ich8lan;
737 /* LED and other operations */
742 /* check management mode */
743 mac->ops.check_mng_mode = e1000_check_mng_mode_ich8lan;
745 mac->ops.id_led_init = e1000_id_led_init_generic;
747 mac->ops.blink_led = e1000_blink_led_generic;
749 mac->ops.setup_led = e1000_setup_led_generic;
751 mac->ops.cleanup_led = e1000_cleanup_led_ich8lan;
752 /* turn on/off LED */
753 mac->ops.led_on = e1000_led_on_ich8lan;
754 mac->ops.led_off = e1000_led_off_ich8lan;
757 mac->rar_entry_count = E1000_PCH2_RAR_ENTRIES;
758 mac->ops.rar_set = e1000_rar_set_pch2lan;
761 #ifndef NO_NON_BLOCKING_PHY_MTA_UPDATE_SUPPORT
762 /* multicast address update for pch2 */
763 mac->ops.update_mc_addr_list =
764 e1000_update_mc_addr_list_pch2lan;
768 #if defined(QV_RELEASE) || !defined(NO_PCH_LPT_B0_SUPPORT)
769 /* save PCH revision_id */
770 e1000_read_pci_cfg(hw, E1000_PCI_REVISION_ID_REG, &pci_cfg);
771 hw->revision_id = (u8)(pci_cfg &= 0x000F);
772 #endif /* QV_RELEASE || !defined(NO_PCH_LPT_B0_SUPPORT) */
773 /* check management mode */
774 mac->ops.check_mng_mode = e1000_check_mng_mode_pchlan;
776 mac->ops.id_led_init = e1000_id_led_init_pchlan;
778 mac->ops.setup_led = e1000_setup_led_pchlan;
780 mac->ops.cleanup_led = e1000_cleanup_led_pchlan;
781 /* turn on/off LED */
782 mac->ops.led_on = e1000_led_on_pchlan;
783 mac->ops.led_off = e1000_led_off_pchlan;
789 if (mac->type == e1000_pch_lpt) {
790 mac->rar_entry_count = E1000_PCH_LPT_RAR_ENTRIES;
791 mac->ops.rar_set = e1000_rar_set_pch_lpt;
792 mac->ops.setup_physical_interface = e1000_setup_copper_link_pch_lpt;
795 /* Enable PCS Lock-loss workaround for ICH8 */
796 if (mac->type == e1000_ich8lan)
797 e1000_set_kmrn_lock_loss_workaround_ich8lan(hw, true);
799 return E1000_SUCCESS;
803 * __e1000_access_emi_reg_locked - Read/write EMI register
804 * @hw: pointer to the HW structure
805 * @addr: EMI address to program
806 * @data: pointer to value to read/write from/to the EMI address
807 * @read: boolean flag to indicate read or write
809 * This helper function assumes the SW/FW/HW Semaphore is already acquired.
811 STATIC s32 __e1000_access_emi_reg_locked(struct e1000_hw *hw, u16 address,
812 u16 *data, bool read)
816 DEBUGFUNC("__e1000_access_emi_reg_locked");
818 ret_val = hw->phy.ops.write_reg_locked(hw, I82579_EMI_ADDR, address);
823 ret_val = hw->phy.ops.read_reg_locked(hw, I82579_EMI_DATA,
826 ret_val = hw->phy.ops.write_reg_locked(hw, I82579_EMI_DATA,
833 * e1000_read_emi_reg_locked - Read Extended Management Interface register
834 * @hw: pointer to the HW structure
835 * @addr: EMI address to program
836 * @data: value to be read from the EMI address
838 * Assumes the SW/FW/HW Semaphore is already acquired.
840 s32 e1000_read_emi_reg_locked(struct e1000_hw *hw, u16 addr, u16 *data)
842 DEBUGFUNC("e1000_read_emi_reg_locked");
844 return __e1000_access_emi_reg_locked(hw, addr, data, true);
848 * e1000_write_emi_reg_locked - Write Extended Management Interface register
849 * @hw: pointer to the HW structure
850 * @addr: EMI address to program
851 * @data: value to be written to the EMI address
853 * Assumes the SW/FW/HW Semaphore is already acquired.
855 s32 e1000_write_emi_reg_locked(struct e1000_hw *hw, u16 addr, u16 data)
857 DEBUGFUNC("e1000_read_emi_reg_locked");
859 return __e1000_access_emi_reg_locked(hw, addr, &data, false);
863 * e1000_set_eee_pchlan - Enable/disable EEE support
864 * @hw: pointer to the HW structure
866 * Enable/disable EEE based on setting in dev_spec structure, the duplex of
867 * the link and the EEE capabilities of the link partner. The LPI Control
868 * register bits will remain set only if/when link is up.
870 * EEE LPI must not be asserted earlier than one second after link is up.
871 * On 82579, EEE LPI should not be enabled until such time otherwise there
872 * can be link issues with some switches. Other devices can have EEE LPI
873 * enabled immediately upon link up since they have a timer in hardware which
874 * prevents LPI from being asserted too early.
876 s32 e1000_set_eee_pchlan(struct e1000_hw *hw)
878 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
880 u16 lpa, pcs_status, adv, adv_addr, lpi_ctrl, data;
882 DEBUGFUNC("e1000_set_eee_pchlan");
884 switch (hw->phy.type) {
885 case e1000_phy_82579:
886 lpa = I82579_EEE_LP_ABILITY;
887 pcs_status = I82579_EEE_PCS_STATUS;
888 adv_addr = I82579_EEE_ADVERTISEMENT;
891 lpa = I217_EEE_LP_ABILITY;
892 pcs_status = I217_EEE_PCS_STATUS;
893 adv_addr = I217_EEE_ADVERTISEMENT;
896 return E1000_SUCCESS;
899 ret_val = hw->phy.ops.acquire(hw);
903 ret_val = hw->phy.ops.read_reg_locked(hw, I82579_LPI_CTRL, &lpi_ctrl);
907 /* Clear bits that enable EEE in various speeds */
908 lpi_ctrl &= ~I82579_LPI_CTRL_ENABLE_MASK;
910 /* Enable EEE if not disabled by user */
911 if (!dev_spec->eee_disable) {
912 /* Save off link partner's EEE ability */
913 ret_val = e1000_read_emi_reg_locked(hw, lpa,
914 &dev_spec->eee_lp_ability);
918 /* Read EEE advertisement */
919 ret_val = e1000_read_emi_reg_locked(hw, adv_addr, &adv);
923 /* Enable EEE only for speeds in which the link partner is
924 * EEE capable and for which we advertise EEE.
926 if (adv & dev_spec->eee_lp_ability & I82579_EEE_1000_SUPPORTED)
927 lpi_ctrl |= I82579_LPI_CTRL_1000_ENABLE;
929 if (adv & dev_spec->eee_lp_ability & I82579_EEE_100_SUPPORTED) {
930 hw->phy.ops.read_reg_locked(hw, PHY_LP_ABILITY, &data);
931 if (data & NWAY_LPAR_100TX_FD_CAPS)
932 lpi_ctrl |= I82579_LPI_CTRL_100_ENABLE;
934 /* EEE is not supported in 100Half, so ignore
935 * partner's EEE in 100 ability if full-duplex
938 dev_spec->eee_lp_ability &=
939 ~I82579_EEE_100_SUPPORTED;
943 if (hw->phy.type == e1000_phy_82579) {
944 ret_val = e1000_read_emi_reg_locked(hw, I82579_LPI_PLL_SHUT,
949 data &= ~I82579_LPI_100_PLL_SHUT;
950 ret_val = e1000_write_emi_reg_locked(hw, I82579_LPI_PLL_SHUT,
954 /* R/Clr IEEE MMD 3.1 bits 11:10 - Tx/Rx LPI Received */
955 ret_val = e1000_read_emi_reg_locked(hw, pcs_status, &data);
959 ret_val = hw->phy.ops.write_reg_locked(hw, I82579_LPI_CTRL, lpi_ctrl);
961 hw->phy.ops.release(hw);
967 * e1000_k1_workaround_lpt_lp - K1 workaround on Lynxpoint-LP
968 * @hw: pointer to the HW structure
969 * @link: link up bool flag
971 * When K1 is enabled for 1Gbps, the MAC can miss 2 DMA completion indications
972 * preventing further DMA write requests. Workaround the issue by disabling
973 * the de-assertion of the clock request when in 1Gpbs mode.
974 * Also, set appropriate Tx re-transmission timeouts for 10 and 100Half link
975 * speeds in order to avoid Tx hangs.
977 STATIC s32 e1000_k1_workaround_lpt_lp(struct e1000_hw *hw, bool link)
979 u32 fextnvm6 = E1000_READ_REG(hw, E1000_FEXTNVM6);
980 u32 status = E1000_READ_REG(hw, E1000_STATUS);
981 s32 ret_val = E1000_SUCCESS;
984 if (link && (status & E1000_STATUS_SPEED_1000)) {
985 ret_val = hw->phy.ops.acquire(hw);
990 e1000_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
996 e1000_write_kmrn_reg_locked(hw,
997 E1000_KMRNCTRLSTA_K1_CONFIG,
999 ~E1000_KMRNCTRLSTA_K1_ENABLE);
1005 E1000_WRITE_REG(hw, E1000_FEXTNVM6,
1006 fextnvm6 | E1000_FEXTNVM6_REQ_PLL_CLK);
1009 e1000_write_kmrn_reg_locked(hw,
1010 E1000_KMRNCTRLSTA_K1_CONFIG,
1013 hw->phy.ops.release(hw);
1015 /* clear FEXTNVM6 bit 8 on link down or 10/100 */
1016 fextnvm6 &= ~E1000_FEXTNVM6_REQ_PLL_CLK;
1018 if (!link || ((status & E1000_STATUS_SPEED_100) &&
1019 (status & E1000_STATUS_FD)))
1020 goto update_fextnvm6;
1022 ret_val = hw->phy.ops.read_reg(hw, I217_INBAND_CTRL, ®);
1026 /* Clear link status transmit timeout */
1027 reg &= ~I217_INBAND_CTRL_LINK_STAT_TX_TIMEOUT_MASK;
1029 if (status & E1000_STATUS_SPEED_100) {
1030 /* Set inband Tx timeout to 5x10us for 100Half */
1031 reg |= 5 << I217_INBAND_CTRL_LINK_STAT_TX_TIMEOUT_SHIFT;
1033 /* Do not extend the K1 entry latency for 100Half */
1034 fextnvm6 &= ~E1000_FEXTNVM6_ENABLE_K1_ENTRY_CONDITION;
1036 /* Set inband Tx timeout to 50x10us for 10Full/Half */
1038 I217_INBAND_CTRL_LINK_STAT_TX_TIMEOUT_SHIFT;
1040 /* Extend the K1 entry latency for 10 Mbps */
1041 fextnvm6 |= E1000_FEXTNVM6_ENABLE_K1_ENTRY_CONDITION;
1044 ret_val = hw->phy.ops.write_reg(hw, I217_INBAND_CTRL, reg);
1049 E1000_WRITE_REG(hw, E1000_FEXTNVM6, fextnvm6);
1057 * e1000_enable_ulp_lpt_lp - configure Ultra Low Power mode for LynxPoint-LP
1058 * @hw: pointer to the HW structure
1059 * @to_sx: boolean indicating a system power state transition to Sx
1061 * When link is down, configure ULP mode to significantly reduce the power
1062 * to the PHY. If on a Manageability Engine (ME) enabled system, tell the
1063 * ME firmware to start the ULP configuration. If not on an ME enabled
1064 * system, configure the ULP mode by software.
1066 s32 e1000_enable_ulp_lpt_lp(struct e1000_hw *hw, bool to_sx)
1069 s32 ret_val = E1000_SUCCESS;
1073 if ((hw->mac.type < e1000_pch_lpt) ||
1074 (hw->device_id == E1000_DEV_ID_PCH_LPT_I217_LM) ||
1075 (hw->device_id == E1000_DEV_ID_PCH_LPT_I217_V) ||
1076 (hw->device_id == E1000_DEV_ID_PCH_I218_LM2) ||
1077 (hw->device_id == E1000_DEV_ID_PCH_I218_V2) ||
1078 (hw->dev_spec.ich8lan.ulp_state == e1000_ulp_state_on))
1083 /* Poll up to 5 seconds for Cable Disconnected indication */
1084 while (!(E1000_READ_REG(hw, E1000_FEXT) &
1085 E1000_FEXT_PHY_CABLE_DISCONNECTED)) {
1086 /* Bail if link is re-acquired */
1087 if (E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU)
1088 return -E1000_ERR_PHY;
1094 DEBUGOUT2("CABLE_DISCONNECTED %s set after %dmsec\n",
1095 (E1000_READ_REG(hw, E1000_FEXT) &
1096 E1000_FEXT_PHY_CABLE_DISCONNECTED) ? "" : "not",
1098 if (!(E1000_READ_REG(hw, E1000_FEXT) &
1099 E1000_FEXT_PHY_CABLE_DISCONNECTED))
1103 if (E1000_READ_REG(hw, E1000_FWSM) & E1000_ICH_FWSM_FW_VALID) {
1104 /* Request ME configure ULP mode in the PHY */
1105 mac_reg = E1000_READ_REG(hw, E1000_H2ME);
1106 mac_reg |= E1000_H2ME_ULP | E1000_H2ME_ENFORCE_SETTINGS;
1107 E1000_WRITE_REG(hw, E1000_H2ME, mac_reg);
1112 ret_val = hw->phy.ops.acquire(hw);
1116 /* During S0 Idle keep the phy in PCI-E mode */
1117 if (hw->dev_spec.ich8lan.smbus_disable)
1120 /* Force SMBus mode in PHY */
1121 ret_val = e1000_read_phy_reg_hv_locked(hw, CV_SMB_CTRL, &phy_reg);
1124 phy_reg |= CV_SMB_CTRL_FORCE_SMBUS;
1125 e1000_write_phy_reg_hv_locked(hw, CV_SMB_CTRL, phy_reg);
1127 /* Force SMBus mode in MAC */
1128 mac_reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
1129 mac_reg |= E1000_CTRL_EXT_FORCE_SMBUS;
1130 E1000_WRITE_REG(hw, E1000_CTRL_EXT, mac_reg);
1132 /* Si workaround for ULP entry flow on i127/rev6 h/w. Enable
1133 * LPLU and disable Gig speed when entering ULP
1135 if ((hw->phy.type == e1000_phy_i217) && (hw->phy.revision == 6)) {
1136 ret_val = e1000_read_phy_reg_hv_locked(hw, HV_OEM_BITS,
1142 phy_reg |= HV_OEM_BITS_LPLU | HV_OEM_BITS_GBE_DIS;
1144 ret_val = e1000_write_phy_reg_hv_locked(hw, HV_OEM_BITS,
1153 /* Change the 'Link Status Change' interrupt to trigger
1154 * on 'Cable Status Change'
1156 ret_val = e1000_read_kmrn_reg_locked(hw,
1157 E1000_KMRNCTRLSTA_OP_MODES,
1161 phy_reg |= E1000_KMRNCTRLSTA_OP_MODES_LSC2CSC;
1162 e1000_write_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_OP_MODES,
1166 /* Set Inband ULP Exit, Reset to SMBus mode and
1167 * Disable SMBus Release on PERST# in PHY
1169 ret_val = e1000_read_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, &phy_reg);
1172 phy_reg |= (I218_ULP_CONFIG1_RESET_TO_SMBUS |
1173 I218_ULP_CONFIG1_DISABLE_SMB_PERST);
1175 if (E1000_READ_REG(hw, E1000_WUFC) & E1000_WUFC_LNKC)
1176 phy_reg |= I218_ULP_CONFIG1_WOL_HOST;
1178 phy_reg &= ~I218_ULP_CONFIG1_WOL_HOST;
1180 phy_reg |= I218_ULP_CONFIG1_STICKY_ULP;
1181 phy_reg &= ~I218_ULP_CONFIG1_INBAND_EXIT;
1183 phy_reg |= I218_ULP_CONFIG1_INBAND_EXIT;
1184 phy_reg &= ~I218_ULP_CONFIG1_STICKY_ULP;
1185 phy_reg &= ~I218_ULP_CONFIG1_WOL_HOST;
1187 e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
1189 /* Set Disable SMBus Release on PERST# in MAC */
1190 mac_reg = E1000_READ_REG(hw, E1000_FEXTNVM7);
1191 mac_reg |= E1000_FEXTNVM7_DISABLE_SMB_PERST;
1192 E1000_WRITE_REG(hw, E1000_FEXTNVM7, mac_reg);
1194 /* Commit ULP changes in PHY by starting auto ULP configuration */
1195 phy_reg |= I218_ULP_CONFIG1_START;
1196 e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
1199 /* Disable Tx so that the MAC doesn't send any (buffered)
1200 * packets to the PHY.
1202 mac_reg = E1000_READ_REG(hw, E1000_TCTL);
1203 mac_reg &= ~E1000_TCTL_EN;
1204 E1000_WRITE_REG(hw, E1000_TCTL, mac_reg);
1207 if ((hw->phy.type == e1000_phy_i217) && (hw->phy.revision == 6) &&
1208 to_sx && (E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU)) {
1209 ret_val = e1000_write_phy_reg_hv_locked(hw, HV_OEM_BITS,
1216 hw->phy.ops.release(hw);
1219 DEBUGOUT1("Error in ULP enable flow: %d\n", ret_val);
1221 hw->dev_spec.ich8lan.ulp_state = e1000_ulp_state_on;
1227 * e1000_disable_ulp_lpt_lp - unconfigure Ultra Low Power mode for LynxPoint-LP
1228 * @hw: pointer to the HW structure
1229 * @force: boolean indicating whether or not to force disabling ULP
1231 * Un-configure ULP mode when link is up, the system is transitioned from
1232 * Sx or the driver is unloaded. If on a Manageability Engine (ME) enabled
1233 * system, poll for an indication from ME that ULP has been un-configured.
1234 * If not on an ME enabled system, un-configure the ULP mode by software.
1236 * During nominal operation, this function is called when link is acquired
1237 * to disable ULP mode (force=false); otherwise, for example when unloading
1238 * the driver or during Sx->S0 transitions, this is called with force=true
1239 * to forcibly disable ULP.
1241 * When the cable is plugged in while the device is in D0, a Cable Status
1242 * Change interrupt is generated which causes this function to be called
1243 * to partially disable ULP mode and restart autonegotiation. This function
1244 * is then called again due to the resulting Link Status Change interrupt
1245 * to finish cleaning up after the ULP flow.
1247 s32 e1000_disable_ulp_lpt_lp(struct e1000_hw *hw, bool force)
1249 s32 ret_val = E1000_SUCCESS;
1254 if ((hw->mac.type < e1000_pch_lpt) ||
1255 (hw->device_id == E1000_DEV_ID_PCH_LPT_I217_LM) ||
1256 (hw->device_id == E1000_DEV_ID_PCH_LPT_I217_V) ||
1257 (hw->device_id == E1000_DEV_ID_PCH_I218_LM2) ||
1258 (hw->device_id == E1000_DEV_ID_PCH_I218_V2) ||
1259 (hw->dev_spec.ich8lan.ulp_state == e1000_ulp_state_off))
1262 if (E1000_READ_REG(hw, E1000_FWSM) & E1000_ICH_FWSM_FW_VALID) {
1264 /* Request ME un-configure ULP mode in the PHY */
1265 mac_reg = E1000_READ_REG(hw, E1000_H2ME);
1266 mac_reg &= ~E1000_H2ME_ULP;
1267 mac_reg |= E1000_H2ME_ENFORCE_SETTINGS;
1268 E1000_WRITE_REG(hw, E1000_H2ME, mac_reg);
1271 /* Poll up to 300msec for ME to clear ULP_CFG_DONE. */
1272 while (E1000_READ_REG(hw, E1000_FWSM) &
1273 E1000_FWSM_ULP_CFG_DONE) {
1275 ret_val = -E1000_ERR_PHY;
1281 DEBUGOUT1("ULP_CONFIG_DONE cleared after %dmsec\n", i * 10);
1284 mac_reg = E1000_READ_REG(hw, E1000_H2ME);
1285 mac_reg &= ~E1000_H2ME_ENFORCE_SETTINGS;
1286 E1000_WRITE_REG(hw, E1000_H2ME, mac_reg);
1288 /* Clear H2ME.ULP after ME ULP configuration */
1289 mac_reg = E1000_READ_REG(hw, E1000_H2ME);
1290 mac_reg &= ~E1000_H2ME_ULP;
1291 E1000_WRITE_REG(hw, E1000_H2ME, mac_reg);
1293 /* Restore link speed advertisements and restart
1296 if (hw->mac.autoneg) {
1297 ret_val = e1000_phy_setup_autoneg(hw);
1301 ret_val = e1000_setup_copper_link_generic(hw);
1305 ret_val = e1000_oem_bits_config_ich8lan(hw, true);
1311 ret_val = hw->phy.ops.acquire(hw);
1315 /* Revert the change to the 'Link Status Change'
1316 * interrupt to trigger on 'Cable Status Change'
1318 ret_val = e1000_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_OP_MODES,
1322 phy_reg &= ~E1000_KMRNCTRLSTA_OP_MODES_LSC2CSC;
1323 e1000_write_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_OP_MODES, phy_reg);
1326 /* Toggle LANPHYPC Value bit */
1327 e1000_toggle_lanphypc_pch_lpt(hw);
1329 /* Unforce SMBus mode in PHY */
1330 ret_val = e1000_read_phy_reg_hv_locked(hw, CV_SMB_CTRL, &phy_reg);
1332 /* The MAC might be in PCIe mode, so temporarily force to
1333 * SMBus mode in order to access the PHY.
1335 mac_reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
1336 mac_reg |= E1000_CTRL_EXT_FORCE_SMBUS;
1337 E1000_WRITE_REG(hw, E1000_CTRL_EXT, mac_reg);
1341 ret_val = e1000_read_phy_reg_hv_locked(hw, CV_SMB_CTRL,
1346 phy_reg &= ~CV_SMB_CTRL_FORCE_SMBUS;
1347 e1000_write_phy_reg_hv_locked(hw, CV_SMB_CTRL, phy_reg);
1349 /* Unforce SMBus mode in MAC */
1350 mac_reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
1351 mac_reg &= ~E1000_CTRL_EXT_FORCE_SMBUS;
1352 E1000_WRITE_REG(hw, E1000_CTRL_EXT, mac_reg);
1354 /* When ULP mode was previously entered, K1 was disabled by the
1355 * hardware. Re-Enable K1 in the PHY when exiting ULP.
1357 ret_val = e1000_read_phy_reg_hv_locked(hw, HV_PM_CTRL, &phy_reg);
1360 phy_reg |= HV_PM_CTRL_K1_ENABLE;
1361 e1000_write_phy_reg_hv_locked(hw, HV_PM_CTRL, phy_reg);
1363 /* Clear ULP enabled configuration */
1364 ret_val = e1000_read_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, &phy_reg);
1367 /* CSC interrupt received due to ULP Indication */
1368 if ((phy_reg & I218_ULP_CONFIG1_IND) || force) {
1369 phy_reg &= ~(I218_ULP_CONFIG1_IND |
1370 I218_ULP_CONFIG1_STICKY_ULP |
1371 I218_ULP_CONFIG1_RESET_TO_SMBUS |
1372 I218_ULP_CONFIG1_WOL_HOST |
1373 I218_ULP_CONFIG1_INBAND_EXIT |
1374 I218_ULP_CONFIG1_EN_ULP_LANPHYPC |
1375 I218_ULP_CONFIG1_DIS_CLR_STICKY_ON_PERST |
1376 I218_ULP_CONFIG1_DISABLE_SMB_PERST);
1377 e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
1379 /* Commit ULP changes by starting auto ULP configuration */
1380 phy_reg |= I218_ULP_CONFIG1_START;
1381 e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
1383 /* Clear Disable SMBus Release on PERST# in MAC */
1384 mac_reg = E1000_READ_REG(hw, E1000_FEXTNVM7);
1385 mac_reg &= ~E1000_FEXTNVM7_DISABLE_SMB_PERST;
1386 E1000_WRITE_REG(hw, E1000_FEXTNVM7, mac_reg);
1389 hw->phy.ops.release(hw);
1391 if (hw->mac.autoneg)
1392 e1000_phy_setup_autoneg(hw);
1394 e1000_setup_copper_link_generic(hw);
1396 e1000_sw_lcd_config_ich8lan(hw);
1398 e1000_oem_bits_config_ich8lan(hw, true);
1400 /* Set ULP state to unknown and return non-zero to
1401 * indicate no link (yet) and re-enter on the next LSC
1402 * to finish disabling ULP flow.
1404 hw->dev_spec.ich8lan.ulp_state =
1405 e1000_ulp_state_unknown;
1412 mac_reg = E1000_READ_REG(hw, E1000_TCTL);
1413 mac_reg |= E1000_TCTL_EN;
1414 E1000_WRITE_REG(hw, E1000_TCTL, mac_reg);
1417 hw->phy.ops.release(hw);
1419 hw->phy.ops.reset(hw);
1424 DEBUGOUT1("Error in ULP disable flow: %d\n", ret_val);
1426 hw->dev_spec.ich8lan.ulp_state = e1000_ulp_state_off;
1431 #endif /* ULP_SUPPORT */
1435 * e1000_check_for_copper_link_ich8lan - Check for link (Copper)
1436 * @hw: pointer to the HW structure
1438 * Checks to see of the link status of the hardware has changed. If a
1439 * change in link status has been detected, then we read the PHY registers
1440 * to get the current speed/duplex if link exists.
1442 STATIC s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw)
1444 struct e1000_mac_info *mac = &hw->mac;
1445 s32 ret_val, tipg_reg = 0;
1446 u16 emi_addr, emi_val = 0;
1450 DEBUGFUNC("e1000_check_for_copper_link_ich8lan");
1452 /* We only want to go out to the PHY registers to see if Auto-Neg
1453 * has completed and/or if our link status has changed. The
1454 * get_link_status flag is set upon receiving a Link Status
1455 * Change or Rx Sequence Error interrupt.
1457 if (!mac->get_link_status)
1458 return E1000_SUCCESS;
1460 if ((hw->mac.type < e1000_pch_lpt) ||
1461 (hw->device_id == E1000_DEV_ID_PCH_LPT_I217_LM) ||
1462 (hw->device_id == E1000_DEV_ID_PCH_LPT_I217_V)) {
1463 /* First we want to see if the MII Status Register reports
1464 * link. If so, then we want to get the current speed/duplex
1467 ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link);
1471 /* Check the MAC's STATUS register to determine link state
1472 * since the PHY could be inaccessible while in ULP mode.
1474 link = !!(E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU);
1476 ret_val = e1000_disable_ulp_lpt_lp(hw, false);
1478 ret_val = e1000_enable_ulp_lpt_lp(hw, false);
1483 if (hw->mac.type == e1000_pchlan) {
1484 ret_val = e1000_k1_gig_workaround_hv(hw, link);
1489 /* When connected at 10Mbps half-duplex, some parts are excessively
1490 * aggressive resulting in many collisions. To avoid this, increase
1491 * the IPG and reduce Rx latency in the PHY.
1493 if (((hw->mac.type == e1000_pch2lan) ||
1494 (hw->mac.type == e1000_pch_lpt)) && link) {
1497 e1000_get_speed_and_duplex_copper_generic(hw, &speed, &duplex);
1498 tipg_reg = E1000_READ_REG(hw, E1000_TIPG);
1499 tipg_reg &= ~E1000_TIPG_IPGT_MASK;
1501 if (duplex == HALF_DUPLEX && speed == SPEED_10) {
1503 /* Reduce Rx latency in analog PHY */
1506 /* Roll back the default values */
1511 E1000_WRITE_REG(hw, E1000_TIPG, tipg_reg);
1513 ret_val = hw->phy.ops.acquire(hw);
1517 if (hw->mac.type == e1000_pch2lan)
1518 emi_addr = I82579_RX_CONFIG;
1520 emi_addr = I217_RX_CONFIG;
1521 ret_val = e1000_write_emi_reg_locked(hw, emi_addr, emi_val);
1524 if (hw->mac.type >= e1000_pch_lpt) {
1527 hw->phy.ops.read_reg_locked(hw, I217_PLL_CLOCK_GATE_REG,
1529 phy_reg &= ~I217_PLL_CLOCK_GATE_MASK;
1530 if (speed == SPEED_100 || speed == SPEED_10)
1534 hw->phy.ops.write_reg_locked(hw,
1535 I217_PLL_CLOCK_GATE_REG,
1538 hw->phy.ops.release(hw);
1544 /* I217 Packet Loss issue:
1545 * ensure that FEXTNVM4 Beacon Duration is set correctly
1547 * Set the Beacon Duration for I217 to 8 usec
1549 if (hw->mac.type == e1000_pch_lpt) {
1552 mac_reg = E1000_READ_REG(hw, E1000_FEXTNVM4);
1553 mac_reg &= ~E1000_FEXTNVM4_BEACON_DURATION_MASK;
1554 mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_8USEC;
1555 E1000_WRITE_REG(hw, E1000_FEXTNVM4, mac_reg);
1558 /* Work-around I218 hang issue */
1559 if ((hw->device_id == E1000_DEV_ID_PCH_LPTLP_I218_LM) ||
1560 (hw->device_id == E1000_DEV_ID_PCH_LPTLP_I218_V) ||
1561 (hw->device_id == E1000_DEV_ID_PCH_I218_LM3) ||
1562 (hw->device_id == E1000_DEV_ID_PCH_I218_V3)) {
1563 ret_val = e1000_k1_workaround_lpt_lp(hw, link);
1567 /* Clear link partner's EEE ability */
1568 hw->dev_spec.ich8lan.eee_lp_ability = 0;
1570 /* Configure K0s minimum time */
1571 if (hw->mac.type == e1000_pch_lpt) {
1572 e1000_configure_k0s_lpt(hw, K1_ENTRY_LATENCY, K1_MIN_TIME);
1576 return E1000_SUCCESS; /* No link detected */
1578 mac->get_link_status = false;
1580 switch (hw->mac.type) {
1582 ret_val = e1000_k1_workaround_lv(hw);
1587 if (hw->phy.type == e1000_phy_82578) {
1588 ret_val = e1000_link_stall_workaround_hv(hw);
1593 /* Workaround for PCHx parts in half-duplex:
1594 * Set the number of preambles removed from the packet
1595 * when it is passed from the PHY to the MAC to prevent
1596 * the MAC from misinterpreting the packet type.
1598 hw->phy.ops.read_reg(hw, HV_KMRN_FIFO_CTRLSTA, &phy_reg);
1599 phy_reg &= ~HV_KMRN_FIFO_CTRLSTA_PREAMBLE_MASK;
1601 if ((E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_FD) !=
1603 phy_reg |= (1 << HV_KMRN_FIFO_CTRLSTA_PREAMBLE_SHIFT);
1605 hw->phy.ops.write_reg(hw, HV_KMRN_FIFO_CTRLSTA, phy_reg);
1611 /* Check if there was DownShift, must be checked
1612 * immediately after link-up
1614 e1000_check_downshift_generic(hw);
1616 /* Enable/Disable EEE after link up */
1617 if (hw->phy.type > e1000_phy_82579) {
1618 ret_val = e1000_set_eee_pchlan(hw);
1623 /* If we are forcing speed/duplex, then we simply return since
1624 * we have already determined whether we have link or not.
1627 return -E1000_ERR_CONFIG;
1629 /* Auto-Neg is enabled. Auto Speed Detection takes care
1630 * of MAC speed/duplex configuration. So we only need to
1631 * configure Collision Distance in the MAC.
1633 mac->ops.config_collision_dist(hw);
1635 /* Configure Flow Control now that Auto-Neg has completed.
1636 * First, we need to restore the desired flow control
1637 * settings because we may have had to re-autoneg with a
1638 * different link partner.
1640 ret_val = e1000_config_fc_after_link_up_generic(hw);
1642 DEBUGOUT("Error configuring flow control\n");
1648 * e1000_init_function_pointers_ich8lan - Initialize ICH8 function pointers
1649 * @hw: pointer to the HW structure
1651 * Initialize family-specific function pointers for PHY, MAC, and NVM.
1653 void e1000_init_function_pointers_ich8lan(struct e1000_hw *hw)
1655 DEBUGFUNC("e1000_init_function_pointers_ich8lan");
1657 hw->mac.ops.init_params = e1000_init_mac_params_ich8lan;
1658 hw->nvm.ops.init_params = e1000_init_nvm_params_ich8lan;
1659 switch (hw->mac.type) {
1662 case e1000_ich10lan:
1663 hw->phy.ops.init_params = e1000_init_phy_params_ich8lan;
1668 hw->phy.ops.init_params = e1000_init_phy_params_pchlan;
1676 * e1000_acquire_nvm_ich8lan - Acquire NVM mutex
1677 * @hw: pointer to the HW structure
1679 * Acquires the mutex for performing NVM operations.
1681 STATIC s32 e1000_acquire_nvm_ich8lan(struct e1000_hw *hw)
1683 DEBUGFUNC("e1000_acquire_nvm_ich8lan");
1685 E1000_MUTEX_LOCK(&hw->dev_spec.ich8lan.nvm_mutex);
1687 return E1000_SUCCESS;
1691 * e1000_release_nvm_ich8lan - Release NVM mutex
1692 * @hw: pointer to the HW structure
1694 * Releases the mutex used while performing NVM operations.
1696 STATIC void e1000_release_nvm_ich8lan(struct e1000_hw *hw)
1698 DEBUGFUNC("e1000_release_nvm_ich8lan");
1700 E1000_MUTEX_UNLOCK(&hw->dev_spec.ich8lan.nvm_mutex);
1706 * e1000_acquire_swflag_ich8lan - Acquire software control flag
1707 * @hw: pointer to the HW structure
1709 * Acquires the software control flag for performing PHY and select
1712 STATIC s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw)
1714 u32 extcnf_ctrl, timeout = PHY_CFG_TIMEOUT;
1715 s32 ret_val = E1000_SUCCESS;
1717 DEBUGFUNC("e1000_acquire_swflag_ich8lan");
1719 E1000_MUTEX_LOCK(&hw->dev_spec.ich8lan.swflag_mutex);
1722 extcnf_ctrl = E1000_READ_REG(hw, E1000_EXTCNF_CTRL);
1723 if (!(extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG))
1731 DEBUGOUT("SW has already locked the resource.\n");
1732 ret_val = -E1000_ERR_CONFIG;
1736 timeout = SW_FLAG_TIMEOUT;
1738 extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG;
1739 E1000_WRITE_REG(hw, E1000_EXTCNF_CTRL, extcnf_ctrl);
1742 extcnf_ctrl = E1000_READ_REG(hw, E1000_EXTCNF_CTRL);
1743 if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG)
1751 DEBUGOUT2("Failed to acquire the semaphore, FW or HW has it: FWSM=0x%8.8x EXTCNF_CTRL=0x%8.8x)\n",
1752 E1000_READ_REG(hw, E1000_FWSM), extcnf_ctrl);
1753 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
1754 E1000_WRITE_REG(hw, E1000_EXTCNF_CTRL, extcnf_ctrl);
1755 ret_val = -E1000_ERR_CONFIG;
1761 E1000_MUTEX_UNLOCK(&hw->dev_spec.ich8lan.swflag_mutex);
1767 * e1000_release_swflag_ich8lan - Release software control flag
1768 * @hw: pointer to the HW structure
1770 * Releases the software control flag for performing PHY and select
1773 STATIC void e1000_release_swflag_ich8lan(struct e1000_hw *hw)
1777 DEBUGFUNC("e1000_release_swflag_ich8lan");
1779 extcnf_ctrl = E1000_READ_REG(hw, E1000_EXTCNF_CTRL);
1781 if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG) {
1782 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
1783 E1000_WRITE_REG(hw, E1000_EXTCNF_CTRL, extcnf_ctrl);
1785 DEBUGOUT("Semaphore unexpectedly released by sw/fw/hw\n");
1788 E1000_MUTEX_UNLOCK(&hw->dev_spec.ich8lan.swflag_mutex);
1794 * e1000_check_mng_mode_ich8lan - Checks management mode
1795 * @hw: pointer to the HW structure
1797 * This checks if the adapter has any manageability enabled.
1798 * This is a function pointer entry point only called by read/write
1799 * routines for the PHY and NVM parts.
1801 STATIC bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw)
1805 DEBUGFUNC("e1000_check_mng_mode_ich8lan");
1807 fwsm = E1000_READ_REG(hw, E1000_FWSM);
1809 return (fwsm & E1000_ICH_FWSM_FW_VALID) &&
1810 ((fwsm & E1000_FWSM_MODE_MASK) ==
1811 (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT));
1815 * e1000_check_mng_mode_pchlan - Checks management mode
1816 * @hw: pointer to the HW structure
1818 * This checks if the adapter has iAMT enabled.
1819 * This is a function pointer entry point only called by read/write
1820 * routines for the PHY and NVM parts.
1822 STATIC bool e1000_check_mng_mode_pchlan(struct e1000_hw *hw)
1826 DEBUGFUNC("e1000_check_mng_mode_pchlan");
1828 fwsm = E1000_READ_REG(hw, E1000_FWSM);
1830 return (fwsm & E1000_ICH_FWSM_FW_VALID) &&
1831 (fwsm & (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT));
1835 * e1000_rar_set_pch2lan - Set receive address register
1836 * @hw: pointer to the HW structure
1837 * @addr: pointer to the receive address
1838 * @index: receive address array register
1840 * Sets the receive address array register at index to the address passed
1841 * in by addr. For 82579, RAR[0] is the base address register that is to
1842 * contain the MAC address but RAR[1-6] are reserved for manageability (ME).
1843 * Use SHRA[0-3] in place of those reserved for ME.
1845 STATIC int e1000_rar_set_pch2lan(struct e1000_hw *hw, u8 *addr, u32 index)
1847 u32 rar_low, rar_high;
1849 DEBUGFUNC("e1000_rar_set_pch2lan");
1851 /* HW expects these in little endian so we reverse the byte order
1852 * from network order (big endian) to little endian
1854 rar_low = ((u32) addr[0] |
1855 ((u32) addr[1] << 8) |
1856 ((u32) addr[2] << 16) | ((u32) addr[3] << 24));
1858 rar_high = ((u32) addr[4] | ((u32) addr[5] << 8));
1860 /* If MAC address zero, no need to set the AV bit */
1861 if (rar_low || rar_high)
1862 rar_high |= E1000_RAH_AV;
1865 E1000_WRITE_REG(hw, E1000_RAL(index), rar_low);
1866 E1000_WRITE_FLUSH(hw);
1867 E1000_WRITE_REG(hw, E1000_RAH(index), rar_high);
1868 E1000_WRITE_FLUSH(hw);
1869 return E1000_SUCCESS;
1872 /* RAR[1-6] are owned by manageability. Skip those and program the
1873 * next address into the SHRA register array.
1875 if (index < (u32) (hw->mac.rar_entry_count)) {
1878 ret_val = e1000_acquire_swflag_ich8lan(hw);
1882 E1000_WRITE_REG(hw, E1000_SHRAL(index - 1), rar_low);
1883 E1000_WRITE_FLUSH(hw);
1884 E1000_WRITE_REG(hw, E1000_SHRAH(index - 1), rar_high);
1885 E1000_WRITE_FLUSH(hw);
1887 e1000_release_swflag_ich8lan(hw);
1889 /* verify the register updates */
1890 if ((E1000_READ_REG(hw, E1000_SHRAL(index - 1)) == rar_low) &&
1891 (E1000_READ_REG(hw, E1000_SHRAH(index - 1)) == rar_high))
1892 return E1000_SUCCESS;
1894 DEBUGOUT2("SHRA[%d] might be locked by ME - FWSM=0x%8.8x\n",
1895 (index - 1), E1000_READ_REG(hw, E1000_FWSM));
1899 DEBUGOUT1("Failed to write receive address at index %d\n", index);
1900 return -E1000_ERR_CONFIG;
1904 * e1000_rar_set_pch_lpt - Set receive address registers
1905 * @hw: pointer to the HW structure
1906 * @addr: pointer to the receive address
1907 * @index: receive address array register
1909 * Sets the receive address register array at index to the address passed
1910 * in by addr. For LPT, RAR[0] is the base address register that is to
1911 * contain the MAC address. SHRA[0-10] are the shared receive address
1912 * registers that are shared between the Host and manageability engine (ME).
1914 STATIC int e1000_rar_set_pch_lpt(struct e1000_hw *hw, u8 *addr, u32 index)
1916 u32 rar_low, rar_high;
1919 DEBUGFUNC("e1000_rar_set_pch_lpt");
1921 /* HW expects these in little endian so we reverse the byte order
1922 * from network order (big endian) to little endian
1924 rar_low = ((u32) addr[0] | ((u32) addr[1] << 8) |
1925 ((u32) addr[2] << 16) | ((u32) addr[3] << 24));
1927 rar_high = ((u32) addr[4] | ((u32) addr[5] << 8));
1929 /* If MAC address zero, no need to set the AV bit */
1930 if (rar_low || rar_high)
1931 rar_high |= E1000_RAH_AV;
1934 E1000_WRITE_REG(hw, E1000_RAL(index), rar_low);
1935 E1000_WRITE_FLUSH(hw);
1936 E1000_WRITE_REG(hw, E1000_RAH(index), rar_high);
1937 E1000_WRITE_FLUSH(hw);
1938 return E1000_SUCCESS;
1941 /* The manageability engine (ME) can lock certain SHRAR registers that
1942 * it is using - those registers are unavailable for use.
1944 if (index < hw->mac.rar_entry_count) {
1945 wlock_mac = E1000_READ_REG(hw, E1000_FWSM) &
1946 E1000_FWSM_WLOCK_MAC_MASK;
1947 wlock_mac >>= E1000_FWSM_WLOCK_MAC_SHIFT;
1949 /* Check if all SHRAR registers are locked */
1953 if ((wlock_mac == 0) || (index <= wlock_mac)) {
1956 ret_val = e1000_acquire_swflag_ich8lan(hw);
1961 E1000_WRITE_REG(hw, E1000_SHRAL_PCH_LPT(index - 1),
1963 E1000_WRITE_FLUSH(hw);
1964 E1000_WRITE_REG(hw, E1000_SHRAH_PCH_LPT(index - 1),
1966 E1000_WRITE_FLUSH(hw);
1968 e1000_release_swflag_ich8lan(hw);
1970 /* verify the register updates */
1971 if ((E1000_READ_REG(hw, E1000_SHRAL_PCH_LPT(index - 1)) == rar_low) &&
1972 (E1000_READ_REG(hw, E1000_SHRAH_PCH_LPT(index - 1)) == rar_high))
1973 return E1000_SUCCESS;
1978 DEBUGOUT1("Failed to write receive address at index %d\n", index);
1979 return -E1000_ERR_CONFIG;
1982 #ifndef NO_NON_BLOCKING_PHY_MTA_UPDATE_SUPPORT
1984 * e1000_update_mc_addr_list_pch2lan - Update Multicast addresses
1985 * @hw: pointer to the HW structure
1986 * @mc_addr_list: array of multicast addresses to program
1987 * @mc_addr_count: number of multicast addresses to program
1989 * Updates entire Multicast Table Array of the PCH2 MAC and PHY.
1990 * The caller must have a packed mc_addr_list of multicast addresses.
1992 STATIC void e1000_update_mc_addr_list_pch2lan(struct e1000_hw *hw,
2000 DEBUGFUNC("e1000_update_mc_addr_list_pch2lan");
2002 e1000_update_mc_addr_list_generic(hw, mc_addr_list, mc_addr_count);
2004 ret_val = hw->phy.ops.acquire(hw);
2008 ret_val = e1000_enable_phy_wakeup_reg_access_bm(hw, &phy_reg);
2012 for (i = 0; i < hw->mac.mta_reg_count; i++) {
2013 hw->phy.ops.write_reg_page(hw, BM_MTA(i),
2014 (u16)(hw->mac.mta_shadow[i] &
2016 hw->phy.ops.write_reg_page(hw, (BM_MTA(i) + 1),
2017 (u16)((hw->mac.mta_shadow[i] >> 16) &
2021 e1000_disable_phy_wakeup_reg_access_bm(hw, &phy_reg);
2024 hw->phy.ops.release(hw);
2027 #endif /* NO_NON_BLOCKING_PHY_MTA_UPDATE_SUPPORT */
2029 * e1000_check_reset_block_ich8lan - Check if PHY reset is blocked
2030 * @hw: pointer to the HW structure
2032 * Checks if firmware is blocking the reset of the PHY.
2033 * This is a function pointer entry point only called by
2036 STATIC s32 e1000_check_reset_block_ich8lan(struct e1000_hw *hw)
2039 bool blocked = false;
2042 DEBUGFUNC("e1000_check_reset_block_ich8lan");
2045 fwsm = E1000_READ_REG(hw, E1000_FWSM);
2046 if (!(fwsm & E1000_ICH_FWSM_RSPCIPHY)) {
2052 } while (blocked && (i++ < 30));
2053 return blocked ? E1000_BLK_PHY_RESET : E1000_SUCCESS;
2057 * e1000_write_smbus_addr - Write SMBus address to PHY needed during Sx states
2058 * @hw: pointer to the HW structure
2060 * Assumes semaphore already acquired.
2063 STATIC s32 e1000_write_smbus_addr(struct e1000_hw *hw)
2066 u32 strap = E1000_READ_REG(hw, E1000_STRAP);
2067 u32 freq = (strap & E1000_STRAP_SMT_FREQ_MASK) >>
2068 E1000_STRAP_SMT_FREQ_SHIFT;
2071 strap &= E1000_STRAP_SMBUS_ADDRESS_MASK;
2073 ret_val = e1000_read_phy_reg_hv_locked(hw, HV_SMB_ADDR, &phy_data);
2077 phy_data &= ~HV_SMB_ADDR_MASK;
2078 phy_data |= (strap >> E1000_STRAP_SMBUS_ADDRESS_SHIFT);
2079 phy_data |= HV_SMB_ADDR_PEC_EN | HV_SMB_ADDR_VALID;
2081 if (hw->phy.type == e1000_phy_i217) {
2082 /* Restore SMBus frequency */
2084 phy_data &= ~HV_SMB_ADDR_FREQ_MASK;
2085 phy_data |= (freq & (1 << 0)) <<
2086 HV_SMB_ADDR_FREQ_LOW_SHIFT;
2087 phy_data |= (freq & (1 << 1)) <<
2088 (HV_SMB_ADDR_FREQ_HIGH_SHIFT - 1);
2090 DEBUGOUT("Unsupported SMB frequency in PHY\n");
2094 return e1000_write_phy_reg_hv_locked(hw, HV_SMB_ADDR, phy_data);
2098 * e1000_sw_lcd_config_ich8lan - SW-based LCD Configuration
2099 * @hw: pointer to the HW structure
2101 * SW should configure the LCD from the NVM extended configuration region
2102 * as a workaround for certain parts.
2104 STATIC s32 e1000_sw_lcd_config_ich8lan(struct e1000_hw *hw)
2106 struct e1000_phy_info *phy = &hw->phy;
2107 u32 i, data, cnf_size, cnf_base_addr, sw_cfg_mask;
2108 s32 ret_val = E1000_SUCCESS;
2109 u16 word_addr, reg_data, reg_addr, phy_page = 0;
2111 DEBUGFUNC("e1000_sw_lcd_config_ich8lan");
2113 /* Initialize the PHY from the NVM on ICH platforms. This
2114 * is needed due to an issue where the NVM configuration is
2115 * not properly autoloaded after power transitions.
2116 * Therefore, after each PHY reset, we will load the
2117 * configuration data out of the NVM manually.
2119 switch (hw->mac.type) {
2121 if (phy->type != e1000_phy_igp_3)
2124 if ((hw->device_id == E1000_DEV_ID_ICH8_IGP_AMT) ||
2125 (hw->device_id == E1000_DEV_ID_ICH8_IGP_C)) {
2126 sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG;
2133 sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG_ICH8M;
2139 ret_val = hw->phy.ops.acquire(hw);
2143 data = E1000_READ_REG(hw, E1000_FEXTNVM);
2144 if (!(data & sw_cfg_mask))
2147 /* Make sure HW does not configure LCD from PHY
2148 * extended configuration before SW configuration
2150 data = E1000_READ_REG(hw, E1000_EXTCNF_CTRL);
2151 if ((hw->mac.type < e1000_pch2lan) &&
2152 (data & E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE))
2155 cnf_size = E1000_READ_REG(hw, E1000_EXTCNF_SIZE);
2156 cnf_size &= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_MASK;
2157 cnf_size >>= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_SHIFT;
2161 cnf_base_addr = data & E1000_EXTCNF_CTRL_EXT_CNF_POINTER_MASK;
2162 cnf_base_addr >>= E1000_EXTCNF_CTRL_EXT_CNF_POINTER_SHIFT;
2164 if (((hw->mac.type == e1000_pchlan) &&
2165 !(data & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE)) ||
2166 (hw->mac.type > e1000_pchlan)) {
2167 /* HW configures the SMBus address and LEDs when the
2168 * OEM and LCD Write Enable bits are set in the NVM.
2169 * When both NVM bits are cleared, SW will configure
2172 ret_val = e1000_write_smbus_addr(hw);
2176 data = E1000_READ_REG(hw, E1000_LEDCTL);
2177 ret_val = e1000_write_phy_reg_hv_locked(hw, HV_LED_CONFIG,
2183 /* Configure LCD from extended configuration region. */
2185 /* cnf_base_addr is in DWORD */
2186 word_addr = (u16)(cnf_base_addr << 1);
2188 for (i = 0; i < cnf_size; i++) {
2189 ret_val = hw->nvm.ops.read(hw, (word_addr + i * 2), 1,
2194 ret_val = hw->nvm.ops.read(hw, (word_addr + i * 2 + 1),
2199 /* Save off the PHY page for future writes. */
2200 if (reg_addr == IGP01E1000_PHY_PAGE_SELECT) {
2201 phy_page = reg_data;
2205 reg_addr &= PHY_REG_MASK;
2206 reg_addr |= phy_page;
2208 ret_val = phy->ops.write_reg_locked(hw, (u32)reg_addr,
2215 hw->phy.ops.release(hw);
2220 * e1000_k1_gig_workaround_hv - K1 Si workaround
2221 * @hw: pointer to the HW structure
2222 * @link: link up bool flag
2224 * If K1 is enabled for 1Gbps, the MAC might stall when transitioning
2225 * from a lower speed. This workaround disables K1 whenever link is at 1Gig
2226 * If link is down, the function will restore the default K1 setting located
2229 STATIC s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link)
2231 s32 ret_val = E1000_SUCCESS;
2233 bool k1_enable = hw->dev_spec.ich8lan.nvm_k1_enabled;
2235 DEBUGFUNC("e1000_k1_gig_workaround_hv");
2237 if (hw->mac.type != e1000_pchlan)
2238 return E1000_SUCCESS;
2240 /* Wrap the whole flow with the sw flag */
2241 ret_val = hw->phy.ops.acquire(hw);
2245 /* Disable K1 when link is 1Gbps, otherwise use the NVM setting */
2247 if (hw->phy.type == e1000_phy_82578) {
2248 ret_val = hw->phy.ops.read_reg_locked(hw, BM_CS_STATUS,
2253 status_reg &= (BM_CS_STATUS_LINK_UP |
2254 BM_CS_STATUS_RESOLVED |
2255 BM_CS_STATUS_SPEED_MASK);
2257 if (status_reg == (BM_CS_STATUS_LINK_UP |
2258 BM_CS_STATUS_RESOLVED |
2259 BM_CS_STATUS_SPEED_1000))
2263 if (hw->phy.type == e1000_phy_82577) {
2264 ret_val = hw->phy.ops.read_reg_locked(hw, HV_M_STATUS,
2269 status_reg &= (HV_M_STATUS_LINK_UP |
2270 HV_M_STATUS_AUTONEG_COMPLETE |
2271 HV_M_STATUS_SPEED_MASK);
2273 if (status_reg == (HV_M_STATUS_LINK_UP |
2274 HV_M_STATUS_AUTONEG_COMPLETE |
2275 HV_M_STATUS_SPEED_1000))
2279 /* Link stall fix for link up */
2280 ret_val = hw->phy.ops.write_reg_locked(hw, PHY_REG(770, 19),
2286 /* Link stall fix for link down */
2287 ret_val = hw->phy.ops.write_reg_locked(hw, PHY_REG(770, 19),
2293 ret_val = e1000_configure_k1_ich8lan(hw, k1_enable);
2296 hw->phy.ops.release(hw);
2302 * e1000_configure_k1_ich8lan - Configure K1 power state
2303 * @hw: pointer to the HW structure
2304 * @enable: K1 state to configure
2306 * Configure the K1 power state based on the provided parameter.
2307 * Assumes semaphore already acquired.
2309 * Success returns 0, Failure returns -E1000_ERR_PHY (-2)
2311 s32 e1000_configure_k1_ich8lan(struct e1000_hw *hw, bool k1_enable)
2319 DEBUGFUNC("e1000_configure_k1_ich8lan");
2321 ret_val = e1000_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
2327 kmrn_reg |= E1000_KMRNCTRLSTA_K1_ENABLE;
2329 kmrn_reg &= ~E1000_KMRNCTRLSTA_K1_ENABLE;
2331 ret_val = e1000_write_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
2337 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
2338 ctrl_reg = E1000_READ_REG(hw, E1000_CTRL);
2340 reg = ctrl_reg & ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100);
2341 reg |= E1000_CTRL_FRCSPD;
2342 E1000_WRITE_REG(hw, E1000_CTRL, reg);
2344 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext | E1000_CTRL_EXT_SPD_BYPS);
2345 E1000_WRITE_FLUSH(hw);
2347 E1000_WRITE_REG(hw, E1000_CTRL, ctrl_reg);
2348 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
2349 E1000_WRITE_FLUSH(hw);
2352 return E1000_SUCCESS;
2356 * e1000_oem_bits_config_ich8lan - SW-based LCD Configuration
2357 * @hw: pointer to the HW structure
2358 * @d0_state: boolean if entering d0 or d3 device state
2360 * SW will configure Gbe Disable and LPLU based on the NVM. The four bits are
2361 * collectively called OEM bits. The OEM Write Enable bit and SW Config bit
2362 * in NVM determines whether HW should configure LPLU and Gbe Disable.
2364 STATIC s32 e1000_oem_bits_config_ich8lan(struct e1000_hw *hw, bool d0_state)
2370 DEBUGFUNC("e1000_oem_bits_config_ich8lan");
2372 if (hw->mac.type < e1000_pchlan)
2375 ret_val = hw->phy.ops.acquire(hw);
2379 if (hw->mac.type == e1000_pchlan) {
2380 mac_reg = E1000_READ_REG(hw, E1000_EXTCNF_CTRL);
2381 if (mac_reg & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE)
2385 mac_reg = E1000_READ_REG(hw, E1000_FEXTNVM);
2386 if (!(mac_reg & E1000_FEXTNVM_SW_CONFIG_ICH8M))
2389 mac_reg = E1000_READ_REG(hw, E1000_PHY_CTRL);
2391 ret_val = hw->phy.ops.read_reg_locked(hw, HV_OEM_BITS, &oem_reg);
2395 oem_reg &= ~(HV_OEM_BITS_GBE_DIS | HV_OEM_BITS_LPLU);
2398 if (mac_reg & E1000_PHY_CTRL_GBE_DISABLE)
2399 oem_reg |= HV_OEM_BITS_GBE_DIS;
2401 if (mac_reg & E1000_PHY_CTRL_D0A_LPLU)
2402 oem_reg |= HV_OEM_BITS_LPLU;
2404 if (mac_reg & (E1000_PHY_CTRL_GBE_DISABLE |
2405 E1000_PHY_CTRL_NOND0A_GBE_DISABLE))
2406 oem_reg |= HV_OEM_BITS_GBE_DIS;
2408 if (mac_reg & (E1000_PHY_CTRL_D0A_LPLU |
2409 E1000_PHY_CTRL_NOND0A_LPLU))
2410 oem_reg |= HV_OEM_BITS_LPLU;
2413 /* Set Restart auto-neg to activate the bits */
2414 if ((d0_state || (hw->mac.type != e1000_pchlan)) &&
2415 !hw->phy.ops.check_reset_block(hw))
2416 oem_reg |= HV_OEM_BITS_RESTART_AN;
2418 ret_val = hw->phy.ops.write_reg_locked(hw, HV_OEM_BITS, oem_reg);
2421 hw->phy.ops.release(hw);
2428 * e1000_set_mdio_slow_mode_hv - Set slow MDIO access mode
2429 * @hw: pointer to the HW structure
2431 STATIC s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw)
2436 DEBUGFUNC("e1000_set_mdio_slow_mode_hv");
2438 ret_val = hw->phy.ops.read_reg(hw, HV_KMRN_MODE_CTRL, &data);
2442 data |= HV_KMRN_MDIO_SLOW;
2444 ret_val = hw->phy.ops.write_reg(hw, HV_KMRN_MODE_CTRL, data);
2450 * e1000_hv_phy_workarounds_ich8lan - A series of Phy workarounds to be
2451 * done after every PHY reset.
2453 STATIC s32 e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw)
2455 s32 ret_val = E1000_SUCCESS;
2458 DEBUGFUNC("e1000_hv_phy_workarounds_ich8lan");
2460 if (hw->mac.type != e1000_pchlan)
2461 return E1000_SUCCESS;
2463 /* Set MDIO slow mode before any other MDIO access */
2464 if (hw->phy.type == e1000_phy_82577) {
2465 ret_val = e1000_set_mdio_slow_mode_hv(hw);
2470 if (((hw->phy.type == e1000_phy_82577) &&
2471 ((hw->phy.revision == 1) || (hw->phy.revision == 2))) ||
2472 ((hw->phy.type == e1000_phy_82578) && (hw->phy.revision == 1))) {
2473 /* Disable generation of early preamble */
2474 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(769, 25), 0x4431);
2478 /* Preamble tuning for SSC */
2479 ret_val = hw->phy.ops.write_reg(hw, HV_KMRN_FIFO_CTRLSTA,
2485 if (hw->phy.type == e1000_phy_82578) {
2486 /* Return registers to default by doing a soft reset then
2487 * writing 0x3140 to the control register.
2489 if (hw->phy.revision < 2) {
2490 e1000_phy_sw_reset_generic(hw);
2491 ret_val = hw->phy.ops.write_reg(hw, PHY_CONTROL,
2497 ret_val = hw->phy.ops.acquire(hw);
2502 ret_val = e1000_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT, 0);
2503 hw->phy.ops.release(hw);
2507 /* Configure the K1 Si workaround during phy reset assuming there is
2508 * link so that it disables K1 if link is in 1Gbps.
2510 ret_val = e1000_k1_gig_workaround_hv(hw, true);
2514 /* Workaround for link disconnects on a busy hub in half duplex */
2515 ret_val = hw->phy.ops.acquire(hw);
2518 ret_val = hw->phy.ops.read_reg_locked(hw, BM_PORT_GEN_CFG, &phy_data);
2521 ret_val = hw->phy.ops.write_reg_locked(hw, BM_PORT_GEN_CFG,
2526 /* set MSE higher to enable link to stay up when noise is high */
2527 ret_val = e1000_write_emi_reg_locked(hw, I82577_MSE_THRESHOLD, 0x0034);
2529 hw->phy.ops.release(hw);
2535 * e1000_copy_rx_addrs_to_phy_ich8lan - Copy Rx addresses from MAC to PHY
2536 * @hw: pointer to the HW structure
2538 void e1000_copy_rx_addrs_to_phy_ich8lan(struct e1000_hw *hw)
2544 DEBUGFUNC("e1000_copy_rx_addrs_to_phy_ich8lan");
2546 ret_val = hw->phy.ops.acquire(hw);
2549 ret_val = e1000_enable_phy_wakeup_reg_access_bm(hw, &phy_reg);
2553 /* Copy both RAL/H (rar_entry_count) and SHRAL/H to PHY */
2554 for (i = 0; i < (hw->mac.rar_entry_count); i++) {
2555 mac_reg = E1000_READ_REG(hw, E1000_RAL(i));
2556 hw->phy.ops.write_reg_page(hw, BM_RAR_L(i),
2557 (u16)(mac_reg & 0xFFFF));
2558 hw->phy.ops.write_reg_page(hw, BM_RAR_M(i),
2559 (u16)((mac_reg >> 16) & 0xFFFF));
2561 mac_reg = E1000_READ_REG(hw, E1000_RAH(i));
2562 hw->phy.ops.write_reg_page(hw, BM_RAR_H(i),
2563 (u16)(mac_reg & 0xFFFF));
2564 hw->phy.ops.write_reg_page(hw, BM_RAR_CTRL(i),
2565 (u16)((mac_reg & E1000_RAH_AV)
2569 e1000_disable_phy_wakeup_reg_access_bm(hw, &phy_reg);
2572 hw->phy.ops.release(hw);
2575 #ifndef CRC32_OS_SUPPORT
2576 STATIC u32 e1000_calc_rx_da_crc(u8 mac[])
2578 u32 poly = 0xEDB88320; /* Polynomial for 802.3 CRC calculation */
2579 u32 i, j, mask, crc;
2581 DEBUGFUNC("e1000_calc_rx_da_crc");
2584 for (i = 0; i < 6; i++) {
2586 for (j = 8; j > 0; j--) {
2587 mask = (crc & 1) * (-1);
2588 crc = (crc >> 1) ^ (poly & mask);
2594 #endif /* CRC32_OS_SUPPORT */
2596 * e1000_lv_jumbo_workaround_ich8lan - required for jumbo frame operation
2598 * @hw: pointer to the HW structure
2599 * @enable: flag to enable/disable workaround when enabling/disabling jumbos
2601 s32 e1000_lv_jumbo_workaround_ich8lan(struct e1000_hw *hw, bool enable)
2603 s32 ret_val = E1000_SUCCESS;
2608 DEBUGFUNC("e1000_lv_jumbo_workaround_ich8lan");
2610 if (hw->mac.type < e1000_pch2lan)
2611 return E1000_SUCCESS;
2613 /* disable Rx path while enabling/disabling workaround */
2614 hw->phy.ops.read_reg(hw, PHY_REG(769, 20), &phy_reg);
2615 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(769, 20),
2616 phy_reg | (1 << 14));
2621 /* Write Rx addresses (rar_entry_count for RAL/H, and
2622 * SHRAL/H) and initial CRC values to the MAC
2624 for (i = 0; i < hw->mac.rar_entry_count; i++) {
2625 u8 mac_addr[ETH_ADDR_LEN] = {0};
2626 u32 addr_high, addr_low;
2628 addr_high = E1000_READ_REG(hw, E1000_RAH(i));
2629 if (!(addr_high & E1000_RAH_AV))
2631 addr_low = E1000_READ_REG(hw, E1000_RAL(i));
2632 mac_addr[0] = (addr_low & 0xFF);
2633 mac_addr[1] = ((addr_low >> 8) & 0xFF);
2634 mac_addr[2] = ((addr_low >> 16) & 0xFF);
2635 mac_addr[3] = ((addr_low >> 24) & 0xFF);
2636 mac_addr[4] = (addr_high & 0xFF);
2637 mac_addr[5] = ((addr_high >> 8) & 0xFF);
2639 #ifndef CRC32_OS_SUPPORT
2640 E1000_WRITE_REG(hw, E1000_PCH_RAICC(i),
2641 e1000_calc_rx_da_crc(mac_addr));
2642 #else /* CRC32_OS_SUPPORT */
2643 E1000_WRITE_REG(hw, E1000_PCH_RAICC(i),
2644 E1000_CRC32(ETH_ADDR_LEN, mac_addr));
2645 #endif /* CRC32_OS_SUPPORT */
2648 /* Write Rx addresses to the PHY */
2649 e1000_copy_rx_addrs_to_phy_ich8lan(hw);
2651 /* Enable jumbo frame workaround in the MAC */
2652 mac_reg = E1000_READ_REG(hw, E1000_FFLT_DBG);
2653 mac_reg &= ~(1 << 14);
2654 mac_reg |= (7 << 15);
2655 E1000_WRITE_REG(hw, E1000_FFLT_DBG, mac_reg);
2657 mac_reg = E1000_READ_REG(hw, E1000_RCTL);
2658 mac_reg |= E1000_RCTL_SECRC;
2659 E1000_WRITE_REG(hw, E1000_RCTL, mac_reg);
2661 ret_val = e1000_read_kmrn_reg_generic(hw,
2662 E1000_KMRNCTRLSTA_CTRL_OFFSET,
2666 ret_val = e1000_write_kmrn_reg_generic(hw,
2667 E1000_KMRNCTRLSTA_CTRL_OFFSET,
2671 ret_val = e1000_read_kmrn_reg_generic(hw,
2672 E1000_KMRNCTRLSTA_HD_CTRL,
2676 data &= ~(0xF << 8);
2678 ret_val = e1000_write_kmrn_reg_generic(hw,
2679 E1000_KMRNCTRLSTA_HD_CTRL,
2684 /* Enable jumbo frame workaround in the PHY */
2685 hw->phy.ops.read_reg(hw, PHY_REG(769, 23), &data);
2686 data &= ~(0x7F << 5);
2687 data |= (0x37 << 5);
2688 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(769, 23), data);
2691 hw->phy.ops.read_reg(hw, PHY_REG(769, 16), &data);
2693 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(769, 16), data);
2696 hw->phy.ops.read_reg(hw, PHY_REG(776, 20), &data);
2697 data &= ~(0x3FF << 2);
2698 data |= (E1000_TX_PTR_GAP << 2);
2699 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(776, 20), data);
2702 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(776, 23), 0xF100);
2705 hw->phy.ops.read_reg(hw, HV_PM_CTRL, &data);
2706 ret_val = hw->phy.ops.write_reg(hw, HV_PM_CTRL, data |
2711 /* Write MAC register values back to h/w defaults */
2712 mac_reg = E1000_READ_REG(hw, E1000_FFLT_DBG);
2713 mac_reg &= ~(0xF << 14);
2714 E1000_WRITE_REG(hw, E1000_FFLT_DBG, mac_reg);
2716 mac_reg = E1000_READ_REG(hw, E1000_RCTL);
2717 mac_reg &= ~E1000_RCTL_SECRC;
2718 E1000_WRITE_REG(hw, E1000_RCTL, mac_reg);
2720 ret_val = e1000_read_kmrn_reg_generic(hw,
2721 E1000_KMRNCTRLSTA_CTRL_OFFSET,
2725 ret_val = e1000_write_kmrn_reg_generic(hw,
2726 E1000_KMRNCTRLSTA_CTRL_OFFSET,
2730 ret_val = e1000_read_kmrn_reg_generic(hw,
2731 E1000_KMRNCTRLSTA_HD_CTRL,
2735 data &= ~(0xF << 8);
2737 ret_val = e1000_write_kmrn_reg_generic(hw,
2738 E1000_KMRNCTRLSTA_HD_CTRL,
2743 /* Write PHY register values back to h/w defaults */
2744 hw->phy.ops.read_reg(hw, PHY_REG(769, 23), &data);
2745 data &= ~(0x7F << 5);
2746 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(769, 23), data);
2749 hw->phy.ops.read_reg(hw, PHY_REG(769, 16), &data);
2751 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(769, 16), data);
2754 hw->phy.ops.read_reg(hw, PHY_REG(776, 20), &data);
2755 data &= ~(0x3FF << 2);
2757 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(776, 20), data);
2760 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(776, 23), 0x7E00);
2763 hw->phy.ops.read_reg(hw, HV_PM_CTRL, &data);
2764 ret_val = hw->phy.ops.write_reg(hw, HV_PM_CTRL, data &
2770 /* re-enable Rx path after enabling/disabling workaround */
2771 return hw->phy.ops.write_reg(hw, PHY_REG(769, 20), phy_reg &
2776 * e1000_lv_phy_workarounds_ich8lan - A series of Phy workarounds to be
2777 * done after every PHY reset.
2779 STATIC s32 e1000_lv_phy_workarounds_ich8lan(struct e1000_hw *hw)
2781 s32 ret_val = E1000_SUCCESS;
2783 DEBUGFUNC("e1000_lv_phy_workarounds_ich8lan");
2785 if (hw->mac.type != e1000_pch2lan)
2786 return E1000_SUCCESS;
2788 /* Set MDIO slow mode before any other MDIO access */
2789 ret_val = e1000_set_mdio_slow_mode_hv(hw);
2793 ret_val = hw->phy.ops.acquire(hw);
2796 /* set MSE higher to enable link to stay up when noise is high */
2797 ret_val = e1000_write_emi_reg_locked(hw, I82579_MSE_THRESHOLD, 0x0034);
2800 /* drop link after 5 times MSE threshold was reached */
2801 ret_val = e1000_write_emi_reg_locked(hw, I82579_MSE_LINK_DOWN, 0x0005);
2803 hw->phy.ops.release(hw);
2809 * e1000_k1_gig_workaround_lv - K1 Si workaround
2810 * @hw: pointer to the HW structure
2812 * Workaround to set the K1 beacon duration for 82579 parts in 10Mbps
2813 * Disable K1 for 1000 and 100 speeds
2815 STATIC s32 e1000_k1_workaround_lv(struct e1000_hw *hw)
2817 s32 ret_val = E1000_SUCCESS;
2820 DEBUGFUNC("e1000_k1_workaround_lv");
2822 if (hw->mac.type != e1000_pch2lan)
2823 return E1000_SUCCESS;
2825 /* Set K1 beacon duration based on 10Mbs speed */
2826 ret_val = hw->phy.ops.read_reg(hw, HV_M_STATUS, &status_reg);
2830 if ((status_reg & (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE))
2831 == (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE)) {
2833 (HV_M_STATUS_SPEED_1000 | HV_M_STATUS_SPEED_100)) {
2836 /* LV 1G/100 Packet drop issue wa */
2837 ret_val = hw->phy.ops.read_reg(hw, HV_PM_CTRL,
2841 pm_phy_reg &= ~HV_PM_CTRL_K1_ENABLE;
2842 ret_val = hw->phy.ops.write_reg(hw, HV_PM_CTRL,
2848 mac_reg = E1000_READ_REG(hw, E1000_FEXTNVM4);
2849 mac_reg &= ~E1000_FEXTNVM4_BEACON_DURATION_MASK;
2850 mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_16USEC;
2851 E1000_WRITE_REG(hw, E1000_FEXTNVM4, mac_reg);
2859 * e1000_gate_hw_phy_config_ich8lan - disable PHY config via hardware
2860 * @hw: pointer to the HW structure
2861 * @gate: boolean set to true to gate, false to ungate
2863 * Gate/ungate the automatic PHY configuration via hardware; perform
2864 * the configuration via software instead.
2866 STATIC void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate)
2870 DEBUGFUNC("e1000_gate_hw_phy_config_ich8lan");
2872 if (hw->mac.type < e1000_pch2lan)
2875 extcnf_ctrl = E1000_READ_REG(hw, E1000_EXTCNF_CTRL);
2878 extcnf_ctrl |= E1000_EXTCNF_CTRL_GATE_PHY_CFG;
2880 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_GATE_PHY_CFG;
2882 E1000_WRITE_REG(hw, E1000_EXTCNF_CTRL, extcnf_ctrl);
2886 * e1000_lan_init_done_ich8lan - Check for PHY config completion
2887 * @hw: pointer to the HW structure
2889 * Check the appropriate indication the MAC has finished configuring the
2890 * PHY after a software reset.
2892 STATIC void e1000_lan_init_done_ich8lan(struct e1000_hw *hw)
2894 u32 data, loop = E1000_ICH8_LAN_INIT_TIMEOUT;
2896 DEBUGFUNC("e1000_lan_init_done_ich8lan");
2898 /* Wait for basic configuration completes before proceeding */
2900 data = E1000_READ_REG(hw, E1000_STATUS);
2901 data &= E1000_STATUS_LAN_INIT_DONE;
2903 } while ((!data) && --loop);
2905 /* If basic configuration is incomplete before the above loop
2906 * count reaches 0, loading the configuration from NVM will
2907 * leave the PHY in a bad state possibly resulting in no link.
2910 DEBUGOUT("LAN_INIT_DONE not set, increase timeout\n");
2912 /* Clear the Init Done bit for the next init event */
2913 data = E1000_READ_REG(hw, E1000_STATUS);
2914 data &= ~E1000_STATUS_LAN_INIT_DONE;
2915 E1000_WRITE_REG(hw, E1000_STATUS, data);
2919 * e1000_post_phy_reset_ich8lan - Perform steps required after a PHY reset
2920 * @hw: pointer to the HW structure
2922 STATIC s32 e1000_post_phy_reset_ich8lan(struct e1000_hw *hw)
2924 s32 ret_val = E1000_SUCCESS;
2927 DEBUGFUNC("e1000_post_phy_reset_ich8lan");
2929 if (hw->phy.ops.check_reset_block(hw))
2930 return E1000_SUCCESS;
2932 /* Allow time for h/w to get to quiescent state after reset */
2935 /* Perform any necessary post-reset workarounds */
2936 switch (hw->mac.type) {
2938 ret_val = e1000_hv_phy_workarounds_ich8lan(hw);
2943 ret_val = e1000_lv_phy_workarounds_ich8lan(hw);
2951 /* Clear the host wakeup bit after lcd reset */
2952 if (hw->mac.type >= e1000_pchlan) {
2953 hw->phy.ops.read_reg(hw, BM_PORT_GEN_CFG, ®);
2954 reg &= ~BM_WUC_HOST_WU_BIT;
2955 hw->phy.ops.write_reg(hw, BM_PORT_GEN_CFG, reg);
2958 /* Configure the LCD with the extended configuration region in NVM */
2959 ret_val = e1000_sw_lcd_config_ich8lan(hw);
2963 /* Configure the LCD with the OEM bits in NVM */
2964 ret_val = e1000_oem_bits_config_ich8lan(hw, true);
2966 if (hw->mac.type == e1000_pch2lan) {
2967 /* Ungate automatic PHY configuration on non-managed 82579 */
2968 if (!(E1000_READ_REG(hw, E1000_FWSM) &
2969 E1000_ICH_FWSM_FW_VALID)) {
2971 e1000_gate_hw_phy_config_ich8lan(hw, false);
2974 /* Set EEE LPI Update Timer to 200usec */
2975 ret_val = hw->phy.ops.acquire(hw);
2978 ret_val = e1000_write_emi_reg_locked(hw,
2979 I82579_LPI_UPDATE_TIMER,
2981 hw->phy.ops.release(hw);
2988 * e1000_phy_hw_reset_ich8lan - Performs a PHY reset
2989 * @hw: pointer to the HW structure
2992 * This is a function pointer entry point called by drivers
2993 * or other shared routines.
2995 STATIC s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw)
2997 s32 ret_val = E1000_SUCCESS;
2999 DEBUGFUNC("e1000_phy_hw_reset_ich8lan");
3001 /* Gate automatic PHY configuration by hardware on non-managed 82579 */
3002 if ((hw->mac.type == e1000_pch2lan) &&
3003 !(E1000_READ_REG(hw, E1000_FWSM) & E1000_ICH_FWSM_FW_VALID))
3004 e1000_gate_hw_phy_config_ich8lan(hw, true);
3006 ret_val = e1000_phy_hw_reset_generic(hw);
3010 return e1000_post_phy_reset_ich8lan(hw);
3014 * e1000_set_lplu_state_pchlan - Set Low Power Link Up state
3015 * @hw: pointer to the HW structure
3016 * @active: true to enable LPLU, false to disable
3018 * Sets the LPLU state according to the active flag. For PCH, if OEM write
3019 * bit are disabled in the NVM, writing the LPLU bits in the MAC will not set
3020 * the phy speed. This function will manually set the LPLU bit and restart
3021 * auto-neg as hw would do. D3 and D0 LPLU will call the same function
3022 * since it configures the same bit.
3024 STATIC s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active)
3029 DEBUGFUNC("e1000_set_lplu_state_pchlan");
3030 ret_val = hw->phy.ops.read_reg(hw, HV_OEM_BITS, &oem_reg);
3035 oem_reg |= HV_OEM_BITS_LPLU;
3037 oem_reg &= ~HV_OEM_BITS_LPLU;
3039 if (!hw->phy.ops.check_reset_block(hw))
3040 oem_reg |= HV_OEM_BITS_RESTART_AN;
3042 return hw->phy.ops.write_reg(hw, HV_OEM_BITS, oem_reg);
3046 * e1000_set_d0_lplu_state_ich8lan - Set Low Power Linkup D0 state
3047 * @hw: pointer to the HW structure
3048 * @active: true to enable LPLU, false to disable
3050 * Sets the LPLU D0 state according to the active flag. When
3051 * activating LPLU this function also disables smart speed
3052 * and vice versa. LPLU will not be activated unless the
3053 * device autonegotiation advertisement meets standards of
3054 * either 10 or 10/100 or 10/100/1000 at all duplexes.
3055 * This is a function pointer entry point only called by
3056 * PHY setup routines.
3058 STATIC s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
3060 struct e1000_phy_info *phy = &hw->phy;
3062 s32 ret_val = E1000_SUCCESS;
3065 DEBUGFUNC("e1000_set_d0_lplu_state_ich8lan");
3067 if (phy->type == e1000_phy_ife)
3068 return E1000_SUCCESS;
3070 phy_ctrl = E1000_READ_REG(hw, E1000_PHY_CTRL);
3073 phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU;
3074 E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl);
3076 if (phy->type != e1000_phy_igp_3)
3077 return E1000_SUCCESS;
3079 /* Call gig speed drop workaround on LPLU before accessing
3082 if (hw->mac.type == e1000_ich8lan)
3083 e1000_gig_downshift_workaround_ich8lan(hw);
3085 /* When LPLU is enabled, we should disable SmartSpeed */
3086 ret_val = phy->ops.read_reg(hw,
3087 IGP01E1000_PHY_PORT_CONFIG,
3091 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
3092 ret_val = phy->ops.write_reg(hw,
3093 IGP01E1000_PHY_PORT_CONFIG,
3098 phy_ctrl &= ~E1000_PHY_CTRL_D0A_LPLU;
3099 E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl);
3101 if (phy->type != e1000_phy_igp_3)
3102 return E1000_SUCCESS;
3104 /* LPLU and SmartSpeed are mutually exclusive. LPLU is used
3105 * during Dx states where the power conservation is most
3106 * important. During driver activity we should enable
3107 * SmartSpeed, so performance is maintained.
3109 if (phy->smart_speed == e1000_smart_speed_on) {
3110 ret_val = phy->ops.read_reg(hw,
3111 IGP01E1000_PHY_PORT_CONFIG,
3116 data |= IGP01E1000_PSCFR_SMART_SPEED;
3117 ret_val = phy->ops.write_reg(hw,
3118 IGP01E1000_PHY_PORT_CONFIG,
3122 } else if (phy->smart_speed == e1000_smart_speed_off) {
3123 ret_val = phy->ops.read_reg(hw,
3124 IGP01E1000_PHY_PORT_CONFIG,
3129 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
3130 ret_val = phy->ops.write_reg(hw,
3131 IGP01E1000_PHY_PORT_CONFIG,
3138 return E1000_SUCCESS;
3142 * e1000_set_d3_lplu_state_ich8lan - Set Low Power Linkup D3 state
3143 * @hw: pointer to the HW structure
3144 * @active: true to enable LPLU, false to disable
3146 * Sets the LPLU D3 state according to the active flag. When
3147 * activating LPLU this function also disables smart speed
3148 * and vice versa. LPLU will not be activated unless the
3149 * device autonegotiation advertisement meets standards of
3150 * either 10 or 10/100 or 10/100/1000 at all duplexes.
3151 * This is a function pointer entry point only called by
3152 * PHY setup routines.
3154 STATIC s32 e1000_set_d3_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
3156 struct e1000_phy_info *phy = &hw->phy;
3158 s32 ret_val = E1000_SUCCESS;
3161 DEBUGFUNC("e1000_set_d3_lplu_state_ich8lan");
3163 phy_ctrl = E1000_READ_REG(hw, E1000_PHY_CTRL);
3166 phy_ctrl &= ~E1000_PHY_CTRL_NOND0A_LPLU;
3167 E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl);
3169 if (phy->type != e1000_phy_igp_3)
3170 return E1000_SUCCESS;
3172 /* LPLU and SmartSpeed are mutually exclusive. LPLU is used
3173 * during Dx states where the power conservation is most
3174 * important. During driver activity we should enable
3175 * SmartSpeed, so performance is maintained.
3177 if (phy->smart_speed == e1000_smart_speed_on) {
3178 ret_val = phy->ops.read_reg(hw,
3179 IGP01E1000_PHY_PORT_CONFIG,
3184 data |= IGP01E1000_PSCFR_SMART_SPEED;
3185 ret_val = phy->ops.write_reg(hw,
3186 IGP01E1000_PHY_PORT_CONFIG,
3190 } else if (phy->smart_speed == e1000_smart_speed_off) {
3191 ret_val = phy->ops.read_reg(hw,
3192 IGP01E1000_PHY_PORT_CONFIG,
3197 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
3198 ret_val = phy->ops.write_reg(hw,
3199 IGP01E1000_PHY_PORT_CONFIG,
3204 } else if ((phy->autoneg_advertised == E1000_ALL_SPEED_DUPLEX) ||
3205 (phy->autoneg_advertised == E1000_ALL_NOT_GIG) ||
3206 (phy->autoneg_advertised == E1000_ALL_10_SPEED)) {
3207 phy_ctrl |= E1000_PHY_CTRL_NOND0A_LPLU;
3208 E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl);
3210 if (phy->type != e1000_phy_igp_3)
3211 return E1000_SUCCESS;
3213 /* Call gig speed drop workaround on LPLU before accessing
3216 if (hw->mac.type == e1000_ich8lan)
3217 e1000_gig_downshift_workaround_ich8lan(hw);
3219 /* When LPLU is enabled, we should disable SmartSpeed */
3220 ret_val = phy->ops.read_reg(hw,
3221 IGP01E1000_PHY_PORT_CONFIG,
3226 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
3227 ret_val = phy->ops.write_reg(hw,
3228 IGP01E1000_PHY_PORT_CONFIG,
3236 * e1000_valid_nvm_bank_detect_ich8lan - finds out the valid bank 0 or 1
3237 * @hw: pointer to the HW structure
3238 * @bank: pointer to the variable that returns the active bank
3240 * Reads signature byte from the NVM using the flash access registers.
3241 * Word 0x13 bits 15:14 = 10b indicate a valid signature for that bank.
3243 STATIC s32 e1000_valid_nvm_bank_detect_ich8lan(struct e1000_hw *hw, u32 *bank)
3246 struct e1000_nvm_info *nvm = &hw->nvm;
3247 u32 bank1_offset = nvm->flash_bank_size * sizeof(u16);
3248 u32 act_offset = E1000_ICH_NVM_SIG_WORD * 2 + 1;
3253 DEBUGFUNC("e1000_valid_nvm_bank_detect_ich8lan");
3255 switch (hw->mac.type) {
3258 eecd = E1000_READ_REG(hw, E1000_EECD);
3259 if ((eecd & E1000_EECD_SEC1VAL_VALID_MASK) ==
3260 E1000_EECD_SEC1VAL_VALID_MASK) {
3261 if (eecd & E1000_EECD_SEC1VAL)
3266 return E1000_SUCCESS;
3268 DEBUGOUT("Unable to determine valid NVM bank via EEC - reading flash signature\n");
3271 /* set bank to 0 in case flash read fails */
3275 ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset,
3279 if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
3280 E1000_ICH_NVM_SIG_VALUE) {
3282 return E1000_SUCCESS;
3286 ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset +
3291 if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
3292 E1000_ICH_NVM_SIG_VALUE) {
3294 return E1000_SUCCESS;
3297 DEBUGOUT("ERROR: No valid NVM bank present\n");
3298 return -E1000_ERR_NVM;
3303 * e1000_read_nvm_ich8lan - Read word(s) from the NVM
3304 * @hw: pointer to the HW structure
3305 * @offset: The offset (in bytes) of the word(s) to read.
3306 * @words: Size of data to read in words
3307 * @data: Pointer to the word(s) to read at offset.
3309 * Reads a word(s) from the NVM using the flash access registers.
3311 STATIC s32 e1000_read_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
3314 struct e1000_nvm_info *nvm = &hw->nvm;
3315 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
3317 s32 ret_val = E1000_SUCCESS;
3321 DEBUGFUNC("e1000_read_nvm_ich8lan");
3323 if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
3325 DEBUGOUT("nvm parameter(s) out of bounds\n");
3326 ret_val = -E1000_ERR_NVM;
3330 nvm->ops.acquire(hw);
3332 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
3333 if (ret_val != E1000_SUCCESS) {
3334 DEBUGOUT("Could not detect valid bank, assuming bank 0\n");
3338 act_offset = (bank) ? nvm->flash_bank_size : 0;
3339 act_offset += offset;
3341 ret_val = E1000_SUCCESS;
3342 for (i = 0; i < words; i++) {
3343 if (dev_spec->shadow_ram[offset+i].modified) {
3344 data[i] = dev_spec->shadow_ram[offset+i].value;
3346 ret_val = e1000_read_flash_word_ich8lan(hw,
3355 nvm->ops.release(hw);
3359 DEBUGOUT1("NVM read error: %d\n", ret_val);
3365 * e1000_flash_cycle_init_ich8lan - Initialize flash
3366 * @hw: pointer to the HW structure
3368 * This function does initial flash setup so that a new read/write/erase cycle
3371 STATIC s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw)
3373 union ich8_hws_flash_status hsfsts;
3374 s32 ret_val = -E1000_ERR_NVM;
3376 DEBUGFUNC("e1000_flash_cycle_init_ich8lan");
3378 hsfsts.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
3380 /* Check if the flash descriptor is valid */
3381 if (!hsfsts.hsf_status.fldesvalid) {
3382 DEBUGOUT("Flash descriptor invalid. SW Sequencing must be used.\n");
3383 return -E1000_ERR_NVM;
3386 /* Clear FCERR and DAEL in hw status by writing 1 */
3387 hsfsts.hsf_status.flcerr = 1;
3388 hsfsts.hsf_status.dael = 1;
3389 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFSTS, hsfsts.regval);
3391 /* Either we should have a hardware SPI cycle in progress
3392 * bit to check against, in order to start a new cycle or
3393 * FDONE bit should be changed in the hardware so that it
3394 * is 1 after hardware reset, which can then be used as an
3395 * indication whether a cycle is in progress or has been
3399 if (!hsfsts.hsf_status.flcinprog) {
3400 /* There is no cycle running at present,
3401 * so we can start a cycle.
3402 * Begin by setting Flash Cycle Done.
3404 hsfsts.hsf_status.flcdone = 1;
3405 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFSTS, hsfsts.regval);
3406 ret_val = E1000_SUCCESS;
3410 /* Otherwise poll for sometime so the current
3411 * cycle has a chance to end before giving up.
3413 for (i = 0; i < ICH_FLASH_READ_COMMAND_TIMEOUT; i++) {
3414 hsfsts.regval = E1000_READ_FLASH_REG16(hw,
3416 if (!hsfsts.hsf_status.flcinprog) {
3417 ret_val = E1000_SUCCESS;
3422 if (ret_val == E1000_SUCCESS) {
3423 /* Successful in waiting for previous cycle to timeout,
3424 * now set the Flash Cycle Done.
3426 hsfsts.hsf_status.flcdone = 1;
3427 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFSTS,
3430 DEBUGOUT("Flash controller busy, cannot get access\n");
3438 * e1000_flash_cycle_ich8lan - Starts flash cycle (read/write/erase)
3439 * @hw: pointer to the HW structure
3440 * @timeout: maximum time to wait for completion
3442 * This function starts a flash cycle and waits for its completion.
3444 STATIC s32 e1000_flash_cycle_ich8lan(struct e1000_hw *hw, u32 timeout)
3446 union ich8_hws_flash_ctrl hsflctl;
3447 union ich8_hws_flash_status hsfsts;
3450 DEBUGFUNC("e1000_flash_cycle_ich8lan");
3452 /* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */
3453 hsflctl.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFCTL);
3454 hsflctl.hsf_ctrl.flcgo = 1;
3456 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFCTL, hsflctl.regval);
3458 /* wait till FDONE bit is set to 1 */
3460 hsfsts.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
3461 if (hsfsts.hsf_status.flcdone)
3464 } while (i++ < timeout);
3466 if (hsfsts.hsf_status.flcdone && !hsfsts.hsf_status.flcerr)
3467 return E1000_SUCCESS;
3469 return -E1000_ERR_NVM;
3473 * e1000_read_flash_word_ich8lan - Read word from flash
3474 * @hw: pointer to the HW structure
3475 * @offset: offset to data location
3476 * @data: pointer to the location for storing the data
3478 * Reads the flash word at offset into data. Offset is converted
3479 * to bytes before read.
3481 STATIC s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset,
3484 DEBUGFUNC("e1000_read_flash_word_ich8lan");
3487 return -E1000_ERR_NVM;
3489 /* Must convert offset into bytes. */
3492 return e1000_read_flash_data_ich8lan(hw, offset, 2, data);
3496 * e1000_read_flash_byte_ich8lan - Read byte from flash
3497 * @hw: pointer to the HW structure
3498 * @offset: The offset of the byte to read.
3499 * @data: Pointer to a byte to store the value read.
3501 * Reads a single byte from the NVM using the flash access registers.
3503 STATIC s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
3509 ret_val = e1000_read_flash_data_ich8lan(hw, offset, 1, &word);
3516 return E1000_SUCCESS;
3520 * e1000_read_flash_data_ich8lan - Read byte or word from NVM
3521 * @hw: pointer to the HW structure
3522 * @offset: The offset (in bytes) of the byte or word to read.
3523 * @size: Size of data to read, 1=byte 2=word
3524 * @data: Pointer to the word to store the value read.
3526 * Reads a byte or word from the NVM using the flash access registers.
3528 STATIC s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
3531 union ich8_hws_flash_status hsfsts;
3532 union ich8_hws_flash_ctrl hsflctl;
3533 u32 flash_linear_addr;
3535 s32 ret_val = -E1000_ERR_NVM;
3538 DEBUGFUNC("e1000_read_flash_data_ich8lan");
3540 if (size < 1 || size > 2 || offset > ICH_FLASH_LINEAR_ADDR_MASK)
3541 return -E1000_ERR_NVM;
3542 flash_linear_addr = ((ICH_FLASH_LINEAR_ADDR_MASK & offset) +
3543 hw->nvm.flash_base_addr);
3548 ret_val = e1000_flash_cycle_init_ich8lan(hw);
3549 if (ret_val != E1000_SUCCESS)
3551 hsflctl.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFCTL);
3553 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
3554 hsflctl.hsf_ctrl.fldbcount = size - 1;
3555 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_READ;
3556 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFCTL, hsflctl.regval);
3557 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FADDR, flash_linear_addr);
3559 ret_val = e1000_flash_cycle_ich8lan(hw,
3560 ICH_FLASH_READ_COMMAND_TIMEOUT);
3562 /* Check if FCERR is set to 1, if set to 1, clear it
3563 * and try the whole sequence a few more times, else
3564 * read in (shift in) the Flash Data0, the order is
3565 * least significant byte first msb to lsb
3567 if (ret_val == E1000_SUCCESS) {
3568 flash_data = E1000_READ_FLASH_REG(hw, ICH_FLASH_FDATA0);
3570 *data = (u8)(flash_data & 0x000000FF);
3572 *data = (u16)(flash_data & 0x0000FFFF);
3575 /* If we've gotten here, then things are probably
3576 * completely hosed, but if the error condition is
3577 * detected, it won't hurt to give it another try...
3578 * ICH_FLASH_CYCLE_REPEAT_COUNT times.
3580 hsfsts.regval = E1000_READ_FLASH_REG16(hw,
3582 if (hsfsts.hsf_status.flcerr) {
3583 /* Repeat for some time before giving up. */
3585 } else if (!hsfsts.hsf_status.flcdone) {
3586 DEBUGOUT("Timeout error - flash cycle did not complete.\n");
3590 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
3597 * e1000_write_nvm_ich8lan - Write word(s) to the NVM
3598 * @hw: pointer to the HW structure
3599 * @offset: The offset (in bytes) of the word(s) to write.
3600 * @words: Size of data to write in words
3601 * @data: Pointer to the word(s) to write at offset.
3603 * Writes a byte or word to the NVM using the flash access registers.
3605 STATIC s32 e1000_write_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
3608 struct e1000_nvm_info *nvm = &hw->nvm;
3609 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
3612 DEBUGFUNC("e1000_write_nvm_ich8lan");
3614 if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
3616 DEBUGOUT("nvm parameter(s) out of bounds\n");
3617 return -E1000_ERR_NVM;
3620 nvm->ops.acquire(hw);
3622 for (i = 0; i < words; i++) {
3623 dev_spec->shadow_ram[offset+i].modified = true;
3624 dev_spec->shadow_ram[offset+i].value = data[i];
3627 nvm->ops.release(hw);
3629 return E1000_SUCCESS;
3633 * e1000_update_nvm_checksum_ich8lan - Update the checksum for NVM
3634 * @hw: pointer to the HW structure
3636 * The NVM checksum is updated by calling the generic update_nvm_checksum,
3637 * which writes the checksum to the shadow ram. The changes in the shadow
3638 * ram are then committed to the EEPROM by processing each bank at a time
3639 * checking for the modified bit and writing only the pending changes.
3640 * After a successful commit, the shadow ram is cleared and is ready for
3643 STATIC s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw)
3645 struct e1000_nvm_info *nvm = &hw->nvm;
3646 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
3647 u32 i, act_offset, new_bank_offset, old_bank_offset, bank;
3651 DEBUGFUNC("e1000_update_nvm_checksum_ich8lan");
3653 ret_val = e1000_update_nvm_checksum_generic(hw);
3657 if (nvm->type != e1000_nvm_flash_sw)
3660 nvm->ops.acquire(hw);
3662 /* We're writing to the opposite bank so if we're on bank 1,
3663 * write to bank 0 etc. We also need to erase the segment that
3664 * is going to be written
3666 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
3667 if (ret_val != E1000_SUCCESS) {
3668 DEBUGOUT("Could not detect valid bank, assuming bank 0\n");
3673 new_bank_offset = nvm->flash_bank_size;
3674 old_bank_offset = 0;
3675 ret_val = e1000_erase_flash_bank_ich8lan(hw, 1);
3679 old_bank_offset = nvm->flash_bank_size;
3680 new_bank_offset = 0;
3681 ret_val = e1000_erase_flash_bank_ich8lan(hw, 0);
3685 for (i = 0; i < E1000_SHADOW_RAM_WORDS; i++) {
3686 if (dev_spec->shadow_ram[i].modified) {
3687 data = dev_spec->shadow_ram[i].value;
3689 ret_val = e1000_read_flash_word_ich8lan(hw, i +
3695 /* If the word is 0x13, then make sure the signature bits
3696 * (15:14) are 11b until the commit has completed.
3697 * This will allow us to write 10b which indicates the
3698 * signature is valid. We want to do this after the write
3699 * has completed so that we don't mark the segment valid
3700 * while the write is still in progress
3702 if (i == E1000_ICH_NVM_SIG_WORD)
3703 data |= E1000_ICH_NVM_SIG_MASK;
3705 /* Convert offset to bytes. */
3706 act_offset = (i + new_bank_offset) << 1;
3710 /* Write the bytes to the new bank. */
3711 ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
3718 ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
3725 /* Don't bother writing the segment valid bits if sector
3726 * programming failed.
3729 DEBUGOUT("Flash commit failed.\n");
3733 /* Finally validate the new segment by setting bit 15:14
3734 * to 10b in word 0x13 , this can be done without an
3735 * erase as well since these bits are 11 to start with
3736 * and we need to change bit 14 to 0b
3738 act_offset = new_bank_offset + E1000_ICH_NVM_SIG_WORD;
3739 ret_val = e1000_read_flash_word_ich8lan(hw, act_offset, &data);
3744 ret_val = e1000_retry_write_flash_byte_ich8lan(hw, act_offset * 2 + 1,
3749 /* And invalidate the previously valid segment by setting
3750 * its signature word (0x13) high_byte to 0b. This can be
3751 * done without an erase because flash erase sets all bits
3752 * to 1's. We can write 1's to 0's without an erase
3754 act_offset = (old_bank_offset + E1000_ICH_NVM_SIG_WORD) * 2 + 1;
3756 ret_val = e1000_retry_write_flash_byte_ich8lan(hw, act_offset, 0);
3761 /* Great! Everything worked, we can now clear the cached entries. */
3762 for (i = 0; i < E1000_SHADOW_RAM_WORDS; i++) {
3763 dev_spec->shadow_ram[i].modified = false;
3764 dev_spec->shadow_ram[i].value = 0xFFFF;
3768 nvm->ops.release(hw);
3770 /* Reload the EEPROM, or else modifications will not appear
3771 * until after the next adapter reset.
3774 nvm->ops.reload(hw);
3780 DEBUGOUT1("NVM update error: %d\n", ret_val);
3786 * e1000_validate_nvm_checksum_ich8lan - Validate EEPROM checksum
3787 * @hw: pointer to the HW structure
3789 * Check to see if checksum needs to be fixed by reading bit 6 in word 0x19.
3790 * If the bit is 0, that the EEPROM had been modified, but the checksum was not
3791 * calculated, in which case we need to calculate the checksum and set bit 6.
3793 STATIC s32 e1000_validate_nvm_checksum_ich8lan(struct e1000_hw *hw)
3798 u16 valid_csum_mask;
3800 DEBUGFUNC("e1000_validate_nvm_checksum_ich8lan");
3802 /* Read NVM and check Invalid Image CSUM bit. If this bit is 0,
3803 * the checksum needs to be fixed. This bit is an indication that
3804 * the NVM was prepared by OEM software and did not calculate
3805 * the checksum...a likely scenario.
3807 switch (hw->mac.type) {
3810 valid_csum_mask = NVM_COMPAT_VALID_CSUM;
3813 word = NVM_FUTURE_INIT_WORD1;
3814 valid_csum_mask = NVM_FUTURE_INIT_WORD1_VALID_CSUM;
3818 ret_val = hw->nvm.ops.read(hw, word, 1, &data);
3822 if (!(data & valid_csum_mask)) {
3823 data |= valid_csum_mask;
3824 ret_val = hw->nvm.ops.write(hw, word, 1, &data);
3827 ret_val = hw->nvm.ops.update(hw);
3832 return e1000_validate_nvm_checksum_generic(hw);
3836 * e1000_write_flash_data_ich8lan - Writes bytes to the NVM
3837 * @hw: pointer to the HW structure
3838 * @offset: The offset (in bytes) of the byte/word to read.
3839 * @size: Size of data to read, 1=byte 2=word
3840 * @data: The byte(s) to write to the NVM.
3842 * Writes one/two bytes to the NVM using the flash access registers.
3844 STATIC s32 e1000_write_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
3847 union ich8_hws_flash_status hsfsts;
3848 union ich8_hws_flash_ctrl hsflctl;
3849 u32 flash_linear_addr;
3854 DEBUGFUNC("e1000_write_ich8_data");
3856 if (size < 1 || size > 2 || offset > ICH_FLASH_LINEAR_ADDR_MASK)
3857 return -E1000_ERR_NVM;
3859 flash_linear_addr = ((ICH_FLASH_LINEAR_ADDR_MASK & offset) +
3860 hw->nvm.flash_base_addr);
3865 ret_val = e1000_flash_cycle_init_ich8lan(hw);
3866 if (ret_val != E1000_SUCCESS)
3868 hsflctl.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFCTL);
3870 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
3871 hsflctl.hsf_ctrl.fldbcount = size - 1;
3872 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_WRITE;
3873 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFCTL, hsflctl.regval);
3875 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FADDR, flash_linear_addr);
3878 flash_data = (u32)data & 0x00FF;
3880 flash_data = (u32)data;
3882 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FDATA0, flash_data);
3884 /* check if FCERR is set to 1 , if set to 1, clear it
3885 * and try the whole sequence a few more times else done
3888 e1000_flash_cycle_ich8lan(hw,
3889 ICH_FLASH_WRITE_COMMAND_TIMEOUT);
3890 if (ret_val == E1000_SUCCESS)
3893 /* If we're here, then things are most likely
3894 * completely hosed, but if the error condition
3895 * is detected, it won't hurt to give it another
3896 * try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
3898 hsfsts.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
3899 if (hsfsts.hsf_status.flcerr)
3900 /* Repeat for some time before giving up. */
3902 if (!hsfsts.hsf_status.flcdone) {
3903 DEBUGOUT("Timeout error - flash cycle did not complete.\n");
3906 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
3913 * e1000_write_flash_byte_ich8lan - Write a single byte to NVM
3914 * @hw: pointer to the HW structure
3915 * @offset: The index of the byte to read.
3916 * @data: The byte to write to the NVM.
3918 * Writes a single byte to the NVM using the flash access registers.
3920 STATIC s32 e1000_write_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
3923 u16 word = (u16)data;
3925 DEBUGFUNC("e1000_write_flash_byte_ich8lan");
3927 return e1000_write_flash_data_ich8lan(hw, offset, 1, word);
3933 * e1000_retry_write_flash_byte_ich8lan - Writes a single byte to NVM
3934 * @hw: pointer to the HW structure
3935 * @offset: The offset of the byte to write.
3936 * @byte: The byte to write to the NVM.
3938 * Writes a single byte to the NVM using the flash access registers.
3939 * Goes through a retry algorithm before giving up.
3941 STATIC s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw,
3942 u32 offset, u8 byte)
3945 u16 program_retries;
3947 DEBUGFUNC("e1000_retry_write_flash_byte_ich8lan");
3949 ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
3953 for (program_retries = 0; program_retries < 100; program_retries++) {
3954 DEBUGOUT2("Retrying Byte %2.2X at offset %u\n", byte, offset);
3956 ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
3957 if (ret_val == E1000_SUCCESS)
3960 if (program_retries == 100)
3961 return -E1000_ERR_NVM;
3963 return E1000_SUCCESS;
3967 * e1000_erase_flash_bank_ich8lan - Erase a bank (4k) from NVM
3968 * @hw: pointer to the HW structure
3969 * @bank: 0 for first bank, 1 for second bank, etc.
3971 * Erases the bank specified. Each bank is a 4k block. Banks are 0 based.
3972 * bank N is 4096 * N + flash_reg_addr.
3974 STATIC s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank)
3976 struct e1000_nvm_info *nvm = &hw->nvm;
3977 union ich8_hws_flash_status hsfsts;
3978 union ich8_hws_flash_ctrl hsflctl;
3979 u32 flash_linear_addr;
3980 /* bank size is in 16bit words - adjust to bytes */
3981 u32 flash_bank_size = nvm->flash_bank_size * 2;
3984 s32 j, iteration, sector_size;
3986 DEBUGFUNC("e1000_erase_flash_bank_ich8lan");
3988 hsfsts.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
3990 /* Determine HW Sector size: Read BERASE bits of hw flash status
3992 * 00: The Hw sector is 256 bytes, hence we need to erase 16
3993 * consecutive sectors. The start index for the nth Hw sector
3994 * can be calculated as = bank * 4096 + n * 256
3995 * 01: The Hw sector is 4K bytes, hence we need to erase 1 sector.
3996 * The start index for the nth Hw sector can be calculated
3998 * 10: The Hw sector is 8K bytes, nth sector = bank * 8192
3999 * (ich9 only, otherwise error condition)
4000 * 11: The Hw sector is 64K bytes, nth sector = bank * 65536
4002 switch (hsfsts.hsf_status.berasesz) {
4004 /* Hw sector size 256 */
4005 sector_size = ICH_FLASH_SEG_SIZE_256;
4006 iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_256;
4009 sector_size = ICH_FLASH_SEG_SIZE_4K;
4013 sector_size = ICH_FLASH_SEG_SIZE_8K;
4017 sector_size = ICH_FLASH_SEG_SIZE_64K;
4021 return -E1000_ERR_NVM;
4024 /* Start with the base address, then add the sector offset. */
4025 flash_linear_addr = hw->nvm.flash_base_addr;
4026 flash_linear_addr += (bank) ? flash_bank_size : 0;
4028 for (j = 0; j < iteration; j++) {
4030 u32 timeout = ICH_FLASH_ERASE_COMMAND_TIMEOUT;
4033 ret_val = e1000_flash_cycle_init_ich8lan(hw);
4037 /* Write a value 11 (block Erase) in Flash
4038 * Cycle field in hw flash control
4041 E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFCTL);
4043 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_ERASE;
4044 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFCTL,
4047 /* Write the last 24 bits of an index within the
4048 * block into Flash Linear address field in Flash
4051 flash_linear_addr += (j * sector_size);
4052 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FADDR,
4055 ret_val = e1000_flash_cycle_ich8lan(hw, timeout);
4056 if (ret_val == E1000_SUCCESS)
4059 /* Check if FCERR is set to 1. If 1,
4060 * clear it and try the whole sequence
4061 * a few more times else Done
4063 hsfsts.regval = E1000_READ_FLASH_REG16(hw,
4065 if (hsfsts.hsf_status.flcerr)
4066 /* repeat for some time before giving up */
4068 else if (!hsfsts.hsf_status.flcdone)
4070 } while (++count < ICH_FLASH_CYCLE_REPEAT_COUNT);
4073 return E1000_SUCCESS;
4077 * e1000_valid_led_default_ich8lan - Set the default LED settings
4078 * @hw: pointer to the HW structure
4079 * @data: Pointer to the LED settings
4081 * Reads the LED default settings from the NVM to data. If the NVM LED
4082 * settings is all 0's or F's, set the LED default to a valid LED default
4085 STATIC s32 e1000_valid_led_default_ich8lan(struct e1000_hw *hw, u16 *data)
4089 DEBUGFUNC("e1000_valid_led_default_ich8lan");
4091 ret_val = hw->nvm.ops.read(hw, NVM_ID_LED_SETTINGS, 1, data);
4093 DEBUGOUT("NVM Read Error\n");
4097 if (*data == ID_LED_RESERVED_0000 || *data == ID_LED_RESERVED_FFFF)
4098 *data = ID_LED_DEFAULT_ICH8LAN;
4100 return E1000_SUCCESS;
4104 * e1000_id_led_init_pchlan - store LED configurations
4105 * @hw: pointer to the HW structure
4107 * PCH does not control LEDs via the LEDCTL register, rather it uses
4108 * the PHY LED configuration register.
4110 * PCH also does not have an "always on" or "always off" mode which
4111 * complicates the ID feature. Instead of using the "on" mode to indicate
4112 * in ledctl_mode2 the LEDs to use for ID (see e1000_id_led_init_generic()),
4113 * use "link_up" mode. The LEDs will still ID on request if there is no
4114 * link based on logic in e1000_led_[on|off]_pchlan().
4116 STATIC s32 e1000_id_led_init_pchlan(struct e1000_hw *hw)
4118 struct e1000_mac_info *mac = &hw->mac;
4120 const u32 ledctl_on = E1000_LEDCTL_MODE_LINK_UP;
4121 const u32 ledctl_off = E1000_LEDCTL_MODE_LINK_UP | E1000_PHY_LED0_IVRT;
4122 u16 data, i, temp, shift;
4124 DEBUGFUNC("e1000_id_led_init_pchlan");
4126 /* Get default ID LED modes */
4127 ret_val = hw->nvm.ops.valid_led_default(hw, &data);
4131 mac->ledctl_default = E1000_READ_REG(hw, E1000_LEDCTL);
4132 mac->ledctl_mode1 = mac->ledctl_default;
4133 mac->ledctl_mode2 = mac->ledctl_default;
4135 for (i = 0; i < 4; i++) {
4136 temp = (data >> (i << 2)) & E1000_LEDCTL_LED0_MODE_MASK;
4139 case ID_LED_ON1_DEF2:
4140 case ID_LED_ON1_ON2:
4141 case ID_LED_ON1_OFF2:
4142 mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
4143 mac->ledctl_mode1 |= (ledctl_on << shift);
4145 case ID_LED_OFF1_DEF2:
4146 case ID_LED_OFF1_ON2:
4147 case ID_LED_OFF1_OFF2:
4148 mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
4149 mac->ledctl_mode1 |= (ledctl_off << shift);
4156 case ID_LED_DEF1_ON2:
4157 case ID_LED_ON1_ON2:
4158 case ID_LED_OFF1_ON2:
4159 mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
4160 mac->ledctl_mode2 |= (ledctl_on << shift);
4162 case ID_LED_DEF1_OFF2:
4163 case ID_LED_ON1_OFF2:
4164 case ID_LED_OFF1_OFF2:
4165 mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
4166 mac->ledctl_mode2 |= (ledctl_off << shift);
4174 return E1000_SUCCESS;
4178 * e1000_get_bus_info_ich8lan - Get/Set the bus type and width
4179 * @hw: pointer to the HW structure
4181 * ICH8 use the PCI Express bus, but does not contain a PCI Express Capability
4182 * register, so the the bus width is hard coded.
4184 STATIC s32 e1000_get_bus_info_ich8lan(struct e1000_hw *hw)
4186 struct e1000_bus_info *bus = &hw->bus;
4189 DEBUGFUNC("e1000_get_bus_info_ich8lan");
4191 ret_val = e1000_get_bus_info_pcie_generic(hw);
4193 /* ICH devices are "PCI Express"-ish. They have
4194 * a configuration space, but do not contain
4195 * PCI Express Capability registers, so bus width
4196 * must be hardcoded.
4198 if (bus->width == e1000_bus_width_unknown)
4199 bus->width = e1000_bus_width_pcie_x1;
4205 * e1000_reset_hw_ich8lan - Reset the hardware
4206 * @hw: pointer to the HW structure
4208 * Does a full reset of the hardware which includes a reset of the PHY and
4211 STATIC s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
4213 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
4218 DEBUGFUNC("e1000_reset_hw_ich8lan");
4220 /* Prevent the PCI-E bus from sticking if there is no TLP connection
4221 * on the last TLP read/write transaction when MAC is reset.
4223 ret_val = e1000_disable_pcie_master_generic(hw);
4225 DEBUGOUT("PCI-E Master disable polling has failed.\n");
4227 DEBUGOUT("Masking off all interrupts\n");
4228 E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
4230 /* Disable the Transmit and Receive units. Then delay to allow
4231 * any pending transactions to complete before we hit the MAC
4232 * with the global reset.
4234 E1000_WRITE_REG(hw, E1000_RCTL, 0);
4235 E1000_WRITE_REG(hw, E1000_TCTL, E1000_TCTL_PSP);
4236 E1000_WRITE_FLUSH(hw);
4240 /* Workaround for ICH8 bit corruption issue in FIFO memory */
4241 if (hw->mac.type == e1000_ich8lan) {
4242 /* Set Tx and Rx buffer allocation to 8k apiece. */
4243 E1000_WRITE_REG(hw, E1000_PBA, E1000_PBA_8K);
4244 /* Set Packet Buffer Size to 16k. */
4245 E1000_WRITE_REG(hw, E1000_PBS, E1000_PBS_16K);
4248 if (hw->mac.type == e1000_pchlan) {
4249 /* Save the NVM K1 bit setting*/
4250 ret_val = e1000_read_nvm(hw, E1000_NVM_K1_CONFIG, 1, &kum_cfg);
4254 if (kum_cfg & E1000_NVM_K1_ENABLE)
4255 dev_spec->nvm_k1_enabled = true;
4257 dev_spec->nvm_k1_enabled = false;
4260 ctrl = E1000_READ_REG(hw, E1000_CTRL);
4262 if (!hw->phy.ops.check_reset_block(hw)) {
4263 /* Full-chip reset requires MAC and PHY reset at the same
4264 * time to make sure the interface between MAC and the
4265 * external PHY is reset.
4267 ctrl |= E1000_CTRL_PHY_RST;
4269 /* Gate automatic PHY configuration by hardware on
4272 if ((hw->mac.type == e1000_pch2lan) &&
4273 !(E1000_READ_REG(hw, E1000_FWSM) & E1000_ICH_FWSM_FW_VALID))
4274 e1000_gate_hw_phy_config_ich8lan(hw, true);
4276 ret_val = e1000_acquire_swflag_ich8lan(hw);
4277 DEBUGOUT("Issuing a global reset to ich8lan\n");
4278 E1000_WRITE_REG(hw, E1000_CTRL, (ctrl | E1000_CTRL_RST));
4279 /* cannot issue a flush here because it hangs the hardware */
4282 /* Set Phy Config Counter to 50msec */
4283 if (hw->mac.type == e1000_pch2lan) {
4284 reg = E1000_READ_REG(hw, E1000_FEXTNVM3);
4285 reg &= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK;
4286 reg |= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC;
4287 E1000_WRITE_REG(hw, E1000_FEXTNVM3, reg);
4291 E1000_MUTEX_UNLOCK(&hw->dev_spec.ich8lan.swflag_mutex);
4293 if (ctrl & E1000_CTRL_PHY_RST) {
4294 ret_val = hw->phy.ops.get_cfg_done(hw);
4298 ret_val = e1000_post_phy_reset_ich8lan(hw);
4303 /* For PCH, this write will make sure that any noise
4304 * will be detected as a CRC error and be dropped rather than show up
4305 * as a bad packet to the DMA engine.
4307 if (hw->mac.type == e1000_pchlan)
4308 E1000_WRITE_REG(hw, E1000_CRC_OFFSET, 0x65656565);
4310 E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
4311 E1000_READ_REG(hw, E1000_ICR);
4313 reg = E1000_READ_REG(hw, E1000_KABGTXD);
4314 reg |= E1000_KABGTXD_BGSQLBIAS;
4315 E1000_WRITE_REG(hw, E1000_KABGTXD, reg);
4317 return E1000_SUCCESS;
4321 * e1000_init_hw_ich8lan - Initialize the hardware
4322 * @hw: pointer to the HW structure
4324 * Prepares the hardware for transmit and receive by doing the following:
4325 * - initialize hardware bits
4326 * - initialize LED identification
4327 * - setup receive address registers
4328 * - setup flow control
4329 * - setup transmit descriptors
4330 * - clear statistics
4332 STATIC s32 e1000_init_hw_ich8lan(struct e1000_hw *hw)
4334 struct e1000_mac_info *mac = &hw->mac;
4335 u32 ctrl_ext, txdctl, snoop;
4339 DEBUGFUNC("e1000_init_hw_ich8lan");
4341 e1000_initialize_hw_bits_ich8lan(hw);
4343 /* Initialize identification LED */
4344 ret_val = mac->ops.id_led_init(hw);
4345 /* An error is not fatal and we should not stop init due to this */
4347 DEBUGOUT("Error initializing identification LED\n");
4349 /* Setup the receive address. */
4350 e1000_init_rx_addrs_generic(hw, mac->rar_entry_count);
4352 /* Zero out the Multicast HASH table */
4353 DEBUGOUT("Zeroing the MTA\n");
4354 for (i = 0; i < mac->mta_reg_count; i++)
4355 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
4357 /* The 82578 Rx buffer will stall if wakeup is enabled in host and
4358 * the ME. Disable wakeup by clearing the host wakeup bit.
4359 * Reset the phy after disabling host wakeup to reset the Rx buffer.
4361 if (hw->phy.type == e1000_phy_82578) {
4362 hw->phy.ops.read_reg(hw, BM_PORT_GEN_CFG, &i);
4363 i &= ~BM_WUC_HOST_WU_BIT;
4364 hw->phy.ops.write_reg(hw, BM_PORT_GEN_CFG, i);
4365 ret_val = e1000_phy_hw_reset_ich8lan(hw);
4370 /* Setup link and flow control */
4371 ret_val = mac->ops.setup_link(hw);
4373 /* Set the transmit descriptor write-back policy for both queues */
4374 txdctl = E1000_READ_REG(hw, E1000_TXDCTL(0));
4375 txdctl = ((txdctl & ~E1000_TXDCTL_WTHRESH) |
4376 E1000_TXDCTL_FULL_TX_DESC_WB);
4377 txdctl = ((txdctl & ~E1000_TXDCTL_PTHRESH) |
4378 E1000_TXDCTL_MAX_TX_DESC_PREFETCH);
4379 E1000_WRITE_REG(hw, E1000_TXDCTL(0), txdctl);
4380 txdctl = E1000_READ_REG(hw, E1000_TXDCTL(1));
4381 txdctl = ((txdctl & ~E1000_TXDCTL_WTHRESH) |
4382 E1000_TXDCTL_FULL_TX_DESC_WB);
4383 txdctl = ((txdctl & ~E1000_TXDCTL_PTHRESH) |
4384 E1000_TXDCTL_MAX_TX_DESC_PREFETCH);
4385 E1000_WRITE_REG(hw, E1000_TXDCTL(1), txdctl);
4387 /* ICH8 has opposite polarity of no_snoop bits.
4388 * By default, we should use snoop behavior.
4390 if (mac->type == e1000_ich8lan)
4391 snoop = PCIE_ICH8_SNOOP_ALL;
4393 snoop = (u32) ~(PCIE_NO_SNOOP_ALL);
4394 e1000_set_pcie_no_snoop_generic(hw, snoop);
4396 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
4397 ctrl_ext |= E1000_CTRL_EXT_RO_DIS;
4398 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
4400 /* Clear all of the statistics registers (clear on read). It is
4401 * important that we do this after we have tried to establish link
4402 * because the symbol error count will increment wildly if there
4405 e1000_clear_hw_cntrs_ich8lan(hw);
4411 * e1000_initialize_hw_bits_ich8lan - Initialize required hardware bits
4412 * @hw: pointer to the HW structure
4414 * Sets/Clears required hardware bits necessary for correctly setting up the
4415 * hardware for transmit and receive.
4417 STATIC void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw)
4421 DEBUGFUNC("e1000_initialize_hw_bits_ich8lan");
4423 /* Extended Device Control */
4424 reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
4426 /* Enable PHY low-power state when MAC is at D3 w/o WoL */
4427 if (hw->mac.type >= e1000_pchlan)
4428 reg |= E1000_CTRL_EXT_PHYPDEN;
4429 E1000_WRITE_REG(hw, E1000_CTRL_EXT, reg);
4431 /* Transmit Descriptor Control 0 */
4432 reg = E1000_READ_REG(hw, E1000_TXDCTL(0));
4434 E1000_WRITE_REG(hw, E1000_TXDCTL(0), reg);
4436 /* Transmit Descriptor Control 1 */
4437 reg = E1000_READ_REG(hw, E1000_TXDCTL(1));
4439 E1000_WRITE_REG(hw, E1000_TXDCTL(1), reg);
4441 /* Transmit Arbitration Control 0 */
4442 reg = E1000_READ_REG(hw, E1000_TARC(0));
4443 if (hw->mac.type == e1000_ich8lan)
4444 reg |= (1 << 28) | (1 << 29);
4445 reg |= (1 << 23) | (1 << 24) | (1 << 26) | (1 << 27);
4446 E1000_WRITE_REG(hw, E1000_TARC(0), reg);
4448 /* Transmit Arbitration Control 1 */
4449 reg = E1000_READ_REG(hw, E1000_TARC(1));
4450 if (E1000_READ_REG(hw, E1000_TCTL) & E1000_TCTL_MULR)
4454 reg |= (1 << 24) | (1 << 26) | (1 << 30);
4455 E1000_WRITE_REG(hw, E1000_TARC(1), reg);
4458 if (hw->mac.type == e1000_ich8lan) {
4459 reg = E1000_READ_REG(hw, E1000_STATUS);
4461 E1000_WRITE_REG(hw, E1000_STATUS, reg);
4464 /* work-around descriptor data corruption issue during nfs v2 udp
4465 * traffic, just disable the nfs filtering capability
4467 reg = E1000_READ_REG(hw, E1000_RFCTL);
4468 reg |= (E1000_RFCTL_NFSW_DIS | E1000_RFCTL_NFSR_DIS);
4470 /* Disable IPv6 extension header parsing because some malformed
4471 * IPv6 headers can hang the Rx.
4473 if (hw->mac.type == e1000_ich8lan)
4474 reg |= (E1000_RFCTL_IPV6_EX_DIS | E1000_RFCTL_NEW_IPV6_EXT_DIS);
4475 E1000_WRITE_REG(hw, E1000_RFCTL, reg);
4477 /* Enable ECC on Lynxpoint */
4478 if (hw->mac.type == e1000_pch_lpt) {
4479 reg = E1000_READ_REG(hw, E1000_PBECCSTS);
4480 reg |= E1000_PBECCSTS_ECC_ENABLE;
4481 E1000_WRITE_REG(hw, E1000_PBECCSTS, reg);
4483 reg = E1000_READ_REG(hw, E1000_CTRL);
4484 reg |= E1000_CTRL_MEHE;
4485 E1000_WRITE_REG(hw, E1000_CTRL, reg);
4492 * e1000_setup_link_ich8lan - Setup flow control and link settings
4493 * @hw: pointer to the HW structure
4495 * Determines which flow control settings to use, then configures flow
4496 * control. Calls the appropriate media-specific link configuration
4497 * function. Assuming the adapter has a valid link partner, a valid link
4498 * should be established. Assumes the hardware has previously been reset
4499 * and the transmitter and receiver are not enabled.
4501 STATIC s32 e1000_setup_link_ich8lan(struct e1000_hw *hw)
4505 DEBUGFUNC("e1000_setup_link_ich8lan");
4507 if (hw->phy.ops.check_reset_block(hw))
4508 return E1000_SUCCESS;
4510 /* ICH parts do not have a word in the NVM to determine
4511 * the default flow control setting, so we explicitly
4514 if (hw->fc.requested_mode == e1000_fc_default)
4515 hw->fc.requested_mode = e1000_fc_full;
4517 /* Save off the requested flow control mode for use later. Depending
4518 * on the link partner's capabilities, we may or may not use this mode.
4520 hw->fc.current_mode = hw->fc.requested_mode;
4522 DEBUGOUT1("After fix-ups FlowControl is now = %x\n",
4523 hw->fc.current_mode);
4525 /* Continue to configure the copper link. */
4526 ret_val = hw->mac.ops.setup_physical_interface(hw);
4530 E1000_WRITE_REG(hw, E1000_FCTTV, hw->fc.pause_time);
4531 if ((hw->phy.type == e1000_phy_82578) ||
4532 (hw->phy.type == e1000_phy_82579) ||
4533 (hw->phy.type == e1000_phy_i217) ||
4534 (hw->phy.type == e1000_phy_82577)) {
4535 E1000_WRITE_REG(hw, E1000_FCRTV_PCH, hw->fc.refresh_time);
4537 ret_val = hw->phy.ops.write_reg(hw,
4538 PHY_REG(BM_PORT_CTRL_PAGE, 27),
4544 return e1000_set_fc_watermarks_generic(hw);
4548 * e1000_setup_copper_link_ich8lan - Configure MAC/PHY interface
4549 * @hw: pointer to the HW structure
4551 * Configures the kumeran interface to the PHY to wait the appropriate time
4552 * when polling the PHY, then call the generic setup_copper_link to finish
4553 * configuring the copper link.
4555 STATIC s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw)
4561 DEBUGFUNC("e1000_setup_copper_link_ich8lan");
4563 ctrl = E1000_READ_REG(hw, E1000_CTRL);
4564 ctrl |= E1000_CTRL_SLU;
4565 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
4566 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
4568 /* Set the mac to wait the maximum time between each iteration
4569 * and increase the max iterations when polling the phy;
4570 * this fixes erroneous timeouts at 10Mbps.
4572 ret_val = e1000_write_kmrn_reg_generic(hw, E1000_KMRNCTRLSTA_TIMEOUTS,
4576 ret_val = e1000_read_kmrn_reg_generic(hw,
4577 E1000_KMRNCTRLSTA_INBAND_PARAM,
4582 ret_val = e1000_write_kmrn_reg_generic(hw,
4583 E1000_KMRNCTRLSTA_INBAND_PARAM,
4588 switch (hw->phy.type) {
4589 case e1000_phy_igp_3:
4590 ret_val = e1000_copper_link_setup_igp(hw);
4595 case e1000_phy_82578:
4596 ret_val = e1000_copper_link_setup_m88(hw);
4600 case e1000_phy_82577:
4601 case e1000_phy_82579:
4602 ret_val = e1000_copper_link_setup_82577(hw);
4607 ret_val = hw->phy.ops.read_reg(hw, IFE_PHY_MDIX_CONTROL,
4612 reg_data &= ~IFE_PMC_AUTO_MDIX;
4614 switch (hw->phy.mdix) {
4616 reg_data &= ~IFE_PMC_FORCE_MDIX;
4619 reg_data |= IFE_PMC_FORCE_MDIX;
4623 reg_data |= IFE_PMC_AUTO_MDIX;
4626 ret_val = hw->phy.ops.write_reg(hw, IFE_PHY_MDIX_CONTROL,
4635 return e1000_setup_copper_link_generic(hw);
4639 * e1000_setup_copper_link_pch_lpt - Configure MAC/PHY interface
4640 * @hw: pointer to the HW structure
4642 * Calls the PHY specific link setup function and then calls the
4643 * generic setup_copper_link to finish configuring the link for
4644 * Lynxpoint PCH devices
4646 STATIC s32 e1000_setup_copper_link_pch_lpt(struct e1000_hw *hw)
4651 DEBUGFUNC("e1000_setup_copper_link_pch_lpt");
4653 ctrl = E1000_READ_REG(hw, E1000_CTRL);
4654 ctrl |= E1000_CTRL_SLU;
4655 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
4656 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
4658 ret_val = e1000_copper_link_setup_82577(hw);
4662 return e1000_setup_copper_link_generic(hw);
4666 * e1000_get_link_up_info_ich8lan - Get current link speed and duplex
4667 * @hw: pointer to the HW structure
4668 * @speed: pointer to store current link speed
4669 * @duplex: pointer to store the current link duplex
4671 * Calls the generic get_speed_and_duplex to retrieve the current link
4672 * information and then calls the Kumeran lock loss workaround for links at
4675 STATIC s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw, u16 *speed,
4680 DEBUGFUNC("e1000_get_link_up_info_ich8lan");
4682 ret_val = e1000_get_speed_and_duplex_copper_generic(hw, speed, duplex);
4686 if ((hw->mac.type == e1000_ich8lan) &&
4687 (hw->phy.type == e1000_phy_igp_3) &&
4688 (*speed == SPEED_1000)) {
4689 ret_val = e1000_kmrn_lock_loss_workaround_ich8lan(hw);
4696 * e1000_kmrn_lock_loss_workaround_ich8lan - Kumeran workaround
4697 * @hw: pointer to the HW structure
4699 * Work-around for 82566 Kumeran PCS lock loss:
4700 * On link status change (i.e. PCI reset, speed change) and link is up and
4702 * 0) if workaround is optionally disabled do nothing
4703 * 1) wait 1ms for Kumeran link to come up
4704 * 2) check Kumeran Diagnostic register PCS lock loss bit
4705 * 3) if not set the link is locked (all is good), otherwise...
4707 * 5) repeat up to 10 times
4708 * Note: this is only called for IGP3 copper when speed is 1gb.
4710 STATIC s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw)
4712 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
4718 DEBUGFUNC("e1000_kmrn_lock_loss_workaround_ich8lan");
4720 if (!dev_spec->kmrn_lock_loss_workaround_enabled)
4721 return E1000_SUCCESS;
4723 /* Make sure link is up before proceeding. If not just return.
4724 * Attempting this while link is negotiating fouled up link
4727 ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link);
4729 return E1000_SUCCESS;
4731 for (i = 0; i < 10; i++) {
4732 /* read once to clear */
4733 ret_val = hw->phy.ops.read_reg(hw, IGP3_KMRN_DIAG, &data);
4736 /* and again to get new status */
4737 ret_val = hw->phy.ops.read_reg(hw, IGP3_KMRN_DIAG, &data);
4741 /* check for PCS lock */
4742 if (!(data & IGP3_KMRN_DIAG_PCS_LOCK_LOSS))
4743 return E1000_SUCCESS;
4745 /* Issue PHY reset */
4746 hw->phy.ops.reset(hw);
4749 /* Disable GigE link negotiation */
4750 phy_ctrl = E1000_READ_REG(hw, E1000_PHY_CTRL);
4751 phy_ctrl |= (E1000_PHY_CTRL_GBE_DISABLE |
4752 E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
4753 E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl);
4755 /* Call gig speed drop workaround on Gig disable before accessing
4758 e1000_gig_downshift_workaround_ich8lan(hw);
4760 /* unable to acquire PCS lock */
4761 return -E1000_ERR_PHY;
4765 * e1000_set_kmrn_lock_loss_workaround_ich8lan - Set Kumeran workaround state
4766 * @hw: pointer to the HW structure
4767 * @state: boolean value used to set the current Kumeran workaround state
4769 * If ICH8, set the current Kumeran workaround state (enabled - true
4770 * /disabled - false).
4772 void e1000_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw,
4775 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
4777 DEBUGFUNC("e1000_set_kmrn_lock_loss_workaround_ich8lan");
4779 if (hw->mac.type != e1000_ich8lan) {
4780 DEBUGOUT("Workaround applies to ICH8 only.\n");
4784 dev_spec->kmrn_lock_loss_workaround_enabled = state;
4790 * e1000_ipg3_phy_powerdown_workaround_ich8lan - Power down workaround on D3
4791 * @hw: pointer to the HW structure
4793 * Workaround for 82566 power-down on D3 entry:
4794 * 1) disable gigabit link
4795 * 2) write VR power-down enable
4797 * Continue if successful, else issue LCD reset and repeat
4799 void e1000_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw)
4805 DEBUGFUNC("e1000_igp3_phy_powerdown_workaround_ich8lan");
4807 if (hw->phy.type != e1000_phy_igp_3)
4810 /* Try the workaround twice (if needed) */
4813 reg = E1000_READ_REG(hw, E1000_PHY_CTRL);
4814 reg |= (E1000_PHY_CTRL_GBE_DISABLE |
4815 E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
4816 E1000_WRITE_REG(hw, E1000_PHY_CTRL, reg);
4818 /* Call gig speed drop workaround on Gig disable before
4819 * accessing any PHY registers
4821 if (hw->mac.type == e1000_ich8lan)
4822 e1000_gig_downshift_workaround_ich8lan(hw);
4824 /* Write VR power-down enable */
4825 hw->phy.ops.read_reg(hw, IGP3_VR_CTRL, &data);
4826 data &= ~IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
4827 hw->phy.ops.write_reg(hw, IGP3_VR_CTRL,
4828 data | IGP3_VR_CTRL_MODE_SHUTDOWN);
4830 /* Read it back and test */
4831 hw->phy.ops.read_reg(hw, IGP3_VR_CTRL, &data);
4832 data &= IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
4833 if ((data == IGP3_VR_CTRL_MODE_SHUTDOWN) || retry)
4836 /* Issue PHY reset and repeat at most one more time */
4837 reg = E1000_READ_REG(hw, E1000_CTRL);
4838 E1000_WRITE_REG(hw, E1000_CTRL, reg | E1000_CTRL_PHY_RST);
4844 * e1000_gig_downshift_workaround_ich8lan - WoL from S5 stops working
4845 * @hw: pointer to the HW structure
4847 * Steps to take when dropping from 1Gb/s (eg. link cable removal (LSC),
4848 * LPLU, Gig disable, MDIC PHY reset):
4849 * 1) Set Kumeran Near-end loopback
4850 * 2) Clear Kumeran Near-end loopback
4851 * Should only be called for ICH8[m] devices with any 1G Phy.
4853 void e1000_gig_downshift_workaround_ich8lan(struct e1000_hw *hw)
4858 DEBUGFUNC("e1000_gig_downshift_workaround_ich8lan");
4860 if ((hw->mac.type != e1000_ich8lan) ||
4861 (hw->phy.type == e1000_phy_ife))
4864 ret_val = e1000_read_kmrn_reg_generic(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
4868 reg_data |= E1000_KMRNCTRLSTA_DIAG_NELPBK;
4869 ret_val = e1000_write_kmrn_reg_generic(hw,
4870 E1000_KMRNCTRLSTA_DIAG_OFFSET,
4874 reg_data &= ~E1000_KMRNCTRLSTA_DIAG_NELPBK;
4875 e1000_write_kmrn_reg_generic(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
4880 * e1000_suspend_workarounds_ich8lan - workarounds needed during S0->Sx
4881 * @hw: pointer to the HW structure
4883 * During S0 to Sx transition, it is possible the link remains at gig
4884 * instead of negotiating to a lower speed. Before going to Sx, set
4885 * 'Gig Disable' to force link speed negotiation to a lower speed based on
4886 * the LPLU setting in the NVM or custom setting. For PCH and newer parts,
4887 * the OEM bits PHY register (LED, GbE disable and LPLU configurations) also
4888 * needs to be written.
4889 * Parts that support (and are linked to a partner which support) EEE in
4890 * 100Mbps should disable LPLU since 100Mbps w/ EEE requires less power
4891 * than 10Mbps w/o EEE.
4893 void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw)
4895 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
4899 DEBUGFUNC("e1000_suspend_workarounds_ich8lan");
4901 phy_ctrl = E1000_READ_REG(hw, E1000_PHY_CTRL);
4902 phy_ctrl |= E1000_PHY_CTRL_GBE_DISABLE;
4904 if (hw->phy.type == e1000_phy_i217) {
4905 u16 phy_reg, device_id = hw->device_id;
4907 if ((device_id == E1000_DEV_ID_PCH_LPTLP_I218_LM) ||
4908 (device_id == E1000_DEV_ID_PCH_LPTLP_I218_V) ||
4909 (device_id == E1000_DEV_ID_PCH_I218_LM3) ||
4910 (device_id == E1000_DEV_ID_PCH_I218_V3)) {
4911 u32 fextnvm6 = E1000_READ_REG(hw, E1000_FEXTNVM6);
4913 E1000_WRITE_REG(hw, E1000_FEXTNVM6,
4914 fextnvm6 & ~E1000_FEXTNVM6_REQ_PLL_CLK);
4917 ret_val = hw->phy.ops.acquire(hw);
4921 if (!dev_spec->eee_disable) {
4925 e1000_read_emi_reg_locked(hw,
4926 I217_EEE_ADVERTISEMENT,
4931 /* Disable LPLU if both link partners support 100BaseT
4932 * EEE and 100Full is advertised on both ends of the
4933 * link, and enable Auto Enable LPI since there will
4934 * be no driver to enable LPI while in Sx.
4936 if ((eee_advert & I82579_EEE_100_SUPPORTED) &&
4937 (dev_spec->eee_lp_ability &
4938 I82579_EEE_100_SUPPORTED) &&
4939 (hw->phy.autoneg_advertised & ADVERTISE_100_FULL)) {
4940 phy_ctrl &= ~(E1000_PHY_CTRL_D0A_LPLU |
4941 E1000_PHY_CTRL_NOND0A_LPLU);
4943 /* Set Auto Enable LPI after link up */
4944 hw->phy.ops.read_reg_locked(hw,
4947 phy_reg |= I217_LPI_GPIO_CTRL_AUTO_EN_LPI;
4948 hw->phy.ops.write_reg_locked(hw,
4954 /* For i217 Intel Rapid Start Technology support,
4955 * when the system is going into Sx and no manageability engine
4956 * is present, the driver must configure proxy to reset only on
4957 * power good. LPI (Low Power Idle) state must also reset only
4958 * on power good, as well as the MTA (Multicast table array).
4959 * The SMBus release must also be disabled on LCD reset.
4961 if (!(E1000_READ_REG(hw, E1000_FWSM) &
4962 E1000_ICH_FWSM_FW_VALID)) {
4963 /* Enable proxy to reset only on power good. */
4964 hw->phy.ops.read_reg_locked(hw, I217_PROXY_CTRL,
4966 phy_reg |= I217_PROXY_CTRL_AUTO_DISABLE;
4967 hw->phy.ops.write_reg_locked(hw, I217_PROXY_CTRL,
4970 /* Set bit enable LPI (EEE) to reset only on
4973 hw->phy.ops.read_reg_locked(hw, I217_SxCTRL, &phy_reg);
4974 phy_reg |= I217_SxCTRL_ENABLE_LPI_RESET;
4975 hw->phy.ops.write_reg_locked(hw, I217_SxCTRL, phy_reg);
4977 /* Disable the SMB release on LCD reset. */
4978 hw->phy.ops.read_reg_locked(hw, I217_MEMPWR, &phy_reg);
4979 phy_reg &= ~I217_MEMPWR_DISABLE_SMB_RELEASE;
4980 hw->phy.ops.write_reg_locked(hw, I217_MEMPWR, phy_reg);
4983 /* Enable MTA to reset for Intel Rapid Start Technology
4986 hw->phy.ops.read_reg_locked(hw, I217_CGFREG, &phy_reg);
4987 phy_reg |= I217_CGFREG_ENABLE_MTA_RESET;
4988 hw->phy.ops.write_reg_locked(hw, I217_CGFREG, phy_reg);
4991 hw->phy.ops.release(hw);
4994 E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl);
4996 if (hw->mac.type == e1000_ich8lan)
4997 e1000_gig_downshift_workaround_ich8lan(hw);
4999 if (hw->mac.type >= e1000_pchlan) {
5000 e1000_oem_bits_config_ich8lan(hw, false);
5002 /* Reset PHY to activate OEM bits on 82577/8 */
5003 if (hw->mac.type == e1000_pchlan)
5004 e1000_phy_hw_reset_generic(hw);
5006 ret_val = hw->phy.ops.acquire(hw);
5009 e1000_write_smbus_addr(hw);
5010 hw->phy.ops.release(hw);
5017 * e1000_resume_workarounds_pchlan - workarounds needed during Sx->S0
5018 * @hw: pointer to the HW structure
5020 * During Sx to S0 transitions on non-managed devices or managed devices
5021 * on which PHY resets are not blocked, if the PHY registers cannot be
5022 * accessed properly by the s/w toggle the LANPHYPC value to power cycle
5024 * On i217, setup Intel Rapid Start Technology.
5026 u32 e1000_resume_workarounds_pchlan(struct e1000_hw *hw)
5030 DEBUGFUNC("e1000_resume_workarounds_pchlan");
5031 if (hw->mac.type < e1000_pch2lan)
5032 return E1000_SUCCESS;
5034 ret_val = e1000_init_phy_workarounds_pchlan(hw);
5036 DEBUGOUT1("Failed to init PHY flow ret_val=%d\n", ret_val);
5040 /* For i217 Intel Rapid Start Technology support when the system
5041 * is transitioning from Sx and no manageability engine is present
5042 * configure SMBus to restore on reset, disable proxy, and enable
5043 * the reset on MTA (Multicast table array).
5045 if (hw->phy.type == e1000_phy_i217) {
5048 ret_val = hw->phy.ops.acquire(hw);
5050 DEBUGOUT("Failed to setup iRST\n");
5054 /* Clear Auto Enable LPI after link up */
5055 hw->phy.ops.read_reg_locked(hw, I217_LPI_GPIO_CTRL, &phy_reg);
5056 phy_reg &= ~I217_LPI_GPIO_CTRL_AUTO_EN_LPI;
5057 hw->phy.ops.write_reg_locked(hw, I217_LPI_GPIO_CTRL, phy_reg);
5059 if (!(E1000_READ_REG(hw, E1000_FWSM) &
5060 E1000_ICH_FWSM_FW_VALID)) {
5061 /* Restore clear on SMB if no manageability engine
5064 ret_val = hw->phy.ops.read_reg_locked(hw, I217_MEMPWR,
5068 phy_reg |= I217_MEMPWR_DISABLE_SMB_RELEASE;
5069 hw->phy.ops.write_reg_locked(hw, I217_MEMPWR, phy_reg);
5072 hw->phy.ops.write_reg_locked(hw, I217_PROXY_CTRL, 0);
5074 /* Enable reset on MTA */
5075 ret_val = hw->phy.ops.read_reg_locked(hw, I217_CGFREG,
5079 phy_reg &= ~I217_CGFREG_ENABLE_MTA_RESET;
5080 hw->phy.ops.write_reg_locked(hw, I217_CGFREG, phy_reg);
5083 DEBUGOUT1("Error %d in resume workarounds\n", ret_val);
5084 hw->phy.ops.release(hw);
5087 return E1000_SUCCESS;
5091 * e1000_cleanup_led_ich8lan - Restore the default LED operation
5092 * @hw: pointer to the HW structure
5094 * Return the LED back to the default configuration.
5096 STATIC s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw)
5098 DEBUGFUNC("e1000_cleanup_led_ich8lan");
5100 if (hw->phy.type == e1000_phy_ife)
5101 return hw->phy.ops.write_reg(hw, IFE_PHY_SPECIAL_CONTROL_LED,
5104 E1000_WRITE_REG(hw, E1000_LEDCTL, hw->mac.ledctl_default);
5105 return E1000_SUCCESS;
5109 * e1000_led_on_ich8lan - Turn LEDs on
5110 * @hw: pointer to the HW structure
5114 STATIC s32 e1000_led_on_ich8lan(struct e1000_hw *hw)
5116 DEBUGFUNC("e1000_led_on_ich8lan");
5118 if (hw->phy.type == e1000_phy_ife)
5119 return hw->phy.ops.write_reg(hw, IFE_PHY_SPECIAL_CONTROL_LED,
5120 (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_ON));
5122 E1000_WRITE_REG(hw, E1000_LEDCTL, hw->mac.ledctl_mode2);
5123 return E1000_SUCCESS;
5127 * e1000_led_off_ich8lan - Turn LEDs off
5128 * @hw: pointer to the HW structure
5130 * Turn off the LEDs.
5132 STATIC s32 e1000_led_off_ich8lan(struct e1000_hw *hw)
5134 DEBUGFUNC("e1000_led_off_ich8lan");
5136 if (hw->phy.type == e1000_phy_ife)
5137 return hw->phy.ops.write_reg(hw, IFE_PHY_SPECIAL_CONTROL_LED,
5138 (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_OFF));
5140 E1000_WRITE_REG(hw, E1000_LEDCTL, hw->mac.ledctl_mode1);
5141 return E1000_SUCCESS;
5145 * e1000_setup_led_pchlan - Configures SW controllable LED
5146 * @hw: pointer to the HW structure
5148 * This prepares the SW controllable LED for use.
5150 STATIC s32 e1000_setup_led_pchlan(struct e1000_hw *hw)
5152 DEBUGFUNC("e1000_setup_led_pchlan");
5154 return hw->phy.ops.write_reg(hw, HV_LED_CONFIG,
5155 (u16)hw->mac.ledctl_mode1);
5159 * e1000_cleanup_led_pchlan - Restore the default LED operation
5160 * @hw: pointer to the HW structure
5162 * Return the LED back to the default configuration.
5164 STATIC s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw)
5166 DEBUGFUNC("e1000_cleanup_led_pchlan");
5168 return hw->phy.ops.write_reg(hw, HV_LED_CONFIG,
5169 (u16)hw->mac.ledctl_default);
5173 * e1000_led_on_pchlan - Turn LEDs on
5174 * @hw: pointer to the HW structure
5178 STATIC s32 e1000_led_on_pchlan(struct e1000_hw *hw)
5180 u16 data = (u16)hw->mac.ledctl_mode2;
5183 DEBUGFUNC("e1000_led_on_pchlan");
5185 /* If no link, then turn LED on by setting the invert bit
5186 * for each LED that's mode is "link_up" in ledctl_mode2.
5188 if (!(E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU)) {
5189 for (i = 0; i < 3; i++) {
5190 led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
5191 if ((led & E1000_PHY_LED0_MODE_MASK) !=
5192 E1000_LEDCTL_MODE_LINK_UP)
5194 if (led & E1000_PHY_LED0_IVRT)
5195 data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
5197 data |= (E1000_PHY_LED0_IVRT << (i * 5));
5201 return hw->phy.ops.write_reg(hw, HV_LED_CONFIG, data);
5205 * e1000_led_off_pchlan - Turn LEDs off
5206 * @hw: pointer to the HW structure
5208 * Turn off the LEDs.
5210 STATIC s32 e1000_led_off_pchlan(struct e1000_hw *hw)
5212 u16 data = (u16)hw->mac.ledctl_mode1;
5215 DEBUGFUNC("e1000_led_off_pchlan");
5217 /* If no link, then turn LED off by clearing the invert bit
5218 * for each LED that's mode is "link_up" in ledctl_mode1.
5220 if (!(E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU)) {
5221 for (i = 0; i < 3; i++) {
5222 led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
5223 if ((led & E1000_PHY_LED0_MODE_MASK) !=
5224 E1000_LEDCTL_MODE_LINK_UP)
5226 if (led & E1000_PHY_LED0_IVRT)
5227 data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
5229 data |= (E1000_PHY_LED0_IVRT << (i * 5));
5233 return hw->phy.ops.write_reg(hw, HV_LED_CONFIG, data);
5237 * e1000_get_cfg_done_ich8lan - Read config done bit after Full or PHY reset
5238 * @hw: pointer to the HW structure
5240 * Read appropriate register for the config done bit for completion status
5241 * and configure the PHY through s/w for EEPROM-less parts.
5243 * NOTE: some silicon which is EEPROM-less will fail trying to read the
5244 * config done bit, so only an error is logged and continues. If we were
5245 * to return with error, EEPROM-less silicon would not be able to be reset
5248 STATIC s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw)
5250 s32 ret_val = E1000_SUCCESS;
5254 DEBUGFUNC("e1000_get_cfg_done_ich8lan");
5256 e1000_get_cfg_done_generic(hw);
5258 /* Wait for indication from h/w that it has completed basic config */
5259 if (hw->mac.type >= e1000_ich10lan) {
5260 e1000_lan_init_done_ich8lan(hw);
5262 ret_val = e1000_get_auto_rd_done_generic(hw);
5264 /* When auto config read does not complete, do not
5265 * return with an error. This can happen in situations
5266 * where there is no eeprom and prevents getting link.
5268 DEBUGOUT("Auto Read Done did not complete\n");
5269 ret_val = E1000_SUCCESS;
5273 /* Clear PHY Reset Asserted bit */
5274 status = E1000_READ_REG(hw, E1000_STATUS);
5275 if (status & E1000_STATUS_PHYRA)
5276 E1000_WRITE_REG(hw, E1000_STATUS, status & ~E1000_STATUS_PHYRA);
5278 DEBUGOUT("PHY Reset Asserted not set - needs delay\n");
5280 /* If EEPROM is not marked present, init the IGP 3 PHY manually */
5281 if (hw->mac.type <= e1000_ich9lan) {
5282 if (!(E1000_READ_REG(hw, E1000_EECD) & E1000_EECD_PRES) &&
5283 (hw->phy.type == e1000_phy_igp_3)) {
5284 e1000_phy_init_script_igp3(hw);
5287 if (e1000_valid_nvm_bank_detect_ich8lan(hw, &bank)) {
5288 /* Maybe we should do a basic PHY config */
5289 DEBUGOUT("EEPROM not present\n");
5290 ret_val = -E1000_ERR_CONFIG;
5298 * e1000_power_down_phy_copper_ich8lan - Remove link during PHY power down
5299 * @hw: pointer to the HW structure
5301 * In the case of a PHY power down to save power, or to turn off link during a
5302 * driver unload, or wake on lan is not enabled, remove the link.
5304 STATIC void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw)
5306 /* If the management interface is not enabled, then power down */
5307 if (!(hw->mac.ops.check_mng_mode(hw) ||
5308 hw->phy.ops.check_reset_block(hw)))
5309 e1000_power_down_phy_copper(hw);
5315 * e1000_clear_hw_cntrs_ich8lan - Clear statistical counters
5316 * @hw: pointer to the HW structure
5318 * Clears hardware counters specific to the silicon family and calls
5319 * clear_hw_cntrs_generic to clear all general purpose counters.
5321 STATIC void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw)
5326 DEBUGFUNC("e1000_clear_hw_cntrs_ich8lan");
5328 e1000_clear_hw_cntrs_base_generic(hw);
5330 E1000_READ_REG(hw, E1000_ALGNERRC);
5331 E1000_READ_REG(hw, E1000_RXERRC);
5332 E1000_READ_REG(hw, E1000_TNCRS);
5333 E1000_READ_REG(hw, E1000_CEXTERR);
5334 E1000_READ_REG(hw, E1000_TSCTC);
5335 E1000_READ_REG(hw, E1000_TSCTFC);
5337 E1000_READ_REG(hw, E1000_MGTPRC);
5338 E1000_READ_REG(hw, E1000_MGTPDC);
5339 E1000_READ_REG(hw, E1000_MGTPTC);
5341 E1000_READ_REG(hw, E1000_IAC);
5342 E1000_READ_REG(hw, E1000_ICRXOC);
5344 /* Clear PHY statistics registers */
5345 if ((hw->phy.type == e1000_phy_82578) ||
5346 (hw->phy.type == e1000_phy_82579) ||
5347 (hw->phy.type == e1000_phy_i217) ||
5348 (hw->phy.type == e1000_phy_82577)) {
5349 ret_val = hw->phy.ops.acquire(hw);
5352 ret_val = hw->phy.ops.set_page(hw,
5353 HV_STATS_PAGE << IGP_PAGE_SHIFT);
5356 hw->phy.ops.read_reg_page(hw, HV_SCC_UPPER, &phy_data);
5357 hw->phy.ops.read_reg_page(hw, HV_SCC_LOWER, &phy_data);
5358 hw->phy.ops.read_reg_page(hw, HV_ECOL_UPPER, &phy_data);
5359 hw->phy.ops.read_reg_page(hw, HV_ECOL_LOWER, &phy_data);
5360 hw->phy.ops.read_reg_page(hw, HV_MCC_UPPER, &phy_data);
5361 hw->phy.ops.read_reg_page(hw, HV_MCC_LOWER, &phy_data);
5362 hw->phy.ops.read_reg_page(hw, HV_LATECOL_UPPER, &phy_data);
5363 hw->phy.ops.read_reg_page(hw, HV_LATECOL_LOWER, &phy_data);
5364 hw->phy.ops.read_reg_page(hw, HV_COLC_UPPER, &phy_data);
5365 hw->phy.ops.read_reg_page(hw, HV_COLC_LOWER, &phy_data);
5366 hw->phy.ops.read_reg_page(hw, HV_DC_UPPER, &phy_data);
5367 hw->phy.ops.read_reg_page(hw, HV_DC_LOWER, &phy_data);
5368 hw->phy.ops.read_reg_page(hw, HV_TNCRS_UPPER, &phy_data);
5369 hw->phy.ops.read_reg_page(hw, HV_TNCRS_LOWER, &phy_data);
5371 hw->phy.ops.release(hw);
5376 * e1000_configure_k0s_lpt - Configure K0s power state
5377 * @hw: pointer to the HW structure
5378 * @entry_latency: Tx idle period for entering K0s - valid values are 0 to 3.
5379 * 0 corresponds to 128ns, each value over 0 doubles the duration.
5380 * @min_time: Minimum Tx idle period allowed - valid values are 0 to 4.
5381 * 0 corresponds to 128ns, each value over 0 doubles the duration.
5383 * Configure the K1 power state based on the provided parameter.
5384 * Assumes semaphore already acquired.
5386 * Success returns 0, Failure returns:
5387 * -E1000_ERR_PHY (-2) in case of access error
5388 * -E1000_ERR_PARAM (-4) in case of parameters error
5390 s32 e1000_configure_k0s_lpt(struct e1000_hw *hw, u8 entry_latency, u8 min_time)
5395 DEBUGFUNC("e1000_configure_k0s_lpt");
5397 if (entry_latency > 3 || min_time > 4)
5398 return -E1000_ERR_PARAM;
5400 ret_val = e1000_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K0S_CTRL,
5405 /* for now don't touch the latency */
5406 kmrn_reg &= ~(E1000_KMRNCTRLSTA_K0S_CTRL_MIN_TIME_MASK);
5407 kmrn_reg |= ((min_time << E1000_KMRNCTRLSTA_K0S_CTRL_MIN_TIME_SHIFT));
5409 ret_val = e1000_write_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K0S_CTRL,
5414 return E1000_SUCCESS;