Skip to content

Commit b4f2553

Browse files
yangbolu1991kartben
authored andcommitted
arch: arm: irq: allow custom irq control for multi-level interrupts
Custom irq control for multi-level interrupts should be allowed. Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
1 parent 8b8d56a commit b4f2553

File tree

3 files changed

+52
-21
lines changed

3 files changed

+52
-21
lines changed

arch/arm/core/cortex_a_r/irq_manage.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,32 @@ extern void z_arm_reserved(void);
3333
* Generic Interrupt Controller (GIC) and therefore the architecture interrupt
3434
* control functions are mapped to the GIC driver interface.
3535
*
36+
* When GIC is used together with other interrupt controller for
37+
* multi-level interrupts support (i.e. CONFIG_MULTI_LEVEL_INTERRUPTS
38+
* is enabled), the architecture interrupt control functions are mapped
39+
* to the SoC layer in `include/arch/arm/irq.h`.
40+
* The exported arm interrupt control functions which are wrappers of
41+
* GIC control could be used for SoC to do level 1 irq control to implement SoC
42+
* layer interrupt control functions.
43+
*
3644
* When a custom interrupt controller is used (i.e.
3745
* CONFIG_ARM_CUSTOM_INTERRUPT_CONTROLLER is enabled), the architecture
3846
* interrupt control functions are mapped to the SoC layer in
3947
* `include/arch/arm/irq.h`.
4048
*/
4149

4250
#if !defined(CONFIG_ARM_CUSTOM_INTERRUPT_CONTROLLER)
43-
void arch_irq_enable(unsigned int irq)
51+
void arm_irq_enable(unsigned int irq)
4452
{
4553
arm_gic_irq_enable(irq);
4654
}
4755

48-
void arch_irq_disable(unsigned int irq)
56+
void arm_irq_disable(unsigned int irq)
4957
{
5058
arm_gic_irq_disable(irq);
5159
}
5260

53-
int arch_irq_is_enabled(unsigned int irq)
61+
int arm_irq_is_enabled(unsigned int irq)
5462
{
5563
return arm_gic_irq_is_enabled(irq);
5664
}
@@ -65,10 +73,11 @@ int arch_irq_is_enabled(unsigned int irq)
6573
* priority levels which are reserved: three for various types of exceptions,
6674
* and possibly one additional to support zero latency interrupts.
6775
*/
68-
void z_arm_irq_priority_set(unsigned int irq, unsigned int prio, uint32_t flags)
76+
void arm_irq_priority_set(unsigned int irq, unsigned int prio, uint32_t flags)
6977
{
7078
arm_gic_irq_set_priority(irq, prio, flags);
7179
}
80+
7281
#endif /* !CONFIG_ARM_CUSTOM_INTERRUPT_CONTROLLER */
7382

7483
void z_arm_fatal_error(unsigned int reason, const struct arch_esf *esf);

arch/arm/core/cortex_m/irq_manage.c

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,38 @@ extern void z_arm_reserved(void);
3232
#define REG_FROM_IRQ(irq) (irq / NUM_IRQS_PER_REG)
3333
#define BIT_FROM_IRQ(irq) (irq % NUM_IRQS_PER_REG)
3434

35+
/*
36+
* For Cortex-M core, the default interrupt controller is the ARM
37+
* NVIC and therefore the architecture interrupt control functions
38+
* are mapped to the NVIC driver interface.
39+
*
40+
* When NVIC is used together with other interrupt controller for
41+
* multi-level interrupts support (i.e. CONFIG_MULTI_LEVEL_INTERRUPTS
42+
* is enabled), the architecture interrupt control functions are mapped
43+
* to the SoC layer in `include/arch/arm/irq.h`.
44+
* The exported arm interrupt control functions which are wrappers of
45+
* NVIC control could be used for SoC to do level 1 irq control to implement SoC
46+
* layer interrupt control functions.
47+
*
48+
* When a custom interrupt controller is used (i.e.
49+
* CONFIG_ARM_CUSTOM_INTERRUPT_CONTROLLER is enabled), the architecture
50+
* interrupt control functions are mapped to the SoC layer in
51+
* `include/arch/arm/irq.h`.
52+
*/
53+
3554
#if !defined(CONFIG_ARM_CUSTOM_INTERRUPT_CONTROLLER)
3655

