diff options
author | marius <marius@FreeBSD.org> | 2010-10-15 14:52:11 +0000 |
---|---|---|
committer | marius <marius@FreeBSD.org> | 2010-10-15 14:52:11 +0000 |
commit | 385153aa98ec9bc0cd0bde471d7b89b6f7304427 (patch) | |
tree | 6dd0ca5b178547c1f20c8ce1f607ac42d4afe2ae /sys/dev/xl/if_xl.c | |
parent | 27659e5aa689e80a32d089f84ed2637bb3ce140d (diff) | |
download | FreeBSD-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/xl/if_xl.c')
-rw-r--r-- | sys/dev/xl/if_xl.c | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/sys/dev/xl/if_xl.c b/sys/dev/xl/if_xl.c index 3f0e1d7..0d77e12 100644 --- a/sys/dev/xl/if_xl.c +++ b/sys/dev/xl/if_xl.c @@ -523,16 +523,6 @@ xl_miibus_readreg(device_t dev, int phy, int reg) sc = device_get_softc(dev); - /* - * Pretend that PHYs are only available at MII address 24. - * This is to guard against problems with certain 3Com ASIC - * revisions that incorrectly map the internal transceiver - * control registers at all MII addresses. This can cause - * the miibus code to attach the same PHY several times over. - */ - if ((sc->xl_flags & XL_FLAG_PHYOK) == 0 && phy != 24) - return (0); - bzero((char *)&frame, sizeof(frame)); frame.mii_phyaddr = phy; frame.mii_regaddr = reg; @@ -550,9 +540,6 @@ xl_miibus_writereg(device_t dev, int phy, int reg, int data) sc = device_get_softc(dev); - if ((sc->xl_flags & XL_FLAG_PHYOK) == 0 && phy != 24) - return (0); - bzero((char *)&frame, sizeof(frame)); frame.mii_phyaddr = phy; frame.mii_regaddr = reg; @@ -1150,7 +1137,7 @@ xl_attach(device_t dev) struct xl_softc *sc; struct ifnet *ifp; int media, pmcap; - int unit, error = 0, rid, res; + int error = 0, phy, rid, res, unit; uint16_t did; sc = device_get_softc(dev); @@ -1467,10 +1454,19 @@ xl_attach(device_t dev) if (bootverbose) device_printf(dev, "found MII/AUTO\n"); xl_setcfg(sc); - if (mii_phy_probe(dev, &sc->xl_miibus, - xl_ifmedia_upd, xl_ifmedia_sts)) { - device_printf(dev, "no PHY found!\n"); - error = ENXIO; + /* + * Attach PHYs only at MII address 24 if !XL_FLAG_PHYOK. + * This is to guard against problems with certain 3Com ASIC + * revisions that incorrectly map the internal transceiver + * control registers at all MII addresses. + */ + phy = MII_PHY_ANY; + if ((sc->xl_flags & XL_FLAG_PHYOK) != 0) + phy = 24; + error = mii_attach(dev, &sc->xl_miibus, ifp, xl_ifmedia_upd, + xl_ifmedia_sts, BMSR_DEFCAPMASK, phy, MII_OFFSET_ANY, 0); + if (error != 0) { + device_printf(dev, "attaching PHYs failed\n"); goto fail; } goto done; |