aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/emma2rh/markeins/irq.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/mips/emma2rh/markeins/irq.c')
-rw-r--r--arch/mips/emma2rh/markeins/irq.c134
1 files changed, 134 insertions, 0 deletions
diff --git a/arch/mips/emma2rh/markeins/irq.c b/arch/mips/emma2rh/markeins/irq.c
new file mode 100644
index 000000000000..76dc3faeaf4e
--- /dev/null
+++ b/arch/mips/emma2rh/markeins/irq.c
@@ -0,0 +1,134 @@
1/*
2 * arch/mips/emma2rh/markeins/irq.c
3 * This file defines the irq handler for EMMA2RH.
4 *
5 * Copyright (C) NEC Electronics Corporation 2004-2006
6 *
7 * This file is based on the arch/mips/ddb5xxx/ddb5477/irq.c
8 *
9 * Copyright 2001 MontaVista Software Inc.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25#include <linux/config.h>
26#include <linux/init.h>
27#include <linux/interrupt.h>
28#include <linux/irq.h>
29#include <linux/types.h>
30#include <linux/ptrace.h>
31#include <linux/delay.h>
32
33#include <asm/i8259.h>
34#include <asm/irq_cpu.h>
35#include <asm/system.h>
36#include <asm/mipsregs.h>
37#include <asm/debug.h>
38#include <asm/addrspace.h>
39#include <asm/bootinfo.h>
40
41#include <asm/emma2rh/emma2rh.h>
42
43/*
44 * IRQ mapping
45 *
46 * 0-7: 8 CPU interrupts
47 * 0 - software interrupt 0
48 * 1 - software interrupt 1
49 * 2 - most Vrc5477 interrupts are routed to this pin
50 * 3 - (optional) some other interrupts routed to this pin for debugg
51 * 4 - not used
52 * 5 - not used
53 * 6 - not used
54 * 7 - cpu timer (used by default)
55 *
56 */
57
58extern void emma2rh_sw_irq_init(u32 base);
59extern void emma2rh_gpio_irq_init(u32 base);
60extern void emma2rh_irq_init(u32 base);
61extern asmlinkage void emma2rh_irq_dispatch(struct pt_regs *regs);
62
63static struct irqaction irq_cascade = {
64 .handler = no_action,
65 .flags = 0,
66 .mask = CPU_MASK_NONE,
67 .name = "cascade",
68 .dev_id = NULL,
69 .next = NULL,
70};
71
72void __init arch_init_irq(void)
73{
74 u32 reg;
75
76 db_run(printk("markeins_irq_setup invoked.\n"));
77
78 /* by default, interrupts are disabled. */
79 emma2rh_out32(EMMA2RH_BHIF_INT_EN_0, 0);
80 emma2rh_out32(EMMA2RH_BHIF_INT_EN_1, 0);
81 emma2rh_out32(EMMA2RH_BHIF_INT_EN_2, 0);
82 emma2rh_out32(EMMA2RH_BHIF_INT1_EN_0, 0);
83 emma2rh_out32(EMMA2RH_BHIF_INT1_EN_1, 0);
84 emma2rh_out32(EMMA2RH_BHIF_INT1_EN_2, 0);
85 emma2rh_out32(EMMA2RH_BHIF_SW_INT_EN, 0);
86
87 clear_c0_status(0xff00);
88 set_c0_status(0x0400);
89
90#define GPIO_PCI (0xf<<15)
91 /* setup GPIO interrupt for PCI interface */
92 /* direction input */
93 reg = emma2rh_in32(EMMA2RH_GPIO_DIR);
94 emma2rh_out32(EMMA2RH_GPIO_DIR, reg & ~GPIO_PCI);
95 /* disable interrupt */
96 reg = emma2rh_in32(EMMA2RH_GPIO_INT_MASK);
97 emma2rh_out32(EMMA2RH_GPIO_INT_MASK, reg & ~GPIO_PCI);
98 /* level triggerd */
99 reg = emma2rh_in32(EMMA2RH_GPIO_INT_MODE);
100 emma2rh_out32(EMMA2RH_GPIO_INT_MODE, reg | GPIO_PCI);
101 reg = emma2rh_in32(EMMA2RH_GPIO_INT_CND_A);
102 emma2rh_out32(EMMA2RH_GPIO_INT_CND_A, reg & (~GPIO_PCI));
103 /* interrupt clear */
104 emma2rh_out32(EMMA2RH_GPIO_INT_ST, ~GPIO_PCI);
105
106 /* init all controllers */
107 emma2rh_irq_init(EMMA2RH_IRQ_BASE);
108 emma2rh_sw_irq_init(EMMA2RH_SW_IRQ_BASE);
109 emma2rh_gpio_irq_init(EMMA2RH_GPIO_IRQ_BASE);
110 mips_cpu_irq_init(CPU_IRQ_BASE);
111
112 /* setup cascade interrupts */
113 setup_irq(EMMA2RH_IRQ_BASE + EMMA2RH_SW_CASCADE, &irq_cascade);
114 setup_irq(EMMA2RH_IRQ_BASE + EMMA2RH_GPIO_CASCADE, &irq_cascade);
115 setup_irq(CPU_IRQ_BASE + CPU_EMMA2RH_CASCADE, &irq_cascade);
116}
117
118asmlinkage void plat_irq_dispatch(struct pt_regs *regs)
119{
120 unsigned int pending = read_c0_status() & read_c0_cause();
121
122 if (pending & STATUSF_IP7)
123 do_IRQ(CPU_IRQ_BASE + 7, regs);
124 else if (pending & STATUSF_IP2)
125 emma2rh_irq_dispatch(regs);
126 else if (pending & STATUSF_IP1)
127 do_IRQ(CPU_IRQ_BASE + 1, regs);
128 else if (pending & STATUSF_IP0)
129 do_IRQ(CPU_IRQ_BASE + 0, regs);
130 else
131 spurious_interrupt(regs);
132}
133
134