aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-sa1100/irq.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-sa1100/irq.c')
-rw-r--r--arch/arm/mach-sa1100/irq.c203
1 files changed, 4 insertions, 199 deletions
diff --git a/arch/arm/mach-sa1100/irq.c b/arch/arm/mach-sa1100/irq.c
index 63e2901db416..65aebfa66fe5 100644
--- a/arch/arm/mach-sa1100/irq.c
+++ b/arch/arm/mach-sa1100/irq.c
@@ -80,170 +80,6 @@ static struct irq_domain_ops sa1100_normal_irqdomain_ops = {
80 80
81static struct irq_domain *sa1100_normal_irqdomain; 81static struct irq_domain *sa1100_normal_irqdomain;
82 82
83/*
84 * SA1100 GPIO edge detection for IRQs:
85 * IRQs are generated on Falling-Edge, Rising-Edge, or both.
86 * Use this instead of directly setting GRER/GFER.
87 */
88static int GPIO_IRQ_rising_edge;
89static int GPIO_IRQ_falling_edge;
90static int GPIO_IRQ_mask = (1 << 11) - 1;
91
92static int sa1100_gpio_type(struct irq_data *d, unsigned int type)
93{
94 unsigned int mask;
95
96 mask = BIT(d->hwirq);
97
98 if (type == IRQ_TYPE_PROBE) {
99 if ((GPIO_IRQ_rising_edge | GPIO_IRQ_falling_edge) & mask)
100 return 0;
101 type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING;
102 }
103
104 if (type & IRQ_TYPE_EDGE_RISING) {
105 GPIO_IRQ_rising_edge |= mask;
106 } else
107 GPIO_IRQ_rising_edge &= ~mask;
108 if (type & IRQ_TYPE_EDGE_FALLING) {
109 GPIO_IRQ_falling_edge |= mask;
110 } else
111 GPIO_IRQ_falling_edge &= ~mask;
112
113 GRER = GPIO_IRQ_rising_edge & GPIO_IRQ_mask;
114 GFER = GPIO_IRQ_falling_edge & GPIO_IRQ_mask;
115
116 return 0;
117}
118
119/*
120 * GPIO IRQs must be acknowledged.
121 */
122static void sa1100_gpio_ack(struct irq_data *d)
123{
124 GEDR = BIT(d->hwirq);
125}
126
127static int sa1100_gpio_wake(struct irq_data *d, unsigned int on)
128{
129 if (on)
130 PWER |= BIT(d->hwirq);
131 else
132 PWER &= ~BIT(d->hwirq);
133 return 0;
134}
135
136/*
137 * This is for IRQs from 0 to 10.
138 */
139static struct irq_chip sa1100_low_gpio_chip = {
140 .name = "GPIO-l",
141 .irq_ack = sa1100_gpio_ack,
142 .irq_mask = sa1100_mask_irq,
143 .irq_unmask = sa1100_unmask_irq,
144 .irq_set_type = sa1100_gpio_type,
145 .irq_set_wake = sa1100_gpio_wake,
146};
147
148static int sa1100_low_gpio_irqdomain_map(struct irq_domain *d,
149 unsigned int irq, irq_hw_number_t hwirq)
150{
151 irq_set_chip_and_handler(irq, &sa1100_low_gpio_chip,
152 handle_edge_irq);
153 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
154
155 return 0;
156}
157
158static struct irq_domain_ops sa1100_low_gpio_irqdomain_ops = {
159 .map = sa1100_low_gpio_irqdomain_map,
160 .xlate = irq_domain_xlate_onetwocell,
161};
162
163static struct irq_domain *sa1100_low_gpio_irqdomain;
164
165/*
166 * IRQ11 (GPIO11 through 27) handler. We enter here with the
167 * irq_controller_lock held, and IRQs disabled. Decode the IRQ
168 * and call the handler.
169 */
170static void
171sa1100_high_gpio_handler(unsigned int irq, struct irq_desc *desc)
172{
173 unsigned int mask;
174
175 mask = GEDR & 0xfffff800;
176 do {
177 /*
178 * clear down all currently active IRQ sources.
179 * We will be processing them all.
180 */
181 GEDR = mask;
182
183 irq = IRQ_GPIO11;
184 mask >>= 11;
185 do {
186 if (mask & 1)
187 generic_handle_irq(irq);
188 mask >>= 1;
189 irq++;
190 } while (mask);
191
192 mask = GEDR & 0xfffff800;
193 } while (mask);
194}
195
196/*
197 * Like GPIO0 to 10, GPIO11-27 IRQs need to be handled specially.
198 * In addition, the IRQs are all collected up into one bit in the
199 * interrupt controller registers.
200 */
201static void sa1100_high_gpio_mask(struct irq_data *d)
202{
203 unsigned int mask = BIT(d->hwirq);
204
205 GPIO_IRQ_mask &= ~mask;
206
207 GRER &= ~mask;
208 GFER &= ~mask;
209}
210
211static void sa1100_high_gpio_unmask(struct irq_data *d)
212{
213 unsigned int mask = BIT(d->hwirq);
214
215 GPIO_IRQ_mask |= mask;
216
217 GRER = GPIO_IRQ_rising_edge & GPIO_IRQ_mask;
218 GFER = GPIO_IRQ_falling_edge & GPIO_IRQ_mask;
219}
220
221static struct irq_chip sa1100_high_gpio_chip = {
222 .name = "GPIO-h",
223 .irq_ack = sa1100_gpio_ack,
224 .irq_mask = sa1100_high_gpio_mask,
225 .irq_unmask = sa1100_high_gpio_unmask,
226 .irq_set_type = sa1100_gpio_type,
227 .irq_set_wake = sa1100_gpio_wake,
228};
229
230static int sa1100_high_gpio_irqdomain_map(struct irq_domain *d,
231 unsigned int irq, irq_hw_number_t hwirq)
232{
233 irq_set_chip_and_handler(irq, &sa1100_high_gpio_chip,
234 handle_edge_irq);
235 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
236
237 return 0;
238}
239
240static struct irq_domain_ops sa1100_high_gpio_irqdomain_ops = {
241 .map = sa1100_high_gpio_irqdomain_map,
242 .xlate = irq_domain_xlate_onetwocell,
243};
244
245static struct irq_domain *sa1100_high_gpio_irqdomain;
246
247static struct resource irq_resource = 83static struct resource irq_resource =
248 DEFINE_RES_MEM_NAMED(0x90050000, SZ_64K, "irqs"); 84 DEFINE_RES_MEM_NAMED(0x90050000, SZ_64K, "irqs");
249 85
@@ -270,17 +106,6 @@ static int sa1100irq_suspend(void)
270 IC_GPIO6|IC_GPIO5|IC_GPIO4|IC_GPIO3|IC_GPIO2| 106 IC_GPIO6|IC_GPIO5|IC_GPIO4|IC_GPIO3|IC_GPIO2|
271 IC_GPIO1|IC_GPIO0); 107 IC_GPIO1|IC_GPIO0);
272 108
273 /*
274 * Set the appropriate edges for wakeup.
275 */
276 GRER = PWER & GPIO_IRQ_rising_edge;
277 GFER = PWER & GPIO_IRQ_falling_edge;
278
279 /*
280 * Clear any pending GPIO interrupts.
281 */
282 GEDR = GEDR;
283
284 return 0; 109 return 0;
285} 110}
286 111
@@ -292,9 +117,6 @@ static void sa1100irq_resume(void)
292 ICCR = st->iccr; 117 ICCR = st->iccr;
293 ICLR = st->iclr; 118 ICLR = st->iclr;
294 119
295 GRER = GPIO_IRQ_rising_edge & GPIO_IRQ_mask;
296 GFER = GPIO_IRQ_falling_edge & GPIO_IRQ_mask;
297
298 ICMR = st->icmr; 120 ICMR = st->icmr;
299 } 121 }
300} 122}
@@ -325,7 +147,8 @@ sa1100_handle_irq(struct pt_regs *regs)
325 if (mask == 0) 147 if (mask == 0)
326 break; 148 break;
327 149
328 handle_IRQ(ffs(mask) - 1 + IRQ_GPIO0, regs); 150 handle_domain_irq(sa1100_normal_irqdomain,
151 ffs(mask) - 1, regs);
329 } while (1); 152 } while (1);
330} 153}
331 154
@@ -339,34 +162,16 @@ void __init sa1100_init_irq(void)
339 /* all IRQs are IRQ, not FIQ */ 162 /* all IRQs are IRQ, not FIQ */
340 ICLR = 0; 163 ICLR = 0;
341 164
342 /* clear all GPIO edge detects */
343 GFER = 0;
344 GRER = 0;
345 GEDR = -1;
346
347 /* 165 /*
348 * Whatever the doc says, this has to be set for the wait-on-irq 166 * Whatever the doc says, this has to be set for the wait-on-irq
349 * instruction to work... on a SA1100 rev 9 at least. 167 * instruction to work... on a SA1100 rev 9 at least.
350 */ 168 */
351 ICCR = 1; 169 ICCR = 1;
352 170
353 sa1100_low_gpio_irqdomain = irq_domain_add_legacy(NULL, 171 sa1100_normal_irqdomain = irq_domain_add_simple(NULL,
354 11, IRQ_GPIO0, 0, 172 32, IRQ_GPIO0_SC,
355 &sa1100_low_gpio_irqdomain_ops, NULL);
356
357 sa1100_normal_irqdomain = irq_domain_add_legacy(NULL,
358 21, IRQ_GPIO11_27, 11,
359 &sa1100_normal_irqdomain_ops, NULL); 173 &sa1100_normal_irqdomain_ops, NULL);
360 174
361 sa1100_high_gpio_irqdomain = irq_domain_add_legacy(NULL,
362 17, IRQ_GPIO11, 11,
363 &sa1100_high_gpio_irqdomain_ops, NULL);
364
365 /*
366 * Install handler for GPIO 11-27 edge detect interrupts
367 */
368 irq_set_chained_handler(IRQ_GPIO11_27, sa1100_high_gpio_handler);
369
370 set_handle_irq(sa1100_handle_irq); 175 set_handle_irq(sa1100_handle_irq);
371 176
372 sa1100_init_gpio(); 177 sa1100_init_gpio();