iopaaureg.h revision 1.4 1 1.4 maxv /* $NetBSD: iopaaureg.h,v 1.4 2019/03/17 06:36:22 maxv Exp $ */
2 1.1 thorpej
3 1.1 thorpej /*
4 1.1 thorpej * Copyright (c) 2002 Wasabi Systems, Inc.
5 1.1 thorpej * All rights reserved.
6 1.1 thorpej *
7 1.1 thorpej * Written by Jason R. Thorpe for Wasabi Systems, Inc.
8 1.1 thorpej *
9 1.1 thorpej * Redistribution and use in source and binary forms, with or without
10 1.1 thorpej * modification, are permitted provided that the following conditions
11 1.1 thorpej * are met:
12 1.1 thorpej * 1. Redistributions of source code must retain the above copyright
13 1.1 thorpej * notice, this list of conditions and the following disclaimer.
14 1.1 thorpej * 2. Redistributions in binary form must reproduce the above copyright
15 1.1 thorpej * notice, this list of conditions and the following disclaimer in the
16 1.1 thorpej * documentation and/or other materials provided with the distribution.
17 1.1 thorpej * 3. All advertising materials mentioning features or use of this software
18 1.1 thorpej * must display the following acknowledgement:
19 1.1 thorpej * This product includes software developed for the NetBSD Project by
20 1.1 thorpej * Wasabi Systems, Inc.
21 1.1 thorpej * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22 1.1 thorpej * or promote products derived from this software without specific prior
23 1.1 thorpej * written permission.
24 1.1 thorpej *
25 1.1 thorpej * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26 1.1 thorpej * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 1.1 thorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 1.1 thorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
29 1.1 thorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 1.1 thorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 1.1 thorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 1.1 thorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 1.1 thorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 1.1 thorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 1.1 thorpej * POSSIBILITY OF SUCH DAMAGE.
36 1.1 thorpej */
37 1.1 thorpej
38 1.1 thorpej #ifndef _XSCALE_IOPAAUREG_H_
39 1.1 thorpej #define _XSCALE_IOPAAUREG_H_
40 1.1 thorpej
41 1.1 thorpej /*
42 1.1 thorpej * The AAU can transfer a maximum of 16MB.
43 1.1 thorpej *
44 1.1 thorpej * XXX The DMA maps are > 32K if we allow the maximum number
45 1.1 thorpej * XXX of DMA segments (16MB / 4K + 1) -- fix this bus_dma
46 1.1 thorpej * XXX problem.
47 1.1 thorpej */
48 1.1 thorpej #define AAU_MAX_XFER (16U * 1024 * 1024)
49 1.1 thorpej #if 0
50 1.1 thorpej #define AAU_MAX_SEGS ((AAU_MAX_XFER / PAGE_SIZE) + 1)
51 1.1 thorpej #else
52 1.1 thorpej #define AAU_MAX_SEGS 1024
53 1.1 thorpej #endif
54 1.1 thorpej
55 1.1 thorpej /*
56 1.1 thorpej * AAU I/O descriptor for operations with various numbers of inputs.
57 1.1 thorpej * Note that all descriptors must be 8-word (32-byte) aligned.
58 1.1 thorpej */
59 1.1 thorpej struct aau_desc_4 {
60 1.1 thorpej struct aau_desc_4 *d_next; /* pointer to next (va) */
61 1.1 thorpej uint32_t d_pa; /* our physical address */
62 1.1 thorpej
63 1.1 thorpej /* Hardware portion -- must be 32-byte aligned. */
64 1.4 maxv uint32_t d_nda __aligned(32); /* next descriptor address */
65 1.2 thorpej uint32_t d_sar[4]; /* source address */
66 1.1 thorpej uint32_t d_dar; /* destination address */
67 1.1 thorpej uint32_t d_bc; /* byte count */
68 1.1 thorpej uint32_t d_dc; /* descriptor control */
69 1.1 thorpej } __attribute__((__packed__));
70 1.1 thorpej
71 1.3 thorpej struct aau_desc_8 {
72 1.3 thorpej struct aau_desc_8 *d_next; /* pointer to next (va) */
73 1.3 thorpej uint32_t d_pa; /* our physical address */
74 1.3 thorpej
75 1.3 thorpej /* Hardware portion -- must be 32-byte aligned. */
76 1.4 maxv uint32_t d_nda __aligned(32); /* next descriptor address */
77 1.3 thorpej uint32_t d_sar[4]; /* source address */
78 1.3 thorpej uint32_t d_dar; /* destination address */
79 1.3 thorpej uint32_t d_bc; /* byte count */
80 1.3 thorpej uint32_t d_dc; /* descriptor control */
81 1.3 thorpej /* Mini Descriptor */
82 1.3 thorpej uint32_t d_sar5_8[4]; /* source address */
83 1.3 thorpej } __attribute__((__packed__));
84 1.3 thorpej
85 1.3 thorpej struct aau_desc_16 {
86 1.3 thorpej struct aau_desc_16 *d_next; /* pointer to next (va) */
87 1.3 thorpej uint32_t d_pa; /* our physical address */
88 1.3 thorpej
89 1.3 thorpej /* Hardware portion -- must be 32-byte aligned. */
90 1.4 maxv uint32_t d_nda __aligned(32); /* next descriptor address */
91 1.3 thorpej uint32_t d_sar[4]; /* source address */
92 1.3 thorpej uint32_t d_dar; /* destination address */
93 1.3 thorpej uint32_t d_bc; /* byte count */
94 1.3 thorpej uint32_t d_dc; /* descriptor control */
95 1.3 thorpej /* Mini Descriptor */
96 1.3 thorpej uint32_t d_sar5_8[4]; /* source address */
97 1.3 thorpej /* Extended Descriptor 0 */
98 1.3 thorpej uint32_t d_edc0; /* ext. descriptor control */
99 1.3 thorpej uint32_t d_sar9_16[8]; /* source address */
100 1.3 thorpej } __attribute__((__packed__));
101 1.3 thorpej
102 1.3 thorpej struct aau_desc_32 {
103 1.3 thorpej struct aau_desc_32 *d_next; /* pointer to next (va) */
104 1.3 thorpej uint32_t d_pa; /* our physical address */
105 1.3 thorpej
106 1.3 thorpej /* Hardware portion -- must be 32-byte aligned. */
107 1.4 maxv uint32_t d_nda __aligned(32); /* next descriptor address */
108 1.3 thorpej uint32_t d_sar[4]; /* source address */
109 1.3 thorpej uint32_t d_dar; /* destination address */
110 1.3 thorpej uint32_t d_bc; /* byte count */
111 1.3 thorpej uint32_t d_dc; /* descriptor control */
112 1.3 thorpej /* Mini Descriptor */
113 1.3 thorpej uint32_t d_sar5_8[4]; /* source address */
114 1.3 thorpej /* Extended Descriptor 0 */
115 1.3 thorpej uint32_t d_edc0; /* ext. descriptor control */
116 1.3 thorpej uint32_t d_sar9_16[8]; /* source address */
117 1.3 thorpej /* Extended Descriptor 1 */
118 1.3 thorpej uint32_t d_edc1; /* ext. descriptor control */
119 1.3 thorpej uint32_t d_sar17_24[8]; /* source address */
120 1.3 thorpej /* Extended Descriptor 2 */
121 1.3 thorpej uint32_t d_edc2; /* ext. descriptor control */
122 1.3 thorpej uint32_t d_sar25_32[8]; /* source address */
123 1.3 thorpej } __attribute__((__packed__));
124 1.3 thorpej
125 1.3 thorpej #define AAU_DESC_SIZE(ninputs) \
126 1.3 thorpej ((ninputs > 16) ? sizeof(struct aau_desc_32) : \
127 1.3 thorpej (ninputs > 8) ? sizeof(struct aau_desc_16) : \
128 1.3 thorpej (ninputs > 4) ? sizeof(struct aau_desc_8) : \
129 1.3 thorpej sizeof(struct aau_desc_4))
130 1.3 thorpej
131 1.1 thorpej #define SYNC_DESC_4_OFFSET offsetof(struct aau_desc_4, d_nda)
132 1.1 thorpej #define SYNC_DESC_4_SIZE (sizeof(struct aau_desc_4) - SYNC_DESC_4_OFFSET)
133 1.3 thorpej
134 1.3 thorpej #define SYNC_DESC(d, size) \
135 1.3 thorpej cpu_dcache_wbinv_range(((vaddr_t)(d)) + SYNC_DESC_4_OFFSET, (size))
136 1.1 thorpej
137 1.1 thorpej /* Descriptor control */
138 1.1 thorpej #define AAU_DC_IE (1U << 0) /* interrupt enable */
139 1.1 thorpej #define AAU_DC_B1_CC(x) ((x) << 1) /* block command/control */
140 1.1 thorpej #define AAU_DC_B2_CC(x) ((x) << 4)
141 1.1 thorpej #define AAU_DC_B3_CC(x) ((x) << 7)
142 1.1 thorpej #define AAU_DC_B4_CC(x) ((x) << 10)
143 1.1 thorpej #define AAU_DC_B5_CC(x) ((x) << 13)
144 1.1 thorpej #define AAU_DC_B6_CC(x) ((x) << 16)
145 1.1 thorpej #define AAU_DC_B7_CC(x) ((x) << 19)
146 1.1 thorpej #define AAU_DC_B8_CC(x) ((x) << 22)
147 1.1 thorpej #define AAU_DC_SBCI_5_8 (1U << 25) /* SAR5-SAR8 valid */
148 1.1 thorpej #define AAU_DC_SBCI_5_16 (2U << 25) /* SAR5-SAR16 valid */
149 1.1 thorpej #define AAU_DC_SBCI_5_32 (3U << 25) /* SAR5-SAR32 valid */
150 1.1 thorpej #define AAU_DC_TC (1U << 28) /* transfer complete */
151 1.1 thorpej #define AAU_DC_PERR (1U << 29) /* parity check error */
152 1.1 thorpej #define AAU_DC_PENB (1U << 30) /* parity check enable */
153 1.1 thorpej #define AAU_DC_DWE (1U << 31) /* destination write enable */
154 1.1 thorpej
155 1.1 thorpej #define AAU_DC_CC_NULL 0 /* null command */
156 1.1 thorpej #define AAU_DC_CC_XOR 1U /* XOR command */
157 1.1 thorpej #define AAU_DC_CC_FILL 2U /* fill command */
158 1.1 thorpej #define AAU_DC_CC_DIRECT_FILL 7U /* direct fill (copy) */
159 1.3 thorpej
160 1.3 thorpej /* Extended descriptor control */
161 1.3 thorpej #define AAU_EDC_B1_CC(x) ((x) << 1) /* block command/control */
162 1.3 thorpej #define AAU_EDC_B2_CC(x) ((x) << 4) /* block command/control */
163 1.3 thorpej #define AAU_EDC_B3_CC(x) ((x) << 7) /* block command/control */
164 1.3 thorpej #define AAU_EDC_B4_CC(x) ((x) << 10) /* block command/control */
165 1.3 thorpej #define AAU_EDC_B5_CC(x) ((x) << 13) /* block command/control */
166 1.3 thorpej #define AAU_EDC_B6_CC(x) ((x) << 16) /* block command/control */
167 1.3 thorpej #define AAU_EDC_B7_CC(x) ((x) << 19) /* block command/control */
168 1.3 thorpej #define AAU_EDC_B8_CC(x) ((x) << 22) /* block command/control */
169 1.1 thorpej
170 1.1 thorpej /* Hardware registers */
171 1.1 thorpej #define AAU_ACR 0x00 /* accelerator control */
172 1.1 thorpej #define AAU_ASR 0x04 /* accelerator status */
173 1.1 thorpej #define AAU_ADAR 0x08 /* descriptor address */
174 1.1 thorpej #define AAU_ANDAR 0x0c /* next descriptor address */
175 1.1 thorpej #define AAU_DAR 0x20 /* destination address */
176 1.1 thorpej #define AAU_ABCR 0x24 /* byte count */
177 1.1 thorpej #define AAU_ADCR 0x28 /* descriptor control */
178 1.1 thorpej /* i80321 only */
179 1.1 thorpej #define AAU_EDCR0 0x3c /* extended descriptor control 0 */
180 1.1 thorpej #define AAU_EDCR1 0x60 /* extended descriptor control 1 */
181 1.1 thorpej #define AAU_EDCR2 0x84 /* extended descriptor control 2 */
182 1.1 thorpej
183 1.1 thorpej #define AAU_ACR_AAE (1U << 0) /* accelerator enable */
184 1.1 thorpej #define AAU_ACR_CR (1U << 1) /* chain resume */
185 1.1 thorpej #define AAU_ACR_512 (1U << 2) /* 512-byte buffer enable */
186 1.1 thorpej
187 1.1 thorpej #define AAU_ASR_MA (1U << 5) /* master abort */
188 1.1 thorpej #define AAU_ASR_ECIF (1U << 8) /* end of chain interrupt */
189 1.1 thorpej #define AAU_ASR_ETIF (1U << 9) /* end of transfer interrupt */
190 1.1 thorpej #define AAU_ASR_AAF (1U << 10) /* acellerator active */
191 1.1 thorpej
192 1.1 thorpej #define AAU_ABCR_MASK 0x00ffffff /* 24-bit count */
193 1.1 thorpej
194 1.1 thorpej #endif /* _XSCALE_IOPAAUREG_H_ */
195