if_wi_pccard.c revision 93624
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/param.h>
42#include <sys/kernel.h>
43#include <sys/socket.h>
44#include <sys/module.h>
45#include <sys/bus.h>
46
47#include <machine/bus.h>
48#include <machine/resource.h>
49#include <sys/rman.h>
50
51#include <net/if.h>
52#include <net/if_arp.h>
53#include <net/ethernet.h>
54#include <net/if_dl.h>
55#include <net/if_media.h>
56#include <net/if_types.h>
57#include <net/if_ieee80211.h>
58
59#include <dev/pccard/pccardvar.h>
60#include <dev/pccard/pccarddevs.h>
61
62#include <dev/wi/if_wavelan_ieee.h>
63#include <dev/wi/if_wivar.h>
64#include <dev/wi/if_wireg.h>
65
66#include "card_if.h"
67
68#if !defined(lint)
69static const char rcsid[] =
70  "$FreeBSD: head/sys/dev/wi/if_wi_pccard.c 93624 2002-04-02 05:49:09Z imp $";
71#endif
72
73static int wi_pccard_match(device_t);
74static int wi_pccard_probe(device_t);
75static int wi_pccard_attach(device_t);
76
77static device_method_t wi_pccard_methods[] = {
78	/* Device interface */
79	DEVMETHOD(device_probe,		pccard_compat_probe),
80	DEVMETHOD(device_attach,	pccard_compat_attach),
81	DEVMETHOD(device_detach,	wi_generic_detach),
82	DEVMETHOD(device_shutdown,	wi_shutdown),
83
84	/* Card interface */
85	DEVMETHOD(card_compat_match,	wi_pccard_match),
86	DEVMETHOD(card_compat_probe,	wi_pccard_probe),
87	DEVMETHOD(card_compat_attach,	wi_pccard_attach),
88
89	{ 0, 0 }
90};
91
92static driver_t wi_pccard_driver = {
93	"wi",
94	wi_pccard_methods,
95	sizeof(struct wi_softc)
96};
97
98DRIVER_MODULE(if_wi, pccard, wi_pccard_driver, wi_devclass, 0, 0);
99
100static const struct pccard_product wi_pccard_products[] = {
101	PCMCIA_CARD(3COM, 3CRWE737A, 0),
102	PCMCIA_CARD(3COM, 3CRWE62092A, 0),
103	PCMCIA_CARD(ADDTRON, AWP100, 0),
104	PCMCIA_CARD(BUFFALO, WLI_PCM_S11, 0),
105	PCMCIA_CARD(BUFFALO, WLI_CF_S11G, 0),
106	PCMCIA_CARD(COMPAQ, NC5004, 0),
107	PCMCIA_CARD(CONTEC, FX_DS110_PCC, 0),
108	PCMCIA_CARD(COREGA, WIRELESS_LAN_PCC_11, 0),
109	PCMCIA_CARD(COREGA, WIRELESS_LAN_PCCA_11, 0),
110	PCMCIA_CARD(COREGA, WIRELESS_LAN_PCCB_11, 0),
111	PCMCIA_CARD(ELSA, XI300_IEEE, 0),
112	PCMCIA_CARD(ELSA, XI800_IEEE, 0),
113	PCMCIA_CARD(EMTAC, WLAN, 0),
114	PCMCIA_CARD(ERICSSON, WIRELESSLAN, 0),
115	PCMCIA_CARD(GEMTEK, WLAN, 0),
116	PCMCIA_CARD(HWN, AIRWAY80211, 0),
117	PCMCIA_CARD(INTEL, PRO_WLAN_2011, 0),
118	PCMCIA_CARD(INTERSIL, PRISM2, 0),
119	PCMCIA_CARD(IODATA2, WNB11PCM, 0),
120	PCMCIA_CARD(LINKSYS2, IWN, 0),
121	PCMCIA_CARD(NWN, WLAN_550, 0),
122	PCMCIA_CARD(NWN, WLAN_1148, 0),
123	/* Now that we do PRISM detection, I don't think we need these - imp */
124	PCMCIA_CARD2(LUCENT, WAVELAN_IEEE, NANOSPEED_PRISM2, 0),
125	PCMCIA_CARD2(LUCENT, WAVELAN_IEEE, NEC_CMZ_RT_WP, 0),
126	PCMCIA_CARD2(LUCENT, WAVELAN_IEEE, NTT_ME_WLAN, 0),
127	PCMCIA_CARD2(LUCENT, WAVELAN_IEEE, SMC_2632W, 0),
128	/* Must be after other LUCENT ones because it is less specific */
129	PCMCIA_CARD(LUCENT, WAVELAN_IEEE, 0),
130	PCMCIA_CARD(PROXIM, RANGELANDS_8430, 0),
131	PCMCIA_CARD(SAMSUNG, SWL_2000N, 0),
132	PCMCIA_CARD(SIMPLETECH, SPECTRUM24_ALT, 0),
133	PCMCIA_CARD(SOCKET, LP_WLAN_CF, 0),
134	PCMCIA_CARD(SYMBOL, LA4100, 0),
135	PCMCIA_CARD(TDK, LAK_CD011WL, 0),
136	{ NULL }
137};
138
139static int
140wi_pccard_match(dev)
141	device_t	dev;
142{
143	const struct pccard_product *pp;
144
145	if ((pp = pccard_product_lookup(dev, wi_pccard_products,
146	    sizeof(wi_pccard_products[0]), NULL)) != NULL) {
147		device_set_desc(dev, pp->pp_name);
148		return 0;
149	}
150	return ENXIO;
151}
152
153static int
154wi_pccard_probe(dev)
155	device_t	dev;
156{
157	struct wi_softc	*sc;
158	int		error;
159
160	sc = device_get_softc(dev);
161	sc->wi_gone = 0;
162	sc->wi_bus_type = WI_BUS_PCCARD;
163
164	error = wi_alloc(dev, 0);
165	if (error)
166		return (error);
167
168	wi_free(dev);
169
170	/* Make sure interrupts are disabled. */
171	CSR_WRITE_2(sc, WI_INT_EN, 0);
172	CSR_WRITE_2(sc, WI_EVENT_ACK, 0xFFFF);
173
174	return (0);
175}
176
177static int
178wi_pccard_attach(device_t dev)
179{
180	struct wi_softc		*sc;
181	int			error;
182
183	sc = device_get_softc(dev);
184
185	error = wi_alloc(dev, 0);
186	if (error) {
187		device_printf(dev, "wi_alloc() failed! (%d)\n", error);
188		return (error);
189	}
190	return (wi_generic_attach(dev));
191}
192