summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Wright <jason@cvs.openbsd.org>1999-07-16 14:59:08 +0000
committerJason Wright <jason@cvs.openbsd.org>1999-07-16 14:59:08 +0000
commit0e5636a12a40a5904e9bb88ec8683a6a91eb98e0 (patch)
tree79139316eab4e879279fa709452e905153b78c4e
parent9e2853823c92af3c3ed247622175ff75af176b46 (diff)
Sync with NetBSD:
o Implement asynchronous autonegotiation when driven by the MII tick (one-second clock). Prevents .5s delays every 5 seconds when the interface is up but there is no link. o Correct the sense of the PCR_FLINK100 bit in nsphy.c.
-rw-r--r--sys/dev/mii/exphy.c8
-rw-r--r--sys/dev/mii/icsphy.c8
-rw-r--r--sys/dev/mii/inphy.c12
-rw-r--r--sys/dev/mii/lxtphy.c12
-rw-r--r--sys/dev/mii/mii_physubr.c74
-rw-r--r--sys/dev/mii/miivar.h9
-rw-r--r--sys/dev/mii/mtdphy.c7
-rw-r--r--sys/dev/mii/nsphy.c19
-rw-r--r--sys/dev/mii/qsphy.c8
-rw-r--r--sys/dev/mii/rlphy.c7
-rw-r--r--sys/dev/mii/sqphy.c12
-rw-r--r--sys/dev/mii/tlphy.c59
-rw-r--r--sys/dev/mii/ukphy.c12
13 files changed, 166 insertions, 81 deletions
diff --git a/sys/dev/mii/exphy.c b/sys/dev/mii/exphy.c
index 8a16211e1ec..8d88968f104 100644
--- a/sys/dev/mii/exphy.c
+++ b/sys/dev/mii/exphy.c
@@ -1,8 +1,8 @@
-/* $OpenBSD: exphy.c,v 1.2 1998/11/11 19:34:44 jason Exp $ */
-/* $NetBSD: exphy.c,v 1.15 1998/11/05 00:19:32 thorpej Exp $ */
+/* $OpenBSD: exphy.c,v 1.3 1999/07/16 14:59:06 jason Exp $ */
+/* $NetBSD: exphy.c,v 1.15.6.1 1999/04/23 15:39:33 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
@@ -216,7 +216,7 @@ exphy_service(sc, mii, cmd)
*/
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:
/*
diff --git a/sys/dev/mii/icsphy.c b/sys/dev/mii/icsphy.c
index 8e26627278c..10a84e1cd9d 100644
--- a/sys/dev/mii/icsphy.c
+++ b/sys/dev/mii/icsphy.c
@@ -1,8 +1,8 @@
-/* $OpenBSD: icsphy.c,v 1.1 1998/11/11 19:34:45 jason Exp $ */
-/* $NetBSD: icsphy.c,v 1.8 1998/11/05 04:08:01 thorpej Exp $ */
+/* $OpenBSD: icsphy.c,v 1.2 1999/07/16 14:59:06 jason Exp $ */
+/* $NetBSD: icsphy.c,v 1.8.6.1 1999/04/23 15:40:56 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
@@ -208,7 +208,7 @@ icsphy_service(sc, mii, cmd)
*/
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:
/*
diff --git a/sys/dev/mii/inphy.c b/sys/dev/mii/inphy.c
index 6f43b03fb1a..38c2660ca52 100644
--- a/sys/dev/mii/inphy.c
+++ b/sys/dev/mii/inphy.c
@@ -1,8 +1,8 @@
-/* $OpenBSD: inphy.c,v 1.2 1998/11/11 19:34:46 jason Exp $ */
-/* $NetBSD: inphy.c,v 1.10 1998/11/05 04:08:02 thorpej Exp $ */
+/* $OpenBSD: inphy.c,v 1.3 1999/07/16 14:59:06 jason Exp $ */
+/* $NetBSD: inphy.c,v 1.10.6.1 1999/04/23 15:39:09 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
@@ -78,6 +78,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>
@@ -216,7 +217,7 @@ inphy_service(sc, mii, cmd)
*/
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:
/*
@@ -270,7 +271,8 @@ inphy_service(sc, mii, cmd)
sc->mii_ticks = 0;
mii_phy_reset(sc);
- (void) mii_phy_auto(sc);
+ if (mii_phy_auto(sc, 0) == EJUSTRETURN)
+ return (0);
break;
}
diff --git a/sys/dev/mii/lxtphy.c b/sys/dev/mii/lxtphy.c
index 5209d172d63..cf5e290757b 100644
--- a/sys/dev/mii/lxtphy.c
+++ b/sys/dev/mii/lxtphy.c
@@ -1,8 +1,8 @@
-/* $OpenBSD: lxtphy.c,v 1.1 1998/11/11 19:34:46 jason Exp $ */
-/* $NetBSD: lxtphy.c,v 1.9 1998/11/05 04:08:02 thorpej Exp $ */
+/* $OpenBSD: lxtphy.c,v 1.2 1999/07/16 14:59:06 jason Exp $ */
+/* $NetBSD: lxtphy.c,v 1.9.6.1 1999/04/23 15:41:43 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
@@ -78,6 +78,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>
@@ -207,7 +208,7 @@ lxtphy_service(sc, mii, cmd)
*/
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:
/*
@@ -262,7 +263,8 @@ lxtphy_service(sc, mii, cmd)
sc->mii_ticks = 0;
mii_phy_reset(sc);
- (void) mii_phy_auto(sc);
+ if (mii_phy_auto(sc, 0) == EJUSTRETURN)
+ return (0);
break;
}
diff --git a/sys/dev/mii/mii_physubr.c b/sys/dev/mii/mii_physubr.c
index 4d7ee6dd5fd..dc8a0ba0b56 100644
--- a/sys/dev/mii/mii_physubr.c
+++ b/sys/dev/mii/mii_physubr.c
@@ -1,8 +1,8 @@
-/* $OpenBSD: mii_physubr.c,v 1.1 1998/11/11 19:34:47 jason Exp $ */
-/* $NetBSD: mii_physubr.c,v 1.2 1998/11/04 23:28:15 thorpej Exp $ */
+/* $OpenBSD: mii_physubr.c,v 1.2 1999/07/16 14:59:07 jason 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
@@ -45,7 +45,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>
@@ -53,28 +55,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);
+ }
- /* 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);
+ 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
+ }
+
+ /*
+ * 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
diff --git a/sys/dev/mii/miivar.h b/sys/dev/mii/miivar.h
index be716d91b86..e084e861bde 100644
--- a/sys/dev/mii/miivar.h
+++ b/sys/dev/mii/miivar.h
@@ -1,8 +1,8 @@
-/* $OpenBSD: miivar.h,v 1.2 1998/11/11 19:34:48 jason Exp $ */
-/* $NetBSD: miivar.h,v 1.7 1998/11/05 04:08:02 thorpej Exp $ */
+/* $OpenBSD: miivar.h,v 1.3 1999/07/16 14:59:07 jason Exp $ */
+/* $NetBSD: miivar.h,v 1.7.6.1 1999/04/23 15:40:35 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
@@ -129,6 +129,7 @@ typedef struct mii_softc mii_softc_t;
/* mii_flags */
#define MIIF_NOISOLATE 0x0001 /* do not isolate the PHY */
+#define MIIF_DOINGAUTO 0x0002 /* doing autonegotiation */
/*
* Used to attach a PHY to a parent.
@@ -161,7 +162,7 @@ void mii_add_media __P((struct mii_data *, int, int));
int mii_media_from_bmcr __P((int));
-int mii_phy_auto __P((struct mii_softc *));
+int mii_phy_auto __P((struct mii_softc *, int));
void mii_phy_reset __P((struct mii_softc *));
void ukphy_status __P((struct mii_softc *));
diff --git a/sys/dev/mii/mtdphy.c b/sys/dev/mii/mtdphy.c
index 0907a470e27..4ea4f144d15 100644
--- a/sys/dev/mii/mtdphy.c
+++ b/sys/dev/mii/mtdphy.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: mtdphy.c,v 1.1 1998/12/28 03:37:55 jason Exp $ */
+/* $OpenBSD: mtdphy.c,v 1.2 1999/07/16 14:59:07 jason Exp $ */
/*
- * Copyright (c) 1998 Jason L. Wright (jason@thought.net)
+ * Copyright (c) 1998, 1999 Jason L. Wright (jason@thought.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -41,6 +41,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>
@@ -152,7 +153,7 @@ mtdphy_service(sc, mii, cmd)
*/
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_TX:
diff --git a/sys/dev/mii/nsphy.c b/sys/dev/mii/nsphy.c
index 2dcb8825fdc..02a602ed862 100644
--- a/sys/dev/mii/nsphy.c
+++ b/sys/dev/mii/nsphy.c
@@ -1,8 +1,8 @@
-/* $OpenBSD: nsphy.c,v 1.4 1999/01/04 04:44:05 jason Exp $ */
-/* $NetBSD: nsphy.c,v 1.16 1998/11/05 04:08:02 thorpej Exp $ */
+/* $OpenBSD: nsphy.c,v 1.5 1999/07/16 14:59:07 jason Exp $ */
+/* $NetBSD: nsphy.c,v 1.18 1999/07/14 23:57:36 thorpej 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
@@ -78,6 +78,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>
@@ -228,11 +229,10 @@ nsphy_service(sc, mii, cmd)
reg |= PCR_CIMDIS;
/*
- * Make sure "force link good" is not set. It's only
- * intended for debugging, but sometimes it's set
- * after a reset.
+ * Make sure "force link good" is set to normal mode.
+ * It's only intended for debugging.
*/
- reg &= ~PCR_FLINK100;
+ reg |= PCR_FLINK100;
#if 0
/*
@@ -253,7 +253,7 @@ nsphy_service(sc, mii, cmd)
*/
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:
/*
@@ -325,7 +325,8 @@ nsphy_service(sc, mii, cmd)
sc->mii_ticks = 0;
nsphy_reset(sc);
- (void) mii_phy_auto(sc);
+ if (mii_phy_auto(sc, 0) == EJUSTRETURN)
+ return (0);
break;
}
diff --git a/sys/dev/mii/qsphy.c b/sys/dev/mii/qsphy.c
index 5ac3f7f752e..598466a5b99 100644
--- a/sys/dev/mii/qsphy.c
+++ b/sys/dev/mii/qsphy.c
@@ -1,8 +1,8 @@
-/* $OpenBSD: qsphy.c,v 1.2 1998/11/11 19:34:48 jason Exp $ */
-/* $NetBSD: qsphy.c,v 1.11 1998/11/05 04:08:02 thorpej Exp $ */
+/* $OpenBSD: qsphy.c,v 1.3 1999/07/16 14:59:07 jason Exp $ */
+/* $NetBSD: qsphy.c,v 1.11.6.1 1999/04/23 15:39:21 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
@@ -208,7 +208,7 @@ qsphy_service(sc, mii, cmd)
*/
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:
/*
diff --git a/sys/dev/mii/rlphy.c b/sys/dev/mii/rlphy.c
index e5e6ae40658..163dba09be4 100644
--- a/sys/dev/mii/rlphy.c
+++ b/sys/dev/mii/rlphy.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: rlphy.c,v 1.2 1998/11/20 02:42:14 jason Exp $ */
+/* $OpenBSD: rlphy.c,v 1.3 1999/07/16 14:59:07 jason Exp $ */
/*
- * Copyright (c) 1998 Jason L. Wright (jason@thought.net)
+ * Copyright (c) 1998, 1999 Jason L. Wright (jason@thought.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -43,6 +43,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>
@@ -155,7 +156,7 @@ rlphy_service(sc, mii, cmd)
*/
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:
/*
diff --git a/sys/dev/mii/sqphy.c b/sys/dev/mii/sqphy.c
index eecc2ec46ec..0f58e2d2589 100644
--- a/sys/dev/mii/sqphy.c
+++ b/sys/dev/mii/sqphy.c
@@ -1,8 +1,8 @@
-/* $OpenBSD: sqphy.c,v 1.1 1998/11/11 19:34:49 jason Exp $ */
-/* $NetBSD: sqphy.c,v 1.8 1998/11/05 04:08:02 thorpej Exp $ */
+/* $OpenBSD: sqphy.c,v 1.2 1999/07/16 14:59:07 jason Exp $ */
+/* $NetBSD: sqphy.c,v 1.8.6.1 1999/04/23 15:41:25 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
@@ -78,6 +78,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>
@@ -207,7 +208,7 @@ sqphy_service(sc, mii, cmd)
*/
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:
/*
@@ -261,7 +262,8 @@ sqphy_service(sc, mii, cmd)
sc->mii_ticks = 0;
mii_phy_reset(sc);
- (void) mii_phy_auto(sc);
+ if (mii_phy_auto(sc, 0) == EJUSTRETURN)
+ return (0);
break;
}
diff --git a/sys/dev/mii/tlphy.c b/sys/dev/mii/tlphy.c
index 18dcfab285e..84457393f5d 100644
--- a/sys/dev/mii/tlphy.c
+++ b/sys/dev/mii/tlphy.c
@@ -1,8 +1,8 @@
-/* $OpenBSD: tlphy.c,v 1.2 1998/11/11 19:34:50 jason Exp $ */
-/* $NetBSD: tlphy.c,v 1.16 1998/11/05 00:19:32 thorpej Exp $ */
+/* $OpenBSD: tlphy.c,v 1.3 1999/07/16 14:59:07 jason 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
@@ -76,6 +76,7 @@
#include <sys/kernel.h>
#include <sys/device.h>
#include <sys/socket.h>
+#include <sys/errno.h>
#ifdef __NetBSD__
#include <machine/bus.h>
@@ -105,6 +106,7 @@
struct tlphy_softc {
struct mii_softc sc_mii; /* generic PHY */
int sc_tlphycap;
+ int sc_need_acomp;
};
#ifdef __NetBSD__
@@ -125,7 +127,8 @@ struct cfattach tlphy_ca = {
};
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
@@ -227,6 +230,9 @@ tlphy_service(self, mii, cmd)
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:
/*
@@ -260,7 +266,7 @@ tlphy_service(self, mii, cmd)
* 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:
@@ -316,7 +322,8 @@ tlphy_service(self, mii, cmd)
sc->sc_mii.mii_ticks = 0;
mii_phy_reset(&sc->sc_mii);
- tlphy_auto(sc);
+ if (tlphy_auto(sc, 0) == EJUSTRETURN)
+ return (0);
break;
}
@@ -383,14 +390,41 @@ tlphy_status(sc)
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
@@ -407,11 +441,4 @@ tlphy_auto(sc)
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);
}
diff --git a/sys/dev/mii/ukphy.c b/sys/dev/mii/ukphy.c
index 035a5a5d2dd..6ae8a128791 100644
--- a/sys/dev/mii/ukphy.c
+++ b/sys/dev/mii/ukphy.c
@@ -1,8 +1,8 @@
-/* $OpenBSD: ukphy.c,v 1.2 1999/05/31 22:13:47 millert Exp $ */
-/* $NetBSD: ukphy.c,v 1.1 1998/11/05 00:36:48 thorpej Exp $ */
+/* $OpenBSD: ukphy.c,v 1.3 1999/07/16 14:59:07 jason Exp $ */
+/* $NetBSD: ukphy.c,v 1.1.6.1 1999/04/23 15:39:00 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>
@@ -204,7 +205,7 @@ ukphy_service(sc, mii, cmd)
*/
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:
/*
@@ -258,7 +259,8 @@ ukphy_service(sc, mii, cmd)
sc->mii_ticks = 0;
mii_phy_reset(sc);
- (void) mii_phy_auto(sc);
+ if (mii_phy_auto(sc, 0) == EJUSTRETURN)
+ return (0);
break;
}