diff options
author | jlemon <jlemon@FreeBSD.org> | 2001-09-29 19:18:52 +0000 |
---|---|---|
committer | jlemon <jlemon@FreeBSD.org> | 2001-09-29 19:18:52 +0000 |
commit | 6689cad44720247770c3439271c41126ceb5476e (patch) | |
tree | e747bfa7e8d363f3c895759cfbfa10fc7ec0841e /sys/dev/mii/e1000phy.c | |
parent | 8bad7ad549c81c7741eb484b254cbe6200cba4c3 (diff) | |
download | FreeBSD-src-6689cad44720247770c3439271c41126ceb5476e.zip FreeBSD-src-6689cad44720247770c3439271c41126ceb5476e.tar.gz |
Cleanup pass for mii drivers.
. Make internal service routines static.
. Use a consistent ordering of checks in MII_TICK. Do the work in the
mii_phy_tick() subroutine if appropriate.
. Call mii_phy_update() to trigger the callbacks.
Diffstat (limited to 'sys/dev/mii/e1000phy.c')
-rw-r--r-- | sys/dev/mii/e1000phy.c | 58 |
1 files changed, 23 insertions, 35 deletions
diff --git a/sys/dev/mii/e1000phy.c b/sys/dev/mii/e1000phy.c index 2be3b882..1f99cce 100644 --- a/sys/dev/mii/e1000phy.c +++ b/sys/dev/mii/e1000phy.c @@ -73,12 +73,12 @@ static driver_t e1000phy_driver = { }; DRIVER_MODULE(e1000phy, miibus, e1000phy_driver, e1000phy_devclass, 0, 0); -int e1000phy_service(struct mii_softc *, struct mii_data *, int); -void e1000phy_status(struct mii_softc *); - +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 void e1000phy_reset(struct mii_softc *); static int e1000phy_debug = 0; @@ -216,7 +216,7 @@ e1000phy_reset(struct mii_softc *sc) PHY_WRITE(sc, 30, 0x00); } -int +static int e1000phy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) { struct ifmedia_entry *ife = mii->mii_media.ifm_cur; @@ -313,43 +313,35 @@ e1000phy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) } /* - * Only used for autonegotiation. + * Is the interface even up? */ - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) { + if ((mii->mii_ifp->if_flags & IFF_UP) == 0) return (0); - } /* - * Is the interface even up? + * Only used for autonegotiation. */ - if ((mii->mii_ifp->if_flags & IFF_UP) == 0) { - return (0); - } + if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) + break; /* - * Only retry autonegotiation every 5 seconds. + * check for link. + * Read the status register twice; BMSR_LINK is latch-low. */ - if (++(sc->mii_ticks) != 5) { - return (0); - } - sc->mii_ticks = 0; + reg = PHY_READ(sc, MII_BMSR) | PHY_READ(sc, MII_BMSR); + if (reg & BMSR_LINK) + break; /* - * 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 = PHY_READ(sc, E1000_SR) | PHY_READ(sc, E1000_SR); - - if (reg & E1000_SR_LINK_STATUS) - break; + if (++sc->mii_ticks != 5) + return (0); + sc->mii_ticks = 0; e1000phy_reset(sc); - - if (e1000phy_mii_phy_auto(sc, 0) == EJUSTRETURN) { - return(0); - } - + if (e1000phy_mii_phy_auto(sc, 0) == EJUSTRETURN) + return (0); break; } @@ -357,15 +349,11 @@ e1000phy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) e1000phy_status(sc); /* Callback if something changed. */ - if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) { - MIIBUS_STATCHG(sc->mii_dev); - sc->mii_active = mii->mii_media_active; - } - + mii_phy_update(sc, cmd); return (0); } -void +static void e1000phy_status(struct mii_softc *sc) { struct mii_data *mii = sc->mii_pdata; |