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