37-
void arch_irq_enable(unsigned int irq)
56+
void arm_irq_enable(unsigned int irq)
3857
{
3958
NVIC_EnableIRQ((IRQn_Type)irq);
4059
}
4160

42-
void arch_irq_disable(unsigned int irq)
61+
void arm_irq_disable(unsigned int irq)
4362
{
4463
NVIC_DisableIRQ((IRQn_Type)irq);
4564
}
4665

47-
int arch_irq_is_enabled(unsigned int irq)
66+
int arm_irq_is_enabled(unsigned int irq)
4867
{
4968
return NVIC->ISER[REG_FROM_IRQ(irq)] & BIT(BIT_FROM_IRQ(irq));
5069
}
@@ -58,7 +77,7 @@ int arch_irq_is_enabled(unsigned int irq)
5877
* of priority levels is a little complex, as there are some hardware
5978
* priority levels which are reserved.
6079
*/
61-
void z_arm_irq_priority_set(unsigned int irq, unsigned int prio, uint32_t flags)
80+
void arm_irq_priority_set(unsigned int irq, unsigned int prio, uint32_t flags)
6281
{
6382
/* The kernel may reserve some of the highest priority levels.
6483
* So we offset the requested priority level with the number

include/zephyr/arch/arm/irq.h

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,23 @@ GTEXT(z_soc_irq_eoi)
3535
#else
3636

3737
#if !defined(CONFIG_ARM_CUSTOM_INTERRUPT_CONTROLLER)
38+
extern void arm_irq_enable(unsigned int irq);
39+
extern void arm_irq_disable(unsigned int irq);
40+
extern int arm_irq_is_enabled(unsigned int irq);
41+
extern void arm_irq_priority_set(unsigned int irq, unsigned int prio, uint32_t flags);
42+
#if !defined(CONFIG_MULTI_LEVEL_INTERRUPTS)
43+
#define arch_irq_enable(irq) arm_irq_enable(irq)
44+
#define arch_irq_disable(irq) arm_irq_disable(irq)
45+
#define arch_irq_is_enabled(irq) arm_irq_is_enabled(irq)
46+
#define z_arm_irq_priority_set(irq, prio, flags) arm_irq_priority_set(irq, prio, flags)
47+
#endif
48+
#endif
3849

39-
extern void arch_irq_enable(unsigned int irq);
40-
extern void arch_irq_disable(unsigned int irq);
41-
extern int arch_irq_is_enabled(unsigned int irq);
42-
43-
/* internal routine documented in C file, needed by IRQ_CONNECT() macro */
44-
extern void z_arm_irq_priority_set(unsigned int irq, unsigned int prio,
45-
uint32_t flags);
46-
47-
#else
48-
50+
#if defined(CONFIG_ARM_CUSTOM_INTERRUPT_CONTROLLER) || defined(CONFIG_MULTI_LEVEL_INTERRUPTS)
4951
/*
50-
* When a custom interrupt controller is specified, map the architecture
51-
* interrupt control functions to the SoC layer interrupt control functions.
52+
* When a custom interrupt controller or multi-level interrupts is specified,
53+
* map the architecture interrupt control functions to the SoC layer interrupt
54+
* control functions.
5255
*/
5356

5457
void z_soc_irq_init(void);
@@ -69,7 +72,7 @@ void z_soc_irq_eoi(unsigned int irq);
6972
#define z_arm_irq_priority_set(irq, prio, flags) \
7073
z_soc_irq_priority_set(irq, prio, flags)
7174

72-
#endif /* !CONFIG_ARM_CUSTOM_INTERRUPT_CONTROLLER */
75+
#endif
7376

7477
extern void z_arm_int_exit(void);
7578

0 commit comments

Comments
 (0)