]> rtime.felk.cvut.cz Git - zynq/linux.git/blob - drivers/staging/apf/xlnk.h
staging: apf: Correct sg list length assignment in apf dma
[zynq/linux.git] / drivers / staging / apf / xlnk.h
1 #ifndef _XLNK_OS_H
2 #define _XLNK_OS_H
3
4 #include <linux/stddef.h>
5 #include <linux/dmaengine.h>
6 #include "xilinx-dma-apf.h"
7 #include "xlnk-sysdef.h"
8
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
20
21 enum xlnk_dma_direction {
22         XLNK_DMA_BI = 0,
23         XLNK_DMA_TO_DEVICE = 1,
24         XLNK_DMA_FROM_DEVICE = 2,
25         XLNK_DMA_NONE = 3,
26 };
27
28 struct xlnk_dma_transfer_handle {
29         dma_addr_t dma_addr;
30         unsigned long transfer_length;
31         void *kern_addr;
32         unsigned long user_addr;
33         enum dma_data_direction transfer_direction;
34         int sg_effective_length;
35         int flags;
36         struct dma_chan *channel;
37         dma_cookie_t dma_cookie;
38         struct dma_async_tx_descriptor *async_desc;
39         struct completion completion_handle;
40 };
41
42 struct xlnk_dmabuf_reg {
43         xlnk_int_type dmabuf_fd;
44         xlnk_intptr_type user_vaddr;
45         struct dma_buf *dbuf;
46         struct dma_buf_attachment *dbuf_attach;
47         struct sg_table *dbuf_sg_table;
48         int is_mapped;
49         int dma_direction;
50         struct list_head list;
51 };
52
53 /* CROSSES KERNEL-USER BOUNDARY */
54 union xlnk_args {
55         struct __attribute__ ((__packed__)) {
56                 xlnk_uint_type len;
57                 xlnk_int_type id;
58                 xlnk_intptr_type phyaddr;
59                 xlnk_byte_type cacheable;
60         } allocbuf;
61         struct __attribute__ ((__packed__)) {
62                 xlnk_uint_type id;
63                 xlnk_intptr_type buf;
64         } freebuf;
65         struct __attribute__ ((__packed__)) {
66                 xlnk_int_type dmabuf_fd;
67                 xlnk_intptr_type user_addr;
68         } dmabuf;
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;
74         } dmarequest;
75 #define XLNK_MAX_APPWORDS 5
76         struct __attribute__ ((__packed__)) {
77                 xlnk_intptr_type dmachan;
78                 xlnk_intptr_type buf;
79                 xlnk_intptr_type buf2;
80                 xlnk_uint_type buf_offset;
81                 xlnk_uint_type len;
82                 xlnk_uint_type bufflag;
83                 xlnk_intptr_type sglist;
84                 xlnk_uint_type sgcnt;
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;
89                 xlnk_uint_type flag;
90                 xlnk_intptr_type dmahandle; /* return value */
91                 xlnk_uint_type last_bd_index;
92         } dmasubmit;
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 */
98                 xlnk_uint_type flags;
99         } dmawait;
100         struct __attribute__ ((__packed__)) {
101                 xlnk_intptr_type dmachan;
102         } dmarelease;
103         struct __attribute__ ((__packed__))  {
104                 xlnk_intptr_type base;
105                 xlnk_uint_type size;
106                 xlnk_uint_type irqs[8];
107                 xlnk_char_type name[32];
108                 xlnk_uint_type id;
109         } devregister;
110         struct __attribute__ ((__packed__)) {
111                 xlnk_intptr_type base;
112         } devunregister;
113         struct __attribute__ ((__packed__)) {
114                 xlnk_char_type name[32];
115                 xlnk_uint_type id;
116                 xlnk_intptr_type base;
117                 xlnk_uint_type size;
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;
129         } dmaregister;
130         struct __attribute__ ((__packed__)) {
131                 xlnk_char_type name[32];
132                 xlnk_uint_type id;
133                 xlnk_intptr_type base;
134                 xlnk_uint_type size;
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;
139         } mcdmaregister;
140         struct __attribute__ ((__packed__)) {
141                 xlnk_intptr_type phys_addr;
142                 xlnk_uint_type size;
143                 xlnk_int_type action;
144         } cachecontrol;
145         struct __attribute__ ((__packed__)) {
146                 xlnk_intptr_type virt_addr;
147                 xlnk_int_type size;
148                 xlnk_enum_type dir;
149                 xlnk_int_type flags;
150                 xlnk_intptr_type phys_addr;
151                 xlnk_intptr_type token;
152         } memop;
153 };
154
155 #endif