aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/irqchip
diff options
context:
space:
mode:
authorAndrew Bresticker <abrestic@chromium.org>2014-09-18 17:47:23 -0400
committerRalf Baechle <ralf@linux-mips.org>2014-11-24 01:44:55 -0500
commitc49581a4dfaade3a483f3db85581a2cdb6bb85a0 (patch)
tree356b4d73d54b6bb55c01034facbff55628e461d0 /drivers/irqchip
parent14d160ab72aaa784219f733fbac6032d3494fc73 (diff)
irqchip: mips-gic: Use IRQ domains
Use a simple IRQ domain for the MIPS GIC. Remove the gic_platform_init callback as it's no longer necessary for it to set the irqchip. 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/7811/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'drivers/irqchip')
-rw-r--r--drivers/irqchip/irq-mips-gic.c48
1 files changed, 40 insertions, 8 deletions
diff --git a/drivers/irqchip/irq-mips-gic.c b/drivers/irqchip/irq-mips-gic.c
index f02cbf5cd8d6..79ab99781534 100644
--- a/drivers/irqchip/irq-mips-gic.c
+++ b/drivers/irqchip/irq-mips-gic.c
@@ -44,6 +44,7 @@ static struct gic_pcpu_mask pcpu_masks[NR_CPUS];
44static struct gic_pending_regs pending_regs[NR_CPUS]; 44static struct gic_pending_regs pending_regs[NR_CPUS];
45static struct gic_intrmask_regs intrmask_regs[NR_CPUS]; 45static struct gic_intrmask_regs intrmask_regs[NR_CPUS];
46static DEFINE_SPINLOCK(gic_lock); 46static DEFINE_SPINLOCK(gic_lock);
47static struct irq_domain *gic_irq_domain;
47 48
48#if defined(CONFIG_CSRC_GIC) || defined(CONFIG_CEVT_GIC) 49#if defined(CONFIG_CSRC_GIC) || defined(CONFIG_CEVT_GIC)
49cycle_t gic_read_count(void) 50cycle_t gic_read_count(void)
@@ -230,24 +231,26 @@ unsigned int gic_get_int(void)
230 231
231static void gic_mask_irq(struct irq_data *d) 232static void gic_mask_irq(struct irq_data *d)
232{ 233{
233 GIC_CLR_INTR_MASK(d->irq - gic_irq_base); 234 GIC_CLR_INTR_MASK(d->hwirq);
234} 235}
235 236
236static void gic_unmask_irq(struct irq_data *d) 237static void gic_unmask_irq(struct irq_data *d)
237{ 238{
238 GIC_SET_INTR_MASK(d->irq - gic_irq_base); 239 GIC_SET_INTR_MASK(d->hwirq);
239} 240}
240 241
241static void gic_ack_irq(struct irq_data *d) 242static void gic_ack_irq(struct irq_data *d)
242{ 243{
244 unsigned int irq = d->hwirq;
245
243 /* Clear edge detector */ 246 /* Clear edge detector */
244 if (gic_irq_flags[d->irq - gic_irq_base] & GIC_TRIG_EDGE) 247 if (gic_irq_flags[irq] & GIC_TRIG_EDGE)
245 GICWRITE(GIC_REG(SHARED, GIC_SH_WEDGE), d->irq - gic_irq_base); 248 GICWRITE(GIC_REG(SHARED, GIC_SH_WEDGE), irq);
246} 249}
247 250
248static int gic_set_type(struct irq_data *d, unsigned int type) 251static int gic_set_type(struct irq_data *d, unsigned int type)
249{ 252{
250 unsigned int irq = d->irq - gic_irq_base; 253 unsigned int irq = d->hwirq;
251 unsigned long flags; 254 unsigned long flags;
252 bool is_edge; 255 bool is_edge;
253 256
@@ -302,7 +305,7 @@ static int gic_set_type(struct irq_data *d, unsigned int type)
302static int gic_set_affinity(struct irq_data *d, const struct cpumask *cpumask, 305static int gic_set_affinity(struct irq_data *d, const struct cpumask *cpumask,
303 bool force) 306 bool force)
304{ 307{
305 unsigned int irq = (d->irq - gic_irq_base); 308 unsigned int irq = d->hwirq;
306 cpumask_t tmp = CPU_MASK_NONE; 309 cpumask_t tmp = CPU_MASK_NONE;
307 unsigned long flags; 310 unsigned long flags;
308 int i; 311 int i;
@@ -345,6 +348,7 @@ static void __init gic_setup_intr(unsigned int intr, unsigned int cpu,
345 unsigned int flags) 348 unsigned int flags)
346{ 349{
347 struct gic_shared_intr_map *map_ptr; 350 struct gic_shared_intr_map *map_ptr;
351 int i;
348 352
349 /* Setup Intr to Pin mapping */ 353 /* Setup Intr to Pin mapping */
350 if (pin & GIC_MAP_TO_NMI_MSK) { 354 if (pin & GIC_MAP_TO_NMI_MSK) {
@@ -382,6 +386,8 @@ static void __init gic_setup_intr(unsigned int intr, unsigned int cpu,
382 GIC_CLR_INTR_MASK(intr); 386 GIC_CLR_INTR_MASK(intr);
383 387
384 /* Initialise per-cpu Interrupt software masks */ 388 /* Initialise per-cpu Interrupt software masks */
389 for (i = 0; i < NR_CPUS; i++)
390 clear_bit(intr, pcpu_masks[i].pcpu_mask);
385 set_bit(intr, pcpu_masks[cpu].pcpu_mask); 391 set_bit(intr, pcpu_masks[cpu].pcpu_mask);
386 392
387 if ((flags & GIC_FLAG_TRANSPARENT) && (cpu_has_veic == 0)) 393 if ((flags & GIC_FLAG_TRANSPARENT) && (cpu_has_veic == 0))
@@ -433,6 +439,29 @@ static void __init gic_basic_init(int numintrs, int numvpes,
433 vpe_local_setup(numvpes); 439 vpe_local_setup(numvpes);
434} 440}
435 441
442static int gic_irq_domain_map(struct irq_domain *d, unsigned int virq,
443 irq_hw_number_t hw)
444{
445 unsigned long flags;
446
447 irq_set_chip_and_handler(virq, &gic_irq_controller, handle_level_irq);
448
449 spin_lock_irqsave(&gic_lock, flags);
450 GICWRITE(GIC_REG_ADDR(SHARED, GIC_SH_MAP_TO_PIN(hw)),
451 GIC_MAP_TO_PIN_MSK | 0);
452 /* Map to VPE 0 by default */
453 GIC_SH_MAP_TO_VPE_SMASK(hw, 0);
454 set_bit(hw, pcpu_masks[0].pcpu_mask);
455 spin_unlock_irqrestore(&gic_lock, flags);
456
457 return 0;
458}
459
460static struct irq_domain_ops gic_irq_domain_ops = {
461 .map = gic_irq_domain_map,
462 .xlate = irq_domain_xlate_twocell,
463};
464
436void __init gic_init(unsigned long gic_base_addr, 465void __init gic_init(unsigned long gic_base_addr,
437 unsigned long gic_addrspace_size, 466 unsigned long gic_addrspace_size,
438 struct gic_intr_map *intr_map, unsigned int intr_map_size, 467 struct gic_intr_map *intr_map, unsigned int intr_map_size,
@@ -454,7 +483,10 @@ void __init gic_init(unsigned long gic_base_addr,
454 GIC_SH_CONFIG_NUMVPES_SHF; 483 GIC_SH_CONFIG_NUMVPES_SHF;
455 numvpes = numvpes + 1; 484 numvpes = numvpes + 1;
456 485
457 gic_basic_init(numintrs, numvpes, intr_map, intr_map_size); 486 gic_irq_domain = irq_domain_add_simple(NULL, GIC_NUM_INTRS, irqbase,
487 &gic_irq_domain_ops, NULL);
488 if (!gic_irq_domain)
489 panic("Failed to add GIC IRQ domain");
458 490
459 gic_platform_init(numintrs, &gic_irq_controller); 491 gic_basic_init(numintrs, numvpes, intr_map, intr_map_size);
460} 492}