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