xref: /rk3399_ARM-atf/include/drivers/st/stm32_mce.h (revision 7f690c3786224d000ff53f459f1bdb6ad05dc1d1)
1*6d797402SNicolas Le Bayon /*
2*6d797402SNicolas Le Bayon  * Copyright (c) 2020-2025, STMicroelectronics - All Rights Reserved
3*6d797402SNicolas Le Bayon  *
4*6d797402SNicolas Le Bayon  * SPDX-License-Identifier: BSD-3-Clause
5*6d797402SNicolas Le Bayon  */
6*6d797402SNicolas Le Bayon 
7*6d797402SNicolas Le Bayon #ifndef STM32_MCE_H
8*6d797402SNicolas Le Bayon #define STM32_MCE_H
9*6d797402SNicolas Le Bayon 
10*6d797402SNicolas Le Bayon #include <stdbool.h>
11*6d797402SNicolas Le Bayon #include <stdint.h>
12*6d797402SNicolas Le Bayon 
13*6d797402SNicolas Le Bayon #include <dt-bindings/soc/stm32mp13-mce.h>
14*6d797402SNicolas Le Bayon 
15*6d797402SNicolas Le Bayon /* MCE encryption modes */
16*6d797402SNicolas Le Bayon #define MCE_BYPASS_MODE			MCE_PLAINTEXT
17*6d797402SNicolas Le Bayon #define MCE_ENCRYPT_MODE		MCE_ENCRYPT
18*6d797402SNicolas Le Bayon #define MCE_ENCRYPTION_MODE_MAX		MCE_ENCRYPT_MODE
19*6d797402SNicolas Le Bayon 
20*6d797402SNicolas Le Bayon /* IP configuration */
21*6d797402SNicolas Le Bayon #define MCE_IP_MAX_REGION_NB		1U
22*6d797402SNicolas Le Bayon 
23*6d797402SNicolas Le Bayon struct stm32_mce_region_s {
24*6d797402SNicolas Le Bayon 	uint32_t encrypt_mode;	/*
25*6d797402SNicolas Le Bayon 				 * Specifies the region encryption mode.
26*6d797402SNicolas Le Bayon 				 * This parameter can be a value of
27*6d797402SNicolas Le Bayon 				 * @ref MCE_*_MODE (in driver header file).
28*6d797402SNicolas Le Bayon 				 */
29*6d797402SNicolas Le Bayon 	uint32_t start_address;	/* Specifies the region start address */
30*6d797402SNicolas Le Bayon 	uint32_t end_address;	/* Specifies the region end address */
31*6d797402SNicolas Le Bayon };
32*6d797402SNicolas Le Bayon 
33*6d797402SNicolas Le Bayon void stm32_mce_init(void);
34*6d797402SNicolas Le Bayon 
35*6d797402SNicolas Le Bayon int stm32_mce_write_master_key(uint8_t *mkey);
36*6d797402SNicolas Le Bayon void stm32_mce_lock_master_key(void);
37*6d797402SNicolas Le Bayon bool stm32_mce_is_master_key_locked(void);
38*6d797402SNicolas Le Bayon 
39*6d797402SNicolas Le Bayon void stm32_mce_lock_global(void);
40*6d797402SNicolas Le Bayon bool stm32_mce_is_globally_locked(void);
41*6d797402SNicolas Le Bayon bool stm32_mce_is_hw_encryption_functional(void);
42*6d797402SNicolas Le Bayon 
43*6d797402SNicolas Le Bayon int stm32_mce_get_address_encryption_state(uint32_t address, uint32_t *state);
44*6d797402SNicolas Le Bayon #endif /* STM32_MCE_H */
45