tech-net archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: RTL8169S/8110S not supported on 4.0_STABLE?



bradd%cat.co.za@localhost wrote:

> Izumi Tsutsui wrote:
> > Anyway, could you try diffs only against rgephy.c
> > and rgephyreg.h first?
> 
> Ok I tried this, see results below.
 :
>     media: Ethernet autoselect (none)
>     status: no carrier

Well, there is some botch in the previous one.

Could you try this one and see if link status is up?
(all zero'ed MAC address is another problem)
---
Izumi Tsutsui


Index: rgephy.c
===================================================================
RCS file: /cvsroot/src/sys/dev/mii/rgephy.c,v
retrieving revision 1.18
diff -u -r1.18 rgephy.c
--- rgephy.c    26 Jan 2008 14:24:14 -0000      1.18
+++ rgephy.c    19 Mar 2008 15:21:55 -0000
@@ -288,9 +288,20 @@
                 * need to restart the autonegotiation process.  Read
                 * the BMSR twice in case it's latched.
                 */
-               reg = PHY_READ(sc, RTK_GMEDIASTAT);
-               if ((reg & RTK_GMEDIASTAT_LINK) != 0)
-                       break;
+               if (sc->mii_mpd_model >= 2) {
+                       /* RTL8211B(L) */
+                       reg = PHY_READ(sc, RGEPHY_MII_SSR);
+                       if (reg & RGEPHY_SSR_LINK) {
+                               sc->mii_ticks = 0;
+                               break;
+                       }
+               } else {
+                       reg = PHY_READ(sc, RTK_GMEDIASTAT);
+                       if ((reg & RTK_GMEDIASTAT_LINK) != 0) {
+                               sc->mii_ticks = 0;
+                               break;
+                       }
+               }
 
                /*
                 * Only retry autonegotiation every 5 seconds.
@@ -326,15 +337,24 @@
 rgephy_status(struct mii_softc *sc)
 {
        struct mii_data *mii = sc->mii_pdata;
-       int bmsr, bmcr;
+       int gstat, bmsr, bmcr;
+       uint16_t ssr;
 
        mii->mii_media_status = IFM_AVALID;
        mii->mii_media_active = IFM_ETHER;
 
-       if ((PHY_READ(sc, RTK_GMEDIASTAT) & RTK_GMEDIASTAT_LINK) != 0)
-               mii->mii_media_status |= IFM_ACTIVE;
+       if (sc->mii_mpd_model>= 2) {
+               ssr = PHY_READ(sc, RGEPHY_MII_SSR);
+               if (ssr & RGEPHY_SSR_LINK)
+                       mii->mii_media_status |= IFM_ACTIVE;
+       } else {
+               gstat = PHY_READ(sc, RTK_GMEDIASTAT);
+               if ((gstat & RTK_GMEDIASTAT_LINK) != 0)
+                       mii->mii_media_status |= IFM_ACTIVE;
+       }
 
        bmsr = PHY_READ(sc, RGEPHY_MII_BMSR);
+       bmsr = PHY_READ(sc, RGEPHY_MII_BMSR);
        bmcr = PHY_READ(sc, RGEPHY_MII_BMCR);
 
        if ((bmcr & RGEPHY_BMCR_ISO) != 0) {
@@ -354,17 +374,39 @@
                }
        }
 
-       bmsr = PHY_READ(sc, RTK_GMEDIASTAT);
-       if ((bmsr & RTK_GMEDIASTAT_1000MBPS) != 0)
-               mii->mii_media_active |= IFM_1000_T;
-       else if ((bmsr & RTK_GMEDIASTAT_100MBPS) != 0)
-               mii->mii_media_active |= IFM_100_TX;
-       else if ((bmsr & RTK_GMEDIASTAT_10MBPS) != 0)
-               mii->mii_media_active |= IFM_10_T;
-       else
-               mii->mii_media_active |= IFM_NONE;
-       if ((bmsr & RTK_GMEDIASTAT_FDX) != 0)
-               mii->mii_media_active |= IFM_FDX;
+       if (sc->mii_mpd_model >= 2) {
+               ssr = PHY_READ(sc, RGEPHY_MII_SSR);
+               switch (ssr & RGEPHY_SSR_SPD_MASK) {
+               case RGEPHY_SSR_S1000:
+                       mii->mii_media_active |= IFM_1000_T;
+                       break;
+               case RGEPHY_SSR_S100:
+                       mii->mii_media_active |= IFM_100_TX;
+                       break;
+               case RGEPHY_SSR_S10:
+                       mii->mii_media_active |= IFM_10_T;
+                       break;
+               default:
+                       mii->mii_media_active |= IFM_NONE;
+                       break;
+               }
+               if (ssr & RGEPHY_SSR_FDX)
+                       mii->mii_media_active |= IFM_FDX;
+               else
+                       mii->mii_media_active |= IFM_HDX;
+       } else {
+               gstat = PHY_READ(sc, RTK_GMEDIASTAT);
+               if ((gstat & RTK_GMEDIASTAT_1000MBPS) != 0)
+                       mii->mii_media_active |= IFM_1000_T;
+               else if ((gstat & RTK_GMEDIASTAT_100MBPS) != 0)
+                       mii->mii_media_active |= IFM_100_TX;
+               else if ((gstat & RTK_GMEDIASTAT_10MBPS) != 0)
+                       mii->mii_media_active |= IFM_10_T;
+               else
+                       mii->mii_media_active |= IFM_NONE;
+               if ((gstat & RTK_GMEDIASTAT_FDX) != 0)
+                       mii->mii_media_active |= IFM_FDX;
+       }
 }
 
 
@@ -394,8 +436,10 @@
        uint32_t bmsr;
        int i;
 
-       PHY_WRITE(sc, RGEPHY_MII_BMCR, RGEPHY_BMCR_PDOWN);
-       DELAY(1000);
+       if (sc->mii_mpd_model < 2) {
+               PHY_WRITE(sc, RGEPHY_MII_BMCR, RGEPHY_BMCR_PDOWN);
+               DELAY(1000);
+       }
 
        for (i = 0; i < 15000; i++) {
                bmsr = PHY_READ(sc, RGEPHY_MII_BMSR);
Index: rgephyreg.h
===================================================================
RCS file: /cvsroot/src/sys/dev/mii/rgephyreg.h,v
retrieving revision 1.2
diff -u -r1.2 rgephyreg.h
--- rgephyreg.h 29 Nov 2006 14:01:53 -0000      1.2
+++ rgephyreg.h 19 Mar 2008 15:21:55 -0000
@@ -137,6 +137,17 @@
 #define RGEPHY_EXTSTS_T_FD_CAP 0x2000  /* 1000base-T FD capable */
 #define RGEPHY_EXTSTS_T_HD_CAP 0x1000  /* 1000base-T HD capable */
 
-
+/* RTL8211B(L) */
+#define RGEPHY_MII_SSR         0x11    /* PHY Specific status register */
+#define        RGEPHY_SSR_S1000        0x8000  /* 1000Mbps */
+#define        RGEPHY_SSR_S100         0x4000  /* 100Mbps */
+#define        RGEPHY_SSR_S10          0x0000  /* 10Mbps */
+#define        RGEPHY_SSR_SPD_MASK     0xc000
+#define        RGEPHY_SSR_FDX          0x2000  /* full duplex */
+#define        RGEPHY_SSR_PAGE_RECEIVED        0x1000  /* new page received */
+#define        RGEPHY_SSR_SPD_DPLX_RESOLVED    0x0800  /* speed/duplex 
resolved */
+#define        RGEPHY_SSR_LINK         0x0400  /* link up */
+#define        RGEPHY_SSR_MDI_XOVER    0x0040  /* MDI crossover */
+#define        RGEPHY_SSR_JABBER       0x0001  /* Jabber */
 
 #endif /* _DEV_MII_RGEPHYREG_H_ */


Home | Main Index | Thread Index | Old Index