From: Reinhard Meyer Date: Thu, 07 Oct 2010 10:20:52 +0200 Subject: [U-Boot] [PATCH 1/2] drivers/net/at91_emac.c: increase timeout for autonegotiation In-Reply-To: <4CAD80DC.2050109@emk-elektronik.de> References: <1286437487-10501-1-git-send-email-andreas.devel@googlemail.com> <1286437487-10501-2-git-send-email-andreas.devel@googlemail.com> <4CAD80DC.2050109@emk-elektronik.de> Message-ID: <4CAD82E4.2030907@emk-elektronik.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de > Dear Andreas Bie?mann, >> This patch increases timeout for autonegotiation from 1 second to 3 seconds. >> Some boards (e.g. at91rm9200ek) did not negotiate within 1 second. > >> @@ -220,7 +220,7 @@ static int at91emac_phy_reset(struct eth_device *netdev) >> at91emac_write(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR, MII_BMCR, >> (BMCR_ANENABLE | BMCR_ANRESTART)); >> >> - for (i = 0; i < 100000 / 100; i++) { >> + for (i = 0; i < 30000; i++) { >> at91emac_read(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR, >> MII_BMSR, &status); >> if (status & BMSR_ANEGCOMPLETE) > > You might want to change the timeout to use the timer like here, > otherwise such looped timeouts are subject to toolchain version > and cache and optimisation and cpu clock and whatever ;) Ok, the patch did not show the udelay(100) in the next line:) With AT91 timer frequency, udelay(100) is quite exact, so the loop will work fine. Nevertheless the other timeout mechanism is more accurate and better to read (I think). Reinhard