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/device.h>
31 #include <asm/mach-types.h>
32 #include <asm/mach/irq.h>
34 #include <mach/hardware.h>
35 #include <mach/regs-irq.h>
42 /* handle PC104 ISA interrupts from the system CPLD */
44 /* table of ISA irq nos to the relevant mask... zero means
45 * the irq is not implemented
47 static unsigned char bast_pc104_irqmasks
[] = {
66 static unsigned char bast_pc104_irqs
[] = { 3, 5, 7, 10 };
69 bast_pc104_mask(struct irq_data
*data
)
73 temp
= __raw_readb(BAST_VA_PC104_IRQMASK
);
74 temp
&= ~bast_pc104_irqmasks
[data
->irq
];
75 __raw_writeb(temp
, BAST_VA_PC104_IRQMASK
);
79 bast_pc104_maskack(struct irq_data
*data
)
81 struct irq_desc
*desc
= irq_desc
+ BAST_IRQ_ISA
;
83 bast_pc104_mask(data
);
84 desc
->irq_data
.chip
->irq_ack(&desc
->irq_data
);
88 bast_pc104_unmask(struct irq_data
*data
)
92 temp
= __raw_readb(BAST_VA_PC104_IRQMASK
);
93 temp
|= bast_pc104_irqmasks
[data
->irq
];
94 __raw_writeb(temp
, BAST_VA_PC104_IRQMASK
);
97 static struct irq_chip bast_pc104_chip
= {
98 .irq_mask
= bast_pc104_mask
,
99 .irq_unmask
= bast_pc104_unmask
,
100 .irq_ack
= bast_pc104_maskack
104 bast_irq_pc104_demux(unsigned int irq
,
105 struct irq_desc
*desc
)
111 stat
= __raw_readb(BAST_VA_PC104_IRQREQ
) & 0xf;
113 if (unlikely(stat
== 0)) {
114 /* ack if we get an irq with nothing (ie, startup) */
116 desc
= irq_desc
+ BAST_IRQ_ISA
;
117 desc
->irq_data
.chip
->irq_ack(&desc
->irq_data
);
121 for (i
= 0; stat
!= 0; i
++, stat
>>= 1) {
123 irqno
= bast_pc104_irqs
[i
];
124 generic_handle_irq(irqno
);
130 static __init
int bast_irq_init(void)
134 if (machine_is_bast()) {
135 printk(KERN_INFO
"BAST PC104 IRQ routing, Copyright 2005 Simtec Electronics\n");
137 /* zap all the IRQs */
139 __raw_writeb(0x0, BAST_VA_PC104_IRQMASK
);
141 irq_set_chained_handler(BAST_IRQ_ISA
, bast_irq_pc104_demux
);
143 /* register our IRQs */
145 for (i
= 0; i
< 4; i
++) {
146 unsigned int irqno
= bast_pc104_irqs
[i
];
148 irq_set_chip_and_handler(irqno
, &bast_pc104_chip
,
150 set_irq_flags(irqno
, IRQF_VALID
);
157 arch_initcall(bast_irq_init
);