b53bf5f79cdc4c821f7b22bba9a305f79b664b94
[openwrt/svn-archive/archive.git] / target / linux / ixp4xx / patches-2.6.25 / 203-npe_driver_phy_reset_autoneg.patch
1 Index: linux-2.6.25.4/drivers/net/arm/ixp4xx_eth.c
2 ===================================================================
3 --- linux-2.6.25.4.orig/drivers/net/arm/ixp4xx_eth.c
4 +++ linux-2.6.25.4/drivers/net/arm/ixp4xx_eth.c
5 @@ -322,8 +322,12 @@ static void phy_reset(struct net_device
6 struct port *port = netdev_priv(dev);
7 int phy_id = port->mii[idx].phy_id;
8 int cycles = 0;
9 + u16 bmcr;
10
11 - mdio_write(dev, phy_id, MII_BMCR, port->mii_bmcr[idx] | BMCR_RESET);
12 + /* reset the PHY */
13 + bmcr = mdio_read(dev, phy_id, MII_BMCR);
14 + bmcr |= BMCR_ANENABLE;
15 + mdio_write(dev, phy_id, MII_BMCR, bmcr | BMCR_RESET);
16
17 while (cycles < MAX_MII_RESET_RETRIES) {
18 if (!(mdio_read(dev, phy_id, MII_BMCR) & BMCR_RESET)) {
19 @@ -331,13 +335,23 @@ static void phy_reset(struct net_device
20 printk(KERN_DEBUG "%s: phy_reset() took %i cycles\n",
21 dev->name, cycles);
22 #endif
23 - return;
24 + break;
25 }
26 udelay(1);
27 cycles++;
28 }
29
30 - printk(KERN_ERR "%s: MII reset failed on PHY%2d\n", dev->name, phy_id);
31 + if (cycles == MAX_MII_RESET_RETRIES) {
32 + printk(KERN_ERR "%s: MII reset failed on PHY%2d\n", dev->name,
33 + phy_id);
34 + return;
35 + }
36 +
37 + /* restart auto negotiation */
38 + bmcr = mdio_read(dev, phy_id, MII_BMCR);
39 + bmcr |= (BMCR_ANENABLE | BMCR_ANRESTART);
40 + mdio_write(dev, phy_id, MII_BMCR, bmcr);
41 +
42 }
43
44 static void eth_set_duplex(struct port *port, int full_duplex)