4 #include <linux/stddef.h>
5 #include <linux/dmaengine.h>
6 #include "xilinx-dma-apf.h"
7 #include "xlnk-sysdef.h"
9 #define XLNK_FLAG_COHERENT 0x00000001
10 #define XLNK_FLAG_KERNEL_BUFFER 0x00000002
11 #define XLNK_FLAG_DMAPOLLING 0x00000004
12 #define XLNK_FLAG_IOMMU_VALID 0x00000008
13 #define XLNK_FLAG_PHYSICAL_ADDR 0x00000100
14 #define XLNK_FLAG_VIRTUAL_ADDR 0x00000200
15 #define XLNK_FLAG_MEM_ACQUIRE 0x00001000
16 #define XLNK_FLAG_MEM_RELEASE 0x00002000
17 #define CF_FLAG_CACHE_FLUSH_INVALIDATE 0x00000001
18 #define CF_FLAG_PHYSICALLY_CONTIGUOUS 0x00000002
19 #define CF_FLAG_DMAPOLLING 0x00000004
21 enum xlnk_dma_direction {
23 XLNK_DMA_TO_DEVICE = 1,
24 XLNK_DMA_FROM_DEVICE = 2,
28 struct xlnk_dma_transfer_handle {
30 unsigned long transfer_length;
32 unsigned long user_addr;
33 enum dma_data_direction transfer_direction;
34 int sg_effective_length;
36 struct dma_chan *channel;
37 dma_cookie_t dma_cookie;
38 struct dma_async_tx_descriptor *async_desc;
39 struct completion completion_handle;
42 struct xlnk_dmabuf_reg {
43 xlnk_int_type dmabuf_fd;
44 xlnk_intptr_type user_vaddr;
46 struct dma_buf_attachment *dbuf_attach;
47 struct sg_table *dbuf_sg_table;
50 struct list_head list;
53 /* CROSSES KERNEL-USER BOUNDARY */
55 struct __attribute__ ((__packed__)) {
58 xlnk_intptr_type phyaddr;
59 xlnk_byte_type cacheable;
61 struct __attribute__ ((__packed__)) {
65 struct __attribute__ ((__packed__)) {
66 xlnk_int_type dmabuf_fd;
67 xlnk_intptr_type user_addr;
69 struct __attribute__ ((__packed__)) {
70 xlnk_char_type name[64];
71 xlnk_intptr_type dmachan;
72 xlnk_uint_type bd_space_phys_addr;
73 xlnk_uint_type bd_space_size;
75 #define XLNK_MAX_APPWORDS 5
76 struct __attribute__ ((__packed__)) {
77 xlnk_intptr_type dmachan;
79 xlnk_intptr_type buf2;
80 xlnk_uint_type buf_offset;
82 xlnk_uint_type bufflag;
83 xlnk_intptr_type sglist;
85 xlnk_enum_type dmadir;
86 xlnk_uint_type nappwords_i;
87 xlnk_uint_type appwords_i[XLNK_MAX_APPWORDS];
88 xlnk_uint_type nappwords_o;
90 xlnk_intptr_type dmahandle; /* return value */
91 xlnk_uint_type last_bd_index;
93 struct __attribute__ ((__packed__)) {
94 xlnk_intptr_type dmahandle;
95 xlnk_uint_type nappwords;
96 xlnk_uint_type appwords[XLNK_MAX_APPWORDS];
97 /* appwords array we only accept 5 max */
100 struct __attribute__ ((__packed__)) {
101 xlnk_intptr_type dmachan;
103 struct __attribute__ ((__packed__)) {
104 xlnk_intptr_type base;
106 xlnk_uint_type irqs[8];
107 xlnk_char_type name[32];
110 struct __attribute__ ((__packed__)) {
111 xlnk_intptr_type base;
113 struct __attribute__ ((__packed__)) {
114 xlnk_char_type name[32];
116 xlnk_intptr_type base;
118 xlnk_uint_type chan_num;
119 xlnk_uint_type chan0_dir;
120 xlnk_uint_type chan0_irq;
121 xlnk_uint_type chan0_poll_mode;
122 xlnk_uint_type chan0_include_dre;
123 xlnk_uint_type chan0_data_width;
124 xlnk_uint_type chan1_dir;
125 xlnk_uint_type chan1_irq;
126 xlnk_uint_type chan1_poll_mode;
127 xlnk_uint_type chan1_include_dre;
128 xlnk_uint_type chan1_data_width;
130 struct __attribute__ ((__packed__)) {
131 xlnk_char_type name[32];
133 xlnk_intptr_type base;
135 xlnk_uint_type mm2s_chan_num;
136 xlnk_uint_type mm2s_chan_irq;
137 xlnk_uint_type s2mm_chan_num;
138 xlnk_uint_type s2mm_chan_irq;
140 struct __attribute__ ((__packed__)) {
141 xlnk_intptr_type phys_addr;
143 xlnk_int_type action;
145 struct __attribute__ ((__packed__)) {
146 xlnk_intptr_type virt_addr;
150 xlnk_intptr_type phys_addr;
151 xlnk_intptr_type token;