1139749Simp/*-
293611Simp * Copyright (c) 1997, 1998, 1999
393611Simp *	Bill Paul <wpaul@ctr.columbia.edu>.  All rights reserved.
493611Simp *
593611Simp * Redistribution and use in source and binary forms, with or without
693611Simp * modification, are permitted provided that the following conditions
793611Simp * are met:
893611Simp * 1. Redistributions of source code must retain the above copyright
993611Simp *    notice, this list of conditions and the following disclaimer.
1093611Simp * 2. Redistributions in binary form must reproduce the above copyright
1193611Simp *    notice, this list of conditions and the following disclaimer in the
1293611Simp *    documentation and/or other materials provided with the distribution.
1393611Simp * 3. All advertising materials mentioning features or use of this software
1493611Simp *    must display the following acknowledgement:
1593611Simp *	This product includes software developed by Bill Paul.
1693611Simp * 4. Neither the name of the author nor the names of any co-contributors
1793611Simp *    may be used to endorse or promote products derived from this software
1893611Simp *    without specific prior written permission.
1993611Simp *
2093611Simp * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
2193611Simp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2293611Simp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2393611Simp * ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
2493611Simp * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2593611Simp * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2693611Simp * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2793611Simp * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2893611Simp * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2993611Simp * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
3093611Simp * THE POSSIBILITY OF SUCH DAMAGE.
3193611Simp */
3293611Simp
3393611Simp/*
3493611Simp * Lucent WaveLAN/IEEE 802.11 PCMCIA driver for FreeBSD.
3593611Simp *
3693611Simp * Written by Bill Paul <wpaul@ctr.columbia.edu>
3793611Simp * Electrical Engineering Department
3893611Simp * Columbia University, New York City
3993611Simp */
4093611Simp
41113038Sobrien#include <sys/cdefs.h>
42113038Sobrien__FBSDID("$FreeBSD$");
43113038Sobrien
4493611Simp#include <sys/param.h>
4593611Simp#include <sys/kernel.h>
46257176Sglebius#include <sys/malloc.h>
4793611Simp#include <sys/socket.h>
4895534Simp#include <sys/systm.h>
49287197Sglebius#include <sys/mbuf.h>
5093611Simp#include <sys/module.h>
5193611Simp#include <sys/bus.h>
5293611Simp
5393611Simp#include <machine/bus.h>
5493611Simp#include <machine/resource.h>
5593611Simp#include <sys/rman.h>
5693611Simp
5793611Simp#include <net/if.h>
5893611Simp#include <net/if_arp.h>
5993611Simp#include <net/ethernet.h>
6093611Simp#include <net/if_dl.h>
6193611Simp#include <net/if_media.h>
6293611Simp#include <net/if_types.h>
6393611Simp
64116951Ssam#include <net80211/ieee80211_var.h>
65119784Ssam#include <net80211/ieee80211_radiotap.h>
66116951Ssam
6793611Simp#include <dev/pccard/pccardvar.h>
68130257Simp#include <dev/pccard/pccard_cis.h>
6993611Simp
7093611Simp#include <dev/wi/if_wavelan_ieee.h>
71119784Ssam#include <dev/wi/if_wireg.h>
7293611Simp#include <dev/wi/if_wivar.h>
7393611Simp
7493611Simp#include "card_if.h"
75129764Simp#include "pccarddevs.h"
7693611Simp
7793611Simpstatic int wi_pccard_probe(device_t);
7893611Simpstatic int wi_pccard_attach(device_t);
7993611Simp
8095534Simpstatic device_method_t wi_pccard_methods[] = {
8195534Simp	/* Device interface */
82150454Simp	DEVMETHOD(device_probe,		wi_pccard_probe),
83150454Simp	DEVMETHOD(device_attach,	wi_pccard_attach),
84109323Ssam	DEVMETHOD(device_detach,	wi_detach),
8593611Simp	DEVMETHOD(device_shutdown,	wi_shutdown),
8693611Simp
8793611Simp	{ 0, 0 }
8893611Simp};
8993611Simp
9093611Simpstatic driver_t wi_pccard_driver = {
9193611Simp	"wi",
9293611Simp	wi_pccard_methods,
9393611Simp	sizeof(struct wi_softc)
9493611Simp};
9593611Simp
96113506SmdoddDRIVER_MODULE(wi, pccard, wi_pccard_driver, wi_devclass, 0, 0);
97113506SmdoddMODULE_DEPEND(wi, wlan, 1, 1, 1);
9893611Simp
9993611Simpstatic const struct pccard_product wi_pccard_products[] = {
100147580Simp	PCMCIA_CARD(3COM, 3CRWE737A),
101147580Simp	PCMCIA_CARD(3COM, 3CRWE777A),
102147580Simp	PCMCIA_CARD(ACTIONTEC, PRISM),
103147872Simp	PCMCIA_CARD(ADAPTEC2, ANW8030),
104147580Simp	PCMCIA_CARD(ADDTRON, AWP100),
105151321Simp	PCMCIA_CARD(AIRVAST, WN_100B),
106147580Simp	PCMCIA_CARD(AIRVAST, WN_100),
107147580Simp	PCMCIA_CARD(ALLIEDTELESIS, WR211PCM),
108147580Simp	PCMCIA_CARD(ARTEM, ONAIR),
109147580Simp 	PCMCIA_CARD(ASUS, WL100),
110147580Simp	PCMCIA_CARD(BAY, EMOBILITY_11B),
111147580Simp	PCMCIA_CARD(BROMAX, IWN),
112147580Simp	PCMCIA_CARD(BROMAX, IWN3),
113147580Simp	PCMCIA_CARD(BROMAX, WCF11),
114147580Simp	PCMCIA_CARD(BUFFALO, WLI_CF_S11G),
115147580Simp	PCMCIA_CARD(BUFFALO, WLI_PCM_S11),
116147580Simp	PCMCIA_CARD(COMPAQ, NC5004),
117147580Simp	PCMCIA_CARD(CONTEC, FX_DS110_PCC),
118147580Simp	PCMCIA_CARD(COREGA, WIRELESS_LAN_PCC_11),
119147580Simp	PCMCIA_CARD(COREGA, WIRELESS_LAN_PCCA_11),
120147580Simp	PCMCIA_CARD(COREGA, WIRELESS_LAN_PCCB_11),
121147580Simp	PCMCIA_CARD(COREGA, WIRELESS_LAN_PCCL_11),
122147580Simp	PCMCIA_CARD(DLINK, DWL650H),
123147580Simp	PCMCIA_CARD(ELSA, XI300_IEEE),
124147580Simp	PCMCIA_CARD(ELSA, XI325_IEEE),
125182236Simp	PCMCIA_CARD(ELSA, APDL325_IEEE),
126151321Simp	PCMCIA_CARD(ELSA, XI330_IEEE),
127147580Simp	PCMCIA_CARD(ELSA, XI800_IEEE),
128147580Simp	PCMCIA_CARD(ELSA, WIFI_FLASH),
129147580Simp	PCMCIA_CARD(EMTAC, WLAN),
130147580Simp	PCMCIA_CARD(ERICSSON, WIRELESSLAN),
131147580Simp	PCMCIA_CARD(GEMTEK, WLAN),
132147580Simp	PCMCIA_CARD(HWN, AIRWAY80211),
133147580Simp	PCMCIA_CARD(INTEL, PRO_WLAN_2011),
134147580Simp	PCMCIA_CARD(INTERSIL, ISL37100P),
135147580Simp	PCMCIA_CARD(INTERSIL, ISL37110P),
136147580Simp	PCMCIA_CARD(INTERSIL, ISL37300P),
137147580Simp	PCMCIA_CARD(INTERSIL2, PRISM2),
138147580Simp	PCMCIA_CARD(IODATA2, WCF12),
139147580Simp	PCMCIA_CARD(IODATA2, WNB11PCM),
140147580Simp	PCMCIA_CARD(FUJITSU, WL110),
141147580Simp	PCMCIA_CARD(LUCENT, WAVELAN_IEEE),
142147580Simp	PCMCIA_CARD(MICROSOFT, MN_520),
143147580Simp	PCMCIA_CARD(NOKIA, C020_WLAN),
144147580Simp	PCMCIA_CARD(NOKIA, C110_WLAN),
145147580Simp	PCMCIA_CARD(PLANEX, GWNS11H),
146147580Simp	PCMCIA_CARD(PROXIM, HARMONY),
147147580Simp	PCMCIA_CARD(PROXIM, RANGELANDS_8430),
148147580Simp	PCMCIA_CARD(SAMSUNG, SWL_2000N),
149147580Simp	PCMCIA_CARD(SIEMENS, SS1021),
150181211Simp	PCMCIA_CARD(SIEMENS, SS1021A),
151147580Simp	PCMCIA_CARD(SIMPLETECH, SPECTRUM24_ALT),
152147580Simp	PCMCIA_CARD(SOCKET, LP_WLAN_CF),
153147580Simp	PCMCIA_CARD(TDK, LAK_CD011WL),
15493611Simp	{ NULL }
15593611Simp};
156292079SimpPCCARD_PNP_INFO(wi_pccard_products);
15793611Simp
15893611Simpstatic int
159150454Simpwi_pccard_probe(device_t dev)
16093611Simp{
16193611Simp	const struct pccard_product *pp;
162130257Simp	u_int32_t fcn = PCCARD_FUNCTION_UNSPEC;
163130257Simp	int error;
16493611Simp
165130257Simp	/* Make sure we're a network driver */
166130257Simp	error = pccard_get_function(dev, &fcn);
167130257Simp	if (error != 0)
168178354Ssam		return error;
169130257Simp	if (fcn != PCCARD_FUNCTION_NETWORK)
170178354Ssam		return ENXIO;
171130257Simp
172178354Ssam	pp = pccard_product_lookup(dev, wi_pccard_products,
173178354Ssam	    sizeof(wi_pccard_products[0]), NULL);
174178354Ssam	if (pp != NULL) {
175113315Simp		if (pp->pp_name != NULL)
176113258Simp			device_set_desc(dev, pp->pp_name);
177178354Ssam		return 0;
178113258Simp	}
179178354Ssam	return ENXIO;
18093611Simp}
18193611Simp
18293611Simpstatic int
183150454Simpwi_pccard_attach(device_t dev)
18493611Simp{
18593611Simp	struct wi_softc	*sc;
186178354Ssam	int error;
18793611Simp
18893611Simp	sc = device_get_softc(dev);
18993611Simp	sc->wi_gone = 0;
19093611Simp	sc->wi_bus_type = WI_BUS_PCCARD;
19193611Simp
19293611Simp	error = wi_alloc(dev, 0);
193178354Ssam	if (error == 0) {
194178354Ssam		/* Make sure interrupts are disabled. */
195178354Ssam		CSR_WRITE_2(sc, WI_INT_EN, 0);
196178354Ssam		CSR_WRITE_2(sc, WI_EVENT_ACK, 0xFFFF);
19793611Simp
198178354Ssam		error = wi_attach(dev);
199178354Ssam		if (error != 0)
200178354Ssam			wi_free(dev);
201101245Simp	}
202178354Ssam	return error;
20393611Simp}
204