shithub: riscv

Download patch

ref: f87baec1d0369764b761e8ca26a910e982123453
parent: b41bf07867e4bc7613b1e876219c571171e389c6
author: cinap_lenrek <[email protected]>
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;
 		}