1a2b45b0dSJonathan Austin #ifndef __ARM_MPU_H 2a2b45b0dSJonathan Austin #define __ARM_MPU_H 3a2b45b0dSJonathan Austin 4a2b45b0dSJonathan Austin /* MPUIR layout */ 5a2b45b0dSJonathan Austin #define MPUIR_nU 1 6a2b45b0dSJonathan Austin #define MPUIR_DREGION 8 7a2b45b0dSJonathan Austin #define MPUIR_IREGION 16 8a2b45b0dSJonathan Austin #define MPUIR_DREGION_SZMASK (0xFF << MPUIR_DREGION) 9a2b45b0dSJonathan Austin #define MPUIR_IREGION_SZMASK (0xFF << MPUIR_IREGION) 10a2b45b0dSJonathan Austin 11a2b45b0dSJonathan Austin /* ID_MMFR0 data relevant to MPU */ 12a2b45b0dSJonathan Austin #define MMFR0_PMSA (0xF << 4) 13a2b45b0dSJonathan Austin #define MMFR0_PMSAv7 (3 << 4) 14a2b45b0dSJonathan Austin 15a2b45b0dSJonathan Austin /* MPU D/I Size Register fields */ 16a2b45b0dSJonathan Austin #define MPU_RSR_SZ 1 17a2b45b0dSJonathan Austin #define MPU_RSR_EN 0 18*5c9d9a1bSVladimir Murzin #define MPU_RSR_SD 8 19*5c9d9a1bSVladimir Murzin 20*5c9d9a1bSVladimir Murzin /* Number of subregions (SD) */ 21*5c9d9a1bSVladimir Murzin #define MPU_NR_SUBREGS 8 22*5c9d9a1bSVladimir Murzin #define MPU_MIN_SUBREG_SIZE 256 23a2b45b0dSJonathan Austin 24a2b45b0dSJonathan Austin /* The D/I RSR value for an enabled region spanning the whole of memory */ 25a2b45b0dSJonathan Austin #define MPU_RSR_ALL_MEM 63 26a2b45b0dSJonathan Austin 27a2b45b0dSJonathan Austin /* Individual bits in the DR/IR ACR */ 28a2b45b0dSJonathan Austin #define MPU_ACR_XN (1 << 12) 29a2b45b0dSJonathan Austin #define MPU_ACR_SHARED (1 << 2) 30a2b45b0dSJonathan Austin 31a2b45b0dSJonathan Austin /* C, B and TEX[2:0] bits only have semantic meanings when grouped */ 32a2b45b0dSJonathan Austin #define MPU_RGN_CACHEABLE 0xB 33a2b45b0dSJonathan Austin #define MPU_RGN_SHARED_CACHEABLE (MPU_RGN_CACHEABLE | MPU_ACR_SHARED) 34a2b45b0dSJonathan Austin #define MPU_RGN_STRONGLY_ORDERED 0 35a2b45b0dSJonathan Austin 36a2b45b0dSJonathan Austin /* Main region should only be shared for SMP */ 37a2b45b0dSJonathan Austin #ifdef CONFIG_SMP 38a2b45b0dSJonathan Austin #define MPU_RGN_NORMAL (MPU_RGN_CACHEABLE | MPU_ACR_SHARED) 39a2b45b0dSJonathan Austin #else 40a2b45b0dSJonathan Austin #define MPU_RGN_NORMAL MPU_RGN_CACHEABLE 41a2b45b0dSJonathan Austin #endif 42a2b45b0dSJonathan Austin 43a2b45b0dSJonathan Austin /* Access permission bits of ACR (only define those that we use)*/ 44a2b45b0dSJonathan Austin #define MPU_AP_PL1RW_PL0RW (0x3 << 8) 45a2b45b0dSJonathan Austin #define MPU_AP_PL1RW_PL0R0 (0x2 << 8) 46a2b45b0dSJonathan Austin #define MPU_AP_PL1RW_PL0NA (0x1 << 8) 47a2b45b0dSJonathan Austin 48a2b45b0dSJonathan Austin /* For minimal static MPU region configurations */ 49a2b45b0dSJonathan Austin #define MPU_PROBE_REGION 0 50a2b45b0dSJonathan Austin #define MPU_BG_REGION 1 51a2b45b0dSJonathan Austin #define MPU_RAM_REGION 2 529dfc28b6SJonathan Austin #define MPU_VECTORS_REGION 3 53a2b45b0dSJonathan Austin 54a2b45b0dSJonathan Austin /* Maximum number of regions Linux is interested in */ 55a2b45b0dSJonathan Austin #define MPU_MAX_REGIONS 16 56a2b45b0dSJonathan Austin 5767c9845bSJonathan Austin #define MPU_DATA_SIDE 0 5867c9845bSJonathan Austin #define MPU_INSTR_SIDE 1 5967c9845bSJonathan Austin 60a2b45b0dSJonathan Austin #ifndef __ASSEMBLY__ 61a2b45b0dSJonathan Austin 62a2b45b0dSJonathan Austin struct mpu_rgn { 63a2b45b0dSJonathan Austin /* Assume same attributes for d/i-side */ 64a2b45b0dSJonathan Austin u32 drbar; 65a2b45b0dSJonathan Austin u32 drsr; 66a2b45b0dSJonathan Austin u32 dracr; 67a2b45b0dSJonathan Austin }; 68a2b45b0dSJonathan Austin 69a2b45b0dSJonathan Austin struct mpu_rgn_info { 70a0995c08SVladimir Murzin unsigned int used; 71a2b45b0dSJonathan Austin struct mpu_rgn rgns[MPU_MAX_REGIONS]; 72a2b45b0dSJonathan Austin }; 73a2b45b0dSJonathan Austin extern struct mpu_rgn_info mpu_rgn_info; 74a2b45b0dSJonathan Austin 75877ec119SVladimir Murzin #ifdef CONFIG_ARM_MPU 76a2b45b0dSJonathan Austin 77877ec119SVladimir Murzin extern void __init adjust_lowmem_bounds_mpu(void); 78877ec119SVladimir Murzin extern void __init mpu_setup(void); 79877ec119SVladimir Murzin 80877ec119SVladimir Murzin #else 81877ec119SVladimir Murzin 82877ec119SVladimir Murzin static inline void adjust_lowmem_bounds_mpu(void) {} 83877ec119SVladimir Murzin static inline void mpu_setup(void) {} 84877ec119SVladimir Murzin 85877ec119SVladimir Murzin #endif /* !CONFIG_ARM_MPU */ 86877ec119SVladimir Murzin 87877ec119SVladimir Murzin #endif /* __ASSEMBLY__ */ 88a2b45b0dSJonathan Austin 89a2b45b0dSJonathan Austin #endif 90