Lines Matching +full:g +full:- +full:link

1 // SPDX-License-Identifier: GPL-2.0-only
12 * genphy_c45_baset1_able - checks if the PMA has BASE-T1 extended abilities
19 if (phydev->pma_extable == -ENODATA) { in genphy_c45_baset1_able()
24 phydev->pma_extable = val; in genphy_c45_baset1_able()
27 return !!(phydev->pma_extable & MDIO_PMA_EXTABLE_BT1); in genphy_c45_baset1_able()
31 * genphy_c45_pma_can_sleep - checks if the PMA have sleep support
46 * genphy_c45_pma_resume - wakes up the PMA module
52 return -EOPNOTSUPP; in genphy_c45_pma_resume()
60 * genphy_c45_pma_suspend - suspends the PMA module
66 return -EOPNOTSUPP; in genphy_c45_pma_suspend()
74 * genphy_c45_pma_baset1_setup_master_slave - configures forced master/slave
82 switch (phydev->master_slave_set) { in genphy_c45_pma_baset1_setup_master_slave()
95 return -EOPNOTSUPP; in genphy_c45_pma_baset1_setup_master_slave()
104 * genphy_c45_pma_setup_forced - configures a forced speed
112 if (phydev->duplex != DUPLEX_FULL) in genphy_c45_pma_setup_forced()
113 return -EINVAL; in genphy_c45_pma_setup_forced()
126 * in 802.3-2012 and 802.3-2015. in genphy_c45_pma_setup_forced()
130 switch (phydev->speed) { in genphy_c45_pma_setup_forced()
143 /* Assume 1000base-T */ in genphy_c45_pma_setup_forced()
148 /* Assume 2.5Gbase-T */ in genphy_c45_pma_setup_forced()
153 /* Assume 5Gbase-T */ in genphy_c45_pma_setup_forced()
158 /* Assume 10Gbase-T */ in genphy_c45_pma_setup_forced()
162 return -EINVAL; in genphy_c45_pma_setup_forced()
184 * The preference is set in the BIT(4) of BASE-T1 AN
186 * is forced or not, it is set in the BIT(12) of BASE-T1
188 * Sets 10BASE-T1L Ability BIT(14) in BASE-T1 autonegotiation
202 switch (phydev->master_slave_set) { in genphy_c45_baset1_an_config_aneg()
222 return -EOPNOTSUPP; in genphy_c45_baset1_an_config_aneg()
225 adv_l |= linkmode_adv_to_mii_t1_adv_l_t(phydev->advertising); in genphy_c45_baset1_an_config_aneg()
234 adv_m |= linkmode_adv_to_mii_t1_adv_m_t(phydev->advertising); in genphy_c45_baset1_an_config_aneg()
247 * genphy_c45_an_config_aneg - configure advertisement registers
250 * Configure advertisement registers based on modes set in phydev->advertising
260 linkmode_and(phydev->advertising, phydev->advertising, in genphy_c45_an_config_aneg()
261 phydev->supported); in genphy_c45_an_config_aneg()
268 adv = linkmode_adv_to_mii_adv_t(phydev->advertising); in genphy_c45_an_config_aneg()
279 adv = linkmode_adv_to_mii_10gbt_adv_t(phydev->advertising); in genphy_c45_an_config_aneg()
295 * genphy_c45_an_disable_aneg - disable auto-negotiation
298 * Disable auto-negotiation in the Clause 45 PHY. The link parameters
316 * genphy_c45_restart_aneg - Enable and restart auto-negotiation
319 * This assumes that the auto-negotiation MMD is present.
321 * Enable and restart auto-negotiation.
336 * genphy_c45_check_and_restart_aneg - Enable and restart auto-negotiation
340 * This assumes that the auto-negotiation MMD is present.
342 * Check, and restart auto-negotiation if needed.
370 * genphy_c45_aneg_done - return auto-negotiation complete status
373 * This assumes that the auto-negotiation MMD is present.
375 * Reads the status register from the auto-negotiation MMD, returning:
376 * - positive if auto-negotiation is complete
377 * - negative errno code on error
378 * - zero otherwise
395 * genphy_c45_read_link - read the overall link status from the MMDs
398 * Read the link status from the specified MMDs, and if they all indicate
399 * that the link is up, set phydev->link to 1. If an error is encountered,
406 bool link = true; in genphy_c45_read_link() local
408 if (phydev->c45_ids.mmds_present & MDIO_DEVS_AN) { in genphy_c45_read_link()
414 * link status and report link as down. in genphy_c45_read_link()
417 phydev->link = 0; in genphy_c45_read_link()
422 while (mmd_mask && link) { in genphy_c45_read_link()
426 /* The link state is latched low so that momentary link in genphy_c45_read_link()
427 * drops can be detected. Do not double-read the status in genphy_c45_read_link()
428 * in polling mode to detect such short link drops except in genphy_c45_read_link()
429 * the link was already down. in genphy_c45_read_link()
431 if (!phy_polling_mode(phydev) || !phydev->link) { in genphy_c45_read_link()
444 link = false; in genphy_c45_read_link()
447 phydev->link = link; in genphy_c45_read_link()
453 /* Read the Clause 45 defined BASE-T1 AN (7.513) status register to check
454 * if autoneg is complete. If so read the BASE-T1 Autonegotiation
455 * Advertisement registers filling in the link partner advertisement,
467 linkmode_clear_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, phydev->lp_advertising); in genphy_c45_baset1_read_lpa()
468 mii_t1_adv_l_mod_linkmode_t(phydev->lp_advertising, 0); in genphy_c45_baset1_read_lpa()
469 mii_t1_adv_m_mod_linkmode_t(phydev->lp_advertising, 0); in genphy_c45_baset1_read_lpa()
471 phydev->pause = 0; in genphy_c45_baset1_read_lpa()
472 phydev->asym_pause = 0; in genphy_c45_baset1_read_lpa()
477 linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, phydev->lp_advertising, 1); in genphy_c45_baset1_read_lpa()
483 mii_t1_adv_l_mod_linkmode_t(phydev->lp_advertising, val); in genphy_c45_baset1_read_lpa()
484 phydev->pause = val & MDIO_AN_T1_ADV_L_PAUSE_CAP ? 1 : 0; in genphy_c45_baset1_read_lpa()
485 phydev->asym_pause = val & MDIO_AN_T1_ADV_L_PAUSE_ASYM ? 1 : 0; in genphy_c45_baset1_read_lpa()
491 mii_t1_adv_m_mod_linkmode_t(phydev->lp_advertising, val); in genphy_c45_baset1_read_lpa()
497 * genphy_c45_read_lpa - read the link partner advertisement and pause
500 * Read the Clause 45 defined base (7.19) and 10G (7.33) status registers,
501 * filling in the link partner advertisement, pause and asym_pause members
502 * in @phydev. This assumes that the auto-negotiation MMD is present, and
504 * to fill in the remainder of the link partner advert from vendor registers.
519 phydev->lp_advertising); in genphy_c45_read_lpa()
520 mii_10gbt_stat_mod_linkmode_lpa_t(phydev->lp_advertising, 0); in genphy_c45_read_lpa()
521 mii_adv_mod_linkmode_adv_t(phydev->lp_advertising, 0); in genphy_c45_read_lpa()
522 phydev->pause = 0; in genphy_c45_read_lpa()
523 phydev->asym_pause = 0; in genphy_c45_read_lpa()
528 linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, phydev->lp_advertising, in genphy_c45_read_lpa()
531 /* Read the link partner's base page advertisement */ in genphy_c45_read_lpa()
536 mii_adv_mod_linkmode_adv_t(phydev->lp_advertising, val); in genphy_c45_read_lpa()
537 phydev->pause = val & LPA_PAUSE_CAP ? 1 : 0; in genphy_c45_read_lpa()
538 phydev->asym_pause = val & LPA_PAUSE_ASYM ? 1 : 0; in genphy_c45_read_lpa()
540 /* Read the link partner's 10G advertisement */ in genphy_c45_read_lpa()
545 mii_10gbt_stat_mod_linkmode_lpa_t(phydev->lp_advertising, val); in genphy_c45_read_lpa()
552 * genphy_c45_pma_baset1_read_master_slave - read forced master/slave
560 phydev->master_slave_state = MASTER_SLAVE_STATE_UNKNOWN; in genphy_c45_pma_baset1_read_master_slave()
561 phydev->master_slave_get = MASTER_SLAVE_CFG_UNKNOWN; in genphy_c45_pma_baset1_read_master_slave()
568 phydev->master_slave_get = MASTER_SLAVE_CFG_MASTER_FORCE; in genphy_c45_pma_baset1_read_master_slave()
569 phydev->master_slave_state = MASTER_SLAVE_STATE_MASTER; in genphy_c45_pma_baset1_read_master_slave()
571 phydev->master_slave_get = MASTER_SLAVE_CFG_SLAVE_FORCE; in genphy_c45_pma_baset1_read_master_slave()
572 phydev->master_slave_state = MASTER_SLAVE_STATE_SLAVE; in genphy_c45_pma_baset1_read_master_slave()
580 * genphy_c45_read_pma - read link speed etc from PMA
587 linkmode_zero(phydev->lp_advertising); in genphy_c45_read_pma()
595 phydev->speed = SPEED_10; in genphy_c45_read_pma()
598 phydev->speed = SPEED_100; in genphy_c45_read_pma()
601 phydev->speed = SPEED_1000; in genphy_c45_read_pma()
604 phydev->speed = SPEED_2500; in genphy_c45_read_pma()
607 phydev->speed = SPEED_5000; in genphy_c45_read_pma()
610 phydev->speed = SPEED_10000; in genphy_c45_read_pma()
613 phydev->speed = SPEED_UNKNOWN; in genphy_c45_read_pma()
617 phydev->duplex = DUPLEX_FULL; in genphy_c45_read_pma()
630 * genphy_c45_read_mdix - read mdix status from PMA
637 if (phydev->speed == SPEED_10000) { in genphy_c45_read_mdix()
645 phydev->mdix = ETH_TP_MDI; in genphy_c45_read_mdix()
649 phydev->mdix = ETH_TP_MDI_X; in genphy_c45_read_mdix()
653 phydev->mdix = ETH_TP_MDI_INVALID; in genphy_c45_read_mdix()
663 * genphy_c45_pma_read_abilities - read supported link modes from PMA
666 * Read the supported link modes from the PMA Status 2 (1.8) register. If bit
668 * PMA Extended Abilities (1.11) register, indicating 1000BASET an 10G related
670 * in the 2.5G/5G PMA Extended register (1.21), indicating if 2.5GBASET and
677 linkmode_clear_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, phydev->supported); in genphy_c45_pma_read_abilities()
678 if (phydev->c45_ids.mmds_present & MDIO_DEVS_AN) { in genphy_c45_pma_read_abilities()
685 phydev->supported); in genphy_c45_pma_read_abilities()
693 phydev->supported, in genphy_c45_pma_read_abilities()
697 phydev->supported, in genphy_c45_pma_read_abilities()
701 phydev->supported, in genphy_c45_pma_read_abilities()
710 phydev->supported, in genphy_c45_pma_read_abilities()
713 phydev->supported, in genphy_c45_pma_read_abilities()
716 phydev->supported, in genphy_c45_pma_read_abilities()
719 phydev->supported, in genphy_c45_pma_read_abilities()
722 phydev->supported, in genphy_c45_pma_read_abilities()
725 phydev->supported, in genphy_c45_pma_read_abilities()
729 phydev->supported, in genphy_c45_pma_read_abilities()
732 phydev->supported, in genphy_c45_pma_read_abilities()
736 phydev->supported, in genphy_c45_pma_read_abilities()
739 phydev->supported, in genphy_c45_pma_read_abilities()
749 phydev->supported, in genphy_c45_pma_read_abilities()
753 phydev->supported, in genphy_c45_pma_read_abilities()
763 phydev->supported, in genphy_c45_pma_read_abilities()
771 phydev->supported, in genphy_c45_pma_read_abilities()
781 * The preference is read from the BIT(4) of BASE-T1 AN
783 * is forced or not, it is read from BASE-T1 AN advertisement
791 phydev->master_slave_get = MASTER_SLAVE_CFG_UNKNOWN; in genphy_c45_baset1_read_status()
792 phydev->master_slave_state = MASTER_SLAVE_STATE_UNKNOWN; in genphy_c45_baset1_read_status()
804 phydev->master_slave_get = MASTER_SLAVE_CFG_MASTER_FORCE; in genphy_c45_baset1_read_status()
806 phydev->master_slave_get = MASTER_SLAVE_CFG_SLAVE_FORCE; in genphy_c45_baset1_read_status()
809 phydev->master_slave_get = MASTER_SLAVE_CFG_MASTER_PREFERRED; in genphy_c45_baset1_read_status()
811 phydev->master_slave_get = MASTER_SLAVE_CFG_SLAVE_PREFERRED; in genphy_c45_baset1_read_status()
819 * genphy_c45_read_status - read PHY status
832 phydev->speed = SPEED_UNKNOWN; in genphy_c45_read_status()
833 phydev->duplex = DUPLEX_UNKNOWN; in genphy_c45_read_status()
834 phydev->pause = 0; in genphy_c45_read_status()
835 phydev->asym_pause = 0; in genphy_c45_read_status()
837 if (phydev->autoneg == AUTONEG_ENABLE) { in genphy_c45_read_status()
858 * genphy_c45_config_aneg - restart auto-negotiation or forced setup
861 * Description: If auto-negotiation is enabled, we configure the
862 * advertising, and then restart auto-negotiation. If it is not
870 if (phydev->autoneg == AUTONEG_DISABLE) in genphy_c45_config_aneg()
900 * genphy_c45_fast_retrain - configure fast retrain registers
904 * Description: If fast-retrain is enabled, we configure PHY as
917 if (linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->supported)) { in genphy_c45_fast_retrain()