divided into PCMCIA attachment and common code of wi.
since if_wi_ieee.h does not depend for pcmcia, sys/dev/pcmcia/if_wi_ieee.h was moved to sys/dev/ic/wi_ieee.h .
This commit is contained in:
parent
b866d429c1
commit
8bb5cfe6aa
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: files,v 1.437 2001/05/02 12:53:32 minoura Exp $
|
||||
# $NetBSD: files,v 1.438 2001/05/06 03:26:38 ichiro Exp $
|
||||
|
||||
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
|
||||
|
||||
|
@ -311,6 +311,10 @@ file dev/ic/awi_wep.c awi
|
|||
file dev/ic/awi_wicfg.c awi
|
||||
file dev/ic/am79c930.c awi
|
||||
|
||||
# Lucent & Intersil WaveLan IEEE (802.11)
|
||||
device wi: arp, wlan, ifnet
|
||||
file dev/ic/wi.c wi
|
||||
|
||||
# 3Com Etherlink-III Ethernet controller
|
||||
device ep: arp, ether, ifnet, mii, mii_bitbang
|
||||
file dev/ic/elink3.c ep
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# $NetBSD: Makefile,v 1.19 2001/04/11 09:07:21 wiz Exp $
|
||||
# $NetBSD: Makefile,v 1.20 2001/05/06 03:26:38 ichiro Exp $
|
||||
|
||||
INCSDIR= /usr/include/dev/ic
|
||||
|
||||
# Only install includes which are used by userland
|
||||
INCS= bt8xx.h isp_ioctl.h mlxreg.h mlxio.h rrunnerreg.h rrunnervar.h wdcreg.h
|
||||
INCS= bt8xx.h isp_ioctl.h mlxreg.h mlxio.h rrunnerreg.h rrunnervar.h wdcreg.h wi_ieee.h
|
||||
|
||||
.include <bsd.kinc.mk>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: awi_wicfg.c,v 1.3 2000/07/06 17:22:25 onoe Exp $ */
|
||||
/* $NetBSD: awi_wicfg.c,v 1.4 2001/05/06 03:26:38 ichiro Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
|
@ -78,7 +78,7 @@
|
|||
#include <dev/ic/awireg.h>
|
||||
#include <dev/ic/awivar.h>
|
||||
|
||||
#include <dev/pcmcia/if_wi_ieee.h> /* XXX */
|
||||
#include <dev/ic/wi_ieee.h> /* XXX */
|
||||
#endif
|
||||
#ifdef __FreeBSD__
|
||||
#include <dev/awi/am79c930reg.h>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_wi.c,v 1.60 2001/04/29 20:12:01 christos Exp $ */
|
||||
/* $NetBSD: wi.c,v 1.1 2001/05/06 03:26:39 ichiro Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997, 1998, 1999
|
||||
|
@ -74,7 +74,6 @@
|
|||
|
||||
#include "opt_inet.h"
|
||||
#include "bpfilter.h"
|
||||
#include "rnd.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -86,10 +85,6 @@
|
|||
#include <sys/kernel.h> /* for hz */
|
||||
#include <sys/proc.h>
|
||||
|
||||
#if NRND > 0
|
||||
#include <sys/rnd.h>
|
||||
#endif
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/if_media.h>
|
||||
|
@ -109,34 +104,13 @@
|
|||
#include <net/bpfdesc.h>
|
||||
#endif
|
||||
|
||||
#include <dev/pcmcia/if_wireg.h>
|
||||
|
||||
#include <dev/pcmcia/pcmciareg.h>
|
||||
#include <dev/pcmcia/pcmciavar.h>
|
||||
#include <dev/pcmcia/pcmciadevs.h>
|
||||
|
||||
#include <dev/pcmcia/if_wi_ieee.h>
|
||||
#include <dev/pcmcia/if_wivar.h>
|
||||
|
||||
#ifdef foo
|
||||
static u_int8_t wi_mcast_addr[6] = { 0x01, 0x60, 0x1D, 0x00, 0x01, 0x00 };
|
||||
#endif
|
||||
|
||||
struct wi_pcmcia_product {
|
||||
u_int32_t pp_vendor; /* vendor ID */
|
||||
u_int32_t pp_product; /* product ID */
|
||||
const char *pp_cisinfo[4]; /* CIS information */
|
||||
const char *pp_name; /* product name */
|
||||
int pp_prism2; /* prism2 chipset */
|
||||
};
|
||||
|
||||
static const struct wi_pcmcia_product *wi_lookup __P((struct pcmcia_attach_args *pa));
|
||||
static int wi_match __P((struct device *, struct cfdata *, void *));
|
||||
static void wi_attach __P((struct device *, struct device *, void *));
|
||||
static int wi_detach __P((struct device *, int));
|
||||
static int wi_activate __P((struct device *, enum devact));
|
||||
|
||||
static int wi_intr __P((void *arg));
|
||||
#include <dev/ic/wi_ieee.h>
|
||||
#include <dev/ic/wireg.h>
|
||||
#include <dev/ic/wivar.h>
|
||||
|
||||
static void wi_reset __P((struct wi_softc *));
|
||||
static int wi_ioctl __P((struct ifnet *, u_long, caddr_t));
|
||||
|
@ -162,10 +136,7 @@ static void wi_inquire __P((void *));
|
|||
static int wi_setdef __P((struct wi_softc *, struct wi_req *));
|
||||
static int wi_getdef __P((struct wi_softc *, struct wi_req *));
|
||||
static int wi_mgmt_xmit __P((struct wi_softc *, caddr_t, int));
|
||||
static void wi_shutdown __P((void *));
|
||||
|
||||
static int wi_enable __P((struct wi_softc *));
|
||||
static void wi_disable __P((struct wi_softc *));
|
||||
static int wi_media_change __P((struct ifnet *));
|
||||
static void wi_media_status __P((struct ifnet *, struct ifmediareq *));
|
||||
|
||||
|
@ -180,244 +151,19 @@ static int wi_sync_media __P((struct wi_softc *, int, int));
|
|||
static int wi_set_pm(struct wi_softc *, struct ieee80211_power *);
|
||||
static int wi_get_pm(struct wi_softc *, struct ieee80211_power *);
|
||||
|
||||
struct cfattach wi_ca = {
|
||||
sizeof(struct wi_softc), wi_match, wi_attach, wi_detach, wi_activate
|
||||
};
|
||||
|
||||
static const struct wi_pcmcia_product wi_pcmcia_products[] = {
|
||||
{ PCMCIA_VENDOR_LUCENT,
|
||||
PCMCIA_PRODUCT_LUCENT_WAVELAN_IEEE,
|
||||
PCMCIA_CIS_LUCENT_WAVELAN_IEEE,
|
||||
PCMCIA_STR_LUCENT_WAVELAN_IEEE,
|
||||
0 },
|
||||
|
||||
{ PCMCIA_VENDOR_3COM,
|
||||
PCMCIA_PRODUCT_3COM_3CRWE737A,
|
||||
PCMCIA_CIS_3COM_3CRWE737A,
|
||||
PCMCIA_STR_3COM_3CRWE737A,
|
||||
1 },
|
||||
|
||||
{ PCMCIA_VENDOR_COREGA,
|
||||
PCMCIA_PRODUCT_COREGA_WIRELESS_LAN_PCC_11,
|
||||
PCMCIA_CIS_COREGA_WIRELESS_LAN_PCC_11,
|
||||
PCMCIA_STR_COREGA_WIRELESS_LAN_PCC_11,
|
||||
1 },
|
||||
|
||||
{ PCMCIA_VENDOR_COREGA,
|
||||
PCMCIA_PRODUCT_COREGA_WIRELESS_LAN_PCCA_11,
|
||||
PCMCIA_CIS_COREGA_WIRELESS_LAN_PCCA_11,
|
||||
PCMCIA_STR_COREGA_WIRELESS_LAN_PCCA_11,
|
||||
1 },
|
||||
|
||||
{ PCMCIA_VENDOR_INTERSIL,
|
||||
PCMCIA_PRODUCT_INTERSIL_PRISM2,
|
||||
PCMCIA_CIS_INTERSIL_PRISM2,
|
||||
PCMCIA_STR_INTERSIL_PRISM2,
|
||||
1 },
|
||||
|
||||
{ PCMCIA_VENDOR_SAMSUNG,
|
||||
PCMCIA_PRODUCT_SAMSUNG_SWL_2000N,
|
||||
PCMCIA_CIS_SAMSUNG_SWL_2000N,
|
||||
PCMCIA_STR_SAMSUNG_SWL_2000N,
|
||||
1 },
|
||||
|
||||
{ PCMCIA_VENDOR_LUCENT,
|
||||
PCMCIA_PRODUCT_LUCENT_WAVELAN_IEEE,
|
||||
PCMCIA_CIS_SMC_2632W,
|
||||
PCMCIA_STR_SMC_2632W,
|
||||
1 },
|
||||
|
||||
{ PCMCIA_VENDOR_LUCENT,
|
||||
PCMCIA_PRODUCT_LUCENT_WAVELAN_IEEE,
|
||||
PCMCIA_CIS_NANOSPEED_PRISM2,
|
||||
PCMCIA_STR_NANOSPEED_PRISM2,
|
||||
1 },
|
||||
|
||||
{ PCMCIA_VENDOR_ELSA,
|
||||
PCMCIA_PRODUCT_ELSA_XI300_IEEE,
|
||||
PCMCIA_CIS_ELSA_XI300_IEEE,
|
||||
PCMCIA_STR_ELSA_XI300_IEEE,
|
||||
1 },
|
||||
|
||||
{ PCMCIA_VENDOR_COMPAQ,
|
||||
PCMCIA_PRODUCT_COMPAQ_NC5004,
|
||||
PCMCIA_CIS_COMPAQ_NC5004,
|
||||
PCMCIA_STR_COMPAQ_NC5004,
|
||||
1 },
|
||||
|
||||
{ PCMCIA_VENDOR_CONTEC,
|
||||
PCMCIA_PRODUCT_CONTEC_FX_DS110_PCC,
|
||||
PCMCIA_CIS_CONTEC_FX_DS110_PCC,
|
||||
PCMCIA_STR_CONTEC_FX_DS110_PCC,
|
||||
1 },
|
||||
|
||||
{ PCMCIA_VENDOR_TDK,
|
||||
PCMCIA_PRODUCT_TDK_LAK_CD011WL,
|
||||
PCMCIA_CIS_TDK_LAK_CD011WL,
|
||||
PCMCIA_STR_TDK_LAK_CD011WL,
|
||||
1 },
|
||||
|
||||
{ PCMCIA_VENDOR_LUCENT,
|
||||
PCMCIA_PRODUCT_LUCENT_WAVELAN_IEEE,
|
||||
PCMCIA_CIS_NEC_CMZ_RT_WP,
|
||||
PCMCIA_STR_NEC_CMZ_RT_WP,
|
||||
1 },
|
||||
|
||||
{ PCMCIA_VENDOR_LUCENT,
|
||||
PCMCIA_PRODUCT_LUCENT_WAVELAN_IEEE,
|
||||
PCMCIA_CIS_NTT_ME_WLAN,
|
||||
PCMCIA_STR_NTT_ME_WLAN,
|
||||
1 },
|
||||
|
||||
{ PCMCIA_VENDOR_IODATA2,
|
||||
PCMCIA_PRODUCT_IODATA2_WNB11PCM,
|
||||
PCMCIA_CIS_IODATA2_WNB11PCM,
|
||||
PCMCIA_STR_IODATA2_WNB11PCM,
|
||||
1 },
|
||||
|
||||
{ 0,
|
||||
0,
|
||||
{ NULL, NULL, NULL, NULL },
|
||||
NULL,
|
||||
0 }
|
||||
};
|
||||
|
||||
static const struct wi_pcmcia_product *
|
||||
wi_lookup(pa)
|
||||
struct pcmcia_attach_args *pa;
|
||||
{
|
||||
const struct wi_pcmcia_product *pp;
|
||||
|
||||
/*
|
||||
* match by CIS information first
|
||||
* XXX: Farallon SkyLINE 11mb uses PRISM II but vendor ID
|
||||
* and product ID is the same as Lucent WaveLAN
|
||||
*/
|
||||
for (pp = wi_pcmcia_products; pp->pp_name != NULL; pp++) {
|
||||
if (pa->card->cis1_info[0] != NULL &&
|
||||
pp->pp_cisinfo[0] != NULL &&
|
||||
strcmp(pa->card->cis1_info[0], pp->pp_cisinfo[0]) == 0 &&
|
||||
pa->card->cis1_info[1] != NULL &&
|
||||
pp->pp_cisinfo[1] != NULL &&
|
||||
strcmp(pa->card->cis1_info[1], pp->pp_cisinfo[1]) == 0)
|
||||
return pp;
|
||||
}
|
||||
|
||||
/* match by vendor/product id */
|
||||
for (pp = wi_pcmcia_products; pp->pp_name != NULL; pp++) {
|
||||
if (pa->manufacturer != PCMCIA_VENDOR_INVALID &&
|
||||
pa->manufacturer == pp->pp_vendor &&
|
||||
pa->product != PCMCIA_PRODUCT_INVALID &&
|
||||
pa->product == pp->pp_product)
|
||||
return pp;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
wi_match(parent, match, aux)
|
||||
struct device *parent;
|
||||
struct cfdata *match;
|
||||
void *aux;
|
||||
{
|
||||
struct pcmcia_attach_args *pa = aux;
|
||||
|
||||
if (wi_lookup(pa) != NULL)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
wi_enable(sc)
|
||||
wi_attach(sc)
|
||||
struct wi_softc *sc;
|
||||
{
|
||||
|
||||
if (sc->sc_enabled != 0)
|
||||
return (0);
|
||||
|
||||
sc->sc_ih = pcmcia_intr_establish(sc->sc_pf, IPL_NET, wi_intr, sc);
|
||||
if (sc->sc_ih == NULL) {
|
||||
printf("%s: couldn't establish interrupt handler\n",
|
||||
sc->sc_dev.dv_xname);
|
||||
return (EIO);
|
||||
}
|
||||
if (pcmcia_function_enable(sc->sc_pf) != 0) {
|
||||
printf("%s: couldn't enable card\n", sc->sc_dev.dv_xname);
|
||||
pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih);
|
||||
return (EIO);
|
||||
}
|
||||
|
||||
sc->sc_enabled = 1;
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
wi_disable(sc)
|
||||
struct wi_softc *sc;
|
||||
{
|
||||
|
||||
if (sc->sc_enabled == 0)
|
||||
return;
|
||||
|
||||
pcmcia_function_disable(sc->sc_pf);
|
||||
pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih);
|
||||
sc->sc_enabled = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Attach the card.
|
||||
*/
|
||||
void
|
||||
wi_attach(parent, self, aux)
|
||||
struct device *parent, *self;
|
||||
void *aux;
|
||||
{
|
||||
struct wi_softc *sc = (void *) self;
|
||||
struct pcmcia_attach_args *pa = aux;
|
||||
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
|
||||
const struct wi_pcmcia_product *pp;
|
||||
struct wi_ltv_macaddr mac;
|
||||
struct wi_ltv_gen gen;
|
||||
char devinfo[256];
|
||||
struct ifnet *ifp = sc->sc_ifp;
|
||||
struct wi_ltv_macaddr mac;
|
||||
struct wi_ltv_gen gen;
|
||||
static const u_int8_t empty_macaddr[ETHER_ADDR_LEN] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
int s;
|
||||
|
||||
/* Print out what we are. */
|
||||
pcmcia_devinfo(&pa->pf->sc->card, 0, devinfo, sizeof(devinfo));
|
||||
printf(": %s\n", devinfo);
|
||||
|
||||
/* Enable the card. */
|
||||
sc->sc_pf = pa->pf;
|
||||
pcmcia_function_init(sc->sc_pf, sc->sc_pf->cfe_head.sqh_first);
|
||||
if (pcmcia_function_enable(sc->sc_pf)) {
|
||||
printf("%s: function enable failed\n", sc->sc_dev.dv_xname);
|
||||
goto enable_failed;
|
||||
}
|
||||
|
||||
/* Allocate/map I/O space. */
|
||||
if (pcmcia_io_alloc(sc->sc_pf, 0, WI_IOSIZ, WI_IOSIZ,
|
||||
&sc->sc_pcioh) != 0) {
|
||||
printf("%s: can't allocate i/o space\n",
|
||||
sc->sc_dev.dv_xname);
|
||||
goto ioalloc_failed;
|
||||
}
|
||||
printf("%s:", sc->sc_dev.dv_xname);
|
||||
if (pcmcia_io_map(sc->sc_pf, PCMCIA_WIDTH_IO16, 0,
|
||||
WI_IOSIZ, &sc->sc_pcioh, &sc->sc_iowin) != 0) {
|
||||
printf(" can't map i/o space\n");
|
||||
goto iomap_failed;
|
||||
}
|
||||
sc->wi_btag = sc->sc_pcioh.iot;
|
||||
sc->wi_bhandle = sc->sc_pcioh.ioh;
|
||||
|
||||
pp = wi_lookup(pa);
|
||||
if (pp == NULL) {
|
||||
/* should not happen */
|
||||
sc->sc_prism2 = 0;
|
||||
} else
|
||||
sc->sc_prism2 = pp->pp_prism2;
|
||||
s = splnet();
|
||||
|
||||
callout_init(&sc->wi_inquire_ch);
|
||||
|
||||
|
@ -444,10 +190,10 @@ wi_attach(parent, self, aux)
|
|||
if (bcmp(sc->sc_macaddr, empty_macaddr, ETHER_ADDR_LEN) == 0) {
|
||||
printf("%s: could not get mac address, attach failed\n",
|
||||
sc->sc_dev.dv_xname);
|
||||
goto bad_enaddr;
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf(", 802.11 address %s\n", ether_sprintf(sc->sc_macaddr));
|
||||
printf(" 802.11 address %s\n", ether_sprintf(sc->sc_macaddr));
|
||||
|
||||
memcpy(ifp->if_xname, sc->sc_dev.dv_xname, IFNAMSIZ);
|
||||
ifp->if_softc = sc;
|
||||
|
@ -457,6 +203,9 @@ wi_attach(parent, self, aux)
|
|||
ifp->if_init = wi_init;
|
||||
ifp->if_stop = wi_stop;
|
||||
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
|
||||
#ifdef IFF_NOTRAILERS
|
||||
ifp->if_flags |= IFF_NOTRAILERS;
|
||||
#endif
|
||||
IFQ_SET_READY(&ifp->if_snd);
|
||||
|
||||
(void)wi_set_ssid(&sc->wi_nodeid, WI_DEFAULT_NODENAME,
|
||||
|
@ -524,25 +273,11 @@ wi_attach(parent, self, aux)
|
|||
|
||||
ifp->if_baudrate = IF_Mbps(2);
|
||||
|
||||
#if NRND > 0
|
||||
rnd_attach_source(&sc->rnd_source, sc->sc_dev.dv_xname,
|
||||
RND_TYPE_NET, 0);
|
||||
#endif
|
||||
/* Attach is successful. */
|
||||
sc->sc_attached = 1;
|
||||
|
||||
sc->sc_sdhook = shutdownhook_establish(wi_shutdown, sc);
|
||||
|
||||
/* Disable the card now, and turn it on when the interface goes up */
|
||||
pcmcia_function_disable(sc->sc_pf);
|
||||
return;
|
||||
|
||||
bad_enaddr:
|
||||
pcmcia_io_unmap(sc->sc_pf, sc->sc_iowin);
|
||||
iomap_failed:
|
||||
pcmcia_io_free(sc->sc_pf, &sc->sc_pcioh);
|
||||
ioalloc_failed:
|
||||
pcmcia_function_disable(sc->sc_pf);
|
||||
enable_failed:
|
||||
sc->sc_iowin = -1;
|
||||
splx(s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void wi_rxeof(sc)
|
||||
|
@ -554,7 +289,7 @@ static void wi_rxeof(sc)
|
|||
struct mbuf *m;
|
||||
int id;
|
||||
|
||||
ifp = &sc->sc_ethercom.ec_if;
|
||||
ifp = sc->sc_ifp;
|
||||
|
||||
id = CSR_READ_2(sc, WI_RX_FID);
|
||||
|
||||
|
@ -652,12 +387,10 @@ static void wi_rxeof(sc)
|
|||
}
|
||||
|
||||
static void wi_txeof(sc, status)
|
||||
struct wi_softc *sc;
|
||||
int status;
|
||||
struct wi_softc *sc;
|
||||
int status;
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
|
||||
ifp = &sc->sc_ethercom.ec_if;
|
||||
struct ifnet *ifp = sc->sc_ifp;
|
||||
|
||||
ifp->if_timer = 0;
|
||||
ifp->if_flags &= ~IFF_OACTIVE;
|
||||
|
@ -797,13 +530,11 @@ int wi_intr(arg)
|
|||
if (IFQ_IS_EMPTY(&ifp->if_snd) == 0)
|
||||
wi_start(ifp);
|
||||
|
||||
#if NRND > 0
|
||||
rnd_add_uint32(&sc->rnd_source, status);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int wi_cmd(sc, cmd, val)
|
||||
static int
|
||||
wi_cmd(sc, cmd, val)
|
||||
struct wi_softc *sc;
|
||||
int cmd;
|
||||
int val;
|
||||
|
@ -812,14 +543,8 @@ static int wi_cmd(sc, cmd, val)
|
|||
|
||||
/* wait for the busy bit to clear */
|
||||
for (i = 0; i < WI_TIMEOUT; i++) {
|
||||
if (!(CSR_READ_2(sc, WI_COMMAND) & WI_CMD_BUSY)) {
|
||||
if (!(CSR_READ_2(sc, WI_COMMAND) & WI_CMD_BUSY))
|
||||
break;
|
||||
}
|
||||
DELAY(10*1000); /* 10 m sec */
|
||||
}
|
||||
|
||||
if (i == WI_TIMEOUT) {
|
||||
return(ETIMEDOUT);
|
||||
}
|
||||
|
||||
CSR_WRITE_2(sc, WI_PARAM0, val);
|
||||
|
@ -827,39 +552,31 @@ static int wi_cmd(sc, cmd, val)
|
|||
CSR_WRITE_2(sc, WI_PARAM2, 0);
|
||||
CSR_WRITE_2(sc, WI_COMMAND, cmd);
|
||||
|
||||
/* wait for the cmd completed bit */
|
||||
for (i = 0; i < WI_TIMEOUT; i++) {
|
||||
/*
|
||||
* Wait for 'command complete' bit to be
|
||||
* set in the event status register.
|
||||
*/
|
||||
s = CSR_READ_2(sc, WI_EVENT_STAT) & WI_EV_CMD;
|
||||
if (s) {
|
||||
/* Ack the event and read result code. */
|
||||
s = CSR_READ_2(sc, WI_STATUS);
|
||||
CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_CMD);
|
||||
#ifdef foo
|
||||
if ((s & WI_CMD_CODE_MASK) != (cmd & WI_CMD_CODE_MASK))
|
||||
return(EIO);
|
||||
#endif
|
||||
if (s & WI_STAT_CMD_RESULT)
|
||||
return(EIO);
|
||||
if (CSR_READ_2(sc, WI_EVENT_STAT) & WI_EV_CMD)
|
||||
break;
|
||||
}
|
||||
if (cmd == WI_CMD_INI)
|
||||
DELAY(100);
|
||||
DELAY(10);
|
||||
}
|
||||
|
||||
/* Ack the command */
|
||||
CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_CMD);
|
||||
|
||||
s = CSR_READ_2(sc, WI_STATUS);
|
||||
if (s & WI_STAT_CMD_RESULT)
|
||||
return(EIO);
|
||||
|
||||
if (i == WI_TIMEOUT)
|
||||
return(ETIMEDOUT);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
static void wi_reset(sc)
|
||||
static void
|
||||
wi_reset(sc)
|
||||
struct wi_softc *sc;
|
||||
{
|
||||
DELAY(100*1000); /* 100 m sec */
|
||||
|
||||
DELAY(100*1000); /* 100 m sec */
|
||||
if (wi_cmd(sc, WI_CMD_INI, 0))
|
||||
printf("%s: init failed\n", sc->sc_dev.dv_xname);
|
||||
CSR_WRITE_2(sc, WI_INT_EN, 0);
|
||||
|
@ -1027,6 +744,7 @@ static int wi_write_record(sc, ltv)
|
|||
CSR_WRITE_2(sc, WI_DATA1, ltv->wi_len);
|
||||
CSR_WRITE_2(sc, WI_DATA1, ltv->wi_type);
|
||||
|
||||
/* Write data */
|
||||
ptr = <v->wi_val;
|
||||
for (i = 0; i < ltv->wi_len - 1; i++)
|
||||
CSR_WRITE_2(sc, WI_DATA1, ptr[i]);
|
||||
|
@ -1392,7 +1110,8 @@ wi_getdef(sc, wreq)
|
|||
return (error);
|
||||
}
|
||||
|
||||
static int wi_ioctl(ifp, command, data)
|
||||
static int
|
||||
wi_ioctl(ifp, command, data)
|
||||
struct ifnet *ifp;
|
||||
u_long command;
|
||||
caddr_t data;
|
||||
|
@ -1411,11 +1130,39 @@ static int wi_ioctl(ifp, command, data)
|
|||
|
||||
ifr = (struct ifreq *)data;
|
||||
switch (command) {
|
||||
case SIOCSIFADDR:
|
||||
case SIOCGIFADDR:
|
||||
case SIOCSIFMTU:
|
||||
error = ether_ioctl(ifp, command, data);
|
||||
break;
|
||||
case SIOCSIFFLAGS:
|
||||
if (!(ifp->if_flags & IFF_UP)) {
|
||||
if (sc->sc_disable)
|
||||
(*sc->sc_disable)(sc);
|
||||
sc->sc_enabled = 0;
|
||||
ifp->if_flags &= ~IFF_RUNNING;
|
||||
}
|
||||
break;
|
||||
case SIOCADDMULTI:
|
||||
case SIOCDELMULTI:
|
||||
error = (command == SIOCADDMULTI) ?
|
||||
ether_addmulti(ifr, &sc->sc_ethercom) :
|
||||
ether_delmulti(ifr, &sc->sc_ethercom);
|
||||
if (error == ENETRESET) {
|
||||
if (sc->sc_enabled != 0) {
|
||||
/*
|
||||
* Multicast list has changed. Set the
|
||||
* hardware filter accordingly.
|
||||
*/
|
||||
wi_setmulti(sc);
|
||||
}
|
||||
error = 0;
|
||||
}
|
||||
break;
|
||||
case SIOCSIFMEDIA:
|
||||
case SIOCGIFMEDIA:
|
||||
error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, command);
|
||||
break;
|
||||
|
||||
case SIOCGWAVELAN:
|
||||
error = copyin(ifr->ifr_data, &wreq, sizeof(wreq));
|
||||
if (error)
|
||||
|
@ -1514,22 +1261,11 @@ static int wi_ioctl(ifp, command, data)
|
|||
break;
|
||||
|
||||
default:
|
||||
error = ether_ioctl(ifp, command, data);
|
||||
if (error == ENETRESET) {
|
||||
if (sc->sc_enabled != 0) {
|
||||
/*
|
||||
* Multicast list has changed. Set the
|
||||
* hardware filter accordingly.
|
||||
*/
|
||||
wi_setmulti(sc);
|
||||
}
|
||||
error = 0;
|
||||
}
|
||||
error = EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
splx(s);
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
@ -1542,8 +1278,11 @@ wi_init(ifp)
|
|||
struct wi_ltv_macaddr mac;
|
||||
int error, id = 0;
|
||||
|
||||
if ((error = wi_enable(sc)) != 0)
|
||||
goto out;
|
||||
if (!sc->sc_enabled) {
|
||||
if((error = (*sc->sc_enable)(sc)) != 0)
|
||||
goto out;
|
||||
sc->sc_enabled = 1;
|
||||
}
|
||||
|
||||
wi_stop(ifp, 0);
|
||||
wi_reset(sc);
|
||||
|
@ -1645,7 +1384,8 @@ wi_init(ifp)
|
|||
return (error);
|
||||
}
|
||||
|
||||
static void wi_start(ifp)
|
||||
static void
|
||||
wi_start(ifp)
|
||||
struct ifnet *ifp;
|
||||
{
|
||||
struct wi_softc *sc;
|
||||
|
@ -1734,7 +1474,8 @@ static void wi_start(ifp)
|
|||
return;
|
||||
}
|
||||
|
||||
static int wi_mgmt_xmit(sc, data, len)
|
||||
static int
|
||||
wi_mgmt_xmit(sc, data, len)
|
||||
struct wi_softc *sc;
|
||||
caddr_t data;
|
||||
int len;
|
||||
|
@ -1779,14 +1520,18 @@ wi_stop(ifp, disable)
|
|||
|
||||
callout_stop(&sc->wi_inquire_ch);
|
||||
|
||||
if (disable)
|
||||
wi_disable(sc);
|
||||
if (disable) {
|
||||
if (sc->sc_disable)
|
||||
(*sc->sc_disable)(sc);
|
||||
sc->sc_enabled = 0;
|
||||
}
|
||||
|
||||
ifp->if_flags &= ~(IFF_OACTIVE | IFF_RUNNING);
|
||||
ifp->if_timer = 0;
|
||||
}
|
||||
|
||||
static void wi_watchdog(ifp)
|
||||
static void
|
||||
wi_watchdog(ifp)
|
||||
struct ifnet *ifp;
|
||||
{
|
||||
struct wi_softc *sc;
|
||||
|
@ -1802,17 +1547,22 @@ static void wi_watchdog(ifp)
|
|||
return;
|
||||
}
|
||||
|
||||
static void wi_shutdown(arg)
|
||||
void *arg;
|
||||
void
|
||||
wi_shutdown(sc)
|
||||
struct wi_softc *sc;
|
||||
{
|
||||
struct wi_softc *sc;
|
||||
int s;
|
||||
|
||||
sc = arg;
|
||||
wi_disable(sc);
|
||||
return;
|
||||
s = splnet();
|
||||
if (sc->sc_enabled) {
|
||||
if (sc->sc_disable)
|
||||
(*sc->sc_disable)(sc);
|
||||
sc->sc_enabled = 0;
|
||||
}
|
||||
splx(s);
|
||||
}
|
||||
|
||||
static int
|
||||
int
|
||||
wi_activate(self, act)
|
||||
struct device *self;
|
||||
enum devact act;
|
||||
|
@ -1834,39 +1584,64 @@ wi_activate(self, act)
|
|||
return (rv);
|
||||
}
|
||||
|
||||
static int
|
||||
wi_detach(self, flags)
|
||||
struct device *self;
|
||||
int flags;
|
||||
int
|
||||
wi_detach(sc)
|
||||
struct wi_softc *sc;
|
||||
{
|
||||
struct wi_softc *sc = (struct wi_softc *)self;
|
||||
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
|
||||
struct ifnet *ifp = sc->sc_ifp;
|
||||
int s;
|
||||
|
||||
if (sc->sc_iowin == -1)
|
||||
/* Nothing to detach. */
|
||||
if (!sc->sc_attached)
|
||||
return (0);
|
||||
|
||||
s = splnet();
|
||||
callout_stop(&sc->wi_inquire_ch);
|
||||
if (sc->sc_sdhook != NULL)
|
||||
shutdownhook_disestablish(sc->sc_sdhook);
|
||||
wi_disable(sc);
|
||||
|
||||
/* Delete all remaining media. */
|
||||
ifmedia_delete_instance(&sc->sc_media, IFM_INST_ANY);
|
||||
|
||||
#if NRND > 0
|
||||
rnd_detach_source(&sc->rnd_source);
|
||||
#endif
|
||||
ether_ifdetach(ifp);
|
||||
if_detach(ifp);
|
||||
|
||||
/* Unmap and free our i/o windows */
|
||||
pcmcia_io_unmap(sc->sc_pf, sc->sc_iowin);
|
||||
pcmcia_io_free(sc->sc_pf, &sc->sc_pcioh);
|
||||
|
||||
if (sc->sc_enabled) {
|
||||
if (sc->sc_disable)
|
||||
(*sc->sc_disable)(sc);
|
||||
sc->sc_enabled = 0;
|
||||
}
|
||||
splx(s);
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
wi_power(sc, why)
|
||||
struct wi_softc *sc;
|
||||
int why;
|
||||
{
|
||||
int s;
|
||||
|
||||
if (!sc->sc_enabled)
|
||||
return;
|
||||
|
||||
s = splnet();
|
||||
switch (why) {
|
||||
case PWR_SUSPEND:
|
||||
case PWR_STANDBY:
|
||||
wi_stop(sc->sc_ifp, 0);
|
||||
if (sc->sc_disable)
|
||||
(*sc->sc_disable)(sc);
|
||||
break;
|
||||
case PWR_RESUME:
|
||||
sc->sc_enabled = 0;
|
||||
wi_init(sc->sc_ifp);
|
||||
(void)wi_intr(sc);
|
||||
break;
|
||||
case PWR_SOFTSUSPEND:
|
||||
case PWR_SOFTSTANDBY:
|
||||
case PWR_SOFTRESUME:
|
||||
break;
|
||||
}
|
||||
splx(s);
|
||||
}
|
||||
|
||||
static int
|
||||
wi_set_ssid(ws, id, len)
|
||||
struct ieee80211_nwid *ws;
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_wi_ieee.h,v 1.8 2000/08/23 19:01:05 jhawk Exp $ */
|
||||
/* $NetBSD: wi_ieee.h,v 1.1 2001/05/06 03:26:39 ichiro Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997, 1998, 1999
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_wireg.h,v 1.7 2001/01/11 11:54:21 ichiro Exp $ */
|
||||
/* $NetBSD: wireg.h,v 1.1 2001/05/06 03:26:39 ichiro Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997, 1998, 1999
|
||||
|
@ -37,7 +37,7 @@
|
|||
* Oslo IETF plenary meeting.
|
||||
*/
|
||||
|
||||
#define WI_TIMEOUT 70000
|
||||
#define WI_TIMEOUT 65536
|
||||
|
||||
#define WI_PORT0 0
|
||||
#define WI_PORT1 1
|
||||
|
@ -92,18 +92,18 @@
|
|||
* register space access macros
|
||||
*/
|
||||
#define CSR_WRITE_4(sc, reg, val) \
|
||||
bus_space_write_4(sc->wi_btag, sc->wi_bhandle, reg, val)
|
||||
bus_space_write_4(sc->sc_iot, sc->sc_ioh, reg, val)
|
||||
#define CSR_WRITE_2(sc, reg, val) \
|
||||
bus_space_write_2(sc->wi_btag, sc->wi_bhandle, reg, val)
|
||||
bus_space_write_2(sc->sc_iot, sc->sc_ioh, reg, val)
|
||||
#define CSR_WRITE_1(sc, reg, val) \
|
||||
bus_space_write_1(sc->wi_btag, sc->wi_bhandle, reg, val)
|
||||
bus_space_write_1(sc->sc_iot, sc->sc_ioh, reg, val)
|
||||
|
||||
#define CSR_READ_4(sc, reg) \
|
||||
bus_space_read_4(sc->wi_btag, sc->wi_bhandle, reg)
|
||||
bus_space_read_4(sc->sc_iot, sc->sc_ioh, reg)
|
||||
#define CSR_READ_2(sc, reg) \
|
||||
bus_space_read_2(sc->wi_btag, sc->wi_bhandle, reg)
|
||||
bus_space_read_2(sc->sc_iot, sc->sc_ioh, reg)
|
||||
#define CSR_READ_1(sc, reg) \
|
||||
bus_space_read_1(sc->wi_btag, sc->wi_bhandle, reg)
|
||||
bus_space_read_1(sc->sc_iot, sc->sc_ioh, reg)
|
||||
|
||||
/*
|
||||
* The WaveLAN/IEEE cards contain an 802.11 MAC controller which Lucent
|
||||
|
@ -147,7 +147,7 @@
|
|||
/*
|
||||
* Size of Hermes I/O space.
|
||||
*/
|
||||
#define WI_IOSIZ 0x40
|
||||
#define WI_IOSIZE 0x40
|
||||
|
||||
/*
|
||||
* Hermes register definitions and what little I know about them.
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_wivar.h,v 1.15 2000/12/09 22:59:44 castor Exp $ */
|
||||
/* $NetBSD: wivar.h,v 1.1 2001/05/06 03:26:39 ichiro Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997, 1998, 1999
|
||||
|
@ -39,22 +39,22 @@
|
|||
*/
|
||||
|
||||
struct wi_softc {
|
||||
struct device sc_dev;
|
||||
struct ethercom sc_ethercom;
|
||||
struct device sc_dev;
|
||||
struct ethercom sc_ethercom;
|
||||
struct ifnet *sc_ifp;
|
||||
void *sc_ih; /* interrupt handler */
|
||||
int (*sc_enable) __P((struct wi_softc *));
|
||||
void (*sc_disable) __P((struct wi_softc *));
|
||||
|
||||
struct pcmcia_function *sc_pf;
|
||||
struct pcmcia_io_handle sc_pcioh;
|
||||
int sc_iowin;
|
||||
int sc_attached;
|
||||
int sc_enabled;
|
||||
int sc_prism2;
|
||||
|
||||
bus_space_tag_t wi_btag;
|
||||
bus_space_handle_t wi_bhandle;
|
||||
bus_space_tag_t sc_iot; /* bus cookie */
|
||||
bus_space_handle_t sc_ioh; /* bus i/o handle */
|
||||
|
||||
struct callout wi_inquire_ch;
|
||||
|
||||
void *sc_sdhook; /* saved shutdown hook for card */
|
||||
void *sc_ih;
|
||||
u_int8_t sc_macaddr[ETHER_ADDR_LEN];
|
||||
|
||||
struct ifmedia sc_media;
|
||||
|
@ -82,7 +82,11 @@ struct wi_softc {
|
|||
int wi_tx_key;
|
||||
struct wi_ltv_keys wi_keys;
|
||||
struct wi_counters wi_stats;
|
||||
#if NRND > 0
|
||||
rndsource_element_t rnd_source; /* random source */
|
||||
#endif
|
||||
};
|
||||
|
||||
int wi_attach __P((struct wi_softc *));
|
||||
int wi_detach __P((struct wi_softc *));
|
||||
int wi_activate __P((struct device *, enum devact));
|
||||
int wi_intr __P((void *arg));
|
||||
void wi_power __P((struct wi_softc *, int));
|
||||
void wi_shutdown __P((struct wi_softc *));
|
|
@ -1,10 +1,10 @@
|
|||
# $NetBSD: Makefile,v 1.6 2001/04/11 19:07:37 jdolecek Exp $
|
||||
# $NetBSD: Makefile,v 1.7 2001/05/06 03:26:39 ichiro Exp $
|
||||
|
||||
# use 'make -f Makefile.pcmciadevs' to make pcmciadevs.h and pcmciadevs_data.h
|
||||
|
||||
INCSDIR= /usr/include/dev/pcmcia
|
||||
|
||||
# Only install includes which are used by userland
|
||||
INCS= if_wi_ieee.h if_cnwioctl.h if_rayreg.h
|
||||
INCS= if_cnwioctl.h if_rayreg.h
|
||||
|
||||
.include <bsd.kinc.mk>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: files.pcmcia,v 1.37 2001/02/24 02:13:33 lukem Exp $
|
||||
# $NetBSD: files.pcmcia,v 1.38 2001/05/06 03:26:39 ichiro Exp $
|
||||
#
|
||||
# Config.new file and device description for machine-independent PCMCIA code.
|
||||
# Included by ports that need it.
|
||||
|
@ -72,11 +72,6 @@ device cnw: arp, ether, ifnet
|
|||
attach cnw at pcmcia
|
||||
file dev/pcmcia/if_cnw.c cnw
|
||||
|
||||
# Lucent WaveLan IEEE (802.11)
|
||||
device wi: arp, ether, ifnet
|
||||
attach wi at pcmcia
|
||||
file dev/pcmcia/if_wi.c wi
|
||||
|
||||
# Megaherz combo cards
|
||||
device mhzc { }
|
||||
attach mhzc at pcmcia
|
||||
|
@ -94,6 +89,10 @@ file dev/pcmcia/if_ray.c ray
|
|||
attach awi at pcmcia with awi_pcmcia
|
||||
file dev/pcmcia/if_awi_pcmcia.c awi_pcmcia
|
||||
|
||||
# Lucent & Intersil WaveLan IEEE (802.11)
|
||||
attach wi at pcmcia with wi_pcmcia
|
||||
file dev/pcmcia/if_wi_pcmcia.c wi_pcmcia
|
||||
|
||||
# Xircom Ethernet cards
|
||||
device xi: arp, ether, ifnet, mii
|
||||
attach xi at pcmcia with xi_pcmcia
|
||||
|
|
|
@ -0,0 +1,470 @@
|
|||
/* $NetBSD: if_wi_pcmcia.c,v 1.1 2001/05/06 03:26:40 ichiro Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Ichiro FUKUHARA (ichiro@ichiro.org).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* PCMCIA attachment for Lucent & Intersil WaveLAN PCMCIA card
|
||||
*/
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "opt_ns.h"
|
||||
#include "bpfilter.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/callout.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_ether.h>
|
||||
#include <net/if_media.h>
|
||||
#include <net/if_ieee80211.h>
|
||||
|
||||
#ifdef INET
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/in_var.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <netinet/if_inarp.h>
|
||||
#endif
|
||||
|
||||
#ifdef NS
|
||||
#include <netns/ns.h>
|
||||
#include <netns/ns_if.h>
|
||||
#endif
|
||||
|
||||
#if NBPFILTER > 0
|
||||
#include <net/bpf.h>
|
||||
#include <net/bpfdesc.h>
|
||||
#endif
|
||||
|
||||
#include <machine/cpu.h>
|
||||
#include <machine/bus.h>
|
||||
#include <machine/intr.h>
|
||||
|
||||
#include <dev/ic/wi_ieee.h>
|
||||
#include <dev/ic/wireg.h>
|
||||
#include <dev/ic/wivar.h>
|
||||
|
||||
#include <dev/pcmcia/pcmciareg.h>
|
||||
#include <dev/pcmcia/pcmciavar.h>
|
||||
#include <dev/pcmcia/pcmciadevs.h>
|
||||
|
||||
static int wi_pcmcia_match __P((struct device *, struct cfdata *, void *));
|
||||
static void wi_pcmcia_attach __P((struct device *, struct device *, void *));
|
||||
static int wi_pcmcia_detach __P((struct device *, int));
|
||||
static int wi_pcmcia_enable __P((struct wi_softc *));
|
||||
static void wi_pcmcia_disable __P((struct wi_softc *));
|
||||
static void wi_pcmcia_powerhook __P((int, void *));
|
||||
static void wi_pcmcia_shutdown __P((void *));
|
||||
|
||||
static const struct wi_pcmcia_product
|
||||
*wi_pcmcia_lookup __P((struct pcmcia_attach_args *pa));
|
||||
|
||||
struct wi_pcmcia_softc {
|
||||
struct wi_softc sc_wi;
|
||||
|
||||
/* PCMCIA-specific */
|
||||
struct pcmcia_io_handle sc_pcioh; /* PCMCIA i/o space info */
|
||||
int sc_io_window; /* our i/o window */
|
||||
struct pcmcia_function *sc_pf; /* PCMCIA function */
|
||||
void *sc_powerhook; /* power hook descriptor */
|
||||
void *sc_sdhook; /* shutdown hook */
|
||||
|
||||
};
|
||||
|
||||
static int wi_pcmcia_find __P((struct wi_pcmcia_softc *,
|
||||
struct pcmcia_attach_args *, struct pcmcia_config_entry *));
|
||||
|
||||
struct cfattach wi_pcmcia_ca = {
|
||||
sizeof(struct wi_pcmcia_softc), wi_pcmcia_match, wi_pcmcia_attach,
|
||||
wi_pcmcia_detach, wi_activate,
|
||||
};
|
||||
|
||||
static const struct wi_pcmcia_product {
|
||||
u_int32_t pp_vendor; /* vendor ID */
|
||||
u_int32_t pp_product; /* product ID */
|
||||
const char *pp_cisinfo[4]; /* CIS information */
|
||||
const char *pp_name; /* product name */
|
||||
int pp_prism2; /* prism2 chipset */
|
||||
} wi_pcmcia_products[] = {
|
||||
{ PCMCIA_VENDOR_LUCENT,
|
||||
PCMCIA_PRODUCT_LUCENT_WAVELAN_IEEE,
|
||||
PCMCIA_CIS_LUCENT_WAVELAN_IEEE,
|
||||
PCMCIA_STR_LUCENT_WAVELAN_IEEE,
|
||||
0 },
|
||||
|
||||
{ PCMCIA_VENDOR_3COM,
|
||||
PCMCIA_PRODUCT_3COM_3CRWE737A,
|
||||
PCMCIA_CIS_3COM_3CRWE737A,
|
||||
PCMCIA_STR_3COM_3CRWE737A,
|
||||
1 },
|
||||
|
||||
{ PCMCIA_VENDOR_COREGA,
|
||||
PCMCIA_PRODUCT_COREGA_WIRELESS_LAN_PCC_11,
|
||||
PCMCIA_CIS_COREGA_WIRELESS_LAN_PCC_11,
|
||||
PCMCIA_STR_COREGA_WIRELESS_LAN_PCC_11,
|
||||
1 },
|
||||
|
||||
{ PCMCIA_VENDOR_COREGA,
|
||||
PCMCIA_PRODUCT_COREGA_WIRELESS_LAN_PCCA_11,
|
||||
PCMCIA_CIS_COREGA_WIRELESS_LAN_PCCA_11,
|
||||
PCMCIA_STR_COREGA_WIRELESS_LAN_PCCA_11,
|
||||
1 },
|
||||
|
||||
{ PCMCIA_VENDOR_INTERSIL,
|
||||
PCMCIA_PRODUCT_INTERSIL_PRISM2,
|
||||
PCMCIA_CIS_INTERSIL_PRISM2,
|
||||
PCMCIA_STR_INTERSIL_PRISM2,
|
||||
1 },
|
||||
|
||||
{ PCMCIA_VENDOR_SAMSUNG,
|
||||
PCMCIA_PRODUCT_SAMSUNG_SWL_2000N,
|
||||
PCMCIA_CIS_SAMSUNG_SWL_2000N,
|
||||
PCMCIA_STR_SAMSUNG_SWL_2000N,
|
||||
1 },
|
||||
|
||||
{ PCMCIA_VENDOR_LUCENT,
|
||||
PCMCIA_PRODUCT_LUCENT_WAVELAN_IEEE,
|
||||
PCMCIA_CIS_SMC_2632W,
|
||||
PCMCIA_STR_SMC_2632W,
|
||||
1 },
|
||||
|
||||
{ PCMCIA_VENDOR_LUCENT,
|
||||
PCMCIA_PRODUCT_LUCENT_WAVELAN_IEEE,
|
||||
PCMCIA_CIS_NANOSPEED_PRISM2,
|
||||
PCMCIA_STR_NANOSPEED_PRISM2,
|
||||
1 },
|
||||
|
||||
{ PCMCIA_VENDOR_ELSA,
|
||||
PCMCIA_PRODUCT_ELSA_XI300_IEEE,
|
||||
PCMCIA_CIS_ELSA_XI300_IEEE,
|
||||
PCMCIA_STR_ELSA_XI300_IEEE,
|
||||
1 },
|
||||
|
||||
{ PCMCIA_VENDOR_COMPAQ,
|
||||
PCMCIA_PRODUCT_COMPAQ_NC5004,
|
||||
PCMCIA_CIS_COMPAQ_NC5004,
|
||||
PCMCIA_STR_COMPAQ_NC5004,
|
||||
1 },
|
||||
|
||||
{ PCMCIA_VENDOR_CONTEC,
|
||||
PCMCIA_PRODUCT_CONTEC_FX_DS110_PCC,
|
||||
PCMCIA_CIS_CONTEC_FX_DS110_PCC,
|
||||
PCMCIA_STR_CONTEC_FX_DS110_PCC,
|
||||
1 },
|
||||
|
||||
{ PCMCIA_VENDOR_TDK,
|
||||
PCMCIA_PRODUCT_TDK_LAK_CD011WL,
|
||||
PCMCIA_CIS_TDK_LAK_CD011WL,
|
||||
PCMCIA_STR_TDK_LAK_CD011WL,
|
||||
1 },
|
||||
|
||||
{ PCMCIA_VENDOR_LUCENT,
|
||||
PCMCIA_PRODUCT_LUCENT_WAVELAN_IEEE,
|
||||
PCMCIA_CIS_NEC_CMZ_RT_WP,
|
||||
PCMCIA_STR_NEC_CMZ_RT_WP,
|
||||
1 },
|
||||
|
||||
{ PCMCIA_VENDOR_LUCENT,
|
||||
PCMCIA_PRODUCT_LUCENT_WAVELAN_IEEE,
|
||||
PCMCIA_CIS_NTT_ME_WLAN,
|
||||
PCMCIA_STR_NTT_ME_WLAN,
|
||||
1 },
|
||||
|
||||
{ PCMCIA_VENDOR_IODATA2,
|
||||
PCMCIA_PRODUCT_IODATA2_WNB11PCM,
|
||||
PCMCIA_CIS_IODATA2_WNB11PCM,
|
||||
PCMCIA_STR_IODATA2_WNB11PCM,
|
||||
1 },
|
||||
#if 0
|
||||
{ PCMCIA_VENDOR_EMTAC,
|
||||
PCMCIA_PRODUCT_EMTAC_WLAN,
|
||||
PCMCIA_CIS_EMTAC_WLAN,
|
||||
PCMCIA_STR_EMTAC_WLAN,
|
||||
1 },
|
||||
#endif
|
||||
{ 0,
|
||||
0,
|
||||
{ NULL, NULL, NULL, NULL },
|
||||
NULL,
|
||||
0 }
|
||||
};
|
||||
|
||||
static const struct wi_pcmcia_product *
|
||||
wi_pcmcia_lookup(pa)
|
||||
struct pcmcia_attach_args *pa;
|
||||
{
|
||||
const struct wi_pcmcia_product *pp;
|
||||
|
||||
/* match by CIS information */
|
||||
for (pp = wi_pcmcia_products; pp->pp_name != NULL; pp++) {
|
||||
if (pa->card->cis1_info[0] != NULL &&
|
||||
pp->pp_cisinfo[0] != NULL &&
|
||||
strcmp(pa->card->cis1_info[0], pp->pp_cisinfo[0]) == 0 &&
|
||||
pa->card->cis1_info[1] != NULL &&
|
||||
pp->pp_cisinfo[1] != NULL &&
|
||||
strcmp(pa->card->cis1_info[1], pp->pp_cisinfo[1]) == 0)
|
||||
return pp;
|
||||
}
|
||||
|
||||
/* match by vendor/product id */
|
||||
for (pp = wi_pcmcia_products; pp->pp_name != NULL; pp++) {
|
||||
if (pa->manufacturer != PCMCIA_VENDOR_INVALID &&
|
||||
pa->manufacturer == pp->pp_vendor &&
|
||||
pa->product != PCMCIA_PRODUCT_INVALID &&
|
||||
pa->product == pp->pp_product)
|
||||
return pp;
|
||||
}
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
wi_pcmcia_match(parent, match, aux)
|
||||
struct device *parent;
|
||||
struct cfdata *match;
|
||||
void *aux;
|
||||
{
|
||||
struct pcmcia_attach_args *pa = aux;
|
||||
|
||||
if (wi_pcmcia_lookup(pa) != NULL)
|
||||
return (1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
wi_pcmcia_enable(sc)
|
||||
struct wi_softc *sc;
|
||||
{
|
||||
struct wi_pcmcia_softc *psc = (struct wi_pcmcia_softc *)sc;
|
||||
struct pcmcia_function *pf = psc->sc_pf;
|
||||
|
||||
/* establish the interrupt. */
|
||||
sc->sc_ih = pcmcia_intr_establish(pf, IPL_NET, wi_intr, sc);
|
||||
if (sc->sc_ih == NULL) {
|
||||
printf("%s: couldn't establish interrupt\n",
|
||||
sc->sc_dev.dv_xname);
|
||||
return (EIO);
|
||||
}
|
||||
if (pcmcia_function_enable(pf) != 0) {
|
||||
printf("%s: couldn't enable card\n", sc->sc_dev.dv_xname);
|
||||
pcmcia_intr_disestablish(pf, sc->sc_ih);
|
||||
return (EIO);
|
||||
}
|
||||
DELAY(1000);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
wi_pcmcia_disable(sc)
|
||||
struct wi_softc *sc;
|
||||
{
|
||||
struct wi_pcmcia_softc *psc = (struct wi_pcmcia_softc *)sc;
|
||||
|
||||
pcmcia_intr_disestablish(psc->sc_pf, sc->sc_ih);
|
||||
pcmcia_function_disable(psc->sc_pf);
|
||||
}
|
||||
|
||||
static int
|
||||
wi_pcmcia_find(psc, pa, cfe)
|
||||
struct wi_pcmcia_softc *psc;
|
||||
struct pcmcia_attach_args *pa;
|
||||
struct pcmcia_config_entry *cfe;
|
||||
{
|
||||
struct wi_softc *sc = &psc->sc_wi;
|
||||
|
||||
/* Allocate/map I/O space. */
|
||||
if (pcmcia_io_alloc(psc->sc_pf, cfe->iospace[0].start,
|
||||
cfe->iospace[0].length, WI_IOSIZE,
|
||||
&psc->sc_pcioh) != 0) {
|
||||
printf("%s: can't allocate i/o space\n",
|
||||
sc->sc_dev.dv_xname);
|
||||
goto fail1;
|
||||
}
|
||||
printf("%s:", sc->sc_dev.dv_xname);
|
||||
if (pcmcia_io_map(psc->sc_pf, PCMCIA_WIDTH_AUTO, 0,
|
||||
psc->sc_pcioh.size, &psc->sc_pcioh,
|
||||
&psc->sc_io_window) != 0) {
|
||||
printf(" can't map i/o space\n");
|
||||
goto fail2;
|
||||
}
|
||||
/* Enable the card */
|
||||
pcmcia_function_init(psc->sc_pf, cfe);
|
||||
if (pcmcia_function_enable(psc->sc_pf)) {
|
||||
printf("%s: function enable failed\n", sc->sc_dev.dv_xname);
|
||||
goto fail3;
|
||||
}
|
||||
|
||||
sc->sc_iot = psc->sc_pcioh.iot;
|
||||
sc->sc_ioh = psc->sc_pcioh.ioh;
|
||||
|
||||
DELAY(1000);
|
||||
return(0);
|
||||
|
||||
fail3:
|
||||
pcmcia_io_unmap(psc->sc_pf, psc->sc_io_window);
|
||||
fail2:
|
||||
pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh);
|
||||
fail1:
|
||||
psc->sc_io_window = -1;
|
||||
return(1);
|
||||
}
|
||||
|
||||
static void
|
||||
wi_pcmcia_attach(parent, self, aux)
|
||||
struct device *parent, *self;
|
||||
void *aux;
|
||||
{
|
||||
struct wi_pcmcia_softc *psc = (void *)self;
|
||||
struct wi_softc *sc = &psc->sc_wi;
|
||||
const struct wi_pcmcia_product *pp;
|
||||
struct pcmcia_attach_args *pa = aux;
|
||||
struct pcmcia_config_entry *cfe;
|
||||
char devinfo[256];
|
||||
|
||||
/* Print out what we are. */
|
||||
pcmcia_devinfo(&pa->pf->sc->card, 0, devinfo, sizeof(devinfo));
|
||||
printf(": %s\n", devinfo);
|
||||
|
||||
psc->sc_pf = pa->pf;
|
||||
|
||||
for (cfe = SIMPLEQ_FIRST(&pa->pf->cfe_head); cfe != NULL;
|
||||
cfe = SIMPLEQ_NEXT(cfe, cfe_list)) {
|
||||
if (cfe->iftype != PCMCIA_IFTYPE_IO)
|
||||
continue;
|
||||
if (cfe->iospace[0].length < WI_IOSIZE)
|
||||
continue;
|
||||
if (wi_pcmcia_find(psc, pa, cfe) == 0)
|
||||
break;
|
||||
}
|
||||
if (cfe == NULL) {
|
||||
printf(": no suitable CIS info found\n");
|
||||
goto no_config_entry;
|
||||
}
|
||||
|
||||
pp = wi_pcmcia_lookup(pa);
|
||||
if (pp == NULL)
|
||||
panic("wi_pcmcia_attach: impossible");
|
||||
|
||||
sc->sc_prism2 = pp->pp_prism2; /* XXX prism2 */
|
||||
sc->sc_enabled = 1;
|
||||
sc->sc_enable = wi_pcmcia_enable;
|
||||
sc->sc_disable = wi_pcmcia_disable;
|
||||
|
||||
/* establish the interrupt. */
|
||||
sc->sc_ih = pcmcia_intr_establish(psc->sc_pf, IPL_NET, wi_intr, sc);
|
||||
if (sc->sc_ih == NULL) {
|
||||
printf("%s: couldn't establish interrupt\n",
|
||||
sc->sc_dev.dv_xname);
|
||||
goto no_interrupt;
|
||||
}
|
||||
|
||||
sc->sc_ifp = &sc->sc_ethercom.ec_if;
|
||||
if (wi_attach(sc) != 0) {
|
||||
printf("%s: failed to attach controller\n",
|
||||
sc->sc_dev.dv_xname);
|
||||
goto attach_failed;
|
||||
}
|
||||
|
||||
psc->sc_sdhook = shutdownhook_establish(wi_pcmcia_shutdown, psc);
|
||||
psc->sc_powerhook = powerhook_establish(wi_pcmcia_powerhook, psc);
|
||||
|
||||
/* disable the card */
|
||||
sc->sc_enabled = 0;
|
||||
wi_pcmcia_disable(sc);
|
||||
return;
|
||||
|
||||
attach_failed:
|
||||
pcmcia_intr_disestablish(psc->sc_pf, sc->sc_ih);
|
||||
no_interrupt:
|
||||
pcmcia_io_unmap(psc->sc_pf, psc->sc_io_window);
|
||||
pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh);
|
||||
no_config_entry:
|
||||
psc->sc_io_window = -1;
|
||||
}
|
||||
|
||||
static int
|
||||
wi_pcmcia_detach(self, flags)
|
||||
struct device *self;
|
||||
int flags;
|
||||
{
|
||||
struct wi_pcmcia_softc *psc = (struct wi_pcmcia_softc *)self;
|
||||
int error;
|
||||
|
||||
if (psc->sc_io_window == -1)
|
||||
/* Nothing to detach. */
|
||||
return (0);
|
||||
|
||||
if (psc->sc_powerhook != NULL)
|
||||
powerhook_disestablish(psc->sc_powerhook);
|
||||
if (psc->sc_sdhook != NULL)
|
||||
shutdownhook_disestablish(psc->sc_sdhook);
|
||||
|
||||
error = wi_detach(&psc->sc_wi);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
/* Unmap our i/o window. */
|
||||
pcmcia_io_unmap(psc->sc_pf, psc->sc_io_window);
|
||||
|
||||
/* Free our i/o space. */
|
||||
pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
wi_pcmcia_powerhook(why, arg)
|
||||
int why;
|
||||
void *arg;
|
||||
{
|
||||
struct wi_pcmcia_softc *psc = arg;
|
||||
struct wi_softc *sc = &psc->sc_wi;
|
||||
|
||||
wi_power(sc, why);
|
||||
}
|
||||
|
||||
static void
|
||||
wi_pcmcia_shutdown(arg)
|
||||
void *arg;
|
||||
{
|
||||
struct wi_pcmcia_softc *psc = arg;
|
||||
struct wi_softc *sc = &psc->sc_wi;
|
||||
|
||||
wi_shutdown(sc);
|
||||
}
|
Loading…
Reference in New Issue