if_ed_isa.c revision 121118
1181834Sroberto/* 2181834Sroberto * Copyright (c) 1995, David Greenman 3181834Sroberto * All rights reserved. 4181834Sroberto * 5181834Sroberto * Redistribution and use in source and binary forms, with or without 6181834Sroberto * modification, are permitted provided that the following conditions 7181834Sroberto * are met: 8181834Sroberto * 1. Redistributions of source code must retain the above copyright 9181834Sroberto * notice unmodified, this list of conditions, and the following 10181834Sroberto * disclaimer. 11181834Sroberto * 2. Redistributions in binary form must reproduce the above copyright 12181834Sroberto * notice, this list of conditions and the following disclaimer in the 13181834Sroberto * documentation and/or other materials provided with the distribution. 14181834Sroberto * 15181834Sroberto * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16181834Sroberto * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17181834Sroberto * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18181834Sroberto * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19181834Sroberto * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20181834Sroberto * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21181834Sroberto * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22181834Sroberto * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23181834Sroberto * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24181834Sroberto * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25181834Sroberto * SUCH DAMAGE. 26181834Sroberto * 27181834Sroberto */ 28181834Sroberto 29181834Sroberto#include <sys/cdefs.h> 30181834Sroberto__FBSDID("$FreeBSD: head/sys/dev/ed/if_ed_isa.c 121118 2003-10-15 17:22:15Z shiba $"); 31181834Sroberto 32181834Sroberto#include <sys/param.h> 33181834Sroberto#include <sys/systm.h> 34181834Sroberto#include <sys/socket.h> 35181834Sroberto#include <sys/kernel.h> 36181834Sroberto 37181834Sroberto#include <sys/module.h> 38181834Sroberto#include <sys/bus.h> 39181834Sroberto#include <machine/bus.h> 40181834Sroberto 41181834Sroberto#include <net/if.h> 42181834Sroberto#include <net/if_arp.h> 43181834Sroberto#include <net/if_mib.h> 44181834Sroberto 45181834Sroberto#include <isa/isavar.h> 46181834Sroberto 47181834Sroberto#include <dev/ed/if_edvar.h> 48181834Sroberto 49181834Srobertostatic int ed_isa_probe (device_t); 50181834Srobertostatic int ed_isa_attach (device_t); 51181834Sroberto 52181834Srobertostatic struct isa_pnp_id ed_ids[] = { 53181834Sroberto { 0x1684a34d, NULL }, /* SMC8416 */ 54181834Sroberto { 0xd680d041, NULL }, /* PNP80d6 */ 55181834Sroberto { 0x1980635e, NULL }, /* WSC8019 */ 56181834Sroberto { 0x0131d805, NULL }, /* ANX3101 */ 57181834Sroberto { 0x01200507, NULL }, /* AXE2001 */ 58181834Sroberto { 0x19808c4a, NULL }, /* RTL8019 */ 59181834Sroberto { 0x0090252a, NULL }, /* JQE9000 */ 60181834Sroberto { 0x0020832e, NULL }, /* KTC2000 */ 61181834Sroberto { 0x4cf48906, NULL }, /* ATIf44c */ 62181834Sroberto { 0, NULL } 63181834Sroberto}; 64181834Sroberto 65181834Srobertostatic int 66181834Srobertoed_isa_probe(dev) 67181834Sroberto device_t dev; 68181834Sroberto{ 69181834Sroberto struct ed_softc *sc = device_get_softc(dev); 70181834Sroberto int flags = device_get_flags(dev); 71181834Sroberto int error = 0; 72181834Sroberto 73181834Sroberto bzero(sc, sizeof(struct ed_softc)); 74181834Sroberto 75181834Sroberto /* Check isapnp ids */ 76181834Sroberto error = ISA_PNP_PROBE(device_get_parent(dev), dev, ed_ids); 77181834Sroberto 78181834Sroberto /* If the card had a PnP ID that didn't match any we know about */ 79181834Sroberto if (error == ENXIO) { 80181834Sroberto goto end; 81181834Sroberto } 82181834Sroberto 83181834Sroberto /* If we had some other problem. */ 84181834Sroberto if (!(error == 0 || error == ENOENT)) { 85181834Sroberto goto end; 86181834Sroberto } 87181834Sroberto 88181834Sroberto /* Heuristic probes */ 89181834Sroberto 90181834Sroberto error = ed_probe_WD80x3(dev, 0, flags); 91181834Sroberto if (error == 0) 92181834Sroberto goto end; 93181834Sroberto ed_release_resources(dev); 94181834Sroberto 95181834Sroberto error = ed_probe_3Com(dev, 0, flags); 96181834Sroberto if (error == 0) 97181834Sroberto goto end; 98181834Sroberto ed_release_resources(dev); 99181834Sroberto 100181834Sroberto error = ed_probe_SIC(dev, 0, flags); 101181834Sroberto if (error == 0) 102181834Sroberto goto end; 103181834Sroberto ed_release_resources(dev); 104181834Sroberto 105181834Sroberto error = ed_probe_Novell(dev, 0, flags); 106181834Sroberto if (error == 0) 107181834Sroberto goto end; 108181834Sroberto ed_release_resources(dev); 109181834Sroberto 110181834Sroberto error = ed_probe_HP_pclanp(dev, 0, flags); 111181834Sroberto if (error == 0) 112181834Sroberto goto end; 113181834Sroberto ed_release_resources(dev); 114181834Sroberto 115181834Srobertoend: 116181834Sroberto if (error == 0) 117181834Sroberto error = ed_alloc_irq(dev, 0, 0); 118181834Sroberto 119181834Sroberto ed_release_resources(dev); 120181834Sroberto return (error); 121181834Sroberto} 122181834Sroberto 123181834Srobertostatic int 124181834Srobertoed_isa_attach(dev) 125181834Sroberto device_t dev; 126181834Sroberto{ 127181834Sroberto struct ed_softc *sc = device_get_softc(dev); 128181834Sroberto int flags = device_get_flags(dev); 129181834Sroberto int error; 130181834Sroberto 131181834Sroberto if (sc->port_used > 0) 132181834Sroberto ed_alloc_port(dev, sc->port_rid, sc->port_used); 133181834Sroberto if (sc->mem_used) 134181834Sroberto ed_alloc_memory(dev, sc->mem_rid, sc->mem_used); 135181834Sroberto 136181834Sroberto ed_alloc_irq(dev, sc->irq_rid, 0); 137181834Sroberto 138181834Sroberto error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET, 139181834Sroberto edintr, sc, &sc->irq_handle); 140181834Sroberto if (error) { 141181834Sroberto ed_release_resources(dev); 142181834Sroberto return (error); 143181834Sroberto } 144181834Sroberto 145181834Sroberto return ed_attach(sc, device_get_unit(dev), flags); 146181834Sroberto} 147181834Sroberto 148181834Srobertostatic device_method_t ed_isa_methods[] = { 149181834Sroberto /* Device interface */ 150181834Sroberto DEVMETHOD(device_probe, ed_isa_probe), 151181834Sroberto DEVMETHOD(device_attach, ed_isa_attach), 152181834Sroberto 153181834Sroberto { 0, 0 } 154181834Sroberto}; 155181834Sroberto 156181834Srobertostatic driver_t ed_isa_driver = { 157181834Sroberto "ed", 158181834Sroberto ed_isa_methods, 159181834Sroberto sizeof(struct ed_softc) 160181834Sroberto}; 161181834Sroberto 162181834SrobertoDRIVER_MODULE(ed, isa, ed_isa_driver, ed_devclass, 0, 0); 163181834SrobertoMODULE_DEPEND(ed, isa, 1, 1, 1); 164181834SrobertoMODULE_DEPEND(ed, ether, 1, 1, 1); 165181834Sroberto