Skip to content

Commit 0daaf5e

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 0da1bae commit 0daaf5e

File tree

6 files changed

+273
-3
lines changed

6 files changed

+273
-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: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
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+
static struct k_spinlock lock;
39+
40+
int rx_grp_intc_set_callback(const struct device *dev, bsp_int_src_t vector, bsp_int_cb_t callback,
41+
void *context)
42+
{
43+
ARG_UNUSED(dev);
44+
bsp_int_err_t err;
45+
46+
err = R_BSP_InterruptWrite_EX(vector, callback, context);
47+
48+
if (err != BSP_INT_SUCCESS) {
49+
err = -EINVAL;
50+
}
51+
52+
return err;
53+
}
54+
55+
int rx_grp_intc_set_grp_int(const struct device *dev, bsp_int_src_t vector, bool set)
56+
{
57+
const struct rx_grp_int_cfg *cfg = dev->config;
58+
volatile bsp_int_ctrl_t group_priority;
59+
bsp_int_err_t err;
60+
61+
group_priority.ipl = cfg->prio;
62+
63+
k_spinlock_key_t key = k_spin_lock(&lock);
64+
65+
if (set) {
66+
/* ENABLE GROUP INTERRUPTS */
67+
err = R_BSP_InterruptControl(vector, BSP_INT_CMD_GROUP_INTERRUPT_ENABLE,
68+
(void *)&group_priority);
69+
} else {
70+
/* DISABLE GROUP INTERRUPTS */
71+
err = R_BSP_InterruptControl(vector, BSP_INT_CMD_GROUP_INTERRUPT_DISABLE, NULL);
72+
}
73+
74+
k_spin_unlock(&lock, key);
75+
76+
if (err != BSP_INT_SUCCESS) {
77+
return -EINVAL;
78+
}
79+
80+
return err;
81+
}
82+
83+
int rx_grp_intc_set_gen(const struct device *dev, int is_number, bool set)
84+
{
85+
const struct rx_grp_int_cfg *cfg = dev->config;
86+
87+
if (is_number < 0 || is_number > 31) {
88+
return -EINVAL;
89+
}
90+
91+
k_spinlock_key_t key = k_spin_lock(&lock);
92+
93+
if (set) {
94+
/* ENABLE GROUP INTERRUPTS */
95+
*cfg->gen |= (1U << is_number);
96+
} else {
97+
/* DISABLE GROUP INTERRUPTS */
98+
*cfg->gen &= ~(1U << is_number);
99+
}
100+
101+
k_spin_unlock(&lock, key);
102+
103+
return 0;
104+
}
105+
106+
static int rx_grp_intc_init(const struct device *dev)
107+
{
108+
const struct rx_grp_int_cfg *cfg = dev->config;
109+
110+
switch (cfg->vect) {
111+
case VECT_GROUP_BL0:
112+
IRQ_CONNECT(VECT_GROUP_BL0, cfg->prio, group_bl0_handler_isr, NULL, 0);
113+
break;
114+
case VECT_GROUP_BL1:
115+
IRQ_CONNECT(VECT_GROUP_BL1, cfg->prio, group_bl1_handler_isr, NULL, 0);
116+
break;
117+
case VECT_GROUP_BL2:
118+
IRQ_CONNECT(VECT_GROUP_BL2, cfg->prio, group_bl2_handler_isr, NULL, 0);
119+
break;
120+
case VECT_GROUP_AL0:
121+
IRQ_CONNECT(VECT_GROUP_AL0, cfg->prio, group_al0_handler_isr, NULL, 0);
122+
break;
123+
case VECT_GROUP_AL1:
124+
IRQ_CONNECT(VECT_GROUP_AL1, cfg->prio, group_al1_handler_isr, NULL, 0);
125+
break;
126+
default:
127+
/* ERROR */
128+
return -EINVAL;
129+
}
130+
131+
irq_enable(cfg->vect);
132+
133+
return 0;
134+
}
135+
136+
#define GRP_INT_RX_INIT(index) \
137+
static struct rx_grp_int_cfg rx_grp_int_##index##_cfg = { \
138+
.gen = (uint32_t *)DT_INST_REG_ADDR_BY_NAME(index, GEN), \
139+
.vect = DT_INST_IRQN(index), \
140+
.prio = DT_INST_IRQ(index, priority)}; \
141+
static int rx_grp_int_##index##_init(const struct device *dev) \
142+
{ \
143+
return rx_grp_intc_init(dev); \
144+
} \
145+
DEVICE_DT_INST_DEFINE(index, rx_grp_int_##index##_init, NULL, NULL, \
146+
&rx_grp_int_##index##_cfg, PRE_KERNEL_1, \
147+
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, NULL);
148+
149+
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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
int rx_grp_intc_set_callback(const struct device *dev, bsp_int_src_t vector, bsp_int_cb_t callback,
12+
void *context);
13+
int rx_grp_intc_set_grp_int(const struct device *dev, bsp_int_src_t vector, bool set);
14+
int rx_grp_intc_set_gen(const struct device *dev, int is_number, bool set);
15+
16+
#endif /* ZEPHYR_DRIVERS_INTERRUPT_CONTROLLER_INTC_RENESAS_RX_GRP_INT_H_ */

0 commit comments

Comments
 (0)