/* Please refer to your PHY manual for registers and their meanings. mii_write() 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_write(int phy_addr, int reg_addr, int data)
/* Please refer to your PHY manual for registers and their meanings. mii_write() 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_write(int phy_addr, int reg_addr, int data)
{
int timeout;
unsigned long eimr;
	EIR = EIR_MII;
	eimr = EIMR;
	EIMR &= ~EIMR_MII;
	MMFR = ( unsigned long ) ( FEC_MMFR_ST_01 | FEC_MMFR_OP_WRITE | FEC_MMFR_PA(phy_addr) | FEC_MMFR_RA(reg_addr) | FEC_MMFR_TA_10 | FEC_MMFR_DATA( data ) );
	for (timeout = 0; timeout < FEC_MII_TIMEOUT; timeout++)
	{
		if( EIR & EIR_MII)
		{
			break;
		}
	}
	if( timeout == FEC_MII_TIMEOUT )
	{
		return 0;
	}
	EIR = EIR_MII;
	EIMR = eimr;
	return 1;
}