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