This source file includes following definitions.
- adp_busreset
- en_pci_match
- en_pci_attach
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
38
39
40
41
42
43
44
45 #include <sys/param.h>
46 #include <sys/systm.h>
47 #include <sys/device.h>
48 #include <sys/mbuf.h>
49 #include <sys/socket.h>
50 #include <sys/socketvar.h>
51
52 #include <net/if.h>
53
54 #include <dev/pci/pcivar.h>
55 #include <dev/pci/pcireg.h>
56 #include <dev/pci/pcidevs.h>
57
58 #include <dev/ic/midwayreg.h>
59 #include <dev/ic/midwayvar.h>
60
61
62
63
64
65
66 struct en_pci_softc {
67
68 struct en_softc esc;
69
70
71 void *sc_ih;
72 pci_chipset_tag_t en_pc;
73
74 };
75
76
77
78
79
80
81
82
83
84
85 #define PCI_CBMA 0x10
86
87
88
89
90
91 #define EN_TONGA 0x60
92
93 #define TONGA_SWAP_DMA 0x80
94 #define TONGA_SWAP_BYTE 0x40
95 #define TONGA_SWAP_WORD 0x20
96
97
98
99
100
101 #define ADP_PCIREG 0x050040
102
103 #define ADP_PCIREG_RESET 0x1
104 #define ADP_PCIREG_IENABLE 0x2
105 #define ADP_PCIREG_SWAP_WORD 0x4
106 #define ADP_PCIREG_SWAP_DMA 0x8
107
108
109
110
111
112 static int en_pci_match(struct device *, void *, void *);
113 static void en_pci_attach(struct device *, struct device *, void *);
114
115
116
117
118
119 struct cfattach en_pci_ca = {
120 sizeof(struct en_pci_softc), en_pci_match, en_pci_attach,
121 };
122
123 #if !defined(MIDWAY_ENIONLY)
124
125 static void adp_busreset(void *);
126
127
128
129
130
131 static void adp_busreset(v)
132
133 void *v;
134
135 {
136 struct en_softc *sc = (struct en_softc *) v;
137 u_int32_t dummy;
138
139 bus_space_write_4(sc->en_memt, sc->en_base, ADP_PCIREG, ADP_PCIREG_RESET);
140 DELAY(1000);
141 dummy = bus_space_read_4(sc->en_memt, sc->en_base, ADP_PCIREG);
142 bus_space_write_4(sc->en_memt, sc->en_base, ADP_PCIREG,
143 (ADP_PCIREG_SWAP_WORD|ADP_PCIREG_SWAP_DMA|ADP_PCIREG_IENABLE));
144 dummy = bus_space_read_4(sc->en_memt, sc->en_base, ADP_PCIREG);
145 if ((dummy & (ADP_PCIREG_SWAP_WORD|ADP_PCIREG_SWAP_DMA)) !=
146 (ADP_PCIREG_SWAP_WORD|ADP_PCIREG_SWAP_DMA))
147 printf("adp_busreset: Adaptec ATM did NOT reset!\n");
148
149 }
150 #endif
151
152
153
154
155
156
157
158 static int en_pci_match(parent, match, aux)
159
160 struct device *parent;
161 void *match;
162 void *aux;
163
164 {
165 struct pci_attach_args *pa = (struct pci_attach_args *) aux;
166
167 #if !defined(MIDWAY_ADPONLY)
168 if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_EFFICIENTNETS &&
169 (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_EFFICIENTNETS_ENI155PF ||
170 PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_EFFICIENTNETS_ENI155PA))
171 return 1;
172 #endif
173
174 #if !defined(MIDWAY_ENIONLY)
175 if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_ADP &&
176 (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_ADP_AIC5900 ||
177 PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_ADP_AIC5905))
178 return 1;
179 #endif
180
181 return 0;
182 }
183
184
185 static void en_pci_attach(parent, self, aux)
186
187 struct device *parent, *self;
188 void *aux;
189
190 {
191 struct en_softc *sc = (void *)self;
192 struct en_pci_softc *scp = (void *)self;
193 struct pci_attach_args *pa = aux;
194 pci_intr_handle_t ih;
195 const char *intrstr;
196 int retval;
197
198 sc->is_adaptec = (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_ADP) ? 1 : 0;
199 scp->en_pc = pa->pa_pc;
200
201
202
203
204
205 if (pci_intr_map(pa, &ih)) {
206 printf(": couldn't map interrupt\n");
207 return;
208 }
209 intrstr = pci_intr_string(scp->en_pc, ih);
210 scp->sc_ih = pci_intr_establish(scp->en_pc, ih, IPL_NET, en_intr, sc,
211 sc->sc_dev.dv_xname);
212 if (scp->sc_ih == NULL) {
213 printf(": couldn't establish interrupt");
214 if (intrstr != NULL)
215 printf(" at %s", intrstr);
216 printf("\n");
217 return;
218 }
219 sc->ipl = 1;
220
221
222
223
224
225 retval = pci_mapreg_map(pa, PCI_CBMA, PCI_MAPREG_TYPE_MEM, 0,
226 &sc->en_memt, &sc->en_base, NULL, &sc->en_obmemsz, 0);
227
228 if (retval) {
229 printf(": couldn't map memory\n");
230 return;
231 }
232
233 printf(": %s\n", intrstr);
234
235
236
237
238
239 #if !defined(MIDWAY_ENIONLY)
240 if (sc->is_adaptec) {
241 sc->en_busreset = adp_busreset;
242 adp_busreset(sc);
243 }
244 #endif
245
246 #if !defined(MIDWAY_ADPONLY)
247 if (!sc->is_adaptec) {
248 sc->en_busreset = NULL;
249 pci_conf_write(scp->en_pc, pa->pa_tag, EN_TONGA,
250 (TONGA_SWAP_DMA|TONGA_SWAP_WORD));
251 }
252 #endif
253
254
255
256
257
258 en_attach(sc);
259
260 }