2 * DMA C definitions and help macros
9 /* registers */ /* Really needed, since both are listed in sw.list? */
15 // ------------------------------------------------------------ dma_descr_group
16 typedef struct dma_descr_group
{
17 struct dma_descr_group
*next
;
28 struct dma_descr_group
*up
;
30 struct dma_descr_context
*context
;
31 struct dma_descr_group
*group
;
35 // ---------------------------------------------------------- dma_descr_context
36 typedef struct dma_descr_context
{
37 struct dma_descr_context
*next
;
42 unsigned store_mode
: 1;
51 struct dma_descr_data
*saved_data
;
55 // ------------------------------------------------------------- dma_descr_data
56 typedef struct dma_descr_data
{
57 struct dma_descr_data
*next
;
72 // --------------------------------------------------------------------- macros
75 #define DMA_ENABLE( inst ) \
76 do { reg_dma_rw_cfg e = REG_RD( dma, inst, rw_cfg );\
77 e.en = regk_dma_yes; \
78 REG_WR( dma, inst, rw_cfg, e); } while( 0 )
81 #define DMA_RESET( inst ) \
82 do { reg_dma_rw_cfg r = REG_RD( dma, inst, rw_cfg );\
84 REG_WR( dma, inst, rw_cfg, r); } while( 0 )
87 #define DMA_STOP( inst ) \
88 do { reg_dma_rw_cfg s = REG_RD( dma, inst, rw_cfg );\
89 s.stop = regk_dma_yes; \
90 REG_WR( dma, inst, rw_cfg, s); } while( 0 )
92 // continue DMA channel operation
93 #define DMA_CONTINUE( inst ) \
94 do { reg_dma_rw_cfg c = REG_RD( dma, inst, rw_cfg );\
95 c.stop = regk_dma_no; \
96 REG_WR( dma, inst, rw_cfg, c); } while( 0 )
98 // give stream command
99 #define DMA_WR_CMD( inst, cmd_par ) \
100 do { reg_dma_rw_stream_cmd __x = {0}; \
101 do { __x = REG_RD(dma, inst, rw_stream_cmd); } while (__x.busy); \
102 __x.cmd = (cmd_par); \
103 REG_WR(dma, inst, rw_stream_cmd, __x); \
107 #define DMA_START_GROUP( inst, group_descr ) \
108 do { REG_WR_INT( dma, inst, rw_group, (int) group_descr ); \
109 DMA_WR_CMD( inst, regk_dma_load_g ); \
110 DMA_WR_CMD( inst, regk_dma_load_c ); \
111 DMA_WR_CMD( inst, regk_dma_load_d | regk_dma_burst ); \
115 #define DMA_START_CONTEXT( inst, ctx_descr ) \
116 do { REG_WR_INT( dma, inst, rw_group_down, (int) ctx_descr ); \
117 DMA_WR_CMD( inst, regk_dma_load_c ); \
118 DMA_WR_CMD( inst, regk_dma_load_d | regk_dma_burst ); \
121 // if the DMA is at the end of the data list, the last data descr is reloaded
122 #define DMA_CONTINUE_DATA( inst ) \
123 do { reg_dma_rw_cmd c = {0}; \
124 c.cont_data = regk_dma_yes;\
125 REG_WR( dma, inst, rw_cmd, c ); } while( 0 )