xref: /netbsd/sys/dev/pci/btvmei.c (revision bf9ec67e)
1 /* $NetBSD: btvmei.c,v 1.7 2002/03/04 02:19:10 simonb Exp $ */
2 
3 /*
4  * Copyright (c) 1999
5  *	Matthias Drochner.  All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. The name of the author may not be used to endorse or promote products
16  *    derived from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  *
29  */
30 
31 #include <sys/cdefs.h>
32 __KERNEL_RCSID(0, "$NetBSD: btvmei.c,v 1.7 2002/03/04 02:19:10 simonb Exp $");
33 
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/kernel.h>
37 #include <sys/device.h>
38 #include <sys/proc.h>
39 #include <sys/malloc.h>
40 
41 #include <machine/bus.h>
42 #include <sys/extent.h>
43 
44 #include <dev/pci/pcireg.h>
45 #include <dev/pci/pcivar.h>
46 #include <dev/pci/pcidevs.h>
47 
48 #include <dev/vme/vmereg.h>
49 #include <dev/vme/vmevar.h>
50 
51 #include <dev/pci/btvmeireg.h>
52 #include <dev/pci/btvmeivar.h>
53 
54 static int b3_617_match __P((struct device *, struct cfdata *, void *));
55 static void b3_617_attach __P((struct device *, struct device *, void *));
56 #ifdef notyet
57 static int b3_617_detach __P((struct device *));
58 #endif
59 void b3_617_slaveconfig __P((struct device *, struct vme_attach_args *));
60 
61 static void b3_617_vmeintr __P((struct b3_617_softc *, unsigned char));
62 
63 /*
64  * mapping ressources, needed for deallocation
65  */
66 struct b3_617_vmeresc {
67 	bus_space_handle_t handle;
68 	bus_size_t len;
69 	int firstpage, maplen;
70 };
71 
72 struct cfattach btvmei_ca = {
73 	sizeof(struct b3_617_softc), b3_617_match, b3_617_attach,
74 #ifdef notyet
75 	b3_617_detach
76 #endif
77 };
78 
79 static int
80 b3_617_match(parent, match, aux)
81 	struct device *parent;
82 	struct cfdata *match;
83 	void *aux;
84 {
85 	struct pci_attach_args *pa = aux;
86 
87 	if ((PCI_VENDOR(pa->pa_id) != PCI_VENDOR_BIT3)
88 	    || (PCI_PRODUCT(pa->pa_id) != PCI_PRODUCT_BIT3_PCIVME617))
89 		return (0);
90 	return (1);
91 }
92 
93 static void
94 b3_617_attach(parent, self, aux)
95 	struct device *parent, *self;
96 	void *aux;
97 {
98 	struct b3_617_softc *sc = (struct b3_617_softc*)self;
99 	struct pci_attach_args *pa = aux;
100 	pci_chipset_tag_t pc = pa->pa_pc;
101 
102 	int rev;
103 
104 	pci_intr_handle_t ih;
105 	const char *intrstr;
106 	struct vmebus_attach_args vaa;
107 
108 	sc->sc_pc = pc;
109 	sc->sc_dmat = pa->pa_dmat;
110 
111 	rev = PCI_REVISION(pci_conf_read(pc, pa->pa_tag, PCI_CLASS_REG));
112 	printf(": BIT3 PCI-VME 617 rev %d\n", rev);
113 
114 	/*
115 	 * Map CSR and mapping table spaces.
116 	 * Don't map VME window; parts are mapped as needed to
117 	 * save kernel virtual memory space
118 	 */
119 	if (pci_mapreg_map(pa, 0x14,
120 			   PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT,
121 			   0, &sc->csrt, &sc->csrh, NULL, NULL) &&
122 	    pci_mapreg_map(pa, 0x10,
123 			   PCI_MAPREG_TYPE_IO,
124 			   0, &sc->csrt, &sc->csrh, NULL, NULL)) {
125 		printf("%s: can't map CSR space\n", self->dv_xname);
126 		return;
127 	}
128 
129 	if (pci_mapreg_map(pa, 0x18,
130 			   PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT,
131 			   0, &sc->mapt, &sc->maph, NULL, NULL)) {
132 		printf("%s: can't map map space\n", self->dv_xname);
133 		return;
134 	}
135 
136 	if (pci_mapreg_info(pc, pa->pa_tag, 0x1c,
137 			    PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT,
138 			    &sc->vmepbase, 0, 0)) {
139 		printf("%s: can't get VME range\n", self->dv_xname);
140 		return;
141 	}
142 	sc->sc_vmet = pa->pa_memt; /* XXX needed for VME mappings */
143 
144 	/* Map and establish the interrupt. */
145 	if (pci_intr_map(pa, &ih)) {
146 		printf("%s: couldn't map interrupt\n", sc->sc_dev.dv_xname);
147 		return;
148 	}
149 	intrstr = pci_intr_string(pc, ih);
150 	/*
151 	 * Use a low interrupt level (the lowest?).
152 	 * We will raise before calling a subdevice's handler.
153 	 */
154 	sc->sc_ih = pci_intr_establish(pc, ih, IPL_BIO, b3_617_intr, sc);
155 	if (sc->sc_ih == NULL) {
156 		printf("%s: couldn't establish interrupt",
157 		       sc->sc_dev.dv_xname);
158 		if (intrstr != NULL)
159 			printf(" at %s", intrstr);
160 		printf("\n");
161 		return;
162 	}
163 	printf("%s: interrupting at %s\n", sc->sc_dev.dv_xname, intrstr);
164 
165 	if (b3_617_init(sc))
166 		return;
167 
168 	/*
169 	 * set up all the tags for use by VME devices
170 	 */
171 	sc->sc_vct.cookie = self;
172 	sc->sc_vct.vct_probe = b3_617_vme_probe;
173 	sc->sc_vct.vct_map = b3_617_map_vme;
174 	sc->sc_vct.vct_unmap = b3_617_unmap_vme;
175 	sc->sc_vct.vct_int_map = b3_617_map_vmeint;
176 	sc->sc_vct.vct_int_establish = b3_617_establish_vmeint;
177 	sc->sc_vct.vct_int_disestablish = b3_617_disestablish_vmeint;
178 	sc->sc_vct.vct_dmamap_create = b3_617_dmamap_create;
179 	sc->sc_vct.vct_dmamap_destroy = b3_617_dmamap_destroy;
180 	sc->sc_vct.vct_dmamem_alloc = b3_617_dmamem_alloc;
181 	sc->sc_vct.vct_dmamem_free = b3_617_dmamem_free;
182 
183 	vaa.va_vct = &(sc->sc_vct);
184 	vaa.va_bdt = pa->pa_dmat;
185 	vaa.va_slaveconfig = b3_617_slaveconfig;
186 
187 	sc->csrwindow.offset = -1;
188 	sc->dmawindow24.offset = -1;
189 	sc->dmawindow32.offset = -1;
190 	config_found(self, &vaa, 0);
191 }
192 
193 #ifdef notyet
194 static int
195 b3_617_detach(dev)
196 	struct device *dev;
197 {
198 	struct b3_617_softc *sc = (struct b3_617_softc *)dev;
199 
200 	b3_617_halt(sc);
201 
202 	if (sc->sc_ih)
203 		pci_intr_disestablish(sc->sc_pc, sc->sc_ih);
204 
205 	bus_space_unmap(sc->sc_bc, sc->csrbase, 32);
206 	bus_space_unmap(sc->sc_bc, sc->mapbase, 64*1024);
207 
208 	return(0);
209 }
210 #endif
211 
212 void
213 b3_617_slaveconfig(dev, va)
214 	struct device *dev;
215 	struct vme_attach_args *va;
216 {
217 	struct b3_617_softc *sc = (struct b3_617_softc *)dev;
218 	vme_chipset_tag_t vmect;
219 	int i, res;
220 	char *name = 0; /* XXX gcc! */
221 
222 	vmect = &sc->sc_vct;
223 	if (!va)
224 		goto freeit;
225 
226 #ifdef DIAGNOSTIC
227 	if (vmect != va->va_vct)
228 		panic("pcivme_slaveconfig: chipset tag?\n");
229 #endif
230 
231 	for (i = 0; i < va->numcfranges; i++) {
232 		res = vme_space_alloc(vmect, va->r[i].offset,
233 				      va->r[i].size, va->r[i].am);
234 		if (res)
235 			panic("%s: can't alloc slave window %x/%x/%x",
236 			       dev->dv_xname, va->r[i].offset,
237 			       va->r[i].size, va->r[i].am);
238 
239 		switch (va->r[i].am & VME_AM_ADRSIZEMASK) {
240 			/* structure assignments! */
241 		    case VME_AM_A16:
242 			sc->csrwindow = va->r[i];
243 			name = "VME CSR";
244 			break;
245 		    case VME_AM_A24:
246 			sc->dmawindow24 = va->r[i];
247 			name = "A24 DMA";
248 			break;
249 		    case VME_AM_A32:
250 			sc->dmawindow32 = va->r[i];
251 			name = "A32 DMA";
252 			break;
253 		}
254 		printf("%s: %s window: %x-%x\n", dev->dv_xname,
255 		       name, va->r[i].offset,
256 		       va->r[i].offset + va->r[i].size - 1);
257 	}
258 	return;
259 
260 freeit:
261 	if (sc->csrwindow.offset != -1)
262 		vme_space_free(vmect, sc->csrwindow.offset,
263 			       sc->csrwindow.size, sc->csrwindow.am);
264 	if (sc->dmawindow32.offset != -1)
265 		vme_space_free(vmect, sc->dmawindow32.offset,
266 			       sc->dmawindow32.size, sc->dmawindow32.am);
267 	if (sc->dmawindow24.offset != -1)
268 		vme_space_free(vmect, sc->dmawindow24.offset,
269 			       sc->dmawindow24.size, sc->dmawindow24.am);
270 }
271 
272 int
273 b3_617_reset(sc)
274 	struct b3_617_softc *sc;
275 {
276 	unsigned char status;
277 
278 	/* reset sequence, ch 5.2 */
279 	status = read_csr_byte(sc, LOC_STATUS);
280 	if (status & LSR_NO_CONNECT) {
281 		printf("%s: not connected\n", sc->sc_dev.dv_xname);
282 		return (-1);
283 	}
284 	status = read_csr_byte(sc, REM_STATUS); /* discard */
285 	write_csr_byte(sc, LOC_CMD1, LC1_CLR_ERROR);
286 	status = read_csr_byte(sc, LOC_STATUS);
287 	if (status & LSR_CERROR_MASK) {
288 		char sbuf[sizeof(BIT3_LSR_BITS) + 64];
289 
290 		bitmask_snprintf(status, BIT3_LSR_BITS, sbuf, sizeof(sbuf));
291 		printf("%s: interface error, lsr=%s\n", sc->sc_dev.dv_xname,
292 		       sbuf);
293 		return (-1);
294 	}
295 	return (0);
296 }
297 
298 int
299 b3_617_init(sc)
300 	struct b3_617_softc *sc;
301 {
302 	unsigned int i;
303 
304 	if (b3_617_reset(sc))
305 		return (-1);
306 
307 	/* all maps invalid */
308 	for (i = MR_PCI_VME; i < MR_PCI_VME + MR_PCI_VME_SIZE; i += 4)
309 		write_mapmem(sc, i, MR_RAM_INVALID);
310 	for (i = MR_VME_PCI; i < MR_VME_PCI + MR_VME_PCI_SIZE; i += 4)
311 		write_mapmem(sc, i, MR_RAM_INVALID);
312 	for (i = MR_DMA_PCI; i < MR_DMA_PCI + MR_DMA_PCI_SIZE; i += 4)
313 		write_mapmem(sc, i, MR_RAM_INVALID);
314 
315 	/*
316 	 * set up scatter page allocation control
317 	 */
318 	sc->vmeext = extent_create("pcivme", MR_PCI_VME,
319 				   MR_PCI_VME + MR_PCI_VME_SIZE - 1, M_DEVBUF,
320 				   sc->vmemap, sizeof(sc->vmemap),
321 				   EX_NOCOALESCE);
322 #if 0
323 	sc->pciext = extent_create("vmepci", MR_VME_PCI,
324 				   MR_VME_PCI + MR_VME_PCI_SIZE - 1, M_DEVBUF,
325 				   sc->pcimap, sizeof(sc->pcimap),
326 				   EX_NOCOALESCE);
327 	sc->dmaext = extent_create("dmapci", MR_DMA_PCI,
328 				   MR_DMA_PCI + MR_DMA_PCI_SIZE - 1, M_DEVBUF,
329 				   sc->dmamap, sizeof(sc->dmamap),
330 				   EX_NOCOALESCE);
331 #endif
332 
333 	/*
334 	 * init int handler queue,
335 	 * enable interrupts if PCI interrupt available
336 	 */
337 	TAILQ_INIT(&(sc->intrhdls));
338 	sc->strayintrs = 0;
339 
340 	if (sc->sc_ih)
341 		write_csr_byte(sc, LOC_INT_CTRL, LIC_INT_ENABLE);
342 	/* no error ints */
343 	write_csr_byte(sc, REM_CMD2, 0); /* enables VME IRQ */
344 
345 	return (0);
346 }
347 
348 #ifdef notyet /* for detach */
349 void
350 b3_617_halt(sc)
351 	struct b3_617_softc *sc;
352 {
353 	/*
354 	 * because detach code checks for existence of children,
355 	 * all ressources (mappings, VME IRQs, DMA requests)
356 	 * should be deallocated at this point
357 	 */
358 
359 	/* disable IRQ */
360 	write_csr_byte(sc, LOC_INT_CTRL, 0);
361 }
362 #endif
363 
364 static void
365 b3_617_vmeintr(sc, lstat)
366 	struct b3_617_softc *sc;
367 	unsigned char lstat;
368 {
369 	int level;
370 
371 	for (level = 7; level >= 1; level--) {
372 		unsigned char vector;
373 		struct b3_617_vmeintrhand *ih;
374 		int found;
375 
376 		if (!(lstat & (1 << level)))
377 			continue;
378 
379 		write_csr_byte(sc, REM_CMD1, level);
380 		vector = read_csr_byte(sc, REM_IACK);
381 
382 		found = 0;
383 
384 		for (ih = sc->intrhdls.tqh_first; ih;
385 		     ih = ih->ih_next.tqe_next) {
386 			if ((ih->ih_level == level) &&
387 			    ((ih->ih_vector == -1) ||
388 			     (ih->ih_vector == vector))) {
389 				int s, res;
390 				/*
391 				 * We should raise the interrupt level
392 				 * to ih->ih_prior here. How to do this
393 				 * machine-independantly?
394 				 * To be safe, raise to the maximum.
395 				 */
396 				s = splhigh();
397 				found |= (res = (*(ih->ih_fun))(ih->ih_arg));
398 				splx(s);
399 				if (res)
400 					ih->ih_count++;
401 				if (res == 1)
402 					break;
403 			}
404 		}
405 		if (!found)
406 			sc->strayintrs++;
407 	}
408 }
409 
410 #define sc ((struct b3_617_softc*)vsc)
411 
412 int
413 b3_617_map_vme(vsc, vmeaddr, len, am, datasizes, swap, tag, handle, resc)
414 	void *vsc;
415 	vme_addr_t vmeaddr;
416 	vme_size_t len;
417 	vme_am_t am;
418 	vme_datasize_t datasizes;
419 	vme_swap_t swap;
420 	bus_space_tag_t *tag;
421 	bus_space_handle_t *handle;
422 	vme_mapresc_t *resc;
423 {
424 	vme_addr_t vmebase, vmeend, va;
425 	unsigned long maplen, first, i;
426 	u_int32_t mapreg;
427 	bus_addr_t pcibase;
428 	int res;
429 	struct b3_617_vmeresc *r;
430 
431 	/* first mapped address */
432 	vmebase = vmeaddr & ~(VME_PAGESIZE - 1);
433 	/* base of last mapped page */
434 	vmeend = (vmeaddr + len - 1) & ~(VME_PAGESIZE - 1);
435 	/* bytes in scatter table required */
436 	maplen = ((vmeend - vmebase) / VME_PAGESIZE + 1) * 4;
437 
438 	if (extent_alloc(sc->vmeext, maplen, 4, 0, EX_FAST, &first))
439 		return (ENOMEM);
440 
441 	/*
442 	 * set up adapter mapping registers
443 	 */
444 	mapreg = (am << MR_AMOD_SHIFT) | MR_FC_RRAM | swap;
445 
446 	for (i = first, va = vmebase;
447 	     i < first + maplen;
448 	     i += 4, va += VME_PAGESIZE) {
449 		write_mapmem(sc, i, mapreg | va);
450 #ifdef BIT3DEBUG
451 		printf("mapreg@%lx=%x\n", i, read_mapmem(sc, i));
452 #endif
453 	}
454 
455 #ifdef DIAGNOSTIC
456 	if (va != vmeend + VME_PAGESIZE)
457 		panic("b3_617_map_pci_vme: botch");
458 #endif
459 	/*
460 	 * map needed range in PCI space
461 	 */
462 	pcibase = sc->vmepbase + (first - MR_PCI_VME) / 4 * VME_PAGESIZE
463 	    + (vmeaddr & (VME_PAGESIZE - 1));
464 
465 	if ((res = bus_space_map(sc->sc_vmet, pcibase, len, 0, handle))) {
466 		for (i = first; i < first + maplen; i += 4)
467 			write_mapmem(sc, i, MR_RAM_INVALID);
468 		extent_free(sc->vmeext, first, maplen, 0);
469 		return (res);
470 	}
471 
472 	*tag = sc->sc_vmet;
473 
474 	/*
475 	 * save all data needed for later unmapping
476 	 */
477 	r = malloc(sizeof(*r), M_DEVBUF, M_NOWAIT); /* XXX check! */
478 	r->handle = *handle;
479 	r->len = len;
480 	r->firstpage = first;
481 	r->maplen = maplen;
482 	*resc = r;
483 	return (0);
484 }
485 
486 void
487 b3_617_unmap_vme(vsc, resc)
488 	void *vsc;
489 	vme_mapresc_t resc;
490 {
491 	unsigned long i;
492 	struct b3_617_vmeresc *r = resc;
493 
494 	/* unmap PCI window */
495 	bus_space_unmap(sc->sc_vmet, r->handle, r->len);
496 
497 	for (i = r->firstpage; i < r->firstpage + r->maplen; i += 4)
498 		write_mapmem(sc, i, MR_RAM_INVALID);
499 
500 	extent_free(sc->vmeext, r->firstpage, r->maplen, 0);
501 
502 	free(r, M_DEVBUF);
503 }
504 
505 int
506 b3_617_vme_probe(vsc, addr, len, am, datasize, callback, cbarg)
507 	void *vsc;
508 	vme_addr_t addr;
509 	vme_size_t len;
510 	vme_am_t am;
511 	vme_datasize_t datasize;
512 	int (*callback) __P((void *, bus_space_tag_t, bus_space_handle_t));
513 	void *cbarg;
514 {
515 	bus_space_tag_t tag;
516 	bus_space_handle_t handle;
517 	vme_mapresc_t resc;
518 	int res, i;
519 	volatile u_int32_t dummy;
520 	int status;
521 
522 	res = b3_617_map_vme(vsc, addr, len, am, 0, 0,
523 			     &tag, &handle, &resc);
524 	if (res)
525 		return (res);
526 
527 	if (read_csr_byte(sc, LOC_STATUS) & LSR_ERROR_MASK) {
528 		printf("b3_617_vme_badaddr: error bit not clean - resetting\n");
529 		write_csr_byte(sc, LOC_CMD1, LC1_CLR_ERROR);
530 	}
531 
532 	if (callback)
533 		res = (*callback)(cbarg, tag, handle);
534 	else {
535 		for (i = 0; i < len;) {
536 			switch (datasize) {
537 			    case VME_D8:
538 				dummy = bus_space_read_1(tag, handle, i);
539 				i++;
540 				break;
541 			    case VME_D16:
542 				dummy = bus_space_read_2(tag, handle, i);
543 				i += 2;
544 				break;
545 			    case VME_D32:
546 				dummy = bus_space_read_4(tag, handle, i);
547 				i += 4;
548 				break;
549 			    default:
550 				panic("b3_617_vme_probe: invalid datasize %x",
551 				      datasize);
552 			}
553 		}
554 	}
555 
556 	if ((status = read_csr_byte(sc, LOC_STATUS)) & LSR_ERROR_MASK) {
557 #ifdef BIT3DEBUG
558 		printf("b3_617_vme_badaddr: caught error %x\n", status);
559 #endif
560 		write_csr_byte(sc, LOC_CMD1, LC1_CLR_ERROR);
561 		res = EIO;
562 	}
563 
564 	b3_617_unmap_vme(vsc, resc);
565 	return (res);
566 }
567 
568 int
569 b3_617_map_vmeint(vsc, level, vector, handlep)
570 	void *vsc;
571 	int level, vector;
572 	vme_intr_handle_t *handlep;
573 {
574 	if (!sc->sc_ih) {
575 		printf("%s: b3_617_map_vmeint: no IRQ\n",
576 		       sc->sc_dev.dv_xname);
577 		return (ENXIO);
578 	}
579 	/*
580 	 * We should check whether the interface can pass this interrupt
581 	 * level at all, but we don't know much about the jumper setting.
582 	 */
583 	*handlep = (void *)(long)((level << 8) | vector); /* XXX */
584 	return (0);
585 }
586 
587 void *
588 b3_617_establish_vmeint(vsc, handle, prior, func, arg)
589 	void *vsc;
590 	vme_intr_handle_t handle;
591 	int prior;
592 	int (*func) __P((void *));
593 	void *arg;
594 {
595 	struct b3_617_vmeintrhand *ih;
596 	long lv;
597 	int s;
598 
599 	/* no point in sleeping unless someone can free memory. */
600 	ih = malloc(sizeof *ih, M_DEVBUF, cold ? M_NOWAIT : M_WAITOK);
601 	if (ih == NULL)
602 		panic("b3_617_map_vmeint: can't malloc handler info");
603 
604 	lv = (long)handle; /* XXX */
605 
606 	ih->ih_fun = func;
607 	ih->ih_arg = arg;
608 	ih->ih_level = lv >> 8;
609 	ih->ih_vector = lv & 0xff;
610 	ih->ih_prior = prior;
611 	ih->ih_count = 0;
612 
613 	s = splhigh();
614 	TAILQ_INSERT_TAIL(&(sc->intrhdls), ih, ih_next);
615 	splx(s);
616 
617 	return (ih);
618 }
619 
620 void
621 b3_617_disestablish_vmeint(vsc, cookie)
622 	void *vsc;
623 	void *cookie;
624 {
625 	struct b3_617_vmeintrhand *ih = cookie;
626 	int s;
627 
628 	if (!ih) {
629 		printf("b3_617_unmap_vmeint: NULL arg\n");
630 		return;
631 	}
632 
633 	s = splhigh();
634 	TAILQ_REMOVE(&(sc->intrhdls), ih, ih_next);
635 	splx(s);
636 
637 	free(ih, M_DEVBUF);
638 }
639 
640 int
641 b3_617_intr(vsc)
642 	void *vsc;
643 {
644 	int handled = 0;
645 
646 	/* follows ch. 5.5.5 (reordered for speed) */
647 	while (read_csr_byte(sc, LOC_INT_CTRL) & LIC_INT_PENDING) {
648 		unsigned char lstat;
649 
650 		handled = 1;
651 
652 		/* no error interrupts! */
653 
654 		lstat = read_csr_byte(sc, LDMA_CMD);
655 		if ((lstat & LDC_DMA_DONE) && (lstat & LDC_DMA_INT_ENABLE)) {
656 			/* DMA done indicator flag */
657 			write_csr_byte(sc, LDMA_CMD, lstat & (~LDC_DMA_DONE));
658 #if 0
659 			b3_617_cntlrdma_done(sc);
660 #endif
661 			continue;
662 		}
663 
664 		lstat = read_csr_byte(sc, LOC_INT_STATUS);
665 		if (lstat & LIS_CINT_MASK) {
666 			/* VME backplane interrupt, ch. 5.5.3 */
667 			b3_617_vmeintr(sc, lstat);
668 		}
669 
670 		/* for now, ignore "mailbox interrupts" */
671 
672 		lstat = read_csr_byte(sc, LOC_STATUS);
673 		if (lstat & LSR_PR_STATUS) {
674 			/* PR interrupt received from REMOTE  */
675 			write_csr_byte(sc, LOC_CMD1, LC1_CLR_PR_INT);
676 			continue;
677 		}
678 
679 		lstat = read_csr_byte(sc, REM_STATUS);
680 		if (lstat & RSR_PT_STATUS) {
681 			/* PT interrupt is set */
682 			write_csr_byte(sc, REM_CMD1, RC1_CLR_PT_INT);
683 			continue;
684 		}
685 	}
686 	return (handled);
687 }
688 
689 int
690 b3_617_dmamap_create(vsc, len, am, datasize, swap,
691 		   nsegs, segsz, bound,
692 		   flags, mapp)
693 	void *vsc;
694 	vme_size_t len;
695 	vme_am_t am;
696 	vme_datasize_t datasize;
697 	vme_swap_t swap;
698 	int nsegs;
699 	vme_size_t segsz;
700 	vme_addr_t bound;
701 	int flags;
702 	bus_dmamap_t *mapp;
703 {
704 	return (EINVAL);
705 }
706 
707 void
708 b3_617_dmamap_destroy(vsc, map)
709 	void *vsc;
710 	bus_dmamap_t map;
711 {
712 }
713 
714 int
715 b3_617_dmamem_alloc(vsc, len, am, datasizes, swap,
716 		    segs, nsegs, rsegs, flags)
717 	void *vsc;
718 	vme_size_t len;
719 	vme_am_t am;
720 	vme_datasize_t datasizes;
721 	vme_swap_t swap;
722 	bus_dma_segment_t *segs;
723 	int nsegs;
724 	int *rsegs;
725 	int flags;
726 {
727 	return (EINVAL);
728 }
729 
730 void
731 b3_617_dmamem_free(vsc, segs, nsegs)
732 	void *vsc;
733 	bus_dma_segment_t *segs;
734 	int nsegs;
735 {
736 }
737 
738 #undef sc
739