git: 3fe25a9bfcd9 - main - mii: Add support for Realtek RTL8211F-VD PHY

From: Peter Jeremy <peterj_at_FreeBSD.org>
Date: Wed, 08 May 2024 09:05:00 UTC
The branch main has been updated by peterj:

URL: https://cgit.FreeBSD.org/src/commit/?id=3fe25a9bfcd9c8afeb096828567353a84be37423

commit 3fe25a9bfcd9c8afeb096828567353a84be37423
Author:     Peter Jeremy <peterj@FreeBSD.org>
AuthorDate: 2024-05-08 08:17:00 +0000
Commit:     Peter Jeremy <peterj@FreeBSD.org>
CommitDate: 2024-05-08 08:17:00 +0000

    mii: Add support for Realtek RTL8211F-VD PHY
    
    The RTL8211F-VD is a replacement/upgrade for the RTL8211F. Based on
    https://github.com/torvalds/linux/commit/bb726b753f75a4eeda291438f89dfd9b94783569,
    the only difference is the lack of the PCR2 register, which FreeBSD
    doesn't use.
    
    This fixes autonegotiation problems using the RTL8211F with ukphy(4).
    Reviewed by:    manu, bz
    MFC after:      1 month
    Differential Revision:  <https://reviews.freebsd.org/D45109
---
 sys/dev/mii/miidevs     | 1 +
 sys/dev/mii/rgephy.c    | 6 ++++--
 sys/dev/mii/rgephyreg.h | 1 +
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/sys/dev/mii/miidevs b/sys/dev/mii/miidevs
index 78d1dddba59f..c8eba403c22d 100644
--- a/sys/dev/mii/miidevs
+++ b/sys/dev/mii/miidevs
@@ -330,6 +330,7 @@ model REALTEK RTL8305SC		0x0005 RTL8305SC 10/100 802.1q switch
 model REALTEK RTL8201E		0x0008 RTL8201E 10/100 media interface
 model REALTEK RTL8251		0x0000 RTL8251/8153 1000BASE-T media interface
 model REALTEK RTL8169S		0x0011 RTL8169S/8110S/8211 1000BASE-T media interface
+model REALTEK RTL8211FVD	0x0007 RTL8211F-VD 1000BASE-T media interface
 
 /* Seeq Seeq PHYs */
 model SEEQ 80220		0x0003 Seeq 80220 10/100 media interface
diff --git a/sys/dev/mii/rgephy.c b/sys/dev/mii/rgephy.c
index 63b3406bb831..4ff86c8c8ccb 100644
--- a/sys/dev/mii/rgephy.c
+++ b/sys/dev/mii/rgephy.c
@@ -93,6 +93,7 @@ static void	rgephy_disable_eee(struct mii_softc *);
 static const struct mii_phydesc rgephys[] = {
 	MII_PHY_DESC(REALTEK, RTL8169S),
 	MII_PHY_DESC(REALTEK, RTL8251),
+	MII_PHY_DESC(REALTEK, RTL8211FVD),
 	MII_PHY_END
 };
 
@@ -283,7 +284,7 @@ rgephy_linkup(struct mii_softc *sc)
 	linkup = 0;
 	if ((sc->mii_flags & MIIF_PHYPRIV0) == 0 &&
 	    sc->mii_mpd_rev >= RGEPHY_8211B) {
-		if (sc->mii_mpd_rev == RGEPHY_8211F) {
+		if (sc->mii_mpd_rev >= RGEPHY_8211F) {
 			reg = PHY_READ(sc, RGEPHY_F_MII_SSR);
 			if (reg & RGEPHY_F_SSR_LINK)
 				linkup++;
@@ -338,7 +339,7 @@ rgephy_status(struct mii_softc *sc)
 
 	if ((sc->mii_flags & MIIF_PHYPRIV0) == 0 &&
 	    sc->mii_mpd_rev >= RGEPHY_8211B) {
-		if (sc->mii_mpd_rev == RGEPHY_8211F) {
+		if (sc->mii_mpd_rev >= RGEPHY_8211F) {
 			ssr = PHY_READ(sc, RGEPHY_F_MII_SSR);
 			switch (ssr & RGEPHY_F_SSR_SPD_MASK) {
 			case RGEPHY_F_SSR_S1000:
@@ -523,6 +524,7 @@ rgephy_reset(struct mii_softc *sc)
 
 	switch (sc->mii_mpd_rev) {
 	case RGEPHY_8211F:
+	case RGEPHY_8211FVD:
 		pcr = PHY_READ(sc, RGEPHY_F_MII_PCR1);
 		pcr &= ~(RGEPHY_F_PCR1_MDI_MM | RGEPHY_F_PCR1_ALDPS_EN);
 		PHY_WRITE(sc, RGEPHY_F_MII_PCR1, pcr);
diff --git a/sys/dev/mii/rgephyreg.h b/sys/dev/mii/rgephyreg.h
index 205f1a836020..fef985ebe30e 100644
--- a/sys/dev/mii/rgephyreg.h
+++ b/sys/dev/mii/rgephyreg.h
@@ -38,6 +38,7 @@
 #define	RGEPHY_8211B		2
 #define	RGEPHY_8211C		3
 #define	RGEPHY_8211F		6
+#define	RGEPHY_8211FVD		8
 
 /*
  * RealTek 8169S/8110S gigE PHY registers