Source-Changes-HG archive

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

[src/netbsd-2-0]: src/sys/dev/mii Pull up revision 1.5 (requested by thorpej ...



details:   https://anonhg.NetBSD.org/src/rev/be4e4c9482c1
branches:  netbsd-2-0
changeset: 564638:be4e4c9482c1
user:      jdc <jdc%NetBSD.org@localhost>
date:      Fri Jan 07 11:42:14 2005 +0000

description:
Pull up revision 1.5 (requested by thorpej in ticket #897)

Enable the SmartSpeed work-around code for the IGP phy, with some
minor adjustments.

diffstat:

 sys/dev/mii/igphy.c |  35 +++++++++++++++++++++--------------
 1 files changed, 21 insertions(+), 14 deletions(-)

diffs (95 lines):

diff -r c1ea3ee2210a -r be4e4c9482c1 sys/dev/mii/igphy.c
--- a/sys/dev/mii/igphy.c       Thu Dec 23 04:45:50 2004 +0000
+++ b/sys/dev/mii/igphy.c       Fri Jan 07 11:42:14 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: igphy.c,v 1.1 2003/10/28 00:15:40 fvdl Exp $   */
+/*     $NetBSD: igphy.c,v 1.1.2.1 2005/01/07 11:42:14 jdc Exp $        */
 
 /*
  * The Intel copyright applies to the analog register setup, and the
@@ -77,7 +77,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: igphy.c,v 1.1 2003/10/28 00:15:40 fvdl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: igphy.c,v 1.1.2.1 2005/01/07 11:42:14 jdc Exp $");
 
 #include "opt_mii.h"
 
@@ -97,16 +97,19 @@
 
 #include <dev/mii/igphyreg.h>
 
+struct igphy_softc {
+       struct mii_softc sc_mii;
+       int sc_smartspeed;
+};
+
 static void igphy_reset(struct mii_softc *);
 static void igphy_load_dspcode(struct mii_softc *);
-#if 0
 static void igphy_smartspeed_workaround(struct mii_softc *sc);
-#endif
 
 int    igphymatch(struct device *, struct cfdata *, void *);
 void   igphyattach(struct device *, struct device *, void *);
 
-CFATTACH_DECL(igphy, sizeof(struct mii_softc),
+CFATTACH_DECL(igphy, sizeof(struct igphy_softc),
     igphymatch, igphyattach, mii_phy_detach, mii_phy_activate);
 
 int    igphy_service(struct mii_softc *, struct mii_data *, int);
@@ -278,9 +281,7 @@
                if (IFM_INST(ife->ifm_media) != sc->mii_inst)
                        return (0);
 
-#if 0
                igphy_smartspeed_workaround(sc);
-#endif
 
                if (mii_phy_tick(sc) == EJUSTRETURN)
                        return (0);
@@ -364,15 +365,20 @@
                mii->mii_media_active = ife->ifm_media;
 }
 
-#if 0
 static void
 igphy_smartspeed_workaround(struct mii_softc *sc)
 {
-       uint16_t reg, gtsr, gctr;
+       struct igphy_softc *igsc = (struct igphy_softc *) sc;
+       uint16_t reg, gtsr, gtcr;
+
+       if ((PHY_READ(sc, MII_BMCR) & BMCR_AUTOEN) == 0)
+               return;
+
+       /* XXX Assume 1000TX-FDX is advertized if doing autonegotiation. */
 
        reg = PHY_READ(sc, MII_BMSR) | PHY_READ(sc, MII_BMSR);
-       if (!(reg & BMSR_LINK)) {
-               switch (sc->mii_ticks) {
+       if ((reg & BMSR_LINK) == 0) {
+               switch (igsc->sc_smartspeed) {
                case 0:
                        gtsr = PHY_READ(sc, MII_100T2SR);
                        if (!(gtsr & GTSR_MAN_MS_FLT))
@@ -386,7 +392,6 @@
                                            gtcr);
                                }
                                mii_phy_auto(sc, 0);
-                               sc->mii_ticks++;
                        }
                        break;
                case IGPHY_TICK_DOWNSHIFT:
@@ -398,6 +403,8 @@
                default:
                        break;
                }
-       }
+               if (igsc->sc_smartspeed++ == IGPHY_TICK_MAX)
+                       igsc->sc_smartspeed = 0;
+       } else
+               igsc->sc_smartspeed = 0;
 }
-#endif



Home | Main Index | Thread Index | Old Index