summaryrefslogtreecommitdiffstats
path: root/target/linux/ixp4xx/patches-2.6.25/203-npe_driver_phy_reset_autoneg.patch
blob: b53bf5f79cdc4c821f7b22bba9a305f79b664b94 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Index: linux-2.6.25.4/drivers/net/arm/ixp4xx_eth.c
===================================================================
--- linux-2.6.25.4.orig/drivers/net/arm/ixp4xx_eth.c
+++ linux-2.6.25.4/drivers/net/arm/ixp4xx_eth.c
@@ -322,8 +322,12 @@ static void phy_reset(struct net_device 
 	struct port *port = netdev_priv(dev);
 	int phy_id = port->mii[idx].phy_id;
 	int cycles = 0;
+	u16 bmcr;
 
-	mdio_write(dev, phy_id, MII_BMCR, port->mii_bmcr[idx] | BMCR_RESET);
+	/* reset the PHY */
+	bmcr = mdio_read(dev, phy_id, MII_BMCR);
+	bmcr |= BMCR_ANENABLE;
+	mdio_write(dev, phy_id, MII_BMCR, bmcr | BMCR_RESET);
 
 	while (cycles < MAX_MII_RESET_RETRIES) {
 		if (!(mdio_read(dev, phy_id, MII_BMCR) & BMCR_RESET)) {
@@ -331,13 +335,23 @@ static void phy_reset(struct net_device 
 			printk(KERN_DEBUG "%s: phy_reset() took %i cycles\n",
 			       dev->name, cycles);
 #endif
-			return;
+			break;
 		}
 		udelay(1);
 		cycles++;
 	}
 
-	printk(KERN_ERR "%s: MII reset failed on PHY%2d\n", dev->name, phy_id);
+	if (cycles == MAX_MII_RESET_RETRIES) {
+		printk(KERN_ERR "%s: MII reset failed on PHY%2d\n", dev->name,
+								phy_id);
+		return;
+	}
+
+	/* restart auto negotiation */
+	bmcr = mdio_read(dev, phy_id, MII_BMCR);
+	bmcr |= (BMCR_ANENABLE | BMCR_ANRESTART);
+	mdio_write(dev, phy_id, MII_BMCR, bmcr);
+
 }
 
 static void eth_set_duplex(struct port *port, int full_duplex)