Zephyr API Documentation 4.4.0-rc1
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
irq.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2025 NVIDIA Corporation <jholdsworth@nvidia.com>
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
11
12#ifndef ZEPHYR_INCLUDE_ARCH_OR1K_IRQ_H_
13#define ZEPHYR_INCLUDE_ARCH_OR1K_IRQ_H_
14
15#include <openrisc/openriscregs.h>
16
17#define SPR_SR_IRQ_MASK (SPR_SR_IEE | SPR_SR_TEE)
18
19#define OR1K_PIC_NUM_INTERRUPTS 32
20
21#ifdef CONFIG_MULTI_LEVEL_INTERRUPTS
22
23/* for _soc_irq_*() */
24#include <soc.h>
25
26#ifdef CONFIG_2ND_LEVEL_INTERRUPTS
27#ifdef CONFIG_3RD_LEVEL_INTERRUPTS
28#define CONFIG_NUM_IRQS (OR1K_PIC_NUM_INTERRUPTS +\
29 (CONFIG_NUM_2ND_LEVEL_AGGREGATORS +\
30 CONFIG_NUM_3RD_LEVEL_AGGREGATORS) *\
31 CONFIG_MAX_IRQ_PER_AGGREGATOR)
32#else
33#define CONFIG_NUM_IRQS (OR1K_PIC_NUM_INTERRUPTS +\
34 CONFIG_NUM_2ND_LEVEL_AGGREGATORS *\
35 CONFIG_MAX_IRQ_PER_AGGREGATOR)
36#endif /* CONFIG_3RD_LEVEL_INTERRUPTS */
37#else
38#define CONFIG_NUM_IRQS OR1K_PIC_NUM_INTERRUPTS
39#endif /* CONFIG_2ND_LEVEL_INTERRUPTS */
40
41void z_soc_irq_init(void);
42void z_soc_irq_enable(unsigned int irq);
43void z_soc_irq_disable(unsigned int irq);
44int z_soc_irq_is_enabled(unsigned int irq);
45
46#define arch_irq_enable(irq) z_soc_irq_enable(irq)
47#define arch_irq_disable(irq) z_soc_irq_disable(irq)
48
49#define arch_irq_is_enabled(irq) z_soc_irq_is_enabled(irq)
50
51#ifdef CONFIG_DYNAMIC_INTERRUPTS
52extern int z_soc_irq_connect_dynamic(unsigned int irq, unsigned int priority,
53 void (*routine)(const void *parameter),
54 const void *parameter, uint32_t flags);
55#endif
56
57#else
58
59#define CONFIG_NUM_IRQS OR1K_PIC_NUM_INTERRUPTS
60
61#define arch_irq_enable(irq) openrisc_irq_enable(irq)
62#define arch_irq_disable(irq) openrisc_irq_disable(irq)
63
64#define arch_irq_is_enabled(irq) openrisc_irq_is_enabled(irq)
65
66#endif
67
68static ALWAYS_INLINE unsigned int arch_irq_lock(void)
69{
70 const uint32_t sr = openrisc_read_spr(SPR_SR);
71
72 openrisc_write_spr(SPR_SR, sr & ~SPR_SR_IRQ_MASK);
73 return (sr & SPR_SR_IRQ_MASK) ? 1 : 0;
74}
75
76static ALWAYS_INLINE void arch_irq_unlock(unsigned int key)
77{
78 const uint32_t sr = openrisc_read_spr(SPR_SR);
79
80 openrisc_write_spr(SPR_SR, key ? (sr | SPR_SR_IRQ_MASK) : (sr & ~SPR_SR_IRQ_MASK));
81}
82
83static ALWAYS_INLINE bool arch_irq_unlocked(unsigned int key)
84{
85 return key != 0;
86}
87
93static ALWAYS_INLINE void arch_irq_enable(unsigned int irq)
94{
95 const unsigned int key = arch_irq_lock();
96
97 openrisc_write_spr(SPR_PICMR, openrisc_read_spr(SPR_PICMR) | BIT(irq));
98 arch_irq_unlock(key);
99}
100
106static ALWAYS_INLINE void arch_irq_disable(unsigned int irq)
107{
108 const unsigned int key = arch_irq_lock();
109
110 openrisc_write_spr(SPR_PICMR, openrisc_read_spr(SPR_PICMR) & ~BIT(irq));
111 arch_irq_unlock(key);
112};
113
114static ALWAYS_INLINE int arch_irq_is_enabled(unsigned int irq)
115{
116 return (openrisc_read_spr(SPR_PICMR) & BIT(irq)) != 0;
117}
118
119#endif /* ZEPHYR_INCLUDE_ARCH_OR1K_IRQ_H_ */
#define arch_irq_disable(irq)
Definition irq.h:59
#define arch_irq_enable(irq)
Definition irq.h:58
#define arch_irq_is_enabled(irq)
Definition irq.h:60
static ALWAYS_INLINE unsigned int arch_irq_lock(void)
Definition irq.h:68
static ALWAYS_INLINE void arch_irq_unlock(unsigned int key)
Definition irq.h:76
#define SPR_SR_IRQ_MASK
Definition irq.h:17
static ALWAYS_INLINE bool arch_irq_unlocked(unsigned int key)
Definition irq.h:83
#define BIT(n)
Unsigned integer with bit position n set (signed in assembly language).
Definition util_macro.h:44
#define ALWAYS_INLINE
Definition common.h:161
flags
Definition parser.h:97
__UINT32_TYPE__ uint32_t
Definition stdint.h:90