nca_pci.c revision 1.1.4.2 1 /* $NetBSD: nca_pci.c,v 1.1.4.2 2010/05/30 05:17:36 rmind 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.1.4.2 2010/05/30 05:17:36 rmind 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
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
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 char devinfo[128];
78
79 sc->sc_dev = self;
80
81 pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo));
82 aprint_naive(": SCSI controller\n");
83 aprint_normal(": %s (rev 0x%02x)\n", devinfo,
84 PCI_REVISION(pa->pa_class));
85
86 if (pci_mapreg_map(pa, 0x10, PCI_MAPREG_TYPE_IO, 0,
87 &sc->sc_regt, &sc->sc_regh, NULL, NULL)) {
88 aprint_error_dev(self, "could not map IO space\n");
89 return;
90 }
91
92 /* The Domex 536 seems to be driven by polling,
93 * don't bother mapping an interrupt handler.
94 */
95
96 sc->sc_rev = NCR_VARIANT_CXD1180;
97 sc->sci_r0 = 0;
98 sc->sci_r1 = 1;
99 sc->sci_r2 = 2;
100 sc->sci_r3 = 3;
101 sc->sci_r4 = 4;
102 sc->sci_r5 = 5;
103 sc->sci_r6 = 6;
104 sc->sci_r7 = 7;
105
106 sc->sc_pio_out = ncr5380_pio_out;
107 sc->sc_pio_in = ncr5380_pio_in;
108 sc->sc_dma_alloc = NULL;
109 sc->sc_dma_free = NULL;
110 sc->sc_dma_setup = NULL;
111 sc->sc_dma_start = NULL;
112 sc->sc_dma_poll = NULL;
113 sc->sc_dma_eop = NULL;
114 sc->sc_dma_stop = NULL;
115 sc->sc_intr_on = NULL;
116 sc->sc_intr_off = NULL;
117
118 sc->sc_flags |= NCR5380_FORCE_POLLING;
119
120 sc->sc_min_dma_len = 0;
121
122 sc->sc_adapter.adapt_request = ncr5380_scsipi_request;
123 sc->sc_adapter.adapt_minphys = minphys;
124
125 sc->sc_channel.chan_id = 7;
126
127 ncr5380_attach(sc);
128 }
129