if_vx_pci.c revision 33676
1236769Sobrien/* 2236769Sobrien * Copyright (C) 1996 Naoki Hamada <nao@tom-yam.or.jp> 3236769Sobrien * All rights reserved. 4236769Sobrien * 5236769Sobrien * Redistribution and use in source and binary forms, with or without 6236769Sobrien * modification, are permitted provided that the following conditions 7236769Sobrien * are met: 8236769Sobrien * 1. Redistributions of source code must retain the above copyright 9236769Sobrien * notice, this list of conditions and the following disclaimer. 10236769Sobrien * 2. Redistributions in binary form must reproduce the above copyright 11236769Sobrien * notice, this list of conditions and the following disclaimer in the 12236769Sobrien * documentation and/or other materials provided with the distribution. 13236769Sobrien * 3. Neither the name of the author nor the names of any co-contributors 14236769Sobrien * may be used to endorse or promote products derived from this software 15236769Sobrien * without specific prior written permission. 16236769Sobrien * 17236769Sobrien * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18236769Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19236769Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20236769Sobrien * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21236769Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22236769Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23236769Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24236769Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25236769Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26236769Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27236769Sobrien * SUCH DAMAGE. 28236769Sobrien * 29236769Sobrien */ 30236769Sobrien 31236769Sobrien#include "pci.h" 32236769Sobrien#if NPCI > 0 33236769Sobrien 34236769Sobrien#include "vx.h" 35236769Sobrien#if NVX > 0 36236769Sobrien 37236769Sobrien#include <sys/param.h> 38236769Sobrien#include <sys/systm.h> 39236769Sobrien#include <sys/kernel.h> 40236769Sobrien#include <sys/socket.h> 41236769Sobrien 42236769Sobrien#include <net/if.h> 43236769Sobrien#include <net/if_arp.h> 44236769Sobrien 45236769Sobrien#include <pci/pcivar.h> 46236769Sobrien 47236769Sobrien#include <dev/vx/if_vxreg.h> 48236769Sobrien 49236769Sobrienstatic void vx_pci_shutdown(int, void *); 50236769Sobrienstatic char *vx_pci_probe(pcici_t, pcidi_t); 51236769Sobrienstatic void vx_pci_attach(pcici_t, int unit); 52236769Sobrien 53236769Sobrienstatic void 54236769Sobrienvx_pci_shutdown( 55236769Sobrien int howto, 56236769Sobrien void *sc) 57236769Sobrien{ 58236769Sobrien vxstop(sc); 59236769Sobrien vxfree(sc); 60236769Sobrien} 61236769Sobrien 62236769Sobrienstatic char* 63236769Sobrienvx_pci_probe( 64236769Sobrien pcici_t config_id, 65236769Sobrien pcidi_t device_id) 66236769Sobrien{ 67236769Sobrien if(device_id == 0x590010b7ul) 68236769Sobrien return "3COM 3C590 Etherlink III PCI"; 69236769Sobrien if(device_id == 0x595010b7ul || device_id == 0x595110b7ul || 70236769Sobrien device_id == 0x595210b7ul) 71236769Sobrien return "3COM 3C595 Fast Etherlink III PCI"; 72236769Sobrien if(device_id == 0x900010b7ul || device_id == 0x900110b7ul) 73236769Sobrien return "3COM 3C900 Etherlink XL PCI"; 74236769Sobrien if(device_id == 0x905010b7ul || device_id == 0x905110b7ul) 75236769Sobrien return "3COM 3C905 Fast Etherlink XL PCI"; 76236769Sobrien return NULL; 77236769Sobrien} 78236769Sobrien 79236769Sobrienstatic void 80236769Sobrienvx_pci_attach( 81236769Sobrien pcici_t config_id, 82236769Sobrien int unit) 83236769Sobrien{ 84236769Sobrien struct vx_softc *sc; 85236769Sobrien 86236769Sobrien if (unit >= NVX) { 87236769Sobrien printf("vx%d: not configured; kernel is built for only %d device%s.\n", 88 unit, NVX, NVX == 1 ? "" : "s"); 89 return; 90 } 91 92 sc = vxalloc(unit); 93 94 sc->vx_io_addr = pci_conf_read(config_id, 0x10) & 0xffffffe0; 95 96 if (vxattach(sc) == 0) { 97 return; 98 } 99 100 /* defect check for 3C590 */ 101 if ((pci_conf_read(config_id, 0) >> 16) == 0x5900) { 102 GO_WINDOW(0); 103 if (vxbusyeeprom(sc)) 104 return; 105 outw(BASE + VX_W0_EEPROM_COMMAND, EEPROM_CMD_RD | EEPROM_SOFT_INFO_2); 106 if (vxbusyeeprom(sc)) 107 return; 108 if (!(inw(BASE + VX_W0_EEPROM_DATA) & NO_RX_OVN_ANOMALY)) { 109 printf("Warning! Defective early revision adapter!\n"); 110 } 111 } 112 113 /* 114 * Add shutdown hook so that DMA is disabled prior to reboot. Not 115 * doing do could allow DMA to corrupt kernel memory during the 116 * reboot before the driver initializes. 117 */ 118 at_shutdown(vx_pci_shutdown, sc, SHUTDOWN_POST_SYNC); 119 120 pci_map_int(config_id, vxintr, (void *) sc, &net_imask); 121} 122 123static struct pci_device vxdevice = { 124 "vx", 125 vx_pci_probe, 126 vx_pci_attach, 127 &vx_count, 128 NULL 129}; 130 131DATA_SET (pcidevice_set, vxdevice); 132 133#endif /* NVX */ 134#endif /* NPCI */ 135