cosc.c revision 1.3.2.4 1 1.3.2.4 jdolecek /* $NetBSD: cosc.c,v 1.3.2.4 2002/09/06 08:31:11 jdolecek 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
65 1.3.2.2 thorpej struct cfattach cosc_ca = {
66 1.3.2.2 thorpej sizeof(struct cosc_softc), coscmatch, coscattach
67 1.3.2.2 thorpej };
68 1.3.2.2 thorpej
69 1.3.2.2 thorpej int cosc_intr __P((void *arg));
70 1.3.2.2 thorpej int cosc_setup_dma __P((struct esc_softc *sc, void *ptr, int len,
71 1.3.2.2 thorpej int mode));
72 1.3.2.2 thorpej int cosc_build_dma_chain __P((struct esc_softc *sc,
73 1.3.2.2 thorpej struct esc_dma_chain *chain, void *p, int l));
74 1.3.2.2 thorpej int cosc_need_bump __P((struct esc_softc *sc, void *ptr, int len));
75 1.3.2.2 thorpej
76 1.3.2.2 thorpej void cosc_led __P((struct esc_softc *sc, int mode));
77 1.3.2.2 thorpej
78 1.3.2.2 thorpej #if COSC_POLL > 0
79 1.3.2.2 thorpej int cosc_poll = 1;
80 1.3.2.2 thorpej #endif
81 1.3.2.2 thorpej
82 1.3.2.2 thorpej
83 1.3.2.2 thorpej int
84 1.3.2.2 thorpej coscmatch(pdp, cf, auxp)
85 1.3.2.2 thorpej struct device *pdp;
86 1.3.2.2 thorpej struct cfdata *cf;
87 1.3.2.2 thorpej void *auxp;
88 1.3.2.2 thorpej {
89 1.3.2.2 thorpej struct podule_attach_args *pa = (struct podule_attach_args *)auxp;
90 1.3.2.2 thorpej
91 1.3.2.2 thorpej /* Look for the card */
92 1.3.2.2 thorpej
93 1.3.2.3 jdolecek if (pa->pa_product == PODULE_CONNECT32)
94 1.3.2.2 thorpej return(1);
95 1.3.2.2 thorpej
96 1.3.2.2 thorpej /* Old versions of the ROM on this card could have the wrong ID */
97 1.3.2.2 thorpej
98 1.3.2.3 jdolecek if (pa ->pa_product == PODULE_ACORN_SCSI &&
99 1.3.2.3 jdolecek strncmp(pa->pa_podule->description, "MCS", 3) == 0)
100 1.3.2.3 jdolecek return(1);
101 1.3.2.3 jdolecek return(0);
102 1.3.2.2 thorpej }
103 1.3.2.2 thorpej
104 1.3.2.2 thorpej static int dummy[6];
105 1.3.2.2 thorpej
106 1.3.2.2 thorpej void
107 1.3.2.2 thorpej coscattach(pdp, dp, auxp)
108 1.3.2.2 thorpej struct device *pdp, *dp;
109 1.3.2.2 thorpej void *auxp;
110 1.3.2.2 thorpej {
111 1.3.2.2 thorpej struct cosc_softc *sc = (struct cosc_softc *)dp;
112 1.3.2.2 thorpej struct podule_attach_args *pa;
113 1.3.2.2 thorpej cosc_regmap_p rp = &sc->sc_regmap;
114 1.3.2.2 thorpej vu_char *esc;
115 1.3.2.2 thorpej
116 1.3.2.2 thorpej pa = (struct podule_attach_args *)auxp;
117 1.3.2.2 thorpej
118 1.3.2.2 thorpej if (pa->pa_podule_number == -1)
119 1.3.2.2 thorpej panic("Podule has disappeared !");
120 1.3.2.2 thorpej
121 1.3.2.2 thorpej sc->sc_podule_number = pa->pa_podule_number;
122 1.3.2.2 thorpej sc->sc_podule = pa->pa_podule;
123 1.3.2.2 thorpej podules[sc->sc_podule_number].attached = 1;
124 1.3.2.2 thorpej
125 1.3.2.2 thorpej printf(":");
126 1.3.2.2 thorpej
127 1.3.2.2 thorpej if (pa->pa_podule->manufacturer == MANUFACTURER_ACORN
128 1.3.2.2 thorpej && pa->pa_podule->product == PODULE_ACORN_SCSI)
129 1.3.2.2 thorpej printf(" Faulty expansion card identity\n");
130 1.3.2.2 thorpej
131 1.3.2.2 thorpej sc->sc_iobase = (vu_char *)sc->sc_podule->fast_base;
132 1.3.2.2 thorpej
133 1.3.2.2 thorpej /* Select page zero (so we can see the config info) */
134 1.3.2.2 thorpej
135 1.3.2.2 thorpej sc->sc_iobase[COSC_PAGE_REGISTER] = 0;
136 1.3.2.2 thorpej
137 1.3.2.2 thorpej rp->chipreset = (vu_char *)&dummy[0];
138 1.3.2.2 thorpej rp->inten = (vu_char *)&dummy[1];
139 1.3.2.2 thorpej rp->status = (vu_char *)&dummy[2];
140 1.3.2.2 thorpej rp->term = &sc->sc_iobase[COSC_TERMINATION_CONTROL];
141 1.3.2.2 thorpej rp->led = (vu_char *)&dummy[4];
142 1.3.2.2 thorpej esc = &sc->sc_iobase[COSC_ESCOFFSET_BASE];
143 1.3.2.2 thorpej
144 1.3.2.2 thorpej rp->esc.esc_tc_low = &esc[COSC_ESCOFFSET_TCL];
145 1.3.2.2 thorpej rp->esc.esc_tc_mid = &esc[COSC_ESCOFFSET_TCM];
146 1.3.2.2 thorpej rp->esc.esc_fifo = &esc[COSC_ESCOFFSET_FIFO];
147 1.3.2.2 thorpej rp->esc.esc_command = &esc[COSC_ESCOFFSET_COMMAND];
148 1.3.2.2 thorpej rp->esc.esc_dest_id = &esc[COSC_ESCOFFSET_DESTID];
149 1.3.2.2 thorpej rp->esc.esc_timeout = &esc[COSC_ESCOFFSET_TIMEOUT];
150 1.3.2.2 thorpej rp->esc.esc_syncper = &esc[COSC_ESCOFFSET_PERIOD];
151 1.3.2.2 thorpej rp->esc.esc_syncoff = &esc[COSC_ESCOFFSET_OFFSET];
152 1.3.2.2 thorpej rp->esc.esc_config1 = &esc[COSC_ESCOFFSET_CONFIG1];
153 1.3.2.2 thorpej rp->esc.esc_clkconv = &esc[COSC_ESCOFFSET_CLOCKCONV];
154 1.3.2.2 thorpej rp->esc.esc_test = &esc[COSC_ESCOFFSET_TEST];
155 1.3.2.2 thorpej rp->esc.esc_config2 = &esc[COSC_ESCOFFSET_CONFIG2];
156 1.3.2.2 thorpej rp->esc.esc_config3 = &esc[COSC_ESCOFFSET_CONFIG3];
157 1.3.2.2 thorpej rp->esc.esc_config4 = &esc[COSC_ESCOFFSET_CONFIG4];
158 1.3.2.2 thorpej rp->esc.esc_tc_high = &esc[COSC_ESCOFFSET_TCH];
159 1.3.2.2 thorpej rp->esc.esc_fifo_bot = &esc[COSC_ESCOFFSET_FIFOBOTTOM];
160 1.3.2.2 thorpej
161 1.3.2.2 thorpej *rp->esc.esc_command = ESC_CMD_RESET_CHIP;
162 1.3.2.2 thorpej delay(1000);
163 1.3.2.2 thorpej *rp->esc.esc_command = ESC_CMD_NOP;
164 1.3.2.2 thorpej
165 1.3.2.2 thorpej /* See if we recognise the controller */
166 1.3.2.2 thorpej
167 1.3.2.2 thorpej switch (*rp->esc.esc_tc_high) {
168 1.3.2.2 thorpej case 0x12:
169 1.3.2.2 thorpej printf(" AM53CF94");
170 1.3.2.2 thorpej break;
171 1.3.2.2 thorpej default:
172 1.3.2.2 thorpej printf(" Unknown controller (%02x)", *rp->esc.esc_tc_high);
173 1.3.2.2 thorpej break;
174 1.3.2.2 thorpej }
175 1.3.2.2 thorpej
176 1.3.2.2 thorpej /* Set termination power */
177 1.3.2.2 thorpej
178 1.3.2.2 thorpej if (sc->sc_iobase[COSC_CONFIG_TERMINATION] & COSC_CONFIG_TERMINATION_ON) {
179 1.3.2.2 thorpej printf(" termpwr on");
180 1.3.2.2 thorpej sc->sc_iobase[COSC_TERMINATION_CONTROL] = COSC_TERMINATION_ON;
181 1.3.2.2 thorpej } else {
182 1.3.2.2 thorpej printf(" termpwr off");
183 1.3.2.2 thorpej sc->sc_iobase[COSC_TERMINATION_CONTROL] = COSC_TERMINATION_OFF;
184 1.3.2.2 thorpej }
185 1.3.2.2 thorpej
186 1.3.2.2 thorpej /* Don't know what this is for */
187 1.3.2.2 thorpej
188 1.3.2.2 thorpej {
189 1.3.2.2 thorpej int byte;
190 1.3.2.2 thorpej int loop;
191 1.3.2.2 thorpej
192 1.3.2.2 thorpej byte = sc->sc_iobase[COSC_REGISTER_01];
193 1.3.2.2 thorpej byte = 0;
194 1.3.2.2 thorpej for (loop = 0; loop < 8; ++loop) {
195 1.3.2.2 thorpej if (sc->sc_iobase[COSC_REGISTER_00] & 0x01)
196 1.3.2.2 thorpej byte |= (1 << loop);
197 1.3.2.2 thorpej }
198 1.3.2.2 thorpej printf(" byte=%02x", byte);
199 1.3.2.2 thorpej }
200 1.3.2.2 thorpej
201 1.3.2.2 thorpej /*
202 1.3.2.2 thorpej * Control register 4 is an AMD special (not on FAS216)
203 1.3.2.2 thorpej *
204 1.3.2.2 thorpej * The powerdown and glitch eater facilities could be useful
205 1.3.2.2 thorpej * Use the podule configuration for this register
206 1.3.2.2 thorpej */
207 1.3.2.2 thorpej
208 1.3.2.2 thorpej sc->sc_softc.sc_config4 = sc->sc_iobase[COSC_CONFIG_CONTROL_REG4];
209 1.3.2.2 thorpej
210 1.3.2.2 thorpej sc->sc_softc.sc_esc = (esc_regmap_p)rp;
211 1.3.2.2 thorpej /* sc->sc_softc.sc_spec = &sc->sc_specific;*/
212 1.3.2.2 thorpej
213 1.3.2.2 thorpej sc->sc_softc.sc_led = cosc_led;
214 1.3.2.2 thorpej sc->sc_softc.sc_setup_dma = cosc_setup_dma;
215 1.3.2.2 thorpej sc->sc_softc.sc_build_dma_chain = cosc_build_dma_chain;
216 1.3.2.2 thorpej sc->sc_softc.sc_need_bump = cosc_need_bump;
217 1.3.2.2 thorpej
218 1.3.2.2 thorpej sc->sc_softc.sc_clock_freq = 40; /* Connect32 runs at 40MHz */
219 1.3.2.2 thorpej sc->sc_softc.sc_timeout = 250; /* Set default timeout to 250ms */
220 1.3.2.2 thorpej sc->sc_softc.sc_config_flags = ESC_NO_DMA;
221 1.3.2.2 thorpej sc->sc_softc.sc_host_id = sc->sc_iobase[COSC_CONFIG_CONTROL_REG1] & ESC_DEST_ID_MASK;
222 1.3.2.2 thorpej
223 1.3.2.2 thorpej printf(" hostid=%d", sc->sc_softc.sc_host_id);
224 1.3.2.2 thorpej
225 1.3.2.2 thorpej #if COSC_POLL > 0
226 1.3.2.2 thorpej if (boot_args)
227 1.3.2.2 thorpej get_bootconf_option(boot_args, "coscpoll",
228 1.3.2.2 thorpej BOOTOPT_TYPE_BOOLEAN, &cosc_poll);
229 1.3.2.2 thorpej
230 1.3.2.4 jdolecek if (cosc_poll) {
231 1.3.2.2 thorpej printf(" polling");
232 1.3.2.4 jdolecek sc->sc_softc.sc_adapter.adapt_flags |= SCSIPI_ADAPT_POLL_ONLY;
233 1.3.2.4 jdolecek }
234 1.3.2.2 thorpej #endif
235 1.3.2.2 thorpej
236 1.3.2.2 thorpej sc->sc_softc.sc_bump_sz = NBPG;
237 1.3.2.2 thorpej sc->sc_softc.sc_bump_pa = 0x0;
238 1.3.2.2 thorpej
239 1.3.2.2 thorpej escinitialize((struct esc_softc *)sc);
240 1.3.2.2 thorpej
241 1.3.2.2 thorpej sc->sc_softc.sc_adapter.adapt_dev = &sc->sc_softc.sc_dev;
242 1.3.2.2 thorpej sc->sc_softc.sc_adapter.adapt_nchannels = 1;
243 1.3.2.2 thorpej sc->sc_softc.sc_adapter.adapt_openings = 7;
244 1.3.2.2 thorpej sc->sc_softc.sc_adapter.adapt_max_periph = 1;
245 1.3.2.2 thorpej sc->sc_softc.sc_adapter.adapt_ioctl = NULL;
246 1.3.2.2 thorpej sc->sc_softc.sc_adapter.adapt_minphys = esc_minphys;
247 1.3.2.4 jdolecek sc->sc_softc.sc_adapter.adapt_request = esc_scsi_request;
248 1.3.2.2 thorpej
249 1.3.2.2 thorpej sc->sc_softc.sc_channel.chan_adapter = &sc->sc_softc.sc_adapter;
250 1.3.2.2 thorpej sc->sc_softc.sc_channel.chan_bustype = &scsi_bustype;
251 1.3.2.2 thorpej sc->sc_softc.sc_channel.chan_channel = 0;
252 1.3.2.2 thorpej sc->sc_softc.sc_channel.chan_ntargets = 8;
253 1.3.2.2 thorpej sc->sc_softc.sc_channel.chan_nluns = 8;
254 1.3.2.2 thorpej sc->sc_softc.sc_channel.chan_id = sc->sc_softc.sc_host_id;
255 1.3.2.2 thorpej
256 1.3.2.2 thorpej /* initialise the card */
257 1.3.2.2 thorpej #if 0
258 1.3.2.2 thorpej *rp->inten = (COSC_POLL?0:1);
259 1.3.2.2 thorpej *rp->led = 0;
260 1.3.2.2 thorpej #endif
261 1.3.2.2 thorpej
262 1.3.2.2 thorpej sc->sc_softc.sc_ih.ih_func = cosc_intr;
263 1.3.2.2 thorpej sc->sc_softc.sc_ih.ih_arg = &sc->sc_softc;
264 1.3.2.2 thorpej sc->sc_softc.sc_ih.ih_level = IPL_BIO;
265 1.3.2.2 thorpej sc->sc_softc.sc_ih.ih_name = "scsi: cosc";
266 1.3.2.2 thorpej sc->sc_softc.sc_ih.ih_maskaddr = sc->sc_podule->irq_addr;
267 1.3.2.2 thorpej sc->sc_softc.sc_ih.ih_maskbits = sc->sc_podule->irq_mask;
268 1.3.2.2 thorpej
269 1.3.2.2 thorpej #if COSC_POLL > 0
270 1.3.2.2 thorpej if (!cosc_poll)
271 1.3.2.2 thorpej #endif
272 1.3.2.2 thorpej {
273 1.3.2.2 thorpej evcnt_attach_dynamic(&sc->sc_intrcnt, EVCNT_TYPE_INTR, NULL,
274 1.3.2.2 thorpej dp->dv_xname, "intr");
275 1.3.2.2 thorpej sc->sc_ih = podulebus_irq_establish(pa->pa_ih, IPL_BIO,
276 1.3.2.2 thorpej cosc_intr, sc, &sc->sc_intrcnt);
277 1.3.2.2 thorpej if (sc->sc_ih == NULL)
278 1.3.2.2 thorpej panic("%s: Cannot install IRQ handler\n",
279 1.3.2.2 thorpej dp->dv_xname);
280 1.3.2.2 thorpej }
281 1.3.2.2 thorpej
282 1.3.2.2 thorpej printf("\n");
283 1.3.2.2 thorpej
284 1.3.2.2 thorpej /* attach all scsi units on us */
285 1.3.2.2 thorpej config_found(dp, &sc->sc_softc.sc_channel, scsiprint);
286 1.3.2.2 thorpej }
287 1.3.2.2 thorpej
288 1.3.2.2 thorpej
289 1.3.2.2 thorpej /* Turn on/off led */
290 1.3.2.2 thorpej
291 1.3.2.2 thorpej void
292 1.3.2.2 thorpej cosc_led(sc, mode)
293 1.3.2.2 thorpej struct esc_softc *sc;
294 1.3.2.2 thorpej int mode;
295 1.3.2.2 thorpej {
296 1.3.2.2 thorpej cosc_regmap_p rp;
297 1.3.2.2 thorpej
298 1.3.2.2 thorpej rp = (cosc_regmap_p)sc->sc_esc;
299 1.3.2.2 thorpej
300 1.3.2.2 thorpej if (mode) {
301 1.3.2.2 thorpej sc->sc_led_status++;
302 1.3.2.2 thorpej } else {
303 1.3.2.2 thorpej if (sc->sc_led_status)
304 1.3.2.2 thorpej sc->sc_led_status--;
305 1.3.2.2 thorpej }
306 1.3.2.2 thorpej /* *rp->led = (sc->sc_led_status?1:0);*/
307 1.3.2.2 thorpej }
308 1.3.2.2 thorpej
309 1.3.2.2 thorpej
310 1.3.2.2 thorpej int
311 1.3.2.2 thorpej cosc_intr(arg)
312 1.3.2.2 thorpej void *arg;
313 1.3.2.2 thorpej {
314 1.3.2.2 thorpej struct esc_softc *dev = arg;
315 1.3.2.2 thorpej cosc_regmap_p rp;
316 1.3.2.2 thorpej int quickints;
317 1.3.2.2 thorpej
318 1.3.2.2 thorpej rp = (cosc_regmap_p)dev->sc_esc;
319 1.3.2.2 thorpej
320 1.3.2.2 thorpej printf("cosc_intr:%08x %02x\n", (u_int)rp->esc.esc_status, *rp->esc.esc_status);
321 1.3.2.2 thorpej
322 1.3.2.2 thorpej if (*rp->esc.esc_status & ESC_STAT_INTERRUPT_PENDING) {
323 1.3.2.2 thorpej quickints = 16;
324 1.3.2.2 thorpej do {
325 1.3.2.2 thorpej dev->sc_status = *rp->esc.esc_status;
326 1.3.2.2 thorpej dev->sc_interrupt = *rp->esc.esc_interrupt;
327 1.3.2.2 thorpej
328 1.3.2.2 thorpej if (dev->sc_interrupt & ESC_INT_RESELECTED) {
329 1.3.2.2 thorpej dev->sc_resel[0] = *rp->esc.esc_fifo;
330 1.3.2.2 thorpej dev->sc_resel[1] = *rp->esc.esc_fifo;
331 1.3.2.2 thorpej }
332 1.3.2.2 thorpej
333 1.3.2.2 thorpej escintr(dev);
334 1.3.2.2 thorpej
335 1.3.2.2 thorpej } while((*rp->esc.esc_status & ESC_STAT_INTERRUPT_PENDING)
336 1.3.2.2 thorpej && --quickints);
337 1.3.2.2 thorpej }
338 1.3.2.2 thorpej
339 1.3.2.2 thorpej return(0); /* Pass interrupt on down the chain */
340 1.3.2.2 thorpej }
341 1.3.2.2 thorpej
342 1.3.2.2 thorpej
343 1.3.2.2 thorpej /* Load transfer address into dma register */
344 1.3.2.2 thorpej
345 1.3.2.2 thorpej void
346 1.3.2.2 thorpej cosc_set_dma_adr(sc, ptr)
347 1.3.2.2 thorpej struct esc_softc *sc;
348 1.3.2.2 thorpej void *ptr;
349 1.3.2.2 thorpej {
350 1.3.2.2 thorpej printf("cosc_set_dma_adr(sc = 0x%08x, ptr = 0x%08x)\n", (u_int)sc, (u_int)ptr);
351 1.3.2.2 thorpej return;
352 1.3.2.2 thorpej }
353 1.3.2.2 thorpej
354 1.3.2.2 thorpej
355 1.3.2.2 thorpej /* Set DMA transfer counter */
356 1.3.2.2 thorpej
357 1.3.2.2 thorpej void
358 1.3.2.2 thorpej cosc_set_dma_tc(sc, len)
359 1.3.2.2 thorpej struct esc_softc *sc;
360 1.3.2.2 thorpej unsigned int len;
361 1.3.2.2 thorpej {
362 1.3.2.2 thorpej printf("cosc_set_dma_tc(sc, len = 0x%08x)", len);
363 1.3.2.2 thorpej
364 1.3.2.2 thorpej /* Set the transfer size on the SCSI controller */
365 1.3.2.2 thorpej
366 1.3.2.2 thorpej *sc->sc_esc->esc_tc_low = len; len >>= 8;
367 1.3.2.2 thorpej *sc->sc_esc->esc_tc_mid = len; len >>= 8;
368 1.3.2.2 thorpej *sc->sc_esc->esc_tc_high = len;
369 1.3.2.2 thorpej }
370 1.3.2.2 thorpej
371 1.3.2.2 thorpej
372 1.3.2.2 thorpej /* Set DMA mode */
373 1.3.2.2 thorpej
374 1.3.2.2 thorpej void
375 1.3.2.2 thorpej cosc_set_dma_mode(sc, mode)
376 1.3.2.2 thorpej struct esc_softc *sc;
377 1.3.2.2 thorpej int mode;
378 1.3.2.2 thorpej {
379 1.3.2.2 thorpej printf("cosc_set_dma_mode(sc, mode = %d)", mode);
380 1.3.2.2 thorpej }
381 1.3.2.2 thorpej
382 1.3.2.2 thorpej
383 1.3.2.2 thorpej /* Initialize DMA for transfer */
384 1.3.2.2 thorpej
385 1.3.2.2 thorpej int
386 1.3.2.2 thorpej cosc_setup_dma(sc, ptr, len, mode)
387 1.3.2.2 thorpej struct esc_softc *sc;
388 1.3.2.2 thorpej void *ptr;
389 1.3.2.2 thorpej int len;
390 1.3.2.2 thorpej int mode;
391 1.3.2.2 thorpej {
392 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);*/
393 1.3.2.2 thorpej return(0);
394 1.3.2.2 thorpej
395 1.3.2.2 thorpej }
396 1.3.2.2 thorpej
397 1.3.2.2 thorpej
398 1.3.2.2 thorpej /* Check if address and len is ok for DMA transfer */
399 1.3.2.2 thorpej
400 1.3.2.2 thorpej int
401 1.3.2.2 thorpej cosc_need_bump(sc, ptr, len)
402 1.3.2.2 thorpej struct esc_softc *sc;
403 1.3.2.2 thorpej void *ptr;
404 1.3.2.2 thorpej int len;
405 1.3.2.2 thorpej {
406 1.3.2.2 thorpej int p;
407 1.3.2.2 thorpej
408 1.3.2.2 thorpej p = (int)ptr & 0x03;
409 1.3.2.2 thorpej
410 1.3.2.2 thorpej if (p) {
411 1.3.2.2 thorpej p = 4-p;
412 1.3.2.2 thorpej
413 1.3.2.2 thorpej if (len < 256)
414 1.3.2.2 thorpej p = len;
415 1.3.2.2 thorpej }
416 1.3.2.2 thorpej
417 1.3.2.2 thorpej return(p);
418 1.3.2.2 thorpej }
419 1.3.2.2 thorpej
420 1.3.2.2 thorpej
421 1.3.2.2 thorpej /* Interrupt driven routines */
422 1.3.2.2 thorpej
423 1.3.2.2 thorpej int
424 1.3.2.2 thorpej cosc_build_dma_chain(sc, chain, p, l)
425 1.3.2.2 thorpej struct esc_softc *sc;
426 1.3.2.2 thorpej struct esc_dma_chain *chain;
427 1.3.2.2 thorpej void *p;
428 1.3.2.2 thorpej int l;
429 1.3.2.2 thorpej {
430 1.3.2.2 thorpej printf("cosc_build_dma_chain()\n");
431 1.3.2.2 thorpej return(0);
432 1.3.2.2 thorpej }
433