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>
4693611Simp#include <sys/socket.h>
4795534Simp#include <sys/systm.h>
4893611Simp#include <sys/module.h>
4993611Simp#include <sys/bus.h>
5093611Simp
5193611Simp#include <machine/bus.h>
5293611Simp#include <machine/resource.h>
5393611Simp#include <sys/rman.h>
5493611Simp
5593611Simp#include <net/if.h>
5693611Simp#include <net/if_arp.h>
5793611Simp#include <net/ethernet.h>
5893611Simp#include <net/if_dl.h>
5993611Simp#include <net/if_media.h>
6093611Simp#include <net/if_types.h>
6193611Simp
62116951Ssam#include <net80211/ieee80211_var.h>
63119784Ssam#include <net80211/ieee80211_radiotap.h>
64116951Ssam
65147580Simp#define PCCARD_API_LEVEL 6
6693611Simp#include <dev/pccard/pccardvar.h>
67130257Simp#include <dev/pccard/pccard_cis.h>
6893611Simp
6993611Simp#include <dev/wi/if_wavelan_ieee.h>
70119784Ssam#include <dev/wi/if_wireg.h>
7193611Simp#include <dev/wi/if_wivar.h>
7293611Simp
7393611Simp#include "card_if.h"
74129764Simp#include "pccarddevs.h"
7593611Simp
7693611Simpstatic int wi_pccard_probe(device_t);
7793611Simpstatic int wi_pccard_attach(device_t);
7893611Simp
7995534Simpstatic device_method_t wi_pccard_methods[] = {
8095534Simp	/* Device interface */
81150454Simp	DEVMETHOD(device_probe,		wi_pccard_probe),
82150454Simp	DEVMETHOD(device_attach,	wi_pccard_attach),
83109323Ssam	DEVMETHOD(device_detach,	wi_detach),
8493611Simp	DEVMETHOD(device_shutdown,	wi_shutdown),
8593611Simp
8693611Simp	{ 0, 0 }
8793611Simp};
8893611Simp
8993611Simpstatic driver_t wi_pccard_driver = {
9093611Simp	"wi",
9193611Simp	wi_pccard_methods,
9293611Simp	sizeof(struct wi_softc)
9393611Simp};
9493611Simp
95113506SmdoddDRIVER_MODULE(wi, pccard, wi_pccard_driver, wi_devclass, 0, 0);
96113506SmdoddMODULE_DEPEND(wi, wlan, 1, 1, 1);
9793611Simp
9893611Simpstatic const struct pccard_product wi_pccard_products[] = {
99147580Simp	PCMCIA_CARD(3COM, 3CRWE737A),
100147580Simp	PCMCIA_CARD(3COM, 3CRWE777A),
101147580Simp	PCMCIA_CARD(ACTIONTEC, PRISM),
102147872Simp	PCMCIA_CARD(ADAPTEC2, ANW8030),
103147580Simp	PCMCIA_CARD(ADDTRON, AWP100),
104151321Simp	PCMCIA_CARD(AIRVAST, WN_100B),
105147580Simp	PCMCIA_CARD(AIRVAST, WN_100),
106147580Simp	PCMCIA_CARD(ALLIEDTELESIS, WR211PCM),
107147580Simp	PCMCIA_CARD(ARTEM, ONAIR),
108147580Simp 	PCMCIA_CARD(ASUS, WL100),
109147580Simp	PCMCIA_CARD(BAY, EMOBILITY_11B),
110147580Simp	PCMCIA_CARD(BROMAX, IWN),
111147580Simp	PCMCIA_CARD(BROMAX, IWN3),
112147580Simp	PCMCIA_CARD(BROMAX, WCF11),
113147580Simp	PCMCIA_CARD(BUFFALO, WLI_CF_S11G),
114147580Simp	PCMCIA_CARD(BUFFALO, WLI_PCM_S11),
115147580Simp	PCMCIA_CARD(COMPAQ, NC5004),
116147580Simp	PCMCIA_CARD(CONTEC, FX_DS110_PCC),
117147580Simp	PCMCIA_CARD(COREGA, WIRELESS_LAN_PCC_11),
118147580Simp	PCMCIA_CARD(COREGA, WIRELESS_LAN_PCCA_11),
119147580Simp	PCMCIA_CARD(COREGA, WIRELESS_LAN_PCCB_11),
120147580Simp	PCMCIA_CARD(COREGA, WIRELESS_LAN_PCCL_11),
121147580Simp	PCMCIA_CARD(DLINK, DWL650H),
122147580Simp	PCMCIA_CARD(ELSA, XI300_IEEE),
123147580Simp	PCMCIA_CARD(ELSA, XI325_IEEE),
124182236Simp	PCMCIA_CARD(ELSA, APDL325_IEEE),
125151321Simp	PCMCIA_CARD(ELSA, XI330_IEEE),
126147580Simp	PCMCIA_CARD(ELSA, XI800_IEEE),
127147580Simp	PCMCIA_CARD(ELSA, WIFI_FLASH),
128147580Simp	PCMCIA_CARD(EMTAC, WLAN),
129147580Simp	PCMCIA_CARD(ERICSSON, WIRELESSLAN),
130147580Simp	PCMCIA_CARD(GEMTEK, WLAN),
131147580Simp	PCMCIA_CARD(HWN, AIRWAY80211),
132147580Simp	PCMCIA_CARD(INTEL, PRO_WLAN_2011),
133147580Simp	PCMCIA_CARD(INTERSIL, ISL37100P),
134147580Simp	PCMCIA_CARD(INTERSIL, ISL37110P),
135147580Simp	PCMCIA_CARD(INTERSIL, ISL37300P),
136147580Simp	PCMCIA_CARD(INTERSIL2, PRISM2),
137147580Simp	PCMCIA_CARD(IODATA2, WCF12),
138147580Simp	PCMCIA_CARD(IODATA2, WNB11PCM),
139147580Simp	PCMCIA_CARD(FUJITSU, WL110),
140147580Simp	PCMCIA_CARD(LUCENT, WAVELAN_IEEE),
141147580Simp	PCMCIA_CARD(MICROSOFT, MN_520),
142147580Simp	PCMCIA_CARD(NOKIA, C020_WLAN),
143147580Simp	PCMCIA_CARD(NOKIA, C110_WLAN),
144147580Simp	PCMCIA_CARD(PLANEX, GWNS11H),
145147580Simp	PCMCIA_CARD(PROXIM, HARMONY),
146147580Simp	PCMCIA_CARD(PROXIM, RANGELANDS_8430),
147147580Simp	PCMCIA_CARD(SAMSUNG, SWL_2000N),
148147580Simp	PCMCIA_CARD(SIEMENS, SS1021),
149181211Simp	PCMCIA_CARD(SIEMENS, SS1021A),
150147580Simp	PCMCIA_CARD(SIMPLETECH, SPECTRUM24_ALT),
151147580Simp	PCMCIA_CARD(SOCKET, LP_WLAN_CF),
152147580Simp	PCMCIA_CARD(TDK, LAK_CD011WL),
15393611Simp	{ NULL }
15493611Simp};
15593611Simp
15693611Simpstatic int
157150454Simpwi_pccard_probe(device_t dev)
15893611Simp{
15993611Simp	const struct pccard_product *pp;
160130257Simp	u_int32_t fcn = PCCARD_FUNCTION_UNSPEC;
161130257Simp	int error;
16293611Simp
163130257Simp	/* Make sure we're a network driver */
164130257Simp	error = pccard_get_function(dev, &fcn);
165130257Simp	if (error != 0)
166178354Ssam		return error;
167130257Simp	if (fcn != PCCARD_FUNCTION_NETWORK)
168178354Ssam		return ENXIO;
169130257Simp
170178354Ssam	pp = pccard_product_lookup(dev, wi_pccard_products,
171178354Ssam	    sizeof(wi_pccard_products[0]), NULL);
172178354Ssam	if (pp != NULL) {
173113315Simp		if (pp->pp_name != NULL)
174113258Simp			device_set_desc(dev, pp->pp_name);
175178354Ssam		return 0;
176113258Simp	}
177178354Ssam	return ENXIO;
17893611Simp}
17993611Simp
18093611Simpstatic int
181150454Simpwi_pccard_attach(device_t dev)
18293611Simp{
18393611Simp	struct wi_softc	*sc;
184178354Ssam	int error;
18593611Simp
18693611Simp	sc = device_get_softc(dev);
18793611Simp	sc->wi_gone = 0;
18893611Simp	sc->wi_bus_type = WI_BUS_PCCARD;
18993611Simp
19093611Simp	error = wi_alloc(dev, 0);
191178354Ssam	if (error == 0) {
192178354Ssam		/* Make sure interrupts are disabled. */
193178354Ssam		CSR_WRITE_2(sc, WI_INT_EN, 0);
194178354Ssam		CSR_WRITE_2(sc, WI_EVENT_ACK, 0xFFFF);
19593611Simp
196178354Ssam		error = wi_attach(dev);
197178354Ssam		if (error != 0)
198178354Ssam			wi_free(dev);
199101245Simp	}
200178354Ssam	return error;
20193611Simp}
202