summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Binkert <nate@cvs.openbsd.org>2001-06-08 02:16:42 +0000
committerNathan Binkert <nate@cvs.openbsd.org>2001-06-08 02:16:42 +0000
commit8f0b00e0a2fd9f1d4a58ba708e6d9b464063f14d (patch)
tree19f4c99ee334735227a88287627fdebfc89bf84e
parent9e436197a7a21d6181bf07840edd20711a785e1e (diff)
Add some general support info for gigabit phys
Fix some comments Remove some dead code From NetBSD
-rw-r--r--sys/dev/mii/mii.h51
-rw-r--r--sys/dev/mii/mii_physubr.c85
-rw-r--r--sys/dev/mii/miivar.h9
-rw-r--r--sys/dev/mii/ukphy.c7
4 files changed, 121 insertions, 31 deletions
diff --git a/sys/dev/mii/mii.h b/sys/dev/mii/mii.h
index ead15f2bc5d..f8abe567722 100644
--- a/sys/dev/mii/mii.h
+++ b/sys/dev/mii/mii.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: mii.h,v 1.2 2000/08/26 20:04:17 nate Exp $ */
-/* $NetBSD: mii.h,v 1.2 1999/09/29 22:49:33 thorpej Exp $ */
+/* $OpenBSD: mii.h,v 1.3 2001/06/08 02:16:41 nate Exp $ */
+/* $NetBSD: mii.h,v 1.6 2001/04/30 19:49:08 thorpej Exp $ */
/*
* Copyright (c) 1997 Manuel Bouyer. All rights reserved.
@@ -54,13 +54,20 @@
#define MII_BMCR 0x00 /* Basic mode control register (rw) */
#define BMCR_RESET 0x8000 /* reset */
#define BMCR_LOOP 0x4000 /* loopback */
-#define BMCR_S100 0x2000 /* speed (10/100) select */
+#define BMCR_SPEED0 0x2000 /* speed selection (LSB) */
#define BMCR_AUTOEN 0x1000 /* autonegotiation enable */
#define BMCR_PDOWN 0x0800 /* power down */
#define BMCR_ISO 0x0400 /* isolate */
#define BMCR_STARTNEG 0x0200 /* restart autonegotiation */
#define BMCR_FDX 0x0100 /* Set duplex mode */
#define BMCR_CTEST 0x0080 /* collision test */
+#define BMCR_SPEED1 0x0040 /* speed selection (MSB) */
+
+#define BMCR_S10 0x0000 /* 10 Mb/s */
+#define BMCR_S100 BMCR_SPEED0 /* 100 Mb/s */
+#define BMCR_S1000 BMCR_SPEED1 /* 1000 Mb/s */
+
+#define BMCR_SPEED(x) ((x) & (BMCR_SPEED0|BMCR_SPEED1))
#define MII_BMSR 0x01 /* Basic mode status register (ro) */
#define BMSR_100T4 0x8000 /* 100 base T4 capable */
@@ -69,15 +76,25 @@
#define BMSR_10TFDX 0x1000 /* 10 base T full duplex capable */
#define BMSR_10THDX 0x0800 /* 10 base T half duplex capable */
#define BMSR_MFPS 0x0040 /* MII Frame Preamble Suppression */
+#define BMSR_100T2FDX 0x0400 /* 100 base T2 full duplex capable */
+#define BMSR_100T2HDX 0x0200 /* 100 base T2 half duplex capable */
+#define BMSR_EXTSTAT 0x0100 /* Extended status in register 15 */
+#define BMSR_MFPS 0x0040 /* MII Frame Preamble Suppression */
#define BMSR_ACOMP 0x0020 /* Autonegotiation complete */
#define BMSR_RFAULT 0x0010 /* Link partner fault */
#define BMSR_ANEG 0x0008 /* Autonegotiation capable */
#define BMSR_LINK 0x0004 /* Link status */
#define BMSR_JABBER 0x0002 /* Jabber detected */
-#define BMSR_EXT 0x0001 /* Extended capability */
+#define BMSR_EXTCAP 0x0001 /* Extended capability */
-#define BMSR_MEDIAMASK (BMSR_100T4|BMSR_100TXFDX|BMSR_100TXHDX|BMSR_10TFDX| \
- BMSR_10THDX|BMSR_ANEG)
+ /*
+ * Note that the EXTSTAT bit indicates that there is extended status
+ * info available in register 15, but 802.3 section 22.2.4.3 also
+ * states that that all 1000 Mb/s capable PHYs will set this bit to 1.
+ */
+
+#define BMSR_MEDIAMASK (BMSR_100T4|BMSR_100TXFDX|BMSR_100TXHDX| \
+ BMSR_10TFDX|BMSR_10THDX|BMSR_100T2FDX|BMSR_100T2HDX)
/*
* Convert BMSR media capabilities to ANAR bits for autonegotiation.
@@ -97,6 +114,7 @@
#define MII_REV(id2) ((id2) & IDR2_REV)
#define MII_ANAR 0x04 /* Autonegotiation advertisement (rw) */
+ /* section 28.2.4.1 and 37.2.6.1 */
#define ANAR_NP 0x8000 /* Next page (ro) */
#define ANAR_ACK 0x4000 /* link partner abilities acknowledged (ro) */
#define ANAR_RF 0x2000 /* remote fault (ro) */
@@ -109,6 +127,7 @@
#define ANAR_CSMA 0x0001 /* protocol selector CSMA/CD */
#define MII_ANLPAR 0x05 /* Autonegotiation lnk partner abilities (rw) */
+ /* section 28.2.4.1 and 37.2.6.1 */
#define ANLPAR_NP 0x8000 /* Next page (ro) */
#define ANLPAR_ACK 0x4000 /* link partner accepted ACK (ro) */
#define ANLPAR_RF 0x2000 /* remote fault (ro) */
@@ -121,10 +140,30 @@
#define ANLPAR_CSMA 0x0001 /* protocol selector CSMA/CD */
#define MII_ANER 0x06 /* Autonegotiation expansion (ro) */
+ /* section 28.2.4.1 and 37.2.6.1 */
#define ANER_MLF 0x0010 /* multiple link detection fault */
#define ANER_LPNP 0x0008 /* link parter next page-able */
#define ANER_NP 0x0004 /* next page-able */
#define ANER_PAGE_RX 0x0002 /* Page received */
#define ANER_LPAN 0x0001 /* link parter autoneg-able */
+#define MII_ANNP 0x07 /* Autonegotiation next page */
+ /* section 28.2.4.1 and 37.2.6.1 */
+
+#define MII_ANLPRNP 0x08 /* Autonegotiation link partner rx next page */
+ /* section 32.5.1 and 37.2.6.1 */
+
+#define MII_100T2CR 0x09 /* 100base-T2 control register */
+
+#define MII_100T2SR 0x0a /* 100base-T2 status register */
+
+#define MII_EXTSR 0x0f /* Extended status register */
+#define EXTSR_1000XFDX 0x8000 /* 1000X full-duplex capable */
+#define EXTSR_1000XHDX 0x4000 /* 1000X half-duplex capable */
+#define EXTSR_1000TFDX 0x2000 /* 1000T full-duplex capable */
+#define EXTSR_1000THDX 0x1000 /* 1000T half-duplex capable */
+
+#define EXTSR_MEDIAMASK (EXTSR_1000XFDX|EXTSR_1000XHDX| \
+ EXTSR_1000TFDX|EXTSR_1000THDX)
+
#endif /* _DEV_MII_MII_H_ */
diff --git a/sys/dev/mii/mii_physubr.c b/sys/dev/mii/mii_physubr.c
index 6d15ac7fafc..ee9cbcdf316 100644
--- a/sys/dev/mii/mii_physubr.c
+++ b/sys/dev/mii/mii_physubr.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: mii_physubr.c,v 1.8 2001/05/03 12:31:43 aaron Exp $ */
-/* $NetBSD: mii_physubr.c,v 1.16 2000/03/15 20:34:43 thorpej Exp $ */
+/* $OpenBSD: mii_physubr.c,v 1.9 2001/06/08 02:16:41 nate Exp $ */
+/* $NetBSD: mii_physubr.c,v 1.20 2001/04/13 23:30:09 thorpej Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -59,14 +59,17 @@
/*
* Media to register setting conversion table. Order matters.
+ * XXX 802.3 doesn't specify ANAR or ANLPAR bits for 1000base.
*/
const struct mii_media mii_media_table[] = {
{ BMCR_ISO, ANAR_CSMA }, /* None */
- { 0, ANAR_CSMA|ANAR_10 }, /* 10baseT */
- { BMCR_FDX, ANAR_CSMA|ANAR_10_FD }, /* 10baseT-FDX */
+ { BMCR_S10, ANAR_CSMA|ANAR_10 }, /* 10baseT */
+ { BMCR_S10|BMCR_FDX, ANAR_CSMA|ANAR_10_FD }, /* 10baseT-FDX */
{ BMCR_S100, ANAR_CSMA|ANAR_T4 }, /* 100baseT4 */
{ BMCR_S100, ANAR_CSMA|ANAR_TX }, /* 100baseTX */
{ BMCR_S100|BMCR_FDX, ANAR_CSMA|ANAR_TX_FD }, /* 100baseTX-FDX */
+ { BMCR_S1000, ANAR_CSMA }, /* 1000base */
+ { BMCR_S1000|BMCR_FDX, ANAR_CSMA }, /* 1000base-FDX */
};
void mii_phy_auto_timeout __P((void *));
@@ -88,7 +91,6 @@ mii_phy_setmedia(sc)
/*
* Table index is stored in the media entry.
*/
-
#ifdef DIAGNOSTIC
if (ife->ifm_data < 0 || ife->ifm_data >= MII_NMEDIA)
panic("mii_phy_setmedia");
@@ -312,7 +314,7 @@ mii_phy_statusmsg(sc)
}
if (announce) {
- s = splimp(); /* XXX Should be splnet() */
+ s = splnet();
rt_ifmsg(ifp);
splx(s);
}
@@ -338,11 +340,6 @@ mii_phy_add_media(sc)
if (sc->mii_capabilities & BMSR_10THDX) {
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_T, 0, sc->mii_inst),
MII_MEDIA_10_T);
-#if 0
- if ((sc->mii_flags & MIIF_NOLOOP) == 0)
- ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_T, IFM_LOOP,
- sc->mii_inst), MII_MEDIA_10_T);
-#endif
}
if (sc->mii_capabilities & BMSR_10TFDX) {
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_T, IFM_FDX, sc->mii_inst),
@@ -351,11 +348,6 @@ mii_phy_add_media(sc)
if (sc->mii_capabilities & BMSR_100TXHDX) {
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, 0, sc->mii_inst),
MII_MEDIA_100_TX);
-#if 0
- if ((sc->mii_flags & MIIF_NOLOOP) == 0)
- ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP,
- sc->mii_inst), MII_MEDIA_100_TX);
-#endif
}
if (sc->mii_capabilities & BMSR_100TXFDX) {
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_FDX, sc->mii_inst),
@@ -364,12 +356,30 @@ mii_phy_add_media(sc)
if (sc->mii_capabilities & BMSR_100T4) {
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_T4, 0, sc->mii_inst),
MII_MEDIA_100_T4);
-#if 0
- if ((sc->mii_flags & MIIF_NOLOOP) == 0)
- ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_T4, IFM_LOOP,
- sc->mii_inst), MII_MEDIA_100_T4);
-#endif
}
+ if (sc->mii_extcapabilities & EXTSR_MEDIAMASK) {
+ /*
+ * XXX Right now only handle 1000SX and 1000TX. Need
+ * XXX to hnalde 1000LX and 1000CX some how.
+ */
+ if (sc->mii_extcapabilities & EXTSR_1000XHDX) {
+ ADD(IFM_MAKEWORD(IFM_ETHER, IFM_1000_SX, 0,
+ sc->mii_inst), MII_MEDIA_1000);
+ }
+ if (sc->mii_extcapabilities & EXTSR_1000XFDX) {
+ ADD(IFM_MAKEWORD(IFM_ETHER, IFM_1000_SX, IFM_FDX,
+ sc->mii_inst), MII_MEDIA_1000_FDX);
+ }
+ if (sc->mii_extcapabilities & EXTSR_1000THDX) {
+ ADD(IFM_MAKEWORD(IFM_ETHER, IFM_1000_TX, 0,
+ sc->mii_inst), MII_MEDIA_1000);
+ }
+ if (sc->mii_extcapabilities & EXTSR_1000TFDX) {
+ ADD(IFM_MAKEWORD(IFM_ETHER, IFM_1000_TX, IFM_FDX,
+ sc->mii_inst), MII_MEDIA_1000_FDX);
+ }
+ }
+
if (sc->mii_capabilities & BMSR_ANEG) {
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_AUTO, 0, sc->mii_inst),
MII_NMEDIA); /* intentionally invalid index */
@@ -420,3 +430,36 @@ mii_phy_detach(self, flags)
return (0);
}
+
+/*
+ * Given an ifmedia word, return the corresponding ANAR value.
+ */
+int
+mii_anar(media)
+ int media;
+{
+ int rv;
+
+ switch (media & (IFM_TMASK|IFM_NMASK|IFM_FDX)) {
+ case IFM_ETHER|IFM_10_T:
+ rv = ANAR_10|ANAR_CSMA;
+ break;
+ case IFM_ETHER|IFM_10_T|IFM_FDX:
+ rv = ANAR_10_FD|ANAR_CSMA;
+ break;
+ case IFM_ETHER|IFM_100_TX:
+ rv = ANAR_TX|ANAR_CSMA;
+ break;
+ case IFM_ETHER|IFM_100_TX|IFM_FDX:
+ rv = ANAR_TX_FD|ANAR_CSMA;
+ break;
+ case IFM_ETHER|IFM_100_T4:
+ rv = ANAR_T4|ANAR_CSMA;
+ break;
+ default:
+ rv = 0;
+ break;
+ }
+
+ return (rv);
+}
diff --git a/sys/dev/mii/miivar.h b/sys/dev/mii/miivar.h
index 407451fbb4e..bb7562c6fd3 100644
--- a/sys/dev/mii/miivar.h
+++ b/sys/dev/mii/miivar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: miivar.h,v 1.9 2001/05/03 12:31:43 aaron Exp $ */
+/* $OpenBSD: miivar.h,v 1.10 2001/06/08 02:16:41 nate Exp $ */
/* $NetBSD: miivar.h,v 1.17 2000/03/06 20:56:57 thorpej Exp $ */
/*-
@@ -138,6 +138,7 @@ struct mii_softc {
int mii_flags; /* misc. flags; see below */
int mii_capabilities; /* capabilities from BMSR */
+ int mii_extcapabilities; /* extended capabilities */
int mii_ticks; /* MII_TICK counter */
#if defined(__NetBSD__)
@@ -195,7 +196,9 @@ struct mii_media {
#define MII_MEDIA_100_T4 3
#define MII_MEDIA_100_TX 4
#define MII_MEDIA_100_TX_FDX 5
-#define MII_NMEDIA 6
+#define MII_MEDIA_1000 6
+#define MII_MEDIA_1000_FDX 7
+#define MII_NMEDIA 8
#ifdef _KERNEL
@@ -237,6 +240,8 @@ void mii_phy_update __P((struct mii_softc *, int));
void mii_phy_statusmsg __P((struct mii_softc *));
void ukphy_status __P((struct mii_softc *));
+
+int mii_anar __P((int));
#endif /* _KERNEL */
#endif /* _DEV_MII_MIIVAR_H_ */
diff --git a/sys/dev/mii/ukphy.c b/sys/dev/mii/ukphy.c
index 27ee6d5bacd..5652a8412e0 100644
--- a/sys/dev/mii/ukphy.c
+++ b/sys/dev/mii/ukphy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ukphy.c,v 1.8 2000/08/28 05:24:06 jason Exp $ */
+/* $OpenBSD: ukphy.c,v 1.9 2001/06/08 02:16:41 nate Exp $ */
/* $NetBSD: ukphy.c,v 1.9 2000/02/02 23:34:57 thorpej Exp $ */
/*-
@@ -142,7 +142,10 @@ ukphyattach(parent, self, aux)
sc->mii_capabilities =
PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
- if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0)
+ if (sc->mii_capabilities & BMSR_EXTSTAT)
+ sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR);
+ if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0 &&
+ (sc->mii_extcapabilities & EXTSR_MEDIAMASK) == 0)
printf("%s: no media present\n", sc->mii_dev.dv_xname);
else
mii_phy_add_media(sc);