aboutsummaryrefslogtreecommitdiffstats
path: root/arch/blackfin/include/asm/dma-mapping.h
diff options
context:
space:
mode:
Diffstat (limited to 'arch/blackfin/include/asm/dma-mapping.h')
-rw-r--r--arch/blackfin/include/asm/dma-mapping.h127
1 files changed, 104 insertions, 23 deletions
diff --git a/arch/blackfin/include/asm/dma-mapping.h b/arch/blackfin/include/asm/dma-mapping.h
index ed6b1f3cccce..f9172ff30e5c 100644
--- a/arch/blackfin/include/asm/dma-mapping.h
+++ b/arch/blackfin/include/asm/dma-mapping.h
@@ -1,9 +1,15 @@
1/*
2 * Copyright 2004-2009 Analog Devices Inc.
3 *
4 * Licensed under the GPL-2 or later.
5 */
6
1#ifndef _BLACKFIN_DMA_MAPPING_H 7#ifndef _BLACKFIN_DMA_MAPPING_H
2#define _BLACKFIN_DMA_MAPPING_H 8#define _BLACKFIN_DMA_MAPPING_H
3 9
4#include <asm/scatterlist.h> 10#include <asm/cacheflush.h>
11struct scatterlist;
5 12
6void dma_alloc_init(unsigned long start, unsigned long end);
7void *dma_alloc_coherent(struct device *dev, size_t size, 13void *dma_alloc_coherent(struct device *dev, size_t size,
8 dma_addr_t *dma_handle, gfp_t gfp); 14 dma_addr_t *dma_handle, gfp_t gfp);
9void dma_free_coherent(struct device *dev, size_t size, void *vaddr, 15void dma_free_coherent(struct device *dev, size_t size, void *vaddr,
@@ -14,13 +20,51 @@ void dma_free_coherent(struct device *dev, size_t size, void *vaddr,
14 */ 20 */
15#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) 21#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) 22#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
23#define dma_supported(d, m) (1)
24#define dma_get_cache_alignment() (32)
25#define dma_is_consistent(d, h) (1)
26
27static inline int
28dma_set_mask(struct device *dev, u64 dma_mask)
29{
30 if (!dev->dma_mask || !dma_supported(dev, dma_mask))
31 return -EIO;
32
33 *dev->dma_mask = dma_mask;
34
35 return 0;
36}
17 37
18static inline 38static inline int
19int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) 39dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
20{ 40{
21 return 0; 41 return 0;
22} 42}
23 43
44extern void
45__dma_sync(dma_addr_t addr, size_t size, enum dma_data_direction dir);
46static inline void
47_dma_sync(dma_addr_t addr, size_t size, enum dma_data_direction dir)
48{
49 if (!__builtin_constant_p(dir)) {
50 __dma_sync(addr, size, dir);
51 return;
52 }
53
54 switch (dir) {
55 case DMA_NONE:
56 BUG();
57 case DMA_TO_DEVICE: /* writeback only */
58 flush_dcache_range(addr, addr + size);
59 break;
60 case DMA_FROM_DEVICE: /* invalidate only */
61 case DMA_BIDIRECTIONAL: /* flush and invalidate */
62 /* Blackfin has no dedicated invalidate (it includes a flush) */
63 invalidate_dcache_range(addr, addr + size);
64 break;
65 }
66}
67
24/* 68/*
25 * Map a single buffer of the indicated size for DMA in streaming mode. 69 * Map a single buffer of the indicated size for DMA in streaming mode.
26 * The 32-bit bus address to use is returned. 70 * The 32-bit bus address to use is returned.
@@ -28,8 +72,13 @@ int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
28 * Once the device is given the dma address, the device owns this memory 72 * 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. 73 * until either pci_unmap_single or pci_dma_sync_single is performed.
30 */ 74 */
31extern dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size, 75static inline dma_addr_t
32 enum dma_data_direction direction); 76dma_map_single(struct device *dev, void *ptr, size_t size,
77 enum dma_data_direction dir)
78{
79 _dma_sync((dma_addr_t)ptr, size, dir);
80 return (dma_addr_t) ptr;
81}
33 82
34static inline dma_addr_t 83static inline dma_addr_t
35dma_map_page(struct device *dev, struct page *page, 84dma_map_page(struct device *dev, struct page *page,
@@ -47,8 +96,12 @@ dma_map_page(struct device *dev, struct page *page,
47 * After this call, reads by the cpu to the buffer are guarenteed to see 96 * After this call, reads by the cpu to the buffer are guarenteed to see
48 * whatever the device wrote there. 97 * whatever the device wrote there.
49 */ 98 */
50extern void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, 99static inline void
51 enum dma_data_direction direction); 100dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
101 enum dma_data_direction dir)
102{
103 BUG_ON(!valid_dma_direction(dir));
104}
52 105
53static inline void 106static inline void
54dma_unmap_page(struct device *dev, dma_addr_t dma_addr, size_t size, 107dma_unmap_page(struct device *dev, dma_addr_t dma_addr, size_t size,
@@ -74,38 +127,66 @@ dma_unmap_page(struct device *dev, dma_addr_t dma_addr, size_t size,
74 * the same here. 127 * the same here.
75 */ 128 */
76extern int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, 129extern int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
77 enum dma_data_direction direction); 130 enum dma_data_direction dir);
78 131
79/* 132/*
80 * Unmap a set of streaming mode DMA translations. 133 * Unmap a set of streaming mode DMA translations.
81 * Again, cpu read rules concerning calls here are the same as for 134 * Again, cpu read rules concerning calls here are the same as for
82 * pci_unmap_single() above. 135 * pci_unmap_single() above.
83 */ 136 */
84extern void dma_unmap_sg(struct device *dev, struct scatterlist *sg, 137static inline void
85 int nhwentries, enum dma_data_direction direction); 138dma_unmap_sg(struct device *dev, struct scatterlist *sg,
139 int nhwentries, enum dma_data_direction dir)
140{
141 BUG_ON(!valid_dma_direction(dir));
142}
86 143
87static inline void dma_sync_single_for_cpu(struct device *dev, 144static inline void
88 dma_addr_t handle, size_t size, 145dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t handle,
89 enum dma_data_direction dir) 146 unsigned long offset, size_t size,
147 enum dma_data_direction dir)
90{ 148{
149 BUG_ON(!valid_dma_direction(dir));
91} 150}
92 151
93static inline void dma_sync_single_for_device(struct device *dev, 152static inline void
94 dma_addr_t handle, size_t size, 153dma_sync_single_range_for_device(struct device *dev, dma_addr_t handle,
95 enum dma_data_direction dir) 154 unsigned long offset, size_t size,
155 enum dma_data_direction dir)
96{ 156{
157 _dma_sync(handle + offset, size, dir);
97} 158}
98 159
99static inline void dma_sync_sg_for_cpu(struct device *dev, 160static inline void
100 struct scatterlist *sg, 161dma_sync_single_for_cpu(struct device *dev, dma_addr_t handle, size_t size,
101 int nents, enum dma_data_direction dir) 162 enum dma_data_direction dir)
102{ 163{
164 dma_sync_single_range_for_cpu(dev, handle, 0, size, dir);
103} 165}
104 166
105static inline void dma_sync_sg_for_device(struct device *dev, 167static inline void
106 struct scatterlist *sg, 168dma_sync_single_for_device(struct device *dev, dma_addr_t handle, size_t size,
107 int nents, enum dma_data_direction dir) 169 enum dma_data_direction dir)
170{
171 dma_sync_single_range_for_device(dev, handle, 0, size, dir);
172}
173
174static inline void
175dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nents,
176 enum dma_data_direction dir)
177{
178 BUG_ON(!valid_dma_direction(dir));
179}
180
181extern void
182dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
183 int nents, enum dma_data_direction dir);
184
185static inline void
186dma_cache_sync(struct device *dev, void *vaddr, size_t size,
187 enum dma_data_direction dir)
108{ 188{
189 _dma_sync((dma_addr_t)vaddr, size, dir);
109} 190}
110 191
111#endif /* _BLACKFIN_DMA_MAPPING_H */ 192#endif /* _BLACKFIN_DMA_MAPPING_H */