summaryrefslogtreecommitdiffstats
path: root/sys/dev/gem
diff options
context:
space:
mode:
authormarius <marius@FreeBSD.org>2010-10-15 14:52:11 +0000
committermarius <marius@FreeBSD.org>2010-10-15 14:52:11 +0000
commit385153aa98ec9bc0cd0bde471d7b89b6f7304427 (patch)
tree6dd0ca5b178547c1f20c8ce1f607ac42d4afe2ae /sys/dev/gem
parent27659e5aa689e80a32d089f84ed2637bb3ce140d (diff)
downloadFreeBSD-src-385153aa98ec9bc0cd0bde471d7b89b6f7304427.zip
FreeBSD-src-385153aa98ec9bc0cd0bde471d7b89b6f7304427.tar.gz
Convert the PHY drivers to honor the mii_flags passed down and convert
the NIC drivers as well as the PHY drivers to take advantage of the mii_attach() introduced in r213878 to get rid of certain hacks. For the most part these were: - Artificially limiting miibus_{read,write}reg methods to certain PHY addresses; we now let mii_attach() only probe the PHY at the desired address(es) instead. - PHY drivers setting MIIF_* flags based on the NIC driver they hang off from, partly even based on grabbing and using the softc of the parent; we now pass these flags down from the NIC to the PHY drivers via mii_attach(). This got us rid of all such hacks except those of brgphy() in combination with bce(4) and bge(4), which is way beyond what can be expressed with simple flags. While at it, I took the opportunity to change the NIC drivers to pass up the error returned by mii_attach() (previously by mii_phy_probe()) and unify the error message used in this case where and as appropriate as mii_attach() actually can fail for a number of reasons, not just because of no PHY(s) being present at the expected address(es). Reviewed by: jhb, yongari
Diffstat (limited to 'sys/dev/gem')
-rw-r--r--sys/dev/gem/if_gem.c39
-rw-r--r--sys/dev/gem/if_gemvar.h2
2 files changed, 17 insertions, 24 deletions
diff --git a/sys/dev/gem/if_gem.c b/sys/dev/gem/if_gem.c
index 8be68ab..5c5750e 100644
--- a/sys/dev/gem/if_gem.c
+++ b/sys/dev/gem/if_gem.c
@@ -149,7 +149,7 @@ gem_attach(struct gem_softc *sc)
{
struct gem_txsoft *txs;
struct ifnet *ifp;
- int error, i;
+ int error, i, phy;
uint32_t v;
if (bootverbose)
@@ -294,14 +294,15 @@ gem_attach(struct gem_softc *sc)
BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE);
switch (sc->sc_variant) {
case GEM_SUN_ERI:
- sc->sc_phyad = GEM_PHYAD_EXTERNAL;
+ phy = GEM_PHYAD_EXTERNAL;
break;
default:
- sc->sc_phyad = -1;
+ phy = MII_PHY_ANY;
break;
}
- error = mii_phy_probe(sc->sc_dev, &sc->sc_miibus,
- gem_mediachange, gem_mediastatus);
+ error = mii_attach(sc->sc_dev, &sc->sc_miibus, ifp,
+ gem_mediachange, gem_mediastatus, BMSR_DEFCAPMASK, phy,
+ MII_OFFSET_ANY, 0);
}
/*
@@ -318,17 +319,18 @@ gem_attach(struct gem_softc *sc)
switch (sc->sc_variant) {
case GEM_SUN_ERI:
case GEM_APPLE_K2_GMAC:
- sc->sc_phyad = GEM_PHYAD_INTERNAL;
+ phy = GEM_PHYAD_INTERNAL;
break;
case GEM_APPLE_GMAC:
- sc->sc_phyad = GEM_PHYAD_EXTERNAL;
+ phy = GEM_PHYAD_EXTERNAL;
break;
default:
- sc->sc_phyad = -1;
+ phy = MII_PHY_ANY;
break;
}
- error = mii_phy_probe(sc->sc_dev, &sc->sc_miibus,
- gem_mediachange, gem_mediastatus);
+ error = mii_attach(sc->sc_dev, &sc->sc_miibus, ifp,
+ gem_mediachange, gem_mediastatus, BMSR_DEFCAPMASK, phy,
+ MII_OFFSET_ANY, 0);
}
/*
@@ -348,12 +350,12 @@ gem_attach(struct gem_softc *sc)
GEM_BANK1_BARRIER(sc, GEM_MII_CONFIG, 4,
BUS_SPACE_BARRIER_WRITE);
sc->sc_flags |= GEM_SERDES;
- sc->sc_phyad = GEM_PHYAD_EXTERNAL;
- error = mii_phy_probe(sc->sc_dev, &sc->sc_miibus,
- gem_mediachange, gem_mediastatus);
+ error = mii_attach(sc->sc_dev, &sc->sc_miibus, ifp,
+ gem_mediachange, gem_mediastatus, BMSR_DEFCAPMASK,
+ GEM_PHYAD_EXTERNAL, MII_OFFSET_ANY, 0);
}
if (error != 0) {
- device_printf(sc->sc_dev, "PHY probe failed: %d\n", error);
+ device_printf(sc->sc_dev, "attaching PHYs failed\n");
goto fail_rxd;
}
sc->sc_mii = device_get_softc(sc->sc_miibus);
@@ -1848,9 +1850,6 @@ gem_mii_readreg(device_t dev, int phy, int reg)
#endif
sc = device_get_softc(dev);
- if (sc->sc_phyad != -1 && phy != sc->sc_phyad)
- return (0);
-
if ((sc->sc_flags & GEM_SERDES) != 0) {
switch (reg) {
case MII_BMCR:
@@ -1909,9 +1908,6 @@ gem_mii_writereg(device_t dev, int phy, int reg, int val)
#endif
sc = device_get_softc(dev);
- if (sc->sc_phyad != -1 && phy != sc->sc_phyad)
- return (0);
-
if ((sc->sc_flags & GEM_SERDES) != 0) {
switch (reg) {
case MII_BMSR:
@@ -1992,8 +1988,7 @@ gem_mii_statchg(device_t dev)
#ifdef GEM_DEBUG
if ((sc->sc_ifp->if_flags & IFF_DEBUG) != 0)
- device_printf(sc->sc_dev, "%s: status change: PHY = %d\n",
- __func__, sc->sc_phyad);
+ device_printf(sc->sc_dev, "%s: status change\n", __func__);
#endif
if ((sc->sc_mii->mii_media_status & IFM_ACTIVE) != 0 &&
diff --git a/sys/dev/gem/if_gemvar.h b/sys/dev/gem/if_gemvar.h
index ab5b2f6..59cb582 100644
--- a/sys/dev/gem/if_gemvar.h
+++ b/sys/dev/gem/if_gemvar.h
@@ -126,8 +126,6 @@ struct gem_softc {
bus_dma_tag_t sc_cdmatag; /* control data bus DMA tag */
bus_dmamap_t sc_dmamap; /* bus DMA handle */
- int sc_phyad; /* PHY to use or -1 for any */
-
u_int sc_variant;
#define GEM_UNKNOWN 0 /* don't know */
#define GEM_SUN_GEM 1 /* Sun GEM */
OpenPOWER on IntegriCloud