[U-Boot-Users] quit unclear code in cpu/arm920t/at91rm9200/ether.c Line:220

Lars Munch lars at segv.dk
Tue May 2 13:58:45 CEST 2006


On Thu, Apr 27, 2006 at 01:12:50PM +0200, Udo Jakobza wrote:
> Hello,
> 
> inside of arm_init() in the part:
> 
> /* MII management start from here */
> if (!(p_mac->EMAC_SR & AT91C_EMAC_LINK)) {
> 		if (!(ret = PhyOps.Init (p_mac))) {
> 			printf ("MAC: error during MII initialization\n");
> 			return 0;
> 		}
> 	}
> the software checks the status of a LINK-Bit. I thing the EMAC_SR register is wrong, because the EMAC_ISR has this valid LINK bit
> (AT91C_EMAC_LINK on bit 9).
> 
> Did anybody find this problem?
> If not, so I will check it with our hardware and then I will prepare a patch.

Yes, that code is wrong. The line:

if (!(p_mac->EMAC_SR & AT91C_EMAC_LINK)) {

makes no sense and always returns true. IMHO we should remove it
completely and always run the PhyOps.Init function. Checking on the
EMAC_ISR register is also wrong since it indicates link changes and is
AFAIK phy dependent and needs to have interrupts enabled.

On most at91rm9200 based systems I have worked on, I do not have link
yet when PhyOps.Init is called. So I have added a small loop in my phy
code waiting for link before returning (max 5 seconds).

Regards
Lars Munch




More information about the U-Boot mailing list