Path: blob/master/arch/ia64/include/asm/dma-mapping.h
17479 views
#ifndef _ASM_IA64_DMA_MAPPING_H1#define _ASM_IA64_DMA_MAPPING_H23/*4* Copyright (C) 2003-2004 Hewlett-Packard Co5* David Mosberger-Tang <[email protected]>6*/7#include <asm/machvec.h>8#include <linux/scatterlist.h>9#include <asm/swiotlb.h>10#include <linux/dma-debug.h>1112#define ARCH_HAS_DMA_GET_REQUIRED_MASK1314#define DMA_ERROR_CODE 01516extern struct dma_map_ops *dma_ops;17extern struct ia64_machine_vector ia64_mv;18extern void set_iommu_machvec(void);1920extern void machvec_dma_sync_single(struct device *, dma_addr_t, size_t,21enum dma_data_direction);22extern void machvec_dma_sync_sg(struct device *, struct scatterlist *, int,23enum dma_data_direction);2425static inline void *dma_alloc_coherent(struct device *dev, size_t size,26dma_addr_t *daddr, gfp_t gfp)27{28struct dma_map_ops *ops = platform_dma_get_ops(dev);29void *caddr;3031caddr = ops->alloc_coherent(dev, size, daddr, gfp);32debug_dma_alloc_coherent(dev, size, *daddr, caddr);33return caddr;34}3536static inline void dma_free_coherent(struct device *dev, size_t size,37void *caddr, dma_addr_t daddr)38{39struct dma_map_ops *ops = platform_dma_get_ops(dev);40debug_dma_free_coherent(dev, size, caddr, daddr);41ops->free_coherent(dev, size, caddr, daddr);42}4344#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)45#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)4647#define get_dma_ops(dev) platform_dma_get_ops(dev)4849#include <asm-generic/dma-mapping-common.h>5051static inline int dma_mapping_error(struct device *dev, dma_addr_t daddr)52{53struct dma_map_ops *ops = platform_dma_get_ops(dev);54return ops->mapping_error(dev, daddr);55}5657static inline int dma_supported(struct device *dev, u64 mask)58{59struct dma_map_ops *ops = platform_dma_get_ops(dev);60return ops->dma_supported(dev, mask);61}6263static inline int64dma_set_mask (struct device *dev, u64 mask)65{66if (!dev->dma_mask || !dma_supported(dev, mask))67return -EIO;68*dev->dma_mask = mask;69return 0;70}7172static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)73{74if (!dev->dma_mask)75return 0;7677return addr + size - 1 <= *dev->dma_mask;78}7980static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)81{82return paddr;83}8485static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)86{87return daddr;88}8990static inline void91dma_cache_sync (struct device *dev, void *vaddr, size_t size,92enum dma_data_direction dir)93{94/*95* IA-64 is cache-coherent, so this is mostly a no-op. However, we do need to96* ensure that dma_cache_sync() enforces order, hence the mb().97*/98mb();99}100101#endif /* _ASM_IA64_DMA_MAPPING_H */102103104