if_wi_pccard.c revision 114102
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
33/*
34 * Lucent WaveLAN/IEEE 802.11 PCMCIA driver for FreeBSD.
35 *
36 * Written by Bill Paul <wpaul@ctr.columbia.edu>
37 * Electrical Engineering Department
38 * Columbia University, New York City
39 */
40
41#include <sys/cdefs.h>
42__FBSDID("$FreeBSD: head/sys/dev/wi/if_wi_pccard.c 114102 2003-04-27 03:34:05Z imp $");
43
44#include "opt_wi.h"
45
46#include <sys/param.h>
47#include <sys/kernel.h>
48#include <sys/socket.h>
49#include <sys/systm.h>
50#include <sys/module.h>
51#include <sys/bus.h>
52
53#include <machine/bus.h>
54#include <machine/resource.h>
55#include <sys/rman.h>
56
57#include <net/if.h>
58#include <net/if_arp.h>
59#include <net/ethernet.h>
60#include <net/if_dl.h>
61#include <net/if_media.h>
62#include <net/if_types.h>
63#include <net/if_ieee80211.h>
64
65#include <dev/pccard/pccardvar.h>
66#if __FreeBSD_version >= 500000
67#include <dev/pccard/pccarddevs.h>
68#endif
69
70#include <dev/wi/if_wavelan_ieee.h>
71#include <dev/wi/if_wivar.h>
72#include <dev/wi/if_wireg.h>
73#ifdef WI_SYMBOL_FIRMWARE
74#include <dev/wi/spectrum24t_cf.h>
75#endif
76
77#include "card_if.h"
78
79static int wi_pccard_probe(device_t);
80static int wi_pccard_attach(device_t);
81
82#if __FreeBSD_version < 500000
83static device_method_t wi_pccard_methods[] = {
84	/* Device interface */
85	DEVMETHOD(device_probe,		wi_pccard_probe),
86	DEVMETHOD(device_attach,	wi_pccard_attach),
87	DEVMETHOD(device_detach,	wi_detach),
88	DEVMETHOD(device_shutdown,	wi_shutdown),
89
90	{ 0, 0 }
91};
92
93#else
94static int wi_pccard_match(device_t);
95
96static device_method_t wi_pccard_methods[] = {
97	/* Device interface */
98	DEVMETHOD(device_probe,		pccard_compat_probe),
99	DEVMETHOD(device_attach,	pccard_compat_attach),
100	DEVMETHOD(device_detach,	wi_detach),
101	DEVMETHOD(device_shutdown,	wi_shutdown),
102
103	/* Card interface */
104	DEVMETHOD(card_compat_match,	wi_pccard_match),
105	DEVMETHOD(card_compat_probe,	wi_pccard_probe),
106	DEVMETHOD(card_compat_attach,	wi_pccard_attach),
107
108	{ 0, 0 }
109};
110
111#endif
112
113static driver_t wi_pccard_driver = {
114	"wi",
115	wi_pccard_methods,
116	sizeof(struct wi_softc)
117};
118
119DRIVER_MODULE(wi, pccard, wi_pccard_driver, wi_devclass, 0, 0);
120MODULE_DEPEND(wi, wlan, 1, 1, 1);
121MODULE_DEPEND(wi, pccard, 1, 1, 1);
122
123#if __FreeBSD_version >= 500000
124static const struct pccard_product wi_pccard_products[] = {
125	PCMCIA_CARD(3COM, 3CRWE737A, 0),
126	PCMCIA_CARD(3COM, 3CRWE777A, 0),
127	PCMCIA_CARD(ACTIONTEC, PRISM, 0),
128	PCMCIA_CARD(ADDTRON, AWP100, 0),
129	PCMCIA_CARD(ALLIEDTELESIS, WR211PCM, 0),
130	PCMCIA_CARD(BAY, EMOBILITY_11B, 0),
131	PCMCIA_CARD(BUFFALO, WLI_PCM_S11, 0),
132	PCMCIA_CARD(BUFFALO, WLI_CF_S11G, 0),
133	PCMCIA_CARD(COMPAQ, NC5004, 0),
134	PCMCIA_CARD(CONTEC, FX_DS110_PCC, 0),
135	PCMCIA_CARD(COREGA, WIRELESS_LAN_PCC_11, 0),
136	PCMCIA_CARD(COREGA, WIRELESS_LAN_PCCA_11, 0),
137	PCMCIA_CARD(COREGA, WIRELESS_LAN_PCCB_11, 0),
138	PCMCIA_CARD(DLINK, DWL650H, 0),
139	PCMCIA_CARD(ELSA, XI300_IEEE, 0),
140	PCMCIA_CARD(ELSA, XI325_IEEE, 0),
141	PCMCIA_CARD(ELSA, XI800_IEEE, 0),
142	PCMCIA_CARD(EMTAC, WLAN, 0),
143	PCMCIA_CARD(ERICSSON, WIRELESSLAN, 0),
144	PCMCIA_CARD(GEMTEK, WLAN, 0),
145	PCMCIA_CARD(HWN, AIRWAY80211, 0),
146	PCMCIA_CARD(INTEL, PRO_WLAN_2011, 0),
147	PCMCIA_CARD(INTERSIL, PRISM2, 0),
148	PCMCIA_CARD(IODATA2, WNB11PCM, 0),
149	PCMCIA_CARD(LINKSYS2, IWN, 0),
150	PCMCIA_CARD(LINKSYS2, IWN3, 0),
151	PCMCIA_CARD(LINKSYS2, WCF11, 0),
152	PCMCIA_CARD(LUCENT, WAVELAN_IEEE, 0),
153	PCMCIA_CARD(NETGEAR_2, MA401RA, 0),
154	PCMCIA_CARD(NOKIA, C110_WLAN, 0),
155	PCMCIA_CARD(OEM1, PRISM3, 0),
156	PCMCIA_CARD(PLANEX_2, GWNS11H, 0),
157	PCMCIA_CARD(PROXIM, RANGELANDS_8430, 0),
158	PCMCIA_CARD(SAMSUNG, SWL_2000N, 0),
159	PCMCIA_CARD(SIMPLETECH, SPECTRUM24_ALT, 0),
160	PCMCIA_CARD(SOCKET, LP_WLAN_CF, 0),
161	PCMCIA_CARD(SYMBOL, LA4100, 0),
162	PCMCIA_CARD(TDK, LAK_CD011WL, 0),
163	{ NULL }
164};
165
166static int
167wi_pccard_match(dev)
168	device_t	dev;
169{
170	const struct pccard_product *pp;
171
172	if ((pp = pccard_product_lookup(dev, wi_pccard_products,
173	    sizeof(wi_pccard_products[0]), NULL)) != NULL) {
174		if (pp->pp_name != NULL)
175			device_set_desc(dev, pp->pp_name);
176		return (0);
177	}
178	return (ENXIO);
179}
180#endif
181
182static int
183wi_pccard_probe(dev)
184	device_t	dev;
185{
186	struct wi_softc	*sc;
187	int		error;
188
189	sc = device_get_softc(dev);
190	sc->wi_gone = 0;
191	sc->wi_bus_type = WI_BUS_PCCARD;
192
193	error = wi_alloc(dev, 0);
194	if (error)
195		return (error);
196
197	wi_free(dev);
198
199	/* Make sure interrupts are disabled. */
200	CSR_WRITE_2(sc, WI_INT_EN, 0);
201	CSR_WRITE_2(sc, WI_EVENT_ACK, 0xFFFF);
202
203	return (0);
204}
205
206static int
207wi_pccard_attach(device_t dev)
208{
209	struct wi_softc		*sc;
210	int			error;
211	uint32_t		vendor;
212	uint32_t		product;
213
214	sc = device_get_softc(dev);
215
216	error = wi_alloc(dev, 0);
217	if (error) {
218		device_printf(dev, "wi_alloc() failed! (%d)\n", error);
219		return (error);
220	}
221
222#if __FreeBSD_version > 500000
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#endif
244
245	return (wi_attach(dev));
246}
247