diff options
author | Haavard Skinnemoen <hskinnemoen@atmel.com> | 2008-03-05 04:00:28 -0500 |
---|---|---|
committer | Haavard Skinnemoen <haavard.skinnemoen@atmel.com> | 2008-07-02 05:05:01 -0400 |
commit | b83d6ee17588f1a4fbfc8ef0451b0900a5ef5950 (patch) | |
tree | bde2ffd7f1ad14d8a6f15300a8e0d7b36224bbc9 | |
parent | 7951f188a0b7f9b2f181c692efb0d31082bec346 (diff) |
avr32: Add simple SRAM allocator
Add SRAM allocator for avr32, which is just a thin wrapper around
genalloc.
Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
-rw-r--r-- | arch/avr32/Kconfig | 1 | ||||
-rw-r--r-- | arch/avr32/mach-at32ap/at32ap700x.c | 26 | ||||
-rw-r--r-- | include/asm-avr32/arch-at32ap/sram.h | 30 |
3 files changed, 57 insertions, 0 deletions
diff --git a/arch/avr32/Kconfig b/arch/avr32/Kconfig index a5793c13f50c..e8ee5fa017b6 100644 --- a/arch/avr32/Kconfig +++ b/arch/avr32/Kconfig | |||
@@ -88,6 +88,7 @@ config PLATFORM_AT32AP | |||
88 | select MMU | 88 | select MMU |
89 | select PERFORMANCE_COUNTERS | 89 | select PERFORMANCE_COUNTERS |
90 | select HAVE_GPIO_LIB | 90 | select HAVE_GPIO_LIB |
91 | select GENERIC_ALLOCATOR | ||
91 | 92 | ||
92 | # | 93 | # |
93 | # CPU types | 94 | # CPU types |
diff --git a/arch/avr32/mach-at32ap/at32ap700x.c b/arch/avr32/mach-at32ap/at32ap700x.c index 3ee5e7278790..07b21b121eef 100644 --- a/arch/avr32/mach-at32ap/at32ap700x.c +++ b/arch/avr32/mach-at32ap/at32ap700x.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <asm/arch/at32ap700x.h> | 20 | #include <asm/arch/at32ap700x.h> |
21 | #include <asm/arch/board.h> | 21 | #include <asm/arch/board.h> |
22 | #include <asm/arch/portmux.h> | 22 | #include <asm/arch/portmux.h> |
23 | #include <asm/arch/sram.h> | ||
23 | 24 | ||
24 | #include <video/atmel_lcdc.h> | 25 | #include <video/atmel_lcdc.h> |
25 | 26 | ||
@@ -2120,3 +2121,28 @@ void __init setup_platform(void) | |||
2120 | at32_init_pio(&pio3_device); | 2121 | at32_init_pio(&pio3_device); |
2121 | at32_init_pio(&pio4_device); | 2122 | at32_init_pio(&pio4_device); |
2122 | } | 2123 | } |
2124 | |||
2125 | struct gen_pool *sram_pool; | ||
2126 | |||
2127 | static int __init sram_init(void) | ||
2128 | { | ||
2129 | struct gen_pool *pool; | ||
2130 | |||
2131 | /* 1KiB granularity */ | ||
2132 | pool = gen_pool_create(10, -1); | ||
2133 | if (!pool) | ||
2134 | goto fail; | ||
2135 | |||
2136 | if (gen_pool_add(pool, 0x24000000, 0x8000, -1)) | ||
2137 | goto err_pool_add; | ||
2138 | |||
2139 | sram_pool = pool; | ||
2140 | return 0; | ||
2141 | |||
2142 | err_pool_add: | ||
2143 | gen_pool_destroy(pool); | ||
2144 | fail: | ||
2145 | pr_err("Failed to create SRAM pool\n"); | ||
2146 | return -ENOMEM; | ||
2147 | } | ||
2148 | core_initcall(sram_init); | ||
diff --git a/include/asm-avr32/arch-at32ap/sram.h b/include/asm-avr32/arch-at32ap/sram.h new file mode 100644 index 000000000000..4838dae7601a --- /dev/null +++ b/include/asm-avr32/arch-at32ap/sram.h | |||
@@ -0,0 +1,30 @@ | |||
1 | /* | ||
2 | * Simple SRAM allocator | ||
3 | * | ||
4 | * Copyright (C) 2008 Atmel Corporation | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | */ | ||
10 | #ifndef __ASM_AVR32_ARCH_SRAM_H | ||
11 | #define __ASM_AVR32_ARCH_SRAM_H | ||
12 | |||
13 | #include <linux/genalloc.h> | ||
14 | |||
15 | extern struct gen_pool *sram_pool; | ||
16 | |||
17 | static inline unsigned long sram_alloc(size_t len) | ||
18 | { | ||
19 | if (!sram_pool) | ||
20 | return 0UL; | ||
21 | |||
22 | return gen_pool_alloc(sram_pool, len); | ||
23 | } | ||
24 | |||
25 | static inline void sram_free(unsigned long addr, size_t len) | ||
26 | { | ||
27 | return gen_pool_free(sram_pool, addr, len); | ||
28 | } | ||
29 | |||
30 | #endif /* __ASM_AVR32_ARCH_SRAM_H */ | ||