if_ed_isa.c revision 151550
1259701Sdim/*- 2259701Sdim * Copyright (c) 1995, David Greenman 3259701Sdim * All rights reserved. 4259701Sdim * 5259701Sdim * Redistribution and use in source and binary forms, with or without 6259701Sdim * modification, are permitted provided that the following conditions 7259701Sdim * are met: 8259701Sdim * 1. Redistributions of source code must retain the above copyright 9259701Sdim * notice unmodified, this list of conditions, and the following 10259701Sdim * disclaimer. 11259701Sdim * 2. Redistributions in binary form must reproduce the above copyright 12259701Sdim * notice, this list of conditions and the following disclaimer in the 13259701Sdim * documentation and/or other materials provided with the distribution. 14259701Sdim * 15259701Sdim * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16259701Sdim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17259701Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18259701Sdim * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19259701Sdim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20259701Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21259701Sdim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22259701Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23259701Sdim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24259701Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25259701Sdim * SUCH DAMAGE. 26259701Sdim * 27259701Sdim */ 28259701Sdim 29259701Sdim#include <sys/cdefs.h> 30259701Sdim__FBSDID("$FreeBSD: head/sys/dev/ed/if_ed_isa.c 151550 2005-10-22 07:26:05Z imp $"); 31259701Sdim 32259701Sdim#include "opt_ed.h" 33259701Sdim 34259701Sdim#include <sys/param.h> 35259701Sdim#include <sys/systm.h> 36259701Sdim#include <sys/socket.h> 37259701Sdim#include <sys/kernel.h> 38259701Sdim 39259701Sdim#include <sys/module.h> 40259701Sdim#include <sys/bus.h> 41259701Sdim#include <machine/bus.h> 42259701Sdim 43259701Sdim#include <net/ethernet.h> 44259701Sdim#include <net/if.h> 45259701Sdim#include <net/if_arp.h> 46259701Sdim#include <net/if_media.h> 47259701Sdim#include <net/if_mib.h> 48259701Sdim 49259701Sdim#include <isa/isavar.h> 50259701Sdim 51259701Sdim#include <dev/ed/if_edvar.h> 52259701Sdim#include <dev/ed/if_edreg.h> 53259701Sdim 54259701Sdimstatic int ed_isa_probe(device_t); 55static int ed_isa_attach(device_t); 56 57static struct isa_pnp_id ed_ids[] = { 58 { 0x1684a34d, NULL }, /* SMC8416 */ 59 { 0xd680d041, NULL }, /* PNP80d6 */ 60 { 0x1980635e, NULL }, /* WSC8019 */ 61 { 0x0131d805, NULL }, /* ANX3101 */ 62 { 0x01200507, NULL }, /* AXE2001 */ 63 { 0x19808c4a, NULL }, /* RTL8019 */ 64 { 0x0090252a, NULL }, /* JQE9000 */ 65 { 0x0020832e, NULL }, /* KTC2000 */ 66 { 0x4cf48906, NULL }, /* ATIf44c */ 67 { 0, NULL } 68}; 69 70static int 71ed_isa_probe_Novell(device_t dev) 72{ 73 struct ed_softc *sc = device_get_softc(dev); 74 int flags = device_get_flags(dev); 75 int err; 76 77 err = ed_probe_Novell(dev, 0, flags); 78 if (err) 79 return err; 80 ed_Novell_read_mac(sc); 81 /* 82 * Final sanity check for Gateway Ethernet cards before 83 * believing that they really are Gateway AT. 84 */ 85 if ((ED_FLAGS_GETTYPE(flags) == ED_FLAGS_GWETHER) && 86 (sc->enaddr[2] == 0x86)) { 87 sc->type_str = "Gateway AT"; 88 } 89 90 return (0); 91} 92 93static int 94ed_isa_probe(device_t dev) 95{ 96 int flags = device_get_flags(dev); 97 int error = 0; 98 99 /* Check isapnp ids */ 100 error = ISA_PNP_PROBE(device_get_parent(dev), dev, ed_ids); 101 102 /* If the card had a PnP ID that didn't match any we know about */ 103 if (error == ENXIO) 104 goto end; 105 106 /* If we had some other problem. */ 107 if (!(error == 0 || error == ENOENT)) 108 goto end; 109 110 /* Heuristic probes */ 111 112 error = ed_probe_WD80x3(dev, 0, flags); 113 if (error == 0) 114 goto end; 115 ed_release_resources(dev); 116 117 error = ed_probe_RTL80x9(dev, 0, flags); 118 if (error == 0) { 119 ed_Novell_read_mac(sc); 120 goto end; 121 } 122 ed_release_resources(dev); 123 124#ifdef ED_3C503 125 error = ed_probe_3Com(dev, 0, flags); 126 if (error == 0) 127 goto end; 128 ed_release_resources(dev); 129#endif 130 131#ifdef ED_SIC 132 error = ed_probe_SIC(dev, 0, flags); 133 if (error == 0) 134 goto end; 135 ed_release_resources(dev); 136#endif 137 error = ed_isa_probe_Novell(dev); 138 if (error == 0) 139 goto end; 140 ed_release_resources(dev); 141 142#ifdef ED_HPP 143 error = ed_probe_HP_pclanp(dev, 0, flags); 144 if (error == 0) 145 goto end; 146 ed_release_resources(dev); 147#endif 148end: 149 if (error == 0) 150 error = ed_alloc_irq(dev, 0, 0); 151 152 ed_release_resources(dev); 153 return (error); 154} 155 156static int 157ed_isa_attach(device_t dev) 158{ 159 struct ed_softc *sc = device_get_softc(dev); 160 int error; 161 162 if (sc->port_used > 0) 163 ed_alloc_port(dev, sc->port_rid, sc->port_used); 164 if (sc->mem_used) 165 ed_alloc_memory(dev, sc->mem_rid, sc->mem_used); 166 167 ed_alloc_irq(dev, sc->irq_rid, 0); 168 169 error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET | INTR_MPSAFE, 170 edintr, sc, &sc->irq_handle); 171 if (error) { 172 ed_release_resources(dev); 173 return (error); 174 } 175 176#ifdef ED_HPP 177 if (sc->vendor == ED_VENDOR_HP && sc->type == ED_TYPE_HP_PCLANPLUS) 178 sc->readmem = ed_hpp_readmem; 179#endif 180 return ed_attach(dev); 181} 182 183static device_method_t ed_isa_methods[] = { 184 /* Device interface */ 185 DEVMETHOD(device_probe, ed_isa_probe), 186 DEVMETHOD(device_attach, ed_isa_attach), 187 DEVMETHOD(device_detach, ed_detach), 188 189 { 0, 0 } 190}; 191 192static driver_t ed_isa_driver = { 193 "ed", 194 ed_isa_methods, 195 sizeof(struct ed_softc) 196}; 197 198DRIVER_MODULE(ed, isa, ed_isa_driver, ed_devclass, 0, 0); 199MODULE_DEPEND(ed, isa, 1, 1, 1); 200MODULE_DEPEND(ed, ether, 1, 1, 1); 201