if_ed_isa.c revision 53450
1254721Semaste/* 2254721Semaste * Copyright (c) 1995, David Greenman 3254721Semaste * All rights reserved. 4254721Semaste * 5254721Semaste * Redistribution and use in source and binary forms, with or without 6254721Semaste * modification, are permitted provided that the following conditions 7254721Semaste * are met: 8254721Semaste * 1. Redistributions of source code must retain the above copyright 9254721Semaste * notice unmodified, this list of conditions, and the following 10254721Semaste * disclaimer. 11254721Semaste * 2. Redistributions in binary form must reproduce the above copyright 12254721Semaste * notice, this list of conditions and the following disclaimer in the 13254721Semaste * documentation and/or other materials provided with the distribution. 14254721Semaste * 15254721Semaste * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16254721Semaste * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17254721Semaste * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18254721Semaste * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19254721Semaste * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20254721Semaste * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21254721Semaste * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22254721Semaste * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23254721Semaste * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24254721Semaste * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25254721Semaste * SUCH DAMAGE. 26254721Semaste * 27254721Semaste * $FreeBSD: head/sys/dev/ed/if_ed_isa.c 53450 1999-11-20 09:28:01Z mdodd $ 28254721Semaste */ 29254721Semaste 30254721Semaste#include <sys/param.h> 31254721Semaste#include <sys/systm.h> 32254721Semaste#include <sys/socket.h> 33254721Semaste#include <sys/kernel.h> 34254721Semaste 35254721Semaste#include <sys/module.h> 36254721Semaste#include <sys/bus.h> 37254721Semaste#include <machine/bus.h> 38254721Semaste 39254721Semaste#include <net/ethernet.h> 40254721Semaste#include <net/if.h> 41254721Semaste#include <net/if_arp.h> 42254721Semaste#include <net/if_mib.h> 43254721Semaste 44254721Semaste#include <isa/isavar.h> 45254721Semaste#include <isa/pnpvar.h> 46254721Semaste 47254721Semaste#include <dev/ed/if_edvar.h> 48254721Semaste 49254721Semastestatic int ed_isa_probe __P((device_t)); 50254721Semastestatic int ed_isa_attach __P((device_t)); 51254721Semaste 52254721Semastestatic struct isa_pnp_id ed_ids[] = { 53254721Semaste { 0x1684a34d, NULL }, /* SMC8416 */ 54254721Semaste { 0xd680d041, NULL }, /* PNP80d6 */ 55254721Semaste { 0x1980635e, NULL }, /* WSC8019 */ 56254721Semaste { 0x0131d805, NULL }, /* ANX3101 */ 57254721Semaste { 0x01200507, NULL }, /* AXE2001 */ 58254721Semaste { 0x19808c4a, NULL }, /* RTL8019 */ 59254721Semaste { 0x0090252a, NULL }, /* JQE9000 */ 60254721Semaste { 0x0020832e, NULL }, /* KTC2000 */ 61254721Semaste { 0, NULL } 62254721Semaste}; 63254721Semaste 64254721Semastestatic int 65254721Semasteed_isa_probe(dev) 66254721Semaste device_t dev; 67254721Semaste{ 68254721Semaste struct ed_softc *sc = device_get_softc(dev); 69254721Semaste int error = 0; 70254721Semaste 71254721Semaste bzero(sc, sizeof(struct ed_softc)); 72254721Semaste 73254721Semaste /* Check isapnp ids */ 74254721Semaste error = ISA_PNP_PROBE(device_get_parent(dev), dev, ed_ids); 75254721Semaste 76254721Semaste /* If the card had a PnP ID that didn't match any we know about */ 77254721Semaste if (error == ENXIO) { 78254721Semaste goto end; 79254721Semaste } 80254721Semaste 81254721Semaste /* If we had some other problem. */ 82254721Semaste if (!(error == 0 || error == ENOENT)) { 83254721Semaste goto end; 84254721Semaste } 85254721Semaste 86254721Semaste /* Heuristic probes */ 87254721Semaste 88254721Semaste error = ed_probe_WD80x3(dev); 89254721Semaste if (error == 0) 90254721Semaste goto end; 91254721Semaste ed_release_resources(dev); 92254721Semaste 93254721Semaste error = ed_probe_3Com(dev); 94254721Semaste if (error == 0) 95254721Semaste goto end; 96254721Semaste ed_release_resources(dev); 97254721Semaste 98254721Semaste error = ed_probe_Novell(dev); 99254721Semaste if (error == 0) 100254721Semaste goto end; 101254721Semaste ed_release_resources(dev); 102254721Semaste 103254721Semaste error = ed_probe_HP_pclanp(dev); 104254721Semaste if (error == 0) 105254721Semaste goto end; 106254721Semaste ed_release_resources(dev); 107254721Semaste 108254721Semasteend: 109254721Semaste if (error == 0) 110254721Semaste error = ed_alloc_irq(dev, 0, 0); 111254721Semaste 112254721Semaste ed_release_resources(dev); 113254721Semaste return (error); 114254721Semaste} 115254721Semaste 116254721Semastestatic int 117254721Semasteed_isa_attach(dev) 118254721Semaste device_t dev; 119254721Semaste{ 120254721Semaste struct ed_softc *sc = device_get_softc(dev); 121254721Semaste int flags = device_get_flags(dev); 122254721Semaste int error; 123254721Semaste 124254721Semaste if (sc->port_used > 0) 125254721Semaste ed_alloc_port(dev, sc->port_rid, sc->port_used); 126254721Semaste if (sc->mem_used) 127254721Semaste ed_alloc_memory(dev, sc->mem_rid, sc->mem_used); 128254721Semaste ed_alloc_irq(dev, sc->irq_rid, 0); 129254721Semaste 130254721Semaste error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET, 131254721Semaste edintr, sc, &sc->irq_handle); 132254721Semaste if (error) { 133254721Semaste ed_release_resources(dev); 134254721Semaste return (error); 135254721Semaste } 136254721Semaste 137254721Semaste return ed_attach(sc, device_get_unit(dev), flags); 138254721Semaste} 139254721Semaste 140254721Semastestatic device_method_t ed_isa_methods[] = { 141254721Semaste /* Device interface */ 142254721Semaste DEVMETHOD(device_probe, ed_isa_probe), 143254721Semaste DEVMETHOD(device_attach, ed_isa_attach), 144254721Semaste 145254721Semaste { 0, 0 } 146254721Semaste}; 147254721Semaste 148254721Semastestatic driver_t ed_isa_driver = { 149254721Semaste "ed", 150254721Semaste ed_isa_methods, 151254721Semaste sizeof(struct ed_softc) 152254721Semaste}; 153254721Semaste 154254721Semastestatic devclass_t ed_isa_devclass; 155254721Semaste 156254721SemasteDRIVER_MODULE(ed, isa, ed_isa_driver, ed_isa_devclass, 0, 0); 157254721Semaste