diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/asm-mips/mach-au1x00/au1xxx_dbdma.h |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'include/asm-mips/mach-au1x00/au1xxx_dbdma.h')
-rw-r--r-- | include/asm-mips/mach-au1x00/au1xxx_dbdma.h | 299 |
1 files changed, 299 insertions, 0 deletions
diff --git a/include/asm-mips/mach-au1x00/au1xxx_dbdma.h b/include/asm-mips/mach-au1x00/au1xxx_dbdma.h new file mode 100644 index 000000000000..d5eb88cd7d51 --- /dev/null +++ b/include/asm-mips/mach-au1x00/au1xxx_dbdma.h | |||
@@ -0,0 +1,299 @@ | |||
1 | /* | ||
2 | * | ||
3 | * BRIEF MODULE DESCRIPTION | ||
4 | * Include file for Alchemy Semiconductor's Au1550 Descriptor | ||
5 | * Based DMA Controller. | ||
6 | * | ||
7 | * Copyright 2004 Embedded Edge, LLC | ||
8 | * dan@embeddededge.com | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify it | ||
11 | * under the terms of the GNU General Public License as published by the | ||
12 | * Free Software Foundation; either version 2 of the License, or (at your | ||
13 | * option) any later version. | ||
14 | * | ||
15 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
16 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
17 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN | ||
18 | * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | ||
21 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
22 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
25 | * | ||
26 | * You should have received a copy of the GNU General Public License along | ||
27 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
28 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
29 | */ | ||
30 | |||
31 | /* Specifics for the Au1xxx Descriptor-Based DMA Controllers, first | ||
32 | * seen in the AU1550 part. | ||
33 | */ | ||
34 | #ifndef _AU1000_DBDMA_H_ | ||
35 | #define _AU1000_DBDMA_H_ | ||
36 | |||
37 | #include <linux/config.h> | ||
38 | |||
39 | #ifndef _LANGUAGE_ASSEMBLY | ||
40 | |||
41 | /* The DMA base addresses. | ||
42 | * The Channels are every 256 bytes (0x0100) from the channel 0 base. | ||
43 | * Interrupt status/enable is bits 15:0 for channels 15 to zero. | ||
44 | */ | ||
45 | #define DDMA_GLOBAL_BASE 0xb4003000 | ||
46 | #define DDMA_CHANNEL_BASE 0xb4002000 | ||
47 | |||
48 | typedef struct dbdma_global { | ||
49 | u32 ddma_config; | ||
50 | u32 ddma_intstat; | ||
51 | u32 ddma_throttle; | ||
52 | u32 ddma_inten; | ||
53 | } dbdma_global_t; | ||
54 | |||
55 | /* General Configuration. | ||
56 | */ | ||
57 | #define DDMA_CONFIG_AF (1 << 2) | ||
58 | #define DDMA_CONFIG_AH (1 << 1) | ||
59 | #define DDMA_CONFIG_AL (1 << 0) | ||
60 | |||
61 | #define DDMA_THROTTLE_EN (1 << 31) | ||
62 | |||
63 | /* The structure of a DMA Channel. | ||
64 | */ | ||
65 | typedef struct au1xxx_dma_channel { | ||
66 | u32 ddma_cfg; /* See below */ | ||
67 | u32 ddma_desptr; /* 32-byte aligned pointer to descriptor */ | ||
68 | u32 ddma_statptr; /* word aligned pointer to status word */ | ||
69 | u32 ddma_dbell; /* A write activates channel operation */ | ||
70 | u32 ddma_irq; /* If bit 0 set, interrupt pending */ | ||
71 | u32 ddma_stat; /* See below */ | ||
72 | u32 ddma_bytecnt; /* Byte count, valid only when chan idle */ | ||
73 | /* Remainder, up to the 256 byte boundary, is reserved. | ||
74 | */ | ||
75 | } au1x_dma_chan_t; | ||
76 | |||
77 | #define DDMA_CFG_SED (1 << 9) /* source DMA level/edge detect */ | ||
78 | #define DDMA_CFG_SP (1 << 8) /* source DMA polarity */ | ||
79 | #define DDMA_CFG_DED (1 << 7) /* destination DMA level/edge detect */ | ||
80 | #define DDMA_CFG_DP (1 << 6) /* destination DMA polarity */ | ||
81 | #define DDMA_CFG_SYNC (1 << 5) /* Sync static bus controller */ | ||
82 | #define DDMA_CFG_PPR (1 << 4) /* PCI posted read/write control */ | ||
83 | #define DDMA_CFG_DFN (1 << 3) /* Descriptor fetch non-coherent */ | ||
84 | #define DDMA_CFG_SBE (1 << 2) /* Source big endian */ | ||
85 | #define DDMA_CFG_DBE (1 << 1) /* Destination big endian */ | ||
86 | #define DDMA_CFG_EN (1 << 0) /* Channel enable */ | ||
87 | |||
88 | /* Always set when descriptor processing done, regardless of | ||
89 | * interrupt enable state. Reflected in global intstat, don't | ||
90 | * clear this until global intstat is read/used. | ||
91 | */ | ||
92 | #define DDMA_IRQ_IN (1 << 0) | ||
93 | |||
94 | #define DDMA_STAT_DB (1 << 2) /* Doorbell pushed */ | ||
95 | #define DDMA_STAT_V (1 << 1) /* Descriptor valid */ | ||
96 | #define DDMA_STAT_H (1 << 0) /* Channel Halted */ | ||
97 | |||
98 | /* "Standard" DDMA Descriptor. | ||
99 | * Must be 32-byte aligned. | ||
100 | */ | ||
101 | typedef struct au1xxx_ddma_desc { | ||
102 | u32 dscr_cmd0; /* See below */ | ||
103 | u32 dscr_cmd1; /* See below */ | ||
104 | u32 dscr_source0; /* source phys address */ | ||
105 | u32 dscr_source1; /* See below */ | ||
106 | u32 dscr_dest0; /* Destination address */ | ||
107 | u32 dscr_dest1; /* See below */ | ||
108 | u32 dscr_stat; /* completion status */ | ||
109 | u32 dscr_nxtptr; /* Next descriptor pointer (mostly) */ | ||
110 | } au1x_ddma_desc_t; | ||
111 | |||
112 | #define DSCR_CMD0_V (1 << 31) /* Descriptor valid */ | ||
113 | #define DSCR_CMD0_MEM (1 << 30) /* mem-mem transfer */ | ||
114 | #define DSCR_CMD0_SID_MASK (0x1f << 25) /* Source ID */ | ||
115 | #define DSCR_CMD0_DID_MASK (0x1f << 20) /* Destination ID */ | ||
116 | #define DSCR_CMD0_SW_MASK (0x3 << 18) /* Source Width */ | ||
117 | #define DSCR_CMD0_DW_MASK (0x3 << 16) /* Destination Width */ | ||
118 | #define DSCR_CMD0_ARB (0x1 << 15) /* Set for Hi Pri */ | ||
119 | #define DSCR_CMD0_DT_MASK (0x3 << 13) /* Descriptor Type */ | ||
120 | #define DSCR_CMD0_SN (0x1 << 12) /* Source non-coherent */ | ||
121 | #define DSCR_CMD0_DN (0x1 << 11) /* Destination non-coherent */ | ||
122 | #define DSCR_CMD0_SM (0x1 << 10) /* Stride mode */ | ||
123 | #define DSCR_CMD0_IE (0x1 << 8) /* Interrupt Enable */ | ||
124 | #define DSCR_CMD0_SP (0x1 << 4) /* Status pointer select */ | ||
125 | #define DSCR_CMD0_CV (0x1 << 2) /* Clear Valid when done */ | ||
126 | #define DSCR_CMD0_ST_MASK (0x3 << 0) /* Status instruction */ | ||
127 | |||
128 | /* Command 0 device IDs. | ||
129 | */ | ||
130 | #define DSCR_CMD0_UART0_TX 0 | ||
131 | #define DSCR_CMD0_UART0_RX 1 | ||
132 | #define DSCR_CMD0_UART3_TX 2 | ||
133 | #define DSCR_CMD0_UART3_RX 3 | ||
134 | #define DSCR_CMD0_DMA_REQ0 4 | ||
135 | #define DSCR_CMD0_DMA_REQ1 5 | ||
136 | #define DSCR_CMD0_DMA_REQ2 6 | ||
137 | #define DSCR_CMD0_DMA_REQ3 7 | ||
138 | #define DSCR_CMD0_USBDEV_RX0 8 | ||
139 | #define DSCR_CMD0_USBDEV_TX0 9 | ||
140 | #define DSCR_CMD0_USBDEV_TX1 10 | ||
141 | #define DSCR_CMD0_USBDEV_TX2 11 | ||
142 | #define DSCR_CMD0_USBDEV_RX3 12 | ||
143 | #define DSCR_CMD0_USBDEV_RX4 13 | ||
144 | #define DSCR_CMD0_PSC0_TX 14 | ||
145 | #define DSCR_CMD0_PSC0_RX 15 | ||
146 | #define DSCR_CMD0_PSC1_TX 16 | ||
147 | #define DSCR_CMD0_PSC1_RX 17 | ||
148 | #define DSCR_CMD0_PSC2_TX 18 | ||
149 | #define DSCR_CMD0_PSC2_RX 19 | ||
150 | #define DSCR_CMD0_PSC3_TX 20 | ||
151 | #define DSCR_CMD0_PSC3_RX 21 | ||
152 | #define DSCR_CMD0_PCI_WRITE 22 | ||
153 | #define DSCR_CMD0_NAND_FLASH 23 | ||
154 | #define DSCR_CMD0_MAC0_RX 24 | ||
155 | #define DSCR_CMD0_MAC0_TX 25 | ||
156 | #define DSCR_CMD0_MAC1_RX 26 | ||
157 | #define DSCR_CMD0_MAC1_TX 27 | ||
158 | #define DSCR_CMD0_THROTTLE 30 | ||
159 | #define DSCR_CMD0_ALWAYS 31 | ||
160 | #define DSCR_NDEV_IDS 32 | ||
161 | |||
162 | #define DSCR_CMD0_SID(x) (((x) & 0x1f) << 25) | ||
163 | #define DSCR_CMD0_DID(x) (((x) & 0x1f) << 20) | ||
164 | |||
165 | /* Source/Destination transfer width. | ||
166 | */ | ||
167 | #define DSCR_CMD0_BYTE 0 | ||
168 | #define DSCR_CMD0_HALFWORD 1 | ||
169 | #define DSCR_CMD0_WORD 2 | ||
170 | |||
171 | #define DSCR_CMD0_SW(x) (((x) & 0x3) << 18) | ||
172 | #define DSCR_CMD0_DW(x) (((x) & 0x3) << 16) | ||
173 | |||
174 | /* DDMA Descriptor Type. | ||
175 | */ | ||
176 | #define DSCR_CMD0_STANDARD 0 | ||
177 | #define DSCR_CMD0_LITERAL 1 | ||
178 | #define DSCR_CMD0_CMP_BRANCH 2 | ||
179 | |||
180 | #define DSCR_CMD0_DT(x) (((x) & 0x3) << 13) | ||
181 | |||
182 | /* Status Instruction. | ||
183 | */ | ||
184 | #define DSCR_CMD0_ST_NOCHANGE 0 /* Don't change */ | ||
185 | #define DSCR_CMD0_ST_CURRENT 1 /* Write current status */ | ||
186 | #define DSCR_CMD0_ST_CMD0 2 /* Write cmd0 with V cleared */ | ||
187 | #define DSCR_CMD0_ST_BYTECNT 3 /* Write remaining byte count */ | ||
188 | |||
189 | #define DSCR_CMD0_ST(x) (((x) & 0x3) << 0) | ||
190 | |||
191 | /* Descriptor Command 1 | ||
192 | */ | ||
193 | #define DSCR_CMD1_SUPTR_MASK (0xf << 28) /* upper 4 bits of src addr */ | ||
194 | #define DSCR_CMD1_DUPTR_MASK (0xf << 24) /* upper 4 bits of dest addr */ | ||
195 | #define DSCR_CMD1_FL_MASK (0x3 << 22) /* Flag bits */ | ||
196 | #define DSCR_CMD1_BC_MASK (0x3fffff) /* Byte count */ | ||
197 | |||
198 | /* Flag description. | ||
199 | */ | ||
200 | #define DSCR_CMD1_FL_MEM_STRIDE0 0 | ||
201 | #define DSCR_CMD1_FL_MEM_STRIDE1 1 | ||
202 | #define DSCR_CMD1_FL_MEM_STRIDE2 2 | ||
203 | |||
204 | #define DSCR_CMD1_FL(x) (((x) & 0x3) << 22) | ||
205 | |||
206 | /* Source1, 1-dimensional stride. | ||
207 | */ | ||
208 | #define DSCR_SRC1_STS_MASK (3 << 30) /* Src xfer size */ | ||
209 | #define DSCR_SRC1_SAM_MASK (3 << 28) /* Src xfer movement */ | ||
210 | #define DSCR_SRC1_SB_MASK (0x3fff << 14) /* Block size */ | ||
211 | #define DSCR_SRC1_SB(x) (((x) & 0x3fff) << 14) | ||
212 | #define DSCR_SRC1_SS_MASK (0x3fff << 0) /* Stride */ | ||
213 | #define DSCR_SRC1_SS(x) (((x) & 0x3fff) << 0) | ||
214 | |||
215 | /* Dest1, 1-dimensional stride. | ||
216 | */ | ||
217 | #define DSCR_DEST1_DTS_MASK (3 << 30) /* Dest xfer size */ | ||
218 | #define DSCR_DEST1_DAM_MASK (3 << 28) /* Dest xfer movement */ | ||
219 | #define DSCR_DEST1_DB_MASK (0x3fff << 14) /* Block size */ | ||
220 | #define DSCR_DEST1_DB(x) (((x) & 0x3fff) << 14) | ||
221 | #define DSCR_DEST1_DS_MASK (0x3fff << 0) /* Stride */ | ||
222 | #define DSCR_DEST1_DS(x) (((x) & 0x3fff) << 0) | ||
223 | |||
224 | #define DSCR_xTS_SIZE1 0 | ||
225 | #define DSCR_xTS_SIZE2 1 | ||
226 | #define DSCR_xTS_SIZE4 2 | ||
227 | #define DSCR_xTS_SIZE8 3 | ||
228 | #define DSCR_SRC1_STS(x) (((x) & 3) << 30) | ||
229 | #define DSCR_DEST1_DTS(x) (((x) & 3) << 30) | ||
230 | |||
231 | #define DSCR_xAM_INCREMENT 0 | ||
232 | #define DSCR_xAM_DECREMENT 1 | ||
233 | #define DSCR_xAM_STATIC 2 | ||
234 | #define DSCR_xAM_BURST 3 | ||
235 | #define DSCR_SRC1_SAM(x) (((x) & 3) << 28) | ||
236 | #define DSCR_DEST1_DAM(x) (((x) & 3) << 28) | ||
237 | |||
238 | /* The next descriptor pointer. | ||
239 | */ | ||
240 | #define DSCR_NXTPTR_MASK (0x07ffffff) | ||
241 | #define DSCR_NXTPTR(x) ((x) >> 5) | ||
242 | #define DSCR_GET_NXTPTR(x) ((x) << 5) | ||
243 | #define DSCR_NXTPTR_MS (1 << 27) | ||
244 | |||
245 | /* The number of DBDMA channels. | ||
246 | */ | ||
247 | #define NUM_DBDMA_CHANS 16 | ||
248 | |||
249 | /* External functions for drivers to use. | ||
250 | */ | ||
251 | /* Use this to allocate a dbdma channel. The device ids are one of the | ||
252 | * DSCR_CMD0 devices IDs, which is usually redefined to a more | ||
253 | * meaningful name. The 'callback' is called during dma completion | ||
254 | * interrupt. | ||
255 | */ | ||
256 | u32 au1xxx_dbdma_chan_alloc(u32 srcid, u32 destid, | ||
257 | void (*callback)(int, void *, struct pt_regs *), void *callparam); | ||
258 | |||
259 | #define DBDMA_MEM_CHAN DSCR_CMD0_ALWAYS | ||
260 | |||
261 | /* ACK! These should be in a board specific description file. | ||
262 | */ | ||
263 | #ifdef CONFIG_MIPS_PB1550 | ||
264 | #define DBDMA_AC97_TX_CHAN DSCR_CMD0_PSC1_TX | ||
265 | #define DBDMA_AC97_RX_CHAN DSCR_CMD0_PSC1_RX | ||
266 | #endif | ||
267 | #ifdef CONFIG_MIPS_DB1550 | ||
268 | #define DBDMA_AC97_TX_CHAN DSCR_CMD0_PSC1_TX | ||
269 | #define DBDMA_AC97_RX_CHAN DSCR_CMD0_PSC1_RX | ||
270 | #endif | ||
271 | |||
272 | |||
273 | /* Set the device width of a in/out fifo. | ||
274 | */ | ||
275 | u32 au1xxx_dbdma_set_devwidth(u32 chanid, int bits); | ||
276 | |||
277 | /* Allocate a ring of descriptors for dbdma. | ||
278 | */ | ||
279 | u32 au1xxx_dbdma_ring_alloc(u32 chanid, int entries); | ||
280 | |||
281 | /* Put buffers on source/destination descriptors. | ||
282 | */ | ||
283 | u32 au1xxx_dbdma_put_source(u32 chanid, void *buf, int nbytes); | ||
284 | u32 au1xxx_dbdma_put_dest(u32 chanid, void *buf, int nbytes); | ||
285 | |||
286 | /* Get a buffer from the destination descriptor. | ||
287 | */ | ||
288 | u32 au1xxx_dbdma_get_dest(u32 chanid, void **buf, int *nbytes); | ||
289 | |||
290 | void au1xxx_dbdma_stop(u32 chanid); | ||
291 | void au1xxx_dbdma_start(u32 chanid); | ||
292 | void au1xxx_dbdma_reset(u32 chanid); | ||
293 | u32 au1xxx_get_dma_residue(u32 chanid); | ||
294 | |||
295 | void au1xxx_dbdma_chan_free(u32 chanid); | ||
296 | void au1xxx_dbdma_dump(u32 chanid); | ||
297 | |||
298 | #endif /* _LANGUAGE_ASSEMBLY */ | ||
299 | #endif /* _AU1000_DBDMA_H_ */ | ||