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