aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ramips/files/arch/mips/ralink/rt305x/irq.c
blob: fcac2dd86017f79fda6a5bba4252c8467faaaf33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
 *  Ralink RT305x SoC specific interrupt handling
 *
 *  Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
 *
 *  This program is free software; you can redistribute it and/or modify it
 *  under the terms of the GNU General Public License version 2 as published
 *  by the Free Software Foundation.
 */

#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/irq.h>

#include <asm/irq_cpu.h>
#include <asm/mipsregs.h>

#include <asm/mach-ralink/common.h>
#include <asm/mach-ralink/rt305x.h>
#include <asm/mach-ralink/rt305x_regs.h>

static void rt305x_intc_irq_dispatch(void)
{
	u32 pending;

	pending = ramips_intc_get_status();

	if (pending & RT305X_INTC_INT_TIMER0)
		do_IRQ(RT305X_INTC_IRQ_TIMER0);

	else if (pending & RT305X_INTC_INT_TIMER1)
		do_IRQ(RT305X_INTC_IRQ_TIMER1);

	else if (pending & RT305X_INTC_INT_UART0)
		do_IRQ(RT305X_INTC_IRQ_UART0);

	else if (pending & RT305X_INTC_INT_UART1)
		do_IRQ(RT305X_INTC_IRQ_UART1);

	else if (pending &  RT305X_INTC_INT_PERFC)
		do_IRQ(RT305X_INTC_IRQ_PERFC);

	else if (pending & RT305X_INTC_INT_OTG)
		do_IRQ(RT305X_INTC_IRQ_OTG);

	/* TODO: handle PIO interrupts as well */

	else
		spurious_interrupt();
}

asmlinkage void plat_irq_dispatch(void)
{
	unsigned long pending;

	pending = read_c0_status() & read_c0_cause() & ST0_IM;

	if (pending & STATUSF_IP7)
		do_IRQ(RT305X_CPU_IRQ_COUNTER);

	else if (pending & STATUSF_IP5)
		do_IRQ(RT305X_CPU_IRQ_FE);

	else if (pending & STATUSF_IP6)
		do_IRQ(RT305X_CPU_IRQ_WNIC);

	else if (pending & STATUSF_IP2)
		rt305x_intc_irq_dispatch();

	else
		spurious_interrupt();
}

void __init arch_init_irq(void)
{
	mips_cpu_irq_init();
	ramips_intc_irq_init(RT305X_INTC_BASE, RT305X_CPU_IRQ_INTC,
			     RT305X_INTC_IRQ_BASE);

	cp0_perfcount_irq = RT305X_INTC_IRQ_PERFC;
}