summaryrefslogtreecommitdiff
path: root/sys/dev/mii/lxtphy.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/lxtphy.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/lxtphy.c')
-rw-r--r--sys/dev/mii/lxtphy.c48
1 files changed, 12 insertions, 36 deletions
diff --git a/sys/dev/mii/lxtphy.c b/sys/dev/mii/lxtphy.c
index e2cb377d8e3..5c290b39fe8 100644
--- a/sys/dev/mii/lxtphy.c
+++ b/sys/dev/mii/lxtphy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lxtphy.c,v 1.3 1999/07/23 12:39:11 deraadt Exp $ */
+/* $OpenBSD: lxtphy.c,v 1.4 1999/12/07 22:01:31 jason Exp $ */
/* $NetBSD: lxtphy.c,v 1.9.6.1 1999/04/23 15:41:43 perry Exp $ */
/*-
@@ -89,22 +89,16 @@
#include <dev/mii/lxtphyreg.h>
-#ifdef __NetBSD__
-int lxtphymatch __P((struct device *, struct cfdata *, void *));
-#else
int lxtphymatch __P((struct device *, void *, void *));
-#endif
void lxtphyattach __P((struct device *, struct device *, void *));
struct cfattach lxtphy_ca = {
sizeof(struct mii_softc), lxtphymatch, lxtphyattach
};
-#ifdef __OpenBSD__
struct cfdriver lxtphy_cd = {
NULL, "lxtphy", DV_DULL
};
-#endif
int lxtphy_service __P((struct mii_softc *, struct mii_data *, int));
void lxtphy_status __P((struct mii_softc *));
@@ -112,17 +106,13 @@ void lxtphy_status __P((struct mii_softc *));
int
lxtphymatch(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_LEVEL1 &&
- MII_MODEL(ma->mii_id2) == MII_MODEL_LEVEL1_LXT970)
+ if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_xxLEVEL1 &&
+ MII_MODEL(ma->mii_id2) == MII_MODEL_xxLEVEL1_LXT970)
return (10);
return (0);
@@ -137,7 +127,7 @@ lxtphyattach(parent, self, aux)
struct mii_attach_args *ma = aux;
struct mii_data *mii = ma->mii_data;
- printf(": %s, rev. %d\n", MII_STR_LEVEL1_LXT970,
+ printf(": %s, rev. %d\n", MII_STR_xxLEVEL1_LXT970,
MII_REV(ma->mii_id2));
sc->mii_inst = mii->mii_instance;
@@ -145,21 +135,12 @@ lxtphyattach(parent, self, aux)
sc->mii_service = lxtphy_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);
-
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
@@ -206,18 +187,8 @@ lxtphy_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;
@@ -262,6 +233,10 @@ lxtphy_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. */
@@ -280,6 +255,7 @@ lxtphy_status(sc)
struct mii_softc *sc;
{
struct mii_data *mii = sc->mii_pdata;
+ struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
int bmcr, csr;
mii->mii_media_status = IFM_AVALID;
@@ -317,5 +293,5 @@ lxtphy_status(sc)
if (csr & CSR_DUPLEX)
mii->mii_media_active |= IFM_FDX;
} else
- mii->mii_media_active = mii_media_from_bmcr(bmcr);
+ mii->mii_media_active = ife->ifm_media;
}