1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2001-2020 Intel Corporation
5 /* 82562G 10/100 Network Connection
6 * 82562G-2 10/100 Network Connection
7 * 82562GT 10/100 Network Connection
8 * 82562GT-2 10/100 Network Connection
9 * 82562V 10/100 Network Connection
10 * 82562V-2 10/100 Network Connection
11 * 82566DC-2 Gigabit Network Connection
12 * 82566DC Gigabit Network Connection
13 * 82566DM-2 Gigabit Network Connection
14 * 82566DM Gigabit Network Connection
15 * 82566MC Gigabit Network Connection
16 * 82566MM Gigabit Network Connection
17 * 82567LM Gigabit Network Connection
18 * 82567LF Gigabit Network Connection
19 * 82567V Gigabit Network Connection
20 * 82567LM-2 Gigabit Network Connection
21 * 82567LF-2 Gigabit Network Connection
22 * 82567V-2 Gigabit Network Connection
23 * 82567LF-3 Gigabit Network Connection
24 * 82567LM-3 Gigabit Network Connection
25 * 82567LM-4 Gigabit Network Connection
26 * 82577LM Gigabit Network Connection
27 * 82577LC Gigabit Network Connection
28 * 82578DM Gigabit Network Connection
29 * 82578DC Gigabit Network Connection
30 * 82579LM Gigabit Network Connection
31 * 82579V Gigabit Network Connection
32 * Ethernet Connection I217-LM
33 * Ethernet Connection I217-V
34 * Ethernet Connection I218-V
35 * Ethernet Connection I218-LM
36 * Ethernet Connection (2) I218-LM
37 * Ethernet Connection (2) I218-V
38 * Ethernet Connection (3) I218-LM
39 * Ethernet Connection (3) I218-V
42 #include "e1000_api.h"
44 STATIC s32 e1000_oem_bits_config_ich8lan(struct e1000_hw *hw, bool d0_state);
45 STATIC s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw);
46 STATIC void e1000_release_swflag_ich8lan(struct e1000_hw *hw);
47 STATIC s32 e1000_acquire_nvm_ich8lan(struct e1000_hw *hw);
48 STATIC void e1000_release_nvm_ich8lan(struct e1000_hw *hw);
49 STATIC bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw);
50 STATIC bool e1000_check_mng_mode_pchlan(struct e1000_hw *hw);
51 STATIC int e1000_rar_set_pch2lan(struct e1000_hw *hw, u8 *addr, u32 index);
52 STATIC int e1000_rar_set_pch_lpt(struct e1000_hw *hw, u8 *addr, u32 index);
53 STATIC s32 e1000_sw_lcd_config_ich8lan(struct e1000_hw *hw);
54 STATIC void e1000_update_mc_addr_list_pch2lan(struct e1000_hw *hw,
57 STATIC s32 e1000_check_reset_block_ich8lan(struct e1000_hw *hw);
58 STATIC s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw);
59 STATIC s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active);
60 STATIC s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw,
62 STATIC s32 e1000_set_d3_lplu_state_ich8lan(struct e1000_hw *hw,
64 STATIC s32 e1000_read_nvm_ich8lan(struct e1000_hw *hw, u16 offset,
65 u16 words, u16 *data);
66 STATIC s32 e1000_read_nvm_spt(struct e1000_hw *hw, u16 offset, u16 words,
68 STATIC s32 e1000_write_nvm_ich8lan(struct e1000_hw *hw, u16 offset,
69 u16 words, u16 *data);
70 STATIC s32 e1000_validate_nvm_checksum_ich8lan(struct e1000_hw *hw);
71 STATIC s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw);
72 STATIC s32 e1000_update_nvm_checksum_spt(struct e1000_hw *hw);
73 STATIC s32 e1000_valid_led_default_ich8lan(struct e1000_hw *hw,
75 STATIC s32 e1000_id_led_init_pchlan(struct e1000_hw *hw);
76 STATIC s32 e1000_get_bus_info_ich8lan(struct e1000_hw *hw);
77 STATIC s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw);
78 STATIC s32 e1000_init_hw_ich8lan(struct e1000_hw *hw);
79 STATIC s32 e1000_setup_link_ich8lan(struct e1000_hw *hw);
80 STATIC s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw);
81 STATIC s32 e1000_setup_copper_link_pch_lpt(struct e1000_hw *hw);
82 STATIC s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw,
83 u16 *speed, u16 *duplex);
84 STATIC s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw);
85 STATIC s32 e1000_led_on_ich8lan(struct e1000_hw *hw);
86 STATIC s32 e1000_led_off_ich8lan(struct e1000_hw *hw);
87 STATIC s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link);
88 STATIC s32 e1000_setup_led_pchlan(struct e1000_hw *hw);
89 STATIC s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw);
90 STATIC s32 e1000_led_on_pchlan(struct e1000_hw *hw);
91 STATIC s32 e1000_led_off_pchlan(struct e1000_hw *hw);
92 STATIC void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw);
93 STATIC s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank);
94 STATIC void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw);
95 STATIC s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw);
96 STATIC s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw,
97 u32 offset, u8 *data);
98 STATIC s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
100 STATIC s32 e1000_read_flash_data32_ich8lan(struct e1000_hw *hw, u32 offset,
102 STATIC s32 e1000_read_flash_dword_ich8lan(struct e1000_hw *hw,
103 u32 offset, u32 *data);
104 STATIC s32 e1000_write_flash_data32_ich8lan(struct e1000_hw *hw,
105 u32 offset, u32 data);
106 STATIC s32 e1000_retry_write_flash_dword_ich8lan(struct e1000_hw *hw,
107 u32 offset, u32 dword);
108 STATIC s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw,
109 u32 offset, u16 *data);
110 STATIC s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw,
111 u32 offset, u8 byte);
112 STATIC s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw);
113 STATIC void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw);
114 STATIC s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw);
115 STATIC s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw);
116 STATIC s32 e1000_k1_workaround_lv(struct e1000_hw *hw);
117 STATIC void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate);
119 /* ICH GbE Flash Hardware Sequencing Flash Status Register bit breakdown */
120 /* Offset 04h HSFSTS */
121 union ich8_hws_flash_status {
123 u16 flcdone:1; /* bit 0 Flash Cycle Done */
124 u16 flcerr:1; /* bit 1 Flash Cycle Error */
125 u16 dael:1; /* bit 2 Direct Access error Log */
126 u16 berasesz:2; /* bit 4:3 Sector Erase Size */
127 u16 flcinprog:1; /* bit 5 flash cycle in Progress */
128 u16 reserved1:2; /* bit 13:6 Reserved */
129 u16 reserved2:6; /* bit 13:6 Reserved */
130 u16 fldesvalid:1; /* bit 14 Flash Descriptor Valid */
131 u16 flockdn:1; /* bit 15 Flash Config Lock-Down */
136 /* ICH GbE Flash Hardware Sequencing Flash control Register bit breakdown */
137 /* Offset 06h FLCTL */
138 union ich8_hws_flash_ctrl {
139 struct ich8_hsflctl {
140 u16 flcgo:1; /* 0 Flash Cycle Go */
141 u16 flcycle:2; /* 2:1 Flash Cycle */
142 u16 reserved:5; /* 7:3 Reserved */
143 u16 fldbcount:2; /* 9:8 Flash Data Byte Count */
144 u16 flockdn:6; /* 15:10 Reserved */
149 /* ICH Flash Region Access Permissions */
150 union ich8_hws_flash_regacc {
152 u32 grra:8; /* 0:7 GbE region Read Access */
153 u32 grwa:8; /* 8:15 GbE region Write Access */
154 u32 gmrag:8; /* 23:16 GbE Master Read Access Grant */
155 u32 gmwag:8; /* 31:24 GbE Master Write Access Grant */
161 * e1000_phy_is_accessible_pchlan - Check if able to access PHY registers
162 * @hw: pointer to the HW structure
164 * Test access to the PHY registers by reading the PHY ID registers. If
165 * the PHY ID is already known (e.g. resume path) compare it with known ID,
166 * otherwise assume the read PHY ID is correct if it is valid.
168 * Assumes the sw/fw/hw semaphore is already acquired.
170 STATIC bool e1000_phy_is_accessible_pchlan(struct e1000_hw *hw)
178 for (retry_count = 0; retry_count < 2; retry_count++) {
179 ret_val = hw->phy.ops.read_reg_locked(hw, PHY_ID1, &phy_reg);
180 if (ret_val || (phy_reg == 0xFFFF))
182 phy_id = (u32)(phy_reg << 16);
184 ret_val = hw->phy.ops.read_reg_locked(hw, PHY_ID2, &phy_reg);
185 if (ret_val || (phy_reg == 0xFFFF)) {
189 phy_id |= (u32)(phy_reg & PHY_REVISION_MASK);
194 if (hw->phy.id == phy_id)
198 hw->phy.revision = (u32)(phy_reg & ~PHY_REVISION_MASK);
202 /* In case the PHY needs to be in mdio slow mode,
203 * set slow mode and try to get the PHY id again.
205 if (hw->mac.type < e1000_pch_lpt) {
206 hw->phy.ops.release(hw);
207 ret_val = e1000_set_mdio_slow_mode_hv(hw);
209 ret_val = e1000_get_phy_id(hw);
210 hw->phy.ops.acquire(hw);
216 if (hw->mac.type >= e1000_pch_lpt) {
217 /* Only unforce SMBus if ME is not active */
218 if (!(E1000_READ_REG(hw, E1000_FWSM) &
219 E1000_ICH_FWSM_FW_VALID)) {
220 /* Unforce SMBus mode in PHY */
221 hw->phy.ops.read_reg_locked(hw, CV_SMB_CTRL, &phy_reg);
222 phy_reg &= ~CV_SMB_CTRL_FORCE_SMBUS;
223 hw->phy.ops.write_reg_locked(hw, CV_SMB_CTRL, phy_reg);
225 /* Unforce SMBus mode in MAC */
226 mac_reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
227 mac_reg &= ~E1000_CTRL_EXT_FORCE_SMBUS;
228 E1000_WRITE_REG(hw, E1000_CTRL_EXT, mac_reg);
236 * e1000_toggle_lanphypc_pch_lpt - toggle the LANPHYPC pin value
237 * @hw: pointer to the HW structure
239 * Toggling the LANPHYPC pin value fully power-cycles the PHY and is
240 * used to reset the PHY to a quiescent state when necessary.
242 STATIC void e1000_toggle_lanphypc_pch_lpt(struct e1000_hw *hw)
246 DEBUGFUNC("e1000_toggle_lanphypc_pch_lpt");
248 /* Set Phy Config Counter to 50msec */
249 mac_reg = E1000_READ_REG(hw, E1000_FEXTNVM3);
250 mac_reg &= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK;
251 mac_reg |= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC;
252 E1000_WRITE_REG(hw, E1000_FEXTNVM3, mac_reg);
254 /* Toggle LANPHYPC Value bit */
255 mac_reg = E1000_READ_REG(hw, E1000_CTRL);
256 mac_reg |= E1000_CTRL_LANPHYPC_OVERRIDE;
257 mac_reg &= ~E1000_CTRL_LANPHYPC_VALUE;
258 E1000_WRITE_REG(hw, E1000_CTRL, mac_reg);
259 E1000_WRITE_FLUSH(hw);
261 mac_reg &= ~E1000_CTRL_LANPHYPC_OVERRIDE;
262 E1000_WRITE_REG(hw, E1000_CTRL, mac_reg);
263 E1000_WRITE_FLUSH(hw);
265 if (hw->mac.type < e1000_pch_lpt) {
272 } while (!(E1000_READ_REG(hw, E1000_CTRL_EXT) &
273 E1000_CTRL_EXT_LPCD) && count--);
280 * e1000_init_phy_workarounds_pchlan - PHY initialization workarounds
281 * @hw: pointer to the HW structure
283 * Workarounds/flow necessary for PHY initialization during driver load
286 STATIC s32 e1000_init_phy_workarounds_pchlan(struct e1000_hw *hw)
288 u32 mac_reg, fwsm = E1000_READ_REG(hw, E1000_FWSM);
291 DEBUGFUNC("e1000_init_phy_workarounds_pchlan");
293 /* Gate automatic PHY configuration by hardware on managed and
294 * non-managed 82579 and newer adapters.
296 e1000_gate_hw_phy_config_ich8lan(hw, true);
298 /* It is not possible to be certain of the current state of ULP
299 * so forcibly disable it.
301 hw->dev_spec.ich8lan.ulp_state = e1000_ulp_state_unknown;
303 ret_val = hw->phy.ops.acquire(hw);
305 DEBUGOUT("Failed to initialize PHY flow\n");
309 /* The MAC-PHY interconnect may be in SMBus mode. If the PHY is
310 * inaccessible and resetting the PHY is not blocked, toggle the
311 * LANPHYPC Value bit to force the interconnect to PCIe mode.
313 switch (hw->mac.type) {
318 if (e1000_phy_is_accessible_pchlan(hw))
321 /* Before toggling LANPHYPC, see if PHY is accessible by
322 * forcing MAC to SMBus mode first.
324 mac_reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
325 mac_reg |= E1000_CTRL_EXT_FORCE_SMBUS;
326 E1000_WRITE_REG(hw, E1000_CTRL_EXT, mac_reg);
328 /* Wait 50 milliseconds for MAC to finish any retries
329 * that it might be trying to perform from previous
330 * attempts to acknowledge any phy read requests.
336 if (e1000_phy_is_accessible_pchlan(hw))
341 if ((hw->mac.type == e1000_pchlan) &&
342 (fwsm & E1000_ICH_FWSM_FW_VALID))
345 if (hw->phy.ops.check_reset_block(hw)) {
346 DEBUGOUT("Required LANPHYPC toggle blocked by ME\n");
347 ret_val = -E1000_ERR_PHY;
351 /* Toggle LANPHYPC Value bit */
352 e1000_toggle_lanphypc_pch_lpt(hw);
353 if (hw->mac.type >= e1000_pch_lpt) {
354 if (e1000_phy_is_accessible_pchlan(hw))
357 /* Toggling LANPHYPC brings the PHY out of SMBus mode
358 * so ensure that the MAC is also out of SMBus mode
360 mac_reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
361 mac_reg &= ~E1000_CTRL_EXT_FORCE_SMBUS;
362 E1000_WRITE_REG(hw, E1000_CTRL_EXT, mac_reg);
364 if (e1000_phy_is_accessible_pchlan(hw))
367 ret_val = -E1000_ERR_PHY;
374 hw->phy.ops.release(hw);
377 /* Check to see if able to reset PHY. Print error if not */
378 if (hw->phy.ops.check_reset_block(hw)) {
379 ERROR_REPORT("Reset blocked by ME\n");
383 /* Reset the PHY before any access to it. Doing so, ensures
384 * that the PHY is in a known good state before we read/write
385 * PHY registers. The generic reset is sufficient here,
386 * because we haven't determined the PHY type yet.
388 ret_val = e1000_phy_hw_reset_generic(hw);
392 /* On a successful reset, possibly need to wait for the PHY
393 * to quiesce to an accessible state before returning control
394 * to the calling function. If the PHY does not quiesce, then
395 * return E1000E_BLK_PHY_RESET, as this is the condition that
398 ret_val = hw->phy.ops.check_reset_block(hw);
400 ERROR_REPORT("ME blocked access to PHY after reset\n");
404 /* Ungate automatic PHY configuration on non-managed 82579 */
405 if ((hw->mac.type == e1000_pch2lan) &&
406 !(fwsm & E1000_ICH_FWSM_FW_VALID)) {
408 e1000_gate_hw_phy_config_ich8lan(hw, false);
415 * e1000_init_phy_params_pchlan - Initialize PHY function pointers
416 * @hw: pointer to the HW structure
418 * Initialize family-specific PHY parameters and function pointers.
420 STATIC s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw)
422 struct e1000_phy_info *phy = &hw->phy;
425 DEBUGFUNC("e1000_init_phy_params_pchlan");
428 phy->reset_delay_us = 100;
430 phy->ops.acquire = e1000_acquire_swflag_ich8lan;
431 phy->ops.check_reset_block = e1000_check_reset_block_ich8lan;
432 phy->ops.get_cfg_done = e1000_get_cfg_done_ich8lan;
433 phy->ops.set_page = e1000_set_page_igp;
434 phy->ops.read_reg = e1000_read_phy_reg_hv;
435 phy->ops.read_reg_locked = e1000_read_phy_reg_hv_locked;
436 phy->ops.read_reg_page = e1000_read_phy_reg_page_hv;
437 phy->ops.release = e1000_release_swflag_ich8lan;
438 phy->ops.reset = e1000_phy_hw_reset_ich8lan;
439 phy->ops.set_d0_lplu_state = e1000_set_lplu_state_pchlan;
440 phy->ops.set_d3_lplu_state = e1000_set_lplu_state_pchlan;
441 phy->ops.write_reg = e1000_write_phy_reg_hv;
442 phy->ops.write_reg_locked = e1000_write_phy_reg_hv_locked;
443 phy->ops.write_reg_page = e1000_write_phy_reg_page_hv;
444 phy->ops.power_up = e1000_power_up_phy_copper;
445 phy->ops.power_down = e1000_power_down_phy_copper_ich8lan;
446 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
448 phy->id = e1000_phy_unknown;
450 ret_val = e1000_init_phy_workarounds_pchlan(hw);
454 if (phy->id == e1000_phy_unknown)
455 switch (hw->mac.type) {
457 ret_val = e1000_get_phy_id(hw);
460 if ((phy->id != 0) && (phy->id != PHY_REVISION_MASK))
468 /* In case the PHY needs to be in mdio slow mode,
469 * set slow mode and try to get the PHY id again.
471 ret_val = e1000_set_mdio_slow_mode_hv(hw);
474 ret_val = e1000_get_phy_id(hw);
479 phy->type = e1000_get_phy_type_from_id(phy->id);
482 case e1000_phy_82577:
483 case e1000_phy_82579:
485 phy->ops.check_polarity = e1000_check_polarity_82577;
486 phy->ops.force_speed_duplex =
487 e1000_phy_force_speed_duplex_82577;
488 phy->ops.get_cable_length = e1000_get_cable_length_82577;
489 phy->ops.get_info = e1000_get_phy_info_82577;
490 phy->ops.commit = e1000_phy_sw_reset_generic;
492 case e1000_phy_82578:
493 phy->ops.check_polarity = e1000_check_polarity_m88;
494 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_m88;
495 phy->ops.get_cable_length = e1000_get_cable_length_m88;
496 phy->ops.get_info = e1000_get_phy_info_m88;
499 ret_val = -E1000_ERR_PHY;
507 * e1000_init_phy_params_ich8lan - Initialize PHY function pointers
508 * @hw: pointer to the HW structure
510 * Initialize family-specific PHY parameters and function pointers.
512 STATIC s32 e1000_init_phy_params_ich8lan(struct e1000_hw *hw)
514 struct e1000_phy_info *phy = &hw->phy;
518 DEBUGFUNC("e1000_init_phy_params_ich8lan");
521 phy->reset_delay_us = 100;
523 phy->ops.acquire = e1000_acquire_swflag_ich8lan;
524 phy->ops.check_reset_block = e1000_check_reset_block_ich8lan;
525 phy->ops.get_cable_length = e1000_get_cable_length_igp_2;
526 phy->ops.get_cfg_done = e1000_get_cfg_done_ich8lan;
527 phy->ops.read_reg = e1000_read_phy_reg_igp;
528 phy->ops.release = e1000_release_swflag_ich8lan;
529 phy->ops.reset = e1000_phy_hw_reset_ich8lan;
530 phy->ops.set_d0_lplu_state = e1000_set_d0_lplu_state_ich8lan;
531 phy->ops.set_d3_lplu_state = e1000_set_d3_lplu_state_ich8lan;
532 phy->ops.write_reg = e1000_write_phy_reg_igp;
533 phy->ops.power_up = e1000_power_up_phy_copper;
534 phy->ops.power_down = e1000_power_down_phy_copper_ich8lan;
536 /* We may need to do this twice - once for IGP and if that fails,
537 * we'll set BM func pointers and try again
539 ret_val = e1000_determine_phy_address(hw);
541 phy->ops.write_reg = e1000_write_phy_reg_bm;
542 phy->ops.read_reg = e1000_read_phy_reg_bm;
543 ret_val = e1000_determine_phy_address(hw);
545 DEBUGOUT("Cannot determine PHY addr. Erroring out\n");
551 while ((e1000_phy_unknown == e1000_get_phy_type_from_id(phy->id)) &&
554 ret_val = e1000_get_phy_id(hw);
561 case IGP03E1000_E_PHY_ID:
562 phy->type = e1000_phy_igp_3;
563 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
564 phy->ops.read_reg_locked = e1000_read_phy_reg_igp_locked;
565 phy->ops.write_reg_locked = e1000_write_phy_reg_igp_locked;
566 phy->ops.get_info = e1000_get_phy_info_igp;
567 phy->ops.check_polarity = e1000_check_polarity_igp;
568 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_igp;
571 case IFE_PLUS_E_PHY_ID:
573 phy->type = e1000_phy_ife;
574 phy->autoneg_mask = E1000_ALL_NOT_GIG;
575 phy->ops.get_info = e1000_get_phy_info_ife;
576 phy->ops.check_polarity = e1000_check_polarity_ife;
577 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_ife;
579 case BME1000_E_PHY_ID:
580 phy->type = e1000_phy_bm;
581 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
582 phy->ops.read_reg = e1000_read_phy_reg_bm;
583 phy->ops.write_reg = e1000_write_phy_reg_bm;
584 phy->ops.commit = e1000_phy_sw_reset_generic;
585 phy->ops.get_info = e1000_get_phy_info_m88;
586 phy->ops.check_polarity = e1000_check_polarity_m88;
587 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_m88;
590 return -E1000_ERR_PHY;
594 return E1000_SUCCESS;
598 * e1000_init_nvm_params_ich8lan - Initialize NVM function pointers
599 * @hw: pointer to the HW structure
601 * Initialize family-specific NVM parameters and function
604 STATIC s32 e1000_init_nvm_params_ich8lan(struct e1000_hw *hw)
606 struct e1000_nvm_info *nvm = &hw->nvm;
607 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
608 u32 gfpreg, sector_base_addr, sector_end_addr;
612 DEBUGFUNC("e1000_init_nvm_params_ich8lan");
614 nvm->type = e1000_nvm_flash_sw;
616 if (hw->mac.type >= e1000_pch_spt) {
617 /* in SPT, gfpreg doesn't exist. NVM size is taken from the
618 * STRAP register. This is because in SPT the GbE Flash region
619 * is no longer accessed through the flash registers. Instead,
620 * the mechanism has changed, and the Flash region access
621 * registers are now implemented in GbE memory space.
623 nvm->flash_base_addr = 0;
625 (((E1000_READ_REG(hw, E1000_STRAP) >> 1) & 0x1F) + 1)
626 * NVM_SIZE_MULTIPLIER;
627 nvm->flash_bank_size = nvm_size / 2;
628 /* Adjust to word count */
629 nvm->flash_bank_size /= sizeof(u16);
630 /* Set the base address for flash register access */
631 hw->flash_address = hw->hw_addr + E1000_FLASH_BASE_ADDR;
633 /* Can't read flash registers if register set isn't mapped. */
634 if (!hw->flash_address) {
635 DEBUGOUT("ERROR: Flash registers not mapped\n");
636 return -E1000_ERR_CONFIG;
639 gfpreg = E1000_READ_FLASH_REG(hw, ICH_FLASH_GFPREG);
641 /* sector_X_addr is a "sector"-aligned address (4096 bytes)
642 * Add 1 to sector_end_addr since this sector is included in
645 sector_base_addr = gfpreg & FLASH_GFPREG_BASE_MASK;
646 sector_end_addr = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK) + 1;
648 /* flash_base_addr is byte-aligned */
649 nvm->flash_base_addr = sector_base_addr
650 << FLASH_SECTOR_ADDR_SHIFT;
652 /* find total size of the NVM, then cut in half since the total
653 * size represents two separate NVM banks.
655 nvm->flash_bank_size = ((sector_end_addr - sector_base_addr)
656 << FLASH_SECTOR_ADDR_SHIFT);
657 nvm->flash_bank_size /= 2;
658 /* Adjust to word count */
659 nvm->flash_bank_size /= sizeof(u16);
662 nvm->word_size = E1000_SHADOW_RAM_WORDS;
664 /* Clear shadow ram */
665 for (i = 0; i < nvm->word_size; i++) {
666 dev_spec->shadow_ram[i].modified = false;
667 dev_spec->shadow_ram[i].value = 0xFFFF;
670 E1000_MUTEX_INIT(&dev_spec->nvm_mutex);
671 E1000_MUTEX_INIT(&dev_spec->swflag_mutex);
673 /* Function Pointers */
674 nvm->ops.acquire = e1000_acquire_nvm_ich8lan;
675 nvm->ops.release = e1000_release_nvm_ich8lan;
676 if (hw->mac.type >= e1000_pch_spt) {
677 nvm->ops.read = e1000_read_nvm_spt;
678 nvm->ops.update = e1000_update_nvm_checksum_spt;
680 nvm->ops.read = e1000_read_nvm_ich8lan;
681 nvm->ops.update = e1000_update_nvm_checksum_ich8lan;
683 nvm->ops.valid_led_default = e1000_valid_led_default_ich8lan;
684 nvm->ops.validate = e1000_validate_nvm_checksum_ich8lan;
685 nvm->ops.write = e1000_write_nvm_ich8lan;
687 return E1000_SUCCESS;
691 * e1000_init_mac_params_ich8lan - Initialize MAC function pointers
692 * @hw: pointer to the HW structure
694 * Initialize family-specific MAC parameters and function
697 STATIC s32 e1000_init_mac_params_ich8lan(struct e1000_hw *hw)
699 struct e1000_mac_info *mac = &hw->mac;
702 DEBUGFUNC("e1000_init_mac_params_ich8lan");
704 /* Set media type function pointer */
705 hw->phy.media_type = e1000_media_type_copper;
707 /* Set mta register count */
708 mac->mta_reg_count = 32;
709 /* Set rar entry count */
710 mac->rar_entry_count = E1000_ICH_RAR_ENTRIES;
711 if (mac->type == e1000_ich8lan)
712 mac->rar_entry_count--;
713 /* Set if part includes ASF firmware */
714 mac->asf_firmware_present = true;
716 mac->has_fwsm = true;
717 /* ARC subsystem not supported */
718 mac->arc_subsystem_valid = false;
719 /* Adaptive IFS supported */
720 mac->adaptive_ifs = true;
722 /* Function pointers */
724 /* bus type/speed/width */
725 mac->ops.get_bus_info = e1000_get_bus_info_ich8lan;
727 mac->ops.set_lan_id = e1000_set_lan_id_single_port;
729 mac->ops.reset_hw = e1000_reset_hw_ich8lan;
730 /* hw initialization */
731 mac->ops.init_hw = e1000_init_hw_ich8lan;
733 mac->ops.setup_link = e1000_setup_link_ich8lan;
734 /* physical interface setup */
735 mac->ops.setup_physical_interface = e1000_setup_copper_link_ich8lan;
737 mac->ops.check_for_link = e1000_check_for_copper_link_ich8lan;
739 mac->ops.get_link_up_info = e1000_get_link_up_info_ich8lan;
740 /* multicast address update */
741 mac->ops.update_mc_addr_list = e1000_update_mc_addr_list_generic;
742 /* clear hardware counters */
743 mac->ops.clear_hw_cntrs = e1000_clear_hw_cntrs_ich8lan;
745 /* LED and other operations */
750 /* check management mode */
751 mac->ops.check_mng_mode = e1000_check_mng_mode_ich8lan;
753 mac->ops.id_led_init = e1000_id_led_init_generic;
755 mac->ops.blink_led = e1000_blink_led_generic;
757 mac->ops.setup_led = e1000_setup_led_generic;
759 mac->ops.cleanup_led = e1000_cleanup_led_ich8lan;
760 /* turn on/off LED */
761 mac->ops.led_on = e1000_led_on_ich8lan;
762 mac->ops.led_off = e1000_led_off_ich8lan;
765 mac->rar_entry_count = E1000_PCH2_RAR_ENTRIES;
766 mac->ops.rar_set = e1000_rar_set_pch2lan;
772 /* multicast address update for pch2 */
773 mac->ops.update_mc_addr_list =
774 e1000_update_mc_addr_list_pch2lan;
777 /* save PCH revision_id */
778 e1000_read_pci_cfg(hw, E1000_PCI_REVISION_ID_REG, &pci_cfg);
779 /* SPT uses full byte for revision ID,
780 * as opposed to previous generations
782 if (hw->mac.type >= e1000_pch_spt)
783 hw->revision_id = (u8)(pci_cfg &= 0x00FF);
785 hw->revision_id = (u8)(pci_cfg &= 0x000F);
786 /* check management mode */
787 mac->ops.check_mng_mode = e1000_check_mng_mode_pchlan;
789 mac->ops.id_led_init = e1000_id_led_init_pchlan;
791 mac->ops.setup_led = e1000_setup_led_pchlan;
793 mac->ops.cleanup_led = e1000_cleanup_led_pchlan;
794 /* turn on/off LED */
795 mac->ops.led_on = e1000_led_on_pchlan;
796 mac->ops.led_off = e1000_led_off_pchlan;
802 if (mac->type >= e1000_pch_lpt) {
803 mac->rar_entry_count = E1000_PCH_LPT_RAR_ENTRIES;
804 mac->ops.rar_set = e1000_rar_set_pch_lpt;
805 mac->ops.setup_physical_interface = e1000_setup_copper_link_pch_lpt;
808 /* Enable PCS Lock-loss workaround for ICH8 */
809 if (mac->type == e1000_ich8lan)
810 e1000_set_kmrn_lock_loss_workaround_ich8lan(hw, true);
812 return E1000_SUCCESS;
816 * __e1000_access_emi_reg_locked - Read/write EMI register
817 * @hw: pointer to the HW structure
818 * @address: EMI address to program
819 * @data: pointer to value to read/write from/to the EMI address
820 * @read: boolean flag to indicate read or write
822 * This helper function assumes the SW/FW/HW Semaphore is already acquired.
824 STATIC s32 __e1000_access_emi_reg_locked(struct e1000_hw *hw, u16 address,
825 u16 *data, bool read)
829 DEBUGFUNC("__e1000_access_emi_reg_locked");
831 ret_val = hw->phy.ops.write_reg_locked(hw, I82579_EMI_ADDR, address);
836 ret_val = hw->phy.ops.read_reg_locked(hw, I82579_EMI_DATA,
839 ret_val = hw->phy.ops.write_reg_locked(hw, I82579_EMI_DATA,
846 * e1000_read_emi_reg_locked - Read Extended Management Interface register
847 * @hw: pointer to the HW structure
848 * @addr: EMI address to program
849 * @data: value to be read from the EMI address
851 * Assumes the SW/FW/HW Semaphore is already acquired.
853 s32 e1000_read_emi_reg_locked(struct e1000_hw *hw, u16 addr, u16 *data)
855 DEBUGFUNC("e1000_read_emi_reg_locked");
857 return __e1000_access_emi_reg_locked(hw, addr, data, true);
861 * e1000_write_emi_reg_locked - Write Extended Management Interface register
862 * @hw: pointer to the HW structure
863 * @addr: EMI address to program
864 * @data: value to be written to the EMI address
866 * Assumes the SW/FW/HW Semaphore is already acquired.
868 s32 e1000_write_emi_reg_locked(struct e1000_hw *hw, u16 addr, u16 data)
870 DEBUGFUNC("e1000_read_emi_reg_locked");
872 return __e1000_access_emi_reg_locked(hw, addr, &data, false);
876 * e1000_set_eee_pchlan - Enable/disable EEE support
877 * @hw: pointer to the HW structure
879 * Enable/disable EEE based on setting in dev_spec structure, the duplex of
880 * the link and the EEE capabilities of the link partner. The LPI Control
881 * register bits will remain set only if/when link is up.
883 * EEE LPI must not be asserted earlier than one second after link is up.
884 * On 82579, EEE LPI should not be enabled until such time otherwise there
885 * can be link issues with some switches. Other devices can have EEE LPI
886 * enabled immediately upon link up since they have a timer in hardware which
887 * prevents LPI from being asserted too early.
889 s32 e1000_set_eee_pchlan(struct e1000_hw *hw)
891 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
893 u16 lpa, pcs_status, adv, adv_addr, lpi_ctrl, data;
895 DEBUGFUNC("e1000_set_eee_pchlan");
897 switch (hw->phy.type) {
898 case e1000_phy_82579:
899 lpa = I82579_EEE_LP_ABILITY;
900 pcs_status = I82579_EEE_PCS_STATUS;
901 adv_addr = I82579_EEE_ADVERTISEMENT;
904 lpa = I217_EEE_LP_ABILITY;
905 pcs_status = I217_EEE_PCS_STATUS;
906 adv_addr = I217_EEE_ADVERTISEMENT;
909 return E1000_SUCCESS;
912 ret_val = hw->phy.ops.acquire(hw);
916 ret_val = hw->phy.ops.read_reg_locked(hw, I82579_LPI_CTRL, &lpi_ctrl);
920 /* Clear bits that enable EEE in various speeds */
921 lpi_ctrl &= ~I82579_LPI_CTRL_ENABLE_MASK;
923 /* Enable EEE if not disabled by user */
924 if (!dev_spec->eee_disable) {
925 /* Save off link partner's EEE ability */
926 ret_val = e1000_read_emi_reg_locked(hw, lpa,
927 &dev_spec->eee_lp_ability);
931 /* Read EEE advertisement */
932 ret_val = e1000_read_emi_reg_locked(hw, adv_addr, &adv);
936 /* Enable EEE only for speeds in which the link partner is
937 * EEE capable and for which we advertise EEE.
939 if (adv & dev_spec->eee_lp_ability & I82579_EEE_1000_SUPPORTED)
940 lpi_ctrl |= I82579_LPI_CTRL_1000_ENABLE;
942 if (adv & dev_spec->eee_lp_ability & I82579_EEE_100_SUPPORTED) {
943 hw->phy.ops.read_reg_locked(hw, PHY_LP_ABILITY, &data);
944 if (data & NWAY_LPAR_100TX_FD_CAPS)
945 lpi_ctrl |= I82579_LPI_CTRL_100_ENABLE;
947 /* EEE is not supported in 100Half, so ignore
948 * partner's EEE in 100 ability if full-duplex
951 dev_spec->eee_lp_ability &=
952 ~I82579_EEE_100_SUPPORTED;
956 if (hw->phy.type == e1000_phy_82579) {
957 ret_val = e1000_read_emi_reg_locked(hw, I82579_LPI_PLL_SHUT,
962 data &= ~I82579_LPI_100_PLL_SHUT;
963 ret_val = e1000_write_emi_reg_locked(hw, I82579_LPI_PLL_SHUT,
967 /* R/Clr IEEE MMD 3.1 bits 11:10 - Tx/Rx LPI Received */
968 ret_val = e1000_read_emi_reg_locked(hw, pcs_status, &data);
972 ret_val = hw->phy.ops.write_reg_locked(hw, I82579_LPI_CTRL, lpi_ctrl);
974 hw->phy.ops.release(hw);
980 * e1000_k1_workaround_lpt_lp - K1 workaround on Lynxpoint-LP
981 * @hw: pointer to the HW structure
982 * @link: link up bool flag
984 * When K1 is enabled for 1Gbps, the MAC can miss 2 DMA completion indications
985 * preventing further DMA write requests. Workaround the issue by disabling
986 * the de-assertion of the clock request when in 1Gpbs mode.
987 * Also, set appropriate Tx re-transmission timeouts for 10 and 100Half link
988 * speeds in order to avoid Tx hangs.
990 STATIC s32 e1000_k1_workaround_lpt_lp(struct e1000_hw *hw, bool link)
992 u32 fextnvm6 = E1000_READ_REG(hw, E1000_FEXTNVM6);
993 u32 status = E1000_READ_REG(hw, E1000_STATUS);
994 s32 ret_val = E1000_SUCCESS;
997 if (link && (status & E1000_STATUS_SPEED_1000)) {
998 ret_val = hw->phy.ops.acquire(hw);
1003 e1000_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
1009 e1000_write_kmrn_reg_locked(hw,
1010 E1000_KMRNCTRLSTA_K1_CONFIG,
1012 ~E1000_KMRNCTRLSTA_K1_ENABLE);
1018 E1000_WRITE_REG(hw, E1000_FEXTNVM6,
1019 fextnvm6 | E1000_FEXTNVM6_REQ_PLL_CLK);
1022 e1000_write_kmrn_reg_locked(hw,
1023 E1000_KMRNCTRLSTA_K1_CONFIG,
1026 hw->phy.ops.release(hw);
1028 /* clear FEXTNVM6 bit 8 on link down or 10/100 */
1029 fextnvm6 &= ~E1000_FEXTNVM6_REQ_PLL_CLK;
1031 if ((hw->phy.revision > 5) || !link ||
1032 ((status & E1000_STATUS_SPEED_100) &&
1033 (status & E1000_STATUS_FD)))
1034 goto update_fextnvm6;
1036 ret_val = hw->phy.ops.read_reg(hw, I217_INBAND_CTRL, ®);
1040 /* Clear link status transmit timeout */
1041 reg &= ~I217_INBAND_CTRL_LINK_STAT_TX_TIMEOUT_MASK;
1043 if (status & E1000_STATUS_SPEED_100) {
1044 /* Set inband Tx timeout to 5x10us for 100Half */
1045 reg |= 5 << I217_INBAND_CTRL_LINK_STAT_TX_TIMEOUT_SHIFT;
1047 /* Do not extend the K1 entry latency for 100Half */
1048 fextnvm6 &= ~E1000_FEXTNVM6_ENABLE_K1_ENTRY_CONDITION;
1050 /* Set inband Tx timeout to 50x10us for 10Full/Half */
1052 I217_INBAND_CTRL_LINK_STAT_TX_TIMEOUT_SHIFT;
1054 /* Extend the K1 entry latency for 10 Mbps */
1055 fextnvm6 |= E1000_FEXTNVM6_ENABLE_K1_ENTRY_CONDITION;
1058 ret_val = hw->phy.ops.write_reg(hw, I217_INBAND_CTRL, reg);
1063 E1000_WRITE_REG(hw, E1000_FEXTNVM6, fextnvm6);
1070 * e1000_enable_ulp_lpt_lp - configure Ultra Low Power mode for LynxPoint-LP
1071 * @hw: pointer to the HW structure
1072 * @to_sx: boolean indicating a system power state transition to Sx
1074 * When link is down, configure ULP mode to significantly reduce the power
1075 * to the PHY. If on a Manageability Engine (ME) enabled system, tell the
1076 * ME firmware to start the ULP configuration. If not on an ME enabled
1077 * system, configure the ULP mode by software.
1079 s32 e1000_enable_ulp_lpt_lp(struct e1000_hw *hw, bool to_sx)
1082 s32 ret_val = E1000_SUCCESS;
1086 if ((hw->mac.type < e1000_pch_lpt) ||
1087 (hw->device_id == E1000_DEV_ID_PCH_LPT_I217_LM) ||
1088 (hw->device_id == E1000_DEV_ID_PCH_LPT_I217_V) ||
1089 (hw->device_id == E1000_DEV_ID_PCH_I218_LM2) ||
1090 (hw->device_id == E1000_DEV_ID_PCH_I218_V2) ||
1091 (hw->dev_spec.ich8lan.ulp_state == e1000_ulp_state_on))
1096 /* Poll up to 5 seconds for Cable Disconnected indication */
1097 while (!(E1000_READ_REG(hw, E1000_FEXT) &
1098 E1000_FEXT_PHY_CABLE_DISCONNECTED)) {
1099 /* Bail if link is re-acquired */
1100 if (E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU)
1101 return -E1000_ERR_PHY;
1107 DEBUGOUT2("CABLE_DISCONNECTED %s set after %dmsec\n",
1108 (E1000_READ_REG(hw, E1000_FEXT) &
1109 E1000_FEXT_PHY_CABLE_DISCONNECTED) ? "" : "not",
1111 if (!(E1000_READ_REG(hw, E1000_FEXT) &
1112 E1000_FEXT_PHY_CABLE_DISCONNECTED))
1116 if (E1000_READ_REG(hw, E1000_FWSM) & E1000_ICH_FWSM_FW_VALID) {
1117 /* Request ME configure ULP mode in the PHY */
1118 mac_reg = E1000_READ_REG(hw, E1000_H2ME);
1119 mac_reg |= E1000_H2ME_ULP | E1000_H2ME_ENFORCE_SETTINGS;
1120 E1000_WRITE_REG(hw, E1000_H2ME, mac_reg);
1125 ret_val = hw->phy.ops.acquire(hw);
1129 /* During S0 Idle keep the phy in PCI-E mode */
1130 if (hw->dev_spec.ich8lan.smbus_disable)
1133 /* Force SMBus mode in PHY */
1134 ret_val = e1000_read_phy_reg_hv_locked(hw, CV_SMB_CTRL, &phy_reg);
1137 phy_reg |= CV_SMB_CTRL_FORCE_SMBUS;
1138 e1000_write_phy_reg_hv_locked(hw, CV_SMB_CTRL, phy_reg);
1140 /* Force SMBus mode in MAC */
1141 mac_reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
1142 mac_reg |= E1000_CTRL_EXT_FORCE_SMBUS;
1143 E1000_WRITE_REG(hw, E1000_CTRL_EXT, mac_reg);
1145 /* Si workaround for ULP entry flow on i127/rev6 h/w. Enable
1146 * LPLU and disable Gig speed when entering ULP
1148 if ((hw->phy.type == e1000_phy_i217) && (hw->phy.revision == 6)) {
1149 ret_val = e1000_read_phy_reg_hv_locked(hw, HV_OEM_BITS,
1155 phy_reg |= HV_OEM_BITS_LPLU | HV_OEM_BITS_GBE_DIS;
1157 ret_val = e1000_write_phy_reg_hv_locked(hw, HV_OEM_BITS,
1166 /* Change the 'Link Status Change' interrupt to trigger
1167 * on 'Cable Status Change'
1169 ret_val = e1000_read_kmrn_reg_locked(hw,
1170 E1000_KMRNCTRLSTA_OP_MODES,
1174 phy_reg |= E1000_KMRNCTRLSTA_OP_MODES_LSC2CSC;
1175 e1000_write_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_OP_MODES,
1179 /* Set Inband ULP Exit, Reset to SMBus mode and
1180 * Disable SMBus Release on PERST# in PHY
1182 ret_val = e1000_read_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, &phy_reg);
1185 phy_reg |= (I218_ULP_CONFIG1_RESET_TO_SMBUS |
1186 I218_ULP_CONFIG1_DISABLE_SMB_PERST);
1188 if (E1000_READ_REG(hw, E1000_WUFC) & E1000_WUFC_LNKC)
1189 phy_reg |= I218_ULP_CONFIG1_WOL_HOST;
1191 phy_reg &= ~I218_ULP_CONFIG1_WOL_HOST;
1193 phy_reg |= I218_ULP_CONFIG1_STICKY_ULP;
1194 phy_reg &= ~I218_ULP_CONFIG1_INBAND_EXIT;
1196 phy_reg |= I218_ULP_CONFIG1_INBAND_EXIT;
1197 phy_reg &= ~I218_ULP_CONFIG1_STICKY_ULP;
1198 phy_reg &= ~I218_ULP_CONFIG1_WOL_HOST;
1200 e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
1202 /* Set Disable SMBus Release on PERST# in MAC */
1203 mac_reg = E1000_READ_REG(hw, E1000_FEXTNVM7);
1204 mac_reg |= E1000_FEXTNVM7_DISABLE_SMB_PERST;
1205 E1000_WRITE_REG(hw, E1000_FEXTNVM7, mac_reg);
1207 /* Commit ULP changes in PHY by starting auto ULP configuration */
1208 phy_reg |= I218_ULP_CONFIG1_START;
1209 e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
1212 /* Disable Tx so that the MAC doesn't send any (buffered)
1213 * packets to the PHY.
1215 mac_reg = E1000_READ_REG(hw, E1000_TCTL);
1216 mac_reg &= ~E1000_TCTL_EN;
1217 E1000_WRITE_REG(hw, E1000_TCTL, mac_reg);
1220 if ((hw->phy.type == e1000_phy_i217) && (hw->phy.revision == 6) &&
1221 to_sx && (E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU)) {
1222 ret_val = e1000_write_phy_reg_hv_locked(hw, HV_OEM_BITS,
1229 hw->phy.ops.release(hw);
1232 DEBUGOUT1("Error in ULP enable flow: %d\n", ret_val);
1234 hw->dev_spec.ich8lan.ulp_state = e1000_ulp_state_on;
1240 * e1000_disable_ulp_lpt_lp - unconfigure Ultra Low Power mode for LynxPoint-LP
1241 * @hw: pointer to the HW structure
1242 * @force: boolean indicating whether or not to force disabling ULP
1244 * Un-configure ULP mode when link is up, the system is transitioned from
1245 * Sx or the driver is unloaded. If on a Manageability Engine (ME) enabled
1246 * system, poll for an indication from ME that ULP has been un-configured.
1247 * If not on an ME enabled system, un-configure the ULP mode by software.
1249 * During nominal operation, this function is called when link is acquired
1250 * to disable ULP mode (force=false); otherwise, for example when unloading
1251 * the driver or during Sx->S0 transitions, this is called with force=true
1252 * to forcibly disable ULP.
1254 * When the cable is plugged in while the device is in D0, a Cable Status
1255 * Change interrupt is generated which causes this function to be called
1256 * to partially disable ULP mode and restart autonegotiation. This function
1257 * is then called again due to the resulting Link Status Change interrupt
1258 * to finish cleaning up after the ULP flow.
1260 s32 e1000_disable_ulp_lpt_lp(struct e1000_hw *hw, bool force)
1262 s32 ret_val = E1000_SUCCESS;
1263 u8 ulp_exit_timeout = 30;
1268 if ((hw->mac.type < e1000_pch_lpt) ||
1269 (hw->device_id == E1000_DEV_ID_PCH_LPT_I217_LM) ||
1270 (hw->device_id == E1000_DEV_ID_PCH_LPT_I217_V) ||
1271 (hw->device_id == E1000_DEV_ID_PCH_I218_LM2) ||
1272 (hw->device_id == E1000_DEV_ID_PCH_I218_V2) ||
1273 (hw->dev_spec.ich8lan.ulp_state == e1000_ulp_state_off))
1276 if (E1000_READ_REG(hw, E1000_FWSM) & E1000_ICH_FWSM_FW_VALID) {
1278 /* Request ME un-configure ULP mode in the PHY */
1279 mac_reg = E1000_READ_REG(hw, E1000_H2ME);
1280 mac_reg &= ~E1000_H2ME_ULP;
1281 mac_reg |= E1000_H2ME_ENFORCE_SETTINGS;
1282 E1000_WRITE_REG(hw, E1000_H2ME, mac_reg);
1285 if (hw->mac.type == e1000_pch_cnp)
1286 ulp_exit_timeout = 100;
1288 while (E1000_READ_REG(hw, E1000_FWSM) &
1289 E1000_FWSM_ULP_CFG_DONE) {
1290 if (i++ == ulp_exit_timeout) {
1291 ret_val = -E1000_ERR_PHY;
1297 DEBUGOUT1("ULP_CONFIG_DONE cleared after %dmsec\n", i * 10);
1300 mac_reg = E1000_READ_REG(hw, E1000_H2ME);
1301 mac_reg &= ~E1000_H2ME_ENFORCE_SETTINGS;
1302 E1000_WRITE_REG(hw, E1000_H2ME, mac_reg);
1304 /* Clear H2ME.ULP after ME ULP configuration */
1305 mac_reg = E1000_READ_REG(hw, E1000_H2ME);
1306 mac_reg &= ~E1000_H2ME_ULP;
1307 E1000_WRITE_REG(hw, E1000_H2ME, mac_reg);
1309 /* Restore link speed advertisements and restart
1312 if (hw->mac.autoneg) {
1313 ret_val = e1000_phy_setup_autoneg(hw);
1317 ret_val = e1000_setup_copper_link_generic(hw);
1321 ret_val = e1000_oem_bits_config_ich8lan(hw, true);
1327 ret_val = hw->phy.ops.acquire(hw);
1331 /* Revert the change to the 'Link Status Change'
1332 * interrupt to trigger on 'Cable Status Change'
1334 ret_val = e1000_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_OP_MODES,
1338 phy_reg &= ~E1000_KMRNCTRLSTA_OP_MODES_LSC2CSC;
1339 e1000_write_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_OP_MODES, phy_reg);
1342 /* Toggle LANPHYPC Value bit */
1343 e1000_toggle_lanphypc_pch_lpt(hw);
1345 /* Unforce SMBus mode in PHY */
1346 ret_val = e1000_read_phy_reg_hv_locked(hw, CV_SMB_CTRL, &phy_reg);
1348 /* The MAC might be in PCIe mode, so temporarily force to
1349 * SMBus mode in order to access the PHY.
1351 mac_reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
1352 mac_reg |= E1000_CTRL_EXT_FORCE_SMBUS;
1353 E1000_WRITE_REG(hw, E1000_CTRL_EXT, mac_reg);
1357 ret_val = e1000_read_phy_reg_hv_locked(hw, CV_SMB_CTRL,
1362 phy_reg &= ~CV_SMB_CTRL_FORCE_SMBUS;
1363 e1000_write_phy_reg_hv_locked(hw, CV_SMB_CTRL, phy_reg);
1365 /* Unforce SMBus mode in MAC */
1366 mac_reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
1367 mac_reg &= ~E1000_CTRL_EXT_FORCE_SMBUS;
1368 E1000_WRITE_REG(hw, E1000_CTRL_EXT, mac_reg);
1370 /* When ULP mode was previously entered, K1 was disabled by the
1371 * hardware. Re-Enable K1 in the PHY when exiting ULP.
1373 ret_val = e1000_read_phy_reg_hv_locked(hw, HV_PM_CTRL, &phy_reg);
1376 phy_reg |= HV_PM_CTRL_K1_ENABLE;
1377 e1000_write_phy_reg_hv_locked(hw, HV_PM_CTRL, phy_reg);
1379 /* Clear ULP enabled configuration */
1380 ret_val = e1000_read_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, &phy_reg);
1383 /* CSC interrupt received due to ULP Indication */
1384 if ((phy_reg & I218_ULP_CONFIG1_IND) || force) {
1385 phy_reg &= ~(I218_ULP_CONFIG1_IND |
1386 I218_ULP_CONFIG1_STICKY_ULP |
1387 I218_ULP_CONFIG1_RESET_TO_SMBUS |
1388 I218_ULP_CONFIG1_WOL_HOST |
1389 I218_ULP_CONFIG1_INBAND_EXIT |
1390 I218_ULP_CONFIG1_EN_ULP_LANPHYPC |
1391 I218_ULP_CONFIG1_DIS_CLR_STICKY_ON_PERST |
1392 I218_ULP_CONFIG1_DISABLE_SMB_PERST);
1393 e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
1395 /* Commit ULP changes by starting auto ULP configuration */
1396 phy_reg |= I218_ULP_CONFIG1_START;
1397 e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
1399 /* Clear Disable SMBus Release on PERST# in MAC */
1400 mac_reg = E1000_READ_REG(hw, E1000_FEXTNVM7);
1401 mac_reg &= ~E1000_FEXTNVM7_DISABLE_SMB_PERST;
1402 E1000_WRITE_REG(hw, E1000_FEXTNVM7, mac_reg);
1405 hw->phy.ops.release(hw);
1407 if (hw->mac.autoneg)
1408 e1000_phy_setup_autoneg(hw);
1410 e1000_setup_copper_link_generic(hw);
1412 e1000_sw_lcd_config_ich8lan(hw);
1414 e1000_oem_bits_config_ich8lan(hw, true);
1416 /* Set ULP state to unknown and return non-zero to
1417 * indicate no link (yet) and re-enter on the next LSC
1418 * to finish disabling ULP flow.
1420 hw->dev_spec.ich8lan.ulp_state =
1421 e1000_ulp_state_unknown;
1428 mac_reg = E1000_READ_REG(hw, E1000_TCTL);
1429 mac_reg |= E1000_TCTL_EN;
1430 E1000_WRITE_REG(hw, E1000_TCTL, mac_reg);
1433 hw->phy.ops.release(hw);
1435 hw->phy.ops.reset(hw);
1440 DEBUGOUT1("Error in ULP disable flow: %d\n", ret_val);
1442 hw->dev_spec.ich8lan.ulp_state = e1000_ulp_state_off;
1450 * e1000_check_for_copper_link_ich8lan - Check for link (Copper)
1451 * @hw: pointer to the HW structure
1453 * Checks to see of the link status of the hardware has changed. If a
1454 * change in link status has been detected, then we read the PHY registers
1455 * to get the current speed/duplex if link exists.
1457 STATIC s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw)
1459 struct e1000_mac_info *mac = &hw->mac;
1460 s32 ret_val, tipg_reg = 0;
1461 u16 emi_addr, emi_val = 0;
1465 DEBUGFUNC("e1000_check_for_copper_link_ich8lan");
1467 /* We only want to go out to the PHY registers to see if Auto-Neg
1468 * has completed and/or if our link status has changed. The
1469 * get_link_status flag is set upon receiving a Link Status
1470 * Change or Rx Sequence Error interrupt.
1472 if (!mac->get_link_status)
1473 return E1000_SUCCESS;
1475 if ((hw->mac.type < e1000_pch_lpt) ||
1476 (hw->device_id == E1000_DEV_ID_PCH_LPT_I217_LM) ||
1477 (hw->device_id == E1000_DEV_ID_PCH_LPT_I217_V)) {
1478 /* First we want to see if the MII Status Register reports
1479 * link. If so, then we want to get the current speed/duplex
1482 ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link);
1486 /* Check the MAC's STATUS register to determine link state
1487 * since the PHY could be inaccessible while in ULP mode.
1489 link = !!(E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU);
1491 ret_val = e1000_disable_ulp_lpt_lp(hw, false);
1493 ret_val = e1000_enable_ulp_lpt_lp(hw, false);
1498 if (hw->mac.type == e1000_pchlan) {
1499 ret_val = e1000_k1_gig_workaround_hv(hw, link);
1504 /* When connected at 10Mbps half-duplex, some parts are excessively
1505 * aggressive resulting in many collisions. To avoid this, increase
1506 * the IPG and reduce Rx latency in the PHY.
1508 if ((hw->mac.type >= e1000_pch2lan) && link) {
1511 e1000_get_speed_and_duplex_copper_generic(hw, &speed, &duplex);
1512 tipg_reg = E1000_READ_REG(hw, E1000_TIPG);
1513 tipg_reg &= ~E1000_TIPG_IPGT_MASK;
1515 if (duplex == HALF_DUPLEX && speed == SPEED_10) {
1517 /* Reduce Rx latency in analog PHY */
1519 } else if (hw->mac.type >= e1000_pch_spt &&
1520 duplex == FULL_DUPLEX && speed != SPEED_1000) {
1524 /* Roll back the default values */
1529 E1000_WRITE_REG(hw, E1000_TIPG, tipg_reg);
1531 ret_val = hw->phy.ops.acquire(hw);
1535 if (hw->mac.type == e1000_pch2lan)
1536 emi_addr = I82579_RX_CONFIG;
1538 emi_addr = I217_RX_CONFIG;
1539 ret_val = e1000_write_emi_reg_locked(hw, emi_addr, emi_val);
1542 if (hw->mac.type >= e1000_pch_lpt) {
1543 hw->phy.ops.read_reg_locked(hw, I217_PLL_CLOCK_GATE_REG,
1545 phy_reg &= ~I217_PLL_CLOCK_GATE_MASK;
1546 if (speed == SPEED_100 || speed == SPEED_10)
1550 hw->phy.ops.write_reg_locked(hw,
1551 I217_PLL_CLOCK_GATE_REG,
1554 if (speed == SPEED_1000) {
1555 hw->phy.ops.read_reg_locked(hw, HV_PM_CTRL,
1558 phy_reg |= HV_PM_CTRL_K1_CLK_REQ;
1560 hw->phy.ops.write_reg_locked(hw, HV_PM_CTRL,
1564 hw->phy.ops.release(hw);
1569 if (hw->mac.type >= e1000_pch_spt) {
1573 if (speed == SPEED_1000) {
1574 ret_val = hw->phy.ops.acquire(hw);
1578 ret_val = hw->phy.ops.read_reg_locked(hw,
1582 hw->phy.ops.release(hw);
1586 ptr_gap = (data & (0x3FF << 2)) >> 2;
1587 if (ptr_gap < 0x18) {
1588 data &= ~(0x3FF << 2);
1589 data |= (0x18 << 2);
1591 hw->phy.ops.write_reg_locked(hw,
1592 PHY_REG(776, 20), data);
1594 hw->phy.ops.release(hw);
1598 ret_val = hw->phy.ops.acquire(hw);
1602 ret_val = hw->phy.ops.write_reg_locked(hw,
1605 hw->phy.ops.release(hw);
1613 /* I217 Packet Loss issue:
1614 * ensure that FEXTNVM4 Beacon Duration is set correctly
1616 * Set the Beacon Duration for I217 to 8 usec
1618 if (hw->mac.type >= e1000_pch_lpt) {
1621 mac_reg = E1000_READ_REG(hw, E1000_FEXTNVM4);
1622 mac_reg &= ~E1000_FEXTNVM4_BEACON_DURATION_MASK;
1623 mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_8USEC;
1624 E1000_WRITE_REG(hw, E1000_FEXTNVM4, mac_reg);
1627 /* Work-around I218 hang issue */
1628 if ((hw->device_id == E1000_DEV_ID_PCH_LPTLP_I218_LM) ||
1629 (hw->device_id == E1000_DEV_ID_PCH_LPTLP_I218_V) ||
1630 (hw->device_id == E1000_DEV_ID_PCH_I218_LM3) ||
1631 (hw->device_id == E1000_DEV_ID_PCH_I218_V3)) {
1632 ret_val = e1000_k1_workaround_lpt_lp(hw, link);
1636 /* Clear link partner's EEE ability */
1637 hw->dev_spec.ich8lan.eee_lp_ability = 0;
1639 /* Configure K0s minimum time */
1640 if (hw->mac.type >= e1000_pch_lpt) {
1641 e1000_configure_k0s_lpt(hw, K1_ENTRY_LATENCY, K1_MIN_TIME);
1644 if (hw->mac.type >= e1000_pch_lpt) {
1645 u32 fextnvm6 = E1000_READ_REG(hw, E1000_FEXTNVM6);
1647 if (hw->mac.type == e1000_pch_spt) {
1648 /* FEXTNVM6 K1-off workaround - for SPT only */
1649 u32 pcieanacfg = E1000_READ_REG(hw, E1000_PCIEANACFG);
1651 if (pcieanacfg & E1000_FEXTNVM6_K1_OFF_ENABLE)
1652 fextnvm6 |= E1000_FEXTNVM6_K1_OFF_ENABLE;
1654 fextnvm6 &= ~E1000_FEXTNVM6_K1_OFF_ENABLE;
1657 if (hw->dev_spec.ich8lan.disable_k1_off == true)
1658 fextnvm6 &= ~E1000_FEXTNVM6_K1_OFF_ENABLE;
1660 E1000_WRITE_REG(hw, E1000_FEXTNVM6, fextnvm6);
1664 return E1000_SUCCESS; /* No link detected */
1666 mac->get_link_status = false;
1668 switch (hw->mac.type) {
1670 ret_val = e1000_k1_workaround_lv(hw);
1675 if (hw->phy.type == e1000_phy_82578) {
1676 ret_val = e1000_link_stall_workaround_hv(hw);
1681 /* Workaround for PCHx parts in half-duplex:
1682 * Set the number of preambles removed from the packet
1683 * when it is passed from the PHY to the MAC to prevent
1684 * the MAC from misinterpreting the packet type.
1686 hw->phy.ops.read_reg(hw, HV_KMRN_FIFO_CTRLSTA, &phy_reg);
1687 phy_reg &= ~HV_KMRN_FIFO_CTRLSTA_PREAMBLE_MASK;
1689 if ((E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_FD) !=
1691 phy_reg |= (1 << HV_KMRN_FIFO_CTRLSTA_PREAMBLE_SHIFT);
1693 hw->phy.ops.write_reg(hw, HV_KMRN_FIFO_CTRLSTA, phy_reg);
1699 /* Check if there was DownShift, must be checked
1700 * immediately after link-up
1702 e1000_check_downshift_generic(hw);
1704 /* Enable/Disable EEE after link up */
1705 if (hw->phy.type > e1000_phy_82579) {
1706 ret_val = e1000_set_eee_pchlan(hw);
1711 /* If we are forcing speed/duplex, then we simply return since
1712 * we have already determined whether we have link or not.
1715 return -E1000_ERR_CONFIG;
1717 /* Auto-Neg is enabled. Auto Speed Detection takes care
1718 * of MAC speed/duplex configuration. So we only need to
1719 * configure Collision Distance in the MAC.
1721 mac->ops.config_collision_dist(hw);
1723 /* Configure Flow Control now that Auto-Neg has completed.
1724 * First, we need to restore the desired flow control
1725 * settings because we may have had to re-autoneg with a
1726 * different link partner.
1728 ret_val = e1000_config_fc_after_link_up_generic(hw);
1730 DEBUGOUT("Error configuring flow control\n");
1736 * e1000_init_function_pointers_ich8lan - Initialize ICH8 function pointers
1737 * @hw: pointer to the HW structure
1739 * Initialize family-specific function pointers for PHY, MAC, and NVM.
1741 void e1000_init_function_pointers_ich8lan(struct e1000_hw *hw)
1743 DEBUGFUNC("e1000_init_function_pointers_ich8lan");
1745 hw->mac.ops.init_params = e1000_init_mac_params_ich8lan;
1746 hw->nvm.ops.init_params = e1000_init_nvm_params_ich8lan;
1747 switch (hw->mac.type) {
1750 case e1000_ich10lan:
1751 hw->phy.ops.init_params = e1000_init_phy_params_ich8lan;
1759 hw->phy.ops.init_params = e1000_init_phy_params_pchlan;
1767 * e1000_acquire_nvm_ich8lan - Acquire NVM mutex
1768 * @hw: pointer to the HW structure
1770 * Acquires the mutex for performing NVM operations.
1772 STATIC s32 e1000_acquire_nvm_ich8lan(struct e1000_hw *hw)
1774 DEBUGFUNC("e1000_acquire_nvm_ich8lan");
1776 E1000_MUTEX_LOCK(&hw->dev_spec.ich8lan.nvm_mutex);
1778 return E1000_SUCCESS;
1782 * e1000_release_nvm_ich8lan - Release NVM mutex
1783 * @hw: pointer to the HW structure
1785 * Releases the mutex used while performing NVM operations.
1787 STATIC void e1000_release_nvm_ich8lan(struct e1000_hw *hw)
1789 DEBUGFUNC("e1000_release_nvm_ich8lan");
1791 E1000_MUTEX_UNLOCK(&hw->dev_spec.ich8lan.nvm_mutex);
1797 * e1000_acquire_swflag_ich8lan - Acquire software control flag
1798 * @hw: pointer to the HW structure
1800 * Acquires the software control flag for performing PHY and select
1803 STATIC s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw)
1805 u32 extcnf_ctrl, timeout = PHY_CFG_TIMEOUT;
1806 s32 ret_val = E1000_SUCCESS;
1808 DEBUGFUNC("e1000_acquire_swflag_ich8lan");
1810 E1000_MUTEX_LOCK(&hw->dev_spec.ich8lan.swflag_mutex);
1813 extcnf_ctrl = E1000_READ_REG(hw, E1000_EXTCNF_CTRL);
1814 if (!(extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG))
1822 DEBUGOUT("SW has already locked the resource.\n");
1823 ret_val = -E1000_ERR_CONFIG;
1827 timeout = SW_FLAG_TIMEOUT;
1829 extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG;
1830 E1000_WRITE_REG(hw, E1000_EXTCNF_CTRL, extcnf_ctrl);
1833 extcnf_ctrl = E1000_READ_REG(hw, E1000_EXTCNF_CTRL);
1834 if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG)
1842 DEBUGOUT2("Failed to acquire the semaphore, FW or HW has it: FWSM=0x%8.8x EXTCNF_CTRL=0x%8.8x)\n",
1843 E1000_READ_REG(hw, E1000_FWSM), extcnf_ctrl);
1844 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
1845 E1000_WRITE_REG(hw, E1000_EXTCNF_CTRL, extcnf_ctrl);
1846 ret_val = -E1000_ERR_CONFIG;
1852 E1000_MUTEX_UNLOCK(&hw->dev_spec.ich8lan.swflag_mutex);
1858 * e1000_release_swflag_ich8lan - Release software control flag
1859 * @hw: pointer to the HW structure
1861 * Releases the software control flag for performing PHY and select
1864 STATIC void e1000_release_swflag_ich8lan(struct e1000_hw *hw)
1868 DEBUGFUNC("e1000_release_swflag_ich8lan");
1870 extcnf_ctrl = E1000_READ_REG(hw, E1000_EXTCNF_CTRL);
1872 if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG) {
1873 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
1874 E1000_WRITE_REG(hw, E1000_EXTCNF_CTRL, extcnf_ctrl);
1876 DEBUGOUT("Semaphore unexpectedly released by sw/fw/hw\n");
1879 E1000_MUTEX_UNLOCK(&hw->dev_spec.ich8lan.swflag_mutex);
1885 * e1000_check_mng_mode_ich8lan - Checks management mode
1886 * @hw: pointer to the HW structure
1888 * This checks if the adapter has any manageability enabled.
1889 * This is a function pointer entry point only called by read/write
1890 * routines for the PHY and NVM parts.
1892 STATIC bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw)
1896 DEBUGFUNC("e1000_check_mng_mode_ich8lan");
1898 fwsm = E1000_READ_REG(hw, E1000_FWSM);
1900 return (fwsm & E1000_ICH_FWSM_FW_VALID) &&
1901 ((fwsm & E1000_FWSM_MODE_MASK) ==
1902 (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT));
1906 * e1000_check_mng_mode_pchlan - Checks management mode
1907 * @hw: pointer to the HW structure
1909 * This checks if the adapter has iAMT enabled.
1910 * This is a function pointer entry point only called by read/write
1911 * routines for the PHY and NVM parts.
1913 STATIC bool e1000_check_mng_mode_pchlan(struct e1000_hw *hw)
1917 DEBUGFUNC("e1000_check_mng_mode_pchlan");
1919 fwsm = E1000_READ_REG(hw, E1000_FWSM);
1921 return (fwsm & E1000_ICH_FWSM_FW_VALID) &&
1922 (fwsm & (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT));
1926 * e1000_rar_set_pch2lan - Set receive address register
1927 * @hw: pointer to the HW structure
1928 * @addr: pointer to the receive address
1929 * @index: receive address array register
1931 * Sets the receive address array register at index to the address passed
1932 * in by addr. For 82579, RAR[0] is the base address register that is to
1933 * contain the MAC address but RAR[1-6] are reserved for manageability (ME).
1934 * Use SHRA[0-3] in place of those reserved for ME.
1936 STATIC int e1000_rar_set_pch2lan(struct e1000_hw *hw, u8 *addr, u32 index)
1938 u32 rar_low, rar_high;
1940 DEBUGFUNC("e1000_rar_set_pch2lan");
1942 /* HW expects these in little endian so we reverse the byte order
1943 * from network order (big endian) to little endian
1945 rar_low = ((u32) addr[0] |
1946 ((u32) addr[1] << 8) |
1947 ((u32) addr[2] << 16) | ((u32) addr[3] << 24));
1949 rar_high = ((u32) addr[4] | ((u32) addr[5] << 8));
1951 /* If MAC address zero, no need to set the AV bit */
1952 if (rar_low || rar_high)
1953 rar_high |= E1000_RAH_AV;
1956 E1000_WRITE_REG(hw, E1000_RAL(index), rar_low);
1957 E1000_WRITE_FLUSH(hw);
1958 E1000_WRITE_REG(hw, E1000_RAH(index), rar_high);
1959 E1000_WRITE_FLUSH(hw);
1960 return E1000_SUCCESS;
1963 /* RAR[1-6] are owned by manageability. Skip those and program the
1964 * next address into the SHRA register array.
1966 if (index < (u32) (hw->mac.rar_entry_count)) {
1969 ret_val = e1000_acquire_swflag_ich8lan(hw);
1973 E1000_WRITE_REG(hw, E1000_SHRAL(index - 1), rar_low);
1974 E1000_WRITE_FLUSH(hw);
1975 E1000_WRITE_REG(hw, E1000_SHRAH(index - 1), rar_high);
1976 E1000_WRITE_FLUSH(hw);
1978 e1000_release_swflag_ich8lan(hw);
1980 /* verify the register updates */
1981 if ((E1000_READ_REG(hw, E1000_SHRAL(index - 1)) == rar_low) &&
1982 (E1000_READ_REG(hw, E1000_SHRAH(index - 1)) == rar_high))
1983 return E1000_SUCCESS;
1985 DEBUGOUT2("SHRA[%d] might be locked by ME - FWSM=0x%8.8x\n",
1986 (index - 1), E1000_READ_REG(hw, E1000_FWSM));
1990 DEBUGOUT1("Failed to write receive address at index %d\n", index);
1991 return -E1000_ERR_CONFIG;
1995 * e1000_rar_set_pch_lpt - Set receive address registers
1996 * @hw: pointer to the HW structure
1997 * @addr: pointer to the receive address
1998 * @index: receive address array register
2000 * Sets the receive address register array at index to the address passed
2001 * in by addr. For LPT, RAR[0] is the base address register that is to
2002 * contain the MAC address. SHRA[0-10] are the shared receive address
2003 * registers that are shared between the Host and manageability engine (ME).
2005 STATIC int e1000_rar_set_pch_lpt(struct e1000_hw *hw, u8 *addr, u32 index)
2007 u32 rar_low, rar_high;
2010 DEBUGFUNC("e1000_rar_set_pch_lpt");
2012 /* HW expects these in little endian so we reverse the byte order
2013 * from network order (big endian) to little endian
2015 rar_low = ((u32) addr[0] | ((u32) addr[1] << 8) |
2016 ((u32) addr[2] << 16) | ((u32) addr[3] << 24));
2018 rar_high = ((u32) addr[4] | ((u32) addr[5] << 8));
2020 /* If MAC address zero, no need to set the AV bit */
2021 if (rar_low || rar_high)
2022 rar_high |= E1000_RAH_AV;
2025 E1000_WRITE_REG(hw, E1000_RAL(index), rar_low);
2026 E1000_WRITE_FLUSH(hw);
2027 E1000_WRITE_REG(hw, E1000_RAH(index), rar_high);
2028 E1000_WRITE_FLUSH(hw);
2029 return E1000_SUCCESS;
2032 /* The manageability engine (ME) can lock certain SHRAR registers that
2033 * it is using - those registers are unavailable for use.
2035 if (index < hw->mac.rar_entry_count) {
2036 wlock_mac = E1000_READ_REG(hw, E1000_FWSM) &
2037 E1000_FWSM_WLOCK_MAC_MASK;
2038 wlock_mac >>= E1000_FWSM_WLOCK_MAC_SHIFT;
2040 /* Check if all SHRAR registers are locked */
2044 if ((wlock_mac == 0) || (index <= wlock_mac)) {
2047 ret_val = e1000_acquire_swflag_ich8lan(hw);
2052 E1000_WRITE_REG(hw, E1000_SHRAL_PCH_LPT(index - 1),
2054 E1000_WRITE_FLUSH(hw);
2055 E1000_WRITE_REG(hw, E1000_SHRAH_PCH_LPT(index - 1),
2057 E1000_WRITE_FLUSH(hw);
2059 e1000_release_swflag_ich8lan(hw);
2061 /* verify the register updates */
2062 if ((E1000_READ_REG(hw, E1000_SHRAL_PCH_LPT(index - 1)) == rar_low) &&
2063 (E1000_READ_REG(hw, E1000_SHRAH_PCH_LPT(index - 1)) == rar_high))
2064 return E1000_SUCCESS;
2069 DEBUGOUT1("Failed to write receive address at index %d\n", index);
2070 return -E1000_ERR_CONFIG;
2074 * e1000_update_mc_addr_list_pch2lan - Update Multicast addresses
2075 * @hw: pointer to the HW structure
2076 * @mc_addr_list: array of multicast addresses to program
2077 * @mc_addr_count: number of multicast addresses to program
2079 * Updates entire Multicast Table Array of the PCH2 MAC and PHY.
2080 * The caller must have a packed mc_addr_list of multicast addresses.
2082 STATIC void e1000_update_mc_addr_list_pch2lan(struct e1000_hw *hw,
2090 DEBUGFUNC("e1000_update_mc_addr_list_pch2lan");
2092 e1000_update_mc_addr_list_generic(hw, mc_addr_list, mc_addr_count);
2094 ret_val = hw->phy.ops.acquire(hw);
2098 ret_val = e1000_enable_phy_wakeup_reg_access_bm(hw, &phy_reg);
2102 for (i = 0; i < hw->mac.mta_reg_count; i++) {
2103 hw->phy.ops.write_reg_page(hw, BM_MTA(i),
2104 (u16)(hw->mac.mta_shadow[i] &
2106 hw->phy.ops.write_reg_page(hw, (BM_MTA(i) + 1),
2107 (u16)((hw->mac.mta_shadow[i] >> 16) &
2111 e1000_disable_phy_wakeup_reg_access_bm(hw, &phy_reg);
2114 hw->phy.ops.release(hw);
2118 * e1000_check_reset_block_ich8lan - Check if PHY reset is blocked
2119 * @hw: pointer to the HW structure
2121 * Checks if firmware is blocking the reset of the PHY.
2122 * This is a function pointer entry point only called by
2125 STATIC s32 e1000_check_reset_block_ich8lan(struct e1000_hw *hw)
2128 bool blocked = false;
2131 DEBUGFUNC("e1000_check_reset_block_ich8lan");
2134 fwsm = E1000_READ_REG(hw, E1000_FWSM);
2135 if (!(fwsm & E1000_ICH_FWSM_RSPCIPHY)) {
2141 } while (blocked && (i++ < 30));
2142 return blocked ? E1000_BLK_PHY_RESET : E1000_SUCCESS;
2146 * e1000_write_smbus_addr - Write SMBus address to PHY needed during Sx states
2147 * @hw: pointer to the HW structure
2149 * Assumes semaphore already acquired.
2152 STATIC s32 e1000_write_smbus_addr(struct e1000_hw *hw)
2155 u32 strap = E1000_READ_REG(hw, E1000_STRAP);
2156 u32 freq = (strap & E1000_STRAP_SMT_FREQ_MASK) >>
2157 E1000_STRAP_SMT_FREQ_SHIFT;
2160 strap &= E1000_STRAP_SMBUS_ADDRESS_MASK;
2162 ret_val = e1000_read_phy_reg_hv_locked(hw, HV_SMB_ADDR, &phy_data);
2166 phy_data &= ~HV_SMB_ADDR_MASK;
2167 phy_data |= (strap >> E1000_STRAP_SMBUS_ADDRESS_SHIFT);
2168 phy_data |= HV_SMB_ADDR_PEC_EN | HV_SMB_ADDR_VALID;
2170 if (hw->phy.type == e1000_phy_i217) {
2171 /* Restore SMBus frequency */
2173 phy_data &= ~HV_SMB_ADDR_FREQ_MASK;
2174 phy_data |= (freq & (1 << 0)) <<
2175 HV_SMB_ADDR_FREQ_LOW_SHIFT;
2176 phy_data |= (freq & (1 << 1)) <<
2177 (HV_SMB_ADDR_FREQ_HIGH_SHIFT - 1);
2179 DEBUGOUT("Unsupported SMB frequency in PHY\n");
2183 return e1000_write_phy_reg_hv_locked(hw, HV_SMB_ADDR, phy_data);
2187 * e1000_sw_lcd_config_ich8lan - SW-based LCD Configuration
2188 * @hw: pointer to the HW structure
2190 * SW should configure the LCD from the NVM extended configuration region
2191 * as a workaround for certain parts.
2193 STATIC s32 e1000_sw_lcd_config_ich8lan(struct e1000_hw *hw)
2195 struct e1000_phy_info *phy = &hw->phy;
2196 u32 i, data, cnf_size, cnf_base_addr, sw_cfg_mask;
2197 s32 ret_val = E1000_SUCCESS;
2198 u16 word_addr, reg_data, reg_addr, phy_page = 0;
2200 DEBUGFUNC("e1000_sw_lcd_config_ich8lan");
2202 /* Initialize the PHY from the NVM on ICH platforms. This
2203 * is needed due to an issue where the NVM configuration is
2204 * not properly autoloaded after power transitions.
2205 * Therefore, after each PHY reset, we will load the
2206 * configuration data out of the NVM manually.
2208 switch (hw->mac.type) {
2210 if (phy->type != e1000_phy_igp_3)
2213 if ((hw->device_id == E1000_DEV_ID_ICH8_IGP_AMT) ||
2214 (hw->device_id == E1000_DEV_ID_ICH8_IGP_C)) {
2215 sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG;
2225 sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG_ICH8M;
2231 ret_val = hw->phy.ops.acquire(hw);
2235 data = E1000_READ_REG(hw, E1000_FEXTNVM);
2236 if (!(data & sw_cfg_mask))
2239 /* Make sure HW does not configure LCD from PHY
2240 * extended configuration before SW configuration
2242 data = E1000_READ_REG(hw, E1000_EXTCNF_CTRL);
2243 if ((hw->mac.type < e1000_pch2lan) &&
2244 (data & E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE))
2247 cnf_size = E1000_READ_REG(hw, E1000_EXTCNF_SIZE);
2248 cnf_size &= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_MASK;
2249 cnf_size >>= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_SHIFT;
2253 cnf_base_addr = data & E1000_EXTCNF_CTRL_EXT_CNF_POINTER_MASK;
2254 cnf_base_addr >>= E1000_EXTCNF_CTRL_EXT_CNF_POINTER_SHIFT;
2256 if (((hw->mac.type == e1000_pchlan) &&
2257 !(data & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE)) ||
2258 (hw->mac.type > e1000_pchlan)) {
2259 /* HW configures the SMBus address and LEDs when the
2260 * OEM and LCD Write Enable bits are set in the NVM.
2261 * When both NVM bits are cleared, SW will configure
2264 ret_val = e1000_write_smbus_addr(hw);
2268 data = E1000_READ_REG(hw, E1000_LEDCTL);
2269 ret_val = e1000_write_phy_reg_hv_locked(hw, HV_LED_CONFIG,
2275 /* Configure LCD from extended configuration region. */
2277 /* cnf_base_addr is in DWORD */
2278 word_addr = (u16)(cnf_base_addr << 1);
2280 for (i = 0; i < cnf_size; i++) {
2281 ret_val = hw->nvm.ops.read(hw, (word_addr + i * 2), 1,
2286 ret_val = hw->nvm.ops.read(hw, (word_addr + i * 2 + 1),
2291 /* Save off the PHY page for future writes. */
2292 if (reg_addr == IGP01E1000_PHY_PAGE_SELECT) {
2293 phy_page = reg_data;
2297 reg_addr &= PHY_REG_MASK;
2298 reg_addr |= phy_page;
2300 ret_val = phy->ops.write_reg_locked(hw, (u32)reg_addr,
2307 hw->phy.ops.release(hw);
2312 * e1000_k1_gig_workaround_hv - K1 Si workaround
2313 * @hw: pointer to the HW structure
2314 * @link: link up bool flag
2316 * If K1 is enabled for 1Gbps, the MAC might stall when transitioning
2317 * from a lower speed. This workaround disables K1 whenever link is at 1Gig
2318 * If link is down, the function will restore the default K1 setting located
2321 STATIC s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link)
2323 s32 ret_val = E1000_SUCCESS;
2325 bool k1_enable = hw->dev_spec.ich8lan.nvm_k1_enabled;
2327 DEBUGFUNC("e1000_k1_gig_workaround_hv");
2329 if (hw->mac.type != e1000_pchlan)
2330 return E1000_SUCCESS;
2332 /* Wrap the whole flow with the sw flag */
2333 ret_val = hw->phy.ops.acquire(hw);
2337 /* Disable K1 when link is 1Gbps, otherwise use the NVM setting */
2339 if (hw->phy.type == e1000_phy_82578) {
2340 ret_val = hw->phy.ops.read_reg_locked(hw, BM_CS_STATUS,
2345 status_reg &= (BM_CS_STATUS_LINK_UP |
2346 BM_CS_STATUS_RESOLVED |
2347 BM_CS_STATUS_SPEED_MASK);
2349 if (status_reg == (BM_CS_STATUS_LINK_UP |
2350 BM_CS_STATUS_RESOLVED |
2351 BM_CS_STATUS_SPEED_1000))
2355 if (hw->phy.type == e1000_phy_82577) {
2356 ret_val = hw->phy.ops.read_reg_locked(hw, HV_M_STATUS,
2361 status_reg &= (HV_M_STATUS_LINK_UP |
2362 HV_M_STATUS_AUTONEG_COMPLETE |
2363 HV_M_STATUS_SPEED_MASK);
2365 if (status_reg == (HV_M_STATUS_LINK_UP |
2366 HV_M_STATUS_AUTONEG_COMPLETE |
2367 HV_M_STATUS_SPEED_1000))
2371 /* Link stall fix for link up */
2372 ret_val = hw->phy.ops.write_reg_locked(hw, PHY_REG(770, 19),
2378 /* Link stall fix for link down */
2379 ret_val = hw->phy.ops.write_reg_locked(hw, PHY_REG(770, 19),
2385 ret_val = e1000_configure_k1_ich8lan(hw, k1_enable);
2388 hw->phy.ops.release(hw);
2394 * e1000_configure_k1_ich8lan - Configure K1 power state
2395 * @hw: pointer to the HW structure
2396 * @k1_enable: K1 state to configure
2398 * Configure the K1 power state based on the provided parameter.
2399 * Assumes semaphore already acquired.
2401 * Success returns 0, Failure returns -E1000_ERR_PHY (-2)
2403 s32 e1000_configure_k1_ich8lan(struct e1000_hw *hw, bool k1_enable)
2411 DEBUGFUNC("e1000_configure_k1_ich8lan");
2413 ret_val = e1000_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
2419 kmrn_reg |= E1000_KMRNCTRLSTA_K1_ENABLE;
2421 kmrn_reg &= ~E1000_KMRNCTRLSTA_K1_ENABLE;
2423 ret_val = e1000_write_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
2429 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
2430 ctrl_reg = E1000_READ_REG(hw, E1000_CTRL);
2432 reg = ctrl_reg & ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100);
2433 reg |= E1000_CTRL_FRCSPD;
2434 E1000_WRITE_REG(hw, E1000_CTRL, reg);
2436 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext | E1000_CTRL_EXT_SPD_BYPS);
2437 E1000_WRITE_FLUSH(hw);
2439 E1000_WRITE_REG(hw, E1000_CTRL, ctrl_reg);
2440 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
2441 E1000_WRITE_FLUSH(hw);
2444 return E1000_SUCCESS;
2448 * e1000_oem_bits_config_ich8lan - SW-based LCD Configuration
2449 * @hw: pointer to the HW structure
2450 * @d0_state: boolean if entering d0 or d3 device state
2452 * SW will configure Gbe Disable and LPLU based on the NVM. The four bits are
2453 * collectively called OEM bits. The OEM Write Enable bit and SW Config bit
2454 * in NVM determines whether HW should configure LPLU and Gbe Disable.
2456 STATIC s32 e1000_oem_bits_config_ich8lan(struct e1000_hw *hw, bool d0_state)
2462 DEBUGFUNC("e1000_oem_bits_config_ich8lan");
2464 if (hw->mac.type < e1000_pchlan)
2467 ret_val = hw->phy.ops.acquire(hw);
2471 if (hw->mac.type == e1000_pchlan) {
2472 mac_reg = E1000_READ_REG(hw, E1000_EXTCNF_CTRL);
2473 if (mac_reg & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE)
2477 mac_reg = E1000_READ_REG(hw, E1000_FEXTNVM);
2478 if (!(mac_reg & E1000_FEXTNVM_SW_CONFIG_ICH8M))
2481 mac_reg = E1000_READ_REG(hw, E1000_PHY_CTRL);
2483 ret_val = hw->phy.ops.read_reg_locked(hw, HV_OEM_BITS, &oem_reg);
2487 oem_reg &= ~(HV_OEM_BITS_GBE_DIS | HV_OEM_BITS_LPLU);
2490 if (mac_reg & E1000_PHY_CTRL_GBE_DISABLE)
2491 oem_reg |= HV_OEM_BITS_GBE_DIS;
2493 if (mac_reg & E1000_PHY_CTRL_D0A_LPLU)
2494 oem_reg |= HV_OEM_BITS_LPLU;
2496 if (mac_reg & (E1000_PHY_CTRL_GBE_DISABLE |
2497 E1000_PHY_CTRL_NOND0A_GBE_DISABLE))
2498 oem_reg |= HV_OEM_BITS_GBE_DIS;
2500 if (mac_reg & (E1000_PHY_CTRL_D0A_LPLU |
2501 E1000_PHY_CTRL_NOND0A_LPLU))
2502 oem_reg |= HV_OEM_BITS_LPLU;
2505 /* Set Restart auto-neg to activate the bits */
2506 if ((d0_state || (hw->mac.type != e1000_pchlan)) &&
2507 !hw->phy.ops.check_reset_block(hw))
2508 oem_reg |= HV_OEM_BITS_RESTART_AN;
2510 ret_val = hw->phy.ops.write_reg_locked(hw, HV_OEM_BITS, oem_reg);
2513 hw->phy.ops.release(hw);
2520 * e1000_set_mdio_slow_mode_hv - Set slow MDIO access mode
2521 * @hw: pointer to the HW structure
2523 STATIC s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw)
2528 DEBUGFUNC("e1000_set_mdio_slow_mode_hv");
2530 ret_val = hw->phy.ops.read_reg(hw, HV_KMRN_MODE_CTRL, &data);
2534 data |= HV_KMRN_MDIO_SLOW;
2536 ret_val = hw->phy.ops.write_reg(hw, HV_KMRN_MODE_CTRL, data);
2542 * e1000_hv_phy_workarounds_ich8lan - A series of Phy workarounds to be
2543 * done after every PHY reset.
2544 * @hw: pointer to the HW structure
2546 STATIC s32 e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw)
2548 s32 ret_val = E1000_SUCCESS;
2551 DEBUGFUNC("e1000_hv_phy_workarounds_ich8lan");
2553 if (hw->mac.type != e1000_pchlan)
2554 return E1000_SUCCESS;
2556 /* Set MDIO slow mode before any other MDIO access */
2557 if (hw->phy.type == e1000_phy_82577) {
2558 ret_val = e1000_set_mdio_slow_mode_hv(hw);
2563 if (((hw->phy.type == e1000_phy_82577) &&
2564 ((hw->phy.revision == 1) || (hw->phy.revision == 2))) ||
2565 ((hw->phy.type == e1000_phy_82578) && (hw->phy.revision == 1))) {
2566 /* Disable generation of early preamble */
2567 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(769, 25), 0x4431);
2571 /* Preamble tuning for SSC */
2572 ret_val = hw->phy.ops.write_reg(hw, HV_KMRN_FIFO_CTRLSTA,
2578 if (hw->phy.type == e1000_phy_82578) {
2579 /* Return registers to default by doing a soft reset then
2580 * writing 0x3140 to the control register.
2582 if (hw->phy.revision < 2) {
2583 e1000_phy_sw_reset_generic(hw);
2584 ret_val = hw->phy.ops.write_reg(hw, PHY_CONTROL,
2590 ret_val = hw->phy.ops.acquire(hw);
2595 ret_val = e1000_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT, 0);
2596 hw->phy.ops.release(hw);
2600 /* Configure the K1 Si workaround during phy reset assuming there is
2601 * link so that it disables K1 if link is in 1Gbps.
2603 ret_val = e1000_k1_gig_workaround_hv(hw, true);
2607 /* Workaround for link disconnects on a busy hub in half duplex */
2608 ret_val = hw->phy.ops.acquire(hw);
2611 ret_val = hw->phy.ops.read_reg_locked(hw, BM_PORT_GEN_CFG, &phy_data);
2614 ret_val = hw->phy.ops.write_reg_locked(hw, BM_PORT_GEN_CFG,
2619 /* set MSE higher to enable link to stay up when noise is high */
2620 ret_val = e1000_write_emi_reg_locked(hw, I82577_MSE_THRESHOLD, 0x0034);
2622 hw->phy.ops.release(hw);
2628 * e1000_copy_rx_addrs_to_phy_ich8lan - Copy Rx addresses from MAC to PHY
2629 * @hw: pointer to the HW structure
2631 void e1000_copy_rx_addrs_to_phy_ich8lan(struct e1000_hw *hw)
2637 DEBUGFUNC("e1000_copy_rx_addrs_to_phy_ich8lan");
2639 ret_val = hw->phy.ops.acquire(hw);
2642 ret_val = e1000_enable_phy_wakeup_reg_access_bm(hw, &phy_reg);
2646 /* Copy both RAL/H (rar_entry_count) and SHRAL/H to PHY */
2647 for (i = 0; i < (hw->mac.rar_entry_count); i++) {
2648 mac_reg = E1000_READ_REG(hw, E1000_RAL(i));
2649 hw->phy.ops.write_reg_page(hw, BM_RAR_L(i),
2650 (u16)(mac_reg & 0xFFFF));
2651 hw->phy.ops.write_reg_page(hw, BM_RAR_M(i),
2652 (u16)((mac_reg >> 16) & 0xFFFF));
2654 mac_reg = E1000_READ_REG(hw, E1000_RAH(i));
2655 hw->phy.ops.write_reg_page(hw, BM_RAR_H(i),
2656 (u16)(mac_reg & 0xFFFF));
2657 hw->phy.ops.write_reg_page(hw, BM_RAR_CTRL(i),
2658 (u16)((mac_reg & E1000_RAH_AV)
2662 e1000_disable_phy_wakeup_reg_access_bm(hw, &phy_reg);
2665 hw->phy.ops.release(hw);
2668 STATIC u32 e1000_calc_rx_da_crc(u8 mac[])
2670 u32 poly = 0xEDB88320; /* Polynomial for 802.3 CRC calculation */
2671 u32 i, j, mask, crc;
2673 DEBUGFUNC("e1000_calc_rx_da_crc");
2676 for (i = 0; i < 6; i++) {
2678 for (j = 8; j > 0; j--) {
2679 mask = (crc & 1) * (-1);
2680 crc = (crc >> 1) ^ (poly & mask);
2687 * e1000_lv_jumbo_workaround_ich8lan - required for jumbo frame operation
2689 * @hw: pointer to the HW structure
2690 * @enable: flag to enable/disable workaround when enabling/disabling jumbos
2692 s32 e1000_lv_jumbo_workaround_ich8lan(struct e1000_hw *hw, bool enable)
2694 s32 ret_val = E1000_SUCCESS;
2699 DEBUGFUNC("e1000_lv_jumbo_workaround_ich8lan");
2701 if (hw->mac.type < e1000_pch2lan)
2702 return E1000_SUCCESS;
2704 /* disable Rx path while enabling/disabling workaround */
2705 hw->phy.ops.read_reg(hw, PHY_REG(769, 20), &phy_reg);
2706 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(769, 20),
2707 phy_reg | (1 << 14));
2712 /* Write Rx addresses (rar_entry_count for RAL/H, and
2713 * SHRAL/H) and initial CRC values to the MAC
2715 for (i = 0; i < hw->mac.rar_entry_count; i++) {
2716 u8 mac_addr[ETH_ADDR_LEN] = {0};
2717 u32 addr_high, addr_low;
2719 addr_high = E1000_READ_REG(hw, E1000_RAH(i));
2720 if (!(addr_high & E1000_RAH_AV))
2722 addr_low = E1000_READ_REG(hw, E1000_RAL(i));
2723 mac_addr[0] = (addr_low & 0xFF);
2724 mac_addr[1] = ((addr_low >> 8) & 0xFF);
2725 mac_addr[2] = ((addr_low >> 16) & 0xFF);
2726 mac_addr[3] = ((addr_low >> 24) & 0xFF);
2727 mac_addr[4] = (addr_high & 0xFF);
2728 mac_addr[5] = ((addr_high >> 8) & 0xFF);
2730 E1000_WRITE_REG(hw, E1000_PCH_RAICC(i),
2731 e1000_calc_rx_da_crc(mac_addr));
2734 /* Write Rx addresses to the PHY */
2735 e1000_copy_rx_addrs_to_phy_ich8lan(hw);
2737 /* Enable jumbo frame workaround in the MAC */
2738 mac_reg = E1000_READ_REG(hw, E1000_FFLT_DBG);
2739 mac_reg &= ~(1 << 14);
2740 mac_reg |= (7 << 15);
2741 E1000_WRITE_REG(hw, E1000_FFLT_DBG, mac_reg);
2743 mac_reg = E1000_READ_REG(hw, E1000_RCTL);
2744 mac_reg |= E1000_RCTL_SECRC;
2745 E1000_WRITE_REG(hw, E1000_RCTL, mac_reg);
2747 ret_val = e1000_read_kmrn_reg_generic(hw,
2748 E1000_KMRNCTRLSTA_CTRL_OFFSET,
2752 ret_val = e1000_write_kmrn_reg_generic(hw,
2753 E1000_KMRNCTRLSTA_CTRL_OFFSET,
2757 ret_val = e1000_read_kmrn_reg_generic(hw,
2758 E1000_KMRNCTRLSTA_HD_CTRL,
2762 data &= ~(0xF << 8);
2764 ret_val = e1000_write_kmrn_reg_generic(hw,
2765 E1000_KMRNCTRLSTA_HD_CTRL,
2770 /* Enable jumbo frame workaround in the PHY */
2771 hw->phy.ops.read_reg(hw, PHY_REG(769, 23), &data);
2772 data &= ~(0x7F << 5);
2773 data |= (0x37 << 5);
2774 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(769, 23), data);
2777 hw->phy.ops.read_reg(hw, PHY_REG(769, 16), &data);
2779 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(769, 16), data);
2782 hw->phy.ops.read_reg(hw, PHY_REG(776, 20), &data);
2783 data &= ~(0x3FF << 2);
2784 data |= (E1000_TX_PTR_GAP << 2);
2785 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(776, 20), data);
2788 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(776, 23), 0xF100);
2791 hw->phy.ops.read_reg(hw, HV_PM_CTRL, &data);
2792 ret_val = hw->phy.ops.write_reg(hw, HV_PM_CTRL, data |
2797 /* Write MAC register values back to h/w defaults */
2798 mac_reg = E1000_READ_REG(hw, E1000_FFLT_DBG);
2799 mac_reg &= ~(0xF << 14);
2800 E1000_WRITE_REG(hw, E1000_FFLT_DBG, mac_reg);
2802 mac_reg = E1000_READ_REG(hw, E1000_RCTL);
2803 mac_reg &= ~E1000_RCTL_SECRC;
2804 E1000_WRITE_REG(hw, E1000_RCTL, mac_reg);
2806 ret_val = e1000_read_kmrn_reg_generic(hw,
2807 E1000_KMRNCTRLSTA_CTRL_OFFSET,
2811 ret_val = e1000_write_kmrn_reg_generic(hw,
2812 E1000_KMRNCTRLSTA_CTRL_OFFSET,
2816 ret_val = e1000_read_kmrn_reg_generic(hw,
2817 E1000_KMRNCTRLSTA_HD_CTRL,
2821 data &= ~(0xF << 8);
2823 ret_val = e1000_write_kmrn_reg_generic(hw,
2824 E1000_KMRNCTRLSTA_HD_CTRL,
2829 /* Write PHY register values back to h/w defaults */
2830 hw->phy.ops.read_reg(hw, PHY_REG(769, 23), &data);
2831 data &= ~(0x7F << 5);
2832 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(769, 23), data);
2835 hw->phy.ops.read_reg(hw, PHY_REG(769, 16), &data);
2837 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(769, 16), data);
2840 hw->phy.ops.read_reg(hw, PHY_REG(776, 20), &data);
2841 data &= ~(0x3FF << 2);
2843 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(776, 20), data);
2846 ret_val = hw->phy.ops.write_reg(hw, PHY_REG(776, 23), 0x7E00);
2849 hw->phy.ops.read_reg(hw, HV_PM_CTRL, &data);
2850 ret_val = hw->phy.ops.write_reg(hw, HV_PM_CTRL, data &
2856 /* re-enable Rx path after enabling/disabling workaround */
2857 return hw->phy.ops.write_reg(hw, PHY_REG(769, 20), phy_reg &
2862 * e1000_lv_phy_workarounds_ich8lan - A series of Phy workarounds to be
2863 * done after every PHY reset.
2864 * @hw: pointer to the HW structure
2866 STATIC s32 e1000_lv_phy_workarounds_ich8lan(struct e1000_hw *hw)
2868 s32 ret_val = E1000_SUCCESS;
2870 DEBUGFUNC("e1000_lv_phy_workarounds_ich8lan");
2872 if (hw->mac.type != e1000_pch2lan)
2873 return E1000_SUCCESS;
2875 /* Set MDIO slow mode before any other MDIO access */
2876 ret_val = e1000_set_mdio_slow_mode_hv(hw);
2880 ret_val = hw->phy.ops.acquire(hw);
2883 /* set MSE higher to enable link to stay up when noise is high */
2884 ret_val = e1000_write_emi_reg_locked(hw, I82579_MSE_THRESHOLD, 0x0034);
2887 /* drop link after 5 times MSE threshold was reached */
2888 ret_val = e1000_write_emi_reg_locked(hw, I82579_MSE_LINK_DOWN, 0x0005);
2890 hw->phy.ops.release(hw);
2896 * e1000_k1_gig_workaround_lv - K1 Si workaround
2897 * @hw: pointer to the HW structure
2899 * Workaround to set the K1 beacon duration for 82579 parts in 10Mbps
2900 * Disable K1 for 1000 and 100 speeds
2902 STATIC s32 e1000_k1_workaround_lv(struct e1000_hw *hw)
2904 s32 ret_val = E1000_SUCCESS;
2907 DEBUGFUNC("e1000_k1_workaround_lv");
2909 if (hw->mac.type != e1000_pch2lan)
2910 return E1000_SUCCESS;
2912 /* Set K1 beacon duration based on 10Mbs speed */
2913 ret_val = hw->phy.ops.read_reg(hw, HV_M_STATUS, &status_reg);
2917 if ((status_reg & (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE))
2918 == (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE)) {
2920 (HV_M_STATUS_SPEED_1000 | HV_M_STATUS_SPEED_100)) {
2923 /* LV 1G/100 Packet drop issue wa */
2924 ret_val = hw->phy.ops.read_reg(hw, HV_PM_CTRL,
2928 pm_phy_reg &= ~HV_PM_CTRL_K1_ENABLE;
2929 ret_val = hw->phy.ops.write_reg(hw, HV_PM_CTRL,
2935 mac_reg = E1000_READ_REG(hw, E1000_FEXTNVM4);
2936 mac_reg &= ~E1000_FEXTNVM4_BEACON_DURATION_MASK;
2937 mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_16USEC;
2938 E1000_WRITE_REG(hw, E1000_FEXTNVM4, mac_reg);
2946 * e1000_gate_hw_phy_config_ich8lan - disable PHY config via hardware
2947 * @hw: pointer to the HW structure
2948 * @gate: boolean set to true to gate, false to ungate
2950 * Gate/ungate the automatic PHY configuration via hardware; perform
2951 * the configuration via software instead.
2953 STATIC void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate)
2957 DEBUGFUNC("e1000_gate_hw_phy_config_ich8lan");
2959 if (hw->mac.type < e1000_pch2lan)
2962 extcnf_ctrl = E1000_READ_REG(hw, E1000_EXTCNF_CTRL);
2965 extcnf_ctrl |= E1000_EXTCNF_CTRL_GATE_PHY_CFG;
2967 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_GATE_PHY_CFG;
2969 E1000_WRITE_REG(hw, E1000_EXTCNF_CTRL, extcnf_ctrl);
2973 * e1000_lan_init_done_ich8lan - Check for PHY config completion
2974 * @hw: pointer to the HW structure
2976 * Check the appropriate indication the MAC has finished configuring the
2977 * PHY after a software reset.
2979 STATIC void e1000_lan_init_done_ich8lan(struct e1000_hw *hw)
2981 u32 data, loop = E1000_ICH8_LAN_INIT_TIMEOUT;
2983 DEBUGFUNC("e1000_lan_init_done_ich8lan");
2985 /* Wait for basic configuration completes before proceeding */
2987 data = E1000_READ_REG(hw, E1000_STATUS);
2988 data &= E1000_STATUS_LAN_INIT_DONE;
2990 } while ((!data) && --loop);
2992 /* If basic configuration is incomplete before the above loop
2993 * count reaches 0, loading the configuration from NVM will
2994 * leave the PHY in a bad state possibly resulting in no link.
2997 DEBUGOUT("LAN_INIT_DONE not set, increase timeout\n");
2999 /* Clear the Init Done bit for the next init event */
3000 data = E1000_READ_REG(hw, E1000_STATUS);
3001 data &= ~E1000_STATUS_LAN_INIT_DONE;
3002 E1000_WRITE_REG(hw, E1000_STATUS, data);
3006 * e1000_post_phy_reset_ich8lan - Perform steps required after a PHY reset
3007 * @hw: pointer to the HW structure
3009 STATIC s32 e1000_post_phy_reset_ich8lan(struct e1000_hw *hw)
3011 s32 ret_val = E1000_SUCCESS;
3014 DEBUGFUNC("e1000_post_phy_reset_ich8lan");
3016 if (hw->phy.ops.check_reset_block(hw))
3017 return E1000_SUCCESS;
3019 /* Allow time for h/w to get to quiescent state after reset */
3022 /* Perform any necessary post-reset workarounds */
3023 switch (hw->mac.type) {
3025 ret_val = e1000_hv_phy_workarounds_ich8lan(hw);
3030 ret_val = e1000_lv_phy_workarounds_ich8lan(hw);
3038 /* Clear the host wakeup bit after lcd reset */
3039 if (hw->mac.type >= e1000_pchlan) {
3040 hw->phy.ops.read_reg(hw, BM_PORT_GEN_CFG, ®);
3041 reg &= ~BM_WUC_HOST_WU_BIT;
3042 hw->phy.ops.write_reg(hw, BM_PORT_GEN_CFG, reg);
3045 /* Configure the LCD with the extended configuration region in NVM */
3046 ret_val = e1000_sw_lcd_config_ich8lan(hw);
3050 /* Configure the LCD with the OEM bits in NVM */
3051 ret_val = e1000_oem_bits_config_ich8lan(hw, true);
3053 if (hw->mac.type == e1000_pch2lan) {
3054 /* Ungate automatic PHY configuration on non-managed 82579 */
3055 if (!(E1000_READ_REG(hw, E1000_FWSM) &
3056 E1000_ICH_FWSM_FW_VALID)) {
3058 e1000_gate_hw_phy_config_ich8lan(hw, false);
3061 /* Set EEE LPI Update Timer to 200usec */
3062 ret_val = hw->phy.ops.acquire(hw);
3065 ret_val = e1000_write_emi_reg_locked(hw,
3066 I82579_LPI_UPDATE_TIMER,
3068 hw->phy.ops.release(hw);
3075 * e1000_phy_hw_reset_ich8lan - Performs a PHY reset
3076 * @hw: pointer to the HW structure
3079 * This is a function pointer entry point called by drivers
3080 * or other shared routines.
3082 STATIC s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw)
3084 s32 ret_val = E1000_SUCCESS;
3086 DEBUGFUNC("e1000_phy_hw_reset_ich8lan");
3088 /* Gate automatic PHY configuration by hardware on non-managed 82579 */
3089 if ((hw->mac.type == e1000_pch2lan) &&
3090 !(E1000_READ_REG(hw, E1000_FWSM) & E1000_ICH_FWSM_FW_VALID))
3091 e1000_gate_hw_phy_config_ich8lan(hw, true);
3093 ret_val = e1000_phy_hw_reset_generic(hw);
3097 return e1000_post_phy_reset_ich8lan(hw);
3101 * e1000_set_lplu_state_pchlan - Set Low Power Link Up state
3102 * @hw: pointer to the HW structure
3103 * @active: true to enable LPLU, false to disable
3105 * Sets the LPLU state according to the active flag. For PCH, if OEM write
3106 * bit are disabled in the NVM, writing the LPLU bits in the MAC will not set
3107 * the phy speed. This function will manually set the LPLU bit and restart
3108 * auto-neg as hw would do. D3 and D0 LPLU will call the same function
3109 * since it configures the same bit.
3111 STATIC s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active)
3116 DEBUGFUNC("e1000_set_lplu_state_pchlan");
3117 ret_val = hw->phy.ops.read_reg(hw, HV_OEM_BITS, &oem_reg);
3122 oem_reg |= HV_OEM_BITS_LPLU;
3124 oem_reg &= ~HV_OEM_BITS_LPLU;
3126 if (!hw->phy.ops.check_reset_block(hw))
3127 oem_reg |= HV_OEM_BITS_RESTART_AN;
3129 return hw->phy.ops.write_reg(hw, HV_OEM_BITS, oem_reg);
3133 * e1000_set_d0_lplu_state_ich8lan - Set Low Power Linkup D0 state
3134 * @hw: pointer to the HW structure
3135 * @active: true to enable LPLU, false to disable
3137 * Sets the LPLU D0 state according to the active flag. When
3138 * activating LPLU this function also disables smart speed
3139 * and vice versa. LPLU will not be activated unless the
3140 * device autonegotiation advertisement meets standards of
3141 * either 10 or 10/100 or 10/100/1000 at all duplexes.
3142 * This is a function pointer entry point only called by
3143 * PHY setup routines.
3145 STATIC s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
3147 struct e1000_phy_info *phy = &hw->phy;
3149 s32 ret_val = E1000_SUCCESS;
3152 DEBUGFUNC("e1000_set_d0_lplu_state_ich8lan");
3154 if (phy->type == e1000_phy_ife)
3155 return E1000_SUCCESS;
3157 phy_ctrl = E1000_READ_REG(hw, E1000_PHY_CTRL);
3160 phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU;
3161 E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl);
3163 if (phy->type != e1000_phy_igp_3)
3164 return E1000_SUCCESS;
3166 /* Call gig speed drop workaround on LPLU before accessing
3169 if (hw->mac.type == e1000_ich8lan)
3170 e1000_gig_downshift_workaround_ich8lan(hw);
3172 /* When LPLU is enabled, we should disable SmartSpeed */
3173 ret_val = phy->ops.read_reg(hw,
3174 IGP01E1000_PHY_PORT_CONFIG,
3178 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
3179 ret_val = phy->ops.write_reg(hw,
3180 IGP01E1000_PHY_PORT_CONFIG,
3185 phy_ctrl &= ~E1000_PHY_CTRL_D0A_LPLU;
3186 E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl);
3188 if (phy->type != e1000_phy_igp_3)
3189 return E1000_SUCCESS;
3191 /* LPLU and SmartSpeed are mutually exclusive. LPLU is used
3192 * during Dx states where the power conservation is most
3193 * important. During driver activity we should enable
3194 * SmartSpeed, so performance is maintained.
3196 if (phy->smart_speed == e1000_smart_speed_on) {
3197 ret_val = phy->ops.read_reg(hw,
3198 IGP01E1000_PHY_PORT_CONFIG,
3203 data |= IGP01E1000_PSCFR_SMART_SPEED;
3204 ret_val = phy->ops.write_reg(hw,
3205 IGP01E1000_PHY_PORT_CONFIG,
3209 } else if (phy->smart_speed == e1000_smart_speed_off) {
3210 ret_val = phy->ops.read_reg(hw,
3211 IGP01E1000_PHY_PORT_CONFIG,
3216 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
3217 ret_val = phy->ops.write_reg(hw,
3218 IGP01E1000_PHY_PORT_CONFIG,
3225 return E1000_SUCCESS;
3229 * e1000_set_d3_lplu_state_ich8lan - Set Low Power Linkup D3 state
3230 * @hw: pointer to the HW structure
3231 * @active: true to enable LPLU, false to disable
3233 * Sets the LPLU D3 state according to the active flag. When
3234 * activating LPLU this function also disables smart speed
3235 * and vice versa. LPLU will not be activated unless the
3236 * device autonegotiation advertisement meets standards of
3237 * either 10 or 10/100 or 10/100/1000 at all duplexes.
3238 * This is a function pointer entry point only called by
3239 * PHY setup routines.
3241 STATIC s32 e1000_set_d3_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
3243 struct e1000_phy_info *phy = &hw->phy;
3245 s32 ret_val = E1000_SUCCESS;
3248 DEBUGFUNC("e1000_set_d3_lplu_state_ich8lan");
3250 phy_ctrl = E1000_READ_REG(hw, E1000_PHY_CTRL);
3253 phy_ctrl &= ~E1000_PHY_CTRL_NOND0A_LPLU;
3254 E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl);
3256 if (phy->type != e1000_phy_igp_3)
3257 return E1000_SUCCESS;
3259 /* LPLU and SmartSpeed are mutually exclusive. LPLU is used
3260 * during Dx states where the power conservation is most
3261 * important. During driver activity we should enable
3262 * SmartSpeed, so performance is maintained.
3264 if (phy->smart_speed == e1000_smart_speed_on) {
3265 ret_val = phy->ops.read_reg(hw,
3266 IGP01E1000_PHY_PORT_CONFIG,
3271 data |= IGP01E1000_PSCFR_SMART_SPEED;
3272 ret_val = phy->ops.write_reg(hw,
3273 IGP01E1000_PHY_PORT_CONFIG,
3277 } else if (phy->smart_speed == e1000_smart_speed_off) {
3278 ret_val = phy->ops.read_reg(hw,
3279 IGP01E1000_PHY_PORT_CONFIG,
3284 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
3285 ret_val = phy->ops.write_reg(hw,
3286 IGP01E1000_PHY_PORT_CONFIG,
3291 } else if ((phy->autoneg_advertised == E1000_ALL_SPEED_DUPLEX) ||
3292 (phy->autoneg_advertised == E1000_ALL_NOT_GIG) ||
3293 (phy->autoneg_advertised == E1000_ALL_10_SPEED)) {
3294 phy_ctrl |= E1000_PHY_CTRL_NOND0A_LPLU;
3295 E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl);
3297 if (phy->type != e1000_phy_igp_3)
3298 return E1000_SUCCESS;
3300 /* Call gig speed drop workaround on LPLU before accessing
3303 if (hw->mac.type == e1000_ich8lan)
3304 e1000_gig_downshift_workaround_ich8lan(hw);
3306 /* When LPLU is enabled, we should disable SmartSpeed */
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,
3323 * e1000_valid_nvm_bank_detect_ich8lan - finds out the valid bank 0 or 1
3324 * @hw: pointer to the HW structure
3325 * @bank: pointer to the variable that returns the active bank
3327 * Reads signature byte from the NVM using the flash access registers.
3328 * Word 0x13 bits 15:14 = 10b indicate a valid signature for that bank.
3330 STATIC s32 e1000_valid_nvm_bank_detect_ich8lan(struct e1000_hw *hw, u32 *bank)
3333 struct e1000_nvm_info *nvm = &hw->nvm;
3334 u32 bank1_offset = nvm->flash_bank_size * sizeof(u16);
3335 u32 act_offset = E1000_ICH_NVM_SIG_WORD * 2 + 1;
3340 DEBUGFUNC("e1000_valid_nvm_bank_detect_ich8lan");
3342 switch (hw->mac.type) {
3346 bank1_offset = nvm->flash_bank_size;
3347 act_offset = E1000_ICH_NVM_SIG_WORD;
3349 /* set bank to 0 in case flash read fails */
3353 ret_val = e1000_read_flash_dword_ich8lan(hw, act_offset,
3357 sig_byte = (u8)((nvm_dword & 0xFF00) >> 8);
3358 if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
3359 E1000_ICH_NVM_SIG_VALUE) {
3361 return E1000_SUCCESS;
3365 ret_val = e1000_read_flash_dword_ich8lan(hw, act_offset +
3370 sig_byte = (u8)((nvm_dword & 0xFF00) >> 8);
3371 if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
3372 E1000_ICH_NVM_SIG_VALUE) {
3374 return E1000_SUCCESS;
3377 DEBUGOUT("ERROR: No valid NVM bank present\n");
3378 return -E1000_ERR_NVM;
3381 eecd = E1000_READ_REG(hw, E1000_EECD);
3382 if ((eecd & E1000_EECD_SEC1VAL_VALID_MASK) ==
3383 E1000_EECD_SEC1VAL_VALID_MASK) {
3384 if (eecd & E1000_EECD_SEC1VAL)
3389 return E1000_SUCCESS;
3391 DEBUGOUT("Unable to determine valid NVM bank via EEC - reading flash signature\n");
3394 /* set bank to 0 in case flash read fails */
3398 ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset,
3402 if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
3403 E1000_ICH_NVM_SIG_VALUE) {
3405 return E1000_SUCCESS;
3409 ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset +
3414 if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
3415 E1000_ICH_NVM_SIG_VALUE) {
3417 return E1000_SUCCESS;
3420 DEBUGOUT("ERROR: No valid NVM bank present\n");
3421 return -E1000_ERR_NVM;
3426 * e1000_read_nvm_spt - NVM access for SPT
3427 * @hw: pointer to the HW structure
3428 * @offset: The offset (in bytes) of the word(s) to read.
3429 * @words: Size of data to read in words.
3430 * @data: pointer to the word(s) to read at offset.
3432 * Reads a word(s) from the NVM
3434 STATIC s32 e1000_read_nvm_spt(struct e1000_hw *hw, u16 offset, u16 words,
3437 struct e1000_nvm_info *nvm = &hw->nvm;
3438 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
3440 s32 ret_val = E1000_SUCCESS;
3446 DEBUGFUNC("e1000_read_nvm_spt");
3448 if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
3450 DEBUGOUT("nvm parameter(s) out of bounds\n");
3451 ret_val = -E1000_ERR_NVM;
3455 nvm->ops.acquire(hw);
3457 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
3458 if (ret_val != E1000_SUCCESS) {
3459 DEBUGOUT("Could not detect valid bank, assuming bank 0\n");
3463 act_offset = (bank) ? nvm->flash_bank_size : 0;
3464 act_offset += offset;
3466 ret_val = E1000_SUCCESS;
3468 for (i = 0; i < words; i += 2) {
3469 if (words - i == 1) {
3470 if (dev_spec->shadow_ram[offset + i].modified) {
3472 dev_spec->shadow_ram[offset + i].value;
3474 offset_to_read = act_offset + i -
3475 ((act_offset + i) % 2);
3477 e1000_read_flash_dword_ich8lan(hw,
3482 if ((act_offset + i) % 2 == 0)
3483 data[i] = (u16)(dword & 0xFFFF);
3485 data[i] = (u16)((dword >> 16) & 0xFFFF);
3488 offset_to_read = act_offset + i;
3489 if (!(dev_spec->shadow_ram[offset + i].modified) ||
3490 !(dev_spec->shadow_ram[offset + i + 1].modified)) {
3492 e1000_read_flash_dword_ich8lan(hw,
3498 if (dev_spec->shadow_ram[offset + i].modified)
3500 dev_spec->shadow_ram[offset + i].value;
3502 data[i] = (u16)(dword & 0xFFFF);
3503 if (dev_spec->shadow_ram[offset + i + 1].modified)
3505 dev_spec->shadow_ram[offset + i + 1].value;
3507 data[i + 1] = (u16)(dword >> 16 & 0xFFFF);
3511 nvm->ops.release(hw);
3515 DEBUGOUT1("NVM read error: %d\n", ret_val);
3521 * e1000_read_nvm_ich8lan - Read word(s) from the NVM
3522 * @hw: pointer to the HW structure
3523 * @offset: The offset (in bytes) of the word(s) to read.
3524 * @words: Size of data to read in words
3525 * @data: Pointer to the word(s) to read at offset.
3527 * Reads a word(s) from the NVM using the flash access registers.
3529 STATIC s32 e1000_read_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
3532 struct e1000_nvm_info *nvm = &hw->nvm;
3533 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
3535 s32 ret_val = E1000_SUCCESS;
3539 DEBUGFUNC("e1000_read_nvm_ich8lan");
3541 if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
3543 DEBUGOUT("nvm parameter(s) out of bounds\n");
3544 ret_val = -E1000_ERR_NVM;
3548 nvm->ops.acquire(hw);
3550 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
3551 if (ret_val != E1000_SUCCESS) {
3552 DEBUGOUT("Could not detect valid bank, assuming bank 0\n");
3556 act_offset = (bank) ? nvm->flash_bank_size : 0;
3557 act_offset += offset;
3559 ret_val = E1000_SUCCESS;
3560 for (i = 0; i < words; i++) {
3561 if (dev_spec->shadow_ram[offset + i].modified) {
3562 data[i] = dev_spec->shadow_ram[offset + i].value;
3564 ret_val = e1000_read_flash_word_ich8lan(hw,
3573 nvm->ops.release(hw);
3577 DEBUGOUT1("NVM read error: %d\n", ret_val);
3583 * e1000_flash_cycle_init_ich8lan - Initialize flash
3584 * @hw: pointer to the HW structure
3586 * This function does initial flash setup so that a new read/write/erase cycle
3589 STATIC s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw)
3591 union ich8_hws_flash_status hsfsts;
3592 s32 ret_val = -E1000_ERR_NVM;
3594 DEBUGFUNC("e1000_flash_cycle_init_ich8lan");
3596 hsfsts.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
3598 /* Check if the flash descriptor is valid */
3599 if (!hsfsts.hsf_status.fldesvalid) {
3600 DEBUGOUT("Flash descriptor invalid. SW Sequencing must be used.\n");
3601 return -E1000_ERR_NVM;
3604 /* Clear FCERR and DAEL in hw status by writing 1 */
3605 hsfsts.hsf_status.flcerr = 1;
3606 hsfsts.hsf_status.dael = 1;
3607 if (hw->mac.type >= e1000_pch_spt)
3608 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_HSFSTS,
3609 hsfsts.regval & 0xFFFF);
3611 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFSTS, hsfsts.regval);
3613 /* Either we should have a hardware SPI cycle in progress
3614 * bit to check against, in order to start a new cycle or
3615 * FDONE bit should be changed in the hardware so that it
3616 * is 1 after hardware reset, which can then be used as an
3617 * indication whether a cycle is in progress or has been
3621 if (!hsfsts.hsf_status.flcinprog) {
3622 /* There is no cycle running at present,
3623 * so we can start a cycle.
3624 * Begin by setting Flash Cycle Done.
3626 hsfsts.hsf_status.flcdone = 1;
3627 if (hw->mac.type >= e1000_pch_spt)
3628 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_HSFSTS,
3629 hsfsts.regval & 0xFFFF);
3631 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFSTS,
3633 ret_val = E1000_SUCCESS;
3637 /* Otherwise poll for sometime so the current
3638 * cycle has a chance to end before giving up.
3640 for (i = 0; i < ICH_FLASH_READ_COMMAND_TIMEOUT; i++) {
3641 hsfsts.regval = E1000_READ_FLASH_REG16(hw,
3643 if (!hsfsts.hsf_status.flcinprog) {
3644 ret_val = E1000_SUCCESS;
3649 if (ret_val == E1000_SUCCESS) {
3650 /* Successful in waiting for previous cycle to timeout,
3651 * now set the Flash Cycle Done.
3653 hsfsts.hsf_status.flcdone = 1;
3654 if (hw->mac.type >= e1000_pch_spt)
3655 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_HSFSTS,
3656 hsfsts.regval & 0xFFFF);
3658 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFSTS,
3661 DEBUGOUT("Flash controller busy, cannot get access\n");
3669 * e1000_flash_cycle_ich8lan - Starts flash cycle (read/write/erase)
3670 * @hw: pointer to the HW structure
3671 * @timeout: maximum time to wait for completion
3673 * This function starts a flash cycle and waits for its completion.
3675 STATIC s32 e1000_flash_cycle_ich8lan(struct e1000_hw *hw, u32 timeout)
3677 union ich8_hws_flash_ctrl hsflctl;
3678 union ich8_hws_flash_status hsfsts;
3681 DEBUGFUNC("e1000_flash_cycle_ich8lan");
3683 /* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */
3684 if (hw->mac.type >= e1000_pch_spt)
3685 hsflctl.regval = E1000_READ_FLASH_REG(hw, ICH_FLASH_HSFSTS)>>16;
3687 hsflctl.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFCTL);
3688 hsflctl.hsf_ctrl.flcgo = 1;
3690 if (hw->mac.type >= e1000_pch_spt)
3691 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_HSFSTS,
3692 hsflctl.regval << 16);
3694 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFCTL, hsflctl.regval);
3696 /* wait till FDONE bit is set to 1 */
3698 hsfsts.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
3699 if (hsfsts.hsf_status.flcdone)
3702 } while (i++ < timeout);
3704 if (hsfsts.hsf_status.flcdone && !hsfsts.hsf_status.flcerr)
3705 return E1000_SUCCESS;
3707 return -E1000_ERR_NVM;
3711 * e1000_read_flash_dword_ich8lan - Read dword from flash
3712 * @hw: pointer to the HW structure
3713 * @offset: offset to data location
3714 * @data: pointer to the location for storing the data
3716 * Reads the flash dword at offset into data. Offset is converted
3717 * to bytes before read.
3719 STATIC s32 e1000_read_flash_dword_ich8lan(struct e1000_hw *hw, u32 offset,
3722 DEBUGFUNC("e1000_read_flash_dword_ich8lan");
3725 return -E1000_ERR_NVM;
3727 /* Must convert word offset into bytes. */
3730 return e1000_read_flash_data32_ich8lan(hw, offset, data);
3734 * e1000_read_flash_word_ich8lan - Read word from flash
3735 * @hw: pointer to the HW structure
3736 * @offset: offset to data location
3737 * @data: pointer to the location for storing the data
3739 * Reads the flash word at offset into data. Offset is converted
3740 * to bytes before read.
3742 STATIC s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset,
3745 DEBUGFUNC("e1000_read_flash_word_ich8lan");
3748 return -E1000_ERR_NVM;
3750 /* Must convert offset into bytes. */
3753 return e1000_read_flash_data_ich8lan(hw, offset, 2, data);
3757 * e1000_read_flash_byte_ich8lan - Read byte from flash
3758 * @hw: pointer to the HW structure
3759 * @offset: The offset of the byte to read.
3760 * @data: Pointer to a byte to store the value read.
3762 * Reads a single byte from the NVM using the flash access registers.
3764 STATIC s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
3770 /* In SPT, only 32 bits access is supported,
3771 * so this function should not be called.
3773 if (hw->mac.type >= e1000_pch_spt)
3774 return -E1000_ERR_NVM;
3776 ret_val = e1000_read_flash_data_ich8lan(hw, offset, 1, &word);
3783 return E1000_SUCCESS;
3787 * e1000_read_flash_data_ich8lan - Read byte or word from NVM
3788 * @hw: pointer to the HW structure
3789 * @offset: The offset (in bytes) of the byte or word to read.
3790 * @size: Size of data to read, 1=byte 2=word
3791 * @data: Pointer to the word to store the value read.
3793 * Reads a byte or word from the NVM using the flash access registers.
3795 STATIC s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
3798 union ich8_hws_flash_status hsfsts;
3799 union ich8_hws_flash_ctrl hsflctl;
3800 u32 flash_linear_addr;
3802 s32 ret_val = -E1000_ERR_NVM;
3805 DEBUGFUNC("e1000_read_flash_data_ich8lan");
3807 if (size < 1 || size > 2 || offset > ICH_FLASH_LINEAR_ADDR_MASK)
3808 return -E1000_ERR_NVM;
3809 flash_linear_addr = ((ICH_FLASH_LINEAR_ADDR_MASK & offset) +
3810 hw->nvm.flash_base_addr);
3815 ret_val = e1000_flash_cycle_init_ich8lan(hw);
3816 if (ret_val != E1000_SUCCESS)
3818 hsflctl.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFCTL);
3820 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
3821 hsflctl.hsf_ctrl.fldbcount = size - 1;
3822 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_READ;
3823 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFCTL, hsflctl.regval);
3824 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FADDR, flash_linear_addr);
3826 ret_val = e1000_flash_cycle_ich8lan(hw,
3827 ICH_FLASH_READ_COMMAND_TIMEOUT);
3829 /* Check if FCERR is set to 1, if set to 1, clear it
3830 * and try the whole sequence a few more times, else
3831 * read in (shift in) the Flash Data0, the order is
3832 * least significant byte first msb to lsb
3834 if (ret_val == E1000_SUCCESS) {
3835 flash_data = E1000_READ_FLASH_REG(hw, ICH_FLASH_FDATA0);
3837 *data = (u8)(flash_data & 0x000000FF);
3839 *data = (u16)(flash_data & 0x0000FFFF);
3842 /* If we've gotten here, then things are probably
3843 * completely hosed, but if the error condition is
3844 * detected, it won't hurt to give it another try...
3845 * ICH_FLASH_CYCLE_REPEAT_COUNT times.
3847 hsfsts.regval = E1000_READ_FLASH_REG16(hw,
3849 if (hsfsts.hsf_status.flcerr) {
3850 /* Repeat for some time before giving up. */
3852 } else if (!hsfsts.hsf_status.flcdone) {
3853 DEBUGOUT("Timeout error - flash cycle did not complete.\n");
3857 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
3863 * e1000_read_flash_data32_ich8lan - Read dword from NVM
3864 * @hw: pointer to the HW structure
3865 * @offset: The offset (in bytes) of the dword to read.
3866 * @data: Pointer to the dword to store the value read.
3868 * Reads a byte or word from the NVM using the flash access registers.
3870 STATIC s32 e1000_read_flash_data32_ich8lan(struct e1000_hw *hw, u32 offset,
3873 union ich8_hws_flash_status hsfsts;
3874 union ich8_hws_flash_ctrl hsflctl;
3875 u32 flash_linear_addr;
3876 s32 ret_val = -E1000_ERR_NVM;
3879 DEBUGFUNC("e1000_read_flash_data_ich8lan");
3881 if (offset > ICH_FLASH_LINEAR_ADDR_MASK ||
3882 hw->mac.type < e1000_pch_spt)
3883 return -E1000_ERR_NVM;
3884 flash_linear_addr = ((ICH_FLASH_LINEAR_ADDR_MASK & offset) +
3885 hw->nvm.flash_base_addr);
3890 ret_val = e1000_flash_cycle_init_ich8lan(hw);
3891 if (ret_val != E1000_SUCCESS)
3893 /* In SPT, This register is in Lan memory space, not flash.
3894 * Therefore, only 32 bit access is supported
3896 hsflctl.regval = E1000_READ_FLASH_REG(hw, ICH_FLASH_HSFSTS)>>16;
3898 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
3899 hsflctl.hsf_ctrl.fldbcount = sizeof(u32) - 1;
3900 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_READ;
3901 /* In SPT, This register is in Lan memory space, not flash.
3902 * Therefore, only 32 bit access is supported
3904 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_HSFSTS,
3905 (u32)hsflctl.regval << 16);
3906 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FADDR, flash_linear_addr);
3908 ret_val = e1000_flash_cycle_ich8lan(hw,
3909 ICH_FLASH_READ_COMMAND_TIMEOUT);
3911 /* Check if FCERR is set to 1, if set to 1, clear it
3912 * and try the whole sequence a few more times, else
3913 * read in (shift in) the Flash Data0, the order is
3914 * least significant byte first msb to lsb
3916 if (ret_val == E1000_SUCCESS) {
3917 *data = E1000_READ_FLASH_REG(hw, ICH_FLASH_FDATA0);
3920 /* If we've gotten here, then things are probably
3921 * completely hosed, but if the error condition is
3922 * detected, it won't hurt to give it another try...
3923 * ICH_FLASH_CYCLE_REPEAT_COUNT times.
3925 hsfsts.regval = E1000_READ_FLASH_REG16(hw,
3927 if (hsfsts.hsf_status.flcerr) {
3928 /* Repeat for some time before giving up. */
3930 } else if (!hsfsts.hsf_status.flcdone) {
3931 DEBUGOUT("Timeout error - flash cycle did not complete.\n");
3935 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
3941 * e1000_write_nvm_ich8lan - Write word(s) to the NVM
3942 * @hw: pointer to the HW structure
3943 * @offset: The offset (in bytes) of the word(s) to write.
3944 * @words: Size of data to write in words
3945 * @data: Pointer to the word(s) to write at offset.
3947 * Writes a byte or word to the NVM using the flash access registers.
3949 STATIC s32 e1000_write_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
3952 struct e1000_nvm_info *nvm = &hw->nvm;
3953 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
3956 DEBUGFUNC("e1000_write_nvm_ich8lan");
3958 if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
3960 DEBUGOUT("nvm parameter(s) out of bounds\n");
3961 return -E1000_ERR_NVM;
3964 nvm->ops.acquire(hw);
3966 for (i = 0; i < words; i++) {
3967 dev_spec->shadow_ram[offset + i].modified = true;
3968 dev_spec->shadow_ram[offset + i].value = data[i];
3971 nvm->ops.release(hw);
3973 return E1000_SUCCESS;
3977 * e1000_update_nvm_checksum_spt - Update the checksum for NVM
3978 * @hw: pointer to the HW structure
3980 * The NVM checksum is updated by calling the generic update_nvm_checksum,
3981 * which writes the checksum to the shadow ram. The changes in the shadow
3982 * ram are then committed to the EEPROM by processing each bank at a time
3983 * checking for the modified bit and writing only the pending changes.
3984 * After a successful commit, the shadow ram is cleared and is ready for
3987 STATIC s32 e1000_update_nvm_checksum_spt(struct e1000_hw *hw)
3989 struct e1000_nvm_info *nvm = &hw->nvm;
3990 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
3991 u32 i, act_offset, new_bank_offset, old_bank_offset, bank;
3995 DEBUGFUNC("e1000_update_nvm_checksum_spt");
3997 ret_val = e1000_update_nvm_checksum_generic(hw);
4001 if (nvm->type != e1000_nvm_flash_sw)
4004 nvm->ops.acquire(hw);
4006 /* We're writing to the opposite bank so if we're on bank 1,
4007 * write to bank 0 etc. We also need to erase the segment that
4008 * is going to be written
4010 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
4011 if (ret_val != E1000_SUCCESS) {
4012 DEBUGOUT("Could not detect valid bank, assuming bank 0\n");
4017 new_bank_offset = nvm->flash_bank_size;
4018 old_bank_offset = 0;
4019 ret_val = e1000_erase_flash_bank_ich8lan(hw, 1);
4023 old_bank_offset = nvm->flash_bank_size;
4024 new_bank_offset = 0;
4025 ret_val = e1000_erase_flash_bank_ich8lan(hw, 0);
4029 for (i = 0; i < E1000_SHADOW_RAM_WORDS; i += 2) {
4030 /* Determine whether to write the value stored
4031 * in the other NVM bank or a modified value stored
4034 ret_val = e1000_read_flash_dword_ich8lan(hw,
4035 i + old_bank_offset,
4038 if (dev_spec->shadow_ram[i].modified) {
4039 dword &= 0xffff0000;
4040 dword |= (dev_spec->shadow_ram[i].value & 0xffff);
4042 if (dev_spec->shadow_ram[i + 1].modified) {
4043 dword &= 0x0000ffff;
4044 dword |= ((dev_spec->shadow_ram[i + 1].value & 0xffff)
4050 /* If the word is 0x13, then make sure the signature bits
4051 * (15:14) are 11b until the commit has completed.
4052 * This will allow us to write 10b which indicates the
4053 * signature is valid. We want to do this after the write
4054 * has completed so that we don't mark the segment valid
4055 * while the write is still in progress
4057 if (i == E1000_ICH_NVM_SIG_WORD - 1)
4058 dword |= E1000_ICH_NVM_SIG_MASK << 16;
4060 /* Convert offset to bytes. */
4061 act_offset = (i + new_bank_offset) << 1;
4065 /* Write the data to the new bank. Offset in words*/
4066 act_offset = i + new_bank_offset;
4067 ret_val = e1000_retry_write_flash_dword_ich8lan(hw, act_offset,
4073 /* Don't bother writing the segment valid bits if sector
4074 * programming failed.
4077 DEBUGOUT("Flash commit failed.\n");
4081 /* Finally validate the new segment by setting bit 15:14
4082 * to 10b in word 0x13 , this can be done without an
4083 * erase as well since these bits are 11 to start with
4084 * and we need to change bit 14 to 0b
4086 act_offset = new_bank_offset + E1000_ICH_NVM_SIG_WORD;
4088 /*offset in words but we read dword*/
4090 ret_val = e1000_read_flash_dword_ich8lan(hw, act_offset, &dword);
4095 dword &= 0xBFFFFFFF;
4096 ret_val = e1000_retry_write_flash_dword_ich8lan(hw, act_offset, dword);
4101 /* offset in words but we read dword*/
4102 act_offset = old_bank_offset + E1000_ICH_NVM_SIG_WORD - 1;
4103 ret_val = e1000_read_flash_dword_ich8lan(hw, act_offset, &dword);
4108 dword &= 0x00FFFFFF;
4109 ret_val = e1000_retry_write_flash_dword_ich8lan(hw, act_offset, dword);
4114 /* Great! Everything worked, we can now clear the cached entries. */
4115 for (i = 0; i < E1000_SHADOW_RAM_WORDS; i++) {
4116 dev_spec->shadow_ram[i].modified = false;
4117 dev_spec->shadow_ram[i].value = 0xFFFF;
4121 nvm->ops.release(hw);
4123 /* Reload the EEPROM, or else modifications will not appear
4124 * until after the next adapter reset.
4127 nvm->ops.reload(hw);
4133 DEBUGOUT1("NVM update error: %d\n", ret_val);
4139 * e1000_update_nvm_checksum_ich8lan - Update the checksum for NVM
4140 * @hw: pointer to the HW structure
4142 * The NVM checksum is updated by calling the generic update_nvm_checksum,
4143 * which writes the checksum to the shadow ram. The changes in the shadow
4144 * ram are then committed to the EEPROM by processing each bank at a time
4145 * checking for the modified bit and writing only the pending changes.
4146 * After a successful commit, the shadow ram is cleared and is ready for
4149 STATIC s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw)
4151 struct e1000_nvm_info *nvm = &hw->nvm;
4152 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
4153 u32 i, act_offset, new_bank_offset, old_bank_offset, bank;
4157 DEBUGFUNC("e1000_update_nvm_checksum_ich8lan");
4159 ret_val = e1000_update_nvm_checksum_generic(hw);
4163 if (nvm->type != e1000_nvm_flash_sw)
4166 nvm->ops.acquire(hw);
4168 /* We're writing to the opposite bank so if we're on bank 1,
4169 * write to bank 0 etc. We also need to erase the segment that
4170 * is going to be written
4172 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
4173 if (ret_val != E1000_SUCCESS) {
4174 DEBUGOUT("Could not detect valid bank, assuming bank 0\n");
4179 new_bank_offset = nvm->flash_bank_size;
4180 old_bank_offset = 0;
4181 ret_val = e1000_erase_flash_bank_ich8lan(hw, 1);
4185 old_bank_offset = nvm->flash_bank_size;
4186 new_bank_offset = 0;
4187 ret_val = e1000_erase_flash_bank_ich8lan(hw, 0);
4191 for (i = 0; i < E1000_SHADOW_RAM_WORDS; i++) {
4192 if (dev_spec->shadow_ram[i].modified) {
4193 data = dev_spec->shadow_ram[i].value;
4195 ret_val = e1000_read_flash_word_ich8lan(hw, i +
4201 /* If the word is 0x13, then make sure the signature bits
4202 * (15:14) are 11b until the commit has completed.
4203 * This will allow us to write 10b which indicates the
4204 * signature is valid. We want to do this after the write
4205 * has completed so that we don't mark the segment valid
4206 * while the write is still in progress
4208 if (i == E1000_ICH_NVM_SIG_WORD)
4209 data |= E1000_ICH_NVM_SIG_MASK;
4211 /* Convert offset to bytes. */
4212 act_offset = (i + new_bank_offset) << 1;
4216 /* Write the bytes to the new bank. */
4217 ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
4224 ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
4231 /* Don't bother writing the segment valid bits if sector
4232 * programming failed.
4235 DEBUGOUT("Flash commit failed.\n");
4239 /* Finally validate the new segment by setting bit 15:14
4240 * to 10b in word 0x13 , this can be done without an
4241 * erase as well since these bits are 11 to start with
4242 * and we need to change bit 14 to 0b
4244 act_offset = new_bank_offset + E1000_ICH_NVM_SIG_WORD;
4245 ret_val = e1000_read_flash_word_ich8lan(hw, act_offset, &data);
4250 ret_val = e1000_retry_write_flash_byte_ich8lan(hw, act_offset * 2 + 1,
4255 /* And invalidate the previously valid segment by setting
4256 * its signature word (0x13) high_byte to 0b. This can be
4257 * done without an erase because flash erase sets all bits
4258 * to 1's. We can write 1's to 0's without an erase
4260 act_offset = (old_bank_offset + E1000_ICH_NVM_SIG_WORD) * 2 + 1;
4262 ret_val = e1000_retry_write_flash_byte_ich8lan(hw, act_offset, 0);
4267 /* Great! Everything worked, we can now clear the cached entries. */
4268 for (i = 0; i < E1000_SHADOW_RAM_WORDS; i++) {
4269 dev_spec->shadow_ram[i].modified = false;
4270 dev_spec->shadow_ram[i].value = 0xFFFF;
4274 nvm->ops.release(hw);
4276 /* Reload the EEPROM, or else modifications will not appear
4277 * until after the next adapter reset.
4280 nvm->ops.reload(hw);
4286 DEBUGOUT1("NVM update error: %d\n", ret_val);
4292 * e1000_validate_nvm_checksum_ich8lan - Validate EEPROM checksum
4293 * @hw: pointer to the HW structure
4295 * Check to see if checksum needs to be fixed by reading bit 6 in word 0x19.
4296 * If the bit is 0, that the EEPROM had been modified, but the checksum was not
4297 * calculated, in which case we need to calculate the checksum and set bit 6.
4299 STATIC s32 e1000_validate_nvm_checksum_ich8lan(struct e1000_hw *hw)
4304 u16 valid_csum_mask;
4306 DEBUGFUNC("e1000_validate_nvm_checksum_ich8lan");
4308 /* Read NVM and check Invalid Image CSUM bit. If this bit is 0,
4309 * the checksum needs to be fixed. This bit is an indication that
4310 * the NVM was prepared by OEM software and did not calculate
4311 * the checksum...a likely scenario.
4313 switch (hw->mac.type) {
4319 valid_csum_mask = NVM_COMPAT_VALID_CSUM;
4322 word = NVM_FUTURE_INIT_WORD1;
4323 valid_csum_mask = NVM_FUTURE_INIT_WORD1_VALID_CSUM;
4327 ret_val = hw->nvm.ops.read(hw, word, 1, &data);
4331 if (!(data & valid_csum_mask)) {
4332 data |= valid_csum_mask;
4333 ret_val = hw->nvm.ops.write(hw, word, 1, &data);
4336 ret_val = hw->nvm.ops.update(hw);
4341 return e1000_validate_nvm_checksum_generic(hw);
4345 * e1000_write_flash_data_ich8lan - Writes bytes to the NVM
4346 * @hw: pointer to the HW structure
4347 * @offset: The offset (in bytes) of the byte/word to read.
4348 * @size: Size of data to read, 1=byte 2=word
4349 * @data: The byte(s) to write to the NVM.
4351 * Writes one/two bytes to the NVM using the flash access registers.
4353 STATIC s32 e1000_write_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
4356 union ich8_hws_flash_status hsfsts;
4357 union ich8_hws_flash_ctrl hsflctl;
4358 u32 flash_linear_addr;
4363 DEBUGFUNC("e1000_write_ich8_data");
4365 if (hw->mac.type >= e1000_pch_spt) {
4366 if (size != 4 || offset > ICH_FLASH_LINEAR_ADDR_MASK)
4367 return -E1000_ERR_NVM;
4369 if (size < 1 || size > 2 || offset > ICH_FLASH_LINEAR_ADDR_MASK)
4370 return -E1000_ERR_NVM;
4373 flash_linear_addr = ((ICH_FLASH_LINEAR_ADDR_MASK & offset) +
4374 hw->nvm.flash_base_addr);
4379 ret_val = e1000_flash_cycle_init_ich8lan(hw);
4380 if (ret_val != E1000_SUCCESS)
4382 /* In SPT, This register is in Lan memory space, not
4383 * flash. Therefore, only 32 bit access is supported
4385 if (hw->mac.type >= e1000_pch_spt)
4387 E1000_READ_FLASH_REG(hw, ICH_FLASH_HSFSTS)>>16;
4390 E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFCTL);
4392 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
4393 hsflctl.hsf_ctrl.fldbcount = size - 1;
4394 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_WRITE;
4395 /* In SPT, This register is in Lan memory space,
4396 * not flash. Therefore, only 32 bit access is
4399 if (hw->mac.type >= e1000_pch_spt)
4400 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_HSFSTS,
4401 hsflctl.regval << 16);
4403 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFCTL,
4406 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FADDR, flash_linear_addr);
4409 flash_data = (u32)data & 0x00FF;
4411 flash_data = (u32)data;
4413 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FDATA0, flash_data);
4415 /* check if FCERR is set to 1 , if set to 1, clear it
4416 * and try the whole sequence a few more times else done
4419 e1000_flash_cycle_ich8lan(hw,
4420 ICH_FLASH_WRITE_COMMAND_TIMEOUT);
4421 if (ret_val == E1000_SUCCESS)
4424 /* If we're here, then things are most likely
4425 * completely hosed, but if the error condition
4426 * is detected, it won't hurt to give it another
4427 * try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
4429 hsfsts.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
4430 if (hsfsts.hsf_status.flcerr)
4431 /* Repeat for some time before giving up. */
4433 if (!hsfsts.hsf_status.flcdone) {
4434 DEBUGOUT("Timeout error - flash cycle did not complete.\n");
4437 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
4443 * e1000_write_flash_data32_ich8lan - Writes 4 bytes to the NVM
4444 * @hw: pointer to the HW structure
4445 * @offset: The offset (in bytes) of the dwords to read.
4446 * @data: The 4 bytes to write to the NVM.
4448 * Writes one/two/four bytes to the NVM using the flash access registers.
4450 STATIC s32 e1000_write_flash_data32_ich8lan(struct e1000_hw *hw, u32 offset,
4453 union ich8_hws_flash_status hsfsts;
4454 union ich8_hws_flash_ctrl hsflctl;
4455 u32 flash_linear_addr;
4459 DEBUGFUNC("e1000_write_flash_data32_ich8lan");
4461 if (hw->mac.type >= e1000_pch_spt) {
4462 if (offset > ICH_FLASH_LINEAR_ADDR_MASK)
4463 return -E1000_ERR_NVM;
4465 flash_linear_addr = ((ICH_FLASH_LINEAR_ADDR_MASK & offset) +
4466 hw->nvm.flash_base_addr);
4470 ret_val = e1000_flash_cycle_init_ich8lan(hw);
4471 if (ret_val != E1000_SUCCESS)
4474 /* In SPT, This register is in Lan memory space, not
4475 * flash. Therefore, only 32 bit access is supported
4477 if (hw->mac.type >= e1000_pch_spt)
4478 hsflctl.regval = E1000_READ_FLASH_REG(hw,
4482 hsflctl.regval = E1000_READ_FLASH_REG16(hw,
4485 hsflctl.hsf_ctrl.fldbcount = sizeof(u32) - 1;
4486 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_WRITE;
4488 /* In SPT, This register is in Lan memory space,
4489 * not flash. Therefore, only 32 bit access is
4492 if (hw->mac.type >= e1000_pch_spt)
4493 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_HSFSTS,
4494 hsflctl.regval << 16);
4496 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFCTL,
4499 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FADDR, flash_linear_addr);
4501 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FDATA0, data);
4503 /* check if FCERR is set to 1 , if set to 1, clear it
4504 * and try the whole sequence a few more times else done
4506 ret_val = e1000_flash_cycle_ich8lan(hw,
4507 ICH_FLASH_WRITE_COMMAND_TIMEOUT);
4509 if (ret_val == E1000_SUCCESS)
4512 /* If we're here, then things are most likely
4513 * completely hosed, but if the error condition
4514 * is detected, it won't hurt to give it another
4515 * try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
4517 hsfsts.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
4519 if (hsfsts.hsf_status.flcerr)
4520 /* Repeat for some time before giving up. */
4522 if (!hsfsts.hsf_status.flcdone) {
4523 DEBUGOUT("Timeout error - flash cycle did not complete.\n");
4526 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
4532 * e1000_write_flash_byte_ich8lan - Write a single byte to NVM
4533 * @hw: pointer to the HW structure
4534 * @offset: The index of the byte to read.
4535 * @data: The byte to write to the NVM.
4537 * Writes a single byte to the NVM using the flash access registers.
4539 STATIC s32 e1000_write_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
4542 u16 word = (u16)data;
4544 DEBUGFUNC("e1000_write_flash_byte_ich8lan");
4546 return e1000_write_flash_data_ich8lan(hw, offset, 1, word);
4550 * e1000_retry_write_flash_dword_ich8lan - Writes a dword to NVM
4551 * @hw: pointer to the HW structure
4552 * @offset: The offset of the word to write.
4553 * @dword: The dword to write to the NVM.
4555 * Writes a single dword to the NVM using the flash access registers.
4556 * Goes through a retry algorithm before giving up.
4558 STATIC s32 e1000_retry_write_flash_dword_ich8lan(struct e1000_hw *hw,
4559 u32 offset, u32 dword)
4562 u16 program_retries;
4564 DEBUGFUNC("e1000_retry_write_flash_dword_ich8lan");
4566 /* Must convert word offset into bytes. */
4569 ret_val = e1000_write_flash_data32_ich8lan(hw, offset, dword);
4573 for (program_retries = 0; program_retries < 100; program_retries++) {
4574 DEBUGOUT2("Retrying Byte %8.8X at offset %u\n", dword, offset);
4576 ret_val = e1000_write_flash_data32_ich8lan(hw, offset, dword);
4577 if (ret_val == E1000_SUCCESS)
4580 if (program_retries == 100)
4581 return -E1000_ERR_NVM;
4583 return E1000_SUCCESS;
4587 * e1000_retry_write_flash_byte_ich8lan - Writes a single byte to NVM
4588 * @hw: pointer to the HW structure
4589 * @offset: The offset of the byte to write.
4590 * @byte: The byte to write to the NVM.
4592 * Writes a single byte to the NVM using the flash access registers.
4593 * Goes through a retry algorithm before giving up.
4595 STATIC s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw,
4596 u32 offset, u8 byte)
4599 u16 program_retries;
4601 DEBUGFUNC("e1000_retry_write_flash_byte_ich8lan");
4603 ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
4607 for (program_retries = 0; program_retries < 100; program_retries++) {
4608 DEBUGOUT2("Retrying Byte %2.2X at offset %u\n", byte, offset);
4610 ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
4611 if (ret_val == E1000_SUCCESS)
4614 if (program_retries == 100)
4615 return -E1000_ERR_NVM;
4617 return E1000_SUCCESS;
4621 * e1000_erase_flash_bank_ich8lan - Erase a bank (4k) from NVM
4622 * @hw: pointer to the HW structure
4623 * @bank: 0 for first bank, 1 for second bank, etc.
4625 * Erases the bank specified. Each bank is a 4k block. Banks are 0 based.
4626 * bank N is 4096 * N + flash_reg_addr.
4628 STATIC s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank)
4630 struct e1000_nvm_info *nvm = &hw->nvm;
4631 union ich8_hws_flash_status hsfsts;
4632 union ich8_hws_flash_ctrl hsflctl;
4633 u32 flash_linear_addr;
4634 /* bank size is in 16bit words - adjust to bytes */
4635 u32 flash_bank_size = nvm->flash_bank_size * 2;
4638 s32 j, iteration, sector_size;
4640 DEBUGFUNC("e1000_erase_flash_bank_ich8lan");
4642 hsfsts.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
4644 /* Determine HW Sector size: Read BERASE bits of hw flash status
4646 * 00: The Hw sector is 256 bytes, hence we need to erase 16
4647 * consecutive sectors. The start index for the nth Hw sector
4648 * can be calculated as = bank * 4096 + n * 256
4649 * 01: The Hw sector is 4K bytes, hence we need to erase 1 sector.
4650 * The start index for the nth Hw sector can be calculated
4652 * 10: The Hw sector is 8K bytes, nth sector = bank * 8192
4653 * (ich9 only, otherwise error condition)
4654 * 11: The Hw sector is 64K bytes, nth sector = bank * 65536
4656 switch (hsfsts.hsf_status.berasesz) {
4658 /* Hw sector size 256 */
4659 sector_size = ICH_FLASH_SEG_SIZE_256;
4660 iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_256;
4663 sector_size = ICH_FLASH_SEG_SIZE_4K;
4667 sector_size = ICH_FLASH_SEG_SIZE_8K;
4671 sector_size = ICH_FLASH_SEG_SIZE_64K;
4675 return -E1000_ERR_NVM;
4678 /* Start with the base address, then add the sector offset. */
4679 flash_linear_addr = hw->nvm.flash_base_addr;
4680 flash_linear_addr += (bank) ? flash_bank_size : 0;
4682 for (j = 0; j < iteration; j++) {
4684 u32 timeout = ICH_FLASH_ERASE_COMMAND_TIMEOUT;
4687 ret_val = e1000_flash_cycle_init_ich8lan(hw);
4691 /* Write a value 11 (block Erase) in Flash
4692 * Cycle field in hw flash control
4694 if (hw->mac.type >= e1000_pch_spt)
4696 E1000_READ_FLASH_REG(hw,
4697 ICH_FLASH_HSFSTS)>>16;
4700 E1000_READ_FLASH_REG16(hw,
4703 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_ERASE;
4704 if (hw->mac.type >= e1000_pch_spt)
4705 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_HSFSTS,
4706 hsflctl.regval << 16);
4708 E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFCTL,
4711 /* Write the last 24 bits of an index within the
4712 * block into Flash Linear address field in Flash
4715 flash_linear_addr += (j * sector_size);
4716 E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FADDR,
4719 ret_val = e1000_flash_cycle_ich8lan(hw, timeout);
4720 if (ret_val == E1000_SUCCESS)
4723 /* Check if FCERR is set to 1. If 1,
4724 * clear it and try the whole sequence
4725 * a few more times else Done
4727 hsfsts.regval = E1000_READ_FLASH_REG16(hw,
4729 if (hsfsts.hsf_status.flcerr)
4730 /* repeat for some time before giving up */
4732 else if (!hsfsts.hsf_status.flcdone)
4734 } while (++count < ICH_FLASH_CYCLE_REPEAT_COUNT);
4737 return E1000_SUCCESS;
4741 * e1000_valid_led_default_ich8lan - Set the default LED settings
4742 * @hw: pointer to the HW structure
4743 * @data: Pointer to the LED settings
4745 * Reads the LED default settings from the NVM to data. If the NVM LED
4746 * settings is all 0's or F's, set the LED default to a valid LED default
4749 STATIC s32 e1000_valid_led_default_ich8lan(struct e1000_hw *hw, u16 *data)
4753 DEBUGFUNC("e1000_valid_led_default_ich8lan");
4755 ret_val = hw->nvm.ops.read(hw, NVM_ID_LED_SETTINGS, 1, data);
4757 DEBUGOUT("NVM Read Error\n");
4761 if (*data == ID_LED_RESERVED_0000 || *data == ID_LED_RESERVED_FFFF)
4762 *data = ID_LED_DEFAULT_ICH8LAN;
4764 return E1000_SUCCESS;
4768 * e1000_id_led_init_pchlan - store LED configurations
4769 * @hw: pointer to the HW structure
4771 * PCH does not control LEDs via the LEDCTL register, rather it uses
4772 * the PHY LED configuration register.
4774 * PCH also does not have an "always on" or "always off" mode which
4775 * complicates the ID feature. Instead of using the "on" mode to indicate
4776 * in ledctl_mode2 the LEDs to use for ID (see e1000_id_led_init_generic()),
4777 * use "link_up" mode. The LEDs will still ID on request if there is no
4778 * link based on logic in e1000_led_[on|off]_pchlan().
4780 STATIC s32 e1000_id_led_init_pchlan(struct e1000_hw *hw)
4782 struct e1000_mac_info *mac = &hw->mac;
4784 const u32 ledctl_on = E1000_LEDCTL_MODE_LINK_UP;
4785 const u32 ledctl_off = E1000_LEDCTL_MODE_LINK_UP | E1000_PHY_LED0_IVRT;
4786 u16 data, i, temp, shift;
4788 DEBUGFUNC("e1000_id_led_init_pchlan");
4790 /* Get default ID LED modes */
4791 ret_val = hw->nvm.ops.valid_led_default(hw, &data);
4795 mac->ledctl_default = E1000_READ_REG(hw, E1000_LEDCTL);
4796 mac->ledctl_mode1 = mac->ledctl_default;
4797 mac->ledctl_mode2 = mac->ledctl_default;
4799 for (i = 0; i < 4; i++) {
4800 temp = (data >> (i << 2)) & E1000_LEDCTL_LED0_MODE_MASK;
4803 case ID_LED_ON1_DEF2:
4804 case ID_LED_ON1_ON2:
4805 case ID_LED_ON1_OFF2:
4806 mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
4807 mac->ledctl_mode1 |= (ledctl_on << shift);
4809 case ID_LED_OFF1_DEF2:
4810 case ID_LED_OFF1_ON2:
4811 case ID_LED_OFF1_OFF2:
4812 mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
4813 mac->ledctl_mode1 |= (ledctl_off << shift);
4820 case ID_LED_DEF1_ON2:
4821 case ID_LED_ON1_ON2:
4822 case ID_LED_OFF1_ON2:
4823 mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
4824 mac->ledctl_mode2 |= (ledctl_on << shift);
4826 case ID_LED_DEF1_OFF2:
4827 case ID_LED_ON1_OFF2:
4828 case ID_LED_OFF1_OFF2:
4829 mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
4830 mac->ledctl_mode2 |= (ledctl_off << shift);
4838 return E1000_SUCCESS;
4842 * e1000_get_bus_info_ich8lan - Get/Set the bus type and width
4843 * @hw: pointer to the HW structure
4845 * ICH8 use the PCI Express bus, but does not contain a PCI Express Capability
4846 * register, so the bus width is hard coded.
4848 STATIC s32 e1000_get_bus_info_ich8lan(struct e1000_hw *hw)
4850 struct e1000_bus_info *bus = &hw->bus;
4853 DEBUGFUNC("e1000_get_bus_info_ich8lan");
4855 ret_val = e1000_get_bus_info_pcie_generic(hw);
4857 /* ICH devices are "PCI Express"-ish. They have
4858 * a configuration space, but do not contain
4859 * PCI Express Capability registers, so bus width
4860 * must be hardcoded.
4862 if (bus->width == e1000_bus_width_unknown)
4863 bus->width = e1000_bus_width_pcie_x1;
4869 * e1000_reset_hw_ich8lan - Reset the hardware
4870 * @hw: pointer to the HW structure
4872 * Does a full reset of the hardware which includes a reset of the PHY and
4875 STATIC s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
4877 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
4883 DEBUGFUNC("e1000_reset_hw_ich8lan");
4885 /* Prevent the PCI-E bus from sticking if there is no TLP connection
4886 * on the last TLP read/write transaction when MAC is reset.
4888 ret_val = e1000_disable_pcie_master_generic(hw);
4890 DEBUGOUT("PCI-E Master disable polling has failed.\n");
4892 DEBUGOUT("Masking off all interrupts\n");
4893 E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
4895 /* Disable the Transmit and Receive units. Then delay to allow
4896 * any pending transactions to complete before we hit the MAC
4897 * with the global reset.
4899 E1000_WRITE_REG(hw, E1000_RCTL, 0);
4900 E1000_WRITE_REG(hw, E1000_TCTL, E1000_TCTL_PSP);
4901 E1000_WRITE_FLUSH(hw);
4905 /* Workaround for ICH8 bit corruption issue in FIFO memory */
4906 if (hw->mac.type == e1000_ich8lan) {
4907 /* Set Tx and Rx buffer allocation to 8k apiece. */
4908 E1000_WRITE_REG(hw, E1000_PBA, E1000_PBA_8K);
4909 /* Set Packet Buffer Size to 16k. */
4910 E1000_WRITE_REG(hw, E1000_PBS, E1000_PBS_16K);
4913 if (hw->mac.type == e1000_pchlan) {
4914 /* Save the NVM K1 bit setting*/
4915 ret_val = e1000_read_nvm(hw, E1000_NVM_K1_CONFIG, 1, &kum_cfg);
4919 if (kum_cfg & E1000_NVM_K1_ENABLE)
4920 dev_spec->nvm_k1_enabled = true;
4922 dev_spec->nvm_k1_enabled = false;
4925 ctrl = E1000_READ_REG(hw, E1000_CTRL);
4927 if (!hw->phy.ops.check_reset_block(hw)) {
4928 /* Full-chip reset requires MAC and PHY reset at the same
4929 * time to make sure the interface between MAC and the
4930 * external PHY is reset.
4932 ctrl |= E1000_CTRL_PHY_RST;
4934 /* Gate automatic PHY configuration by hardware on
4937 if ((hw->mac.type == e1000_pch2lan) &&
4938 !(E1000_READ_REG(hw, E1000_FWSM) & E1000_ICH_FWSM_FW_VALID))
4939 e1000_gate_hw_phy_config_ich8lan(hw, true);
4941 ret_val = e1000_acquire_swflag_ich8lan(hw);
4943 /* Read from EXTCNF_CTRL in e1000_acquire_swflag_ich8lan function
4944 * may occur during global reset and cause system hang.
4945 * Configuration space access creates the needed delay.
4946 * Write to E1000_STRAP RO register E1000_PCI_VENDOR_ID_REGISTER value
4947 * insures configuration space read is done before global reset.
4949 e1000_read_pci_cfg(hw, E1000_PCI_VENDOR_ID_REGISTER, &pci_cfg);
4950 E1000_WRITE_REG(hw, E1000_STRAP, pci_cfg);
4951 DEBUGOUT("Issuing a global reset to ich8lan\n");
4952 E1000_WRITE_REG(hw, E1000_CTRL, (ctrl | E1000_CTRL_RST));
4953 /* cannot issue a flush here because it hangs the hardware */
4956 /* Configuration space access improve HW level time sync mechanism.
4957 * Write to E1000_STRAP RO register E1000_PCI_VENDOR_ID_REGISTER
4958 * value to insure configuration space read is done
4959 * before any access to mac register.
4961 e1000_read_pci_cfg(hw, E1000_PCI_VENDOR_ID_REGISTER, &pci_cfg);
4962 E1000_WRITE_REG(hw, E1000_STRAP, pci_cfg);
4964 /* Set Phy Config Counter to 50msec */
4965 if (hw->mac.type == e1000_pch2lan) {
4966 reg = E1000_READ_REG(hw, E1000_FEXTNVM3);
4967 reg &= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK;
4968 reg |= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC;
4969 E1000_WRITE_REG(hw, E1000_FEXTNVM3, reg);
4973 E1000_MUTEX_UNLOCK(&hw->dev_spec.ich8lan.swflag_mutex);
4975 if (ctrl & E1000_CTRL_PHY_RST) {
4976 ret_val = hw->phy.ops.get_cfg_done(hw);
4980 ret_val = e1000_post_phy_reset_ich8lan(hw);
4985 /* For PCH, this write will make sure that any noise
4986 * will be detected as a CRC error and be dropped rather than show up
4987 * as a bad packet to the DMA engine.
4989 if (hw->mac.type == e1000_pchlan)
4990 E1000_WRITE_REG(hw, E1000_CRC_OFFSET, 0x65656565);
4992 E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
4993 E1000_READ_REG(hw, E1000_ICR);
4995 reg = E1000_READ_REG(hw, E1000_KABGTXD);
4996 reg |= E1000_KABGTXD_BGSQLBIAS;
4997 E1000_WRITE_REG(hw, E1000_KABGTXD, reg);
4999 return E1000_SUCCESS;
5003 * e1000_init_hw_ich8lan - Initialize the hardware
5004 * @hw: pointer to the HW structure
5006 * Prepares the hardware for transmit and receive by doing the following:
5007 * - initialize hardware bits
5008 * - initialize LED identification
5009 * - setup receive address registers
5010 * - setup flow control
5011 * - setup transmit descriptors
5012 * - clear statistics
5014 STATIC s32 e1000_init_hw_ich8lan(struct e1000_hw *hw)
5016 struct e1000_mac_info *mac = &hw->mac;
5017 u32 ctrl_ext, txdctl, snoop;
5021 DEBUGFUNC("e1000_init_hw_ich8lan");
5023 e1000_initialize_hw_bits_ich8lan(hw);
5025 /* Initialize identification LED */
5026 ret_val = mac->ops.id_led_init(hw);
5027 /* An error is not fatal and we should not stop init due to this */
5029 DEBUGOUT("Error initializing identification LED\n");
5031 /* Setup the receive address. */
5032 e1000_init_rx_addrs_generic(hw, mac->rar_entry_count);
5034 /* Zero out the Multicast HASH table */
5035 DEBUGOUT("Zeroing the MTA\n");
5036 for (i = 0; i < mac->mta_reg_count; i++)
5037 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
5039 /* The 82578 Rx buffer will stall if wakeup is enabled in host and
5040 * the ME. Disable wakeup by clearing the host wakeup bit.
5041 * Reset the phy after disabling host wakeup to reset the Rx buffer.
5043 if (hw->phy.type == e1000_phy_82578) {
5044 hw->phy.ops.read_reg(hw, BM_PORT_GEN_CFG, &i);
5045 i &= ~BM_WUC_HOST_WU_BIT;
5046 hw->phy.ops.write_reg(hw, BM_PORT_GEN_CFG, i);
5047 ret_val = e1000_phy_hw_reset_ich8lan(hw);
5052 /* Setup link and flow control */
5053 ret_val = mac->ops.setup_link(hw);
5055 /* Set the transmit descriptor write-back policy for both queues */
5056 txdctl = E1000_READ_REG(hw, E1000_TXDCTL(0));
5057 txdctl = ((txdctl & ~E1000_TXDCTL_WTHRESH) |
5058 E1000_TXDCTL_FULL_TX_DESC_WB);
5059 txdctl = ((txdctl & ~E1000_TXDCTL_PTHRESH) |
5060 E1000_TXDCTL_MAX_TX_DESC_PREFETCH);
5061 E1000_WRITE_REG(hw, E1000_TXDCTL(0), txdctl);
5062 txdctl = E1000_READ_REG(hw, E1000_TXDCTL(1));
5063 txdctl = ((txdctl & ~E1000_TXDCTL_WTHRESH) |
5064 E1000_TXDCTL_FULL_TX_DESC_WB);
5065 txdctl = ((txdctl & ~E1000_TXDCTL_PTHRESH) |
5066 E1000_TXDCTL_MAX_TX_DESC_PREFETCH);
5067 E1000_WRITE_REG(hw, E1000_TXDCTL(1), txdctl);
5069 /* ICH8 has opposite polarity of no_snoop bits.
5070 * By default, we should use snoop behavior.
5072 if (mac->type == e1000_ich8lan)
5073 snoop = PCIE_ICH8_SNOOP_ALL;
5075 snoop = (u32) ~(PCIE_NO_SNOOP_ALL);
5076 e1000_set_pcie_no_snoop_generic(hw, snoop);
5078 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
5079 ctrl_ext |= E1000_CTRL_EXT_RO_DIS;
5080 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
5082 /* Clear all of the statistics registers (clear on read). It is
5083 * important that we do this after we have tried to establish link
5084 * because the symbol error count will increment wildly if there
5087 e1000_clear_hw_cntrs_ich8lan(hw);
5093 * e1000_initialize_hw_bits_ich8lan - Initialize required hardware bits
5094 * @hw: pointer to the HW structure
5096 * Sets/Clears required hardware bits necessary for correctly setting up the
5097 * hardware for transmit and receive.
5099 STATIC void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw)
5103 DEBUGFUNC("e1000_initialize_hw_bits_ich8lan");
5105 /* Extended Device Control */
5106 reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
5108 /* Enable PHY low-power state when MAC is at D3 w/o WoL */
5109 if (hw->mac.type >= e1000_pchlan)
5110 reg |= E1000_CTRL_EXT_PHYPDEN;
5111 E1000_WRITE_REG(hw, E1000_CTRL_EXT, reg);
5113 /* Transmit Descriptor Control 0 */
5114 reg = E1000_READ_REG(hw, E1000_TXDCTL(0));
5116 E1000_WRITE_REG(hw, E1000_TXDCTL(0), reg);
5118 /* Transmit Descriptor Control 1 */
5119 reg = E1000_READ_REG(hw, E1000_TXDCTL(1));
5121 E1000_WRITE_REG(hw, E1000_TXDCTL(1), reg);
5123 /* Transmit Arbitration Control 0 */
5124 reg = E1000_READ_REG(hw, E1000_TARC(0));
5125 if (hw->mac.type == e1000_ich8lan)
5126 reg |= (1 << 28) | (1 << 29);
5127 reg |= (1 << 23) | (1 << 24) | (1 << 26) | (1 << 27);
5128 E1000_WRITE_REG(hw, E1000_TARC(0), reg);
5130 /* Transmit Arbitration Control 1 */
5131 reg = E1000_READ_REG(hw, E1000_TARC(1));
5132 if (E1000_READ_REG(hw, E1000_TCTL) & E1000_TCTL_MULR)
5136 reg |= (1 << 24) | (1 << 26) | (1 << 30);
5137 E1000_WRITE_REG(hw, E1000_TARC(1), reg);
5140 if (hw->mac.type == e1000_ich8lan) {
5141 reg = E1000_READ_REG(hw, E1000_STATUS);
5143 E1000_WRITE_REG(hw, E1000_STATUS, reg);
5146 /* work-around descriptor data corruption issue during nfs v2 udp
5147 * traffic, just disable the nfs filtering capability
5149 reg = E1000_READ_REG(hw, E1000_RFCTL);
5150 reg |= (E1000_RFCTL_NFSW_DIS | E1000_RFCTL_NFSR_DIS);
5152 /* Disable IPv6 extension header parsing because some malformed
5153 * IPv6 headers can hang the Rx.
5155 if (hw->mac.type == e1000_ich8lan)
5156 reg |= (E1000_RFCTL_IPV6_EX_DIS | E1000_RFCTL_NEW_IPV6_EXT_DIS);
5157 E1000_WRITE_REG(hw, E1000_RFCTL, reg);
5159 /* Enable ECC on Lynxpoint */
5160 if (hw->mac.type >= e1000_pch_lpt) {
5161 reg = E1000_READ_REG(hw, E1000_PBECCSTS);
5162 reg |= E1000_PBECCSTS_ECC_ENABLE;
5163 E1000_WRITE_REG(hw, E1000_PBECCSTS, reg);
5165 reg = E1000_READ_REG(hw, E1000_CTRL);
5166 reg |= E1000_CTRL_MEHE;
5167 E1000_WRITE_REG(hw, E1000_CTRL, reg);
5174 * e1000_setup_link_ich8lan - Setup flow control and link settings
5175 * @hw: pointer to the HW structure
5177 * Determines which flow control settings to use, then configures flow
5178 * control. Calls the appropriate media-specific link configuration
5179 * function. Assuming the adapter has a valid link partner, a valid link
5180 * should be established. Assumes the hardware has previously been reset
5181 * and the transmitter and receiver are not enabled.
5183 STATIC s32 e1000_setup_link_ich8lan(struct e1000_hw *hw)
5187 DEBUGFUNC("e1000_setup_link_ich8lan");
5189 /* ICH parts do not have a word in the NVM to determine
5190 * the default flow control setting, so we explicitly
5193 if (hw->fc.requested_mode == e1000_fc_default)
5194 hw->fc.requested_mode = e1000_fc_full;
5196 /* Save off the requested flow control mode for use later. Depending
5197 * on the link partner's capabilities, we may or may not use this mode.
5199 hw->fc.current_mode = hw->fc.requested_mode;
5201 DEBUGOUT1("After fix-ups FlowControl is now = %x\n",
5202 hw->fc.current_mode);
5204 if (!hw->phy.ops.check_reset_block(hw)) {
5205 /* Continue to configure the copper link. */
5206 ret_val = hw->mac.ops.setup_physical_interface(hw);
5211 E1000_WRITE_REG(hw, E1000_FCTTV, hw->fc.pause_time);
5212 if ((hw->phy.type == e1000_phy_82578) ||
5213 (hw->phy.type == e1000_phy_82579) ||
5214 (hw->phy.type == e1000_phy_i217) ||
5215 (hw->phy.type == e1000_phy_82577)) {
5216 E1000_WRITE_REG(hw, E1000_FCRTV_PCH, hw->fc.refresh_time);
5218 ret_val = hw->phy.ops.write_reg(hw,
5219 PHY_REG(BM_PORT_CTRL_PAGE, 27),
5225 return e1000_set_fc_watermarks_generic(hw);
5229 * e1000_setup_copper_link_ich8lan - Configure MAC/PHY interface
5230 * @hw: pointer to the HW structure
5232 * Configures the kumeran interface to the PHY to wait the appropriate time
5233 * when polling the PHY, then call the generic setup_copper_link to finish
5234 * configuring the copper link.
5236 STATIC s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw)
5242 DEBUGFUNC("e1000_setup_copper_link_ich8lan");
5244 ctrl = E1000_READ_REG(hw, E1000_CTRL);
5245 ctrl |= E1000_CTRL_SLU;
5246 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
5247 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
5249 /* Set the mac to wait the maximum time between each iteration
5250 * and increase the max iterations when polling the phy;
5251 * this fixes erroneous timeouts at 10Mbps.
5253 ret_val = e1000_write_kmrn_reg_generic(hw, E1000_KMRNCTRLSTA_TIMEOUTS,
5257 ret_val = e1000_read_kmrn_reg_generic(hw,
5258 E1000_KMRNCTRLSTA_INBAND_PARAM,
5263 ret_val = e1000_write_kmrn_reg_generic(hw,
5264 E1000_KMRNCTRLSTA_INBAND_PARAM,
5269 switch (hw->phy.type) {
5270 case e1000_phy_igp_3:
5271 ret_val = e1000_copper_link_setup_igp(hw);
5276 case e1000_phy_82578:
5277 ret_val = e1000_copper_link_setup_m88(hw);
5281 case e1000_phy_82577:
5282 case e1000_phy_82579:
5283 ret_val = e1000_copper_link_setup_82577(hw);
5288 ret_val = hw->phy.ops.read_reg(hw, IFE_PHY_MDIX_CONTROL,
5293 reg_data &= ~IFE_PMC_AUTO_MDIX;
5295 switch (hw->phy.mdix) {
5297 reg_data &= ~IFE_PMC_FORCE_MDIX;
5300 reg_data |= IFE_PMC_FORCE_MDIX;
5304 reg_data |= IFE_PMC_AUTO_MDIX;
5307 ret_val = hw->phy.ops.write_reg(hw, IFE_PHY_MDIX_CONTROL,
5316 return e1000_setup_copper_link_generic(hw);
5320 * e1000_setup_copper_link_pch_lpt - Configure MAC/PHY interface
5321 * @hw: pointer to the HW structure
5323 * Calls the PHY specific link setup function and then calls the
5324 * generic setup_copper_link to finish configuring the link for
5325 * Lynxpoint PCH devices
5327 STATIC s32 e1000_setup_copper_link_pch_lpt(struct e1000_hw *hw)
5332 DEBUGFUNC("e1000_setup_copper_link_pch_lpt");
5334 ctrl = E1000_READ_REG(hw, E1000_CTRL);
5335 ctrl |= E1000_CTRL_SLU;
5336 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
5337 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
5339 ret_val = e1000_copper_link_setup_82577(hw);
5343 return e1000_setup_copper_link_generic(hw);
5347 * e1000_get_link_up_info_ich8lan - Get current link speed and duplex
5348 * @hw: pointer to the HW structure
5349 * @speed: pointer to store current link speed
5350 * @duplex: pointer to store the current link duplex
5352 * Calls the generic get_speed_and_duplex to retrieve the current link
5353 * information and then calls the Kumeran lock loss workaround for links at
5356 STATIC s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw, u16 *speed,
5361 DEBUGFUNC("e1000_get_link_up_info_ich8lan");
5363 ret_val = e1000_get_speed_and_duplex_copper_generic(hw, speed, duplex);
5367 if ((hw->mac.type == e1000_ich8lan) &&
5368 (hw->phy.type == e1000_phy_igp_3) &&
5369 (*speed == SPEED_1000)) {
5370 ret_val = e1000_kmrn_lock_loss_workaround_ich8lan(hw);
5377 * e1000_kmrn_lock_loss_workaround_ich8lan - Kumeran workaround
5378 * @hw: pointer to the HW structure
5380 * Work-around for 82566 Kumeran PCS lock loss:
5381 * On link status change (i.e. PCI reset, speed change) and link is up and
5383 * 0) if workaround is optionally disabled do nothing
5384 * 1) wait 1ms for Kumeran link to come up
5385 * 2) check Kumeran Diagnostic register PCS lock loss bit
5386 * 3) if not set the link is locked (all is good), otherwise...
5388 * 5) repeat up to 10 times
5389 * Note: this is only called for IGP3 copper when speed is 1gb.
5391 STATIC s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw)
5393 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
5399 DEBUGFUNC("e1000_kmrn_lock_loss_workaround_ich8lan");
5401 if (!dev_spec->kmrn_lock_loss_workaround_enabled)
5402 return E1000_SUCCESS;
5404 /* Make sure link is up before proceeding. If not just return.
5405 * Attempting this while link is negotiating fouled up link
5408 ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link);
5410 return E1000_SUCCESS;
5412 for (i = 0; i < 10; i++) {
5413 /* read once to clear */
5414 ret_val = hw->phy.ops.read_reg(hw, IGP3_KMRN_DIAG, &data);
5417 /* and again to get new status */
5418 ret_val = hw->phy.ops.read_reg(hw, IGP3_KMRN_DIAG, &data);
5422 /* check for PCS lock */
5423 if (!(data & IGP3_KMRN_DIAG_PCS_LOCK_LOSS))
5424 return E1000_SUCCESS;
5426 /* Issue PHY reset */
5427 hw->phy.ops.reset(hw);
5430 /* Disable GigE link negotiation */
5431 phy_ctrl = E1000_READ_REG(hw, E1000_PHY_CTRL);
5432 phy_ctrl |= (E1000_PHY_CTRL_GBE_DISABLE |
5433 E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
5434 E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl);
5436 /* Call gig speed drop workaround on Gig disable before accessing
5439 e1000_gig_downshift_workaround_ich8lan(hw);
5441 /* unable to acquire PCS lock */
5442 return -E1000_ERR_PHY;
5446 * e1000_set_kmrn_lock_loss_workaround_ich8lan - Set Kumeran workaround state
5447 * @hw: pointer to the HW structure
5448 * @state: boolean value used to set the current Kumeran workaround state
5450 * If ICH8, set the current Kumeran workaround state (enabled - true
5451 * /disabled - false).
5453 void e1000_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw,
5456 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
5458 DEBUGFUNC("e1000_set_kmrn_lock_loss_workaround_ich8lan");
5460 if (hw->mac.type != e1000_ich8lan) {
5461 DEBUGOUT("Workaround applies to ICH8 only.\n");
5465 dev_spec->kmrn_lock_loss_workaround_enabled = state;
5471 * e1000_ipg3_phy_powerdown_workaround_ich8lan - Power down workaround on D3
5472 * @hw: pointer to the HW structure
5474 * Workaround for 82566 power-down on D3 entry:
5475 * 1) disable gigabit link
5476 * 2) write VR power-down enable
5478 * Continue if successful, else issue LCD reset and repeat
5480 void e1000_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw)
5486 DEBUGFUNC("e1000_igp3_phy_powerdown_workaround_ich8lan");
5488 if (hw->phy.type != e1000_phy_igp_3)
5491 /* Try the workaround twice (if needed) */
5494 reg = E1000_READ_REG(hw, E1000_PHY_CTRL);
5495 reg |= (E1000_PHY_CTRL_GBE_DISABLE |
5496 E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
5497 E1000_WRITE_REG(hw, E1000_PHY_CTRL, reg);
5499 /* Call gig speed drop workaround on Gig disable before
5500 * accessing any PHY registers
5502 if (hw->mac.type == e1000_ich8lan)
5503 e1000_gig_downshift_workaround_ich8lan(hw);
5505 /* Write VR power-down enable */
5506 hw->phy.ops.read_reg(hw, IGP3_VR_CTRL, &data);
5507 data &= ~IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
5508 hw->phy.ops.write_reg(hw, IGP3_VR_CTRL,
5509 data | IGP3_VR_CTRL_MODE_SHUTDOWN);
5511 /* Read it back and test */
5512 hw->phy.ops.read_reg(hw, IGP3_VR_CTRL, &data);
5513 data &= IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
5514 if ((data == IGP3_VR_CTRL_MODE_SHUTDOWN) || retry)
5517 /* Issue PHY reset and repeat at most one more time */
5518 reg = E1000_READ_REG(hw, E1000_CTRL);
5519 E1000_WRITE_REG(hw, E1000_CTRL, reg | E1000_CTRL_PHY_RST);
5525 * e1000_gig_downshift_workaround_ich8lan - WoL from S5 stops working
5526 * @hw: pointer to the HW structure
5528 * Steps to take when dropping from 1Gb/s (eg. link cable removal (LSC),
5529 * LPLU, Gig disable, MDIC PHY reset):
5530 * 1) Set Kumeran Near-end loopback
5531 * 2) Clear Kumeran Near-end loopback
5532 * Should only be called for ICH8[m] devices with any 1G Phy.
5534 void e1000_gig_downshift_workaround_ich8lan(struct e1000_hw *hw)
5539 DEBUGFUNC("e1000_gig_downshift_workaround_ich8lan");
5541 if ((hw->mac.type != e1000_ich8lan) ||
5542 (hw->phy.type == e1000_phy_ife))
5545 ret_val = e1000_read_kmrn_reg_generic(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
5549 reg_data |= E1000_KMRNCTRLSTA_DIAG_NELPBK;
5550 ret_val = e1000_write_kmrn_reg_generic(hw,
5551 E1000_KMRNCTRLSTA_DIAG_OFFSET,
5555 reg_data &= ~E1000_KMRNCTRLSTA_DIAG_NELPBK;
5556 e1000_write_kmrn_reg_generic(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
5561 * e1000_suspend_workarounds_ich8lan - workarounds needed during S0->Sx
5562 * @hw: pointer to the HW structure
5564 * During S0 to Sx transition, it is possible the link remains at gig
5565 * instead of negotiating to a lower speed. Before going to Sx, set
5566 * 'Gig Disable' to force link speed negotiation to a lower speed based on
5567 * the LPLU setting in the NVM or custom setting. For PCH and newer parts,
5568 * the OEM bits PHY register (LED, GbE disable and LPLU configurations) also
5569 * needs to be written.
5570 * Parts that support (and are linked to a partner which support) EEE in
5571 * 100Mbps should disable LPLU since 100Mbps w/ EEE requires less power
5572 * than 10Mbps w/o EEE.
5574 void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw)
5576 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
5580 DEBUGFUNC("e1000_suspend_workarounds_ich8lan");
5582 phy_ctrl = E1000_READ_REG(hw, E1000_PHY_CTRL);
5583 phy_ctrl |= E1000_PHY_CTRL_GBE_DISABLE;
5585 if (hw->phy.type == e1000_phy_i217) {
5586 u16 phy_reg, device_id = hw->device_id;
5588 if ((device_id == E1000_DEV_ID_PCH_LPTLP_I218_LM) ||
5589 (device_id == E1000_DEV_ID_PCH_LPTLP_I218_V) ||
5590 (device_id == E1000_DEV_ID_PCH_I218_LM3) ||
5591 (device_id == E1000_DEV_ID_PCH_I218_V3) ||
5592 (hw->mac.type >= e1000_pch_spt)) {
5593 u32 fextnvm6 = E1000_READ_REG(hw, E1000_FEXTNVM6);
5595 E1000_WRITE_REG(hw, E1000_FEXTNVM6,
5596 fextnvm6 & ~E1000_FEXTNVM6_REQ_PLL_CLK);
5599 ret_val = hw->phy.ops.acquire(hw);
5603 if (!dev_spec->eee_disable) {
5607 e1000_read_emi_reg_locked(hw,
5608 I217_EEE_ADVERTISEMENT,
5613 /* Disable LPLU if both link partners support 100BaseT
5614 * EEE and 100Full is advertised on both ends of the
5615 * link, and enable Auto Enable LPI since there will
5616 * be no driver to enable LPI while in Sx.
5618 if ((eee_advert & I82579_EEE_100_SUPPORTED) &&
5619 (dev_spec->eee_lp_ability &
5620 I82579_EEE_100_SUPPORTED) &&
5621 (hw->phy.autoneg_advertised & ADVERTISE_100_FULL)) {
5622 phy_ctrl &= ~(E1000_PHY_CTRL_D0A_LPLU |
5623 E1000_PHY_CTRL_NOND0A_LPLU);
5625 /* Set Auto Enable LPI after link up */
5626 hw->phy.ops.read_reg_locked(hw,
5629 phy_reg |= I217_LPI_GPIO_CTRL_AUTO_EN_LPI;
5630 hw->phy.ops.write_reg_locked(hw,
5636 /* For i217 Intel Rapid Start Technology support,
5637 * when the system is going into Sx and no manageability engine
5638 * is present, the driver must configure proxy to reset only on
5639 * power good. LPI (Low Power Idle) state must also reset only
5640 * on power good, as well as the MTA (Multicast table array).
5641 * The SMBus release must also be disabled on LCD reset.
5643 if (!(E1000_READ_REG(hw, E1000_FWSM) &
5644 E1000_ICH_FWSM_FW_VALID)) {
5645 /* Enable proxy to reset only on power good. */
5646 hw->phy.ops.read_reg_locked(hw, I217_PROXY_CTRL,
5648 phy_reg |= I217_PROXY_CTRL_AUTO_DISABLE;
5649 hw->phy.ops.write_reg_locked(hw, I217_PROXY_CTRL,
5652 /* Set bit enable LPI (EEE) to reset only on
5655 hw->phy.ops.read_reg_locked(hw, I217_SxCTRL, &phy_reg);
5656 phy_reg |= I217_SxCTRL_ENABLE_LPI_RESET;
5657 hw->phy.ops.write_reg_locked(hw, I217_SxCTRL, phy_reg);
5659 /* Disable the SMB release on LCD reset. */
5660 hw->phy.ops.read_reg_locked(hw, I217_MEMPWR, &phy_reg);
5661 phy_reg &= ~I217_MEMPWR_DISABLE_SMB_RELEASE;
5662 hw->phy.ops.write_reg_locked(hw, I217_MEMPWR, phy_reg);
5665 /* Enable MTA to reset for Intel Rapid Start Technology
5668 hw->phy.ops.read_reg_locked(hw, I217_CGFREG, &phy_reg);
5669 phy_reg |= I217_CGFREG_ENABLE_MTA_RESET;
5670 hw->phy.ops.write_reg_locked(hw, I217_CGFREG, phy_reg);
5673 hw->phy.ops.release(hw);
5676 E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl);
5678 if (hw->mac.type == e1000_ich8lan)
5679 e1000_gig_downshift_workaround_ich8lan(hw);
5681 if (hw->mac.type >= e1000_pchlan) {
5682 e1000_oem_bits_config_ich8lan(hw, false);
5684 /* Reset PHY to activate OEM bits on 82577/8 */
5685 if (hw->mac.type == e1000_pchlan)
5686 e1000_phy_hw_reset_generic(hw);
5688 ret_val = hw->phy.ops.acquire(hw);
5691 e1000_write_smbus_addr(hw);
5692 hw->phy.ops.release(hw);
5699 * e1000_resume_workarounds_pchlan - workarounds needed during Sx->S0
5700 * @hw: pointer to the HW structure
5702 * During Sx to S0 transitions on non-managed devices or managed devices
5703 * on which PHY resets are not blocked, if the PHY registers cannot be
5704 * accessed properly by the s/w toggle the LANPHYPC value to power cycle
5706 * On i217, setup Intel Rapid Start Technology.
5708 u32 e1000_resume_workarounds_pchlan(struct e1000_hw *hw)
5712 DEBUGFUNC("e1000_resume_workarounds_pchlan");
5713 if (hw->mac.type < e1000_pch2lan)
5714 return E1000_SUCCESS;
5716 ret_val = e1000_init_phy_workarounds_pchlan(hw);
5718 DEBUGOUT1("Failed to init PHY flow ret_val=%d\n", ret_val);
5722 /* For i217 Intel Rapid Start Technology support when the system
5723 * is transitioning from Sx and no manageability engine is present
5724 * configure SMBus to restore on reset, disable proxy, and enable
5725 * the reset on MTA (Multicast table array).
5727 if (hw->phy.type == e1000_phy_i217) {
5730 ret_val = hw->phy.ops.acquire(hw);
5732 DEBUGOUT("Failed to setup iRST\n");
5736 /* Clear Auto Enable LPI after link up */
5737 hw->phy.ops.read_reg_locked(hw, I217_LPI_GPIO_CTRL, &phy_reg);
5738 phy_reg &= ~I217_LPI_GPIO_CTRL_AUTO_EN_LPI;
5739 hw->phy.ops.write_reg_locked(hw, I217_LPI_GPIO_CTRL, phy_reg);
5741 if (!(E1000_READ_REG(hw, E1000_FWSM) &
5742 E1000_ICH_FWSM_FW_VALID)) {
5743 /* Restore clear on SMB if no manageability engine
5746 ret_val = hw->phy.ops.read_reg_locked(hw, I217_MEMPWR,
5750 phy_reg |= I217_MEMPWR_DISABLE_SMB_RELEASE;
5751 hw->phy.ops.write_reg_locked(hw, I217_MEMPWR, phy_reg);
5754 hw->phy.ops.write_reg_locked(hw, I217_PROXY_CTRL, 0);
5756 /* Enable reset on MTA */
5757 ret_val = hw->phy.ops.read_reg_locked(hw, I217_CGFREG,
5761 phy_reg &= ~I217_CGFREG_ENABLE_MTA_RESET;
5762 hw->phy.ops.write_reg_locked(hw, I217_CGFREG, phy_reg);
5765 DEBUGOUT1("Error %d in resume workarounds\n", ret_val);
5766 hw->phy.ops.release(hw);
5769 return E1000_SUCCESS;
5773 * e1000_cleanup_led_ich8lan - Restore the default LED operation
5774 * @hw: pointer to the HW structure
5776 * Return the LED back to the default configuration.
5778 STATIC s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw)
5780 DEBUGFUNC("e1000_cleanup_led_ich8lan");
5782 if (hw->phy.type == e1000_phy_ife)
5783 return hw->phy.ops.write_reg(hw, IFE_PHY_SPECIAL_CONTROL_LED,
5786 E1000_WRITE_REG(hw, E1000_LEDCTL, hw->mac.ledctl_default);
5787 return E1000_SUCCESS;
5791 * e1000_led_on_ich8lan - Turn LEDs on
5792 * @hw: pointer to the HW structure
5796 STATIC s32 e1000_led_on_ich8lan(struct e1000_hw *hw)
5798 DEBUGFUNC("e1000_led_on_ich8lan");
5800 if (hw->phy.type == e1000_phy_ife)
5801 return hw->phy.ops.write_reg(hw, IFE_PHY_SPECIAL_CONTROL_LED,
5802 (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_ON));
5804 E1000_WRITE_REG(hw, E1000_LEDCTL, hw->mac.ledctl_mode2);
5805 return E1000_SUCCESS;
5809 * e1000_led_off_ich8lan - Turn LEDs off
5810 * @hw: pointer to the HW structure
5812 * Turn off the LEDs.
5814 STATIC s32 e1000_led_off_ich8lan(struct e1000_hw *hw)
5816 DEBUGFUNC("e1000_led_off_ich8lan");
5818 if (hw->phy.type == e1000_phy_ife)
5819 return hw->phy.ops.write_reg(hw, IFE_PHY_SPECIAL_CONTROL_LED,
5820 (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_OFF));
5822 E1000_WRITE_REG(hw, E1000_LEDCTL, hw->mac.ledctl_mode1);
5823 return E1000_SUCCESS;
5827 * e1000_setup_led_pchlan - Configures SW controllable LED
5828 * @hw: pointer to the HW structure
5830 * This prepares the SW controllable LED for use.
5832 STATIC s32 e1000_setup_led_pchlan(struct e1000_hw *hw)
5834 DEBUGFUNC("e1000_setup_led_pchlan");
5836 return hw->phy.ops.write_reg(hw, HV_LED_CONFIG,
5837 (u16)hw->mac.ledctl_mode1);
5841 * e1000_cleanup_led_pchlan - Restore the default LED operation
5842 * @hw: pointer to the HW structure
5844 * Return the LED back to the default configuration.
5846 STATIC s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw)
5848 DEBUGFUNC("e1000_cleanup_led_pchlan");
5850 return hw->phy.ops.write_reg(hw, HV_LED_CONFIG,
5851 (u16)hw->mac.ledctl_default);
5855 * e1000_led_on_pchlan - Turn LEDs on
5856 * @hw: pointer to the HW structure
5860 STATIC s32 e1000_led_on_pchlan(struct e1000_hw *hw)
5862 u16 data = (u16)hw->mac.ledctl_mode2;
5865 DEBUGFUNC("e1000_led_on_pchlan");
5867 /* If no link, then turn LED on by setting the invert bit
5868 * for each LED that's mode is "link_up" in ledctl_mode2.
5870 if (!(E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU)) {
5871 for (i = 0; i < 3; i++) {
5872 led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
5873 if ((led & E1000_PHY_LED0_MODE_MASK) !=
5874 E1000_LEDCTL_MODE_LINK_UP)
5876 if (led & E1000_PHY_LED0_IVRT)
5877 data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
5879 data |= (E1000_PHY_LED0_IVRT << (i * 5));
5883 return hw->phy.ops.write_reg(hw, HV_LED_CONFIG, data);
5887 * e1000_led_off_pchlan - Turn LEDs off
5888 * @hw: pointer to the HW structure
5890 * Turn off the LEDs.
5892 STATIC s32 e1000_led_off_pchlan(struct e1000_hw *hw)
5894 u16 data = (u16)hw->mac.ledctl_mode1;
5897 DEBUGFUNC("e1000_led_off_pchlan");
5899 /* If no link, then turn LED off by clearing the invert bit
5900 * for each LED that's mode is "link_up" in ledctl_mode1.
5902 if (!(E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU)) {
5903 for (i = 0; i < 3; i++) {
5904 led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
5905 if ((led & E1000_PHY_LED0_MODE_MASK) !=
5906 E1000_LEDCTL_MODE_LINK_UP)
5908 if (led & E1000_PHY_LED0_IVRT)
5909 data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
5911 data |= (E1000_PHY_LED0_IVRT << (i * 5));
5915 return hw->phy.ops.write_reg(hw, HV_LED_CONFIG, data);
5919 * e1000_get_cfg_done_ich8lan - Read config done bit after Full or PHY reset
5920 * @hw: pointer to the HW structure
5922 * Read appropriate register for the config done bit for completion status
5923 * and configure the PHY through s/w for EEPROM-less parts.
5925 * NOTE: some silicon which is EEPROM-less will fail trying to read the
5926 * config done bit, so only an error is logged and continues. If we were
5927 * to return with error, EEPROM-less silicon would not be able to be reset
5930 STATIC s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw)
5932 s32 ret_val = E1000_SUCCESS;
5936 DEBUGFUNC("e1000_get_cfg_done_ich8lan");
5938 e1000_get_cfg_done_generic(hw);
5940 /* Wait for indication from h/w that it has completed basic config */
5941 if (hw->mac.type >= e1000_ich10lan) {
5942 e1000_lan_init_done_ich8lan(hw);
5944 ret_val = e1000_get_auto_rd_done_generic(hw);
5946 /* When auto config read does not complete, do not
5947 * return with an error. This can happen in situations
5948 * where there is no eeprom and prevents getting link.
5950 DEBUGOUT("Auto Read Done did not complete\n");
5951 ret_val = E1000_SUCCESS;
5955 /* Clear PHY Reset Asserted bit */
5956 status = E1000_READ_REG(hw, E1000_STATUS);
5957 if (status & E1000_STATUS_PHYRA)
5958 E1000_WRITE_REG(hw, E1000_STATUS, status & ~E1000_STATUS_PHYRA);
5960 DEBUGOUT("PHY Reset Asserted not set - needs delay\n");
5962 /* If EEPROM is not marked present, init the IGP 3 PHY manually */
5963 if (hw->mac.type <= e1000_ich9lan) {
5964 if (!(E1000_READ_REG(hw, E1000_EECD) & E1000_EECD_PRES) &&
5965 (hw->phy.type == e1000_phy_igp_3)) {
5966 e1000_phy_init_script_igp3(hw);
5969 if (e1000_valid_nvm_bank_detect_ich8lan(hw, &bank)) {
5970 /* Maybe we should do a basic PHY config */
5971 DEBUGOUT("EEPROM not present\n");
5972 ret_val = -E1000_ERR_CONFIG;
5980 * e1000_power_down_phy_copper_ich8lan - Remove link during PHY power down
5981 * @hw: pointer to the HW structure
5983 * In the case of a PHY power down to save power, or to turn off link during a
5984 * driver unload, or wake on lan is not enabled, remove the link.
5986 STATIC void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw)
5988 /* If the management interface is not enabled, then power down */
5989 if (!(hw->mac.ops.check_mng_mode(hw) ||
5990 hw->phy.ops.check_reset_block(hw)))
5991 e1000_power_down_phy_copper(hw);
5997 * e1000_clear_hw_cntrs_ich8lan - Clear statistical counters
5998 * @hw: pointer to the HW structure
6000 * Clears hardware counters specific to the silicon family and calls
6001 * clear_hw_cntrs_generic to clear all general purpose counters.
6003 STATIC void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw)
6008 DEBUGFUNC("e1000_clear_hw_cntrs_ich8lan");
6010 e1000_clear_hw_cntrs_base_generic(hw);
6012 E1000_READ_REG(hw, E1000_ALGNERRC);
6013 E1000_READ_REG(hw, E1000_RXERRC);
6014 E1000_READ_REG(hw, E1000_TNCRS);
6015 E1000_READ_REG(hw, E1000_CEXTERR);
6016 E1000_READ_REG(hw, E1000_TSCTC);
6017 E1000_READ_REG(hw, E1000_TSCTFC);
6019 E1000_READ_REG(hw, E1000_MGTPRC);
6020 E1000_READ_REG(hw, E1000_MGTPDC);
6021 E1000_READ_REG(hw, E1000_MGTPTC);
6023 E1000_READ_REG(hw, E1000_IAC);
6024 E1000_READ_REG(hw, E1000_ICRXOC);
6026 /* Clear PHY statistics registers */
6027 if ((hw->phy.type == e1000_phy_82578) ||
6028 (hw->phy.type == e1000_phy_82579) ||
6029 (hw->phy.type == e1000_phy_i217) ||
6030 (hw->phy.type == e1000_phy_82577)) {
6031 ret_val = hw->phy.ops.acquire(hw);
6034 ret_val = hw->phy.ops.set_page(hw,
6035 HV_STATS_PAGE << IGP_PAGE_SHIFT);
6038 hw->phy.ops.read_reg_page(hw, HV_SCC_UPPER, &phy_data);
6039 hw->phy.ops.read_reg_page(hw, HV_SCC_LOWER, &phy_data);
6040 hw->phy.ops.read_reg_page(hw, HV_ECOL_UPPER, &phy_data);
6041 hw->phy.ops.read_reg_page(hw, HV_ECOL_LOWER, &phy_data);
6042 hw->phy.ops.read_reg_page(hw, HV_MCC_UPPER, &phy_data);
6043 hw->phy.ops.read_reg_page(hw, HV_MCC_LOWER, &phy_data);
6044 hw->phy.ops.read_reg_page(hw, HV_LATECOL_UPPER, &phy_data);
6045 hw->phy.ops.read_reg_page(hw, HV_LATECOL_LOWER, &phy_data);
6046 hw->phy.ops.read_reg_page(hw, HV_COLC_UPPER, &phy_data);
6047 hw->phy.ops.read_reg_page(hw, HV_COLC_LOWER, &phy_data);
6048 hw->phy.ops.read_reg_page(hw, HV_DC_UPPER, &phy_data);
6049 hw->phy.ops.read_reg_page(hw, HV_DC_LOWER, &phy_data);
6050 hw->phy.ops.read_reg_page(hw, HV_TNCRS_UPPER, &phy_data);
6051 hw->phy.ops.read_reg_page(hw, HV_TNCRS_LOWER, &phy_data);
6053 hw->phy.ops.release(hw);
6058 * e1000_configure_k0s_lpt - Configure K0s power state
6059 * @hw: pointer to the HW structure
6060 * @entry_latency: Tx idle period for entering K0s - valid values are 0 to 3.
6061 * 0 corresponds to 128ns, each value over 0 doubles the duration.
6062 * @min_time: Minimum Tx idle period allowed - valid values are 0 to 4.
6063 * 0 corresponds to 128ns, each value over 0 doubles the duration.
6065 * Configure the K1 power state based on the provided parameter.
6066 * Assumes semaphore already acquired.
6068 * Success returns 0, Failure returns:
6069 * -E1000_ERR_PHY (-2) in case of access error
6070 * -E1000_ERR_PARAM (-4) in case of parameters error
6072 s32 e1000_configure_k0s_lpt(struct e1000_hw *hw, u8 entry_latency, u8 min_time)
6077 DEBUGFUNC("e1000_configure_k0s_lpt");
6079 if (entry_latency > 3 || min_time > 4)
6080 return -E1000_ERR_PARAM;
6082 ret_val = e1000_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K0S_CTRL,
6087 /* for now don't touch the latency */
6088 kmrn_reg &= ~(E1000_KMRNCTRLSTA_K0S_CTRL_MIN_TIME_MASK);
6089 kmrn_reg |= ((min_time << E1000_KMRNCTRLSTA_K0S_CTRL_MIN_TIME_SHIFT));
6091 ret_val = e1000_write_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K0S_CTRL,
6096 return E1000_SUCCESS;