Place the essentially common "ticks" and "active" members into the
mii_softc (generic phy goo), and just switch all of the PHY drivers (except tlphy, which really does have special stuff) to use an mii_softc instead of a private one.
This commit is contained in:
parent
f66039cbce
commit
2a17544c19
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: exphy.c,v 1.14 1998/11/04 23:59:51 thorpej Exp $ */
|
||||
/* $NetBSD: exphy.c,v 1.15 1998/11/05 00:19:32 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
@ -84,20 +84,15 @@
|
||||
#include <dev/mii/miivar.h>
|
||||
#include <dev/mii/miidevs.h>
|
||||
|
||||
struct exphy_softc {
|
||||
struct mii_softc sc_mii; /* generic PHY */
|
||||
int sc_active;
|
||||
};
|
||||
|
||||
int exphymatch __P((struct device *, struct cfdata *, void *));
|
||||
void exphyattach __P((struct device *, struct device *, void *));
|
||||
|
||||
struct cfattach exphy_ca = {
|
||||
sizeof(struct exphy_softc), exphymatch, exphyattach
|
||||
sizeof(struct mii_softc), exphymatch, exphyattach
|
||||
};
|
||||
|
||||
int exphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
void exphy_reset __P((struct exphy_softc *));
|
||||
void exphy_reset __P((struct mii_softc *));
|
||||
|
||||
int
|
||||
exphymatch(parent, match, aux)
|
||||
@ -128,16 +123,16 @@ exphyattach(parent, self, aux)
|
||||
struct device *parent, *self;
|
||||
void *aux;
|
||||
{
|
||||
struct exphy_softc *sc = (struct exphy_softc *)self;
|
||||
struct mii_softc *sc = (struct mii_softc *)self;
|
||||
struct mii_attach_args *ma = aux;
|
||||
struct mii_data *mii = ma->mii_data;
|
||||
|
||||
printf(": 3Com internal media interface\n");
|
||||
|
||||
sc->sc_mii.mii_inst = mii->mii_instance;
|
||||
sc->sc_mii.mii_phy = ma->mii_phyno;
|
||||
sc->sc_mii.mii_service = exphy_service;
|
||||
sc->sc_mii.mii_pdata = mii;
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = exphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
/*
|
||||
* The 3Com PHY can never be isolated, so never allow non-zero
|
||||
@ -145,48 +140,47 @@ exphyattach(parent, self, aux)
|
||||
*/
|
||||
if (mii->mii_instance != 0) {
|
||||
printf("%s: ignoring this PHY, non-zero instance\n",
|
||||
sc->sc_mii.mii_dev.dv_xname);
|
||||
sc->mii_dev.dv_xname);
|
||||
return;
|
||||
}
|
||||
sc->sc_mii.mii_flags |= MIIF_NOISOLATE;
|
||||
sc->mii_flags |= MIIF_NOISOLATE;
|
||||
|
||||
#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
|
||||
|
||||
#if 0 /* See above. */
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_NONE, 0, sc->sc_mii.mii_inst),
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_NONE, 0, sc->mii_inst),
|
||||
BMCR_ISO);
|
||||
#endif
|
||||
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->sc_mii.mii_inst),
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->mii_inst),
|
||||
BMCR_LOOP|BMCR_S100);
|
||||
|
||||
exphy_reset(sc);
|
||||
|
||||
sc->sc_mii.mii_capabilities =
|
||||
PHY_READ(&sc->sc_mii, MII_BMSR) & ma->mii_capmask;
|
||||
printf("%s: ", sc->sc_mii.mii_dev.dv_xname);
|
||||
if ((sc->sc_mii.mii_capabilities & BMSR_MEDIAMASK) == 0)
|
||||
sc->mii_capabilities =
|
||||
PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
printf("%s: ", sc->mii_dev.dv_xname);
|
||||
if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0)
|
||||
printf("no media present");
|
||||
else
|
||||
mii_add_media(mii, sc->sc_mii.mii_capabilities,
|
||||
sc->sc_mii.mii_inst);
|
||||
mii_add_media(mii, sc->mii_capabilities,
|
||||
sc->mii_inst);
|
||||
printf("\n");
|
||||
#undef ADD
|
||||
}
|
||||
|
||||
int
|
||||
exphy_service(self, mii, cmd)
|
||||
struct mii_softc *self;
|
||||
exphy_service(sc, mii, cmd)
|
||||
struct mii_softc *sc;
|
||||
struct mii_data *mii;
|
||||
int cmd;
|
||||
{
|
||||
struct exphy_softc *sc = (struct exphy_softc *)self;
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
|
||||
/*
|
||||
* We can't isolate the 3Com PHY, so it has to be the only one!
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst)
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
panic("exphy_service: can't isolate 3Com PHY");
|
||||
|
||||
switch (cmd) {
|
||||
@ -205,9 +199,9 @@ exphy_service(self, mii, cmd)
|
||||
/*
|
||||
* If we're already in auto mode, just return.
|
||||
*/
|
||||
if (PHY_READ(&sc->sc_mii, MII_BMCR) & BMCR_AUTOEN)
|
||||
if (PHY_READ(sc, MII_BMCR) & BMCR_AUTOEN)
|
||||
return (0);
|
||||
(void) mii_phy_auto(&sc->sc_mii);
|
||||
(void) mii_phy_auto(sc);
|
||||
break;
|
||||
case IFM_100_T4:
|
||||
/*
|
||||
@ -218,9 +212,9 @@ exphy_service(self, mii, cmd)
|
||||
/*
|
||||
* BMCR data is stored in the ifmedia entry.
|
||||
*/
|
||||
PHY_WRITE(&sc->sc_mii, MII_ANAR,
|
||||
PHY_WRITE(sc, MII_ANAR,
|
||||
mii_anar(ife->ifm_media));
|
||||
PHY_WRITE(&sc->sc_mii, MII_BMCR, ife->ifm_data);
|
||||
PHY_WRITE(sc, MII_BMCR, ife->ifm_data);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -245,26 +239,26 @@ exphy_service(self, mii, cmd)
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
ukphy_status(&sc->sc_mii);
|
||||
ukphy_status(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
if (sc->sc_active != mii->mii_media_active || cmd == MII_MEDIACHG) {
|
||||
(*mii->mii_statchg)(sc->sc_mii.mii_dev.dv_parent);
|
||||
sc->sc_active = mii->mii_media_active;
|
||||
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;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
exphy_reset(sc)
|
||||
struct exphy_softc *sc;
|
||||
struct mii_softc *sc;
|
||||
{
|
||||
|
||||
mii_phy_reset(&sc->sc_mii);
|
||||
mii_phy_reset(sc);
|
||||
|
||||
/*
|
||||
* XXX 3Com PHY doesn't set the BMCR properly after
|
||||
* XXX reset, which breaks autonegotiation.
|
||||
*/
|
||||
PHY_WRITE(&sc->sc_mii, MII_BMCR, BMCR_S100|BMCR_AUTOEN|BMCR_FDX);
|
||||
PHY_WRITE(sc, MII_BMCR, BMCR_S100|BMCR_AUTOEN|BMCR_FDX);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: icsphy.c,v 1.5 1998/11/04 23:44:09 thorpej Exp $ */
|
||||
/* $NetBSD: icsphy.c,v 1.6 1998/11/05 00:19:32 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
@ -87,21 +87,16 @@
|
||||
|
||||
#include <dev/mii/icsphyreg.h>
|
||||
|
||||
struct icsphy_softc {
|
||||
struct mii_softc sc_mii; /* generic PHY */
|
||||
int sc_active;
|
||||
};
|
||||
|
||||
int icsphymatch __P((struct device *, struct cfdata *, void *));
|
||||
void icsphyattach __P((struct device *, struct device *, void *));
|
||||
|
||||
struct cfattach icsphy_ca = {
|
||||
sizeof(struct icsphy_softc), icsphymatch, icsphyattach
|
||||
sizeof(struct mii_softc), icsphymatch, icsphyattach
|
||||
};
|
||||
|
||||
int icsphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
void icsphy_reset __P((struct icsphy_softc *));
|
||||
void icsphy_status __P((struct icsphy_softc *));
|
||||
void icsphy_reset __P((struct mii_softc *));
|
||||
void icsphy_status __P((struct mii_softc *));
|
||||
|
||||
int
|
||||
icsphymatch(parent, match, aux)
|
||||
@ -123,46 +118,45 @@ icsphyattach(parent, self, aux)
|
||||
struct device *parent, *self;
|
||||
void *aux;
|
||||
{
|
||||
struct icsphy_softc *sc = (struct icsphy_softc *)self;
|
||||
struct mii_softc *sc = (struct mii_softc *)self;
|
||||
struct mii_attach_args *ma = aux;
|
||||
struct mii_data *mii = ma->mii_data;
|
||||
|
||||
printf(": %s, rev. %d\n", MII_STR_ICS_1890,
|
||||
MII_REV(ma->mii_id2));
|
||||
|
||||
sc->sc_mii.mii_inst = mii->mii_instance;
|
||||
sc->sc_mii.mii_phy = ma->mii_phyno;
|
||||
sc->sc_mii.mii_service = icsphy_service;
|
||||
sc->sc_mii.mii_pdata = mii;
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
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->sc_mii.mii_inst),
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_NONE, 0, sc->mii_inst),
|
||||
BMCR_ISO);
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->sc_mii.mii_inst),
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->mii_inst),
|
||||
BMCR_LOOP|BMCR_S100);
|
||||
|
||||
icsphy_reset(sc);
|
||||
|
||||
sc->sc_mii.mii_capabilities =
|
||||
PHY_READ(&sc->sc_mii, MII_BMSR) & ma->mii_capmask;
|
||||
printf("%s: ", sc->sc_mii.mii_dev.dv_xname);
|
||||
if ((sc->sc_mii.mii_capabilities & BMSR_MEDIAMASK) == 0)
|
||||
sc->mii_capabilities =
|
||||
PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
printf("%s: ", sc->mii_dev.dv_xname);
|
||||
if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0)
|
||||
printf("no media present");
|
||||
else
|
||||
mii_add_media(mii, sc->sc_mii.mii_capabilities,
|
||||
sc->sc_mii.mii_inst);
|
||||
mii_add_media(mii, sc->mii_capabilities,
|
||||
sc->mii_inst);
|
||||
printf("\n");
|
||||
#undef ADD
|
||||
}
|
||||
|
||||
int
|
||||
icsphy_service(self, mii, cmd)
|
||||
struct mii_softc *self;
|
||||
icsphy_service(sc, mii, cmd)
|
||||
struct mii_softc *sc;
|
||||
struct mii_data *mii;
|
||||
int cmd;
|
||||
{
|
||||
struct icsphy_softc *sc = (struct icsphy_softc *)self;
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
int reg;
|
||||
|
||||
@ -171,7 +165,7 @@ icsphy_service(self, mii, cmd)
|
||||
/*
|
||||
* If we're not polling our PHY instance, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst)
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
break;
|
||||
|
||||
@ -180,9 +174,9 @@ icsphy_service(self, mii, cmd)
|
||||
* If the media indicates a different PHY instance,
|
||||
* isolate ourselves.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst) {
|
||||
reg = PHY_READ(&sc->sc_mii, MII_BMCR);
|
||||
PHY_WRITE(&sc->sc_mii, MII_BMCR, reg | BMCR_ISO);
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
|
||||
reg = PHY_READ(sc, MII_BMCR);
|
||||
PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -197,9 +191,9 @@ icsphy_service(self, mii, cmd)
|
||||
/*
|
||||
* If we're already in auto mode, just return.
|
||||
*/
|
||||
if (PHY_READ(&sc->sc_mii, MII_BMCR) & BMCR_AUTOEN)
|
||||
if (PHY_READ(sc, MII_BMCR) & BMCR_AUTOEN)
|
||||
return (0);
|
||||
(void) mii_phy_auto(&sc->sc_mii);
|
||||
(void) mii_phy_auto(sc);
|
||||
break;
|
||||
case IFM_100_T4:
|
||||
/*
|
||||
@ -210,9 +204,9 @@ icsphy_service(self, mii, cmd)
|
||||
/*
|
||||
* BMCR data is stored in the ifmedia entry.
|
||||
*/
|
||||
PHY_WRITE(&sc->sc_mii, MII_ANAR,
|
||||
PHY_WRITE(sc, MII_ANAR,
|
||||
mii_anar(ife->ifm_media));
|
||||
PHY_WRITE(&sc->sc_mii, MII_BMCR, ife->ifm_data);
|
||||
PHY_WRITE(sc, MII_BMCR, ife->ifm_data);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -220,7 +214,7 @@ icsphy_service(self, mii, cmd)
|
||||
/*
|
||||
* If we're not currently selected, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst)
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
@ -246,18 +240,18 @@ icsphy_service(self, mii, cmd)
|
||||
icsphy_status(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
if (sc->sc_active != mii->mii_media_active || cmd == MII_MEDIACHG) {
|
||||
(*mii->mii_statchg)(sc->sc_mii.mii_dev.dv_parent);
|
||||
sc->sc_active = mii->mii_media_active;
|
||||
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;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
icsphy_status(sc)
|
||||
struct icsphy_softc *sc;
|
||||
struct mii_softc *sc;
|
||||
{
|
||||
struct mii_data *mii = sc->sc_mii.mii_pdata;
|
||||
struct mii_data *mii = sc->mii_pdata;
|
||||
int bmcr, qpr;
|
||||
|
||||
mii->mii_media_status = IFM_AVALID;
|
||||
@ -268,13 +262,13 @@ icsphy_status(sc)
|
||||
* and we have to read it twice to unlatch it anyhow. This
|
||||
* gives us fewer register reads.
|
||||
*/
|
||||
qpr = PHY_READ(&sc->sc_mii, MII_ICSPHY_QPR); /* unlatch */
|
||||
qpr = PHY_READ(&sc->sc_mii, MII_ICSPHY_QPR); /* real value */
|
||||
qpr = PHY_READ(sc, MII_ICSPHY_QPR); /* unlatch */
|
||||
qpr = PHY_READ(sc, MII_ICSPHY_QPR); /* real value */
|
||||
|
||||
if (qpr & QPR_LINK)
|
||||
mii->mii_media_status |= IFM_ACTIVE;
|
||||
|
||||
bmcr = PHY_READ(&sc->sc_mii, MII_BMCR);
|
||||
bmcr = PHY_READ(sc, MII_BMCR);
|
||||
if (bmcr & BMCR_ISO) {
|
||||
mii->mii_media_active |= IFM_NONE;
|
||||
mii->mii_media_status = 0;
|
||||
@ -300,9 +294,9 @@ icsphy_status(sc)
|
||||
|
||||
void
|
||||
icsphy_reset(sc)
|
||||
struct icsphy_softc *sc;
|
||||
struct mii_softc *sc;
|
||||
{
|
||||
|
||||
mii_phy_reset(&sc->sc_mii);
|
||||
PHY_WRITE(&sc->sc_mii, MII_ICSPHY_ECR2, ECR2_10TPROT|ECR2_Q10T);
|
||||
mii_phy_reset(sc);
|
||||
PHY_WRITE(sc, MII_ICSPHY_ECR2, ECR2_10TPROT|ECR2_Q10T);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: inphy.c,v 1.8 1998/11/04 23:44:09 thorpej Exp $ */
|
||||
/* $NetBSD: inphy.c,v 1.9 1998/11/05 00:19:32 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
@ -87,21 +87,15 @@
|
||||
|
||||
#include <dev/mii/inphyreg.h>
|
||||
|
||||
struct inphy_softc {
|
||||
struct mii_softc sc_mii; /* generic PHY */
|
||||
int sc_ticks;
|
||||
int sc_active;
|
||||
};
|
||||
|
||||
int inphymatch __P((struct device *, struct cfdata *, void *));
|
||||
void inphyattach __P((struct device *, struct device *, void *));
|
||||
|
||||
struct cfattach inphy_ca = {
|
||||
sizeof(struct inphy_softc), inphymatch, inphyattach
|
||||
sizeof(struct mii_softc), inphymatch, inphyattach
|
||||
};
|
||||
|
||||
int inphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
void inphy_status __P((struct inphy_softc *));
|
||||
void inphy_status __P((struct mii_softc *));
|
||||
|
||||
int
|
||||
inphymatch(parent, match, aux)
|
||||
@ -123,55 +117,54 @@ inphyattach(parent, self, aux)
|
||||
struct device *parent, *self;
|
||||
void *aux;
|
||||
{
|
||||
struct inphy_softc *sc = (struct inphy_softc *)self;
|
||||
struct mii_softc *sc = (struct mii_softc *)self;
|
||||
struct mii_attach_args *ma = aux;
|
||||
struct mii_data *mii = ma->mii_data;
|
||||
|
||||
printf(": %s, rev. %d\n", MII_STR_INTEL_I82555,
|
||||
MII_REV(ma->mii_id2));
|
||||
|
||||
sc->sc_mii.mii_inst = mii->mii_instance;
|
||||
sc->sc_mii.mii_phy = ma->mii_phyno;
|
||||
sc->sc_mii.mii_service = inphy_service;
|
||||
sc->sc_mii.mii_pdata = mii;
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = inphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
/*
|
||||
* i82557 wedges if all of its PHYs are isolated!
|
||||
*/
|
||||
if (strcmp(parent->dv_cfdata->cf_driver->cd_name, "fxp") == 0 &&
|
||||
mii->mii_instance == 0)
|
||||
sc->sc_mii.mii_flags |= MIIF_NOISOLATE;
|
||||
sc->mii_flags |= MIIF_NOISOLATE;
|
||||
|
||||
#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
|
||||
|
||||
if ((sc->sc_mii.mii_flags & MIIF_NOISOLATE) == 0)
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_NONE, 0, sc->sc_mii.mii_inst),
|
||||
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->sc_mii.mii_inst),
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->mii_inst),
|
||||
BMCR_LOOP|BMCR_S100);
|
||||
|
||||
mii_phy_reset(&sc->sc_mii);
|
||||
mii_phy_reset(sc);
|
||||
|
||||
sc->sc_mii.mii_capabilities =
|
||||
PHY_READ(&sc->sc_mii, MII_BMSR) & ma->mii_capmask;
|
||||
printf("%s: ", sc->sc_mii.mii_dev.dv_xname);
|
||||
if ((sc->sc_mii.mii_capabilities & BMSR_MEDIAMASK) == 0)
|
||||
sc->mii_capabilities =
|
||||
PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
printf("%s: ", sc->mii_dev.dv_xname);
|
||||
if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0)
|
||||
printf("no media present");
|
||||
else
|
||||
mii_add_media(mii, sc->sc_mii.mii_capabilities,
|
||||
sc->sc_mii.mii_inst);
|
||||
mii_add_media(mii, sc->mii_capabilities,
|
||||
sc->mii_inst);
|
||||
printf("\n");
|
||||
#undef ADD
|
||||
}
|
||||
|
||||
int
|
||||
inphy_service(self, mii, cmd)
|
||||
struct mii_softc *self;
|
||||
inphy_service(sc, mii, cmd)
|
||||
struct mii_softc *sc;
|
||||
struct mii_data *mii;
|
||||
int cmd;
|
||||
{
|
||||
struct inphy_softc *sc = (struct inphy_softc *)self;
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
int reg;
|
||||
|
||||
@ -180,7 +173,7 @@ inphy_service(self, mii, cmd)
|
||||
/*
|
||||
* If we're not polling our PHY instance, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst)
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
break;
|
||||
|
||||
@ -189,9 +182,9 @@ inphy_service(self, mii, cmd)
|
||||
* If the media indicates a different PHY instance,
|
||||
* isolate ourselves.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst) {
|
||||
reg = PHY_READ(&sc->sc_mii, MII_BMCR);
|
||||
PHY_WRITE(&sc->sc_mii, MII_BMCR, reg | BMCR_ISO);
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
|
||||
reg = PHY_READ(sc, MII_BMCR);
|
||||
PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -206,9 +199,9 @@ inphy_service(self, mii, cmd)
|
||||
/*
|
||||
* If we're already in auto mode, just return.
|
||||
*/
|
||||
if (PHY_READ(&sc->sc_mii, MII_BMCR) & BMCR_AUTOEN)
|
||||
if (PHY_READ(sc, MII_BMCR) & BMCR_AUTOEN)
|
||||
return (0);
|
||||
(void) mii_phy_auto(&sc->sc_mii);
|
||||
(void) mii_phy_auto(sc);
|
||||
break;
|
||||
case IFM_100_T4:
|
||||
/*
|
||||
@ -219,9 +212,9 @@ inphy_service(self, mii, cmd)
|
||||
/*
|
||||
* BMCR data is stored in the ifmedia entry.
|
||||
*/
|
||||
PHY_WRITE(&sc->sc_mii, MII_ANAR,
|
||||
PHY_WRITE(sc, MII_ANAR,
|
||||
mii_anar(ife->ifm_media));
|
||||
PHY_WRITE(&sc->sc_mii, MII_BMCR, ife->ifm_data);
|
||||
PHY_WRITE(sc, MII_BMCR, ife->ifm_data);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -229,7 +222,7 @@ inphy_service(self, mii, cmd)
|
||||
/*
|
||||
* If we're not currently selected, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst)
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
@ -249,20 +242,20 @@ inphy_service(self, mii, cmd)
|
||||
* need to restart the autonegotiation process. Read
|
||||
* the BMSR twice in case it's latched.
|
||||
*/
|
||||
reg = PHY_READ(&sc->sc_mii, MII_BMSR) |
|
||||
PHY_READ(&sc->sc_mii, MII_BMSR);
|
||||
reg = PHY_READ(sc, MII_BMSR) |
|
||||
PHY_READ(sc, MII_BMSR);
|
||||
if (reg & BMSR_LINK)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Only retry autonegotiation every 5 seconds.
|
||||
*/
|
||||
if (++sc->sc_ticks != 5)
|
||||
if (++sc->mii_ticks != 5)
|
||||
return (0);
|
||||
|
||||
sc->sc_ticks = 0;
|
||||
mii_phy_reset(&sc->sc_mii);
|
||||
(void) mii_phy_auto(&sc->sc_mii);
|
||||
sc->mii_ticks = 0;
|
||||
mii_phy_reset(sc);
|
||||
(void) mii_phy_auto(sc);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -270,29 +263,29 @@ inphy_service(self, mii, cmd)
|
||||
inphy_status(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
if (sc->sc_active != mii->mii_media_active || cmd == MII_MEDIACHG) {
|
||||
(*mii->mii_statchg)(sc->sc_mii.mii_dev.dv_parent);
|
||||
sc->sc_active = mii->mii_media_active;
|
||||
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;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
inphy_status(sc)
|
||||
struct inphy_softc *sc;
|
||||
struct mii_softc *sc;
|
||||
{
|
||||
struct mii_data *mii = sc->sc_mii.mii_pdata;
|
||||
struct mii_data *mii = sc->mii_pdata;
|
||||
int bmsr, bmcr, scr;
|
||||
|
||||
mii->mii_media_status = IFM_AVALID;
|
||||
mii->mii_media_active = IFM_ETHER;
|
||||
|
||||
bmsr = PHY_READ(&sc->sc_mii, MII_BMSR) |
|
||||
PHY_READ(&sc->sc_mii, MII_BMSR);
|
||||
bmsr = PHY_READ(sc, MII_BMSR) |
|
||||
PHY_READ(sc, MII_BMSR);
|
||||
if (bmsr & BMSR_LINK)
|
||||
mii->mii_media_status |= IFM_ACTIVE;
|
||||
|
||||
bmcr = PHY_READ(&sc->sc_mii, MII_BMCR);
|
||||
bmcr = PHY_READ(sc, MII_BMCR);
|
||||
if (bmcr & BMCR_ISO) {
|
||||
mii->mii_media_active |= IFM_NONE;
|
||||
mii->mii_media_status = 0;
|
||||
@ -308,7 +301,7 @@ inphy_status(sc)
|
||||
mii->mii_media_active |= IFM_NONE;
|
||||
return;
|
||||
}
|
||||
scr = PHY_READ(&sc->sc_mii, MII_INPHY_SCR);
|
||||
scr = PHY_READ(sc, MII_INPHY_SCR);
|
||||
if (scr & SCR_T4)
|
||||
mii->mii_media_active |= IFM_100_T4;
|
||||
else if (scr & SCR_S100)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: lxtphy.c,v 1.6 1998/11/04 23:44:09 thorpej Exp $ */
|
||||
/* $NetBSD: lxtphy.c,v 1.7 1998/11/05 00:19:32 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
@ -87,21 +87,15 @@
|
||||
|
||||
#include <dev/mii/lxtphyreg.h>
|
||||
|
||||
struct lxtphy_softc {
|
||||
struct mii_softc sc_mii; /* generic PHY */
|
||||
int sc_ticks;
|
||||
int sc_active;
|
||||
};
|
||||
|
||||
int lxtphymatch __P((struct device *, struct cfdata *, void *));
|
||||
void lxtphyattach __P((struct device *, struct device *, void *));
|
||||
|
||||
struct cfattach lxtphy_ca = {
|
||||
sizeof(struct lxtphy_softc), lxtphymatch, lxtphyattach
|
||||
sizeof(struct mii_softc), lxtphymatch, lxtphyattach
|
||||
};
|
||||
|
||||
int lxtphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
void lxtphy_status __P((struct lxtphy_softc *));
|
||||
void lxtphy_status __P((struct mii_softc *));
|
||||
|
||||
int
|
||||
lxtphymatch(parent, match, aux)
|
||||
@ -123,46 +117,45 @@ lxtphyattach(parent, self, aux)
|
||||
struct device *parent, *self;
|
||||
void *aux;
|
||||
{
|
||||
struct lxtphy_softc *sc = (struct lxtphy_softc *)self;
|
||||
struct mii_softc *sc = (struct mii_softc *)self;
|
||||
struct mii_attach_args *ma = aux;
|
||||
struct mii_data *mii = ma->mii_data;
|
||||
|
||||
printf(": %s, rev. %d\n", MII_STR_LEVEL1_LXT970,
|
||||
MII_REV(ma->mii_id2));
|
||||
|
||||
sc->sc_mii.mii_inst = mii->mii_instance;
|
||||
sc->sc_mii.mii_phy = ma->mii_phyno;
|
||||
sc->sc_mii.mii_service = lxtphy_service;
|
||||
sc->sc_mii.mii_pdata = mii;
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
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->sc_mii.mii_inst),
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_NONE, 0, sc->mii_inst),
|
||||
BMCR_ISO);
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->sc_mii.mii_inst),
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->mii_inst),
|
||||
BMCR_LOOP|BMCR_S100);
|
||||
|
||||
mii_phy_reset(&sc->sc_mii);
|
||||
mii_phy_reset(sc);
|
||||
|
||||
sc->sc_mii.mii_capabilities =
|
||||
PHY_READ(&sc->sc_mii, MII_BMSR) & ma->mii_capmask;
|
||||
printf("%s: ", sc->sc_mii.mii_dev.dv_xname);
|
||||
if ((sc->sc_mii.mii_capabilities & BMSR_MEDIAMASK) == 0)
|
||||
sc->mii_capabilities =
|
||||
PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
printf("%s: ", sc->mii_dev.dv_xname);
|
||||
if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0)
|
||||
printf("no media present");
|
||||
else
|
||||
mii_add_media(mii, sc->sc_mii.mii_capabilities,
|
||||
sc->sc_mii.mii_inst);
|
||||
mii_add_media(mii, sc->mii_capabilities,
|
||||
sc->mii_inst);
|
||||
printf("\n");
|
||||
#undef ADD
|
||||
}
|
||||
|
||||
int
|
||||
lxtphy_service(self, mii, cmd)
|
||||
struct mii_softc *self;
|
||||
lxtphy_service(sc, mii, cmd)
|
||||
struct mii_softc *sc;
|
||||
struct mii_data *mii;
|
||||
int cmd;
|
||||
{
|
||||
struct lxtphy_softc *sc = (struct lxtphy_softc *)self;
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
int reg;
|
||||
|
||||
@ -171,7 +164,7 @@ lxtphy_service(self, mii, cmd)
|
||||
/*
|
||||
* If we're not polling our PHY instance, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst)
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
break;
|
||||
|
||||
@ -180,9 +173,9 @@ lxtphy_service(self, mii, cmd)
|
||||
* If the media indicates a different PHY instance,
|
||||
* isolate ourselves.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst) {
|
||||
reg = PHY_READ(&sc->sc_mii, MII_BMCR);
|
||||
PHY_WRITE(&sc->sc_mii, MII_BMCR, reg | BMCR_ISO);
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
|
||||
reg = PHY_READ(sc, MII_BMCR);
|
||||
PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -197,9 +190,9 @@ lxtphy_service(self, mii, cmd)
|
||||
/*
|
||||
* If we're already in auto mode, just return.
|
||||
*/
|
||||
if (PHY_READ(&sc->sc_mii, MII_BMCR) & BMCR_AUTOEN)
|
||||
if (PHY_READ(sc, MII_BMCR) & BMCR_AUTOEN)
|
||||
return (0);
|
||||
(void) mii_phy_auto(&sc->sc_mii);
|
||||
(void) mii_phy_auto(sc);
|
||||
break;
|
||||
case IFM_100_T4:
|
||||
/*
|
||||
@ -210,9 +203,9 @@ lxtphy_service(self, mii, cmd)
|
||||
/*
|
||||
* BMCR data is stored in the ifmedia entry.
|
||||
*/
|
||||
PHY_WRITE(&sc->sc_mii, MII_ANAR,
|
||||
PHY_WRITE(sc, MII_ANAR,
|
||||
mii_anar(ife->ifm_media));
|
||||
PHY_WRITE(&sc->sc_mii, MII_BMCR, ife->ifm_data);
|
||||
PHY_WRITE(sc, MII_BMCR, ife->ifm_data);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -220,7 +213,7 @@ lxtphy_service(self, mii, cmd)
|
||||
/*
|
||||
* If we're not currently selected, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst)
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
@ -242,19 +235,19 @@ lxtphy_service(self, mii, cmd)
|
||||
* link indication is dynamic, not latched, so only
|
||||
* one register read is required.
|
||||
*/
|
||||
reg = PHY_READ(&sc->sc_mii, MII_LXTPHY_CSR);
|
||||
reg = PHY_READ(sc, MII_LXTPHY_CSR);
|
||||
if (reg & CSR_LINK)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Only retry autonegotiation every 5 seconds.
|
||||
*/
|
||||
if (++sc->sc_ticks != 5)
|
||||
if (++sc->mii_ticks != 5)
|
||||
return (0);
|
||||
|
||||
sc->sc_ticks = 0;
|
||||
mii_phy_reset(&sc->sc_mii);
|
||||
(void) mii_phy_auto(&sc->sc_mii);
|
||||
sc->mii_ticks = 0;
|
||||
mii_phy_reset(sc);
|
||||
(void) mii_phy_auto(sc);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -262,18 +255,18 @@ lxtphy_service(self, mii, cmd)
|
||||
lxtphy_status(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
if (sc->sc_active != mii->mii_media_active || cmd == MII_MEDIACHG) {
|
||||
(*mii->mii_statchg)(sc->sc_mii.mii_dev.dv_parent);
|
||||
sc->sc_active = mii->mii_media_active;
|
||||
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;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
lxtphy_status(sc)
|
||||
struct lxtphy_softc *sc;
|
||||
struct mii_softc *sc;
|
||||
{
|
||||
struct mii_data *mii = sc->sc_mii.mii_pdata;
|
||||
struct mii_data *mii = sc->mii_pdata;
|
||||
int bmcr, csr;
|
||||
|
||||
mii->mii_media_status = IFM_AVALID;
|
||||
@ -284,11 +277,11 @@ lxtphy_status(sc)
|
||||
* for media type anyhow, and the link status in the CSR
|
||||
* doens't latch, so fewer register reads are required.
|
||||
*/
|
||||
csr = PHY_READ(&sc->sc_mii, MII_LXTPHY_CSR);
|
||||
csr = PHY_READ(sc, MII_LXTPHY_CSR);
|
||||
if (csr & CSR_LINK)
|
||||
mii->mii_media_status |= IFM_ACTIVE;
|
||||
|
||||
bmcr = PHY_READ(&sc->sc_mii, MII_BMCR);
|
||||
bmcr = PHY_READ(sc, MII_BMCR);
|
||||
if (bmcr & BMCR_ISO) {
|
||||
mii->mii_media_active |= IFM_NONE;
|
||||
mii->mii_media_status = 0;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: miivar.h,v 1.5 1998/11/04 23:59:51 thorpej Exp $ */
|
||||
/* $NetBSD: miivar.h,v 1.6 1998/11/05 00:19:32 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
@ -121,6 +121,8 @@ struct mii_softc {
|
||||
|
||||
int mii_flags; /* misc. flags; see below */
|
||||
int mii_capabilities; /* capabilities from BMSR */
|
||||
int mii_ticks; /* MII_TICK counter */
|
||||
int mii_active; /* last active media */
|
||||
};
|
||||
typedef struct mii_softc mii_softc_t;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: nsphy.c,v 1.14 1998/11/04 23:44:09 thorpej Exp $ */
|
||||
/* $NetBSD: nsphy.c,v 1.15 1998/11/05 00:19:32 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
@ -87,21 +87,15 @@
|
||||
|
||||
#include <dev/mii/nsphyreg.h>
|
||||
|
||||
struct nsphy_softc {
|
||||
struct mii_softc sc_mii; /* generic PHY */
|
||||
int sc_ticks;
|
||||
int sc_active;
|
||||
};
|
||||
|
||||
int nsphymatch __P((struct device *, struct cfdata *, void *));
|
||||
void nsphyattach __P((struct device *, struct device *, void *));
|
||||
|
||||
struct cfattach nsphy_ca = {
|
||||
sizeof(struct nsphy_softc), nsphymatch, nsphyattach
|
||||
sizeof(struct mii_softc), nsphymatch, nsphyattach
|
||||
};
|
||||
|
||||
int nsphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
void nsphy_status __P((struct nsphy_softc *));
|
||||
void nsphy_status __P((struct mii_softc *));
|
||||
|
||||
int
|
||||
nsphymatch(parent, match, aux)
|
||||
@ -123,56 +117,55 @@ nsphyattach(parent, self, aux)
|
||||
struct device *parent, *self;
|
||||
void *aux;
|
||||
{
|
||||
struct nsphy_softc *sc = (struct nsphy_softc *)self;
|
||||
struct mii_softc *sc = (struct mii_softc *)self;
|
||||
struct mii_attach_args *ma = aux;
|
||||
struct mii_data *mii = ma->mii_data;
|
||||
|
||||
printf(": %s, rev. %d\n", MII_STR_NATSEMI_DP83840,
|
||||
MII_REV(ma->mii_id2));
|
||||
|
||||
sc->sc_mii.mii_inst = mii->mii_instance;
|
||||
sc->sc_mii.mii_phy = ma->mii_phyno;
|
||||
sc->sc_mii.mii_service = nsphy_service;
|
||||
sc->sc_mii.mii_pdata = mii;
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = nsphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
/*
|
||||
* i82557 wedges if all of its PHYs are isolated!
|
||||
*/
|
||||
if (strcmp(parent->dv_cfdata->cf_driver->cd_name, "fxp") == 0 &&
|
||||
mii->mii_instance == 0)
|
||||
sc->sc_mii.mii_flags |= MIIF_NOISOLATE;
|
||||
sc->mii_flags |= MIIF_NOISOLATE;
|
||||
|
||||
#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
|
||||
|
||||
#if 0
|
||||
/* Can't do this on the i82557! */
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_NONE, 0, sc->sc_mii.mii_inst),
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_NONE, 0, sc->mii_inst),
|
||||
BMCR_ISO);
|
||||
#endif
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->sc_mii.mii_inst),
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->mii_inst),
|
||||
BMCR_LOOP|BMCR_S100);
|
||||
|
||||
mii_phy_reset(&sc->sc_mii);
|
||||
mii_phy_reset(sc);
|
||||
|
||||
sc->sc_mii.mii_capabilities =
|
||||
PHY_READ(&sc->sc_mii, MII_BMSR) & ma->mii_capmask;
|
||||
printf("%s: ", sc->sc_mii.mii_dev.dv_xname);
|
||||
if ((sc->sc_mii.mii_capabilities & BMSR_MEDIAMASK) == 0)
|
||||
sc->mii_capabilities =
|
||||
PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
printf("%s: ", sc->mii_dev.dv_xname);
|
||||
if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0)
|
||||
printf("no media present");
|
||||
else
|
||||
mii_add_media(mii, sc->sc_mii.mii_capabilities,
|
||||
sc->sc_mii.mii_inst);
|
||||
mii_add_media(mii, sc->mii_capabilities,
|
||||
sc->mii_inst);
|
||||
printf("\n");
|
||||
#undef ADD
|
||||
}
|
||||
|
||||
int
|
||||
nsphy_service(self, mii, cmd)
|
||||
struct mii_softc *self;
|
||||
nsphy_service(sc, mii, cmd)
|
||||
struct mii_softc *sc;
|
||||
struct mii_data *mii;
|
||||
int cmd;
|
||||
{
|
||||
struct nsphy_softc *sc = (struct nsphy_softc *)self;
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
int reg;
|
||||
|
||||
@ -181,7 +174,7 @@ nsphy_service(self, mii, cmd)
|
||||
/*
|
||||
* If we're not polling our PHY instance, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst)
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
break;
|
||||
|
||||
@ -190,9 +183,9 @@ nsphy_service(self, mii, cmd)
|
||||
* If the media indicates a different PHY instance,
|
||||
* isolate ourselves.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst) {
|
||||
reg = PHY_READ(&sc->sc_mii, MII_BMCR);
|
||||
PHY_WRITE(&sc->sc_mii, MII_BMCR, reg | BMCR_ISO);
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
|
||||
reg = PHY_READ(sc, MII_BMCR);
|
||||
PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -202,7 +195,7 @@ nsphy_service(self, mii, cmd)
|
||||
if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
|
||||
break;
|
||||
|
||||
reg = PHY_READ(&sc->sc_mii, MII_NSPHY_PCR);
|
||||
reg = PHY_READ(sc, MII_NSPHY_PCR);
|
||||
|
||||
/*
|
||||
* Set up the PCR to use LED4 to indicate full-duplex
|
||||
@ -233,16 +226,16 @@ nsphy_service(self, mii, cmd)
|
||||
reg |= 0x0100 | 0x0400;
|
||||
#endif
|
||||
|
||||
PHY_WRITE(&sc->sc_mii, MII_NSPHY_PCR, reg);
|
||||
PHY_WRITE(sc, MII_NSPHY_PCR, reg);
|
||||
|
||||
switch (IFM_SUBTYPE(ife->ifm_media)) {
|
||||
case IFM_AUTO:
|
||||
/*
|
||||
* If we're already in auto mode, just return.
|
||||
*/
|
||||
if (PHY_READ(&sc->sc_mii, MII_BMCR) & BMCR_AUTOEN)
|
||||
if (PHY_READ(sc, MII_BMCR) & BMCR_AUTOEN)
|
||||
return (0);
|
||||
(void) mii_phy_auto(&sc->sc_mii);
|
||||
(void) mii_phy_auto(sc);
|
||||
break;
|
||||
case IFM_100_T4:
|
||||
/*
|
||||
@ -253,9 +246,9 @@ nsphy_service(self, mii, cmd)
|
||||
/*
|
||||
* BMCR data is stored in the ifmedia entry.
|
||||
*/
|
||||
PHY_WRITE(&sc->sc_mii, MII_ANAR,
|
||||
PHY_WRITE(sc, MII_ANAR,
|
||||
mii_anar(ife->ifm_media));
|
||||
PHY_WRITE(&sc->sc_mii, MII_BMCR, ife->ifm_data);
|
||||
PHY_WRITE(sc, MII_BMCR, ife->ifm_data);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -263,7 +256,7 @@ nsphy_service(self, mii, cmd)
|
||||
/*
|
||||
* If we're not currently selected, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst)
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
@ -283,20 +276,20 @@ nsphy_service(self, mii, cmd)
|
||||
* need to restart the autonegotiation process. Read
|
||||
* the BMSR twice in case it's latched.
|
||||
*/
|
||||
reg = PHY_READ(&sc->sc_mii, MII_BMSR) |
|
||||
PHY_READ(&sc->sc_mii, MII_BMSR);
|
||||
reg = PHY_READ(sc, MII_BMSR) |
|
||||
PHY_READ(sc, MII_BMSR);
|
||||
if (reg & BMSR_LINK)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Only retry autonegotiation every 5 seconds.
|
||||
*/
|
||||
if (++sc->sc_ticks != 5)
|
||||
if (++sc->mii_ticks != 5)
|
||||
return (0);
|
||||
|
||||
sc->sc_ticks = 0;
|
||||
mii_phy_reset(&sc->sc_mii);
|
||||
(void) mii_phy_auto(&sc->sc_mii);
|
||||
sc->mii_ticks = 0;
|
||||
mii_phy_reset(sc);
|
||||
(void) mii_phy_auto(sc);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -304,29 +297,29 @@ nsphy_service(self, mii, cmd)
|
||||
nsphy_status(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
if (sc->sc_active != mii->mii_media_active || cmd == MII_MEDIACHG) {
|
||||
(*mii->mii_statchg)(sc->sc_mii.mii_dev.dv_parent);
|
||||
sc->sc_active = mii->mii_media_active;
|
||||
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;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
nsphy_status(sc)
|
||||
struct nsphy_softc *sc;
|
||||
struct mii_softc *sc;
|
||||
{
|
||||
struct mii_data *mii = sc->sc_mii.mii_pdata;
|
||||
struct mii_data *mii = sc->mii_pdata;
|
||||
int bmsr, bmcr, par, anlpar;
|
||||
|
||||
mii->mii_media_status = IFM_AVALID;
|
||||
mii->mii_media_active = IFM_ETHER;
|
||||
|
||||
bmsr = PHY_READ(&sc->sc_mii, MII_BMSR) |
|
||||
PHY_READ(&sc->sc_mii, MII_BMSR);
|
||||
bmsr = PHY_READ(sc, MII_BMSR) |
|
||||
PHY_READ(sc, MII_BMSR);
|
||||
if (bmsr & BMSR_LINK)
|
||||
mii->mii_media_status |= IFM_ACTIVE;
|
||||
|
||||
bmcr = PHY_READ(&sc->sc_mii, MII_BMCR);
|
||||
bmcr = PHY_READ(sc, MII_BMCR);
|
||||
if (bmcr & BMCR_ISO) {
|
||||
mii->mii_media_active |= IFM_NONE;
|
||||
mii->mii_media_status = 0;
|
||||
@ -352,9 +345,9 @@ nsphy_status(sc)
|
||||
* properly! Determine media based on link partner's
|
||||
* advertised capabilities.
|
||||
*/
|
||||
if (PHY_READ(&sc->sc_mii, MII_ANER) & ANER_LPAN) {
|
||||
anlpar = PHY_READ(&sc->sc_mii, MII_ANAR) &
|
||||
PHY_READ(&sc->sc_mii, MII_ANLPAR);
|
||||
if (PHY_READ(sc, MII_ANER) & ANER_LPAN) {
|
||||
anlpar = PHY_READ(sc, MII_ANAR) &
|
||||
PHY_READ(sc, MII_ANLPAR);
|
||||
if (anlpar & ANLPAR_T4)
|
||||
mii->mii_media_active |= IFM_100_T4;
|
||||
else if (anlpar & ANLPAR_TX_FD)
|
||||
@ -375,7 +368,7 @@ nsphy_status(sc)
|
||||
* We will never be in full-duplex mode if this is
|
||||
* the case, so reading the PAR is OK.
|
||||
*/
|
||||
par = PHY_READ(&sc->sc_mii, MII_NSPHY_PAR);
|
||||
par = PHY_READ(sc, MII_NSPHY_PAR);
|
||||
if (par & PAR_10)
|
||||
mii->mii_media_active |= IFM_10_T;
|
||||
else
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: qsphy.c,v 1.8 1998/11/04 23:44:09 thorpej Exp $ */
|
||||
/* $NetBSD: qsphy.c,v 1.9 1998/11/05 00:19:32 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
@ -87,21 +87,16 @@
|
||||
|
||||
#include <dev/mii/qsphyreg.h>
|
||||
|
||||
struct qsphy_softc {
|
||||
struct mii_softc sc_mii; /* generic PHY */
|
||||
int sc_active;
|
||||
};
|
||||
|
||||
int qsphymatch __P((struct device *, struct cfdata *, void *));
|
||||
void qsphyattach __P((struct device *, struct device *, void *));
|
||||
|
||||
struct cfattach qsphy_ca = {
|
||||
sizeof(struct qsphy_softc), qsphymatch, qsphyattach
|
||||
sizeof(struct mii_softc), qsphymatch, qsphyattach
|
||||
};
|
||||
|
||||
int qsphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
void qsphy_reset __P((struct qsphy_softc *));
|
||||
void qsphy_status __P((struct qsphy_softc *));
|
||||
void qsphy_reset __P((struct mii_softc *));
|
||||
void qsphy_status __P((struct mii_softc *));
|
||||
|
||||
int
|
||||
qsphymatch(parent, match, aux)
|
||||
@ -123,46 +118,45 @@ qsphyattach(parent, self, aux)
|
||||
struct device *parent, *self;
|
||||
void *aux;
|
||||
{
|
||||
struct qsphy_softc *sc = (struct qsphy_softc *)self;
|
||||
struct mii_softc *sc = (struct mii_softc *)self;
|
||||
struct mii_attach_args *ma = aux;
|
||||
struct mii_data *mii = ma->mii_data;
|
||||
|
||||
printf(": %s, rev. %d\n", MII_STR_QUALSEMI_QS6612,
|
||||
MII_REV(ma->mii_id2));
|
||||
|
||||
sc->sc_mii.mii_inst = mii->mii_instance;
|
||||
sc->sc_mii.mii_phy = ma->mii_phyno;
|
||||
sc->sc_mii.mii_service = qsphy_service;
|
||||
sc->sc_mii.mii_pdata = mii;
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = qsphy_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->sc_mii.mii_inst),
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_NONE, 0, sc->mii_inst),
|
||||
BMCR_ISO);
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->sc_mii.mii_inst),
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->mii_inst),
|
||||
BMCR_LOOP|BMCR_S100);
|
||||
|
||||
qsphy_reset(sc);
|
||||
|
||||
sc->sc_mii.mii_capabilities =
|
||||
PHY_READ(&sc->sc_mii, MII_BMSR) & ma->mii_capmask;
|
||||
printf("%s: ", sc->sc_mii.mii_dev.dv_xname);
|
||||
if ((sc->sc_mii.mii_capabilities & BMSR_MEDIAMASK) == 0)
|
||||
sc->mii_capabilities =
|
||||
PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
printf("%s: ", sc->mii_dev.dv_xname);
|
||||
if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0)
|
||||
printf("no media present");
|
||||
else
|
||||
mii_add_media(mii, sc->sc_mii.mii_capabilities,
|
||||
sc->sc_mii.mii_inst);
|
||||
mii_add_media(mii, sc->mii_capabilities,
|
||||
sc->mii_inst);
|
||||
printf("\n");
|
||||
#undef ADD
|
||||
}
|
||||
|
||||
int
|
||||
qsphy_service(self, mii, cmd)
|
||||
struct mii_softc *self;
|
||||
qsphy_service(sc, mii, cmd)
|
||||
struct mii_softc *sc;
|
||||
struct mii_data *mii;
|
||||
int cmd;
|
||||
{
|
||||
struct qsphy_softc *sc = (struct qsphy_softc *)self;
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
int reg;
|
||||
|
||||
@ -171,7 +165,7 @@ qsphy_service(self, mii, cmd)
|
||||
/*
|
||||
* If we're not polling our PHY instance, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst)
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
break;
|
||||
|
||||
@ -180,9 +174,9 @@ qsphy_service(self, mii, cmd)
|
||||
* If the media indicates a different PHY instance,
|
||||
* isolate ourselves.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst) {
|
||||
reg = PHY_READ(&sc->sc_mii, MII_BMCR);
|
||||
PHY_WRITE(&sc->sc_mii, MII_BMCR, reg | BMCR_ISO);
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
|
||||
reg = PHY_READ(sc, MII_BMCR);
|
||||
PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -197,9 +191,9 @@ qsphy_service(self, mii, cmd)
|
||||
/*
|
||||
* If we're already in auto mode, just return.
|
||||
*/
|
||||
if (PHY_READ(&sc->sc_mii, MII_BMCR) & BMCR_AUTOEN)
|
||||
if (PHY_READ(sc, MII_BMCR) & BMCR_AUTOEN)
|
||||
return (0);
|
||||
(void) mii_phy_auto(&sc->sc_mii);
|
||||
(void) mii_phy_auto(sc);
|
||||
break;
|
||||
case IFM_100_T4:
|
||||
/*
|
||||
@ -210,9 +204,9 @@ qsphy_service(self, mii, cmd)
|
||||
/*
|
||||
* BMCR data is stored in the ifmedia entry.
|
||||
*/
|
||||
PHY_WRITE(&sc->sc_mii, MII_ANAR,
|
||||
PHY_WRITE(sc, MII_ANAR,
|
||||
mii_anar(ife->ifm_media));
|
||||
PHY_WRITE(&sc->sc_mii, MII_BMCR, ife->ifm_data);
|
||||
PHY_WRITE(sc, MII_BMCR, ife->ifm_data);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -220,7 +214,7 @@ qsphy_service(self, mii, cmd)
|
||||
/*
|
||||
* If we're not currently selected, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst)
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
@ -246,29 +240,29 @@ qsphy_service(self, mii, cmd)
|
||||
qsphy_status(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
if (sc->sc_active != mii->mii_media_active || cmd == MII_MEDIACHG) {
|
||||
(*mii->mii_statchg)(sc->sc_mii.mii_dev.dv_parent);
|
||||
sc->sc_active = mii->mii_media_active;
|
||||
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;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
qsphy_status(sc)
|
||||
struct qsphy_softc *sc;
|
||||
struct mii_softc *sc;
|
||||
{
|
||||
struct mii_data *mii = sc->sc_mii.mii_pdata;
|
||||
struct mii_data *mii = sc->mii_pdata;
|
||||
int bmsr, bmcr, pctl;
|
||||
|
||||
mii->mii_media_status = IFM_AVALID;
|
||||
mii->mii_media_active = IFM_ETHER;
|
||||
|
||||
bmsr = PHY_READ(&sc->sc_mii, MII_BMSR) |
|
||||
PHY_READ(&sc->sc_mii, MII_BMSR);
|
||||
bmsr = PHY_READ(sc, MII_BMSR) |
|
||||
PHY_READ(sc, MII_BMSR);
|
||||
if (bmsr & BMSR_LINK)
|
||||
mii->mii_media_status |= IFM_ACTIVE;
|
||||
|
||||
bmcr = PHY_READ(&sc->sc_mii, MII_BMCR);
|
||||
bmcr = PHY_READ(sc, MII_BMCR);
|
||||
if (bmcr & BMCR_ISO) {
|
||||
mii->mii_media_active |= IFM_NONE;
|
||||
mii->mii_media_status = 0;
|
||||
@ -284,8 +278,8 @@ qsphy_status(sc)
|
||||
return;
|
||||
}
|
||||
|
||||
pctl = PHY_READ(&sc->sc_mii, MII_QSPHY_PCTL) |
|
||||
PHY_READ(&sc->sc_mii, MII_QSPHY_PCTL);
|
||||
pctl = PHY_READ(sc, MII_QSPHY_PCTL) |
|
||||
PHY_READ(sc, MII_QSPHY_PCTL);
|
||||
switch (pctl & PCTL_OPMASK) {
|
||||
case PCTL_10_T:
|
||||
mii->mii_media_active |= IFM_10_T;
|
||||
@ -311,9 +305,9 @@ qsphy_status(sc)
|
||||
|
||||
void
|
||||
qsphy_reset(sc)
|
||||
struct qsphy_softc *sc;
|
||||
struct mii_softc *sc;
|
||||
{
|
||||
|
||||
mii_phy_reset(&sc->sc_mii);
|
||||
PHY_WRITE(&sc->sc_mii, MII_QSPHY_IMASK, 0);
|
||||
mii_phy_reset(sc);
|
||||
PHY_WRITE(sc, MII_QSPHY_IMASK, 0);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: sqphy.c,v 1.5 1998/11/04 23:44:09 thorpej Exp $ */
|
||||
/* $NetBSD: sqphy.c,v 1.6 1998/11/05 00:19:32 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
@ -87,21 +87,15 @@
|
||||
|
||||
#include <dev/mii/sqphyreg.h>
|
||||
|
||||
struct sqphy_softc {
|
||||
struct mii_softc sc_mii; /* generic PHY */
|
||||
int sc_ticks;
|
||||
int sc_active;
|
||||
};
|
||||
|
||||
int sqphymatch __P((struct device *, struct cfdata *, void *));
|
||||
void sqphyattach __P((struct device *, struct device *, void *));
|
||||
|
||||
struct cfattach sqphy_ca = {
|
||||
sizeof(struct sqphy_softc), sqphymatch, sqphyattach
|
||||
sizeof(struct mii_softc), sqphymatch, sqphyattach
|
||||
};
|
||||
|
||||
int sqphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
void sqphy_status __P((struct sqphy_softc *));
|
||||
void sqphy_status __P((struct mii_softc *));
|
||||
|
||||
int
|
||||
sqphymatch(parent, match, aux)
|
||||
@ -123,46 +117,45 @@ sqphyattach(parent, self, aux)
|
||||
struct device *parent, *self;
|
||||
void *aux;
|
||||
{
|
||||
struct sqphy_softc *sc = (struct sqphy_softc *)self;
|
||||
struct mii_softc *sc = (struct mii_softc *)self;
|
||||
struct mii_attach_args *ma = aux;
|
||||
struct mii_data *mii = ma->mii_data;
|
||||
|
||||
printf(": %s, rev. %d\n", MII_STR_SEEQ_80220,
|
||||
MII_REV(ma->mii_id2));
|
||||
|
||||
sc->sc_mii.mii_inst = mii->mii_instance;
|
||||
sc->sc_mii.mii_phy = ma->mii_phyno;
|
||||
sc->sc_mii.mii_service = sqphy_service;
|
||||
sc->sc_mii.mii_pdata = mii;
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = sqphy_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->sc_mii.mii_inst),
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_NONE, 0, sc->mii_inst),
|
||||
BMCR_ISO);
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->sc_mii.mii_inst),
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->mii_inst),
|
||||
BMCR_LOOP|BMCR_S100);
|
||||
|
||||
mii_phy_reset(&sc->sc_mii);
|
||||
mii_phy_reset(sc);
|
||||
|
||||
sc->sc_mii.mii_capabilities =
|
||||
PHY_READ(&sc->sc_mii, MII_BMSR) & ma->mii_capmask;
|
||||
printf("%s: ", sc->sc_mii.mii_dev.dv_xname);
|
||||
if ((sc->sc_mii.mii_capabilities & BMSR_MEDIAMASK) == 0)
|
||||
sc->mii_capabilities =
|
||||
PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
printf("%s: ", sc->mii_dev.dv_xname);
|
||||
if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0)
|
||||
printf("no media present");
|
||||
else
|
||||
mii_add_media(mii, sc->sc_mii.mii_capabilities,
|
||||
sc->sc_mii.mii_inst);
|
||||
mii_add_media(mii, sc->mii_capabilities,
|
||||
sc->mii_inst);
|
||||
printf("\n");
|
||||
#undef ADD
|
||||
}
|
||||
|
||||
int
|
||||
sqphy_service(self, mii, cmd)
|
||||
struct mii_softc *self;
|
||||
sqphy_service(sc, mii, cmd)
|
||||
struct mii_softc *sc;
|
||||
struct mii_data *mii;
|
||||
int cmd;
|
||||
{
|
||||
struct sqphy_softc *sc = (struct sqphy_softc *)self;
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
int reg;
|
||||
|
||||
@ -171,7 +164,7 @@ sqphy_service(self, mii, cmd)
|
||||
/*
|
||||
* If we're not polling our PHY instance, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst)
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
break;
|
||||
|
||||
@ -180,9 +173,9 @@ sqphy_service(self, mii, cmd)
|
||||
* If the media indicates a different PHY instance,
|
||||
* isolate ourselves.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst) {
|
||||
reg = PHY_READ(&sc->sc_mii, MII_BMCR);
|
||||
PHY_WRITE(&sc->sc_mii, MII_BMCR, reg | BMCR_ISO);
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
|
||||
reg = PHY_READ(sc, MII_BMCR);
|
||||
PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -197,9 +190,9 @@ sqphy_service(self, mii, cmd)
|
||||
/*
|
||||
* If we're already in auto mode, just return.
|
||||
*/
|
||||
if (PHY_READ(&sc->sc_mii, MII_BMCR) & BMCR_AUTOEN)
|
||||
if (PHY_READ(sc, MII_BMCR) & BMCR_AUTOEN)
|
||||
return (0);
|
||||
(void) mii_phy_auto(&sc->sc_mii);
|
||||
(void) mii_phy_auto(sc);
|
||||
break;
|
||||
case IFM_100_T4:
|
||||
/*
|
||||
@ -210,9 +203,9 @@ sqphy_service(self, mii, cmd)
|
||||
/*
|
||||
* BMCR data is stored in the ifmedia entry.
|
||||
*/
|
||||
PHY_WRITE(&sc->sc_mii, MII_ANAR,
|
||||
PHY_WRITE(sc, MII_ANAR,
|
||||
mii_anar(ife->ifm_media));
|
||||
PHY_WRITE(&sc->sc_mii, MII_BMCR, ife->ifm_data);
|
||||
PHY_WRITE(sc, MII_BMCR, ife->ifm_data);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -220,7 +213,7 @@ sqphy_service(self, mii, cmd)
|
||||
/*
|
||||
* If we're not currently selected, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst)
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
@ -240,20 +233,20 @@ sqphy_service(self, mii, cmd)
|
||||
* need to restart the autonegotiation process. Read
|
||||
* the BMSR twice in case it's latched.
|
||||
*/
|
||||
reg = PHY_READ(&sc->sc_mii, MII_BMSR) |
|
||||
PHY_READ(&sc->sc_mii, MII_BMSR);
|
||||
reg = PHY_READ(sc, MII_BMSR) |
|
||||
PHY_READ(sc, MII_BMSR);
|
||||
if (reg & BMSR_LINK)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Only retry autonegotiation every 5 seconds.
|
||||
*/
|
||||
if (++sc->sc_ticks != 5)
|
||||
if (++sc->mii_ticks != 5)
|
||||
return (0);
|
||||
|
||||
sc->sc_ticks = 0;
|
||||
mii_phy_reset(&sc->sc_mii);
|
||||
(void) mii_phy_auto(&sc->sc_mii);
|
||||
sc->mii_ticks = 0;
|
||||
mii_phy_reset(sc);
|
||||
(void) mii_phy_auto(sc);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -261,29 +254,29 @@ sqphy_service(self, mii, cmd)
|
||||
sqphy_status(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
if (sc->sc_active != mii->mii_media_active || cmd == MII_MEDIACHG) {
|
||||
(*mii->mii_statchg)(sc->sc_mii.mii_dev.dv_parent);
|
||||
sc->sc_active = mii->mii_media_active;
|
||||
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;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
sqphy_status(sc)
|
||||
struct sqphy_softc *sc;
|
||||
struct mii_softc *sc;
|
||||
{
|
||||
struct mii_data *mii = sc->sc_mii.mii_pdata;
|
||||
struct mii_data *mii = sc->mii_pdata;
|
||||
int bmsr, bmcr, status;
|
||||
|
||||
mii->mii_media_status = IFM_AVALID;
|
||||
mii->mii_media_active = IFM_ETHER;
|
||||
|
||||
bmsr = PHY_READ(&sc->sc_mii, MII_BMSR) |
|
||||
PHY_READ(&sc->sc_mii, MII_BMSR);
|
||||
bmsr = PHY_READ(sc, MII_BMSR) |
|
||||
PHY_READ(sc, MII_BMSR);
|
||||
if (bmsr & BMSR_LINK)
|
||||
mii->mii_media_status |= IFM_ACTIVE;
|
||||
|
||||
bmcr = PHY_READ(&sc->sc_mii, MII_BMCR);
|
||||
bmcr = PHY_READ(sc, MII_BMCR);
|
||||
if (bmcr & BMCR_ISO) {
|
||||
mii->mii_media_active |= IFM_NONE;
|
||||
mii->mii_media_status = 0;
|
||||
@ -299,7 +292,7 @@ sqphy_status(sc)
|
||||
return;
|
||||
}
|
||||
|
||||
status = PHY_READ(&sc->sc_mii, MII_SQPHY_STATUS);
|
||||
status = PHY_READ(sc, MII_SQPHY_STATUS);
|
||||
if (status & STATUS_SPD_DET)
|
||||
mii->mii_media_active |= IFM_100_TX;
|
||||
else
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: tlphy.c,v 1.15 1998/11/04 23:44:09 thorpej Exp $ */
|
||||
/* $NetBSD: tlphy.c,v 1.16 1998/11/05 00:19:32 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
@ -97,9 +97,7 @@
|
||||
|
||||
struct tlphy_softc {
|
||||
struct mii_softc sc_mii; /* generic PHY */
|
||||
int sc_ticks;
|
||||
int sc_tlphycap;
|
||||
int sc_active;
|
||||
};
|
||||
|
||||
int tlphymatch __P((struct device *, struct cfdata *, void *));
|
||||
@ -292,10 +290,10 @@ tlphy_service(self, mii, cmd)
|
||||
/*
|
||||
* Only retry autonegotiation every 5 seconds.
|
||||
*/
|
||||
if (++sc->sc_ticks != 5)
|
||||
if (++sc->sc_mii.mii_ticks != 5)
|
||||
return (0);
|
||||
|
||||
sc->sc_ticks = 0;
|
||||
sc->sc_mii.mii_ticks = 0;
|
||||
mii_phy_reset(&sc->sc_mii);
|
||||
tlphy_auto(sc);
|
||||
break;
|
||||
@ -305,9 +303,10 @@ tlphy_service(self, mii, cmd)
|
||||
tlphy_status(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
if (sc->sc_active != mii->mii_media_active || cmd == MII_MEDIACHG) {
|
||||
if (sc->sc_mii.mii_active != mii->mii_media_active ||
|
||||
cmd == MII_MEDIACHG) {
|
||||
(*mii->mii_statchg)(sc->sc_mii.mii_dev.dv_parent);
|
||||
sc->sc_active = mii->mii_media_active;
|
||||
sc->sc_mii.mii_active = mii->mii_media_active;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user