convert brcm-2.4 to the new target structure
[openwrt.git] / target / linux / brcm-2.4 / files / arch / mips / bcm947xx / generic / irq.c
1 /*
2 * Generic interrupt control functions for Broadcom MIPS boards
3 *
4 * Copyright 2004, Broadcom Corporation
5 * All Rights Reserved.
6 *
7 * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8 * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
9 * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10 * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
11 *
12 * $Id: irq.c,v 1.1 2005/03/16 13:50:00 wbx Exp $
13 */
14
15 #include <linux/config.h>
16 #include <linux/init.h>
17 #include <linux/kernel.h>
18 #include <linux/types.h>
19 #include <linux/interrupt.h>
20 #include <linux/irq.h>
21
22 #include <asm/irq.h>
23 #include <asm/mipsregs.h>
24 #include <asm/gdb-stub.h>
25
26 #define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4 | IE_IRQ5)
27
28 extern asmlinkage void brcmIRQ(void);
29 extern asmlinkage unsigned int do_IRQ(int irq, struct pt_regs *regs);
30
31 void
32 brcm_irq_dispatch(struct pt_regs *regs)
33 {
34 u32 cause;
35
36 cause = read_c0_cause() &
37 read_c0_status() &
38 CAUSEF_IP;
39
40 #ifdef CONFIG_KERNPROF
41 change_c0_status(cause | 1, 1);
42 #else
43 clear_c0_status(cause);
44 #endif
45
46 if (cause & CAUSEF_IP7)
47 do_IRQ(7, regs);
48 if (cause & CAUSEF_IP2)
49 do_IRQ(2, regs);
50 if (cause & CAUSEF_IP3)
51 do_IRQ(3, regs);
52 if (cause & CAUSEF_IP4)
53 do_IRQ(4, regs);
54 if (cause & CAUSEF_IP5)
55 do_IRQ(5, regs);
56 if (cause & CAUSEF_IP6)
57 do_IRQ(6, regs);
58 }
59
60 static void
61 enable_brcm_irq(unsigned int irq)
62 {
63 if (irq < 8)
64 set_c0_status(1 << (irq + 8));
65 else
66 set_c0_status(IE_IRQ0);
67 }
68
69 static void
70 disable_brcm_irq(unsigned int irq)
71 {
72 if (irq < 8)
73 clear_c0_status(1 << (irq + 8));
74 else
75 clear_c0_status(IE_IRQ0);
76 }
77
78 static void
79 ack_brcm_irq(unsigned int irq)
80 {
81 /* Already done in brcm_irq_dispatch */
82 }
83
84 static unsigned int
85 startup_brcm_irq(unsigned int irq)
86 {
87 enable_brcm_irq(irq);
88
89 return 0; /* never anything pending */
90 }
91
92 static void
93 end_brcm_irq(unsigned int irq)
94 {
95 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
96 enable_brcm_irq(irq);
97 }
98
99 static struct hw_interrupt_type brcm_irq_type = {
100 typename: "MIPS",
101 startup: startup_brcm_irq,
102 shutdown: disable_brcm_irq,
103 enable: enable_brcm_irq,
104 disable: disable_brcm_irq,
105 ack: ack_brcm_irq,
106 end: end_brcm_irq,
107 NULL
108 };
109
110 void __init
111 init_IRQ(void)
112 {
113 int i;
114
115 for (i = 0; i < NR_IRQS; i++) {
116 irq_desc[i].status = IRQ_DISABLED;
117 irq_desc[i].action = 0;
118 irq_desc[i].depth = 1;
119 irq_desc[i].handler = &brcm_irq_type;
120 }
121
122 set_except_vector(0, brcmIRQ);
123 change_c0_status(ST0_IM, ALLINTS);
124
125 #ifdef CONFIG_REMOTE_DEBUG
126 printk("Breaking into debugger...\n");
127 set_debug_traps();
128 breakpoint();
129 #endif
130 }
This page took 0.053172 seconds and 5 git commands to generate.