1 /* $NetBSD: if_ep_isapnp.c,v 1.11 1997/12/17 01:31:59 thorpej Exp $ */ 2 3 /* 4 * Copyright (c) 1997 Jonathan Stone <jonathan@NetBSD.org> 5 * Copyright (c) 1997 Charles M. Hannum. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. All advertising materials mentioning features or use of this software 16 * must display the following acknowledgement: 17 * This product includes software developed by Charles M. Hannum. 18 * 4. The name of the author may not be used to endorse or promote products 19 * derived from this software without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 #include "bpfilter.h" 34 35 #include <sys/param.h> 36 #include <sys/systm.h> 37 #include <sys/mbuf.h> 38 #include <sys/socket.h> 39 #include <sys/ioctl.h> 40 #include <sys/errno.h> 41 #include <sys/syslog.h> 42 #include <sys/select.h> 43 #include <sys/device.h> 44 45 #include <net/if.h> 46 #include <net/if_dl.h> 47 #include <net/if_ether.h> 48 #include <net/if_media.h> 49 50 #ifdef INET 51 #include <netinet/in.h> 52 #include <netinet/in_systm.h> 53 #include <netinet/in_var.h> 54 #include <netinet/ip.h> 55 #endif 56 57 #ifdef NS 58 #include <netns/ns.h> 59 #include <netns/ns_if.h> 60 #endif 61 62 #if NBPFILTER > 0 63 #include <net/bpf.h> 64 #include <net/bpfdesc.h> 65 #endif 66 67 #include <machine/cpu.h> 68 #include <machine/bus.h> 69 #include <machine/intr.h> 70 71 #include <dev/isa/isavar.h> 72 73 #include <dev/isapnp/isapnpreg.h> 74 #include <dev/isapnp/isapnpvar.h> 75 76 #include <dev/ic/elink3var.h> 77 #include <dev/ic/elink3reg.h> 78 79 #ifdef __BROKEN_INDIRECT_CONFIG 80 int ep_isapnp_match __P((struct device *, void *, void *)); 81 #else 82 int ep_isapnp_match __P((struct device *, struct cfdata *, void *)); 83 #endif 84 void ep_isapnp_attach __P((struct device *, struct device *, void *)); 85 86 struct cfattach ep_isapnp_ca = { 87 sizeof(struct ep_softc), ep_isapnp_match, ep_isapnp_attach 88 }; 89 90 int 91 ep_isapnp_match(parent, match, aux) 92 struct device *parent; 93 #ifdef __BROKEN_INDIRECT_CONFIG 94 void *match; 95 #else 96 struct cfdata *match; 97 #endif 98 void *aux; 99 { 100 struct isapnp_attach_args *ipa = aux; 101 102 if (strcmp(ipa->ipa_devlogic, "TCM5090") && 103 strcmp(ipa->ipa_devlogic, "TCM5091") && 104 strcmp(ipa->ipa_devlogic, "TCM5094") && 105 strcmp(ipa->ipa_devlogic, "TCM5095") && 106 strcmp(ipa->ipa_devlogic, "TCM5098")) 107 return (0); 108 109 return (1); 110 } 111 112 void 113 ep_isapnp_attach(parent, self, aux) 114 struct device *parent, *self; 115 void *aux; 116 { 117 struct ep_softc *sc = (void *)self; 118 struct isapnp_attach_args *ipa = aux; 119 120 printf("\n"); 121 122 if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) { 123 printf("%s: error in region allocation\n", sc->sc_dev.dv_xname); 124 return; 125 } 126 127 printf("%s: %s %s\n", sc->sc_dev.dv_xname, ipa->ipa_devident, 128 ipa->ipa_devclass); 129 130 sc->sc_iot = ipa->ipa_iot; 131 sc->sc_ioh = ipa->ipa_io[0].h; 132 sc->bustype = EP_BUS_ISA; 133 134 sc->sc_ih = isa_intr_establish(ipa->ipa_ic, ipa->ipa_irq[0].num, 135 ipa->ipa_irq[0].type, IPL_NET, epintr, sc); 136 137 sc->enable = NULL; 138 sc->disable = NULL; 139 sc->enabled = 1; 140 141 if (strcmp(ipa->ipa_devlogic, "TCM5090") && 142 strcmp(ipa->ipa_devlogic, "TCM5091") && 143 strcmp(ipa->ipa_devlogic, "TCM5094") && 144 strcmp(ipa->ipa_devlogic, "TCM5095") && 145 strcmp(ipa->ipa_devlogic, "TCM5098")) { 146 epconfig(sc, EP_CHIPSET_UNKNOWN, NULL); /* XXX: 3c515 ? */ 147 } else { 148 epconfig(sc, EP_CHIPSET_3C509, NULL); 149 } 150 } 151