- Don't set MIIF_NOISOLATE so tdkphy(4) can be used in configurations

with multiple PHYs. There doesn't seem to be a problem with isolating
  78Q2120 per se nor in combination with the NICs they're used with and
  tdkphy(4) was already adding IFM_NONE anyway.
- Set MIIF_NOLOOP as loopback doesn't work with this PHY. The MIIF_NOLOOP
  flag currently triggers nothing but hopefully will be respected by
  mii_phy_setmedia() later on.
- Use mii_phy_add_media() instead of mii_add_media() so the latter can
  be eventually retired.
- Take advantage of mii_phy_setmedia().

Thanks to Hans-Joerg Sirtl for lending me test hardware.

Obtained from:	NetBSD tqphy(4)
MFC after:	2 weeks
This commit is contained in:
Marius Strobl 2006-12-02 20:16:45 +00:00
parent ba76315fa2
commit 9dd3a16881
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=164832

View file

@ -123,25 +123,18 @@ tdkphy_attach(device_t dev)
mii->mii_instance++;
sc->mii_flags |= MIIF_NOISOLATE;
#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_NONE, 0, sc->mii_inst),
BMCR_ISO);
#if 0
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->mii_inst),
BMCR_LOOP|BMCR_S100);
#endif
/*
* Apparently, we can't do loopback on this PHY.
*/
sc->mii_flags |= MIIF_NOLOOP;
mii_phy_reset(sc);
sc->mii_capabilities =
PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
device_printf(dev, " ");
mii_add_media(sc);
mii_phy_add_media(sc);
printf("\n");
#undef ADD
MIIBUS_MEDIAINIT(sc->mii_dev);
return (0);
@ -179,28 +172,7 @@ tdkphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
break;
switch (IFM_SUBTYPE(ife->ifm_media)) {
case IFM_AUTO:
/*
* If we're already in auto mode, just return.
*/
if (PHY_READ(sc, MII_BMCR) & BMCR_AUTOEN)
return (0);
(void) mii_phy_auto(sc);
break;
case IFM_100_T4:
/*
* Not supported on MII
*/
return (EINVAL);
default:
/*
* BMCR data is stored in the ifmedia entry.
*/
PHY_WRITE(sc, MII_ANAR,
mii_anar(ife->ifm_media));
PHY_WRITE(sc, MII_BMCR, ife->ifm_data);
}
mii_phy_setmedia(sc);
break;
case MII_TICK:
@ -230,6 +202,7 @@ static void
tdkphy_status(struct mii_softc *phy)
{
struct mii_data *mii = phy->mii_pdata;
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
int bmsr, bmcr, anlpar, diag;
mii->mii_media_status = IFM_AVALID;
@ -296,7 +269,6 @@ tdkphy_status(struct mii_softc *phy)
mii->mii_media_active |= IFM_10_T;
}
}
} else {
mii->mii_media_active = mii_media_from_bmcr(bmcr);
}
} else
mii->mii_media_active = ife->ifm_media;
}