1 /* 2 * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 #pragma once 7 8 #include "hal/apm_ll.h" 9 10 #ifdef __cplusplus 11 extern "C" { 12 #endif 13 14 /** 15 * @brief Region configuration data. 16 */ 17 typedef struct { 18 apm_ll_secure_mode_t sec_mode; 19 uint32_t regn_num; 20 uint32_t regn_start_addr; 21 uint32_t regn_end_addr; 22 uint32_t regn_pms; 23 } apm_hp_hal_region_config_data_t; 24 25 /** 26 * @brief Secure mode(TEE/REE[0:2] configuration data. 27 */ 28 typedef struct { 29 apm_ll_secure_mode_t sec_mode; /* Secure mode to be configured TEE/REE[0:2]. */ 30 uint32_t master_ids; /* Bit mask for masters to be part of this secure mode. */ 31 apm_hp_hal_region_config_data_t *pms_data; /* Region configuration data. */ 32 } apm_hp_secure_mode_config_t; 33 34 /** 35 * @brief Set secure mode 36 * 37 * @param master_id APM master ID 38 * @param sec_mode Secure mode 39 */ 40 void apm_tee_hal_set_master_secure_mode(apm_ll_master_id_t master_id, apm_ll_secure_mode_t sec_mode); 41 42 /** 43 * @brief TEE controller clock auto gating enable 44 * 45 * @param enable Flag for HP clock auto gating enable/disable 46 */ 47 void apm_tee_hal_clk_gating_enable(bool enable); 48 49 /** 50 * @brief enable/disable HP Region access permission filter 51 * 52 * @param regn_num Memory Region number 53 * @param enable Flag for Region access filter enable/disable 54 */ 55 void apm_hp_hal_region_filter_enable(uint32_t regn_num, bool enable); 56 57 /** 58 * @brief enable/disable HP access path(M[0:3]) 59 * 60 * @param hp_m_path HP access path 61 * @param enable Flag for HP M path filter enable/disable 62 */ 63 void apm_hp_hal_m_filter_enable(apm_ll_hp_access_path_t hp_m_path, bool enable); 64 65 /** 66 * @brief Region configuration 67 * 68 * @param pms_data Region configuration data 69 */ 70 void apm_hp_hal_region_config(const apm_hp_hal_region_config_data_t *pms_data); 71 72 /** 73 * @brief Get HP access path(M[0:3]) exception status 74 * 75 * @param hp_m_path HP access path 76 */ 77 uint8_t apm_hp_hal_m_exception_status(apm_ll_hp_access_path_t hp_m_path); 78 79 /** 80 * @brief Clear HP access path(M[0:3]) exception 81 * 82 * @param hp_m_path HP access path 83 */ 84 void apm_hp_hal_m_exception_clear(apm_ll_hp_access_path_t hp_m_path); 85 86 /** 87 * @brief Get HP access path(M[0:3]) exception information 88 * 89 * @param excp_info Exception related information like addr, 90 * region, sec_mode and master id 91 */ 92 void apm_hp_hal_get_m_exception_info(apm_hp_m_exception_info_t *excp_info); 93 94 /** 95 * @brief Interrupt enable for access path(M[0:3]) 96 * 97 * @param hp_m_path HP access path 98 * @param enable Flag for access path interrupt enable/disable 99 */ 100 void apm_hp_hal_m_interrupt_enable(apm_ll_hp_access_path_t hp_m_path, bool enable); 101 102 /** 103 * @brief HP clock auto gating enable 104 * 105 * @param enable Flag for HP clock auto gating enable/disable 106 */ 107 void apm_hp_hal_clk_gating_enable(bool enable); 108 109 /** 110 * @brief TEE/REE execution environment configuration. 111 * 112 * This API will be called from TEE mode initialization code which is 113 * responsible to setup TEE/REE execution environment. 114 * It includes, allocation of all bus masters, memory ranges and other 115 * peripherals to the given secure mode. 116 * All this information should be passed by the TEE mode initialization code. 117 */ 118 void apm_hp_hal_master_sec_mode_config(apm_hp_secure_mode_config_t *sec_mode_data); 119 120 /** 121 * @brief APM/TEE/HP System Reg reset event bypass enable 122 * 123 * Disable: tee_reg/apm_reg/hp_system_reg will not only be reset by power-reset, 124 * but also some reset events. 125 * Enable: tee_reg/apm_reg/hp_system_reg will only be reset by power-reset. 126 * Some reset events will be bypassed. 127 * 128 * @param enable Flag for event bypass enable/disable 129 */ 130 void apm_hp_hal_reset_event_enable(bool enable); 131 132 #ifdef __cplusplus 133 } 134 #endif 135