--- zzzz-none-000/linux-4.9.276/drivers/net/phy/phy_device.c 2021-07-20 14:21:16.000000000 +0000 +++ falcon-5530-750/linux-4.9.276/drivers/net/phy/phy_device.c 2023-04-05 08:19:01.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,11 @@ if ((phy_id & 0x1fffffff) == 0x1fffffff) return ERR_PTR(-ENODEV); +#if IS_ENABLED(CONFIG_PHY_ID0_JZ_66791_PANIC) + if (!phy_id) + panic("JZ-66791: mdio bus lockup"); +#endif + return phy_device_create(bus, addr, phy_id, is_c45, &c45_ids); } EXPORT_SYMBOL(get_phy_device); @@ -924,6 +930,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 +1023,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);