summaryrefslogtreecommitdiff
path: root/sys/dev/mii/brgphy.c
diff options
context:
space:
mode:
authorBrad Smith <brad@cvs.openbsd.org>2006-07-23 06:34:04 +0000
committerBrad Smith <brad@cvs.openbsd.org>2006-07-23 06:34:04 +0000
commite2dcfa32f2b5c58bd3067fffc0bdb1c894e3bc25 (patch)
treefb3d13ef37022bea1e7c0a561d60ddd67b0445ad /sys/dev/mii/brgphy.c
parentc38d84932f7b9f5f2ff59e399e329c01bae8b3f4 (diff)
revert back to the old brgphy_mii_phy_auto() which simplifies the autoneg code.
Diffstat (limited to 'sys/dev/mii/brgphy.c')
-rw-r--r--sys/dev/mii/brgphy.c72
1 files changed, 21 insertions, 51 deletions
diff --git a/sys/dev/mii/brgphy.c b/sys/dev/mii/brgphy.c
index cb9eddb7057..7151fd9a5a2 100644
--- a/sys/dev/mii/brgphy.c
+++ b/sys/dev/mii/brgphy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: brgphy.c,v 1.49 2006/06/26 04:59:26 brad Exp $ */
+/* $OpenBSD: brgphy.c,v 1.50 2006/07/23 06:34:03 brad Exp $ */
/*
* Copyright (c) 2000
@@ -44,6 +44,7 @@
#include <sys/kernel.h>
#include <sys/device.h>
#include <sys/socket.h>
+#include <sys/timeout.h>
#include <sys/errno.h>
#include <machine/bus.h>
@@ -81,7 +82,7 @@ struct cfdriver brgphy_cd = {
int brgphy_service(struct mii_softc *, struct mii_data *, int);
void brgphy_status(struct mii_softc *);
-int brgphy_mii_phy_auto(struct mii_softc *, int);
+int brgphy_mii_phy_auto(struct mii_softc *);
void brgphy_loop(struct mii_softc *);
void brgphy_reset(struct mii_softc *);
void brgphy_load_dspcode(struct mii_softc *);
@@ -224,7 +225,7 @@ brgphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
if (PHY_READ(sc, BRGPHY_MII_BMCR) & BRGPHY_BMCR_AUTOEN)
return (0);
#endif
- (void) brgphy_mii_phy_auto(sc, 1);
+ (void) brgphy_mii_phy_auto(sc);
break;
case IFM_1000_T:
speed = BRGPHY_S1000;
@@ -316,8 +317,7 @@ setit:
break;
sc->mii_ticks = 0;
- if (brgphy_mii_phy_auto(sc, 0) == EJUSTRETURN)
- return (0);
+ brgphy_mii_phy_auto(sc);
break;
}
@@ -405,54 +405,24 @@ brgphy_status(struct mii_softc *sc)
int
-brgphy_mii_phy_auto(struct mii_softc *sc, int waitfor)
+brgphy_mii_phy_auto(struct mii_softc *sc)
{
- int bmsr, ktcr = 0, i;
-
- if ((sc->mii_flags & MIIF_DOINGAUTO) == 0) {
- brgphy_loop(sc);
- PHY_RESET(sc);
- ktcr = BRGPHY_1000CTL_AFD|BRGPHY_1000CTL_AHD;
- if (sc->mii_model == MII_MODEL_xxBROADCOM_BCM5701)
- ktcr |= BRGPHY_1000CTL_MSE|BRGPHY_1000CTL_MSC;
- PHY_WRITE(sc, BRGPHY_MII_1000CTL, ktcr);
- ktcr = PHY_READ(sc, BRGPHY_MII_1000CTL);
- DELAY(1000);
- PHY_WRITE(sc, BRGPHY_MII_ANAR,
- BMSR_MEDIA_TO_ANAR(sc->mii_capabilities) | ANAR_CSMA);
- DELAY(1000);
- PHY_WRITE(sc, BRGPHY_MII_BMCR,
- BRGPHY_BMCR_AUTOEN | BRGPHY_BMCR_STARTNEG);
- PHY_WRITE(sc, BRGPHY_MII_IMR, 0xFF00);
- }
+ int ktcr = 0;
- if (waitfor) {
- /* Wait 500ms for it to complete. */
- for (i = 0; i < 500; i++) {
- if ((bmsr = PHY_READ(sc, BRGPHY_MII_BMSR)) &
- BRGPHY_BMSR_ACOMP)
- return (0);
- 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 ((sc->mii_flags & MIIF_DOINGAUTO) == 0) {
- sc->mii_flags |= MIIF_DOINGAUTO;
- timeout_set(&sc->mii_phy_timo, mii_phy_auto_timeout, sc);
- timeout_add(&sc->mii_phy_timo, hz / 2);
- }
+ brgphy_loop(sc);
+ PHY_RESET(sc);
+ ktcr = BRGPHY_1000CTL_AFD|BRGPHY_1000CTL_AHD;
+ if (sc->mii_model == MII_MODEL_xxBROADCOM_BCM5701)
+ ktcr |= BRGPHY_1000CTL_MSE|BRGPHY_1000CTL_MSC;
+ PHY_WRITE(sc, BRGPHY_MII_1000CTL, ktcr);
+ ktcr = PHY_READ(sc, BRGPHY_MII_1000CTL);
+ DELAY(1000);
+ PHY_WRITE(sc, BRGPHY_MII_ANAR,
+ BMSR_MEDIA_TO_ANAR(sc->mii_capabilities) | ANAR_CSMA);
+ DELAY(1000);
+ PHY_WRITE(sc, BRGPHY_MII_BMCR,
+ BRGPHY_BMCR_AUTOEN | BRGPHY_BMCR_STARTNEG);
+ PHY_WRITE(sc, BRGPHY_MII_IMR, 0xFF00);
return (EJUSTRETURN);
}