xref: /openbsd-src/sys/dev/pci/siop_pci.c (revision db3296cf5c1dd9058ceecc3a29fe4aaa0bd26000)
1 /*	$OpenBSD: siop_pci.c,v 1.5 2002/11/16 04:37:29 krw Exp $ */
2 /*	$NetBSD: siop_pci.c,v 1.14 2002/10/02 16:51:54 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(parent, match, aux)
64 	struct device *parent;
65 	void *match;
66 	void *aux;
67 {
68 	struct pci_attach_args *pa = aux;
69 	const struct siop_product_desc *pp;
70 
71 	/* look if it's a known product */
72 	pp = siop_lookup_product(pa->pa_id, PCI_REVISION(pa->pa_class));
73 	if (pp)
74 		return 1;
75 	return 0;
76 }
77 
78 void
79 siop_pci_attach(parent, self, aux)
80 	struct device *parent, *self;
81 	void *aux;
82 {
83 	struct pci_attach_args *pa = aux;
84 	struct siop_pci_softc *sc = (struct siop_pci_softc *)self;
85 
86 	if (siop_pci_attach_common(&sc->siop_pci, &sc->siop.sc_c,
87 	    pa, siop_intr) == 0)
88 		return;
89 
90 	siop_attach(&sc->siop);
91 }
92