Skip to contentSkip to conversation

net: phy: at803x: Use a helper to check for phy reset existence

PATCH Applied Maxime Chevallier 4 participants 4 messages Jul 15 – Jul 20

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: phy: at803x: Use a helper to check for phy reset existence

The at803x family of devices are subjected to an errata that requires hard-reseting the PHY upon link change.

That can only work if there's a physical reset line wired to the PHY, which the driver checks by looking if there's a reset GPIO configured for the MDIO device.

The reset may however be controlled through a reset controller, which isn't accounted for in the errata handling.

Besides that, PHY drivers aren't expected to directly access the mdiodev's resources directly, let's therefore wrap this with a phylib helper, that uses a similar mdio helper to check for reset existence.

This was found in preparation for bus-level resource management for better mdio scan support.

---
 drivers/net/phy/qcom/at803x.c | 2 +-
 include/linux/mdio.h          | 5 +++++
 include/linux/phy.h           | 5 +++++
 3 files changed, 11 insertions(+), 1 deletion(-)
drivers/net/phy/qcom/at803x.c +1 -1
index ba4dc07752b6..6872dbf77856 100644
@@ -537,7 +537,7 @@ static void at803x_link_change_notify(struct phy_device *phydev)
 	 * in the FIFO. In such cases, the FIFO enters an error mode it
 	 * cannot recover from by software.
 	 */
-	if (phydev->state == PHY_NOLINK && phydev->mdio.reset_gpio) {
+	if (phydev->state == PHY_NOLINK && phy_device_has_reset(phydev)) {
 		struct at803x_context context;
 
 		at803x_context_save(phydev, &context);
include/linux/mdio.h +5 -0
index 300805e66592..a7d9e3ae362a 100644
@@ -86,6 +86,11 @@ static inline void *mdiodev_get_drvdata(struct mdio_device *mdio)
 	return dev_get_drvdata(&mdio->dev);
 }
 
+static inline bool mdiodev_has_reset(struct mdio_device *mdio)
+{
+	return (mdio->reset_gpio || mdio->reset_ctrl);
+}
+
 void mdio_device_free(struct mdio_device *mdiodev);
 struct mdio_device *mdio_device_create(struct mii_bus *bus, int addr);
 int mdio_device_register(struct mdio_device *mdiodev);
include/linux/phy.h +5 -0
index fc680901275b..beff1d6fcc7c 100644
@@ -2231,6 +2231,11 @@ static inline void phy_device_reset(struct phy_device *phydev, int value)
 	mdio_device_reset(&phydev->mdio, value);
 }
 
+static inline bool phy_device_has_reset(struct phy_device *phydev)
+{
+	return mdiodev_has_reset(&phydev->mdio);
+}
+
 #define phydev_err(_phydev, format, args...)	\
 	dev_err(&_phydev->mdio.dev, format, ##args)
 
Signature · 1 line
2.55.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Maxime Chevallier

The at803x family of devices are subjected to an errata that requires hard-reseting the PHY upon link change.

That can only work if there's a physical reset line wired to the PHY, which the driver checks by looking if there's a reset GPIO configured for the MDIO device.

The reset may however be controlled through a reset controller, which isn't accounted for in the errata handling.

Quoted 8 lines

Besides that, PHY drivers aren't expected to directly access the mdiodev's resources directly, let's therefore wrap this with a phylib helper, that uses a similar mdio helper to check for reset existence.

This was found in preparation for bus-level resource management for better mdio scan support.

Andrew

Reviewed-by on v1 1/1
#2 lore raw
In reply to Maxime Chevallier

Hi Maxime

Quoted 59 lines · Maxime Chevallier

The at803x family of devices are subjected to an errata that requires hard-reseting the PHY upon link change.

That can only work if there's a physical reset line wired to the PHY, which the driver checks by looking if there's a reset GPIO configured for the MDIO device.

The reset may however be controlled through a reset controller, which isn't accounted for in the errata handling.

Besides that, PHY drivers aren't expected to directly access the mdiodev's resources directly, let's therefore wrap this with a phylib helper, that uses a similar mdio helper to check for reset existence.

This was found in preparation for bus-level resource management for better mdio scan support.

---

drivers/net/phy/qcom/at803x.c | 2 +-
include/linux/mdio.h          | 5 +++++
include/linux/phy.h           | 5 +++++
3 files changed, 11 insertions(+), 1 deletion(-)
drivers/net/phy/qcom/at803x.c +1 -1
index ba4dc07752b6..6872dbf77856 100644
@@ -537,7 +537,7 @@ static void at803x_link_change_notify(struct phy_device *phydev)
 	 * in the FIFO. In such cases, the FIFO enters an error mode it
 	 * cannot recover from by software.
 	 */
-	if (phydev->state == PHY_NOLINK && phydev->mdio.reset_gpio) {
+	if (phydev->state == PHY_NOLINK && phy_device_has_reset(phydev)) {
 		struct at803x_context context;
 
 		at803x_context_save(phydev, &context);
include/linux/mdio.h +5 -0
index 300805e66592..a7d9e3ae362a 100644
@@ -86,6 +86,11 @@ static inline void *mdiodev_get_drvdata(struct mdio_device *mdio)
 	return dev_get_drvdata(&mdio->dev);
 }
 
+static inline bool mdiodev_has_reset(struct mdio_device *mdio)
+{
+	return (mdio->reset_gpio || mdio->reset_ctrl);
+}
+
 void mdio_device_free(struct mdio_device *mdiodev);
 struct mdio_device *mdio_device_create(struct mii_bus *bus, int addr);
 int mdio_device_register(struct mdio_device *mdiodev);
include/linux/phy.h +0 -0
index fc680901275b..beff1d6fcc7c 100644
@@ -2231,6 +2231,11 @@ static inline void phy_device_reset(struct phy_device *phydev, int value)
 	mdio_device_reset(&phydev->mdio, value);

include/linux/phy.h static inline void phy_device_reset(struct phy_device *phydev, int value) · line 2241

Quoted 10 lines
include/linux/phy.h +5 -0
 }
 
+static inline bool phy_device_has_reset(struct phy_device *phydev)
+{
+	return mdiodev_has_reset(&phydev->mdio);
+}
+
 #define phydev_err(_phydev, format, args...)	\
 	dev_err(&_phydev->mdio.dev, format, ##args)
 

Thanks,
Nicolai

#3 lore raw
In reply to Maxime Chevallier
This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Quoted 8 lines · On Wed, 15 Jul 2026 12:13:54 +0200 you wrote:

The at803x family of devices are subjected to an errata that requires hard-reseting the PHY upon link change.

That can only work if there's a physical reset line wired to the PHY, which the driver checks by looking if there's a reset GPIO configured for the MDIO device.

[...]

Here is the summary with links:
- [net-next] net: phy: at803x: Use a helper to check for phy reset existence

    https://git.kernel.org/netdev/net-next/c/285fd588859f

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html