Merge branch 'upstream-fixes' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik...
[linux-2.6] / arch / mips / kernel / irq-rm7000.c
1 /*
2  * Copyright (C) 2003 Ralf Baechle
3  *
4  * This program is free software; you can redistribute  it and/or modify it
5  * under  the terms of  the GNU General  Public License as published by the
6  * Free Software Foundation;  either version 2 of the  License, or (at your
7  * option) any later version.
8  *
9  * Handler for RM7000 extended interrupts.  These are a non-standard
10  * feature so we handle them separately from standard interrupts.
11  */
12 #include <linux/init.h>
13 #include <linux/interrupt.h>
14 #include <linux/kernel.h>
15
16 #include <asm/irq_cpu.h>
17 #include <asm/mipsregs.h>
18 #include <asm/system.h>
19
20 static int irq_base;
21
22 static inline void unmask_rm7k_irq(unsigned int irq)
23 {
24         set_c0_intcontrol(0x100 << (irq - irq_base));
25 }
26
27 static inline void mask_rm7k_irq(unsigned int irq)
28 {
29         clear_c0_intcontrol(0x100 << (irq - irq_base));
30 }
31
32 static inline void rm7k_cpu_irq_enable(unsigned int irq)
33 {
34         unsigned long flags;
35
36         local_irq_save(flags);
37         unmask_rm7k_irq(irq);
38         local_irq_restore(flags);
39 }
40
41 static void rm7k_cpu_irq_disable(unsigned int irq)
42 {
43         unsigned long flags;
44
45         local_irq_save(flags);
46         mask_rm7k_irq(irq);
47         local_irq_restore(flags);
48 }
49
50 static unsigned int rm7k_cpu_irq_startup(unsigned int irq)
51 {
52         rm7k_cpu_irq_enable(irq);
53
54         return 0;
55 }
56
57 #define rm7k_cpu_irq_shutdown   rm7k_cpu_irq_disable
58
59 /*
60  * While we ack the interrupt interrupts are disabled and thus we don't need
61  * to deal with concurrency issues.  Same for rm7k_cpu_irq_end.
62  */
63 static void rm7k_cpu_irq_ack(unsigned int irq)
64 {
65         mask_rm7k_irq(irq);
66 }
67
68 static void rm7k_cpu_irq_end(unsigned int irq)
69 {
70         if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
71                 unmask_rm7k_irq(irq);
72 }
73
74 static hw_irq_controller rm7k_irq_controller = {
75         .typename = "RM7000",
76         .startup = rm7k_cpu_irq_startup,
77         .shutdown = rm7k_cpu_irq_shutdown,
78         .enable = rm7k_cpu_irq_enable,
79         .disable = rm7k_cpu_irq_disable,
80         .ack = rm7k_cpu_irq_ack,
81         .end = rm7k_cpu_irq_end,
82 };
83
84 void __init rm7k_cpu_irq_init(int base)
85 {
86         int i;
87
88         clear_c0_intcontrol(0x00000f00);                /* Mask all */
89
90         for (i = base; i < base + 4; i++) {
91                 irq_desc[i].status = IRQ_DISABLED;
92                 irq_desc[i].action = NULL;
93                 irq_desc[i].depth = 1;
94                 irq_desc[i].handler = &rm7k_irq_controller;
95         }
96
97         irq_base = base;
98 }