cosc.c revision 1.1.4.3 1 1.1.4.3 nathanw /* $NetBSD: cosc.c,v 1.1.4.3 2002/06/20 03:37:20 nathanw Exp $ */
2 1.1.4.2 nathanw
3 1.1.4.2 nathanw /*
4 1.1.4.2 nathanw * Copyright (c) 1996 Mark Brinicombe
5 1.1.4.2 nathanw * All rights reserved.
6 1.1.4.2 nathanw *
7 1.1.4.2 nathanw * Redistribution and use in source and binary forms, with or without
8 1.1.4.2 nathanw * modification, are permitted provided that the following conditions
9 1.1.4.2 nathanw * are met:
10 1.1.4.2 nathanw * 1. Redistributions of source code must retain the above copyright
11 1.1.4.2 nathanw * notice, this list of conditions and the following disclaimer.
12 1.1.4.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
13 1.1.4.2 nathanw * notice, this list of conditions and the following disclaimer in the
14 1.1.4.2 nathanw * documentation and/or other materials provided with the distribution.
15 1.1.4.2 nathanw * 3. All advertising materials mentioning features or use of this software
16 1.1.4.2 nathanw * must display the following acknowledgement:
17 1.1.4.2 nathanw * This product includes software developed by Mark Brinicombe
18 1.1.4.2 nathanw * for the NetBSD Project.
19 1.1.4.2 nathanw * 4. Neither the name of the University nor the names of its contributors
20 1.1.4.2 nathanw * may be used to endorse or promote products derived from this software
21 1.1.4.2 nathanw * without specific prior written permission.
22 1.1.4.2 nathanw *
23 1.1.4.2 nathanw * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 1.1.4.2 nathanw * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 1.1.4.2 nathanw * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 1.1.4.2 nathanw * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 1.1.4.2 nathanw * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 1.1.4.2 nathanw * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 1.1.4.2 nathanw * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 1.1.4.2 nathanw * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 1.1.4.2 nathanw * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 1.1.4.2 nathanw * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 1.1.4.2 nathanw *
34 1.1.4.2 nathanw * from: asc.c,v 1.8 1996/06/12 20:46:58 mark Exp
35 1.1.4.2 nathanw */
36 1.1.4.2 nathanw
37 1.1.4.2 nathanw /*
38 1.1.4.2 nathanw * Driver for the MCS Connect 32 SCSI 2 card with AM53C94 SCSI controller.
39 1.1.4.2 nathanw *
40 1.1.4.2 nathanw * Thanks to Mike <mcsmike (at) knipp.de> at MCS for loaning a card.
41 1.1.4.2 nathanw * Thanks to Andreas Gandor <andi (at) knipp.de> for some technical information
42 1.1.4.2 nathanw */
43 1.1.4.2 nathanw
44 1.1.4.2 nathanw #include <sys/param.h>
45 1.1.4.2 nathanw #include <sys/systm.h>
46 1.1.4.2 nathanw #include <sys/kernel.h>
47 1.1.4.2 nathanw #include <sys/device.h>
48 1.1.4.2 nathanw #include <dev/scsipi/scsi_all.h>
49 1.1.4.2 nathanw #include <dev/scsipi/scsipi_all.h>
50 1.1.4.2 nathanw #include <dev/scsipi/scsiconf.h>
51 1.1.4.2 nathanw #include <machine/bootconfig.h>
52 1.1.4.2 nathanw #include <machine/io.h>
53 1.1.4.2 nathanw #include <machine/intr.h>
54 1.1.4.2 nathanw #include <arm/arm32/katelib.h>
55 1.1.4.2 nathanw #include <acorn32/podulebus/podulebus.h>
56 1.1.4.2 nathanw #include <acorn32/podulebus/escreg.h>
57 1.1.4.2 nathanw #include <acorn32/podulebus/escvar.h>
58 1.1.4.2 nathanw #include <acorn32/podulebus/coscreg.h>
59 1.1.4.2 nathanw #include <acorn32/podulebus/coscvar.h>
60 1.1.4.2 nathanw #include <dev/podulebus/podules.h>
61 1.1.4.2 nathanw
62 1.1.4.2 nathanw void coscattach __P((struct device *, struct device *, void *));
63 1.1.4.2 nathanw int coscmatch __P((struct device *, struct cfdata *, void *));
64 1.1.4.2 nathanw void cosc_scsi_request __P((struct scsipi_channel *,
65 1.1.4.2 nathanw scsipi_adapter_req_t, void *));
66 1.1.4.2 nathanw
67 1.1.4.2 nathanw struct cfattach cosc_ca = {
68 1.1.4.2 nathanw sizeof(struct cosc_softc), coscmatch, coscattach
69 1.1.4.2 nathanw };
70 1.1.4.2 nathanw
71 1.1.4.2 nathanw int cosc_intr __P((void *arg));
72 1.1.4.2 nathanw int cosc_setup_dma __P((struct esc_softc *sc, void *ptr, int len,
73 1.1.4.2 nathanw int mode));
74 1.1.4.2 nathanw int cosc_build_dma_chain __P((struct esc_softc *sc,
75 1.1.4.2 nathanw struct esc_dma_chain *chain, void *p, int l));
76 1.1.4.2 nathanw int cosc_need_bump __P((struct esc_softc *sc, void *ptr, int len));
77 1.1.4.2 nathanw
78 1.1.4.2 nathanw void cosc_led __P((struct esc_softc *sc, int mode));
79 1.1.4.2 nathanw
80 1.1.4.2 nathanw #if COSC_POLL > 0
81 1.1.4.2 nathanw int cosc_poll = 1;
82 1.1.4.2 nathanw #endif
83 1.1.4.2 nathanw
84 1.1.4.2 nathanw
85 1.1.4.2 nathanw int
86 1.1.4.2 nathanw coscmatch(pdp, cf, auxp)
87 1.1.4.2 nathanw struct device *pdp;
88 1.1.4.2 nathanw struct cfdata *cf;
89 1.1.4.2 nathanw void *auxp;
90 1.1.4.2 nathanw {
91 1.1.4.2 nathanw struct podule_attach_args *pa = (struct podule_attach_args *)auxp;
92 1.1.4.2 nathanw
93 1.1.4.2 nathanw /* Look for the card */
94 1.1.4.2 nathanw
95 1.1.4.3 nathanw if (pa->pa_product == PODULE_CONNECT32)
96 1.1.4.2 nathanw return(1);
97 1.1.4.2 nathanw
98 1.1.4.2 nathanw /* Old versions of the ROM on this card could have the wrong ID */
99 1.1.4.2 nathanw
100 1.1.4.3 nathanw if (pa ->pa_product == PODULE_ACORN_SCSI &&
101 1.1.4.3 nathanw strncmp(pa->pa_podule->description, "MCS", 3) == 0)
102 1.1.4.3 nathanw return(1);
103 1.1.4.3 nathanw return(0);
104 1.1.4.2 nathanw }
105 1.1.4.2 nathanw
106 1.1.4.2 nathanw static int dummy[6];
107 1.1.4.2 nathanw
108 1.1.4.2 nathanw void
109 1.1.4.2 nathanw coscattach(pdp, dp, auxp)
110 1.1.4.2 nathanw struct device *pdp, *dp;
111 1.1.4.2 nathanw void *auxp;
112 1.1.4.2 nathanw {
113 1.1.4.2 nathanw struct cosc_softc *sc = (struct cosc_softc *)dp;
114 1.1.4.2 nathanw struct podule_attach_args *pa;
115 1.1.4.2 nathanw cosc_regmap_p rp = &sc->sc_regmap;
116 1.1.4.2 nathanw vu_char *esc;
117 1.1.4.2 nathanw
118 1.1.4.2 nathanw pa = (struct podule_attach_args *)auxp;
119 1.1.4.2 nathanw
120 1.1.4.2 nathanw if (pa->pa_podule_number == -1)
121 1.1.4.2 nathanw panic("Podule has disappeared !");
122 1.1.4.2 nathanw
123 1.1.4.2 nathanw sc->sc_podule_number = pa->pa_podule_number;
124 1.1.4.2 nathanw sc->sc_podule = pa->pa_podule;
125 1.1.4.2 nathanw podules[sc->sc_podule_number].attached = 1;
126 1.1.4.2 nathanw
127 1.1.4.2 nathanw printf(":");
128 1.1.4.2 nathanw
129 1.1.4.2 nathanw if (pa->pa_podule->manufacturer == MANUFACTURER_ACORN
130 1.1.4.2 nathanw && pa->pa_podule->product == PODULE_ACORN_SCSI)
131 1.1.4.2 nathanw printf(" Faulty expansion card identity\n");
132 1.1.4.2 nathanw
133 1.1.4.2 nathanw sc->sc_iobase = (vu_char *)sc->sc_podule->fast_base;
134 1.1.4.2 nathanw
135 1.1.4.2 nathanw /* Select page zero (so we can see the config info) */
136 1.1.4.2 nathanw
137 1.1.4.2 nathanw sc->sc_iobase[COSC_PAGE_REGISTER] = 0;
138 1.1.4.2 nathanw
139 1.1.4.2 nathanw rp->chipreset = (vu_char *)&dummy[0];
140 1.1.4.2 nathanw rp->inten = (vu_char *)&dummy[1];
141 1.1.4.2 nathanw rp->status = (vu_char *)&dummy[2];
142 1.1.4.2 nathanw rp->term = &sc->sc_iobase[COSC_TERMINATION_CONTROL];
143 1.1.4.2 nathanw rp->led = (vu_char *)&dummy[4];
144 1.1.4.2 nathanw esc = &sc->sc_iobase[COSC_ESCOFFSET_BASE];
145 1.1.4.2 nathanw
146 1.1.4.2 nathanw rp->esc.esc_tc_low = &esc[COSC_ESCOFFSET_TCL];
147 1.1.4.2 nathanw rp->esc.esc_tc_mid = &esc[COSC_ESCOFFSET_TCM];
148 1.1.4.2 nathanw rp->esc.esc_fifo = &esc[COSC_ESCOFFSET_FIFO];
149 1.1.4.2 nathanw rp->esc.esc_command = &esc[COSC_ESCOFFSET_COMMAND];
150 1.1.4.2 nathanw rp->esc.esc_dest_id = &esc[COSC_ESCOFFSET_DESTID];
151 1.1.4.2 nathanw rp->esc.esc_timeout = &esc[COSC_ESCOFFSET_TIMEOUT];
152 1.1.4.2 nathanw rp->esc.esc_syncper = &esc[COSC_ESCOFFSET_PERIOD];
153 1.1.4.2 nathanw rp->esc.esc_syncoff = &esc[COSC_ESCOFFSET_OFFSET];
154 1.1.4.2 nathanw rp->esc.esc_config1 = &esc[COSC_ESCOFFSET_CONFIG1];
155 1.1.4.2 nathanw rp->esc.esc_clkconv = &esc[COSC_ESCOFFSET_CLOCKCONV];
156 1.1.4.2 nathanw rp->esc.esc_test = &esc[COSC_ESCOFFSET_TEST];
157 1.1.4.2 nathanw rp->esc.esc_config2 = &esc[COSC_ESCOFFSET_CONFIG2];
158 1.1.4.2 nathanw rp->esc.esc_config3 = &esc[COSC_ESCOFFSET_CONFIG3];
159 1.1.4.2 nathanw rp->esc.esc_config4 = &esc[COSC_ESCOFFSET_CONFIG4];
160 1.1.4.2 nathanw rp->esc.esc_tc_high = &esc[COSC_ESCOFFSET_TCH];
161 1.1.4.2 nathanw rp->esc.esc_fifo_bot = &esc[COSC_ESCOFFSET_FIFOBOTTOM];
162 1.1.4.2 nathanw
163 1.1.4.2 nathanw *rp->esc.esc_command = ESC_CMD_RESET_CHIP;
164 1.1.4.2 nathanw delay(1000);
165 1.1.4.2 nathanw *rp->esc.esc_command = ESC_CMD_NOP;
166 1.1.4.2 nathanw
167 1.1.4.2 nathanw /* See if we recognise the controller */
168 1.1.4.2 nathanw
169 1.1.4.2 nathanw switch (*rp->esc.esc_tc_high) {
170 1.1.4.2 nathanw case 0x12:
171 1.1.4.2 nathanw printf(" AM53CF94");
172 1.1.4.2 nathanw break;
173 1.1.4.2 nathanw default:
174 1.1.4.2 nathanw printf(" Unknown controller (%02x)", *rp->esc.esc_tc_high);
175 1.1.4.2 nathanw break;
176 1.1.4.2 nathanw }
177 1.1.4.2 nathanw
178 1.1.4.2 nathanw /* Set termination power */
179 1.1.4.2 nathanw
180 1.1.4.2 nathanw if (sc->sc_iobase[COSC_CONFIG_TERMINATION] & COSC_CONFIG_TERMINATION_ON) {
181 1.1.4.2 nathanw printf(" termpwr on");
182 1.1.4.2 nathanw sc->sc_iobase[COSC_TERMINATION_CONTROL] = COSC_TERMINATION_ON;
183 1.1.4.2 nathanw } else {
184 1.1.4.2 nathanw printf(" termpwr off");
185 1.1.4.2 nathanw sc->sc_iobase[COSC_TERMINATION_CONTROL] = COSC_TERMINATION_OFF;
186 1.1.4.2 nathanw }
187 1.1.4.2 nathanw
188 1.1.4.2 nathanw /* Don't know what this is for */
189 1.1.4.2 nathanw
190 1.1.4.2 nathanw {
191 1.1.4.2 nathanw int byte;
192 1.1.4.2 nathanw int loop;
193 1.1.4.2 nathanw
194 1.1.4.2 nathanw byte = sc->sc_iobase[COSC_REGISTER_01];
195 1.1.4.2 nathanw byte = 0;
196 1.1.4.2 nathanw for (loop = 0; loop < 8; ++loop) {
197 1.1.4.2 nathanw if (sc->sc_iobase[COSC_REGISTER_00] & 0x01)
198 1.1.4.2 nathanw byte |= (1 << loop);
199 1.1.4.2 nathanw }
200 1.1.4.2 nathanw printf(" byte=%02x", byte);
201 1.1.4.2 nathanw }
202 1.1.4.2 nathanw
203 1.1.4.2 nathanw /*
204 1.1.4.2 nathanw * Control register 4 is an AMD special (not on FAS216)
205 1.1.4.2 nathanw *
206 1.1.4.2 nathanw * The powerdown and glitch eater facilities could be useful
207 1.1.4.2 nathanw * Use the podule configuration for this register
208 1.1.4.2 nathanw */
209 1.1.4.2 nathanw
210 1.1.4.2 nathanw sc->sc_softc.sc_config4 = sc->sc_iobase[COSC_CONFIG_CONTROL_REG4];
211 1.1.4.2 nathanw
212 1.1.4.2 nathanw sc->sc_softc.sc_esc = (esc_regmap_p)rp;
213 1.1.4.2 nathanw /* sc->sc_softc.sc_spec = &sc->sc_specific;*/
214 1.1.4.2 nathanw
215 1.1.4.2 nathanw sc->sc_softc.sc_led = cosc_led;
216 1.1.4.2 nathanw sc->sc_softc.sc_setup_dma = cosc_setup_dma;
217 1.1.4.2 nathanw sc->sc_softc.sc_build_dma_chain = cosc_build_dma_chain;
218 1.1.4.2 nathanw sc->sc_softc.sc_need_bump = cosc_need_bump;
219 1.1.4.2 nathanw
220 1.1.4.2 nathanw sc->sc_softc.sc_clock_freq = 40; /* Connect32 runs at 40MHz */
221 1.1.4.2 nathanw sc->sc_softc.sc_timeout = 250; /* Set default timeout to 250ms */
222 1.1.4.2 nathanw sc->sc_softc.sc_config_flags = ESC_NO_DMA;
223 1.1.4.2 nathanw sc->sc_softc.sc_host_id = sc->sc_iobase[COSC_CONFIG_CONTROL_REG1] & ESC_DEST_ID_MASK;
224 1.1.4.2 nathanw
225 1.1.4.2 nathanw printf(" hostid=%d", sc->sc_softc.sc_host_id);
226 1.1.4.2 nathanw
227 1.1.4.2 nathanw #if COSC_POLL > 0
228 1.1.4.2 nathanw if (boot_args)
229 1.1.4.2 nathanw get_bootconf_option(boot_args, "coscpoll",
230 1.1.4.2 nathanw BOOTOPT_TYPE_BOOLEAN, &cosc_poll);
231 1.1.4.2 nathanw
232 1.1.4.2 nathanw if (cosc_poll)
233 1.1.4.2 nathanw printf(" polling");
234 1.1.4.2 nathanw #endif
235 1.1.4.2 nathanw
236 1.1.4.2 nathanw sc->sc_softc.sc_bump_sz = NBPG;
237 1.1.4.2 nathanw sc->sc_softc.sc_bump_pa = 0x0;
238 1.1.4.2 nathanw
239 1.1.4.2 nathanw escinitialize((struct esc_softc *)sc);
240 1.1.4.2 nathanw
241 1.1.4.2 nathanw sc->sc_softc.sc_adapter.adapt_dev = &sc->sc_softc.sc_dev;
242 1.1.4.2 nathanw sc->sc_softc.sc_adapter.adapt_nchannels = 1;
243 1.1.4.2 nathanw sc->sc_softc.sc_adapter.adapt_openings = 7;
244 1.1.4.2 nathanw sc->sc_softc.sc_adapter.adapt_max_periph = 1;
245 1.1.4.2 nathanw sc->sc_softc.sc_adapter.adapt_ioctl = NULL;
246 1.1.4.2 nathanw sc->sc_softc.sc_adapter.adapt_minphys = esc_minphys;
247 1.1.4.2 nathanw sc->sc_softc.sc_adapter.adapt_request = cosc_scsi_request;
248 1.1.4.2 nathanw
249 1.1.4.2 nathanw sc->sc_softc.sc_channel.chan_adapter = &sc->sc_softc.sc_adapter;
250 1.1.4.2 nathanw sc->sc_softc.sc_channel.chan_bustype = &scsi_bustype;
251 1.1.4.2 nathanw sc->sc_softc.sc_channel.chan_channel = 0;
252 1.1.4.2 nathanw sc->sc_softc.sc_channel.chan_ntargets = 8;
253 1.1.4.2 nathanw sc->sc_softc.sc_channel.chan_nluns = 8;
254 1.1.4.2 nathanw sc->sc_softc.sc_channel.chan_id = sc->sc_softc.sc_host_id;
255 1.1.4.2 nathanw
256 1.1.4.2 nathanw /* initialise the card */
257 1.1.4.2 nathanw #if 0
258 1.1.4.2 nathanw *rp->inten = (COSC_POLL?0:1);
259 1.1.4.2 nathanw *rp->led = 0;
260 1.1.4.2 nathanw #endif
261 1.1.4.2 nathanw
262 1.1.4.2 nathanw sc->sc_softc.sc_ih.ih_func = cosc_intr;
263 1.1.4.2 nathanw sc->sc_softc.sc_ih.ih_arg = &sc->sc_softc;
264 1.1.4.2 nathanw sc->sc_softc.sc_ih.ih_level = IPL_BIO;
265 1.1.4.2 nathanw sc->sc_softc.sc_ih.ih_name = "scsi: cosc";
266 1.1.4.2 nathanw sc->sc_softc.sc_ih.ih_maskaddr = sc->sc_podule->irq_addr;
267 1.1.4.2 nathanw sc->sc_softc.sc_ih.ih_maskbits = sc->sc_podule->irq_mask;
268 1.1.4.2 nathanw
269 1.1.4.2 nathanw #if COSC_POLL > 0
270 1.1.4.2 nathanw if (!cosc_poll)
271 1.1.4.2 nathanw #endif
272 1.1.4.2 nathanw {
273 1.1.4.2 nathanw evcnt_attach_dynamic(&sc->sc_intrcnt, EVCNT_TYPE_INTR, NULL,
274 1.1.4.2 nathanw dp->dv_xname, "intr");
275 1.1.4.2 nathanw sc->sc_ih = podulebus_irq_establish(pa->pa_ih, IPL_BIO,
276 1.1.4.2 nathanw cosc_intr, sc, &sc->sc_intrcnt);
277 1.1.4.2 nathanw if (sc->sc_ih == NULL)
278 1.1.4.2 nathanw panic("%s: Cannot install IRQ handler\n",
279 1.1.4.2 nathanw dp->dv_xname);
280 1.1.4.2 nathanw }
281 1.1.4.2 nathanw
282 1.1.4.2 nathanw printf("\n");
283 1.1.4.2 nathanw
284 1.1.4.2 nathanw /* attach all scsi units on us */
285 1.1.4.2 nathanw config_found(dp, &sc->sc_softc.sc_channel, scsiprint);
286 1.1.4.2 nathanw }
287 1.1.4.2 nathanw
288 1.1.4.2 nathanw
289 1.1.4.2 nathanw /* Turn on/off led */
290 1.1.4.2 nathanw
291 1.1.4.2 nathanw void
292 1.1.4.2 nathanw cosc_led(sc, mode)
293 1.1.4.2 nathanw struct esc_softc *sc;
294 1.1.4.2 nathanw int mode;
295 1.1.4.2 nathanw {
296 1.1.4.2 nathanw cosc_regmap_p rp;
297 1.1.4.2 nathanw
298 1.1.4.2 nathanw rp = (cosc_regmap_p)sc->sc_esc;
299 1.1.4.2 nathanw
300 1.1.4.2 nathanw if (mode) {
301 1.1.4.2 nathanw sc->sc_led_status++;
302 1.1.4.2 nathanw } else {
303 1.1.4.2 nathanw if (sc->sc_led_status)
304 1.1.4.2 nathanw sc->sc_led_status--;
305 1.1.4.2 nathanw }
306 1.1.4.2 nathanw /* *rp->led = (sc->sc_led_status?1:0);*/
307 1.1.4.2 nathanw }
308 1.1.4.2 nathanw
309 1.1.4.2 nathanw
310 1.1.4.2 nathanw int
311 1.1.4.2 nathanw cosc_intr(arg)
312 1.1.4.2 nathanw void *arg;
313 1.1.4.2 nathanw {
314 1.1.4.2 nathanw struct esc_softc *dev = arg;
315 1.1.4.2 nathanw cosc_regmap_p rp;
316 1.1.4.2 nathanw int quickints;
317 1.1.4.2 nathanw
318 1.1.4.2 nathanw rp = (cosc_regmap_p)dev->sc_esc;
319 1.1.4.2 nathanw
320 1.1.4.2 nathanw printf("cosc_intr:%08x %02x\n", (u_int)rp->esc.esc_status, *rp->esc.esc_status);
321 1.1.4.2 nathanw
322 1.1.4.2 nathanw if (*rp->esc.esc_status & ESC_STAT_INTERRUPT_PENDING) {
323 1.1.4.2 nathanw quickints = 16;
324 1.1.4.2 nathanw do {
325 1.1.4.2 nathanw dev->sc_status = *rp->esc.esc_status;
326 1.1.4.2 nathanw dev->sc_interrupt = *rp->esc.esc_interrupt;
327 1.1.4.2 nathanw
328 1.1.4.2 nathanw if (dev->sc_interrupt & ESC_INT_RESELECTED) {
329 1.1.4.2 nathanw dev->sc_resel[0] = *rp->esc.esc_fifo;
330 1.1.4.2 nathanw dev->sc_resel[1] = *rp->esc.esc_fifo;
331 1.1.4.2 nathanw }
332 1.1.4.2 nathanw
333 1.1.4.2 nathanw escintr(dev);
334 1.1.4.2 nathanw
335 1.1.4.2 nathanw } while((*rp->esc.esc_status & ESC_STAT_INTERRUPT_PENDING)
336 1.1.4.2 nathanw && --quickints);
337 1.1.4.2 nathanw }
338 1.1.4.2 nathanw
339 1.1.4.2 nathanw return(0); /* Pass interrupt on down the chain */
340 1.1.4.2 nathanw }
341 1.1.4.2 nathanw
342 1.1.4.2 nathanw
343 1.1.4.2 nathanw /* Load transfer address into dma register */
344 1.1.4.2 nathanw
345 1.1.4.2 nathanw void
346 1.1.4.2 nathanw cosc_set_dma_adr(sc, ptr)
347 1.1.4.2 nathanw struct esc_softc *sc;
348 1.1.4.2 nathanw void *ptr;
349 1.1.4.2 nathanw {
350 1.1.4.2 nathanw printf("cosc_set_dma_adr(sc = 0x%08x, ptr = 0x%08x)\n", (u_int)sc, (u_int)ptr);
351 1.1.4.2 nathanw return;
352 1.1.4.2 nathanw }
353 1.1.4.2 nathanw
354 1.1.4.2 nathanw
355 1.1.4.2 nathanw /* Set DMA transfer counter */
356 1.1.4.2 nathanw
357 1.1.4.2 nathanw void
358 1.1.4.2 nathanw cosc_set_dma_tc(sc, len)
359 1.1.4.2 nathanw struct esc_softc *sc;
360 1.1.4.2 nathanw unsigned int len;
361 1.1.4.2 nathanw {
362 1.1.4.2 nathanw printf("cosc_set_dma_tc(sc, len = 0x%08x)", len);
363 1.1.4.2 nathanw
364 1.1.4.2 nathanw /* Set the transfer size on the SCSI controller */
365 1.1.4.2 nathanw
366 1.1.4.2 nathanw *sc->sc_esc->esc_tc_low = len; len >>= 8;
367 1.1.4.2 nathanw *sc->sc_esc->esc_tc_mid = len; len >>= 8;
368 1.1.4.2 nathanw *sc->sc_esc->esc_tc_high = len;
369 1.1.4.2 nathanw }
370 1.1.4.2 nathanw
371 1.1.4.2 nathanw
372 1.1.4.2 nathanw /* Set DMA mode */
373 1.1.4.2 nathanw
374 1.1.4.2 nathanw void
375 1.1.4.2 nathanw cosc_set_dma_mode(sc, mode)
376 1.1.4.2 nathanw struct esc_softc *sc;
377 1.1.4.2 nathanw int mode;
378 1.1.4.2 nathanw {
379 1.1.4.2 nathanw printf("cosc_set_dma_mode(sc, mode = %d)", mode);
380 1.1.4.2 nathanw }
381 1.1.4.2 nathanw
382 1.1.4.2 nathanw
383 1.1.4.2 nathanw /* Initialize DMA for transfer */
384 1.1.4.2 nathanw
385 1.1.4.2 nathanw int
386 1.1.4.2 nathanw cosc_setup_dma(sc, ptr, len, mode)
387 1.1.4.2 nathanw struct esc_softc *sc;
388 1.1.4.2 nathanw void *ptr;
389 1.1.4.2 nathanw int len;
390 1.1.4.2 nathanw int mode;
391 1.1.4.2 nathanw {
392 1.1.4.2 nathanw /* printf("cosc_setup_dma(sc, ptr = 0x%08x, len = 0x%08x, mode = 0x%08x)\n", (u_int)ptr, len, mode);*/
393 1.1.4.2 nathanw return(0);
394 1.1.4.2 nathanw
395 1.1.4.2 nathanw }
396 1.1.4.2 nathanw
397 1.1.4.2 nathanw
398 1.1.4.2 nathanw /* Check if address and len is ok for DMA transfer */
399 1.1.4.2 nathanw
400 1.1.4.2 nathanw int
401 1.1.4.2 nathanw cosc_need_bump(sc, ptr, len)
402 1.1.4.2 nathanw struct esc_softc *sc;
403 1.1.4.2 nathanw void *ptr;
404 1.1.4.2 nathanw int len;
405 1.1.4.2 nathanw {
406 1.1.4.2 nathanw int p;
407 1.1.4.2 nathanw
408 1.1.4.2 nathanw p = (int)ptr & 0x03;
409 1.1.4.2 nathanw
410 1.1.4.2 nathanw if (p) {
411 1.1.4.2 nathanw p = 4-p;
412 1.1.4.2 nathanw
413 1.1.4.2 nathanw if (len < 256)
414 1.1.4.2 nathanw p = len;
415 1.1.4.2 nathanw }
416 1.1.4.2 nathanw
417 1.1.4.2 nathanw return(p);
418 1.1.4.2 nathanw }
419 1.1.4.2 nathanw
420 1.1.4.2 nathanw
421 1.1.4.2 nathanw /* Interrupt driven routines */
422 1.1.4.2 nathanw
423 1.1.4.2 nathanw int
424 1.1.4.2 nathanw cosc_build_dma_chain(sc, chain, p, l)
425 1.1.4.2 nathanw struct esc_softc *sc;
426 1.1.4.2 nathanw struct esc_dma_chain *chain;
427 1.1.4.2 nathanw void *p;
428 1.1.4.2 nathanw int l;
429 1.1.4.2 nathanw {
430 1.1.4.2 nathanw printf("cosc_build_dma_chain()\n");
431 1.1.4.2 nathanw return(0);
432 1.1.4.2 nathanw }
433 1.1.4.2 nathanw
434 1.1.4.2 nathanw
435 1.1.4.2 nathanw void
436 1.1.4.2 nathanw cosc_scsi_request(chan, req, arg)
437 1.1.4.2 nathanw struct scsipi_channel *chan;
438 1.1.4.2 nathanw scsipi_adapter_req_t req;
439 1.1.4.2 nathanw void *arg;
440 1.1.4.2 nathanw {
441 1.1.4.2 nathanw struct scsipi_xfer *xs;
442 1.1.4.2 nathanw
443 1.1.4.2 nathanw switch (req) {
444 1.1.4.2 nathanw case ADAPTER_REQ_RUN_XFER:
445 1.1.4.2 nathanw xs = arg;
446 1.1.4.2 nathanw
447 1.1.4.2 nathanw #if COSC_POLL > 0
448 1.1.4.2 nathanw if (cosc_poll)
449 1.1.4.2 nathanw xs->xs_control |= XS_CTL_POLL;
450 1.1.4.2 nathanw #endif
451 1.1.4.2 nathanw #if 0
452 1.1.4.2 nathanw if (periph->periph_lun == 0)
453 1.1.4.2 nathanw printf("id=%d lun=%d cmdlen=%d datalen=%d opcode=%02x flags=%08x status=%02x blk=%02x %02x\n",
454 1.1.4.2 nathanw xs->xs_periph->periph_target, xs->xs_periph->periph_lun, xs->cmdlen, xs->datalen, xs->cmd->opcode,
455 1.1.4.2 nathanw xs->xs_control, xs->status, xs->cmd->bytes[0], xs->cmd->bytes[1]);
456 1.1.4.2 nathanw #endif
457 1.1.4.2 nathanw default:
458 1.1.4.2 nathanw }
459 1.1.4.2 nathanw esc_scsi_request(chan, req, arg);
460 1.1.4.2 nathanw }
461