summaryrefslogtreecommitdiffstats
path: root/sys/dev/mii
diff options
context:
space:
mode:
authormarius <marius@FreeBSD.org>2006-11-27 23:37:59 +0000
committermarius <marius@FreeBSD.org>2006-11-27 23:37:59 +0000
commit08a258453383859edd0bbf92eb53a12b42997b6c (patch)
treeb5cec847884d828d30cc9b003440222d8efaa397 /sys/dev/mii
parentef00496038337374d5b4e46970df97b80d4efda4 (diff)
downloadFreeBSD-src-08a258453383859edd0bbf92eb53a12b42997b6c.zip
FreeBSD-src-08a258453383859edd0bbf92eb53a12b42997b6c.tar.gz
- Add a MIIF_FORCEANEG flag which forces an auto-negotiation to always
take place if IFM_AUTO is selected. This allows drivers like nsphy(4), which need to force writing the ANAR according to the BMSR, to take advantage of mii_phy_setmedia(). [1] - In mii_phy_reset() once the current media is set don't isolate the PHY corresponding to the instance of the currently selected media rather than unconditionally not isolating the PHY corresponding to instance 0. This saves a isolation-unisolation-cycle of the PHY corresponding to the currently selected media for the case were it isn't instance 0. - Fix some whitespace nits. [1] Obtained from: NetBSD [1] MFC after: 2 weeks
Diffstat (limited to 'sys/dev/mii')
-rw-r--r--sys/dev/mii/mii_physubr.c14
-rw-r--r--sys/dev/mii/miivar.h1
2 files changed, 11 insertions, 4 deletions
diff --git a/sys/dev/mii/mii_physubr.c b/sys/dev/mii/mii_physubr.c
index 281016b..733e9fb 100644
--- a/sys/dev/mii/mii_physubr.c
+++ b/sys/dev/mii/mii_physubr.c
@@ -114,7 +114,8 @@ mii_phy_setmedia(struct mii_softc *sc)
int bmcr, anar, gtcr;
if (IFM_SUBTYPE(ife->ifm_media) == IFM_AUTO) {
- if ((PHY_READ(sc, MII_BMCR) & BMCR_AUTOEN) == 0)
+ if ((PHY_READ(sc, MII_BMCR) & BMCR_AUTOEN) == 0 ||
+ (sc->mii_flags & MIIF_FORCEANEG))
(void) mii_phy_auto(sc);
return;
}
@@ -247,6 +248,7 @@ mii_phy_tick(struct mii_softc *sc)
void
mii_phy_reset(struct mii_softc *sc)
{
+ struct ifmedia_entry *ife = sc->mii_pdata->mii_media.ifm_cur;
int reg, i;
if (sc->mii_flags & MIIF_NOISOLATE)
@@ -257,14 +259,17 @@ mii_phy_reset(struct mii_softc *sc)
/* Wait 100ms for it to complete. */
for (i = 0; i < 100; i++) {
- reg = PHY_READ(sc, MII_BMCR);
+ reg = PHY_READ(sc, MII_BMCR);
if ((reg & BMCR_RESET) == 0)
break;
DELAY(1000);
}
- if (sc->mii_inst != 0 && ((sc->mii_flags & MIIF_NOISOLATE) == 0))
- PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
+ if ((sc->mii_flags & MIIF_NOISOLATE) == 0) {
+ if ((ife == NULL && sc->mii_inst != 0) ||
+ (ife != NULL && IFM_INST(ife->ifm_media) != sc->mii_inst))
+ PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
+ }
}
void
@@ -548,5 +553,6 @@ mii_phy_match_gen(const struct mii_attach_args *ma,
const struct mii_phydesc *
mii_phy_match(const struct mii_attach_args *ma, const struct mii_phydesc *mpd)
{
+
return (mii_phy_match_gen(ma, mpd, sizeof(struct mii_phydesc)));
}
diff --git a/sys/dev/mii/miivar.h b/sys/dev/mii/miivar.h
index b9b7318..ae4e18a 100644
--- a/sys/dev/mii/miivar.h
+++ b/sys/dev/mii/miivar.h
@@ -138,6 +138,7 @@ typedef struct mii_softc mii_softc_t;
#define MIIF_IS_1000X 0x0080 /* is a 1000BASE-X device */
#define MIIF_DOPAUSE 0x0100 /* advertise PAUSE capability */
#define MIIF_IS_HPNA 0x0200 /* is a HomePNA device */
+#define MIIF_FORCEANEG 0x0400 /* force auto-negotiation */
/* Default mii_anegticks values */
#define MII_ANEGTICKS 5
OpenPOWER on IntegriCloud