Other Parts Discussed in Thread: HALCOGEN, DP83640
Hi
file source/HL_phy_dp83640.c generated by HalCoGen (all versions include latest 4.6.0) contain this code
uint32 Dp83640IDGet(uint32 mdioBaseAddr, uint32 phyAddr)
{
uint32 id = 0U;
uint16 data = 0U;
/* read the ID1 register */
(void)MDIOPhyRegRead(mdioBaseAddr, phyAddr, (uint32)PHY_ID1, &data);
/* update the ID1 value */
id = (uint32)data;
id = (uint32)((uint32)id << PHY_ID_SHIFT);
/* read the ID2 register */
(void)MDIOPhyRegRead(mdioBaseAddr, phyAddr, (uint32)PHY_ID2, &data);
/* update the ID2 value */
id |= data;
/* return the ID in ID1:ID2 format */
return id;
}
This code is sensitive to race condition with chip reset. First MDIOPhyRegRead could fail when chip reset isn't finished. Chip reset can be finished immediately after. In this conditions second MDIOPhyRegRead didn't fail. And function returns invalid PHY_ID.
