if_ed_isa.c revision 100721
1219820Sjeff/* 2219820Sjeff * Copyright (c) 1995, David Greenman 3219820Sjeff * All rights reserved. 4219820Sjeff * 5219820Sjeff * Redistribution and use in source and binary forms, with or without 6219820Sjeff * modification, are permitted provided that the following conditions 7219820Sjeff * are met: 8219820Sjeff * 1. Redistributions of source code must retain the above copyright 9219820Sjeff * notice unmodified, this list of conditions, and the following 10219820Sjeff * disclaimer. 11219820Sjeff * 2. Redistributions in binary form must reproduce the above copyright 12219820Sjeff * notice, this list of conditions and the following disclaimer in the 13219820Sjeff * documentation and/or other materials provided with the distribution. 14219820Sjeff * 15219820Sjeff * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16219820Sjeff * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17219820Sjeff * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18219820Sjeff * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19219820Sjeff * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20219820Sjeff * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21219820Sjeff * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22219820Sjeff * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23219820Sjeff * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24219820Sjeff * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25219820Sjeff * SUCH DAMAGE. 26219820Sjeff * 27219820Sjeff * $FreeBSD: head/sys/dev/ed/if_ed_isa.c 100721 2002-07-26 17:33:58Z takawata $ 28219820Sjeff */ 29219820Sjeff 30219820Sjeff#include <sys/param.h> 31219820Sjeff#include <sys/systm.h> 32219820Sjeff#include <sys/socket.h> 33219820Sjeff#include <sys/kernel.h> 34219820Sjeff 35219820Sjeff#include <sys/module.h> 36219820Sjeff#include <sys/bus.h> 37219820Sjeff#include <machine/bus.h> 38219820Sjeff 39219820Sjeff#include <net/if.h> 40219820Sjeff#include <net/if_arp.h> 41219820Sjeff#include <net/if_mib.h> 42219820Sjeff 43219820Sjeff#include <isa/isavar.h> 44219820Sjeff 45219820Sjeff#include <dev/ed/if_edvar.h> 46219820Sjeff 47219820Sjeffstatic int ed_isa_probe (device_t); 48219820Sjeffstatic int ed_isa_attach (device_t); 49219820Sjeff 50219820Sjeffstatic struct isa_pnp_id ed_ids[] = { 51219820Sjeff { 0x1684a34d, NULL }, /* SMC8416 */ 52219820Sjeff { 0xd680d041, NULL }, /* PNP80d6 */ 53219820Sjeff { 0x1980635e, NULL }, /* WSC8019 */ 54219820Sjeff { 0x0131d805, NULL }, /* ANX3101 */ 55219820Sjeff { 0x01200507, NULL }, /* AXE2001 */ 56219820Sjeff { 0x19808c4a, NULL }, /* RTL8019 */ 57219820Sjeff { 0x0090252a, NULL }, /* JQE9000 */ 58219820Sjeff { 0x0020832e, NULL }, /* KTC2000 */ 59219820Sjeff { 0x4cf48906, NULL }, /* ATIf44c */ 60219820Sjeff { 0, NULL } 61219820Sjeff}; 62219820Sjeff 63219820Sjeffstatic int 64219820Sjeffed_isa_probe(dev) 65219820Sjeff device_t dev; 66219820Sjeff{ 67219820Sjeff struct ed_softc *sc = device_get_softc(dev); 68219820Sjeff int flags = device_get_flags(dev); 69219820Sjeff int error = 0; 70219820Sjeff 71219820Sjeff bzero(sc, sizeof(struct ed_softc)); 72219820Sjeff 73219820Sjeff /* Check isapnp ids */ 74219820Sjeff error = ISA_PNP_PROBE(device_get_parent(dev), dev, ed_ids); 75219820Sjeff 76219820Sjeff /* If the card had a PnP ID that didn't match any we know about */ 77219820Sjeff if (error == ENXIO) { 78219820Sjeff goto end; 79219820Sjeff } 80219820Sjeff 81219820Sjeff /* If we had some other problem. */ 82219820Sjeff if (!(error == 0 || error == ENOENT)) { 83219820Sjeff goto end; 84219820Sjeff } 85 86 /* Heuristic probes */ 87 88 error = ed_probe_WD80x3(dev, 0, flags); 89 if (error == 0) 90 goto end; 91 ed_release_resources(dev); 92 93 error = ed_probe_3Com(dev, 0, flags); 94 if (error == 0) 95 goto end; 96 ed_release_resources(dev); 97 98 error = ed_probe_Novell(dev, 0, flags); 99 if (error == 0) 100 goto end; 101 ed_release_resources(dev); 102 103 error = ed_probe_HP_pclanp(dev, 0, flags); 104 if (error == 0) 105 goto end; 106 ed_release_resources(dev); 107 108end: 109 if (error == 0) 110 error = ed_alloc_irq(dev, 0, 0); 111 112 ed_release_resources(dev); 113 return (error); 114} 115 116static int 117ed_isa_attach(dev) 118 device_t dev; 119{ 120 struct ed_softc *sc = device_get_softc(dev); 121 int flags = device_get_flags(dev); 122 int error; 123 124 if (sc->port_used > 0) 125 ed_alloc_port(dev, sc->port_rid, sc->port_used); 126 if (sc->mem_used) 127 ed_alloc_memory(dev, sc->mem_rid, sc->mem_used); 128 129 ed_alloc_irq(dev, sc->irq_rid, 0); 130 131 error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET, 132 edintr, sc, &sc->irq_handle); 133 if (error) { 134 ed_release_resources(dev); 135 return (error); 136 } 137 138 return ed_attach(sc, device_get_unit(dev), flags); 139} 140 141static device_method_t ed_isa_methods[] = { 142 /* Device interface */ 143 DEVMETHOD(device_probe, ed_isa_probe), 144 DEVMETHOD(device_attach, ed_isa_attach), 145 146 { 0, 0 } 147}; 148 149static driver_t ed_isa_driver = { 150 "ed", 151 ed_isa_methods, 152 sizeof(struct ed_softc) 153}; 154 155DRIVER_MODULE(if_ed, isa, ed_isa_driver, ed_devclass, 0, 0); 156