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