Cleanup pass for mii drivers.
. Make internal service routines static. . Use a consistent ordering of checks in MII_TICK. Do the work in the mii_phy_tick() subroutine if appropriate. . Call mii_phy_update() to trigger the callbacks.
This commit is contained in:
parent
8bad7ad549
commit
6689cad447
@ -116,10 +116,10 @@ static driver_t dcphy_driver = {
|
||||
|
||||
DRIVER_MODULE(dcphy, miibus, dcphy_driver, dcphy_devclass, 0, 0);
|
||||
|
||||
int dcphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
void dcphy_status __P((struct mii_softc *));
|
||||
static int dcphy_auto __P((struct mii_softc *, int));
|
||||
static void dcphy_reset __P((struct mii_softc *));
|
||||
static int dcphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
static void dcphy_status __P((struct mii_softc *));
|
||||
static void dcphy_reset __P((struct mii_softc *));
|
||||
static int dcphy_auto __P((struct mii_softc *, int));
|
||||
|
||||
static int dcphy_probe(dev)
|
||||
device_t dev;
|
||||
@ -221,7 +221,7 @@ static int dcphy_detach(dev)
|
||||
return(0);
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
dcphy_service(sc, mii, cmd)
|
||||
struct mii_softc *sc;
|
||||
struct mii_data *mii;
|
||||
@ -317,23 +317,23 @@ dcphy_service(sc, mii, cmd)
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Only used for autonegotiation.
|
||||
*/
|
||||
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Is the interface even up?
|
||||
*/
|
||||
if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Only used for autonegotiation.
|
||||
*/
|
||||
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
|
||||
break;
|
||||
|
||||
reg = CSR_READ_4(dc_sc, DC_10BTSTAT) &
|
||||
(DC_TSTAT_LS10|DC_TSTAT_LS100);
|
||||
|
||||
if (!(reg & DC_TSTAT_LS10) || !(reg & DC_TSTAT_LS100))
|
||||
return(0);
|
||||
break;
|
||||
|
||||
/*
|
||||
* Only retry autonegotiation every 5 seconds.
|
||||
@ -353,14 +353,11 @@ dcphy_service(sc, mii, cmd)
|
||||
dcphy_status(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) {
|
||||
MIIBUS_STATCHG(sc->mii_dev);
|
||||
sc->mii_active = mii->mii_media_active;
|
||||
}
|
||||
mii_phy_update(sc, cmd);
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
dcphy_status(sc)
|
||||
struct mii_softc *sc;
|
||||
{
|
||||
|
@ -103,8 +103,8 @@ static driver_t pnphy_driver = {
|
||||
|
||||
DRIVER_MODULE(pnphy, miibus, pnphy_driver, pnphy_devclass, 0, 0);
|
||||
|
||||
int pnphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
void pnphy_status __P((struct mii_softc *));
|
||||
static int pnphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
static void pnphy_status __P((struct mii_softc *));
|
||||
|
||||
static int pnphy_probe(dev)
|
||||
device_t dev;
|
||||
@ -184,7 +184,7 @@ static int pnphy_detach(dev)
|
||||
return(0);
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
pnphy_service(sc, mii, cmd)
|
||||
struct mii_softc *sc;
|
||||
struct mii_data *mii;
|
||||
@ -256,33 +256,24 @@ pnphy_service(sc, mii, cmd)
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Only used for autonegotiation.
|
||||
*/
|
||||
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Is the interface even up?
|
||||
*/
|
||||
if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
|
||||
return (0);
|
||||
|
||||
return(0);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
pnphy_status(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) {
|
||||
MIIBUS_STATCHG(sc->mii_dev);
|
||||
sc->mii_active = mii->mii_media_active;
|
||||
}
|
||||
mii_phy_update(sc, cmd);
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
pnphy_status(sc)
|
||||
struct mii_softc *sc;
|
||||
{
|
||||
|
@ -115,9 +115,9 @@ static driver_t acphy_driver = {
|
||||
|
||||
DRIVER_MODULE(acphy, miibus, acphy_driver, acphy_devclass, 0, 0);
|
||||
|
||||
int acphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
void acphy_reset __P((struct mii_softc *));
|
||||
void acphy_status __P((struct mii_softc *));
|
||||
static int acphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
static void acphy_reset __P((struct mii_softc *));
|
||||
static void acphy_status __P((struct mii_softc *));
|
||||
|
||||
static int acphy_probe(dev)
|
||||
device_t dev;
|
||||
@ -184,7 +184,7 @@ static int acphy_detach(dev)
|
||||
return(0);
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
acphy_service(sc, mii, cmd)
|
||||
struct mii_softc *sc;
|
||||
struct mii_data *mii;
|
||||
@ -252,12 +252,6 @@ acphy_service(sc, mii, cmd)
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Only used for autonegotiation.
|
||||
*/
|
||||
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Is the interface even up?
|
||||
*/
|
||||
@ -265,14 +259,18 @@ acphy_service(sc, mii, cmd)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Check to see if we have link. If we do, we don't
|
||||
* need to restart the autonegotiation process. Read
|
||||
* the BMSR twice in case it's latched.
|
||||
* Only used for autonegotiation.
|
||||
*/
|
||||
reg = PHY_READ(sc, MII_BMSR) |
|
||||
PHY_READ(sc, MII_BMSR);
|
||||
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
|
||||
break;
|
||||
|
||||
/*
|
||||
* check for link.
|
||||
* Read the status register twice; BMSR_LINK is latch-low.
|
||||
*/
|
||||
reg = PHY_READ(sc, MII_BMSR) | PHY_READ(sc, MII_BMSR);
|
||||
if (reg & BMSR_LINK)
|
||||
return (0);
|
||||
break;
|
||||
|
||||
/*
|
||||
* Only retry autonegotiation every 5 seconds.
|
||||
@ -291,14 +289,11 @@ acphy_service(sc, mii, cmd)
|
||||
acphy_status(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) {
|
||||
MIIBUS_STATCHG(sc->mii_dev);
|
||||
sc->mii_active = mii->mii_media_active;
|
||||
}
|
||||
mii_phy_update(sc, cmd);
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
acphy_status(sc)
|
||||
struct mii_softc *sc;
|
||||
{
|
||||
@ -343,7 +338,7 @@ acphy_status(sc)
|
||||
mii->mii_media_active = ife->ifm_media;
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
acphy_reset(sc)
|
||||
struct mii_softc *sc;
|
||||
{
|
||||
|
@ -83,8 +83,8 @@ static driver_t amphy_driver = {
|
||||
|
||||
DRIVER_MODULE(amphy, miibus, amphy_driver, amphy_devclass, 0, 0);
|
||||
|
||||
int amphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
void amphy_status __P((struct mii_softc *));
|
||||
static int amphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
static void amphy_status __P((struct mii_softc *));
|
||||
|
||||
static int amphy_probe(dev)
|
||||
device_t dev;
|
||||
@ -167,7 +167,8 @@ static int amphy_detach(dev)
|
||||
|
||||
return(0);
|
||||
}
|
||||
int
|
||||
|
||||
static int
|
||||
amphy_service(sc, mii, cmd)
|
||||
struct mii_softc *sc;
|
||||
struct mii_data *mii;
|
||||
@ -232,40 +233,8 @@ amphy_service(sc, mii, cmd)
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* 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);
|
||||
|
||||
/*
|
||||
* Only retry autonegotiation every 5 seconds.
|
||||
*/
|
||||
if (++sc->mii_ticks != 5)
|
||||
return (0);
|
||||
|
||||
sc->mii_ticks = 0;
|
||||
|
||||
/*
|
||||
* Check to see if we have link. If we do, we don't
|
||||
* need to restart the autonegotiation process. Read
|
||||
* the BMSR twice in case it's latched.
|
||||
*/
|
||||
reg = PHY_READ(sc, MII_BMSR) |
|
||||
PHY_READ(sc, MII_BMSR);
|
||||
if (reg & BMSR_LINK)
|
||||
break;
|
||||
|
||||
mii_phy_reset(sc);
|
||||
if (mii_phy_auto(sc, 0) == EJUSTRETURN)
|
||||
return(0);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -273,14 +242,11 @@ amphy_service(sc, mii, cmd)
|
||||
amphy_status(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) {
|
||||
MIIBUS_STATCHG(sc->mii_dev);
|
||||
sc->mii_active = mii->mii_media_active;
|
||||
}
|
||||
mii_phy_update(sc, cmd);
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
amphy_status(sc)
|
||||
struct mii_softc *sc;
|
||||
{
|
||||
|
@ -85,9 +85,8 @@ static driver_t brgphy_driver = {
|
||||
|
||||
DRIVER_MODULE(brgphy, miibus, brgphy_driver, brgphy_devclass, 0, 0);
|
||||
|
||||
int brgphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
void brgphy_status __P((struct mii_softc *));
|
||||
|
||||
static int brgphy_service(struct mii_softc *, struct mii_data *, int);
|
||||
static void brgphy_status(struct mii_softc *);
|
||||
static int brgphy_mii_phy_auto __P((struct mii_softc *, int));
|
||||
extern void mii_phy_auto_timeout __P((void *));
|
||||
|
||||
@ -192,7 +191,8 @@ static int brgphy_detach(dev)
|
||||
|
||||
return(0);
|
||||
}
|
||||
int
|
||||
|
||||
static int
|
||||
brgphy_service(sc, mii, cmd)
|
||||
struct mii_softc *sc;
|
||||
struct mii_data *mii;
|
||||
@ -298,12 +298,6 @@ setit:
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Only used for autonegotiation.
|
||||
*/
|
||||
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Is the interface even up?
|
||||
*/
|
||||
@ -311,12 +305,10 @@ setit:
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Only retry autonegotiation every 5 seconds.
|
||||
* Only used for autonegotiation.
|
||||
*/
|
||||
if (++sc->mii_ticks != 5)
|
||||
return (0);
|
||||
|
||||
sc->mii_ticks = 0;
|
||||
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
|
||||
break;
|
||||
|
||||
/*
|
||||
* Check to see if we have link. If we do, we don't
|
||||
@ -327,9 +319,16 @@ setit:
|
||||
if (reg & BRGPHY_AUXSTS_LINK)
|
||||
break;
|
||||
|
||||
/*
|
||||
* Only retry autonegotiation every 5 seconds.
|
||||
*/
|
||||
if (++sc->mii_ticks != 5)
|
||||
return (0);
|
||||
|
||||
sc->mii_ticks = 0;
|
||||
mii_phy_reset(sc);
|
||||
if (brgphy_mii_phy_auto(sc, 0) == EJUSTRETURN)
|
||||
return(0);
|
||||
return (0);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -337,14 +336,11 @@ setit:
|
||||
brgphy_status(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) {
|
||||
MIIBUS_STATCHG(sc->mii_dev);
|
||||
sc->mii_active = mii->mii_media_active;
|
||||
}
|
||||
mii_phy_update(sc, cmd);
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
brgphy_status(sc)
|
||||
struct mii_softc *sc;
|
||||
{
|
||||
|
@ -116,10 +116,10 @@ static driver_t dcphy_driver = {
|
||||
|
||||
DRIVER_MODULE(dcphy, miibus, dcphy_driver, dcphy_devclass, 0, 0);
|
||||
|
||||
int dcphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
void dcphy_status __P((struct mii_softc *));
|
||||
static int dcphy_auto __P((struct mii_softc *, int));
|
||||
static void dcphy_reset __P((struct mii_softc *));
|
||||
static int dcphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
static void dcphy_status __P((struct mii_softc *));
|
||||
static void dcphy_reset __P((struct mii_softc *));
|
||||
static int dcphy_auto __P((struct mii_softc *, int));
|
||||
|
||||
static int dcphy_probe(dev)
|
||||
device_t dev;
|
||||
@ -221,7 +221,7 @@ static int dcphy_detach(dev)
|
||||
return(0);
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
dcphy_service(sc, mii, cmd)
|
||||
struct mii_softc *sc;
|
||||
struct mii_data *mii;
|
||||
@ -317,23 +317,23 @@ dcphy_service(sc, mii, cmd)
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Only used for autonegotiation.
|
||||
*/
|
||||
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Is the interface even up?
|
||||
*/
|
||||
if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Only used for autonegotiation.
|
||||
*/
|
||||
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
|
||||
break;
|
||||
|
||||
reg = CSR_READ_4(dc_sc, DC_10BTSTAT) &
|
||||
(DC_TSTAT_LS10|DC_TSTAT_LS100);
|
||||
|
||||
if (!(reg & DC_TSTAT_LS10) || !(reg & DC_TSTAT_LS100))
|
||||
return(0);
|
||||
break;
|
||||
|
||||
/*
|
||||
* Only retry autonegotiation every 5 seconds.
|
||||
@ -353,14 +353,11 @@ dcphy_service(sc, mii, cmd)
|
||||
dcphy_status(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) {
|
||||
MIIBUS_STATCHG(sc->mii_dev);
|
||||
sc->mii_active = mii->mii_media_active;
|
||||
}
|
||||
mii_phy_update(sc, cmd);
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
dcphy_status(sc)
|
||||
struct mii_softc *sc;
|
||||
{
|
||||
|
@ -73,12 +73,12 @@ static driver_t e1000phy_driver = {
|
||||
};
|
||||
DRIVER_MODULE(e1000phy, miibus, e1000phy_driver, e1000phy_devclass, 0, 0);
|
||||
|
||||
int e1000phy_service(struct mii_softc *, struct mii_data *, int);
|
||||
void e1000phy_status(struct mii_softc *);
|
||||
|
||||
static int e1000phy_service(struct mii_softc *, struct mii_data *, int);
|
||||
static void e1000phy_status(struct mii_softc *);
|
||||
static void e1000phy_reset(struct mii_softc *);
|
||||
static int e1000phy_mii_phy_auto(struct mii_softc *, int);
|
||||
|
||||
extern void mii_phy_auto_timeout(void *);
|
||||
static void e1000phy_reset(struct mii_softc *);
|
||||
|
||||
static int e1000phy_debug = 0;
|
||||
|
||||
@ -216,7 +216,7 @@ e1000phy_reset(struct mii_softc *sc)
|
||||
PHY_WRITE(sc, 30, 0x00);
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
e1000phy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
{
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
@ -312,44 +312,36 @@ e1000phy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Only used for autonegotiation.
|
||||
*/
|
||||
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) {
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Is the interface even up?
|
||||
*/
|
||||
if ((mii->mii_ifp->if_flags & IFF_UP) == 0) {
|
||||
if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Only used for autonegotiation.
|
||||
*/
|
||||
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
|
||||
break;
|
||||
|
||||
/*
|
||||
* check for link.
|
||||
* Read the status register twice; BMSR_LINK is latch-low.
|
||||
*/
|
||||
reg = PHY_READ(sc, MII_BMSR) | PHY_READ(sc, MII_BMSR);
|
||||
if (reg & BMSR_LINK)
|
||||
break;
|
||||
|
||||
/*
|
||||
* Only retry autonegotiation every 5 seconds.
|
||||
*/
|
||||
if (++(sc->mii_ticks) != 5) {
|
||||
if (++sc->mii_ticks != 5)
|
||||
return (0);
|
||||
}
|
||||
|
||||
sc->mii_ticks = 0;
|
||||
|
||||
/*
|
||||
* Check to see if we have link. If we do, we don't
|
||||
* need to restart the autonegotiation process. Read
|
||||
* the BMSR twice in case it's latched.
|
||||
*/
|
||||
reg = PHY_READ(sc, E1000_SR) | PHY_READ(sc, E1000_SR);
|
||||
|
||||
if (reg & E1000_SR_LINK_STATUS)
|
||||
break;
|
||||
|
||||
e1000phy_reset(sc);
|
||||
|
||||
if (e1000phy_mii_phy_auto(sc, 0) == EJUSTRETURN) {
|
||||
return(0);
|
||||
}
|
||||
|
||||
if (e1000phy_mii_phy_auto(sc, 0) == EJUSTRETURN)
|
||||
return (0);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -357,15 +349,11 @@ e1000phy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
e1000phy_status(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) {
|
||||
MIIBUS_STATCHG(sc->mii_dev);
|
||||
sc->mii_active = mii->mii_media_active;
|
||||
}
|
||||
|
||||
mii_phy_update(sc, cmd);
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
e1000phy_status(struct mii_softc *sc)
|
||||
{
|
||||
struct mii_data *mii = sc->mii_pdata;
|
||||
|
@ -114,8 +114,8 @@ static driver_t exphy_driver = {
|
||||
|
||||
DRIVER_MODULE(xlphy, miibus, exphy_driver, exphy_devclass, 0, 0);
|
||||
|
||||
int exphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
void exphy_reset __P((struct mii_softc *));
|
||||
static int exphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
static void exphy_reset __P((struct mii_softc *));
|
||||
|
||||
static int exphy_probe(dev)
|
||||
device_t dev;
|
||||
@ -221,7 +221,7 @@ static int exphy_detach(dev)
|
||||
return(0);
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
exphy_service(sc, mii, cmd)
|
||||
struct mii_softc *sc;
|
||||
struct mii_data *mii;
|
||||
@ -271,18 +271,18 @@ exphy_service(sc, mii, cmd)
|
||||
break;
|
||||
|
||||
case MII_TICK:
|
||||
/*
|
||||
* Only used for autonegotiation.
|
||||
*/
|
||||
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Is the interface even up?
|
||||
*/
|
||||
if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Only used for autonegotiation.
|
||||
*/
|
||||
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
|
||||
break;
|
||||
|
||||
/*
|
||||
* The 3Com PHY's autonegotiation doesn't need to be
|
||||
* kicked; it continues in the background.
|
||||
@ -294,14 +294,11 @@ exphy_service(sc, mii, cmd)
|
||||
ukphy_status(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) {
|
||||
MIIBUS_STATCHG(sc->mii_dev);
|
||||
sc->mii_active = mii->mii_media_active;
|
||||
}
|
||||
mii_phy_update(sc, cmd);
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
exphy_reset(sc)
|
||||
struct mii_softc *sc;
|
||||
{
|
||||
|
@ -74,9 +74,8 @@ static driver_t inphy_driver = {
|
||||
|
||||
DRIVER_MODULE(inphy, miibus, inphy_driver, inphy_devclass, 0, 0);
|
||||
|
||||
int inphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd);
|
||||
void inphy_status(struct mii_softc *sc);
|
||||
|
||||
static int inphy_service(struct mii_softc *, struct mii_data *, int);
|
||||
static void inphy_status(struct mii_softc *);
|
||||
|
||||
static int
|
||||
inphy_probe(device_t dev)
|
||||
@ -171,7 +170,7 @@ inphy_detach(device_t dev)
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
inphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
{
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
@ -222,36 +221,7 @@ inphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
case MII_TICK:
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Is the interface even up?
|
||||
*/
|
||||
if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Only used for autonegotiation.
|
||||
*/
|
||||
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* check for link.
|
||||
* Read the status register twice; BMSR_LINK is latch-low.
|
||||
*/
|
||||
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->mii_ticks != 5)
|
||||
return (0);
|
||||
|
||||
sc->mii_ticks = 0;
|
||||
mii_phy_reset(sc);
|
||||
if (mii_phy_auto(sc, 0) == EJUSTRETURN)
|
||||
if (mii_phy_tick(sc) == EJUSTRETURN)
|
||||
return (0);
|
||||
break;
|
||||
}
|
||||
@ -260,14 +230,11 @@ inphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
inphy_status(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) {
|
||||
MIIBUS_STATCHG(sc->mii_dev);
|
||||
sc->mii_active = mii->mii_media_active;
|
||||
}
|
||||
mii_phy_update(sc, cmd);
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
inphy_status(struct mii_softc *sc)
|
||||
{
|
||||
struct mii_data *mii = sc->mii_pdata;
|
||||
|
@ -274,38 +274,7 @@ lxtphy_service(sc, mii, cmd)
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Only used for autonegotiation.
|
||||
*/
|
||||
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Is the interface even up?
|
||||
*/
|
||||
if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Check to see if we have link. If we do, we don't
|
||||
* need to restart the autonegotiation process. Read
|
||||
* the BMSR twice in case it's latched.
|
||||
*/
|
||||
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->mii_ticks != 5)
|
||||
return (0);
|
||||
|
||||
sc->mii_ticks = 0;
|
||||
mii_phy_reset(sc);
|
||||
if (mii_phy_auto(sc, 0) == EJUSTRETURN)
|
||||
if (mii_phy_tick(sc) == EJUSTRETURN)
|
||||
return (0);
|
||||
break;
|
||||
}
|
||||
@ -314,10 +283,7 @@ lxtphy_service(sc, mii, cmd)
|
||||
lxtphy_status(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) {
|
||||
MIIBUS_STATCHG(sc->mii_dev);
|
||||
sc->mii_active = mii->mii_media_active;
|
||||
}
|
||||
mii_phy_update(sc, cmd);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -65,6 +65,7 @@ oui TDK 0x00c039 TDK
|
||||
oui TI 0x080028 Texas Instruments
|
||||
oui XAQTI 0x00e0ae XaQti Corp.
|
||||
oui MARVELL 0x005043 Marvell Semiconductor
|
||||
oui xxMARVELL 0x000ac2 Marvell Semiconductor
|
||||
|
||||
/* in the 79c873, AMD uses another OUI (which matches Davicom!) */
|
||||
oui xxAMD 0x00606e Advanced Micro Devices
|
||||
@ -154,4 +155,6 @@ model xxTI 100VGPMI 0x0002 ThunderLAN 100VG-AnyLan media interface
|
||||
model XAQTI XMACII 0x0000 XaQti Corp. XMAC II gigabit interface
|
||||
|
||||
/* Marvell Semiconductor PHYs */
|
||||
model MARVELL E1000 0x0000 Marvell Semiconductor 88E1000* gigabit PHY
|
||||
model MARVELL E1000 0x0000 Marvell 88E1000 Gigabit PHY
|
||||
model xxMARVELL E1000 0x0005 Marvell 88E1000 Gigabit PHY
|
||||
|
||||
|
@ -72,6 +72,7 @@
|
||||
#define MII_OUI_TI 0x080028 /* Texas Instruments */
|
||||
#define MII_OUI_XAQTI 0x00e0ae /* XaQti Corp. */
|
||||
#define MII_OUI_MARVELL 0x005043 /* Marvell Semiconductor */
|
||||
#define MII_OUI_xxMARVELL 0x000ac2 /* Marvell Semiconductor */
|
||||
|
||||
/* in the 79c873, AMD uses another OUI (which matches Davicom!) */
|
||||
#define MII_OUI_xxAMD 0x00606e /* Advanced Micro Devices */
|
||||
@ -191,4 +192,7 @@
|
||||
|
||||
/* Marvell Semiconductor PHYs */
|
||||
#define MII_MODEL_MARVELL_E1000 0x0000
|
||||
#define MII_STR_MARVELL_E1000 "Marvell Semiconductor 88E1000* gigabit PHY"
|
||||
#define MII_STR_MARVELL_E1000 "Marvell 88E1000 Gigabit PHY"
|
||||
#define MII_MODEL_xxMARVELL_E1000 0x0005
|
||||
#define MII_STR_xxMARVELL_E1000 "Marvell 88E1000 Gigabit PHY"
|
||||
|
||||
|
@ -314,12 +314,6 @@ mlphy_service(xsc, mii, cmd)
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Only used for autonegotiation.
|
||||
*/
|
||||
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Is the interface even up?
|
||||
*/
|
||||
@ -327,12 +321,10 @@ mlphy_service(xsc, mii, cmd)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Only retry autonegotiation every 5 seconds.
|
||||
* Only used for autonegotiation.
|
||||
*/
|
||||
if (++sc->mii_ticks != 5)
|
||||
return (0);
|
||||
|
||||
sc->mii_ticks = 0;
|
||||
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
|
||||
break;
|
||||
|
||||
/*
|
||||
* Check to see if we have link. If we do, we don't
|
||||
@ -355,11 +347,17 @@ mlphy_service(xsc, mii, cmd)
|
||||
if (!msc->ml_linked) {
|
||||
msc->ml_linked = 1;
|
||||
mlphy_status(sc);
|
||||
break;
|
||||
}
|
||||
return(0);
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Only retry autonegotiation every 5 seconds.
|
||||
*/
|
||||
if (++sc->mii_ticks != 5)
|
||||
return (0);
|
||||
|
||||
sc->mii_ticks = 0;
|
||||
msc->ml_linked = 0;
|
||||
mii->mii_media_active = IFM_NONE;
|
||||
mii_phy_reset(sc);
|
||||
@ -382,15 +380,12 @@ mlphy_service(xsc, mii, cmd)
|
||||
(void) (*other->mii_service)(other, mii, MII_POLLSTAT);
|
||||
other->mii_inst = other_inst;
|
||||
sc->mii_active = other->mii_active;
|
||||
sc->mii_status = other->mii_status;
|
||||
} else
|
||||
ukphy_status(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) {
|
||||
MIIBUS_STATCHG(sc->mii_dev);
|
||||
sc->mii_active = mii->mii_media_active;
|
||||
}
|
||||
|
||||
mii_phy_update(sc, cmd);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -95,9 +95,8 @@ static driver_t nsgphy_driver = {
|
||||
|
||||
DRIVER_MODULE(nsgphy, miibus, nsgphy_driver, nsgphy_devclass, 0, 0);
|
||||
|
||||
int nsgphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
void nsgphy_status __P((struct mii_softc *));
|
||||
|
||||
static int nsgphy_service __P((struct mii_softc *, struct mii_data *,int));
|
||||
static void nsgphy_status __P((struct mii_softc *));
|
||||
static int nsgphy_mii_phy_auto __P((struct mii_softc *, int));
|
||||
extern void mii_phy_auto_timeout __P((void *));
|
||||
|
||||
@ -300,18 +299,25 @@ nsgphy_service(sc, mii, cmd)
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Only used for autonegotiation.
|
||||
*/
|
||||
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Is the interface even up?
|
||||
*/
|
||||
if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Only used for autonegotiation.
|
||||
*/
|
||||
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
|
||||
break;
|
||||
|
||||
/*
|
||||
* Check to see if we have link.
|
||||
*/
|
||||
reg = PHY_READ(sc, NSGPHY_MII_PHYSUP);
|
||||
if (reg & NSGPHY_PHYSUP_LNKSTS)
|
||||
break;
|
||||
|
||||
/*
|
||||
* Only retry autonegotiation every 5 seconds.
|
||||
* Actually, for gigE PHYs, we should wait longer, since
|
||||
@ -323,13 +329,6 @@ nsgphy_service(sc, mii, cmd)
|
||||
|
||||
sc->mii_ticks = 0;
|
||||
|
||||
/*
|
||||
* Check to see if we have link.
|
||||
*/
|
||||
reg = PHY_READ(sc, NSGPHY_MII_PHYSUP);
|
||||
if (reg & NSGPHY_PHYSUP_LNKSTS)
|
||||
break;
|
||||
|
||||
mii_phy_reset(sc);
|
||||
if (nsgphy_mii_phy_auto(sc, 0) == EJUSTRETURN)
|
||||
return(0);
|
||||
@ -340,14 +339,11 @@ nsgphy_service(sc, mii, cmd)
|
||||
nsgphy_status(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) {
|
||||
MIIBUS_STATCHG(sc->mii_dev);
|
||||
sc->mii_active = mii->mii_media_active;
|
||||
}
|
||||
mii_phy_update(sc, cmd);
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
nsgphy_status(sc)
|
||||
struct mii_softc *sc;
|
||||
{
|
||||
|
@ -118,8 +118,8 @@ static driver_t nsphy_driver = {
|
||||
|
||||
DRIVER_MODULE(nsphy, miibus, nsphy_driver, nsphy_devclass, 0, 0);
|
||||
|
||||
int nsphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
void nsphy_status __P((struct mii_softc *));
|
||||
static int nsphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
static void nsphy_status __P((struct mii_softc *));
|
||||
|
||||
static int nsphy_probe(dev)
|
||||
device_t dev;
|
||||
@ -208,7 +208,7 @@ static int nsphy_detach(dev)
|
||||
return(0);
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
nsphy_service(sc, mii, cmd)
|
||||
struct mii_softc *sc;
|
||||
struct mii_data *mii;
|
||||
@ -310,38 +310,7 @@ nsphy_service(sc, mii, cmd)
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Only used for autonegotiation.
|
||||
*/
|
||||
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Is the interface even up?
|
||||
*/
|
||||
if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Check to see if we have link. If we do, we don't
|
||||
* need to restart the autonegotiation process. Read
|
||||
* the BMSR twice in case it's latched.
|
||||
*/
|
||||
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->mii_ticks != 5)
|
||||
return (0);
|
||||
|
||||
sc->mii_ticks = 0;
|
||||
mii_phy_reset(sc);
|
||||
if (mii_phy_auto(sc, 0) == EJUSTRETURN)
|
||||
if (mii_phy_tick(sc) == EJUSTRETURN)
|
||||
return (0);
|
||||
break;
|
||||
}
|
||||
@ -350,14 +319,11 @@ nsphy_service(sc, mii, cmd)
|
||||
nsphy_status(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) {
|
||||
MIIBUS_STATCHG(sc->mii_dev);
|
||||
sc->mii_active = mii->mii_media_active;
|
||||
}
|
||||
mii_phy_update(sc, cmd);
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
nsphy_status(sc)
|
||||
struct mii_softc *sc;
|
||||
{
|
||||
|
@ -89,7 +89,7 @@ static driver_t pnaphy_driver = {
|
||||
|
||||
DRIVER_MODULE(pnaphy, miibus, pnaphy_driver, pnaphy_devclass, 0, 0);
|
||||
|
||||
int pnaphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
static int pnaphy_service __P((struct mii_softc *, struct mii_data *,int));
|
||||
|
||||
static int
|
||||
pnaphy_probe(dev)
|
||||
@ -232,38 +232,7 @@ pnaphy_service(sc, mii, cmd)
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Only used for autonegotiation.
|
||||
*/
|
||||
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Is the interface even up?
|
||||
*/
|
||||
if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Check to see if we have link. If we do, we don't
|
||||
* need to restart the autonegotiation process. Read
|
||||
* the BMSR twice in case it's latched.
|
||||
*/
|
||||
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->mii_ticks != 5)
|
||||
return (0);
|
||||
|
||||
sc->mii_ticks = 0;
|
||||
mii_phy_reset(sc);
|
||||
if (mii_phy_auto(sc, 0) == EJUSTRETURN)
|
||||
if (mii_phy_tick(sc) == EJUSTRETURN)
|
||||
return (0);
|
||||
break;
|
||||
}
|
||||
@ -274,9 +243,6 @@ pnaphy_service(sc, mii, cmd)
|
||||
mii->mii_media_active = IFM_ETHER|IFM_homePNA;
|
||||
|
||||
/* Callback if something changed. */
|
||||
if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) {
|
||||
MIIBUS_STATCHG(sc->mii_dev);
|
||||
sc->mii_active = mii->mii_media_active;
|
||||
}
|
||||
mii_phy_update(sc, cmd);
|
||||
return (0);
|
||||
}
|
||||
|
@ -103,8 +103,8 @@ static driver_t pnphy_driver = {
|
||||
|
||||
DRIVER_MODULE(pnphy, miibus, pnphy_driver, pnphy_devclass, 0, 0);
|
||||
|
||||
int pnphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
void pnphy_status __P((struct mii_softc *));
|
||||
static int pnphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
static void pnphy_status __P((struct mii_softc *));
|
||||
|
||||
static int pnphy_probe(dev)
|
||||
device_t dev;
|
||||
@ -184,7 +184,7 @@ static int pnphy_detach(dev)
|
||||
return(0);
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
pnphy_service(sc, mii, cmd)
|
||||
struct mii_softc *sc;
|
||||
struct mii_data *mii;
|
||||
@ -256,33 +256,24 @@ pnphy_service(sc, mii, cmd)
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Only used for autonegotiation.
|
||||
*/
|
||||
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Is the interface even up?
|
||||
*/
|
||||
if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
|
||||
return (0);
|
||||
|
||||
return(0);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
pnphy_status(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) {
|
||||
MIIBUS_STATCHG(sc->mii_dev);
|
||||
sc->mii_active = mii->mii_media_active;
|
||||
}
|
||||
mii_phy_update(sc, cmd);
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
pnphy_status(sc)
|
||||
struct mii_softc *sc;
|
||||
{
|
||||
|
@ -119,9 +119,9 @@ static driver_t qsphy_driver = {
|
||||
|
||||
DRIVER_MODULE(qsphy, miibus, qsphy_driver, qsphy_devclass, 0, 0);
|
||||
|
||||
int qsphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
void qsphy_reset __P((struct mii_softc *));
|
||||
void qsphy_status __P((struct mii_softc *));
|
||||
static int qsphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
static void qsphy_reset __P((struct mii_softc *));
|
||||
static void qsphy_status __P((struct mii_softc *));
|
||||
|
||||
static int qsphy_probe(dev)
|
||||
device_t dev;
|
||||
@ -188,7 +188,7 @@ static int qsphy_detach(dev)
|
||||
return(0);
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
qsphy_service(sc, mii, cmd)
|
||||
struct mii_softc *sc;
|
||||
struct mii_data *mii;
|
||||
@ -251,12 +251,6 @@ qsphy_service(sc, mii, cmd)
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Only used for autonegotiation.
|
||||
*/
|
||||
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Is the interface even up?
|
||||
*/
|
||||
@ -264,14 +258,18 @@ qsphy_service(sc, mii, cmd)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Check to see if we have link. If we do, we don't
|
||||
* need to restart the autonegotiation process. Read
|
||||
* the BMSR twice in case it's latched.
|
||||
* Only used for autonegotiation.
|
||||
*/
|
||||
reg = PHY_READ(sc, MII_BMSR) |
|
||||
PHY_READ(sc, MII_BMSR);
|
||||
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
|
||||
break;
|
||||
|
||||
/*
|
||||
* check for link.
|
||||
* Read the status register twice; BMSR_LINK is latch-low.
|
||||
*/
|
||||
reg = PHY_READ(sc, MII_BMSR) | PHY_READ(sc, MII_BMSR);
|
||||
if (reg & BMSR_LINK)
|
||||
return (0);
|
||||
break;
|
||||
|
||||
/*
|
||||
* Only retry autonegotiation every 5 seconds.
|
||||
@ -280,7 +278,7 @@ qsphy_service(sc, mii, cmd)
|
||||
return (0);
|
||||
|
||||
sc->mii_ticks = 0;
|
||||
mii_phy_reset(sc);
|
||||
qsphy_reset(sc);
|
||||
if (mii_phy_auto(sc, 0) == EJUSTRETURN)
|
||||
return (0);
|
||||
break;
|
||||
@ -290,14 +288,11 @@ qsphy_service(sc, mii, cmd)
|
||||
qsphy_status(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) {
|
||||
MIIBUS_STATCHG(sc->mii_dev);
|
||||
sc->mii_active = mii->mii_media_active;
|
||||
}
|
||||
mii_phy_update(sc, cmd);
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
qsphy_status(sc)
|
||||
struct mii_softc *sc;
|
||||
{
|
||||
@ -356,7 +351,7 @@ qsphy_status(sc)
|
||||
mii->mii_media_active = ife->ifm_media;
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
qsphy_reset(sc)
|
||||
struct mii_softc *sc;
|
||||
{
|
||||
|
@ -78,8 +78,8 @@ static driver_t rlphy_driver = {
|
||||
|
||||
DRIVER_MODULE(rlphy, miibus, rlphy_driver, rlphy_devclass, 0, 0);
|
||||
|
||||
int rlphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
void rlphy_reset __P((struct mii_softc *));
|
||||
static int rlphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
static void rlphy_reset __P((struct mii_softc *));
|
||||
|
||||
static int rlphy_probe(dev)
|
||||
device_t dev;
|
||||
@ -181,7 +181,7 @@ static int rlphy_detach(dev)
|
||||
return(0);
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
rlphy_service(sc, mii, cmd)
|
||||
struct mii_softc *sc;
|
||||
struct mii_data *mii;
|
||||
@ -231,12 +231,6 @@ rlphy_service(sc, mii, cmd)
|
||||
break;
|
||||
|
||||
case MII_TICK:
|
||||
/*
|
||||
* Only used for autonegotiation.
|
||||
*/
|
||||
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Is the interface even up?
|
||||
*/
|
||||
@ -244,12 +238,10 @@ rlphy_service(sc, mii, cmd)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Only retry autonegotiation every 5 seconds.
|
||||
* Only used for autonegotiation.
|
||||
*/
|
||||
if (++sc->mii_ticks != 5)
|
||||
return (0);
|
||||
|
||||
sc->mii_ticks = 0;
|
||||
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
|
||||
break;
|
||||
|
||||
/*
|
||||
* The RealTek PHY's autonegotiation doesn't need to be
|
||||
@ -262,14 +254,11 @@ rlphy_service(sc, mii, cmd)
|
||||
ukphy_status(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) {
|
||||
MIIBUS_STATCHG(sc->mii_dev);
|
||||
sc->mii_active = mii->mii_media_active;
|
||||
}
|
||||
mii_phy_update(sc, cmd);
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
rlphy_reset(sc)
|
||||
struct mii_softc *sc;
|
||||
{
|
||||
|
@ -175,7 +175,7 @@ static int tdkphy_detach(device_t dev)
|
||||
return(0);
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
tdkphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
{
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
@ -237,38 +237,7 @@ tdkphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Only used for autonegotiation.
|
||||
*/
|
||||
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Is the interface even up?
|
||||
*/
|
||||
if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Check to see if we have link. If we do, we don't
|
||||
* need to restart the autonegotiation process. Read
|
||||
* the BMSR twice in case it's latched.
|
||||
*/
|
||||
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->mii_ticks != 5)
|
||||
return (0);
|
||||
|
||||
sc->mii_ticks = 0;
|
||||
mii_phy_reset(sc);
|
||||
if (mii_phy_auto(sc, 0) == EJUSTRETURN)
|
||||
if (mii_phy_tick(sc) == EJUSTRETURN)
|
||||
return (0);
|
||||
break;
|
||||
}
|
||||
@ -279,15 +248,13 @@ tdkphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
PHY_WRITE(sc, MII_BMCR, PHY_READ(sc, MII_BMCR) | BMCR_FDX);
|
||||
else
|
||||
PHY_WRITE(sc, MII_BMCR, PHY_READ(sc, MII_BMCR) & ~BMCR_FDX);
|
||||
|
||||
/* Callback if something changed. */
|
||||
if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) {
|
||||
MIIBUS_STATCHG(sc->mii_dev);
|
||||
sc->mii_active = mii->mii_media_active;
|
||||
}
|
||||
mii_phy_update(sc, cmd);
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
tdkphy_status(struct mii_softc *phy)
|
||||
{
|
||||
struct mii_data *mii = phy->mii_pdata;
|
||||
|
@ -125,10 +125,10 @@ static driver_t tlphy_driver = {
|
||||
|
||||
DRIVER_MODULE(tlphy, miibus, tlphy_driver, tlphy_devclass, 0, 0);
|
||||
|
||||
int tlphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
int tlphy_auto __P((struct tlphy_softc *, int));
|
||||
void tlphy_acomp __P((struct tlphy_softc *));
|
||||
void tlphy_status __P((struct tlphy_softc *));
|
||||
static int tlphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
static int tlphy_auto __P((struct tlphy_softc *, int));
|
||||
static void tlphy_acomp __P((struct tlphy_softc *));
|
||||
static void tlphy_status __P((struct tlphy_softc *));
|
||||
|
||||
static int tlphy_probe(dev)
|
||||
device_t dev;
|
||||
@ -241,7 +241,7 @@ static int tlphy_detach(dev)
|
||||
return(0);
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
tlphy_service(self, mii, cmd)
|
||||
struct mii_softc *self;
|
||||
struct mii_data *mii;
|
||||
@ -311,18 +311,18 @@ tlphy_service(self, mii, cmd)
|
||||
if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Only used for autonegotiation.
|
||||
*/
|
||||
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Is the interface even up?
|
||||
*/
|
||||
if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Only used for autonegotiation.
|
||||
*/
|
||||
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
|
||||
break;
|
||||
|
||||
/*
|
||||
* Check to see if we have link. If we do, we don't
|
||||
* need to restart the autonegotiation process. Read
|
||||
@ -333,7 +333,7 @@ tlphy_service(self, mii, cmd)
|
||||
reg = PHY_READ(&sc->sc_mii, MII_BMSR) |
|
||||
PHY_READ(&sc->sc_mii, MII_BMSR);
|
||||
if (reg & BMSR_LINK)
|
||||
return (0);
|
||||
break;
|
||||
|
||||
/*
|
||||
* Only retry autonegotiation every 5 seconds.
|
||||
@ -352,15 +352,11 @@ tlphy_service(self, mii, cmd)
|
||||
tlphy_status(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
if (sc->sc_mii.mii_active != mii->mii_media_active ||
|
||||
cmd == MII_MEDIACHG) {
|
||||
MIIBUS_STATCHG(sc->sc_mii.mii_dev);
|
||||
sc->sc_mii.mii_active = mii->mii_media_active;
|
||||
}
|
||||
mii_phy_update(&sc->sc_mii, cmd);
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
tlphy_status(sc)
|
||||
struct tlphy_softc *sc;
|
||||
{
|
||||
@ -403,7 +399,7 @@ tlphy_status(sc)
|
||||
mii->mii_media_active |= IFM_10_T;
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
tlphy_auto(sc, waitfor)
|
||||
struct tlphy_softc *sc;
|
||||
int waitfor;
|
||||
@ -431,7 +427,7 @@ tlphy_auto(sc, waitfor)
|
||||
return (error);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
tlphy_acomp(sc)
|
||||
struct tlphy_softc *sc;
|
||||
{
|
||||
|
@ -115,7 +115,7 @@ static driver_t ukphy_driver = {
|
||||
|
||||
DRIVER_MODULE(ukphy, miibus, ukphy_driver, ukphy_devclass, 0, 0);
|
||||
|
||||
int ukphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
static int ukphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
|
||||
static int
|
||||
ukphy_probe(dev)
|
||||
@ -199,7 +199,7 @@ static int ukphy_detach(dev)
|
||||
return(0);
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
ukphy_service(sc, mii, cmd)
|
||||
struct mii_softc *sc;
|
||||
struct mii_data *mii;
|
||||
@ -264,38 +264,7 @@ ukphy_service(sc, mii, cmd)
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Only used for autonegotiation.
|
||||
*/
|
||||
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Is the interface even up?
|
||||
*/
|
||||
if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Check to see if we have link. If we do, we don't
|
||||
* need to restart the autonegotiation process. Read
|
||||
* the BMSR twice in case it's latched.
|
||||
*/
|
||||
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->mii_ticks != 5)
|
||||
return (0);
|
||||
|
||||
sc->mii_ticks = 0;
|
||||
mii_phy_reset(sc);
|
||||
if (mii_phy_auto(sc, 0) == EJUSTRETURN)
|
||||
if (mii_phy_tick(sc) == EJUSTRETURN)
|
||||
return (0);
|
||||
break;
|
||||
}
|
||||
@ -304,9 +273,6 @@ ukphy_service(sc, mii, cmd)
|
||||
ukphy_status(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) {
|
||||
MIIBUS_STATCHG(sc->mii_dev);
|
||||
sc->mii_active = mii->mii_media_active;
|
||||
}
|
||||
mii_phy_update(sc, cmd);
|
||||
return (0);
|
||||
}
|
||||
|
@ -85,9 +85,8 @@ static driver_t xmphy_driver = {
|
||||
|
||||
DRIVER_MODULE(xmphy, miibus, xmphy_driver, xmphy_devclass, 0, 0);
|
||||
|
||||
int xmphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
void xmphy_status __P((struct mii_softc *));
|
||||
|
||||
static int xmphy_service __P((struct mii_softc *, struct mii_data *, int));
|
||||
static void xmphy_status __P((struct mii_softc *));
|
||||
static int xmphy_mii_phy_auto __P((struct mii_softc *, int));
|
||||
extern void mii_phy_auto_timeout __P((void *));
|
||||
|
||||
@ -179,7 +178,8 @@ static int xmphy_detach(dev)
|
||||
|
||||
return(0);
|
||||
}
|
||||
int
|
||||
|
||||
static int
|
||||
xmphy_service(sc, mii, cmd)
|
||||
struct mii_softc *sc;
|
||||
struct mii_data *mii;
|
||||
@ -250,18 +250,27 @@ xmphy_service(sc, mii, cmd)
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Only used for autonegotiation.
|
||||
*/
|
||||
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Is the interface even up?
|
||||
*/
|
||||
if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Only used for autonegotiation.
|
||||
*/
|
||||
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
|
||||
break;
|
||||
|
||||
/*
|
||||
* Check to see if we have link. If we do, we don't
|
||||
* need to restart the autonegotiation process. Read
|
||||
* the BMSR twice in case it's latched.
|
||||
*/
|
||||
reg = PHY_READ(sc, MII_BMSR) | PHY_READ(sc, MII_BMSR);
|
||||
if (reg & BMSR_LINK)
|
||||
break;
|
||||
|
||||
/*
|
||||
* Only retry autonegotiation every 5 seconds.
|
||||
*/
|
||||
@ -270,16 +279,6 @@ xmphy_service(sc, mii, cmd)
|
||||
|
||||
sc->mii_ticks = 0;
|
||||
|
||||
/*
|
||||
* Check to see if we have link. If we do, we don't
|
||||
* need to restart the autonegotiation process. Read
|
||||
* the BMSR twice in case it's latched.
|
||||
*/
|
||||
reg = PHY_READ(sc, XMPHY_MII_BMSR) |
|
||||
PHY_READ(sc, XMPHY_MII_BMSR);
|
||||
if (reg & XMPHY_BMSR_LINK)
|
||||
break;
|
||||
|
||||
mii_phy_reset(sc);
|
||||
if (xmphy_mii_phy_auto(sc, 0) == EJUSTRETURN)
|
||||
return(0);
|
||||
@ -290,14 +289,11 @@ xmphy_service(sc, mii, cmd)
|
||||
xmphy_status(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) {
|
||||
MIIBUS_STATCHG(sc->mii_dev);
|
||||
sc->mii_active = mii->mii_media_active;
|
||||
}
|
||||
mii_phy_update(sc, cmd);
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
xmphy_status(sc)
|
||||
struct mii_softc *sc;
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user