1 /* $OpenBSD: if_ti_pci.c,v 1.5 2015/11/24 17:11:39 mpi Exp $ */ 2 3 /* 4 * Copyright (c) 1997, 1998, 1999 5 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. All advertising materials mentioning features or use of this software 16 * must display the following acknowledgement: 17 * This product includes software developed by Bill Paul. 18 * 4. Neither the name of the author nor the names of any co-contributors 19 * may be used to endorse or promote products derived from this software 20 * without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND 23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD 26 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 32 * THE POSSIBILITY OF SUCH DAMAGE. 33 * 34 * $FreeBSD: src/sys/pci/if_ti.c,v 1.25 2000/01/18 00:26:29 wpaul Exp $ 35 */ 36 37 /* 38 * Alteon Networks Tigon PCI gigabit ethernet driver for OpenBSD. 39 * 40 * Written by Bill Paul <wpaul@ctr.columbia.edu> 41 * Electrical Engineering Department 42 * Columbia University, New York City 43 */ 44 45 /* 46 * The Alteon Networks Tigon chip contains an embedded R4000 CPU, 47 * gigabit MAC, dual DMA channels and a PCI interface unit. NICs 48 * using the Tigon may have anywhere from 512K to 2MB of SRAM. The 49 * Tigon supports hardware IP, TCP and UCP checksumming, multicast 50 * filtering and jumbo (9014 byte) frames. The hardware is largely 51 * controlled by firmware, which must be loaded into the NIC during 52 * initialization. 53 * 54 * The Tigon 2 contains 2 R4000 CPUs and requires a newer firmware 55 * revision, which supports new features such as extended commands, 56 * extended jumbo receive ring desciptors and a mini receive ring. 57 * 58 * Alteon Networks is to be commended for releasing such a vast amount 59 * of development material for the Tigon NIC without requiring an NDA 60 * (although they really should have done it a long time ago). With 61 * any luck, the other vendors will finally wise up and follow Alteon's 62 * stellar example. 63 * 64 * The following people deserve special thanks: 65 * - Terry Murphy of 3Com, for providing a 3c985 Tigon 1 board 66 * for testing 67 * - Raymond Lee of Netgear, for providing a pair of Netgear 68 * GA620 Tigon 2 boards for testing 69 * - Ulf Zimmermann, for bringing the GA260 to my attention and 70 * convincing me to write this driver. 71 * - Andrew Gallatin for providing FreeBSD/Alpha support. 72 */ 73 74 #include <sys/param.h> 75 #include <sys/device.h> 76 #include <sys/socket.h> 77 #include <sys/systm.h> 78 79 #include <net/if.h> 80 #include <net/if_media.h> 81 82 #include <netinet/in.h> 83 #include <netinet/if_ether.h> 84 85 #include <dev/pci/pcireg.h> 86 #include <dev/pci/pcivar.h> 87 #include <dev/pci/pcidevs.h> 88 89 #include <dev/ic/tireg.h> 90 #include <dev/ic/tivar.h> 91 92 int ti_pci_match(struct device *, void *, void *); 93 void ti_pci_attach(struct device *, struct device *, void *); 94 95 struct cfattach ti_pci_ca = { 96 sizeof(struct ti_softc), ti_pci_match, ti_pci_attach 97 }; 98 99 const struct pci_matchid ti_devices[] = { 100 { PCI_VENDOR_NETGEAR, PCI_PRODUCT_NETGEAR_GA620 }, 101 { PCI_VENDOR_NETGEAR, PCI_PRODUCT_NETGEAR_GA620T }, 102 { PCI_VENDOR_ALTEON, PCI_PRODUCT_ALTEON_ACENIC }, 103 { PCI_VENDOR_ALTEON, PCI_PRODUCT_ALTEON_ACENICT }, 104 { PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C985 }, 105 { PCI_VENDOR_SGI, PCI_PRODUCT_SGI_TIGON }, 106 { PCI_VENDOR_DEC, PCI_PRODUCT_DEC_PN9000SX } 107 }; 108 109 int 110 ti_pci_match(struct device *parent, void *match, void *aux) 111 { 112 return (pci_matchbyid(aux, ti_devices, nitems(ti_devices))); 113 } 114 115 void 116 ti_pci_attach(struct device *parent, struct device *self, void *aux) 117 { 118 struct ti_softc *sc = (struct ti_softc *)self; 119 struct pci_attach_args *pa = aux; 120 pci_chipset_tag_t pc = pa->pa_pc; 121 pci_intr_handle_t ih; 122 const char *intrstr = NULL; 123 bus_size_t size; 124 125 /* 126 * Map control/status registers. 127 */ 128 if (pci_mapreg_map(pa, TI_PCI_LOMEM, 129 PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT, 0, 130 &sc->ti_btag, &sc->ti_bhandle, NULL, &size, 0)) { 131 printf(": can't map registers\n"); 132 return; 133 } 134 135 sc->sc_dmatag = pa->pa_dmat; 136 137 if (pci_intr_map(pa, &ih)) { 138 printf(": can't map interrupt\n"); 139 goto unmap; 140 } 141 intrstr = pci_intr_string(pc, ih); 142 sc->ti_intrhand = pci_intr_establish(pc, ih, IPL_NET, ti_intr, sc, 143 self->dv_xname); 144 if (sc->ti_intrhand == NULL) { 145 printf(": can't establish interrupt"); 146 if (intrstr != NULL) 147 printf(" at %s", intrstr); 148 printf("\n"); 149 goto unmap; 150 } 151 printf(": %s", intrstr); 152 153 /* 154 * We really need a better way to tell a 1000baseTX card 155 * from a 1000baseSX one, since in theory there could be 156 * OEMed 1000baseTX cards from lame vendors who aren't 157 * clever enough to change the PCI ID. For the moment 158 * though, the AceNIC is the only copper card available. 159 */ 160 if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_ALTEON && 161 PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_ALTEON_ACENICT) 162 sc->ti_copper = 1; 163 /* Ok, it's not the only copper card available */ 164 if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_NETGEAR && 165 PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_NETGEAR_GA620T) 166 sc->ti_copper = 1; 167 168 if (ti_attach(sc) == 0) 169 return; 170 171 pci_intr_disestablish(pc, sc->ti_intrhand); 172 173 unmap: 174 bus_space_unmap(sc->ti_btag, sc->ti_bhandle, size); 175 } 176