diff options
author | Oleksij Rempel <o.rempel@pengutronix.de> | 2022-05-06 06:23:54 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2022-05-09 13:09:29 +0200 |
commit | b9a366f3d874ce1c9c0148ec399f2ce4ab05a467 (patch) | |
tree | 24bfc126fa8e922e615f33b2b099d420ee0d27f3 /drivers/net/phy/phy-c45.c | |
parent | net: phy: genphy_c45_pma_baset1_setup_master_slave: do no set unknown configu... (diff) | |
download | linux-b9a366f3d874ce1c9c0148ec399f2ce4ab05a467.tar.xz linux-b9a366f3d874ce1c9c0148ec399f2ce4ab05a467.zip |
net: phy: introduce genphy_c45_pma_baset1_read_master_slave()
Move baset1 specific part of genphy_c45_read_pma() code to
separate function to make it reusable by PHY drivers.
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/phy/phy-c45.c')
-rw-r--r-- | drivers/net/phy/phy-c45.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c index b1f7c63f66cd..d440b76a18b4 100644 --- a/drivers/net/phy/phy-c45.c +++ b/drivers/net/phy/phy-c45.c @@ -551,6 +551,30 @@ int genphy_c45_read_lpa(struct phy_device *phydev) EXPORT_SYMBOL_GPL(genphy_c45_read_lpa); /** + * genphy_c45_pma_baset1_read_master_slave - read forced master/slave + * configuration + * @phydev: target phy_device struct + */ +int genphy_c45_pma_baset1_read_master_slave(struct phy_device *phydev) +{ + int val; + + phydev->master_slave_state = MASTER_SLAVE_STATE_UNKNOWN; + + val = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_PMD_BT1_CTRL); + if (val < 0) + return val; + + if (val & MDIO_PMA_PMD_BT1_CTRL_CFG_MST) + phydev->master_slave_state = MASTER_SLAVE_STATE_MASTER; + else + phydev->master_slave_state = MASTER_SLAVE_STATE_SLAVE; + + return 0; +} +EXPORT_SYMBOL_GPL(genphy_c45_pma_baset1_read_master_slave); + +/** * genphy_c45_read_pma - read link speed etc from PMA * @phydev: target phy_device struct */ @@ -591,14 +615,9 @@ int genphy_c45_read_pma(struct phy_device *phydev) phydev->duplex = DUPLEX_FULL; if (genphy_c45_baset1_able(phydev)) { - val = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_PMD_BT1_CTRL); + val = genphy_c45_pma_baset1_read_master_slave(phydev); if (val < 0) return val; - - if (MDIO_PMA_PMD_BT1_CTRL_CFG_MST) - phydev->master_slave_state = MASTER_SLAVE_STATE_MASTER; - else - phydev->master_slave_state = MASTER_SLAVE_STATE_SLAVE; } return 0; |