/* Read PHY register. Return 1 if successfully, 0 if timeout.  */
unsigned char EMAC_ReadPhy(unsigned char PhyAddress, unsigned char Address, unsigned int *pValue, unsigned int retry)
/* Read PHY register. Return 1 if successfully, 0 if timeout.  */
unsigned char EMAC_ReadPhy(unsigned char PhyAddress, unsigned char Address, unsigned int *pValue, unsigned int retry)
{
    AT91C_BASE_EMAC->EMAC_MAN = (AT91C_EMAC_SOF & (0x01 << 30))
                              | (AT91C_EMAC_CODE & (2 << 16))
                              | (AT91C_EMAC_RW & (2 << 28))
                              | (AT91C_EMAC_PHYA & ((PhyAddress & 0x1f) << 23))
                              | (AT91C_EMAC_REGA & (Address << 18));
    if ( EMAC_WaitPhy(retry) == 0 ) {
        trace_LOG(trace_ERROR, "TimeOut EMAC_ReadPhy\n\r");
        return 0;
    }
    *pValue = ( AT91C_BASE_EMAC->EMAC_MAN & 0x0000ffff );
    return 1;
}