diff options
Diffstat (limited to 'include/linux/dma-direct.h')
-rw-r--r-- | include/linux/dma-direct.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/include/linux/dma-direct.h b/include/linux/dma-direct.h new file mode 100644 index 000000000000..bcdb1a3e4b1f --- /dev/null +++ b/include/linux/dma-direct.h | |||
@@ -0,0 +1,47 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
2 | #ifndef _LINUX_DMA_DIRECT_H | ||
3 | #define _LINUX_DMA_DIRECT_H 1 | ||
4 | |||
5 | #include <linux/dma-mapping.h> | ||
6 | |||
7 | #ifdef CONFIG_ARCH_HAS_PHYS_TO_DMA | ||
8 | #include <asm/dma-direct.h> | ||
9 | #else | ||
10 | static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) | ||
11 | { | ||
12 | dma_addr_t dev_addr = (dma_addr_t)paddr; | ||
13 | |||
14 | return dev_addr - ((dma_addr_t)dev->dma_pfn_offset << PAGE_SHIFT); | ||
15 | } | ||
16 | |||
17 | static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t dev_addr) | ||
18 | { | ||
19 | phys_addr_t paddr = (phys_addr_t)dev_addr; | ||
20 | |||
21 | return paddr + ((phys_addr_t)dev->dma_pfn_offset << PAGE_SHIFT); | ||
22 | } | ||
23 | |||
24 | static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size) | ||
25 | { | ||
26 | if (!dev->dma_mask) | ||
27 | return false; | ||
28 | |||
29 | return addr + size - 1 <= *dev->dma_mask; | ||
30 | } | ||
31 | #endif /* !CONFIG_ARCH_HAS_PHYS_TO_DMA */ | ||
32 | |||
33 | #ifdef CONFIG_ARCH_HAS_DMA_MARK_CLEAN | ||
34 | void dma_mark_clean(void *addr, size_t size); | ||
35 | #else | ||
36 | static inline void dma_mark_clean(void *addr, size_t size) | ||
37 | { | ||
38 | } | ||
39 | #endif /* CONFIG_ARCH_HAS_DMA_MARK_CLEAN */ | ||
40 | |||
41 | void *dma_direct_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle, | ||
42 | gfp_t gfp, unsigned long attrs); | ||
43 | void dma_direct_free(struct device *dev, size_t size, void *cpu_addr, | ||
44 | dma_addr_t dma_addr, unsigned long attrs); | ||
45 | int dma_direct_supported(struct device *dev, u64 mask); | ||
46 | |||
47 | #endif /* _LINUX_DMA_DIRECT_H */ | ||