diff options
author | Magnus Damm <damm@igel.co.jp> | 2008-07-16 06:02:54 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2008-07-28 05:10:35 -0400 |
commit | 1eca5c92729a83f64826d15a9ecb1652dda54bcb (patch) | |
tree | 95753726159c945deccef68d4b54de9f4d5ec756 /arch/sh/mm | |
parent | 714750dd5c6aef8e204d35ba28c1be9641418671 (diff) |
sh: Add memory chunks to SH-Mobile UIO devices
This patch adds physically contiguous memory chunks to the UIO devices.
The same strategy can be used in the future for the CEU as well.
Signed-off-by: Magnus Damm <damm@igel.co.jp>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh/mm')
-rw-r--r-- | arch/sh/mm/consistent.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/arch/sh/mm/consistent.c b/arch/sh/mm/consistent.c index d3c33fc5b1c2..8277982d0938 100644 --- a/arch/sh/mm/consistent.c +++ b/arch/sh/mm/consistent.c | |||
@@ -10,6 +10,7 @@ | |||
10 | * for more details. | 10 | * for more details. |
11 | */ | 11 | */ |
12 | #include <linux/mm.h> | 12 | #include <linux/mm.h> |
13 | #include <linux/platform_device.h> | ||
13 | #include <linux/dma-mapping.h> | 14 | #include <linux/dma-mapping.h> |
14 | #include <asm/cacheflush.h> | 15 | #include <asm/cacheflush.h> |
15 | #include <asm/addrspace.h> | 16 | #include <asm/addrspace.h> |
@@ -185,3 +186,32 @@ void dma_cache_sync(struct device *dev, void *vaddr, size_t size, | |||
185 | } | 186 | } |
186 | } | 187 | } |
187 | EXPORT_SYMBOL(dma_cache_sync); | 188 | EXPORT_SYMBOL(dma_cache_sync); |
189 | |||
190 | int platform_resource_setup_memory(struct platform_device *pdev, | ||
191 | char *name, unsigned long memsize) | ||
192 | { | ||
193 | struct resource *r; | ||
194 | dma_addr_t dma_handle; | ||
195 | void *buf; | ||
196 | |||
197 | r = pdev->resource + pdev->num_resources - 1; | ||
198 | if (r->flags) { | ||
199 | pr_warning("%s: unable to find empty space for resource\n", | ||
200 | name); | ||
201 | return -EINVAL; | ||
202 | } | ||
203 | |||
204 | buf = dma_alloc_coherent(NULL, memsize, &dma_handle, GFP_KERNEL); | ||
205 | if (!buf) { | ||
206 | pr_warning("%s: unable to allocate memory\n", name); | ||
207 | return -ENOMEM; | ||
208 | } | ||
209 | |||
210 | memset(buf, 0, memsize); | ||
211 | |||
212 | r->flags = IORESOURCE_MEM; | ||
213 | r->start = dma_handle; | ||
214 | r->end = r->start + memsize - 1; | ||
215 | r->name = name; | ||
216 | return 0; | ||
217 | } | ||