2 * linux/arch/armnommu/mach-atmel/irq.c
4 * Copyright (C) 1999 ARM Limited
5 * Copyright (C) 2003 SAMSUNG ELECTRONICS
6 * Hyok S. Choi (hyok.choi@samsung.com)
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
22 #include <linux/types.h>
23 #include <linux/sched.h>
24 #include <linux/interrupt.h>
25 #include <linux/types.h>
26 #include <linux/kernel.h>
27 #include <linux/init.h>
28 #include <linux/list.h>
29 #include <linux/device.h>
30 #include <linux/slab.h>
31 #include <linux/string.h>
32 #include <linux/sysdev.h>
34 #include <asm/hardware.h>
37 #include <asm/setup.h>
38 #include <asm/mach-types.h>
40 #include <asm/mach/arch.h>
41 #include <asm/mach/irq.h>
42 #include <asm/mach/map.h>
44 /* Internal Sources */
45 #define LevelSensitive (0<<5)
46 #define EdgeTriggered (1<<5)
48 /* External Sources */
49 #define LowLevel (0<<5)
50 #define NegativeEdge (1<<5)
51 #define HighLevel (2<<5)
52 #define PositiveEdge (3<<5)
54 static unsigned char eb01_irq_prtable
[32] = {
76 static unsigned char eb01_irq_type
[32] = {
94 EdgeTriggered
, /* IRQ0 = neg. edge */
112 void __inline__
at91_mask_irq(unsigned int irq
)
114 unsigned long mask
= 1 << (irq
);
115 __raw_writel(mask
, AIC_IDCR
);
118 void __inline__
at91_unmask_irq(unsigned int irq
)
120 unsigned long mask
= 1 << (irq
);
121 __raw_writel(mask
, AIC_IECR
);
124 void __inline__
at91_mask_ack_irq(unsigned int irq
)
129 void __inline__
at91_end_of_isr(void)
131 /* Indicates end of ISR to AIC */
132 __raw_writel(0x1L
, AIC_EOICR
); /* AIC don't care the value */
135 void __inline__
at91_unmask_and_eoi(unsigned int irq
)
137 at91_unmask_irq(irq
);
141 static struct irqchip at91_chip
= {
142 .ack
= at91_mask_ack_irq
,
143 .mask
= at91_mask_irq
,
144 .unmask
= at91_unmask_and_eoi
,
148 static unsigned long ic_irq_enable
;
150 static int irq_suspend(struct sys_device
*dev
, u32 state
)
155 static int irq_resume(struct sys_device
*dev
)
157 /* disable all irq sources */
161 #define irq_suspend NULL
162 #define irq_resume NULL
165 static struct sysdev_class irq_class
= {
166 set_kset_name("irq"),
167 .suspend
= irq_suspend
,
168 .resume
= irq_resume
,
171 static struct sys_device irq_device
= {
176 static int __init
irq_init_sysfs(void)
178 int ret
= sysdev_class_register(&irq_class
);
180 ret
= sysdev_register(&irq_device
);
184 device_initcall(irq_init_sysfs
);
186 void __init
atmel_init_irq(void)
190 /* Disable all interrupts */
191 __raw_writel(0xFFFFFFFF, AIC_IDCR
);
193 /* Clear all interrupts */
194 __raw_writel(0xFFFFFFFF, AIC_ICCR
);
196 for ( irq
= 0 ; irq
< 32 ; irq
++ ) {
197 __raw_writel(irq
, AIC_EOICR
);
200 for ( irq
= 0 ; irq
< 32 ; irq
++ ) {
201 __raw_writel(eb01_irq_prtable
[irq
] | eb01_irq_type
[irq
],
205 for (irq
= 0; irq
< NR_IRQS
; irq
++) {
206 if (!VALID_IRQ(irq
)) continue;
207 set_irq_chip(irq
, &at91_chip
);
208 set_irq_handler(irq
, do_level_IRQ
);
209 set_irq_flags(irq
, IRQF_VALID
| IRQF_PROBE
);