/* Please refer to your PHY manual for registers and their meanings. mii_read() polls for the FEC's MII interrupt event and clears it. If after a suitable amount of time the event isn't triggered, a value of 0 is returned.  */
static int fec_mii_read(int phy_addr, int reg_addr, unsigned short *data)
/* Please refer to your PHY manual for registers and their meanings. mii_read() polls for the FEC's MII interrupt event and clears it. If after a suitable amount of time the event isn't triggered, a value of 0 is returned.  */
static int fec_mii_read(int phy_addr, int reg_addr, unsigned short *data)
{
int timeout;
unsigned long eimr;
	EIR = 0xffffffff;
	eimr = EIMR;
	EIMR &= ~EIMR_MII;
	MMFR = ( unsigned long ) ( FEC_MMFR_ST_01 | FEC_MMFR_OP_READ | FEC_MMFR_PA(phy_addr) | FEC_MMFR_RA(reg_addr) | FEC_MMFR_TA_10 );
	for (timeout = 0; timeout < FEC_MII_TIMEOUT; timeout++)
	{
		if (EIR)
		{
			break;
		}
	}
	if(timeout == FEC_MII_TIMEOUT)
	{
		return 0;
	}
	EIR = EIR_MII;
	EIMR = eimr;
	*data = (unsigned short)(MMFR & 0x0000FFFF);
	return 1;
}