if_wi_pccard.c revision 104833
180708Sjake/* 280708Sjake * Copyright (c) 1997, 1998, 1999 380708Sjake * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. 480708Sjake * 580708Sjake * Redistribution and use in source and binary forms, with or without 680708Sjake * modification, are permitted provided that the following conditions 780708Sjake * are met: 880708Sjake * 1. Redistributions of source code must retain the above copyright 980708Sjake * notice, this list of conditions and the following disclaimer. 1080708Sjake * 2. Redistributions in binary form must reproduce the above copyright 1180708Sjake * notice, this list of conditions and the following disclaimer in the 1280708Sjake * documentation and/or other materials provided with the distribution. 1380708Sjake * 3. All advertising materials mentioning features or use of this software 1481334Sobrien * must display the following acknowledgement: 1580708Sjake * This product includes software developed by Bill Paul. 1680708Sjake * 4. Neither the name of the author nor the names of any co-contributors 1781334Sobrien * may be used to endorse or promote products derived from this software 1880708Sjake * without specific prior written permission. 1980708Sjake * 2080708Sjake * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND 2180708Sjake * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2280708Sjake * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2380708Sjake * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD 2480708Sjake * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2580708Sjake * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2680708Sjake * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2780708Sjake * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2880708Sjake * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2980708Sjake * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 3080708Sjake * THE POSSIBILITY OF SUCH DAMAGE. 3180708Sjake */ 32166105Smarius 3382005Sjake/* 34166105Smarius * Lucent WaveLAN/IEEE 802.11 PCMCIA driver for FreeBSD. 3581135Stmm * 3686523Sjake * Written by Bill Paul <wpaul@ctr.columbia.edu> 3782005Sjake * Electrical Engineering Department 38112924Sjake * Columbia University, New York City 39112924Sjake */ 40166105Smarius 41166105Smarius#include "opt_wi.h" 42112920Sjake 4383053Sobrien#include <sys/param.h> 44113023Sjake#include <sys/kernel.h> 45113023Sjake#include <sys/socket.h> 46112920Sjake#include <sys/systm.h> 47113023Sjake#include <sys/module.h> 48113023Sjake#include <sys/bus.h> 49113023Sjake 50113023Sjake#include <machine/bus.h> 51113023Sjake#include <machine/resource.h> 52199135Skib#include <sys/rman.h> 53199135Skib 54105454Stmm#include <net/if.h> 5580708Sjake#include <net/if_arp.h> 5680708Sjake#include <net/ethernet.h> 57166105Smarius#include <net/if_dl.h> 58234785Sdim#include <net/if_media.h> 5980708Sjake#include <net/if_types.h> 6080708Sjake#include <net/if_ieee80211.h> 61166105Smarius 62166105Smarius#include <dev/pccard/pccardvar.h> 6380708Sjake#if __FreeBSD_version >= 500000 64#include <dev/pccard/pccarddevs.h> 65#endif 66 67#include <dev/wi/if_wavelan_ieee.h> 68#include <dev/wi/wi_hostap.h> 69#include <dev/wi/if_wivar.h> 70#include <dev/wi/if_wireg.h> 71#ifdef WI_SYMBOL_FIRMWARE 72#include <dev/wi/spectrum24t_cf.h> 73#endif 74 75#include "card_if.h" 76 77#if !defined(lint) 78static const char rcsid[] = 79 "$FreeBSD: head/sys/dev/wi/if_wi_pccard.c 104833 2002-10-11 05:43:38Z imp $"; 80#endif 81 82static int wi_pccard_probe(device_t); 83static int wi_pccard_attach(device_t); 84 85#if __FreeBSD_version < 500000 86static device_method_t wi_pccard_methods[] = { 87 /* Device interface */ 88 DEVMETHOD(device_probe, wi_pccard_probe), 89 DEVMETHOD(device_attach, wi_pccard_attach), 90 DEVMETHOD(device_detach, wi_generic_detach), 91 DEVMETHOD(device_shutdown, wi_shutdown), 92 93 { 0, 0 } 94}; 95 96#else 97static int wi_pccard_match(device_t); 98 99static device_method_t wi_pccard_methods[] = { 100 /* Device interface */ 101 DEVMETHOD(device_probe, pccard_compat_probe), 102 DEVMETHOD(device_attach, pccard_compat_attach), 103 DEVMETHOD(device_detach, wi_generic_detach), 104 DEVMETHOD(device_shutdown, wi_shutdown), 105 106 /* Card interface */ 107 DEVMETHOD(card_compat_match, wi_pccard_match), 108 DEVMETHOD(card_compat_probe, wi_pccard_probe), 109 DEVMETHOD(card_compat_attach, wi_pccard_attach), 110 111 { 0, 0 } 112}; 113 114#endif 115 116static driver_t wi_pccard_driver = { 117 "wi", 118 wi_pccard_methods, 119 sizeof(struct wi_softc) 120}; 121 122DRIVER_MODULE(if_wi, pccard, wi_pccard_driver, wi_devclass, 0, 0); 123 124#if __FreeBSD_version >= 500000 125static const struct pccard_product wi_pccard_products[] = { 126 PCMCIA_CARD(3COM, 3CRWE737A, 0), 127 PCMCIA_CARD(3COM, 3CRWE777A, 0), 128 PCMCIA_CARD(ACTIONTEC, HWC01170, 0), 129 PCMCIA_CARD(ADDTRON, AWP100, 0), 130 PCMCIA_CARD(BUFFALO, WLI_PCM_S11, 0), 131 PCMCIA_CARD(BUFFALO, WLI_CF_S11G, 0), 132 PCMCIA_CARD(COMPAQ, NC5004, 0), 133 PCMCIA_CARD(CONTEC, FX_DS110_PCC, 0), 134 PCMCIA_CARD(COREGA, WIRELESS_LAN_PCC_11, 0), 135 PCMCIA_CARD(COREGA, WIRELESS_LAN_PCCA_11, 0), 136 PCMCIA_CARD(COREGA, WIRELESS_LAN_PCCB_11, 0), 137 PCMCIA_CARD(ELSA, XI300_IEEE, 0), 138 PCMCIA_CARD(ELSA, XI325_IEEE, 0), 139 PCMCIA_CARD(ELSA, XI800_IEEE, 0), 140 PCMCIA_CARD(EMTAC, WLAN, 0), 141 PCMCIA_CARD(ERICSSON, WIRELESSLAN, 0), 142 PCMCIA_CARD(GEMTEK, WLAN, 0), 143 PCMCIA_CARD(HWN, AIRWAY80211, 0), 144 PCMCIA_CARD(INTEL, PRO_WLAN_2011, 0), 145 PCMCIA_CARD(INTERSIL, PRISM2, 0), 146 PCMCIA_CARD(IODATA2, WNB11PCM, 0), 147 PCMCIA_CARD(LINKSYS2, IWN, 0), 148 PCMCIA_CARD(LINKSYS2, IWN2, 0), 149 /* Now that we do PRISM detection, I don't think we need these - imp */ 150 PCMCIA_CARD2(LUCENT, WAVELAN_IEEE, NANOSPEED_PRISM2, 0), 151 PCMCIA_CARD2(LUCENT, WAVELAN_IEEE, NEC_CMZ_RT_WP, 0), 152 PCMCIA_CARD2(LUCENT, WAVELAN_IEEE, NTT_ME_WLAN, 0), 153 PCMCIA_CARD2(LUCENT, WAVELAN_IEEE, SMC_2632W, 0), 154 /* Must be after other LUCENT ones because it is less specific */ 155 PCMCIA_CARD(LUCENT, WAVELAN_IEEE, 0), 156 PCMCIA_CARD(NETGEAR2, MA401RA, 0), 157 PCMCIA_CARD(NOKIA, C110_WLAN, 0), 158 PCMCIA_CARD(PLANEX2, GWNS11H, 0), 159 PCMCIA_CARD(PROXIM, RANGELANDS_8430, 0), 160 PCMCIA_CARD(SAMSUNG, SWL_2000N, 0), 161 PCMCIA_CARD(SIMPLETECH, SPECTRUM24_ALT, 0), 162 PCMCIA_CARD(SOCKET, LP_WLAN_CF, 0), 163 PCMCIA_CARD(SYMBOL, LA4100, 0), 164 PCMCIA_CARD(TDK, LAK_CD011WL, 0), 165 { NULL } 166}; 167 168static int 169wi_pccard_match(dev) 170 device_t dev; 171{ 172 const struct pccard_product *pp; 173 174 if ((pp = pccard_product_lookup(dev, wi_pccard_products, 175 sizeof(wi_pccard_products[0]), NULL)) != NULL) { 176 device_set_desc(dev, pp->pp_name); 177 return 0; 178 } 179 return ENXIO; 180} 181#endif 182 183static int 184wi_pccard_probe(dev) 185 device_t dev; 186{ 187 struct wi_softc *sc; 188 int error; 189 190 sc = device_get_softc(dev); 191 sc->wi_gone = 0; 192 sc->wi_bus_type = WI_BUS_PCCARD; 193 194 error = wi_alloc(dev, 0); 195 if (error) 196 return (error); 197 198 wi_free(dev); 199 200 /* Make sure interrupts are disabled. */ 201 CSR_WRITE_2(sc, WI_INT_EN, 0); 202 CSR_WRITE_2(sc, WI_EVENT_ACK, 0xFFFF); 203 204 return (0); 205} 206 207static int 208wi_pccard_attach(device_t dev) 209{ 210 struct wi_softc *sc; 211 int error; 212 uint32_t vendor; 213 uint32_t product; 214 215 sc = device_get_softc(dev); 216 217 error = wi_alloc(dev, 0); 218 if (error) { 219 device_printf(dev, "wi_alloc() failed! (%d)\n", error); 220 return (error); 221 } 222 223 /* 224 * The cute little Symbol LA4100-series CF cards need to have 225 * code downloaded to them. 226 */ 227 pccard_get_vendor(dev, &vendor); 228 pccard_get_product(dev, &product); 229 if (vendor == PCMCIA_VENDOR_SYMBOL && 230 product == PCMCIA_PRODUCT_SYMBOL_LA4100) { 231#ifdef WI_SYMBOL_FIRMWARE 232 if (wi_symbol_load_firm(sc, 233 spectrum24t_primsym, sizeof(spectrum24t_primsym), 234 spectrum24t_secsym, sizeof(spectrum24t_secsym))) { 235 device_printf(dev, "couldn't load firmware\n"); 236 } 237#else 238 device_printf(dev, 239 "Symbol LA4100 needs 'option WI_SYMBOL_FIRMWARE'\n"); 240 return (ENXIO); 241#endif 242 } 243 244 return (wi_generic_attach(dev)); 245} 246