2018-08-04 16:23:16 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2017-07-11 09:00:26 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2012 Regents of the University of California
|
|
|
|
* Copyright (C) 2017 SiFive
|
2018-08-04 16:23:16 +08:00
|
|
|
* Copyright (C) 2018 Christoph Hellwig
|
2017-07-11 09:00:26 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/irqchip.h>
|
|
|
|
#include <linux/irqdomain.h>
|
2018-10-03 03:15:07 +08:00
|
|
|
#include <linux/seq_file.h>
|
|
|
|
#include <asm/smp.h>
|
2017-07-11 09:00:26 +08:00
|
|
|
|
2018-08-04 16:23:16 +08:00
|
|
|
/*
|
|
|
|
* Possible interrupt causes:
|
|
|
|
*/
|
2019-04-25 16:38:37 +08:00
|
|
|
#define INTERRUPT_CAUSE_SOFTWARE IRQ_S_SOFT
|
|
|
|
#define INTERRUPT_CAUSE_TIMER IRQ_S_TIMER
|
|
|
|
#define INTERRUPT_CAUSE_EXTERNAL IRQ_S_EXT
|
2018-08-04 16:23:16 +08:00
|
|
|
|
2018-10-03 03:15:07 +08:00
|
|
|
int arch_show_interrupts(struct seq_file *p, int prec)
|
|
|
|
{
|
|
|
|
show_ipi_stats(p, prec);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-10-18 13:20:05 +08:00
|
|
|
asmlinkage __visible void __irq_entry do_IRQ(struct pt_regs *regs)
|
2018-08-04 16:23:16 +08:00
|
|
|
{
|
|
|
|
struct pt_regs *old_regs = set_irq_regs(regs);
|
|
|
|
|
|
|
|
irq_enter();
|
2019-04-25 16:38:37 +08:00
|
|
|
switch (regs->scause & ~SCAUSE_IRQ_FLAG) {
|
2018-08-04 16:23:19 +08:00
|
|
|
case INTERRUPT_CAUSE_TIMER:
|
|
|
|
riscv_timer_interrupt();
|
|
|
|
break;
|
2018-08-04 16:23:16 +08:00
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
case INTERRUPT_CAUSE_SOFTWARE:
|
|
|
|
/*
|
|
|
|
* We only use software interrupts to pass IPIs, so if a non-SMP
|
|
|
|
* system gets one, then we don't know what to do.
|
|
|
|
*/
|
|
|
|
riscv_software_interrupt();
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
case INTERRUPT_CAUSE_EXTERNAL:
|
|
|
|
handle_arch_irq(regs);
|
|
|
|
break;
|
|
|
|
default:
|
2019-04-15 17:14:41 +08:00
|
|
|
pr_alert("unexpected interrupt cause 0x%lx", regs->scause);
|
|
|
|
BUG();
|
2018-08-04 16:23:16 +08:00
|
|
|
}
|
|
|
|
irq_exit();
|
|
|
|
|
|
|
|
set_irq_regs(old_regs);
|
|
|
|
}
|
|
|
|
|
2017-07-11 09:00:26 +08:00
|
|
|
void __init init_IRQ(void)
|
|
|
|
{
|
|
|
|
irqchip_init();
|
|
|
|
}
|