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