2 * Copyright (C) 1996 Naoki Hamada <nao@tom-yam.or.jp>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the author nor the names of any co-contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * $FreeBSD: src/sys/dev/vx/if_vx_pci.c,v 1.21 2000/05/28 15:59:52 peter Exp $
30 * $DragonFly: src/sys/dev/netif/vx/if_vx_pci.c,v 1.5 2003/12/07 19:23:40 dillon Exp $
33 #include <sys/param.h>
34 #include <sys/systm.h>
35 #include <sys/kernel.h>
36 #include <sys/socket.h>
39 #include <net/if_arp.h>
41 #include <machine/bus_pio.h>
42 #include <machine/bus.h>
43 #include <machine/resource.h>
47 #include <bus/pci/pcivar.h>
48 #include <bus/pci/pcireg.h>
52 static void vx_pci_shutdown(device_t);
53 static int vx_pci_probe(device_t);
54 static int vx_pci_attach(device_t);
56 static device_method_t vx_methods[] = {
57 /* Device interface */
58 DEVMETHOD(device_probe, vx_pci_probe),
59 DEVMETHOD(device_attach, vx_pci_attach),
60 DEVMETHOD(device_shutdown, vx_pci_shutdown),
65 static driver_t vx_driver = {
68 sizeof(struct vx_softc)
71 static devclass_t vx_devclass;
73 DRIVER_MODULE(if_vx, pci, vx_driver, vx_devclass, 0, 0);
81 sc = device_get_softc(dev);
92 device_id = pci_read_config(dev, PCIR_DEVVENDOR, 4);
94 if(device_id == 0x590010b7ul) {
95 device_set_desc(dev, "3COM 3C590 Etherlink III PCI");
98 if(device_id == 0x595010b7ul || device_id == 0x595110b7ul ||
99 device_id == 0x595210b7ul) {
100 device_set_desc(dev, "3COM 3C595 Etherlink III PCI");
104 * The (Fast) Etherlink XL adapters are now supported by
105 * the xl driver, which uses bus master DMA and is much
106 * faster. (And which also supports the 3c905B.
108 #ifdef VORTEX_ETHERLINK_XL
109 if(device_id == 0x900010b7ul || device_id == 0x900110b7ul) {
110 device_set_desc(dev, "3COM 3C900 Etherlink XL PCI");
113 if(device_id == 0x905010b7ul || device_id == 0x905110b7ul) {
114 device_set_desc(dev, "3COM 3C905 Etherlink XL PCI");
128 sc = device_get_softc(dev);
131 sc->vx_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
132 0, ~0, 1, RF_ACTIVE);
134 if (sc->vx_res == NULL)
137 sc->vx_btag = rman_get_bustag(sc->vx_res);
138 sc->vx_bhandle = rman_get_bushandle(sc->vx_res);
141 sc->vx_irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1,
142 RF_SHAREABLE | RF_ACTIVE);
144 if (sc->vx_irq == NULL)
147 if (bus_setup_intr(dev, sc->vx_irq, INTR_TYPE_NET,
148 vxintr, sc, &sc->vx_intrhand))
151 if (vxattach(sc) == 0) {
155 /* defect check for 3C590 */
156 if ((pci_read_config(dev, PCIR_DEVVENDOR, 4) >> 16) == 0x5900) {
158 if (vxbusyeeprom(sc))
160 CSR_WRITE_2(sc, VX_W0_EEPROM_COMMAND,
161 EEPROM_CMD_RD | EEPROM_SOFT_INFO_2);
162 if (vxbusyeeprom(sc))
164 if (!(CSR_READ_2(sc, VX_W0_EEPROM_DATA) & NO_RX_OVN_ANOMALY)) {
165 printf("Warning! Defective early revision adapter!\n");
172 if (sc->vx_intrhand != NULL)
173 bus_teardown_intr(dev, sc->vx_irq, sc->vx_intrhand);
174 if (sc->vx_res != NULL)
175 bus_release_resource(dev, SYS_RES_IOPORT, 0, sc->vx_res);
176 if (sc->vx_irq != NULL)
177 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->vx_irq);