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_read_nvm_spt(struct e1000_hw *hw, u16 offset, u16 words,
99 STATIC s32 e1000_write_nvm_ich8lan(struct e1000_hw *hw, u16 offset,
100 u16 words, u16 *data);
101 STATIC s32 e1000_validate_nvm_checksum_ich8lan(struct e1000_hw *hw);
102 STATIC s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw);
103 STATIC s32 e1000_update_nvm_checksum_spt(struct e1000_hw *hw);
104 STATIC s32 e1000_valid_led_default_ich8lan(struct e1000_hw *hw,
106 STATIC s32 e1000_id_led_init_pchlan(struct e1000_hw *hw);
107 STATIC s32 e1000_get_bus_info_ich8lan(struct e1000_hw *hw);
108 STATIC s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw);
109 STATIC s32 e1000_init_hw_ich8lan(struct e1000_hw *hw);
110 STATIC s32 e1000_setup_link_ich8lan(struct e1000_hw *hw);
111 STATIC s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw);
112 STATIC s32 e1000_setup_copper_link_pch_lpt(struct e1000_hw *hw);
113 STATIC s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw,
114 u16 *speed, u16 *duplex);
115 STATIC s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw);
116 STATIC s32 e1000_led_on_ich8lan(struct e1000_hw *hw);
117 STATIC s32 e1000_led_off_ich8lan(struct e1000_hw *hw);
118 STATIC s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link);
119 STATIC s32 e1000_setup_led_pchlan(struct e1000_hw *hw);
120 STATIC s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw);
121 STATIC s32 e1000_led_on_pchlan(struct e1000_hw *hw);
122 STATIC s32 e1000_led_off_pchlan(struct e1000_hw *hw);
123 STATIC void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw);
124 STATIC s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank);
125 STATIC void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw);
126 STATIC s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw);
127 STATIC s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw,
128 u32 offset, u8 *data);
129 STATIC s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
131 STATIC s32 e1000_read_flash_data32_ich8lan(struct e1000_hw *hw, u32 offset,
133 STATIC s32 e1000_read_flash_dword_ich8lan(struct e1000_hw *hw,
134 u32 offset, u32 *data);
135 STATIC s32 e1000_write_flash_data32_ich8lan(struct e1000_hw *hw,
136 u32 offset, u32 data);
137 STATIC s32 e1000_retry_write_flash_dword_ich8lan(struct e1000_hw *hw,
138 u32 offset, u32 dword);
139 STATIC s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw,
140 u32 offset, u16 *data);
141 STATIC s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw,
142 u32 offset, u8 byte);
143 STATIC s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw);
144 STATIC void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw);
145 STATIC s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw);
146 STATIC s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw);
147 STATIC s32 e1000_k1_workaround_lv(struct e1000_hw *hw);
148 STATIC void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate);
150 /* ICH GbE Flash Hardware Sequencing Flash Status Register bit breakdown */
151 /* Offset 04h HSFSTS */
152 union ich8_hws_flash_status {
154 u16 flcdone:1; /* bit 0 Flash Cycle Done */
155 u16 flcerr:1; /* bit 1 Flash Cycle Error */
156 u16 dael:1; /* bit 2 Direct Access error Log */
157 u16 berasesz:2; /* bit 4:3 Sector Erase Size */
158 u16 flcinprog:1; /* bit 5 flash cycle in Progress */
159 u16 reserved1:2; /* bit 13:6 Reserved */
160 u16 reserved2:6; /* bit 13:6 Reserved */
161 u16 fldesvalid:1; /* bit 14 Flash Descriptor Valid */
162 u16 flockdn:1; /* bit 15 Flash Config Lock-Down */
167 /* ICH GbE Flash Hardware Sequencing Flash control Register bit breakdown */
168 /* Offset 06h FLCTL */
169 union ich8_hws_flash_ctrl {
170 struct ich8_hsflctl {
171 u16 flcgo:1; /* 0 Flash Cycle Go */
172 u16 flcycle:2; /* 2:1 Flash Cycle */
173 u16 reserved:5; /* 7:3 Reserved */
174 u16 fldbcount:2; /* 9:8 Flash Data Byte Count */
175 u16 flockdn:6; /* 15:10 Reserved */
180 /* ICH Flash Region Access Permissions */
181 union ich8_hws_flash_regacc {
183 u32 grra:8; /* 0:7 GbE region Read Access */
184 u32 grwa:8; /* 8:15 GbE region Write Access */
185 u32 gmrag:8; /* 23:16 GbE Master Read Access Grant */
186 u32 gmwag:8; /* 31:24 GbE Master Write Access Grant */
192 * e1000_phy_is_accessible_pchlan - Check if able to access PHY registers
193 * @hw: pointer to the HW structure
195 * Test access to the PHY registers by reading the PHY ID registers. If
196 * the PHY ID is already known (e.g. resume path) compare it with known ID,
197 * otherwise assume the read PHY ID is correct if it is valid.
199 * Assumes the sw/fw/hw semaphore is already acquired.
201 STATIC bool e1000_phy_is_accessible_pchlan(struct e1000_hw *hw)
209 for (retry_count = 0; retry_count < 2; retry_count++) {
210 ret_val = hw->phy.ops.read_reg_locked(hw, PHY_ID1, &phy_reg);
211 if (ret_val || (phy_reg == 0xFFFF))
213 phy_id = (u32)(phy_reg << 16);
215 ret_val = hw->phy.ops.read_reg_locked(hw, PHY_ID2, &phy_reg);
216 if (ret_val || (phy_reg == 0xFFFF)) {
220 phy_id |= (u32)(phy_reg & PHY_REVISION_MASK);
225 if (hw->phy.id == phy_id)
229 hw->phy.revision = (u32)(phy_reg & ~PHY_REVISION_MASK);
233 /* In case the PHY needs to be in mdio slow mode,
234 * set slow mode and try to get the PHY id again.
236 if (hw->mac.type < e1000_pch_lpt) {
237 hw->phy.ops.release(hw);
238 ret_val = e1000_set_mdio_slow_mode_hv(hw);
240 ret_val = e1000_get_phy_id(hw);
241 hw->phy.ops.acquire(hw);
247 if (hw->mac.type >= e1000_pch_lpt) {
248 /* Only unforce SMBus if ME is not active */
249 if (!(E1000_READ_REG(hw, E1000_FWSM) &
250 E1000_ICH_FWSM_FW_VALID)) {
251 /* Unforce SMBus mode in PHY */
252 hw->phy.ops.read_reg_locked(hw, CV_SMB_CTRL, &phy_reg);
253 phy_reg &= ~CV_SMB_CTRL_FORCE_SMBUS;
254 hw->phy.ops.write_reg_locked(hw, CV_SMB_CTRL, phy_reg);
256 /* Unforce SMBus mode in MAC */
257 mac_reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
258 mac_reg &= ~E1000_CTRL_EXT_FORCE_SMBUS;
259 E1000_WRITE_REG(hw, E1000_CTRL_EXT, mac_reg);
267 * e1000_toggle_lanphypc_pch_lpt - toggle the LANPHYPC pin value
268 * @hw: pointer to the HW structure
270 * Toggling the LANPHYPC pin value fully power-cycles the PHY and is
271 * used to reset the PHY to a quiescent state when necessary.
273 STATIC void e1000_toggle_lanphypc_pch_lpt(struct e1000_hw *hw)
277 DEBUGFUNC("e1000_toggle_lanphypc_pch_lpt");
279 /* Set Phy Config Counter to 50msec */
280 mac_reg = E1000_READ_REG(hw, E1000_FEXTNVM3);
281 mac_reg &= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK;
282 mac_reg |= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC;
283 E1000_WRITE_REG(hw, E1000_FEXTNVM3, mac_reg);
285 /* Toggle LANPHYPC Value bit */
286 mac_reg = E1000_READ_REG(hw, E1000_CTRL);
287 mac_reg |= E1000_CTRL_LANPHYPC_OVERRIDE;
288 mac_reg &= ~E1000_CTRL_LANPHYPC_VALUE;
289 E1000_WRITE_REG(hw, E1000_CTRL, mac_reg);
290 E1000_WRITE_FLUSH(hw);
292 mac_reg &= ~E1000_CTRL_LANPHYPC_OVERRIDE;
293 E1000_WRITE_REG(hw, E1000_CTRL, mac_reg);
294 E1000_WRITE_FLUSH(hw);
296 if (hw->mac.type < e1000_pch_lpt) {
303 } while (!(E1000_READ_REG(hw, E1000_CTRL_EXT) &
304 E1000_CTRL_EXT_LPCD) && count--);
311 * e1000_init_phy_workarounds_pchlan - PHY initialization workarounds
312 * @hw: pointer to the HW structure
314 * Workarounds/flow necessary for PHY initialization during driver load
317 STATIC s32 e1000_init_phy_workarounds_pchlan(struct e1000_hw *hw)
319 u32 mac_reg, fwsm = E1000_READ_REG(hw, E1000_FWSM);
322 DEBUGFUNC("e1000_init_phy_workarounds_pchlan");
324 /* Gate automatic PHY configuration by hardware on managed and
325 * non-managed 82579 and newer adapters.
327 e1000_gate_hw_phy_config_ich8lan(hw, true);
330 /* It is not possible to be certain of the current state of ULP
331 * so forcibly disable it.
333 hw->dev_spec.ich8lan.ulp_state = e1000_ulp_state_unknown;
335 #endif /* ULP_SUPPORT */
336 ret_val = hw->phy.ops.acquire(hw);
338 DEBUGOUT("Failed to initialize PHY flow\n");
342 /* The MAC-PHY interconnect may be in SMBus mode. If the PHY is
343 * inaccessible and resetting the PHY is not blocked, toggle the
344 * LANPHYPC Value bit to force the interconnect to PCIe mode.
346 switch (hw->mac.type) {
349 if (e1000_phy_is_accessible_pchlan(hw))
352 /* Before toggling LANPHYPC, see if PHY is accessible by
353 * forcing MAC to SMBus mode first.
355 mac_reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
356 mac_reg |= E1000_CTRL_EXT_FORCE_SMBUS;
357 E1000_WRITE_REG(hw, E1000_CTRL_EXT, mac_reg);
359 /* Wait 50 milliseconds for MAC to finish any retries
360 * that it might be trying to perform from previous
361 * attempts to acknowledge any phy read requests.
367 if (e1000_phy_is_accessible_pchlan(hw))
372 if ((hw->mac.type == e1000_pchlan) &&
373 (fwsm & E1000_ICH_FWSM_FW_VALID))
376 if (hw->phy.ops.check_reset_block(hw)) {
377 DEBUGOUT("Required LANPHYPC toggle blocked by ME\n");
378 ret_val = -E1000_ERR_PHY;
382 /* Toggle LANPHYPC Value bit */
383 e1000_toggle_lanphypc_pch_lpt(hw);
384 if (hw->mac.type >= e1000_pch_lpt) {
385 if (e1000_phy_is_accessible_pchlan(hw))
388 /* Toggling LANPHYPC brings the PHY out of SMBus mode
389 * so ensure that the MAC is also out of SMBus mode
391 mac_reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
392 mac_reg &= ~E1000_CTRL_EXT_FORCE_SMBUS;
393 E1000_WRITE_REG(hw, E1000_CTRL_EXT, mac_reg);
395 if (e1000_phy_is_accessible_pchlan(hw))
398 ret_val = -E1000_ERR_PHY;
405 hw->phy.ops.release(hw);
408 /* Check to see if able to reset PHY. Print error if not */
409 if (hw->phy.ops.check_reset_block(hw)) {
410 ERROR_REPORT("Reset blocked by ME\n");
414 /* Reset the PHY before any access to it. Doing so, ensures
415 * that the PHY is in a known good state before we read/write
416 * PHY registers. The generic reset is sufficient here,
417 * because we haven't determined the PHY type yet.
419 ret_val = e1000_phy_hw_reset_generic(hw);
423 /* On a successful reset, possibly need to wait for the PHY
424 * to quiesce to an accessible state before returning control
425 * to the calling function. If the PHY does not quiesce, then
426 * return E1000E_BLK_PHY_RESET, as this is the condition that
429 ret_val = hw->phy.ops.check_reset_block(hw);
431 ERROR_REPORT("ME blocked access to PHY after reset\n");
435 /* Ungate automatic PHY configuration on non-managed 82579 */
436 if ((hw->mac.type == e1000_pch2lan) &&
437 !(fwsm & E1000_ICH_FWSM_FW_VALID)) {
439 e1000_gate_hw_phy_config_ich8lan(hw, false);
446 * e1000_init_phy_params_pchlan - Initialize PHY function pointers
447 * @hw: pointer to the HW structure
449 * Initialize family-specific PHY parameters and function pointers.
451 STATIC s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw)
453 struct e1000_phy_info *phy = &hw->phy;
456 DEBUGFUNC("e1000_init_phy_params_pchlan");
459 phy->reset_delay_us = 100;
461 phy->ops.acquire = e1000_acquire_swflag_ich8lan;
462 phy->ops.check_reset_block = e1000_check_reset_block_ich8lan;
463 phy->ops.get_cfg_done = e1000_get_cfg_done_ich8lan;
464 phy->ops.set_page = e1000_set_page_igp;
465 phy->ops.read_reg = e1000_read_phy_reg_hv;
466 phy->ops.read_reg_locked = e1000_read_phy_reg_hv_locked;
467 phy->ops.read_reg_page = e1000_read_phy_reg_page_hv;
468 phy->ops.release = e1000_release_swflag_ich8lan;
469 phy->ops.reset = e1000_phy_hw_reset_ich8lan;
470 phy->ops.set_d0_lplu_state = e1000_set_lplu_state_pchlan;
471 phy->ops.set_d3_lplu_state = e1000_set_lplu_state_pchlan;
472 phy->ops.write_reg = e1000_write_phy_reg_hv;
473 phy->ops.write_reg_locked = e1000_write_phy_reg_hv_locked;
474 phy->ops.write_reg_page = e1000_write_phy_reg_page_hv;
475 phy->ops.power_up = e1000_power_up_phy_copper;
476 phy->ops.power_down = e1000_power_down_phy_copper_ich8lan;
477 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
479 phy->id = e1000_phy_unknown;
481 ret_val = e1000_init_phy_workarounds_pchlan(hw);
485 if (phy->id == e1000_phy_unknown)
486 switch (hw->mac.type) {
488 ret_val = e1000_get_phy_id(hw);
491 if ((phy->id != 0) && (phy->id != PHY_REVISION_MASK))
497 /* In case the PHY needs to be in mdio slow mode,
498 * set slow mode and try to get the PHY id again.
500 ret_val = e1000_set_mdio_slow_mode_hv(hw);
503 ret_val = e1000_get_phy_id(hw);
508 phy->type = e1000_get_phy_type_from_id(phy->id);
511 case e1000_phy_82577:
512 case e1000_phy_82579:
514 phy->ops.check_polarity = e1000_check_polarity_82577;
515 phy->ops.force_speed_duplex =
516 e1000_phy_force_speed_duplex_82577;
517 phy->ops.get_cable_length = e1000_get_cable_length_82577;
518 phy->ops.get_info = e1000_get_phy_info_82577;
519 phy->ops.commit = e1000_phy_sw_reset_generic;
521 case e1000_phy_82578:
522 phy->ops.check_polarity = e1000_check_polarity_m88;
523 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_m88;
524 phy->ops.get_cable_length = e1000_get_cable_length_m88;
525 phy->ops.get_info = e1000_get_phy_info_m88;
528 ret_val = -E1000_ERR_PHY;
536 * e1000_init_phy_params_ich8lan - Initialize PHY function pointers
537 * @hw: pointer to the HW structure
539 * Initialize family-specific PHY parameters and function pointers.
541 STATIC s32 e1000_init_phy_params_ich8lan(struct e1000_hw *hw)
543 struct e1000_phy_info *phy = &hw->phy;
547 DEBUGFUNC("e1000_init_phy_params_ich8lan");
550 phy->reset_delay_us = 100;
552 phy->ops.acquire = e1000_acquire_swflag_ich8lan;
553 phy->ops.check_reset_block = e1000_check_reset_block_ich8lan;
554 phy->ops.get_cable_length = e1000_get_cable_length_igp_2;
555 phy->ops.get_cfg_done = e1000_get_cfg_done_ich8lan;
556 phy->ops.read_reg = e1000_read_phy_reg_igp;
557 phy->ops.release = e1000_release_swflag_ich8lan;
558 phy->ops.reset = e1000_phy_hw_reset_ich8lan;
559 phy->ops.set_d0_lplu_state = e1000_set_d0_lplu_state_ich8lan;
560 phy->ops.set_d3_lplu_state = e1000_set_d3_lplu_state_ich8lan;
561 phy->ops.write_reg = e1000_write_phy_reg_igp;
562 phy->ops.power_up = e1000_power_up_phy_copper;
563 phy->ops.power_down = e1000_power_down_phy_copper_ich8lan;
565 /* We may need to do this twice - once for IGP and if that fails,
566 * we'll set BM func pointers and try again
568 ret_val = e1000_determine_phy_address(hw);
570 phy->ops.write_reg = e1000_write_phy_reg_bm;
571 phy->ops.read_reg = e1000_read_phy_reg_bm;
572 ret_val = e1000_determine_phy_address(hw);
574 DEBUGOUT("Cannot determine PHY addr. Erroring out\n");
580 while ((e1000_phy_unknown == e1000_get_phy_type_from_id(phy->id)) &&
583 ret_val = e1000_get_phy_id(hw);
590 case IGP03E1000_E_PHY_ID:
591 phy->type = e1000_phy_igp_3;
592 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
593 phy->ops.read_reg_locked = e1000_read_phy_reg_igp_locked;
594 phy->ops.write_reg_locked = e1000_write_phy_reg_igp_locked;
595 phy->ops.get_info = e1000_get_phy_info_igp;
596 phy->ops.check_polarity = e1000_check_polarity_igp;
597 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_igp;
600 case IFE_PLUS_E_PHY_ID:
602 phy->type = e1000_phy_ife;
603 phy->autoneg_mask = E1000_ALL_NOT_GIG;
604 phy->ops.get_info = e1000_get_phy_info_ife;
605 phy->ops.check_polarity = e1000_check_polarity_ife;
606 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_ife;
608 case BME1000_E_PHY_ID:
609 phy->type = e1000_phy_bm;
610 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
611 phy->ops.read_reg = e1000_read_phy_reg_bm;
612 phy->ops.write_reg = e1000_write_phy_reg_bm;
613 phy->ops.commit = e1000_phy_sw_reset_generic;
614 phy->ops.get_info = e1000_get_phy_info_m88;
615 phy->ops.check_polarity = e1000_check_polarity_m88;
616 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_m88;
619 return -E1000_ERR_PHY;
623 return E1000_SUCCESS;
627 * e1000_init_nvm_params_ich8lan - Initialize NVM function pointers
628 * @hw: pointer to the HW structure
630 * Initialize family-specific NVM parameters and function
633 STATIC s32 e1000_init_nvm_params_ich8lan(struct e1000_hw *hw)
635 struct e1000_nvm_info *nvm = &hw->nvm;
636 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
637 u32 gfpreg, sector_base_addr, sector_end_addr;
641 DEBUGFUNC("e1000_init_nvm_params_ich8lan");
643 nvm->type = e1000_nvm_flash_sw;
645 if (hw->mac.type >= e1000_pch_spt) {
646 /* in SPT, gfpreg doesn't exist. NVM size is taken from the
647 * STRAP register. This is because in SPT the GbE Flash region
648 * is no longer accessed through the flash registers. Instead,
649 * the mechanism has changed, and the Flash region access
650 * registers are now implemented in GbE memory space.
652 nvm->flash_base_addr = 0;
654 (((E1000_READ_REG(hw, E1000_STRAP) >> 1) & 0x1F) + 1)
655 * NVM_SIZE_MULTIPLIER;
656 nvm->flash_bank_size = nvm_size / 2;
657 /* Adjust to word count */
658 nvm->flash_bank_size /= sizeof(u16);
659 /* Set the base address for flash register access */
660 hw->flash_address = hw->hw_addr + E1000_FLASH_BASE_ADDR;
662 /* Can't read flash registers if register set isn't mapped. */
663 if (!hw->flash_address) {
664 DEBUGOUT("ERROR: Flash registers not mapped\n");
665 return -E1000_ERR_CONFIG;
668 gfpreg = E1000_READ_FLASH_REG(hw, ICH_FLASH_GFPREG);
670 /* sector_X_addr is a "sector"-aligned address (4096 bytes)
671 * Add 1 to sector_end_addr since this sector is included in
674 sector_base_addr = gfpreg & FLASH_GFPREG_BASE_MASK;
675 sector_end_addr = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK) + 1;
677 /* flash_base_addr is byte-aligned */
678 nvm->flash_base_addr = sector_base_addr
679 << FLASH_SECTOR_ADDR_SHIFT;
681 /* find total size of the NVM, then cut in half since the total
682 * size represents two separate NVM banks.
684 nvm->flash_bank_size = ((sector_end_addr - sector_base_addr)
685 << FLASH_SECTOR_ADDR_SHIFT);
686 nvm->flash_bank_size /= 2;
687 /* Adjust to word count */
688 nvm->flash_bank_size /= sizeof(u16);
691 nvm->word_size = E1000_SHADOW_RAM_WORDS;
693 /* Clear shadow ram */
694 for (i = 0; i < nvm->word_size; i++) {
695 dev_spec->shadow_ram[i].modified = false;
696 dev_spec->shadow_ram[i].value = 0xFFFF;
699 E1000_MUTEX_INIT(&dev_spec->nvm_mutex);
700 E1000_MUTEX_INIT(&dev_spec->swflag_mutex);
702 /* Function Pointers */
703 nvm->ops.acquire = e1000_acquire_nvm_ich8lan;
704 nvm->ops.release = e1000_release_nvm_ich8lan;
705 if (hw->mac.type >= e1000_pch_spt) {
706 nvm->ops.read = e1000_read_nvm_spt;
707 nvm->ops.update = e1000_update_nvm_checksum_spt;
709 nvm->ops.read = e1000_read_nvm_ich8lan;
710 nvm->ops.update = e1000_update_nvm_checksum_ich8lan;
712 nvm->ops.valid_led_default = e1000_valid_led_default_ich8lan;
713 nvm->ops.validate = e1000_validate_nvm_checksum_ich8lan;
714 nvm->ops.write = e1000_write_nvm_ich8lan;
716 return E1000_SUCCESS;
720 * e1000_init_mac_params_ich8lan - Initialize MAC function pointers
721 * @hw: pointer to the HW structure
723 * Initialize family-specific MAC parameters and function
726 STATIC s32 e1000_init_mac_params_ich8lan(struct e1000_hw *hw)
728 struct e1000_mac_info *mac = &hw->mac;
729 #if defined(QV_RELEASE) || !defined(NO_PCH_LPT_B0_SUPPORT)
731 #endif /* QV_RELEASE || !defined(NO_PCH_LPT_B0_SUPPORT) */
733 DEBUGFUNC("e1000_init_mac_params_ich8lan");
735 /* Set media type function pointer */
736 hw->phy.media_type = e1000_media_type_copper;
738 /* Set mta register count */
739 mac->mta_reg_count = 32;
740 /* Set rar entry count */
741 mac->rar_entry_count = E1000_ICH_RAR_ENTRIES;
742 if (mac->type == e1000_ich8lan)
743 mac->rar_entry_count--;
744 /* Set if part includes ASF firmware */
745 mac->asf_firmware_present = true;
747 mac->has_fwsm = true;
748 /* ARC subsystem not supported */
749 mac->arc_subsystem_valid = false;
750 /* Adaptive IFS supported */
751 mac->adaptive_ifs = true;
753 /* Function pointers */
755 /* bus type/speed/width */
756 mac->ops.get_bus_info = e1000_get_bus_info_ich8lan;
758 mac->ops.set_lan_id = e1000_set_lan_id_single_port;
760 mac->ops.reset_hw = e1000_reset_hw_ich8lan;
761 /* hw initialization */
762 mac->ops.init_hw = e1000_init_hw_ich8lan;
764 mac->ops.setup_link = e1000_setup_link_ich8lan;
765 /* physical interface setup */
766 mac->ops.setup_physical_interface = e1000_setup_copper_link_ich8lan;
768 mac->ops.check_for_link = e1000_check_for_copper_link_ich8lan;
770 mac->ops.get_link_up_info = e1000_get_link_up_info_ich8lan;
771 /* multicast address update */
772 mac->ops.update_mc_addr_list = e1000_update_mc_addr_list_generic;
773 /* clear hardware counters */
774 mac->ops.clear_hw_cntrs = e1000_clear_hw_cntrs_ich8lan;
776 /* LED and other operations */
781 /* check management mode */
782 mac->ops.check_mng_mode = e1000_check_mng_mode_ich8lan;
784 mac->ops.id_led_init = e1000_id_led_init_generic;
786 mac->ops.blink_led = e1000_blink_led_generic;
788 mac->ops.setup_led = e1000_setup_led_generic;
790 mac->ops.cleanup_led = e1000_cleanup_led_ich8lan;
791 /* turn on/off LED */
792 mac->ops.led_on = e1000_led_on_ich8lan;
793 mac->ops.led_off = e1000_led_off_ich8lan;
796 mac->rar_entry_count = E1000_PCH2_RAR_ENTRIES;
797 mac->ops.rar_set = e1000_rar_set_pch2lan;
801 #ifndef NO_NON_BLOCKING_PHY_MTA_UPDATE_SUPPORT
802 /* multicast address update for pch2 */
803 mac->ops.update_mc_addr_list =
804 e1000_update_mc_addr_list_pch2lan;
808 #if defined(QV_RELEASE) || !defined(NO_PCH_LPT_B0_SUPPORT)
809 /* save PCH revision_id */
810 e1000_read_pci_cfg(hw, E1000_PCI_REVISION_ID_REG, &pci_cfg);
811 /* SPT uses full byte for revision ID,
812 * as opposed to previous generations
814 if (hw->mac.type >= e1000_pch_spt)
815 hw->revision_id = (u8)(pci_cfg &= 0x00FF);
817 hw->revision_id = (u8)(pci_cfg &= 0x000F);
818 #endif /* QV_RELEASE || !defined(NO_PCH_LPT_B0_SUPPORT) */
819 /* check management mode */
820 mac->ops.check_mng_mode = e1000_check_mng_mode_pchlan;
822 mac->ops.id_led_init = e1000_id_led_init_pchlan;
824 mac->ops.setup_led = e1000_setup_led_pchlan;
826 mac->ops.cleanup_led = e1000_cleanup_led_pchlan;
827 /* turn on/off LED */
828 mac->ops.led_on = e1000_led_on_pchlan;
829 mac->ops.led_off = e1000_led_off_pchlan;
835 if (mac->type >= e1000_pch_lpt) {
836 mac->rar_entry_count = E1000_PCH_LPT_RAR_ENTRIES;
837 mac->ops.rar_set = e1000_rar_set_pch_lpt;
838 mac->ops.setup_physical_interface = e1000_setup_copper_link_pch_lpt;
841 /* Enable PCS Lock-loss workaround for ICH8 */
842 if (mac->type == e1000_ich8lan)
843 e1000_set_kmrn_lock_loss_workaround_ich8lan(hw, true);
845 return E1000_SUCCESS;
849 * __e1000_access_emi_reg_locked - Read/write EMI register
850 * @hw: pointer to the HW structure
851 * @addr: EMI address to program
852 * @data: pointer to value to read/write from/to the EMI address
853 * @read: boolean flag to indicate read or write
855 * This helper function assumes the SW/FW/HW Semaphore is already acquired.
857 STATIC s32 __e1000_access_emi_reg_locked(struct e1000_hw *hw, u16 address,
858 u16 *data, bool read)
862 DEBUGFUNC("__e1000_access_emi_reg_locked");
864 ret_val = hw->phy.ops.write_reg_locked(hw, I82579_EMI_ADDR, address);
869 ret_val = hw->phy.ops.read_reg_locked(hw, I82579_EMI_DATA,
872 ret_val = hw->phy.ops.write_reg_locked(hw, I82579_EMI_DATA,
879 * e1000_read_emi_reg_locked - Read Extended Management Interface register
880 * @hw: pointer to the HW structure
881 * @addr: EMI address to program
882 * @data: value to be read from the EMI address
884 * Assumes the SW/FW/HW Semaphore is already acquired.
886 s32 e1000_read_emi_reg_locked(struct e1000_hw *hw, u16 addr, u16 *data)
888 DEBUGFUNC("e1000_read_emi_reg_locked");
890 return __e1000_access_emi_reg_locked(hw, addr, data, true);
894 * e1000_write_emi_reg_locked - Write Extended Management Interface register
895 * @hw: pointer to the HW structure
896 * @addr: EMI address to program
897 * @data: value to be written to the EMI address
899 * Assumes the SW/FW/HW Semaphore is already acquired.
901 s32 e1000_write_emi_reg_locked(struct e1000_hw *hw, u16 addr, u16 data)
903 DEBUGFUNC("e1000_read_emi_reg_locked");
905 return __e1000_access_emi_reg_locked(hw, addr, &data, false);
909 * e1000_set_eee_pchlan - Enable/disable EEE support
910 * @hw: pointer to the HW structure
912 * Enable/disable EEE based on setting in dev_spec structure, the duplex of
913 * the link and the EEE capabilities of the link partner. The LPI Control
914 * register bits will remain set only if/when link is up.
916 * EEE LPI must not be asserted earlier than one second after link is up.
917 * On 82579, EEE LPI should not be enabled until such time otherwise there
918 * can be link issues with some switches. Other devices can have EEE LPI
919 * enabled immediately upon link up since they have a timer in hardware which
920 * prevents LPI from being asserted too early.
922 s32 e1000_set_eee_pchlan(struct e1000_hw *hw)
924 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
926 u16 lpa, pcs_status, adv, adv_addr, lpi_ctrl, data;
928 DEBUGFUNC("e1000_set_eee_pchlan");
930 switch (hw->phy.type) {
931 case e1000_phy_82579:
932 lpa = I82579_EEE_LP_ABILITY;
933 pcs_status = I82579_EEE_PCS_STATUS;
934 adv_addr = I82579_EEE_ADVERTISEMENT;
937 lpa = I217_EEE_LP_ABILITY;
938 pcs_status = I217_EEE_PCS_STATUS;
939 adv_addr = I217_EEE_ADVERTISEMENT;
942 return E1000_SUCCESS;
945 ret_val = hw->phy.ops.acquire(hw);
949 ret_val = hw->phy.ops.read_reg_locked(hw, I82579_LPI_CTRL, &lpi_ctrl);
953 /* Clear bits that enable EEE in various speeds */
954 lpi_ctrl &= ~I82579_LPI_CTRL_ENABLE_MASK;
956 /* Enable EEE if not disabled by user */
957 if (!dev_spec->eee_disable) {
958 /* Save off link partner's EEE ability */
959 ret_val = e1000_read_emi_reg_locked(hw, lpa,
960 &dev_spec->eee_lp_ability);
964 /* Read EEE advertisement */
965 ret_val = e1000_read_emi_reg_locked(hw, adv_addr, &adv);
969 /* Enable EEE only for speeds in which the link partner is
970 * EEE capable and for which we advertise EEE.
972 if (adv & dev_spec->eee_lp_ability & I82579_EEE_1000_SUPPORTED)
973 lpi_ctrl |= I82579_LPI_CTRL_1000_ENABLE;
975 if (adv & dev_spec->eee_lp_ability & I82579_EEE_100_SUPPORTED) {
976 hw->phy.ops.read_reg_locked(hw, PHY_LP_ABILITY, &data);
977 if (data & NWAY_LPAR_100TX_FD_CAPS)
978 lpi_ctrl |= I82579_LPI_CTRL_100_ENABLE;
980 /* EEE is not supported in 100Half, so ignore
981 * partner's EEE in 100 ability if full-duplex
984 dev_spec->eee_lp_ability &=
985 ~I82579_EEE_100_SUPPORTED;
989 if (hw->phy.type == e1000_phy_82579) {
990 ret_val = e1000_read_emi_reg_locked(hw, I82579_LPI_PLL_SHUT,
995 data &= ~I82579_LPI_100_PLL_SHUT;
996 ret_val = e1000_write_emi_reg_locked(hw, I82579_LPI_PLL_SHUT,
1000 /* R/Clr IEEE MMD 3.1 bits 11:10 - Tx/Rx LPI Received */
1001 ret_val = e1000_read_emi_reg_locked(hw, pcs_status, &data);
1005 ret_val = hw->phy.ops.write_reg_locked(hw, I82579_LPI_CTRL, lpi_ctrl);
1007 hw->phy.ops.release(hw);
1013 * e1000_k1_workaround_lpt_lp - K1 workaround on Lynxpoint-LP
1014 * @hw: pointer to the HW structure
1015 * @link: link up bool flag
1017 * When K1 is enabled for 1Gbps, the MAC can miss 2 DMA completion indications
1018 * preventing further DMA write requests. Workaround the issue by disabling
1019 * the de-assertion of the clock request when in 1Gpbs mode.
1020 * Also, set appropriate Tx re-transmission timeouts for 10 and 100Half link
1021 * speeds in order to avoid Tx hangs.
1023 STATIC s32 e1000_k1_workaround_lpt_lp(struct e1000_hw *hw, bool link)
1025 u32 fextnvm6 = E1000_READ_REG(hw, E1000_FEXTNVM6);
1026 u32 status = E1000_READ_REG(hw, E1000_STATUS);
1027 s32 ret_val = E1000_SUCCESS;
1030 if (link && (status & E1000_STATUS_SPEED_1000)) {
1031 ret_val = hw->phy.ops.acquire(hw);
1036 e1000_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
1042 e1000_write_kmrn_reg_locked(hw,
1043 E1000_KMRNCTRLSTA_K1_CONFIG,
1045 ~E1000_KMRNCTRLSTA_K1_ENABLE);
1051 E1000_WRITE_REG(hw, E1000_FEXTNVM6,
1052 fextnvm6 | E1000_FEXTNVM6_REQ_PLL_CLK);
1055 e1000_write_kmrn_reg_locked(hw,
1056 E1000_KMRNCTRLSTA_K1_CONFIG,
1059 hw->phy.ops.release(hw);
1061 /* clear FEXTNVM6 bit 8 on link down or 10/100 */
1062 fextnvm6 &= ~E1000_FEXTNVM6_REQ_PLL_CLK;
1064 if ((hw->phy.revision > 5) || !link ||
1065 ((status & E1000_STATUS_SPEED_100) &&
1066 (status & E1000_STATUS_FD)))
1067 goto update_fextnvm6;
1069 ret_val = hw->phy.ops.read_reg(hw, I217_INBAND_CTRL, ®);
1073 /* Clear link status transmit timeout */
1074 reg &= ~I217_INBAND_CTRL_LINK_STAT_TX_TIMEOUT_MASK;
1076 if (status & E1000_STATUS_SPEED_100) {
1077 /* Set inband Tx timeout to 5x10us for 100Half */
1078 reg |= 5 << I217_INBAND_CTRL_LINK_STAT_TX_TIMEOUT_SHIFT;
1080 /* Do not extend the K1 entry latency for 100Half */
1081 fextnvm6 &= ~E1000_FEXTNVM6_ENABLE_K1_ENTRY_CONDITION;
1083 /* Set inband Tx timeout to 50x10us for 10Full/Half */
1085 I217_INBAND_CTRL_LINK_STAT_TX_TIMEOUT_SHIFT;
1087 /* Extend the K1 entry latency for 10 Mbps */
1088 fextnvm6 |= E1000_FEXTNVM6_ENABLE_K1_ENTRY_CONDITION;
1091 ret_val = hw->phy.ops.write_reg(hw, I217_INBAND_CTRL, reg);
1096 E1000_WRITE_REG(hw, E1000_FEXTNVM6, fextnvm6);
1104 * e1000_enable_ulp_lpt_lp - configure Ultra Low Power mode for LynxPoint-LP
1105 * @hw: pointer to the HW structure
1106 * @to_sx: boolean indicating a system power state transition to Sx
1108 * When link is down, configure ULP mode to significantly reduce the power
1109 * to the PHY. If on a Manageability Engine (ME) enabled system, tell the
1110 * ME firmware to start the ULP configuration. If not on an ME enabled
1111 * system, configure the ULP mode by software.
1113 s32 e1000_enable_ulp_lpt_lp(struct e1000_hw *hw, bool to_sx)
1116 s32 ret_val = E1000_SUCCESS;
1120 if ((hw->mac.type < e1000_pch_lpt) ||
1121 (hw->device_id == E1000_DEV_ID_PCH_LPT_I217_LM) ||
1122 (hw->device_id == E1000_DEV_ID_PCH_LPT_I217_V) ||
1123 (hw->device_id == E1000_DEV_ID_PCH_I218_LM2) ||
1124 (hw->device_id == E1000_DEV_ID_PCH_I218_V2) ||
1125 (hw->dev_spec.ich8lan.ulp_state == e1000_ulp_state_on))
1130 /* Poll up to 5 seconds for Cable Disconnected indication */
1131 while (!(E1000_READ_REG(hw, E1000_FEXT) &
1132 E1000_FEXT_PHY_CABLE_DISCONNECTED)) {
1133 /* Bail if link is re-acquired */
1134 if (E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU)
1135 return -E1000_ERR_PHY;
1141 DEBUGOUT2("CABLE_DISCONNECTED %s set after %dmsec\n",
1142 (E1000_READ_REG(hw, E1000_FEXT) &
1143 E1000_FEXT_PHY_CABLE_DISCONNECTED) ? "" : "not",
1145 if (!(E1000_READ_REG(hw, E1000_FEXT) &
1146 E1000_FEXT_PHY_CABLE_DISCONNECTED))
1150 if (E1000_READ_REG(hw, E1000_FWSM) & E1000_ICH_FWSM_FW_VALID) {
1151 /* Request ME configure ULP mode in the PHY */
1152 mac_reg = E1000_READ_REG(hw, E1000_H2ME);
1153 mac_reg |= E1000_H2ME_ULP | E1000_H2ME_ENFORCE_SETTINGS;
1154 E1000_WRITE_REG(hw, E1000_H2ME, mac_reg);
1159 ret_val = hw->phy.ops.acquire(hw);
1163 /* During S0 Idle keep the phy in PCI-E mode */
1164 if (hw->dev_spec.ich8lan.smbus_disable)
1167 /* Force SMBus mode in PHY */
1168 ret_val = e1000_read_phy_reg_hv_locked(hw, CV_SMB_CTRL, &phy_reg);
1171 phy_reg |= CV_SMB_CTRL_FORCE_SMBUS;
1172 e1000_write_phy_reg_hv_locked(hw, CV_SMB_CTRL, phy_reg);
1174 /* Force SMBus mode in MAC */
1175 mac_reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
1176 mac_reg |= E1000_CTRL_EXT_FORCE_SMBUS;
1177 E1000_WRITE_REG(hw, E1000_CTRL_EXT, mac_reg);
1179 /* Si workaround for ULP entry flow on i127/rev6 h/w. Enable
1180 * LPLU and disable Gig speed when entering ULP
1182 if ((hw->phy.type == e1000_phy_i217) && (hw->phy.revision == 6)) {
1183 ret_val = e1000_read_phy_reg_hv_locked(hw, HV_OEM_BITS,
1189 phy_reg |= HV_OEM_BITS_LPLU | HV_OEM_BITS_GBE_DIS;
1191 ret_val = e1000_write_phy_reg_hv_locked(hw, HV_OEM_BITS,
1200 /* Change the 'Link Status Change' interrupt to trigger
1201 * on 'Cable Status Change'
1203 ret_val = e1000_read_kmrn_reg_locked(hw,
1204 E1000_KMRNCTRLSTA_OP_MODES,
1208 phy_reg |= E1000_KMRNCTRLSTA_OP_MODES_LSC2CSC;
1209 e1000_write_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_OP_MODES,
1213 /* Set Inband ULP Exit, Reset to SMBus mode and
1214 * Disable SMBus Release on PERST# in PHY
1216 ret_val = e1000_read_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, &phy_reg);
1219 phy_reg |= (I218_ULP_CONFIG1_RESET_TO_SMBUS |
1220 I218_ULP_CONFIG1_DISABLE_SMB_PERST);
1222 if (E1000_READ_REG(hw, E1000_WUFC) & E1000_WUFC_LNKC)
1223 phy_reg |= I218_ULP_CONFIG1_WOL_HOST;
1225 phy_reg &= ~I218_ULP_CONFIG1_WOL_HOST;
1227 phy_reg |= I218_ULP_CONFIG1_STICKY_ULP;
1228 phy_reg &= ~I218_ULP_CONFIG1_INBAND_EXIT;
1230 phy_reg |= I218_ULP_CONFIG1_INBAND_EXIT;
1231 phy_reg &= ~I218_ULP_CONFIG1_STICKY_ULP;
1232 phy_reg &= ~I218_ULP_CONFIG1_WOL_HOST;
1234 e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
1236 /* Set Disable SMBus Release on PERST# in MAC */
1237 mac_reg = E1000_READ_REG(hw, E1000_FEXTNVM7);
1238 mac_reg |= E1000_FEXTNVM7_DISABLE_SMB_PERST;
1239 E1000_WRITE_REG(hw, E1000_FEXTNVM7, mac_reg);
1241 /* Commit ULP changes in PHY by starting auto ULP configuration */
1242 phy_reg |= I218_ULP_CONFIG1_START;
1243 e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
1246 /* Disable Tx so that the MAC doesn't send any (buffered)
1247 * packets to the PHY.
1249 mac_reg = E1000_READ_REG(hw, E1000_TCTL);
1250 mac_reg &= ~E1000_TCTL_EN;
1251 E1000_WRITE_REG(hw, E1000_TCTL, mac_reg);
1254 if ((hw->phy.type == e1000_phy_i217) && (hw->phy.revision == 6) &&
1255 to_sx && (E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU)) {
1256 ret_val = e1000_write_phy_reg_hv_locked(hw, HV_OEM_BITS,
1263 hw->phy.ops.release(hw);
1266 DEBUGOUT1("Error in ULP enable flow: %d\n", ret_val);
1268 hw->dev_spec.ich8lan.ulp_state = e1000_ulp_state_on;
1274 * e1000_disable_ulp_lpt_lp - unconfigure Ultra Low Power mode for LynxPoint-LP
1275 * @hw: pointer to the HW structure
1276 * @force: boolean indicating whether or not to force disabling ULP
1278 * Un-configure ULP mode when link is up, the system is transitioned from
1279 * Sx or the driver is unloaded. If on a Manageability Engine (ME) enabled
1280 * system, poll for an indication from ME that ULP has been un-configured.
1281 * If not on an ME enabled system, un-configure the ULP mode by software.
1283 * During nominal operation, this function is called when link is acquired
1284 * to disable ULP mode (force=false); otherwise, for example when unloading
1285 * the driver or during Sx->S0 transitions, this is called with force=true
1286 * to forcibly disable ULP.
1288 * When the cable is plugged in while the device is in D0, a Cable Status
1289 * Change interrupt is generated which causes this function to be called
1290 * to partially disable ULP mode and restart autonegotiation. This function
1291 * is then called again due to the resulting Link Status Change interrupt
1292 * to finish cleaning up after the ULP flow.
1294 s32 e1000_disable_ulp_lpt_lp(struct e1000_hw *hw, bool force)
1296 s32 ret_val = E1000_SUCCESS;
1301 if ((hw->mac.type < e1000_pch_lpt) ||
1302 (hw->device_id == E1000_DEV_ID_PCH_LPT_I217_LM) ||
1303 (hw->device_id == E1000_DEV_ID_PCH_LPT_I217_V) ||
1304 (hw->device_id == E1000_DEV_ID_PCH_I218_LM2) ||
1305 (hw->device_id == E1000_DEV_ID_PCH_I218_V2) ||
1306 (hw->dev_spec.ich8lan.ulp_state == e1000_ulp_state_off))
1309 if (E1000_READ_REG(hw, E1000_FWSM) & E1000_ICH_FWSM_FW_VALID) {
1311 /* Request ME un-configure ULP mode in the PHY */
1312 mac_reg = E1000_READ_REG(hw, E1000_H2ME);
1313 mac_reg &= ~E1000_H2ME_ULP;
1314 mac_reg |= E1000_H2ME_ENFORCE_SETTINGS;
1315 E1000_WRITE_REG(hw, E1000_H2ME, mac_reg);
1318 /* Poll up to 300msec for ME to clear ULP_CFG_DONE. */
1319 while (E1000_READ_REG(hw, E1000_FWSM) &
1320 E1000_FWSM_ULP_CFG_DONE) {
1322 ret_val = -E1000_ERR_PHY;
1328 DEBUGOUT1("ULP_CONFIG_DONE cleared after %dmsec\n", i * 10);
1331 mac_reg = E1000_READ_REG(hw, E1000_H2ME);
1332 mac_reg &= ~E1000_H2ME_ENFORCE_SETTINGS;
1333 E1000_WRITE_REG(hw, E1000_H2ME, mac_reg);
1335 /* Clear H2ME.ULP after ME ULP configuration */
1336 mac_reg = E1000_READ_REG(hw, E1000_H2ME);
1337 mac_reg &= ~E1000_H2ME_ULP;
1338 E1000_WRITE_REG(hw, E1000_H2ME, mac_reg);
1340 /* Restore link speed advertisements and restart
1343 if (hw->mac.autoneg) {
1344 ret_val = e1000_phy_setup_autoneg(hw);
1348 ret_val = e1000_setup_copper_link_generic(hw);
1352 ret_val = e1000_oem_bits_config_ich8lan(hw, true);
1358 ret_val = hw->phy.ops.acquire(hw);
1362 /* Revert the change to the 'Link Status Change'
1363 * interrupt to trigger on 'Cable Status Change'
1365 ret_val = e1000_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_OP_MODES,
1369 phy_reg &= ~E1000_KMRNCTRLSTA_OP_MODES_LSC2CSC;
1370 e1000_write_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_OP_MODES, phy_reg);
1373 /* Toggle LANPHYPC Value bit */
1374 e1000_toggle_lanphypc_pch_lpt(hw);
1376 /* Unforce SMBus mode in PHY */
1377 ret_val = e1000_read_phy_reg_hv_locked(hw, CV_SMB_CTRL, &phy_reg);
1379 /* The MAC might be in PCIe mode, so temporarily force to
1380 * SMBus mode in order to access the PHY.
1382 mac_reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
1383 mac_reg |= E1000_CTRL_EXT_FORCE_SMBUS;
1384 E1000_WRITE_REG(hw, E1000_CTRL_EXT, mac_reg);
1388 ret_val = e1000_read_phy_reg_hv_locked(hw, CV_SMB_CTRL,
1393 phy_reg &= ~CV_SMB_CTRL_FORCE_SMBUS;
1394 e1000_write_phy_reg_hv_locked(hw, CV_SMB_CTRL, phy_reg);
1396 /* Unforce SMBus mode in MAC */
1397 mac_reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
1398 mac_reg &= ~E1000_CTRL_EXT_FORCE_SMBUS;
1399 E1000_WRITE_REG(hw, E1000_CTRL_EXT, mac_reg);
1401 /* When ULP mode was previously entered, K1 was disabled by the
1402 * hardware. Re-Enable K1 in the PHY when exiting ULP.
1404 ret_val = e1000_read_phy_reg_hv_locked(hw, HV_PM_CTRL, &phy_reg);
1407 phy_reg |= HV_PM_CTRL_K1_ENABLE;
1408 e1000_write_phy_reg_hv_locked(hw, HV_PM_CTRL, phy_reg);
1410 /* Clear ULP enabled configuration */
1411 ret_val = e1000_read_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, &phy_reg);
1414 /* CSC interrupt received due to ULP Indication */
1415 if ((phy_reg & I218_ULP_CONFIG1_IND) || force) {
1416 phy_reg &= ~(I218_ULP_CONFIG1_IND |
1417 I218_ULP_CONFIG1_STICKY_ULP |
1418 I218_ULP_CONFIG1_RESET_TO_SMBUS |
1419 I218_ULP_CONFIG1_WOL_HOST |
1420 I218_ULP_CONFIG1_INBAND_EXIT |
1421 I218_ULP_CONFIG1_EN_ULP_LANPHYPC |
1422 I218_ULP_CONFIG1_DIS_CLR_STICKY_ON_PERST |
1423 I218_ULP_CONFIG1_DISABLE_SMB_PERST);
1424 e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
1426 /* Commit ULP changes by starting auto ULP configuration */
1427 phy_reg |= I218_ULP_CONFIG1_START;
1428 e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
1430 /* Clear Disable SMBus Release on PERST# in MAC */
1431 mac_reg = E1000_READ_REG(hw, E1000_FEXTNVM7);
1432 mac_reg &= ~E1000_FEXTNVM7_DISABLE_SMB_PERST;
1433 E1000_WRITE_REG(hw, E1000_FEXTNVM7, mac_reg);
1436 hw->phy.ops.release(hw);
1438 if (hw->mac.autoneg)
1439 e1000_phy_setup_autoneg(hw);
1441 e1000_setup_copper_link_generic(hw);
1443 e1000_sw_lcd_config_ich8lan(hw);
1445 e1000_oem_bits_config_ich8lan(hw, true);
1447 /* Set ULP state to unknown and return non-zero to
1448 * indicate no link (yet) and re-enter on the next LSC
1449 * to finish disabling ULP flow.
1451 hw->dev_spec.ich8lan.ulp_state =
1452 e1000_ulp_state_unknown;
1459 mac_reg = E1000_READ_REG(hw, E1000_TCTL);
1460 mac_reg |= E1000_TCTL_EN;
1461 E1000_WRITE_REG(hw, E1000_TCTL, mac_reg);
1464 hw->phy.ops.release(hw);
1466 hw->phy.ops.reset(hw);
1471 DEBUGOUT1("Error in ULP disable flow: %d\n", ret_val);
1473 hw->dev_spec.ich8lan.ulp_state = e1000_ulp_state_off;
1478 #endif /* ULP_SUPPORT */
1482 * e1000_check_for_copper_link_ich8lan - Check for link (Copper)
1483 * @hw: pointer to the HW structure
1485 * Checks to see of the link status of the hardware has changed. If a
1486 * change in link status has been detected, then we read the PHY registers
1487 * to get the current speed/duplex if link exists.
1489 STATIC s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw)
1491 struct e1000_mac_info *mac = &hw->mac;
1492 s32 ret_val, tipg_reg = 0;
1493 u16 emi_addr, emi_val = 0;
1497 DEBUGFUNC("e1000_check_for_copper_link_ich8lan");
1499 /* We only want to go out to the PHY registers to see if Auto-Neg
1500 * has completed and/or if our link status has changed. The
1501 * get_link_status flag is set upon receiving a Link Status
1502 * Change or Rx Sequence Error interrupt.
1504 if (!mac->get_link_status)
1505 return E1000_SUCCESS;
1507 if ((hw->mac.type < e1000_pch_lpt) ||
1508 (hw->device_id == E1000_DEV_ID_PCH_LPT_I217_LM) ||
1509 (hw->device_id == E1000_DEV_ID_PCH_LPT_I217_V)) {
1510 /* First we want to see if the MII Status Register reports
1511 * link. If so, then we want to get the current speed/duplex
1514 ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link);
1518 /* Check the MAC's STATUS register to determine link state
1519 * since the PHY could be inaccessible while in ULP mode.
1521 link = !!(E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU);
1523 ret_val = e1000_disable_ulp_lpt_lp(hw, false);
1525 ret_val = e1000_enable_ulp_lpt_lp(hw, false);
1530 if (hw->mac.type == e1000_pchlan) {
1531 ret_val = e1000_k1_gig_workaround_hv(hw, link);
1536 /* When connected at 10Mbps half-duplex, some parts are excessively
1537 * aggressive resulting in many collisions. To avoid this, increase
1538 * the IPG and reduce Rx latency in the PHY.
1540 if ((hw->mac.type >= e1000_pch2lan) && link) {
1543 e1000_get_speed_and_duplex_copper_generic(hw, &speed, &duplex);
1544 tipg_reg = E1000_READ_REG(hw, E1000_TIPG);
1545 tipg_reg &= ~E1000_TIPG_IPGT_MASK;
1547 if (duplex == HALF_DUPLEX && speed == SPEED_10) {
1549 /* Reduce Rx latency in analog PHY */
1551 } else if (hw->mac.type >= e1000_pch_spt &&
1552 duplex == FULL_DUPLEX && speed != SPEED_1000) {
1556 /* Roll back the default values */
1561 E1000_WRITE_REG(hw, E1000_TIPG, tipg_reg);
1563 ret_val = hw->phy.ops.acquire(hw);
1567 if (hw->mac.type == e1000_pch2lan)
1568 emi_addr = I82579_RX_CONFIG;
1570 emi_addr = I217_RX_CONFIG;
1571 ret_val = e1000_write_emi_reg_locked(hw, emi_addr, emi_val);
1574 if (hw->mac.type >= e1000_pch_lpt) {
1577 hw->phy.ops.read_reg_locked(hw, I217_PLL_CLOCK_GATE_REG,
1579 phy_reg &= ~I217_PLL_CLOCK_GATE_MASK;
1580 if (speed == SPEED_100 || speed == SPEED_10)
1584 hw->phy.ops.write_reg_locked(hw,
1585 I217_PLL_CLOCK_GATE_REG,
1588 if (speed == SPEED_1000) {
1589 hw->phy.ops.read_reg_locked(hw, HV_PM_CTRL,
1592 phy_reg |= HV_PM_CTRL_K1_CLK_REQ;
1594 hw->phy.ops.write_reg_locked(hw, HV_PM_CTRL,
1598 hw->phy.ops.release(hw);
1603 if (hw->mac.type >= e1000_pch_spt) {
1607 if (speed == SPEED_1000) {
1608 ret_val = hw->phy.ops.acquire(hw);
1612 ret_val = hw->phy.ops.read_reg_locked(hw,
1616 hw->phy.ops.release(hw);
1620 ptr_gap = (data & (0x3FF << 2)) >> 2;
1621 if (ptr_gap < 0x18) {
1622 data &= ~(0x3FF << 2);
1623 data |= (0x18 << 2);
1625 hw->phy.ops.write_reg_locked(hw,
1626 PHY_REG(776, 20), data);
1628 hw->phy.ops.release(hw);
1632 ret_val = hw->phy.ops.acquire(hw);
1636 ret_val = hw->phy.ops.write_reg_locked(hw,
1639 hw->phy.ops.release(hw);
1647 /* I217 Packet Loss issue:
1648 * ensure that FEXTNVM4 Beacon Duration is set correctly
1650 * Set the Beacon Duration for I217 to 8 usec
1652 if (hw->mac.type >= e1000_pch_lpt) {
1655 mac_reg = E1000_READ_REG(hw, E1000_FEXTNVM4);
1656 mac_reg &= ~E1000_FEXTNVM4_BEACON_DURATION_MASK;
1657 mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_8USEC;
1658 E1000_WRITE_REG(hw, E1000_FEXTNVM4, mac_reg);
1661 /* Work-around I218 hang issue */
1662 if ((hw->device_id == E1000_DEV_ID_PCH_LPTLP_I218_LM) ||
1663 (hw->device_id == E1000_DEV_ID_PCH_LPTLP_I218_V) ||
1664 (hw->device_id == E1000_DEV_ID_PCH_I218_LM3) ||
1665 (hw->device_id == E1000_DEV_ID_PCH_I218_V3)) {
1666 ret_val = e1000_k1_workaround_lpt_lp(hw, link);
1670 /* Clear link partner's EEE ability */
1671 hw->dev_spec.ich8lan.eee_lp_ability = 0;
1673 /* Configure K0s minimum time */
1674 if (hw->mac.type >= e1000_pch_lpt) {
1675 e1000_configure_k0s_lpt(hw, K1_ENTRY_LATENCY, K1_MIN_TIME);
1678 if (hw->mac.type >= e1000_pch_lpt) {
1679 u32 fextnvm6 = E1000_READ_REG(hw, E1000_FEXTNVM6);
1681 if (hw->mac.type == e1000_pch_spt) {
1682 /* FEXTNVM6 K1-off workaround - for SPT only */
1683 u32 pcieanacfg = E1000_READ_REG(hw, E1000_PCIEANACFG);
1685 if (pcieanacfg & E1000_FEXTNVM6_K1_OFF_ENABLE)
1686 fextnvm6 |= E1000_FEXTNVM6_K1_OFF_ENABLE;
1688 fextnvm6 &= ~E1000_FEXTNVM6_K1_OFF_ENABLE;
1691 if (hw->dev_spec.ich8lan.disable_k1_off == true)
1692 fextnvm6 &= ~E1000_FEXTNVM6_K1_OFF_ENABLE;
1694 E1000_WRITE_REG(hw, E1000_FEXTNVM6, fextnvm6);
1698 return E1000_SUCCESS; /* No link detected */
1700 mac->get_link_status = false;
1702 switch (hw->mac.type) {
1704 ret_val = e1000_k1_workaround_lv(hw);
1709 if (hw->phy.type == e1000_phy_82578) {
1710 ret_val = e1000_link_stall_workaround_hv(hw);
1715 /* Workaround for PCHx parts in half-duplex:
1716 * Set the number of preambles removed from the packet
1717 * when it is passed from the PHY to the MAC to prevent
1718 * the MAC from misinterpreting the packet type.
1720 hw->phy.ops.read_reg(hw, HV_KMRN_FIFO_CTRLSTA, &phy_reg);
1721 phy_reg &= ~HV_KMRN_FIFO_CTRLSTA_PREAMBLE_MASK;
1723 if ((E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_FD) !=
1725 phy_reg |= (1 << HV_KMRN_FIFO_CTRLSTA_PREAMBLE_SHIFT);
1727 hw->phy.ops.write_reg(hw, HV_KMRN_FIFO_CTRLSTA, phy_reg);
1733 /* Check if there was DownShift, must be checked
1734 * immediately after link-up
1736 e1000_check_downshift_generic(hw);
1738 /* Enable/Disable EEE after link up */
1739 if (hw->phy.type > e1000_phy_82579) {
1740 ret_val = e1000_set_eee_pchlan(hw);
1745 /* If we are forcing speed/duplex, then we simply return since
1746 * we have already determined whether we have link or not.
1749 return -E1000_ERR_CONFIG;
1751 /* Auto-Neg is enabled. Auto Speed Detection takes care
1752 * of MAC speed/duplex configuration. So we only need to
1753 * configure Collision Distance in the MAC.
1755 mac->ops.config_collision_dist(hw);
1757 /* Configure Flow Control now that Auto-Neg has completed.
1758 * First, we need to restore the desired flow control
1759 * settings because we may have had to re-autoneg with a
1760 * different link partner.
1762 ret_val = e1000_config_fc_after_link_up_generic(hw);
1764 DEBUGOUT("Error configuring flow control\n");
1770 * e1000_init_function_pointers_ich8lan - Initialize ICH8 function pointers
1771 * @hw: pointer to the HW structure
1773 * Initialize family-specific function pointers for PHY, MAC, and NVM.
1775 void e1000_init_function_pointers_ich8lan(struct e1000_hw *hw)
1777 DEBUGFUNC("e1000_init_function_pointers_ich8lan");
1779 hw->mac.ops.init_params = e1000_init_mac_params_ich8lan;
1780 hw->nvm.ops.init_params = e1000_init_nvm_params_ich8lan;
1781 switch (hw->mac.type) {
1784 case e1000_ich10lan:
1785 hw->phy.ops.init_params = e1000_init_phy_params_ich8lan;
1791 hw->phy.ops.init_params = e1000_init_phy_params_pchlan;
1799 * e1000_acquire_nvm_ich8lan - Acquire NVM mutex
1800 * @hw: pointer to the HW structure
1802 * Acquires the mutex for performing NVM operations.
1804 STATIC s32 e1000_acquire_nvm_ich8lan(struct e1000_hw *hw)
1806 DEBUGFUNC("e1000_acquire_nvm_ich8lan");
1808 E1000_MUTEX_LOCK(&hw->dev_spec.ich8lan.nvm_mutex);
1810 return E1000_SUCCESS;
1814 * e1000_release_nvm_ich8lan - Release NVM mutex
1815 * @hw: pointer to the HW structure
1817 * Releases the mutex used while performing NVM operations.
1819 STATIC void e1000_release_nvm_ich8lan(struct e1000_hw *hw)
1821 DEBUGFUNC("e1000_release_nvm_ich8lan");
1823 E1000_MUTEX_UNLOCK(&hw->dev_spec.ich8lan.nvm_mutex);
1829 * e1000_acquire_swflag_ich8lan - Acquire software control flag
1830 * @hw: pointer to the HW structure
1832 * Acquires the software control flag for performing PHY and select
1835 STATIC s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw)
1837 u32 extcnf_ctrl, timeout = PHY_CFG_TIMEOUT;
1838 s32 ret_val = E1000_SUCCESS;
1840 DEBUGFUNC("e1000_acquire_swflag_ich8lan");
1842 E1000_MUTEX_LOCK(&hw->dev_spec.ich8lan.swflag_mutex);
1845 extcnf_ctrl = E1000_READ_REG(hw, E1000_EXTCNF_CTRL);
1846 if (!(extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG))
1854 DEBUGOUT("SW has already locked the resource.\n");
1855 ret_val = -E1000_ERR_CONFIG;
1859 timeout = SW_FLAG_TIMEOUT;
1861 extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG;
1862 E1000_WRITE_REG(hw, E1000_EXTCNF_CTRL, extcnf_ctrl);
1865 extcnf_ctrl = E1000_READ_REG(hw, E1000_EXTCNF_CTRL);
1866 if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG)
1874 DEBUGOUT2("Failed to acquire the semaphore, FW or HW has it: FWSM=0x%8.8x EXTCNF_CTRL=0x%8.8x)\n",
1875 E1000_READ_REG(hw, E1000_FWSM), extcnf_ctrl);
1876 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
1877 E1000_WRITE_REG(hw, E1000_EXTCNF_CTRL, extcnf_ctrl);
1878 ret_val = -E1000_ERR_CONFIG;
1884 E1000_MUTEX_UNLOCK(&hw->dev_spec.ich8lan.swflag_mutex);
1890 * e1000_release_swflag_ich8lan - Release software control flag
1891 * @hw: pointer to the HW structure
1893 * Releases the software control flag for performing PHY and select
1896 STATIC void e1000_release_swflag_ich8lan(struct e1000_hw *hw)
1900 DEBUGFUNC("e1000_release_swflag_ich8lan");
1902 extcnf_ctrl = E1000_READ_REG(hw, E1000_EXTCNF_CTRL);
1904 if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG) {
1905 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
1906 E1000_WRITE_REG(hw, E1000_EXTCNF_CTRL, extcnf_ctrl);
1908 DEBUGOUT("Semaphore unexpectedly released by sw/fw/hw\n");
1911 E1000_MUTEX_UNLOCK(&hw->dev_spec.ich8lan.swflag_mutex);
1917 * e1000_check_mng_mode_ich8lan - Checks management mode
1918 * @hw: pointer to the HW structure
1920 * This checks if the adapter has any manageability enabled.
1921 * This is a function pointer entry point only called by read/write
1922 * routines for the PHY and NVM parts.
1924 STATIC bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw)
1928 DEBUGFUNC("e1000_check_mng_mode_ich8lan");
1930 fwsm = E1000_READ_REG(hw, E1000_FWSM);
1932 return (fwsm & E1000_ICH_FWSM_FW_VALID) &&
1933 ((fwsm & E1000_FWSM_MODE_MASK) ==
1934 (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT));
1938 * e1000_check_mng_mode_pchlan - Checks management mode
1939 * @hw: pointer to the HW structure
1941 * This checks if the adapter has iAMT enabled.
1942 * This is a function pointer entry point only called by read/write
1943 * routines for the PHY and NVM parts.
1945 STATIC bool e1000_check_mng_mode_pchlan(struct e1000_hw *hw)
1949 DEBUGFUNC("e1000_check_mng_mode_pchlan");
1951 fwsm = E1000_READ_REG(hw, E1000_FWSM);
1953 return (fwsm & E1000_ICH_FWSM_FW_VALID) &&
1954 (fwsm & (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT));
1958 * e1000_rar_set_pch2lan - Set receive address register
1959 * @hw: pointer to the HW structure
1960 * @addr: pointer to the receive address
1961 * @index: receive address array register
1963 * Sets the receive address array register at index to the address passed
1964 * in by addr. For 82579, RAR[0] is the base address register that is to
1965 * contain the MAC address but RAR[1-6] are reserved for manageability (ME).
1966 * Use SHRA[0-3] in place of those reserved for ME.
1968 STATIC int e1000_rar_set_pch2lan(struct e1000_hw *hw, u8 *addr, u32 index)
1970 u32 rar_low, rar_high;
1972 DEBUGFUNC("e1000_rar_set_pch2lan");
1974 /* HW expects these in little endian so we reverse the byte order
1975 * from network order (big endian) to little endian
1977 rar_low = ((u32) addr[0] |
1978 ((u32) addr[1] << 8) |
1979 ((u32) addr[2] << 16) | ((u32) addr[3] << 24));
1981 rar_high = ((u32) addr[4] | ((u32) addr[5] << 8));
1983 /* If MAC address zero, no need to set the AV bit */
1984 if (rar_low || rar_high)
1985 rar_high |= E1000_RAH_AV;
1988 E1000_WRITE_REG(hw, E1000_RAL(index), rar_low);
1989 E1000_WRITE_FLUSH(hw);
1990 E1000_WRITE_REG(hw, E1000_RAH(index), rar_high);
1991 E1000_WRITE_FLUSH(hw);
1992 return E1000_SUCCESS;
1995 /* RAR[1-6] are owned by manageability. Skip those and program the
1996 * next address into the SHRA register array.
1998 if (index < (u32) (hw->mac.rar_entry_count)) {
2001 ret_val = e1000_acquire_swflag_ich8lan(hw);
2005 E1000_WRITE_REG(hw, E1000_SHRAL(index - 1), rar_low);
2006 E1000_WRITE_FLUSH(hw);
2007 E1000_WRITE_REG(hw, E1000_SHRAH(index - 1), rar_high);
2008 E1000_WRITE_FLUSH(hw);
2010 e1000_release_swflag_ich8lan(hw);
2012 /* verify the register updates */
2013 if ((E1000_READ_REG(hw, E1000_SHRAL(index - 1)) == rar_low) &&
2014 (E1000_READ_REG(hw, E1000_SHRAH(index - 1)) == rar_high))
2015 return E1000_SUCCESS;
2017 DEBUGOUT2("SHRA[%d] might be locked by ME - FWSM=0x%8.8x\n",
2018 (index - 1), E1000_READ_REG(hw, E1000_FWSM));
2022 DEBUGOUT1("Failed to write receive address at index %d\n", index);
2023 return -E1000_ERR_CONFIG;
2027 * e1000_rar_set_pch_lpt - Set receive address registers
2028 * @hw: pointer to the HW structure
2029 * @addr: pointer to the receive address
2030 * @index: receive address array register
2032 * Sets the receive address register array at index to the address passed
2033 * in by addr. For LPT, RAR[0] is the base address register that is to
2034 * contain the MAC address. SHRA[0-10] are the shared receive address
2035 * registers that are shared between the Host and manageability engine (ME).
2037 STATIC int e1000_rar_set_pch_lpt(struct e1000_hw *hw, u8 *addr, u32 index)
2039 u32 rar_low, rar_high;
2042 DEBUGFUNC("e1000_rar_set_pch_lpt");
2044 /* HW expects these in little endian so we reverse the byte order
2045 * from network order (big endian) to little endian
2047 rar_low = ((u32) addr[0] | ((u32) addr[1] << 8) |
2048 ((u32) addr[2] << 16) | ((u32) addr[3] << 24));
2050 rar_high = ((u32) addr[4] | ((u32) addr[5] << 8));
2052 /* If MAC address zero, no need to set the AV bit */
2053 if (rar_low || rar_high)
2054 rar_high |= E1000_RAH_AV;
2057 E1000_WRITE_REG(hw, E1000_RAL(index), rar_low);
2058 E1000_WRITE_FLUSH(hw);
2059 E1000_WRITE_REG(hw, E1000_RAH(index), rar_high);
2060 E1000_WRITE_FLUSH(hw);
2061 return E1000_SUCCESS;
2064 /* The manageability engine (ME) can lock certain SHRAR registers that
2065 * it is using - those registers are unavailable for use.
2067 if (index < hw->mac.rar_entry_count) {
2068 wlock_mac = E1000_READ_REG(hw, E1000_FWSM) &
2069 E1000_FWSM_WLOCK_MAC_MASK;
2070 wlock_mac >>= E1000_FWSM_WLOCK_MAC_SHIFT;
2072 /* Check if all SHRAR registers are locked */
2076 if ((wlock_mac == 0) || (index <= wlock_mac)) {
2079 ret_val = e1000_acquire_swflag_ich8lan(hw);
2084 E1000_WRITE_REG(hw, E1000_SHRAL_PCH_LPT(index - 1),
2086 E1000_WRITE_FLUSH(hw);
2087 E1000_WRITE_REG(hw, E1000_SHRAH_PCH_LPT(index - 1),
2089 E1000_WRITE_FLUSH(hw);
2091 e1000_release_swflag_ich8lan(hw);
2093 /* verify the register updates */
2094 if ((E1000_READ_REG(hw, E1000_SHRAL_PCH_LPT(index - 1)) == rar_low) &&
2095 (E1000_READ_REG(hw, E1000_SHRAH_PCH_LPT(index - 1)) == rar_high))
2096 return E1000_SUCCESS;
2101 DEBUGOUT1("Failed to write receive address at index %d\n", index);
2102 return -E1000_ERR_CONFIG;
2105 #ifndef NO_NON_BLOCKING_PHY_MTA_UPDATE_SUPPORT
2107 * e1000_update_mc_addr_list_pch2lan - Update Multicast addresses
2108 * @hw: pointer to the HW structure
2109 * @mc_addr_list: array of multicast addresses to program
2110 * @mc_addr_count: number of multicast addresses to program
2112 * Updates entire Multicast Table Array of the PCH2 MAC and PHY.
2113 * The caller must have a packed mc_addr_list of multicast addresses.
2115 STATIC void e1000_update_mc_addr_list_pch2lan(struct e1000_hw *hw,
2123 DEBUGFUNC("e1000_update_mc_addr_list_pch2lan");
2125 e1000_update_mc_addr_list_generic(hw, mc_addr_list, mc_addr_count);
2127 ret_val = hw->phy.ops.acquire(hw);
2131 ret_val = e1000_enable_phy_wakeup_reg_access_bm(hw, &phy_reg);
2135 for (i = 0; i < hw->mac.mta_reg_count; i++) {
2136 hw->phy.ops.write_reg_page(hw, BM_MTA(i),
2137 (u16)(hw->mac.mta_shadow[i] &
2139 hw->phy.ops.write_reg_page(hw, (BM_MTA(i) + 1),
2140 (u16)((hw->mac.mta_shadow[i] >> 16) &
2144 e1000_disable_phy_wakeup_reg_access_bm(hw, &phy_reg);
2147 hw->phy.ops.release(hw);
2150 #endif /* NO_NON_BLOCKING_PHY_MTA_UPDATE_SUPPORT */
2152 * e1000_check_reset_block_ich8lan - Check if PHY reset is blocked
2153 * @hw: pointer to the HW structure
2155 * Checks if firmware is blocking the reset of the PHY.
2156 * This is a function pointer entry point only called by
2159 STATIC s32 e1000_check_reset_block_ich8lan(struct e1000_hw *hw)
2162 bool blocked = false;
2165 DEBUGFUNC("e1000_check_reset_block_ich8lan");
2168 fwsm = E1000_READ_REG(hw, E1000_FWSM);
2169 if (!(fwsm & E1000_ICH_FWSM_RSPCIPHY)) {
2175 } while (blocked && (i++ < 30));
2176 return blocked ? E1000_BLK_PHY_RESET : E1000_SUCCESS;
2180 * e1000_write_smbus_addr - Write SMBus address to PHY needed during Sx states
2181 * @hw: pointer to the HW structure
2183 * Assumes semaphore already acquired.
2186 STATIC s32 e1000_write_smbus_addr(struct e1000_hw *hw)
2189 u32 strap = E1000_READ_REG(hw, E1000_STRAP);
2190 u32 freq = (strap & E1000_STRAP_SMT_FREQ_MASK) >>
2191 E1000_STRAP_SMT_FREQ_SHIFT;
2194 strap &= E1000_STRAP_SMBUS_ADDRESS_MASK;
2196 ret_val = e1000_read_phy_reg_hv_locked(hw, HV_SMB_ADDR, &phy_data);
2200 phy_data &= ~HV_SMB_ADDR_MASK;
2201 phy_data |= (strap >> E1000_STRAP_SMBUS_ADDRESS_SHIFT);
2202 phy_data |= HV_SMB_ADDR_PEC_EN | HV_SMB_ADDR_VALID;
2204 if (hw->phy.type == e1000_phy_i217) {
2205 /* Restore SMBus frequency */
2207 phy_data &= ~HV_SMB_ADDR_FREQ_MASK;
2208 phy_data |= (freq & (1 << 0)) <<
2209 HV_SMB_ADDR_FREQ_LOW_SHIFT;
2210 phy_data |= (freq & (1 << 1)) <<
2211 (HV_SMB_ADDR_FREQ_HIGH_SHIFT - 1);
2213 DEBUGOUT("Unsupported SMB frequency in PHY\n");
2217 return e1000_write_phy_reg_hv_locked(hw, HV_SMB_ADDR, phy_data);
2221 * e1000_sw_lcd_config_ich8lan - SW-based LCD Configuration
2222 * @hw: pointer to the HW structure
2224 * SW should configure the LCD from the NVM extended configuration region
2225 * as a workaround for certain parts.
2227 STATIC s32 e1000_sw_lcd_config_ich8lan(struct e1000_hw *hw)
2229 struct e1000_phy_info *phy = &hw->phy;
2230 u32 i, data, cnf_size, cnf_base_addr, sw_cfg_mask;
2231 s32 ret_val = E1000_SUCCESS;
2232 u16 word_addr, reg_data, reg_addr, phy_page = 0;
2234 DEBUGFUNC("e1000_sw_lcd_config_ich8lan");
2236 /* Initialize the PHY from the NVM on ICH platforms. This
2237 * is needed due to an issue where the NVM configuration is
2238 * not properly autoloaded after power transitions.
2239 * Therefore, after each PHY reset, we will load the
2240 * configuration data out of the NVM manually.
2242 switch (hw->mac.type) {
2244 if (phy->type != e1000_phy_igp_3)
2247 if ((hw->device_id == E1000_DEV_ID_ICH8_IGP_AMT) ||
2248 (hw->device_id == E1000_DEV_ID_ICH8_IGP_C)) {
2249 sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG;
2257 sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG_ICH8M;
2263 ret_val = hw->phy.ops.acquire(hw);
2267 data = E1000_READ_REG(hw, E1000_FEXTNVM);
2268 if (!(data & sw_cfg_mask))
2271 /* Make sure HW does not configure LCD from PHY
2272 * extended configuration before SW configuration
2274 data = E1000_READ_REG(hw, E1000_EXTCNF_CTRL);
2275 if ((hw->mac.type < e1000_pch2lan) &&
2276 (data & E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE))
2279 cnf_size = E1000_READ_REG(hw, E1000_EXTCNF_SIZE);
2280 cnf_size &= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_MASK;
2281 cnf_size >>= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_SHIFT;
2285 cnf_base_addr = data & E1000_EXTCNF_CTRL_EXT_CNF_POINTER_MASK;
2286 cnf_base_addr >>= E1000_EXTCNF_CTRL_EXT_CNF_POINTER_SHIFT;
2288 if (((hw->mac.type == e1000_pchlan) &&
2289 !(data & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE)) ||
2290 (hw->mac.type > e1000_pchlan)) {
2291 /* HW configures the SMBus address and LEDs when the
2292 * OEM and LCD Write Enable bits are set in the NVM.
2293 * When both NVM bits are cleared, SW will configure
2296 ret_val = e1000_write_smbus_addr(hw);
2300 data = E1000_READ_REG(hw, E1000_LEDCTL);
2301 ret_val = e1000_write_phy_reg_hv_locked(hw, HV_LED_CONFIG,
2307 /* Configure LCD from extended configuration region. */
2309 /* cnf_base_addr is in DWORD */
2310 word_addr = (u16)(cnf_base_addr << 1);
2312 for (i = 0; i < cnf_size; i++) {
2313 ret_val = hw->nvm.ops.read(hw, (word_addr + i * 2), 1,
2318 ret_val = hw->nvm.ops.read(hw, (word_addr + i * 2 + 1),
2323 /* Save off the PHY page for future writes. */
2324 if (reg_addr == IGP01E1000_PHY_PAGE_SELECT) {
2325 phy_page = reg_data;
2329 reg_addr &= PHY_REG_MASK;
2330 reg_addr |= phy_page;
2332 ret_val = phy->ops.write_reg_locked(hw, (u32)reg_addr,
2339 hw->phy.ops.release(hw);
2344 * e1000_k1_gig_workaround_hv - K1 Si workaround
2345 * @hw: pointer to the HW structure
2346 * @link: link up bool flag
2348 * If K1 is enabled for 1Gbps, the MAC might stall when transitioning
2349 * from a lower speed. This workaround disables K1 whenever link is at 1Gig
2350 * If link is down, the function will restore the default K1 setting located
2353 STATIC s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link)
2355 s32 ret_val = E1000_SUCCESS;
2357 bool k1_enable = hw->dev_spec.ich8lan.nvm_k1_enabled;
2359 DEBUGFUNC("e1000_k1_gig_workaround_hv");
2361 if (hw->mac.type != e1000_pchlan)
2362 return E1000_SUCCESS;
2364 /* Wrap the whole flow with the sw flag */
2365 ret_val = hw->phy.ops.acquire(hw);
2369 /* Disable K1 when link is 1Gbps, otherwise use the NVM setting */
2371 if (hw->phy.type == e1000_phy_82578) {
2372 ret_val = hw->phy.ops.read_reg_locked(hw, BM_CS_STATUS,
2377 status_reg &= (BM_CS_STATUS_LINK_UP |
2378 BM_CS_STATUS_RESOLVED |
2379 BM_CS_STATUS_SPEED_MASK);
2381 if (status_reg == (BM_CS_STATUS_LINK_UP |
2382 BM_CS_STATUS_RESOLVED |
2383 BM_CS_STATUS_SPEED_1000))
2387 if (hw->phy.type == e1000_phy_82577) {
2388 ret_val = hw->phy.ops.read_reg_locked(hw, HV_M_STATUS,
2393 status_reg &= (HV_M_STATUS_LINK_UP |
2394 HV_M_STATUS_AUTONEG_COMPLETE |
2395 HV_M_STATUS_SPEED_MASK);
2397 if (status_reg == (HV_M_STATUS_LINK_UP |
2398 HV_M_STATUS_AUTONEG_COMPLETE |
2399 HV_M_STATUS_SPEED_1000))
2403 /* Link stall fix for link up */
2404 ret_val = hw->phy.ops.write_reg_locked(hw, PHY_REG(770, 19),
2410 /* Link stall fix for link down */
2411 ret_val = hw->phy.ops.write_reg_locked(hw, PHY_REG(770, 19),
2417 ret_val = e1000_configure_k1_ich8lan(hw, k1_enable);
2420 hw->phy.ops.release(hw);
2426 * e1000_configure_k1_ich8lan - Configure K1 power state
2427 * @hw: pointer to the HW structure
2428 * @enable: K1 state to configure
2430 * Configure the K1 power state based on the provided parameter.
2431 * Assumes semaphore already acquired.
2433 * Success returns 0, Failure returns -E1000_ERR_PHY (-2)
2435 s32 e1000_configure_k1_ich8lan(struct e1000_hw *hw, bool k1_enable)
2443 DEBUGFUNC("e1000_configure_k1_ich8lan");
2445 ret_val = e1000_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
2451 kmrn_reg |= E1000_KMRNCTRLSTA_K1_ENABLE;
2453 kmrn_reg &= ~E1000_KMRNCTRLSTA_K1_ENABLE;
2455 ret_val = e1000_write_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
2461 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
2462 ctrl_reg = E1000_READ_REG(hw, E1000_CTRL);
2464 reg = ctrl_reg & ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100);
2465 reg |= E1000_CTRL_FRCSPD;
2466 E1000_WRITE_REG(hw, E1000_CTRL, reg);
2468 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext | E1000_CTRL_EXT_SPD_BYPS);
2469 E1000_WRITE_FLUSH(hw);
2471 E1000_WRITE_REG(hw, E1000_CTRL, ctrl_reg);
2472 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
2473 E1000_WRITE_FLUSH(hw);
2476 return E1000_SUCCESS;
2480 * e1000_oem_bits_config_ich8lan - SW-based LCD Configuration
2481 * @hw: pointer to the HW structure
2482 * @d0_state: boolean if entering d0 or d3 device state
2484 * SW will configure Gbe Disable and LPLU based on the NVM. The four bits are
2485 * collectively called OEM bits. The OEM Write Enable bit and SW Config bit
2486 * in NVM determines whether HW should configure LPLU and Gbe Disable.
2488 STATIC s32 e1000_oem_bits_config_ich8lan(struct e1000_hw *hw, bool d0_state)
2494 DEBUGFUNC("e1000_oem_bits_config_ich8lan");
2496 if (hw->mac.type < e1000_pchlan)
2499 ret_val = hw->phy.ops.acquire(hw);
2503 if (hw->mac.type == e1000_pchlan) {
2504 mac_reg = E1000_READ_REG(hw, E1000_EXTCNF_CTRL);
2505 if (mac_reg & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE)
2509 mac_reg = E1000_READ_REG(hw, E1000_FEXTNVM);
2510 if (!(mac_reg & E1000_FEXTNVM_SW_CONFIG_ICH8M))
2513 mac_reg = E1000_READ_REG(hw, E1000_PHY_CTRL);
2515 ret_val = hw->phy.ops.read_reg_locked(hw, HV_OEM_BITS, &oem_reg);
2519 oem_reg &= ~(HV_OEM_BITS_GBE_DIS | HV_OEM_BITS_LPLU);
2522 if (mac_reg & E1000_PHY_CTRL_GBE_DISABLE)
2523 oem_reg |= HV_OEM_BITS_GBE_DIS;
2525 if (mac_reg & E1000_PHY_CTRL_D0A_LPLU)
2526 oem_reg |= HV_OEM_BITS_LPLU;
2528 if (mac_reg & (E1000_PHY_CTRL_GBE_DISABLE |
2529 E1000_PHY_CTRL_NOND0A_GBE_DISABLE))
2530 oem_reg |= HV_OEM_BITS_GBE_DIS;
2532 if (mac_reg & (E1000_PHY_CTRL_D0A_LPLU |
2533 E1000_PHY_CTRL_NOND0A_LPLU))
2534 oem_reg |= HV_OEM_BITS_LPLU;
2537 /* Set Restart auto-neg to activate the bits */
2538 if ((d0_state || (hw->mac.type != e1000_pchlan)) &&
2539 !hw->phy.ops.check_reset_block(hw))
2540 oem_reg |= HV_OEM_BITS_RESTART_AN;
2542 ret_val = hw->phy.ops.write_reg_locked(hw, HV_OEM_BITS, oem_reg);
2545 hw->phy.ops.release(hw);
2552 * e1000_set_mdio_slow_mode_hv - Set slow MDIO access mode
2553 * @hw: pointer to the HW structure
2555 STATIC s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw)
2560 DEBUGFUNC("e1000_set_mdio_slow_mode_hv");
2562 ret_val = hw->phy.ops.read_reg(hw, HV_KMRN_MODE_CTRL, &data);
2566 data |= HV_KMRN_MDIO_SLOW;
2568 ret_val = hw->phy.ops.write_reg(hw, HV_KMRN_MODE_CTRL, data);
2574 * e1000_hv_phy_workarounds_ich8lan - A series of Phy workarounds to be
2575 * done after every PHY reset.
2577 STATIC s32 e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw)
2579 s32 ret_val = E1000_SUCCESS;
2582 DEBUGFUNC("e1000_hv_phy_workarounds_ich8lan");
2584 if (hw->mac.type != e1000_pchlan)
2585 return E1000_SUCCESS;
2587 /* Set MDIO slow mode before any other MDIO access */
2588 if (hw->phy.type == e1000_phy_82577) {
2589 ret_val = e1000_set_mdio_slow_mode_hv(hw);
2594 if (((hw->phy.type == e1000_phy_82577) &&
2595 ((hw->phy.revision == 1) || (hw->phy.revision == 2))) ||
2596 ((hw->phy.type == e1000_phy_82578) && (hw->phy.revision == 1))) {
2597 /* Disable generation of early preamble */
2598 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(769, 25), 0x4431);
2602 /* Preamble tuning for SSC */
2603 ret_val = hw->phy.ops.write_reg(hw, HV_KMRN_FIFO_CTRLSTA,
2609 if (hw->phy.type == e1000_phy_82578) {
2610 /* Return registers to default by doing a soft reset then
2611 * writing 0x3140 to the control register.
2613 if (hw->phy.revision < 2) {
2614 e1000_phy_sw_reset_generic(hw);
2615 ret_val = hw->phy.ops.write_reg(hw, PHY_CONTROL,
2621 ret_val = hw->phy.ops.acquire(hw);
2626 ret_val = e1000_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT, 0);
2627 hw->phy.ops.release(hw);
2631 /* Configure the K1 Si workaround during phy reset assuming there is
2632 * link so that it disables K1 if link is in 1Gbps.
2634 ret_val = e1000_k1_gig_workaround_hv(hw, true);
2638 /* Workaround for link disconnects on a busy hub in half duplex */
2639 ret_val = hw->phy.ops.acquire(hw);
2642 ret_val = hw->phy.ops.read_reg_locked(hw, BM_PORT_GEN_CFG, &phy_data);
2645 ret_val = hw->phy.ops.write_reg_locked(hw, BM_PORT_GEN_CFG,
2650 /* set MSE higher to enable link to stay up when noise is high */
2651 ret_val = e1000_write_emi_reg_locked(hw, I82577_MSE_THRESHOLD, 0x0034);
2653 hw->phy.ops.release(hw);
2659 * e1000_copy_rx_addrs_to_phy_ich8lan - Copy Rx addresses from MAC to PHY
2660 * @hw: pointer to the HW structure
2662 void e1000_copy_rx_addrs_to_phy_ich8lan(struct e1000_hw *hw)
2668 DEBUGFUNC("e1000_copy_rx_addrs_to_phy_ich8lan");
2670 ret_val = hw->phy.ops.acquire(hw);
2673 ret_val = e1000_enable_phy_wakeup_reg_access_bm(hw, &phy_reg);
2677 /* Copy both RAL/H (rar_entry_count) and SHRAL/H to PHY */
2678 for (i = 0; i < (hw->mac.rar_entry_count); i++) {
2679 mac_reg = E1000_READ_REG(hw, E1000_RAL(i));
2680 hw->phy.ops.write_reg_page(hw, BM_RAR_L(i),
2681 (u16)(mac_reg & 0xFFFF));
2682 hw->phy.ops.write_reg_page(hw, BM_RAR_M(i),
2683 (u16)((mac_reg >> 16) & 0xFFFF));
2685 mac_reg = E1000_READ_REG(hw, E1000_RAH(i));
2686 hw->phy.ops.write_reg_page(hw, BM_RAR_H(i),
2687 (u16)(mac_reg & 0xFFFF));
2688 hw->phy.ops.write_reg_page(hw, BM_RAR_CTRL(i),
2689 (u16)((mac_reg & E1000_RAH_AV)
2693 e1000_disable_phy_wakeup_reg_access_bm(hw, &phy_reg);
2696 hw->phy.ops.release(hw);
2699 #ifndef CRC32_OS_SUPPORT
2700 STATIC u32 e1000_calc_rx_da_crc(u8 mac[])
2702 u32 poly = 0xEDB88320; /* Polynomial for 802.3 CRC calculation */
2703 u32 i, j, mask, crc;
2705 DEBUGFUNC("e1000_calc_rx_da_crc");
2708 for (i = 0; i < 6; i++) {
2710 for (j = 8; j > 0; j--) {
2711 mask = (crc & 1) * (-1);
2712 crc = (crc >> 1) ^ (poly & mask);
2718 #endif /* CRC32_OS_SUPPORT */
2720 * e1000_lv_jumbo_workaround_ich8lan - required for jumbo frame operation
2722 * @hw: pointer to the HW structure
2723 * @enable: flag to enable/disable workaround when enabling/disabling jumbos
2725 s32 e1000_lv_jumbo_workaround_ich8lan(struct e1000_hw *hw, bool enable)
2727 s32 ret_val = E1000_SUCCESS;
2732 DEBUGFUNC("e1000_lv_jumbo_workaround_ich8lan");
2734 if (hw->mac.type < e1000_pch2lan)
2735 return E1000_SUCCESS;
2737 /* disable Rx path while enabling/disabling workaround */
2738 hw->phy.ops.read_reg(hw, PHY_REG(769, 20), &phy_reg);
2739 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(769, 20),
2740 phy_reg | (1 << 14));
2745 /* Write Rx addresses (rar_entry_count for RAL/H, and
2746 * SHRAL/H) and initial CRC values to the MAC
2748 for (i = 0; i < hw->mac.rar_entry_count; i++) {
2749 u8 mac_addr[ETH_ADDR_LEN] = {0};
2750 u32 addr_high, addr_low;
2752 addr_high = E1000_READ_REG(hw, E1000_RAH(i));
2753 if (!(addr_high & E1000_RAH_AV))
2755 addr_low = E1000_READ_REG(hw, E1000_RAL(i));
2756 mac_addr[0] = (addr_low & 0xFF);
2757 mac_addr[1] = ((addr_low >> 8) & 0xFF);
2758 mac_addr[2] = ((addr_low >> 16) & 0xFF);
2759 mac_addr[3] = ((addr_low >> 24) & 0xFF);
2760 mac_addr[4] = (addr_high & 0xFF);
2761 mac_addr[5] = ((addr_high >> 8) & 0xFF);
2763 #ifndef CRC32_OS_SUPPORT
2764 E1000_WRITE_REG(hw, E1000_PCH_RAICC(i),
2765 e1000_calc_rx_da_crc(mac_addr));
2766 #else /* CRC32_OS_SUPPORT */
2767 E1000_WRITE_REG(hw, E1000_PCH_RAICC(i),
2768 E1000_CRC32(ETH_ADDR_LEN, mac_addr));
2769 #endif /* CRC32_OS_SUPPORT */
2772 /* Write Rx addresses to the PHY */
2773 e1000_copy_rx_addrs_to_phy_ich8lan(hw);
2775 /* Enable jumbo frame workaround in the MAC */
2776 mac_reg = E1000_READ_REG(hw, E1000_FFLT_DBG);
2777 mac_reg &= ~(1 << 14);
2778 mac_reg |= (7 << 15);
2779 E1000_WRITE_REG(hw, E1000_FFLT_DBG, mac_reg);
2781 mac_reg = E1000_READ_REG(hw, E1000_RCTL);
2782 mac_reg |= E1000_RCTL_SECRC;
2783 E1000_WRITE_REG(hw, E1000_RCTL, mac_reg);
2785 ret_val = e1000_read_kmrn_reg_generic(hw,
2786 E1000_KMRNCTRLSTA_CTRL_OFFSET,
2790 ret_val = e1000_write_kmrn_reg_generic(hw,
2791 E1000_KMRNCTRLSTA_CTRL_OFFSET,
2795 ret_val = e1000_read_kmrn_reg_generic(hw,
2796 E1000_KMRNCTRLSTA_HD_CTRL,
2800 data &= ~(0xF << 8);
2802 ret_val = e1000_write_kmrn_reg_generic(hw,
2803 E1000_KMRNCTRLSTA_HD_CTRL,
2808 /* Enable jumbo frame workaround in the PHY */
2809 hw->phy.ops.read_reg(hw, PHY_REG(769, 23), &data);
2810 data &= ~(0x7F << 5);
2811 data |= (0x37 << 5);
2812 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(769, 23), data);
2815 hw->phy.ops.read_reg(hw, PHY_REG(769, 16), &data);
2817 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(769, 16), data);
2820 hw->phy.ops.read_reg(hw, PHY_REG(776, 20), &data);
2821 data &= ~(0x3FF << 2);
2822 data |= (E1000_TX_PTR_GAP << 2);
2823 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(776, 20), data);
2826 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(776, 23), 0xF100);
2829 hw->phy.ops.read_reg(hw, HV_PM_CTRL, &data);
2830 ret_val = hw->phy.ops.write_reg(hw, HV_PM_CTRL, data |
2835 /* Write MAC register values back to h/w defaults */
2836 mac_reg = E1000_READ_REG(hw, E1000_FFLT_DBG);
2837 mac_reg &= ~(0xF << 14);
2838 E1000_WRITE_REG(hw, E1000_FFLT_DBG, mac_reg);
2840 mac_reg = E1000_READ_REG(hw, E1000_RCTL);
2841 mac_reg &= ~E1000_RCTL_SECRC;
2842 E1000_WRITE_REG(hw, E1000_RCTL, mac_reg);
2844 ret_val = e1000_read_kmrn_reg_generic(hw,
2845 E1000_KMRNCTRLSTA_CTRL_OFFSET,
2849 ret_val = e1000_write_kmrn_reg_generic(hw,
2850 E1000_KMRNCTRLSTA_CTRL_OFFSET,
2854 ret_val = e1000_read_kmrn_reg_generic(hw,
2855 E1000_KMRNCTRLSTA_HD_CTRL,
2859 data &= ~(0xF << 8);
2861 ret_val = e1000_write_kmrn_reg_generic(hw,
2862 E1000_KMRNCTRLSTA_HD_CTRL,
2867 /* Write PHY register values back to h/w defaults */
2868 hw->phy.ops.read_reg(hw, PHY_REG(769, 23), &data);
2869 data &= ~(0x7F << 5);
2870 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(769, 23), data);
2873 hw->phy.ops.read_reg(hw, PHY_REG(769, 16), &data);
2875 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(769, 16), data);
2878 hw->phy.ops.read_reg(hw, PHY_REG(776, 20), &data);
2879 data &= ~(0x3FF << 2);
2881 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(776, 20), data);
2884 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(776, 23), 0x7E00);
2887 hw->phy.ops.read_reg(hw, HV_PM_CTRL, &data);
2888 ret_val = hw->phy.ops.write_reg(hw, HV_PM_CTRL, data &
2894 /* re-enable Rx path after enabling/disabling workaround */
2895 return hw->phy.ops.write_reg(hw, PHY_REG(769, 20), phy_reg &
2900 * e1000_lv_phy_workarounds_ich8lan - A series of Phy workarounds to be
2901 * done after every PHY reset.
2903 STATIC s32 e1000_lv_phy_workarounds_ich8lan(struct e1000_hw *hw)
2905 s32 ret_val = E1000_SUCCESS;
2907 DEBUGFUNC("e1000_lv_phy_workarounds_ich8lan");
2909 if (hw->mac.type != e1000_pch2lan)
2910 return E1000_SUCCESS;
2912 /* Set MDIO slow mode before any other MDIO access */
2913 ret_val = e1000_set_mdio_slow_mode_hv(hw);
2917 ret_val = hw->phy.ops.acquire(hw);
2920 /* set MSE higher to enable link to stay up when noise is high */
2921 ret_val = e1000_write_emi_reg_locked(hw, I82579_MSE_THRESHOLD, 0x0034);
2924 /* drop link after 5 times MSE threshold was reached */
2925 ret_val = e1000_write_emi_reg_locked(hw, I82579_MSE_LINK_DOWN, 0x0005);
2927 hw->phy.ops.release(hw);
2933 * e1000_k1_gig_workaround_lv - K1 Si workaround
2934 * @hw: pointer to the HW structure
2936 * Workaround to set the K1 beacon duration for 82579 parts in 10Mbps
2937 * Disable K1 for 1000 and 100 speeds
2939 STATIC s32 e1000_k1_workaround_lv(struct e1000_hw *hw)
2941 s32 ret_val = E1000_SUCCESS;
2944 DEBUGFUNC("e1000_k1_workaround_lv");
2946 if (hw->mac.type != e1000_pch2lan)
2947 return E1000_SUCCESS;
2949 /* Set K1 beacon duration based on 10Mbs speed */
2950 ret_val = hw->phy.ops.read_reg(hw, HV_M_STATUS, &status_reg);
2954 if ((status_reg & (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE))
2955 == (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE)) {
2957 (HV_M_STATUS_SPEED_1000 | HV_M_STATUS_SPEED_100)) {
2960 /* LV 1G/100 Packet drop issue wa */
2961 ret_val = hw->phy.ops.read_reg(hw, HV_PM_CTRL,
2965 pm_phy_reg &= ~HV_PM_CTRL_K1_ENABLE;
2966 ret_val = hw->phy.ops.write_reg(hw, HV_PM_CTRL,
2972 mac_reg = E1000_READ_REG(hw, E1000_FEXTNVM4);
2973 mac_reg &= ~E1000_FEXTNVM4_BEACON_DURATION_MASK;
2974 mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_16USEC;
2975 E1000_WRITE_REG(hw, E1000_FEXTNVM4, mac_reg);
2983 * e1000_gate_hw_phy_config_ich8lan - disable PHY config via hardware
2984 * @hw: pointer to the HW structure
2985 * @gate: boolean set to true to gate, false to ungate
2987 * Gate/ungate the automatic PHY configuration via hardware; perform
2988 * the configuration via software instead.
2990 STATIC void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate)
2994 DEBUGFUNC("e1000_gate_hw_phy_config_ich8lan");
2996 if (hw->mac.type < e1000_pch2lan)
2999 extcnf_ctrl = E1000_READ_REG(hw, E1000_EXTCNF_CTRL);
3002 extcnf_ctrl |= E1000_EXTCNF_CTRL_GATE_PHY_CFG;
3004 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_GATE_PHY_CFG;
3006 E1000_WRITE_REG(hw, E1000_EXTCNF_CTRL, extcnf_ctrl);
3010 * e1000_lan_init_done_ich8lan - Check for PHY config completion
3011 * @hw: pointer to the HW structure
3013 * Check the appropriate indication the MAC has finished configuring the
3014 * PHY after a software reset.
3016 STATIC void e1000_lan_init_done_ich8lan(struct e1000_hw *hw)
3018 u32 data, loop = E1000_ICH8_LAN_INIT_TIMEOUT;
3020 DEBUGFUNC("e1000_lan_init_done_ich8lan");
3022 /* Wait for basic configuration completes before proceeding */
3024 data = E1000_READ_REG(hw, E1000_STATUS);
3025 data &= E1000_STATUS_LAN_INIT_DONE;
3027 } while ((!data) && --loop);
3029 /* If basic configuration is incomplete before the above loop
3030 * count reaches 0, loading the configuration from NVM will
3031 * leave the PHY in a bad state possibly resulting in no link.
3034 DEBUGOUT("LAN_INIT_DONE not set, increase timeout\n");
3036 /* Clear the Init Done bit for the next init event */
3037 data = E1000_READ_REG(hw, E1000_STATUS);
3038 data &= ~E1000_STATUS_LAN_INIT_DONE;
3039 E1000_WRITE_REG(hw, E1000_STATUS, data);
3043 * e1000_post_phy_reset_ich8lan - Perform steps required after a PHY reset
3044 * @hw: pointer to the HW structure
3046 STATIC s32 e1000_post_phy_reset_ich8lan(struct e1000_hw *hw)
3048 s32 ret_val = E1000_SUCCESS;
3051 DEBUGFUNC("e1000_post_phy_reset_ich8lan");
3053 if (hw->phy.ops.check_reset_block(hw))
3054 return E1000_SUCCESS;
3056 /* Allow time for h/w to get to quiescent state after reset */
3059 /* Perform any necessary post-reset workarounds */
3060 switch (hw->mac.type) {
3062 ret_val = e1000_hv_phy_workarounds_ich8lan(hw);
3067 ret_val = e1000_lv_phy_workarounds_ich8lan(hw);
3075 /* Clear the host wakeup bit after lcd reset */
3076 if (hw->mac.type >= e1000_pchlan) {
3077 hw->phy.ops.read_reg(hw, BM_PORT_GEN_CFG, ®);
3078 reg &= ~BM_WUC_HOST_WU_BIT;
3079 hw->phy.ops.write_reg(hw, BM_PORT_GEN_CFG, reg);
3082 /* Configure the LCD with the extended configuration region in NVM */
3083 ret_val = e1000_sw_lcd_config_ich8lan(hw);
3087 /* Configure the LCD with the OEM bits in NVM */
3088 ret_val = e1000_oem_bits_config_ich8lan(hw, true);
3090 if (hw->mac.type == e1000_pch2lan) {
3091 /* Ungate automatic PHY configuration on non-managed 82579 */
3092 if (!(E1000_READ_REG(hw, E1000_FWSM) &
3093 E1000_ICH_FWSM_FW_VALID)) {
3095 e1000_gate_hw_phy_config_ich8lan(hw, false);
3098 /* Set EEE LPI Update Timer to 200usec */
3099 ret_val = hw->phy.ops.acquire(hw);
3102 ret_val = e1000_write_emi_reg_locked(hw,
3103 I82579_LPI_UPDATE_TIMER,
3105 hw->phy.ops.release(hw);
3112 * e1000_phy_hw_reset_ich8lan - Performs a PHY reset
3113 * @hw: pointer to the HW structure
3116 * This is a function pointer entry point called by drivers
3117 * or other shared routines.
3119 STATIC s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw)
3121 s32 ret_val = E1000_SUCCESS;
3123 DEBUGFUNC("e1000_phy_hw_reset_ich8lan");
3125 /* Gate automatic PHY configuration by hardware on non-managed 82579 */
3126 if ((hw->mac.type == e1000_pch2lan) &&
3127 !(E1000_READ_REG(hw, E1000_FWSM) & E1000_ICH_FWSM_FW_VALID))
3128 e1000_gate_hw_phy_config_ich8lan(hw, true);
3130 ret_val = e1000_phy_hw_reset_generic(hw);
3134 return e1000_post_phy_reset_ich8lan(hw);
3138 * e1000_set_lplu_state_pchlan - Set Low Power Link Up state
3139 * @hw: pointer to the HW structure
3140 * @active: true to enable LPLU, false to disable
3142 * Sets the LPLU state according to the active flag. For PCH, if OEM write
3143 * bit are disabled in the NVM, writing the LPLU bits in the MAC will not set
3144 * the phy speed. This function will manually set the LPLU bit and restart
3145 * auto-neg as hw would do. D3 and D0 LPLU will call the same function
3146 * since it configures the same bit.
3148 STATIC s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active)
3153 DEBUGFUNC("e1000_set_lplu_state_pchlan");
3154 ret_val = hw->phy.ops.read_reg(hw, HV_OEM_BITS, &oem_reg);
3159 oem_reg |= HV_OEM_BITS_LPLU;
3161 oem_reg &= ~HV_OEM_BITS_LPLU;
3163 if (!hw->phy.ops.check_reset_block(hw))
3164 oem_reg |= HV_OEM_BITS_RESTART_AN;
3166 return hw->phy.ops.write_reg(hw, HV_OEM_BITS, oem_reg);
3170 * e1000_set_d0_lplu_state_ich8lan - Set Low Power Linkup D0 state
3171 * @hw: pointer to the HW structure
3172 * @active: true to enable LPLU, false to disable
3174 * Sets the LPLU D0 state according to the active flag. When
3175 * activating LPLU this function also disables smart speed
3176 * and vice versa. LPLU will not be activated unless the
3177 * device autonegotiation advertisement meets standards of
3178 * either 10 or 10/100 or 10/100/1000 at all duplexes.
3179 * This is a function pointer entry point only called by
3180 * PHY setup routines.
3182 STATIC s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
3184 struct e1000_phy_info *phy = &hw->phy;
3186 s32 ret_val = E1000_SUCCESS;
3189 DEBUGFUNC("e1000_set_d0_lplu_state_ich8lan");
3191 if (phy->type == e1000_phy_ife)
3192 return E1000_SUCCESS;
3194 phy_ctrl = E1000_READ_REG(hw, E1000_PHY_CTRL);
3197 phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU;
3198 E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl);
3200 if (phy->type != e1000_phy_igp_3)
3201 return E1000_SUCCESS;
3203 /* Call gig speed drop workaround on LPLU before accessing
3206 if (hw->mac.type == e1000_ich8lan)
3207 e1000_gig_downshift_workaround_ich8lan(hw);
3209 /* When LPLU is enabled, we should disable SmartSpeed */
3210 ret_val = phy->ops.read_reg(hw,
3211 IGP01E1000_PHY_PORT_CONFIG,
3215 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
3216 ret_val = phy->ops.write_reg(hw,
3217 IGP01E1000_PHY_PORT_CONFIG,
3222 phy_ctrl &= ~E1000_PHY_CTRL_D0A_LPLU;
3223 E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl);
3225 if (phy->type != e1000_phy_igp_3)
3226 return E1000_SUCCESS;
3228 /* LPLU and SmartSpeed are mutually exclusive. LPLU is used
3229 * during Dx states where the power conservation is most
3230 * important. During driver activity we should enable
3231 * SmartSpeed, so performance is maintained.
3233 if (phy->smart_speed == e1000_smart_speed_on) {
3234 ret_val = phy->ops.read_reg(hw,
3235 IGP01E1000_PHY_PORT_CONFIG,
3240 data |= IGP01E1000_PSCFR_SMART_SPEED;
3241 ret_val = phy->ops.write_reg(hw,
3242 IGP01E1000_PHY_PORT_CONFIG,
3246 } else if (phy->smart_speed == e1000_smart_speed_off) {
3247 ret_val = phy->ops.read_reg(hw,
3248 IGP01E1000_PHY_PORT_CONFIG,
3253 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
3254 ret_val = phy->ops.write_reg(hw,
3255 IGP01E1000_PHY_PORT_CONFIG,
3262 return E1000_SUCCESS;
3266 * e1000_set_d3_lplu_state_ich8lan - Set Low Power Linkup D3 state
3267 * @hw: pointer to the HW structure
3268 * @active: true to enable LPLU, false to disable
3270 * Sets the LPLU D3 state according to the active flag. When
3271 * activating LPLU this function also disables smart speed
3272 * and vice versa. LPLU will not be activated unless the
3273 * device autonegotiation advertisement meets standards of
3274 * either 10 or 10/100 or 10/100/1000 at all duplexes.
3275 * This is a function pointer entry point only called by
3276 * PHY setup routines.
3278 STATIC s32 e1000_set_d3_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
3280 struct e1000_phy_info *phy = &hw->phy;
3282 s32 ret_val = E1000_SUCCESS;
3285 DEBUGFUNC("e1000_set_d3_lplu_state_ich8lan");
3287 phy_ctrl = E1000_READ_REG(hw, E1000_PHY_CTRL);
3290 phy_ctrl &= ~E1000_PHY_CTRL_NOND0A_LPLU;
3291 E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl);
3293 if (phy->type != e1000_phy_igp_3)
3294 return E1000_SUCCESS;
3296 /* LPLU and SmartSpeed are mutually exclusive. LPLU is used
3297 * during Dx states where the power conservation is most
3298 * important. During driver activity we should enable
3299 * SmartSpeed, so performance is maintained.
3301 if (phy->smart_speed == e1000_smart_speed_on) {
3302 ret_val = phy->ops.read_reg(hw,
3303 IGP01E1000_PHY_PORT_CONFIG,
3308 data |= IGP01E1000_PSCFR_SMART_SPEED;
3309 ret_val = phy->ops.write_reg(hw,
3310 IGP01E1000_PHY_PORT_CONFIG,
3314 } else if (phy->smart_speed == e1000_smart_speed_off) {
3315 ret_val = phy->ops.read_reg(hw,
3316 IGP01E1000_PHY_PORT_CONFIG,
3321 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
3322 ret_val = phy->ops.write_reg(hw,
3323 IGP01E1000_PHY_PORT_CONFIG,
3328 } else if ((phy->autoneg_advertised == E1000_ALL_SPEED_DUPLEX) ||
3329 (phy->autoneg_advertised == E1000_ALL_NOT_GIG) ||
3330 (phy->autoneg_advertised == E1000_ALL_10_SPEED)) {
3331 phy_ctrl |= E1000_PHY_CTRL_NOND0A_LPLU;
3332 E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl);
3334 if (phy->type != e1000_phy_igp_3)
3335 return E1000_SUCCESS;
3337 /* Call gig speed drop workaround on LPLU before accessing
3340 if (hw->mac.type == e1000_ich8lan)
3341 e1000_gig_downshift_workaround_ich8lan(hw);
3343 /* When LPLU is enabled, we should disable SmartSpeed */
3344 ret_val = phy->ops.read_reg(hw,
3345 IGP01E1000_PHY_PORT_CONFIG,
3350 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
3351 ret_val = phy->ops.write_reg(hw,
3352 IGP01E1000_PHY_PORT_CONFIG,
3360 * e1000_valid_nvm_bank_detect_ich8lan - finds out the valid bank 0 or 1
3361 * @hw: pointer to the HW structure
3362 * @bank: pointer to the variable that returns the active bank
3364 * Reads signature byte from the NVM using the flash access registers.
3365 * Word 0x13 bits 15:14 = 10b indicate a valid signature for that bank.
3367 STATIC s32 e1000_valid_nvm_bank_detect_ich8lan(struct e1000_hw *hw, u32 *bank)
3370 struct e1000_nvm_info *nvm = &hw->nvm;
3371 u32 bank1_offset = nvm->flash_bank_size * sizeof(u16);
3372 u32 act_offset = E1000_ICH_NVM_SIG_WORD * 2 + 1;
3377 DEBUGFUNC("e1000_valid_nvm_bank_detect_ich8lan");
3379 switch (hw->mac.type) {
3381 bank1_offset = nvm->flash_bank_size;
3382 act_offset = E1000_ICH_NVM_SIG_WORD;
3384 /* set bank to 0 in case flash read fails */
3388 ret_val = e1000_read_flash_dword_ich8lan(hw, act_offset,
3392 sig_byte = (u8)((nvm_dword & 0xFF00) >> 8);
3393 if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
3394 E1000_ICH_NVM_SIG_VALUE) {
3396 return E1000_SUCCESS;
3400 ret_val = e1000_read_flash_dword_ich8lan(hw, act_offset +
3405 sig_byte = (u8)((nvm_dword & 0xFF00) >> 8);
3406 if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
3407 E1000_ICH_NVM_SIG_VALUE) {
3409 return E1000_SUCCESS;
3412 DEBUGOUT("ERROR: No valid NVM bank present\n");
3413 return -E1000_ERR_NVM;
3416 eecd = E1000_READ_REG(hw, E1000_EECD);
3417 if ((eecd & E1000_EECD_SEC1VAL_VALID_MASK) ==
3418 E1000_EECD_SEC1VAL_VALID_MASK) {
3419 if (eecd & E1000_EECD_SEC1VAL)
3424 return E1000_SUCCESS;
3426 DEBUGOUT("Unable to determine valid NVM bank via EEC - reading flash signature\n");
3429 /* set bank to 0 in case flash read fails */
3433 ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset,
3437 if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
3438 E1000_ICH_NVM_SIG_VALUE) {
3440 return E1000_SUCCESS;
3444 ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset +
3449 if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
3450 E1000_ICH_NVM_SIG_VALUE) {
3452 return E1000_SUCCESS;
3455 DEBUGOUT("ERROR: No valid NVM bank present\n");
3456 return -E1000_ERR_NVM;
3461 * e1000_read_nvm_spt - NVM access for SPT
3462 * @hw: pointer to the HW structure
3463 * @offset: The offset (in bytes) of the word(s) to read.
3464 * @words: Size of data to read in words.
3465 * @data: pointer to the word(s) to read at offset.
3467 * Reads a word(s) from the NVM
3469 STATIC s32 e1000_read_nvm_spt(struct e1000_hw *hw, u16 offset, u16 words,
3472 struct e1000_nvm_info *nvm = &hw->nvm;
3473 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
3475 s32 ret_val = E1000_SUCCESS;
3481 DEBUGFUNC("e1000_read_nvm_spt");
3483 if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
3485 DEBUGOUT("nvm parameter(s) out of bounds\n");
3486 ret_val = -E1000_ERR_NVM;
3490 nvm->ops.acquire(hw);
3492 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
3493 if (ret_val != E1000_SUCCESS) {
3494 DEBUGOUT("Could not detect valid bank, assuming bank 0\n");
3498 act_offset = (bank) ? nvm->flash_bank_size : 0;
3499 act_offset += offset;
3501 ret_val = E1000_SUCCESS;
3503 for (i = 0; i < words; i += 2) {
3504 if (words - i == 1) {
3505 if (dev_spec->shadow_ram[offset+i].modified) {
3506 data[i] = dev_spec->shadow_ram[offset+i].value;
3508 offset_to_read = act_offset + i -
3509 ((act_offset + i) % 2);
3511 e1000_read_flash_dword_ich8lan(hw,
3516 if ((act_offset + i) % 2 == 0)
3517 data[i] = (u16)(dword & 0xFFFF);
3519 data[i] = (u16)((dword >> 16) & 0xFFFF);
3522 offset_to_read = act_offset + i;
3523 if (!(dev_spec->shadow_ram[offset+i].modified) ||
3524 !(dev_spec->shadow_ram[offset+i+1].modified)) {
3526 e1000_read_flash_dword_ich8lan(hw,
3532 if (dev_spec->shadow_ram[offset+i].modified)
3533 data[i] = dev_spec->shadow_ram[offset+i].value;
3535 data[i] = (u16) (dword & 0xFFFF);
3536 if (dev_spec->shadow_ram[offset+i].modified)
3538 dev_spec->shadow_ram[offset+i+1].value;
3540 data[i+1] = (u16) (dword >> 16 & 0xFFFF);
3544 nvm->ops.release(hw);
3548 DEBUGOUT1("NVM read error: %d\n", ret_val);
3554 * e1000_read_nvm_ich8lan - Read word(s) from the NVM
3555 * @hw: pointer to the HW structure
3556 * @offset: The offset (in bytes) of the word(s) to read.
3557 * @words: Size of data to read in words
3558 * @data: Pointer to the word(s) to read at offset.
3560 * Reads a word(s) from the NVM using the flash access registers.
3562 STATIC s32 e1000_read_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
3565 struct e1000_nvm_info *nvm = &hw->nvm;
3566 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
3568 s32 ret_val = E1000_SUCCESS;
3572 DEBUGFUNC("e1000_read_nvm_ich8lan");
3574 if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
3576 DEBUGOUT("nvm parameter(s) out of bounds\n");
3577 ret_val = -E1000_ERR_NVM;
3581 nvm->ops.acquire(hw);
3583 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
3584 if (ret_val != E1000_SUCCESS) {
3585 DEBUGOUT("Could not detect valid bank, assuming bank 0\n");
3589 act_offset = (bank) ? nvm->flash_bank_size : 0;
3590 act_offset += offset;
3592 ret_val = E1000_SUCCESS;
3593 for (i = 0; i < words; i++) {
3594 if (dev_spec->shadow_ram[offset+i].modified) {
3595 data[i] = dev_spec->shadow_ram[offset+i].value;
3597 ret_val = e1000_read_flash_word_ich8lan(hw,
3606 nvm->ops.release(hw);
3610 DEBUGOUT1("NVM read error: %d\n", ret_val);
3616 * e1000_flash_cycle_init_ich8lan - Initialize flash
3617 * @hw: pointer to the HW structure
3619 * This function does initial flash setup so that a new read/write/erase cycle
3622 STATIC s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw)
3624 union ich8_hws_flash_status hsfsts;
3625 s32 ret_val = -E1000_ERR_NVM;
3627 DEBUGFUNC("e1000_flash_cycle_init_ich8lan");
3629 hsfsts.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
3631 /* Check if the flash descriptor is valid */
3632 if (!hsfsts.hsf_status.fldesvalid) {
3633 DEBUGOUT("Flash descriptor invalid. SW Sequencing must be used.\n");
3634 return -E1000_ERR_NVM;
3637 /* Clear FCERR and DAEL in hw status by writing 1 */
3638 hsfsts.hsf_status.flcerr = 1;
3639 hsfsts.hsf_status.dael = 1;
3640 if (hw->mac.type >= e1000_pch_spt)
3641 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_HSFSTS,
3642 hsfsts.regval & 0xFFFF);
3644 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFSTS, hsfsts.regval);
3646 /* Either we should have a hardware SPI cycle in progress
3647 * bit to check against, in order to start a new cycle or
3648 * FDONE bit should be changed in the hardware so that it
3649 * is 1 after hardware reset, which can then be used as an
3650 * indication whether a cycle is in progress or has been
3654 if (!hsfsts.hsf_status.flcinprog) {
3655 /* There is no cycle running at present,
3656 * so we can start a cycle.
3657 * Begin by setting Flash Cycle Done.
3659 hsfsts.hsf_status.flcdone = 1;
3660 if (hw->mac.type >= e1000_pch_spt)
3661 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_HSFSTS,
3662 hsfsts.regval & 0xFFFF);
3664 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFSTS,
3666 ret_val = E1000_SUCCESS;
3670 /* Otherwise poll for sometime so the current
3671 * cycle has a chance to end before giving up.
3673 for (i = 0; i < ICH_FLASH_READ_COMMAND_TIMEOUT; i++) {
3674 hsfsts.regval = E1000_READ_FLASH_REG16(hw,
3676 if (!hsfsts.hsf_status.flcinprog) {
3677 ret_val = E1000_SUCCESS;
3682 if (ret_val == E1000_SUCCESS) {
3683 /* Successful in waiting for previous cycle to timeout,
3684 * now set the Flash Cycle Done.
3686 hsfsts.hsf_status.flcdone = 1;
3687 if (hw->mac.type >= e1000_pch_spt)
3688 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_HSFSTS,
3689 hsfsts.regval & 0xFFFF);
3691 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFSTS,
3694 DEBUGOUT("Flash controller busy, cannot get access\n");
3702 * e1000_flash_cycle_ich8lan - Starts flash cycle (read/write/erase)
3703 * @hw: pointer to the HW structure
3704 * @timeout: maximum time to wait for completion
3706 * This function starts a flash cycle and waits for its completion.
3708 STATIC s32 e1000_flash_cycle_ich8lan(struct e1000_hw *hw, u32 timeout)
3710 union ich8_hws_flash_ctrl hsflctl;
3711 union ich8_hws_flash_status hsfsts;
3714 DEBUGFUNC("e1000_flash_cycle_ich8lan");
3716 /* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */
3717 if (hw->mac.type >= e1000_pch_spt)
3718 hsflctl.regval = E1000_READ_FLASH_REG(hw, ICH_FLASH_HSFSTS)>>16;
3720 hsflctl.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFCTL);
3721 hsflctl.hsf_ctrl.flcgo = 1;
3723 if (hw->mac.type >= e1000_pch_spt)
3724 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_HSFSTS,
3725 hsflctl.regval << 16);
3727 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFCTL, hsflctl.regval);
3729 /* wait till FDONE bit is set to 1 */
3731 hsfsts.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
3732 if (hsfsts.hsf_status.flcdone)
3735 } while (i++ < timeout);
3737 if (hsfsts.hsf_status.flcdone && !hsfsts.hsf_status.flcerr)
3738 return E1000_SUCCESS;
3740 return -E1000_ERR_NVM;
3744 * e1000_read_flash_dword_ich8lan - Read dword from flash
3745 * @hw: pointer to the HW structure
3746 * @offset: offset to data location
3747 * @data: pointer to the location for storing the data
3749 * Reads the flash dword at offset into data. Offset is converted
3750 * to bytes before read.
3752 STATIC s32 e1000_read_flash_dword_ich8lan(struct e1000_hw *hw, u32 offset,
3755 DEBUGFUNC("e1000_read_flash_dword_ich8lan");
3758 return -E1000_ERR_NVM;
3760 /* Must convert word offset into bytes. */
3763 return e1000_read_flash_data32_ich8lan(hw, offset, data);
3767 * e1000_read_flash_word_ich8lan - Read word from flash
3768 * @hw: pointer to the HW structure
3769 * @offset: offset to data location
3770 * @data: pointer to the location for storing the data
3772 * Reads the flash word at offset into data. Offset is converted
3773 * to bytes before read.
3775 STATIC s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset,
3778 DEBUGFUNC("e1000_read_flash_word_ich8lan");
3781 return -E1000_ERR_NVM;
3783 /* Must convert offset into bytes. */
3786 return e1000_read_flash_data_ich8lan(hw, offset, 2, data);
3790 * e1000_read_flash_byte_ich8lan - Read byte from flash
3791 * @hw: pointer to the HW structure
3792 * @offset: The offset of the byte to read.
3793 * @data: Pointer to a byte to store the value read.
3795 * Reads a single byte from the NVM using the flash access registers.
3797 STATIC s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
3803 /* In SPT, only 32 bits access is supported,
3804 * so this function should not be called.
3806 if (hw->mac.type >= e1000_pch_spt)
3807 return -E1000_ERR_NVM;
3809 ret_val = e1000_read_flash_data_ich8lan(hw, offset, 1, &word);
3816 return E1000_SUCCESS;
3820 * e1000_read_flash_data_ich8lan - Read byte or word from NVM
3821 * @hw: pointer to the HW structure
3822 * @offset: The offset (in bytes) of the byte or word to read.
3823 * @size: Size of data to read, 1=byte 2=word
3824 * @data: Pointer to the word to store the value read.
3826 * Reads a byte or word from the NVM using the flash access registers.
3828 STATIC s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
3831 union ich8_hws_flash_status hsfsts;
3832 union ich8_hws_flash_ctrl hsflctl;
3833 u32 flash_linear_addr;
3835 s32 ret_val = -E1000_ERR_NVM;
3838 DEBUGFUNC("e1000_read_flash_data_ich8lan");
3840 if (size < 1 || size > 2 || offset > ICH_FLASH_LINEAR_ADDR_MASK)
3841 return -E1000_ERR_NVM;
3842 flash_linear_addr = ((ICH_FLASH_LINEAR_ADDR_MASK & offset) +
3843 hw->nvm.flash_base_addr);
3848 ret_val = e1000_flash_cycle_init_ich8lan(hw);
3849 if (ret_val != E1000_SUCCESS)
3851 hsflctl.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFCTL);
3853 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
3854 hsflctl.hsf_ctrl.fldbcount = size - 1;
3855 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_READ;
3856 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFCTL, hsflctl.regval);
3857 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FADDR, flash_linear_addr);
3859 ret_val = e1000_flash_cycle_ich8lan(hw,
3860 ICH_FLASH_READ_COMMAND_TIMEOUT);
3862 /* Check if FCERR is set to 1, if set to 1, clear it
3863 * and try the whole sequence a few more times, else
3864 * read in (shift in) the Flash Data0, the order is
3865 * least significant byte first msb to lsb
3867 if (ret_val == E1000_SUCCESS) {
3868 flash_data = E1000_READ_FLASH_REG(hw, ICH_FLASH_FDATA0);
3870 *data = (u8)(flash_data & 0x000000FF);
3872 *data = (u16)(flash_data & 0x0000FFFF);
3875 /* If we've gotten here, then things are probably
3876 * completely hosed, but if the error condition is
3877 * detected, it won't hurt to give it another try...
3878 * ICH_FLASH_CYCLE_REPEAT_COUNT times.
3880 hsfsts.regval = E1000_READ_FLASH_REG16(hw,
3882 if (hsfsts.hsf_status.flcerr) {
3883 /* Repeat for some time before giving up. */
3885 } else if (!hsfsts.hsf_status.flcdone) {
3886 DEBUGOUT("Timeout error - flash cycle did not complete.\n");
3890 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
3896 * e1000_read_flash_data32_ich8lan - Read dword from NVM
3897 * @hw: pointer to the HW structure
3898 * @offset: The offset (in bytes) of the dword to read.
3899 * @data: Pointer to the dword to store the value read.
3901 * Reads a byte or word from the NVM using the flash access registers.
3903 STATIC s32 e1000_read_flash_data32_ich8lan(struct e1000_hw *hw, u32 offset,
3906 union ich8_hws_flash_status hsfsts;
3907 union ich8_hws_flash_ctrl hsflctl;
3908 u32 flash_linear_addr;
3909 s32 ret_val = -E1000_ERR_NVM;
3912 DEBUGFUNC("e1000_read_flash_data_ich8lan");
3914 if (offset > ICH_FLASH_LINEAR_ADDR_MASK ||
3915 hw->mac.type < e1000_pch_spt)
3916 return -E1000_ERR_NVM;
3917 flash_linear_addr = ((ICH_FLASH_LINEAR_ADDR_MASK & offset) +
3918 hw->nvm.flash_base_addr);
3923 ret_val = e1000_flash_cycle_init_ich8lan(hw);
3924 if (ret_val != E1000_SUCCESS)
3926 /* In SPT, This register is in Lan memory space, not flash.
3927 * Therefore, only 32 bit access is supported
3929 hsflctl.regval = E1000_READ_FLASH_REG(hw, ICH_FLASH_HSFSTS)>>16;
3931 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
3932 hsflctl.hsf_ctrl.fldbcount = sizeof(u32) - 1;
3933 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_READ;
3934 /* In SPT, This register is in Lan memory space, not flash.
3935 * Therefore, only 32 bit access is supported
3937 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_HSFSTS,
3938 (u32)hsflctl.regval << 16);
3939 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FADDR, flash_linear_addr);
3941 ret_val = e1000_flash_cycle_ich8lan(hw,
3942 ICH_FLASH_READ_COMMAND_TIMEOUT);
3944 /* Check if FCERR is set to 1, if set to 1, clear it
3945 * and try the whole sequence a few more times, else
3946 * read in (shift in) the Flash Data0, the order is
3947 * least significant byte first msb to lsb
3949 if (ret_val == E1000_SUCCESS) {
3950 *data = E1000_READ_FLASH_REG(hw, ICH_FLASH_FDATA0);
3953 /* If we've gotten here, then things are probably
3954 * completely hosed, but if the error condition is
3955 * detected, it won't hurt to give it another try...
3956 * ICH_FLASH_CYCLE_REPEAT_COUNT times.
3958 hsfsts.regval = E1000_READ_FLASH_REG16(hw,
3960 if (hsfsts.hsf_status.flcerr) {
3961 /* Repeat for some time before giving up. */
3963 } else if (!hsfsts.hsf_status.flcdone) {
3964 DEBUGOUT("Timeout error - flash cycle did not complete.\n");
3968 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
3974 * e1000_write_nvm_ich8lan - Write word(s) to the NVM
3975 * @hw: pointer to the HW structure
3976 * @offset: The offset (in bytes) of the word(s) to write.
3977 * @words: Size of data to write in words
3978 * @data: Pointer to the word(s) to write at offset.
3980 * Writes a byte or word to the NVM using the flash access registers.
3982 STATIC s32 e1000_write_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
3985 struct e1000_nvm_info *nvm = &hw->nvm;
3986 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
3989 DEBUGFUNC("e1000_write_nvm_ich8lan");
3991 if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
3993 DEBUGOUT("nvm parameter(s) out of bounds\n");
3994 return -E1000_ERR_NVM;
3997 nvm->ops.acquire(hw);
3999 for (i = 0; i < words; i++) {
4000 dev_spec->shadow_ram[offset+i].modified = true;
4001 dev_spec->shadow_ram[offset+i].value = data[i];
4004 nvm->ops.release(hw);
4006 return E1000_SUCCESS;
4010 * e1000_update_nvm_checksum_spt - Update the checksum for NVM
4011 * @hw: pointer to the HW structure
4013 * The NVM checksum is updated by calling the generic update_nvm_checksum,
4014 * which writes the checksum to the shadow ram. The changes in the shadow
4015 * ram are then committed to the EEPROM by processing each bank at a time
4016 * checking for the modified bit and writing only the pending changes.
4017 * After a successful commit, the shadow ram is cleared and is ready for
4020 STATIC s32 e1000_update_nvm_checksum_spt(struct e1000_hw *hw)
4022 struct e1000_nvm_info *nvm = &hw->nvm;
4023 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
4024 u32 i, act_offset, new_bank_offset, old_bank_offset, bank;
4028 DEBUGFUNC("e1000_update_nvm_checksum_spt");
4030 ret_val = e1000_update_nvm_checksum_generic(hw);
4034 if (nvm->type != e1000_nvm_flash_sw)
4037 nvm->ops.acquire(hw);
4039 /* We're writing to the opposite bank so if we're on bank 1,
4040 * write to bank 0 etc. We also need to erase the segment that
4041 * is going to be written
4043 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
4044 if (ret_val != E1000_SUCCESS) {
4045 DEBUGOUT("Could not detect valid bank, assuming bank 0\n");
4050 new_bank_offset = nvm->flash_bank_size;
4051 old_bank_offset = 0;
4052 ret_val = e1000_erase_flash_bank_ich8lan(hw, 1);
4056 old_bank_offset = nvm->flash_bank_size;
4057 new_bank_offset = 0;
4058 ret_val = e1000_erase_flash_bank_ich8lan(hw, 0);
4062 for (i = 0; i < E1000_SHADOW_RAM_WORDS; i += 2) {
4063 /* Determine whether to write the value stored
4064 * in the other NVM bank or a modified value stored
4067 ret_val = e1000_read_flash_dword_ich8lan(hw,
4068 i + old_bank_offset,
4071 if (dev_spec->shadow_ram[i].modified) {
4072 dword &= 0xffff0000;
4073 dword |= (dev_spec->shadow_ram[i].value & 0xffff);
4075 if (dev_spec->shadow_ram[i + 1].modified) {
4076 dword &= 0x0000ffff;
4077 dword |= ((dev_spec->shadow_ram[i + 1].value & 0xffff)
4083 /* If the word is 0x13, then make sure the signature bits
4084 * (15:14) are 11b until the commit has completed.
4085 * This will allow us to write 10b which indicates the
4086 * signature is valid. We want to do this after the write
4087 * has completed so that we don't mark the segment valid
4088 * while the write is still in progress
4090 if (i == E1000_ICH_NVM_SIG_WORD - 1)
4091 dword |= E1000_ICH_NVM_SIG_MASK << 16;
4093 /* Convert offset to bytes. */
4094 act_offset = (i + new_bank_offset) << 1;
4098 /* Write the data to the new bank. Offset in words*/
4099 act_offset = i + new_bank_offset;
4100 ret_val = e1000_retry_write_flash_dword_ich8lan(hw, act_offset,
4106 /* Don't bother writing the segment valid bits if sector
4107 * programming failed.
4110 DEBUGOUT("Flash commit failed.\n");
4114 /* Finally validate the new segment by setting bit 15:14
4115 * to 10b in word 0x13 , this can be done without an
4116 * erase as well since these bits are 11 to start with
4117 * and we need to change bit 14 to 0b
4119 act_offset = new_bank_offset + E1000_ICH_NVM_SIG_WORD;
4121 /*offset in words but we read dword*/
4123 ret_val = e1000_read_flash_dword_ich8lan(hw, act_offset, &dword);
4128 dword &= 0xBFFFFFFF;
4129 ret_val = e1000_retry_write_flash_dword_ich8lan(hw, act_offset, dword);
4134 /* And invalidate the previously valid segment by setting
4135 * its signature word (0x13) high_byte to 0b. This can be
4136 * done without an erase because flash erase sets all bits
4137 * to 1's. We can write 1's to 0's without an erase
4139 act_offset = (old_bank_offset + E1000_ICH_NVM_SIG_WORD) * 2 + 1;
4141 /* offset in words but we read dword*/
4142 act_offset = old_bank_offset + E1000_ICH_NVM_SIG_WORD - 1;
4143 ret_val = e1000_read_flash_dword_ich8lan(hw, act_offset, &dword);
4148 dword &= 0x00FFFFFF;
4149 ret_val = e1000_retry_write_flash_dword_ich8lan(hw, act_offset, dword);
4154 /* Great! Everything worked, we can now clear the cached entries. */
4155 for (i = 0; i < E1000_SHADOW_RAM_WORDS; i++) {
4156 dev_spec->shadow_ram[i].modified = false;
4157 dev_spec->shadow_ram[i].value = 0xFFFF;
4161 nvm->ops.release(hw);
4163 /* Reload the EEPROM, or else modifications will not appear
4164 * until after the next adapter reset.
4167 nvm->ops.reload(hw);
4173 DEBUGOUT1("NVM update error: %d\n", ret_val);
4179 * e1000_update_nvm_checksum_ich8lan - Update the checksum for NVM
4180 * @hw: pointer to the HW structure
4182 * The NVM checksum is updated by calling the generic update_nvm_checksum,
4183 * which writes the checksum to the shadow ram. The changes in the shadow
4184 * ram are then committed to the EEPROM by processing each bank at a time
4185 * checking for the modified bit and writing only the pending changes.
4186 * After a successful commit, the shadow ram is cleared and is ready for
4189 STATIC s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw)
4191 struct e1000_nvm_info *nvm = &hw->nvm;
4192 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
4193 u32 i, act_offset, new_bank_offset, old_bank_offset, bank;
4197 DEBUGFUNC("e1000_update_nvm_checksum_ich8lan");
4199 ret_val = e1000_update_nvm_checksum_generic(hw);
4203 if (nvm->type != e1000_nvm_flash_sw)
4206 nvm->ops.acquire(hw);
4208 /* We're writing to the opposite bank so if we're on bank 1,
4209 * write to bank 0 etc. We also need to erase the segment that
4210 * is going to be written
4212 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
4213 if (ret_val != E1000_SUCCESS) {
4214 DEBUGOUT("Could not detect valid bank, assuming bank 0\n");
4219 new_bank_offset = nvm->flash_bank_size;
4220 old_bank_offset = 0;
4221 ret_val = e1000_erase_flash_bank_ich8lan(hw, 1);
4225 old_bank_offset = nvm->flash_bank_size;
4226 new_bank_offset = 0;
4227 ret_val = e1000_erase_flash_bank_ich8lan(hw, 0);
4231 for (i = 0; i < E1000_SHADOW_RAM_WORDS; i++) {
4232 if (dev_spec->shadow_ram[i].modified) {
4233 data = dev_spec->shadow_ram[i].value;
4235 ret_val = e1000_read_flash_word_ich8lan(hw, i +
4241 /* If the word is 0x13, then make sure the signature bits
4242 * (15:14) are 11b until the commit has completed.
4243 * This will allow us to write 10b which indicates the
4244 * signature is valid. We want to do this after the write
4245 * has completed so that we don't mark the segment valid
4246 * while the write is still in progress
4248 if (i == E1000_ICH_NVM_SIG_WORD)
4249 data |= E1000_ICH_NVM_SIG_MASK;
4251 /* Convert offset to bytes. */
4252 act_offset = (i + new_bank_offset) << 1;
4256 /* Write the bytes to the new bank. */
4257 ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
4264 ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
4271 /* Don't bother writing the segment valid bits if sector
4272 * programming failed.
4275 DEBUGOUT("Flash commit failed.\n");
4279 /* Finally validate the new segment by setting bit 15:14
4280 * to 10b in word 0x13 , this can be done without an
4281 * erase as well since these bits are 11 to start with
4282 * and we need to change bit 14 to 0b
4284 act_offset = new_bank_offset + E1000_ICH_NVM_SIG_WORD;
4285 ret_val = e1000_read_flash_word_ich8lan(hw, act_offset, &data);
4290 ret_val = e1000_retry_write_flash_byte_ich8lan(hw, act_offset * 2 + 1,
4295 /* And invalidate the previously valid segment by setting
4296 * its signature word (0x13) high_byte to 0b. This can be
4297 * done without an erase because flash erase sets all bits
4298 * to 1's. We can write 1's to 0's without an erase
4300 act_offset = (old_bank_offset + E1000_ICH_NVM_SIG_WORD) * 2 + 1;
4302 ret_val = e1000_retry_write_flash_byte_ich8lan(hw, act_offset, 0);
4307 /* Great! Everything worked, we can now clear the cached entries. */
4308 for (i = 0; i < E1000_SHADOW_RAM_WORDS; i++) {
4309 dev_spec->shadow_ram[i].modified = false;
4310 dev_spec->shadow_ram[i].value = 0xFFFF;
4314 nvm->ops.release(hw);
4316 /* Reload the EEPROM, or else modifications will not appear
4317 * until after the next adapter reset.
4320 nvm->ops.reload(hw);
4326 DEBUGOUT1("NVM update error: %d\n", ret_val);
4332 * e1000_validate_nvm_checksum_ich8lan - Validate EEPROM checksum
4333 * @hw: pointer to the HW structure
4335 * Check to see if checksum needs to be fixed by reading bit 6 in word 0x19.
4336 * If the bit is 0, that the EEPROM had been modified, but the checksum was not
4337 * calculated, in which case we need to calculate the checksum and set bit 6.
4339 STATIC s32 e1000_validate_nvm_checksum_ich8lan(struct e1000_hw *hw)
4344 u16 valid_csum_mask;
4346 DEBUGFUNC("e1000_validate_nvm_checksum_ich8lan");
4348 /* Read NVM and check Invalid Image CSUM bit. If this bit is 0,
4349 * the checksum needs to be fixed. This bit is an indication that
4350 * the NVM was prepared by OEM software and did not calculate
4351 * the checksum...a likely scenario.
4353 switch (hw->mac.type) {
4357 valid_csum_mask = NVM_COMPAT_VALID_CSUM;
4360 word = NVM_FUTURE_INIT_WORD1;
4361 valid_csum_mask = NVM_FUTURE_INIT_WORD1_VALID_CSUM;
4365 ret_val = hw->nvm.ops.read(hw, word, 1, &data);
4369 if (!(data & valid_csum_mask)) {
4370 data |= valid_csum_mask;
4371 ret_val = hw->nvm.ops.write(hw, word, 1, &data);
4374 ret_val = hw->nvm.ops.update(hw);
4379 return e1000_validate_nvm_checksum_generic(hw);
4383 * e1000_write_flash_data_ich8lan - Writes bytes to the NVM
4384 * @hw: pointer to the HW structure
4385 * @offset: The offset (in bytes) of the byte/word to read.
4386 * @size: Size of data to read, 1=byte 2=word
4387 * @data: The byte(s) to write to the NVM.
4389 * Writes one/two bytes to the NVM using the flash access registers.
4391 STATIC s32 e1000_write_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
4394 union ich8_hws_flash_status hsfsts;
4395 union ich8_hws_flash_ctrl hsflctl;
4396 u32 flash_linear_addr;
4401 DEBUGFUNC("e1000_write_ich8_data");
4403 if (hw->mac.type >= e1000_pch_spt) {
4404 if (size != 4 || offset > ICH_FLASH_LINEAR_ADDR_MASK)
4405 return -E1000_ERR_NVM;
4407 if (size < 1 || size > 2 || offset > ICH_FLASH_LINEAR_ADDR_MASK)
4408 return -E1000_ERR_NVM;
4411 flash_linear_addr = ((ICH_FLASH_LINEAR_ADDR_MASK & offset) +
4412 hw->nvm.flash_base_addr);
4417 ret_val = e1000_flash_cycle_init_ich8lan(hw);
4418 if (ret_val != E1000_SUCCESS)
4420 /* In SPT, This register is in Lan memory space, not
4421 * flash. Therefore, only 32 bit access is supported
4423 if (hw->mac.type >= e1000_pch_spt)
4425 E1000_READ_FLASH_REG(hw, ICH_FLASH_HSFSTS)>>16;
4428 E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFCTL);
4430 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
4431 hsflctl.hsf_ctrl.fldbcount = size - 1;
4432 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_WRITE;
4433 /* In SPT, This register is in Lan memory space,
4434 * not flash. Therefore, only 32 bit access is
4437 if (hw->mac.type >= e1000_pch_spt)
4438 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_HSFSTS,
4439 hsflctl.regval << 16);
4441 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFCTL,
4444 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FADDR, flash_linear_addr);
4447 flash_data = (u32)data & 0x00FF;
4449 flash_data = (u32)data;
4451 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FDATA0, flash_data);
4453 /* check if FCERR is set to 1 , if set to 1, clear it
4454 * and try the whole sequence a few more times else done
4457 e1000_flash_cycle_ich8lan(hw,
4458 ICH_FLASH_WRITE_COMMAND_TIMEOUT);
4459 if (ret_val == E1000_SUCCESS)
4462 /* If we're here, then things are most likely
4463 * completely hosed, but if the error condition
4464 * is detected, it won't hurt to give it another
4465 * try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
4467 hsfsts.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
4468 if (hsfsts.hsf_status.flcerr)
4469 /* Repeat for some time before giving up. */
4471 if (!hsfsts.hsf_status.flcdone) {
4472 DEBUGOUT("Timeout error - flash cycle did not complete.\n");
4475 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
4481 * e1000_write_flash_data32_ich8lan - Writes 4 bytes to the NVM
4482 * @hw: pointer to the HW structure
4483 * @offset: The offset (in bytes) of the dwords to read.
4484 * @data: The 4 bytes to write to the NVM.
4486 * Writes one/two/four bytes to the NVM using the flash access registers.
4488 STATIC s32 e1000_write_flash_data32_ich8lan(struct e1000_hw *hw, u32 offset,
4491 union ich8_hws_flash_status hsfsts;
4492 union ich8_hws_flash_ctrl hsflctl;
4493 u32 flash_linear_addr;
4497 DEBUGFUNC("e1000_write_flash_data32_ich8lan");
4499 if (hw->mac.type >= e1000_pch_spt) {
4500 if (offset > ICH_FLASH_LINEAR_ADDR_MASK)
4501 return -E1000_ERR_NVM;
4503 flash_linear_addr = ((ICH_FLASH_LINEAR_ADDR_MASK & offset) +
4504 hw->nvm.flash_base_addr);
4508 ret_val = e1000_flash_cycle_init_ich8lan(hw);
4509 if (ret_val != E1000_SUCCESS)
4512 /* In SPT, This register is in Lan memory space, not
4513 * flash. Therefore, only 32 bit access is supported
4515 if (hw->mac.type >= e1000_pch_spt)
4516 hsflctl.regval = E1000_READ_FLASH_REG(hw,
4520 hsflctl.regval = E1000_READ_FLASH_REG16(hw,
4523 hsflctl.hsf_ctrl.fldbcount = sizeof(u32) - 1;
4524 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_WRITE;
4526 /* In SPT, This register is in Lan memory space,
4527 * not flash. Therefore, only 32 bit access is
4530 if (hw->mac.type >= e1000_pch_spt)
4531 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_HSFSTS,
4532 hsflctl.regval << 16);
4534 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFCTL,
4537 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FADDR, flash_linear_addr);
4539 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FDATA0, data);
4541 /* check if FCERR is set to 1 , if set to 1, clear it
4542 * and try the whole sequence a few more times else done
4544 ret_val = e1000_flash_cycle_ich8lan(hw,
4545 ICH_FLASH_WRITE_COMMAND_TIMEOUT);
4547 if (ret_val == E1000_SUCCESS)
4550 /* If we're here, then things are most likely
4551 * completely hosed, but if the error condition
4552 * is detected, it won't hurt to give it another
4553 * try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
4555 hsfsts.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
4557 if (hsfsts.hsf_status.flcerr)
4558 /* Repeat for some time before giving up. */
4560 if (!hsfsts.hsf_status.flcdone) {
4561 DEBUGOUT("Timeout error - flash cycle did not complete.\n");
4564 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
4570 * e1000_write_flash_byte_ich8lan - Write a single byte to NVM
4571 * @hw: pointer to the HW structure
4572 * @offset: The index of the byte to read.
4573 * @data: The byte to write to the NVM.
4575 * Writes a single byte to the NVM using the flash access registers.
4577 STATIC s32 e1000_write_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
4580 u16 word = (u16)data;
4582 DEBUGFUNC("e1000_write_flash_byte_ich8lan");
4584 return e1000_write_flash_data_ich8lan(hw, offset, 1, word);
4588 * e1000_retry_write_flash_dword_ich8lan - Writes a dword to NVM
4589 * @hw: pointer to the HW structure
4590 * @offset: The offset of the word to write.
4591 * @dword: The dword to write to the NVM.
4593 * Writes a single dword to the NVM using the flash access registers.
4594 * Goes through a retry algorithm before giving up.
4596 STATIC s32 e1000_retry_write_flash_dword_ich8lan(struct e1000_hw *hw,
4597 u32 offset, u32 dword)
4600 u16 program_retries;
4602 DEBUGFUNC("e1000_retry_write_flash_dword_ich8lan");
4604 /* Must convert word offset into bytes. */
4607 ret_val = e1000_write_flash_data32_ich8lan(hw, offset, dword);
4611 for (program_retries = 0; program_retries < 100; program_retries++) {
4612 DEBUGOUT2("Retrying Byte %8.8X at offset %u\n", dword, offset);
4614 ret_val = e1000_write_flash_data32_ich8lan(hw, offset, dword);
4615 if (ret_val == E1000_SUCCESS)
4618 if (program_retries == 100)
4619 return -E1000_ERR_NVM;
4621 return E1000_SUCCESS;
4625 * e1000_retry_write_flash_byte_ich8lan - Writes a single byte to NVM
4626 * @hw: pointer to the HW structure
4627 * @offset: The offset of the byte to write.
4628 * @byte: The byte to write to the NVM.
4630 * Writes a single byte to the NVM using the flash access registers.
4631 * Goes through a retry algorithm before giving up.
4633 STATIC s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw,
4634 u32 offset, u8 byte)
4637 u16 program_retries;
4639 DEBUGFUNC("e1000_retry_write_flash_byte_ich8lan");
4641 ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
4645 for (program_retries = 0; program_retries < 100; program_retries++) {
4646 DEBUGOUT2("Retrying Byte %2.2X at offset %u\n", byte, offset);
4648 ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
4649 if (ret_val == E1000_SUCCESS)
4652 if (program_retries == 100)
4653 return -E1000_ERR_NVM;
4655 return E1000_SUCCESS;
4659 * e1000_erase_flash_bank_ich8lan - Erase a bank (4k) from NVM
4660 * @hw: pointer to the HW structure
4661 * @bank: 0 for first bank, 1 for second bank, etc.
4663 * Erases the bank specified. Each bank is a 4k block. Banks are 0 based.
4664 * bank N is 4096 * N + flash_reg_addr.
4666 STATIC s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank)
4668 struct e1000_nvm_info *nvm = &hw->nvm;
4669 union ich8_hws_flash_status hsfsts;
4670 union ich8_hws_flash_ctrl hsflctl;
4671 u32 flash_linear_addr;
4672 /* bank size is in 16bit words - adjust to bytes */
4673 u32 flash_bank_size = nvm->flash_bank_size * 2;
4676 s32 j, iteration, sector_size;
4678 DEBUGFUNC("e1000_erase_flash_bank_ich8lan");
4680 hsfsts.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
4682 /* Determine HW Sector size: Read BERASE bits of hw flash status
4684 * 00: The Hw sector is 256 bytes, hence we need to erase 16
4685 * consecutive sectors. The start index for the nth Hw sector
4686 * can be calculated as = bank * 4096 + n * 256
4687 * 01: The Hw sector is 4K bytes, hence we need to erase 1 sector.
4688 * The start index for the nth Hw sector can be calculated
4690 * 10: The Hw sector is 8K bytes, nth sector = bank * 8192
4691 * (ich9 only, otherwise error condition)
4692 * 11: The Hw sector is 64K bytes, nth sector = bank * 65536
4694 switch (hsfsts.hsf_status.berasesz) {
4696 /* Hw sector size 256 */
4697 sector_size = ICH_FLASH_SEG_SIZE_256;
4698 iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_256;
4701 sector_size = ICH_FLASH_SEG_SIZE_4K;
4705 sector_size = ICH_FLASH_SEG_SIZE_8K;
4709 sector_size = ICH_FLASH_SEG_SIZE_64K;
4713 return -E1000_ERR_NVM;
4716 /* Start with the base address, then add the sector offset. */
4717 flash_linear_addr = hw->nvm.flash_base_addr;
4718 flash_linear_addr += (bank) ? flash_bank_size : 0;
4720 for (j = 0; j < iteration; j++) {
4722 u32 timeout = ICH_FLASH_ERASE_COMMAND_TIMEOUT;
4725 ret_val = e1000_flash_cycle_init_ich8lan(hw);
4729 /* Write a value 11 (block Erase) in Flash
4730 * Cycle field in hw flash control
4732 if (hw->mac.type >= e1000_pch_spt)
4734 E1000_READ_FLASH_REG(hw,
4735 ICH_FLASH_HSFSTS)>>16;
4738 E1000_READ_FLASH_REG16(hw,
4741 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_ERASE;
4742 if (hw->mac.type >= e1000_pch_spt)
4743 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_HSFSTS,
4744 hsflctl.regval << 16);
4746 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFCTL,
4749 /* Write the last 24 bits of an index within the
4750 * block into Flash Linear address field in Flash
4753 flash_linear_addr += (j * sector_size);
4754 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FADDR,
4757 ret_val = e1000_flash_cycle_ich8lan(hw, timeout);
4758 if (ret_val == E1000_SUCCESS)
4761 /* Check if FCERR is set to 1. If 1,
4762 * clear it and try the whole sequence
4763 * a few more times else Done
4765 hsfsts.regval = E1000_READ_FLASH_REG16(hw,
4767 if (hsfsts.hsf_status.flcerr)
4768 /* repeat for some time before giving up */
4770 else if (!hsfsts.hsf_status.flcdone)
4772 } while (++count < ICH_FLASH_CYCLE_REPEAT_COUNT);
4775 return E1000_SUCCESS;
4779 * e1000_valid_led_default_ich8lan - Set the default LED settings
4780 * @hw: pointer to the HW structure
4781 * @data: Pointer to the LED settings
4783 * Reads the LED default settings from the NVM to data. If the NVM LED
4784 * settings is all 0's or F's, set the LED default to a valid LED default
4787 STATIC s32 e1000_valid_led_default_ich8lan(struct e1000_hw *hw, u16 *data)
4791 DEBUGFUNC("e1000_valid_led_default_ich8lan");
4793 ret_val = hw->nvm.ops.read(hw, NVM_ID_LED_SETTINGS, 1, data);
4795 DEBUGOUT("NVM Read Error\n");
4799 if (*data == ID_LED_RESERVED_0000 || *data == ID_LED_RESERVED_FFFF)
4800 *data = ID_LED_DEFAULT_ICH8LAN;
4802 return E1000_SUCCESS;
4806 * e1000_id_led_init_pchlan - store LED configurations
4807 * @hw: pointer to the HW structure
4809 * PCH does not control LEDs via the LEDCTL register, rather it uses
4810 * the PHY LED configuration register.
4812 * PCH also does not have an "always on" or "always off" mode which
4813 * complicates the ID feature. Instead of using the "on" mode to indicate
4814 * in ledctl_mode2 the LEDs to use for ID (see e1000_id_led_init_generic()),
4815 * use "link_up" mode. The LEDs will still ID on request if there is no
4816 * link based on logic in e1000_led_[on|off]_pchlan().
4818 STATIC s32 e1000_id_led_init_pchlan(struct e1000_hw *hw)
4820 struct e1000_mac_info *mac = &hw->mac;
4822 const u32 ledctl_on = E1000_LEDCTL_MODE_LINK_UP;
4823 const u32 ledctl_off = E1000_LEDCTL_MODE_LINK_UP | E1000_PHY_LED0_IVRT;
4824 u16 data, i, temp, shift;
4826 DEBUGFUNC("e1000_id_led_init_pchlan");
4828 /* Get default ID LED modes */
4829 ret_val = hw->nvm.ops.valid_led_default(hw, &data);
4833 mac->ledctl_default = E1000_READ_REG(hw, E1000_LEDCTL);
4834 mac->ledctl_mode1 = mac->ledctl_default;
4835 mac->ledctl_mode2 = mac->ledctl_default;
4837 for (i = 0; i < 4; i++) {
4838 temp = (data >> (i << 2)) & E1000_LEDCTL_LED0_MODE_MASK;
4841 case ID_LED_ON1_DEF2:
4842 case ID_LED_ON1_ON2:
4843 case ID_LED_ON1_OFF2:
4844 mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
4845 mac->ledctl_mode1 |= (ledctl_on << shift);
4847 case ID_LED_OFF1_DEF2:
4848 case ID_LED_OFF1_ON2:
4849 case ID_LED_OFF1_OFF2:
4850 mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
4851 mac->ledctl_mode1 |= (ledctl_off << shift);
4858 case ID_LED_DEF1_ON2:
4859 case ID_LED_ON1_ON2:
4860 case ID_LED_OFF1_ON2:
4861 mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
4862 mac->ledctl_mode2 |= (ledctl_on << shift);
4864 case ID_LED_DEF1_OFF2:
4865 case ID_LED_ON1_OFF2:
4866 case ID_LED_OFF1_OFF2:
4867 mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
4868 mac->ledctl_mode2 |= (ledctl_off << shift);
4876 return E1000_SUCCESS;
4880 * e1000_get_bus_info_ich8lan - Get/Set the bus type and width
4881 * @hw: pointer to the HW structure
4883 * ICH8 use the PCI Express bus, but does not contain a PCI Express Capability
4884 * register, so the the bus width is hard coded.
4886 STATIC s32 e1000_get_bus_info_ich8lan(struct e1000_hw *hw)
4888 struct e1000_bus_info *bus = &hw->bus;
4891 DEBUGFUNC("e1000_get_bus_info_ich8lan");
4893 ret_val = e1000_get_bus_info_pcie_generic(hw);
4895 /* ICH devices are "PCI Express"-ish. They have
4896 * a configuration space, but do not contain
4897 * PCI Express Capability registers, so bus width
4898 * must be hardcoded.
4900 if (bus->width == e1000_bus_width_unknown)
4901 bus->width = e1000_bus_width_pcie_x1;
4907 * e1000_reset_hw_ich8lan - Reset the hardware
4908 * @hw: pointer to the HW structure
4910 * Does a full reset of the hardware which includes a reset of the PHY and
4913 STATIC s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
4915 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
4920 DEBUGFUNC("e1000_reset_hw_ich8lan");
4922 /* Prevent the PCI-E bus from sticking if there is no TLP connection
4923 * on the last TLP read/write transaction when MAC is reset.
4925 ret_val = e1000_disable_pcie_master_generic(hw);
4927 DEBUGOUT("PCI-E Master disable polling has failed.\n");
4929 DEBUGOUT("Masking off all interrupts\n");
4930 E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
4932 /* Disable the Transmit and Receive units. Then delay to allow
4933 * any pending transactions to complete before we hit the MAC
4934 * with the global reset.
4936 E1000_WRITE_REG(hw, E1000_RCTL, 0);
4937 E1000_WRITE_REG(hw, E1000_TCTL, E1000_TCTL_PSP);
4938 E1000_WRITE_FLUSH(hw);
4942 /* Workaround for ICH8 bit corruption issue in FIFO memory */
4943 if (hw->mac.type == e1000_ich8lan) {
4944 /* Set Tx and Rx buffer allocation to 8k apiece. */
4945 E1000_WRITE_REG(hw, E1000_PBA, E1000_PBA_8K);
4946 /* Set Packet Buffer Size to 16k. */
4947 E1000_WRITE_REG(hw, E1000_PBS, E1000_PBS_16K);
4950 if (hw->mac.type == e1000_pchlan) {
4951 /* Save the NVM K1 bit setting*/
4952 ret_val = e1000_read_nvm(hw, E1000_NVM_K1_CONFIG, 1, &kum_cfg);
4956 if (kum_cfg & E1000_NVM_K1_ENABLE)
4957 dev_spec->nvm_k1_enabled = true;
4959 dev_spec->nvm_k1_enabled = false;
4962 ctrl = E1000_READ_REG(hw, E1000_CTRL);
4964 if (!hw->phy.ops.check_reset_block(hw)) {
4965 /* Full-chip reset requires MAC and PHY reset at the same
4966 * time to make sure the interface between MAC and the
4967 * external PHY is reset.
4969 ctrl |= E1000_CTRL_PHY_RST;
4971 /* Gate automatic PHY configuration by hardware on
4974 if ((hw->mac.type == e1000_pch2lan) &&
4975 !(E1000_READ_REG(hw, E1000_FWSM) & E1000_ICH_FWSM_FW_VALID))
4976 e1000_gate_hw_phy_config_ich8lan(hw, true);
4978 ret_val = e1000_acquire_swflag_ich8lan(hw);
4979 DEBUGOUT("Issuing a global reset to ich8lan\n");
4980 E1000_WRITE_REG(hw, E1000_CTRL, (ctrl | E1000_CTRL_RST));
4981 /* cannot issue a flush here because it hangs the hardware */
4984 /* Set Phy Config Counter to 50msec */
4985 if (hw->mac.type == e1000_pch2lan) {
4986 reg = E1000_READ_REG(hw, E1000_FEXTNVM3);
4987 reg &= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK;
4988 reg |= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC;
4989 E1000_WRITE_REG(hw, E1000_FEXTNVM3, reg);
4993 E1000_MUTEX_UNLOCK(&hw->dev_spec.ich8lan.swflag_mutex);
4995 if (ctrl & E1000_CTRL_PHY_RST) {
4996 ret_val = hw->phy.ops.get_cfg_done(hw);
5000 ret_val = e1000_post_phy_reset_ich8lan(hw);
5005 /* For PCH, this write will make sure that any noise
5006 * will be detected as a CRC error and be dropped rather than show up
5007 * as a bad packet to the DMA engine.
5009 if (hw->mac.type == e1000_pchlan)
5010 E1000_WRITE_REG(hw, E1000_CRC_OFFSET, 0x65656565);
5012 E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
5013 E1000_READ_REG(hw, E1000_ICR);
5015 reg = E1000_READ_REG(hw, E1000_KABGTXD);
5016 reg |= E1000_KABGTXD_BGSQLBIAS;
5017 E1000_WRITE_REG(hw, E1000_KABGTXD, reg);
5019 return E1000_SUCCESS;
5023 * e1000_init_hw_ich8lan - Initialize the hardware
5024 * @hw: pointer to the HW structure
5026 * Prepares the hardware for transmit and receive by doing the following:
5027 * - initialize hardware bits
5028 * - initialize LED identification
5029 * - setup receive address registers
5030 * - setup flow control
5031 * - setup transmit descriptors
5032 * - clear statistics
5034 STATIC s32 e1000_init_hw_ich8lan(struct e1000_hw *hw)
5036 struct e1000_mac_info *mac = &hw->mac;
5037 u32 ctrl_ext, txdctl, snoop;
5041 DEBUGFUNC("e1000_init_hw_ich8lan");
5043 e1000_initialize_hw_bits_ich8lan(hw);
5045 /* Initialize identification LED */
5046 ret_val = mac->ops.id_led_init(hw);
5047 /* An error is not fatal and we should not stop init due to this */
5049 DEBUGOUT("Error initializing identification LED\n");
5051 /* Setup the receive address. */
5052 e1000_init_rx_addrs_generic(hw, mac->rar_entry_count);
5054 /* Zero out the Multicast HASH table */
5055 DEBUGOUT("Zeroing the MTA\n");
5056 for (i = 0; i < mac->mta_reg_count; i++)
5057 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
5059 /* The 82578 Rx buffer will stall if wakeup is enabled in host and
5060 * the ME. Disable wakeup by clearing the host wakeup bit.
5061 * Reset the phy after disabling host wakeup to reset the Rx buffer.
5063 if (hw->phy.type == e1000_phy_82578) {
5064 hw->phy.ops.read_reg(hw, BM_PORT_GEN_CFG, &i);
5065 i &= ~BM_WUC_HOST_WU_BIT;
5066 hw->phy.ops.write_reg(hw, BM_PORT_GEN_CFG, i);
5067 ret_val = e1000_phy_hw_reset_ich8lan(hw);
5072 /* Setup link and flow control */
5073 ret_val = mac->ops.setup_link(hw);
5075 /* Set the transmit descriptor write-back policy for both queues */
5076 txdctl = E1000_READ_REG(hw, E1000_TXDCTL(0));
5077 txdctl = ((txdctl & ~E1000_TXDCTL_WTHRESH) |
5078 E1000_TXDCTL_FULL_TX_DESC_WB);
5079 txdctl = ((txdctl & ~E1000_TXDCTL_PTHRESH) |
5080 E1000_TXDCTL_MAX_TX_DESC_PREFETCH);
5081 E1000_WRITE_REG(hw, E1000_TXDCTL(0), txdctl);
5082 txdctl = E1000_READ_REG(hw, E1000_TXDCTL(1));
5083 txdctl = ((txdctl & ~E1000_TXDCTL_WTHRESH) |
5084 E1000_TXDCTL_FULL_TX_DESC_WB);
5085 txdctl = ((txdctl & ~E1000_TXDCTL_PTHRESH) |
5086 E1000_TXDCTL_MAX_TX_DESC_PREFETCH);
5087 E1000_WRITE_REG(hw, E1000_TXDCTL(1), txdctl);
5089 /* ICH8 has opposite polarity of no_snoop bits.
5090 * By default, we should use snoop behavior.
5092 if (mac->type == e1000_ich8lan)
5093 snoop = PCIE_ICH8_SNOOP_ALL;
5095 snoop = (u32) ~(PCIE_NO_SNOOP_ALL);
5096 e1000_set_pcie_no_snoop_generic(hw, snoop);
5098 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
5099 ctrl_ext |= E1000_CTRL_EXT_RO_DIS;
5100 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
5102 /* Clear all of the statistics registers (clear on read). It is
5103 * important that we do this after we have tried to establish link
5104 * because the symbol error count will increment wildly if there
5107 e1000_clear_hw_cntrs_ich8lan(hw);
5113 * e1000_initialize_hw_bits_ich8lan - Initialize required hardware bits
5114 * @hw: pointer to the HW structure
5116 * Sets/Clears required hardware bits necessary for correctly setting up the
5117 * hardware for transmit and receive.
5119 STATIC void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw)
5123 DEBUGFUNC("e1000_initialize_hw_bits_ich8lan");
5125 /* Extended Device Control */
5126 reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
5128 /* Enable PHY low-power state when MAC is at D3 w/o WoL */
5129 if (hw->mac.type >= e1000_pchlan)
5130 reg |= E1000_CTRL_EXT_PHYPDEN;
5131 E1000_WRITE_REG(hw, E1000_CTRL_EXT, reg);
5133 /* Transmit Descriptor Control 0 */
5134 reg = E1000_READ_REG(hw, E1000_TXDCTL(0));
5136 E1000_WRITE_REG(hw, E1000_TXDCTL(0), reg);
5138 /* Transmit Descriptor Control 1 */
5139 reg = E1000_READ_REG(hw, E1000_TXDCTL(1));
5141 E1000_WRITE_REG(hw, E1000_TXDCTL(1), reg);
5143 /* Transmit Arbitration Control 0 */
5144 reg = E1000_READ_REG(hw, E1000_TARC(0));
5145 if (hw->mac.type == e1000_ich8lan)
5146 reg |= (1 << 28) | (1 << 29);
5147 reg |= (1 << 23) | (1 << 24) | (1 << 26) | (1 << 27);
5148 E1000_WRITE_REG(hw, E1000_TARC(0), reg);
5150 /* Transmit Arbitration Control 1 */
5151 reg = E1000_READ_REG(hw, E1000_TARC(1));
5152 if (E1000_READ_REG(hw, E1000_TCTL) & E1000_TCTL_MULR)
5156 reg |= (1 << 24) | (1 << 26) | (1 << 30);
5157 E1000_WRITE_REG(hw, E1000_TARC(1), reg);
5160 if (hw->mac.type == e1000_ich8lan) {
5161 reg = E1000_READ_REG(hw, E1000_STATUS);
5163 E1000_WRITE_REG(hw, E1000_STATUS, reg);
5166 /* work-around descriptor data corruption issue during nfs v2 udp
5167 * traffic, just disable the nfs filtering capability
5169 reg = E1000_READ_REG(hw, E1000_RFCTL);
5170 reg |= (E1000_RFCTL_NFSW_DIS | E1000_RFCTL_NFSR_DIS);
5172 /* Disable IPv6 extension header parsing because some malformed
5173 * IPv6 headers can hang the Rx.
5175 if (hw->mac.type == e1000_ich8lan)
5176 reg |= (E1000_RFCTL_IPV6_EX_DIS | E1000_RFCTL_NEW_IPV6_EXT_DIS);
5177 E1000_WRITE_REG(hw, E1000_RFCTL, reg);
5179 /* Enable ECC on Lynxpoint */
5180 if (hw->mac.type >= e1000_pch_lpt) {
5181 reg = E1000_READ_REG(hw, E1000_PBECCSTS);
5182 reg |= E1000_PBECCSTS_ECC_ENABLE;
5183 E1000_WRITE_REG(hw, E1000_PBECCSTS, reg);
5185 reg = E1000_READ_REG(hw, E1000_CTRL);
5186 reg |= E1000_CTRL_MEHE;
5187 E1000_WRITE_REG(hw, E1000_CTRL, reg);
5194 * e1000_setup_link_ich8lan - Setup flow control and link settings
5195 * @hw: pointer to the HW structure
5197 * Determines which flow control settings to use, then configures flow
5198 * control. Calls the appropriate media-specific link configuration
5199 * function. Assuming the adapter has a valid link partner, a valid link
5200 * should be established. Assumes the hardware has previously been reset
5201 * and the transmitter and receiver are not enabled.
5203 STATIC s32 e1000_setup_link_ich8lan(struct e1000_hw *hw)
5207 DEBUGFUNC("e1000_setup_link_ich8lan");
5209 if (hw->phy.ops.check_reset_block(hw))
5210 return E1000_SUCCESS;
5212 /* ICH parts do not have a word in the NVM to determine
5213 * the default flow control setting, so we explicitly
5216 if (hw->fc.requested_mode == e1000_fc_default)
5217 hw->fc.requested_mode = e1000_fc_full;
5219 /* Save off the requested flow control mode for use later. Depending
5220 * on the link partner's capabilities, we may or may not use this mode.
5222 hw->fc.current_mode = hw->fc.requested_mode;
5224 DEBUGOUT1("After fix-ups FlowControl is now = %x\n",
5225 hw->fc.current_mode);
5227 /* Continue to configure the copper link. */
5228 ret_val = hw->mac.ops.setup_physical_interface(hw);
5232 E1000_WRITE_REG(hw, E1000_FCTTV, hw->fc.pause_time);
5233 if ((hw->phy.type == e1000_phy_82578) ||
5234 (hw->phy.type == e1000_phy_82579) ||
5235 (hw->phy.type == e1000_phy_i217) ||
5236 (hw->phy.type == e1000_phy_82577)) {
5237 E1000_WRITE_REG(hw, E1000_FCRTV_PCH, hw->fc.refresh_time);
5239 ret_val = hw->phy.ops.write_reg(hw,
5240 PHY_REG(BM_PORT_CTRL_PAGE, 27),
5246 return e1000_set_fc_watermarks_generic(hw);
5250 * e1000_setup_copper_link_ich8lan - Configure MAC/PHY interface
5251 * @hw: pointer to the HW structure
5253 * Configures the kumeran interface to the PHY to wait the appropriate time
5254 * when polling the PHY, then call the generic setup_copper_link to finish
5255 * configuring the copper link.
5257 STATIC s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw)
5263 DEBUGFUNC("e1000_setup_copper_link_ich8lan");
5265 ctrl = E1000_READ_REG(hw, E1000_CTRL);
5266 ctrl |= E1000_CTRL_SLU;
5267 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
5268 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
5270 /* Set the mac to wait the maximum time between each iteration
5271 * and increase the max iterations when polling the phy;
5272 * this fixes erroneous timeouts at 10Mbps.
5274 ret_val = e1000_write_kmrn_reg_generic(hw, E1000_KMRNCTRLSTA_TIMEOUTS,
5278 ret_val = e1000_read_kmrn_reg_generic(hw,
5279 E1000_KMRNCTRLSTA_INBAND_PARAM,
5284 ret_val = e1000_write_kmrn_reg_generic(hw,
5285 E1000_KMRNCTRLSTA_INBAND_PARAM,
5290 switch (hw->phy.type) {
5291 case e1000_phy_igp_3:
5292 ret_val = e1000_copper_link_setup_igp(hw);
5297 case e1000_phy_82578:
5298 ret_val = e1000_copper_link_setup_m88(hw);
5302 case e1000_phy_82577:
5303 case e1000_phy_82579:
5304 ret_val = e1000_copper_link_setup_82577(hw);
5309 ret_val = hw->phy.ops.read_reg(hw, IFE_PHY_MDIX_CONTROL,
5314 reg_data &= ~IFE_PMC_AUTO_MDIX;
5316 switch (hw->phy.mdix) {
5318 reg_data &= ~IFE_PMC_FORCE_MDIX;
5321 reg_data |= IFE_PMC_FORCE_MDIX;
5325 reg_data |= IFE_PMC_AUTO_MDIX;
5328 ret_val = hw->phy.ops.write_reg(hw, IFE_PHY_MDIX_CONTROL,
5337 return e1000_setup_copper_link_generic(hw);
5341 * e1000_setup_copper_link_pch_lpt - Configure MAC/PHY interface
5342 * @hw: pointer to the HW structure
5344 * Calls the PHY specific link setup function and then calls the
5345 * generic setup_copper_link to finish configuring the link for
5346 * Lynxpoint PCH devices
5348 STATIC s32 e1000_setup_copper_link_pch_lpt(struct e1000_hw *hw)
5353 DEBUGFUNC("e1000_setup_copper_link_pch_lpt");
5355 ctrl = E1000_READ_REG(hw, E1000_CTRL);
5356 ctrl |= E1000_CTRL_SLU;
5357 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
5358 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
5360 ret_val = e1000_copper_link_setup_82577(hw);
5364 return e1000_setup_copper_link_generic(hw);
5368 * e1000_get_link_up_info_ich8lan - Get current link speed and duplex
5369 * @hw: pointer to the HW structure
5370 * @speed: pointer to store current link speed
5371 * @duplex: pointer to store the current link duplex
5373 * Calls the generic get_speed_and_duplex to retrieve the current link
5374 * information and then calls the Kumeran lock loss workaround for links at
5377 STATIC s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw, u16 *speed,
5382 DEBUGFUNC("e1000_get_link_up_info_ich8lan");
5384 ret_val = e1000_get_speed_and_duplex_copper_generic(hw, speed, duplex);
5388 if ((hw->mac.type == e1000_ich8lan) &&
5389 (hw->phy.type == e1000_phy_igp_3) &&
5390 (*speed == SPEED_1000)) {
5391 ret_val = e1000_kmrn_lock_loss_workaround_ich8lan(hw);
5398 * e1000_kmrn_lock_loss_workaround_ich8lan - Kumeran workaround
5399 * @hw: pointer to the HW structure
5401 * Work-around for 82566 Kumeran PCS lock loss:
5402 * On link status change (i.e. PCI reset, speed change) and link is up and
5404 * 0) if workaround is optionally disabled do nothing
5405 * 1) wait 1ms for Kumeran link to come up
5406 * 2) check Kumeran Diagnostic register PCS lock loss bit
5407 * 3) if not set the link is locked (all is good), otherwise...
5409 * 5) repeat up to 10 times
5410 * Note: this is only called for IGP3 copper when speed is 1gb.
5412 STATIC s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw)
5414 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
5420 DEBUGFUNC("e1000_kmrn_lock_loss_workaround_ich8lan");
5422 if (!dev_spec->kmrn_lock_loss_workaround_enabled)
5423 return E1000_SUCCESS;
5425 /* Make sure link is up before proceeding. If not just return.
5426 * Attempting this while link is negotiating fouled up link
5429 ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link);
5431 return E1000_SUCCESS;
5433 for (i = 0; i < 10; i++) {
5434 /* read once to clear */
5435 ret_val = hw->phy.ops.read_reg(hw, IGP3_KMRN_DIAG, &data);
5438 /* and again to get new status */
5439 ret_val = hw->phy.ops.read_reg(hw, IGP3_KMRN_DIAG, &data);
5443 /* check for PCS lock */
5444 if (!(data & IGP3_KMRN_DIAG_PCS_LOCK_LOSS))
5445 return E1000_SUCCESS;
5447 /* Issue PHY reset */
5448 hw->phy.ops.reset(hw);
5451 /* Disable GigE link negotiation */
5452 phy_ctrl = E1000_READ_REG(hw, E1000_PHY_CTRL);
5453 phy_ctrl |= (E1000_PHY_CTRL_GBE_DISABLE |
5454 E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
5455 E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl);
5457 /* Call gig speed drop workaround on Gig disable before accessing
5460 e1000_gig_downshift_workaround_ich8lan(hw);
5462 /* unable to acquire PCS lock */
5463 return -E1000_ERR_PHY;
5467 * e1000_set_kmrn_lock_loss_workaround_ich8lan - Set Kumeran workaround state
5468 * @hw: pointer to the HW structure
5469 * @state: boolean value used to set the current Kumeran workaround state
5471 * If ICH8, set the current Kumeran workaround state (enabled - true
5472 * /disabled - false).
5474 void e1000_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw,
5477 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
5479 DEBUGFUNC("e1000_set_kmrn_lock_loss_workaround_ich8lan");
5481 if (hw->mac.type != e1000_ich8lan) {
5482 DEBUGOUT("Workaround applies to ICH8 only.\n");
5486 dev_spec->kmrn_lock_loss_workaround_enabled = state;
5492 * e1000_ipg3_phy_powerdown_workaround_ich8lan - Power down workaround on D3
5493 * @hw: pointer to the HW structure
5495 * Workaround for 82566 power-down on D3 entry:
5496 * 1) disable gigabit link
5497 * 2) write VR power-down enable
5499 * Continue if successful, else issue LCD reset and repeat
5501 void e1000_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw)
5507 DEBUGFUNC("e1000_igp3_phy_powerdown_workaround_ich8lan");
5509 if (hw->phy.type != e1000_phy_igp_3)
5512 /* Try the workaround twice (if needed) */
5515 reg = E1000_READ_REG(hw, E1000_PHY_CTRL);
5516 reg |= (E1000_PHY_CTRL_GBE_DISABLE |
5517 E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
5518 E1000_WRITE_REG(hw, E1000_PHY_CTRL, reg);
5520 /* Call gig speed drop workaround on Gig disable before
5521 * accessing any PHY registers
5523 if (hw->mac.type == e1000_ich8lan)
5524 e1000_gig_downshift_workaround_ich8lan(hw);
5526 /* Write VR power-down enable */
5527 hw->phy.ops.read_reg(hw, IGP3_VR_CTRL, &data);
5528 data &= ~IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
5529 hw->phy.ops.write_reg(hw, IGP3_VR_CTRL,
5530 data | IGP3_VR_CTRL_MODE_SHUTDOWN);
5532 /* Read it back and test */
5533 hw->phy.ops.read_reg(hw, IGP3_VR_CTRL, &data);
5534 data &= IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
5535 if ((data == IGP3_VR_CTRL_MODE_SHUTDOWN) || retry)
5538 /* Issue PHY reset and repeat at most one more time */
5539 reg = E1000_READ_REG(hw, E1000_CTRL);
5540 E1000_WRITE_REG(hw, E1000_CTRL, reg | E1000_CTRL_PHY_RST);
5546 * e1000_gig_downshift_workaround_ich8lan - WoL from S5 stops working
5547 * @hw: pointer to the HW structure
5549 * Steps to take when dropping from 1Gb/s (eg. link cable removal (LSC),
5550 * LPLU, Gig disable, MDIC PHY reset):
5551 * 1) Set Kumeran Near-end loopback
5552 * 2) Clear Kumeran Near-end loopback
5553 * Should only be called for ICH8[m] devices with any 1G Phy.
5555 void e1000_gig_downshift_workaround_ich8lan(struct e1000_hw *hw)
5560 DEBUGFUNC("e1000_gig_downshift_workaround_ich8lan");
5562 if ((hw->mac.type != e1000_ich8lan) ||
5563 (hw->phy.type == e1000_phy_ife))
5566 ret_val = e1000_read_kmrn_reg_generic(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
5570 reg_data |= E1000_KMRNCTRLSTA_DIAG_NELPBK;
5571 ret_val = e1000_write_kmrn_reg_generic(hw,
5572 E1000_KMRNCTRLSTA_DIAG_OFFSET,
5576 reg_data &= ~E1000_KMRNCTRLSTA_DIAG_NELPBK;
5577 e1000_write_kmrn_reg_generic(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
5582 * e1000_suspend_workarounds_ich8lan - workarounds needed during S0->Sx
5583 * @hw: pointer to the HW structure
5585 * During S0 to Sx transition, it is possible the link remains at gig
5586 * instead of negotiating to a lower speed. Before going to Sx, set
5587 * 'Gig Disable' to force link speed negotiation to a lower speed based on
5588 * the LPLU setting in the NVM or custom setting. For PCH and newer parts,
5589 * the OEM bits PHY register (LED, GbE disable and LPLU configurations) also
5590 * needs to be written.
5591 * Parts that support (and are linked to a partner which support) EEE in
5592 * 100Mbps should disable LPLU since 100Mbps w/ EEE requires less power
5593 * than 10Mbps w/o EEE.
5595 void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw)
5597 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
5601 DEBUGFUNC("e1000_suspend_workarounds_ich8lan");
5603 phy_ctrl = E1000_READ_REG(hw, E1000_PHY_CTRL);
5604 phy_ctrl |= E1000_PHY_CTRL_GBE_DISABLE;
5606 if (hw->phy.type == e1000_phy_i217) {
5607 u16 phy_reg, device_id = hw->device_id;
5609 if ((device_id == E1000_DEV_ID_PCH_LPTLP_I218_LM) ||
5610 (device_id == E1000_DEV_ID_PCH_LPTLP_I218_V) ||
5611 (device_id == E1000_DEV_ID_PCH_I218_LM3) ||
5612 (device_id == E1000_DEV_ID_PCH_I218_V3) ||
5613 (hw->mac.type >= e1000_pch_spt)) {
5614 u32 fextnvm6 = E1000_READ_REG(hw, E1000_FEXTNVM6);
5616 E1000_WRITE_REG(hw, E1000_FEXTNVM6,
5617 fextnvm6 & ~E1000_FEXTNVM6_REQ_PLL_CLK);
5620 ret_val = hw->phy.ops.acquire(hw);
5624 if (!dev_spec->eee_disable) {
5628 e1000_read_emi_reg_locked(hw,
5629 I217_EEE_ADVERTISEMENT,
5634 /* Disable LPLU if both link partners support 100BaseT
5635 * EEE and 100Full is advertised on both ends of the
5636 * link, and enable Auto Enable LPI since there will
5637 * be no driver to enable LPI while in Sx.
5639 if ((eee_advert & I82579_EEE_100_SUPPORTED) &&
5640 (dev_spec->eee_lp_ability &
5641 I82579_EEE_100_SUPPORTED) &&
5642 (hw->phy.autoneg_advertised & ADVERTISE_100_FULL)) {
5643 phy_ctrl &= ~(E1000_PHY_CTRL_D0A_LPLU |
5644 E1000_PHY_CTRL_NOND0A_LPLU);
5646 /* Set Auto Enable LPI after link up */
5647 hw->phy.ops.read_reg_locked(hw,
5650 phy_reg |= I217_LPI_GPIO_CTRL_AUTO_EN_LPI;
5651 hw->phy.ops.write_reg_locked(hw,
5657 /* For i217 Intel Rapid Start Technology support,
5658 * when the system is going into Sx and no manageability engine
5659 * is present, the driver must configure proxy to reset only on
5660 * power good. LPI (Low Power Idle) state must also reset only
5661 * on power good, as well as the MTA (Multicast table array).
5662 * The SMBus release must also be disabled on LCD reset.
5664 if (!(E1000_READ_REG(hw, E1000_FWSM) &
5665 E1000_ICH_FWSM_FW_VALID)) {
5666 /* Enable proxy to reset only on power good. */
5667 hw->phy.ops.read_reg_locked(hw, I217_PROXY_CTRL,
5669 phy_reg |= I217_PROXY_CTRL_AUTO_DISABLE;
5670 hw->phy.ops.write_reg_locked(hw, I217_PROXY_CTRL,
5673 /* Set bit enable LPI (EEE) to reset only on
5676 hw->phy.ops.read_reg_locked(hw, I217_SxCTRL, &phy_reg);
5677 phy_reg |= I217_SxCTRL_ENABLE_LPI_RESET;
5678 hw->phy.ops.write_reg_locked(hw, I217_SxCTRL, phy_reg);
5680 /* Disable the SMB release on LCD reset. */
5681 hw->phy.ops.read_reg_locked(hw, I217_MEMPWR, &phy_reg);
5682 phy_reg &= ~I217_MEMPWR_DISABLE_SMB_RELEASE;
5683 hw->phy.ops.write_reg_locked(hw, I217_MEMPWR, phy_reg);
5686 /* Enable MTA to reset for Intel Rapid Start Technology
5689 hw->phy.ops.read_reg_locked(hw, I217_CGFREG, &phy_reg);
5690 phy_reg |= I217_CGFREG_ENABLE_MTA_RESET;
5691 hw->phy.ops.write_reg_locked(hw, I217_CGFREG, phy_reg);
5694 hw->phy.ops.release(hw);
5697 E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl);
5699 if (hw->mac.type == e1000_ich8lan)
5700 e1000_gig_downshift_workaround_ich8lan(hw);
5702 if (hw->mac.type >= e1000_pchlan) {
5703 e1000_oem_bits_config_ich8lan(hw, false);
5705 /* Reset PHY to activate OEM bits on 82577/8 */
5706 if (hw->mac.type == e1000_pchlan)
5707 e1000_phy_hw_reset_generic(hw);
5709 ret_val = hw->phy.ops.acquire(hw);
5712 e1000_write_smbus_addr(hw);
5713 hw->phy.ops.release(hw);
5720 * e1000_resume_workarounds_pchlan - workarounds needed during Sx->S0
5721 * @hw: pointer to the HW structure
5723 * During Sx to S0 transitions on non-managed devices or managed devices
5724 * on which PHY resets are not blocked, if the PHY registers cannot be
5725 * accessed properly by the s/w toggle the LANPHYPC value to power cycle
5727 * On i217, setup Intel Rapid Start Technology.
5729 u32 e1000_resume_workarounds_pchlan(struct e1000_hw *hw)
5733 DEBUGFUNC("e1000_resume_workarounds_pchlan");
5734 if (hw->mac.type < e1000_pch2lan)
5735 return E1000_SUCCESS;
5737 ret_val = e1000_init_phy_workarounds_pchlan(hw);
5739 DEBUGOUT1("Failed to init PHY flow ret_val=%d\n", ret_val);
5743 /* For i217 Intel Rapid Start Technology support when the system
5744 * is transitioning from Sx and no manageability engine is present
5745 * configure SMBus to restore on reset, disable proxy, and enable
5746 * the reset on MTA (Multicast table array).
5748 if (hw->phy.type == e1000_phy_i217) {
5751 ret_val = hw->phy.ops.acquire(hw);
5753 DEBUGOUT("Failed to setup iRST\n");
5757 /* Clear Auto Enable LPI after link up */
5758 hw->phy.ops.read_reg_locked(hw, I217_LPI_GPIO_CTRL, &phy_reg);
5759 phy_reg &= ~I217_LPI_GPIO_CTRL_AUTO_EN_LPI;
5760 hw->phy.ops.write_reg_locked(hw, I217_LPI_GPIO_CTRL, phy_reg);
5762 if (!(E1000_READ_REG(hw, E1000_FWSM) &
5763 E1000_ICH_FWSM_FW_VALID)) {
5764 /* Restore clear on SMB if no manageability engine
5767 ret_val = hw->phy.ops.read_reg_locked(hw, I217_MEMPWR,
5771 phy_reg |= I217_MEMPWR_DISABLE_SMB_RELEASE;
5772 hw->phy.ops.write_reg_locked(hw, I217_MEMPWR, phy_reg);
5775 hw->phy.ops.write_reg_locked(hw, I217_PROXY_CTRL, 0);
5777 /* Enable reset on MTA */
5778 ret_val = hw->phy.ops.read_reg_locked(hw, I217_CGFREG,
5782 phy_reg &= ~I217_CGFREG_ENABLE_MTA_RESET;
5783 hw->phy.ops.write_reg_locked(hw, I217_CGFREG, phy_reg);
5786 DEBUGOUT1("Error %d in resume workarounds\n", ret_val);
5787 hw->phy.ops.release(hw);
5790 return E1000_SUCCESS;
5794 * e1000_cleanup_led_ich8lan - Restore the default LED operation
5795 * @hw: pointer to the HW structure
5797 * Return the LED back to the default configuration.
5799 STATIC s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw)
5801 DEBUGFUNC("e1000_cleanup_led_ich8lan");
5803 if (hw->phy.type == e1000_phy_ife)
5804 return hw->phy.ops.write_reg(hw, IFE_PHY_SPECIAL_CONTROL_LED,
5807 E1000_WRITE_REG(hw, E1000_LEDCTL, hw->mac.ledctl_default);
5808 return E1000_SUCCESS;
5812 * e1000_led_on_ich8lan - Turn LEDs on
5813 * @hw: pointer to the HW structure
5817 STATIC s32 e1000_led_on_ich8lan(struct e1000_hw *hw)
5819 DEBUGFUNC("e1000_led_on_ich8lan");
5821 if (hw->phy.type == e1000_phy_ife)
5822 return hw->phy.ops.write_reg(hw, IFE_PHY_SPECIAL_CONTROL_LED,
5823 (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_ON));
5825 E1000_WRITE_REG(hw, E1000_LEDCTL, hw->mac.ledctl_mode2);
5826 return E1000_SUCCESS;
5830 * e1000_led_off_ich8lan - Turn LEDs off
5831 * @hw: pointer to the HW structure
5833 * Turn off the LEDs.
5835 STATIC s32 e1000_led_off_ich8lan(struct e1000_hw *hw)
5837 DEBUGFUNC("e1000_led_off_ich8lan");
5839 if (hw->phy.type == e1000_phy_ife)
5840 return hw->phy.ops.write_reg(hw, IFE_PHY_SPECIAL_CONTROL_LED,
5841 (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_OFF));
5843 E1000_WRITE_REG(hw, E1000_LEDCTL, hw->mac.ledctl_mode1);
5844 return E1000_SUCCESS;
5848 * e1000_setup_led_pchlan - Configures SW controllable LED
5849 * @hw: pointer to the HW structure
5851 * This prepares the SW controllable LED for use.
5853 STATIC s32 e1000_setup_led_pchlan(struct e1000_hw *hw)
5855 DEBUGFUNC("e1000_setup_led_pchlan");
5857 return hw->phy.ops.write_reg(hw, HV_LED_CONFIG,
5858 (u16)hw->mac.ledctl_mode1);
5862 * e1000_cleanup_led_pchlan - Restore the default LED operation
5863 * @hw: pointer to the HW structure
5865 * Return the LED back to the default configuration.
5867 STATIC s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw)
5869 DEBUGFUNC("e1000_cleanup_led_pchlan");
5871 return hw->phy.ops.write_reg(hw, HV_LED_CONFIG,
5872 (u16)hw->mac.ledctl_default);
5876 * e1000_led_on_pchlan - Turn LEDs on
5877 * @hw: pointer to the HW structure
5881 STATIC s32 e1000_led_on_pchlan(struct e1000_hw *hw)
5883 u16 data = (u16)hw->mac.ledctl_mode2;
5886 DEBUGFUNC("e1000_led_on_pchlan");
5888 /* If no link, then turn LED on by setting the invert bit
5889 * for each LED that's mode is "link_up" in ledctl_mode2.
5891 if (!(E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU)) {
5892 for (i = 0; i < 3; i++) {
5893 led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
5894 if ((led & E1000_PHY_LED0_MODE_MASK) !=
5895 E1000_LEDCTL_MODE_LINK_UP)
5897 if (led & E1000_PHY_LED0_IVRT)
5898 data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
5900 data |= (E1000_PHY_LED0_IVRT << (i * 5));
5904 return hw->phy.ops.write_reg(hw, HV_LED_CONFIG, data);
5908 * e1000_led_off_pchlan - Turn LEDs off
5909 * @hw: pointer to the HW structure
5911 * Turn off the LEDs.
5913 STATIC s32 e1000_led_off_pchlan(struct e1000_hw *hw)
5915 u16 data = (u16)hw->mac.ledctl_mode1;
5918 DEBUGFUNC("e1000_led_off_pchlan");
5920 /* If no link, then turn LED off by clearing the invert bit
5921 * for each LED that's mode is "link_up" in ledctl_mode1.
5923 if (!(E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU)) {
5924 for (i = 0; i < 3; i++) {
5925 led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
5926 if ((led & E1000_PHY_LED0_MODE_MASK) !=
5927 E1000_LEDCTL_MODE_LINK_UP)
5929 if (led & E1000_PHY_LED0_IVRT)
5930 data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
5932 data |= (E1000_PHY_LED0_IVRT << (i * 5));
5936 return hw->phy.ops.write_reg(hw, HV_LED_CONFIG, data);
5940 * e1000_get_cfg_done_ich8lan - Read config done bit after Full or PHY reset
5941 * @hw: pointer to the HW structure
5943 * Read appropriate register for the config done bit for completion status
5944 * and configure the PHY through s/w for EEPROM-less parts.
5946 * NOTE: some silicon which is EEPROM-less will fail trying to read the
5947 * config done bit, so only an error is logged and continues. If we were
5948 * to return with error, EEPROM-less silicon would not be able to be reset
5951 STATIC s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw)
5953 s32 ret_val = E1000_SUCCESS;
5957 DEBUGFUNC("e1000_get_cfg_done_ich8lan");
5959 e1000_get_cfg_done_generic(hw);
5961 /* Wait for indication from h/w that it has completed basic config */
5962 if (hw->mac.type >= e1000_ich10lan) {
5963 e1000_lan_init_done_ich8lan(hw);
5965 ret_val = e1000_get_auto_rd_done_generic(hw);
5967 /* When auto config read does not complete, do not
5968 * return with an error. This can happen in situations
5969 * where there is no eeprom and prevents getting link.
5971 DEBUGOUT("Auto Read Done did not complete\n");
5972 ret_val = E1000_SUCCESS;
5976 /* Clear PHY Reset Asserted bit */
5977 status = E1000_READ_REG(hw, E1000_STATUS);
5978 if (status & E1000_STATUS_PHYRA)
5979 E1000_WRITE_REG(hw, E1000_STATUS, status & ~E1000_STATUS_PHYRA);
5981 DEBUGOUT("PHY Reset Asserted not set - needs delay\n");
5983 /* If EEPROM is not marked present, init the IGP 3 PHY manually */
5984 if (hw->mac.type <= e1000_ich9lan) {
5985 if (!(E1000_READ_REG(hw, E1000_EECD) & E1000_EECD_PRES) &&
5986 (hw->phy.type == e1000_phy_igp_3)) {
5987 e1000_phy_init_script_igp3(hw);
5990 if (e1000_valid_nvm_bank_detect_ich8lan(hw, &bank)) {
5991 /* Maybe we should do a basic PHY config */
5992 DEBUGOUT("EEPROM not present\n");
5993 ret_val = -E1000_ERR_CONFIG;
6001 * e1000_power_down_phy_copper_ich8lan - Remove link during PHY power down
6002 * @hw: pointer to the HW structure
6004 * In the case of a PHY power down to save power, or to turn off link during a
6005 * driver unload, or wake on lan is not enabled, remove the link.
6007 STATIC void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw)
6009 /* If the management interface is not enabled, then power down */
6010 if (!(hw->mac.ops.check_mng_mode(hw) ||
6011 hw->phy.ops.check_reset_block(hw)))
6012 e1000_power_down_phy_copper(hw);
6018 * e1000_clear_hw_cntrs_ich8lan - Clear statistical counters
6019 * @hw: pointer to the HW structure
6021 * Clears hardware counters specific to the silicon family and calls
6022 * clear_hw_cntrs_generic to clear all general purpose counters.
6024 STATIC void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw)
6029 DEBUGFUNC("e1000_clear_hw_cntrs_ich8lan");
6031 e1000_clear_hw_cntrs_base_generic(hw);
6033 E1000_READ_REG(hw, E1000_ALGNERRC);
6034 E1000_READ_REG(hw, E1000_RXERRC);
6035 E1000_READ_REG(hw, E1000_TNCRS);
6036 E1000_READ_REG(hw, E1000_CEXTERR);
6037 E1000_READ_REG(hw, E1000_TSCTC);
6038 E1000_READ_REG(hw, E1000_TSCTFC);
6040 E1000_READ_REG(hw, E1000_MGTPRC);
6041 E1000_READ_REG(hw, E1000_MGTPDC);
6042 E1000_READ_REG(hw, E1000_MGTPTC);
6044 E1000_READ_REG(hw, E1000_IAC);
6045 E1000_READ_REG(hw, E1000_ICRXOC);
6047 /* Clear PHY statistics registers */
6048 if ((hw->phy.type == e1000_phy_82578) ||
6049 (hw->phy.type == e1000_phy_82579) ||
6050 (hw->phy.type == e1000_phy_i217) ||
6051 (hw->phy.type == e1000_phy_82577)) {
6052 ret_val = hw->phy.ops.acquire(hw);
6055 ret_val = hw->phy.ops.set_page(hw,
6056 HV_STATS_PAGE << IGP_PAGE_SHIFT);
6059 hw->phy.ops.read_reg_page(hw, HV_SCC_UPPER, &phy_data);
6060 hw->phy.ops.read_reg_page(hw, HV_SCC_LOWER, &phy_data);
6061 hw->phy.ops.read_reg_page(hw, HV_ECOL_UPPER, &phy_data);
6062 hw->phy.ops.read_reg_page(hw, HV_ECOL_LOWER, &phy_data);
6063 hw->phy.ops.read_reg_page(hw, HV_MCC_UPPER, &phy_data);
6064 hw->phy.ops.read_reg_page(hw, HV_MCC_LOWER, &phy_data);
6065 hw->phy.ops.read_reg_page(hw, HV_LATECOL_UPPER, &phy_data);
6066 hw->phy.ops.read_reg_page(hw, HV_LATECOL_LOWER, &phy_data);
6067 hw->phy.ops.read_reg_page(hw, HV_COLC_UPPER, &phy_data);
6068 hw->phy.ops.read_reg_page(hw, HV_COLC_LOWER, &phy_data);
6069 hw->phy.ops.read_reg_page(hw, HV_DC_UPPER, &phy_data);
6070 hw->phy.ops.read_reg_page(hw, HV_DC_LOWER, &phy_data);
6071 hw->phy.ops.read_reg_page(hw, HV_TNCRS_UPPER, &phy_data);
6072 hw->phy.ops.read_reg_page(hw, HV_TNCRS_LOWER, &phy_data);
6074 hw->phy.ops.release(hw);
6079 * e1000_configure_k0s_lpt - Configure K0s power state
6080 * @hw: pointer to the HW structure
6081 * @entry_latency: Tx idle period for entering K0s - valid values are 0 to 3.
6082 * 0 corresponds to 128ns, each value over 0 doubles the duration.
6083 * @min_time: Minimum Tx idle period allowed - valid values are 0 to 4.
6084 * 0 corresponds to 128ns, each value over 0 doubles the duration.
6086 * Configure the K1 power state based on the provided parameter.
6087 * Assumes semaphore already acquired.
6089 * Success returns 0, Failure returns:
6090 * -E1000_ERR_PHY (-2) in case of access error
6091 * -E1000_ERR_PARAM (-4) in case of parameters error
6093 s32 e1000_configure_k0s_lpt(struct e1000_hw *hw, u8 entry_latency, u8 min_time)
6098 DEBUGFUNC("e1000_configure_k0s_lpt");
6100 if (entry_latency > 3 || min_time > 4)
6101 return -E1000_ERR_PARAM;
6103 ret_val = e1000_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K0S_CTRL,
6108 /* for now don't touch the latency */
6109 kmrn_reg &= ~(E1000_KMRNCTRLSTA_K0S_CTRL_MIN_TIME_MASK);
6110 kmrn_reg |= ((min_time << E1000_KMRNCTRLSTA_K0S_CTRL_MIN_TIME_SHIFT));
6112 ret_val = e1000_write_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K0S_CTRL,
6117 return E1000_SUCCESS;