/* Description: Reads the ID registers of the PHY at @addr on the @bus, stores it in @phy_id and returns zero on success.  */
int get_phy_id(struct mii_dev *bus, int addr, int devad, uint32_t *phy_id)
/* Description: Reads the ID registers of the PHY at @addr on the @bus, stores it in @phy_id and returns zero on success.  */
int get_phy_id(struct mii_dev *bus, int addr, int devad, uint32_t *phy_id)
{
    int phy_reg;
    phy_reg = bus->read(bus, addr, devad, MII_PHYSID1);
    if (phy_reg < 0)
        return -EIO;
    *phy_id = (phy_reg & 0xffff) << 16;
    phy_reg = bus->read(bus, addr, devad, MII_PHYSID2);
    if (phy_reg < 0)
        return -EIO;
    *phy_id |= (phy_reg & 0xffff);
    return 0;
}