MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_phy_reset

Function rt_phy_reset

components/drivers/phy/phy.c:225–260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

223}
224
225int rt_phy_reset(struct rt_phy_device *phydev)
226{
227 int reg;
228 int timeout = 500;
229 int devad = RT_MDIO_DEVAD_NONE;
230
231 if (phydev->flags & RT_PHY_FLAG_BROKEN_RESET)
232 return 0;
233
234 if (rt_phy_write(phydev, devad, RT_MII_BMCR, RT_BMCR_RESET) < 0)
235 {
236 LOG_D("PHY reset failed\n");
237 return -1;
238 }
239
240 reg = rt_phy_read(phydev, devad, RT_MII_BMCR);
241 while ((reg & RT_BMCR_RESET) && timeout--)
242 {
243 reg = rt_phy_read(phydev, devad, RT_MII_BMCR);
244
245 if (reg < 0)
246 {
247 LOG_D("PHY status read failed\n");
248 return -1;
249 }
250 rt_thread_mdelay(1);
251 }
252
253 if (reg & RT_BMCR_RESET)
254 {
255 LOG_D("PHY reset timed out\n");
256 return -1;
257 }
258
259 return 0;
260}
261
262static struct rt_bus rt_phy_bus;
263

Callers 1

rt_phy_get_deviceFunction · 0.85

Calls 3

rt_thread_mdelayFunction · 0.85
rt_phy_writeFunction · 0.70
rt_phy_readFunction · 0.70

Tested by

no test coverage detected