if_ep_isapnp.c revision 1.4 1 /* $NetBSD: if_ep_isapnp.c,v 1.4 1997/03/18 18:58:12 christos Exp $ */
2
3 /*
4 * Copyright (c) 1997 Charles M. Hannum. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by Charles M. Hannum.
17 * 4. The name of the author may not be used to endorse or promote products
18 * derived from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #include "bpfilter.h"
33
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/mbuf.h>
37 #include <sys/socket.h>
38 #include <sys/ioctl.h>
39 #include <sys/errno.h>
40 #include <sys/syslog.h>
41 #include <sys/select.h>
42 #include <sys/device.h>
43
44 #include <net/if.h>
45 #include <net/if_dl.h>
46 #include <net/if_types.h>
47
48 #include <net/if_ether.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/ic/elink3var.h>
72 #include <dev/ic/elink3reg.h>
73
74 #include <dev/isa/isavar.h>
75
76 #include <dev/isapnp/isapnpreg.h>
77 #include <dev/isapnp/isapnpvar.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 return (!strcmp(ipa->ipa_devlogic, "TCM5094"));
103 }
104
105 void
106 ep_isapnp_attach(parent, self, aux)
107 struct device *parent, *self;
108 void *aux;
109 {
110 struct ep_softc *sc = (void *)self;
111 struct isapnp_attach_args *ipa = aux;
112 u_short conn = 0;
113
114 sc->sc_iot = ipa->ipa_iot;
115 sc->sc_ioh = ipa->ipa_io[0].h;
116 sc->bustype = EP_BUS_ISA;
117
118 GO_WINDOW(0);
119 conn = bus_space_read_2(sc->sc_iot, sc->sc_ioh, EP_W0_CONFIG_CTRL);
120
121 printf("\n");
122
123 if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
124 printf("%s: error in region allocation\n", sc->sc_dev.dv_xname);
125 return;
126 }
127
128 printf("%s: %s %s\n", sc->sc_dev.dv_xname, ipa->ipa_devident,
129 ipa->ipa_devclass);
130
131 sc->sc_ih = isa_intr_establish(ipa->ipa_ic, ipa->ipa_irq[0].num,
132 IST_EDGE, IPL_NET, epintr, sc);
133
134 /* we can't easily tell if this is a 3c509B or 3c515 */
135 epconfig(sc, EP_CHIPSET_UNKNOWN); /* XXX */
136 }
137