summaryrefslogtreecommitdiffstats
path: root/sys/dev/bge
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/bge
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/bge')
-rw-r--r--sys/dev/bge/if_bge.c18
-rw-r--r--sys/dev/bge/if_bgereg.h1
2 files changed, 7 insertions, 12 deletions
diff --git a/sys/dev/bge/if_bge.c b/sys/dev/bge/if_bge.c
index 5381e3b..662713f 100644
--- a/sys/dev/bge/if_bge.c
+++ b/sys/dev/bge/if_bge.c
@@ -781,10 +781,6 @@ bge_miibus_readreg(device_t dev, int phy, int reg)
sc = device_get_softc(dev);
- /* Prevent the probe from finding incorrect devices. */
- if (phy != sc->bge_phy_addr)
- return (0);
-
/* Clear the autopoll bit if set, otherwise may trigger PCI errors. */
if ((sc->bge_mi_mode & BGE_MIMODE_AUTOPOLL) != 0) {
CSR_WRITE_4(sc, BGE_MI_MODE,
@@ -2563,7 +2559,7 @@ bge_attach(device_t dev)
struct bge_softc *sc;
uint32_t hwcfg = 0, misccfg;
u_char eaddr[ETHER_ADDR_LEN];
- int error, msicount, reg, rid, trys;
+ int error, msicount, phy_addr, reg, rid, trys;
sc = device_get_softc(dev);
sc->bge_dev = dev;
@@ -2596,7 +2592,7 @@ bge_attach(device_t dev)
sc->bge_chiprev = BGE_CHIPREV(sc->bge_chipid);
/* Set default PHY address. */
- sc->bge_phy_addr = 1;
+ phy_addr = 1;
/*
* Don't enable Ethernet@WireSpeed for the 5700, 5906, or the
@@ -2961,17 +2957,17 @@ bge_attach(device_t dev)
again:
bge_asf_driver_up(sc);
- if (mii_phy_probe(dev, &sc->bge_miibus,
- bge_ifmedia_upd, bge_ifmedia_sts)) {
+ error = (mii_attach(dev, &sc->bge_miibus, ifp,
+ bge_ifmedia_upd, bge_ifmedia_sts, BMSR_DEFCAPMASK,
+ phy_addr, MII_OFFSET_ANY, 0));
+ if (error != 0) {
if (trys++ < 4) {
device_printf(sc->bge_dev, "Try again\n");
bge_miibus_writereg(sc->bge_dev, 1, MII_BMCR,
BMCR_RESET);
goto again;
}
-
- device_printf(sc->bge_dev, "MII without any PHY!\n");
- error = ENXIO;
+ device_printf(sc->bge_dev, "attaching PHYs failed\n");
goto fail;
}
diff --git a/sys/dev/bge/if_bgereg.h b/sys/dev/bge/if_bgereg.h
index 19c455c..60a39f8 100644
--- a/sys/dev/bge/if_bgereg.h
+++ b/sys/dev/bge/if_bgereg.h
@@ -2757,7 +2757,6 @@ struct bge_softc {
uint32_t bge_tx_max_coal_bds;
uint32_t bge_mi_mode;
int bge_if_flags;
- int bge_phy_addr;
int bge_txcnt;
int bge_link; /* link state */
int bge_link_evt; /* pending link event */
OpenPOWER on IntegriCloud