1 /*
2  * Copyright (c) 2023 Carlo Caione <ccaione@baylibre.com>
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 #ifndef ZEPHYR_INCLUDE_DT_BINDINGS_MEM_ATTR_ARM_H_
7 #define ZEPHYR_INCLUDE_DT_BINDINGS_MEM_ATTR_ARM_H_
8 
9 #include <zephyr/sys/util_macro.h>
10 #include <zephyr/dt-bindings/memory-attr/memory-attr.h>
11 
12 /*
13  * Architecture specific ARM MPU related attributes.
14  *
15  * This list is to seamlessly support the MPU regions configuration using DT and
16  * the `zephyr,memory-attr` property.
17  *
18  * This is legacy and it should NOT be extended further. If new MPU region
19  * types must be added, these must rely on the generic memory attributes.
20  */
21 #define DT_MEM_ARM_MASK			DT_MEM_ARCH_ATTR_MASK
22 #define DT_MEM_ARM_GET(x)		((x) & DT_MEM_ARM_MASK)
23 #define DT_MEM_ARM(x)			((x) << DT_MEM_ARCH_ATTR_SHIFT)
24 
25 #define  ATTR_MPU_RAM			BIT(0)
26 #define  ATTR_MPU_RAM_NOCACHE		BIT(1)
27 #define  ATTR_MPU_FLASH			BIT(2)
28 #define  ATTR_MPU_PPB			BIT(3)
29 #define  ATTR_MPU_IO			BIT(4)
30 #define  ATTR_MPU_EXTMEM		BIT(5)
31 
32 #define DT_MEM_ARM_MPU_RAM		DT_MEM_ARM(ATTR_MPU_RAM)
33 #define DT_MEM_ARM_MPU_RAM_NOCACHE	DT_MEM_ARM(ATTR_MPU_RAM_NOCACHE)
34 #define DT_MEM_ARM_MPU_FLASH		DT_MEM_ARM(ATTR_MPU_FLASH)
35 #define DT_MEM_ARM_MPU_PPB		DT_MEM_ARM(ATTR_MPU_PPB)
36 #define DT_MEM_ARM_MPU_IO		DT_MEM_ARM(ATTR_MPU_IO)
37 #define DT_MEM_ARM_MPU_EXTMEM		DT_MEM_ARM(ATTR_MPU_EXTMEM)
38 #define DT_MEM_ARM_MPU_UNKNOWN		DT_MEM_ARCH_ATTR_UNKNOWN
39 
40 #endif /* ZEPHYR_INCLUDE_DT_BINDINGS_MEM_ATTR_ARM_H_ */
41