2018-08-04 15:23:16 +07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2017-07-11 08:00:26 +07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2012 Regents of the University of California
|
|
|
|
* Copyright (C) 2017 SiFive
|
2018-08-04 15:23:16 +07:00
|
|
|
* Copyright (C) 2018 Christoph Hellwig
|
2017-07-11 08:00:26 +07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/irqchip.h>
|
|
|
|
#include <linux/irqdomain.h>
|
2018-10-03 02:15:07 +07:00
|
|
|
#include <linux/seq_file.h>
|
|
|
|
#include <asm/smp.h>
|
2017-07-11 08:00:26 +07:00
|
|
|
|
2018-08-04 15:23:16 +07:00
|
|
|
/*
|
|
|
|
* Possible interrupt causes:
|
|
|
|
*/
|
|
|
|
#define INTERRUPT_CAUSE_SOFTWARE 1
|
|
|
|
#define INTERRUPT_CAUSE_TIMER 5
|
|
|
|
#define INTERRUPT_CAUSE_EXTERNAL 9
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The high order bit of the trap cause register is always set for
|
|
|
|
* interrupts, which allows us to differentiate them from exceptions
|
|
|
|
* quickly. The INTERRUPT_CAUSE_* macros don't contain that bit, so we
|
|
|
|
* need to mask it off.
|
|
|
|
*/
|
|
|
|
#define INTERRUPT_CAUSE_FLAG (1UL << (__riscv_xlen - 1))
|
|
|
|
|
2018-10-03 02:15:07 +07:00
|
|
|
int arch_show_interrupts(struct seq_file *p, int prec)
|
|
|
|
{
|
|
|
|
show_ipi_stats(p, prec);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-10-03 02:14:54 +07:00
|
|
|
asmlinkage void __irq_entry do_IRQ(struct pt_regs *regs)
|
2018-08-04 15:23:16 +07:00
|
|
|
{
|
|
|
|
struct pt_regs *old_regs = set_irq_regs(regs);
|
|
|
|
|
|
|
|
irq_enter();
|
2018-10-03 02:14:54 +07:00
|
|
|
switch (regs->scause & ~INTERRUPT_CAUSE_FLAG) {
|
2018-08-04 15:23:19 +07:00
|
|
|
case INTERRUPT_CAUSE_TIMER:
|
|
|
|
riscv_timer_interrupt();
|
|
|
|
break;
|
2018-08-04 15:23:16 +07: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 16:14:41 +07:00
|
|
|
pr_alert("unexpected interrupt cause 0x%lx", regs->scause);
|
|
|
|
BUG();
|
2018-08-04 15:23:16 +07:00
|
|
|
}
|
|
|
|
irq_exit();
|
|
|
|
|
|
|
|
set_irq_regs(old_regs);
|
|
|
|
}
|
|
|
|
|
2017-07-11 08:00:26 +07:00
|
|
|
void __init init_IRQ(void)
|
|
|
|
{
|
|
|
|
irqchip_init();
|
|
|
|
}
|