Skip to content

Commit 9d0c74f

Browse files
TatsuyaOgawanxquytranpzz
authored andcommitted
drivers: interrupt-controller: Add support Group interrupt driver on RX
Add support Group interrupt driver on RX Signed-off-by: Tatsuya Ogawa <[email protected]>
1 parent b11639f commit 9d0c74f

File tree

6 files changed

+308
-0
lines changed

6 files changed

+308
-0
lines changed

drivers/interrupt_controller/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ zephyr_library_sources_ifdef(CONFIG_NXP_SIUL2_EIRQ intc_nxp_siul2_eirq.
4444
zephyr_library_sources_ifdef(CONFIG_NXP_S32_WKPU intc_wkpu_nxp_s32.c)
4545
zephyr_library_sources_ifdef(CONFIG_XMC4XXX_INTC intc_xmc4xxx.c)
4646
zephyr_library_sources_ifdef(CONFIG_NXP_PINT intc_nxp_pint.c)
47+
zephyr_library_sources_ifdef(CONFIG_RENESAS_RX_GRP_INTC intc_renesas_rx_grp_int.c)
4748
zephyr_library_sources_ifdef(CONFIG_RENESAS_RX_ICU intc_renesas_rx_icu.c)
4849
zephyr_library_sources_ifdef(CONFIG_RENESAS_RZ_EXT_IRQ intc_renesas_rz_ext_irq.c)
4950
zephyr_library_sources_ifdef(CONFIG_NXP_IRQSTEER intc_nxp_irqsteer.c)

drivers/interrupt_controller/Kconfig.renesas_rx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,10 @@ config RENESAS_RX_ICU
77
depends on DT_HAS_RENESAS_RX_ICU_ENABLED
88
help
99
Renesas RX series interrupt controller unit
10+
11+
config RENESAS_RX_GRP_INTC
12+
bool "Renesas RX series group interrupt"
13+
default y
14+
depends on DT_HAS_RENESAS_RX_GRP_INTC_ENABLED
15+
help
16+
Renesas RX series group interrupt feature
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
/*
2+
* Copyright (c) 2025 Renesas Electronics Corporation
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#define DT_DRV_COMPAT renesas_rx_grp_intc
7+
8+
#include <zephyr/device.h>
9+
#include <zephyr/irq.h>
10+
#include <zephyr/spinlock.h>
11+
#include <zephyr/drivers/interrupt_controller/intc_renesas_rx_grp_int.h>
12+
#include <errno.h>
13+
14+
extern void group_bl0_handler_isr(void);
15+
extern void group_bl1_handler_isr(void);
16+
extern void group_bl2_handler_isr(void);
17+
extern void group_al0_handler_isr(void);
18+
extern void group_al1_handler_isr(void);
19+
20+
#define VECT_GROUP_BL0 DT_IRQN(DT_NODELABEL(group_irq_bl0))
21+
#define VECT_GROUP_BL1 DT_IRQN(DT_NODELABEL(group_irq_bl1))
22+
#define VECT_GROUP_BL2 DT_IRQN(DT_NODELABEL(group_irq_bl2))
23+
#define VECT_GROUP_AL0 DT_IRQN(DT_NODELABEL(group_irq_al0))
24+
#define VECT_GROUP_AL1 DT_IRQN(DT_NODELABEL(group_irq_al1))
25+
26+
/**
27+
* @brief configuration data for a group interrupt device
28+
*/
29+
struct rx_grp_int_cfg {
30+
/* address of the Group Interrupt Request Enable Register (GENxxx) */
31+
volatile uint32_t *gen;
32+
/* vector number of the interrupt */
33+
const uint8_t vect;
34+
/* priority of the interrupt */
35+
const uint8_t prio;
36+
};
37+
38+
struct rx_grp_int_data {
39+
struct k_spinlock lock;
40+
};
41+
42+
int rx_grp_intc_set_callback(const struct device *dev, bsp_int_src_t vector, bsp_int_cb_t callback,
43+
void *context)
44+
{
45+
ARG_UNUSED(dev);
46+
bsp_int_err_t err;
47+
48+
err = R_BSP_InterruptWrite_EX(vector, callback, context);
49+
50+
if (err != BSP_INT_SUCCESS) {
51+
err = -EINVAL;
52+
}
53+
54+
return err;
55+
}
56+
57+
int rx_grp_intc_set_grp_int(const struct device *dev, bsp_int_src_t vector, bool set)
58+
{
59+
const struct rx_grp_int_cfg *cfg = dev->config;
60+
struct rx_grp_int_data *data = dev->data;
61+
volatile bsp_int_ctrl_t group_priority;
62+
bsp_int_err_t err;
63+
64+
group_priority.ipl = cfg->prio;
65+
66+
k_spinlock_key_t key = k_spin_lock(&data->lock);
67+
68+
if (set) {
69+
/* ENABLE GROUP INTERRUPTS */
70+
err = R_BSP_InterruptControl(vector, BSP_INT_CMD_GROUP_INTERRUPT_ENABLE,
71+
(void *)&group_priority);
72+
} else {
73+
/* DISABLE GROUP INTERRUPTS */
74+
err = R_BSP_InterruptControl(vector, BSP_INT_CMD_GROUP_INTERRUPT_DISABLE, NULL);
75+
}
76+
77+
k_spin_unlock(&data->lock, key);
78+
79+
if (err != BSP_INT_SUCCESS) {
80+
return -EINVAL;
81+
}
82+
83+
return err;
84+
}
85+
86+
int rx_grp_intc_set_gen(const struct device *dev, int is_number, bool set)
87+
{
88+
const struct rx_grp_int_cfg *cfg = dev->config;
89+
struct rx_grp_int_data *data = dev->data;
90+
91+
if (is_number < 0 || is_number > 31) {
92+
return -EINVAL;
93+
}
94+
95+
k_spinlock_key_t key = k_spin_lock(&data->lock);
96+
97+
if (set) {
98+
/* ENABLE GROUP INTERRUPTS */
99+
*cfg->gen |= (1U << is_number);
100+
} else {
101+
/* DISABLE GROUP INTERRUPTS */
102+
*cfg->gen &= ~(1U << is_number);
103+
}
104+
105+
k_spin_unlock(&data->lock, key);
106+
107+
return 0;
108+
}
109+
110+
static int rx_grp_intc_init(const struct device *dev)
111+
{
112+
const struct rx_grp_int_cfg *cfg = dev->config;
113+
114+
switch (cfg->vect) {
115+
case VECT_GROUP_BL0:
116+
IRQ_CONNECT(VECT_GROUP_BL0, cfg->prio, group_bl0_handler_isr, NULL, 0);
117+
break;
118+
case VECT_GROUP_BL1:
119+
IRQ_CONNECT(VECT_GROUP_BL1, cfg->prio, group_bl1_handler_isr, NULL, 0);
120+
break;
121+
case VECT_GROUP_BL2:
122+
IRQ_CONNECT(VECT_GROUP_BL2, cfg->prio, group_bl2_handler_isr, NULL, 0);
123+
break;
124+
case VECT_GROUP_AL0:
125+
IRQ_CONNECT(VECT_GROUP_AL0, cfg->prio, group_al0_handler_isr, NULL, 0);
126+
break;
127+
case VECT_GROUP_AL1:
128+
IRQ_CONNECT(VECT_GROUP_AL1, cfg->prio, group_al1_handler_isr, NULL, 0);
129+
break;
130+
default:
131+
/* ERROR */
132+
return -EINVAL;
133+
}
134+
135+
irq_enable(cfg->vect);
136+
137+
return 0;
138+
}
139+
140+
#define GRP_INT_RX_INIT(index) \
141+
static struct rx_grp_int_cfg rx_grp_int_##index##_cfg = { \
142+
.gen = (uint32_t *)DT_INST_REG_ADDR_BY_NAME(index, GEN), \
143+
.vect = DT_INST_IRQN(index), \
144+
.prio = DT_INST_IRQ(index, priority), \
145+
}; \
146+
static struct rx_grp_int_data rx_grp_int_##index##_data; \
147+
static int rx_grp_int_##index##_init(const struct device *dev) \
148+
{ \
149+
return rx_grp_intc_init(dev); \
150+
} \
151+
DEVICE_DT_INST_DEFINE(index, rx_grp_int_##index##_init, NULL, &rx_grp_int_##index##_data, \
152+
&rx_grp_int_##index##_cfg, PRE_KERNEL_1, \
153+
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, NULL);
154+
155+
DT_INST_FOREACH_STATUS_OKAY(GRP_INT_RX_INIT);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright (c) 2021 KT-Elektronik Klaucke und Partner GmbH
2+
# Copyright (c) 2025 Renesas Electronics Corporation
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
description: Renesas group interrupt
6+
compatible: "renesas,rx-grp-intc"
7+
8+
include: [interrupt-controller.yaml, base.yaml]
9+
10+
properties:
11+
reg:
12+
required: true
13+
14+
reg-names:
15+
required: true
16+
17+
"#interrupt-cells":
18+
const: 2
19+
20+
interrupt-cells:
21+
- irq
22+
- priority

