dmacreg.h revision 1.1 1 1.1 uch /* $NetBSD: dmacreg.h,v 1.1 2001/10/16 15:38:36 uch Exp $ */
2 1.1 uch
3 1.1 uch /*-
4 1.1 uch * Copyright (c) 2001 The NetBSD Foundation, Inc.
5 1.1 uch * All rights reserved.
6 1.1 uch *
7 1.1 uch * This code is derived from software contributed to The NetBSD Foundation
8 1.1 uch * by UCHIYAMA Yasushi.
9 1.1 uch *
10 1.1 uch * Redistribution and use in source and binary forms, with or without
11 1.1 uch * modification, are permitted provided that the following conditions
12 1.1 uch * are met:
13 1.1 uch * 1. Redistributions of source code must retain the above copyright
14 1.1 uch * notice, this list of conditions and the following disclaimer.
15 1.1 uch * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 uch * notice, this list of conditions and the following disclaimer in the
17 1.1 uch * documentation and/or other materials provided with the distribution.
18 1.1 uch * 3. All advertising materials mentioning features or use of this software
19 1.1 uch * must display the following acknowledgement:
20 1.1 uch * This product includes software developed by the NetBSD
21 1.1 uch * Foundation, Inc. and its contributors.
22 1.1 uch * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1 uch * contributors may be used to endorse or promote products derived
24 1.1 uch * from this software without specific prior written permission.
25 1.1 uch *
26 1.1 uch * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1 uch * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1 uch * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1 uch * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1 uch * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1 uch * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1 uch * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1 uch * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1 uch * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1 uch * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1 uch * POSSIBILITY OF SUCH DAMAGE.
37 1.1 uch */
38 1.1 uch
39 1.1 uch typedef u_int64_t dmatag_t;
40 1.1 uch
41 1.1 uch #define DMAC_BLOCK_SIZE 16
42 1.1 uch #define DMAC_SLICE_SIZE 128
43 1.1 uch #define DMAC_TRANSFER_QWCMAX 0xffff
44 1.1 uch
45 1.1 uch /* all register length are 32bit */
46 1.1 uch #define DMAC_REGBASE MIPS_PHYS_TO_KSEG1(0x10008000)
47 1.1 uch #define DMAC_REGSIZE 0x00010000
48 1.1 uch
49 1.1 uch /*
50 1.1 uch * DMAC common registers.
51 1.1 uch */
52 1.1 uch #define D_CTRL_REG MIPS_PHYS_TO_KSEG1(0x1000e000) /* DMA control */
53 1.1 uch #define D_STAT_REG MIPS_PHYS_TO_KSEG1(0x1000e010) /* interrupt status */
54 1.1 uch #define D_PCR_REG MIPS_PHYS_TO_KSEG1(0x1000e020) /* priority control */
55 1.1 uch #define D_SQWC_REG MIPS_PHYS_TO_KSEG1(0x1000e030) /* interleave size */
56 1.1 uch #define D_RBOR_REG MIPS_PHYS_TO_KSEG1(0x1000e040) /* ring buffer addr */
57 1.1 uch #define D_RBSR_REG MIPS_PHYS_TO_KSEG1(0x1000e050) /* ring buffer size */
58 1.1 uch #define D_STADR_REG MIPS_PHYS_TO_KSEG1(0x1000e060) /* stall address */
59 1.1 uch #define D_ENABLER_REG MIPS_PHYS_TO_KSEG1(0x1000f520) /* DMA enable (r) */
60 1.1 uch #define D_ENABLEW_REG MIPS_PHYS_TO_KSEG1(0x1000f590) /* DMA enable (w) */
61 1.1 uch
62 1.1 uch /*
63 1.1 uch * Channel registers. (10ch)
64 1.1 uch */
65 1.1 uch #define DMA_CH_VIF0 0 /* to (priority 0) */
66 1.1 uch #define DMA_CH_VIF1 1 /* both */
67 1.1 uch #define DMA_CH_GIF 2 /* to */
68 1.1 uch #define DMA_CH_FROMIPU 3
69 1.1 uch #define DMA_CH_TOIPU 4
70 1.1 uch #define DMA_CH_SIF0 5 /* from */
71 1.1 uch #define DMA_CH_SIF1 6 /* to */
72 1.1 uch #define DMA_CH_SIF2 7 /* both (priority 1) */
73 1.1 uch #define DMA_CH_FROMSPR 8 /* burst channel */
74 1.1 uch #define DMA_CH_TOSPR 9 /* burst channel */
75 1.1 uch #define DMA_CH_VALID(x) (((x) >= 0) && ((x) <= 9))
76 1.1 uch
77 1.1 uch #define D_CHCR_OFS 0x00
78 1.1 uch #define D_MADR_OFS 0x10
79 1.1 uch #define D_QWC_OFS 0x20
80 1.1 uch #define D_TADR_OFS 0x30
81 1.1 uch #define D_ASR0_OFS 0x40
82 1.1 uch #define D_ASR1_OFS 0x50
83 1.1 uch #define D_SADR_OFS 0x80
84 1.1 uch
85 1.1 uch #define D0_REGBASE MIPS_PHYS_TO_KSEG1(0x10008000)
86 1.1 uch #define D1_REGBASE MIPS_PHYS_TO_KSEG1(0x10009000)
87 1.1 uch #define D2_REGBASE MIPS_PHYS_TO_KSEG1(0x1000a000)
88 1.1 uch #define D3_REGBASE MIPS_PHYS_TO_KSEG1(0x1000b000)
89 1.1 uch #define D4_REGBASE MIPS_PHYS_TO_KSEG1(0x1000b400)
90 1.1 uch #define D5_REGBASE MIPS_PHYS_TO_KSEG1(0x1000c000)
91 1.1 uch #define D6_REGBASE MIPS_PHYS_TO_KSEG1(0x1000c400)
92 1.1 uch #define D7_REGBASE MIPS_PHYS_TO_KSEG1(0x1000c800)
93 1.1 uch #define D8_REGBASE MIPS_PHYS_TO_KSEG1(0x1000d000)
94 1.1 uch #define D9_REGBASE MIPS_PHYS_TO_KSEG1(0x1000d400)
95 1.1 uch
96 1.1 uch #define D_CHCR_REG(base) (base)
97 1.1 uch #define D_MADR_REG(base) (base + D_MADR_OFS)
98 1.1 uch #define D_QWC_REG(base) (base + D_QWC_OFS)
99 1.1 uch #define D_TADR_REG(base) (base + D_TADR_OFS)
100 1.1 uch #define D_ASR0_REG(base) (base + D_ASR0_OFS)
101 1.1 uch #define D_ASR1_REG(base) (base + D_ASR1_OFS)
102 1.1 uch #define D_SADR_REG(base) (base + D_SADR_OFS)
103 1.1 uch
104 1.1 uch #define D0_CHCR_REG MIPS_PHYS_TO_KSEG1(0x10008000)
105 1.1 uch #define D0_MADR_REG MIPS_PHYS_TO_KSEG1(0x10008010)
106 1.1 uch #define D0_QWC_REG MIPS_PHYS_TO_KSEG1(0x10008020)
107 1.1 uch #define D0_TADR_REG MIPS_PHYS_TO_KSEG1(0x10008030)
108 1.1 uch #define D0_ASR0_REG MIPS_PHYS_TO_KSEG1(0x10008040)
109 1.1 uch #define D0_ASR1_REG MIPS_PHYS_TO_KSEG1(0x10008050)
110 1.1 uch
111 1.1 uch #define D1_CHCR_REG MIPS_PHYS_TO_KSEG1(0x10009000)
112 1.1 uch #define D1_MADR_REG MIPS_PHYS_TO_KSEG1(0x10009010)
113 1.1 uch #define D1_QWC_REG MIPS_PHYS_TO_KSEG1(0x10009020)
114 1.1 uch #define D1_TADR_REG MIPS_PHYS_TO_KSEG1(0x10009030)
115 1.1 uch #define D1_ASR0_REG MIPS_PHYS_TO_KSEG1(0x10009040)
116 1.1 uch #define D1_ASR1_REG MIPS_PHYS_TO_KSEG1(0x10009050)
117 1.1 uch
118 1.1 uch #define D2_CHCR_REG MIPS_PHYS_TO_KSEG1(0x1000a000)
119 1.1 uch #define D2_MADR_REG MIPS_PHYS_TO_KSEG1(0x1000a010)
120 1.1 uch #define D2_QWC_REG MIPS_PHYS_TO_KSEG1(0x1000a020)
121 1.1 uch #define D2_TADR_REG MIPS_PHYS_TO_KSEG1(0x1000a030)
122 1.1 uch #define D2_ASR0_REG MIPS_PHYS_TO_KSEG1(0x1000a040)
123 1.1 uch #define D2_ASR1_REG MIPS_PHYS_TO_KSEG1(0x1000a050)
124 1.1 uch
125 1.1 uch #define D3_CHCR_REG MIPS_PHYS_TO_KSEG1(0x1000b000)
126 1.1 uch #define D3_MADR_REG MIPS_PHYS_TO_KSEG1(0x1000b010)
127 1.1 uch #define D3_QWC_REG MIPS_PHYS_TO_KSEG1(0x1000b020)
128 1.1 uch
129 1.1 uch #define D4_CHCR_REG MIPS_PHYS_TO_KSEG1(0x1000b400)
130 1.1 uch #define D4_MADR_REG MIPS_PHYS_TO_KSEG1(0x1000b410)
131 1.1 uch #define D4_QWC_REG MIPS_PHYS_TO_KSEG1(0x1000b420)
132 1.1 uch #define D4_TADR_REG MIPS_PHYS_TO_KSEG1(0x1000b430)
133 1.1 uch
134 1.1 uch #define D5_CHCR_REG MIPS_PHYS_TO_KSEG1(0x1000c000)
135 1.1 uch #define D5_MADR_REG MIPS_PHYS_TO_KSEG1(0x1000c010)
136 1.1 uch #define D5_QWC_REG MIPS_PHYS_TO_KSEG1(0x1000c020)
137 1.1 uch
138 1.1 uch #define D6_CHCR_REG MIPS_PHYS_TO_KSEG1(0x1000c400)
139 1.1 uch #define D6_MADR_REG MIPS_PHYS_TO_KSEG1(0x1000c410)
140 1.1 uch #define D6_QWC_REG MIPS_PHYS_TO_KSEG1(0x1000c420)
141 1.1 uch #define D6_TADR_REG MIPS_PHYS_TO_KSEG1(0x1000c430)
142 1.1 uch
143 1.1 uch #define D7_CHCR_REG MIPS_PHYS_TO_KSEG1(0x1000c800)
144 1.1 uch #define D7_MADR_REG MIPS_PHYS_TO_KSEG1(0x1000c810)
145 1.1 uch #define D7_QWC_REG MIPS_PHYS_TO_KSEG1(0x1000c820)
146 1.1 uch
147 1.1 uch #define D8_CHCR_REG MIPS_PHYS_TO_KSEG1(0x1000d000)
148 1.1 uch #define D8_MADR_REG MIPS_PHYS_TO_KSEG1(0x1000d010)
149 1.1 uch #define D8_QWC_REG MIPS_PHYS_TO_KSEG1(0x1000d020)
150 1.1 uch #define D8_SADR_REG MIPS_PHYS_TO_KSEG1(0x1000d080)
151 1.1 uch
152 1.1 uch #define D9_CHCR_REG MIPS_PHYS_TO_KSEG1(0x1000d400)
153 1.1 uch #define D9_MADR_REG MIPS_PHYS_TO_KSEG1(0x1000d410)
154 1.1 uch #define D9_QWC_REG MIPS_PHYS_TO_KSEG1(0x1000d420)
155 1.1 uch #define D9_TADR_REG MIPS_PHYS_TO_KSEG1(0x1000d430)
156 1.1 uch #define D9_SADR_REG MIPS_PHYS_TO_KSEG1(0x1000d480)
157 1.1 uch
158 1.1 uch /*
159 1.1 uch * DMA control
160 1.1 uch */
161 1.1 uch #define D_CTRL_DMAE 0x00000001 /* all DMA enable/disable */
162 1.1 uch #define D_CTRL_RELE 0x00000002 /* Cycle stealing on/off */
163 1.1 uch /* Memory FIFO drain control */
164 1.1 uch #define D_CTRL_MFD_MASK 0x3
165 1.1 uch #define D_CTRL_MFD_SHIFT 2
166 1.1 uch #define D_CTRL_MFD(x) \
167 1.1 uch (((x) >> D_CTRL_MFD_SHIFT) & D_CTRL_MFD_MASK)
168 1.1 uch #define D_CTRL_MFD_CLR(x) \
169 1.1 uch ((x) & ~(D_CTRL_MFD_MASK << D_CTRL_MFD_SHIFT))
170 1.1 uch #define D_CTRL_MFD_SET(x, val) \
171 1.1 uch ((x) | (((val) << D_CTRL_MFD_SHIFT) & \
172 1.1 uch (D_CTRL_MFD_MASK << D_CTRL_MFD_SHIFT)))
173 1.1 uch #define D_CTRL_MFD_DISABLE 0
174 1.1 uch #define D_CTRL_MFD_VIF1 2
175 1.1 uch #define D_CTRL_MFD_GIF 3
176 1.1 uch
177 1.1 uch /* Stall control source channel */
178 1.1 uch #define D_CTRL_STS_MASK 0x3
179 1.1 uch #define D_CTRL_STS_SHIFT 4
180 1.1 uch #define D_CTRL_STS(x) \
181 1.1 uch (((x) >> D_CTRL_STS_SHIFT) & D_CTRL_STS_MASK)
182 1.1 uch #define D_CTRL_STS_CLR(x) \
183 1.1 uch ((x) & ~(D_CTRL_STS_MASK << D_CTRL_STS_SHIFT))
184 1.1 uch #define D_CTRL_STS_SET(x, val) \
185 1.1 uch ((x) | (((val) << D_CTRL_STS_SHIFT) & \
186 1.1 uch (D_CTRL_STS_MASK << D_CTRL_STS_SHIFT)))
187 1.1 uch #define D_CTRL_STS_NONE 0
188 1.1 uch #define D_CTRL_STS_SIF0 1
189 1.1 uch #define D_CTRL_STS_FROMSPR 2
190 1.1 uch #define D_CTRL_STS_FROMIPU 3
191 1.1 uch
192 1.1 uch /* Stall control drain channel */
193 1.1 uch #define D_CTRL_STD_MASK 0x3
194 1.1 uch #define D_CTRL_STD_SHIFT 6
195 1.1 uch #define D_CTRL_STD(x) \
196 1.1 uch (((x) >> D_CTRL_STD_SHIFT) & D_CTRL_STD_MASK)
197 1.1 uch #define D_CTRL_STD_CLR(x) \
198 1.1 uch ((x) & ~(D_CTRL_STD_MASK << D_CTRL_STD_SHIFT))
199 1.1 uch #define D_CTRL_STD_SET(x, val) \
200 1.1 uch ((x) | (((val) << D_CTRL_STD_SHIFT) & \
201 1.1 uch (D_CTRL_STD_MASK << D_CTRL_STD_SHIFT)))
202 1.1 uch #define D_CTRL_STD_NONE 0
203 1.1 uch #define D_CTRL_STD_VIF1 1
204 1.1 uch #define D_CTRL_STD_GIF 2
205 1.1 uch #define D_CTRL_STD_SIF1 3
206 1.1 uch
207 1.1 uch /*
208 1.1 uch * Release cycle
209 1.1 uch * for burst channel Cycle steanling on mode only.
210 1.1 uch */
211 1.1 uch #define D_CTRL_RCYC_MASK 0x7
212 1.1 uch #define D_CTRL_RCYC_SHIFT 8
213 1.1 uch #define D_CTRL_RCYC(x) \
214 1.1 uch (((x) >> D_CTRL_RCYC_SHIFT) & D_CTRL_RCYC_MASK)
215 1.1 uch #define D_CTRL_RCYC_CLR(x) \
216 1.1 uch ((x) & ~(D_CTRL_RCYC_MASK << D_CTRL_RCYC_SHIFT))
217 1.1 uch #define D_CTRL_RCYC_SET(x, val) \
218 1.1 uch ((x) | (((val) << D_CTRL_RCYC_SHIFT) & \
219 1.1 uch (D_CTRL_RCYC_MASK << D_CTRL_RCYC_SHIFT)))
220 1.1 uch #define D_CTRL_RCYC_CYCLE(x) (8 << (x))
221 1.1 uch
222 1.1 uch /*
223 1.1 uch * Interrupt status register (write clear/invert)
224 1.1 uch * DMAC interrupt line connected to MIPS HwINT1
225 1.1 uch */
226 1.1 uch /* MFIFO empty interrupt enable */
227 1.1 uch #define D_STAT_MEIM 0x40000000
228 1.1 uch /* DMA stall interrupt enable */
229 1.1 uch #define D_STAT_SIM 0x20000000
230 1.1 uch /* Channel interrupt enable */
231 1.1 uch #define D_STAT_CIM_MASK 0x3ff
232 1.1 uch #define D_STAT_CIM_SHIFT 16
233 1.1 uch #define D_STAT_CIM(x) (((x) >> D_STAT_CIM_SHIFT) & D_STAT_CIM_MASK)
234 1.1 uch #define D_STAT_CIM_BIT(x) ((1 << (x)) << D_STAT_CIM_SHIFT)
235 1.1 uch #define D_STAT_CIM9 0x02000000
236 1.1 uch #define D_STAT_CIM8 0x01000000
237 1.1 uch #define D_STAT_CIM7 0x00800000
238 1.1 uch #define D_STAT_CIM6 0x00400000
239 1.1 uch #define D_STAT_CIM5 0x00200000
240 1.1 uch #define D_STAT_CIM4 0x00100000
241 1.1 uch #define D_STAT_CIM3 0x00080000
242 1.1 uch #define D_STAT_CIM2 0x00040000
243 1.1 uch #define D_STAT_CIM1 0x00020000
244 1.1 uch #define D_STAT_CIM0 0x00010000
245 1.1 uch /* BUSERR interrupt status */
246 1.1 uch #define D_STAT_BEIS 0x00008000
247 1.1 uch /* MFIFO empty interrupt status */
248 1.1 uch #define D_STAT_MEIS 0x00004000
249 1.1 uch /* DMA stall interrupt status */
250 1.1 uch #define D_STAT_SIS 0x00002000
251 1.1 uch /* Channel interrupt status */
252 1.1 uch #define D_STAT_CIS_MASK 0x3ff
253 1.1 uch #define D_STAT_CIS_SHIFT 0
254 1.1 uch #define D_STAT_CIS_BIT(x) (1 << (x))
255 1.1 uch #define D_STAT_CIS9 0x00000200
256 1.1 uch #define D_STAT_CIS8 0x00000100
257 1.1 uch #define D_STAT_CIS7 0x00000080
258 1.1 uch #define D_STAT_CIS6 0x00000040
259 1.1 uch #define D_STAT_CIS5 0x00000020
260 1.1 uch #define D_STAT_CIS4 0x00000010
261 1.1 uch #define D_STAT_CIS3 0x00000008
262 1.1 uch #define D_STAT_CIS2 0x00000004
263 1.1 uch #define D_STAT_CIS1 0x00000002
264 1.1 uch #define D_STAT_CIS0 0x00000001
265 1.1 uch
266 1.1 uch /*
267 1.1 uch * Priority control register.
268 1.1 uch */
269 1.1 uch /* Priority control enable */
270 1.1 uch #define D_PCR_PCE 0x80000000
271 1.1 uch /* Channel DMA enable (packet priority control enable) */
272 1.1 uch #define D_PCR_CDE_MASK 0x3ff
273 1.1 uch #define D_PCR_CDE_SHIFT 16
274 1.1 uch #define D_PCR_CDE(x) \
275 1.1 uch (((x) >> D_PCR_CDE_SHIFT) & D_PCR_CDE_MASK)
276 1.1 uch #define D_PCR_CDE_CLR(x) \
277 1.1 uch ((x) & ~(D_PCR_CDE_MASK << D_PCR_CDE_SHIFT))
278 1.1 uch #define D_PCR_CDE_SET(x, val) \
279 1.1 uch ((x) | (((val) << D_PCR_CDE_SHIFT) & \
280 1.1 uch (D_PCR_CDE_MASK << D_PCR_CDE_SHIFT)))
281 1.1 uch #define D_PCR_CDE9 0x02000000
282 1.1 uch #define D_PCR_CDE8 0x01000000
283 1.1 uch #define D_PCR_CDE7 0x00800000
284 1.1 uch #define D_PCR_CDE6 0x00400000
285 1.1 uch #define D_PCR_CDE5 0x00200000
286 1.1 uch #define D_PCR_CDE4 0x00100000
287 1.1 uch #define D_PCR_CDE3 0x00080000
288 1.1 uch #define D_PCR_CDE2 0x00040000
289 1.1 uch #define D_PCR_CDE1 0x00020000
290 1.1 uch #define D_PCR_CDE0 0x00010000
291 1.1 uch /* COP control (interrupt status connect to CPCOND[0] or not) */
292 1.1 uch #define D_PCR_CPC_MASK 0x3ff
293 1.1 uch #define D_PCR_CPC_SHIFT 0
294 1.1 uch #define D_PCR_CPC(x) ((x) & D_PCR_CPC_MASK)
295 1.1 uch #define D_PCR_CPC_CLR(x) ((x) & ~D_PCR_CPC_MASK)
296 1.1 uch #define D_PCR_CPC_SET(x, val) ((x) | ((val) & D_PCR_CPC_MASK))
297 1.1 uch #define D_PCR_CPC_BIT(x) (1 << (x))
298 1.1 uch #define D_PCR_CPC9 0x00000200
299 1.1 uch #define D_PCR_CPC8 0x00000100
300 1.1 uch #define D_PCR_CPC7 0x00000080
301 1.1 uch #define D_PCR_CPC6 0x00000040
302 1.1 uch #define D_PCR_CPC5 0x00000020
303 1.1 uch #define D_PCR_CPC4 0x00000010
304 1.1 uch #define D_PCR_CPC3 0x00000008
305 1.1 uch #define D_PCR_CPC2 0x00000004
306 1.1 uch #define D_PCR_CPC1 0x00000002
307 1.1 uch #define D_PCR_CPC0 0x00000001
308 1.1 uch
309 1.1 uch /*
310 1.1 uch * Interleave size register
311 1.1 uch */
312 1.1 uch /* Transfer quadword counter */
313 1.1 uch #define D_SQWC_TQWC_MASK 0xff
314 1.1 uch #define D_SQWC_TQWC_SHIFT 16
315 1.1 uch #define D_SQWC_TQWC(x) \
316 1.1 uch (((x) >> D_SQWC_TQWC_SHIFT) & D_SQWC_TQWC_MASK)
317 1.1 uch #define D_SQWC_TQWC_CLR(x) \
318 1.1 uch ((x) & ~(D_SQWC_TQWC_MASK << D_SQWC_TQWC_SHIFT))
319 1.1 uch #define D_SQWC_TQWC_SET(x, val) \
320 1.1 uch ((x) | (((val) << D_SQWC_TQWC_SHIFT) & \
321 1.1 uch (D_SQWC_TQWC_MASK << D_SQWC_TQWC_SHIFT)))
322 1.1 uch /* Skip quadword counter */
323 1.1 uch #define D_SQWC_SQWC_MASK 0xff
324 1.1 uch #define D_SQWC_SQWC_SHIFT 0
325 1.1 uch #define D_SQWC_SQWC(x) \
326 1.1 uch (((x) >> D_SQWC_SQWC_SHIFT) & D_SQWC_SQWC_MASK)
327 1.1 uch #define D_SQWC_SQWC_CLR(x) \
328 1.1 uch ((x) & ~(D_SQWC_SQWC_MASK << D_SQWC_SQWC_SHIFT))
329 1.1 uch #define D_SQWC_SQWC_SET(x, val) \
330 1.1 uch ((x) | (((val) << D_SQWC_SQWC_SHIFT) & \
331 1.1 uch (D_SQWC_SQWC_MASK << D_SQWC_SQWC_SHIFT)))
332 1.1 uch
333 1.1 uch /*
334 1.1 uch * Ring buffer address register
335 1.1 uch * 16byte alignment address [30:4]
336 1.1 uch */
337 1.1 uch
338 1.1 uch /*
339 1.1 uch * Ring buffer size register
340 1.1 uch * must be 2 ** n qword. [30:4]
341 1.1 uch */
342 1.1 uch
343 1.1 uch /*
344 1.1 uch * Stall address register
345 1.1 uch * [30:0] (qword alignment)
346 1.1 uch */
347 1.1 uch
348 1.1 uch /*
349 1.1 uch * DMA suspend register
350 1.1 uch */
351 1.1 uch #define D_ENABLE_SUSPEND 0x00010000
352 1.1 uch
353 1.1 uch
354 1.1 uch /*
355 1.1 uch * Channel specific register.
356 1.1 uch */
357 1.1 uch
358 1.1 uch /* CHANNEL CONTROL REGISTER */
359 1.1 uch /* upper 16bit of DMA tag last read. */
360 1.1 uch #define D_CHCR_TAG_MASK 0xff
361 1.1 uch #define D_CHCR_TAG_SHIFT 16
362 1.1 uch #define D_CHCR_TAG(x) \
363 1.1 uch (((x) >> D_CHCR_TAG_SHIFT) & D_CHCR_TAG_MASK)
364 1.1 uch #define D_CHCR_TAG_CLR(x) \
365 1.1 uch ((x) & ~(D_CHCR_TAG_MASK << D_CHCR_TAG_SHIFT))
366 1.1 uch #define D_CHCR_TAG_SET(x, val) \
367 1.1 uch ((x) | (((val) << D_CHCR_TAG_SHIFT) & \
368 1.1 uch (D_CHCR_TAG_MASK << D_CHCR_TAG_SHIFT)))
369 1.1 uch /* DMA start */
370 1.1 uch #define D_CHCR_STR 0x00000100
371 1.1 uch /* Tag interrupt enable (IRQ bit of DMAtag) */
372 1.1 uch #define D_CHCR_TIE 0x00000080
373 1.1 uch /* Tag transfer enable (Source chain mode only) */
374 1.1 uch #define D_CHCR_TTE 0x00000040
375 1.1 uch /* Address stack pointer */
376 1.1 uch #define D_CHCR_ASP_MASK 0x3
377 1.1 uch #define D_CHCR_ASP_SHIFT 4
378 1.1 uch #define D_CHCR_ASP(x) \
379 1.1 uch (((x) >> D_CHCR_ASP_SHIFT) & D_CHCR_ASP_MASK)
380 1.1 uch #define D_CHCR_ASP_CLR(x) \
381 1.1 uch ((x) & ~(D_CHCR_ASP_MASK << D_CHCR_ASP_SHIFT))
382 1.1 uch #define D_CHCR_ASP_SET(x, val) \
383 1.1 uch ((x) | (((val) << D_CHCR_ASP_SHIFT) & \
384 1.1 uch (D_CHCR_ASP_MASK << D_CHCR_ASP_SHIFT)))
385 1.1 uch #define D_CHCR_ASP_PUSHED_NONE 0
386 1.1 uch #define D_CHCR_ASP_PUSHED_1 1
387 1.1 uch #define D_CHCR_ASP_PUSHED_2 2
388 1.1 uch /* Logical transfer mode */
389 1.1 uch #define D_CHCR_MOD_MASK 0x3
390 1.1 uch #define D_CHCR_MOD_SHIFT 2
391 1.1 uch #define D_CHCR_MOD(x) \
392 1.1 uch (((x) >> D_CHCR_MOD_SHIFT) & D_CHCR_MOD_MASK)
393 1.1 uch #define D_CHCR_MOD_CLR(x) \
394 1.1 uch ((x) & ~(D_CHCR_MOD_MASK << D_CHCR_MOD_SHIFT))
395 1.1 uch #define D_CHCR_MOD_SET(x, val) \
396 1.1 uch ((x) | (((val) << D_CHCR_MOD_SHIFT) & \
397 1.1 uch (D_CHCR_MOD_MASK << D_CHCR_MOD_SHIFT)))
398 1.1 uch #define D_CHCR_MOD_NORMAL 0
399 1.1 uch #define D_CHCR_MOD_CHAIN 1
400 1.1 uch #define D_CHCR_MOD_INTERLEAVE 2
401 1.1 uch /*
402 1.1 uch * DMA transfer direction (1 ... from Memory, 0 ... to Memory)
403 1.1 uch * (VIF1, SIF2 only. i.e. `both'-direction channel requires this)
404 1.1 uch */
405 1.1 uch #define D_CHCR_DIR 0x00000001
406 1.1 uch
407 1.1 uch /*
408 1.1 uch * TRANSFER ADDRESS REGISTER (D-RAM address)
409 1.1 uch * 16 byte alignment. In FROMSPR, TOSPR channel, D_MADR_SPR always 0
410 1.1 uch */
411 1.1 uch #define D_MADR_SPR 0x80000000
412 1.1 uch
413 1.1 uch /*
414 1.1 uch * TAG ADDRESS REGISTER (next tag address)
415 1.1 uch * 16 byte alignment.
416 1.1 uch */
417 1.1 uch #define D_TADR_SPR 0x80000000
418 1.1 uch
419 1.1 uch /*
420 1.1 uch * TAG ADDRESS STACK REGISTER (2 stage)
421 1.1 uch * 16 byte alignment.
422 1.1 uch */
423 1.1 uch #define D_ASR_SPR 0x80000000
424 1.1 uch
425 1.1 uch /*
426 1.1 uch * SPR TRANSFER ADDRESS REGISTER (SPR address)
427 1.1 uch * 16 byte alignment. FROMSPR, TOSPR only.
428 1.1 uch */
429 1.1 uch #define D_SADR_MASK 0x3fff
430 1.1 uch #define D_SADR_SHIFT 0
431 1.1 uch #define D_SADR(x) \
432 1.1 uch ((u_int32_t)(x) & D_SADR_MASK)
433 1.1 uch /*
434 1.1 uch * TRANSFER SIZE REGISTER
435 1.1 uch * min 16 byte to max 1 Mbyte.
436 1.1 uch */
437 1.1 uch #define D_QWC_MASK 0xffff
438 1.1 uch #define D_QWC_SHIFT 0
439 1.1 uch #define D_QWC(x) (((x) >> D_QWC_SHIFT) & D_QWC_MASK)
440 1.1 uch #define D_QWC_CLR(x) ((x) & ~(D_QWC_MASK << D_QWC_SHIFT))
441 1.1 uch #define D_QWC_SET(x, val) \
442 1.1 uch ((x) | (((val) << D_QWC_SHIFT) & D_QWC_MASK << D_QWC_SHIFT))
443 1.1 uch
444 1.1 uch /*
445 1.1 uch * Source/Destination Chain Tag definition.
446 1.1 uch * SC ... VIF0, VIF1, GIF, toIPU, SIF1, toSPR
447 1.1 uch * DC ... SIF0, fromSPR
448 1.1 uch */
449 1.1 uch /*
450 1.1 uch * DMA address
451 1.1 uch * At least, 16byte align.
452 1.1 uch * but 64byte align is recommended. because EE D-cash line size is 64byte.
453 1.1 uch * To gain maximum DMA speed, use 128 byte align.
454 1.1 uch */
455 1.1 uch #define DMATAG_ADDR_MASK 0xffffffff
456 1.1 uch #define DMATAG_ADDR_SHIFT 32
457 1.1 uch #define DMATAG_ADDR(x) \
458 1.1 uch ((u_int32_t)(((x) >> DMATAG_ADDR_SHIFT) & DMATAG_ADDR_MASK))
459 1.1 uch #define DMATAG_ADDR_SET(x, val) \
460 1.1 uch ((dmatag_t)(x) | (((dmatag_t)(val)) << DMATAG_ADDR_SHIFT))
461 1.1 uch
462 1.1 uch #define DMATAG_ADDR32_INVALID(x) ((x) & 0xf) /* 16byte alignment */
463 1.1 uch
464 1.1 uch /*
465 1.1 uch * DMA controller command
466 1.1 uch */
467 1.1 uch #define DMATAG_CMD_MASK 0xffffffff
468 1.1 uch #define DMATAG_CMD_SHIFT 0
469 1.1 uch #define DMATAG_CMD(x) \
470 1.1 uch ((u_int32_t)((x) & DMATAG_CMD_MASK))
471 1.1 uch
472 1.1 uch #define DMATAG_CMD_IRQ 0x80000000
473 1.1 uch
474 1.1 uch #define DMATAG_CMD_ID_MASK 0x7
475 1.1 uch #define DMATAG_CMD_ID_SHIFT 28
476 1.1 uch #define DMATAG_CMD_ID(x) \
477 1.1 uch (((x) >> DMATAG_CMD_ID_SHIFT) & DMATAG_CMD_ID_MASK)
478 1.1 uch #define DMATAG_CMD_ID_CLR(x) \
479 1.1 uch ((x) & ~(DMATAG_CMD_ID_MASK << DMATAG_CMD_ID_SHIFT))
480 1.1 uch #define DMATAG_CMD_ID_SET(x, val) \
481 1.1 uch ((x) | (((val) << DMATAG_CMD_ID_SHIFT) & \
482 1.1 uch (DMATAG_CMD_ID_MASK << DMATAG_CMD_ID_SHIFT)))
483 1.1 uch #define DMATAG_CMD_SCID_REFE 0
484 1.1 uch #define DMATAG_CMD_SCID_CNT 1
485 1.1 uch #define DMATAG_CMD_SCID_NEXT 2
486 1.1 uch #define DMATAG_CMD_SCID_REF 3
487 1.1 uch #define DMATAG_CMD_SCID_REFS 4 /* VIF1, GIF, SIF1 only */
488 1.1 uch #define DMATAG_CMD_SCID_CALL 5 /* VIF0, VIF1, GIF only */
489 1.1 uch #define DMATAG_CMD_SCID_RET 6 /* VIF0, VIF1, GIF only */
490 1.1 uch #define DMATAG_CMD_SCID_END 7
491 1.1 uch
492 1.1 uch #define DMATAG_CMD_DCID_CNTS 0 /* SIF0, fromSPR only */
493 1.1 uch #define DMATAG_CMD_DCID_CNT 1
494 1.1 uch #define DMATAG_CMD_DCID_END 7
495 1.1 uch
496 1.1 uch #define DMATAG_CMD_PCE_MASK 0x3
497 1.1 uch #define DMATAG_CMD_PCE_SHIFT 26
498 1.1 uch #define DMATAG_CMD_PCE(x) \
499 1.1 uch (((x) >> DMATAG_CMD_PCE_SHIFT) & DMATAG_CMD_PCE_MASK)
500 1.1 uch #define DMATAG_CMD_PCE_CLR(x) \
501 1.1 uch ((x) & ~(DMATAG_CMD_PCE_MASK << DMATAG_CMD_PCE_SHIFT))
502 1.1 uch #define DMATAG_CMD_PCE_SET(x, val) \
503 1.1 uch ((x) | (((val) << DMATAG_CMD_PCE_SHIFT) & \
504 1.1 uch (DMATAG_CMD_PCE_MASK << DMATAG_CMD_PCE_SHIFT)))
505 1.1 uch #define DMATAG_CMD_PCE_NONE 0
506 1.1 uch #define DMATAG_CMD_PCE_DISABLE 2
507 1.1 uch #define DMATAG_CMD_PCE_ENABLE 3
508 1.1 uch
509 1.1 uch #define DMATAG_CMD_QWC_MASK 0xffff
510 1.1 uch #define DMATAG_CMD_QWC_SHIFT 0
511 1.1 uch #define DMATAG_CMD_QWC(x) \
512 1.1 uch (((x) >> DMATAG_CMD_QWC_SHIFT) & DMATAG_CMD_QWC_MASK)
513 1.1 uch #define DMATAG_CMD_QWC_CLR(x) \
514 1.1 uch ((x) & ~(DMATAG_CMD_QWC_MASK << DMATAG_CMD_QWC_SHIFT))
515 1.1 uch #define DMATAG_CMD_QWC_SET(x, val) \
516 1.1 uch ((x) | (((val) << DMATAG_CMD_QWC_SHIFT) & \
517 1.1 uch (DMATAG_CMD_QWC_MASK << DMATAG_CMD_QWC_SHIFT)))
518