GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / arch / mips / brcm-boards / generic / irq.c
blobd2d10ae9ff23acad673e9a7a312506fdb3bfbd61
1 /*
2 * Generic interrupt control functions for Broadcom MIPS boards
4 * Copyright (C) 2012, Broadcom Corporation. All Rights Reserved.
5 *
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
13 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
15 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
16 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 * $Id: irq.c,v 1.1 2007-09-04 04:41:12 $
21 #include <linux/config.h>
22 #include <linux/init.h>
23 #include <linux/kernel.h>
24 #include <linux/types.h>
25 #include <linux/interrupt.h>
26 #include <linux/irq.h>
28 #include <asm/irq.h>
29 #include <asm/mipsregs.h>
30 #include <asm/gdb-stub.h>
32 #define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4 | IE_IRQ5)
34 extern asmlinkage void brcmIRQ(void);
35 extern asmlinkage unsigned int do_IRQ(int irq, struct pt_regs *regs);
37 void
38 plat_irq_dispatch(struct pt_regs *regs)
40 u32 cause;
42 cause = read_c0_cause() &
43 read_c0_status() &
44 CAUSEF_IP;
46 #ifdef CONFIG_KERNPROF
47 change_c0_status(cause | 1, 1);
48 #else
49 clear_c0_status(cause);
50 #endif
52 if (cause & CAUSEF_IP7)
53 do_IRQ(7, regs);
54 if (cause & CAUSEF_IP2)
55 do_IRQ(2, regs);
56 if (cause & CAUSEF_IP3)
57 do_IRQ(3, regs);
58 if (cause & CAUSEF_IP4)
59 do_IRQ(4, regs);
60 if (cause & CAUSEF_IP5)
61 do_IRQ(5, regs);
62 if (cause & CAUSEF_IP6)
63 do_IRQ(6, regs);
66 static void
67 enable_brcm_irq(unsigned int irq)
69 if (irq < 8)
70 set_c0_status(1 << (irq + 8));
71 else
72 set_c0_status(IE_IRQ0);
75 static void
76 disable_brcm_irq(unsigned int irq)
78 if (irq < 8)
79 clear_c0_status(1 << (irq + 8));
80 else
81 clear_c0_status(IE_IRQ0);
84 static void
85 ack_brcm_irq(unsigned int irq)
87 /* Already done in plat_irq_dispatch */
90 static unsigned int
91 startup_brcm_irq(unsigned int irq)
93 enable_brcm_irq(irq);
95 return 0; /* never anything pending */
98 static void
99 end_brcm_irq(unsigned int irq)
101 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
102 enable_brcm_irq(irq);
105 static struct hw_interrupt_type brcm_irq_type = {
106 typename: "MIPS",
107 startup: startup_brcm_irq,
108 shutdown: disable_brcm_irq,
109 enable: enable_brcm_irq,
110 disable: disable_brcm_irq,
111 ack: ack_brcm_irq,
112 end: end_brcm_irq,
113 NULL
116 void __init
117 init_IRQ(void)
119 int i;
121 for (i = 0; i < NR_IRQS; i++) {
122 irq_desc[i].status = IRQ_DISABLED;
123 irq_desc[i].action = 0;
124 irq_desc[i].depth = 1;
125 irq_desc[i].handler = &brcm_irq_type;
128 change_c0_status(ST0_IM, ALLINTS);
130 #ifdef CONFIG_KGDB
131 printk("Breaking into debugger...\n");
132 set_debug_traps();
133 breakpoint();
134 #endif