if_ep_isapnp.c revision 1.14 1 /* $NetBSD: if_ep_isapnp.c,v 1.14 1998/07/05 06:49:14 jonathan Exp $ */
2
3 /*
4 * Copyright (c) 1997 Jonathan Stone <jonathan (at) 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 "opt_inet.h"
34 #include "opt_ns.h"
35 #include "bpfilter.h"
36
37 #include <sys/param.h>
38 #include <sys/systm.h>
39 #include <sys/mbuf.h>
40 #include <sys/socket.h>
41 #include <sys/ioctl.h>
42 #include <sys/errno.h>
43 #include <sys/syslog.h>
44 #include <sys/select.h>
45 #include <sys/device.h>
46
47 #include <net/if.h>
48 #include <net/if_dl.h>
49 #include <net/if_ether.h>
50 #include <net/if_media.h>
51
52 #ifdef INET
53 #include <netinet/in.h>
54 #include <netinet/in_systm.h>
55 #include <netinet/in_var.h>
56 #include <netinet/ip.h>
57 #endif
58
59 #ifdef NS
60 #include <netns/ns.h>
61 #include <netns/ns_if.h>
62 #endif
63
64 #if NBPFILTER > 0
65 #include <net/bpf.h>
66 #include <net/bpfdesc.h>
67 #endif
68
69 #include <machine/cpu.h>
70 #include <machine/bus.h>
71 #include <machine/intr.h>
72
73 #include <dev/isa/isavar.h>
74
75 #include <dev/isapnp/isapnpreg.h>
76 #include <dev/isapnp/isapnpvar.h>
77
78 #include <dev/ic/elink3var.h>
79 #include <dev/ic/elink3reg.h>
80
81 int ep_isapnp_match __P((struct device *, struct cfdata *, void *));
82 void ep_isapnp_attach __P((struct device *, struct device *, void *));
83
84 struct cfattach ep_isapnp_ca = {
85 sizeof(struct ep_softc), ep_isapnp_match, ep_isapnp_attach
86 };
87
88 int
89 ep_isapnp_match(parent, match, aux)
90 struct device *parent;
91 struct cfdata *match;
92 void *aux;
93 {
94 struct isapnp_attach_args *ipa = aux;
95
96 if (strcmp(ipa->ipa_devlogic, "TCM5090") &&
97 strcmp(ipa->ipa_devlogic, "TCM5091") &&
98 strcmp(ipa->ipa_devlogic, "TCM5094") &&
99 strcmp(ipa->ipa_devlogic, "TCM5095") &&
100 strcmp(ipa->ipa_devlogic, "TCM5098"))
101 return (0);
102
103 return (1);
104 }
105
106 void
107 ep_isapnp_attach(parent, self, aux)
108 struct device *parent, *self;
109 void *aux;
110 {
111 struct ep_softc *sc = (void *)self;
112 struct isapnp_attach_args *ipa = aux;
113
114 printf("\n");
115
116 if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
117 printf("%s: error in region allocation\n", sc->sc_dev.dv_xname);
118 return;
119 }
120
121 printf("%s: %s %s\n", sc->sc_dev.dv_xname, ipa->ipa_devident,
122 ipa->ipa_devclass);
123
124 sc->sc_iot = ipa->ipa_iot;
125 sc->sc_ioh = ipa->ipa_io[0].h;
126 sc->bustype = EP_BUS_ISA;
127
128 sc->sc_ih = isa_intr_establish(ipa->ipa_ic, ipa->ipa_irq[0].num,
129 ipa->ipa_irq[0].type, IPL_NET, epintr, sc);
130
131 sc->enable = NULL;
132 sc->disable = NULL;
133 sc->enabled = 1;
134
135 if (strcmp(ipa->ipa_devlogic, "TCM5090") &&
136 strcmp(ipa->ipa_devlogic, "TCM5091") &&
137 strcmp(ipa->ipa_devlogic, "TCM5094") &&
138 strcmp(ipa->ipa_devlogic, "TCM5095") &&
139 strcmp(ipa->ipa_devlogic, "TCM5098")) {
140 epconfig(sc, EP_CHIPSET_UNKNOWN, NULL); /* XXX: 3c515 ? */
141 } else {
142 epconfig(sc, EP_CHIPSET_3C509, NULL);
143 }
144 }
145