diff options
author | Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> | 2016-08-10 07:22:16 -0400 |
---|---|---|
committer | Vinod Koul <vinod.koul@intel.com> | 2016-09-26 12:46:41 -0400 |
commit | 6f3d87968f9c8b529bc81eff5a1f45e92553493d (patch) | |
tree | 977a550789b14f198154488a9c105cc2049c6b50 /include/linux/dma-mapping.h | |
parent | 0e74b34dfc3318bf4c7e51349d453d49fb8e9e16 (diff) |
dma-mapping: add dma_{map,unmap}_resource
Map/Unmap a device MMIO resource from a physical address. If no dma_map_ops
method is available the operation is a no-op.
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Diffstat (limited to 'include/linux/dma-mapping.h')
-rw-r--r-- | include/linux/dma-mapping.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index 673b7be85f7a..6e00c7fdbbd3 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h | |||
@@ -264,6 +264,42 @@ static inline void dma_unmap_page(struct device *dev, dma_addr_t addr, | |||
264 | debug_dma_unmap_page(dev, addr, size, dir, false); | 264 | debug_dma_unmap_page(dev, addr, size, dir, false); |
265 | } | 265 | } |
266 | 266 | ||
267 | static inline dma_addr_t dma_map_resource(struct device *dev, | ||
268 | phys_addr_t phys_addr, | ||
269 | size_t size, | ||
270 | enum dma_data_direction dir, | ||
271 | unsigned long attrs) | ||
272 | { | ||
273 | struct dma_map_ops *ops = get_dma_ops(dev); | ||
274 | unsigned long pfn = __phys_to_pfn(phys_addr); | ||
275 | dma_addr_t addr; | ||
276 | |||
277 | BUG_ON(!valid_dma_direction(dir)); | ||
278 | |||
279 | /* Don't allow RAM to be mapped */ | ||
280 | BUG_ON(pfn_valid(pfn)); | ||
281 | |||
282 | addr = phys_addr; | ||
283 | if (ops->map_resource) | ||
284 | addr = ops->map_resource(dev, phys_addr, size, dir, attrs); | ||
285 | |||
286 | debug_dma_map_resource(dev, phys_addr, size, dir, addr); | ||
287 | |||
288 | return addr; | ||
289 | } | ||
290 | |||
291 | static inline void dma_unmap_resource(struct device *dev, dma_addr_t addr, | ||
292 | size_t size, enum dma_data_direction dir, | ||
293 | unsigned long attrs) | ||
294 | { | ||
295 | struct dma_map_ops *ops = get_dma_ops(dev); | ||
296 | |||
297 | BUG_ON(!valid_dma_direction(dir)); | ||
298 | if (ops->unmap_resource) | ||
299 | ops->unmap_resource(dev, addr, size, dir, attrs); | ||
300 | debug_dma_unmap_resource(dev, addr, size, dir); | ||
301 | } | ||
302 | |||
267 | static inline void dma_sync_single_for_cpu(struct device *dev, dma_addr_t addr, | 303 | static inline void dma_sync_single_for_cpu(struct device *dev, dma_addr_t addr, |
268 | size_t size, | 304 | size_t size, |
269 | enum dma_data_direction dir) | 305 | enum dma_data_direction dir) |