sparc: use dma_map_page instead of dma_map_single
[safe/jmp/linux-2.6] / arch / sparc / include / asm / dma-mapping_64.h
1 #ifndef _ASM_SPARC64_DMA_MAPPING_H
2 #define _ASM_SPARC64_DMA_MAPPING_H
3
4 #include <linux/scatterlist.h>
5 #include <linux/mm.h>
6
7 struct dma_ops {
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,
16                            size_t size,
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,
21                          int nhwentries,
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,
30                                 int nelems,
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);
35 };
36 extern const struct dma_ops *dma_ops;
37
38 static inline void *dma_alloc_coherent(struct device *dev, size_t size,
39                                        dma_addr_t *dma_handle, gfp_t flag)
40 {
41         return dma_ops->alloc_coherent(dev, size, dma_handle, flag);
42 }
43
44 static inline void dma_free_coherent(struct device *dev, size_t size,
45                                      void *cpu_addr, dma_addr_t dma_handle)
46 {
47         dma_ops->free_coherent(dev, size, cpu_addr, dma_handle);
48 }
49
50 static inline dma_addr_t dma_map_single(struct device *dev, void *cpu_addr,
51                                         size_t size,
52                                         enum dma_data_direction direction)
53 {
54         return dma_ops->map_page(dev, virt_to_page(cpu_addr),
55                                  (unsigned long)cpu_addr & ~PAGE_MASK, size,
56                                  direction);
57 }
58
59 static inline void dma_unmap_single(struct device *dev, dma_addr_t dma_addr,
60                                     size_t size,
61                                     enum dma_data_direction direction)
62 {
63         dma_ops->unmap_page(dev, dma_addr, size, direction);
64 }
65
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)
69 {
70         return dma_ops->map_page(dev, page, offset, size, direction);
71 }
72
73 static inline void dma_unmap_page(struct device *dev, dma_addr_t dma_address,
74                                   size_t size,
75                                   enum dma_data_direction direction)
76 {
77         dma_ops->unmap_page(dev, dma_address, size, direction);
78 }
79
80 static inline int dma_map_sg(struct device *dev, struct scatterlist *sg,
81                              int nents, enum dma_data_direction direction)
82 {
83         return dma_ops->map_sg(dev, sg, nents, direction);
84 }
85
86 static inline void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
87                                 int nents, enum dma_data_direction direction)
88 {
89         dma_ops->unmap_sg(dev, sg, nents, direction);
90 }
91
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)
95 {
96         dma_ops->sync_single_for_cpu(dev, dma_handle, size, direction);
97 }
98
99 static inline void dma_sync_single_for_device(struct device *dev,
100                                               dma_addr_t dma_handle,
101                                               size_t size,
102                                               enum dma_data_direction direction)
103 {
104         /* No flushing needed to sync cpu writes to the device.  */
105 }
106
107 static inline void dma_sync_sg_for_cpu(struct device *dev,
108                                        struct scatterlist *sg, int nelems,
109                                        enum dma_data_direction direction)
110 {
111         dma_ops->sync_sg_for_cpu(dev, sg, nelems, direction);
112 }
113
114 static inline void dma_sync_sg_for_device(struct device *dev,
115                                           struct scatterlist *sg, int nelems,
116                                           enum dma_data_direction direction)
117 {
118         /* No flushing needed to sync cpu writes to the device.  */
119 }
120
121 #endif /* _ASM_SPARC64_DMA_MAPPING_H */