public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Gregory CLEMENT <gregory.clement@bootlin.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 2/7] MIPS: Allow to prefetch and lock instructions into cache
Date: Wed,  5 Dec 2018 18:10:49 +0100	[thread overview]
Message-ID: <20181205171054.926-3-gregory.clement@bootlin.com> (raw)
In-Reply-To: <20181205171054.926-1-gregory.clement@bootlin.com>

This path add a new helper allowing to prefetch and lock instructions
into cache. This is useful very early in the boot when no RAM is
available yet.

Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
---
 arch/mips/include/asm/cacheops.h | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/arch/mips/include/asm/cacheops.h b/arch/mips/include/asm/cacheops.h
index 3161875441..98b67ccc8e 100644
--- a/arch/mips/include/asm/cacheops.h
+++ b/arch/mips/include/asm/cacheops.h
@@ -19,6 +19,25 @@ static inline void mips_cache(int op, const volatile void *addr)
 #endif
 }
 
+#define MIPS32_WHICH_ICACHE                    0x0
+#define MIPS32_FETCH_AND_LOCK                  0x7
+
+#define ICACHE_LOAD_LOCK (MIPS32_WHICH_ICACHE | (MIPS32_FETCH_AND_LOCK << 2))
+
+/* Prefetch and lock instructions into cache */
+static inline void icache_lock(void *func, size_t len)
+{
+	int i, lines = ((len - 1) / ARCH_DMA_MINALIGN) + 1;
+
+	for (i = 0; i < lines; i++) {
+		asm volatile (" cache %0, %1(%2)"
+			      : /* No Output */
+			      : "I" ICACHE_LOAD_LOCK,
+				"n" (i * ARCH_DMA_MINALIGN),
+				"r" (func)
+			      : /* No Clobbers */);
+	}
+}
 #endif /* !__ASSEMBLY__ */
 
 /*
-- 
2.19.2

  parent reply	other threads:[~2018-12-05 17:10 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-05 17:10 [U-Boot] [PATCH v3 0/7] ] Add support for the SoCs found in Microsemi switches Gregory CLEMENT
2018-12-05 17:10 ` [U-Boot] [PATCH v3 1/7] MIPS: move create_tlb() in an proper header: mipsregs.h Gregory CLEMENT
2018-12-05 17:10 ` Gregory CLEMENT [this message]
2018-12-05 17:10 ` [U-Boot] [PATCH v3 3/7] MSCC: add support for Ocelot SoCs Gregory CLEMENT
2018-12-10 16:57   ` Daniel Schwierzeck
2018-12-13 14:05     ` Gregory CLEMENT
2018-12-13 14:55       ` Daniel Schwierzeck
2018-12-05 17:10 ` [U-Boot] [PATCH v3 4/7] MSCC: add support for Luton SoCs Gregory CLEMENT
2018-12-10 17:03   ` Daniel Schwierzeck
2018-12-13 14:29     ` Gregory CLEMENT
2018-12-05 17:10 ` [U-Boot] [PATCH v3 5/7] MSCC: add board support for the Ocelots based evaluation boards Gregory CLEMENT
2018-12-10 17:17   ` Daniel Schwierzeck
2018-12-13 14:43     ` Gregory CLEMENT
2018-12-05 17:10 ` [U-Boot] [PATCH v3 6/7] MSCC: add board support for the Luton based evaluation board Gregory CLEMENT
2018-12-05 17:10 ` [U-Boot] [PATCH v3 7/7] MIPS: bootm: Add support for Vcore III linux kernel Gregory CLEMENT
2018-12-10 17:30   ` Daniel Schwierzeck
2018-12-14 10:43     ` Gregory CLEMENT

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=20181205171054.926-3-gregory.clement@bootlin.com \
    --to=gregory.clement@bootlin.com \
    --cc=u-boot@lists.denx.de \
    /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