1 /* $OpenBSD: if_ti_pci.c,v 1.3 2014/07/22 13:12:11 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_dl.h> 81 #include <net/if_media.h> 82 83 #ifdef INET 84 #include <netinet/in.h> 85 #include <netinet/if_ether.h> 86 #endif 87 88 #include <dev/pci/pcireg.h> 89 #include <dev/pci/pcivar.h> 90 #include <dev/pci/pcidevs.h> 91 92 #include <dev/ic/tireg.h> 93 #include <dev/ic/tivar.h> 94 95 int ti_pci_match(struct device *, void *, void *); 96 void ti_pci_attach(struct device *, struct device *, void *); 97 98 struct cfattach ti_pci_ca = { 99 sizeof(struct ti_softc), ti_pci_match, ti_pci_attach 100 }; 101 102 const struct pci_matchid ti_devices[] = { 103 { PCI_VENDOR_NETGEAR, PCI_PRODUCT_NETGEAR_GA620 }, 104 { PCI_VENDOR_NETGEAR, PCI_PRODUCT_NETGEAR_GA620T }, 105 { PCI_VENDOR_ALTEON, PCI_PRODUCT_ALTEON_ACENIC }, 106 { PCI_VENDOR_ALTEON, PCI_PRODUCT_ALTEON_ACENICT }, 107 { PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C985 }, 108 { PCI_VENDOR_SGI, PCI_PRODUCT_SGI_TIGON }, 109 { PCI_VENDOR_DEC, PCI_PRODUCT_DEC_PN9000SX } 110 }; 111 112 int 113 ti_pci_match(struct device *parent, void *match, void *aux) 114 { 115 return (pci_matchbyid(aux, ti_devices, nitems(ti_devices))); 116 } 117 118 void 119 ti_pci_attach(struct device *parent, struct device *self, void *aux) 120 { 121 struct ti_softc *sc = (struct ti_softc *)self; 122 struct pci_attach_args *pa = aux; 123 pci_chipset_tag_t pc = pa->pa_pc; 124 pci_intr_handle_t ih; 125 const char *intrstr = NULL; 126 bus_size_t size; 127 128 /* 129 * Map control/status registers. 130 */ 131 if (pci_mapreg_map(pa, TI_PCI_LOMEM, 132 PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT, 0, 133 &sc->ti_btag, &sc->ti_bhandle, NULL, &size, 0)) { 134 printf(": can't map registers\n"); 135 return; 136 } 137 138 sc->sc_dmatag = pa->pa_dmat; 139 140 if (pci_intr_map(pa, &ih)) { 141 printf(": can't map interrupt\n"); 142 goto unmap; 143 } 144 intrstr = pci_intr_string(pc, ih); 145 sc->ti_intrhand = pci_intr_establish(pc, ih, IPL_NET, ti_intr, sc, 146 self->dv_xname); 147 if (sc->ti_intrhand == NULL) { 148 printf(": can't establish interrupt"); 149 if (intrstr != NULL) 150 printf(" at %s", intrstr); 151 printf("\n"); 152 goto unmap; 153 } 154 printf(": %s", intrstr); 155 156 /* 157 * We really need a better way to tell a 1000baseTX card 158 * from a 1000baseSX one, since in theory there could be 159 * OEMed 1000baseTX cards from lame vendors who aren't 160 * clever enough to change the PCI ID. For the moment 161 * though, the AceNIC is the only copper card available. 162 */ 163 if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_ALTEON && 164 PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_ALTEON_ACENICT) 165 sc->ti_copper = 1; 166 /* Ok, it's not the only copper card available */ 167 if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_NETGEAR && 168 PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_NETGEAR_GA620T) 169 sc->ti_copper = 1; 170 171 if (ti_attach(sc) == 0) 172 return; 173 174 pci_intr_disestablish(pc, sc->ti_intrhand); 175 176 unmap: 177 bus_space_unmap(sc->ti_btag, sc->ti_bhandle, size); 178 } 179