1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /*
3  * Copyright (c) 2014, ARM Limited and Contributors. All rights reserved.
4  * Copyright (c) 2018-2019, STMicroelectronics
5  */
6 
7 #ifndef __STM32_ETZPC_H__
8 #define __STM32_ETZPC_H__
9 
10 #include <util.h>
11 #include <types_ext.h>
12 
13 enum etzpc_decprot_attributes {
14 	ETZPC_DECPROT_S_RW = 0,
15 	ETZPC_DECPROT_NS_R_S_W = 1,
16 	ETZPC_DECPROT_MCU_ISOLATION = 2,
17 	ETZPC_DECPROT_NS_RW = 3,
18 	ETZPC_DECPROT_MAX = 4,
19 };
20 
21 #define ETZPC_TZMA_ALL_SECURE		GENMASK_32(9, 0)
22 #define ETZPC_TZMA_ALL_NO_SECURE	0x0
23 
24 /*
25  * Load a DECPROT configuration
26  * @decprot_id: ID that is the index of the DECPROT in the ETZPC interface
27  * @decprot_attr: Restriction access attributes
28  */
29 void etzpc_configure_decprot(uint32_t decprot_id,
30 			     enum etzpc_decprot_attributes decprot_attr);
31 
32 /*
33  * Get the DECPROT attribute
34  * @decprot_id: ID that is the index of the DECPROT in the ETZPC interface
35  * Return attribute of this DECPROT
36  */
37 enum etzpc_decprot_attributes etzpc_get_decprot(uint32_t decprot_id);
38 
39 /*
40  * Lock access to the DECPROT attributes
41  * @decprot_id: ID that is the index of the DECPROT in the ETZPC interface
42  */
43 void etzpc_lock_decprot(uint32_t decprot_id);
44 
45 /*
46  * Return the lock status of the target DECPROT
47  * @decprot_id: ID that is the index of the DECPROT in the ETZPC interface
48  */
49 bool etzpc_get_lock_decprot(uint32_t decprot_id);
50 
51 /*
52  * Configure the target TZMA read only size
53  * @tzma_id: ID that is the index of the TZMA in the ETZPC interface
54  * @tzma_value: Read-only size
55  */
56 void etzpc_configure_tzma(uint32_t tzma_id, uint16_t tzma_value);
57 
58 /*
59  * Get the target TZMA read only size
60  * @tzma_id: ID that is the index of the TZMA in the ETZPC interface
61  * Return the size of read-only area
62  */
63 uint16_t etzpc_get_tzma(uint32_t tzma_id);
64 
65 /*
66  * Lock the target TZMA
67  * @tzma_id: ID that is the index of the TZMA in the ETZPC interface
68  */
69 void etzpc_lock_tzma(uint32_t tzma_id);
70 
71 /*
72  * Return the lock status of the target TZMA
73  * @tzma_id: ID that is the index of the TZMA in the ETZPC interface
74  * Return true if TZMA is locked, false otherwise
75  */
76 bool etzpc_get_lock_tzma(uint32_t tzma_id);
77 
78 /*
79  * Init the ETZPC device, nedded when not using the device tree
80  * @base: ETZPC interface registers physcal base address
81  */
82 #ifdef CFG_STM32_ETZPC
83 void stm32_etzpc_init(paddr_t base);
84 #else
stm32_etzpc_init(paddr_t __unused base)85 static inline void stm32_etzpc_init(paddr_t __unused base) {}
86 #endif
87 
88 #endif /*__STM32_ETZPC_H__*/
89