Linux-2.6.12-rc2
[pandora-kernel.git] / arch / arm / mach-s3c2410 / bast-irq.c
1 /* linux/arch/arm/mach-s3c2410/bast-irq.c
2  *
3  * Copyright (c) 2004 Simtec Electronics
4  *   Ben Dooks <ben@simtec.co.uk>
5  *
6  * http://www.simtec.co.uk/products/EB2410ITX/
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  *
22  * Modifications:
23  *     08-Jan-2003 BJD  Moved from central IRQ code
24  */
25
26
27 #include <linux/init.h>
28 #include <linux/module.h>
29 #include <linux/ioport.h>
30 #include <linux/ptrace.h>
31 #include <linux/sysdev.h>
32
33 #include <asm/hardware.h>
34 #include <asm/irq.h>
35 #include <asm/io.h>
36
37 #include <asm/mach/irq.h>
38 #include <asm/hardware/s3c2410/irq.h>
39
40 #if 0
41 #include <asm/debug-ll.h>
42 #endif
43
44 #define irqdbf(x...)
45 #define irqdbf2(x...)
46
47
48 /* handle PC104 ISA interrupts from the system CPLD */
49
50 /* table of ISA irq nos to the relevant mask... zero means
51  * the irq is not implemented
52 */
53 static unsigned char bast_pc104_irqmasks[] = {
54         0,   /* 0 */
55         0,   /* 1 */
56         0,   /* 2 */
57         1,   /* 3 */
58         0,   /* 4 */
59         2,   /* 5 */
60         0,   /* 6 */
61         4,   /* 7 */
62         0,   /* 8 */
63         0,   /* 9 */
64         8,   /* 10 */
65         0,   /* 11 */
66         0,   /* 12 */
67         0,   /* 13 */
68         0,   /* 14 */
69         0,   /* 15 */
70 };
71
72 static unsigned char bast_pc104_irqs[] = { 3, 5, 7, 10 };
73
74 static void
75 bast_pc104_mask(unsigned int irqno)
76 {
77         unsigned long temp;
78
79         temp = __raw_readb(BAST_VA_PC104_IRQMASK);
80         temp &= ~bast_pc104_irqmasks[irqno];
81         __raw_writeb(temp, BAST_VA_PC104_IRQMASK);
82
83         if (temp == 0)
84                 bast_extint_mask(IRQ_ISA);
85 }
86
87 static void
88 bast_pc104_ack(unsigned int irqno)
89 {
90         bast_extint_ack(IRQ_ISA);
91 }
92
93 static void
94 bast_pc104_unmask(unsigned int irqno)
95 {
96         unsigned long temp;
97
98         temp = __raw_readb(BAST_VA_PC104_IRQMASK);
99         temp |= bast_pc104_irqmasks[irqno];
100         __raw_writeb(temp, BAST_VA_PC104_IRQMASK);
101
102         bast_extint_unmask(IRQ_ISA);
103 }
104
105 static struct bast_pc104_chip = {
106         .mask        = bast_pc104_mask,
107         .unmask      = bast_pc104_unmask,
108         .ack         = bast_pc104_ack
109 };
110
111 static void
112 bast_irq_pc104_demux(unsigned int irq,
113                      struct irqdesc *desc,
114                      struct pt_regs *regs)
115 {
116         unsigned int stat;
117         unsigned int irqno;
118         int i;
119
120         stat = __raw_readb(BAST_VA_PC104_IRQREQ) & 0xf;
121
122         for (i = 0; i < 4 && stat != 0; i++) {
123                 if (stat & 1) {
124                         irqno = bast_pc104_irqs[i];
125                         desc = irq_desc + irqno;
126
127                         desc->handle(irqno, desc, regs);
128                 }
129
130                 stat >>= 1;
131         }
132 }