1 /* $OpenBSD: siop_pci.c,v 1.9 2024/05/24 06:02:58 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
34 #include <dev/pci/pcireg.h>
35 #include <dev/pci/pcivar.h>
36
37 #include <scsi/scsi_all.h>
38 #include <scsi/scsiconf.h>
39
40 #include <dev/ic/siopvar_common.h>
41 #include <dev/pci/siop_pci_common.h>
42 #include <dev/ic/siopvar.h>
43
44 int siop_pci_match(struct device *, void *, void *);
45 void siop_pci_attach(struct device *, struct device *, void *);
46
47 struct siop_pci_softc {
48 struct siop_softc siop;
49 struct siop_pci_common_softc siop_pci;
50 };
51
52 const struct cfattach siop_pci_ca = {
53 sizeof(struct siop_pci_softc), siop_pci_match, siop_pci_attach
54 };
55
56 int
siop_pci_match(struct device * parent,void * match,void * aux)57 siop_pci_match( struct device *parent, void *match, void *aux)
58 {
59 struct pci_attach_args *pa = aux;
60 const struct siop_product_desc *pp;
61
62 /* look if it's a known product */
63 pp = siop_lookup_product(pa->pa_id, PCI_REVISION(pa->pa_class));
64 if (pp)
65 return 1;
66 return 0;
67 }
68
69 void
siop_pci_attach(struct device * parent,struct device * self,void * aux)70 siop_pci_attach(struct device *parent, struct device *self, void *aux)
71 {
72 struct pci_attach_args *pa = aux;
73 struct siop_pci_softc *sc = (struct siop_pci_softc *)self;
74
75 if (siop_pci_attach_common(&sc->siop_pci, &sc->siop.sc_c,
76 pa, siop_intr) == 0)
77 return;
78
79 siop_attach(&sc->siop);
80 }
81