FreeBSD Bugzilla – Attachment 152860 Details for
Bug 197265
[mii] patch to support rtl8211f ethernet phys
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch to support rtl8211f Rev 2
rtl8211f-v2.txt (text/plain), 6.16 KB, created by
john
on 2015-02-11 03:17:49 UTC
(
hide
)
Description:
patch to support rtl8211f Rev 2
Filename:
MIME Type:
Creator:
john
Created:
2015-02-11 03:17:49 UTC
Size:
6.16 KB
patch
obsolete
>Index: sys/dev/mii/rgephy.c >=================================================================== >--- sys/dev/mii/rgephy.c (revision 278021) >+++ sys/dev/mii/rgephy.c (working copy) >@@ -148,6 +148,7 @@ > { > struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > int reg, speed, gig, anar; >+ int bmcr, bmsr; > > switch (cmd) { > case MII_POLLSTAT: >@@ -239,11 +240,18 @@ > */ > if ((sc->mii_flags & MIIF_PHYPRIV0) == 0 && > sc->mii_mpd_rev >= 2) { >- /* RTL8211B(L) */ >- reg = PHY_READ(sc, RGEPHY_MII_SSR); >- if (reg & RGEPHY_SSR_LINK) { >- sc->mii_ticks = 0; >- break; >+ bmcr = PHY_READ(sc, RGEPHY_MII_BMCR); >+ /* A side effect is to update the link status. */ >+ bmsr = PHY_READ(sc, RGEPHY_MII_BMSR); >+ if ((bmcr & RGEPHY_BMCR_AUTOEN) == 0 || >+ (bmsr & RGEPHY_BMSR_ACOMP) == RGEPHY_BMSR_ACOMP) { >+ /* The previous read updated the link status. */ >+ bmsr = PHY_READ(sc, RGEPHY_MII_BMSR); >+ if ((bmsr & RGEPHY_BMSR_LINK) >+ == RGEPHY_BMSR_LINK) { >+ sc->mii_ticks = 0; >+ break; >+ } > } > } else { > reg = PHY_READ(sc, RL_GMEDIASTAT); >@@ -287,24 +295,12 @@ > rgephy_status(struct mii_softc *sc) > { > struct mii_data *mii = sc->mii_pdata; >- int bmsr, bmcr; >+ int bmcr, bmsr; > uint16_t ssr; > > mii->mii_media_status = IFM_AVALID; > mii->mii_media_active = IFM_ETHER; > >- if ((sc->mii_flags & MIIF_PHYPRIV0) == 0 && sc->mii_mpd_rev >= 2) { >- ssr = PHY_READ(sc, RGEPHY_MII_SSR); >- if (ssr & RGEPHY_SSR_LINK) >- mii->mii_media_status |= IFM_ACTIVE; >- } else { >- bmsr = PHY_READ(sc, RL_GMEDIASTAT); >- if (bmsr & RL_GMEDIASTAT_LINK) >- mii->mii_media_status |= IFM_ACTIVE; >- } >- >- bmsr = PHY_READ(sc, RGEPHY_MII_BMSR); >- > bmcr = PHY_READ(sc, RGEPHY_MII_BMCR); > if (bmcr & RGEPHY_BMCR_ISO) { > mii->mii_media_active |= IFM_NONE; >@@ -315,6 +311,8 @@ > if (bmcr & RGEPHY_BMCR_LOOP) > mii->mii_media_active |= IFM_LOOP; > >+ /* A side effect is to update the link status. */ >+ bmsr = PHY_READ(sc, RGEPHY_MII_BMSR); > if (bmcr & RGEPHY_BMCR_AUTOEN) { > if ((bmsr & RGEPHY_BMSR_ACOMP) == 0) { > /* Erg, still trying, I guess... */ >@@ -324,25 +322,59 @@ > } > > if ((sc->mii_flags & MIIF_PHYPRIV0) == 0 && sc->mii_mpd_rev >= 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; >+ /* The previous read updated the link status. */ >+ bmsr = PHY_READ(sc, RGEPHY_MII_BMSR); >+ if ((bmsr & RGEPHY_BMSR_LINK) == RGEPHY_BMSR_LINK) >+ mii->mii_media_status |= IFM_ACTIVE; >+ } else { >+ bmsr = PHY_READ(sc, RL_GMEDIASTAT); >+ if (bmsr & RL_GMEDIASTAT_LINK) >+ mii->mii_media_status |= IFM_ACTIVE; >+ } >+ >+ if ((sc->mii_flags & MIIF_PHYPRIV0) == 0 && sc->mii_mpd_rev >= 2) { >+ if (sc->mii_mpd_rev == 6) { >+ /* RTL8211F */ >+ ssr = PHY_READ(sc, RGEPHY_F_MII_SSR); >+ switch (ssr & RGEPHY_F_SSR_SPD_MASK) { >+ case RGEPHY_F_SSR_S1000: >+ mii->mii_media_active |= IFM_1000_T; >+ break; >+ case RGEPHY_F_SSR_S100: >+ mii->mii_media_active |= IFM_100_TX; >+ break; >+ case RGEPHY_F_SSR_S10: >+ mii->mii_media_active |= IFM_10_T; >+ break; >+ default: >+ mii->mii_media_active |= IFM_NONE; >+ break; >+ } >+ if (ssr & RGEPHY_F_SSR_FDX) >+ mii->mii_media_active |= IFM_FDX; >+ else >+ mii->mii_media_active |= IFM_HDX; >+ } else { >+ 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; > } >- if (ssr & RGEPHY_SSR_FDX) >- mii->mii_media_active |= IFM_FDX; >- else >- mii->mii_media_active |= IFM_HDX; > } else { > bmsr = PHY_READ(sc, RL_GMEDIASTAT); > if (bmsr & RL_GMEDIASTAT_1000MBPS) >@@ -491,11 +523,21 @@ > } > > if (sc->mii_mpd_rev >= 2) { >- pcr = PHY_READ(sc, RGEPHY_MII_PCR); >- if ((pcr & RGEPHY_PCR_MDIX_AUTO) == 0) { >- pcr &= ~RGEPHY_PCR_MDI_MASK; >- pcr |= RGEPHY_PCR_MDIX_AUTO; >- PHY_WRITE(sc, RGEPHY_MII_PCR, pcr); >+ if (sc->mii_mpd_rev == 6) { >+ /* RTL8211F */ >+ pcr = PHY_READ(sc, RGEPHY_F_MII_PCR1); >+ if ((pcr & RGEPHY_F_PCR1_MDI_MM) >+ == RGEPHY_F_PCR1_MDI_MM) { >+ pcr &= ~RGEPHY_F_PCR1_MDI_MM; >+ PHY_WRITE(sc, RGEPHY_F_MII_PCR1, pcr); >+ } >+ } else { >+ pcr = PHY_READ(sc, RGEPHY_MII_PCR); >+ if ((pcr & RGEPHY_PCR_MDIX_AUTO) == 0) { >+ pcr &= ~RGEPHY_PCR_MDI_MASK; >+ pcr |= RGEPHY_PCR_MDIX_AUTO; >+ PHY_WRITE(sc, RGEPHY_MII_PCR, pcr); >+ } > } > } > >Index: sys/dev/mii/rgephyreg.h >=================================================================== >--- sys/dev/mii/rgephyreg.h (revision 278021) >+++ sys/dev/mii/rgephyreg.h (working copy) >@@ -162,4 +162,20 @@ > #define RGEPHY_SSR_ALDPS 0x0008 /* RTL8211C(L) only */ > #define RGEPHY_SSR_JABBER 0x0001 /* Jabber */ > >+/* RTL8211F */ >+#define RGEPHY_F_MII_PCR1 0x18 /* PHY Specific control register */ >+#define RGEPHY_F_PCR1_MDI_MM 0x0200 /* MDI / MDIX Manual Mode */ >+#define RGEPHY_F_PCR1_MDI_MODE 0x0100 /* MDI Mode (0=MDIX,1=MDI) */ >+#define RGEPHY_F_PCR1_ALDPS_EN 0x0004 /* Link Down Power Saving Enable */ >+ >+/* RTL8211F */ >+#define RGEPHY_F_MII_SSR 0x1a /* PHY Specific status register */ >+#define RGEPHY_F_SSR_S1000 0x0020 /* 1000Mbps */ >+#define RGEPHY_F_SSR_S100 0x0010 /* 100Mbps */ >+#define RGEPHY_F_SSR_S10 0x0000 /* 10Mbps */ >+#define RGEPHY_F_SSR_SPD_MASK 0x0030 >+#define RGEPHY_F_SSR_FDX 0x0008 /* full duplex */ >+#define RGEPHY_F_SSR_LINK 0x0004 /* link up */ >+#define RGEPHY_F_SSR_JABBER 0x0001 /* Jabber */ >+ > #endif /* _DEV_RGEPHY_MIIREG_H_ */ >------------------------------------------------------------------------- >| Feith Systems | Voice: 1-215-646-8000 | Email: john@feith.com | >| John Wehle | Fax: 1-215-540-5495 | | >-------------------------------------------------------------------------
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 197265
:
152469
| 152860 |
154127