2018-08-04 11:23:16 +03:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2017-07-11 04:00:26 +03:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2012 Regents of the University of California
|
|
|
|
* Copyright (C) 2017 SiFive
|
2018-08-04 11:23:16 +03:00
|
|
|
* Copyright (C) 2018 Christoph Hellwig
|
2017-07-11 04:00:26 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/irqchip.h>
|
|
|
|
#include <linux/irqdomain.h>
|
2018-10-02 22:15:07 +03:00
|
|
|
#include <linux/seq_file.h>
|
|
|
|
#include <asm/smp.h>
|
2017-07-11 04:00:26 +03:00
|
|
|
|
2018-08-04 11:23:16 +03:00
|
|
|
/*
|
|
|
|
* Possible interrupt causes:
|
|
|
|
*/
|
2019-04-25 11:38:37 +03: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 11:23:16 +03:00
|
|
|
|
2018-10-02 22:15:07 +03:00
|
|
|
int arch_show_interrupts(struct seq_file *p, int prec)
|
|
|
|
{
|
|
|
|
show_ipi_stats(p, prec);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-10-02 22:14:54 +03:00
|
|
|
asmlinkage void __irq_entry do_IRQ(struct pt_regs *regs)
|
2018-08-04 11:23:16 +03:00
|
|
|
{
|
|
|
|
struct pt_regs *old_regs = set_irq_regs(regs);
|
|
|
|
|
|
|
|
irq_enter();
|
2019-04-25 11:38:37 +03:00
|
|
|
switch (regs->scause & ~SCAUSE_IRQ_FLAG) {
|
2018-08-04 11:23:19 +03:00
|
|
|
case INTERRUPT_CAUSE_TIMER:
|
|
|
|
riscv_timer_interrupt();
|
|
|
|
break;
|
2018-08-04 11:23:16 +03: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 12:14:41 +03:00
|
|
|
pr_alert("unexpected interrupt cause 0x%lx", regs->scause);
|
|
|
|
BUG();
|
2018-08-04 11:23:16 +03:00
|
|
|
}
|
|
|
|
irq_exit();
|
|
|
|
|
|
|
|
set_irq_regs(old_regs);
|
|
|
|
}
|
|
|
|
|
2017-07-11 04:00:26 +03:00
|
|
|
void __init init_IRQ(void)
|
|
|
|
{
|
|
|
|
irqchip_init();
|
|
|
|
}
|