13 #include <linux/module.h>
20 #include <mach/hardware.h>
21 #include <mach/irqs.h>
32 static int GPIO_IRQ_rising_edge;
33 static int GPIO_IRQ_falling_edge;
34 static int GPIO_IRQ_mask = (1 << 11) - 1;
39 #define GPIO_11_27_IRQ(i) ((i) - 21)
40 #define GPIO11_27_MASK(irq) (1 << GPIO_11_27_IRQ(irq))
42 static int sa1100_gpio_type(
struct irq_data *
d,
unsigned int type)
52 if ((GPIO_IRQ_rising_edge | GPIO_IRQ_falling_edge) & mask)
58 GPIO_IRQ_rising_edge |=
mask;
60 GPIO_IRQ_rising_edge &= ~mask;
62 GPIO_IRQ_falling_edge |=
mask;
64 GPIO_IRQ_falling_edge &= ~mask;
66 GRER = GPIO_IRQ_rising_edge & GPIO_IRQ_mask;
67 GFER = GPIO_IRQ_falling_edge & GPIO_IRQ_mask;
75 static void sa1100_low_gpio_ack(
struct irq_data *
d)
80 static void sa1100_low_gpio_mask(
struct irq_data *
d)
85 static void sa1100_low_gpio_unmask(
struct irq_data *
d)
90 static int sa1100_low_gpio_wake(
struct irq_data *
d,
unsigned int on)
99 static struct irq_chip sa1100_low_gpio_chip = {
101 .irq_ack = sa1100_low_gpio_ack,
102 .irq_mask = sa1100_low_gpio_mask,
103 .irq_unmask = sa1100_low_gpio_unmask,
104 .irq_set_type = sa1100_gpio_type,
105 .irq_set_wake = sa1100_low_gpio_wake,
114 sa1100_high_gpio_handler(
unsigned int irq,
struct irq_desc *
desc)
118 mask =
GEDR & 0xfffff800;
135 mask =
GEDR & 0xfffff800;
144 static void sa1100_high_gpio_ack(
struct irq_data *d)
151 static void sa1100_high_gpio_mask(
struct irq_data *d)
155 GPIO_IRQ_mask &= ~mask;
161 static void sa1100_high_gpio_unmask(
struct irq_data *d)
165 GPIO_IRQ_mask |=
mask;
167 GRER = GPIO_IRQ_rising_edge & GPIO_IRQ_mask;
168 GFER = GPIO_IRQ_falling_edge & GPIO_IRQ_mask;
171 static int sa1100_high_gpio_wake(
struct irq_data *d,
unsigned int on)
180 static struct irq_chip sa1100_high_gpio_chip = {
182 .irq_ack = sa1100_high_gpio_ack,
183 .irq_mask = sa1100_high_gpio_mask,
184 .irq_unmask = sa1100_high_gpio_unmask,
185 .irq_set_type = sa1100_gpio_type,
186 .irq_set_wake = sa1100_high_gpio_wake,
193 static void sa1100_mask_irq(
struct irq_data *d)
198 static void sa1100_unmask_irq(
struct irq_data *d)
206 static int sa1100_set_wake(
struct irq_data *d,
unsigned int on)
218 static struct irq_chip sa1100_normal_chip = {
220 .irq_ack = sa1100_mask_irq,
221 .irq_mask = sa1100_mask_irq,
222 .irq_unmask = sa1100_unmask_irq,
223 .irq_set_wake = sa1100_set_wake,
226 static struct resource irq_resource =
229 static struct sa1100irq_state {
236 static int sa1100irq_suspend(
void)
238 struct sa1100irq_state *
st = &sa1100irq_state;
256 GFER =
PWER & GPIO_IRQ_falling_edge;
266 static void sa1100irq_resume(
void)
268 struct sa1100irq_state *
st = &sa1100irq_state;
274 GRER = GPIO_IRQ_rising_edge & GPIO_IRQ_mask;
275 GFER = GPIO_IRQ_falling_edge & GPIO_IRQ_mask;
281 static struct syscore_ops sa1100irq_syscore_ops = {
282 .suspend = sa1100irq_suspend,
283 .resume = sa1100irq_resume,
286 static int __init sa1100irq_init_devicefs(
void)
317 for (irq = 0; irq <= 10; irq++) {
318 irq_set_chip_and_handler(irq, &sa1100_low_gpio_chip,
323 for (irq = 12; irq <= 31; irq++) {
324 irq_set_chip_and_handler(irq, &sa1100_normal_chip,
329 for (irq = 32; irq <= 48; irq++) {
330 irq_set_chip_and_handler(irq, &sa1100_high_gpio_chip,
339 irq_set_chained_handler(
IRQ_GPIO11_27, sa1100_high_gpio_handler);