Full support for Ginger Console
[linux-ginger.git] / arch / blackfin / include / asm / dma-mapping.h
blob7a23d824ac961693d5935ccd757fa359f2cb8438
1 /*
2 * Copyright 2004-2009 Analog Devices Inc.
4 * Licensed under the GPL-2 or later.
5 */
7 #ifndef _BLACKFIN_DMA_MAPPING_H
8 #define _BLACKFIN_DMA_MAPPING_H
10 #include <asm/scatterlist.h>
12 void dma_alloc_init(unsigned long start, unsigned long end);
13 void *dma_alloc_coherent(struct device *dev, size_t size,
14 dma_addr_t *dma_handle, gfp_t gfp);
15 void dma_free_coherent(struct device *dev, size_t size, void *vaddr,
16 dma_addr_t dma_handle);
19 * Now for the API extensions over the pci_ one
21 #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
22 #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
24 static inline
25 int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
27 return 0;
31 * Map a single buffer of the indicated size for DMA in streaming mode.
32 * The 32-bit bus address to use is returned.
34 * Once the device is given the dma address, the device owns this memory
35 * until either pci_unmap_single or pci_dma_sync_single is performed.
37 extern dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size,
38 enum dma_data_direction direction);
40 static inline dma_addr_t
41 dma_map_page(struct device *dev, struct page *page,
42 unsigned long offset, size_t size,
43 enum dma_data_direction dir)
45 return dma_map_single(dev, page_address(page) + offset, size, dir);
49 * Unmap a single streaming mode DMA translation. The dma_addr and size
50 * must match what was provided for in a previous pci_map_single call. All
51 * other usages are undefined.
53 * After this call, reads by the cpu to the buffer are guarenteed to see
54 * whatever the device wrote there.
56 extern void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
57 enum dma_data_direction direction);
59 static inline void
60 dma_unmap_page(struct device *dev, dma_addr_t dma_addr, size_t size,
61 enum dma_data_direction dir)
63 dma_unmap_single(dev, dma_addr, size, dir);
67 * Map a set of buffers described by scatterlist in streaming
68 * mode for DMA. This is the scather-gather version of the
69 * above pci_map_single interface. Here the scatter gather list
70 * elements are each tagged with the appropriate dma address
71 * and length. They are obtained via sg_dma_{address,length}(SG).
73 * NOTE: An implementation may be able to use a smaller number of
74 * DMA address/length pairs than there are SG table elements.
75 * (for example via virtual mapping capabilities)
76 * The routine returns the number of addr/length pairs actually
77 * used, at most nents.
79 * Device ownership issues as mentioned above for pci_map_single are
80 * the same here.
82 extern int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
83 enum dma_data_direction direction);
86 * Unmap a set of streaming mode DMA translations.
87 * Again, cpu read rules concerning calls here are the same as for
88 * pci_unmap_single() above.
90 extern void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
91 int nhwentries, enum dma_data_direction direction);
93 static inline void dma_sync_single_for_cpu(struct device *dev,
94 dma_addr_t handle, size_t size,
95 enum dma_data_direction dir)
99 static inline void dma_sync_single_for_device(struct device *dev,
100 dma_addr_t handle, size_t size,
101 enum dma_data_direction dir)
105 static inline void dma_sync_sg_for_cpu(struct device *dev,
106 struct scatterlist *sg,
107 int nents, enum dma_data_direction dir)
111 static inline void dma_sync_sg_for_device(struct device *dev,
112 struct scatterlist *sg,
113 int nents, enum dma_data_direction dir)
117 #endif /* _BLACKFIN_DMA_MAPPING_H */