Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-8]: src/sys/dev/mii Pull up the following revisions, requested by...
details: https://anonhg.NetBSD.org/src/rev/f9fce084180c
branches: netbsd-8
changeset: 460467:f9fce084180c
user: martin <martin%NetBSD.org@localhost>
date: Thu Oct 24 15:54:46 2019 +0000
description:
Pull up the following revisions, requested by msaitoh in ticket #1413:
sys/dev/mii/rgephy.c 1.43, 1.47, 1.49, 1.54-1.57
sys/dev/mii/rgephyreg.h 1.10, 1.12
(both via patch)
- It seems EEE support is not only on 8211F but on 8211D and newer.
- Indicate master mode if the negotiated result say so.
- Use symbolic names for chip revision.
- Cosmetic changes.
- KNF.
diffstat:
sys/dev/mii/rgephy.c | 113 +++++++++++++++++++++++++----------------------
sys/dev/mii/rgephyreg.h | 8 ++-
2 files changed, 66 insertions(+), 55 deletions(-)
diffs (274 lines):
diff -r 5c23ff80403d -r f9fce084180c sys/dev/mii/rgephy.c
--- a/sys/dev/mii/rgephy.c Thu Oct 24 15:51:28 2019 +0000
+++ b/sys/dev/mii/rgephy.c Thu Oct 24 15:54:46 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rgephy.c,v 1.40.10.2 2019/05/13 12:40:13 martin Exp $ */
+/* $NetBSD: rgephy.c,v 1.40.10.3 2019/10/24 15:54:46 martin Exp $ */
/*
* Copyright (c) 2003
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rgephy.c,v 1.40.10.2 2019/05/13 12:40:13 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rgephy.c,v 1.40.10.3 2019/10/24 15:54:46 martin Exp $");
/*
@@ -73,6 +73,7 @@
static void rgephy_status(struct mii_softc *);
static int rgephy_mii_phy_auto(struct mii_softc *);
static void rgephy_reset(struct mii_softc *);
+static bool rgephy_linkup(struct mii_softc *);
static void rgephy_loop(struct mii_softc *);
static void rgephy_load_dspcode(struct mii_softc *);
@@ -116,13 +117,9 @@
int rev;
const char *sep = "";
- ma = aux;
- mii = ma->mii_data;
-
rev = MII_REV(ma->mii_id2);
mpd = mii_phy_match(ma, rgephys);
aprint_naive(": Media interface\n");
- aprint_normal(": %s, rev. %d\n", mpd->mpd_name, rev);
sc->mii_dev = self;
sc->mii_inst = mii->mii_instance;
@@ -130,6 +127,15 @@
sc->mii_mpd_oui = MII_OUI(ma->mii_id1, ma->mii_id2);
sc->mii_mpd_model = MII_MODEL(ma->mii_id2);
sc->mii_mpd_rev = MII_REV(ma->mii_id2);
+
+ if (sc->mii_mpd_model == MII_MODEL_REALTEK_RTL8169S) {
+ aprint_normal(": RTL8211");
+ if (sc->mii_mpd_rev != 0)
+ aprint_normal("%c",'@' + sc->mii_mpd_rev);
+ aprint_normal(" 1000BASE-T media interface\n");
+ } else
+ aprint_normal(": %s, rev. %d\n", mpd->mpd_name, rev);
+
sc->mii_pdata = mii;
sc->mii_flags = ma->mii_flags;
sc->mii_anegticks = MII_ANEGTICKS_GIGE;
@@ -152,9 +158,9 @@
* media explicitly. Why?
*/
aprint_normal_dev(self, "");
- if (sc->mii_capabilities & BMSR_EXTSTAT) {
+ if (sc->mii_capabilities & BMSR_EXTSTAT)
sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR);
- }
+
mii_phy_add_media(sc);
/* rtl8169S does not report auto-sense; add manually. */
@@ -257,9 +263,8 @@
if ((mii->mii_ifp->if_flags & IFF_LINK0)) {
PHY_WRITE(sc, MII_100T2CR,
gig|GTCR_MAN_MS|GTCR_ADV_MS);
- } else {
- PHY_WRITE(sc, MII_100T2CR, gig|GTCR_MAN_MS);
- }
+ } else
+ PHY_WRITE(sc, MII_100T2CR, gig | GTCR_MAN_MS);
PHY_WRITE(sc, MII_BMCR, speed |
BMCR_AUTOEN | BMCR_STARTNEG);
break;
@@ -303,26 +308,9 @@
* need to restart the autonegotiation process. Read
* the BMSR twice in case it's latched.
*/
- if (sc->mii_mpd_rev >= 6) {
- /* RTL8211F */
- reg = PHY_READ(sc, RGEPHY_MII_PHYSR);
- if (reg & RGEPHY_PHYSR_LINK) {
- sc->mii_ticks = 0;
- break;
- }
- } else if (sc->mii_mpd_rev >= 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;
- }
+ if (rgephy_linkup(sc)) {
+ sc->mii_ticks = 0;
+ break;
}
/* Announce link loss right after it happens. */
@@ -343,7 +331,6 @@
/*
* Callback if something changed. Note that we need to poke
* the DSP on the RealTek PHYs if the media changes.
- *
*/
if (sc->mii_media_active != mii->mii_media_active ||
sc->mii_media_status != mii->mii_media_status ||
@@ -354,29 +341,41 @@
return 0;
}
+static bool
+rgephy_linkup(struct mii_softc *sc)
+{
+ bool linkup = false;
+ u_int reg;
+
+ if (sc->mii_mpd_rev >= RGEPHY_8211F) {
+ reg = PHY_READ(sc, RGEPHY_MII_PHYSR);
+ if (reg & RGEPHY_PHYSR_LINK)
+ linkup = true;
+ } else if (sc->mii_mpd_rev >= RGEPHY_8211B) {
+ reg = PHY_READ(sc, RGEPHY_MII_SSR);
+ if (reg & RGEPHY_SSR_LINK)
+ linkup = true;
+ } else {
+ reg = PHY_READ(sc, RTK_GMEDIASTAT);
+ if ((reg & RTK_GMEDIASTAT_LINK) != 0)
+ linkup = true;
+ }
+
+ return linkup;
+}
+
static void
rgephy_status(struct mii_softc *sc)
{
struct mii_data *mii = sc->mii_pdata;
- int gstat, bmsr, bmcr, physr;
+ int gstat, bmsr, bmcr, gtsr, physr;
uint16_t ssr;
mii->mii_media_status = IFM_AVALID;
mii->mii_media_active = IFM_ETHER;
- if (sc->mii_mpd_rev >= 6) {
- physr = PHY_READ(sc, RGEPHY_MII_PHYSR);
- if (physr & RGEPHY_PHYSR_LINK)
- mii->mii_media_status |= IFM_ACTIVE;
- } else if (sc->mii_mpd_rev >= 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;
- }
+ if (rgephy_linkup(sc))
+ mii->mii_media_status |= IFM_ACTIVE;
bmsr = PHY_READ(sc, MII_BMSR);
bmcr = PHY_READ(sc, MII_BMCR);
@@ -398,7 +397,7 @@
}
}
- if (sc->mii_mpd_rev >= 6) {
+ if (sc->mii_mpd_rev >= RGEPHY_8211F) {
physr = PHY_READ(sc, RGEPHY_MII_PHYSR);
switch (__SHIFTOUT(physr, RGEPHY_PHYSR_SPEED)) {
case RGEPHY_PHYSR_SPEED_1000:
@@ -419,7 +418,7 @@
IFM_FDX;
else
mii->mii_media_active |= IFM_HDX;
- } else if (sc->mii_mpd_rev >= 2) {
+ } else if (sc->mii_mpd_rev >= RGEPHY_8211B) {
ssr = PHY_READ(sc, RGEPHY_MII_SSR);
switch (ssr & RGEPHY_SSR_SPD_MASK) {
case RGEPHY_SSR_S1000:
@@ -456,6 +455,12 @@
else
mii->mii_media_active |= IFM_HDX;
}
+
+ if (IFM_SUBTYPE(mii->mii_media_active) == IFM_1000_T) {
+ gtsr = PHY_READ(sc, MII_100T2SR);
+ if ((gtsr & GTSR_MS_RES) != 0)
+ mii->mii_media_active |= IFM_ETH_MASTER;
+ }
}
@@ -489,7 +494,7 @@
int i;
if (sc->mii_mpd_model != MII_MODEL_REALTEK_RTL8251 &&
- sc->mii_mpd_rev < 2) {
+ sc->mii_mpd_rev < RGEPHY_8211B) {
PHY_WRITE(sc, MII_BMCR, BMCR_PDOWN);
DELAY(1000);
}
@@ -524,7 +529,7 @@
int val;
if (sc->mii_mpd_model == MII_MODEL_REALTEK_RTL8251 ||
- sc->mii_mpd_rev >= 2)
+ sc->mii_mpd_rev >= RGEPHY_8211B)
return;
#if 1
@@ -625,16 +630,16 @@
DELAY(1000);
if (sc->mii_mpd_model != MII_MODEL_REALTEK_RTL8251 &&
- sc->mii_mpd_rev < 2) {
+ sc->mii_mpd_rev < RGEPHY_8211B) {
rgephy_load_dspcode(sc);
- } else if (sc->mii_mpd_rev == 3) {
+ } else if (sc->mii_mpd_rev == RGEPHY_8211C) {
/* RTL8211C(L) */
ssr = PHY_READ(sc, RGEPHY_MII_SSR);
if ((ssr & RGEPHY_SSR_ALDPS) != 0) {
ssr &= ~RGEPHY_SSR_ALDPS;
PHY_WRITE(sc, RGEPHY_MII_SSR, ssr);
}
- } else if (sc->mii_mpd_rev == 6) {
+ } else if (sc->mii_mpd_rev == RGEPHY_8211F) {
/* RTL8211F */
phycr1 = PHY_READ(sc, RGEPHY_MII_PHYCR1);
phycr1 &= ~RGEPHY_PHYCR1_MDI_MMCE;
@@ -657,7 +662,7 @@
/* NWay enable and Restart NWay */
PHY_WRITE(sc, MII_BMCR, BMCR_RESET | BMCR_AUTOEN | BMCR_STARTNEG);
- if (sc->mii_mpd_rev == 6) {
+ if (sc->mii_mpd_rev >= RGEPHY_8211D) {
/* RTL8211F */
delay(10000);
/* disable EEE */
diff -r 5c23ff80403d -r f9fce084180c sys/dev/mii/rgephyreg.h
--- a/sys/dev/mii/rgephyreg.h Thu Oct 24 15:51:28 2019 +0000
+++ b/sys/dev/mii/rgephyreg.h Thu Oct 24 15:54:46 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rgephyreg.h,v 1.9 2015/08/21 16:29:48 jmcneill Exp $ */
+/* $NetBSD: rgephyreg.h,v 1.9.10.1 2019/10/24 15:54:46 martin Exp $ */
/*
* Copyright (c) 2003
@@ -37,6 +37,12 @@
#ifndef _DEV_MII_RGEPHYREG_H_
#define _DEV_MII_RGEPHYREG_H_
+#define RGEPHY_8211B 2
+#define RGEPHY_8211C 3
+#define RGEPHY_8211D 4
+#define RGEPHY_8211E 5
+#define RGEPHY_8211F 6
+
/*
* RealTek 8169S/8110S gigE PHY registers
*/
Home |
Main Index |
Thread Index |
Old Index