Home | History | Annotate | Line # | Download | only in pci
nca_pci.c revision 1.1.14.1
      1  1.1.14.1      yamt /*	$NetBSD: nca_pci.c,v 1.1.14.1 2012/04/17 00:07:51 yamt Exp $  */
      2       1.1  jakllsch 
      3       1.1  jakllsch /*
      4       1.1  jakllsch  * Copyright (c) 2010 Jonathan A. Kollasch
      5       1.1  jakllsch  * All rights reserved.
      6       1.1  jakllsch  *
      7       1.1  jakllsch  * Redistribution and use in source and binary forms, with or without
      8       1.1  jakllsch  * modification, are permitted provided that the following conditions
      9       1.1  jakllsch  * are met:
     10       1.1  jakllsch  * 1. Redistributions of source code must retain the above copyright
     11       1.1  jakllsch  *    notice, this list of conditions and the following disclaimer.
     12       1.1  jakllsch  * 2. Redistributions in binary form must reproduce the above copyright
     13       1.1  jakllsch  *    notice, this list of conditions and the following disclaimer in the
     14       1.1  jakllsch  *    documentation and/or other materials provided with the distribution.
     15       1.1  jakllsch  *
     16       1.1  jakllsch  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     17       1.1  jakllsch  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     18       1.1  jakllsch  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     19       1.1  jakllsch  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
     20       1.1  jakllsch  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     21       1.1  jakllsch  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     22       1.1  jakllsch  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     23       1.1  jakllsch  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     24       1.1  jakllsch  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     25       1.1  jakllsch  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
     26       1.1  jakllsch  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27       1.1  jakllsch  */
     28       1.1  jakllsch 
     29       1.1  jakllsch /*
     30       1.1  jakllsch  * PCI attachment for 5380-compatible Domex 536 SCSI controller,
     31       1.1  jakllsch  * found on Domex DMX-3191D.
     32       1.1  jakllsch  */
     33       1.1  jakllsch 
     34       1.1  jakllsch #include <sys/cdefs.h>
     35  1.1.14.1      yamt __KERNEL_RCSID(0, "$NetBSD: nca_pci.c,v 1.1.14.1 2012/04/17 00:07:51 yamt Exp $");
     36       1.1  jakllsch 
     37       1.1  jakllsch #include <sys/param.h>
     38       1.1  jakllsch #include <sys/systm.h>
     39       1.1  jakllsch #include <sys/kernel.h>
     40       1.1  jakllsch #include <sys/device.h>
     41       1.1  jakllsch #include <sys/buf.h>
     42       1.1  jakllsch 
     43       1.1  jakllsch #include <sys/bus.h>
     44       1.1  jakllsch 
     45       1.1  jakllsch #include <dev/pci/pcireg.h>
     46       1.1  jakllsch #include <dev/pci/pcivar.h>
     47       1.1  jakllsch #include <dev/pci/pcidevs.h>
     48       1.1  jakllsch 
     49       1.1  jakllsch #include <dev/scsipi/scsi_all.h>
     50       1.1  jakllsch #include <dev/scsipi/scsipi_all.h>
     51       1.1  jakllsch #include <dev/scsipi/scsiconf.h>
     52       1.1  jakllsch 
     53       1.1  jakllsch #include <dev/ic/ncr5380reg.h>
     54       1.1  jakllsch #include <dev/ic/ncr5380var.h>
     55       1.1  jakllsch 
     56       1.1  jakllsch static int nca_pci_match(device_t, cfdata_t, void *);
     57       1.1  jakllsch static void nca_pci_attach(device_t, device_t, void *);
     58       1.1  jakllsch 
     59       1.1  jakllsch CFATTACH_DECL_NEW(nca_pci, sizeof(struct ncr5380_softc),
     60       1.1  jakllsch     nca_pci_match, nca_pci_attach, NULL, NULL);
     61       1.1  jakllsch 
     62       1.1  jakllsch static int
     63       1.1  jakllsch nca_pci_match(device_t parent, cfdata_t match, void *aux)
     64       1.1  jakllsch {
     65       1.1  jakllsch 	struct pci_attach_args *pa = aux;
     66       1.1  jakllsch 	if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_DOMEX &&
     67       1.1  jakllsch 	    PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_DOMEX_PCISCSI)
     68       1.1  jakllsch 		return 1;
     69       1.1  jakllsch 	return 0;
     70       1.1  jakllsch }
     71       1.1  jakllsch 
     72       1.1  jakllsch static void
     73       1.1  jakllsch nca_pci_attach(device_t parent, device_t self, void *aux)
     74       1.1  jakllsch {
     75       1.1  jakllsch 	struct ncr5380_softc *sc = device_private(self);
     76       1.1  jakllsch 	struct pci_attach_args *pa = aux;
     77       1.1  jakllsch 
     78       1.1  jakllsch 	sc->sc_dev = self;
     79       1.1  jakllsch 
     80  1.1.14.1      yamt 	pci_aprint_devinfo(pa, "SCSI controller");
     81       1.1  jakllsch 
     82       1.1  jakllsch 	if (pci_mapreg_map(pa, 0x10, PCI_MAPREG_TYPE_IO, 0,
     83       1.1  jakllsch             &sc->sc_regt, &sc->sc_regh, NULL, NULL)) {
     84       1.1  jakllsch                 aprint_error_dev(self, "could not map IO space\n");
     85       1.1  jakllsch                 return;
     86       1.1  jakllsch         }
     87       1.1  jakllsch 
     88       1.1  jakllsch 	/* The Domex 536 seems to be driven by polling,
     89       1.1  jakllsch 	 * don't bother mapping an interrupt handler.
     90       1.1  jakllsch 	 */
     91       1.1  jakllsch 
     92       1.1  jakllsch 	sc->sc_rev = NCR_VARIANT_CXD1180;
     93       1.1  jakllsch 	sc->sci_r0 = 0;
     94       1.1  jakllsch 	sc->sci_r1 = 1;
     95       1.1  jakllsch 	sc->sci_r2 = 2;
     96       1.1  jakllsch 	sc->sci_r3 = 3;
     97       1.1  jakllsch 	sc->sci_r4 = 4;
     98       1.1  jakllsch 	sc->sci_r5 = 5;
     99       1.1  jakllsch 	sc->sci_r6 = 6;
    100       1.1  jakllsch 	sc->sci_r7 = 7;
    101       1.1  jakllsch 
    102       1.1  jakllsch 	sc->sc_pio_out = ncr5380_pio_out;
    103       1.1  jakllsch 	sc->sc_pio_in =  ncr5380_pio_in;
    104       1.1  jakllsch 	sc->sc_dma_alloc = NULL;
    105       1.1  jakllsch 	sc->sc_dma_free  = NULL;
    106       1.1  jakllsch 	sc->sc_dma_setup = NULL;
    107       1.1  jakllsch 	sc->sc_dma_start = NULL;
    108       1.1  jakllsch 	sc->sc_dma_poll  = NULL;
    109       1.1  jakllsch 	sc->sc_dma_eop   = NULL;
    110       1.1  jakllsch 	sc->sc_dma_stop  = NULL;
    111       1.1  jakllsch 	sc->sc_intr_on   = NULL;
    112       1.1  jakllsch 	sc->sc_intr_off  = NULL;
    113       1.1  jakllsch 
    114       1.1  jakllsch 	sc->sc_flags |= NCR5380_FORCE_POLLING;
    115       1.1  jakllsch 
    116       1.1  jakllsch 	sc->sc_min_dma_len = 0;
    117       1.1  jakllsch 
    118       1.1  jakllsch 	sc->sc_adapter.adapt_request = ncr5380_scsipi_request;
    119       1.1  jakllsch 	sc->sc_adapter.adapt_minphys = minphys;
    120       1.1  jakllsch 
    121       1.1  jakllsch 	sc->sc_channel.chan_id = 7;
    122       1.1  jakllsch 
    123       1.1  jakllsch 	ncr5380_attach(sc);
    124       1.1  jakllsch }
    125