]> git.karo-electronics.de Git - mv-sheeva.git/blob - include/asm-x86/dma-mapping_64.h
369188a348f40c262455f5812f3eff8e94d7d967
[mv-sheeva.git] / include / asm-x86 / dma-mapping_64.h
1 #ifndef _X8664_DMA_MAPPING_H
2 #define _X8664_DMA_MAPPING_H 1
3
4 extern dma_addr_t bad_dma_address;
5 extern const struct dma_mapping_ops* dma_ops;
6 extern int iommu_merge;
7
8 static inline int dma_mapping_error(dma_addr_t dma_addr)
9 {
10         if (dma_ops->mapping_error)
11                 return dma_ops->mapping_error(dma_addr);
12
13         return (dma_addr == bad_dma_address);
14 }
15
16 #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
17 #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
18
19 #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
20 #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
21
22 extern void *dma_alloc_coherent(struct device *dev, size_t size,
23                                 dma_addr_t *dma_handle, gfp_t gfp);
24 extern void dma_free_coherent(struct device *dev, size_t size, void *vaddr,
25                               dma_addr_t dma_handle);
26
27 static inline dma_addr_t
28 dma_map_single(struct device *hwdev, void *ptr, size_t size,
29                int direction)
30 {
31         BUG_ON(!valid_dma_direction(direction));
32         return dma_ops->map_single(hwdev, ptr, size, direction);
33 }
34
35 static inline void
36 dma_unmap_single(struct device *dev, dma_addr_t addr,size_t size,
37                  int direction)
38 {
39         BUG_ON(!valid_dma_direction(direction));
40         dma_ops->unmap_single(dev, addr, size, direction);
41 }
42
43 #define dma_map_page(dev,page,offset,size,dir) \
44         dma_map_single((dev), page_address(page)+(offset), (size), (dir))
45
46 #define dma_unmap_page dma_unmap_single
47
48 static inline void
49 dma_sync_single_for_cpu(struct device *hwdev, dma_addr_t dma_handle,
50                         size_t size, int direction)
51 {
52         BUG_ON(!valid_dma_direction(direction));
53         if (dma_ops->sync_single_for_cpu)
54                 dma_ops->sync_single_for_cpu(hwdev, dma_handle, size,
55                                              direction);
56         flush_write_buffers();
57 }
58
59 static inline void
60 dma_sync_single_for_device(struct device *hwdev, dma_addr_t dma_handle,
61                            size_t size, int direction)
62 {
63         BUG_ON(!valid_dma_direction(direction));
64         if (dma_ops->sync_single_for_device)
65                 dma_ops->sync_single_for_device(hwdev, dma_handle, size,
66                                                 direction);
67         flush_write_buffers();
68 }
69
70 static inline void
71 dma_sync_single_range_for_cpu(struct device *hwdev, dma_addr_t dma_handle,
72                               unsigned long offset, size_t size, int direction)
73 {
74         BUG_ON(!valid_dma_direction(direction));
75         if (dma_ops->sync_single_range_for_cpu) {
76                 dma_ops->sync_single_range_for_cpu(hwdev, dma_handle, offset, size, direction);
77         }
78
79         flush_write_buffers();
80 }
81
82 static inline void
83 dma_sync_single_range_for_device(struct device *hwdev, dma_addr_t dma_handle,
84                                  unsigned long offset, size_t size, int direction)
85 {
86         BUG_ON(!valid_dma_direction(direction));
87         if (dma_ops->sync_single_range_for_device)
88                 dma_ops->sync_single_range_for_device(hwdev, dma_handle,
89                                                       offset, size, direction);
90
91         flush_write_buffers();
92 }
93
94 static inline void
95 dma_sync_sg_for_cpu(struct device *hwdev, struct scatterlist *sg,
96                     int nelems, int direction)
97 {
98         BUG_ON(!valid_dma_direction(direction));
99         if (dma_ops->sync_sg_for_cpu)
100                 dma_ops->sync_sg_for_cpu(hwdev, sg, nelems, direction);
101         flush_write_buffers();
102 }
103
104 static inline void
105 dma_sync_sg_for_device(struct device *hwdev, struct scatterlist *sg,
106                        int nelems, int direction)
107 {
108         BUG_ON(!valid_dma_direction(direction));
109         if (dma_ops->sync_sg_for_device) {
110                 dma_ops->sync_sg_for_device(hwdev, sg, nelems, direction);
111         }
112
113         flush_write_buffers();
114 }
115
116 static inline int
117 dma_map_sg(struct device *hwdev, struct scatterlist *sg, int nents, int direction)
118 {
119         BUG_ON(!valid_dma_direction(direction));
120         return dma_ops->map_sg(hwdev, sg, nents, direction);
121 }
122
123 static inline void
124 dma_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nents,
125              int direction)
126 {
127         BUG_ON(!valid_dma_direction(direction));
128         dma_ops->unmap_sg(hwdev, sg, nents, direction);
129 }
130
131 extern int dma_supported(struct device *hwdev, u64 mask);
132
133 /* same for gart, swiotlb, and nommu */
134 static inline int dma_get_cache_alignment(void)
135 {
136         return boot_cpu_data.x86_clflush_size;
137 }
138
139 #define dma_is_consistent(d, h) 1
140
141 extern int dma_set_mask(struct device *dev, u64 mask);
142
143 static inline void
144 dma_cache_sync(struct device *dev, void *vaddr, size_t size,
145         enum dma_data_direction dir)
146 {
147         flush_write_buffers();
148 }
149
150 extern struct device fallback_dev;
151 extern int panic_on_overflow;
152
153 #endif /* _X8664_DMA_MAPPING_H */