Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/mii Reduce the access of the ESSR register.



details:   https://anonhg.NetBSD.org/src/rev/7079e5c6a03f
branches:  trunk
changeset: 1029233:7079e5c6a03f
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Tue Dec 28 06:36:29 2021 +0000

description:
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.

diffstat:

 sys/dev/mii/makphy.c    |  24 +++++++++++++++---------
 sys/dev/mii/makphyvar.h |   5 +++--
 2 files changed, 18 insertions(+), 11 deletions(-)

diffs (72 lines):

diff -r d94792998c90 -r 7079e5c6a03f sys/dev/mii/makphy.c
--- a/sys/dev/mii/makphy.c      Tue Dec 28 06:35:37 2021 +0000
+++ b/sys/dev/mii/makphy.c      Tue Dec 28 06:36:29 2021 +0000
@@ -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 @@
                                default:
                                        break;
                                }
-                       }
+                       } else
+                               maksc->sc_flags |= MAKPHY_F_FICO_AUTOSEL;
                        break;
                default:
                        break;
@@ -487,14 +488,19 @@
                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 */
 
diff -r d94792998c90 -r 7079e5c6a03f sys/dev/mii/makphyvar.h
--- a/sys/dev/mii/makphyvar.h   Tue Dec 28 06:35:37 2021 +0000
+++ b/sys/dev/mii/makphyvar.h   Tue Dec 28 06:36:29 2021 +0000
@@ -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 @@
        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_ */



Home | Main Index | Thread Index | Old Index