2 * Copyright (C) 2003 Ralf Baechle
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.
9 * Handler for RM9000 extended interrupts. These are a non-standard
10 * feature so we handle them separately from standard interrupts.
12 #include <linux/init.h>
13 #include <linux/interrupt.h>
14 #include <linux/kernel.h>
15 #include <linux/module.h>
17 #include <asm/irq_cpu.h>
18 #include <asm/mipsregs.h>
19 #include <asm/system.h>
23 static inline void unmask_rm9k_irq(unsigned int irq)
25 set_c0_intcontrol(0x1000 << (irq - irq_base));
28 static inline void mask_rm9k_irq(unsigned int irq)
30 clear_c0_intcontrol(0x1000 << (irq - irq_base));
33 static inline void rm9k_cpu_irq_enable(unsigned int irq)
37 local_irq_save(flags);
39 local_irq_restore(flags);
42 static void rm9k_cpu_irq_disable(unsigned int irq)
46 local_irq_save(flags);
48 local_irq_restore(flags);
51 static unsigned int rm9k_cpu_irq_startup(unsigned int irq)
53 rm9k_cpu_irq_enable(irq);
58 #define rm9k_cpu_irq_shutdown rm9k_cpu_irq_disable
61 * Performance counter interrupts are global on all processors.
63 static void local_rm9k_perfcounter_irq_startup(void *args)
65 unsigned int irq = (unsigned int) args;
67 rm9k_cpu_irq_enable(irq);
70 static unsigned int rm9k_perfcounter_irq_startup(unsigned int irq)
72 on_each_cpu(local_rm9k_perfcounter_irq_startup, (void *) irq, 0, 1);
77 static void local_rm9k_perfcounter_irq_shutdown(void *args)
79 unsigned int irq = (unsigned int) args;
82 local_irq_save(flags);
84 local_irq_restore(flags);
87 static void rm9k_perfcounter_irq_shutdown(unsigned int irq)
89 on_each_cpu(local_rm9k_perfcounter_irq_shutdown, (void *) irq, 0, 1);
94 * While we ack the interrupt interrupts are disabled and thus we don't need
95 * to deal with concurrency issues. Same for rm9k_cpu_irq_end.
97 static void rm9k_cpu_irq_ack(unsigned int irq)
102 static void rm9k_cpu_irq_end(unsigned int irq)
104 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
105 unmask_rm9k_irq(irq);
108 static hw_irq_controller rm9k_irq_controller = {
109 .typename = "RM9000",
110 .startup = rm9k_cpu_irq_startup,
111 .shutdown = rm9k_cpu_irq_shutdown,
112 .enable = rm9k_cpu_irq_enable,
113 .disable = rm9k_cpu_irq_disable,
114 .ack = rm9k_cpu_irq_ack,
115 .end = rm9k_cpu_irq_end,
118 static hw_irq_controller rm9k_perfcounter_irq = {
119 .typename = "RM9000",
120 .startup = rm9k_perfcounter_irq_startup,
121 .shutdown = rm9k_perfcounter_irq_shutdown,
122 .enable = rm9k_cpu_irq_enable,
123 .disable = rm9k_cpu_irq_disable,
124 .ack = rm9k_cpu_irq_ack,
125 .end = rm9k_cpu_irq_end,
128 unsigned int rm9000_perfcount_irq;
130 EXPORT_SYMBOL(rm9000_perfcount_irq);
132 void __init rm9k_cpu_irq_init(int base)
136 clear_c0_intcontrol(0x0000f000); /* Mask all */
138 for (i = base; i < base + 4; i++) {
139 irq_desc[i].status = IRQ_DISABLED;
140 irq_desc[i].action = NULL;
141 irq_desc[i].depth = 1;
142 irq_desc[i].chip = &rm9k_irq_controller;
145 rm9000_perfcount_irq = base + 1;
146 irq_desc[rm9000_perfcount_irq].chip = &rm9k_perfcounter_irq;