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.2->1.3 (thorpej): Fix PR7361
details: https://anonhg.NetBSD.org/src/rev/17d5fed0b9fc
branches: netbsd-1-4
changeset: 468440:17d5fed0b9fc
user: perry <perry%NetBSD.org@localhost>
date: Fri Apr 23 15:40:26 1999 +0000
description:
pullup 1.2->1.3 (thorpej): Fix PR7361
diffstat:
sys/dev/mii/mii_physubr.c | 72 ++++++++++++++++++++++++++++++++++++++--------
1 files changed, 59 insertions(+), 13 deletions(-)
diffs (107 lines):
diff -r 3eec92da198a -r 17d5fed0b9fc sys/dev/mii/mii_physubr.c
--- a/sys/dev/mii/mii_physubr.c Fri Apr 23 15:39:44 1999 +0000
+++ b/sys/dev/mii/mii_physubr.c Fri Apr 23 15:40:26 1999 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: mii_physubr.c,v 1.2 1998/11/04 23:28:15 thorpej Exp $ */
+/* $NetBSD: mii_physubr.c,v 1.2.6.1 1999/04/23 15:40:26 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
@@ -44,7 +44,9 @@
#include <sys/param.h>
#include <sys/device.h>
#include <sys/systm.h>
+#include <sys/kernel.h>
#include <sys/socket.h>
+#include <sys/errno.h>
#include <net/if.h>
#include <net/if_media.h>
@@ -52,28 +54,72 @@
#include <dev/mii/mii.h>
#include <dev/mii/miivar.h>
+void mii_phy_auto_timeout __P((void *));
+
int
-mii_phy_auto(mii)
+mii_phy_auto(mii, waitfor)
struct mii_softc *mii;
{
int bmsr, i;
- PHY_WRITE(mii, MII_ANAR,
- BMSR_MEDIA_TO_ANAR(mii->mii_capabilities) | ANAR_CSMA);
- PHY_WRITE(mii, MII_BMCR, BMCR_AUTOEN | BMCR_STARTNEG);
+ if ((mii->mii_flags & MIIF_DOINGAUTO) == 0) {
+ PHY_WRITE(mii, MII_ANAR,
+ BMSR_MEDIA_TO_ANAR(mii->mii_capabilities) | ANAR_CSMA);
+ PHY_WRITE(mii, MII_BMCR, BMCR_AUTOEN | BMCR_STARTNEG);
+ }
+
+ if (waitfor) {
+ /* Wait 500ms for it to complete. */
+ for (i = 0; i < 500; i++) {
+ if ((bmsr = PHY_READ(mii, MII_BMSR)) & BMSR_ACOMP)
+ return (0);
+ delay(1000);
+#if 0
+ if ((bmsr & BMSR_ACOMP) == 0)
+ printf("%s: autonegotiation failed to complete\n",
+ mii->mii_dev.dv_xname);
+#endif
+ }
- /* Wait 500ms for it to complete. */
- for (i = 0; i < 500; i++) {
- if ((bmsr = PHY_READ(mii, MII_BMSR)) & BMSR_ACOMP)
- return (1);
- delay(1000);
+ /*
+ * Don't need to worry about clearing MIIF_DOINGAUTO.
+ * If that's set, a timeout is pending, and it will
+ * clear the flag.
+ */
+ return (EIO);
}
+
+ /*
+ * Just let it finish asynchronously. This is for the benefit of
+ * the tick handler driving autonegotiation. Don't want 500ms
+ * delays all the time while the system is running!
+ */
+ if ((mii->mii_flags & MIIF_DOINGAUTO) == 0) {
+ mii->mii_flags |= MIIF_DOINGAUTO;
+ timeout(mii_phy_auto_timeout, mii, hz >> 1);
+ }
+ return (EJUSTRETURN);
+}
+
+void
+mii_phy_auto_timeout(arg)
+ void *arg;
+{
+ struct mii_softc *mii = arg;
+ int s, bmsr;
+
+ s = splnet();
+ mii->mii_flags &= ~MIIF_DOINGAUTO;
+ bmsr = PHY_READ(mii, MII_BMSR);
#if 0
if ((bmsr & BMSR_ACOMP) == 0)
printf("%s: autonegotiation failed to complete\n",
- mii->mii_dev.dv_xname);
+ sc->sc_dev.dv_xname);
#endif
- return (0);
+
+ /* Update the media status. */
+ (void) (*mii->mii_service)(mii, mii->mii_pdata, MII_POLLSTAT);
+ splx(s);
}
void
Home |
Main Index |
Thread Index |
Old Index