aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-davinci/sram.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-davinci/sram.c')
-rw-r--r--arch/arm/mach-davinci/sram.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/arch/arm/mach-davinci/sram.c b/arch/arm/mach-davinci/sram.c
index db0f7787faf1..c5f7ee5cc80a 100644
--- a/arch/arm/mach-davinci/sram.c
+++ b/arch/arm/mach-davinci/sram.c
@@ -10,6 +10,7 @@
10 */ 10 */
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/io.h>
13#include <linux/genalloc.h> 14#include <linux/genalloc.h>
14 15
15#include <mach/common.h> 16#include <mach/common.h>
@@ -17,6 +18,11 @@
17 18
18static struct gen_pool *sram_pool; 19static struct gen_pool *sram_pool;
19 20
21struct gen_pool *sram_get_gen_pool(void)
22{
23 return sram_pool;
24}
25
20void *sram_alloc(size_t len, dma_addr_t *dma) 26void *sram_alloc(size_t len, dma_addr_t *dma)
21{ 27{
22 unsigned long vaddr; 28 unsigned long vaddr;
@@ -32,7 +38,7 @@ void *sram_alloc(size_t len, dma_addr_t *dma)
32 return NULL; 38 return NULL;
33 39
34 if (dma) 40 if (dma)
35 *dma = dma_base + (vaddr - SRAM_VIRT); 41 *dma = gen_pool_virt_to_phys(sram_pool, vaddr);
36 return (void *)vaddr; 42 return (void *)vaddr;
37 43
38} 44}
@@ -53,8 +59,10 @@ EXPORT_SYMBOL(sram_free);
53 */ 59 */
54static int __init sram_init(void) 60static int __init sram_init(void)
55{ 61{
62 phys_addr_t phys = davinci_soc_info.sram_dma;
56 unsigned len = davinci_soc_info.sram_len; 63 unsigned len = davinci_soc_info.sram_len;
57 int status = 0; 64 int status = 0;
65 void *addr;
58 66
59 if (len) { 67 if (len) {
60 len = min_t(unsigned, len, SRAM_SIZE); 68 len = min_t(unsigned, len, SRAM_SIZE);
@@ -62,8 +70,17 @@ static int __init sram_init(void)
62 if (!sram_pool) 70 if (!sram_pool)
63 status = -ENOMEM; 71 status = -ENOMEM;
64 } 72 }
65 if (sram_pool) 73
66 status = gen_pool_add(sram_pool, SRAM_VIRT, len, -1); 74 if (sram_pool) {
75 addr = ioremap(phys, len);
76 if (!addr)
77 return -ENOMEM;
78 status = gen_pool_add_virt(sram_pool, (unsigned)addr,
79 phys, len, -1);
80 if (status < 0)
81 iounmap(addr);
82 }
83
67 WARN_ON(status < 0); 84 WARN_ON(status < 0);
68 return status; 85 return status;
69} 86}