Module Name: src
Committed By: martin
Date: Thu Oct 17 19:06:58 UTC 2019
Modified Files:
src/sys/dev/mii [netbsd-9]: ciphy.c rgephy.c
Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #347):
sys/dev/mii/ciphy.c: revision 1.35
sys/dev/mii/rgephy.c: revision 1.56
sys/dev/mii/rgephy.c: revision 1.57
Make new rgephy_linkup() function and share it like FreeBSD.
No functional change intended.
- Indicate master mode if the negotiated result say so.
- KNF
To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.34.4.1 src/sys/dev/mii/ciphy.c
cvs rdiff -u -r1.55 -r1.55.2.1 src/sys/dev/mii/rgephy.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/mii/ciphy.c
diff -u src/sys/dev/mii/ciphy.c:1.34 src/sys/dev/mii/ciphy.c:1.34.4.1
--- src/sys/dev/mii/ciphy.c:1.34 Thu Apr 11 09:14:07 2019
+++ src/sys/dev/mii/ciphy.c Thu Oct 17 19:06:58 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ciphy.c,v 1.34 2019/04/11 09:14:07 msaitoh Exp $ */
+/* $NetBSD: ciphy.c,v 1.34.4.1 2019/10/17 19:06:58 martin Exp $ */
/*-
* Copyright (c) 2004
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ciphy.c,v 1.34 2019/04/11 09:14:07 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ciphy.c,v 1.34.4.1 2019/10/17 19:06:58 martin Exp $");
/*
* Driver for the Cicada CS8201 10/100/1000 copper PHY.
@@ -297,7 +297,7 @@ static void
ciphy_status(struct mii_softc *sc)
{
struct mii_data *mii = sc->mii_pdata;
- uint16_t bmsr, bmcr;
+ uint16_t bmsr, bmcr, gtsr;
mii->mii_media_status = IFM_AVALID;
mii->mii_media_active = IFM_ETHER;
@@ -343,16 +343,19 @@ ciphy_status(struct mii_softc *sc)
else
mii->mii_media_active |= IFM_HDX;
- return;
+ if (IFM_SUBTYPE(mii->mii_media_active) == IFM_1000_T) {
+ PHY_READ(sc, MII_GTSR, >sr);
+ if ((gtsr & GTSR_MS_RES) != 0)
+ mii->mii_media_active |= IFM_ETH_MASTER;
+ }
}
static void
ciphy_reset(struct mii_softc *sc)
{
+
mii_phy_reset(sc);
DELAY(1000);
-
- return;
}
static inline int
@@ -437,6 +440,4 @@ ciphy_fixup(struct mii_softc *sc)
model);
break;
}
-
- return;
}
Index: src/sys/dev/mii/rgephy.c
diff -u src/sys/dev/mii/rgephy.c:1.55 src/sys/dev/mii/rgephy.c:1.55.2.1
--- src/sys/dev/mii/rgephy.c:1.55 Wed Jun 5 17:50:06 2019
+++ src/sys/dev/mii/rgephy.c Thu Oct 17 19:06:58 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: rgephy.c,v 1.55 2019/06/05 17:50:06 triaxx Exp $ */
+/* $NetBSD: rgephy.c,v 1.55.2.1 2019/10/17 19:06:58 martin Exp $ */
/*
* Copyright (c) 2003
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rgephy.c,v 1.55 2019/06/05 17:50:06 triaxx Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rgephy.c,v 1.55.2.1 2019/10/17 19:06:58 martin Exp $");
/*
@@ -75,6 +75,7 @@ static int rgephy_service(struct mii_sof
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 *);
@@ -295,26 +296,9 @@ rgephy_service(struct mii_softc *sc, str
* need to restart the autonegotiation process. Read
* the BMSR twice in case it's latched.
*/
- if (sc->mii_mpd_rev >= RGEPHY_8211F) {
- /* RTL8211F */
- PHY_READ(sc, RGEPHY_MII_PHYSR, ®);
- if (reg & RGEPHY_PHYSR_LINK) {
- sc->mii_ticks = 0;
- break;
- }
- } else if (sc->mii_mpd_rev >= RGEPHY_8211B) {
- /* RTL8211B(L) */
- PHY_READ(sc, RGEPHY_MII_SSR, ®);
- if (reg & RGEPHY_SSR_LINK) {
- sc->mii_ticks = 0;
- break;
- }
- } else {
- 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. */
@@ -345,28 +329,40 @@ rgephy_service(struct mii_softc *sc, str
return 0;
}
+static bool
+rgephy_linkup(struct mii_softc *sc)
+{
+ bool linkup = false;
+ uint16_t reg;
+
+ if (sc->mii_mpd_rev >= RGEPHY_8211F) {
+ PHY_READ(sc, RGEPHY_MII_PHYSR, ®);
+ if (reg & RGEPHY_PHYSR_LINK)
+ linkup = true;
+ } else if (sc->mii_mpd_rev >= RGEPHY_8211B) {
+ PHY_READ(sc, RGEPHY_MII_SSR, ®);
+ if (reg & RGEPHY_SSR_LINK)
+ linkup = true;
+ } else {
+ 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;
- uint16_t gstat, bmsr, bmcr, physr, ssr;
+ uint16_t gstat, bmsr, bmcr, gtsr, physr, ssr;
mii->mii_media_status = IFM_AVALID;
mii->mii_media_active = IFM_ETHER;
- if (sc->mii_mpd_rev >= RGEPHY_8211F) {
- PHY_READ(sc, RGEPHY_MII_PHYSR, &physr);
- if (physr & RGEPHY_PHYSR_LINK)
- mii->mii_media_status |= IFM_ACTIVE;
- } else if (sc->mii_mpd_rev >= RGEPHY_8211B) {
- PHY_READ(sc, RGEPHY_MII_SSR, &ssr);
- if (ssr & RGEPHY_SSR_LINK)
- mii->mii_media_status |= IFM_ACTIVE;
- } else {
- PHY_READ(sc, RTK_GMEDIASTAT, &gstat);
- if ((gstat & RTK_GMEDIASTAT_LINK) != 0)
- mii->mii_media_status |= IFM_ACTIVE;
- }
+ if (rgephy_linkup(sc))
+ mii->mii_media_status |= IFM_ACTIVE;
PHY_READ(sc, MII_BMSR, &bmsr);
PHY_READ(sc, MII_BMCR, &bmcr);
@@ -446,6 +442,12 @@ rgephy_status(struct mii_softc *sc)
else
mii->mii_media_active |= IFM_HDX;
}
+
+ if (IFM_SUBTYPE(mii->mii_media_active) == IFM_1000_T) {
+ PHY_READ(sc, MII_GTSR, >sr);
+ if ((gtsr & GTSR_MS_RES) != 0)
+ mii->mii_media_active |= IFM_ETH_MASTER;
+ }
}
static int