aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-mips/mach-au1x00/au1xxx_dbdma.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-mips/mach-au1x00/au1xxx_dbdma.h')
-rw-r--r--include/asm-mips/mach-au1x00/au1xxx_dbdma.h155
1 files changed, 74 insertions, 81 deletions
diff --git a/include/asm-mips/mach-au1x00/au1xxx_dbdma.h b/include/asm-mips/mach-au1x00/au1xxx_dbdma.h
index 93d507cea518..ad17d7ce516a 100644
--- a/include/asm-mips/mach-au1x00/au1xxx_dbdma.h
+++ b/include/asm-mips/mach-au1x00/au1xxx_dbdma.h
@@ -28,17 +28,18 @@
28 * 675 Mass Ave, Cambridge, MA 02139, USA. 28 * 675 Mass Ave, Cambridge, MA 02139, USA.
29 */ 29 */
30 30
31/* Specifics for the Au1xxx Descriptor-Based DMA Controllers, first 31/*
32 * seen in the AU1550 part. 32 * Specifics for the Au1xxx Descriptor-Based DMA Controller,
33 * first seen in the AU1550 part.
33 */ 34 */
34#ifndef _AU1000_DBDMA_H_ 35#ifndef _AU1000_DBDMA_H_
35#define _AU1000_DBDMA_H_ 36#define _AU1000_DBDMA_H_
36 37
37
38#ifndef _LANGUAGE_ASSEMBLY 38#ifndef _LANGUAGE_ASSEMBLY
39 39
40/* The DMA base addresses. 40/*
41 * The Channels are every 256 bytes (0x0100) from the channel 0 base. 41 * The DMA base addresses.
42 * The channels are every 256 bytes (0x0100) from the channel 0 base.
42 * Interrupt status/enable is bits 15:0 for channels 15 to zero. 43 * Interrupt status/enable is bits 15:0 for channels 15 to zero.
43 */ 44 */
44#define DDMA_GLOBAL_BASE 0xb4003000 45#define DDMA_GLOBAL_BASE 0xb4003000
@@ -51,16 +52,14 @@ typedef volatile struct dbdma_global {
51 u32 ddma_inten; 52 u32 ddma_inten;
52} dbdma_global_t; 53} dbdma_global_t;
53 54
54/* General Configuration. 55/* General Configuration. */
55*/
56#define DDMA_CONFIG_AF (1 << 2) 56#define DDMA_CONFIG_AF (1 << 2)
57#define DDMA_CONFIG_AH (1 << 1) 57#define DDMA_CONFIG_AH (1 << 1)
58#define DDMA_CONFIG_AL (1 << 0) 58#define DDMA_CONFIG_AL (1 << 0)
59 59
60#define DDMA_THROTTLE_EN (1 << 31) 60#define DDMA_THROTTLE_EN (1 << 31)
61 61
62/* The structure of a DMA Channel. 62/* The structure of a DMA Channel. */
63*/
64typedef volatile struct au1xxx_dma_channel { 63typedef volatile struct au1xxx_dma_channel {
65 u32 ddma_cfg; /* See below */ 64 u32 ddma_cfg; /* See below */
66 u32 ddma_desptr; /* 32-byte aligned pointer to descriptor */ 65 u32 ddma_desptr; /* 32-byte aligned pointer to descriptor */
@@ -69,8 +68,7 @@ typedef volatile struct au1xxx_dma_channel {
69 u32 ddma_irq; /* If bit 0 set, interrupt pending */ 68 u32 ddma_irq; /* If bit 0 set, interrupt pending */
70 u32 ddma_stat; /* See below */ 69 u32 ddma_stat; /* See below */
71 u32 ddma_bytecnt; /* Byte count, valid only when chan idle */ 70 u32 ddma_bytecnt; /* Byte count, valid only when chan idle */
72 /* Remainder, up to the 256 byte boundary, is reserved. 71 /* Remainder, up to the 256 byte boundary, is reserved. */
73 */
74} au1x_dma_chan_t; 72} au1x_dma_chan_t;
75 73
76#define DDMA_CFG_SED (1 << 9) /* source DMA level/edge detect */ 74#define DDMA_CFG_SED (1 << 9) /* source DMA level/edge detect */
@@ -84,7 +82,8 @@ typedef volatile struct au1xxx_dma_channel {
84#define DDMA_CFG_DBE (1 << 1) /* Destination big endian */ 82#define DDMA_CFG_DBE (1 << 1) /* Destination big endian */
85#define DDMA_CFG_EN (1 << 0) /* Channel enable */ 83#define DDMA_CFG_EN (1 << 0) /* Channel enable */
86 84
87/* Always set when descriptor processing done, regardless of 85/*
86 * Always set when descriptor processing done, regardless of
88 * interrupt enable state. Reflected in global intstat, don't 87 * interrupt enable state. Reflected in global intstat, don't
89 * clear this until global intstat is read/used. 88 * clear this until global intstat is read/used.
90 */ 89 */
@@ -94,7 +93,8 @@ typedef volatile struct au1xxx_dma_channel {
94#define DDMA_STAT_V (1 << 1) /* Descriptor valid */ 93#define DDMA_STAT_V (1 << 1) /* Descriptor valid */
95#define DDMA_STAT_H (1 << 0) /* Channel Halted */ 94#define DDMA_STAT_H (1 << 0) /* Channel Halted */
96 95
97/* "Standard" DDMA Descriptor. 96/*
97 * "Standard" DDMA Descriptor.
98 * Must be 32-byte aligned. 98 * Must be 32-byte aligned.
99 */ 99 */
100typedef volatile struct au1xxx_ddma_desc { 100typedef volatile struct au1xxx_ddma_desc {
@@ -106,8 +106,9 @@ typedef volatile struct au1xxx_ddma_desc {
106 u32 dscr_dest1; /* See below */ 106 u32 dscr_dest1; /* See below */
107 u32 dscr_stat; /* completion status */ 107 u32 dscr_stat; /* completion status */
108 u32 dscr_nxtptr; /* Next descriptor pointer (mostly) */ 108 u32 dscr_nxtptr; /* Next descriptor pointer (mostly) */
109 /* First 32bytes are HW specific!!! 109 /*
110 Lets have some SW data following.. make sure its 32bytes 110 * First 32 bytes are HW specific!!!
111 * Lets have some SW data following -- make sure it's 32 bytes.
111 */ 112 */
112 u32 sw_status; 113 u32 sw_status;
113 u32 sw_context; 114 u32 sw_context;
@@ -130,10 +131,9 @@ typedef volatile struct au1xxx_ddma_desc {
130#define DSCR_CMD0_CV (0x1 << 2) /* Clear Valid when done */ 131#define DSCR_CMD0_CV (0x1 << 2) /* Clear Valid when done */
131#define DSCR_CMD0_ST_MASK (0x3 << 0) /* Status instruction */ 132#define DSCR_CMD0_ST_MASK (0x3 << 0) /* Status instruction */
132 133
133#define SW_STATUS_INUSE (1<<0) 134#define SW_STATUS_INUSE (1 << 0)
134 135
135/* Command 0 device IDs. 136/* Command 0 device IDs. */
136*/
137#ifdef CONFIG_SOC_AU1550 137#ifdef CONFIG_SOC_AU1550
138#define DSCR_CMD0_UART0_TX 0 138#define DSCR_CMD0_UART0_TX 0
139#define DSCR_CMD0_UART0_RX 1 139#define DSCR_CMD0_UART0_RX 1
@@ -198,16 +198,15 @@ typedef volatile struct au1xxx_ddma_desc {
198#define DSCR_CMD0_THROTTLE 30 198#define DSCR_CMD0_THROTTLE 30
199#define DSCR_CMD0_ALWAYS 31 199#define DSCR_CMD0_ALWAYS 31
200#define DSCR_NDEV_IDS 32 200#define DSCR_NDEV_IDS 32
201/* THis macro is used to find/create custom device types */ 201/* This macro is used to find/create custom device types */
202#define DSCR_DEV2CUSTOM_ID(x, d) (((((x)&0xFFFF)<<8)|0x32000000)|((d)&0xFF)) 202#define DSCR_DEV2CUSTOM_ID(x, d) (((((x) & 0xFFFF) << 8) | 0x32000000) | \
203#define DSCR_CUSTOM2DEV_ID(x) ((x)&0xFF) 203 ((d) & 0xFF))
204 204#define DSCR_CUSTOM2DEV_ID(x) ((x) & 0xFF)
205 205
206#define DSCR_CMD0_SID(x) (((x) & 0x1f) << 25) 206#define DSCR_CMD0_SID(x) (((x) & 0x1f) << 25)
207#define DSCR_CMD0_DID(x) (((x) & 0x1f) << 20) 207#define DSCR_CMD0_DID(x) (((x) & 0x1f) << 20)
208 208
209/* Source/Destination transfer width. 209/* Source/Destination transfer width. */
210*/
211#define DSCR_CMD0_BYTE 0 210#define DSCR_CMD0_BYTE 0
212#define DSCR_CMD0_HALFWORD 1 211#define DSCR_CMD0_HALFWORD 1
213#define DSCR_CMD0_WORD 2 212#define DSCR_CMD0_WORD 2
@@ -215,16 +214,14 @@ typedef volatile struct au1xxx_ddma_desc {
215#define DSCR_CMD0_SW(x) (((x) & 0x3) << 18) 214#define DSCR_CMD0_SW(x) (((x) & 0x3) << 18)
216#define DSCR_CMD0_DW(x) (((x) & 0x3) << 16) 215#define DSCR_CMD0_DW(x) (((x) & 0x3) << 16)
217 216
218/* DDMA Descriptor Type. 217/* DDMA Descriptor Type. */
219*/
220#define DSCR_CMD0_STANDARD 0 218#define DSCR_CMD0_STANDARD 0
221#define DSCR_CMD0_LITERAL 1 219#define DSCR_CMD0_LITERAL 1
222#define DSCR_CMD0_CMP_BRANCH 2 220#define DSCR_CMD0_CMP_BRANCH 2
223 221
224#define DSCR_CMD0_DT(x) (((x) & 0x3) << 13) 222#define DSCR_CMD0_DT(x) (((x) & 0x3) << 13)
225 223
226/* Status Instruction. 224/* Status Instruction. */
227*/
228#define DSCR_CMD0_ST_NOCHANGE 0 /* Don't change */ 225#define DSCR_CMD0_ST_NOCHANGE 0 /* Don't change */
229#define DSCR_CMD0_ST_CURRENT 1 /* Write current status */ 226#define DSCR_CMD0_ST_CURRENT 1 /* Write current status */
230#define DSCR_CMD0_ST_CMD0 2 /* Write cmd0 with V cleared */ 227#define DSCR_CMD0_ST_CMD0 2 /* Write cmd0 with V cleared */
@@ -232,23 +229,20 @@ typedef volatile struct au1xxx_ddma_desc {
232 229
233#define DSCR_CMD0_ST(x) (((x) & 0x3) << 0) 230#define DSCR_CMD0_ST(x) (((x) & 0x3) << 0)
234 231
235/* Descriptor Command 1 232/* Descriptor Command 1. */
236*/
237#define DSCR_CMD1_SUPTR_MASK (0xf << 28) /* upper 4 bits of src addr */ 233#define DSCR_CMD1_SUPTR_MASK (0xf << 28) /* upper 4 bits of src addr */
238#define DSCR_CMD1_DUPTR_MASK (0xf << 24) /* upper 4 bits of dest addr */ 234#define DSCR_CMD1_DUPTR_MASK (0xf << 24) /* upper 4 bits of dest addr */
239#define DSCR_CMD1_FL_MASK (0x3 << 22) /* Flag bits */ 235#define DSCR_CMD1_FL_MASK (0x3 << 22) /* Flag bits */
240#define DSCR_CMD1_BC_MASK (0x3fffff) /* Byte count */ 236#define DSCR_CMD1_BC_MASK (0x3fffff) /* Byte count */
241 237
242/* Flag description. 238/* Flag description. */
243*/
244#define DSCR_CMD1_FL_MEM_STRIDE0 0 239#define DSCR_CMD1_FL_MEM_STRIDE0 0
245#define DSCR_CMD1_FL_MEM_STRIDE1 1 240#define DSCR_CMD1_FL_MEM_STRIDE1 1
246#define DSCR_CMD1_FL_MEM_STRIDE2 2 241#define DSCR_CMD1_FL_MEM_STRIDE2 2
247 242
248#define DSCR_CMD1_FL(x) (((x) & 0x3) << 22) 243#define DSCR_CMD1_FL(x) (((x) & 0x3) << 22)
249 244
250/* Source1, 1-dimensional stride. 245/* Source1, 1-dimensional stride. */
251*/
252#define DSCR_SRC1_STS_MASK (3 << 30) /* Src xfer size */ 246#define DSCR_SRC1_STS_MASK (3 << 30) /* Src xfer size */
253#define DSCR_SRC1_SAM_MASK (3 << 28) /* Src xfer movement */ 247#define DSCR_SRC1_SAM_MASK (3 << 28) /* Src xfer movement */
254#define DSCR_SRC1_SB_MASK (0x3fff << 14) /* Block size */ 248#define DSCR_SRC1_SB_MASK (0x3fff << 14) /* Block size */
@@ -256,8 +250,7 @@ typedef volatile struct au1xxx_ddma_desc {
256#define DSCR_SRC1_SS_MASK (0x3fff << 0) /* Stride */ 250#define DSCR_SRC1_SS_MASK (0x3fff << 0) /* Stride */
257#define DSCR_SRC1_SS(x) (((x) & 0x3fff) << 0) 251#define DSCR_SRC1_SS(x) (((x) & 0x3fff) << 0)
258 252
259/* Dest1, 1-dimensional stride. 253/* Dest1, 1-dimensional stride. */
260*/
261#define DSCR_DEST1_DTS_MASK (3 << 30) /* Dest xfer size */ 254#define DSCR_DEST1_DTS_MASK (3 << 30) /* Dest xfer size */
262#define DSCR_DEST1_DAM_MASK (3 << 28) /* Dest xfer movement */ 255#define DSCR_DEST1_DAM_MASK (3 << 28) /* Dest xfer movement */
263#define DSCR_DEST1_DB_MASK (0x3fff << 14) /* Block size */ 256#define DSCR_DEST1_DB_MASK (0x3fff << 14) /* Block size */
@@ -279,29 +272,27 @@ typedef volatile struct au1xxx_ddma_desc {
279#define DSCR_SRC1_SAM(x) (((x) & 3) << 28) 272#define DSCR_SRC1_SAM(x) (((x) & 3) << 28)
280#define DSCR_DEST1_DAM(x) (((x) & 3) << 28) 273#define DSCR_DEST1_DAM(x) (((x) & 3) << 28)
281 274
282/* The next descriptor pointer. 275/* The next descriptor pointer. */
283*/
284#define DSCR_NXTPTR_MASK (0x07ffffff) 276#define DSCR_NXTPTR_MASK (0x07ffffff)
285#define DSCR_NXTPTR(x) ((x) >> 5) 277#define DSCR_NXTPTR(x) ((x) >> 5)
286#define DSCR_GET_NXTPTR(x) ((x) << 5) 278#define DSCR_GET_NXTPTR(x) ((x) << 5)
287#define DSCR_NXTPTR_MS (1 << 27) 279#define DSCR_NXTPTR_MS (1 << 27)
288 280
289/* The number of DBDMA channels. 281/* The number of DBDMA channels. */
290*/
291#define NUM_DBDMA_CHANS 16 282#define NUM_DBDMA_CHANS 16
292 283
293/* 284/*
294 * Ddma API definitions 285 * DDMA API definitions
295 * FIXME: may not fit to this header file 286 * FIXME: may not fit to this header file
296 */ 287 */
297typedef struct dbdma_device_table { 288typedef struct dbdma_device_table {
298 u32 dev_id; 289 u32 dev_id;
299 u32 dev_flags; 290 u32 dev_flags;
300 u32 dev_tsize; 291 u32 dev_tsize;
301 u32 dev_devwidth; 292 u32 dev_devwidth;
302 u32 dev_physaddr; /* If FIFO */ 293 u32 dev_physaddr; /* If FIFO */
303 u32 dev_intlevel; 294 u32 dev_intlevel;
304 u32 dev_intpolarity; 295 u32 dev_intpolarity;
305} dbdev_tab_t; 296} dbdev_tab_t;
306 297
307 298
@@ -316,44 +307,41 @@ typedef struct dbdma_chan_config {
316 au1x_ddma_desc_t *chan_desc_base; 307 au1x_ddma_desc_t *chan_desc_base;
317 au1x_ddma_desc_t *get_ptr, *put_ptr, *cur_ptr; 308 au1x_ddma_desc_t *get_ptr, *put_ptr, *cur_ptr;
318 void *chan_callparam; 309 void *chan_callparam;
319 void (*chan_callback)(int, void *); 310 void (*chan_callback)(int, void *);
320} chan_tab_t; 311} chan_tab_t;
321 312
322#define DEV_FLAGS_INUSE (1 << 0) 313#define DEV_FLAGS_INUSE (1 << 0)
323#define DEV_FLAGS_ANYUSE (1 << 1) 314#define DEV_FLAGS_ANYUSE (1 << 1)
324#define DEV_FLAGS_OUT (1 << 2) 315#define DEV_FLAGS_OUT (1 << 2)
325#define DEV_FLAGS_IN (1 << 3) 316#define DEV_FLAGS_IN (1 << 3)
326#define DEV_FLAGS_BURSTABLE (1 << 4) 317#define DEV_FLAGS_BURSTABLE (1 << 4)
327#define DEV_FLAGS_SYNC (1 << 5) 318#define DEV_FLAGS_SYNC (1 << 5)
328/* end Ddma API definitions */ 319/* end DDMA API definitions */
329 320
330/* External functions for drivers to use. 321/*
331*/ 322 * External functions for drivers to use.
332/* Use this to allocate a dbdma channel. The device ids are one of the 323 * Use this to allocate a DBDMA channel. The device IDs are one of
333 * DSCR_CMD0 devices IDs, which is usually redefined to a more 324 * the DSCR_CMD0 devices IDs, which is usually redefined to a more
334 * meaningful name. The 'callback' is called during dma completion 325 * meaningful name. The 'callback' is called during DMA completion
335 * interrupt. 326 * interrupt.
336 */ 327 */
337extern u32 au1xxx_dbdma_chan_alloc(u32 srcid, u32 destid, 328extern u32 au1xxx_dbdma_chan_alloc(u32 srcid, u32 destid,
338 void (*callback)(int, void *), void *callparam); 329 void (*callback)(int, void *),
330 void *callparam);
339 331
340#define DBDMA_MEM_CHAN DSCR_CMD0_ALWAYS 332#define DBDMA_MEM_CHAN DSCR_CMD0_ALWAYS
341 333
342/* Set the device width of a in/out fifo. 334/* Set the device width of an in/out FIFO. */
343*/
344u32 au1xxx_dbdma_set_devwidth(u32 chanid, int bits); 335u32 au1xxx_dbdma_set_devwidth(u32 chanid, int bits);
345 336
346/* Allocate a ring of descriptors for dbdma. 337/* Allocate a ring of descriptors for DBDMA. */
347*/
348u32 au1xxx_dbdma_ring_alloc(u32 chanid, int entries); 338u32 au1xxx_dbdma_ring_alloc(u32 chanid, int entries);
349 339
350/* Put buffers on source/destination descriptors. 340/* Put buffers on source/destination descriptors. */
351*/
352u32 _au1xxx_dbdma_put_source(u32 chanid, void *buf, int nbytes, u32 flags); 341u32 _au1xxx_dbdma_put_source(u32 chanid, void *buf, int nbytes, u32 flags);
353u32 _au1xxx_dbdma_put_dest(u32 chanid, void *buf, int nbytes, u32 flags); 342u32 _au1xxx_dbdma_put_dest(u32 chanid, void *buf, int nbytes, u32 flags);
354 343
355/* Get a buffer from the destination descriptor. 344/* Get a buffer from the destination descriptor. */
356*/
357u32 au1xxx_dbdma_get_dest(u32 chanid, void **buf, int *nbytes); 345u32 au1xxx_dbdma_get_dest(u32 chanid, void **buf, int *nbytes);
358 346
359void au1xxx_dbdma_stop(u32 chanid); 347void au1xxx_dbdma_stop(u32 chanid);
@@ -364,29 +352,34 @@ u32 au1xxx_get_dma_residue(u32 chanid);
364void au1xxx_dbdma_chan_free(u32 chanid); 352void au1xxx_dbdma_chan_free(u32 chanid);
365void au1xxx_dbdma_dump(u32 chanid); 353void au1xxx_dbdma_dump(u32 chanid);
366 354
367u32 au1xxx_dbdma_put_dscr(u32 chanid, au1x_ddma_desc_t *dscr ); 355u32 au1xxx_dbdma_put_dscr(u32 chanid, au1x_ddma_desc_t *dscr);
368 356
369u32 au1xxx_ddma_add_device( dbdev_tab_t *dev ); 357u32 au1xxx_ddma_add_device(dbdev_tab_t *dev);
370void * au1xxx_ddma_get_nextptr_virt(au1x_ddma_desc_t *dp); 358void *au1xxx_ddma_get_nextptr_virt(au1x_ddma_desc_t *dp);
371 359
372/* 360/*
373 Some compatibilty macros -- 361 * Some compatibilty macros -- needed to make changes to API
374 Needed to make changes to API without breaking existing drivers 362 * without breaking existing drivers.
375*/ 363 */
376#define au1xxx_dbdma_put_source(chanid, buf, nbytes)_au1xxx_dbdma_put_source(chanid, buf, nbytes, DDMA_FLAGS_IE) 364#define au1xxx_dbdma_put_source(chanid, buf, nbytes) \
377#define au1xxx_dbdma_put_source_flags(chanid, buf, nbytes, flags) _au1xxx_dbdma_put_source(chanid, buf, nbytes, flags) 365 _au1xxx_dbdma_put_source(chanid, buf, nbytes, DDMA_FLAGS_IE)
378#define put_source_flags(chanid, buf, nbytes, flags) au1xxx_dbdma_put_source_flags(chanid, buf, nbytes, flags) 366#define au1xxx_dbdma_put_source_flags(chanid, buf, nbytes, flags) \
379 367 _au1xxx_dbdma_put_source(chanid, buf, nbytes, flags)
380 368#define put_source_flags(chanid, buf, nbytes, flags) \
381#define au1xxx_dbdma_put_dest(chanid, buf, nbytes) _au1xxx_dbdma_put_dest(chanid, buf, nbytes, DDMA_FLAGS_IE) 369 au1xxx_dbdma_put_source_flags(chanid, buf, nbytes, flags)
382#define au1xxx_dbdma_put_dest_flags(chanid, buf, nbytes, flags) _au1xxx_dbdma_put_dest(chanid, buf, nbytes, flags) 370
383#define put_dest_flags(chanid, buf, nbytes, flags) au1xxx_dbdma_put_dest_flags(chanid, buf, nbytes, flags) 371#define au1xxx_dbdma_put_dest(chanid, buf, nbytes) \
372 _au1xxx_dbdma_put_dest(chanid, buf, nbytes, DDMA_FLAGS_IE)
373#define au1xxx_dbdma_put_dest_flags(chanid, buf, nbytes, flags) \
374 _au1xxx_dbdma_put_dest(chanid, buf, nbytes, flags)
375#define put_dest_flags(chanid, buf, nbytes, flags) \
376 au1xxx_dbdma_put_dest_flags(chanid, buf, nbytes, flags)
384 377
385/* 378/*
386 * Flags for the put_source/put_dest functions. 379 * Flags for the put_source/put_dest functions.
387 */ 380 */
388#define DDMA_FLAGS_IE (1<<0) 381#define DDMA_FLAGS_IE (1 << 0)
389#define DDMA_FLAGS_NOIE (1<<1) 382#define DDMA_FLAGS_NOIE (1 << 1)
390 383
391#endif /* _LANGUAGE_ASSEMBLY */ 384#endif /* _LANGUAGE_ASSEMBLY */
392#endif /* _AU1000_DBDMA_H_ */ 385#endif /* _AU1000_DBDMA_H_ */