net: phy: microchip: Reset LAN88xx PHY to ensure clean link state on LAN7800/7850

BugLink: https://bugs.launchpad.net/bugs/2102118

[ Upstream commit ccb989e4d1efe0dd81b28c437443532d80d9ecee ]

Fix outdated MII_LPA data in the LAN88xx PHY, which is used in LAN7800
and LAN7850 USB Ethernet controllers. Due to a hardware limitation, the
PHY cannot reliably update link status after parallel detection when the
link partner does not support auto-negotiation. To mitigate this, add a
PHY reset in `lan88xx_link_change_notify()` when `phydev->state` is
`PHY_NOLINK`, ensuring the PHY starts in a clean state and reports
accurate fixed link parallel detection results.

Fixes: 792aec47d5 ("add microchip LAN88xx phy driver")
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Link: https://patch.msgid.link/20241125084050.414352-1-o.rempel@pengutronix.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Koichiro Den <koichiro.den@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
This commit is contained in:
Oleksij Rempel
2025-03-12 22:51:00 +09:00
committed by Stefan Bader
parent 5e897b2914
commit 7026cca30f
+21
View File
@@ -345,6 +345,22 @@ static int lan88xx_config_aneg(struct phy_device *phydev)
static void lan88xx_link_change_notify(struct phy_device *phydev)
{
int temp;
int ret;
/* Reset PHY to ensure MII_LPA provides up-to-date information. This
* issue is reproducible only after parallel detection, as described
* in IEEE 802.3-2022, Section 28.2.3.1 ("Parallel detection function"),
* where the link partner does not support auto-negotiation.
*/
if (phydev->state == PHY_NOLINK) {
ret = phy_init_hw(phydev);
if (ret < 0)
goto link_change_notify_failed;
ret = _phy_start_aneg(phydev);
if (ret < 0)
goto link_change_notify_failed;
}
/* At forced 100 F/H mode, chip may fail to set mode correctly
* when cable is switched between long(~50+m) and short one.
@@ -371,6 +387,11 @@ static void lan88xx_link_change_notify(struct phy_device *phydev)
temp |= LAN88XX_INT_MASK_MDINTPIN_EN_;
phy_write(phydev, LAN88XX_INT_MASK, temp);
}
return;
link_change_notify_failed:
phydev_err(phydev, "Link change process failed %pe\n", ERR_PTR(ret));
}
static struct phy_driver microchip_phy_driver[] = {