xref: /openbsd-src/sys/dev/pci/siop_pci.c (revision a28daedfc357b214be5c701aa8ba8adb29a7f1c2)
1 /*	$OpenBSD: siop_pci.c,v 1.6 2005/10/08 18:32:28 krw 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  * 3. All advertising materials mentioning features or use of this software
16  *    must display the following acknowledgement:
17  *	This product includes software developed by Manuel Bouyer.
18  * 4. The name of the author may not be used to endorse or promote products
19  *    derived from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 /* SYM53c8xx PCI-SCSI I/O Processors driver: PCI front-end */
34 
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/device.h>
38 #include <sys/kernel.h>
39 
40 #include <dev/pci/pcireg.h>
41 #include <dev/pci/pcivar.h>
42 
43 #include <scsi/scsi_all.h>
44 #include <scsi/scsiconf.h>
45 
46 #include <dev/ic/siopvar_common.h>
47 #include <dev/pci/siop_pci_common.h>
48 #include <dev/ic/siopvar.h>
49 
50 int     siop_pci_match(struct device *, void *, void *);
51 void    siop_pci_attach(struct device *, struct device *, void *);
52 
53 struct siop_pci_softc {
54 	struct siop_softc siop;
55 	struct siop_pci_common_softc siop_pci;
56 };
57 
58 struct cfattach siop_pci_ca = {
59 	sizeof(struct siop_pci_softc), siop_pci_match, siop_pci_attach
60 };
61 
62 int
63 siop_pci_match( struct device *parent, void *match, void *aux)
64 {
65 	struct pci_attach_args *pa = aux;
66 	const struct siop_product_desc *pp;
67 
68 	/* look if it's a known product */
69 	pp = siop_lookup_product(pa->pa_id, PCI_REVISION(pa->pa_class));
70 	if (pp)
71 		return 1;
72 	return 0;
73 }
74 
75 void
76 siop_pci_attach(struct device *parent, struct device *self, void *aux)
77 {
78 	struct pci_attach_args *pa = aux;
79 	struct siop_pci_softc *sc = (struct siop_pci_softc *)self;
80 
81 	if (siop_pci_attach_common(&sc->siop_pci, &sc->siop.sc_c,
82 	    pa, siop_intr) == 0)
83 		return;
84 
85 	siop_attach(&sc->siop);
86 }
87