]> pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/mips/dec/kn02-irq.c
Merge branch 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik...
[linux-2.6-omap-h63xx.git] / arch / mips / dec / kn02-irq.c
1 /*
2  *      linux/arch/mips/dec/kn02-irq.c
3  *
4  *      DECstation 5000/200 (KN02) Control and Status Register
5  *      interrupts.
6  *
7  *      Copyright (c) 2002, 2003, 2005  Maciej W. Rozycki
8  *
9  *      This program is free software; you can redistribute it and/or
10  *      modify it under the terms of the GNU General Public License
11  *      as published by the Free Software Foundation; either version
12  *      2 of the License, or (at your option) any later version.
13  */
14
15 #include <linux/init.h>
16 #include <linux/irq.h>
17 #include <linux/types.h>
18
19 #include <asm/dec/kn02.h>
20
21
22 /*
23  * Bits 7:0 of the Control Register are write-only -- the
24  * corresponding bits of the Status Register have a different
25  * meaning.  Hence we use a cache.  It speeds up things a bit
26  * as well.
27  *
28  * There is no default value -- it has to be initialized.
29  */
30 u32 cached_kn02_csr;
31
32
33 static int kn02_irq_base;
34
35
36 static inline void unmask_kn02_irq(unsigned int irq)
37 {
38         volatile u32 *csr = (volatile u32 *)CKSEG1ADDR(KN02_SLOT_BASE +
39                                                        KN02_CSR);
40
41         cached_kn02_csr |= (1 << (irq - kn02_irq_base + 16));
42         *csr = cached_kn02_csr;
43 }
44
45 static inline void mask_kn02_irq(unsigned int irq)
46 {
47         volatile u32 *csr = (volatile u32 *)CKSEG1ADDR(KN02_SLOT_BASE +
48                                                        KN02_CSR);
49
50         cached_kn02_csr &= ~(1 << (irq - kn02_irq_base + 16));
51         *csr = cached_kn02_csr;
52 }
53
54 static void ack_kn02_irq(unsigned int irq)
55 {
56         mask_kn02_irq(irq);
57         iob();
58 }
59
60 static void end_kn02_irq(unsigned int irq)
61 {
62         if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
63                 unmask_kn02_irq(irq);
64 }
65
66 static struct irq_chip kn02_irq_type = {
67         .typename = "KN02-CSR",
68         .ack = ack_kn02_irq,
69         .mask = mask_kn02_irq,
70         .mask_ack = ack_kn02_irq,
71         .unmask = unmask_kn02_irq,
72         .end = end_kn02_irq,
73 };
74
75
76 void __init init_kn02_irqs(int base)
77 {
78         volatile u32 *csr = (volatile u32 *)CKSEG1ADDR(KN02_SLOT_BASE +
79                                                        KN02_CSR);
80         int i;
81
82         /* Mask interrupts. */
83         cached_kn02_csr &= ~KN02_CSR_IOINTEN;
84         *csr = cached_kn02_csr;
85         iob();
86
87         for (i = base; i < base + KN02_IRQ_LINES; i++)
88                 set_irq_chip_and_handler(i, &kn02_irq_type, handle_level_irq);
89
90         kn02_irq_base = base;
91 }