if_ae_nubus.c revision 1.31 1 1.31 thorpej /* $NetBSD: if_ae_nubus.c,v 1.31 2001/02/12 18:49:03 thorpej Exp $ */
2 1.1 scottr
3 1.1 scottr /*
4 1.1 scottr * Copyright (C) 1997 Scott Reynolds
5 1.1 scottr * All rights reserved.
6 1.1 scottr *
7 1.1 scottr * Redistribution and use in source and binary forms, with or without
8 1.1 scottr * modification, are permitted provided that the following conditions
9 1.1 scottr * are met:
10 1.1 scottr * 1. Redistributions of source code must retain the above copyright
11 1.1 scottr * notice, this list of conditions and the following disclaimer.
12 1.1 scottr * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 scottr * notice, this list of conditions and the following disclaimer in the
14 1.1 scottr * documentation and/or other materials provided with the distribution.
15 1.21 scottr * 3. The name of the author may not be used to endorse or promote products
16 1.1 scottr * derived from this software without specific prior written permission.
17 1.1 scottr *
18 1.1 scottr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 1.1 scottr * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 1.1 scottr * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 1.1 scottr * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 1.1 scottr * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 1.1 scottr * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 1.1 scottr * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 1.1 scottr * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 1.1 scottr * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 1.1 scottr * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 1.1 scottr */
29 1.11 scottr /*
30 1.11 scottr * Some parts are derived from code adapted for MacBSD by Brad Parker
31 1.11 scottr * <brad (at) fcr.com>.
32 1.11 scottr *
33 1.11 scottr * Currently supports:
34 1.11 scottr * Apple NB Ethernet Card
35 1.11 scottr * Apple NB Ethernet Card II
36 1.11 scottr * Interlan A310 NuBus Ethernet card
37 1.11 scottr * Cayman Systems GatorCard
38 1.11 scottr * Asante MacCon II/E
39 1.11 scottr * Kinetics EtherPort SE/30
40 1.11 scottr */
41 1.1 scottr
42 1.1 scottr #include <sys/param.h>
43 1.1 scottr #include <sys/device.h>
44 1.1 scottr #include <sys/errno.h>
45 1.1 scottr #include <sys/ioctl.h>
46 1.14 scottr #include <sys/malloc.h>
47 1.1 scottr #include <sys/socket.h>
48 1.4 scottr #include <sys/syslog.h>
49 1.1 scottr #include <sys/systm.h>
50 1.1 scottr
51 1.1 scottr #include <net/if.h>
52 1.24 thorpej #include <net/if_media.h>
53 1.7 is #include <net/if_ether.h>
54 1.1 scottr
55 1.1 scottr #include <machine/bus.h>
56 1.1 scottr #include <machine/viareg.h>
57 1.1 scottr
58 1.1 scottr #include <dev/ic/dp8390reg.h>
59 1.14 scottr #include <dev/ic/dp8390var.h>
60 1.26 scottr #include <mac68k/nubus/nubus.h>
61 1.19 scottr #include <mac68k/dev/if_aevar.h>
62 1.19 scottr #include <mac68k/dev/if_aereg.h>
63 1.1 scottr
64 1.1 scottr static int ae_nubus_match __P((struct device *, struct cfdata *, void *));
65 1.1 scottr static void ae_nubus_attach __P((struct device *, struct device *, void *));
66 1.18 scottr static int ae_nb_card_vendor __P((bus_space_tag_t, bus_space_handle_t,
67 1.18 scottr struct nubus_attach_args *));
68 1.18 scottr static int ae_nb_get_enaddr __P((bus_space_tag_t, bus_space_handle_t,
69 1.18 scottr struct nubus_attach_args *, u_int8_t *));
70 1.11 scottr #ifdef DEBUG
71 1.4 scottr static void ae_nb_watchdog __P((struct ifnet *));
72 1.11 scottr #endif
73 1.1 scottr
74 1.25 scottr void ae_nubus_intr __P((void *));
75 1.22 thorpej
76 1.1 scottr struct cfattach ae_nubus_ca = {
77 1.14 scottr sizeof(struct dp8390_softc), ae_nubus_match, ae_nubus_attach
78 1.1 scottr };
79 1.1 scottr
80 1.1 scottr static int
81 1.1 scottr ae_nubus_match(parent, cf, aux)
82 1.1 scottr struct device *parent;
83 1.1 scottr struct cfdata *cf;
84 1.1 scottr void *aux;
85 1.1 scottr {
86 1.14 scottr struct nubus_attach_args *na = (struct nubus_attach_args *)aux;
87 1.1 scottr bus_space_handle_t bsh;
88 1.1 scottr int rv;
89 1.1 scottr
90 1.1 scottr if (bus_space_map(na->na_tag, NUBUS_SLOT2PA(na->slot), NBMEMSIZE,
91 1.1 scottr 0, &bsh))
92 1.1 scottr return (0);
93 1.1 scottr
94 1.1 scottr rv = 0;
95 1.1 scottr
96 1.1 scottr if (na->category == NUBUS_CATEGORY_NETWORK &&
97 1.1 scottr na->type == NUBUS_TYPE_ETHERNET) {
98 1.18 scottr switch (ae_nb_card_vendor(na->na_tag, bsh, na)) {
99 1.14 scottr case DP8390_VENDOR_APPLE:
100 1.14 scottr case DP8390_VENDOR_ASANTE:
101 1.14 scottr case DP8390_VENDOR_FARALLON:
102 1.14 scottr case DP8390_VENDOR_INTERLAN:
103 1.14 scottr case DP8390_VENDOR_KINETICS:
104 1.27 scottr case DP8390_VENDOR_CABLETRON:
105 1.1 scottr rv = 1;
106 1.1 scottr break;
107 1.14 scottr case DP8390_VENDOR_DAYNA:
108 1.1 scottr rv = UNSUPP;
109 1.1 scottr break;
110 1.1 scottr default:
111 1.1 scottr break;
112 1.1 scottr }
113 1.1 scottr }
114 1.1 scottr
115 1.1 scottr bus_space_unmap(na->na_tag, bsh, NBMEMSIZE);
116 1.1 scottr
117 1.1 scottr return rv;
118 1.1 scottr }
119 1.1 scottr
120 1.1 scottr /*
121 1.1 scottr * Install interface into kernel networking data structures
122 1.1 scottr */
123 1.1 scottr static void
124 1.1 scottr ae_nubus_attach(parent, self, aux)
125 1.1 scottr struct device *parent, *self;
126 1.1 scottr void *aux;
127 1.1 scottr {
128 1.14 scottr struct dp8390_softc *sc = (struct dp8390_softc *)self;
129 1.14 scottr struct nubus_attach_args *na = (struct nubus_attach_args *)aux;
130 1.11 scottr #ifdef DEBUG
131 1.7 is struct ifnet *ifp = &sc->sc_ec.ec_if;
132 1.11 scottr #endif
133 1.1 scottr bus_space_tag_t bst;
134 1.1 scottr bus_space_handle_t bsh;
135 1.11 scottr int i, success;
136 1.14 scottr char *cardtype;
137 1.1 scottr
138 1.1 scottr bst = na->na_tag;
139 1.1 scottr if (bus_space_map(bst, NUBUS_SLOT2PA(na->slot), NBMEMSIZE,
140 1.1 scottr 0, &bsh)) {
141 1.1 scottr printf(": can't map memory space\n");
142 1.1 scottr return;
143 1.1 scottr }
144 1.1 scottr
145 1.4 scottr sc->sc_regt = sc->sc_buft = bst;
146 1.3 scottr sc->sc_flags = self->dv_cfdata->cf_flags;
147 1.14 scottr
148 1.18 scottr cardtype = nubus_get_card_name(bst, bsh, na->fmt);
149 1.14 scottr
150 1.14 scottr sc->is790 = 0;
151 1.14 scottr
152 1.14 scottr sc->mem_start = 0;
153 1.1 scottr sc->mem_size = 0;
154 1.1 scottr
155 1.1 scottr success = 0;
156 1.1 scottr
157 1.23 briggs switch (ae_nb_card_vendor(bst, bsh, na)) {
158 1.14 scottr case DP8390_VENDOR_APPLE: /* Apple-compatible cards */
159 1.14 scottr case DP8390_VENDOR_ASANTE:
160 1.11 scottr /* Map register offsets */
161 1.11 scottr for (i = 0; i < 16; i++) /* reverse order, longword aligned */
162 1.11 scottr sc->sc_reg_map[i] = (15 - i) << 2;
163 1.11 scottr
164 1.16 scottr sc->dcr_reg = (ED_DCR_FT1 | ED_DCR_WTS | ED_DCR_LS);
165 1.1 scottr if (bus_space_subregion(bst, bsh,
166 1.4 scottr AE_REG_OFFSET, AE_REG_SIZE, &sc->sc_regh)) {
167 1.1 scottr printf(": failed to map register space\n");
168 1.1 scottr break;
169 1.1 scottr }
170 1.1 scottr if ((sc->mem_size = ae_size_card_memory(bst, bsh,
171 1.1 scottr AE_DATA_OFFSET)) == 0) {
172 1.1 scottr printf(": failed to determine size of RAM.\n");
173 1.1 scottr break;
174 1.1 scottr }
175 1.1 scottr if (bus_space_subregion(bst, bsh,
176 1.4 scottr AE_DATA_OFFSET, sc->mem_size, &sc->sc_bufh)) {
177 1.1 scottr printf(": failed to map register space\n");
178 1.1 scottr break;
179 1.1 scottr }
180 1.3 scottr #ifdef AE_OLD_GET_ENADDR
181 1.1 scottr /* Get station address from on-board ROM */
182 1.1 scottr for (i = 0; i < ETHER_ADDR_LEN; ++i)
183 1.14 scottr sc->sc_enaddr[i] =
184 1.1 scottr bus_space_read_1(bst, bsh, (AE_ROM_OFFSET + i * 2));
185 1.3 scottr #else
186 1.18 scottr if (ae_nb_get_enaddr(bst, bsh, na, sc->sc_enaddr)) {
187 1.3 scottr printf(": can't find MAC address\n");
188 1.3 scottr break;
189 1.3 scottr }
190 1.3 scottr #endif
191 1.1 scottr
192 1.1 scottr success = 1;
193 1.1 scottr break;
194 1.1 scottr
195 1.14 scottr case DP8390_VENDOR_DAYNA:
196 1.11 scottr /* Map register offsets */
197 1.11 scottr for (i = 0; i < 16; i++) /* normal order, longword aligned */
198 1.11 scottr sc->sc_reg_map[i] = i << 2;
199 1.11 scottr
200 1.16 scottr sc->dcr_reg = (ED_DCR_FT1 | ED_DCR_WTS | ED_DCR_LS);
201 1.1 scottr if (bus_space_subregion(bst, bsh,
202 1.4 scottr DP_REG_OFFSET, AE_REG_SIZE, &sc->sc_regh)) {
203 1.1 scottr printf(": failed to map register space\n");
204 1.1 scottr break;
205 1.1 scottr }
206 1.1 scottr sc->mem_size = 8192;
207 1.1 scottr if (bus_space_subregion(bst, bsh,
208 1.4 scottr DP_DATA_OFFSET, sc->mem_size, &sc->sc_bufh)) {
209 1.1 scottr printf(": failed to map register space\n");
210 1.1 scottr break;
211 1.1 scottr }
212 1.3 scottr #ifdef AE_OLD_GET_ENADDR
213 1.1 scottr /* Get station address from on-board ROM */
214 1.1 scottr for (i = 0; i < ETHER_ADDR_LEN; ++i)
215 1.14 scottr sc->sc_enaddr[i] =
216 1.1 scottr bus_space_read_1(bst, bsh, (DP_ROM_OFFSET + i * 2));
217 1.3 scottr #else
218 1.18 scottr if (ae_nb_get_enaddr(bst, bsh, na, sc->sc_enaddr)) {
219 1.3 scottr printf(": can't find MAC address\n");
220 1.3 scottr break;
221 1.3 scottr }
222 1.3 scottr #endif
223 1.1 scottr
224 1.1 scottr printf(": unsupported Dayna hardware\n");
225 1.1 scottr break;
226 1.1 scottr
227 1.14 scottr case DP8390_VENDOR_FARALLON:
228 1.11 scottr /* Map register offsets */
229 1.11 scottr for (i = 0; i < 16; i++) /* reverse order, longword aligned */
230 1.11 scottr sc->sc_reg_map[i] = (15 - i) << 2;
231 1.11 scottr
232 1.16 scottr sc->dcr_reg = (ED_DCR_FT1 | ED_DCR_WTS | ED_DCR_LS);
233 1.1 scottr if (bus_space_subregion(bst, bsh,
234 1.4 scottr AE_REG_OFFSET, AE_REG_SIZE, &sc->sc_regh)) {
235 1.1 scottr printf(": failed to map register space\n");
236 1.1 scottr break;
237 1.1 scottr }
238 1.1 scottr if ((sc->mem_size = ae_size_card_memory(bst, bsh,
239 1.1 scottr AE_DATA_OFFSET)) == 0) {
240 1.1 scottr printf(": failed to determine size of RAM.\n");
241 1.1 scottr break;
242 1.1 scottr }
243 1.1 scottr if (bus_space_subregion(bst, bsh,
244 1.4 scottr AE_DATA_OFFSET, sc->mem_size, &sc->sc_bufh)) {
245 1.1 scottr printf(": failed to map register space\n");
246 1.1 scottr break;
247 1.1 scottr }
248 1.3 scottr #ifdef AE_OLD_GET_ENADDR
249 1.1 scottr /* Get station address from on-board ROM */
250 1.1 scottr for (i = 0; i < ETHER_ADDR_LEN; ++i)
251 1.14 scottr sc->sc_enaddr[i] =
252 1.1 scottr bus_space_read_1(bst, bsh, (FE_ROM_OFFSET + i));
253 1.6 scottr #else
254 1.18 scottr if (ae_nb_get_enaddr(bst, bsh, na, sc->sc_enaddr)) {
255 1.6 scottr printf(": can't find MAC address\n");
256 1.6 scottr break;
257 1.6 scottr }
258 1.3 scottr #endif
259 1.1 scottr
260 1.1 scottr success = 1;
261 1.1 scottr break;
262 1.1 scottr
263 1.14 scottr case DP8390_VENDOR_INTERLAN:
264 1.11 scottr /* Map register offsets */
265 1.11 scottr for (i = 0; i < 16; i++) /* normal order, longword aligned */
266 1.11 scottr sc->sc_reg_map[i] = i << 2;
267 1.11 scottr
268 1.16 scottr sc->dcr_reg = (ED_DCR_FT1 | ED_DCR_WTS | ED_DCR_LS);
269 1.2 scottr if (bus_space_subregion(bst, bsh,
270 1.4 scottr GC_REG_OFFSET, AE_REG_SIZE, &sc->sc_regh)) {
271 1.2 scottr printf(": failed to map register space\n");
272 1.2 scottr break;
273 1.2 scottr }
274 1.2 scottr if ((sc->mem_size = ae_size_card_memory(bst, bsh,
275 1.3 scottr GC_DATA_OFFSET)) == 0) {
276 1.2 scottr printf(": failed to determine size of RAM.\n");
277 1.2 scottr break;
278 1.2 scottr }
279 1.2 scottr if (bus_space_subregion(bst, bsh,
280 1.4 scottr GC_DATA_OFFSET, sc->mem_size, &sc->sc_bufh)) {
281 1.2 scottr printf(": failed to map register space\n");
282 1.2 scottr break;
283 1.2 scottr }
284 1.2 scottr
285 1.3 scottr /* reset the NIC chip */
286 1.3 scottr bus_space_write_1(bst, bsh, GC_RESET_OFFSET, 0);
287 1.3 scottr
288 1.18 scottr if (ae_nb_get_enaddr(bst, bsh, na, sc->sc_enaddr)) {
289 1.9 scottr /* Fall back to snarf directly from ROM. Ick. */
290 1.9 scottr for (i = 0; i < ETHER_ADDR_LEN; ++i)
291 1.14 scottr sc->sc_enaddr[i] =
292 1.9 scottr bus_space_read_1(bst, bsh,
293 1.9 scottr (GC_ROM_OFFSET + i * 4));
294 1.2 scottr }
295 1.2 scottr
296 1.2 scottr success = 1;
297 1.2 scottr break;
298 1.2 scottr
299 1.14 scottr case DP8390_VENDOR_KINETICS:
300 1.11 scottr /* Map register offsets */
301 1.11 scottr for (i = 0; i < 16; i++) /* normal order, longword aligned */
302 1.11 scottr sc->sc_reg_map[i] = i << 2;
303 1.11 scottr
304 1.3 scottr if (bus_space_subregion(bst, bsh,
305 1.4 scottr KE_REG_OFFSET, AE_REG_SIZE, &sc->sc_regh)) {
306 1.3 scottr printf(": failed to map register space\n");
307 1.3 scottr break;
308 1.3 scottr }
309 1.3 scottr if ((sc->mem_size = ae_size_card_memory(bst, bsh,
310 1.3 scottr KE_DATA_OFFSET)) == 0) {
311 1.3 scottr printf(": failed to determine size of RAM.\n");
312 1.3 scottr break;
313 1.3 scottr }
314 1.3 scottr if (bus_space_subregion(bst, bsh,
315 1.4 scottr KE_DATA_OFFSET, sc->mem_size, &sc->sc_bufh)) {
316 1.3 scottr printf(": failed to map register space\n");
317 1.3 scottr break;
318 1.3 scottr }
319 1.18 scottr if (ae_nb_get_enaddr(bst, bsh, na, sc->sc_enaddr)) {
320 1.3 scottr printf(": can't find MAC address\n");
321 1.3 scottr break;
322 1.3 scottr }
323 1.3 scottr
324 1.3 scottr success = 1;
325 1.3 scottr break;
326 1.3 scottr
327 1.27 scottr case DP8390_VENDOR_CABLETRON:
328 1.27 scottr /* Map register offsets */
329 1.27 scottr for (i = 0; i < 16; i++)
330 1.27 scottr sc->sc_reg_map[i] = i << 1 ; /* normal order, word aligned */
331 1.27 scottr sc->dcr_reg = (ED_DCR_FT1 | ED_DCR_WTS | ED_DCR_LS);
332 1.27 scottr if (bus_space_subregion(bst, bsh,
333 1.27 scottr CT_REG_OFFSET, AE_REG_SIZE, &sc->sc_regh)) {
334 1.27 scottr printf(": failed to map register space\n");
335 1.27 scottr break;
336 1.27 scottr }
337 1.27 scottr if ((sc->mem_size = ae_size_card_memory(bst, bsh,
338 1.27 scottr CT_DATA_OFFSET)) == 0) {
339 1.27 scottr printf(": failed to determine size of RAM.\n");
340 1.27 scottr break;
341 1.27 scottr }
342 1.27 scottr if (bus_space_subregion(bst, bsh,
343 1.27 scottr CT_DATA_OFFSET, sc->mem_size, &sc->sc_bufh)) {
344 1.27 scottr printf(": failed to map register space\n");
345 1.27 scottr break;
346 1.27 scottr }
347 1.27 scottr if (ae_nb_get_enaddr(bst, bsh, na, sc->sc_enaddr)) {
348 1.27 scottr printf(": can't find MAC address\n");
349 1.27 scottr break;
350 1.27 scottr }
351 1.27 scottr success = 1;
352 1.27 scottr break;
353 1.1 scottr default:
354 1.1 scottr break;
355 1.1 scottr }
356 1.1 scottr
357 1.1 scottr if (!success) {
358 1.1 scottr bus_space_unmap(bst, bsh, NBMEMSIZE);
359 1.1 scottr return;
360 1.1 scottr }
361 1.1 scottr
362 1.14 scottr /*
363 1.14 scottr * Override test_mem and write_mbuf functions; other defaults
364 1.14 scottr * already work properly.
365 1.14 scottr */
366 1.14 scottr sc->test_mem = ae_test_mem;
367 1.14 scottr sc->write_mbuf = ae_write_mbuf;
368 1.11 scottr #ifdef DEBUG
369 1.4 scottr ifp->if_watchdog = ae_nb_watchdog; /* Override watchdog */
370 1.11 scottr #endif
371 1.31 thorpej sc->sc_media_init = dp8390_media_init;
372 1.14 scottr
373 1.22 thorpej /* Interface is always enabled. */
374 1.22 thorpej sc->sc_enabled = 1;
375 1.22 thorpej
376 1.23 briggs printf(": %s, %dKB memory\n", cardtype, sc->mem_size / 1024);
377 1.22 thorpej
378 1.31 thorpej if (dp8390_config(sc)) {
379 1.5 scottr bus_space_unmap(bst, bsh, NBMEMSIZE);
380 1.5 scottr return;
381 1.5 scottr }
382 1.1 scottr
383 1.22 thorpej /* make sure interrupts are vectored to us */
384 1.22 thorpej add_nubus_intr(na->slot, ae_nubus_intr, sc);
385 1.22 thorpej }
386 1.22 thorpej
387 1.22 thorpej void
388 1.25 scottr ae_nubus_intr(arg)
389 1.22 thorpej void *arg;
390 1.22 thorpej {
391 1.23 briggs struct dp8390_softc *sc = (struct dp8390_softc *)arg;
392 1.23 briggs
393 1.25 scottr (void)dp8390_intr(sc);
394 1.1 scottr }
395 1.1 scottr
396 1.1 scottr static int
397 1.18 scottr ae_nb_card_vendor(bst, bsh, na)
398 1.18 scottr bus_space_tag_t bst;
399 1.18 scottr bus_space_handle_t bsh;
400 1.1 scottr struct nubus_attach_args *na;
401 1.1 scottr {
402 1.1 scottr int vendor;
403 1.1 scottr
404 1.1 scottr switch (na->drsw) {
405 1.1 scottr case NUBUS_DRSW_3COM:
406 1.12 briggs switch (na->drhw) {
407 1.12 briggs case NUBUS_DRHW_APPLE_SN:
408 1.17 briggs case NUBUS_DRHW_APPLE_SNT:
409 1.14 scottr vendor = DP8390_VENDOR_UNKNOWN;
410 1.12 briggs break;
411 1.12 briggs default:
412 1.14 scottr vendor = DP8390_VENDOR_APPLE;
413 1.12 briggs break;
414 1.12 briggs }
415 1.12 briggs break;
416 1.1 scottr case NUBUS_DRSW_APPLE:
417 1.29 scottr if (na->drhw == NUBUS_DRHW_ASANTE_LC) {
418 1.29 scottr vendor = DP8390_VENDOR_UNKNOWN;
419 1.29 scottr break;
420 1.29 scottr }
421 1.29 scottr /* FALLTHROUGH */
422 1.20 briggs case NUBUS_DRSW_DAYNA2:
423 1.1 scottr case NUBUS_DRSW_TECHWORKS:
424 1.28 scottr case NUBUS_DRSW_TFLLAN:
425 1.27 scottr if (na->drhw == NUBUS_DRHW_CABLETRON) {
426 1.27 scottr vendor = DP8390_VENDOR_CABLETRON;
427 1.27 scottr } else {
428 1.27 scottr vendor = DP8390_VENDOR_APPLE;
429 1.27 scottr }
430 1.1 scottr break;
431 1.1 scottr case NUBUS_DRSW_ASANTE:
432 1.14 scottr vendor = DP8390_VENDOR_ASANTE;
433 1.1 scottr break;
434 1.1 scottr case NUBUS_DRSW_FARALLON:
435 1.14 scottr vendor = DP8390_VENDOR_FARALLON;
436 1.1 scottr break;
437 1.1 scottr case NUBUS_DRSW_GATOR:
438 1.1 scottr switch (na->drhw) {
439 1.1 scottr default:
440 1.1 scottr case NUBUS_DRHW_INTERLAN:
441 1.14 scottr vendor = DP8390_VENDOR_INTERLAN;
442 1.1 scottr break;
443 1.1 scottr case NUBUS_DRHW_KINETICS:
444 1.18 scottr if (strncmp(nubus_get_card_name(bst, bsh, na->fmt),
445 1.18 scottr "EtherPort", 9) == 0)
446 1.14 scottr vendor = DP8390_VENDOR_KINETICS;
447 1.2 scottr else
448 1.14 scottr vendor = DP8390_VENDOR_DAYNA;
449 1.1 scottr break;
450 1.1 scottr }
451 1.1 scottr break;
452 1.1 scottr default:
453 1.14 scottr vendor = DP8390_VENDOR_UNKNOWN;
454 1.1 scottr }
455 1.1 scottr return vendor;
456 1.3 scottr }
457 1.3 scottr
458 1.3 scottr static int
459 1.18 scottr ae_nb_get_enaddr(bst, bsh, na, ep)
460 1.18 scottr bus_space_tag_t bst;
461 1.18 scottr bus_space_handle_t bsh;
462 1.3 scottr struct nubus_attach_args *na;
463 1.3 scottr u_int8_t *ep;
464 1.3 scottr {
465 1.3 scottr nubus_dir dir;
466 1.3 scottr nubus_dirent dirent;
467 1.28 scottr int rv;
468 1.3 scottr
469 1.3 scottr /*
470 1.28 scottr * XXX - note hardwired resource IDs here; these are assumed to
471 1.28 scottr * be used by all cards, but should be fixed when we find out
472 1.28 scottr * more about Ethernet card resources.
473 1.3 scottr */
474 1.3 scottr nubus_get_main_dir(na->fmt, &dir);
475 1.28 scottr switch (ae_nb_card_vendor(bst, bsh, na)) {
476 1.28 scottr case DP8390_VENDOR_APPLE:
477 1.28 scottr if (na->drsw == NUBUS_DRSW_TFLLAN) { /* TFL LAN E410/E420 */
478 1.28 scottr rv = nubus_find_rsrc(bst, bsh, na->fmt,
479 1.28 scottr &dir, 0x08, &dirent);
480 1.28 scottr break;
481 1.28 scottr }
482 1.28 scottr /*FALLTHROUGH*/
483 1.28 scottr default:
484 1.28 scottr rv = nubus_find_rsrc(bst, bsh, na->fmt, &dir, 0x80, &dirent);
485 1.28 scottr break;
486 1.28 scottr }
487 1.28 scottr if (rv <= 0)
488 1.3 scottr return 1;
489 1.3 scottr nubus_get_dir_from_rsrc(na->fmt, &dirent, &dir);
490 1.18 scottr if (nubus_find_rsrc(bst, bsh, na->fmt, &dir, 0x80, &dirent) <= 0)
491 1.3 scottr return 1;
492 1.18 scottr if (nubus_get_ind_data(bst, bsh,
493 1.18 scottr na->fmt, &dirent, ep, ETHER_ADDR_LEN) <= 0)
494 1.3 scottr return 1;
495 1.3 scottr
496 1.3 scottr return 0;
497 1.4 scottr }
498 1.4 scottr
499 1.11 scottr #ifdef DEBUG
500 1.4 scottr static void
501 1.4 scottr ae_nb_watchdog(ifp)
502 1.4 scottr struct ifnet *ifp;
503 1.4 scottr {
504 1.14 scottr struct dp8390_softc *sc = ifp->if_softc;
505 1.4 scottr
506 1.4 scottr /*
507 1.4 scottr * This is a kludge! The via code seems to miss slot interrupts
508 1.4 scottr * sometimes. This kludges around that by calling the handler
509 1.4 scottr * by hand if the watchdog is activated. -- XXX (akb)
510 1.4 scottr */
511 1.25 scottr (*via2itab[1])((void *)1);
512 1.4 scottr
513 1.4 scottr log(LOG_ERR, "%s: device timeout\n", sc->sc_dev.dv_xname);
514 1.7 is ++ifp->if_oerrors;
515 1.4 scottr
516 1.14 scottr dp8390_reset(sc);
517 1.1 scottr }
518 1.11 scottr #endif
519