changelog shortlog tags branches changeset file revisions annotate raw help

Mercurial > hg > plan9front / sys/src/9/port/ethermii.c

revision 7318: 386fe43162b4
parent 7305: 617312eef5e1
     1.1--- a/sys/src/9/port/ethermii.c
     1.2+++ b/sys/src/9/port/ethermii.c
     1.3@@ -14,7 +14,8 @@ int
     1.4 mii(Mii* mii, int mask)
     1.5 {
     1.6 	MiiPhy *miiphy;
     1.7-	int bit, oui, phyno, r, rmask;
     1.8+	int bit, oui, phyno, rmask;
     1.9+	u32int id;
    1.10 
    1.11 	/*
    1.12 	 * Probe through mii for PHYs in mask;
    1.13@@ -33,10 +34,9 @@ mii(Mii* mii, int mask)
    1.14 		}
    1.15 		if(mii->mir(mii, phyno, Bmsr) == -1)
    1.16 			continue;
    1.17-		r = mii->mir(mii, phyno, Phyidr1);
    1.18-		oui = (r & 0x3FFF)<<6;
    1.19-		r = mii->mir(mii, phyno, Phyidr2);
    1.20-		oui |= r>>10;
    1.21+		id = mii->mir(mii, phyno, Phyidr1) << 16;
    1.22+		id |= mii->mir(mii, phyno, Phyidr2);
    1.23+		oui = (id & 0x3FFFFC00)>>10;
    1.24 		if(oui == 0xFFFFF || oui == 0)
    1.25 			continue;
    1.26 
    1.27@@ -44,6 +44,7 @@ mii(Mii* mii, int mask)
    1.28 			continue;
    1.29 
    1.30 		miiphy->mii = mii;
    1.31+		miiphy->id = id;
    1.32 		miiphy->oui = oui;
    1.33 		miiphy->phyno = phyno;
    1.34 
    1.35@@ -233,3 +234,29 @@ miistatus(Mii* mii)
    1.36 
    1.37 	return 0;
    1.38 }
    1.39+
    1.40+int
    1.41+miimmdr(Mii* mii, int a, int r)
    1.42+{
    1.43+	a &= 0x1F;
    1.44+	if(miimiw(mii, Mmdctrl, a) == -1)
    1.45+		return -1;
    1.46+	if(miimiw(mii, Mmddata, r) == -1)
    1.47+		return -1;
    1.48+	if(miimiw(mii, Mmdctrl, a | 0x4000) == -1)
    1.49+		return -1;
    1.50+	return miimir(mii, Mmddata);
    1.51+}
    1.52+
    1.53+int
    1.54+miimmdw(Mii* mii, int a, int r, int data)
    1.55+{
    1.56+	a &= 0x1F;
    1.57+	if(miimiw(mii, Mmdctrl, a) == -1)
    1.58+		return -1;
    1.59+	if(miimiw(mii, Mmddata, r) == -1)
    1.60+		return -1;
    1.61+	if(miimiw(mii, Mmdctrl, a | 0x4000) == -1)
    1.62+		return -1;
    1.63+	return miimiw(mii, Mmddata, data);
    1.64+}