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/kernel/dma-mapping.c | |
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/kernel/dma-mapping.c')
-rw-r--r-- | arch/blackfin/kernel/dma-mapping.c | 54 |
1 files changed, 17 insertions, 37 deletions
diff --git a/arch/blackfin/kernel/dma-mapping.c b/arch/blackfin/kernel/dma-mapping.c index 755a0f4b61ae..e937f323d82c 100644 --- a/arch/blackfin/kernel/dma-mapping.c +++ b/arch/blackfin/kernel/dma-mapping.c | |||
@@ -7,17 +7,11 @@ | |||
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <linux/types.h> | 9 | #include <linux/types.h> |
10 | #include <linux/mm.h> | 10 | #include <linux/gfp.h> |
11 | #include <linux/string.h> | 11 | #include <linux/string.h> |
12 | #include <linux/bootmem.h> | ||
13 | #include <linux/spinlock.h> | 12 | #include <linux/spinlock.h> |
14 | #include <linux/device.h> | ||
15 | #include <linux/dma-mapping.h> | 13 | #include <linux/dma-mapping.h> |
16 | #include <linux/io.h> | ||
17 | #include <linux/scatterlist.h> | 14 | #include <linux/scatterlist.h> |
18 | #include <asm/cacheflush.h> | ||
19 | #include <asm/bfin-global.h> | ||
20 | #include <asm/sections.h> | ||
21 | 15 | ||
22 | static spinlock_t dma_page_lock; | 16 | static spinlock_t dma_page_lock; |
23 | static unsigned long *dma_page; | 17 | static unsigned long *dma_page; |
@@ -26,7 +20,7 @@ static unsigned long dma_base; | |||
26 | static unsigned long dma_size; | 20 | static unsigned long dma_size; |
27 | static unsigned int dma_initialized; | 21 | static unsigned int dma_initialized; |
28 | 22 | ||
29 | void dma_alloc_init(unsigned long start, unsigned long end) | 23 | static void dma_alloc_init(unsigned long start, unsigned long end) |
30 | { | 24 | { |
31 | spin_lock_init(&dma_page_lock); | 25 | spin_lock_init(&dma_page_lock); |
32 | dma_initialized = 0; | 26 | dma_initialized = 0; |
@@ -93,7 +87,7 @@ static void __free_dma_pages(unsigned long addr, unsigned int pages) | |||
93 | } | 87 | } |
94 | 88 | ||
95 | void *dma_alloc_coherent(struct device *dev, size_t size, | 89 | void *dma_alloc_coherent(struct device *dev, size_t size, |
96 | dma_addr_t * dma_handle, gfp_t gfp) | 90 | dma_addr_t *dma_handle, gfp_t gfp) |
97 | { | 91 | { |
98 | void *ret; | 92 | void *ret; |
99 | 93 | ||
@@ -117,21 +111,14 @@ dma_free_coherent(struct device *dev, size_t size, void *vaddr, | |||
117 | EXPORT_SYMBOL(dma_free_coherent); | 111 | EXPORT_SYMBOL(dma_free_coherent); |
118 | 112 | ||
119 | /* | 113 | /* |
120 | * Dummy functions defined for some existing drivers | 114 | * Streaming DMA mappings |
121 | */ | 115 | */ |
122 | 116 | void __dma_sync(dma_addr_t addr, size_t size, | |
123 | dma_addr_t | 117 | enum dma_data_direction dir) |
124 | dma_map_single(struct device *dev, void *ptr, size_t size, | ||
125 | enum dma_data_direction direction) | ||
126 | { | 118 | { |
127 | BUG_ON(direction == DMA_NONE); | 119 | _dma_sync(addr, size, dir); |
128 | |||
129 | invalidate_dcache_range((unsigned long)ptr, | ||
130 | (unsigned long)ptr + size); | ||
131 | |||
132 | return (dma_addr_t) ptr; | ||
133 | } | 120 | } |
134 | EXPORT_SYMBOL(dma_map_single); | 121 | EXPORT_SYMBOL(__dma_sync); |
135 | 122 | ||
136 | int | 123 | int |
137 | dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, | 124 | dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, |
@@ -139,30 +126,23 @@ dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, | |||
139 | { | 126 | { |
140 | int i; | 127 | int i; |
141 | 128 | ||
142 | BUG_ON(direction == DMA_NONE); | ||
143 | |||
144 | for (i = 0; i < nents; i++, sg++) { | 129 | for (i = 0; i < nents; i++, sg++) { |
145 | sg->dma_address = (dma_addr_t) sg_virt(sg); | 130 | sg->dma_address = (dma_addr_t) sg_virt(sg); |
146 | 131 | __dma_sync(sg_dma_address(sg), sg_dma_len(sg), direction); | |
147 | invalidate_dcache_range(sg_dma_address(sg), | ||
148 | sg_dma_address(sg) + | ||
149 | sg_dma_len(sg)); | ||
150 | } | 132 | } |
151 | 133 | ||
152 | return nents; | 134 | return nents; |
153 | } | 135 | } |
154 | EXPORT_SYMBOL(dma_map_sg); | 136 | EXPORT_SYMBOL(dma_map_sg); |
155 | 137 | ||
156 | void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, | 138 | void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, |
157 | enum dma_data_direction direction) | 139 | int nelems, enum dma_data_direction direction) |
158 | { | 140 | { |
159 | BUG_ON(direction == DMA_NONE); | 141 | int i; |
160 | } | ||
161 | EXPORT_SYMBOL(dma_unmap_single); | ||
162 | 142 | ||
163 | void dma_unmap_sg(struct device *dev, struct scatterlist *sg, | 143 | for (i = 0; i < nelems; i++, sg++) { |
164 | int nhwentries, enum dma_data_direction direction) | 144 | sg->dma_address = (dma_addr_t) sg_virt(sg); |
165 | { | 145 | __dma_sync(sg_dma_address(sg), sg_dma_len(sg), direction); |
166 | BUG_ON(direction == DMA_NONE); | 146 | } |
167 | } | 147 | } |
168 | EXPORT_SYMBOL(dma_unmap_sg); | 148 | EXPORT_SYMBOL(dma_sync_sg_for_device); |