mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 2/2] arm: make disabling the cache actually work
Date: Fri, 22 Jan 2010 16:14:35 +0100	[thread overview]
Message-ID: <1264173275-1858-2-git-send-email-u.kleine-koenig@pengutronix.de> (raw)
In-Reply-To: <20100122150628.GA12856@pengutronix.de>

The code before looks to me like work in progress.  It only drained the
write buffer and skipped disabling mmu and caches by an early return
from inline assembler (which is broken in itself as it doesn't restore
frame pointer, stack pointer and other saved registers).

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 arch/arm/cpu/mmu.c |   29 ++++++++++++++++++++++++++++-
 1 files changed, 28 insertions(+), 1 deletions(-)

diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c
index 9e00927..95b8302 100644
--- a/arch/arm/cpu/mmu.c
+++ b/arch/arm/cpu/mmu.c
@@ -54,7 +54,7 @@ void mmu_enable(void)
 {
 	asm volatile (
 		"mrc p15, 0, r1, c1, c0, 0;"
-		"orr r1, r1, #0x0007;"  /* enable MMU + Dcache */
+		"orr r1, r1, #0x0007;"  /* enable MMU + Dcache + alignment fault checking */
 		"mcr p15, 0, r1, c1, c0, 0"
 		:
 		:
@@ -67,6 +67,30 @@ void mmu_enable(void)
  */
 void mmu_disable(void)
 {
+#if defined(CONFIG_CPU_ARM926T)
+	unsigned int tmp = 0;
+	asm volatile (
+		/* test, clean and invalidate D cache */
+		"1:	mrc	p15, 0, r15, c7, c14, 3\n"
+		"	bne	1b\n"
+		/* invalidate I cache (Rd SBZ) */
+		"	mcr	p15, 0, %1, c7, c5, 0\n"
+		/* drain write buffer (Rd SBZ) */
+		"	mcr	p15, 0, %1, c7, c10, 4\n"
+
+		/* read control register */
+		"	mrc	p15, 0, %0, c1, c0\n"
+		/* clear C and M */
+		"	bic	%0, %0, #0x0005\n"
+		/* write back control register */
+		"	mcr	p15, 0, %0, c1, c0\n"
+
+		/* invalidate TLBs (Rd SBZ) */
+		"	mcr p15, 0, %1, c8, c7, 0;"
+		: "=&r" (tmp) : "r" (tmp) : "cc" );
+
+#else
+	/* ??? */
 	asm volatile (
 		"nop; "
 		"nop; "
@@ -75,9 +99,11 @@ void mmu_disable(void)
 		"nop; "
 		"nop; "
 		/* test, clean and invalidate cache */
+		/* mrc     p15, 0, $rd, c7, c14, 3; is armv5tej specific */
 		"1:	mrc	p15, 0, r15, c7, c14, 3;" 
 		"	bne	1b;"
 		"	mov	pc, lr;"
+		/* the following code is never reached */
 		"	mov r0, #0x0;"
 		"	mcr p15, 0, r0, c7, c10, 4;" /* drain the write buffer   */
 		"	mcr p15, 0, r1, c7, c6, 0;"  /* clear data cache         */
@@ -90,6 +116,7 @@ void mmu_disable(void)
 		:
 		: "r0" /* Clobber list */
 	);
+#endif
 }
 
 /*
-- 
1.6.6


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      parent reply	other threads:[~2010-01-22 15:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-22 15:06 [PATCH] arm cache fixes Uwe Kleine-König
2010-01-22 15:14 ` [PATCH 1/2] give nice output when generating barebox.bin and barebox.S Uwe Kleine-König
2010-03-12  9:51   ` [PATCH] " Uwe Kleine-König
2010-01-22 15:14 ` Uwe Kleine-König [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1264173275-1858-2-git-send-email-u.kleine-koenig@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox