1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /* 3 * Copyright 2020-2022 NXP 4 */ 5 #ifndef __DRIVERS_IMX_MU_H 6 #define __DRIVERS_IMX_MU_H 7 8 #include <tee_api_types.h> 9 #include <types_ext.h> 10 #include <util.h> 11 12 #define IMX_MU_DATA_U32(mesg, idx) ((mesg)->data.u32[(idx)]) 13 #define IMX_MU_DATA_U16(mesg, idx) ((mesg)->data.u16[(idx)]) 14 #define IMX_MU_DATA_U8(mesg, idx) ((mesg)->data.u8[(idx)]) 15 16 #define IMX_MU_MSG_SIZE 17 17 #define IMX_MU_NB_CHANNEL 4 18 19 #if defined(CFG_MX8ULP) || defined(CFG_MX93) || defined(CFG_MX91) || \ 20 defined(CFG_MX95) 21 struct imx_mu_msg_header { 22 uint8_t version; 23 uint8_t size; 24 uint8_t command; 25 uint8_t tag; 26 }; 27 #elif defined(CFG_MX8QM) || defined(CFG_MX8QX) || defined(CFG_MX8DXL) 28 struct imx_mu_msg_header { 29 uint8_t version; 30 uint8_t size; 31 uint8_t tag; 32 uint8_t command; 33 }; 34 #else 35 #error "Platform not supported" 36 #endif 37 38 /* 39 * i.MX MU message format 40 * Note: the header format differs depending of the platform. 41 */ 42 struct imx_mu_msg { 43 struct imx_mu_msg_header header; 44 union { 45 uint32_t u32[IMX_MU_MSG_SIZE]; 46 uint16_t u16[IMX_MU_MSG_SIZE * 2]; 47 uint8_t u8[IMX_MU_MSG_SIZE * 4]; 48 } data; 49 }; 50 51 /* 52 * Initialize the MU interface 53 * 54 * @base: virtual base address of the MU controller 55 */ 56 void imx_mu_init(vaddr_t base); 57 58 /* 59 * Initiate a communication with the external controller. It sends a message 60 * and return the answer of the controller. 61 * 62 * @base: virtual base address of the MU controller 63 * @[in/out]msg: message sent and received 64 * @wait_for_answer: true if an answer from the controller is expected, false 65 * otherwise 66 */ 67 TEE_Result imx_mu_call(vaddr_t base, struct imx_mu_msg *msg, 68 bool wait_for_answer); 69 #endif /* __DRIVERS_IMX_MU_H */ 70