Source-Changes-HG archive

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

[src/netbsd-1-4]: src/sys/dev/mii pullup 1.16->1.17 (thorpej): Fix PR7361



details:   https://anonhg.NetBSD.org/src/rev/3eec92da198a
branches:  netbsd-1-4
changeset: 468439:3eec92da198a
user:      perry <perry%NetBSD.org@localhost>
date:      Fri Apr 23 15:39:44 1999 +0000

description:
pullup 1.16->1.17 (thorpej): Fix PR7361

diffstat:

 sys/dev/mii/nsphy.c |  10 +++++---
 sys/dev/mii/tlphy.c |  56 +++++++++++++++++++++++++++++++++++++++-------------
 2 files changed, 48 insertions(+), 18 deletions(-)

diffs (165 lines):

diff -r f0a33b13de8b -r 3eec92da198a sys/dev/mii/nsphy.c
--- a/sys/dev/mii/nsphy.c       Fri Apr 23 15:39:33 1999 +0000
+++ b/sys/dev/mii/nsphy.c       Fri Apr 23 15:39:44 1999 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: nsphy.c,v 1.16 1998/11/05 04:08:02 thorpej Exp $       */
+/*     $NetBSD: nsphy.c,v 1.16.6.1 1999/04/23 15:39:44 perry Exp $     */
 
 /*-
- * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -77,6 +77,7 @@
 #include <sys/device.h>
 #include <sys/malloc.h>
 #include <sys/socket.h>
+#include <sys/errno.h>
 
 #include <net/if.h>
 #include <net/if_media.h>
@@ -235,7 +236,7 @@
                         */
                        if (PHY_READ(sc, MII_BMCR) & BMCR_AUTOEN)
                                return (0);
-                       (void) mii_phy_auto(sc);
+                       (void) mii_phy_auto(sc, 1);
                        break;
                case IFM_100_T4:
                        /*
@@ -289,7 +290,8 @@
 
                sc->mii_ticks = 0;
                mii_phy_reset(sc);
-               (void) mii_phy_auto(sc);
+               if (mii_phy_auto(sc, 0) == EJUSTRETURN)
+                       return (0);
                break;
        }
 
diff -r f0a33b13de8b -r 3eec92da198a sys/dev/mii/tlphy.c
--- a/sys/dev/mii/tlphy.c       Fri Apr 23 15:39:33 1999 +0000
+++ b/sys/dev/mii/tlphy.c       Fri Apr 23 15:39:44 1999 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: tlphy.c,v 1.16 1998/11/05 00:19:32 thorpej Exp $       */
+/*     $NetBSD: tlphy.c,v 1.16.6.1 1999/04/23 15:40:13 perry Exp $     */
 
 /*-
- * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -75,6 +75,7 @@
 #include <sys/kernel.h>
 #include <sys/device.h>
 #include <sys/socket.h>
+#include <sys/errno.h>
 
 #include <machine/bus.h>
 
@@ -98,6 +99,7 @@
 struct tlphy_softc {
        struct mii_softc sc_mii;                /* generic PHY */
        int sc_tlphycap;
+       int sc_need_acomp;
 };
 
 int    tlphymatch __P((struct device *, struct cfdata *, void *));
@@ -108,7 +110,8 @@
 };
 
 int    tlphy_service __P((struct mii_softc *, struct mii_data *, int));
-void   tlphy_auto __P((struct tlphy_softc *));
+int    tlphy_auto __P((struct tlphy_softc *, int));
+void   tlphy_acomp __P((struct tlphy_softc *));
 void   tlphy_status __P((struct tlphy_softc *));
 
 int
@@ -206,6 +209,9 @@
        struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
        int reg;
 
+       if ((sc->sc_mii.mii_flags & MIIF_DOINGAUTO) == 0 && sc->sc_need_acomp)
+               tlphy_acomp(sc);
+
        switch (cmd) {
        case MII_POLLSTAT:
                /*
@@ -239,7 +245,7 @@
                         * an autonegotiation cycle, so there's no such
                         * thing as "already in auto mode".
                         */
-                       tlphy_auto(sc);
+                       (void) tlphy_auto(sc, 1);
                        break;
                case IFM_10_2:
                case IFM_10_5:
@@ -295,7 +301,8 @@
 
                sc->sc_mii.mii_ticks = 0;
                mii_phy_reset(&sc->sc_mii);
-               tlphy_auto(sc);
+               if (tlphy_auto(sc, 0) == EJUSTRETURN)
+                       return (0);
                break;
        }
 
@@ -362,14 +369,41 @@
        mii->mii_media_active |= IFM_10_T;
 }
 
+int
+tlphy_auto(sc, waitfor)
+       struct tlphy_softc *sc;
+       int waitfor;
+{
+       int error;
+
+       switch ((error = mii_phy_auto(&sc->sc_mii, waitfor))) {
+       case EIO:
+               /*
+                * Just assume we're not in full-duplex mode.
+                * XXX Check link and try AUI/BNC?
+                */
+               PHY_WRITE(&sc->sc_mii, MII_BMCR, 0);
+               break;
+
+       case EJUSTRETURN:
+               /* Flag that we need to program when it completes. */
+               sc->sc_need_acomp = 1;
+               break;
+
+       default:
+               tlphy_acomp(sc);
+       }
+
+       return (error);
+}
+
 void
-tlphy_auto(sc)
+tlphy_acomp(sc)
        struct tlphy_softc *sc;
 {
        int aner, anlpar;
 
-       if (mii_phy_auto(&sc->sc_mii) == 0)
-               goto dflt;
+       sc->sc_need_acomp = 0;
 
        /*
         * Grr, braindead ThunderLAN PHY doesn't self-configure
@@ -386,11 +420,5 @@
                        return;
                }
        }
-
- dflt:
-       /*
-        * Just assume we're not in full-duplex mode.
-        * XXX Check link and try AUI/BNC?
-        */
        PHY_WRITE(&sc->sc_mii, MII_BMCR, 0);
 }



Home | Main Index | Thread Index | Old Index