OpenCores
URL https://opencores.org/ocsvn/test_project/test_project/trunk

Subversion Repositories test_project

[/] [test_project/] [trunk/] [linux_sd_driver/] [include/] [asm-generic/] [dma-mapping.h] - Blame information for rev 82

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 62 marcus.erl
/* Copyright (C) 2002 by James.Bottomley@HansenPartnership.com
2
 *
3
 * Implements the generic device dma API via the existing pci_ one
4
 * for unconverted architectures
5
 */
6
 
7
#ifndef _ASM_GENERIC_DMA_MAPPING_H
8
#define _ASM_GENERIC_DMA_MAPPING_H
9
 
10
 
11
#ifdef CONFIG_PCI
12
 
13
/* we implement the API below in terms of the existing PCI one,
14
 * so include it */
15
#include <linux/pci.h>
16
/* need struct page definitions */
17
#include <linux/mm.h>
18
 
19
static inline int
20
dma_supported(struct device *dev, u64 mask)
21
{
22
        BUG_ON(dev->bus != &pci_bus_type);
23
 
24
        return pci_dma_supported(to_pci_dev(dev), mask);
25
}
26
 
27
static inline int
28
dma_set_mask(struct device *dev, u64 dma_mask)
29
{
30
        BUG_ON(dev->bus != &pci_bus_type);
31
 
32
        return pci_set_dma_mask(to_pci_dev(dev), dma_mask);
33
}
34
 
35
static inline void *
36
dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
37
                   gfp_t flag)
38
{
39
        BUG_ON(dev->bus != &pci_bus_type);
40
 
41
        return pci_alloc_consistent(to_pci_dev(dev), size, dma_handle);
42
}
43
 
44
static inline void
45
dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
46
                    dma_addr_t dma_handle)
47
{
48
        BUG_ON(dev->bus != &pci_bus_type);
49
 
50
        pci_free_consistent(to_pci_dev(dev), size, cpu_addr, dma_handle);
51
}
52
 
53
static inline dma_addr_t
54
dma_map_single(struct device *dev, void *cpu_addr, size_t size,
55
               enum dma_data_direction direction)
56
{
57
        BUG_ON(dev->bus != &pci_bus_type);
58
 
59
        return pci_map_single(to_pci_dev(dev), cpu_addr, size, (int)direction);
60
}
61
 
62
static inline void
63
dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
64
                 enum dma_data_direction direction)
65
{
66
        BUG_ON(dev->bus != &pci_bus_type);
67
 
68
        pci_unmap_single(to_pci_dev(dev), dma_addr, size, (int)direction);
69
}
70
 
71
static inline dma_addr_t
72
dma_map_page(struct device *dev, struct page *page,
73
             unsigned long offset, size_t size,
74
             enum dma_data_direction direction)
75
{
76
        BUG_ON(dev->bus != &pci_bus_type);
77
 
78
        return pci_map_page(to_pci_dev(dev), page, offset, size, (int)direction);
79
}
80
 
81
static inline void
82
dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
83
               enum dma_data_direction direction)
84
{
85
        BUG_ON(dev->bus != &pci_bus_type);
86
 
87
        pci_unmap_page(to_pci_dev(dev), dma_address, size, (int)direction);
88
}
89
 
90
static inline int
91
dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
92
           enum dma_data_direction direction)
93
{
94
        BUG_ON(dev->bus != &pci_bus_type);
95
 
96
        return pci_map_sg(to_pci_dev(dev), sg, nents, (int)direction);
97
}
98
 
99
static inline void
100
dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
101
             enum dma_data_direction direction)
102
{
103
        BUG_ON(dev->bus != &pci_bus_type);
104
 
105
        pci_unmap_sg(to_pci_dev(dev), sg, nhwentries, (int)direction);
106
}
107
 
108
static inline void
109
dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size,
110
                        enum dma_data_direction direction)
111
{
112
        BUG_ON(dev->bus != &pci_bus_type);
113
 
114
        pci_dma_sync_single_for_cpu(to_pci_dev(dev), dma_handle,
115
                                    size, (int)direction);
116
}
117
 
118
static inline void
119
dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, size_t size,
120
                           enum dma_data_direction direction)
121
{
122
        BUG_ON(dev->bus != &pci_bus_type);
123
 
124
        pci_dma_sync_single_for_device(to_pci_dev(dev), dma_handle,
125
                                       size, (int)direction);
126
}
127
 
128
static inline void
129
dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
130
                    enum dma_data_direction direction)
