1 /*
2  * Copyright (c) 2019 Synopsys
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <zephyr/devicetree.h>
8 #include <zephyr/arch/arc/v2/mpu/arc_mpu.h>
9 #include <zephyr/linker/linker-defs.h>
10 
11 static struct arc_mpu_region mpu_regions[] = {
12 	/* Region ICCM */
13 	MPU_REGION_ENTRY("ICCM",
14 			 DT_REG_ADDR(DT_INST(0, arc_iccm)),
15 			 DT_REG_SIZE(DT_INST(0, arc_iccm)),
16 			 REGION_ROM_ATTR),
17 	/* Region DCCM */
18 	MPU_REGION_ENTRY("DCCM",
19 			 DT_REG_ADDR(DT_INST(0, arc_dccm)),
20 			 DT_REG_SIZE(DT_INST(0, arc_dccm)),
21 			 REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC),
22 	/* Region XCCM */
23 #if DT_REG_SIZE(DT_INST(0, arc_xccm)) > 0
24 	MPU_REGION_ENTRY("XCCM",
25 			 DT_REG_ADDR(DT_INST(0, arc_xccm)),
26 			 DT_REG_SIZE(DT_INST(0, arc_xccm)),
27 			 REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC),
28 #endif
29 	/* Region YCCM */
30 #if DT_REG_SIZE(DT_INST(0, arc_yccm)) > 0
31 	MPU_REGION_ENTRY("YCCM",
32 			 DT_REG_ADDR(DT_INST(0, arc_yccm)),
33 			 DT_REG_SIZE(DT_INST(0, arc_yccm)),
34 			 REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC),
35 #endif
36 	/* Region DDR RAM */
37 	MPU_REGION_ENTRY("SRAM",
38 			DT_REG_ADDR(DT_INST(0, mmio_sram)),
39 			DT_REG_SIZE(DT_INST(0, mmio_sram)),
40 			REGION_KERNEL_RAM_ATTR |
41 			AUX_MPU_ATTR_KW | AUX_MPU_ATTR_KR | AUX_MPU_ATTR_UR |
42 			AUX_MPU_ATTR_KE | AUX_MPU_ATTR_UE | REGION_DYNAMIC),
43 	/* Region Peripheral */
44 	MPU_REGION_ENTRY("PERIPHERAL",
45 			 0xF0000000,
46 			 32 * 1024 * 1024,
47 			 REGION_KERNEL_RAM_ATTR),
48 };
49 
50 struct arc_mpu_config mpu_config = {
51 	.num_regions = ARRAY_SIZE(mpu_regions),
52 	.mpu_regions = mpu_regions,
53 };
54