drivers: ethernet: phy: vsc8541: Add timeout on SW reset
The driver previously could enter an infinite loop if the PHY software reset failed to complete, which could happen due to hardware reset issues or MDIO bus problems. Add a timeout of 1000 iterations so we report an error in this scenario rather than causing a lockup. Signed-off-by: Robert Hancock <robert.hancock@calian.com>
This commit is contained in:
parent
aa85d76777
commit
aab1f68d08
@ -134,6 +134,7 @@ static int phy_mc_vsc8541_reset(const struct device *dev)
|
||||
const struct mc_vsc8541_config *cfg = dev->config;
|
||||
int ret;
|
||||
uint16_t reg = 0U;
|
||||
int count = 0;
|
||||
|
||||
#if DT_ANY_INST_HAS_PROP_STATUS_OKAY(reset_gpios)
|
||||
|
||||
@ -197,8 +198,15 @@ static int phy_mc_vsc8541_reset(const struct device *dev)
|
||||
|
||||
/* wait for phy finished software reset */
|
||||
do {
|
||||
phy_mc_vsc8541_read(dev, MII_BMCR, ®);
|
||||
} while (reg & MII_BMCR_RESET);
|
||||
ret = phy_mc_vsc8541_read(dev, MII_BMCR, ®);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
if (count++ > 1000) {
|
||||
LOG_ERR("phy reset timed out");
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
} while ((reg & MII_BMCR_RESET) != 0U);
|
||||
|
||||
/* configure the RGMII clk delay */
|
||||
reg = 0x0;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user