if_ed_isa.c revision 52464
1/* 2 * Copyright (c) 1995, David Greenman 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice unmodified, this list of conditions, and the following 10 * disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * 27 * $FreeBSD: head/sys/dev/ed/if_ed_isa.c 52464 1999-10-24 07:17:26Z mdodd $ 28 */ 29 30#include "card.h" 31#if NCARD == 0 32 33#include <sys/param.h> 34#include <sys/systm.h> 35#include <sys/socket.h> 36#include <sys/kernel.h> 37 38#include <sys/module.h> 39#include <sys/bus.h> 40#include <machine/bus.h> 41 42#include <net/ethernet.h> 43#include <net/if.h> 44#include <net/if_arp.h> 45#include <net/if_mib.h> 46 47#include <isa/isavar.h> 48#include <isa/pnpvar.h> 49 50#include <dev/ed/if_edvar.h> 51 52static int ed_isa_probe __P((device_t)); 53static int ed_isa_attach __P((device_t)); 54 55static struct isa_pnp_id ed_ids[] = { 56 { 0x1684a34d, NULL }, /* SMC8416 */ 57 { 0xd680d041, NULL }, /* PNP80d6 */ 58 { 0x1980635e, NULL }, /* WSC8019 */ 59 { 0x0131d805, NULL }, /* ANX3101 */ 60 { 0x01200507, NULL }, /* AXE2001 */ 61 { 0x19808c4a, NULL }, /* RTL8019 */ 62 { 0x0090252a, NULL }, /* JQE9000 */ 63 { 0x0020832e, NULL }, /* KTC2000 */ 64 { 0, NULL } 65}; 66 67static int 68ed_isa_probe(dev) 69 device_t dev; 70{ 71 struct ed_softc *sc = device_get_softc(dev); 72 int error = 0; 73 74 bzero(sc, sizeof(struct ed_softc)); 75 76 /* Check isapnp ids */ 77 error = ISA_PNP_PROBE(device_get_parent(dev), dev, ed_ids); 78 79 /* If the card had a PnP ID that didn't match any we know about */ 80 if (error == ENXIO) { 81 goto end; 82 } 83 84 /* If we had some other problem. */ 85 if (!(error == 0 || error == ENOENT)) { 86 goto end; 87 } 88 89 /* Heuristic probes */ 90 91 error = ed_probe_WD80x3(dev); 92 if (error == 0) 93 goto end; 94 ed_release_resources(dev); 95 96 error = ed_probe_3Com(dev); 97 if (error == 0) 98 goto end; 99 ed_release_resources(dev); 100 101 error = ed_probe_Novell(dev); 102 if (error == 0) 103 goto end; 104 ed_release_resources(dev); 105 106 error = ed_probe_HP_pclanp(dev); 107 if (error == 0) 108 goto end; 109 ed_release_resources(dev); 110 111end: 112 if (error == 0) 113 error = ed_alloc_irq(dev, 0, 0); 114 115 ed_release_resources(dev); 116 return (error); 117} 118 119static int 120ed_isa_attach(dev) 121 device_t dev; 122{ 123 struct ed_softc *sc = device_get_softc(dev); 124 int flags = device_get_flags(dev); 125 int error; 126 127 if (sc->port_used > 0) 128 ed_alloc_port(dev, sc->port_rid, 1); 129 if (sc->mem_used) 130 ed_alloc_memory(dev, sc->mem_rid, 1); 131 ed_alloc_irq(dev, sc->irq_rid, 0); 132 133 error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET, 134 edintr, sc, &sc->irq_handle); 135 if (error) { 136 ed_release_resources(dev); 137 return (error); 138 } 139 140 return ed_attach(sc, device_get_unit(dev), flags); 141} 142 143static device_method_t ed_isa_methods[] = { 144 /* Device interface */ 145 DEVMETHOD(device_probe, ed_isa_probe), 146 DEVMETHOD(device_attach, ed_isa_attach), 147 148 { 0, 0 } 149}; 150 151static driver_t ed_isa_driver = { 152 "ed", 153 ed_isa_methods, 154 sizeof(struct ed_softc) 155}; 156 157static devclass_t ed_isa_devclass; 158 159DRIVER_MODULE(ed, isa, ed_isa_driver, ed_isa_devclass, 0, 0); 160#endif 161