Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-9]: src/sys/dev/mii Pull up following revision(s) (requested by m...
details: https://anonhg.NetBSD.org/src/rev/40295b6fbe33
branches: netbsd-9
changeset: 462687:40295b6fbe33
user: martin <martin%NetBSD.org@localhost>
date: Thu Oct 17 19:06:58 2019 +0000
description:
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
diffstat:
sys/dev/mii/ciphy.c | 17 ++++++-----
sys/dev/mii/rgephy.c | 74 ++++++++++++++++++++++++++-------------------------
2 files changed, 47 insertions(+), 44 deletions(-)
diffs (181 lines):
diff -r d12c02cbe4d5 -r 40295b6fbe33 sys/dev/mii/ciphy.c
--- a/sys/dev/mii/ciphy.c Thu Oct 17 19:02:54 2019 +0000
+++ b/sys/dev/mii/ciphy.c Thu Oct 17 19:06:58 2019 +0000
@@ -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 @@
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 @@
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 @@
model);
break;
}
-
- return;
}
diff -r d12c02cbe4d5 -r 40295b6fbe33 sys/dev/mii/rgephy.c
--- a/sys/dev/mii/rgephy.c Thu Oct 17 19:02:54 2019 +0000
+++ b/sys/dev/mii/rgephy.c Thu Oct 17 19:06:58 2019 +0000
@@ -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 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 @@
* 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 @@
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 @@
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
Home |
Main Index |
Thread Index |
Old Index