nca_isa.c revision 1.6.6.2 1 1.6.6.2 bouyer /* $NetBSD: nca_isa.c,v 1.6.6.2 2000/11/20 11:41:19 bouyer Exp $ */
2 1.6.6.2 bouyer
3 1.6.6.2 bouyer /*-
4 1.6.6.2 bouyer * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
5 1.6.6.2 bouyer * All rights reserved.
6 1.6.6.2 bouyer *
7 1.6.6.2 bouyer * This code is derived from software contributed to The NetBSD Foundation
8 1.6.6.2 bouyer * by John M. Ruschmeyer.
9 1.6.6.2 bouyer *
10 1.6.6.2 bouyer * Redistribution and use in source and binary forms, with or without
11 1.6.6.2 bouyer * modification, are permitted provided that the following conditions
12 1.6.6.2 bouyer * are met:
13 1.6.6.2 bouyer * 1. Redistributions of source code must retain the above copyright
14 1.6.6.2 bouyer * notice, this list of conditions and the following disclaimer.
15 1.6.6.2 bouyer * 2. Redistributions in binary form must reproduce the above copyright
16 1.6.6.2 bouyer * notice, this list of conditions and the following disclaimer in the
17 1.6.6.2 bouyer * documentation and/or other materials provided with the distribution.
18 1.6.6.2 bouyer * 3. All advertising materials mentioning features or use of this software
19 1.6.6.2 bouyer * must display the following acknowledgement:
20 1.6.6.2 bouyer * This product includes software developed by the NetBSD
21 1.6.6.2 bouyer * Foundation, Inc. and its contributors.
22 1.6.6.2 bouyer * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.6.6.2 bouyer * contributors may be used to endorse or promote products derived
24 1.6.6.2 bouyer * from this software without specific prior written permission.
25 1.6.6.2 bouyer *
26 1.6.6.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.6.6.2 bouyer * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.6.6.2 bouyer * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.6.6.2 bouyer * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.6.6.2 bouyer * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.6.6.2 bouyer * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.6.6.2 bouyer * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.6.6.2 bouyer * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.6.6.2 bouyer * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.6.6.2 bouyer * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.6.6.2 bouyer * POSSIBILITY OF SUCH DAMAGE.
37 1.6.6.2 bouyer */
38 1.6.6.2 bouyer
39 1.6.6.2 bouyer /*
40 1.6.6.2 bouyer * FreeBSD generic NCR-5380/NCR-53C400 SCSI driver
41 1.6.6.2 bouyer *
42 1.6.6.2 bouyer * Copyright (C) 1994 Serge Vakulenko (vak (at) cronyx.ru)
43 1.6.6.2 bouyer *
44 1.6.6.2 bouyer * Redistribution and use in source and binary forms, with or without
45 1.6.6.2 bouyer * modification, are permitted provided that the following conditions
46 1.6.6.2 bouyer * are met:
47 1.6.6.2 bouyer * 1. Redistributions of source code must retain the above copyright
48 1.6.6.2 bouyer * notice, this list of conditions and the following disclaimer.
49 1.6.6.2 bouyer * 2. Redistributions in binary form must reproduce the above copyright
50 1.6.6.2 bouyer * notice, this list of conditions and the following disclaimer in the
51 1.6.6.2 bouyer * documentation and/or other materials provided with the distribution.
52 1.6.6.2 bouyer *
53 1.6.6.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND
54 1.6.6.2 bouyer * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
55 1.6.6.2 bouyer * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
56 1.6.6.2 bouyer * ARE DISCLAIMED. IN NO EVENT SHALL THE DEVELOPERS BE LIABLE
57 1.6.6.2 bouyer * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
58 1.6.6.2 bouyer * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
59 1.6.6.2 bouyer * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60 1.6.6.2 bouyer * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61 1.6.6.2 bouyer * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62 1.6.6.2 bouyer * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63 1.6.6.2 bouyer * SUCH DAMAGE.
64 1.6.6.2 bouyer */
65 1.6.6.2 bouyer
66 1.6.6.2 bouyer #include <sys/param.h>
67 1.6.6.2 bouyer #include <sys/systm.h>
68 1.6.6.2 bouyer #include <sys/device.h>
69 1.6.6.2 bouyer #include <sys/buf.h>
70 1.6.6.2 bouyer
71 1.6.6.2 bouyer #include <machine/bus.h>
72 1.6.6.2 bouyer #include <machine/intr.h>
73 1.6.6.2 bouyer
74 1.6.6.2 bouyer #include <dev/scsipi/scsi_all.h>
75 1.6.6.2 bouyer #include <dev/scsipi/scsipi_all.h>
76 1.6.6.2 bouyer #include <dev/scsipi/scsiconf.h>
77 1.6.6.2 bouyer
78 1.6.6.2 bouyer #include <dev/isa/isavar.h>
79 1.6.6.2 bouyer #include <dev/isa/isadmavar.h>
80 1.6.6.2 bouyer
81 1.6.6.2 bouyer #include <dev/ic/ncr5380reg.h>
82 1.6.6.2 bouyer #include <dev/ic/ncr5380var.h>
83 1.6.6.2 bouyer #include <dev/ic/ncr53c400reg.h>
84 1.6.6.2 bouyer
85 1.6.6.2 bouyer struct nca_isa_softc {
86 1.6.6.2 bouyer struct ncr5380_softc sc_ncr5380; /* glue to MI code */
87 1.6.6.2 bouyer
88 1.6.6.2 bouyer void *sc_ih;
89 1.6.6.2 bouyer int sc_irq;
90 1.6.6.2 bouyer int sc_options;
91 1.6.6.2 bouyer };
92 1.6.6.2 bouyer
93 1.6.6.2 bouyer struct nca_isa_probe_data {
94 1.6.6.2 bouyer struct device sc_dev;
95 1.6.6.2 bouyer int sc_reg_offset;
96 1.6.6.2 bouyer int sc_host_type;
97 1.6.6.2 bouyer };
98 1.6.6.2 bouyer
99 1.6.6.2 bouyer int nca_isa_find __P((bus_space_tag_t, bus_space_handle_t, bus_size_t,
100 1.6.6.2 bouyer struct nca_isa_probe_data *));
101 1.6.6.2 bouyer int nca_isa_match __P((struct device *, struct cfdata *, void *));
102 1.6.6.2 bouyer void nca_isa_attach __P((struct device *, struct device *, void *));
103 1.6.6.2 bouyer int nca_isa_test __P((bus_space_tag_t, bus_space_handle_t, bus_size_t));
104 1.6.6.2 bouyer
105 1.6.6.2 bouyer struct cfattach nca_isa_ca = {
106 1.6.6.2 bouyer sizeof(struct nca_isa_softc), nca_isa_match, nca_isa_attach
107 1.6.6.2 bouyer };
108 1.6.6.2 bouyer
109 1.6.6.2 bouyer
110 1.6.6.2 bouyer /* Supported controller types */
111 1.6.6.2 bouyer #define MAX_NCA_CONTROLLER 3
112 1.6.6.2 bouyer #define CTLR_NCR_5380 1
113 1.6.6.2 bouyer #define CTLR_NCR_53C400 2
114 1.6.6.2 bouyer #define CTLR_PAS16 3
115 1.6.6.2 bouyer
116 1.6.6.2 bouyer #define NCA_ISA_IOSIZE 16
117 1.6.6.2 bouyer #define MIN_DMA_LEN 128
118 1.6.6.2 bouyer
119 1.6.6.2 bouyer /* Options for disconnect/reselect, DMA, and interrupts. */
120 1.6.6.2 bouyer #define NCA_NO_DISCONNECT 0xff
121 1.6.6.2 bouyer #define NCA_NO_PARITY_CHK 0xff00
122 1.6.6.2 bouyer #define NCA_FORCE_POLLING 0x10000
123 1.6.6.2 bouyer
124 1.6.6.2 bouyer
125 1.6.6.2 bouyer /*
126 1.6.6.2 bouyer * Initialization and test function used by nca_isa_find()
127 1.6.6.2 bouyer */
128 1.6.6.2 bouyer int
129 1.6.6.2 bouyer nca_isa_test(iot, ioh, reg_offset)
130 1.6.6.2 bouyer bus_space_tag_t iot;
131 1.6.6.2 bouyer bus_space_handle_t ioh;
132 1.6.6.2 bouyer bus_size_t reg_offset;
133 1.6.6.2 bouyer {
134 1.6.6.2 bouyer /* Reset the SCSI bus. */
135 1.6.6.2 bouyer bus_space_write_1(iot, ioh, reg_offset + C80_ICR, SCI_ICMD_RST);
136 1.6.6.2 bouyer bus_space_write_1(iot, ioh, reg_offset + C80_ODR, 0);
137 1.6.6.2 bouyer /* Hold reset for at least 25 microseconds. */
138 1.6.6.2 bouyer delay(500);
139 1.6.6.2 bouyer /* Check that status cleared. */
140 1.6.6.2 bouyer if (bus_space_read_1(iot, ioh, reg_offset + C80_CSBR) != SCI_BUS_RST) {
141 1.6.6.2 bouyer #ifdef DEBUG
142 1.6.6.2 bouyer printf("nca_isa_find: reset status not cleared [0x%x]\n",
143 1.6.6.2 bouyer bus_space_read_1(iot, ioh, reg_offset+C80_CSBR));
144 1.6.6.2 bouyer #endif
145 1.6.6.2 bouyer bus_space_write_1(iot, ioh, reg_offset+C80_ICR, 0);
146 1.6.6.2 bouyer return 0;
147 1.6.6.2 bouyer }
148 1.6.6.2 bouyer /* Clear reset. */
149 1.6.6.2 bouyer bus_space_write_1(iot, ioh, reg_offset + C80_ICR, 0);
150 1.6.6.2 bouyer /* Wait a Bus Clear Delay (800 ns + bus free delay 800 ns). */
151 1.6.6.2 bouyer delay(16000);
152 1.6.6.2 bouyer
153 1.6.6.2 bouyer /* Read RPI port, resetting parity/interrupt state. */
154 1.6.6.2 bouyer bus_space_read_1(iot, ioh, reg_offset + C80_RPIR);
155 1.6.6.2 bouyer
156 1.6.6.2 bouyer /* Test BSR: parity error, interrupt request and busy loss state
157 1.6.6.2 bouyer * should be cleared. */
158 1.6.6.2 bouyer if (bus_space_read_1(iot, ioh, reg_offset + C80_BSR) & (SCI_CSR_PERR |
159 1.6.6.2 bouyer SCI_CSR_INT | SCI_CSR_DISC)) {
160 1.6.6.2 bouyer #ifdef DEBUG
161 1.6.6.2 bouyer printf("nca_isa_find: Parity/Interrupt/Busy not cleared [0x%x]\n",
162 1.6.6.2 bouyer bus_space_read_1(iot, ioh, reg_offset+C80_BSR));
163 1.6.6.2 bouyer #endif
164 1.6.6.2 bouyer return 0;
165 1.6.6.2 bouyer }
166 1.6.6.2 bouyer
167 1.6.6.2 bouyer /* We must have found one */
168 1.6.6.2 bouyer return 1;
169 1.6.6.2 bouyer }
170 1.6.6.2 bouyer
171 1.6.6.2 bouyer
172 1.6.6.2 bouyer /*
173 1.6.6.2 bouyer * Look for the board
174 1.6.6.2 bouyer */
175 1.6.6.2 bouyer int
176 1.6.6.2 bouyer nca_isa_find(iot, ioh, max_offset, epd)
177 1.6.6.2 bouyer bus_space_tag_t iot;
178 1.6.6.2 bouyer bus_space_handle_t ioh;
179 1.6.6.2 bouyer bus_size_t max_offset;
180 1.6.6.2 bouyer struct nca_isa_probe_data *epd;
181 1.6.6.2 bouyer {
182 1.6.6.2 bouyer /*
183 1.6.6.2 bouyer * We check for the existence of a board by trying to initialize it,
184 1.6.6.2 bouyer * Then sending the commands to reset the SCSI bus.
185 1.6.6.2 bouyer * (Unfortunately, this duplicates code which is already in the MI
186 1.6.6.2 bouyer * driver. Unavoidable as that code is not suited to this task.)
187 1.6.6.2 bouyer * This is largely stolen from FreeBSD.
188 1.6.6.2 bouyer */
189 1.6.6.2 bouyer
190 1.6.6.2 bouyer int cont_type;
191 1.6.6.2 bouyer bus_size_t base_offset, reg_offset = 0;
192 1.6.6.2 bouyer
193 1.6.6.2 bouyer /*
194 1.6.6.2 bouyer * Some notes:
195 1.6.6.2 bouyer * In the case of a port-mapped board, we should be pointing
196 1.6.6.2 bouyer * right at the chip registers (if they are there at all).
197 1.6.6.2 bouyer * For a memory-mapped card, we loop through the 16K paragraph,
198 1.6.6.2 bouyer * 8 bytes at a time, until we either find it or run out
199 1.6.6.2 bouyer * of region. This means we will probably be doing things like
200 1.6.6.2 bouyer * trying to write to ROMS, etc. Hopefully, this is not a problem.
201 1.6.6.2 bouyer */
202 1.6.6.2 bouyer
203 1.6.6.2 bouyer for (base_offset = 0; base_offset < max_offset; base_offset += 0x08) {
204 1.6.6.2 bouyer #ifdef DEBUG
205 1.6.6.2 bouyer printf("nca_isa_find: testing offset 0x%x\n", (int)base_offset);
206 1.6.6.2 bouyer #endif
207 1.6.6.2 bouyer
208 1.6.6.2 bouyer /* See if anything is there */
209 1.6.6.2 bouyer if (bus_space_read_1(iot, ioh, base_offset) == 0xff)
210 1.6.6.2 bouyer continue;
211 1.6.6.2 bouyer
212 1.6.6.2 bouyer /* Loop around for each board type */
213 1.6.6.2 bouyer for (cont_type = 1; cont_type <= MAX_NCA_CONTROLLER; cont_type++) {
214 1.6.6.2 bouyer /* Per-controller initialization */
215 1.6.6.2 bouyer switch (cont_type) {
216 1.6.6.2 bouyer case CTLR_NCR_5380:
217 1.6.6.2 bouyer /* No special inits */
218 1.6.6.2 bouyer reg_offset = 0;
219 1.6.6.2 bouyer break;
220 1.6.6.2 bouyer case CTLR_NCR_53C400:
221 1.6.6.2 bouyer /* Reset into 5380-compat. mode */
222 1.6.6.2 bouyer bus_space_write_1(iot, ioh,
223 1.6.6.2 bouyer base_offset + C400_CSR,
224 1.6.6.2 bouyer C400_CSR_5380_ENABLE);
225 1.6.6.2 bouyer reg_offset = C400_5380_REG_OFFSET;
226 1.6.6.2 bouyer break;
227 1.6.6.2 bouyer case CTLR_PAS16:
228 1.6.6.2 bouyer /* Not currently supported */
229 1.6.6.2 bouyer reg_offset = 0;
230 1.6.6.2 bouyer cont_type = 0;
231 1.6.6.2 bouyer continue;
232 1.6.6.2 bouyer }
233 1.6.6.2 bouyer
234 1.6.6.2 bouyer /* Initialize controller and bus */
235 1.6.6.2 bouyer if (nca_isa_test(iot, ioh, base_offset+reg_offset)) {
236 1.6.6.2 bouyer epd->sc_reg_offset = base_offset;
237 1.6.6.2 bouyer epd->sc_host_type = cont_type;
238 1.6.6.2 bouyer return cont_type; /* This must be it */
239 1.6.6.2 bouyer }
240 1.6.6.2 bouyer }
241 1.6.6.2 bouyer }
242 1.6.6.2 bouyer
243 1.6.6.2 bouyer /* If we got here, we didn't find one */
244 1.6.6.2 bouyer return 0;
245 1.6.6.2 bouyer }
246 1.6.6.2 bouyer
247 1.6.6.2 bouyer
248 1.6.6.2 bouyer /*
249 1.6.6.2 bouyer * See if there is anything at the config'd address.
250 1.6.6.2 bouyer * If so, call the real probe to see what it is.
251 1.6.6.2 bouyer */
252 1.6.6.2 bouyer int
253 1.6.6.2 bouyer nca_isa_match(parent, match, aux)
254 1.6.6.2 bouyer struct device *parent;
255 1.6.6.2 bouyer struct cfdata *match;
256 1.6.6.2 bouyer void *aux;
257 1.6.6.2 bouyer {
258 1.6.6.2 bouyer struct isa_attach_args *ia = aux;
259 1.6.6.2 bouyer bus_space_tag_t iot = ia->ia_iot;
260 1.6.6.2 bouyer bus_space_tag_t memt = ia->ia_memt;
261 1.6.6.2 bouyer bus_space_handle_t ioh;
262 1.6.6.2 bouyer struct nca_isa_probe_data epd;
263 1.6.6.2 bouyer int rv = 0;
264 1.6.6.2 bouyer
265 1.6.6.2 bouyer /* See if we are looking for a port- or memory-mapped adapter */
266 1.6.6.2 bouyer if (ia->ia_iobase != -1) {
267 1.6.6.2 bouyer /* Port-mapped card */
268 1.6.6.2 bouyer if (bus_space_map(iot, ia->ia_iobase, NCA_ISA_IOSIZE, 0, &ioh))
269 1.6.6.2 bouyer return 0;
270 1.6.6.2 bouyer
271 1.6.6.2 bouyer /* See if a 53C80/53C400 is there */
272 1.6.6.2 bouyer rv = nca_isa_find(iot, ioh, 0x07, &epd);
273 1.6.6.2 bouyer
274 1.6.6.2 bouyer bus_space_unmap(iot, ioh, NCA_ISA_IOSIZE);
275 1.6.6.2 bouyer } else {
276 1.6.6.2 bouyer /* Memory-mapped card */
277 1.6.6.2 bouyer if (bus_space_map(memt, ia->ia_maddr, 0x4000, 0, &ioh))
278 1.6.6.2 bouyer return 0;
279 1.6.6.2 bouyer
280 1.6.6.2 bouyer /* See if a 53C80/53C400 is somewhere in this para. */
281 1.6.6.2 bouyer rv = nca_isa_find(memt, ioh, 0x03ff0, &epd);
282 1.6.6.2 bouyer
283 1.6.6.2 bouyer bus_space_unmap(memt, ioh, 0x04000);
284 1.6.6.2 bouyer }
285 1.6.6.2 bouyer
286 1.6.6.2 bouyer /* Adjust the attachment args if we found one */
287 1.6.6.2 bouyer if (rv) {
288 1.6.6.2 bouyer if (ia->ia_iobase != -1) {
289 1.6.6.2 bouyer /* Port-mapped */
290 1.6.6.2 bouyer ia->ia_iosize = NCA_ISA_IOSIZE;
291 1.6.6.2 bouyer } else {
292 1.6.6.2 bouyer /* Memory-mapped */
293 1.6.6.2 bouyer ia->ia_maddr += epd.sc_reg_offset;
294 1.6.6.2 bouyer ia->ia_msize = NCA_ISA_IOSIZE;
295 1.6.6.2 bouyer ia->ia_iosize = 0;
296 1.6.6.2 bouyer }
297 1.6.6.2 bouyer }
298 1.6.6.2 bouyer
299 1.6.6.2 bouyer return rv;
300 1.6.6.2 bouyer }
301 1.6.6.2 bouyer
302 1.6.6.2 bouyer /*
303 1.6.6.2 bouyer * Attach this instance, and then all the sub-devices
304 1.6.6.2 bouyer */
305 1.6.6.2 bouyer void
306 1.6.6.2 bouyer nca_isa_attach(parent, self, aux)
307 1.6.6.2 bouyer struct device *parent, *self;
308 1.6.6.2 bouyer void *aux;
309 1.6.6.2 bouyer {
310 1.6.6.2 bouyer struct isa_attach_args *ia = aux;
311 1.6.6.2 bouyer struct nca_isa_softc *esc = (void *)self;
312 1.6.6.2 bouyer struct ncr5380_softc *sc = &esc->sc_ncr5380;
313 1.6.6.2 bouyer bus_space_tag_t iot = ia->ia_iot;
314 1.6.6.2 bouyer bus_space_handle_t ioh;
315 1.6.6.2 bouyer struct nca_isa_probe_data epd;
316 1.6.6.2 bouyer isa_chipset_tag_t ic = ia->ia_ic;
317 1.6.6.2 bouyer
318 1.6.6.2 bouyer printf("\n");
319 1.6.6.2 bouyer
320 1.6.6.2 bouyer if (ia->ia_iobase != -1) {
321 1.6.6.2 bouyer iot = ia->ia_iot;
322 1.6.6.2 bouyer if (bus_space_map(iot, ia->ia_iobase, NCA_ISA_IOSIZE, 0, &ioh)) {
323 1.6.6.2 bouyer printf("%s: can't map i/o space\n",
324 1.6.6.2 bouyer sc->sc_dev.dv_xname);
325 1.6.6.2 bouyer return;
326 1.6.6.2 bouyer }
327 1.6.6.2 bouyer } else {
328 1.6.6.2 bouyer iot = ia->ia_memt;
329 1.6.6.2 bouyer if (bus_space_map(iot, ia->ia_maddr, NCA_ISA_IOSIZE, 0, &ioh)) {
330 1.6.6.2 bouyer printf("%s: can't map mem space\n",
331 1.6.6.2 bouyer sc->sc_dev.dv_xname);
332 1.6.6.2 bouyer return;
333 1.6.6.2 bouyer }
334 1.6.6.2 bouyer }
335 1.6.6.2 bouyer
336 1.6.6.2 bouyer switch (nca_isa_find(iot, ioh, NCA_ISA_IOSIZE, &epd)) {
337 1.6.6.2 bouyer case 0:
338 1.6.6.2 bouyer /* Not found- must have gone away */
339 1.6.6.2 bouyer printf("%s: nca_isa_find failed\n", sc->sc_dev.dv_xname);
340 1.6.6.2 bouyer return;
341 1.6.6.2 bouyer case CTLR_NCR_5380:
342 1.6.6.2 bouyer printf("%s: NCR 53C80 detected\n", sc->sc_dev.dv_xname);
343 1.6.6.2 bouyer sc->sci_r0 = 0;
344 1.6.6.2 bouyer sc->sci_r1 = 1;
345 1.6.6.2 bouyer sc->sci_r2 = 2;
346 1.6.6.2 bouyer sc->sci_r3 = 3;
347 1.6.6.2 bouyer sc->sci_r4 = 4;
348 1.6.6.2 bouyer sc->sci_r5 = 5;
349 1.6.6.2 bouyer sc->sci_r6 = 6;
350 1.6.6.2 bouyer sc->sci_r7 = 7;
351 1.6.6.2 bouyer sc->sc_rev = NCR_VARIANT_NCR5380;
352 1.6.6.2 bouyer break;
353 1.6.6.2 bouyer case CTLR_NCR_53C400:
354 1.6.6.2 bouyer printf("%s: NCR 53C400 detected\n", sc->sc_dev.dv_xname);
355 1.6.6.2 bouyer sc->sci_r0 = C400_5380_REG_OFFSET + 0;
356 1.6.6.2 bouyer sc->sci_r1 = C400_5380_REG_OFFSET + 1;
357 1.6.6.2 bouyer sc->sci_r2 = C400_5380_REG_OFFSET + 2;
358 1.6.6.2 bouyer sc->sci_r3 = C400_5380_REG_OFFSET + 3;
359 1.6.6.2 bouyer sc->sci_r4 = C400_5380_REG_OFFSET + 4;
360 1.6.6.2 bouyer sc->sci_r5 = C400_5380_REG_OFFSET + 5;
361 1.6.6.2 bouyer sc->sci_r6 = C400_5380_REG_OFFSET + 6;
362 1.6.6.2 bouyer sc->sci_r7 = C400_5380_REG_OFFSET + 7;
363 1.6.6.2 bouyer sc->sc_rev = NCR_VARIANT_NCR53C400;
364 1.6.6.2 bouyer break;
365 1.6.6.2 bouyer case CTLR_PAS16:
366 1.6.6.2 bouyer printf("%s: ProAudio Spectrum 16 detected\n", sc->sc_dev.dv_xname);
367 1.6.6.2 bouyer sc->sc_rev = NCR_VARIANT_PAS16;
368 1.6.6.2 bouyer break;
369 1.6.6.2 bouyer }
370 1.6.6.2 bouyer
371 1.6.6.2 bouyer
372 1.6.6.2 bouyer /*
373 1.6.6.2 bouyer * MD function pointers used by the MI code.
374 1.6.6.2 bouyer */
375 1.6.6.2 bouyer sc->sc_pio_out = ncr5380_pio_out;
376 1.6.6.2 bouyer sc->sc_pio_in = ncr5380_pio_in;
377 1.6.6.2 bouyer sc->sc_dma_alloc = NULL;
378 1.6.6.2 bouyer sc->sc_dma_free = NULL;
379 1.6.6.2 bouyer sc->sc_dma_setup = NULL;
380 1.6.6.2 bouyer sc->sc_dma_start = NULL;
381 1.6.6.2 bouyer sc->sc_dma_poll = NULL;
382 1.6.6.2 bouyer sc->sc_dma_eop = NULL;
383 1.6.6.2 bouyer sc->sc_dma_stop = NULL;
384 1.6.6.2 bouyer sc->sc_intr_on = NULL;
385 1.6.6.2 bouyer sc->sc_intr_off = NULL;
386 1.6.6.2 bouyer
387 1.6.6.2 bouyer if (ia->ia_irq != IRQUNK) {
388 1.6.6.2 bouyer esc->sc_ih = isa_intr_establish(ic, ia->ia_irq, IST_EDGE,
389 1.6.6.2 bouyer IPL_BIO, ncr5380_intr, esc);
390 1.6.6.2 bouyer if (esc->sc_ih == NULL) {
391 1.6.6.2 bouyer printf("nca: couldn't establish interrupt\n");
392 1.6.6.2 bouyer return;
393 1.6.6.2 bouyer }
394 1.6.6.2 bouyer } else
395 1.6.6.2 bouyer sc->sc_flags |= NCR5380_FORCE_POLLING;
396 1.6.6.2 bouyer
397 1.6.6.2 bouyer
398 1.6.6.2 bouyer /*
399 1.6.6.2 bouyer * Support the "options" (config file flags).
400 1.6.6.2 bouyer * Disconnect/reselect is a per-target mask.
401 1.6.6.2 bouyer * Interrupts and DMA are per-controller.
402 1.6.6.2 bouyer */
403 1.6.6.2 bouyer #if 0
404 1.6.6.2 bouyer esc->sc_options = 0x00000; /* no options */
405 1.6.6.2 bouyer #else
406 1.6.6.2 bouyer esc->sc_options = 0x0ffff; /* all options except force poll */
407 1.6.6.2 bouyer #endif
408 1.6.6.2 bouyer
409 1.6.6.2 bouyer sc->sc_no_disconnect =
410 1.6.6.2 bouyer (esc->sc_options & NCA_NO_DISCONNECT);
411 1.6.6.2 bouyer sc->sc_parity_disable =
412 1.6.6.2 bouyer (esc->sc_options & NCA_NO_PARITY_CHK) >> 8;
413 1.6.6.2 bouyer if (esc->sc_options & NCA_FORCE_POLLING)
414 1.6.6.2 bouyer sc->sc_flags |= NCR5380_FORCE_POLLING;
415 1.6.6.2 bouyer sc->sc_min_dma_len = MIN_DMA_LEN;
416 1.6.6.2 bouyer
417 1.6.6.2 bouyer
418 1.6.6.2 bouyer /*
419 1.6.6.2 bouyer * Initialize fields used by the MI code
420 1.6.6.2 bouyer */
421 1.6.6.2 bouyer sc->sc_regt = iot;
422 1.6.6.2 bouyer sc->sc_regh = ioh;
423 1.6.6.2 bouyer
424 1.6.6.2 bouyer /*
425 1.6.6.2 bouyer * Fill in our portion of the scsipi_adapter.
426 1.6.6.2 bouyer */
427 1.6.6.2 bouyer sc->sc_adapter.adapt_request = ncr5380_scsipi_request;
428 1.6.6.2 bouyer sc->sc_adapter.adapt_minphys = minphys;
429 1.6.6.2 bouyer
430 1.6.6.2 bouyer /*
431 1.6.6.2 bouyer * Fill in our portion of the scsipi_channel.
432 1.6.6.2 bouyer */
433 1.6.6.2 bouyer
434 1.6.6.2 bouyer sc->sc_channel.chan_id = 7;
435 1.6.6.2 bouyer
436 1.6.6.2 bouyer /*
437 1.6.6.2 bouyer * Initialize nca board itself.
438 1.6.6.2 bouyer */
439 1.6.6.2 bouyer ncr5380_attach(sc);
440 1.6.6.2 bouyer }
441