4b312a286f
From the README: Any IEEE 802.11 cards use AMD Am79C930 and Harris (Intersil) Chipset with PCnetMobile firmware by AMD. BayStack 650 1Mbps Frequency Hopping PCCARD adapter BayStack 660 2Mbps Direct Sequence PCCARD adapter Icom SL-200 2Mbps Direct Sequence PCCARD adapter Melco WLI-PCM 2Mbps Direct Sequence PCCARD adapter NEL SSMagic 2Mbps Direct Sequence PCCARD adapter Netwave AirSurfer Plus 1Mbps Frequency Hopping PCCARD adapter Netwave AirSurfer Pro 2Mbps Direct Sequence PCCARD adapter Known Problems: WEP is not supported. Does not create IBSS itself. Cannot configure the following on FreeBSD: selection of infrastructure/adhoc mode ESSID ... Submitted by: Atsushi Onoe <onoe@sm.sony.co.jp>
246 lines
6.7 KiB
C
246 lines
6.7 KiB
C
/*
|
|
* Copyright (c) 2000 Atsushi Onoe <onoe@sm.sony.co.jp>
|
|
* All rights reserved.
|
|
*
|
|
* 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.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
|
*
|
|
* $FreeBSD$
|
|
*/
|
|
|
|
#include <sys/param.h>
|
|
#include <sys/systm.h>
|
|
#include <sys/kernel.h>
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/module.h>
|
|
#include <sys/bus.h>
|
|
|
|
#include <machine/bus.h>
|
|
#include <machine/resource.h>
|
|
#include <sys/rman.h>
|
|
|
|
#include <net/if.h>
|
|
#include <net/if_arp.h>
|
|
#include <net/if_media.h>
|
|
#include <net/ethernet.h>
|
|
#include <net/if_ieee80211.h>
|
|
|
|
#include <machine/clock.h>
|
|
|
|
#include <dev/awi/am79c930reg.h>
|
|
#include <dev/awi/am79c930var.h>
|
|
#include <dev/awi/awireg.h>
|
|
#include <dev/awi/awivar.h>
|
|
|
|
struct awi_pccard_softc {
|
|
struct awi_softc sc_awi;
|
|
|
|
u_int8_t sc_version[AWI_BANNER_LEN];
|
|
int sc_intr_mask;
|
|
void *sc_intrhand;
|
|
struct resource *sc_irq_res;
|
|
int sc_irq_rid;
|
|
struct resource *sc_port_res;
|
|
int sc_port_rid;
|
|
struct resource *sc_mem_res;
|
|
int sc_mem_rid;
|
|
};
|
|
|
|
/*
|
|
* Initialize the device - called from Slot manager.
|
|
*/
|
|
static int
|
|
awi_pccard_probe(device_t dev)
|
|
{
|
|
struct awi_pccard_softc *psc = device_get_softc(dev);
|
|
struct awi_softc *sc = &psc->sc_awi;
|
|
int error = 0;
|
|
|
|
psc->sc_port_rid = 0;
|
|
psc->sc_port_res = bus_alloc_resource(dev, SYS_RES_IOPORT,
|
|
&psc->sc_port_rid, 0, ~0, 16, RF_ACTIVE);
|
|
if (!psc->sc_port_res)
|
|
return ENOMEM;
|
|
|
|
sc->sc_chip.sc_iot = I386_BUS_SPACE_IO;
|
|
sc->sc_chip.sc_ioh =
|
|
(bus_space_handle_t)rman_get_start(psc->sc_port_res);
|
|
am79c930_chip_init(&sc->sc_chip, 0);
|
|
DELAY(1000);
|
|
|
|
awi_read_bytes(sc, AWI_BANNER, psc->sc_version, AWI_BANNER_LEN);
|
|
if (memcmp(psc->sc_version, "PCnetMobile:", 12) != 0) {
|
|
device_printf(dev, "awi_pccard_probe: bad banner: %12D\n",
|
|
psc->sc_version, " ");
|
|
error = ENXIO;
|
|
} else
|
|
device_set_desc(dev, psc->sc_version);
|
|
bus_release_resource(dev, SYS_RES_IOPORT, psc->sc_port_rid,
|
|
psc->sc_port_res);
|
|
|
|
return error;
|
|
}
|
|
|
|
static int
|
|
awi_pccard_attach(device_t dev)
|
|
{
|
|
struct awi_pccard_softc *psc = device_get_softc(dev);
|
|
struct awi_softc *sc = &psc->sc_awi;
|
|
struct ifnet *ifp = &sc->sc_ec.ac_if;
|
|
int error = 0;
|
|
|
|
psc->sc_port_res = 0;
|
|
psc->sc_irq_res = 0;
|
|
psc->sc_mem_res = 0;
|
|
psc->sc_intrhand = 0;
|
|
|
|
ifp->if_name = device_get_name(dev);
|
|
ifp->if_unit = device_get_unit(dev);
|
|
if (ifp->if_name == NULL) {
|
|
printf("awi%d: awi_pccard_attach: cannot get device name\n",
|
|
device_get_unit(dev));
|
|
goto fail;
|
|
}
|
|
snprintf(sc->sc_dev.dv_xname, sizeof(sc->sc_dev.dv_xname),
|
|
"%s%d", ifp->if_name, ifp->if_unit);
|
|
|
|
psc->sc_port_rid = 0;
|
|
psc->sc_port_res = bus_alloc_resource(dev, SYS_RES_IOPORT,
|
|
&psc->sc_port_rid, 0, ~0, 16, RF_ACTIVE);
|
|
if (!psc->sc_port_res) {
|
|
device_printf(dev, "awi_pccard_attach: port alloc failed\n");
|
|
goto fail;
|
|
}
|
|
sc->sc_chip.sc_iot = I386_BUS_SPACE_IO;
|
|
sc->sc_chip.sc_ioh =
|
|
(bus_space_handle_t)rman_get_start(psc->sc_port_res);
|
|
|
|
psc->sc_irq_rid = 0;
|
|
psc->sc_irq_res = bus_alloc_resource(dev, SYS_RES_IRQ,
|
|
&psc->sc_irq_rid, 0, ~0, 1, RF_ACTIVE);
|
|
if (!psc->sc_irq_res) {
|
|
device_printf(dev, "awi_pccard_attach: irq alloc failed\n");
|
|
goto fail;
|
|
}
|
|
|
|
psc->sc_mem_rid = 0;
|
|
psc->sc_mem_res = bus_alloc_resource(dev, SYS_RES_MEMORY,
|
|
&psc->sc_mem_rid, 0, ~0, 0x8000, RF_ACTIVE);
|
|
if (psc->sc_mem_res) {
|
|
sc->sc_chip.sc_memt = I386_BUS_SPACE_MEM;
|
|
sc->sc_chip.sc_memh =
|
|
(bus_space_handle_t)rman_get_virtual(psc->sc_mem_res);
|
|
am79c930_chip_init(&sc->sc_chip, 1);
|
|
} else
|
|
am79c930_chip_init(&sc->sc_chip, 0);
|
|
|
|
error = bus_setup_intr(dev, psc->sc_irq_res, INTR_TYPE_NET,
|
|
(void (*)(void *))awi_intr, sc, &psc->sc_intrhand);
|
|
if (error) {
|
|
device_printf(dev, "awi_pccard_attach: intr setup failed\n");
|
|
goto fail;
|
|
}
|
|
|
|
sc->sc_cansleep = 1;
|
|
sc->sc_enabled = 1;
|
|
sc->sc_ifp = &sc->sc_ec.ac_if;
|
|
|
|
error = awi_attach(sc);
|
|
sc->sc_enabled = 0; /*XXX*/
|
|
if (error == 0)
|
|
return 0;
|
|
device_printf(dev, "awi_pccard_attach: awi_attach failed\n");
|
|
|
|
fail:
|
|
if (psc->sc_intrhand) {
|
|
bus_teardown_intr(dev, psc->sc_irq_res, psc->sc_intrhand);
|
|
psc->sc_intrhand = 0;
|
|
}
|
|
if (psc->sc_port_res) {
|
|
bus_release_resource(dev, SYS_RES_IOPORT, psc->sc_port_rid,
|
|
psc->sc_port_res);
|
|
psc->sc_port_res = 0;
|
|
}
|
|
if (psc->sc_irq_res) {
|
|
bus_release_resource(dev, SYS_RES_IRQ, psc->sc_irq_rid,
|
|
psc->sc_irq_res);
|
|
psc->sc_irq_res = 0;
|
|
}
|
|
if (psc->sc_mem_res) {
|
|
bus_release_resource(dev, SYS_RES_MEMORY, psc->sc_mem_rid,
|
|
psc->sc_mem_res);
|
|
psc->sc_mem_res = 0;
|
|
}
|
|
if (error == 0)
|
|
error = ENXIO;
|
|
return error;
|
|
}
|
|
|
|
static int
|
|
awi_pccard_detach(device_t dev)
|
|
{
|
|
struct awi_pccard_softc *psc = device_get_softc(dev);
|
|
struct awi_softc *sc = &psc->sc_awi;
|
|
struct ifnet *ifp = &sc->sc_ec.ac_if;
|
|
|
|
if_detach(ifp);
|
|
ifp->if_flags &= ~IFF_RUNNING;
|
|
if (psc->sc_intrhand) {
|
|
bus_teardown_intr(dev, psc->sc_irq_res, psc->sc_intrhand);
|
|
psc->sc_intrhand = 0;
|
|
}
|
|
if (psc->sc_port_res) {
|
|
bus_release_resource(dev, SYS_RES_IOPORT, psc->sc_port_rid,
|
|
psc->sc_port_res);
|
|
psc->sc_port_res = 0;
|
|
}
|
|
if (psc->sc_irq_res) {
|
|
bus_release_resource(dev, SYS_RES_IRQ, psc->sc_irq_rid,
|
|
psc->sc_irq_res);
|
|
psc->sc_irq_res = 0;
|
|
}
|
|
if (psc->sc_mem_res) {
|
|
bus_release_resource(dev, SYS_RES_MEMORY, psc->sc_mem_rid,
|
|
psc->sc_mem_res);
|
|
psc->sc_mem_res = 0;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static device_method_t awi_pccard_methods[] = {
|
|
/* Device interface */
|
|
DEVMETHOD(device_probe, awi_pccard_probe),
|
|
DEVMETHOD(device_attach, awi_pccard_attach),
|
|
DEVMETHOD(device_detach, awi_pccard_detach),
|
|
|
|
{ 0, 0 }
|
|
};
|
|
|
|
static driver_t awi_pccard_driver = {
|
|
"awi",
|
|
awi_pccard_methods,
|
|
sizeof(struct awi_pccard_softc),
|
|
};
|
|
|
|
extern devclass_t awi_devclass;
|
|
|
|
DRIVER_MODULE(awi, pccard, awi_pccard_driver, awi_devclass, 0, 0);
|