summaryrefslogtreecommitdiff
path: root/sys/dev/mii/inphy.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/mii/inphy.c')
-rw-r--r--sys/dev/mii/inphy.c44
1 files changed, 9 insertions, 35 deletions
diff --git a/sys/dev/mii/inphy.c b/sys/dev/mii/inphy.c
index 0f07f41fe44..938e283f04b 100644
--- a/sys/dev/mii/inphy.c
+++ b/sys/dev/mii/inphy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: inphy.c,v 1.4 1999/07/23 12:39:11 deraadt Exp $ */
+/* $OpenBSD: inphy.c,v 1.5 1999/12/07 22:01:30 jason Exp $ */
/* $NetBSD: inphy.c,v 1.10.6.1 1999/04/23 15:39:09 perry Exp $ */
/*-
@@ -89,22 +89,16 @@
#include <dev/mii/inphyreg.h>
-#ifdef __NetBSD__
-int inphymatch __P((struct device *, struct cfdata *, void *));
-#else
int inphymatch __P((struct device *, void *, void *));
-#endif
void inphyattach __P((struct device *, struct device *, void *));
struct cfattach inphy_ca = {
sizeof(struct mii_softc), inphymatch, inphyattach
};
-#ifdef __OpenBSD__
struct cfdriver inphy_cd = {
NULL, "inphy", DV_DULL
};
-#endif
int inphy_service __P((struct mii_softc *, struct mii_data *, int));
void inphy_status __P((struct mii_softc *));
@@ -112,11 +106,7 @@ void inphy_status __P((struct mii_softc *));
int
inphymatch(parent, match, aux)
struct device *parent;
-#ifdef __NetBSD__
- struct cfdata *match;
-#else
void *match;
-#endif
void *aux;
{
struct mii_attach_args *ma = aux;
@@ -152,23 +142,12 @@ inphyattach(parent, self, aux)
mii->mii_instance == 0)
sc->mii_flags |= MIIF_NOISOLATE;
-#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
-
- if ((sc->mii_flags & MIIF_NOISOLATE) == 0)
- ADD(IFM_MAKEWORD(IFM_ETHER, IFM_NONE, 0, sc->mii_inst),
- BMCR_ISO);
-
- ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->mii_inst),
- BMCR_LOOP|BMCR_S100);
-
mii_phy_reset(sc);
sc->mii_capabilities =
PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
if (sc->mii_capabilities & BMSR_MEDIAMASK)
- mii_add_media(mii, sc->mii_capabilities,
- sc->mii_inst);
-#undef ADD
+ mii_add_media(sc);
}
int
@@ -215,18 +194,8 @@ inphy_service(sc, mii, cmd)
return (0);
(void) mii_phy_auto(sc, 1);
break;
- case IFM_100_T4:
- /*
- * XXX Not supported as a manual setting right now.
- */
- return (EINVAL);
default:
- /*
- * BMCR data is stored in the ifmedia entry.
- */
- PHY_WRITE(sc, MII_ANAR,
- mii_anar(ife->ifm_media));
- PHY_WRITE(sc, MII_BMCR, ife->ifm_data);
+ mii_phy_setmedia(sc);
}
break;
@@ -270,6 +239,10 @@ inphy_service(sc, mii, cmd)
if (mii_phy_auto(sc, 0) == EJUSTRETURN)
return (0);
break;
+
+ case MII_DOWN:
+ mii_phy_down(sc);
+ return (0);
}
/* Update the media status. */
@@ -288,6 +261,7 @@ inphy_status(sc)
struct mii_softc *sc;
{
struct mii_data *mii = sc->mii_pdata;
+ struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
int bmsr, bmcr, scr;
mii->mii_media_status = IFM_AVALID;
@@ -324,5 +298,5 @@ inphy_status(sc)
if (scr & SCR_FDX)
mii->mii_media_active |= IFM_FDX;
} else
- mii->mii_media_active = mii_media_from_bmcr(bmcr);
+ mii->mii_media_active = ife->ifm_media;
}