FreeBSD/Linux Kernel Cross Reference
sys/pci/if_vx_pci.c
1 /*
2 * Copyright (C) 1996 Naoki Hamada <nao@tom-yam.or.jp>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
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.
16 *
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
27 * SUCH DAMAGE.
28 *
29 */
30
31 #include "pci.h"
32 #if NPCI > 0
33
34 #include "vx.h"
35 #if NVX > 0
36
37 #include <sys/param.h>
38 #include <sys/systm.h>
39 #include <sys/kernel.h>
40 #include <sys/socket.h>
41
42 #include <net/if.h>
43
44 #ifdef INET
45 #include <netinet/in.h>
46 #include <netinet/if_ether.h>
47 #endif
48
49 #ifdef NS
50 #include <netns/ns.h>
51 #include <netns/ns_if.h>
52 #endif
53
54 #include <machine/clock.h>
55
56 #include <pci/pcivar.h>
57
58 #include <dev/vx/if_vxreg.h>
59
60 static void vx_pci_shutdown(int, void *);
61 static char *vx_pci_probe(pcici_t, pcidi_t);
62 static void vx_pci_attach(pcici_t, int unit);
63
64 static void
65 vx_pci_shutdown(
66 int howto,
67 void *sc)
68 {
69 vxstop(sc);
70 vxfree(sc);
71 }
72
73 static char*
74 vx_pci_probe(
75 pcici_t config_id,
76 pcidi_t device_id)
77 {
78 if(device_id == 0x590010b7ul)
79 return "3COM 3C590 Etherlink III PCI";
80 if(device_id == 0x595010b7ul || device_id == 0x595110b7ul ||
81 device_id == 0x595210b7ul)
82 return "3COM 3C595 Fast Etherlink III PCI";
83 /*
84 * The (Fast) Etherlink XL adapters are now supported by
85 * the xl driver, which uses bus master DMA and is much
86 * faster. (And which also supports the 3c905B.)
87 */
88 #ifdef VORTEX_ETHERLINK_XL
89 if(device_id == 0x900010b7ul || device_id == 0x900110b7ul)
90 return "3COM 3C900 Etherlink XL PCI";
91 if(device_id == 0x905010b7ul || device_id == 0x905110b7ul)
92 return "3COM 3C905 Fast Etherlink XL PCI";
93 #endif
94 return NULL;
95 }
96
97 static void
98 vx_pci_attach(
99 pcici_t config_id,
100 int unit)
101 {
102 struct vx_softc *sc;
103
104 if (unit >= NVX) {
105 printf("vx%d: not configured; kernel is built for only %d device%s.\n",
106 unit, NVX, NVX == 1 ? "" : "s");
107 return;
108 }
109
110 sc = vxalloc(unit);
111
112 sc->vx_io_addr = pci_conf_read(config_id, 0x10) & 0xffffffe0;
113
114 if (vxattach(sc) == 0) {
115 return;
116 }
117
118 /* defect check for 3C590 */
119 if ((pci_conf_read(config_id, 0) >> 16) == 0x5900) {
120 GO_WINDOW(0);
121 if (vxbusyeeprom(sc))
122 return;
123 outw(BASE + VX_W0_EEPROM_COMMAND, EEPROM_CMD_RD | EEPROM_SOFT_INFO_2);
124 if (vxbusyeeprom(sc))
125 return;
126 if (!(inw(BASE + VX_W0_EEPROM_DATA) & NO_RX_OVN_ANOMALY)) {
127 printf("Warning! Defective early revision adapter!\n");
128 }
129 }
130
131 /*
132 * Add shutdown hook so that DMA is disabled prior to reboot. Not
133 * doing do could allow DMA to corrupt kernel memory during the
134 * reboot before the driver initializes.
135 */
136 at_shutdown(vx_pci_shutdown, sc, SHUTDOWN_POST_SYNC);
137
138 pci_map_int(config_id, (void *) vxintr, (void *) sc, &net_imask);
139 }
140
141 static struct pci_device vxdevice = {
142 "vx",
143 vx_pci_probe,
144 vx_pci_attach,
145 &vx_count,
146 NULL
147 };
148
149 DATA_SET (pcidevice_set, vxdevice);
150
151 #endif /* NVX */
152 #endif /* NPCI */
Cache object: 96a31edeb1bc84c1e005cf84d651d06a
|