Massimiliano Cialdi

Autonegotiation in PHY_Init() hangs

Discussion created by Massimiliano Cialdi on Jul 4, 2017
Latest reply on Aug 29, 2017 by Gustavo Costa

PHY driver provided with KSDK 2.2 has the function PHY_Init() that need to be explained:

 

in particular line 102:

 

result = PHY_Write(base, phyAddr, PHY_BASICCONTROL_REG,
    (PHY_BCTL_AUTONEG_MASK | PHY_BCTL_RESTART_AUTONEG_MASK));
if (result == kStatus_Success)
{
    /* Check auto negotiation complete. */
    while (counter --)
    {
        result = PHY_Read(base, phyAddr, PHY_BASICSTATUS_REG, &bssReg);
        if ( result == kStatus_Success)
        {
            if ((bssReg & PHY_BSTATUS_AUTONEGCOMP_MASK) != 0)
            {
                break;
            }
        }

        if (!counter)
        {
            return kStatus_PHY_AutoNegotiateFail;
        }
    }
}

 

If the link is down (eg. ethernet cable disconnected) it loops until count is not 0. count is initialize to 1048575, so it loops for many seconds.

This results, in an hands of many seconds at startup.

I wonder why the check is done without check link state.

 

best regards

Max

Outcomes