blob: 1667ba1fa43dc9b29d568ca8dd4a8ca86da83b01 [file] [log] [blame]
Ben Dooks7fcc1132005-07-26 19:20:27 +01001/* linux/arch/arm/mach-s3c2410/s3c2440-irq.c
2 *
3 * Copyright (c) 2003,2004 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
5 *
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.
10 *
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.
15 *
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
19 *
Ben Dooks7fcc1132005-07-26 19:20:27 +010020*/
21
22#include <linux/init.h>
23#include <linux/module.h>
24#include <linux/interrupt.h>
25#include <linux/ioport.h>
26#include <linux/ptrace.h>
27#include <linux/sysdev.h>
28
29#include <asm/hardware.h>
30#include <asm/irq.h>
31#include <asm/io.h>
32
33#include <asm/mach/irq.h>
34
35#include <asm/arch/regs-irq.h>
36#include <asm/arch/regs-gpio.h>
37
38#include "cpu.h"
39#include "pm.h"
40#include "irq.h"
41
42/* WDT/AC97 */
43
44static void s3c_irq_demux_wdtac97(unsigned int irq,
45 struct irqdesc *desc,
46 struct pt_regs *regs)
47{
48 unsigned int subsrc, submsk;
49 struct irqdesc *mydesc;
50
51 /* read the current pending interrupts, and the mask
52 * for what it is available */
53
54 subsrc = __raw_readl(S3C2410_SUBSRCPND);
55 submsk = __raw_readl(S3C2410_INTSUBMSK);
56
57 subsrc &= ~submsk;
58 subsrc >>= 13;
59 subsrc &= 3;
60
61 if (subsrc != 0) {
62 if (subsrc & 1) {
63 mydesc = irq_desc + IRQ_S3C2440_WDT;
Russell King664399e2005-09-04 19:45:00 +010064 desc_handle_irq(IRQ_S3C2440_WDT, mydesc, regs);
Ben Dooks7fcc1132005-07-26 19:20:27 +010065 }
66 if (subsrc & 2) {
67 mydesc = irq_desc + IRQ_S3C2440_AC97;
Russell King664399e2005-09-04 19:45:00 +010068 desc_handle_irq(IRQ_S3C2440_AC97, mydesc, regs);
Ben Dooks7fcc1132005-07-26 19:20:27 +010069 }
70 }
71}
72
73
74#define INTMSK_WDT (1UL << (IRQ_WDT - IRQ_EINT0))
75
76static void
77s3c_irq_wdtac97_mask(unsigned int irqno)
78{
79 s3c_irqsub_mask(irqno, INTMSK_WDT, 3<<13);
80}
81
82static void
83s3c_irq_wdtac97_unmask(unsigned int irqno)
84{
85 s3c_irqsub_unmask(irqno, INTMSK_WDT);
86}
87
88static void
89s3c_irq_wdtac97_ack(unsigned int irqno)
90{
91 s3c_irqsub_maskack(irqno, INTMSK_WDT, 3<<13);
92}
93
94static struct irqchip s3c_irq_wdtac97 = {
95 .mask = s3c_irq_wdtac97_mask,
96 .unmask = s3c_irq_wdtac97_unmask,
97 .ack = s3c_irq_wdtac97_ack,
98};
99
Ben Dooks7fcc1132005-07-26 19:20:27 +0100100static int s3c2440_irq_add(struct sys_device *sysdev)
101{
102 unsigned int irqno;
103
104 printk("S3C2440: IRQ Support\n");
105
Ben Dooks7fcc1132005-07-26 19:20:27 +0100106 /* add new chained handler for wdt, ac7 */
107
108 set_irq_chip(IRQ_WDT, &s3c_irq_level_chip);
109 set_irq_handler(IRQ_WDT, do_level_IRQ);
110 set_irq_chained_handler(IRQ_WDT, s3c_irq_demux_wdtac97);
111
112 for (irqno = IRQ_S3C2440_WDT; irqno <= IRQ_S3C2440_AC97; irqno++) {
113 set_irq_chip(irqno, &s3c_irq_wdtac97);
114 set_irq_handler(irqno, do_level_IRQ);
115 set_irq_flags(irqno, IRQF_VALID);
116 }
117
Ben Dooks7fcc1132005-07-26 19:20:27 +0100118 return 0;
119}
120
121static struct sysdev_driver s3c2440_irq_driver = {
122 .add = s3c2440_irq_add,
123};
124
Ben Dooks96ce2382006-06-18 23:06:41 +0100125static int s3c2440_irq_init(void)
Ben Dooks7fcc1132005-07-26 19:20:27 +0100126{
127 return sysdev_driver_register(&s3c2440_sysclass, &s3c2440_irq_driver);
128}
129
Ben Dooks96ce2382006-06-18 23:06:41 +0100130arch_initcall(s3c2440_irq_init);
Ben Dooks7fcc1132005-07-26 19:20:27 +0100131