1 #ifndef _ASM_SPARC64_DMA_MAPPING_H
2 #define _ASM_SPARC64_DMA_MAPPING_H
4 #include <linux/scatterlist.h>
8 void *(*alloc_coherent)(struct device *dev, size_t size,
9 dma_addr_t *dma_handle, gfp_t flag);
10 void (*free_coherent)(struct device *dev, size_t size,
11 void *cpu_addr, dma_addr_t dma_handle);
12 dma_addr_t (*map_page)(struct device *dev, struct page *page,
13 unsigned long offset, size_t size,
14 enum dma_data_direction direction);
15 void (*unmap_page)(struct device *dev, dma_addr_t dma_addr,
17 enum dma_data_direction direction);
18 int (*map_sg)(struct device *dev, struct scatterlist *sg, int nents,
19 enum dma_data_direction direction);
20 void (*unmap_sg)(struct device *dev, struct scatterlist *sg,
22 enum dma_data_direction direction);
23 void (*sync_single_for_cpu)(struct device *dev,
24 dma_addr_t dma_handle, size_t size,
25 enum dma_data_direction direction);
26 void (*sync_single_for_device)(struct device *dev,
27 dma_addr_t dma_handle, size_t size,
28 enum dma_data_direction direction);
29 void (*sync_sg_for_cpu)(struct device *dev, struct scatterlist *sg,
31 enum dma_data_direction direction);
32 void (*sync_sg_for_device)(struct device *dev,
33 struct scatterlist *sg, int nents,
34 enum dma_data_direction dir);
36 extern const struct dma_ops *dma_ops;
38 static inline void *dma_alloc_coherent(struct device *dev, size_t size,
39 dma_addr_t *dma_handle, gfp_t flag)
41 return dma_ops->alloc_coherent(dev, size, dma_handle, flag);
44 static inline void dma_free_coherent(struct device *dev, size_t size,
45 void *cpu_addr, dma_addr_t dma_handle)
47 dma_ops->free_coherent(dev, size, cpu_addr, dma_handle);
50 static inline dma_addr_t dma_map_single(struct device *dev, void *cpu_addr,
52 enum dma_data_direction direction)
54 return dma_ops->map_page(dev, virt_to_page(cpu_addr),
55 (unsigned long)cpu_addr & ~PAGE_MASK, size,
59 static inline void dma_unmap_single(struct device *dev, dma_addr_t dma_addr,
61 enum dma_data_direction direction)
63 dma_ops->unmap_page(dev, dma_addr, size, direction);
66 static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
67 unsigned long offset, size_t size,
68 enum dma_data_direction direction)
70 return dma_ops->map_page(dev, page, offset, size, direction);
73 static inline void dma_unmap_page(struct device *dev, dma_addr_t dma_address,
75 enum dma_data_direction direction)
77 dma_ops->unmap_page(dev, dma_address, size, direction);
80 static inline int dma_map_sg(struct device *dev, struct scatterlist *sg,
81 int nents, enum dma_data_direction direction)
83 return dma_ops->map_sg(dev, sg, nents, direction);
86 static inline void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
87 int nents, enum dma_data_direction direction)
89 dma_ops->unmap_sg(dev, sg, nents, direction);
92 static inline void dma_sync_single_for_cpu(struct device *dev,
93 dma_addr_t dma_handle, size_t size,
94 enum dma_data_direction direction)
96 dma_ops->sync_single_for_cpu(dev, dma_handle, size, direction);
99 static inline void dma_sync_single_for_device(struct device *dev,
100 dma_addr_t dma_handle,
102 enum dma_data_direction direction)
104 /* No flushing needed to sync cpu writes to the device. */
107 static inline void dma_sync_sg_for_cpu(struct device *dev,
108 struct scatterlist *sg, int nelems,
109 enum dma_data_direction direction)
111 dma_ops->sync_sg_for_cpu(dev, sg, nelems, direction);
114 static inline void dma_sync_sg_for_device(struct device *dev,
115 struct scatterlist *sg, int nelems,
116 enum dma_data_direction direction)
118 /* No flushing needed to sync cpu writes to the device. */
121 #endif /* _ASM_SPARC64_DMA_MAPPING_H */