nextdmareg.h revision 1.7.8.2 1 1.7.8.2 nathanw /* $NetBSD: nextdmareg.h,v 1.7.8.2 2002/09/17 21:16:30 nathanw Exp $ */
2 1.7.8.2 nathanw /*
3 1.7.8.2 nathanw * Copyright (c) 1998 Darrin B. Jewell
4 1.7.8.2 nathanw * All rights reserved.
5 1.7.8.2 nathanw *
6 1.7.8.2 nathanw * Redistribution and use in source and binary forms, with or without
7 1.7.8.2 nathanw * modification, are permitted provided that the following conditions
8 1.7.8.2 nathanw * are met:
9 1.7.8.2 nathanw * 1. Redistributions of source code must retain the above copyright
10 1.7.8.2 nathanw * notice, this list of conditions and the following disclaimer.
11 1.7.8.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
12 1.7.8.2 nathanw * notice, this list of conditions and the following disclaimer in the
13 1.7.8.2 nathanw * documentation and/or other materials provided with the distribution.
14 1.7.8.2 nathanw * 3. All advertising materials mentioning features or use of this software
15 1.7.8.2 nathanw * must display the following acknowledgement:
16 1.7.8.2 nathanw * This product includes software developed by Darrin B. Jewell
17 1.7.8.2 nathanw * 4. The name of the author may not be used to endorse or promote products
18 1.7.8.2 nathanw * derived from this software without specific prior written permission
19 1.7.8.2 nathanw *
20 1.7.8.2 nathanw * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 1.7.8.2 nathanw * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 1.7.8.2 nathanw * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 1.7.8.2 nathanw * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 1.7.8.2 nathanw * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 1.7.8.2 nathanw * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 1.7.8.2 nathanw * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 1.7.8.2 nathanw * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 1.7.8.2 nathanw * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 1.7.8.2 nathanw * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 1.7.8.2 nathanw */
31 1.7.8.2 nathanw
32 1.7.8.2 nathanw /* I think the chip can handle 64k per chain, but I don't
33 1.7.8.2 nathanw * know how much per segment for sure. We might try
34 1.7.8.2 nathanw * experimenting with this value. Can we cross page boundaries?
35 1.7.8.2 nathanw */
36 1.7.8.2 nathanw #define MAX_DMASIZE 8192
37 1.7.8.2 nathanw
38 1.7.8.2 nathanw /* from nextdev/dma.h */
39 1.7.8.2 nathanw
40 1.7.8.2 nathanw #if 0
41 1.7.8.2 nathanw #define DMA_BEGINALIGNMENT 4 /* initial buffer must be on long */
42 1.7.8.2 nathanw #else
43 1.7.8.2 nathanw /* But to make cache handling easier, we put it on a cache line anyway. */
44 1.7.8.2 nathanw #define DMA_BEGINALIGNMENT 16
45 1.7.8.2 nathanw #endif
46 1.7.8.2 nathanw #define DMA_ENDALIGNMENT 16 /* DMA must end on quad longword */
47 1.7.8.2 nathanw
48 1.7.8.2 nathanw #define DMA_ALIGN(type, addr) \
49 1.7.8.2 nathanw ((type)(((unsigned)(addr)+DMA_BEGINALIGNMENT-1) \
50 1.7.8.2 nathanw &~(DMA_BEGINALIGNMENT-1)))
51 1.7.8.2 nathanw
52 1.7.8.2 nathanw #define DMA_ENDALIGN(type, addr) \
53 1.7.8.2 nathanw ((type)(((unsigned)(addr)+DMA_ENDALIGNMENT-1) \
54 1.7.8.2 nathanw &~(DMA_ENDALIGNMENT-1)))
55 1.7.8.2 nathanw
56 1.7.8.2 nathanw #define DMA_BEGINALIGNED(addr) (((unsigned)(addr)&(DMA_BEGINALIGNMENT-1))==0)
57 1.7.8.2 nathanw #define DMA_ENDALIGNED(addr) (((unsigned)(addr)&(DMA_ENDALIGNMENT-1))==0)
58 1.7.8.2 nathanw
59 1.7.8.2 nathanw #if 0
60 1.7.8.2 nathanw struct dma_dev { /* format of dma device registers */
61 1.7.8.2 nathanw int dd_csr; /* control & status register */
62 1.7.8.2 nathanw char dd_pad[0x3fec]; /* csr not contiguous with next */
63 1.7.8.2 nathanw char *dd_saved_next; /* saved pointers for HW restart */
64 1.7.8.2 nathanw char *dd_saved_limit;
65 1.7.8.2 nathanw char *dd_saved_start;
66 1.7.8.2 nathanw char *dd_saved_stop;
67 1.7.8.2 nathanw char *dd_next; /* next word to dma */
68 1.7.8.2 nathanw char *dd_limit; /* dma complete when next == limit */
69 1.7.8.2 nathanw char *dd_start; /* start of 2nd buf to dma */
70 1.7.8.2 nathanw char *dd_stop; /* end of 2nd buf to dma */
71 1.7.8.2 nathanw char dd_pad2[0x1f0];
72 1.7.8.2 nathanw char *dd_next_initbuf; /* next register that inits dma buffering */
73 1.7.8.2 nathanw };
74 1.7.8.2 nathanw #endif
75 1.7.8.2 nathanw
76 1.7.8.2 nathanw #define DD_CSR 0
77 1.7.8.2 nathanw #define DD_SAVED_NEXT (DD_CSR +sizeof(int) + 0x3fec)
78 1.7.8.2 nathanw #define DD_SAVED_LIMIT (DD_SAVED_NEXT +sizeof(char *))
79 1.7.8.2 nathanw #define DD_SAVED_START (DD_SAVED_LIMIT +sizeof(char *))
80 1.7.8.2 nathanw #define DD_SAVED_STOP (DD_SAVED_START +sizeof(char *))
81 1.7.8.2 nathanw #define DD_NEXT (DD_SAVED_STOP +sizeof(char *))
82 1.7.8.2 nathanw #define DD_LIMIT (DD_NEXT +sizeof(char *))
83 1.7.8.2 nathanw #define DD_START (DD_LIMIT +sizeof(char *))
84 1.7.8.2 nathanw #define DD_STOP (DD_START +sizeof(char *))
85 1.7.8.2 nathanw #define DD_NEXT_INITBUF (DD_STOP +sizeof(char *) + 0x1f0)
86 1.7.8.2 nathanw
87 1.7.8.2 nathanw #define DD_SIZE (DD_NEXT_INITBUF+sizeof(char *))
88 1.7.8.2 nathanw /*
89 1.7.8.2 nathanw * bits in dd_csr
90 1.7.8.2 nathanw */
91 1.7.8.2 nathanw /* read bits */
92 1.7.8.2 nathanw #define DMACSR_ENABLE 0x01000000 /* enable dma transfer */
93 1.7.8.2 nathanw #define DMACSR_SUPDATE 0x02000000 /* single update */
94 1.7.8.2 nathanw #define DMACSR_READ 0x04000000 /* dma is ina read operation */
95 1.7.8.2 nathanw #define DMACSR_COMPLETE 0x08000000 /* current dma has completed */
96 1.7.8.2 nathanw #define DMACSR_BUSEXC 0x10000000 /* bus exception occurred */
97 1.7.8.2 nathanw /* write bits */
98 1.7.8.2 nathanw #define DMACSR_SETENABLE 0x00010000 /* set enable */
99 1.7.8.2 nathanw #define DMACSR_SETSUPDATE 0x00020000 /* set single update */
100 1.7.8.2 nathanw #define DMACSR_SETREAD 0x00040000 /* dma from dev to mem */
101 1.7.8.2 nathanw #define DMACSR_SETWRITE 0x00000000 /* dma from mem to dev */
102 1.7.8.2 nathanw #define DMACSR_CLRCOMPLETE 0x00080000 /* clear complete conditional */
103 1.7.8.2 nathanw #define DMACSR_RESET 0x00100000 /* clr cmplt, sup, enable */
104 1.7.8.2 nathanw #define DMACSR_INITBUF 0x00200000 /* initialize DMA buffers */
105 1.7.8.2 nathanw #define DMACSR_INITBUFTURBO 0x00800000
106 1.7.8.2 nathanw
107 1.7.8.2 nathanw #define DMACSR_BITS \
108 1.7.8.2 nathanw "\20\35BUSEXC\34COMPLETE\33READ\32SUPDATE\31ENABLE\26INITBUF\25RESET\24CLRCOMPLETE\23SETREAD\22SETSUPDATE\21SETENABLE"
109