Lines Matching +full:auto +full:- +full:negotiation

1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 1999 - 2006 Intel Corporation. */
88 * e1000_set_phy_type - Set the phy type member in the hw struct.
93 if (hw->mac_type == e1000_undefined) in e1000_set_phy_type()
94 return -E1000_ERR_PHY_TYPE; in e1000_set_phy_type()
96 switch (hw->phy_id) { in e1000_set_phy_type()
102 hw->phy_type = e1000_phy_m88; in e1000_set_phy_type()
105 if (hw->mac_type == e1000_82541 || in e1000_set_phy_type()
106 hw->mac_type == e1000_82541_rev_2 || in e1000_set_phy_type()
107 hw->mac_type == e1000_82547 || in e1000_set_phy_type()
108 hw->mac_type == e1000_82547_rev_2) in e1000_set_phy_type()
109 hw->phy_type = e1000_phy_igp; in e1000_set_phy_type()
112 hw->phy_type = e1000_phy_8211; in e1000_set_phy_type()
115 hw->phy_type = e1000_phy_8201; in e1000_set_phy_type()
119 hw->phy_type = e1000_phy_undefined; in e1000_set_phy_type()
120 return -E1000_ERR_PHY_TYPE; in e1000_set_phy_type()
127 * e1000_phy_init_script - IGP phy init script - initializes the GbE PHY
134 if (hw->phy_init_script) { in e1000_phy_init_script()
149 switch (hw->mac_type) { in e1000_phy_init_script()
177 if (hw->mac_type == e1000_82547) { in e1000_phy_init_script()
196 coarse -= in e1000_phy_init_script()
198 fine -= IGP01E1000_ANALOG_FUSE_FINE_1; in e1000_phy_init_script()
201 fine -= IGP01E1000_ANALOG_FUSE_FINE_10; in e1000_phy_init_script()
221 * e1000_set_mac_type - Set the mac type member in the hw struct.
226 switch (hw->device_id) { in e1000_set_mac_type()
228 switch (hw->revision_id) { in e1000_set_mac_type()
230 hw->mac_type = e1000_82542_rev2_0; in e1000_set_mac_type()
233 hw->mac_type = e1000_82542_rev2_1; in e1000_set_mac_type()
237 return -E1000_ERR_MAC_TYPE; in e1000_set_mac_type()
242 hw->mac_type = e1000_82543; in e1000_set_mac_type()
248 hw->mac_type = e1000_82544; in e1000_set_mac_type()
255 hw->mac_type = e1000_82540; in e1000_set_mac_type()
259 hw->mac_type = e1000_82545; in e1000_set_mac_type()
264 hw->mac_type = e1000_82545_rev_3; in e1000_set_mac_type()
269 hw->mac_type = e1000_82546; in e1000_set_mac_type()
277 hw->mac_type = e1000_82546_rev_3; in e1000_set_mac_type()
282 hw->mac_type = e1000_82541; in e1000_set_mac_type()
288 hw->mac_type = e1000_82541_rev_2; in e1000_set_mac_type()
292 hw->mac_type = e1000_82547; in e1000_set_mac_type()
295 hw->mac_type = e1000_82547_rev_2; in e1000_set_mac_type()
298 hw->mac_type = e1000_ce4100; in e1000_set_mac_type()
302 return -E1000_ERR_MAC_TYPE; in e1000_set_mac_type()
305 switch (hw->mac_type) { in e1000_set_mac_type()
310 hw->asf_firmware_present = true; in e1000_set_mac_type()
319 if (hw->mac_type == e1000_82543) in e1000_set_mac_type()
320 hw->bad_tx_carr_stats_fd = true; in e1000_set_mac_type()
322 if (hw->mac_type > e1000_82544) in e1000_set_mac_type()
323 hw->has_smbus = true; in e1000_set_mac_type()
329 * e1000_set_media_type - Set media type and TBI compatibility.
336 if (hw->mac_type != e1000_82543) { in e1000_set_media_type()
338 hw->tbi_compatibility_en = false; in e1000_set_media_type()
341 switch (hw->device_id) { in e1000_set_media_type()
344 hw->media_type = e1000_media_type_internal_serdes; in e1000_set_media_type()
347 switch (hw->mac_type) { in e1000_set_media_type()
350 hw->media_type = e1000_media_type_fiber; in e1000_set_media_type()
353 hw->media_type = e1000_media_type_copper; in e1000_set_media_type()
358 hw->media_type = e1000_media_type_fiber; in e1000_set_media_type()
360 hw->tbi_compatibility_en = false; in e1000_set_media_type()
362 hw->media_type = e1000_media_type_copper; in e1000_set_media_type()
370 * e1000_reset_hw - reset the hardware completely
384 if (hw->mac_type == e1000_82542_rev2_0) { in e1000_reset_hw()
402 hw->tbi_compatibility_on = false; in e1000_reset_hw()
412 if ((hw->mac_type == e1000_82541) || (hw->mac_type == e1000_82547)) { in e1000_reset_hw()
420 * the current PCI configuration. The global reset bit is self- in e1000_reset_hw()
425 switch (hw->mac_type) { in e1000_reset_hw()
432 /* These controllers can't ack the 64-bit write when issuing the in e1000_reset_hw()
433 * reset, so use IO-mapping as a workaround to issue the reset in e1000_reset_hw()
448 /* After MAC reset, force reload of EEPROM to restore power-on settings in e1000_reset_hw()
452 switch (hw->mac_type) { in e1000_reset_hw()
474 /* Auto read done will delay 5ms or poll based on mac type */ in e1000_reset_hw()
482 if (hw->mac_type >= e1000_82540) { in e1000_reset_hw()
488 if ((hw->mac_type == e1000_82541) || (hw->mac_type == e1000_82547)) { in e1000_reset_hw()
506 if (hw->mac_type == e1000_82542_rev2_0) { in e1000_reset_hw()
507 if (hw->pci_cmd_word & PCI_COMMAND_INVALIDATE) in e1000_reset_hw()
515 * e1000_init_hw - Performs basic configuration of the adapter.
519 * post-reset uninitialized state. Initializes the receive address registers,
521 * configuration and flow control settings. Clears all on-chip counters. Leaves
544 if (hw->mac_type < e1000_82545_rev_3) in e1000_init_hw()
549 if (hw->mac_type == e1000_82542_rev2_0) { in e1000_init_hw()
558 * Receive Address Registers (RARs 0 - 15). in e1000_init_hw()
563 if (hw->mac_type == e1000_82542_rev2_0) { in e1000_init_hw()
567 if (hw->pci_cmd_word & PCI_COMMAND_INVALIDATE) in e1000_init_hw()
587 if (hw->dma_fairness && hw->mac_type <= e1000_82543) { in e1000_init_hw()
592 switch (hw->mac_type) { in e1000_init_hw()
597 /* Workaround for PCI-X problem when BIOS sets MMRBC in e1000_init_hw()
600 if (hw->bus_type == e1000_bus_type_pcix && in e1000_init_hw()
609 /* Set the transmit descriptor write-back policy */ in e1000_init_hw()
610 if (hw->mac_type > e1000_82544) { in e1000_init_hw()
625 if (hw->device_id == E1000_DEV_ID_82546GB_QUAD_COPPER || in e1000_init_hw()
626 hw->device_id == E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3) { in e1000_init_hw()
639 * e1000_adjust_serdes_amplitude - Adjust SERDES output amplitude based on EEPROM setting.
647 if (hw->media_type != e1000_media_type_internal_serdes) in e1000_adjust_serdes_amplitude()
650 switch (hw->mac_type) { in e1000_adjust_serdes_amplitude()
676 * e1000_setup_link - Configures flow control and link settings.
679 * Determines which flow control settings to use. Calls the appropriate media-
694 * disabling auto-negotiation, and the direction of the in e1000_setup_link()
695 * SW defined pins. If there is no SW over-ride of the flow in e1000_setup_link()
696 * control setting, then the variable hw->fc will in e1000_setup_link()
699 if (hw->fc == E1000_FC_DEFAULT) { in e1000_setup_link()
704 return -E1000_ERR_EEPROM; in e1000_setup_link()
707 hw->fc = E1000_FC_NONE; in e1000_setup_link()
710 hw->fc = E1000_FC_TX_PAUSE; in e1000_setup_link()
712 hw->fc = E1000_FC_FULL; in e1000_setup_link()
719 if (hw->mac_type == e1000_82542_rev2_0) in e1000_setup_link()
720 hw->fc &= (~E1000_FC_TX_PAUSE); in e1000_setup_link()
722 if ((hw->mac_type < e1000_82543) && (hw->report_tx_early == 1)) in e1000_setup_link()
723 hw->fc &= (~E1000_FC_RX_PAUSE); in e1000_setup_link()
725 hw->original_fc = hw->fc; in e1000_setup_link()
727 e_dbg("After fix-ups FlowControl is now = %x\n", hw->fc); in e1000_setup_link()
736 if (hw->mac_type == e1000_82543) { in e1000_setup_link()
741 return -E1000_ERR_EEPROM; in e1000_setup_link()
749 ret_val = (hw->media_type == e1000_media_type_copper) ? in e1000_setup_link()
763 ew32(FCTTV, hw->fc_pause_time); in e1000_setup_link()
771 if (!(hw->fc & E1000_FC_TX_PAUSE)) { in e1000_setup_link()
779 if (hw->fc_send_xon) { in e1000_setup_link()
780 ew32(FCRTL, (hw->fc_low_water | E1000_FCRTL_XONE)); in e1000_setup_link()
781 ew32(FCRTH, hw->fc_high_water); in e1000_setup_link()
783 ew32(FCRTL, hw->fc_low_water); in e1000_setup_link()
784 ew32(FCRTH, hw->fc_high_water); in e1000_setup_link()
791 * e1000_setup_fiber_serdes_link - prepare fiber or serdes link
814 if (hw->media_type == e1000_media_type_fiber) in e1000_setup_fiber_serdes_link()
815 signal = (hw->mac_type > e1000_82544) ? E1000_CTRL_SWDPIN1 : 0; in e1000_setup_fiber_serdes_link()
832 * the device accordingly. If auto-negotiation is enabled, then in e1000_setup_fiber_serdes_link()
834 * the Tranmsit Config Word Register (TXCW) and re-start in e1000_setup_fiber_serdes_link()
835 * auto-negotiation. However, if auto-negotiation is disabled, then in e1000_setup_fiber_serdes_link()
847 switch (hw->fc) { in e1000_setup_fiber_serdes_link()
849 /* Flow ctrl is completely disabled by a software over-ride */ in e1000_setup_fiber_serdes_link()
854 * a software over-ride. Since there really isn't a way to in e1000_setup_fiber_serdes_link()
864 * by a software over-ride. in e1000_setup_fiber_serdes_link()
870 * over-ride. in e1000_setup_fiber_serdes_link()
876 return -E1000_ERR_CONFIG; in e1000_setup_fiber_serdes_link()
879 /* Since auto-negotiation is enabled, take the link out of reset (the in e1000_setup_fiber_serdes_link()
881 * will restart auto-negotiation. If auto-negotiation is successful in e1000_setup_fiber_serdes_link()
882 * then the link-up status bit will be set and the flow control enable in e1000_setup_fiber_serdes_link()
885 e_dbg("Auto-negotiation enabled\n"); in e1000_setup_fiber_serdes_link()
891 hw->txcw = txcw; in e1000_setup_fiber_serdes_link()
895 * "Link-Up" indication in the Device Status Register. Time-out if a in e1000_setup_fiber_serdes_link()
896 * link isn't seen in 500 milliseconds seconds (Auto-negotiation should in e1000_setup_fiber_serdes_link()
901 if (hw->media_type == e1000_media_type_internal_serdes || in e1000_setup_fiber_serdes_link()
911 e_dbg("Never got a valid link from auto-neg!!!\n"); in e1000_setup_fiber_serdes_link()
912 hw->autoneg_failed = 1; in e1000_setup_fiber_serdes_link()
916 * communicate with non-autonegotiating link partners. in e1000_setup_fiber_serdes_link()
923 hw->autoneg_failed = 0; in e1000_setup_fiber_serdes_link()
925 hw->autoneg_failed = 0; in e1000_setup_fiber_serdes_link()
935 * e1000_copper_link_rtl_setup - Copper link setup for e1000_phy_rtl series.
959 switch (hw->phy_type) { in gbe_dhg_phy_setup()
996 * e1000_copper_link_preconfig - early configuration for copper
1012 if (hw->mac_type > e1000_82543) { in e1000_copper_link_preconfig()
1031 e_dbg("Phy ID = %x\n", hw->phy_id); in e1000_copper_link_preconfig()
1038 if ((hw->mac_type == e1000_82545_rev_3) || in e1000_copper_link_preconfig()
1039 (hw->mac_type == e1000_82546_rev_3)) { in e1000_copper_link_preconfig()
1047 if (hw->mac_type <= e1000_82543 || in e1000_copper_link_preconfig()
1048 hw->mac_type == e1000_82541 || hw->mac_type == e1000_82547 || in e1000_copper_link_preconfig()
1049 hw->mac_type == e1000_82541_rev_2 || in e1000_copper_link_preconfig()
1050 hw->mac_type == e1000_82547_rev_2) in e1000_copper_link_preconfig()
1051 hw->phy_reset_disable = false; in e1000_copper_link_preconfig()
1057 * e1000_copper_link_igp_setup - Copper link setup for e1000_phy_igp series.
1066 if (hw->phy_reset_disable) in e1000_copper_link_igp_setup()
1084 if (hw->phy_type == e1000_phy_igp) { in e1000_copper_link_igp_setup()
1093 /* Configure mdi-mdix settings */ in e1000_copper_link_igp_setup()
1098 if ((hw->mac_type == e1000_82541) || (hw->mac_type == e1000_82547)) { in e1000_copper_link_igp_setup()
1099 hw->dsp_config_state = e1000_dsp_config_disabled; in e1000_copper_link_igp_setup()
1104 hw->mdix = 1; in e1000_copper_link_igp_setup()
1107 hw->dsp_config_state = e1000_dsp_config_enabled; in e1000_copper_link_igp_setup()
1110 switch (hw->mdix) { in e1000_copper_link_igp_setup()
1127 /* set auto-master slave resolution settings */ in e1000_copper_link_igp_setup()
1128 if (hw->autoneg) { in e1000_copper_link_igp_setup()
1129 e1000_ms_type phy_ms_setting = hw->master_slave; in e1000_copper_link_igp_setup()
1131 if (hw->ffe_config_state == e1000_ffe_config_active) in e1000_copper_link_igp_setup()
1132 hw->ffe_config_state = e1000_ffe_config_enabled; in e1000_copper_link_igp_setup()
1134 if (hw->dsp_config_state == e1000_dsp_config_activated) in e1000_copper_link_igp_setup()
1135 hw->dsp_config_state = e1000_dsp_config_enabled; in e1000_copper_link_igp_setup()
1138 * should disable SmartSpeed and enable Auto MasterSlave in e1000_copper_link_igp_setup()
1141 if (hw->autoneg_advertised == ADVERTISE_1000_FULL) { in e1000_copper_link_igp_setup()
1154 /* Set auto Master/Slave resolution process */ in e1000_copper_link_igp_setup()
1171 hw->original_master_slave = (phy_data & CR_1000T_MS_ENABLE) ? in e1000_copper_link_igp_setup()
1199 * e1000_copper_link_mgp_setup - Copper link setup for e1000_phy_m88 series.
1207 if (hw->phy_reset_disable) in e1000_copper_link_mgp_setup()
1210 /* Enable CRS on TX. This must be set for half-duplex operation. */ in e1000_copper_link_mgp_setup()
1218 * MDI/MDI-X = 0 (default) in e1000_copper_link_mgp_setup()
1219 * 0 - Auto for all speeds in e1000_copper_link_mgp_setup()
1220 * 1 - MDI mode in e1000_copper_link_mgp_setup()
1221 * 2 - MDI-X mode in e1000_copper_link_mgp_setup()
1222 * 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes) in e1000_copper_link_mgp_setup()
1226 switch (hw->mdix) { in e1000_copper_link_mgp_setup()
1245 * 0 - Disabled in e1000_copper_link_mgp_setup()
1246 * 1 - Enabled in e1000_copper_link_mgp_setup()
1249 if (hw->disable_polarity_correction == 1) in e1000_copper_link_mgp_setup()
1255 if (hw->phy_revision < M88E1011_I_REV_4) { in e1000_copper_link_mgp_setup()
1267 if ((hw->phy_revision == E1000_REVISION_2) && in e1000_copper_link_mgp_setup()
1268 (hw->phy_id == M88E1111_I_PHY_ID)) { in e1000_copper_link_mgp_setup()
1302 * e1000_copper_link_autoneg - setup auto-neg
1305 * Setup auto-negotiation and flow control advertisements,
1306 * and then perform auto-negotiation.
1313 /* Perform some bounds checking on the hw->autoneg_advertised in e1000_copper_link_autoneg()
1316 hw->autoneg_advertised &= AUTONEG_ADVERTISE_SPEED_DEFAULT; in e1000_copper_link_autoneg()
1321 if (hw->autoneg_advertised == 0) in e1000_copper_link_autoneg()
1322 hw->autoneg_advertised = AUTONEG_ADVERTISE_SPEED_DEFAULT; in e1000_copper_link_autoneg()
1325 if (hw->phy_type == e1000_phy_8201) in e1000_copper_link_autoneg()
1326 hw->autoneg_advertised &= AUTONEG_ADVERTISE_10_100_ALL; in e1000_copper_link_autoneg()
1328 e_dbg("Reconfiguring auto-neg advertisement params\n"); in e1000_copper_link_autoneg()
1331 e_dbg("Error Setting up Auto-Negotiation\n"); in e1000_copper_link_autoneg()
1334 e_dbg("Restarting Auto-Neg\n"); in e1000_copper_link_autoneg()
1336 /* Restart auto-negotiation by setting the Auto Neg Enable bit and in e1000_copper_link_autoneg()
1337 * the Auto Neg Restart bit in the PHY control register. in e1000_copper_link_autoneg()
1348 /* Does the user want to wait for Auto-Neg to complete here, or in e1000_copper_link_autoneg()
1351 if (hw->wait_autoneg_complete) { in e1000_copper_link_autoneg()
1360 hw->get_link_status = true; in e1000_copper_link_autoneg()
1366 * e1000_copper_link_postconfig - post link setup
1382 if ((hw->mac_type >= e1000_82544) && (hw->mac_type != e1000_ce4100)) { in e1000_copper_link_postconfig()
1398 if (hw->phy_type == e1000_phy_igp) { in e1000_copper_link_postconfig()
1410 * e1000_setup_copper_link - phy/speed/duplex setting
1426 if (hw->phy_type == e1000_phy_igp) { in e1000_setup_copper_link()
1430 } else if (hw->phy_type == e1000_phy_m88) { in e1000_setup_copper_link()
1442 if (hw->autoneg) { in e1000_setup_copper_link()
1489 * e1000_phy_setup_autoneg - phy settings
1500 /* Read the MII Auto-Neg Advertisement Register (Address 4). */ in e1000_phy_setup_autoneg()
1505 /* Read the MII 1000Base-T Control Register (Address 9). */ in e1000_phy_setup_autoneg()
1509 else if (hw->phy_type == e1000_phy_8201) in e1000_phy_setup_autoneg()
1519 /* First we clear all the 10/100 mb speed bits in the Auto-Neg in e1000_phy_setup_autoneg()
1521 * the 1000Base-T Control Register (Address 9). in e1000_phy_setup_autoneg()
1526 e_dbg("autoneg_advertised %x\n", hw->autoneg_advertised); in e1000_phy_setup_autoneg()
1529 if (hw->autoneg_advertised & ADVERTISE_10_HALF) { in e1000_phy_setup_autoneg()
1535 if (hw->autoneg_advertised & ADVERTISE_10_FULL) { in e1000_phy_setup_autoneg()
1541 if (hw->autoneg_advertised & ADVERTISE_100_HALF) { in e1000_phy_setup_autoneg()
1547 if (hw->autoneg_advertised & ADVERTISE_100_FULL) { in e1000_phy_setup_autoneg()
1553 if (hw->autoneg_advertised & ADVERTISE_1000_HALF) { in e1000_phy_setup_autoneg()
1559 if (hw->autoneg_advertised & ADVERTISE_1000_FULL) { in e1000_phy_setup_autoneg()
1566 * auto-negotiation is enabled, then software will have to set the in e1000_phy_setup_autoneg()
1567 * "PAUSE" bits to the correct value in the Auto-Negotiation in e1000_phy_setup_autoneg()
1568 * Advertisement Register (PHY_AUTONEG_ADV) and re-start in e1000_phy_setup_autoneg()
1569 * auto-negotiation. in e1000_phy_setup_autoneg()
1581 switch (hw->fc) { in e1000_phy_setup_autoneg()
1584 * software over-ride. in e1000_phy_setup_autoneg()
1590 * disabled, by a software over-ride. in e1000_phy_setup_autoneg()
1602 * disabled, by a software over-ride. in e1000_phy_setup_autoneg()
1609 * over-ride. in e1000_phy_setup_autoneg()
1615 return -E1000_ERR_CONFIG; in e1000_phy_setup_autoneg()
1622 e_dbg("Auto-Neg Advertising %x\n", mii_autoneg_adv_reg); in e1000_phy_setup_autoneg()
1624 if (hw->phy_type == e1000_phy_8201) { in e1000_phy_setup_autoneg()
1637 * e1000_phy_force_speed_duplex - force link settings
1640 * Force PHY speed and duplex settings to hw->forced_speed_duplex
1652 hw->fc = E1000_FC_NONE; in e1000_phy_force_speed_duplex()
1654 e_dbg("hw->fc = %d\n", hw->fc); in e1000_phy_force_speed_duplex()
1663 /* Clear the Auto Speed Detect Enable bit. */ in e1000_phy_force_speed_duplex()
1676 if (hw->forced_speed_duplex == e1000_100_full || in e1000_phy_force_speed_duplex()
1677 hw->forced_speed_duplex == e1000_10_full) { in e1000_phy_force_speed_duplex()
1694 if (hw->forced_speed_duplex == e1000_100_full || in e1000_phy_force_speed_duplex()
1695 hw->forced_speed_duplex == e1000_100_half) { in e1000_phy_force_speed_duplex()
1714 if (hw->phy_type == e1000_phy_m88) { in e1000_phy_force_speed_duplex()
1720 /* Clear Auto-Crossover to force MDI manually. M88E1000 requires in e1000_phy_force_speed_duplex()
1734 /* Disable MDI-X support for 10/100 */ in e1000_phy_force_speed_duplex()
1736 /* Clear Auto-Crossover to force MDI manually. IGP requires MDI in e1000_phy_force_speed_duplex()
1761 * Since we are forcing speed and duplex, Auto-Neg is not enabled. in e1000_phy_force_speed_duplex()
1767 if (hw->wait_autoneg_complete) { in e1000_phy_force_speed_duplex()
1773 for (i = PHY_FORCE_TIME; i > 0; i--) { in e1000_phy_force_speed_duplex()
1774 /* Read the MII Status Register and wait for Auto-Neg in e1000_phy_force_speed_duplex()
1791 if ((i == 0) && (hw->phy_type == e1000_phy_m88)) { in e1000_phy_force_speed_duplex()
1801 /* This loop will early-out if the link condition has been in e1000_phy_force_speed_duplex()
1804 for (i = PHY_FORCE_TIME; i > 0; i--) { in e1000_phy_force_speed_duplex()
1808 /* Read the MII Status Register and wait for Auto-Neg in e1000_phy_force_speed_duplex()
1823 if (hw->phy_type == e1000_phy_m88) { in e1000_phy_force_speed_duplex()
1824 /* Because we reset the PHY above, we need to re-force TX_CLK in in e1000_phy_force_speed_duplex()
1857 if ((hw->mac_type == e1000_82544 || in e1000_phy_force_speed_duplex()
1858 hw->mac_type == e1000_82543) && in e1000_phy_force_speed_duplex()
1859 (!hw->autoneg) && in e1000_phy_force_speed_duplex()
1860 (hw->forced_speed_duplex == e1000_10_full || in e1000_phy_force_speed_duplex()
1861 hw->forced_speed_duplex == e1000_10_half)) { in e1000_phy_force_speed_duplex()
1871 * e1000_config_collision_dist - set collision distance register
1882 if (hw->mac_type < e1000_82543) in e1000_config_collision_dist()
1897 * e1000_config_mac_to_phy - sync phy and mac settings
1910 /* 82544 or newer MAC, Auto Speed Detection takes care of in e1000_config_mac_to_phy()
1913 if ((hw->mac_type >= e1000_82544) && (hw->mac_type != e1000_ce4100)) in e1000_config_mac_to_phy()
1923 switch (hw->phy_type) { in e1000_config_mac_to_phy()
1973 * e1000_force_mac_fc - force flow control settings
1990 /* Because we didn't get link via the internal auto-negotiation in e1000_force_mac_fc()
1992 * auto-neg), we have to manually enable/disable transmit an in e1000_force_mac_fc()
1996 * according to the "hw->fc" parameter. in e1000_force_mac_fc()
2008 switch (hw->fc) { in e1000_force_mac_fc()
2025 return -E1000_ERR_CONFIG; in e1000_force_mac_fc()
2029 if (hw->mac_type == e1000_82542_rev2_0) in e1000_force_mac_fc()
2037 * e1000_config_fc_after_link_up - configure flow control after autoneg
2056 /* Check for the case where we have fiber media and auto-neg failed in e1000_config_fc_after_link_up()
2060 if (((hw->media_type == e1000_media_type_fiber) && in e1000_config_fc_after_link_up()
2061 (hw->autoneg_failed)) || in e1000_config_fc_after_link_up()
2062 ((hw->media_type == e1000_media_type_internal_serdes) && in e1000_config_fc_after_link_up()
2063 (hw->autoneg_failed)) || in e1000_config_fc_after_link_up()
2064 ((hw->media_type == e1000_media_type_copper) && in e1000_config_fc_after_link_up()
2065 (!hw->autoneg))) { in e1000_config_fc_after_link_up()
2073 /* Check for the case where we have copper media and auto-neg is in e1000_config_fc_after_link_up()
2074 * enabled. In this case, we need to check and see if Auto-Neg in e1000_config_fc_after_link_up()
2078 if ((hw->media_type == e1000_media_type_copper) && hw->autoneg) { in e1000_config_fc_after_link_up()
2092 * read both the Auto Negotiation Advertisement Register in e1000_config_fc_after_link_up()
2106 /* Two bits in the Auto Negotiation Advertisement in e1000_config_fc_after_link_up()
2107 * Register (Address 4) and two bits in the Auto in e1000_config_fc_after_link_up()
2108 * Negotiation Base Page Ability Register (Address 5) in e1000_config_fc_after_link_up()
2118 *-------|---------|-------|---------|------------------ in e1000_config_fc_after_link_up()
2137 *-------|---------|-------|---------|------------------ in e1000_config_fc_after_link_up()
2150 if (hw->original_fc == E1000_FC_FULL) { in e1000_config_fc_after_link_up()
2151 hw->fc = E1000_FC_FULL; in e1000_config_fc_after_link_up()
2154 hw->fc = E1000_FC_RX_PAUSE; in e1000_config_fc_after_link_up()
2163 *-------|---------|-------|---------|------------------ in e1000_config_fc_after_link_up()
2171 hw->fc = E1000_FC_TX_PAUSE; in e1000_config_fc_after_link_up()
2179 *-------|---------|-------|---------|------------------ in e1000_config_fc_after_link_up()
2187 hw->fc = E1000_FC_RX_PAUSE; in e1000_config_fc_after_link_up()
2213 else if ((hw->original_fc == E1000_FC_NONE || in e1000_config_fc_after_link_up()
2214 hw->original_fc == E1000_FC_TX_PAUSE) || in e1000_config_fc_after_link_up()
2215 hw->fc_strict_ieee) { in e1000_config_fc_after_link_up()
2216 hw->fc = E1000_FC_NONE; in e1000_config_fc_after_link_up()
2219 hw->fc = E1000_FC_RX_PAUSE; in e1000_config_fc_after_link_up()
2224 /* Now we need to do one last check... If we auto- in e1000_config_fc_after_link_up()
2237 hw->fc = E1000_FC_NONE; in e1000_config_fc_after_link_up()
2250 ("Copper PHY and Auto Neg has not completed.\n"); in e1000_config_fc_after_link_up()
2257 * e1000_check_for_serdes_link_generic - Check for link (Serdes)
2274 /* If we don't have link (auto-negotiation failed or link partner in e1000_check_for_serdes_link_generic()
2275 * cannot auto-negotiate), and our link partner is not trying to in e1000_check_for_serdes_link_generic()
2276 * auto-negotiate with us (we are receiving idles or data), in e1000_check_for_serdes_link_generic()
2277 * we need to force link up. We also need to give auto-negotiation in e1000_check_for_serdes_link_generic()
2282 if (hw->autoneg_failed == 0) { in e1000_check_for_serdes_link_generic()
2283 hw->autoneg_failed = 1; in e1000_check_for_serdes_link_generic()
2288 /* Disable auto-negotiation in the TXCW register */ in e1000_check_for_serdes_link_generic()
2289 ew32(TXCW, (hw->txcw & ~E1000_TXCW_ANE)); in e1000_check_for_serdes_link_generic()
2291 /* Force link-up and also force full-duplex. */ in e1000_check_for_serdes_link_generic()
2304 * sets, re-enable auto-negotiation in the TXCW register in e1000_check_for_serdes_link_generic()
2306 * in an attempt to auto-negotiate with our link partner. in e1000_check_for_serdes_link_generic()
2309 ew32(TXCW, hw->txcw); in e1000_check_for_serdes_link_generic()
2312 hw->serdes_has_link = true; in e1000_check_for_serdes_link_generic()
2314 /* If we force link for non-auto-negotiation switch, check in e1000_check_for_serdes_link_generic()
2323 hw->serdes_has_link = true; in e1000_check_for_serdes_link_generic()
2324 e_dbg("SERDES: Link up - forced.\n"); in e1000_check_for_serdes_link_generic()
2327 hw->serdes_has_link = false; in e1000_check_for_serdes_link_generic()
2328 e_dbg("SERDES: Link down - force failed.\n"); in e1000_check_for_serdes_link_generic()
2340 hw->serdes_has_link = true; in e1000_check_for_serdes_link_generic()
2341 e_dbg("SERDES: Link up - autoneg " in e1000_check_for_serdes_link_generic()
2344 hw->serdes_has_link = false; in e1000_check_for_serdes_link_generic()
2345 e_dbg("SERDES: Link down - invalid" in e1000_check_for_serdes_link_generic()
2349 hw->serdes_has_link = false; in e1000_check_for_serdes_link_generic()
2350 e_dbg("SERDES: Link down - no sync.\n"); in e1000_check_for_serdes_link_generic()
2353 hw->serdes_has_link = false; in e1000_check_for_serdes_link_generic()
2354 e_dbg("SERDES: Link down - autoneg failed\n"); in e1000_check_for_serdes_link_generic()
2384 if ((hw->media_type == e1000_media_type_fiber) || in e1000_check_for_link()
2385 (hw->media_type == e1000_media_type_internal_serdes)) { in e1000_check_for_link()
2388 if (hw->media_type == e1000_media_type_fiber) { in e1000_check_for_link()
2390 hw->get_link_status = false; in e1000_check_for_link()
2395 * registers to see if Auto-Neg has completed and/or if our link in e1000_check_for_link()
2400 if ((hw->media_type == e1000_media_type_copper) && hw->get_link_status) { in e1000_check_for_link()
2414 hw->get_link_status = false; in e1000_check_for_link()
2416 * immediately after link-up in e1000_check_for_link()
2429 if ((hw->mac_type == e1000_82544 || in e1000_check_for_link()
2430 hw->mac_type == e1000_82543) && in e1000_check_for_link()
2431 (!hw->autoneg) && in e1000_check_for_link()
2432 (hw->forced_speed_duplex == e1000_10_full || in e1000_check_for_link()
2433 hw->forced_speed_duplex == e1000_10_half)) { in e1000_check_for_link()
2451 if (!hw->autoneg) in e1000_check_for_link()
2452 return -E1000_ERR_CONFIG; in e1000_check_for_link()
2457 /* We have a M88E1000 PHY and Auto-Neg is enabled. If we in e1000_check_for_link()
2458 * have Si on board that is 82544 or newer, Auto in e1000_check_for_link()
2465 if ((hw->mac_type >= e1000_82544) && in e1000_check_for_link()
2466 (hw->mac_type != e1000_ce4100)) in e1000_check_for_link()
2477 /* Configure Flow Control now that Auto-Neg has completed. in e1000_check_for_link()
2479 * because we may have had to re-autoneg with a different link in e1000_check_for_link()
2489 * auto-negotiated link. These are conditions for checking the in e1000_check_for_link()
2496 if (hw->tbi_compatibility_en) { in e1000_check_for_link()
2511 if (hw->tbi_compatibility_on) { in e1000_check_for_link()
2518 hw->tbi_compatibility_on = false; in e1000_check_for_link()
2527 if (!hw->tbi_compatibility_on) { in e1000_check_for_link()
2528 hw->tbi_compatibility_on = true; in e1000_check_for_link()
2537 if ((hw->media_type == e1000_media_type_fiber) || in e1000_check_for_link()
2538 (hw->media_type == e1000_media_type_internal_serdes)) in e1000_check_for_link()
2558 if (hw->mac_type >= e1000_82543) { in e1000_get_speed_and_duplex()
2588 if (hw->phy_type == e1000_phy_igp && hw->speed_downgraded) { in e1000_get_speed_and_duplex()
2623 e_dbg("Waiting for Auto-Neg to complete.\n"); in e1000_wait_autoneg()
2626 for (i = PHY_AUTO_NEG_TIME; i > 0; i--) { in e1000_wait_autoneg()
2627 /* Read the MII Status Register and wait for Auto-Neg in e1000_wait_autoneg()
2645 * e1000_raise_mdi_clk - Raises the Management Data Clock
2660 * e1000_lower_mdi_clk - Lowers the Management Data Clock
2675 * e1000_shift_out_mdi_bits - Shifts data bits out to the PHY
2692 mask <<= (count - 1); in e1000_shift_out_mdi_bits()
2723 * e1000_shift_in_mdi_bits - Shifts data bits in from the PHY
2776 * e1000_read_phy_reg - read a phy register
2791 if ((hw->phy_type == e1000_phy_igp) && in e1000_read_phy_reg()
2812 const u32 phy_addr = (hw->mac_type == e1000_ce4100) ? hw->phy_addr : 1; in e1000_read_phy_reg_ex()
2816 return -E1000_ERR_PARAM; in e1000_read_phy_reg_ex()
2819 if (hw->mac_type > e1000_82543) { in e1000_read_phy_reg_ex()
2820 /* Set up Op-code, Phy Address, and register address in the MDI in e1000_read_phy_reg_ex()
2824 if (hw->mac_type == e1000_ce4100) { in e1000_read_phy_reg_ex()
2844 return -E1000_ERR_PHY; in e1000_read_phy_reg_ex()
2850 return -E1000_ERR_PHY; in e1000_read_phy_reg_ex()
2871 return -E1000_ERR_PHY; in e1000_read_phy_reg_ex()
2875 return -E1000_ERR_PHY; in e1000_read_phy_reg_ex()
2904 * need to "shift in" the 16-bit value (18 total bits) of the in e1000_read_phy_reg_ex()
2913 * e1000_write_phy_reg - write a phy register
2928 if ((hw->phy_type == e1000_phy_igp) && in e1000_write_phy_reg()
2950 const u32 phy_addr = (hw->mac_type == e1000_ce4100) ? hw->phy_addr : 1; in e1000_write_phy_reg_ex()
2954 return -E1000_ERR_PARAM; in e1000_write_phy_reg_ex()
2957 if (hw->mac_type > e1000_82543) { in e1000_write_phy_reg_ex()
2958 /* Set up Op-code, Phy Address, register address, and data in e1000_write_phy_reg_ex()
2963 if (hw->mac_type == e1000_ce4100) { in e1000_write_phy_reg_ex()
2983 return -E1000_ERR_PHY; in e1000_write_phy_reg_ex()
3004 return -E1000_ERR_PHY; in e1000_write_phy_reg_ex()
3033 * e1000_phy_hw_reset - reset the phy, hardware style
3036 * Returns the PHY to the power-on reset state
3045 if (hw->mac_type > e1000_82543) { in e1000_phy_hw_reset()
3049 * and de-assert. in e1000_phy_hw_reset()
3077 if ((hw->mac_type == e1000_82541) || (hw->mac_type == e1000_82547)) { in e1000_phy_hw_reset()
3090 * e1000_phy_reset - reset the phy to commit settings
3101 switch (hw->phy_type) { in e1000_phy_reset()
3121 if (hw->phy_type == e1000_phy_igp) in e1000_phy_reset()
3128 * e1000_detect_gig_phy - check the phy type
3139 if (hw->phy_id != 0) in e1000_detect_gig_phy()
3147 hw->phy_id = (u32)(phy_id_high << 16); in e1000_detect_gig_phy()
3153 hw->phy_id |= (u32)(phy_id_low & PHY_REVISION_MASK); in e1000_detect_gig_phy()
3154 hw->phy_revision = (u32)phy_id_low & ~PHY_REVISION_MASK; in e1000_detect_gig_phy()
3156 switch (hw->mac_type) { in e1000_detect_gig_phy()
3158 if (hw->phy_id == M88E1000_E_PHY_ID) in e1000_detect_gig_phy()
3162 if (hw->phy_id == M88E1000_I_PHY_ID) in e1000_detect_gig_phy()
3170 if (hw->phy_id == M88E1011_I_PHY_ID) in e1000_detect_gig_phy()
3174 if ((hw->phy_id == RTL8211B_PHY_ID) || in e1000_detect_gig_phy()
3175 (hw->phy_id == RTL8201N_PHY_ID) || in e1000_detect_gig_phy()
3176 (hw->phy_id == M88E1118_E_PHY_ID)) in e1000_detect_gig_phy()
3183 if (hw->phy_id == IGP01E1000_I_PHY_ID) in e1000_detect_gig_phy()
3187 e_dbg("Invalid MAC type %d\n", hw->mac_type); in e1000_detect_gig_phy()
3188 return -E1000_ERR_CONFIG; in e1000_detect_gig_phy()
3193 e_dbg("PHY ID 0x%X detected\n", hw->phy_id); in e1000_detect_gig_phy()
3196 e_dbg("Invalid PHY ID 0x%X\n", hw->phy_id); in e1000_detect_gig_phy()
3197 return -E1000_ERR_PHY; in e1000_detect_gig_phy()
3201 * e1000_phy_reset_dsp - reset DSP
3227 * e1000_phy_igp_get_info - get igp specific registers
3241 * and it stored in the hw->speed_downgraded parameter. in e1000_phy_igp_get_info()
3243 phy_info->downshift = (e1000_downshift) hw->speed_downgraded; in e1000_phy_igp_get_info()
3246 phy_info->extended_10bt_distance = e1000_10bt_ext_dist_enable_normal; in e1000_phy_igp_get_info()
3249 phy_info->polarity_correction = e1000_polarity_reversal_enabled; in e1000_phy_igp_get_info()
3256 phy_info->cable_polarity = polarity; in e1000_phy_igp_get_info()
3262 phy_info->mdix_mode = in e1000_phy_igp_get_info()
3275 phy_info->local_rx = ((phy_data & SR_1000T_LOCAL_RX_STATUS) >> in e1000_phy_igp_get_info()
3278 phy_info->remote_rx = ((phy_data & SR_1000T_REMOTE_RX_STATUS) >> in e1000_phy_igp_get_info()
3291 phy_info->cable_length = e1000_cable_length_50; in e1000_phy_igp_get_info()
3293 phy_info->cable_length = e1000_cable_length_50_80; in e1000_phy_igp_get_info()
3295 phy_info->cable_length = e1000_cable_length_80_110; in e1000_phy_igp_get_info()
3297 phy_info->cable_length = e1000_cable_length_110_140; in e1000_phy_igp_get_info()
3299 phy_info->cable_length = e1000_cable_length_140; in e1000_phy_igp_get_info()
3306 * e1000_phy_m88_get_info - get m88 specific registers
3320 * and it stored in the hw->speed_downgraded parameter. in e1000_phy_m88_get_info()
3322 phy_info->downshift = (e1000_downshift) hw->speed_downgraded; in e1000_phy_m88_get_info()
3328 phy_info->extended_10bt_distance = in e1000_phy_m88_get_info()
3334 phy_info->polarity_correction = in e1000_phy_m88_get_info()
3343 phy_info->cable_polarity = polarity; in e1000_phy_m88_get_info()
3349 phy_info->mdix_mode = in e1000_phy_m88_get_info()
3357 phy_info->cable_length = in e1000_phy_m88_get_info()
3366 phy_info->local_rx = ((phy_data & SR_1000T_LOCAL_RX_STATUS) >> in e1000_phy_m88_get_info()
3369 phy_info->remote_rx = ((phy_data & SR_1000T_REMOTE_RX_STATUS) >> in e1000_phy_m88_get_info()
3378 * e1000_phy_get_info - request phy info
3389 phy_info->cable_length = e1000_cable_length_undefined; in e1000_phy_get_info()
3390 phy_info->extended_10bt_distance = e1000_10bt_ext_dist_enable_undefined; in e1000_phy_get_info()
3391 phy_info->cable_polarity = e1000_rev_polarity_undefined; in e1000_phy_get_info()
3392 phy_info->downshift = e1000_downshift_undefined; in e1000_phy_get_info()
3393 phy_info->polarity_correction = e1000_polarity_reversal_undefined; in e1000_phy_get_info()
3394 phy_info->mdix_mode = e1000_auto_x_mode_undefined; in e1000_phy_get_info()
3395 phy_info->local_rx = e1000_1000t_rx_status_undefined; in e1000_phy_get_info()
3396 phy_info->remote_rx = e1000_1000t_rx_status_undefined; in e1000_phy_get_info()
3398 if (hw->media_type != e1000_media_type_copper) { in e1000_phy_get_info()
3400 return -E1000_ERR_CONFIG; in e1000_phy_get_info()
3413 return -E1000_ERR_CONFIG; in e1000_phy_get_info()
3416 if (hw->phy_type == e1000_phy_igp) in e1000_phy_get_info()
3418 else if ((hw->phy_type == e1000_phy_8211) || in e1000_phy_get_info()
3419 (hw->phy_type == e1000_phy_8201)) in e1000_phy_get_info()
3427 if (!hw->autoneg && (hw->mdix == 0 || hw->mdix == 3)) { in e1000_validate_mdi_setting()
3429 hw->mdix = 1; in e1000_validate_mdi_setting()
3430 return -E1000_ERR_CONFIG; in e1000_validate_mdi_setting()
3436 * e1000_init_eeprom_params - initialize sw eeprom vars
3444 struct e1000_eeprom_info *eeprom = &hw->eeprom; in e1000_init_eeprom_params()
3449 switch (hw->mac_type) { in e1000_init_eeprom_params()
3454 eeprom->type = e1000_eeprom_microwire; in e1000_init_eeprom_params()
3455 eeprom->word_size = 64; in e1000_init_eeprom_params()
3456 eeprom->opcode_bits = 3; in e1000_init_eeprom_params()
3457 eeprom->address_bits = 6; in e1000_init_eeprom_params()
3458 eeprom->delay_usec = 50; in e1000_init_eeprom_params()
3465 eeprom->type = e1000_eeprom_microwire; in e1000_init_eeprom_params()
3466 eeprom->opcode_bits = 3; in e1000_init_eeprom_params()
3467 eeprom->delay_usec = 50; in e1000_init_eeprom_params()
3469 eeprom->word_size = 256; in e1000_init_eeprom_params()
3470 eeprom->address_bits = 8; in e1000_init_eeprom_params()
3472 eeprom->word_size = 64; in e1000_init_eeprom_params()
3473 eeprom->address_bits = 6; in e1000_init_eeprom_params()
3481 eeprom->type = e1000_eeprom_spi; in e1000_init_eeprom_params()
3482 eeprom->opcode_bits = 8; in e1000_init_eeprom_params()
3483 eeprom->delay_usec = 1; in e1000_init_eeprom_params()
3485 eeprom->page_size = 32; in e1000_init_eeprom_params()
3486 eeprom->address_bits = 16; in e1000_init_eeprom_params()
3488 eeprom->page_size = 8; in e1000_init_eeprom_params()
3489 eeprom->address_bits = 8; in e1000_init_eeprom_params()
3492 eeprom->type = e1000_eeprom_microwire; in e1000_init_eeprom_params()
3493 eeprom->opcode_bits = 3; in e1000_init_eeprom_params()
3494 eeprom->delay_usec = 50; in e1000_init_eeprom_params()
3496 eeprom->word_size = 256; in e1000_init_eeprom_params()
3497 eeprom->address_bits = 8; in e1000_init_eeprom_params()
3499 eeprom->word_size = 64; in e1000_init_eeprom_params()
3500 eeprom->address_bits = 6; in e1000_init_eeprom_params()
3508 if (eeprom->type == e1000_eeprom_spi) { in e1000_init_eeprom_params()
3513 eeprom->word_size = 64; in e1000_init_eeprom_params()
3526 eeprom->word_size = 1 << (eeprom_size + EEPROM_WORD_SIZE_SHIFT); in e1000_init_eeprom_params()
3532 * e1000_raise_ee_clk - Raises the EEPROM's clock input.
3544 udelay(hw->eeprom.delay_usec); in e1000_raise_ee_clk()
3548 * e1000_lower_ee_clk - Lowers the EEPROM's clock input.
3560 udelay(hw->eeprom.delay_usec); in e1000_lower_ee_clk()
3564 * e1000_shift_out_ee_bits - Shift data bits out to the EEPROM.
3571 struct e1000_eeprom_info *eeprom = &hw->eeprom; in e1000_shift_out_ee_bits()
3579 mask = 0x01 << (count - 1); in e1000_shift_out_ee_bits()
3581 if (eeprom->type == e1000_eeprom_microwire) in e1000_shift_out_ee_bits()
3583 else if (eeprom->type == e1000_eeprom_spi) in e1000_shift_out_ee_bits()
3601 udelay(eeprom->delay_usec); in e1000_shift_out_ee_bits()
3616 * e1000_shift_in_ee_bits - Shift data bits in from the EEPROM
3655 * e1000_acquire_eeprom - Prepares EEPROM for access
3663 struct e1000_eeprom_info *eeprom = &hw->eeprom; in e1000_acquire_eeprom()
3669 if (hw->mac_type > e1000_82544) { in e1000_acquire_eeprom()
3683 return -E1000_ERR_EEPROM; in e1000_acquire_eeprom()
3689 if (eeprom->type == e1000_eeprom_microwire) { in e1000_acquire_eeprom()
3697 } else if (eeprom->type == e1000_eeprom_spi) { in e1000_acquire_eeprom()
3709 * e1000_standby_eeprom - Returns EEPROM to a "standby" state
3714 struct e1000_eeprom_info *eeprom = &hw->eeprom; in e1000_standby_eeprom()
3719 if (eeprom->type == e1000_eeprom_microwire) { in e1000_standby_eeprom()
3723 udelay(eeprom->delay_usec); in e1000_standby_eeprom()
3729 udelay(eeprom->delay_usec); in e1000_standby_eeprom()
3735 udelay(eeprom->delay_usec); in e1000_standby_eeprom()
3741 udelay(eeprom->delay_usec); in e1000_standby_eeprom()
3742 } else if (eeprom->type == e1000_eeprom_spi) { in e1000_standby_eeprom()
3747 udelay(eeprom->delay_usec); in e1000_standby_eeprom()
3751 udelay(eeprom->delay_usec); in e1000_standby_eeprom()
3756 * e1000_release_eeprom - drop chip select
3767 if (hw->eeprom.type == e1000_eeprom_spi) { in e1000_release_eeprom()
3774 udelay(hw->eeprom.delay_usec); in e1000_release_eeprom()
3775 } else if (hw->eeprom.type == e1000_eeprom_microwire) { in e1000_release_eeprom()
3778 /* CS on Microwire is active-high */ in e1000_release_eeprom()
3787 udelay(hw->eeprom.delay_usec); in e1000_release_eeprom()
3793 udelay(hw->eeprom.delay_usec); in e1000_release_eeprom()
3797 if (hw->mac_type > e1000_82544) { in e1000_release_eeprom()
3804 * e1000_spi_eeprom_ready - Reads a 16 bit word from the EEPROM.
3820 hw->eeprom.opcode_bits); in e1000_spi_eeprom_ready()
3831 /* ATMEL SPI write time could vary from 0-20mSec on 3.3V devices (and in e1000_spi_eeprom_ready()
3832 * only 0-5mSec on 5V devices) in e1000_spi_eeprom_ready()
3836 return -E1000_ERR_EEPROM; in e1000_spi_eeprom_ready()
3843 * e1000_read_eeprom - Reads a 16 bit word from the EEPROM.
3862 struct e1000_eeprom_info *eeprom = &hw->eeprom; in e1000_do_read_eeprom()
3865 if (hw->mac_type == e1000_ce4100) { in e1000_do_read_eeprom()
3874 if ((offset >= eeprom->word_size) || in e1000_do_read_eeprom()
3875 (words > eeprom->word_size - offset) || in e1000_do_read_eeprom()
3878 "size = %d\n", offset, eeprom->word_size); in e1000_do_read_eeprom()
3879 return -E1000_ERR_EEPROM; in e1000_do_read_eeprom()
3882 /* EEPROM's that don't use EERD to read require us to bit-bang the SPI in e1000_do_read_eeprom()
3886 /* Prepare the EEPROM for bit-bang reading */ in e1000_do_read_eeprom()
3888 return -E1000_ERR_EEPROM; in e1000_do_read_eeprom()
3890 /* Set up the SPI or Microwire EEPROM for bit-bang reading. We have in e1000_do_read_eeprom()
3893 if (eeprom->type == e1000_eeprom_spi) { in e1000_do_read_eeprom()
3899 return -E1000_ERR_EEPROM; in e1000_do_read_eeprom()
3907 if ((eeprom->address_bits == 8) && (offset >= 128)) in e1000_do_read_eeprom()
3911 e1000_shift_out_ee_bits(hw, read_opcode, eeprom->opcode_bits); in e1000_do_read_eeprom()
3913 eeprom->address_bits); in e1000_do_read_eeprom()
3917 * overhead of eeprom setup and tear-down. The address counter in e1000_do_read_eeprom()
3926 } else if (eeprom->type == e1000_eeprom_microwire) { in e1000_do_read_eeprom()
3931 eeprom->opcode_bits); in e1000_do_read_eeprom()
3933 eeprom->address_bits); in e1000_do_read_eeprom()
3936 * overhead of eeprom setup and tear-down. in e1000_do_read_eeprom()
3951 * e1000_validate_eeprom_checksum - Verifies that the EEPROM has a valid checksum
3966 return -E1000_ERR_EEPROM; in e1000_validate_eeprom_checksum()
3973 if ((hw->subsystem_vendor_id == 0x103C) && (eeprom_data == 0x16d6)) in e1000_validate_eeprom_checksum()
3981 return -E1000_ERR_EEPROM; in e1000_validate_eeprom_checksum()
3986 * e1000_update_eeprom_checksum - Calculates/writes the EEPROM checksum
4000 return -E1000_ERR_EEPROM; in e1000_update_eeprom_checksum()
4004 checksum = (u16)EEPROM_SUM - checksum; in e1000_update_eeprom_checksum()
4007 return -E1000_ERR_EEPROM; in e1000_update_eeprom_checksum()
4013 * e1000_write_eeprom - write words to the different EEPROM types.
4035 struct e1000_eeprom_info *eeprom = &hw->eeprom; in e1000_do_write_eeprom()
4038 if (hw->mac_type == e1000_ce4100) { in e1000_do_write_eeprom()
4047 if ((offset >= eeprom->word_size) || in e1000_do_write_eeprom()
4048 (words > eeprom->word_size - offset) || in e1000_do_write_eeprom()
4051 return -E1000_ERR_EEPROM; in e1000_do_write_eeprom()
4056 return -E1000_ERR_EEPROM; in e1000_do_write_eeprom()
4058 if (eeprom->type == e1000_eeprom_microwire) { in e1000_do_write_eeprom()
4072 * e1000_write_eeprom_spi - Writes a 16 bit word to a given offset in an SPI EEPROM.
4081 struct e1000_eeprom_info *eeprom = &hw->eeprom; in e1000_write_eeprom_spi()
4088 return -E1000_ERR_EEPROM; in e1000_write_eeprom_spi()
4095 eeprom->opcode_bits); in e1000_write_eeprom_spi()
4102 if ((eeprom->address_bits == 8) && (offset >= 128)) in e1000_write_eeprom_spi()
4105 /* Send the Write command (8-bit opcode + addr) */ in e1000_write_eeprom_spi()
4106 e1000_shift_out_ee_bits(hw, write_opcode, eeprom->opcode_bits); in e1000_write_eeprom_spi()
4109 eeprom->address_bits); in e1000_write_eeprom_spi()
4123 /* Some larger eeprom sizes are capable of a 32-byte in e1000_write_eeprom_spi()
4125 * capable of an 8-byte PAGE WRITE operation. Break the in e1000_write_eeprom_spi()
4128 if ((((offset + widx) * 2) % eeprom->page_size) == 0) { in e1000_write_eeprom_spi()
4139 * e1000_write_eeprom_microwire - Writes a 16 bit word to a given offset in a Microwire EEPROM.
4148 struct e1000_eeprom_info *eeprom = &hw->eeprom; in e1000_write_eeprom_microwire()
4153 /* Send the write enable command to the EEPROM (3-bit opcode plus in e1000_write_eeprom_microwire()
4154 * 6/8-bit dummy address beginning with 11). It's less work to include in e1000_write_eeprom_microwire()
4160 (u16)(eeprom->opcode_bits + 2)); in e1000_write_eeprom_microwire()
4162 e1000_shift_out_ee_bits(hw, 0, (u16)(eeprom->address_bits - 2)); in e1000_write_eeprom_microwire()
4168 /* Send the Write command (3-bit opcode + addr) */ in e1000_write_eeprom_microwire()
4170 eeprom->opcode_bits); in e1000_write_eeprom_microwire()
4173 eeprom->address_bits); in e1000_write_eeprom_microwire()
4196 return -E1000_ERR_EEPROM; in e1000_write_eeprom_microwire()
4206 /* Send the write disable command to the EEPROM (3-bit opcode plus in e1000_write_eeprom_microwire()
4207 * 6/8-bit dummy address beginning with 10). It's less work to include in e1000_write_eeprom_microwire()
4213 (u16)(eeprom->opcode_bits + 2)); in e1000_write_eeprom_microwire()
4215 e1000_shift_out_ee_bits(hw, 0, (u16)(eeprom->address_bits - 2)); in e1000_write_eeprom_microwire()
4221 * e1000_read_mac_addr - read the adapters MAC from eeprom
4236 return -E1000_ERR_EEPROM; in e1000_read_mac_addr()
4238 hw->perm_mac_addr[i] = (u8)(eeprom_data & 0x00FF); in e1000_read_mac_addr()
4239 hw->perm_mac_addr[i + 1] = (u8)(eeprom_data >> 8); in e1000_read_mac_addr()
4242 switch (hw->mac_type) { in e1000_read_mac_addr()
4248 hw->perm_mac_addr[5] ^= 0x01; in e1000_read_mac_addr()
4253 hw->mac_addr[i] = hw->perm_mac_addr[i]; in e1000_read_mac_addr()
4258 * e1000_init_rx_addrs - Initializes receive address filters.
4273 e1000_rar_set(hw, hw->mac_addr, 0); in e1000_init_rx_addrs()
4280 e_dbg("Clearing RAR[1-14]\n"); in e1000_init_rx_addrs()
4290 * e1000_hash_mc_addr - Hashes an address to determine its location in the multicast table
4301 switch (hw->mc_filter_type) { in e1000_hash_mc_addr()
4329 * e1000_rar_set - Puts an ethernet address into a receive address register.
4357 * addresses and undo the re-direction to manageability. in e1000_rar_set()
4360 * configure the Rx unit. Last, we re-enable the AV bits and continue in e1000_rar_set()
4363 switch (hw->mac_type) { in e1000_rar_set()
4377 * e1000_write_vfta - Writes a value to the specified offset in the VLAN filter table.
4386 if ((hw->mac_type == e1000_82544) && ((offset & 0x1) == 1)) { in e1000_write_vfta()
4387 temp = E1000_READ_REG_ARRAY(hw, VFTA, (offset - 1)); in e1000_write_vfta()
4390 E1000_WRITE_REG_ARRAY(hw, VFTA, (offset - 1), temp); in e1000_write_vfta()
4399 * e1000_clear_vfta - Clears the VLAN filter table
4421 if (hw->mac_type < e1000_82540) { in e1000_id_led_init()
4427 hw->ledctl_default = ledctl; in e1000_id_led_init()
4428 hw->ledctl_mode1 = hw->ledctl_default; in e1000_id_led_init()
4429 hw->ledctl_mode2 = hw->ledctl_default; in e1000_id_led_init()
4433 return -E1000_ERR_EEPROM; in e1000_id_led_init()
4447 hw->ledctl_mode1 &= ~(ledctl_mask << (i << 3)); in e1000_id_led_init()
4448 hw->ledctl_mode1 |= ledctl_on << (i << 3); in e1000_id_led_init()
4453 hw->ledctl_mode1 &= ~(ledctl_mask << (i << 3)); in e1000_id_led_init()
4454 hw->ledctl_mode1 |= ledctl_off << (i << 3); in e1000_id_led_init()
4464 hw->ledctl_mode2 &= ~(ledctl_mask << (i << 3)); in e1000_id_led_init()
4465 hw->ledctl_mode2 |= ledctl_on << (i << 3); in e1000_id_led_init()
4470 hw->ledctl_mode2 &= ~(ledctl_mask << (i << 3)); in e1000_id_led_init()
4471 hw->ledctl_mode2 |= ledctl_off << (i << 3); in e1000_id_led_init()
4492 switch (hw->mac_type) { in e1000_setup_led()
4505 &hw->phy_spd_default); in e1000_setup_led()
4509 (u16)(hw->phy_spd_default & in e1000_setup_led()
4515 if (hw->media_type == e1000_media_type_fiber) { in e1000_setup_led()
4518 hw->ledctl_default = ledctl; in e1000_setup_led()
4526 } else if (hw->media_type == e1000_media_type_copper) in e1000_setup_led()
4527 ew32(LEDCTL, hw->ledctl_mode1); in e1000_setup_led()
4535 * e1000_cleanup_led - Restores the saved state of the SW controlable LED.
4542 switch (hw->mac_type) { in e1000_cleanup_led()
4555 hw->phy_spd_default); in e1000_cleanup_led()
4561 ew32(LEDCTL, hw->ledctl_default); in e1000_cleanup_led()
4569 * e1000_led_on - Turns on the software controllable LED
4576 switch (hw->mac_type) { in e1000_led_on()
4585 if (hw->media_type == e1000_media_type_fiber) { in e1000_led_on()
4596 if (hw->media_type == e1000_media_type_fiber) { in e1000_led_on()
4600 } else if (hw->media_type == e1000_media_type_copper) { in e1000_led_on()
4601 ew32(LEDCTL, hw->ledctl_mode2); in e1000_led_on()
4613 * e1000_led_off - Turns off the software controllable LED
4620 switch (hw->mac_type) { in e1000_led_off()
4629 if (hw->media_type == e1000_media_type_fiber) { in e1000_led_off()
4640 if (hw->media_type == e1000_media_type_fiber) { in e1000_led_off()
4644 } else if (hw->media_type == e1000_media_type_copper) { in e1000_led_off()
4645 ew32(LEDCTL, hw->ledctl_mode1); in e1000_led_off()
4657 * e1000_clear_hw_cntrs - Clears all hardware statistics counters.
4716 if (hw->mac_type < e1000_82543) in e1000_clear_hw_cntrs()
4726 if (hw->mac_type <= e1000_82544) in e1000_clear_hw_cntrs()
4735 * e1000_reset_adaptive - Resets Adaptive IFS to its default state.
4739 * hw->ifs_params_forced to true. However, you must initialize hw->
4745 if (hw->adaptive_ifs) { in e1000_reset_adaptive()
4746 if (!hw->ifs_params_forced) { in e1000_reset_adaptive()
4747 hw->current_ifs_val = 0; in e1000_reset_adaptive()
4748 hw->ifs_min_val = IFS_MIN; in e1000_reset_adaptive()
4749 hw->ifs_max_val = IFS_MAX; in e1000_reset_adaptive()
4750 hw->ifs_step_size = IFS_STEP; in e1000_reset_adaptive()
4751 hw->ifs_ratio = IFS_RATIO; in e1000_reset_adaptive()
4753 hw->in_ifs_mode = false; in e1000_reset_adaptive()
4761 * e1000_update_adaptive - update adaptive IFS
4769 if (hw->adaptive_ifs) { in e1000_update_adaptive()
4770 if ((hw->collision_delta * hw->ifs_ratio) > hw->tx_packet_delta) { in e1000_update_adaptive()
4771 if (hw->tx_packet_delta > MIN_NUM_XMITS) { in e1000_update_adaptive()
4772 hw->in_ifs_mode = true; in e1000_update_adaptive()
4773 if (hw->current_ifs_val < hw->ifs_max_val) { in e1000_update_adaptive()
4774 if (hw->current_ifs_val == 0) in e1000_update_adaptive()
4775 hw->current_ifs_val = in e1000_update_adaptive()
4776 hw->ifs_min_val; in e1000_update_adaptive()
4778 hw->current_ifs_val += in e1000_update_adaptive()
4779 hw->ifs_step_size; in e1000_update_adaptive()
4780 ew32(AIT, hw->current_ifs_val); in e1000_update_adaptive()
4784 if (hw->in_ifs_mode && in e1000_update_adaptive()
4785 (hw->tx_packet_delta <= MIN_NUM_XMITS)) { in e1000_update_adaptive()
4786 hw->current_ifs_val = 0; in e1000_update_adaptive()
4787 hw->in_ifs_mode = false; in e1000_update_adaptive()
4806 switch (hw->mac_type) { in e1000_get_bus_info()
4809 hw->bus_type = e1000_bus_type_pci; in e1000_get_bus_info()
4810 hw->bus_speed = e1000_bus_speed_unknown; in e1000_get_bus_info()
4811 hw->bus_width = e1000_bus_width_unknown; in e1000_get_bus_info()
4815 hw->bus_type = (status & E1000_STATUS_PCIX_MODE) ? in e1000_get_bus_info()
4818 if (hw->device_id == E1000_DEV_ID_82546EB_QUAD_COPPER) { in e1000_get_bus_info()
4819 hw->bus_speed = (hw->bus_type == e1000_bus_type_pci) ? in e1000_get_bus_info()
4821 } else if (hw->bus_type == e1000_bus_type_pci) { in e1000_get_bus_info()
4822 hw->bus_speed = (status & E1000_STATUS_PCI66) ? in e1000_get_bus_info()
4827 hw->bus_speed = e1000_bus_speed_66; in e1000_get_bus_info()
4830 hw->bus_speed = e1000_bus_speed_100; in e1000_get_bus_info()
4833 hw->bus_speed = e1000_bus_speed_133; in e1000_get_bus_info()
4836 hw->bus_speed = e1000_bus_speed_reserved; in e1000_get_bus_info()
4840 hw->bus_width = (status & E1000_STATUS_BUS64) ? in e1000_get_bus_info()
4857 unsigned long io_addr = hw->io_base; in e1000_write_reg_io()
4858 unsigned long io_data = hw->io_base + 4; in e1000_write_reg_io()
4865 * e1000_get_cable_length - Estimates the cable length.
4870 * returns: - E1000_ERR_XXX
4889 if (hw->phy_type == e1000_phy_m88) { in e1000_get_cable_length()
4920 return -E1000_ERR_PHY; in e1000_get_cable_length()
4922 } else if (hw->phy_type == e1000_phy_igp) { /* For IGP PHY */ in e1000_get_cable_length()
4942 IGP01E1000_AGC_LENGTH_TABLE_SIZE - 1) || in e1000_get_cable_length()
4944 return -E1000_ERR_PHY; in e1000_get_cable_length()
4956 agc_value -= min_agc_value; in e1000_get_cable_length()
4959 agc_value /= (IGP01E1000_PHY_CHANNEL_NUM - 1); in e1000_get_cable_length()
4966 *min_length = ((e1000_igp_cable_length_table[agc_value] - in e1000_get_cable_length()
4968 (e1000_igp_cable_length_table[agc_value] - in e1000_get_cable_length()
4978 * e1000_check_polarity - Check the cable polarity
4980 * @polarity: output parameter : 0 - Polarity is not reversed
4981 * 1 - Polarity is reversed.
4983 * returns: - E1000_ERR_XXX
4998 if (hw->phy_type == e1000_phy_m88) { in e1000_check_polarity()
5008 } else if (hw->phy_type == e1000_phy_igp) { in e1000_check_polarity()
5045 * e1000_check_downshift - Check if Downshift occurred
5048 * returns: - E1000_ERR_XXX
5061 if (hw->phy_type == e1000_phy_igp) { in e1000_check_downshift()
5067 hw->speed_downgraded = in e1000_check_downshift()
5069 } else if (hw->phy_type == e1000_phy_m88) { in e1000_check_downshift()
5075 hw->speed_downgraded = (phy_data & M88E1000_PSSR_DOWNSHIFT) >> in e1000_check_downshift()
5099 if (hw->dsp_config_state != e1000_dsp_config_enabled) in e1000_1000Mb_check_cable_length()
5116 hw->dsp_config_state = e1000_dsp_config_activated; in e1000_1000Mb_check_cable_length()
5135 hw->ffe_config_state = e1000_ffe_config_active; in e1000_1000Mb_check_cable_length()
5159 * returns: - E1000_ERR_PHY if fail to read/write the PHY
5171 if (hw->phy_type != e1000_phy_igp) in e1000_config_dsp_after_link_change()
5187 if (hw->dsp_config_state == e1000_dsp_config_activated) { in e1000_config_dsp_after_link_change()
5240 hw->dsp_config_state = e1000_dsp_config_enabled; in e1000_config_dsp_after_link_change()
5243 if (hw->ffe_config_state == e1000_ffe_config_active) { in e1000_config_dsp_after_link_change()
5285 hw->ffe_config_state = e1000_ffe_config_enabled; in e1000_config_dsp_after_link_change()
5292 * e1000_set_phy_mode - Set PHY to class A mode
5297 * 2. Restart auto-negotiation or force link.
5304 if ((hw->mac_type == e1000_82545_rev_3) && in e1000_set_phy_mode()
5305 (hw->media_type == e1000_media_type_copper)) { in e1000_set_phy_mode()
5325 hw->phy_reset_disable = false; in e1000_set_phy_mode()
5333 * e1000_set_d3_lplu_state - set d3 link power state
5342 * returns: - E1000_ERR_PHY if fail to read/write the PHY
5350 if (hw->phy_type != e1000_phy_igp) in e1000_set_d3_lplu_state()
5357 if (hw->mac_type == e1000_82541_rev_2 || in e1000_set_d3_lplu_state()
5358 hw->mac_type == e1000_82547_rev_2) { in e1000_set_d3_lplu_state()
5366 if (hw->mac_type == e1000_82541_rev_2 || in e1000_set_d3_lplu_state()
5367 hw->mac_type == e1000_82547_rev_2) { in e1000_set_d3_lplu_state()
5381 if (hw->smart_speed == e1000_smart_speed_on) { in e1000_set_d3_lplu_state()
5394 } else if (hw->smart_speed == e1000_smart_speed_off) { in e1000_set_d3_lplu_state()
5408 } else if ((hw->autoneg_advertised == AUTONEG_ADVERTISE_SPEED_DEFAULT) || in e1000_set_d3_lplu_state()
5409 (hw->autoneg_advertised == AUTONEG_ADVERTISE_10_ALL) || in e1000_set_d3_lplu_state()
5410 (hw->autoneg_advertised == AUTONEG_ADVERTISE_10_100_ALL)) { in e1000_set_d3_lplu_state()
5411 if (hw->mac_type == e1000_82541_rev_2 || in e1000_set_d3_lplu_state()
5412 hw->mac_type == e1000_82547_rev_2) { in e1000_set_d3_lplu_state()
5450 switch (hw->mac_type) { in e1000_set_vco_speed()
5502 * e1000_enable_mng_pass_thru - check for bmc pass through
5506 * returns: - true/false
5512 if (hw->asf_firmware_present) { in e1000_enable_mng_pass_thru()
5545 /* This loop will early-out if the NO link condition has been met. */ in e1000_polarity_reversal_workaround()
5546 for (i = PHY_FORCE_TIME; i > 0; i--) { in e1000_polarity_reversal_workaround()
5567 /* Now we will re-enable th transmitter on the PHY */ in e1000_polarity_reversal_workaround()
5589 /* This loop will early-out if the link condition has been met. */ in e1000_polarity_reversal_workaround()
5590 for (i = PHY_FORCE_TIME; i > 0; i--) { in e1000_polarity_reversal_workaround()
5614 * Check for EEPROM Auto Read bit done.
5615 * returns: - E1000_ERR_RESET if fail to reset MAC
5629 * returns: - E1000_ERR_RESET if fail to reset MAC