if_ae_nubus.c revision 1.43 1 1.43 skrll /* $NetBSD: if_ae_nubus.c,v 1.43 2020/02/05 08:36:56 skrll 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.34 lukem
42 1.34 lukem #include <sys/cdefs.h>
43 1.43 skrll __KERNEL_RCSID(0, "$NetBSD: if_ae_nubus.c,v 1.43 2020/02/05 08:36:56 skrll Exp $");
44 1.1 scottr
45 1.1 scottr #include <sys/param.h>
46 1.1 scottr #include <sys/device.h>
47 1.1 scottr #include <sys/errno.h>
48 1.1 scottr #include <sys/ioctl.h>
49 1.14 scottr #include <sys/malloc.h>
50 1.1 scottr #include <sys/socket.h>
51 1.4 scottr #include <sys/syslog.h>
52 1.1 scottr #include <sys/systm.h>
53 1.1 scottr
54 1.1 scottr #include <net/if.h>
55 1.24 thorpej #include <net/if_media.h>
56 1.7 is #include <net/if_ether.h>
57 1.1 scottr
58 1.1 scottr #include <machine/bus.h>
59 1.1 scottr #include <machine/viareg.h>
60 1.1 scottr
61 1.1 scottr #include <dev/ic/dp8390reg.h>
62 1.14 scottr #include <dev/ic/dp8390var.h>
63 1.26 scottr #include <mac68k/nubus/nubus.h>
64 1.19 scottr #include <mac68k/dev/if_aevar.h>
65 1.19 scottr #include <mac68k/dev/if_aereg.h>
66 1.1 scottr
67 1.41 tsutsui static int ae_nubus_match(device_t, cfdata_t, void *);
68 1.41 tsutsui static void ae_nubus_attach(device_t, device_t, void *);
69 1.35 chs static int ae_nb_card_vendor(bus_space_tag_t, bus_space_handle_t,
70 1.35 chs struct nubus_attach_args *);
71 1.35 chs static int ae_nb_get_enaddr(bus_space_tag_t, bus_space_handle_t,
72 1.35 chs struct nubus_attach_args *, u_int8_t *);
73 1.11 scottr #ifdef DEBUG
74 1.35 chs static void ae_nb_watchdog(struct ifnet *);
75 1.11 scottr #endif
76 1.1 scottr
77 1.35 chs void ae_nubus_intr(void *);
78 1.22 thorpej
79 1.41 tsutsui CFATTACH_DECL_NEW(ae_nubus, sizeof(struct dp8390_softc),
80 1.33 thorpej ae_nubus_match, ae_nubus_attach, NULL, NULL);
81 1.1 scottr
82 1.1 scottr static int
83 1.41 tsutsui ae_nubus_match(device_t parent, cfdata_t cf, void *aux)
84 1.1 scottr {
85 1.41 tsutsui struct nubus_attach_args *na = aux;
86 1.1 scottr bus_space_handle_t bsh;
87 1.1 scottr int rv;
88 1.1 scottr
89 1.1 scottr if (bus_space_map(na->na_tag, NUBUS_SLOT2PA(na->slot), NBMEMSIZE,
90 1.1 scottr 0, &bsh))
91 1.1 scottr return (0);
92 1.1 scottr
93 1.1 scottr rv = 0;
94 1.1 scottr
95 1.1 scottr if (na->category == NUBUS_CATEGORY_NETWORK &&
96 1.1 scottr na->type == NUBUS_TYPE_ETHERNET) {
97 1.18 scottr switch (ae_nb_card_vendor(na->na_tag, bsh, na)) {
98 1.14 scottr case DP8390_VENDOR_APPLE:
99 1.14 scottr case DP8390_VENDOR_ASANTE:
100 1.14 scottr case DP8390_VENDOR_FARALLON:
101 1.14 scottr case DP8390_VENDOR_INTERLAN:
102 1.14 scottr case DP8390_VENDOR_KINETICS:
103 1.27 scottr case DP8390_VENDOR_CABLETRON:
104 1.1 scottr rv = 1;
105 1.1 scottr break;
106 1.14 scottr case DP8390_VENDOR_DAYNA:
107 1.1 scottr rv = UNSUPP;
108 1.1 scottr break;
109 1.1 scottr default:
110 1.1 scottr break;
111 1.1 scottr }
112 1.1 scottr }
113 1.1 scottr
114 1.1 scottr bus_space_unmap(na->na_tag, bsh, NBMEMSIZE);
115 1.1 scottr
116 1.1 scottr return rv;
117 1.1 scottr }
118 1.1 scottr
119 1.1 scottr /*
120 1.1 scottr * Install interface into kernel networking data structures
121 1.1 scottr */
122 1.1 scottr static void
123 1.41 tsutsui ae_nubus_attach(device_t parent, device_t self, void *aux)
124 1.1 scottr {
125 1.41 tsutsui struct dp8390_softc *sc = device_private(self);
126 1.41 tsutsui struct nubus_attach_args *na = aux;
127 1.11 scottr #ifdef DEBUG
128 1.7 is struct ifnet *ifp = &sc->sc_ec.ec_if;
129 1.11 scottr #endif
130 1.1 scottr bus_space_tag_t bst;
131 1.1 scottr bus_space_handle_t bsh;
132 1.11 scottr int i, success;
133 1.36 rjs const char *cardtype;
134 1.1 scottr
135 1.41 tsutsui sc->sc_dev = self;
136 1.1 scottr bst = na->na_tag;
137 1.1 scottr if (bus_space_map(bst, NUBUS_SLOT2PA(na->slot), NBMEMSIZE,
138 1.1 scottr 0, &bsh)) {
139 1.41 tsutsui aprint_error(": can't map memory space\n");
140 1.1 scottr return;
141 1.1 scottr }
142 1.1 scottr
143 1.4 scottr sc->sc_regt = sc->sc_buft = bst;
144 1.38 thorpej sc->sc_flags = device_cfdata(self)->cf_flags;
145 1.14 scottr
146 1.18 scottr cardtype = nubus_get_card_name(bst, bsh, na->fmt);
147 1.14 scottr
148 1.14 scottr sc->is790 = 0;
149 1.14 scottr
150 1.14 scottr sc->mem_start = 0;
151 1.1 scottr sc->mem_size = 0;
152 1.1 scottr
153 1.1 scottr success = 0;
154 1.1 scottr
155 1.23 briggs switch (ae_nb_card_vendor(bst, bsh, na)) {
156 1.14 scottr case DP8390_VENDOR_APPLE: /* Apple-compatible cards */
157 1.14 scottr case DP8390_VENDOR_ASANTE:
158 1.11 scottr /* Map register offsets */
159 1.11 scottr for (i = 0; i < 16; i++) /* reverse order, longword aligned */
160 1.11 scottr sc->sc_reg_map[i] = (15 - i) << 2;
161 1.11 scottr
162 1.16 scottr sc->dcr_reg = (ED_DCR_FT1 | ED_DCR_WTS | ED_DCR_LS);
163 1.1 scottr if (bus_space_subregion(bst, bsh,
164 1.4 scottr AE_REG_OFFSET, AE_REG_SIZE, &sc->sc_regh)) {
165 1.41 tsutsui aprint_error(": failed to map register space\n");
166 1.1 scottr break;
167 1.1 scottr }
168 1.1 scottr if ((sc->mem_size = ae_size_card_memory(bst, bsh,
169 1.1 scottr AE_DATA_OFFSET)) == 0) {
170 1.41 tsutsui aprint_error(": failed to determine size of RAM.\n");
171 1.1 scottr break;
172 1.1 scottr }
173 1.1 scottr if (bus_space_subregion(bst, bsh,
174 1.4 scottr AE_DATA_OFFSET, sc->mem_size, &sc->sc_bufh)) {
175 1.41 tsutsui aprint_error(": failed to map register space\n");
176 1.1 scottr break;
177 1.1 scottr }
178 1.3 scottr #ifdef AE_OLD_GET_ENADDR
179 1.1 scottr /* Get station address from on-board ROM */
180 1.1 scottr for (i = 0; i < ETHER_ADDR_LEN; ++i)
181 1.14 scottr sc->sc_enaddr[i] =
182 1.1 scottr bus_space_read_1(bst, bsh, (AE_ROM_OFFSET + i * 2));
183 1.3 scottr #else
184 1.18 scottr if (ae_nb_get_enaddr(bst, bsh, na, sc->sc_enaddr)) {
185 1.41 tsutsui aprint_error(": can't find MAC address\n");
186 1.3 scottr break;
187 1.3 scottr }
188 1.3 scottr #endif
189 1.1 scottr
190 1.1 scottr success = 1;
191 1.1 scottr break;
192 1.1 scottr
193 1.14 scottr case DP8390_VENDOR_DAYNA:
194 1.11 scottr /* Map register offsets */
195 1.11 scottr for (i = 0; i < 16; i++) /* normal order, longword aligned */
196 1.11 scottr sc->sc_reg_map[i] = i << 2;
197 1.11 scottr
198 1.16 scottr sc->dcr_reg = (ED_DCR_FT1 | ED_DCR_WTS | ED_DCR_LS);
199 1.1 scottr if (bus_space_subregion(bst, bsh,
200 1.4 scottr DP_REG_OFFSET, AE_REG_SIZE, &sc->sc_regh)) {
201 1.41 tsutsui aprint_error(": failed to map register space\n");
202 1.1 scottr break;
203 1.1 scottr }
204 1.1 scottr sc->mem_size = 8192;
205 1.1 scottr if (bus_space_subregion(bst, bsh,
206 1.4 scottr DP_DATA_OFFSET, sc->mem_size, &sc->sc_bufh)) {
207 1.41 tsutsui aprint_error(": failed to map register space\n");
208 1.1 scottr break;
209 1.1 scottr }
210 1.3 scottr #ifdef AE_OLD_GET_ENADDR
211 1.1 scottr /* Get station address from on-board ROM */
212 1.1 scottr for (i = 0; i < ETHER_ADDR_LEN; ++i)
213 1.14 scottr sc->sc_enaddr[i] =
214 1.1 scottr bus_space_read_1(bst, bsh, (DP_ROM_OFFSET + i * 2));
215 1.3 scottr #else
216 1.18 scottr if (ae_nb_get_enaddr(bst, bsh, na, sc->sc_enaddr)) {
217 1.41 tsutsui aprint_error(": can't find MAC address\n");
218 1.3 scottr break;
219 1.3 scottr }
220 1.3 scottr #endif
221 1.1 scottr
222 1.41 tsutsui aprint_error(": unsupported Dayna hardware\n");
223 1.1 scottr break;
224 1.1 scottr
225 1.14 scottr case DP8390_VENDOR_FARALLON:
226 1.11 scottr /* Map register offsets */
227 1.11 scottr for (i = 0; i < 16; i++) /* reverse order, longword aligned */
228 1.11 scottr sc->sc_reg_map[i] = (15 - i) << 2;
229 1.11 scottr
230 1.16 scottr sc->dcr_reg = (ED_DCR_FT1 | ED_DCR_WTS | ED_DCR_LS);
231 1.1 scottr if (bus_space_subregion(bst, bsh,
232 1.4 scottr AE_REG_OFFSET, AE_REG_SIZE, &sc->sc_regh)) {
233 1.41 tsutsui aprint_error(": failed to map register space\n");
234 1.1 scottr break;
235 1.1 scottr }
236 1.1 scottr if ((sc->mem_size = ae_size_card_memory(bst, bsh,
237 1.1 scottr AE_DATA_OFFSET)) == 0) {
238 1.41 tsutsui aprint_error(": failed to determine size of RAM.\n");
239 1.1 scottr break;
240 1.1 scottr }
241 1.1 scottr if (bus_space_subregion(bst, bsh,
242 1.4 scottr AE_DATA_OFFSET, sc->mem_size, &sc->sc_bufh)) {
243 1.41 tsutsui aprint_error(": failed to map register space\n");
244 1.1 scottr break;
245 1.1 scottr }
246 1.3 scottr #ifdef AE_OLD_GET_ENADDR
247 1.1 scottr /* Get station address from on-board ROM */
248 1.1 scottr for (i = 0; i < ETHER_ADDR_LEN; ++i)
249 1.14 scottr sc->sc_enaddr[i] =
250 1.1 scottr bus_space_read_1(bst, bsh, (FE_ROM_OFFSET + i));
251 1.6 scottr #else
252 1.18 scottr if (ae_nb_get_enaddr(bst, bsh, na, sc->sc_enaddr)) {
253 1.41 tsutsui aprint_error(": can't find MAC address\n");
254 1.6 scottr break;
255 1.6 scottr }
256 1.3 scottr #endif
257 1.1 scottr
258 1.1 scottr success = 1;
259 1.1 scottr break;
260 1.1 scottr
261 1.14 scottr case DP8390_VENDOR_INTERLAN:
262 1.11 scottr /* Map register offsets */
263 1.11 scottr for (i = 0; i < 16; i++) /* normal order, longword aligned */
264 1.11 scottr sc->sc_reg_map[i] = i << 2;
265 1.11 scottr
266 1.16 scottr sc->dcr_reg = (ED_DCR_FT1 | ED_DCR_WTS | ED_DCR_LS);
267 1.2 scottr if (bus_space_subregion(bst, bsh,
268 1.4 scottr GC_REG_OFFSET, AE_REG_SIZE, &sc->sc_regh)) {
269 1.41 tsutsui aprint_error(": failed to map register space\n");
270 1.2 scottr break;
271 1.2 scottr }
272 1.2 scottr if ((sc->mem_size = ae_size_card_memory(bst, bsh,
273 1.3 scottr GC_DATA_OFFSET)) == 0) {
274 1.41 tsutsui aprint_error(": failed to determine size of RAM.\n");
275 1.2 scottr break;
276 1.2 scottr }
277 1.2 scottr if (bus_space_subregion(bst, bsh,
278 1.4 scottr GC_DATA_OFFSET, sc->mem_size, &sc->sc_bufh)) {
279 1.41 tsutsui aprint_error(": failed to map register space\n");
280 1.2 scottr break;
281 1.2 scottr }
282 1.2 scottr
283 1.3 scottr /* reset the NIC chip */
284 1.3 scottr bus_space_write_1(bst, bsh, GC_RESET_OFFSET, 0);
285 1.3 scottr
286 1.18 scottr if (ae_nb_get_enaddr(bst, bsh, na, sc->sc_enaddr)) {
287 1.9 scottr /* Fall back to snarf directly from ROM. Ick. */
288 1.9 scottr for (i = 0; i < ETHER_ADDR_LEN; ++i)
289 1.14 scottr sc->sc_enaddr[i] =
290 1.9 scottr bus_space_read_1(bst, bsh,
291 1.9 scottr (GC_ROM_OFFSET + i * 4));
292 1.2 scottr }
293 1.2 scottr
294 1.2 scottr success = 1;
295 1.2 scottr break;
296 1.2 scottr
297 1.14 scottr case DP8390_VENDOR_KINETICS:
298 1.11 scottr /* Map register offsets */
299 1.11 scottr for (i = 0; i < 16; i++) /* normal order, longword aligned */
300 1.11 scottr sc->sc_reg_map[i] = i << 2;
301 1.11 scottr
302 1.3 scottr if (bus_space_subregion(bst, bsh,
303 1.4 scottr KE_REG_OFFSET, AE_REG_SIZE, &sc->sc_regh)) {
304 1.41 tsutsui aprint_error(": failed to map register space\n");
305 1.3 scottr break;
306 1.3 scottr }
307 1.3 scottr if ((sc->mem_size = ae_size_card_memory(bst, bsh,
308 1.3 scottr KE_DATA_OFFSET)) == 0) {
309 1.41 tsutsui aprint_error(": failed to determine size of RAM.\n");
310 1.3 scottr break;
311 1.3 scottr }
312 1.3 scottr if (bus_space_subregion(bst, bsh,
313 1.4 scottr KE_DATA_OFFSET, sc->mem_size, &sc->sc_bufh)) {
314 1.41 tsutsui aprint_error(": failed to map register space\n");
315 1.3 scottr break;
316 1.3 scottr }
317 1.18 scottr if (ae_nb_get_enaddr(bst, bsh, na, sc->sc_enaddr)) {
318 1.41 tsutsui aprint_error(": can't find MAC address\n");
319 1.3 scottr break;
320 1.3 scottr }
321 1.3 scottr
322 1.3 scottr success = 1;
323 1.3 scottr break;
324 1.3 scottr
325 1.27 scottr case DP8390_VENDOR_CABLETRON:
326 1.27 scottr /* Map register offsets */
327 1.27 scottr for (i = 0; i < 16; i++)
328 1.27 scottr sc->sc_reg_map[i] = i << 1 ; /* normal order, word aligned */
329 1.27 scottr sc->dcr_reg = (ED_DCR_FT1 | ED_DCR_WTS | ED_DCR_LS);
330 1.27 scottr if (bus_space_subregion(bst, bsh,
331 1.27 scottr CT_REG_OFFSET, AE_REG_SIZE, &sc->sc_regh)) {
332 1.41 tsutsui aprint_error(": failed to map register space\n");
333 1.27 scottr break;
334 1.27 scottr }
335 1.27 scottr if ((sc->mem_size = ae_size_card_memory(bst, bsh,
336 1.27 scottr CT_DATA_OFFSET)) == 0) {
337 1.41 tsutsui aprint_error(": failed to determine size of RAM.\n");
338 1.27 scottr break;
339 1.27 scottr }
340 1.27 scottr if (bus_space_subregion(bst, bsh,
341 1.27 scottr CT_DATA_OFFSET, sc->mem_size, &sc->sc_bufh)) {
342 1.41 tsutsui aprint_error(": failed to map register space\n");
343 1.27 scottr break;
344 1.27 scottr }
345 1.27 scottr if (ae_nb_get_enaddr(bst, bsh, na, sc->sc_enaddr)) {
346 1.41 tsutsui aprint_error(": can't find MAC address\n");
347 1.27 scottr break;
348 1.27 scottr }
349 1.27 scottr success = 1;
350 1.27 scottr break;
351 1.1 scottr default:
352 1.1 scottr break;
353 1.1 scottr }
354 1.1 scottr
355 1.1 scottr if (!success) {
356 1.1 scottr bus_space_unmap(bst, bsh, NBMEMSIZE);
357 1.1 scottr return;
358 1.1 scottr }
359 1.1 scottr
360 1.14 scottr /*
361 1.14 scottr * Override test_mem and write_mbuf functions; other defaults
362 1.14 scottr * already work properly.
363 1.14 scottr */
364 1.14 scottr sc->test_mem = ae_test_mem;
365 1.14 scottr sc->write_mbuf = ae_write_mbuf;
366 1.11 scottr #ifdef DEBUG
367 1.4 scottr ifp->if_watchdog = ae_nb_watchdog; /* Override watchdog */
368 1.11 scottr #endif
369 1.31 thorpej sc->sc_media_init = dp8390_media_init;
370 1.14 scottr
371 1.22 thorpej /* Interface is always enabled. */
372 1.22 thorpej sc->sc_enabled = 1;
373 1.22 thorpej
374 1.41 tsutsui aprint_normal(": %s, %dKB memory\n", cardtype, sc->mem_size / 1024);
375 1.22 thorpej
376 1.31 thorpej if (dp8390_config(sc)) {
377 1.5 scottr bus_space_unmap(bst, bsh, NBMEMSIZE);
378 1.5 scottr return;
379 1.5 scottr }
380 1.1 scottr
381 1.22 thorpej /* make sure interrupts are vectored to us */
382 1.22 thorpej add_nubus_intr(na->slot, ae_nubus_intr, sc);
383 1.22 thorpej }
384 1.22 thorpej
385 1.22 thorpej void
386 1.35 chs ae_nubus_intr(void *arg)
387 1.22 thorpej {
388 1.41 tsutsui struct dp8390_softc *sc = arg;
389 1.43 skrll
390 1.25 scottr (void)dp8390_intr(sc);
391 1.1 scottr }
392 1.1 scottr
393 1.1 scottr static int
394 1.35 chs ae_nb_card_vendor(bus_space_tag_t bst, bus_space_handle_t bsh,
395 1.35 chs struct nubus_attach_args *na)
396 1.1 scottr {
397 1.1 scottr int vendor;
398 1.1 scottr
399 1.1 scottr switch (na->drsw) {
400 1.1 scottr case NUBUS_DRSW_3COM:
401 1.12 briggs switch (na->drhw) {
402 1.12 briggs case NUBUS_DRHW_APPLE_SN:
403 1.17 briggs case NUBUS_DRHW_APPLE_SNT:
404 1.14 scottr vendor = DP8390_VENDOR_UNKNOWN;
405 1.12 briggs break;
406 1.12 briggs default:
407 1.14 scottr vendor = DP8390_VENDOR_APPLE;
408 1.12 briggs break;
409 1.12 briggs }
410 1.12 briggs break;
411 1.1 scottr case NUBUS_DRSW_APPLE:
412 1.29 scottr if (na->drhw == NUBUS_DRHW_ASANTE_LC) {
413 1.29 scottr vendor = DP8390_VENDOR_UNKNOWN;
414 1.29 scottr break;
415 1.29 scottr }
416 1.29 scottr /* FALLTHROUGH */
417 1.20 briggs case NUBUS_DRSW_DAYNA2:
418 1.1 scottr case NUBUS_DRSW_TECHWORKS:
419 1.28 scottr case NUBUS_DRSW_TFLLAN:
420 1.27 scottr if (na->drhw == NUBUS_DRHW_CABLETRON) {
421 1.27 scottr vendor = DP8390_VENDOR_CABLETRON;
422 1.27 scottr } else {
423 1.27 scottr vendor = DP8390_VENDOR_APPLE;
424 1.27 scottr }
425 1.1 scottr break;
426 1.1 scottr case NUBUS_DRSW_ASANTE:
427 1.14 scottr vendor = DP8390_VENDOR_ASANTE;
428 1.1 scottr break;
429 1.1 scottr case NUBUS_DRSW_FARALLON:
430 1.14 scottr vendor = DP8390_VENDOR_FARALLON;
431 1.1 scottr break;
432 1.1 scottr case NUBUS_DRSW_GATOR:
433 1.1 scottr switch (na->drhw) {
434 1.1 scottr default:
435 1.1 scottr case NUBUS_DRHW_INTERLAN:
436 1.14 scottr vendor = DP8390_VENDOR_INTERLAN;
437 1.1 scottr break;
438 1.1 scottr case NUBUS_DRHW_KINETICS:
439 1.18 scottr if (strncmp(nubus_get_card_name(bst, bsh, na->fmt),
440 1.18 scottr "EtherPort", 9) == 0)
441 1.14 scottr vendor = DP8390_VENDOR_KINETICS;
442 1.2 scottr else
443 1.14 scottr vendor = DP8390_VENDOR_DAYNA;
444 1.1 scottr break;
445 1.1 scottr }
446 1.1 scottr break;
447 1.1 scottr default:
448 1.14 scottr vendor = DP8390_VENDOR_UNKNOWN;
449 1.1 scottr }
450 1.1 scottr return vendor;
451 1.3 scottr }
452 1.3 scottr
453 1.3 scottr static int
454 1.35 chs ae_nb_get_enaddr(bus_space_tag_t bst, bus_space_handle_t bsh,
455 1.35 chs struct nubus_attach_args *na, u_int8_t *ep)
456 1.3 scottr {
457 1.3 scottr nubus_dir dir;
458 1.3 scottr nubus_dirent dirent;
459 1.28 scottr int rv;
460 1.3 scottr
461 1.3 scottr /*
462 1.28 scottr * XXX - note hardwired resource IDs here; these are assumed to
463 1.28 scottr * be used by all cards, but should be fixed when we find out
464 1.28 scottr * more about Ethernet card resources.
465 1.3 scottr */
466 1.3 scottr nubus_get_main_dir(na->fmt, &dir);
467 1.28 scottr switch (ae_nb_card_vendor(bst, bsh, na)) {
468 1.28 scottr case DP8390_VENDOR_APPLE:
469 1.28 scottr if (na->drsw == NUBUS_DRSW_TFLLAN) { /* TFL LAN E410/E420 */
470 1.28 scottr rv = nubus_find_rsrc(bst, bsh, na->fmt,
471 1.28 scottr &dir, 0x08, &dirent);
472 1.28 scottr break;
473 1.28 scottr }
474 1.28 scottr /*FALLTHROUGH*/
475 1.28 scottr default:
476 1.28 scottr rv = nubus_find_rsrc(bst, bsh, na->fmt, &dir, 0x80, &dirent);
477 1.28 scottr break;
478 1.28 scottr }
479 1.28 scottr if (rv <= 0)
480 1.3 scottr return 1;
481 1.3 scottr nubus_get_dir_from_rsrc(na->fmt, &dirent, &dir);
482 1.18 scottr if (nubus_find_rsrc(bst, bsh, na->fmt, &dir, 0x80, &dirent) <= 0)
483 1.3 scottr return 1;
484 1.18 scottr if (nubus_get_ind_data(bst, bsh,
485 1.18 scottr na->fmt, &dirent, ep, ETHER_ADDR_LEN) <= 0)
486 1.3 scottr return 1;
487 1.3 scottr
488 1.3 scottr return 0;
489 1.4 scottr }
490 1.4 scottr
491 1.11 scottr #ifdef DEBUG
492 1.4 scottr static void
493 1.35 chs ae_nb_watchdog(struct ifnet *ifp)
494 1.4 scottr {
495 1.14 scottr struct dp8390_softc *sc = ifp->if_softc;
496 1.4 scottr
497 1.4 scottr /*
498 1.4 scottr * This is a kludge! The via code seems to miss slot interrupts
499 1.4 scottr * sometimes. This kludges around that by calling the handler
500 1.4 scottr * by hand if the watchdog is activated. -- XXX (akb)
501 1.4 scottr */
502 1.25 scottr (*via2itab[1])((void *)1);
503 1.4 scottr
504 1.40 hauke log(LOG_ERR, "%s: device timeout\n", device_xname(sc->sc_dev));
505 1.42 skrll if_statinc(ifp, if_oerrors);
506 1.4 scottr
507 1.14 scottr dp8390_reset(sc);
508 1.1 scottr }
509 1.11 scottr #endif
510