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) {
350 if (e1000_phy_is_accessible_pchlan(hw))
353 /* Before toggling LANPHYPC, see if PHY is accessible by
354 * forcing MAC to SMBus mode first.
356 mac_reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
357 mac_reg |= E1000_CTRL_EXT_FORCE_SMBUS;
358 E1000_WRITE_REG(hw, E1000_CTRL_EXT, mac_reg);
360 /* Wait 50 milliseconds for MAC to finish any retries
361 * that it might be trying to perform from previous
362 * attempts to acknowledge any phy read requests.
368 if (e1000_phy_is_accessible_pchlan(hw))
373 if ((hw->mac.type == e1000_pchlan) &&
374 (fwsm & E1000_ICH_FWSM_FW_VALID))
377 if (hw->phy.ops.check_reset_block(hw)) {
378 DEBUGOUT("Required LANPHYPC toggle blocked by ME\n");
379 ret_val = -E1000_ERR_PHY;
383 /* Toggle LANPHYPC Value bit */
384 e1000_toggle_lanphypc_pch_lpt(hw);
385 if (hw->mac.type >= e1000_pch_lpt) {
386 if (e1000_phy_is_accessible_pchlan(hw))
389 /* Toggling LANPHYPC brings the PHY out of SMBus mode
390 * so ensure that the MAC is also out of SMBus mode
392 mac_reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
393 mac_reg &= ~E1000_CTRL_EXT_FORCE_SMBUS;
394 E1000_WRITE_REG(hw, E1000_CTRL_EXT, mac_reg);
396 if (e1000_phy_is_accessible_pchlan(hw))
399 ret_val = -E1000_ERR_PHY;
406 hw->phy.ops.release(hw);
409 /* Check to see if able to reset PHY. Print error if not */
410 if (hw->phy.ops.check_reset_block(hw)) {
411 ERROR_REPORT("Reset blocked by ME\n");
415 /* Reset the PHY before any access to it. Doing so, ensures
416 * that the PHY is in a known good state before we read/write
417 * PHY registers. The generic reset is sufficient here,
418 * because we haven't determined the PHY type yet.
420 ret_val = e1000_phy_hw_reset_generic(hw);
424 /* On a successful reset, possibly need to wait for the PHY
425 * to quiesce to an accessible state before returning control
426 * to the calling function. If the PHY does not quiesce, then
427 * return E1000E_BLK_PHY_RESET, as this is the condition that
430 ret_val = hw->phy.ops.check_reset_block(hw);
432 ERROR_REPORT("ME blocked access to PHY after reset\n");
436 /* Ungate automatic PHY configuration on non-managed 82579 */
437 if ((hw->mac.type == e1000_pch2lan) &&
438 !(fwsm & E1000_ICH_FWSM_FW_VALID)) {
440 e1000_gate_hw_phy_config_ich8lan(hw, false);
447 * e1000_init_phy_params_pchlan - Initialize PHY function pointers
448 * @hw: pointer to the HW structure
450 * Initialize family-specific PHY parameters and function pointers.
452 STATIC s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw)
454 struct e1000_phy_info *phy = &hw->phy;
457 DEBUGFUNC("e1000_init_phy_params_pchlan");
460 phy->reset_delay_us = 100;
462 phy->ops.acquire = e1000_acquire_swflag_ich8lan;
463 phy->ops.check_reset_block = e1000_check_reset_block_ich8lan;
464 phy->ops.get_cfg_done = e1000_get_cfg_done_ich8lan;
465 phy->ops.set_page = e1000_set_page_igp;
466 phy->ops.read_reg = e1000_read_phy_reg_hv;
467 phy->ops.read_reg_locked = e1000_read_phy_reg_hv_locked;
468 phy->ops.read_reg_page = e1000_read_phy_reg_page_hv;
469 phy->ops.release = e1000_release_swflag_ich8lan;
470 phy->ops.reset = e1000_phy_hw_reset_ich8lan;
471 phy->ops.set_d0_lplu_state = e1000_set_lplu_state_pchlan;
472 phy->ops.set_d3_lplu_state = e1000_set_lplu_state_pchlan;
473 phy->ops.write_reg = e1000_write_phy_reg_hv;
474 phy->ops.write_reg_locked = e1000_write_phy_reg_hv_locked;
475 phy->ops.write_reg_page = e1000_write_phy_reg_page_hv;
476 phy->ops.power_up = e1000_power_up_phy_copper;
477 phy->ops.power_down = e1000_power_down_phy_copper_ich8lan;
478 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
480 phy->id = e1000_phy_unknown;
482 ret_val = e1000_init_phy_workarounds_pchlan(hw);
486 if (phy->id == e1000_phy_unknown)
487 switch (hw->mac.type) {
489 ret_val = e1000_get_phy_id(hw);
492 if ((phy->id != 0) && (phy->id != PHY_REVISION_MASK))
499 /* In case the PHY needs to be in mdio slow mode,
500 * set slow mode and try to get the PHY id again.
502 ret_val = e1000_set_mdio_slow_mode_hv(hw);
505 ret_val = e1000_get_phy_id(hw);
510 phy->type = e1000_get_phy_type_from_id(phy->id);
513 case e1000_phy_82577:
514 case e1000_phy_82579:
516 phy->ops.check_polarity = e1000_check_polarity_82577;
517 phy->ops.force_speed_duplex =
518 e1000_phy_force_speed_duplex_82577;
519 phy->ops.get_cable_length = e1000_get_cable_length_82577;
520 phy->ops.get_info = e1000_get_phy_info_82577;
521 phy->ops.commit = e1000_phy_sw_reset_generic;
523 case e1000_phy_82578:
524 phy->ops.check_polarity = e1000_check_polarity_m88;
525 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_m88;
526 phy->ops.get_cable_length = e1000_get_cable_length_m88;
527 phy->ops.get_info = e1000_get_phy_info_m88;
530 ret_val = -E1000_ERR_PHY;
538 * e1000_init_phy_params_ich8lan - Initialize PHY function pointers
539 * @hw: pointer to the HW structure
541 * Initialize family-specific PHY parameters and function pointers.
543 STATIC s32 e1000_init_phy_params_ich8lan(struct e1000_hw *hw)
545 struct e1000_phy_info *phy = &hw->phy;
549 DEBUGFUNC("e1000_init_phy_params_ich8lan");
552 phy->reset_delay_us = 100;
554 phy->ops.acquire = e1000_acquire_swflag_ich8lan;
555 phy->ops.check_reset_block = e1000_check_reset_block_ich8lan;
556 phy->ops.get_cable_length = e1000_get_cable_length_igp_2;
557 phy->ops.get_cfg_done = e1000_get_cfg_done_ich8lan;
558 phy->ops.read_reg = e1000_read_phy_reg_igp;
559 phy->ops.release = e1000_release_swflag_ich8lan;
560 phy->ops.reset = e1000_phy_hw_reset_ich8lan;
561 phy->ops.set_d0_lplu_state = e1000_set_d0_lplu_state_ich8lan;
562 phy->ops.set_d3_lplu_state = e1000_set_d3_lplu_state_ich8lan;
563 phy->ops.write_reg = e1000_write_phy_reg_igp;
564 phy->ops.power_up = e1000_power_up_phy_copper;
565 phy->ops.power_down = e1000_power_down_phy_copper_ich8lan;
567 /* We may need to do this twice - once for IGP and if that fails,
568 * we'll set BM func pointers and try again
570 ret_val = e1000_determine_phy_address(hw);
572 phy->ops.write_reg = e1000_write_phy_reg_bm;
573 phy->ops.read_reg = e1000_read_phy_reg_bm;
574 ret_val = e1000_determine_phy_address(hw);
576 DEBUGOUT("Cannot determine PHY addr. Erroring out\n");
582 while ((e1000_phy_unknown == e1000_get_phy_type_from_id(phy->id)) &&
585 ret_val = e1000_get_phy_id(hw);
592 case IGP03E1000_E_PHY_ID:
593 phy->type = e1000_phy_igp_3;
594 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
595 phy->ops.read_reg_locked = e1000_read_phy_reg_igp_locked;
596 phy->ops.write_reg_locked = e1000_write_phy_reg_igp_locked;
597 phy->ops.get_info = e1000_get_phy_info_igp;
598 phy->ops.check_polarity = e1000_check_polarity_igp;
599 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_igp;
602 case IFE_PLUS_E_PHY_ID:
604 phy->type = e1000_phy_ife;
605 phy->autoneg_mask = E1000_ALL_NOT_GIG;
606 phy->ops.get_info = e1000_get_phy_info_ife;
607 phy->ops.check_polarity = e1000_check_polarity_ife;
608 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_ife;
610 case BME1000_E_PHY_ID:
611 phy->type = e1000_phy_bm;
612 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
613 phy->ops.read_reg = e1000_read_phy_reg_bm;
614 phy->ops.write_reg = e1000_write_phy_reg_bm;
615 phy->ops.commit = e1000_phy_sw_reset_generic;
616 phy->ops.get_info = e1000_get_phy_info_m88;
617 phy->ops.check_polarity = e1000_check_polarity_m88;
618 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_m88;
621 return -E1000_ERR_PHY;
625 return E1000_SUCCESS;
629 * e1000_init_nvm_params_ich8lan - Initialize NVM function pointers
630 * @hw: pointer to the HW structure
632 * Initialize family-specific NVM parameters and function
635 STATIC s32 e1000_init_nvm_params_ich8lan(struct e1000_hw *hw)
637 struct e1000_nvm_info *nvm = &hw->nvm;
638 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
639 u32 gfpreg, sector_base_addr, sector_end_addr;
643 DEBUGFUNC("e1000_init_nvm_params_ich8lan");
645 nvm->type = e1000_nvm_flash_sw;
647 if (hw->mac.type >= e1000_pch_spt) {
648 /* in SPT, gfpreg doesn't exist. NVM size is taken from the
649 * STRAP register. This is because in SPT the GbE Flash region
650 * is no longer accessed through the flash registers. Instead,
651 * the mechanism has changed, and the Flash region access
652 * registers are now implemented in GbE memory space.
654 nvm->flash_base_addr = 0;
656 (((E1000_READ_REG(hw, E1000_STRAP) >> 1) & 0x1F) + 1)
657 * NVM_SIZE_MULTIPLIER;
658 nvm->flash_bank_size = nvm_size / 2;
659 /* Adjust to word count */
660 nvm->flash_bank_size /= sizeof(u16);
661 /* Set the base address for flash register access */
662 hw->flash_address = hw->hw_addr + E1000_FLASH_BASE_ADDR;
664 /* Can't read flash registers if register set isn't mapped. */
665 if (!hw->flash_address) {
666 DEBUGOUT("ERROR: Flash registers not mapped\n");
667 return -E1000_ERR_CONFIG;
670 gfpreg = E1000_READ_FLASH_REG(hw, ICH_FLASH_GFPREG);
672 /* sector_X_addr is a "sector"-aligned address (4096 bytes)
673 * Add 1 to sector_end_addr since this sector is included in
676 sector_base_addr = gfpreg & FLASH_GFPREG_BASE_MASK;
677 sector_end_addr = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK) + 1;
679 /* flash_base_addr is byte-aligned */
680 nvm->flash_base_addr = sector_base_addr
681 << FLASH_SECTOR_ADDR_SHIFT;
683 /* find total size of the NVM, then cut in half since the total
684 * size represents two separate NVM banks.
686 nvm->flash_bank_size = ((sector_end_addr - sector_base_addr)
687 << FLASH_SECTOR_ADDR_SHIFT);
688 nvm->flash_bank_size /= 2;
689 /* Adjust to word count */
690 nvm->flash_bank_size /= sizeof(u16);
693 nvm->word_size = E1000_SHADOW_RAM_WORDS;
695 /* Clear shadow ram */
696 for (i = 0; i < nvm->word_size; i++) {
697 dev_spec->shadow_ram[i].modified = false;
698 dev_spec->shadow_ram[i].value = 0xFFFF;
701 E1000_MUTEX_INIT(&dev_spec->nvm_mutex);
702 E1000_MUTEX_INIT(&dev_spec->swflag_mutex);
704 /* Function Pointers */
705 nvm->ops.acquire = e1000_acquire_nvm_ich8lan;
706 nvm->ops.release = e1000_release_nvm_ich8lan;
707 if (hw->mac.type >= e1000_pch_spt) {
708 nvm->ops.read = e1000_read_nvm_spt;
709 nvm->ops.update = e1000_update_nvm_checksum_spt;
711 nvm->ops.read = e1000_read_nvm_ich8lan;
712 nvm->ops.update = e1000_update_nvm_checksum_ich8lan;
714 nvm->ops.valid_led_default = e1000_valid_led_default_ich8lan;
715 nvm->ops.validate = e1000_validate_nvm_checksum_ich8lan;
716 nvm->ops.write = e1000_write_nvm_ich8lan;
718 return E1000_SUCCESS;
722 * e1000_init_mac_params_ich8lan - Initialize MAC function pointers
723 * @hw: pointer to the HW structure
725 * Initialize family-specific MAC parameters and function
728 STATIC s32 e1000_init_mac_params_ich8lan(struct e1000_hw *hw)
730 struct e1000_mac_info *mac = &hw->mac;
731 #if defined(QV_RELEASE) || !defined(NO_PCH_LPT_B0_SUPPORT)
733 #endif /* QV_RELEASE || !defined(NO_PCH_LPT_B0_SUPPORT) */
735 DEBUGFUNC("e1000_init_mac_params_ich8lan");
737 /* Set media type function pointer */
738 hw->phy.media_type = e1000_media_type_copper;
740 /* Set mta register count */
741 mac->mta_reg_count = 32;
742 /* Set rar entry count */
743 mac->rar_entry_count = E1000_ICH_RAR_ENTRIES;
744 if (mac->type == e1000_ich8lan)
745 mac->rar_entry_count--;
746 /* Set if part includes ASF firmware */
747 mac->asf_firmware_present = true;
749 mac->has_fwsm = true;
750 /* ARC subsystem not supported */
751 mac->arc_subsystem_valid = false;
752 /* Adaptive IFS supported */
753 mac->adaptive_ifs = true;
755 /* Function pointers */
757 /* bus type/speed/width */
758 mac->ops.get_bus_info = e1000_get_bus_info_ich8lan;
760 mac->ops.set_lan_id = e1000_set_lan_id_single_port;
762 mac->ops.reset_hw = e1000_reset_hw_ich8lan;
763 /* hw initialization */
764 mac->ops.init_hw = e1000_init_hw_ich8lan;
766 mac->ops.setup_link = e1000_setup_link_ich8lan;
767 /* physical interface setup */
768 mac->ops.setup_physical_interface = e1000_setup_copper_link_ich8lan;
770 mac->ops.check_for_link = e1000_check_for_copper_link_ich8lan;
772 mac->ops.get_link_up_info = e1000_get_link_up_info_ich8lan;
773 /* multicast address update */
774 mac->ops.update_mc_addr_list = e1000_update_mc_addr_list_generic;
775 /* clear hardware counters */
776 mac->ops.clear_hw_cntrs = e1000_clear_hw_cntrs_ich8lan;
778 /* LED and other operations */
783 /* check management mode */
784 mac->ops.check_mng_mode = e1000_check_mng_mode_ich8lan;
786 mac->ops.id_led_init = e1000_id_led_init_generic;
788 mac->ops.blink_led = e1000_blink_led_generic;
790 mac->ops.setup_led = e1000_setup_led_generic;
792 mac->ops.cleanup_led = e1000_cleanup_led_ich8lan;
793 /* turn on/off LED */
794 mac->ops.led_on = e1000_led_on_ich8lan;
795 mac->ops.led_off = e1000_led_off_ich8lan;
798 mac->rar_entry_count = E1000_PCH2_RAR_ENTRIES;
799 mac->ops.rar_set = e1000_rar_set_pch2lan;
804 #ifndef NO_NON_BLOCKING_PHY_MTA_UPDATE_SUPPORT
805 /* multicast address update for pch2 */
806 mac->ops.update_mc_addr_list =
807 e1000_update_mc_addr_list_pch2lan;
811 #if defined(QV_RELEASE) || !defined(NO_PCH_LPT_B0_SUPPORT)
812 /* save PCH revision_id */
813 e1000_read_pci_cfg(hw, E1000_PCI_REVISION_ID_REG, &pci_cfg);
814 /* SPT uses full byte for revision ID,
815 * as opposed to previous generations
817 if (hw->mac.type >= e1000_pch_spt)
818 hw->revision_id = (u8)(pci_cfg &= 0x00FF);
820 hw->revision_id = (u8)(pci_cfg &= 0x000F);
821 #endif /* QV_RELEASE || !defined(NO_PCH_LPT_B0_SUPPORT) */
822 /* check management mode */
823 mac->ops.check_mng_mode = e1000_check_mng_mode_pchlan;
825 mac->ops.id_led_init = e1000_id_led_init_pchlan;
827 mac->ops.setup_led = e1000_setup_led_pchlan;
829 mac->ops.cleanup_led = e1000_cleanup_led_pchlan;
830 /* turn on/off LED */
831 mac->ops.led_on = e1000_led_on_pchlan;
832 mac->ops.led_off = e1000_led_off_pchlan;
838 if (mac->type >= e1000_pch_lpt) {
839 mac->rar_entry_count = E1000_PCH_LPT_RAR_ENTRIES;
840 mac->ops.rar_set = e1000_rar_set_pch_lpt;
841 mac->ops.setup_physical_interface = e1000_setup_copper_link_pch_lpt;
844 /* Enable PCS Lock-loss workaround for ICH8 */
845 if (mac->type == e1000_ich8lan)
846 e1000_set_kmrn_lock_loss_workaround_ich8lan(hw, true);
848 return E1000_SUCCESS;
852 * __e1000_access_emi_reg_locked - Read/write EMI register
853 * @hw: pointer to the HW structure
854 * @addr: EMI address to program
855 * @data: pointer to value to read/write from/to the EMI address
856 * @read: boolean flag to indicate read or write
858 * This helper function assumes the SW/FW/HW Semaphore is already acquired.
860 STATIC s32 __e1000_access_emi_reg_locked(struct e1000_hw *hw, u16 address,
861 u16 *data, bool read)
865 DEBUGFUNC("__e1000_access_emi_reg_locked");
867 ret_val = hw->phy.ops.write_reg_locked(hw, I82579_EMI_ADDR, address);
872 ret_val = hw->phy.ops.read_reg_locked(hw, I82579_EMI_DATA,
875 ret_val = hw->phy.ops.write_reg_locked(hw, I82579_EMI_DATA,
882 * e1000_read_emi_reg_locked - Read Extended Management Interface register
883 * @hw: pointer to the HW structure
884 * @addr: EMI address to program
885 * @data: value to be read from the EMI address
887 * Assumes the SW/FW/HW Semaphore is already acquired.
889 s32 e1000_read_emi_reg_locked(struct e1000_hw *hw, u16 addr, u16 *data)
891 DEBUGFUNC("e1000_read_emi_reg_locked");
893 return __e1000_access_emi_reg_locked(hw, addr, data, true);
897 * e1000_write_emi_reg_locked - Write Extended Management Interface register
898 * @hw: pointer to the HW structure
899 * @addr: EMI address to program
900 * @data: value to be written to the EMI address
902 * Assumes the SW/FW/HW Semaphore is already acquired.
904 s32 e1000_write_emi_reg_locked(struct e1000_hw *hw, u16 addr, u16 data)
906 DEBUGFUNC("e1000_read_emi_reg_locked");
908 return __e1000_access_emi_reg_locked(hw, addr, &data, false);
912 * e1000_set_eee_pchlan - Enable/disable EEE support
913 * @hw: pointer to the HW structure
915 * Enable/disable EEE based on setting in dev_spec structure, the duplex of
916 * the link and the EEE capabilities of the link partner. The LPI Control
917 * register bits will remain set only if/when link is up.
919 * EEE LPI must not be asserted earlier than one second after link is up.
920 * On 82579, EEE LPI should not be enabled until such time otherwise there
921 * can be link issues with some switches. Other devices can have EEE LPI
922 * enabled immediately upon link up since they have a timer in hardware which
923 * prevents LPI from being asserted too early.
925 s32 e1000_set_eee_pchlan(struct e1000_hw *hw)
927 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
929 u16 lpa, pcs_status, adv, adv_addr, lpi_ctrl, data;
931 DEBUGFUNC("e1000_set_eee_pchlan");
933 switch (hw->phy.type) {
934 case e1000_phy_82579:
935 lpa = I82579_EEE_LP_ABILITY;
936 pcs_status = I82579_EEE_PCS_STATUS;
937 adv_addr = I82579_EEE_ADVERTISEMENT;
940 lpa = I217_EEE_LP_ABILITY;
941 pcs_status = I217_EEE_PCS_STATUS;
942 adv_addr = I217_EEE_ADVERTISEMENT;
945 return E1000_SUCCESS;
948 ret_val = hw->phy.ops.acquire(hw);
952 ret_val = hw->phy.ops.read_reg_locked(hw, I82579_LPI_CTRL, &lpi_ctrl);
956 /* Clear bits that enable EEE in various speeds */
957 lpi_ctrl &= ~I82579_LPI_CTRL_ENABLE_MASK;
959 /* Enable EEE if not disabled by user */
960 if (!dev_spec->eee_disable) {
961 /* Save off link partner's EEE ability */
962 ret_val = e1000_read_emi_reg_locked(hw, lpa,
963 &dev_spec->eee_lp_ability);
967 /* Read EEE advertisement */
968 ret_val = e1000_read_emi_reg_locked(hw, adv_addr, &adv);
972 /* Enable EEE only for speeds in which the link partner is
973 * EEE capable and for which we advertise EEE.
975 if (adv & dev_spec->eee_lp_ability & I82579_EEE_1000_SUPPORTED)
976 lpi_ctrl |= I82579_LPI_CTRL_1000_ENABLE;
978 if (adv & dev_spec->eee_lp_ability & I82579_EEE_100_SUPPORTED) {
979 hw->phy.ops.read_reg_locked(hw, PHY_LP_ABILITY, &data);
980 if (data & NWAY_LPAR_100TX_FD_CAPS)
981 lpi_ctrl |= I82579_LPI_CTRL_100_ENABLE;
983 /* EEE is not supported in 100Half, so ignore
984 * partner's EEE in 100 ability if full-duplex
987 dev_spec->eee_lp_ability &=
988 ~I82579_EEE_100_SUPPORTED;
992 if (hw->phy.type == e1000_phy_82579) {
993 ret_val = e1000_read_emi_reg_locked(hw, I82579_LPI_PLL_SHUT,
998 data &= ~I82579_LPI_100_PLL_SHUT;
999 ret_val = e1000_write_emi_reg_locked(hw, I82579_LPI_PLL_SHUT,
1003 /* R/Clr IEEE MMD 3.1 bits 11:10 - Tx/Rx LPI Received */
1004 ret_val = e1000_read_emi_reg_locked(hw, pcs_status, &data);
1008 ret_val = hw->phy.ops.write_reg_locked(hw, I82579_LPI_CTRL, lpi_ctrl);
1010 hw->phy.ops.release(hw);
1016 * e1000_k1_workaround_lpt_lp - K1 workaround on Lynxpoint-LP
1017 * @hw: pointer to the HW structure
1018 * @link: link up bool flag
1020 * When K1 is enabled for 1Gbps, the MAC can miss 2 DMA completion indications
1021 * preventing further DMA write requests. Workaround the issue by disabling
1022 * the de-assertion of the clock request when in 1Gpbs mode.
1023 * Also, set appropriate Tx re-transmission timeouts for 10 and 100Half link
1024 * speeds in order to avoid Tx hangs.
1026 STATIC s32 e1000_k1_workaround_lpt_lp(struct e1000_hw *hw, bool link)
1028 u32 fextnvm6 = E1000_READ_REG(hw, E1000_FEXTNVM6);
1029 u32 status = E1000_READ_REG(hw, E1000_STATUS);
1030 s32 ret_val = E1000_SUCCESS;
1033 if (link && (status & E1000_STATUS_SPEED_1000)) {
1034 ret_val = hw->phy.ops.acquire(hw);
1039 e1000_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
1045 e1000_write_kmrn_reg_locked(hw,
1046 E1000_KMRNCTRLSTA_K1_CONFIG,
1048 ~E1000_KMRNCTRLSTA_K1_ENABLE);
1054 E1000_WRITE_REG(hw, E1000_FEXTNVM6,
1055 fextnvm6 | E1000_FEXTNVM6_REQ_PLL_CLK);
1058 e1000_write_kmrn_reg_locked(hw,
1059 E1000_KMRNCTRLSTA_K1_CONFIG,
1062 hw->phy.ops.release(hw);
1064 /* clear FEXTNVM6 bit 8 on link down or 10/100 */
1065 fextnvm6 &= ~E1000_FEXTNVM6_REQ_PLL_CLK;
1067 if ((hw->phy.revision > 5) || !link ||
1068 ((status & E1000_STATUS_SPEED_100) &&
1069 (status & E1000_STATUS_FD)))
1070 goto update_fextnvm6;
1072 ret_val = hw->phy.ops.read_reg(hw, I217_INBAND_CTRL, ®);
1076 /* Clear link status transmit timeout */
1077 reg &= ~I217_INBAND_CTRL_LINK_STAT_TX_TIMEOUT_MASK;
1079 if (status & E1000_STATUS_SPEED_100) {
1080 /* Set inband Tx timeout to 5x10us for 100Half */
1081 reg |= 5 << I217_INBAND_CTRL_LINK_STAT_TX_TIMEOUT_SHIFT;
1083 /* Do not extend the K1 entry latency for 100Half */
1084 fextnvm6 &= ~E1000_FEXTNVM6_ENABLE_K1_ENTRY_CONDITION;
1086 /* Set inband Tx timeout to 50x10us for 10Full/Half */
1088 I217_INBAND_CTRL_LINK_STAT_TX_TIMEOUT_SHIFT;
1090 /* Extend the K1 entry latency for 10 Mbps */
1091 fextnvm6 |= E1000_FEXTNVM6_ENABLE_K1_ENTRY_CONDITION;
1094 ret_val = hw->phy.ops.write_reg(hw, I217_INBAND_CTRL, reg);
1099 E1000_WRITE_REG(hw, E1000_FEXTNVM6, fextnvm6);
1107 * e1000_enable_ulp_lpt_lp - configure Ultra Low Power mode for LynxPoint-LP
1108 * @hw: pointer to the HW structure
1109 * @to_sx: boolean indicating a system power state transition to Sx
1111 * When link is down, configure ULP mode to significantly reduce the power
1112 * to the PHY. If on a Manageability Engine (ME) enabled system, tell the
1113 * ME firmware to start the ULP configuration. If not on an ME enabled
1114 * system, configure the ULP mode by software.
1116 s32 e1000_enable_ulp_lpt_lp(struct e1000_hw *hw, bool to_sx)
1119 s32 ret_val = E1000_SUCCESS;
1123 if ((hw->mac.type < e1000_pch_lpt) ||
1124 (hw->device_id == E1000_DEV_ID_PCH_LPT_I217_LM) ||
1125 (hw->device_id == E1000_DEV_ID_PCH_LPT_I217_V) ||
1126 (hw->device_id == E1000_DEV_ID_PCH_I218_LM2) ||
1127 (hw->device_id == E1000_DEV_ID_PCH_I218_V2) ||
1128 (hw->dev_spec.ich8lan.ulp_state == e1000_ulp_state_on))
1133 /* Poll up to 5 seconds for Cable Disconnected indication */
1134 while (!(E1000_READ_REG(hw, E1000_FEXT) &
1135 E1000_FEXT_PHY_CABLE_DISCONNECTED)) {
1136 /* Bail if link is re-acquired */
1137 if (E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU)
1138 return -E1000_ERR_PHY;
1144 DEBUGOUT2("CABLE_DISCONNECTED %s set after %dmsec\n",
1145 (E1000_READ_REG(hw, E1000_FEXT) &
1146 E1000_FEXT_PHY_CABLE_DISCONNECTED) ? "" : "not",
1148 if (!(E1000_READ_REG(hw, E1000_FEXT) &
1149 E1000_FEXT_PHY_CABLE_DISCONNECTED))
1153 if (E1000_READ_REG(hw, E1000_FWSM) & E1000_ICH_FWSM_FW_VALID) {
1154 /* Request ME configure ULP mode in the PHY */
1155 mac_reg = E1000_READ_REG(hw, E1000_H2ME);
1156 mac_reg |= E1000_H2ME_ULP | E1000_H2ME_ENFORCE_SETTINGS;
1157 E1000_WRITE_REG(hw, E1000_H2ME, mac_reg);
1162 ret_val = hw->phy.ops.acquire(hw);
1166 /* During S0 Idle keep the phy in PCI-E mode */
1167 if (hw->dev_spec.ich8lan.smbus_disable)
1170 /* Force SMBus mode in PHY */
1171 ret_val = e1000_read_phy_reg_hv_locked(hw, CV_SMB_CTRL, &phy_reg);
1174 phy_reg |= CV_SMB_CTRL_FORCE_SMBUS;
1175 e1000_write_phy_reg_hv_locked(hw, CV_SMB_CTRL, phy_reg);
1177 /* Force SMBus mode in MAC */
1178 mac_reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
1179 mac_reg |= E1000_CTRL_EXT_FORCE_SMBUS;
1180 E1000_WRITE_REG(hw, E1000_CTRL_EXT, mac_reg);
1182 /* Si workaround for ULP entry flow on i127/rev6 h/w. Enable
1183 * LPLU and disable Gig speed when entering ULP
1185 if ((hw->phy.type == e1000_phy_i217) && (hw->phy.revision == 6)) {
1186 ret_val = e1000_read_phy_reg_hv_locked(hw, HV_OEM_BITS,
1192 phy_reg |= HV_OEM_BITS_LPLU | HV_OEM_BITS_GBE_DIS;
1194 ret_val = e1000_write_phy_reg_hv_locked(hw, HV_OEM_BITS,
1203 /* Change the 'Link Status Change' interrupt to trigger
1204 * on 'Cable Status Change'
1206 ret_val = e1000_read_kmrn_reg_locked(hw,
1207 E1000_KMRNCTRLSTA_OP_MODES,
1211 phy_reg |= E1000_KMRNCTRLSTA_OP_MODES_LSC2CSC;
1212 e1000_write_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_OP_MODES,
1216 /* Set Inband ULP Exit, Reset to SMBus mode and
1217 * Disable SMBus Release on PERST# in PHY
1219 ret_val = e1000_read_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, &phy_reg);
1222 phy_reg |= (I218_ULP_CONFIG1_RESET_TO_SMBUS |
1223 I218_ULP_CONFIG1_DISABLE_SMB_PERST);
1225 if (E1000_READ_REG(hw, E1000_WUFC) & E1000_WUFC_LNKC)
1226 phy_reg |= I218_ULP_CONFIG1_WOL_HOST;
1228 phy_reg &= ~I218_ULP_CONFIG1_WOL_HOST;
1230 phy_reg |= I218_ULP_CONFIG1_STICKY_ULP;
1231 phy_reg &= ~I218_ULP_CONFIG1_INBAND_EXIT;
1233 phy_reg |= I218_ULP_CONFIG1_INBAND_EXIT;
1234 phy_reg &= ~I218_ULP_CONFIG1_STICKY_ULP;
1235 phy_reg &= ~I218_ULP_CONFIG1_WOL_HOST;
1237 e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
1239 /* Set Disable SMBus Release on PERST# in MAC */
1240 mac_reg = E1000_READ_REG(hw, E1000_FEXTNVM7);
1241 mac_reg |= E1000_FEXTNVM7_DISABLE_SMB_PERST;
1242 E1000_WRITE_REG(hw, E1000_FEXTNVM7, mac_reg);
1244 /* Commit ULP changes in PHY by starting auto ULP configuration */
1245 phy_reg |= I218_ULP_CONFIG1_START;
1246 e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
1249 /* Disable Tx so that the MAC doesn't send any (buffered)
1250 * packets to the PHY.
1252 mac_reg = E1000_READ_REG(hw, E1000_TCTL);
1253 mac_reg &= ~E1000_TCTL_EN;
1254 E1000_WRITE_REG(hw, E1000_TCTL, mac_reg);
1257 if ((hw->phy.type == e1000_phy_i217) && (hw->phy.revision == 6) &&
1258 to_sx && (E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU)) {
1259 ret_val = e1000_write_phy_reg_hv_locked(hw, HV_OEM_BITS,
1266 hw->phy.ops.release(hw);
1269 DEBUGOUT1("Error in ULP enable flow: %d\n", ret_val);
1271 hw->dev_spec.ich8lan.ulp_state = e1000_ulp_state_on;
1277 * e1000_disable_ulp_lpt_lp - unconfigure Ultra Low Power mode for LynxPoint-LP
1278 * @hw: pointer to the HW structure
1279 * @force: boolean indicating whether or not to force disabling ULP
1281 * Un-configure ULP mode when link is up, the system is transitioned from
1282 * Sx or the driver is unloaded. If on a Manageability Engine (ME) enabled
1283 * system, poll for an indication from ME that ULP has been un-configured.
1284 * If not on an ME enabled system, un-configure the ULP mode by software.
1286 * During nominal operation, this function is called when link is acquired
1287 * to disable ULP mode (force=false); otherwise, for example when unloading
1288 * the driver or during Sx->S0 transitions, this is called with force=true
1289 * to forcibly disable ULP.
1291 * When the cable is plugged in while the device is in D0, a Cable Status
1292 * Change interrupt is generated which causes this function to be called
1293 * to partially disable ULP mode and restart autonegotiation. This function
1294 * is then called again due to the resulting Link Status Change interrupt
1295 * to finish cleaning up after the ULP flow.
1297 s32 e1000_disable_ulp_lpt_lp(struct e1000_hw *hw, bool force)
1299 s32 ret_val = E1000_SUCCESS;
1304 if ((hw->mac.type < e1000_pch_lpt) ||
1305 (hw->device_id == E1000_DEV_ID_PCH_LPT_I217_LM) ||
1306 (hw->device_id == E1000_DEV_ID_PCH_LPT_I217_V) ||
1307 (hw->device_id == E1000_DEV_ID_PCH_I218_LM2) ||
1308 (hw->device_id == E1000_DEV_ID_PCH_I218_V2) ||
1309 (hw->dev_spec.ich8lan.ulp_state == e1000_ulp_state_off))
1312 if (E1000_READ_REG(hw, E1000_FWSM) & E1000_ICH_FWSM_FW_VALID) {
1314 /* Request ME un-configure ULP mode in the PHY */
1315 mac_reg = E1000_READ_REG(hw, E1000_H2ME);
1316 mac_reg &= ~E1000_H2ME_ULP;
1317 mac_reg |= E1000_H2ME_ENFORCE_SETTINGS;
1318 E1000_WRITE_REG(hw, E1000_H2ME, mac_reg);
1321 /* Poll up to 300msec for ME to clear ULP_CFG_DONE. */
1322 while (E1000_READ_REG(hw, E1000_FWSM) &
1323 E1000_FWSM_ULP_CFG_DONE) {
1325 ret_val = -E1000_ERR_PHY;
1331 DEBUGOUT1("ULP_CONFIG_DONE cleared after %dmsec\n", i * 10);
1334 mac_reg = E1000_READ_REG(hw, E1000_H2ME);
1335 mac_reg &= ~E1000_H2ME_ENFORCE_SETTINGS;
1336 E1000_WRITE_REG(hw, E1000_H2ME, mac_reg);
1338 /* Clear H2ME.ULP after ME ULP configuration */
1339 mac_reg = E1000_READ_REG(hw, E1000_H2ME);
1340 mac_reg &= ~E1000_H2ME_ULP;
1341 E1000_WRITE_REG(hw, E1000_H2ME, mac_reg);
1343 /* Restore link speed advertisements and restart
1346 if (hw->mac.autoneg) {
1347 ret_val = e1000_phy_setup_autoneg(hw);
1351 ret_val = e1000_setup_copper_link_generic(hw);
1355 ret_val = e1000_oem_bits_config_ich8lan(hw, true);
1361 ret_val = hw->phy.ops.acquire(hw);
1365 /* Revert the change to the 'Link Status Change'
1366 * interrupt to trigger on 'Cable Status Change'
1368 ret_val = e1000_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_OP_MODES,
1372 phy_reg &= ~E1000_KMRNCTRLSTA_OP_MODES_LSC2CSC;
1373 e1000_write_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_OP_MODES, phy_reg);
1376 /* Toggle LANPHYPC Value bit */
1377 e1000_toggle_lanphypc_pch_lpt(hw);
1379 /* Unforce SMBus mode in PHY */
1380 ret_val = e1000_read_phy_reg_hv_locked(hw, CV_SMB_CTRL, &phy_reg);
1382 /* The MAC might be in PCIe mode, so temporarily force to
1383 * SMBus mode in order to access the PHY.
1385 mac_reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
1386 mac_reg |= E1000_CTRL_EXT_FORCE_SMBUS;
1387 E1000_WRITE_REG(hw, E1000_CTRL_EXT, mac_reg);
1391 ret_val = e1000_read_phy_reg_hv_locked(hw, CV_SMB_CTRL,
1396 phy_reg &= ~CV_SMB_CTRL_FORCE_SMBUS;
1397 e1000_write_phy_reg_hv_locked(hw, CV_SMB_CTRL, phy_reg);
1399 /* Unforce SMBus mode in MAC */
1400 mac_reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
1401 mac_reg &= ~E1000_CTRL_EXT_FORCE_SMBUS;
1402 E1000_WRITE_REG(hw, E1000_CTRL_EXT, mac_reg);
1404 /* When ULP mode was previously entered, K1 was disabled by the
1405 * hardware. Re-Enable K1 in the PHY when exiting ULP.
1407 ret_val = e1000_read_phy_reg_hv_locked(hw, HV_PM_CTRL, &phy_reg);
1410 phy_reg |= HV_PM_CTRL_K1_ENABLE;
1411 e1000_write_phy_reg_hv_locked(hw, HV_PM_CTRL, phy_reg);
1413 /* Clear ULP enabled configuration */
1414 ret_val = e1000_read_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, &phy_reg);
1417 /* CSC interrupt received due to ULP Indication */
1418 if ((phy_reg & I218_ULP_CONFIG1_IND) || force) {
1419 phy_reg &= ~(I218_ULP_CONFIG1_IND |
1420 I218_ULP_CONFIG1_STICKY_ULP |
1421 I218_ULP_CONFIG1_RESET_TO_SMBUS |
1422 I218_ULP_CONFIG1_WOL_HOST |
1423 I218_ULP_CONFIG1_INBAND_EXIT |
1424 I218_ULP_CONFIG1_EN_ULP_LANPHYPC |
1425 I218_ULP_CONFIG1_DIS_CLR_STICKY_ON_PERST |
1426 I218_ULP_CONFIG1_DISABLE_SMB_PERST);
1427 e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
1429 /* Commit ULP changes by starting auto ULP configuration */
1430 phy_reg |= I218_ULP_CONFIG1_START;
1431 e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
1433 /* Clear Disable SMBus Release on PERST# in MAC */
1434 mac_reg = E1000_READ_REG(hw, E1000_FEXTNVM7);
1435 mac_reg &= ~E1000_FEXTNVM7_DISABLE_SMB_PERST;
1436 E1000_WRITE_REG(hw, E1000_FEXTNVM7, mac_reg);
1439 hw->phy.ops.release(hw);
1441 if (hw->mac.autoneg)
1442 e1000_phy_setup_autoneg(hw);
1444 e1000_setup_copper_link_generic(hw);
1446 e1000_sw_lcd_config_ich8lan(hw);
1448 e1000_oem_bits_config_ich8lan(hw, true);
1450 /* Set ULP state to unknown and return non-zero to
1451 * indicate no link (yet) and re-enter on the next LSC
1452 * to finish disabling ULP flow.
1454 hw->dev_spec.ich8lan.ulp_state =
1455 e1000_ulp_state_unknown;
1462 mac_reg = E1000_READ_REG(hw, E1000_TCTL);
1463 mac_reg |= E1000_TCTL_EN;
1464 E1000_WRITE_REG(hw, E1000_TCTL, mac_reg);
1467 hw->phy.ops.release(hw);
1469 hw->phy.ops.reset(hw);
1474 DEBUGOUT1("Error in ULP disable flow: %d\n", ret_val);
1476 hw->dev_spec.ich8lan.ulp_state = e1000_ulp_state_off;
1481 #endif /* ULP_SUPPORT */
1485 * e1000_check_for_copper_link_ich8lan - Check for link (Copper)
1486 * @hw: pointer to the HW structure
1488 * Checks to see of the link status of the hardware has changed. If a
1489 * change in link status has been detected, then we read the PHY registers
1490 * to get the current speed/duplex if link exists.
1492 STATIC s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw)
1494 struct e1000_mac_info *mac = &hw->mac;
1495 s32 ret_val, tipg_reg = 0;
1496 u16 emi_addr, emi_val = 0;
1500 DEBUGFUNC("e1000_check_for_copper_link_ich8lan");
1502 /* We only want to go out to the PHY registers to see if Auto-Neg
1503 * has completed and/or if our link status has changed. The
1504 * get_link_status flag is set upon receiving a Link Status
1505 * Change or Rx Sequence Error interrupt.
1507 if (!mac->get_link_status)
1508 return E1000_SUCCESS;
1510 if ((hw->mac.type < e1000_pch_lpt) ||
1511 (hw->device_id == E1000_DEV_ID_PCH_LPT_I217_LM) ||
1512 (hw->device_id == E1000_DEV_ID_PCH_LPT_I217_V)) {
1513 /* First we want to see if the MII Status Register reports
1514 * link. If so, then we want to get the current speed/duplex
1517 ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link);
1521 /* Check the MAC's STATUS register to determine link state
1522 * since the PHY could be inaccessible while in ULP mode.
1524 link = !!(E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU);
1526 ret_val = e1000_disable_ulp_lpt_lp(hw, false);
1528 ret_val = e1000_enable_ulp_lpt_lp(hw, false);
1533 if (hw->mac.type == e1000_pchlan) {
1534 ret_val = e1000_k1_gig_workaround_hv(hw, link);
1539 /* When connected at 10Mbps half-duplex, some parts are excessively
1540 * aggressive resulting in many collisions. To avoid this, increase
1541 * the IPG and reduce Rx latency in the PHY.
1543 if ((hw->mac.type >= e1000_pch2lan) && link) {
1546 e1000_get_speed_and_duplex_copper_generic(hw, &speed, &duplex);
1547 tipg_reg = E1000_READ_REG(hw, E1000_TIPG);
1548 tipg_reg &= ~E1000_TIPG_IPGT_MASK;
1550 if (duplex == HALF_DUPLEX && speed == SPEED_10) {
1552 /* Reduce Rx latency in analog PHY */
1554 } else if (hw->mac.type >= e1000_pch_spt &&
1555 duplex == FULL_DUPLEX && speed != SPEED_1000) {
1559 /* Roll back the default values */
1564 E1000_WRITE_REG(hw, E1000_TIPG, tipg_reg);
1566 ret_val = hw->phy.ops.acquire(hw);
1570 if (hw->mac.type == e1000_pch2lan)
1571 emi_addr = I82579_RX_CONFIG;
1573 emi_addr = I217_RX_CONFIG;
1574 ret_val = e1000_write_emi_reg_locked(hw, emi_addr, emi_val);
1577 if (hw->mac.type >= e1000_pch_lpt) {
1580 hw->phy.ops.read_reg_locked(hw, I217_PLL_CLOCK_GATE_REG,
1582 phy_reg &= ~I217_PLL_CLOCK_GATE_MASK;
1583 if (speed == SPEED_100 || speed == SPEED_10)
1587 hw->phy.ops.write_reg_locked(hw,
1588 I217_PLL_CLOCK_GATE_REG,
1591 if (speed == SPEED_1000) {
1592 hw->phy.ops.read_reg_locked(hw, HV_PM_CTRL,
1595 phy_reg |= HV_PM_CTRL_K1_CLK_REQ;
1597 hw->phy.ops.write_reg_locked(hw, HV_PM_CTRL,
1601 hw->phy.ops.release(hw);
1606 if (hw->mac.type >= e1000_pch_spt) {
1610 if (speed == SPEED_1000) {
1611 ret_val = hw->phy.ops.acquire(hw);
1615 ret_val = hw->phy.ops.read_reg_locked(hw,
1619 hw->phy.ops.release(hw);
1623 ptr_gap = (data & (0x3FF << 2)) >> 2;
1624 if (ptr_gap < 0x18) {
1625 data &= ~(0x3FF << 2);
1626 data |= (0x18 << 2);
1628 hw->phy.ops.write_reg_locked(hw,
1629 PHY_REG(776, 20), data);
1631 hw->phy.ops.release(hw);
1635 ret_val = hw->phy.ops.acquire(hw);
1639 ret_val = hw->phy.ops.write_reg_locked(hw,
1642 hw->phy.ops.release(hw);
1650 /* I217 Packet Loss issue:
1651 * ensure that FEXTNVM4 Beacon Duration is set correctly
1653 * Set the Beacon Duration for I217 to 8 usec
1655 if (hw->mac.type >= e1000_pch_lpt) {
1658 mac_reg = E1000_READ_REG(hw, E1000_FEXTNVM4);
1659 mac_reg &= ~E1000_FEXTNVM4_BEACON_DURATION_MASK;
1660 mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_8USEC;
1661 E1000_WRITE_REG(hw, E1000_FEXTNVM4, mac_reg);
1664 /* Work-around I218 hang issue */
1665 if ((hw->device_id == E1000_DEV_ID_PCH_LPTLP_I218_LM) ||
1666 (hw->device_id == E1000_DEV_ID_PCH_LPTLP_I218_V) ||
1667 (hw->device_id == E1000_DEV_ID_PCH_I218_LM3) ||
1668 (hw->device_id == E1000_DEV_ID_PCH_I218_V3)) {
1669 ret_val = e1000_k1_workaround_lpt_lp(hw, link);
1673 /* Clear link partner's EEE ability */
1674 hw->dev_spec.ich8lan.eee_lp_ability = 0;
1676 /* Configure K0s minimum time */
1677 if (hw->mac.type >= e1000_pch_lpt) {
1678 e1000_configure_k0s_lpt(hw, K1_ENTRY_LATENCY, K1_MIN_TIME);
1681 if (hw->mac.type >= e1000_pch_lpt) {
1682 u32 fextnvm6 = E1000_READ_REG(hw, E1000_FEXTNVM6);
1684 if (hw->mac.type == e1000_pch_spt) {
1685 /* FEXTNVM6 K1-off workaround - for SPT only */
1686 u32 pcieanacfg = E1000_READ_REG(hw, E1000_PCIEANACFG);
1688 if (pcieanacfg & E1000_FEXTNVM6_K1_OFF_ENABLE)
1689 fextnvm6 |= E1000_FEXTNVM6_K1_OFF_ENABLE;
1691 fextnvm6 &= ~E1000_FEXTNVM6_K1_OFF_ENABLE;
1694 if (hw->dev_spec.ich8lan.disable_k1_off == true)
1695 fextnvm6 &= ~E1000_FEXTNVM6_K1_OFF_ENABLE;
1697 E1000_WRITE_REG(hw, E1000_FEXTNVM6, fextnvm6);
1701 return E1000_SUCCESS; /* No link detected */
1703 mac->get_link_status = false;
1705 switch (hw->mac.type) {
1707 ret_val = e1000_k1_workaround_lv(hw);
1712 if (hw->phy.type == e1000_phy_82578) {
1713 ret_val = e1000_link_stall_workaround_hv(hw);
1718 /* Workaround for PCHx parts in half-duplex:
1719 * Set the number of preambles removed from the packet
1720 * when it is passed from the PHY to the MAC to prevent
1721 * the MAC from misinterpreting the packet type.
1723 hw->phy.ops.read_reg(hw, HV_KMRN_FIFO_CTRLSTA, &phy_reg);
1724 phy_reg &= ~HV_KMRN_FIFO_CTRLSTA_PREAMBLE_MASK;
1726 if ((E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_FD) !=
1728 phy_reg |= (1 << HV_KMRN_FIFO_CTRLSTA_PREAMBLE_SHIFT);
1730 hw->phy.ops.write_reg(hw, HV_KMRN_FIFO_CTRLSTA, phy_reg);
1736 /* Check if there was DownShift, must be checked
1737 * immediately after link-up
1739 e1000_check_downshift_generic(hw);
1741 /* Enable/Disable EEE after link up */
1742 if (hw->phy.type > e1000_phy_82579) {
1743 ret_val = e1000_set_eee_pchlan(hw);
1748 /* If we are forcing speed/duplex, then we simply return since
1749 * we have already determined whether we have link or not.
1752 return -E1000_ERR_CONFIG;
1754 /* Auto-Neg is enabled. Auto Speed Detection takes care
1755 * of MAC speed/duplex configuration. So we only need to
1756 * configure Collision Distance in the MAC.
1758 mac->ops.config_collision_dist(hw);
1760 /* Configure Flow Control now that Auto-Neg has completed.
1761 * First, we need to restore the desired flow control
1762 * settings because we may have had to re-autoneg with a
1763 * different link partner.
1765 ret_val = e1000_config_fc_after_link_up_generic(hw);
1767 DEBUGOUT("Error configuring flow control\n");
1773 * e1000_init_function_pointers_ich8lan - Initialize ICH8 function pointers
1774 * @hw: pointer to the HW structure
1776 * Initialize family-specific function pointers for PHY, MAC, and NVM.
1778 void e1000_init_function_pointers_ich8lan(struct e1000_hw *hw)
1780 DEBUGFUNC("e1000_init_function_pointers_ich8lan");
1782 hw->mac.ops.init_params = e1000_init_mac_params_ich8lan;
1783 hw->nvm.ops.init_params = e1000_init_nvm_params_ich8lan;
1784 switch (hw->mac.type) {
1787 case e1000_ich10lan:
1788 hw->phy.ops.init_params = e1000_init_phy_params_ich8lan;
1795 hw->phy.ops.init_params = e1000_init_phy_params_pchlan;
1803 * e1000_acquire_nvm_ich8lan - Acquire NVM mutex
1804 * @hw: pointer to the HW structure
1806 * Acquires the mutex for performing NVM operations.
1808 STATIC s32 e1000_acquire_nvm_ich8lan(struct e1000_hw *hw)
1810 DEBUGFUNC("e1000_acquire_nvm_ich8lan");
1812 E1000_MUTEX_LOCK(&hw->dev_spec.ich8lan.nvm_mutex);
1814 return E1000_SUCCESS;
1818 * e1000_release_nvm_ich8lan - Release NVM mutex
1819 * @hw: pointer to the HW structure
1821 * Releases the mutex used while performing NVM operations.
1823 STATIC void e1000_release_nvm_ich8lan(struct e1000_hw *hw)
1825 DEBUGFUNC("e1000_release_nvm_ich8lan");
1827 E1000_MUTEX_UNLOCK(&hw->dev_spec.ich8lan.nvm_mutex);
1833 * e1000_acquire_swflag_ich8lan - Acquire software control flag
1834 * @hw: pointer to the HW structure
1836 * Acquires the software control flag for performing PHY and select
1839 STATIC s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw)
1841 u32 extcnf_ctrl, timeout = PHY_CFG_TIMEOUT;
1842 s32 ret_val = E1000_SUCCESS;
1844 DEBUGFUNC("e1000_acquire_swflag_ich8lan");
1846 E1000_MUTEX_LOCK(&hw->dev_spec.ich8lan.swflag_mutex);
1849 extcnf_ctrl = E1000_READ_REG(hw, E1000_EXTCNF_CTRL);
1850 if (!(extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG))
1858 DEBUGOUT("SW has already locked the resource.\n");
1859 ret_val = -E1000_ERR_CONFIG;
1863 timeout = SW_FLAG_TIMEOUT;
1865 extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG;
1866 E1000_WRITE_REG(hw, E1000_EXTCNF_CTRL, extcnf_ctrl);
1869 extcnf_ctrl = E1000_READ_REG(hw, E1000_EXTCNF_CTRL);
1870 if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG)
1878 DEBUGOUT2("Failed to acquire the semaphore, FW or HW has it: FWSM=0x%8.8x EXTCNF_CTRL=0x%8.8x)\n",
1879 E1000_READ_REG(hw, E1000_FWSM), extcnf_ctrl);
1880 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
1881 E1000_WRITE_REG(hw, E1000_EXTCNF_CTRL, extcnf_ctrl);
1882 ret_val = -E1000_ERR_CONFIG;
1888 E1000_MUTEX_UNLOCK(&hw->dev_spec.ich8lan.swflag_mutex);
1894 * e1000_release_swflag_ich8lan - Release software control flag
1895 * @hw: pointer to the HW structure
1897 * Releases the software control flag for performing PHY and select
1900 STATIC void e1000_release_swflag_ich8lan(struct e1000_hw *hw)
1904 DEBUGFUNC("e1000_release_swflag_ich8lan");
1906 extcnf_ctrl = E1000_READ_REG(hw, E1000_EXTCNF_CTRL);
1908 if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG) {
1909 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
1910 E1000_WRITE_REG(hw, E1000_EXTCNF_CTRL, extcnf_ctrl);
1912 DEBUGOUT("Semaphore unexpectedly released by sw/fw/hw\n");
1915 E1000_MUTEX_UNLOCK(&hw->dev_spec.ich8lan.swflag_mutex);
1921 * e1000_check_mng_mode_ich8lan - Checks management mode
1922 * @hw: pointer to the HW structure
1924 * This checks if the adapter has any manageability enabled.
1925 * This is a function pointer entry point only called by read/write
1926 * routines for the PHY and NVM parts.
1928 STATIC bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw)
1932 DEBUGFUNC("e1000_check_mng_mode_ich8lan");
1934 fwsm = E1000_READ_REG(hw, E1000_FWSM);
1936 return (fwsm & E1000_ICH_FWSM_FW_VALID) &&
1937 ((fwsm & E1000_FWSM_MODE_MASK) ==
1938 (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT));
1942 * e1000_check_mng_mode_pchlan - Checks management mode
1943 * @hw: pointer to the HW structure
1945 * This checks if the adapter has iAMT enabled.
1946 * This is a function pointer entry point only called by read/write
1947 * routines for the PHY and NVM parts.
1949 STATIC bool e1000_check_mng_mode_pchlan(struct e1000_hw *hw)
1953 DEBUGFUNC("e1000_check_mng_mode_pchlan");
1955 fwsm = E1000_READ_REG(hw, E1000_FWSM);
1957 return (fwsm & E1000_ICH_FWSM_FW_VALID) &&
1958 (fwsm & (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT));
1962 * e1000_rar_set_pch2lan - Set receive address register
1963 * @hw: pointer to the HW structure
1964 * @addr: pointer to the receive address
1965 * @index: receive address array register
1967 * Sets the receive address array register at index to the address passed
1968 * in by addr. For 82579, RAR[0] is the base address register that is to
1969 * contain the MAC address but RAR[1-6] are reserved for manageability (ME).
1970 * Use SHRA[0-3] in place of those reserved for ME.
1972 STATIC int e1000_rar_set_pch2lan(struct e1000_hw *hw, u8 *addr, u32 index)
1974 u32 rar_low, rar_high;
1976 DEBUGFUNC("e1000_rar_set_pch2lan");
1978 /* HW expects these in little endian so we reverse the byte order
1979 * from network order (big endian) to little endian
1981 rar_low = ((u32) addr[0] |
1982 ((u32) addr[1] << 8) |
1983 ((u32) addr[2] << 16) | ((u32) addr[3] << 24));
1985 rar_high = ((u32) addr[4] | ((u32) addr[5] << 8));
1987 /* If MAC address zero, no need to set the AV bit */
1988 if (rar_low || rar_high)
1989 rar_high |= E1000_RAH_AV;
1992 E1000_WRITE_REG(hw, E1000_RAL(index), rar_low);
1993 E1000_WRITE_FLUSH(hw);
1994 E1000_WRITE_REG(hw, E1000_RAH(index), rar_high);
1995 E1000_WRITE_FLUSH(hw);
1996 return E1000_SUCCESS;
1999 /* RAR[1-6] are owned by manageability. Skip those and program the
2000 * next address into the SHRA register array.
2002 if (index < (u32) (hw->mac.rar_entry_count)) {
2005 ret_val = e1000_acquire_swflag_ich8lan(hw);
2009 E1000_WRITE_REG(hw, E1000_SHRAL(index - 1), rar_low);
2010 E1000_WRITE_FLUSH(hw);
2011 E1000_WRITE_REG(hw, E1000_SHRAH(index - 1), rar_high);
2012 E1000_WRITE_FLUSH(hw);
2014 e1000_release_swflag_ich8lan(hw);
2016 /* verify the register updates */
2017 if ((E1000_READ_REG(hw, E1000_SHRAL(index - 1)) == rar_low) &&
2018 (E1000_READ_REG(hw, E1000_SHRAH(index - 1)) == rar_high))
2019 return E1000_SUCCESS;
2021 DEBUGOUT2("SHRA[%d] might be locked by ME - FWSM=0x%8.8x\n",
2022 (index - 1), E1000_READ_REG(hw, E1000_FWSM));
2026 DEBUGOUT1("Failed to write receive address at index %d\n", index);
2027 return -E1000_ERR_CONFIG;
2031 * e1000_rar_set_pch_lpt - Set receive address registers
2032 * @hw: pointer to the HW structure
2033 * @addr: pointer to the receive address
2034 * @index: receive address array register
2036 * Sets the receive address register array at index to the address passed
2037 * in by addr. For LPT, RAR[0] is the base address register that is to
2038 * contain the MAC address. SHRA[0-10] are the shared receive address
2039 * registers that are shared between the Host and manageability engine (ME).
2041 STATIC int e1000_rar_set_pch_lpt(struct e1000_hw *hw, u8 *addr, u32 index)
2043 u32 rar_low, rar_high;
2046 DEBUGFUNC("e1000_rar_set_pch_lpt");
2048 /* HW expects these in little endian so we reverse the byte order
2049 * from network order (big endian) to little endian
2051 rar_low = ((u32) addr[0] | ((u32) addr[1] << 8) |
2052 ((u32) addr[2] << 16) | ((u32) addr[3] << 24));
2054 rar_high = ((u32) addr[4] | ((u32) addr[5] << 8));
2056 /* If MAC address zero, no need to set the AV bit */
2057 if (rar_low || rar_high)
2058 rar_high |= E1000_RAH_AV;
2061 E1000_WRITE_REG(hw, E1000_RAL(index), rar_low);
2062 E1000_WRITE_FLUSH(hw);
2063 E1000_WRITE_REG(hw, E1000_RAH(index), rar_high);
2064 E1000_WRITE_FLUSH(hw);
2065 return E1000_SUCCESS;
2068 /* The manageability engine (ME) can lock certain SHRAR registers that
2069 * it is using - those registers are unavailable for use.
2071 if (index < hw->mac.rar_entry_count) {
2072 wlock_mac = E1000_READ_REG(hw, E1000_FWSM) &
2073 E1000_FWSM_WLOCK_MAC_MASK;
2074 wlock_mac >>= E1000_FWSM_WLOCK_MAC_SHIFT;
2076 /* Check if all SHRAR registers are locked */
2080 if ((wlock_mac == 0) || (index <= wlock_mac)) {
2083 ret_val = e1000_acquire_swflag_ich8lan(hw);
2088 E1000_WRITE_REG(hw, E1000_SHRAL_PCH_LPT(index - 1),
2090 E1000_WRITE_FLUSH(hw);
2091 E1000_WRITE_REG(hw, E1000_SHRAH_PCH_LPT(index - 1),
2093 E1000_WRITE_FLUSH(hw);
2095 e1000_release_swflag_ich8lan(hw);
2097 /* verify the register updates */
2098 if ((E1000_READ_REG(hw, E1000_SHRAL_PCH_LPT(index - 1)) == rar_low) &&
2099 (E1000_READ_REG(hw, E1000_SHRAH_PCH_LPT(index - 1)) == rar_high))
2100 return E1000_SUCCESS;
2105 DEBUGOUT1("Failed to write receive address at index %d\n", index);
2106 return -E1000_ERR_CONFIG;
2109 #ifndef NO_NON_BLOCKING_PHY_MTA_UPDATE_SUPPORT
2111 * e1000_update_mc_addr_list_pch2lan - Update Multicast addresses
2112 * @hw: pointer to the HW structure
2113 * @mc_addr_list: array of multicast addresses to program
2114 * @mc_addr_count: number of multicast addresses to program
2116 * Updates entire Multicast Table Array of the PCH2 MAC and PHY.
2117 * The caller must have a packed mc_addr_list of multicast addresses.
2119 STATIC void e1000_update_mc_addr_list_pch2lan(struct e1000_hw *hw,
2127 DEBUGFUNC("e1000_update_mc_addr_list_pch2lan");
2129 e1000_update_mc_addr_list_generic(hw, mc_addr_list, mc_addr_count);
2131 ret_val = hw->phy.ops.acquire(hw);
2135 ret_val = e1000_enable_phy_wakeup_reg_access_bm(hw, &phy_reg);
2139 for (i = 0; i < hw->mac.mta_reg_count; i++) {
2140 hw->phy.ops.write_reg_page(hw, BM_MTA(i),
2141 (u16)(hw->mac.mta_shadow[i] &
2143 hw->phy.ops.write_reg_page(hw, (BM_MTA(i) + 1),
2144 (u16)((hw->mac.mta_shadow[i] >> 16) &
2148 e1000_disable_phy_wakeup_reg_access_bm(hw, &phy_reg);
2151 hw->phy.ops.release(hw);
2154 #endif /* NO_NON_BLOCKING_PHY_MTA_UPDATE_SUPPORT */
2156 * e1000_check_reset_block_ich8lan - Check if PHY reset is blocked
2157 * @hw: pointer to the HW structure
2159 * Checks if firmware is blocking the reset of the PHY.
2160 * This is a function pointer entry point only called by
2163 STATIC s32 e1000_check_reset_block_ich8lan(struct e1000_hw *hw)
2166 bool blocked = false;
2169 DEBUGFUNC("e1000_check_reset_block_ich8lan");
2172 fwsm = E1000_READ_REG(hw, E1000_FWSM);
2173 if (!(fwsm & E1000_ICH_FWSM_RSPCIPHY)) {
2179 } while (blocked && (i++ < 30));
2180 return blocked ? E1000_BLK_PHY_RESET : E1000_SUCCESS;
2184 * e1000_write_smbus_addr - Write SMBus address to PHY needed during Sx states
2185 * @hw: pointer to the HW structure
2187 * Assumes semaphore already acquired.
2190 STATIC s32 e1000_write_smbus_addr(struct e1000_hw *hw)
2193 u32 strap = E1000_READ_REG(hw, E1000_STRAP);
2194 u32 freq = (strap & E1000_STRAP_SMT_FREQ_MASK) >>
2195 E1000_STRAP_SMT_FREQ_SHIFT;
2198 strap &= E1000_STRAP_SMBUS_ADDRESS_MASK;
2200 ret_val = e1000_read_phy_reg_hv_locked(hw, HV_SMB_ADDR, &phy_data);
2204 phy_data &= ~HV_SMB_ADDR_MASK;
2205 phy_data |= (strap >> E1000_STRAP_SMBUS_ADDRESS_SHIFT);
2206 phy_data |= HV_SMB_ADDR_PEC_EN | HV_SMB_ADDR_VALID;
2208 if (hw->phy.type == e1000_phy_i217) {
2209 /* Restore SMBus frequency */
2211 phy_data &= ~HV_SMB_ADDR_FREQ_MASK;
2212 phy_data |= (freq & (1 << 0)) <<
2213 HV_SMB_ADDR_FREQ_LOW_SHIFT;
2214 phy_data |= (freq & (1 << 1)) <<
2215 (HV_SMB_ADDR_FREQ_HIGH_SHIFT - 1);
2217 DEBUGOUT("Unsupported SMB frequency in PHY\n");
2221 return e1000_write_phy_reg_hv_locked(hw, HV_SMB_ADDR, phy_data);
2225 * e1000_sw_lcd_config_ich8lan - SW-based LCD Configuration
2226 * @hw: pointer to the HW structure
2228 * SW should configure the LCD from the NVM extended configuration region
2229 * as a workaround for certain parts.
2231 STATIC s32 e1000_sw_lcd_config_ich8lan(struct e1000_hw *hw)
2233 struct e1000_phy_info *phy = &hw->phy;
2234 u32 i, data, cnf_size, cnf_base_addr, sw_cfg_mask;
2235 s32 ret_val = E1000_SUCCESS;
2236 u16 word_addr, reg_data, reg_addr, phy_page = 0;
2238 DEBUGFUNC("e1000_sw_lcd_config_ich8lan");
2240 /* Initialize the PHY from the NVM on ICH platforms. This
2241 * is needed due to an issue where the NVM configuration is
2242 * not properly autoloaded after power transitions.
2243 * Therefore, after each PHY reset, we will load the
2244 * configuration data out of the NVM manually.
2246 switch (hw->mac.type) {
2248 if (phy->type != e1000_phy_igp_3)
2251 if ((hw->device_id == E1000_DEV_ID_ICH8_IGP_AMT) ||
2252 (hw->device_id == E1000_DEV_ID_ICH8_IGP_C)) {
2253 sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG;
2262 sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG_ICH8M;
2268 ret_val = hw->phy.ops.acquire(hw);
2272 data = E1000_READ_REG(hw, E1000_FEXTNVM);
2273 if (!(data & sw_cfg_mask))
2276 /* Make sure HW does not configure LCD from PHY
2277 * extended configuration before SW configuration
2279 data = E1000_READ_REG(hw, E1000_EXTCNF_CTRL);
2280 if ((hw->mac.type < e1000_pch2lan) &&
2281 (data & E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE))
2284 cnf_size = E1000_READ_REG(hw, E1000_EXTCNF_SIZE);
2285 cnf_size &= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_MASK;
2286 cnf_size >>= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_SHIFT;
2290 cnf_base_addr = data & E1000_EXTCNF_CTRL_EXT_CNF_POINTER_MASK;
2291 cnf_base_addr >>= E1000_EXTCNF_CTRL_EXT_CNF_POINTER_SHIFT;
2293 if (((hw->mac.type == e1000_pchlan) &&
2294 !(data & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE)) ||
2295 (hw->mac.type > e1000_pchlan)) {
2296 /* HW configures the SMBus address and LEDs when the
2297 * OEM and LCD Write Enable bits are set in the NVM.
2298 * When both NVM bits are cleared, SW will configure
2301 ret_val = e1000_write_smbus_addr(hw);
2305 data = E1000_READ_REG(hw, E1000_LEDCTL);
2306 ret_val = e1000_write_phy_reg_hv_locked(hw, HV_LED_CONFIG,
2312 /* Configure LCD from extended configuration region. */
2314 /* cnf_base_addr is in DWORD */
2315 word_addr = (u16)(cnf_base_addr << 1);
2317 for (i = 0; i < cnf_size; i++) {
2318 ret_val = hw->nvm.ops.read(hw, (word_addr + i * 2), 1,
2323 ret_val = hw->nvm.ops.read(hw, (word_addr + i * 2 + 1),
2328 /* Save off the PHY page for future writes. */
2329 if (reg_addr == IGP01E1000_PHY_PAGE_SELECT) {
2330 phy_page = reg_data;
2334 reg_addr &= PHY_REG_MASK;
2335 reg_addr |= phy_page;
2337 ret_val = phy->ops.write_reg_locked(hw, (u32)reg_addr,
2344 hw->phy.ops.release(hw);
2349 * e1000_k1_gig_workaround_hv - K1 Si workaround
2350 * @hw: pointer to the HW structure
2351 * @link: link up bool flag
2353 * If K1 is enabled for 1Gbps, the MAC might stall when transitioning
2354 * from a lower speed. This workaround disables K1 whenever link is at 1Gig
2355 * If link is down, the function will restore the default K1 setting located
2358 STATIC s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link)
2360 s32 ret_val = E1000_SUCCESS;
2362 bool k1_enable = hw->dev_spec.ich8lan.nvm_k1_enabled;
2364 DEBUGFUNC("e1000_k1_gig_workaround_hv");
2366 if (hw->mac.type != e1000_pchlan)
2367 return E1000_SUCCESS;
2369 /* Wrap the whole flow with the sw flag */
2370 ret_val = hw->phy.ops.acquire(hw);
2374 /* Disable K1 when link is 1Gbps, otherwise use the NVM setting */
2376 if (hw->phy.type == e1000_phy_82578) {
2377 ret_val = hw->phy.ops.read_reg_locked(hw, BM_CS_STATUS,
2382 status_reg &= (BM_CS_STATUS_LINK_UP |
2383 BM_CS_STATUS_RESOLVED |
2384 BM_CS_STATUS_SPEED_MASK);
2386 if (status_reg == (BM_CS_STATUS_LINK_UP |
2387 BM_CS_STATUS_RESOLVED |
2388 BM_CS_STATUS_SPEED_1000))
2392 if (hw->phy.type == e1000_phy_82577) {
2393 ret_val = hw->phy.ops.read_reg_locked(hw, HV_M_STATUS,
2398 status_reg &= (HV_M_STATUS_LINK_UP |
2399 HV_M_STATUS_AUTONEG_COMPLETE |
2400 HV_M_STATUS_SPEED_MASK);
2402 if (status_reg == (HV_M_STATUS_LINK_UP |
2403 HV_M_STATUS_AUTONEG_COMPLETE |
2404 HV_M_STATUS_SPEED_1000))
2408 /* Link stall fix for link up */
2409 ret_val = hw->phy.ops.write_reg_locked(hw, PHY_REG(770, 19),
2415 /* Link stall fix for link down */
2416 ret_val = hw->phy.ops.write_reg_locked(hw, PHY_REG(770, 19),
2422 ret_val = e1000_configure_k1_ich8lan(hw, k1_enable);
2425 hw->phy.ops.release(hw);
2431 * e1000_configure_k1_ich8lan - Configure K1 power state
2432 * @hw: pointer to the HW structure
2433 * @enable: K1 state to configure
2435 * Configure the K1 power state based on the provided parameter.
2436 * Assumes semaphore already acquired.
2438 * Success returns 0, Failure returns -E1000_ERR_PHY (-2)
2440 s32 e1000_configure_k1_ich8lan(struct e1000_hw *hw, bool k1_enable)
2448 DEBUGFUNC("e1000_configure_k1_ich8lan");
2450 ret_val = e1000_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
2456 kmrn_reg |= E1000_KMRNCTRLSTA_K1_ENABLE;
2458 kmrn_reg &= ~E1000_KMRNCTRLSTA_K1_ENABLE;
2460 ret_val = e1000_write_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
2466 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
2467 ctrl_reg = E1000_READ_REG(hw, E1000_CTRL);
2469 reg = ctrl_reg & ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100);
2470 reg |= E1000_CTRL_FRCSPD;
2471 E1000_WRITE_REG(hw, E1000_CTRL, reg);
2473 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext | E1000_CTRL_EXT_SPD_BYPS);
2474 E1000_WRITE_FLUSH(hw);
2476 E1000_WRITE_REG(hw, E1000_CTRL, ctrl_reg);
2477 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
2478 E1000_WRITE_FLUSH(hw);
2481 return E1000_SUCCESS;
2485 * e1000_oem_bits_config_ich8lan - SW-based LCD Configuration
2486 * @hw: pointer to the HW structure
2487 * @d0_state: boolean if entering d0 or d3 device state
2489 * SW will configure Gbe Disable and LPLU based on the NVM. The four bits are
2490 * collectively called OEM bits. The OEM Write Enable bit and SW Config bit
2491 * in NVM determines whether HW should configure LPLU and Gbe Disable.
2493 STATIC s32 e1000_oem_bits_config_ich8lan(struct e1000_hw *hw, bool d0_state)
2499 DEBUGFUNC("e1000_oem_bits_config_ich8lan");
2501 if (hw->mac.type < e1000_pchlan)
2504 ret_val = hw->phy.ops.acquire(hw);
2508 if (hw->mac.type == e1000_pchlan) {
2509 mac_reg = E1000_READ_REG(hw, E1000_EXTCNF_CTRL);
2510 if (mac_reg & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE)
2514 mac_reg = E1000_READ_REG(hw, E1000_FEXTNVM);
2515 if (!(mac_reg & E1000_FEXTNVM_SW_CONFIG_ICH8M))
2518 mac_reg = E1000_READ_REG(hw, E1000_PHY_CTRL);
2520 ret_val = hw->phy.ops.read_reg_locked(hw, HV_OEM_BITS, &oem_reg);
2524 oem_reg &= ~(HV_OEM_BITS_GBE_DIS | HV_OEM_BITS_LPLU);
2527 if (mac_reg & E1000_PHY_CTRL_GBE_DISABLE)
2528 oem_reg |= HV_OEM_BITS_GBE_DIS;
2530 if (mac_reg & E1000_PHY_CTRL_D0A_LPLU)
2531 oem_reg |= HV_OEM_BITS_LPLU;
2533 if (mac_reg & (E1000_PHY_CTRL_GBE_DISABLE |
2534 E1000_PHY_CTRL_NOND0A_GBE_DISABLE))
2535 oem_reg |= HV_OEM_BITS_GBE_DIS;
2537 if (mac_reg & (E1000_PHY_CTRL_D0A_LPLU |
2538 E1000_PHY_CTRL_NOND0A_LPLU))
2539 oem_reg |= HV_OEM_BITS_LPLU;
2542 /* Set Restart auto-neg to activate the bits */
2543 if ((d0_state || (hw->mac.type != e1000_pchlan)) &&
2544 !hw->phy.ops.check_reset_block(hw))
2545 oem_reg |= HV_OEM_BITS_RESTART_AN;
2547 ret_val = hw->phy.ops.write_reg_locked(hw, HV_OEM_BITS, oem_reg);
2550 hw->phy.ops.release(hw);
2557 * e1000_set_mdio_slow_mode_hv - Set slow MDIO access mode
2558 * @hw: pointer to the HW structure
2560 STATIC s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw)
2565 DEBUGFUNC("e1000_set_mdio_slow_mode_hv");
2567 ret_val = hw->phy.ops.read_reg(hw, HV_KMRN_MODE_CTRL, &data);
2571 data |= HV_KMRN_MDIO_SLOW;
2573 ret_val = hw->phy.ops.write_reg(hw, HV_KMRN_MODE_CTRL, data);
2579 * e1000_hv_phy_workarounds_ich8lan - A series of Phy workarounds to be
2580 * done after every PHY reset.
2582 STATIC s32 e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw)
2584 s32 ret_val = E1000_SUCCESS;
2587 DEBUGFUNC("e1000_hv_phy_workarounds_ich8lan");
2589 if (hw->mac.type != e1000_pchlan)
2590 return E1000_SUCCESS;
2592 /* Set MDIO slow mode before any other MDIO access */
2593 if (hw->phy.type == e1000_phy_82577) {
2594 ret_val = e1000_set_mdio_slow_mode_hv(hw);
2599 if (((hw->phy.type == e1000_phy_82577) &&
2600 ((hw->phy.revision == 1) || (hw->phy.revision == 2))) ||
2601 ((hw->phy.type == e1000_phy_82578) && (hw->phy.revision == 1))) {
2602 /* Disable generation of early preamble */
2603 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(769, 25), 0x4431);
2607 /* Preamble tuning for SSC */
2608 ret_val = hw->phy.ops.write_reg(hw, HV_KMRN_FIFO_CTRLSTA,
2614 if (hw->phy.type == e1000_phy_82578) {
2615 /* Return registers to default by doing a soft reset then
2616 * writing 0x3140 to the control register.
2618 if (hw->phy.revision < 2) {
2619 e1000_phy_sw_reset_generic(hw);
2620 ret_val = hw->phy.ops.write_reg(hw, PHY_CONTROL,
2626 ret_val = hw->phy.ops.acquire(hw);
2631 ret_val = e1000_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT, 0);
2632 hw->phy.ops.release(hw);
2636 /* Configure the K1 Si workaround during phy reset assuming there is
2637 * link so that it disables K1 if link is in 1Gbps.
2639 ret_val = e1000_k1_gig_workaround_hv(hw, true);
2643 /* Workaround for link disconnects on a busy hub in half duplex */
2644 ret_val = hw->phy.ops.acquire(hw);
2647 ret_val = hw->phy.ops.read_reg_locked(hw, BM_PORT_GEN_CFG, &phy_data);
2650 ret_val = hw->phy.ops.write_reg_locked(hw, BM_PORT_GEN_CFG,
2655 /* set MSE higher to enable link to stay up when noise is high */
2656 ret_val = e1000_write_emi_reg_locked(hw, I82577_MSE_THRESHOLD, 0x0034);
2658 hw->phy.ops.release(hw);
2664 * e1000_copy_rx_addrs_to_phy_ich8lan - Copy Rx addresses from MAC to PHY
2665 * @hw: pointer to the HW structure
2667 void e1000_copy_rx_addrs_to_phy_ich8lan(struct e1000_hw *hw)
2673 DEBUGFUNC("e1000_copy_rx_addrs_to_phy_ich8lan");
2675 ret_val = hw->phy.ops.acquire(hw);
2678 ret_val = e1000_enable_phy_wakeup_reg_access_bm(hw, &phy_reg);
2682 /* Copy both RAL/H (rar_entry_count) and SHRAL/H to PHY */
2683 for (i = 0; i < (hw->mac.rar_entry_count); i++) {
2684 mac_reg = E1000_READ_REG(hw, E1000_RAL(i));
2685 hw->phy.ops.write_reg_page(hw, BM_RAR_L(i),
2686 (u16)(mac_reg & 0xFFFF));
2687 hw->phy.ops.write_reg_page(hw, BM_RAR_M(i),
2688 (u16)((mac_reg >> 16) & 0xFFFF));
2690 mac_reg = E1000_READ_REG(hw, E1000_RAH(i));
2691 hw->phy.ops.write_reg_page(hw, BM_RAR_H(i),
2692 (u16)(mac_reg & 0xFFFF));
2693 hw->phy.ops.write_reg_page(hw, BM_RAR_CTRL(i),
2694 (u16)((mac_reg & E1000_RAH_AV)
2698 e1000_disable_phy_wakeup_reg_access_bm(hw, &phy_reg);
2701 hw->phy.ops.release(hw);
2704 #ifndef CRC32_OS_SUPPORT
2705 STATIC u32 e1000_calc_rx_da_crc(u8 mac[])
2707 u32 poly = 0xEDB88320; /* Polynomial for 802.3 CRC calculation */
2708 u32 i, j, mask, crc;
2710 DEBUGFUNC("e1000_calc_rx_da_crc");
2713 for (i = 0; i < 6; i++) {
2715 for (j = 8; j > 0; j--) {
2716 mask = (crc & 1) * (-1);
2717 crc = (crc >> 1) ^ (poly & mask);
2723 #endif /* CRC32_OS_SUPPORT */
2725 * e1000_lv_jumbo_workaround_ich8lan - required for jumbo frame operation
2727 * @hw: pointer to the HW structure
2728 * @enable: flag to enable/disable workaround when enabling/disabling jumbos
2730 s32 e1000_lv_jumbo_workaround_ich8lan(struct e1000_hw *hw, bool enable)
2732 s32 ret_val = E1000_SUCCESS;
2737 DEBUGFUNC("e1000_lv_jumbo_workaround_ich8lan");
2739 if (hw->mac.type < e1000_pch2lan)
2740 return E1000_SUCCESS;
2742 /* disable Rx path while enabling/disabling workaround */
2743 hw->phy.ops.read_reg(hw, PHY_REG(769, 20), &phy_reg);
2744 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(769, 20),
2745 phy_reg | (1 << 14));
2750 /* Write Rx addresses (rar_entry_count for RAL/H, and
2751 * SHRAL/H) and initial CRC values to the MAC
2753 for (i = 0; i < hw->mac.rar_entry_count; i++) {
2754 u8 mac_addr[ETH_ADDR_LEN] = {0};
2755 u32 addr_high, addr_low;
2757 addr_high = E1000_READ_REG(hw, E1000_RAH(i));
2758 if (!(addr_high & E1000_RAH_AV))
2760 addr_low = E1000_READ_REG(hw, E1000_RAL(i));
2761 mac_addr[0] = (addr_low & 0xFF);
2762 mac_addr[1] = ((addr_low >> 8) & 0xFF);
2763 mac_addr[2] = ((addr_low >> 16) & 0xFF);
2764 mac_addr[3] = ((addr_low >> 24) & 0xFF);
2765 mac_addr[4] = (addr_high & 0xFF);
2766 mac_addr[5] = ((addr_high >> 8) & 0xFF);
2768 #ifndef CRC32_OS_SUPPORT
2769 E1000_WRITE_REG(hw, E1000_PCH_RAICC(i),
2770 e1000_calc_rx_da_crc(mac_addr));
2771 #else /* CRC32_OS_SUPPORT */
2772 E1000_WRITE_REG(hw, E1000_PCH_RAICC(i),
2773 E1000_CRC32(ETH_ADDR_LEN, mac_addr));
2774 #endif /* CRC32_OS_SUPPORT */
2777 /* Write Rx addresses to the PHY */
2778 e1000_copy_rx_addrs_to_phy_ich8lan(hw);
2780 /* Enable jumbo frame workaround in the MAC */
2781 mac_reg = E1000_READ_REG(hw, E1000_FFLT_DBG);
2782 mac_reg &= ~(1 << 14);
2783 mac_reg |= (7 << 15);
2784 E1000_WRITE_REG(hw, E1000_FFLT_DBG, mac_reg);
2786 mac_reg = E1000_READ_REG(hw, E1000_RCTL);
2787 mac_reg |= E1000_RCTL_SECRC;
2788 E1000_WRITE_REG(hw, E1000_RCTL, mac_reg);
2790 ret_val = e1000_read_kmrn_reg_generic(hw,
2791 E1000_KMRNCTRLSTA_CTRL_OFFSET,
2795 ret_val = e1000_write_kmrn_reg_generic(hw,
2796 E1000_KMRNCTRLSTA_CTRL_OFFSET,
2800 ret_val = e1000_read_kmrn_reg_generic(hw,
2801 E1000_KMRNCTRLSTA_HD_CTRL,
2805 data &= ~(0xF << 8);
2807 ret_val = e1000_write_kmrn_reg_generic(hw,
2808 E1000_KMRNCTRLSTA_HD_CTRL,
2813 /* Enable jumbo frame workaround in the PHY */
2814 hw->phy.ops.read_reg(hw, PHY_REG(769, 23), &data);
2815 data &= ~(0x7F << 5);
2816 data |= (0x37 << 5);
2817 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(769, 23), data);
2820 hw->phy.ops.read_reg(hw, PHY_REG(769, 16), &data);
2822 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(769, 16), data);
2825 hw->phy.ops.read_reg(hw, PHY_REG(776, 20), &data);
2826 data &= ~(0x3FF << 2);
2827 data |= (E1000_TX_PTR_GAP << 2);
2828 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(776, 20), data);
2831 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(776, 23), 0xF100);
2834 hw->phy.ops.read_reg(hw, HV_PM_CTRL, &data);
2835 ret_val = hw->phy.ops.write_reg(hw, HV_PM_CTRL, data |
2840 /* Write MAC register values back to h/w defaults */
2841 mac_reg = E1000_READ_REG(hw, E1000_FFLT_DBG);
2842 mac_reg &= ~(0xF << 14);
2843 E1000_WRITE_REG(hw, E1000_FFLT_DBG, mac_reg);
2845 mac_reg = E1000_READ_REG(hw, E1000_RCTL);
2846 mac_reg &= ~E1000_RCTL_SECRC;
2847 E1000_WRITE_REG(hw, E1000_RCTL, mac_reg);
2849 ret_val = e1000_read_kmrn_reg_generic(hw,
2850 E1000_KMRNCTRLSTA_CTRL_OFFSET,
2854 ret_val = e1000_write_kmrn_reg_generic(hw,
2855 E1000_KMRNCTRLSTA_CTRL_OFFSET,
2859 ret_val = e1000_read_kmrn_reg_generic(hw,
2860 E1000_KMRNCTRLSTA_HD_CTRL,
2864 data &= ~(0xF << 8);
2866 ret_val = e1000_write_kmrn_reg_generic(hw,
2867 E1000_KMRNCTRLSTA_HD_CTRL,
2872 /* Write PHY register values back to h/w defaults */
2873 hw->phy.ops.read_reg(hw, PHY_REG(769, 23), &data);
2874 data &= ~(0x7F << 5);
2875 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(769, 23), data);
2878 hw->phy.ops.read_reg(hw, PHY_REG(769, 16), &data);
2880 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(769, 16), data);
2883 hw->phy.ops.read_reg(hw, PHY_REG(776, 20), &data);
2884 data &= ~(0x3FF << 2);
2886 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(776, 20), data);
2889 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(776, 23), 0x7E00);
2892 hw->phy.ops.read_reg(hw, HV_PM_CTRL, &data);
2893 ret_val = hw->phy.ops.write_reg(hw, HV_PM_CTRL, data &
2899 /* re-enable Rx path after enabling/disabling workaround */
2900 return hw->phy.ops.write_reg(hw, PHY_REG(769, 20), phy_reg &
2905 * e1000_lv_phy_workarounds_ich8lan - A series of Phy workarounds to be
2906 * done after every PHY reset.
2908 STATIC s32 e1000_lv_phy_workarounds_ich8lan(struct e1000_hw *hw)
2910 s32 ret_val = E1000_SUCCESS;
2912 DEBUGFUNC("e1000_lv_phy_workarounds_ich8lan");
2914 if (hw->mac.type != e1000_pch2lan)
2915 return E1000_SUCCESS;
2917 /* Set MDIO slow mode before any other MDIO access */
2918 ret_val = e1000_set_mdio_slow_mode_hv(hw);
2922 ret_val = hw->phy.ops.acquire(hw);
2925 /* set MSE higher to enable link to stay up when noise is high */
2926 ret_val = e1000_write_emi_reg_locked(hw, I82579_MSE_THRESHOLD, 0x0034);
2929 /* drop link after 5 times MSE threshold was reached */
2930 ret_val = e1000_write_emi_reg_locked(hw, I82579_MSE_LINK_DOWN, 0x0005);
2932 hw->phy.ops.release(hw);
2938 * e1000_k1_gig_workaround_lv - K1 Si workaround
2939 * @hw: pointer to the HW structure
2941 * Workaround to set the K1 beacon duration for 82579 parts in 10Mbps
2942 * Disable K1 for 1000 and 100 speeds
2944 STATIC s32 e1000_k1_workaround_lv(struct e1000_hw *hw)
2946 s32 ret_val = E1000_SUCCESS;
2949 DEBUGFUNC("e1000_k1_workaround_lv");
2951 if (hw->mac.type != e1000_pch2lan)
2952 return E1000_SUCCESS;
2954 /* Set K1 beacon duration based on 10Mbs speed */
2955 ret_val = hw->phy.ops.read_reg(hw, HV_M_STATUS, &status_reg);
2959 if ((status_reg & (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE))
2960 == (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE)) {
2962 (HV_M_STATUS_SPEED_1000 | HV_M_STATUS_SPEED_100)) {
2965 /* LV 1G/100 Packet drop issue wa */
2966 ret_val = hw->phy.ops.read_reg(hw, HV_PM_CTRL,
2970 pm_phy_reg &= ~HV_PM_CTRL_K1_ENABLE;
2971 ret_val = hw->phy.ops.write_reg(hw, HV_PM_CTRL,
2977 mac_reg = E1000_READ_REG(hw, E1000_FEXTNVM4);
2978 mac_reg &= ~E1000_FEXTNVM4_BEACON_DURATION_MASK;
2979 mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_16USEC;
2980 E1000_WRITE_REG(hw, E1000_FEXTNVM4, mac_reg);
2988 * e1000_gate_hw_phy_config_ich8lan - disable PHY config via hardware
2989 * @hw: pointer to the HW structure
2990 * @gate: boolean set to true to gate, false to ungate
2992 * Gate/ungate the automatic PHY configuration via hardware; perform
2993 * the configuration via software instead.
2995 STATIC void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate)
2999 DEBUGFUNC("e1000_gate_hw_phy_config_ich8lan");
3001 if (hw->mac.type < e1000_pch2lan)
3004 extcnf_ctrl = E1000_READ_REG(hw, E1000_EXTCNF_CTRL);
3007 extcnf_ctrl |= E1000_EXTCNF_CTRL_GATE_PHY_CFG;
3009 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_GATE_PHY_CFG;
3011 E1000_WRITE_REG(hw, E1000_EXTCNF_CTRL, extcnf_ctrl);
3015 * e1000_lan_init_done_ich8lan - Check for PHY config completion
3016 * @hw: pointer to the HW structure
3018 * Check the appropriate indication the MAC has finished configuring the
3019 * PHY after a software reset.
3021 STATIC void e1000_lan_init_done_ich8lan(struct e1000_hw *hw)
3023 u32 data, loop = E1000_ICH8_LAN_INIT_TIMEOUT;
3025 DEBUGFUNC("e1000_lan_init_done_ich8lan");
3027 /* Wait for basic configuration completes before proceeding */
3029 data = E1000_READ_REG(hw, E1000_STATUS);
3030 data &= E1000_STATUS_LAN_INIT_DONE;
3032 } while ((!data) && --loop);
3034 /* If basic configuration is incomplete before the above loop
3035 * count reaches 0, loading the configuration from NVM will
3036 * leave the PHY in a bad state possibly resulting in no link.
3039 DEBUGOUT("LAN_INIT_DONE not set, increase timeout\n");
3041 /* Clear the Init Done bit for the next init event */
3042 data = E1000_READ_REG(hw, E1000_STATUS);
3043 data &= ~E1000_STATUS_LAN_INIT_DONE;
3044 E1000_WRITE_REG(hw, E1000_STATUS, data);
3048 * e1000_post_phy_reset_ich8lan - Perform steps required after a PHY reset
3049 * @hw: pointer to the HW structure
3051 STATIC s32 e1000_post_phy_reset_ich8lan(struct e1000_hw *hw)
3053 s32 ret_val = E1000_SUCCESS;
3056 DEBUGFUNC("e1000_post_phy_reset_ich8lan");
3058 if (hw->phy.ops.check_reset_block(hw))
3059 return E1000_SUCCESS;
3061 /* Allow time for h/w to get to quiescent state after reset */
3064 /* Perform any necessary post-reset workarounds */
3065 switch (hw->mac.type) {
3067 ret_val = e1000_hv_phy_workarounds_ich8lan(hw);
3072 ret_val = e1000_lv_phy_workarounds_ich8lan(hw);
3080 /* Clear the host wakeup bit after lcd reset */
3081 if (hw->mac.type >= e1000_pchlan) {
3082 hw->phy.ops.read_reg(hw, BM_PORT_GEN_CFG, ®);
3083 reg &= ~BM_WUC_HOST_WU_BIT;
3084 hw->phy.ops.write_reg(hw, BM_PORT_GEN_CFG, reg);
3087 /* Configure the LCD with the extended configuration region in NVM */
3088 ret_val = e1000_sw_lcd_config_ich8lan(hw);
3092 /* Configure the LCD with the OEM bits in NVM */
3093 ret_val = e1000_oem_bits_config_ich8lan(hw, true);
3095 if (hw->mac.type == e1000_pch2lan) {
3096 /* Ungate automatic PHY configuration on non-managed 82579 */
3097 if (!(E1000_READ_REG(hw, E1000_FWSM) &
3098 E1000_ICH_FWSM_FW_VALID)) {
3100 e1000_gate_hw_phy_config_ich8lan(hw, false);
3103 /* Set EEE LPI Update Timer to 200usec */
3104 ret_val = hw->phy.ops.acquire(hw);
3107 ret_val = e1000_write_emi_reg_locked(hw,
3108 I82579_LPI_UPDATE_TIMER,
3110 hw->phy.ops.release(hw);
3117 * e1000_phy_hw_reset_ich8lan - Performs a PHY reset
3118 * @hw: pointer to the HW structure
3121 * This is a function pointer entry point called by drivers
3122 * or other shared routines.
3124 STATIC s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw)
3126 s32 ret_val = E1000_SUCCESS;
3128 DEBUGFUNC("e1000_phy_hw_reset_ich8lan");
3130 /* Gate automatic PHY configuration by hardware on non-managed 82579 */
3131 if ((hw->mac.type == e1000_pch2lan) &&
3132 !(E1000_READ_REG(hw, E1000_FWSM) & E1000_ICH_FWSM_FW_VALID))
3133 e1000_gate_hw_phy_config_ich8lan(hw, true);
3135 ret_val = e1000_phy_hw_reset_generic(hw);
3139 return e1000_post_phy_reset_ich8lan(hw);
3143 * e1000_set_lplu_state_pchlan - Set Low Power Link Up state
3144 * @hw: pointer to the HW structure
3145 * @active: true to enable LPLU, false to disable
3147 * Sets the LPLU state according to the active flag. For PCH, if OEM write
3148 * bit are disabled in the NVM, writing the LPLU bits in the MAC will not set
3149 * the phy speed. This function will manually set the LPLU bit and restart
3150 * auto-neg as hw would do. D3 and D0 LPLU will call the same function
3151 * since it configures the same bit.
3153 STATIC s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active)
3158 DEBUGFUNC("e1000_set_lplu_state_pchlan");
3159 ret_val = hw->phy.ops.read_reg(hw, HV_OEM_BITS, &oem_reg);
3164 oem_reg |= HV_OEM_BITS_LPLU;
3166 oem_reg &= ~HV_OEM_BITS_LPLU;
3168 if (!hw->phy.ops.check_reset_block(hw))
3169 oem_reg |= HV_OEM_BITS_RESTART_AN;
3171 return hw->phy.ops.write_reg(hw, HV_OEM_BITS, oem_reg);
3175 * e1000_set_d0_lplu_state_ich8lan - Set Low Power Linkup D0 state
3176 * @hw: pointer to the HW structure
3177 * @active: true to enable LPLU, false to disable
3179 * Sets the LPLU D0 state according to the active flag. When
3180 * activating LPLU this function also disables smart speed
3181 * and vice versa. LPLU will not be activated unless the
3182 * device autonegotiation advertisement meets standards of
3183 * either 10 or 10/100 or 10/100/1000 at all duplexes.
3184 * This is a function pointer entry point only called by
3185 * PHY setup routines.
3187 STATIC s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
3189 struct e1000_phy_info *phy = &hw->phy;
3191 s32 ret_val = E1000_SUCCESS;
3194 DEBUGFUNC("e1000_set_d0_lplu_state_ich8lan");
3196 if (phy->type == e1000_phy_ife)
3197 return E1000_SUCCESS;
3199 phy_ctrl = E1000_READ_REG(hw, E1000_PHY_CTRL);
3202 phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU;
3203 E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl);
3205 if (phy->type != e1000_phy_igp_3)
3206 return E1000_SUCCESS;
3208 /* Call gig speed drop workaround on LPLU before accessing
3211 if (hw->mac.type == e1000_ich8lan)
3212 e1000_gig_downshift_workaround_ich8lan(hw);
3214 /* When LPLU is enabled, we should disable SmartSpeed */
3215 ret_val = phy->ops.read_reg(hw,
3216 IGP01E1000_PHY_PORT_CONFIG,
3220 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
3221 ret_val = phy->ops.write_reg(hw,
3222 IGP01E1000_PHY_PORT_CONFIG,
3227 phy_ctrl &= ~E1000_PHY_CTRL_D0A_LPLU;
3228 E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl);
3230 if (phy->type != e1000_phy_igp_3)
3231 return E1000_SUCCESS;
3233 /* LPLU and SmartSpeed are mutually exclusive. LPLU is used
3234 * during Dx states where the power conservation is most
3235 * important. During driver activity we should enable
3236 * SmartSpeed, so performance is maintained.
3238 if (phy->smart_speed == e1000_smart_speed_on) {
3239 ret_val = phy->ops.read_reg(hw,
3240 IGP01E1000_PHY_PORT_CONFIG,
3245 data |= IGP01E1000_PSCFR_SMART_SPEED;
3246 ret_val = phy->ops.write_reg(hw,
3247 IGP01E1000_PHY_PORT_CONFIG,
3251 } else if (phy->smart_speed == e1000_smart_speed_off) {
3252 ret_val = phy->ops.read_reg(hw,
3253 IGP01E1000_PHY_PORT_CONFIG,
3258 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
3259 ret_val = phy->ops.write_reg(hw,
3260 IGP01E1000_PHY_PORT_CONFIG,
3267 return E1000_SUCCESS;
3271 * e1000_set_d3_lplu_state_ich8lan - Set Low Power Linkup D3 state
3272 * @hw: pointer to the HW structure
3273 * @active: true to enable LPLU, false to disable
3275 * Sets the LPLU D3 state according to the active flag. When
3276 * activating LPLU this function also disables smart speed
3277 * and vice versa. LPLU will not be activated unless the
3278 * device autonegotiation advertisement meets standards of
3279 * either 10 or 10/100 or 10/100/1000 at all duplexes.
3280 * This is a function pointer entry point only called by
3281 * PHY setup routines.
3283 STATIC s32 e1000_set_d3_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
3285 struct e1000_phy_info *phy = &hw->phy;
3287 s32 ret_val = E1000_SUCCESS;
3290 DEBUGFUNC("e1000_set_d3_lplu_state_ich8lan");
3292 phy_ctrl = E1000_READ_REG(hw, E1000_PHY_CTRL);
3295 phy_ctrl &= ~E1000_PHY_CTRL_NOND0A_LPLU;
3296 E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl);
3298 if (phy->type != e1000_phy_igp_3)
3299 return E1000_SUCCESS;
3301 /* LPLU and SmartSpeed are mutually exclusive. LPLU is used
3302 * during Dx states where the power conservation is most
3303 * important. During driver activity we should enable
3304 * SmartSpeed, so performance is maintained.
3306 if (phy->smart_speed == e1000_smart_speed_on) {
3307 ret_val = phy->ops.read_reg(hw,
3308 IGP01E1000_PHY_PORT_CONFIG,
3313 data |= IGP01E1000_PSCFR_SMART_SPEED;
3314 ret_val = phy->ops.write_reg(hw,
3315 IGP01E1000_PHY_PORT_CONFIG,
3319 } else if (phy->smart_speed == e1000_smart_speed_off) {
3320 ret_val = phy->ops.read_reg(hw,
3321 IGP01E1000_PHY_PORT_CONFIG,
3326 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
3327 ret_val = phy->ops.write_reg(hw,
3328 IGP01E1000_PHY_PORT_CONFIG,
3333 } else if ((phy->autoneg_advertised == E1000_ALL_SPEED_DUPLEX) ||
3334 (phy->autoneg_advertised == E1000_ALL_NOT_GIG) ||
3335 (phy->autoneg_advertised == E1000_ALL_10_SPEED)) {
3336 phy_ctrl |= E1000_PHY_CTRL_NOND0A_LPLU;
3337 E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl);
3339 if (phy->type != e1000_phy_igp_3)
3340 return E1000_SUCCESS;
3342 /* Call gig speed drop workaround on LPLU before accessing
3345 if (hw->mac.type == e1000_ich8lan)
3346 e1000_gig_downshift_workaround_ich8lan(hw);
3348 /* When LPLU is enabled, we should disable SmartSpeed */
3349 ret_val = phy->ops.read_reg(hw,
3350 IGP01E1000_PHY_PORT_CONFIG,
3355 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
3356 ret_val = phy->ops.write_reg(hw,
3357 IGP01E1000_PHY_PORT_CONFIG,
3365 * e1000_valid_nvm_bank_detect_ich8lan - finds out the valid bank 0 or 1
3366 * @hw: pointer to the HW structure
3367 * @bank: pointer to the variable that returns the active bank
3369 * Reads signature byte from the NVM using the flash access registers.
3370 * Word 0x13 bits 15:14 = 10b indicate a valid signature for that bank.
3372 STATIC s32 e1000_valid_nvm_bank_detect_ich8lan(struct e1000_hw *hw, u32 *bank)
3375 struct e1000_nvm_info *nvm = &hw->nvm;
3376 u32 bank1_offset = nvm->flash_bank_size * sizeof(u16);
3377 u32 act_offset = E1000_ICH_NVM_SIG_WORD * 2 + 1;
3382 DEBUGFUNC("e1000_valid_nvm_bank_detect_ich8lan");
3384 switch (hw->mac.type) {
3387 bank1_offset = nvm->flash_bank_size;
3388 act_offset = E1000_ICH_NVM_SIG_WORD;
3390 /* set bank to 0 in case flash read fails */
3394 ret_val = e1000_read_flash_dword_ich8lan(hw, act_offset,
3398 sig_byte = (u8)((nvm_dword & 0xFF00) >> 8);
3399 if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
3400 E1000_ICH_NVM_SIG_VALUE) {
3402 return E1000_SUCCESS;
3406 ret_val = e1000_read_flash_dword_ich8lan(hw, act_offset +
3411 sig_byte = (u8)((nvm_dword & 0xFF00) >> 8);
3412 if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
3413 E1000_ICH_NVM_SIG_VALUE) {
3415 return E1000_SUCCESS;
3418 DEBUGOUT("ERROR: No valid NVM bank present\n");
3419 return -E1000_ERR_NVM;
3422 eecd = E1000_READ_REG(hw, E1000_EECD);
3423 if ((eecd & E1000_EECD_SEC1VAL_VALID_MASK) ==
3424 E1000_EECD_SEC1VAL_VALID_MASK) {
3425 if (eecd & E1000_EECD_SEC1VAL)
3430 return E1000_SUCCESS;
3432 DEBUGOUT("Unable to determine valid NVM bank via EEC - reading flash signature\n");
3435 /* set bank to 0 in case flash read fails */
3439 ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset,
3443 if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
3444 E1000_ICH_NVM_SIG_VALUE) {
3446 return E1000_SUCCESS;
3450 ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset +
3455 if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
3456 E1000_ICH_NVM_SIG_VALUE) {
3458 return E1000_SUCCESS;
3461 DEBUGOUT("ERROR: No valid NVM bank present\n");
3462 return -E1000_ERR_NVM;
3467 * e1000_read_nvm_spt - NVM access for SPT
3468 * @hw: pointer to the HW structure
3469 * @offset: The offset (in bytes) of the word(s) to read.
3470 * @words: Size of data to read in words.
3471 * @data: pointer to the word(s) to read at offset.
3473 * Reads a word(s) from the NVM
3475 STATIC s32 e1000_read_nvm_spt(struct e1000_hw *hw, u16 offset, u16 words,
3478 struct e1000_nvm_info *nvm = &hw->nvm;
3479 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
3481 s32 ret_val = E1000_SUCCESS;
3487 DEBUGFUNC("e1000_read_nvm_spt");
3489 if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
3491 DEBUGOUT("nvm parameter(s) out of bounds\n");
3492 ret_val = -E1000_ERR_NVM;
3496 nvm->ops.acquire(hw);
3498 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
3499 if (ret_val != E1000_SUCCESS) {
3500 DEBUGOUT("Could not detect valid bank, assuming bank 0\n");
3504 act_offset = (bank) ? nvm->flash_bank_size : 0;
3505 act_offset += offset;
3507 ret_val = E1000_SUCCESS;
3509 for (i = 0; i < words; i += 2) {
3510 if (words - i == 1) {
3511 if (dev_spec->shadow_ram[offset+i].modified) {
3512 data[i] = dev_spec->shadow_ram[offset+i].value;
3514 offset_to_read = act_offset + i -
3515 ((act_offset + i) % 2);
3517 e1000_read_flash_dword_ich8lan(hw,
3522 if ((act_offset + i) % 2 == 0)
3523 data[i] = (u16)(dword & 0xFFFF);
3525 data[i] = (u16)((dword >> 16) & 0xFFFF);
3528 offset_to_read = act_offset + i;
3529 if (!(dev_spec->shadow_ram[offset+i].modified) ||
3530 !(dev_spec->shadow_ram[offset+i+1].modified)) {
3532 e1000_read_flash_dword_ich8lan(hw,
3538 if (dev_spec->shadow_ram[offset+i].modified)
3539 data[i] = dev_spec->shadow_ram[offset+i].value;
3541 data[i] = (u16) (dword & 0xFFFF);
3542 if (dev_spec->shadow_ram[offset+i].modified)
3544 dev_spec->shadow_ram[offset+i+1].value;
3546 data[i+1] = (u16) (dword >> 16 & 0xFFFF);
3550 nvm->ops.release(hw);
3554 DEBUGOUT1("NVM read error: %d\n", ret_val);
3560 * e1000_read_nvm_ich8lan - Read word(s) from the NVM
3561 * @hw: pointer to the HW structure
3562 * @offset: The offset (in bytes) of the word(s) to read.
3563 * @words: Size of data to read in words
3564 * @data: Pointer to the word(s) to read at offset.
3566 * Reads a word(s) from the NVM using the flash access registers.
3568 STATIC s32 e1000_read_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
3571 struct e1000_nvm_info *nvm = &hw->nvm;
3572 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
3574 s32 ret_val = E1000_SUCCESS;
3578 DEBUGFUNC("e1000_read_nvm_ich8lan");
3580 if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
3582 DEBUGOUT("nvm parameter(s) out of bounds\n");
3583 ret_val = -E1000_ERR_NVM;
3587 nvm->ops.acquire(hw);
3589 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
3590 if (ret_val != E1000_SUCCESS) {
3591 DEBUGOUT("Could not detect valid bank, assuming bank 0\n");
3595 act_offset = (bank) ? nvm->flash_bank_size : 0;
3596 act_offset += offset;
3598 ret_val = E1000_SUCCESS;
3599 for (i = 0; i < words; i++) {
3600 if (dev_spec->shadow_ram[offset+i].modified) {
3601 data[i] = dev_spec->shadow_ram[offset+i].value;
3603 ret_val = e1000_read_flash_word_ich8lan(hw,
3612 nvm->ops.release(hw);
3616 DEBUGOUT1("NVM read error: %d\n", ret_val);
3622 * e1000_flash_cycle_init_ich8lan - Initialize flash
3623 * @hw: pointer to the HW structure
3625 * This function does initial flash setup so that a new read/write/erase cycle
3628 STATIC s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw)
3630 union ich8_hws_flash_status hsfsts;
3631 s32 ret_val = -E1000_ERR_NVM;
3633 DEBUGFUNC("e1000_flash_cycle_init_ich8lan");
3635 hsfsts.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
3637 /* Check if the flash descriptor is valid */
3638 if (!hsfsts.hsf_status.fldesvalid) {
3639 DEBUGOUT("Flash descriptor invalid. SW Sequencing must be used.\n");
3640 return -E1000_ERR_NVM;
3643 /* Clear FCERR and DAEL in hw status by writing 1 */
3644 hsfsts.hsf_status.flcerr = 1;
3645 hsfsts.hsf_status.dael = 1;
3646 if (hw->mac.type >= e1000_pch_spt)
3647 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_HSFSTS,
3648 hsfsts.regval & 0xFFFF);
3650 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFSTS, hsfsts.regval);
3652 /* Either we should have a hardware SPI cycle in progress
3653 * bit to check against, in order to start a new cycle or
3654 * FDONE bit should be changed in the hardware so that it
3655 * is 1 after hardware reset, which can then be used as an
3656 * indication whether a cycle is in progress or has been
3660 if (!hsfsts.hsf_status.flcinprog) {
3661 /* There is no cycle running at present,
3662 * so we can start a cycle.
3663 * Begin by setting Flash Cycle Done.
3665 hsfsts.hsf_status.flcdone = 1;
3666 if (hw->mac.type >= e1000_pch_spt)
3667 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_HSFSTS,
3668 hsfsts.regval & 0xFFFF);
3670 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFSTS,
3672 ret_val = E1000_SUCCESS;
3676 /* Otherwise poll for sometime so the current
3677 * cycle has a chance to end before giving up.
3679 for (i = 0; i < ICH_FLASH_READ_COMMAND_TIMEOUT; i++) {
3680 hsfsts.regval = E1000_READ_FLASH_REG16(hw,
3682 if (!hsfsts.hsf_status.flcinprog) {
3683 ret_val = E1000_SUCCESS;
3688 if (ret_val == E1000_SUCCESS) {
3689 /* Successful in waiting for previous cycle to timeout,
3690 * now set the Flash Cycle Done.
3692 hsfsts.hsf_status.flcdone = 1;
3693 if (hw->mac.type >= e1000_pch_spt)
3694 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_HSFSTS,
3695 hsfsts.regval & 0xFFFF);
3697 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFSTS,
3700 DEBUGOUT("Flash controller busy, cannot get access\n");
3708 * e1000_flash_cycle_ich8lan - Starts flash cycle (read/write/erase)
3709 * @hw: pointer to the HW structure
3710 * @timeout: maximum time to wait for completion
3712 * This function starts a flash cycle and waits for its completion.
3714 STATIC s32 e1000_flash_cycle_ich8lan(struct e1000_hw *hw, u32 timeout)
3716 union ich8_hws_flash_ctrl hsflctl;
3717 union ich8_hws_flash_status hsfsts;
3720 DEBUGFUNC("e1000_flash_cycle_ich8lan");
3722 /* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */
3723 if (hw->mac.type >= e1000_pch_spt)
3724 hsflctl.regval = E1000_READ_FLASH_REG(hw, ICH_FLASH_HSFSTS)>>16;
3726 hsflctl.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFCTL);
3727 hsflctl.hsf_ctrl.flcgo = 1;
3729 if (hw->mac.type >= e1000_pch_spt)
3730 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_HSFSTS,
3731 hsflctl.regval << 16);
3733 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFCTL, hsflctl.regval);
3735 /* wait till FDONE bit is set to 1 */
3737 hsfsts.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
3738 if (hsfsts.hsf_status.flcdone)
3741 } while (i++ < timeout);
3743 if (hsfsts.hsf_status.flcdone && !hsfsts.hsf_status.flcerr)
3744 return E1000_SUCCESS;
3746 return -E1000_ERR_NVM;
3750 * e1000_read_flash_dword_ich8lan - Read dword from flash
3751 * @hw: pointer to the HW structure
3752 * @offset: offset to data location
3753 * @data: pointer to the location for storing the data
3755 * Reads the flash dword at offset into data. Offset is converted
3756 * to bytes before read.
3758 STATIC s32 e1000_read_flash_dword_ich8lan(struct e1000_hw *hw, u32 offset,
3761 DEBUGFUNC("e1000_read_flash_dword_ich8lan");
3764 return -E1000_ERR_NVM;
3766 /* Must convert word offset into bytes. */
3769 return e1000_read_flash_data32_ich8lan(hw, offset, data);
3773 * e1000_read_flash_word_ich8lan - Read word from flash
3774 * @hw: pointer to the HW structure
3775 * @offset: offset to data location
3776 * @data: pointer to the location for storing the data
3778 * Reads the flash word at offset into data. Offset is converted
3779 * to bytes before read.
3781 STATIC s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset,
3784 DEBUGFUNC("e1000_read_flash_word_ich8lan");
3787 return -E1000_ERR_NVM;
3789 /* Must convert offset into bytes. */
3792 return e1000_read_flash_data_ich8lan(hw, offset, 2, data);
3796 * e1000_read_flash_byte_ich8lan - Read byte from flash
3797 * @hw: pointer to the HW structure
3798 * @offset: The offset of the byte to read.
3799 * @data: Pointer to a byte to store the value read.
3801 * Reads a single byte from the NVM using the flash access registers.
3803 STATIC s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
3809 /* In SPT, only 32 bits access is supported,
3810 * so this function should not be called.
3812 if (hw->mac.type >= e1000_pch_spt)
3813 return -E1000_ERR_NVM;
3815 ret_val = e1000_read_flash_data_ich8lan(hw, offset, 1, &word);
3822 return E1000_SUCCESS;
3826 * e1000_read_flash_data_ich8lan - Read byte or word from NVM
3827 * @hw: pointer to the HW structure
3828 * @offset: The offset (in bytes) of the byte or word to read.
3829 * @size: Size of data to read, 1=byte 2=word
3830 * @data: Pointer to the word to store the value read.
3832 * Reads a byte or word from the NVM using the flash access registers.
3834 STATIC s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
3837 union ich8_hws_flash_status hsfsts;
3838 union ich8_hws_flash_ctrl hsflctl;
3839 u32 flash_linear_addr;
3841 s32 ret_val = -E1000_ERR_NVM;
3844 DEBUGFUNC("e1000_read_flash_data_ich8lan");
3846 if (size < 1 || size > 2 || offset > ICH_FLASH_LINEAR_ADDR_MASK)
3847 return -E1000_ERR_NVM;
3848 flash_linear_addr = ((ICH_FLASH_LINEAR_ADDR_MASK & offset) +
3849 hw->nvm.flash_base_addr);
3854 ret_val = e1000_flash_cycle_init_ich8lan(hw);
3855 if (ret_val != E1000_SUCCESS)
3857 hsflctl.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFCTL);
3859 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
3860 hsflctl.hsf_ctrl.fldbcount = size - 1;
3861 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_READ;
3862 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFCTL, hsflctl.regval);
3863 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FADDR, flash_linear_addr);
3865 ret_val = e1000_flash_cycle_ich8lan(hw,
3866 ICH_FLASH_READ_COMMAND_TIMEOUT);
3868 /* Check if FCERR is set to 1, if set to 1, clear it
3869 * and try the whole sequence a few more times, else
3870 * read in (shift in) the Flash Data0, the order is
3871 * least significant byte first msb to lsb
3873 if (ret_val == E1000_SUCCESS) {
3874 flash_data = E1000_READ_FLASH_REG(hw, ICH_FLASH_FDATA0);
3876 *data = (u8)(flash_data & 0x000000FF);
3878 *data = (u16)(flash_data & 0x0000FFFF);
3881 /* If we've gotten here, then things are probably
3882 * completely hosed, but if the error condition is
3883 * detected, it won't hurt to give it another try...
3884 * ICH_FLASH_CYCLE_REPEAT_COUNT times.
3886 hsfsts.regval = E1000_READ_FLASH_REG16(hw,
3888 if (hsfsts.hsf_status.flcerr) {
3889 /* Repeat for some time before giving up. */
3891 } else if (!hsfsts.hsf_status.flcdone) {
3892 DEBUGOUT("Timeout error - flash cycle did not complete.\n");
3896 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
3902 * e1000_read_flash_data32_ich8lan - Read dword from NVM
3903 * @hw: pointer to the HW structure
3904 * @offset: The offset (in bytes) of the dword to read.
3905 * @data: Pointer to the dword to store the value read.
3907 * Reads a byte or word from the NVM using the flash access registers.
3909 STATIC s32 e1000_read_flash_data32_ich8lan(struct e1000_hw *hw, u32 offset,
3912 union ich8_hws_flash_status hsfsts;
3913 union ich8_hws_flash_ctrl hsflctl;
3914 u32 flash_linear_addr;
3915 s32 ret_val = -E1000_ERR_NVM;
3918 DEBUGFUNC("e1000_read_flash_data_ich8lan");
3920 if (offset > ICH_FLASH_LINEAR_ADDR_MASK ||
3921 hw->mac.type < e1000_pch_spt)
3922 return -E1000_ERR_NVM;
3923 flash_linear_addr = ((ICH_FLASH_LINEAR_ADDR_MASK & offset) +
3924 hw->nvm.flash_base_addr);
3929 ret_val = e1000_flash_cycle_init_ich8lan(hw);
3930 if (ret_val != E1000_SUCCESS)
3932 /* In SPT, This register is in Lan memory space, not flash.
3933 * Therefore, only 32 bit access is supported
3935 hsflctl.regval = E1000_READ_FLASH_REG(hw, ICH_FLASH_HSFSTS)>>16;
3937 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
3938 hsflctl.hsf_ctrl.fldbcount = sizeof(u32) - 1;
3939 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_READ;
3940 /* In SPT, This register is in Lan memory space, not flash.
3941 * Therefore, only 32 bit access is supported
3943 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_HSFSTS,
3944 (u32)hsflctl.regval << 16);
3945 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FADDR, flash_linear_addr);
3947 ret_val = e1000_flash_cycle_ich8lan(hw,
3948 ICH_FLASH_READ_COMMAND_TIMEOUT);
3950 /* Check if FCERR is set to 1, if set to 1, clear it
3951 * and try the whole sequence a few more times, else
3952 * read in (shift in) the Flash Data0, the order is
3953 * least significant byte first msb to lsb
3955 if (ret_val == E1000_SUCCESS) {
3956 *data = E1000_READ_FLASH_REG(hw, ICH_FLASH_FDATA0);
3959 /* If we've gotten here, then things are probably
3960 * completely hosed, but if the error condition is
3961 * detected, it won't hurt to give it another try...
3962 * ICH_FLASH_CYCLE_REPEAT_COUNT times.
3964 hsfsts.regval = E1000_READ_FLASH_REG16(hw,
3966 if (hsfsts.hsf_status.flcerr) {
3967 /* Repeat for some time before giving up. */
3969 } else if (!hsfsts.hsf_status.flcdone) {
3970 DEBUGOUT("Timeout error - flash cycle did not complete.\n");
3974 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
3980 * e1000_write_nvm_ich8lan - Write word(s) to the NVM
3981 * @hw: pointer to the HW structure
3982 * @offset: The offset (in bytes) of the word(s) to write.
3983 * @words: Size of data to write in words
3984 * @data: Pointer to the word(s) to write at offset.
3986 * Writes a byte or word to the NVM using the flash access registers.
3988 STATIC s32 e1000_write_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
3991 struct e1000_nvm_info *nvm = &hw->nvm;
3992 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
3995 DEBUGFUNC("e1000_write_nvm_ich8lan");
3997 if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
3999 DEBUGOUT("nvm parameter(s) out of bounds\n");
4000 return -E1000_ERR_NVM;
4003 nvm->ops.acquire(hw);
4005 for (i = 0; i < words; i++) {
4006 dev_spec->shadow_ram[offset+i].modified = true;
4007 dev_spec->shadow_ram[offset+i].value = data[i];
4010 nvm->ops.release(hw);
4012 return E1000_SUCCESS;
4016 * e1000_update_nvm_checksum_spt - Update the checksum for NVM
4017 * @hw: pointer to the HW structure
4019 * The NVM checksum is updated by calling the generic update_nvm_checksum,
4020 * which writes the checksum to the shadow ram. The changes in the shadow
4021 * ram are then committed to the EEPROM by processing each bank at a time
4022 * checking for the modified bit and writing only the pending changes.
4023 * After a successful commit, the shadow ram is cleared and is ready for
4026 STATIC s32 e1000_update_nvm_checksum_spt(struct e1000_hw *hw)
4028 struct e1000_nvm_info *nvm = &hw->nvm;
4029 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
4030 u32 i, act_offset, new_bank_offset, old_bank_offset, bank;
4034 DEBUGFUNC("e1000_update_nvm_checksum_spt");
4036 ret_val = e1000_update_nvm_checksum_generic(hw);
4040 if (nvm->type != e1000_nvm_flash_sw)
4043 nvm->ops.acquire(hw);
4045 /* We're writing to the opposite bank so if we're on bank 1,
4046 * write to bank 0 etc. We also need to erase the segment that
4047 * is going to be written
4049 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
4050 if (ret_val != E1000_SUCCESS) {
4051 DEBUGOUT("Could not detect valid bank, assuming bank 0\n");
4056 new_bank_offset = nvm->flash_bank_size;
4057 old_bank_offset = 0;
4058 ret_val = e1000_erase_flash_bank_ich8lan(hw, 1);
4062 old_bank_offset = nvm->flash_bank_size;
4063 new_bank_offset = 0;
4064 ret_val = e1000_erase_flash_bank_ich8lan(hw, 0);
4068 for (i = 0; i < E1000_SHADOW_RAM_WORDS; i += 2) {
4069 /* Determine whether to write the value stored
4070 * in the other NVM bank or a modified value stored
4073 ret_val = e1000_read_flash_dword_ich8lan(hw,
4074 i + old_bank_offset,
4077 if (dev_spec->shadow_ram[i].modified) {
4078 dword &= 0xffff0000;
4079 dword |= (dev_spec->shadow_ram[i].value & 0xffff);
4081 if (dev_spec->shadow_ram[i + 1].modified) {
4082 dword &= 0x0000ffff;
4083 dword |= ((dev_spec->shadow_ram[i + 1].value & 0xffff)
4089 /* If the word is 0x13, then make sure the signature bits
4090 * (15:14) are 11b until the commit has completed.
4091 * This will allow us to write 10b which indicates the
4092 * signature is valid. We want to do this after the write
4093 * has completed so that we don't mark the segment valid
4094 * while the write is still in progress
4096 if (i == E1000_ICH_NVM_SIG_WORD - 1)
4097 dword |= E1000_ICH_NVM_SIG_MASK << 16;
4099 /* Convert offset to bytes. */
4100 act_offset = (i + new_bank_offset) << 1;
4104 /* Write the data to the new bank. Offset in words*/
4105 act_offset = i + new_bank_offset;
4106 ret_val = e1000_retry_write_flash_dword_ich8lan(hw, act_offset,
4112 /* Don't bother writing the segment valid bits if sector
4113 * programming failed.
4116 DEBUGOUT("Flash commit failed.\n");
4120 /* Finally validate the new segment by setting bit 15:14
4121 * to 10b in word 0x13 , this can be done without an
4122 * erase as well since these bits are 11 to start with
4123 * and we need to change bit 14 to 0b
4125 act_offset = new_bank_offset + E1000_ICH_NVM_SIG_WORD;
4127 /*offset in words but we read dword*/
4129 ret_val = e1000_read_flash_dword_ich8lan(hw, act_offset, &dword);
4134 dword &= 0xBFFFFFFF;
4135 ret_val = e1000_retry_write_flash_dword_ich8lan(hw, act_offset, dword);
4140 /* And invalidate the previously valid segment by setting
4141 * its signature word (0x13) high_byte to 0b. This can be
4142 * done without an erase because flash erase sets all bits
4143 * to 1's. We can write 1's to 0's without an erase
4145 act_offset = (old_bank_offset + E1000_ICH_NVM_SIG_WORD) * 2 + 1;
4147 /* offset in words but we read dword*/
4148 act_offset = old_bank_offset + E1000_ICH_NVM_SIG_WORD - 1;
4149 ret_val = e1000_read_flash_dword_ich8lan(hw, act_offset, &dword);
4154 dword &= 0x00FFFFFF;
4155 ret_val = e1000_retry_write_flash_dword_ich8lan(hw, act_offset, dword);
4160 /* Great! Everything worked, we can now clear the cached entries. */
4161 for (i = 0; i < E1000_SHADOW_RAM_WORDS; i++) {
4162 dev_spec->shadow_ram[i].modified = false;
4163 dev_spec->shadow_ram[i].value = 0xFFFF;
4167 nvm->ops.release(hw);
4169 /* Reload the EEPROM, or else modifications will not appear
4170 * until after the next adapter reset.
4173 nvm->ops.reload(hw);
4179 DEBUGOUT1("NVM update error: %d\n", ret_val);
4185 * e1000_update_nvm_checksum_ich8lan - Update the checksum for NVM
4186 * @hw: pointer to the HW structure
4188 * The NVM checksum is updated by calling the generic update_nvm_checksum,
4189 * which writes the checksum to the shadow ram. The changes in the shadow
4190 * ram are then committed to the EEPROM by processing each bank at a time
4191 * checking for the modified bit and writing only the pending changes.
4192 * After a successful commit, the shadow ram is cleared and is ready for
4195 STATIC s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw)
4197 struct e1000_nvm_info *nvm = &hw->nvm;
4198 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
4199 u32 i, act_offset, new_bank_offset, old_bank_offset, bank;
4203 DEBUGFUNC("e1000_update_nvm_checksum_ich8lan");
4205 ret_val = e1000_update_nvm_checksum_generic(hw);
4209 if (nvm->type != e1000_nvm_flash_sw)
4212 nvm->ops.acquire(hw);
4214 /* We're writing to the opposite bank so if we're on bank 1,
4215 * write to bank 0 etc. We also need to erase the segment that
4216 * is going to be written
4218 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
4219 if (ret_val != E1000_SUCCESS) {
4220 DEBUGOUT("Could not detect valid bank, assuming bank 0\n");
4225 new_bank_offset = nvm->flash_bank_size;
4226 old_bank_offset = 0;
4227 ret_val = e1000_erase_flash_bank_ich8lan(hw, 1);
4231 old_bank_offset = nvm->flash_bank_size;
4232 new_bank_offset = 0;
4233 ret_val = e1000_erase_flash_bank_ich8lan(hw, 0);
4237 for (i = 0; i < E1000_SHADOW_RAM_WORDS; i++) {
4238 if (dev_spec->shadow_ram[i].modified) {
4239 data = dev_spec->shadow_ram[i].value;
4241 ret_val = e1000_read_flash_word_ich8lan(hw, i +
4247 /* If the word is 0x13, then make sure the signature bits
4248 * (15:14) are 11b until the commit has completed.
4249 * This will allow us to write 10b which indicates the
4250 * signature is valid. We want to do this after the write
4251 * has completed so that we don't mark the segment valid
4252 * while the write is still in progress
4254 if (i == E1000_ICH_NVM_SIG_WORD)
4255 data |= E1000_ICH_NVM_SIG_MASK;
4257 /* Convert offset to bytes. */
4258 act_offset = (i + new_bank_offset) << 1;
4262 /* Write the bytes to the new bank. */
4263 ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
4270 ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
4277 /* Don't bother writing the segment valid bits if sector
4278 * programming failed.
4281 DEBUGOUT("Flash commit failed.\n");
4285 /* Finally validate the new segment by setting bit 15:14
4286 * to 10b in word 0x13 , this can be done without an
4287 * erase as well since these bits are 11 to start with
4288 * and we need to change bit 14 to 0b
4290 act_offset = new_bank_offset + E1000_ICH_NVM_SIG_WORD;
4291 ret_val = e1000_read_flash_word_ich8lan(hw, act_offset, &data);
4296 ret_val = e1000_retry_write_flash_byte_ich8lan(hw, act_offset * 2 + 1,
4301 /* And invalidate the previously valid segment by setting
4302 * its signature word (0x13) high_byte to 0b. This can be
4303 * done without an erase because flash erase sets all bits
4304 * to 1's. We can write 1's to 0's without an erase
4306 act_offset = (old_bank_offset + E1000_ICH_NVM_SIG_WORD) * 2 + 1;
4308 ret_val = e1000_retry_write_flash_byte_ich8lan(hw, act_offset, 0);
4313 /* Great! Everything worked, we can now clear the cached entries. */
4314 for (i = 0; i < E1000_SHADOW_RAM_WORDS; i++) {
4315 dev_spec->shadow_ram[i].modified = false;
4316 dev_spec->shadow_ram[i].value = 0xFFFF;
4320 nvm->ops.release(hw);
4322 /* Reload the EEPROM, or else modifications will not appear
4323 * until after the next adapter reset.
4326 nvm->ops.reload(hw);
4332 DEBUGOUT1("NVM update error: %d\n", ret_val);
4338 * e1000_validate_nvm_checksum_ich8lan - Validate EEPROM checksum
4339 * @hw: pointer to the HW structure
4341 * Check to see if checksum needs to be fixed by reading bit 6 in word 0x19.
4342 * If the bit is 0, that the EEPROM had been modified, but the checksum was not
4343 * calculated, in which case we need to calculate the checksum and set bit 6.
4345 STATIC s32 e1000_validate_nvm_checksum_ich8lan(struct e1000_hw *hw)
4350 u16 valid_csum_mask;
4352 DEBUGFUNC("e1000_validate_nvm_checksum_ich8lan");
4354 /* Read NVM and check Invalid Image CSUM bit. If this bit is 0,
4355 * the checksum needs to be fixed. This bit is an indication that
4356 * the NVM was prepared by OEM software and did not calculate
4357 * the checksum...a likely scenario.
4359 switch (hw->mac.type) {
4364 valid_csum_mask = NVM_COMPAT_VALID_CSUM;
4367 word = NVM_FUTURE_INIT_WORD1;
4368 valid_csum_mask = NVM_FUTURE_INIT_WORD1_VALID_CSUM;
4372 ret_val = hw->nvm.ops.read(hw, word, 1, &data);
4376 if (!(data & valid_csum_mask)) {
4377 data |= valid_csum_mask;
4378 ret_val = hw->nvm.ops.write(hw, word, 1, &data);
4381 ret_val = hw->nvm.ops.update(hw);
4386 return e1000_validate_nvm_checksum_generic(hw);
4390 * e1000_write_flash_data_ich8lan - Writes bytes to the NVM
4391 * @hw: pointer to the HW structure
4392 * @offset: The offset (in bytes) of the byte/word to read.
4393 * @size: Size of data to read, 1=byte 2=word
4394 * @data: The byte(s) to write to the NVM.
4396 * Writes one/two bytes to the NVM using the flash access registers.
4398 STATIC s32 e1000_write_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
4401 union ich8_hws_flash_status hsfsts;
4402 union ich8_hws_flash_ctrl hsflctl;
4403 u32 flash_linear_addr;
4408 DEBUGFUNC("e1000_write_ich8_data");
4410 if (hw->mac.type >= e1000_pch_spt) {
4411 if (size != 4 || offset > ICH_FLASH_LINEAR_ADDR_MASK)
4412 return -E1000_ERR_NVM;
4414 if (size < 1 || size > 2 || offset > ICH_FLASH_LINEAR_ADDR_MASK)
4415 return -E1000_ERR_NVM;
4418 flash_linear_addr = ((ICH_FLASH_LINEAR_ADDR_MASK & offset) +
4419 hw->nvm.flash_base_addr);
4424 ret_val = e1000_flash_cycle_init_ich8lan(hw);
4425 if (ret_val != E1000_SUCCESS)
4427 /* In SPT, This register is in Lan memory space, not
4428 * flash. Therefore, only 32 bit access is supported
4430 if (hw->mac.type >= e1000_pch_spt)
4432 E1000_READ_FLASH_REG(hw, ICH_FLASH_HSFSTS)>>16;
4435 E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFCTL);
4437 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
4438 hsflctl.hsf_ctrl.fldbcount = size - 1;
4439 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_WRITE;
4440 /* In SPT, This register is in Lan memory space,
4441 * not flash. Therefore, only 32 bit access is
4444 if (hw->mac.type >= e1000_pch_spt)
4445 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_HSFSTS,
4446 hsflctl.regval << 16);
4448 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFCTL,
4451 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FADDR, flash_linear_addr);
4454 flash_data = (u32)data & 0x00FF;
4456 flash_data = (u32)data;
4458 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FDATA0, flash_data);
4460 /* check if FCERR is set to 1 , if set to 1, clear it
4461 * and try the whole sequence a few more times else done
4464 e1000_flash_cycle_ich8lan(hw,
4465 ICH_FLASH_WRITE_COMMAND_TIMEOUT);
4466 if (ret_val == E1000_SUCCESS)
4469 /* If we're here, then things are most likely
4470 * completely hosed, but if the error condition
4471 * is detected, it won't hurt to give it another
4472 * try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
4474 hsfsts.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
4475 if (hsfsts.hsf_status.flcerr)
4476 /* Repeat for some time before giving up. */
4478 if (!hsfsts.hsf_status.flcdone) {
4479 DEBUGOUT("Timeout error - flash cycle did not complete.\n");
4482 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
4488 * e1000_write_flash_data32_ich8lan - Writes 4 bytes to the NVM
4489 * @hw: pointer to the HW structure
4490 * @offset: The offset (in bytes) of the dwords to read.
4491 * @data: The 4 bytes to write to the NVM.
4493 * Writes one/two/four bytes to the NVM using the flash access registers.
4495 STATIC s32 e1000_write_flash_data32_ich8lan(struct e1000_hw *hw, u32 offset,
4498 union ich8_hws_flash_status hsfsts;
4499 union ich8_hws_flash_ctrl hsflctl;
4500 u32 flash_linear_addr;
4504 DEBUGFUNC("e1000_write_flash_data32_ich8lan");
4506 if (hw->mac.type >= e1000_pch_spt) {
4507 if (offset > ICH_FLASH_LINEAR_ADDR_MASK)
4508 return -E1000_ERR_NVM;
4510 flash_linear_addr = ((ICH_FLASH_LINEAR_ADDR_MASK & offset) +
4511 hw->nvm.flash_base_addr);
4515 ret_val = e1000_flash_cycle_init_ich8lan(hw);
4516 if (ret_val != E1000_SUCCESS)
4519 /* In SPT, This register is in Lan memory space, not
4520 * flash. Therefore, only 32 bit access is supported
4522 if (hw->mac.type >= e1000_pch_spt)
4523 hsflctl.regval = E1000_READ_FLASH_REG(hw,
4527 hsflctl.regval = E1000_READ_FLASH_REG16(hw,
4530 hsflctl.hsf_ctrl.fldbcount = sizeof(u32) - 1;
4531 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_WRITE;
4533 /* In SPT, This register is in Lan memory space,
4534 * not flash. Therefore, only 32 bit access is
4537 if (hw->mac.type >= e1000_pch_spt)
4538 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_HSFSTS,
4539 hsflctl.regval << 16);
4541 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFCTL,
4544 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FADDR, flash_linear_addr);
4546 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FDATA0, data);
4548 /* check if FCERR is set to 1 , if set to 1, clear it
4549 * and try the whole sequence a few more times else done
4551 ret_val = e1000_flash_cycle_ich8lan(hw,
4552 ICH_FLASH_WRITE_COMMAND_TIMEOUT);
4554 if (ret_val == E1000_SUCCESS)
4557 /* If we're here, then things are most likely
4558 * completely hosed, but if the error condition
4559 * is detected, it won't hurt to give it another
4560 * try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
4562 hsfsts.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
4564 if (hsfsts.hsf_status.flcerr)
4565 /* Repeat for some time before giving up. */
4567 if (!hsfsts.hsf_status.flcdone) {
4568 DEBUGOUT("Timeout error - flash cycle did not complete.\n");
4571 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
4577 * e1000_write_flash_byte_ich8lan - Write a single byte to NVM
4578 * @hw: pointer to the HW structure
4579 * @offset: The index of the byte to read.
4580 * @data: The byte to write to the NVM.
4582 * Writes a single byte to the NVM using the flash access registers.
4584 STATIC s32 e1000_write_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
4587 u16 word = (u16)data;
4589 DEBUGFUNC("e1000_write_flash_byte_ich8lan");
4591 return e1000_write_flash_data_ich8lan(hw, offset, 1, word);
4595 * e1000_retry_write_flash_dword_ich8lan - Writes a dword to NVM
4596 * @hw: pointer to the HW structure
4597 * @offset: The offset of the word to write.
4598 * @dword: The dword to write to the NVM.
4600 * Writes a single dword to the NVM using the flash access registers.
4601 * Goes through a retry algorithm before giving up.
4603 STATIC s32 e1000_retry_write_flash_dword_ich8lan(struct e1000_hw *hw,
4604 u32 offset, u32 dword)
4607 u16 program_retries;
4609 DEBUGFUNC("e1000_retry_write_flash_dword_ich8lan");
4611 /* Must convert word offset into bytes. */
4614 ret_val = e1000_write_flash_data32_ich8lan(hw, offset, dword);
4618 for (program_retries = 0; program_retries < 100; program_retries++) {
4619 DEBUGOUT2("Retrying Byte %8.8X at offset %u\n", dword, offset);
4621 ret_val = e1000_write_flash_data32_ich8lan(hw, offset, dword);
4622 if (ret_val == E1000_SUCCESS)
4625 if (program_retries == 100)
4626 return -E1000_ERR_NVM;
4628 return E1000_SUCCESS;
4632 * e1000_retry_write_flash_byte_ich8lan - Writes a single byte to NVM
4633 * @hw: pointer to the HW structure
4634 * @offset: The offset of the byte to write.
4635 * @byte: The byte to write to the NVM.
4637 * Writes a single byte to the NVM using the flash access registers.
4638 * Goes through a retry algorithm before giving up.
4640 STATIC s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw,
4641 u32 offset, u8 byte)
4644 u16 program_retries;
4646 DEBUGFUNC("e1000_retry_write_flash_byte_ich8lan");
4648 ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
4652 for (program_retries = 0; program_retries < 100; program_retries++) {
4653 DEBUGOUT2("Retrying Byte %2.2X at offset %u\n", byte, offset);
4655 ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
4656 if (ret_val == E1000_SUCCESS)
4659 if (program_retries == 100)
4660 return -E1000_ERR_NVM;
4662 return E1000_SUCCESS;
4666 * e1000_erase_flash_bank_ich8lan - Erase a bank (4k) from NVM
4667 * @hw: pointer to the HW structure
4668 * @bank: 0 for first bank, 1 for second bank, etc.
4670 * Erases the bank specified. Each bank is a 4k block. Banks are 0 based.
4671 * bank N is 4096 * N + flash_reg_addr.
4673 STATIC s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank)
4675 struct e1000_nvm_info *nvm = &hw->nvm;
4676 union ich8_hws_flash_status hsfsts;
4677 union ich8_hws_flash_ctrl hsflctl;
4678 u32 flash_linear_addr;
4679 /* bank size is in 16bit words - adjust to bytes */
4680 u32 flash_bank_size = nvm->flash_bank_size * 2;
4683 s32 j, iteration, sector_size;
4685 DEBUGFUNC("e1000_erase_flash_bank_ich8lan");
4687 hsfsts.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
4689 /* Determine HW Sector size: Read BERASE bits of hw flash status
4691 * 00: The Hw sector is 256 bytes, hence we need to erase 16
4692 * consecutive sectors. The start index for the nth Hw sector
4693 * can be calculated as = bank * 4096 + n * 256
4694 * 01: The Hw sector is 4K bytes, hence we need to erase 1 sector.
4695 * The start index for the nth Hw sector can be calculated
4697 * 10: The Hw sector is 8K bytes, nth sector = bank * 8192
4698 * (ich9 only, otherwise error condition)
4699 * 11: The Hw sector is 64K bytes, nth sector = bank * 65536
4701 switch (hsfsts.hsf_status.berasesz) {
4703 /* Hw sector size 256 */
4704 sector_size = ICH_FLASH_SEG_SIZE_256;
4705 iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_256;
4708 sector_size = ICH_FLASH_SEG_SIZE_4K;
4712 sector_size = ICH_FLASH_SEG_SIZE_8K;
4716 sector_size = ICH_FLASH_SEG_SIZE_64K;
4720 return -E1000_ERR_NVM;
4723 /* Start with the base address, then add the sector offset. */
4724 flash_linear_addr = hw->nvm.flash_base_addr;
4725 flash_linear_addr += (bank) ? flash_bank_size : 0;
4727 for (j = 0; j < iteration; j++) {
4729 u32 timeout = ICH_FLASH_ERASE_COMMAND_TIMEOUT;
4732 ret_val = e1000_flash_cycle_init_ich8lan(hw);
4736 /* Write a value 11 (block Erase) in Flash
4737 * Cycle field in hw flash control
4739 if (hw->mac.type >= e1000_pch_spt)
4741 E1000_READ_FLASH_REG(hw,
4742 ICH_FLASH_HSFSTS)>>16;
4745 E1000_READ_FLASH_REG16(hw,
4748 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_ERASE;
4749 if (hw->mac.type >= e1000_pch_spt)
4750 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_HSFSTS,
4751 hsflctl.regval << 16);
4753 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFCTL,
4756 /* Write the last 24 bits of an index within the
4757 * block into Flash Linear address field in Flash
4760 flash_linear_addr += (j * sector_size);
4761 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FADDR,
4764 ret_val = e1000_flash_cycle_ich8lan(hw, timeout);
4765 if (ret_val == E1000_SUCCESS)
4768 /* Check if FCERR is set to 1. If 1,
4769 * clear it and try the whole sequence
4770 * a few more times else Done
4772 hsfsts.regval = E1000_READ_FLASH_REG16(hw,
4774 if (hsfsts.hsf_status.flcerr)
4775 /* repeat for some time before giving up */
4777 else if (!hsfsts.hsf_status.flcdone)
4779 } while (++count < ICH_FLASH_CYCLE_REPEAT_COUNT);
4782 return E1000_SUCCESS;
4786 * e1000_valid_led_default_ich8lan - Set the default LED settings
4787 * @hw: pointer to the HW structure
4788 * @data: Pointer to the LED settings
4790 * Reads the LED default settings from the NVM to data. If the NVM LED
4791 * settings is all 0's or F's, set the LED default to a valid LED default
4794 STATIC s32 e1000_valid_led_default_ich8lan(struct e1000_hw *hw, u16 *data)
4798 DEBUGFUNC("e1000_valid_led_default_ich8lan");
4800 ret_val = hw->nvm.ops.read(hw, NVM_ID_LED_SETTINGS, 1, data);
4802 DEBUGOUT("NVM Read Error\n");
4806 if (*data == ID_LED_RESERVED_0000 || *data == ID_LED_RESERVED_FFFF)
4807 *data = ID_LED_DEFAULT_ICH8LAN;
4809 return E1000_SUCCESS;
4813 * e1000_id_led_init_pchlan - store LED configurations
4814 * @hw: pointer to the HW structure
4816 * PCH does not control LEDs via the LEDCTL register, rather it uses
4817 * the PHY LED configuration register.
4819 * PCH also does not have an "always on" or "always off" mode which
4820 * complicates the ID feature. Instead of using the "on" mode to indicate
4821 * in ledctl_mode2 the LEDs to use for ID (see e1000_id_led_init_generic()),
4822 * use "link_up" mode. The LEDs will still ID on request if there is no
4823 * link based on logic in e1000_led_[on|off]_pchlan().
4825 STATIC s32 e1000_id_led_init_pchlan(struct e1000_hw *hw)
4827 struct e1000_mac_info *mac = &hw->mac;
4829 const u32 ledctl_on = E1000_LEDCTL_MODE_LINK_UP;
4830 const u32 ledctl_off = E1000_LEDCTL_MODE_LINK_UP | E1000_PHY_LED0_IVRT;
4831 u16 data, i, temp, shift;
4833 DEBUGFUNC("e1000_id_led_init_pchlan");
4835 /* Get default ID LED modes */
4836 ret_val = hw->nvm.ops.valid_led_default(hw, &data);
4840 mac->ledctl_default = E1000_READ_REG(hw, E1000_LEDCTL);
4841 mac->ledctl_mode1 = mac->ledctl_default;
4842 mac->ledctl_mode2 = mac->ledctl_default;
4844 for (i = 0; i < 4; i++) {
4845 temp = (data >> (i << 2)) & E1000_LEDCTL_LED0_MODE_MASK;
4848 case ID_LED_ON1_DEF2:
4849 case ID_LED_ON1_ON2:
4850 case ID_LED_ON1_OFF2:
4851 mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
4852 mac->ledctl_mode1 |= (ledctl_on << shift);
4854 case ID_LED_OFF1_DEF2:
4855 case ID_LED_OFF1_ON2:
4856 case ID_LED_OFF1_OFF2:
4857 mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
4858 mac->ledctl_mode1 |= (ledctl_off << shift);
4865 case ID_LED_DEF1_ON2:
4866 case ID_LED_ON1_ON2:
4867 case ID_LED_OFF1_ON2:
4868 mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
4869 mac->ledctl_mode2 |= (ledctl_on << shift);
4871 case ID_LED_DEF1_OFF2:
4872 case ID_LED_ON1_OFF2:
4873 case ID_LED_OFF1_OFF2:
4874 mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
4875 mac->ledctl_mode2 |= (ledctl_off << shift);
4883 return E1000_SUCCESS;
4887 * e1000_get_bus_info_ich8lan - Get/Set the bus type and width
4888 * @hw: pointer to the HW structure
4890 * ICH8 use the PCI Express bus, but does not contain a PCI Express Capability
4891 * register, so the the bus width is hard coded.
4893 STATIC s32 e1000_get_bus_info_ich8lan(struct e1000_hw *hw)
4895 struct e1000_bus_info *bus = &hw->bus;
4898 DEBUGFUNC("e1000_get_bus_info_ich8lan");
4900 ret_val = e1000_get_bus_info_pcie_generic(hw);
4902 /* ICH devices are "PCI Express"-ish. They have
4903 * a configuration space, but do not contain
4904 * PCI Express Capability registers, so bus width
4905 * must be hardcoded.
4907 if (bus->width == e1000_bus_width_unknown)
4908 bus->width = e1000_bus_width_pcie_x1;
4914 * e1000_reset_hw_ich8lan - Reset the hardware
4915 * @hw: pointer to the HW structure
4917 * Does a full reset of the hardware which includes a reset of the PHY and
4920 STATIC s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
4922 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
4927 DEBUGFUNC("e1000_reset_hw_ich8lan");
4929 /* Prevent the PCI-E bus from sticking if there is no TLP connection
4930 * on the last TLP read/write transaction when MAC is reset.
4932 ret_val = e1000_disable_pcie_master_generic(hw);
4934 DEBUGOUT("PCI-E Master disable polling has failed.\n");
4936 DEBUGOUT("Masking off all interrupts\n");
4937 E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
4939 /* Disable the Transmit and Receive units. Then delay to allow
4940 * any pending transactions to complete before we hit the MAC
4941 * with the global reset.
4943 E1000_WRITE_REG(hw, E1000_RCTL, 0);
4944 E1000_WRITE_REG(hw, E1000_TCTL, E1000_TCTL_PSP);
4945 E1000_WRITE_FLUSH(hw);
4949 /* Workaround for ICH8 bit corruption issue in FIFO memory */
4950 if (hw->mac.type == e1000_ich8lan) {
4951 /* Set Tx and Rx buffer allocation to 8k apiece. */
4952 E1000_WRITE_REG(hw, E1000_PBA, E1000_PBA_8K);
4953 /* Set Packet Buffer Size to 16k. */
4954 E1000_WRITE_REG(hw, E1000_PBS, E1000_PBS_16K);
4957 if (hw->mac.type == e1000_pchlan) {
4958 /* Save the NVM K1 bit setting*/
4959 ret_val = e1000_read_nvm(hw, E1000_NVM_K1_CONFIG, 1, &kum_cfg);
4963 if (kum_cfg & E1000_NVM_K1_ENABLE)
4964 dev_spec->nvm_k1_enabled = true;
4966 dev_spec->nvm_k1_enabled = false;
4969 ctrl = E1000_READ_REG(hw, E1000_CTRL);
4971 if (!hw->phy.ops.check_reset_block(hw)) {
4972 /* Full-chip reset requires MAC and PHY reset at the same
4973 * time to make sure the interface between MAC and the
4974 * external PHY is reset.
4976 ctrl |= E1000_CTRL_PHY_RST;
4978 /* Gate automatic PHY configuration by hardware on
4981 if ((hw->mac.type == e1000_pch2lan) &&
4982 !(E1000_READ_REG(hw, E1000_FWSM) & E1000_ICH_FWSM_FW_VALID))
4983 e1000_gate_hw_phy_config_ich8lan(hw, true);
4985 ret_val = e1000_acquire_swflag_ich8lan(hw);
4986 DEBUGOUT("Issuing a global reset to ich8lan\n");
4987 E1000_WRITE_REG(hw, E1000_CTRL, (ctrl | E1000_CTRL_RST));
4988 /* cannot issue a flush here because it hangs the hardware */
4991 /* Set Phy Config Counter to 50msec */
4992 if (hw->mac.type == e1000_pch2lan) {
4993 reg = E1000_READ_REG(hw, E1000_FEXTNVM3);
4994 reg &= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK;
4995 reg |= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC;
4996 E1000_WRITE_REG(hw, E1000_FEXTNVM3, reg);
5000 E1000_MUTEX_UNLOCK(&hw->dev_spec.ich8lan.swflag_mutex);
5002 if (ctrl & E1000_CTRL_PHY_RST) {
5003 ret_val = hw->phy.ops.get_cfg_done(hw);
5007 ret_val = e1000_post_phy_reset_ich8lan(hw);
5012 /* For PCH, this write will make sure that any noise
5013 * will be detected as a CRC error and be dropped rather than show up
5014 * as a bad packet to the DMA engine.
5016 if (hw->mac.type == e1000_pchlan)
5017 E1000_WRITE_REG(hw, E1000_CRC_OFFSET, 0x65656565);
5019 E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
5020 E1000_READ_REG(hw, E1000_ICR);
5022 reg = E1000_READ_REG(hw, E1000_KABGTXD);
5023 reg |= E1000_KABGTXD_BGSQLBIAS;
5024 E1000_WRITE_REG(hw, E1000_KABGTXD, reg);
5026 return E1000_SUCCESS;
5030 * e1000_init_hw_ich8lan - Initialize the hardware
5031 * @hw: pointer to the HW structure
5033 * Prepares the hardware for transmit and receive by doing the following:
5034 * - initialize hardware bits
5035 * - initialize LED identification
5036 * - setup receive address registers
5037 * - setup flow control
5038 * - setup transmit descriptors
5039 * - clear statistics
5041 STATIC s32 e1000_init_hw_ich8lan(struct e1000_hw *hw)
5043 struct e1000_mac_info *mac = &hw->mac;
5044 u32 ctrl_ext, txdctl, snoop;
5048 DEBUGFUNC("e1000_init_hw_ich8lan");
5050 e1000_initialize_hw_bits_ich8lan(hw);
5052 /* Initialize identification LED */
5053 ret_val = mac->ops.id_led_init(hw);
5054 /* An error is not fatal and we should not stop init due to this */
5056 DEBUGOUT("Error initializing identification LED\n");
5058 /* Setup the receive address. */
5059 e1000_init_rx_addrs_generic(hw, mac->rar_entry_count);
5061 /* Zero out the Multicast HASH table */
5062 DEBUGOUT("Zeroing the MTA\n");
5063 for (i = 0; i < mac->mta_reg_count; i++)
5064 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
5066 /* The 82578 Rx buffer will stall if wakeup is enabled in host and
5067 * the ME. Disable wakeup by clearing the host wakeup bit.
5068 * Reset the phy after disabling host wakeup to reset the Rx buffer.
5070 if (hw->phy.type == e1000_phy_82578) {
5071 hw->phy.ops.read_reg(hw, BM_PORT_GEN_CFG, &i);
5072 i &= ~BM_WUC_HOST_WU_BIT;
5073 hw->phy.ops.write_reg(hw, BM_PORT_GEN_CFG, i);
5074 ret_val = e1000_phy_hw_reset_ich8lan(hw);
5079 /* Setup link and flow control */
5080 ret_val = mac->ops.setup_link(hw);
5082 /* Set the transmit descriptor write-back policy for both queues */
5083 txdctl = E1000_READ_REG(hw, E1000_TXDCTL(0));
5084 txdctl = ((txdctl & ~E1000_TXDCTL_WTHRESH) |
5085 E1000_TXDCTL_FULL_TX_DESC_WB);
5086 txdctl = ((txdctl & ~E1000_TXDCTL_PTHRESH) |
5087 E1000_TXDCTL_MAX_TX_DESC_PREFETCH);
5088 E1000_WRITE_REG(hw, E1000_TXDCTL(0), txdctl);
5089 txdctl = E1000_READ_REG(hw, E1000_TXDCTL(1));
5090 txdctl = ((txdctl & ~E1000_TXDCTL_WTHRESH) |
5091 E1000_TXDCTL_FULL_TX_DESC_WB);
5092 txdctl = ((txdctl & ~E1000_TXDCTL_PTHRESH) |
5093 E1000_TXDCTL_MAX_TX_DESC_PREFETCH);
5094 E1000_WRITE_REG(hw, E1000_TXDCTL(1), txdctl);
5096 /* ICH8 has opposite polarity of no_snoop bits.
5097 * By default, we should use snoop behavior.
5099 if (mac->type == e1000_ich8lan)
5100 snoop = PCIE_ICH8_SNOOP_ALL;
5102 snoop = (u32) ~(PCIE_NO_SNOOP_ALL);
5103 e1000_set_pcie_no_snoop_generic(hw, snoop);
5105 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
5106 ctrl_ext |= E1000_CTRL_EXT_RO_DIS;
5107 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
5109 /* Clear all of the statistics registers (clear on read). It is
5110 * important that we do this after we have tried to establish link
5111 * because the symbol error count will increment wildly if there
5114 e1000_clear_hw_cntrs_ich8lan(hw);
5120 * e1000_initialize_hw_bits_ich8lan - Initialize required hardware bits
5121 * @hw: pointer to the HW structure
5123 * Sets/Clears required hardware bits necessary for correctly setting up the
5124 * hardware for transmit and receive.
5126 STATIC void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw)
5130 DEBUGFUNC("e1000_initialize_hw_bits_ich8lan");
5132 /* Extended Device Control */
5133 reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
5135 /* Enable PHY low-power state when MAC is at D3 w/o WoL */
5136 if (hw->mac.type >= e1000_pchlan)
5137 reg |= E1000_CTRL_EXT_PHYPDEN;
5138 E1000_WRITE_REG(hw, E1000_CTRL_EXT, reg);
5140 /* Transmit Descriptor Control 0 */
5141 reg = E1000_READ_REG(hw, E1000_TXDCTL(0));
5143 E1000_WRITE_REG(hw, E1000_TXDCTL(0), reg);
5145 /* Transmit Descriptor Control 1 */
5146 reg = E1000_READ_REG(hw, E1000_TXDCTL(1));
5148 E1000_WRITE_REG(hw, E1000_TXDCTL(1), reg);
5150 /* Transmit Arbitration Control 0 */
5151 reg = E1000_READ_REG(hw, E1000_TARC(0));
5152 if (hw->mac.type == e1000_ich8lan)
5153 reg |= (1 << 28) | (1 << 29);
5154 reg |= (1 << 23) | (1 << 24) | (1 << 26) | (1 << 27);
5155 E1000_WRITE_REG(hw, E1000_TARC(0), reg);
5157 /* Transmit Arbitration Control 1 */
5158 reg = E1000_READ_REG(hw, E1000_TARC(1));
5159 if (E1000_READ_REG(hw, E1000_TCTL) & E1000_TCTL_MULR)
5163 reg |= (1 << 24) | (1 << 26) | (1 << 30);
5164 E1000_WRITE_REG(hw, E1000_TARC(1), reg);
5167 if (hw->mac.type == e1000_ich8lan) {
5168 reg = E1000_READ_REG(hw, E1000_STATUS);
5170 E1000_WRITE_REG(hw, E1000_STATUS, reg);
5173 /* work-around descriptor data corruption issue during nfs v2 udp
5174 * traffic, just disable the nfs filtering capability
5176 reg = E1000_READ_REG(hw, E1000_RFCTL);
5177 reg |= (E1000_RFCTL_NFSW_DIS | E1000_RFCTL_NFSR_DIS);
5179 /* Disable IPv6 extension header parsing because some malformed
5180 * IPv6 headers can hang the Rx.
5182 if (hw->mac.type == e1000_ich8lan)
5183 reg |= (E1000_RFCTL_IPV6_EX_DIS | E1000_RFCTL_NEW_IPV6_EXT_DIS);
5184 E1000_WRITE_REG(hw, E1000_RFCTL, reg);
5186 /* Enable ECC on Lynxpoint */
5187 if (hw->mac.type >= e1000_pch_lpt) {
5188 reg = E1000_READ_REG(hw, E1000_PBECCSTS);
5189 reg |= E1000_PBECCSTS_ECC_ENABLE;
5190 E1000_WRITE_REG(hw, E1000_PBECCSTS, reg);
5192 reg = E1000_READ_REG(hw, E1000_CTRL);
5193 reg |= E1000_CTRL_MEHE;
5194 E1000_WRITE_REG(hw, E1000_CTRL, reg);
5201 * e1000_setup_link_ich8lan - Setup flow control and link settings
5202 * @hw: pointer to the HW structure
5204 * Determines which flow control settings to use, then configures flow
5205 * control. Calls the appropriate media-specific link configuration
5206 * function. Assuming the adapter has a valid link partner, a valid link
5207 * should be established. Assumes the hardware has previously been reset
5208 * and the transmitter and receiver are not enabled.
5210 STATIC s32 e1000_setup_link_ich8lan(struct e1000_hw *hw)
5214 DEBUGFUNC("e1000_setup_link_ich8lan");
5216 if (hw->phy.ops.check_reset_block(hw))
5217 return E1000_SUCCESS;
5219 /* ICH parts do not have a word in the NVM to determine
5220 * the default flow control setting, so we explicitly
5223 if (hw->fc.requested_mode == e1000_fc_default)
5224 hw->fc.requested_mode = e1000_fc_full;
5226 /* Save off the requested flow control mode for use later. Depending
5227 * on the link partner's capabilities, we may or may not use this mode.
5229 hw->fc.current_mode = hw->fc.requested_mode;
5231 DEBUGOUT1("After fix-ups FlowControl is now = %x\n",
5232 hw->fc.current_mode);
5234 /* Continue to configure the copper link. */
5235 ret_val = hw->mac.ops.setup_physical_interface(hw);
5239 E1000_WRITE_REG(hw, E1000_FCTTV, hw->fc.pause_time);
5240 if ((hw->phy.type == e1000_phy_82578) ||
5241 (hw->phy.type == e1000_phy_82579) ||
5242 (hw->phy.type == e1000_phy_i217) ||
5243 (hw->phy.type == e1000_phy_82577)) {
5244 E1000_WRITE_REG(hw, E1000_FCRTV_PCH, hw->fc.refresh_time);
5246 ret_val = hw->phy.ops.write_reg(hw,
5247 PHY_REG(BM_PORT_CTRL_PAGE, 27),
5253 return e1000_set_fc_watermarks_generic(hw);
5257 * e1000_setup_copper_link_ich8lan - Configure MAC/PHY interface
5258 * @hw: pointer to the HW structure
5260 * Configures the kumeran interface to the PHY to wait the appropriate time
5261 * when polling the PHY, then call the generic setup_copper_link to finish
5262 * configuring the copper link.
5264 STATIC s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw)
5270 DEBUGFUNC("e1000_setup_copper_link_ich8lan");
5272 ctrl = E1000_READ_REG(hw, E1000_CTRL);
5273 ctrl |= E1000_CTRL_SLU;
5274 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
5275 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
5277 /* Set the mac to wait the maximum time between each iteration
5278 * and increase the max iterations when polling the phy;
5279 * this fixes erroneous timeouts at 10Mbps.
5281 ret_val = e1000_write_kmrn_reg_generic(hw, E1000_KMRNCTRLSTA_TIMEOUTS,
5285 ret_val = e1000_read_kmrn_reg_generic(hw,
5286 E1000_KMRNCTRLSTA_INBAND_PARAM,
5291 ret_val = e1000_write_kmrn_reg_generic(hw,
5292 E1000_KMRNCTRLSTA_INBAND_PARAM,
5297 switch (hw->phy.type) {
5298 case e1000_phy_igp_3:
5299 ret_val = e1000_copper_link_setup_igp(hw);
5304 case e1000_phy_82578:
5305 ret_val = e1000_copper_link_setup_m88(hw);
5309 case e1000_phy_82577:
5310 case e1000_phy_82579:
5311 ret_val = e1000_copper_link_setup_82577(hw);
5316 ret_val = hw->phy.ops.read_reg(hw, IFE_PHY_MDIX_CONTROL,
5321 reg_data &= ~IFE_PMC_AUTO_MDIX;
5323 switch (hw->phy.mdix) {
5325 reg_data &= ~IFE_PMC_FORCE_MDIX;
5328 reg_data |= IFE_PMC_FORCE_MDIX;
5332 reg_data |= IFE_PMC_AUTO_MDIX;
5335 ret_val = hw->phy.ops.write_reg(hw, IFE_PHY_MDIX_CONTROL,
5344 return e1000_setup_copper_link_generic(hw);
5348 * e1000_setup_copper_link_pch_lpt - Configure MAC/PHY interface
5349 * @hw: pointer to the HW structure
5351 * Calls the PHY specific link setup function and then calls the
5352 * generic setup_copper_link to finish configuring the link for
5353 * Lynxpoint PCH devices
5355 STATIC s32 e1000_setup_copper_link_pch_lpt(struct e1000_hw *hw)
5360 DEBUGFUNC("e1000_setup_copper_link_pch_lpt");
5362 ctrl = E1000_READ_REG(hw, E1000_CTRL);
5363 ctrl |= E1000_CTRL_SLU;
5364 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
5365 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
5367 ret_val = e1000_copper_link_setup_82577(hw);
5371 return e1000_setup_copper_link_generic(hw);
5375 * e1000_get_link_up_info_ich8lan - Get current link speed and duplex
5376 * @hw: pointer to the HW structure
5377 * @speed: pointer to store current link speed
5378 * @duplex: pointer to store the current link duplex
5380 * Calls the generic get_speed_and_duplex to retrieve the current link
5381 * information and then calls the Kumeran lock loss workaround for links at
5384 STATIC s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw, u16 *speed,
5389 DEBUGFUNC("e1000_get_link_up_info_ich8lan");
5391 ret_val = e1000_get_speed_and_duplex_copper_generic(hw, speed, duplex);
5395 if ((hw->mac.type == e1000_ich8lan) &&
5396 (hw->phy.type == e1000_phy_igp_3) &&
5397 (*speed == SPEED_1000)) {
5398 ret_val = e1000_kmrn_lock_loss_workaround_ich8lan(hw);
5405 * e1000_kmrn_lock_loss_workaround_ich8lan - Kumeran workaround
5406 * @hw: pointer to the HW structure
5408 * Work-around for 82566 Kumeran PCS lock loss:
5409 * On link status change (i.e. PCI reset, speed change) and link is up and
5411 * 0) if workaround is optionally disabled do nothing
5412 * 1) wait 1ms for Kumeran link to come up
5413 * 2) check Kumeran Diagnostic register PCS lock loss bit
5414 * 3) if not set the link is locked (all is good), otherwise...
5416 * 5) repeat up to 10 times
5417 * Note: this is only called for IGP3 copper when speed is 1gb.
5419 STATIC s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw)
5421 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
5427 DEBUGFUNC("e1000_kmrn_lock_loss_workaround_ich8lan");
5429 if (!dev_spec->kmrn_lock_loss_workaround_enabled)
5430 return E1000_SUCCESS;
5432 /* Make sure link is up before proceeding. If not just return.
5433 * Attempting this while link is negotiating fouled up link
5436 ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link);
5438 return E1000_SUCCESS;
5440 for (i = 0; i < 10; i++) {
5441 /* read once to clear */
5442 ret_val = hw->phy.ops.read_reg(hw, IGP3_KMRN_DIAG, &data);
5445 /* and again to get new status */
5446 ret_val = hw->phy.ops.read_reg(hw, IGP3_KMRN_DIAG, &data);
5450 /* check for PCS lock */
5451 if (!(data & IGP3_KMRN_DIAG_PCS_LOCK_LOSS))
5452 return E1000_SUCCESS;
5454 /* Issue PHY reset */
5455 hw->phy.ops.reset(hw);
5458 /* Disable GigE link negotiation */
5459 phy_ctrl = E1000_READ_REG(hw, E1000_PHY_CTRL);
5460 phy_ctrl |= (E1000_PHY_CTRL_GBE_DISABLE |
5461 E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
5462 E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl);
5464 /* Call gig speed drop workaround on Gig disable before accessing
5467 e1000_gig_downshift_workaround_ich8lan(hw);
5469 /* unable to acquire PCS lock */
5470 return -E1000_ERR_PHY;
5474 * e1000_set_kmrn_lock_loss_workaround_ich8lan - Set Kumeran workaround state
5475 * @hw: pointer to the HW structure
5476 * @state: boolean value used to set the current Kumeran workaround state
5478 * If ICH8, set the current Kumeran workaround state (enabled - true
5479 * /disabled - false).
5481 void e1000_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw,
5484 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
5486 DEBUGFUNC("e1000_set_kmrn_lock_loss_workaround_ich8lan");
5488 if (hw->mac.type != e1000_ich8lan) {
5489 DEBUGOUT("Workaround applies to ICH8 only.\n");
5493 dev_spec->kmrn_lock_loss_workaround_enabled = state;
5499 * e1000_ipg3_phy_powerdown_workaround_ich8lan - Power down workaround on D3
5500 * @hw: pointer to the HW structure
5502 * Workaround for 82566 power-down on D3 entry:
5503 * 1) disable gigabit link
5504 * 2) write VR power-down enable
5506 * Continue if successful, else issue LCD reset and repeat
5508 void e1000_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw)
5514 DEBUGFUNC("e1000_igp3_phy_powerdown_workaround_ich8lan");
5516 if (hw->phy.type != e1000_phy_igp_3)
5519 /* Try the workaround twice (if needed) */
5522 reg = E1000_READ_REG(hw, E1000_PHY_CTRL);
5523 reg |= (E1000_PHY_CTRL_GBE_DISABLE |
5524 E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
5525 E1000_WRITE_REG(hw, E1000_PHY_CTRL, reg);
5527 /* Call gig speed drop workaround on Gig disable before
5528 * accessing any PHY registers
5530 if (hw->mac.type == e1000_ich8lan)
5531 e1000_gig_downshift_workaround_ich8lan(hw);
5533 /* Write VR power-down enable */
5534 hw->phy.ops.read_reg(hw, IGP3_VR_CTRL, &data);
5535 data &= ~IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
5536 hw->phy.ops.write_reg(hw, IGP3_VR_CTRL,
5537 data | IGP3_VR_CTRL_MODE_SHUTDOWN);
5539 /* Read it back and test */
5540 hw->phy.ops.read_reg(hw, IGP3_VR_CTRL, &data);
5541 data &= IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
5542 if ((data == IGP3_VR_CTRL_MODE_SHUTDOWN) || retry)
5545 /* Issue PHY reset and repeat at most one more time */
5546 reg = E1000_READ_REG(hw, E1000_CTRL);
5547 E1000_WRITE_REG(hw, E1000_CTRL, reg | E1000_CTRL_PHY_RST);
5553 * e1000_gig_downshift_workaround_ich8lan - WoL from S5 stops working
5554 * @hw: pointer to the HW structure
5556 * Steps to take when dropping from 1Gb/s (eg. link cable removal (LSC),
5557 * LPLU, Gig disable, MDIC PHY reset):
5558 * 1) Set Kumeran Near-end loopback
5559 * 2) Clear Kumeran Near-end loopback
5560 * Should only be called for ICH8[m] devices with any 1G Phy.
5562 void e1000_gig_downshift_workaround_ich8lan(struct e1000_hw *hw)
5567 DEBUGFUNC("e1000_gig_downshift_workaround_ich8lan");
5569 if ((hw->mac.type != e1000_ich8lan) ||
5570 (hw->phy.type == e1000_phy_ife))
5573 ret_val = e1000_read_kmrn_reg_generic(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
5577 reg_data |= E1000_KMRNCTRLSTA_DIAG_NELPBK;
5578 ret_val = e1000_write_kmrn_reg_generic(hw,
5579 E1000_KMRNCTRLSTA_DIAG_OFFSET,
5583 reg_data &= ~E1000_KMRNCTRLSTA_DIAG_NELPBK;
5584 e1000_write_kmrn_reg_generic(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
5589 * e1000_suspend_workarounds_ich8lan - workarounds needed during S0->Sx
5590 * @hw: pointer to the HW structure
5592 * During S0 to Sx transition, it is possible the link remains at gig
5593 * instead of negotiating to a lower speed. Before going to Sx, set
5594 * 'Gig Disable' to force link speed negotiation to a lower speed based on
5595 * the LPLU setting in the NVM or custom setting. For PCH and newer parts,
5596 * the OEM bits PHY register (LED, GbE disable and LPLU configurations) also
5597 * needs to be written.
5598 * Parts that support (and are linked to a partner which support) EEE in
5599 * 100Mbps should disable LPLU since 100Mbps w/ EEE requires less power
5600 * than 10Mbps w/o EEE.
5602 void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw)
5604 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
5608 DEBUGFUNC("e1000_suspend_workarounds_ich8lan");
5610 phy_ctrl = E1000_READ_REG(hw, E1000_PHY_CTRL);
5611 phy_ctrl |= E1000_PHY_CTRL_GBE_DISABLE;
5613 if (hw->phy.type == e1000_phy_i217) {
5614 u16 phy_reg, device_id = hw->device_id;
5616 if ((device_id == E1000_DEV_ID_PCH_LPTLP_I218_LM) ||
5617 (device_id == E1000_DEV_ID_PCH_LPTLP_I218_V) ||
5618 (device_id == E1000_DEV_ID_PCH_I218_LM3) ||
5619 (device_id == E1000_DEV_ID_PCH_I218_V3) ||
5620 (hw->mac.type >= e1000_pch_spt)) {
5621 u32 fextnvm6 = E1000_READ_REG(hw, E1000_FEXTNVM6);
5623 E1000_WRITE_REG(hw, E1000_FEXTNVM6,
5624 fextnvm6 & ~E1000_FEXTNVM6_REQ_PLL_CLK);
5627 ret_val = hw->phy.ops.acquire(hw);
5631 if (!dev_spec->eee_disable) {
5635 e1000_read_emi_reg_locked(hw,
5636 I217_EEE_ADVERTISEMENT,
5641 /* Disable LPLU if both link partners support 100BaseT
5642 * EEE and 100Full is advertised on both ends of the
5643 * link, and enable Auto Enable LPI since there will
5644 * be no driver to enable LPI while in Sx.
5646 if ((eee_advert & I82579_EEE_100_SUPPORTED) &&
5647 (dev_spec->eee_lp_ability &
5648 I82579_EEE_100_SUPPORTED) &&
5649 (hw->phy.autoneg_advertised & ADVERTISE_100_FULL)) {
5650 phy_ctrl &= ~(E1000_PHY_CTRL_D0A_LPLU |
5651 E1000_PHY_CTRL_NOND0A_LPLU);
5653 /* Set Auto Enable LPI after link up */
5654 hw->phy.ops.read_reg_locked(hw,
5657 phy_reg |= I217_LPI_GPIO_CTRL_AUTO_EN_LPI;
5658 hw->phy.ops.write_reg_locked(hw,
5664 /* For i217 Intel Rapid Start Technology support,
5665 * when the system is going into Sx and no manageability engine
5666 * is present, the driver must configure proxy to reset only on
5667 * power good. LPI (Low Power Idle) state must also reset only
5668 * on power good, as well as the MTA (Multicast table array).
5669 * The SMBus release must also be disabled on LCD reset.
5671 if (!(E1000_READ_REG(hw, E1000_FWSM) &
5672 E1000_ICH_FWSM_FW_VALID)) {
5673 /* Enable proxy to reset only on power good. */
5674 hw->phy.ops.read_reg_locked(hw, I217_PROXY_CTRL,
5676 phy_reg |= I217_PROXY_CTRL_AUTO_DISABLE;
5677 hw->phy.ops.write_reg_locked(hw, I217_PROXY_CTRL,
5680 /* Set bit enable LPI (EEE) to reset only on
5683 hw->phy.ops.read_reg_locked(hw, I217_SxCTRL, &phy_reg);
5684 phy_reg |= I217_SxCTRL_ENABLE_LPI_RESET;
5685 hw->phy.ops.write_reg_locked(hw, I217_SxCTRL, phy_reg);
5687 /* Disable the SMB release on LCD reset. */
5688 hw->phy.ops.read_reg_locked(hw, I217_MEMPWR, &phy_reg);
5689 phy_reg &= ~I217_MEMPWR_DISABLE_SMB_RELEASE;
5690 hw->phy.ops.write_reg_locked(hw, I217_MEMPWR, phy_reg);
5693 /* Enable MTA to reset for Intel Rapid Start Technology
5696 hw->phy.ops.read_reg_locked(hw, I217_CGFREG, &phy_reg);
5697 phy_reg |= I217_CGFREG_ENABLE_MTA_RESET;
5698 hw->phy.ops.write_reg_locked(hw, I217_CGFREG, phy_reg);
5701 hw->phy.ops.release(hw);
5704 E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl);
5706 if (hw->mac.type == e1000_ich8lan)
5707 e1000_gig_downshift_workaround_ich8lan(hw);
5709 if (hw->mac.type >= e1000_pchlan) {
5710 e1000_oem_bits_config_ich8lan(hw, false);
5712 /* Reset PHY to activate OEM bits on 82577/8 */
5713 if (hw->mac.type == e1000_pchlan)
5714 e1000_phy_hw_reset_generic(hw);
5716 ret_val = hw->phy.ops.acquire(hw);
5719 e1000_write_smbus_addr(hw);
5720 hw->phy.ops.release(hw);
5727 * e1000_resume_workarounds_pchlan - workarounds needed during Sx->S0
5728 * @hw: pointer to the HW structure
5730 * During Sx to S0 transitions on non-managed devices or managed devices
5731 * on which PHY resets are not blocked, if the PHY registers cannot be
5732 * accessed properly by the s/w toggle the LANPHYPC value to power cycle
5734 * On i217, setup Intel Rapid Start Technology.
5736 u32 e1000_resume_workarounds_pchlan(struct e1000_hw *hw)
5740 DEBUGFUNC("e1000_resume_workarounds_pchlan");
5741 if (hw->mac.type < e1000_pch2lan)
5742 return E1000_SUCCESS;
5744 ret_val = e1000_init_phy_workarounds_pchlan(hw);
5746 DEBUGOUT1("Failed to init PHY flow ret_val=%d\n", ret_val);
5750 /* For i217 Intel Rapid Start Technology support when the system
5751 * is transitioning from Sx and no manageability engine is present
5752 * configure SMBus to restore on reset, disable proxy, and enable
5753 * the reset on MTA (Multicast table array).
5755 if (hw->phy.type == e1000_phy_i217) {
5758 ret_val = hw->phy.ops.acquire(hw);
5760 DEBUGOUT("Failed to setup iRST\n");
5764 /* Clear Auto Enable LPI after link up */
5765 hw->phy.ops.read_reg_locked(hw, I217_LPI_GPIO_CTRL, &phy_reg);
5766 phy_reg &= ~I217_LPI_GPIO_CTRL_AUTO_EN_LPI;
5767 hw->phy.ops.write_reg_locked(hw, I217_LPI_GPIO_CTRL, phy_reg);
5769 if (!(E1000_READ_REG(hw, E1000_FWSM) &
5770 E1000_ICH_FWSM_FW_VALID)) {
5771 /* Restore clear on SMB if no manageability engine
5774 ret_val = hw->phy.ops.read_reg_locked(hw, I217_MEMPWR,
5778 phy_reg |= I217_MEMPWR_DISABLE_SMB_RELEASE;
5779 hw->phy.ops.write_reg_locked(hw, I217_MEMPWR, phy_reg);
5782 hw->phy.ops.write_reg_locked(hw, I217_PROXY_CTRL, 0);
5784 /* Enable reset on MTA */
5785 ret_val = hw->phy.ops.read_reg_locked(hw, I217_CGFREG,
5789 phy_reg &= ~I217_CGFREG_ENABLE_MTA_RESET;
5790 hw->phy.ops.write_reg_locked(hw, I217_CGFREG, phy_reg);
5793 DEBUGOUT1("Error %d in resume workarounds\n", ret_val);
5794 hw->phy.ops.release(hw);
5797 return E1000_SUCCESS;
5801 * e1000_cleanup_led_ich8lan - Restore the default LED operation
5802 * @hw: pointer to the HW structure
5804 * Return the LED back to the default configuration.
5806 STATIC s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw)
5808 DEBUGFUNC("e1000_cleanup_led_ich8lan");
5810 if (hw->phy.type == e1000_phy_ife)
5811 return hw->phy.ops.write_reg(hw, IFE_PHY_SPECIAL_CONTROL_LED,
5814 E1000_WRITE_REG(hw, E1000_LEDCTL, hw->mac.ledctl_default);
5815 return E1000_SUCCESS;
5819 * e1000_led_on_ich8lan - Turn LEDs on
5820 * @hw: pointer to the HW structure
5824 STATIC s32 e1000_led_on_ich8lan(struct e1000_hw *hw)
5826 DEBUGFUNC("e1000_led_on_ich8lan");
5828 if (hw->phy.type == e1000_phy_ife)
5829 return hw->phy.ops.write_reg(hw, IFE_PHY_SPECIAL_CONTROL_LED,
5830 (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_ON));
5832 E1000_WRITE_REG(hw, E1000_LEDCTL, hw->mac.ledctl_mode2);
5833 return E1000_SUCCESS;
5837 * e1000_led_off_ich8lan - Turn LEDs off
5838 * @hw: pointer to the HW structure
5840 * Turn off the LEDs.
5842 STATIC s32 e1000_led_off_ich8lan(struct e1000_hw *hw)
5844 DEBUGFUNC("e1000_led_off_ich8lan");
5846 if (hw->phy.type == e1000_phy_ife)
5847 return hw->phy.ops.write_reg(hw, IFE_PHY_SPECIAL_CONTROL_LED,
5848 (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_OFF));
5850 E1000_WRITE_REG(hw, E1000_LEDCTL, hw->mac.ledctl_mode1);
5851 return E1000_SUCCESS;
5855 * e1000_setup_led_pchlan - Configures SW controllable LED
5856 * @hw: pointer to the HW structure
5858 * This prepares the SW controllable LED for use.
5860 STATIC s32 e1000_setup_led_pchlan(struct e1000_hw *hw)
5862 DEBUGFUNC("e1000_setup_led_pchlan");
5864 return hw->phy.ops.write_reg(hw, HV_LED_CONFIG,
5865 (u16)hw->mac.ledctl_mode1);
5869 * e1000_cleanup_led_pchlan - Restore the default LED operation
5870 * @hw: pointer to the HW structure
5872 * Return the LED back to the default configuration.
5874 STATIC s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw)
5876 DEBUGFUNC("e1000_cleanup_led_pchlan");
5878 return hw->phy.ops.write_reg(hw, HV_LED_CONFIG,
5879 (u16)hw->mac.ledctl_default);
5883 * e1000_led_on_pchlan - Turn LEDs on
5884 * @hw: pointer to the HW structure
5888 STATIC s32 e1000_led_on_pchlan(struct e1000_hw *hw)
5890 u16 data = (u16)hw->mac.ledctl_mode2;
5893 DEBUGFUNC("e1000_led_on_pchlan");
5895 /* If no link, then turn LED on by setting the invert bit
5896 * for each LED that's mode is "link_up" in ledctl_mode2.
5898 if (!(E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU)) {
5899 for (i = 0; i < 3; i++) {
5900 led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
5901 if ((led & E1000_PHY_LED0_MODE_MASK) !=
5902 E1000_LEDCTL_MODE_LINK_UP)
5904 if (led & E1000_PHY_LED0_IVRT)
5905 data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
5907 data |= (E1000_PHY_LED0_IVRT << (i * 5));
5911 return hw->phy.ops.write_reg(hw, HV_LED_CONFIG, data);
5915 * e1000_led_off_pchlan - Turn LEDs off
5916 * @hw: pointer to the HW structure
5918 * Turn off the LEDs.
5920 STATIC s32 e1000_led_off_pchlan(struct e1000_hw *hw)
5922 u16 data = (u16)hw->mac.ledctl_mode1;
5925 DEBUGFUNC("e1000_led_off_pchlan");
5927 /* If no link, then turn LED off by clearing the invert bit
5928 * for each LED that's mode is "link_up" in ledctl_mode1.
5930 if (!(E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU)) {
5931 for (i = 0; i < 3; i++) {
5932 led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
5933 if ((led & E1000_PHY_LED0_MODE_MASK) !=
5934 E1000_LEDCTL_MODE_LINK_UP)
5936 if (led & E1000_PHY_LED0_IVRT)
5937 data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
5939 data |= (E1000_PHY_LED0_IVRT << (i * 5));
5943 return hw->phy.ops.write_reg(hw, HV_LED_CONFIG, data);
5947 * e1000_get_cfg_done_ich8lan - Read config done bit after Full or PHY reset
5948 * @hw: pointer to the HW structure
5950 * Read appropriate register for the config done bit for completion status
5951 * and configure the PHY through s/w for EEPROM-less parts.
5953 * NOTE: some silicon which is EEPROM-less will fail trying to read the
5954 * config done bit, so only an error is logged and continues. If we were
5955 * to return with error, EEPROM-less silicon would not be able to be reset
5958 STATIC s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw)
5960 s32 ret_val = E1000_SUCCESS;
5964 DEBUGFUNC("e1000_get_cfg_done_ich8lan");
5966 e1000_get_cfg_done_generic(hw);
5968 /* Wait for indication from h/w that it has completed basic config */
5969 if (hw->mac.type >= e1000_ich10lan) {
5970 e1000_lan_init_done_ich8lan(hw);
5972 ret_val = e1000_get_auto_rd_done_generic(hw);
5974 /* When auto config read does not complete, do not
5975 * return with an error. This can happen in situations
5976 * where there is no eeprom and prevents getting link.
5978 DEBUGOUT("Auto Read Done did not complete\n");
5979 ret_val = E1000_SUCCESS;
5983 /* Clear PHY Reset Asserted bit */
5984 status = E1000_READ_REG(hw, E1000_STATUS);
5985 if (status & E1000_STATUS_PHYRA)
5986 E1000_WRITE_REG(hw, E1000_STATUS, status & ~E1000_STATUS_PHYRA);
5988 DEBUGOUT("PHY Reset Asserted not set - needs delay\n");
5990 /* If EEPROM is not marked present, init the IGP 3 PHY manually */
5991 if (hw->mac.type <= e1000_ich9lan) {
5992 if (!(E1000_READ_REG(hw, E1000_EECD) & E1000_EECD_PRES) &&
5993 (hw->phy.type == e1000_phy_igp_3)) {
5994 e1000_phy_init_script_igp3(hw);
5997 if (e1000_valid_nvm_bank_detect_ich8lan(hw, &bank)) {
5998 /* Maybe we should do a basic PHY config */
5999 DEBUGOUT("EEPROM not present\n");
6000 ret_val = -E1000_ERR_CONFIG;
6008 * e1000_power_down_phy_copper_ich8lan - Remove link during PHY power down
6009 * @hw: pointer to the HW structure
6011 * In the case of a PHY power down to save power, or to turn off link during a
6012 * driver unload, or wake on lan is not enabled, remove the link.
6014 STATIC void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw)
6016 /* If the management interface is not enabled, then power down */
6017 if (!(hw->mac.ops.check_mng_mode(hw) ||
6018 hw->phy.ops.check_reset_block(hw)))
6019 e1000_power_down_phy_copper(hw);
6025 * e1000_clear_hw_cntrs_ich8lan - Clear statistical counters
6026 * @hw: pointer to the HW structure
6028 * Clears hardware counters specific to the silicon family and calls
6029 * clear_hw_cntrs_generic to clear all general purpose counters.
6031 STATIC void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw)
6036 DEBUGFUNC("e1000_clear_hw_cntrs_ich8lan");
6038 e1000_clear_hw_cntrs_base_generic(hw);
6040 E1000_READ_REG(hw, E1000_ALGNERRC);
6041 E1000_READ_REG(hw, E1000_RXERRC);
6042 E1000_READ_REG(hw, E1000_TNCRS);
6043 E1000_READ_REG(hw, E1000_CEXTERR);
6044 E1000_READ_REG(hw, E1000_TSCTC);
6045 E1000_READ_REG(hw, E1000_TSCTFC);
6047 E1000_READ_REG(hw, E1000_MGTPRC);
6048 E1000_READ_REG(hw, E1000_MGTPDC);
6049 E1000_READ_REG(hw, E1000_MGTPTC);
6051 E1000_READ_REG(hw, E1000_IAC);
6052 E1000_READ_REG(hw, E1000_ICRXOC);
6054 /* Clear PHY statistics registers */
6055 if ((hw->phy.type == e1000_phy_82578) ||
6056 (hw->phy.type == e1000_phy_82579) ||
6057 (hw->phy.type == e1000_phy_i217) ||
6058 (hw->phy.type == e1000_phy_82577)) {
6059 ret_val = hw->phy.ops.acquire(hw);
6062 ret_val = hw->phy.ops.set_page(hw,
6063 HV_STATS_PAGE << IGP_PAGE_SHIFT);
6066 hw->phy.ops.read_reg_page(hw, HV_SCC_UPPER, &phy_data);
6067 hw->phy.ops.read_reg_page(hw, HV_SCC_LOWER, &phy_data);
6068 hw->phy.ops.read_reg_page(hw, HV_ECOL_UPPER, &phy_data);
6069 hw->phy.ops.read_reg_page(hw, HV_ECOL_LOWER, &phy_data);
6070 hw->phy.ops.read_reg_page(hw, HV_MCC_UPPER, &phy_data);
6071 hw->phy.ops.read_reg_page(hw, HV_MCC_LOWER, &phy_data);
6072 hw->phy.ops.read_reg_page(hw, HV_LATECOL_UPPER, &phy_data);
6073 hw->phy.ops.read_reg_page(hw, HV_LATECOL_LOWER, &phy_data);
6074 hw->phy.ops.read_reg_page(hw, HV_COLC_UPPER, &phy_data);
6075 hw->phy.ops.read_reg_page(hw, HV_COLC_LOWER, &phy_data);
6076 hw->phy.ops.read_reg_page(hw, HV_DC_UPPER, &phy_data);
6077 hw->phy.ops.read_reg_page(hw, HV_DC_LOWER, &phy_data);
6078 hw->phy.ops.read_reg_page(hw, HV_TNCRS_UPPER, &phy_data);
6079 hw->phy.ops.read_reg_page(hw, HV_TNCRS_LOWER, &phy_data);
6081 hw->phy.ops.release(hw);
6086 * e1000_configure_k0s_lpt - Configure K0s power state
6087 * @hw: pointer to the HW structure
6088 * @entry_latency: Tx idle period for entering K0s - valid values are 0 to 3.
6089 * 0 corresponds to 128ns, each value over 0 doubles the duration.
6090 * @min_time: Minimum Tx idle period allowed - valid values are 0 to 4.
6091 * 0 corresponds to 128ns, each value over 0 doubles the duration.
6093 * Configure the K1 power state based on the provided parameter.
6094 * Assumes semaphore already acquired.
6096 * Success returns 0, Failure returns:
6097 * -E1000_ERR_PHY (-2) in case of access error
6098 * -E1000_ERR_PARAM (-4) in case of parameters error
6100 s32 e1000_configure_k0s_lpt(struct e1000_hw *hw, u8 entry_latency, u8 min_time)
6105 DEBUGFUNC("e1000_configure_k0s_lpt");
6107 if (entry_latency > 3 || min_time > 4)
6108 return -E1000_ERR_PARAM;
6110 ret_val = e1000_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K0S_CTRL,
6115 /* for now don't touch the latency */
6116 kmrn_reg &= ~(E1000_KMRNCTRLSTA_K0S_CTRL_MIN_TIME_MASK);
6117 kmrn_reg |= ((min_time << E1000_KMRNCTRLSTA_K0S_CTRL_MIN_TIME_SHIFT));
6119 ret_val = e1000_write_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K0S_CTRL,
6124 return E1000_SUCCESS;