--- zzzz-none-000/linux-4.9.218/drivers/net/phy/phy_device.c 2020-04-02 15:20:41.000000000 +0000 +++ seale-7590ax-750/linux-4.9.218/drivers/net/phy/phy_device.c 2023-03-29 10:59:07.000000000 +0000 @@ -334,6 +334,7 @@ dev->pause = 0; dev->asym_pause = 0; dev->link = 1; + dev->port = PORT_TP; dev->interface = PHY_INTERFACE_MODE_GMII; dev->autoneg = AUTONEG_ENABLE; @@ -533,6 +534,9 @@ if ((phy_id & 0x1fffffff) == 0x1fffffff) return ERR_PTR(-ENODEV); + if (!phy_id) + panic("JZ-66791: mdio bus lockup"); + return phy_device_create(bus, addr, phy_id, is_c45, &c45_ids); } EXPORT_SYMBOL(get_phy_device); @@ -924,6 +928,14 @@ phydev->state = PHY_READY; + /* Port is set to PORT_TP by default and the actual PHY driver will set + * it to different value depending on the PHY configuration. If we have + * the generic PHY driver we can't figure it out, thus set the old + * legacy PORT_MII value. + */ + if (using_genphy) + phydev->port = PORT_MII; + /* Initial carrier state is off as the phy is about to be * (re)initialized. */ @@ -1009,6 +1021,9 @@ struct mii_bus *bus; int i; + if (phydev->drv && phydev->drv->detach) + phydev->drv->detach(phydev); + phydev->attached_dev->phydev = NULL; phydev->attached_dev = NULL; phy_suspend(phydev);