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