Skip to content

Commit ba23599

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 <tatsuya.ogawa.nx@renesas.com>
1 parent cfe81d9 commit ba23599

File tree

6 files changed

+314
-3
lines changed

6 files changed

+314
-3
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: 78 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,12 @@
3838
<0x0087300 0xff>,
3939
<0x00872f0 0x02>,
4040
<0x0087500 0x0f>,
41-
<0x0087510 0x01>,
42-
<0x0087514 0x01>;
43-
reg-names = "IR", "IER", "IPR", "FIR", "IRQCR", "IRQFLTE", "IRQFLTC0";
41+
<0x0087520 0x01>,
42+
<0x0087521 0x01>,
43+
<0x0087528 0x01>,
44+
<0x008752a 0x01>;
45+
reg-names = "IR", "IER", "IPR", "FIR", "IRQCR", "IRQFLTE",
46+
"IRQFLTE1", "IRQFLTC0", "IRQFLTC1";
4447

4548
swint1: swint1@872e0 {
4649
compatible = "renesas,rx-swint";
@@ -558,5 +561,77 @@
558561
zephyr,memory-region = "OFSM";
559562
status = "okay";
560563
};
564+
565+
group_irq_be0: grp_intc@87600 {
566+
compatible = "renesas,rx-grp-intc";
567+
interrupt-controller;
568+
label = "be0";
569+
reg = <0x00087600 0x04>,
570+
<0x00087640 0x04>;
571+
reg-names = "GRP", "GEN";
572+
interrupts = <106 4>;
573+
status = "disabled";
574+
#interrupt-cells = <2>;
575+
};
576+
577+
group_irq_bl0: grp_intc@87630 {
578+
compatible = "renesas,rx-grp-intc";
579+
interrupt-controller;
580+
label = "bl0";
581+
reg = <0x00087630 0x04>,
582+
<0x00087670 0x04>;
583+
reg-names = "GRP", "GEN";
584+
interrupts = <110 4>;
585+
status = "okay";
586+
#interrupt-cells = <2>;
587+
};
588+
589+
group_irq_bl1: grp_intc@87634 {
590+
compatible = "renesas,rx-grp-intc";
591+
interrupt-controller;
592+
label = "bl1";
593+
reg = <0x00087634 0x04>,
594+
<0x00087674 0x04>;
595+
reg-names = "GRP", "GEN";
596+
interrupts = <111 4>;
597+
status = "disabled";
598+
#interrupt-cells = <2>;
599+
};
600+
601+
group_irq_bl2: grp_intc@87638 {
602+
compatible = "renesas,rx-grp-intc";
603+
interrupt-controller;
604+
label = "bl2";
605+
reg = <0x00087638 0x04>,
606+
<0x00087678 0x04>;
607+
reg-names = "GRP", "GEN";
608+
interrupts = <107 4>;
609+
status = "disabled";
610+
#interrupt-cells = <2>;
611+
};
612+
613+
group_irq_al0: grp_intc@87830 {
614+
compatible = "renesas,rx-grp-intc";
615+
interrupt-controller;
616+
label = "al0";
617+
reg = <0x00087830 0x04>,
618+
<0x00087870 0x04>;
619+
reg-names = "GRP", "GEN";
620+
interrupts = <112 4>;
621+
status = "disabled";
622+
#interrupt-cells = <2>;
623+
};
624+
625+
group_irq_al1: grp_intc@87834 {
626+
compatible = "renesas,rx-grp-intc";
627+
interrupt-controller;
628+
label = "al1";
629+
reg = <0x00087834 0x04>,
630+
<0x00087874 0x04>;
631+
reg-names = "GRP", "GEN";
632+
interrupts = <113 4>;
633+
status = "disabled";
634+
#interrupt-cells = <2>;
635+
};
561636
};
562637
};
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)