Home | History | Annotate | Line # | Download | only in pci
siop_pci.c revision 1.21.68.1
      1  1.21.68.1      jym /*	$NetBSD: siop_pci.c,v 1.21.68.1 2009/05/13 17:20:29 jym Exp $	*/
      2        1.1   bouyer 
      3        1.1   bouyer /*
      4        1.1   bouyer  * Copyright (c) 2000 Manuel Bouyer.
      5        1.1   bouyer  *
      6        1.1   bouyer  * Redistribution and use in source and binary forms, with or without
      7        1.1   bouyer  * modification, are permitted provided that the following conditions
      8        1.1   bouyer  * are met:
      9        1.1   bouyer  * 1. Redistributions of source code must retain the above copyright
     10        1.1   bouyer  *    notice, this list of conditions and the following disclaimer.
     11        1.1   bouyer  * 2. Redistributions in binary form must reproduce the above copyright
     12        1.1   bouyer  *    notice, this list of conditions and the following disclaimer in the
     13        1.1   bouyer  *    documentation and/or other materials provided with the distribution.
     14        1.1   bouyer  * 3. All advertising materials mentioning features or use of this software
     15        1.1   bouyer  *    must display the following acknowledgement:
     16       1.11   bouyer  *	This product includes software developed by Manuel Bouyer.
     17        1.2   bouyer  * 4. The name of the author may not be used to endorse or promote products
     18        1.2   bouyer  *    derived from this software without specific prior written permission.
     19        1.1   bouyer  *
     20        1.8   bouyer  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     21        1.8   bouyer  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     22        1.8   bouyer  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     23       1.17    perry  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     24        1.8   bouyer  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     25        1.8   bouyer  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26        1.8   bouyer  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     27        1.8   bouyer  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28        1.8   bouyer  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     29        1.8   bouyer  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30        1.1   bouyer  */
     31        1.1   bouyer 
     32        1.1   bouyer /* SYM53c8xx PCI-SCSI I/O Processors driver: PCI front-end */
     33        1.9    lukem 
     34        1.9    lukem #include <sys/cdefs.h>
     35  1.21.68.1      jym __KERNEL_RCSID(0, "$NetBSD: siop_pci.c,v 1.21.68.1 2009/05/13 17:20:29 jym Exp $");
     36        1.1   bouyer 
     37        1.1   bouyer #include <sys/param.h>
     38        1.1   bouyer #include <sys/systm.h>
     39        1.1   bouyer #include <sys/device.h>
     40        1.1   bouyer #include <sys/kernel.h>
     41       1.15  thorpej 
     42       1.15  thorpej #include <uvm/uvm_extern.h>
     43        1.1   bouyer 
     44        1.1   bouyer #include <dev/pci/pcireg.h>
     45        1.1   bouyer #include <dev/pci/pcivar.h>
     46        1.1   bouyer 
     47        1.1   bouyer #include <dev/scsipi/scsipi_all.h>
     48        1.1   bouyer #include <dev/scsipi/scsipiconf.h>
     49        1.1   bouyer 
     50       1.10   bouyer #include <dev/ic/siopvar_common.h>
     51       1.10   bouyer #include <dev/pci/siop_pci_common.h>
     52        1.1   bouyer #include <dev/ic/siopvar.h>
     53        1.1   bouyer 
     54       1.10   bouyer struct siop_pci_softc {
     55       1.10   bouyer 	struct siop_softc siop;
     56       1.10   bouyer 	struct siop_pci_common_softc siop_pci;
     57       1.10   bouyer };
     58       1.10   bouyer 
     59       1.18  thorpej static int
     60  1.21.68.1      jym siop_pci_match(device_t parent, cfdata_t match, void *aux)
     61        1.1   bouyer {
     62        1.1   bouyer 	struct pci_attach_args *pa = aux;
     63        1.1   bouyer 	const struct siop_product_desc *pp;
     64        1.1   bouyer 
     65        1.1   bouyer 	/* look if it's a known product */
     66        1.1   bouyer 	pp = siop_lookup_product(pa->pa_id, PCI_REVISION(pa->pa_class));
     67        1.1   bouyer 	if (pp)
     68        1.1   bouyer 		return 1;
     69        1.1   bouyer 	return 0;
     70        1.1   bouyer }
     71        1.1   bouyer 
     72       1.18  thorpej static void
     73  1.21.68.1      jym siop_pci_attach(device_t parent, device_t self, void *aux)
     74        1.1   bouyer {
     75        1.1   bouyer 	struct pci_attach_args *pa = aux;
     76  1.21.68.1      jym 	struct siop_pci_softc *sc = device_private(self);
     77        1.8   bouyer 
     78       1.10   bouyer 	if (siop_pci_attach_common(&sc->siop_pci, &sc->siop.sc_c,
     79       1.10   bouyer 	    pa, siop_intr) == 0)
     80        1.7  thorpej 		return;
     81        1.7  thorpej 
     82        1.1   bouyer 	siop_attach(&sc->siop);
     83        1.1   bouyer }
     84       1.18  thorpej 
     85       1.18  thorpej CFATTACH_DECL(siop_pci, sizeof(struct siop_pci_softc),
     86       1.18  thorpej     siop_pci_match, siop_pci_attach, NULL, NULL);
     87