ahc_pci.c revision 1.19.2.4 1 1.19.2.4 bouyer /* $NetBSD: ahc_pci.c,v 1.19.2.4 2001/03/27 15:32:07 bouyer Exp $ */
2 1.2 thorpej
3 1.1 mycroft /*
4 1.1 mycroft * Product specific probe and attach routines for:
5 1.19.2.1 bouyer * 3940, 2940, aic7895, aic7890, aic7880,
6 1.19.2.1 bouyer * aic7870, aic7860 and aic7850 SCSI controllers
7 1.1 mycroft *
8 1.19.2.1 bouyer * Copyright (c) 1994, 1995, 1996, 1997, 1998, 1999, 2000 Justin T. Gibbs.
9 1.1 mycroft * All rights reserved.
10 1.1 mycroft *
11 1.1 mycroft * Redistribution and use in source and binary forms, with or without
12 1.1 mycroft * modification, are permitted provided that the following conditions
13 1.1 mycroft * are met:
14 1.1 mycroft * 1. Redistributions of source code must retain the above copyright
15 1.19.2.1 bouyer * notice, this list of conditions, and the following disclaimer,
16 1.19.2.1 bouyer * without modification.
17 1.19.2.1 bouyer * 2. The name of the author may not be used to endorse or promote products
18 1.1 mycroft * derived from this software without specific prior written permission.
19 1.1 mycroft *
20 1.19.2.1 bouyer * Alternatively, this software may be distributed under the terms of the
21 1.19.2.1 bouyer * the GNU Public License ("GPL").
22 1.19.2.1 bouyer *
23 1.1 mycroft * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
24 1.1 mycroft * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 1.1 mycroft * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 1.1 mycroft * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
27 1.1 mycroft * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 1.1 mycroft * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 1.1 mycroft * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 1.1 mycroft * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 1.1 mycroft * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 1.1 mycroft * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 1.1 mycroft * SUCH DAMAGE.
34 1.3 explorer *
35 1.19.2.1 bouyer * $FreeBSD: src/sys/dev/aic7xxx/ahc_pci.c,v 1.28 2000/02/09 21:00:22 gibbs Exp $
36 1.1 mycroft */
37 1.1 mycroft
38 1.1 mycroft #include <sys/param.h>
39 1.1 mycroft #include <sys/systm.h>
40 1.1 mycroft #include <sys/malloc.h>
41 1.1 mycroft #include <sys/kernel.h>
42 1.1 mycroft #include <sys/queue.h>
43 1.1 mycroft #include <sys/device.h>
44 1.19.2.1 bouyer #include <sys/reboot.h>
45 1.19.2.1 bouyer
46 1.1 mycroft #include <machine/bus.h>
47 1.1 mycroft #include <machine/intr.h>
48 1.1 mycroft
49 1.1 mycroft #include <dev/pci/pcireg.h>
50 1.1 mycroft #include <dev/pci/pcivar.h>
51 1.1 mycroft
52 1.19.2.1 bouyer /* XXXX some i386 on-board chips act weird when memory-mapped */
53 1.19.2.1 bouyer #ifndef __i386__
54 1.19.2.1 bouyer #define AHC_ALLOW_MEMIO
55 1.5 thorpej #endif
56 1.5 thorpej
57 1.19.2.1 bouyer #define AHC_PCI_IOADDR PCI_MAPREG_START /* I/O Address */
58 1.19.2.1 bouyer #define AHC_PCI_MEMADDR (PCI_MAPREG_START + 4) /* Mem I/O Address */
59 1.1 mycroft
60 1.19.2.1 bouyer #include <dev/scsipi/scsi_all.h>
61 1.19.2.1 bouyer #include <dev/scsipi/scsipi_all.h>
62 1.19.2.1 bouyer #include <dev/scsipi/scsiconf.h>
63 1.1 mycroft
64 1.19.2.1 bouyer #include <dev/ic/aic7xxxvar.h>
65 1.19.2.1 bouyer #include <dev/ic/smc93cx6var.h>
66 1.1 mycroft
67 1.19.2.1 bouyer #include <dev/microcode/aic7xxx/aic7xxx_reg.h>
68 1.1 mycroft
69 1.19.2.1 bouyer struct ahc_pci_busdata {
70 1.19.2.1 bouyer pci_chipset_tag_t pc;
71 1.19.2.1 bouyer pcitag_t tag;
72 1.19.2.1 bouyer u_int dev;
73 1.19.2.1 bouyer u_int func;
74 1.19.2.1 bouyer };
75 1.1 mycroft
76 1.19.2.1 bouyer static __inline u_int64_t
77 1.19.2.1 bouyer ahc_compose_id(u_int device, u_int vendor, u_int subdevice, u_int subvendor)
78 1.19.2.1 bouyer {
79 1.19.2.1 bouyer u_int64_t id;
80 1.1 mycroft
81 1.19.2.1 bouyer id = subvendor
82 1.19.2.1 bouyer | (subdevice << 16)
83 1.19.2.1 bouyer | ((u_int64_t)vendor << 32)
84 1.19.2.1 bouyer | ((u_int64_t)device << 48);
85 1.1 mycroft
86 1.19.2.1 bouyer return (id);
87 1.19.2.1 bouyer }
88 1.1 mycroft
89 1.19.2.1 bouyer #define ID_ALL_MASK 0xFFFFFFFFFFFFFFFFull
90 1.19.2.1 bouyer #define ID_DEV_VENDOR_MASK 0xFFFFFFFF00000000ull
91 1.19.2.1 bouyer #define ID_AIC7850 0x5078900400000000ull
92 1.19.2.1 bouyer #define ID_AHA_2910_15_20_30C 0x5078900478509004ull
93 1.19.2.1 bouyer #define ID_AIC7855 0x5578900400000000ull
94 1.19.2.1 bouyer #define ID_AIC7859 0x3860900400000000ull
95 1.19.2.1 bouyer #define ID_AHA_2930CU 0x3860900438699004ull
96 1.19.2.1 bouyer #define ID_AIC7860 0x6078900400000000ull
97 1.19.2.1 bouyer #define ID_AIC7860C 0x6078900478609004ull
98 1.19.2.1 bouyer #define ID_AHA_2940AU_0 0x6178900400000000ull
99 1.19.2.1 bouyer #define ID_AHA_2940AU_1 0x6178900478619004ull
100 1.19.2.1 bouyer #define ID_AHA_2940AU_CN 0x2178900478219004ull
101 1.19.2.1 bouyer #define ID_AHA_2930C_VAR 0x6038900438689004ull
102 1.19.2.1 bouyer
103 1.19.2.1 bouyer #define ID_AIC7870 0x7078900400000000ull
104 1.19.2.1 bouyer #define ID_AHA_2940 0x7178900400000000ull
105 1.19.2.1 bouyer #define ID_AHA_3940 0x7278900400000000ull
106 1.19.2.1 bouyer #define ID_AHA_398X 0x7378900400000000ull
107 1.19.2.1 bouyer #define ID_AHA_2944 0x7478900400000000ull
108 1.19.2.1 bouyer #define ID_AHA_3944 0x7578900400000000ull
109 1.19.2.1 bouyer
110 1.19.2.1 bouyer #define ID_AIC7880 0x8078900400000000ull
111 1.19.2.1 bouyer #define ID_AIC7880_B 0x8078900478809004ull
112 1.19.2.1 bouyer #define ID_AHA_2940U 0x8178900400000000ull
113 1.19.2.1 bouyer #define ID_AHA_3940U 0x8278900400000000ull
114 1.19.2.1 bouyer #define ID_AHA_2944U 0x8478900400000000ull
115 1.19.2.1 bouyer #define ID_AHA_3944U 0x8578900400000000ull
116 1.19.2.1 bouyer #define ID_AHA_398XU 0x8378900400000000ull
117 1.19.2.1 bouyer #define ID_AHA_4944U 0x8678900400000000ull
118 1.19.2.1 bouyer #define ID_AHA_2940UB 0x8178900478819004ull
119 1.19.2.1 bouyer #define ID_AHA_2930U 0x8878900478889004ull
120 1.19.2.1 bouyer #define ID_AHA_2940U_PRO 0x8778900478879004ull
121 1.19.2.1 bouyer #define ID_AHA_2940U_CN 0x0078900478009004ull
122 1.19.2.1 bouyer
123 1.19.2.1 bouyer #define ID_AIC7895 0x7895900478959004ull
124 1.19.2.1 bouyer #define ID_AIC7895_RAID_PORT 0x7893900478939004ull
125 1.19.2.1 bouyer #define ID_AHA_2940U_DUAL 0x7895900478919004ull
126 1.19.2.1 bouyer #define ID_AHA_3940AU 0x7895900478929004ull
127 1.19.2.1 bouyer #define ID_AHA_3944AU 0x7895900478949004ull
128 1.19.2.1 bouyer
129 1.19.2.1 bouyer #define ID_AIC7890 0x001F9005000F9005ull
130 1.19.2.1 bouyer #define ID_AAA_131U2 0x0013900500039005ull
131 1.19.2.1 bouyer #define ID_AHA_2930U2 0x0011900501819005ull
132 1.19.2.1 bouyer #define ID_AHA_2940U2B 0x00109005A1009005ull
133 1.19.2.1 bouyer #define ID_AHA_2940U2_OEM 0x0010900521809005ull
134 1.19.2.1 bouyer #define ID_AHA_2940U2 0x00109005A1809005ull
135 1.19.2.1 bouyer #define ID_AHA_2950U2B 0x00109005E1009005ull
136 1.19.2.1 bouyer
137 1.19.2.1 bouyer #define ID_AIC7892 0x008F9005FFFF9005ull
138 1.19.2.1 bouyer #define ID_AHA_29160 0x00809005E2A09005ull
139 1.19.2.1 bouyer #define ID_AHA_29160_CPQ 0x00809005E2A00E11ull
140 1.19.2.1 bouyer #define ID_AHA_29160N 0x0080900562A09005ull
141 1.19.2.1 bouyer #define ID_AHA_29160B 0x00809005E2209005ull
142 1.19.2.1 bouyer #define ID_AHA_19160B 0x0081900562A19005ull
143 1.19.2.1 bouyer
144 1.19.2.1 bouyer #define ID_AIC7896 0x005F9005FFFF9005ull
145 1.19.2.1 bouyer #define ID_AHA_3950U2B_0 0x00509005FFFF9005ull
146 1.19.2.1 bouyer #define ID_AHA_3950U2B_1 0x00509005F5009005ull
147 1.19.2.1 bouyer #define ID_AHA_3950U2D_0 0x00519005FFFF9005ull
148 1.19.2.1 bouyer #define ID_AHA_3950U2D_1 0x00519005B5009005ull
149 1.19.2.1 bouyer
150 1.19.2.1 bouyer #define ID_AIC7899 0x00CF9005FFFF9005ull
151 1.19.2.1 bouyer #define ID_AHA_3960D 0x00C09005F6209005ull /* AKA AHA-39160 */
152 1.19.2.1 bouyer #define ID_AHA_3960D_CPQ 0x00C09005F6200E11ull
153 1.19.2.1 bouyer
154 1.19.2.1 bouyer #define ID_AIC7810 0x1078900400000000ull
155 1.19.2.1 bouyer #define ID_AIC7815 0x7815900400000000ull
156 1.19.2.1 bouyer
157 1.19.2.1 bouyer typedef int (ahc_device_setup_t)(struct pci_attach_args *, char *,
158 1.19.2.1 bouyer ahc_chip *, ahc_feature *, ahc_flag *);
159 1.19.2.1 bouyer
160 1.19.2.1 bouyer static ahc_device_setup_t ahc_aic7850_setup;
161 1.19.2.1 bouyer static ahc_device_setup_t ahc_aic7855_setup;
162 1.19.2.1 bouyer static ahc_device_setup_t ahc_aic7859_setup;
163 1.19.2.1 bouyer static ahc_device_setup_t ahc_aic7860_setup;
164 1.19.2.1 bouyer static ahc_device_setup_t ahc_aic7870_setup;
165 1.19.2.1 bouyer static ahc_device_setup_t ahc_aha394X_setup;
166 1.19.2.1 bouyer static ahc_device_setup_t ahc_aha398X_setup;
167 1.19.2.1 bouyer static ahc_device_setup_t ahc_aic7880_setup;
168 1.19.2.1 bouyer static ahc_device_setup_t ahc_2940Pro_setup;
169 1.19.2.1 bouyer static ahc_device_setup_t ahc_aha394XU_setup;
170 1.19.2.1 bouyer static ahc_device_setup_t ahc_aha398XU_setup;
171 1.19.2.1 bouyer static ahc_device_setup_t ahc_aic7890_setup;
172 1.19.2.1 bouyer static ahc_device_setup_t ahc_aic7892_setup;
173 1.19.2.1 bouyer static ahc_device_setup_t ahc_aic7895_setup;
174 1.19.2.1 bouyer static ahc_device_setup_t ahc_aic7896_setup;
175 1.19.2.1 bouyer static ahc_device_setup_t ahc_aic7899_setup;
176 1.19.2.1 bouyer static ahc_device_setup_t ahc_raid_setup;
177 1.19.2.1 bouyer static ahc_device_setup_t ahc_aha394XX_setup;
178 1.19.2.1 bouyer static ahc_device_setup_t ahc_aha398XX_setup;
179 1.19.2.1 bouyer
180 1.19.2.1 bouyer struct ahc_pci_identity {
181 1.19.2.1 bouyer u_int64_t full_id;
182 1.19.2.1 bouyer u_int64_t id_mask;
183 1.19.2.3 bouyer const char *name;
184 1.19.2.1 bouyer ahc_device_setup_t *setup;
185 1.1 mycroft };
186 1.1 mycroft
187 1.19.2.3 bouyer const struct ahc_pci_identity ahc_pci_ident_table [] =
188 1.19.2.1 bouyer {
189 1.19.2.1 bouyer /* aic7850 based controllers */
190 1.19.2.1 bouyer {
191 1.19.2.1 bouyer ID_AHA_2910_15_20_30C,
192 1.19.2.1 bouyer ID_ALL_MASK,
193 1.19.2.1 bouyer "Adaptec 2910/15/20/30C SCSI adapter",
194 1.19.2.1 bouyer ahc_aic7850_setup
195 1.19.2.1 bouyer },
196 1.19.2.1 bouyer /* aic7859 based controllers */
197 1.19.2.1 bouyer {
198 1.19.2.1 bouyer ID_AHA_2930CU,
199 1.19.2.1 bouyer ID_ALL_MASK,
200 1.19.2.1 bouyer "Adaptec 2930CU SCSI adapter",
201 1.19.2.1 bouyer ahc_aic7859_setup
202 1.19.2.1 bouyer },
203 1.19.2.1 bouyer /* aic7860 based controllers */
204 1.19.2.1 bouyer {
205 1.19.2.1 bouyer ID_AHA_2940AU_0 & ID_DEV_VENDOR_MASK,
206 1.19.2.1 bouyer ID_DEV_VENDOR_MASK,
207 1.19.2.1 bouyer "Adaptec 2940A Ultra SCSI adapter",
208 1.19.2.1 bouyer ahc_aic7860_setup
209 1.19.2.1 bouyer },
210 1.19.2.1 bouyer {
211 1.19.2.1 bouyer ID_AHA_2940AU_CN & ID_DEV_VENDOR_MASK,
212 1.19.2.1 bouyer ID_DEV_VENDOR_MASK,
213 1.19.2.1 bouyer "Adaptec 2940A/CN Ultra SCSI adapter",
214 1.19.2.1 bouyer ahc_aic7860_setup
215 1.19.2.1 bouyer },
216 1.19.2.1 bouyer {
217 1.19.2.1 bouyer ID_AHA_2930C_VAR & ID_DEV_VENDOR_MASK,
218 1.19.2.1 bouyer ID_DEV_VENDOR_MASK,
219 1.19.2.1 bouyer "Adaptec 2930C SCSI adapter (VAR)",
220 1.19.2.1 bouyer ahc_aic7860_setup
221 1.19.2.1 bouyer },
222 1.19.2.1 bouyer /* aic7870 based controllers */
223 1.19.2.1 bouyer {
224 1.19.2.1 bouyer ID_AHA_2940,
225 1.19.2.1 bouyer ID_ALL_MASK,
226 1.19.2.1 bouyer "Adaptec 2940 SCSI adapter",
227 1.19.2.1 bouyer ahc_aic7870_setup
228 1.19.2.1 bouyer },
229 1.19.2.1 bouyer {
230 1.19.2.1 bouyer ID_AHA_3940,
231 1.19.2.1 bouyer ID_ALL_MASK,
232 1.19.2.1 bouyer "Adaptec 3940 SCSI adapter",
233 1.19.2.1 bouyer ahc_aha394X_setup
234 1.19.2.1 bouyer },
235 1.19.2.1 bouyer {
236 1.19.2.1 bouyer ID_AHA_398X,
237 1.19.2.1 bouyer ID_ALL_MASK,
238 1.19.2.1 bouyer "Adaptec 398X SCSI RAID adapter",
239 1.19.2.1 bouyer ahc_aha398X_setup
240 1.19.2.1 bouyer },
241 1.19.2.1 bouyer {
242 1.19.2.1 bouyer ID_AHA_2944,
243 1.19.2.1 bouyer ID_ALL_MASK,
244 1.19.2.1 bouyer "Adaptec 2944 SCSI adapter",
245 1.19.2.1 bouyer ahc_aic7870_setup
246 1.19.2.1 bouyer },
247 1.19.2.1 bouyer {
248 1.19.2.1 bouyer ID_AHA_3944,
249 1.19.2.1 bouyer ID_ALL_MASK,
250 1.19.2.1 bouyer "Adaptec 3944 SCSI adapter",
251 1.19.2.1 bouyer ahc_aha394X_setup
252 1.19.2.1 bouyer },
253 1.19.2.1 bouyer /* aic7880 based controllers */
254 1.19.2.1 bouyer {
255 1.19.2.1 bouyer ID_AHA_2940U & ID_DEV_VENDOR_MASK,
256 1.19.2.1 bouyer ID_DEV_VENDOR_MASK,
257 1.19.2.1 bouyer "Adaptec 2940 Ultra SCSI adapter",
258 1.19.2.1 bouyer ahc_aic7880_setup
259 1.19.2.1 bouyer },
260 1.19.2.1 bouyer {
261 1.19.2.1 bouyer ID_AHA_3940U & ID_DEV_VENDOR_MASK,
262 1.19.2.1 bouyer ID_DEV_VENDOR_MASK,
263 1.19.2.1 bouyer "Adaptec 3940 Ultra SCSI adapter",
264 1.19.2.1 bouyer ahc_aha394XU_setup
265 1.19.2.1 bouyer },
266 1.19.2.1 bouyer {
267 1.19.2.1 bouyer ID_AHA_2944U & ID_DEV_VENDOR_MASK,
268 1.19.2.1 bouyer ID_DEV_VENDOR_MASK,
269 1.19.2.1 bouyer "Adaptec 2944 Ultra SCSI adapter",
270 1.19.2.1 bouyer ahc_aic7880_setup
271 1.19.2.1 bouyer },
272 1.19.2.1 bouyer {
273 1.19.2.1 bouyer ID_AHA_3944U & ID_DEV_VENDOR_MASK,
274 1.19.2.1 bouyer ID_DEV_VENDOR_MASK,
275 1.19.2.1 bouyer "Adaptec 3944 Ultra SCSI adapter",
276 1.19.2.1 bouyer ahc_aha394XU_setup
277 1.19.2.1 bouyer },
278 1.19.2.1 bouyer {
279 1.19.2.1 bouyer ID_AHA_398XU & ID_DEV_VENDOR_MASK,
280 1.19.2.1 bouyer ID_DEV_VENDOR_MASK,
281 1.19.2.1 bouyer "Adaptec 398X Ultra SCSI RAID adapter",
282 1.19.2.1 bouyer ahc_aha398XU_setup
283 1.19.2.1 bouyer },
284 1.19.2.1 bouyer {
285 1.19.2.1 bouyer /*
286 1.19.2.1 bouyer * XXX Don't know the slot numbers
287 1.19.2.1 bouyer * so we can't identify channels
288 1.19.2.1 bouyer */
289 1.19.2.1 bouyer ID_AHA_4944U & ID_DEV_VENDOR_MASK,
290 1.19.2.1 bouyer ID_DEV_VENDOR_MASK,
291 1.19.2.1 bouyer "Adaptec 4944 Ultra SCSI adapter",
292 1.19.2.1 bouyer ahc_aic7880_setup
293 1.19.2.1 bouyer },
294 1.19.2.1 bouyer {
295 1.19.2.1 bouyer ID_AHA_2930U & ID_DEV_VENDOR_MASK,
296 1.19.2.1 bouyer ID_DEV_VENDOR_MASK,
297 1.19.2.1 bouyer "Adaptec 2930 Ultra SCSI adapter",
298 1.19.2.1 bouyer ahc_aic7880_setup
299 1.19.2.1 bouyer },
300 1.19.2.1 bouyer {
301 1.19.2.1 bouyer ID_AHA_2940U_PRO & ID_DEV_VENDOR_MASK,
302 1.19.2.1 bouyer ID_DEV_VENDOR_MASK,
303 1.19.2.1 bouyer "Adaptec 2940 Pro Ultra SCSI adapter",
304 1.19.2.1 bouyer ahc_2940Pro_setup
305 1.19.2.1 bouyer },
306 1.19.2.1 bouyer {
307 1.19.2.1 bouyer ID_AHA_2940U_CN & ID_DEV_VENDOR_MASK,
308 1.19.2.1 bouyer ID_DEV_VENDOR_MASK,
309 1.19.2.1 bouyer "Adaptec 2940/CN Ultra SCSI adapter",
310 1.19.2.1 bouyer ahc_aic7880_setup
311 1.19.2.1 bouyer },
312 1.19.2.1 bouyer /* aic7890 based controllers */
313 1.19.2.1 bouyer {
314 1.19.2.1 bouyer ID_AHA_2930U2,
315 1.19.2.1 bouyer ID_ALL_MASK,
316 1.19.2.1 bouyer "Adaptec 2930 Ultra2 SCSI adapter",
317 1.19.2.1 bouyer ahc_aic7890_setup
318 1.19.2.1 bouyer },
319 1.19.2.1 bouyer {
320 1.19.2.1 bouyer ID_AHA_2940U2B,
321 1.19.2.1 bouyer ID_ALL_MASK,
322 1.19.2.1 bouyer "Adaptec 2940B Ultra2 SCSI adapter",
323 1.19.2.1 bouyer ahc_aic7890_setup
324 1.19.2.1 bouyer },
325 1.19.2.1 bouyer {
326 1.19.2.1 bouyer ID_AHA_2940U2_OEM,
327 1.19.2.1 bouyer ID_ALL_MASK,
328 1.19.2.1 bouyer "Adaptec 2940 Ultra2 SCSI adapter (OEM)",
329 1.19.2.1 bouyer ahc_aic7890_setup
330 1.19.2.1 bouyer },
331 1.19.2.1 bouyer {
332 1.19.2.1 bouyer ID_AHA_2940U2,
333 1.19.2.1 bouyer ID_ALL_MASK,
334 1.19.2.1 bouyer "Adaptec 2940 Ultra2 SCSI adapter",
335 1.19.2.1 bouyer ahc_aic7890_setup
336 1.19.2.1 bouyer },
337 1.19.2.1 bouyer {
338 1.19.2.1 bouyer ID_AHA_2950U2B,
339 1.19.2.1 bouyer ID_ALL_MASK,
340 1.19.2.1 bouyer "Adaptec 2950 Ultra2 SCSI adapter",
341 1.19.2.1 bouyer ahc_aic7890_setup
342 1.19.2.1 bouyer },
343 1.19.2.1 bouyer {
344 1.19.2.1 bouyer ID_AAA_131U2,
345 1.19.2.1 bouyer ID_ALL_MASK,
346 1.19.2.1 bouyer "Adaptec AAA-131 Ultra2 RAID adapter",
347 1.19.2.1 bouyer ahc_aic7890_setup
348 1.19.2.1 bouyer },
349 1.19.2.1 bouyer /* aic7892 based controllers */
350 1.19.2.1 bouyer {
351 1.19.2.1 bouyer ID_AHA_29160,
352 1.19.2.1 bouyer ID_ALL_MASK,
353 1.19.2.1 bouyer "Adaptec 29160 Ultra160 SCSI adapter",
354 1.19.2.1 bouyer ahc_aic7892_setup
355 1.19.2.1 bouyer },
356 1.19.2.1 bouyer {
357 1.19.2.1 bouyer ID_AHA_29160_CPQ,
358 1.19.2.1 bouyer ID_ALL_MASK,
359 1.19.2.1 bouyer "Adaptec (Compaq OEM) 29160 Ultra160 SCSI adapter",
360 1.19.2.1 bouyer ahc_aic7892_setup
361 1.19.2.1 bouyer },
362 1.19.2.1 bouyer {
363 1.19.2.1 bouyer ID_AHA_29160N,
364 1.19.2.1 bouyer ID_ALL_MASK,
365 1.19.2.1 bouyer "Adaptec 29160N Ultra160 SCSI adapter",
366 1.19.2.1 bouyer ahc_aic7892_setup
367 1.19.2.1 bouyer },
368 1.19.2.1 bouyer {
369 1.19.2.1 bouyer ID_AHA_29160B,
370 1.19.2.1 bouyer ID_ALL_MASK,
371 1.19.2.1 bouyer "Adaptec 29160B Ultra160 SCSI adapter",
372 1.19.2.1 bouyer ahc_aic7892_setup
373 1.19.2.1 bouyer },
374 1.19.2.1 bouyer {
375 1.19.2.1 bouyer ID_AHA_19160B,
376 1.19.2.1 bouyer ID_ALL_MASK,
377 1.19.2.1 bouyer "Adaptec 19160B Ultra160 SCSI adapter",
378 1.19.2.1 bouyer ahc_aic7892_setup
379 1.19.2.1 bouyer },
380 1.19.2.1 bouyer /* aic7895 based controllers */
381 1.19.2.1 bouyer {
382 1.19.2.1 bouyer ID_AHA_2940U_DUAL,
383 1.19.2.1 bouyer ID_ALL_MASK,
384 1.19.2.1 bouyer "Adaptec 2940/DUAL Ultra SCSI adapter",
385 1.19.2.1 bouyer ahc_aic7895_setup
386 1.19.2.1 bouyer },
387 1.19.2.1 bouyer {
388 1.19.2.1 bouyer ID_AHA_3940AU,
389 1.19.2.1 bouyer ID_ALL_MASK,
390 1.19.2.1 bouyer "Adaptec 3940A Ultra SCSI adapter",
391 1.19.2.1 bouyer ahc_aic7895_setup
392 1.19.2.1 bouyer },
393 1.19.2.1 bouyer {
394 1.19.2.1 bouyer ID_AHA_3944AU,
395 1.19.2.1 bouyer ID_ALL_MASK,
396 1.19.2.1 bouyer "Adaptec 3944A Ultra SCSI adapter",
397 1.19.2.1 bouyer ahc_aic7895_setup
398 1.19.2.1 bouyer },
399 1.19.2.1 bouyer /* aic7896/97 based controllers */
400 1.19.2.1 bouyer {
401 1.19.2.1 bouyer ID_AHA_3950U2B_0,
402 1.19.2.1 bouyer ID_ALL_MASK,
403 1.19.2.1 bouyer "Adaptec 3950B Ultra2 SCSI adapter",
404 1.19.2.1 bouyer ahc_aic7896_setup
405 1.19.2.1 bouyer },
406 1.19.2.1 bouyer {
407 1.19.2.1 bouyer ID_AHA_3950U2B_1,
408 1.19.2.1 bouyer ID_ALL_MASK,
409 1.19.2.1 bouyer "Adaptec 3950B Ultra2 SCSI adapter",
410 1.19.2.1 bouyer ahc_aic7896_setup
411 1.19.2.1 bouyer },
412 1.19.2.1 bouyer {
413 1.19.2.1 bouyer ID_AHA_3950U2D_0,
414 1.19.2.1 bouyer ID_ALL_MASK,
415 1.19.2.1 bouyer "Adaptec 3950D Ultra2 SCSI adapter",
416 1.19.2.1 bouyer ahc_aic7896_setup
417 1.19.2.1 bouyer },
418 1.19.2.1 bouyer {
419 1.19.2.1 bouyer ID_AHA_3950U2D_1,
420 1.19.2.1 bouyer ID_ALL_MASK,
421 1.19.2.1 bouyer "Adaptec 3950D Ultra2 SCSI adapter",
422 1.19.2.1 bouyer ahc_aic7896_setup
423 1.19.2.1 bouyer },
424 1.19.2.1 bouyer /* aic7899 based controllers */
425 1.19.2.1 bouyer {
426 1.19.2.1 bouyer ID_AHA_3960D,
427 1.19.2.1 bouyer ID_ALL_MASK,
428 1.19.2.1 bouyer "Adaptec 3960D Ultra160 SCSI adapter",
429 1.19.2.1 bouyer ahc_aic7899_setup
430 1.19.2.1 bouyer },
431 1.19.2.1 bouyer {
432 1.19.2.1 bouyer ID_AHA_3960D_CPQ,
433 1.19.2.1 bouyer ID_ALL_MASK,
434 1.19.2.1 bouyer "Adaptec (Compaq OEM) 3960D Ultra160 SCSI adapter",
435 1.19.2.1 bouyer ahc_aic7899_setup
436 1.19.2.1 bouyer },
437 1.19.2.1 bouyer /* Generic chip probes for devices we don't know 'exactly' */
438 1.19.2.1 bouyer {
439 1.19.2.1 bouyer ID_AIC7850 & ID_DEV_VENDOR_MASK,
440 1.19.2.1 bouyer ID_DEV_VENDOR_MASK,
441 1.19.2.1 bouyer "Adaptec aic7850 SCSI adapter",
442 1.19.2.1 bouyer ahc_aic7850_setup
443 1.19.2.1 bouyer },
444 1.19.2.1 bouyer {
445 1.19.2.1 bouyer ID_AIC7855 & ID_DEV_VENDOR_MASK,
446 1.19.2.1 bouyer ID_DEV_VENDOR_MASK,
447 1.19.2.1 bouyer "Adaptec aic7855 SCSI adapter",
448 1.19.2.1 bouyer ahc_aic7855_setup
449 1.19.2.1 bouyer },
450 1.19.2.1 bouyer {
451 1.19.2.1 bouyer ID_AIC7859 & ID_DEV_VENDOR_MASK,
452 1.19.2.1 bouyer ID_DEV_VENDOR_MASK,
453 1.19.2.1 bouyer "Adaptec aic7859 SCSI adapter",
454 1.19.2.1 bouyer ahc_aic7859_setup
455 1.19.2.1 bouyer },
456 1.19.2.1 bouyer {
457 1.19.2.1 bouyer ID_AIC7860 & ID_DEV_VENDOR_MASK,
458 1.19.2.1 bouyer ID_DEV_VENDOR_MASK,
459 1.19.2.1 bouyer "Adaptec aic7860 SCSI adapter",
460 1.19.2.1 bouyer ahc_aic7860_setup
461 1.19.2.1 bouyer },
462 1.19.2.1 bouyer {
463 1.19.2.1 bouyer ID_AIC7870 & ID_DEV_VENDOR_MASK,
464 1.19.2.1 bouyer ID_DEV_VENDOR_MASK,
465 1.19.2.1 bouyer "Adaptec aic7870 SCSI adapter",
466 1.19.2.1 bouyer ahc_aic7870_setup
467 1.19.2.1 bouyer },
468 1.19.2.1 bouyer {
469 1.19.2.1 bouyer ID_AIC7880 & ID_DEV_VENDOR_MASK,
470 1.19.2.1 bouyer ID_DEV_VENDOR_MASK,
471 1.19.2.1 bouyer "Adaptec aic7880 Ultra SCSI adapter",
472 1.19.2.1 bouyer ahc_aic7880_setup
473 1.19.2.1 bouyer },
474 1.19.2.1 bouyer {
475 1.19.2.1 bouyer ID_AIC7890 & ID_DEV_VENDOR_MASK,
476 1.19.2.1 bouyer ID_DEV_VENDOR_MASK,
477 1.19.2.1 bouyer "Adaptec aic7890/91 Ultra2 SCSI adapter",
478 1.19.2.1 bouyer ahc_aic7890_setup
479 1.19.2.1 bouyer },
480 1.19.2.1 bouyer {
481 1.19.2.1 bouyer ID_AIC7892 & ID_DEV_VENDOR_MASK,
482 1.19.2.1 bouyer ID_DEV_VENDOR_MASK,
483 1.19.2.1 bouyer "Adaptec aic7892 Ultra160 SCSI adapter",
484 1.19.2.1 bouyer ahc_aic7892_setup
485 1.19.2.1 bouyer },
486 1.19.2.1 bouyer {
487 1.19.2.1 bouyer ID_AIC7895 & ID_DEV_VENDOR_MASK,
488 1.19.2.1 bouyer ID_DEV_VENDOR_MASK,
489 1.19.2.1 bouyer "Adaptec aic7895 Ultra SCSI adapter",
490 1.19.2.1 bouyer ahc_aic7895_setup
491 1.19.2.1 bouyer },
492 1.19.2.1 bouyer {
493 1.19.2.1 bouyer ID_AIC7895_RAID_PORT & ID_DEV_VENDOR_MASK,
494 1.19.2.1 bouyer ID_DEV_VENDOR_MASK,
495 1.19.2.1 bouyer "Adaptec aic7895 Ultra SCSI adapter (RAID PORT)",
496 1.19.2.1 bouyer ahc_aic7895_setup
497 1.19.2.1 bouyer },
498 1.19.2.1 bouyer {
499 1.19.2.1 bouyer ID_AIC7896 & ID_DEV_VENDOR_MASK,
500 1.19.2.1 bouyer ID_DEV_VENDOR_MASK,
501 1.19.2.1 bouyer "Adaptec aic7896/97 Ultra2 SCSI adapter",
502 1.19.2.1 bouyer ahc_aic7896_setup
503 1.19.2.1 bouyer },
504 1.19.2.1 bouyer {
505 1.19.2.1 bouyer ID_AIC7899 & ID_DEV_VENDOR_MASK,
506 1.19.2.1 bouyer ID_DEV_VENDOR_MASK,
507 1.19.2.1 bouyer "Adaptec aic7899 Ultra160 SCSI adapter",
508 1.19.2.1 bouyer ahc_aic7899_setup
509 1.19.2.1 bouyer },
510 1.19.2.1 bouyer {
511 1.19.2.1 bouyer ID_AIC7810 & ID_DEV_VENDOR_MASK,
512 1.19.2.1 bouyer ID_DEV_VENDOR_MASK,
513 1.19.2.1 bouyer "Adaptec aic7810 RAID memory controller",
514 1.19.2.1 bouyer ahc_raid_setup
515 1.19.2.1 bouyer },
516 1.19.2.1 bouyer {
517 1.19.2.1 bouyer ID_AIC7815 & ID_DEV_VENDOR_MASK,
518 1.19.2.1 bouyer ID_DEV_VENDOR_MASK,
519 1.19.2.1 bouyer "Adaptec aic7815 RAID memory controller",
520 1.19.2.1 bouyer ahc_raid_setup
521 1.19.2.1 bouyer }
522 1.1 mycroft };
523 1.1 mycroft
524 1.19.2.1 bouyer static const int ahc_num_pci_devs =
525 1.19.2.1 bouyer sizeof(ahc_pci_ident_table) / sizeof(*ahc_pci_ident_table);
526 1.19.2.1 bouyer
527 1.19.2.1 bouyer #define AHC_394X_SLOT_CHANNEL_A 4
528 1.19.2.1 bouyer #define AHC_394X_SLOT_CHANNEL_B 5
529 1.19.2.1 bouyer
530 1.19.2.1 bouyer #define AHC_398X_SLOT_CHANNEL_A 4
531 1.19.2.1 bouyer #define AHC_398X_SLOT_CHANNEL_B 8
532 1.19.2.1 bouyer #define AHC_398X_SLOT_CHANNEL_C 12
533 1.1 mycroft
534 1.19.2.1 bouyer #define DEVCONFIG 0x40
535 1.19.2.1 bouyer #define SCBSIZE32 0x00010000 /* aic789X only */
536 1.19.2.1 bouyer #define MPORTMODE 0x00000400 /* aic7870 only */
537 1.19.2.1 bouyer #define RAMPSM 0x00000200 /* aic7870 only */
538 1.19.2.1 bouyer #define VOLSENSE 0x00000100
539 1.19.2.1 bouyer #define SCBRAMSEL 0x00000080
540 1.19.2.1 bouyer #define MRDCEN 0x00000040
541 1.19.2.1 bouyer #define EXTSCBTIME 0x00000020 /* aic7870 only */
542 1.19.2.1 bouyer #define EXTSCBPEN 0x00000010 /* aic7870 only */
543 1.19.2.1 bouyer #define BERREN 0x00000008
544 1.19.2.1 bouyer #define DACEN 0x00000004
545 1.19.2.1 bouyer #define STPWLEVEL 0x00000002
546 1.19.2.1 bouyer #define DIFACTNEGEN 0x00000001 /* aic7870 only */
547 1.1 mycroft
548 1.19.2.1 bouyer #define CSIZE_LATTIME 0x0c
549 1.19.2.1 bouyer #define CACHESIZE 0x0000003f /* only 5 bits */
550 1.19.2.1 bouyer #define LATTIME 0x0000ff00
551 1.1 mycroft
552 1.19.2.3 bouyer static const struct ahc_pci_identity *ahc_find_pci_device(pcireg_t, pcireg_t);
553 1.19.2.1 bouyer static int ahc_ext_scbram_present(struct ahc_softc *ahc);
554 1.19.2.1 bouyer static void ahc_ext_scbram_config(struct ahc_softc *ahc, int enable,
555 1.19.2.1 bouyer int pcheck, int fast);
556 1.19.2.1 bouyer static void ahc_probe_ext_scbram(struct ahc_softc *ahc);
557 1.1 mycroft
558 1.10 cgd int ahc_pci_probe __P((struct device *, struct cfdata *, void *));
559 1.1 mycroft void ahc_pci_attach __P((struct device *, struct device *, void *));
560 1.1 mycroft
561 1.19.2.1 bouyer /* Exported for use in the ahc_intr routine */
562 1.19.2.1 bouyer int ahc_pci_intr(struct ahc_softc *ahc);
563 1.19.2.1 bouyer
564 1.1 mycroft struct cfattach ahc_pci_ca = {
565 1.19.2.1 bouyer sizeof(struct ahc_softc), ahc_pci_probe, ahc_pci_attach
566 1.1 mycroft };
567 1.1 mycroft
568 1.19.2.3 bouyer static const struct ahc_pci_identity *
569 1.19.2.1 bouyer ahc_find_pci_device(id, subid)
570 1.19.2.1 bouyer pcireg_t id, subid;
571 1.19.2.1 bouyer {
572 1.19.2.1 bouyer u_int64_t full_id;
573 1.19.2.3 bouyer const struct ahc_pci_identity *entry;
574 1.19.2.1 bouyer u_int i;
575 1.19.2.1 bouyer
576 1.19.2.1 bouyer full_id = ahc_compose_id(PCI_PRODUCT(id), PCI_VENDOR(id),
577 1.19.2.1 bouyer PCI_PRODUCT(subid), PCI_VENDOR(subid));
578 1.19.2.1 bouyer
579 1.19.2.1 bouyer for (i = 0; i < ahc_num_pci_devs; i++) {
580 1.19.2.1 bouyer entry = &ahc_pci_ident_table[i];
581 1.19.2.1 bouyer if (entry->full_id == (full_id & entry->id_mask))
582 1.19.2.1 bouyer return (entry);
583 1.19.2.1 bouyer }
584 1.19.2.1 bouyer return (NULL);
585 1.19.2.1 bouyer }
586 1.19.2.1 bouyer
587 1.1 mycroft int
588 1.1 mycroft ahc_pci_probe(parent, match, aux)
589 1.19.2.1 bouyer struct device *parent;
590 1.19.2.1 bouyer struct cfdata *match;
591 1.19.2.1 bouyer void *aux;
592 1.19.2.1 bouyer {
593 1.19.2.1 bouyer struct pci_attach_args *pa = aux;
594 1.19.2.3 bouyer const struct ahc_pci_identity *entry;
595 1.19.2.1 bouyer pcireg_t subid;
596 1.19.2.1 bouyer
597 1.19.2.1 bouyer subid = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_SUBSYS_ID_REG);
598 1.19.2.1 bouyer entry = ahc_find_pci_device(pa->pa_id, subid);
599 1.19.2.1 bouyer return entry != NULL ? 1 : 0;
600 1.1 mycroft }
601 1.1 mycroft
602 1.19.2.1 bouyer void
603 1.1 mycroft ahc_pci_attach(parent, self, aux)
604 1.19.2.1 bouyer struct device *parent, *self;
605 1.19.2.1 bouyer void *aux;
606 1.1 mycroft {
607 1.1 mycroft struct pci_attach_args *pa = aux;
608 1.19.2.3 bouyer const struct ahc_pci_identity *entry;
609 1.19.2.1 bouyer struct ahc_softc *ahc = (void *)self;
610 1.19.2.1 bouyer pcireg_t command;
611 1.19.2.1 bouyer ahc_chip ahc_t = AHC_NONE;
612 1.19.2.1 bouyer ahc_feature ahc_fe = AHC_FENONE;
613 1.19.2.1 bouyer ahc_flag ahc_f = AHC_FNONE;
614 1.19.2.1 bouyer u_int our_id = 0;
615 1.19.2.1 bouyer u_int sxfrctl1;
616 1.19.2.1 bouyer u_int scsiseq;
617 1.19.2.1 bouyer int error;
618 1.19.2.1 bouyer char channel;
619 1.19.2.1 bouyer pcireg_t subid;
620 1.19.2.1 bouyer int ioh_valid, memh_valid;
621 1.19.2.1 bouyer bus_space_tag_t st, iot;
622 1.19.2.1 bouyer bus_space_handle_t sh, ioh;
623 1.19.2.1 bouyer #ifdef AHC_ALLOW_MEMIO
624 1.19.2.1 bouyer bus_space_tag_t memt;
625 1.19.2.1 bouyer bus_space_handle_t memh;
626 1.19.2.1 bouyer pcireg_t memtype;
627 1.19.2.1 bouyer #endif
628 1.1 mycroft pci_intr_handle_t ih;
629 1.1 mycroft const char *intrstr;
630 1.19.2.1 bouyer struct ahc_pci_busdata *bd;
631 1.1 mycroft
632 1.19.2.1 bouyer command = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG);
633 1.19.2.1 bouyer subid = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_SUBSYS_ID_REG);
634 1.19.2.1 bouyer entry = ahc_find_pci_device(pa->pa_id, subid);
635 1.19.2.1 bouyer if (entry == NULL)
636 1.19.2.1 bouyer return;
637 1.19.2.1 bouyer error = entry->setup(pa, &channel, &ahc_t, &ahc_fe, &ahc_f);
638 1.19.2.1 bouyer if (error != 0)
639 1.1 mycroft return;
640 1.13 cgd
641 1.19.2.1 bouyer ioh_valid = memh_valid = 0;
642 1.19.2.1 bouyer
643 1.19.2.1 bouyer #ifdef AHC_ALLOW_MEMIO
644 1.19.2.1 bouyer memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, AHC_PCI_MEMADDR);
645 1.19.2.1 bouyer switch (memtype) {
646 1.19.2.1 bouyer case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT:
647 1.19.2.1 bouyer case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_64BIT:
648 1.19.2.1 bouyer memh_valid = (pci_mapreg_map(pa, AHC_PCI_MEMADDR,
649 1.19.2.1 bouyer memtype, 0, &memt, &memh, NULL, NULL) == 0);
650 1.19.2.1 bouyer break;
651 1.19.2.1 bouyer default:
652 1.19.2.1 bouyer memh_valid = 0;
653 1.19.2.1 bouyer }
654 1.19.2.1 bouyer #endif
655 1.19.2.1 bouyer ioh_valid = (pci_mapreg_map(pa, AHC_PCI_IOADDR,
656 1.19.2.1 bouyer PCI_MAPREG_TYPE_IO, 0, &iot, &ioh, NULL, NULL) == 0);
657 1.19.2.1 bouyer
658 1.19.2.1 bouyer if (ioh_valid) {
659 1.13 cgd st = iot;
660 1.13 cgd sh = ioh;
661 1.19.2.1 bouyer #ifdef AHC_ALLOW_MEMIO
662 1.19.2.1 bouyer } else if (memh_valid) {
663 1.19.2.1 bouyer st = memt;
664 1.19.2.1 bouyer sh = memh;
665 1.19.2.1 bouyer #endif
666 1.12 cgd } else {
667 1.13 cgd printf(": unable to map registers\n");
668 1.1 mycroft return;
669 1.12 cgd }
670 1.19.2.1 bouyer
671 1.12 cgd printf("\n");
672 1.19.2.1 bouyer
673 1.1 mycroft
674 1.19.2.1 bouyer /* Ensure busmastering is enabled */
675 1.19.2.1 bouyer command |= PCI_COMMAND_MASTER_ENABLE;;
676 1.19.2.1 bouyer pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, command);
677 1.1 mycroft
678 1.1 mycroft /* On all PCI adapters, we allow SCB paging */
679 1.1 mycroft ahc_f |= AHC_PAGESCBS;
680 1.19.2.1 bouyer if (ahc_alloc(ahc, sh, st, pa->pa_dmat,
681 1.19.2.1 bouyer ahc_t|AHC_PCI, ahc_fe, ahc_f) < 0)
682 1.19.2.1 bouyer return;
683 1.1 mycroft
684 1.19.2.1 bouyer bd = malloc(sizeof (struct ahc_pci_busdata), M_DEVBUF, M_NOWAIT);
685 1.19.2.1 bouyer if (bd == NULL) {
686 1.19.2.1 bouyer printf(": unable to allocate bus-specific data\n");
687 1.19.2.1 bouyer return;
688 1.1 mycroft }
689 1.1 mycroft
690 1.19.2.1 bouyer bd->pc = pa->pa_pc;
691 1.19.2.1 bouyer bd->tag = pa->pa_tag;
692 1.19.2.1 bouyer bd->func = pa->pa_function;
693 1.19.2.1 bouyer bd->dev = pa->pa_device;
694 1.19.2.1 bouyer
695 1.19.2.1 bouyer ahc->bus_data = bd;
696 1.19.2.1 bouyer ahc->bus_intr = ahc_pci_intr;
697 1.19.2.1 bouyer ahc->channel = channel;
698 1.19.2.1 bouyer
699 1.19.2.1 bouyer /* Remeber how the card was setup in case there is no SEEPROM */
700 1.19.2.1 bouyer ahc_outb(ahc, HCNTRL, ahc->pause);
701 1.19.2.1 bouyer if ((ahc->features & AHC_ULTRA2) != 0)
702 1.19.2.1 bouyer our_id = ahc_inb(ahc, SCSIID_ULTRA2) & OID;
703 1.19.2.1 bouyer else
704 1.19.2.1 bouyer our_id = ahc_inb(ahc, SCSIID) & OID;
705 1.19.2.1 bouyer sxfrctl1 = ahc_inb(ahc, SXFRCTL1) & STPWEN;
706 1.19.2.1 bouyer scsiseq = ahc_inb(ahc, SCSISEQ);
707 1.1 mycroft
708 1.19.2.1 bouyer if (ahc_reset(ahc) != 0) {
709 1.19.2.1 bouyer /* Failed */
710 1.1 mycroft ahc_free(ahc);
711 1.1 mycroft return;
712 1.1 mycroft }
713 1.19.2.1 bouyer
714 1.19.2.1 bouyer if ((ahc->features & AHC_DT) != 0) {
715 1.19.2.1 bouyer u_int optionmode;
716 1.19.2.1 bouyer u_int sfunct;
717 1.19.2.1 bouyer
718 1.19.2.1 bouyer /* Perform ALT-Mode Setup */
719 1.19.2.1 bouyer sfunct = ahc_inb(ahc, SFUNCT) & ~ALT_MODE;
720 1.19.2.1 bouyer ahc_outb(ahc, SFUNCT, sfunct | ALT_MODE);
721 1.19.2.1 bouyer optionmode = ahc_inb(ahc, OPTIONMODE);
722 1.19.2.4 bouyer #ifdef DEBUG
723 1.19.2.4 bouyer printf("%s: OptionMode = %x\n", ahc->sc_dev.dv_xname,
724 1.19.2.4 bouyer optionmode);
725 1.19.2.4 bouyer #endif
726 1.19.2.1 bouyer ahc_outb(ahc, OPTIONMODE, OPTIONMODE_DEFAULTS);
727 1.19.2.1 bouyer /* Send CRC info in target mode every 4K */
728 1.19.2.1 bouyer ahc_outb(ahc, TARGCRCCNT, 0);
729 1.19.2.1 bouyer ahc_outb(ahc, TARGCRCCNT + 1, 0x10);
730 1.19.2.1 bouyer ahc_outb(ahc, SFUNCT, sfunct);
731 1.19.2.1 bouyer
732 1.19.2.1 bouyer /* Normal mode setup */
733 1.19.2.1 bouyer ahc_outb(ahc, CRCCONTROL1, CRCVALCHKEN|CRCENDCHKEN|CRCREQCHKEN
734 1.19.2.1 bouyer |TARGCRCENDEN|TARGCRCCNTEN);
735 1.19.2.1 bouyer }
736 1.1 mycroft
737 1.19.2.2 bouyer if (pci_intr_map(pa, &ih)) {
738 1.8 christos printf("%s: couldn't map interrupt\n", ahc->sc_dev.dv_xname);
739 1.1 mycroft ahc_free(ahc);
740 1.1 mycroft return;
741 1.1 mycroft }
742 1.1 mycroft intrstr = pci_intr_string(pa->pa_pc, ih);
743 1.19.2.1 bouyer ahc->ih = pci_intr_establish(pa->pa_pc, ih, IPL_BIO, ahc_intr, ahc);
744 1.19.2.1 bouyer if (ahc->ih == NULL) {
745 1.8 christos printf("%s: couldn't establish interrupt",
746 1.1 mycroft ahc->sc_dev.dv_xname);
747 1.1 mycroft if (intrstr != NULL)
748 1.8 christos printf(" at %s", intrstr);
749 1.8 christos printf("\n");
750 1.1 mycroft ahc_free(ahc);
751 1.1 mycroft return;
752 1.1 mycroft }
753 1.1 mycroft if (intrstr != NULL)
754 1.8 christos printf("%s: interrupting at %s\n", ahc->sc_dev.dv_xname,
755 1.1 mycroft intrstr);
756 1.1 mycroft
757 1.1 mycroft /*
758 1.19.2.1 bouyer * Do aic7880/aic7870/aic7860/aic7850 specific initialization
759 1.1 mycroft */
760 1.1 mycroft {
761 1.19.2.1 bouyer u_int8_t sblkctl;
762 1.19.2.1 bouyer u_int dscommand0;
763 1.19.2.1 bouyer
764 1.19.2.1 bouyer dscommand0 = ahc_inb(ahc, DSCOMMAND0);
765 1.19.2.1 bouyer dscommand0 |= MPARCKEN;
766 1.19.2.1 bouyer if ((ahc->features & AHC_ULTRA2) != 0) {
767 1.1 mycroft
768 1.1 mycroft /*
769 1.19.2.1 bouyer * DPARCKEN doesn't work correctly on
770 1.19.2.1 bouyer * some MBs so don't use it.
771 1.1 mycroft */
772 1.19.2.1 bouyer dscommand0 &= ~(USCBSIZE32|DPARCKEN);
773 1.19.2.1 bouyer dscommand0 |= CACHETHEN;
774 1.1 mycroft }
775 1.1 mycroft
776 1.19.2.1 bouyer ahc_outb(ahc, DSCOMMAND0, dscommand0);
777 1.19.2.1 bouyer
778 1.19.2.1 bouyer /* See if we have an SEEPROM and perform auto-term */
779 1.19.2.1 bouyer check_extport(ahc, &sxfrctl1);
780 1.19.2.1 bouyer
781 1.1 mycroft /*
782 1.1 mycroft * Take the LED out of diagnostic mode
783 1.1 mycroft */
784 1.19.2.1 bouyer sblkctl = ahc_inb(ahc, SBLKCTL);
785 1.19.2.1 bouyer ahc_outb(ahc, SBLKCTL, (sblkctl & ~(DIAGLEDEN|DIAGLEDON)));
786 1.1 mycroft
787 1.1 mycroft /*
788 1.1 mycroft * I don't know where this is set in the SEEPROM or by the
789 1.19.2.1 bouyer * BIOS, so we default to 100% on Ultra or slower controllers
790 1.19.2.1 bouyer * and 75% on ULTRA2 controllers.
791 1.1 mycroft */
792 1.19.2.1 bouyer if ((ahc->features & AHC_ULTRA2) != 0) {
793 1.19.2.1 bouyer ahc_outb(ahc, DFF_THRSH, RD_DFTHRSH_75|WR_DFTHRSH_75);
794 1.19.2.1 bouyer } else {
795 1.19.2.1 bouyer ahc_outb(ahc, DSPCISTATUS, DFTHRSH_100);
796 1.19.2.1 bouyer }
797 1.1 mycroft
798 1.19.2.1 bouyer if (ahc->flags & AHC_USEDEFAULTS) {
799 1.1 mycroft /*
800 1.1 mycroft * PCI Adapter default setup
801 1.1 mycroft * Should only be used if the adapter does not have
802 1.1 mycroft * an SEEPROM.
803 1.1 mycroft */
804 1.1 mycroft /* See if someone else set us up already */
805 1.19.2.1 bouyer if (scsiseq != 0) {
806 1.8 christos printf("%s: Using left over BIOS settings\n",
807 1.1 mycroft ahc_name(ahc));
808 1.1 mycroft ahc->flags &= ~AHC_USEDEFAULTS;
809 1.19.2.1 bouyer } else {
810 1.1 mycroft /*
811 1.19.2.1 bouyer * Assume only one connector and always turn
812 1.19.2.1 bouyer * on termination.
813 1.1 mycroft */
814 1.19.2.1 bouyer our_id = 0x07;
815 1.19.2.1 bouyer sxfrctl1 = STPWEN;
816 1.1 mycroft }
817 1.19.2.1 bouyer ahc_outb(ahc, SCSICONF, our_id|ENSPCHK|RESET_SCSI);
818 1.1 mycroft
819 1.19.2.1 bouyer ahc->our_id = our_id;
820 1.19.2.1 bouyer }
821 1.1 mycroft }
822 1.1 mycroft
823 1.19.2.1 bouyer /*
824 1.19.2.1 bouyer * Take a look to see if we have external SRAM.
825 1.19.2.1 bouyer * We currently do not attempt to use SRAM that is
826 1.19.2.1 bouyer * shared among multiple controllers.
827 1.19.2.1 bouyer */
828 1.19.2.1 bouyer ahc_probe_ext_scbram(ahc);
829 1.19.2.1 bouyer
830 1.19.2.1 bouyer
831 1.19.2.1 bouyer printf("%s: %s ", ahc_name(ahc),
832 1.19.2.1 bouyer ahc_chip_names[ahc->chip & AHC_CHIPID_MASK]);
833 1.19.2.1 bouyer
834 1.19.2.1 bouyer /*
835 1.19.2.1 bouyer * Record our termination setting for the
836 1.19.2.1 bouyer * generic initialization routine.
837 1.19.2.1 bouyer */
838 1.19.2.1 bouyer if ((sxfrctl1 & STPWEN) != 0)
839 1.19.2.1 bouyer ahc->flags |= AHC_TERM_ENB_A;
840 1.19.2.1 bouyer
841 1.19.2.1 bouyer if (ahc_init(ahc)) {
842 1.1 mycroft ahc_free(ahc);
843 1.19.2.1 bouyer return;
844 1.1 mycroft }
845 1.1 mycroft
846 1.1 mycroft ahc_attach(ahc);
847 1.1 mycroft }
848 1.1 mycroft
849 1.1 mycroft /*
850 1.19.2.1 bouyer * Test for the presense of external sram in an
851 1.19.2.1 bouyer * "unshared" configuration.
852 1.1 mycroft */
853 1.19.2.1 bouyer static int
854 1.19.2.1 bouyer ahc_ext_scbram_present(struct ahc_softc *ahc)
855 1.1 mycroft {
856 1.19.2.1 bouyer int ramps;
857 1.19.2.1 bouyer int single_user;
858 1.19.2.1 bouyer pcireg_t devconfig;
859 1.19.2.1 bouyer struct ahc_pci_busdata *bd = ahc->bus_data;
860 1.19.2.1 bouyer
861 1.19.2.1 bouyer devconfig = pci_conf_read(bd->pc, bd->tag, DEVCONFIG);
862 1.19.2.1 bouyer single_user = (devconfig & MPORTMODE) != 0;
863 1.19.2.1 bouyer
864 1.19.2.1 bouyer if ((ahc->features & AHC_ULTRA2) != 0)
865 1.19.2.1 bouyer ramps = (ahc_inb(ahc, DSCOMMAND0) & RAMPS) != 0;
866 1.19.2.1 bouyer else if ((ahc->chip & AHC_CHIPID_MASK) >= AHC_AIC7870)
867 1.19.2.1 bouyer ramps = (devconfig & RAMPSM) != 0;
868 1.19.2.1 bouyer else
869 1.19.2.1 bouyer ramps = 0;
870 1.19.2.1 bouyer
871 1.19.2.1 bouyer if (ramps && single_user)
872 1.19.2.1 bouyer return (1);
873 1.19.2.1 bouyer return (0);
874 1.19.2.1 bouyer }
875 1.19.2.1 bouyer
876 1.19.2.1 bouyer /*
877 1.19.2.1 bouyer * Enable external scbram.
878 1.19.2.1 bouyer */
879 1.19.2.1 bouyer static void
880 1.19.2.1 bouyer ahc_ext_scbram_config(struct ahc_softc *ahc, int enable, int pcheck, int fast)
881 1.19.2.1 bouyer {
882 1.19.2.1 bouyer pcireg_t devconfig;
883 1.19.2.1 bouyer struct ahc_pci_busdata *bd = ahc->bus_data;
884 1.19.2.1 bouyer
885 1.19.2.1 bouyer if (ahc->features & AHC_MULTI_FUNC) {
886 1.1 mycroft /*
887 1.19.2.1 bouyer * Set the SCB Base addr (highest address bit)
888 1.19.2.1 bouyer * depending on which channel we are.
889 1.1 mycroft */
890 1.19.2.1 bouyer ahc_outb(ahc, SCBBADDR, (u_int8_t)bd->func);
891 1.19.2.1 bouyer }
892 1.1 mycroft
893 1.19.2.1 bouyer devconfig = pci_conf_read(bd->pc, bd->tag, DEVCONFIG);
894 1.19.2.1 bouyer if ((ahc->features & AHC_ULTRA2) != 0) {
895 1.19.2.1 bouyer u_int dscommand0;
896 1.19.2.1 bouyer
897 1.19.2.1 bouyer dscommand0 = ahc_inb(ahc, DSCOMMAND0);
898 1.19.2.1 bouyer if (enable)
899 1.19.2.1 bouyer dscommand0 &= ~INTSCBRAMSEL;
900 1.19.2.1 bouyer else
901 1.19.2.1 bouyer dscommand0 |= INTSCBRAMSEL;
902 1.19.2.1 bouyer ahc_outb(ahc, DSCOMMAND0, dscommand0);
903 1.19.2.1 bouyer } else {
904 1.19.2.1 bouyer if (fast)
905 1.19.2.1 bouyer devconfig &= ~EXTSCBTIME;
906 1.19.2.1 bouyer else
907 1.19.2.1 bouyer devconfig |= EXTSCBTIME;
908 1.19.2.1 bouyer if (enable)
909 1.19.2.1 bouyer devconfig &= ~SCBRAMSEL;
910 1.19.2.1 bouyer else
911 1.19.2.1 bouyer devconfig |= SCBRAMSEL;
912 1.19.2.1 bouyer }
913 1.19.2.1 bouyer if (pcheck)
914 1.19.2.1 bouyer devconfig |= EXTSCBPEN;
915 1.19.2.1 bouyer else
916 1.19.2.1 bouyer devconfig &= ~EXTSCBPEN;
917 1.1 mycroft
918 1.19.2.1 bouyer pci_conf_write(bd->pc, bd->tag, DEVCONFIG, devconfig);
919 1.19.2.1 bouyer }
920 1.1 mycroft
921 1.19.2.1 bouyer /*
922 1.19.2.1 bouyer * Take a look to see if we have external SRAM.
923 1.19.2.1 bouyer * We currently do not attempt to use SRAM that is
924 1.19.2.1 bouyer * shared among multiple controllers.
925 1.19.2.1 bouyer */
926 1.19.2.1 bouyer static void
927 1.19.2.1 bouyer ahc_probe_ext_scbram(struct ahc_softc *ahc)
928 1.19.2.1 bouyer {
929 1.19.2.1 bouyer int num_scbs;
930 1.19.2.1 bouyer int test_num_scbs;
931 1.19.2.1 bouyer int enable;
932 1.19.2.1 bouyer int pcheck;
933 1.19.2.1 bouyer int fast;
934 1.19.2.1 bouyer
935 1.19.2.1 bouyer if (ahc_ext_scbram_present(ahc) == 0)
936 1.19.2.1 bouyer return;
937 1.19.2.1 bouyer
938 1.19.2.1 bouyer /*
939 1.19.2.1 bouyer * Probe for the best parameters to use.
940 1.19.2.1 bouyer */
941 1.19.2.1 bouyer enable = FALSE;
942 1.19.2.1 bouyer pcheck = FALSE;
943 1.19.2.1 bouyer fast = FALSE;
944 1.19.2.1 bouyer ahc_ext_scbram_config(ahc, /*enable*/TRUE, pcheck, fast);
945 1.19.2.1 bouyer num_scbs = ahc_probe_scbs(ahc);
946 1.19.2.1 bouyer if (num_scbs == 0) {
947 1.19.2.1 bouyer /* The SRAM wasn't really present. */
948 1.19.2.1 bouyer goto done;
949 1.1 mycroft }
950 1.19.2.1 bouyer enable = TRUE;
951 1.19.2.1 bouyer
952 1.19.2.1 bouyer /*
953 1.19.2.1 bouyer * Clear any outstanding parity error
954 1.19.2.1 bouyer * and ensure that parity error reporting
955 1.19.2.1 bouyer * is enabled.
956 1.19.2.1 bouyer */
957 1.19.2.1 bouyer ahc_outb(ahc, SEQCTL, 0);
958 1.19.2.1 bouyer ahc_outb(ahc, CLRINT, CLRPARERR);
959 1.19.2.1 bouyer ahc_outb(ahc, CLRINT, CLRBRKADRINT);
960 1.19.2.1 bouyer
961 1.19.2.1 bouyer /* Now see if we can do parity */
962 1.19.2.1 bouyer ahc_ext_scbram_config(ahc, enable, /*pcheck*/TRUE, fast);
963 1.19.2.1 bouyer num_scbs = ahc_probe_scbs(ahc);
964 1.19.2.1 bouyer if ((ahc_inb(ahc, INTSTAT) & BRKADRINT) == 0
965 1.19.2.1 bouyer || (ahc_inb(ahc, ERROR) & MPARERR) == 0)
966 1.19.2.1 bouyer pcheck = TRUE;
967 1.19.2.1 bouyer
968 1.19.2.1 bouyer /* Clear any resulting parity error */
969 1.19.2.1 bouyer ahc_outb(ahc, CLRINT, CLRPARERR);
970 1.19.2.1 bouyer ahc_outb(ahc, CLRINT, CLRBRKADRINT);
971 1.19.2.1 bouyer
972 1.19.2.1 bouyer /* Now see if we can do fast timing */
973 1.19.2.1 bouyer ahc_ext_scbram_config(ahc, enable, pcheck, /*fast*/TRUE);
974 1.19.2.1 bouyer test_num_scbs = ahc_probe_scbs(ahc);
975 1.19.2.1 bouyer if (test_num_scbs == num_scbs
976 1.19.2.1 bouyer && ((ahc_inb(ahc, INTSTAT) & BRKADRINT) == 0
977 1.19.2.1 bouyer || (ahc_inb(ahc, ERROR) & MPARERR) == 0))
978 1.19.2.1 bouyer fast = TRUE;
979 1.19.2.1 bouyer
980 1.19.2.1 bouyer done:
981 1.19.2.1 bouyer /*
982 1.19.2.1 bouyer * Disable parity error reporting until we
983 1.19.2.1 bouyer * can load instruction ram.
984 1.19.2.1 bouyer */
985 1.19.2.1 bouyer ahc_outb(ahc, SEQCTL, PERRORDIS|FAILDIS);
986 1.19.2.1 bouyer /* Clear any latched parity error */
987 1.19.2.1 bouyer ahc_outb(ahc, CLRINT, CLRPARERR);
988 1.19.2.1 bouyer ahc_outb(ahc, CLRINT, CLRBRKADRINT);
989 1.19.2.1 bouyer if (bootverbose && enable) {
990 1.19.2.1 bouyer printf("%s: External SRAM, %s access%s\n",
991 1.19.2.1 bouyer ahc_name(ahc), fast ? "fast" : "slow",
992 1.19.2.1 bouyer pcheck ? ", parity checking enabled" : "");
993 1.19.2.1 bouyer
994 1.19.2.1 bouyer }
995 1.19.2.1 bouyer ahc_ext_scbram_config(ahc, enable, pcheck, fast);
996 1.19.2.1 bouyer }
997 1.19.2.1 bouyer
998 1.19.2.1 bouyer #define DPE PCI_STATUS_PARITY_DETECT
999 1.19.2.1 bouyer #define SSE PCI_STATUS_SPECIAL_ERROR
1000 1.19.2.1 bouyer #define RMA PCI_STATUS_MASTER_ABORT
1001 1.19.2.1 bouyer #define RTA PCI_STATUS_MASTER_TARGET_ABORT
1002 1.19.2.1 bouyer #define STA PCI_STATUS_TARGET_TARGET_ABORT
1003 1.19.2.1 bouyer #define DPR PCI_STATUS_PARITY_ERROR
1004 1.19.2.1 bouyer
1005 1.19.2.1 bouyer int
1006 1.19.2.1 bouyer ahc_pci_intr(struct ahc_softc *ahc)
1007 1.19.2.1 bouyer {
1008 1.19.2.1 bouyer pcireg_t status1;
1009 1.19.2.1 bouyer struct ahc_pci_busdata *bd = ahc->bus_data;
1010 1.19.2.1 bouyer
1011 1.19.2.1 bouyer if ((ahc_inb(ahc, ERROR) & PCIERRSTAT) == 0)
1012 1.19.2.1 bouyer return 0;
1013 1.19.2.1 bouyer
1014 1.19.2.1 bouyer status1 = pci_conf_read(bd->pc, bd->tag, PCI_COMMAND_STATUS_REG);
1015 1.19.2.1 bouyer
1016 1.19.2.1 bouyer if (status1 & DPE) {
1017 1.19.2.1 bouyer printf("%s: Data Parity Error Detected during address "
1018 1.19.2.1 bouyer "or write data phase\n", ahc_name(ahc));
1019 1.19.2.1 bouyer }
1020 1.19.2.1 bouyer if (status1 & SSE) {
1021 1.19.2.1 bouyer printf("%s: Signal System Error Detected\n", ahc_name(ahc));
1022 1.19.2.1 bouyer }
1023 1.19.2.1 bouyer if (status1 & RMA) {
1024 1.19.2.1 bouyer printf("%s: Received a Master Abort\n", ahc_name(ahc));
1025 1.19.2.1 bouyer }
1026 1.19.2.1 bouyer if (status1 & RTA) {
1027 1.19.2.1 bouyer printf("%s: Received a Target Abort\n", ahc_name(ahc));
1028 1.19.2.1 bouyer }
1029 1.19.2.1 bouyer if (status1 & STA) {
1030 1.19.2.1 bouyer printf("%s: Signaled a Target Abort\n", ahc_name(ahc));
1031 1.19.2.1 bouyer }
1032 1.19.2.1 bouyer if (status1 & DPR) {
1033 1.19.2.1 bouyer printf("%s: Data Parity Error has been reported via PERR#\n",
1034 1.19.2.1 bouyer ahc_name(ahc));
1035 1.19.2.1 bouyer }
1036 1.19.2.1 bouyer if ((status1 & (DPE|SSE|RMA|RTA|STA|DPR)) == 0) {
1037 1.19.2.1 bouyer printf("%s: Latched PCIERR interrupt with "
1038 1.19.2.1 bouyer "no status bits set\n", ahc_name(ahc));
1039 1.19.2.1 bouyer }
1040 1.19.2.1 bouyer pci_conf_write(bd->pc, bd->tag, PCI_COMMAND_STATUS_REG, status1);
1041 1.19.2.1 bouyer
1042 1.19.2.1 bouyer if (status1 & (DPR|RMA|RTA)) {
1043 1.19.2.1 bouyer ahc_outb(ahc, CLRINT, CLRPARERR);
1044 1.19.2.1 bouyer }
1045 1.19.2.1 bouyer
1046 1.19.2.1 bouyer return 1;
1047 1.3 explorer }
1048 1.3 explorer
1049 1.3 explorer static int
1050 1.19.2.1 bouyer ahc_aic7850_setup(struct pci_attach_args *pa, char *channel,
1051 1.19.2.1 bouyer ahc_chip *chip, ahc_feature *features, ahc_flag *flags)
1052 1.3 explorer {
1053 1.19.2.1 bouyer *channel = 'A';
1054 1.19.2.1 bouyer *chip = AHC_AIC7850;
1055 1.19.2.1 bouyer *features = AHC_AIC7850_FE;
1056 1.19.2.1 bouyer return (0);
1057 1.19.2.1 bouyer }
1058 1.3 explorer
1059 1.19.2.1 bouyer static int
1060 1.19.2.1 bouyer ahc_aic7855_setup(struct pci_attach_args *pa, char *channel,
1061 1.19.2.1 bouyer ahc_chip *chip, ahc_feature *features, ahc_flag *flags)
1062 1.19.2.1 bouyer {
1063 1.19.2.1 bouyer *channel = 'A';
1064 1.19.2.1 bouyer *chip = AHC_AIC7855;
1065 1.19.2.1 bouyer *features = AHC_AIC7855_FE;
1066 1.19.2.1 bouyer return (0);
1067 1.3 explorer }
1068 1.3 explorer
1069 1.19.2.1 bouyer static int
1070 1.19.2.1 bouyer ahc_aic7859_setup(struct pci_attach_args *pa, char *channel,
1071 1.19.2.1 bouyer ahc_chip *chip, ahc_feature *features, ahc_flag *flags)
1072 1.3 explorer {
1073 1.19.2.1 bouyer *channel = 'A';
1074 1.19.2.1 bouyer *chip = AHC_AIC7859;
1075 1.19.2.1 bouyer *features = AHC_AIC7859_FE;
1076 1.19.2.1 bouyer return (0);
1077 1.1 mycroft }
1078 1.1 mycroft
1079 1.19.2.1 bouyer static int
1080 1.19.2.1 bouyer ahc_aic7860_setup(struct pci_attach_args *pa, char *channel,
1081 1.19.2.1 bouyer ahc_chip *chip, ahc_feature *features, ahc_flag *flags)
1082 1.19.2.1 bouyer {
1083 1.19.2.1 bouyer *channel = 'A';
1084 1.19.2.1 bouyer *chip = AHC_AIC7860;
1085 1.19.2.1 bouyer *features = AHC_AIC7860_FE;
1086 1.19.2.1 bouyer return (0);
1087 1.19.2.1 bouyer }
1088 1.19.2.1 bouyer
1089 1.19.2.1 bouyer static int
1090 1.19.2.1 bouyer ahc_aic7870_setup(struct pci_attach_args *pa, char *channel,
1091 1.19.2.1 bouyer ahc_chip *chip, ahc_feature *features, ahc_flag *flags)
1092 1.19.2.1 bouyer {
1093 1.19.2.1 bouyer *channel = 'A';
1094 1.19.2.1 bouyer *chip = AHC_AIC7870;
1095 1.19.2.1 bouyer *features = AHC_AIC7870_FE;
1096 1.19.2.1 bouyer return (0);
1097 1.19.2.1 bouyer }
1098 1.19.2.1 bouyer
1099 1.19.2.1 bouyer static int
1100 1.19.2.1 bouyer ahc_aha394X_setup(struct pci_attach_args *pa, char *channel,
1101 1.19.2.1 bouyer ahc_chip *chip, ahc_feature *features, ahc_flag *flags)
1102 1.19.2.1 bouyer {
1103 1.19.2.1 bouyer int error;
1104 1.19.2.1 bouyer
1105 1.19.2.1 bouyer error = ahc_aic7870_setup(pa, channel, chip, features, flags);
1106 1.19.2.1 bouyer if (error == 0)
1107 1.19.2.1 bouyer error = ahc_aha394XX_setup(pa, channel, chip, features, flags);
1108 1.19.2.1 bouyer return (error);
1109 1.19.2.1 bouyer }
1110 1.19.2.1 bouyer
1111 1.19.2.1 bouyer static int
1112 1.19.2.1 bouyer ahc_aha398X_setup(struct pci_attach_args *pa, char *channel,
1113 1.19.2.1 bouyer ahc_chip *chip, ahc_feature *features, ahc_flag *flags)
1114 1.19.2.1 bouyer {
1115 1.19.2.1 bouyer int error;
1116 1.19.2.1 bouyer
1117 1.19.2.1 bouyer error = ahc_aic7870_setup(pa, channel, chip, features, flags);
1118 1.19.2.1 bouyer if (error == 0)
1119 1.19.2.1 bouyer error = ahc_aha398XX_setup(pa, channel, chip, features, flags);
1120 1.19.2.1 bouyer return (error);
1121 1.19.2.1 bouyer }
1122 1.19.2.1 bouyer
1123 1.19.2.1 bouyer static int
1124 1.19.2.1 bouyer ahc_aic7880_setup(struct pci_attach_args *pa, char *channel,
1125 1.19.2.1 bouyer ahc_chip *chip, ahc_feature *features, ahc_flag *flags)
1126 1.19.2.1 bouyer {
1127 1.19.2.1 bouyer *channel = 'A';
1128 1.19.2.1 bouyer *chip = AHC_AIC7880;
1129 1.19.2.1 bouyer *features = AHC_AIC7880_FE;
1130 1.19.2.1 bouyer return (0);
1131 1.19.2.1 bouyer }
1132 1.19.2.1 bouyer
1133 1.19.2.1 bouyer static int
1134 1.19.2.1 bouyer ahc_2940Pro_setup(struct pci_attach_args *pa, char *channel,
1135 1.19.2.1 bouyer ahc_chip *chip, ahc_feature *features, ahc_flag *flags)
1136 1.19.2.1 bouyer {
1137 1.19.2.1 bouyer int error;
1138 1.19.2.1 bouyer
1139 1.19.2.1 bouyer *flags |= AHC_INT50_SPEEDFLEX;
1140 1.19.2.1 bouyer error = ahc_aic7880_setup(pa, channel, chip, features, flags);
1141 1.19.2.1 bouyer return (0);
1142 1.19.2.1 bouyer }
1143 1.19.2.1 bouyer
1144 1.19.2.1 bouyer static int
1145 1.19.2.1 bouyer ahc_aha394XU_setup(struct pci_attach_args *pa, char *channel,
1146 1.19.2.1 bouyer ahc_chip *chip, ahc_feature *features, ahc_flag *flags)
1147 1.19.2.1 bouyer {
1148 1.19.2.1 bouyer int error;
1149 1.19.2.1 bouyer
1150 1.19.2.1 bouyer error = ahc_aic7880_setup(pa, channel, chip, features, flags);
1151 1.19.2.1 bouyer if (error == 0)
1152 1.19.2.1 bouyer error = ahc_aha394XX_setup(pa, channel, chip, features, flags);
1153 1.19.2.1 bouyer return (error);
1154 1.19.2.1 bouyer }
1155 1.19.2.1 bouyer
1156 1.19.2.1 bouyer static int
1157 1.19.2.1 bouyer ahc_aha398XU_setup(struct pci_attach_args *pa, char *channel,
1158 1.19.2.1 bouyer ahc_chip *chip, ahc_feature *features, ahc_flag *flags)
1159 1.19.2.1 bouyer {
1160 1.19.2.1 bouyer int error;
1161 1.19.2.1 bouyer
1162 1.19.2.1 bouyer error = ahc_aic7880_setup(pa, channel, chip, features, flags);
1163 1.19.2.1 bouyer if (error == 0)
1164 1.19.2.1 bouyer error = ahc_aha398XX_setup(pa, channel, chip, features, flags);
1165 1.19.2.1 bouyer return (error);
1166 1.19.2.1 bouyer }
1167 1.19.2.1 bouyer
1168 1.19.2.1 bouyer static int
1169 1.19.2.1 bouyer ahc_aic7890_setup(struct pci_attach_args *pa, char *channel,
1170 1.19.2.1 bouyer ahc_chip *chip, ahc_feature *features, ahc_flag *flags)
1171 1.19.2.1 bouyer {
1172 1.19.2.1 bouyer *channel = 'A';
1173 1.19.2.1 bouyer *chip = AHC_AIC7890;
1174 1.19.2.1 bouyer *features = AHC_AIC7890_FE;
1175 1.19.2.1 bouyer *flags |= AHC_NEWEEPROM_FMT;
1176 1.19.2.1 bouyer return (0);
1177 1.19.2.1 bouyer }
1178 1.19.2.1 bouyer
1179 1.19.2.1 bouyer static int
1180 1.19.2.1 bouyer ahc_aic7892_setup(struct pci_attach_args *pa, char *channel,
1181 1.19.2.1 bouyer ahc_chip *chip, ahc_feature *features, ahc_flag *flags)
1182 1.19.2.1 bouyer {
1183 1.19.2.1 bouyer *channel = 'A';
1184 1.19.2.1 bouyer *chip = AHC_AIC7892;
1185 1.19.2.1 bouyer *features = AHC_AIC7892_FE;
1186 1.19.2.1 bouyer *flags |= AHC_NEWEEPROM_FMT;
1187 1.19.2.1 bouyer return (0);
1188 1.19.2.1 bouyer }
1189 1.19.2.1 bouyer
1190 1.19.2.1 bouyer static int
1191 1.19.2.1 bouyer ahc_aic7895_setup(struct pci_attach_args *pa, char *channel,
1192 1.19.2.1 bouyer ahc_chip *chip, ahc_feature *features, ahc_flag *flags)
1193 1.19.2.1 bouyer {
1194 1.19.2.1 bouyer pcireg_t devconfig;
1195 1.19.2.1 bouyer
1196 1.19.2.1 bouyer *channel = pa->pa_function == 1 ? 'B' : 'A';
1197 1.19.2.1 bouyer *chip = AHC_AIC7895;
1198 1.19.2.1 bouyer /* The 'C' revision of the aic7895 has a few additional features */
1199 1.19.2.1 bouyer if (PCI_REVISION(pa->pa_class) >= 4)
1200 1.19.2.1 bouyer *features = AHC_AIC7895C_FE;
1201 1.19.2.1 bouyer else
1202 1.19.2.1 bouyer *features = AHC_AIC7895_FE;
1203 1.19.2.1 bouyer *flags |= AHC_NEWEEPROM_FMT;
1204 1.19.2.1 bouyer devconfig = pci_conf_read(pa->pa_pc, pa->pa_tag, DEVCONFIG);
1205 1.19.2.1 bouyer devconfig &= ~SCBSIZE32;
1206 1.19.2.1 bouyer pci_conf_write(pa->pa_pc, pa->pa_tag, DEVCONFIG, devconfig);
1207 1.19.2.1 bouyer return (0);
1208 1.19.2.1 bouyer }
1209 1.19.2.1 bouyer
1210 1.19.2.1 bouyer static int
1211 1.19.2.1 bouyer ahc_aic7896_setup(struct pci_attach_args *pa, char *channel,
1212 1.19.2.1 bouyer ahc_chip *chip, ahc_feature *features, ahc_flag *flags)
1213 1.19.2.1 bouyer {
1214 1.19.2.1 bouyer *channel = pa->pa_function == 1 ? 'B' : 'A';
1215 1.19.2.1 bouyer *chip = AHC_AIC7896;
1216 1.19.2.1 bouyer *features = AHC_AIC7896_FE;
1217 1.19.2.1 bouyer *flags |= AHC_NEWEEPROM_FMT;
1218 1.19.2.1 bouyer return (0);
1219 1.19.2.1 bouyer }
1220 1.19.2.1 bouyer
1221 1.19.2.1 bouyer static int
1222 1.19.2.1 bouyer ahc_aic7899_setup(struct pci_attach_args *pa, char *channel,
1223 1.19.2.1 bouyer ahc_chip *chip, ahc_feature *features, ahc_flag *flags)
1224 1.19.2.1 bouyer {
1225 1.19.2.1 bouyer *channel = pa->pa_function == 1 ? 'B' : 'A';
1226 1.19.2.1 bouyer *chip = AHC_AIC7899;
1227 1.19.2.1 bouyer *features = AHC_AIC7899_FE;
1228 1.19.2.1 bouyer *flags |= AHC_NEWEEPROM_FMT;
1229 1.19.2.1 bouyer return (0);
1230 1.19.2.1 bouyer }
1231 1.19.2.1 bouyer
1232 1.19.2.1 bouyer static int
1233 1.19.2.1 bouyer ahc_raid_setup(struct pci_attach_args *pa, char *channel,
1234 1.19.2.1 bouyer ahc_chip *chip, ahc_feature *features, ahc_flag *flags)
1235 1.19.2.1 bouyer {
1236 1.19.2.1 bouyer printf(": RAID functionality unsupported\n");
1237 1.19.2.1 bouyer return (ENXIO);
1238 1.19.2.1 bouyer }
1239 1.19.2.1 bouyer
1240 1.19.2.1 bouyer static int
1241 1.19.2.1 bouyer ahc_aha394XX_setup(struct pci_attach_args *pa, char *channel,
1242 1.19.2.1 bouyer ahc_chip *chip, ahc_feature *features, ahc_flag *flags)
1243 1.19.2.1 bouyer {
1244 1.19.2.1 bouyer switch (pa->pa_device) {
1245 1.19.2.1 bouyer case AHC_394X_SLOT_CHANNEL_A:
1246 1.19.2.1 bouyer *channel = 'A';
1247 1.19.2.1 bouyer break;
1248 1.19.2.1 bouyer case AHC_394X_SLOT_CHANNEL_B:
1249 1.19.2.1 bouyer *channel = 'B';
1250 1.19.2.1 bouyer break;
1251 1.19.2.1 bouyer default:
1252 1.19.2.1 bouyer printf("adapter at unexpected slot %d\n"
1253 1.19.2.1 bouyer "unable to map to a channel\n",
1254 1.19.2.1 bouyer pa->pa_device);
1255 1.19.2.1 bouyer *channel = 'A';
1256 1.19.2.1 bouyer }
1257 1.19.2.1 bouyer return (0);
1258 1.19.2.1 bouyer }
1259 1.19.2.1 bouyer
1260 1.19.2.1 bouyer static int
1261 1.19.2.1 bouyer ahc_aha398XX_setup(struct pci_attach_args *pa, char *channel,
1262 1.19.2.1 bouyer ahc_chip *chip, ahc_feature *features, ahc_flag *flags)
1263 1.19.2.1 bouyer {
1264 1.19.2.1 bouyer switch (pa->pa_device) {
1265 1.19.2.1 bouyer case AHC_398X_SLOT_CHANNEL_A:
1266 1.19.2.1 bouyer *channel = 'A';
1267 1.19.2.1 bouyer break;
1268 1.19.2.1 bouyer case AHC_398X_SLOT_CHANNEL_B:
1269 1.19.2.1 bouyer *channel = 'B';
1270 1.19.2.1 bouyer break;
1271 1.19.2.1 bouyer case AHC_398X_SLOT_CHANNEL_C:
1272 1.19.2.1 bouyer *channel = 'C';
1273 1.19.2.1 bouyer break;
1274 1.19.2.1 bouyer default:
1275 1.19.2.1 bouyer printf("adapter at unexpected slot %d\n"
1276 1.19.2.1 bouyer "unable to map to a channel\n",
1277 1.19.2.1 bouyer pa->pa_device);
1278 1.19.2.1 bouyer *channel = 'A';
1279 1.19.2.1 bouyer }
1280 1.19.2.1 bouyer *flags |= AHC_LARGE_SEEPROM;
1281 1.19.2.1 bouyer return (0);
1282 1.19.2.1 bouyer }
1283