This source file includes following definitions.
- get_arch_dma_ops
- pfn_to_dma
- dma_to_pfn
- dma_to_virt
- virt_to_dma
- pfn_to_dma
- dma_to_pfn
- dma_to_virt
- virt_to_dma
1
2 #ifndef ASMARM_DMA_MAPPING_H
3 #define ASMARM_DMA_MAPPING_H
4
5 #ifdef __KERNEL__
6
7 #include <linux/mm_types.h>
8 #include <linux/scatterlist.h>
9 #include <linux/dma-debug.h>
10
11 #include <asm/memory.h>
12
13 #include <xen/xen.h>
14 #include <asm/xen/hypervisor.h>
15
16 extern const struct dma_map_ops arm_dma_ops;
17 extern const struct dma_map_ops arm_coherent_dma_ops;
18
19 static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
20 {
21 if (IS_ENABLED(CONFIG_MMU) && !IS_ENABLED(CONFIG_ARM_LPAE))
22 return &arm_dma_ops;
23 return NULL;
24 }
25
26 #ifdef __arch_page_to_dma
27 #error Please update to __arch_pfn_to_dma
28 #endif
29
30
31
32
33
34
35 #ifndef __arch_pfn_to_dma
36 static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn)
37 {
38 if (dev)
39 pfn -= dev->dma_pfn_offset;
40 return (dma_addr_t)__pfn_to_bus(pfn);
41 }
42
43 static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr)
44 {
45 unsigned long pfn = __bus_to_pfn(addr);
46
47 if (dev)
48 pfn += dev->dma_pfn_offset;
49
50 return pfn;
51 }
52
53 static inline void *dma_to_virt(struct device *dev, dma_addr_t addr)
54 {
55 if (dev) {
56 unsigned long pfn = dma_to_pfn(dev, addr);
57
58 return phys_to_virt(__pfn_to_phys(pfn));
59 }
60
61 return (void *)__bus_to_virt((unsigned long)addr);
62 }
63
64 static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
65 {
66 if (dev)
67 return pfn_to_dma(dev, virt_to_pfn(addr));
68
69 return (dma_addr_t)__virt_to_bus((unsigned long)(addr));
70 }
71
72 #else
73 static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn)
74 {
75 return __arch_pfn_to_dma(dev, pfn);
76 }
77
78 static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr)
79 {
80 return __arch_dma_to_pfn(dev, addr);
81 }
82
83 static inline void *dma_to_virt(struct device *dev, dma_addr_t addr)
84 {
85 return __arch_dma_to_virt(dev, addr);
86 }
87
88 static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
89 {
90 return __arch_virt_to_dma(dev, addr);
91 }
92 #endif
93
94
95
96
97
98
99
100
101
102
103
104
105 extern void *arm_dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
106 gfp_t gfp, unsigned long attrs);
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122 extern void arm_dma_free(struct device *dev, size_t size, void *cpu_addr,
123 dma_addr_t handle, unsigned long attrs);
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138 extern int arm_dma_mmap(struct device *dev, struct vm_area_struct *vma,
139 void *cpu_addr, dma_addr_t dma_addr, size_t size,
140 unsigned long attrs);
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166 extern int dmabounce_register_dev(struct device *, unsigned long,
167 unsigned long, int (*)(struct device *, dma_addr_t, size_t));
168
169
170
171
172
173
174
175
176
177
178
179 extern void dmabounce_unregister_dev(struct device *);
180
181
182
183
184
185
186 extern int arm_dma_map_sg(struct device *, struct scatterlist *, int,
187 enum dma_data_direction, unsigned long attrs);
188 extern void arm_dma_unmap_sg(struct device *, struct scatterlist *, int,
189 enum dma_data_direction, unsigned long attrs);
190 extern void arm_dma_sync_sg_for_cpu(struct device *, struct scatterlist *, int,
191 enum dma_data_direction);
192 extern void arm_dma_sync_sg_for_device(struct device *, struct scatterlist *, int,
193 enum dma_data_direction);
194 extern int arm_dma_get_sgtable(struct device *dev, struct sg_table *sgt,
195 void *cpu_addr, dma_addr_t dma_addr, size_t size,
196 unsigned long attrs);
197
198 #endif
199 #endif