net: phy: c45: add a separate function to read BASE-T1 abilities
authorStefan Eichenberger <eichest@gmail.com>
Wed, 19 Jul 2023 06:42:56 +0000 (08:42 +0200)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 20 Jul 2023 10:24:06 +0000 (12:24 +0200)
Add a separate function to read the BASE-T1 abilities. Some PHYs do not
indicate the availability of the extended BASE-T1 ability register, so
this function must be called separately.

Signed-off-by: Stefan Eichenberger <eichest@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/phy/phy-c45.c
include/linux/phy.h

index b73c428a15663e341da78b6da7224f2b92d3d790..58a6bbbe8a70cbc0057fa911cfea8b59215e0e64 100644 (file)
@@ -881,6 +881,36 @@ int genphy_c45_an_config_eee_aneg(struct phy_device *phydev)
        return genphy_c45_write_eee_adv(phydev, phydev->advertising_eee);
 }
 
+/**
+ * genphy_c45_pma_baset1_read_abilities - read supported baset1 link modes from PMA
+ * @phydev: target phy_device struct
+ *
+ * Read the supported link modes from the extended BASE-T1 ability register
+ */
+int genphy_c45_pma_baset1_read_abilities(struct phy_device *phydev)
+{
+       int val;
+
+       val = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_PMD_BT1);
+       if (val < 0)
+               return val;
+
+       linkmode_mod_bit(ETHTOOL_LINK_MODE_10baseT1L_Full_BIT,
+                        phydev->supported,
+                        val & MDIO_PMA_PMD_BT1_B10L_ABLE);
+
+       val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_T1_STAT);
+       if (val < 0)
+               return val;
+
+       linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
+                        phydev->supported,
+                        val & MDIO_AN_STAT1_ABLE);
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(genphy_c45_pma_baset1_read_abilities);
+
 /**
  * genphy_c45_pma_read_abilities - read supported link modes from PMA
  * @phydev: target phy_device struct
@@ -977,21 +1007,9 @@ int genphy_c45_pma_read_abilities(struct phy_device *phydev)
                }
 
                if (val & MDIO_PMA_EXTABLE_BT1) {
-                       val = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_PMD_BT1);
+                       val = genphy_c45_pma_baset1_read_abilities(phydev);
                        if (val < 0)
                                return val;
-
-                       linkmode_mod_bit(ETHTOOL_LINK_MODE_10baseT1L_Full_BIT,
-                                        phydev->supported,
-                                        val & MDIO_PMA_PMD_BT1_B10L_ABLE);
-
-                       val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_T1_STAT);
-                       if (val < 0)
-                               return val;
-
-                       linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
-                                        phydev->supported,
-                                        val & MDIO_AN_STAT1_ABLE);
                }
        }
 
index 11c1e91563d4730f6ba458548727336cf27a1d5f..b254848a9c99a6060d04fc9d255fe8b22eb90a09 100644 (file)
@@ -1826,6 +1826,7 @@ int genphy_c45_an_config_aneg(struct phy_device *phydev);
 int genphy_c45_an_disable_aneg(struct phy_device *phydev);
 int genphy_c45_read_mdix(struct phy_device *phydev);
 int genphy_c45_pma_read_abilities(struct phy_device *phydev);
+int genphy_c45_pma_baset1_read_abilities(struct phy_device *phydev);
 int genphy_c45_read_eee_abilities(struct phy_device *phydev);
 int genphy_c45_pma_baset1_read_master_slave(struct phy_device *phydev);
 int genphy_c45_read_status(struct phy_device *phydev);