blob: c3f11524f10c4c594fb6e5a03f97f286824ee5be [file] [log] [blame]
Russell King15d07dc2012-03-28 18:30:01 +01001#ifndef __ASM_ARM_CP15_H
2#define __ASM_ARM_CP15_H
3
David Howells9f97da72012-03-28 18:30:01 +01004#include <asm/barrier.h>
Russell King15d07dc2012-03-28 18:30:01 +01005
6/*
7 * CR1 bits (CP#15 CR1)
8 */
9#define CR_M (1 << 0) /* MMU enable */
10#define CR_A (1 << 1) /* Alignment abort enable */
11#define CR_C (1 << 2) /* Dcache enable */
12#define CR_W (1 << 3) /* Write buffer enable */
13#define CR_P (1 << 4) /* 32-bit exception handler */
14#define CR_D (1 << 5) /* 32-bit data address range */
15#define CR_L (1 << 6) /* Implementation defined */
16#define CR_B (1 << 7) /* Big endian */
17#define CR_S (1 << 8) /* System MMU protection */
18#define CR_R (1 << 9) /* ROM MMU protection */
19#define CR_F (1 << 10) /* Implementation defined */
20#define CR_Z (1 << 11) /* Implementation defined */
21#define CR_I (1 << 12) /* Icache enable */
22#define CR_V (1 << 13) /* Vectors relocated to 0xffff0000 */
23#define CR_RR (1 << 14) /* Round Robin cache replacement */
24#define CR_L4 (1 << 15) /* LDR pc can set T bit */
25#define CR_DT (1 << 16)
Jonathan Austinaca7e592013-02-21 15:21:34 +000026#ifdef CONFIG_MMU
27#define CR_HA (1 << 17) /* Hardware management of Access Flag */
28#else
29#define CR_BR (1 << 17) /* MPU Background region enable (PMSA) */
30#endif
Russell King15d07dc2012-03-28 18:30:01 +010031#define CR_IT (1 << 18)
32#define CR_ST (1 << 19)
33#define CR_FI (1 << 21) /* Fast interrupt (lower latency mode) */
34#define CR_U (1 << 22) /* Unaligned access operation */
35#define CR_XP (1 << 23) /* Extended page tables */
36#define CR_VE (1 << 24) /* Vectored interrupts */
37#define CR_EE (1 << 25) /* Exception (Big) Endian */
38#define CR_TRE (1 << 28) /* TEX remap enable */
39#define CR_AFE (1 << 29) /* Access flag enable */
40#define CR_TE (1 << 30) /* Thumb exception enable */
41
42#ifndef __ASSEMBLY__
43
44#if __LINUX_ARM_ARCH__ >= 4
Russell King4585eaf2014-04-13 18:47:34 +010045#define vectors_high() (get_cr() & CR_V)
Russell King15d07dc2012-03-28 18:30:01 +010046#else
47#define vectors_high() (0)
48#endif
49
Uwe Kleine-Königb849a602012-01-16 10:34:31 +010050#ifdef CONFIG_CPU_CP15
51
Russell King15d07dc2012-03-28 18:30:01 +010052extern unsigned long cr_alignment; /* defined in entry-armv.S */
53
Russell King7668fd52014-04-13 20:09:55 +010054static inline unsigned long get_cr(void)
Russell King15d07dc2012-03-28 18:30:01 +010055{
Russell King7668fd52014-04-13 20:09:55 +010056 unsigned long val;
Russell King15d07dc2012-03-28 18:30:01 +010057 asm("mrc p15, 0, %0, c1, c0, 0 @ get CR" : "=r" (val) : : "cc");
58 return val;
59}
60
Russell King7668fd52014-04-13 20:09:55 +010061static inline void set_cr(unsigned long val)
Russell King15d07dc2012-03-28 18:30:01 +010062{
63 asm volatile("mcr p15, 0, %0, c1, c0, 0 @ set CR"
64 : : "r" (val) : "cc");
65 isb();
66}
67
Rob Herringbbc8d772013-01-16 17:57:33 -060068static inline unsigned int get_auxcr(void)
69{
70 unsigned int val;
71 asm("mrc p15, 0, %0, c1, c0, 1 @ get AUXCR" : "=r" (val));
72 return val;
73}
74
75static inline void set_auxcr(unsigned int val)
76{
77 asm volatile("mcr p15, 0, %0, c1, c0, 1 @ set AUXCR"
78 : : "r" (val));
79 isb();
80}
81
Russell King15d07dc2012-03-28 18:30:01 +010082#define CPACC_FULL(n) (3 << (n * 2))
83#define CPACC_SVC(n) (1 << (n * 2))
84#define CPACC_DISABLE(n) (0 << (n * 2))
85
86static inline unsigned int get_copro_access(void)
87{
88 unsigned int val;
89 asm("mrc p15, 0, %0, c1, c0, 2 @ get copro access"
90 : "=r" (val) : : "cc");
91 return val;
92}
93
94static inline void set_copro_access(unsigned int val)
95{
96 asm volatile("mcr p15, 0, %0, c1, c0, 2 @ set copro access"
97 : : "r" (val) : "cc");
98 isb();
99}
100
Uwe Kleine-Königb849a602012-01-16 10:34:31 +0100101#else /* ifdef CONFIG_CPU_CP15 */
102
103/*
Russell King0aeb3402014-04-13 19:43:26 +0100104 * cr_alignment is tightly coupled to cp15 (at least in the minds of the
105 * developers). Yielding 0 for machines without a cp15 (and making it
106 * read-only) is fine for most cases and saves quite some #ifdeffery.
Uwe Kleine-Königb849a602012-01-16 10:34:31 +0100107 */
Uwe Kleine-Königb849a602012-01-16 10:34:31 +0100108#define cr_alignment UL(0)
109
Russell King4585eaf2014-04-13 18:47:34 +0100110static inline unsigned long get_cr(void)
111{
112 return 0;
113}
114
Uwe Kleine-Königb849a602012-01-16 10:34:31 +0100115#endif /* ifdef CONFIG_CPU_CP15 / else */
116
117#endif /* ifndef __ASSEMBLY__ */
Russell King15d07dc2012-03-28 18:30:01 +0100118
119#endif