diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2002-04-07 23:23:50 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2002-04-07 23:23:50 +0000 |
commit | 752fff194f19d2b87b971091292141daa060b18f (patch) | |
tree | 3a6a6853d650cec9fc59d5e0213772bf92e8192d | |
parent | 22f3493ebcdf605c8797fed0a307101a53259eb3 (diff) |
Don't reset COR in wi_reset(), break it out into its own function and
only call it from wi_attach() and wi_pcmcia_activate() (ie: just once).
It would be nicer to have the COR reset be part of the bus-specific
code but we need to know whether or not we have a Lucent card since
old Lucent firmware revs get messed up on a COR soft reset.
Even with the COR reset we still need to avoid initializing Symbol
cards more than once. However, we *do* want to do a reset after
returning from suspend. Therefore, rename wi_gone to wi_flags and
store both the attach and init status in it. wi_reset() now checks
wi_flags to see if the card should be initialized in the Symbol case.
Info on initializing Symbol cards once from NetBSD.
-rw-r--r-- | sys/dev/ic/if_wi.c | 56 | ||||
-rw-r--r-- | sys/dev/ic/if_wi_hostap.c | 4 | ||||
-rw-r--r-- | sys/dev/ic/if_wivar.h | 8 | ||||
-rw-r--r-- | sys/dev/pcmcia/if_wi_pcmcia.c | 9 |
4 files changed, 51 insertions, 26 deletions
diff --git a/sys/dev/ic/if_wi.c b/sys/dev/ic/if_wi.c index a0078e5ec14..570ec408666 100644 --- a/sys/dev/ic/if_wi.c +++ b/sys/dev/ic/if_wi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wi.c,v 1.48 2002/04/06 23:48:38 millert Exp $ */ +/* $OpenBSD: if_wi.c,v 1.49 2002/04/07 23:23:49 millert Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -124,7 +124,7 @@ u_int32_t widebug = WIDEBUG; #if !defined(lint) && !defined(__OpenBSD__) static const char rcsid[] = - "$OpenBSD: if_wi.c,v 1.48 2002/04/06 23:48:38 millert Exp $"; + "$OpenBSD: if_wi.c,v 1.49 2002/04/07 23:23:49 millert Exp $"; #endif /* lint */ #ifdef foo @@ -132,6 +132,7 @@ static u_int8_t wi_mcast_addr[6] = { 0x01, 0x60, 0x1D, 0x00, 0x01, 0x00 }; #endif STATIC void wi_reset(struct wi_softc *); +STATIC void wi_cor_reset(struct wi_softc *); STATIC int wi_ioctl(struct ifnet *, u_long, caddr_t); STATIC void wi_start(struct ifnet *); STATIC void wi_watchdog(struct ifnet *); @@ -183,8 +184,9 @@ wi_attach(sc) struct ifnet *ifp; int error; - sc->wi_gone = 0; + sc->wi_flags = WI_FLAGS_ATTACHED; + wi_cor_reset(sc); wi_reset(sc); /* Read the station address. */ @@ -341,7 +343,7 @@ wi_intr(vsc) ifp = &sc->arpcom.ac_if; - if (sc->wi_gone || !(ifp->if_flags & IFF_UP)) { + if (!(sc->wi_flags & WI_FLAGS_ATTACHED) || !(ifp->if_flags & IFF_UP)) { CSR_WRITE_2(sc, WI_EVENT_ACK, 0xFFFF); CSR_WRITE_2(sc, WI_INT_EN, 0); return (0); @@ -683,9 +685,34 @@ STATIC void wi_reset(sc) struct wi_softc *sc; { + DPRINTF(WID_RESET, ("wi_reset: sc %p\n", sc)); + + /* Symbol firmware cannot be initialized more than once. */ + if (sc->sc_firmware_type == WI_SYMBOL && + (sc->wi_flags & WI_FLAGS_INITIALIZED)) + return; + + if (wi_cmd(sc, WI_CMD_INI, 0)) + printf(WI_PRT_FMT ": init failed\n", WI_PRT_ARG(sc)); + else + sc->wi_flags |= WI_FLAGS_INITIALIZED; + + CSR_WRITE_2(sc, WI_INT_EN, 0); + CSR_WRITE_2(sc, WI_EVENT_ACK, 0xFFFF); + + /* Calibrate timer. */ + WI_SETVAL(WI_RID_TICK_TIME, 8); + + return; +} + +STATIC void +wi_cor_reset(sc) + struct wi_softc *sc; +{ u_int8_t cor_value; - DPRINTF(WID_RESET, ("wi_reset: sc %p\n", sc)); + DPRINTF(WID_RESET, ("wi_cor_reset: sc %p\n", sc)); /* * Do a soft reset of the card. This is required by Symbol cards @@ -703,15 +730,6 @@ wi_reset(sc) DELAY(1000); } - if (wi_cmd(sc, WI_CMD_INI, 0)) - printf(WI_PRT_FMT ": init failed\n", WI_PRT_ARG(sc)); - - CSR_WRITE_2(sc, WI_INT_EN, 0); - CSR_WRITE_2(sc, WI_EVENT_ACK, 0xFFFF); - - /* Calibrate timer. */ - WI_SETVAL(WI_RID_TICK_TIME, 8); - return; } @@ -1196,7 +1214,7 @@ wi_ioctl(ifp, command, data) sc = ifp->if_softc; ifr = (struct ifreq *)data; - if (sc->wi_gone) { + if (!(sc->wi_flags & WI_FLAGS_ATTACHED)) { splx(s); return(ENODEV); } @@ -1418,7 +1436,7 @@ wi_init(sc) struct wi_ltv_macaddr mac; int id = 0; - if (sc->wi_gone) + if (!(sc->wi_flags & WI_FLAGS_ATTACHED)) return; DPRINTF(WID_INIT, ("wi_init: sc %p\n", sc)); @@ -1702,7 +1720,7 @@ wi_start(ifp) DPRINTF(WID_START, ("wi_start: ifp %p sc %p\n", ifp, sc)); - if (sc->wi_gone) + if (!(sc->wi_flags & WI_FLAGS_ATTACHED)) return; if (ifp->if_flags & IFF_OACTIVE) @@ -1851,7 +1869,7 @@ wi_mgmt_xmit(sc, data, len) struct wi_80211_hdr *hdr; caddr_t dptr; - if (sc->wi_gone) + if (!(sc->wi_flags & WI_FLAGS_ATTACHED)) return(ENODEV); hdr = (struct wi_80211_hdr *)data; @@ -1888,7 +1906,7 @@ wi_stop(sc) wihap_shutdown(sc); - if (sc->wi_gone) + if (!(sc->wi_flags & WI_FLAGS_ATTACHED)) return; DPRINTF(WID_STOP, ("wi_stop: sc %p\n", sc)); diff --git a/sys/dev/ic/if_wi_hostap.c b/sys/dev/ic/if_wi_hostap.c index 5866a7882b0..e989e086aa8 100644 --- a/sys/dev/ic/if_wi_hostap.c +++ b/sys/dev/ic/if_wi_hostap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wi_hostap.c,v 1.8 2002/04/01 22:00:18 mickey Exp $ */ +/* $OpenBSD: if_wi_hostap.c,v 1.9 2002/04/07 23:23:49 millert Exp $ */ /* * Copyright (c) 2002 @@ -288,7 +288,7 @@ wihap_shutdown(struct wi_softc *sc) timeout_del(&sta->tmo); - if (!sc->wi_gone) { + if (sc->wi_flags & WI_FLAGS_ATTACHED) { /* Disassociate station. */ if (sta->flags & WI_SIFLAGS_ASSOC) wihap_sta_disassoc(sc, sta, diff --git a/sys/dev/ic/if_wivar.h b/sys/dev/ic/if_wivar.h index 3cfd244dd30..ee065adb670 100644 --- a/sys/dev/ic/if_wivar.h +++ b/sys/dev/ic/if_wivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wivar.h,v 1.8 2002/04/06 23:48:38 millert Exp $ */ +/* $OpenBSD: if_wivar.h,v 1.9 2002/04/07 23:23:49 millert Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -49,7 +49,7 @@ struct wi_softc { bus_size_t wi_cor_offset; int wi_tx_data_id; int wi_tx_mgmt_id; - int wi_gone; + int wi_flags; int wi_if_flags; u_int16_t wi_ptype; u_int16_t wi_portnum; @@ -89,6 +89,10 @@ struct wi_softc { int wi_icv_flag; }; +/* Values for wi_flags. */ +#define WI_FLAGS_ATTACHED 0x01 +#define WI_FLAGS_INITIALIZED 0x02 + /* Firmware types */ #define WI_LUCENT 0 #define WI_INTERSIL 1 diff --git a/sys/dev/pcmcia/if_wi_pcmcia.c b/sys/dev/pcmcia/if_wi_pcmcia.c index bd12a0e9d82..d0f4695940b 100644 --- a/sys/dev/pcmcia/if_wi_pcmcia.c +++ b/sys/dev/pcmcia/if_wi_pcmcia.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wi_pcmcia.c,v 1.26 2002/04/06 21:58:12 millert Exp $ */ +/* $OpenBSD: if_wi_pcmcia.c,v 1.27 2002/04/07 23:23:49 millert Exp $ */ /* $NetBSD: if_wi_pcmcia.c,v 1.14 2001/11/26 04:34:56 ichiro Exp $ */ /* @@ -77,6 +77,7 @@ int wi_pcmcia_activate(struct device *, enum devact); int wi_intr(void *); int wi_attach(struct wi_softc *); +void wi_cor_reset(struct wi_softc *); void wi_init(struct wi_softc *); void wi_stop(struct wi_softc *); @@ -379,7 +380,7 @@ wi_pcmcia_detach(dev, flags) struct wi_softc *sc = &psc->sc_wi; struct ifnet *ifp = &sc->arpcom.ac_if; - if (sc->wi_gone) { + if (!(sc->wi_flags & WI_FLAGS_ATTACHED)) { printf("%s: already detached\n", sc->sc_dev.dv_xname); return (0); } @@ -393,7 +394,7 @@ wi_pcmcia_detach(dev, flags) ether_ifdetach(ifp); if_detach(ifp); - sc->wi_gone = 1; + sc->wi_flags = 0; return (0); } @@ -414,6 +415,7 @@ wi_pcmcia_activate(dev, act) pcmcia_function_enable(psc->sc_pf); sc->sc_ih = pcmcia_intr_establish(psc->sc_pf, IPL_NET, wi_intr, sc, sc->sc_dev.dv_xname); + wi_cor_reset(sc); wi_init(sc); break; @@ -421,6 +423,7 @@ wi_pcmcia_activate(dev, act) ifp->if_timer = 0; if (ifp->if_flags & IFF_RUNNING) wi_stop(sc); + sc->wi_flags &= ~WI_FLAGS_INITIALIZED; pcmcia_intr_disestablish(psc->sc_pf, sc->sc_ih); pcmcia_function_disable(psc->sc_pf); break; |