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