aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/kernel/irq-gic.c
diff options
context:
space:
mode:
authorSteven J. Hill <sjhill@mips.com>2012-08-31 17:05:37 -0400
committerSteven J. Hill <sjhill@mips.com>2012-09-13 16:43:47 -0400
commit0b271f5600b5ae56d331a18da830e33f9fb0acdc (patch)
treed49f4e86e0563aa212545587adacb15170978082 /arch/mips/kernel/irq-gic.c
parentec47b27434eff8ad41e7389efca1e5a6ca8b519a (diff)
MIPS: Make GIC code platform independent.
The GIC interrupt code is used by multiple platforms and the current code was half Malta dependent code. These changes abstract away the platform specific differences. Signed-off-by: Steven J. Hill <sjhill@mips.com>
Diffstat (limited to 'arch/mips/kernel/irq-gic.c')
-rw-r--r--arch/mips/kernel/irq-gic.c35
1 files changed, 11 insertions, 24 deletions
diff --git a/arch/mips/kernel/irq-gic.c b/arch/mips/kernel/irq-gic.c
index 0c527f652196..18124c3bda2f 100644
--- a/arch/mips/kernel/irq-gic.c
+++ b/arch/mips/kernel/irq-gic.c
@@ -12,12 +12,11 @@
12#include <asm-generic/bitops/find.h> 12#include <asm-generic/bitops/find.h>
13 13
14 14
15static unsigned long _gic_base; 15unsigned long _gic_base;
16static unsigned int _irqbase; 16unsigned int gic_irq_base;
17static unsigned int gic_irq_flags[GIC_NUM_INTRS]; 17unsigned int gic_irq_flags[GIC_NUM_INTRS];
18#define GIC_IRQ_FLAG_EDGE 0x0001
19 18
20struct gic_pcpu_mask pcpu_masks[NR_CPUS]; 19static struct gic_pcpu_mask pcpu_masks[NR_CPUS];
21static struct gic_pending_regs pending_regs[NR_CPUS]; 20static struct gic_pending_regs pending_regs[NR_CPUS];
22static struct gic_intrmask_regs intrmask_regs[NR_CPUS]; 21static struct gic_intrmask_regs intrmask_regs[NR_CPUS];
23 22
@@ -87,27 +86,16 @@ unsigned int gic_get_int(void)
87 return i; 86 return i;
88} 87}
89 88
90static void gic_irq_ack(struct irq_data *d)
91{
92 unsigned int irq = d->irq - _irqbase;
93
94 pr_debug("CPU%d: %s: irq%d\n", smp_processor_id(), __func__, irq);
95 GIC_CLR_INTR_MASK(irq);
96
97 if (gic_irq_flags[irq] & GIC_IRQ_FLAG_EDGE)
98 GICWRITE(GIC_REG(SHARED, GIC_SH_WEDGE), irq);
99}
100
101static void gic_mask_irq(struct irq_data *d) 89static void gic_mask_irq(struct irq_data *d)
102{ 90{
103 unsigned int irq = d->irq - _irqbase; 91 unsigned int irq = d->irq - gic_irq_base;
104 pr_debug("CPU%d: %s: irq%d\n", smp_processor_id(), __func__, irq); 92 pr_debug("CPU%d: %s: irq%d\n", smp_processor_id(), __func__, irq);
105 GIC_CLR_INTR_MASK(irq); 93 GIC_CLR_INTR_MASK(irq);
106} 94}
107 95
108static void gic_unmask_irq(struct irq_data *d) 96static void gic_unmask_irq(struct irq_data *d)
109{ 97{
110 unsigned int irq = d->irq - _irqbase; 98 unsigned int irq = d->irq - gic_irq_base;
111 pr_debug("CPU%d: %s: irq%d\n", smp_processor_id(), __func__, irq); 99 pr_debug("CPU%d: %s: irq%d\n", smp_processor_id(), __func__, irq);
112 GIC_SET_INTR_MASK(irq); 100 GIC_SET_INTR_MASK(irq);
113} 101}
@@ -119,7 +107,7 @@ static DEFINE_SPINLOCK(gic_lock);
119static int gic_set_affinity(struct irq_data *d, const struct cpumask *cpumask, 107static int gic_set_affinity(struct irq_data *d, const struct cpumask *cpumask,
120 bool force) 108 bool force)
121{ 109{
122 unsigned int irq = d->irq - _irqbase; 110 unsigned int irq = d->irq - gic_irq_base;
123 cpumask_t tmp = CPU_MASK_NONE; 111 cpumask_t tmp = CPU_MASK_NONE;
124 unsigned long flags; 112 unsigned long flags;
125 int i; 113 int i;
@@ -194,7 +182,7 @@ static void __init gic_setup_intr(unsigned int intr, unsigned int cpu,
194 if (flags & GIC_FLAG_TRANSPARENT) 182 if (flags & GIC_FLAG_TRANSPARENT)
195 GIC_SET_INTR_MASK(intr); 183 GIC_SET_INTR_MASK(intr);
196 if (trigtype == GIC_TRIG_EDGE) 184 if (trigtype == GIC_TRIG_EDGE)
197 gic_irq_flags[intr] |= GIC_IRQ_FLAG_EDGE; 185 gic_irq_flags[intr] |= GIC_TRIG_EDGE;
198} 186}
199 187
200static void __init gic_basic_init(int numintrs, int numvpes, 188static void __init gic_basic_init(int numintrs, int numvpes,
@@ -227,9 +215,6 @@ static void __init gic_basic_init(int numintrs, int numvpes,
227 } 215 }
228 216
229 vpe_local_setup(numvpes); 217 vpe_local_setup(numvpes);
230
231 for (i = _irqbase; i < (_irqbase + numintrs); i++)
232 irq_set_chip(i, &gic_irq_controller);
233} 218}
234 219
235void __init gic_init(unsigned long gic_base_addr, 220void __init gic_init(unsigned long gic_base_addr,
@@ -242,7 +227,7 @@ void __init gic_init(unsigned long gic_base_addr,
242 227
243 _gic_base = (unsigned long) ioremap_nocache(gic_base_addr, 228 _gic_base = (unsigned long) ioremap_nocache(gic_base_addr,
244 gic_addrspace_size); 229 gic_addrspace_size);
245 _irqbase = irqbase; 230 gic_irq_base = irqbase;
246 231
247 GICREAD(GIC_REG(SHARED, GIC_SH_CONFIG), gicconfig); 232 GICREAD(GIC_REG(SHARED, GIC_SH_CONFIG), gicconfig);
248 numintrs = (gicconfig & GIC_SH_CONFIG_NUMINTRS_MSK) >> 233 numintrs = (gicconfig & GIC_SH_CONFIG_NUMINTRS_MSK) >>
@@ -255,4 +240,6 @@ void __init gic_init(unsigned long gic_base_addr,
255 pr_debug("%s called\n", __func__); 240 pr_debug("%s called\n", __func__);
256 241
257 gic_basic_init(numintrs, numvpes, intr_map, intr_map_size); 242 gic_basic_init(numintrs, numvpes, intr_map, intr_map_size);
243
244 gic_platform_init(numintrs, &gic_irq_controller);
258} 245}