diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2002-04-06 20:31:57 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2002-04-06 20:31:57 +0000 |
commit | 1ffd2dd0212e07660e093e5bb0ea41c1d79ba481 (patch) | |
tree | 67ff5176a31fb981583028fdc695a3a4a6dff8e0 | |
parent | 67857a500302b2ff61b461cb9b125bdb6415d074 (diff) |
Add support for Symbol cards and printing of the primary station
firmware version. Adapted from NetBSD and the Linux orinoco driver.
The Symbol firmware requires that we do a COR soft reset before
initializing the card in wi_reset(). Also, setting WI_RID_ROAMING_MODE
caused the Symbol card to go into a strange (non-working) mode with
firmware 2.x.x.
There are some other Symbol additions/oddities that will need to be
addressed in the future.
-rw-r--r-- | sys/dev/ic/if_wi.c | 194 | ||||
-rw-r--r-- | sys/dev/ic/if_wi_ieee.h | 14 | ||||
-rw-r--r-- | sys/dev/ic/if_wireg.h | 44 | ||||
-rw-r--r-- | sys/dev/ic/if_wivar.h | 14 | ||||
-rw-r--r-- | sys/dev/pci/if_wi_pci.c | 41 | ||||
-rw-r--r-- | sys/dev/pcmcia/if_wi_pcmcia.c | 7 |
6 files changed, 203 insertions, 111 deletions
diff --git a/sys/dev/ic/if_wi.c b/sys/dev/ic/if_wi.c index 1e729efd582..894aedc589c 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.45 2002/04/05 15:35:34 millert Exp $ */ +/* $OpenBSD: if_wi.c,v 1.46 2002/04/06 20:31:56 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.45 2002/04/05 15:35:34 millert Exp $"; + "$OpenBSD: if_wi.c,v 1.46 2002/04/06 20:31:56 millert Exp $"; #endif /* lint */ #ifdef foo @@ -269,14 +269,14 @@ wi_attach(sc, print_cis) ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_AUTO, 0, 0), 0); ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_AUTO, IFM_IEEE80211_ADHOC, 0), 0); - if (sc->sc_prism2) + if (sc->sc_firmware_type == WI_INTERSIL) ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_AUTO, IFM_IEEE80211_HOSTAP, 0), 0); if (sc->wi_supprates & WI_SUPPRATES_1M) { ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS1, 0, 0), 0); ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS1, IFM_IEEE80211_ADHOC, 0), 0); - if (sc->sc_prism2) + if (sc->sc_firmware_type == WI_INTERSIL) ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS1, IFM_IEEE80211_HOSTAP, 0), 0); } @@ -284,7 +284,7 @@ wi_attach(sc, print_cis) ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS2, 0, 0), 0); ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS2, IFM_IEEE80211_ADHOC, 0), 0); - if (sc->sc_prism2) + if (sc->sc_firmware_type == WI_INTERSIL) ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS2, IFM_IEEE80211_HOSTAP, 0), 0); } @@ -292,7 +292,7 @@ wi_attach(sc, print_cis) ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS5, 0, 0), 0); ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS5, IFM_IEEE80211_ADHOC, 0), 0); - if (sc->sc_prism2) + if (sc->sc_firmware_type == WI_INTERSIL) ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS5, IFM_IEEE80211_HOSTAP, 0), 0); } @@ -300,7 +300,7 @@ wi_attach(sc, print_cis) ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS11, 0, 0), 0); ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS11, IFM_IEEE80211_ADHOC, 0), 0); - if (sc->sc_prism2) + if (sc->sc_firmware_type == WI_INTERSIL) ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS11, IFM_IEEE80211_HOSTAP, 0), 0); ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_MANUAL, 0, 0), 0); @@ -683,10 +683,29 @@ STATIC void wi_reset(sc) struct wi_softc *sc; { + u_int8_t cor_value; + DPRINTF(WID_RESET, ("wi_reset: sc %p\n", sc)); + /* + * Do a soft reset of the card. This is required by Symbol cards + * and shouldn't hurt others. We don't do this on Lucent cards + * because it messes up some old Lucent firmware revisions. + */ + if (sc->sc_firmware_type != WI_LUCENT) { + cor_value = bus_space_read_2(sc->wi_ltag, sc->wi_lhandle, + sc->wi_cor_offset); + bus_space_write_1(sc->wi_ltag, sc->wi_lhandle, + sc->wi_cor_offset, (cor_value | WI_COR_SOFT_RESET)); + DELAY(1000); + bus_space_write_1(sc->wi_ltag, sc->wi_lhandle, + sc->wi_cor_offset, (cor_value & ~WI_COR_SOFT_RESET)); + 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); @@ -708,7 +727,7 @@ wi_read_record(sc, ltv) int len, code; struct wi_ltv_gen *oltv, p2ltv; - if (sc->sc_prism2) { + if (sc->sc_firmware_type != WI_LUCENT) { oltv = ltv; switch (ltv->wi_type) { case WI_RID_ENCRYPTION: @@ -752,7 +771,7 @@ wi_read_record(sc, ltv) if (ltv->wi_len > 1) CSR_READ_RAW_2(sc, WI_DATA1, ptr, (ltv->wi_len-1)*2); - if (sc->sc_prism2) { + if (sc->sc_firmware_type != WI_LUCENT) { int v; switch (oltv->wi_type) { @@ -778,15 +797,9 @@ wi_read_record(sc, ltv) oltv->wi_val = htole16(0); break; case WI_RID_TX_CRYPT_KEY: - oltv->wi_len = 2; - oltv->wi_val = ltv->wi_val; - break; case WI_RID_CNFAUTHMODE: oltv->wi_len = 2; - if (ltv->wi_val & htole16(0x01)) - oltv->wi_val = htole16(1); - else if (ltv->wi_val & htole16(0x02)) - oltv->wi_val = htole16(2); + oltv->wi_val = ltv->wi_val; break; } } @@ -806,7 +819,7 @@ wi_write_record(sc, ltv) int i; struct wi_ltv_gen p2ltv; - if (sc->sc_prism2) { + if (sc->sc_firmware_type != WI_LUCENT) { int v; switch (ltv->wi_type) { @@ -834,11 +847,14 @@ wi_write_record(sc, ltv) /* Disable tx encryption... * it's broken. */ - p2ltv.wi_val = htole16(0x13); + p2ltv.wi_val = htole16(HOST_ENCRYPT | + PRIVACY_INVOKED | + EXCLUDE_UNENCRYPTED); else - p2ltv.wi_val = htole16(0x03); + p2ltv.wi_val = htole16(PRIVACY_INVOKED | + EXCLUDE_UNENCRYPTED); else - p2ltv.wi_val = htole16(0x90); + p2ltv.wi_val = htole16(HOST_ENCRYPT | HOST_DECRYPT); ltv = &p2ltv; break; case WI_RID_TX_CRYPT_KEY: @@ -867,15 +883,6 @@ wi_write_record(sc, ltv) } } return (0); - case WI_RID_CNFAUTHMODE: - p2ltv.wi_type = WI_RID_CNFAUTHMODE; - p2ltv.wi_len = 2; - if (ltv->wi_val == htole16(1)) - p2ltv.wi_val = htole16(0x01); - else if (ltv->wi_val == htole16(2)) - p2ltv.wi_val = htole16(0x02); - ltv = &p2ltv; - break; } } @@ -1021,8 +1028,8 @@ wi_alloc_nicmem(sc, len, id) if (i < 0) return(ETIMEDOUT); - CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_ALLOC); *id = CSR_READ_2(sc, WI_ALLOC_FID); + CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_ALLOC); if (wi_seek(sc, *id, 0, WI_BAP0)) return(EIO); @@ -1306,13 +1313,20 @@ wi_ioctl(ifp, command, data) error = copyin(ifr->ifr_data, &wreq, sizeof(wreq)); if (error) break; - if (wreq.wi_type == WI_RID_IFACE_STATS) { - error = EINVAL; + error = EINVAL; + switch (wreq.wi_type) { + case WI_RID_IFACE_STATS: break; - } else if (wreq.wi_type == WI_RID_MGMT_XMIT) { + case WI_RID_MGMT_XMIT: error = wi_mgmt_xmit(sc, (caddr_t)&wreq.wi_val, wreq.wi_len); - } else { + break; + case WI_RID_ROAMING_MODE: + /* Symbol cards use 0xFC2D for something else. */ + if (sc->sc_firmware_type == WI_SYMBOL) + break; + /* FALLTHROUGH */ + default: error = wi_write_record(sc, (struct wi_ltv_gen *)&wreq); if (!error) error = wi_setdef(sc, &wreq); @@ -1431,8 +1445,9 @@ wi_init(sc) /* Power Managment Max Sleep */ WI_SETVAL(WI_RID_MAX_SLEEP, sc->wi_max_sleep); - /* Roaming type */ - WI_SETVAL(WI_RID_ROAMING_MODE, sc->wi_roaming); + /* Set Roaming Mode unless this is a Symbol card. */ + if (sc->sc_firmware_type != WI_SYMBOL) + WI_SETVAL(WI_RID_ROAMING_MODE, sc->wi_roaming); /* Specify the network name */ WI_SETSTR(WI_RID_DESIRED_SSID, sc->wi_net_name); @@ -1476,15 +1491,17 @@ wi_init(sc) sc->wi_keys.wi_len = (sizeof(struct wi_ltv_keys) / 2) + 1; sc->wi_keys.wi_type = WI_RID_DEFLT_CRYPT_KEYS; wi_write_record(sc, (struct wi_ltv_gen *)&sc->wi_keys); - if (sc->sc_prism2 && sc->wi_use_wep) { + if (sc->sc_firmware_type != WI_LUCENT && sc->wi_use_wep) { /* - * For Prism2 Firmware version less than 0.8.2. + * HWB3163 EVAL-CARD Firmware version less than 0.8.2. + * * If promiscuous mode is disabled, the Prism2 chip * does not work with WEP . * I'm currently investigating the details of this. * (ichiro@netbsd.org) */ - if (sc->sc_prism2_ver < 82 ) { + if (sc->sc_firmware_type == WI_INTERSIL && + sc->sc_sta_firmware_ver < 802 ) { /* firm ver < 0.8.2 */ WI_SETVAL(WI_RID_PROMISC, 1); } @@ -1692,9 +1709,10 @@ nextpkt: if (!wihap_check_tx(&sc->wi_hostap_info, eh->ether_dhost, &tx_frame.wi_tx_rate) && !(ifp->if_flags & IFF_PROMISC)) { if (ifp->if_flags & IFF_DEBUG) - printf("wi_start: dropping unassoc dst %s\n", + printf(WI_PRT_FMT + ": wi_start: dropping unassoc dst %s\n", + WI_PRT_ARG(sc), ether_sprintf(eh->ether_dhost)); - m_freem(m0); goto nextpkt; } } @@ -1770,8 +1788,10 @@ nextpkt: if (sc->wi_ptype == WI_PORTTYPE_AP && sc->wi_use_wep) { - /* Do host encryption. */ - printf("XXX: host encrypt not implemented for 802.3\n"); + /* Do host encryption. (XXX - not implemented) */ + printf(WI_PRT_FMT + ": host encrypt not implemented for 802.3\n", + WI_PRT_ARG(sc)); } else { m_copydata(m0, 0, m0->m_pkthdr.len, (caddr_t)&sc->wi_txbuf); @@ -1795,7 +1815,7 @@ nextpkt: m_freem(m0); if (wi_cmd(sc, WI_CMD_TX|WI_RECLAIM, id)) - printf(WI_PRT_FMT ": xmit failed\n", WI_PRT_ARG(sc)); + printf(WI_PRT_FMT ": wi_start: xmit failed\n", WI_PRT_ARG(sc)); ifp->if_flags |= IFF_OACTIVE; @@ -1839,7 +1859,8 @@ wi_mgmt_xmit(sc, data, len) (len - sizeof(struct wi_80211_hdr)) + 2); if (wi_cmd(sc, WI_CMD_TX|WI_RECLAIM, id)) { - printf(WI_PRT_FMT ": xmit failed\n", WI_PRT_ARG(sc)); + printf(WI_PRT_FMT ": wi_mgmt_xmit: xmit failed\n", + WI_PRT_ARG(sc)); return(EIO); } @@ -1908,12 +1929,14 @@ wi_get_id(sc, print_cis) { struct wi_ltv_ver ver; struct wi_ltv_cis cis; + u_int16_t pri_fw_ver[3]; const char *p; if (print_cis) { /* * For PCI attachments the CIS strings won't have been printed * so print them here. + * XXX - messes up each odd character on Symbol cards */ cis.wi_type = WI_RID_CIS; cis.wi_len = sizeof(cis.wi_cis); @@ -1938,51 +1961,66 @@ wi_get_id(sc, print_cis) switch (letoh16(ver.wi_ver[0])) { case WI_NIC_EVB2: p = "PRISM I HFA3841(EVB2)"; - sc->sc_prism2 = 1; + sc->sc_firmware_type = WI_INTERSIL; break; case WI_NIC_HWB3763: p = "PRISM II HWB3763 rev.B"; - sc->sc_prism2 = 1; + sc->sc_firmware_type = WI_INTERSIL; break; case WI_NIC_HWB3163: p = "PRISM II HWB3163 rev.A"; - sc->sc_prism2 = 1; + sc->sc_firmware_type = WI_INTERSIL; break; case WI_NIC_HWB3163B: p = "PRISM II HWB3163 rev.B"; - sc->sc_prism2 = 1; + sc->sc_firmware_type = WI_INTERSIL; break; case WI_NIC_EVB3: p = "PRISM II HFA3842(EVB3)"; - sc->sc_prism2 = 1; + sc->sc_firmware_type = WI_INTERSIL; break; case WI_NIC_HWB1153: p = "PRISM I HFA1153"; - sc->sc_prism2 = 1; + sc->sc_firmware_type = WI_INTERSIL; break; case WI_NIC_P2_SST: p = "PRISM II HWB3163 SST-flash"; - sc->sc_prism2 = 1; + sc->sc_firmware_type = WI_INTERSIL; break; case WI_NIC_PRISM2_5: p = "PRISM 2.5 ISL3873"; - sc->sc_prism2 = 1; + sc->sc_firmware_type = WI_INTERSIL; break; case WI_NIC_3874A: p = "PRISM 2.5 ISL3874A(PCI)"; - sc->sc_prism2 = 1; + sc->sc_firmware_type = WI_INTERSIL; break; case WI_NIC_37300P: p = "PRISM 2.5 ISL37300P"; - sc->sc_prism2 = 1; + sc->sc_firmware_type = WI_INTERSIL; break; default: - p = "Lucent chip or unknown chip"; - sc->sc_prism2 = 0; + if (letoh16(ver.wi_ver[0]) & 0x8000) { + p = "Unknown PRISM2 chip"; + sc->sc_firmware_type = WI_INTERSIL; + } else { + sc->sc_firmware_type = WI_LUCENT; + } break; } - /* get firmware version */ + /* get primary firmware version (XXX - how to do Lucent?) */ + if (sc->sc_firmware_type != WI_LUCENT) { + bzero(&ver, sizeof(ver)); + ver.wi_type = WI_RID_PRI_IDENTITY; + ver.wi_len = 5; + wi_read_record(sc, (struct wi_ltv_gen *)&ver); + pri_fw_ver[0] = letoh16(ver.wi_ver[2]); + pri_fw_ver[1] = letoh16(ver.wi_ver[3]); + pri_fw_ver[2] = letoh16(ver.wi_ver[1]); + } + + /* get station firmware version */ bzero(&ver, sizeof(ver)); ver.wi_type = WI_RID_STA_IDENTITY; ver.wi_len = 5; @@ -1990,15 +2028,39 @@ wi_get_id(sc, print_cis) ver.wi_ver[1] = letoh16(ver.wi_ver[1]); ver.wi_ver[2] = letoh16(ver.wi_ver[2]); ver.wi_ver[3] = letoh16(ver.wi_ver[3]); - if (sc->sc_prism2) { - printf("\n%s: %s, Firmware %d.%d.%d, ", - WI_PRT_ARG(sc), p, ver.wi_ver[2], - ver.wi_ver[3], ver.wi_ver[1]); - sc->sc_prism2_ver = ver.wi_ver[2] * 100 + - ver.wi_ver[3] * 10 + ver.wi_ver[1]; - } else { + sc->sc_sta_firmware_ver = ver.wi_ver[2] * 10000 + + ver.wi_ver[3] * 100 + ver.wi_ver[1]; + + if (sc->sc_firmware_type == WI_INTERSIL && + (sc->sc_sta_firmware_ver == 10102 || sc->sc_sta_firmware_ver == 20102)) { + struct wi_ltv_str sver; + char *p; + + bzero(&sver, sizeof(sver)); + sver.wi_type = WI_RID_SYMBOL_IDENTITY; + sver.wi_len = 7; + /* value should be "V2.00-11" */ + if (wi_read_record(sc, (struct wi_ltv_gen *)&sver) == 0 && + *(p = (char *)sver.wi_str) == 'V' && + p[2] == '.' && p[5] == '-' && p[8] == '\0') { + sc->sc_firmware_type = WI_SYMBOL; + sc->sc_sta_firmware_ver = (p[1] - '0') * 10000 + + (p[3] - '0') * 1000 + (p[4] - '0') * 100 + + (p[6] - '0') * 10 + (p[7] - '0'); + } + } + + if (sc->sc_firmware_type == WI_LUCENT) { printf("\n%s: Firmware %d.%d variant %d, ", WI_PRT_ARG(sc), ver.wi_ver[2], ver.wi_ver[3], ver.wi_ver[1]); + } else { + printf("\n%s: %s%s, Firmware %d.%d.%d (primary), %d.%d.%d (station), ", + WI_PRT_ARG(sc), + sc->sc_firmware_type == WI_SYMBOL ? "Symbol " : "", p, + pri_fw_ver[0], pri_fw_ver[1], pri_fw_ver[2], + sc->sc_sta_firmware_ver / 10000, + (sc->sc_sta_firmware_ver % 10000) / 100, + sc->sc_sta_firmware_ver % 100); } return; @@ -2069,7 +2131,7 @@ wi_media_change(ifp) (IFM_IEEE80211_ADHOC|IFM_IEEE80211_HOSTAP)) return (EINVAL); if ((sc->sc_media.ifm_cur->ifm_media & IFM_IEEE80211_HOSTAP) && - !sc->sc_prism2) + sc->sc_firmware_type == WI_LUCENT) return (EINVAL); if ((sc->sc_media.ifm_cur->ifm_media & IFM_IEEE80211_ADHOC)) diff --git a/sys/dev/ic/if_wi_ieee.h b/sys/dev/ic/if_wi_ieee.h index 55f15dead52..ac4531e3acd 100644 --- a/sys/dev/ic/if_wi_ieee.h +++ b/sys/dev/ic/if_wi_ieee.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wi_ieee.h,v 1.4 2002/03/28 18:21:06 mickey Exp $ */ +/* $OpenBSD: if_wi_ieee.h,v 1.5 2002/04/06 20:31:56 millert Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -171,7 +171,8 @@ struct wi_counters { */ #define WI_RID_DNLD_BUF 0xFD01 -#define WI_RID_MEMSZ 0xFD02 +#define WI_RID_MEMSZ 0xFD02 /* memory size info (Lucent) */ +#define WI_RID_PRI_IDENTITY 0xFD02 /* primary firmware ident (PRISM2) */ #define WI_RID_DOMAINS 0xFD11 /* List of intended regulatory domains */ #define WI_RID_CIS 0xFD13 /* CIS info */ #define WI_RID_COMMQUAL 0xFD43 /* Communications quality */ @@ -213,6 +214,14 @@ struct wi_counters { #define WI_RID_P2_CRYPT_KEY2 0xFC26 #define WI_RID_P2_CRYPT_KEY3 0xFC27 #define WI_RID_P2_ENCRYPTION 0xFC28 +#define PRIVACY_INVOKED 0x01 +#define EXCLUDE_UNENCRYPTED 0x02 +#define HOST_ENCRYPT 0x10 +#define IV_EVERY_FRAME 0x00 +#define IV_EVERY10_FRAME 0x20 +#define IV_EVERY50_FRAME 0x40 +#define IV_EVERY100_FRAME 0x60 +#define HOST_DECRYPT 0x80 #define WI_RID_WEP_MAPTABLE 0xFC29 #define WI_RID_CNFAUTHMODE 0xFC2A #define WI_RID_ROAMING_MODE 0xFC2D /* Roaming mode (1:firm,3:disable) */ @@ -283,6 +292,7 @@ struct wi_ltv_keys { #define WI_RID_STA_IDENTITY 0xFD20 /* station funcs firmware ident */ #define WI_RID_STA_SUP_RANGE 0xFD21 /* station supplier compat */ #define WI_RID_MFI_ACT_RANGE 0xFD22 +#define WI_RID_SYMBOL_IDENTITY 0xFD24 /* Symbol station firmware ident */ #define WI_RID_CFI_ACT_RANGE 0xFD33 /* diff --git a/sys/dev/ic/if_wireg.h b/sys/dev/ic/if_wireg.h index 92352b06e50..b9aee89668e 100644 --- a/sys/dev/ic/if_wireg.h +++ b/sys/dev/ic/if_wireg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wireg.h,v 1.16 2002/03/30 21:57:40 millert Exp $ */ +/* $OpenBSD: if_wireg.h,v 1.17 2002/04/06 20:31:56 millert Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -271,16 +271,18 @@ #define WI_AUX_OFFSET 0x3C #define WI_AUX_DATA 0x3E -#define WI_PCI_PLX_LOCALRES 0x14 /* PLX chip's local registers */ -#define WI_PCI_PLX_MEMRES 0x18 /* Prism attribute memory (PLX) */ -#define WI_PCI_PLX_IORES 0x1C /* Prism I/O space (PLX) */ +#define WI_COR_OFFSET 0x3E0 /* COR attribute offset of card */ + +#define WI_PLX_LOCALRES 0x14 /* PLX chip's local registers */ +#define WI_PLX_MEMRES 0x18 /* Prism attribute memory (PLX) */ +#define WI_PLX_IORES 0x1C /* Prism I/O space (PLX) */ #define WI_PLX_INTCSR 0x4C /* PLX Interrupt CSR */ #define WI_PLX_INTEN 0x40 /* Interrupt Enable bit */ -#define WI_PLX_COR_OFFSET 0x3E0 /* COR attribute offset of Prism2 */ #define WI_PLX_COR_VALUE 0x41 /* Enable with irq in level trigger */ -#define WI_PCI_TMD_LOCALRES 0x14 /* TMD chip's local registers */ -#define WI_PCI_TMD_IORES 0x18 /* Prism I/O space (TMD) */ +#define WI_TMD_LOCALRES 0x14 /* TMD chip's local registers */ +#define WI_TMD_IORES 0x18 /* Prism I/O space (TMD) */ +#define WI_TMD_COR_OFFSET 0x00 /* COR attribute offset of Prism2 */ #define WI_TMD_COR_VALUE 0x45 /* @@ -290,7 +292,7 @@ * About WI_PCI_COR: In this Register, only soft-reset bit implement; Bit(7). */ #define WI_PCI_CBMA 0x10 -#define WI_PCI_COR 0x4C +#define WI_PCI_COR_OFFSET 0x4C #define WI_PCI_HCR 0x5C #define WI_PCI_MASTER0_ADDRH 0x80 #define WI_PCI_MASTER0_ADDRL 0x84 @@ -304,7 +306,8 @@ #define WI_PCI_MASTER1_LEN 0xA8 #define WI_PCI_MASTER1_CON 0xAC -#define WI_PCI_SOFT_RESET (1 << 7) +#define WI_COR_SOFT_RESET (1 << 7) +#define WI_COR_CLEAR 0x00 /* * One form of communication with the Hermes is with what Lucent calls @@ -378,16 +381,19 @@ struct wi_ltv_ver { u_int16_t wi_len; u_int16_t wi_type; u_int16_t wi_ver[4]; -#define WI_NIC_EVB2 0x8000 -#define WI_NIC_HWB3763 0x8001 -#define WI_NIC_HWB3163 0x8002 -#define WI_NIC_HWB3163B 0x8003 -#define WI_NIC_EVB3 0x8004 -#define WI_NIC_HWB1153 0x8007 -#define WI_NIC_P2_SST 0x8008 /* Prism2 with SST flush */ -#define WI_NIC_PRISM2_5 0x800C -#define WI_NIC_3874A 0x8013 /* Prism2.5 Mini-PCI */ -#define WI_NIC_37300P 0x801a +#define WI_NIC_LUCENT 0x0001 +#define WI_NIC_SONY 0x0002 +#define WI_NIC_LUCENT_EM 0x0005 +#define WI_NIC_EVB2 0x8000 +#define WI_NIC_HWB3763 0x8001 +#define WI_NIC_HWB3163 0x8002 +#define WI_NIC_HWB3163B 0x8003 +#define WI_NIC_EVB3 0x8004 +#define WI_NIC_HWB1153 0x8007 +#define WI_NIC_P2_SST 0x8008 /* Prism2 with SST flush */ +#define WI_NIC_PRISM2_5 0x800C +#define WI_NIC_3874A 0x8013 /* Prism2.5 Mini-PCI */ +#define WI_NIC_37300P 0x801a }; /* diff --git a/sys/dev/ic/if_wivar.h b/sys/dev/ic/if_wivar.h index 309bbf750ab..73a54871165 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.6 2002/03/28 18:21:06 mickey Exp $ */ +/* $OpenBSD: if_wivar.h,v 1.7 2002/04/06 20:31:56 millert Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -44,6 +44,9 @@ struct wi_softc { struct ifmedia sc_media; bus_space_handle_t wi_bhandle; bus_space_tag_t wi_btag; + bus_space_handle_t wi_lhandle; + bus_space_tag_t wi_ltag; + bus_size_t wi_cor_offset; int wi_tx_data_id; int wi_tx_mgmt_id; int wi_gone; @@ -77,14 +80,19 @@ struct wi_softc { void *sc_ih; struct timeout sc_timo; int sc_enabled; - int sc_prism2; - int sc_prism2_ver; + int sc_firmware_type; + int sc_sta_firmware_ver; int sc_pci; struct wihap_info wi_hostap_info; u_int32_t wi_icv; int wi_icv_flag; }; +/* Firmware types */ +#define WI_LUCENT 0 +#define WI_INTERSIL 1 +#define WI_SYMBOL 2 + #define WI_PRT_FMT "%s" #define WI_PRT_ARG(sc) (sc)->sc_dev.dv_xname diff --git a/sys/dev/pci/if_wi_pci.c b/sys/dev/pci/if_wi_pci.c index e58a62cdcc4..419ea224b1e 100644 --- a/sys/dev/pci/if_wi_pci.c +++ b/sys/dev/pci/if_wi_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wi_pci.c,v 1.21 2002/04/03 22:49:56 millert Exp $ */ +/* $OpenBSD: if_wi_pci.c,v 1.22 2002/04/06 20:31:56 millert Exp $ */ /* * Copyright (c) 2001, 2002 Todd C. Miller <Todd.Miller@courtesan.com> @@ -167,12 +167,14 @@ wi_pci_attach(parent, self, aux) /* Map memory and I/O registers. */ switch (pp->pp_type) { case WI_PCI_PLX: - if (pci_mapreg_map(pa, WI_PCI_PLX_MEMRES, PCI_MAPREG_TYPE_MEM, 0, + if (pci_mapreg_map(pa, WI_PLX_MEMRES, PCI_MAPREG_TYPE_MEM, 0, &memt, &memh, NULL, &memsize, 0) != 0) { printf(": can't map mem space\n"); return; } - if (pci_mapreg_map(pa, WI_PCI_PLX_IORES, + sc->wi_ltag = memt; + sc->wi_lhandle = memh; + if (pci_mapreg_map(pa, WI_PLX_IORES, PCI_MAPREG_TYPE_IO, 0, &iot, &ioh, NULL, NULL, 0) != 0) { printf(": can't map I/O space\n"); return; @@ -184,10 +186,10 @@ wi_pci_attach(parent, self, aux) * As such, we don't consider an error here to be fatal. */ localsize = 0; - if (pci_mapreg_type(pa->pa_pc, pa->pa_tag, WI_PCI_PLX_LOCALRES) + if (pci_mapreg_type(pa->pa_pc, pa->pa_tag, WI_PLX_LOCALRES) == PCI_MAPREG_TYPE_IO) { if (pci_io_find(pa->pa_pc, pa->pa_tag, - WI_PCI_PLX_LOCALRES, &localbase, &localsize) != 0) + WI_PLX_LOCALRES, &localbase, &localsize) != 0) printf(": can't find PLX I/O space\n"); if (localsize != 0) { if (bus_space_map(pa->pa_iot, localbase, @@ -206,14 +208,18 @@ wi_pci_attach(parent, self, aux) return; } sc->sc_pci = 1; + sc->wi_ltag = iot; + sc->wi_lhandle = ioh; break; case WI_PCI_TMD: - if (pci_mapreg_map(pa, WI_PCI_TMD_LOCALRES, PCI_MAPREG_TYPE_IO, + if (pci_mapreg_map(pa, WI_TMD_LOCALRES, PCI_MAPREG_TYPE_IO, 0, &localt, &localh, NULL, &localsize, 0) != 0) { printf(": can't map TMD I/O space\n"); return; } - if (pci_mapreg_map(pa, WI_PCI_TMD_IORES, PCI_MAPREG_TYPE_IO, + sc->wi_ltag = localt; + sc->wi_lhandle = localh; + if (pci_mapreg_map(pa, WI_TMD_IORES, PCI_MAPREG_TYPE_IO, 0, &iot, &ioh, NULL, NULL, 0) != 0) { printf(": can't map I/O space\n"); return; @@ -269,33 +275,32 @@ wi_pci_attach(parent, self, aux) /* * Setup the PLX chip for level interrupts and config index 1 */ - bus_space_write_1(memt, memh, - WI_PLX_COR_OFFSET, WI_PLX_COR_VALUE); + bus_space_write_1(memt, memh, WI_COR_OFFSET, WI_PLX_COR_VALUE); + sc->wi_cor_offset = WI_COR_OFFSET; /* Unmap registers we no longer need access to. */ if (localsize != 0) bus_space_unmap(localt, localh, localsize); - bus_space_unmap(memt, memh, memsize); wi_attach(sc, 1); break; case WI_PCI_PRISM: - bus_space_write_2(iot, ioh, WI_PCI_COR, WI_PCI_SOFT_RESET); + bus_space_write_2(iot, ioh, WI_PCI_COR_OFFSET, + WI_COR_SOFT_RESET); DELAY(100*1000); /* 100 m sec */ - bus_space_write_2(iot, ioh, WI_PCI_COR, 0x0); + bus_space_write_2(iot, ioh, WI_PCI_COR_OFFSET, WI_COR_CLEAR); DELAY(100*1000); /* 100 m sec */ + sc->wi_cor_offset = WI_PCI_COR_OFFSET; wi_attach(sc, 0); break; case WI_PCI_TMD: - bus_space_write_1(localt, localh, 0, WI_TMD_COR_VALUE); - /* XXX - correct delay? */ - DELAY(100*1000); /* 100 m sec */ + bus_space_write_1(localt, localh, WI_TMD_COR_OFFSET, + WI_TMD_COR_VALUE); + DELAY(1000); if (bus_space_read_1(localt, localh, 0) != WI_TMD_COR_VALUE) printf(": unable to initialize TMD7160 "); - - /* Unmap registers we no longer need access to. */ - bus_space_unmap(localt, localh, localsize); + sc->wi_cor_offset = WI_TMD_COR_OFFSET; wi_attach(sc, 1); break; diff --git a/sys/dev/pcmcia/if_wi_pcmcia.c b/sys/dev/pcmcia/if_wi_pcmcia.c index 1801c011f52..eb371023df4 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.24 2002/04/06 00:58:05 mickey Exp $ */ +/* $OpenBSD: if_wi_pcmcia.c,v 1.25 2002/04/06 20:31:56 millert Exp $ */ /* $NetBSD: if_wi_pcmcia.c,v 1.14 2001/11/26 04:34:56 ichiro Exp $ */ /* @@ -342,8 +342,9 @@ wi_pcmcia_attach(parent, self, aux) } state++; - sc->wi_btag = psc->sc_pcioh.iot; - sc->wi_bhandle = psc->sc_pcioh.ioh; + sc->wi_ltag = sc->wi_btag = psc->sc_pcioh.iot; + sc->wi_lhandle = sc->wi_bhandle = psc->sc_pcioh.ioh; + sc->wi_cor_offset = WI_COR_OFFSET; /* Make sure interrupts are disabled. */ CSR_WRITE_2(sc, WI_INT_EN, 0); |