dts/rx/renesas/rx26t-common.dtsi

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,5 +562,77 @@
562562
zephyr,memory-region = "OFSM";
563563
status = "okay";
564564
};
565+
566+
group_irq_be0: grp_intc@87600 {
567+
compatible = "renesas,rx-grp-intc";
568+
interrupt-controller;
569+
label = "be0";
570+
reg = <0x00087600 0x04>,
571+
<0x00087640 0x04>;
572+
reg-names = "GRP", "GEN";
573+
interrupts = <106 4>;
574+
status = "disabled";
575+
#interrupt-cells = <2>;
576+
};
577+
578+
group_irq_bl0: grp_intc@87630 {
579+
compatible = "renesas,rx-grp-intc";
580+
interrupt-controller;
581+
label = "bl0";
582+
reg = <0x00087630 0x04>,
583+
<0x00087670 0x04>;
584+
reg-names = "GRP", "GEN";
585+
interrupts = <110 4>;
586+
status = "okay";
587+
#interrupt-cells = <2>;
588+
};
589+
590+
group_irq_bl1: grp_intc@87634 {
591+
compatible = "renesas,rx-grp-intc";
592+
interrupt-controller;
593+
label = "bl1";
594+
reg = <0x00087634 0x04>,
595+
<0x00087674 0x04>;
596+
reg-names = "GRP", "GEN";
597+
interrupts = <111 4>;
598+
status = "disabled";
599+
#interrupt-cells = <2>;
600+
};
601+
602+
group_irq_bl2: grp_intc@87638 {
603+
compatible = "renesas,rx-grp-intc";
604+
interrupt-controller;
605+
label = "bl2";
606+
reg = <0x00087638 0x04>,
607+
<0x00087678 0x04>;
608+
reg-names = "GRP", "GEN";
609+
interrupts = <107 4>;
610+
status = "disabled";
611+
#interrupt-cells = <2>;
612+
};
613+
614+
group_irq_al0: grp_intc@87830 {
615+
compatible = "renesas,rx-grp-intc";
616+
interrupt-controller;
617+
label = "al0";
618+
reg = <0x00087830 0x04>,
619+
<0x00087870 0x04>;
620+
reg-names = "GRP", "GEN";
621+
interrupts = <112 4>;
622+
status = "disabled";
623+
#interrupt-cells = <2>;
624+
};
625+
626+
group_irq_al1: grp_intc@87834 {
627+
compatible = "renesas,rx-grp-intc";
628+
interrupt-controller;
629+
label = "al1";
630+
reg = <0x00087834 0x04>,
631+
<0x00087874 0x04>;
632+
reg-names = "GRP", "GEN";
633+
interrupts = <113 4>;
634+
status = "disabled";
635+
#interrupt-cells = <2>;
636+
};
565637
};
566638
};
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright (c) 2025 Renesas Electronics Corporation
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#ifndef ZEPHYR_DRIVERS_INTERRUPT_CONTROLLER_INTC_RENESAS_RX_GRP_INT_H_
7+
#define ZEPHYR_DRIVERS_INTERRUPT_CONTROLLER_INTC_RENESAS_RX_GRP_INT_H_
8+
9+
#include "platform.h"
10+
11+
/**
12+
* @brief Enables or disables a group interrupt for a given interrupt vector.
13+
*
14+
* @param dev RX group interrupt device.
15+
* @param vector The interrupt vector (bsp_int_src_t) to be controlled.
16+
* @param set A boolean indicating enable or disable.
17+
*
18+
* @retval 0 If successful.
19+
* @retval -EINVAL if the interrupt control operation fails.
20+
*/
21+
int rx_grp_intc_set_grp_int(const struct device *dev, bsp_int_src_t vector, bool set);
22+
23+
/**
24+
* @brief Enables or disables a specific group interrupt source by setting or clearing the
25+
* corresponding bit (is_number) in the group interrupt register.
26+
*
27+
* @param dev RX group interrupt device.
28+
* @param is_number Index of the interrupt source (0–31) within the group.
29+
* @param set A boolean indicating enable or disable.
30+
*
31+
* @retval 0 If successful.
32+
* @retval -EINVAL if the interrupt control operation fails.
33+
*/
34+
int rx_grp_intc_set_gen(const struct device *dev, int is_number, bool set);
35+
36+
/**
37+
* @brief Registers a callback function for a specific group interrupt source (vector). When the
38+
* interrupt is triggered, the provided callback is executed with the associated context.
39+
*
40+
* @param dev RX group interrupt device.
41+
* @param vector Interrupt source to attach the callback to.
42+
* @param callback Function to be called when the interrupt occurs.
43+
* @param context Pointer to user-defined data passed to the callback.
44+
*
45+
* @retval 0 if successful.
46+
* @retval -EINVAL if the callback registration fails.
47+
*/
48+
int rx_grp_intc_set_callback(const struct device *dev, bsp_int_src_t vector, bsp_int_cb_t callback,
49+
void *context);
50+
51+
#endif /* ZEPHYR_DRIVERS_INTERRUPT_CONTROLLER_INTC_RENESAS_RX_GRP_INT_H_ */

0 commit comments

Comments
 (0)