summaryrefslogtreecommitdiff
path: root/sys/dev/mii/rlphy.c
diff options
context:
space:
mode:
authorNathan Binkert <nate@cvs.openbsd.org>2000-08-26 20:04:19 +0000
committerNathan Binkert <nate@cvs.openbsd.org>2000-08-26 20:04:19 +0000
commit841e005741a8dcb32a106f13731c7dd1e832d2b7 (patch)
tree61d0acb17595089ed91f7518d6314428615d1b9e /sys/dev/mii/rlphy.c
parentbd43edc61a95550b14f127a9a6b2902a6208f11b (diff)
sync mii code with netbsd
adds detach functionality for phys some code cleanup Nobody really had time to test all of this out, but theo said commit anyway
Diffstat (limited to 'sys/dev/mii/rlphy.c')
-rw-r--r--sys/dev/mii/rlphy.c48
1 files changed, 13 insertions, 35 deletions
diff --git a/sys/dev/mii/rlphy.c b/sys/dev/mii/rlphy.c
index 5fdd8ee8ffa..d4948d867a6 100644
--- a/sys/dev/mii/rlphy.c
+++ b/sys/dev/mii/rlphy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rlphy.c,v 1.5 1999/12/07 22:01:32 jason Exp $ */
+/* $OpenBSD: rlphy.c,v 1.6 2000/08/26 20:04:18 nate Exp $ */
/*
* Copyright (c) 1998, 1999 Jason L. Wright (jason@thought.net)
@@ -56,7 +56,8 @@ int rlphymatch __P((struct device *, void *, void *));
void rlphyattach __P((struct device *, struct device *, void *));
struct cfattach rlphy_ca = {
- sizeof(struct mii_softc), rlphymatch, rlphyattach
+ sizeof(struct mii_softc), rlphymatch, rlphyattach, mii_phy_detach,
+ mii_phy_activate
};
struct cfdriver rlphy_cd = {
@@ -102,14 +103,16 @@ rlphyattach(parent, self, aux)
sc->mii_inst = mii->mii_instance;
sc->mii_phy = ma->mii_phyno;
sc->mii_service = rlphy_service;
+ sc->mii_status = ukphy_status;
sc->mii_pdata = mii;
+ sc->mii_flags = mii->mii_flags;
rlphy_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
@@ -120,6 +123,9 @@ rlphy_service(sc, mii, cmd)
{
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
+ if ((sc->mii_dev.dv_flags & DVF_ACTIVE) == 0)
+ return (ENXIO);
+
/*
* Can't isolate the RTL8139 phy, so it has to be the only one.
*/
@@ -137,37 +143,12 @@ rlphy_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:
- /*
- * 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 RTL8139 autonegotiation doesn't need to be
- * kicked; it continues in the background.
- */
break;
case MII_DOWN:
@@ -176,13 +157,10 @@ rlphy_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);
}