Module Name: src Committed By: msaitoh Date: Tue Dec 28 06:36:30 UTC 2021
Modified Files: src/sys/dev/mii: makphy.c makphyvar.h Log Message: Reduce the access of the ESSR register. - makphyattach() have a code to detect the Fiber/Copper auto selection feature. Save the info to sc_flags to reduce the access to the ESSR register. One of the reason is that the register is not implemented on QEMU. Another reason is that it's not required to access the register if the device is in the copper only mode. To generate a diff of this commit: cvs rdiff -u -r1.70 -r1.71 src/sys/dev/mii/makphy.c cvs rdiff -u -r1.2 -r1.3 src/sys/dev/mii/makphyvar.h 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/makphy.c diff -u src/sys/dev/mii/makphy.c:1.70 src/sys/dev/mii/makphy.c:1.71 --- src/sys/dev/mii/makphy.c:1.70 Tue Dec 28 06:35:37 2021 +++ src/sys/dev/mii/makphy.c Tue Dec 28 06:36:29 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: makphy.c,v 1.70 2021/12/28 06:35:37 msaitoh Exp $ */ +/* $NetBSD: makphy.c,v 1.71 2021/12/28 06:36:29 msaitoh Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: makphy.c,v 1.70 2021/12/28 06:35:37 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: makphy.c,v 1.71 2021/12/28 06:36:29 msaitoh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -259,7 +259,8 @@ page0: default: break; } - } + } else + maksc->sc_flags |= MAKPHY_F_FICO_AUTOSEL; break; default: break; @@ -487,14 +488,19 @@ makphy_status(struct mii_softc *sc) mii->mii_media_active |= IFM_1000_SX; } else if ((sc->mii_mpd_model == MII_MODEL_xxMARVELL_E1011) || (sc->mii_mpd_model == MII_MODEL_xxMARVELL_E1111)) { - /* Fiber/Copper auto select mode */ + struct makphy_softc *maksc = (struct makphy_softc *)sc; - PHY_READ(sc, MAKPHY_ESSR, &essr); - if ((essr & ESSR_FIBER_LINK) == 0) + if ((maksc->sc_flags & MAKPHY_F_FICO_AUTOSEL) != 0) { + /* Fiber/Copper auto select mode */ + PHY_READ(sc, MAKPHY_ESSR, &essr); + if ((essr & ESSR_FIBER_LINK) == 0) + goto copper; + else { + /* Regard as 1000BASE-SX */ + mii->mii_media_active |= IFM_1000_SX; + } + } else goto copper; - - /* XXX Assume 1000BASE-SX only */ - mii->mii_media_active |= IFM_1000_SX; } else if (sc->mii_mpd_model == MII_MODEL_xxMARVELL_E1112) { /* Fiber/Copper auto select mode */ Index: src/sys/dev/mii/makphyvar.h diff -u src/sys/dev/mii/makphyvar.h:1.2 src/sys/dev/mii/makphyvar.h:1.3 --- src/sys/dev/mii/makphyvar.h:1.2 Mon Mar 25 06:17:56 2019 +++ src/sys/dev/mii/makphyvar.h Tue Dec 28 06:36:29 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: makphyvar.h,v 1.2 2019/03/25 06:17:56 msaitoh Exp $ */ +/* $NetBSD: makphyvar.h,v 1.3 2021/12/28 06:36:29 msaitoh Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -37,6 +37,7 @@ struct makphy_softc { uint32_t sc_flags; }; -#define MAKPHY_F_I210 __BIT(0) /* Identify I210 (mii_model == 0) */ +#define MAKPHY_F_I210 __BIT(0) /* Identify I210 (mii_model == 0) */ +#define MAKPHY_F_FICO_AUTOSEL __BIT(1) /* Fiber/Copper autoselect mode */ #endif /* _MII_MAKPHYVAR_H_ */