aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips
diff options
context:
space:
mode:
authorPhil Sutter <n0-1@freewrt.org>2008-11-28 14:45:10 -0500
committerRalf Baechle <ralf@linux-mips.org>2009-01-30 16:32:59 -0500
commit4aa0f4d7264bc4f54603de5db1ffcaf8912ddd23 (patch)
treeea927484cd34bbb9ac84e301e8d9ec469fe251b0 /arch/mips
parentfb91e2cb7d3d44356bb92411d6d6b7cb51ce156c (diff)
MIPS: RB532: Add set_type() function to IRQ struct.
Interrupt Group 4 mapps the GPIO pins enabled as interrupt sources; add defines to make this clear when addressing them later in code. The mapped GPIOs support triggering on either level high or low. To achieve this, the set_type() function calls rb532_gpio_set_ilevel() for interrupts of the above mentioned group. As there is no way to alter the triggering characteristics of the other interrupts, accept level triggering on status high only. (This is just a guess; but as the system boots fine and interrupt-driven devices (e.g. serial console) work with no implications, it seems to be right.) To clear a GPIO mapped IRQ, the source has to be cleared (i.e., the interrupt status bit of the corresponding GPIO pin). This is done inside rb532_disable_irq(). After applying these changes I could undo most of my former "fixes" to pata-rb532-cf. Particularly all interrupt handling can be done generically via set_irq_type() as it was before. Signed-off-by: Phil Sutter <n0-1@freewrt.org> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips')
-rw-r--r--arch/mips/include/asm/mach-rc32434/irq.h3
-rw-r--r--arch/mips/rb532/irq.c27
2 files changed, 30 insertions, 0 deletions
diff --git a/arch/mips/include/asm/mach-rc32434/irq.h b/arch/mips/include/asm/mach-rc32434/irq.h
index 56738d8ec4e2..023a5b100ed0 100644
--- a/arch/mips/include/asm/mach-rc32434/irq.h
+++ b/arch/mips/include/asm/mach-rc32434/irq.h
@@ -30,4 +30,7 @@
30#define ETH0_RX_OVR_IRQ (GROUP3_IRQ_BASE + 9) 30#define ETH0_RX_OVR_IRQ (GROUP3_IRQ_BASE + 9)
31#define ETH0_TX_UND_IRQ (GROUP3_IRQ_BASE + 10) 31#define ETH0_TX_UND_IRQ (GROUP3_IRQ_BASE + 10)
32 32
33#define GPIO_MAPPED_IRQ_BASE GROUP4_IRQ_BASE
34#define GPIO_MAPPED_IRQ_GROUP 4
35
33#endif /* __ASM_RC32434_IRQ_H */ 36#endif /* __ASM_RC32434_IRQ_H */
diff --git a/arch/mips/rb532/irq.c b/arch/mips/rb532/irq.c
index 549b46d2fcee..53eeb5e7bc5b 100644
--- a/arch/mips/rb532/irq.c
+++ b/arch/mips/rb532/irq.c
@@ -46,6 +46,7 @@
46#include <asm/system.h> 46#include <asm/system.h>
47 47
48#include <asm/mach-rc32434/irq.h> 48#include <asm/mach-rc32434/irq.h>
49#include <asm/mach-rc32434/gpio.h>
49 50
50struct intr_group { 51struct intr_group {
51 u32 mask; /* mask of valid bits in pending/mask registers */ 52 u32 mask; /* mask of valid bits in pending/mask registers */
@@ -150,6 +151,9 @@ static void rb532_disable_irq(unsigned int irq_nr)
150 mask |= intr_bit; 151 mask |= intr_bit;
151 WRITE_MASK(addr, mask); 152 WRITE_MASK(addr, mask);
152 153
154 if (group == GPIO_MAPPED_IRQ_GROUP)
155 rb532_gpio_set_istat(0, irq_nr - GPIO_MAPPED_IRQ_BASE);
156
153 /* 157 /*
154 * if there are no more interrupts enabled in this 158 * if there are no more interrupts enabled in this
155 * group, disable corresponding IP 159 * group, disable corresponding IP
@@ -165,12 +169,35 @@ static void rb532_mask_and_ack_irq(unsigned int irq_nr)
165 ack_local_irq(group_to_ip(irq_to_group(irq_nr))); 169 ack_local_irq(group_to_ip(irq_to_group(irq_nr)));
166} 170}
167 171
172static int rb532_set_type(unsigned int irq_nr, unsigned type)
173{
174 int gpio = irq_nr - GPIO_MAPPED_IRQ_BASE;
175 int group = irq_to_group(irq_nr);
176
177 if (group != GPIO_MAPPED_IRQ_GROUP)
178 return (type == IRQ_TYPE_LEVEL_HIGH) ? 0 : -EINVAL;
179
180 switch (type) {
181 case IRQ_TYPE_LEVEL_HIGH:
182 rb532_gpio_set_ilevel(1, gpio);
183 break;
184 case IRQ_TYPE_LEVEL_LOW:
185 rb532_gpio_set_ilevel(0, gpio);
186 break;
187 default:
188 return -EINVAL;
189 }
190
191 return 0;
192}
193
168static struct irq_chip rc32434_irq_type = { 194static struct irq_chip rc32434_irq_type = {
169 .name = "RB532", 195 .name = "RB532",
170 .ack = rb532_disable_irq, 196 .ack = rb532_disable_irq,
171 .mask = rb532_disable_irq, 197 .mask = rb532_disable_irq,
172 .mask_ack = rb532_mask_and_ack_irq, 198 .mask_ack = rb532_mask_and_ack_irq,
173 .unmask = rb532_enable_irq, 199 .unmask = rb532_enable_irq,
200 .set_type = rb532_set_type,
174}; 201};
175 202
176void __init arch_init_irq(void) 203void __init arch_init_irq(void)