1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /* 3 * Copyright (c) 2023, STMicroelectronics - All Rights Reserved 4 */ 5 6 #ifndef __DRIVERS_STM32_REMOTEPROC_H 7 #define __DRIVERS_STM32_REMOTEPROC_H 8 9 #include <stdint.h> 10 #include <tee_api_types.h> 11 #include <types_ext.h> 12 13 /* IDs of the supported remote processors*/ 14 #define STM32_M4_RPROC_ID 0 15 16 /* 17 * stm32_rproc_get() - get the rproc handle associated to a remote processor ID 18 * @rproc_id unique identifier of the remote processor 19 * Return a pointer to the rproc firmware handle related to @rproc_id or NULL. 20 */ 21 void *stm32_rproc_get(uint32_t rproc_id); 22 23 /* 24 * stm32_rproc_da_to_pa() - Convert the coprocessor device address to a CPU 25 * physical address. 26 * @rproc_id unique identifier of the remote processor 27 * @da device memory address from the remote processor space 28 * perspective. 29 * @size size of the memory 30 * @pa Output CPU physical address associated to @da. 31 * Return TEE_SUCCESS or appropriate error. 32 */ 33 TEE_Result stm32_rproc_da_to_pa(uint32_t rproc_id, paddr_t da, size_t size, 34 paddr_t *pa); 35 36 /* 37 * stm32_rproc_map() - map the physical address if valid 38 * @rproc_id unique identifier of the remote processor 39 * @pa physical address from the CPU space perspective 40 * @size size of the memory 41 * @va Output CPU virtual address associated to @pa. 42 * Return TEE_SUCCESS or appropriate error. 43 */ 44 TEE_Result stm32_rproc_map(uint32_t rproc_id, paddr_t pa, size_t size, 45 void **va); 46 47 /* 48 * stm32_rproc_unmap() - ummap the virtual address mapped with stm32_rproc_map 49 * @rproc_id unique identifier of the remote processor 50 * @va virtual address 51 * @size size of the memory 52 * Return TEE_SUCCESS or appropriate error. 53 */ 54 TEE_Result stm32_rproc_unmap(uint32_t rproc_id, void *va, size_t size); 55 56 /* 57 * stm32_rproc_start() - start the remote processor core 58 * @rproc_id unique identifier of the remote processor 59 * Return TEE_SUCCESS or appropriate error. 60 */ 61 TEE_Result stm32_rproc_start(uint32_t rproc_id); 62 63 /* 64 * stm32_rproc_stop() - stop the remote processor core 65 * @rproc_id unique identifier of the remote processor 66 * Return TEE_SUCCESS or appropriate error. 67 */ 68 TEE_Result stm32_rproc_stop(uint32_t rproc_id); 69 70 /* 71 * stm32_rproc_clean_up_memories() - clear remote processor memory regions 72 * @rproc_id unique identifier of the remote processor 73 * Return TEE_SUCCESS or appropriate error. 74 */ 75 TEE_Result stm32_rproc_clean_up_memories(uint32_t rproc_id); 76 77 #ifdef CFG_STM32MP_REMOTEPROC 78 /* Return true is secure loading of remoteproc firmware is enabled */ 79 bool stm32_rproc_is_secure(uint32_t rproc_id); 80 #else stm32_rproc_is_secure(uint32_t rproc_id __unused)81static inline bool stm32_rproc_is_secure(uint32_t rproc_id __unused) 82 { 83 return false; 84 } 85 #endif 86 87 #endif /* __DRIVERS_STM32_REMOTEPROC_H */ 88