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