1 /* $NetBSD: depca_eisa.c,v 1.7 2005/02/27 00:26:59 perry Exp $ */
2
3 /*-
4 * Copyright (c) 2000 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 /*
40 * EISA bus front-end for the Digital DEPCA Ethernet controller.
41 */
42
43 #include <sys/cdefs.h>
44 __KERNEL_RCSID(0, "$NetBSD: depca_eisa.c,v 1.7 2005/02/27 00:26:59 perry Exp $");
45
46 #include "opt_inet.h"
47 #include "bpfilter.h"
48
49 #include <sys/param.h>
50 #include <sys/systm.h>
51 #include <sys/mbuf.h>
52 #include <sys/syslog.h>
53 #include <sys/socket.h>
54 #include <sys/device.h>
55
56 #include <net/if.h>
57 #include <net/if_media.h>
58 #include <net/if_ether.h>
59
60 #ifdef INET
61 #include <netinet/in.h>
62 #include <netinet/if_inarp.h>
63 #endif
64
65 #include <machine/bus.h>
66 #include <machine/intr.h>
67
68 #include <dev/eisa/eisareg.h>
69 #include <dev/eisa/eisavar.h>
70 #include <dev/eisa/eisadevs.h>
71
72 #include <dev/ic/lancereg.h>
73 #include <dev/ic/lancevar.h>
74 #include <dev/ic/am7990reg.h>
75 #include <dev/ic/am7990var.h>
76 #include <dev/ic/depcareg.h>
77 #include <dev/ic/depcavar.h>
78
79 static int depca_eisa_match(struct device *, struct cfdata *, void *);
80 static void depca_eisa_attach(struct device *, struct device *, void *);
81
82 struct depca_eisa_softc {
83 struct depca_softc sc_depca;
84
85 eisa_chipset_tag_t sc_ec;
86 int sc_irq;
87 int sc_ist;
88 };
89
90 CFATTACH_DECL(depca_eisa, sizeof(struct depca_eisa_softc),
91 depca_eisa_match, depca_eisa_attach, NULL, NULL);
92
93 static void *depca_eisa_intr_establish(struct depca_softc *,
94 struct lance_softc *);
95
96 static int
97 depca_eisa_match(struct device *parent, struct cfdata *match, void *aux)
98 {
99 struct eisa_attach_args *ea = aux;
100
101 return (strcmp(ea->ea_idstring, "DEC4220") == 0);
102 }
103
104 #define DEPCA_ECU_FUNC_NETINTR 0
105 #define DEPCA_ECU_FUNC_NETBUF 1
106
107 static void
108 depca_eisa_attach(struct device *parent, struct device *self, void *aux)
109 {
110 struct depca_softc *sc = (void *) self;
111 struct depca_eisa_softc *esc = (void *) self;
112 struct eisa_attach_args *ea = aux;
113 struct eisa_cfg_mem ecm;
114 struct eisa_cfg_irq eci;
115
116 printf(": DEC DE422 Ethernet\n");
117
118 sc->sc_iot = ea->ea_iot;
119 sc->sc_memt = ea->ea_memt;
120
121 esc->sc_ec = ea->ea_ec;
122
123 sc->sc_intr_establish = depca_eisa_intr_establish;
124
125 if (eisa_conf_read_mem(ea->ea_ec, ea->ea_slot,
126 DEPCA_ECU_FUNC_NETBUF, 0, &ecm) != 0) {
127 printf("%s: unable to find network buffer\n",
128 sc->sc_dev.dv_xname);
129 return;
130 }
131
132 printf("%s: shared memory at 0x%lx-0x%lx\n", sc->sc_dev.dv_xname,
133 ecm.ecm_addr, ecm.ecm_addr + ecm.ecm_size - 1);
134
135 sc->sc_memsize = ecm.ecm_size;
136
137 if (bus_space_map(sc->sc_iot, EISA_SLOT_ADDR(ea->ea_slot) + 0xc00, 16,
138 0, &sc->sc_ioh) != 0) {
139 printf("%s: unable to map i/o space\n", sc->sc_dev.dv_xname);
140 return;
141 }
142 if (bus_space_map(sc->sc_memt, ecm.ecm_addr, sc->sc_memsize,
143 0, &sc->sc_memh) != 0) {
144 printf("%s: unable to map memory space\n", sc->sc_dev.dv_xname);
145 return;
146 }
147
148 if (eisa_conf_read_irq(ea->ea_ec, ea->ea_slot,
149 DEPCA_ECU_FUNC_NETINTR, 0, &eci) != 0) {
150 printf("%s: unable to determine IRQ\n",
151 sc->sc_dev.dv_xname);
152 return;
153 }
154
155 esc->sc_irq = eci.eci_irq;
156 esc->sc_ist = eci.eci_ist;
157
158 depca_attach(sc);
159 }
160
161 static void *
162 depca_eisa_intr_establish(struct depca_softc *parent, struct lance_softc *child)
163 {
164 struct depca_eisa_softc *esc = (void *) parent;
165 eisa_intr_handle_t ih;
166 const char *intrstr;
167 void *rv;
168
169 if (eisa_intr_map(esc->sc_ec, esc->sc_irq, &ih)) {
170 printf("%s: unable to map interrupt (%d)\n",
171 parent->sc_dev.dv_xname, esc->sc_irq);
172 return (NULL);
173 }
174 intrstr = eisa_intr_string(esc->sc_ec, ih);
175 rv = eisa_intr_establish(esc->sc_ec, ih, esc->sc_ist, IPL_NET,
176 (esc->sc_ist == IST_LEVEL) ? am7990_intr : depca_intredge, child);
177 if (rv == NULL) {
178 printf("%s: unable to establish interrupt",
179 parent->sc_dev.dv_xname);
180 if (intrstr != NULL)
181 printf(" at %s", intrstr);
182 printf("\n");
183 return (NULL);
184 }
185 if (intrstr != NULL)
186 printf("%s: interrupting at %s\n", parent->sc_dev.dv_xname,
187 intrstr);
188
189 return (rv);
190 }
Cache object: d24bda6d1285d5b367bac6f80edb3f7b
|