Path: blob/master/arch/frv/include/asm/dma-mapping.h
15118 views
#ifndef _ASM_DMA_MAPPING_H1#define _ASM_DMA_MAPPING_H23#include <linux/device.h>4#include <asm/cache.h>5#include <asm/cacheflush.h>6#include <asm/scatterlist.h>7#include <asm/io.h>89/*10* See Documentation/DMA-API.txt for the description of how the11* following DMA API should work.12*/1314#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)15#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)1617extern unsigned long __nongprelbss dma_coherent_mem_start;18extern unsigned long __nongprelbss dma_coherent_mem_end;1920void *dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t gfp);21void dma_free_coherent(struct device *dev, size_t size, void *vaddr, dma_addr_t dma_handle);2223extern dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size,24enum dma_data_direction direction);2526static inline27void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,28enum dma_data_direction direction)29{30BUG_ON(direction == DMA_NONE);31}3233extern int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,34enum dma_data_direction direction);3536static inline37void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,38enum dma_data_direction direction)39{40BUG_ON(direction == DMA_NONE);41}4243extern44dma_addr_t dma_map_page(struct device *dev, struct page *page, unsigned long offset,45size_t size, enum dma_data_direction direction);4647static inline48void dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,49enum dma_data_direction direction)50{51BUG_ON(direction == DMA_NONE);52}535455static inline56void dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size,57enum dma_data_direction direction)58{59}6061static inline62void dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, size_t size,63enum dma_data_direction direction)64{65flush_write_buffers();66}6768static inline69void dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle,70unsigned long offset, size_t size,71enum dma_data_direction direction)72{73}7475static inline76void dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle,77unsigned long offset, size_t size,78enum dma_data_direction direction)79{80flush_write_buffers();81}8283static inline84void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,85enum dma_data_direction direction)86{87}8889static inline90void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,91enum dma_data_direction direction)92{93flush_write_buffers();94}9596static inline97int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)98{99return 0;100}101102static inline103int dma_supported(struct device *dev, u64 mask)104{105/*106* we fall back to GFP_DMA when the mask isn't all 1s,107* so we can't guarantee allocations that must be108* within a tighter range than GFP_DMA..109*/110if (mask < 0x00ffffff)111return 0;112113return 1;114}115116static inline117int dma_set_mask(struct device *dev, u64 mask)118{119if (!dev->dma_mask || !dma_supported(dev, mask))120return -EIO;121122*dev->dma_mask = mask;123124return 0;125}126127static inline128void dma_cache_sync(struct device *dev, void *vaddr, size_t size,129enum dma_data_direction direction)130{131flush_write_buffers();132}133134#endif /* _ASM_DMA_MAPPING_H */135136137