xref: /linux/arch/arm/include/asm/mpu.h (revision 877ec119dbbf9576953efc457ede5243621ad6eb)
1 #ifndef __ARM_MPU_H
2 #define __ARM_MPU_H
3 
4 /* MPUIR layout */
5 #define MPUIR_nU		1
6 #define MPUIR_DREGION		8
7 #define MPUIR_IREGION		16
8 #define MPUIR_DREGION_SZMASK	(0xFF << MPUIR_DREGION)
9 #define MPUIR_IREGION_SZMASK	(0xFF << MPUIR_IREGION)
10 
11 /* ID_MMFR0 data relevant to MPU */
12 #define MMFR0_PMSA		(0xF << 4)
13 #define MMFR0_PMSAv7		(3 << 4)
14 
15 /* MPU D/I Size Register fields */
16 #define MPU_RSR_SZ		1
17 #define MPU_RSR_EN		0
18 
19 /* The D/I RSR value for an enabled region spanning the whole of memory */
20 #define MPU_RSR_ALL_MEM		63
21 
22 /* Individual bits in the DR/IR ACR */
23 #define MPU_ACR_XN		(1 << 12)
24 #define MPU_ACR_SHARED		(1 << 2)
25 
26 /* C, B and TEX[2:0] bits only have semantic meanings when grouped */
27 #define MPU_RGN_CACHEABLE	0xB
28 #define MPU_RGN_SHARED_CACHEABLE (MPU_RGN_CACHEABLE | MPU_ACR_SHARED)
29 #define MPU_RGN_STRONGLY_ORDERED 0
30 
31 /* Main region should only be shared for SMP */
32 #ifdef CONFIG_SMP
33 #define MPU_RGN_NORMAL		(MPU_RGN_CACHEABLE | MPU_ACR_SHARED)
34 #else
35 #define MPU_RGN_NORMAL		MPU_RGN_CACHEABLE
36 #endif
37 
38 /* Access permission bits of ACR (only define those that we use)*/
39 #define MPU_AP_PL1RW_PL0RW	(0x3 << 8)
40 #define MPU_AP_PL1RW_PL0R0	(0x2 << 8)
41 #define MPU_AP_PL1RW_PL0NA	(0x1 << 8)
42 
43 /* For minimal static MPU region configurations */
44 #define MPU_PROBE_REGION	0
45 #define MPU_BG_REGION		1
46 #define MPU_RAM_REGION		2
47 #define MPU_VECTORS_REGION	3
48 
49 /* Maximum number of regions Linux is interested in */
50 #define MPU_MAX_REGIONS		16
51 
52 #define MPU_DATA_SIDE		0
53 #define MPU_INSTR_SIDE		1
54 
55 #ifndef __ASSEMBLY__
56 
57 struct mpu_rgn {
58 	/* Assume same attributes for d/i-side  */
59 	u32 drbar;
60 	u32 drsr;
61 	u32 dracr;
62 };
63 
64 struct mpu_rgn_info {
65 	u32 mpuir;
66 	struct mpu_rgn rgns[MPU_MAX_REGIONS];
67 };
68 extern struct mpu_rgn_info mpu_rgn_info;
69 
70 #ifdef CONFIG_ARM_MPU
71 
72 extern void __init adjust_lowmem_bounds_mpu(void);
73 extern void __init mpu_setup(void);
74 
75 #else
76 
77 static inline void adjust_lowmem_bounds_mpu(void) {}
78 static inline void mpu_setup(void) {}
79 
80 #endif /* !CONFIG_ARM_MPU */
81 
82 #endif /* __ASSEMBLY__ */
83 
84 #endif
85