diff options
author | Andrew Bresticker <abrestic@chromium.org> | 2014-09-18 17:47:25 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2014-11-24 01:44:56 -0500 |
commit | fbd552417bf275f6da591a0118a019b3006245fd (patch) | |
tree | 733e9bdb72300dd7eb760aabfd8347257ea6997f /drivers/irqchip | |
parent | 18743d2781d01d34d132f952a2e16353ccb4c3de (diff) |
irqchip: mips-gic: Probe for number of external interrupts
Instead of requiring platforms to define the correct GIC_NUM_INTRS,
use the value reported in GIC_SH_CONFIG.
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
Acked-by: Jason Cooper <jason@lakedaemon.net>
Reviewed-by: Qais Yousef <qais.yousef@imgtec.com>
Tested-by: Qais Yousef <qais.yousef@imgtec.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Jeffrey Deans <jeffrey.deans@imgtec.com>
Cc: Markos Chandras <markos.chandras@imgtec.com>
Cc: Paul Burton <paul.burton@imgtec.com>
Cc: Jonas Gorski <jogo@openwrt.org>
Cc: John Crispin <blogic@openwrt.org>
Cc: David Daney <ddaney.cavm@gmail.com>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/7817/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'drivers/irqchip')
-rw-r--r-- | drivers/irqchip/irq-mips-gic.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/drivers/irqchip/irq-mips-gic.c b/drivers/irqchip/irq-mips-gic.c index 633a34639388..3cd91d34973d 100644 --- a/drivers/irqchip/irq-mips-gic.c +++ b/drivers/irqchip/irq-mips-gic.c | |||
@@ -28,15 +28,15 @@ unsigned int gic_irq_flags[GIC_NUM_INTRS]; | |||
28 | unsigned int gic_cpu_pin; | 28 | unsigned int gic_cpu_pin; |
29 | 29 | ||
30 | struct gic_pcpu_mask { | 30 | struct gic_pcpu_mask { |
31 | DECLARE_BITMAP(pcpu_mask, GIC_NUM_INTRS); | 31 | DECLARE_BITMAP(pcpu_mask, GIC_MAX_INTRS); |
32 | }; | 32 | }; |
33 | 33 | ||
34 | struct gic_pending_regs { | 34 | struct gic_pending_regs { |
35 | DECLARE_BITMAP(pending, GIC_NUM_INTRS); | 35 | DECLARE_BITMAP(pending, GIC_MAX_INTRS); |
36 | }; | 36 | }; |
37 | 37 | ||
38 | struct gic_intrmask_regs { | 38 | struct gic_intrmask_regs { |
39 | DECLARE_BITMAP(intrmask, GIC_NUM_INTRS); | 39 | DECLARE_BITMAP(intrmask, GIC_MAX_INTRS); |
40 | }; | 40 | }; |
41 | 41 | ||
42 | static struct gic_pcpu_mask pcpu_masks[NR_CPUS]; | 42 | static struct gic_pcpu_mask pcpu_masks[NR_CPUS]; |
@@ -44,6 +44,7 @@ static struct gic_pending_regs pending_regs[NR_CPUS]; | |||
44 | static struct gic_intrmask_regs intrmask_regs[NR_CPUS]; | 44 | static struct gic_intrmask_regs intrmask_regs[NR_CPUS]; |
45 | static DEFINE_SPINLOCK(gic_lock); | 45 | static DEFINE_SPINLOCK(gic_lock); |
46 | static struct irq_domain *gic_irq_domain; | 46 | static struct irq_domain *gic_irq_domain; |
47 | static int gic_shared_intrs; | ||
47 | 48 | ||
48 | static void __gic_irq_dispatch(void); | 49 | static void __gic_irq_dispatch(void); |
49 | 50 | ||
@@ -192,26 +193,26 @@ void gic_get_int_mask(unsigned long *dst, const unsigned long *src) | |||
192 | intrmask_abs = (unsigned long *) GIC_REG_ABS_ADDR(SHARED, | 193 | intrmask_abs = (unsigned long *) GIC_REG_ABS_ADDR(SHARED, |
193 | GIC_SH_MASK_31_0_OFS); | 194 | GIC_SH_MASK_31_0_OFS); |
194 | 195 | ||
195 | for (i = 0; i < BITS_TO_LONGS(GIC_NUM_INTRS); i++) { | 196 | for (i = 0; i < BITS_TO_LONGS(gic_shared_intrs); i++) { |
196 | GICREAD(*pending_abs, pending[i]); | 197 | GICREAD(*pending_abs, pending[i]); |
197 | GICREAD(*intrmask_abs, intrmask[i]); | 198 | GICREAD(*intrmask_abs, intrmask[i]); |
198 | pending_abs++; | 199 | pending_abs++; |
199 | intrmask_abs++; | 200 | intrmask_abs++; |
200 | } | 201 | } |
201 | 202 | ||
202 | bitmap_and(pending, pending, intrmask, GIC_NUM_INTRS); | 203 | bitmap_and(pending, pending, intrmask, gic_shared_intrs); |
203 | bitmap_and(pending, pending, pcpu_mask, GIC_NUM_INTRS); | 204 | bitmap_and(pending, pending, pcpu_mask, gic_shared_intrs); |
204 | bitmap_and(dst, src, pending, GIC_NUM_INTRS); | 205 | bitmap_and(dst, src, pending, gic_shared_intrs); |
205 | } | 206 | } |
206 | 207 | ||
207 | unsigned int gic_get_int(void) | 208 | unsigned int gic_get_int(void) |
208 | { | 209 | { |
209 | DECLARE_BITMAP(interrupts, GIC_NUM_INTRS); | 210 | DECLARE_BITMAP(interrupts, GIC_MAX_INTRS); |
210 | 211 | ||
211 | bitmap_fill(interrupts, GIC_NUM_INTRS); | 212 | bitmap_fill(interrupts, gic_shared_intrs); |
212 | gic_get_int_mask(interrupts, interrupts); | 213 | gic_get_int_mask(interrupts, interrupts); |
213 | 214 | ||
214 | return find_first_bit(interrupts, GIC_NUM_INTRS); | 215 | return find_first_bit(interrupts, gic_shared_intrs); |
215 | } | 216 | } |
216 | 217 | ||
217 | static void gic_mask_irq(struct irq_data *d) | 218 | static void gic_mask_irq(struct irq_data *d) |
@@ -332,7 +333,7 @@ static void __gic_irq_dispatch(void) | |||
332 | { | 333 | { |
333 | unsigned int intr, virq; | 334 | unsigned int intr, virq; |
334 | 335 | ||
335 | while ((intr = gic_get_int()) != GIC_NUM_INTRS) { | 336 | while ((intr = gic_get_int()) != gic_shared_intrs) { |
336 | virq = irq_linear_revmap(gic_irq_domain, intr); | 337 | virq = irq_linear_revmap(gic_irq_domain, intr); |
337 | do_IRQ(virq); | 338 | do_IRQ(virq); |
338 | } | 339 | } |
@@ -405,7 +406,7 @@ static __init void gic_ipi_init(void) | |||
405 | int i; | 406 | int i; |
406 | 407 | ||
407 | /* Use last 2 * NR_CPUS interrupts as IPIs */ | 408 | /* Use last 2 * NR_CPUS interrupts as IPIs */ |
408 | gic_resched_int_base = GIC_NUM_INTRS - nr_cpu_ids; | 409 | gic_resched_int_base = gic_shared_intrs - nr_cpu_ids; |
409 | gic_call_int_base = gic_resched_int_base - nr_cpu_ids; | 410 | gic_call_int_base = gic_resched_int_base - nr_cpu_ids; |
410 | 411 | ||
411 | for (i = 0; i < nr_cpu_ids; i++) { | 412 | for (i = 0; i < nr_cpu_ids; i++) { |
@@ -419,19 +420,18 @@ static inline void gic_ipi_init(void) | |||
419 | } | 420 | } |
420 | #endif | 421 | #endif |
421 | 422 | ||
422 | static void __init gic_basic_init(int numintrs, int numvpes) | 423 | static void __init gic_basic_init(int numvpes) |
423 | { | 424 | { |
424 | unsigned int i; | 425 | unsigned int i; |
425 | 426 | ||
426 | board_bind_eic_interrupt = &gic_bind_eic_interrupt; | 427 | board_bind_eic_interrupt = &gic_bind_eic_interrupt; |
427 | 428 | ||
428 | /* Setup defaults */ | 429 | /* Setup defaults */ |
429 | for (i = 0; i < numintrs; i++) { | 430 | for (i = 0; i < gic_shared_intrs; i++) { |
430 | GIC_SET_POLARITY(i, GIC_POL_POS); | 431 | GIC_SET_POLARITY(i, GIC_POL_POS); |
431 | GIC_SET_TRIGGER(i, GIC_TRIG_LEVEL); | 432 | GIC_SET_TRIGGER(i, GIC_TRIG_LEVEL); |
432 | GIC_CLR_INTR_MASK(i); | 433 | GIC_CLR_INTR_MASK(i); |
433 | if (i < GIC_NUM_INTRS) | 434 | gic_irq_flags[i] = 0; |
434 | gic_irq_flags[i] = 0; | ||
435 | } | 435 | } |
436 | 436 | ||
437 | vpe_local_setup(numvpes); | 437 | vpe_local_setup(numvpes); |
@@ -471,9 +471,9 @@ void __init gic_init(unsigned long gic_base_addr, | |||
471 | gic_addrspace_size); | 471 | gic_addrspace_size); |
472 | 472 | ||
473 | GICREAD(GIC_REG(SHARED, GIC_SH_CONFIG), gicconfig); | 473 | GICREAD(GIC_REG(SHARED, GIC_SH_CONFIG), gicconfig); |
474 | numintrs = (gicconfig & GIC_SH_CONFIG_NUMINTRS_MSK) >> | 474 | gic_shared_intrs = (gicconfig & GIC_SH_CONFIG_NUMINTRS_MSK) >> |
475 | GIC_SH_CONFIG_NUMINTRS_SHF; | 475 | GIC_SH_CONFIG_NUMINTRS_SHF; |
476 | numintrs = ((numintrs + 1) * 8); | 476 | gic_shared_intrs = ((gic_shared_intrs + 1) * 8); |
477 | 477 | ||
478 | numvpes = (gicconfig & GIC_SH_CONFIG_NUMVPES_MSK) >> | 478 | numvpes = (gicconfig & GIC_SH_CONFIG_NUMVPES_MSK) >> |
479 | GIC_SH_CONFIG_NUMVPES_SHF; | 479 | GIC_SH_CONFIG_NUMVPES_SHF; |
@@ -490,12 +490,12 @@ void __init gic_init(unsigned long gic_base_addr, | |||
490 | gic_irq_dispatch); | 490 | gic_irq_dispatch); |
491 | } | 491 | } |
492 | 492 | ||
493 | gic_irq_domain = irq_domain_add_simple(NULL, GIC_NUM_INTRS, irqbase, | 493 | gic_irq_domain = irq_domain_add_simple(NULL, gic_shared_intrs, irqbase, |
494 | &gic_irq_domain_ops, NULL); | 494 | &gic_irq_domain_ops, NULL); |
495 | if (!gic_irq_domain) | 495 | if (!gic_irq_domain) |
496 | panic("Failed to add GIC IRQ domain"); | 496 | panic("Failed to add GIC IRQ domain"); |
497 | 497 | ||
498 | gic_basic_init(numintrs, numvpes); | 498 | gic_basic_init(numvpes); |
499 | 499 | ||
500 | gic_ipi_init(); | 500 | gic_ipi_init(); |
501 | } | 501 | } |