Skip to content

Commit ccb989e

Browse files
oleremkuba-moo
authored andcommitted
net: phy: microchip: Reset LAN88xx PHY to ensure clean link state on LAN7800/7850
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: 792aec4 ("add microchip LAN88xx phy driver") Signed-off-by: Oleksij Rempel <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 51ee075 commit ccb989e

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

drivers/net/phy/microchip.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,22 @@ static int lan88xx_config_aneg(struct phy_device *phydev)
351351
static void lan88xx_link_change_notify(struct phy_device *phydev)
352352
{
353353
int temp;
354+
int ret;
355+
356+
/* Reset PHY to ensure MII_LPA provides up-to-date information. This
357+
* issue is reproducible only after parallel detection, as described
358+
* in IEEE 802.3-2022, Section 28.2.3.1 ("Parallel detection function"),
359+
* where the link partner does not support auto-negotiation.
360+
*/
361+
if (phydev->state == PHY_NOLINK) {
362+
ret = phy_init_hw(phydev);
363+
if (ret < 0)
364+
goto link_change_notify_failed;
365+
366+
ret = _phy_start_aneg(phydev);
367+
if (ret < 0)
368+
goto link_change_notify_failed;
369+
}
354370

355371
/* At forced 100 F/H mode, chip may fail to set mode correctly
356372
* when cable is switched between long(~50+m) and short one.
@@ -377,6 +393,11 @@ static void lan88xx_link_change_notify(struct phy_device *phydev)
377393
temp |= LAN88XX_INT_MASK_MDINTPIN_EN_;
378394
phy_write(phydev, LAN88XX_INT_MASK, temp);
379395
}
396+
397+
return;
398+
399+
link_change_notify_failed:
400+
phydev_err(phydev, "Link change process failed %pe\n", ERR_PTR(ret));
380401
}
381402

382403
/**

0 commit comments

Comments
 (0)