if_vx_pci.c revision 28508
1224133Sdim/* 2224133Sdim * Copyright (C) 1996 Naoki Hamada <nao@tom-yam.or.jp> 3224133Sdim * All rights reserved. 4224133Sdim * 5224133Sdim * Redistribution and use in source and binary forms, with or without 6224133Sdim * modification, are permitted provided that the following conditions 7224133Sdim * are met: 8224133Sdim * 1. Redistributions of source code must retain the above copyright 9224133Sdim * notice, this list of conditions and the following disclaimer. 10224133Sdim * 2. Redistributions in binary form must reproduce the above copyright 11224133Sdim * notice, this list of conditions and the following disclaimer in the 12224133Sdim * documentation and/or other materials provided with the distribution. 13224133Sdim * 3. Neither the name of the author nor the names of any co-contributors 14224133Sdim * may be used to endorse or promote products derived from this software 15224133Sdim * without specific prior written permission. 16224133Sdim * 17249423Sdim * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18249423Sdim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19249423Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20234353Sdim * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21234353Sdim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22224133Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23226633Sdim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24226633Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25226633Sdim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26226633Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27234353Sdim * SUCH DAMAGE. 28239462Sdim * 29224133Sdim */ 30224133Sdim 31224133Sdim#include "pci.h" 32234353Sdim#if NPCI > 0 33224133Sdim 34224133Sdim#include "vx.h" 35224133Sdim#if NVX > 0 36224133Sdim 37226633Sdim#include <sys/param.h> 38239462Sdim#include <sys/systm.h> 39226633Sdim#include <sys/kernel.h> 40226633Sdim#include <sys/socket.h> 41226633Sdim 42241430Sdim#include <net/if.h> 43234353Sdim 44234353Sdim#ifdef INET 45234353Sdim#include <netinet/in.h> 46234353Sdim#include <netinet/if_ether.h> 47234353Sdim#endif 48224133Sdim 49224133Sdim#ifdef NS 50249423Sdim#include <netns/ns.h> 51249423Sdim#include <netns/ns_if.h> 52249423Sdim#endif 53249423Sdim 54224133Sdim#include <pci/pcivar.h> 55224133Sdim 56224133Sdim#include <dev/vx/if_vxreg.h> 57224133Sdim 58224133Sdimstatic void vx_pci_shutdown(int, void *); 59224133Sdimstatic char *vx_pci_probe(pcici_t, pcidi_t); 60224133Sdimstatic void vx_pci_attach(pcici_t, int unit); 61224133Sdim 62224133Sdimstatic void 63224133Sdimvx_pci_shutdown( 64224133Sdim int howto, 65224133Sdim void *sc) 66224133Sdim{ 67224133Sdim vxstop(sc); 68224133Sdim vxfree(sc); 69} 70 71static char* 72vx_pci_probe( 73 pcici_t config_id, 74 pcidi_t device_id) 75{ 76 if(device_id == 0x590010b7ul) 77 return "3COM 3C590 Etherlink III PCI"; 78 if(device_id == 0x595010b7ul || device_id == 0x595110b7ul || 79 device_id == 0x595210b7ul) 80 return "3COM 3C595 Fast Etherlink III PCI"; 81 if(device_id == 0x900010b7ul || device_id == 0x900110b7ul) 82 return "3COM 3C900 Etherlink XL PCI"; 83 if(device_id == 0x905010b7ul || device_id == 0x905110b7ul) 84 return "3COM 3C905 Fast Etherlink XL PCI"; 85 return NULL; 86} 87 88static void 89vx_pci_attach( 90 pcici_t config_id, 91 int unit) 92{ 93 struct vx_softc *sc; 94 95 if (unit >= NVX) { 96 printf("vx%d: not configured; kernel is built for only %d device%s.\n", 97 unit, NVX, NVX == 1 ? "" : "s"); 98 return; 99 } 100 101 sc = vxalloc(unit); 102 103 sc->vx_io_addr = pci_conf_read(config_id, 0x10) & 0xffffffe0; 104 105 if (vxattach(sc) == 0) { 106 return; 107 } 108 109 /* defect check for 3C590 */ 110 if ((pci_conf_read(config_id, 0) >> 16) == 0x5900) { 111 GO_WINDOW(0); 112 if (vxbusyeeprom(sc)) 113 return; 114 outw(BASE + VX_W0_EEPROM_COMMAND, EEPROM_CMD_RD | EEPROM_SOFT_INFO_2); 115 if (vxbusyeeprom(sc)) 116 return; 117 if (!(inw(BASE + VX_W0_EEPROM_DATA) & NO_RX_OVN_ANOMALY)) { 118 printf("Warning! Defective early revision adapter!\n"); 119 } 120 } 121 122 /* 123 * Add shutdown hook so that DMA is disabled prior to reboot. Not 124 * doing do could allow DMA to corrupt kernel memory during the 125 * reboot before the driver initializes. 126 */ 127 at_shutdown(vx_pci_shutdown, sc, SHUTDOWN_POST_SYNC); 128 129 pci_map_int(config_id, (pci_inthand_t*)vxintr, (void *) sc, &net_imask); 130} 131 132static struct pci_device vxdevice = { 133 "vx", 134 vx_pci_probe, 135 vx_pci_attach, 136 &vx_count, 137 NULL 138}; 139 140DATA_SET (pcidevice_set, vxdevice); 141 142#endif /* NVX */ 143#endif /* NPCI */ 144