diff options
author | Barry Song <barry.song@analog.com> | 2009-11-22 22:47:24 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2009-12-15 00:16:01 -0500 |
commit | dd3b0e3e6a322184313e47e2fd5955ab113ad463 (patch) | |
tree | 224a3f1eae739b66ecfb65bc44dc7d9a482a0df3 /arch/blackfin/include | |
parent | a00b4fe5ce4b98f7c4457fffdb392d7bfece2e78 (diff) |
Blackfin: dma-mapping.h: flesh out missing DMA mapping functions
Signed-off-by: Barry Song <barry.song@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'arch/blackfin/include')
-rw-r--r-- | arch/blackfin/include/asm/dma-mapping.h | 121 | ||||
-rw-r--r-- | arch/blackfin/include/asm/dma.h | 5 |
2 files changed, 99 insertions, 27 deletions
diff --git a/arch/blackfin/include/asm/dma-mapping.h b/arch/blackfin/include/asm/dma-mapping.h index 7a23d824ac96..f9172ff30e5c 100644 --- a/arch/blackfin/include/asm/dma-mapping.h +++ b/arch/blackfin/include/asm/dma-mapping.h | |||
@@ -7,9 +7,9 @@ | |||
7 | #ifndef _BLACKFIN_DMA_MAPPING_H | 7 | #ifndef _BLACKFIN_DMA_MAPPING_H |
8 | #define _BLACKFIN_DMA_MAPPING_H | 8 | #define _BLACKFIN_DMA_MAPPING_H |
9 | 9 | ||
10 | #include <asm/scatterlist.h> | 10 | #include <asm/cacheflush.h> |
11 | struct scatterlist; | ||
11 | 12 | ||
12 | void dma_alloc_init(unsigned long start, unsigned long end); | ||
13 | void *dma_alloc_coherent(struct device *dev, size_t size, | 13 | void *dma_alloc_coherent(struct device *dev, size_t size, |
14 | dma_addr_t *dma_handle, gfp_t gfp); | 14 | dma_addr_t *dma_handle, gfp_t gfp); |
15 | void dma_free_coherent(struct device *dev, size_t size, void *vaddr, | 15 | void dma_free_coherent(struct device *dev, size_t size, void *vaddr, |
@@ -20,13 +20,51 @@ void dma_free_coherent(struct device *dev, size_t size, void *vaddr, | |||
20 | */ | 20 | */ |
21 | #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) |
22 | #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) | ||
23 | 26 | ||
24 | static inline | 27 | static inline int |
25 | int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) | 28 | dma_set_mask(struct device *dev, u64 dma_mask) |
26 | { | 29 | { |
30 | if (!dev->dma_mask || !dma_supported(dev, dma_mask)) | ||
31 | return -EIO; | ||
32 | |||
33 | *dev->dma_mask = dma_mask; | ||
34 | |||
27 | return 0; | 35 | return 0; |
28 | } | 36 | } |
29 | 37 | ||
38 | static inline int | ||
39 | dma_mapping_error(struct device *dev, dma_addr_t dma_addr) | ||
40 | { | ||
41 | return 0; | ||
42 | } | ||
43 | |||
44 | extern void | ||
45 | __dma_sync(dma_addr_t addr, size_t size, enum dma_data_direction dir); | ||
46 | static 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 | |||
30 | /* | 68 | /* |
31 | * 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. |
32 | * The 32-bit bus address to use is returned. | 70 | * The 32-bit bus address to use is returned. |
@@ -34,8 +72,13 @@ int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) | |||
34 | * 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 |
35 | * 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. |
36 | */ | 74 | */ |
37 | extern dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size, | 75 | static inline dma_addr_t |
38 | enum dma_data_direction direction); | 76 | dma_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 | } | ||
39 | 82 | ||
40 | static inline dma_addr_t | 83 | static inline dma_addr_t |
41 | dma_map_page(struct device *dev, struct page *page, | 84 | dma_map_page(struct device *dev, struct page *page, |
@@ -53,8 +96,12 @@ dma_map_page(struct device *dev, struct page *page, | |||
53 | * 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 |
54 | * whatever the device wrote there. | 97 | * whatever the device wrote there. |
55 | */ | 98 | */ |
56 | extern void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, | 99 | static inline void |
57 | enum dma_data_direction direction); | 100 | dma_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 | } | ||
58 | 105 | ||
59 | static inline void | 106 | static inline void |
60 | dma_unmap_page(struct device *dev, dma_addr_t dma_addr, size_t size, | 107 | dma_unmap_page(struct device *dev, dma_addr_t dma_addr, size_t size, |
@@ -80,38 +127,66 @@ dma_unmap_page(struct device *dev, dma_addr_t dma_addr, size_t size, | |||
80 | * the same here. | 127 | * the same here. |
81 | */ | 128 | */ |
82 | extern int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, | 129 | extern int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, |
83 | enum dma_data_direction direction); | 130 | enum dma_data_direction dir); |
84 | 131 | ||
85 | /* | 132 | /* |
86 | * Unmap a set of streaming mode DMA translations. | 133 | * Unmap a set of streaming mode DMA translations. |
87 | * 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 |
88 | * pci_unmap_single() above. | 135 | * pci_unmap_single() above. |
89 | */ | 136 | */ |
90 | extern void dma_unmap_sg(struct device *dev, struct scatterlist *sg, | 137 | static inline void |
91 | int nhwentries, enum dma_data_direction direction); | 138 | dma_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 | } | ||
92 | 143 | ||
93 | static inline void dma_sync_single_for_cpu(struct device *dev, | 144 | static inline void |
94 | dma_addr_t handle, size_t size, | 145 | dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t handle, |
95 | enum dma_data_direction dir) | 146 | unsigned long offset, size_t size, |
147 | enum dma_data_direction dir) | ||
96 | { | 148 | { |
149 | BUG_ON(!valid_dma_direction(dir)); | ||
97 | } | 150 | } |
98 | 151 | ||
99 | static inline void dma_sync_single_for_device(struct device *dev, | 152 | static inline void |
100 | dma_addr_t handle, size_t size, | 153 | dma_sync_single_range_for_device(struct device *dev, dma_addr_t handle, |
101 | enum dma_data_direction dir) | 154 | unsigned long offset, size_t size, |
155 | enum dma_data_direction dir) | ||
102 | { | 156 | { |
157 | _dma_sync(handle + offset, size, dir); | ||
103 | } | 158 | } |
104 | 159 | ||
105 | static inline void dma_sync_sg_for_cpu(struct device *dev, | 160 | static inline void |
106 | struct scatterlist *sg, | 161 | dma_sync_single_for_cpu(struct device *dev, dma_addr_t handle, size_t size, |
107 | int nents, enum dma_data_direction dir) | 162 | enum dma_data_direction dir) |
108 | { | 163 | { |
164 | dma_sync_single_range_for_cpu(dev, handle, 0, size, dir); | ||
109 | } | 165 | } |
110 | 166 | ||
111 | static inline void dma_sync_sg_for_device(struct device *dev, | 167 | static inline void |
112 | struct scatterlist *sg, | 168 | dma_sync_single_for_device(struct device *dev, dma_addr_t handle, size_t size, |
113 | 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 | |||
174 | static inline void | ||
175 | dma_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 | |||
181 | extern void | ||
182 | dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, | ||
183 | int nents, enum dma_data_direction dir); | ||
184 | |||
185 | static inline void | ||
186 | dma_cache_sync(struct device *dev, void *vaddr, size_t size, | ||
187 | enum dma_data_direction dir) | ||
114 | { | 188 | { |
189 | _dma_sync((dma_addr_t)vaddr, size, dir); | ||
115 | } | 190 | } |
116 | 191 | ||
117 | #endif /* _BLACKFIN_DMA_MAPPING_H */ | 192 | #endif /* _BLACKFIN_DMA_MAPPING_H */ |
diff --git a/arch/blackfin/include/asm/dma.h b/arch/blackfin/include/asm/dma.h index 5eb29502bbe4..bd2e62243abe 100644 --- a/arch/blackfin/include/asm/dma.h +++ b/arch/blackfin/include/asm/dma.h | |||
@@ -13,8 +13,7 @@ | |||
13 | #include <asm/atomic.h> | 13 | #include <asm/atomic.h> |
14 | #include <asm/blackfin.h> | 14 | #include <asm/blackfin.h> |
15 | #include <asm/page.h> | 15 | #include <asm/page.h> |
16 | 16 | #include <asm-generic/dma.h> | |
17 | #define MAX_DMA_ADDRESS PAGE_OFFSET | ||
18 | 17 | ||
19 | /* DMA_CONFIG Masks */ | 18 | /* DMA_CONFIG Masks */ |
20 | #define DMAEN 0x0001 /* DMA Channel Enable */ | 19 | #define DMAEN 0x0001 /* DMA Channel Enable */ |
@@ -257,8 +256,6 @@ static inline void enable_dma(unsigned int channel) | |||
257 | dma_ch[channel].regs->curr_y_count = 0; | 256 | dma_ch[channel].regs->curr_y_count = 0; |
258 | dma_ch[channel].regs->cfg |= DMAEN; | 257 | dma_ch[channel].regs->cfg |= DMAEN; |
259 | } | 258 | } |
260 | void free_dma(unsigned int channel); | ||
261 | int request_dma(unsigned int channel, const char *device_id); | ||
262 | int set_dma_callback(unsigned int channel, irq_handler_t callback, void *data); | 259 | int set_dma_callback(unsigned int channel, irq_handler_t callback, void *data); |
263 | 260 | ||
264 | static inline void dma_disable_irq(unsigned int channel) | 261 | static inline void dma_disable_irq(unsigned int channel) |