131
{
132
        BUG_ON(dev->bus != &pci_bus_type);
133
 
134
        pci_dma_sync_sg_for_cpu(to_pci_dev(dev), sg, nelems, (int)direction);
135
}
136
 
137
static inline void
138
dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,
139
                       enum dma_data_direction direction)
140
{
141
        BUG_ON(dev->bus != &pci_bus_type);
142
 
143
        pci_dma_sync_sg_for_device(to_pci_dev(dev), sg, nelems, (int)direction);
144
}
145
 
146
static inline int
147
dma_mapping_error(dma_addr_t dma_addr)
148
{
149
        return pci_dma_mapping_error(dma_addr);
150
}
151
 
152
 
153
#else
154
 
155
static inline int
156
dma_supported(struct device *dev, u64 mask)
157
{
158
        return 0;
159
}
160
 
161
static inline int
162
dma_set_mask(struct device *dev, u64 dma_mask)
163
{
164
        BUG();
165
        return 0;
166
}
167
 
168
static inline void *
169
dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
170
                   gfp_t flag)
171
{
172 82 tac2
 
173
 
174
      BUG();
175
 
176 62 marcus.erl
}
177
 
178 82 tac2
 
179
 
180 62 marcus.erl
static inline void
181
dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
182
                    dma_addr_t dma_handle)
183
{
184 82 tac2
 
185
                 kfree(cpu_addr);
186
                 return;
187
 
188
 
189 62 marcus.erl
}
190
 
191
static inline dma_addr_t
192
dma_map_single(struct device *dev, void *cpu_addr, size_t size,
193
               enum dma_data_direction direction)
194
{
195
        BUG();
196
        return 0;
197
}
198
 
199
static inline void
200
dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
201
                 enum dma_data_direction direction)
202
{
203
        BUG();
204
}
205
 
206
static inline dma_addr_t
207
dma_map_page(struct device *dev, struct page *page,
208
             unsigned long offset, size_t size,
209
             enum dma_data_direction direction)
210
{
211
        BUG();
212
        return 0;
213
}
214
 
215
static inline void
216
dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
217
               enum dma_data_direction direction)
218
{
219
        BUG();
220
}
221
 
222
static inline int
223 82 tac2
dma_map_sg(struct device *dev, struct scatterlist *sglist, int nents,
224 62 marcus.erl
           enum dma_data_direction direction)
225
{
226
        BUG();
227
}
228
 
229
static inline void
230
dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
231
             enum dma_data_direction direction)
232
{
233
        BUG();
234
}
235
 
236
static inline void
237
dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size,
238
                        enum dma_data_direction direction)
239
{
240
        BUG();
241
}
242
 
243
static inline void
244
dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, size_t size,
245
                           enum dma_data_direction direction)
246
{
247
        BUG();
248
}
249
 
250
static inline void
251
dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
252
                    enum dma_data_direction direction)
253
{
254
        BUG();
255
}
256
 
257
static inline void
258
dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,
259
                       enum dma_data_direction direction)
260
{
261
        BUG();
262
}
263
 
264
static inline int
265
dma_error(dma_addr_t dma_addr)
266
{
267
        return 0;
268
}
269
 
270
#endif
271
 
272
/* Now for the API extensions over the pci_ one */
273
 
274
#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
275
#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
276
#define dma_is_consistent(d, h) (1)
277
 
278
static inline int
279
dma_get_cache_alignment(void)
280
{
281
        /* no easy way to get cache size on all processors, so return
282
         * the maximum possible, to be safe */
283
        return (1 << INTERNODE_CACHE_SHIFT);
284
}
285
 
286
static inline void
287
dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle,
288
                              unsigned long offset, size_t size,
289
                              enum dma_data_direction direction)
290
{
291
        /* just sync everything, that's all the pci API can do */
292
        dma_sync_single_for_cpu(dev, dma_handle, offset+size, direction);
293
}
294
 
295
static inline void
296
dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle,
297
                                 unsigned long offset, size_t size,
298
                                 enum dma_data_direction direction)
299
{
300
        /* just sync everything, that's all the pci API can do */
301
        dma_sync_single_for_device(dev, dma_handle, offset+size, direction);
302
}
303
 
304
static inline void
305
dma_cache_sync(struct device *dev, void *vaddr, size_t size,
306
               enum dma_data_direction direction)
307
{
308
        /* could define this in terms of the dma_cache ... operations,
309
         * but if you get this on a platform, you should convert the platform
310
         * to using the generic device DMA API */
311
        BUG();
312
}
313
 
314
#endif
315
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.