- Remove attempts to implement setting of BMCR_LOOP/MIIF_NOLOOP
(reporting IFM_LOOP based on BMCR_LOOP is left in place though as it might provide useful for debugging). For most mii(4) drivers it was unclear whether the PHYs driven by them actually support loopback or not. Moreover, typically loopback mode also needs to be activated on the MAC, which none of the Ethernet drivers using mii(4) implements. Given that loopback media has no real use (and obviously hardly had a chance to actually work) besides for driver development (which just loopback mode should be sufficient for though, i.e one doesn't necessary need support for loopback media) support for it is just dropped as both NetBSD and OpenBSD already did quite some time ago. - Let mii_phy_add_media() also announce the support of IFM_NONE. - Restructure the PHY entry points to use a structure of entry points instead of discrete function pointers, and extend this to include a "reset" entry point. Make sure any PHY-specific reset routine is always used, and provide one for lxtphy(4) which disables MII interrupts (as is done for a few other PHYs we have drivers for). This includes changing NIC drivers which previously just called the generic mii_phy_reset() to now actually call the PHY-specific reset routine, which might be crucial in some cases. While at it, the redundant checks in these NIC drivers for mii->mii_instance not being zero before calling the reset routines were removed because as soon as one PHY driver attaches mii->mii_instance is incremented and we hardly can end up in their media change callbacks etc if no PHY driver has attached as mii_attach() would have failed in that case and not attach a miibus(4) instance. Consequently, NIC drivers now no longer should call mii_phy_reset() directly, so it was removed from EXPORT_SYMS. - Add a mii_phy_dev_attach() as a companion helper to mii_phy_dev_probe(). The purpose of that function is to perform the common steps to attach a PHY driver instance and to hook it up to the miibus(4) instance and to optionally also handle the probing, addition and initialization of the supported media. So all a PHY driver without any special requirements has to do in its bus attach method is to call mii_phy_dev_attach() along with PHY-specific MIIF_* flags, a pointer to its PHY functions and the add_media set to one. All PHY drivers were updated to take advantage of mii_phy_dev_attach() as appropriate. Along with these changes the capability mask was added to the mii_softc structure so PHY drivers taking advantage of mii_phy_dev_attach() but still handling media on their own do not need to fiddle with the MII attach arguments anyway. - Keep track of the PHY offset in the mii_softc structure. This is done for compatibility with NetBSD/OpenBSD. - Keep track of the PHY's OUI, model and revision in the mii_softc structure. Several PHY drivers require this information also after attaching and previously had to wrap their own softc around mii_softc. NetBSD/OpenBSD also keep track of the model and revision on their mii_softc structure. All PHY drivers were updated to take advantage as appropriate. - Convert the mebers of the MII data structure to unsigned where appropriate. This is partly inspired by NetBSD/OpenBSD. - According to IEEE 802.3-2002 the bits actually have to be reversed when mapping an OUI to the MII ID registers. All PHY drivers and miidevs where changed as necessary. Actually this now again allows to largely share miidevs with NetBSD, which fixed this problem already 9 years ago. Consequently miidevs was synced as far as possible. - Add MIIF_NOMANPAUSE and mii_phy_flowstatus() calls to drivers that weren't explicitly converted to support flow control before. It's unclear whether flow control actually works with these but typically it should and their net behavior should be more correct with these changes in place than without if the MAC driver sets MIIF_DOPAUSE. Obtained from: NetBSD (partially) Reviewed by: yongari (earlier version), silence on arch@ and net@
This commit is contained in:
parent
5b5140322d
commit
3fcb7a5365
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=221407
@ -903,10 +903,8 @@ ae_mediachange(struct ifnet *ifp)
|
||||
KASSERT(sc != NULL, ("[ae, %d]: sc is NULL", __LINE__));
|
||||
AE_LOCK(sc);
|
||||
mii = device_get_softc(sc->miibus);
|
||||
if (mii->mii_instance != 0) {
|
||||
LIST_FOREACH(mii_sc, &mii->mii_phys, mii_list)
|
||||
mii_phy_reset(mii_sc);
|
||||
}
|
||||
LIST_FOREACH(mii_sc, &mii->mii_phys, mii_list)
|
||||
PHY_RESET(mii_sc);
|
||||
error = mii_mediachg(mii);
|
||||
AE_UNLOCK(sc);
|
||||
|
||||
|
@ -301,10 +301,8 @@ age_mediachange(struct ifnet *ifp)
|
||||
sc = ifp->if_softc;
|
||||
AGE_LOCK(sc);
|
||||
mii = device_get_softc(sc->age_miibus);
|
||||
if (mii->mii_instance != 0) {
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
mii_phy_reset(miisc);
|
||||
}
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
PHY_RESET(miisc);
|
||||
error = mii_mediachg(mii);
|
||||
AGE_UNLOCK(sc);
|
||||
|
||||
|
@ -365,10 +365,8 @@ alc_mediachange(struct ifnet *ifp)
|
||||
sc = ifp->if_softc;
|
||||
ALC_LOCK(sc);
|
||||
mii = device_get_softc(sc->alc_miibus);
|
||||
if (mii->mii_instance != 0) {
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
mii_phy_reset(miisc);
|
||||
}
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
PHY_RESET(miisc);
|
||||
error = mii_mediachg(mii);
|
||||
ALC_UNLOCK(sc);
|
||||
|
||||
|
@ -286,10 +286,8 @@ ale_mediachange(struct ifnet *ifp)
|
||||
sc = ifp->if_softc;
|
||||
ALE_LOCK(sc);
|
||||
mii = device_get_softc(sc->ale_miibus);
|
||||
if (mii->mii_instance != 0) {
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
mii_phy_reset(miisc);
|
||||
}
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
PHY_RESET(miisc);
|
||||
error = mii_mediachg(mii);
|
||||
ALE_UNLOCK(sc);
|
||||
|
||||
|
@ -6141,6 +6141,7 @@ bce_ifmedia_upd_locked(struct ifnet *ifp)
|
||||
{
|
||||
struct bce_softc *sc = ifp->if_softc;
|
||||
struct mii_data *mii;
|
||||
struct mii_softc *miisc;
|
||||
int error;
|
||||
|
||||
DBENTER(BCE_VERBOSE_PHY);
|
||||
@ -6153,12 +6154,8 @@ bce_ifmedia_upd_locked(struct ifnet *ifp)
|
||||
/* Make sure the MII bus has been enumerated. */
|
||||
if (mii) {
|
||||
sc->bce_link_up = FALSE;
|
||||
if (mii->mii_instance) {
|
||||
struct mii_softc *miisc;
|
||||
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
mii_phy_reset(miisc);
|
||||
}
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
PHY_RESET(miisc);
|
||||
error = mii_mediachg(mii);
|
||||
}
|
||||
|
||||
|
@ -1736,18 +1736,15 @@ bfe_ifmedia_upd(struct ifnet *ifp)
|
||||
{
|
||||
struct bfe_softc *sc;
|
||||
struct mii_data *mii;
|
||||
struct mii_softc *miisc;
|
||||
int error;
|
||||
|
||||
sc = ifp->if_softc;
|
||||
BFE_LOCK(sc);
|
||||
|
||||
mii = device_get_softc(sc->bfe_miibus);
|
||||
if (mii->mii_instance) {
|
||||
struct mii_softc *miisc;
|
||||
for (miisc = LIST_FIRST(&mii->mii_phys); miisc != NULL;
|
||||
miisc = LIST_NEXT(miisc, mii_list))
|
||||
mii_phy_reset(miisc);
|
||||
}
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
PHY_RESET(miisc);
|
||||
error = mii_mediachg(mii);
|
||||
BFE_UNLOCK(sc);
|
||||
|
||||
|
@ -4854,9 +4854,8 @@ bge_ifmedia_upd_locked(struct ifnet *ifp)
|
||||
|
||||
sc->bge_link_evt++;
|
||||
mii = device_get_softc(sc->bge_miibus);
|
||||
if (mii->mii_instance)
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
mii_phy_reset(miisc);
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
PHY_RESET(miisc);
|
||||
mii_mediachg(mii);
|
||||
|
||||
/*
|
||||
|
@ -114,6 +114,12 @@ static void dcphy_status(struct mii_softc *);
|
||||
static void dcphy_reset(struct mii_softc *);
|
||||
static int dcphy_auto(struct mii_softc *);
|
||||
|
||||
static const struct mii_phy_funcs dcphy_funcs = {
|
||||
dcphy_service,
|
||||
dcphy_status,
|
||||
dcphy_reset
|
||||
};
|
||||
|
||||
static int
|
||||
dcphy_probe(device_t dev)
|
||||
{
|
||||
@ -138,30 +144,16 @@ static int
|
||||
dcphy_attach(device_t dev)
|
||||
{
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
struct dc_softc *dc_sc;
|
||||
device_t brdev;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_flags = miibus_get_flags(dev);
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = dcphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
mii_phy_dev_attach(dev, MIIF_NOISOLATE | MIIF_NOMANPAUSE,
|
||||
&dcphy_funcs, 0);
|
||||
|
||||
/*
|
||||
* Apparently, we can neither isolate nor do loopback.
|
||||
*/
|
||||
sc->mii_flags |= MIIF_NOISOLATE | MIIF_NOLOOP;
|
||||
|
||||
/*dcphy_reset(sc);*/
|
||||
dc_sc = mii->mii_ifp->if_softc;
|
||||
/*PHY_RESET(sc);*/
|
||||
dc_sc = sc->mii_pdata->mii_ifp->if_softc;
|
||||
CSR_WRITE_4(dc_sc, DC_10BTSTAT, 0);
|
||||
CSR_WRITE_4(dc_sc, DC_10BTCTRL, 0);
|
||||
|
||||
@ -182,7 +174,7 @@ dcphy_attach(device_t dev)
|
||||
break;
|
||||
}
|
||||
|
||||
sc->mii_capabilities &= ma->mii_capmask;
|
||||
sc->mii_capabilities &= sc->mii_capmask;
|
||||
device_printf(dev, " ");
|
||||
mii_phy_add_media(sc);
|
||||
printf("\n");
|
||||
@ -219,11 +211,11 @@ dcphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
|
||||
switch (IFM_SUBTYPE(ife->ifm_media)) {
|
||||
case IFM_AUTO:
|
||||
/*dcphy_reset(sc);*/
|
||||
(void) dcphy_auto(sc);
|
||||
/*PHY_RESET(sc);*/
|
||||
(void)dcphy_auto(sc);
|
||||
break;
|
||||
case IFM_100_TX:
|
||||
dcphy_reset(sc);
|
||||
PHY_RESET(sc);
|
||||
DC_CLRBIT(dc_sc, DC_10BTCTRL, DC_TCTL_AUTONEGENBL);
|
||||
mode |= DC_NETCFG_PORTSEL | DC_NETCFG_PCS |
|
||||
DC_NETCFG_SCRAMBLER;
|
||||
@ -292,7 +284,7 @@ dcphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
dcphy_status(sc);
|
||||
PHY_STATUS(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
mii_phy_update(sc, cmd);
|
||||
|
@ -90,6 +90,13 @@ DRIVER_MODULE(pnphy, miibus, pnphy_driver, pnphy_devclass, 0, 0);
|
||||
|
||||
static int pnphy_service(struct mii_softc *, struct mii_data *, int);
|
||||
static void pnphy_status(struct mii_softc *);
|
||||
static void pnphy_reset(struct mii_softc *);
|
||||
|
||||
static const struct mii_phy_funcs pnphy_funcs = {
|
||||
pnphy_service,
|
||||
pnphy_status,
|
||||
pnphy_reset
|
||||
};
|
||||
|
||||
static int
|
||||
pnphy_probe(device_t dev)
|
||||
@ -115,29 +122,15 @@ static int
|
||||
pnphy_attach(device_t dev)
|
||||
{
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_flags = miibus_get_flags(dev);
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = pnphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
/*
|
||||
* Apparently, we can neither isolate nor do loopback.
|
||||
*/
|
||||
sc->mii_flags |= MIIF_NOISOLATE | MIIF_NOLOOP;
|
||||
mii_phy_dev_attach(dev, MIIF_NOISOLATE | MIIF_NOMANPAUSE,
|
||||
&pnphy_funcs, 0);
|
||||
|
||||
sc->mii_capabilities =
|
||||
BMSR_100TXFDX | BMSR_100TXHDX | BMSR_10TFDX | BMSR_10THDX;
|
||||
sc->mii_capabilities &= ma->mii_capmask;
|
||||
sc->mii_capabilities &= sc->mii_capmask;
|
||||
device_printf(dev, " ");
|
||||
mii_phy_add_media(sc);
|
||||
printf("\n");
|
||||
@ -194,7 +187,7 @@ pnphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
pnphy_status(sc);
|
||||
PHY_STATUS(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
mii_phy_update(sc, cmd);
|
||||
@ -226,3 +219,9 @@ pnphy_status(struct mii_softc *sc)
|
||||
else
|
||||
mii->mii_media_active |= IFM_HDX;
|
||||
}
|
||||
|
||||
static void
|
||||
pnphy_reset(struct mii_softc *sc __unused)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -401,17 +401,9 @@ ed_pccard_kick_phy(struct ed_softc *sc)
|
||||
struct mii_softc *miisc;
|
||||
struct mii_data *mii;
|
||||
|
||||
/*
|
||||
* Many of the PHYs that wind up on PC Cards are weird in
|
||||
* this way. Generally, we don't need to worry so much about
|
||||
* the Isolation protocol since there's only one PHY in
|
||||
* these designs, so this workaround is reasonable.
|
||||
*/
|
||||
mii = device_get_softc(sc->miibus);
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list) {
|
||||
miisc->mii_flags |= MIIF_FORCEANEG;
|
||||
mii_phy_reset(miisc);
|
||||
}
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
PHY_RESET(miisc);
|
||||
return (mii_mediachg(mii));
|
||||
}
|
||||
|
||||
@ -582,13 +574,13 @@ ed_pccard_attach(device_t dev)
|
||||
ed_pccard_dl100xx_mii_reset(sc);
|
||||
(void)mii_attach(dev, &sc->miibus, sc->ifp, ed_ifmedia_upd,
|
||||
ed_ifmedia_sts, BMSR_DEFCAPMASK, MII_PHY_ANY,
|
||||
MII_OFFSET_ANY, 0);
|
||||
MII_OFFSET_ANY, MIIF_FORCEANEG);
|
||||
} else if (sc->chip_type == ED_CHIP_TYPE_AX88190 ||
|
||||
sc->chip_type == ED_CHIP_TYPE_AX88790 ||
|
||||
sc->chip_type == ED_CHIP_TYPE_TC5299J) {
|
||||
error = mii_attach(dev, &sc->miibus, sc->ifp, ed_ifmedia_upd,
|
||||
ed_ifmedia_sts, BMSR_DEFCAPMASK, MII_PHY_ANY,
|
||||
MII_OFFSET_ANY, 0);
|
||||
MII_OFFSET_ANY, MIIF_FORCEANEG);
|
||||
if (error != 0) {
|
||||
device_printf(dev, "attaching PHYs failed\n");
|
||||
goto bad;
|
||||
|
@ -515,13 +515,10 @@ et_ifmedia_upd_locked(struct ifnet *ifp)
|
||||
{
|
||||
struct et_softc *sc = ifp->if_softc;
|
||||
struct mii_data *mii = device_get_softc(sc->sc_miibus);
|
||||
struct mii_softc *miisc;
|
||||
|
||||
if (mii->mii_instance != 0) {
|
||||
struct mii_softc *miisc;
|
||||
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
mii_phy_reset(miisc);
|
||||
}
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
PHY_RESET(miisc);
|
||||
mii_mediachg(mii);
|
||||
|
||||
return (0);
|
||||
|
@ -2555,14 +2555,12 @@ fxp_ifmedia_upd(struct ifnet *ifp)
|
||||
{
|
||||
struct fxp_softc *sc = ifp->if_softc;
|
||||
struct mii_data *mii;
|
||||
struct mii_softc *miisc;
|
||||
|
||||
mii = device_get_softc(sc->miibus);
|
||||
FXP_LOCK(sc);
|
||||
if (mii->mii_instance) {
|
||||
struct mii_softc *miisc;
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
mii_phy_reset(miisc);
|
||||
}
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
PHY_RESET(miisc);
|
||||
mii_mediachg(mii);
|
||||
FXP_UNLOCK(sc);
|
||||
return (0);
|
||||
|
@ -1566,7 +1566,7 @@ hme_mediachange_locked(struct hme_softc *sc)
|
||||
*/
|
||||
if (sc->sc_phys[0] != -1 && sc->sc_phys[1] != -1)
|
||||
LIST_FOREACH(child, &sc->sc_mii->mii_phys, mii_list)
|
||||
mii_phy_reset(child);
|
||||
PHY_RESET(child);
|
||||
return (mii_mediachg(sc->sc_mii));
|
||||
}
|
||||
|
||||
|
@ -318,10 +318,8 @@ jme_mediachange(struct ifnet *ifp)
|
||||
sc = ifp->if_softc;
|
||||
JME_LOCK(sc);
|
||||
mii = device_get_softc(sc->jme_miibus);
|
||||
if (mii->mii_instance != 0) {
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
mii_phy_reset(miisc);
|
||||
}
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
PHY_RESET(miisc);
|
||||
error = mii_mediachg(mii);
|
||||
JME_UNLOCK(sc);
|
||||
|
||||
|
@ -1402,18 +1402,15 @@ lge_ifmedia_upd_locked(ifp)
|
||||
{
|
||||
struct lge_softc *sc;
|
||||
struct mii_data *mii;
|
||||
struct mii_softc *miisc;
|
||||
|
||||
sc = ifp->if_softc;
|
||||
|
||||
LGE_LOCK_ASSERT(sc);
|
||||
mii = device_get_softc(sc->lge_miibus);
|
||||
sc->lge_link = 0;
|
||||
if (mii->mii_instance) {
|
||||
struct mii_softc *miisc;
|
||||
for (miisc = LIST_FIRST(&mii->mii_phys); miisc != NULL;
|
||||
miisc = LIST_NEXT(miisc, mii_list))
|
||||
mii_phy_reset(miisc);
|
||||
}
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
PHY_RESET(miisc);
|
||||
mii_mediachg(mii);
|
||||
}
|
||||
|
||||
|
@ -105,13 +105,19 @@ static void acphy_reset(struct mii_softc *);
|
||||
static void acphy_status(struct mii_softc *);
|
||||
|
||||
static const struct mii_phydesc acphys[] = {
|
||||
MII_PHY_DESC(xxALTIMA, AC101),
|
||||
MII_PHY_DESC(xxALTIMA, AC101L),
|
||||
MII_PHY_DESC(ALTIMA, AC101),
|
||||
MII_PHY_DESC(ALTIMA, AC101L),
|
||||
/* XXX This is reported to work, but it's not from any data sheet. */
|
||||
MII_PHY_DESC(xxALTIMA, ACXXX),
|
||||
MII_PHY_DESC(ALTIMA, ACXXX),
|
||||
MII_PHY_END
|
||||
};
|
||||
|
||||
static const struct mii_phy_funcs acphy_funcs = {
|
||||
acphy_service,
|
||||
acphy_status,
|
||||
acphy_reset
|
||||
};
|
||||
|
||||
static int
|
||||
acphy_probe(device_t dev)
|
||||
{
|
||||
@ -123,27 +129,17 @@ static int
|
||||
acphy_attach(device_t dev)
|
||||
{
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_flags = miibus_get_flags(dev);
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = acphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &acphy_funcs, 0);
|
||||
|
||||
acphy_reset(sc);
|
||||
PHY_RESET(sc);
|
||||
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & sc->mii_capmask;
|
||||
device_printf(dev, " ");
|
||||
|
||||
#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
|
||||
#define ADD(m, c) ifmedia_add(&sc->mii_pdata->mii_media, (m), (c), NULL)
|
||||
if ((PHY_READ(sc, MII_ACPHY_MCTL) & AC_MCTL_FX_SEL) != 0) {
|
||||
sc->mii_flags |= MIIF_HAVEFIBER;
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_FX, 0, sc->mii_inst),
|
||||
@ -200,7 +196,7 @@ acphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
acphy_status(sc);
|
||||
PHY_STATUS(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
mii_phy_update(sc, cmd);
|
||||
@ -245,7 +241,8 @@ acphy_status(struct mii_softc *sc)
|
||||
mii->mii_media_active |= IFM_10_T;
|
||||
|
||||
if (diag & AC_DIAG_DUPLEX)
|
||||
mii->mii_media_active |= IFM_FDX;
|
||||
mii->mii_media_active |=
|
||||
IFM_FDX | mii_phy_flowstatus(sc);
|
||||
else
|
||||
mii->mii_media_active |= IFM_HDX;
|
||||
} else
|
||||
|
@ -83,12 +83,18 @@ static int amphy_service(struct mii_softc *, struct mii_data *, int);
|
||||
static void amphy_status(struct mii_softc *);
|
||||
|
||||
static const struct mii_phydesc amphys[] = {
|
||||
MII_PHY_DESC(DAVICOM, DM9102),
|
||||
MII_PHY_DESC(xxAMD, 79C873),
|
||||
MII_PHY_DESC(xxDAVICOM, DM9102),
|
||||
MII_PHY_DESC(xxDAVICOM, DM9101),
|
||||
MII_PHY_DESC(yyDAVICOM, DM9101),
|
||||
MII_PHY_END
|
||||
};
|
||||
|
||||
static const struct mii_phy_funcs amphy_funcs = {
|
||||
amphy_service,
|
||||
amphy_status,
|
||||
mii_phy_reset
|
||||
};
|
||||
|
||||
static int
|
||||
amphy_probe(device_t dev)
|
||||
{
|
||||
@ -99,37 +105,8 @@ amphy_probe(device_t dev)
|
||||
static int
|
||||
amphy_attach(device_t dev)
|
||||
{
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_flags = miibus_get_flags(dev);
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = amphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
|
||||
|
||||
#if 0
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->mii_inst),
|
||||
MII_MEDIA_100_TX);
|
||||
#endif
|
||||
|
||||
mii_phy_reset(sc);
|
||||
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
device_printf(dev, " ");
|
||||
mii_phy_add_media(sc);
|
||||
printf("\n");
|
||||
#undef ADD
|
||||
MIIBUS_MEDIAINIT(sc->mii_dev);
|
||||
mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &hy_funcs, 1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -158,7 +135,7 @@ amphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
amphy_status(sc);
|
||||
PHY_STATUS(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
mii_phy_update(sc, cmd);
|
||||
@ -231,6 +208,8 @@ amphy_status(struct mii_softc *sc)
|
||||
mii->mii_media_active |= IFM_10_T|IFM_HDX;
|
||||
else if (par & DSCSR_10HDX)
|
||||
mii->mii_media_active |= IFM_10_T|IFM_HDX;
|
||||
if ((mii->mii_media_active & IFM_FDX) != 0)
|
||||
mii->mii_media_active |= mii_phy_flowstatus(sc);
|
||||
} else
|
||||
mii->mii_media_active = ife->ifm_media;
|
||||
}
|
||||
|
@ -53,13 +53,6 @@ __FBSDID("$FreeBSD$");
|
||||
static int atphy_probe(device_t);
|
||||
static int atphy_attach(device_t);
|
||||
|
||||
struct atphy_softc {
|
||||
struct mii_softc mii_sc;
|
||||
int mii_oui;
|
||||
int mii_model;
|
||||
int mii_rev;
|
||||
};
|
||||
|
||||
static device_method_t atphy_methods[] = {
|
||||
/* Device interface. */
|
||||
DEVMETHOD(device_probe, atphy_probe),
|
||||
@ -73,7 +66,7 @@ static devclass_t atphy_devclass;
|
||||
static driver_t atphy_driver = {
|
||||
"atphy",
|
||||
atphy_methods,
|
||||
sizeof(struct atphy_softc)
|
||||
sizeof(struct mii_softc)
|
||||
};
|
||||
|
||||
DRIVER_MODULE(atphy, miibus, atphy_driver, atphy_devclass, 0, 0);
|
||||
@ -85,12 +78,18 @@ static uint16_t atphy_anar(struct ifmedia_entry *);
|
||||
static int atphy_setmedia(struct mii_softc *, int);
|
||||
|
||||
static const struct mii_phydesc atphys[] = {
|
||||
MII_PHY_DESC(ATHEROS, F1),
|
||||
MII_PHY_DESC(ATHEROS, F1_7),
|
||||
MII_PHY_DESC(ATHEROS, F2),
|
||||
MII_PHY_DESC(xxATHEROS, F1),
|
||||
MII_PHY_DESC(xxATHEROS, F1_7),
|
||||
MII_PHY_DESC(xxATHEROS, F2),
|
||||
MII_PHY_END
|
||||
};
|
||||
|
||||
static const struct mii_phy_funcs atphy_funcs = {
|
||||
atphy_service,
|
||||
atphy_status,
|
||||
atphy_reset
|
||||
};
|
||||
|
||||
static int
|
||||
atphy_probe(device_t dev)
|
||||
{
|
||||
@ -101,41 +100,8 @@ atphy_probe(device_t dev)
|
||||
static int
|
||||
atphy_attach(device_t dev)
|
||||
{
|
||||
struct atphy_softc *asc;
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
|
||||
asc = device_get_softc(dev);
|
||||
sc = &asc->mii_sc;
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_flags = miibus_get_flags(dev);
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = atphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
asc->mii_oui = MII_OUI(ma->mii_id1, ma->mii_id2);
|
||||
asc->mii_model = MII_MODEL(ma->mii_id2);
|
||||
asc->mii_rev = MII_REV(ma->mii_id2);
|
||||
if (bootverbose)
|
||||
device_printf(dev, "OUI 0x%06x, model 0x%04x, rev. %d\n",
|
||||
asc->mii_oui, asc->mii_model, asc->mii_rev);
|
||||
|
||||
atphy_reset(sc);
|
||||
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
if (sc->mii_capabilities & BMSR_EXTSTAT)
|
||||
sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR);
|
||||
device_printf(dev, " ");
|
||||
mii_phy_add_media(sc);
|
||||
printf("\n");
|
||||
|
||||
MIIBUS_MEDIAINIT(sc->mii_dev);
|
||||
mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &atphy_funcs, 1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -244,7 +210,7 @@ atphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
atphy_status(sc);
|
||||
PHY_STATUS(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
mii_phy_update(sc, cmd);
|
||||
@ -318,12 +284,9 @@ static void
|
||||
atphy_reset(struct mii_softc *sc)
|
||||
{
|
||||
struct ifmedia_entry *ife = sc->mii_pdata->mii_media.ifm_cur;
|
||||
struct atphy_softc *asc;
|
||||
uint32_t reg;
|
||||
int i;
|
||||
|
||||
asc = (struct atphy_softc *)sc;
|
||||
|
||||
/* Take PHY out of power down mode. */
|
||||
PHY_WRITE(sc, 29, 0x29);
|
||||
PHY_WRITE(sc, 30, 0);
|
||||
|
@ -73,10 +73,16 @@ static int axphy_service(struct mii_softc *, struct mii_data *, int);
|
||||
static void axphy_status(struct mii_softc *);
|
||||
|
||||
static const struct mii_phydesc axphys[] = {
|
||||
MII_PHY_DESC(ASIX, AX88X9X),
|
||||
MII_PHY_DESC(xxASIX, AX88X9X),
|
||||
MII_PHY_END
|
||||
};
|
||||
|
||||
static const struct mii_phy_funcs axphy_funcs = {
|
||||
axphy_service,
|
||||
axphy_status,
|
||||
mii_phy_reset
|
||||
};
|
||||
|
||||
static int
|
||||
axphy_probe(device_t dev)
|
||||
{
|
||||
@ -88,31 +94,11 @@ static int
|
||||
axphy_attach(device_t dev)
|
||||
{
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_flags = miibus_get_flags(dev);
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = axphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
sc->mii_flags |= MIIF_NOISOLATE;
|
||||
|
||||
mii_phy_reset(sc);
|
||||
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
device_printf(dev, " ");
|
||||
mii_phy_add_media(sc);
|
||||
printf("\n");
|
||||
|
||||
MIIBUS_MEDIAINIT(sc->mii_dev);
|
||||
mii_phy_dev_attach(dev, MIIF_NOISOLATE | MIIF_NOMANPAUSE,
|
||||
&axphy_funcs, 1);
|
||||
mii_phy_setmedia(sc);
|
||||
|
||||
return (0);
|
||||
@ -143,7 +129,7 @@ axphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
axphy_status(sc);
|
||||
PHY_STATUS(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
mii_phy_update(sc, cmd);
|
||||
@ -187,7 +173,8 @@ axphy_status(struct mii_softc *sc)
|
||||
else
|
||||
mii->mii_media_active |= IFM_10_T;
|
||||
if (scr & SCR_FDX)
|
||||
mii->mii_media_active |= IFM_FDX;
|
||||
mii->mii_media_active |=
|
||||
IFM_FDX | mii_phy_flowstatus(sc);
|
||||
else
|
||||
mii->mii_media_active |= IFM_HDX;
|
||||
#endif
|
||||
|
@ -85,11 +85,6 @@ __FBSDID("$FreeBSD$");
|
||||
static int bmtphy_probe(device_t);
|
||||
static int bmtphy_attach(device_t);
|
||||
|
||||
struct bmtphy_softc {
|
||||
struct mii_softc mii_sc;
|
||||
int mii_model;
|
||||
};
|
||||
|
||||
static device_method_t bmtphy_methods[] = {
|
||||
/* Device interface */
|
||||
DEVMETHOD(device_probe, bmtphy_probe),
|
||||
@ -105,7 +100,7 @@ static devclass_t bmtphy_devclass;
|
||||
static driver_t bmtphy_driver = {
|
||||
"bmtphy",
|
||||
bmtphy_methods,
|
||||
sizeof(struct bmtphy_softc)
|
||||
sizeof(struct mii_softc)
|
||||
};
|
||||
|
||||
DRIVER_MODULE(bmtphy, miibus, bmtphy_driver, bmtphy_devclass, 0, 0);
|
||||
@ -115,20 +110,26 @@ static void bmtphy_status(struct mii_softc *);
|
||||
static void bmtphy_reset(struct mii_softc *);
|
||||
|
||||
static const struct mii_phydesc bmtphys_dp[] = {
|
||||
MII_PHY_DESC(BROADCOM, BCM4401),
|
||||
MII_PHY_DESC(BROADCOM, BCM5201),
|
||||
MII_PHY_DESC(BROADCOM, BCM5214),
|
||||
MII_PHY_DESC(BROADCOM, BCM5221),
|
||||
MII_PHY_DESC(BROADCOM, BCM5222),
|
||||
MII_PHY_DESC(xxBROADCOM, BCM4401),
|
||||
MII_PHY_DESC(xxBROADCOM, BCM5201),
|
||||
MII_PHY_DESC(xxBROADCOM, BCM5214),
|
||||
MII_PHY_DESC(xxBROADCOM, BCM5221),
|
||||
MII_PHY_DESC(xxBROADCOM, BCM5222),
|
||||
MII_PHY_END
|
||||
};
|
||||
|
||||
static const struct mii_phydesc bmtphys_lp[] = {
|
||||
MII_PHY_DESC(BROADCOM, 3C905B),
|
||||
MII_PHY_DESC(BROADCOM, 3C905C),
|
||||
MII_PHY_DESC(xxBROADCOM, 3C905B),
|
||||
MII_PHY_DESC(xxBROADCOM, 3C905C),
|
||||
MII_PHY_END
|
||||
};
|
||||
|
||||
static const struct mii_phy_funcs bmtphy_funcs = {
|
||||
bmtphy_service,
|
||||
bmtphy_status,
|
||||
bmtphy_reset
|
||||
};
|
||||
|
||||
static int
|
||||
bmtphy_probe(device_t dev)
|
||||
{
|
||||
@ -145,37 +146,8 @@ bmtphy_probe(device_t dev)
|
||||
static int
|
||||
bmtphy_attach(device_t dev)
|
||||
{
|
||||
struct bmtphy_softc *bsc;
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
|
||||
bsc = device_get_softc(dev);
|
||||
sc = &bsc->mii_sc;
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_flags = miibus_get_flags(dev);
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = bmtphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
sc->mii_flags |= MIIF_NOMANPAUSE;
|
||||
|
||||
bsc->mii_model = MII_MODEL(ma->mii_id2);
|
||||
|
||||
bmtphy_reset(sc);
|
||||
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
device_printf(dev, " ");
|
||||
mii_phy_add_media(sc);
|
||||
printf("\n");
|
||||
|
||||
MIIBUS_MEDIAINIT(sc->mii_dev);
|
||||
|
||||
mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &bmtphy_funcs, 1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -204,7 +176,7 @@ bmtphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
bmtphy_status(sc);
|
||||
PHY_STATUS(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
mii_phy_update(sc, cmd);
|
||||
@ -267,14 +239,11 @@ bmtphy_status(struct mii_softc *sc)
|
||||
static void
|
||||
bmtphy_reset(struct mii_softc *sc)
|
||||
{
|
||||
struct bmtphy_softc *bsc;
|
||||
u_int16_t data;
|
||||
|
||||
bsc = (struct bmtphy_softc *)sc;
|
||||
|
||||
mii_phy_reset(sc);
|
||||
|
||||
if (bsc->mii_model == MII_MODEL_BROADCOM_BCM5221) {
|
||||
if (sc->mii_mpd_model == MII_MODEL_xxBROADCOM_BCM5221) {
|
||||
/* Enable shadow register mode. */
|
||||
data = PHY_READ(sc, 0x1f);
|
||||
PHY_WRITE(sc, 0x1f, data | 0x0080);
|
||||
|
@ -68,9 +68,6 @@ static int brgphy_attach(device_t);
|
||||
|
||||
struct brgphy_softc {
|
||||
struct mii_softc mii_sc;
|
||||
int mii_oui;
|
||||
int mii_model;
|
||||
int mii_rev;
|
||||
int serdes_flags; /* Keeps track of the serdes type used */
|
||||
#define BRGPHY_5706S 0x0001
|
||||
#define BRGPHY_5708S 0x0002
|
||||
@ -117,37 +114,43 @@ static void brgphy_ethernet_wirespeed(struct mii_softc *);
|
||||
static void brgphy_jumbo_settings(struct mii_softc *, u_long);
|
||||
|
||||
static const struct mii_phydesc brgphys[] = {
|
||||
MII_PHY_DESC(xxBROADCOM, BCM5400),
|
||||
MII_PHY_DESC(xxBROADCOM, BCM5401),
|
||||
MII_PHY_DESC(xxBROADCOM, BCM5411),
|
||||
MII_PHY_DESC(xxBROADCOM, BCM54K2),
|
||||
MII_PHY_DESC(xxBROADCOM, BCM5701),
|
||||
MII_PHY_DESC(xxBROADCOM, BCM5703),
|
||||
MII_PHY_DESC(xxBROADCOM, BCM5704),
|
||||
MII_PHY_DESC(xxBROADCOM, BCM5705),
|
||||
MII_PHY_DESC(xxBROADCOM, BCM5706),
|
||||
MII_PHY_DESC(xxBROADCOM, BCM5714),
|
||||
MII_PHY_DESC(xxBROADCOM, BCM5750),
|
||||
MII_PHY_DESC(xxBROADCOM, BCM5752),
|
||||
MII_PHY_DESC(xxBROADCOM, BCM5754),
|
||||
MII_PHY_DESC(xxBROADCOM, BCM5780),
|
||||
MII_PHY_DESC(xxBROADCOM, BCM5708C),
|
||||
MII_PHY_DESC(xxBROADCOM_ALT1, BCM5482S),
|
||||
MII_PHY_DESC(xxBROADCOM_ALT1, BCM5755),
|
||||
MII_PHY_DESC(xxBROADCOM_ALT1, BCM5787),
|
||||
MII_PHY_DESC(xxBROADCOM_ALT1, BCM5708S),
|
||||
MII_PHY_DESC(xxBROADCOM_ALT1, BCM5709CAX),
|
||||
MII_PHY_DESC(xxBROADCOM_ALT1, BCM5722),
|
||||
MII_PHY_DESC(xxBROADCOM_ALT1, BCM5784),
|
||||
MII_PHY_DESC(xxBROADCOM_ALT1, BCM5709C),
|
||||
MII_PHY_DESC(xxBROADCOM_ALT1, BCM5761),
|
||||
MII_PHY_DESC(xxBROADCOM_ALT1, BCM5709S),
|
||||
MII_PHY_DESC(xxBROADCOM_ALT2, BCM5717C),
|
||||
MII_PHY_DESC(xxBROADCOM_ALT2, BCM57765),
|
||||
MII_PHY_DESC(BROADCOM2, BCM5906),
|
||||
MII_PHY_DESC(BROADCOM, BCM5400),
|
||||
MII_PHY_DESC(BROADCOM, BCM5401),
|
||||
MII_PHY_DESC(BROADCOM, BCM5411),
|
||||
MII_PHY_DESC(BROADCOM, BCM54K2),
|
||||
MII_PHY_DESC(BROADCOM, BCM5701),
|
||||
MII_PHY_DESC(BROADCOM, BCM5703),
|
||||
MII_PHY_DESC(BROADCOM, BCM5704),
|
||||
MII_PHY_DESC(BROADCOM, BCM5705),
|
||||
MII_PHY_DESC(BROADCOM, BCM5706),
|
||||
MII_PHY_DESC(BROADCOM, BCM5714),
|
||||
MII_PHY_DESC(BROADCOM, BCM5421),
|
||||
MII_PHY_DESC(BROADCOM, BCM5750),
|
||||
MII_PHY_DESC(BROADCOM, BCM5752),
|
||||
MII_PHY_DESC(BROADCOM, BCM5780),
|
||||
MII_PHY_DESC(BROADCOM, BCM5708C),
|
||||
MII_PHY_DESC(BROADCOM2, BCM5482),
|
||||
MII_PHY_DESC(BROADCOM2, BCM5708S),
|
||||
MII_PHY_DESC(BROADCOM2, BCM5709C),
|
||||
MII_PHY_DESC(BROADCOM2, BCM5709S),
|
||||
MII_PHY_DESC(BROADCOM2, BCM5709CAX),
|
||||
MII_PHY_DESC(BROADCOM2, BCM5722),
|
||||
MII_PHY_DESC(BROADCOM2, BCM5755),
|
||||
MII_PHY_DESC(BROADCOM2, BCM5754),
|
||||
MII_PHY_DESC(BROADCOM2, BCM5761),
|
||||
MII_PHY_DESC(BROADCOM2, BCM5784),
|
||||
MII_PHY_DESC(BROADCOM3, BCM5717C),
|
||||
MII_PHY_DESC(BROADCOM3, BCM57765),
|
||||
MII_PHY_DESC(xxBROADCOM_ALT1, BCM5906),
|
||||
MII_PHY_END
|
||||
};
|
||||
|
||||
static const struct mii_phy_funcs brgphy_funcs = {
|
||||
brgphy_service,
|
||||
brgphy_status,
|
||||
brgphy_reset
|
||||
};
|
||||
|
||||
#define HS21_PRODUCT_ID "IBM eServer BladeCenter HS21"
|
||||
#define HS21_BCM_CHIPID 0x57081021
|
||||
|
||||
@ -186,49 +189,22 @@ brgphy_attach(device_t dev)
|
||||
struct bge_softc *bge_sc = NULL;
|
||||
struct bce_softc *bce_sc = NULL;
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
struct ifnet *ifp;
|
||||
|
||||
bsc = device_get_softc(dev);
|
||||
sc = &bsc->mii_sc;
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
/* Initialize mii_softc structure */
|
||||
sc->mii_flags = miibus_get_flags(dev);
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = brgphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
mii_phy_dev_attach(dev, MIIF_NOISOLATE | MIIF_NOMANPAUSE,
|
||||
&brgphy_funcs, 0);
|
||||
|
||||
/*
|
||||
* At least some variants wedge when isolating, at least some also
|
||||
* don't support loopback.
|
||||
*/
|
||||
sc->mii_flags |= MIIF_NOISOLATE | MIIF_NOLOOP | MIIF_NOMANPAUSE;
|
||||
|
||||
/* Initialize brgphy_softc structure */
|
||||
bsc->mii_oui = MII_OUI(ma->mii_id1, ma->mii_id2);
|
||||
bsc->mii_model = MII_MODEL(ma->mii_id2);
|
||||
bsc->mii_rev = MII_REV(ma->mii_id2);
|
||||
bsc->serdes_flags = 0;
|
||||
|
||||
if (bootverbose)
|
||||
device_printf(dev, "OUI 0x%06x, model 0x%04x, rev. %d\n",
|
||||
bsc->mii_oui, bsc->mii_model, bsc->mii_rev);
|
||||
|
||||
/* Handle any special cases based on the PHY ID */
|
||||
switch (bsc->mii_oui) {
|
||||
switch (sc->mii_mpd_oui) {
|
||||
case MII_OUI_BROADCOM:
|
||||
case MII_OUI_BROADCOM2:
|
||||
break;
|
||||
case MII_OUI_xxBROADCOM:
|
||||
switch (bsc->mii_model) {
|
||||
case MII_MODEL_xxBROADCOM_BCM5706:
|
||||
case MII_MODEL_xxBROADCOM_BCM5714:
|
||||
switch (sc->mii_mpd_model) {
|
||||
case MII_MODEL_BROADCOM_BCM5706:
|
||||
case MII_MODEL_BROADCOM_BCM5714:
|
||||
/*
|
||||
* The 5464 PHY used in the 5706 supports both copper
|
||||
* and fiber interfaces over GMII. Need to check the
|
||||
@ -245,23 +221,18 @@ brgphy_attach(device_t dev)
|
||||
}
|
||||
break;
|
||||
} break;
|
||||
case MII_OUI_xxBROADCOM_ALT1:
|
||||
switch (bsc->mii_model) {
|
||||
case MII_MODEL_xxBROADCOM_ALT1_BCM5708S:
|
||||
case MII_OUI_BROADCOM2:
|
||||
switch (sc->mii_mpd_model) {
|
||||
case MII_MODEL_BROADCOM2_BCM5708S:
|
||||
bsc->serdes_flags |= BRGPHY_5708S;
|
||||
sc->mii_flags |= MIIF_HAVEFIBER;
|
||||
break;
|
||||
case MII_MODEL_xxBROADCOM_ALT1_BCM5709S:
|
||||
case MII_MODEL_BROADCOM2_BCM5709S:
|
||||
bsc->serdes_flags |= BRGPHY_5709S;
|
||||
sc->mii_flags |= MIIF_HAVEFIBER;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case MII_OUI_xxBROADCOM_ALT2:
|
||||
/* No special handling yet. */
|
||||
break;
|
||||
default:
|
||||
device_printf(dev, "Unrecognized OUI for PHY!\n");
|
||||
}
|
||||
|
||||
ifp = sc->mii_pdata->mii_ifp;
|
||||
@ -273,15 +244,15 @@ brgphy_attach(device_t dev)
|
||||
bce_sc = ifp->if_softc;
|
||||
}
|
||||
|
||||
brgphy_reset(sc);
|
||||
PHY_RESET(sc);
|
||||
|
||||
/* Read the PHY's capabilities. */
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & sc->mii_capmask;
|
||||
if (sc->mii_capabilities & BMSR_EXTSTAT)
|
||||
sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR);
|
||||
device_printf(dev, " ");
|
||||
|
||||
#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
|
||||
#define ADD(m, c) ifmedia_add(&sc->mii_pdata->mii_media, (m), (c), NULL)
|
||||
|
||||
/* Add the supported media types */
|
||||
if ((sc->mii_flags & MIIF_HAVEFIBER) == 0) {
|
||||
@ -322,7 +293,6 @@ brgphy_attach(device_t dev)
|
||||
static int
|
||||
brgphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
{
|
||||
struct brgphy_softc *bsc = (struct brgphy_softc *)sc;
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
int val;
|
||||
|
||||
@ -335,7 +305,7 @@ brgphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
break;
|
||||
|
||||
/* Todo: Why is this here? Is it really needed? */
|
||||
brgphy_reset(sc); /* XXX hardware bug work-around */
|
||||
PHY_RESET(sc); /* XXX hardware bug work-around */
|
||||
|
||||
switch (IFM_SUBTYPE(ife->ifm_media)) {
|
||||
case IFM_AUTO:
|
||||
@ -390,7 +360,7 @@ brgphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
brgphy_status(sc);
|
||||
PHY_STATUS(sc);
|
||||
|
||||
/*
|
||||
* Callback if something changed. Note that we need to poke
|
||||
@ -399,28 +369,24 @@ brgphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
if (sc->mii_media_active != mii->mii_media_active ||
|
||||
sc->mii_media_status != mii->mii_media_status ||
|
||||
cmd == MII_MEDIACHG) {
|
||||
switch (bsc->mii_oui) {
|
||||
switch (sc->mii_mpd_oui) {
|
||||
case MII_OUI_BROADCOM:
|
||||
break;
|
||||
case MII_OUI_xxBROADCOM:
|
||||
switch (bsc->mii_model) {
|
||||
case MII_MODEL_xxBROADCOM_BCM5400:
|
||||
switch (sc->mii_mpd_model) {
|
||||
case MII_MODEL_BROADCOM_BCM5400:
|
||||
bcm5401_load_dspcode(sc);
|
||||
break;
|
||||
case MII_MODEL_xxBROADCOM_BCM5401:
|
||||
if (bsc->mii_rev == 1 || bsc->mii_rev == 3)
|
||||
case MII_MODEL_BROADCOM_BCM5401:
|
||||
if (sc->mii_mpd_rev == 1 || sc->mii_mpd_rev == 3)
|
||||
bcm5401_load_dspcode(sc);
|
||||
break;
|
||||
case MII_MODEL_xxBROADCOM_BCM5411:
|
||||
case MII_MODEL_BROADCOM_BCM5411:
|
||||
bcm5411_load_dspcode(sc);
|
||||
break;
|
||||
case MII_MODEL_xxBROADCOM_BCM54K2:
|
||||
case MII_MODEL_BROADCOM_BCM54K2:
|
||||
bcm54k2_load_dspcode(sc);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case MII_OUI_xxBROADCOM_ALT1:
|
||||
break;
|
||||
}
|
||||
}
|
||||
mii_phy_update(sc, cmd);
|
||||
@ -625,10 +591,9 @@ brgphy_status(struct mii_softc *sc)
|
||||
static void
|
||||
brgphy_mii_phy_auto(struct mii_softc *sc, int media)
|
||||
{
|
||||
struct brgphy_softc *bsc = (struct brgphy_softc *)sc;
|
||||
int anar, ktcr = 0;
|
||||
|
||||
brgphy_reset(sc);
|
||||
PHY_RESET(sc);
|
||||
|
||||
if ((sc->mii_flags & MIIF_HAVEFIBER) == 0) {
|
||||
anar = BMSR_MEDIA_TO_ANAR(sc->mii_capabilities) | ANAR_CSMA;
|
||||
@ -645,7 +610,7 @@ brgphy_mii_phy_auto(struct mii_softc *sc, int media)
|
||||
}
|
||||
|
||||
ktcr = BRGPHY_1000CTL_AFD | BRGPHY_1000CTL_AHD;
|
||||
if (bsc->mii_model == MII_MODEL_xxBROADCOM_BCM5701)
|
||||
if (sc->mii_mpd_model == MII_MODEL_BROADCOM_BCM5701)
|
||||
ktcr |= BRGPHY_1000CTL_MSE | BRGPHY_1000CTL_MSC;
|
||||
PHY_WRITE(sc, BRGPHY_MII_1000CTL, ktcr);
|
||||
ktcr = PHY_READ(sc, BRGPHY_MII_1000CTL);
|
||||
@ -875,12 +840,11 @@ brgphy_ethernet_wirespeed(struct mii_softc *sc)
|
||||
static void
|
||||
brgphy_jumbo_settings(struct mii_softc *sc, u_long mtu)
|
||||
{
|
||||
struct brgphy_softc *bsc = (struct brgphy_softc *)sc;
|
||||
uint32_t val;
|
||||
|
||||
/* Set or clear jumbo frame settings in the PHY. */
|
||||
if (mtu > ETHER_MAX_LEN) {
|
||||
if (bsc->mii_model == MII_MODEL_xxBROADCOM_BCM5401) {
|
||||
if (sc->mii_mpd_model == MII_MODEL_BROADCOM_BCM5401) {
|
||||
/* BCM5401 PHY cannot read-modify-write. */
|
||||
PHY_WRITE(sc, BRGPHY_MII_AUXCTL, 0x4c20);
|
||||
} else {
|
||||
@ -908,7 +872,6 @@ brgphy_jumbo_settings(struct mii_softc *sc, u_long mtu)
|
||||
static void
|
||||
brgphy_reset(struct mii_softc *sc)
|
||||
{
|
||||
struct brgphy_softc *bsc = (struct brgphy_softc *)sc;
|
||||
struct bge_softc *bge_sc = NULL;
|
||||
struct bce_softc *bce_sc = NULL;
|
||||
struct ifnet *ifp;
|
||||
@ -918,29 +881,24 @@ brgphy_reset(struct mii_softc *sc)
|
||||
mii_phy_reset(sc);
|
||||
|
||||
/* Handle any PHY specific procedures following the reset. */
|
||||
switch (bsc->mii_oui) {
|
||||
switch (sc->mii_mpd_oui) {
|
||||
case MII_OUI_BROADCOM:
|
||||
break;
|
||||
case MII_OUI_xxBROADCOM:
|
||||
switch (bsc->mii_model) {
|
||||
case MII_MODEL_xxBROADCOM_BCM5400:
|
||||
switch (sc->mii_mpd_model) {
|
||||
case MII_MODEL_BROADCOM_BCM5400:
|
||||
bcm5401_load_dspcode(sc);
|
||||
break;
|
||||
case MII_MODEL_xxBROADCOM_BCM5401:
|
||||
if (bsc->mii_rev == 1 || bsc->mii_rev == 3)
|
||||
case MII_MODEL_BROADCOM_BCM5401:
|
||||
if (sc->mii_mpd_rev == 1 || sc->mii_mpd_rev == 3)
|
||||
bcm5401_load_dspcode(sc);
|
||||
break;
|
||||
case MII_MODEL_xxBROADCOM_BCM5411:
|
||||
case MII_MODEL_BROADCOM_BCM5411:
|
||||
bcm5411_load_dspcode(sc);
|
||||
break;
|
||||
case MII_MODEL_xxBROADCOM_BCM54K2:
|
||||
case MII_MODEL_BROADCOM_BCM54K2:
|
||||
bcm54k2_load_dspcode(sc);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case MII_OUI_xxBROADCOM_ALT1:
|
||||
case MII_OUI_xxBROADCOM_ALT2:
|
||||
break;
|
||||
}
|
||||
|
||||
ifp = sc->mii_pdata->mii_ifp;
|
||||
|
@ -86,16 +86,22 @@ static void ciphy_reset(struct mii_softc *);
|
||||
static void ciphy_fixup(struct mii_softc *);
|
||||
|
||||
static const struct mii_phydesc ciphys[] = {
|
||||
MII_PHY_DESC(CICADA, CS8201),
|
||||
MII_PHY_DESC(CICADA, CS8201A),
|
||||
MII_PHY_DESC(CICADA, CS8201B),
|
||||
MII_PHY_DESC(CICADA, CS8204),
|
||||
MII_PHY_DESC(CICADA, VSC8211),
|
||||
MII_PHY_DESC(CICADA, CS8244),
|
||||
MII_PHY_DESC(VITESSE, VSC8601),
|
||||
MII_PHY_DESC(xxCICADA, CS8201),
|
||||
MII_PHY_DESC(xxCICADA, CS8201A),
|
||||
MII_PHY_DESC(xxCICADA, CS8201B),
|
||||
MII_PHY_DESC(xxCICADA, CS8204),
|
||||
MII_PHY_DESC(xxCICADA, VSC8211),
|
||||
MII_PHY_DESC(xxCICADA, CS8244),
|
||||
MII_PHY_DESC(xxVITESSE, VSC8601),
|
||||
MII_PHY_END
|
||||
};
|
||||
|
||||
static const struct mii_phy_funcs ciphy_funcs = {
|
||||
ciphy_service,
|
||||
ciphy_status,
|
||||
ciphy_reset
|
||||
};
|
||||
|
||||
static int
|
||||
ciphy_probe(device_t dev)
|
||||
{
|
||||
@ -106,34 +112,9 @@ ciphy_probe(device_t dev)
|
||||
static int
|
||||
ciphy_attach(device_t dev)
|
||||
{
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_flags = miibus_get_flags(dev);
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = ciphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
sc->mii_flags |= MIIF_NOISOLATE;
|
||||
|
||||
ciphy_reset(sc);
|
||||
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
if (sc->mii_capabilities & BMSR_EXTSTAT)
|
||||
sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR);
|
||||
device_printf(dev, " ");
|
||||
mii_phy_add_media(sc);
|
||||
printf("\n");
|
||||
|
||||
MIIBUS_MEDIAINIT(sc->mii_dev);
|
||||
mii_phy_dev_attach(dev, MIIF_NOISOLATE | MIIF_NOMANPAUSE,
|
||||
&ciphy_funcs, 1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -239,7 +220,7 @@ ciphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
ciphy_status(sc);
|
||||
PHY_STATUS(sc);
|
||||
|
||||
/*
|
||||
* Callback if something changed. Note that we need to poke
|
||||
@ -299,7 +280,7 @@ ciphy_status(struct mii_softc *sc)
|
||||
}
|
||||
|
||||
if (bmsr & CIPHY_AUXCSR_FDX)
|
||||
mii->mii_media_active |= IFM_FDX;
|
||||
mii->mii_media_active |= IFM_FDX | mii_phy_flowstatus(sc);
|
||||
else
|
||||
mii->mii_media_active |= IFM_HDX;
|
||||
|
||||
@ -349,8 +330,8 @@ ciphy_fixup(struct mii_softc *sc)
|
||||
}
|
||||
|
||||
switch (model) {
|
||||
case MII_MODEL_CICADA_CS8204:
|
||||
case MII_MODEL_CICADA_CS8201:
|
||||
case MII_MODEL_xxCICADA_CS8204:
|
||||
case MII_MODEL_xxCICADA_CS8201:
|
||||
|
||||
/* Turn off "aux mode" (whatever that means) */
|
||||
PHY_SETBIT(sc, CIPHY_MII_AUXCSR, CIPHY_AUXCSR_MDPPS);
|
||||
@ -371,8 +352,8 @@ ciphy_fixup(struct mii_softc *sc)
|
||||
|
||||
break;
|
||||
|
||||
case MII_MODEL_CICADA_CS8201A:
|
||||
case MII_MODEL_CICADA_CS8201B:
|
||||
case MII_MODEL_xxCICADA_CS8201A:
|
||||
case MII_MODEL_xxCICADA_CS8201B:
|
||||
|
||||
/*
|
||||
* Work around speed polling bug in VT3119/VT3216
|
||||
@ -386,9 +367,9 @@ ciphy_fixup(struct mii_softc *sc)
|
||||
}
|
||||
|
||||
break;
|
||||
case MII_MODEL_CICADA_VSC8211:
|
||||
case MII_MODEL_CICADA_CS8244:
|
||||
case MII_MODEL_VITESSE_VSC8601:
|
||||
case MII_MODEL_xxCICADA_VSC8211:
|
||||
case MII_MODEL_xxCICADA_CS8244:
|
||||
case MII_MODEL_xxVITESSE_VSC8601:
|
||||
break;
|
||||
default:
|
||||
device_printf(sc->mii_dev, "unknown CICADA PHY model %x\n",
|
||||
|
@ -65,11 +65,6 @@ __FBSDID("$FreeBSD$");
|
||||
static int e1000phy_probe(device_t);
|
||||
static int e1000phy_attach(device_t);
|
||||
|
||||
struct e1000phy_softc {
|
||||
struct mii_softc mii_sc;
|
||||
int mii_model;
|
||||
};
|
||||
|
||||
static device_method_t e1000phy_methods[] = {
|
||||
/* device interface */
|
||||
DEVMETHOD(device_probe, e1000phy_probe),
|
||||
@ -83,7 +78,7 @@ static devclass_t e1000phy_devclass;
|
||||
static driver_t e1000phy_driver = {
|
||||
"e1000phy",
|
||||
e1000phy_methods,
|
||||
sizeof(struct e1000phy_softc)
|
||||
sizeof(struct mii_softc)
|
||||
};
|
||||
|
||||
DRIVER_MODULE(e1000phy, miibus, e1000phy_driver, e1000phy_devclass, 0, 0);
|
||||
@ -91,32 +86,38 @@ DRIVER_MODULE(e1000phy, miibus, e1000phy_driver, e1000phy_devclass, 0, 0);
|
||||
static int e1000phy_service(struct mii_softc *, struct mii_data *, int);
|
||||
static void e1000phy_status(struct mii_softc *);
|
||||
static void e1000phy_reset(struct mii_softc *);
|
||||
static int e1000phy_mii_phy_auto(struct e1000phy_softc *, int);
|
||||
static int e1000phy_mii_phy_auto(struct mii_softc *, int);
|
||||
|
||||
static const struct mii_phydesc e1000phys[] = {
|
||||
MII_PHY_DESC(MARVELL, E1000),
|
||||
MII_PHY_DESC(MARVELL, E1011),
|
||||
MII_PHY_DESC(MARVELL, E1000_3),
|
||||
MII_PHY_DESC(MARVELL, E1000S),
|
||||
MII_PHY_DESC(MARVELL, E1000_5),
|
||||
MII_PHY_DESC(MARVELL, E1101),
|
||||
MII_PHY_DESC(MARVELL, E3082),
|
||||
MII_PHY_DESC(MARVELL, E1112),
|
||||
MII_PHY_DESC(MARVELL, E1149),
|
||||
MII_PHY_DESC(MARVELL, E1111),
|
||||
MII_PHY_DESC(MARVELL, E1116),
|
||||
MII_PHY_DESC(MARVELL, E1116R),
|
||||
MII_PHY_DESC(MARVELL, E1118),
|
||||
MII_PHY_DESC(MARVELL, E3016),
|
||||
MII_PHY_DESC(MARVELL, PHYG65G),
|
||||
MII_PHY_DESC(xxMARVELL, E1000),
|
||||
MII_PHY_DESC(xxMARVELL, E1011),
|
||||
MII_PHY_DESC(xxMARVELL, E1000_3),
|
||||
MII_PHY_DESC(xxMARVELL, E1000S),
|
||||
MII_PHY_DESC(xxMARVELL, E1000_5),
|
||||
MII_PHY_DESC(xxMARVELL, E1101),
|
||||
MII_PHY_DESC(xxMARVELL, E3082),
|
||||
MII_PHY_DESC(xxMARVELL, E1112),
|
||||
MII_PHY_DESC(xxMARVELL, E1149),
|
||||
MII_PHY_DESC(xxMARVELL, E1111),
|
||||
MII_PHY_DESC(xxMARVELL, E1116),
|
||||
MII_PHY_DESC(xxMARVELL, E1116R),
|
||||
MII_PHY_DESC(xxMARVELL, E1118),
|
||||
MII_PHY_DESC(xxMARVELL, E3016),
|
||||
MII_PHY_DESC(xxMARVELL, PHYG65G),
|
||||
MII_PHY_END
|
||||
};
|
||||
|
||||
static const struct mii_phy_funcs e1000phy_funcs = {
|
||||
e1000phy_service,
|
||||
e1000phy_status,
|
||||
e1000phy_reset
|
||||
};
|
||||
|
||||
static int
|
||||
e1000phy_probe(device_t dev)
|
||||
{
|
||||
@ -127,40 +128,25 @@ e1000phy_probe(device_t dev)
|
||||
static int
|
||||
e1000phy_attach(device_t dev)
|
||||
{
|
||||
struct e1000phy_softc *esc;
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
struct ifnet *ifp;
|
||||
|
||||
esc = device_get_softc(dev);
|
||||
sc = &esc->mii_sc;
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
sc = device_get_softc(dev);
|
||||
|
||||
sc->mii_flags = miibus_get_flags(dev);
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = e1000phy_service;
|
||||
sc->mii_pdata = mii;
|
||||
mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &e1000phy_funcs, 0);
|
||||
|
||||
sc->mii_flags |= MIIF_NOMANPAUSE;
|
||||
|
||||
esc->mii_model = MII_MODEL(ma->mii_id2);
|
||||
ifp = sc->mii_pdata->mii_ifp;
|
||||
if (strcmp(ifp->if_dname, "msk") == 0 &&
|
||||
(sc->mii_flags & MIIF_MACPRIV0) != 0)
|
||||
sc->mii_flags |= MIIF_PHYPRIV0;
|
||||
|
||||
switch (esc->mii_model) {
|
||||
case MII_MODEL_MARVELL_E1011:
|
||||
case MII_MODEL_MARVELL_E1112:
|
||||
switch (sc->mii_mpd_model) {
|
||||
case MII_MODEL_xxMARVELL_E1011:
|
||||
case MII_MODEL_xxMARVELL_E1112:
|
||||
if (PHY_READ(sc, E1000_ESSR) & E1000_ESSR_FIBER_LINK)
|
||||
sc->mii_flags |= MIIF_HAVEFIBER;
|
||||
break;
|
||||
case MII_MODEL_MARVELL_E1149:
|
||||
case MII_MODEL_xxMARVELL_E1149:
|
||||
/*
|
||||
* Some 88E1149 PHY's page select is initialized to
|
||||
* point to other bank instead of copper/fiber bank
|
||||
@ -176,9 +162,9 @@ e1000phy_attach(device_t dev)
|
||||
break;
|
||||
}
|
||||
|
||||
e1000phy_reset(sc);
|
||||
PHY_RESET(sc);
|
||||
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & sc->mii_capmask;
|
||||
if (sc->mii_capabilities & BMSR_EXTSTAT)
|
||||
sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR);
|
||||
device_printf(dev, " ");
|
||||
@ -192,15 +178,13 @@ e1000phy_attach(device_t dev)
|
||||
static void
|
||||
e1000phy_reset(struct mii_softc *sc)
|
||||
{
|
||||
struct e1000phy_softc *esc;
|
||||
uint16_t reg, page;
|
||||
|
||||
esc = (struct e1000phy_softc *)sc;
|
||||
reg = PHY_READ(sc, E1000_SCR);
|
||||
if ((sc->mii_flags & MIIF_HAVEFIBER) != 0) {
|
||||
reg &= ~E1000_SCR_AUTO_X_MODE;
|
||||
PHY_WRITE(sc, E1000_SCR, reg);
|
||||
if (esc->mii_model == MII_MODEL_MARVELL_E1112) {
|
||||
if (sc->mii_mpd_model == MII_MODEL_xxMARVELL_E1112) {
|
||||
/* Select 1000BASE-X only mode. */
|
||||
page = PHY_READ(sc, E1000_EADR);
|
||||
PHY_WRITE(sc, E1000_EADR, 2);
|
||||
@ -218,25 +202,25 @@ e1000phy_reset(struct mii_softc *sc)
|
||||
PHY_WRITE(sc, E1000_EADR, page);
|
||||
}
|
||||
} else {
|
||||
switch (esc->mii_model) {
|
||||
case MII_MODEL_MARVELL_E1111:
|
||||
case MII_MODEL_MARVELL_E1112:
|
||||
case MII_MODEL_MARVELL_E1116:
|
||||
case MII_MODEL_MARVELL_E1118:
|
||||
case MII_MODEL_MARVELL_E1149:
|
||||
case MII_MODEL_MARVELL_PHYG65G:
|
||||
switch (sc->mii_mpd_model) {
|
||||
case MII_MODEL_xxMARVELL_E1111:
|
||||
case MII_MODEL_xxMARVELL_E1112:
|
||||
case MII_MODEL_xxMARVELL_E1116:
|
||||
case MII_MODEL_xxMARVELL_E1118:
|
||||
case MII_MODEL_xxMARVELL_E1149:
|
||||
case MII_MODEL_xxMARVELL_PHYG65G:
|
||||
/* Disable energy detect mode. */
|
||||
reg &= ~E1000_SCR_EN_DETECT_MASK;
|
||||
reg |= E1000_SCR_AUTO_X_MODE;
|
||||
if (esc->mii_model == MII_MODEL_MARVELL_E1116)
|
||||
if (sc->mii_mpd_model == MII_MODEL_xxMARVELL_E1116)
|
||||
reg &= ~E1000_SCR_POWER_DOWN;
|
||||
reg |= E1000_SCR_ASSERT_CRS_ON_TX;
|
||||
break;
|
||||
case MII_MODEL_MARVELL_E3082:
|
||||
case MII_MODEL_xxMARVELL_E3082:
|
||||
reg |= (E1000_SCR_AUTO_X_MODE >> 1);
|
||||
reg |= E1000_SCR_ASSERT_CRS_ON_TX;
|
||||
break;
|
||||
case MII_MODEL_MARVELL_E3016:
|
||||
case MII_MODEL_xxMARVELL_E3016:
|
||||
reg |= E1000_SCR_AUTO_MDIX;
|
||||
reg &= ~(E1000_SCR_EN_DETECT |
|
||||
E1000_SCR_SCRAMBLER_DISABLE);
|
||||
@ -249,14 +233,14 @@ e1000phy_reset(struct mii_softc *sc)
|
||||
reg |= E1000_SCR_ASSERT_CRS_ON_TX;
|
||||
break;
|
||||
}
|
||||
if (esc->mii_model != MII_MODEL_MARVELL_E3016) {
|
||||
if (sc->mii_mpd_model != MII_MODEL_xxMARVELL_E3016) {
|
||||
/* Auto correction for reversed cable polarity. */
|
||||
reg &= ~E1000_SCR_POLARITY_REVERSAL;
|
||||
}
|
||||
PHY_WRITE(sc, E1000_SCR, reg);
|
||||
|
||||
if (esc->mii_model == MII_MODEL_MARVELL_E1116 ||
|
||||
esc->mii_model == MII_MODEL_MARVELL_E1149) {
|
||||
if (sc->mii_mpd_model == MII_MODEL_xxMARVELL_E1116 ||
|
||||
sc->mii_mpd_model == MII_MODEL_xxMARVELL_E1149) {
|
||||
PHY_WRITE(sc, E1000_EADR, 2);
|
||||
reg = PHY_READ(sc, E1000_SCR);
|
||||
reg |= E1000_SCR_RGMII_POWER_UP;
|
||||
@ -265,12 +249,12 @@ e1000phy_reset(struct mii_softc *sc)
|
||||
}
|
||||
}
|
||||
|
||||
switch (esc->mii_model) {
|
||||
case MII_MODEL_MARVELL_E3082:
|
||||
case MII_MODEL_MARVELL_E1112:
|
||||
case MII_MODEL_MARVELL_E1118:
|
||||
switch (sc->mii_mpd_model) {
|
||||
case MII_MODEL_xxMARVELL_E3082:
|
||||
case MII_MODEL_xxMARVELL_E1112:
|
||||
case MII_MODEL_xxMARVELL_E1118:
|
||||
break;
|
||||
case MII_MODEL_MARVELL_E1116:
|
||||
case MII_MODEL_xxMARVELL_E1116:
|
||||
page = PHY_READ(sc, E1000_EADR);
|
||||
/* Select page 3, LED control register. */
|
||||
PHY_WRITE(sc, E1000_EADR, 3);
|
||||
@ -284,7 +268,7 @@ e1000phy_reset(struct mii_softc *sc)
|
||||
E1000_BLINK_RATE(E1000_BLINK_84MS));
|
||||
PHY_WRITE(sc, E1000_EADR, page);
|
||||
break;
|
||||
case MII_MODEL_MARVELL_E3016:
|
||||
case MII_MODEL_xxMARVELL_E3016:
|
||||
/* LED2 -> ACT, LED1 -> LINK, LED0 -> SPEED. */
|
||||
PHY_WRITE(sc, 0x16, 0x0B << 8 | 0x05 << 4 | 0x04);
|
||||
/* Integrated register calibration workaround. */
|
||||
@ -309,7 +293,6 @@ static int
|
||||
e1000phy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
{
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
struct e1000phy_softc *esc = (struct e1000phy_softc *)sc;
|
||||
uint16_t speed, gig;
|
||||
int reg;
|
||||
|
||||
@ -325,7 +308,7 @@ e1000phy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
break;
|
||||
|
||||
if (IFM_SUBTYPE(ife->ifm_media) == IFM_AUTO) {
|
||||
e1000phy_mii_phy_auto(esc, ife->ifm_media);
|
||||
e1000phy_mii_phy_auto(sc, ife->ifm_media);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -412,13 +395,13 @@ e1000phy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
break;
|
||||
|
||||
sc->mii_ticks = 0;
|
||||
e1000phy_reset(sc);
|
||||
e1000phy_mii_phy_auto(esc, ife->ifm_media);
|
||||
PHY_RESET(sc);
|
||||
e1000phy_mii_phy_auto(sc, ife->ifm_media);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
e1000phy_status(sc);
|
||||
PHY_STATUS(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
mii_phy_update(sc, cmd);
|
||||
@ -489,12 +472,10 @@ e1000phy_status(struct mii_softc *sc)
|
||||
}
|
||||
|
||||
static int
|
||||
e1000phy_mii_phy_auto(struct e1000phy_softc *esc, int media)
|
||||
e1000phy_mii_phy_auto(struct mii_softc *sc, int media)
|
||||
{
|
||||
struct mii_softc *sc;
|
||||
uint16_t reg;
|
||||
|
||||
sc = &esc->mii_sc;
|
||||
if ((sc->mii_flags & MIIF_HAVEFIBER) == 0) {
|
||||
reg = PHY_READ(sc, E1000_AR);
|
||||
reg &= ~(E1000_AR_PAUSE | E1000_AR_ASM_DIR);
|
||||
|
@ -111,10 +111,16 @@ static void exphy_reset(struct mii_softc *);
|
||||
*/
|
||||
static const struct mii_phydesc exphys[] = {
|
||||
{ 0, 0, "3Com internal media interface" },
|
||||
MII_PHY_DESC(BROADCOM, 3C905C),
|
||||
MII_PHY_DESC(xxBROADCOM, 3C905C),
|
||||
MII_PHY_END
|
||||
};
|
||||
|
||||
|
||||
static const struct mii_phy_funcs exphy_funcs = {
|
||||
exphy_service,
|
||||
ukphy_status,
|
||||
exphy_reset
|
||||
};
|
||||
|
||||
static int
|
||||
exphy_probe(device_t dev)
|
||||
{
|
||||
@ -128,40 +134,12 @@ exphy_probe(device_t dev)
|
||||
static int
|
||||
exphy_attach(device_t dev)
|
||||
{
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_flags = miibus_get_flags(dev);
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = exphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
/*
|
||||
* The 3Com PHY can never be isolated.
|
||||
*/
|
||||
sc->mii_flags |= MIIF_NOISOLATE;
|
||||
|
||||
#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
|
||||
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->mii_inst),
|
||||
MII_MEDIA_100_TX);
|
||||
|
||||
exphy_reset(sc);
|
||||
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
device_printf(dev, " ");
|
||||
mii_phy_add_media(sc);
|
||||
printf("\n");
|
||||
#undef ADD
|
||||
MIIBUS_MEDIAINIT(sc->mii_dev);
|
||||
mii_phy_dev_attach(dev, MIIF_NOISOLATE | MIIF_NOMANPAUSE,
|
||||
&exphy_funcs, 1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -198,7 +176,7 @@ exphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
ukphy_status(sc);
|
||||
PHY_STATUS(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
mii_phy_update(sc, cmd);
|
||||
|
@ -111,6 +111,12 @@ DRIVER_MODULE(gentbi, miibus, gentbi_driver, gentbi_devclass, 0, 0);
|
||||
static int gentbi_service(struct mii_softc *, struct mii_data *, int);
|
||||
static void gentbi_status(struct mii_softc *);
|
||||
|
||||
static const struct mii_phy_funcs gentbi_funcs = {
|
||||
gentbi_service,
|
||||
gentbi_status,
|
||||
mii_phy_reset
|
||||
};
|
||||
|
||||
static int
|
||||
gentbi_probe(device_t dev)
|
||||
{
|
||||
@ -152,36 +158,19 @@ static int
|
||||
gentbi_attach(device_t dev)
|
||||
{
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
if (bootverbose)
|
||||
device_printf(dev, "OUI 0x%06x, model 0x%04x, rev. %d\n",
|
||||
MII_OUI(ma->mii_id1, ma->mii_id2),
|
||||
MII_MODEL(ma->mii_id2), MII_REV(ma->mii_id2));
|
||||
mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &gentbi_funcs, 0);
|
||||
|
||||
sc->mii_flags = miibus_get_flags(dev);
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = gentbi_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
sc->mii_flags |= MIIF_NOMANPAUSE;
|
||||
|
||||
mii_phy_reset(sc);
|
||||
PHY_RESET(sc);
|
||||
|
||||
/*
|
||||
* Mask out all media in the BMSR. We only are really interested
|
||||
* in "auto".
|
||||
*/
|
||||
sc->mii_capabilities =
|
||||
PHY_READ(sc, MII_BMSR) & ma->mii_capmask & ~BMSR_MEDIAMASK;
|
||||
PHY_READ(sc, MII_BMSR) & sc->mii_capmask & ~BMSR_MEDIAMASK;
|
||||
if (sc->mii_capabilities & BMSR_EXTSTAT)
|
||||
sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR);
|
||||
|
||||
@ -218,7 +207,7 @@ gentbi_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
gentbi_status(sc);
|
||||
PHY_STATUS(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
mii_phy_update(sc, cmd);
|
||||
|
@ -83,11 +83,6 @@ __FBSDID("$FreeBSD$");
|
||||
static int icsphy_probe(device_t dev);
|
||||
static int icsphy_attach(device_t dev);
|
||||
|
||||
struct icsphy_softc {
|
||||
struct mii_softc mii_sc;
|
||||
int mii_model;
|
||||
};
|
||||
|
||||
static device_method_t icsphy_methods[] = {
|
||||
/* device interface */
|
||||
DEVMETHOD(device_probe, icsphy_probe),
|
||||
@ -102,7 +97,7 @@ static devclass_t icsphy_devclass;
|
||||
static driver_t icsphy_driver = {
|
||||
"icsphy",
|
||||
icsphy_methods,
|
||||
sizeof(struct icsphy_softc)
|
||||
sizeof(struct mii_softc)
|
||||
};
|
||||
|
||||
DRIVER_MODULE(icsphy, miibus, icsphy_driver, icsphy_devclass, 0, 0);
|
||||
@ -112,13 +107,19 @@ static void icsphy_status(struct mii_softc *);
|
||||
static void icsphy_reset(struct mii_softc *);
|
||||
|
||||
static const struct mii_phydesc icsphys[] = {
|
||||
MII_PHY_DESC(xxICS, 1889),
|
||||
MII_PHY_DESC(xxICS, 1890),
|
||||
MII_PHY_DESC(xxICS, 1892),
|
||||
MII_PHY_DESC(xxICS, 1893),
|
||||
MII_PHY_DESC(ICS, 1889),
|
||||
MII_PHY_DESC(ICS, 1890),
|
||||
MII_PHY_DESC(ICS, 1892),
|
||||
MII_PHY_DESC(ICS, 1893),
|
||||
MII_PHY_END
|
||||
};
|
||||
|
||||
static const struct mii_phy_funcs icsphy_funcs = {
|
||||
icsphy_service,
|
||||
icsphy_status,
|
||||
icsphy_reset
|
||||
};
|
||||
|
||||
static int
|
||||
icsphy_probe(device_t dev)
|
||||
{
|
||||
@ -129,40 +130,9 @@ icsphy_probe(device_t dev)
|
||||
static int
|
||||
icsphy_attach(device_t dev)
|
||||
{
|
||||
struct icsphy_softc *isc;
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
|
||||
isc = device_get_softc(dev);
|
||||
sc = &isc->mii_sc;
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_flags = miibus_get_flags(dev);
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = icsphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
sc->mii_flags |= MIIF_NOISOLATE;
|
||||
|
||||
ifmedia_add(&mii->mii_media,
|
||||
IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->mii_inst),
|
||||
MII_MEDIA_100_TX, NULL);
|
||||
|
||||
isc->mii_model = MII_MODEL(ma->mii_id2);
|
||||
icsphy_reset(sc);
|
||||
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
device_printf(dev, " ");
|
||||
mii_phy_add_media(sc);
|
||||
printf("\n");
|
||||
|
||||
MIIBUS_MEDIAINIT(sc->mii_dev);
|
||||
|
||||
mii_phy_dev_attach(dev, MIIF_NOISOLATE | MIIF_NOMANPAUSE,
|
||||
&icsphy_funcs, 1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -191,7 +161,7 @@ icsphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
icsphy_status(sc);
|
||||
PHY_STATUS(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
mii_phy_update(sc, cmd);
|
||||
@ -240,7 +210,8 @@ icsphy_status(struct mii_softc *sc)
|
||||
else
|
||||
mii->mii_media_active |= IFM_10_T;
|
||||
if (qpr & QPR_FDX)
|
||||
mii->mii_media_active |= IFM_FDX;
|
||||
mii->mii_media_active |=
|
||||
IFM_FDX | mii_phy_flowstatus(sc);
|
||||
else
|
||||
mii->mii_media_active |= IFM_HDX;
|
||||
} else
|
||||
@ -250,16 +221,15 @@ icsphy_status(struct mii_softc *sc)
|
||||
static void
|
||||
icsphy_reset(struct mii_softc *sc)
|
||||
{
|
||||
struct icsphy_softc *isc = (struct icsphy_softc *)sc;
|
||||
|
||||
mii_phy_reset(sc);
|
||||
/* set powerdown feature */
|
||||
switch (isc->mii_model) {
|
||||
case MII_MODEL_xxICS_1890:
|
||||
case MII_MODEL_xxICS_1893:
|
||||
switch (sc->mii_mpd_model) {
|
||||
case MII_MODEL_ICS_1890:
|
||||
case MII_MODEL_ICS_1893:
|
||||
PHY_WRITE(sc, MII_ICSPHY_ECR2, ECR2_100AUTOPWRDN);
|
||||
break;
|
||||
case MII_MODEL_xxICS_1892:
|
||||
case MII_MODEL_ICS_1892:
|
||||
PHY_WRITE(sc, MII_ICSPHY_ECR2,
|
||||
ECR2_10AUTOPWRDN|ECR2_100AUTOPWRDN);
|
||||
break;
|
||||
|
@ -80,14 +80,20 @@ static void inphy_status(struct mii_softc *);
|
||||
static void inphy_reset(struct mii_softc *);
|
||||
|
||||
static const struct mii_phydesc inphys[] = {
|
||||
MII_PHY_DESC(INTEL, I82553C),
|
||||
MII_PHY_DESC(INTEL, I82555),
|
||||
MII_PHY_DESC(INTEL, I82562EM),
|
||||
MII_PHY_DESC(INTEL, I82562ET),
|
||||
MII_PHY_DESC(xxINTEL, I82553AB),
|
||||
MII_PHY_DESC(xxINTEL, I82553),
|
||||
MII_PHY_DESC(yyINTEL, I82553),
|
||||
MII_PHY_DESC(yyINTEL, I82555),
|
||||
MII_PHY_DESC(yyINTEL, I82562EM),
|
||||
MII_PHY_DESC(yyINTEL, I82562ET),
|
||||
MII_PHY_END
|
||||
};
|
||||
|
||||
static const struct mii_phy_funcs inphy_funcs = {
|
||||
inphy_service,
|
||||
inphy_status,
|
||||
inphy_reset
|
||||
};
|
||||
|
||||
static int
|
||||
inphy_probe(device_t dev)
|
||||
{
|
||||
@ -98,37 +104,8 @@ inphy_probe(device_t dev)
|
||||
static int
|
||||
inphy_attach(device_t dev)
|
||||
{
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_flags = miibus_get_flags(dev);
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = inphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
sc->mii_flags |= MIIF_NOMANPAUSE;
|
||||
|
||||
ifmedia_add(&mii->mii_media,
|
||||
IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->mii_inst),
|
||||
MII_MEDIA_100_TX, NULL);
|
||||
|
||||
inphy_reset(sc);
|
||||
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
device_printf(dev, " ");
|
||||
mii_phy_add_media(sc);
|
||||
printf("\n");
|
||||
|
||||
MIIBUS_MEDIAINIT(sc->mii_dev);
|
||||
|
||||
mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &inphy_funcs, 1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -157,7 +134,7 @@ inphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
inphy_status(sc);
|
||||
PHY_STATUS(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
mii_phy_update(sc, cmd);
|
||||
|
@ -57,12 +57,6 @@ __FBSDID("$FreeBSD$");
|
||||
static int ip1000phy_probe(device_t);
|
||||
static int ip1000phy_attach(device_t);
|
||||
|
||||
struct ip1000phy_softc {
|
||||
struct mii_softc mii_sc;
|
||||
int model;
|
||||
int revision;
|
||||
};
|
||||
|
||||
static device_method_t ip1000phy_methods[] = {
|
||||
/* device interface */
|
||||
DEVMETHOD(device_probe, ip1000phy_probe),
|
||||
@ -87,11 +81,17 @@ static void ip1000phy_reset(struct mii_softc *);
|
||||
static int ip1000phy_mii_phy_auto(struct mii_softc *, int);
|
||||
|
||||
static const struct mii_phydesc ip1000phys[] = {
|
||||
MII_PHY_DESC(ICPLUS, IP1000A),
|
||||
MII_PHY_DESC(ICPLUS, IP1001),
|
||||
MII_PHY_DESC(xxICPLUS, IP1000A),
|
||||
MII_PHY_DESC(xxICPLUS, IP1001),
|
||||
MII_PHY_END
|
||||
};
|
||||
|
||||
static const struct mii_phy_funcs ip1000phy_funcs = {
|
||||
ip1000phy_service,
|
||||
ip1000phy_status,
|
||||
ip1000phy_reset
|
||||
};
|
||||
|
||||
static int
|
||||
ip1000phy_probe(device_t dev)
|
||||
{
|
||||
@ -102,43 +102,16 @@ ip1000phy_probe(device_t dev)
|
||||
static int
|
||||
ip1000phy_attach(device_t dev)
|
||||
{
|
||||
struct ip1000phy_softc *isc;
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
u_int flags;
|
||||
|
||||
isc = device_get_softc(dev);
|
||||
sc = &isc->mii_sc;
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_flags = miibus_get_flags(dev);
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = ip1000phy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
sc->mii_flags |= MIIF_NOISOLATE | MIIF_NOMANPAUSE;
|
||||
|
||||
isc->model = MII_MODEL(ma->mii_id2);
|
||||
isc->revision = MII_REV(ma->mii_id2);
|
||||
if (isc->model == MII_MODEL_ICPLUS_IP1000A &&
|
||||
strcmp(mii->mii_ifp->if_dname, "stge") == 0 &&
|
||||
(sc->mii_flags & MIIF_MACPRIV0) != 0)
|
||||
sc->mii_flags |= MIIF_PHYPRIV0;
|
||||
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
if (sc->mii_capabilities & BMSR_EXTSTAT)
|
||||
sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR);
|
||||
device_printf(dev, " ");
|
||||
|
||||
ip1000phy_reset(sc);
|
||||
mii_phy_add_media(sc);
|
||||
printf("\n");
|
||||
|
||||
MIIBUS_MEDIAINIT(sc->mii_dev);
|
||||
flags = MIIF_NOISOLATE | MIIF_NOMANPAUSE;
|
||||
if (MII_MODEL(ma->mii_id2) == MII_MODEL_xxICPLUS_IP1000A &&
|
||||
strcmp(ma->mii_data->mii_ifp->if_dname, "stge") == 0 &&
|
||||
(miibus_get_flags(dev) & MIIF_MACPRIV0) != 0)
|
||||
flags |= MIIF_PHYPRIV0;
|
||||
mii_phy_dev_attach(dev, flags, &ip1000phy_funcs, 0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -160,7 +133,7 @@ ip1000phy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
break;
|
||||
}
|
||||
|
||||
ip1000phy_reset(sc);
|
||||
PHY_RESET(sc);
|
||||
switch (IFM_SUBTYPE(ife->ifm_media)) {
|
||||
case IFM_AUTO:
|
||||
(void)ip1000phy_mii_phy_auto(sc, ife->ifm_media);
|
||||
@ -245,7 +218,7 @@ ip1000phy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
ip1000phy_status(sc);
|
||||
PHY_STATUS(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
mii_phy_update(sc, cmd);
|
||||
@ -255,12 +228,9 @@ ip1000phy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
static void
|
||||
ip1000phy_status(struct mii_softc *sc)
|
||||
{
|
||||
struct ip1000phy_softc *isc;
|
||||
struct mii_data *mii = sc->mii_pdata;
|
||||
uint32_t bmsr, bmcr, stat;
|
||||
|
||||
isc = (struct ip1000phy_softc *)sc;
|
||||
|
||||
mii->mii_media_status = IFM_AVALID;
|
||||
mii->mii_media_active = IFM_ETHER;
|
||||
|
||||
@ -281,7 +251,7 @@ ip1000phy_status(struct mii_softc *sc)
|
||||
}
|
||||
}
|
||||
|
||||
if (isc->model == MII_MODEL_ICPLUS_IP1001) {
|
||||
if (sc->mii_mpd_model == MII_MODEL_xxICPLUS_IP1001) {
|
||||
stat = PHY_READ(sc, IP1000PHY_LSR);
|
||||
switch (stat & IP1000PHY_LSR_SPEED_MASK) {
|
||||
case IP1000PHY_LSR_SPEED_10:
|
||||
@ -339,12 +309,10 @@ ip1000phy_status(struct mii_softc *sc)
|
||||
static int
|
||||
ip1000phy_mii_phy_auto(struct mii_softc *sc, int media)
|
||||
{
|
||||
struct ip1000phy_softc *isc;
|
||||
uint32_t reg;
|
||||
|
||||
isc = (struct ip1000phy_softc *)sc;
|
||||
reg = 0;
|
||||
if (isc->model == MII_MODEL_ICPLUS_IP1001) {
|
||||
if (sc->mii_mpd_model == MII_MODEL_xxICPLUS_IP1001) {
|
||||
reg = PHY_READ(sc, IP1000PHY_MII_ANAR);
|
||||
reg &= ~(IP1000PHY_ANAR_PAUSE | IP1000PHY_ANAR_APAUSE);
|
||||
reg |= IP1000PHY_ANAR_NP;
|
||||
|
@ -56,13 +56,6 @@ static void jmphy_reset(struct mii_softc *);
|
||||
static uint16_t jmphy_anar(struct ifmedia_entry *);
|
||||
static int jmphy_setmedia(struct mii_softc *, struct ifmedia_entry *);
|
||||
|
||||
struct jmphy_softc {
|
||||
struct mii_softc mii_sc;
|
||||
int mii_oui;
|
||||
int mii_model;
|
||||
int mii_rev;
|
||||
};
|
||||
|
||||
static device_method_t jmphy_methods[] = {
|
||||
/* Device interface. */
|
||||
DEVMETHOD(device_probe, jmphy_probe),
|
||||
@ -76,7 +69,7 @@ static devclass_t jmphy_devclass;
|
||||
static driver_t jmphy_driver = {
|
||||
"jmphy",
|
||||
jmphy_methods,
|
||||
sizeof(struct jmphy_softc)
|
||||
sizeof(struct mii_softc)
|
||||
};
|
||||
|
||||
DRIVER_MODULE(jmphy, miibus, jmphy_driver, jmphy_devclass, 0, 0);
|
||||
@ -90,6 +83,12 @@ static const struct mii_phydesc jmphys[] = {
|
||||
MII_PHY_END
|
||||
};
|
||||
|
||||
static const struct mii_phy_funcs jmphy_funcs = {
|
||||
jmphy_service,
|
||||
jmphy_status,
|
||||
jmphy_reset
|
||||
};
|
||||
|
||||
static int
|
||||
jmphy_probe(device_t dev)
|
||||
{
|
||||
@ -100,46 +99,15 @@ jmphy_probe(device_t dev)
|
||||
static int
|
||||
jmphy_attach(device_t dev)
|
||||
{
|
||||
struct jmphy_softc *jsc;
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
struct ifnet *ifp;
|
||||
u_int flags;
|
||||
|
||||
jsc = device_get_softc(dev);
|
||||
sc = &jsc->mii_sc;
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_flags = miibus_get_flags(dev);
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = jmphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
ifp = sc->mii_pdata->mii_ifp;
|
||||
if (strcmp(ifp->if_dname, "jme") == 0 &&
|
||||
(sc->mii_flags & MIIF_MACPRIV0) != 0)
|
||||
sc->mii_flags |= MIIF_PHYPRIV0;
|
||||
jsc->mii_oui = MII_OUI(ma->mii_id1, ma->mii_id2);
|
||||
jsc->mii_model = MII_MODEL(ma->mii_id2);
|
||||
jsc->mii_rev = MII_REV(ma->mii_id2);
|
||||
if (bootverbose)
|
||||
device_printf(dev, "OUI 0x%06x, model 0x%04x, rev. %d\n",
|
||||
jsc->mii_oui, jsc->mii_model, jsc->mii_rev);
|
||||
|
||||
jmphy_reset(sc);
|
||||
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
if (sc->mii_capabilities & BMSR_EXTSTAT)
|
||||
sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR);
|
||||
device_printf(dev, " ");
|
||||
mii_phy_add_media(sc);
|
||||
printf("\n");
|
||||
|
||||
MIIBUS_MEDIAINIT(sc->mii_dev);
|
||||
flags = 0;
|
||||
if (strcmp(ma->mii_data->mii_ifp->if_dname, "jme") == 0 &&
|
||||
(miibus_get_flags(dev) & MIIF_MACPRIV0) != 0)
|
||||
flags |= MIIF_PHYPRIV0;
|
||||
mii_phy_dev_attach(dev, flags, &jmphy_funcs, 1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -196,7 +164,7 @@ jmphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
jmphy_status(sc);
|
||||
PHY_STATUS(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
mii_phy_update(sc, cmd);
|
||||
@ -269,12 +237,9 @@ jmphy_status(struct mii_softc *sc)
|
||||
static void
|
||||
jmphy_reset(struct mii_softc *sc)
|
||||
{
|
||||
struct jmphy_softc *jsc;
|
||||
uint16_t t2cr, val;
|
||||
int i;
|
||||
|
||||
jsc = (struct jmphy_softc *)sc;
|
||||
|
||||
/* Disable sleep mode. */
|
||||
PHY_WRITE(sc, JMPHY_TMCTL,
|
||||
PHY_READ(sc, JMPHY_TMCTL) & ~JMPHY_TMCTL_SLEEP_ENB);
|
||||
@ -369,9 +334,6 @@ jmphy_setmedia(struct mii_softc *sc, struct ifmedia_entry *ife)
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
if ((ife->ifm_media & IFM_LOOP) != 0)
|
||||
bmcr |= BMCR_LOOP;
|
||||
|
||||
anar = jmphy_anar(ife);
|
||||
if ((IFM_SUBTYPE(ife->ifm_media) == IFM_AUTO ||
|
||||
(ife->ifm_media & IFM_FDX) != 0) &&
|
||||
|
@ -106,6 +106,7 @@ DRIVER_MODULE(lxtphy, miibus, lxtphy_driver, lxtphy_devclass, 0, 0);
|
||||
|
||||
static int lxtphy_service(struct mii_softc *, struct mii_data *, int);
|
||||
static void lxtphy_status(struct mii_softc *);
|
||||
static void lxtphy_reset(struct mii_softc *);
|
||||
static void lxtphy_set_tp(struct mii_softc *);
|
||||
static void lxtphy_set_fx(struct mii_softc *);
|
||||
|
||||
@ -114,6 +115,12 @@ static const struct mii_phydesc lxtphys[] = {
|
||||
MII_PHY_END
|
||||
};
|
||||
|
||||
static const struct mii_phy_funcs lxtphy_funcs = {
|
||||
lxtphy_service,
|
||||
lxtphy_status,
|
||||
lxtphy_reset
|
||||
};
|
||||
|
||||
static int
|
||||
lxtphy_probe(device_t dev)
|
||||
{
|
||||
@ -125,27 +132,17 @@ static int
|
||||
lxtphy_attach(device_t dev)
|
||||
{
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_flags = miibus_get_flags(dev);
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = lxtphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &lxtphy_funcs, 0);
|
||||
|
||||
mii_phy_reset(sc);
|
||||
PHY_RESET(sc);
|
||||
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & sc->mii_capmask;
|
||||
device_printf(dev, " ");
|
||||
|
||||
#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
|
||||
#define ADD(m, c) ifmedia_add(&sc->mii_pdata->mii_media, (m), (c), NULL)
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_FX, 0, sc->mii_inst),
|
||||
MII_MEDIA_100_TX);
|
||||
printf("100baseFX, ");
|
||||
@ -192,7 +189,7 @@ lxtphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
lxtphy_status(sc);
|
||||
PHY_STATUS(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
mii_phy_update(sc, cmd);
|
||||
@ -240,13 +237,23 @@ lxtphy_status(struct mii_softc *sc)
|
||||
else
|
||||
mii->mii_media_active |= IFM_10_T;
|
||||
if (csr & CSR_DUPLEX)
|
||||
mii->mii_media_active |= IFM_FDX;
|
||||
mii->mii_media_active |=
|
||||
IFM_FDX | mii_phy_flowstatus(sc);
|
||||
else
|
||||
mii->mii_media_active |= IFM_HDX;
|
||||
} else
|
||||
mii->mii_media_active = ife->ifm_media;
|
||||
}
|
||||
|
||||
static void
|
||||
lxtphy_reset(struct mii_softc *sc)
|
||||
{
|
||||
|
||||
mii_phy_reset(sc);
|
||||
PHY_WRITE(sc, MII_LXTPHY_IER,
|
||||
PHY_READ(sc, MII_LXTPHY_IER) & ~IER_INTEN);
|
||||
}
|
||||
|
||||
static void
|
||||
lxtphy_set_tp(struct mii_softc *sc)
|
||||
{
|
||||
|
@ -44,7 +44,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/socket.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/bus.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_media.h>
|
||||
@ -69,6 +69,7 @@ static int miibus_writereg(device_t, int, int, int);
|
||||
static void miibus_statchg(device_t);
|
||||
static void miibus_linkchg(device_t);
|
||||
static void miibus_mediainit(device_t);
|
||||
static unsigned char mii_bitreverse(unsigned char x);
|
||||
|
||||
static device_method_t miibus_methods[] = {
|
||||
/* device interface */
|
||||
@ -87,9 +88,9 @@ static device_method_t miibus_methods[] = {
|
||||
/* MII interface */
|
||||
DEVMETHOD(miibus_readreg, miibus_readreg),
|
||||
DEVMETHOD(miibus_writereg, miibus_writereg),
|
||||
DEVMETHOD(miibus_statchg, miibus_statchg),
|
||||
DEVMETHOD(miibus_linkchg, miibus_linkchg),
|
||||
DEVMETHOD(miibus_mediainit, miibus_mediainit),
|
||||
DEVMETHOD(miibus_statchg, miibus_statchg),
|
||||
DEVMETHOD(miibus_linkchg, miibus_linkchg),
|
||||
DEVMETHOD(miibus_mediainit, miibus_mediainit),
|
||||
|
||||
{ 0, 0 }
|
||||
};
|
||||
@ -265,7 +266,7 @@ miibus_linkchg(device_t dev)
|
||||
MIIBUS_LINKCHG(parent);
|
||||
|
||||
mii = device_get_softc(dev);
|
||||
|
||||
|
||||
if (mii->mii_media_status & IFM_AVALID) {
|
||||
if (mii->mii_media_status & IFM_ACTIVE)
|
||||
link_state = LINK_STATE_UP;
|
||||
@ -361,7 +362,7 @@ mii_attach(device_t dev, device_t *miibus, struct ifnet *ifp,
|
||||
* has been allocated.
|
||||
*/
|
||||
ma.mii_data = device_get_softc(*miibus);
|
||||
}
|
||||
}
|
||||
|
||||
ma.mii_capmask = capmask;
|
||||
|
||||
@ -392,7 +393,7 @@ mii_attach(device_t dev, device_t *miibus, struct ifnet *ifp,
|
||||
* Check to see if there is a PHY at this address. Note,
|
||||
* many braindead PHYs report 0/0 in their ID registers,
|
||||
* so we test for media in the BMSR.
|
||||
*/
|
||||
*/
|
||||
bmsr = MIIBUS_READREG(dev, ma.mii_phyno, MII_BMSR);
|
||||
if (bmsr == 0 || bmsr == 0xffff ||
|
||||
(bmsr & (BMSR_EXTSTAT | BMSR_MEDIAMASK)) == 0) {
|
||||
@ -411,10 +412,11 @@ mii_attach(device_t dev, device_t *miibus, struct ifnet *ifp,
|
||||
* Extract the IDs. Braindead PHYs will be handled by
|
||||
* the `ukphy' driver, as we have no ID information to
|
||||
* match on.
|
||||
*/
|
||||
*/
|
||||
ma.mii_id1 = MIIBUS_READREG(dev, ma.mii_phyno, MII_PHYIDR1);
|
||||
ma.mii_id2 = MIIBUS_READREG(dev, ma.mii_phyno, MII_PHYIDR2);
|
||||
|
||||
ma.mii_offset = offset;
|
||||
args = malloc(sizeof(struct mii_attach_args), M_DEVBUF,
|
||||
M_NOWAIT);
|
||||
if (args == NULL)
|
||||
@ -486,7 +488,7 @@ mii_mediachg(struct mii_data *mii)
|
||||
BMCR_ISO);
|
||||
continue;
|
||||
}
|
||||
rv = (*child->mii_service)(child, mii, MII_MEDIACHG);
|
||||
rv = PHY_SERVICE(child, mii, MII_MEDIACHG);
|
||||
if (rv)
|
||||
return (rv);
|
||||
}
|
||||
@ -509,7 +511,7 @@ mii_tick(struct mii_data *mii)
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != child->mii_inst)
|
||||
continue;
|
||||
(void)(*child->mii_service)(child, mii, MII_TICK);
|
||||
(void)PHY_SERVICE(child, mii, MII_TICK);
|
||||
}
|
||||
}
|
||||
|
||||
@ -531,7 +533,7 @@ mii_pollstat(struct mii_data *mii)
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != child->mii_inst)
|
||||
continue;
|
||||
(void)(*child->mii_service)(child, mii, MII_POLLSTAT);
|
||||
(void)PHY_SERVICE(child, mii, MII_POLLSTAT);
|
||||
}
|
||||
}
|
||||
|
||||
@ -546,3 +548,25 @@ mii_down(struct mii_data *mii)
|
||||
LIST_FOREACH(child, &mii->mii_phys, mii_list)
|
||||
mii_phy_down(child);
|
||||
}
|
||||
|
||||
static unsigned char
|
||||
mii_bitreverse(unsigned char x)
|
||||
{
|
||||
static unsigned char nibbletab[16] = {
|
||||
0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15
|
||||
};
|
||||
|
||||
return ((nibbletab[x & 15] << 4) | nibbletab[x >> 4]);
|
||||
}
|
||||
|
||||
u_int
|
||||
mii_oui(u_int id1, u_int id2)
|
||||
{
|
||||
u_int h;
|
||||
|
||||
h = (id1 << 6) | (id2 >> 10);
|
||||
|
||||
return ((mii_bitreverse(h >> 16) << 16) |
|
||||
(mii_bitreverse((h >> 8) & 0xff) << 8) |
|
||||
mii_bitreverse(h & 0xff));
|
||||
}
|
||||
|
@ -89,15 +89,9 @@
|
||||
* info available in register 15, but 802.3 section 22.2.4.3 also
|
||||
* states that that all 1000 Mb/s capable PHYs will set this bit to 1.
|
||||
*/
|
||||
#if 0
|
||||
#define BMSR_MEDIAMASK (BMSR_100T4|BMSR_100TXFDX|BMSR_100TXHDX|BMSR_10TFDX| \
|
||||
BMSR_10THDX|BMSR_ANEG)
|
||||
|
||||
#else
|
||||
/* NetBSD uses: */
|
||||
#define BMSR_MEDIAMASK (BMSR_100T4|BMSR_100TXFDX|BMSR_100TXHDX| \
|
||||
BMSR_10TFDX|BMSR_10THDX|BMSR_100T2FDX|BMSR_100T2HDX)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Convert BMSR media capabilities to ANAR bits for autonegotiation.
|
||||
@ -112,10 +106,6 @@
|
||||
#define IDR2_MODEL 0x03f0 /* vendor model */
|
||||
#define IDR2_REV 0x000f /* vendor revision */
|
||||
|
||||
#define MII_OUI(id1, id2) (((id1) << 6) | ((id2) >> 10))
|
||||
#define MII_MODEL(id2) (((id2) & IDR2_MODEL) >> 4)
|
||||
#define MII_REV(id2) ((id2) & IDR2_REV)
|
||||
|
||||
#define MII_ANAR 0x04 /* Autonegotiation advertisement (rw) */
|
||||
/* section 28.2.4.1 and 37.2.6.1 */
|
||||
#define ANAR_NP 0x8000 /* Next page (ro) */
|
||||
|
@ -150,9 +150,6 @@ mii_phy_setmedia(struct mii_softc *sc)
|
||||
}
|
||||
}
|
||||
|
||||
if ((ife->ifm_media & IFM_LOOP) != 0)
|
||||
bmcr |= BMCR_LOOP;
|
||||
|
||||
PHY_WRITE(sc, MII_ANAR, anar);
|
||||
PHY_WRITE(sc, MII_BMCR, bmcr);
|
||||
if ((sc->mii_flags & MIIF_HAVE_GTCR) != 0)
|
||||
@ -251,7 +248,7 @@ mii_phy_tick(struct mii_softc *sc)
|
||||
return (EJUSTRETURN);
|
||||
|
||||
sc->mii_ticks = 0;
|
||||
mii_phy_reset(sc);
|
||||
PHY_RESET(sc);
|
||||
mii_phy_auto(sc);
|
||||
return (0);
|
||||
}
|
||||
@ -332,9 +329,11 @@ mii_phy_add_media(struct mii_softc *sc)
|
||||
#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
|
||||
#define PRINT(s) printf("%s%s", sep, s); sep = ", "
|
||||
|
||||
if ((sc->mii_flags & MIIF_NOISOLATE) == 0)
|
||||
if ((sc->mii_flags & MIIF_NOISOLATE) == 0) {
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_NONE, 0, sc->mii_inst),
|
||||
MII_MEDIA_NONE);
|
||||
PRINT("none");
|
||||
}
|
||||
|
||||
/*
|
||||
* There are different interpretations for the bits in
|
||||
@ -521,6 +520,50 @@ mii_phy_dev_probe(device_t dev, const struct mii_phydesc *mpd, int mrv)
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
void
|
||||
mii_phy_dev_attach(device_t dev, u_int flags, const struct mii_phy_funcs *mpf,
|
||||
int add_media)
|
||||
{
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_flags = flags | miibus_get_flags(dev);
|
||||
sc->mii_mpd_oui = MII_OUI(ma->mii_id1, ma->mii_id2);
|
||||
sc->mii_mpd_model = MII_MODEL(ma->mii_id2);
|
||||
sc->mii_mpd_rev = MII_REV(ma->mii_id2);
|
||||
sc->mii_capmask = ma->mii_capmask;
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_offset = ma->mii_offset;
|
||||
sc->mii_funcs = mpf;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
if (bootverbose)
|
||||
device_printf(dev, "OUI 0x%06x, model 0x%04x, rev. %d\n",
|
||||
sc->mii_mpd_oui, sc->mii_mpd_model, sc->mii_mpd_rev);
|
||||
|
||||
if (add_media == 0)
|
||||
return;
|
||||
|
||||
PHY_RESET(sc);
|
||||
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & sc->mii_capmask;
|
||||
if (sc->mii_capabilities & BMSR_EXTSTAT)
|
||||
sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR);
|
||||
device_printf(dev, " ");
|
||||
mii_phy_add_media(sc);
|
||||
printf("\n");
|
||||
|
||||
MIIBUS_MEDIAINIT(sc->mii_dev);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the flow control status flag from MII_ANAR & MII_ANLPAR.
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
$FreeBSD$
|
||||
/*$NetBSD: miidevs,v 1.6 1999/05/14 11:37:30 drochner Exp $*/
|
||||
/*$NetBSD: miidevs,v 1.99 2011/01/26 18:39:04 bouyer Exp $*/
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
|
||||
@ -35,69 +35,77 @@ $FreeBSD$
|
||||
* List of known MII OUIs.
|
||||
* For a complete list see http://standards.ieee.org/regauth/oui/
|
||||
*
|
||||
* XXX Vendors do obviously not agree how OUIs (18 bit) are mapped
|
||||
* to the 16 bits available in the id registers. The MII_OUI() macro
|
||||
* in "mii.h" reflects the most obvious way. If a vendor uses a
|
||||
* different mapping, an "xx" prefixed OUI is defined here which is
|
||||
* mangled accordingly to compensate.
|
||||
* XXX Vendors do obviously not agree how OUIs (24 bit) are mapped
|
||||
* to the 22 bits available in the id registers.
|
||||
* IEEE 802.3u-1995, subclause 22.2.4.3.1, figure 22-12, depicts the right
|
||||
* mapping; the bit positions are defined in IEEE 802-1990, figure 5.2.
|
||||
* (There is a formal 802.3 interpretation, number 1-07/98 of July 09 1998,
|
||||
* about this.)
|
||||
* The MII_OUI() macro in "mii.h" reflects this.
|
||||
* If a vendor uses a different mapping, an "xx" prefixed OUI is defined here
|
||||
* which is mangled accordingly to compensate.
|
||||
*/
|
||||
|
||||
oui AGERE 0x00a0bc Agere Systems
|
||||
oui AGERE 0x00053d Agere Systems
|
||||
oui ALTIMA 0x0010a9 Altima Communications
|
||||
oui AMD 0x00001a Advanced Micro Devices
|
||||
oui ASIX 0x00602e Asix Semiconductor
|
||||
oui ATHEROS 0x001374 Atheros Communications
|
||||
oui BROADCOM 0x001018 Broadcom Corporation
|
||||
oui BROADCOM2 0x000af7 Broadcom Corporation
|
||||
oui BROADCOM3 0x001be9 Broadcom Corporation
|
||||
oui CICADA 0x0003F1 Cicada Semiconductor
|
||||
oui DAVICOM 0x00606e Davicom Semiconductor
|
||||
oui ENABLESEMI 0x0010dd Enable Semiconductor
|
||||
oui ICPLUS 0x0090c3 IC Plus Corp.
|
||||
oui ICS 0x00a0be Integrated Circuit Systems
|
||||
oui INTEL 0x00aa00 Intel
|
||||
oui JATO 0x00e083 Jato Technologies
|
||||
oui JMICRON 0x001b8c JMicron Technologies
|
||||
oui INTEL 0x00aa00 Intel Corporation
|
||||
oui JMICRON 0x00d831 JMicron Technologies
|
||||
oui LEVEL1 0x00207b Level 1
|
||||
oui NATSEMI 0x080017 National Semiconductor
|
||||
oui QUALSEMI 0x006051 Quality Semiconductor
|
||||
oui RDC 0x000bb4 RDC Semiconductor
|
||||
oui REALTEK 0x000020 RealTek Semicondctor
|
||||
oui SEEQ 0x00a07d Seeq
|
||||
oui SIS 0x00e006 Silicon Integrated Systems
|
||||
oui SMSC 0x0005be SMSC
|
||||
oui TDK 0x00c039 TDK
|
||||
oui TI 0x080028 Texas Instruments
|
||||
oui VITESSE 0x0001c1 Vitesse Semiconductor
|
||||
oui XAQTI 0x00e0ae XaQti Corp.
|
||||
oui MARVELL 0x005043 Marvell Semiconductor
|
||||
oui xxMARVELL 0x000ac2 Marvell Semiconductor
|
||||
oui MYSON 0x00c0b4 Myson Technology
|
||||
oui NATSEMI 0x080017 National Semiconductor
|
||||
oui PMCSIERRA 0x00e004 PMC-Sierra
|
||||
oui QUALSEMI 0x006051 Quality Semiconductor
|
||||
oui RDC 0x00d02d RDC Semiconductor
|
||||
oui REALTEK 0x00e04c RealTek Semicondctor
|
||||
oui SEEQ 0x00a07d Seeq Technology
|
||||
oui SIS 0x00e006 Silicon Integrated Systems
|
||||
oui TI 0x080028 Texas Instruments
|
||||
oui TSC 0x00c039 TDK Semiconductor
|
||||
oui XAQTI 0x00e0ae XaQti Corp.
|
||||
|
||||
/* in the 79c873, AMD uses another OUI (which matches Davicom!) */
|
||||
oui xxAMD 0x00606e Advanced Micro Devices
|
||||
/* Some Intel 82553's use an alternative OUI. */
|
||||
oui xxINTEL 0x001f00 Intel Corporation
|
||||
|
||||
/* Intel 82553 A/B steppings */
|
||||
oui xxINTEL 0x00f800 Intel
|
||||
/* Some VIA 6122's use an alternative OUI. */
|
||||
oui xxCICADA 0x00c08f Cicada Semiconductor
|
||||
|
||||
/* some vendors have the bits swapped within bytes
|
||||
(ie, ordered as on the wire) */
|
||||
oui xxALTIMA 0x000895 Altima Communications
|
||||
/* bad bitorder (bits "g" and "h" (= MSBs byte 1) lost) */
|
||||
oui yyAMD 0x000058 Advanced Micro Devices
|
||||
oui xxATHEROS 0x00c82e Atheros Communications
|
||||
oui xxBROADCOM 0x000818 Broadcom Corporation
|
||||
oui xxBROADCOM_ALT1 0x0050ef Broadcom Corporation
|
||||
oui xxBROADCOM_ALT2 0x00d897 Broadcom Corporation
|
||||
oui xxICS 0x00057d Integrated Circuit Systems
|
||||
oui xxSEEQ 0x0005be Seeq
|
||||
oui xxSIS 0x000760 Silicon Integrated Systems
|
||||
oui xxTI 0x100014 Texas Instruments
|
||||
oui xxXAQTI 0x350700 XaQti Corp.
|
||||
oui xxDAVICOM 0x000676 Davicom Semiconductor
|
||||
oui yyINTEL 0x005500 Intel Corporation
|
||||
oui xxJATO 0x0007c1 Jato Technologies
|
||||
oui xxMARVELL 0x000ac2 Marvell Semiconductor
|
||||
oui xxMYSON 0x00032d Myson Technology
|
||||
oui xxNATSEMI 0x1000e8 National Semiconductor
|
||||
oui xxQUALSEMI 0x00068a Quality Semiconductor
|
||||
oui xxTSC 0x00039c TDK Semiconductor
|
||||
oui xxVITESSE 0x008083 Vitesse Semiconductor
|
||||
|
||||
/* Level 1 is completely different - from right to left.
|
||||
(Two bits get lost in the third OUI byte.) */
|
||||
oui xxLEVEL1 0x1e0400 Level 1
|
||||
/* bad byteorder (bits "q" and "r" (= LSBs byte 3) lost) */
|
||||
oui xxLEVEL1 0x782000 Level 1
|
||||
oui xxXAQTI 0xace000 XaQti Corp.
|
||||
|
||||
/* Don't know what's going on here. */
|
||||
oui xxDAVICOM 0x006040 Davicom Semiconductor
|
||||
|
||||
/* This is the OUI of the gigE PHY in the RealTek 8169S/8110S/8211B chips */
|
||||
oui xxREALTEK 0x000732
|
||||
oui xxASIX 0x000674 Asix Semiconductor
|
||||
oui yyDAVICOM 0x000602 Davicom Semiconductor
|
||||
oui xxICPLUS 0x0009c3 IC Plus Corp.
|
||||
oui xxPMCSIERRA 0x0009c0 PMC-Sierra
|
||||
oui xxPMCSIERRA2 0x009057 PMC-Sierra
|
||||
oui xxREALTEK 0x000732 RealTek Semicondctor
|
||||
oui yyREALTEK 0x000004 RealTek Semicondctor
|
||||
|
||||
/*
|
||||
* List of known models. Grouped by oui.
|
||||
@ -108,93 +116,109 @@ model AGERE ET1011 0x0001 ET1011 10/100/1000baseT PHY
|
||||
model AGERE ET1011C 0x0004 ET1011C 10/100/1000baseT PHY
|
||||
|
||||
/* Altima Communications PHYs */
|
||||
model xxALTIMA AC101 0x0021 AC101 10/100 media interface
|
||||
model xxALTIMA AC101L 0x0012 AC101L 10/100 media interface
|
||||
model xxALTIMA ACXXX 0x0001 ACXXX 10/100 media interface
|
||||
model ALTIMA ACXXX 0x0001 ACXXX 10/100 media interface
|
||||
model ALTIMA AC101L 0x0012 AC101L 10/100 media interface
|
||||
model ALTIMA AC101 0x0021 AC101 10/100 media interface
|
||||
/* AMD Am79C87[45] have ALTIMA OUI */
|
||||
model ALTIMA Am79C875 0x0014 Am79C875 10/100 media interface
|
||||
model ALTIMA Am79C874 0x0021 Am79C874 10/100 media interface
|
||||
|
||||
/* Advanced Micro Devices PHYs */
|
||||
model AMD 79c973phy 0x0036 Am79c973 internal PHY
|
||||
model AMD 79c978 0x0039 Am79c978 HomePNA PHY
|
||||
model xxAMD 79C873 0x0000 Am79C873/DM9101 10/100 media interface
|
||||
/* see Davicom DM9101 for Am79C873 */
|
||||
model yyAMD 79C972_10T 0x0001 Am79C972 internal 10BASE-T interface
|
||||
model yyAMD 79c973phy 0x0036 Am79C973 internal 10/100 media interface
|
||||
model yyAMD 79c901 0x0037 Am79C901 10BASE-T interface
|
||||
model yyAMD 79c901home 0x0039 Am79C901 HomePNA 1.0 interface
|
||||
|
||||
/* Asix semiconductor PHYs. */
|
||||
model ASIX AX88X9X 0x0031 Ax88x9x internal PHY
|
||||
/* Atheros Communications/Attansic PHYs */
|
||||
model xxATHEROS F1 0x0001 Atheros F1 10/100/1000 PHY
|
||||
model xxATHEROS F2 0x0002 Atheros F2 10/100 PHY
|
||||
model xxATHEROS F1_7 0x0007 Atheros F1 10/100/1000 PHY
|
||||
|
||||
/* Atheros Communications/Attansic PHYs. */
|
||||
model ATHEROS F1 0x0001 Atheros F1 10/100/1000 PHY
|
||||
model ATHEROS F2 0x0002 Atheros F2 10/100 PHY
|
||||
model ATHEROS F1_7 0x0007 Atheros F1 10/100/1000 PHY
|
||||
/* Asix semiconductor PHYs */
|
||||
model xxASIX AX88X9X 0x0031 Ax88x9x internal PHY
|
||||
|
||||
/* Broadcom Corp. PHYs. */
|
||||
model BROADCOM 3C905B 0x0012 3c905B 10/100 internal PHY
|
||||
model BROADCOM 3C905C 0x0017 3c905C 10/100 internal PHY
|
||||
model BROADCOM BCM5201 0x0021 BCM5201 10/100baseTX PHY
|
||||
model BROADCOM BCM5214 0x0028 BCM5214 Quad 10/100 PHY
|
||||
model BROADCOM BCM5221 0x001e BCM5221 10/100baseTX PHY
|
||||
model BROADCOM BCM5222 0x0032 BCM5222 Dual 10/100 PHY
|
||||
model BROADCOM BCM4401 0x0036 BCM4401 10/100baseTX PHY
|
||||
model xxBROADCOM BCM5400 0x0004 Broadcom 1000baseTX PHY
|
||||
model xxBROADCOM BCM5401 0x0005 BCM5401 10/100/1000baseTX PHY
|
||||
model xxBROADCOM BCM5411 0x0007 BCM5411 10/100/1000baseTX PHY
|
||||
model xxBROADCOM BCM5754 0x000e BCM5754 10/100/1000baseTX PHY
|
||||
model xxBROADCOM BCM5752 0x0010 BCM5752 10/100/1000baseTX PHY
|
||||
model xxBROADCOM BCM5701 0x0011 BCM5701 10/100/1000baseTX PHY
|
||||
model xxBROADCOM BCM5706 0x0015 BCM5706 10/100/1000baseTX/SX PHY
|
||||
model xxBROADCOM BCM5703 0x0016 BCM5703 10/100/1000baseTX PHY
|
||||
model xxBROADCOM BCM5704 0x0019 BCM5704 10/100/1000baseTX PHY
|
||||
model xxBROADCOM BCM5705 0x001a BCM5705 10/100/1000baseTX PHY
|
||||
model xxBROADCOM BCM5750 0x0018 BCM5750 10/100/1000baseTX PHY
|
||||
model xxBROADCOM BCM54K2 0x002e BCM54K2 10/100/1000baseTX PHY
|
||||
model xxBROADCOM BCM5714 0x0034 BCM5714 10/100/1000baseTX PHY
|
||||
model xxBROADCOM BCM5780 0x0035 BCM5780 10/100/1000baseTX PHY
|
||||
model xxBROADCOM BCM5708C 0x0036 BCM5708C 10/100/1000baseTX PHY
|
||||
model xxBROADCOM_ALT1 BCM5482S 0x000b BCM5482S Dual-Port 10/100/1000baseX/FX PHY
|
||||
model xxBROADCOM_ALT1 BCM5755 0x000c BCM5755 10/100/1000baseTX PHY
|
||||
model xxBROADCOM_ALT1 BCM5787 0x000e BCM5787 10/100/1000baseTX PHY
|
||||
model xxBROADCOM_ALT1 BCM5708S 0x0015 BCM5708S 1000/2500BaseSX PHY
|
||||
model xxBROADCOM_ALT1 BCM5709CAX 0x002c BCM5709C(AX) 10/100/1000baseTX PHY
|
||||
model xxBROADCOM_ALT1 BCM5722 0x002d BCM5722 10/100/1000baseTX PHY
|
||||
model xxBROADCOM_ALT1 BCM5784 0x003a BCM5784 10/100/1000baseTX PHY
|
||||
model xxBROADCOM_ALT1 BCM5709C 0x003c BCM5709C 10/100/1000baseTX PHY
|
||||
model xxBROADCOM_ALT1 BCM5761 0x003d BCM5761 10/100/1000baseTX PHY
|
||||
model xxBROADCOM_ALT1 BCM5709S 0x003f BCM5709S 1000/2500baseSX PHY
|
||||
model xxBROADCOM_ALT2 BCM5717C 0x0020 BCM5717C 10/100/1000baseTX PHY
|
||||
model xxBROADCOM_ALT2 BCM57765 0x0024 BCM57765 10/100/1000baseTX PHY
|
||||
model BROADCOM2 BCM5906 0x0004 BCM5906 10/100baseTX PHY
|
||||
/* Broadcom Corp. PHYs */
|
||||
model xxBROADCOM 3C905B 0x0012 Broadcom 3c905B internal PHY
|
||||
model xxBROADCOM 3C905C 0x0017 Broadcom 3c905C internal PHY
|
||||
model xxBROADCOM BCM5201 0x0021 BCM5201 10/100 media interface
|
||||
model xxBROADCOM BCM5214 0x0028 BCM5214 Quad 10/100 media interface
|
||||
model xxBROADCOM BCM5221 0x001e BCM5221 10/100 media interface
|
||||
model xxBROADCOM BCM5222 0x0032 BCM5222 Dual 10/100 media interface
|
||||
model xxBROADCOM BCM4401 0x0036 BCM4401 10/100 media interface
|
||||
model BROADCOM BCM5400 0x0004 BCM5400 1000BASE-T media interface
|
||||
model BROADCOM BCM5401 0x0005 BCM5401 1000BASE-T media interface
|
||||
model BROADCOM BCM5411 0x0007 BCM5411 1000BASE-T media interface
|
||||
model BROADCOM BCM5464 0x000b BCM5464 1000BASE-T media interface
|
||||
model BROADCOM BCM5461 0x000c BCM5461 1000BASE-T media interface
|
||||
model BROADCOM BCM5462 0x000d BCM5462 1000BASE-T media interface
|
||||
model BROADCOM BCM5421 0x000e BCM5421 1000BASE-T media interface
|
||||
model BROADCOM BCM5752 0x0010 BCM5752 1000BASE-T media interface
|
||||
model BROADCOM BCM5701 0x0011 BCM5701 1000BASE-T media interface
|
||||
model BROADCOM BCM5706 0x0015 BCM5706 1000BASE-T/SX media interface
|
||||
model BROADCOM BCM5703 0x0016 BCM5703 1000BASE-T media interface
|
||||
model BROADCOM BCM5750 0x0018 BCM5750 1000BASE-T media interface
|
||||
model BROADCOM BCM5704 0x0019 BCM5704 1000BASE-T media interface
|
||||
model BROADCOM BCM5705 0x001a BCM5705 1000BASE-T media interface
|
||||
model BROADCOM BCM54K2 0x002e BCM54K2 1000BASE-T media interface
|
||||
model BROADCOM BCM5714 0x0034 BCM5714 1000BASE-T media interface
|
||||
model BROADCOM BCM5780 0x0035 BCM5780 1000BASE-T media interface
|
||||
model BROADCOM BCM5708C 0x0036 BCM5708C 1000BASE-T media interface
|
||||
model BROADCOM2 BCM5906 0x0004 BCM5906 10/100baseTX media interface
|
||||
model BROADCOM2 BCM5481 0x000a BCM5481 1000BASE-T media interface
|
||||
model BROADCOM2 BCM5482 0x000b BCM5482 1000BASE-T media interface
|
||||
model BROADCOM2 BCM5755 0x000c BCM5755 1000BASE-T media interface
|
||||
model BROADCOM2 BCM5754 0x000e BCM5754/5787 1000BASE-T media interface
|
||||
model BROADCOM2 BCM5708S 0x0015 BCM5708S 1000/2500baseSX PHY
|
||||
model BROADCOM2 BCM5709CAX 0x002c BCM5709CAX 10/100/1000baseT PHY
|
||||
model BROADCOM2 BCM5722 0x002d BCM5722 1000BASE-T media interface
|
||||
model BROADCOM2 BCM5784 0x003a BCM5784 10/100/1000baseT PHY
|
||||
model BROADCOM2 BCM5709C 0x003c BCM5709 10/100/1000baseT PHY
|
||||
model BROADCOM2 BCM5761 0x003d BCM5761 10/100/1000baseT PHY
|
||||
model BROADCOM2 BCM5709S 0x003f BCM5709S 1000/2500baseSX PHY
|
||||
model BROADCOM3 BCM5717C 0x0020 BCM5717C 1000BASE-T media interface
|
||||
model BROADCOM3 BCM57765 0x0024 BCM57765 1000BASE-T media interface
|
||||
model xxBROADCOM_ALT1 BCM5906 0x0004 BCM5906 10/100baseTX media interface
|
||||
|
||||
/* Cicada Semiconductor PHYs (now owned by Vitesse?) */
|
||||
model CICADA CS8201 0x0001 Cicada CS8201 10/100/1000TX PHY
|
||||
model CICADA CS8204 0x0004 Cicada CS8204 10/100/1000TX PHY
|
||||
model CICADA VSC8211 0x000b Cicada VSC8211 10/100/1000TX PHY
|
||||
model CICADA CS8201A 0x0020 Cicada CS8201 10/100/1000TX PHY
|
||||
model CICADA CS8201B 0x0021 Cicada CS8201 10/100/1000TX PHY
|
||||
model CICADA CS8244 0x002c Cicada CS8244 10/100/1000TX PHY
|
||||
model VITESSE VSC8601 0x0002 Vitesse VSC8601 10/100/1000TX PHY
|
||||
model xxCICADA CS8201 0x0001 Cicada CS8201 10/100/1000TX PHY
|
||||
model xxCICADA CS8204 0x0004 Cicada CS8204 10/100/1000TX PHY
|
||||
model xxCICADA VSC8211 0x000b Cicada VSC8211 10/100/1000TX PHY
|
||||
model xxCICADA CS8201A 0x0020 Cicada CS8201 10/100/1000TX PHY
|
||||
model xxCICADA CS8201B 0x0021 Cicada CS8201 10/100/1000TX PHY
|
||||
model xxCICADA CS8244 0x002c Cicada CS8244 10/100/1000TX PHY
|
||||
model xxVITESSE VSC8601 0x0002 Vitesse VSC8601 10/100/1000TX PHY
|
||||
|
||||
/* Davicom Semiconductor PHYs */
|
||||
model DAVICOM DM9102 0x0004 DM9102 10/100 media interface
|
||||
model xxDAVICOM DM9101 0x0000 DM9101 10/100 media interface
|
||||
|
||||
/* Integrated Circuit Systems PHYs */
|
||||
model xxICS 1889 0x0001 ICS1889 10/100 media interface
|
||||
model xxICS 1890 0x0002 ICS1890 10/100 media interface
|
||||
model xxICS 1892 0x0003 ICS1892 10/100 media interface
|
||||
model xxICS 1893 0x0004 ICS1893 10/100 media interface
|
||||
/* AMD Am79C873 seems to be a relabeled DM9101 */
|
||||
model xxDAVICOM DM9101 0x0000 DM9101 (AMD Am79C873) 10/100 media interface
|
||||
model xxDAVICOM DM9102 0x0004 DM9102 10/100 media interface
|
||||
model yyDAVICOM DM9101 0x0000 DM9101 10/100 media interface
|
||||
|
||||
/* IC Plus Corp. PHYs */
|
||||
model ICPLUS IP101 0x0005 IC Plus 10/100 PHY
|
||||
model ICPLUS IP1000A 0x0008 IC Plus 10/100/1000 media interface
|
||||
model ICPLUS IP1001 0x0019 IC Plus IP1001 10/100/1000 media interface
|
||||
model xxICPLUS IP101 0x0005 IP101 10/100 PHY
|
||||
model xxICPLUS IP1000A 0x0008 IP100A 10/100/1000 media interface
|
||||
model xxICPLUS IP1001 0x0019 IP1001 10/100/1000 media interface
|
||||
|
||||
/* Intel PHYs */
|
||||
model xxINTEL I82553AB 0x0000 i83553 10/100 media interface
|
||||
model INTEL I82555 0x0015 i82555 10/100 media interface
|
||||
model INTEL I82562EM 0x0032 i82562EM 10/100 media interface
|
||||
model INTEL I82562ET 0x0033 i82562ET 10/100 media interface
|
||||
model INTEL I82553C 0x0035 i82553 10/100 media interface
|
||||
/* Integrated Circuit Systems PHYs */
|
||||
model ICS 1889 0x0001 ICS1889 10/100 media interface
|
||||
model ICS 1890 0x0002 ICS1890 10/100 media interface
|
||||
model ICS 1892 0x0003 ICS1892 10/100 media interface
|
||||
model ICS 1893 0x0004 ICS1893 10/100 media interface
|
||||
|
||||
/* Intel Corporation PHYs */
|
||||
model xxINTEL I82553 0x0000 i82553 10/100 media interface
|
||||
model yyINTEL I82555 0x0015 i82555 10/100 media interface
|
||||
model yyINTEL I82562EH 0x0017 i82562EH HomePNA interface
|
||||
model yyINTEL I82562G 0x0031 i82562G 10/100 media interface
|
||||
model yyINTEL I82562EM 0x0032 i82562EM 10/100 media interface
|
||||
model yyINTEL I82562ET 0x0033 i82562ET 10/100 media interface
|
||||
model yyINTEL I82553 0x0035 i82553 10/100 media interface
|
||||
model yyINTEL I82566 0x0039 i82566 10/100/1000 media interface
|
||||
model INTEL I82577 0x0005 i82577 10/100/1000 media interface
|
||||
|
||||
/* Jato Technologies PHYs */
|
||||
model JATO BASEX 0x0000 Jato 1000baseX media interface
|
||||
model xxJATO BASEX 0x0000 Jato 1000baseX media interface
|
||||
|
||||
/* JMicron Technologies PHYs */
|
||||
model JMICRON JMP211 0x0021 JMP211 10/100/1000 media interface
|
||||
@ -202,66 +226,79 @@ model JMICRON JMP202 0x0022 JMP202 10/100 media interface
|
||||
|
||||
/* Level 1 PHYs */
|
||||
model xxLEVEL1 LXT970 0x0000 LXT970 10/100 media interface
|
||||
model LEVEL1 LXT971 0x000e LXT971/2 10/100 media interface
|
||||
model LEVEL1 LXT973 0x0021 LXT973 10/100 Dual PHY
|
||||
model LEVEL1 LXT974 0x0004 LXT974 10/100 Quad PHY
|
||||
model LEVEL1 LXT975 0x0005 LXT975 10/100 Quad PHY
|
||||
model LEVEL1 LXT1000_OLD 0x0003 LXT1000 1000BASE-T media interface
|
||||
model LEVEL1 LXT1000 0x000c LXT1000 1000BASE-T media interface
|
||||
|
||||
/* Marvell Semiconductor PHYs */
|
||||
model xxMARVELL E1000 0x0000 Marvell 88E1000 Gigabit PHY
|
||||
model xxMARVELL E1011 0x0002 Marvell 88E1011 Gigabit PHY
|
||||
model xxMARVELL E1000_3 0x0003 Marvell 88E1000 Gigabit PHY
|
||||
model xxMARVELL E1000S 0x0004 Marvell 88E1000S Gigabit PHY
|
||||
model xxMARVELL E1000_5 0x0005 Marvell 88E1000 Gigabit PHY
|
||||
model xxMARVELL E1101 0x0006 Marvell 88E1101 Gigabit PHY
|
||||
model xxMARVELL E3082 0x0008 Marvell 88E3082 10/100 Fast Ethernet PHY
|
||||
model xxMARVELL E1112 0x0009 Marvell 88E1112 Gigabit PHY
|
||||
model xxMARVELL E1149 0x000b Marvell 88E1149 Gigabit PHY
|
||||
model xxMARVELL E1111 0x000c Marvell 88E1111 Gigabit PHY
|
||||
model xxMARVELL E1116 0x0021 Marvell 88E1116 Gigabit PHY
|
||||
model xxMARVELL E1116R 0x0024 Marvell 88E1116R Gigabit PHY
|
||||
model xxMARVELL E1118 0x0022 Marvell 88E1118 Gigabit PHY
|
||||
model xxMARVELL E3016 0x0026 Marvell 88E3016 10/100 Fast Ethernet PHY
|
||||
model xxMARVELL PHYG65G 0x0027 Marvell PHYG65G Gigabit PHY
|
||||
model MARVELL E1000 0x0005 Marvell 88E1000 Gigabit PHY
|
||||
model MARVELL E1011 0x0002 Marvell 88E1011 Gigabit PHY
|
||||
model MARVELL E1000_3 0x0003 Marvell 88E1000 Gigabit PHY
|
||||
model MARVELL E1000_5 0x0005 Marvell 88E1000 Gigabit PHY
|
||||
model MARVELL E1111 0x000c Marvell 88E1111 Gigabit PHY
|
||||
|
||||
/* National Semiconductor PHYs */
|
||||
model NATSEMI DP83840 0x0000 DP83840 10/100 media interface
|
||||
model NATSEMI DP83843 0x0001 DP83843 10/100 media interface
|
||||
model NATSEMI DP83815 0x0002 DP83815 10/100 media interface
|
||||
model NATSEMI DP83847 0x0003 DP83847 10/100 media interface
|
||||
model NATSEMI DP83891 0x0005 DP83891 10/100/1000 media interface
|
||||
model NATSEMI DP83861 0x0006 DP83861 10/100/1000 media interface
|
||||
model NATSEMI DP83865 0x0007 DP83865 10/100/1000 media interface
|
||||
model xxNATSEMI DP83840 0x0000 DP83840 10/100 media interface
|
||||
model xxNATSEMI DP83843 0x0001 DP83843 10/100 media interface
|
||||
model xxNATSEMI DP83815 0x0002 DP83815 10/100 media interface
|
||||
model xxNATSEMI DP83847 0x0003 DP83847 10/100 media interface
|
||||
model xxNATSEMI DP83891 0x0005 DP83891 1000BASE-T media interface
|
||||
model xxNATSEMI DP83861 0x0006 DP83861 1000BASE-T media interface
|
||||
model xxNATSEMI DP83865 0x0007 DP83865 1000BASE-T media interface
|
||||
|
||||
/* PMC Sierra PHYs */
|
||||
model xxPMCSIERRA PM8351 0x0000 PM8351 OctalPHY Gigabit interface
|
||||
model xxPMCSIERRA2 PM8352 0x0002 PM8352 OctalPHY Gigabit interface
|
||||
model xxPMCSIERRA2 PM8353 0x0003 PM8353 QuadPHY Gigabit interface
|
||||
model PMCSIERRA PM8354 0x0004 PM8354 QuadPHY Gigabit interface
|
||||
|
||||
/* Quality Semiconductor PHYs */
|
||||
model QUALSEMI QS6612 0x0000 QS6612 10/100 media interface
|
||||
model xxQUALSEMI QS6612 0x0000 QS6612 10/100 media interface
|
||||
|
||||
/* RDC Semiconductor PHYs */
|
||||
model RDC R6040 0x0003 R6040 10/100 media interface
|
||||
|
||||
/* RealTek Semiconductor PHYs */
|
||||
model REALTEK RTL8201L 0x0020 RTL8201L 10/100 media interface
|
||||
model xxREALTEK RTL8305SC 0x0005 RTL8305SC 10/100 802.1q switch
|
||||
model xxREALTEK RTL8201E 0x0008 RTL8201E 10/100 media interface
|
||||
model xxREALTEK RTL8169S 0x0011 RTL8169S/8110S/8211B media interface
|
||||
/* RealTek Semicondctor PHYs */
|
||||
model yyREALTEK RTL8201L 0x0020 RTL8201L 10/100 media interface
|
||||
model xxREALTEK RTL8169S 0x0011 RTL8169S/8110S/8211 1000BASE-T media interface
|
||||
model REALTEK RTL8305SC 0x0005 RTL8305SC 10/100 802.1q switch
|
||||
model REALTEK RTL8201E 0x0008 RTL8201E 10/100 media interface
|
||||
model REALTEK RTL8169S 0x0011 RTL8169S/8110S/8211 1000BASE-T media interface
|
||||
|
||||
/* Seeq PHYs */
|
||||
model xxSEEQ 80220 0x0003 Seeq 80220 10/100 media interface
|
||||
model xxSEEQ 84220 0x0004 Seeq 84220 10/100 media interface
|
||||
/* Seeq Seeq PHYs */
|
||||
model SEEQ 80220 0x0003 Seeq 80220 10/100 media interface
|
||||
model SEEQ 84220 0x0004 Seeq 84220 10/100 media interface
|
||||
model SEEQ 80225 0x0008 Seeq 80225 10/100 media interface
|
||||
|
||||
/* Silicon Integrated Systems PHYs */
|
||||
model xxSIS 900 0x0000 SiS 900 10/100 media interface
|
||||
|
||||
/* SMSC PHYs */
|
||||
model SMSC LAN83C183 0x0004 SMSC LAN83C183 10/100 media interface
|
||||
|
||||
/* TDK */
|
||||
model TDK 78Q2120 0x0014 TDK 78Q2120 media interface
|
||||
model SIS 900 0x0000 SiS 900 10/100 media interface
|
||||
|
||||
/* Texas Instruments PHYs */
|
||||
model xxTI TLAN10T 0x0001 ThunderLAN 10baseT media interface
|
||||
model xxTI 100VGPMI 0x0002 ThunderLAN 100VG-AnyLan media interface
|
||||
model TI TLAN10T 0x0001 ThunderLAN 10BASE-T media interface
|
||||
model TI 100VGPMI 0x0002 ThunderLAN 100VG-AnyLan media interface
|
||||
model TI TNETE2101 0x0003 TNETE2101 media interface
|
||||
|
||||
/* XaQti Corp. PHYs. */
|
||||
model XAQTI XMACII 0x0000 XaQti Corp. XMAC II gigabit interface
|
||||
/* TDK Semiconductor PHYs */
|
||||
model xxTSC 78Q2120 0x0014 78Q2120 10/100 media interface
|
||||
model xxTSC 78Q2121 0x0015 78Q2121 100BASE-TX media interface
|
||||
|
||||
/* Marvell Semiconductor PHYs */
|
||||
model MARVELL E1000 0x0000 Marvell 88E1000 Gigabit PHY
|
||||
model MARVELL E1011 0x0002 Marvell 88E1011 Gigabit PHY
|
||||
model MARVELL E1000_3 0x0003 Marvell 88E1000 Gigabit PHY
|
||||
model MARVELL E1000S 0x0004 Marvell 88E1000S Gigabit PHY
|
||||
model MARVELL E1000_5 0x0005 Marvell 88E1000 Gigabit PHY
|
||||
model MARVELL E1101 0x0006 Marvell 88E1101 Gigabit PHY
|
||||
model MARVELL E3082 0x0008 Marvell 88E3082 10/100 Fast Ethernet PHY
|
||||
model MARVELL E1112 0x0009 Marvell 88E1112 Gigabit PHY
|
||||
model MARVELL E1149 0x000b Marvell 88E1149 Gigabit PHY
|
||||
model MARVELL E1111 0x000c Marvell 88E1111 Gigabit PHY
|
||||
model MARVELL E1116 0x0021 Marvell 88E1116 Gigabit PHY
|
||||
model MARVELL E1116R 0x0024 Marvell 88E1116R Gigabit PHY
|
||||
model MARVELL E1118 0x0022 Marvell 88E1118 Gigabit PHY
|
||||
model MARVELL E3016 0x0026 Marvell 88E3016 10/100 Fast Ethernet PHY
|
||||
model MARVELL PHYG65G 0x0027 Marvell PHYG65G Gigabit PHY
|
||||
model xxMARVELL E1000 0x0005 Marvell 88E1000 Gigabit PHY
|
||||
model xxMARVELL E1011 0x0002 Marvell 88E1011 Gigabit PHY
|
||||
model xxMARVELL E1000_3 0x0003 Marvell 88E1000 Gigabit PHY
|
||||
model xxMARVELL E1000_5 0x0005 Marvell 88E1000 Gigabit PHY
|
||||
model xxMARVELL E1111 0x000c Marvell 88E1111 Gigabit PHY
|
||||
/* XaQti Corp. PHYs */
|
||||
model xxXAQTI XMACII 0x0000 XaQti Corp. XMAC II gigabit interface
|
||||
|
@ -38,7 +38,7 @@
|
||||
#include <sys/queue.h>
|
||||
|
||||
/*
|
||||
* Media Independent Interface configuration defintions.
|
||||
* Media Independent Interface data structure defintions
|
||||
*/
|
||||
|
||||
struct mii_softc;
|
||||
@ -65,13 +65,13 @@ struct mii_data {
|
||||
* request is made.
|
||||
*/
|
||||
LIST_HEAD(mii_listhead, mii_softc) mii_phys;
|
||||
int mii_instance;
|
||||
u_int mii_instance;
|
||||
|
||||
/*
|
||||
* PHY driver fills this in with active media status.
|
||||
*/
|
||||
int mii_media_status;
|
||||
int mii_media_active;
|
||||
u_int mii_media_status;
|
||||
u_int mii_media_active;
|
||||
|
||||
/*
|
||||
* Calls from MII layer into network interface driver.
|
||||
@ -83,10 +83,13 @@ struct mii_data {
|
||||
typedef struct mii_data mii_data_t;
|
||||
|
||||
/*
|
||||
* This call is used by the MII layer to call into the PHY driver
|
||||
* to perform a `service request'.
|
||||
* Functions provided by the PHY to perform various functions.
|
||||
*/
|
||||
typedef int (*mii_downcall_t)(struct mii_softc *, struct mii_data *, int);
|
||||
struct mii_phy_funcs {
|
||||
int (*pf_service)(struct mii_softc *, struct mii_data *, int);
|
||||
void (*pf_status)(struct mii_softc *);
|
||||
void (*pf_reset)(struct mii_softc *);
|
||||
};
|
||||
|
||||
/*
|
||||
* Requests that can be made to the downcall.
|
||||
@ -105,26 +108,35 @@ struct mii_softc {
|
||||
|
||||
LIST_ENTRY(mii_softc) mii_list; /* entry on parent's PHY list */
|
||||
|
||||
int mii_phy; /* our MII address */
|
||||
int mii_inst; /* instance for ifmedia */
|
||||
uint32_t mii_mpd_oui; /* the PHY's OUI (MII_OUI())*/
|
||||
uint32_t mii_mpd_model; /* the PHY's model (MII_MODEL())*/
|
||||
uint32_t mii_mpd_rev; /* the PHY's revision (MII_REV())*/
|
||||
u_int mii_capmask; /* capability mask for BMSR */
|
||||
u_int mii_phy; /* our MII address */
|
||||
u_int mii_offset; /* first PHY, second PHY, etc. */
|
||||
u_int mii_inst; /* instance for ifmedia */
|
||||
|
||||
/* Our PHY functions. */
|
||||
const struct mii_phy_funcs *mii_funcs;
|
||||
|
||||
mii_downcall_t mii_service; /* our downcall */
|
||||
struct mii_data *mii_pdata; /* pointer to parent's mii_data */
|
||||
|
||||
int mii_flags; /* misc. flags; see below */
|
||||
int mii_capabilities; /* capabilities from BMSR */
|
||||
int mii_extcapabilities; /* extended capabilities */
|
||||
int mii_ticks; /* MII_TICK counter */
|
||||
int mii_anegticks; /* ticks before retrying aneg */
|
||||
int mii_media_active; /* last active media */
|
||||
int mii_media_status; /* last active status */
|
||||
u_int mii_flags; /* misc. flags; see below */
|
||||
u_int mii_capabilities; /* capabilities from BMSR */
|
||||
u_int mii_extcapabilities; /* extended capabilities */
|
||||
u_int mii_ticks; /* MII_TICK counter */
|
||||
u_int mii_anegticks; /* ticks before retrying aneg */
|
||||
u_int mii_media_active; /* last active media */
|
||||
u_int mii_media_status; /* last active status */
|
||||
};
|
||||
typedef struct mii_softc mii_softc_t;
|
||||
|
||||
/* mii_flags */
|
||||
#define MIIF_INITDONE 0x00000001 /* has been initialized (mii_data) */
|
||||
#define MIIF_NOISOLATE 0x00000002 /* do not isolate the PHY */
|
||||
#if 0
|
||||
#define MIIF_NOLOOP 0x00000004 /* no loopback capability */
|
||||
#endif
|
||||
#define MIIF_DOINGAUTO 0x00000008 /* doing autonegotiation (mii_softc) */
|
||||
#define MIIF_AUTOTSLEEP 0x00000010 /* use tsleep(), not callout() */
|
||||
#define MIIF_HAVEFIBER 0x00000020 /* from parent: has fiber interface */
|
||||
@ -161,10 +173,11 @@ typedef struct mii_softc mii_softc_t;
|
||||
*/
|
||||
struct mii_attach_args {
|
||||
struct mii_data *mii_data; /* pointer to parent data */
|
||||
int mii_phyno; /* MII address */
|
||||
int mii_id1; /* PHY ID register 1 */
|
||||
int mii_id2; /* PHY ID register 2 */
|
||||
int mii_capmask; /* capability mask from BMSR */
|
||||
u_int mii_phyno; /* MII address */
|
||||
u_int mii_offset; /* first PHY, second PHY, etc. */
|
||||
uint32_t mii_id1; /* PHY ID register 1 */
|
||||
uint32_t mii_id2; /* PHY ID register 2 */
|
||||
u_int mii_capmask; /* capability mask for BMSR */
|
||||
};
|
||||
typedef struct mii_attach_args mii_attach_args_t;
|
||||
|
||||
@ -172,8 +185,8 @@ typedef struct mii_attach_args mii_attach_args_t;
|
||||
* Used to match a PHY.
|
||||
*/
|
||||
struct mii_phydesc {
|
||||
u_int32_t mpd_oui; /* the PHY's OUI */
|
||||
u_int32_t mpd_model; /* the PHY's model */
|
||||
uint32_t mpd_oui; /* the PHY's OUI */
|
||||
uint32_t mpd_model; /* the PHY's model */
|
||||
const char *mpd_name; /* the PHY's name */
|
||||
};
|
||||
#define MII_PHY_DESC(a, b) { MII_OUI_ ## a, MII_MODEL_ ## a ## _ ## b, \
|
||||
@ -184,9 +197,9 @@ struct mii_phydesc {
|
||||
* An array of these structures map MII media types to BMCR/ANAR settings.
|
||||
*/
|
||||
struct mii_media {
|
||||
int mm_bmcr; /* BMCR settings for this media */
|
||||
int mm_anar; /* ANAR settings for this media */
|
||||
int mm_gtcr; /* 100base-T2 or 1000base-T CR */
|
||||
u_int mm_bmcr; /* BMCR settings for this media */
|
||||
u_int mm_anar; /* ANAR settings for this media */
|
||||
u_int mm_gtcr; /* 100base-T2 or 1000base-T CR */
|
||||
};
|
||||
|
||||
#define MII_MEDIA_NONE 0
|
||||
@ -209,6 +222,15 @@ struct mii_media {
|
||||
#define PHY_WRITE(p, r, v) \
|
||||
MIIBUS_WRITEREG((p)->mii_dev, (p)->mii_phy, (r), (v))
|
||||
|
||||
#define PHY_SERVICE(p, d, o) \
|
||||
(*(p)->mii_funcs->pf_service)((p), (d), (o))
|
||||
|
||||
#define PHY_STATUS(p) \
|
||||
(*(p)->mii_funcs->pf_status)(p)
|
||||
|
||||
#define PHY_RESET(p) \
|
||||
(*(p)->mii_funcs->pf_reset)(p)
|
||||
|
||||
enum miibus_device_ivars {
|
||||
MIIBUS_IVAR_FLAGS
|
||||
};
|
||||
@ -219,7 +241,7 @@ enum miibus_device_ivars {
|
||||
#define MIIBUS_ACCESSOR(var, ivar, type) \
|
||||
__BUS_ACCESSOR(miibus, var, MIIBUS, ivar, type)
|
||||
|
||||
MIIBUS_ACCESSOR(flags, FLAGS, int)
|
||||
MIIBUS_ACCESSOR(flags, FLAGS, u_int)
|
||||
|
||||
extern devclass_t miibus_devclass;
|
||||
extern driver_t miibus_driver;
|
||||
@ -250,8 +272,16 @@ const struct mii_phydesc * mii_phy_match(const struct mii_attach_args *ma,
|
||||
const struct mii_phydesc * mii_phy_match_gen(const struct mii_attach_args *ma,
|
||||
const struct mii_phydesc *mpd, size_t endlen);
|
||||
int mii_phy_dev_probe(device_t dev, const struct mii_phydesc *mpd, int mrv);
|
||||
void mii_phy_dev_attach(device_t dev, u_int flags,
|
||||
const struct mii_phy_funcs *mpf, int add_media);
|
||||
|
||||
void ukphy_status(struct mii_softc *);
|
||||
|
||||
u_int mii_oui(u_int, u_int);
|
||||
#define MII_OUI(id1, id2) mii_oui(id1, id2)
|
||||
#define MII_MODEL(id2) (((id2) & IDR2_MODEL) >> 4)
|
||||
#define MII_REV(id2) ((id2) & IDR2_REV)
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#endif /* _DEV_MII_MIIVAR_H_ */
|
||||
|
@ -102,6 +102,12 @@ static int mlphy_service(struct mii_softc *, struct mii_data *, int);
|
||||
static void mlphy_reset(struct mii_softc *);
|
||||
static void mlphy_status(struct mii_softc *);
|
||||
|
||||
static const struct mii_phy_funcs mlphy_funcs = {
|
||||
mlphy_service,
|
||||
mlphy_status,
|
||||
mlphy_reset
|
||||
};
|
||||
|
||||
static int
|
||||
mlphy_probe(dev)
|
||||
device_t dev;
|
||||
@ -137,37 +143,21 @@ mlphy_attach(dev)
|
||||
{
|
||||
struct mlphy_softc *msc;
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
|
||||
msc = device_get_softc(dev);
|
||||
sc = &msc->ml_mii;
|
||||
msc->ml_dev = dev;
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &mlphy_funcs, 0);
|
||||
|
||||
sc->mii_flags = miibus_get_flags(dev);
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = mlphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
PHY_RESET(sc);
|
||||
|
||||
#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
|
||||
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->mii_inst),
|
||||
MII_MEDIA_100_TX);
|
||||
|
||||
mii_phy_reset(sc);
|
||||
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & sc->mii_capmask;
|
||||
/* Let the companion PHY (if any) only handle the media we don't. */
|
||||
ma->mii_capmask = ~sc->mii_capabilities;
|
||||
sc->mii_capmask = ~sc->mii_capabilities;
|
||||
device_printf(dev, " ");
|
||||
mii_phy_add_media(sc);
|
||||
printf("\n");
|
||||
#undef ADD
|
||||
|
||||
MIIBUS_MEDIAINIT(sc->mii_dev);
|
||||
return (0);
|
||||
}
|
||||
@ -230,7 +220,7 @@ mlphy_service(xsc, mii, cmd)
|
||||
*/
|
||||
msc->ml_state = ML_STATE_AUTO_SELF;
|
||||
if (other != NULL) {
|
||||
mii_phy_reset(other);
|
||||
PHY_RESET(other);
|
||||
PHY_WRITE(other, MII_BMCR, BMCR_ISO);
|
||||
}
|
||||
(void)mii_phy_auto(sc);
|
||||
@ -247,7 +237,7 @@ mlphy_service(xsc, mii, cmd)
|
||||
* BMCR data is stored in the ifmedia entry.
|
||||
*/
|
||||
if (other != NULL) {
|
||||
mii_phy_reset(other);
|
||||
PHY_RESET(other);
|
||||
PHY_WRITE(other, MII_BMCR, ife->ifm_data);
|
||||
}
|
||||
mii_phy_setmedia(sc);
|
||||
@ -262,7 +252,7 @@ mlphy_service(xsc, mii, cmd)
|
||||
* BMCR data is stored in the ifmedia entry.
|
||||
*/
|
||||
if (other != NULL) {
|
||||
mii_phy_reset(other);
|
||||
PHY_RESET(other);
|
||||
PHY_WRITE(other, MII_BMCR, BMCR_ISO);
|
||||
}
|
||||
mii_phy_setmedia(sc);
|
||||
@ -307,7 +297,7 @@ mlphy_service(xsc, mii, cmd)
|
||||
if (reg & BMSR_LINK) {
|
||||
if (!msc->ml_linked) {
|
||||
msc->ml_linked = 1;
|
||||
mlphy_status(sc);
|
||||
PHY_STATUS(sc);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -321,10 +311,10 @@ mlphy_service(xsc, mii, cmd)
|
||||
sc->mii_ticks = 0;
|
||||
msc->ml_linked = 0;
|
||||
mii->mii_media_active = IFM_NONE;
|
||||
mii_phy_reset(sc);
|
||||
PHY_RESET(sc);
|
||||
msc->ml_state = ML_STATE_AUTO_SELF;
|
||||
if (other != NULL) {
|
||||
mii_phy_reset(other);
|
||||
PHY_RESET(other);
|
||||
PHY_WRITE(other, MII_BMCR, BMCR_ISO);
|
||||
}
|
||||
mii_phy_auto(sc);
|
||||
@ -337,7 +327,7 @@ mlphy_service(xsc, mii, cmd)
|
||||
other_inst = other->mii_inst;
|
||||
other->mii_inst = sc->mii_inst;
|
||||
if (IFM_INST(ife->ifm_media) == other->mii_inst)
|
||||
(void)(*other->mii_service)(other, mii, MII_POLLSTAT);
|
||||
(void)PHY_SERVICE(other, mii, MII_POLLSTAT);
|
||||
other->mii_inst = other_inst;
|
||||
sc->mii_media_active = other->mii_media_active;
|
||||
sc->mii_media_status = other->mii_media_status;
|
||||
@ -386,15 +376,15 @@ mlphy_status(sc)
|
||||
|
||||
if (IFM_SUBTYPE(mii->mii_media_active) != IFM_10_T) {
|
||||
msc->ml_state = ML_STATE_AUTO_SELF;
|
||||
mii_phy_reset(other);
|
||||
PHY_RESET(other);
|
||||
PHY_WRITE(other, MII_BMCR, BMCR_ISO);
|
||||
}
|
||||
|
||||
if (IFM_SUBTYPE(mii->mii_media_active) == IFM_10_T) {
|
||||
msc->ml_state = ML_STATE_AUTO_OTHER;
|
||||
mlphy_reset(&msc->ml_mii);
|
||||
PHY_RESET(&msc->ml_mii);
|
||||
PHY_WRITE(&msc->ml_mii, MII_BMCR, BMCR_ISO);
|
||||
mii_phy_reset(other);
|
||||
PHY_RESET(other);
|
||||
mii_phy_auto(other);
|
||||
}
|
||||
}
|
||||
|
@ -100,12 +100,18 @@ static int nsgphy_service(struct mii_softc *, struct mii_data *,int);
|
||||
static void nsgphy_status(struct mii_softc *);
|
||||
|
||||
static const struct mii_phydesc nsgphys[] = {
|
||||
MII_PHY_DESC(NATSEMI, DP83861),
|
||||
MII_PHY_DESC(NATSEMI, DP83865),
|
||||
MII_PHY_DESC(NATSEMI, DP83891),
|
||||
MII_PHY_DESC(xxNATSEMI, DP83861),
|
||||
MII_PHY_DESC(xxNATSEMI, DP83865),
|
||||
MII_PHY_DESC(xxNATSEMI, DP83891),
|
||||
MII_PHY_END
|
||||
};
|
||||
|
||||
static const struct mii_phy_funcs nsgphy_funcs = {
|
||||
nsgphy_service,
|
||||
nsgphy_status,
|
||||
mii_phy_reset
|
||||
};
|
||||
|
||||
static int
|
||||
nsgphy_probe(device_t dev)
|
||||
{
|
||||
@ -117,34 +123,19 @@ static int
|
||||
nsgphy_attach(device_t dev)
|
||||
{
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
ma = device_get_ivars(dev);
|
||||
if (bootverbose)
|
||||
device_printf(dev, "<rev. %d>\n", MII_REV(ma->mii_id2));
|
||||
device_printf(dev, " ");
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_flags = miibus_get_flags(dev);
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = nsgphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &nsgphy_funcs, 0);
|
||||
|
||||
sc->mii_flags |= MIIF_NOMANPAUSE;
|
||||
|
||||
mii_phy_reset(sc);
|
||||
PHY_RESET(sc);
|
||||
|
||||
/*
|
||||
* NB: the PHY has the 10BASE-T BMSR bits hard-wired to 0,
|
||||
* even though it supports 10BASE-T.
|
||||
*/
|
||||
sc->mii_capabilities = (PHY_READ(sc, MII_BMSR) |
|
||||
BMSR_10TFDX | BMSR_10THDX) & ma->mii_capmask;
|
||||
BMSR_10TFDX | BMSR_10THDX) & sc->mii_capmask;
|
||||
/*
|
||||
* Note that as documented manual 1000BASE-T modes of DP83865 only
|
||||
* work together with other National Semiconductor PHYs.
|
||||
@ -184,7 +175,7 @@ nsgphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
nsgphy_status(sc);
|
||||
PHY_STATUS(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
mii_phy_update(sc, cmd);
|
||||
|
@ -108,10 +108,16 @@ static void nsphy_status(struct mii_softc *);
|
||||
static void nsphy_reset(struct mii_softc *);
|
||||
|
||||
static const struct mii_phydesc nsphys[] = {
|
||||
MII_PHY_DESC(NATSEMI, DP83840),
|
||||
MII_PHY_DESC(xxNATSEMI, DP83840),
|
||||
MII_PHY_END
|
||||
};
|
||||
|
||||
static const struct mii_phy_funcs nsphy_funcs = {
|
||||
nsphy_service,
|
||||
nsphy_status,
|
||||
nsphy_reset
|
||||
};
|
||||
|
||||
static int
|
||||
nsphy_probe(device_t dev)
|
||||
{
|
||||
@ -122,52 +128,17 @@ nsphy_probe(device_t dev)
|
||||
static int
|
||||
nsphy_attach(device_t dev)
|
||||
{
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
const char *nic;
|
||||
u_int flags;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_flags = miibus_get_flags(dev);
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = nsphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
nic = device_get_name(device_get_parent(sc->mii_dev));
|
||||
nic = device_get_name(device_get_parent(device_get_parent(dev)));
|
||||
flags = MIIF_NOMANPAUSE;
|
||||
/*
|
||||
* Am79C971 wedge when isolating all of their external PHYs.
|
||||
*/
|
||||
if (strcmp(nic, "pcn") == 0)
|
||||
sc->mii_flags |= MIIF_NOISOLATE;
|
||||
|
||||
#if 1
|
||||
|
||||
#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
|
||||
|
||||
/*
|
||||
* XXX IFM_LOOP should be handled by mii_phy_add_media() based
|
||||
* on MIIF_NOLOOP.
|
||||
*/
|
||||
if ((sc->mii_flags & MIIF_NOLOOP) == 0)
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP,
|
||||
sc->mii_inst), MII_MEDIA_100_TX);
|
||||
|
||||
#endif
|
||||
|
||||
nsphy_reset(sc);
|
||||
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
device_printf(dev, " ");
|
||||
mii_phy_add_media(sc);
|
||||
printf("\n");
|
||||
|
||||
MIIBUS_MEDIAINIT(sc->mii_dev);
|
||||
flags |= MIIF_NOISOLATE;
|
||||
mii_phy_dev_attach(dev, flags, &nsphy_funcs, 1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -233,7 +204,7 @@ nsphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
nsphy_status(sc);
|
||||
PHY_STATUS(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
mii_phy_update(sc, cmd);
|
||||
@ -296,6 +267,9 @@ nsphy_status(struct mii_softc *sc)
|
||||
mii->mii_media_active |= IFM_10_T|IFM_HDX;
|
||||
else
|
||||
mii->mii_media_active |= IFM_NONE;
|
||||
if ((mii->mii_media_active & IFM_FDX) != 0)
|
||||
mii->mii_media_active |=
|
||||
mii_phy_flowstatus(sc);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -110,63 +110,31 @@ static int nsphyter_service(struct mii_softc *, struct mii_data *, int);
|
||||
static void nsphyter_status(struct mii_softc *);
|
||||
static void nsphyter_reset(struct mii_softc *);
|
||||
|
||||
static const struct mii_phydesc nsphys[] = {
|
||||
MII_PHY_DESC(NATSEMI, DP83815),
|
||||
MII_PHY_DESC(NATSEMI, DP83843),
|
||||
MII_PHY_DESC(NATSEMI, DP83847),
|
||||
static const struct mii_phydesc nsphyters[] = {
|
||||
MII_PHY_DESC(xxNATSEMI, DP83815),
|
||||
MII_PHY_DESC(xxNATSEMI, DP83843),
|
||||
MII_PHY_DESC(xxNATSEMI, DP83847),
|
||||
MII_PHY_END
|
||||
};
|
||||
|
||||
static const struct mii_phy_funcs nsphyter_funcs = {
|
||||
nsphyter_service,
|
||||
nsphyter_status,
|
||||
nsphyter_reset
|
||||
};
|
||||
|
||||
static int
|
||||
nsphyter_probe(device_t dev)
|
||||
{
|
||||
|
||||
return (mii_phy_dev_probe(dev, nsphys, BUS_PROBE_DEFAULT));
|
||||
return (mii_phy_dev_probe(dev, nsphyters, BUS_PROBE_DEFAULT));
|
||||
}
|
||||
|
||||
static int
|
||||
nsphyter_attach(device_t dev)
|
||||
{
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_flags = miibus_get_flags(dev);
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = nsphyter_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
sc->mii_flags |= MIIF_NOMANPAUSE;
|
||||
|
||||
#if 1
|
||||
|
||||
#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
|
||||
|
||||
/*
|
||||
* XXX IFM_LOOP should be handled by mii_phy_add_media() based
|
||||
* on MIIF_NOLOOP.
|
||||
*/
|
||||
if ((sc->mii_flags & MIIF_NOLOOP) == 0)
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP,
|
||||
sc->mii_inst), MII_MEDIA_100_TX);
|
||||
|
||||
#endif
|
||||
|
||||
nsphyter_reset(sc);
|
||||
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
device_printf(dev, " ");
|
||||
mii_phy_add_media(sc);
|
||||
printf("\n");
|
||||
|
||||
MIIBUS_MEDIAINIT(sc->mii_dev);
|
||||
mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &nsphyter_funcs, 1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -195,7 +163,7 @@ nsphyter_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
nsphyter_status(sc);
|
||||
PHY_STATUS(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
mii_phy_update(sc, cmd);
|
||||
|
@ -85,10 +85,16 @@ DRIVER_MODULE(pnaphy, miibus, pnaphy_driver, pnaphy_devclass, 0, 0);
|
||||
static int pnaphy_service(struct mii_softc *, struct mii_data *,int);
|
||||
|
||||
static const struct mii_phydesc pnaphys[] = {
|
||||
MII_PHY_DESC(AMD, 79c978),
|
||||
MII_PHY_DESC(yyAMD, 79c901home),
|
||||
MII_PHY_END
|
||||
};
|
||||
|
||||
static const struct mii_phy_funcs pnaphy_funcs = {
|
||||
pnaphy_service,
|
||||
ukphy_status,
|
||||
mii_phy_reset
|
||||
};
|
||||
|
||||
static int
|
||||
pnaphy_probe(device_t dev)
|
||||
{
|
||||
@ -99,32 +105,9 @@ pnaphy_probe(device_t dev)
|
||||
static int
|
||||
pnaphy_attach(device_t dev)
|
||||
{
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_flags = miibus_get_flags(dev);
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = pnaphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
sc->mii_flags |= MIIF_NOISOLATE | MIIF_NOLOOP | MIIF_IS_HPNA;
|
||||
|
||||
mii_phy_reset(sc);
|
||||
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
device_printf(dev, " ");
|
||||
mii_phy_add_media(sc);
|
||||
printf("\n");
|
||||
|
||||
MIIBUS_MEDIAINIT(sc->mii_dev);
|
||||
mii_phy_dev_attach(dev, MIIF_NOISOLATE | MIIF_IS_HPNA |
|
||||
MIIF_NOMANPAUSE, &pnaphy_funcs, 1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -160,7 +143,7 @@ pnaphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
ukphy_status(sc);
|
||||
PHY_STATUS(sc);
|
||||
if (IFM_SUBTYPE(mii->mii_media_active) == IFM_10_T)
|
||||
mii->mii_media_active = IFM_ETHER | IFM_HPNA_1;
|
||||
|
||||
|
@ -109,10 +109,16 @@ static void qsphy_reset(struct mii_softc *);
|
||||
static void qsphy_status(struct mii_softc *);
|
||||
|
||||
static const struct mii_phydesc qsphys[] = {
|
||||
MII_PHY_DESC(QUALSEMI, QS6612),
|
||||
MII_PHY_DESC(xxQUALSEMI, QS6612),
|
||||
MII_PHY_END
|
||||
};
|
||||
|
||||
static const struct mii_phy_funcs qsphy_funcs = {
|
||||
qsphy_service,
|
||||
qsphy_status,
|
||||
qsphy_reset
|
||||
};
|
||||
|
||||
static int
|
||||
qsphy_probe(device_t dev)
|
||||
{
|
||||
@ -123,30 +129,8 @@ qsphy_probe(device_t dev)
|
||||
static int
|
||||
qsphy_attach(device_t dev)
|
||||
{
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_flags = miibus_get_flags(dev);
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = qsphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
qsphy_reset(sc);
|
||||
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
device_printf(dev, " ");
|
||||
mii_phy_add_media(sc);
|
||||
printf("\n");
|
||||
|
||||
MIIBUS_MEDIAINIT(sc->mii_dev);
|
||||
mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &qsphy_funcs, 1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -182,7 +166,7 @@ qsphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
qsphy_status(sc);
|
||||
PHY_STATUS(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
mii_phy_update(sc, cmd);
|
||||
@ -238,6 +222,8 @@ qsphy_status(struct mii_softc *sc)
|
||||
mii->mii_media_active |= IFM_NONE;
|
||||
break;
|
||||
}
|
||||
if ((mii->mii_media_active & IFM_FDX) != 0)
|
||||
mii->mii_media_active |= mii_phy_flowstatus(sc);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -55,7 +55,6 @@ static device_attach_t rdcphy_attach;
|
||||
|
||||
struct rdcphy_softc {
|
||||
struct mii_softc mii_sc;
|
||||
int mii_model;
|
||||
int mii_link_tick;
|
||||
#define RDCPHY_MANNEG_TICK 3
|
||||
};
|
||||
@ -87,6 +86,12 @@ static const struct mii_phydesc rdcphys[] = {
|
||||
MII_PHY_END
|
||||
};
|
||||
|
||||
static const struct mii_phy_funcs rdcphy_funcs = {
|
||||
rdcphy_service,
|
||||
rdcphy_status,
|
||||
mii_phy_reset
|
||||
};
|
||||
|
||||
static int
|
||||
rdcphy_probe(device_t dev)
|
||||
{
|
||||
@ -97,40 +102,8 @@ rdcphy_probe(device_t dev)
|
||||
static int
|
||||
rdcphy_attach(device_t dev)
|
||||
{
|
||||
struct rdcphy_softc *rsc;
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
|
||||
rsc = device_get_softc(dev);
|
||||
sc = &rsc->mii_sc;
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_flags = miibus_get_flags(dev);
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = rdcphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
rsc->mii_model = MII_MODEL(ma->mii_id2);
|
||||
if (bootverbose)
|
||||
device_printf(dev, "OUI 0x%06x, model 0x%04x, rev. %d\n",
|
||||
MII_OUI(ma->mii_id1, ma->mii_id2), MII_MODEL(ma->mii_id2),
|
||||
MII_REV(ma->mii_id2));
|
||||
|
||||
mii_phy_reset(sc);
|
||||
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
if (sc->mii_capabilities & BMSR_EXTSTAT)
|
||||
sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR);
|
||||
device_printf(dev, " ");
|
||||
mii_phy_add_media(sc);
|
||||
printf("\n");
|
||||
|
||||
MIIBUS_MEDIAINIT(sc->mii_dev);
|
||||
mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &rdcphy_funcs, 1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -205,7 +178,7 @@ rdcphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
rdcphy_status(sc);
|
||||
PHY_STATUS(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
mii_phy_update(sc, cmd);
|
||||
|
@ -62,12 +62,6 @@ __FBSDID("$FreeBSD$");
|
||||
static int rgephy_probe(device_t);
|
||||
static int rgephy_attach(device_t);
|
||||
|
||||
struct rgephy_softc {
|
||||
struct mii_softc mii_sc;
|
||||
int mii_model;
|
||||
int mii_revision;
|
||||
};
|
||||
|
||||
static device_method_t rgephy_methods[] = {
|
||||
/* device interface */
|
||||
DEVMETHOD(device_probe, rgephy_probe),
|
||||
@ -82,7 +76,7 @@ static devclass_t rgephy_devclass;
|
||||
static driver_t rgephy_driver = {
|
||||
"rgephy",
|
||||
rgephy_methods,
|
||||
sizeof(struct rgephy_softc)
|
||||
sizeof(struct mii_softc)
|
||||
};
|
||||
|
||||
DRIVER_MODULE(rgephy, miibus, rgephy_driver, rgephy_devclass, 0, 0);
|
||||
@ -95,10 +89,16 @@ static void rgephy_loop(struct mii_softc *);
|
||||
static void rgephy_load_dspcode(struct mii_softc *);
|
||||
|
||||
static const struct mii_phydesc rgephys[] = {
|
||||
MII_PHY_DESC(xxREALTEK, RTL8169S),
|
||||
MII_PHY_DESC(REALTEK, RTL8169S),
|
||||
MII_PHY_END
|
||||
};
|
||||
|
||||
static const struct mii_phy_funcs rgephy_funcs = {
|
||||
rgephy_service,
|
||||
rgephy_status,
|
||||
rgephy_reset
|
||||
};
|
||||
|
||||
static int
|
||||
rgephy_probe(device_t dev)
|
||||
{
|
||||
@ -109,52 +109,30 @@ rgephy_probe(device_t dev)
|
||||
static int
|
||||
rgephy_attach(device_t dev)
|
||||
{
|
||||
struct rgephy_softc *rsc;
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
|
||||
rsc = device_get_softc(dev);
|
||||
sc = &rsc->mii_sc;
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
sc = device_get_softc(dev);
|
||||
|
||||
sc->mii_flags = miibus_get_flags(dev);
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = rgephy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
rsc->mii_model = MII_MODEL(ma->mii_id2);
|
||||
rsc->mii_revision = MII_REV(ma->mii_id2);
|
||||
|
||||
#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
|
||||
|
||||
#if 0
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->mii_inst),
|
||||
MII_MEDIA_100_TX);
|
||||
#endif
|
||||
mii_phy_dev_attach(dev, 0, &rgephy_funcs, 0);
|
||||
|
||||
/* RTL8169S do not report auto-sense; add manually. */
|
||||
sc->mii_capabilities = (PHY_READ(sc, MII_BMSR) | BMSR_ANEG) &
|
||||
ma->mii_capmask;
|
||||
sc->mii_capmask;
|
||||
if (sc->mii_capabilities & BMSR_EXTSTAT)
|
||||
sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR);
|
||||
device_printf(dev, " ");
|
||||
mii_phy_add_media(sc);
|
||||
printf("\n");
|
||||
#undef ADD
|
||||
/*
|
||||
* Allow IFM_FLAG0 to be set indicating that auto-negotiation with
|
||||
* manual configuration, which is used to work around issues with
|
||||
* certain setups by default, should not be triggered as it may in
|
||||
* turn cause harm in some edge cases.
|
||||
*/
|
||||
mii->mii_media.ifm_mask |= IFM_FLAG0;
|
||||
sc->mii_pdata->mii_media.ifm_mask |= IFM_FLAG0;
|
||||
|
||||
PHY_RESET(sc);
|
||||
|
||||
rgephy_reset(sc);
|
||||
MIIBUS_MEDIAINIT(sc->mii_dev);
|
||||
return (0);
|
||||
}
|
||||
@ -162,12 +140,9 @@ rgephy_attach(device_t dev)
|
||||
static int
|
||||
rgephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
{
|
||||
struct rgephy_softc *rsc;
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
int reg, speed, gig, anar;
|
||||
|
||||
rsc = (struct rgephy_softc *)sc;
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
break;
|
||||
@ -179,7 +154,7 @@ rgephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
|
||||
break;
|
||||
|
||||
rgephy_reset(sc); /* XXX hardware bug work-around */
|
||||
PHY_RESET(sc); /* XXX hardware bug work-around */
|
||||
|
||||
anar = PHY_READ(sc, RGEPHY_MII_ANAR);
|
||||
anar &= ~(RGEPHY_ANAR_PC | RGEPHY_ANAR_ASP |
|
||||
@ -268,7 +243,7 @@ rgephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
* Check to see if we have link. If we do, we don't
|
||||
* need to restart the autonegotiation process.
|
||||
*/
|
||||
if (rsc->mii_revision >= 2) {
|
||||
if (sc->mii_mpd_rev >= 2) {
|
||||
/* RTL8211B(L) */
|
||||
reg = PHY_READ(sc, RGEPHY_MII_SSR);
|
||||
if (reg & RGEPHY_SSR_LINK) {
|
||||
@ -297,7 +272,7 @@ rgephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
rgephy_status(sc);
|
||||
PHY_STATUS(sc);
|
||||
|
||||
/*
|
||||
* Callback if something changed. Note that we need to poke
|
||||
@ -316,7 +291,6 @@ rgephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
static void
|
||||
rgephy_status(struct mii_softc *sc)
|
||||
{
|
||||
struct rgephy_softc *rsc;
|
||||
struct mii_data *mii = sc->mii_pdata;
|
||||
int bmsr, bmcr;
|
||||
uint16_t ssr;
|
||||
@ -324,8 +298,7 @@ rgephy_status(struct mii_softc *sc)
|
||||
mii->mii_media_status = IFM_AVALID;
|
||||
mii->mii_media_active = IFM_ETHER;
|
||||
|
||||
rsc = (struct rgephy_softc *)sc;
|
||||
if (rsc->mii_revision >= 2) {
|
||||
if (sc->mii_mpd_rev >= 2) {
|
||||
ssr = PHY_READ(sc, RGEPHY_MII_SSR);
|
||||
if (ssr & RGEPHY_SSR_LINK)
|
||||
mii->mii_media_status |= IFM_ACTIVE;
|
||||
@ -355,7 +328,7 @@ rgephy_status(struct mii_softc *sc)
|
||||
}
|
||||
}
|
||||
|
||||
if (rsc->mii_revision >= 2) {
|
||||
if (sc->mii_mpd_rev >= 2) {
|
||||
ssr = PHY_READ(sc, RGEPHY_MII_SSR);
|
||||
switch (ssr & RGEPHY_SSR_SPD_MASK) {
|
||||
case RGEPHY_SSR_S1000:
|
||||
@ -405,7 +378,7 @@ rgephy_mii_phy_auto(struct mii_softc *sc, int media)
|
||||
int anar;
|
||||
|
||||
rgephy_loop(sc);
|
||||
rgephy_reset(sc);
|
||||
PHY_RESET(sc);
|
||||
|
||||
anar = BMSR_MEDIA_TO_ANAR(sc->mii_capabilities) | ANAR_CSMA;
|
||||
if ((media & IFM_FLOW) != 0 || (sc->mii_flags & MIIF_FORCEPAUSE) != 0)
|
||||
@ -425,11 +398,9 @@ rgephy_mii_phy_auto(struct mii_softc *sc, int media)
|
||||
static void
|
||||
rgephy_loop(struct mii_softc *sc)
|
||||
{
|
||||
struct rgephy_softc *rsc;
|
||||
int i;
|
||||
|
||||
rsc = (struct rgephy_softc *)sc;
|
||||
if (rsc->mii_revision < 2) {
|
||||
if (sc->mii_mpd_rev < 2) {
|
||||
PHY_WRITE(sc, RGEPHY_MII_BMCR, RGEPHY_BMCR_PDOWN);
|
||||
DELAY(1000);
|
||||
}
|
||||
@ -460,11 +431,9 @@ rgephy_loop(struct mii_softc *sc)
|
||||
static void
|
||||
rgephy_load_dspcode(struct mii_softc *sc)
|
||||
{
|
||||
struct rgephy_softc *rsc;
|
||||
int val;
|
||||
|
||||
rsc = (struct rgephy_softc *)sc;
|
||||
if (rsc->mii_revision >= 2)
|
||||
if (sc->mii_mpd_rev >= 2)
|
||||
return;
|
||||
|
||||
PHY_WRITE(sc, 31, 0x0001);
|
||||
@ -513,11 +482,9 @@ rgephy_load_dspcode(struct mii_softc *sc)
|
||||
static void
|
||||
rgephy_reset(struct mii_softc *sc)
|
||||
{
|
||||
struct rgephy_softc *rsc;
|
||||
uint16_t ssr;
|
||||
|
||||
rsc = (struct rgephy_softc *)sc;
|
||||
if (rsc->mii_revision == 3) {
|
||||
if (sc->mii_mpd_rev == 3) {
|
||||
/* RTL8211C(L) */
|
||||
ssr = PHY_READ(sc, RGEPHY_MII_SSR);
|
||||
if ((ssr & RGEPHY_SSR_ALDPS) != 0) {
|
||||
|
@ -57,11 +57,6 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include "miibus_if.h"
|
||||
|
||||
struct rlphy_softc {
|
||||
struct mii_softc sc_mii; /* generic PHY */
|
||||
int sc_is_RTL8201L; /* is an external RTL8201L PHY */
|
||||
};
|
||||
|
||||
static int rlphy_probe(device_t);
|
||||
static int rlphy_attach(device_t);
|
||||
|
||||
@ -79,7 +74,7 @@ static devclass_t rlphy_devclass;
|
||||
static driver_t rlphy_driver = {
|
||||
"rlphy",
|
||||
rlphy_methods,
|
||||
sizeof(struct rlphy_softc)
|
||||
sizeof(struct mii_softc)
|
||||
};
|
||||
|
||||
DRIVER_MODULE(rlphy, miibus, rlphy_driver, rlphy_devclass, 0, 0);
|
||||
@ -97,12 +92,18 @@ static const struct mii_phydesc rlintphys[] = {
|
||||
};
|
||||
|
||||
static const struct mii_phydesc rlphys[] = {
|
||||
MII_PHY_DESC(REALTEK, RTL8201L),
|
||||
MII_PHY_DESC(xxREALTEK, RTL8201E),
|
||||
MII_PHY_DESC(ICPLUS, IP101),
|
||||
MII_PHY_DESC(yyREALTEK, RTL8201L),
|
||||
MII_PHY_DESC(REALTEK, RTL8201E),
|
||||
MII_PHY_DESC(xxICPLUS, IP101),
|
||||
MII_PHY_END
|
||||
};
|
||||
|
||||
static const struct mii_phy_funcs rlphy_funcs = {
|
||||
rlphy_service,
|
||||
rlphy_status,
|
||||
mii_phy_reset
|
||||
};
|
||||
|
||||
static int
|
||||
rlphy_probe(device_t dev)
|
||||
{
|
||||
@ -122,50 +123,12 @@ rlphy_probe(device_t dev)
|
||||
static int
|
||||
rlphy_attach(device_t dev)
|
||||
{
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
struct rlphy_softc *rsc;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
|
||||
/*
|
||||
* Check whether we're the RTL8201L PHY and remember so the status
|
||||
* routine can query the proper register for speed detection.
|
||||
*/
|
||||
rsc = (struct rlphy_softc *)sc;
|
||||
if (mii_phy_dev_probe(dev, rlphys, 0) == 0)
|
||||
rsc->sc_is_RTL8201L++;
|
||||
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_flags = miibus_get_flags(dev);
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = rlphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
/*
|
||||
* The RealTek PHY can never be isolated.
|
||||
*/
|
||||
sc->mii_flags |= MIIF_NOISOLATE;
|
||||
|
||||
#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
|
||||
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->mii_inst),
|
||||
MII_MEDIA_100_TX);
|
||||
|
||||
mii_phy_reset(sc);
|
||||
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
device_printf(dev, " ");
|
||||
mii_phy_add_media(sc);
|
||||
printf("\n");
|
||||
#undef ADD
|
||||
MIIBUS_MEDIAINIT(sc->mii_dev);
|
||||
mii_phy_dev_attach(dev, MIIF_NOISOLATE | MIIF_NOMANPAUSE,
|
||||
&rlphy_funcs, 1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -202,7 +165,7 @@ rlphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
rlphy_status(sc);
|
||||
PHY_STATUS(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
mii_phy_update(sc, cmd);
|
||||
@ -212,7 +175,6 @@ rlphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
static void
|
||||
rlphy_status(struct mii_softc *phy)
|
||||
{
|
||||
struct rlphy_softc *rsc =(struct rlphy_softc *)phy;
|
||||
struct mii_data *mii = phy->mii_pdata;
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
int bmsr, bmcr, anlpar;
|
||||
@ -260,6 +222,9 @@ rlphy_status(struct mii_softc *phy)
|
||||
mii->mii_media_active |= IFM_10_T|IFM_HDX;
|
||||
else
|
||||
mii->mii_media_active |= IFM_NONE;
|
||||
if ((mii->mii_media_active & IFM_FDX) != 0)
|
||||
mii->mii_media_active |=
|
||||
mii_phy_flowstatus(phy);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
@ -280,16 +245,16 @@ rlphy_status(struct mii_softc *phy)
|
||||
* To determine the link speed, we have to do one
|
||||
* of two things:
|
||||
*
|
||||
* - If this is a standalone RealTek RTL8201(L) PHY,
|
||||
* we can determine the link speed by testing bit 0
|
||||
* in the magic, vendor-specific register at offset
|
||||
* 0x19.
|
||||
* - If this is a standalone RealTek RTL8201(L) or
|
||||
* workalike PHY, we can determine the link speed by
|
||||
* testing bit 0 in the magic, vendor-specific register
|
||||
* at offset 0x19.
|
||||
*
|
||||
* - If this is a RealTek MAC with integrated PHY, we
|
||||
* can test the 'SPEED10' bit of the MAC's media status
|
||||
* register.
|
||||
*/
|
||||
if (rsc->sc_is_RTL8201L) {
|
||||
if (!(phy->mii_mpd_model == 0 && phy->mii_mpd_rev == 0)) {
|
||||
if (PHY_READ(phy, 0x0019) & 0x01)
|
||||
mii->mii_media_active |= IFM_100_TX;
|
||||
else
|
||||
|
@ -91,10 +91,16 @@ static void rlswitch_phydump(device_t dev);
|
||||
#endif
|
||||
|
||||
static const struct mii_phydesc rlswitches[] = {
|
||||
MII_PHY_DESC(xxREALTEK, RTL8305SC),
|
||||
MII_PHY_DESC(REALTEK, RTL8305SC),
|
||||
MII_PHY_END
|
||||
};
|
||||
|
||||
static const struct mii_phy_funcs rlswitch_funcs = {
|
||||
rlswitch_service,
|
||||
rlswitch_status,
|
||||
mii_phy_reset
|
||||
};
|
||||
|
||||
static int
|
||||
rlswitch_probe(device_t dev)
|
||||
{
|
||||
@ -111,38 +117,19 @@ static int
|
||||
rlswitch_attach(device_t dev)
|
||||
{
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_flags = miibus_get_flags(dev);
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = rlswitch_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
/*
|
||||
* We handle all pseudo PHYs in a single instance.
|
||||
*/
|
||||
sc->mii_flags |= MIIF_NOISOLATE;
|
||||
mii_phy_dev_attach(dev, MIIF_NOISOLATE | MIIF_NOMANPAUSE,
|
||||
&rlswitch_funcs, 0);
|
||||
|
||||
#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
|
||||
|
||||
#if 0
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->mii_inst),
|
||||
MII_MEDIA_100_TX);
|
||||
#endif
|
||||
|
||||
sc->mii_capabilities = BMSR_100TXFDX & ma->mii_capmask;
|
||||
sc->mii_capabilities = BMSR_100TXFDX & sc->mii_capmask;
|
||||
device_printf(dev, " ");
|
||||
mii_phy_add_media(sc);
|
||||
printf("\n");
|
||||
#undef ADD
|
||||
#ifdef RL_DEBUG
|
||||
rlswitch_phydump(dev);
|
||||
#endif
|
||||
@ -375,7 +362,7 @@ rlswitch_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
rlswitch_status(sc);
|
||||
PHY_STATUS(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
// mii_phy_update(sc, cmd);
|
||||
@ -390,7 +377,8 @@ rlswitch_status(struct mii_softc *phy)
|
||||
mii->mii_media_status = IFM_AVALID;
|
||||
mii->mii_media_active = IFM_ETHER;
|
||||
mii->mii_media_status |= IFM_ACTIVE;
|
||||
mii->mii_media_active |= IFM_100_TX|IFM_FDX;
|
||||
mii->mii_media_active |=
|
||||
IFM_100_TX | IFM_FDX | mii_phy_flowstatus(phy);
|
||||
}
|
||||
|
||||
#ifdef RL_DEBUG
|
||||
|
@ -88,6 +88,12 @@ static const struct mii_phydesc ruephys[] = {
|
||||
MII_PHY_END
|
||||
};
|
||||
|
||||
static const struct mii_phy_funcs ruephy_funcs = {
|
||||
ruephy_service,
|
||||
ruephy_status,
|
||||
ruephy_reset
|
||||
};
|
||||
|
||||
static int
|
||||
ruephy_probe(device_t dev)
|
||||
{
|
||||
@ -101,35 +107,9 @@ ruephy_probe(device_t dev)
|
||||
static int
|
||||
ruephy_attach(device_t dev)
|
||||
{
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_flags = miibus_get_flags(dev);
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = ruephy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
/*
|
||||
* Apparently, we can neither isolate nor do loopback on this PHY.
|
||||
*/
|
||||
sc->mii_flags |= MIIF_NOISOLATE | MIIF_NOLOOP;
|
||||
|
||||
ruephy_reset(sc);
|
||||
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
device_printf(dev, " ");
|
||||
mii_phy_add_media(sc);
|
||||
printf("\n");
|
||||
|
||||
MIIBUS_MEDIAINIT(sc->mii_dev);
|
||||
mii_phy_dev_attach(dev, MIIF_NOISOLATE | MIIF_NOMANPAUSE,
|
||||
&ruephy_funcs, 1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -181,14 +161,14 @@ ruephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
break;
|
||||
|
||||
sc->mii_ticks = 0;
|
||||
ruephy_reset(sc);
|
||||
PHY_RESET(sc);
|
||||
if (mii_phy_auto(sc) == EJUSTRETURN)
|
||||
return (0);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
ruephy_status(sc);
|
||||
PHY_STATUS(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
mii_phy_update(sc, cmd);
|
||||
@ -244,7 +224,8 @@ ruephy_status(struct mii_softc *phy)
|
||||
mii->mii_media_active |= IFM_10_T;
|
||||
|
||||
if (msr & RUEPHY_MSR_DUPLEX)
|
||||
mii->mii_media_active |= IFM_FDX;
|
||||
mii->mii_media_active |=
|
||||
IFM_FDX | mii_phy_flowstatus(phy);
|
||||
else
|
||||
mii->mii_media_active |= IFM_HDX;
|
||||
} else
|
||||
|
@ -53,7 +53,7 @@ static int smcphy_probe(device_t);
|
||||
static int smcphy_attach(device_t);
|
||||
|
||||
static int smcphy_service(struct mii_softc *, struct mii_data *, int);
|
||||
static int smcphy_reset(struct mii_softc *);
|
||||
static void smcphy_reset(struct mii_softc *);
|
||||
static void smcphy_auto(struct mii_softc *, int);
|
||||
|
||||
static device_method_t smcphy_methods[] = {
|
||||
@ -77,10 +77,16 @@ static driver_t smcphy_driver = {
|
||||
DRIVER_MODULE(smcphy, miibus, smcphy_driver, smcphy_devclass, 0, 0);
|
||||
|
||||
static const struct mii_phydesc smcphys[] = {
|
||||
MII_PHY_DESC(SMSC, LAN83C183),
|
||||
MII_PHY_DESC(SEEQ, 84220),
|
||||
MII_PHY_END
|
||||
};
|
||||
|
||||
static const struct mii_phy_funcs smcphy_funcs = {
|
||||
smcphy_service,
|
||||
ukphy_status,
|
||||
smcphy_reset
|
||||
};
|
||||
|
||||
static int
|
||||
smcphy_probe(device_t dev)
|
||||
{
|
||||
@ -91,37 +97,12 @@ smcphy_probe(device_t dev)
|
||||
static int
|
||||
smcphy_attach(device_t dev)
|
||||
{
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
struct mii_softc *sc;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_flags = miibus_get_flags(dev);
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = smcphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
sc->mii_flags |= MIIF_NOISOLATE | MIIF_NOLOOP;
|
||||
|
||||
if (smcphy_reset(sc) != 0) {
|
||||
device_printf(dev, "reset failed\n");
|
||||
}
|
||||
|
||||
/* Mask interrupts, we poll instead. */
|
||||
PHY_WRITE(sc, 0x1e, 0xffc0);
|
||||
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
device_printf(dev, " ");
|
||||
mii_phy_add_media(sc);
|
||||
printf("\n");
|
||||
|
||||
MIIBUS_MEDIAINIT(sc->mii_dev);
|
||||
mii_phy_dev_attach(dev, MIIF_NOISOLATE | MIIF_NOMANPAUSE,
|
||||
&smcphy_funcs, 1);
|
||||
mii_phy_setmedia(sc);
|
||||
|
||||
return (0);
|
||||
@ -184,22 +165,20 @@ smcphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
}
|
||||
|
||||
sc->mii_ticks = 0;
|
||||
if (smcphy_reset(sc) != 0) {
|
||||
device_printf(sc->mii_dev, "reset failed\n");
|
||||
}
|
||||
PHY_RESET(sc);
|
||||
smcphy_auto(sc, ife->ifm_media);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
ukphy_status(sc);
|
||||
PHY_STATUS(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
mii_phy_update(sc, cmd);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
static void
|
||||
smcphy_reset(struct mii_softc *sc)
|
||||
{
|
||||
u_int bmcr;
|
||||
@ -214,12 +193,13 @@ smcphy_reset(struct mii_softc *sc)
|
||||
break;
|
||||
}
|
||||
|
||||
if (bmcr & BMCR_RESET) {
|
||||
return (EIO);
|
||||
}
|
||||
if (bmcr & BMCR_RESET)
|
||||
device_printf(sc->mii_dev, "reset failed\n");
|
||||
|
||||
PHY_WRITE(sc, MII_BMCR, 0x3000);
|
||||
return (0);
|
||||
|
||||
/* Mask interrupts, we poll instead. */
|
||||
PHY_WRITE(sc, 0x1e, 0xffc0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -88,10 +88,16 @@ static int tdkphy_service(struct mii_softc *, struct mii_data *, int);
|
||||
static void tdkphy_status(struct mii_softc *);
|
||||
|
||||
static const struct mii_phydesc tdkphys[] = {
|
||||
MII_PHY_DESC(TDK, 78Q2120),
|
||||
MII_PHY_DESC(xxTSC, 78Q2120),
|
||||
MII_PHY_END
|
||||
};
|
||||
|
||||
static const struct mii_phy_funcs tdkphy_funcs = {
|
||||
tdkphy_service,
|
||||
tdkphy_status,
|
||||
mii_phy_reset
|
||||
};
|
||||
|
||||
static int
|
||||
tdkphy_probe(device_t dev)
|
||||
{
|
||||
@ -102,39 +108,8 @@ tdkphy_probe(device_t dev)
|
||||
static int
|
||||
tdkphy_attach(device_t dev)
|
||||
{
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
sc = device_get_softc(dev);
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
if (bootverbose)
|
||||
device_printf(dev, "OUI 0x%06x, model 0x%04x, rev. %d\n",
|
||||
MII_OUI(ma->mii_id1, ma->mii_id2),
|
||||
MII_MODEL(ma->mii_id2), MII_REV(ma->mii_id2));
|
||||
|
||||
sc->mii_flags = miibus_get_flags(dev);
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = tdkphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
/*
|
||||
* 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_phy_add_media(sc);
|
||||
printf("\n");
|
||||
|
||||
MIIBUS_MEDIAINIT(sc->mii_dev);
|
||||
mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &tdkphy_funcs, 1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -163,7 +138,7 @@ tdkphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
tdkphy_status(sc);
|
||||
PHY_STATUS(sc);
|
||||
if (sc->mii_pdata->mii_media_active & IFM_FDX)
|
||||
PHY_WRITE(sc, MII_BMCR, PHY_READ(sc, MII_BMCR) | BMCR_FDX);
|
||||
else
|
||||
@ -247,6 +222,8 @@ tdkphy_status(struct mii_softc *phy)
|
||||
mii->mii_media_active |= IFM_10_T;
|
||||
}
|
||||
}
|
||||
if ((mii->mii_media_active & IFM_FDX) != 0)
|
||||
mii->mii_media_active |= mii_phy_flowstatus(phy);
|
||||
} else
|
||||
mii->mii_media_active = ife->ifm_media;
|
||||
}
|
||||
|
@ -113,13 +113,19 @@ DRIVER_MODULE(tlphy, miibus, tlphy_driver, tlphy_devclass, 0, 0);
|
||||
static int tlphy_service(struct mii_softc *, struct mii_data *, int);
|
||||
static int tlphy_auto(struct tlphy_softc *);
|
||||
static void tlphy_acomp(struct tlphy_softc *);
|
||||
static void tlphy_status(struct tlphy_softc *);
|
||||
static void tlphy_status(struct mii_softc *);
|
||||
|
||||
static const struct mii_phydesc tlphys[] = {
|
||||
MII_PHY_DESC(xxTI, TLAN10T),
|
||||
MII_PHY_DESC(TI, TLAN10T),
|
||||
MII_PHY_END
|
||||
};
|
||||
|
||||
static const struct mii_phy_funcs tlphy_funcs = {
|
||||
tlphy_service,
|
||||
tlphy_status,
|
||||
mii_phy_reset
|
||||
};
|
||||
|
||||
static int
|
||||
tlphy_probe(device_t dev)
|
||||
{
|
||||
@ -134,24 +140,13 @@ static int
|
||||
tlphy_attach(device_t dev)
|
||||
{
|
||||
device_t *devlist;
|
||||
struct tlphy_softc *sc;
|
||||
struct mii_softc *other;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
struct mii_softc *other, *sc_mii;
|
||||
const char *sep = "";
|
||||
int capmask, devs, i;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
ma = device_get_ivars(dev);
|
||||
sc->sc_mii.mii_dev = device_get_parent(dev);
|
||||
mii = device_get_softc(sc->sc_mii.mii_dev);
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, &sc->sc_mii, mii_list);
|
||||
sc_mii = device_get_softc(dev);
|
||||
|
||||
sc->sc_mii.mii_flags = miibus_get_flags(dev);
|
||||
sc->sc_mii.mii_inst = mii->mii_instance;
|
||||
sc->sc_mii.mii_phy = ma->mii_phyno;
|
||||
sc->sc_mii.mii_service = tlphy_service;
|
||||
sc->sc_mii.mii_pdata = mii;
|
||||
mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &tlphy_funcs, 0);
|
||||
|
||||
/*
|
||||
* Note that if we're on a device that also supports 100baseTX,
|
||||
@ -160,8 +155,8 @@ tlphy_attach(device_t dev)
|
||||
* UTP connector.
|
||||
*/
|
||||
capmask = BMSR_DEFCAPMASK;
|
||||
if (mii->mii_instance &&
|
||||
device_get_children(sc->sc_mii.mii_dev, &devlist, &devs) == 0) {
|
||||
if (sc_mii->mii_inst &&
|
||||
device_get_children(sc_mii->mii_dev, &devlist, &devs) == 0) {
|
||||
for (i = 0; i < devs; i++) {
|
||||
if (devlist[i] != dev) {
|
||||
other = device_get_softc(devlist[i]);
|
||||
@ -172,43 +167,38 @@ tlphy_attach(device_t dev)
|
||||
free(devlist, M_TEMP);
|
||||
}
|
||||
|
||||
mii->mii_instance++;
|
||||
PHY_RESET(sc_mii);
|
||||
|
||||
mii_phy_reset(&sc->sc_mii);
|
||||
|
||||
sc->sc_mii.mii_capabilities =
|
||||
PHY_READ(&sc->sc_mii, MII_BMSR) & capmask;
|
||||
|
||||
#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
|
||||
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_T, IFM_LOOP, sc->sc_mii.mii_inst),
|
||||
MII_MEDIA_100_TX);
|
||||
sc_mii->mii_capabilities = PHY_READ(sc_mii, MII_BMSR) & capmask;
|
||||
|
||||
#define ADD(m, c) \
|
||||
ifmedia_add(&sc_mii->mii_pdata->mii_media, (m), (c), NULL)
|
||||
#define PRINT(s) printf("%s%s", sep, s); sep = ", "
|
||||
|
||||
if ((sc->sc_mii.mii_flags & (MIIF_MACPRIV0 | MIIF_MACPRIV1)) != 0 &&
|
||||
(sc->sc_mii.mii_capabilities & BMSR_MEDIAMASK) != 0)
|
||||
if ((sc_mii->mii_flags & (MIIF_MACPRIV0 | MIIF_MACPRIV1)) != 0 &&
|
||||
(sc_mii->mii_capabilities & BMSR_MEDIAMASK) != 0)
|
||||
device_printf(dev, " ");
|
||||
if ((sc->sc_mii.mii_flags & MIIF_MACPRIV0) != 0) {
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_2, 0, sc->sc_mii.mii_inst),
|
||||
if ((sc_mii->mii_flags & MIIF_MACPRIV0) != 0) {
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_2, 0, sc_mii->mii_inst),
|
||||
0);
|
||||
PRINT("10base2/BNC");
|
||||
}
|
||||
if ((sc->sc_mii.mii_flags & MIIF_MACPRIV1) != 0) {
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_5, 0, sc->sc_mii.mii_inst),
|
||||
if ((sc_mii->mii_flags & MIIF_MACPRIV1) != 0) {
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_5, 0, sc_mii->mii_inst),
|
||||
0);
|
||||
PRINT("10base5/AUI");
|
||||
}
|
||||
if ((sc->sc_mii.mii_capabilities & BMSR_MEDIAMASK) != 0) {
|
||||
if ((sc_mii->mii_capabilities & BMSR_MEDIAMASK) != 0) {
|
||||
printf("%s", sep);
|
||||
mii_phy_add_media(&sc->sc_mii);
|
||||
mii_phy_add_media(sc_mii);
|
||||
}
|
||||
if ((sc->sc_mii.mii_flags & (MIIF_MACPRIV0 | MIIF_MACPRIV1)) != 0 &&
|
||||
(sc->sc_mii.mii_capabilities & BMSR_MEDIAMASK) != 0)
|
||||
if ((sc_mii->mii_flags & (MIIF_MACPRIV0 | MIIF_MACPRIV1)) != 0 &&
|
||||
(sc_mii->mii_capabilities & BMSR_MEDIAMASK) != 0)
|
||||
printf("\n");
|
||||
#undef ADD
|
||||
#undef PRINT
|
||||
MIIBUS_MEDIAINIT(sc->sc_mii.mii_dev);
|
||||
|
||||
MIIBUS_MEDIAINIT(sc_mii->mii_dev);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -287,13 +277,13 @@ tlphy_service(struct mii_softc *self, struct mii_data *mii, int cmd)
|
||||
break;
|
||||
|
||||
sc->sc_mii.mii_ticks = 0;
|
||||
mii_phy_reset(&sc->sc_mii);
|
||||
PHY_RESET(&sc->sc_mii);
|
||||
(void)tlphy_auto(sc);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
tlphy_status(sc);
|
||||
PHY_STATUS(self);
|
||||
|
||||
/* Callback if something changed. */
|
||||
mii_phy_update(&sc->sc_mii, cmd);
|
||||
@ -301,8 +291,9 @@ tlphy_service(struct mii_softc *self, struct mii_data *mii, int cmd)
|
||||
}
|
||||
|
||||
static void
|
||||
tlphy_status(struct tlphy_softc *sc)
|
||||
tlphy_status(struct mii_softc *self)
|
||||
{
|
||||
struct tlphy_softc *sc = (struct tlphy_softc *)self;
|
||||
struct mii_data *mii = sc->sc_mii.mii_pdata;
|
||||
int bmsr, bmcr, tlctrl;
|
||||
|
||||
@ -338,7 +329,7 @@ tlphy_status(struct tlphy_softc *sc)
|
||||
* just have to report what's in the BMCR.
|
||||
*/
|
||||
if (bmcr & BMCR_FDX)
|
||||
mii->mii_media_active |= IFM_FDX;
|
||||
mii->mii_media_active |= IFM_FDX | mii_phy_flowstatus(self);
|
||||
else
|
||||
mii->mii_media_active |= IFM_HDX;
|
||||
mii->mii_media_active |= IFM_10_T;
|
||||
|
@ -91,6 +91,12 @@ static driver_t truephy_driver = {
|
||||
|
||||
DRIVER_MODULE(truephy, miibus, truephy_driver, truephy_devclass, 0, 0);
|
||||
|
||||
static const struct mii_phy_funcs truephy_funcs = {
|
||||
truephy_service,
|
||||
truephy_status,
|
||||
truephy_reset
|
||||
};
|
||||
|
||||
static const struct truephy_dsp {
|
||||
uint16_t index;
|
||||
uint16_t data;
|
||||
@ -140,31 +146,15 @@ static int
|
||||
truephy_attach(device_t dev)
|
||||
{
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
ma = device_get_ivars(dev);
|
||||
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
mii_phy_dev_attach(dev, MIIF_NOISOLATE | MIIF_NOMANPAUSE,
|
||||
&truephy_funcs, 0);
|
||||
|
||||
sc->mii_flags = miibus_get_flags(dev);
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = truephy_service;
|
||||
sc->mii_pdata = mii;
|
||||
PHY_RESET(sc);
|
||||
|
||||
sc->mii_flags |= MIIF_NOISOLATE | MIIF_NOLOOP;
|
||||
|
||||
if (MII_MODEL(ma->mii_id2) == MII_MODEL_AGERE_ET1011)
|
||||
mii_phy_reset(sc);
|
||||
else
|
||||
truephy_reset(sc);
|
||||
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & sc->mii_capmask;
|
||||
if (sc->mii_capabilities & BMSR_EXTSTAT) {
|
||||
sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR);
|
||||
/* No 1000baseT half-duplex support */
|
||||
@ -210,7 +200,7 @@ truephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
|
||||
if (IFM_SUBTYPE(ife->ifm_media) == IFM_1000_T) {
|
||||
PHY_WRITE(sc, MII_BMCR,
|
||||
bmcr | BMCR_AUTOEN | BMCR_STARTNEG);
|
||||
bmcr | BMCR_AUTOEN | BMCR_STARTNEG);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -222,7 +212,7 @@ truephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
truephy_status(sc);
|
||||
PHY_STATUS(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
mii_phy_update(sc, cmd);
|
||||
@ -234,6 +224,11 @@ truephy_reset(struct mii_softc *sc)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (sc->mii_mpd_model == MII_MODEL_AGERE_ET1011) {
|
||||
mii_phy_reset(sc);
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < 2; ++i) {
|
||||
PHY_READ(sc, MII_PHYIDR1);
|
||||
PHY_READ(sc, MII_PHYIDR2);
|
||||
@ -326,7 +321,7 @@ truephy_status(struct mii_softc *sc)
|
||||
}
|
||||
|
||||
if (sr & TRUEPHY_SR_FDX)
|
||||
mii->mii_media_active |= IFM_FDX;
|
||||
mii->mii_media_active |= IFM_FDX | mii_phy_flowstatus(sc);
|
||||
else
|
||||
mii->mii_media_active |= IFM_HDX;
|
||||
}
|
||||
|
@ -101,6 +101,12 @@ DRIVER_MODULE(ukphy, miibus, ukphy_driver, ukphy_devclass, 0, 0);
|
||||
|
||||
static int ukphy_service(struct mii_softc *, struct mii_data *, int);
|
||||
|
||||
static const struct mii_phy_funcs ukphy_funcs = {
|
||||
ukphy_service,
|
||||
ukphy_status,
|
||||
mii_phy_reset
|
||||
};
|
||||
|
||||
static int
|
||||
ukphy_probe(device_t dev)
|
||||
{
|
||||
@ -116,38 +122,10 @@ static int
|
||||
ukphy_attach(device_t dev)
|
||||
{
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
if (bootverbose)
|
||||
device_printf(dev, "OUI 0x%06x, model 0x%04x, rev. %d\n",
|
||||
MII_OUI(ma->mii_id1, ma->mii_id2),
|
||||
MII_MODEL(ma->mii_id2), MII_REV(ma->mii_id2));
|
||||
|
||||
sc->mii_flags = miibus_get_flags(dev);
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = ukphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
sc->mii_flags |= MIIF_NOMANPAUSE;
|
||||
|
||||
mii_phy_reset(sc);
|
||||
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
if (sc->mii_capabilities & BMSR_EXTSTAT)
|
||||
sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR);
|
||||
device_printf(dev, " ");
|
||||
mii_phy_add_media(sc);
|
||||
printf("\n");
|
||||
|
||||
MIIBUS_MEDIAINIT(sc->mii_dev);
|
||||
mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &ukphy_funcs, 1);
|
||||
mii_phy_setmedia(sc);
|
||||
|
||||
return (0);
|
||||
@ -178,7 +156,7 @@ ukphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
ukphy_status(sc);
|
||||
PHY_STATUS(sc);
|
||||
|
||||
/* Callback if something changed. */
|
||||
mii_phy_update(sc, cmd);
|
||||
|
@ -84,11 +84,17 @@ static void xmphy_status(struct mii_softc *);
|
||||
static int xmphy_mii_phy_auto(struct mii_softc *);
|
||||
|
||||
static const struct mii_phydesc xmphys[] = {
|
||||
{ MII_OUI_xxXAQTI, MII_MODEL_XAQTI_XMACII, MII_STR_XAQTI_XMACII },
|
||||
MII_PHY_DESC(JATO, BASEX),
|
||||
MII_PHY_DESC(xxJATO, BASEX),
|
||||
MII_PHY_DESC(xxXAQTI, XMACII),
|
||||
MII_PHY_END
|
||||
};
|
||||
|
||||
static const struct mii_phy_funcs xmphy_funcs = {
|
||||
xmphy_service,
|
||||
xmphy_status,
|
||||
mii_phy_reset
|
||||
};
|
||||
|
||||
static int
|
||||
xmphy_probe(device_t dev)
|
||||
{
|
||||
@ -100,28 +106,17 @@ static int
|
||||
xmphy_attach(device_t dev)
|
||||
{
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
const char *sep = "";
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_flags = miibus_get_flags(dev);
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = xmphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
sc->mii_flags |= MIIF_NOISOLATE;
|
||||
mii_phy_dev_attach(dev, MIIF_NOISOLATE | MIIF_NOMANPAUSE,
|
||||
&xmphy_funcs, 0);
|
||||
sc->mii_anegticks = MII_ANEGTICKS;
|
||||
|
||||
mii_phy_reset(sc);
|
||||
PHY_RESET(sc);
|
||||
|
||||
#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
|
||||
#define ADD(m, c) ifmedia_add(&sc->mii_pdata->mii_media, (m), (c), NULL)
|
||||
#define PRINT(s) printf("%s%s", sep, s); sep = ", "
|
||||
|
||||
device_printf(dev, " ");
|
||||
@ -134,6 +129,7 @@ xmphy_attach(device_t dev)
|
||||
PRINT("auto");
|
||||
|
||||
printf("\n");
|
||||
|
||||
#undef ADD
|
||||
#undef PRINT
|
||||
|
||||
@ -170,7 +166,7 @@ xmphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
(void)xmphy_mii_phy_auto(sc);
|
||||
break;
|
||||
case IFM_1000_SX:
|
||||
mii_phy_reset(sc);
|
||||
PHY_RESET(sc);
|
||||
if ((ife->ifm_media & IFM_FDX) != 0) {
|
||||
PHY_WRITE(sc, XMPHY_MII_ANAR, XMPHY_ANAR_FDX);
|
||||
PHY_WRITE(sc, XMPHY_MII_BMCR, XMPHY_BMCR_FDX);
|
||||
@ -212,7 +208,7 @@ xmphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
|
||||
sc->mii_ticks = 0;
|
||||
|
||||
mii_phy_reset(sc);
|
||||
PHY_RESET(sc);
|
||||
xmphy_mii_phy_auto(sc);
|
||||
return (0);
|
||||
}
|
||||
@ -247,7 +243,6 @@ xmphy_status(struct mii_softc *sc)
|
||||
if (bmcr & XMPHY_BMCR_LOOP)
|
||||
mii->mii_media_active |= IFM_LOOP;
|
||||
|
||||
|
||||
if (bmcr & XMPHY_BMCR_AUTOEN) {
|
||||
if ((bmsr & XMPHY_BMSR_ACOMP) == 0) {
|
||||
if (bmsr & XMPHY_BMSR_LINK) {
|
||||
|
@ -3295,14 +3295,10 @@ nfe_set_linkspeed(struct nfe_softc *sc)
|
||||
break;
|
||||
}
|
||||
}
|
||||
phyno = 0;
|
||||
if (mii->mii_instance) {
|
||||
miisc = LIST_FIRST(&mii->mii_phys);
|
||||
phyno = miisc->mii_phy;
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
mii_phy_reset(miisc);
|
||||
} else
|
||||
return;
|
||||
miisc = LIST_FIRST(&mii->mii_phys);
|
||||
phyno = miisc->mii_phy;
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
PHY_RESET(miisc);
|
||||
nfe_miibus_writereg(sc->nfe_dev, phyno, MII_100T2CR, 0);
|
||||
nfe_miibus_writereg(sc->nfe_dev, phyno,
|
||||
MII_ANAR, ANAR_TX_FD | ANAR_TX | ANAR_10_FD | ANAR_10 | ANAR_CSMA);
|
||||
|
@ -2396,10 +2396,8 @@ nge_mediachange(struct ifnet *ifp)
|
||||
sc = ifp->if_softc;
|
||||
NGE_LOCK(sc);
|
||||
mii = device_get_softc(sc->nge_miibus);
|
||||
if (mii->mii_instance) {
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
mii_phy_reset(miisc);
|
||||
}
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
PHY_RESET(miisc);
|
||||
error = mii_mediachg(mii);
|
||||
NGE_UNLOCK(sc);
|
||||
|
||||
|
@ -1177,19 +1177,15 @@ nve_ifmedia_upd_locked(struct ifnet *ifp)
|
||||
{
|
||||
struct nve_softc *sc = ifp->if_softc;
|
||||
struct mii_data *mii;
|
||||
struct mii_softc *miisc;
|
||||
|
||||
DEBUGOUT(NVE_DEBUG_MII, "nve: nve_ifmedia_upd\n");
|
||||
|
||||
NVE_LOCK_ASSERT(sc);
|
||||
mii = device_get_softc(sc->miibus);
|
||||
|
||||
if (mii->mii_instance) {
|
||||
struct mii_softc *miisc;
|
||||
for (miisc = LIST_FIRST(&mii->mii_phys); miisc != NULL;
|
||||
miisc = LIST_NEXT(miisc, mii_list)) {
|
||||
mii_phy_reset(miisc);
|
||||
}
|
||||
}
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
PHY_RESET(miisc);
|
||||
mii_mediachg(mii);
|
||||
}
|
||||
|
||||
|
@ -634,14 +634,13 @@ pcn_attach(dev)
|
||||
ifp->if_snd.ifq_maxlen = PCN_TX_LIST_CNT - 1;
|
||||
|
||||
/*
|
||||
* Do MII setup. Note that loopback support isn't implemented.
|
||||
* Do MII setup.
|
||||
* See the comment in pcn_miibus_readreg() for why we can't
|
||||
* universally pass MIIF_NOISOLATE here.
|
||||
*/
|
||||
sc->pcn_extphyaddr = -1;
|
||||
error = mii_attach(dev, &sc->pcn_miibus, ifp, pcn_ifmedia_upd,
|
||||
pcn_ifmedia_sts, BMSR_DEFCAPMASK, MII_PHY_ANY, MII_OFFSET_ANY,
|
||||
MIIF_NOLOOP);
|
||||
pcn_ifmedia_sts, BMSR_DEFCAPMASK, MII_PHY_ANY, MII_OFFSET_ANY, 0);
|
||||
if (error != 0) {
|
||||
device_printf(dev, "attaching PHYs failed\n");
|
||||
goto fail;
|
||||
|
@ -528,17 +528,15 @@ sf_ifmedia_upd(struct ifnet *ifp)
|
||||
{
|
||||
struct sf_softc *sc;
|
||||
struct mii_data *mii;
|
||||
struct mii_softc *miisc;
|
||||
int error;
|
||||
|
||||
sc = ifp->if_softc;
|
||||
SF_LOCK(sc);
|
||||
|
||||
mii = device_get_softc(sc->sf_miibus);
|
||||
if (mii->mii_instance) {
|
||||
struct mii_softc *miisc;
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
mii_phy_reset(miisc);
|
||||
}
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
PHY_RESET(miisc);
|
||||
error = mii_mediachg(mii);
|
||||
SF_UNLOCK(sc);
|
||||
|
||||
|
@ -1715,16 +1715,14 @@ sge_ifmedia_upd(struct ifnet *ifp)
|
||||
{
|
||||
struct sge_softc *sc;
|
||||
struct mii_data *mii;
|
||||
struct mii_softc *miisc;
|
||||
int error;
|
||||
|
||||
sc = ifp->if_softc;
|
||||
SGE_LOCK(sc);
|
||||
mii = device_get_softc(sc->sge_miibus);
|
||||
if (mii->mii_instance) {
|
||||
struct mii_softc *miisc;
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
mii_phy_reset(miisc);
|
||||
}
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
PHY_RESET(miisc);
|
||||
error = mii_mediachg(mii);
|
||||
SGE_UNLOCK(sc);
|
||||
|
||||
|
@ -2209,17 +2209,15 @@ sis_ifmedia_upd(struct ifnet *ifp)
|
||||
{
|
||||
struct sis_softc *sc;
|
||||
struct mii_data *mii;
|
||||
struct mii_softc *miisc;
|
||||
int error;
|
||||
|
||||
sc = ifp->if_softc;
|
||||
|
||||
SIS_LOCK(sc);
|
||||
mii = device_get_softc(sc->sis_miibus);
|
||||
if (mii->mii_instance) {
|
||||
struct mii_softc *miisc;
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
mii_phy_reset(miisc);
|
||||
}
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
PHY_RESET(miisc);
|
||||
error = mii_mediachg(mii);
|
||||
SIS_UNLOCK(sc);
|
||||
|
||||
|
@ -458,10 +458,8 @@ ste_ifmedia_upd(struct ifnet *ifp)
|
||||
sc = ifp->if_softc;
|
||||
STE_LOCK(sc);
|
||||
mii = device_get_softc(sc->ste_miibus);
|
||||
if (mii->mii_instance) {
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
mii_phy_reset(miisc);
|
||||
}
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
PHY_RESET(miisc);
|
||||
error = mii_mediachg(mii);
|
||||
STE_UNLOCK(sc);
|
||||
|
||||
|
@ -1053,8 +1053,7 @@ epic_ifmedia_upd_locked(struct ifnet *ifp)
|
||||
sc->phyid = EPIC_UNKN_PHY;
|
||||
|
||||
/* Lookup selected PHY. */
|
||||
for (miisc = LIST_FIRST(&mii->mii_phys); miisc != NULL;
|
||||
miisc = LIST_NEXT(miisc, mii_list)) {
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list) {
|
||||
if (IFM_INST(media) == miisc->mii_inst) {
|
||||
sc->physc = miisc;
|
||||
break;
|
||||
@ -1071,12 +1070,12 @@ epic_ifmedia_upd_locked(struct ifnet *ifp)
|
||||
oui = MII_OUI(id1, id2);
|
||||
model = MII_MODEL(id2);
|
||||
switch (oui) {
|
||||
case MII_OUI_QUALSEMI:
|
||||
if (model == MII_MODEL_QUALSEMI_QS6612)
|
||||
case MII_OUI_xxQUALSEMI:
|
||||
if (model == MII_MODEL_xxQUALSEMI_QS6612)
|
||||
sc->phyid = EPIC_QS6612_PHY;
|
||||
break;
|
||||
case MII_OUI_xxALTIMA:
|
||||
if (model == MII_MODEL_xxALTIMA_AC101)
|
||||
case MII_OUI_ALTIMA:
|
||||
if (model == MII_MODEL_ALTIMA_AC101)
|
||||
sc->phyid = EPIC_AC101_PHY;
|
||||
break;
|
||||
case MII_OUI_xxLEVEL1:
|
||||
|
@ -1011,16 +1011,13 @@ aue_ifmedia_upd(struct ifnet *ifp)
|
||||
{
|
||||
struct aue_softc *sc = ifp->if_softc;
|
||||
struct mii_data *mii = GET_MII(sc);
|
||||
struct mii_softc *miisc;
|
||||
|
||||
AUE_LOCK_ASSERT(sc, MA_OWNED);
|
||||
|
||||
sc->sc_flags &= ~AUE_FLAG_LINK;
|
||||
if (mii->mii_instance) {
|
||||
struct mii_softc *miisc;
|
||||
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
mii_phy_reset(miisc);
|
||||
}
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
PHY_RESET(miisc);
|
||||
mii_mediachg(mii);
|
||||
return (0);
|
||||
}
|
||||
|
@ -417,16 +417,13 @@ axe_ifmedia_upd(struct ifnet *ifp)
|
||||
{
|
||||
struct axe_softc *sc = ifp->if_softc;
|
||||
struct mii_data *mii = GET_MII(sc);
|
||||
struct mii_softc *miisc;
|
||||
int error;
|
||||
|
||||
AXE_LOCK_ASSERT(sc, MA_OWNED);
|
||||
|
||||
if (mii->mii_instance) {
|
||||
struct mii_softc *miisc;
|
||||
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
mii_phy_reset(miisc);
|
||||
}
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
PHY_RESET(miisc);
|
||||
error = mii_mediachg(mii);
|
||||
return (error);
|
||||
}
|
||||
|
@ -868,16 +868,13 @@ rue_ifmedia_upd(struct ifnet *ifp)
|
||||
{
|
||||
struct rue_softc *sc = ifp->if_softc;
|
||||
struct mii_data *mii = GET_MII(sc);
|
||||
struct mii_softc *miisc;
|
||||
|
||||
RUE_LOCK_ASSERT(sc, MA_OWNED);
|
||||
|
||||
sc->sc_flags &= ~RUE_FLAG_LINK;
|
||||
if (mii->mii_instance) {
|
||||
struct mii_softc *miisc;
|
||||
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
mii_phy_reset(miisc);
|
||||
}
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
PHY_RESET(miisc);
|
||||
mii_mediachg(mii);
|
||||
return (0);
|
||||
}
|
||||
|
@ -732,16 +732,13 @@ udav_ifmedia_upd(struct ifnet *ifp)
|
||||
{
|
||||
struct udav_softc *sc = ifp->if_softc;
|
||||
struct mii_data *mii = GET_MII(sc);
|
||||
struct mii_softc *miisc;
|
||||
|
||||
UDAV_LOCK_ASSERT(sc, MA_OWNED);
|
||||
|
||||
sc->sc_flags &= ~UDAV_FLAG_LINK;
|
||||
if (mii->mii_instance) {
|
||||
struct mii_softc *miisc;
|
||||
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
mii_phy_reset(miisc);
|
||||
}
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
PHY_RESET(miisc);
|
||||
mii_mediachg(mii);
|
||||
return (0);
|
||||
}
|
||||
|
@ -2141,10 +2141,8 @@ vr_ifmedia_upd(struct ifnet *ifp)
|
||||
sc = ifp->if_softc;
|
||||
VR_LOCK(sc);
|
||||
mii = device_get_softc(sc->vr_miibus);
|
||||
if (mii->mii_instance) {
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
mii_phy_reset(miisc);
|
||||
}
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
PHY_RESET(miisc);
|
||||
error = mii_mediachg(mii);
|
||||
VR_UNLOCK(sc);
|
||||
|
||||
|
@ -312,10 +312,8 @@ vte_mediachange_locked(struct ifnet *ifp)
|
||||
|
||||
sc = ifp->if_softc;
|
||||
mii = device_get_softc(sc->vte_miibus);
|
||||
if (mii->mii_instance != 0) {
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
mii_phy_reset(miisc);
|
||||
}
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
PHY_RESET(miisc);
|
||||
error = mii_mediachg(mii);
|
||||
|
||||
return (error);
|
||||
|
@ -681,6 +681,7 @@ wb_reset(sc)
|
||||
{
|
||||
register int i;
|
||||
struct mii_data *mii;
|
||||
struct mii_softc *miisc;
|
||||
|
||||
CSR_WRITE_4(sc, WB_NETCFG, 0);
|
||||
CSR_WRITE_4(sc, WB_BUSCTL, 0);
|
||||
@ -705,16 +706,8 @@ wb_reset(sc)
|
||||
return;
|
||||
|
||||
mii = device_get_softc(sc->wb_miibus);
|
||||
if (mii == NULL)
|
||||
return;
|
||||
|
||||
if (mii->mii_instance) {
|
||||
struct mii_softc *miisc;
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
mii_phy_reset(miisc);
|
||||
}
|
||||
|
||||
return;
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
PHY_RESET(miisc);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -725,9 +718,6 @@ wb_fixmedia(sc)
|
||||
struct ifnet *ifp;
|
||||
u_int32_t media;
|
||||
|
||||
if (sc->wb_miibus == NULL)
|
||||
return;
|
||||
|
||||
mii = device_get_softc(sc->wb_miibus);
|
||||
ifp = sc->wb_ifp;
|
||||
|
||||
@ -742,8 +732,6 @@ wb_fixmedia(sc)
|
||||
return;
|
||||
|
||||
ifmedia_set(&mii->mii_media, media);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1179,10 +1179,8 @@ arge_ifmedia_upd(struct ifnet *ifp)
|
||||
sc = ifp->if_softc;
|
||||
ARGE_LOCK(sc);
|
||||
mii = device_get_softc(sc->arge_miibus);
|
||||
if (mii->mii_instance) {
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
mii_phy_reset(miisc);
|
||||
}
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
PHY_RESET(miisc);
|
||||
error = mii_mediachg(mii);
|
||||
ARGE_UNLOCK(sc);
|
||||
|
||||
|
@ -329,16 +329,12 @@ octe_mii_medchange(struct ifnet *ifp)
|
||||
{
|
||||
cvm_oct_private_t *priv;
|
||||
struct mii_data *mii;
|
||||
struct mii_softc *miisc;
|
||||
|
||||
priv = ifp->if_softc;
|
||||
mii = device_get_softc(priv->miibus);
|
||||
|
||||
if (mii->mii_instance) {
|
||||
struct mii_softc *miisc;
|
||||
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
mii_phy_reset(miisc);
|
||||
}
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
PHY_RESET(miisc);
|
||||
mii_mediachg(mii);
|
||||
|
||||
return (0);
|
||||
|
@ -925,10 +925,8 @@ kr_ifmedia_upd(struct ifnet *ifp)
|
||||
sc = ifp->if_softc;
|
||||
KR_LOCK(sc);
|
||||
mii = device_get_softc(sc->kr_miibus);
|
||||
if (mii->mii_instance) {
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
mii_phy_reset(miisc);
|
||||
}
|
||||
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
||||
PHY_RESET(miisc);
|
||||
error = mii_mediachg(mii);
|
||||
KR_UNLOCK(sc);
|
||||
|
||||
|
@ -14,7 +14,6 @@ SRCS+= xmphy.c
|
||||
|
||||
EXPORT_SYMS= mii_attach \
|
||||
mii_mediachg \
|
||||
mii_phy_reset \
|
||||
mii_pollstat \
|
||||
mii_tick
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user