Home | History | Annotate | Line # | Download | only in pci
if_tlp_pci.c revision 1.7
      1  1.7  thorpej /*	$NetBSD: if_tlp_pci.c,v 1.7 1999/09/14 05:59:53 thorpej Exp $	*/
      2  1.1  thorpej 
      3  1.1  thorpej /*-
      4  1.1  thorpej  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
      5  1.1  thorpej  * All rights reserved.
      6  1.1  thorpej  *
      7  1.1  thorpej  * This code is derived from software contributed to The NetBSD Foundation
      8  1.1  thorpej  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
      9  1.1  thorpej  * NASA Ames Research Center.
     10  1.1  thorpej  *
     11  1.1  thorpej  * Redistribution and use in source and binary forms, with or without
     12  1.1  thorpej  * modification, are permitted provided that the following conditions
     13  1.1  thorpej  * are met:
     14  1.1  thorpej  * 1. Redistributions of source code must retain the above copyright
     15  1.1  thorpej  *    notice, this list of conditions and the following disclaimer.
     16  1.1  thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     17  1.1  thorpej  *    notice, this list of conditions and the following disclaimer in the
     18  1.1  thorpej  *    documentation and/or other materials provided with the distribution.
     19  1.1  thorpej  * 3. All advertising materials mentioning features or use of this software
     20  1.1  thorpej  *    must display the following acknowledgement:
     21  1.1  thorpej  *	This product includes software developed by the NetBSD
     22  1.1  thorpej  *	Foundation, Inc. and its contributors.
     23  1.1  thorpej  * 4. Neither the name of The NetBSD Foundation nor the names of its
     24  1.1  thorpej  *    contributors may be used to endorse or promote products derived
     25  1.1  thorpej  *    from this software without specific prior written permission.
     26  1.1  thorpej  *
     27  1.1  thorpej  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     28  1.1  thorpej  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     29  1.1  thorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     30  1.1  thorpej  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     31  1.1  thorpej  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     32  1.1  thorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     33  1.1  thorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     34  1.1  thorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     35  1.1  thorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     36  1.1  thorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     37  1.1  thorpej  * POSSIBILITY OF SUCH DAMAGE.
     38  1.1  thorpej  */
     39  1.1  thorpej 
     40  1.1  thorpej /*
     41  1.1  thorpej  * PCI bus front-end for the Digital Semiconductor ``Tulip'' (21x4x)
     42  1.1  thorpej  * Ethernet controller family driver.
     43  1.1  thorpej  */
     44  1.1  thorpej 
     45  1.1  thorpej #include "opt_inet.h"
     46  1.1  thorpej #include "opt_ns.h"
     47  1.1  thorpej #include "bpfilter.h"
     48  1.1  thorpej 
     49  1.1  thorpej #include <sys/param.h>
     50  1.1  thorpej #include <sys/systm.h>
     51  1.1  thorpej #include <sys/mbuf.h>
     52  1.1  thorpej #include <sys/malloc.h>
     53  1.1  thorpej #include <sys/kernel.h>
     54  1.1  thorpej #include <sys/socket.h>
     55  1.1  thorpej #include <sys/ioctl.h>
     56  1.1  thorpej #include <sys/errno.h>
     57  1.1  thorpej #include <sys/device.h>
     58  1.1  thorpej 
     59  1.1  thorpej #include <net/if.h>
     60  1.1  thorpej #include <net/if_dl.h>
     61  1.1  thorpej #include <net/if_media.h>
     62  1.1  thorpej #include <net/if_ether.h>
     63  1.1  thorpej 
     64  1.1  thorpej #if NBPFILTER > 0
     65  1.1  thorpej #include <net/bpf.h>
     66  1.1  thorpej #endif
     67  1.1  thorpej 
     68  1.1  thorpej #ifdef INET
     69  1.1  thorpej #include <netinet/in.h>
     70  1.1  thorpej #include <netinet/if_inarp.h>
     71  1.1  thorpej #endif
     72  1.1  thorpej 
     73  1.1  thorpej #ifdef NS
     74  1.1  thorpej #include <netns/ns.h>
     75  1.1  thorpej #include <netns/ns_if.h>
     76  1.1  thorpej #endif
     77  1.1  thorpej 
     78  1.1  thorpej #include <machine/bus.h>
     79  1.1  thorpej #include <machine/intr.h>
     80  1.1  thorpej 
     81  1.1  thorpej #include <dev/mii/miivar.h>
     82  1.1  thorpej 
     83  1.1  thorpej #include <dev/ic/tulipreg.h>
     84  1.1  thorpej #include <dev/ic/tulipvar.h>
     85  1.1  thorpej 
     86  1.1  thorpej #include <dev/pci/pcivar.h>
     87  1.1  thorpej #include <dev/pci/pcireg.h>
     88  1.1  thorpej #include <dev/pci/pcidevs.h>
     89  1.1  thorpej 
     90  1.1  thorpej /*
     91  1.1  thorpej  * PCI configuration space registers used by the Tulip.
     92  1.1  thorpej  */
     93  1.1  thorpej #define	TULIP_PCI_IOBA		0x10	/* i/o mapped base */
     94  1.1  thorpej #define	TULIP_PCI_MMBA		0x14	/* memory mapped base */
     95  1.1  thorpej 
     96  1.1  thorpej struct tulip_pci_softc {
     97  1.1  thorpej 	struct tulip_softc sc_tulip;	/* real Tulip softc */
     98  1.1  thorpej 
     99  1.1  thorpej 	/* PCI-specific goo. */
    100  1.1  thorpej 	void	*sc_ih;			/* interrupt handle */
    101  1.1  thorpej };
    102  1.1  thorpej 
    103  1.1  thorpej int	tlp_pci_match __P((struct device *, struct cfdata *, void *));
    104  1.1  thorpej void	tlp_pci_attach __P((struct device *, struct device *, void *));
    105  1.1  thorpej 
    106  1.1  thorpej struct cfattach tlp_pci_ca = {
    107  1.1  thorpej 	sizeof(struct tulip_pci_softc), tlp_pci_match, tlp_pci_attach,
    108  1.1  thorpej };
    109  1.1  thorpej 
    110  1.1  thorpej const struct tulip_pci_product {
    111  1.1  thorpej 	u_int32_t	tpp_vendor;	/* PCI vendor ID */
    112  1.1  thorpej 	u_int32_t	tpp_product;	/* PCI product ID */
    113  1.1  thorpej 	tulip_chip_t	tpp_chip;	/* base Tulip chip type */
    114  1.1  thorpej } tlp_pci_products[] = {
    115  1.5  thorpej #ifdef TLP_MATCH_21040
    116  1.1  thorpej 	{ PCI_VENDOR_DEC,		PCI_PRODUCT_DEC_21040,
    117  1.1  thorpej 	  TULIP_CHIP_21040 },
    118  1.5  thorpej #endif
    119  1.5  thorpej #ifdef TLP_MATCH_21041
    120  1.1  thorpej 	{ PCI_VENDOR_DEC,		PCI_PRODUCT_DEC_21041,
    121  1.1  thorpej 	  TULIP_CHIP_21041 },
    122  1.5  thorpej #endif
    123  1.5  thorpej #ifdef TLP_MATCH_21140
    124  1.1  thorpej 	{ PCI_VENDOR_DEC,		PCI_PRODUCT_DEC_21140,
    125  1.1  thorpej 	  TULIP_CHIP_21140 },
    126  1.5  thorpej #endif
    127  1.5  thorpej #ifdef TLP_MATCH_21142
    128  1.1  thorpej 	{ PCI_VENDOR_DEC,		PCI_PRODUCT_DEC_21142,
    129  1.1  thorpej 	  TULIP_CHIP_21142 },
    130  1.1  thorpej #endif
    131  1.1  thorpej 
    132  1.3  thorpej 	{ PCI_VENDOR_LITEON,		PCI_PRODUCT_LITEON_82C168,
    133  1.1  thorpej 	  TULIP_CHIP_82C168 },
    134  1.1  thorpej 
    135  1.1  thorpej #if 0
    136  1.4  thorpej 	/*
    137  1.4  thorpej 	 * Note: This is like a MX98715A with Wake-On-LAN and a
    138  1.4  thorpej 	 * 128-bit multicast hash table.
    139  1.4  thorpej 	 */
    140  1.4  thorpej 	{ PCI_VENDOR_LITEON,		PCI_PRODUCT_LITEON_82C115,
    141  1.4  thorpej 	  TULIP_CHIP_82C115 },
    142  1.4  thorpej #endif
    143  1.4  thorpej 
    144  1.4  thorpej #if 0
    145  1.1  thorpej 	{ PCI_VENDOR_MACRONIX,		PCI_PRODUCT_MACRONIX_MX98713,
    146  1.1  thorpej 	  TULIP_CHIP_MX98713 },
    147  1.1  thorpej 	{ PCI_VENDOR_MACRONIX,		PCI_PRODUCT_MACRONIX_MX987x5,
    148  1.1  thorpej 	  TULIP_CHIP_MX98715 },
    149  1.4  thorpej 
    150  1.4  thorpej 	{ PCI_VENDOR_COMPEX,		PCI_PRODUCT_COMPEX_RL100TX,
    151  1.4  thorpej 	  TULIP_CHIP_MX98713 },
    152  1.1  thorpej #endif
    153  1.1  thorpej 
    154  1.1  thorpej 	{ PCI_VENDOR_WINBOND,		PCI_PRODUCT_WINBOND_W89C840F,
    155  1.1  thorpej 	  TULIP_CHIP_WB89C840F },
    156  1.4  thorpej 	{ PCI_VENDOR_COMPEX,		PCI_PRODUCT_COMPEX_RL100ATX,
    157  1.4  thorpej 	  TULIP_CHIP_WB89C840F },
    158  1.4  thorpej 
    159  1.4  thorpej #if 0
    160  1.4  thorpej 	{ PCI_VENDOR_DAVICOM,		PCI_PRODUCT_DAVICOM_DM9102,
    161  1.4  thorpej 	  TULIP_CHIP_DM9102 },
    162  1.4  thorpej 
    163  1.4  thorpej 	{ PCI_VENDOR_ADMTEK,		PCI_PRODUCT_ADMTEK_AL981,
    164  1.4  thorpej 	  TULIP_CHIP_AL981 },
    165  1.4  thorpej 
    166  1.4  thorpej 	{ PCI_VENDOR_ASIX,		PCI_PRODUCT_ASIX_AX88140A,
    167  1.4  thorpej 	  TULIP_CHIP_AX88140 },
    168  1.4  thorpej #endif
    169  1.1  thorpej 
    170  1.1  thorpej 	{ 0,				0,
    171  1.1  thorpej 	  TULIP_CHIP_INVALID },
    172  1.1  thorpej };
    173  1.1  thorpej 
    174  1.1  thorpej const char *tlp_pci_chip_names[] = TULIP_CHIP_NAMES;
    175  1.1  thorpej 
    176  1.1  thorpej const struct tulip_pci_product *tlp_pci_lookup
    177  1.1  thorpej     __P((const struct pci_attach_args *));
    178  1.1  thorpej 
    179  1.1  thorpej const struct tulip_pci_product *
    180  1.1  thorpej tlp_pci_lookup(pa)
    181  1.1  thorpej 	const struct pci_attach_args *pa;
    182  1.1  thorpej {
    183  1.1  thorpej 	const struct tulip_pci_product *tpp;
    184  1.1  thorpej 
    185  1.1  thorpej 	for (tpp = tlp_pci_products;
    186  1.1  thorpej 	     tlp_pci_chip_names[tpp->tpp_chip] != NULL;
    187  1.1  thorpej 	     tpp++) {
    188  1.1  thorpej 		if (PCI_VENDOR(pa->pa_id) == tpp->tpp_vendor &&
    189  1.1  thorpej 		    PCI_PRODUCT(pa->pa_id) == tpp->tpp_product)
    190  1.1  thorpej 			return (tpp);
    191  1.1  thorpej 	}
    192  1.1  thorpej 	return (NULL);
    193  1.1  thorpej }
    194  1.1  thorpej 
    195  1.1  thorpej int
    196  1.1  thorpej tlp_pci_match(parent, match, aux)
    197  1.1  thorpej 	struct device *parent;
    198  1.1  thorpej 	struct cfdata *match;
    199  1.1  thorpej 	void *aux;
    200  1.1  thorpej {
    201  1.1  thorpej 	struct pci_attach_args *pa = aux;
    202  1.1  thorpej 
    203  1.1  thorpej 	if (tlp_pci_lookup(pa) != NULL)
    204  1.1  thorpej 		return (10);	/* beat if_de.c */
    205  1.1  thorpej 
    206  1.1  thorpej 	return (0);
    207  1.1  thorpej }
    208  1.1  thorpej 
    209  1.1  thorpej void
    210  1.1  thorpej tlp_pci_attach(parent, self, aux)
    211  1.1  thorpej 	struct device *parent, *self;
    212  1.1  thorpej 	void *aux;
    213  1.1  thorpej {
    214  1.1  thorpej 	struct tulip_pci_softc *psc = (void *) self;
    215  1.1  thorpej 	struct tulip_softc *sc = &psc->sc_tulip;
    216  1.1  thorpej 	struct pci_attach_args *pa = aux;
    217  1.1  thorpej 	pci_chipset_tag_t pc = pa->pa_pc;
    218  1.1  thorpej 	pci_intr_handle_t ih;
    219  1.1  thorpej 	const char *intrstr = NULL;
    220  1.1  thorpej 	bus_space_tag_t iot, memt;
    221  1.1  thorpej 	bus_space_handle_t ioh, memh;
    222  1.1  thorpej 	int ioh_valid, memh_valid, i, j;
    223  1.1  thorpej 	const struct tulip_pci_product *tpp;
    224  1.5  thorpej 	u_int8_t enaddr[ETHER_ADDR_LEN];
    225  1.1  thorpej 	u_int32_t val;
    226  1.1  thorpej 	const char *name = NULL;
    227  1.1  thorpej 
    228  1.1  thorpej 	/*
    229  1.1  thorpej 	 * Map the device.
    230  1.1  thorpej 	 */
    231  1.1  thorpej 	ioh_valid = (pci_mapreg_map(pa, TULIP_PCI_IOBA,
    232  1.1  thorpej 	    PCI_MAPREG_TYPE_IO, 0,
    233  1.1  thorpej 	    &iot, &ioh, NULL, NULL) == 0);
    234  1.1  thorpej 	memh_valid = (pci_mapreg_map(pa, TULIP_PCI_MMBA,
    235  1.1  thorpej 	    PCI_MAPREG_TYPE_MEM|PCI_MAPREG_MEM_TYPE_32BIT, 0,
    236  1.1  thorpej 	    &memt, &memh, NULL, NULL) == 0);
    237  1.1  thorpej 
    238  1.1  thorpej 	if (memh_valid) {
    239  1.1  thorpej 		sc->sc_st = memt;
    240  1.1  thorpej 		sc->sc_sh = memh;
    241  1.1  thorpej 	} else if (ioh_valid) {
    242  1.1  thorpej 		sc->sc_st = iot;
    243  1.1  thorpej 		sc->sc_sh = ioh;
    244  1.1  thorpej 	} else {
    245  1.1  thorpej 		printf(": unable to map device registers\n");
    246  1.1  thorpej 		return;
    247  1.1  thorpej 	}
    248  1.1  thorpej 
    249  1.1  thorpej 	tpp = tlp_pci_lookup(pa);
    250  1.1  thorpej 	if (tpp == NULL) {
    251  1.1  thorpej 		printf("\n");
    252  1.1  thorpej 		panic("tlp_pci_attach: impossible");
    253  1.1  thorpej 	}
    254  1.1  thorpej 	sc->sc_chip = tpp->tpp_chip;
    255  1.1  thorpej 
    256  1.1  thorpej 	/*
    257  1.6  thorpej 	 * By default, Tulip registers are 8 bytes long (4 bytes
    258  1.6  thorpej 	 * followed by a 4 byte pad).
    259  1.6  thorpej 	 */
    260  1.6  thorpej 	sc->sc_regshift = 3;
    261  1.6  thorpej 
    262  1.6  thorpej 	/*
    263  1.1  thorpej 	 * Get revision info, and set some chip-specific variables.
    264  1.1  thorpej 	 */
    265  1.1  thorpej 	sc->sc_rev = PCI_REVISION(pa->pa_class);
    266  1.1  thorpej 	switch (sc->sc_chip) {
    267  1.1  thorpej 	case TULIP_CHIP_21140:
    268  1.1  thorpej 		if (sc->sc_rev >= 0x20)
    269  1.1  thorpej 			sc->sc_chip = TULIP_CHIP_21140A;
    270  1.1  thorpej 		break;
    271  1.1  thorpej 
    272  1.1  thorpej 	case TULIP_CHIP_21142:
    273  1.1  thorpej 		if (sc->sc_rev >= 0x20)
    274  1.1  thorpej 			sc->sc_chip = TULIP_CHIP_21143;
    275  1.1  thorpej 		break;
    276  1.1  thorpej 
    277  1.1  thorpej 	case TULIP_CHIP_82C168:
    278  1.1  thorpej 		if (sc->sc_rev >= 0x20)
    279  1.1  thorpej 			sc->sc_chip = TULIP_CHIP_82C169;
    280  1.1  thorpej 		break;
    281  1.1  thorpej 
    282  1.1  thorpej 	case TULIP_CHIP_MX98713:
    283  1.1  thorpej 		if (sc->sc_rev >= 0x10)
    284  1.1  thorpej 			sc->sc_chip = TULIP_CHIP_MX98713A;
    285  1.1  thorpej 		break;
    286  1.1  thorpej 
    287  1.1  thorpej 	case TULIP_CHIP_MX98715:
    288  1.1  thorpej 		if (sc->sc_rev >= 0x30)
    289  1.1  thorpej 			sc->sc_chip = TULIP_CHIP_MX98725;
    290  1.1  thorpej 		break;
    291  1.1  thorpej 
    292  1.1  thorpej 	case TULIP_CHIP_WB89C840F:
    293  1.7  thorpej 		sc->sc_regshift = 2;
    294  1.4  thorpej 		break;
    295  1.4  thorpej 
    296  1.4  thorpej 	case TULIP_CHIP_AX88140:
    297  1.4  thorpej 		if (sc->sc_rev >= 0x10)
    298  1.4  thorpej 			sc->sc_chip = TULIP_CHIP_AX88141;
    299  1.1  thorpej 		break;
    300  1.1  thorpej 
    301  1.1  thorpej 	default:
    302  1.1  thorpej 		/* Nothing. */
    303  1.1  thorpej 	}
    304  1.1  thorpej 
    305  1.1  thorpej 	printf(": %s Ethernet, pass %d.%d\n",
    306  1.1  thorpej 	    tlp_pci_chip_names[sc->sc_chip],
    307  1.1  thorpej 	    (sc->sc_rev >> 4) & 0xf, sc->sc_rev & 0xf);
    308  1.1  thorpej 
    309  1.1  thorpej 	sc->sc_dmat = pa->pa_dmat;
    310  1.1  thorpej 
    311  1.1  thorpej 	/*
    312  1.1  thorpej 	 * Make sure bus mastering is enabled.
    313  1.1  thorpej 	 */
    314  1.1  thorpej 	pci_conf_write(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG,
    315  1.1  thorpej 	    pci_conf_read(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG) |
    316  1.1  thorpej 	    PCI_COMMAND_MASTER_ENABLE);
    317  1.1  thorpej 
    318  1.1  thorpej 	/*
    319  1.1  thorpej 	 * Get the cacheline size.
    320  1.1  thorpej 	 */
    321  1.1  thorpej 	sc->sc_cacheline = PCI_CACHELINE(pci_conf_read(pc, pa->pa_tag,
    322  1.1  thorpej 	    PCI_BHLC_REG));
    323  1.1  thorpej 
    324  1.1  thorpej 	/*
    325  1.1  thorpej 	 * Read the contents of the Ethernet Address ROM/SROM.
    326  1.1  thorpej 	 */
    327  1.5  thorpej 	memset(sc->sc_srom, 0, sizeof(sc->sc_srom));
    328  1.1  thorpej 	switch (sc->sc_chip) {
    329  1.1  thorpej 	case TULIP_CHIP_21040:
    330  1.1  thorpej 		TULIP_WRITE(sc, CSR_MIIROM, MIIROM_SROMCS);
    331  1.5  thorpej 		for (i = 0; i < sizeof(sc->sc_srom); i++) {
    332  1.1  thorpej 			for (j = 0; j < 10000; j++) {
    333  1.1  thorpej 				val = TULIP_READ(sc, CSR_MIIROM);
    334  1.1  thorpej 				if ((val & MIIROM_DN) == 0)
    335  1.1  thorpej 					break;
    336  1.1  thorpej 			}
    337  1.5  thorpej 			sc->sc_srom[i] = val & MIIROM_DATA;
    338  1.1  thorpej 		}
    339  1.1  thorpej 		break;
    340  1.1  thorpej 
    341  1.1  thorpej 	case TULIP_CHIP_82C168:
    342  1.1  thorpej 	case TULIP_CHIP_82C169:
    343  1.5  thorpej 	    {
    344  1.5  thorpej 		u_int16_t *rombuf = (u_int16_t *)sc->sc_srom;
    345  1.5  thorpej 
    346  1.1  thorpej 		/*
    347  1.1  thorpej 		 * The Lite-On PNIC stores the Ethernet address in
    348  1.1  thorpej 		 * the first 3 words of the EEPROM.  EEPROM access
    349  1.1  thorpej 		 * is not like the other Tulip chips.
    350  1.1  thorpej 		 */
    351  1.1  thorpej 		for (i = 0; i < 3; i++) {
    352  1.1  thorpej 			TULIP_WRITE(sc, CSR_PNIC_SROMCTL,
    353  1.1  thorpej 			    PNIC_SROMCTL_READ | i);
    354  1.1  thorpej 			for (j = 0; j < 500; j++) {
    355  1.1  thorpej 				delay(2);
    356  1.1  thorpej 				val = TULIP_READ(sc, CSR_MIIROM);
    357  1.1  thorpej 				if ((val & PNIC_MIIROM_BUSY) == 0)
    358  1.1  thorpej 					break;
    359  1.1  thorpej 			}
    360  1.1  thorpej 			if (val & PNIC_MIIROM_BUSY) {
    361  1.1  thorpej 				printf("%s: EEPROM timed out\n",
    362  1.1  thorpej 				    sc->sc_dev.dv_xname);
    363  1.1  thorpej 				return;
    364  1.1  thorpej 			}
    365  1.2  thorpej 			rombuf[i] = bswap16(val & PNIC_MIIROM_DATA);
    366  1.1  thorpej 		}
    367  1.1  thorpej 		break;
    368  1.5  thorpej 	    }
    369  1.1  thorpej 
    370  1.1  thorpej 	default:
    371  1.5  thorpej 		tlp_read_srom(sc, 0, sizeof(sc->sc_srom) >> 2,
    372  1.5  thorpej 		    (u_int16_t *)sc->sc_srom);
    373  1.1  thorpej 	}
    374  1.1  thorpej 
    375  1.1  thorpej 	/*
    376  1.1  thorpej 	 * Deal with chip/board quirks.  This includes setting up
    377  1.1  thorpej 	 * the mediasw, and extracting the Ethernet address from
    378  1.1  thorpej 	 * the rombuf.
    379  1.1  thorpej 	 *
    380  1.1  thorpej 	 * XXX Eventually, handle master/slave interrupts on the
    381  1.1  thorpej 	 * XXX multi-port boards which require that.
    382  1.1  thorpej 	 */
    383  1.1  thorpej 	switch (sc->sc_chip) {
    384  1.5  thorpej 	case TULIP_CHIP_21040:
    385  1.5  thorpej 		/*
    386  1.5  thorpej 		 * None of the 21040 boards have the new-style SROMs.
    387  1.5  thorpej 		 */
    388  1.5  thorpej 		if (tlp_parse_old_srom(sc, enaddr) == 0) {
    389  1.5  thorpej 			printf("%s: unable to decode old-style SROM\n",
    390  1.5  thorpej 			    sc->sc_dev.dv_xname);
    391  1.5  thorpej 			return;
    392  1.5  thorpej 		}
    393  1.5  thorpej 
    394  1.5  thorpej 		/*
    395  1.5  thorpej 		 * All 21040 boards start out with the same
    396  1.5  thorpej 		 * media switch.
    397  1.5  thorpej 		 */
    398  1.5  thorpej 		sc->sc_mediasw = &tlp_21040_mediasw;
    399  1.5  thorpej 
    400  1.5  thorpej 		/*
    401  1.5  thorpej 		 * XXX Eventually we should attempt to identify
    402  1.5  thorpej 		 * XXX other boards, and set the media appropriately.
    403  1.5  thorpej 		 */
    404  1.5  thorpej 		break;
    405  1.5  thorpej 
    406  1.1  thorpej 	case TULIP_CHIP_82C168:
    407  1.1  thorpej 	case TULIP_CHIP_82C169:
    408  1.1  thorpej 		/*
    409  1.1  thorpej 		 * Lite-On PNIC's Ethernet address is the first 6
    410  1.1  thorpej 		 * bytes of its EEPROM.
    411  1.1  thorpej 		 */
    412  1.5  thorpej 		memcpy(enaddr, sc->sc_srom, ETHER_ADDR_LEN);
    413  1.1  thorpej 
    414  1.1  thorpej 		/*
    415  1.1  thorpej 		 * Lite-On PNICs always use the same mediasw; we
    416  1.1  thorpej 		 * select MII vs. internal NWAY automatically.
    417  1.1  thorpej 		 */
    418  1.1  thorpej 		sc->sc_mediasw = &tlp_pnic_mediasw;
    419  1.1  thorpej 		break;
    420  1.1  thorpej 
    421  1.1  thorpej 	case TULIP_CHIP_WB89C840F:
    422  1.1  thorpej 		/*
    423  1.1  thorpej 		 * Winbond 89C840F's Ethernet address is the first
    424  1.1  thorpej 		 * 6 bytes of its EEPROM.
    425  1.1  thorpej 		 */
    426  1.5  thorpej 		memcpy(enaddr, sc->sc_srom, ETHER_ADDR_LEN);
    427  1.1  thorpej 
    428  1.1  thorpej 		/*
    429  1.1  thorpej 		 * Winbond 89C840F has an MII attached to the SIO.
    430  1.1  thorpej 		 */
    431  1.1  thorpej 		sc->sc_mediasw = &tlp_sio_mii_mediasw;
    432  1.1  thorpej 		break;
    433  1.1  thorpej 
    434  1.1  thorpej 	default:
    435  1.1  thorpej 		printf("%s: sorry, unable to handle your board\n",
    436  1.1  thorpej 		    sc->sc_dev.dv_xname);
    437  1.1  thorpej 		return;
    438  1.1  thorpej 	}
    439  1.1  thorpej 
    440  1.1  thorpej 	/*
    441  1.1  thorpej 	 * Map and establish our interrupt.
    442  1.1  thorpej 	 */
    443  1.1  thorpej 	if (pci_intr_map(pc, pa->pa_intrtag, pa->pa_intrpin,
    444  1.1  thorpej 	    pa->pa_intrline, &ih)) {
    445  1.1  thorpej 		printf("%s: unable to map interrupt\n", sc->sc_dev.dv_xname);
    446  1.1  thorpej 		return;
    447  1.1  thorpej 	}
    448  1.1  thorpej 	intrstr = pci_intr_string(pc, ih);
    449  1.1  thorpej 	psc->sc_ih = pci_intr_establish(pc, ih, IPL_NET, tlp_intr, sc);
    450  1.1  thorpej 	if (psc->sc_ih == NULL) {
    451  1.1  thorpej 		printf("%s: unable to establish interrupt",
    452  1.1  thorpej 		    sc->sc_dev.dv_xname);
    453  1.1  thorpej 		if (intrstr != NULL)
    454  1.1  thorpej 			printf(" at %s", intrstr);
    455  1.1  thorpej 		printf("\n");
    456  1.1  thorpej 		return;
    457  1.1  thorpej 	}
    458  1.1  thorpej 	printf("%s: interrupting at %s\n", sc->sc_dev.dv_xname, intrstr);
    459  1.1  thorpej 
    460  1.1  thorpej 	/*
    461  1.1  thorpej 	 * Finish off the attach.
    462  1.1  thorpej 	 */
    463  1.1  thorpej 	tlp_attach(sc, name, enaddr);
    464  1.1  thorpej }
    465