135863739SMike Smith /*- 235863739SMike Smith * Copyright (c) 2000 Michael Smith 3c6eafcf2SScott Long * Copyright (c) 2001 Scott Long 435863739SMike Smith * Copyright (c) 2000 BSDi 5fadfef89SScott Long * Copyright (c) 2001 Adaptec, Inc. 635863739SMike Smith * All rights reserved. 735863739SMike Smith * 835863739SMike Smith * Redistribution and use in source and binary forms, with or without 935863739SMike Smith * modification, are permitted provided that the following conditions 1035863739SMike Smith * are met: 1135863739SMike Smith * 1. Redistributions of source code must retain the above copyright 1235863739SMike Smith * notice, this list of conditions and the following disclaimer. 1335863739SMike Smith * 2. Redistributions in binary form must reproduce the above copyright 1435863739SMike Smith * notice, this list of conditions and the following disclaimer in the 1535863739SMike Smith * documentation and/or other materials provided with the distribution. 1635863739SMike Smith * 1735863739SMike Smith * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1835863739SMike Smith * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1935863739SMike Smith * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2035863739SMike Smith * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2135863739SMike Smith * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2235863739SMike Smith * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2335863739SMike Smith * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2435863739SMike Smith * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2535863739SMike Smith * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2635863739SMike Smith * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2735863739SMike Smith * SUCH DAMAGE. 2835863739SMike Smith */ 2935863739SMike Smith 30aad970f1SDavid E. O'Brien #include <sys/cdefs.h> 31aad970f1SDavid E. O'Brien __FBSDID("$FreeBSD$"); 32aad970f1SDavid E. O'Brien 3335863739SMike Smith /* 3435863739SMike Smith * PCI bus interface and resource allocation. 3535863739SMike Smith */ 3635863739SMike Smith 37f6c4dd3fSScott Long #include "opt_aac.h" 38f6c4dd3fSScott Long 3935863739SMike Smith #include <sys/param.h> 4035863739SMike Smith #include <sys/systm.h> 4135863739SMike Smith #include <sys/kernel.h> 42fe12f24bSPoul-Henning Kamp #include <sys/module.h> 4335863739SMike Smith 449e2e96d8SScott Long #include <sys/bio.h> 4535863739SMike Smith #include <sys/bus.h> 4635863739SMike Smith #include <sys/conf.h> 4735863739SMike Smith #include <sys/disk.h> 4835863739SMike Smith 4935863739SMike Smith #include <machine/bus.h> 5035863739SMike Smith #include <machine/resource.h> 5135863739SMike Smith #include <sys/rman.h> 5235863739SMike Smith 53dc5f7dd0SWarner Losh #include <dev/pci/pcireg.h> 54dc5f7dd0SWarner Losh #include <dev/pci/pcivar.h> 5535863739SMike Smith 5635863739SMike Smith #include <dev/aac/aacreg.h> 570b0594cdSScott Long #include <sys/aac_ioctl.h> 5835863739SMike Smith #include <dev/aac/aacvar.h> 5935863739SMike Smith 6035863739SMike Smith static int aac_pci_probe(device_t dev); 6135863739SMike Smith static int aac_pci_attach(device_t dev); 6235863739SMike Smith 6335863739SMike Smith static device_method_t aac_methods[] = { 6435863739SMike Smith /* Device interface */ 6535863739SMike Smith DEVMETHOD(device_probe, aac_pci_probe), 6635863739SMike Smith DEVMETHOD(device_attach, aac_pci_attach), 6735863739SMike Smith DEVMETHOD(device_detach, aac_detach), 6835863739SMike Smith DEVMETHOD(device_suspend, aac_suspend), 6935863739SMike Smith DEVMETHOD(device_resume, aac_resume), 7035863739SMike Smith 7135863739SMike Smith DEVMETHOD(bus_print_child, bus_generic_print_child), 7235863739SMike Smith DEVMETHOD(bus_driver_added, bus_generic_driver_added), 7335863739SMike Smith { 0, 0 } 7435863739SMike Smith }; 7535863739SMike Smith 7635863739SMike Smith static driver_t aac_pci_driver = { 7735863739SMike Smith "aac", 7835863739SMike Smith aac_methods, 7935863739SMike Smith sizeof(struct aac_softc) 8035863739SMike Smith }; 8135863739SMike Smith 82e45bef2aSMike Smith static devclass_t aac_devclass; 83e45bef2aSMike Smith 8435863739SMike Smith DRIVER_MODULE(aac, pci, aac_pci_driver, aac_devclass, 0, 0); 85b3d93fd0SMatt Jacob MODULE_DEPEND(aac, pci, 1, 1, 1); 86b3d93fd0SMatt Jacob 8735863739SMike Smith 8835863739SMike Smith struct aac_ident 8935863739SMike Smith { 9035863739SMike Smith u_int16_t vendor; 9135863739SMike Smith u_int16_t device; 9235863739SMike Smith u_int16_t subvendor; 9335863739SMike Smith u_int16_t subdevice; 9435863739SMike Smith int hwif; 95fe3cb0e1SScott Long int quirks; 9635863739SMike Smith char *desc; 9735863739SMike Smith } aac_identifiers[] = { 98a6d35632SScott Long {0x1028, 0x0001, 0x1028, 0x0001, AAC_HWIF_I960RX, 0, 99fe3cb0e1SScott Long "Dell PERC 2/Si"}, 100a6d35632SScott Long {0x1028, 0x0002, 0x1028, 0x0002, AAC_HWIF_I960RX, 0, 101fe3cb0e1SScott Long "Dell PERC 3/Di"}, 102a6d35632SScott Long {0x1028, 0x0003, 0x1028, 0x0003, AAC_HWIF_I960RX, 0, 103fe3cb0e1SScott Long "Dell PERC 3/Si"}, 104a6d35632SScott Long {0x1028, 0x0004, 0x1028, 0x00d0, AAC_HWIF_I960RX, 0, 105fe3cb0e1SScott Long "Dell PERC 3/Si"}, 106a6d35632SScott Long {0x1028, 0x0002, 0x1028, 0x00d1, AAC_HWIF_I960RX, 0, 107fe3cb0e1SScott Long "Dell PERC 3/Di"}, 108a6d35632SScott Long {0x1028, 0x0002, 0x1028, 0x00d9, AAC_HWIF_I960RX, 0, 109fe3cb0e1SScott Long "Dell PERC 3/Di"}, 110a6d35632SScott Long {0x1028, 0x000a, 0x1028, 0x0106, AAC_HWIF_I960RX, 0, 111fe3cb0e1SScott Long "Dell PERC 3/Di"}, 112a6d35632SScott Long {0x1028, 0x000a, 0x1028, 0x011b, AAC_HWIF_I960RX, 0, 113fe3cb0e1SScott Long "Dell PERC 3/Di"}, 114a6d35632SScott Long {0x1028, 0x000a, 0x1028, 0x0121, AAC_HWIF_I960RX, 0, 115fe3cb0e1SScott Long "Dell PERC 3/Di"}, 116a6d35632SScott Long {0x1011, 0x0046, 0x9005, 0x0364, AAC_HWIF_STRONGARM, 0, 117fe3cb0e1SScott Long "Adaptec AAC-364"}, 1184b00f859SScott Long {0x1011, 0x0046, 0x9005, 0x0365, AAC_HWIF_STRONGARM, 1194b00f859SScott Long AAC_FLAGS_BROKEN_MEMMAP, "Adaptec SCSI RAID 5400S"}, 120a6d35632SScott Long {0x1011, 0x0046, 0x9005, 0x1364, AAC_HWIF_STRONGARM, AAC_FLAGS_PERC2QC, 121a6d35632SScott Long "Dell PERC 2/QC"}, 122a6d35632SScott Long {0x1011, 0x0046, 0x103c, 0x10c2, AAC_HWIF_STRONGARM, 0, 123a9f3d2c7SScott Long "HP NetRaid-4M"}, 124a6d35632SScott Long {0x9005, 0x0285, 0x9005, 0x0285, AAC_HWIF_I960RX, AAC_FLAGS_NO4GB | 125a6d35632SScott Long AAC_FLAGS_256FIBS, "Adaptec SCSI RAID 2200S"}, 126a6d35632SScott Long {0x9005, 0x0285, 0x1028, 0x0287, AAC_HWIF_I960RX, AAC_FLAGS_NO4GB | 127a6d35632SScott Long AAC_FLAGS_256FIBS, "Dell PERC 320/DC"}, 128a6d35632SScott Long {0x9005, 0x0285, 0x9005, 0x0286, AAC_HWIF_I960RX, AAC_FLAGS_NO4GB | 129a6d35632SScott Long AAC_FLAGS_256FIBS, "Adaptec SCSI RAID 2120S"}, 1309d5be300SScott Long {0x9005, 0x0285, 0x9005, 0x0290, AAC_HWIF_I960RX, AAC_FLAGS_NO4GB, 1317598d049SChristian Brueffer "Adaptec SATA RAID 2410SA"}, 132ad452e65SScott Long {0x9005, 0x0285, 0x1028, 0x0291, AAC_HWIF_I960RX, AAC_FLAGS_NO4GB, 133ad452e65SScott Long "Dell CERC SATA RAID 2"}, 134ad452e65SScott Long {0x9005, 0x0285, 0x9005, 0x0292, AAC_HWIF_I960RX, AAC_FLAGS_NO4GB, 1357598d049SChristian Brueffer "Adaptec SATA RAID 2810SA"}, 136b1e56e58SScott Long {0x9005, 0x0285, 0x9005, 0x0293, AAC_HWIF_I960RX, AAC_FLAGS_NO4GB, 1377598d049SChristian Brueffer "Adaptec SATA RAID 21610SA"}, 13816ee26fdSPaul Saab {0x9005, 0x0285, 0x103c, 0x3227, AAC_HWIF_I960RX, AAC_FLAGS_NO4GB, 13916ee26fdSPaul Saab "HP ML110 G2 (Adaptec 2610SA)"}, 140ecefe571SScott Long {0x9005, 0x0286, 0x9005, 0x028c, AAC_HWIF_RKT, 0, 141ecefe571SScott Long "Adaptec SCSI RAID 2230S"}, 1424afedc31SScott Long {0x9005, 0x0286, 0x9005, 0x028d, AAC_HWIF_RKT, 0, 1434afedc31SScott Long "Adaptec SCSI RAID 2130S"}, 1447cb209f5SScott Long 1457cb209f5SScott Long {0x9005, 0x0285, 0x9005, 0x0287, AAC_HWIF_I960RX, AAC_FLAGS_NO4GB | 1467cb209f5SScott Long AAC_FLAGS_256FIBS, "Adaptec SCSI RAID 2200S"}, 1477cb209f5SScott Long {0x9005, 0x0285, 0x17aa, 0x0286, AAC_HWIF_I960RX, AAC_FLAGS_NO4GB | 1487cb209f5SScott Long AAC_FLAGS_256FIBS, "Legend S220"}, 1497cb209f5SScott Long {0x9005, 0x0285, 0x17aa, 0x0287, AAC_HWIF_I960RX, AAC_FLAGS_NO4GB | 1507cb209f5SScott Long AAC_FLAGS_256FIBS, "Legend S230"}, 1517cb209f5SScott Long {0x9005, 0x0285, 0x9005, 0x0288, AAC_HWIF_I960RX, 0, 1527cb209f5SScott Long "Adaptec SCSI RAID 3230S"}, 1537cb209f5SScott Long {0x9005, 0x0285, 0x9005, 0x0289, AAC_HWIF_I960RX, 0, 1547cb209f5SScott Long "Adaptec SCSI RAID 3240S"}, 1557cb209f5SScott Long {0x9005, 0x0285, 0x9005, 0x028a, AAC_HWIF_I960RX, 0, 1567cb209f5SScott Long "Adaptec SCSI RAID 2020ZCR"}, 1577cb209f5SScott Long {0x9005, 0x0285, 0x9005, 0x028b, AAC_HWIF_I960RX, 0, 1587cb209f5SScott Long "Adaptec SCSI RAID 2025ZCR"}, 1597cb209f5SScott Long {0x9005, 0x0286, 0x9005, 0x029b, AAC_HWIF_RKT, 0, 1607cb209f5SScott Long "Adaptec SATA RAID 2820SA"}, 1617cb209f5SScott Long {0x9005, 0x0286, 0x9005, 0x029c, AAC_HWIF_RKT, 0, 1627cb209f5SScott Long "Adaptec SATA RAID 2620SA"}, 1637cb209f5SScott Long {0x9005, 0x0286, 0x9005, 0x029d, AAC_HWIF_RKT, 0, 1647cb209f5SScott Long "Adaptec SATA RAID 2420SA"}, 1657cb209f5SScott Long {0x9005, 0x0286, 0x9005, 0x029e, AAC_HWIF_RKT, 0, 1667598d049SChristian Brueffer "ICP ICP9024RO SCSI RAID"}, 1677cb209f5SScott Long {0x9005, 0x0286, 0x9005, 0x029f, AAC_HWIF_RKT, 0, 1687598d049SChristian Brueffer "ICP ICP9014RO SCSI RAID"}, 1697cb209f5SScott Long {0x9005, 0x0285, 0x9005, 0x0294, AAC_HWIF_I960RX, 0, 1707cb209f5SScott Long "Adaptec SATA RAID 2026ZCR"}, 1717cb209f5SScott Long {0x9005, 0x0285, 0x103c, 0x3227, AAC_HWIF_I960RX, 0, 1727cb209f5SScott Long "Adaptec SATA RAID 2610SA"}, 1737cb209f5SScott Long {0x9005, 0x0285, 0x9005, 0x0296, AAC_HWIF_I960RX, 0, 1747cb209f5SScott Long "Adaptec SCSI RAID 2240S"}, 1757cb209f5SScott Long {0x9005, 0x0285, 0x9005, 0x0297, AAC_HWIF_I960RX, 0, 1767cb209f5SScott Long "Adaptec SAS RAID 4005SAS"}, 1777cb209f5SScott Long {0x9005, 0x0285, 0x1014, 0x02f2, AAC_HWIF_I960RX, 0, 1787cb209f5SScott Long "IBM ServeRAID 8i"}, 1797cb209f5SScott Long {0x9005, 0x0285, 0x9005, 0x0298, AAC_HWIF_I960RX, 0, 1807cb209f5SScott Long "Adaptec SAS RAID 4000SAS"}, 1817cb209f5SScott Long {0x9005, 0x0285, 0x9005, 0x0299, AAC_HWIF_I960RX, 0, 1827cb209f5SScott Long "Adaptec SAS RAID 4800SAS"}, 1837cb209f5SScott Long {0x9005, 0x0285, 0x9005, 0x029a, AAC_HWIF_I960RX, 0, 1847cb209f5SScott Long "Adaptec SAS RAID 4805SAS"}, 1857cb209f5SScott Long {0x9005, 0x0285, 0x9005, 0x028e, AAC_HWIF_I960RX, 0, 1867cb209f5SScott Long "Adaptec SATA RAID 2020SA ZCR"}, 1877cb209f5SScott Long {0x9005, 0x0285, 0x9005, 0x028f, AAC_HWIF_I960RX, 0, 1887cb209f5SScott Long "Adaptec SATA RAID 2025SA ZCR"}, 1897cb209f5SScott Long {0x9005, 0x0285, 0x9005, 0x02a4, AAC_HWIF_I960RX, 0, 1907598d049SChristian Brueffer "ICP ICP9085LI SAS RAID"}, 1917cb209f5SScott Long {0x9005, 0x0285, 0x9005, 0x02a5, AAC_HWIF_I960RX, 0, 1927598d049SChristian Brueffer "ICP ICP5085BR SAS RAID"}, 1937cb209f5SScott Long {0x9005, 0x0286, 0x9005, 0x02a0, AAC_HWIF_RKT, 0, 1947598d049SChristian Brueffer "ICP ICP9047MA SATA RAID"}, 1957cb209f5SScott Long {0x9005, 0x0286, 0x9005, 0x02a1, AAC_HWIF_RKT, 0, 1967598d049SChristian Brueffer "ICP ICP9087MA SATA RAID"}, 197afa3f6dfSEd Maste {0x9005, 0x0285, 0x9005, 0x02bb, AAC_HWIF_I960RX, 0, 198afa3f6dfSEd Maste "Adaptec RAID 3405"}, 199afa3f6dfSEd Maste {0x9005, 0x0285, 0x9005, 0x02bc, AAC_HWIF_I960RX, 0, 200afa3f6dfSEd Maste "Adaptec RAID 3805"}, 201eae94b67SScott Long {0x9005, 0x0286, 0x1014, 0x9580, AAC_HWIF_RKT, 0, 202eae94b67SScott Long "IBM ServeRAID-8k"}, 203fe3cb0e1SScott Long {0, 0, 0, 0, 0, 0, 0} 20435863739SMike Smith }; 20535863739SMike Smith 2062419217bSScott Long static struct aac_ident * 2072419217bSScott Long aac_find_ident(device_t dev) 2082419217bSScott Long { 2092419217bSScott Long struct aac_ident *m; 2102419217bSScott Long 2112419217bSScott Long for (m = aac_identifiers; m->vendor != 0; m++) { 2122419217bSScott Long if ((m->vendor == pci_get_vendor(dev)) && 2132419217bSScott Long (m->device == pci_get_device(dev)) && 2142419217bSScott Long (m->subvendor == pci_get_subvendor(dev)) && 2152419217bSScott Long (m->subdevice == pci_get_subdevice(dev))) 2162419217bSScott Long return (m); 2172419217bSScott Long } 2182419217bSScott Long 2192419217bSScott Long return (NULL); 2202419217bSScott Long } 2212419217bSScott Long 222914da7d0SScott Long /* 22335863739SMike Smith * Determine whether this is one of our supported adapters. 22435863739SMike Smith */ 22535863739SMike Smith static int 22635863739SMike Smith aac_pci_probe(device_t dev) 22735863739SMike Smith { 2282419217bSScott Long struct aac_ident *id; 22935863739SMike Smith 23035863739SMike Smith debug_called(1); 23135863739SMike Smith 2322419217bSScott Long if ((id = aac_find_ident(dev)) != NULL) { 2332419217bSScott Long device_set_desc(dev, id->desc); 234494f3ca1SWarner Losh return(BUS_PROBE_DEFAULT); 23535863739SMike Smith } 23635863739SMike Smith return(ENXIO); 23735863739SMike Smith } 23835863739SMike Smith 239914da7d0SScott Long /* 24035863739SMike Smith * Allocate resources for our device, set up the bus interface. 24135863739SMike Smith */ 24235863739SMike Smith static int 24335863739SMike Smith aac_pci_attach(device_t dev) 24435863739SMike Smith { 24535863739SMike Smith struct aac_softc *sc; 2462419217bSScott Long struct aac_ident *id; 2472419217bSScott Long int error; 24835863739SMike Smith u_int32_t command; 24935863739SMike Smith 25035863739SMike Smith debug_called(1); 25135863739SMike Smith 25235863739SMike Smith /* 25335863739SMike Smith * Initialise softc. 25435863739SMike Smith */ 25535863739SMike Smith sc = device_get_softc(dev); 25635863739SMike Smith bzero(sc, sizeof(*sc)); 25735863739SMike Smith sc->aac_dev = dev; 25835863739SMike Smith 25935863739SMike Smith /* assume failure is 'not configured' */ 26035863739SMike Smith error = ENXIO; 26135863739SMike Smith 26235863739SMike Smith /* 26335863739SMike Smith * Verify that the adapter is correctly set up in PCI space. 26435863739SMike Smith */ 26535863739SMike Smith command = pci_read_config(sc->aac_dev, PCIR_COMMAND, 2); 26635863739SMike Smith command |= PCIM_CMD_BUSMASTEREN; 26735863739SMike Smith pci_write_config(dev, PCIR_COMMAND, command, 2); 26835863739SMike Smith command = pci_read_config(sc->aac_dev, PCIR_COMMAND, 2); 26935863739SMike Smith if (!(command & PCIM_CMD_BUSMASTEREN)) { 27035863739SMike Smith device_printf(sc->aac_dev, "can't enable bus-master feature\n"); 27135863739SMike Smith goto out; 27235863739SMike Smith } 27335863739SMike Smith if ((command & PCIM_CMD_MEMEN) == 0) { 27435863739SMike Smith device_printf(sc->aac_dev, "memory window not available\n"); 27535863739SMike Smith goto out; 27635863739SMike Smith } 27735863739SMike Smith 27835863739SMike Smith /* 27935863739SMike Smith * Allocate the PCI register window. 28035863739SMike Smith */ 2815b80c0d7SScott Long sc->aac_regs_rid = PCIR_BAR(0); 2825f96beb9SNate Lawson if ((sc->aac_regs_resource = bus_alloc_resource_any(sc->aac_dev, 283914da7d0SScott Long SYS_RES_MEMORY, 284914da7d0SScott Long &sc->aac_regs_rid, 2855f96beb9SNate Lawson RF_ACTIVE)) == 2865f96beb9SNate Lawson NULL) { 287914da7d0SScott Long device_printf(sc->aac_dev, 288914da7d0SScott Long "couldn't allocate register window\n"); 28935863739SMike Smith goto out; 29035863739SMike Smith } 29135863739SMike Smith sc->aac_btag = rman_get_bustag(sc->aac_regs_resource); 29235863739SMike Smith sc->aac_bhandle = rman_get_bushandle(sc->aac_regs_resource); 29335863739SMike Smith 29435863739SMike Smith /* assume failure is 'out of memory' */ 29535863739SMike Smith error = ENOMEM; 29635863739SMike Smith 29735863739SMike Smith /* 29835863739SMike Smith * Allocate the parent bus DMA tag appropriate for our PCI interface. 29935863739SMike Smith * 30035863739SMike Smith * Note that some of these controllers are 64-bit capable. 30135863739SMike Smith */ 30235863739SMike Smith if (bus_dma_tag_create(NULL, /* parent */ 303cbfd045bSScott Long PAGE_SIZE, 0, /* algnmnt, boundary */ 304a6d35632SScott Long BUS_SPACE_MAXADDR, /* lowaddr */ 30535863739SMike Smith BUS_SPACE_MAXADDR, /* highaddr */ 30635863739SMike Smith NULL, NULL, /* filter, filterarg */ 307a6d35632SScott Long BUS_SPACE_MAXSIZE_32BIT, /* maxsize */ 3087cb209f5SScott Long BUS_SPACE_UNRESTRICTED, /* nsegments */ 30935863739SMike Smith BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ 310a6d35632SScott Long 0, /* flags */ 311f6b1c44dSScott Long NULL, NULL, /* No locking needed */ 31235863739SMike Smith &sc->aac_parent_dmat)) { 31335863739SMike Smith device_printf(sc->aac_dev, "can't allocate parent DMA tag\n"); 31435863739SMike Smith goto out; 31535863739SMike Smith } 31635863739SMike Smith 31735863739SMike Smith /* 318c6eafcf2SScott Long * Detect the hardware interface version, set up the bus interface 319c6eafcf2SScott Long * indirection. 32035863739SMike Smith */ 3212419217bSScott Long id = aac_find_ident(dev); 3222419217bSScott Long sc->aac_hwif = id->hwif; 32335863739SMike Smith switch(sc->aac_hwif) { 32435863739SMike Smith case AAC_HWIF_I960RX: 32535863739SMike Smith debug(2, "set hardware up for i960Rx"); 32635863739SMike Smith sc->aac_if = aac_rx_interface; 32735863739SMike Smith break; 32835863739SMike Smith case AAC_HWIF_STRONGARM: 32935863739SMike Smith debug(2, "set hardware up for StrongARM"); 33035863739SMike Smith sc->aac_if = aac_sa_interface; 33135863739SMike Smith break; 332b3457b51SScott Long case AAC_HWIF_FALCON: 333b3457b51SScott Long debug(2, "set hardware up for Falcon/PPC"); 334b3457b51SScott Long sc->aac_if = aac_fa_interface; 335b3457b51SScott Long break; 3364afedc31SScott Long case AAC_HWIF_RKT: 3377cb209f5SScott Long debug(2, "set hardware up for Rocket/MIPS"); 3384afedc31SScott Long sc->aac_if = aac_rkt_interface; 3394afedc31SScott Long break; 3404afedc31SScott Long default: 3414afedc31SScott Long sc->aac_hwif = AAC_HWIF_UNKNOWN; 3420b94a66eSMike Smith device_printf(sc->aac_dev, "unknown hardware type\n"); 3430b94a66eSMike Smith error = ENXIO; 3440b94a66eSMike Smith goto out; 3450b94a66eSMike Smith } 34635863739SMike Smith 3472419217bSScott Long /* Set up quirks */ 3482419217bSScott Long sc->flags = id->quirks; 349fe94b852SScott Long 350fe94b852SScott Long /* 35135863739SMike Smith * Do bus-independent initialisation. 35235863739SMike Smith */ 35335863739SMike Smith error = aac_attach(sc); 35435863739SMike Smith 35535863739SMike Smith out: 35635863739SMike Smith if (error) 35735863739SMike Smith aac_free(sc); 35835863739SMike Smith return(error); 35935863739SMike Smith } 360608d7ac2SScott Long 361608d7ac2SScott Long /* 362608d7ac2SScott Long * Do nothing driver that will attach to the SCSI channels of a Dell PERC 363608d7ac2SScott Long * controller. This is needed to keep the power management subsystem from 364608d7ac2SScott Long * trying to power down these devices. 365608d7ac2SScott Long */ 366608d7ac2SScott Long static int aacch_probe(device_t dev); 367608d7ac2SScott Long static int aacch_attach(device_t dev); 368608d7ac2SScott Long static int aacch_detach(device_t dev); 369608d7ac2SScott Long 370608d7ac2SScott Long static device_method_t aacch_methods[] = { 371608d7ac2SScott Long /* Device interface */ 372608d7ac2SScott Long DEVMETHOD(device_probe, aacch_probe), 373608d7ac2SScott Long DEVMETHOD(device_attach, aacch_attach), 374608d7ac2SScott Long DEVMETHOD(device_detach, aacch_detach), 375608d7ac2SScott Long { 0, 0 } 376608d7ac2SScott Long }; 377608d7ac2SScott Long 378608d7ac2SScott Long struct aacch_softc { 379608d7ac2SScott Long device_t dev; 380608d7ac2SScott Long }; 381608d7ac2SScott Long 382608d7ac2SScott Long static driver_t aacch_driver = { 383608d7ac2SScott Long "aacch", 384608d7ac2SScott Long aacch_methods, 385608d7ac2SScott Long sizeof(struct aacch_softc) 386608d7ac2SScott Long }; 387608d7ac2SScott Long 388608d7ac2SScott Long static devclass_t aacch_devclass; 389608d7ac2SScott Long DRIVER_MODULE(aacch, pci, aacch_driver, aacch_devclass, 0, 0); 390608d7ac2SScott Long 391608d7ac2SScott Long static int 392608d7ac2SScott Long aacch_probe(device_t dev) 393608d7ac2SScott Long { 394608d7ac2SScott Long 3951b3a4f4eSScott Long if ((pci_get_vendor(dev) != 0x9005) || 3961b3a4f4eSScott Long (pci_get_device(dev) != 0x00c5)) 397608d7ac2SScott Long return (ENXIO); 398608d7ac2SScott Long 399608d7ac2SScott Long device_set_desc(dev, "AAC RAID Channel"); 400608d7ac2SScott Long return (-10); 401608d7ac2SScott Long } 402608d7ac2SScott Long 403608d7ac2SScott Long static int 404608d7ac2SScott Long aacch_attach(device_t dev) 405608d7ac2SScott Long { 406608d7ac2SScott Long struct aacch_softc *sc; 407608d7ac2SScott Long 408608d7ac2SScott Long sc = device_get_softc(dev); 409608d7ac2SScott Long 410608d7ac2SScott Long sc->dev = dev; 411608d7ac2SScott Long 412608d7ac2SScott Long return (0); 413608d7ac2SScott Long } 414608d7ac2SScott Long 415608d7ac2SScott Long static int 416608d7ac2SScott Long aacch_detach(device_t dev) 417608d7ac2SScott Long { 418608d7ac2SScott Long 419608d7ac2SScott Long return (0); 420608d7ac2SScott Long } 421