Linux 2.6.31.6
[linux/fpc-iii.git] / arch / arm / mach-s3c2443 / irq.c
blob0e0d693f397449139f8fd9e790a1f4693e3f661b
1 /* linux/arch/arm/mach-s3c2443/irq.c
3 * Copyright (c) 2007 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <linux/init.h>
23 #include <linux/module.h>
24 #include <linux/interrupt.h>
25 #include <linux/ioport.h>
26 #include <linux/sysdev.h>
27 #include <linux/io.h>
29 #include <mach/hardware.h>
30 #include <asm/irq.h>
32 #include <asm/mach/irq.h>
34 #include <mach/regs-irq.h>
35 #include <mach/regs-gpio.h>
37 #include <plat/cpu.h>
38 #include <plat/pm.h>
39 #include <plat/irq.h>
41 #define INTMSK(start, end) ((1 << ((end) + 1 - (start))) - 1)
43 static inline void s3c2443_irq_demux(unsigned int irq, unsigned int len)
45 unsigned int subsrc, submsk;
46 unsigned int end;
48 /* read the current pending interrupts, and the mask
49 * for what it is available */
51 subsrc = __raw_readl(S3C2410_SUBSRCPND);
52 submsk = __raw_readl(S3C2410_INTSUBMSK);
54 subsrc &= ~submsk;
55 subsrc >>= (irq - S3C2410_IRQSUB(0));
56 subsrc &= (1 << len)-1;
58 end = len + irq;
60 for (; irq < end && subsrc; irq++) {
61 if (subsrc & 1)
62 generic_handle_irq(irq);
64 subsrc >>= 1;
68 /* WDT/AC97 sub interrupts */
70 static void s3c2443_irq_demux_wdtac97(unsigned int irq, struct irq_desc *desc)
72 s3c2443_irq_demux(IRQ_S3C2443_WDT, 4);
75 #define INTMSK_WDTAC97 (1UL << (IRQ_WDT - IRQ_EINT0))
76 #define SUBMSK_WDTAC97 INTMSK(IRQ_S3C2443_WDT, IRQ_S3C2443_AC97)
78 static void s3c2443_irq_wdtac97_mask(unsigned int irqno)
80 s3c_irqsub_mask(irqno, INTMSK_WDTAC97, SUBMSK_WDTAC97);
83 static void s3c2443_irq_wdtac97_unmask(unsigned int irqno)
85 s3c_irqsub_unmask(irqno, INTMSK_WDTAC97);
88 static void s3c2443_irq_wdtac97_ack(unsigned int irqno)
90 s3c_irqsub_maskack(irqno, INTMSK_WDTAC97, SUBMSK_WDTAC97);
93 static struct irq_chip s3c2443_irq_wdtac97 = {
94 .mask = s3c2443_irq_wdtac97_mask,
95 .unmask = s3c2443_irq_wdtac97_unmask,
96 .ack = s3c2443_irq_wdtac97_ack,
100 /* LCD sub interrupts */
102 static void s3c2443_irq_demux_lcd(unsigned int irq, struct irq_desc *desc)
104 s3c2443_irq_demux(IRQ_S3C2443_LCD1, 4);
107 #define INTMSK_LCD (1UL << (IRQ_LCD - IRQ_EINT0))
108 #define SUBMSK_LCD INTMSK(IRQ_S3C2443_LCD1, IRQ_S3C2443_LCD4)
110 static void s3c2443_irq_lcd_mask(unsigned int irqno)
112 s3c_irqsub_mask(irqno, INTMSK_LCD, SUBMSK_LCD);
115 static void s3c2443_irq_lcd_unmask(unsigned int irqno)
117 s3c_irqsub_unmask(irqno, INTMSK_LCD);
120 static void s3c2443_irq_lcd_ack(unsigned int irqno)
122 s3c_irqsub_maskack(irqno, INTMSK_LCD, SUBMSK_LCD);
125 static struct irq_chip s3c2443_irq_lcd = {
126 .mask = s3c2443_irq_lcd_mask,
127 .unmask = s3c2443_irq_lcd_unmask,
128 .ack = s3c2443_irq_lcd_ack,
132 /* DMA sub interrupts */
134 static void s3c2443_irq_demux_dma(unsigned int irq, struct irq_desc *desc)
136 s3c2443_irq_demux(IRQ_S3C2443_DMA0, 6);
139 #define INTMSK_DMA (1UL << (IRQ_S3C2443_DMA - IRQ_EINT0))
140 #define SUBMSK_DMA INTMSK(IRQ_S3C2443_DMA0, IRQ_S3C2443_DMA5)
143 static void s3c2443_irq_dma_mask(unsigned int irqno)
145 s3c_irqsub_mask(irqno, INTMSK_DMA, SUBMSK_DMA);
148 static void s3c2443_irq_dma_unmask(unsigned int irqno)
150 s3c_irqsub_unmask(irqno, INTMSK_DMA);
153 static void s3c2443_irq_dma_ack(unsigned int irqno)
155 s3c_irqsub_maskack(irqno, INTMSK_DMA, SUBMSK_DMA);
158 static struct irq_chip s3c2443_irq_dma = {
159 .mask = s3c2443_irq_dma_mask,
160 .unmask = s3c2443_irq_dma_unmask,
161 .ack = s3c2443_irq_dma_ack,
165 /* UART3 sub interrupts */
167 static void s3c2443_irq_demux_uart3(unsigned int irq, struct irq_desc *desc)
169 s3c2443_irq_demux(IRQ_S3C2443_UART3, 3);
172 #define INTMSK_UART3 (1UL << (IRQ_S3C2443_UART3 - IRQ_EINT0))
173 #define SUBMSK_UART3 (0xf << (IRQ_S3C2443_RX3 - S3C2410_IRQSUB(0)))
176 static void s3c2443_irq_uart3_mask(unsigned int irqno)
178 s3c_irqsub_mask(irqno, INTMSK_UART3, SUBMSK_UART3);
181 static void s3c2443_irq_uart3_unmask(unsigned int irqno)
183 s3c_irqsub_unmask(irqno, INTMSK_UART3);
186 static void s3c2443_irq_uart3_ack(unsigned int irqno)
188 s3c_irqsub_maskack(irqno, INTMSK_UART3, SUBMSK_UART3);
191 static struct irq_chip s3c2443_irq_uart3 = {
192 .mask = s3c2443_irq_uart3_mask,
193 .unmask = s3c2443_irq_uart3_unmask,
194 .ack = s3c2443_irq_uart3_ack,
198 /* CAM sub interrupts */
200 static void s3c2443_irq_demux_cam(unsigned int irq, struct irq_desc *desc)
202 s3c2443_irq_demux(IRQ_S3C2440_CAM_C, 4);
205 #define INTMSK_CAM (1UL << (IRQ_CAM - IRQ_EINT0))
206 #define SUBMSK_CAM INTMSK(IRQ_S3C2440_CAM_C, IRQ_S3C2440_CAM_P)
208 static void s3c2443_irq_cam_mask(unsigned int irqno)
210 s3c_irqsub_mask(irqno, INTMSK_CAM, SUBMSK_CAM);
213 static void s3c2443_irq_cam_unmask(unsigned int irqno)
215 s3c_irqsub_unmask(irqno, INTMSK_CAM);
218 static void s3c2443_irq_cam_ack(unsigned int irqno)
220 s3c_irqsub_maskack(irqno, INTMSK_CAM, SUBMSK_CAM);
223 static struct irq_chip s3c2443_irq_cam = {
224 .mask = s3c2443_irq_cam_mask,
225 .unmask = s3c2443_irq_cam_unmask,
226 .ack = s3c2443_irq_cam_ack,
229 /* IRQ initialisation code */
231 static int __init s3c2443_add_sub(unsigned int base,
232 void (*demux)(unsigned int,
233 struct irq_desc *),
234 struct irq_chip *chip,
235 unsigned int start, unsigned int end)
237 unsigned int irqno;
239 set_irq_chip(base, &s3c_irq_level_chip);
240 set_irq_handler(base, handle_level_irq);
241 set_irq_chained_handler(base, demux);
243 for (irqno = start; irqno <= end; irqno++) {
244 set_irq_chip(irqno, chip);
245 set_irq_handler(irqno, handle_level_irq);
246 set_irq_flags(irqno, IRQF_VALID);
249 return 0;
252 static int __init s3c2443_irq_add(struct sys_device *sysdev)
254 printk("S3C2443: IRQ Support\n");
256 s3c2443_add_sub(IRQ_CAM, s3c2443_irq_demux_cam, &s3c2443_irq_cam,
257 IRQ_S3C2440_CAM_C, IRQ_S3C2440_CAM_P);
259 s3c2443_add_sub(IRQ_LCD, s3c2443_irq_demux_lcd, &s3c2443_irq_lcd,
260 IRQ_S3C2443_LCD1, IRQ_S3C2443_LCD4);
262 s3c2443_add_sub(IRQ_S3C2443_DMA, s3c2443_irq_demux_dma,
263 &s3c2443_irq_dma, IRQ_S3C2443_DMA0, IRQ_S3C2443_DMA5);
265 s3c2443_add_sub(IRQ_S3C2443_UART3, s3c2443_irq_demux_uart3,
266 &s3c2443_irq_uart3,
267 IRQ_S3C2443_RX3, IRQ_S3C2443_ERR3);
269 s3c2443_add_sub(IRQ_WDT, s3c2443_irq_demux_wdtac97,
270 &s3c2443_irq_wdtac97,
271 IRQ_S3C2443_WDT, IRQ_S3C2443_AC97);
273 return 0;
276 static struct sysdev_driver s3c2443_irq_driver = {
277 .add = s3c2443_irq_add,
280 static int __init s3c2443_irq_init(void)
282 return sysdev_driver_register(&s3c2443_sysclass, &s3c2443_irq_driver);
285 arch_initcall(s3c2443_irq_init);