x86/xen: resume timer irqs early
[linux/fpc-iii.git] / arch / frv / include / asm / dma-mapping.h
blob1746a2b8e6e7287cd9ad612caa00af6bd9cd8a28
1 #ifndef _ASM_DMA_MAPPING_H
2 #define _ASM_DMA_MAPPING_H
4 #include <linux/device.h>
5 #include <asm/cache.h>
6 #include <asm/cacheflush.h>
7 #include <asm/scatterlist.h>
8 #include <asm/io.h>
11 * See Documentation/DMA-API.txt for the description of how the
12 * following DMA API should work.
15 #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
16 #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
18 extern unsigned long __nongprelbss dma_coherent_mem_start;
19 extern unsigned long __nongprelbss dma_coherent_mem_end;
21 void *dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t gfp);
22 void dma_free_coherent(struct device *dev, size_t size, void *vaddr, dma_addr_t dma_handle);
24 extern dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size,
25 enum dma_data_direction direction);
27 static inline
28 void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
29 enum dma_data_direction direction)
31 BUG_ON(direction == DMA_NONE);
34 extern int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
35 enum dma_data_direction direction);
37 static inline
38 void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
39 enum dma_data_direction direction)
41 BUG_ON(direction == DMA_NONE);
44 extern
45 dma_addr_t dma_map_page(struct device *dev, struct page *page, unsigned long offset,
46 size_t size, enum dma_data_direction direction);
48 static inline
49 void dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
50 enum dma_data_direction direction)
52 BUG_ON(direction == DMA_NONE);
56 static inline
57 void dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size,
58 enum dma_data_direction direction)
62 static inline
63 void dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, size_t size,
64 enum dma_data_direction direction)
66 flush_write_buffers();
69 static inline
70 void dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle,
71 unsigned long offset, size_t size,
72 enum dma_data_direction direction)
76 static inline
77 void dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle,
78 unsigned long offset, size_t size,
79 enum dma_data_direction direction)
81 flush_write_buffers();
84 static inline
85 void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
86 enum dma_data_direction direction)
90 static inline
91 void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,
92 enum dma_data_direction direction)
94 flush_write_buffers();
97 static inline
98 int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
100 return 0;
103 static inline
104 int dma_supported(struct device *dev, u64 mask)
107 * we fall back to GFP_DMA when the mask isn't all 1s,
108 * so we can't guarantee allocations that must be
109 * within a tighter range than GFP_DMA..
111 if (mask < 0x00ffffff)
112 return 0;
114 return 1;
117 static inline
118 int dma_set_mask(struct device *dev, u64 mask)
120 if (!dev->dma_mask || !dma_supported(dev, mask))
121 return -EIO;
123 *dev->dma_mask = mask;
125 return 0;
128 static inline
129 void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
130 enum dma_data_direction direction)
132 flush_write_buffers();
135 /* Not supported for now */
136 static inline int dma_mmap_coherent(struct device *dev,
137 struct vm_area_struct *vma, void *cpu_addr,
138 dma_addr_t dma_addr, size_t size)
140 return -EINVAL;
143 static inline int dma_get_sgtable(struct device *dev, struct sg_table *sgt,
144 void *cpu_addr, dma_addr_t dma_addr,
145 size_t size)
147 return -EINVAL;
150 #endif /* _ASM_DMA_MAPPING_H */