Linux-libre 4.15.7-gnu
[librecmc/linux-libre.git] / arch / blackfin / include / asm / dma-mapping.h
1 /*
2  * Copyright 2004-2009 Analog Devices Inc.
3  *
4  * Licensed under the GPL-2 or later.
5  */
6
7 #ifndef _BLACKFIN_DMA_MAPPING_H
8 #define _BLACKFIN_DMA_MAPPING_H
9
10 #include <asm/cacheflush.h>
11
12 extern void
13 __dma_sync(dma_addr_t addr, size_t size, enum dma_data_direction dir);
14 static inline void
15 __dma_sync_inline(dma_addr_t addr, size_t size, enum dma_data_direction dir)
16 {
17         switch (dir) {
18         case DMA_NONE:
19                 BUG();
20         case DMA_TO_DEVICE:             /* writeback only */
21                 flush_dcache_range(addr, addr + size);
22                 break;
23         case DMA_FROM_DEVICE: /* invalidate only */
24         case DMA_BIDIRECTIONAL: /* flush and invalidate */
25                 /* Blackfin has no dedicated invalidate (it includes a flush) */
26                 invalidate_dcache_range(addr, addr + size);
27                 break;
28         }
29 }
30 static inline void
31 _dma_sync(dma_addr_t addr, size_t size, enum dma_data_direction dir)
32 {
33         if (__builtin_constant_p(dir))
34                 __dma_sync_inline(addr, size, dir);
35         else
36                 __dma_sync(addr, size, dir);
37 }
38
39 extern const struct dma_map_ops bfin_dma_ops;
40
41 static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
42 {
43         return &bfin_dma_ops;
44 }
45
46 #endif                          /* _BLACKFIN_DMA_MAPPING_H */