1 /*-
2 * Copyright (c) 1997, 1998, 1999
3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by Bill Paul.
16 * 4. Neither the name of the author nor the names of any co-contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 * $FreeBSD: head/sys/dev/wi/if_wi_pccard.c 292079 2015-12-11 05:27:56Z imp $
33 */
34
35 /*
36 * Lucent WaveLAN/IEEE 802.11 PCMCIA driver for FreeBSD.
37 *
38 * Written by Bill Paul <wpaul@ctr.columbia.edu>
39 * Electrical Engineering Department
40 * Columbia University, New York City
41 */
42
43 #include <sys/param.h>
44 #include <sys/kernel.h>
45 #include <sys/malloc.h>
46 #include <sys/socket.h>
47 #include <sys/systm.h>
48 #include <sys/mbuf.h>
49 #include <sys/module.h>
50 #include <sys/bus.h>
51
52 #if !defined(__DragonFly__)
53 #include <machine/bus.h>
54 #include <machine/resource.h>
55 #endif
56 #include <sys/rman.h>
57
58 #include <net/if.h>
59 #include <net/if_arp.h>
60 #include <net/ethernet.h>
61 #include <net/if_dl.h>
62 #include <net/if_media.h>
63 #include <net/if_types.h>
64
65 #if defined(__DragonFly__)
66 #include <netproto/802_11/ieee80211_var.h>
67 #include <netproto/802_11/ieee80211_radiotap.h>
68 #else
69 #include <net80211/ieee80211_var.h>
70 #include <net80211/ieee80211_radiotap.h>
71 #endif
72
73 #if defined(__DragonFly__)
74 #define PCCARD_API_LEVEL 6
75 #include <bus/pccard/pccardvar.h>
76 #include <bus/pccard/pccard_cis.h>
77 #else
78 #include <dev/pccard/pccardvar.h>
79 #include <dev/pccard/pccard_cis.h>
80 #endif
81
82 #if defined(__DragonFly__)
83 #include "if_wavelan_ieee.h"
84 #include "if_wireg.h"
85 #include "if_wivar.h"
86 #else
87 #include <dev/wi/if_wavelan_ieee.h>
88 #include <dev/wi/if_wireg.h>
89 #include <dev/wi/if_wivar.h>
90 #endif
91
92 #include "card_if.h"
93 #include "pccarddevs.h"
94
95 static int wi_pccard_probe(device_t);
96 static int wi_pccard_attach(device_t);
97
98 static device_method_t wi_pccard_methods[] = {
99 /* Device interface */
100 DEVMETHOD(device_probe, wi_pccard_probe),
101 DEVMETHOD(device_attach, wi_pccard_attach),
102 DEVMETHOD(device_detach, wi_detach),
103 DEVMETHOD(device_shutdown, wi_shutdown),
104
105 DEVMETHOD_END
106 };
107
108 static driver_t wi_pccard_driver = {
109 "wi",
110 wi_pccard_methods,
111 sizeof(struct wi_softc)
112 };
113
114 DRIVER_MODULE(wi, pccard, wi_pccard_driver, wi_devclass, NULL, NULL);
115 MODULE_DEPEND(wi, wlan, 1, 1, 1);
116
117 static const struct pccard_product wi_pccard_products[] = {
118 PCMCIA_CARD(3COM, 3CRWE737A),
119 PCMCIA_CARD(3COM, 3CRWE777A),
120 PCMCIA_CARD(ACTIONTEC, PRISM),
121 PCMCIA_CARD(ADAPTEC2, ANW8030),
122 PCMCIA_CARD(ADDTRON, AWP100),
123 PCMCIA_CARD(AIRVAST, WN_100B),
124 PCMCIA_CARD(AIRVAST, WN_100),
125 PCMCIA_CARD(ALLIEDTELESIS, WR211PCM),
126 PCMCIA_CARD(ARTEM, ONAIR),
127 PCMCIA_CARD(ASUS, WL100),
128 PCMCIA_CARD(BAY, EMOBILITY_11B),
129 PCMCIA_CARD(BROMAX, IWN),
130 PCMCIA_CARD(BROMAX, IWN3),
131 PCMCIA_CARD(BROMAX, WCF11),
132 PCMCIA_CARD(BUFFALO, WLI_CF_S11G),
133 PCMCIA_CARD(BUFFALO, WLI_PCM_S11),
134 PCMCIA_CARD(COMPAQ, NC5004),
135 PCMCIA_CARD(CONTEC, FX_DS110_PCC),
136 PCMCIA_CARD(COREGA, WIRELESS_LAN_PCC_11),
137 PCMCIA_CARD(COREGA, WIRELESS_LAN_PCCA_11),
138 PCMCIA_CARD(COREGA, WIRELESS_LAN_PCCB_11),
139 PCMCIA_CARD(COREGA, WIRELESS_LAN_PCCL_11),
140 PCMCIA_CARD(DLINK, DWL650H),
141 PCMCIA_CARD(ELSA, XI300_IEEE),
142 PCMCIA_CARD(ELSA, XI325_IEEE),
143 PCMCIA_CARD(ELSA, APDL325_IEEE),
144 PCMCIA_CARD(ELSA, XI330_IEEE),
145 PCMCIA_CARD(ELSA, XI800_IEEE),
146 PCMCIA_CARD(ELSA, WIFI_FLASH),
147 PCMCIA_CARD(EMTAC, WLAN),
148 PCMCIA_CARD(ERICSSON, WIRELESSLAN),
149 PCMCIA_CARD(GEMTEK, WLAN),
150 PCMCIA_CARD(HWN, AIRWAY80211),
151 PCMCIA_CARD(INTEL, PRO_WLAN_2011),
152 PCMCIA_CARD(INTERSIL, ISL37100P),
153 PCMCIA_CARD(INTERSIL, ISL37110P),
154 PCMCIA_CARD(INTERSIL, ISL37300P),
155 PCMCIA_CARD(INTERSIL2, PRISM2),
156 PCMCIA_CARD(IODATA2, WCF12),
157 PCMCIA_CARD(IODATA2, WNB11PCM),
158 PCMCIA_CARD(FUJITSU, WL110),
159 PCMCIA_CARD(LUCENT, WAVELAN_IEEE),
160 PCMCIA_CARD(MICROSOFT, MN_520),
161 PCMCIA_CARD(NOKIA, C020_WLAN),
162 PCMCIA_CARD(NOKIA, C110_WLAN),
163 PCMCIA_CARD(PLANEX, GWNS11H),
164 PCMCIA_CARD(PROXIM, HARMONY),
165 PCMCIA_CARD(PROXIM, RANGELANDS_8430),
166 PCMCIA_CARD(SAMSUNG, SWL_2000N),
167 PCMCIA_CARD(SIEMENS, SS1021),
168 PCMCIA_CARD(SIEMENS, SS1021A),
169 PCMCIA_CARD(SIMPLETECH, SPECTRUM24_ALT),
170 PCMCIA_CARD(SOCKET, LP_WLAN_CF),
171 PCMCIA_CARD(TDK, LAK_CD011WL),
172 { NULL }
173 };
174 #if !defined(__DragonFly__)
175 PCCARD_PNP_INFO(wi_pccard_products);
176 #endif
177
178 static int
wi_pccard_probe(device_t dev)179 wi_pccard_probe(device_t dev)
180 {
181 const struct pccard_product *pp;
182 u_int32_t fcn = PCCARD_FUNCTION_UNSPEC;
183 #if !defined(__DragonFly__)
184 int error;
185 #endif
186
187 /* Make sure we're a network driver */
188 #if defined(__DragonFly__)
189 fcn = pccard_get_function_number(dev);
190 #else
191 error = pccard_get_function(dev, &fcn);
192 if (error != 0)
193 return error;
194 #endif
195 if (fcn != PCCARD_FUNCTION_NETWORK)
196 return ENXIO;
197
198 pp = pccard_product_lookup(dev, wi_pccard_products,
199 sizeof(wi_pccard_products[0]), NULL);
200 if (pp != NULL) {
201 if (pp->pp_name != NULL)
202 device_set_desc(dev, pp->pp_name);
203 return 0;
204 }
205 return ENXIO;
206 }
207
208 static int
wi_pccard_attach(device_t dev)209 wi_pccard_attach(device_t dev)
210 {
211 struct wi_softc *sc;
212 int error;
213
214 sc = device_get_softc(dev);
215 sc->wi_gone = 0;
216 sc->wi_bus_type = WI_BUS_PCCARD;
217
218 error = wi_alloc(dev, 0);
219 if (error == 0) {
220 /* Make sure interrupts are disabled. */
221 CSR_WRITE_2(sc, WI_INT_EN, 0);
222 CSR_WRITE_2(sc, WI_EVENT_ACK, 0xFFFF);
223
224 error = wi_attach(dev);
225 if (error != 0)
226 wi_free(dev);
227 }
228 return error;
229 }
230