diff options
author | yongari <yongari@FreeBSD.org> | 2012-02-23 01:20:21 +0000 |
---|---|---|
committer | yongari <yongari@FreeBSD.org> | 2012-02-23 01:20:21 +0000 |
commit | a02033c7257bbab87f964e2a224acbd73be4771f (patch) | |
tree | 25ea1f01bf1aa9af67b4e53291d76db611314d95 | |
parent | 51c7bc89f03c75520ffd7c33fdcbb80a9b81a614 (diff) | |
download | FreeBSD-src-a02033c7257bbab87f964e2a224acbd73be4771f.zip FreeBSD-src-a02033c7257bbab87f964e2a224acbd73be4771f.tar.gz |
Add Seeq Technology 80220 PHY support to smcphy(4). This PHY is
found on Adaptec AIC-6915 Starfire ethernet controller.
While here, use status register to know resolved speed/duplex.
With this change, sf(4) correctly reports speed/duplex of
established link.
Reviewed by: marius
-rw-r--r-- | sys/dev/mii/smcphy.c | 64 |
1 files changed, 60 insertions, 4 deletions
diff --git a/sys/dev/mii/smcphy.c b/sys/dev/mii/smcphy.c index fbeaddf..1dd418d 100644 --- a/sys/dev/mii/smcphy.c +++ b/sys/dev/mii/smcphy.c @@ -55,6 +55,7 @@ static int smcphy_attach(device_t); static int smcphy_service(struct mii_softc *, struct mii_data *, int); static void smcphy_reset(struct mii_softc *); static void smcphy_auto(struct mii_softc *, int); +static void smcphy_status(struct mii_softc *); static device_method_t smcphy_methods[] = { /* device interface */ @@ -76,13 +77,20 @@ static driver_t smcphy_driver = { DRIVER_MODULE(smcphy, miibus, smcphy_driver, smcphy_devclass, 0, 0); static const struct mii_phydesc smcphys[] = { + MII_PHY_DESC(SEEQ, 80220), MII_PHY_DESC(SEEQ, 84220), MII_PHY_END }; +static const struct mii_phy_funcs smcphy80220_funcs = { + smcphy_service, + smcphy_status, + mii_phy_reset +}; + static const struct mii_phy_funcs smcphy_funcs = { smcphy_service, - ukphy_status, + smcphy_status, smcphy_reset }; @@ -97,11 +105,16 @@ static int smcphy_attach(device_t dev) { struct mii_softc *sc; + struct mii_attach_args *ma; + const struct mii_phy_funcs *mpf; sc = device_get_softc(dev); - - mii_phy_dev_attach(dev, MIIF_NOISOLATE | MIIF_NOMANPAUSE, - &smcphy_funcs, 1); + ma = device_get_ivars(dev); + if (MII_MODEL(ma->mii_id2) == MII_MODEL_SEEQ_80220) + mpf = &smcphy80220_funcs; + else + mpf = &smcphy_funcs; + mii_phy_dev_attach(dev, MIIF_NOISOLATE | MIIF_NOMANPAUSE, mpf, 1); mii_phy_setmedia(sc); return (0); @@ -214,3 +227,46 @@ smcphy_auto(struct mii_softc *sc, int media) anar = PHY_READ(sc, MII_ANAR); PHY_WRITE(sc, MII_BMCR, BMCR_AUTOEN | BMCR_STARTNEG); } + +static void +smcphy_status(struct mii_softc *sc) +{ + struct mii_data *mii; + uint32_t bmcr, bmsr, status; + + mii = sc->mii_pdata; + mii->mii_media_status = IFM_AVALID; + mii->mii_media_active = IFM_ETHER; + + bmsr = PHY_READ(sc, MII_BMSR) | PHY_READ(sc, MII_BMSR); + if ((bmsr & BMSR_LINK) != 0) + mii->mii_media_status |= IFM_ACTIVE; + + bmcr = PHY_READ(sc, MII_BMCR); + if ((bmcr & BMCR_ISO) != 0) { + mii->mii_media_active |= IFM_NONE; + mii->mii_media_status = 0; + return; + } + + if ((bmcr & BMCR_LOOP) != 0) + mii->mii_media_active |= IFM_LOOP; + + if ((bmcr & BMCR_AUTOEN) != 0) { + if ((bmsr & BMSR_ACOMP) == 0) { + /* Erg, still trying, I guess... */ + mii->mii_media_active |= IFM_NONE; + return; + } + } + + status = PHY_READ(sc, 0x12); + if (status & 0x0080) + mii->mii_media_active |= IFM_100_TX; + else + mii->mii_media_active |= IFM_10_T; + if (status & 0x0040) + mii->mii_media_active |= IFM_FDX | mii_phy_flowstatus(sc); + else + mii->mii_media_active |= IFM_HDX; +} |