Skip to content

Commit 3856689

Browse files
nhutnguyenkcKhiemNguyenT
authored andcommitted
hal: renesas: rz: Initial support for IPM
Initial HAL support for IPM Signed-off-by: Phuc Pham <[email protected]> Signed-off-by: Nhut Nguyen <[email protected]>
1 parent 4dedba1 commit 3856689

File tree

5 files changed

+782
-0
lines changed

5 files changed

+782
-0
lines changed

drivers/rz/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@ zephyr_library_sources_ifdef(CONFIG_USE_RZ_FSP_SCIF_UART
2525

2626
zephyr_library_sources_ifdef(CONFIG_USE_RZ_FSP_ADC
2727
fsp/src/${SOC_SERIES_PREFIX}/r_adc_c/r_adc_c.c)
28+
29+
zephyr_library_sources_ifdef(CONFIG_USE_RZ_FSP_MHU
30+
fsp/src/${SOC_SERIES_PREFIX}/r_mhu_ns/r_mhu_ns.c)

drivers/rz/fsp/inc/api/r_mhu_api.h

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
/*
2+
* Copyright (c) 2020 - 2024 Renesas Electronics Corporation and/or its affiliates
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*/
6+
7+
/*******************************************************************************************************************//**
8+
* @ingroup RENESAS_INTERFACES
9+
* @defgroup MHU_API MHU Interface (for secure and non secure channels)
10+
* @brief Interface for Message Handling Unit
11+
*
12+
* @section MHU_API_SUMMARY Summary
13+
* The Message Handling Unit interface provides a common API for MHU HAL drivers.
14+
* The Message Handling Unit interface supports:
15+
* - Message communication between Cortex-A55 and Cortex-M33.
16+
* - 32-bit data can be communicated between CPUs via shared memory.
17+
*
18+
* Implemented by:
19+
* - @ref MHU_S
20+
* - @ref MHU_NS
21+
*
22+
* @{
23+
**********************************************************************************************************************/
24+
25+
/***********************************************************************************************************************
26+
* Includes
27+
**********************************************************************************************************************/
28+
29+
/* Register definitions, common services and error codes. */
30+
#include "bsp_api.h"
31+
32+
#ifndef R_MHU_API_H
33+
#define R_MHU_API_H
34+
35+
/* Common macro for FSP header files. There is also a corresponding FSP_FOOTER macro at the end of this file. */
36+
FSP_HEADER
37+
38+
/**********************************************************************************************************************
39+
* Macro definitions
40+
**********************************************************************************************************************/
41+
42+
/**********************************************************************************************************************
43+
* Typedef definitions
44+
**********************************************************************************************************************/
45+
46+
typedef enum e_mhu_send_type
47+
{
48+
MHU_SEND_TYPE_MSG = 0, ///< Channel for sending "message" and receiving "response".
49+
MHU_SEND_TYPE_RSP, ///< Channel for sending "response" and receiving "message".
50+
} mhu_send_type_t;
51+
52+
/** MHU callback parameter definition */
53+
typedef struct st_mhu_callback_args
54+
{
55+
/** Placeholder for user data. Set in @ref mhu_api_t::open function in @ref mhu_cfg_t. */
56+
void const * p_context;
57+
uint32_t channel; ///< Channel where the receive interrupt occurred.
58+
uint32_t msg; ///< 32-bit received data.
59+
} mhu_callback_args_t;
60+
61+
/** MHU configuration block */
62+
typedef struct st_mhu_cfg
63+
{
64+
/** Generic configuration */
65+
uint32_t channel; ///< Identifier recognizable by implementation
66+
uint8_t rx_ipl; ///< Receive interrupt priority
67+
IRQn_Type rx_irq; ///< Receive interrupt ID
68+
69+
/** Parameters to control software behavior */
70+
void (* p_callback)(mhu_callback_args_t * p_args); ///< Pointer to callback function
71+
72+
void const * p_shared_memory; ///< Pointer to 64-bit send/receive data buffer.
73+
74+
/** Placeholder for user data. Passed to the user callback in @ref mhu_callback_args_t. */
75+
void const * p_context;
76+
} mhu_cfg_t;
77+
78+
/** MHU control block. Allocate an instance specific control block to pass into the MHU API calls.
79+
* @par Implemented as
80+
* - mhu_instance_ctrl_t
81+
*/
82+
typedef void mhu_ctrl_t;
83+
84+
/** Interface definition for MHU */
85+
typedef struct st_mhu_api
86+
{
87+
/** Opens the MHU driver and initializes the hardware.
88+
* @par Implemented as
89+
* - @ref R_MHU_S_Open()
90+
* - @ref R_MHU_NS_Open()
91+
*
92+
* @param[in] p_ctrl Pointer to control block. Must be declared by user. Elements are set here.
93+
* @param[in] p_cfg Pointer to configuration structure.
94+
*/
95+
fsp_err_t (* open)(mhu_ctrl_t * const p_ctrl, mhu_cfg_t const * const p_cfg);
96+
97+
/** Performs a send operation on an MHU device.
98+
* @par Implemented as
99+
* - @ref R_MHU_S_MsgSend()
100+
* - @ref R_MHU_NS_MsgSend()
101+
*
102+
* @param[in] p_ctrl Pointer to control block set in mhu_api_t::open call.
103+
* @param[in] msg 32bit send data.
104+
*/
105+
fsp_err_t (* msgSend)(mhu_ctrl_t * const p_ctrl, uint32_t const msg);
106+
107+
/**
108+
* Specify callback function and optional context pointer and working memory pointer.
109+
* @par Implemented as
110+
* - @ref R_MHU_S_CallbackSet()
111+
* - @ref R_MHU_NS_CallbackSet()
112+
*
113+
* @param[in] p_ctrl Control block set in @ref mhu_api_t::open call for this channel.
114+
* @param[in] p_callback Callback function to register
115+
* @param[in] p_context Pointer to send to callback function
116+
* @param[in] p_callback_memory Pointer to volatile memory where callback structure can be allocated.
117+
* Callback arguments allocated here are only valid during the callback.
118+
*/
119+
fsp_err_t (* callbackSet)(mhu_ctrl_t * const p_api_ctrl, void (* p_callback) (mhu_callback_args_t *),
120+
void const * const p_context, mhu_callback_args_t * const p_callback_memory);
121+
122+
/** Closes the driver and releases the MHU device.
123+
* @par Implemented as
124+
* - @ref R_MHU_S_Close()
125+
* - @ref R_MHU_NS_Close()
126+
*
127+
* @param[in] p_ctrl Pointer to control block set in mhu_api_t::open call.
128+
*/
129+
fsp_err_t (* close)(mhu_ctrl_t * const p_ctrl);
130+
} mhu_api_t;
131+
132+
/** This structure encompasses everything that is needed to use an instance of this interface. */
133+
typedef struct st_mhu_instance
134+
{
135+
mhu_ctrl_t * p_ctrl; ///< Pointer to the control structure for this instance
136+
mhu_cfg_t const * p_cfg; ///< Pointer to the configuration structure for this instance
137+
mhu_api_t const * p_api; ///< Pointer to the API structure for this instance
138+
} mhu_instance_t;
139+
140+
/******************************************************************************************************************//**
141+
* @} (end addtogroup MHU_API)
142+
*********************************************************************************************************************/
143+
144+
/* Common macro for FSP header files. There is also a corresponding FSP_HEADER macro at the top of this file. */
145+
FSP_FOOTER
146+
147+
#endif /* R_MHU_API_H */
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/*
2+
* Copyright (c) 2020 - 2024 Renesas Electronics Corporation and/or its affiliates
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*/
6+
7+
/*******************************************************************************************************************//**
8+
* @addtogroup MHU_NS
9+
* @{
10+
**********************************************************************************************************************/
11+
12+
/***********************************************************************************************************************
13+
* Includes
14+
**********************************************************************************************************************/
15+
#include "r_mhu_api.h"
16+
#include "r_mhu_ns_cfg.h"
17+
18+
#ifndef R_MHU_NS_H
19+
#define R_MHU_NS_H
20+
21+
/* Common macro for FSP header files. There is also a corresponding FSP_FOOTER macro at the end of this file. */
22+
FSP_HEADER
23+
24+
/***********************************************************************************************************************
25+
* Macro definitions
26+
**********************************************************************************************************************/
27+
28+
/*************************************************************************************************
29+
* Type defines
30+
*************************************************************************************************/
31+
32+
/** Channel control block. DO NOT INITIALIZE. Initialization occurs when @ref mhu_api_t::open is called. */
33+
typedef struct st_mhu_ns_instance_ctrl
34+
{
35+
uint32_t open; ///< Indicates whether the open() API has been successfully called.
36+
mhu_cfg_t const * p_cfg; ///< Pointer to instance configuration
37+
R_MHU0_Type * p_regs; ///< Base register for this channel
38+
39+
uint32_t channel; ///< channel
40+
mhu_send_type_t send_type; ///< Send Type: Message or Response
41+
uint32_t * p_shared_memory_tx; ///< Pointer to send data area
42+
uint32_t * p_shared_memory_rx; ///< Pointer to recv data area
43+
44+
#if BSP_TZ_SECURE_BUILD
45+
bool callback_is_secure; ///< p_callback is in secure memory
46+
#endif
47+
48+
/* Pointer to callback and optional working memory */
49+
void (* p_callback)(mhu_callback_args_t *);
50+
51+
/* Pointer to non-secure memory that can be used to pass arguments to a callback in non-secure memory. */
52+
mhu_callback_args_t * p_callback_memory;
53+
54+
/* Pointer to context to be passed into callback function */
55+
void const * p_context;
56+
} mhu_ns_instance_ctrl_t;
57+
58+
/**********************************************************************************************************************
59+
* Exported global variables
60+
**********************************************************************************************************************/
61+
62+
/** @cond INC_HEADER_DEFS_SEC */
63+
/** Filled in Interface API structure for this Instance. */
64+
extern const mhu_api_t g_mhu_ns_on_mhu_ns;
65+
66+
/** @endcond */
67+
68+
/***********************************************************************************************************************
69+
* Public APIs
70+
**********************************************************************************************************************/
71+
fsp_err_t R_MHU_NS_Open(mhu_ctrl_t * p_ctrl, mhu_cfg_t const * const p_cfg);
72+
73+
fsp_err_t R_MHU_NS_MsgSend(mhu_ctrl_t * const p_ctrl, uint32_t const msg);
74+
75+
fsp_err_t R_MHU_NS_Close(mhu_ctrl_t * const p_ctrl);
76+
77+
fsp_err_t R_MHU_NS_CallbackSet(mhu_ctrl_t * const p_api_ctrl,
78+
void ( * p_callback ) (mhu_callback_args_t *),
79+
void const * const p_context,
80+
mhu_callback_args_t * const p_callback_memory);
81+
82+
void R_MHU_NS_IsrSub(uint32_t irq);
83+
84+
/** Common macro for FSP header files. There is also a corresponding FSP_HEADER macro at the top of this file. */
85+
FSP_FOOTER
86+
87+
#endif /* R_MHU_NS_H */
88+
89+
/*******************************************************************************************************************//**
90+
* @} (end defgroup MHU_NS)
91+
**********************************************************************************************************************/

0 commit comments

Comments
 (0)