1 /* SPDX-License-Identifier: Apache-2.0
2  *
3  * Copyright (c) 2021 Lexmark International, Inc.
4  */
5 
6 #include <zephyr/kernel.h>
7 #include <zephyr/arch/arm/mpu/arm_mpu.h>
8 
9 #define MPUTYPE_READ_ONLY \
10 	{ \
11 		.rasr = (P_RO_U_RO_Msk \
12 				| (7 << MPU_RASR_TEX_Pos) \
13 				| MPU_RASR_C_Msk \
14 				| MPU_RASR_B_Msk \
15 				| MPU_RASR_XN_Msk) \
16 	}
17 
18 #define MPUTYPE_READ_ONLY_PRIV \
19 	{ \
20 		.rasr = (P_RO_U_RO_Msk \
21 				| (5 << MPU_RASR_TEX_Pos) \
22 				| MPU_RASR_B_Msk) \
23 	}
24 
25 #define MPUTYPE_PRIV_WBWACACHE \
26 	{ \
27 		.rasr = (P_RW_U_NA_Msk \
28 				| (5 << MPU_RASR_TEX_Pos) \
29 				| MPU_RASR_B_Msk) \
30 	}
31 
32 #define MPUTYPE_PRIV_DEVICE \
33 	{ \
34 		.rasr = (P_RW_U_NA_Msk \
35 				| (2 << MPU_RASR_TEX_Pos)) \
36 	}
37 
38 extern uint32_t _image_rom_end_order;
39 static const struct arm_mpu_region mpu_regions[] = {
40 	MPU_REGION_ENTRY("FLASH0",
41 			0xc0000000,
42 			REGION_32M,
43 			MPUTYPE_READ_ONLY),
44 
45 	MPU_REGION_ENTRY("SRAM_PRIV",
46 			0x00000000,
47 			REGION_2G,
48 			MPUTYPE_PRIV_WBWACACHE),
49 
50 	MPU_REGION_ENTRY("SRAM",
51 			0x00000000,
52 			((uint32_t)&_image_rom_end_order),
53 			MPUTYPE_READ_ONLY_PRIV),
54 
55 	MPU_REGION_ENTRY("REGISTERS",
56 			0xf8000000,
57 			REGION_128M,
58 			MPUTYPE_PRIV_DEVICE),
59 };
60 
61 const struct arm_mpu_config mpu_config = {
62 	.num_regions = ARRAY_SIZE(mpu_regions),
63 	.mpu_regions = mpu_regions,
64 };
65