xref: /linux/arch/powerpc/include/asm/dma-direct.h (revision ec63e2a4897075e427c121d863bd89c44578094f)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef ASM_POWERPC_DMA_DIRECT_H
3 #define ASM_POWERPC_DMA_DIRECT_H 1
4 
5 static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
6 {
7 	if (!dev->dma_mask)
8 		return false;
9 
10 	return addr + size - 1 <=
11 		min_not_zero(*dev->dma_mask, dev->bus_dma_mask);
12 }
13 
14 static inline dma_addr_t __phys_to_dma(struct device *dev, phys_addr_t paddr)
15 {
16 	if (!dev)
17 		return paddr + PCI_DRAM_OFFSET;
18 	return paddr + dev->archdata.dma_offset;
19 }
20 
21 static inline phys_addr_t __dma_to_phys(struct device *dev, dma_addr_t daddr)
22 {
23 	if (!dev)
24 		return daddr - PCI_DRAM_OFFSET;
25 	return daddr - dev->archdata.dma_offset;
26 }
27 #endif /* ASM_POWERPC_DMA_DIRECT_H */
28