Lines Matching +full:auto +full:- +full:flow +full:- +full:control

1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 1999 - 2018 Intel Corporation. */
37 * e1000e_check_reset_block_generic - Check if PHY reset is blocked
40 * Read the PHY management control register and check whether a PHY reset
54 * e1000e_get_phy_id - Retrieve the PHY ID and revision
62 struct e1000_phy_info *phy = &hw->phy; in e1000e_get_phy_id()
67 if (!phy->ops.read_reg) in e1000e_get_phy_id()
75 phy->id = (u32)(phy_id << 16); in e1000e_get_phy_id()
81 phy->id |= (u32)(phy_id & PHY_REVISION_MASK); in e1000e_get_phy_id()
82 phy->revision = (u32)(phy_id & ~PHY_REVISION_MASK); in e1000e_get_phy_id()
84 if (phy->id != 0 && phy->id != PHY_REVISION_MASK) in e1000e_get_phy_id()
94 * e1000e_phy_reset_dsp - Reset PHY DSP
112 hw->phy.retry_enabled = false; in e1000e_disable_phy_retry()
117 hw->phy.retry_enabled = true; in e1000e_enable_phy_retry()
121 * e1000e_read_phy_reg_mdic - Read MDI control register
126 * Reads the MDI control register in the PHY at offset and stores the
132 struct e1000_phy_info *phy = &hw->phy; in e1000e_read_phy_reg_mdic()
137 return -E1000_ERR_PARAM; in e1000e_read_phy_reg_mdic()
140 retry_max = phy->retry_enabled ? phy->retry_count : 0; in e1000e_read_phy_reg_mdic()
142 /* Set up Op-code, Phy Address, and register offset in the MDI in e1000e_read_phy_reg_mdic()
143 * Control register. The MAC will take care of interfacing with the in e1000e_read_phy_reg_mdic()
150 (phy->addr << E1000_MDIC_PHY_SHIFT) | in e1000e_read_phy_reg_mdic()
175 e_dbg("MDI Read offset error - requested %d, returned %d\n", in e1000e_read_phy_reg_mdic()
183 if (hw->mac.type == e1000_pch2lan) in e1000e_read_phy_reg_mdic()
197 return -E1000_ERR_PHY; in e1000e_read_phy_reg_mdic()
201 * e1000e_write_phy_reg_mdic - Write MDI control register
206 * Writes data to MDI control register in the PHY at offset.
211 struct e1000_phy_info *phy = &hw->phy; in e1000e_write_phy_reg_mdic()
216 return -E1000_ERR_PARAM; in e1000e_write_phy_reg_mdic()
219 retry_max = phy->retry_enabled ? phy->retry_count : 0; in e1000e_write_phy_reg_mdic()
221 /* Set up Op-code, Phy Address, and register offset in the MDI in e1000e_write_phy_reg_mdic()
222 * Control register. The MAC will take care of interfacing with the in e1000e_write_phy_reg_mdic()
230 (phy->addr << E1000_MDIC_PHY_SHIFT) | in e1000e_write_phy_reg_mdic()
255 e_dbg("MDI Write offset error - requested %d, returned %d\n", in e1000e_write_phy_reg_mdic()
263 if (hw->mac.type == e1000_pch2lan) in e1000e_write_phy_reg_mdic()
275 return -E1000_ERR_PHY; in e1000e_write_phy_reg_mdic()
279 * e1000e_read_phy_reg_m88 - Read m88 PHY register
292 ret_val = hw->phy.ops.acquire(hw); in e1000e_read_phy_reg_m88()
299 hw->phy.ops.release(hw); in e1000e_read_phy_reg_m88()
305 * e1000e_write_phy_reg_m88 - Write m88 PHY register
317 ret_val = hw->phy.ops.acquire(hw); in e1000e_write_phy_reg_m88()
324 hw->phy.ops.release(hw); in e1000e_write_phy_reg_m88()
330 * e1000_set_page_igp - Set page as on IGP-like PHY(s)
342 hw->phy.addr = 1; in e1000_set_page_igp()
348 * __e1000e_read_phy_reg_igp - Read igp PHY register
364 if (!hw->phy.ops.acquire) in __e1000e_read_phy_reg_igp()
367 ret_val = hw->phy.ops.acquire(hw); in __e1000e_read_phy_reg_igp()
381 hw->phy.ops.release(hw); in __e1000e_read_phy_reg_igp()
387 * e1000e_read_phy_reg_igp - Read igp PHY register
402 * e1000e_read_phy_reg_igp_locked - Read igp PHY register
416 * __e1000e_write_phy_reg_igp - Write igp PHY register
431 if (!hw->phy.ops.acquire) in __e1000e_write_phy_reg_igp()
434 ret_val = hw->phy.ops.acquire(hw); in __e1000e_write_phy_reg_igp()
447 hw->phy.ops.release(hw); in __e1000e_write_phy_reg_igp()
453 * e1000e_write_phy_reg_igp - Write igp PHY register
467 * e1000e_write_phy_reg_igp_locked - Write igp PHY register
481 * __e1000_read_kmrn_reg - Read kumeran register
499 if (!hw->phy.ops.acquire) in __e1000_read_kmrn_reg()
502 ret_val = hw->phy.ops.acquire(hw); in __e1000_read_kmrn_reg()
518 hw->phy.ops.release(hw); in __e1000_read_kmrn_reg()
524 * e1000e_read_kmrn_reg - Read kumeran register
539 * e1000e_read_kmrn_reg_locked - Read kumeran register
554 * __e1000_write_kmrn_reg - Write kumeran register
572 if (!hw->phy.ops.acquire) in __e1000_write_kmrn_reg()
575 ret_val = hw->phy.ops.acquire(hw); in __e1000_write_kmrn_reg()
587 hw->phy.ops.release(hw); in __e1000_write_kmrn_reg()
593 * e1000e_write_kmrn_reg - Write kumeran register
607 * e1000e_write_kmrn_reg_locked - Write kumeran register
621 * e1000_set_master_slave_mode - Setup PHY for Master/slave mode
637 hw->phy.original_ms_type = (phy_data & CTL1000_ENABLE_MASTER) ? in e1000_set_master_slave_mode()
641 switch (hw->phy.ms_type) { in e1000_set_master_slave_mode()
660 * e1000_copper_link_setup_82577 - Setup 82577 PHY for copper link
663 * Sets up Carrier-sense on Transmit and downshift values.
670 /* Enable CRS on Tx. This must be set for half-duplex operation. */ in e1000_copper_link_setup_82577()
690 * 0 - Auto (default) in e1000_copper_link_setup_82577()
691 * 1 - MDI mode in e1000_copper_link_setup_82577()
692 * 2 - MDI-X mode in e1000_copper_link_setup_82577()
694 switch (hw->phy.mdix) { in e1000_copper_link_setup_82577()
713 * e1000e_copper_link_setup_m88 - Setup m88 PHY's for copper link
716 * Sets up MDI/MDI-X and polarity for m88 PHY's. If necessary, transmit clock
721 struct e1000_phy_info *phy = &hw->phy; in e1000e_copper_link_setup_m88()
725 /* Enable CRS on Tx. This must be set for half-duplex operation. */ in e1000e_copper_link_setup_m88()
731 if (phy->type != e1000_phy_bm) in e1000e_copper_link_setup_m88()
735 * MDI/MDI-X = 0 (default) in e1000e_copper_link_setup_m88()
736 * 0 - Auto for all speeds in e1000e_copper_link_setup_m88()
737 * 1 - MDI mode in e1000e_copper_link_setup_m88()
738 * 2 - MDI-X mode in e1000e_copper_link_setup_m88()
739 * 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes) in e1000e_copper_link_setup_m88()
743 switch (phy->mdix) { in e1000e_copper_link_setup_m88()
762 * 0 - Disabled in e1000e_copper_link_setup_m88()
763 * 1 - Enabled in e1000e_copper_link_setup_m88()
766 if (phy->disable_polarity_correction) in e1000e_copper_link_setup_m88()
770 if (phy->type == e1000_phy_bm) { in e1000e_copper_link_setup_m88()
772 if (phy->id == BME1000_E_PHY_ID_R2) { in e1000e_copper_link_setup_m88()
779 ret_val = phy->ops.commit(hw); in e1000e_copper_link_setup_m88()
793 if ((phy->type == e1000_phy_m88) && in e1000e_copper_link_setup_m88()
794 (phy->revision < E1000_REVISION_4) && in e1000e_copper_link_setup_m88()
795 (phy->id != BME1000_E_PHY_ID_R2)) { in e1000e_copper_link_setup_m88()
796 /* Force TX_CLK in the Extended PHY Specific Control Register in e1000e_copper_link_setup_m88()
805 if ((phy->revision == 2) && (phy->id == M88E1111_I_PHY_ID)) { in e1000e_copper_link_setup_m88()
806 /* 82573L PHY - set the downshift counter to 5x. */ in e1000e_copper_link_setup_m88()
821 if ((phy->type == e1000_phy_bm) && (phy->id == BME1000_E_PHY_ID_R2)) { in e1000e_copper_link_setup_m88()
834 if (phy->ops.commit) { in e1000e_copper_link_setup_m88()
835 ret_val = phy->ops.commit(hw); in e1000e_copper_link_setup_m88()
842 if (phy->type == e1000_phy_82578) { in e1000e_copper_link_setup_m88()
847 /* 82578 PHY - set the downshift count to 1x. */ in e1000e_copper_link_setup_m88()
859 * e1000e_copper_link_setup_igp - Setup igp PHY's for copper link
862 * Sets up LPLU, MDI/MDI-X, polarity, Smartspeed and Master/Slave config for
867 struct e1000_phy_info *phy = &hw->phy; in e1000e_copper_link_setup_igp()
883 if (hw->phy.ops.set_d0_lplu_state) { in e1000e_copper_link_setup_igp()
884 ret_val = hw->phy.ops.set_d0_lplu_state(hw, false); in e1000e_copper_link_setup_igp()
890 /* Configure mdi-mdix settings */ in e1000e_copper_link_setup_igp()
897 switch (phy->mdix) { in e1000e_copper_link_setup_igp()
913 /* set auto-master slave resolution settings */ in e1000e_copper_link_setup_igp()
914 if (hw->mac.autoneg) { in e1000e_copper_link_setup_igp()
916 * should disable SmartSpeed and enable Auto MasterSlave in e1000e_copper_link_setup_igp()
919 if (phy->autoneg_advertised == ADVERTISE_1000_FULL) { in e1000e_copper_link_setup_igp()
932 /* Set auto Master/Slave resolution process */ in e1000e_copper_link_setup_igp()
950 * e1000_phy_setup_autoneg - Configure PHY for auto-negotiation
953 * Reads the MII auto-neg advertisement register and/or the 1000T control
954 * register and if the PHY is already setup for auto-negotiation, then
955 * return successful. Otherwise, setup advertisement and flow control to
956 * the appropriate values for the wanted auto-negotiation.
960 struct e1000_phy_info *phy = &hw->phy; in e1000_phy_setup_autoneg()
965 phy->autoneg_advertised &= phy->autoneg_mask; in e1000_phy_setup_autoneg()
967 /* Read the MII Auto-Neg Advertisement Register (Address 4). */ in e1000_phy_setup_autoneg()
972 if (phy->autoneg_mask & ADVERTISE_1000_FULL) { in e1000_phy_setup_autoneg()
973 /* Read the MII 1000Base-T Control Register (Address 9). */ in e1000_phy_setup_autoneg()
986 /* First we clear all the 10/100 mb speed bits in the Auto-Neg in e1000_phy_setup_autoneg()
988 * the 1000Base-T Control Register (Address 9). in e1000_phy_setup_autoneg()
995 e_dbg("autoneg_advertised %x\n", phy->autoneg_advertised); in e1000_phy_setup_autoneg()
998 if (phy->autoneg_advertised & ADVERTISE_10_HALF) { in e1000_phy_setup_autoneg()
1004 if (phy->autoneg_advertised & ADVERTISE_10_FULL) { in e1000_phy_setup_autoneg()
1010 if (phy->autoneg_advertised & ADVERTISE_100_HALF) { in e1000_phy_setup_autoneg()
1016 if (phy->autoneg_advertised & ADVERTISE_100_FULL) { in e1000_phy_setup_autoneg()
1022 if (phy->autoneg_advertised & ADVERTISE_1000_HALF) in e1000_phy_setup_autoneg()
1026 if (phy->autoneg_advertised & ADVERTISE_1000_FULL) { in e1000_phy_setup_autoneg()
1031 /* Check for a software override of the flow control settings, and in e1000_phy_setup_autoneg()
1033 * auto-negotiation is enabled, then software will have to set the in e1000_phy_setup_autoneg()
1034 * "PAUSE" bits to the correct value in the Auto-Negotiation in e1000_phy_setup_autoneg()
1035 * Advertisement Register (MII_ADVERTISE) and re-start auto- in e1000_phy_setup_autoneg()
1039 * 0: Flow control is completely disabled in e1000_phy_setup_autoneg()
1040 * 1: Rx flow control is enabled (we can receive pause frames in e1000_phy_setup_autoneg()
1042 * 2: Tx flow control is enabled (we can send pause frames in e1000_phy_setup_autoneg()
1044 * 3: Both Rx and Tx flow control (symmetric) are enabled. in e1000_phy_setup_autoneg()
1045 * other: No software override. The flow control configuration in e1000_phy_setup_autoneg()
1048 switch (hw->fc.current_mode) { in e1000_phy_setup_autoneg()
1050 /* Flow control (Rx & Tx) is completely disabled by a in e1000_phy_setup_autoneg()
1051 * software over-ride. in e1000_phy_setup_autoneg()
1055 phy->autoneg_advertised &= in e1000_phy_setup_autoneg()
1059 /* Rx Flow control is enabled, and Tx Flow control is in e1000_phy_setup_autoneg()
1060 * disabled, by a software over-ride. in e1000_phy_setup_autoneg()
1070 phy->autoneg_advertised |= in e1000_phy_setup_autoneg()
1074 /* Tx Flow control is enabled, and Rx Flow control is in e1000_phy_setup_autoneg()
1075 * disabled, by a software over-ride. in e1000_phy_setup_autoneg()
1079 phy->autoneg_advertised |= ADVERTISED_Asym_Pause; in e1000_phy_setup_autoneg()
1080 phy->autoneg_advertised &= ~ADVERTISED_Pause; in e1000_phy_setup_autoneg()
1083 /* Flow control (both Rx and Tx) is enabled by a software in e1000_phy_setup_autoneg()
1084 * over-ride. in e1000_phy_setup_autoneg()
1088 phy->autoneg_advertised |= in e1000_phy_setup_autoneg()
1092 e_dbg("Flow control param set incorrectly\n"); in e1000_phy_setup_autoneg()
1093 return -E1000_ERR_CONFIG; in e1000_phy_setup_autoneg()
1100 e_dbg("Auto-Neg Advertising %x\n", mii_autoneg_adv_reg); in e1000_phy_setup_autoneg()
1102 if (phy->autoneg_mask & ADVERTISE_1000_FULL) in e1000_phy_setup_autoneg()
1109 * e1000_copper_link_autoneg - Setup/Enable autoneg for copper link
1119 struct e1000_phy_info *phy = &hw->phy; in e1000_copper_link_autoneg()
1126 phy->autoneg_advertised &= phy->autoneg_mask; in e1000_copper_link_autoneg()
1131 if (!phy->autoneg_advertised) in e1000_copper_link_autoneg()
1132 phy->autoneg_advertised = phy->autoneg_mask; in e1000_copper_link_autoneg()
1134 e_dbg("Reconfiguring auto-neg advertisement params\n"); in e1000_copper_link_autoneg()
1137 e_dbg("Error Setting up Auto-Negotiation\n"); in e1000_copper_link_autoneg()
1140 e_dbg("Restarting Auto-Neg\n"); in e1000_copper_link_autoneg()
1142 /* Restart auto-negotiation by setting the Auto Neg Enable bit and in e1000_copper_link_autoneg()
1143 * the Auto Neg Restart bit in the PHY control register. in e1000_copper_link_autoneg()
1154 /* Does the user want to wait for Auto-Neg to complete here, or in e1000_copper_link_autoneg()
1157 if (phy->autoneg_wait_to_complete) { in e1000_copper_link_autoneg()
1165 hw->mac.get_link_status = true; in e1000_copper_link_autoneg()
1171 * e1000e_setup_copper_link - Configure copper link settings
1174 * Calls the appropriate function to configure the link for auto-neg or forced
1176 * to configure collision distance and flow control are called. If link is
1177 * not established, we return -E1000_ERR_PHY (-2).
1184 if (hw->mac.autoneg) { in e1000e_setup_copper_link()
1185 /* Setup autoneg and flow control advertisement and perform in e1000e_setup_copper_link()
1196 ret_val = hw->phy.ops.force_speed_duplex(hw); in e1000e_setup_copper_link()
1213 hw->mac.ops.config_collision_dist(hw); in e1000e_setup_copper_link()
1223 * e1000e_phy_force_speed_duplex_igp - Force speed/duplex for igp PHY
1227 * auto-crossover to force MDI manually. Waits for link and returns
1228 * successful if link up is successful, else -E1000_ERR_PHY (-2).
1232 struct e1000_phy_info *phy = &hw->phy; in e1000e_phy_force_speed_duplex_igp()
1247 /* Clear Auto-Crossover to force MDI manually. IGP requires MDI in e1000e_phy_force_speed_duplex_igp()
1265 if (phy->autoneg_wait_to_complete) { in e1000e_phy_force_speed_duplex_igp()
1285 * e1000e_phy_force_speed_duplex_m88 - Force speed/duplex for m88 PHY
1289 * auto-crossover to force MDI manually. Resets the PHY to commit the
1296 struct e1000_phy_info *phy = &hw->phy; in e1000e_phy_force_speed_duplex_m88()
1301 /* Clear Auto-Crossover to force MDI manually. M88E1000 requires MDI in e1000e_phy_force_speed_duplex_m88()
1326 if (hw->phy.ops.commit) { in e1000e_phy_force_speed_duplex_m88()
1327 ret_val = hw->phy.ops.commit(hw); in e1000e_phy_force_speed_duplex_m88()
1332 if (phy->autoneg_wait_to_complete) { in e1000e_phy_force_speed_duplex_m88()
1341 if (hw->phy.type != e1000_phy_m88) { in e1000e_phy_force_speed_duplex_m88()
1364 if (hw->phy.type != e1000_phy_m88) in e1000e_phy_force_speed_duplex_m88()
1371 /* Resetting the phy means we need to re-force TX_CLK in the in e1000e_phy_force_speed_duplex_m88()
1372 * Extended PHY Specific Control Register to 25MHz clock from in e1000e_phy_force_speed_duplex_m88()
1380 /* In addition, we must re-enable CRS on Tx for both half and full in e1000e_phy_force_speed_duplex_m88()
1394 * e1000_phy_force_speed_duplex_ife - Force PHY speed & duplex
1403 struct e1000_phy_info *phy = &hw->phy; in e1000_phy_force_speed_duplex_ife()
1418 /* Disable MDI-X support for 10/100 */ in e1000_phy_force_speed_duplex_ife()
1434 if (phy->autoneg_wait_to_complete) { in e1000_phy_force_speed_duplex_ife()
1456 * e1000e_phy_force_speed_duplex_setup - Configure forced PHY speed/duplex
1460 * Forces speed and duplex on the PHY by doing the following: disable flow
1461 * control, force speed/duplex on the MAC, disable auto speed detection,
1462 * disable auto-negotiation, configure duplex, configure speed, configure
1469 struct e1000_mac_info *mac = &hw->mac; in e1000e_phy_force_speed_duplex_setup()
1472 /* Turn off flow control when forcing speed/duplex */ in e1000e_phy_force_speed_duplex_setup()
1473 hw->fc.current_mode = e1000_fc_none; in e1000e_phy_force_speed_duplex_setup()
1480 /* Disable Auto Speed Detection */ in e1000e_phy_force_speed_duplex_setup()
1487 if (mac->forced_speed_duplex & E1000_ALL_HALF_DUPLEX) { in e1000e_phy_force_speed_duplex_setup()
1498 if (mac->forced_speed_duplex & E1000_ALL_100_SPEED) { in e1000e_phy_force_speed_duplex_setup()
1509 hw->mac.ops.config_collision_dist(hw); in e1000e_phy_force_speed_duplex_setup()
1515 * e1000e_set_d3_lplu_state - Sets low power link up state for D3
1530 struct e1000_phy_info *phy = &hw->phy; in e1000e_set_d3_lplu_state()
1548 if (phy->smart_speed == e1000_smart_speed_on) { in e1000e_set_d3_lplu_state()
1559 } else if (phy->smart_speed == e1000_smart_speed_off) { in e1000e_set_d3_lplu_state()
1571 } else if ((phy->autoneg_advertised == E1000_ALL_SPEED_DUPLEX) || in e1000e_set_d3_lplu_state()
1572 (phy->autoneg_advertised == E1000_ALL_NOT_GIG) || in e1000e_set_d3_lplu_state()
1573 (phy->autoneg_advertised == E1000_ALL_10_SPEED)) { in e1000e_set_d3_lplu_state()
1592 * e1000e_check_downshift - Checks whether a downshift in speed occurred
1601 struct e1000_phy_info *phy = &hw->phy; in e1000e_check_downshift()
1605 switch (phy->type) { in e1000e_check_downshift()
1620 phy->speed_downgraded = false; in e1000e_check_downshift()
1627 phy->speed_downgraded = !!(phy_data & mask); in e1000e_check_downshift()
1633 * e1000_check_polarity_m88 - Checks the polarity.
1636 * Success returns 0, Failure returns -E1000_ERR_PHY (-2)
1642 struct e1000_phy_info *phy = &hw->phy; in e1000_check_polarity_m88()
1649 phy->cable_polarity = ((data & M88E1000_PSSR_REV_POLARITY) in e1000_check_polarity_m88()
1657 * e1000_check_polarity_igp - Checks the polarity.
1660 * Success returns 0, Failure returns -E1000_ERR_PHY (-2)
1667 struct e1000_phy_info *phy = &hw->phy; in e1000_check_polarity_igp()
1693 phy->cable_polarity = ((data & mask) in e1000_check_polarity_igp()
1701 * e1000_check_polarity_ife - Check cable polarity for IFE PHY
1708 struct e1000_phy_info *phy = &hw->phy; in e1000_check_polarity_ife()
1714 if (phy->polarity_correction) { in e1000_check_polarity_ife()
1725 phy->cable_polarity = ((phy_data & mask) in e1000_check_polarity_ife()
1733 * e1000_wait_autoneg - Wait for auto-neg completion
1736 * Waits for auto-negotiation to complete or for the auto-negotiation time
1745 for (i = PHY_AUTO_NEG_LIMIT; i > 0; i--) { in e1000_wait_autoneg()
1757 /* PHY_AUTO_NEG_TIME expiration doesn't guarantee auto-negotiation in e1000_wait_autoneg()
1764 * e1000e_phy_has_link_generic - Polls PHY for link
1812 * e1000e_get_cable_length_m88 - Determine cable length for m88 PHY
1821 * 1 50 - 80 meters
1822 * 2 80 - 110 meters
1823 * 3 110 - 140 meters
1828 struct e1000_phy_info *phy = &hw->phy; in e1000e_get_cable_length_m88()
1838 if (index >= M88E1000_CABLE_LENGTH_TABLE_SIZE - 1) in e1000e_get_cable_length_m88()
1839 return -E1000_ERR_PHY; in e1000e_get_cable_length_m88()
1841 phy->min_cable_length = e1000_m88_cable_length_table[index]; in e1000e_get_cable_length_m88()
1842 phy->max_cable_length = e1000_m88_cable_length_table[index + 1]; in e1000e_get_cable_length_m88()
1844 phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2; in e1000e_get_cable_length_m88()
1850 * e1000e_get_cable_length_igp_2 - Determine cable length for igp2 PHY
1853 * The automatic gain control (agc) normalizes the amplitude of the
1862 struct e1000_phy_info *phy = &hw->phy; in e1000e_get_cable_length_igp_2()
1866 u16 min_agc_index = IGP02E1000_CABLE_LENGTH_TABLE_SIZE - 1; in e1000e_get_cable_length_igp_2()
1891 return -E1000_ERR_PHY; in e1000e_get_cable_length_igp_2()
1904 agc_value -= (e1000_igp_2_cable_length_table[min_agc_index] + in e1000e_get_cable_length_igp_2()
1906 agc_value /= (IGP02E1000_PHY_CHANNEL_NUM - 2); in e1000e_get_cable_length_igp_2()
1908 /* Calculate cable length with the error range of +/- 10 meters. */ in e1000e_get_cable_length_igp_2()
1909 phy->min_cable_length = (((agc_value - IGP02E1000_AGC_RANGE) > 0) ? in e1000e_get_cable_length_igp_2()
1910 (agc_value - IGP02E1000_AGC_RANGE) : 0); in e1000e_get_cable_length_igp_2()
1911 phy->max_cable_length = agc_value + IGP02E1000_AGC_RANGE; in e1000e_get_cable_length_igp_2()
1913 phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2; in e1000e_get_cable_length_igp_2()
1919 * e1000e_get_phy_info_m88 - Retrieve PHY information
1923 * to verify that link is up. Read the PHY special control register to
1924 * determine the polarity and 10base-T extended distance. Read the PHY
1930 struct e1000_phy_info *phy = &hw->phy; in e1000e_get_phy_info_m88()
1935 if (phy->media_type != e1000_media_type_copper) { in e1000e_get_phy_info_m88()
1937 return -E1000_ERR_CONFIG; in e1000e_get_phy_info_m88()
1946 return -E1000_ERR_CONFIG; in e1000e_get_phy_info_m88()
1953 phy->polarity_correction = !!(phy_data & in e1000e_get_phy_info_m88()
1964 phy->is_mdix = !!(phy_data & M88E1000_PSSR_MDIX); in e1000e_get_phy_info_m88()
1967 ret_val = hw->phy.ops.get_cable_length(hw); in e1000e_get_phy_info_m88()
1975 phy->local_rx = (phy_data & LPA_1000LOCALRXOK) in e1000e_get_phy_info_m88()
1978 phy->remote_rx = (phy_data & LPA_1000REMRXOK) in e1000e_get_phy_info_m88()
1982 phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED; in e1000e_get_phy_info_m88()
1983 phy->local_rx = e1000_1000t_rx_status_undefined; in e1000e_get_phy_info_m88()
1984 phy->remote_rx = e1000_1000t_rx_status_undefined; in e1000e_get_phy_info_m88()
1991 * e1000e_get_phy_info_igp - Retrieve igp PHY information
1995 * set/determine 10base-T extended distance and polarity correction. Read
2001 struct e1000_phy_info *phy = &hw->phy; in e1000e_get_phy_info_igp()
2012 return -E1000_ERR_CONFIG; in e1000e_get_phy_info_igp()
2015 phy->polarity_correction = true; in e1000e_get_phy_info_igp()
2025 phy->is_mdix = !!(data & IGP01E1000_PSSR_MDIX); in e1000e_get_phy_info_igp()
2029 ret_val = phy->ops.get_cable_length(hw); in e1000e_get_phy_info_igp()
2037 phy->local_rx = (data & LPA_1000LOCALRXOK) in e1000e_get_phy_info_igp()
2040 phy->remote_rx = (data & LPA_1000REMRXOK) in e1000e_get_phy_info_igp()
2043 phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED; in e1000e_get_phy_info_igp()
2044 phy->local_rx = e1000_1000t_rx_status_undefined; in e1000e_get_phy_info_igp()
2045 phy->remote_rx = e1000_1000t_rx_status_undefined; in e1000e_get_phy_info_igp()
2052 * e1000_get_phy_info_ife - Retrieves various IFE PHY states
2059 struct e1000_phy_info *phy = &hw->phy; in e1000_get_phy_info_ife()
2070 return -E1000_ERR_CONFIG; in e1000_get_phy_info_ife()
2076 phy->polarity_correction = !(data & IFE_PSC_AUTO_POLARITY_DISABLE); in e1000_get_phy_info_ife()
2078 if (phy->polarity_correction) { in e1000_get_phy_info_ife()
2084 phy->cable_polarity = ((data & IFE_PSC_FORCE_POLARITY) in e1000_get_phy_info_ife()
2093 phy->is_mdix = !!(data & IFE_PMC_MDIX_STATUS); in e1000_get_phy_info_ife()
2096 phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED; in e1000_get_phy_info_ife()
2097 phy->local_rx = e1000_1000t_rx_status_undefined; in e1000_get_phy_info_ife()
2098 phy->remote_rx = e1000_1000t_rx_status_undefined; in e1000_get_phy_info_ife()
2104 * e1000e_phy_sw_reset - PHY software reset
2107 * Does a software reset of the PHY by reading the PHY control register and
2108 * setting/write the control register reset bit to the PHY.
2130 * e1000e_phy_hw_reset_generic - PHY hardware reset
2134 * semaphore (if necessary) and read/set/write the device control reset
2140 struct e1000_phy_info *phy = &hw->phy; in e1000e_phy_hw_reset_generic()
2144 if (phy->ops.check_reset_block) { in e1000e_phy_hw_reset_generic()
2145 ret_val = phy->ops.check_reset_block(hw); in e1000e_phy_hw_reset_generic()
2150 ret_val = phy->ops.acquire(hw); in e1000e_phy_hw_reset_generic()
2158 udelay(phy->reset_delay_us); in e1000e_phy_hw_reset_generic()
2165 phy->ops.release(hw); in e1000e_phy_hw_reset_generic()
2167 return phy->ops.get_cfg_done(hw); in e1000e_phy_hw_reset_generic()
2171 * e1000e_get_cfg_done_generic - Generic configuration done
2174 * Generic function to wait 10 milli-seconds for configuration to complete
2185 * e1000e_phy_init_script_igp3 - Inits the IGP3 PHY
2195 /* Enable rise/fall, 10-mode work in class-A */ in e1000e_phy_init_script_igp3()
2253 /* Enable LPLU and disable AN to 1000 in non-D0a states, in e1000e_phy_init_script_igp3()
2268 * e1000e_get_phy_type_from_id - Get PHY type from id
2322 * e1000e_determine_phy_address - Determines PHY address.
2335 hw->phy.id = phy_type; in e1000e_determine_phy_address()
2338 hw->phy.addr = phy_addr; in e1000e_determine_phy_address()
2343 phy_type = e1000e_get_phy_type_from_id(hw->phy.id); in e1000e_determine_phy_address()
2345 /* If phy_type is valid, break - we found our in e1000e_determine_phy_address()
2356 return -E1000_ERR_PHY_TYPE; in e1000e_determine_phy_address()
2360 * e1000_get_phy_addr_for_bm_page - Retrieve PHY page address
2377 * e1000e_write_phy_reg_bm - Write BM PHY register
2390 ret_val = hw->phy.ops.acquire(hw); in e1000e_write_phy_reg_bm()
2401 hw->phy.addr = e1000_get_phy_addr_for_bm_page(page, offset); in e1000e_write_phy_reg_bm()
2410 if (hw->phy.addr == 1) { in e1000e_write_phy_reg_bm()
2429 hw->phy.ops.release(hw); in e1000e_write_phy_reg_bm()
2434 * e1000e_read_phy_reg_bm - Read BM PHY register
2448 ret_val = hw->phy.ops.acquire(hw); in e1000e_read_phy_reg_bm()
2459 hw->phy.addr = e1000_get_phy_addr_for_bm_page(page, offset); in e1000e_read_phy_reg_bm()
2468 if (hw->phy.addr == 1) { in e1000e_read_phy_reg_bm()
2486 hw->phy.ops.release(hw); in e1000e_read_phy_reg_bm()
2491 * e1000e_read_phy_reg_bm2 - Read BM PHY register
2505 ret_val = hw->phy.ops.acquire(hw); in e1000e_read_phy_reg_bm2()
2516 hw->phy.addr = 1; in e1000e_read_phy_reg_bm2()
2530 hw->phy.ops.release(hw); in e1000e_read_phy_reg_bm2()
2535 * e1000e_write_phy_reg_bm2 - Write BM PHY register
2548 ret_val = hw->phy.ops.acquire(hw); in e1000e_write_phy_reg_bm2()
2559 hw->phy.addr = 1; in e1000e_write_phy_reg_bm2()
2574 hw->phy.ops.release(hw); in e1000e_write_phy_reg_bm2()
2579 * e1000_enable_phy_wakeup_reg_access_bm - enable access to BM wakeup registers
2592 hw->phy.addr = 1; in e1000_enable_phy_wakeup_reg_access_bm()
2594 /* Select Port Control Registers page */ in e1000_enable_phy_wakeup_reg_access_bm()
2597 e_dbg("Could not set Port Control page\n"); in e1000_enable_phy_wakeup_reg_access_bm()
2622 /* Select Host Wakeup Registers page - caller now able to write in e1000_enable_phy_wakeup_reg_access_bm()
2629 * e1000_disable_phy_wakeup_reg_access_bm - disable access to BM wakeup regs
2643 /* Select Port Control Registers page */ in e1000_disable_phy_wakeup_reg_access_bm()
2646 e_dbg("Could not set Port Control page\n"); in e1000_disable_phy_wakeup_reg_access_bm()
2660 * e1000_access_phy_wakeup_reg_bm - Read/write BM PHY wakeup register
2693 if ((hw->mac.type == e1000_pchlan) && in e1000_access_phy_wakeup_reg_bm()
2738 * e1000_power_up_phy_copper - Restore copper link in case of PHY power down
2761 * e1000_power_down_phy_copper - Restore copper link in case of PHY power down
2785 * __e1000_read_phy_reg_hv - Read HV PHY register
2802 u32 phy_addr = hw->phy.addr = e1000_get_phy_addr_for_hv_page(page); in __e1000_read_phy_reg_hv()
2805 ret_val = hw->phy.ops.acquire(hw); in __e1000_read_phy_reg_hv()
2832 hw->phy.addr = phy_addr; in __e1000_read_phy_reg_hv()
2845 hw->phy.ops.release(hw); in __e1000_read_phy_reg_hv()
2851 * e1000_read_phy_reg_hv - Read HV PHY register
2866 * e1000_read_phy_reg_hv_locked - Read HV PHY register
2880 * e1000_read_phy_reg_page_hv - Read HV PHY register
2894 * __e1000_write_phy_reg_hv - Write HV PHY register
2910 u32 phy_addr = hw->phy.addr = e1000_get_phy_addr_for_hv_page(page); in __e1000_write_phy_reg_hv()
2913 ret_val = hw->phy.ops.acquire(hw); in __e1000_write_phy_reg_hv()
2936 * Power Down (when bit 11 of the PHY Control register is set) in __e1000_write_phy_reg_hv()
2938 if ((hw->phy.type == e1000_phy_82578) && in __e1000_write_phy_reg_hv()
2939 (hw->phy.revision >= 1) && in __e1000_write_phy_reg_hv()
2940 (hw->phy.addr == 2) && in __e1000_write_phy_reg_hv()
2956 hw->phy.addr = phy_addr; in __e1000_write_phy_reg_hv()
2971 hw->phy.ops.release(hw); in __e1000_write_phy_reg_hv()
2977 * e1000_write_phy_reg_hv - Write HV PHY register
2991 * e1000_write_phy_reg_hv_locked - Write HV PHY register
3005 * e1000_write_phy_reg_page_hv - Write HV PHY register
3019 * e1000_get_phy_addr_for_hv_page - Get PHY address based on page
3033 * e1000_access_phy_debug_regs_hv - Read HV PHY vendor specific high registers
3052 addr_reg = ((hw->phy.type == e1000_phy_82578) ? in e1000_access_phy_debug_regs_hv()
3057 hw->phy.addr = 2; in e1000_access_phy_debug_regs_hv()
3079 * e1000_link_stall_workaround_hv - Si workaround
3094 if (hw->phy.type != e1000_phy_82578) in e1000_link_stall_workaround_hv()
3131 * e1000_check_polarity_82577 - Checks the polarity.
3134 * Success returns 0, Failure returns -E1000_ERR_PHY (-2)
3140 struct e1000_phy_info *phy = &hw->phy; in e1000_check_polarity_82577()
3147 phy->cable_polarity = ((data & I82577_PHY_STATUS2_REV_POLARITY) in e1000_check_polarity_82577()
3155 * e1000_phy_force_speed_duplex_82577 - Force speed/duplex for I82577 PHY
3162 struct e1000_phy_info *phy = &hw->phy; in e1000_phy_force_speed_duplex_82577()
3179 if (phy->autoneg_wait_to_complete) { in e1000_phy_force_speed_duplex_82577()
3199 * e1000_get_phy_info_82577 - Retrieve I82577 PHY information
3203 * set/determine 10base-T extended distance and polarity correction. Read
3209 struct e1000_phy_info *phy = &hw->phy; in e1000_get_phy_info_82577()
3220 return -E1000_ERR_CONFIG; in e1000_get_phy_info_82577()
3223 phy->polarity_correction = true; in e1000_get_phy_info_82577()
3233 phy->is_mdix = !!(data & I82577_PHY_STATUS2_MDIX); in e1000_get_phy_info_82577()
3237 ret_val = hw->phy.ops.get_cable_length(hw); in e1000_get_phy_info_82577()
3245 phy->local_rx = (data & LPA_1000LOCALRXOK) in e1000_get_phy_info_82577()
3248 phy->remote_rx = (data & LPA_1000REMRXOK) in e1000_get_phy_info_82577()
3251 phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED; in e1000_get_phy_info_82577()
3252 phy->local_rx = e1000_1000t_rx_status_undefined; in e1000_get_phy_info_82577()
3253 phy->remote_rx = e1000_1000t_rx_status_undefined; in e1000_get_phy_info_82577()
3260 * e1000_get_cable_length_82577 - Determine cable length for 82577 PHY
3268 struct e1000_phy_info *phy = &hw->phy; in e1000_get_cable_length_82577()
3279 return -E1000_ERR_PHY; in e1000_get_cable_length_82577()
3281 phy->cable_length = length; in e1000_get_cable_length_82577()