From 2bdcfd0c1cef53f79a0f3a9c89de2b9353a04cd1 Mon Sep 17 00:00:00 2001 From: phk Date: Sat, 4 May 2002 11:00:30 +0000 Subject: Clean up mii/phy drivers: Remove the MIIF_DOINGAUTO which doesn't really do anything at the end of the day except bloat the drivers which has copy&pasted it. --- sys/dev/mii/acphy.c | 2 +- sys/dev/mii/amphy.c | 2 +- sys/dev/mii/brgphy.c | 79 ++++++++------------------- sys/dev/mii/dcphy.c | 59 +++++--------------- sys/dev/mii/e1000phy.c | 71 +++++-------------------- sys/dev/mii/lxtphy.c | 2 +- sys/dev/mii/mii_physubr.c | 133 +++++++++++++--------------------------------- sys/dev/mii/miivar.h | 4 +- sys/dev/mii/mlphy.c | 9 ++-- sys/dev/mii/nsgphy.c | 1 - sys/dev/mii/nsphy.c | 2 +- sys/dev/mii/qsphy.c | 2 +- sys/dev/mii/rlphy.c | 2 +- sys/dev/mii/tdkphy.c | 2 +- sys/dev/mii/tlphy.c | 16 +++--- sys/dev/mii/xmphy.c | 60 +++++---------------- 16 files changed, 115 insertions(+), 331 deletions(-) (limited to 'sys/dev/mii') diff --git a/sys/dev/mii/acphy.c b/sys/dev/mii/acphy.c index f505761..5d6ba64 100644 --- a/sys/dev/mii/acphy.c +++ b/sys/dev/mii/acphy.c @@ -213,7 +213,7 @@ acphy_service(sc, mii, cmd) if (PHY_READ(sc, MII_BMCR) & BMCR_AUTOEN) return (0); - (void) mii_phy_auto(sc, 1); + (void) mii_phy_auto(sc); break; default: diff --git a/sys/dev/mii/amphy.c b/sys/dev/mii/amphy.c index 16a2455..70462f4 100644 --- a/sys/dev/mii/amphy.c +++ b/sys/dev/mii/amphy.c @@ -190,7 +190,7 @@ amphy_service(sc, mii, cmd) */ if (PHY_READ(sc, MII_BMCR) & BMCR_AUTOEN) return (0); - (void) mii_phy_auto(sc, 1); + (void) mii_phy_auto(sc); break; case IFM_100_T4: /* diff --git a/sys/dev/mii/brgphy.c b/sys/dev/mii/brgphy.c index 08f1ff9..fb8a9b8 100644 --- a/sys/dev/mii/brgphy.c +++ b/sys/dev/mii/brgphy.c @@ -86,8 +86,7 @@ DRIVER_MODULE(brgphy, miibus, brgphy_driver, brgphy_devclass, 0, 0); static int brgphy_service(struct mii_softc *, struct mii_data *, int); static void brgphy_status(struct mii_softc *); -static int brgphy_mii_phy_auto(struct mii_softc *, int); -extern void mii_phy_auto_timeout(void *); +static int brgphy_mii_phy_auto(struct mii_softc *); static int brgphy_probe(dev) device_t dev; @@ -228,7 +227,7 @@ brgphy_service(sc, mii, cmd) if (PHY_READ(sc, BRGPHY_MII_BMCR) & BRGPHY_BMCR_AUTOEN) return (0); #endif - (void) brgphy_mii_phy_auto(sc, 1); + (void) brgphy_mii_phy_auto(sc); break; case IFM_1000_T: speed = BRGPHY_S1000; @@ -313,9 +312,8 @@ setit: sc->mii_ticks = 0; mii_phy_reset(sc); - if (brgphy_mii_phy_auto(sc, 0) == EJUSTRETURN) - return (0); - break; + brgphy_mii_phy_auto(sc); + return (0); } /* Update the media status. */ @@ -390,59 +388,24 @@ brgphy_status(sc) static int -brgphy_mii_phy_auto(mii, waitfor) +brgphy_mii_phy_auto(mii) struct mii_softc *mii; - int waitfor; { - int bmsr, ktcr = 0, i; - - if ((mii->mii_flags & MIIF_DOINGAUTO) == 0) { - mii_phy_reset(mii); - PHY_WRITE(mii, BRGPHY_MII_BMCR, 0); - DELAY(1000); - ktcr = PHY_READ(mii, BRGPHY_MII_1000CTL); - PHY_WRITE(mii, BRGPHY_MII_1000CTL, ktcr | - BRGPHY_1000CTL_AFD|BRGPHY_1000CTL_AHD); - ktcr = PHY_READ(mii, BRGPHY_MII_1000CTL); - DELAY(1000); - PHY_WRITE(mii, BRGPHY_MII_ANAR, - BMSR_MEDIA_TO_ANAR(mii->mii_capabilities) | ANAR_CSMA); - DELAY(1000); - PHY_WRITE(mii, BRGPHY_MII_BMCR, - BRGPHY_BMCR_AUTOEN | BRGPHY_BMCR_STARTNEG); - PHY_WRITE(mii, BRGPHY_MII_IMR, 0xFF00); - } - - if (waitfor) { - /* Wait 500ms for it to complete. */ - for (i = 0; i < 500; i++) { - if ((bmsr = PHY_READ(mii, BRGPHY_MII_BMSR)) & - BRGPHY_BMSR_ACOMP) - return (0); - DELAY(1000); -#if 0 - if ((bmsr & BMSR_ACOMP) == 0) - printf("%s: autonegotiation failed to complete\n", - mii->mii_dev.dv_xname); -#endif - } - - /* - * Don't need to worry about clearing MIIF_DOINGAUTO. - * If that's set, a timeout is pending, and it will - * clear the flag. - */ - return (EIO); - } - - /* - * Just let it finish asynchronously. This is for the benefit of - * the tick handler driving autonegotiation. Don't want 500ms - * delays all the time while the system is running! - */ - if ((mii->mii_flags & MIIF_DOINGAUTO) == 0) { - mii->mii_flags |= MIIF_DOINGAUTO; - mii->mii_auto_ch = timeout(mii_phy_auto_timeout, mii, hz >> 1); - } + int ktcr = 0; + + mii_phy_reset(mii); + PHY_WRITE(mii, BRGPHY_MII_BMCR, 0); + DELAY(1000); + ktcr = PHY_READ(mii, BRGPHY_MII_1000CTL); + PHY_WRITE(mii, BRGPHY_MII_1000CTL, ktcr | + BRGPHY_1000CTL_AFD|BRGPHY_1000CTL_AHD); + ktcr = PHY_READ(mii, BRGPHY_MII_1000CTL); + DELAY(1000); + PHY_WRITE(mii, BRGPHY_MII_ANAR, + BMSR_MEDIA_TO_ANAR(mii->mii_capabilities) | ANAR_CSMA); + DELAY(1000); + PHY_WRITE(mii, BRGPHY_MII_BMCR, + BRGPHY_BMCR_AUTOEN | BRGPHY_BMCR_STARTNEG); + PHY_WRITE(mii, BRGPHY_MII_IMR, 0xFF00); return (EJUSTRETURN); } diff --git a/sys/dev/mii/dcphy.c b/sys/dev/mii/dcphy.c index 3426b11..bf040e8 100644 --- a/sys/dev/mii/dcphy.c +++ b/sys/dev/mii/dcphy.c @@ -118,7 +118,7 @@ DRIVER_MODULE(dcphy, miibus, dcphy_driver, dcphy_devclass, 0, 0); static int dcphy_service(struct mii_softc *, struct mii_data *, int); static void dcphy_status(struct mii_softc *); static void dcphy_reset(struct mii_softc *); -static int dcphy_auto(struct mii_softc *, int); +static int dcphy_auto(struct mii_softc *); static int dcphy_probe(dev) device_t dev; @@ -250,8 +250,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); + (void) dcphy_auto(sc); break; case IFM_100_T4: /* @@ -329,9 +328,7 @@ dcphy_service(sc, mii, cmd) break; sc->mii_ticks = 0; - /*if (DC_IS_INTEL(dc_sc))*/ - sc->mii_flags &= ~MIIF_DOINGAUTO; - dcphy_auto(sc, 0); + dcphy_auto(sc); break; } @@ -429,51 +426,23 @@ skip: } static int -dcphy_auto(mii, waitfor) +dcphy_auto(mii) struct mii_softc *mii; - int waitfor; { - int i; struct dc_softc *sc; sc = mii->mii_pdata->mii_ifp->if_softc; - if ((mii->mii_flags & MIIF_DOINGAUTO) == 0) { - DC_CLRBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL); - DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_FULLDUPLEX); - DC_CLRBIT(sc, DC_SIARESET, DC_SIA_RESET); - if (mii->mii_capabilities & BMSR_100TXHDX) - CSR_WRITE_4(sc, DC_10BTCTRL, 0x3FFFF); - else - CSR_WRITE_4(sc, DC_10BTCTRL, 0xFFFF); - DC_SETBIT(sc, DC_SIARESET, DC_SIA_RESET); - DC_SETBIT(sc, DC_10BTCTRL, DC_TCTL_AUTONEGENBL); - DC_SETBIT(sc, DC_10BTSTAT, DC_ASTAT_TXDISABLE); - } - - if (waitfor) { - /* Wait 500ms for it to complete. */ - for (i = 0; i < 500; i++) { - if ((CSR_READ_4(sc, DC_10BTSTAT) & DC_TSTAT_ANEGSTAT) - == DC_ASTAT_AUTONEGCMP) - return(0); - DELAY(1000); - } - /* - * Don't need to worry about clearing MIIF_DOINGAUTO. - * If that's set, a timeout is pending, and it will - * clear the flag. - */ - return(EIO); - } - - /* - * Just let it finish asynchronously. This is for the benefit of - * the tick handler driving autonegotiation. Don't want 500ms - * delays all the time while the system is running! - */ - if ((mii->mii_flags & MIIF_DOINGAUTO) == 0) - mii->mii_flags |= MIIF_DOINGAUTO; + DC_CLRBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL); + DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_FULLDUPLEX); + DC_CLRBIT(sc, DC_SIARESET, DC_SIA_RESET); + if (mii->mii_capabilities & BMSR_100TXHDX) + CSR_WRITE_4(sc, DC_10BTCTRL, 0x3FFFF); + else + CSR_WRITE_4(sc, DC_10BTCTRL, 0xFFFF); + DC_SETBIT(sc, DC_SIARESET, DC_SIA_RESET); + DC_SETBIT(sc, DC_10BTCTRL, DC_TCTL_AUTONEGENBL); + DC_SETBIT(sc, DC_10BTSTAT, DC_ASTAT_TXDISABLE); return(EJUSTRETURN); } diff --git a/sys/dev/mii/e1000phy.c b/sys/dev/mii/e1000phy.c index 86e5bfd..a202a87 100644 --- a/sys/dev/mii/e1000phy.c +++ b/sys/dev/mii/e1000phy.c @@ -75,9 +75,7 @@ DRIVER_MODULE(e1000phy, miibus, e1000phy_driver, e1000phy_devclass, 0, 0); static int e1000phy_service(struct mii_softc *, struct mii_data *, int); static void e1000phy_status(struct mii_softc *); static void e1000phy_reset(struct mii_softc *); -static int e1000phy_mii_phy_auto(struct mii_softc *, int); - -extern void mii_phy_auto_timeout(void *); +static int e1000phy_mii_phy_auto(struct mii_softc *); static int e1000phy_debug = 0; @@ -232,24 +230,15 @@ e1000phy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) switch (IFM_SUBTYPE(ife->ifm_media)) { case IFM_AUTO: - /* - * If we're already in auto mode, just return. - */ - if (sc->mii_flags & MIIF_DOINGAUTO) { - return (0); - } e1000phy_reset(sc); - (void)e1000phy_mii_phy_auto(sc, 1); + (void)e1000phy_mii_phy_auto(sc); break; case IFM_1000_T: - if (sc->mii_flags & MIIF_DOINGAUTO) - return (0); - e1000phy_reset(sc); /* TODO - any other way to force 1000BT? */ - (void)e1000phy_mii_phy_auto(sc, 1); + (void)e1000phy_mii_phy_auto(sc); break; case IFM_100_TX: @@ -321,9 +310,8 @@ e1000phy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) sc->mii_ticks = 0; e1000phy_reset(sc); - if (e1000phy_mii_phy_auto(sc, 0) == EJUSTRETURN) - return (0); - break; + e1000phy_mii_phy_auto(sc); + return (0); } /* Update the media status. */ @@ -357,8 +345,7 @@ e1000phy_status(struct mii_softc *sc) if (bmcr & E1000_CR_LOOPBACK) mii->mii_media_active |= IFM_LOOP; - if ((sc->mii_flags & MIIF_DOINGAUTO) && - (!(bmsr & E1000_SR_AUTO_NEG_COMPLETE) || !(ssr & E1000_SSR_LINK) || + if ((!(bmsr & E1000_SR_AUTO_NEG_COMPLETE) || !(ssr & E1000_SSR_LINK) || !(ssr & E1000_SSR_SPD_DPLX_RESOLVED))) { /* Erg, still trying, I guess... */ mii->mii_media_active |= IFM_NONE; @@ -390,47 +377,15 @@ e1000phy_status(struct mii_softc *sc) } static int -e1000phy_mii_phy_auto(struct mii_softc *mii, int waitfor) +e1000phy_mii_phy_auto(struct mii_softc *mii) { - int bmsr, i; - - if ((mii->mii_flags & MIIF_DOINGAUTO) == 0) { - PHY_WRITE(mii, E1000_AR, E1000_AR_10T | E1000_AR_10T_FD | - E1000_AR_100TX | E1000_AR_100TX_FD | - E1000_AR_PAUSE | E1000_AR_ASM_DIR); - PHY_WRITE(mii, E1000_1GCR, E1000_1GCR_1000T_FD); - PHY_WRITE(mii, E1000_CR, - E1000_CR_AUTO_NEG_ENABLE | E1000_CR_RESTART_AUTO_NEG); - } - - if (waitfor) { - /* Wait 500ms for it to complete. */ - for (i = 0; i < 500; i++) { - bmsr = - PHY_READ(mii, E1000_SR) | PHY_READ(mii, E1000_SR); - - if (bmsr & E1000_SR_AUTO_NEG_COMPLETE) { - return (0); - } - DELAY(1000); - } - /* - * Don't need to worry about clearing MIIF_DOINGAUTO. - * If that's set, a timeout is pending, and it will - * clear the flag. [do it anyway] - */ - } + PHY_WRITE(mii, E1000_AR, E1000_AR_10T | E1000_AR_10T_FD | + E1000_AR_100TX | E1000_AR_100TX_FD | + E1000_AR_PAUSE | E1000_AR_ASM_DIR); + PHY_WRITE(mii, E1000_1GCR, E1000_1GCR_1000T_FD); + PHY_WRITE(mii, E1000_CR, + E1000_CR_AUTO_NEG_ENABLE | E1000_CR_RESTART_AUTO_NEG); - /* - * Just let it finish asynchronously. This is for the benefit of - * the tick handler driving autonegotiation. Don't want 500ms - * delays all the time while the system is running! - */ - if ((mii->mii_flags & MIIF_DOINGAUTO) == 0) { - mii->mii_flags |= MIIF_DOINGAUTO; - mii->mii_ticks = 0; - mii->mii_auto_ch = timeout(mii_phy_auto_timeout, mii, hz >> 1); - } return (EJUSTRETURN); } diff --git a/sys/dev/mii/lxtphy.c b/sys/dev/mii/lxtphy.c index 15ec110..1969860 100644 --- a/sys/dev/mii/lxtphy.c +++ b/sys/dev/mii/lxtphy.c @@ -229,7 +229,7 @@ lxtphy_service(sc, mii, cmd) lxtphy_set_tp(sc); - (void) mii_phy_auto(sc, 1); + (void) mii_phy_auto(sc); break; case IFM_100_T4: /* diff --git a/sys/dev/mii/mii_physubr.c b/sys/dev/mii/mii_physubr.c index 07ea088..a1c0228 100644 --- a/sys/dev/mii/mii_physubr.c +++ b/sys/dev/mii/mii_physubr.c @@ -108,8 +108,6 @@ const struct mii_media mii_media_table[MII_NMEDIA] = { GTCR_ADV_1000TFDX }, }; -void mii_phy_auto_timeout(void *); - void mii_phy_setmedia(struct mii_softc *sc) { @@ -119,7 +117,7 @@ mii_phy_setmedia(struct mii_softc *sc) if (IFM_SUBTYPE(ife->ifm_media) == IFM_AUTO) { if ((PHY_READ(sc, MII_BMCR) & BMCR_AUTOEN) == 0) - (void) mii_phy_auto(sc, 1); + (void) mii_phy_auto(sc); return; } @@ -156,97 +154,48 @@ mii_phy_setmedia(struct mii_softc *sc) } int -mii_phy_auto(struct mii_softc *sc, int waitfor) +mii_phy_auto(struct mii_softc *sc) { - int bmsr, i; - - if ((sc->mii_flags & MIIF_DOINGAUTO) == 0) { - /* - * Check for 1000BASE-X. Autonegotiation is a bit - * different on such devices. - */ - if (sc->mii_flags & MIIF_IS_1000X) { - uint16_t anar = 0; - - if (sc->mii_extcapabilities & EXTSR_1000XFDX) - anar |= ANAR_X_FD; - if (sc->mii_extcapabilities & EXTSR_1000XHDX) - anar |= ANAR_X_HD; - - if (sc->mii_flags & MIIF_DOPAUSE) { - /* XXX Asymmetric vs. symmetric? */ - anar |= ANLPAR_X_PAUSE_TOWARDS; - } - - PHY_WRITE(sc, MII_ANAR, anar); - } else { - uint16_t anar; - - anar = BMSR_MEDIA_TO_ANAR(sc->mii_capabilities) | - ANAR_CSMA; - if (sc->mii_flags & MIIF_DOPAUSE) - anar |= ANAR_FC; - PHY_WRITE(sc, MII_ANAR, anar); - if (sc->mii_flags & MIIF_HAVE_GTCR) { - uint16_t gtcr = 0; - - if (sc->mii_extcapabilities & EXTSR_1000TFDX) - gtcr |= GTCR_ADV_1000TFDX; - if (sc->mii_extcapabilities & EXTSR_1000THDX) - gtcr |= GTCR_ADV_1000THDX; - - PHY_WRITE(sc, MII_100T2CR, gtcr); - } - } - PHY_WRITE(sc, MII_BMCR, BMCR_AUTOEN | BMCR_STARTNEG); - } - - if (waitfor) { - /* Wait 500ms for it to complete. */ - for (i = 0; i < 500; i++) { - if ((bmsr = PHY_READ(sc, MII_BMSR)) & BMSR_ACOMP) - return (0); - DELAY(1000); - } - - /* - * Don't need to worry about clearing MIIF_DOINGAUTO. - * If that's set, a timeout is pending, and it will - * clear the flag. - */ - return (EIO); - } /* - * Just let it finish asynchronously. This is for the benefit of - * the tick handler driving autonegotiation. Don't want 500ms - * delays all the time while the system is running! + * Check for 1000BASE-X. Autonegotiation is a bit + * different on such devices. */ - if ((sc->mii_flags & MIIF_DOINGAUTO) == 0) { - sc->mii_flags |= MIIF_DOINGAUTO; - sc->mii_auto_ch = timeout(mii_phy_auto_timeout, sc, hz >> 1); - } - return (EJUSTRETURN); -} + if (sc->mii_flags & MIIF_IS_1000X) { + uint16_t anar = 0; -void -mii_phy_auto_timeout(void *arg) -{ - struct mii_softc *sc = arg; - int s, bmsr; + if (sc->mii_extcapabilities & EXTSR_1000XFDX) + anar |= ANAR_X_FD; + if (sc->mii_extcapabilities & EXTSR_1000XHDX) + anar |= ANAR_X_HD; -#if 0 - if ((sc->mii_dev.dv_flags & DVF_ACTIVE) == 0) - return; -#endif + if (sc->mii_flags & MIIF_DOPAUSE) { + /* XXX Asymmetric vs. symmetric? */ + anar |= ANLPAR_X_PAUSE_TOWARDS; + } + + PHY_WRITE(sc, MII_ANAR, anar); + } else { + uint16_t anar; - s = splnet(); - sc->mii_flags &= ~MIIF_DOINGAUTO; - bmsr = PHY_READ(sc, MII_BMSR); + anar = BMSR_MEDIA_TO_ANAR(sc->mii_capabilities) | + ANAR_CSMA; + if (sc->mii_flags & MIIF_DOPAUSE) + anar |= ANAR_FC; + PHY_WRITE(sc, MII_ANAR, anar); + if (sc->mii_flags & MIIF_HAVE_GTCR) { + uint16_t gtcr = 0; - /* Update the media status. */ - (void) (*sc->mii_service)(sc, sc->mii_pdata, MII_POLLSTAT); - splx(s); + if (sc->mii_extcapabilities & EXTSR_1000TFDX) + gtcr |= GTCR_ADV_1000TFDX; + if (sc->mii_extcapabilities & EXTSR_1000THDX) + gtcr |= GTCR_ADV_1000THDX; + + PHY_WRITE(sc, MII_100T2CR, gtcr); + } + } + PHY_WRITE(sc, MII_BMCR, BMCR_AUTOEN | BMCR_STARTNEG); + return (EJUSTRETURN); } int @@ -288,13 +237,7 @@ mii_phy_tick(struct mii_softc *sc) sc->mii_ticks = 0; mii_phy_reset(sc); - if (mii_phy_auto(sc, 0) == EJUSTRETURN) - return (EJUSTRETURN); - - /* - * Might need to generate a status message if autonegotiation - * failed. - */ + mii_phy_auto(sc); return (0); } @@ -325,10 +268,6 @@ void mii_phy_down(struct mii_softc *sc) { - if (sc->mii_flags & MIIF_DOINGAUTO) { - sc->mii_flags &= ~MIIF_DOINGAUTO; - untimeout(mii_phy_auto_timeout, sc, sc->mii_auto_ch); - } } void diff --git a/sys/dev/mii/miivar.h b/sys/dev/mii/miivar.h index cb56fd5..f6c759c 100644 --- a/sys/dev/mii/miivar.h +++ b/sys/dev/mii/miivar.h @@ -117,7 +117,6 @@ struct mii_softc { mii_downcall_t mii_service; /* our downcall */ struct mii_data *mii_pdata; /* pointer to parent's mii_data */ - struct callout_handle mii_auto_ch; /* callout handle for phy autoneg */ int mii_flags; /* misc. flags; see below */ int mii_capabilities; /* capabilities from BMSR */ @@ -133,7 +132,6 @@ typedef struct mii_softc mii_softc_t; #define MIIF_INITDONE 0x0001 /* has been initialized (mii_data) */ #define MIIF_NOISOLATE 0x0002 /* do not isolate the PHY */ #define MIIF_NOLOOP 0x0004 /* no loopback capability */ -#define MIIF_DOINGAUTO 0x0008 /* doing autonegotiation (mii_softc) */ #define MIIF_AUTOTSLEEP 0x0010 /* use tsleep(), not callout() */ #define MIIF_HAVEFIBER 0x0020 /* from parent: has fiber interface */ #define MIIF_HAVE_GTCR 0x0040 /* has 100base-T2/1000base-T CR */ @@ -211,7 +209,7 @@ void mii_phy_add_media(struct mii_softc *); int mii_media_from_bmcr(int); -int mii_phy_auto(struct mii_softc *, int); +int mii_phy_auto(struct mii_softc *); int mii_phy_detach(device_t dev); void mii_phy_down(struct mii_softc *); void mii_phy_reset(struct mii_softc *); diff --git a/sys/dev/mii/mlphy.c b/sys/dev/mii/mlphy.c index 44ab59d..d600455 100644 --- a/sys/dev/mii/mlphy.c +++ b/sys/dev/mii/mlphy.c @@ -238,7 +238,7 @@ mlphy_service(xsc, mii, cmd) mii_phy_reset(other); PHY_WRITE(other, MII_BMCR, BMCR_ISO); } - (void) mii_phy_auto(sc, 1); + (void) mii_phy_auto(sc); msc->ml_linked = 0; return(0); break; @@ -346,9 +346,8 @@ mlphy_service(xsc, mii, cmd) mii_phy_reset(other); PHY_WRITE(other, MII_BMCR, BMCR_ISO); } - if (mii_phy_auto(sc, 0) == EJUSTRETURN) - return(0); - break; + mii_phy_auto(sc); + return(0); } /* Update the media status. */ @@ -425,7 +424,7 @@ static void mlphy_status(sc) mlphy_reset(&msc->ml_mii); PHY_WRITE(&msc->ml_mii, MII_BMCR, BMCR_ISO); mii_phy_reset(other); - mii_phy_auto(other, 1); + mii_phy_auto(other); } return; diff --git a/sys/dev/mii/nsgphy.c b/sys/dev/mii/nsgphy.c index f4fa53f..07c695c 100644 --- a/sys/dev/mii/nsgphy.c +++ b/sys/dev/mii/nsgphy.c @@ -103,7 +103,6 @@ DRIVER_MODULE(nsgphy, miibus, nsgphy_driver, nsgphy_devclass, 0, 0); static int nsgphy_service(struct mii_softc *, struct mii_data *,int); static void nsgphy_status(struct mii_softc *); -extern void mii_phy_auto_timeout(void *); const struct mii_phydesc gphyters[] = { { MII_OUI_NATSEMI, MII_MODEL_NATSEMI_DP83861, diff --git a/sys/dev/mii/nsphy.c b/sys/dev/mii/nsphy.c index 3667d44..e297619 100644 --- a/sys/dev/mii/nsphy.c +++ b/sys/dev/mii/nsphy.c @@ -267,7 +267,7 @@ nsphy_service(sc, mii, cmd) */ if (PHY_READ(sc, MII_BMCR) & BMCR_AUTOEN) return (0); - (void) mii_phy_auto(sc, 1); + (void) mii_phy_auto(sc); break; case IFM_100_T4: /* diff --git a/sys/dev/mii/qsphy.c b/sys/dev/mii/qsphy.c index fae4567..c40161f 100644 --- a/sys/dev/mii/qsphy.c +++ b/sys/dev/mii/qsphy.c @@ -212,7 +212,7 @@ qsphy_service(sc, mii, cmd) if (PHY_READ(sc, MII_BMCR) & BMCR_AUTOEN) return (0); - (void) mii_phy_auto(sc, 1); + (void) mii_phy_auto(sc); break; default: diff --git a/sys/dev/mii/rlphy.c b/sys/dev/mii/rlphy.c index f45046a..fcf5538 100644 --- a/sys/dev/mii/rlphy.c +++ b/sys/dev/mii/rlphy.c @@ -205,7 +205,7 @@ rlphy_service(sc, mii, cmd) */ if (PHY_READ(sc, MII_BMCR) & BMCR_AUTOEN) return (0); - (void) mii_phy_auto(sc, 0); + (void) mii_phy_auto(sc); break; case IFM_100_T4: /* diff --git a/sys/dev/mii/tdkphy.c b/sys/dev/mii/tdkphy.c index a5f08b3..833c499 100644 --- a/sys/dev/mii/tdkphy.c +++ b/sys/dev/mii/tdkphy.c @@ -195,7 +195,7 @@ tdkphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) */ if (PHY_READ(sc, MII_BMCR) & BMCR_AUTOEN) return (0); - (void) mii_phy_auto(sc, 1); + (void) mii_phy_auto(sc); break; case IFM_100_T4: /* diff --git a/sys/dev/mii/tlphy.c b/sys/dev/mii/tlphy.c index 70a79c7..cbd14d7 100644 --- a/sys/dev/mii/tlphy.c +++ b/sys/dev/mii/tlphy.c @@ -125,7 +125,7 @@ static driver_t tlphy_driver = { DRIVER_MODULE(tlphy, miibus, tlphy_driver, tlphy_devclass, 0, 0); static int tlphy_service(struct mii_softc *, struct mii_data *, int); -static int tlphy_auto(struct tlphy_softc *, int); +static int tlphy_auto(struct tlphy_softc *); static void tlphy_acomp(struct tlphy_softc *); static void tlphy_status(struct tlphy_softc *); @@ -235,7 +235,7 @@ tlphy_service(self, mii, cmd) struct ifmedia_entry *ife = mii->mii_media.ifm_cur; int reg; - if ((sc->sc_mii.mii_flags & MIIF_DOINGAUTO) == 0 && sc->sc_need_acomp) + if (sc->sc_need_acomp) tlphy_acomp(sc); switch (cmd) { @@ -271,7 +271,7 @@ tlphy_service(self, mii, cmd) * an autonegotiation cycle, so there's no such * thing as "already in auto mode". */ - (void) tlphy_auto(sc, 1); + (void) tlphy_auto(sc); break; case IFM_10_2: case IFM_10_5: @@ -327,9 +327,8 @@ tlphy_service(self, mii, cmd) sc->sc_mii.mii_ticks = 0; mii_phy_reset(&sc->sc_mii); - if (tlphy_auto(sc, 0) == EJUSTRETURN) - return (0); - break; + tlphy_auto(sc); + return (0); } /* Update the media status. */ @@ -384,13 +383,12 @@ tlphy_status(sc) } static int -tlphy_auto(sc, waitfor) +tlphy_auto(sc) struct tlphy_softc *sc; - int waitfor; { int error; - switch ((error = mii_phy_auto(&sc->sc_mii, waitfor))) { + switch ((error = mii_phy_auto(&sc->sc_mii))) { case EIO: /* * Just assume we're not in full-duplex mode. diff --git a/sys/dev/mii/xmphy.c b/sys/dev/mii/xmphy.c index 3a75701..a67933c 100644 --- a/sys/dev/mii/xmphy.c +++ b/sys/dev/mii/xmphy.c @@ -86,8 +86,7 @@ DRIVER_MODULE(xmphy, miibus, xmphy_driver, xmphy_devclass, 0, 0); static int xmphy_service(struct mii_softc *, struct mii_data *, int); static void xmphy_status(struct mii_softc *); -static int xmphy_mii_phy_auto(struct mii_softc *, int); -extern void mii_phy_auto_timeout(void *); +static int xmphy_mii_phy_auto(struct mii_softc *); static int xmphy_probe(dev) device_t dev; @@ -206,7 +205,7 @@ xmphy_service(sc, mii, cmd) if (PHY_READ(sc, XMPHY_MII_BMCR) & XMPHY_BMCR_AUTOEN) return (0); #endif - (void) xmphy_mii_phy_auto(sc, 1); + (void) xmphy_mii_phy_auto(sc); break; case IFM_1000_SX: mii_phy_reset(sc); @@ -263,9 +262,8 @@ xmphy_service(sc, mii, cmd) sc->mii_ticks = 0; mii_phy_reset(sc); - if (xmphy_mii_phy_auto(sc, 0) == EJUSTRETURN) - return(0); - break; + xmphy_mii_phy_auto(sc); + return(0); } /* Update the media status. */ @@ -332,51 +330,17 @@ xmphy_status(sc) static int -xmphy_mii_phy_auto(mii, waitfor) +xmphy_mii_phy_auto(mii) struct mii_softc *mii; - int waitfor; { - int bmsr, anar = 0, i; - - if ((mii->mii_flags & MIIF_DOINGAUTO) == 0) { - anar = PHY_READ(mii, XMPHY_MII_ANAR); - anar |= XMPHY_ANAR_FDX|XMPHY_ANAR_HDX; - PHY_WRITE(mii, XMPHY_MII_ANAR, anar); - DELAY(1000); - PHY_WRITE(mii, XMPHY_MII_BMCR, - XMPHY_BMCR_AUTOEN | XMPHY_BMCR_STARTNEG); - } - - if (waitfor) { - /* Wait 500ms for it to complete. */ - for (i = 0; i < 500; i++) { - if ((bmsr = PHY_READ(mii, XMPHY_MII_BMSR)) & - XMPHY_BMSR_ACOMP) - return (0); - DELAY(1000); -#if 0 - if ((bmsr & BMSR_ACOMP) == 0) - printf("%s: autonegotiation failed to complete\n", - mii->mii_dev.dv_xname); -#endif - } + int anar = 0; - /* - * Don't need to worry about clearing MIIF_DOINGAUTO. - * If that's set, a timeout is pending, and it will - * clear the flag. - */ - return (EIO); - } + anar = PHY_READ(mii, XMPHY_MII_ANAR); + anar |= XMPHY_ANAR_FDX|XMPHY_ANAR_HDX; + PHY_WRITE(mii, XMPHY_MII_ANAR, anar); + DELAY(1000); + PHY_WRITE(mii, XMPHY_MII_BMCR, + XMPHY_BMCR_AUTOEN | XMPHY_BMCR_STARTNEG); - /* - * Just let it finish asynchronously. This is for the benefit of - * the tick handler driving autonegotiation. Don't want 500ms - * delays all the time while the system is running! - */ - if ((mii->mii_flags & MIIF_DOINGAUTO) == 0) { - mii->mii_flags |= MIIF_DOINGAUTO; - mii->mii_auto_ch = timeout(mii_phy_auto_timeout, mii, hz >> 1); - } return (EJUSTRETURN); } -- cgit v1.1