xref: /netbsd-src/sys/dev/isapnp/if_ep_isapnp.c (revision d0fed6c87ddc40a8bffa6f99e7433ddfc864dd83)
1 /*	$NetBSD: if_ep_isapnp.c,v 1.6 1997/03/30 22:47:07 jonathan 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, "TCM5094"))
103 		return (0);
104 
105 	return (1);
106 }
107 
108 void
109 ep_isapnp_attach(parent, self, aux)
110 	struct device *parent, *self;
111 	void *aux;
112 {
113 	struct ep_softc *sc = (void *)self;
114 	struct isapnp_attach_args *ipa = aux;
115 	u_short conn = 0;
116 
117 	printf("\n");
118 
119 	sc->sc_iot = ipa->ipa_iot;
120 	sc->sc_ioh = ipa->ipa_io[0].h;
121 	sc->bustype = EP_BUS_ISA;
122 
123 	GO_WINDOW(0);
124 	conn = bus_space_read_2(sc->sc_iot, sc->sc_ioh, EP_W0_CONFIG_CTRL);
125 
126 	if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
127 		printf("%s: error in region allocation\n", sc->sc_dev.dv_xname);
128 		return;
129 	}
130 
131 	printf("%s: %s %s\n", sc->sc_dev.dv_xname, ipa->ipa_devident,
132 	    ipa->ipa_devclass);
133 
134 	sc->sc_ih = isa_intr_establish(ipa->ipa_ic, ipa->ipa_irq[0].num,
135 	    IST_EDGE, IPL_NET, epintr, sc);
136 
137 	/* we can't easily tell if this is a 3c509B or 3c515 */
138 	epconfig(sc, EP_CHIPSET_UNKNOWN);	/* XXX */
139 }
140