root/dev/pci/iha_pci.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. iha_pci_probe
  2. iha_pci_attach

    1 /*      $OpenBSD: iha_pci.c,v 1.11 2006/11/29 00:56:51 dlg Exp $ */
    2 /*-------------------------------------------------------------------------
    3  *
    4  * Device driver for the INI-9XXXU/UW or INIC-940/950  PCI SCSI Controller.
    5  *
    6  * Written for 386bsd and FreeBSD by
    7  *      Winston Hung            <winstonh@initio.com>
    8  *
    9  * Copyright (c) 1997-1999 Initio Corp
   10  * Copyright (c) 2000-2002 Ken Westerback
   11  *
   12  * Redistribution and use in source and binary forms, with or without
   13  * modification, are permitted provided that the following conditions
   14  * are met:
   15  * 1. Redistributions of source code must retain the above copyright
   16  *    notice, this list of conditions and the following disclaimer,
   17  *    without modification, immediately at the beginning of the file.
   18  * 2. The name of the author may not be used to endorse or promote products
   19  *    derived from this software without specific prior written permission.
   20  *
   21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   24  * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
   25  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   26  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
   27  * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   29  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
   30  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
   31  * THE POSSIBILITY OF SUCH DAMAGE.
   32  *
   33  *-------------------------------------------------------------------------
   34  */
   35 #include <sys/param.h>
   36 #include <sys/systm.h>
   37 #include <sys/device.h>
   38 
   39 #include <dev/pci/pcidevs.h>
   40 #include <dev/pci/pcivar.h>
   41 
   42 #include <scsi/scsi_all.h>
   43 #include <scsi/scsiconf.h>
   44 
   45 #include <dev/ic/iha.h>
   46 
   47 int  iha_pci_probe(struct device *, void *, void *);
   48 void iha_pci_attach(struct device *, struct device *, void *);
   49 
   50 struct cfattach iha_pci_ca = {
   51         sizeof(struct iha_softc), iha_pci_probe, iha_pci_attach
   52 };
   53 
   54 int
   55 iha_pci_probe(parent, match, aux)
   56         struct device *parent;
   57         void *match;
   58         void *aux;
   59 {
   60         struct pci_attach_args *pa = aux;
   61 
   62         if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_INITIO)
   63                 switch (PCI_PRODUCT(pa->pa_id)) {
   64                 case PCI_PRODUCT_INITIO_INIC940:
   65                 case PCI_PRODUCT_INITIO_INIC950:
   66                         return (1);
   67                 }
   68 
   69         if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_DTCTECH)
   70                 switch (PCI_PRODUCT(pa->pa_id)) {
   71                 case PCI_PRODUCT_DTCTECH_DMX3194U:
   72                         return (1);
   73                 }
   74 
   75         return (0);
   76 }
   77 
   78 void
   79 iha_pci_attach(parent, self, aux)
   80         struct device *parent;
   81         struct device *self;
   82         void *aux;
   83 {
   84         struct pci_attach_args *pa = aux;
   85         struct scsibus_attach_args saa;
   86         bus_space_handle_t ioh;
   87         pci_intr_handle_t ih;
   88         struct iha_softc *sc = (void *)self;
   89         bus_space_tag_t iot;
   90         const char *intrstr;
   91         int ioh_valid;
   92                                 
   93         /*
   94          * XXX - Tried memory mapping (using code from adw and ahc)
   95          *       rather that IO mapping, but it didn't work at all..
   96          */
   97         ioh_valid = pci_mapreg_map(pa, PCI_MAPREG_START, PCI_MAPREG_TYPE_IO, 0,
   98             &iot, &ioh, NULL, NULL, 0);
   99 
  100         if (ioh_valid != 0) {
  101                 printf("%s: unable to map registers\n", sc->sc_dev.dv_xname);
  102                 return;
  103         }
  104 
  105         sc->sc_iot  = iot;
  106         sc->sc_ioh  = ioh;
  107         sc->sc_dmat = pa->pa_dmat;
  108         
  109         if (pci_intr_map(pa, &ih)) {
  110                 printf("%s: couldn't map interrupt\n", sc->sc_dev.dv_xname);
  111                 return;
  112         }
  113         intrstr = pci_intr_string(pa->pa_pc, ih);
  114 
  115         sc->sc_ih = pci_intr_establish(pa->pa_pc, ih, IPL_BIO, iha_intr, sc,
  116                                        sc->sc_dev.dv_xname);
  117 
  118         if (sc->sc_ih == NULL) {
  119                 printf(": couldn't establish interrupt");
  120                 if (intrstr != NULL)
  121                         printf(" at %s", intrstr);
  122                 printf("\n");
  123         } else {
  124                 if (intrstr != NULL)
  125                         printf(": %s\n", intrstr);
  126 
  127                 if (iha_init_tulip(sc) == 0) {
  128                         bzero(&saa, sizeof(saa));
  129                         saa.saa_sc_link = &sc->sc_link;
  130                         config_found(&sc->sc_dev, &saa, scsiprint);
  131                 }
  132         }
  133 }

/* [<][>][^][v][top][bottom][index][help] */