net phylib: force to wait for link
When starting a network device wait until the link is up. Otherwise autobooting does not work with little timeout and several attempts have to be made until the network is finally up. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
11cb1620fe
commit
a1a50a4654
|
@ -400,11 +400,14 @@ int genphy_setup_forced(struct phy_device *phydev)
|
|||
return err;
|
||||
}
|
||||
|
||||
static int phy_aneg_done(struct phy_device *phydev)
|
||||
int phy_wait_aneg_done(struct phy_device *phydev)
|
||||
{
|
||||
uint64_t start = get_time_ns();
|
||||
int ctl;
|
||||
|
||||
if (phydev->autoneg == AUTONEG_DISABLE)
|
||||
return 0;
|
||||
|
||||
while (!is_timeout(start, PHY_AN_TIMEOUT * SECOND)) {
|
||||
ctl = phy_read(phydev, MII_BMSR);
|
||||
if (ctl & BMSR_ANEGCOMPLETE) {
|
||||
|
@ -451,7 +454,7 @@ int genphy_restart_aneg(struct phy_device *phydev)
|
|||
if (ctl < 0)
|
||||
return ctl;
|
||||
|
||||
return phy_aneg_done(phydev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -267,6 +267,7 @@ int phy_device_connect(struct eth_device *dev, struct mii_bus *bus, int addr,
|
|||
u32 flags, phy_interface_t interface);
|
||||
|
||||
int phy_update_status(struct phy_device *phydev);
|
||||
int phy_wait_aneg_done(struct phy_device *phydev);
|
||||
|
||||
/* Generic PHY support and helper functions */
|
||||
int genphy_restart_aneg(struct phy_device *phydev);
|
||||
|
|
|
@ -138,6 +138,9 @@ static int eth_carrier_check(int force)
|
|||
if (!eth_current->phydev)
|
||||
return 0;
|
||||
|
||||
if (force)
|
||||
phy_wait_aneg_done(eth_current->phydev);
|
||||
|
||||
if (force || is_timeout(last_link_check, 5 * SECOND) ||
|
||||
!eth_current->phydev->link) {
|
||||
ret = phy_update_status(eth_current->phydev);
|
||||
|
|
Loading…
Reference in New Issue