RT-AC56 3.0.0.4.374.37 core
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / arch / arm / mach-s3c2410 / bast-irq.c
blob8e9602f8a2d919c8dac7e56c53ce9cf063915009
1 /* linux/arch/arm/mach-s3c2410/bast-irq.c
3 * Copyright 2003-2005 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
6 * http://www.simtec.co.uk/products/EB2410ITX/
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.
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.
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
24 #include <linux/init.h>
25 #include <linux/module.h>
26 #include <linux/ioport.h>
27 #include <linux/sysdev.h>
28 #include <linux/io.h>
30 #include <asm/mach-types.h>
32 #include <mach/hardware.h>
33 #include <asm/irq.h>
35 #include <asm/mach/irq.h>
37 #include <mach/regs-irq.h>
38 #include <mach/bast-map.h>
39 #include <mach/bast-irq.h>
41 #include <plat/irq.h>
44 #define irqdbf(x...)
45 #define irqdbf2(x...)
48 /* handle PC104 ISA interrupts from the system CPLD */
50 /* table of ISA irq nos to the relevant mask... zero means
51 * the irq is not implemented
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 */
72 static unsigned char bast_pc104_irqs[] = { 3, 5, 7, 10 };
74 static void
75 bast_pc104_mask(unsigned int irqno)
77 unsigned long temp;
79 temp = __raw_readb(BAST_VA_PC104_IRQMASK);
80 temp &= ~bast_pc104_irqmasks[irqno];
81 __raw_writeb(temp, BAST_VA_PC104_IRQMASK);
84 static void
85 bast_pc104_maskack(unsigned int irqno)
87 struct irq_desc *desc = irq_desc + IRQ_ISA;
89 bast_pc104_mask(irqno);
90 desc->chip->ack(IRQ_ISA);
93 static void
94 bast_pc104_unmask(unsigned int irqno)
96 unsigned long temp;
98 temp = __raw_readb(BAST_VA_PC104_IRQMASK);
99 temp |= bast_pc104_irqmasks[irqno];
100 __raw_writeb(temp, BAST_VA_PC104_IRQMASK);
103 static struct irq_chip bast_pc104_chip = {
104 .mask = bast_pc104_mask,
105 .unmask = bast_pc104_unmask,
106 .ack = bast_pc104_maskack
109 static void
110 bast_irq_pc104_demux(unsigned int irq,
111 struct irq_desc *desc)
113 unsigned int stat;
114 unsigned int irqno;
115 int i;
117 stat = __raw_readb(BAST_VA_PC104_IRQREQ) & 0xf;
119 if (unlikely(stat == 0)) {
120 /* ack if we get an irq with nothing (ie, startup) */
122 desc = irq_desc + IRQ_ISA;
123 desc->chip->ack(IRQ_ISA);
124 } else {
125 /* handle the IRQ */
127 for (i = 0; stat != 0; i++, stat >>= 1) {
128 if (stat & 1) {
129 irqno = bast_pc104_irqs[i];
130 generic_handle_irq(irqno);
136 static __init int bast_irq_init(void)
138 unsigned int i;
140 if (machine_is_bast()) {
141 printk(KERN_INFO "BAST PC104 IRQ routing, Copyright 2005 Simtec Electronics\n");
143 /* zap all the IRQs */
145 __raw_writeb(0x0, BAST_VA_PC104_IRQMASK);
147 set_irq_chained_handler(IRQ_ISA, bast_irq_pc104_demux);
149 /* register our IRQs */
151 for (i = 0; i < 4; i++) {
152 unsigned int irqno = bast_pc104_irqs[i];
154 set_irq_chip(irqno, &bast_pc104_chip);
155 set_irq_handler(irqno, handle_level_irq);
156 set_irq_flags(irqno, IRQF_VALID);
160 return 0;
163 arch_initcall(bast_irq_init);