esiop_pci.c revision 1.18
11.18Suebayasi/*	$NetBSD: esiop_pci.c,v 1.18 2010/11/13 13:52:05 uebayasi 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 *
151.1Sbouyer * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
161.1Sbouyer * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
171.1Sbouyer * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
181.8Sperry * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
191.1Sbouyer * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
201.1Sbouyer * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
211.1Sbouyer * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
221.1Sbouyer * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
231.1Sbouyer * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
241.1Sbouyer * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
251.1Sbouyer */
261.1Sbouyer
271.1Sbouyer/* SYM53c8xx PCI-SCSI I/O Processors driver: PCI front-end */
281.1Sbouyer
291.1Sbouyer#include <sys/cdefs.h>
301.18Suebayasi__KERNEL_RCSID(0, "$NetBSD: esiop_pci.c,v 1.18 2010/11/13 13:52:05 uebayasi Exp $");
311.1Sbouyer
321.1Sbouyer#include <sys/param.h>
331.1Sbouyer#include <sys/systm.h>
341.1Sbouyer#include <sys/device.h>
351.1Sbouyer#include <sys/kernel.h>
361.6Sthorpej
371.1Sbouyer#include <dev/pci/pcireg.h>
381.1Sbouyer#include <dev/pci/pcivar.h>
391.1Sbouyer
401.1Sbouyer#include <dev/scsipi/scsipi_all.h>
411.1Sbouyer#include <dev/scsipi/scsipiconf.h>
421.1Sbouyer
431.1Sbouyer#include <dev/ic/siopvar_common.h>
441.1Sbouyer#include <dev/pci/siop_pci_common.h>
451.1Sbouyer#include <dev/ic/esiopvar.h>
461.1Sbouyer
471.1Sbouyerstruct esiop_pci_softc {
481.1Sbouyer	struct esiop_softc esiop;
491.1Sbouyer	struct siop_pci_common_softc esiop_pci;
501.1Sbouyer};
511.1Sbouyer
521.9Sthorpejstatic int
531.14Sceggeresiop_pci_match(device_t parent, cfdata_t match, void *aux)
541.1Sbouyer{
551.1Sbouyer	struct pci_attach_args *pa = aux;
561.1Sbouyer	const struct siop_product_desc *pp;
571.1Sbouyer
581.1Sbouyer	/* look if it's a known product */
591.1Sbouyer	pp = siop_lookup_product(pa->pa_id, PCI_REVISION(pa->pa_class));
601.1Sbouyer	if (pp == NULL)
611.1Sbouyer		return 0;
621.1Sbouyer	/* we need 10 scratch registers and load/store */
631.1Sbouyer	if ((pp->features & SF_CHIP_10REGS) == 0)
641.1Sbouyer		return 0;
651.1Sbouyer	if ((pp->features & SF_CHIP_LS) == 0)
661.1Sbouyer		return 0;
671.1Sbouyer	return 2;
681.1Sbouyer}
691.1Sbouyer
701.9Sthorpejstatic void
711.14Sceggeresiop_pci_attach(device_t parent, device_t self, void *aux)
721.1Sbouyer{
731.1Sbouyer	struct pci_attach_args *pa = aux;
741.15Scegger	struct esiop_pci_softc *sc = device_private(self);
751.1Sbouyer
761.16Stsutsui	sc->esiop.sc_c.sc_dev = self;
771.1Sbouyer	if (siop_pci_attach_common(&sc->esiop_pci, &sc->esiop.sc_c,
781.1Sbouyer	    pa, esiop_intr) == 0)
791.1Sbouyer		return;
801.1Sbouyer
811.1Sbouyer	esiop_attach(&sc->esiop);
821.1Sbouyer}
831.9Sthorpej
841.9Sthorpej
851.16StsutsuiCFATTACH_DECL_NEW(esiop_pci, sizeof(struct esiop_pci_softc),
861.9Sthorpej    esiop_pci_match, esiop_pci_attach, NULL, NULL);
87