2018-01-10 23:21:13 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
#ifndef ASM_POWERPC_DMA_DIRECT_H
|
|
|
|
#define ASM_POWERPC_DMA_DIRECT_H 1
|
|
|
|
|
|
|
|
static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
|
|
|
|
{
|
|
|
|
if (!dev->dma_mask)
|
|
|
|
return false;
|
|
|
|
|
2019-02-13 15:01:21 +08:00
|
|
|
return addr + size - 1 <=
|
|
|
|
min_not_zero(*dev->dma_mask, dev->bus_dma_mask);
|
2018-01-10 23:21:13 +08:00
|
|
|
}
|
|
|
|
|
2018-03-19 18:38:24 +08:00
|
|
|
static inline dma_addr_t __phys_to_dma(struct device *dev, phys_addr_t paddr)
|
2018-01-10 23:21:13 +08:00
|
|
|
{
|
2019-02-13 15:01:31 +08:00
|
|
|
if (!dev)
|
|
|
|
return paddr + PCI_DRAM_OFFSET;
|
|
|
|
return paddr + dev->archdata.dma_offset;
|
2018-01-10 23:21:13 +08:00
|
|
|
}
|
|
|
|
|
2018-03-19 18:38:24 +08:00
|
|
|
static inline phys_addr_t __dma_to_phys(struct device *dev, dma_addr_t daddr)
|
2018-01-10 23:21:13 +08:00
|
|
|
{
|
2019-02-13 15:01:31 +08:00
|
|
|
if (!dev)
|
|
|
|
return daddr - PCI_DRAM_OFFSET;
|
|
|
|
return daddr - dev->archdata.dma_offset;
|
2018-01-10 23:21:13 +08:00
|
|
|
}
|
|
|
|
#endif /* ASM_POWERPC_DMA_DIRECT_H */
|