blob: ed6b1f3cccce769cf62b38ae70cbac7c7c77e1bd [file] [log] [blame]
Bryan Wu1394f032007-05-06 14:50:22 -07001#ifndef _BLACKFIN_DMA_MAPPING_H
2#define _BLACKFIN_DMA_MAPPING_H
3
4#include <asm/scatterlist.h>
5
6void dma_alloc_init(unsigned long start, unsigned long end);
7void *dma_alloc_coherent(struct device *dev, size_t size,
8 dma_addr_t *dma_handle, gfp_t gfp);
9void dma_free_coherent(struct device *dev, size_t size, void *vaddr,
10 dma_addr_t dma_handle);
11
12/*
13 * Now for the API extensions over the pci_ one
14 */
15#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
16#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
17
Mike Frysinger62273ee2008-11-18 17:48:22 +080018static inline
19int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
20{
21 return 0;
22}
Sonic Zhang334280f2007-06-21 11:34:16 +080023
Bryan Wu1394f032007-05-06 14:50:22 -070024/*
25 * Map a single buffer of the indicated size for DMA in streaming mode.
26 * The 32-bit bus address to use is returned.
27 *
28 * Once the device is given the dma address, the device owns this memory
29 * until either pci_unmap_single or pci_dma_sync_single is performed.
30 */
31extern dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size,
32 enum dma_data_direction direction);
33
Bryan Wu9fcdc782008-04-23 07:41:52 +080034static inline dma_addr_t
35dma_map_page(struct device *dev, struct page *page,
36 unsigned long offset, size_t size,
37 enum dma_data_direction dir)
38{
39 return dma_map_single(dev, page_address(page) + offset, size, dir);
40}
41
Bryan Wu1394f032007-05-06 14:50:22 -070042/*
43 * Unmap a single streaming mode DMA translation. The dma_addr and size
44 * must match what was provided for in a previous pci_map_single call. All
45 * other usages are undefined.
46 *
47 * After this call, reads by the cpu to the buffer are guarenteed to see
48 * whatever the device wrote there.
49 */
50extern void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
51 enum dma_data_direction direction);
52
Bryan Wu9fcdc782008-04-23 07:41:52 +080053static inline void
54dma_unmap_page(struct device *dev, dma_addr_t dma_addr, size_t size,
55 enum dma_data_direction dir)
56{
57 dma_unmap_single(dev, dma_addr, size, dir);
58}
59
Bryan Wu1394f032007-05-06 14:50:22 -070060/*
61 * Map a set of buffers described by scatterlist in streaming
62 * mode for DMA. This is the scather-gather version of the
63 * above pci_map_single interface. Here the scatter gather list
64 * elements are each tagged with the appropriate dma address
65 * and length. They are obtained via sg_dma_{address,length}(SG).
66 *
67 * NOTE: An implementation may be able to use a smaller number of
68 * DMA address/length pairs than there are SG table elements.
69 * (for example via virtual mapping capabilities)
70 * The routine returns the number of addr/length pairs actually
71 * used, at most nents.
72 *
73 * Device ownership issues as mentioned above for pci_map_single are
74 * the same here.
75 */
76extern int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
77 enum dma_data_direction direction);
78
79/*
80 * Unmap a set of streaming mode DMA translations.
81 * Again, cpu read rules concerning calls here are the same as for
82 * pci_unmap_single() above.
83 */
84extern void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
85 int nhwentries, enum dma_data_direction direction);
86
Bryan Wu31f3d4a2008-09-22 20:23:55 +080087static inline void dma_sync_single_for_cpu(struct device *dev,
88 dma_addr_t handle, size_t size,
89 enum dma_data_direction dir)
90{
91}
92
93static inline void dma_sync_single_for_device(struct device *dev,
94 dma_addr_t handle, size_t size,
95 enum dma_data_direction dir)
96{
97}
FUJITA Tomonori42b86e02009-06-22 21:48:37 -040098
99static inline void dma_sync_sg_for_cpu(struct device *dev,
100 struct scatterlist *sg,
101 int nents, enum dma_data_direction dir)
102{
103}
104
105static inline void dma_sync_sg_for_device(struct device *dev,
106 struct scatterlist *sg,
107 int nents, enum dma_data_direction dir)
108{
109}
110
Bryan Wu1394f032007-05-06 14:50:22 -0700111#endif /* _BLACKFIN_DMA_MAPPING_H */