2 * All Rights Reserved, Copyright (C) Fujitsu Limited 1995
4 * This software may be used, modified, copied, distributed, and sold, in
5 * both source and binary form provided that the above copyright, these
6 * terms and the following disclaimer are retained. The name of the author
7 * and/or the contributor may not be used to endorse or promote products
8 * derived from this software without specific prior written permission.
10 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND THE CONTRIBUTOR ``AS IS'' AND
11 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
12 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
13 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR THE CONTRIBUTOR BE LIABLE
14 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
15 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
16 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION.
17 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
18 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
19 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 #include <sys/param.h>
26 #include <sys/systm.h>
27 #include <sys/kernel.h>
28 #include <sys/socket.h>
29 #include <sys/module.h>
32 #include <machine/bus.h>
34 #include <machine/resource.h>
36 #include <net/ethernet.h>
38 #include <net/if_mib.h>
39 #include <net/if_media.h>
41 #include <netinet/in.h>
42 #include <netinet/if_ether.h>
44 #include <i386/isa/ic/mb86960.h>
45 #include <dev/fe/if_fereg.h>
46 #include <dev/fe/if_fevar.h>
48 #include <isa/isavar.h>
53 static int fe_isa_probe(device_t);
54 static int fe_isa_attach(device_t);
56 static struct isa_pnp_id fe_ids[] = {
57 { 0x101ee0d, NULL }, /* CON0101 - Contec C-NET(98)P2-T */
61 static device_method_t fe_isa_methods[] = {
62 /* Device interface */
63 DEVMETHOD(device_probe, fe_isa_probe),
64 DEVMETHOD(device_attach, fe_isa_attach),
69 static driver_t fe_isa_driver = {
72 sizeof (struct fe_softc)
75 DRIVER_MODULE(fe, isa, fe_isa_driver, fe_devclass, 0, 0);
78 static int fe98_alloc_port(device_t, int);
80 static int fe_probe_re1000(device_t);
81 static int fe_probe_cnet9ne(device_t);
82 static int fe_probe_rex(device_t);
83 static int fe_probe_ssi(device_t);
84 static int fe_probe_jli(device_t);
85 static int fe_probe_lnx(device_t);
86 static int fe_probe_gwy(device_t);
87 static int fe_probe_ubn(device_t);
90 * Determine if the device is present at a specified I/O address. The
91 * main entry to the driver.
94 fe_isa_probe(device_t dev)
99 /* Prepare for the softc struct. */
100 sc = device_get_softc(dev);
101 sc->sc_unit = device_get_unit(dev);
103 /* Check isapnp ids */
104 error = ISA_PNP_PROBE(device_get_parent(dev), dev, fe_ids);
106 /* If the card had a PnP ID that didn't match any we know about */
110 /* If we had some other problem. */
111 if (!(error == 0 || error == ENOENT))
114 /* Probe for supported boards. */
115 if ((error = fe_probe_re1000(dev)) == 0)
117 fe_release_resource(dev);
119 if ((error = fe_probe_cnet9ne(dev)) == 0)
121 fe_release_resource(dev);
123 if ((error = fe_probe_rex(dev)) == 0)
125 fe_release_resource(dev);
127 if ((error = fe_probe_ssi(dev)) == 0)
129 fe_release_resource(dev);
131 if ((error = fe_probe_jli(dev)) == 0)
133 fe_release_resource(dev);
135 if ((error = fe_probe_lnx(dev)) == 0)
137 fe_release_resource(dev);
139 if ((error = fe_probe_ubn(dev)) == 0)
141 fe_release_resource(dev);
143 if ((error = fe_probe_gwy(dev)) == 0)
145 fe_release_resource(dev);
149 error = fe_alloc_irq(dev, 0);
151 fe_release_resource(dev);
156 fe_isa_attach(device_t dev)
158 struct fe_softc *sc = device_get_softc(dev);
161 fe98_alloc_port(dev, sc->type);
162 fe_alloc_irq(dev, 0);
164 return fe_attach(dev);
168 /* Generic I/O address table */
169 static bus_addr_t ioaddr_generic[MAXREGISTERS] = {
170 0x000, 0x001, 0x002, 0x003, 0x004, 0x005, 0x006, 0x007,
171 0x008, 0x009, 0x00a, 0x00b, 0x00c, 0x00d, 0x00e, 0x00f,
172 0x010, 0x011, 0x012, 0x013, 0x014, 0x015, 0x016, 0x017,
173 0x018, 0x019, 0x01a, 0x01b, 0x01c, 0x01d, 0x01e, 0x01f,
176 /* I/O address table for RE1000/1000Plus */
177 static bus_addr_t ioaddr_re1000[MAXREGISTERS] = {
178 0x0000, 0x0001, 0x0200, 0x0201, 0x0400, 0x0401, 0x0600, 0x0601,
179 0x0800, 0x0801, 0x0a00, 0x0a01, 0x0c00, 0x0c01, 0x0e00, 0x0e01,
180 0x1000, 0x1200, 0x1400, 0x1600, 0x1800, 0x1a00, 0x1c00, 0x1e00,
181 0x1001, 0x1201, 0x1401, 0x1601, 0x1801, 0x1a01, 0x1c01, 0x1e01,
184 /* I/O address table for CNET9NE */
185 static bus_addr_t ioaddr_cnet9ne[MAXREGISTERS] = {
186 0x000, 0x001, 0x002, 0x003, 0x004, 0x005, 0x006, 0x007,
187 0x008, 0x009, 0x00a, 0x00b, 0x00c, 0x00d, 0x00e, 0x00f,
188 0x400, 0x402, 0x404, 0x406, 0x408, 0x40a, 0x40c, 0x40e,
189 0x401, 0x403, 0x405, 0x407, 0x409, 0x40b, 0x40d, 0x40f,
192 /* I/O address table for LAC-98 */
193 static bus_addr_t ioaddr_lnx[MAXREGISTERS] = {
194 0x000, 0x002, 0x004, 0x006, 0x008, 0x00a, 0x00c, 0x00e,
195 0x100, 0x102, 0x104, 0x106, 0x108, 0x10a, 0x10c, 0x10e,
196 0x200, 0x202, 0x204, 0x206, 0x208, 0x20a, 0x20c, 0x20e,
197 0x300, 0x302, 0x304, 0x306, 0x308, 0x30a, 0x30c, 0x30e,
200 /* I/O address table for Access/PC N98C+ */
201 static bus_addr_t ioaddr_ubn[MAXREGISTERS] = {
202 0x000, 0x001, 0x002, 0x003, 0x004, 0x005, 0x006, 0x007,
203 0x008, 0x009, 0x00a, 0x00b, 0x00c, 0x00d, 0x00e, 0x00f,
204 0x200, 0x201, 0x202, 0x203, 0x204, 0x205, 0x206, 0x207,
205 0x208, 0x209, 0x20a, 0x20b, 0x20c, 0x20d, 0x20e, 0x20f,
208 /* I/O address table for REX-9880 */
209 static bus_addr_t ioaddr_rex[MAXREGISTERS] = {
210 0x000, 0x001, 0x002, 0x003, 0x004, 0x005, 0x006, 0x007,
211 0x008, 0x009, 0x00a, 0x00b, 0x00c, 0x00d, 0x00e, 0x00f,
212 0x100, 0x101, 0x102, 0x103, 0x104, 0x105, 0x106, 0x107,
213 0x108, 0x109, 0x10a, 0x10b, 0x10c, 0x10d, 0x10e, 0x10f,
217 fe98_alloc_port(device_t dev, int type)
219 struct fe_softc *sc = device_get_softc(dev);
220 struct resource *res;
229 case FE_TYPE_CNET9NE:
230 iat = ioaddr_cnet9ne;
234 iat = ioaddr_generic;
242 iat = ioaddr_generic;
254 iat = ioaddr_generic;
260 res = isa_alloc_resourcev(dev, SYS_RES_IOPORT, &rid,
261 iat, size, RF_ACTIVE);
265 isa_load_resourcev(res, iat, size);
268 sc->port_used = size;
270 sc->iot = rman_get_bustag(res);
271 sc->ioh = rman_get_bushandle(res);
277 * Probe and initialization for Allied-Telesis RE1000 series.
280 fe_init_re1000(struct fe_softc *sc)
282 /* Setup IRQ control register on the ASIC. */
283 fe_outb(sc, FE_RE1000_IRQCONF, sc->priv_info);
287 fe_probe_re1000(device_t dev)
289 struct fe_softc *sc = device_get_softc(dev);
294 static struct fe_simple_probe_struct probe_table [] = {
295 { FE_DLCR2, 0x58, 0x00 },
296 { FE_DLCR4, 0x08, 0x00 },
300 /* See if the specified I/O address is possible for RE1000. */
301 /* [01]D[02468ACE] are allowed. */
302 if (bus_get_resource(dev, SYS_RES_IOPORT, 0, &iobase, NULL) != 0)
304 if ((iobase & ~0x10E) != 0xD0)
307 if (fe98_alloc_port(dev, FE_TYPE_RE1000))
310 /* Fill the softc struct with default values. */
311 fe_softc_defaults(sc);
313 /* See if the card is on its address. */
314 if (!fe_simple_probe(sc, probe_table))
317 /* Get our station address from EEPROM. */
318 fe_inblk(sc, 0x18, sc->sc_enaddr, ETHER_ADDR_LEN);
320 /* Make sure it is Allied-Telesis's. */
321 if (!valid_Ether_p(sc->sc_enaddr, 0x0000F4))
324 /* Calculate checksum. */
325 sum = fe_inb(sc, 0x1e);
326 for (i = 0; i < ETHER_ADDR_LEN; i++)
327 sum ^= sc->sc_enaddr[i];
331 /* Setup the board type. */
332 sc->typestr = "RE1000";
334 /* This looks like an RE1000 board. It requires an
335 explicit IRQ setting in config. Make sure we have one,
336 determining an appropriate value for the IRQ control
339 bus_get_resource(dev, SYS_RES_IRQ, 0, &irq, NULL);
341 case 3: n = 0x10; break;
342 case 5: n = 0x20; break;
343 case 6: n = 0x40; break;
344 case 12: n = 0x80; break;
346 fe_irq_failure(sc->typestr, sc->sc_unit, irq, "3/5/6/12");
349 sc->priv_info = (fe_inb(sc, FE_RE1000_IRQCONF) & 0x0f) | n;
351 /* Setup hooks. We need a special initialization procedure. */
352 sc->init = fe_init_re1000;
357 /* JLI sub-probe for Allied-Telesis RE1000Plus/ME1500 series. */
358 static u_short const *
359 fe_probe_jli_re1000p(struct fe_softc * sc, u_char const * eeprom)
362 static u_short const irqmaps_re1000p [4] = { 3, 5, 6, 12 };
364 /* Make sure the EEPROM contains Allied-Telesis bit pattern. */
365 if (eeprom[1] != 0xFF) return NULL;
366 for (i = 2; i < 8; i++) if (eeprom[i] != 0xFF) return NULL;
367 for (i = 14; i < 24; i++) if (eeprom[i] != 0xFF) return NULL;
369 /* Get our station address from EEPROM, and make sure the
370 EEPROM contains Allied-Telesis's address. */
371 bcopy(eeprom + 8, sc->sc_enaddr, ETHER_ADDR_LEN);
372 if (!valid_Ether_p(sc->sc_enaddr, 0x0000F4))
375 /* I don't know any sub-model identification. */
376 sc->typestr = "RE1000Plus/ME1500";
378 /* Returns the IRQ table for the RE1000Plus. */
379 return irqmaps_re1000p;
384 * Probe for Allied-Telesis RE1000Plus/ME1500 series.
387 fe_probe_jli(device_t dev)
389 struct fe_softc *sc = device_get_softc(dev);
390 int i, n, xirq, error;
392 u_char eeprom [JLI_EEPROM_SIZE];
393 u_short const * irqmap;
395 static u_short const baseaddr [8] =
396 { 0x1D6, 0x1D8, 0x1DA, 0x1D4, 0x0D4, 0x0D2, 0x0D8, 0x0D0 };
397 static struct fe_simple_probe_struct const probe_table [] = {
398 /* { FE_DLCR1, 0x20, 0x00 }, Doesn't work. */
399 { FE_DLCR2, 0x50, 0x00 },
400 { FE_DLCR4, 0x08, 0x00 },
401 /* { FE_DLCR5, 0x80, 0x00 }, Doesn't work. */
403 { FE_BMPR16, 0x1B, 0x00 },
404 { FE_BMPR17, 0x7F, 0x00 },
410 * See if the specified address is possible for MB86965A JLI mode.
412 if (bus_get_resource(dev, SYS_RES_IOPORT, 0, &iobase, NULL) != 0)
414 for (i = 0; i < 8; i++) {
415 if (baseaddr[i] == iobase)
421 if (fe98_alloc_port(dev, FE_TYPE_RE1000))
424 /* Fill the softc struct with default values. */
425 fe_softc_defaults(sc);
428 * We should test if MB86965A is on the base address now.
429 * Unfortunately, it is very hard to probe it reliably, since
430 * we have no way to reset the chip under software control.
431 * On cold boot, we could check the "signature" bit patterns
432 * described in the Fujitsu document. On warm boot, however,
433 * we can predict almost nothing about register values.
435 if (!fe_simple_probe(sc, probe_table))
438 /* Check if our I/O address matches config info on 86965. */
439 n = (fe_inb(sc, FE_BMPR19) & FE_B19_ADDR) >> FE_B19_ADDR_SHIFT;
440 if (baseaddr[n] != iobase)
444 * We are now almost sure we have an MB86965 at the given
445 * address. So, read EEPROM through it. We have to write
446 * into LSI registers to read from EEPROM. I want to avoid it
447 * at this stage, but I cannot test the presence of the chip
448 * any further without reading EEPROM. FIXME.
450 fe_read_eeprom_jli(sc, eeprom);
452 /* Make sure that config info in EEPROM and 86965 agree. */
453 if (eeprom[FE_EEPROM_CONF] != fe_inb(sc, FE_BMPR19))
456 /* Use 86965 media selection scheme, unless othewise
457 specified. It is "AUTO always" and "select with BMPR13".
458 This behaviour covers most of the 86965 based board (as
459 minimum requirements.) It is backward compatible with
460 previous versions, also. */
462 sc->defmedia = MB_HA;
463 sc->msel = fe_msel_965;
465 /* Perform board-specific probe. */
466 if ((irqmap = fe_probe_jli_re1000p(sc, eeprom)) == NULL)
469 /* Find the IRQ read from EEPROM. */
470 n = (fe_inb(sc, FE_BMPR19) & FE_B19_IRQ) >> FE_B19_IRQ_SHIFT;
473 /* Try to determine IRQ setting. */
474 error = bus_get_resource(dev, SYS_RES_IRQ, 0, &irq, NULL);
475 if (error && xirq == NO_IRQ) {
476 /* The device must be configured with an explicit IRQ. */
477 device_printf(dev, "IRQ auto-detection does not work\n");
479 } else if (error && xirq != NO_IRQ) {
480 /* Just use the probed IRQ value. */
481 bus_set_resource(dev, SYS_RES_IRQ, 0, xirq, 1);
482 } else if (!error && xirq == NO_IRQ) {
483 /* No problem. Go ahead. */
484 } else if (irq == xirq) {
485 /* Good. Go ahead. */
487 /* User must be warned in this case. */
488 sc->stability |= UNSTABLE_IRQ;
491 /* Setup a hook, which resets te 86965 when the driver is being
492 initialized. This may solve a nasty bug. FIXME. */
493 sc->init = fe_init_jli;
500 * Probe and initialization for Contec C-NET(9N)E series.
503 /* TODO: Should be in "if_fereg.h" */
504 #define FE_CNET9NE_INTR 0x10 /* Interrupt Mask? */
507 fe_init_cnet9ne(struct fe_softc *sc)
509 /* Enable interrupt? FIXME. */
510 fe_outb(sc, FE_CNET9NE_INTR, 0x10);
514 fe_probe_cnet9ne (device_t dev)
516 struct fe_softc *sc = device_get_softc(dev);
519 static struct fe_simple_probe_struct probe_table [] = {
520 { FE_DLCR2, 0x58, 0x00 },
521 { FE_DLCR4, 0x08, 0x00 },
525 /* See if the specified I/O address is possible for C-NET(9N)E. */
526 if (bus_get_resource(dev, SYS_RES_IOPORT, 0, &iobase, NULL) != 0)
528 if (iobase != 0x73D0)
531 if (fe98_alloc_port(dev, FE_TYPE_CNET9NE))
534 /* Fill the softc struct with default values. */
535 fe_softc_defaults(sc);
537 /* See if the card is on its address. */
538 if (!fe_simple_probe(sc, probe_table))
541 /* Get our station address from EEPROM. */
542 fe_inblk(sc, 0x18, sc->sc_enaddr, ETHER_ADDR_LEN);
544 /* Make sure it is Contec's. */
545 if (!valid_Ether_p(sc->sc_enaddr, 0x00804C))
548 /* Determine the card type. */
549 if (sc->sc_enaddr[3] == 0x06) {
550 sc->typestr = "C-NET(9N)C";
552 /* We seems to need our own IDENT bits... FIXME. */
553 sc->proto_dlcr7 = FE_D7_BYTSWP_LH | FE_D7_IDENT_NICE;
555 /* C-NET(9N)C requires an explicit IRQ to work. */
556 if (bus_get_resource(dev, SYS_RES_IRQ, 0, &irq, NULL) != 0) {
557 fe_irq_failure(sc->typestr, sc->sc_unit, NO_IRQ, NULL);
561 sc->typestr = "C-NET(9N)E";
563 /* C-NET(9N)E works only IRQ5. */
564 if (bus_get_resource(dev, SYS_RES_IRQ, 0, &irq, NULL) != 0)
567 fe_irq_failure(sc->typestr, sc->sc_unit, irq, "5");
571 /* We need an init hook to initialize ASIC before we start. */
572 sc->init = fe_init_cnet9ne;
575 /* C-NET(9N)E has 64KB SRAM. */
576 sc->proto_dlcr6 = FE_D6_BUFSIZ_64KB | FE_D6_TXBSIZ_2x4KB
577 | FE_D6_BBW_WORD | FE_D6_SBW_WORD | FE_D6_SRAM;
584 * Probe for Contec C-NET(98)P2 series.
585 * (Logitec LAN-98TP/LAN-98T25P - parhaps)
588 fe_probe_ssi(device_t dev)
590 struct fe_softc *sc = device_get_softc(dev);
593 u_char eeprom [SSI_EEPROM_SIZE];
594 static struct fe_simple_probe_struct probe_table [] = {
595 { FE_DLCR2, 0x08, 0x00 },
596 { FE_DLCR4, 0x08, 0x00 },
599 static u_short const irqmap[] = {
601 NO_IRQ, NO_IRQ, NO_IRQ, 3, NO_IRQ, 5, 6, NO_IRQ,
602 NO_IRQ, 9, 10, NO_IRQ, 12, 13, NO_IRQ, NO_IRQ,
603 /* INT3 INT41 INT5 INT6 */
606 /* See if the specified I/O address is possible for 78Q8377A. */
607 /* [0-D]3D0 are allowed. */
608 if (bus_get_resource(dev, SYS_RES_IOPORT, 0, &iobase, NULL) != 0)
610 if ((iobase & 0xFFF) != 0x3D0)
613 if (fe98_alloc_port(dev, FE_TYPE_SSI))
616 /* Fill the softc struct with default values. */
617 fe_softc_defaults(sc);
619 /* See if the card is on its address. */
620 if (!fe_simple_probe(sc, probe_table))
623 /* We now have to read the config EEPROM. We should be very
624 careful, since doing so destroys a register. (Remember, we
625 are not yet sure we have a C-NET(98)P2 board here.) Don't
626 remember to select BMPRs bofore reading EEPROM, since other
627 register bank may be selected before the probe() is called. */
628 fe_read_eeprom_ssi(sc, eeprom);
630 /* Make sure the Ethernet (MAC) station address is of Contec's. */
631 if (!valid_Ether_p(eeprom + FE_SSI_EEP_ADDR, 0x00804C))
633 bcopy(eeprom + FE_SSI_EEP_ADDR, sc->sc_enaddr, ETHER_ADDR_LEN);
635 /* Setup the board type. */
636 sc->typestr = "C-NET(98)P2";
638 /* Non-PnP mode, set static resource from eeprom. */
639 if (!isa_get_vendorid(dev)) {
640 /* Get IRQ configuration from EEPROM. */
641 irq = irqmap[eeprom[FE_SSI_EEP_IRQ]];
643 fe_irq_failure(sc->typestr, sc->sc_unit, irq,
647 bus_set_resource(dev, SYS_RES_IRQ, 0, irq, 1);
650 /* Get Duplex-mode configuration from EEPROM. */
651 sc->proto_dlcr4 |= (eeprom[FE_SSI_EEP_DUPLEX] & FE_D4_DSC);
653 /* Fill softc struct accordingly. */
655 sc->defmedia = MB_HT;
662 * Probe for TDK LAC-98012/013/025/9N011 - parhaps.
665 fe_probe_lnx(device_t dev)
667 struct fe_softc *sc = device_get_softc(dev);
670 u_char eeprom [LNX_EEPROM_SIZE];
672 static struct fe_simple_probe_struct probe_table [] = {
673 { FE_DLCR2, 0x58, 0x00 },
674 { FE_DLCR4, 0x08, 0x00 },
678 /* See if the specified I/O address is possible for TDK/LANX boards. */
679 /* 0D0, 4D0, 8D0, and CD0 are allowed. */
680 if (bus_get_resource(dev, SYS_RES_IOPORT, 0, &iobase, NULL) != 0)
682 if ((iobase & ~0xC00) != 0xD0)
685 if (fe98_alloc_port(dev, FE_TYPE_LNX))
688 /* Fill the softc struct with default values. */
689 fe_softc_defaults(sc);
691 /* See if the card is on its address. */
692 if (!fe_simple_probe(sc, probe_table))
695 /* We now have to read the config EEPROM. We should be very
696 careful, since doing so destroys a register. (Remember, we
697 are not yet sure we have a LAC-98012/98013 board here.) */
698 fe_read_eeprom_lnx(sc, eeprom);
700 /* Make sure the Ethernet (MAC) station address is of TDK/LANX's. */
701 if (!valid_Ether_p(eeprom, 0x008098))
703 bcopy(eeprom, sc->sc_enaddr, ETHER_ADDR_LEN);
705 /* Setup the board type. */
706 sc->typestr = "LAC-98012/98013";
708 /* This looks like a TDK/LANX board. It requires an
709 explicit IRQ setting in config. Make sure we have one,
710 determining an appropriate value for the IRQ control
713 if (bus_get_resource(dev, SYS_RES_IRQ, 0, &irq, NULL) != 0)
716 case 3 : sc->priv_info = 0x10 | LNX_CLK_LO | LNX_SDA_HI; break;
717 case 5 : sc->priv_info = 0x20 | LNX_CLK_LO | LNX_SDA_HI; break;
718 case 6 : sc->priv_info = 0x40 | LNX_CLK_LO | LNX_SDA_HI; break;
719 case 12: sc->priv_info = 0x80 | LNX_CLK_LO | LNX_SDA_HI; break;
721 fe_irq_failure(sc->typestr, sc->sc_unit, irq, "3/5/6/12");
725 /* LAC-98's system bus width is 8-bit. */
726 sc->proto_dlcr6 = FE_D6_BUFSIZ_32KB | FE_D6_TXBSIZ_2x2KB
727 | FE_D6_BBW_BYTE | FE_D6_SBW_BYTE | FE_D6_SRAM_150ns;
729 /* Setup hooks. We need a special initialization procedure. */
730 sc->init = fe_init_lnx;
737 * Probe for Gateway Communications' old cards.
738 * (both as Generic MB86960 probe routine)
741 fe_probe_gwy(device_t dev)
743 struct fe_softc *sc = device_get_softc(dev);
745 static struct fe_simple_probe_struct probe_table [] = {
746 /* { FE_DLCR2, 0x70, 0x00 }, */
747 { FE_DLCR2, 0x58, 0x00 },
748 { FE_DLCR4, 0x08, 0x00 },
754 * I'm not sure which address is possible, so accepts any.
757 if (fe98_alloc_port(dev, FE_TYPE_GWY))
760 /* Fill the softc struct with default values. */
761 fe_softc_defaults(sc);
763 /* See if the card is on its address. */
764 if (!fe_simple_probe(sc, probe_table))
767 /* Get our station address from EEPROM. */
768 fe_inblk(sc, 0x18, sc->sc_enaddr, ETHER_ADDR_LEN);
769 if (!valid_Ether_p(sc->sc_enaddr, 0x000000))
772 /* Determine the card type. */
773 sc->typestr = "Generic MB86960 Ethernet";
774 if (valid_Ether_p(sc->sc_enaddr, 0x000061))
775 sc->typestr = "Gateway Ethernet (Fujitsu chipset)";
777 /* Gateway's board requires an explicit IRQ to work, since it
778 is not possible to probe the setting of jumpers. */
779 if (bus_get_resource(dev, SYS_RES_IRQ, 0, NULL, NULL) != 0) {
780 fe_irq_failure(sc->typestr, sc->sc_unit, NO_IRQ, NULL);
789 * Probe for Ungermann-Bass Access/PC N98C+(Model 85152).
792 fe_probe_ubn(device_t dev)
794 struct fe_softc *sc = device_get_softc(dev);
799 static struct fe_simple_probe_struct const probe_table [] = {
800 { FE_DLCR2, 0x58, 0x00 },
801 { FE_DLCR4, 0x08, 0x00 },
805 /* See if the specified I/O address is possible for Access/PC. */
806 /* [01][048C]D0 are allowed. */
807 if (bus_get_resource(dev, SYS_RES_IOPORT, 0, &iobase, NULL) != 0)
809 if ((iobase & ~0x1C00) != 0xD0)
812 if (fe98_alloc_port(dev, FE_TYPE_UBN))
815 /* Fill the softc struct with default values. */
816 fe_softc_defaults(sc);
819 if (!fe_simple_probe(sc, probe_table))
822 /* NOTE: Access/NOTE N98 sometimes freeze when reading station
823 address. In case of using it togather with C-NET(9N)C,
824 this problem usually happens.
825 Writing DLCR7 prevents freezing, but I don't know why. FIXME. */
827 /* Save the current value for the DLCR7 register we are about
829 save7 = fe_inb(sc, FE_DLCR7);
830 fe_outb(sc, FE_DLCR7,
831 sc->proto_dlcr7 | FE_D7_RBS_BMPR | FE_D7_POWER_UP);
833 /* Get our station address form ID ROM and make sure it is UBN's. */
834 fe_inblk(sc, 0x18, sc->sc_enaddr, ETHER_ADDR_LEN);
835 if (!valid_Ether_p(sc->sc_enaddr, 0x00DD01))
838 /* Calculate checksum. */
839 sum = fe_inb(sc, 0x1e);
840 for (i = 0; i < ETHER_ADDR_LEN; i++)
841 sum ^= sc->sc_enaddr[i];
846 /* Setup the board type. */
847 sc->typestr = "Access/PC";
849 /* This looks like an AccessPC/N98C+ board. It requires an
850 explicit IRQ setting in config. Make sure we have one,
851 determining an appropriate value for the IRQ control
854 bus_get_resource(dev, SYS_RES_IRQ, 0, &irq, NULL);
856 case 3: sc->priv_info = 0x01; break;
857 case 5: sc->priv_info = 0x02; break;
858 case 6: sc->priv_info = 0x04; break;
859 case 12: sc->priv_info = 0x08; break;
861 fe_irq_failure(sc->typestr, sc->sc_unit, irq, "3/5/6/12");
865 /* Setup hooks. We need a special initialization procedure. */
866 sc->init = fe_init_ubn;
871 fe_outb(sc, FE_DLCR7, save7);
877 * REX boards(non-JLI type) support routine.
880 #define REX_EEPROM_SIZE 32
884 fe_read_eeprom_rex(struct fe_softc *sc, u_char *data)
890 save16 = fe_inb(sc, 0x10);
892 /* Issue a start condition. */
893 val = fe_inb(sc, 0x10) & 0xf0;
894 fe_outb(sc, 0x10, val);
896 (void) fe_inb(sc, 0x10);
897 (void) fe_inb(sc, 0x10);
898 (void) fe_inb(sc, 0x10);
899 (void) fe_inb(sc, 0x10);
901 /* Read bytes from EEPROM. */
902 for (i = 0; i < REX_EEPROM_SIZE; i++) {
903 /* Read a byte and store it into the buffer. */
905 for (bit = 0x01; bit != 0x00; bit <<= 1)
906 if (fe_inb(sc, 0x10) & REX_DAT)
911 fe_outb(sc, 0x10, save16);
914 /* Report what we got. */
916 data -= REX_EEPROM_SIZE;
917 for (i = 0; i < REX_EEPROM_SIZE; i += 16) {
918 printf("fe%d: EEPROM(REX):%3x: %16D\n",
919 sc->sc_unit, i, data + i, " ");
927 fe_init_rex(struct fe_softc *sc)
929 /* Setup IRQ control register on the ASIC. */
930 fe_outb(sc, 0x10, sc->priv_info);
934 * Probe for RATOC REX-9880/81/82/83 series.
937 fe_probe_rex(device_t dev)
939 struct fe_softc *sc = device_get_softc(dev);
943 u_char eeprom [REX_EEPROM_SIZE];
945 static struct fe_simple_probe_struct probe_table [] = {
946 { FE_DLCR2, 0x58, 0x00 },
947 { FE_DLCR4, 0x08, 0x00 },
951 /* See if the specified I/O address is possible for REX-9880. */
952 /* 6[46CE]D0 are allowed. */
953 if (bus_get_resource(dev, SYS_RES_IOPORT, 0, &iobase, NULL) != 0)
955 if ((iobase & ~0xA00) != 0x64D0)
958 if (fe98_alloc_port(dev, FE_TYPE_REX))
961 /* Fill the softc struct with default values. */
962 fe_softc_defaults(sc);
964 /* See if the card is on its address. */
965 if (!fe_simple_probe(sc, probe_table))
968 /* We now have to read the config EEPROM. We should be very
969 careful, since doing so destroys a register. (Remember, we
970 are not yet sure we have a REX-9880 board here.) */
971 fe_read_eeprom_rex(sc, eeprom);
972 for (i = 0; i < ETHER_ADDR_LEN; i++)
973 sc->sc_enaddr[i] = eeprom[7 - i];
975 /* Make sure it is RATOC's. */
976 if (!valid_Ether_p(sc->sc_enaddr, 0x00C0D0) &&
977 !valid_Ether_p(sc->sc_enaddr, 0x00803D))
980 /* Setup the board type. */
981 sc->typestr = "REX-9880/9883";
983 /* This looks like a REX-9880 board. It requires an
984 explicit IRQ setting in config. Make sure we have one,
985 determining an appropriate value for the IRQ control
988 bus_get_resource(dev, SYS_RES_IRQ, 0, &irq, NULL);
990 case 3: sc->priv_info = 0x10; break;
991 case 5: sc->priv_info = 0x20; break;
992 case 6: sc->priv_info = 0x40; break;
993 case 12: sc->priv_info = 0x80; break;
995 fe_irq_failure(sc->typestr, sc->sc_unit, irq, "3/5/6/12");
999 /* Setup hooks. We need a special initialization procedure. */
1000 sc->init = fe_init_rex;
1002 /* REX-9880 has 64KB SRAM. */
1003 sc->proto_dlcr6 = FE_D6_BUFSIZ_64KB | FE_D6_TXBSIZ_2x4KB
1004 | FE_D6_BBW_WORD | FE_D6_SBW_WORD | FE_D6_SRAM;
1006 sc->proto_dlcr7 |= FE_D7_EOPPOL; /* XXX */