Home | History | Annotate | Line # | Download | only in pci
if_tlp_pci.c revision 1.46
      1 /*	$NetBSD: if_tlp_pci.c,v 1.46 2000/08/03 03:07:31 castor Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
      9  * NASA Ames Research Center.
     10  *
     11  * Redistribution and use in source and binary forms, with or without
     12  * modification, are permitted provided that the following conditions
     13  * are met:
     14  * 1. Redistributions of source code must retain the above copyright
     15  *    notice, this list of conditions and the following disclaimer.
     16  * 2. Redistributions in binary form must reproduce the above copyright
     17  *    notice, this list of conditions and the following disclaimer in the
     18  *    documentation and/or other materials provided with the distribution.
     19  * 3. All advertising materials mentioning features or use of this software
     20  *    must display the following acknowledgement:
     21  *	This product includes software developed by the NetBSD
     22  *	Foundation, Inc. and its contributors.
     23  * 4. Neither the name of The NetBSD Foundation nor the names of its
     24  *    contributors may be used to endorse or promote products derived
     25  *    from this software without specific prior written permission.
     26  *
     27  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     28  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     29  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     30  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     31  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     37  * POSSIBILITY OF SUCH DAMAGE.
     38  */
     39 
     40 /*
     41  * PCI bus front-end for the Digital Semiconductor ``Tulip'' (21x4x)
     42  * Ethernet controller family driver.
     43  */
     44 
     45 #include "opt_inet.h"
     46 #include "opt_ns.h"
     47 #include "bpfilter.h"
     48 #include "opt_tlp.h"
     49 
     50 #include <sys/param.h>
     51 #include <sys/systm.h>
     52 #include <sys/mbuf.h>
     53 #include <sys/malloc.h>
     54 #include <sys/kernel.h>
     55 #include <sys/socket.h>
     56 #include <sys/ioctl.h>
     57 #include <sys/errno.h>
     58 #include <sys/device.h>
     59 
     60 #include <machine/endian.h>
     61 
     62 #include <net/if.h>
     63 #include <net/if_dl.h>
     64 #include <net/if_media.h>
     65 #include <net/if_ether.h>
     66 
     67 #if NBPFILTER > 0
     68 #include <net/bpf.h>
     69 #endif
     70 
     71 #ifdef INET
     72 #include <netinet/in.h>
     73 #include <netinet/if_inarp.h>
     74 #endif
     75 
     76 #ifdef NS
     77 #include <netns/ns.h>
     78 #include <netns/ns_if.h>
     79 #endif
     80 
     81 #include <machine/bus.h>
     82 #include <machine/intr.h>
     83 
     84 #include <dev/mii/miivar.h>
     85 #include <dev/mii/mii_bitbang.h>
     86 
     87 #include <dev/ic/tulipreg.h>
     88 #include <dev/ic/tulipvar.h>
     89 
     90 #include <dev/pci/pcivar.h>
     91 #include <dev/pci/pcireg.h>
     92 #include <dev/pci/pcidevs.h>
     93 
     94 /*
     95  * PCI configuration space registers used by the Tulip.
     96  */
     97 #define	TULIP_PCI_IOBA		0x10	/* i/o mapped base */
     98 #define	TULIP_PCI_MMBA		0x14	/* memory mapped base */
     99 #define	TULIP_PCI_CFDA		0x40	/* configuration driver area */
    100 
    101 #define	CFDA_SLEEP		0x80000000	/* sleep mode */
    102 #define	CFDA_SNOOZE		0x40000000	/* snooze mode */
    103 
    104 struct tulip_pci_softc {
    105 	struct tulip_softc sc_tulip;	/* real Tulip softc */
    106 
    107 	/* PCI-specific goo. */
    108 	void	*sc_ih;			/* interrupt handle */
    109 
    110 	pci_chipset_tag_t sc_pc;	/* our PCI chipset */
    111 	pcitag_t sc_pcitag;		/* our PCI tag */
    112 
    113 	int	sc_flags;		/* flags; see below */
    114 
    115 	LIST_HEAD(, tulip_pci_softc) sc_intrslaves;
    116 	LIST_ENTRY(tulip_pci_softc) sc_intrq;
    117 
    118 	/* Our {ROM,interrupt} master. */
    119 	struct tulip_pci_softc *sc_master;
    120 };
    121 
    122 /* sc_flags */
    123 #define	TULIP_PCI_SHAREDINTR	0x01	/* interrupt is shared */
    124 #define	TULIP_PCI_SLAVEINTR	0x02	/* interrupt is slave */
    125 #define	TULIP_PCI_SHAREDROM	0x04	/* ROM is shared */
    126 #define	TULIP_PCI_SLAVEROM	0x08	/* slave of shared ROM */
    127 
    128 int	tlp_pci_match __P((struct device *, struct cfdata *, void *));
    129 void	tlp_pci_attach __P((struct device *, struct device *, void *));
    130 
    131 struct cfattach tlp_pci_ca = {
    132 	sizeof(struct tulip_pci_softc), tlp_pci_match, tlp_pci_attach,
    133 };
    134 
    135 const struct tulip_pci_product {
    136 	u_int32_t	tpp_vendor;	/* PCI vendor ID */
    137 	u_int32_t	tpp_product;	/* PCI product ID */
    138 	tulip_chip_t	tpp_chip;	/* base Tulip chip type */
    139 } tlp_pci_products[] = {
    140 #ifdef TLP_MATCH_21040
    141 	{ PCI_VENDOR_DEC,		PCI_PRODUCT_DEC_21040,
    142 	  TULIP_CHIP_21040 },
    143 #endif
    144 #ifdef TLP_MATCH_21041
    145 	{ PCI_VENDOR_DEC,		PCI_PRODUCT_DEC_21041,
    146 	  TULIP_CHIP_21041 },
    147 #endif
    148 #ifdef TLP_MATCH_21140
    149 	{ PCI_VENDOR_DEC,		PCI_PRODUCT_DEC_21140,
    150 	  TULIP_CHIP_21140 },
    151 #endif
    152 #ifdef TLP_MATCH_21142
    153 	{ PCI_VENDOR_DEC,		PCI_PRODUCT_DEC_21142,
    154 	  TULIP_CHIP_21142 },
    155 #endif
    156 
    157 	{ PCI_VENDOR_LITEON,		PCI_PRODUCT_LITEON_82C168,
    158 	  TULIP_CHIP_82C168 },
    159 
    160 	/*
    161 	 * Note: This is like a MX98725 with Wake-On-LAN and a
    162 	 * 128-bit multicast hash table.
    163 	 */
    164 	{ PCI_VENDOR_LITEON,		PCI_PRODUCT_LITEON_82C115,
    165 	  TULIP_CHIP_82C115 },
    166 
    167 	{ PCI_VENDOR_MACRONIX,		PCI_PRODUCT_MACRONIX_MX98713,
    168 	  TULIP_CHIP_MX98713 },
    169 	{ PCI_VENDOR_MACRONIX,		PCI_PRODUCT_MACRONIX_MX987x5,
    170 	  TULIP_CHIP_MX98715 },
    171 
    172 	{ PCI_VENDOR_COMPEX,		PCI_PRODUCT_COMPEX_RL100TX,
    173 	  TULIP_CHIP_MX98713 },
    174 
    175 	{ PCI_VENDOR_WINBOND,		PCI_PRODUCT_WINBOND_W89C840F,
    176 	  TULIP_CHIP_WB89C840F },
    177 	{ PCI_VENDOR_COMPEX,		PCI_PRODUCT_COMPEX_RL100ATX,
    178 	  TULIP_CHIP_WB89C840F },
    179 
    180 	{ PCI_VENDOR_DAVICOM,		PCI_PRODUCT_DAVICOM_DM9102,
    181 	  TULIP_CHIP_DM9102 },
    182 
    183 	{ PCI_VENDOR_ADMTEK,		PCI_PRODUCT_ADMTEK_AL981,
    184 	  TULIP_CHIP_AL981 },
    185 
    186 #if 0
    187 	{ PCI_VENDOR_ASIX,		PCI_PRODUCT_ASIX_AX88140A,
    188 	  TULIP_CHIP_AX88140 },
    189 #endif
    190 
    191 	{ 0,				0,
    192 	  TULIP_CHIP_INVALID },
    193 };
    194 
    195 struct tlp_pci_quirks {
    196 	void		(*tpq_func) __P((struct tulip_pci_softc *,
    197 			    const u_int8_t *));
    198 	u_int8_t	tpq_oui[3];
    199 };
    200 
    201 void	tlp_pci_dec_quirks __P((struct tulip_pci_softc *,
    202 	    const u_int8_t *));
    203 
    204 void	tlp_pci_znyx_21040_quirks __P((struct tulip_pci_softc *,
    205 	    const u_int8_t *));
    206 void	tlp_pci_smc_21040_quirks __P((struct tulip_pci_softc *,
    207 	    const u_int8_t *));
    208 void	tlp_pci_cogent_21040_quirks __P((struct tulip_pci_softc *,
    209 	    const u_int8_t *));
    210 void	tlp_pci_accton_21040_quirks __P((struct tulip_pci_softc *,
    211 	    const u_int8_t *));
    212 
    213 void	tlp_pci_cobalt_21142_quirks __P((struct tulip_pci_softc *,
    214 	    const u_int8_t *));
    215 
    216 const struct tlp_pci_quirks tlp_pci_21040_quirks[] = {
    217 	{ tlp_pci_znyx_21040_quirks,	{ 0x00, 0xc0, 0x95 } },
    218 	{ tlp_pci_smc_21040_quirks,	{ 0x00, 0x00, 0xc0 } },
    219 	{ tlp_pci_cogent_21040_quirks,	{ 0x00, 0x00, 0x92 } },
    220 	{ tlp_pci_accton_21040_quirks,	{ 0x00, 0x00, 0xe8 } },
    221 	{ NULL,				{ 0, 0, 0 } }
    222 };
    223 
    224 const struct tlp_pci_quirks tlp_pci_21041_quirks[] = {
    225 	{ tlp_pci_dec_quirks,		{ 0x08, 0x00, 0x2b } },
    226 	{ tlp_pci_dec_quirks,		{ 0x00, 0x00, 0xf8 } },
    227 	{ NULL,				{ 0, 0, 0 } }
    228 };
    229 
    230 void	tlp_pci_asante_21140_quirks __P((struct tulip_pci_softc *,
    231 	    const u_int8_t *));
    232 
    233 const struct tlp_pci_quirks tlp_pci_21140_quirks[] = {
    234 	{ tlp_pci_dec_quirks,		{ 0x08, 0x00, 0x2b } },
    235 	{ tlp_pci_dec_quirks,		{ 0x00, 0x00, 0xf8 } },
    236 	{ tlp_pci_asante_21140_quirks,	{ 0x00, 0x00, 0x94 } },
    237 	{ NULL,				{ 0, 0, 0 } }
    238 };
    239 
    240 const struct tlp_pci_quirks tlp_pci_21142_quirks[] = {
    241 	{ tlp_pci_dec_quirks,		{ 0x08, 0x00, 0x2b } },
    242 	{ tlp_pci_dec_quirks,		{ 0x00, 0x00, 0xf8 } },
    243 	{ tlp_pci_cobalt_21142_quirks,	{ 0x00, 0x10, 0xe0 } },
    244 	{ NULL,				{ 0, 0, 0 } }
    245 };
    246 
    247 int	tlp_pci_shared_intr __P((void *));
    248 
    249 const struct tulip_pci_product *tlp_pci_lookup
    250     __P((const struct pci_attach_args *));
    251 void tlp_pci_get_quirks __P((struct tulip_pci_softc *, const u_int8_t *,
    252     const struct tlp_pci_quirks *));
    253 void tlp_pci_check_slaved __P((struct tulip_pci_softc *, int, int));
    254 
    255 const struct tulip_pci_product *
    256 tlp_pci_lookup(pa)
    257 	const struct pci_attach_args *pa;
    258 {
    259 	const struct tulip_pci_product *tpp;
    260 
    261 	for (tpp = tlp_pci_products;
    262 	     tlp_chip_names[tpp->tpp_chip] != NULL;
    263 	     tpp++) {
    264 		if (PCI_VENDOR(pa->pa_id) == tpp->tpp_vendor &&
    265 		    PCI_PRODUCT(pa->pa_id) == tpp->tpp_product)
    266 			return (tpp);
    267 	}
    268 	return (NULL);
    269 }
    270 
    271 void
    272 tlp_pci_get_quirks(psc, enaddr, tpq)
    273 	struct tulip_pci_softc *psc;
    274 	const u_int8_t *enaddr;
    275 	const struct tlp_pci_quirks *tpq;
    276 {
    277 
    278 	for (; tpq->tpq_func != NULL; tpq++) {
    279 		if (tpq->tpq_oui[0] == enaddr[0] &&
    280 		    tpq->tpq_oui[1] == enaddr[1] &&
    281 		    tpq->tpq_oui[2] == enaddr[2]) {
    282 			(*tpq->tpq_func)(psc, enaddr);
    283 			return;
    284 		}
    285 	}
    286 }
    287 
    288 void
    289 tlp_pci_check_slaved(psc, shared, slaved)
    290 	struct tulip_pci_softc *psc;
    291 	int shared, slaved;
    292 {
    293 	extern struct cfdriver tlp_cd;
    294 	struct tulip_pci_softc *cur, *best = NULL;
    295 	struct tulip_softc *sc = &psc->sc_tulip;
    296 	int i;
    297 
    298 	/*
    299 	 * First of all, find the lowest pcidev numbered device on our
    300 	 * bus marked as shared.  That should be our master.
    301 	 */
    302 	for (i = 0; i < tlp_cd.cd_ndevs; i++) {
    303 		if ((cur = tlp_cd.cd_devs[i]) == NULL)
    304 			continue;
    305 		if (cur->sc_tulip.sc_dev.dv_parent != sc->sc_dev.dv_parent)
    306 			continue;
    307 		if ((cur->sc_flags & shared) == 0)
    308 			continue;
    309 		if (cur == psc)
    310 			continue;
    311 		if (best == NULL ||
    312 		    best->sc_tulip.sc_devno > cur->sc_tulip.sc_devno)
    313 			best = cur;
    314 	}
    315 
    316 	if (best != NULL) {
    317 		psc->sc_master = best;
    318 		psc->sc_flags |= (shared | slaved);
    319 	}
    320 }
    321 
    322 int
    323 tlp_pci_match(parent, match, aux)
    324 	struct device *parent;
    325 	struct cfdata *match;
    326 	void *aux;
    327 {
    328 	struct pci_attach_args *pa = aux;
    329 
    330 	if (tlp_pci_lookup(pa) != NULL)
    331 		return (10);	/* beat if_de.c */
    332 
    333 	return (0);
    334 }
    335 
    336 void
    337 tlp_pci_attach(parent, self, aux)
    338 	struct device *parent, *self;
    339 	void *aux;
    340 {
    341 	struct tulip_pci_softc *psc = (void *) self;
    342 	struct tulip_softc *sc = &psc->sc_tulip;
    343 	struct pci_attach_args *pa = aux;
    344 	pci_chipset_tag_t pc = pa->pa_pc;
    345 	pci_intr_handle_t ih;
    346 	const char *intrstr = NULL;
    347 	bus_space_tag_t iot, memt;
    348 	bus_space_handle_t ioh, memh;
    349 	int ioh_valid, memh_valid, i, j;
    350 	const struct tulip_pci_product *tpp;
    351 	u_int8_t enaddr[ETHER_ADDR_LEN];
    352 	u_int32_t val;
    353 	pcireg_t reg;
    354 	int pmreg;
    355 
    356 	sc->sc_devno = pa->pa_device;
    357 	psc->sc_pc = pa->pa_pc;
    358 	psc->sc_pcitag = pa->pa_tag;
    359 
    360 	LIST_INIT(&psc->sc_intrslaves);
    361 
    362 	tpp = tlp_pci_lookup(pa);
    363 	if (tpp == NULL) {
    364 		printf("\n");
    365 		panic("tlp_pci_attach: impossible");
    366 	}
    367 	sc->sc_chip = tpp->tpp_chip;
    368 
    369 	/*
    370 	 * By default, Tulip registers are 8 bytes long (4 bytes
    371 	 * followed by a 4 byte pad).
    372 	 */
    373 	sc->sc_regshift = 3;
    374 
    375 	/*
    376 	 * No power management hooks.
    377 	 * XXX Maybe we should add some!
    378 	 */
    379 	sc->sc_flags |= TULIPF_ENABLED;
    380 
    381 	/*
    382 	 * Get revision info, and set some chip-specific variables.
    383 	 */
    384 	sc->sc_rev = PCI_REVISION(pa->pa_class);
    385 	switch (sc->sc_chip) {
    386 	case TULIP_CHIP_21140:
    387 		if (sc->sc_rev >= 0x20)
    388 			sc->sc_chip = TULIP_CHIP_21140A;
    389 		break;
    390 
    391 	case TULIP_CHIP_21142:
    392 		if (sc->sc_rev >= 0x20)
    393 			sc->sc_chip = TULIP_CHIP_21143;
    394 		break;
    395 
    396 	case TULIP_CHIP_82C168:
    397 		if (sc->sc_rev >= 0x20)
    398 			sc->sc_chip = TULIP_CHIP_82C169;
    399 		break;
    400 
    401 	case TULIP_CHIP_MX98713:
    402 		if (sc->sc_rev >= 0x10)
    403 			sc->sc_chip = TULIP_CHIP_MX98713A;
    404 		break;
    405 
    406 	case TULIP_CHIP_MX98715:
    407 		if (sc->sc_rev >= 0x20)
    408 			sc->sc_chip = TULIP_CHIP_MX98715A;
    409  		if (sc->sc_rev >= 0x25)
    410  			sc->sc_chip = TULIP_CHIP_MX98715AEC_X;
    411 		if (sc->sc_rev >= 0x30)
    412 			sc->sc_chip = TULIP_CHIP_MX98725;
    413 		break;
    414 
    415 	case TULIP_CHIP_WB89C840F:
    416 		sc->sc_regshift = 2;
    417 		break;
    418 
    419 	case TULIP_CHIP_AX88140:
    420 		if (sc->sc_rev >= 0x10)
    421 			sc->sc_chip = TULIP_CHIP_AX88141;
    422 		break;
    423 
    424 	case TULIP_CHIP_DM9102:
    425 		if (sc->sc_rev >= 0x30)
    426 			sc->sc_chip = TULIP_CHIP_DM9102A;
    427 		break;
    428 
    429 	default:
    430 		/* Nothing. */
    431 	}
    432 
    433 	printf(": %s Ethernet, pass %d.%d\n",
    434 	    tlp_chip_names[sc->sc_chip],
    435 	    (sc->sc_rev >> 4) & 0xf, sc->sc_rev & 0xf);
    436 
    437 	switch (sc->sc_chip) {
    438 	case TULIP_CHIP_21040:
    439 		if (sc->sc_rev < 0x20) {
    440 			printf("%s: 21040 must be at least pass 2.0\n",
    441 			    sc->sc_dev.dv_xname);
    442 			return;
    443 		}
    444 		break;
    445 
    446 	case TULIP_CHIP_21140:
    447 		if (sc->sc_rev < 0x11) {
    448 			printf("%s: 21140 must be at least pass 1.1\n",
    449 			    sc->sc_dev.dv_xname);
    450 			return;
    451 		}
    452 		break;
    453 
    454 	default:
    455 		/* Nothing. */
    456 	}
    457 
    458 	/*
    459 	 * Check to see if the device is in power-save mode, and
    460 	 * being it out if necessary.
    461 	 */
    462 	switch (sc->sc_chip) {
    463 	case TULIP_CHIP_21140:
    464 	case TULIP_CHIP_21140A:
    465 	case TULIP_CHIP_21142:
    466 	case TULIP_CHIP_21143:
    467 	case TULIP_CHIP_MX98713A:
    468 	case TULIP_CHIP_MX98715:
    469 	case TULIP_CHIP_MX98715A:
    470 	case TULIP_CHIP_MX98715AEC_X:
    471 	case TULIP_CHIP_MX98725:
    472 	case TULIP_CHIP_DM9102:
    473 	case TULIP_CHIP_DM9102A:
    474 		/*
    475 		 * Clear the "sleep mode" bit in the CFDA register.
    476 		 */
    477 		reg = pci_conf_read(pc, pa->pa_tag, TULIP_PCI_CFDA);
    478 		if (reg & (CFDA_SLEEP|CFDA_SNOOZE))
    479 			pci_conf_write(pc, pa->pa_tag, TULIP_PCI_CFDA,
    480 			    reg & ~(CFDA_SLEEP|CFDA_SNOOZE));
    481 		break;
    482 
    483 	default:
    484 		/* Nothing. */
    485 	}
    486 
    487 	if (pci_get_capability(pc, pa->pa_tag, PCI_CAP_PWRMGMT, &pmreg, 0)) {
    488 		reg = pci_conf_read(pc, pa->pa_tag, pmreg + 4);
    489 		switch (reg & PCI_PMCSR_STATE_MASK) {
    490 		case PCI_PMCSR_STATE_D1:
    491 		case PCI_PMCSR_STATE_D2:
    492 			printf(": waking up from power state D%d\n%s",
    493 			    reg & PCI_PMCSR_STATE_MASK, sc->sc_dev.dv_xname);
    494 			pci_conf_write(pc, pa->pa_tag, pmreg + 4,
    495 			    (reg & ~PCI_PMCSR_STATE_MASK) |
    496 			    PCI_PMCSR_STATE_D0);
    497 			break;
    498 		case PCI_PMCSR_STATE_D3:
    499 			/*
    500 			 * The card has lost all configuration data in
    501 			 * this state, so punt.
    502 			 */
    503 			printf(": unable to wake up from power state D3, "
    504 			       "reboot required.\n");
    505 			pci_conf_write(pc, pa->pa_tag, pmreg + 4,
    506 			    (reg & ~PCI_PMCSR_STATE_MASK) |
    507 			    PCI_PMCSR_STATE_D0);
    508 			return;
    509 		}
    510 	}
    511 
    512 	/*
    513 	 * Map the device.
    514 	 */
    515 	ioh_valid = (pci_mapreg_map(pa, TULIP_PCI_IOBA,
    516 	    PCI_MAPREG_TYPE_IO, 0,
    517 	    &iot, &ioh, NULL, NULL) == 0);
    518 	memh_valid = (pci_mapreg_map(pa, TULIP_PCI_MMBA,
    519 	    PCI_MAPREG_TYPE_MEM|PCI_MAPREG_MEM_TYPE_32BIT, 0,
    520 	    &memt, &memh, NULL, NULL) == 0);
    521 
    522 	if (memh_valid) {
    523 		sc->sc_st = memt;
    524 		sc->sc_sh = memh;
    525 	} else if (ioh_valid) {
    526 		sc->sc_st = iot;
    527 		sc->sc_sh = ioh;
    528 	} else {
    529 		printf(": unable to map device registers\n");
    530 		return;
    531 	}
    532 
    533 	sc->sc_dmat = pa->pa_dmat;
    534 
    535 	/*
    536 	 * Make sure bus mastering is enabled.
    537 	 */
    538 	pci_conf_write(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG,
    539 	    pci_conf_read(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG) |
    540 	    PCI_COMMAND_MASTER_ENABLE);
    541 
    542 	/*
    543 	 * Get the cacheline size.
    544 	 */
    545 	sc->sc_cacheline = PCI_CACHELINE(pci_conf_read(pc, pa->pa_tag,
    546 	    PCI_BHLC_REG));
    547 
    548 	/*
    549 	 * Get PCI data moving command info.
    550 	 */
    551 	if (pa->pa_flags & PCI_FLAGS_MRL_OKAY)
    552 		sc->sc_flags |= TULIPF_MRL;
    553 	if (pa->pa_flags & PCI_FLAGS_MRM_OKAY)
    554 		sc->sc_flags |= TULIPF_MRM;
    555 	if (pa->pa_flags & PCI_FLAGS_MWI_OKAY)
    556 		sc->sc_flags |= TULIPF_MWI;
    557 
    558 	/*
    559 	 * Read the contents of the Ethernet Address ROM/SROM.
    560 	 */
    561 	switch (sc->sc_chip) {
    562 	case TULIP_CHIP_21040:
    563 		sc->sc_srom_addrbits = 6;
    564 		sc->sc_srom = malloc(TULIP_ROM_SIZE(6), M_DEVBUF, M_NOWAIT);
    565 		TULIP_WRITE(sc, CSR_MIIROM, MIIROM_SROMCS);
    566 		for (i = 0; i < TULIP_ROM_SIZE(6); i++) {
    567 			for (j = 0; j < 10000; j++) {
    568 				val = TULIP_READ(sc, CSR_MIIROM);
    569 				if ((val & MIIROM_DN) == 0)
    570 					break;
    571 			}
    572 			sc->sc_srom[i] = val & MIIROM_DATA;
    573 		}
    574 		break;
    575 
    576 	case TULIP_CHIP_82C168:
    577 	case TULIP_CHIP_82C169:
    578 	    {
    579 		sc->sc_srom_addrbits = 2;
    580 		sc->sc_srom = malloc(TULIP_ROM_SIZE(2), M_DEVBUF, M_NOWAIT);
    581 
    582 		/*
    583 		 * The Lite-On PNIC stores the Ethernet address in
    584 		 * the first 3 words of the EEPROM.  EEPROM access
    585 		 * is not like the other Tulip chips.
    586 		 */
    587 		for (i = 0; i < 6; i += 2) {
    588 			TULIP_WRITE(sc, CSR_PNIC_SROMCTL,
    589 			    PNIC_SROMCTL_READ | (i >> 1));
    590 			for (j = 0; j < 500; j++) {
    591 				delay(2);
    592 				val = TULIP_READ(sc, CSR_MIIROM);
    593 				if ((val & PNIC_MIIROM_BUSY) == 0)
    594 					break;
    595 			}
    596 			if (val & PNIC_MIIROM_BUSY) {
    597 				printf("%s: EEPROM timed out\n",
    598 				    sc->sc_dev.dv_xname);
    599 				return;
    600 			}
    601 			val &= PNIC_MIIROM_DATA;
    602 			sc->sc_srom[i] = val >> 8;
    603 			sc->sc_srom[i + 1] = val & 0xff;
    604 		}
    605 		break;
    606 	    }
    607 
    608 	default:
    609 		if (tlp_read_srom(sc) == 0)
    610 			goto cant_cope;
    611 		break;
    612 	}
    613 
    614 	/*
    615 	 * Deal with chip/board quirks.  This includes setting up
    616 	 * the mediasw, and extracting the Ethernet address from
    617 	 * the rombuf.
    618 	 */
    619 	switch (sc->sc_chip) {
    620 	case TULIP_CHIP_21040:
    621 		/* Check for a slaved ROM on a multi-port board. */
    622 		tlp_pci_check_slaved(psc, TULIP_PCI_SHAREDROM,
    623 		    TULIP_PCI_SLAVEROM);
    624 		if (psc->sc_flags & TULIP_PCI_SLAVEROM)
    625 			memcpy(sc->sc_srom, psc->sc_master->sc_tulip.sc_srom,
    626 			    sizeof(sc->sc_srom));
    627 
    628 		/*
    629 		 * Parse the Ethernet Address ROM.
    630 		 */
    631 		if (tlp_parse_old_srom(sc, enaddr) == 0)
    632 			goto cant_cope;
    633 
    634 		/*
    635 		 * If we have a slaved ROM, adjust the Ethernet address.
    636 		 */
    637 		if (psc->sc_flags & TULIP_PCI_SLAVEROM)
    638 			enaddr[5] +=
    639 			    sc->sc_devno - psc->sc_master->sc_tulip.sc_devno;
    640 
    641 		/*
    642 		 * All 21040 boards start out with the same
    643 		 * media switch.
    644 		 */
    645 		sc->sc_mediasw = &tlp_21040_mediasw;
    646 
    647 		/*
    648 		 * Deal with any quirks this board might have.
    649 		 */
    650 		tlp_pci_get_quirks(psc, enaddr, tlp_pci_21040_quirks);
    651 		break;
    652 
    653 	case TULIP_CHIP_21041:
    654 		/* Check for a slaved ROM on a multi-port board. */
    655 		tlp_pci_check_slaved(psc, TULIP_PCI_SHAREDROM,
    656 		    TULIP_PCI_SLAVEROM);
    657 		if (psc->sc_flags & TULIP_PCI_SLAVEROM)
    658 			memcpy(sc->sc_srom, psc->sc_master->sc_tulip.sc_srom,
    659 			    sizeof(sc->sc_srom));
    660 
    661 		/* Check for new format SROM. */
    662 		if (tlp_isv_srom_enaddr(sc, enaddr) == 0) {
    663 			/*
    664 			 * Not an ISV SROM; try the old DEC Ethernet Address
    665 			 * ROM format.
    666 			 */
    667 			if (tlp_parse_old_srom(sc, enaddr) == 0)
    668 				goto cant_cope;
    669 		}
    670 
    671 		/*
    672 		 * All 21041 boards use the same media switch; they all
    673 		 * work basically the same!  Yippee!
    674 		 */
    675 		sc->sc_mediasw = &tlp_21041_mediasw;
    676 
    677 		/*
    678 		 * Deal with any quirks this board might have.
    679 		 */
    680 		tlp_pci_get_quirks(psc, enaddr, tlp_pci_21041_quirks);
    681 		break;
    682 
    683 	case TULIP_CHIP_21140:
    684 	case TULIP_CHIP_21140A:
    685 		/* Check for new format SROM. */
    686 		if (tlp_isv_srom_enaddr(sc, enaddr) == 0) {
    687 			/*
    688 			 * Not an ISV SROM; try the old DEC Ethernet Address
    689 			 * ROM format.
    690 			 */
    691 			if (tlp_parse_old_srom(sc, enaddr) == 0)
    692 				goto cant_cope;
    693 		} else {
    694 			/*
    695 			 * We start out with the 2114x ISV media switch.
    696 			 * When we search for quirks, we may change to
    697 			 * a different switch.
    698 			 */
    699 			sc->sc_mediasw = &tlp_2114x_isv_mediasw;
    700 		}
    701 
    702 		/*
    703 		 * Deal with any quirks this board might have.
    704 		 */
    705 		tlp_pci_get_quirks(psc, enaddr, tlp_pci_21140_quirks);
    706 
    707 		/*
    708 		 * Bail out now if we can't deal with this board.
    709 		 */
    710 		if (sc->sc_mediasw == NULL)
    711 			goto cant_cope;
    712 		break;
    713 
    714 	case TULIP_CHIP_21142:
    715 	case TULIP_CHIP_21143:
    716 		/* Check for new format SROM. */
    717 		if (tlp_isv_srom_enaddr(sc, enaddr) == 0) {
    718 			/*
    719 			 * Not an ISV SROM; try the old DEC Ethernet Address
    720 			 * ROM format.
    721 			 */
    722 			if (tlp_parse_old_srom(sc, enaddr) == 0)
    723 				goto cant_cope;
    724 		} else {
    725 			/*
    726 			 * We start out with the 2114x ISV media switch.
    727 			 * When we search for quirks, we may change to
    728 			 * a different switch.
    729 			 */
    730 			sc->sc_mediasw = &tlp_2114x_isv_mediasw;
    731 		}
    732 
    733 		/*
    734 		 * Deal with any quirks this board might have.
    735 		 */
    736 		tlp_pci_get_quirks(psc, enaddr, tlp_pci_21142_quirks);
    737 
    738 		/*
    739 		 * Bail out now if we can't deal with this board.
    740 		 */
    741 		if (sc->sc_mediasw == NULL)
    742 			goto cant_cope;
    743 		break;
    744 
    745 	case TULIP_CHIP_82C168:
    746 	case TULIP_CHIP_82C169:
    747 		/*
    748 		 * Lite-On PNIC's Ethernet address is the first 6
    749 		 * bytes of its EEPROM.
    750 		 */
    751 		memcpy(enaddr, sc->sc_srom, ETHER_ADDR_LEN);
    752 
    753 		/*
    754 		 * Lite-On PNICs always use the same mediasw; we
    755 		 * select MII vs. internal NWAY automatically.
    756 		 */
    757 		sc->sc_mediasw = &tlp_pnic_mediasw;
    758 		break;
    759 
    760 	case TULIP_CHIP_MX98713:
    761 		/*
    762 		 * The Macronix MX98713 has an MII and GPIO, but no
    763 		 * internal Nway block.  This chip is basically a
    764 		 * perfect 21140A clone, with the exception of the
    765 		 * a magic register frobbing in order to make the
    766 		 * interface function.
    767 		 */
    768 		if (tlp_isv_srom_enaddr(sc, enaddr)) {
    769 			sc->sc_mediasw = &tlp_2114x_isv_mediasw;
    770 			break;
    771 		}
    772 		/* FALLTHROUGH */
    773 
    774 	case TULIP_CHIP_82C115:
    775 		/*
    776 		 * Yippee!  The Lite-On 82C115 is a clone of
    777 		 * the MX98725 (the data sheet even says `MXIC'
    778 		 * on it)!  Imagine that, a clone of a clone.
    779 		 *
    780 		 * The differences are really minimal:
    781 		 *
    782 		 *	- Wake-On-LAN support
    783 		 *	- 128-bit multicast hash table, rather than
    784 		 *	  the standard 512-bit hash table
    785 		 */
    786 		/* FALLTHROUGH */
    787 
    788 	case TULIP_CHIP_MX98713A:
    789 	case TULIP_CHIP_MX98715A:
    790 	case TULIP_CHIP_MX98715AEC_X:
    791 	case TULIP_CHIP_MX98725:
    792 		/*
    793 		 * The MX98713A has an MII as well as an internal Nway block,
    794 		 * but no GPIO.  The MX98715 and MX98725 have an internal
    795 		 * Nway block only.
    796 		 *
    797 		 * The internal Nway block, unlike the Lite-On PNIC's, does
    798 		 * just that - performs Nway.  Once autonegotiation completes,
    799 		 * we must program the GPR media information into the chip.
    800 		 *
    801 		 * The byte offset of the Ethernet address is stored at
    802 		 * offset 0x70.
    803 		 */
    804 		memcpy(enaddr, &sc->sc_srom[sc->sc_srom[0x70]], ETHER_ADDR_LEN);
    805 		sc->sc_mediasw = &tlp_pmac_mediasw;
    806 		break;
    807 
    808 	case TULIP_CHIP_WB89C840F:
    809 		/*
    810 		 * Winbond 89C840F's Ethernet address is the first
    811 		 * 6 bytes of its EEPROM.
    812 		 */
    813 		memcpy(enaddr, sc->sc_srom, ETHER_ADDR_LEN);
    814 
    815 		/*
    816 		 * Winbond 89C840F has an MII attached to the SIO.
    817 		 */
    818 		sc->sc_mediasw = &tlp_sio_mii_mediasw;
    819 		break;
    820 
    821 	case TULIP_CHIP_AL981:
    822 		/*
    823 		 * The ADMtek AL981's Ethernet address is located
    824 		 * at offset 8 of its EEPROM.
    825 		 */
    826 		memcpy(enaddr, &sc->sc_srom[8], ETHER_ADDR_LEN);
    827 
    828 		/*
    829 		 * ADMtek AL981 has a built-in PHY accessed through
    830 		 * special registers.
    831 		 */
    832 		sc->sc_mediasw = &tlp_al981_mediasw;
    833 		break;
    834 
    835 	case TULIP_CHIP_DM9102:
    836 	case TULIP_CHIP_DM9102A:
    837 		/*
    838 		 * Some boards with the Davicom chip have an ISV
    839 		 * SROM (mostly DM9102A boards -- trying to describe
    840 		 * the HomePNA PHY, probably) although the data in
    841 		 * them is generally wrong.  Check for ISV format
    842 		 * and grab the Ethernet address that way, and if
    843 		 * that fails, fall back on grabbing it from an
    844 		 * observed offset of 20 (which is where it would
    845 		 * be in an ISV SROM anyhow, tho ISV can cope with
    846 		 * multi-port boards).
    847 		 */
    848 		if (tlp_isv_srom_enaddr(sc, enaddr))
    849 			memcpy(enaddr, &sc->sc_srom[20], ETHER_ADDR_LEN);
    850 
    851 		/*
    852 		 * Davicom chips all have an internal MII interface
    853 		 * and a built-in PHY.  DM9102A also has a an external
    854 		 * MII interface, usually with a HomePNA PHY attached
    855 		 * to it.
    856 		 */
    857 		sc->sc_mediasw = &tlp_dm9102_mediasw;
    858 		break;
    859 
    860 	default:
    861  cant_cope:
    862 		printf("%s: sorry, unable to handle your board\n",
    863 		    sc->sc_dev.dv_xname);
    864 		return;
    865 	}
    866 
    867 	/*
    868 	 * Handle shared interrupts.
    869 	 */
    870 	if (psc->sc_flags & TULIP_PCI_SHAREDINTR) {
    871 		if (psc->sc_master)
    872 			psc->sc_flags |= TULIP_PCI_SLAVEINTR;
    873 		else {
    874 			tlp_pci_check_slaved(psc, TULIP_PCI_SHAREDINTR,
    875 			    TULIP_PCI_SLAVEINTR);
    876 			if (psc->sc_master == NULL)
    877 				psc->sc_master = psc;
    878 		}
    879 		LIST_INSERT_HEAD(&psc->sc_master->sc_intrslaves,
    880 		    psc, sc_intrq);
    881 	}
    882 
    883 	if (psc->sc_flags & TULIP_PCI_SLAVEINTR) {
    884 		printf("%s: sharing interrupt with %s\n",
    885 		    sc->sc_dev.dv_xname,
    886 		    psc->sc_master->sc_tulip.sc_dev.dv_xname);
    887 	} else {
    888 		/*
    889 		 * Map and establish our interrupt.
    890 		 */
    891 		if (pci_intr_map(pc, pa->pa_intrtag, pa->pa_intrpin,
    892 		    pa->pa_intrline, &ih)) {
    893 			printf("%s: unable to map interrupt\n",
    894 			    sc->sc_dev.dv_xname);
    895 			return;
    896 		}
    897 		intrstr = pci_intr_string(pc, ih);
    898 		psc->sc_ih = pci_intr_establish(pc, ih, IPL_NET,
    899 		    (psc->sc_flags & TULIP_PCI_SHAREDINTR) ?
    900 		    tlp_pci_shared_intr : tlp_intr, sc);
    901 		if (psc->sc_ih == NULL) {
    902 			printf("%s: unable to establish interrupt",
    903 			    sc->sc_dev.dv_xname);
    904 			if (intrstr != NULL)
    905 				printf(" at %s", intrstr);
    906 			printf("\n");
    907 			return;
    908 		}
    909 		printf("%s: interrupting at %s\n", sc->sc_dev.dv_xname,
    910 		    intrstr);
    911 	}
    912 
    913 	/*
    914 	 * Finish off the attach.
    915 	 */
    916 	tlp_attach(sc, enaddr);
    917 }
    918 
    919 int
    920 tlp_pci_shared_intr(arg)
    921 	void *arg;
    922 {
    923 	struct tulip_pci_softc *master = arg, *slave;
    924 	int rv = 0;
    925 
    926 	for (slave = LIST_FIRST(&master->sc_intrslaves);
    927 	     slave != NULL;
    928 	     slave = LIST_NEXT(slave, sc_intrq))
    929 		rv |= tlp_intr(&slave->sc_tulip);
    930 
    931 	return (rv);
    932 }
    933 
    934 void
    935 tlp_pci_dec_quirks(psc, enaddr)
    936 	struct tulip_pci_softc *psc;
    937 	const u_int8_t *enaddr;
    938 {
    939 	struct tulip_softc *sc = &psc->sc_tulip;
    940 
    941 	/*
    942 	 * This isn't really a quirk-gathering device, really.  We
    943 	 * just want to get the spiffy DEC board name from the SROM.
    944 	 */
    945 	strcpy(sc->sc_name, "DEC ");
    946 
    947 	if (memcmp(&sc->sc_srom[29], "DE500", 5) == 0 ||
    948 	    memcmp(&sc->sc_srom[29], "DE450", 5) == 0)
    949 		memcpy(&sc->sc_name[4], &sc->sc_srom[29], 8);
    950 }
    951 
    952 void
    953 tlp_pci_znyx_21040_quirks(psc, enaddr)
    954 	struct tulip_pci_softc *psc;
    955 	const u_int8_t *enaddr;
    956 {
    957 	struct tulip_softc *sc = &psc->sc_tulip;
    958 	u_int16_t id = 0;
    959 
    960 	/*
    961 	 * If we have a slaved ROM, just copy the bits from the master.
    962 	 * This is in case we fail the ROM ID check (older boards) and
    963 	 * need to fall back on Ethernet address model checking; that
    964 	 * will fail for slave chips.
    965 	 */
    966 	if (psc->sc_flags & TULIP_PCI_SLAVEROM) {
    967 		strcpy(sc->sc_name, psc->sc_master->sc_tulip.sc_name);
    968 		sc->sc_mediasw = psc->sc_master->sc_tulip.sc_mediasw;
    969 		psc->sc_flags |=
    970 		    psc->sc_master->sc_flags & TULIP_PCI_SHAREDINTR;
    971 		return;
    972 	}
    973 
    974 	if (sc->sc_srom[32] == 0x4a && sc->sc_srom[33] == 0x52) {
    975 		id = sc->sc_srom[37] | (sc->sc_srom[36] << 8);
    976 		switch (id) {
    977  zx312:
    978 		case 0x0602:	/* ZX312 */
    979 			strcpy(sc->sc_name, "ZNYX ZX312");
    980 			return;
    981 
    982 		case 0x0622:	/* ZX312T */
    983 			strcpy(sc->sc_name, "ZNYX ZX312T");
    984 			sc->sc_mediasw = &tlp_21040_tp_mediasw;
    985 			return;
    986 
    987  zx314_inta:
    988 		case 0x0701:	/* ZX314 INTA */
    989 			psc->sc_flags |= TULIP_PCI_SHAREDINTR;
    990 			/* FALLTHROUGH */
    991 		case 0x0711:	/* ZX314 */
    992 			strcpy(sc->sc_name, "ZNYX ZX314");
    993 			psc->sc_flags |= TULIP_PCI_SHAREDROM;
    994 			sc->sc_mediasw = &tlp_21040_tp_mediasw;
    995 			return;
    996 
    997  zx315_inta:
    998 		case 0x0801:	/* ZX315 INTA */
    999 			psc->sc_flags |= TULIP_PCI_SHAREDINTR;
   1000 			/* FALLTHROUGH */
   1001 		case 0x0811:	/* ZX315 */
   1002 			strcpy(sc->sc_name, "ZNYX ZX315");
   1003 			psc->sc_flags |= TULIP_PCI_SHAREDROM;
   1004 			return;
   1005 
   1006 		default:
   1007 			id = 0;
   1008 		}
   1009 	}
   1010 
   1011 	/*
   1012 	 * Deal with boards that have broken ROMs.
   1013 	 */
   1014 	if (id == 0) {
   1015 		if ((enaddr[3] & ~3) == 0xf0 && (enaddr[5] & 3) == 0x00)
   1016 			goto zx314_inta;
   1017 		if ((enaddr[3] & ~3) == 0xf4 && (enaddr[5] & 1) == 0x00)
   1018 			goto zx315_inta;
   1019 		if ((enaddr[3] & ~3) == 0xec)
   1020 			goto zx312;
   1021 	}
   1022 
   1023 	strcpy(sc->sc_name, "ZNYX ZX31x");
   1024 }
   1025 
   1026 void
   1027 tlp_pci_smc_21040_quirks(psc, enaddr)
   1028 	struct tulip_pci_softc *psc;
   1029 	const u_int8_t *enaddr;
   1030 {
   1031 	struct tulip_softc *sc = &psc->sc_tulip;
   1032 	u_int16_t id1, id2, ei;
   1033 	int auibnc = 0, utp = 0;
   1034 	char *cp;
   1035 
   1036 	id1 = sc->sc_srom[0x60] | (sc->sc_srom[0x61] << 8);
   1037 	id2 = sc->sc_srom[0x62] | (sc->sc_srom[0x63] << 8);
   1038 	ei  = sc->sc_srom[0x66] | (sc->sc_srom[0x67] << 8);
   1039 
   1040 	strcpy(sc->sc_name, "SMC 8432");
   1041 	cp = &sc->sc_name[8];
   1042 
   1043 	if ((id1 & 1) == 0) {
   1044 		*cp++ = 'B';
   1045 		auibnc = 1;
   1046 	}
   1047 	if ((id1 & 0xff) > 0x32) {
   1048 		*cp++ = 'T';
   1049 		utp = 1;
   1050 	}
   1051 	if ((id1 & 0x4000) == 0) {
   1052 		*cp++ = 'A';
   1053 		auibnc = 1;
   1054 	}
   1055 	if (id2 == 0x15) {
   1056 		sc->sc_name[7] = '4';
   1057 		*cp++ = '-';
   1058 		*cp++ = 'C';
   1059 		*cp++ = 'H';
   1060 		*cp++ = ei ? '2' : '1';
   1061 	}
   1062 	*cp = '\0';
   1063 
   1064 	if (utp != 0 && auibnc == 0)
   1065 		sc->sc_mediasw = &tlp_21040_tp_mediasw;
   1066 	else if (utp == 0 && auibnc != 0)
   1067 		sc->sc_mediasw = &tlp_21040_auibnc_mediasw;
   1068 }
   1069 
   1070 void
   1071 tlp_pci_cogent_21040_quirks(psc, enaddr)
   1072 	struct tulip_pci_softc *psc;
   1073 	const u_int8_t *enaddr;
   1074 {
   1075 
   1076 	strcpy(psc->sc_tulip.sc_name, "Cogent multi-port");
   1077 	psc->sc_flags |= TULIP_PCI_SHAREDINTR|TULIP_PCI_SHAREDROM;
   1078 }
   1079 
   1080 void
   1081 tlp_pci_accton_21040_quirks(psc, enaddr)
   1082 	struct tulip_pci_softc *psc;
   1083 	const u_int8_t *enaddr;
   1084 {
   1085 
   1086 	strcpy(psc->sc_tulip.sc_name, "ACCTON EN1203");
   1087 }
   1088 
   1089 void	tlp_pci_asante_21140_reset __P((struct tulip_softc *));
   1090 
   1091 void
   1092 tlp_pci_asante_21140_quirks(psc, enaddr)
   1093 	struct tulip_pci_softc *psc;
   1094 	const u_int8_t *enaddr;
   1095 {
   1096 	struct tulip_softc *sc = &psc->sc_tulip;
   1097 
   1098 	/*
   1099 	 * Some Asante boards don't use the ISV SROM format.  For
   1100 	 * those that don't, we initialize the GPIO direction bits,
   1101 	 * and provide our own reset hook, which resets the MII.
   1102 	 *
   1103 	 * All of these boards use SIO-attached-MII media.
   1104 	 */
   1105 	if (sc->sc_mediasw == &tlp_2114x_isv_mediasw)
   1106 		return;
   1107 
   1108 	strcpy(sc->sc_name, "Asante");
   1109 
   1110 	sc->sc_gp_dir = 0xbf;
   1111 	sc->sc_reset = tlp_pci_asante_21140_reset;
   1112 	sc->sc_mediasw = &tlp_sio_mii_mediasw;
   1113 }
   1114 
   1115 void
   1116 tlp_pci_asante_21140_reset(sc)
   1117 	struct tulip_softc *sc;
   1118 {
   1119 
   1120 	TULIP_WRITE(sc, CSR_GPP, GPP_GPC | sc->sc_gp_dir);
   1121 	TULIP_WRITE(sc, CSR_GPP, 0x8);
   1122 	delay(100);
   1123 	TULIP_WRITE(sc, CSR_GPP, 0);
   1124 }
   1125 
   1126 void	tlp_pci_cobalt_21142_reset __P((struct tulip_softc *));
   1127 
   1128 void
   1129 tlp_pci_cobalt_21142_quirks(psc, enaddr)
   1130 	struct tulip_pci_softc *psc;
   1131 	const u_int8_t *enaddr;
   1132 {
   1133 	struct tulip_softc *sc = &psc->sc_tulip;
   1134 
   1135 	/*
   1136 	 * Cobalt Networks interfaces are just MII-on-SIO.
   1137 	 */
   1138 	sc->sc_reset = tlp_pci_cobalt_21142_reset;
   1139 	sc->sc_mediasw = &tlp_sio_mii_mediasw;
   1140 
   1141 	/*
   1142 	 * The Cobalt systems tend to fall back to store-and-forward
   1143 	 * pretty quickly, so we select that from the beginning to
   1144 	 * avoid initial timeouts.
   1145 	 */
   1146 	sc->sc_txthresh = TXTH_SF;
   1147 }
   1148 
   1149 void
   1150 tlp_pci_cobalt_21142_reset(sc)
   1151 	struct tulip_softc *sc;
   1152 {
   1153 	/*
   1154 	 * Reset PHY.
   1155 	 */
   1156 	TULIP_WRITE(sc, CSR_SIAGEN, SIAGEN_CWE | (1 << 16));
   1157 	delay(10);
   1158 	TULIP_WRITE(sc, CSR_SIAGEN, SIAGEN_CWE);
   1159 	delay(10);
   1160 }
   1161