1 |
800 |
filepang |
#ifndef _DMA_H_
|
2 |
|
|
#define _DMA_H_
|
3 |
|
|
|
4 |
|
|
struct dma_channel_descriptor {
|
5 |
|
|
unsigned int control;
|
6 |
|
|
unsigned int tranfer_size;
|
7 |
|
|
unsigned int src_addr;
|
8 |
|
|
unsigned int src_mask;
|
9 |
|
|
unsigned int dst_addr;
|
10 |
|
|
unsigned int dat_mask;
|
11 |
|
|
unsigned int list_desc;
|
12 |
|
|
unsigned int sw_ptr;
|
13 |
|
|
};
|
14 |
|
|
|
15 |
|
|
#define DMA_CHAN_NUMBER (31)
|
16 |
|
|
|
17 |
|
|
struct dma_t {
|
18 |
|
|
unsigned int control;
|
19 |
|
|
unsigned int int_msk_a;
|
20 |
|
|
unsigned int int_msk_b;
|
21 |
|
|
unsigned int int_src_a;
|
22 |
|
|
unsigned int int_src_b;
|
23 |
|
|
unsigned int padding[3];
|
24 |
|
|
struct dma_channel_descriptor channels[DMA_CHAN_NUMBER];
|
25 |
|
|
};
|
26 |
|
|
|
27 |
|
|
// DMA main control register
|
28 |
|
|
#define DMA_CSR_PAUSE (0x1)
|
29 |
|
|
#define DMA_CSR_GO (0x0)
|
30 |
|
|
|
31 |
|
|
// DMA Channel controller register
|
32 |
|
|
#define DMA_CHAN_INT_SRC_MSK (0x7 << 20) // channel interrupt source
|
33 |
|
|
#define DMA_CHAN_INE_CHK_DONE_MSK (0x1 << 19) // enable channel interrupt on transfer done when 1
|
34 |
|
|
#define DMA_CHAN_INE_DONE_MSK (0x1 << 18) // enable channel interrupt on transfer done when 1
|
35 |
|
|
#define DMA_CHAN_INE_ERR_MSK (0x1 << 17) // enable channel interrupt on erros when 1
|
36 |
|
|
#define DMA_CHAN_RST_EN_MSK (0x1 << 16) // hadware reset enable when 1
|
37 |
|
|
#define DMA_CHAN_PRIORITY_MSK (0x7 << 13) // channel Priority, 0 is lowest
|
38 |
|
|
#define DMA_CHAN_ERR_MSK (0x1 << 12) // channel stopped due to error when 1
|
39 |
|
|
#define DMA_CHAN_DONE_MSK (0x1 << 11) // channel stopped due to error when 1
|
40 |
|
|
#define DMA_CHAN_BUSY_MSK (0x1 << 10) // channel is busy when 1
|
41 |
|
|
#define DMA_CHAN_STOP_MSK (0x1 << 9) // stop current transfer, and set the ERR bit
|
42 |
|
|
#define DMA_CHAN_SZ_WB_MSK (0x1 << 8) // if this bit is set, enables the writting back of
|
43 |
|
|
// remaining size of the DEST_CSR when USE_ED is set
|
44 |
|
|
#define DMA_CHAN_USE_ED_MSK (0x1 << 7) // use external descriptor linked list when 1
|
45 |
|
|
#define DMA_CHAN_ARS_MSK (0x1 << 6) // auto restart when 1
|
46 |
|
|
#define DMA_CHAN_MODE_MSK (0x1 << 5) // normal mode when 0, HW handshake mode when 1
|
47 |
|
|
#define DMA_CHAN_INC_SRC_MSK (0x1 << 4) // increment src addr when 1
|
48 |
|
|
#define DMA_CHAN_INC_DST_MSK (0x1 << 3) // increment dst addr when 1
|
49 |
|
|
#define DMA_CHAN_SRC_SEL_MSK (0x1 << 2) // interface 0 or 1
|
50 |
|
|
#define DMA_CHAN_DST_SEL_MSK (0x1 << 1) // interface 0 or 1
|
51 |
|
|
#define DMA_CHAN_ENABLE_MSK (0x1 ) // enable when 0
|
52 |
|
|
|
53 |
|
|
#define DMA_CHAN_INT_SRC_SHT (20)
|
54 |
|
|
#define DMA_CHAN_INE_CHK_DONE_SHT (19)
|
55 |
|
|
#define DMA_CHAN_INE_DONE_SHT (18)
|
56 |
|
|
#define DMA_CHAN_INE_ERR_SHT (17)
|
57 |
|
|
#define DMA_CHAN_RST_EN_SHT (16)
|
58 |
|
|
#define DMA_CHAN_PRIORITY_SHT (13)
|
59 |
|
|
#define DMA_CHAN_ERR_SHT (12)
|
60 |
|
|
#define DMA_CHAN_DONE_SHT (11)
|
61 |
|
|
#define DMA_CHAN_BUSY_SHT (10)
|
62 |
|
|
#define DMA_CHAN_STOP_SHT ( 9)
|
63 |
|
|
#define DMA_CHAN_SZ_WB_SHT ( 8)
|
64 |
|
|
#define DMA_CHAN_USE_ED_SHT ( 7)
|
65 |
|
|
#define DMA_CHAN_ARS_SHT ( 6)
|
66 |
|
|
#define DMA_CHAN_MODE_SHT ( 5)
|
67 |
|
|
#define DMA_CHAN_INC_SRC_SHT ( 4)
|
68 |
|
|
#define DMA_CHAN_INC_DST_SHT ( 3)
|
69 |
|
|
#define DMA_CHAN_SRC_SEL_SHT ( 2)
|
70 |
|
|
#define DMA_CHAN_DST_SEL_SHT ( 1)
|
71 |
|
|
#define DMA_CHAN_ENABLE_SHT ( 0)
|
72 |
|
|
|
73 |
|
|
// DMA Channel size register
|
74 |
|
|
#define DMA_CHAN_CHK_SZ_MSK (0x1FF << 16) // Chunk Trnasfer size. number of words(4 Bytes) to
|
75 |
|
|
// be transferred at one given time. Maximum size is 2K bytes
|
76 |
|
|
#define DMA_CHAN_TOT_SZ_MSK (0x7FF ) // Total Transfre Size, number of words(4 Bytes).
|
77 |
|
|
// Maximum size is 16K bytes
|
78 |
|
|
|
79 |
|
|
#define DMA_CHAN_CHK_SZ_SHT (16)
|
80 |
|
|
#define DMA_CHAN_TOT_SZ_SHT ( 0)
|
81 |
|
|
|
82 |
|
|
|
83 |
|
|
void dma_init(void *dma_base);
|
84 |
|
|
unsigned int dma_irq_src_a(void);
|
85 |
|
|
unsigned int dma_irq_src_b(void);
|
86 |
|
|
unsigned int dma_irq_msk_a(void);
|
87 |
|
|
unsigned int dma_irq_msk_b(void);
|
88 |
|
|
int dma_channel_set(int channel,
|
89 |
|
|
unsigned int src_interface, unsigned int src_addr, unsigned int src_addr_incr,
|
90 |
|
|
unsigned int dst_interface, unsigned int dst_addr, unsigned int dst_addr_incr,
|
91 |
|
|
unsigned int chunk_word, unsigned int transfer_word,
|
92 |
|
|
int handshake_mode, int int_enable);
|
93 |
|
|
int dma_block_transfer(int channel,
|
94 |
|
|
unsigned int src_interface, unsigned int src_addr,
|
95 |
|
|
unsigned int dst_interface, unsigned int dst_addr,
|
96 |
|
|
unsigned int chunk_word, unsigned int transfer_word,
|
97 |
|
|
int int_enable);
|
98 |
|
|
#endif
|