Skip to content

Commit b88839a

Browse files
Quang LeKhiemNguyenT
authored andcommitted
hal: renesas: rz: Add external interrutp support for RZ/A
Add external interrupt support for RZ/A Signed-off-by: Quang Le <[email protected]> Signed-off-by: Nhut Nguyen <[email protected]>
1 parent c6fc0d0 commit b88839a

File tree

7 files changed

+929
-3
lines changed

7 files changed

+929
-3
lines changed

drivers/rz/CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,14 @@ zephyr_library_sources_ifdef(CONFIG_USE_RZ_FSP_IIC_MASTER
5959
zephyr_library_sources_ifdef(CONFIG_USE_RZ_FSP_GTM
6060
fsp/src/${SOC_SERIES_PREFIX}/r_gtm/r_gtm.c)
6161

62-
if("${CONFIG_SOC_SERIES}" MATCHES "rzg.*")
62+
if(CONFIG_DT_HAS_RENESAS_RZ_INTC_ENABLED)
6363
zephyr_library_sources_ifdef(CONFIG_USE_RZ_FSP_EXT_IRQ
64-
fsp/src/${SOC_SERIES_PREFIX}/r_intc_irq/r_intc_irq.c
64+
fsp/src/${SOC_SERIES_PREFIX}/r_intc_irq/r_intc_irq.c)
65+
zephyr_library_sources_ifdef(CONFIG_RENESAS_RZ_INTC_HAS_NMI
6566
fsp/src/${SOC_SERIES_PREFIX}/r_intc_nmi/r_intc_nmi.c)
66-
elseif("${CONFIG_SOC_SERIES}" MATCHES "rz[tn].*")
67+
endif()
68+
69+
if(CONFIG_DT_HAS_RENESAS_RZ_ICU_ENABLED)
6770
zephyr_library_sources_ifdef(CONFIG_USE_RZ_FSP_EXT_IRQ
6871
fsp/src/${SOC_SERIES_PREFIX}/r_icu/r_icu.c)
6972
endif()
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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 INTC_IRQ
9+
* @{
10+
**********************************************************************************************************************/
11+
12+
#ifndef R_INTC_IRQ_H
13+
#define R_INTC_IRQ_H
14+
15+
/***********************************************************************************************************************
16+
* Includes
17+
**********************************************************************************************************************/
18+
#include "bsp_api.h"
19+
#include "r_external_irq_api.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+
* Typedef definitions
30+
*********************************************************************************************************************/
31+
32+
/** INTC_IRQ private control block. DO NOT MODIFY. Initialization occurs when R_INTC_IRQ_ExternalIrqOpen is called. */
33+
typedef struct st_intc_irq_instance_ctrl
34+
{
35+
uint32_t open; ///< Used to determine if channel control block is in use
36+
IRQn_Type irq; ///< Interrupt number
37+
uint8_t channel; ///< Channel
38+
39+
#if BSP_TZ_SECURE_BUILD
40+
external_irq_callback_args_t * p_callback_memory; // Pointer to non-secure memory that can be used to pass arguments to a callback in non-secure memory.
41+
#endif
42+
void (* p_callback)(external_irq_callback_args_t * p_args); // Pointer to callback that is called when an edge is detected on the external irq pin.
43+
44+
/** Placeholder for user data. Passed to the user callback in ::external_irq_callback_args_t. */
45+
void const * p_context;
46+
} intc_irq_instance_ctrl_t;
47+
48+
/**********************************************************************************************************************
49+
* Exported global variables
50+
**********************************************************************************************************************/
51+
52+
/** @cond INC_HEADER_DEFS_SEC */
53+
/** Filled in Interface API structure for this Instance. */
54+
extern const external_irq_api_t g_external_irq_on_intc_irq;
55+
56+
/** @endcond */
57+
58+
/***********************************************************************************************************************
59+
* Public APIs
60+
**********************************************************************************************************************/
61+
fsp_err_t R_INTC_IRQ_ExternalIrqOpen(external_irq_ctrl_t * const p_api_ctrl, external_irq_cfg_t const * const p_cfg);
62+
63+
fsp_err_t R_INTC_IRQ_ExternalIrqEnable(external_irq_ctrl_t * const p_api_ctrl);
64+
65+
fsp_err_t R_INTC_IRQ_ExternalIrqDisable(external_irq_ctrl_t * const p_api_ctrl);
66+
67+
fsp_err_t R_INTC_IRQ_ExternalIrqCallbackSet(external_irq_ctrl_t * const p_api_ctrl,
68+
void ( * p_callback)(
69+
external_irq_callback_args_t *),
70+
void const * const p_context,
71+
external_irq_callback_args_t * const p_callback_memory);
72+
73+
fsp_err_t R_INTC_IRQ_ExternalIrqClose(external_irq_ctrl_t * const p_api_ctrl);
74+
75+
/*******************************************************************************************************************//**
76+
* @} (end defgroup INTC_IRQ)
77+
**********************************************************************************************************************/
78+
79+
/* Common macro for FSP header files. There is also a corresponding FSP_HEADER macro at the top of this file. */
80+
FSP_FOOTER
81+
82+
#endif // R_INTC_IRQ_H
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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 INTC_NMI
9+
* @{
10+
**********************************************************************************************************************/
11+
12+
#ifndef R_INTC_NMI_H
13+
#define R_INTC_NMI_H
14+
15+
/***********************************************************************************************************************
16+
* Includes
17+
**********************************************************************************************************************/
18+
#include "bsp_api.h"
19+
#include "r_external_irq_api.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+
* Typedef definitions
30+
*********************************************************************************************************************/
31+
32+
/** INTC_NMI private control block. DO NOT MODIFY. Initialization occurs when R_INTC_NMI_ExternalIrqOpen is called. */
33+
typedef struct st_intc_nmi_instance_ctrl
34+
{
35+
uint32_t open; ///< Used to determine if channel control block is in use
36+
IRQn_Type irq; ///< Interrupt number
37+
uint8_t channel; ///< Channel
38+
39+
#if BSP_TZ_SECURE_BUILD
40+
external_irq_callback_args_t * p_callback_memory; // Pointer to non-secure memory that can be used to pass arguments to a callback in non-secure memory.
41+
#endif
42+
void (* p_callback)(external_irq_callback_args_t * p_args); // Pointer to callback that is called when an edge is detected on the external irq pin.
43+
44+
/** Placeholder for user data. Passed to the user callback in ::external_irq_callback_args_t. */
45+
void const * p_context;
46+
} intc_nmi_instance_ctrl_t;
47+
48+
/**********************************************************************************************************************
49+
* Exported global variables
50+
**********************************************************************************************************************/
51+
52+
/** @cond INC_HEADER_DEFS_SEC */
53+
/** Filled in Interface API structure for this Instance. */
54+
extern const external_irq_api_t g_external_irq_on_intc_nmi;
55+
56+
/** @endcond */
57+
58+
/***********************************************************************************************************************
59+
* Public APIs
60+
**********************************************************************************************************************/
61+
fsp_err_t R_INTC_NMI_ExternalIrqOpen(external_irq_ctrl_t * const p_api_ctrl, external_irq_cfg_t const * const p_cfg);
62+
63+
fsp_err_t R_INTC_NMI_ExternalIrqEnable(external_irq_ctrl_t * const p_api_ctrl);
64+
65+
fsp_err_t R_INTC_NMI_ExternalIrqDisable(external_irq_ctrl_t * const p_api_ctrl);
66+
67+
fsp_err_t R_INTC_NMI_ExternalIrqCallbackSet(external_irq_ctrl_t * const p_api_ctrl,
68+
void ( * p_callback)(
69+
external_irq_callback_args_t *),
70+
void const * const p_context,
71+
external_irq_callback_args_t * const p_callback_memory);
72+
73+
fsp_err_t R_INTC_NMI_ExternalIrqClose(external_irq_ctrl_t * const p_api_ctrl);
74+
75+
/*******************************************************************************************************************//**
76+
* @} (end defgroup INTC_NMI)
77+
**********************************************************************************************************************/
78+
79+
/* Common macro for FSP header files. There is also a corresponding FSP_HEADER macro at the top of this file. */
80+
FSP_FOOTER
81+
82+
#endif // R_INTC_NMI_H

0 commit comments

Comments
 (0)