xref: /freebsd/sys/dev/aac/aac_pci.c (revision ba3c1f5972d7b90feb6e6da47905ff2757e0fe57)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2000 Michael Smith
5  * Copyright (c) 2001 Scott Long
6  * Copyright (c) 2000 BSDi
7  * Copyright (c) 2001 Adaptec, Inc.
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  */
31 
32 #include <sys/cdefs.h>
33 __FBSDID("$FreeBSD$");
34 
35 /*
36  * PCI bus interface and resource allocation.
37  */
38 
39 #include "opt_aac.h"
40 
41 #include <sys/param.h>
42 #include <sys/systm.h>
43 #include <sys/kernel.h>
44 #include <sys/module.h>
45 
46 #include <sys/bio.h>
47 #include <sys/bus.h>
48 #include <sys/conf.h>
49 #include <sys/disk.h>
50 
51 #include <machine/bus.h>
52 #include <machine/resource.h>
53 #include <sys/rman.h>
54 
55 #include <dev/pci/pcireg.h>
56 #include <dev/pci/pcivar.h>
57 
58 #include <dev/aac/aacreg.h>
59 #include <sys/aac_ioctl.h>
60 #include <dev/aac/aacvar.h>
61 
62 static int	aac_pci_probe(device_t dev);
63 static int	aac_pci_attach(device_t dev);
64 
65 static int aac_enable_msi = 1;
66 SYSCTL_INT(_hw_aac, OID_AUTO, enable_msi, CTLFLAG_RDTUN, &aac_enable_msi, 0,
67     "Enable MSI interrupts");
68 
69 static device_method_t aac_methods[] = {
70 	/* Device interface */
71 	DEVMETHOD(device_probe,		aac_pci_probe),
72 	DEVMETHOD(device_attach,	aac_pci_attach),
73 	DEVMETHOD(device_detach,	aac_detach),
74 	DEVMETHOD(device_suspend,	aac_suspend),
75 	DEVMETHOD(device_resume,	aac_resume),
76 
77 	DEVMETHOD_END
78 };
79 
80 static driver_t aac_pci_driver = {
81 	"aac",
82 	aac_methods,
83 	sizeof(struct aac_softc)
84 };
85 
86 DRIVER_MODULE(aac, pci, aac_pci_driver, NULL, NULL);
87 MODULE_DEPEND(aac, pci, 1, 1, 1);
88 
89 static const struct aac_ident
90 {
91 	u_int16_t		vendor;
92 	u_int16_t		device;
93 	u_int16_t		subvendor;
94 	u_int16_t		subdevice;
95 	int			hwif;
96 	int			quirks;
97 	const char		*desc;
98 } aac_identifiers[] = {
99 	{0x1028, 0x0001, 0x1028, 0x0001, AAC_HWIF_I960RX, 0,
100 	"Dell PERC 2/Si"},
101 	{0x1028, 0x0002, 0x1028, 0x0002, AAC_HWIF_I960RX, 0,
102 	"Dell PERC 3/Di"},
103 	{0x1028, 0x0003, 0x1028, 0x0003, AAC_HWIF_I960RX, 0,
104 	"Dell PERC 3/Si"},
105 	{0x1028, 0x0004, 0x1028, 0x00d0, AAC_HWIF_I960RX, 0,
106 	"Dell PERC 3/Si"},
107 	{0x1028, 0x0002, 0x1028, 0x00d1, AAC_HWIF_I960RX, 0,
108 	"Dell PERC 3/Di"},
109 	{0x1028, 0x0002, 0x1028, 0x00d9, AAC_HWIF_I960RX, 0,
110 	"Dell PERC 3/Di"},
111 	{0x1028, 0x000a, 0x1028, 0x0106, AAC_HWIF_I960RX, 0,
112 	"Dell PERC 3/Di"},
113 	{0x1028, 0x000a, 0x1028, 0x011b, AAC_HWIF_I960RX, 0,
114 	"Dell PERC 3/Di"},
115 	{0x1028, 0x000a, 0x1028, 0x0121, AAC_HWIF_I960RX, 0,
116 	"Dell PERC 3/Di"},
117 	{0x1011, 0x0046, 0x9005, 0x0364, AAC_HWIF_STRONGARM, 0,
118 	"Adaptec AAC-364"},
119 	{0x1011, 0x0046, 0x9005, 0x0365, AAC_HWIF_STRONGARM,
120 	 AAC_FLAGS_BROKEN_MEMMAP, "Adaptec SCSI RAID 5400S"},
121 	{0x1011, 0x0046, 0x9005, 0x1364, AAC_HWIF_STRONGARM, AAC_FLAGS_PERC2QC,
122 	 "Dell PERC 2/QC"},
123 	{0x1011, 0x0046, 0x103c, 0x10c2, AAC_HWIF_STRONGARM, 0,
124 	 "HP NetRaid-4M"},
125 	{0x9005, 0x0285, 0x9005, 0x0285, AAC_HWIF_I960RX, AAC_FLAGS_NO4GB |
126 	 AAC_FLAGS_256FIBS, "Adaptec SCSI RAID 2200S"},
127 	{0x9005, 0x0285, 0x1028, 0x0287, AAC_HWIF_I960RX, AAC_FLAGS_NO4GB |
128 	 AAC_FLAGS_256FIBS, "Dell PERC 320/DC"},
129 	{0x9005, 0x0285, 0x9005, 0x0286, AAC_HWIF_I960RX, AAC_FLAGS_NO4GB |
130 	 AAC_FLAGS_256FIBS, "Adaptec SCSI RAID 2120S"},
131 	{0x9005, 0x0285, 0x9005, 0x0290, AAC_HWIF_I960RX, AAC_FLAGS_NO4GB,
132 	 "Adaptec SATA RAID 2410SA"},
133 	{0x9005, 0x0285, 0x1028, 0x0291, AAC_HWIF_I960RX, AAC_FLAGS_NO4GB,
134 	 "Dell CERC SATA RAID 2"},
135 	{0x9005, 0x0285, 0x9005, 0x0292, AAC_HWIF_I960RX, AAC_FLAGS_NO4GB,
136 	 "Adaptec SATA RAID 2810SA"},
137 	{0x9005, 0x0285, 0x9005, 0x0293, AAC_HWIF_I960RX, AAC_FLAGS_NO4GB,
138 	 "Adaptec SATA RAID 21610SA"},
139 	{0x9005, 0x0285, 0x103c, 0x3227, AAC_HWIF_I960RX, AAC_FLAGS_NO4GB,
140 	 "HP ML110 G2 (Adaptec 2610SA)"},
141 	{0x9005, 0x0286, 0x9005, 0x028c, AAC_HWIF_RKT, AAC_FLAGS_NOMSI,
142 	 "Adaptec SCSI RAID 2230S"},
143 	{0x9005, 0x0286, 0x9005, 0x028d, AAC_HWIF_RKT, 0,
144 	 "Adaptec SCSI RAID 2130S"},
145 	{0x9005, 0x0285, 0x9005, 0x0287, AAC_HWIF_I960RX, AAC_FLAGS_NO4GB |
146 	 AAC_FLAGS_256FIBS, "Adaptec SCSI RAID 2200S"},
147 	{0x9005, 0x0285, 0x17aa, 0x0286, AAC_HWIF_I960RX, AAC_FLAGS_NO4GB |
148 	 AAC_FLAGS_256FIBS, "Legend S220"},
149 	{0x9005, 0x0285, 0x17aa, 0x0287, AAC_HWIF_I960RX, AAC_FLAGS_NO4GB |
150 	 AAC_FLAGS_256FIBS, "Legend S230"},
151 	{0x9005, 0x0285, 0x9005, 0x0288, AAC_HWIF_I960RX, 0,
152 	 "Adaptec SCSI RAID 3230S"},
153 	{0x9005, 0x0285, 0x9005, 0x0289, AAC_HWIF_I960RX, 0,
154 	 "Adaptec SCSI RAID 3240S"},
155 	{0x9005, 0x0285, 0x9005, 0x028a, AAC_HWIF_I960RX, 0,
156 	 "Adaptec SCSI RAID 2020ZCR"},
157 	{0x9005, 0x0285, 0x9005, 0x028b, AAC_HWIF_I960RX, 0,
158 	 "Adaptec SCSI RAID 2025ZCR"},
159 	{0x9005, 0x0286, 0x9005, 0x029b, AAC_HWIF_RKT, AAC_FLAGS_NOMSI,
160 	 "Adaptec SATA RAID 2820SA"},
161 	{0x9005, 0x0286, 0x9005, 0x029c, AAC_HWIF_RKT, 0,
162 	 "Adaptec SATA RAID 2620SA"},
163 	{0x9005, 0x0286, 0x9005, 0x029d, AAC_HWIF_RKT, 0,
164 	 "Adaptec SATA RAID 2420SA"},
165 	{0x9005, 0x0286, 0x9005, 0x029e, AAC_HWIF_RKT, 0,
166 	 "ICP ICP9024RO SCSI RAID"},
167 	{0x9005, 0x0286, 0x9005, 0x029f, AAC_HWIF_RKT, 0,
168 	 "ICP ICP9014RO SCSI RAID"},
169 	{0x9005, 0x0285, 0x9005, 0x0294, AAC_HWIF_I960RX, 0,
170 	 "Adaptec SATA RAID 2026ZCR"},
171 	{0x9005, 0x0285, 0x9005, 0x0296, AAC_HWIF_I960RX, 0,
172 	 "Adaptec SCSI RAID 2240S"},
173 	{0x9005, 0x0285, 0x9005, 0x0297, AAC_HWIF_I960RX, 0,
174 	 "Adaptec SAS RAID 4005SAS"},
175 	{0x9005, 0x0285, 0x1014, 0x02f2, AAC_HWIF_I960RX, 0,
176 	 "IBM ServeRAID 8i"},
177 	{0x9005, 0x0285, 0x1014, 0x0312, AAC_HWIF_I960RX, 0,
178 	 "IBM ServeRAID 8i"},
179 	{0x9005, 0x0285, 0x9005, 0x0298, AAC_HWIF_I960RX, 0,
180 	 "Adaptec RAID 4000"},
181 	{0x9005, 0x0285, 0x9005, 0x0299, AAC_HWIF_I960RX, 0,
182 	 "Adaptec SAS RAID 4800SAS"},
183 	{0x9005, 0x0285, 0x9005, 0x029a, AAC_HWIF_I960RX, 0,
184 	 "Adaptec SAS RAID 4805SAS"},
185 	{0x9005, 0x0285, 0x9005, 0x028e, AAC_HWIF_I960RX, 0,
186 	 "Adaptec SATA RAID 2020SA ZCR"},
187 	{0x9005, 0x0285, 0x9005, 0x028f, AAC_HWIF_I960RX, 0,
188 	 "Adaptec SATA RAID 2025SA ZCR"},
189 	{0x9005, 0x0285, 0x9005, 0x02a4, AAC_HWIF_I960RX, 0,
190 	 "ICP ICP9085LI SAS RAID"},
191 	{0x9005, 0x0285, 0x9005, 0x02a5, AAC_HWIF_I960RX, 0,
192 	 "ICP ICP5085BR SAS RAID"},
193 	{0x9005, 0x0286, 0x9005, 0x02a0, AAC_HWIF_RKT, 0,
194 	 "ICP ICP9047MA SATA RAID"},
195 	{0x9005, 0x0286, 0x9005, 0x02a1, AAC_HWIF_RKT, 0,
196 	 "ICP ICP9087MA SATA RAID"},
197 	{0x9005, 0x0286, 0x9005, 0x02a6, AAC_HWIF_RKT, 0,
198 	 "ICP9067MA SATA RAID"},
199 	{0x9005, 0x0285, 0x9005, 0x02b5, AAC_HWIF_I960RX, 0,
200 	 "Adaptec RAID 5445"},
201 	{0x9005, 0x0285, 0x9005, 0x02b6, AAC_HWIF_I960RX, 0,
202 	 "Adaptec RAID 5805"},
203 	{0x9005, 0x0285, 0x9005, 0x02b7, AAC_HWIF_I960RX, 0,
204 	 "Adaptec RAID 5085"},
205 	{0x9005, 0x0285, 0x9005, 0x02b8, AAC_HWIF_I960RX, 0,
206 	 "ICP RAID ICP5445SL"},
207 	{0x9005, 0x0285, 0x9005, 0x02b9, AAC_HWIF_I960RX, 0,
208 	 "ICP RAID ICP5085SL"},
209 	{0x9005, 0x0285, 0x9005, 0x02ba, AAC_HWIF_I960RX, 0,
210 	 "ICP RAID ICP5805SL"},
211 	{0x9005, 0x0285, 0x9005, 0x02bb, AAC_HWIF_I960RX, 0,
212 	 "Adaptec RAID 3405"},
213 	{0x9005, 0x0285, 0x9005, 0x02bc, AAC_HWIF_I960RX, 0,
214 	 "Adaptec RAID 3805"},
215 	{0x9005, 0x0285, 0x9005, 0x02bd, AAC_HWIF_I960RX, 0,
216 	 "Adaptec RAID 31205"},
217 	{0x9005, 0x0285, 0x9005, 0x02be, AAC_HWIF_I960RX, 0,
218 	 "Adaptec RAID 31605"},
219 	{0x9005, 0x0285, 0x9005, 0x02bf, AAC_HWIF_I960RX, 0,
220 	 "ICP RAID ICP5045BL"},
221 	{0x9005, 0x0285, 0x9005, 0x02c0, AAC_HWIF_I960RX, 0,
222 	 "ICP RAID ICP5085BL"},
223 	{0x9005, 0x0285, 0x9005, 0x02c1, AAC_HWIF_I960RX, 0,
224 	 "ICP RAID ICP5125BR"},
225 	{0x9005, 0x0285, 0x9005, 0x02c2, AAC_HWIF_I960RX, 0,
226 	 "ICP RAID ICP5165BR"},
227 	{0x9005, 0x0285, 0x9005, 0x02c3, AAC_HWIF_I960RX, 0,
228 	 "Adaptec RAID 51205"},
229 	{0x9005, 0x0285, 0x9005, 0x02c4, AAC_HWIF_I960RX, 0,
230 	 "Adaptec RAID 51605"},
231 	{0x9005, 0x0285, 0x9005, 0x02c5, AAC_HWIF_I960RX, 0,
232 	 "ICP RAID ICP5125SL"},
233 	{0x9005, 0x0285, 0x9005, 0x02c6, AAC_HWIF_I960RX, 0,
234 	 "ICP RAID ICP5165SL"},
235 	{0x9005, 0x0285, 0x9005, 0x02c7, AAC_HWIF_I960RX, 0,
236 	 "Adaptec RAID 3085"},
237 	{0x9005, 0x0285, 0x9005, 0x02c8, AAC_HWIF_I960RX, 0,
238 	 "ICP RAID ICP5805BL"},
239 	{0x9005, 0x0285, 0x9005, 0x02ce, AAC_HWIF_I960RX, 0,
240 	 "Adaptec RAID 51245"},
241 	{0x9005, 0x0285, 0x9005, 0x02cf, AAC_HWIF_I960RX, 0,
242 	 "Adaptec RAID 51645"},
243 	{0x9005, 0x0285, 0x9005, 0x02d0, AAC_HWIF_I960RX, 0,
244 	 "Adaptec RAID 52445"},
245 	{0x9005, 0x0285, 0x9005, 0x02d1, AAC_HWIF_I960RX, 0,
246 	 "Adaptec RAID 5405"},
247 	{0x9005, 0x0285, 0x9005, 0x02d4, AAC_HWIF_I960RX, 0,
248 	 "Adaptec RAID 2045"},
249 	{0x9005, 0x0285, 0x9005, 0x02d5, AAC_HWIF_I960RX, 0,
250 	 "Adaptec RAID 2405"},
251 	{0x9005, 0x0285, 0x9005, 0x02d6, AAC_HWIF_I960RX, 0,
252 	 "Adaptec RAID 2445"},
253 	{0x9005, 0x0285, 0x9005, 0x02d7, AAC_HWIF_I960RX, 0,
254 	 "Adaptec RAID 2805"},
255 	{0x9005, 0x0286, 0x1014, 0x9580, AAC_HWIF_RKT, 0,
256 	 "IBM ServeRAID-8k"},
257 	{0x9005, 0x0285, 0x1014, 0x034d, AAC_HWIF_I960RX, 0,
258 	 "IBM ServeRAID 8s"},
259 	{0x9005, 0x0285, 0x108e, 0x7aac, AAC_HWIF_I960RX, 0,
260 	 "Sun STK RAID REM"},
261 	{0x9005, 0x0285, 0x108e, 0x7aae, AAC_HWIF_I960RX, 0,
262 	 "Sun STK RAID EM"},
263 	{0x9005, 0x0285, 0x108e, 0x286, AAC_HWIF_I960RX, 0,
264 	 "SG-XPCIESAS-R-IN"},
265 	{0x9005, 0x0285, 0x108e, 0x287, AAC_HWIF_I960RX, 0,
266 	 "SG-XPCIESAS-R-EX"},
267 	{0x9005, 0x0285, 0x15d9, 0x2b5, AAC_HWIF_I960RX, 0,
268 	 "AOC-USAS-S4i"},
269 	{0x9005, 0x0285, 0x15d9, 0x2b6, AAC_HWIF_I960RX, 0,
270 	 "AOC-USAS-S8i"},
271 	{0x9005, 0x0285, 0x15d9, 0x2c9, AAC_HWIF_I960RX, 0,
272 	 "AOC-USAS-S4iR"},
273 	{0x9005, 0x0285, 0x15d9, 0x2ca, AAC_HWIF_I960RX, 0,
274 	 "AOC-USAS-S8iR"},
275 	{0x9005, 0x0285, 0x15d9, 0x2d2, AAC_HWIF_I960RX, 0,
276 	 "AOC-USAS-S8i-LP"},
277 	{0x9005, 0x0285, 0x15d9, 0x2d3, AAC_HWIF_I960RX, 0,
278 	 "AOC-USAS-S8iR-LP"},
279 	{0, 0, 0, 0, 0, 0, 0}
280 };
281 
282 static const struct aac_ident
283 aac_family_identifiers[] = {
284 	{0x9005, 0x0285, 0, 0, AAC_HWIF_I960RX, 0,
285 	 "Adaptec RAID Controller"},
286 	{0x9005, 0x0286, 0, 0, AAC_HWIF_RKT, 0,
287 	 "Adaptec RAID Controller"},
288 	{0, 0, 0, 0, 0, 0, 0}
289 };
290 
291 static const struct aac_ident *
292 aac_find_ident(device_t dev)
293 {
294 	const struct aac_ident *m;
295 	u_int16_t vendid, devid, sub_vendid, sub_devid;
296 
297 	vendid = pci_get_vendor(dev);
298 	devid = pci_get_device(dev);
299 	sub_vendid = pci_get_subvendor(dev);
300 	sub_devid = pci_get_subdevice(dev);
301 
302 	for (m = aac_identifiers; m->vendor != 0; m++) {
303 		if ((m->vendor == vendid) && (m->device == devid) &&
304 		    (m->subvendor == sub_vendid) &&
305 		    (m->subdevice == sub_devid))
306 			return (m);
307 	}
308 
309 	for (m = aac_family_identifiers; m->vendor != 0; m++) {
310 		if ((m->vendor == vendid) && (m->device == devid))
311 			return (m);
312 	}
313 	return (NULL);
314 }
315 
316 /*
317  * Determine whether this is one of our supported adapters.
318  */
319 static int
320 aac_pci_probe(device_t dev)
321 {
322 	const struct aac_ident *id;
323 
324 	fwprintf(NULL, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
325 
326 	if ((id = aac_find_ident(dev)) != NULL) {
327 		device_set_desc(dev, id->desc);
328 		return(BUS_PROBE_DEFAULT);
329 	}
330 	return(ENXIO);
331 }
332 
333 /*
334  * Allocate resources for our device, set up the bus interface.
335  */
336 static int
337 aac_pci_attach(device_t dev)
338 {
339 	struct aac_softc *sc;
340 	const struct aac_ident *id;
341 	int count, error, rid;
342 
343 	fwprintf(NULL, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
344 
345 	/*
346 	 * Initialise softc.
347 	 */
348 	sc = device_get_softc(dev);
349 	sc->aac_dev = dev;
350 
351 	/* assume failure is 'not configured' */
352 	error = ENXIO;
353 
354 	/*
355 	 * Verify that the adapter is correctly set up in PCI space.
356 	 */
357 	pci_enable_busmaster(dev);
358 	if (!(pci_read_config(dev, PCIR_COMMAND, 2) & PCIM_CMD_BUSMASTEREN)) {
359 		device_printf(dev, "can't enable bus-master feature\n");
360 		goto out;
361 	}
362 
363 	/*
364 	 * Detect the hardware interface version, set up the bus interface
365 	 * indirection.
366 	 */
367 	id = aac_find_ident(dev);
368 	sc->aac_hwif = id->hwif;
369 	switch(sc->aac_hwif) {
370 	case AAC_HWIF_I960RX:
371 	case AAC_HWIF_NARK:
372 		fwprintf(sc, HBA_FLAGS_DBG_INIT_B,
373 		    "set hardware up for i960Rx/NARK");
374 		sc->aac_if = &aac_rx_interface;
375 		break;
376 	case AAC_HWIF_STRONGARM:
377 		fwprintf(sc, HBA_FLAGS_DBG_INIT_B,
378 		    "set hardware up for StrongARM");
379 		sc->aac_if = &aac_sa_interface;
380 		break;
381 	case AAC_HWIF_RKT:
382 		fwprintf(sc, HBA_FLAGS_DBG_INIT_B,
383 		    "set hardware up for Rocket/MIPS");
384 		sc->aac_if = &aac_rkt_interface;
385 		break;
386 	default:
387 		sc->aac_hwif = AAC_HWIF_UNKNOWN;
388 		device_printf(dev, "unknown hardware type\n");
389 		goto out;
390 	}
391 
392 	/* Set up quirks */
393 	sc->flags = id->quirks;
394 
395 	/*
396 	 * Allocate the PCI register window(s).
397 	 */
398 	rid = PCIR_BAR(0);
399 	if ((sc->aac_regs_res0 = bus_alloc_resource_any(dev,
400 	    SYS_RES_MEMORY, &rid, RF_ACTIVE)) == NULL) {
401 		device_printf(dev, "can't allocate register window 0\n");
402 		goto out;
403 	}
404 	sc->aac_btag0 = rman_get_bustag(sc->aac_regs_res0);
405 	sc->aac_bhandle0 = rman_get_bushandle(sc->aac_regs_res0);
406 
407 	if (sc->aac_hwif == AAC_HWIF_NARK) {
408 		rid = PCIR_BAR(1);
409 		if ((sc->aac_regs_res1 = bus_alloc_resource_any(dev,
410 		    SYS_RES_MEMORY, &rid, RF_ACTIVE)) == NULL) {
411 			device_printf(dev,
412 			    "can't allocate register window 1\n");
413 			goto out;
414 		}
415 		sc->aac_btag1 = rman_get_bustag(sc->aac_regs_res1);
416 		sc->aac_bhandle1 = rman_get_bushandle(sc->aac_regs_res1);
417 	} else {
418 		sc->aac_regs_res1 = sc->aac_regs_res0;
419 		sc->aac_btag1 = sc->aac_btag0;
420 		sc->aac_bhandle1 = sc->aac_bhandle0;
421 	}
422 
423 	/*
424 	 * Allocate the interrupt.
425 	 */
426 	rid = 0;
427 	if (aac_enable_msi != 0 && (sc->flags & AAC_FLAGS_NOMSI) == 0) {
428 		count = 1;
429 		if (pci_alloc_msi(dev, &count) == 0)
430 			rid = 1;
431 	}
432 	if ((sc->aac_irq = bus_alloc_resource_any(sc->aac_dev, SYS_RES_IRQ,
433 	    &rid, RF_ACTIVE | (rid != 0 ? 0 : RF_SHAREABLE))) == NULL) {
434 		device_printf(dev, "can't allocate interrupt\n");
435 		goto out;
436 	}
437 
438 	/*
439 	 * Allocate the parent bus DMA tag appropriate for our PCI interface.
440 	 *
441 	 * Note that some of these controllers are 64-bit capable.
442 	 */
443 	if (bus_dma_tag_create(bus_get_dma_tag(dev),	/* parent */
444 			       PAGE_SIZE,		/* algnmnt */
445 			       ((bus_size_t)((uint64_t)1 << 32)), /* boundary*/
446 			       BUS_SPACE_MAXADDR,	/* lowaddr */
447 			       BUS_SPACE_MAXADDR, 	/* highaddr */
448 			       NULL, NULL, 		/* filter, filterarg */
449 			       BUS_SPACE_MAXSIZE_32BIT,	/* maxsize */
450 			       BUS_SPACE_UNRESTRICTED,	/* nsegments */
451 			       BUS_SPACE_MAXSIZE_32BIT,	/* maxsegsize */
452 			       0,			/* flags */
453 			       NULL, NULL,		/* No locking needed */
454 			       &sc->aac_parent_dmat)) {
455 		device_printf(dev, "can't allocate parent DMA tag\n");
456 		goto out;
457 	}
458 
459 	/*
460 	 * Do bus-independent initialisation.
461 	 */
462 	error = aac_attach(sc);
463 
464 out:
465 	if (error)
466 		aac_free(sc);
467 	return(error);
468 }
469 
470 /*
471  * Do nothing driver that will attach to the SCSI channels of a Dell PERC
472  * controller.  This is needed to keep the power management subsystem from
473  * trying to power down these devices.
474  */
475 static int aacch_probe(device_t dev);
476 static int aacch_attach(device_t dev);
477 static int aacch_detach(device_t dev);
478 
479 static device_method_t aacch_methods[] = {
480 	/* Device interface */
481 	DEVMETHOD(device_probe,		aacch_probe),
482 	DEVMETHOD(device_attach,	aacch_attach),
483 	DEVMETHOD(device_detach,	aacch_detach),
484 	DEVMETHOD_END
485 };
486 
487 static driver_t aacch_driver = {
488 	"aacch",
489 	aacch_methods,
490 	1	/* no softc */
491 };
492 
493 DRIVER_MODULE(aacch, pci, aacch_driver, NULL, NULL);
494 MODULE_PNP_INFO("U16:vendor;U16:device;", pci, aacch,
495     aac_identifiers, nitems(aac_identifiers) - 1);
496 
497 static int
498 aacch_probe(device_t dev)
499 {
500 
501 	if ((pci_get_vendor(dev) != 0x9005) ||
502 	    (pci_get_device(dev) != 0x00c5))
503 		return (ENXIO);
504 
505 	device_set_desc(dev, "AAC RAID Channel");
506 	return (-10);
507 }
508 
509 static int
510 aacch_attach(device_t dev __unused)
511 {
512 
513 	return (0);
514 }
515 
516 static int
517 aacch_detach(device_t dev __unused)
518 {
519 
520 	return (0);
521 }
522