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