spi-topcliff-pch: Fix issue for transmitting over 4KByte
[zen-stable.git] / arch / c6x / include / asm / dma-mapping.h
blob03579fd99dba62ad24c2649536a623ed37c24aa8
1 /*
2 * Port on Texas Instruments TMS320C6x architecture
4 * Copyright (C) 2004, 2009, 2010, 2011 Texas Instruments Incorporated
5 * Author: Aurelien Jacquiot <aurelien.jacquiot@ti.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
12 #ifndef _ASM_C6X_DMA_MAPPING_H
13 #define _ASM_C6X_DMA_MAPPING_H
15 #include <linux/dma-debug.h>
16 #include <asm-generic/dma-coherent.h>
18 #define dma_supported(d, m) 1
20 static inline int dma_set_mask(struct device *dev, u64 dma_mask)
22 if (!dev->dma_mask || !dma_supported(dev, dma_mask))
23 return -EIO;
25 *dev->dma_mask = dma_mask;
27 return 0;
31 * DMA errors are defined by all-bits-set in the DMA address.
33 static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
35 return dma_addr == ~0;
38 extern dma_addr_t dma_map_single(struct device *dev, void *cpu_addr,
39 size_t size, enum dma_data_direction dir);
41 extern void dma_unmap_single(struct device *dev, dma_addr_t handle,
42 size_t size, enum dma_data_direction dir);
44 extern int dma_map_sg(struct device *dev, struct scatterlist *sglist,
45 int nents, enum dma_data_direction direction);
47 extern void dma_unmap_sg(struct device *dev, struct scatterlist *sglist,
48 int nents, enum dma_data_direction direction);
50 static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
51 unsigned long offset, size_t size,
52 enum dma_data_direction dir)
54 dma_addr_t handle;
56 handle = dma_map_single(dev, page_address(page) + offset, size, dir);
58 debug_dma_map_page(dev, page, offset, size, dir, handle, false);
60 return handle;
63 static inline void dma_unmap_page(struct device *dev, dma_addr_t handle,
64 size_t size, enum dma_data_direction dir)
66 dma_unmap_single(dev, handle, size, dir);
68 debug_dma_unmap_page(dev, handle, size, dir, false);
71 extern void dma_sync_single_for_cpu(struct device *dev, dma_addr_t handle,
72 size_t size, enum dma_data_direction dir);
74 extern void dma_sync_single_for_device(struct device *dev, dma_addr_t handle,
75 size_t size,
76 enum dma_data_direction dir);
78 extern void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
79 int nents, enum dma_data_direction dir);
81 extern void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
82 int nents, enum dma_data_direction dir);
84 extern void coherent_mem_init(u32 start, u32 size);
85 extern void *dma_alloc_coherent(struct device *, size_t, dma_addr_t *, gfp_t);
86 extern void dma_free_coherent(struct device *, size_t, void *, dma_addr_t);
88 #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent((d), (s), (h), (f))
89 #define dma_free_noncoherent(d, s, v, h) dma_free_coherent((d), (s), (v), (h))
91 #endif /* _ASM_C6X_DMA_MAPPING_H */