diff options
author | Paul Mundt <lethal@linux-sh.org> | 2010-10-14 13:09:00 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2010-10-14 13:09:00 -0400 |
commit | c993487ec87ba6d9ea47b03dad562123d503f4a2 (patch) | |
tree | b7e9332b6fbbb8bf105b7db8e79bc0e1d6f55033 /arch/sh | |
parent | b6b77b2d5ffd2f8ee74fcc27661f7f4962c34705 (diff) |
sh: Provide a generic SRAM pool for tiny memories.
This sets up a generic SRAM pool for CPUs and platform code to insert
their otherwise unused memories into. A simple alloc/free interface is
provided (lifed from avr32) for generic code.
This only applies to tiny SRAMs that are otherwise unmanaged, and does
not take in to account the more complex SRAMs sitting behind transfer
engines, or that employ an I/D split.
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh')
-rw-r--r-- | arch/sh/include/asm/sram.h | 38 | ||||
-rw-r--r-- | arch/sh/mm/Kconfig | 4 | ||||
-rw-r--r-- | arch/sh/mm/Makefile | 1 | ||||
-rw-r--r-- | arch/sh/mm/sram.c | 34 |
4 files changed, 77 insertions, 0 deletions
diff --git a/arch/sh/include/asm/sram.h b/arch/sh/include/asm/sram.h new file mode 100644 index 000000000000..a2808ce4c0aa --- /dev/null +++ b/arch/sh/include/asm/sram.h | |||
@@ -0,0 +1,38 @@ | |||
1 | #ifndef __ASM_SRAM_H | ||
2 | #define __ASM_SRAM_H | ||
3 | |||
4 | #ifdef CONFIG_HAVE_SRAM_POOL | ||
5 | |||
6 | #include <linux/spinlock.h> | ||
7 | #include <linux/genalloc.h> | ||
8 | |||
9 | /* arch/sh/mm/sram.c */ | ||
10 | extern struct gen_pool *sram_pool; | ||
11 | |||
12 | static inline unsigned long sram_alloc(size_t len) | ||
13 | { | ||
14 | if (!sram_pool) | ||
15 | return 0UL; | ||
16 | |||
17 | return gen_pool_alloc(sram_pool, len); | ||
18 | } | ||
19 | |||
20 | static inline void sram_free(unsigned long addr, size_t len) | ||
21 | { | ||
22 | return gen_pool_free(sram_pool, addr, len); | ||
23 | } | ||
24 | |||
25 | #else | ||
26 | |||
27 | static inline unsigned long sram_alloc(size_t len) | ||
28 | { | ||
29 | return 0; | ||
30 | } | ||
31 | |||
32 | static inline void sram_free(unsigned long addr, size_t len) | ||
33 | { | ||
34 | } | ||
35 | |||
36 | #endif /* CONFIG_HAVE_SRAM_POOL */ | ||
37 | |||
38 | #endif /* __ASM_SRAM_H */ | ||
diff --git a/arch/sh/mm/Kconfig b/arch/sh/mm/Kconfig index 1445ca6257df..09370392aff1 100644 --- a/arch/sh/mm/Kconfig +++ b/arch/sh/mm/Kconfig | |||
@@ -168,6 +168,10 @@ config IOREMAP_FIXED | |||
168 | config UNCACHED_MAPPING | 168 | config UNCACHED_MAPPING |
169 | bool | 169 | bool |
170 | 170 | ||
171 | config HAVE_SRAM_POOL | ||
172 | bool | ||
173 | select GENERIC_ALLOCATOR | ||
174 | |||
171 | choice | 175 | choice |
172 | prompt "Kernel page size" | 176 | prompt "Kernel page size" |
173 | default PAGE_SIZE_4KB | 177 | default PAGE_SIZE_4KB |
diff --git a/arch/sh/mm/Makefile b/arch/sh/mm/Makefile index 939663c55911..ab89ea4f9414 100644 --- a/arch/sh/mm/Makefile +++ b/arch/sh/mm/Makefile | |||
@@ -40,6 +40,7 @@ obj-$(CONFIG_PMB) += pmb.o | |||
40 | obj-$(CONFIG_NUMA) += numa.o | 40 | obj-$(CONFIG_NUMA) += numa.o |
41 | obj-$(CONFIG_IOREMAP_FIXED) += ioremap_fixed.o | 41 | obj-$(CONFIG_IOREMAP_FIXED) += ioremap_fixed.o |
42 | obj-$(CONFIG_UNCACHED_MAPPING) += uncached.o | 42 | obj-$(CONFIG_UNCACHED_MAPPING) += uncached.o |
43 | obj-$(CONFIG_HAVE_SRAM_POOL) += sram.o | ||
43 | 44 | ||
44 | # Special flags for fault_64.o. This puts restrictions on the number of | 45 | # Special flags for fault_64.o. This puts restrictions on the number of |
45 | # caller-save registers that the compiler can target when building this file. | 46 | # caller-save registers that the compiler can target when building this file. |
diff --git a/arch/sh/mm/sram.c b/arch/sh/mm/sram.c new file mode 100644 index 000000000000..bc156ec4545e --- /dev/null +++ b/arch/sh/mm/sram.c | |||
@@ -0,0 +1,34 @@ | |||
1 | /* | ||
2 | * SRAM pool for tiny memories not otherwise managed. | ||
3 | * | ||
4 | * Copyright (C) 2010 Paul Mundt | ||
5 | * | ||
6 | * This file is subject to the terms and conditions of the GNU General Public | ||
7 | * License. See the file "COPYING" in the main directory of this archive | ||
8 | * for more details. | ||
9 | */ | ||
10 | #include <linux/init.h> | ||
11 | #include <linux/kernel.h> | ||
12 | #include <asm/sram.h> | ||
13 | |||
14 | /* | ||
15 | * This provides a standard SRAM pool for tiny memories that can be | ||
16 | * added either by the CPU or the platform code. Typical SRAM sizes | ||
17 | * to be inserted in to the pool will generally be less than the page | ||
18 | * size, with anything more reasonably sized handled as a NUMA memory | ||
19 | * node. | ||
20 | */ | ||
21 | struct gen_pool *sram_pool; | ||
22 | |||
23 | static int __init sram_pool_init(void) | ||
24 | { | ||
25 | /* | ||
26 | * This is a global pool, we don't care about node locality. | ||
27 | */ | ||
28 | sram_pool = gen_pool_create(1, -1); | ||
29 | if (unlikely(!sram_pool)) | ||
30 | return -ENOMEM; | ||
31 | |||
32 | return 0; | ||
33 | } | ||
34 | core_initcall(sram_pool_init); | ||