git: 9front

Download patch

ref: e4878ad8a758ee30a459607841d95b5e9f275464
parent: 8417623637b66273996e1dcae96932e9b1d672a9
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Fri Nov 1 19:39:41 EDT 2013

make auto negotiation work on 82562et (thanks mischief!)

the diver used to skip auto negotiation when
auto-negotiation enable (bit 12 in command register)
was clear.

setting the bit now, which makes auto negotiation work.

we skip auto negotiation only when it was already enabled
and status regiser indicates completion (bit 9).

--- a/sys/src/9/pc/ether82557.c
+++ b/sys/src/9/pc/ether82557.c
@@ -1212,26 +1212,26 @@
 			 */
 			miir(ctlr, phyaddr, 0x01);
 			bmsr = miir(ctlr, phyaddr, 0x01);
-			if((miir(ctlr, phyaddr, 0) & 0x1000) && !(bmsr & 0x0020)){
-				miiw(ctlr, phyaddr, 0x1A, 0x2010);
-				x = miir(ctlr, phyaddr, 0);
-				miiw(ctlr, phyaddr, 0, 0x0200|x);
-				for(i = 0; i < 3000; i++){
-					delay(1);
-					if(miir(ctlr, phyaddr, 0x01) & 0x0020)
-						break;
-				}
-				miiw(ctlr, phyaddr, 0x1A, 0x2000);
-					
-				anar = miir(ctlr, phyaddr, 0x04);
-				anlpar = miir(ctlr, phyaddr, 0x05) & 0x03E0;
-				anar &= anlpar;
-				bmcr = 0;
-				if(anar & 0x380)
-					bmcr = 0x2000;
-				if(anar & 0x0140)
-					bmcr |= 0x0100;
+			if((miir(ctlr, phyaddr, 0) & 0x1000) && (bmsr & 0x0020))
+				break;
+			miiw(ctlr, phyaddr, 0x1A, 0x2010);
+			x = miir(ctlr, phyaddr, 0);
+			miiw(ctlr, phyaddr, 0, 0x1200|x);
+			for(i = 0; i < 3000; i++){
+				delay(1);
+				if(miir(ctlr, phyaddr, 0x01) & 0x0020)
+					break;
 			}
+			miiw(ctlr, phyaddr, 0x1A, 0x2000);
+					
+			anar = miir(ctlr, phyaddr, 0x04);
+			anlpar = miir(ctlr, phyaddr, 0x05) & 0x03E0;
+			anar &= anlpar;
+			bmcr = 0;
+			if(anar & 0x380)
+				bmcr = 0x2000;
+			if(anar & 0x0140)
+				bmcr |= 0x0100;
 			break;
 		}
 
--