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