mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 07/17] ARM: Add get_cr/set_cr functions
Date: Thu, 29 Apr 2010 09:52:05 +0200	[thread overview]
Message-ID: <1272527535-17527-8-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1272527535-17527-1-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/include/asm/system.h |   72 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 72 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/include/asm/system.h

diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h
new file mode 100644
index 0000000..77d6305
--- /dev/null
+++ b/arch/arm/include/asm/system.h
@@ -0,0 +1,72 @@
+#ifndef __ASM_ARM_SYSTEM_H
+#define __ASM_ARM_SYSTEM_H
+
+#if __LINUX_ARM_ARCH__ >= 7
+#define isb() __asm__ __volatile__ ("isb" : : : "memory")
+#define dsb() __asm__ __volatile__ ("dsb" : : : "memory")
+#define dmb() __asm__ __volatile__ ("dmb" : : : "memory")
+#elif defined(CONFIG_CPU_XSC3) || __LINUX_ARM_ARCH__ == 6
+#define isb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c5, 4" \
+                                    : : "r" (0) : "memory")
+#define dsb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 4" \
+                                    : : "r" (0) : "memory")
+#define dmb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" \
+                                    : : "r" (0) : "memory")
+#elif defined(CONFIG_CPU_FA526)
+#define isb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c5, 4" \
+                                    : : "r" (0) : "memory")
+#define dsb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 4" \
+                                    : : "r" (0) : "memory")
+#define dmb() __asm__ __volatile__ ("" : : : "memory")
+#else
+#define isb() __asm__ __volatile__ ("" : : : "memory")
+#define dsb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 4" \
+                                    : : "r" (0) : "memory")
+#define dmb() __asm__ __volatile__ ("" : : : "memory")
+#endif
+
+/*
+ * CR1 bits (CP#15 CR1)
+ */
+#define CR_M    (1 << 0)	/* MMU enable				*/
+#define CR_A    (1 << 1)	/* Alignment abort enable		*/
+#define CR_C    (1 << 2)	/* Dcache enable			*/
+#define CR_W    (1 << 3)	/* Write buffer enable			*/
+#define CR_P    (1 << 4)	/* 32-bit exception handler		*/
+#define CR_D    (1 << 5)	/* 32-bit data address range		*/
+#define CR_L    (1 << 6)	/* Implementation defined		*/
+#define CR_B    (1 << 7)	/* Big endian				*/
+#define CR_S    (1 << 8)	/* System MMU protection		*/
+#define CR_R    (1 << 9)	/* ROM MMU protection			*/
+#define CR_F    (1 << 10)	/* Implementation defined		*/
+#define CR_Z    (1 << 11)	/* Implementation defined		*/
+#define CR_I    (1 << 12)	/* Icache enable			*/
+#define CR_V    (1 << 13)	/* Vectors relocated to 0xffff0000	*/
+#define CR_RR   (1 << 14)	/* Round Robin cache replacement	*/
+#define CR_L4   (1 << 15)	/* LDR pc can set T bit			*/
+#define CR_DT   (1 << 16)
+#define CR_IT   (1 << 18)
+#define CR_ST   (1 << 19)
+#define CR_FI   (1 << 21)	/* Fast interrupt (lower latency mode)	*/
+#define CR_U    (1 << 22)	/* Unaligned access operation		*/
+#define CR_XP   (1 << 23)	/* Extended page tables			*/
+#define CR_VE   (1 << 24)	/* Vectored interrupts			*/
+#define CR_EE   (1 << 25)	/* Exception (Big) Endian		*/
+#define CR_TRE  (1 << 28)	/* TEX remap enable			*/
+#define CR_AFE  (1 << 29)	/* Access flag enable			*/
+#define CR_TE   (1 << 30)	/* Thumb exception enable		*/
+
+static inline unsigned int get_cr(void)
+{
+	unsigned int val;
+	asm("mrc p15, 0, %0, c1, c0, 0  @ get CR" : "=r" (val) : : "cc");
+	return val;
+}
+
+static inline void set_cr(unsigned int val)
+{
+	asm volatile("mcr p15, 0, %0, c1, c0, 0 @ set CR"
+	  : : "r" (val) : "cc");
+	isb();
+}
+#endif /* __ASM_ARM_SYSTEM_H */
-- 
1.7.0


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

  parent reply	other threads:[~2010-04-29  7:52 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-29  7:51 patches for next v2 Sascha Hauer
2010-04-29  7:51 ` [PATCH 01/17] i.MX35 stack: Fix mc9sdz60 reset register offset Sascha Hauer
2010-04-29  7:52 ` [PATCH 02/17] ARM: use memalign in dma_alloc_coherent to assure alignment Sascha Hauer
2010-04-29  7:52 ` [PATCH 03/17] fsl_udc: make it work with MMU on Sascha Hauer
2010-04-29  7:52 ` [PATCH 04/17] Increase MAX_FILES to 128 Sascha Hauer
2010-04-29  7:52 ` [PATCH 05/17] fix _update scripts Sascha Hauer
2010-04-29  7:52 ` [PATCH 06/17] define __LINUX_ARM_ARCH__ for armv6 processors Sascha Hauer
2010-04-29  7:52 ` Sascha Hauer [this message]
2010-04-29  7:52 ` [PATCH 08/17] ARM: update icache functions to use get_cr/set_cr Sascha Hauer
2010-04-29  7:52 ` [PATCH 09/17] pcm043: Speed up NAND controller before copying barebox image Sascha Hauer
2010-05-03 11:29   ` Peter Korsgaard
2010-05-03 13:09     ` Sascha Hauer
2010-04-29  7:52 ` [PATCH 10/17] add arm helper function to determine the program counter Sascha Hauer
2010-04-29  7:52 ` [PATCH 11/17] arm: remove unused variables from header file Sascha Hauer
2010-04-29  7:52 ` [PATCH 12/17] arm: move __mmu_cache_flush to bare_init section Sascha Hauer
2010-04-29  7:52 ` [PATCH 13/17] arm: reimplement startup code in C Sascha Hauer
2010-04-29  7:52 ` [PATCH 14/17] i.MX: remove __REG from esd controller regs. use readl/writel instead Sascha Hauer
2010-04-29  7:52 ` [PATCH 15/17] pcm043: reimplement lowlevel code in C Sascha Hauer
2010-04-29  7:52 ` [PATCH 16/17] i.MX35: Fix ahbclock calculation Sascha Hauer
2010-04-29  7:52 ` [PATCH 17/17] pcm038: reimplement lowlevel code in C Sascha Hauer

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=1272527535-17527-8-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@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