/* Read a value from a PHY's MII register.  */
int mii_read(int ch, int phy_addr, int reg_addr, int *data)
/* Read a value from a PHY's MII register.  */
int mii_read(int ch, int phy_addr, int reg_addr, int *data)
{
	int timeout;
	ENET_EIR = ENET_EIR_MII_MASK;
	ENET_MMFR = 0
		| ENET_MMFR_ST(0x01)
		| ENET_MMFR_OP(0x2)
		| ENET_MMFR_PA(phy_addr)
		| ENET_MMFR_RA(reg_addr)
		| ENET_MMFR_TA(0x02);
	for (timeout = 0; timeout < MII_TIMEOUT; timeout++)
	{
		if (ENET_EIR & ENET_EIR_MII_MASK)
			break;
	}
	if(timeout == MII_TIMEOUT) 
		return 1;
	ENET_EIR = ENET_EIR_MII_MASK;
	*data = ENET_MMFR & 0x0000FFFF;
	return 0;
}