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