if_ed_isa.c revision 53450
1193326Sed/* 2193326Sed * Copyright (c) 1995, David Greenman 3193326Sed * All rights reserved. 4193326Sed * 5193326Sed * Redistribution and use in source and binary forms, with or without 6193326Sed * modification, are permitted provided that the following conditions 7193326Sed * are met: 8193326Sed * 1. Redistributions of source code must retain the above copyright 9193326Sed * notice unmodified, this list of conditions, and the following 10193326Sed * disclaimer. 11193326Sed * 2. Redistributions in binary form must reproduce the above copyright 12193326Sed * notice, this list of conditions and the following disclaimer in the 13193326Sed * documentation and/or other materials provided with the distribution. 14212904Sdim * 15193326Sed * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16249423Sdim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17234353Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18193326Sed * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19239462Sdim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20199990Srdivacky * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21198092Srdivacky * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22249423Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23193326Sed * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24207619Srdivacky * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25199990Srdivacky * SUCH DAMAGE. 26249423Sdim * 27249423Sdim * $FreeBSD: head/sys/dev/ed/if_ed_isa.c 53450 1999-11-20 09:28:01Z mdodd $ 28249423Sdim */ 29249423Sdim 30219077Sdim#include <sys/param.h> 31198092Srdivacky#include <sys/systm.h> 32239462Sdim#include <sys/socket.h> 33239462Sdim#include <sys/kernel.h> 34198092Srdivacky 35193326Sed#include <sys/module.h> 36212904Sdim#include <sys/bus.h> 37193326Sed#include <machine/bus.h> 38249423Sdim 39249423Sdim#include <net/ethernet.h> 40218893Sdim#include <net/if.h> 41218893Sdim#include <net/if_arp.h> 42249423Sdim#include <net/if_mib.h> 43249423Sdim 44249423Sdim#include <isa/isavar.h> 45249423Sdim#include <isa/pnpvar.h> 46249423Sdim 47193326Sed#include <dev/ed/if_edvar.h> 48193326Sed 49193326Sedstatic int ed_isa_probe __P((device_t)); 50193326Sedstatic int ed_isa_attach __P((device_t)); 51193326Sed 52249423Sdimstatic struct isa_pnp_id ed_ids[] = { 53193326Sed { 0x1684a34d, NULL }, /* SMC8416 */ 54193326Sed { 0xd680d041, NULL }, /* PNP80d6 */ 55193326Sed { 0x1980635e, NULL }, /* WSC8019 */ 56249423Sdim { 0x0131d805, NULL }, /* ANX3101 */ 57249423Sdim { 0x01200507, NULL }, /* AXE2001 */ 58249423Sdim { 0x19808c4a, NULL }, /* RTL8019 */ 59249423Sdim { 0x0090252a, NULL }, /* JQE9000 */ 60249423Sdim { 0x0020832e, NULL }, /* KTC2000 */ 61221345Sdim { 0, NULL } 62226633Sdim}; 63226633Sdim 64193326Sedstatic int 65193326Seded_isa_probe(dev) 66218893Sdim device_t dev; 67218893Sdim{ 68263508Sdim struct ed_softc *sc = device_get_softc(dev); 69198092Srdivacky int error = 0; 70193326Sed 71193326Sed bzero(sc, sizeof(struct ed_softc)); 72198092Srdivacky 73193326Sed /* Check isapnp ids */ 74193326Sed error = ISA_PNP_PROBE(device_get_parent(dev), dev, ed_ids); 75193326Sed 76199990Srdivacky /* If the card had a PnP ID that didn't match any we know about */ 77263508Sdim if (error == ENXIO) { 78218893Sdim goto end; 79251662Sdim } 80251662Sdim 81251662Sdim /* If we had some other problem. */ 82251662Sdim if (!(error == 0 || error == ENOENT)) { 83224145Sdim goto end; 84251662Sdim } 85251662Sdim 86251662Sdim /* Heuristic probes */ 87251662Sdim 88251662Sdim error = ed_probe_WD80x3(dev); 89251662Sdim if (error == 0) 90251662Sdim goto end; 91251662Sdim ed_release_resources(dev); 92251662Sdim 93251662Sdim error = ed_probe_3Com(dev); 94251662Sdim if (error == 0) 95251662Sdim goto end; 96224145Sdim ed_release_resources(dev); 97224145Sdim 98224145Sdim error = ed_probe_Novell(dev); 99224145Sdim if (error == 0) 100224145Sdim goto end; 101224145Sdim ed_release_resources(dev); 102224145Sdim 103234353Sdim error = ed_probe_HP_pclanp(dev); 104224145Sdim if (error == 0) 105224145Sdim goto end; 106224145Sdim ed_release_resources(dev); 107224145Sdim 108224145Sdimend: 109224145Sdim if (error == 0) 110224145Sdim error = ed_alloc_irq(dev, 0, 0); 111224145Sdim 112224145Sdim ed_release_resources(dev); 113224145Sdim return (error); 114224145Sdim} 115199990Srdivacky 116199990Srdivackystatic int 117226633Sdimed_isa_attach(dev) 118226633Sdim device_t dev; 119226633Sdim{ 120226633Sdim struct ed_softc *sc = device_get_softc(dev); 121226633Sdim int flags = device_get_flags(dev); 122226633Sdim int error; 123226633Sdim 124226633Sdim if (sc->port_used > 0) 125226633Sdim ed_alloc_port(dev, sc->port_rid, sc->port_used); 126226633Sdim if (sc->mem_used) 127226633Sdim ed_alloc_memory(dev, sc->mem_rid, sc->mem_used); 128226633Sdim ed_alloc_irq(dev, sc->irq_rid, 0); 129226633Sdim 130226633Sdim error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET, 131226633Sdim edintr, sc, &sc->irq_handle); 132226633Sdim if (error) { 133226633Sdim ed_release_resources(dev); 134226633Sdim return (error); 135226633Sdim } 136226633Sdim 137226633Sdim return ed_attach(sc, device_get_unit(dev), flags); 138226633Sdim} 139226633Sdim 140226633Sdimstatic device_method_t ed_isa_methods[] = { 141226633Sdim /* Device interface */ 142226633Sdim DEVMETHOD(device_probe, ed_isa_probe), 143226633Sdim DEVMETHOD(device_attach, ed_isa_attach), 144226633Sdim 145226633Sdim { 0, 0 } 146226633Sdim}; 147249423Sdim 148226633Sdimstatic driver_t ed_isa_driver = { 149226633Sdim "ed", 150226633Sdim ed_isa_methods, 151226633Sdim sizeof(struct ed_softc) 152226633Sdim}; 153226633Sdim 154226633Sdimstatic devclass_t ed_isa_devclass; 155226633Sdim 156226633SdimDRIVER_MODULE(ed, isa, ed_isa_driver, ed_isa_devclass, 0, 0); 157226633Sdim