esiop_pci.c revision 1.9
11.9Sthorpej/*	$NetBSD: esiop_pci.c,v 1.9 2005/06/28 00:28:42 thorpej Exp $	*/
21.1Sbouyer
31.1Sbouyer/*
41.1Sbouyer * Copyright (c) 2002 Manuel Bouyer.
51.1Sbouyer *
61.1Sbouyer * Redistribution and use in source and binary forms, with or without
71.1Sbouyer * modification, are permitted provided that the following conditions
81.1Sbouyer * are met:
91.1Sbouyer * 1. Redistributions of source code must retain the above copyright
101.1Sbouyer *    notice, this list of conditions and the following disclaimer.
111.1Sbouyer * 2. Redistributions in binary form must reproduce the above copyright
121.1Sbouyer *    notice, this list of conditions and the following disclaimer in the
131.1Sbouyer *    documentation and/or other materials provided with the distribution.
141.1Sbouyer * 3. All advertising materials mentioning features or use of this software
151.1Sbouyer *    must display the following acknowledgement:
161.2Sbouyer *	This product includes software developed by Manuel Bouyer.
171.1Sbouyer * 4. The name of the author may not be used to endorse or promote products
181.1Sbouyer *    derived from this software without specific prior written permission.
191.1Sbouyer *
201.1Sbouyer * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
211.1Sbouyer * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
221.1Sbouyer * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
231.8Sperry * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
241.1Sbouyer * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
251.1Sbouyer * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
261.1Sbouyer * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
271.1Sbouyer * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
281.1Sbouyer * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
291.1Sbouyer * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
301.1Sbouyer */
311.1Sbouyer
321.1Sbouyer/* SYM53c8xx PCI-SCSI I/O Processors driver: PCI front-end */
331.1Sbouyer
341.1Sbouyer#include <sys/cdefs.h>
351.9Sthorpej__KERNEL_RCSID(0, "$NetBSD: esiop_pci.c,v 1.9 2005/06/28 00:28:42 thorpej Exp $");
361.1Sbouyer
371.1Sbouyer#include <sys/param.h>
381.1Sbouyer#include <sys/systm.h>
391.1Sbouyer#include <sys/device.h>
401.1Sbouyer#include <sys/kernel.h>
411.6Sthorpej
421.6Sthorpej#include <uvm/uvm_extern.h>
431.1Sbouyer
441.1Sbouyer#include <dev/pci/pcireg.h>
451.1Sbouyer#include <dev/pci/pcivar.h>
461.1Sbouyer
471.1Sbouyer#include <dev/scsipi/scsipi_all.h>
481.1Sbouyer#include <dev/scsipi/scsipiconf.h>
491.1Sbouyer
501.1Sbouyer#include <dev/ic/siopvar_common.h>
511.1Sbouyer#include <dev/pci/siop_pci_common.h>
521.1Sbouyer#include <dev/ic/esiopvar.h>
531.1Sbouyer
541.1Sbouyerstruct esiop_pci_softc {
551.1Sbouyer	struct esiop_softc esiop;
561.1Sbouyer	struct siop_pci_common_softc esiop_pci;
571.1Sbouyer};
581.1Sbouyer
591.9Sthorpejstatic int
601.9Sthorpejesiop_pci_match(struct device *parent, struct cfdata *match, void *aux)
611.1Sbouyer{
621.1Sbouyer	struct pci_attach_args *pa = aux;
631.1Sbouyer	const struct siop_product_desc *pp;
641.1Sbouyer
651.1Sbouyer	/* look if it's a known product */
661.1Sbouyer	pp = siop_lookup_product(pa->pa_id, PCI_REVISION(pa->pa_class));
671.1Sbouyer	if (pp == NULL)
681.1Sbouyer		return 0;
691.1Sbouyer	/* we need 10 scratch registers and load/store */
701.1Sbouyer	if ((pp->features & SF_CHIP_10REGS) == 0)
711.1Sbouyer		return 0;
721.1Sbouyer	if ((pp->features & SF_CHIP_LS) == 0)
731.1Sbouyer		return 0;
741.1Sbouyer	return 2;
751.1Sbouyer}
761.1Sbouyer
771.9Sthorpejstatic void
781.9Sthorpejesiop_pci_attach(struct device *parent, struct device *self, void *aux)
791.1Sbouyer{
801.1Sbouyer	struct pci_attach_args *pa = aux;
811.1Sbouyer	struct esiop_pci_softc *sc = (struct esiop_pci_softc *)self;
821.1Sbouyer
831.1Sbouyer	if (siop_pci_attach_common(&sc->esiop_pci, &sc->esiop.sc_c,
841.1Sbouyer	    pa, esiop_intr) == 0)
851.1Sbouyer		return;
861.1Sbouyer
871.1Sbouyer	esiop_attach(&sc->esiop);
881.1Sbouyer}
891.9Sthorpej
901.9Sthorpej
911.9SthorpejCFATTACH_DECL(esiop_pci, sizeof(struct esiop_pci_softc),
921.9Sthorpej    esiop_pci_match, esiop_pci_attach, NULL, NULL);
93