diff options
Diffstat (limited to 'include/asm-powerpc/dma-mapping.h')
-rw-r--r-- | include/asm-powerpc/dma-mapping.h | 116 |
1 files changed, 86 insertions, 30 deletions
diff --git a/include/asm-powerpc/dma-mapping.h b/include/asm-powerpc/dma-mapping.h index bbefb69bfb67..de1395023cb1 100644 --- a/include/asm-powerpc/dma-mapping.h +++ b/include/asm-powerpc/dma-mapping.h | |||
@@ -13,6 +13,7 @@ | |||
13 | /* need struct page definitions */ | 13 | /* need struct page definitions */ |
14 | #include <linux/mm.h> | 14 | #include <linux/mm.h> |
15 | #include <linux/scatterlist.h> | 15 | #include <linux/scatterlist.h> |
16 | #include <linux/dma-attrs.h> | ||
16 | #include <asm/io.h> | 17 | #include <asm/io.h> |
17 | 18 | ||
18 | #define DMA_ERROR_CODE (~(dma_addr_t)0x0) | 19 | #define DMA_ERROR_CODE (~(dma_addr_t)0x0) |
@@ -53,13 +54,17 @@ struct dma_mapping_ops { | |||
53 | void (*free_coherent)(struct device *dev, size_t size, | 54 | void (*free_coherent)(struct device *dev, size_t size, |
54 | void *vaddr, dma_addr_t dma_handle); | 55 | void *vaddr, dma_addr_t dma_handle); |
55 | dma_addr_t (*map_single)(struct device *dev, void *ptr, | 56 | dma_addr_t (*map_single)(struct device *dev, void *ptr, |
56 | size_t size, enum dma_data_direction direction); | 57 | size_t size, enum dma_data_direction direction, |
58 | struct dma_attrs *attrs); | ||
57 | void (*unmap_single)(struct device *dev, dma_addr_t dma_addr, | 59 | void (*unmap_single)(struct device *dev, dma_addr_t dma_addr, |
58 | size_t size, enum dma_data_direction direction); | 60 | size_t size, enum dma_data_direction direction, |
61 | struct dma_attrs *attrs); | ||
59 | int (*map_sg)(struct device *dev, struct scatterlist *sg, | 62 | int (*map_sg)(struct device *dev, struct scatterlist *sg, |
60 | int nents, enum dma_data_direction direction); | 63 | int nents, enum dma_data_direction direction, |
64 | struct dma_attrs *attrs); | ||
61 | void (*unmap_sg)(struct device *dev, struct scatterlist *sg, | 65 | void (*unmap_sg)(struct device *dev, struct scatterlist *sg, |
62 | int nents, enum dma_data_direction direction); | 66 | int nents, enum dma_data_direction direction, |
67 | struct dma_attrs *attrs); | ||
63 | int (*dma_supported)(struct device *dev, u64 mask); | 68 | int (*dma_supported)(struct device *dev, u64 mask); |
64 | int (*set_dma_mask)(struct device *dev, u64 dma_mask); | 69 | int (*set_dma_mask)(struct device *dev, u64 dma_mask); |
65 | }; | 70 | }; |
@@ -109,6 +114,77 @@ static inline int dma_set_mask(struct device *dev, u64 dma_mask) | |||
109 | return 0; | 114 | return 0; |
110 | } | 115 | } |
111 | 116 | ||
117 | static inline dma_addr_t dma_map_single_attrs(struct device *dev, | ||
118 | void *cpu_addr, | ||
119 | size_t size, | ||
120 | enum dma_data_direction direction, | ||
121 | struct dma_attrs *attrs) | ||
122 | { | ||
123 | struct dma_mapping_ops *dma_ops = get_dma_ops(dev); | ||
124 | |||
125 | BUG_ON(!dma_ops); | ||
126 | return dma_ops->map_single(dev, cpu_addr, size, direction, attrs); | ||
127 | } | ||
128 | |||
129 | static inline void dma_unmap_single_attrs(struct device *dev, | ||
130 | dma_addr_t dma_addr, | ||
131 | size_t size, | ||
132 | enum dma_data_direction direction, | ||
133 | struct dma_attrs *attrs) | ||
134 | { | ||
135 | struct dma_mapping_ops *dma_ops = get_dma_ops(dev); | ||
136 | |||
137 | BUG_ON(!dma_ops); | ||
138 | dma_ops->unmap_single(dev, dma_addr, size, direction, attrs); | ||
139 | } | ||
140 | |||
141 | static inline dma_addr_t dma_map_page_attrs(struct device *dev, | ||
142 | struct page *page, | ||
143 | unsigned long offset, size_t size, | ||
144 | enum dma_data_direction direction, | ||
145 | struct dma_attrs *attrs) | ||
146 | { | ||
147 | struct dma_mapping_ops *dma_ops = get_dma_ops(dev); | ||
148 | |||
149 | BUG_ON(!dma_ops); | ||
150 | return dma_ops->map_single(dev, page_address(page) + offset, size, | ||
151 | direction, attrs); | ||
152 | } | ||
153 | |||
154 | static inline void dma_unmap_page_attrs(struct device *dev, | ||
155 | dma_addr_t dma_address, | ||
156 | size_t size, | ||
157 | enum dma_data_direction direction, | ||
158 | struct dma_attrs *attrs) | ||
159 | { | ||
160 | struct dma_mapping_ops *dma_ops = get_dma_ops(dev); | ||
161 | |||
162 | BUG_ON(!dma_ops); | ||
163 | dma_ops->unmap_single(dev, dma_address, size, direction, attrs); | ||
164 | } | ||
165 | |||
166 | static inline int dma_map_sg_attrs(struct device *dev, struct scatterlist *sg, | ||
167 | int nents, enum dma_data_direction direction, | ||
168 | struct dma_attrs *attrs) | ||
169 | { | ||
170 | struct dma_mapping_ops *dma_ops = get_dma_ops(dev); | ||
171 | |||
172 | BUG_ON(!dma_ops); | ||
173 | return dma_ops->map_sg(dev, sg, nents, direction, attrs); | ||
174 | } | ||
175 | |||
176 | static inline void dma_unmap_sg_attrs(struct device *dev, | ||
177 | struct scatterlist *sg, | ||
178 | int nhwentries, | ||
179 | enum dma_data_direction direction, | ||
180 | struct dma_attrs *attrs) | ||
181 | { | ||
182 | struct dma_mapping_ops *dma_ops = get_dma_ops(dev); | ||
183 | |||
184 | BUG_ON(!dma_ops); | ||
185 | dma_ops->unmap_sg(dev, sg, nhwentries, direction, attrs); | ||
186 | } | ||
187 | |||
112 | static inline void *dma_alloc_coherent(struct device *dev, size_t size, | 188 | static inline void *dma_alloc_coherent(struct device *dev, size_t size, |
113 | dma_addr_t *dma_handle, gfp_t flag) | 189 | dma_addr_t *dma_handle, gfp_t flag) |
114 | { | 190 | { |
@@ -131,63 +207,43 @@ static inline dma_addr_t dma_map_single(struct device *dev, void *cpu_addr, | |||
131 | size_t size, | 207 | size_t size, |
132 | enum dma_data_direction direction) | 208 | enum dma_data_direction direction) |
133 | { | 209 | { |
134 | struct dma_mapping_ops *dma_ops = get_dma_ops(dev); | 210 | return dma_map_single_attrs(dev, cpu_addr, size, direction, NULL); |
135 | |||
136 | BUG_ON(!dma_ops); | ||
137 | return dma_ops->map_single(dev, cpu_addr, size, direction); | ||
138 | } | 211 | } |
139 | 212 | ||
140 | static inline void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, | 213 | static inline void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, |
141 | size_t size, | 214 | size_t size, |
142 | enum dma_data_direction direction) | 215 | enum dma_data_direction direction) |
143 | { | 216 | { |
144 | struct dma_mapping_ops *dma_ops = get_dma_ops(dev); | 217 | dma_unmap_single_attrs(dev, dma_addr, size, direction, NULL); |
145 | |||
146 | BUG_ON(!dma_ops); | ||
147 | dma_ops->unmap_single(dev, dma_addr, size, direction); | ||
148 | } | 218 | } |
149 | 219 | ||
150 | static inline dma_addr_t dma_map_page(struct device *dev, struct page *page, | 220 | static inline dma_addr_t dma_map_page(struct device *dev, struct page *page, |
151 | unsigned long offset, size_t size, | 221 | unsigned long offset, size_t size, |
152 | enum dma_data_direction direction) | 222 | enum dma_data_direction direction) |
153 | { | 223 | { |
154 | struct dma_mapping_ops *dma_ops = get_dma_ops(dev); | 224 | return dma_map_page_attrs(dev, page, offset, size, direction, NULL); |
155 | |||
156 | BUG_ON(!dma_ops); | ||
157 | return dma_ops->map_single(dev, page_address(page) + offset, size, | ||
158 | direction); | ||
159 | } | 225 | } |
160 | 226 | ||
161 | static inline void dma_unmap_page(struct device *dev, dma_addr_t dma_address, | 227 | static inline void dma_unmap_page(struct device *dev, dma_addr_t dma_address, |
162 | size_t size, | 228 | size_t size, |
163 | enum dma_data_direction direction) | 229 | enum dma_data_direction direction) |
164 | { | 230 | { |
165 | struct dma_mapping_ops *dma_ops = get_dma_ops(dev); | 231 | dma_unmap_page_attrs(dev, dma_address, size, direction, NULL); |
166 | |||
167 | BUG_ON(!dma_ops); | ||
168 | dma_ops->unmap_single(dev, dma_address, size, direction); | ||
169 | } | 232 | } |
170 | 233 | ||
171 | static inline int dma_map_sg(struct device *dev, struct scatterlist *sg, | 234 | static inline int dma_map_sg(struct device *dev, struct scatterlist *sg, |
172 | int nents, enum dma_data_direction direction) | 235 | int nents, enum dma_data_direction direction) |
173 | { | 236 | { |
174 | struct dma_mapping_ops *dma_ops = get_dma_ops(dev); | 237 | return dma_map_sg_attrs(dev, sg, nents, direction, NULL); |
175 | |||
176 | BUG_ON(!dma_ops); | ||
177 | return dma_ops->map_sg(dev, sg, nents, direction); | ||
178 | } | 238 | } |
179 | 239 | ||
180 | static inline void dma_unmap_sg(struct device *dev, struct scatterlist *sg, | 240 | static inline void dma_unmap_sg(struct device *dev, struct scatterlist *sg, |
181 | int nhwentries, | 241 | int nhwentries, |
182 | enum dma_data_direction direction) | 242 | enum dma_data_direction direction) |
183 | { | 243 | { |
184 | struct dma_mapping_ops *dma_ops = get_dma_ops(dev); | 244 | dma_unmap_sg_attrs(dev, sg, nhwentries, direction, NULL); |
185 | |||
186 | BUG_ON(!dma_ops); | ||
187 | dma_ops->unmap_sg(dev, sg, nhwentries, direction); | ||
188 | } | 245 | } |
189 | 246 | ||
190 | |||
191 | /* | 247 | /* |
192 | * Available generic sets of operations | 248 | * Available generic sets of operations |
193 | */ | 249 | */ |