This source file includes following definitions.
- xl_pci_match
- xl_pci_attach
- xl_pci_intr_ack
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37 #include "bpfilter.h"
38
39 #include <sys/param.h>
40 #include <sys/systm.h>
41 #include <sys/mbuf.h>
42 #include <sys/protosw.h>
43 #include <sys/socket.h>
44 #include <sys/ioctl.h>
45 #include <sys/errno.h>
46 #include <sys/malloc.h>
47 #include <sys/kernel.h>
48 #include <sys/proc.h>
49 #include <sys/device.h>
50
51 #include <net/if.h>
52 #include <net/if_dl.h>
53 #include <net/if_types.h>
54 #include <net/if_media.h>
55
56 #ifdef INET
57 #include <netinet/in.h>
58 #include <netinet/in_systm.h>
59 #include <netinet/in_var.h>
60 #include <netinet/ip.h>
61 #include <netinet/if_ether.h>
62 #endif
63
64 #include <dev/mii/mii.h>
65 #include <dev/mii/miivar.h>
66 #include <dev/pci/pcireg.h>
67 #include <dev/pci/pcivar.h>
68 #include <dev/pci/pcidevs.h>
69
70 #if NBPFILTER > 0
71 #include <net/bpf.h>
72 #endif
73
74
75
76
77
78
79
80
81
82
83
84 #define XL_USEIOSPACE
85
86 #define XL_PCI_FUNCMEM 0x0018
87 #define XL_PCI_INTR 0x0004
88 #define XL_PCI_INTRACK 0x8000
89
90 #include <dev/ic/xlreg.h>
91
92 int xl_pci_match(struct device *, void *, void *);
93 void xl_pci_attach(struct device *, struct device *, void *);
94 void xl_pci_intr_ack(struct xl_softc *);
95
96 struct cfattach xl_pci_ca = {
97 sizeof(struct xl_softc), xl_pci_match, xl_pci_attach,
98 };
99
100 const struct pci_matchid xl_pci_devices[] = {
101 { PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3CSOHO100TX },
102 { PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C900TPO },
103 { PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C900COMBO },
104 { PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C900B },
105 { PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C900BCOMBO },
106 { PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C900BTPC },
107 { PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C900BFL },
108 { PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C905TX },
109 { PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C905T4 },
110 { PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C905BTX },
111 { PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C905BT4 },
112 { PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C905BCOMBO },
113 { PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C905BFX },
114 { PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C980TX },
115 { PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C980CTX },
116 { PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C905CTX },
117 { PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C450 },
118 { PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C555 },
119 { PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C556 },
120 { PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C556B },
121 { PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C9201 },
122 { PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C920BEMBW },
123 };
124
125 int
126 xl_pci_match(struct device *parent, void *match, void *aux)
127 {
128 return (pci_matchbyid((struct pci_attach_args *)aux, xl_pci_devices,
129 sizeof(xl_pci_devices)/sizeof(xl_pci_devices[0])));
130 }
131
132 void
133 xl_pci_attach(struct device *parent, struct device *self, void *aux)
134 {
135 struct xl_softc *sc = (struct xl_softc *)self;
136 struct pci_attach_args *pa = aux;
137 pci_chipset_tag_t pc = pa->pa_pc;
138 pci_intr_handle_t ih;
139 const char *intrstr = NULL;
140 bus_size_t iosize, funsize;
141 u_int32_t command;
142
143 sc->sc_dmat = pa->pa_dmat;
144
145 sc->xl_flags = 0;
146
147
148 switch (PCI_PRODUCT(pa->pa_id)) {
149 case TC_DEVICEID_HURRICANE_555:
150 sc->xl_flags |= XL_FLAG_EEPROM_OFFSET_30 | XL_FLAG_8BITROM;
151 break;
152 case TC_DEVICEID_HURRICANE_556:
153 sc->xl_flags |= XL_FLAG_FUNCREG | XL_FLAG_PHYOK |
154 XL_FLAG_EEPROM_OFFSET_30 | XL_FLAG_WEIRDRESET;
155 sc->xl_flags |= XL_FLAG_INVERT_LED_PWR|XL_FLAG_INVERT_MII_PWR;
156 sc->xl_flags |= XL_FLAG_8BITROM;
157 break;
158 case TC_DEVICEID_HURRICANE_556B:
159 sc->xl_flags |= XL_FLAG_FUNCREG | XL_FLAG_PHYOK |
160 XL_FLAG_EEPROM_OFFSET_30 | XL_FLAG_WEIRDRESET;
161 sc->xl_flags |= XL_FLAG_INVERT_LED_PWR|XL_FLAG_INVERT_MII_PWR;
162 break;
163 case PCI_PRODUCT_3COM_3C9201:
164 case PCI_PRODUCT_3COM_3C920BEMBW:
165 sc->xl_flags |= XL_FLAG_PHYOK;
166 break;
167 case TC_DEVICEID_BOOMERANG_10_100BT:
168 sc->xl_flags |= XL_FLAG_NO_MMIO;
169 break;
170 default:
171 break;
172 }
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191 command = pci_conf_read(pc, pa->pa_tag, XL_PCI_CAPID) & 0xff;
192 if (command == 0x01) {
193
194 command = pci_conf_read(pc, pa->pa_tag,
195 XL_PCI_PWRMGMTCTRL);
196 if (command & XL_PSTATE_MASK) {
197 u_int32_t io, mem, irq;
198
199
200 io = pci_conf_read(pc, pa->pa_tag, XL_PCI_LOIO);
201 mem = pci_conf_read(pc, pa->pa_tag, XL_PCI_LOMEM);
202 irq = pci_conf_read(pc, pa->pa_tag, XL_PCI_INTLINE);
203
204
205 printf("%s: chip is in D%d power mode "
206 "-- setting to D0\n",
207 sc->sc_dev.dv_xname, command & XL_PSTATE_MASK);
208 command &= 0xFFFFFFFC;
209 pci_conf_write(pc, pa->pa_tag,
210 XL_PCI_PWRMGMTCTRL, command);
211
212 pci_conf_write(pc, pa->pa_tag, XL_PCI_LOIO, io);
213 pci_conf_write(pc, pa->pa_tag, XL_PCI_LOMEM, mem);
214 pci_conf_write(pc, pa->pa_tag, XL_PCI_INTLINE, irq);
215 }
216 }
217
218
219
220
221 #ifdef XL_USEIOSPACE
222 if (pci_mapreg_map(pa, XL_PCI_LOIO, PCI_MAPREG_TYPE_IO, 0,
223 &sc->xl_btag, &sc->xl_bhandle, NULL, &iosize, 0)) {
224 printf(": can't map i/o space\n");
225 return;
226 }
227 #else
228 if (pci_mapreg_map(pa, XL_PCI_LOMEM, PCI_MAPREG_TYPE_MEM, 0,
229 &sc->xl_btag, &sc->xl_bhandle, NULL, &iosize, 0)) {
230 printf(": can't map i/o space\n");
231 return;
232 }
233 #endif
234
235 if (sc->xl_flags & XL_FLAG_FUNCREG) {
236 if (pci_mapreg_map(pa, XL_PCI_FUNCMEM, PCI_MAPREG_TYPE_MEM, 0,
237 &sc->xl_funct, &sc->xl_funch, NULL, &funsize, 0)) {
238 printf(": can't map i/o space\n");
239 bus_space_unmap(sc->xl_btag, sc->xl_bhandle, iosize);
240 return;
241 }
242 sc->intr_ack = xl_pci_intr_ack;
243 }
244
245
246
247
248 if (pci_intr_map(pa, &ih)) {
249 printf(": couldn't map interrupt\n");
250 bus_space_unmap(sc->xl_btag, sc->xl_bhandle, iosize);
251 if (sc->xl_flags & XL_FLAG_FUNCREG)
252 bus_space_unmap(sc->xl_funct, sc->xl_funch, funsize);
253 return;
254 }
255
256 intrstr = pci_intr_string(pc, ih);
257 sc->xl_intrhand = pci_intr_establish(pc, ih, IPL_NET, xl_intr, sc,
258 self->dv_xname);
259 if (sc->xl_intrhand == NULL) {
260 printf(": couldn't establish interrupt");
261 if (intrstr != NULL)
262 printf(" at %s", intrstr);
263 bus_space_unmap(sc->xl_btag, sc->xl_bhandle, iosize);
264 if (sc->xl_flags & XL_FLAG_FUNCREG)
265 bus_space_unmap(sc->xl_funct, sc->xl_funch, funsize);
266 return;
267 }
268 printf(": %s", intrstr);
269
270 xl_attach(sc);
271 }
272
273
274 void
275 xl_pci_intr_ack(struct xl_softc *sc)
276 {
277 bus_space_write_4(sc->xl_funct, sc->xl_funch, XL_PCI_INTR,
278 XL_PCI_INTRACK);
279 }