From: Wong Vee Khee Date: Tue, 23 Mar 2021 16:46:40 +0000 (+0800) Subject: net: phy: add genphy_c45_loopback X-Git-Tag: v5.15~1236^2~415^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0ef25ed104ac17fa0586fbb076f24a5e8940b966;p=platform%2Fkernel%2Flinux-starfive.git net: phy: add genphy_c45_loopback Add generic code to enable C45 PHY loopback into the common phy-c45.c file. This will allow C45 PHY drivers aceess this by setting .set_loopback. Suggested-by: Heiner Kallweit Signed-off-by: Wong Vee Khee Reviewed-by: Heiner Kallweit Reviewed-by: Andrew Lunn Signed-off-by: David S. Miller --- diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c index 077f292..91e3acb 100644 --- a/drivers/net/phy/phy-c45.c +++ b/drivers/net/phy/phy-c45.c @@ -560,6 +560,14 @@ int gen10g_config_aneg(struct phy_device *phydev) } EXPORT_SYMBOL_GPL(gen10g_config_aneg); +int genphy_c45_loopback(struct phy_device *phydev, bool enable) +{ + return phy_modify_mmd(phydev, MDIO_MMD_PCS, MDIO_CTRL1, + MDIO_PCS_CTRL1_LOOPBACK, + enable ? MDIO_PCS_CTRL1_LOOPBACK : 0); +} +EXPORT_SYMBOL_GPL(genphy_c45_loopback); + struct phy_driver genphy_c45_driver = { .phy_id = 0xffffffff, .phy_id_mask = 0xffffffff, diff --git a/include/linux/phy.h b/include/linux/phy.h index 1a12e44..8e2cf84 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1532,6 +1532,7 @@ int genphy_c45_read_mdix(struct phy_device *phydev); int genphy_c45_pma_read_abilities(struct phy_device *phydev); int genphy_c45_read_status(struct phy_device *phydev); int genphy_c45_config_aneg(struct phy_device *phydev); +int genphy_c45_loopback(struct phy_device *phydev, bool enable); /* Generic C45 PHY driver */ extern struct phy_driver genphy_c45_driver;