* @brief get phy id * * get phy id by read the register 2 and 3 of PHY device, * Register of the MII management interface stipulates that * register 2 contains thehigh 16 bits of the PHY’s identifier * the register 3 contains the low 16 bits of the PHY’s identifier * * @param bus MII bus pointer * @param addr PHY device address * @param devad dev addr if be set to zero it means c22 mode
| 328 | * @return if read success return 0,else return -RT_EIO |
| 329 | */ |
| 330 | static int get_phy_id(struct mii_bus *bus, int addr, int devad, rt_uint32_t *phy_id) |
| 331 | { |
| 332 | int phy_reg; |
| 333 | |
| 334 | phy_reg = bus->read(bus, addr, devad, RT_MII_PHYSID1); |
| 335 | |
| 336 | if (phy_reg < 0) |
| 337 | return -RT_EIO; |
| 338 | |
| 339 | *phy_id = (phy_reg & 0xffff) << 16; |
| 340 | |
| 341 | phy_reg = bus->read(bus, addr, devad, RT_MII_PHYSID2); |
| 342 | |
| 343 | if (phy_reg < 0) |
| 344 | return -RT_EIO; |
| 345 | |
| 346 | *phy_id |= (phy_reg & 0xffff); |
| 347 | |
| 348 | return 0; |
| 349 | } |
| 350 | |
| 351 | /** |
| 352 | * @brief create phy device by mask |
no test coverage detected