summaryrefslogtreecommitdiffstats
path: root/sys/dev/mii/rlphy.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/mii/rlphy.c')
-rw-r--r--sys/dev/mii/rlphy.c77
1 files changed, 21 insertions, 56 deletions
diff --git a/sys/dev/mii/rlphy.c b/sys/dev/mii/rlphy.c
index 02dab48..b285f7f 100644
--- a/sys/dev/mii/rlphy.c
+++ b/sys/dev/mii/rlphy.c
@@ -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
OpenPOWER on IntegriCloud