aac_pci.c (247591) | aac_pci.c (254004) |
---|---|
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 --- 14 unchanged lines hidden (view full) --- 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> | 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 --- 14 unchanged lines hidden (view full) --- 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: head/sys/dev/aac/aac_pci.c 247591 2013-03-01 22:09:08Z marius $"); | 31__FBSDID("$FreeBSD: head/sys/dev/aac/aac_pci.c 254004 2013-08-06 18:55:59Z marius $"); |
32 33/* 34 * PCI bus interface and resource allocation. 35 */ 36 37#include "opt_aac.h" 38 39#include <sys/param.h> --- 94 unchanged lines hidden (view full) --- 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)"}, | 32 33/* 34 * PCI bus interface and resource allocation. 35 */ 36 37#include "opt_aac.h" 38 39#include <sys/param.h> --- 94 unchanged lines hidden (view full) --- 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, 0, | 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"}, | 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, 0, | 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, --- 137 unchanged lines hidden (view full) --- 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 } | 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, --- 137 unchanged lines hidden (view full) --- 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 | |
315 return (NULL); 316} 317 318/* 319 * Determine whether this is one of our supported adapters. 320 */ 321static int 322aac_pci_probe(device_t dev) --- 12 unchanged lines hidden (view full) --- 335/* 336 * Allocate resources for our device, set up the bus interface. 337 */ 338static int 339aac_pci_attach(device_t dev) 340{ 341 struct aac_softc *sc; 342 const struct aac_ident *id; | 314 return (NULL); 315} 316 317/* 318 * Determine whether this is one of our supported adapters. 319 */ 320static int 321aac_pci_probe(device_t dev) --- 12 unchanged lines hidden (view full) --- 334/* 335 * Allocate resources for our device, set up the bus interface. 336 */ 337static int 338aac_pci_attach(device_t dev) 339{ 340 struct aac_softc *sc; 341 const struct aac_ident *id; |
343 int count, error, reg, rid; | 342 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; --- 6 unchanged lines hidden (view full) --- 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 /* | 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; --- 6 unchanged lines hidden (view full) --- 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 /* |
|
366 * Allocate the PCI register window(s). 367 */ 368 rid = PCIR_BAR(0); 369 if ((sc->aac_regs_res0 = bus_alloc_resource_any(dev, 370 SYS_RES_MEMORY, &rid, RF_ACTIVE)) == NULL) { 371 device_printf(dev, "can't allocate register window 0\n"); 372 goto out; 373 } --- 16 unchanged lines hidden (view full) --- 390 sc->aac_bhandle1 = sc->aac_bhandle0; 391 } 392 393 /* 394 * Allocate the interrupt. 395 */ 396 rid = 0; 397 count = 0; | 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 } --- 16 unchanged lines hidden (view full) --- 421 sc->aac_bhandle1 = sc->aac_bhandle0; 422 } 423 424 /* 425 * Allocate the interrupt. 426 */ 427 rid = 0; 428 count = 0; |
398 if (aac_enable_msi != 0 && pci_find_cap(dev, PCIY_MSI, ®) == 0) { 399 count = pci_msi_count(dev); | 429 if (aac_enable_msi != 0 && (sc->flags & AAC_FLAGS_NOMSI) == 0 && 430 (count = pci_msi_count(dev)) != 0) { |
400 if (count > 1) 401 count = 1; 402 else 403 count = 0; 404 if (count == 1 && pci_alloc_msi(dev, &count) == 0) 405 rid = 1; 406 } 407 if ((sc->aac_irq = bus_alloc_resource_any(sc->aac_dev, SYS_RES_IRQ, --- 18 unchanged lines hidden (view full) --- 426 0, /* flags */ 427 NULL, NULL, /* No locking needed */ 428 &sc->aac_parent_dmat)) { 429 device_printf(dev, "can't allocate parent DMA tag\n"); 430 goto out; 431 } 432 433 /* | 431 if (count > 1) 432 count = 1; 433 else 434 count = 0; 435 if (count == 1 && pci_alloc_msi(dev, &count) == 0) 436 rid = 1; 437 } 438 if ((sc->aac_irq = bus_alloc_resource_any(sc->aac_dev, SYS_RES_IRQ, --- 18 unchanged lines hidden (view full) --- 457 0, /* flags */ 458 NULL, NULL, /* No locking needed */ 459 &sc->aac_parent_dmat)) { 460 device_printf(dev, "can't allocate parent DMA tag\n"); 461 goto out; 462 } 463 464 /* |
434 * Detect the hardware interface version, set up the bus interface 435 * indirection. 436 */ 437 id = aac_find_ident(dev); 438 sc->aac_hwif = id->hwif; 439 switch(sc->aac_hwif) { 440 case AAC_HWIF_I960RX: 441 case AAC_HWIF_NARK: 442 fwprintf(sc, HBA_FLAGS_DBG_INIT_B, "set hardware up for i960Rx/NARK"); 443 sc->aac_if = &aac_rx_interface; 444 break; 445 case AAC_HWIF_STRONGARM: 446 fwprintf(sc, HBA_FLAGS_DBG_INIT_B, "set hardware up for StrongARM"); 447 sc->aac_if = &aac_sa_interface; 448 break; 449 case AAC_HWIF_RKT: 450 fwprintf(sc, HBA_FLAGS_DBG_INIT_B, "set hardware up for Rocket/MIPS"); 451 sc->aac_if = &aac_rkt_interface; 452 break; 453 default: 454 sc->aac_hwif = AAC_HWIF_UNKNOWN; 455 device_printf(dev, "unknown hardware type\n"); 456 error = ENXIO; 457 goto out; 458 } 459 460 /* Set up quirks */ 461 sc->flags = id->quirks; 462 463 /* | |
464 * Do bus-independent initialisation. 465 */ 466 error = aac_attach(sc); 467 468out: 469 if (error) 470 aac_free(sc); 471 return(error); --- 62 unchanged lines hidden --- | 465 * Do bus-independent initialisation. 466 */ 467 error = aac_attach(sc); 468 469out: 470 if (error) 471 aac_free(sc); 472 return(error); --- 62 unchanged lines hidden --- |