if_ed_isa.c revision 147256
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 */ 28219820Sjeff 29219820Sjeff#include <sys/cdefs.h> 30219820Sjeff__FBSDID("$FreeBSD: head/sys/dev/ed/if_ed_isa.c 147256 2005-06-10 16:49:24Z brooks $"); 31219820Sjeff 32219820Sjeff#include "opt_ed.h" 33219820Sjeff 34219820Sjeff#include <sys/param.h> 35219820Sjeff#include <sys/systm.h> 36219820Sjeff#include <sys/socket.h> 37219820Sjeff#include <sys/kernel.h> 38219820Sjeff 39219820Sjeff#include <sys/module.h> 40219820Sjeff#include <sys/bus.h> 41219820Sjeff#include <machine/bus.h> 42219820Sjeff 43219820Sjeff#include <net/ethernet.h> 44219820Sjeff#include <net/if.h> 45219820Sjeff#include <net/if_arp.h> 46219820Sjeff#include <net/if_mib.h> 47219820Sjeff 48219820Sjeff#include <isa/isavar.h> 49219820Sjeff 50219820Sjeff#include <dev/ed/if_edvar.h> 51219820Sjeff 52219820Sjeffstatic int ed_isa_probe(device_t); 53219820Sjeffstatic int ed_isa_attach(device_t); 54219820Sjeff 55219820Sjeffstatic struct isa_pnp_id ed_ids[] = { 56219820Sjeff { 0x1684a34d, NULL }, /* SMC8416 */ 57219820Sjeff { 0xd680d041, NULL }, /* PNP80d6 */ 58219820Sjeff { 0x1980635e, NULL }, /* WSC8019 */ 59219820Sjeff { 0x0131d805, NULL }, /* ANX3101 */ 60219820Sjeff { 0x01200507, NULL }, /* AXE2001 */ 61219820Sjeff { 0x19808c4a, NULL }, /* RTL8019 */ 62219820Sjeff { 0x0090252a, NULL }, /* JQE9000 */ 63219820Sjeff { 0x0020832e, NULL }, /* KTC2000 */ 64219820Sjeff { 0x4cf48906, NULL }, /* ATIf44c */ 65219820Sjeff { 0, NULL } 66219820Sjeff}; 67219820Sjeff 68219820Sjeffstatic int 69219820Sjeffed_isa_probe_Novell(device_t dev) 70219820Sjeff{ 71219820Sjeff struct ed_softc *sc = device_get_softc(dev); 72219820Sjeff int flags = device_get_flags(dev); 73219820Sjeff int err; 74219820Sjeff 75219820Sjeff err = ed_probe_Novell(dev, 0, flags); 76219820Sjeff if (err) 77219820Sjeff return err; 78219820Sjeff ed_Novell_read_mac(sc); 79219820Sjeff /* 80292107Shselasky * Final sanity check for Gateway Ethernet cards before 81219820Sjeff * believing that they really are Gateway AT. 82219820Sjeff */ 83219820Sjeff if ((ED_FLAGS_GETTYPE(flags) == ED_FLAGS_GWETHER) && 84219820Sjeff (sc->enaddr[2] == 0x86)) { 85219820Sjeff sc->type_str = "Gateway AT"; 86219820Sjeff } 87 88 return (0); 89} 90 91static int 92ed_isa_probe(device_t dev) 93{ 94 int flags = device_get_flags(dev); 95 int error = 0; 96 97 /* Check isapnp ids */ 98 error = ISA_PNP_PROBE(device_get_parent(dev), dev, ed_ids); 99 100 /* If the card had a PnP ID that didn't match any we know about */ 101 if (error == ENXIO) 102 goto end; 103 104 /* If we had some other problem. */ 105 if (!(error == 0 || error == ENOENT)) 106 goto end; 107 108 /* Heuristic probes */ 109 110 error = ed_probe_WD80x3(dev, 0, flags); 111 if (error == 0) 112 goto end; 113 ed_release_resources(dev); 114 115#ifdef ED_3C503 116 error = ed_probe_3Com(dev, 0, flags); 117 if (error == 0) 118 goto end; 119 ed_release_resources(dev); 120#endif 121 122#ifdef ED_SIC 123 error = ed_probe_SIC(dev, 0, flags); 124 if (error == 0) 125 goto end; 126 ed_release_resources(dev); 127#endif 128 error = ed_isa_probe_Novell(dev); 129 if (error == 0) 130 goto end; 131 ed_release_resources(dev); 132 133#ifdef ED_HPP 134 error = ed_probe_HP_pclanp(dev, 0, flags); 135 if (error == 0) 136 goto end; 137 ed_release_resources(dev); 138#endif 139end: 140 if (error == 0) 141 error = ed_alloc_irq(dev, 0, 0); 142 143 ed_release_resources(dev); 144 return (error); 145} 146 147static int 148ed_isa_attach(device_t dev) 149{ 150 struct ed_softc *sc = device_get_softc(dev); 151 int error; 152 153 if (sc->port_used > 0) 154 ed_alloc_port(dev, sc->port_rid, sc->port_used); 155 if (sc->mem_used) 156 ed_alloc_memory(dev, sc->mem_rid, sc->mem_used); 157 158 ed_alloc_irq(dev, sc->irq_rid, 0); 159 160 error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET, 161 edintr, sc, &sc->irq_handle); 162 if (error) { 163 ed_release_resources(dev); 164 return (error); 165 } 166 167 return ed_attach(dev); 168} 169 170static device_method_t ed_isa_methods[] = { 171 /* Device interface */ 172 DEVMETHOD(device_probe, ed_isa_probe), 173 DEVMETHOD(device_attach, ed_isa_attach), 174 DEVMETHOD(device_detach, ed_detach), 175 176 { 0, 0 } 177}; 178 179static driver_t ed_isa_driver = { 180 "ed", 181 ed_isa_methods, 182 sizeof(struct ed_softc) 183}; 184 185DRIVER_MODULE(ed, isa, ed_isa_driver, ed_devclass, 0, 0); 186MODULE_DEPEND(ed, isa, 1, 1, 1); 187MODULE_DEPEND(ed, ether, 1, 1, 1); 188