if_an_isa.c revision 55992
1310419Sdelphij/* 2275970Scy * Copyright (c) 1997, 1998, 1999 3275970Scy * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. 4275970Scy * 5275970Scy * Redistribution and use in source and binary forms, with or without 6310419Sdelphij * modification, are permitted provided that the following conditions 7275970Scy * are met: 8275970Scy * 1. Redistributions of source code must retain the above copyright 9275970Scy * notice, this list of conditions and the following disclaimer. 10275970Scy * 2. Redistributions in binary form must reproduce the above copyright 11275970Scy * notice, this list of conditions and the following disclaimer in the 12275970Scy * documentation and/or other materials provided with the distribution. 13275970Scy * 3. All advertising materials mentioning features or use of this software 14275970Scy * must display the following acknowledgement: 15275970Scy * This product includes software developed by Bill Paul. 16275970Scy * 4. Neither the name of the author nor the names of any co-contributors 17275970Scy * may be used to endorse or promote products derived from this software 18275970Scy * without specific prior written permission. 19275970Scy * 20275970Scy * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND 21275970Scy * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22275970Scy * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23275970Scy * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD 24275970Scy * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25275970Scy * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26275970Scy * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27275970Scy * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28275970Scy * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29275970Scy * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30275970Scy * THE POSSIBILITY OF SUCH DAMAGE. 31275970Scy * 32275970Scy * $FreeBSD: head/sys/dev/an/if_an_isa.c 55992 2000-01-14 20:41:03Z wpaul $ 33275970Scy */ 34275970Scy 35275970Scy/* 36275970Scy * Aironet 4500/4800 802.11 PCMCIA/ISA/PCI driver for FreeBSD. 37275970Scy * 38275970Scy * Written by Bill Paul <wpaul@ctr.columbia.edu> 39275970Scy * Electrical Engineering Department 40275970Scy * Columbia University, New York City 41275970Scy */ 42275970Scy 43275970Scy#include "opt_inet.h" 44275970Scy#ifdef INET 45275970Scy#define ANCACHE 46275970Scy#endif 47294904Sdelphij 48275970Scy#include <sys/param.h> 49275970Scy#include <sys/systm.h> 50275970Scy#include <sys/sockio.h> 51275970Scy#include <sys/mbuf.h> 52275970Scy#include <sys/malloc.h> 53275970Scy#include <sys/kernel.h> 54275970Scy#include <sys/socket.h> 55275970Scy 56294904Sdelphij#include <sys/module.h> 57294904Sdelphij#include <sys/bus.h> 58294904Sdelphij#include <machine/bus.h> 59294904Sdelphij#include <sys/rman.h> 60294904Sdelphij#include <machine/resource.h> 61294904Sdelphij 62294904Sdelphij#include <net/if.h> 63294904Sdelphij#include <net/if_arp.h> 64294904Sdelphij#include <net/ethernet.h> 65275970Scy#include <net/if_dl.h> 66275970Scy#include <net/if_types.h> 67275970Scy 68275970Scy#include <isa/isavar.h> 69275970Scy#include <isa/pnpvar.h> 70275970Scy 71275970Scy#include <dev/an/if_aironet_ieee.h> 72275970Scy#include <dev/an/if_anreg.h> 73275970Scy 74275970Scystatic struct isa_pnp_id an_ids[] = { 75275970Scy { 0x0100ec06, "Aironet ISA4500/ISA4800" }, 76275970Scy { 0, NULL } 77275970Scy}; 78275970Scy 79275970Scystatic int an_probe_isa __P((device_t)); 80275970Scystatic int an_attach_isa __P((device_t)); 81275970Scystatic int an_detach_isa __P((device_t)); 82275970Scy 83275970Scystatic int an_probe_isa(dev) 84275970Scy device_t dev; 85275970Scy{ 86275970Scy int error = 0; 87275970Scy 88275970Scy error = ISA_PNP_PROBE(device_get_parent(dev), dev, an_ids); 89275970Scy if (error == ENXIO) 90275970Scy return(error); 91275970Scy 92275970Scy error = an_probe(dev); 93275970Scy an_release_resources(dev); 94275970Scy if (error == 0) 95275970Scy return (ENXIO); 96275970Scy 97275970Scy error = an_alloc_irq(dev, 0, 0); 98275970Scy an_release_resources(dev); 99275970Scy if (!error) 100275970Scy device_set_desc(dev, "Aironet ISA4500/ISA4800"); 101275970Scy return (error); 102275970Scy} 103275970Scy 104275970Scystatic int 105275970Scyan_attach_isa(dev) 106275970Scy device_t dev; 107275970Scy{ 108275970Scy struct an_softc *sc = device_get_softc(dev); 109275970Scy int flags = device_get_flags(dev); 110275970Scy int error; 111275970Scy 112275970Scy an_alloc_port(dev, sc->port_rid, 1); 113275970Scy an_alloc_irq(dev, sc->irq_rid, 0); 114275970Scy 115275970Scy error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET, 116275970Scy an_intr, sc, &sc->irq_handle); 117275970Scy if (error) { 118275970Scy an_release_resources(dev); 119275970Scy return (error); 120275970Scy } 121275970Scy 122275970Scy sc->an_bhandle = rman_get_bushandle(sc->port_res); 123275970Scy sc->an_btag = rman_get_bustag(sc->port_res); 124275970Scy 125275970Scy return an_attach(sc, device_get_unit(dev), flags); 126275970Scy} 127275970Scy 128275970Scystatic int 129275970Scyan_detach_isa(device_t dev) 130275970Scy{ 131275970Scy struct an_softc *sc = device_get_softc(dev); 132275970Scy struct ifnet *ifp = &sc->arpcom.ac_if; 133275970Scy 134275970Scy an_stop(sc); 135275970Scy if_detach(ifp); 136275970Scy bus_teardown_intr(dev, sc->irq_res, sc->irq_handle); 137275970Scy an_release_resources(dev); 138275970Scy 139275970Scy return (0); 140275970Scy} 141275970Scy 142275970Scystatic device_method_t an_isa_methods[] = { 143275970Scy /* Device interface */ 144275970Scy DEVMETHOD(device_probe, an_probe_isa), 145275970Scy DEVMETHOD(device_attach, an_attach_isa), 146275970Scy DEVMETHOD(device_detach, an_detach_isa), 147275970Scy DEVMETHOD(device_shutdown, an_shutdown), 148275970Scy { 0, 0 } 149275970Scy}; 150275970Scy 151275970Scystatic driver_t an_isa_driver = { 152275970Scy "an", 153275970Scy an_isa_methods, 154275970Scy sizeof(struct an_softc) 155275970Scy}; 156280849Scy 157275970Scystatic devclass_t an_isa_devclass; 158294904Sdelphij 159275970ScyDRIVER_MODULE(if_an, isa, an_isa_driver, an_isa_devclass, 0, 0); 160275970Scy