1 /* Intel PRO/1000 Linux driver
2 * Copyright(c) 1999 - 2014 Intel Corporation.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * The full GNU General Public License is included in this distribution in
14 * the file called "COPYING".
16 * Contact Information:
17 * Linux NICS <linux.nics@intel.com>
18 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
19 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
22 /* 82562G 10/100 Network Connection
23 * 82562G-2 10/100 Network Connection
24 * 82562GT 10/100 Network Connection
25 * 82562GT-2 10/100 Network Connection
26 * 82562V 10/100 Network Connection
27 * 82562V-2 10/100 Network Connection
28 * 82566DC-2 Gigabit Network Connection
29 * 82566DC Gigabit Network Connection
30 * 82566DM-2 Gigabit Network Connection
31 * 82566DM Gigabit Network Connection
32 * 82566MC Gigabit Network Connection
33 * 82566MM Gigabit Network Connection
34 * 82567LM Gigabit Network Connection
35 * 82567LF Gigabit Network Connection
36 * 82567V Gigabit Network Connection
37 * 82567LM-2 Gigabit Network Connection
38 * 82567LF-2 Gigabit Network Connection
39 * 82567V-2 Gigabit Network Connection
40 * 82567LF-3 Gigabit Network Connection
41 * 82567LM-3 Gigabit Network Connection
42 * 82567LM-4 Gigabit Network Connection
43 * 82577LM Gigabit Network Connection
44 * 82577LC Gigabit Network Connection
45 * 82578DM Gigabit Network Connection
46 * 82578DC Gigabit Network Connection
47 * 82579LM Gigabit Network Connection
48 * 82579V Gigabit Network Connection
53 /* ICH GbE Flash Hardware Sequencing Flash Status Register bit breakdown */
54 /* Offset 04h HSFSTS */
55 union ich8_hws_flash_status {
57 u16 flcdone:1; /* bit 0 Flash Cycle Done */
58 u16 flcerr:1; /* bit 1 Flash Cycle Error */
59 u16 dael:1; /* bit 2 Direct Access error Log */
60 u16 berasesz:2; /* bit 4:3 Sector Erase Size */
61 u16 flcinprog:1; /* bit 5 flash cycle in Progress */
62 u16 reserved1:2; /* bit 13:6 Reserved */
63 u16 reserved2:6; /* bit 13:6 Reserved */
64 u16 fldesvalid:1; /* bit 14 Flash Descriptor Valid */
65 u16 flockdn:1; /* bit 15 Flash Config Lock-Down */
70 /* ICH GbE Flash Hardware Sequencing Flash control Register bit breakdown */
71 /* Offset 06h FLCTL */
72 union ich8_hws_flash_ctrl {
74 u16 flcgo:1; /* 0 Flash Cycle Go */
75 u16 flcycle:2; /* 2:1 Flash Cycle */
76 u16 reserved:5; /* 7:3 Reserved */
77 u16 fldbcount:2; /* 9:8 Flash Data Byte Count */
78 u16 flockdn:6; /* 15:10 Reserved */
83 /* ICH Flash Region Access Permissions */
84 union ich8_hws_flash_regacc {
86 u32 grra:8; /* 0:7 GbE region Read Access */
87 u32 grwa:8; /* 8:15 GbE region Write Access */
88 u32 gmrag:8; /* 23:16 GbE Master Read Access Grant */
89 u32 gmwag:8; /* 31:24 GbE Master Write Access Grant */
94 /* ICH Flash Protected Region */
95 union ich8_flash_protected_range {
97 u32 base:13; /* 0:12 Protected Range Base */
98 u32 reserved1:2; /* 13:14 Reserved */
99 u32 rpe:1; /* 15 Read Protection Enable */
100 u32 limit:13; /* 16:28 Protected Range Limit */
101 u32 reserved2:2; /* 29:30 Reserved */
102 u32 wpe:1; /* 31 Write Protection Enable */
107 static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw);
108 static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw);
109 static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank);
110 static s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw,
111 u32 offset, u8 byte);
112 static s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
114 static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset,
116 static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
118 static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw);
119 static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw);
120 static s32 e1000_led_on_ich8lan(struct e1000_hw *hw);
121 static s32 e1000_led_off_ich8lan(struct e1000_hw *hw);
122 static s32 e1000_id_led_init_pchlan(struct e1000_hw *hw);
123 static s32 e1000_setup_led_pchlan(struct e1000_hw *hw);
124 static s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw);
125 static s32 e1000_led_on_pchlan(struct e1000_hw *hw);
126 static s32 e1000_led_off_pchlan(struct e1000_hw *hw);
127 static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active);
128 static void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw);
129 static void e1000_lan_init_done_ich8lan(struct e1000_hw *hw);
130 static s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link);
131 static s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw);
132 static bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw);
133 static bool e1000_check_mng_mode_pchlan(struct e1000_hw *hw);
134 static void e1000_rar_set_pch2lan(struct e1000_hw *hw, u8 *addr, u32 index);
135 static void e1000_rar_set_pch_lpt(struct e1000_hw *hw, u8 *addr, u32 index);
136 static s32 e1000_k1_workaround_lv(struct e1000_hw *hw);
137 static void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate);
138 static s32 e1000_setup_copper_link_pch_lpt(struct e1000_hw *hw);
140 static inline u16 __er16flash(struct e1000_hw *hw, unsigned long reg)
142 return readw(hw->flash_address + reg);
145 static inline u32 __er32flash(struct e1000_hw *hw, unsigned long reg)
147 return readl(hw->flash_address + reg);
150 static inline void __ew16flash(struct e1000_hw *hw, unsigned long reg, u16 val)
152 writew(val, hw->flash_address + reg);
155 static inline void __ew32flash(struct e1000_hw *hw, unsigned long reg, u32 val)
157 writel(val, hw->flash_address + reg);
160 #define er16flash(reg) __er16flash(hw, (reg))
161 #define er32flash(reg) __er32flash(hw, (reg))
162 #define ew16flash(reg, val) __ew16flash(hw, (reg), (val))
163 #define ew32flash(reg, val) __ew32flash(hw, (reg), (val))
166 * e1000_phy_is_accessible_pchlan - Check if able to access PHY registers
167 * @hw: pointer to the HW structure
169 * Test access to the PHY registers by reading the PHY ID registers. If
170 * the PHY ID is already known (e.g. resume path) compare it with known ID,
171 * otherwise assume the read PHY ID is correct if it is valid.
173 * Assumes the sw/fw/hw semaphore is already acquired.
175 static bool e1000_phy_is_accessible_pchlan(struct e1000_hw *hw)
183 for (retry_count = 0; retry_count < 2; retry_count++) {
184 ret_val = e1e_rphy_locked(hw, MII_PHYSID1, &phy_reg);
185 if (ret_val || (phy_reg == 0xFFFF))
187 phy_id = (u32)(phy_reg << 16);
189 ret_val = e1e_rphy_locked(hw, MII_PHYSID2, &phy_reg);
190 if (ret_val || (phy_reg == 0xFFFF)) {
194 phy_id |= (u32)(phy_reg & PHY_REVISION_MASK);
199 if (hw->phy.id == phy_id)
203 hw->phy.revision = (u32)(phy_reg & ~PHY_REVISION_MASK);
207 /* In case the PHY needs to be in mdio slow mode,
208 * set slow mode and try to get the PHY id again.
210 hw->phy.ops.release(hw);
211 ret_val = e1000_set_mdio_slow_mode_hv(hw);
213 ret_val = e1000e_get_phy_id(hw);
214 hw->phy.ops.acquire(hw);
219 if (hw->mac.type == e1000_pch_lpt) {
220 /* Unforce SMBus mode in PHY */
221 e1e_rphy_locked(hw, CV_SMB_CTRL, &phy_reg);
222 phy_reg &= ~CV_SMB_CTRL_FORCE_SMBUS;
223 e1e_wphy_locked(hw, CV_SMB_CTRL, phy_reg);
225 /* Unforce SMBus mode in MAC */
226 mac_reg = er32(CTRL_EXT);
227 mac_reg &= ~E1000_CTRL_EXT_FORCE_SMBUS;
228 ew32(CTRL_EXT, mac_reg);
235 * e1000_init_phy_workarounds_pchlan - PHY initialization workarounds
236 * @hw: pointer to the HW structure
238 * Workarounds/flow necessary for PHY initialization during driver load
241 static s32 e1000_init_phy_workarounds_pchlan(struct e1000_hw *hw)
243 struct e1000_adapter *adapter = hw->adapter;
244 u32 mac_reg, fwsm = er32(FWSM);
247 /* Gate automatic PHY configuration by hardware on managed and
248 * non-managed 82579 and newer adapters.
250 e1000_gate_hw_phy_config_ich8lan(hw, true);
252 ret_val = hw->phy.ops.acquire(hw);
254 e_dbg("Failed to initialize PHY flow\n");
258 /* The MAC-PHY interconnect may be in SMBus mode. If the PHY is
259 * inaccessible and resetting the PHY is not blocked, toggle the
260 * LANPHYPC Value bit to force the interconnect to PCIe mode.
262 switch (hw->mac.type) {
264 if (e1000_phy_is_accessible_pchlan(hw))
267 /* Before toggling LANPHYPC, see if PHY is accessible by
268 * forcing MAC to SMBus mode first.
270 mac_reg = er32(CTRL_EXT);
271 mac_reg |= E1000_CTRL_EXT_FORCE_SMBUS;
272 ew32(CTRL_EXT, mac_reg);
274 /* Wait 50 milliseconds for MAC to finish any retries
275 * that it might be trying to perform from previous
276 * attempts to acknowledge any phy read requests.
282 if (e1000_phy_is_accessible_pchlan(hw))
287 if ((hw->mac.type == e1000_pchlan) &&
288 (fwsm & E1000_ICH_FWSM_FW_VALID))
291 if (hw->phy.ops.check_reset_block(hw)) {
292 e_dbg("Required LANPHYPC toggle blocked by ME\n");
293 ret_val = -E1000_ERR_PHY;
297 e_dbg("Toggling LANPHYPC\n");
299 /* Set Phy Config Counter to 50msec */
300 mac_reg = er32(FEXTNVM3);
301 mac_reg &= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK;
302 mac_reg |= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC;
303 ew32(FEXTNVM3, mac_reg);
305 /* Toggle LANPHYPC Value bit */
306 mac_reg = er32(CTRL);
307 mac_reg |= E1000_CTRL_LANPHYPC_OVERRIDE;
308 mac_reg &= ~E1000_CTRL_LANPHYPC_VALUE;
311 usleep_range(10, 20);
312 mac_reg &= ~E1000_CTRL_LANPHYPC_OVERRIDE;
315 if (hw->mac.type < e1000_pch_lpt) {
320 usleep_range(5000, 10000);
321 } while (!(er32(CTRL_EXT) &
322 E1000_CTRL_EXT_LPCD) && count--);
323 usleep_range(30000, 60000);
324 if (e1000_phy_is_accessible_pchlan(hw))
327 /* Toggling LANPHYPC brings the PHY out of SMBus mode
328 * so ensure that the MAC is also out of SMBus mode
330 mac_reg = er32(CTRL_EXT);
331 mac_reg &= ~E1000_CTRL_EXT_FORCE_SMBUS;
332 ew32(CTRL_EXT, mac_reg);
334 if (e1000_phy_is_accessible_pchlan(hw))
337 ret_val = -E1000_ERR_PHY;
344 hw->phy.ops.release(hw);
347 /* Check to see if able to reset PHY. Print error if not */
348 if (hw->phy.ops.check_reset_block(hw)) {
349 e_err("Reset blocked by ME\n");
353 /* Reset the PHY before any access to it. Doing so, ensures
354 * that the PHY is in a known good state before we read/write
355 * PHY registers. The generic reset is sufficient here,
356 * because we haven't determined the PHY type yet.
358 ret_val = e1000e_phy_hw_reset_generic(hw);
362 /* On a successful reset, possibly need to wait for the PHY
363 * to quiesce to an accessible state before returning control
364 * to the calling function. If the PHY does not quiesce, then
365 * return E1000E_BLK_PHY_RESET, as this is the condition that
368 ret_val = hw->phy.ops.check_reset_block(hw);
370 e_err("ME blocked access to PHY after reset\n");
374 /* Ungate automatic PHY configuration on non-managed 82579 */
375 if ((hw->mac.type == e1000_pch2lan) &&
376 !(fwsm & E1000_ICH_FWSM_FW_VALID)) {
377 usleep_range(10000, 20000);
378 e1000_gate_hw_phy_config_ich8lan(hw, false);
385 * e1000_init_phy_params_pchlan - Initialize PHY function pointers
386 * @hw: pointer to the HW structure
388 * Initialize family-specific PHY parameters and function pointers.
390 static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw)
392 struct e1000_phy_info *phy = &hw->phy;
396 phy->reset_delay_us = 100;
398 phy->ops.set_page = e1000_set_page_igp;
399 phy->ops.read_reg = e1000_read_phy_reg_hv;
400 phy->ops.read_reg_locked = e1000_read_phy_reg_hv_locked;
401 phy->ops.read_reg_page = e1000_read_phy_reg_page_hv;
402 phy->ops.set_d0_lplu_state = e1000_set_lplu_state_pchlan;
403 phy->ops.set_d3_lplu_state = e1000_set_lplu_state_pchlan;
404 phy->ops.write_reg = e1000_write_phy_reg_hv;
405 phy->ops.write_reg_locked = e1000_write_phy_reg_hv_locked;
406 phy->ops.write_reg_page = e1000_write_phy_reg_page_hv;
407 phy->ops.power_up = e1000_power_up_phy_copper;
408 phy->ops.power_down = e1000_power_down_phy_copper_ich8lan;
409 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
411 phy->id = e1000_phy_unknown;
413 ret_val = e1000_init_phy_workarounds_pchlan(hw);
417 if (phy->id == e1000_phy_unknown)
418 switch (hw->mac.type) {
420 ret_val = e1000e_get_phy_id(hw);
423 if ((phy->id != 0) && (phy->id != PHY_REVISION_MASK))
428 /* In case the PHY needs to be in mdio slow mode,
429 * set slow mode and try to get the PHY id again.
431 ret_val = e1000_set_mdio_slow_mode_hv(hw);
434 ret_val = e1000e_get_phy_id(hw);
439 phy->type = e1000e_get_phy_type_from_id(phy->id);
442 case e1000_phy_82577:
443 case e1000_phy_82579:
445 phy->ops.check_polarity = e1000_check_polarity_82577;
446 phy->ops.force_speed_duplex =
447 e1000_phy_force_speed_duplex_82577;
448 phy->ops.get_cable_length = e1000_get_cable_length_82577;
449 phy->ops.get_info = e1000_get_phy_info_82577;
450 phy->ops.commit = e1000e_phy_sw_reset;
452 case e1000_phy_82578:
453 phy->ops.check_polarity = e1000_check_polarity_m88;
454 phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_m88;
455 phy->ops.get_cable_length = e1000e_get_cable_length_m88;
456 phy->ops.get_info = e1000e_get_phy_info_m88;
459 ret_val = -E1000_ERR_PHY;
467 * e1000_init_phy_params_ich8lan - Initialize PHY function pointers
468 * @hw: pointer to the HW structure
470 * Initialize family-specific PHY parameters and function pointers.
472 static s32 e1000_init_phy_params_ich8lan(struct e1000_hw *hw)
474 struct e1000_phy_info *phy = &hw->phy;
479 phy->reset_delay_us = 100;
481 phy->ops.power_up = e1000_power_up_phy_copper;
482 phy->ops.power_down = e1000_power_down_phy_copper_ich8lan;
484 /* We may need to do this twice - once for IGP and if that fails,
485 * we'll set BM func pointers and try again
487 ret_val = e1000e_determine_phy_address(hw);
489 phy->ops.write_reg = e1000e_write_phy_reg_bm;
490 phy->ops.read_reg = e1000e_read_phy_reg_bm;
491 ret_val = e1000e_determine_phy_address(hw);
493 e_dbg("Cannot determine PHY addr. Erroring out\n");
499 while ((e1000_phy_unknown == e1000e_get_phy_type_from_id(phy->id)) &&
501 usleep_range(1000, 2000);
502 ret_val = e1000e_get_phy_id(hw);
509 case IGP03E1000_E_PHY_ID:
510 phy->type = e1000_phy_igp_3;
511 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
512 phy->ops.read_reg_locked = e1000e_read_phy_reg_igp_locked;
513 phy->ops.write_reg_locked = e1000e_write_phy_reg_igp_locked;
514 phy->ops.get_info = e1000e_get_phy_info_igp;
515 phy->ops.check_polarity = e1000_check_polarity_igp;
516 phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_igp;
519 case IFE_PLUS_E_PHY_ID:
521 phy->type = e1000_phy_ife;
522 phy->autoneg_mask = E1000_ALL_NOT_GIG;
523 phy->ops.get_info = e1000_get_phy_info_ife;
524 phy->ops.check_polarity = e1000_check_polarity_ife;
525 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_ife;
527 case BME1000_E_PHY_ID:
528 phy->type = e1000_phy_bm;
529 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
530 phy->ops.read_reg = e1000e_read_phy_reg_bm;
531 phy->ops.write_reg = e1000e_write_phy_reg_bm;
532 phy->ops.commit = e1000e_phy_sw_reset;
533 phy->ops.get_info = e1000e_get_phy_info_m88;
534 phy->ops.check_polarity = e1000_check_polarity_m88;
535 phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_m88;
538 return -E1000_ERR_PHY;
546 * e1000_init_nvm_params_ich8lan - Initialize NVM function pointers
547 * @hw: pointer to the HW structure
549 * Initialize family-specific NVM parameters and function
552 static s32 e1000_init_nvm_params_ich8lan(struct e1000_hw *hw)
554 struct e1000_nvm_info *nvm = &hw->nvm;
555 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
556 u32 gfpreg, sector_base_addr, sector_end_addr;
559 /* Can't read flash registers if the register set isn't mapped. */
560 if (!hw->flash_address) {
561 e_dbg("ERROR: Flash registers not mapped\n");
562 return -E1000_ERR_CONFIG;
565 nvm->type = e1000_nvm_flash_sw;
567 gfpreg = er32flash(ICH_FLASH_GFPREG);
569 /* sector_X_addr is a "sector"-aligned address (4096 bytes)
570 * Add 1 to sector_end_addr since this sector is included in
573 sector_base_addr = gfpreg & FLASH_GFPREG_BASE_MASK;
574 sector_end_addr = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK) + 1;
576 /* flash_base_addr is byte-aligned */
577 nvm->flash_base_addr = sector_base_addr << FLASH_SECTOR_ADDR_SHIFT;
579 /* find total size of the NVM, then cut in half since the total
580 * size represents two separate NVM banks.
582 nvm->flash_bank_size = ((sector_end_addr - sector_base_addr)
583 << FLASH_SECTOR_ADDR_SHIFT);
584 nvm->flash_bank_size /= 2;
585 /* Adjust to word count */
586 nvm->flash_bank_size /= sizeof(u16);
588 nvm->word_size = E1000_ICH8_SHADOW_RAM_WORDS;
590 /* Clear shadow ram */
591 for (i = 0; i < nvm->word_size; i++) {
592 dev_spec->shadow_ram[i].modified = false;
593 dev_spec->shadow_ram[i].value = 0xFFFF;
600 * e1000_init_mac_params_ich8lan - Initialize MAC function pointers
601 * @hw: pointer to the HW structure
603 * Initialize family-specific MAC parameters and function
606 static s32 e1000_init_mac_params_ich8lan(struct e1000_hw *hw)
608 struct e1000_mac_info *mac = &hw->mac;
610 /* Set media type function pointer */
611 hw->phy.media_type = e1000_media_type_copper;
613 /* Set mta register count */
614 mac->mta_reg_count = 32;
615 /* Set rar entry count */
616 mac->rar_entry_count = E1000_ICH_RAR_ENTRIES;
617 if (mac->type == e1000_ich8lan)
618 mac->rar_entry_count--;
620 mac->has_fwsm = true;
621 /* ARC subsystem not supported */
622 mac->arc_subsystem_valid = false;
623 /* Adaptive IFS supported */
624 mac->adaptive_ifs = true;
626 /* LED and other operations */
631 /* check management mode */
632 mac->ops.check_mng_mode = e1000_check_mng_mode_ich8lan;
634 mac->ops.id_led_init = e1000e_id_led_init_generic;
636 mac->ops.blink_led = e1000e_blink_led_generic;
638 mac->ops.setup_led = e1000e_setup_led_generic;
640 mac->ops.cleanup_led = e1000_cleanup_led_ich8lan;
641 /* turn on/off LED */
642 mac->ops.led_on = e1000_led_on_ich8lan;
643 mac->ops.led_off = e1000_led_off_ich8lan;
646 mac->rar_entry_count = E1000_PCH2_RAR_ENTRIES;
647 mac->ops.rar_set = e1000_rar_set_pch2lan;
651 /* check management mode */
652 mac->ops.check_mng_mode = e1000_check_mng_mode_pchlan;
654 mac->ops.id_led_init = e1000_id_led_init_pchlan;
656 mac->ops.setup_led = e1000_setup_led_pchlan;
658 mac->ops.cleanup_led = e1000_cleanup_led_pchlan;
659 /* turn on/off LED */
660 mac->ops.led_on = e1000_led_on_pchlan;
661 mac->ops.led_off = e1000_led_off_pchlan;
667 if (mac->type == e1000_pch_lpt) {
668 mac->rar_entry_count = E1000_PCH_LPT_RAR_ENTRIES;
669 mac->ops.rar_set = e1000_rar_set_pch_lpt;
670 mac->ops.setup_physical_interface =
671 e1000_setup_copper_link_pch_lpt;
674 /* Enable PCS Lock-loss workaround for ICH8 */
675 if (mac->type == e1000_ich8lan)
676 e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw, true);
682 * __e1000_access_emi_reg_locked - Read/write EMI register
683 * @hw: pointer to the HW structure
684 * @addr: EMI address to program
685 * @data: pointer to value to read/write from/to the EMI address
686 * @read: boolean flag to indicate read or write
688 * This helper function assumes the SW/FW/HW Semaphore is already acquired.
690 static s32 __e1000_access_emi_reg_locked(struct e1000_hw *hw, u16 address,
691 u16 *data, bool read)
695 ret_val = e1e_wphy_locked(hw, I82579_EMI_ADDR, address);
700 ret_val = e1e_rphy_locked(hw, I82579_EMI_DATA, data);
702 ret_val = e1e_wphy_locked(hw, I82579_EMI_DATA, *data);
708 * e1000_read_emi_reg_locked - Read Extended Management Interface register
709 * @hw: pointer to the HW structure
710 * @addr: EMI address to program
711 * @data: value to be read from the EMI address
713 * Assumes the SW/FW/HW Semaphore is already acquired.
715 s32 e1000_read_emi_reg_locked(struct e1000_hw *hw, u16 addr, u16 *data)
717 return __e1000_access_emi_reg_locked(hw, addr, data, true);
721 * e1000_write_emi_reg_locked - Write Extended Management Interface register
722 * @hw: pointer to the HW structure
723 * @addr: EMI address to program
724 * @data: value to be written to the EMI address
726 * Assumes the SW/FW/HW Semaphore is already acquired.
728 s32 e1000_write_emi_reg_locked(struct e1000_hw *hw, u16 addr, u16 data)
730 return __e1000_access_emi_reg_locked(hw, addr, &data, false);
734 * e1000_set_eee_pchlan - Enable/disable EEE support
735 * @hw: pointer to the HW structure
737 * Enable/disable EEE based on setting in dev_spec structure, the duplex of
738 * the link and the EEE capabilities of the link partner. The LPI Control
739 * register bits will remain set only if/when link is up.
741 * EEE LPI must not be asserted earlier than one second after link is up.
742 * On 82579, EEE LPI should not be enabled until such time otherwise there
743 * can be link issues with some switches. Other devices can have EEE LPI
744 * enabled immediately upon link up since they have a timer in hardware which
745 * prevents LPI from being asserted too early.
747 s32 e1000_set_eee_pchlan(struct e1000_hw *hw)
749 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
751 u16 lpa, pcs_status, adv, adv_addr, lpi_ctrl, data;
753 switch (hw->phy.type) {
754 case e1000_phy_82579:
755 lpa = I82579_EEE_LP_ABILITY;
756 pcs_status = I82579_EEE_PCS_STATUS;
757 adv_addr = I82579_EEE_ADVERTISEMENT;
760 lpa = I217_EEE_LP_ABILITY;
761 pcs_status = I217_EEE_PCS_STATUS;
762 adv_addr = I217_EEE_ADVERTISEMENT;
768 ret_val = hw->phy.ops.acquire(hw);
772 ret_val = e1e_rphy_locked(hw, I82579_LPI_CTRL, &lpi_ctrl);
776 /* Clear bits that enable EEE in various speeds */
777 lpi_ctrl &= ~I82579_LPI_CTRL_ENABLE_MASK;
779 /* Enable EEE if not disabled by user */
780 if (!dev_spec->eee_disable) {
781 /* Save off link partner's EEE ability */
782 ret_val = e1000_read_emi_reg_locked(hw, lpa,
783 &dev_spec->eee_lp_ability);
787 /* Read EEE advertisement */
788 ret_val = e1000_read_emi_reg_locked(hw, adv_addr, &adv);
792 /* Enable EEE only for speeds in which the link partner is
793 * EEE capable and for which we advertise EEE.
795 if (adv & dev_spec->eee_lp_ability & I82579_EEE_1000_SUPPORTED)
796 lpi_ctrl |= I82579_LPI_CTRL_1000_ENABLE;
798 if (adv & dev_spec->eee_lp_ability & I82579_EEE_100_SUPPORTED) {
799 e1e_rphy_locked(hw, MII_LPA, &data);
800 if (data & LPA_100FULL)
801 lpi_ctrl |= I82579_LPI_CTRL_100_ENABLE;
803 /* EEE is not supported in 100Half, so ignore
804 * partner's EEE in 100 ability if full-duplex
807 dev_spec->eee_lp_ability &=
808 ~I82579_EEE_100_SUPPORTED;
812 /* R/Clr IEEE MMD 3.1 bits 11:10 - Tx/Rx LPI Received */
813 ret_val = e1000_read_emi_reg_locked(hw, pcs_status, &data);
817 ret_val = e1e_wphy_locked(hw, I82579_LPI_CTRL, lpi_ctrl);
819 hw->phy.ops.release(hw);
825 * e1000_k1_workaround_lpt_lp - K1 workaround on Lynxpoint-LP
826 * @hw: pointer to the HW structure
827 * @link: link up bool flag
829 * When K1 is enabled for 1Gbps, the MAC can miss 2 DMA completion indications
830 * preventing further DMA write requests. Workaround the issue by disabling
831 * the de-assertion of the clock request when in 1Gpbs mode.
832 * Also, set appropriate Tx re-transmission timeouts for 10 and 100Half link
833 * speeds in order to avoid Tx hangs.
835 static s32 e1000_k1_workaround_lpt_lp(struct e1000_hw *hw, bool link)
837 u32 fextnvm6 = er32(FEXTNVM6);
838 u32 status = er32(STATUS);
842 if (link && (status & E1000_STATUS_SPEED_1000)) {
843 ret_val = hw->phy.ops.acquire(hw);
848 e1000e_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
854 e1000e_write_kmrn_reg_locked(hw,
855 E1000_KMRNCTRLSTA_K1_CONFIG,
857 ~E1000_KMRNCTRLSTA_K1_ENABLE);
861 usleep_range(10, 20);
863 ew32(FEXTNVM6, fextnvm6 | E1000_FEXTNVM6_REQ_PLL_CLK);
866 e1000e_write_kmrn_reg_locked(hw,
867 E1000_KMRNCTRLSTA_K1_CONFIG,
870 hw->phy.ops.release(hw);
872 /* clear FEXTNVM6 bit 8 on link down or 10/100 */
873 fextnvm6 &= ~E1000_FEXTNVM6_REQ_PLL_CLK;
875 if (!link || ((status & E1000_STATUS_SPEED_100) &&
876 (status & E1000_STATUS_FD)))
877 goto update_fextnvm6;
879 ret_val = e1e_rphy(hw, I217_INBAND_CTRL, ®);
883 /* Clear link status transmit timeout */
884 reg &= ~I217_INBAND_CTRL_LINK_STAT_TX_TIMEOUT_MASK;
886 if (status & E1000_STATUS_SPEED_100) {
887 /* Set inband Tx timeout to 5x10us for 100Half */
888 reg |= 5 << I217_INBAND_CTRL_LINK_STAT_TX_TIMEOUT_SHIFT;
890 /* Do not extend the K1 entry latency for 100Half */
891 fextnvm6 &= ~E1000_FEXTNVM6_ENABLE_K1_ENTRY_CONDITION;
893 /* Set inband Tx timeout to 50x10us for 10Full/Half */
895 I217_INBAND_CTRL_LINK_STAT_TX_TIMEOUT_SHIFT;
897 /* Extend the K1 entry latency for 10 Mbps */
898 fextnvm6 |= E1000_FEXTNVM6_ENABLE_K1_ENTRY_CONDITION;
901 ret_val = e1e_wphy(hw, I217_INBAND_CTRL, reg);
906 ew32(FEXTNVM6, fextnvm6);
913 * e1000_platform_pm_pch_lpt - Set platform power management values
914 * @hw: pointer to the HW structure
915 * @link: bool indicating link status
917 * Set the Latency Tolerance Reporting (LTR) values for the "PCIe-like"
918 * GbE MAC in the Lynx Point PCH based on Rx buffer size and link speed
919 * when link is up (which must not exceed the maximum latency supported
920 * by the platform), otherwise specify there is no LTR requirement.
921 * Unlike true-PCIe devices which set the LTR maximum snoop/no-snoop
922 * latencies in the LTR Extended Capability Structure in the PCIe Extended
923 * Capability register set, on this device LTR is set by writing the
924 * equivalent snoop/no-snoop latencies in the LTRV register in the MAC and
925 * set the SEND bit to send an Intel On-chip System Fabric sideband (IOSF-SB)
926 * message to the PMC.
928 static s32 e1000_platform_pm_pch_lpt(struct e1000_hw *hw, bool link)
930 u32 reg = link << (E1000_LTRV_REQ_SHIFT + E1000_LTRV_NOSNOOP_SHIFT) |
931 link << E1000_LTRV_REQ_SHIFT | E1000_LTRV_SEND;
932 u16 lat_enc = 0; /* latency encoded */
935 u16 speed, duplex, scale = 0;
936 u16 max_snoop, max_nosnoop;
937 u16 max_ltr_enc; /* max LTR latency encoded */
938 s64 lat_ns; /* latency (ns) */
942 if (!hw->adapter->max_frame_size) {
943 e_dbg("max_frame_size not set.\n");
944 return -E1000_ERR_CONFIG;
947 hw->mac.ops.get_link_up_info(hw, &speed, &duplex);
949 e_dbg("Speed not set.\n");
950 return -E1000_ERR_CONFIG;
953 /* Rx Packet Buffer Allocation size (KB) */
954 rxa = er32(PBA) & E1000_PBA_RXA_MASK;
956 /* Determine the maximum latency tolerated by the device.
958 * Per the PCIe spec, the tolerated latencies are encoded as
959 * a 3-bit encoded scale (only 0-5 are valid) multiplied by
960 * a 10-bit value (0-1023) to provide a range from 1 ns to
961 * 2^25*(2^10-1) ns. The scale is encoded as 0=2^0ns,
962 * 1=2^5ns, 2=2^10ns,...5=2^25ns.
964 lat_ns = ((s64)rxa * 1024 -
965 (2 * (s64)hw->adapter->max_frame_size)) * 8 * 1000;
969 do_div(lat_ns, speed);
972 while (value > PCI_LTR_VALUE_MASK) {
974 value = DIV_ROUND_UP(value, (1 << 5));
976 if (scale > E1000_LTRV_SCALE_MAX) {
977 e_dbg("Invalid LTR latency scale %d\n", scale);
978 return -E1000_ERR_CONFIG;
980 lat_enc = (u16)((scale << PCI_LTR_SCALE_SHIFT) | value);
982 /* Determine the maximum latency tolerated by the platform */
983 pci_read_config_word(hw->adapter->pdev, E1000_PCI_LTR_CAP_LPT,
985 pci_read_config_word(hw->adapter->pdev,
986 E1000_PCI_LTR_CAP_LPT + 2, &max_nosnoop);
987 max_ltr_enc = max_t(u16, max_snoop, max_nosnoop);
989 if (lat_enc > max_ltr_enc)
990 lat_enc = max_ltr_enc;
993 /* Set Snoop and No-Snoop latencies the same */
994 reg |= lat_enc | (lat_enc << E1000_LTRV_NOSNOOP_SHIFT);
1001 * e1000_check_for_copper_link_ich8lan - Check for link (Copper)
1002 * @hw: pointer to the HW structure
1004 * Checks to see of the link status of the hardware has changed. If a
1005 * change in link status has been detected, then we read the PHY registers
1006 * to get the current speed/duplex if link exists.
1008 static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw)
1010 struct e1000_mac_info *mac = &hw->mac;
1015 /* We only want to go out to the PHY registers to see if Auto-Neg
1016 * has completed and/or if our link status has changed. The
1017 * get_link_status flag is set upon receiving a Link Status
1018 * Change or Rx Sequence Error interrupt.
1020 if (!mac->get_link_status)
1023 /* First we want to see if the MII Status Register reports
1024 * link. If so, then we want to get the current speed/duplex
1027 ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link);
1031 if (hw->mac.type == e1000_pchlan) {
1032 ret_val = e1000_k1_gig_workaround_hv(hw, link);
1037 /* When connected at 10Mbps half-duplex, 82579 parts are excessively
1038 * aggressive resulting in many collisions. To avoid this, increase
1039 * the IPG and reduce Rx latency in the PHY.
1041 if ((hw->mac.type == e1000_pch2lan) && link) {
1044 if (!(reg & (E1000_STATUS_FD | E1000_STATUS_SPEED_MASK))) {
1046 reg &= ~E1000_TIPG_IPGT_MASK;
1050 /* Reduce Rx latency in analog PHY */
1051 ret_val = hw->phy.ops.acquire(hw);
1056 e1000_write_emi_reg_locked(hw, I82579_RX_CONFIG, 0);
1058 hw->phy.ops.release(hw);
1065 /* Work-around I218 hang issue */
1066 if ((hw->adapter->pdev->device == E1000_DEV_ID_PCH_LPTLP_I218_LM) ||
1067 (hw->adapter->pdev->device == E1000_DEV_ID_PCH_LPTLP_I218_V) ||
1068 (hw->adapter->pdev->device == E1000_DEV_ID_PCH_I218_LM3) ||
1069 (hw->adapter->pdev->device == E1000_DEV_ID_PCH_I218_V3)) {
1070 ret_val = e1000_k1_workaround_lpt_lp(hw, link);
1075 if (hw->mac.type == e1000_pch_lpt) {
1076 /* Set platform power management values for
1077 * Latency Tolerance Reporting (LTR)
1079 ret_val = e1000_platform_pm_pch_lpt(hw, link);
1084 /* Clear link partner's EEE ability */
1085 hw->dev_spec.ich8lan.eee_lp_ability = 0;
1088 return 0; /* No link detected */
1090 mac->get_link_status = false;
1092 switch (hw->mac.type) {
1094 ret_val = e1000_k1_workaround_lv(hw);
1099 if (hw->phy.type == e1000_phy_82578) {
1100 ret_val = e1000_link_stall_workaround_hv(hw);
1105 /* Workaround for PCHx parts in half-duplex:
1106 * Set the number of preambles removed from the packet
1107 * when it is passed from the PHY to the MAC to prevent
1108 * the MAC from misinterpreting the packet type.
1110 e1e_rphy(hw, HV_KMRN_FIFO_CTRLSTA, &phy_reg);
1111 phy_reg &= ~HV_KMRN_FIFO_CTRLSTA_PREAMBLE_MASK;
1113 if ((er32(STATUS) & E1000_STATUS_FD) != E1000_STATUS_FD)
1114 phy_reg |= (1 << HV_KMRN_FIFO_CTRLSTA_PREAMBLE_SHIFT);
1116 e1e_wphy(hw, HV_KMRN_FIFO_CTRLSTA, phy_reg);
1122 /* Check if there was DownShift, must be checked
1123 * immediately after link-up
1125 e1000e_check_downshift(hw);
1127 /* Enable/Disable EEE after link up */
1128 if (hw->phy.type > e1000_phy_82579) {
1129 ret_val = e1000_set_eee_pchlan(hw);
1134 /* If we are forcing speed/duplex, then we simply return since
1135 * we have already determined whether we have link or not.
1138 return -E1000_ERR_CONFIG;
1140 /* Auto-Neg is enabled. Auto Speed Detection takes care
1141 * of MAC speed/duplex configuration. So we only need to
1142 * configure Collision Distance in the MAC.
1144 mac->ops.config_collision_dist(hw);
1146 /* Configure Flow Control now that Auto-Neg has completed.
1147 * First, we need to restore the desired flow control
1148 * settings because we may have had to re-autoneg with a
1149 * different link partner.
1151 ret_val = e1000e_config_fc_after_link_up(hw);
1153 e_dbg("Error configuring flow control\n");
1158 static s32 e1000_get_variants_ich8lan(struct e1000_adapter *adapter)
1160 struct e1000_hw *hw = &adapter->hw;
1163 rc = e1000_init_mac_params_ich8lan(hw);
1167 rc = e1000_init_nvm_params_ich8lan(hw);
1171 switch (hw->mac.type) {
1174 case e1000_ich10lan:
1175 rc = e1000_init_phy_params_ich8lan(hw);
1180 rc = e1000_init_phy_params_pchlan(hw);
1188 /* Disable Jumbo Frame support on parts with Intel 10/100 PHY or
1189 * on parts with MACsec enabled in NVM (reflected in CTRL_EXT).
1191 if ((adapter->hw.phy.type == e1000_phy_ife) ||
1192 ((adapter->hw.mac.type >= e1000_pch2lan) &&
1193 (!(er32(CTRL_EXT) & E1000_CTRL_EXT_LSECCK)))) {
1194 adapter->flags &= ~FLAG_HAS_JUMBO_FRAMES;
1195 adapter->max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN;
1197 hw->mac.ops.blink_led = NULL;
1200 if ((adapter->hw.mac.type == e1000_ich8lan) &&
1201 (adapter->hw.phy.type != e1000_phy_ife))
1202 adapter->flags |= FLAG_LSC_GIG_SPEED_DROP;
1204 /* Enable workaround for 82579 w/ ME enabled */
1205 if ((adapter->hw.mac.type == e1000_pch2lan) &&
1206 (er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
1207 adapter->flags2 |= FLAG2_PCIM2PCI_ARBITER_WA;
1212 static DEFINE_MUTEX(nvm_mutex);
1215 * e1000_acquire_nvm_ich8lan - Acquire NVM mutex
1216 * @hw: pointer to the HW structure
1218 * Acquires the mutex for performing NVM operations.
1220 static s32 e1000_acquire_nvm_ich8lan(struct e1000_hw __always_unused *hw)
1222 mutex_lock(&nvm_mutex);
1228 * e1000_release_nvm_ich8lan - Release NVM mutex
1229 * @hw: pointer to the HW structure
1231 * Releases the mutex used while performing NVM operations.
1233 static void e1000_release_nvm_ich8lan(struct e1000_hw __always_unused *hw)
1235 mutex_unlock(&nvm_mutex);
1239 * e1000_acquire_swflag_ich8lan - Acquire software control flag
1240 * @hw: pointer to the HW structure
1242 * Acquires the software control flag for performing PHY and select
1245 static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw)
1247 u32 extcnf_ctrl, timeout = PHY_CFG_TIMEOUT;
1250 if (test_and_set_bit(__E1000_ACCESS_SHARED_RESOURCE,
1251 &hw->adapter->state)) {
1252 e_dbg("contention for Phy access\n");
1253 return -E1000_ERR_PHY;
1257 extcnf_ctrl = er32(EXTCNF_CTRL);
1258 if (!(extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG))
1266 e_dbg("SW has already locked the resource.\n");
1267 ret_val = -E1000_ERR_CONFIG;
1271 timeout = SW_FLAG_TIMEOUT;
1273 extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG;
1274 ew32(EXTCNF_CTRL, extcnf_ctrl);
1277 extcnf_ctrl = er32(EXTCNF_CTRL);
1278 if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG)
1286 e_dbg("Failed to acquire the semaphore, FW or HW has it: FWSM=0x%8.8x EXTCNF_CTRL=0x%8.8x)\n",
1287 er32(FWSM), extcnf_ctrl);
1288 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
1289 ew32(EXTCNF_CTRL, extcnf_ctrl);
1290 ret_val = -E1000_ERR_CONFIG;
1296 clear_bit(__E1000_ACCESS_SHARED_RESOURCE, &hw->adapter->state);
1302 * e1000_release_swflag_ich8lan - Release software control flag
1303 * @hw: pointer to the HW structure
1305 * Releases the software control flag for performing PHY and select
1308 static void e1000_release_swflag_ich8lan(struct e1000_hw *hw)
1312 extcnf_ctrl = er32(EXTCNF_CTRL);
1314 if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG) {
1315 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
1316 ew32(EXTCNF_CTRL, extcnf_ctrl);
1318 e_dbg("Semaphore unexpectedly released by sw/fw/hw\n");
1321 clear_bit(__E1000_ACCESS_SHARED_RESOURCE, &hw->adapter->state);
1325 * e1000_check_mng_mode_ich8lan - Checks management mode
1326 * @hw: pointer to the HW structure
1328 * This checks if the adapter has any manageability enabled.
1329 * This is a function pointer entry point only called by read/write
1330 * routines for the PHY and NVM parts.
1332 static bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw)
1337 return ((fwsm & E1000_ICH_FWSM_FW_VALID) &&
1338 ((fwsm & E1000_FWSM_MODE_MASK) ==
1339 (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT)));
1343 * e1000_check_mng_mode_pchlan - Checks management mode
1344 * @hw: pointer to the HW structure
1346 * This checks if the adapter has iAMT enabled.
1347 * This is a function pointer entry point only called by read/write
1348 * routines for the PHY and NVM parts.
1350 static bool e1000_check_mng_mode_pchlan(struct e1000_hw *hw)
1355 return (fwsm & E1000_ICH_FWSM_FW_VALID) &&
1356 (fwsm & (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT));
1360 * e1000_rar_set_pch2lan - Set receive address register
1361 * @hw: pointer to the HW structure
1362 * @addr: pointer to the receive address
1363 * @index: receive address array register
1365 * Sets the receive address array register at index to the address passed
1366 * in by addr. For 82579, RAR[0] is the base address register that is to
1367 * contain the MAC address but RAR[1-6] are reserved for manageability (ME).
1368 * Use SHRA[0-3] in place of those reserved for ME.
1370 static void e1000_rar_set_pch2lan(struct e1000_hw *hw, u8 *addr, u32 index)
1372 u32 rar_low, rar_high;
1374 /* HW expects these in little endian so we reverse the byte order
1375 * from network order (big endian) to little endian
1377 rar_low = ((u32)addr[0] |
1378 ((u32)addr[1] << 8) |
1379 ((u32)addr[2] << 16) | ((u32)addr[3] << 24));
1381 rar_high = ((u32)addr[4] | ((u32)addr[5] << 8));
1383 /* If MAC address zero, no need to set the AV bit */
1384 if (rar_low || rar_high)
1385 rar_high |= E1000_RAH_AV;
1388 ew32(RAL(index), rar_low);
1390 ew32(RAH(index), rar_high);
1395 /* RAR[1-6] are owned by manageability. Skip those and program the
1396 * next address into the SHRA register array.
1398 if (index < (u32)(hw->mac.rar_entry_count - 6)) {
1401 ret_val = e1000_acquire_swflag_ich8lan(hw);
1405 ew32(SHRAL(index - 1), rar_low);
1407 ew32(SHRAH(index - 1), rar_high);
1410 e1000_release_swflag_ich8lan(hw);
1412 /* verify the register updates */
1413 if ((er32(SHRAL(index - 1)) == rar_low) &&
1414 (er32(SHRAH(index - 1)) == rar_high))
1417 e_dbg("SHRA[%d] might be locked by ME - FWSM=0x%8.8x\n",
1418 (index - 1), er32(FWSM));
1422 e_dbg("Failed to write receive address at index %d\n", index);
1426 * e1000_rar_set_pch_lpt - Set receive address registers
1427 * @hw: pointer to the HW structure
1428 * @addr: pointer to the receive address
1429 * @index: receive address array register
1431 * Sets the receive address register array at index to the address passed
1432 * in by addr. For LPT, RAR[0] is the base address register that is to
1433 * contain the MAC address. SHRA[0-10] are the shared receive address
1434 * registers that are shared between the Host and manageability engine (ME).
1436 static void e1000_rar_set_pch_lpt(struct e1000_hw *hw, u8 *addr, u32 index)
1438 u32 rar_low, rar_high;
1441 /* HW expects these in little endian so we reverse the byte order
1442 * from network order (big endian) to little endian
1444 rar_low = ((u32)addr[0] | ((u32)addr[1] << 8) |
1445 ((u32)addr[2] << 16) | ((u32)addr[3] << 24));
1447 rar_high = ((u32)addr[4] | ((u32)addr[5] << 8));
1449 /* If MAC address zero, no need to set the AV bit */
1450 if (rar_low || rar_high)
1451 rar_high |= E1000_RAH_AV;
1454 ew32(RAL(index), rar_low);
1456 ew32(RAH(index), rar_high);
1461 /* The manageability engine (ME) can lock certain SHRAR registers that
1462 * it is using - those registers are unavailable for use.
1464 if (index < hw->mac.rar_entry_count) {
1465 wlock_mac = er32(FWSM) & E1000_FWSM_WLOCK_MAC_MASK;
1466 wlock_mac >>= E1000_FWSM_WLOCK_MAC_SHIFT;
1468 /* Check if all SHRAR registers are locked */
1472 if ((wlock_mac == 0) || (index <= wlock_mac)) {
1475 ret_val = e1000_acquire_swflag_ich8lan(hw);
1480 ew32(SHRAL_PCH_LPT(index - 1), rar_low);
1482 ew32(SHRAH_PCH_LPT(index - 1), rar_high);
1485 e1000_release_swflag_ich8lan(hw);
1487 /* verify the register updates */
1488 if ((er32(SHRAL_PCH_LPT(index - 1)) == rar_low) &&
1489 (er32(SHRAH_PCH_LPT(index - 1)) == rar_high))
1495 e_dbg("Failed to write receive address at index %d\n", index);
1499 * e1000_check_reset_block_ich8lan - Check if PHY reset is blocked
1500 * @hw: pointer to the HW structure
1502 * Checks if firmware is blocking the reset of the PHY.
1503 * This is a function pointer entry point only called by
1506 static s32 e1000_check_reset_block_ich8lan(struct e1000_hw *hw)
1508 bool blocked = false;
1511 while ((blocked = !(er32(FWSM) & E1000_ICH_FWSM_RSPCIPHY)) &&
1513 usleep_range(10000, 20000);
1514 return blocked ? E1000_BLK_PHY_RESET : 0;
1518 * e1000_write_smbus_addr - Write SMBus address to PHY needed during Sx states
1519 * @hw: pointer to the HW structure
1521 * Assumes semaphore already acquired.
1524 static s32 e1000_write_smbus_addr(struct e1000_hw *hw)
1527 u32 strap = er32(STRAP);
1528 u32 freq = (strap & E1000_STRAP_SMT_FREQ_MASK) >>
1529 E1000_STRAP_SMT_FREQ_SHIFT;
1532 strap &= E1000_STRAP_SMBUS_ADDRESS_MASK;
1534 ret_val = e1000_read_phy_reg_hv_locked(hw, HV_SMB_ADDR, &phy_data);
1538 phy_data &= ~HV_SMB_ADDR_MASK;
1539 phy_data |= (strap >> E1000_STRAP_SMBUS_ADDRESS_SHIFT);
1540 phy_data |= HV_SMB_ADDR_PEC_EN | HV_SMB_ADDR_VALID;
1542 if (hw->phy.type == e1000_phy_i217) {
1543 /* Restore SMBus frequency */
1545 phy_data &= ~HV_SMB_ADDR_FREQ_MASK;
1546 phy_data |= (freq & (1 << 0)) <<
1547 HV_SMB_ADDR_FREQ_LOW_SHIFT;
1548 phy_data |= (freq & (1 << 1)) <<
1549 (HV_SMB_ADDR_FREQ_HIGH_SHIFT - 1);
1551 e_dbg("Unsupported SMB frequency in PHY\n");
1555 return e1000_write_phy_reg_hv_locked(hw, HV_SMB_ADDR, phy_data);
1559 * e1000_sw_lcd_config_ich8lan - SW-based LCD Configuration
1560 * @hw: pointer to the HW structure
1562 * SW should configure the LCD from the NVM extended configuration region
1563 * as a workaround for certain parts.
1565 static s32 e1000_sw_lcd_config_ich8lan(struct e1000_hw *hw)
1567 struct e1000_phy_info *phy = &hw->phy;
1568 u32 i, data, cnf_size, cnf_base_addr, sw_cfg_mask;
1570 u16 word_addr, reg_data, reg_addr, phy_page = 0;
1572 /* Initialize the PHY from the NVM on ICH platforms. This
1573 * is needed due to an issue where the NVM configuration is
1574 * not properly autoloaded after power transitions.
1575 * Therefore, after each PHY reset, we will load the
1576 * configuration data out of the NVM manually.
1578 switch (hw->mac.type) {
1580 if (phy->type != e1000_phy_igp_3)
1583 if ((hw->adapter->pdev->device == E1000_DEV_ID_ICH8_IGP_AMT) ||
1584 (hw->adapter->pdev->device == E1000_DEV_ID_ICH8_IGP_C)) {
1585 sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG;
1592 sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG_ICH8M;
1598 ret_val = hw->phy.ops.acquire(hw);
1602 data = er32(FEXTNVM);
1603 if (!(data & sw_cfg_mask))
1606 /* Make sure HW does not configure LCD from PHY
1607 * extended configuration before SW configuration
1609 data = er32(EXTCNF_CTRL);
1610 if ((hw->mac.type < e1000_pch2lan) &&
1611 (data & E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE))
1614 cnf_size = er32(EXTCNF_SIZE);
1615 cnf_size &= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_MASK;
1616 cnf_size >>= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_SHIFT;
1620 cnf_base_addr = data & E1000_EXTCNF_CTRL_EXT_CNF_POINTER_MASK;
1621 cnf_base_addr >>= E1000_EXTCNF_CTRL_EXT_CNF_POINTER_SHIFT;
1623 if (((hw->mac.type == e1000_pchlan) &&
1624 !(data & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE)) ||
1625 (hw->mac.type > e1000_pchlan)) {
1626 /* HW configures the SMBus address and LEDs when the
1627 * OEM and LCD Write Enable bits are set in the NVM.
1628 * When both NVM bits are cleared, SW will configure
1631 ret_val = e1000_write_smbus_addr(hw);
1635 data = er32(LEDCTL);
1636 ret_val = e1000_write_phy_reg_hv_locked(hw, HV_LED_CONFIG,
1642 /* Configure LCD from extended configuration region. */
1644 /* cnf_base_addr is in DWORD */
1645 word_addr = (u16)(cnf_base_addr << 1);
1647 for (i = 0; i < cnf_size; i++) {
1648 ret_val = e1000_read_nvm(hw, (word_addr + i * 2), 1, ®_data);
1652 ret_val = e1000_read_nvm(hw, (word_addr + i * 2 + 1),
1657 /* Save off the PHY page for future writes. */
1658 if (reg_addr == IGP01E1000_PHY_PAGE_SELECT) {
1659 phy_page = reg_data;
1663 reg_addr &= PHY_REG_MASK;
1664 reg_addr |= phy_page;
1666 ret_val = e1e_wphy_locked(hw, (u32)reg_addr, reg_data);
1672 hw->phy.ops.release(hw);
1677 * e1000_k1_gig_workaround_hv - K1 Si workaround
1678 * @hw: pointer to the HW structure
1679 * @link: link up bool flag
1681 * If K1 is enabled for 1Gbps, the MAC might stall when transitioning
1682 * from a lower speed. This workaround disables K1 whenever link is at 1Gig
1683 * If link is down, the function will restore the default K1 setting located
1686 static s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link)
1690 bool k1_enable = hw->dev_spec.ich8lan.nvm_k1_enabled;
1692 if (hw->mac.type != e1000_pchlan)
1695 /* Wrap the whole flow with the sw flag */
1696 ret_val = hw->phy.ops.acquire(hw);
1700 /* Disable K1 when link is 1Gbps, otherwise use the NVM setting */
1702 if (hw->phy.type == e1000_phy_82578) {
1703 ret_val = e1e_rphy_locked(hw, BM_CS_STATUS,
1708 status_reg &= (BM_CS_STATUS_LINK_UP |
1709 BM_CS_STATUS_RESOLVED |
1710 BM_CS_STATUS_SPEED_MASK);
1712 if (status_reg == (BM_CS_STATUS_LINK_UP |
1713 BM_CS_STATUS_RESOLVED |
1714 BM_CS_STATUS_SPEED_1000))
1718 if (hw->phy.type == e1000_phy_82577) {
1719 ret_val = e1e_rphy_locked(hw, HV_M_STATUS, &status_reg);
1723 status_reg &= (HV_M_STATUS_LINK_UP |
1724 HV_M_STATUS_AUTONEG_COMPLETE |
1725 HV_M_STATUS_SPEED_MASK);
1727 if (status_reg == (HV_M_STATUS_LINK_UP |
1728 HV_M_STATUS_AUTONEG_COMPLETE |
1729 HV_M_STATUS_SPEED_1000))
1733 /* Link stall fix for link up */
1734 ret_val = e1e_wphy_locked(hw, PHY_REG(770, 19), 0x0100);
1739 /* Link stall fix for link down */
1740 ret_val = e1e_wphy_locked(hw, PHY_REG(770, 19), 0x4100);
1745 ret_val = e1000_configure_k1_ich8lan(hw, k1_enable);
1748 hw->phy.ops.release(hw);
1754 * e1000_configure_k1_ich8lan - Configure K1 power state
1755 * @hw: pointer to the HW structure
1756 * @enable: K1 state to configure
1758 * Configure the K1 power state based on the provided parameter.
1759 * Assumes semaphore already acquired.
1761 * Success returns 0, Failure returns -E1000_ERR_PHY (-2)
1763 s32 e1000_configure_k1_ich8lan(struct e1000_hw *hw, bool k1_enable)
1771 ret_val = e1000e_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
1777 kmrn_reg |= E1000_KMRNCTRLSTA_K1_ENABLE;
1779 kmrn_reg &= ~E1000_KMRNCTRLSTA_K1_ENABLE;
1781 ret_val = e1000e_write_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
1786 usleep_range(20, 40);
1787 ctrl_ext = er32(CTRL_EXT);
1788 ctrl_reg = er32(CTRL);
1790 reg = ctrl_reg & ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100);
1791 reg |= E1000_CTRL_FRCSPD;
1794 ew32(CTRL_EXT, ctrl_ext | E1000_CTRL_EXT_SPD_BYPS);
1796 usleep_range(20, 40);
1797 ew32(CTRL, ctrl_reg);
1798 ew32(CTRL_EXT, ctrl_ext);
1800 usleep_range(20, 40);
1806 * e1000_oem_bits_config_ich8lan - SW-based LCD Configuration
1807 * @hw: pointer to the HW structure
1808 * @d0_state: boolean if entering d0 or d3 device state
1810 * SW will configure Gbe Disable and LPLU based on the NVM. The four bits are
1811 * collectively called OEM bits. The OEM Write Enable bit and SW Config bit
1812 * in NVM determines whether HW should configure LPLU and Gbe Disable.
1814 static s32 e1000_oem_bits_config_ich8lan(struct e1000_hw *hw, bool d0_state)
1820 if (hw->mac.type < e1000_pchlan)
1823 ret_val = hw->phy.ops.acquire(hw);
1827 if (hw->mac.type == e1000_pchlan) {
1828 mac_reg = er32(EXTCNF_CTRL);
1829 if (mac_reg & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE)
1833 mac_reg = er32(FEXTNVM);
1834 if (!(mac_reg & E1000_FEXTNVM_SW_CONFIG_ICH8M))
1837 mac_reg = er32(PHY_CTRL);
1839 ret_val = e1e_rphy_locked(hw, HV_OEM_BITS, &oem_reg);
1843 oem_reg &= ~(HV_OEM_BITS_GBE_DIS | HV_OEM_BITS_LPLU);
1846 if (mac_reg & E1000_PHY_CTRL_GBE_DISABLE)
1847 oem_reg |= HV_OEM_BITS_GBE_DIS;
1849 if (mac_reg & E1000_PHY_CTRL_D0A_LPLU)
1850 oem_reg |= HV_OEM_BITS_LPLU;
1852 if (mac_reg & (E1000_PHY_CTRL_GBE_DISABLE |
1853 E1000_PHY_CTRL_NOND0A_GBE_DISABLE))
1854 oem_reg |= HV_OEM_BITS_GBE_DIS;
1856 if (mac_reg & (E1000_PHY_CTRL_D0A_LPLU |
1857 E1000_PHY_CTRL_NOND0A_LPLU))
1858 oem_reg |= HV_OEM_BITS_LPLU;
1861 /* Set Restart auto-neg to activate the bits */
1862 if ((d0_state || (hw->mac.type != e1000_pchlan)) &&
1863 !hw->phy.ops.check_reset_block(hw))
1864 oem_reg |= HV_OEM_BITS_RESTART_AN;
1866 ret_val = e1e_wphy_locked(hw, HV_OEM_BITS, oem_reg);
1869 hw->phy.ops.release(hw);
1875 * e1000_set_mdio_slow_mode_hv - Set slow MDIO access mode
1876 * @hw: pointer to the HW structure
1878 static s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw)
1883 ret_val = e1e_rphy(hw, HV_KMRN_MODE_CTRL, &data);
1887 data |= HV_KMRN_MDIO_SLOW;
1889 ret_val = e1e_wphy(hw, HV_KMRN_MODE_CTRL, data);
1895 * e1000_hv_phy_workarounds_ich8lan - A series of Phy workarounds to be
1896 * done after every PHY reset.
1898 static s32 e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw)
1903 if (hw->mac.type != e1000_pchlan)
1906 /* Set MDIO slow mode before any other MDIO access */
1907 if (hw->phy.type == e1000_phy_82577) {
1908 ret_val = e1000_set_mdio_slow_mode_hv(hw);
1913 if (((hw->phy.type == e1000_phy_82577) &&
1914 ((hw->phy.revision == 1) || (hw->phy.revision == 2))) ||
1915 ((hw->phy.type == e1000_phy_82578) && (hw->phy.revision == 1))) {
1916 /* Disable generation of early preamble */
1917 ret_val = e1e_wphy(hw, PHY_REG(769, 25), 0x4431);
1921 /* Preamble tuning for SSC */
1922 ret_val = e1e_wphy(hw, HV_KMRN_FIFO_CTRLSTA, 0xA204);
1927 if (hw->phy.type == e1000_phy_82578) {
1928 /* Return registers to default by doing a soft reset then
1929 * writing 0x3140 to the control register.
1931 if (hw->phy.revision < 2) {
1932 e1000e_phy_sw_reset(hw);
1933 ret_val = e1e_wphy(hw, MII_BMCR, 0x3140);
1938 ret_val = hw->phy.ops.acquire(hw);
1943 ret_val = e1000e_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT, 0);
1944 hw->phy.ops.release(hw);
1948 /* Configure the K1 Si workaround during phy reset assuming there is
1949 * link so that it disables K1 if link is in 1Gbps.
1951 ret_val = e1000_k1_gig_workaround_hv(hw, true);
1955 /* Workaround for link disconnects on a busy hub in half duplex */
1956 ret_val = hw->phy.ops.acquire(hw);
1959 ret_val = e1e_rphy_locked(hw, BM_PORT_GEN_CFG, &phy_data);
1962 ret_val = e1e_wphy_locked(hw, BM_PORT_GEN_CFG, phy_data & 0x00FF);
1966 /* set MSE higher to enable link to stay up when noise is high */
1967 ret_val = e1000_write_emi_reg_locked(hw, I82577_MSE_THRESHOLD, 0x0034);
1969 hw->phy.ops.release(hw);
1975 * e1000_copy_rx_addrs_to_phy_ich8lan - Copy Rx addresses from MAC to PHY
1976 * @hw: pointer to the HW structure
1978 void e1000_copy_rx_addrs_to_phy_ich8lan(struct e1000_hw *hw)
1984 ret_val = hw->phy.ops.acquire(hw);
1987 ret_val = e1000_enable_phy_wakeup_reg_access_bm(hw, &phy_reg);
1991 /* Copy both RAL/H (rar_entry_count) and SHRAL/H to PHY */
1992 for (i = 0; i < (hw->mac.rar_entry_count); i++) {
1993 mac_reg = er32(RAL(i));
1994 hw->phy.ops.write_reg_page(hw, BM_RAR_L(i),
1995 (u16)(mac_reg & 0xFFFF));
1996 hw->phy.ops.write_reg_page(hw, BM_RAR_M(i),
1997 (u16)((mac_reg >> 16) & 0xFFFF));
1999 mac_reg = er32(RAH(i));
2000 hw->phy.ops.write_reg_page(hw, BM_RAR_H(i),
2001 (u16)(mac_reg & 0xFFFF));
2002 hw->phy.ops.write_reg_page(hw, BM_RAR_CTRL(i),
2003 (u16)((mac_reg & E1000_RAH_AV)
2007 e1000_disable_phy_wakeup_reg_access_bm(hw, &phy_reg);
2010 hw->phy.ops.release(hw);
2014 * e1000_lv_jumbo_workaround_ich8lan - required for jumbo frame operation
2016 * @hw: pointer to the HW structure
2017 * @enable: flag to enable/disable workaround when enabling/disabling jumbos
2019 s32 e1000_lv_jumbo_workaround_ich8lan(struct e1000_hw *hw, bool enable)
2026 if (hw->mac.type < e1000_pch2lan)
2029 /* disable Rx path while enabling/disabling workaround */
2030 e1e_rphy(hw, PHY_REG(769, 20), &phy_reg);
2031 ret_val = e1e_wphy(hw, PHY_REG(769, 20), phy_reg | (1 << 14));
2036 /* Write Rx addresses (rar_entry_count for RAL/H, and
2037 * SHRAL/H) and initial CRC values to the MAC
2039 for (i = 0; i < hw->mac.rar_entry_count; i++) {
2040 u8 mac_addr[ETH_ALEN] = { 0 };
2041 u32 addr_high, addr_low;
2043 addr_high = er32(RAH(i));
2044 if (!(addr_high & E1000_RAH_AV))
2046 addr_low = er32(RAL(i));
2047 mac_addr[0] = (addr_low & 0xFF);
2048 mac_addr[1] = ((addr_low >> 8) & 0xFF);
2049 mac_addr[2] = ((addr_low >> 16) & 0xFF);
2050 mac_addr[3] = ((addr_low >> 24) & 0xFF);
2051 mac_addr[4] = (addr_high & 0xFF);
2052 mac_addr[5] = ((addr_high >> 8) & 0xFF);
2054 ew32(PCH_RAICC(i), ~ether_crc_le(ETH_ALEN, mac_addr));
2057 /* Write Rx addresses to the PHY */
2058 e1000_copy_rx_addrs_to_phy_ich8lan(hw);
2060 /* Enable jumbo frame workaround in the MAC */
2061 mac_reg = er32(FFLT_DBG);
2062 mac_reg &= ~(1 << 14);
2063 mac_reg |= (7 << 15);
2064 ew32(FFLT_DBG, mac_reg);
2066 mac_reg = er32(RCTL);
2067 mac_reg |= E1000_RCTL_SECRC;
2068 ew32(RCTL, mac_reg);
2070 ret_val = e1000e_read_kmrn_reg(hw,
2071 E1000_KMRNCTRLSTA_CTRL_OFFSET,
2075 ret_val = e1000e_write_kmrn_reg(hw,
2076 E1000_KMRNCTRLSTA_CTRL_OFFSET,
2080 ret_val = e1000e_read_kmrn_reg(hw,
2081 E1000_KMRNCTRLSTA_HD_CTRL,
2085 data &= ~(0xF << 8);
2087 ret_val = e1000e_write_kmrn_reg(hw,
2088 E1000_KMRNCTRLSTA_HD_CTRL,
2093 /* Enable jumbo frame workaround in the PHY */
2094 e1e_rphy(hw, PHY_REG(769, 23), &data);
2095 data &= ~(0x7F << 5);
2096 data |= (0x37 << 5);
2097 ret_val = e1e_wphy(hw, PHY_REG(769, 23), data);
2100 e1e_rphy(hw, PHY_REG(769, 16), &data);
2102 ret_val = e1e_wphy(hw, PHY_REG(769, 16), data);
2105 e1e_rphy(hw, PHY_REG(776, 20), &data);
2106 data &= ~(0x3FF << 2);
2107 data |= (0x1A << 2);
2108 ret_val = e1e_wphy(hw, PHY_REG(776, 20), data);
2111 ret_val = e1e_wphy(hw, PHY_REG(776, 23), 0xF100);
2114 e1e_rphy(hw, HV_PM_CTRL, &data);
2115 ret_val = e1e_wphy(hw, HV_PM_CTRL, data | (1 << 10));
2119 /* Write MAC register values back to h/w defaults */
2120 mac_reg = er32(FFLT_DBG);
2121 mac_reg &= ~(0xF << 14);
2122 ew32(FFLT_DBG, mac_reg);
2124 mac_reg = er32(RCTL);
2125 mac_reg &= ~E1000_RCTL_SECRC;
2126 ew32(RCTL, mac_reg);
2128 ret_val = e1000e_read_kmrn_reg(hw,
2129 E1000_KMRNCTRLSTA_CTRL_OFFSET,
2133 ret_val = e1000e_write_kmrn_reg(hw,
2134 E1000_KMRNCTRLSTA_CTRL_OFFSET,
2138 ret_val = e1000e_read_kmrn_reg(hw,
2139 E1000_KMRNCTRLSTA_HD_CTRL,
2143 data &= ~(0xF << 8);
2145 ret_val = e1000e_write_kmrn_reg(hw,
2146 E1000_KMRNCTRLSTA_HD_CTRL,
2151 /* Write PHY register values back to h/w defaults */
2152 e1e_rphy(hw, PHY_REG(769, 23), &data);
2153 data &= ~(0x7F << 5);
2154 ret_val = e1e_wphy(hw, PHY_REG(769, 23), data);
2157 e1e_rphy(hw, PHY_REG(769, 16), &data);
2159 ret_val = e1e_wphy(hw, PHY_REG(769, 16), data);
2162 e1e_rphy(hw, PHY_REG(776, 20), &data);
2163 data &= ~(0x3FF << 2);
2165 ret_val = e1e_wphy(hw, PHY_REG(776, 20), data);
2168 ret_val = e1e_wphy(hw, PHY_REG(776, 23), 0x7E00);
2171 e1e_rphy(hw, HV_PM_CTRL, &data);
2172 ret_val = e1e_wphy(hw, HV_PM_CTRL, data & ~(1 << 10));
2177 /* re-enable Rx path after enabling/disabling workaround */
2178 return e1e_wphy(hw, PHY_REG(769, 20), phy_reg & ~(1 << 14));
2182 * e1000_lv_phy_workarounds_ich8lan - A series of Phy workarounds to be
2183 * done after every PHY reset.
2185 static s32 e1000_lv_phy_workarounds_ich8lan(struct e1000_hw *hw)
2189 if (hw->mac.type != e1000_pch2lan)
2192 /* Set MDIO slow mode before any other MDIO access */
2193 ret_val = e1000_set_mdio_slow_mode_hv(hw);
2197 ret_val = hw->phy.ops.acquire(hw);
2200 /* set MSE higher to enable link to stay up when noise is high */
2201 ret_val = e1000_write_emi_reg_locked(hw, I82579_MSE_THRESHOLD, 0x0034);
2204 /* drop link after 5 times MSE threshold was reached */
2205 ret_val = e1000_write_emi_reg_locked(hw, I82579_MSE_LINK_DOWN, 0x0005);
2207 hw->phy.ops.release(hw);
2213 * e1000_k1_gig_workaround_lv - K1 Si workaround
2214 * @hw: pointer to the HW structure
2216 * Workaround to set the K1 beacon duration for 82579 parts
2218 static s32 e1000_k1_workaround_lv(struct e1000_hw *hw)
2225 if (hw->mac.type != e1000_pch2lan)
2228 /* Set K1 beacon duration based on 1Gbps speed or otherwise */
2229 ret_val = e1e_rphy(hw, HV_M_STATUS, &status_reg);
2233 if ((status_reg & (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE))
2234 == (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE)) {
2235 mac_reg = er32(FEXTNVM4);
2236 mac_reg &= ~E1000_FEXTNVM4_BEACON_DURATION_MASK;
2238 ret_val = e1e_rphy(hw, I82579_LPI_CTRL, &phy_reg);
2242 if (status_reg & HV_M_STATUS_SPEED_1000) {
2245 mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_8USEC;
2246 phy_reg &= ~I82579_LPI_CTRL_FORCE_PLL_LOCK_COUNT;
2247 /* LV 1G Packet drop issue wa */
2248 ret_val = e1e_rphy(hw, HV_PM_CTRL, &pm_phy_reg);
2251 pm_phy_reg &= ~HV_PM_CTRL_PLL_STOP_IN_K1_GIGA;
2252 ret_val = e1e_wphy(hw, HV_PM_CTRL, pm_phy_reg);
2256 mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_16USEC;
2257 phy_reg |= I82579_LPI_CTRL_FORCE_PLL_LOCK_COUNT;
2259 ew32(FEXTNVM4, mac_reg);
2260 ret_val = e1e_wphy(hw, I82579_LPI_CTRL, phy_reg);
2267 * e1000_gate_hw_phy_config_ich8lan - disable PHY config via hardware
2268 * @hw: pointer to the HW structure
2269 * @gate: boolean set to true to gate, false to ungate
2271 * Gate/ungate the automatic PHY configuration via hardware; perform
2272 * the configuration via software instead.
2274 static void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate)
2278 if (hw->mac.type < e1000_pch2lan)
2281 extcnf_ctrl = er32(EXTCNF_CTRL);
2284 extcnf_ctrl |= E1000_EXTCNF_CTRL_GATE_PHY_CFG;
2286 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_GATE_PHY_CFG;
2288 ew32(EXTCNF_CTRL, extcnf_ctrl);
2292 * e1000_lan_init_done_ich8lan - Check for PHY config completion
2293 * @hw: pointer to the HW structure
2295 * Check the appropriate indication the MAC has finished configuring the
2296 * PHY after a software reset.
2298 static void e1000_lan_init_done_ich8lan(struct e1000_hw *hw)
2300 u32 data, loop = E1000_ICH8_LAN_INIT_TIMEOUT;
2302 /* Wait for basic configuration completes before proceeding */
2304 data = er32(STATUS);
2305 data &= E1000_STATUS_LAN_INIT_DONE;
2306 usleep_range(100, 200);
2307 } while ((!data) && --loop);
2309 /* If basic configuration is incomplete before the above loop
2310 * count reaches 0, loading the configuration from NVM will
2311 * leave the PHY in a bad state possibly resulting in no link.
2314 e_dbg("LAN_INIT_DONE not set, increase timeout\n");
2316 /* Clear the Init Done bit for the next init event */
2317 data = er32(STATUS);
2318 data &= ~E1000_STATUS_LAN_INIT_DONE;
2323 * e1000_post_phy_reset_ich8lan - Perform steps required after a PHY reset
2324 * @hw: pointer to the HW structure
2326 static s32 e1000_post_phy_reset_ich8lan(struct e1000_hw *hw)
2331 if (hw->phy.ops.check_reset_block(hw))
2334 /* Allow time for h/w to get to quiescent state after reset */
2335 usleep_range(10000, 20000);
2337 /* Perform any necessary post-reset workarounds */
2338 switch (hw->mac.type) {
2340 ret_val = e1000_hv_phy_workarounds_ich8lan(hw);
2345 ret_val = e1000_lv_phy_workarounds_ich8lan(hw);
2353 /* Clear the host wakeup bit after lcd reset */
2354 if (hw->mac.type >= e1000_pchlan) {
2355 e1e_rphy(hw, BM_PORT_GEN_CFG, ®);
2356 reg &= ~BM_WUC_HOST_WU_BIT;
2357 e1e_wphy(hw, BM_PORT_GEN_CFG, reg);
2360 /* Configure the LCD with the extended configuration region in NVM */
2361 ret_val = e1000_sw_lcd_config_ich8lan(hw);
2365 /* Configure the LCD with the OEM bits in NVM */
2366 ret_val = e1000_oem_bits_config_ich8lan(hw, true);
2368 if (hw->mac.type == e1000_pch2lan) {
2369 /* Ungate automatic PHY configuration on non-managed 82579 */
2370 if (!(er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) {
2371 usleep_range(10000, 20000);
2372 e1000_gate_hw_phy_config_ich8lan(hw, false);
2375 /* Set EEE LPI Update Timer to 200usec */
2376 ret_val = hw->phy.ops.acquire(hw);
2379 ret_val = e1000_write_emi_reg_locked(hw,
2380 I82579_LPI_UPDATE_TIMER,
2382 hw->phy.ops.release(hw);
2389 * e1000_phy_hw_reset_ich8lan - Performs a PHY reset
2390 * @hw: pointer to the HW structure
2393 * This is a function pointer entry point called by drivers
2394 * or other shared routines.
2396 static s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw)
2400 /* Gate automatic PHY configuration by hardware on non-managed 82579 */
2401 if ((hw->mac.type == e1000_pch2lan) &&
2402 !(er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
2403 e1000_gate_hw_phy_config_ich8lan(hw, true);
2405 ret_val = e1000e_phy_hw_reset_generic(hw);
2409 return e1000_post_phy_reset_ich8lan(hw);
2413 * e1000_set_lplu_state_pchlan - Set Low Power Link Up state
2414 * @hw: pointer to the HW structure
2415 * @active: true to enable LPLU, false to disable
2417 * Sets the LPLU state according to the active flag. For PCH, if OEM write
2418 * bit are disabled in the NVM, writing the LPLU bits in the MAC will not set
2419 * the phy speed. This function will manually set the LPLU bit and restart
2420 * auto-neg as hw would do. D3 and D0 LPLU will call the same function
2421 * since it configures the same bit.
2423 static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active)
2428 ret_val = e1e_rphy(hw, HV_OEM_BITS, &oem_reg);
2433 oem_reg |= HV_OEM_BITS_LPLU;
2435 oem_reg &= ~HV_OEM_BITS_LPLU;
2437 if (!hw->phy.ops.check_reset_block(hw))
2438 oem_reg |= HV_OEM_BITS_RESTART_AN;
2440 return e1e_wphy(hw, HV_OEM_BITS, oem_reg);
2444 * e1000_set_d0_lplu_state_ich8lan - Set Low Power Linkup D0 state
2445 * @hw: pointer to the HW structure
2446 * @active: true to enable LPLU, false to disable
2448 * Sets the LPLU D0 state according to the active flag. When
2449 * activating LPLU this function also disables smart speed
2450 * and vice versa. LPLU will not be activated unless the
2451 * device autonegotiation advertisement meets standards of
2452 * either 10 or 10/100 or 10/100/1000 at all duplexes.
2453 * This is a function pointer entry point only called by
2454 * PHY setup routines.
2456 static s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
2458 struct e1000_phy_info *phy = &hw->phy;
2463 if (phy->type == e1000_phy_ife)
2466 phy_ctrl = er32(PHY_CTRL);
2469 phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU;
2470 ew32(PHY_CTRL, phy_ctrl);
2472 if (phy->type != e1000_phy_igp_3)
2475 /* Call gig speed drop workaround on LPLU before accessing
2478 if (hw->mac.type == e1000_ich8lan)
2479 e1000e_gig_downshift_workaround_ich8lan(hw);
2481 /* When LPLU is enabled, we should disable SmartSpeed */
2482 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data);
2485 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
2486 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);
2490 phy_ctrl &= ~E1000_PHY_CTRL_D0A_LPLU;
2491 ew32(PHY_CTRL, phy_ctrl);
2493 if (phy->type != e1000_phy_igp_3)
2496 /* LPLU and SmartSpeed are mutually exclusive. LPLU is used
2497 * during Dx states where the power conservation is most
2498 * important. During driver activity we should enable
2499 * SmartSpeed, so performance is maintained.
2501 if (phy->smart_speed == e1000_smart_speed_on) {
2502 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
2507 data |= IGP01E1000_PSCFR_SMART_SPEED;
2508 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
2512 } else if (phy->smart_speed == e1000_smart_speed_off) {
2513 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
2518 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
2519 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
2530 * e1000_set_d3_lplu_state_ich8lan - Set Low Power Linkup D3 state
2531 * @hw: pointer to the HW structure
2532 * @active: true to enable LPLU, false to disable
2534 * Sets the LPLU D3 state according to the active flag. When
2535 * activating LPLU this function also disables smart speed
2536 * and vice versa. LPLU will not be activated unless the
2537 * device autonegotiation advertisement meets standards of
2538 * either 10 or 10/100 or 10/100/1000 at all duplexes.
2539 * This is a function pointer entry point only called by
2540 * PHY setup routines.
2542 static s32 e1000_set_d3_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
2544 struct e1000_phy_info *phy = &hw->phy;
2549 phy_ctrl = er32(PHY_CTRL);
2552 phy_ctrl &= ~E1000_PHY_CTRL_NOND0A_LPLU;
2553 ew32(PHY_CTRL, phy_ctrl);
2555 if (phy->type != e1000_phy_igp_3)
2558 /* LPLU and SmartSpeed are mutually exclusive. LPLU is used
2559 * during Dx states where the power conservation is most
2560 * important. During driver activity we should enable
2561 * SmartSpeed, so performance is maintained.
2563 if (phy->smart_speed == e1000_smart_speed_on) {
2564 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
2569 data |= IGP01E1000_PSCFR_SMART_SPEED;
2570 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
2574 } else if (phy->smart_speed == e1000_smart_speed_off) {
2575 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
2580 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
2581 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
2586 } else if ((phy->autoneg_advertised == E1000_ALL_SPEED_DUPLEX) ||
2587 (phy->autoneg_advertised == E1000_ALL_NOT_GIG) ||
2588 (phy->autoneg_advertised == E1000_ALL_10_SPEED)) {
2589 phy_ctrl |= E1000_PHY_CTRL_NOND0A_LPLU;
2590 ew32(PHY_CTRL, phy_ctrl);
2592 if (phy->type != e1000_phy_igp_3)
2595 /* Call gig speed drop workaround on LPLU before accessing
2598 if (hw->mac.type == e1000_ich8lan)
2599 e1000e_gig_downshift_workaround_ich8lan(hw);
2601 /* When LPLU is enabled, we should disable SmartSpeed */
2602 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data);
2606 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
2607 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);
2614 * e1000_valid_nvm_bank_detect_ich8lan - finds out the valid bank 0 or 1
2615 * @hw: pointer to the HW structure
2616 * @bank: pointer to the variable that returns the active bank
2618 * Reads signature byte from the NVM using the flash access registers.
2619 * Word 0x13 bits 15:14 = 10b indicate a valid signature for that bank.
2621 static s32 e1000_valid_nvm_bank_detect_ich8lan(struct e1000_hw *hw, u32 *bank)
2624 struct e1000_nvm_info *nvm = &hw->nvm;
2625 u32 bank1_offset = nvm->flash_bank_size * sizeof(u16);
2626 u32 act_offset = E1000_ICH_NVM_SIG_WORD * 2 + 1;
2630 switch (hw->mac.type) {
2634 if ((eecd & E1000_EECD_SEC1VAL_VALID_MASK) ==
2635 E1000_EECD_SEC1VAL_VALID_MASK) {
2636 if (eecd & E1000_EECD_SEC1VAL)
2643 e_dbg("Unable to determine valid NVM bank via EEC - reading flash signature\n");
2646 /* set bank to 0 in case flash read fails */
2650 ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset,
2654 if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
2655 E1000_ICH_NVM_SIG_VALUE) {
2661 ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset +
2666 if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
2667 E1000_ICH_NVM_SIG_VALUE) {
2672 e_dbg("ERROR: No valid NVM bank present\n");
2673 return -E1000_ERR_NVM;
2678 * e1000_read_nvm_ich8lan - Read word(s) from the NVM
2679 * @hw: pointer to the HW structure
2680 * @offset: The offset (in bytes) of the word(s) to read.
2681 * @words: Size of data to read in words
2682 * @data: Pointer to the word(s) to read at offset.
2684 * Reads a word(s) from the NVM using the flash access registers.
2686 static s32 e1000_read_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
2689 struct e1000_nvm_info *nvm = &hw->nvm;
2690 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
2696 if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
2698 e_dbg("nvm parameter(s) out of bounds\n");
2699 ret_val = -E1000_ERR_NVM;
2703 nvm->ops.acquire(hw);
2705 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
2707 e_dbg("Could not detect valid bank, assuming bank 0\n");
2711 act_offset = (bank) ? nvm->flash_bank_size : 0;
2712 act_offset += offset;
2715 for (i = 0; i < words; i++) {
2716 if (dev_spec->shadow_ram[offset + i].modified) {
2717 data[i] = dev_spec->shadow_ram[offset + i].value;
2719 ret_val = e1000_read_flash_word_ich8lan(hw,
2728 nvm->ops.release(hw);
2732 e_dbg("NVM read error: %d\n", ret_val);
2738 * e1000_flash_cycle_init_ich8lan - Initialize flash
2739 * @hw: pointer to the HW structure
2741 * This function does initial flash setup so that a new read/write/erase cycle
2744 static s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw)
2746 union ich8_hws_flash_status hsfsts;
2747 s32 ret_val = -E1000_ERR_NVM;
2749 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
2751 /* Check if the flash descriptor is valid */
2752 if (!hsfsts.hsf_status.fldesvalid) {
2753 e_dbg("Flash descriptor invalid. SW Sequencing must be used.\n");
2754 return -E1000_ERR_NVM;
2757 /* Clear FCERR and DAEL in hw status by writing 1 */
2758 hsfsts.hsf_status.flcerr = 1;
2759 hsfsts.hsf_status.dael = 1;
2761 ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
2763 /* Either we should have a hardware SPI cycle in progress
2764 * bit to check against, in order to start a new cycle or
2765 * FDONE bit should be changed in the hardware so that it
2766 * is 1 after hardware reset, which can then be used as an
2767 * indication whether a cycle is in progress or has been
2771 if (!hsfsts.hsf_status.flcinprog) {
2772 /* There is no cycle running at present,
2773 * so we can start a cycle.
2774 * Begin by setting Flash Cycle Done.
2776 hsfsts.hsf_status.flcdone = 1;
2777 ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
2782 /* Otherwise poll for sometime so the current
2783 * cycle has a chance to end before giving up.
2785 for (i = 0; i < ICH_FLASH_READ_COMMAND_TIMEOUT; i++) {
2786 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
2787 if (!hsfsts.hsf_status.flcinprog) {
2794 /* Successful in waiting for previous cycle to timeout,
2795 * now set the Flash Cycle Done.
2797 hsfsts.hsf_status.flcdone = 1;
2798 ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
2800 e_dbg("Flash controller busy, cannot get access\n");
2808 * e1000_flash_cycle_ich8lan - Starts flash cycle (read/write/erase)
2809 * @hw: pointer to the HW structure
2810 * @timeout: maximum time to wait for completion
2812 * This function starts a flash cycle and waits for its completion.
2814 static s32 e1000_flash_cycle_ich8lan(struct e1000_hw *hw, u32 timeout)
2816 union ich8_hws_flash_ctrl hsflctl;
2817 union ich8_hws_flash_status hsfsts;
2820 /* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */
2821 hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
2822 hsflctl.hsf_ctrl.flcgo = 1;
2823 ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
2825 /* wait till FDONE bit is set to 1 */
2827 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
2828 if (hsfsts.hsf_status.flcdone)
2831 } while (i++ < timeout);
2833 if (hsfsts.hsf_status.flcdone && !hsfsts.hsf_status.flcerr)
2836 return -E1000_ERR_NVM;
2840 * e1000_read_flash_word_ich8lan - Read word from flash
2841 * @hw: pointer to the HW structure
2842 * @offset: offset to data location
2843 * @data: pointer to the location for storing the data
2845 * Reads the flash word at offset into data. Offset is converted
2846 * to bytes before read.
2848 static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset,
2851 /* Must convert offset into bytes. */
2854 return e1000_read_flash_data_ich8lan(hw, offset, 2, data);
2858 * e1000_read_flash_byte_ich8lan - Read byte from flash
2859 * @hw: pointer to the HW structure
2860 * @offset: The offset of the byte to read.
2861 * @data: Pointer to a byte to store the value read.
2863 * Reads a single byte from the NVM using the flash access registers.
2865 static s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
2871 ret_val = e1000_read_flash_data_ich8lan(hw, offset, 1, &word);
2881 * e1000_read_flash_data_ich8lan - Read byte or word from NVM
2882 * @hw: pointer to the HW structure
2883 * @offset: The offset (in bytes) of the byte or word to read.
2884 * @size: Size of data to read, 1=byte 2=word
2885 * @data: Pointer to the word to store the value read.
2887 * Reads a byte or word from the NVM using the flash access registers.
2889 static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
2892 union ich8_hws_flash_status hsfsts;
2893 union ich8_hws_flash_ctrl hsflctl;
2894 u32 flash_linear_addr;
2896 s32 ret_val = -E1000_ERR_NVM;
2899 if (size < 1 || size > 2 || offset > ICH_FLASH_LINEAR_ADDR_MASK)
2900 return -E1000_ERR_NVM;
2902 flash_linear_addr = ((ICH_FLASH_LINEAR_ADDR_MASK & offset) +
2903 hw->nvm.flash_base_addr);
2908 ret_val = e1000_flash_cycle_init_ich8lan(hw);
2912 hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
2913 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
2914 hsflctl.hsf_ctrl.fldbcount = size - 1;
2915 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_READ;
2916 ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
2918 ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
2921 e1000_flash_cycle_ich8lan(hw,
2922 ICH_FLASH_READ_COMMAND_TIMEOUT);
2924 /* Check if FCERR is set to 1, if set to 1, clear it
2925 * and try the whole sequence a few more times, else
2926 * read in (shift in) the Flash Data0, the order is
2927 * least significant byte first msb to lsb
2930 flash_data = er32flash(ICH_FLASH_FDATA0);
2932 *data = (u8)(flash_data & 0x000000FF);
2934 *data = (u16)(flash_data & 0x0000FFFF);
2937 /* If we've gotten here, then things are probably
2938 * completely hosed, but if the error condition is
2939 * detected, it won't hurt to give it another try...
2940 * ICH_FLASH_CYCLE_REPEAT_COUNT times.
2942 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
2943 if (hsfsts.hsf_status.flcerr) {
2944 /* Repeat for some time before giving up. */
2946 } else if (!hsfsts.hsf_status.flcdone) {
2947 e_dbg("Timeout error - flash cycle did not complete.\n");
2951 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
2957 * e1000_write_nvm_ich8lan - Write word(s) to the NVM
2958 * @hw: pointer to the HW structure
2959 * @offset: The offset (in bytes) of the word(s) to write.
2960 * @words: Size of data to write in words
2961 * @data: Pointer to the word(s) to write at offset.
2963 * Writes a byte or word to the NVM using the flash access registers.
2965 static s32 e1000_write_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
2968 struct e1000_nvm_info *nvm = &hw->nvm;
2969 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
2972 if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
2974 e_dbg("nvm parameter(s) out of bounds\n");
2975 return -E1000_ERR_NVM;
2978 nvm->ops.acquire(hw);
2980 for (i = 0; i < words; i++) {
2981 dev_spec->shadow_ram[offset + i].modified = true;
2982 dev_spec->shadow_ram[offset + i].value = data[i];
2985 nvm->ops.release(hw);
2991 * e1000_update_nvm_checksum_ich8lan - Update the checksum for NVM
2992 * @hw: pointer to the HW structure
2994 * The NVM checksum is updated by calling the generic update_nvm_checksum,
2995 * which writes the checksum to the shadow ram. The changes in the shadow
2996 * ram are then committed to the EEPROM by processing each bank at a time
2997 * checking for the modified bit and writing only the pending changes.
2998 * After a successful commit, the shadow ram is cleared and is ready for
3001 static s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw)
3003 struct e1000_nvm_info *nvm = &hw->nvm;
3004 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
3005 u32 i, act_offset, new_bank_offset, old_bank_offset, bank;
3009 ret_val = e1000e_update_nvm_checksum_generic(hw);
3013 if (nvm->type != e1000_nvm_flash_sw)
3016 nvm->ops.acquire(hw);
3018 /* We're writing to the opposite bank so if we're on bank 1,
3019 * write to bank 0 etc. We also need to erase the segment that
3020 * is going to be written
3022 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
3024 e_dbg("Could not detect valid bank, assuming bank 0\n");
3029 new_bank_offset = nvm->flash_bank_size;
3030 old_bank_offset = 0;
3031 ret_val = e1000_erase_flash_bank_ich8lan(hw, 1);
3035 old_bank_offset = nvm->flash_bank_size;
3036 new_bank_offset = 0;
3037 ret_val = e1000_erase_flash_bank_ich8lan(hw, 0);
3042 for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i++) {
3043 /* Determine whether to write the value stored
3044 * in the other NVM bank or a modified value stored
3047 if (dev_spec->shadow_ram[i].modified) {
3048 data = dev_spec->shadow_ram[i].value;
3050 ret_val = e1000_read_flash_word_ich8lan(hw, i +
3057 /* If the word is 0x13, then make sure the signature bits
3058 * (15:14) are 11b until the commit has completed.
3059 * This will allow us to write 10b which indicates the
3060 * signature is valid. We want to do this after the write
3061 * has completed so that we don't mark the segment valid
3062 * while the write is still in progress
3064 if (i == E1000_ICH_NVM_SIG_WORD)
3065 data |= E1000_ICH_NVM_SIG_MASK;
3067 /* Convert offset to bytes. */
3068 act_offset = (i + new_bank_offset) << 1;
3070 usleep_range(100, 200);
3071 /* Write the bytes to the new bank. */
3072 ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
3078 usleep_range(100, 200);
3079 ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
3086 /* Don't bother writing the segment valid bits if sector
3087 * programming failed.
3090 /* Possibly read-only, see e1000e_write_protect_nvm_ich8lan() */
3091 e_dbg("Flash commit failed.\n");
3095 /* Finally validate the new segment by setting bit 15:14
3096 * to 10b in word 0x13 , this can be done without an
3097 * erase as well since these bits are 11 to start with
3098 * and we need to change bit 14 to 0b
3100 act_offset = new_bank_offset + E1000_ICH_NVM_SIG_WORD;
3101 ret_val = e1000_read_flash_word_ich8lan(hw, act_offset, &data);
3106 ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
3112 /* And invalidate the previously valid segment by setting
3113 * its signature word (0x13) high_byte to 0b. This can be
3114 * done without an erase because flash erase sets all bits
3115 * to 1's. We can write 1's to 0's without an erase
3117 act_offset = (old_bank_offset + E1000_ICH_NVM_SIG_WORD) * 2 + 1;
3118 ret_val = e1000_retry_write_flash_byte_ich8lan(hw, act_offset, 0);
3122 /* Great! Everything worked, we can now clear the cached entries. */
3123 for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i++) {
3124 dev_spec->shadow_ram[i].modified = false;
3125 dev_spec->shadow_ram[i].value = 0xFFFF;
3129 nvm->ops.release(hw);
3131 /* Reload the EEPROM, or else modifications will not appear
3132 * until after the next adapter reset.
3135 nvm->ops.reload(hw);
3136 usleep_range(10000, 20000);
3141 e_dbg("NVM update error: %d\n", ret_val);
3147 * e1000_validate_nvm_checksum_ich8lan - Validate EEPROM checksum
3148 * @hw: pointer to the HW structure
3150 * Check to see if checksum needs to be fixed by reading bit 6 in word 0x19.
3151 * If the bit is 0, that the EEPROM had been modified, but the checksum was not
3152 * calculated, in which case we need to calculate the checksum and set bit 6.
3154 static s32 e1000_validate_nvm_checksum_ich8lan(struct e1000_hw *hw)
3159 u16 valid_csum_mask;
3161 /* Read NVM and check Invalid Image CSUM bit. If this bit is 0,
3162 * the checksum needs to be fixed. This bit is an indication that
3163 * the NVM was prepared by OEM software and did not calculate
3164 * the checksum...a likely scenario.
3166 switch (hw->mac.type) {
3169 valid_csum_mask = NVM_COMPAT_VALID_CSUM;
3172 word = NVM_FUTURE_INIT_WORD1;
3173 valid_csum_mask = NVM_FUTURE_INIT_WORD1_VALID_CSUM;
3177 ret_val = e1000_read_nvm(hw, word, 1, &data);
3181 if (!(data & valid_csum_mask)) {
3182 data |= valid_csum_mask;
3183 ret_val = e1000_write_nvm(hw, word, 1, &data);
3186 ret_val = e1000e_update_nvm_checksum(hw);
3191 return e1000e_validate_nvm_checksum_generic(hw);
3195 * e1000e_write_protect_nvm_ich8lan - Make the NVM read-only
3196 * @hw: pointer to the HW structure
3198 * To prevent malicious write/erase of the NVM, set it to be read-only
3199 * so that the hardware ignores all write/erase cycles of the NVM via
3200 * the flash control registers. The shadow-ram copy of the NVM will
3201 * still be updated, however any updates to this copy will not stick
3202 * across driver reloads.
3204 void e1000e_write_protect_nvm_ich8lan(struct e1000_hw *hw)
3206 struct e1000_nvm_info *nvm = &hw->nvm;
3207 union ich8_flash_protected_range pr0;
3208 union ich8_hws_flash_status hsfsts;
3211 nvm->ops.acquire(hw);
3213 gfpreg = er32flash(ICH_FLASH_GFPREG);
3215 /* Write-protect GbE Sector of NVM */
3216 pr0.regval = er32flash(ICH_FLASH_PR0);
3217 pr0.range.base = gfpreg & FLASH_GFPREG_BASE_MASK;
3218 pr0.range.limit = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK);
3219 pr0.range.wpe = true;
3220 ew32flash(ICH_FLASH_PR0, pr0.regval);
3222 /* Lock down a subset of GbE Flash Control Registers, e.g.
3223 * PR0 to prevent the write-protection from being lifted.
3224 * Once FLOCKDN is set, the registers protected by it cannot
3225 * be written until FLOCKDN is cleared by a hardware reset.
3227 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
3228 hsfsts.hsf_status.flockdn = true;
3229 ew32flash(ICH_FLASH_HSFSTS, hsfsts.regval);
3231 nvm->ops.release(hw);
3235 * e1000_write_flash_data_ich8lan - Writes bytes to the NVM
3236 * @hw: pointer to the HW structure
3237 * @offset: The offset (in bytes) of the byte/word to read.
3238 * @size: Size of data to read, 1=byte 2=word
3239 * @data: The byte(s) to write to the NVM.
3241 * Writes one/two bytes to the NVM using the flash access registers.
3243 static s32 e1000_write_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
3246 union ich8_hws_flash_status hsfsts;
3247 union ich8_hws_flash_ctrl hsflctl;
3248 u32 flash_linear_addr;
3253 if (size < 1 || size > 2 || data > size * 0xff ||
3254 offset > ICH_FLASH_LINEAR_ADDR_MASK)
3255 return -E1000_ERR_NVM;
3257 flash_linear_addr = ((ICH_FLASH_LINEAR_ADDR_MASK & offset) +
3258 hw->nvm.flash_base_addr);
3263 ret_val = e1000_flash_cycle_init_ich8lan(hw);
3267 hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
3268 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
3269 hsflctl.hsf_ctrl.fldbcount = size - 1;
3270 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_WRITE;
3271 ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
3273 ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
3276 flash_data = (u32)data & 0x00FF;
3278 flash_data = (u32)data;
3280 ew32flash(ICH_FLASH_FDATA0, flash_data);
3282 /* check if FCERR is set to 1 , if set to 1, clear it
3283 * and try the whole sequence a few more times else done
3286 e1000_flash_cycle_ich8lan(hw,
3287 ICH_FLASH_WRITE_COMMAND_TIMEOUT);
3291 /* If we're here, then things are most likely
3292 * completely hosed, but if the error condition
3293 * is detected, it won't hurt to give it another
3294 * try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
3296 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
3297 if (hsfsts.hsf_status.flcerr)
3298 /* Repeat for some time before giving up. */
3300 if (!hsfsts.hsf_status.flcdone) {
3301 e_dbg("Timeout error - flash cycle did not complete.\n");
3304 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
3310 * e1000_write_flash_byte_ich8lan - Write a single byte to NVM
3311 * @hw: pointer to the HW structure
3312 * @offset: The index of the byte to read.
3313 * @data: The byte to write to the NVM.
3315 * Writes a single byte to the NVM using the flash access registers.
3317 static s32 e1000_write_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
3320 u16 word = (u16)data;
3322 return e1000_write_flash_data_ich8lan(hw, offset, 1, word);
3326 * e1000_retry_write_flash_byte_ich8lan - Writes a single byte to NVM
3327 * @hw: pointer to the HW structure
3328 * @offset: The offset of the byte to write.
3329 * @byte: The byte to write to the NVM.
3331 * Writes a single byte to the NVM using the flash access registers.
3332 * Goes through a retry algorithm before giving up.
3334 static s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw,
3335 u32 offset, u8 byte)
3338 u16 program_retries;
3340 ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
3344 for (program_retries = 0; program_retries < 100; program_retries++) {
3345 e_dbg("Retrying Byte %2.2X at offset %u\n", byte, offset);
3346 usleep_range(100, 200);
3347 ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
3351 if (program_retries == 100)
3352 return -E1000_ERR_NVM;
3358 * e1000_erase_flash_bank_ich8lan - Erase a bank (4k) from NVM
3359 * @hw: pointer to the HW structure
3360 * @bank: 0 for first bank, 1 for second bank, etc.
3362 * Erases the bank specified. Each bank is a 4k block. Banks are 0 based.
3363 * bank N is 4096 * N + flash_reg_addr.
3365 static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank)
3367 struct e1000_nvm_info *nvm = &hw->nvm;
3368 union ich8_hws_flash_status hsfsts;
3369 union ich8_hws_flash_ctrl hsflctl;
3370 u32 flash_linear_addr;
3371 /* bank size is in 16bit words - adjust to bytes */
3372 u32 flash_bank_size = nvm->flash_bank_size * 2;
3375 s32 j, iteration, sector_size;
3377 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
3379 /* Determine HW Sector size: Read BERASE bits of hw flash status
3381 * 00: The Hw sector is 256 bytes, hence we need to erase 16
3382 * consecutive sectors. The start index for the nth Hw sector
3383 * can be calculated as = bank * 4096 + n * 256
3384 * 01: The Hw sector is 4K bytes, hence we need to erase 1 sector.
3385 * The start index for the nth Hw sector can be calculated
3387 * 10: The Hw sector is 8K bytes, nth sector = bank * 8192
3388 * (ich9 only, otherwise error condition)
3389 * 11: The Hw sector is 64K bytes, nth sector = bank * 65536
3391 switch (hsfsts.hsf_status.berasesz) {
3393 /* Hw sector size 256 */
3394 sector_size = ICH_FLASH_SEG_SIZE_256;
3395 iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_256;
3398 sector_size = ICH_FLASH_SEG_SIZE_4K;
3402 sector_size = ICH_FLASH_SEG_SIZE_8K;
3406 sector_size = ICH_FLASH_SEG_SIZE_64K;
3410 return -E1000_ERR_NVM;
3413 /* Start with the base address, then add the sector offset. */
3414 flash_linear_addr = hw->nvm.flash_base_addr;
3415 flash_linear_addr += (bank) ? flash_bank_size : 0;
3417 for (j = 0; j < iteration; j++) {
3419 u32 timeout = ICH_FLASH_ERASE_COMMAND_TIMEOUT;
3422 ret_val = e1000_flash_cycle_init_ich8lan(hw);
3426 /* Write a value 11 (block Erase) in Flash
3427 * Cycle field in hw flash control
3429 hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
3430 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_ERASE;
3431 ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
3433 /* Write the last 24 bits of an index within the
3434 * block into Flash Linear address field in Flash
3437 flash_linear_addr += (j * sector_size);
3438 ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
3440 ret_val = e1000_flash_cycle_ich8lan(hw, timeout);
3444 /* Check if FCERR is set to 1. If 1,
3445 * clear it and try the whole sequence
3446 * a few more times else Done
3448 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
3449 if (hsfsts.hsf_status.flcerr)
3450 /* repeat for some time before giving up */
3452 else if (!hsfsts.hsf_status.flcdone)
3454 } while (++count < ICH_FLASH_CYCLE_REPEAT_COUNT);
3461 * e1000_valid_led_default_ich8lan - Set the default LED settings
3462 * @hw: pointer to the HW structure
3463 * @data: Pointer to the LED settings
3465 * Reads the LED default settings from the NVM to data. If the NVM LED
3466 * settings is all 0's or F's, set the LED default to a valid LED default
3469 static s32 e1000_valid_led_default_ich8lan(struct e1000_hw *hw, u16 *data)
3473 ret_val = e1000_read_nvm(hw, NVM_ID_LED_SETTINGS, 1, data);
3475 e_dbg("NVM Read Error\n");
3479 if (*data == ID_LED_RESERVED_0000 || *data == ID_LED_RESERVED_FFFF)
3480 *data = ID_LED_DEFAULT_ICH8LAN;
3486 * e1000_id_led_init_pchlan - store LED configurations
3487 * @hw: pointer to the HW structure
3489 * PCH does not control LEDs via the LEDCTL register, rather it uses
3490 * the PHY LED configuration register.
3492 * PCH also does not have an "always on" or "always off" mode which
3493 * complicates the ID feature. Instead of using the "on" mode to indicate
3494 * in ledctl_mode2 the LEDs to use for ID (see e1000e_id_led_init_generic()),
3495 * use "link_up" mode. The LEDs will still ID on request if there is no
3496 * link based on logic in e1000_led_[on|off]_pchlan().
3498 static s32 e1000_id_led_init_pchlan(struct e1000_hw *hw)
3500 struct e1000_mac_info *mac = &hw->mac;
3502 const u32 ledctl_on = E1000_LEDCTL_MODE_LINK_UP;
3503 const u32 ledctl_off = E1000_LEDCTL_MODE_LINK_UP | E1000_PHY_LED0_IVRT;
3504 u16 data, i, temp, shift;
3506 /* Get default ID LED modes */
3507 ret_val = hw->nvm.ops.valid_led_default(hw, &data);
3511 mac->ledctl_default = er32(LEDCTL);
3512 mac->ledctl_mode1 = mac->ledctl_default;
3513 mac->ledctl_mode2 = mac->ledctl_default;
3515 for (i = 0; i < 4; i++) {
3516 temp = (data >> (i << 2)) & E1000_LEDCTL_LED0_MODE_MASK;
3519 case ID_LED_ON1_DEF2:
3520 case ID_LED_ON1_ON2:
3521 case ID_LED_ON1_OFF2:
3522 mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
3523 mac->ledctl_mode1 |= (ledctl_on << shift);
3525 case ID_LED_OFF1_DEF2:
3526 case ID_LED_OFF1_ON2:
3527 case ID_LED_OFF1_OFF2:
3528 mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
3529 mac->ledctl_mode1 |= (ledctl_off << shift);
3536 case ID_LED_DEF1_ON2:
3537 case ID_LED_ON1_ON2:
3538 case ID_LED_OFF1_ON2:
3539 mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
3540 mac->ledctl_mode2 |= (ledctl_on << shift);
3542 case ID_LED_DEF1_OFF2:
3543 case ID_LED_ON1_OFF2:
3544 case ID_LED_OFF1_OFF2:
3545 mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
3546 mac->ledctl_mode2 |= (ledctl_off << shift);
3558 * e1000_get_bus_info_ich8lan - Get/Set the bus type and width
3559 * @hw: pointer to the HW structure
3561 * ICH8 use the PCI Express bus, but does not contain a PCI Express Capability
3562 * register, so the the bus width is hard coded.
3564 static s32 e1000_get_bus_info_ich8lan(struct e1000_hw *hw)
3566 struct e1000_bus_info *bus = &hw->bus;
3569 ret_val = e1000e_get_bus_info_pcie(hw);
3571 /* ICH devices are "PCI Express"-ish. They have
3572 * a configuration space, but do not contain
3573 * PCI Express Capability registers, so bus width
3574 * must be hardcoded.
3576 if (bus->width == e1000_bus_width_unknown)
3577 bus->width = e1000_bus_width_pcie_x1;
3583 * e1000_reset_hw_ich8lan - Reset the hardware
3584 * @hw: pointer to the HW structure
3586 * Does a full reset of the hardware which includes a reset of the PHY and
3589 static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
3591 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
3596 /* Prevent the PCI-E bus from sticking if there is no TLP connection
3597 * on the last TLP read/write transaction when MAC is reset.
3599 ret_val = e1000e_disable_pcie_master(hw);
3601 e_dbg("PCI-E Master disable polling has failed.\n");
3603 e_dbg("Masking off all interrupts\n");
3604 ew32(IMC, 0xffffffff);
3606 /* Disable the Transmit and Receive units. Then delay to allow
3607 * any pending transactions to complete before we hit the MAC
3608 * with the global reset.
3611 ew32(TCTL, E1000_TCTL_PSP);
3614 usleep_range(10000, 20000);
3616 /* Workaround for ICH8 bit corruption issue in FIFO memory */
3617 if (hw->mac.type == e1000_ich8lan) {
3618 /* Set Tx and Rx buffer allocation to 8k apiece. */
3619 ew32(PBA, E1000_PBA_8K);
3620 /* Set Packet Buffer Size to 16k. */
3621 ew32(PBS, E1000_PBS_16K);
3624 if (hw->mac.type == e1000_pchlan) {
3625 /* Save the NVM K1 bit setting */
3626 ret_val = e1000_read_nvm(hw, E1000_NVM_K1_CONFIG, 1, &kum_cfg);
3630 if (kum_cfg & E1000_NVM_K1_ENABLE)
3631 dev_spec->nvm_k1_enabled = true;
3633 dev_spec->nvm_k1_enabled = false;
3638 if (!hw->phy.ops.check_reset_block(hw)) {
3639 /* Full-chip reset requires MAC and PHY reset at the same
3640 * time to make sure the interface between MAC and the
3641 * external PHY is reset.
3643 ctrl |= E1000_CTRL_PHY_RST;
3645 /* Gate automatic PHY configuration by hardware on
3648 if ((hw->mac.type == e1000_pch2lan) &&
3649 !(er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
3650 e1000_gate_hw_phy_config_ich8lan(hw, true);
3652 ret_val = e1000_acquire_swflag_ich8lan(hw);
3653 e_dbg("Issuing a global reset to ich8lan\n");
3654 ew32(CTRL, (ctrl | E1000_CTRL_RST));
3655 /* cannot issue a flush here because it hangs the hardware */
3658 /* Set Phy Config Counter to 50msec */
3659 if (hw->mac.type == e1000_pch2lan) {
3660 reg = er32(FEXTNVM3);
3661 reg &= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK;
3662 reg |= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC;
3663 ew32(FEXTNVM3, reg);
3667 clear_bit(__E1000_ACCESS_SHARED_RESOURCE, &hw->adapter->state);
3669 if (ctrl & E1000_CTRL_PHY_RST) {
3670 ret_val = hw->phy.ops.get_cfg_done(hw);
3674 ret_val = e1000_post_phy_reset_ich8lan(hw);
3679 /* For PCH, this write will make sure that any noise
3680 * will be detected as a CRC error and be dropped rather than show up
3681 * as a bad packet to the DMA engine.
3683 if (hw->mac.type == e1000_pchlan)
3684 ew32(CRC_OFFSET, 0x65656565);
3686 ew32(IMC, 0xffffffff);
3689 reg = er32(KABGTXD);
3690 reg |= E1000_KABGTXD_BGSQLBIAS;
3697 * e1000_init_hw_ich8lan - Initialize the hardware
3698 * @hw: pointer to the HW structure
3700 * Prepares the hardware for transmit and receive by doing the following:
3701 * - initialize hardware bits
3702 * - initialize LED identification
3703 * - setup receive address registers
3704 * - setup flow control
3705 * - setup transmit descriptors
3706 * - clear statistics
3708 static s32 e1000_init_hw_ich8lan(struct e1000_hw *hw)
3710 struct e1000_mac_info *mac = &hw->mac;
3711 u32 ctrl_ext, txdctl, snoop;
3715 e1000_initialize_hw_bits_ich8lan(hw);
3717 /* Initialize identification LED */
3718 ret_val = mac->ops.id_led_init(hw);
3719 /* An error is not fatal and we should not stop init due to this */
3721 e_dbg("Error initializing identification LED\n");
3723 /* Setup the receive address. */
3724 e1000e_init_rx_addrs(hw, mac->rar_entry_count);
3726 /* Zero out the Multicast HASH table */
3727 e_dbg("Zeroing the MTA\n");
3728 for (i = 0; i < mac->mta_reg_count; i++)
3729 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
3731 /* The 82578 Rx buffer will stall if wakeup is enabled in host and
3732 * the ME. Disable wakeup by clearing the host wakeup bit.
3733 * Reset the phy after disabling host wakeup to reset the Rx buffer.
3735 if (hw->phy.type == e1000_phy_82578) {
3736 e1e_rphy(hw, BM_PORT_GEN_CFG, &i);
3737 i &= ~BM_WUC_HOST_WU_BIT;
3738 e1e_wphy(hw, BM_PORT_GEN_CFG, i);
3739 ret_val = e1000_phy_hw_reset_ich8lan(hw);
3744 /* Setup link and flow control */
3745 ret_val = mac->ops.setup_link(hw);
3747 /* Set the transmit descriptor write-back policy for both queues */
3748 txdctl = er32(TXDCTL(0));
3749 txdctl = ((txdctl & ~E1000_TXDCTL_WTHRESH) |
3750 E1000_TXDCTL_FULL_TX_DESC_WB);
3751 txdctl = ((txdctl & ~E1000_TXDCTL_PTHRESH) |
3752 E1000_TXDCTL_MAX_TX_DESC_PREFETCH);
3753 ew32(TXDCTL(0), txdctl);
3754 txdctl = er32(TXDCTL(1));
3755 txdctl = ((txdctl & ~E1000_TXDCTL_WTHRESH) |
3756 E1000_TXDCTL_FULL_TX_DESC_WB);
3757 txdctl = ((txdctl & ~E1000_TXDCTL_PTHRESH) |
3758 E1000_TXDCTL_MAX_TX_DESC_PREFETCH);
3759 ew32(TXDCTL(1), txdctl);
3761 /* ICH8 has opposite polarity of no_snoop bits.
3762 * By default, we should use snoop behavior.
3764 if (mac->type == e1000_ich8lan)
3765 snoop = PCIE_ICH8_SNOOP_ALL;
3767 snoop = (u32)~(PCIE_NO_SNOOP_ALL);
3768 e1000e_set_pcie_no_snoop(hw, snoop);
3770 ctrl_ext = er32(CTRL_EXT);
3771 ctrl_ext |= E1000_CTRL_EXT_RO_DIS;
3772 ew32(CTRL_EXT, ctrl_ext);
3774 /* Clear all of the statistics registers (clear on read). It is
3775 * important that we do this after we have tried to establish link
3776 * because the symbol error count will increment wildly if there
3779 e1000_clear_hw_cntrs_ich8lan(hw);
3785 * e1000_initialize_hw_bits_ich8lan - Initialize required hardware bits
3786 * @hw: pointer to the HW structure
3788 * Sets/Clears required hardware bits necessary for correctly setting up the
3789 * hardware for transmit and receive.
3791 static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw)
3795 /* Extended Device Control */
3796 reg = er32(CTRL_EXT);
3798 /* Enable PHY low-power state when MAC is at D3 w/o WoL */
3799 if (hw->mac.type >= e1000_pchlan)
3800 reg |= E1000_CTRL_EXT_PHYPDEN;
3801 ew32(CTRL_EXT, reg);
3803 /* Transmit Descriptor Control 0 */
3804 reg = er32(TXDCTL(0));
3806 ew32(TXDCTL(0), reg);
3808 /* Transmit Descriptor Control 1 */
3809 reg = er32(TXDCTL(1));
3811 ew32(TXDCTL(1), reg);
3813 /* Transmit Arbitration Control 0 */
3814 reg = er32(TARC(0));
3815 if (hw->mac.type == e1000_ich8lan)
3816 reg |= (1 << 28) | (1 << 29);
3817 reg |= (1 << 23) | (1 << 24) | (1 << 26) | (1 << 27);
3820 /* Transmit Arbitration Control 1 */
3821 reg = er32(TARC(1));
3822 if (er32(TCTL) & E1000_TCTL_MULR)
3826 reg |= (1 << 24) | (1 << 26) | (1 << 30);
3830 if (hw->mac.type == e1000_ich8lan) {
3836 /* work-around descriptor data corruption issue during nfs v2 udp
3837 * traffic, just disable the nfs filtering capability
3840 reg |= (E1000_RFCTL_NFSW_DIS | E1000_RFCTL_NFSR_DIS);
3842 /* Disable IPv6 extension header parsing because some malformed
3843 * IPv6 headers can hang the Rx.
3845 if (hw->mac.type == e1000_ich8lan)
3846 reg |= (E1000_RFCTL_IPV6_EX_DIS | E1000_RFCTL_NEW_IPV6_EXT_DIS);
3849 /* Enable ECC on Lynxpoint */
3850 if (hw->mac.type == e1000_pch_lpt) {
3851 reg = er32(PBECCSTS);
3852 reg |= E1000_PBECCSTS_ECC_ENABLE;
3853 ew32(PBECCSTS, reg);
3856 reg |= E1000_CTRL_MEHE;
3862 * e1000_setup_link_ich8lan - Setup flow control and link settings
3863 * @hw: pointer to the HW structure
3865 * Determines which flow control settings to use, then configures flow
3866 * control. Calls the appropriate media-specific link configuration
3867 * function. Assuming the adapter has a valid link partner, a valid link
3868 * should be established. Assumes the hardware has previously been reset
3869 * and the transmitter and receiver are not enabled.
3871 static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw)
3875 if (hw->phy.ops.check_reset_block(hw))
3878 /* ICH parts do not have a word in the NVM to determine
3879 * the default flow control setting, so we explicitly
3882 if (hw->fc.requested_mode == e1000_fc_default) {
3883 /* Workaround h/w hang when Tx flow control enabled */
3884 if (hw->mac.type == e1000_pchlan)
3885 hw->fc.requested_mode = e1000_fc_rx_pause;
3887 hw->fc.requested_mode = e1000_fc_full;
3890 /* Save off the requested flow control mode for use later. Depending
3891 * on the link partner's capabilities, we may or may not use this mode.
3893 hw->fc.current_mode = hw->fc.requested_mode;
3895 e_dbg("After fix-ups FlowControl is now = %x\n", hw->fc.current_mode);
3897 /* Continue to configure the copper link. */
3898 ret_val = hw->mac.ops.setup_physical_interface(hw);
3902 ew32(FCTTV, hw->fc.pause_time);
3903 if ((hw->phy.type == e1000_phy_82578) ||
3904 (hw->phy.type == e1000_phy_82579) ||
3905 (hw->phy.type == e1000_phy_i217) ||
3906 (hw->phy.type == e1000_phy_82577)) {
3907 ew32(FCRTV_PCH, hw->fc.refresh_time);
3909 ret_val = e1e_wphy(hw, PHY_REG(BM_PORT_CTRL_PAGE, 27),
3915 return e1000e_set_fc_watermarks(hw);
3919 * e1000_setup_copper_link_ich8lan - Configure MAC/PHY interface
3920 * @hw: pointer to the HW structure
3922 * Configures the kumeran interface to the PHY to wait the appropriate time
3923 * when polling the PHY, then call the generic setup_copper_link to finish
3924 * configuring the copper link.
3926 static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw)
3933 ctrl |= E1000_CTRL_SLU;
3934 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
3937 /* Set the mac to wait the maximum time between each iteration
3938 * and increase the max iterations when polling the phy;
3939 * this fixes erroneous timeouts at 10Mbps.
3941 ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_TIMEOUTS, 0xFFFF);
3944 ret_val = e1000e_read_kmrn_reg(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
3949 ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
3954 switch (hw->phy.type) {
3955 case e1000_phy_igp_3:
3956 ret_val = e1000e_copper_link_setup_igp(hw);
3961 case e1000_phy_82578:
3962 ret_val = e1000e_copper_link_setup_m88(hw);
3966 case e1000_phy_82577:
3967 case e1000_phy_82579:
3968 ret_val = e1000_copper_link_setup_82577(hw);
3973 ret_val = e1e_rphy(hw, IFE_PHY_MDIX_CONTROL, ®_data);
3977 reg_data &= ~IFE_PMC_AUTO_MDIX;
3979 switch (hw->phy.mdix) {
3981 reg_data &= ~IFE_PMC_FORCE_MDIX;
3984 reg_data |= IFE_PMC_FORCE_MDIX;
3988 reg_data |= IFE_PMC_AUTO_MDIX;
3991 ret_val = e1e_wphy(hw, IFE_PHY_MDIX_CONTROL, reg_data);
3999 return e1000e_setup_copper_link(hw);
4003 * e1000_setup_copper_link_pch_lpt - Configure MAC/PHY interface
4004 * @hw: pointer to the HW structure
4006 * Calls the PHY specific link setup function and then calls the
4007 * generic setup_copper_link to finish configuring the link for
4008 * Lynxpoint PCH devices
4010 static s32 e1000_setup_copper_link_pch_lpt(struct e1000_hw *hw)
4016 ctrl |= E1000_CTRL_SLU;
4017 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
4020 ret_val = e1000_copper_link_setup_82577(hw);
4024 return e1000e_setup_copper_link(hw);
4028 * e1000_get_link_up_info_ich8lan - Get current link speed and duplex
4029 * @hw: pointer to the HW structure
4030 * @speed: pointer to store current link speed
4031 * @duplex: pointer to store the current link duplex
4033 * Calls the generic get_speed_and_duplex to retrieve the current link
4034 * information and then calls the Kumeran lock loss workaround for links at
4037 static s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw, u16 *speed,
4042 ret_val = e1000e_get_speed_and_duplex_copper(hw, speed, duplex);
4046 if ((hw->mac.type == e1000_ich8lan) &&
4047 (hw->phy.type == e1000_phy_igp_3) && (*speed == SPEED_1000)) {
4048 ret_val = e1000_kmrn_lock_loss_workaround_ich8lan(hw);
4055 * e1000_kmrn_lock_loss_workaround_ich8lan - Kumeran workaround
4056 * @hw: pointer to the HW structure
4058 * Work-around for 82566 Kumeran PCS lock loss:
4059 * On link status change (i.e. PCI reset, speed change) and link is up and
4061 * 0) if workaround is optionally disabled do nothing
4062 * 1) wait 1ms for Kumeran link to come up
4063 * 2) check Kumeran Diagnostic register PCS lock loss bit
4064 * 3) if not set the link is locked (all is good), otherwise...
4066 * 5) repeat up to 10 times
4067 * Note: this is only called for IGP3 copper when speed is 1gb.
4069 static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw)
4071 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
4077 if (!dev_spec->kmrn_lock_loss_workaround_enabled)
4080 /* Make sure link is up before proceeding. If not just return.
4081 * Attempting this while link is negotiating fouled up link
4084 ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link);
4088 for (i = 0; i < 10; i++) {
4089 /* read once to clear */
4090 ret_val = e1e_rphy(hw, IGP3_KMRN_DIAG, &data);
4093 /* and again to get new status */
4094 ret_val = e1e_rphy(hw, IGP3_KMRN_DIAG, &data);
4098 /* check for PCS lock */
4099 if (!(data & IGP3_KMRN_DIAG_PCS_LOCK_LOSS))
4102 /* Issue PHY reset */
4103 e1000_phy_hw_reset(hw);
4106 /* Disable GigE link negotiation */
4107 phy_ctrl = er32(PHY_CTRL);
4108 phy_ctrl |= (E1000_PHY_CTRL_GBE_DISABLE |
4109 E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
4110 ew32(PHY_CTRL, phy_ctrl);
4112 /* Call gig speed drop workaround on Gig disable before accessing
4115 e1000e_gig_downshift_workaround_ich8lan(hw);
4117 /* unable to acquire PCS lock */
4118 return -E1000_ERR_PHY;
4122 * e1000e_set_kmrn_lock_loss_workaround_ich8lan - Set Kumeran workaround state
4123 * @hw: pointer to the HW structure
4124 * @state: boolean value used to set the current Kumeran workaround state
4126 * If ICH8, set the current Kumeran workaround state (enabled - true
4127 * /disabled - false).
4129 void e1000e_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw,
4132 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
4134 if (hw->mac.type != e1000_ich8lan) {
4135 e_dbg("Workaround applies to ICH8 only.\n");
4139 dev_spec->kmrn_lock_loss_workaround_enabled = state;
4143 * e1000_ipg3_phy_powerdown_workaround_ich8lan - Power down workaround on D3
4144 * @hw: pointer to the HW structure
4146 * Workaround for 82566 power-down on D3 entry:
4147 * 1) disable gigabit link
4148 * 2) write VR power-down enable
4150 * Continue if successful, else issue LCD reset and repeat
4152 void e1000e_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw)
4158 if (hw->phy.type != e1000_phy_igp_3)
4161 /* Try the workaround twice (if needed) */
4164 reg = er32(PHY_CTRL);
4165 reg |= (E1000_PHY_CTRL_GBE_DISABLE |
4166 E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
4167 ew32(PHY_CTRL, reg);
4169 /* Call gig speed drop workaround on Gig disable before
4170 * accessing any PHY registers
4172 if (hw->mac.type == e1000_ich8lan)
4173 e1000e_gig_downshift_workaround_ich8lan(hw);
4175 /* Write VR power-down enable */
4176 e1e_rphy(hw, IGP3_VR_CTRL, &data);
4177 data &= ~IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
4178 e1e_wphy(hw, IGP3_VR_CTRL, data | IGP3_VR_CTRL_MODE_SHUTDOWN);
4180 /* Read it back and test */
4181 e1e_rphy(hw, IGP3_VR_CTRL, &data);
4182 data &= IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
4183 if ((data == IGP3_VR_CTRL_MODE_SHUTDOWN) || retry)
4186 /* Issue PHY reset and repeat at most one more time */
4188 ew32(CTRL, reg | E1000_CTRL_PHY_RST);
4194 * e1000e_gig_downshift_workaround_ich8lan - WoL from S5 stops working
4195 * @hw: pointer to the HW structure
4197 * Steps to take when dropping from 1Gb/s (eg. link cable removal (LSC),
4198 * LPLU, Gig disable, MDIC PHY reset):
4199 * 1) Set Kumeran Near-end loopback
4200 * 2) Clear Kumeran Near-end loopback
4201 * Should only be called for ICH8[m] devices with any 1G Phy.
4203 void e1000e_gig_downshift_workaround_ich8lan(struct e1000_hw *hw)
4208 if ((hw->mac.type != e1000_ich8lan) || (hw->phy.type == e1000_phy_ife))
4211 ret_val = e1000e_read_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
4215 reg_data |= E1000_KMRNCTRLSTA_DIAG_NELPBK;
4216 ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
4220 reg_data &= ~E1000_KMRNCTRLSTA_DIAG_NELPBK;
4221 e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET, reg_data);
4225 * e1000_suspend_workarounds_ich8lan - workarounds needed during S0->Sx
4226 * @hw: pointer to the HW structure
4228 * During S0 to Sx transition, it is possible the link remains at gig
4229 * instead of negotiating to a lower speed. Before going to Sx, set
4230 * 'Gig Disable' to force link speed negotiation to a lower speed based on
4231 * the LPLU setting in the NVM or custom setting. For PCH and newer parts,
4232 * the OEM bits PHY register (LED, GbE disable and LPLU configurations) also
4233 * needs to be written.
4234 * Parts that support (and are linked to a partner which support) EEE in
4235 * 100Mbps should disable LPLU since 100Mbps w/ EEE requires less power
4236 * than 10Mbps w/o EEE.
4238 void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw)
4240 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
4244 phy_ctrl = er32(PHY_CTRL);
4245 phy_ctrl |= E1000_PHY_CTRL_GBE_DISABLE;
4247 if (hw->phy.type == e1000_phy_i217) {
4248 u16 phy_reg, device_id = hw->adapter->pdev->device;
4250 if ((device_id == E1000_DEV_ID_PCH_LPTLP_I218_LM) ||
4251 (device_id == E1000_DEV_ID_PCH_LPTLP_I218_V) ||
4252 (device_id == E1000_DEV_ID_PCH_I218_LM3) ||
4253 (device_id == E1000_DEV_ID_PCH_I218_V3)) {
4254 u32 fextnvm6 = er32(FEXTNVM6);
4256 ew32(FEXTNVM6, fextnvm6 & ~E1000_FEXTNVM6_REQ_PLL_CLK);
4259 ret_val = hw->phy.ops.acquire(hw);
4263 if (!dev_spec->eee_disable) {
4267 e1000_read_emi_reg_locked(hw,
4268 I217_EEE_ADVERTISEMENT,
4273 /* Disable LPLU if both link partners support 100BaseT
4274 * EEE and 100Full is advertised on both ends of the
4277 if ((eee_advert & I82579_EEE_100_SUPPORTED) &&
4278 (dev_spec->eee_lp_ability &
4279 I82579_EEE_100_SUPPORTED) &&
4280 (hw->phy.autoneg_advertised & ADVERTISE_100_FULL))
4281 phy_ctrl &= ~(E1000_PHY_CTRL_D0A_LPLU |
4282 E1000_PHY_CTRL_NOND0A_LPLU);
4285 /* For i217 Intel Rapid Start Technology support,
4286 * when the system is going into Sx and no manageability engine
4287 * is present, the driver must configure proxy to reset only on
4288 * power good. LPI (Low Power Idle) state must also reset only
4289 * on power good, as well as the MTA (Multicast table array).
4290 * The SMBus release must also be disabled on LCD reset.
4292 if (!(er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) {
4293 /* Enable proxy to reset only on power good. */
4294 e1e_rphy_locked(hw, I217_PROXY_CTRL, &phy_reg);
4295 phy_reg |= I217_PROXY_CTRL_AUTO_DISABLE;
4296 e1e_wphy_locked(hw, I217_PROXY_CTRL, phy_reg);
4298 /* Set bit enable LPI (EEE) to reset only on
4301 e1e_rphy_locked(hw, I217_SxCTRL, &phy_reg);
4302 phy_reg |= I217_SxCTRL_ENABLE_LPI_RESET;
4303 e1e_wphy_locked(hw, I217_SxCTRL, phy_reg);
4305 /* Disable the SMB release on LCD reset. */
4306 e1e_rphy_locked(hw, I217_MEMPWR, &phy_reg);
4307 phy_reg &= ~I217_MEMPWR_DISABLE_SMB_RELEASE;
4308 e1e_wphy_locked(hw, I217_MEMPWR, phy_reg);
4311 /* Enable MTA to reset for Intel Rapid Start Technology
4314 e1e_rphy_locked(hw, I217_CGFREG, &phy_reg);
4315 phy_reg |= I217_CGFREG_ENABLE_MTA_RESET;
4316 e1e_wphy_locked(hw, I217_CGFREG, phy_reg);
4319 hw->phy.ops.release(hw);
4322 ew32(PHY_CTRL, phy_ctrl);
4324 if (hw->mac.type == e1000_ich8lan)
4325 e1000e_gig_downshift_workaround_ich8lan(hw);
4327 if (hw->mac.type >= e1000_pchlan) {
4328 e1000_oem_bits_config_ich8lan(hw, false);
4330 /* Reset PHY to activate OEM bits on 82577/8 */
4331 if (hw->mac.type == e1000_pchlan)
4332 e1000e_phy_hw_reset_generic(hw);
4334 ret_val = hw->phy.ops.acquire(hw);
4337 e1000_write_smbus_addr(hw);
4338 hw->phy.ops.release(hw);
4343 * e1000_resume_workarounds_pchlan - workarounds needed during Sx->S0
4344 * @hw: pointer to the HW structure
4346 * During Sx to S0 transitions on non-managed devices or managed devices
4347 * on which PHY resets are not blocked, if the PHY registers cannot be
4348 * accessed properly by the s/w toggle the LANPHYPC value to power cycle
4350 * On i217, setup Intel Rapid Start Technology.
4352 void e1000_resume_workarounds_pchlan(struct e1000_hw *hw)
4356 if (hw->mac.type < e1000_pch2lan)
4359 ret_val = e1000_init_phy_workarounds_pchlan(hw);
4361 e_dbg("Failed to init PHY flow ret_val=%d\n", ret_val);
4365 /* For i217 Intel Rapid Start Technology support when the system
4366 * is transitioning from Sx and no manageability engine is present
4367 * configure SMBus to restore on reset, disable proxy, and enable
4368 * the reset on MTA (Multicast table array).
4370 if (hw->phy.type == e1000_phy_i217) {
4373 ret_val = hw->phy.ops.acquire(hw);
4375 e_dbg("Failed to setup iRST\n");
4379 if (!(er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) {
4380 /* Restore clear on SMB if no manageability engine
4383 ret_val = e1e_rphy_locked(hw, I217_MEMPWR, &phy_reg);
4386 phy_reg |= I217_MEMPWR_DISABLE_SMB_RELEASE;
4387 e1e_wphy_locked(hw, I217_MEMPWR, phy_reg);
4390 e1e_wphy_locked(hw, I217_PROXY_CTRL, 0);
4392 /* Enable reset on MTA */
4393 ret_val = e1e_rphy_locked(hw, I217_CGFREG, &phy_reg);
4396 phy_reg &= ~I217_CGFREG_ENABLE_MTA_RESET;
4397 e1e_wphy_locked(hw, I217_CGFREG, phy_reg);
4400 e_dbg("Error %d in resume workarounds\n", ret_val);
4401 hw->phy.ops.release(hw);
4406 * e1000_cleanup_led_ich8lan - Restore the default LED operation
4407 * @hw: pointer to the HW structure
4409 * Return the LED back to the default configuration.
4411 static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw)
4413 if (hw->phy.type == e1000_phy_ife)
4414 return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED, 0);
4416 ew32(LEDCTL, hw->mac.ledctl_default);
4421 * e1000_led_on_ich8lan - Turn LEDs on
4422 * @hw: pointer to the HW structure
4426 static s32 e1000_led_on_ich8lan(struct e1000_hw *hw)
4428 if (hw->phy.type == e1000_phy_ife)
4429 return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED,
4430 (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_ON));
4432 ew32(LEDCTL, hw->mac.ledctl_mode2);
4437 * e1000_led_off_ich8lan - Turn LEDs off
4438 * @hw: pointer to the HW structure
4440 * Turn off the LEDs.
4442 static s32 e1000_led_off_ich8lan(struct e1000_hw *hw)
4444 if (hw->phy.type == e1000_phy_ife)
4445 return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED,
4446 (IFE_PSCL_PROBE_MODE |
4447 IFE_PSCL_PROBE_LEDS_OFF));
4449 ew32(LEDCTL, hw->mac.ledctl_mode1);
4454 * e1000_setup_led_pchlan - Configures SW controllable LED
4455 * @hw: pointer to the HW structure
4457 * This prepares the SW controllable LED for use.
4459 static s32 e1000_setup_led_pchlan(struct e1000_hw *hw)
4461 return e1e_wphy(hw, HV_LED_CONFIG, (u16)hw->mac.ledctl_mode1);
4465 * e1000_cleanup_led_pchlan - Restore the default LED operation
4466 * @hw: pointer to the HW structure
4468 * Return the LED back to the default configuration.
4470 static s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw)
4472 return e1e_wphy(hw, HV_LED_CONFIG, (u16)hw->mac.ledctl_default);
4476 * e1000_led_on_pchlan - Turn LEDs on
4477 * @hw: pointer to the HW structure
4481 static s32 e1000_led_on_pchlan(struct e1000_hw *hw)
4483 u16 data = (u16)hw->mac.ledctl_mode2;
4486 /* If no link, then turn LED on by setting the invert bit
4487 * for each LED that's mode is "link_up" in ledctl_mode2.
4489 if (!(er32(STATUS) & E1000_STATUS_LU)) {
4490 for (i = 0; i < 3; i++) {
4491 led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
4492 if ((led & E1000_PHY_LED0_MODE_MASK) !=
4493 E1000_LEDCTL_MODE_LINK_UP)
4495 if (led & E1000_PHY_LED0_IVRT)
4496 data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
4498 data |= (E1000_PHY_LED0_IVRT << (i * 5));
4502 return e1e_wphy(hw, HV_LED_CONFIG, data);
4506 * e1000_led_off_pchlan - Turn LEDs off
4507 * @hw: pointer to the HW structure
4509 * Turn off the LEDs.
4511 static s32 e1000_led_off_pchlan(struct e1000_hw *hw)
4513 u16 data = (u16)hw->mac.ledctl_mode1;
4516 /* If no link, then turn LED off by clearing the invert bit
4517 * for each LED that's mode is "link_up" in ledctl_mode1.
4519 if (!(er32(STATUS) & E1000_STATUS_LU)) {
4520 for (i = 0; i < 3; i++) {
4521 led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
4522 if ((led & E1000_PHY_LED0_MODE_MASK) !=
4523 E1000_LEDCTL_MODE_LINK_UP)
4525 if (led & E1000_PHY_LED0_IVRT)
4526 data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
4528 data |= (E1000_PHY_LED0_IVRT << (i * 5));
4532 return e1e_wphy(hw, HV_LED_CONFIG, data);
4536 * e1000_get_cfg_done_ich8lan - Read config done bit after Full or PHY reset
4537 * @hw: pointer to the HW structure
4539 * Read appropriate register for the config done bit for completion status
4540 * and configure the PHY through s/w for EEPROM-less parts.
4542 * NOTE: some silicon which is EEPROM-less will fail trying to read the
4543 * config done bit, so only an error is logged and continues. If we were
4544 * to return with error, EEPROM-less silicon would not be able to be reset
4547 static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw)
4553 e1000e_get_cfg_done_generic(hw);
4555 /* Wait for indication from h/w that it has completed basic config */
4556 if (hw->mac.type >= e1000_ich10lan) {
4557 e1000_lan_init_done_ich8lan(hw);
4559 ret_val = e1000e_get_auto_rd_done(hw);
4561 /* When auto config read does not complete, do not
4562 * return with an error. This can happen in situations
4563 * where there is no eeprom and prevents getting link.
4565 e_dbg("Auto Read Done did not complete\n");
4570 /* Clear PHY Reset Asserted bit */
4571 status = er32(STATUS);
4572 if (status & E1000_STATUS_PHYRA)
4573 ew32(STATUS, status & ~E1000_STATUS_PHYRA);
4575 e_dbg("PHY Reset Asserted not set - needs delay\n");
4577 /* If EEPROM is not marked present, init the IGP 3 PHY manually */
4578 if (hw->mac.type <= e1000_ich9lan) {
4579 if (!(er32(EECD) & E1000_EECD_PRES) &&
4580 (hw->phy.type == e1000_phy_igp_3)) {
4581 e1000e_phy_init_script_igp3(hw);
4584 if (e1000_valid_nvm_bank_detect_ich8lan(hw, &bank)) {
4585 /* Maybe we should do a basic PHY config */
4586 e_dbg("EEPROM not present\n");
4587 ret_val = -E1000_ERR_CONFIG;
4595 * e1000_power_down_phy_copper_ich8lan - Remove link during PHY power down
4596 * @hw: pointer to the HW structure
4598 * In the case of a PHY power down to save power, or to turn off link during a
4599 * driver unload, or wake on lan is not enabled, remove the link.
4601 static void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw)
4603 /* If the management interface is not enabled, then power down */
4604 if (!(hw->mac.ops.check_mng_mode(hw) ||
4605 hw->phy.ops.check_reset_block(hw)))
4606 e1000_power_down_phy_copper(hw);
4610 * e1000_clear_hw_cntrs_ich8lan - Clear statistical counters
4611 * @hw: pointer to the HW structure
4613 * Clears hardware counters specific to the silicon family and calls
4614 * clear_hw_cntrs_generic to clear all general purpose counters.
4616 static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw)
4621 e1000e_clear_hw_cntrs_base(hw);
4637 /* Clear PHY statistics registers */
4638 if ((hw->phy.type == e1000_phy_82578) ||
4639 (hw->phy.type == e1000_phy_82579) ||
4640 (hw->phy.type == e1000_phy_i217) ||
4641 (hw->phy.type == e1000_phy_82577)) {
4642 ret_val = hw->phy.ops.acquire(hw);
4645 ret_val = hw->phy.ops.set_page(hw,
4646 HV_STATS_PAGE << IGP_PAGE_SHIFT);
4649 hw->phy.ops.read_reg_page(hw, HV_SCC_UPPER, &phy_data);
4650 hw->phy.ops.read_reg_page(hw, HV_SCC_LOWER, &phy_data);
4651 hw->phy.ops.read_reg_page(hw, HV_ECOL_UPPER, &phy_data);
4652 hw->phy.ops.read_reg_page(hw, HV_ECOL_LOWER, &phy_data);
4653 hw->phy.ops.read_reg_page(hw, HV_MCC_UPPER, &phy_data);
4654 hw->phy.ops.read_reg_page(hw, HV_MCC_LOWER, &phy_data);
4655 hw->phy.ops.read_reg_page(hw, HV_LATECOL_UPPER, &phy_data);
4656 hw->phy.ops.read_reg_page(hw, HV_LATECOL_LOWER, &phy_data);
4657 hw->phy.ops.read_reg_page(hw, HV_COLC_UPPER, &phy_data);
4658 hw->phy.ops.read_reg_page(hw, HV_COLC_LOWER, &phy_data);
4659 hw->phy.ops.read_reg_page(hw, HV_DC_UPPER, &phy_data);
4660 hw->phy.ops.read_reg_page(hw, HV_DC_LOWER, &phy_data);
4661 hw->phy.ops.read_reg_page(hw, HV_TNCRS_UPPER, &phy_data);
4662 hw->phy.ops.read_reg_page(hw, HV_TNCRS_LOWER, &phy_data);
4664 hw->phy.ops.release(hw);
4668 static const struct e1000_mac_operations ich8_mac_ops = {
4669 /* check_mng_mode dependent on mac type */
4670 .check_for_link = e1000_check_for_copper_link_ich8lan,
4671 /* cleanup_led dependent on mac type */
4672 .clear_hw_cntrs = e1000_clear_hw_cntrs_ich8lan,
4673 .get_bus_info = e1000_get_bus_info_ich8lan,
4674 .set_lan_id = e1000_set_lan_id_single_port,
4675 .get_link_up_info = e1000_get_link_up_info_ich8lan,
4676 /* led_on dependent on mac type */
4677 /* led_off dependent on mac type */
4678 .update_mc_addr_list = e1000e_update_mc_addr_list_generic,
4679 .reset_hw = e1000_reset_hw_ich8lan,
4680 .init_hw = e1000_init_hw_ich8lan,
4681 .setup_link = e1000_setup_link_ich8lan,
4682 .setup_physical_interface = e1000_setup_copper_link_ich8lan,
4683 /* id_led_init dependent on mac type */
4684 .config_collision_dist = e1000e_config_collision_dist_generic,
4685 .rar_set = e1000e_rar_set_generic,
4688 static const struct e1000_phy_operations ich8_phy_ops = {
4689 .acquire = e1000_acquire_swflag_ich8lan,
4690 .check_reset_block = e1000_check_reset_block_ich8lan,
4692 .get_cfg_done = e1000_get_cfg_done_ich8lan,
4693 .get_cable_length = e1000e_get_cable_length_igp_2,
4694 .read_reg = e1000e_read_phy_reg_igp,
4695 .release = e1000_release_swflag_ich8lan,
4696 .reset = e1000_phy_hw_reset_ich8lan,
4697 .set_d0_lplu_state = e1000_set_d0_lplu_state_ich8lan,
4698 .set_d3_lplu_state = e1000_set_d3_lplu_state_ich8lan,
4699 .write_reg = e1000e_write_phy_reg_igp,
4702 static const struct e1000_nvm_operations ich8_nvm_ops = {
4703 .acquire = e1000_acquire_nvm_ich8lan,
4704 .read = e1000_read_nvm_ich8lan,
4705 .release = e1000_release_nvm_ich8lan,
4706 .reload = e1000e_reload_nvm_generic,
4707 .update = e1000_update_nvm_checksum_ich8lan,
4708 .valid_led_default = e1000_valid_led_default_ich8lan,
4709 .validate = e1000_validate_nvm_checksum_ich8lan,
4710 .write = e1000_write_nvm_ich8lan,
4713 const struct e1000_info e1000_ich8_info = {
4714 .mac = e1000_ich8lan,
4715 .flags = FLAG_HAS_WOL
4717 | FLAG_HAS_CTRLEXT_ON_LOAD
4722 .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN,
4723 .get_variants = e1000_get_variants_ich8lan,
4724 .mac_ops = &ich8_mac_ops,
4725 .phy_ops = &ich8_phy_ops,
4726 .nvm_ops = &ich8_nvm_ops,
4729 const struct e1000_info e1000_ich9_info = {
4730 .mac = e1000_ich9lan,
4731 .flags = FLAG_HAS_JUMBO_FRAMES
4734 | FLAG_HAS_CTRLEXT_ON_LOAD
4739 .max_hw_frame_size = DEFAULT_JUMBO,
4740 .get_variants = e1000_get_variants_ich8lan,
4741 .mac_ops = &ich8_mac_ops,
4742 .phy_ops = &ich8_phy_ops,
4743 .nvm_ops = &ich8_nvm_ops,
4746 const struct e1000_info e1000_ich10_info = {
4747 .mac = e1000_ich10lan,
4748 .flags = FLAG_HAS_JUMBO_FRAMES
4751 | FLAG_HAS_CTRLEXT_ON_LOAD
4756 .max_hw_frame_size = DEFAULT_JUMBO,
4757 .get_variants = e1000_get_variants_ich8lan,
4758 .mac_ops = &ich8_mac_ops,
4759 .phy_ops = &ich8_phy_ops,
4760 .nvm_ops = &ich8_nvm_ops,
4763 const struct e1000_info e1000_pch_info = {
4764 .mac = e1000_pchlan,
4765 .flags = FLAG_IS_ICH
4767 | FLAG_HAS_CTRLEXT_ON_LOAD
4770 | FLAG_HAS_JUMBO_FRAMES
4771 | FLAG_DISABLE_FC_PAUSE_TIME /* errata */
4773 .flags2 = FLAG2_HAS_PHY_STATS,
4775 .max_hw_frame_size = 4096,
4776 .get_variants = e1000_get_variants_ich8lan,
4777 .mac_ops = &ich8_mac_ops,
4778 .phy_ops = &ich8_phy_ops,
4779 .nvm_ops = &ich8_nvm_ops,
4782 const struct e1000_info e1000_pch2_info = {
4783 .mac = e1000_pch2lan,
4784 .flags = FLAG_IS_ICH
4786 | FLAG_HAS_HW_TIMESTAMP
4787 | FLAG_HAS_CTRLEXT_ON_LOAD
4790 | FLAG_HAS_JUMBO_FRAMES
4792 .flags2 = FLAG2_HAS_PHY_STATS
4795 .max_hw_frame_size = 9018,
4796 .get_variants = e1000_get_variants_ich8lan,
4797 .mac_ops = &ich8_mac_ops,
4798 .phy_ops = &ich8_phy_ops,
4799 .nvm_ops = &ich8_nvm_ops,
4802 const struct e1000_info e1000_pch_lpt_info = {
4803 .mac = e1000_pch_lpt,
4804 .flags = FLAG_IS_ICH
4806 | FLAG_HAS_HW_TIMESTAMP
4807 | FLAG_HAS_CTRLEXT_ON_LOAD
4810 | FLAG_HAS_JUMBO_FRAMES
4812 .flags2 = FLAG2_HAS_PHY_STATS
4815 .max_hw_frame_size = 9018,
4816 .get_variants = e1000_get_variants_ich8lan,
4817 .mac_ops = &ich8_mac_ops,
4818 .phy_ops = &ich8_phy_ops,
4819 .nvm_ops = &ich8_nvm_ops,