1 // SPDX-License-Identifier: GPL-2.0
2 /*******************************************************************************
4 Intel(R) Gigabit Ethernet Linux driver
5 Copyright(c) 2007-2013 Intel Corporation.
8 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
9 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
11 *******************************************************************************/
13 #include "e1000_api.h"
15 static s32 e1000_validate_mdi_setting_generic(struct e1000_hw *hw);
16 static void e1000_set_lan_id_multi_port_pcie(struct e1000_hw *hw);
17 static void e1000_config_collision_dist_generic(struct e1000_hw *hw);
18 static void e1000_rar_set_generic(struct e1000_hw *hw, u8 *addr, u32 index);
21 * e1000_init_mac_ops_generic - Initialize MAC function pointers
22 * @hw: pointer to the HW structure
24 * Setups up the function pointers to no-op functions
26 void e1000_init_mac_ops_generic(struct e1000_hw *hw)
28 struct e1000_mac_info *mac = &hw->mac;
29 DEBUGFUNC("e1000_init_mac_ops_generic");
32 mac->ops.init_params = e1000_null_ops_generic;
33 mac->ops.init_hw = e1000_null_ops_generic;
34 mac->ops.reset_hw = e1000_null_ops_generic;
35 mac->ops.setup_physical_interface = e1000_null_ops_generic;
36 mac->ops.get_bus_info = e1000_null_ops_generic;
37 mac->ops.set_lan_id = e1000_set_lan_id_multi_port_pcie;
38 mac->ops.read_mac_addr = e1000_read_mac_addr_generic;
39 mac->ops.config_collision_dist = e1000_config_collision_dist_generic;
40 mac->ops.clear_hw_cntrs = e1000_null_mac_generic;
42 mac->ops.cleanup_led = e1000_null_ops_generic;
43 mac->ops.setup_led = e1000_null_ops_generic;
44 mac->ops.blink_led = e1000_null_ops_generic;
45 mac->ops.led_on = e1000_null_ops_generic;
46 mac->ops.led_off = e1000_null_ops_generic;
48 mac->ops.setup_link = e1000_null_ops_generic;
49 mac->ops.get_link_up_info = e1000_null_link_info;
50 mac->ops.check_for_link = e1000_null_ops_generic;
52 mac->ops.check_mng_mode = e1000_null_mng_mode;
54 mac->ops.update_mc_addr_list = e1000_null_update_mc;
55 mac->ops.clear_vfta = e1000_null_mac_generic;
56 mac->ops.write_vfta = e1000_null_write_vfta;
57 mac->ops.rar_set = e1000_rar_set_generic;
58 mac->ops.validate_mdi_setting = e1000_validate_mdi_setting_generic;
62 * e1000_null_ops_generic - No-op function, returns 0
63 * @hw: pointer to the HW structure
65 s32 e1000_null_ops_generic(struct e1000_hw E1000_UNUSEDARG *hw)
67 DEBUGFUNC("e1000_null_ops_generic");
72 * e1000_null_mac_generic - No-op function, return void
73 * @hw: pointer to the HW structure
75 void e1000_null_mac_generic(struct e1000_hw E1000_UNUSEDARG *hw)
77 DEBUGFUNC("e1000_null_mac_generic");
82 * e1000_null_link_info - No-op function, return 0
83 * @hw: pointer to the HW structure
85 s32 e1000_null_link_info(struct e1000_hw E1000_UNUSEDARG *hw,
86 u16 E1000_UNUSEDARG *s, u16 E1000_UNUSEDARG *d)
88 DEBUGFUNC("e1000_null_link_info");
93 * e1000_null_mng_mode - No-op function, return false
94 * @hw: pointer to the HW structure
96 bool e1000_null_mng_mode(struct e1000_hw E1000_UNUSEDARG *hw)
98 DEBUGFUNC("e1000_null_mng_mode");
103 * e1000_null_update_mc - No-op function, return void
104 * @hw: pointer to the HW structure
106 void e1000_null_update_mc(struct e1000_hw E1000_UNUSEDARG *hw,
107 u8 E1000_UNUSEDARG *h, u32 E1000_UNUSEDARG a)
109 DEBUGFUNC("e1000_null_update_mc");
114 * e1000_null_write_vfta - No-op function, return void
115 * @hw: pointer to the HW structure
117 void e1000_null_write_vfta(struct e1000_hw E1000_UNUSEDARG *hw,
118 u32 E1000_UNUSEDARG a, u32 E1000_UNUSEDARG b)
120 DEBUGFUNC("e1000_null_write_vfta");
125 * e1000_null_rar_set - No-op function, return void
126 * @hw: pointer to the HW structure
128 void e1000_null_rar_set(struct e1000_hw E1000_UNUSEDARG *hw,
129 u8 E1000_UNUSEDARG *h, u32 E1000_UNUSEDARG a)
131 DEBUGFUNC("e1000_null_rar_set");
136 * e1000_get_bus_info_pcie_generic - Get PCIe bus information
137 * @hw: pointer to the HW structure
139 * Determines and stores the system bus information for a particular
140 * network interface. The following bus information is determined and stored:
141 * bus speed, bus width, type (PCIe), and PCIe function.
143 s32 e1000_get_bus_info_pcie_generic(struct e1000_hw *hw)
145 struct e1000_mac_info *mac = &hw->mac;
146 struct e1000_bus_info *bus = &hw->bus;
148 u16 pcie_link_status;
150 DEBUGFUNC("e1000_get_bus_info_pcie_generic");
152 bus->type = e1000_bus_type_pci_express;
154 ret_val = e1000_read_pcie_cap_reg(hw, PCIE_LINK_STATUS,
157 bus->width = e1000_bus_width_unknown;
158 bus->speed = e1000_bus_speed_unknown;
160 switch (pcie_link_status & PCIE_LINK_SPEED_MASK) {
161 case PCIE_LINK_SPEED_2500:
162 bus->speed = e1000_bus_speed_2500;
164 case PCIE_LINK_SPEED_5000:
165 bus->speed = e1000_bus_speed_5000;
168 bus->speed = e1000_bus_speed_unknown;
172 bus->width = (enum e1000_bus_width)((pcie_link_status &
173 PCIE_LINK_WIDTH_MASK) >> PCIE_LINK_WIDTH_SHIFT);
176 mac->ops.set_lan_id(hw);
178 return E1000_SUCCESS;
182 * e1000_set_lan_id_multi_port_pcie - Set LAN id for PCIe multiple port devices
184 * @hw: pointer to the HW structure
186 * Determines the LAN function id by reading memory-mapped registers
187 * and swaps the port value if requested.
189 static void e1000_set_lan_id_multi_port_pcie(struct e1000_hw *hw)
191 struct e1000_bus_info *bus = &hw->bus;
194 /* The status register reports the correct function number
195 * for the device regardless of function swap state.
197 reg = E1000_READ_REG(hw, E1000_STATUS);
198 bus->func = (reg & E1000_STATUS_FUNC_MASK) >> E1000_STATUS_FUNC_SHIFT;
202 * e1000_set_lan_id_single_port - Set LAN id for a single port device
203 * @hw: pointer to the HW structure
205 * Sets the LAN function id to zero for a single port device.
207 void e1000_set_lan_id_single_port(struct e1000_hw *hw)
209 struct e1000_bus_info *bus = &hw->bus;
215 * e1000_clear_vfta_generic - Clear VLAN filter table
216 * @hw: pointer to the HW structure
218 * Clears the register array which contains the VLAN filter table by
219 * setting all the values to 0.
221 void e1000_clear_vfta_generic(struct e1000_hw *hw)
225 DEBUGFUNC("e1000_clear_vfta_generic");
227 for (offset = 0; offset < E1000_VLAN_FILTER_TBL_SIZE; offset++) {
228 E1000_WRITE_REG_ARRAY(hw, E1000_VFTA, offset, 0);
229 E1000_WRITE_FLUSH(hw);
234 * e1000_write_vfta_generic - Write value to VLAN filter table
235 * @hw: pointer to the HW structure
236 * @offset: register offset in VLAN filter table
237 * @value: register value written to VLAN filter table
239 * Writes value at the given offset in the register array which stores
240 * the VLAN filter table.
242 void e1000_write_vfta_generic(struct e1000_hw *hw, u32 offset, u32 value)
244 DEBUGFUNC("e1000_write_vfta_generic");
246 E1000_WRITE_REG_ARRAY(hw, E1000_VFTA, offset, value);
247 E1000_WRITE_FLUSH(hw);
251 * e1000_init_rx_addrs_generic - Initialize receive address's
252 * @hw: pointer to the HW structure
253 * @rar_count: receive address registers
255 * Setup the receive address registers by setting the base receive address
256 * register to the devices MAC address and clearing all the other receive
257 * address registers to 0.
259 void e1000_init_rx_addrs_generic(struct e1000_hw *hw, u16 rar_count)
262 u8 mac_addr[ETH_ADDR_LEN] = {0};
264 DEBUGFUNC("e1000_init_rx_addrs_generic");
266 /* Setup the receive address */
267 DEBUGOUT("Programming MAC Address into RAR[0]\n");
269 hw->mac.ops.rar_set(hw, hw->mac.addr, 0);
271 /* Zero out the other (rar_entry_count - 1) receive addresses */
272 DEBUGOUT1("Clearing RAR[1-%u]\n", rar_count-1);
273 for (i = 1; i < rar_count; i++)
274 hw->mac.ops.rar_set(hw, mac_addr, i);
278 * e1000_check_alt_mac_addr_generic - Check for alternate MAC addr
279 * @hw: pointer to the HW structure
281 * Checks the nvm for an alternate MAC address. An alternate MAC address
282 * can be setup by pre-boot software and must be treated like a permanent
283 * address and must override the actual permanent MAC address. If an
284 * alternate MAC address is found it is programmed into RAR0, replacing
285 * the permanent address that was installed into RAR0 by the Si on reset.
286 * This function will return SUCCESS unless it encounters an error while
287 * reading the EEPROM.
289 s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw)
293 u16 offset, nvm_alt_mac_addr_offset, nvm_data;
294 u8 alt_mac_addr[ETH_ADDR_LEN];
296 DEBUGFUNC("e1000_check_alt_mac_addr_generic");
298 ret_val = hw->nvm.ops.read(hw, NVM_COMPAT, 1, &nvm_data);
303 /* Alternate MAC address is handled by the option ROM for 82580
304 * and newer. SW support not required.
306 if (hw->mac.type >= e1000_82580)
307 return E1000_SUCCESS;
309 ret_val = hw->nvm.ops.read(hw, NVM_ALT_MAC_ADDR_PTR, 1,
310 &nvm_alt_mac_addr_offset);
312 DEBUGOUT("NVM Read Error\n");
316 if ((nvm_alt_mac_addr_offset == 0xFFFF) ||
317 (nvm_alt_mac_addr_offset == 0x0000))
318 /* There is no Alternate MAC Address */
319 return E1000_SUCCESS;
321 if (hw->bus.func == E1000_FUNC_1)
322 nvm_alt_mac_addr_offset += E1000_ALT_MAC_ADDRESS_OFFSET_LAN1;
323 if (hw->bus.func == E1000_FUNC_2)
324 nvm_alt_mac_addr_offset += E1000_ALT_MAC_ADDRESS_OFFSET_LAN2;
326 if (hw->bus.func == E1000_FUNC_3)
327 nvm_alt_mac_addr_offset += E1000_ALT_MAC_ADDRESS_OFFSET_LAN3;
328 for (i = 0; i < ETH_ADDR_LEN; i += 2) {
329 offset = nvm_alt_mac_addr_offset + (i >> 1);
330 ret_val = hw->nvm.ops.read(hw, offset, 1, &nvm_data);
332 DEBUGOUT("NVM Read Error\n");
336 alt_mac_addr[i] = (u8)(nvm_data & 0xFF);
337 alt_mac_addr[i + 1] = (u8)(nvm_data >> 8);
340 /* if multicast bit is set, the alternate address will not be used */
341 if (alt_mac_addr[0] & 0x01) {
342 DEBUGOUT("Ignoring Alternate Mac Address with MC bit set\n");
343 return E1000_SUCCESS;
346 /* We have a valid alternate MAC address, and we want to treat it the
347 * same as the normal permanent MAC address stored by the HW into the
348 * RAR. Do this by mapping this address into RAR0.
350 hw->mac.ops.rar_set(hw, alt_mac_addr, 0);
352 return E1000_SUCCESS;
356 * e1000_rar_set_generic - Set receive address register
357 * @hw: pointer to the HW structure
358 * @addr: pointer to the receive address
359 * @index: receive address array register
361 * Sets the receive address array register at index to the address passed
364 static void e1000_rar_set_generic(struct e1000_hw *hw, u8 *addr, u32 index)
366 u32 rar_low, rar_high;
368 DEBUGFUNC("e1000_rar_set_generic");
370 /* HW expects these in little endian so we reverse the byte order
371 * from network order (big endian) to little endian
373 rar_low = ((u32) addr[0] | ((u32) addr[1] << 8) |
374 ((u32) addr[2] << 16) | ((u32) addr[3] << 24));
376 rar_high = ((u32) addr[4] | ((u32) addr[5] << 8));
378 /* If MAC address zero, no need to set the AV bit */
379 if (rar_low || rar_high)
380 rar_high |= E1000_RAH_AV;
382 /* Some bridges will combine consecutive 32-bit writes into
383 * a single burst write, which will malfunction on some parts.
384 * The flushes avoid this.
386 E1000_WRITE_REG(hw, E1000_RAL(index), rar_low);
387 E1000_WRITE_FLUSH(hw);
388 E1000_WRITE_REG(hw, E1000_RAH(index), rar_high);
389 E1000_WRITE_FLUSH(hw);
393 * e1000_hash_mc_addr_generic - Generate a multicast hash value
394 * @hw: pointer to the HW structure
395 * @mc_addr: pointer to a multicast address
397 * Generates a multicast address hash value which is used to determine
398 * the multicast filter table array address and new table value.
400 u32 e1000_hash_mc_addr_generic(struct e1000_hw *hw, u8 *mc_addr)
402 u32 hash_value, hash_mask;
405 DEBUGFUNC("e1000_hash_mc_addr_generic");
407 /* Register count multiplied by bits per register */
408 hash_mask = (hw->mac.mta_reg_count * 32) - 1;
410 /* For a mc_filter_type of 0, bit_shift is the number of left-shifts
411 * where 0xFF would still fall within the hash mask.
413 while (hash_mask >> bit_shift != 0xFF)
416 /* The portion of the address that is used for the hash table
417 * is determined by the mc_filter_type setting.
418 * The algorithm is such that there is a total of 8 bits of shifting.
419 * The bit_shift for a mc_filter_type of 0 represents the number of
420 * left-shifts where the MSB of mc_addr[5] would still fall within
421 * the hash_mask. Case 0 does this exactly. Since there are a total
422 * of 8 bits of shifting, then mc_addr[4] will shift right the
423 * remaining number of bits. Thus 8 - bit_shift. The rest of the
424 * cases are a variation of this algorithm...essentially raising the
425 * number of bits to shift mc_addr[5] left, while still keeping the
426 * 8-bit shifting total.
428 * For example, given the following Destination MAC Address and an
429 * mta register count of 128 (thus a 4096-bit vector and 0xFFF mask),
430 * we can see that the bit_shift for case 0 is 4. These are the hash
431 * values resulting from each mc_filter_type...
432 * [0] [1] [2] [3] [4] [5]
436 * case 0: hash_value = ((0x34 >> 4) | (0x56 << 4)) & 0xFFF = 0x563
437 * case 1: hash_value = ((0x34 >> 3) | (0x56 << 5)) & 0xFFF = 0xAC6
438 * case 2: hash_value = ((0x34 >> 2) | (0x56 << 6)) & 0xFFF = 0x163
439 * case 3: hash_value = ((0x34 >> 0) | (0x56 << 8)) & 0xFFF = 0x634
441 switch (hw->mac.mc_filter_type) {
456 hash_value = hash_mask & (((mc_addr[4] >> (8 - bit_shift)) |
457 (((u16) mc_addr[5]) << bit_shift)));
463 * e1000_update_mc_addr_list_generic - Update Multicast addresses
464 * @hw: pointer to the HW structure
465 * @mc_addr_list: array of multicast addresses to program
466 * @mc_addr_count: number of multicast addresses to program
468 * Updates entire Multicast Table Array.
469 * The caller must have a packed mc_addr_list of multicast addresses.
471 void e1000_update_mc_addr_list_generic(struct e1000_hw *hw,
472 u8 *mc_addr_list, u32 mc_addr_count)
474 u32 hash_value, hash_bit, hash_reg;
477 DEBUGFUNC("e1000_update_mc_addr_list_generic");
479 /* clear mta_shadow */
480 memset(&hw->mac.mta_shadow, 0, sizeof(hw->mac.mta_shadow));
482 /* update mta_shadow from mc_addr_list */
483 for (i = 0; (u32) i < mc_addr_count; i++) {
484 hash_value = e1000_hash_mc_addr_generic(hw, mc_addr_list);
486 hash_reg = (hash_value >> 5) & (hw->mac.mta_reg_count - 1);
487 hash_bit = hash_value & 0x1F;
489 hw->mac.mta_shadow[hash_reg] |= (1 << hash_bit);
490 mc_addr_list += (ETH_ADDR_LEN);
493 /* replace the entire MTA table */
494 for (i = hw->mac.mta_reg_count - 1; i >= 0; i--)
495 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, hw->mac.mta_shadow[i]);
496 E1000_WRITE_FLUSH(hw);
500 * e1000_clear_hw_cntrs_base_generic - Clear base hardware counters
501 * @hw: pointer to the HW structure
503 * Clears the base hardware counters by reading the counter registers.
505 void e1000_clear_hw_cntrs_base_generic(struct e1000_hw *hw)
507 DEBUGFUNC("e1000_clear_hw_cntrs_base_generic");
509 E1000_READ_REG(hw, E1000_CRCERRS);
510 E1000_READ_REG(hw, E1000_SYMERRS);
511 E1000_READ_REG(hw, E1000_MPC);
512 E1000_READ_REG(hw, E1000_SCC);
513 E1000_READ_REG(hw, E1000_ECOL);
514 E1000_READ_REG(hw, E1000_MCC);
515 E1000_READ_REG(hw, E1000_LATECOL);
516 E1000_READ_REG(hw, E1000_COLC);
517 E1000_READ_REG(hw, E1000_DC);
518 E1000_READ_REG(hw, E1000_SEC);
519 E1000_READ_REG(hw, E1000_RLEC);
520 E1000_READ_REG(hw, E1000_XONRXC);
521 E1000_READ_REG(hw, E1000_XONTXC);
522 E1000_READ_REG(hw, E1000_XOFFRXC);
523 E1000_READ_REG(hw, E1000_XOFFTXC);
524 E1000_READ_REG(hw, E1000_FCRUC);
525 E1000_READ_REG(hw, E1000_GPRC);
526 E1000_READ_REG(hw, E1000_BPRC);
527 E1000_READ_REG(hw, E1000_MPRC);
528 E1000_READ_REG(hw, E1000_GPTC);
529 E1000_READ_REG(hw, E1000_GORCL);
530 E1000_READ_REG(hw, E1000_GORCH);
531 E1000_READ_REG(hw, E1000_GOTCL);
532 E1000_READ_REG(hw, E1000_GOTCH);
533 E1000_READ_REG(hw, E1000_RNBC);
534 E1000_READ_REG(hw, E1000_RUC);
535 E1000_READ_REG(hw, E1000_RFC);
536 E1000_READ_REG(hw, E1000_ROC);
537 E1000_READ_REG(hw, E1000_RJC);
538 E1000_READ_REG(hw, E1000_TORL);
539 E1000_READ_REG(hw, E1000_TORH);
540 E1000_READ_REG(hw, E1000_TOTL);
541 E1000_READ_REG(hw, E1000_TOTH);
542 E1000_READ_REG(hw, E1000_TPR);
543 E1000_READ_REG(hw, E1000_TPT);
544 E1000_READ_REG(hw, E1000_MPTC);
545 E1000_READ_REG(hw, E1000_BPTC);
549 * e1000_check_for_copper_link_generic - Check for link (Copper)
550 * @hw: pointer to the HW structure
552 * Checks to see of the link status of the hardware has changed. If a
553 * change in link status has been detected, then we read the PHY registers
554 * to get the current speed/duplex if link exists.
556 s32 e1000_check_for_copper_link_generic(struct e1000_hw *hw)
558 struct e1000_mac_info *mac = &hw->mac;
562 DEBUGFUNC("e1000_check_for_copper_link");
564 /* We only want to go out to the PHY registers to see if Auto-Neg
565 * has completed and/or if our link status has changed. The
566 * get_link_status flag is set upon receiving a Link Status
567 * Change or Rx Sequence Error interrupt.
569 if (!mac->get_link_status)
570 return E1000_SUCCESS;
572 /* First we want to see if the MII Status Register reports
573 * link. If so, then we want to get the current speed/duplex
576 ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link);
581 return E1000_SUCCESS; /* No link detected */
583 mac->get_link_status = false;
585 /* Check if there was DownShift, must be checked
586 * immediately after link-up
588 e1000_check_downshift_generic(hw);
590 /* If we are forcing speed/duplex, then we simply return since
591 * we have already determined whether we have link or not.
594 return -E1000_ERR_CONFIG;
596 /* Auto-Neg is enabled. Auto Speed Detection takes care
597 * of MAC speed/duplex configuration. So we only need to
598 * configure Collision Distance in the MAC.
600 mac->ops.config_collision_dist(hw);
602 /* Configure Flow Control now that Auto-Neg has completed.
603 * First, we need to restore the desired flow control
604 * settings because we may have had to re-autoneg with a
605 * different link partner.
607 ret_val = e1000_config_fc_after_link_up_generic(hw);
609 DEBUGOUT("Error configuring flow control\n");
615 * e1000_check_for_fiber_link_generic - Check for link (Fiber)
616 * @hw: pointer to the HW structure
618 * Checks for link up on the hardware. If link is not up and we have
619 * a signal, then we need to force link up.
621 s32 e1000_check_for_fiber_link_generic(struct e1000_hw *hw)
623 struct e1000_mac_info *mac = &hw->mac;
629 DEBUGFUNC("e1000_check_for_fiber_link_generic");
631 ctrl = E1000_READ_REG(hw, E1000_CTRL);
632 status = E1000_READ_REG(hw, E1000_STATUS);
633 rxcw = E1000_READ_REG(hw, E1000_RXCW);
635 /* If we don't have link (auto-negotiation failed or link partner
636 * cannot auto-negotiate), the cable is plugged in (we have signal),
637 * and our link partner is not trying to auto-negotiate with us (we
638 * are receiving idles or data), we need to force link up. We also
639 * need to give auto-negotiation time to complete, in case the cable
640 * was just plugged in. The autoneg_failed flag does this.
642 /* (ctrl & E1000_CTRL_SWDPIN1) == 1 == have signal */
643 if ((ctrl & E1000_CTRL_SWDPIN1) && !(status & E1000_STATUS_LU) &&
644 !(rxcw & E1000_RXCW_C)) {
645 if (!mac->autoneg_failed) {
646 mac->autoneg_failed = true;
647 return E1000_SUCCESS;
649 DEBUGOUT("NOT Rx'ing /C/, disable AutoNeg and force link.\n");
651 /* Disable auto-negotiation in the TXCW register */
652 E1000_WRITE_REG(hw, E1000_TXCW, (mac->txcw & ~E1000_TXCW_ANE));
654 /* Force link-up and also force full-duplex. */
655 ctrl = E1000_READ_REG(hw, E1000_CTRL);
656 ctrl |= (E1000_CTRL_SLU | E1000_CTRL_FD);
657 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
659 /* Configure Flow Control after forcing link up. */
660 ret_val = e1000_config_fc_after_link_up_generic(hw);
662 DEBUGOUT("Error configuring flow control\n");
665 } else if ((ctrl & E1000_CTRL_SLU) && (rxcw & E1000_RXCW_C)) {
666 /* If we are forcing link and we are receiving /C/ ordered
667 * sets, re-enable auto-negotiation in the TXCW register
668 * and disable forced link in the Device Control register
669 * in an attempt to auto-negotiate with our link partner.
671 DEBUGOUT("Rx'ing /C/, enable AutoNeg and stop forcing link.\n");
672 E1000_WRITE_REG(hw, E1000_TXCW, mac->txcw);
673 E1000_WRITE_REG(hw, E1000_CTRL, (ctrl & ~E1000_CTRL_SLU));
675 mac->serdes_has_link = true;
678 return E1000_SUCCESS;
682 * e1000_check_for_serdes_link_generic - Check for link (Serdes)
683 * @hw: pointer to the HW structure
685 * Checks for link up on the hardware. If link is not up and we have
686 * a signal, then we need to force link up.
688 s32 e1000_check_for_serdes_link_generic(struct e1000_hw *hw)
690 struct e1000_mac_info *mac = &hw->mac;
696 DEBUGFUNC("e1000_check_for_serdes_link_generic");
698 ctrl = E1000_READ_REG(hw, E1000_CTRL);
699 status = E1000_READ_REG(hw, E1000_STATUS);
700 rxcw = E1000_READ_REG(hw, E1000_RXCW);
702 /* If we don't have link (auto-negotiation failed or link partner
703 * cannot auto-negotiate), and our link partner is not trying to
704 * auto-negotiate with us (we are receiving idles or data),
705 * we need to force link up. We also need to give auto-negotiation
708 /* (ctrl & E1000_CTRL_SWDPIN1) == 1 == have signal */
709 if (!(status & E1000_STATUS_LU) && !(rxcw & E1000_RXCW_C)) {
710 if (!mac->autoneg_failed) {
711 mac->autoneg_failed = true;
712 return E1000_SUCCESS;
714 DEBUGOUT("NOT Rx'ing /C/, disable AutoNeg and force link.\n");
716 /* Disable auto-negotiation in the TXCW register */
717 E1000_WRITE_REG(hw, E1000_TXCW, (mac->txcw & ~E1000_TXCW_ANE));
719 /* Force link-up and also force full-duplex. */
720 ctrl = E1000_READ_REG(hw, E1000_CTRL);
721 ctrl |= (E1000_CTRL_SLU | E1000_CTRL_FD);
722 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
724 /* Configure Flow Control after forcing link up. */
725 ret_val = e1000_config_fc_after_link_up_generic(hw);
727 DEBUGOUT("Error configuring flow control\n");
730 } else if ((ctrl & E1000_CTRL_SLU) && (rxcw & E1000_RXCW_C)) {
731 /* If we are forcing link and we are receiving /C/ ordered
732 * sets, re-enable auto-negotiation in the TXCW register
733 * and disable forced link in the Device Control register
734 * in an attempt to auto-negotiate with our link partner.
736 DEBUGOUT("Rx'ing /C/, enable AutoNeg and stop forcing link.\n");
737 E1000_WRITE_REG(hw, E1000_TXCW, mac->txcw);
738 E1000_WRITE_REG(hw, E1000_CTRL, (ctrl & ~E1000_CTRL_SLU));
740 mac->serdes_has_link = true;
741 } else if (!(E1000_TXCW_ANE & E1000_READ_REG(hw, E1000_TXCW))) {
742 /* If we force link for non-auto-negotiation switch, check
743 * link status based on MAC synchronization for internal
746 /* SYNCH bit and IV bit are sticky. */
748 rxcw = E1000_READ_REG(hw, E1000_RXCW);
749 if (rxcw & E1000_RXCW_SYNCH) {
750 if (!(rxcw & E1000_RXCW_IV)) {
751 mac->serdes_has_link = true;
752 DEBUGOUT("SERDES: Link up - forced.\n");
755 mac->serdes_has_link = false;
756 DEBUGOUT("SERDES: Link down - force failed.\n");
760 if (E1000_TXCW_ANE & E1000_READ_REG(hw, E1000_TXCW)) {
761 status = E1000_READ_REG(hw, E1000_STATUS);
762 if (status & E1000_STATUS_LU) {
763 /* SYNCH bit and IV bit are sticky, so reread rxcw. */
765 rxcw = E1000_READ_REG(hw, E1000_RXCW);
766 if (rxcw & E1000_RXCW_SYNCH) {
767 if (!(rxcw & E1000_RXCW_IV)) {
768 mac->serdes_has_link = true;
769 DEBUGOUT("SERDES: Link up - autoneg completed successfully.\n");
771 mac->serdes_has_link = false;
772 DEBUGOUT("SERDES: Link down - invalid codewords detected in autoneg.\n");
775 mac->serdes_has_link = false;
776 DEBUGOUT("SERDES: Link down - no sync.\n");
779 mac->serdes_has_link = false;
780 DEBUGOUT("SERDES: Link down - autoneg failed\n");
784 return E1000_SUCCESS;
788 * e1000_set_default_fc_generic - Set flow control default values
789 * @hw: pointer to the HW structure
791 * Read the EEPROM for the default values for flow control and store the
794 static s32 e1000_set_default_fc_generic(struct e1000_hw *hw)
799 DEBUGFUNC("e1000_set_default_fc_generic");
801 /* Read and store word 0x0F of the EEPROM. This word contains bits
802 * that determine the hardware's default PAUSE (flow control) mode,
803 * a bit that determines whether the HW defaults to enabling or
804 * disabling auto-negotiation, and the direction of the
805 * SW defined pins. If there is no SW over-ride of the flow
806 * control setting, then the variable hw->fc will
807 * be initialized based on a value in the EEPROM.
809 ret_val = hw->nvm.ops.read(hw, NVM_INIT_CONTROL2_REG, 1, &nvm_data);
812 DEBUGOUT("NVM Read Error\n");
816 if (!(nvm_data & NVM_WORD0F_PAUSE_MASK))
817 hw->fc.requested_mode = e1000_fc_none;
818 else if ((nvm_data & NVM_WORD0F_PAUSE_MASK) ==
820 hw->fc.requested_mode = e1000_fc_tx_pause;
822 hw->fc.requested_mode = e1000_fc_full;
824 return E1000_SUCCESS;
828 * e1000_setup_link_generic - Setup flow control and link settings
829 * @hw: pointer to the HW structure
831 * Determines which flow control settings to use, then configures flow
832 * control. Calls the appropriate media-specific link configuration
833 * function. Assuming the adapter has a valid link partner, a valid link
834 * should be established. Assumes the hardware has previously been reset
835 * and the transmitter and receiver are not enabled.
837 s32 e1000_setup_link_generic(struct e1000_hw *hw)
841 DEBUGFUNC("e1000_setup_link_generic");
843 /* In the case of the phy reset being blocked, we already have a link.
844 * We do not need to set it up again.
846 if (hw->phy.ops.check_reset_block && hw->phy.ops.check_reset_block(hw))
847 return E1000_SUCCESS;
849 /* If requested flow control is set to default, set flow control
850 * based on the EEPROM flow control settings.
852 if (hw->fc.requested_mode == e1000_fc_default) {
853 ret_val = e1000_set_default_fc_generic(hw);
858 /* Save off the requested flow control mode for use later. Depending
859 * on the link partner's capabilities, we may or may not use this mode.
861 hw->fc.current_mode = hw->fc.requested_mode;
863 DEBUGOUT1("After fix-ups FlowControl is now = %x\n",
864 hw->fc.current_mode);
866 /* Call the necessary media_type subroutine to configure the link. */
867 ret_val = hw->mac.ops.setup_physical_interface(hw);
871 /* Initialize the flow control address, type, and PAUSE timer
872 * registers to their default values. This is done even if flow
873 * control is disabled, because it does not hurt anything to
874 * initialize these registers.
876 DEBUGOUT("Initializing the Flow Control address, type and timer regs\n");
877 E1000_WRITE_REG(hw, E1000_FCT, FLOW_CONTROL_TYPE);
878 E1000_WRITE_REG(hw, E1000_FCAH, FLOW_CONTROL_ADDRESS_HIGH);
879 E1000_WRITE_REG(hw, E1000_FCAL, FLOW_CONTROL_ADDRESS_LOW);
881 E1000_WRITE_REG(hw, E1000_FCTTV, hw->fc.pause_time);
883 return e1000_set_fc_watermarks_generic(hw);
887 * e1000_commit_fc_settings_generic - Configure flow control
888 * @hw: pointer to the HW structure
890 * Write the flow control settings to the Transmit Config Word Register (TXCW)
891 * base on the flow control settings in e1000_mac_info.
893 static s32 e1000_commit_fc_settings_generic(struct e1000_hw *hw)
895 struct e1000_mac_info *mac = &hw->mac;
898 DEBUGFUNC("e1000_commit_fc_settings_generic");
900 /* Check for a software override of the flow control settings, and
901 * setup the device accordingly. If auto-negotiation is enabled, then
902 * software will have to set the "PAUSE" bits to the correct value in
903 * the Transmit Config Word Register (TXCW) and re-start auto-
904 * negotiation. However, if auto-negotiation is disabled, then
905 * software will have to manually configure the two flow control enable
906 * bits in the CTRL register.
908 * The possible values of the "fc" parameter are:
909 * 0: Flow control is completely disabled
910 * 1: Rx flow control is enabled (we can receive pause frames,
911 * but not send pause frames).
912 * 2: Tx flow control is enabled (we can send pause frames but we
913 * do not support receiving pause frames).
914 * 3: Both Rx and Tx flow control (symmetric) are enabled.
916 switch (hw->fc.current_mode) {
918 /* Flow control completely disabled by a software over-ride. */
919 txcw = (E1000_TXCW_ANE | E1000_TXCW_FD);
921 case e1000_fc_rx_pause:
922 /* Rx Flow control is enabled and Tx Flow control is disabled
923 * by a software over-ride. Since there really isn't a way to
924 * advertise that we are capable of Rx Pause ONLY, we will
925 * advertise that we support both symmetric and asymmetric Rx
926 * PAUSE. Later, we will disable the adapter's ability to send
929 txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_PAUSE_MASK);
931 case e1000_fc_tx_pause:
932 /* Tx Flow control is enabled, and Rx Flow control is disabled,
933 * by a software over-ride.
935 txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_ASM_DIR);
938 /* Flow control (both Rx and Tx) is enabled by a software
941 txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_PAUSE_MASK);
944 DEBUGOUT("Flow control param set incorrectly\n");
945 return -E1000_ERR_CONFIG;
949 E1000_WRITE_REG(hw, E1000_TXCW, txcw);
952 return E1000_SUCCESS;
956 * e1000_poll_fiber_serdes_link_generic - Poll for link up
957 * @hw: pointer to the HW structure
959 * Polls for link up by reading the status register, if link fails to come
960 * up with auto-negotiation, then the link is forced if a signal is detected.
962 static s32 e1000_poll_fiber_serdes_link_generic(struct e1000_hw *hw)
964 struct e1000_mac_info *mac = &hw->mac;
968 DEBUGFUNC("e1000_poll_fiber_serdes_link_generic");
970 /* If we have a signal (the cable is plugged in, or assumed true for
971 * serdes media) then poll for a "Link-Up" indication in the Device
972 * Status Register. Time-out if a link isn't seen in 500 milliseconds
973 * seconds (Auto-negotiation should complete in less than 500
974 * milliseconds even if the other end is doing it in SW).
976 for (i = 0; i < FIBER_LINK_UP_LIMIT; i++) {
978 status = E1000_READ_REG(hw, E1000_STATUS);
979 if (status & E1000_STATUS_LU)
982 if (i == FIBER_LINK_UP_LIMIT) {
983 DEBUGOUT("Never got a valid link from auto-neg!!!\n");
984 mac->autoneg_failed = true;
985 /* AutoNeg failed to achieve a link, so we'll call
986 * mac->check_for_link. This routine will force the
987 * link up if we detect a signal. This will allow us to
988 * communicate with non-autonegotiating link partners.
990 ret_val = mac->ops.check_for_link(hw);
992 DEBUGOUT("Error while checking for link\n");
995 mac->autoneg_failed = false;
997 mac->autoneg_failed = false;
998 DEBUGOUT("Valid Link Found\n");
1001 return E1000_SUCCESS;
1005 * e1000_setup_fiber_serdes_link_generic - Setup link for fiber/serdes
1006 * @hw: pointer to the HW structure
1008 * Configures collision distance and flow control for fiber and serdes
1009 * links. Upon successful setup, poll for link.
1011 s32 e1000_setup_fiber_serdes_link_generic(struct e1000_hw *hw)
1016 DEBUGFUNC("e1000_setup_fiber_serdes_link_generic");
1018 ctrl = E1000_READ_REG(hw, E1000_CTRL);
1020 /* Take the link out of reset */
1021 ctrl &= ~E1000_CTRL_LRST;
1023 hw->mac.ops.config_collision_dist(hw);
1025 ret_val = e1000_commit_fc_settings_generic(hw);
1029 /* Since auto-negotiation is enabled, take the link out of reset (the
1030 * link will be in reset, because we previously reset the chip). This
1031 * will restart auto-negotiation. If auto-negotiation is successful
1032 * then the link-up status bit will be set and the flow control enable
1033 * bits (RFCE and TFCE) will be set according to their negotiated value.
1035 DEBUGOUT("Auto-negotiation enabled\n");
1037 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
1038 E1000_WRITE_FLUSH(hw);
1041 /* For these adapters, the SW definable pin 1 is set when the optics
1042 * detect a signal. If we have a signal, then poll for a "Link-Up"
1045 if (hw->phy.media_type == e1000_media_type_internal_serdes ||
1046 (E1000_READ_REG(hw, E1000_CTRL) & E1000_CTRL_SWDPIN1)) {
1047 ret_val = e1000_poll_fiber_serdes_link_generic(hw);
1049 DEBUGOUT("No signal detected\n");
1056 * e1000_config_collision_dist_generic - Configure collision distance
1057 * @hw: pointer to the HW structure
1059 * Configures the collision distance to the default value and is used
1060 * during link setup.
1062 static void e1000_config_collision_dist_generic(struct e1000_hw *hw)
1066 DEBUGFUNC("e1000_config_collision_dist_generic");
1068 tctl = E1000_READ_REG(hw, E1000_TCTL);
1070 tctl &= ~E1000_TCTL_COLD;
1071 tctl |= E1000_COLLISION_DISTANCE << E1000_COLD_SHIFT;
1073 E1000_WRITE_REG(hw, E1000_TCTL, tctl);
1074 E1000_WRITE_FLUSH(hw);
1078 * e1000_set_fc_watermarks_generic - Set flow control high/low watermarks
1079 * @hw: pointer to the HW structure
1081 * Sets the flow control high/low threshold (watermark) registers. If
1082 * flow control XON frame transmission is enabled, then set XON frame
1083 * transmission as well.
1085 s32 e1000_set_fc_watermarks_generic(struct e1000_hw *hw)
1087 u32 fcrtl = 0, fcrth = 0;
1089 DEBUGFUNC("e1000_set_fc_watermarks_generic");
1091 /* Set the flow control receive threshold registers. Normally,
1092 * these registers will be set to a default threshold that may be
1093 * adjusted later by the driver's runtime code. However, if the
1094 * ability to transmit pause frames is not enabled, then these
1095 * registers will be set to 0.
1097 if (hw->fc.current_mode & e1000_fc_tx_pause) {
1098 /* We need to set up the Receive Threshold high and low water
1099 * marks as well as (optionally) enabling the transmission of
1102 fcrtl = hw->fc.low_water;
1103 if (hw->fc.send_xon)
1104 fcrtl |= E1000_FCRTL_XONE;
1106 fcrth = hw->fc.high_water;
1108 E1000_WRITE_REG(hw, E1000_FCRTL, fcrtl);
1109 E1000_WRITE_REG(hw, E1000_FCRTH, fcrth);
1111 return E1000_SUCCESS;
1115 * e1000_force_mac_fc_generic - Force the MAC's flow control settings
1116 * @hw: pointer to the HW structure
1118 * Force the MAC's flow control settings. Sets the TFCE and RFCE bits in the
1119 * device control register to reflect the adapter settings. TFCE and RFCE
1120 * need to be explicitly set by software when a copper PHY is used because
1121 * autonegotiation is managed by the PHY rather than the MAC. Software must
1122 * also configure these bits when link is forced on a fiber connection.
1124 s32 e1000_force_mac_fc_generic(struct e1000_hw *hw)
1128 DEBUGFUNC("e1000_force_mac_fc_generic");
1130 ctrl = E1000_READ_REG(hw, E1000_CTRL);
1132 /* Because we didn't get link via the internal auto-negotiation
1133 * mechanism (we either forced link or we got link via PHY
1134 * auto-neg), we have to manually enable/disable transmit an
1135 * receive flow control.
1137 * The "Case" statement below enables/disable flow control
1138 * according to the "hw->fc.current_mode" parameter.
1140 * The possible values of the "fc" parameter are:
1141 * 0: Flow control is completely disabled
1142 * 1: Rx flow control is enabled (we can receive pause
1143 * frames but not send pause frames).
1144 * 2: Tx flow control is enabled (we can send pause frames
1145 * frames but we do not receive pause frames).
1146 * 3: Both Rx and Tx flow control (symmetric) is enabled.
1147 * other: No other values should be possible at this point.
1149 DEBUGOUT1("hw->fc.current_mode = %u\n", hw->fc.current_mode);
1151 switch (hw->fc.current_mode) {
1153 ctrl &= (~(E1000_CTRL_TFCE | E1000_CTRL_RFCE));
1155 case e1000_fc_rx_pause:
1156 ctrl &= (~E1000_CTRL_TFCE);
1157 ctrl |= E1000_CTRL_RFCE;
1159 case e1000_fc_tx_pause:
1160 ctrl &= (~E1000_CTRL_RFCE);
1161 ctrl |= E1000_CTRL_TFCE;
1164 ctrl |= (E1000_CTRL_TFCE | E1000_CTRL_RFCE);
1167 DEBUGOUT("Flow control param set incorrectly\n");
1168 return -E1000_ERR_CONFIG;
1171 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
1173 return E1000_SUCCESS;
1177 * e1000_config_fc_after_link_up_generic - Configures flow control after link
1178 * @hw: pointer to the HW structure
1180 * Checks the status of auto-negotiation after link up to ensure that the
1181 * speed and duplex were not forced. If the link needed to be forced, then
1182 * flow control needs to be forced also. If auto-negotiation is enabled
1183 * and did not fail, then we configure flow control based on our link
1186 s32 e1000_config_fc_after_link_up_generic(struct e1000_hw *hw)
1188 struct e1000_mac_info *mac = &hw->mac;
1189 s32 ret_val = E1000_SUCCESS;
1190 u32 pcs_status_reg, pcs_adv_reg, pcs_lp_ability_reg, pcs_ctrl_reg;
1191 u16 mii_status_reg, mii_nway_adv_reg, mii_nway_lp_ability_reg;
1194 DEBUGFUNC("e1000_config_fc_after_link_up_generic");
1196 /* Check for the case where we have fiber media and auto-neg failed
1197 * so we had to force link. In this case, we need to force the
1198 * configuration of the MAC to match the "fc" parameter.
1200 if (mac->autoneg_failed) {
1201 if (hw->phy.media_type == e1000_media_type_fiber ||
1202 hw->phy.media_type == e1000_media_type_internal_serdes)
1203 ret_val = e1000_force_mac_fc_generic(hw);
1205 if (hw->phy.media_type == e1000_media_type_copper)
1206 ret_val = e1000_force_mac_fc_generic(hw);
1210 DEBUGOUT("Error forcing flow control settings\n");
1214 /* Check for the case where we have copper media and auto-neg is
1215 * enabled. In this case, we need to check and see if Auto-Neg
1216 * has completed, and if so, how the PHY and link partner has
1217 * flow control configured.
1219 if ((hw->phy.media_type == e1000_media_type_copper) && mac->autoneg) {
1220 /* Read the MII Status Register and check to see if AutoNeg
1221 * has completed. We read this twice because this reg has
1222 * some "sticky" (latched) bits.
1224 ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &mii_status_reg);
1227 ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &mii_status_reg);
1231 if (!(mii_status_reg & MII_SR_AUTONEG_COMPLETE)) {
1232 DEBUGOUT("Copper PHY and Auto Neg has not completed.\n");
1236 /* The AutoNeg process has completed, so we now need to
1237 * read both the Auto Negotiation Advertisement
1238 * Register (Address 4) and the Auto_Negotiation Base
1239 * Page Ability Register (Address 5) to determine how
1240 * flow control was negotiated.
1242 ret_val = hw->phy.ops.read_reg(hw, PHY_AUTONEG_ADV,
1246 ret_val = hw->phy.ops.read_reg(hw, PHY_LP_ABILITY,
1247 &mii_nway_lp_ability_reg);
1251 /* Two bits in the Auto Negotiation Advertisement Register
1252 * (Address 4) and two bits in the Auto Negotiation Base
1253 * Page Ability Register (Address 5) determine flow control
1254 * for both the PHY and the link partner. The following
1255 * table, taken out of the IEEE 802.3ab/D6.0 dated March 25,
1256 * 1999, describes these PAUSE resolution bits and how flow
1257 * control is determined based upon these settings.
1258 * NOTE: DC = Don't Care
1260 * LOCAL DEVICE | LINK PARTNER
1261 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | NIC Resolution
1262 *-------|---------|-------|---------|--------------------
1263 * 0 | 0 | DC | DC | e1000_fc_none
1264 * 0 | 1 | 0 | DC | e1000_fc_none
1265 * 0 | 1 | 1 | 0 | e1000_fc_none
1266 * 0 | 1 | 1 | 1 | e1000_fc_tx_pause
1267 * 1 | 0 | 0 | DC | e1000_fc_none
1268 * 1 | DC | 1 | DC | e1000_fc_full
1269 * 1 | 1 | 0 | 0 | e1000_fc_none
1270 * 1 | 1 | 0 | 1 | e1000_fc_rx_pause
1272 * Are both PAUSE bits set to 1? If so, this implies
1273 * Symmetric Flow Control is enabled at both ends. The
1274 * ASM_DIR bits are irrelevant per the spec.
1276 * For Symmetric Flow Control:
1278 * LOCAL DEVICE | LINK PARTNER
1279 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
1280 *-------|---------|-------|---------|--------------------
1281 * 1 | DC | 1 | DC | E1000_fc_full
1284 if ((mii_nway_adv_reg & NWAY_AR_PAUSE) &&
1285 (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE)) {
1286 /* Now we need to check if the user selected Rx ONLY
1287 * of pause frames. In this case, we had to advertise
1288 * FULL flow control because we could not advertise Rx
1289 * ONLY. Hence, we must now check to see if we need to
1290 * turn OFF the TRANSMISSION of PAUSE frames.
1292 if (hw->fc.requested_mode == e1000_fc_full) {
1293 hw->fc.current_mode = e1000_fc_full;
1294 DEBUGOUT("Flow Control = FULL.\n");
1296 hw->fc.current_mode = e1000_fc_rx_pause;
1297 DEBUGOUT("Flow Control = Rx PAUSE frames only.\n");
1300 /* For receiving PAUSE frames ONLY.
1302 * LOCAL DEVICE | LINK PARTNER
1303 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
1304 *-------|---------|-------|---------|--------------------
1305 * 0 | 1 | 1 | 1 | e1000_fc_tx_pause
1307 else if (!(mii_nway_adv_reg & NWAY_AR_PAUSE) &&
1308 (mii_nway_adv_reg & NWAY_AR_ASM_DIR) &&
1309 (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) &&
1310 (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) {
1311 hw->fc.current_mode = e1000_fc_tx_pause;
1312 DEBUGOUT("Flow Control = Tx PAUSE frames only.\n");
1314 /* For transmitting PAUSE frames ONLY.
1316 * LOCAL DEVICE | LINK PARTNER
1317 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
1318 *-------|---------|-------|---------|--------------------
1319 * 1 | 1 | 0 | 1 | e1000_fc_rx_pause
1321 else if ((mii_nway_adv_reg & NWAY_AR_PAUSE) &&
1322 (mii_nway_adv_reg & NWAY_AR_ASM_DIR) &&
1323 !(mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) &&
1324 (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) {
1325 hw->fc.current_mode = e1000_fc_rx_pause;
1326 DEBUGOUT("Flow Control = Rx PAUSE frames only.\n");
1328 /* Per the IEEE spec, at this point flow control
1329 * should be disabled.
1331 hw->fc.current_mode = e1000_fc_none;
1332 DEBUGOUT("Flow Control = NONE.\n");
1335 /* Now we need to do one last check... If we auto-
1336 * negotiated to HALF DUPLEX, flow control should not be
1337 * enabled per IEEE 802.3 spec.
1339 ret_val = mac->ops.get_link_up_info(hw, &speed, &duplex);
1341 DEBUGOUT("Error getting link speed and duplex\n");
1345 if (duplex == HALF_DUPLEX)
1346 hw->fc.current_mode = e1000_fc_none;
1348 /* Now we call a subroutine to actually force the MAC
1349 * controller to use the correct flow control settings.
1351 ret_val = e1000_force_mac_fc_generic(hw);
1353 DEBUGOUT("Error forcing flow control settings\n");
1358 /* Check for the case where we have SerDes media and auto-neg is
1359 * enabled. In this case, we need to check and see if Auto-Neg
1360 * has completed, and if so, how the PHY and link partner has
1361 * flow control configured.
1363 if ((hw->phy.media_type == e1000_media_type_internal_serdes) &&
1365 /* Read the PCS_LSTS and check to see if AutoNeg
1368 pcs_status_reg = E1000_READ_REG(hw, E1000_PCS_LSTAT);
1370 if (!(pcs_status_reg & E1000_PCS_LSTS_AN_COMPLETE)) {
1371 DEBUGOUT("PCS Auto Neg has not completed.\n");
1375 /* The AutoNeg process has completed, so we now need to
1376 * read both the Auto Negotiation Advertisement
1377 * Register (PCS_ANADV) and the Auto_Negotiation Base
1378 * Page Ability Register (PCS_LPAB) to determine how
1379 * flow control was negotiated.
1381 pcs_adv_reg = E1000_READ_REG(hw, E1000_PCS_ANADV);
1382 pcs_lp_ability_reg = E1000_READ_REG(hw, E1000_PCS_LPAB);
1384 /* Two bits in the Auto Negotiation Advertisement Register
1385 * (PCS_ANADV) and two bits in the Auto Negotiation Base
1386 * Page Ability Register (PCS_LPAB) determine flow control
1387 * for both the PHY and the link partner. The following
1388 * table, taken out of the IEEE 802.3ab/D6.0 dated March 25,
1389 * 1999, describes these PAUSE resolution bits and how flow
1390 * control is determined based upon these settings.
1391 * NOTE: DC = Don't Care
1393 * LOCAL DEVICE | LINK PARTNER
1394 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | NIC Resolution
1395 *-------|---------|-------|---------|--------------------
1396 * 0 | 0 | DC | DC | e1000_fc_none
1397 * 0 | 1 | 0 | DC | e1000_fc_none
1398 * 0 | 1 | 1 | 0 | e1000_fc_none
1399 * 0 | 1 | 1 | 1 | e1000_fc_tx_pause
1400 * 1 | 0 | 0 | DC | e1000_fc_none
1401 * 1 | DC | 1 | DC | e1000_fc_full
1402 * 1 | 1 | 0 | 0 | e1000_fc_none
1403 * 1 | 1 | 0 | 1 | e1000_fc_rx_pause
1405 * Are both PAUSE bits set to 1? If so, this implies
1406 * Symmetric Flow Control is enabled at both ends. The
1407 * ASM_DIR bits are irrelevant per the spec.
1409 * For Symmetric Flow Control:
1411 * LOCAL DEVICE | LINK PARTNER
1412 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
1413 *-------|---------|-------|---------|--------------------
1414 * 1 | DC | 1 | DC | e1000_fc_full
1417 if ((pcs_adv_reg & E1000_TXCW_PAUSE) &&
1418 (pcs_lp_ability_reg & E1000_TXCW_PAUSE)) {
1419 /* Now we need to check if the user selected Rx ONLY
1420 * of pause frames. In this case, we had to advertise
1421 * FULL flow control because we could not advertise Rx
1422 * ONLY. Hence, we must now check to see if we need to
1423 * turn OFF the TRANSMISSION of PAUSE frames.
1425 if (hw->fc.requested_mode == e1000_fc_full) {
1426 hw->fc.current_mode = e1000_fc_full;
1427 DEBUGOUT("Flow Control = FULL.\n");
1429 hw->fc.current_mode = e1000_fc_rx_pause;
1430 DEBUGOUT("Flow Control = Rx PAUSE frames only.\n");
1433 /* For receiving PAUSE frames ONLY.
1435 * LOCAL DEVICE | LINK PARTNER
1436 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
1437 *-------|---------|-------|---------|--------------------
1438 * 0 | 1 | 1 | 1 | e1000_fc_tx_pause
1440 else if (!(pcs_adv_reg & E1000_TXCW_PAUSE) &&
1441 (pcs_adv_reg & E1000_TXCW_ASM_DIR) &&
1442 (pcs_lp_ability_reg & E1000_TXCW_PAUSE) &&
1443 (pcs_lp_ability_reg & E1000_TXCW_ASM_DIR)) {
1444 hw->fc.current_mode = e1000_fc_tx_pause;
1445 DEBUGOUT("Flow Control = Tx PAUSE frames only.\n");
1447 /* For transmitting PAUSE frames ONLY.
1449 * LOCAL DEVICE | LINK PARTNER
1450 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
1451 *-------|---------|-------|---------|--------------------
1452 * 1 | 1 | 0 | 1 | e1000_fc_rx_pause
1454 else if ((pcs_adv_reg & E1000_TXCW_PAUSE) &&
1455 (pcs_adv_reg & E1000_TXCW_ASM_DIR) &&
1456 !(pcs_lp_ability_reg & E1000_TXCW_PAUSE) &&
1457 (pcs_lp_ability_reg & E1000_TXCW_ASM_DIR)) {
1458 hw->fc.current_mode = e1000_fc_rx_pause;
1459 DEBUGOUT("Flow Control = Rx PAUSE frames only.\n");
1461 /* Per the IEEE spec, at this point flow control
1462 * should be disabled.
1464 hw->fc.current_mode = e1000_fc_none;
1465 DEBUGOUT("Flow Control = NONE.\n");
1468 /* Now we call a subroutine to actually force the MAC
1469 * controller to use the correct flow control settings.
1471 pcs_ctrl_reg = E1000_READ_REG(hw, E1000_PCS_LCTL);
1472 pcs_ctrl_reg |= E1000_PCS_LCTL_FORCE_FCTRL;
1473 E1000_WRITE_REG(hw, E1000_PCS_LCTL, pcs_ctrl_reg);
1475 ret_val = e1000_force_mac_fc_generic(hw);
1477 DEBUGOUT("Error forcing flow control settings\n");
1482 return E1000_SUCCESS;
1486 * e1000_get_speed_and_duplex_copper_generic - Retrieve current speed/duplex
1487 * @hw: pointer to the HW structure
1488 * @speed: stores the current speed
1489 * @duplex: stores the current duplex
1491 * Read the status register for the current speed/duplex and store the current
1492 * speed and duplex for copper connections.
1494 s32 e1000_get_speed_and_duplex_copper_generic(struct e1000_hw *hw, u16 *speed,
1499 DEBUGFUNC("e1000_get_speed_and_duplex_copper_generic");
1501 status = E1000_READ_REG(hw, E1000_STATUS);
1502 if (status & E1000_STATUS_SPEED_1000) {
1503 *speed = SPEED_1000;
1504 DEBUGOUT("1000 Mbs, ");
1505 } else if (status & E1000_STATUS_SPEED_100) {
1507 DEBUGOUT("100 Mbs, ");
1510 DEBUGOUT("10 Mbs, ");
1513 if (status & E1000_STATUS_FD) {
1514 *duplex = FULL_DUPLEX;
1515 DEBUGOUT("Full Duplex\n");
1517 *duplex = HALF_DUPLEX;
1518 DEBUGOUT("Half Duplex\n");
1521 return E1000_SUCCESS;
1525 * e1000_get_speed_and_duplex_fiber_generic - Retrieve current speed/duplex
1526 * @hw: pointer to the HW structure
1527 * @speed: stores the current speed
1528 * @duplex: stores the current duplex
1530 * Sets the speed and duplex to gigabit full duplex (the only possible option)
1531 * for fiber/serdes links.
1533 s32 e1000_get_speed_and_duplex_fiber_serdes_generic(struct e1000_hw E1000_UNUSEDARG *hw,
1534 u16 *speed, u16 *duplex)
1536 DEBUGFUNC("e1000_get_speed_and_duplex_fiber_serdes_generic");
1538 *speed = SPEED_1000;
1539 *duplex = FULL_DUPLEX;
1541 return E1000_SUCCESS;
1545 * e1000_get_hw_semaphore_generic - Acquire hardware semaphore
1546 * @hw: pointer to the HW structure
1548 * Acquire the HW semaphore to access the PHY or NVM
1550 s32 e1000_get_hw_semaphore_generic(struct e1000_hw *hw)
1553 s32 timeout = hw->nvm.word_size + 1;
1556 DEBUGFUNC("e1000_get_hw_semaphore_generic");
1558 /* Get the SW semaphore */
1559 while (i < timeout) {
1560 swsm = E1000_READ_REG(hw, E1000_SWSM);
1561 if (!(swsm & E1000_SWSM_SMBI))
1569 DEBUGOUT("Driver can't access device - SMBI bit is set.\n");
1570 return -E1000_ERR_NVM;
1573 /* Get the FW semaphore. */
1574 for (i = 0; i < timeout; i++) {
1575 swsm = E1000_READ_REG(hw, E1000_SWSM);
1576 E1000_WRITE_REG(hw, E1000_SWSM, swsm | E1000_SWSM_SWESMBI);
1578 /* Semaphore acquired if bit latched */
1579 if (E1000_READ_REG(hw, E1000_SWSM) & E1000_SWSM_SWESMBI)
1586 /* Release semaphores */
1587 e1000_put_hw_semaphore_generic(hw);
1588 DEBUGOUT("Driver can't access the NVM\n");
1589 return -E1000_ERR_NVM;
1592 return E1000_SUCCESS;
1596 * e1000_put_hw_semaphore_generic - Release hardware semaphore
1597 * @hw: pointer to the HW structure
1599 * Release hardware semaphore used to access the PHY or NVM
1601 void e1000_put_hw_semaphore_generic(struct e1000_hw *hw)
1605 DEBUGFUNC("e1000_put_hw_semaphore_generic");
1607 swsm = E1000_READ_REG(hw, E1000_SWSM);
1609 swsm &= ~(E1000_SWSM_SMBI | E1000_SWSM_SWESMBI);
1611 E1000_WRITE_REG(hw, E1000_SWSM, swsm);
1615 * e1000_get_auto_rd_done_generic - Check for auto read completion
1616 * @hw: pointer to the HW structure
1618 * Check EEPROM for Auto Read done bit.
1620 s32 e1000_get_auto_rd_done_generic(struct e1000_hw *hw)
1624 DEBUGFUNC("e1000_get_auto_rd_done_generic");
1626 while (i < AUTO_READ_DONE_TIMEOUT) {
1627 if (E1000_READ_REG(hw, E1000_EECD) & E1000_EECD_AUTO_RD)
1633 if (i == AUTO_READ_DONE_TIMEOUT) {
1634 DEBUGOUT("Auto read by HW from NVM has not completed.\n");
1635 return -E1000_ERR_RESET;
1638 return E1000_SUCCESS;
1642 * e1000_valid_led_default_generic - Verify a valid default LED config
1643 * @hw: pointer to the HW structure
1644 * @data: pointer to the NVM (EEPROM)
1646 * Read the EEPROM for the current default LED configuration. If the
1647 * LED configuration is not valid, set to a valid LED configuration.
1649 s32 e1000_valid_led_default_generic(struct e1000_hw *hw, u16 *data)
1653 DEBUGFUNC("e1000_valid_led_default_generic");
1655 ret_val = hw->nvm.ops.read(hw, NVM_ID_LED_SETTINGS, 1, data);
1657 DEBUGOUT("NVM Read Error\n");
1661 if (*data == ID_LED_RESERVED_0000 || *data == ID_LED_RESERVED_FFFF)
1662 *data = ID_LED_DEFAULT;
1664 return E1000_SUCCESS;
1668 * e1000_id_led_init_generic -
1669 * @hw: pointer to the HW structure
1672 s32 e1000_id_led_init_generic(struct e1000_hw *hw)
1674 struct e1000_mac_info *mac = &hw->mac;
1676 const u32 ledctl_mask = 0x000000FF;
1677 const u32 ledctl_on = E1000_LEDCTL_MODE_LED_ON;
1678 const u32 ledctl_off = E1000_LEDCTL_MODE_LED_OFF;
1680 const u16 led_mask = 0x0F;
1682 DEBUGFUNC("e1000_id_led_init_generic");
1684 ret_val = hw->nvm.ops.valid_led_default(hw, &data);
1688 mac->ledctl_default = E1000_READ_REG(hw, E1000_LEDCTL);
1689 mac->ledctl_mode1 = mac->ledctl_default;
1690 mac->ledctl_mode2 = mac->ledctl_default;
1692 for (i = 0; i < 4; i++) {
1693 temp = (data >> (i << 2)) & led_mask;
1695 case ID_LED_ON1_DEF2:
1696 case ID_LED_ON1_ON2:
1697 case ID_LED_ON1_OFF2:
1698 mac->ledctl_mode1 &= ~(ledctl_mask << (i << 3));
1699 mac->ledctl_mode1 |= ledctl_on << (i << 3);
1701 case ID_LED_OFF1_DEF2:
1702 case ID_LED_OFF1_ON2:
1703 case ID_LED_OFF1_OFF2:
1704 mac->ledctl_mode1 &= ~(ledctl_mask << (i << 3));
1705 mac->ledctl_mode1 |= ledctl_off << (i << 3);
1712 case ID_LED_DEF1_ON2:
1713 case ID_LED_ON1_ON2:
1714 case ID_LED_OFF1_ON2:
1715 mac->ledctl_mode2 &= ~(ledctl_mask << (i << 3));
1716 mac->ledctl_mode2 |= ledctl_on << (i << 3);
1718 case ID_LED_DEF1_OFF2:
1719 case ID_LED_ON1_OFF2:
1720 case ID_LED_OFF1_OFF2:
1721 mac->ledctl_mode2 &= ~(ledctl_mask << (i << 3));
1722 mac->ledctl_mode2 |= ledctl_off << (i << 3);
1730 return E1000_SUCCESS;
1734 * e1000_setup_led_generic - Configures SW controllable LED
1735 * @hw: pointer to the HW structure
1737 * This prepares the SW controllable LED for use and saves the current state
1738 * of the LED so it can be later restored.
1740 s32 e1000_setup_led_generic(struct e1000_hw *hw)
1744 DEBUGFUNC("e1000_setup_led_generic");
1746 if (hw->mac.ops.setup_led != e1000_setup_led_generic)
1747 return -E1000_ERR_CONFIG;
1749 if (hw->phy.media_type == e1000_media_type_fiber) {
1750 ledctl = E1000_READ_REG(hw, E1000_LEDCTL);
1751 hw->mac.ledctl_default = ledctl;
1753 ledctl &= ~(E1000_LEDCTL_LED0_IVRT | E1000_LEDCTL_LED0_BLINK |
1754 E1000_LEDCTL_LED0_MODE_MASK);
1755 ledctl |= (E1000_LEDCTL_MODE_LED_OFF <<
1756 E1000_LEDCTL_LED0_MODE_SHIFT);
1757 E1000_WRITE_REG(hw, E1000_LEDCTL, ledctl);
1758 } else if (hw->phy.media_type == e1000_media_type_copper) {
1759 E1000_WRITE_REG(hw, E1000_LEDCTL, hw->mac.ledctl_mode1);
1762 return E1000_SUCCESS;
1766 * e1000_cleanup_led_generic - Set LED config to default operation
1767 * @hw: pointer to the HW structure
1769 * Remove the current LED configuration and set the LED configuration
1770 * to the default value, saved from the EEPROM.
1772 s32 e1000_cleanup_led_generic(struct e1000_hw *hw)
1774 DEBUGFUNC("e1000_cleanup_led_generic");
1776 E1000_WRITE_REG(hw, E1000_LEDCTL, hw->mac.ledctl_default);
1777 return E1000_SUCCESS;
1781 * e1000_blink_led_generic - Blink LED
1782 * @hw: pointer to the HW structure
1784 * Blink the LEDs which are set to be on.
1786 s32 e1000_blink_led_generic(struct e1000_hw *hw)
1788 u32 ledctl_blink = 0;
1791 DEBUGFUNC("e1000_blink_led_generic");
1793 if (hw->phy.media_type == e1000_media_type_fiber) {
1794 /* always blink LED0 for PCI-E fiber */
1795 ledctl_blink = E1000_LEDCTL_LED0_BLINK |
1796 (E1000_LEDCTL_MODE_LED_ON << E1000_LEDCTL_LED0_MODE_SHIFT);
1798 /* Set the blink bit for each LED that's "on" (0x0E)
1799 * (or "off" if inverted) in ledctl_mode2. The blink
1800 * logic in hardware only works when mode is set to "on"
1801 * so it must be changed accordingly when the mode is
1802 * "off" and inverted.
1804 ledctl_blink = hw->mac.ledctl_mode2;
1805 for (i = 0; i < 32; i += 8) {
1806 u32 mode = (hw->mac.ledctl_mode2 >> i) &
1807 E1000_LEDCTL_LED0_MODE_MASK;
1808 u32 led_default = hw->mac.ledctl_default >> i;
1810 if ((!(led_default & E1000_LEDCTL_LED0_IVRT) &&
1811 (mode == E1000_LEDCTL_MODE_LED_ON)) ||
1812 ((led_default & E1000_LEDCTL_LED0_IVRT) &&
1813 (mode == E1000_LEDCTL_MODE_LED_OFF))) {
1815 ~(E1000_LEDCTL_LED0_MODE_MASK << i);
1816 ledctl_blink |= (E1000_LEDCTL_LED0_BLINK |
1817 E1000_LEDCTL_MODE_LED_ON) << i;
1822 E1000_WRITE_REG(hw, E1000_LEDCTL, ledctl_blink);
1824 return E1000_SUCCESS;
1828 * e1000_led_on_generic - Turn LED on
1829 * @hw: pointer to the HW structure
1833 s32 e1000_led_on_generic(struct e1000_hw *hw)
1837 DEBUGFUNC("e1000_led_on_generic");
1839 switch (hw->phy.media_type) {
1840 case e1000_media_type_fiber:
1841 ctrl = E1000_READ_REG(hw, E1000_CTRL);
1842 ctrl &= ~E1000_CTRL_SWDPIN0;
1843 ctrl |= E1000_CTRL_SWDPIO0;
1844 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
1846 case e1000_media_type_copper:
1847 E1000_WRITE_REG(hw, E1000_LEDCTL, hw->mac.ledctl_mode2);
1853 return E1000_SUCCESS;
1857 * e1000_led_off_generic - Turn LED off
1858 * @hw: pointer to the HW structure
1862 s32 e1000_led_off_generic(struct e1000_hw *hw)
1866 DEBUGFUNC("e1000_led_off_generic");
1868 switch (hw->phy.media_type) {
1869 case e1000_media_type_fiber:
1870 ctrl = E1000_READ_REG(hw, E1000_CTRL);
1871 ctrl |= E1000_CTRL_SWDPIN0;
1872 ctrl |= E1000_CTRL_SWDPIO0;
1873 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
1875 case e1000_media_type_copper:
1876 E1000_WRITE_REG(hw, E1000_LEDCTL, hw->mac.ledctl_mode1);
1882 return E1000_SUCCESS;
1886 * e1000_set_pcie_no_snoop_generic - Set PCI-express capabilities
1887 * @hw: pointer to the HW structure
1888 * @no_snoop: bitmap of snoop events
1890 * Set the PCI-express register to snoop for events enabled in 'no_snoop'.
1892 void e1000_set_pcie_no_snoop_generic(struct e1000_hw *hw, u32 no_snoop)
1896 DEBUGFUNC("e1000_set_pcie_no_snoop_generic");
1899 gcr = E1000_READ_REG(hw, E1000_GCR);
1900 gcr &= ~(PCIE_NO_SNOOP_ALL);
1902 E1000_WRITE_REG(hw, E1000_GCR, gcr);
1907 * e1000_disable_pcie_master_generic - Disables PCI-express master access
1908 * @hw: pointer to the HW structure
1910 * Returns E1000_SUCCESS if successful, else returns -10
1911 * (-E1000_ERR_MASTER_REQUESTS_PENDING) if master disable bit has not caused
1912 * the master requests to be disabled.
1914 * Disables PCI-Express master access and verifies there are no pending
1917 s32 e1000_disable_pcie_master_generic(struct e1000_hw *hw)
1920 s32 timeout = MASTER_DISABLE_TIMEOUT;
1922 DEBUGFUNC("e1000_disable_pcie_master_generic");
1924 ctrl = E1000_READ_REG(hw, E1000_CTRL);
1925 ctrl |= E1000_CTRL_GIO_MASTER_DISABLE;
1926 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
1929 if (!(E1000_READ_REG(hw, E1000_STATUS) &
1930 E1000_STATUS_GIO_MASTER_ENABLE))
1937 DEBUGOUT("Master requests are pending.\n");
1938 return -E1000_ERR_MASTER_REQUESTS_PENDING;
1941 return E1000_SUCCESS;
1945 * e1000_reset_adaptive_generic - Reset Adaptive Interframe Spacing
1946 * @hw: pointer to the HW structure
1948 * Reset the Adaptive Interframe Spacing throttle to default values.
1950 void e1000_reset_adaptive_generic(struct e1000_hw *hw)
1952 struct e1000_mac_info *mac = &hw->mac;
1954 DEBUGFUNC("e1000_reset_adaptive_generic");
1956 if (!mac->adaptive_ifs) {
1957 DEBUGOUT("Not in Adaptive IFS mode!\n");
1961 mac->current_ifs_val = 0;
1962 mac->ifs_min_val = IFS_MIN;
1963 mac->ifs_max_val = IFS_MAX;
1964 mac->ifs_step_size = IFS_STEP;
1965 mac->ifs_ratio = IFS_RATIO;
1967 mac->in_ifs_mode = false;
1968 E1000_WRITE_REG(hw, E1000_AIT, 0);
1972 * e1000_update_adaptive_generic - Update Adaptive Interframe Spacing
1973 * @hw: pointer to the HW structure
1975 * Update the Adaptive Interframe Spacing Throttle value based on the
1976 * time between transmitted packets and time between collisions.
1978 void e1000_update_adaptive_generic(struct e1000_hw *hw)
1980 struct e1000_mac_info *mac = &hw->mac;
1982 DEBUGFUNC("e1000_update_adaptive_generic");
1984 if (!mac->adaptive_ifs) {
1985 DEBUGOUT("Not in Adaptive IFS mode!\n");
1989 if ((mac->collision_delta * mac->ifs_ratio) > mac->tx_packet_delta) {
1990 if (mac->tx_packet_delta > MIN_NUM_XMITS) {
1991 mac->in_ifs_mode = true;
1992 if (mac->current_ifs_val < mac->ifs_max_val) {
1993 if (!mac->current_ifs_val)
1994 mac->current_ifs_val = mac->ifs_min_val;
1996 mac->current_ifs_val +=
1998 E1000_WRITE_REG(hw, E1000_AIT,
1999 mac->current_ifs_val);
2003 if (mac->in_ifs_mode &&
2004 (mac->tx_packet_delta <= MIN_NUM_XMITS)) {
2005 mac->current_ifs_val = 0;
2006 mac->in_ifs_mode = false;
2007 E1000_WRITE_REG(hw, E1000_AIT, 0);
2013 * e1000_validate_mdi_setting_generic - Verify MDI/MDIx settings
2014 * @hw: pointer to the HW structure
2016 * Verify that when not using auto-negotiation that MDI/MDIx is correctly
2017 * set, which is forced to MDI mode only.
2019 static s32 e1000_validate_mdi_setting_generic(struct e1000_hw *hw)
2021 DEBUGFUNC("e1000_validate_mdi_setting_generic");
2023 if (!hw->mac.autoneg && (hw->phy.mdix == 0 || hw->phy.mdix == 3)) {
2024 DEBUGOUT("Invalid MDI setting detected\n");
2026 return -E1000_ERR_CONFIG;
2029 return E1000_SUCCESS;
2033 * e1000_validate_mdi_setting_crossover_generic - Verify MDI/MDIx settings
2034 * @hw: pointer to the HW structure
2036 * Validate the MDI/MDIx setting, allowing for auto-crossover during forced
2039 s32 e1000_validate_mdi_setting_crossover_generic(struct e1000_hw E1000_UNUSEDARG *hw)
2041 DEBUGFUNC("e1000_validate_mdi_setting_crossover_generic");
2043 return E1000_SUCCESS;
2047 * e1000_write_8bit_ctrl_reg_generic - Write a 8bit CTRL register
2048 * @hw: pointer to the HW structure
2049 * @reg: 32bit register offset such as E1000_SCTL
2050 * @offset: register offset to write to
2051 * @data: data to write at register offset
2053 * Writes an address/data control type register. There are several of these
2054 * and they all have the format address << 8 | data and bit 31 is polled for
2057 s32 e1000_write_8bit_ctrl_reg_generic(struct e1000_hw *hw, u32 reg,
2058 u32 offset, u8 data)
2060 u32 i, regvalue = 0;
2062 DEBUGFUNC("e1000_write_8bit_ctrl_reg_generic");
2064 /* Set up the address and data */
2065 regvalue = ((u32)data) | (offset << E1000_GEN_CTL_ADDRESS_SHIFT);
2066 E1000_WRITE_REG(hw, reg, regvalue);
2068 /* Poll the ready bit to see if the MDI read completed */
2069 for (i = 0; i < E1000_GEN_POLL_TIMEOUT; i++) {
2071 regvalue = E1000_READ_REG(hw, reg);
2072 if (regvalue & E1000_GEN_CTL_READY)
2075 if (!(regvalue & E1000_GEN_CTL_READY)) {
2076 DEBUGOUT1("Reg %08x did not indicate ready\n", reg);
2077 return -E1000_ERR_PHY;
2080 return E1000_SUCCESS;