xref: /freebsd/sys/dev/aac/aac_pci.c (revision 190cef3d52236565eb22e18b33e9e865ec634aa3)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
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 static devclass_t	aac_devclass;
87 
88 DRIVER_MODULE(aac, pci, aac_pci_driver, aac_devclass, NULL, NULL);
89 MODULE_DEPEND(aac, pci, 1, 1, 1);
90 
91 static const struct aac_ident
92 {
93 	u_int16_t		vendor;
94 	u_int16_t		device;
95 	u_int16_t		subvendor;
96 	u_int16_t		subdevice;
97 	int			hwif;
98 	int			quirks;
99 	const char		*desc;
100 } aac_identifiers[] = {
101 	{0x1028, 0x0001, 0x1028, 0x0001, AAC_HWIF_I960RX, 0,
102 	"Dell PERC 2/Si"},
103 	{0x1028, 0x0002, 0x1028, 0x0002, AAC_HWIF_I960RX, 0,
104 	"Dell PERC 3/Di"},
105 	{0x1028, 0x0003, 0x1028, 0x0003, AAC_HWIF_I960RX, 0,
106 	"Dell PERC 3/Si"},
107 	{0x1028, 0x0004, 0x1028, 0x00d0, AAC_HWIF_I960RX, 0,
108 	"Dell PERC 3/Si"},
109 	{0x1028, 0x0002, 0x1028, 0x00d1, AAC_HWIF_I960RX, 0,
110 	"Dell PERC 3/Di"},
111 	{0x1028, 0x0002, 0x1028, 0x00d9, AAC_HWIF_I960RX, 0,
112 	"Dell PERC 3/Di"},
113 	{0x1028, 0x000a, 0x1028, 0x0106, AAC_HWIF_I960RX, 0,
114 	"Dell PERC 3/Di"},
115 	{0x1028, 0x000a, 0x1028, 0x011b, AAC_HWIF_I960RX, 0,
116 	"Dell PERC 3/Di"},
117 	{0x1028, 0x000a, 0x1028, 0x0121, AAC_HWIF_I960RX, 0,
118 	"Dell PERC 3/Di"},
119 	{0x1011, 0x0046, 0x9005, 0x0364, AAC_HWIF_STRONGARM, 0,
120 	"Adaptec AAC-364"},
121 	{0x1011, 0x0046, 0x9005, 0x0365, AAC_HWIF_STRONGARM,
122 	 AAC_FLAGS_BROKEN_MEMMAP, "Adaptec SCSI RAID 5400S"},
123 	{0x1011, 0x0046, 0x9005, 0x1364, AAC_HWIF_STRONGARM, AAC_FLAGS_PERC2QC,
124 	 "Dell PERC 2/QC"},
125 	{0x1011, 0x0046, 0x103c, 0x10c2, AAC_HWIF_STRONGARM, 0,
126 	 "HP NetRaid-4M"},
127 	{0x9005, 0x0285, 0x9005, 0x0285, AAC_HWIF_I960RX, AAC_FLAGS_NO4GB |
128 	 AAC_FLAGS_256FIBS, "Adaptec SCSI RAID 2200S"},
129 	{0x9005, 0x0285, 0x1028, 0x0287, AAC_HWIF_I960RX, AAC_FLAGS_NO4GB |
130 	 AAC_FLAGS_256FIBS, "Dell PERC 320/DC"},
131 	{0x9005, 0x0285, 0x9005, 0x0286, AAC_HWIF_I960RX, AAC_FLAGS_NO4GB |
132 	 AAC_FLAGS_256FIBS, "Adaptec SCSI RAID 2120S"},
133 	{0x9005, 0x0285, 0x9005, 0x0290, AAC_HWIF_I960RX, AAC_FLAGS_NO4GB,
134 	 "Adaptec SATA RAID 2410SA"},
135 	{0x9005, 0x0285, 0x1028, 0x0291, AAC_HWIF_I960RX, AAC_FLAGS_NO4GB,
136 	 "Dell CERC SATA RAID 2"},
137 	{0x9005, 0x0285, 0x9005, 0x0292, AAC_HWIF_I960RX, AAC_FLAGS_NO4GB,
138 	 "Adaptec SATA RAID 2810SA"},
139 	{0x9005, 0x0285, 0x9005, 0x0293, AAC_HWIF_I960RX, AAC_FLAGS_NO4GB,
140 	 "Adaptec SATA RAID 21610SA"},
141 	{0x9005, 0x0285, 0x103c, 0x3227, AAC_HWIF_I960RX, AAC_FLAGS_NO4GB,
142 	 "HP ML110 G2 (Adaptec 2610SA)"},
143 	{0x9005, 0x0286, 0x9005, 0x028c, AAC_HWIF_RKT, AAC_FLAGS_NOMSI,
144 	 "Adaptec SCSI RAID 2230S"},
145 	{0x9005, 0x0286, 0x9005, 0x028d, AAC_HWIF_RKT, 0,
146 	 "Adaptec SCSI RAID 2130S"},
147 	{0x9005, 0x0285, 0x9005, 0x0287, AAC_HWIF_I960RX, AAC_FLAGS_NO4GB |
148 	 AAC_FLAGS_256FIBS, "Adaptec SCSI RAID 2200S"},
149 	{0x9005, 0x0285, 0x17aa, 0x0286, AAC_HWIF_I960RX, AAC_FLAGS_NO4GB |
150 	 AAC_FLAGS_256FIBS, "Legend S220"},
151 	{0x9005, 0x0285, 0x17aa, 0x0287, AAC_HWIF_I960RX, AAC_FLAGS_NO4GB |
152 	 AAC_FLAGS_256FIBS, "Legend S230"},
153 	{0x9005, 0x0285, 0x9005, 0x0288, AAC_HWIF_I960RX, 0,
154 	 "Adaptec SCSI RAID 3230S"},
155 	{0x9005, 0x0285, 0x9005, 0x0289, AAC_HWIF_I960RX, 0,
156 	 "Adaptec SCSI RAID 3240S"},
157 	{0x9005, 0x0285, 0x9005, 0x028a, AAC_HWIF_I960RX, 0,
158 	 "Adaptec SCSI RAID 2020ZCR"},
159 	{0x9005, 0x0285, 0x9005, 0x028b, AAC_HWIF_I960RX, 0,
160 	 "Adaptec SCSI RAID 2025ZCR"},
161 	{0x9005, 0x0286, 0x9005, 0x029b, AAC_HWIF_RKT, AAC_FLAGS_NOMSI,
162 	 "Adaptec SATA RAID 2820SA"},
163 	{0x9005, 0x0286, 0x9005, 0x029c, AAC_HWIF_RKT, 0,
164 	 "Adaptec SATA RAID 2620SA"},
165 	{0x9005, 0x0286, 0x9005, 0x029d, AAC_HWIF_RKT, 0,
166 	 "Adaptec SATA RAID 2420SA"},
167 	{0x9005, 0x0286, 0x9005, 0x029e, AAC_HWIF_RKT, 0,
168 	 "ICP ICP9024RO SCSI RAID"},
169 	{0x9005, 0x0286, 0x9005, 0x029f, AAC_HWIF_RKT, 0,
170 	 "ICP ICP9014RO SCSI RAID"},
171 	{0x9005, 0x0285, 0x9005, 0x0294, AAC_HWIF_I960RX, 0,
172 	 "Adaptec SATA RAID 2026ZCR"},
173 	{0x9005, 0x0285, 0x9005, 0x0296, AAC_HWIF_I960RX, 0,
174 	 "Adaptec SCSI RAID 2240S"},
175 	{0x9005, 0x0285, 0x9005, 0x0297, AAC_HWIF_I960RX, 0,
176 	 "Adaptec SAS RAID 4005SAS"},
177 	{0x9005, 0x0285, 0x1014, 0x02f2, AAC_HWIF_I960RX, 0,
178 	 "IBM ServeRAID 8i"},
179 	{0x9005, 0x0285, 0x1014, 0x0312, AAC_HWIF_I960RX, 0,
180 	 "IBM ServeRAID 8i"},
181 	{0x9005, 0x0285, 0x9005, 0x0298, AAC_HWIF_I960RX, 0,
182 	 "Adaptec RAID 4000"},
183 	{0x9005, 0x0285, 0x9005, 0x0299, AAC_HWIF_I960RX, 0,
184 	 "Adaptec SAS RAID 4800SAS"},
185 	{0x9005, 0x0285, 0x9005, 0x029a, AAC_HWIF_I960RX, 0,
186 	 "Adaptec SAS RAID 4805SAS"},
187 	{0x9005, 0x0285, 0x9005, 0x028e, AAC_HWIF_I960RX, 0,
188 	 "Adaptec SATA RAID 2020SA ZCR"},
189 	{0x9005, 0x0285, 0x9005, 0x028f, AAC_HWIF_I960RX, 0,
190 	 "Adaptec SATA RAID 2025SA ZCR"},
191 	{0x9005, 0x0285, 0x9005, 0x02a4, AAC_HWIF_I960RX, 0,
192 	 "ICP ICP9085LI SAS RAID"},
193 	{0x9005, 0x0285, 0x9005, 0x02a5, AAC_HWIF_I960RX, 0,
194 	 "ICP ICP5085BR SAS RAID"},
195 	{0x9005, 0x0286, 0x9005, 0x02a0, AAC_HWIF_RKT, 0,
196 	 "ICP ICP9047MA SATA RAID"},
197 	{0x9005, 0x0286, 0x9005, 0x02a1, AAC_HWIF_RKT, 0,
198 	 "ICP ICP9087MA SATA RAID"},
199 	{0x9005, 0x0286, 0x9005, 0x02a6, AAC_HWIF_RKT, 0,
200 	 "ICP9067MA SATA RAID"},
201 	{0x9005, 0x0285, 0x9005, 0x02b5, AAC_HWIF_I960RX, 0,
202 	 "Adaptec RAID 5445"},
203 	{0x9005, 0x0285, 0x9005, 0x02b6, AAC_HWIF_I960RX, 0,
204 	 "Adaptec RAID 5805"},
205 	{0x9005, 0x0285, 0x9005, 0x02b7, AAC_HWIF_I960RX, 0,
206 	 "Adaptec RAID 5085"},
207 	{0x9005, 0x0285, 0x9005, 0x02b8, AAC_HWIF_I960RX, 0,
208 	 "ICP RAID ICP5445SL"},
209 	{0x9005, 0x0285, 0x9005, 0x02b9, AAC_HWIF_I960RX, 0,
210 	 "ICP RAID ICP5085SL"},
211 	{0x9005, 0x0285, 0x9005, 0x02ba, AAC_HWIF_I960RX, 0,
212 	 "ICP RAID ICP5805SL"},
213 	{0x9005, 0x0285, 0x9005, 0x02bb, AAC_HWIF_I960RX, 0,
214 	 "Adaptec RAID 3405"},
215 	{0x9005, 0x0285, 0x9005, 0x02bc, AAC_HWIF_I960RX, 0,
216 	 "Adaptec RAID 3805"},
217 	{0x9005, 0x0285, 0x9005, 0x02bd, AAC_HWIF_I960RX, 0,
218 	 "Adaptec RAID 31205"},
219 	{0x9005, 0x0285, 0x9005, 0x02be, AAC_HWIF_I960RX, 0,
220 	 "Adaptec RAID 31605"},
221 	{0x9005, 0x0285, 0x9005, 0x02bf, AAC_HWIF_I960RX, 0,
222 	 "ICP RAID ICP5045BL"},
223 	{0x9005, 0x0285, 0x9005, 0x02c0, AAC_HWIF_I960RX, 0,
224 	 "ICP RAID ICP5085BL"},
225 	{0x9005, 0x0285, 0x9005, 0x02c1, AAC_HWIF_I960RX, 0,
226 	 "ICP RAID ICP5125BR"},
227 	{0x9005, 0x0285, 0x9005, 0x02c2, AAC_HWIF_I960RX, 0,
228 	 "ICP RAID ICP5165BR"},
229 	{0x9005, 0x0285, 0x9005, 0x02c3, AAC_HWIF_I960RX, 0,
230 	 "Adaptec RAID 51205"},
231 	{0x9005, 0x0285, 0x9005, 0x02c4, AAC_HWIF_I960RX, 0,
232 	 "Adaptec RAID 51605"},
233 	{0x9005, 0x0285, 0x9005, 0x02c5, AAC_HWIF_I960RX, 0,
234 	 "ICP RAID ICP5125SL"},
235 	{0x9005, 0x0285, 0x9005, 0x02c6, AAC_HWIF_I960RX, 0,
236 	 "ICP RAID ICP5165SL"},
237 	{0x9005, 0x0285, 0x9005, 0x02c7, AAC_HWIF_I960RX, 0,
238 	 "Adaptec RAID 3085"},
239 	{0x9005, 0x0285, 0x9005, 0x02c8, AAC_HWIF_I960RX, 0,
240 	 "ICP RAID ICP5805BL"},
241 	{0x9005, 0x0285, 0x9005, 0x02ce, AAC_HWIF_I960RX, 0,
242 	 "Adaptec RAID 51245"},
243 	{0x9005, 0x0285, 0x9005, 0x02cf, AAC_HWIF_I960RX, 0,
244 	 "Adaptec RAID 51645"},
245 	{0x9005, 0x0285, 0x9005, 0x02d0, AAC_HWIF_I960RX, 0,
246 	 "Adaptec RAID 52445"},
247 	{0x9005, 0x0285, 0x9005, 0x02d1, AAC_HWIF_I960RX, 0,
248 	 "Adaptec RAID 5405"},
249 	{0x9005, 0x0285, 0x9005, 0x02d4, AAC_HWIF_I960RX, 0,
250 	 "Adaptec RAID 2045"},
251 	{0x9005, 0x0285, 0x9005, 0x02d5, AAC_HWIF_I960RX, 0,
252 	 "Adaptec RAID 2405"},
253 	{0x9005, 0x0285, 0x9005, 0x02d6, AAC_HWIF_I960RX, 0,
254 	 "Adaptec RAID 2445"},
255 	{0x9005, 0x0285, 0x9005, 0x02d7, AAC_HWIF_I960RX, 0,
256 	 "Adaptec RAID 2805"},
257 	{0x9005, 0x0286, 0x1014, 0x9580, AAC_HWIF_RKT, 0,
258 	 "IBM ServeRAID-8k"},
259 	{0x9005, 0x0285, 0x1014, 0x034d, AAC_HWIF_I960RX, 0,
260 	 "IBM ServeRAID 8s"},
261 	{0x9005, 0x0285, 0x108e, 0x7aac, AAC_HWIF_I960RX, 0,
262 	 "Sun STK RAID REM"},
263 	{0x9005, 0x0285, 0x108e, 0x7aae, AAC_HWIF_I960RX, 0,
264 	 "Sun STK RAID EM"},
265 	{0x9005, 0x0285, 0x108e, 0x286, AAC_HWIF_I960RX, 0,
266 	 "SG-XPCIESAS-R-IN"},
267 	{0x9005, 0x0285, 0x108e, 0x287, AAC_HWIF_I960RX, 0,
268 	 "SG-XPCIESAS-R-EX"},
269 	{0x9005, 0x0285, 0x15d9, 0x2b5, AAC_HWIF_I960RX, 0,
270 	 "AOC-USAS-S4i"},
271 	{0x9005, 0x0285, 0x15d9, 0x2b6, AAC_HWIF_I960RX, 0,
272 	 "AOC-USAS-S8i"},
273 	{0x9005, 0x0285, 0x15d9, 0x2c9, AAC_HWIF_I960RX, 0,
274 	 "AOC-USAS-S4iR"},
275 	{0x9005, 0x0285, 0x15d9, 0x2ca, AAC_HWIF_I960RX, 0,
276 	 "AOC-USAS-S8iR"},
277 	{0x9005, 0x0285, 0x15d9, 0x2d2, AAC_HWIF_I960RX, 0,
278 	 "AOC-USAS-S8i-LP"},
279 	{0x9005, 0x0285, 0x15d9, 0x2d3, AAC_HWIF_I960RX, 0,
280 	 "AOC-USAS-S8iR-LP"},
281 	{0, 0, 0, 0, 0, 0, 0}
282 };
283 
284 static const struct aac_ident
285 aac_family_identifiers[] = {
286 	{0x9005, 0x0285, 0, 0, AAC_HWIF_I960RX, 0,
287 	 "Adaptec RAID Controller"},
288 	{0x9005, 0x0286, 0, 0, AAC_HWIF_RKT, 0,
289 	 "Adaptec RAID Controller"},
290 	{0, 0, 0, 0, 0, 0, 0}
291 };
292 
293 static const struct aac_ident *
294 aac_find_ident(device_t dev)
295 {
296 	const struct aac_ident *m;
297 	u_int16_t vendid, devid, sub_vendid, sub_devid;
298 
299 	vendid = pci_get_vendor(dev);
300 	devid = pci_get_device(dev);
301 	sub_vendid = pci_get_subvendor(dev);
302 	sub_devid = pci_get_subdevice(dev);
303 
304 	for (m = aac_identifiers; m->vendor != 0; m++) {
305 		if ((m->vendor == vendid) && (m->device == devid) &&
306 		    (m->subvendor == sub_vendid) &&
307 		    (m->subdevice == sub_devid))
308 			return (m);
309 	}
310 
311 	for (m = aac_family_identifiers; m->vendor != 0; m++) {
312 		if ((m->vendor == vendid) && (m->device == devid))
313 			return (m);
314 	}
315 	return (NULL);
316 }
317 
318 /*
319  * Determine whether this is one of our supported adapters.
320  */
321 static int
322 aac_pci_probe(device_t dev)
323 {
324 	const struct aac_ident *id;
325 
326 	fwprintf(NULL, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
327 
328 	if ((id = aac_find_ident(dev)) != NULL) {
329 		device_set_desc(dev, id->desc);
330 		return(BUS_PROBE_DEFAULT);
331 	}
332 	return(ENXIO);
333 }
334 
335 /*
336  * Allocate resources for our device, set up the bus interface.
337  */
338 static int
339 aac_pci_attach(device_t dev)
340 {
341 	struct aac_softc *sc;
342 	const struct aac_ident *id;
343 	int count, error, rid;
344 
345 	fwprintf(NULL, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
346 
347 	/*
348 	 * Initialise softc.
349 	 */
350 	sc = device_get_softc(dev);
351 	sc->aac_dev = dev;
352 
353 	/* assume failure is 'not configured' */
354 	error = ENXIO;
355 
356 	/*
357 	 * Verify that the adapter is correctly set up in PCI space.
358 	 */
359 	pci_enable_busmaster(dev);
360 	if (!(pci_read_config(dev, PCIR_COMMAND, 2) & PCIM_CMD_BUSMASTEREN)) {
361 		device_printf(dev, "can't enable bus-master feature\n");
362 		goto out;
363 	}
364 
365 	/*
366 	 * Detect the hardware interface version, set up the bus interface
367 	 * indirection.
368 	 */
369 	id = aac_find_ident(dev);
370 	sc->aac_hwif = id->hwif;
371 	switch(sc->aac_hwif) {
372 	case AAC_HWIF_I960RX:
373 	case AAC_HWIF_NARK:
374 		fwprintf(sc, HBA_FLAGS_DBG_INIT_B,
375 		    "set hardware up for i960Rx/NARK");
376 		sc->aac_if = &aac_rx_interface;
377 		break;
378 	case AAC_HWIF_STRONGARM:
379 		fwprintf(sc, HBA_FLAGS_DBG_INIT_B,
380 		    "set hardware up for StrongARM");
381 		sc->aac_if = &aac_sa_interface;
382 		break;
383 	case AAC_HWIF_RKT:
384 		fwprintf(sc, HBA_FLAGS_DBG_INIT_B,
385 		    "set hardware up for Rocket/MIPS");
386 		sc->aac_if = &aac_rkt_interface;
387 		break;
388 	default:
389 		sc->aac_hwif = AAC_HWIF_UNKNOWN;
390 		device_printf(dev, "unknown hardware type\n");
391 		goto out;
392 	}
393 
394 	/* Set up quirks */
395 	sc->flags = id->quirks;
396 
397 	/*
398 	 * Allocate the PCI register window(s).
399 	 */
400 	rid = PCIR_BAR(0);
401 	if ((sc->aac_regs_res0 = bus_alloc_resource_any(dev,
402 	    SYS_RES_MEMORY, &rid, RF_ACTIVE)) == NULL) {
403 		device_printf(dev, "can't allocate register window 0\n");
404 		goto out;
405 	}
406 	sc->aac_btag0 = rman_get_bustag(sc->aac_regs_res0);
407 	sc->aac_bhandle0 = rman_get_bushandle(sc->aac_regs_res0);
408 
409 	if (sc->aac_hwif == AAC_HWIF_NARK) {
410 		rid = PCIR_BAR(1);
411 		if ((sc->aac_regs_res1 = bus_alloc_resource_any(dev,
412 		    SYS_RES_MEMORY, &rid, RF_ACTIVE)) == NULL) {
413 			device_printf(dev,
414 			    "can't allocate register window 1\n");
415 			goto out;
416 		}
417 		sc->aac_btag1 = rman_get_bustag(sc->aac_regs_res1);
418 		sc->aac_bhandle1 = rman_get_bushandle(sc->aac_regs_res1);
419 	} else {
420 		sc->aac_regs_res1 = sc->aac_regs_res0;
421 		sc->aac_btag1 = sc->aac_btag0;
422 		sc->aac_bhandle1 = sc->aac_bhandle0;
423 	}
424 
425 	/*
426 	 * Allocate the interrupt.
427 	 */
428 	rid = 0;
429 	if (aac_enable_msi != 0 && (sc->flags & AAC_FLAGS_NOMSI) == 0) {
430 		count = 1;
431 		if (pci_alloc_msi(dev, &count) == 0)
432 			rid = 1;
433 	}
434 	if ((sc->aac_irq = bus_alloc_resource_any(sc->aac_dev, SYS_RES_IRQ,
435 	    &rid, RF_ACTIVE | (rid != 0 ? 0 : RF_SHAREABLE))) == NULL) {
436 		device_printf(dev, "can't allocate interrupt\n");
437 		goto out;
438 	}
439 
440 	/*
441 	 * Allocate the parent bus DMA tag appropriate for our PCI interface.
442 	 *
443 	 * Note that some of these controllers are 64-bit capable.
444 	 */
445 	if (bus_dma_tag_create(bus_get_dma_tag(dev),	/* parent */
446 			       PAGE_SIZE, 0,		/* algnmnt, boundary */
447 			       BUS_SPACE_MAXADDR,	/* lowaddr */
448 			       BUS_SPACE_MAXADDR, 	/* highaddr */
449 			       NULL, NULL, 		/* filter, filterarg */
450 			       BUS_SPACE_MAXSIZE_32BIT,	/* maxsize */
451 			       BUS_SPACE_UNRESTRICTED,	/* nsegments */
452 			       BUS_SPACE_MAXSIZE_32BIT,	/* maxsegsize */
453 			       0,			/* flags */
454 			       NULL, NULL,		/* No locking needed */
455 			       &sc->aac_parent_dmat)) {
456 		device_printf(dev, "can't allocate parent DMA tag\n");
457 		goto out;
458 	}
459 
460 	/*
461 	 * Do bus-independent initialisation.
462 	 */
463 	error = aac_attach(sc);
464 
465 out:
466 	if (error)
467 		aac_free(sc);
468 	return(error);
469 }
470 
471 /*
472  * Do nothing driver that will attach to the SCSI channels of a Dell PERC
473  * controller.  This is needed to keep the power management subsystem from
474  * trying to power down these devices.
475  */
476 static int aacch_probe(device_t dev);
477 static int aacch_attach(device_t dev);
478 static int aacch_detach(device_t dev);
479 
480 static device_method_t aacch_methods[] = {
481 	/* Device interface */
482 	DEVMETHOD(device_probe,		aacch_probe),
483 	DEVMETHOD(device_attach,	aacch_attach),
484 	DEVMETHOD(device_detach,	aacch_detach),
485 	DEVMETHOD_END
486 };
487 
488 static driver_t aacch_driver = {
489 	"aacch",
490 	aacch_methods,
491 	1	/* no softc */
492 };
493 
494 static devclass_t	aacch_devclass;
495 DRIVER_MODULE(aacch, pci, aacch_driver, aacch_devclass, NULL, NULL);
496 MODULE_PNP_INFO("U16:vendor;U16:device;", pci, aac,
497     aac_identifiers, sizeof(aac_identifiers[0]), nitems(aac_identifiers) - 1);
498 
499 static int
500 aacch_probe(device_t dev)
501 {
502 
503 	if ((pci_get_vendor(dev) != 0x9005) ||
504 	    (pci_get_device(dev) != 0x00c5))
505 		return (ENXIO);
506 
507 	device_set_desc(dev, "AAC RAID Channel");
508 	return (-10);
509 }
510 
511 static int
512 aacch_attach(device_t dev __unused)
513 {
514 
515 	return (0);
516 }
517 
518 static int
519 aacch_detach(device_t dev __unused)
520 {
521 
522 	return (0);
523 }
524