1 /*
2  * Copyright 2023-2024 NXP
3  * All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  */
7 
8 #ifndef FSL_EZHV_H_
9 #define FSL_EZHV_H_
10 
11 #include "fsl_common.h"
12 
13 /*!
14  * @addtogroup ezhv
15  * @{
16  */
17 
18 /*******************************************************************************
19  * Definitions
20  ******************************************************************************/
21 
22 /*! @name Driver version */
23 /*@{*/
24 /*! @brief cache driver version. */
25 #define FSL_EZHV_DRIVER_VERSION (MAKE_VERSION(2, 0, 0))
26 /*@}*/
27 
28 /*! @brief Callback function prototype for the ezhv driver. */
29 typedef void (*ezhv_callback_t)(void *param);
30 
31 /*!
32  * @brief Structure for EZHV copy image to destination address
33  *
34  * Defines source and destination address for copying image with given size.
35  */
36 typedef struct _ezhv_copy_image
37 {
38     uint32_t srcAddr;
39     uint32_t destAddr;
40     uint32_t size;
41 } ezhv_copy_image_t;
42 
43 /*!
44  * @Brief List of EZHV APIs
45  */
46 typedef uint32_t ezhv_api_t;
47 
48 #define EZHV_API_MAX_ARG 8U
49 
50 /*!
51  * @brief parameters used by EZHV
52  */
53 typedef struct _ezhv_param {
54     ezhv_api_t ezhvApi;
55     uint32_t argc;
56     uint32_t *argv[EZHV_API_MAX_ARG];
57 } ezhv_param_t;
58 
59 /*! @brief ARM to wake up EZHV by 4 kinds of interrupt requests */
60 typedef enum _ARM2EZHV_INT {
61     kEZHV_ARM2EZHV_MEI = SYSCON4_ARM2EZHV_INT_CTRL_MEIP_MASK,
62     kEZHV_ARM2EZHV_SEI = SYSCON4_ARM2EZHV_INT_CTRL_SEIP_MASK,
63     kEZHV_ARM2EZHV_MSI = SYSCON4_ARM2EZHV_INT_CTRL_MSIP_MASK,
64     kEZHV_ARM2EZHV_MTI = SYSCON4_ARM2EZHV_INT_CTRL_MTIP_MASK,
65 } arm2ezhv_intctl_t;
66 
67 /*******************************************************************************
68  * Variables
69  ******************************************************************************/
70 
71 /*******************************************************************************
72  * API
73  ******************************************************************************/
74 
75 #if defined(__cplusplus)
76 extern "C" {
77 #endif
78 
79 /*!
80  * @brief Initialize the EZHV.
81  *
82  * @param ezhvCopyImage The information about the EZHV image to copy.
83  */
84 void EZHV_Init(ezhv_copy_image_t *ezhvCopyImage);
85 
86  /*!
87  * @brief Initialize the EZHV.
88  *
89  * This function is similar with EZHV_Init, the difference is this function
90  * does not install the firmware, the firmware could be installed using
91  * EZHV_InstallFirmware.
92  */
93 void EZHV_InitWithoutFirmware(void);
94 
95 /*!
96  * @brief install EZHV firmware by given image info
97  *
98  * @param ezhvCopyImage The information about the EZHV image to copy.
99  */
100 void EZHV_InstallFirmware(ezhv_copy_image_t *ezhvCopyImage);
101 
102 /*!
103  * @brief Boot EZHV from given address bootAddr
104  *
105  * @param bootAddr The boot address.
106  */
107 void EZHV_Boot(uint32_t bootAddr);
108 
109 /*!
110  * @brief Deinitialize the EZHV.
111  */
112 void EZHV_Deinit(void);
113 
114 /*!
115  * @brief Install the complete callback function.
116  *
117  * @param callback The callback called when EZHV program finished.
118  * @param param parameter for callback function
119  */
120 void EZHV_InstallCallback(ezhv_callback_t callback, void *param);
121 
122 /*!
123  * @brief Install the complete callback function..
124  *
125  * @return The base address of arm2ezhv paramter
126  */
127 uint32_t *EZHV_GetParaAddr(void);
128 
129 /*!
130  * @brief When EZHV is in wait state, this is used to wake up EZHV.
131  *
132  * @param arm2ezhvInt The interrupt to wake up EZHV.
133  */
134 void EZHV_WakeupEzhv(arm2ezhv_intctl_t arm2ezhvInt);
135 
136 /*!
137  * @brief Set the parameter used by EZHV.
138  *
139  * @param para Parameter written into shared mem between ARM and EZHV.
140  */
141 void EZHV_SetPara(ezhv_param_t *para);
142 /*@}*/
143 
144 #if defined(__cplusplus)
145 }
146 #endif
147 
148 /*! @}*/
149 
150 #endif
151