1 /* $OpenBSD: siop_pci.c,v 1.7 2010/07/23 07:47:13 jsg Exp $ */ 2 /* $NetBSD: siop_pci.c,v 1.18 2005/06/28 00:28:42 thorpej Exp $ */ 3 4 /* 5 * Copyright (c) 2000 Manuel Bouyer. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28 /* SYM53c8xx PCI-SCSI I/O Processors driver: PCI front-end */ 29 30 #include <sys/param.h> 31 #include <sys/systm.h> 32 #include <sys/device.h> 33 #include <sys/kernel.h> 34 35 #include <dev/pci/pcireg.h> 36 #include <dev/pci/pcivar.h> 37 38 #include <scsi/scsi_all.h> 39 #include <scsi/scsiconf.h> 40 41 #include <dev/ic/siopvar_common.h> 42 #include <dev/pci/siop_pci_common.h> 43 #include <dev/ic/siopvar.h> 44 45 int siop_pci_match(struct device *, void *, void *); 46 void siop_pci_attach(struct device *, struct device *, void *); 47 48 struct siop_pci_softc { 49 struct siop_softc siop; 50 struct siop_pci_common_softc siop_pci; 51 }; 52 53 struct cfattach siop_pci_ca = { 54 sizeof(struct siop_pci_softc), siop_pci_match, siop_pci_attach 55 }; 56 57 int 58 siop_pci_match( struct device *parent, void *match, void *aux) 59 { 60 struct pci_attach_args *pa = aux; 61 const struct siop_product_desc *pp; 62 63 /* look if it's a known product */ 64 pp = siop_lookup_product(pa->pa_id, PCI_REVISION(pa->pa_class)); 65 if (pp) 66 return 1; 67 return 0; 68 } 69 70 void 71 siop_pci_attach(struct device *parent, struct device *self, void *aux) 72 { 73 struct pci_attach_args *pa = aux; 74 struct siop_pci_softc *sc = (struct siop_pci_softc *)self; 75 76 if (siop_pci_attach_common(&sc->siop_pci, &sc->siop.sc_c, 77 pa, siop_intr) == 0) 78 return; 79 80 siop_attach(&sc->siop); 81 } 82