[MMC] Remove trailing whitespace in wbsd
[linux-2.6/verdex.git] / arch / mips / kernel / irq_cpu.c
blob2b936cf1ef70fe6f655cd235260912044a7e6368
1 /*
2 * Copyright 2001 MontaVista Software Inc.
3 * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
5 * Copyright (C) 2001 Ralf Baechle
7 * This file define the irq handler for MIPS CPU interrupts.
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
16 * Almost all MIPS CPUs define 8 interrupt sources. They are typically
17 * level triggered (i.e., cannot be cleared from CPU; must be cleared from
18 * device). The first two are software interrupts which we don't really
19 * use or support. The last one is usually the CPU timer interrupt if
20 * counter register is present or, for CPUs with an external FPU, by
21 * convention it's the FPU exception interrupt.
23 * Don't even think about using this on SMP. You have been warned.
25 * This file exports one global function:
26 * void mips_cpu_irq_init(int irq_base);
28 #include <linux/init.h>
29 #include <linux/interrupt.h>
30 #include <linux/kernel.h>
32 #include <asm/irq_cpu.h>
33 #include <asm/mipsregs.h>
34 #include <asm/system.h>
36 static int mips_cpu_irq_base;
38 static inline void unmask_mips_irq(unsigned int irq)
40 clear_c0_cause(0x100 << (irq - mips_cpu_irq_base));
41 set_c0_status(0x100 << (irq - mips_cpu_irq_base));
44 static inline void mask_mips_irq(unsigned int irq)
46 clear_c0_status(0x100 << (irq - mips_cpu_irq_base));
49 static inline void mips_cpu_irq_enable(unsigned int irq)
51 unsigned long flags;
53 local_irq_save(flags);
54 unmask_mips_irq(irq);
55 local_irq_restore(flags);
58 static void mips_cpu_irq_disable(unsigned int irq)
60 unsigned long flags;
62 local_irq_save(flags);
63 mask_mips_irq(irq);
64 local_irq_restore(flags);
67 static unsigned int mips_cpu_irq_startup(unsigned int irq)
69 mips_cpu_irq_enable(irq);
71 return 0;
74 #define mips_cpu_irq_shutdown mips_cpu_irq_disable
77 * While we ack the interrupt interrupts are disabled and thus we don't need
78 * to deal with concurrency issues. Same for mips_cpu_irq_end.
80 static void mips_cpu_irq_ack(unsigned int irq)
82 /* Only necessary for soft interrupts */
83 clear_c0_cause(0x100 << (irq - mips_cpu_irq_base));
85 mask_mips_irq(irq);
88 static void mips_cpu_irq_end(unsigned int irq)
90 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
91 unmask_mips_irq(irq);
94 static hw_irq_controller mips_cpu_irq_controller = {
95 "MIPS",
96 mips_cpu_irq_startup,
97 mips_cpu_irq_shutdown,
98 mips_cpu_irq_enable,
99 mips_cpu_irq_disable,
100 mips_cpu_irq_ack,
101 mips_cpu_irq_end,
102 NULL /* no affinity stuff for UP */
106 void __init mips_cpu_irq_init(int irq_base)
108 int i;
110 for (i = irq_base; i < irq_base + 8; i++) {
111 irq_desc[i].status = IRQ_DISABLED;
112 irq_desc[i].action = NULL;
113 irq_desc[i].depth = 1;
114 irq_desc[i].handler = &mips_cpu_irq_controller;
117 mips_cpu_irq_base = irq_base;