if_vx_pci.c revision 32350
1251877Speter/* 2251877Speter * Copyright (C) 1996 Naoki Hamada <nao@tom-yam.or.jp> 3251877Speter * All rights reserved. 4251877Speter * 5251877Speter * Redistribution and use in source and binary forms, with or without 6251877Speter * modification, are permitted provided that the following conditions 7251877Speter * are met: 8251877Speter * 1. Redistributions of source code must retain the above copyright 9251877Speter * notice, this list of conditions and the following disclaimer. 10251877Speter * 2. Redistributions in binary form must reproduce the above copyright 11251877Speter * notice, this list of conditions and the following disclaimer in the 12251877Speter * documentation and/or other materials provided with the distribution. 13251877Speter * 3. Neither the name of the author nor the names of any co-contributors 14251877Speter * may be used to endorse or promote products derived from this software 15251877Speter * without specific prior written permission. 16251877Speter * 17251877Speter * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18251877Speter * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19251877Speter * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20253895Speter * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21251877Speter * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22251877Speter * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23251877Speter * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24251877Speter * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25251877Speter * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26251877Speter * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27251877Speter * SUCH DAMAGE. 28251877Speter * 29251877Speter */ 30251877Speter 31251877Speter#include "pci.h" 32251877Speter#if NPCI > 0 33251877Speter 34251877Speter#include "vx.h" 35251877Speter#if NVX > 0 36251877Speter#include "opt_inet.h" 37251877Speter 38251877Speter#include <sys/param.h> 39251877Speter#include <sys/systm.h> 40251877Speter#include <sys/kernel.h> 41251877Speter#include <sys/socket.h> 42251877Speter 43251877Speter#include <net/ethernet.h> 44251877Speter#include <net/if.h> 45251877Speter#include <net/if_arp.h> 46251877Speter 47251877Speter#ifdef INET 48251877Speter#include <netinet/in.h> 49251877Speter#include <netinet/if_ether.h> 50251877Speter#endif 51251877Speter 52251877Speter 53251877Speter#ifdef NS 54251877Speter#include <netns/ns.h> 55251877Speter#include <netns/ns_if.h> 56251877Speter#endif 57251877Speter 58251877Speter#include <pci/pcivar.h> 59251877Speter 60251877Speter#include <dev/vx/if_vxreg.h> 61251877Speter 62251877Speterstatic void vx_pci_shutdown(int, void *); 63251877Speterstatic char *vx_pci_probe(pcici_t, pcidi_t); 64251877Speterstatic void vx_pci_attach(pcici_t, int unit); 65251877Speter 66251877Speterstatic void 67251877Spetervx_pci_shutdown( 68251877Speter int howto, 69251877Speter void *sc) 70251877Speter{ 71251877Speter vxstop(sc); 72251877Speter vxfree(sc); 73251877Speter} 74251877Speter 75251877Speterstatic char* 76251877Spetervx_pci_probe( 77251877Speter pcici_t config_id, 78251877Speter pcidi_t device_id) 79251877Speter{ 80251877Speter if(device_id == 0x590010b7ul) 81251877Speter return "3COM 3C590 Etherlink III PCI"; 82251877Speter if(device_id == 0x595010b7ul || device_id == 0x595110b7ul || 83251877Speter device_id == 0x595210b7ul) 84251877Speter return "3COM 3C595 Fast Etherlink III PCI"; 85251877Speter if(device_id == 0x900010b7ul || device_id == 0x900110b7ul) 86251877Speter return "3COM 3C900 Etherlink XL PCI"; 87251877Speter if(device_id == 0x905010b7ul || device_id == 0x905110b7ul) 88251877Speter return "3COM 3C905 Fast Etherlink XL PCI"; 89251877Speter return NULL; 90251877Speter} 91251877Speter 92251877Speterstatic void 93251877Spetervx_pci_attach( 94251877Speter pcici_t config_id, 95251877Speter int unit) 96251877Speter{ 97251877Speter struct vx_softc *sc; 98251877Speter 99251877Speter if (unit >= NVX) { 100251877Speter printf("vx%d: not configured; kernel is built for only %d device%s.\n", 101251877Speter unit, NVX, NVX == 1 ? "" : "s"); 102251877Speter return; 103251877Speter } 104251877Speter 105251877Speter sc = vxalloc(unit); 106251877Speter 107251877Speter sc->vx_io_addr = pci_conf_read(config_id, 0x10) & 0xffffffe0; 108251877Speter 109251877Speter if (vxattach(sc) == 0) { 110251877Speter return; 111251877Speter } 112251877Speter 113251877Speter /* defect check for 3C590 */ 114251877Speter if ((pci_conf_read(config_id, 0) >> 16) == 0x5900) { 115251877Speter GO_WINDOW(0); 116251877Speter if (vxbusyeeprom(sc)) 117251877Speter return; 118251877Speter outw(BASE + VX_W0_EEPROM_COMMAND, EEPROM_CMD_RD | EEPROM_SOFT_INFO_2); 119251877Speter if (vxbusyeeprom(sc)) 120251877Speter return; 121251877Speter if (!(inw(BASE + VX_W0_EEPROM_DATA) & NO_RX_OVN_ANOMALY)) { 122251877Speter printf("Warning! Defective early revision adapter!\n"); 123251877Speter } 124251877Speter } 125251877Speter 126251877Speter /* 127251877Speter * Add shutdown hook so that DMA is disabled prior to reboot. Not 128251877Speter * doing do could allow DMA to corrupt kernel memory during the 129251877Speter * reboot before the driver initializes. 130251877Speter */ 131251877Speter at_shutdown(vx_pci_shutdown, sc, SHUTDOWN_POST_SYNC); 132251877Speter 133251877Speter pci_map_int(config_id, vxintr, (void *) sc, &net_imask); 134251877Speter} 135251877Speter 136251877Speterstatic struct pci_device vxdevice = { 137251877Speter "vx", 138251877Speter vx_pci_probe, 139251877Speter vx_pci_attach, 140251877Speter &vx_count, 141251877Speter NULL 142251877Speter}; 143251877Speter 144251877SpeterDATA_SET (pcidevice_set, vxdevice); 145251877Speter 146251877Speter#endif /* NVX */ 147251877Speter#endif /* NPCI */ 148251877Speter