Path: blob/master/arch/tile/include/asm/dma-mapping.h
10819 views
/*1* Copyright 2010 Tilera Corporation. All Rights Reserved.2*3* This program is free software; you can redistribute it and/or4* modify it under the terms of the GNU General Public License5* as published by the Free Software Foundation, version 2.6*7* This program is distributed in the hope that it will be useful, but8* WITHOUT ANY WARRANTY; without even the implied warranty of9* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or10* NON INFRINGEMENT. See the GNU General Public License for11* more details.12*/1314#ifndef _ASM_TILE_DMA_MAPPING_H15#define _ASM_TILE_DMA_MAPPING_H1617#include <linux/mm.h>18#include <linux/scatterlist.h>19#include <linux/cache.h>20#include <linux/io.h>2122/*23* Note that on x86 and powerpc, there is a "struct dma_mapping_ops"24* that is used for all the DMA operations. For now, we don't have an25* equivalent on tile, because we only have a single way of doing DMA.26* (Tilera bug 7994 to use dma_mapping_ops.)27*/2829#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)30#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)3132extern dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size,33enum dma_data_direction);34extern void dma_unmap_single(struct device *dev, dma_addr_t dma_addr,35size_t size, enum dma_data_direction);36extern int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,37enum dma_data_direction);38extern void dma_unmap_sg(struct device *dev, struct scatterlist *sg,39int nhwentries, enum dma_data_direction);40extern dma_addr_t dma_map_page(struct device *dev, struct page *page,41unsigned long offset, size_t size,42enum dma_data_direction);43extern void dma_unmap_page(struct device *dev, dma_addr_t dma_address,44size_t size, enum dma_data_direction);45extern void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,46int nelems, enum dma_data_direction);47extern void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,48int nelems, enum dma_data_direction);495051void *dma_alloc_coherent(struct device *dev, size_t size,52dma_addr_t *dma_handle, gfp_t flag);5354void dma_free_coherent(struct device *dev, size_t size,55void *vaddr, dma_addr_t dma_handle);5657extern void dma_sync_single_for_cpu(struct device *, dma_addr_t, size_t,58enum dma_data_direction);59extern void dma_sync_single_for_device(struct device *, dma_addr_t,60size_t, enum dma_data_direction);61extern void dma_sync_single_range_for_cpu(struct device *, dma_addr_t,62unsigned long offset, size_t,63enum dma_data_direction);64extern void dma_sync_single_range_for_device(struct device *, dma_addr_t,65unsigned long offset, size_t,66enum dma_data_direction);67extern void dma_cache_sync(struct device *dev, void *vaddr, size_t,68enum dma_data_direction);6970static inline int71dma_mapping_error(struct device *dev, dma_addr_t dma_addr)72{73return 0;74}7576static inline int77dma_supported(struct device *dev, u64 mask)78{79return 1;80}8182static inline int83dma_set_mask(struct device *dev, u64 mask)84{85if (!dev->dma_mask || !dma_supported(dev, mask))86return -EIO;8788*dev->dma_mask = mask;8990return 0;91}9293#endif /* _ASM_TILE_DMA_MAPPING_H */949596