/* This detects PHY chip from address 0-31 by reading PHY status registers. PHY chip can be connected at any of this address.  */
static int ethernet_phy_detect(struct eth_device *dev)
/* This detects PHY chip from address 0-31 by reading PHY status registers. PHY chip can be connected at any of this address.  */
static int ethernet_phy_detect(struct eth_device *dev)
{
	u32 val;
	u16 tmp, mii_status;
	u8 addr;
	for (addr = 0; addr < 32; addr++) {
		if (miiphy_read(dev->name, addr, MII_BMSR, &mii_status)	!= 0)
			continue;
		if (mii_status == 0 || mii_status == 0xffff)
			continue;
		if (miiphy_read(dev->name, addr, MII_PHYSID1, &tmp) != 0)
			continue;
		val = tmp << 16;
		if (miiphy_read(dev->name, addr, MII_PHYSID2, &tmp) != 0)
			continue;
		val |= tmp;
		if ((val & 0xfffffff0) != 0)
			return addr;
	}
	return -1;
}