diff options
Diffstat (limited to 'arch/ia64/include/asm/dma-mapping.h')
-rw-r--r-- | arch/ia64/include/asm/dma-mapping.h | 194 |
1 files changed, 110 insertions, 84 deletions
diff --git a/arch/ia64/include/asm/dma-mapping.h b/arch/ia64/include/asm/dma-mapping.h index 1f912d927585..36c0009dbece 100644 --- a/arch/ia64/include/asm/dma-mapping.h +++ b/arch/ia64/include/asm/dma-mapping.h | |||
@@ -11,99 +11,128 @@ | |||
11 | 11 | ||
12 | #define ARCH_HAS_DMA_GET_REQUIRED_MASK | 12 | #define ARCH_HAS_DMA_GET_REQUIRED_MASK |
13 | 13 | ||
14 | struct dma_mapping_ops { | 14 | extern struct dma_map_ops *dma_ops; |
15 | int (*mapping_error)(struct device *dev, | ||
16 | dma_addr_t dma_addr); | ||
17 | void* (*alloc_coherent)(struct device *dev, size_t size, | ||
18 | dma_addr_t *dma_handle, gfp_t gfp); | ||
19 | void (*free_coherent)(struct device *dev, size_t size, | ||
20 | void *vaddr, dma_addr_t dma_handle); | ||
21 | dma_addr_t (*map_single)(struct device *hwdev, unsigned long ptr, | ||
22 | size_t size, int direction); | ||
23 | void (*unmap_single)(struct device *dev, dma_addr_t addr, | ||
24 | size_t size, int direction); | ||
25 | void (*sync_single_for_cpu)(struct device *hwdev, | ||
26 | dma_addr_t dma_handle, size_t size, | ||
27 | int direction); | ||
28 | void (*sync_single_for_device)(struct device *hwdev, | ||
29 | dma_addr_t dma_handle, size_t size, | ||
30 | int direction); | ||
31 | void (*sync_single_range_for_cpu)(struct device *hwdev, | ||
32 | dma_addr_t dma_handle, unsigned long offset, | ||
33 | size_t size, int direction); | ||
34 | void (*sync_single_range_for_device)(struct device *hwdev, | ||
35 | dma_addr_t dma_handle, unsigned long offset, | ||
36 | size_t size, int direction); | ||
37 | void (*sync_sg_for_cpu)(struct device *hwdev, | ||
38 | struct scatterlist *sg, int nelems, | ||
39 | int direction); | ||
40 | void (*sync_sg_for_device)(struct device *hwdev, | ||
41 | struct scatterlist *sg, int nelems, | ||
42 | int direction); | ||
43 | int (*map_sg)(struct device *hwdev, struct scatterlist *sg, | ||
44 | int nents, int direction); | ||
45 | void (*unmap_sg)(struct device *hwdev, | ||
46 | struct scatterlist *sg, int nents, | ||
47 | int direction); | ||
48 | int (*dma_supported_op)(struct device *hwdev, u64 mask); | ||
49 | int is_phys; | ||
50 | }; | ||
51 | |||
52 | extern struct dma_mapping_ops *dma_ops; | ||
53 | extern struct ia64_machine_vector ia64_mv; | 15 | extern struct ia64_machine_vector ia64_mv; |
54 | extern void set_iommu_machvec(void); | 16 | extern void set_iommu_machvec(void); |
55 | 17 | ||
56 | #define dma_alloc_coherent(dev, size, handle, gfp) \ | 18 | extern void machvec_dma_sync_single(struct device *, dma_addr_t, size_t, |
57 | platform_dma_alloc_coherent(dev, size, handle, (gfp) | GFP_DMA) | 19 | enum dma_data_direction); |
20 | extern void machvec_dma_sync_sg(struct device *, struct scatterlist *, int, | ||
21 | enum dma_data_direction); | ||
58 | 22 | ||
59 | /* coherent mem. is cheap */ | 23 | static inline void *dma_alloc_coherent(struct device *dev, size_t size, |
60 | static inline void * | 24 | dma_addr_t *daddr, gfp_t gfp) |
61 | dma_alloc_noncoherent(struct device *dev, size_t size, dma_addr_t *dma_handle, | ||
62 | gfp_t flag) | ||
63 | { | 25 | { |
64 | return dma_alloc_coherent(dev, size, dma_handle, flag); | 26 | struct dma_map_ops *ops = platform_dma_get_ops(dev); |
27 | return ops->alloc_coherent(dev, size, daddr, gfp); | ||
65 | } | 28 | } |
66 | #define dma_free_coherent platform_dma_free_coherent | 29 | |
67 | static inline void | 30 | static inline void dma_free_coherent(struct device *dev, size_t size, |
68 | dma_free_noncoherent(struct device *dev, size_t size, void *cpu_addr, | 31 | void *caddr, dma_addr_t daddr) |
69 | dma_addr_t dma_handle) | 32 | { |
33 | struct dma_map_ops *ops = platform_dma_get_ops(dev); | ||
34 | ops->free_coherent(dev, size, caddr, daddr); | ||
35 | } | ||
36 | |||
37 | #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) | ||
38 | #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) | ||
39 | |||
40 | static inline dma_addr_t dma_map_single_attrs(struct device *dev, | ||
41 | void *caddr, size_t size, | ||
42 | enum dma_data_direction dir, | ||
43 | struct dma_attrs *attrs) | ||
44 | { | ||
45 | struct dma_map_ops *ops = platform_dma_get_ops(dev); | ||
46 | return ops->map_page(dev, virt_to_page(caddr), | ||
47 | (unsigned long)caddr & ~PAGE_MASK, size, | ||
48 | dir, attrs); | ||
49 | } | ||
50 | |||
51 | static inline void dma_unmap_single_attrs(struct device *dev, dma_addr_t daddr, | ||
52 | size_t size, | ||
53 | enum dma_data_direction dir, | ||
54 | struct dma_attrs *attrs) | ||
55 | { | ||
56 | struct dma_map_ops *ops = platform_dma_get_ops(dev); | ||
57 | ops->unmap_page(dev, daddr, size, dir, attrs); | ||
58 | } | ||
59 | |||
60 | #define dma_map_single(d, a, s, r) dma_map_single_attrs(d, a, s, r, NULL) | ||
61 | #define dma_unmap_single(d, a, s, r) dma_unmap_single_attrs(d, a, s, r, NULL) | ||
62 | |||
63 | static inline int dma_map_sg_attrs(struct device *dev, struct scatterlist *sgl, | ||
64 | int nents, enum dma_data_direction dir, | ||
65 | struct dma_attrs *attrs) | ||
66 | { | ||
67 | struct dma_map_ops *ops = platform_dma_get_ops(dev); | ||
68 | return ops->map_sg(dev, sgl, nents, dir, attrs); | ||
69 | } | ||
70 | |||
71 | static inline void dma_unmap_sg_attrs(struct device *dev, | ||
72 | struct scatterlist *sgl, int nents, | ||
73 | enum dma_data_direction dir, | ||
74 | struct dma_attrs *attrs) | ||
75 | { | ||
76 | struct dma_map_ops *ops = platform_dma_get_ops(dev); | ||
77 | ops->unmap_sg(dev, sgl, nents, dir, attrs); | ||
78 | } | ||
79 | |||
80 | #define dma_map_sg(d, s, n, r) dma_map_sg_attrs(d, s, n, r, NULL) | ||
81 | #define dma_unmap_sg(d, s, n, r) dma_unmap_sg_attrs(d, s, n, r, NULL) | ||
82 | |||
83 | static inline void dma_sync_single_for_cpu(struct device *dev, dma_addr_t daddr, | ||
84 | size_t size, | ||
85 | enum dma_data_direction dir) | ||
70 | { | 86 | { |
71 | dma_free_coherent(dev, size, cpu_addr, dma_handle); | 87 | struct dma_map_ops *ops = platform_dma_get_ops(dev); |
88 | ops->sync_single_for_cpu(dev, daddr, size, dir); | ||
72 | } | 89 | } |
73 | #define dma_map_single_attrs platform_dma_map_single_attrs | 90 | |
74 | static inline dma_addr_t dma_map_single(struct device *dev, void *cpu_addr, | 91 | static inline void dma_sync_sg_for_cpu(struct device *dev, |
75 | size_t size, int dir) | 92 | struct scatterlist *sgl, |
93 | int nents, enum dma_data_direction dir) | ||
76 | { | 94 | { |
77 | return dma_map_single_attrs(dev, cpu_addr, size, dir, NULL); | 95 | struct dma_map_ops *ops = platform_dma_get_ops(dev); |
96 | ops->sync_sg_for_cpu(dev, sgl, nents, dir); | ||
78 | } | 97 | } |
79 | #define dma_map_sg_attrs platform_dma_map_sg_attrs | 98 | |
80 | static inline int dma_map_sg(struct device *dev, struct scatterlist *sgl, | 99 | static inline void dma_sync_single_for_device(struct device *dev, |
81 | int nents, int dir) | 100 | dma_addr_t daddr, |
101 | size_t size, | ||
102 | enum dma_data_direction dir) | ||
82 | { | 103 | { |
83 | return dma_map_sg_attrs(dev, sgl, nents, dir, NULL); | 104 | struct dma_map_ops *ops = platform_dma_get_ops(dev); |
105 | ops->sync_single_for_device(dev, daddr, size, dir); | ||
84 | } | 106 | } |
85 | #define dma_unmap_single_attrs platform_dma_unmap_single_attrs | 107 | |
86 | static inline void dma_unmap_single(struct device *dev, dma_addr_t cpu_addr, | 108 | static inline void dma_sync_sg_for_device(struct device *dev, |
87 | size_t size, int dir) | 109 | struct scatterlist *sgl, |
110 | int nents, | ||
111 | enum dma_data_direction dir) | ||
88 | { | 112 | { |
89 | return dma_unmap_single_attrs(dev, cpu_addr, size, dir, NULL); | 113 | struct dma_map_ops *ops = platform_dma_get_ops(dev); |
114 | ops->sync_sg_for_device(dev, sgl, nents, dir); | ||
90 | } | 115 | } |
91 | #define dma_unmap_sg_attrs platform_dma_unmap_sg_attrs | 116 | |
92 | static inline void dma_unmap_sg(struct device *dev, struct scatterlist *sgl, | 117 | static inline int dma_mapping_error(struct device *dev, dma_addr_t daddr) |
93 | int nents, int dir) | 118 | { |
119 | struct dma_map_ops *ops = platform_dma_get_ops(dev); | ||
120 | return ops->mapping_error(dev, daddr); | ||
121 | } | ||
122 | |||
123 | static inline dma_addr_t dma_map_page(struct device *dev, struct page *page, | ||
124 | size_t offset, size_t size, | ||
125 | enum dma_data_direction dir) | ||
94 | { | 126 | { |
95 | return dma_unmap_sg_attrs(dev, sgl, nents, dir, NULL); | 127 | struct dma_map_ops *ops = platform_dma_get_ops(dev); |
128 | return ops->map_page(dev, page, offset, size, dir, NULL); | ||
96 | } | 129 | } |
97 | #define dma_sync_single_for_cpu platform_dma_sync_single_for_cpu | ||
98 | #define dma_sync_sg_for_cpu platform_dma_sync_sg_for_cpu | ||
99 | #define dma_sync_single_for_device platform_dma_sync_single_for_device | ||
100 | #define dma_sync_sg_for_device platform_dma_sync_sg_for_device | ||
101 | #define dma_mapping_error platform_dma_mapping_error | ||
102 | 130 | ||
103 | #define dma_map_page(dev, pg, off, size, dir) \ | 131 | static inline void dma_unmap_page(struct device *dev, dma_addr_t addr, |
104 | dma_map_single(dev, page_address(pg) + (off), (size), (dir)) | 132 | size_t size, enum dma_data_direction dir) |
105 | #define dma_unmap_page(dev, dma_addr, size, dir) \ | 133 | { |
106 | dma_unmap_single(dev, dma_addr, size, dir) | 134 | dma_unmap_single(dev, addr, size, dir); |
135 | } | ||
107 | 136 | ||
108 | /* | 137 | /* |
109 | * Rest of this file is part of the "Advanced DMA API". Use at your own risk. | 138 | * Rest of this file is part of the "Advanced DMA API". Use at your own risk. |
@@ -115,7 +144,11 @@ static inline void dma_unmap_sg(struct device *dev, struct scatterlist *sgl, | |||
115 | #define dma_sync_single_range_for_device(dev, dma_handle, offset, size, dir) \ | 144 | #define dma_sync_single_range_for_device(dev, dma_handle, offset, size, dir) \ |
116 | dma_sync_single_for_device(dev, dma_handle, size, dir) | 145 | dma_sync_single_for_device(dev, dma_handle, size, dir) |
117 | 146 | ||
118 | #define dma_supported platform_dma_supported | 147 | static inline int dma_supported(struct device *dev, u64 mask) |
148 | { | ||
149 | struct dma_map_ops *ops = platform_dma_get_ops(dev); | ||
150 | return ops->dma_supported(dev, mask); | ||
151 | } | ||
119 | 152 | ||
120 | static inline int | 153 | static inline int |
121 | dma_set_mask (struct device *dev, u64 mask) | 154 | dma_set_mask (struct device *dev, u64 mask) |
@@ -141,11 +174,4 @@ dma_cache_sync (struct device *dev, void *vaddr, size_t size, | |||
141 | 174 | ||
142 | #define dma_is_consistent(d, h) (1) /* all we do is coherent memory... */ | 175 | #define dma_is_consistent(d, h) (1) /* all we do is coherent memory... */ |
143 | 176 | ||
144 | static inline struct dma_mapping_ops *get_dma_ops(struct device *dev) | ||
145 | { | ||
146 | return dma_ops; | ||
147 | } | ||
148 | |||
149 | |||
150 | |||
151 | #endif /* _ASM_IA64_DMA_MAPPING_H */ | 177 | #endif /* _ASM_IA64_DMA_MAPPING_H */ |