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