summaryrefslogtreecommitdiff
path: root/sys/dev/mii/icsphy.c
diff options
context:
space:
mode:
authorJason Wright <jason@cvs.openbsd.org>1999-12-07 22:01:34 +0000
committerJason Wright <jason@cvs.openbsd.org>1999-12-07 22:01:34 +0000
commit90108b38f19fc6ca669c2296a3d74500d8818a39 (patch)
tree675bda7203b288a18e60016c22f6e3e78ac90114 /sys/dev/mii/icsphy.c
parent703694a5279961334bfedfce9c01810442e3cd2f (diff)
Merge with NetBSD:
o move common support functions for phy drivers from mii.c to mii_physubr.c, so that they are not includes if no PHY is configured o Clean up the code that adds media a little, and make media selection table-driven in preparation for some other changes to be made. o Don't add any loopback versions of media, for now. o Add mii_down(), which is used by MAC drivers to inform PHYs that the interface is now down. PHYs use this to cancel pending asynchronous operations. o Add OUI for Enable Semiconductor. o New Driver for TDK TSC78Q2120 PHY
Diffstat (limited to 'sys/dev/mii/icsphy.c')
-rw-r--r--sys/dev/mii/icsphy.c48
1 files changed, 12 insertions, 36 deletions
diff --git a/sys/dev/mii/icsphy.c b/sys/dev/mii/icsphy.c
index f5feaafcff1..f349c0af6c7 100644
--- a/sys/dev/mii/icsphy.c
+++ b/sys/dev/mii/icsphy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: icsphy.c,v 1.4 1999/09/07 10:05:15 niklas Exp $ */
+/* $OpenBSD: icsphy.c,v 1.5 1999/12/07 22:01:30 jason Exp $ */
/* $NetBSD: icsphy.c,v 1.8.6.1 1999/04/23 15:40:56 perry Exp $ */
/*-
@@ -88,11 +88,7 @@
#include <dev/mii/icsphyreg.h>
-#ifdef __NetBSD__
-int icsphymatch __P((struct device *, struct cfdata *, void *));
-#else
int icsphymatch __P((struct device *, void *, void *));
-#endif
void icsphyattach __P((struct device *, struct device *, void *));
int icsphydetach __P((struct device *, int));
@@ -100,11 +96,9 @@ struct cfattach icsphy_ca = {
sizeof(struct mii_softc), icsphymatch, icsphyattach, icsphydetach
};
-#ifdef __OpenBSD__
struct cfdriver icsphy_cd = {
NULL, "icsphy", DV_DULL
};
-#endif
int icsphy_service __P((struct mii_softc *, struct mii_data *, int));
void icsphy_reset __P((struct mii_softc *));
@@ -113,17 +107,13 @@ void icsphy_status __P((struct mii_softc *));
int
icsphymatch(parent, match, aux)
struct device *parent;
-#ifdef __NetBSD__
- struct cfdata *match;
-#else
void *match;
-#endif
void *aux;
{
struct mii_attach_args *ma = aux;
- if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_ICS &&
- MII_MODEL(ma->mii_id2) == MII_MODEL_ICS_1890)
+ if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_xxICS &&
+ MII_MODEL(ma->mii_id2) == MII_MODEL_xxICS_1890)
return (10);
return (0);
@@ -138,7 +128,7 @@ icsphyattach(parent, self, aux)
struct mii_attach_args *ma = aux;
struct mii_data *mii = ma->mii_data;
- printf(": %s, rev. %d\n", MII_STR_ICS_1890,
+ printf(": %s, rev. %d\n", MII_STR_xxICS_1890,
MII_REV(ma->mii_id2));
sc->mii_inst = mii->mii_instance;
@@ -146,21 +136,12 @@ icsphyattach(parent, self, aux)
sc->mii_service = icsphy_service;
sc->mii_pdata = mii;
-#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
-
- 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);
-
icsphy_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 +196,8 @@ icsphy_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;
@@ -254,6 +225,10 @@ icsphy_service(sc, mii, cmd)
* kicked; it continues in the background.
*/
break;
+
+ case MII_DOWN:
+ mii_phy_down(sc);
+ return (0);
}
/* Update the media status. */
@@ -272,6 +247,7 @@ icsphy_status(sc)
struct mii_softc *sc;
{
struct mii_data *mii = sc->mii_pdata;
+ struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
int bmcr, qpr;
mii->mii_media_status = IFM_AVALID;
@@ -311,7 +287,7 @@ icsphy_status(sc)
if (qpr & QPR_FDX)
mii->mii_media_active |= IFM_FDX;
} else
- mii->mii_media_active = mii_media_from_bmcr(bmcr);
+ mii->mii_media_active = ife->ifm_media;
}
void