* [PATCH 1/2] ARM: only look for TCM on ARM926 and later
@ 2011-12-07 22:40 Linus Walleij
2011-12-11 10:23 ` Russell King - ARM Linux
0 siblings, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2011-12-07 22:40 UTC (permalink / raw)
To: linux-arm-kernel
The Integrator AP/CP can have a varying set of core modules, some
(like ARM920T) are so old that trying to read the TCM status register
with CP15 will make them hang. So we need to make sure that we are
running on 926 or later in order to be able to activate this for
the Integrator. (The Integrator with CM926EJ-S has 32+32 kb of TCM
memory.)
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
arch/arm/kernel/tcm.c | 19 ++++++++++++++++---
1 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/arch/arm/kernel/tcm.c b/arch/arm/kernel/tcm.c
index 30e302d..700c876 100644
--- a/arch/arm/kernel/tcm.c
+++ b/arch/arm/kernel/tcm.c
@@ -180,9 +180,10 @@ static int __init setup_tcm_bank(u8 type, u8 bank, u8 banks,
*/
void __init tcm_init(void)
{
- u32 tcm_status = read_cpuid_tcmstatus();
- u8 dtcm_banks = (tcm_status >> 16) & 0x03;
- u8 itcm_banks = (tcm_status & 0x03);
+ u32 cpuid = read_cpuid_id();
+ u32 tcm_status;
+ u8 dtcm_banks;
+ u8 itcm_banks;
size_t dtcm_code_sz = &__edtcm_data - &__sdtcm_data;
size_t itcm_code_sz = &__eitcm_text - &__sitcm_text;
char *start;
@@ -191,6 +192,18 @@ void __init tcm_init(void)
int ret;
int i;
+ /*
+ * Prior to ARM926 there is no TCM, and trying to read the status
+ * register will hang the processor.
+ */
+ if (((cpuid & 0x0008f000) == 0x00000000) &&
+ ((cpuid >> 4) < 0x926))
+ return;
+
+ tcm_status = read_cpuid_tcmstatus();
+ dtcm_banks = (tcm_status >> 16) & 0x03;
+ itcm_banks = (tcm_status & 0x03);
+
/* Values greater than 2 for D/ITCM banks are "reserved" */
if (dtcm_banks > 2)
dtcm_banks = 0;
--
1.7.6.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 1/2] ARM: only look for TCM on ARM926 and later
2011-12-07 22:40 [PATCH 1/2] ARM: only look for TCM on ARM926 and later Linus Walleij
@ 2011-12-11 10:23 ` Russell King - ARM Linux
2011-12-12 8:22 ` Linus Walleij
0 siblings, 1 reply; 4+ messages in thread
From: Russell King - ARM Linux @ 2011-12-11 10:23 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Dec 07, 2011 at 11:40:16PM +0100, Linus Walleij wrote:
> + u32 cpuid = read_cpuid_id();
...
> + /*
> + * Prior to ARM926 there is no TCM, and trying to read the status
> + * register will hang the processor.
> + */
> + if (((cpuid & 0x0008f000) == 0x00000000) &&
> + ((cpuid >> 4) < 0x926))
> + return;
This doesn't look correct. The CPU ID register for an ARM920T is
0x41X2920X, which will fail both the first and second tests. The first
fails because of the 0x????9???, and the second fails because of the
non-zero vendor, revision and architecture IDs.
Also, what if the CPU is not an ARM CPU? Part numbers are dependent
on the vendor field.
Maybe we want to change to a different approach - rule out all
architectures prior to ARMv5 (which will include ARM920T etc). I think
it is a safe assumption to make that anything older than ARMv5 will not
have TCM.
if (cpu_architecture() < CPU_ARCH_ARMv5)
return;
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] ARM: only look for TCM on ARM926 and later
2011-12-11 10:23 ` Russell King - ARM Linux
@ 2011-12-12 8:22 ` Linus Walleij
2011-12-12 8:25 ` Linus Walleij
0 siblings, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2011-12-12 8:22 UTC (permalink / raw)
To: linux-arm-kernel
On Sun, Dec 11, 2011 at 11:23 AM, Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:
> Maybe we want to change to a different approach - rule out all
> architectures prior to ARMv5 (which will include ARM920T etc). ?I think
> it is a safe assumption to make that anything older than ARMv5 will not
> have TCM.
>
> ? ? ? ?if (cpu_architecture() < CPU_ARCH_ARMv5)
> ? ? ? ? ? ? ? ?return;
Yes this is way better, thanks Russell!
I've rewritten it like this and I'll replace the patch in the patch tracker
ASAP:
>From 5da56ebc51d4116fe6dbdbff770c31b52e01b9d4 Mon Sep 17 00:00:00 2001
From: Linus Walleij <linus.walleij@linaro.org>
Date: Wed, 7 Dec 2011 23:40:16 +0100
Subject: [PATCH] ARM: only look for TCM on ARM926 and later
The Integrator AP/CP can have a varying set of core modules, some
(like ARM920T) are so old that trying to read the TCM status register
with CP15 will make them hang. So we need to make sure that we are
running on 926 or later in order to be able to activate this for
the Integrator. (The Integrator with CM926EJ-S has 32+32 kb of TCM
memory.)
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
arch/arm/kernel/tcm.c | 22 +++++++++++++++++++---
1 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/arch/arm/kernel/tcm.c b/arch/arm/kernel/tcm.c
index 30e302d..01ec453 100644
--- a/arch/arm/kernel/tcm.c
+++ b/arch/arm/kernel/tcm.c
@@ -180,9 +180,9 @@ static int __init setup_tcm_bank(u8 type, u8 bank, u8 banks,
*/
void __init tcm_init(void)
{
- u32 tcm_status = read_cpuid_tcmstatus();
- u8 dtcm_banks = (tcm_status >> 16) & 0x03;
- u8 itcm_banks = (tcm_status & 0x03);
+ u32 tcm_status;
+ u8 dtcm_banks;
+ u8 itcm_banks;
size_t dtcm_code_sz = &__edtcm_data - &__sdtcm_data;
size_t itcm_code_sz = &__eitcm_text - &__sitcm_text;
char *start;
@@ -191,6 +191,22 @@ void __init tcm_init(void)
int ret;
int i;
+ /*
+ * Prior to ARMv5 there is no TCM, and trying to read the status
+ * register will hang the processor.
+ */
+ if (cpu_architecture() < CPU_ARCH_ARMv5) {
+ if (dtcm_code_sz || itcm_code_sz)
+ pr_info("CPU TCM: %u bytes of DTCM and %u bytes of "
+ "ITCM code compiled in, but no TCM present "
+ "in pre-v5 CPU\n", dtcm_code_sz, itcm_code_sz);
+ return;
+ }
+
+ tcm_status = read_cpuid_tcmstatus();
+ dtcm_banks = (tcm_status >> 16) & 0x03;
+ itcm_banks = (tcm_status & 0x03);
+
/* Values greater than 2 for D/ITCM banks are "reserved" */
if (dtcm_banks > 2)
dtcm_banks = 0;
--
1.7.3.2
Yours,
Linus Walleij
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 1/2] ARM: only look for TCM on ARM926 and later
2011-12-12 8:22 ` Linus Walleij
@ 2011-12-12 8:25 ` Linus Walleij
0 siblings, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2011-12-12 8:25 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Dec 12, 2011 at 9:22 AM, Linus Walleij <linus.walleij@linaro.org> wrote:
> Subject: [PATCH] ARM: only look for TCM on ARM926 and later
(...)
> running on 926 or later in order to be able to activate this for
I'll replace the above inctances of 926 with v5 too...
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-12-12 8:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-07 22:40 [PATCH 1/2] ARM: only look for TCM on ARM926 and later Linus Walleij
2011-12-11 10:23 ` Russell King - ARM Linux
2011-12-12 8:22 ` Linus Walleij
2011-12-12 8:25 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).