diff options
author | Aaron Campbell <aaron@cvs.openbsd.org> | 2000-09-07 20:10:22 +0000 |
---|---|---|
committer | Aaron Campbell <aaron@cvs.openbsd.org> | 2000-09-07 20:10:22 +0000 |
commit | 653e038f4e286aadac796ed6c0cce53819bcb399 (patch) | |
tree | 0cec406cc6e743d5ec79542ff418b3b1b60a4ccf /sys/dev | |
parent | b1f70bd88e1320c8a578b5f576ae5e58efd3ee33 (diff) |
During the last FreeBSD dc(4) sync, I very stupidly forgot to check for changes
in dcphy(4) as well, breaking some cards (i.e., the Macronix PMAC 98715). This
commit brings dcphy up-to-date. Thanks to cgruber@troba.com and ericj@ for
providing me with Macronix cards for testing.
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/mii/dcphy.c | 89 |
1 files changed, 27 insertions, 62 deletions
diff --git a/sys/dev/mii/dcphy.c b/sys/dev/mii/dcphy.c index f9ccebb2c91..e750b476908 100644 --- a/sys/dev/mii/dcphy.c +++ b/sys/dev/mii/dcphy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dcphy.c,v 1.3 2000/08/26 20:04:17 nate Exp $ */ +/* $OpenBSD: dcphy.c,v 1.4 2000/09/07 20:10:21 aaron Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -31,7 +31,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/mii/dcphy.c,v 1.2 1999/12/13 21:45:13 wpaul Exp $ + * $FreeBSD: src/sys/dev/mii/dcphy.c,v 1.5 2000/06/05 19:37:15 wpaul Exp $ */ /* @@ -47,7 +47,6 @@ #include <sys/device.h> #include <sys/systm.h> #include <sys/kernel.h> -#include <sys/malloc.h> #include <sys/socket.h> #include <sys/errno.h> #include <sys/socket.h> @@ -220,6 +219,7 @@ dcphy_service(sc, mii, cmd) switch (IFM_SUBTYPE(ife->ifm_media)) { case IFM_AUTO: /*dcphy_reset(sc);*/ + sc->mii_flags &= ~MIIF_DOINGAUTO; (void) dcphy_auto(sc, 0); break; case IFM_100_T4: @@ -280,57 +280,21 @@ dcphy_service(sc, mii, cmd) if ((mii->mii_ifp->if_flags & IFF_UP) == 0) return (0); - if (sc->mii_flags & MIIF_DOINGAUTO) { - if (++sc->mii_ticks != 5) - return(0); - else { - sc->mii_ticks = 0; - sc->mii_flags &= ~MIIF_DOINGAUTO; - sc->mii_flags |= MIIF_AUTOTIMEOUT; - } - } + reg = CSR_READ_4(dc_sc, DC_10BTSTAT) & + (DC_TSTAT_LS10|DC_TSTAT_LS100); - sc->mii_flags &= ~MIIF_DOINGAUTO; + if (!(reg & DC_TSTAT_LS10) || !(reg & DC_TSTAT_LS100)) + return (0); /* - * Check to see if we have link. If we do, we don't - * need to restart the autonegotiation process. Read - * the BMSR twice in case it's latched. + * Only retry autonegotiation every 5 seconds. */ - reg = CSR_READ_4(dc_sc, DC_10BTSTAT) & - (DC_TSTAT_LS10|DC_TSTAT_LS100); - - if (IFM_SUBTYPE(mii->mii_media_active) == IFM_100_TX && - !(reg & DC_TSTAT_LS100)) { - if (sc->mii_flags & MIIF_AUTOTIMEOUT) { - sc->mii_flags &= ~MIIF_AUTOTIMEOUT; - break; - } else - return(0); - } else if (IFM_SUBTYPE(mii->mii_media_active) == IFM_10_T && - !(reg & DC_TSTAT_LS10)) { - if (sc->mii_flags & MIIF_AUTOTIMEOUT) { - sc->mii_flags &= ~MIIF_AUTOTIMEOUT; - break; - } else - return(0); - } else if (IFM_SUBTYPE(mii->mii_media_active) == IFM_NONE && - (!(reg & DC_TSTAT_LS10) || !(reg & DC_TSTAT_LS100))) { - if (sc->mii_flags & MIIF_AUTOTIMEOUT) { - sc->mii_flags &= ~MIIF_AUTOTIMEOUT; - break; - } else - return(0); - } else if (CSR_READ_4(dc_sc, DC_ISR) & DC_ISR_LINKGOOD) { - if (sc->mii_flags & MIIF_AUTOTIMEOUT) { - sc->mii_flags &= ~MIIF_AUTOTIMEOUT; - break; - } else - return(0); - } + if (++sc->mii_ticks != 50) + return (0); sc->mii_ticks = 0; - /*dcphy_reset(sc);*/ + /*if (DC_IS_INTEL(dc_sc))*/ + sc->mii_flags &= ~MIIF_DOINGAUTO; dcphy_auto(sc, 0); break; @@ -349,7 +313,7 @@ dcphy_status(sc) struct mii_softc *sc; { struct mii_data *mii = sc->mii_pdata; - int reg, anlpar; + int reg, anlpar, tstat = 0; struct dc_softc *dc_sc; dc_sc = mii->mii_ifp->if_softc; @@ -357,33 +321,33 @@ dcphy_status(sc) mii->mii_media_status = IFM_AVALID; mii->mii_media_active = IFM_ETHER; + if ((mii->mii_ifp->if_flags & IFF_UP) == 0) + return; + reg = CSR_READ_4(dc_sc, DC_10BTSTAT) & - (DC_TSTAT_LS10|DC_TSTAT_LS100); + (DC_TSTAT_LS10|DC_TSTAT_LS100); if (!(reg & DC_TSTAT_LS10) || !(reg & DC_TSTAT_LS100)) mii->mii_media_status |= IFM_ACTIVE; - if (sc->mii_flags & MIIF_DOINGAUTO) { - mii->mii_media_active |= IFM_NONE; - return; - } - - if (CSR_READ_4(dc_sc, DC_10BTCTRL) & DC_TCTL_AUTONEGENBL && - CSR_READ_4(dc_sc, DC_10BTSTAT) & DC_TSTAT_ANEGSTAT) { + if (CSR_READ_4(dc_sc, DC_10BTCTRL) & DC_TCTL_AUTONEGENBL) { /* Erg, still trying, I guess... */ - if ((CSR_READ_4(dc_sc, DC_10BTSTAT) & - DC_ASTAT_AUTONEGCMP) != DC_ASTAT_AUTONEGCMP) { + tstat = CSR_READ_4(dc_sc, DC_10BTSTAT); + if ((tstat & DC_TSTAT_ANEGSTAT) != DC_ASTAT_AUTONEGCMP) { + if ((DC_IS_MACRONIX(dc_sc) || DC_IS_PNICII(dc_sc)) && + (tstat & DC_TSTAT_ANEGSTAT) == DC_ASTAT_DISABLE) + goto skip; mii->mii_media_active |= IFM_NONE; return; } - if (CSR_READ_4(dc_sc, DC_10BTSTAT) & DC_TSTAT_LP_CAN_NWAY) { - anlpar = CSR_READ_4(dc_sc, DC_10BTSTAT) >> 16; + if (tstat & DC_TSTAT_LP_CAN_NWAY) { + anlpar = tstat >> 16; if (anlpar & ANLPAR_T4 && sc->mii_capabilities & BMSR_100TXHDX) mii->mii_media_active |= IFM_100_T4; else if (anlpar & ANLPAR_TX_FD && - sc->mii_capabilities & BMSR_100TXHDX) + sc->mii_capabilities & BMSR_100TXFDX) mii->mii_media_active |= IFM_100_TX|IFM_FDX; else if (anlpar & ANLPAR_TX && sc->mii_capabilities & BMSR_100TXHDX) @@ -418,6 +382,7 @@ dcphy_status(sc) return; } +skip: if (CSR_READ_4(dc_sc, DC_NETCFG) & DC_NETCFG_SCRAMBLER) mii->mii_media_active |= IFM_100_TX; else |