diff options
author | marius <marius@FreeBSD.org> | 2006-12-02 15:32:34 +0000 |
---|---|---|
committer | marius <marius@FreeBSD.org> | 2006-12-02 15:32:34 +0000 |
commit | 923629baa0e29adb56de97ed5d8fd54e71cd3b49 (patch) | |
tree | 25749fe19f52ff6e7be4f3431382ac173c7c08fc | |
parent | 2db40ccfce7ea070a08fa10f3969ee21f4d49779 (diff) | |
download | FreeBSD-src-923629baa0e29adb56de97ed5d8fd54e71cd3b49.zip FreeBSD-src-923629baa0e29adb56de97ed5d8fd54e71cd3b49.tar.gz |
Add a helper function mii_phy_dev_probe(), which wraps around the
mii_phy_match() API and takes care of the PHY device probe based on
the struct mii_phydesc array and the match return value provided.
Convert PHY drivers to take advantage of mii_phy_dev_probe(),
converting drivers to provide a mii_phydesc table in the first
place where necessary.
Reviewed by: yongari
MFC after: 2 weeks
-rw-r--r-- | sys/dev/mii/acphy.c | 20 | ||||
-rw-r--r-- | sys/dev/mii/amphy.c | 22 | ||||
-rw-r--r-- | sys/dev/mii/bmtphy.c | 47 | ||||
-rw-r--r-- | sys/dev/mii/brgphy.c | 11 | ||||
-rw-r--r-- | sys/dev/mii/ciphy.c | 30 | ||||
-rw-r--r-- | sys/dev/mii/inphy.c | 42 | ||||
-rw-r--r-- | sys/dev/mii/ip1000phy.c | 14 | ||||
-rw-r--r-- | sys/dev/mii/lxtphy.c | 16 | ||||
-rw-r--r-- | sys/dev/mii/mii_physubr.c | 14 | ||||
-rw-r--r-- | sys/dev/mii/miivar.h | 1 | ||||
-rw-r--r-- | sys/dev/mii/nsgphy.c | 15 | ||||
-rw-r--r-- | sys/dev/mii/nsphy.c | 16 | ||||
-rw-r--r-- | sys/dev/mii/pnaphy.c | 20 | ||||
-rw-r--r-- | sys/dev/mii/qsphy.c | 16 | ||||
-rw-r--r-- | sys/dev/mii/rgephy.c | 16 | ||||
-rw-r--r-- | sys/dev/mii/rlphy.c | 29 | ||||
-rw-r--r-- | sys/dev/mii/tdkphy.c | 16 | ||||
-rw-r--r-- | sys/dev/mii/tlphy.c | 16 | ||||
-rw-r--r-- | sys/dev/mii/xmphy.c | 23 |
19 files changed, 135 insertions, 249 deletions
diff --git a/sys/dev/mii/acphy.c b/sys/dev/mii/acphy.c index 24af909..fd4c385 100644 --- a/sys/dev/mii/acphy.c +++ b/sys/dev/mii/acphy.c @@ -116,23 +116,17 @@ static int acphy_service(struct mii_softc *, struct mii_data *, int); 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_END +}; + static int acphy_probe(device_t dev) { - struct mii_attach_args *ma; - - ma = device_get_ivars(dev); - - if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_xxALTIMA && - MII_MODEL(ma->mii_id2) == MII_MODEL_xxALTIMA_AC101) { - device_set_desc(dev, MII_STR_xxALTIMA_AC101); - } else if(MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_xxALTIMA && - MII_MODEL(ma->mii_id2) == MII_MODEL_xxALTIMA_AC101L) { - device_set_desc(dev, MII_STR_xxALTIMA_AC101L); - } else - return (ENXIO); - return (BUS_PROBE_DEFAULT); + return (mii_phy_dev_probe(dev, acphys, BUS_PROBE_DEFAULT)); } static int diff --git a/sys/dev/mii/amphy.c b/sys/dev/mii/amphy.c index f50b0b7..cb32f13 100644 --- a/sys/dev/mii/amphy.c +++ b/sys/dev/mii/amphy.c @@ -82,25 +82,17 @@ DRIVER_MODULE(amphy, miibus, amphy_driver, amphy_devclass, 0, 0); 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(xxAMD, 79C873), + MII_PHY_DESC(xxDAVICOM, DM9101), + MII_PHY_END +}; + static int amphy_probe(device_t dev) { - struct mii_attach_args *ma; - - ma = device_get_ivars(dev); - - if ((MII_OUI(ma->mii_id1, ma->mii_id2) != MII_OUI_xxAMD || - MII_MODEL(ma->mii_id2) != MII_MODEL_xxAMD_79C873) && - (MII_OUI(ma->mii_id1, ma->mii_id2) != MII_OUI_xxDAVICOM || - MII_MODEL(ma->mii_id2) != MII_MODEL_xxDAVICOM_DM9101)) - return(ENXIO); - - if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_xxAMD) - device_set_desc(dev, MII_STR_xxAMD_79C873); - else if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_xxDAVICOM) - device_set_desc(dev, MII_STR_xxDAVICOM_DM9101); - return(BUS_PROBE_DEFAULT); + return (mii_phy_dev_probe(dev, amphys, BUS_PROBE_DEFAULT)); } static int diff --git a/sys/dev/mii/bmtphy.c b/sys/dev/mii/bmtphy.c index faf39b8..2217257 100644 --- a/sys/dev/mii/bmtphy.c +++ b/sys/dev/mii/bmtphy.c @@ -120,41 +120,30 @@ DRIVER_MODULE(bmtphy, miibus, bmtphy_driver, bmtphy_devclass, 0, 0); static int bmtphy_service(struct mii_softc *, struct mii_data *, int); static void bmtphy_status(struct mii_softc *); +static const struct mii_phydesc bmtphys_dp[] = { + MII_PHY_DESC(BROADCOM, BCM4401), + MII_PHY_DESC(BROADCOM, BCM5201), + MII_PHY_DESC(BROADCOM, BCM5221), + MII_PHY_END +}; + +static const struct mii_phydesc bmtphys_lp[] = { + MII_PHY_DESC(BROADCOM, 3C905B), + MII_PHY_DESC(BROADCOM, 3C905C), + MII_PHY_END +}; + static int bmtphy_probe(device_t dev) { - struct mii_attach_args *ma; int rval; - ma = device_get_ivars(dev); - rval = BUS_PROBE_DEFAULT; - - if (MII_OUI(ma->mii_id1, ma->mii_id2) != MII_OUI_BROADCOM) - return (ENXIO); - - switch (MII_MODEL(ma->mii_id2)) { - case MII_MODEL_BROADCOM_3C905B: - device_set_desc(dev, MII_STR_BROADCOM_3C905B); - rval = BUS_PROBE_LOW_PRIORITY; /* Let exphy take precedence. */ - break; - case MII_MODEL_BROADCOM_3C905C: - device_set_desc(dev, MII_STR_BROADCOM_3C905C); - rval = BUS_PROBE_LOW_PRIORITY; /* Let exphy take precedence. */ - break; - case MII_MODEL_BROADCOM_BCM5201: - device_set_desc(dev, MII_STR_BROADCOM_BCM5201); - break; - case MII_MODEL_BROADCOM_BCM5221: - device_set_desc(dev, MII_STR_BROADCOM_BCM5221); - break; - case MII_MODEL_BROADCOM_BCM4401: - device_set_desc(dev, MII_STR_BROADCOM_BCM4401); - break; - default: - return (ENXIO); - } + /* Let exphy(4) take precedence for these. */ + rval = mii_phy_dev_probe(dev, bmtphys_lp, BUS_PROBE_LOW_PRIORITY); + if (rval <= 0) + return (rval); - return (rval); + return (mii_phy_dev_probe(dev, bmtphys_dp, BUS_PROBE_DEFAULT)); } static int diff --git a/sys/dev/mii/brgphy.c b/sys/dev/mii/brgphy.c index f8464da..3a90aa0 100644 --- a/sys/dev/mii/brgphy.c +++ b/sys/dev/mii/brgphy.c @@ -118,17 +118,8 @@ static const struct mii_phydesc brgphys[] = { static int brgphy_probe(device_t dev) { - struct mii_attach_args *ma; - const struct mii_phydesc *mpd; - - ma = device_get_ivars(dev); - mpd = mii_phy_match(ma, brgphys); - if (mpd != NULL) { - device_set_desc(dev, mpd->mpd_name); - return (BUS_PROBE_DEFAULT); - } - return (ENXIO); + return (mii_phy_dev_probe(dev, brgphys, BUS_PROBE_DEFAULT)); } static int diff --git a/sys/dev/mii/ciphy.c b/sys/dev/mii/ciphy.c index dbd6b1d..ed601ad 100644 --- a/sys/dev/mii/ciphy.c +++ b/sys/dev/mii/ciphy.c @@ -88,32 +88,18 @@ static void ciphy_status(struct mii_softc *); 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_END +}; + static int ciphy_probe(device_t dev) { - struct mii_attach_args *ma; - - ma = device_get_ivars(dev); - - if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_CICADA && - MII_MODEL(ma->mii_id2) == MII_MODEL_CICADA_CS8201) { - device_set_desc(dev, MII_STR_CICADA_CS8201); - return (BUS_PROBE_DEFAULT); - } - - if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_CICADA && - MII_MODEL(ma->mii_id2) == MII_MODEL_CICADA_CS8201A) { - device_set_desc(dev, MII_STR_CICADA_CS8201A); - return (BUS_PROBE_DEFAULT); - } - - if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_CICADA && - MII_MODEL(ma->mii_id2) == MII_MODEL_CICADA_CS8201B) { - device_set_desc(dev, MII_STR_CICADA_CS8201B); - return (BUS_PROBE_DEFAULT); - } - return (ENXIO); + return (mii_phy_dev_probe(dev, ciphys, BUS_PROBE_DEFAULT)); } static int diff --git a/sys/dev/mii/inphy.c b/sys/dev/mii/inphy.c index fae1730..a8f2794 100644 --- a/sys/dev/mii/inphy.c +++ b/sys/dev/mii/inphy.c @@ -78,38 +78,20 @@ DRIVER_MODULE(inphy, miibus, inphy_driver, inphy_devclass, 0, 0); static int inphy_service(struct mii_softc *, struct mii_data *, int); static void inphy_status(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_END +}; + static int inphy_probe(device_t dev) { - struct mii_attach_args *ma; - ma = device_get_ivars(dev); - - /* Intel 82553 A/B steppings */ - if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_xxINTEL && - MII_MODEL(ma->mii_id2) == MII_MODEL_xxINTEL_I82553AB) { - device_set_desc(dev, MII_STR_xxINTEL_I82553AB); - return (BUS_PROBE_DEFAULT); - } - - if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_INTEL) { - switch (MII_MODEL(ma->mii_id2)) { - case MII_MODEL_INTEL_I82555: - device_set_desc(dev, MII_STR_INTEL_I82555); - return (BUS_PROBE_DEFAULT); - case MII_MODEL_INTEL_I82553C: - device_set_desc(dev, MII_STR_INTEL_I82553C); - return (BUS_PROBE_DEFAULT); - case MII_MODEL_INTEL_I82562EM: - device_set_desc(dev, MII_STR_INTEL_I82562EM); - return (BUS_PROBE_DEFAULT); - case MII_MODEL_INTEL_I82562ET: - device_set_desc(dev, MII_STR_INTEL_I82562ET); - return (BUS_PROBE_DEFAULT); - } - } - - return (ENXIO); + return (mii_phy_dev_probe(dev, inphys, BUS_PROBE_DEFAULT)); } static int @@ -131,10 +113,6 @@ inphy_attach(device_t dev) sc->mii_pdata = mii; mii->mii_instance++; -#if 0 - sc->mii_flags |= MIIF_NOISOLATE; -#endif - ifmedia_add(&mii->mii_media, IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->mii_inst), BMCR_LOOP|BMCR_S100, NULL); diff --git a/sys/dev/mii/ip1000phy.c b/sys/dev/mii/ip1000phy.c index 5b8e577..73f0ca2 100644 --- a/sys/dev/mii/ip1000phy.c +++ b/sys/dev/mii/ip1000phy.c @@ -40,7 +40,6 @@ __FBSDID("$FreeBSD$"); #include <sys/socket.h> #include <sys/bus.h> - #include <net/if.h> #include <net/if_media.h> @@ -89,17 +88,8 @@ static const struct mii_phydesc ip1000phys[] = { static int ip1000phy_probe(device_t dev) { - struct mii_attach_args *ma; - const struct mii_phydesc *mpd; - - ma = device_get_ivars(dev); - mpd = mii_phy_match(ma, ip1000phys); - if (mpd != NULL) { - device_set_desc(dev, mpd->mpd_name); - return (BUS_PROBE_DEFAULT); - } - return (ENXIO); + return (mii_phy_dev_probe(dev, ip1000phys, BUS_PROBE_DEFAULT)); } static int @@ -237,7 +227,7 @@ ip1000phy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) PHY_WRITE(sc, IP1000PHY_MII_BMCR, speed); /* - * When settning the link manually, one side must + * When setting the link manually, one side must * be the master and the other the slave. However * ifmedia doesn't give us a good way to specify * this, so we fake it by using one of the LINK diff --git a/sys/dev/mii/lxtphy.c b/sys/dev/mii/lxtphy.c index 77af3c2..5d23203 100644 --- a/sys/dev/mii/lxtphy.c +++ b/sys/dev/mii/lxtphy.c @@ -121,20 +121,16 @@ static void lxtphy_status(struct mii_softc *); static void lxtphy_set_tp(struct mii_softc *); static void lxtphy_set_fx(struct mii_softc *); +static const struct mii_phydesc lxtphys[] = { + MII_PHY_DESC(xxLEVEL1, LXT970), + MII_PHY_END +}; + static int lxtphy_probe(device_t dev) { - struct mii_attach_args *ma; - - ma = device_get_ivars(dev); - - if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_xxLEVEL1 && - MII_MODEL(ma->mii_id2) == MII_MODEL_xxLEVEL1_LXT970) { - device_set_desc(dev, MII_STR_xxLEVEL1_LXT970); - } else - return (ENXIO); - return (BUS_PROBE_DEFAULT); + return (mii_phy_dev_probe(dev, lxtphys, BUS_PROBE_DEFAULT)); } static int diff --git a/sys/dev/mii/mii_physubr.c b/sys/dev/mii/mii_physubr.c index dd81f4a..dd82677 100644 --- a/sys/dev/mii/mii_physubr.c +++ b/sys/dev/mii/mii_physubr.c @@ -52,7 +52,6 @@ __FBSDID("$FreeBSD$"); #include <sys/module.h> #include <sys/bus.h> - #include <net/if.h> #include <net/if_media.h> @@ -562,3 +561,16 @@ mii_phy_match(const struct mii_attach_args *ma, const struct mii_phydesc *mpd) return (mii_phy_match_gen(ma, mpd, sizeof(struct mii_phydesc))); } + +int +mii_phy_dev_probe(device_t dev, const struct mii_phydesc *mpd, int mrv) +{ + + mpd = mii_phy_match(device_get_ivars(dev), mpd); + if (mpd != NULL) { + device_set_desc(dev, mpd->mpd_name); + return (mrv); + } + + return (ENXIO); +} diff --git a/sys/dev/mii/miivar.h b/sys/dev/mii/miivar.h index ae4e18a..33ce299 100644 --- a/sys/dev/mii/miivar.h +++ b/sys/dev/mii/miivar.h @@ -229,6 +229,7 @@ const struct mii_phydesc * mii_phy_match(const struct mii_attach_args *ma, const struct mii_phydesc *mpd); 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 ukphy_status(struct mii_softc *); #endif /* _KERNEL */ diff --git a/sys/dev/mii/nsgphy.c b/sys/dev/mii/nsgphy.c index 8748b66..d7db537 100644 --- a/sys/dev/mii/nsgphy.c +++ b/sys/dev/mii/nsgphy.c @@ -61,7 +61,6 @@ __FBSDID("$FreeBSD$"); #include <sys/socket.h> #include <sys/bus.h> - #include <net/if.h> #include <net/if_media.h> @@ -93,13 +92,12 @@ static driver_t nsgphy_driver = { sizeof(struct mii_softc) }; - DRIVER_MODULE(nsgphy, miibus, nsgphy_driver, nsgphy_devclass, 0, 0); static int nsgphy_service(struct mii_softc *, struct mii_data *,int); static void nsgphy_status(struct mii_softc *); -const struct mii_phydesc gphyters[] = { +static const struct mii_phydesc nsgphys[] = { MII_PHY_DESC(NATSEMI, DP83861), MII_PHY_DESC(NATSEMI, DP83891), MII_PHY_END @@ -108,17 +106,8 @@ const struct mii_phydesc gphyters[] = { static int nsgphy_probe(device_t dev) { - struct mii_attach_args *ma; - const struct mii_phydesc *mpd; - - ma = device_get_ivars(dev); - mpd = mii_phy_match(ma, gphyters); - if (mpd != NULL) { - device_set_desc(dev, mpd->mpd_name); - return (BUS_PROBE_DEFAULT); - } - return (ENXIO); + return (mii_phy_dev_probe(dev, nsgphys, BUS_PROBE_DEFAULT)); } static int diff --git a/sys/dev/mii/nsphy.c b/sys/dev/mii/nsphy.c index c15a814..49796e8 100644 --- a/sys/dev/mii/nsphy.c +++ b/sys/dev/mii/nsphy.c @@ -119,20 +119,16 @@ static int nsphy_service(struct mii_softc *, struct mii_data *, int); 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_END +}; + static int nsphy_probe(device_t dev) { - struct mii_attach_args *ma; - - ma = device_get_ivars(dev); - - if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_NATSEMI && - MII_MODEL(ma->mii_id2) == MII_MODEL_NATSEMI_DP83840) { - device_set_desc(dev, MII_STR_NATSEMI_DP83840); - } else - return (ENXIO); - return (BUS_PROBE_DEFAULT); + return (mii_phy_dev_probe(dev, nsphys, BUS_PROBE_DEFAULT)); } static int diff --git a/sys/dev/mii/pnaphy.c b/sys/dev/mii/pnaphy.c index e7db926..d37ffaf 100644 --- a/sys/dev/mii/pnaphy.c +++ b/sys/dev/mii/pnaphy.c @@ -54,7 +54,6 @@ __FBSDID("$FreeBSD$"); #include <net/if.h> #include <net/if_media.h> - #include <dev/mii/mii.h> #include <dev/mii/miivar.h> #include "miidevs.h" @@ -85,21 +84,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_END +}; + static int pnaphy_probe(device_t dev) { - struct mii_attach_args *ma; - - ma = device_get_ivars(dev); - - if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_AMD && - MII_MODEL(ma->mii_id2) == MII_MODEL_AMD_79c978) { - device_set_desc(dev, MII_STR_AMD_79c978); - return(BUS_PROBE_DEFAULT); - } - - return(ENXIO); + return (mii_phy_dev_probe(dev, pnaphys, BUS_PROBE_DEFAULT)); } static int @@ -149,7 +143,7 @@ pnaphy_attach(device_t dev) MIIBUS_MEDIAINIT(sc->mii_dev); - return(0); + return (0); } static int diff --git a/sys/dev/mii/qsphy.c b/sys/dev/mii/qsphy.c index 1d61cef..2bed7b3 100644 --- a/sys/dev/mii/qsphy.c +++ b/sys/dev/mii/qsphy.c @@ -120,20 +120,16 @@ static int qsphy_service(struct mii_softc *, struct mii_data *, int); 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_END +}; + static int qsphy_probe(device_t dev) { - struct mii_attach_args *ma; - - ma = device_get_ivars(dev); - - if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_QUALSEMI && - MII_MODEL(ma->mii_id2) == MII_MODEL_QUALSEMI_QS6612) { - device_set_desc(dev, MII_STR_QUALSEMI_QS6612); - } else - return (ENXIO); - return (BUS_PROBE_DEFAULT); + return (mii_phy_dev_probe(dev, qsphys, BUS_PROBE_DEFAULT)); } static int diff --git a/sys/dev/mii/rgephy.c b/sys/dev/mii/rgephy.c index ffee835..c5c35a1 100644 --- a/sys/dev/mii/rgephy.c +++ b/sys/dev/mii/rgephy.c @@ -90,20 +90,16 @@ static void rgephy_loop(struct mii_softc *); static void rgephy_load_dspcode(struct mii_softc *); static int rgephy_mii_model; +static const struct mii_phydesc rgephys[] = { + MII_PHY_DESC(xxREALTEK, RTL8169S), + MII_PHY_END +}; + static int rgephy_probe(device_t dev) { - struct mii_attach_args *ma; - - ma = device_get_ivars(dev); - - if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_xxREALTEK && - MII_MODEL(ma->mii_id2) == MII_MODEL_xxREALTEK_RTL8169S) { - device_set_desc(dev, MII_STR_xxREALTEK_RTL8169S); - return(BUS_PROBE_DEFAULT); - } - return(ENXIO); + return (mii_phy_dev_probe(dev, rgephys, BUS_PROBE_DEFAULT)); } static int diff --git a/sys/dev/mii/rlphy.c b/sys/dev/mii/rlphy.c index 3541198..f672000 100644 --- a/sys/dev/mii/rlphy.c +++ b/sys/dev/mii/rlphy.c @@ -82,26 +82,27 @@ DRIVER_MODULE(rlphy, miibus, rlphy_driver, rlphy_devclass, 0, 0); static int rlphy_service(struct mii_softc *, struct mii_data *, int); static void rlphy_status(struct mii_softc *); +static const struct mii_phydesc rlphys[] = { + MII_PHY_DESC(REALTEK, RTL8201L), + MII_PHY_END +}; + static int rlphy_probe(device_t dev) { struct mii_attach_args *ma; - device_t parent; - - ma = device_get_ivars(dev); - parent = device_get_parent(device_get_parent(dev)); + const char *nic; + int rv; - /* Test for RealTek 8201L PHY */ - if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_REALTEK && - MII_MODEL(ma->mii_id2) == MII_MODEL_REALTEK_RTL8201L) { - device_set_desc(dev, MII_STR_REALTEK_RTL8201L); - return (BUS_PROBE_DEFAULT); - } + rv = mii_phy_dev_probe(dev, rlphys, BUS_PROBE_DEFAULT); + if (rv <= 0) + return (rv); /* - * RealTek PHY doesn't have vendor/device ID registers: - * the rl driver fakes up a return value of all zeros. + * RealTek interal PHYs don't have vendor/device ID registers; + * the `re' and `rl' drivers fake up a return value of all zeros. */ + ma = device_get_ivars(dev); if (MII_OUI(ma->mii_id1, ma->mii_id2) != 0 || MII_MODEL(ma->mii_id2) != 0) return (ENXIO); @@ -109,8 +110,8 @@ rlphy_probe(device_t dev) /* * Make sure the parent is an `rl' or an `re'. */ - if (strcmp(device_get_name(parent), "rl") != 0 && - strcmp(device_get_name(parent), "re") != 0) + nic = device_get_name(device_get_parent(device_get_parent(dev))); + if (strcmp(nic, "rl") != 0 && strcmp(nic, "re") != 0) return (ENXIO); device_set_desc(dev, "RealTek internal media interface"); diff --git a/sys/dev/mii/tdkphy.c b/sys/dev/mii/tdkphy.c index 1ac7e6f..2e89c2d 100644 --- a/sys/dev/mii/tdkphy.c +++ b/sys/dev/mii/tdkphy.c @@ -54,7 +54,6 @@ __FBSDID("$FreeBSD$"); #include <net/if.h> #include <net/if_media.h> - #include <dev/mii/mii.h> #include <dev/mii/miivar.h> #include "miidevs.h" @@ -95,17 +94,16 @@ DRIVER_MODULE(tdkphy, miibus, tdkphy_driver, tdkphy_devclass, 0, 0); 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_END +}; + static int tdkphy_probe(device_t dev) { - struct mii_attach_args *ma; - ma = device_get_ivars(dev); - if ((MII_OUI(ma->mii_id1, ma->mii_id2) != MII_OUI_TDK || - MII_MODEL(ma->mii_id2) != MII_MODEL_TDK_78Q2120)) - return (ENXIO); - - device_set_desc(dev, MII_STR_TDK_78Q2120); - return (BUS_PROBE_DEFAULT); + + return (mii_phy_dev_probe(dev, tdkphys, BUS_PROBE_DEFAULT)); } static int diff --git a/sys/dev/mii/tlphy.c b/sys/dev/mii/tlphy.c index d489537..7543d6c 100644 --- a/sys/dev/mii/tlphy.c +++ b/sys/dev/mii/tlphy.c @@ -127,20 +127,16 @@ static int tlphy_auto(struct tlphy_softc *); static void tlphy_acomp(struct tlphy_softc *); static void tlphy_status(struct tlphy_softc *); +static const struct mii_phydesc tlphys[] = { + MII_PHY_DESC(xxTI, TLAN10T), + MII_PHY_END +}; + static int tlphy_probe(device_t dev) { - struct mii_attach_args *ma; - - ma = device_get_ivars(dev); - - if (MII_OUI(ma->mii_id1, ma->mii_id2) != MII_OUI_xxTI || - MII_MODEL(ma->mii_id2) != MII_MODEL_xxTI_TLAN10T) - return (ENXIO); - - device_set_desc(dev, MII_STR_xxTI_TLAN10T); - return (BUS_PROBE_DEFAULT); + return (mii_phy_dev_probe(dev, tlphys, BUS_PROBE_DEFAULT)); } static int diff --git a/sys/dev/mii/xmphy.c b/sys/dev/mii/xmphy.c index c071b1f..b7f5ae9 100644 --- a/sys/dev/mii/xmphy.c +++ b/sys/dev/mii/xmphy.c @@ -83,26 +83,17 @@ static int xmphy_service(struct mii_softc *, struct mii_data *, int); 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_END +}; + static int xmphy_probe(device_t dev) { - struct mii_attach_args *ma; - - ma = device_get_ivars(dev); - - if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_xxXAQTI && - MII_MODEL(ma->mii_id2) == MII_MODEL_XAQTI_XMACII) { - device_set_desc(dev, MII_STR_XAQTI_XMACII); - return(BUS_PROBE_DEFAULT); - } - - if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_JATO && - MII_MODEL(ma->mii_id2) == MII_MODEL_JATO_BASEX) { - device_set_desc(dev, MII_STR_JATO_BASEX); - return(BUS_PROBE_DEFAULT); - } - return(ENXIO); + return (mii_phy_dev_probe(dev, xmphys, BUS_PROBE_DEFAULT)); } static int |