summaryrefslogtreecommitdiffstats
path: root/target/linux/at91/patches-2.6.21/010-dm9161a-phyfix.patch
blob: 7d7d51f5d02048ae26f525b1394ca50b6f02bd19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Index: linux-2.6.21.7/drivers/net/arm/at91_ether.c
===================================================================
--- linux-2.6.21.7.orig/drivers/net/arm/at91_ether.c
+++ linux-2.6.21.7/drivers/net/arm/at91_ether.c
@@ -146,6 +146,7 @@ static void update_linkspeed(struct net_
 	struct at91_private *lp = netdev_priv(dev);
 	unsigned int bmsr, bmcr, lpa, mac_cfg;
 	unsigned int speed, duplex;
+	unsigned long timeout = jiffies + HZ;
 
 	if (!mii_link_ok(&lp->mii)) {		/* no link */
 		netif_carrier_off(dev);
@@ -158,8 +159,15 @@ static void update_linkspeed(struct net_
 	read_phy(lp->phy_address, MII_BMSR, &bmsr);
 	read_phy(lp->phy_address, MII_BMCR, &bmcr);
 	if (bmcr & BMCR_ANENABLE) {				/* AutoNegotiation is enabled */
-		if (!(bmsr & BMSR_ANEGCOMPLETE))
-			return;			/* Do nothing - another interrupt generated when negotiation complete */
+		while (!(bmsr & BMSR_ANEGCOMPLETE)) {
+			if (time_after(jiffies, timeout)) {
+				printk("at91_ether: Auto-negotiate timeout\n");
+				return;
+			}
+			read_phy(lp->phy_address, MII_BMSR, &bmsr);
+			read_phy(lp->phy_address, MII_BMCR, &bmcr);
+			cpu_relax();
+		}
 
 		read_phy(lp->phy_address, MII_LPA, &lpa);
 		if ((lpa & LPA_100FULL) || (lpa & LPA_100HALF)) speed = SPEED_100;