if_ef.c revision 1.32 1 /* $NetBSD: if_ef.c,v 1.32 2019/04/09 05:59:14 msaitoh Exp $ */
2
3 /*-
4 * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Rafal K. Boni.
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 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: if_ef.c,v 1.32 2019/04/09 05:59:14 msaitoh Exp $");
34
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/mbuf.h>
38 #include <sys/errno.h>
39 #include <sys/device.h>
40 #include <sys/protosw.h>
41 #include <sys/socket.h>
42
43 #include <net/if.h>
44 #include <net/if_dl.h>
45 #include <net/if_types.h>
46 #include <net/if_media.h>
47 #include <net/if_ether.h>
48
49 #include <sys/cpu.h>
50 #include <sys/bus.h>
51 #include <sys/intr.h>
52
53 #include <dev/isa/isareg.h>
54 #include <dev/isa/isavar.h>
55
56 #include <dev/ic/i82586reg.h>
57 #include <dev/ic/i82586var.h>
58 #include <dev/isa/if_efreg.h>
59 #include <dev/isa/elink.h>
60
61 #ifdef EF_DEBUG
62 #define DPRINTF(x) printf x
63 #else
64 #define DPRINTF(x)
65 #endif
66
67 struct ef_softc {
68 struct ie_softc sc_ie;
69
70 bus_space_tag_t sc_regt; /* space tag for registers */
71 bus_space_handle_t sc_regh; /* space handle for registers */
72
73 void* sc_ih; /* interrupt handle */
74
75 uint8_t card_rev; /* hardware revision */
76 uint8_t card_type; /* card model -- AUI/BNC or TP */
77 };
78
79 static int ef_media[] = {
80 IFM_ETHER | IFM_10_5,
81 IFM_ETHER | IFM_10_2,
82 };
83 #define NEF_MEDIA (sizeof(ef_media) / sizeof(ef_media[0]))
84
85 static int eftp_media[] = {
86 IFM_ETHER | IFM_10_T,
87 };
88 #define NEFTP_MEDIA (sizeof(eftp_media) / sizeof(eftp_media[0]))
89
90 /* Routines required by the MI i82586 driver API */
91 static void ef_reset(struct ie_softc *, int);
92 static void ef_hwinit(struct ie_softc *);
93 static void ef_atten(struct ie_softc *, int);
94 static int ef_intrhook(struct ie_softc *, int);
95
96 static void ef_copyin(struct ie_softc *, void *, int, size_t);
97 static void ef_copyout(struct ie_softc *, const void *, int, size_t);
98
99 static uint16_t ef_read_16(struct ie_softc *, int);
100 static void ef_write_16(struct ie_softc *, int, uint16_t);
101 static void ef_write_24(struct ie_softc *, int, int);
102
103 static void ef_mediastatus(struct ie_softc *, struct ifmediareq *);
104
105 /* Local routines */
106 static int ef_port_check(bus_space_tag_t, bus_space_handle_t);
107
108 static int ef_match(device_t, cfdata_t, void *);
109 static void ef_attach(device_t, device_t, void *);
110
111 /*
112 * This keeps track of which ISAs have been through an ie probe sequence.
113 * A simple static variable isn't enough, since it's conceivable that
114 * a system might have more than one ISA bus.
115 *
116 * The "isa_bus" member is a pointer to the parent ISA bus device struct
117 * which will unique per ISA bus.
118 */
119
120 #define MAXCARDS_PER_ISABUS 8 /* If you have more than 8, you lose */
121
122 struct ef_isabus {
123 LIST_ENTRY(ef_isabus) isa_link;
124 device_t isa_bus;
125
126 int bus_state;
127
128 struct card {
129 bus_addr_t iobase;
130 bus_addr_t maddr;
131 bus_size_t msize;
132 int irq;
133 int available;
134 } isa_cards[MAXCARDS_PER_ISABUS];
135 };
136
137 static LIST_HEAD(, ef_isabus) ef_isa_buses;
138 static int ef_isa_buses_inited;
139
140 static void
141 ef_card_add(struct ef_isabus *bus, bus_addr_t iobase, bus_addr_t maddr,
142 bus_size_t msiz, int irq)
143 {
144 int idx;
145
146 DPRINTF(("Adding 3c507 at 0x%x, IRQ %d, Mem 0x%lx/%ld\n",
147 (u_int) iobase, irq, (u_long) maddr, msiz));
148
149 for (idx = 0; idx < MAXCARDS_PER_ISABUS; idx++) {
150 if (bus->isa_cards[idx].available == 0) {
151 bus->isa_cards[idx].iobase = iobase;
152 bus->isa_cards[idx].maddr = maddr;
153 bus->isa_cards[idx].msize = msiz;
154 bus->isa_cards[idx].irq = irq;
155 bus->isa_cards[idx].available = 1;
156 break;
157 }
158 }
159 }
160
161 /*
162 * 3C507 support routines
163 */
164 static void
165 ef_reset(struct ie_softc *sc, int why)
166 {
167 struct ef_softc *esc = (struct ef_softc *)sc;
168
169 switch (why) {
170 case CHIP_PROBE:
171 /* Reset to chip to see if it responds */
172 bus_space_write_1(esc->sc_regt, esc->sc_regh,
173 EF_CTRL, EF_CTRL_RESET);
174 DELAY(100);
175 bus_space_write_1(esc->sc_regt, esc->sc_regh,
176 EF_CTRL, EF_CTRL_NORMAL);
177 DELAY(100);
178 break;
179
180 case CARD_RESET:
181 /*
182 * This takes around 10sec, and we can get
183 * by quite well w/out it...
184 */
185 break;
186 }
187 }
188
189 static void
190 ef_atten(struct ie_softc *sc, int why)
191 {
192 struct ef_softc *esc = (struct ef_softc *)sc;
193
194 bus_space_write_1(esc->sc_regt, esc->sc_regh, EF_ATTN, 1);
195 }
196
197 static void
198 ef_hwinit(struct ie_softc *sc)
199 {
200 struct ef_softc *esc = (struct ef_softc *)sc;
201
202 bus_space_write_1(esc->sc_regt, esc->sc_regh, EF_ICTRL, 1);
203 }
204
205 static int
206 ef_intrhook(struct ie_softc *sc, int where)
207 {
208 unsigned char cr;
209 struct ef_softc *esc = (struct ef_softc *)sc;
210
211 switch (where) {
212 case INTR_ENTER:
213 /* Entering ISR: disable, ack card interrupts */
214 cr = bus_space_read_1(esc->sc_regt, esc->sc_regh, EF_CTRL);
215 bus_space_write_1(esc->sc_regt, esc->sc_regh, EF_CTRL,
216 cr & ~EF_CTRL_IEN);
217 bus_space_write_1(esc->sc_regt, esc->sc_regh, EF_ICTRL, 1);
218 break;
219
220 case INTR_EXIT:
221 /* Exiting ISR: re-enable card interrupts */
222 cr = bus_space_read_1(esc->sc_regt, esc->sc_regh, EF_CTRL);
223 bus_space_write_1(esc->sc_regt, esc->sc_regh, EF_CTRL,
224 cr | EF_CTRL_IEN);
225 break;
226
227 case INTR_LOOP:
228 /* Looping in ISR: ack new interrupts */
229 bus_space_write_1(esc->sc_regt, esc->sc_regh, EF_ICTRL, 1);
230 break;
231 }
232
233 return 1;
234 }
235
236 static uint16_t
237 ef_read_16(struct ie_softc *sc, int offset)
238 {
239
240 bus_space_barrier(sc->bt, sc->bh, offset, 2, BUS_SPACE_BARRIER_READ);
241 return bus_space_read_2(sc->bt, sc->bh, offset);
242 }
243
244 static void
245 ef_copyin(struct ie_softc *sc, void *dst, int offset, size_t size)
246 {
247 int dribble;
248 uint8_t *bptr = dst;
249
250 bus_space_barrier(sc->bt, sc->bh, offset, size,
251 BUS_SPACE_BARRIER_READ);
252
253 if (offset % 2) {
254 *bptr = bus_space_read_1(sc->bt, sc->bh, offset);
255 offset++; bptr++; size--;
256 }
257
258 dribble = size % 2;
259 bus_space_read_region_2(sc->bt, sc->bh, offset, (uint16_t *) bptr,
260 size >> 1);
261
262 if (dribble) {
263 bptr += size - 1;
264 offset += size - 1;
265 *bptr = bus_space_read_1(sc->bt, sc->bh, offset);
266 }
267 }
268
269 static void
270 ef_copyout(struct ie_softc *sc, const void *src, int offset, size_t size)
271 {
272 int dribble;
273 int osize = size;
274 int ooffset = offset;
275 const uint8_t *bptr = src;
276
277 if (offset % 2) {
278 bus_space_write_1(sc->bt, sc->bh, offset, *bptr);
279 offset++; bptr++; size--;
280 }
281
282 dribble = size % 2;
283 bus_space_write_region_2(sc->bt, sc->bh, offset,
284 (const uint16_t *)bptr, size >> 1);
285 if (dribble) {
286 bptr += size - 1;
287 offset += size - 1;
288 bus_space_write_1(sc->bt, sc->bh, offset, *bptr);
289 }
290
291 bus_space_barrier(sc->bt, sc->bh, ooffset, osize,
292 BUS_SPACE_BARRIER_WRITE);
293 }
294
295 static void
296 ef_write_16(struct ie_softc *sc, int offset, uint16_t value)
297 {
298
299 bus_space_write_2(sc->bt, sc->bh, offset, value);
300 bus_space_barrier(sc->bt, sc->bh, offset, 2, BUS_SPACE_BARRIER_WRITE);
301 }
302
303 static void
304 ef_write_24(struct ie_softc *sc, int offset, int addr)
305 {
306
307 bus_space_write_4(sc->bt, sc->bh, offset,
308 addr + (u_long)sc->sc_maddr - (u_long)sc->sc_iobase);
309 bus_space_barrier(sc->bt, sc->bh, offset, 4, BUS_SPACE_BARRIER_WRITE);
310 }
311
312 static void
313 ef_mediastatus(struct ie_softc *sc, struct ifmediareq *ifmr)
314 {
315 struct ifmedia *ifm = &sc->sc_media;
316
317 /* The currently selected media is always the active media. */
318 ifmr->ifm_active = ifm->ifm_cur->ifm_media;
319 }
320
321 static int
322 ef_match(device_t parent, cfdata_t cf, void *aux)
323 {
324 struct isa_attach_args * const ia = aux;
325 int idx;
326 struct ef_isabus *bus;
327 bus_space_handle_t ioh;
328 bus_space_tag_t iot = ia->ia_iot;
329
330 if (ISA_DIRECT_CONFIG(ia))
331 return 0;
332
333 if (ef_isa_buses_inited == 0) {
334 LIST_INIT(&ef_isa_buses);
335 ef_isa_buses_inited = 1;
336 }
337
338 /* Probe this bus if we haven't done so already. */
339 for (bus = ef_isa_buses.lh_first; bus != NULL;
340 bus = bus->isa_link.le_next) {
341 if (bus->isa_bus == parent)
342 break;
343 }
344
345 if (bus == NULL) {
346 bus_addr_t iobase;
347
348 /* Mark this bus so we don't probe it again. */
349 bus = (struct ef_isabus *)
350 malloc(sizeof(struct ef_isabus), M_DEVBUF, M_NOWAIT);
351 if (bus == NULL)
352 panic("%s: can't allocate state storage for %s",
353 __func__, device_xname(parent));
354
355 bus->bus_state = 0; /* Nothing done yet */
356 bus->isa_bus = parent;
357
358 LIST_INSERT_HEAD(&ef_isa_buses, bus, isa_link);
359
360 if (bus_space_map(iot, ELINK_ID_PORT, 1, 0, &ioh)) {
361 DPRINTF(("3c507 probe: can't map Etherlink ID port\n"));
362 return 0;
363 }
364
365 /*
366 * Reset and put card in CONFIG state without
367 * changing address.
368 */
369 elink_reset(iot, ioh, device_unit(parent));
370 elink_idseq(iot, ioh, ELINK_507_POLY);
371 elink_idseq(iot, ioh, ELINK_507_POLY);
372 bus_space_write_1(iot, ioh, 0, 0xff);
373
374 /* Unmap the ID port */
375 bus_space_unmap(iot, ioh, 1);
376
377 bus->bus_state++; /* Cards now in CONFIG state */
378
379 for (iobase = EF_IOBASE_LOW; iobase <= EF_IOBASE_HIGH;
380 iobase += EF_IOSIZE) {
381 /* Map the 507's port-space for the probe sequence. */
382 if (bus_space_map(iot, iobase, EF_IOSIZE,
383 0, &ioh) != 0)
384 continue;
385
386 /* Now look for the 3Com magic bytes */
387
388 if (ef_port_check(iot, ioh)) {
389 int irq;
390 uint8_t v;
391 bus_addr_t maddr;
392 bus_addr_t msiz1;
393 bus_space_handle_t memh;
394
395 irq = bus_space_read_1(iot, ioh, EF_IRQ) &
396 EF_IRQ_MASK;
397
398 v = bus_space_read_1(iot, ioh, EF_MADDR);
399 maddr = EF_MADDR_BASE +
400 ((v & EF_MADDR_MASK) << EF_MADDR_SHIFT);
401 msiz1 = ((v & EF_MSIZE_MASK) + 1) *
402 EF_MSIZE_STEP;
403
404 if (bus_space_map(ia->ia_memt, maddr,
405 msiz1, 0, &memh) == 0) {
406 ef_card_add(bus, iobase, maddr,
407 msiz1, irq);
408 bus_space_unmap(ia->ia_memt,
409 memh, msiz1);
410 }
411 }
412 bus_space_unmap(iot, ioh, EF_IOSIZE);
413 }
414 }
415
416 if (ia->ia_nio < 1)
417 return 0;
418 if (ia->ia_niomem < 1)
419 return 0;
420 if (ia->ia_nirq < 1)
421 return 0;
422
423 for (idx = 0; idx < MAXCARDS_PER_ISABUS; idx++) {
424 if (bus->isa_cards[idx].available != 1)
425 continue;
426
427 if (ia->ia_io[0].ir_addr != ISA_UNKNOWN_PORT &&
428 ia->ia_io[0].ir_addr != bus->isa_cards[idx].iobase)
429 continue;
430
431 if (ia->ia_iomem[0].ir_addr != ISA_UNKNOWN_IOMEM &&
432 ia->ia_iomem[0].ir_addr != bus->isa_cards[idx].maddr)
433 continue;
434
435 if (ia->ia_irq[0].ir_irq != ISA_UNKNOWN_IRQ &&
436 ia->ia_irq[0].ir_irq != bus->isa_cards[idx].irq)
437 continue;
438
439 break;
440 }
441
442 if (idx == MAXCARDS_PER_ISABUS)
443 return 0;
444
445 bus->isa_cards[idx].available++;
446
447 ia->ia_nio = 1;
448 ia->ia_io[0].ir_addr = bus->isa_cards[idx].iobase;
449 ia->ia_io[0].ir_size = EF_IOSIZE;
450
451 ia->ia_niomem = 1;
452 ia->ia_iomem[0].ir_addr = bus->isa_cards[idx].maddr;
453 ia->ia_iomem[0].ir_size = bus->isa_cards[idx].msize;
454
455 ia->ia_nirq = 1;
456 ia->ia_irq[0].ir_irq = bus->isa_cards[idx].irq;
457
458 ia->ia_ndrq = 0;
459
460 return 1;
461 }
462
463 static void
464 ef_attach(device_t parent, device_t self, void *aux)
465 {
466 struct ef_softc *esc = device_private(self);
467 struct ie_softc *sc = &esc->sc_ie;
468 struct isa_attach_args *ia = aux;
469 bus_space_tag_t iot = ia->ia_iot;
470
471 int i;
472 char vers[20];
473 struct ef_isabus *bus;
474 uint8_t partno[EF_TYPE_LEN];
475 bus_space_handle_t ioh, memh;
476 uint8_t ethaddr[ETHER_ADDR_LEN];
477
478 sc->sc_dev = self;
479 sc->hwinit = ef_hwinit;
480 sc->hwreset = ef_reset;
481 sc->chan_attn = ef_atten;
482 sc->intrhook = ef_intrhook;
483
484 sc->ie_bus_barrier = NULL;
485
486 sc->memcopyin = ef_copyin;
487 sc->memcopyout = ef_copyout;
488 sc->ie_bus_read16 = ef_read_16;
489 sc->ie_bus_write16 = ef_write_16;
490 sc->ie_bus_write24 = ef_write_24;
491
492 sc->sc_msize = 0;
493
494 /*
495 * NOP chains don't give any advantage on this card, in fact they
496 * seem to slow it down some. As the doctor says, "if it hurts,
497 * don't do it".
498 */
499 sc->do_xmitnopchain = 0;
500
501 sc->sc_mediachange = NULL;
502 sc->sc_mediastatus = ef_mediastatus;
503
504 /* Find the cards parent bus */
505 for (bus = ef_isa_buses.lh_first; bus != NULL;
506 bus = bus->isa_link.le_next) {
507
508 if (bus->isa_bus == parent)
509 break;
510 }
511
512 if (bus == NULL)
513 panic("%s: Can't find parent bus!", device_xname(self));
514
515
516 /* If the bus hasn't been transitioned to the RUN state, do so now */
517 if (bus->bus_state == 1) {
518 if (bus_space_map(iot, ELINK_ID_PORT, 1, 0, &ioh) != 0) {
519 DPRINTF(("\n%s: Can't map Elink ID port!\n",
520 device_xname(self)));
521 return;
522 }
523
524 bus_space_write_1(ia->ia_iot, ioh, 0, 0x00);
525 elink_idseq(ia->ia_iot, ioh, ELINK_507_POLY);
526 bus_space_write_1(ia->ia_iot, ioh, 0, 0x00);
527 bus_space_unmap(ia->ia_iot, ioh, 1);
528
529 bus->bus_state++;
530 }
531
532 /* Map i/o space. */
533 if (bus_space_map(ia->ia_iot, ia->ia_io[0].ir_addr,
534 ia->ia_io[0].ir_size, 0, &ioh) != 0) {
535
536 DPRINTF(("\n%s: can't map i/o space 0x%x-0x%x\n",
537 device_xname(self), ia->ia_io[0].ir_addr,
538 ia->ia_io[0].ir_addr + ia->ia_io[0].ir_size - 1));
539 return;
540 }
541
542 esc->sc_regt = ia->ia_iot;
543 esc->sc_regh = ioh;
544
545 if (bus_space_map(ia->ia_memt, ia->ia_iomem[0].ir_addr,
546 ia->ia_iomem[0].ir_size, 0, &memh) != 0) {
547
548 DPRINTF(("\n%s: can't map iomem space 0x%x-0x%x\n",
549 device_xname(self), ia->ia_maddr,
550 ia->ia_maddr + ia->ia_msize - 1));
551 bus_space_unmap(ia->ia_iot, ioh, ia->ia_io[0].ir_size);
552 return;
553 }
554
555 sc->bt = ia->ia_memt;
556 sc->bh = memh;
557
558 sc->sc_msize = ia->ia_iomem[0].ir_size;
559 sc->sc_maddr = (void *)memh;
560 sc->sc_iobase = (char *)sc->sc_maddr + sc->sc_msize - (1 << 24);
561
562 /* Set up pointers to important on-card control structures */
563 sc->iscp = 0;
564 sc->scb = IE_ISCP_SZ;
565 sc->scp = sc->sc_msize + IE_SCP_ADDR - (1 << 24);
566
567 sc->buf_area = sc->scb + IE_SCB_SZ;
568 sc->buf_area_sz = sc->sc_msize - IE_ISCP_SZ - IE_SCB_SZ - IE_SCP_SZ;
569
570 /* Zero card memory */
571 bus_space_set_region_1(sc->bt, sc->bh, 0, 0, sc->sc_msize);
572
573 /* Set card to 16-bit bus mode */
574 bus_space_write_1(sc->bt, sc->bh, IE_SCP_BUS_USE((u_long)sc->scp),
575 IE_SYSBUS_16BIT);
576
577 /* Set up pointers to key structures */
578 ef_write_24(sc, IE_SCP_ISCP((u_long)sc->scp), (u_long)sc->iscp);
579 ef_write_16(sc, IE_ISCP_SCB((u_long)sc->iscp), (u_long)sc->scb);
580 ef_write_24(sc, IE_ISCP_BASE((u_long)sc->iscp), (u_long)sc->iscp);
581
582 /* flush setup of pointers, check if chip answers */
583 bus_space_barrier(sc->bt, sc->bh, 0, sc->sc_msize,
584 BUS_SPACE_BARRIER_WRITE);
585 if (!i82586_proberam(sc)) {
586 DPRINTF(("\n%s: can't talk to i82586!\n",
587 device_xname(self)));
588 bus_space_unmap(ia->ia_iot, ioh, ia->ia_io[0].ir_size);
589 bus_space_unmap(ia->ia_memt, memh, ia->ia_iomem[0].ir_size);
590 return;
591 }
592
593 /* Set bank 2 for card part number and revision */
594 bus_space_write_1(esc->sc_regt, esc->sc_regh, EF_CTRL,
595 EF_CTRL_NRST | EF_CTRL_BNK2);
596
597 /* The card revision is encoded in BCD */
598 i = bus_space_read_1(esc->sc_regt, esc->sc_regh, EF_REV);
599 esc->card_rev = 10 * (i / 16) + (i % 16);
600
601 for (i = 0; i < EF_TYPE_LEN; i++)
602 partno[i] = bus_space_read_1(esc->sc_regt, esc->sc_regh,
603 EF_TYPE + i);
604
605 /* Use part number to guess if card is TP or AUI/BNC model */
606 esc->card_type = EF_IS_TP(partno) ? EF_CARD_TP : EF_CARD_BNC;
607
608 /* Set bank 0 for ethernet address */
609 bus_space_write_1(esc->sc_regt, esc->sc_regh,
610 EF_CTRL, EF_CTRL_NORMAL);
611
612 for (i = 0; i < EF_ADDR_LEN; i++)
613 ethaddr[i] = bus_space_read_1(esc->sc_regt, esc->sc_regh,
614 EF_ADDR + i);
615
616 snprintf(vers, sizeof(vers), "%s, rev. %d",
617 (esc->card_type == EF_CARD_TP) ? "3C507-TP" : "3C507",
618 esc->card_rev);
619
620 if (esc->card_type == EF_CARD_TP)
621 i82586_attach(sc, vers, ethaddr, eftp_media, NEFTP_MEDIA,
622 eftp_media[0]);
623 else {
624 uint8_t media = bus_space_read_1(esc->sc_regt, esc->sc_regh,
625 EF_MEDIA);
626 media = (media & EF_MEDIA_MASK) >> EF_MEDIA_SHIFT;
627
628 i82586_attach(sc, vers, ethaddr, ef_media, NEF_MEDIA,
629 ef_media[media]);
630 }
631
632 /* Clear the interrupt latch just in case. */
633 bus_space_write_1(esc->sc_regt, esc->sc_regh, EF_ICTRL, 1);
634
635 esc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
636 IST_EDGE, IPL_NET, i82586_intr, sc);
637 if (esc->sc_ih == NULL) {
638 DPRINTF(("\n%s: can't establish interrupt\n",
639 device_xname(self)));
640 }
641 }
642
643 static int
644 ef_port_check(bus_space_tag_t iot, bus_space_handle_t ioh)
645 {
646 int i;
647 u_char ch;
648 const u_char *signature = EF_SIGNATURE;
649
650 for (i = 0; i < strlen(signature); i++) {
651 ch = bus_space_read_1(iot, ioh, i);
652 if (ch != signature[i])
653 return 0;
654 }
655
656 /* If card is mapped in high memory (above 15Meg), we can't use it */
657 ch = bus_space_read_1(iot, ioh, EF_MADDR);
658 if (ch & EF_MADDR_HIGH)
659 return 0; /* XXX: maybe we should panic?? */
660
661 return 1;
662 }
663
664 CFATTACH_DECL_NEW(ef, sizeof(struct ef_softc),
665 ef_match, ef_attach, NULL, NULL);
666
667