xref: /netbsd-src/sys/dev/pci/siop_pci.c (revision 8184d5dc03eacfd0e7a669e4d7e8fddefc529123)
1*8184d5dcSuebayasi /*	$NetBSD: siop_pci.c,v 1.27 2010/11/13 13:52:08 uebayasi Exp $	*/
219ada4a8Sbouyer 
319ada4a8Sbouyer /*
419ada4a8Sbouyer  * Copyright (c) 2000 Manuel Bouyer.
519ada4a8Sbouyer  *
619ada4a8Sbouyer  * Redistribution and use in source and binary forms, with or without
719ada4a8Sbouyer  * modification, are permitted provided that the following conditions
819ada4a8Sbouyer  * are met:
919ada4a8Sbouyer  * 1. Redistributions of source code must retain the above copyright
1019ada4a8Sbouyer  *    notice, this list of conditions and the following disclaimer.
1119ada4a8Sbouyer  * 2. Redistributions in binary form must reproduce the above copyright
1219ada4a8Sbouyer  *    notice, this list of conditions and the following disclaimer in the
1319ada4a8Sbouyer  *    documentation and/or other materials provided with the distribution.
1419ada4a8Sbouyer  *
15a1c4db6cSbouyer  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16a1c4db6cSbouyer  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17a1c4db6cSbouyer  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18a1c4db6cSbouyer  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19a1c4db6cSbouyer  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20a1c4db6cSbouyer  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21a1c4db6cSbouyer  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22a1c4db6cSbouyer  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23a1c4db6cSbouyer  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24a1c4db6cSbouyer  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2519ada4a8Sbouyer  */
2619ada4a8Sbouyer 
2719ada4a8Sbouyer /* SYM53c8xx PCI-SCSI I/O Processors driver: PCI front-end */
2819ada4a8Sbouyer 
299048aaaeSlukem #include <sys/cdefs.h>
30*8184d5dcSuebayasi __KERNEL_RCSID(0, "$NetBSD: siop_pci.c,v 1.27 2010/11/13 13:52:08 uebayasi Exp $");
319048aaaeSlukem 
3219ada4a8Sbouyer #include <sys/param.h>
3319ada4a8Sbouyer #include <sys/systm.h>
3419ada4a8Sbouyer #include <sys/device.h>
3519ada4a8Sbouyer #include <sys/kernel.h>
3619ada4a8Sbouyer 
3719ada4a8Sbouyer #include <dev/pci/pcireg.h>
3819ada4a8Sbouyer #include <dev/pci/pcivar.h>
3919ada4a8Sbouyer 
4019ada4a8Sbouyer #include <dev/scsipi/scsipi_all.h>
4119ada4a8Sbouyer #include <dev/scsipi/scsipiconf.h>
4219ada4a8Sbouyer 
4397fe8b91Sbouyer #include <dev/ic/siopvar_common.h>
44a1c4db6cSbouyer #include <dev/pci/siop_pci_common.h>
4597fe8b91Sbouyer #include <dev/ic/siopvar.h>
4619ada4a8Sbouyer 
4797fe8b91Sbouyer struct siop_pci_softc {
4897fe8b91Sbouyer 	struct siop_softc siop;
4997fe8b91Sbouyer 	struct siop_pci_common_softc siop_pci;
5097fe8b91Sbouyer };
5197fe8b91Sbouyer 
52d36c43c5Sthorpej static int
siop_pci_match(device_t parent,cfdata_t match,void * aux)53a591bc88Scegger siop_pci_match(device_t parent, cfdata_t match, void *aux)
5419ada4a8Sbouyer {
5519ada4a8Sbouyer 	struct pci_attach_args *pa = aux;
5619ada4a8Sbouyer 	const struct siop_product_desc *pp;
5719ada4a8Sbouyer 
5819ada4a8Sbouyer 	/* look if it's a known product */
5919ada4a8Sbouyer 	pp = siop_lookup_product(pa->pa_id, PCI_REVISION(pa->pa_class));
6019ada4a8Sbouyer 	if (pp)
6119ada4a8Sbouyer 		return 1;
6219ada4a8Sbouyer 	return 0;
6319ada4a8Sbouyer }
6419ada4a8Sbouyer 
65d36c43c5Sthorpej static void
siop_pci_attach(device_t parent,device_t self,void * aux)66a591bc88Scegger siop_pci_attach(device_t parent, device_t self, void *aux)
6719ada4a8Sbouyer {
6819ada4a8Sbouyer 	struct pci_attach_args *pa = aux;
69b8169823Scegger 	struct siop_pci_softc *sc = device_private(self);
7019ada4a8Sbouyer 
7131ec75e9Stsutsui 	sc->siop.sc_c.sc_dev = self;
7297fe8b91Sbouyer 	if (siop_pci_attach_common(&sc->siop_pci, &sc->siop.sc_c,
7397fe8b91Sbouyer 	    pa, siop_intr) == 0)
7419ada4a8Sbouyer 		return;
755786c811Sthorpej 
7619ada4a8Sbouyer 	siop_attach(&sc->siop);
7719ada4a8Sbouyer }
78d36c43c5Sthorpej 
7931ec75e9Stsutsui CFATTACH_DECL_NEW(siop_pci, sizeof(struct siop_pci_softc),
80d36c43c5Sthorpej     siop_pci_match, siop_pci_attach, NULL, NULL);
81