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>
30 #include <asm/mach-types.h>
32 #include <mach/hardware.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>
44 #include <asm/debug-ll.h>
51 /* handle PC104 ISA interrupts from the system CPLD */
53 /* table of ISA irq nos to the relevant mask... zero means
54 * the irq is not implemented
56 static unsigned char bast_pc104_irqmasks
[] = {
75 static unsigned char bast_pc104_irqs
[] = { 3, 5, 7, 10 };
78 bast_pc104_mask(unsigned int irqno
)
82 temp
= __raw_readb(BAST_VA_PC104_IRQMASK
);
83 temp
&= ~bast_pc104_irqmasks
[irqno
];
84 __raw_writeb(temp
, BAST_VA_PC104_IRQMASK
);
88 bast_pc104_maskack(unsigned int irqno
)
90 struct irq_desc
*desc
= irq_desc
+ IRQ_ISA
;
92 bast_pc104_mask(irqno
);
93 desc
->chip
->ack(IRQ_ISA
);
97 bast_pc104_unmask(unsigned int irqno
)
101 temp
= __raw_readb(BAST_VA_PC104_IRQMASK
);
102 temp
|= bast_pc104_irqmasks
[irqno
];
103 __raw_writeb(temp
, BAST_VA_PC104_IRQMASK
);
106 static struct irq_chip bast_pc104_chip
= {
107 .mask
= bast_pc104_mask
,
108 .unmask
= bast_pc104_unmask
,
109 .ack
= bast_pc104_maskack
113 bast_irq_pc104_demux(unsigned int irq
,
114 struct irq_desc
*desc
)
120 stat
= __raw_readb(BAST_VA_PC104_IRQREQ
) & 0xf;
122 if (unlikely(stat
== 0)) {
123 /* ack if we get an irq with nothing (ie, startup) */
125 desc
= irq_desc
+ IRQ_ISA
;
126 desc
->chip
->ack(IRQ_ISA
);
130 for (i
= 0; stat
!= 0; i
++, stat
>>= 1) {
132 irqno
= bast_pc104_irqs
[i
];
133 generic_handle_irq(irqno
);
139 static __init
int bast_irq_init(void)
143 if (machine_is_bast()) {
144 printk(KERN_INFO
"BAST PC104 IRQ routing, Copyright 2005 Simtec Electronics\n");
146 /* zap all the IRQs */
148 __raw_writeb(0x0, BAST_VA_PC104_IRQMASK
);
150 set_irq_chained_handler(IRQ_ISA
, bast_irq_pc104_demux
);
152 /* register our IRQs */
154 for (i
= 0; i
< 4; i
++) {
155 unsigned int irqno
= bast_pc104_irqs
[i
];
157 set_irq_chip(irqno
, &bast_pc104_chip
);
158 set_irq_handler(irqno
, handle_level_irq
);
159 set_irq_flags(irqno
, IRQF_VALID
);
166 arch_initcall(bast_irq_init
);