2 * linux/arch/arm/mach-sa1100/irq.c
4 * Copyright (C) 1999-2001 Nicolas Pitre
6 * Generic IRQ handling for the SA11x0, GPIO 11-27 IRQ demultiplexing.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
12 #include <linux/init.h>
13 #include <linux/module.h>
14 #include <linux/interrupt.h>
16 #include <linux/irq.h>
17 #include <linux/irqdomain.h>
18 #include <linux/ioport.h>
19 #include <linux/syscore_ops.h>
21 #include <mach/hardware.h>
22 #include <mach/irqs.h>
23 #include <asm/mach/irq.h>
24 #include <asm/exception.h>
30 * We don't need to ACK IRQs on the SA1100 unless they're GPIOs
31 * this is for internal IRQs i.e. from IRQ LCD to RTCAlrm.
33 static void sa1100_mask_irq(struct irq_data
*d
)
35 ICMR
&= ~BIT(d
->hwirq
);
38 static void sa1100_unmask_irq(struct irq_data
*d
)
40 ICMR
|= BIT(d
->hwirq
);
44 * Apart form GPIOs, only the RTC alarm can be a wakeup event.
46 static int sa1100_set_wake(struct irq_data
*d
, unsigned int on
)
48 if (BIT(d
->hwirq
) == IC_RTCAlrm
) {
58 static struct irq_chip sa1100_normal_chip
= {
60 .irq_ack
= sa1100_mask_irq
,
61 .irq_mask
= sa1100_mask_irq
,
62 .irq_unmask
= sa1100_unmask_irq
,
63 .irq_set_wake
= sa1100_set_wake
,
66 static int sa1100_normal_irqdomain_map(struct irq_domain
*d
,
67 unsigned int irq
, irq_hw_number_t hwirq
)
69 irq_set_chip_and_handler(irq
, &sa1100_normal_chip
,
71 set_irq_flags(irq
, IRQF_VALID
);
76 static struct irq_domain_ops sa1100_normal_irqdomain_ops
= {
77 .map
= sa1100_normal_irqdomain_map
,
78 .xlate
= irq_domain_xlate_onetwocell
,
81 static struct irq_domain
*sa1100_normal_irqdomain
;
83 static struct resource irq_resource
=
84 DEFINE_RES_MEM_NAMED(0x90050000, SZ_64K
, "irqs");
86 static struct sa1100irq_state
{
93 static int sa1100irq_suspend(void)
95 struct sa1100irq_state
*st
= &sa1100irq_state
;
103 * Disable all GPIO-based interrupts.
105 ICMR
&= ~(IC_GPIO11_27
|IC_GPIO10
|IC_GPIO9
|IC_GPIO8
|IC_GPIO7
|
106 IC_GPIO6
|IC_GPIO5
|IC_GPIO4
|IC_GPIO3
|IC_GPIO2
|
112 static void sa1100irq_resume(void)
114 struct sa1100irq_state
*st
= &sa1100irq_state
;
124 static struct syscore_ops sa1100irq_syscore_ops
= {
125 .suspend
= sa1100irq_suspend
,
126 .resume
= sa1100irq_resume
,
129 static int __init
sa1100irq_init_devicefs(void)
131 register_syscore_ops(&sa1100irq_syscore_ops
);
135 device_initcall(sa1100irq_init_devicefs
);
137 static asmlinkage
void __exception_irq_entry
138 sa1100_handle_irq(struct pt_regs
*regs
)
140 uint32_t icip
, icmr
, mask
;
150 handle_domain_irq(sa1100_normal_irqdomain
,
151 ffs(mask
) - 1, regs
);
155 void __init
sa1100_init_irq(void)
157 request_resource(&iomem_resource
, &irq_resource
);
159 /* disable all IRQs */
162 /* all IRQs are IRQ, not FIQ */
166 * Whatever the doc says, this has to be set for the wait-on-irq
167 * instruction to work... on a SA1100 rev 9 at least.
171 sa1100_normal_irqdomain
= irq_domain_add_simple(NULL
,
173 &sa1100_normal_irqdomain_ops
, NULL
);
175 set_handle_irq(sa1100_handle_irq
);