diff options
Diffstat (limited to 'sys/dev/mii/mtdphy.c')
-rw-r--r-- | sys/dev/mii/mtdphy.c | 49 |
1 files changed, 13 insertions, 36 deletions
diff --git a/sys/dev/mii/mtdphy.c b/sys/dev/mii/mtdphy.c index 67086f5d24c..803b88c381a 100644 --- a/sys/dev/mii/mtdphy.c +++ b/sys/dev/mii/mtdphy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mtdphy.c,v 1.4 1999/12/07 22:01:31 jason Exp $ */ +/* $OpenBSD: mtdphy.c,v 1.5 2000/08/26 20:04:18 nate Exp $ */ /* * Copyright (c) 1998, 1999 Jason L. Wright (jason@thought.net) @@ -55,7 +55,8 @@ int mtdphymatch __P((struct device *, void *, void *)); void mtdphyattach __P((struct device *, struct device *, void *)); struct cfattach mtdphy_ca = { - sizeof(struct mii_softc), mtdphymatch, mtdphyattach + sizeof(struct mii_softc), mtdphymatch, mtdphyattach, mii_phy_detach, + mii_phy_activate }; struct cfdriver mtdphy_cd = { @@ -93,14 +94,16 @@ mtdphyattach(parent, self, aux) sc->mii_inst = mii->mii_instance; sc->mii_phy = ma->mii_phyno; sc->mii_service = mtdphy_service; + sc->mii_status = ukphy_status; sc->mii_pdata = mii; + sc->mii_flags = mii->mii_flags; mii_phy_reset(sc); sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; if (sc->mii_capabilities & BMSR_MEDIAMASK) - mii_add_media(sc); + mii_phy_add_media(sc); } int @@ -112,6 +115,9 @@ mtdphy_service(sc, mii, cmd) struct ifmedia_entry *ife = mii->mii_media.ifm_cur; int reg; + if ((sc->mii_dev.dv_flags & DVF_ACTIVE) == 0) + return (ENXIO); + switch (cmd) { case MII_POLLSTAT: /* @@ -134,19 +140,7 @@ mtdphy_service(sc, mii, cmd) if ((mii->mii_ifp->if_flags & IFF_UP) == 0) break; - switch (IFM_SUBTYPE(ife->ifm_media)) { - case IFM_AUTO: - /* - * If we're already in auto mode, just return. - */ - if (PHY_READ(sc, MII_BMCR) & BMCR_AUTOEN) - return (0); - (void) mii_phy_auto(sc, 1); - break; - - default: - mii_phy_setmedia(sc); - } + mii_phy_setmedia(sc); break; case MII_TICK: @@ -156,22 +150,8 @@ mtdphy_service(sc, mii, cmd) if (IFM_INST(ife->ifm_media) != sc->mii_inst) return (0); - /* - * Only used for autonegotiation. - */ - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) + if (mii_phy_tick(sc) == EJUSTRETURN) return (0); - - /* - * Is the interface even up? - */ - if ((mii->mii_ifp->if_flags & IFF_UP) == 0) - return (0); - - /* - * The MTD972 autonegotiation doesn't need to be - * kicked; it continues in the background. - */ break; case MII_DOWN: @@ -180,12 +160,9 @@ mtdphy_service(sc, mii, cmd) } /* Update the media status. */ - ukphy_status(sc); + mii_phy_status(sc); /* Callback if something changed. */ - if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) { - (*mii->mii_statchg)(sc->mii_dev.dv_parent); - sc->mii_active = mii->mii_media_active; - } + mii_phy_update(sc, cmd); return (0); } |