diff options
-rw-r--r-- | arch/arm/include/asm/tcm.h | 2 | ||||
-rw-r--r-- | arch/arm/kernel/tcm.c | 21 |
2 files changed, 20 insertions, 3 deletions
diff --git a/arch/arm/include/asm/tcm.h b/arch/arm/include/asm/tcm.h index 5929ef5d927..8578d726ad7 100644 --- a/arch/arm/include/asm/tcm.h +++ b/arch/arm/include/asm/tcm.h | |||
@@ -27,5 +27,7 @@ | |||
27 | 27 | ||
28 | void *tcm_alloc(size_t len); | 28 | void *tcm_alloc(size_t len); |
29 | void tcm_free(void *addr, size_t len); | 29 | void tcm_free(void *addr, size_t len); |
30 | bool tcm_dtcm_present(void); | ||
31 | bool tcm_itcm_present(void); | ||
30 | 32 | ||
31 | #endif | 33 | #endif |
diff --git a/arch/arm/kernel/tcm.c b/arch/arm/kernel/tcm.c index d402d482952..30e302d33e0 100644 --- a/arch/arm/kernel/tcm.c +++ b/arch/arm/kernel/tcm.c | |||
@@ -19,6 +19,8 @@ | |||
19 | #include "tcm.h" | 19 | #include "tcm.h" |
20 | 20 | ||
21 | static struct gen_pool *tcm_pool; | 21 | static struct gen_pool *tcm_pool; |
22 | static bool dtcm_present; | ||
23 | static bool itcm_present; | ||
22 | 24 | ||
23 | /* TCM section definitions from the linker */ | 25 | /* TCM section definitions from the linker */ |
24 | extern char __itcm_start, __sitcm_text, __eitcm_text; | 26 | extern char __itcm_start, __sitcm_text, __eitcm_text; |
@@ -90,6 +92,18 @@ void tcm_free(void *addr, size_t len) | |||
90 | } | 92 | } |
91 | EXPORT_SYMBOL(tcm_free); | 93 | EXPORT_SYMBOL(tcm_free); |
92 | 94 | ||
95 | bool tcm_dtcm_present(void) | ||
96 | { | ||
97 | return dtcm_present; | ||
98 | } | ||
99 | EXPORT_SYMBOL(tcm_dtcm_present); | ||
100 | |||
101 | bool tcm_itcm_present(void) | ||
102 | { | ||
103 | return itcm_present; | ||
104 | } | ||
105 | EXPORT_SYMBOL(tcm_itcm_present); | ||
106 | |||
93 | static int __init setup_tcm_bank(u8 type, u8 bank, u8 banks, | 107 | static int __init setup_tcm_bank(u8 type, u8 bank, u8 banks, |
94 | u32 *offset) | 108 | u32 *offset) |
95 | { | 109 | { |
@@ -208,6 +222,7 @@ void __init tcm_init(void) | |||
208 | memcpy(start, ram, dtcm_code_sz); | 222 | memcpy(start, ram, dtcm_code_sz); |
209 | pr_debug("CPU DTCM: copied data from %p - %p\n", | 223 | pr_debug("CPU DTCM: copied data from %p - %p\n", |
210 | start, end); | 224 | start, end); |
225 | dtcm_present = true; | ||
211 | } else if (dtcm_code_sz) { | 226 | } else if (dtcm_code_sz) { |
212 | pr_info("CPU DTCM: %u bytes of code compiled to DTCM but no " | 227 | pr_info("CPU DTCM: %u bytes of code compiled to DTCM but no " |
213 | "DTCM banks present in CPU\n", dtcm_code_sz); | 228 | "DTCM banks present in CPU\n", dtcm_code_sz); |
@@ -239,6 +254,7 @@ no_dtcm: | |||
239 | memcpy(start, ram, itcm_code_sz); | 254 | memcpy(start, ram, itcm_code_sz); |
240 | pr_debug("CPU ITCM: copied code from %p - %p\n", | 255 | pr_debug("CPU ITCM: copied code from %p - %p\n", |
241 | start, end); | 256 | start, end); |
257 | itcm_present = true; | ||
242 | } else if (itcm_code_sz) { | 258 | } else if (itcm_code_sz) { |
243 | pr_info("CPU ITCM: %u bytes of code compiled to ITCM but no " | 259 | pr_info("CPU ITCM: %u bytes of code compiled to ITCM but no " |
244 | "ITCM banks present in CPU\n", itcm_code_sz); | 260 | "ITCM banks present in CPU\n", itcm_code_sz); |
@@ -252,7 +268,6 @@ no_dtcm: | |||
252 | */ | 268 | */ |
253 | static int __init setup_tcm_pool(void) | 269 | static int __init setup_tcm_pool(void) |
254 | { | 270 | { |
255 | u32 tcm_status = read_cpuid_tcmstatus(); | ||
256 | u32 dtcm_pool_start = (u32) &__edtcm_data; | 271 | u32 dtcm_pool_start = (u32) &__edtcm_data; |
257 | u32 itcm_pool_start = (u32) &__eitcm_text; | 272 | u32 itcm_pool_start = (u32) &__eitcm_text; |
258 | int ret; | 273 | int ret; |
@@ -267,7 +282,7 @@ static int __init setup_tcm_pool(void) | |||
267 | pr_debug("Setting up TCM memory pool\n"); | 282 | pr_debug("Setting up TCM memory pool\n"); |
268 | 283 | ||
269 | /* Add the rest of DTCM to the TCM pool */ | 284 | /* Add the rest of DTCM to the TCM pool */ |
270 | if (tcm_status & (0x03 << 16)) { | 285 | if (dtcm_present) { |
271 | if (dtcm_pool_start < dtcm_end) { | 286 | if (dtcm_pool_start < dtcm_end) { |
272 | ret = gen_pool_add(tcm_pool, dtcm_pool_start, | 287 | ret = gen_pool_add(tcm_pool, dtcm_pool_start, |
273 | dtcm_end - dtcm_pool_start, -1); | 288 | dtcm_end - dtcm_pool_start, -1); |
@@ -284,7 +299,7 @@ static int __init setup_tcm_pool(void) | |||
284 | } | 299 | } |
285 | 300 | ||
286 | /* Add the rest of ITCM to the TCM pool */ | 301 | /* Add the rest of ITCM to the TCM pool */ |
287 | if (tcm_status & 0x03) { | 302 | if (itcm_present) { |
288 | if (itcm_pool_start < itcm_end) { | 303 | if (itcm_pool_start < itcm_end) { |
289 | ret = gen_pool_add(tcm_pool, itcm_pool_start, | 304 | ret = gen_pool_add(tcm_pool, itcm_pool_start, |
290 | itcm_end - itcm_pool_start, -1); | 305 | itcm_end - itcm_pool_start, -1); |