Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mach-sa1100/irq.c |
| 3 | * |
| 4 | * Copyright (C) 1999-2001 Nicolas Pitre |
| 5 | * |
| 6 | * Generic IRQ handling for the SA11x0, GPIO 11-27 IRQ demultiplexing. |
| 7 | * |
| 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. |
| 11 | */ |
| 12 | #include <linux/init.h> |
| 13 | #include <linux/module.h> |
Thomas Gleixner | 119c641 | 2006-07-01 22:32:38 +0100 | [diff] [blame] | 14 | #include <linux/interrupt.h> |
Russell King | 3169663 | 2012-06-06 11:42:36 +0100 | [diff] [blame] | 15 | #include <linux/io.h> |
Thomas Gleixner | 119c641 | 2006-07-01 22:32:38 +0100 | [diff] [blame] | 16 | #include <linux/irq.h> |
Dmitry Eremin-Solenikov | 1eca42b | 2014-11-28 15:56:54 +0100 | [diff] [blame] | 17 | #include <linux/irqdomain.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include <linux/ioport.h> |
Rafael J. Wysocki | 9053398 | 2011-04-22 22:03:03 +0200 | [diff] [blame] | 19 | #include <linux/syscore_ops.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 21 | #include <mach/hardware.h> |
Rob Herring | f314f33 | 2012-02-24 00:06:51 +0100 | [diff] [blame] | 22 | #include <mach/irqs.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | #include <asm/mach/irq.h> |
Dmitry Eremin-Solenikov | affcab3 | 2014-11-28 15:55:16 +0100 | [diff] [blame] | 24 | #include <asm/exception.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | |
| 26 | #include "generic.h" |
| 27 | |
| 28 | |
| 29 | /* |
| 30 | * SA1100 GPIO edge detection for IRQs: |
| 31 | * IRQs are generated on Falling-Edge, Rising-Edge, or both. |
| 32 | * Use this instead of directly setting GRER/GFER. |
| 33 | */ |
| 34 | static int GPIO_IRQ_rising_edge; |
| 35 | static int GPIO_IRQ_falling_edge; |
| 36 | static int GPIO_IRQ_mask = (1 << 11) - 1; |
| 37 | |
Lennert Buytenhek | c4e8964 | 2010-11-29 11:12:06 +0100 | [diff] [blame] | 38 | static int sa1100_gpio_type(struct irq_data *d, unsigned int type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | { |
| 40 | unsigned int mask; |
| 41 | |
Dmitry Eremin-Solenikov | 1eeec6a | 2014-11-28 15:57:32 +0100 | [diff] [blame^] | 42 | mask = BIT(d->hwirq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | |
Dmitry Baryshkov | 6cab486 | 2008-07-27 04:23:31 +0100 | [diff] [blame] | 44 | if (type == IRQ_TYPE_PROBE) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | if ((GPIO_IRQ_rising_edge | GPIO_IRQ_falling_edge) & mask) |
| 46 | return 0; |
Dmitry Baryshkov | 6cab486 | 2008-07-27 04:23:31 +0100 | [diff] [blame] | 47 | type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | } |
| 49 | |
Dmitry Baryshkov | 6cab486 | 2008-07-27 04:23:31 +0100 | [diff] [blame] | 50 | if (type & IRQ_TYPE_EDGE_RISING) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | GPIO_IRQ_rising_edge |= mask; |
| 52 | } else |
| 53 | GPIO_IRQ_rising_edge &= ~mask; |
Dmitry Baryshkov | 6cab486 | 2008-07-27 04:23:31 +0100 | [diff] [blame] | 54 | if (type & IRQ_TYPE_EDGE_FALLING) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | GPIO_IRQ_falling_edge |= mask; |
| 56 | } else |
| 57 | GPIO_IRQ_falling_edge &= ~mask; |
| 58 | |
| 59 | GRER = GPIO_IRQ_rising_edge & GPIO_IRQ_mask; |
| 60 | GFER = GPIO_IRQ_falling_edge & GPIO_IRQ_mask; |
| 61 | |
| 62 | return 0; |
| 63 | } |
| 64 | |
| 65 | /* |
Dmitry Eremin-Solenikov | 0fea30c | 2014-11-28 15:56:13 +0100 | [diff] [blame] | 66 | * GPIO IRQs must be acknowledged. This is for IRQs from GPIO0 to 10. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | */ |
Lennert Buytenhek | c4e8964 | 2010-11-29 11:12:06 +0100 | [diff] [blame] | 68 | static void sa1100_low_gpio_ack(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | { |
Dmitry Eremin-Solenikov | 1eeec6a | 2014-11-28 15:57:32 +0100 | [diff] [blame^] | 70 | GEDR = BIT(d->hwirq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | } |
| 72 | |
Lennert Buytenhek | c4e8964 | 2010-11-29 11:12:06 +0100 | [diff] [blame] | 73 | static void sa1100_low_gpio_mask(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | { |
Dmitry Eremin-Solenikov | 1eeec6a | 2014-11-28 15:57:32 +0100 | [diff] [blame^] | 75 | ICMR &= ~BIT(d->hwirq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | } |
| 77 | |
Lennert Buytenhek | c4e8964 | 2010-11-29 11:12:06 +0100 | [diff] [blame] | 78 | static void sa1100_low_gpio_unmask(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | { |
Dmitry Eremin-Solenikov | 1eeec6a | 2014-11-28 15:57:32 +0100 | [diff] [blame^] | 80 | ICMR |= BIT(d->hwirq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | } |
| 82 | |
Lennert Buytenhek | c4e8964 | 2010-11-29 11:12:06 +0100 | [diff] [blame] | 83 | static int sa1100_low_gpio_wake(struct irq_data *d, unsigned int on) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | { |
| 85 | if (on) |
Dmitry Eremin-Solenikov | 1eeec6a | 2014-11-28 15:57:32 +0100 | [diff] [blame^] | 86 | PWER |= BIT(d->hwirq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | else |
Dmitry Eremin-Solenikov | 1eeec6a | 2014-11-28 15:57:32 +0100 | [diff] [blame^] | 88 | PWER &= ~BIT(d->hwirq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | return 0; |
| 90 | } |
| 91 | |
David Brownell | 38c677c | 2006-08-01 22:26:25 +0100 | [diff] [blame] | 92 | static struct irq_chip sa1100_low_gpio_chip = { |
| 93 | .name = "GPIO-l", |
Lennert Buytenhek | c4e8964 | 2010-11-29 11:12:06 +0100 | [diff] [blame] | 94 | .irq_ack = sa1100_low_gpio_ack, |
| 95 | .irq_mask = sa1100_low_gpio_mask, |
| 96 | .irq_unmask = sa1100_low_gpio_unmask, |
| 97 | .irq_set_type = sa1100_gpio_type, |
| 98 | .irq_set_wake = sa1100_low_gpio_wake, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | }; |
| 100 | |
Dmitry Eremin-Solenikov | 1eca42b | 2014-11-28 15:56:54 +0100 | [diff] [blame] | 101 | static int sa1100_low_gpio_irqdomain_map(struct irq_domain *d, |
| 102 | unsigned int irq, irq_hw_number_t hwirq) |
| 103 | { |
| 104 | irq_set_chip_and_handler(irq, &sa1100_low_gpio_chip, |
| 105 | handle_edge_irq); |
| 106 | set_irq_flags(irq, IRQF_VALID | IRQF_PROBE); |
| 107 | |
| 108 | return 0; |
| 109 | } |
| 110 | |
| 111 | static struct irq_domain_ops sa1100_low_gpio_irqdomain_ops = { |
| 112 | .map = sa1100_low_gpio_irqdomain_map, |
| 113 | .xlate = irq_domain_xlate_onetwocell, |
| 114 | }; |
| 115 | |
| 116 | static struct irq_domain *sa1100_low_gpio_irqdomain; |
| 117 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | /* |
| 119 | * IRQ11 (GPIO11 through 27) handler. We enter here with the |
| 120 | * irq_controller_lock held, and IRQs disabled. Decode the IRQ |
| 121 | * and call the handler. |
| 122 | */ |
| 123 | static void |
Russell King | 10dd5ce | 2006-11-23 11:41:32 +0000 | [diff] [blame] | 124 | sa1100_high_gpio_handler(unsigned int irq, struct irq_desc *desc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | { |
| 126 | unsigned int mask; |
| 127 | |
| 128 | mask = GEDR & 0xfffff800; |
| 129 | do { |
| 130 | /* |
| 131 | * clear down all currently active IRQ sources. |
| 132 | * We will be processing them all. |
| 133 | */ |
| 134 | GEDR = mask; |
| 135 | |
| 136 | irq = IRQ_GPIO11; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | mask >>= 11; |
| 138 | do { |
| 139 | if (mask & 1) |
Dmitry Baryshkov | d8aa025 | 2008-10-09 13:36:24 +0100 | [diff] [blame] | 140 | generic_handle_irq(irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | mask >>= 1; |
| 142 | irq++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | } while (mask); |
| 144 | |
| 145 | mask = GEDR & 0xfffff800; |
| 146 | } while (mask); |
| 147 | } |
| 148 | |
| 149 | /* |
| 150 | * Like GPIO0 to 10, GPIO11-27 IRQs need to be handled specially. |
| 151 | * In addition, the IRQs are all collected up into one bit in the |
| 152 | * interrupt controller registers. |
| 153 | */ |
Lennert Buytenhek | c4e8964 | 2010-11-29 11:12:06 +0100 | [diff] [blame] | 154 | static void sa1100_high_gpio_ack(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | { |
Dmitry Eremin-Solenikov | 1eeec6a | 2014-11-28 15:57:32 +0100 | [diff] [blame^] | 156 | unsigned int mask = BIT(d->hwirq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | |
| 158 | GEDR = mask; |
| 159 | } |
| 160 | |
Lennert Buytenhek | c4e8964 | 2010-11-29 11:12:06 +0100 | [diff] [blame] | 161 | static void sa1100_high_gpio_mask(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | { |
Dmitry Eremin-Solenikov | 1eeec6a | 2014-11-28 15:57:32 +0100 | [diff] [blame^] | 163 | unsigned int mask = BIT(d->hwirq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | |
| 165 | GPIO_IRQ_mask &= ~mask; |
| 166 | |
| 167 | GRER &= ~mask; |
| 168 | GFER &= ~mask; |
| 169 | } |
| 170 | |
Lennert Buytenhek | c4e8964 | 2010-11-29 11:12:06 +0100 | [diff] [blame] | 171 | static void sa1100_high_gpio_unmask(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | { |
Dmitry Eremin-Solenikov | 1eeec6a | 2014-11-28 15:57:32 +0100 | [diff] [blame^] | 173 | unsigned int mask = BIT(d->hwirq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | |
| 175 | GPIO_IRQ_mask |= mask; |
| 176 | |
| 177 | GRER = GPIO_IRQ_rising_edge & GPIO_IRQ_mask; |
| 178 | GFER = GPIO_IRQ_falling_edge & GPIO_IRQ_mask; |
| 179 | } |
| 180 | |
Lennert Buytenhek | c4e8964 | 2010-11-29 11:12:06 +0100 | [diff] [blame] | 181 | static int sa1100_high_gpio_wake(struct irq_data *d, unsigned int on) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | { |
| 183 | if (on) |
Dmitry Eremin-Solenikov | 1eeec6a | 2014-11-28 15:57:32 +0100 | [diff] [blame^] | 184 | PWER |= BIT(d->hwirq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | else |
Dmitry Eremin-Solenikov | 1eeec6a | 2014-11-28 15:57:32 +0100 | [diff] [blame^] | 186 | PWER &= ~BIT(d->hwirq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | return 0; |
| 188 | } |
| 189 | |
David Brownell | 38c677c | 2006-08-01 22:26:25 +0100 | [diff] [blame] | 190 | static struct irq_chip sa1100_high_gpio_chip = { |
| 191 | .name = "GPIO-h", |
Lennert Buytenhek | c4e8964 | 2010-11-29 11:12:06 +0100 | [diff] [blame] | 192 | .irq_ack = sa1100_high_gpio_ack, |
| 193 | .irq_mask = sa1100_high_gpio_mask, |
| 194 | .irq_unmask = sa1100_high_gpio_unmask, |
| 195 | .irq_set_type = sa1100_gpio_type, |
| 196 | .irq_set_wake = sa1100_high_gpio_wake, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | }; |
| 198 | |
Dmitry Eremin-Solenikov | 1eca42b | 2014-11-28 15:56:54 +0100 | [diff] [blame] | 199 | static int sa1100_high_gpio_irqdomain_map(struct irq_domain *d, |
| 200 | unsigned int irq, irq_hw_number_t hwirq) |
| 201 | { |
| 202 | irq_set_chip_and_handler(irq, &sa1100_high_gpio_chip, |
| 203 | handle_edge_irq); |
| 204 | set_irq_flags(irq, IRQF_VALID | IRQF_PROBE); |
| 205 | |
| 206 | return 0; |
| 207 | } |
| 208 | |
| 209 | static struct irq_domain_ops sa1100_high_gpio_irqdomain_ops = { |
| 210 | .map = sa1100_high_gpio_irqdomain_map, |
| 211 | .xlate = irq_domain_xlate_onetwocell, |
| 212 | }; |
| 213 | |
| 214 | static struct irq_domain *sa1100_high_gpio_irqdomain; |
| 215 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | /* |
| 217 | * We don't need to ACK IRQs on the SA1100 unless they're GPIOs |
Dmitry Eremin-Solenikov | 0fea30c | 2014-11-28 15:56:13 +0100 | [diff] [blame] | 218 | * this is for internal IRQs i.e. from IRQ LCD to RTCAlrm. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | */ |
Lennert Buytenhek | c4e8964 | 2010-11-29 11:12:06 +0100 | [diff] [blame] | 220 | static void sa1100_mask_irq(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | { |
Dmitry Eremin-Solenikov | 1eeec6a | 2014-11-28 15:57:32 +0100 | [diff] [blame^] | 222 | ICMR &= ~BIT(d->hwirq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | } |
| 224 | |
Lennert Buytenhek | c4e8964 | 2010-11-29 11:12:06 +0100 | [diff] [blame] | 225 | static void sa1100_unmask_irq(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | { |
Dmitry Eremin-Solenikov | 1eeec6a | 2014-11-28 15:57:32 +0100 | [diff] [blame^] | 227 | ICMR |= BIT(d->hwirq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | } |
| 229 | |
Russell King | 19ca5d2 | 2006-05-06 11:26:30 +0100 | [diff] [blame] | 230 | /* |
| 231 | * Apart form GPIOs, only the RTC alarm can be a wakeup event. |
| 232 | */ |
Lennert Buytenhek | c4e8964 | 2010-11-29 11:12:06 +0100 | [diff] [blame] | 233 | static int sa1100_set_wake(struct irq_data *d, unsigned int on) |
Russell King | 19ca5d2 | 2006-05-06 11:26:30 +0100 | [diff] [blame] | 234 | { |
Dmitry Eremin-Solenikov | 1eeec6a | 2014-11-28 15:57:32 +0100 | [diff] [blame^] | 235 | if (BIT(d->hwirq) == IC_RTCAlrm) { |
Russell King | 19ca5d2 | 2006-05-06 11:26:30 +0100 | [diff] [blame] | 236 | if (on) |
| 237 | PWER |= PWER_RTC; |
| 238 | else |
| 239 | PWER &= ~PWER_RTC; |
| 240 | return 0; |
| 241 | } |
| 242 | return -EINVAL; |
| 243 | } |
| 244 | |
David Brownell | 38c677c | 2006-08-01 22:26:25 +0100 | [diff] [blame] | 245 | static struct irq_chip sa1100_normal_chip = { |
| 246 | .name = "SC", |
Lennert Buytenhek | c4e8964 | 2010-11-29 11:12:06 +0100 | [diff] [blame] | 247 | .irq_ack = sa1100_mask_irq, |
| 248 | .irq_mask = sa1100_mask_irq, |
| 249 | .irq_unmask = sa1100_unmask_irq, |
| 250 | .irq_set_wake = sa1100_set_wake, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | }; |
| 252 | |
Dmitry Eremin-Solenikov | 1eca42b | 2014-11-28 15:56:54 +0100 | [diff] [blame] | 253 | static int sa1100_normal_irqdomain_map(struct irq_domain *d, |
| 254 | unsigned int irq, irq_hw_number_t hwirq) |
| 255 | { |
| 256 | irq_set_chip_and_handler(irq, &sa1100_normal_chip, |
| 257 | handle_level_irq); |
| 258 | set_irq_flags(irq, IRQF_VALID); |
| 259 | |
| 260 | return 0; |
| 261 | } |
| 262 | |
| 263 | static struct irq_domain_ops sa1100_normal_irqdomain_ops = { |
| 264 | .map = sa1100_normal_irqdomain_map, |
| 265 | .xlate = irq_domain_xlate_onetwocell, |
| 266 | }; |
| 267 | |
| 268 | static struct irq_domain *sa1100_normal_irqdomain; |
| 269 | |
Russell King | a181099 | 2012-01-12 10:25:29 +0000 | [diff] [blame] | 270 | static struct resource irq_resource = |
| 271 | DEFINE_RES_MEM_NAMED(0x90050000, SZ_64K, "irqs"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | |
| 273 | static struct sa1100irq_state { |
| 274 | unsigned int saved; |
| 275 | unsigned int icmr; |
| 276 | unsigned int iclr; |
| 277 | unsigned int iccr; |
| 278 | } sa1100irq_state; |
| 279 | |
Rafael J. Wysocki | 9053398 | 2011-04-22 22:03:03 +0200 | [diff] [blame] | 280 | static int sa1100irq_suspend(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | { |
| 282 | struct sa1100irq_state *st = &sa1100irq_state; |
| 283 | |
| 284 | st->saved = 1; |
| 285 | st->icmr = ICMR; |
| 286 | st->iclr = ICLR; |
| 287 | st->iccr = ICCR; |
| 288 | |
| 289 | /* |
| 290 | * Disable all GPIO-based interrupts. |
| 291 | */ |
| 292 | ICMR &= ~(IC_GPIO11_27|IC_GPIO10|IC_GPIO9|IC_GPIO8|IC_GPIO7| |
| 293 | IC_GPIO6|IC_GPIO5|IC_GPIO4|IC_GPIO3|IC_GPIO2| |
| 294 | IC_GPIO1|IC_GPIO0); |
| 295 | |
| 296 | /* |
| 297 | * Set the appropriate edges for wakeup. |
| 298 | */ |
| 299 | GRER = PWER & GPIO_IRQ_rising_edge; |
| 300 | GFER = PWER & GPIO_IRQ_falling_edge; |
| 301 | |
| 302 | /* |
| 303 | * Clear any pending GPIO interrupts. |
| 304 | */ |
| 305 | GEDR = GEDR; |
| 306 | |
| 307 | return 0; |
| 308 | } |
| 309 | |
Rafael J. Wysocki | 9053398 | 2011-04-22 22:03:03 +0200 | [diff] [blame] | 310 | static void sa1100irq_resume(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | { |
| 312 | struct sa1100irq_state *st = &sa1100irq_state; |
| 313 | |
| 314 | if (st->saved) { |
| 315 | ICCR = st->iccr; |
| 316 | ICLR = st->iclr; |
| 317 | |
| 318 | GRER = GPIO_IRQ_rising_edge & GPIO_IRQ_mask; |
| 319 | GFER = GPIO_IRQ_falling_edge & GPIO_IRQ_mask; |
| 320 | |
| 321 | ICMR = st->icmr; |
| 322 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | } |
| 324 | |
Rafael J. Wysocki | 9053398 | 2011-04-22 22:03:03 +0200 | [diff] [blame] | 325 | static struct syscore_ops sa1100irq_syscore_ops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | .suspend = sa1100irq_suspend, |
| 327 | .resume = sa1100irq_resume, |
| 328 | }; |
| 329 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | static int __init sa1100irq_init_devicefs(void) |
| 331 | { |
Rafael J. Wysocki | 9053398 | 2011-04-22 22:03:03 +0200 | [diff] [blame] | 332 | register_syscore_ops(&sa1100irq_syscore_ops); |
| 333 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | } |
| 335 | |
| 336 | device_initcall(sa1100irq_init_devicefs); |
| 337 | |
Dmitry Eremin-Solenikov | affcab3 | 2014-11-28 15:55:16 +0100 | [diff] [blame] | 338 | static asmlinkage void __exception_irq_entry |
| 339 | sa1100_handle_irq(struct pt_regs *regs) |
| 340 | { |
| 341 | uint32_t icip, icmr, mask; |
| 342 | |
| 343 | do { |
| 344 | icip = (ICIP); |
| 345 | icmr = (ICMR); |
| 346 | mask = icip & icmr; |
| 347 | |
| 348 | if (mask == 0) |
| 349 | break; |
| 350 | |
| 351 | handle_IRQ(ffs(mask) - 1 + IRQ_GPIO0, regs); |
| 352 | } while (1); |
| 353 | } |
| 354 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | void __init sa1100_init_irq(void) |
| 356 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | request_resource(&iomem_resource, &irq_resource); |
| 358 | |
| 359 | /* disable all IRQs */ |
| 360 | ICMR = 0; |
| 361 | |
| 362 | /* all IRQs are IRQ, not FIQ */ |
| 363 | ICLR = 0; |
| 364 | |
| 365 | /* clear all GPIO edge detects */ |
| 366 | GFER = 0; |
| 367 | GRER = 0; |
| 368 | GEDR = -1; |
| 369 | |
| 370 | /* |
| 371 | * Whatever the doc says, this has to be set for the wait-on-irq |
| 372 | * instruction to work... on a SA1100 rev 9 at least. |
| 373 | */ |
| 374 | ICCR = 1; |
| 375 | |
Dmitry Eremin-Solenikov | 1eca42b | 2014-11-28 15:56:54 +0100 | [diff] [blame] | 376 | sa1100_low_gpio_irqdomain = irq_domain_add_legacy(NULL, |
| 377 | 11, IRQ_GPIO0, 0, |
| 378 | &sa1100_low_gpio_irqdomain_ops, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | |
Dmitry Eremin-Solenikov | 1eca42b | 2014-11-28 15:56:54 +0100 | [diff] [blame] | 380 | sa1100_normal_irqdomain = irq_domain_add_legacy(NULL, |
Dmitry Eremin-Solenikov | 0ebd465f | 2014-11-28 15:57:11 +0100 | [diff] [blame] | 381 | 21, IRQ_GPIO11_27, 11, |
Dmitry Eremin-Solenikov | 1eca42b | 2014-11-28 15:56:54 +0100 | [diff] [blame] | 382 | &sa1100_normal_irqdomain_ops, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | |
Dmitry Eremin-Solenikov | 1eca42b | 2014-11-28 15:56:54 +0100 | [diff] [blame] | 384 | sa1100_high_gpio_irqdomain = irq_domain_add_legacy(NULL, |
| 385 | 17, IRQ_GPIO11, 11, |
| 386 | &sa1100_high_gpio_irqdomain_ops, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | |
| 388 | /* |
| 389 | * Install handler for GPIO 11-27 edge detect interrupts |
| 390 | */ |
Thomas Gleixner | 6845664a | 2011-03-24 13:25:22 +0100 | [diff] [blame] | 391 | irq_set_chained_handler(IRQ_GPIO11_27, sa1100_high_gpio_handler); |
Dmitry Baryshkov | 45528e3 | 2008-04-10 13:31:47 +0100 | [diff] [blame] | 392 | |
Dmitry Eremin-Solenikov | affcab3 | 2014-11-28 15:55:16 +0100 | [diff] [blame] | 393 | set_handle_irq(sa1100_handle_irq); |
| 394 | |
Dmitry Baryshkov | 45528e3 | 2008-04-10 13:31:47 +0100 | [diff] [blame] | 395 | sa1100_init_gpio(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 396 | } |