]> git.karo-electronics.de Git - karo-tx-linux.git/blob - include/asm-x86/dma-mapping_32.h
c61ae7ff222c55ca788818638c6e76176d5cc1ad
[karo-tx-linux.git] / include / asm-x86 / dma-mapping_32.h
1 #ifndef _ASM_I386_DMA_MAPPING_H
2 #define _ASM_I386_DMA_MAPPING_H
3
4 #include <linux/mm.h>
5 #include <linux/scatterlist.h>
6
7 #include <asm/cache.h>
8 #include <asm/io.h>
9 #include <asm/bug.h>
10
11 static inline int
12 dma_mapping_error(dma_addr_t dma_addr)
13 {
14         return 0;
15 }
16
17 extern int forbid_dac;
18
19 static inline int
20 dma_supported(struct device *dev, u64 mask)
21 {
22         /*
23          * we fall back to GFP_DMA when the mask isn't all 1s,
24          * so we can't guarantee allocations that must be
25          * within a tighter range than GFP_DMA..
26          */
27         if(mask < 0x00ffffff)
28                 return 0;
29
30         /* Work around chipset bugs */
31         if (forbid_dac > 0 && mask > 0xffffffffULL)
32                 return 0;
33
34         return 1;
35 }
36
37 static inline int
38 dma_set_mask(struct device *dev, u64 mask)
39 {
40         if(!dev->dma_mask || !dma_supported(dev, mask))
41                 return -EIO;
42
43         *dev->dma_mask = mask;
44
45         return 0;
46 }
47
48 static inline int
49 dma_get_cache_alignment(void)
50 {
51         /* no easy way to get cache size on all x86, so return the
52          * maximum possible, to be safe */
53         return (1 << INTERNODE_CACHE_SHIFT);
54 }
55
56 #define dma_is_consistent(d, h) (1)
57
58 static inline void
59 dma_cache_sync(struct device *dev, void *vaddr, size_t size,
60                enum dma_data_direction direction)
61 {
62         flush_write_buffers();
63 }
64
65 #define ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY
66 extern int
67 dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
68                             dma_addr_t device_addr, size_t size, int flags);
69
70 extern void
71 dma_release_declared_memory(struct device *dev);
72
73 extern void *
74 dma_mark_declared_memory_occupied(struct device *dev,
75                                   dma_addr_t device_addr, size_t size);
76
77 #endif