1139749Simp/*- 252245Smdodd * Copyright (c) 1995, David Greenman 352245Smdodd * All rights reserved. 452245Smdodd * 552245Smdodd * Redistribution and use in source and binary forms, with or without 652245Smdodd * modification, are permitted provided that the following conditions 752245Smdodd * are met: 852245Smdodd * 1. Redistributions of source code must retain the above copyright 952245Smdodd * notice unmodified, this list of conditions, and the following 1052245Smdodd * disclaimer. 1152245Smdodd * 2. Redistributions in binary form must reproduce the above copyright 1252245Smdodd * notice, this list of conditions and the following disclaimer in the 1352245Smdodd * documentation and/or other materials provided with the distribution. 1452245Smdodd * 1552245Smdodd * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1652245Smdodd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1752245Smdodd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1852245Smdodd * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1952245Smdodd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2052245Smdodd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2152245Smdodd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2252245Smdodd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2352245Smdodd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2452245Smdodd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2552245Smdodd * SUCH DAMAGE. 2652245Smdodd * 2752245Smdodd */ 2852245Smdodd 29119418Sobrien#include <sys/cdefs.h> 30119418Sobrien__FBSDID("$FreeBSD$"); 31119418Sobrien 32141586Simp#include "opt_ed.h" 33141586Simp 3452245Smdodd#include <sys/param.h> 3552245Smdodd#include <sys/systm.h> 3652245Smdodd#include <sys/socket.h> 3752245Smdodd#include <sys/kernel.h> 3852245Smdodd 3952245Smdodd#include <sys/module.h> 4052245Smdodd#include <sys/bus.h> 4152245Smdodd#include <machine/bus.h> 4252245Smdodd 43141932Simp#include <net/ethernet.h> 4452245Smdodd#include <net/if.h> 4552245Smdodd#include <net/if_arp.h> 46149558Simp#include <net/if_media.h> 4752245Smdodd#include <net/if_mib.h> 4852245Smdodd 4952245Smdodd#include <isa/isavar.h> 5052245Smdodd 5152245Smdodd#include <dev/ed/if_edvar.h> 52149558Simp#include <dev/ed/if_edreg.h> 5352245Smdodd 54142254Simpstatic int ed_isa_probe(device_t); 55142254Simpstatic int ed_isa_attach(device_t); 5652245Smdodd 5752245Smdoddstatic struct isa_pnp_id ed_ids[] = { 5852245Smdodd { 0x0131d805, NULL }, /* ANX3101 */ 59154391Simp { 0x4cf48906, NULL }, /* ATIf44c */ 6052245Smdodd { 0x01200507, NULL }, /* AXE2001 */ 61211764Syongari { 0x0115180e, NULL }, /* CPX1501 */ 6252245Smdodd { 0x0090252a, NULL }, /* JQE9000 */ 6352245Smdodd { 0x0020832e, NULL }, /* KTC2000 */ 64154391Simp { 0xd680d041, NULL }, /* PNP80d6 */ 65154391Simp { 0x6081d041, NULL }, /* PNP8160 */ 66154391Simp { 0x19808c4a, NULL }, /* RTL8019 */ 67154391Simp { 0x1684a34d, NULL }, /* SMC8416 */ 68154391Simp { 0x1980635e, NULL }, /* WSC8019 */ 6952245Smdodd { 0, NULL } 7052245Smdodd}; 7152245Smdodd 7252245Smdoddstatic int 73141932Simped_isa_probe_Novell(device_t dev) 7452245Smdodd{ 75141932Simp struct ed_softc *sc = device_get_softc(dev); 7664777Snyan int flags = device_get_flags(dev); 77141932Simp int err; 78141932Simp 79141932Simp err = ed_probe_Novell(dev, 0, flags); 80141932Simp if (err) 81141932Simp return err; 82141932Simp ed_Novell_read_mac(sc); 83141932Simp /* 84141932Simp * Final sanity check for Gateway Ethernet cards before 85141932Simp * believing that they really are Gateway AT. 86154924Simp * XXX I think this is stale. 87141932Simp */ 88141932Simp if ((ED_FLAGS_GETTYPE(flags) == ED_FLAGS_GWETHER) && 89147256Sbrooks (sc->enaddr[2] == 0x86)) { 90141932Simp sc->type_str = "Gateway AT"; 91141932Simp } 92141932Simp 93141932Simp return (0); 94141932Simp} 95141932Simp 96141932Simpstatic int 97141932Simped_isa_probe(device_t dev) 98141932Simp{ 99151551Simp struct ed_softc *sc = device_get_softc(dev); 100141932Simp int flags = device_get_flags(dev); 10152245Smdodd int error = 0; 10252245Smdodd 10352245Smdodd /* Check isapnp ids */ 10452245Smdodd error = ISA_PNP_PROBE(device_get_parent(dev), dev, ed_ids); 10552245Smdodd 10652245Smdodd /* If the card had a PnP ID that didn't match any we know about */ 107141932Simp if (error == ENXIO) 10852245Smdodd goto end; 10952245Smdodd 11052245Smdodd /* If we had some other problem. */ 111141932Simp if (!(error == 0 || error == ENOENT)) 11252245Smdodd goto end; 11352245Smdodd 11452245Smdodd /* Heuristic probes */ 11552245Smdodd 11664777Snyan error = ed_probe_WD80x3(dev, 0, flags); 11752245Smdodd if (error == 0) 11852245Smdodd goto end; 11952245Smdodd ed_release_resources(dev); 12052245Smdodd 121150957Simp error = ed_probe_RTL80x9(dev, 0, flags); 122151550Simp if (error == 0) { 123151550Simp ed_Novell_read_mac(sc); 124150957Simp goto end; 125151550Simp } 126150957Simp ed_release_resources(dev); 127150957Simp 128141586Simp#ifdef ED_3C503 12964777Snyan error = ed_probe_3Com(dev, 0, flags); 13052245Smdodd if (error == 0) 13152245Smdodd goto end; 13252245Smdodd ed_release_resources(dev); 133141586Simp#endif 13452245Smdodd 135141586Simp#ifdef ED_SIC 136121118Sshiba error = ed_probe_SIC(dev, 0, flags); 137121118Sshiba if (error == 0) 138121118Sshiba goto end; 139121118Sshiba ed_release_resources(dev); 140141586Simp#endif 141141932Simp error = ed_isa_probe_Novell(dev); 14252245Smdodd if (error == 0) 14352245Smdodd goto end; 14452245Smdodd ed_release_resources(dev); 14552247Smdodd 146141586Simp#ifdef ED_HPP 14764777Snyan error = ed_probe_HP_pclanp(dev, 0, flags); 14852245Smdodd if (error == 0) 14952245Smdodd goto end; 15052245Smdodd ed_release_resources(dev); 151141586Simp#endif 15252245Smdoddend: 15352245Smdodd if (error == 0) 15452245Smdodd error = ed_alloc_irq(dev, 0, 0); 15552245Smdodd 15652245Smdodd ed_release_resources(dev); 15752245Smdodd return (error); 15852245Smdodd} 15952245Smdodd 16052245Smdoddstatic int 161142254Simped_isa_attach(device_t dev) 16252245Smdodd{ 16352245Smdodd struct ed_softc *sc = device_get_softc(dev); 16452245Smdodd int error; 16552245Smdodd 16652245Smdodd if (sc->port_used > 0) 167191299Simp ed_alloc_port(dev, 0, sc->port_used); 16852245Smdodd if (sc->mem_used) 169191299Simp ed_alloc_memory(dev, 0, sc->mem_used); 170191299Simp ed_alloc_irq(dev, 0, 0); 17164777Snyan 172191234Simp if (sc->sc_media_ioctl == NULL) 173191234Simp ed_gen_ifmedia_init(sc); 174191234Simp error = ed_attach(dev); 17552245Smdodd if (error) { 17652245Smdodd ed_release_resources(dev); 17752245Smdodd return (error); 17864777Snyan } 179191234Simp error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET | INTR_MPSAFE, 180191234Simp NULL, edintr, sc, &sc->irq_handle); 181191234Simp if (error) 182191234Simp ed_release_resources(dev); 183191234Simp return (error); 18464777Snyan} 18552245Smdodd 18652245Smdoddstatic device_method_t ed_isa_methods[] = { 18752245Smdodd /* Device interface */ 18852245Smdodd DEVMETHOD(device_probe, ed_isa_probe), 18952245Smdodd DEVMETHOD(device_attach, ed_isa_attach), 190141494Simp DEVMETHOD(device_detach, ed_detach), 19152245Smdodd 19252245Smdodd { 0, 0 } 19352245Smdodd}; 19452245Smdodd 19552245Smdoddstatic driver_t ed_isa_driver = { 19652245Smdodd "ed", 19752245Smdodd ed_isa_methods, 19852245Smdodd sizeof(struct ed_softc) 19952245Smdodd}; 20052245Smdodd 201113506SmdoddDRIVER_MODULE(ed, isa, ed_isa_driver, ed_devclass, 0, 0); 202113506SmdoddMODULE_DEPEND(ed, isa, 1, 1, 1); 203113506SmdoddMODULE_DEPEND(ed, ether, 1, 1, 1); 204