[PATCH 1/3] net: phy: allow PHY drivers to implement their own software reset

Stefan Kerkmann s.kerkmann at pengutronix.de
Thu May 23 07:40:28 PDT 2024


This is a port of linux commit 9df81dd7583d14862d0cfb673a941b261f3b2112
("net: phy: allow PHY drivers to implement their own software reset")
which implements the ability for phy drivers to implement the own
non-standard software reset sequence.

A side effect is that fixups will now applied always even if
.config_init is undefined. This shouldn't be possible to happen though,
because phy_driver_register will populate the member with
genphy_config_init in that case, so the member should never be NULL.

Signed-off-by: Stefan Kerkmann <s.kerkmann at pengutronix.de>
---
 drivers/net/phy/phy.c | 16 ++++++++++++++--
 include/linux/phy.h   |  5 +++++
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index abd78b2c80..a83f183302 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -1108,14 +1108,26 @@ int phy_init_hw(struct phy_device *phydev)
 	struct phy_driver *phydrv = to_phy_driver(phydev->dev.driver);
 	int ret;
 
-	if (!phydrv || !phydrv->config_init)
+	if (!phydrv)
 		return 0;
 
+	if (phydrv->soft_reset) {
+		ret = phydrv->soft_reset(phydev);
+		if (ret < 0)
+			return ret;
+	}
+
 	ret = phy_scan_fixups(phydev);
 	if (ret < 0)
 		return ret;
 
-	return phydrv->config_init(phydev);
+	if (phydrv->config_init) {
+		ret = phydrv->config_init(phydev);
+		if (ret < 0)
+			return ret;
+	}
+
+	return 0;
 }
 
 static struct phy_driver genphy_driver = {
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 7da4f94e0e..a6b96a5984 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -275,6 +275,11 @@ struct phy_driver {
 	const void *driver_data;
 	bool is_phy;
 
+	/**
+	 * @soft_reset: Called to issue a PHY software reset
+	 */
+	int (*soft_reset)(struct phy_device *phydev);
+
 	/*
 	 * Called to initialize the PHY,
 	 * including after a reset

-- 
2.39.2




More information about the barebox mailing list