Skip to content

Commit 0c60a31

Browse files
avpatelMarc Zyngier
authored andcommitted
irqchip/riscv-intc: Allow drivers to directly discover INTC hwnode
Various RISC-V drivers (such as SBI IPI, SBI Timer, SBI PMU, and KVM RISC-V) don't have associated DT node but these drivers need standard per-CPU (local) interrupts defined by the RISC-V privileged specification. We add riscv_get_intc_hwnode() in arch/riscv which allows RISC-V drivers not having DT node to discover INTC hwnode which in-turn helps these drivers to map per-CPU (local) interrupts provided by the INTC driver. Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reviewed-by: Atish Patra <atishp@rivosinc.com> Acked-by: Palmer Dabbelt <palmer@rivosinc.com> Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20230328035223.1480939-3-apatel@ventanamicro.com
1 parent 3ee9256 commit 0c60a31

3 files changed

Lines changed: 29 additions & 0 deletions

File tree

arch/riscv/include/asm/irq.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212

1313
#include <asm-generic/irq.h>
1414

15+
void riscv_set_intc_hwnode_fn(struct fwnode_handle *(*fn)(void));
16+
17+
struct fwnode_handle *riscv_get_intc_hwnode(void);
18+
1519
extern void __init init_IRQ(void);
1620

1721
#endif /* _ASM_RISCV_IRQ_H */

arch/riscv/kernel/irq.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,27 @@
77

88
#include <linux/interrupt.h>
99
#include <linux/irqchip.h>
10+
#include <linux/irqdomain.h>
11+
#include <linux/module.h>
1012
#include <linux/seq_file.h>
1113
#include <asm/smp.h>
1214

15+
static struct fwnode_handle *(*__get_intc_node)(void);
16+
17+
void riscv_set_intc_hwnode_fn(struct fwnode_handle *(*fn)(void))
18+
{
19+
__get_intc_node = fn;
20+
}
21+
22+
struct fwnode_handle *riscv_get_intc_hwnode(void)
23+
{
24+
if (__get_intc_node)
25+
return __get_intc_node();
26+
27+
return NULL;
28+
}
29+
EXPORT_SYMBOL_GPL(riscv_get_intc_hwnode);
30+
1331
int arch_show_interrupts(struct seq_file *p, int prec)
1432
{
1533
show_ipi_stats(p, prec);

drivers/irqchip/irq-riscv-intc.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ static const struct irq_domain_ops riscv_intc_domain_ops = {
9292
.xlate = irq_domain_xlate_onecell,
9393
};
9494

95+
static struct fwnode_handle *riscv_intc_hwnode(void)
96+
{
97+
return intc_domain->fwnode;
98+
}
99+
95100
static int __init riscv_intc_init(struct device_node *node,
96101
struct device_node *parent)
97102
{
@@ -126,6 +131,8 @@ static int __init riscv_intc_init(struct device_node *node,
126131
return rc;
127132
}
128133

134+
riscv_set_intc_hwnode_fn(riscv_intc_hwnode);
135+
129136
cpuhp_setup_state(CPUHP_AP_IRQ_RISCV_STARTING,
130137
"irqchip/riscv/intc:starting",
131138
riscv_intc_cpu_starting,

0 commit comments

Comments
 (0)