Skip to content

Commit c49581a

Browse files
abresticralfbaechle
authored andcommitted
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>
1 parent 14d160a commit c49581a

File tree

4 files changed

+40
-32
lines changed

4 files changed

+40
-32
lines changed

arch/mips/include/asm/gic.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,5 +385,4 @@ extern void gic_bind_eic_interrupt(int irq, int set);
385385
extern unsigned int gic_get_timer_pending(void);
386386
extern void gic_get_int_mask(unsigned long *dst, const unsigned long *src);
387387
extern unsigned int gic_get_int(void);
388-
extern void gic_platform_init(int irqs, struct irq_chip *irq_controller);
389388
#endif /* _ASM_GICREGS_H */

arch/mips/mti-malta/malta-int.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -714,11 +714,3 @@ int malta_be_handler(struct pt_regs *regs, int is_fixup)
714714

715715
return retval;
716716
}
717-
718-
void __init gic_platform_init(int irqs, struct irq_chip *irq_controller)
719-
{
720-
int i;
721-
722-
for (i = gic_irq_base; i < (gic_irq_base + irqs); i++)
723-
irq_set_chip(i, irq_controller);
724-
}

arch/mips/mti-sead3/sead3-int.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,3 @@ void __init arch_init_irq(void)
8585
ARRAY_SIZE(gic_intr_map), MIPS_GIC_IRQ_BASE);
8686
}
8787

88-
void __init gic_platform_init(int irqs, struct irq_chip *irq_controller)
89-
{
90-
int i;
91-
92-
/*
93-
* For non-EIC mode, we want to setup the GIC in pass-through
94-
* mode, as if the GIC didn't exist. Do not map any interrupts
95-
* for an external interrupt controller.
96-
*/
97-
if (!cpu_has_veic)
98-
return;
99-
100-
for (i = gic_irq_base; i < (gic_irq_base + irqs); i++)
101-
irq_set_chip_and_handler(i, irq_controller, handle_percpu_irq);
102-
}

drivers/irqchip/irq-mips-gic.c

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ static struct gic_pcpu_mask pcpu_masks[NR_CPUS];
4444
static struct gic_pending_regs pending_regs[NR_CPUS];
4545
static struct gic_intrmask_regs intrmask_regs[NR_CPUS];
4646
static DEFINE_SPINLOCK(gic_lock);
47+
static struct irq_domain *gic_irq_domain;
4748

4849
#if defined(CONFIG_CSRC_GIC) || defined(CONFIG_CEVT_GIC)
4950
cycle_t gic_read_count(void)
@@ -230,24 +231,26 @@ unsigned int gic_get_int(void)
230231

231232
static void gic_mask_irq(struct irq_data *d)
232233
{
233-
GIC_CLR_INTR_MASK(d->irq - gic_irq_base);
234+
GIC_CLR_INTR_MASK(d->hwirq);
234235
}
235236

236237
static void gic_unmask_irq(struct irq_data *d)
237238
{
238-
GIC_SET_INTR_MASK(d->irq - gic_irq_base);
239+
GIC_SET_INTR_MASK(d->hwirq);
239240
}
240241

241242
static void gic_ack_irq(struct irq_data *d)
242243
{
244+
unsigned int irq = d->hwirq;
245+
243246
/* Clear edge detector */
244-
if (gic_irq_flags[d->irq - gic_irq_base] & GIC_TRIG_EDGE)
245-
GICWRITE(GIC_REG(SHARED, GIC_SH_WEDGE), d->irq - gic_irq_base);
247+
if (gic_irq_flags[irq] & GIC_TRIG_EDGE)
248+
GICWRITE(GIC_REG(SHARED, GIC_SH_WEDGE), irq);
246249
}
247250

248251
static int gic_set_type(struct irq_data *d, unsigned int type)
249252
{
250-
unsigned int irq = d->irq - gic_irq_base;
253+
unsigned int irq = d->hwirq;
251254
unsigned long flags;
252255
bool is_edge;
253256

@@ -302,7 +305,7 @@ static int gic_set_type(struct irq_data *d, unsigned int type)
302305
static int gic_set_affinity(struct irq_data *d, const struct cpumask *cpumask,
303306
bool force)
304307
{
305-
unsigned int irq = (d->irq - gic_irq_base);
308+
unsigned int irq = d->hwirq;
306309
cpumask_t tmp = CPU_MASK_NONE;
307310
unsigned long flags;
308311
int i;
@@ -345,6 +348,7 @@ static void __init gic_setup_intr(unsigned int intr, unsigned int cpu,
345348
unsigned int flags)
346349
{
347350
struct gic_shared_intr_map *map_ptr;
351+
int i;
348352

349353
/* Setup Intr to Pin mapping */
350354
if (pin & GIC_MAP_TO_NMI_MSK) {
@@ -382,6 +386,8 @@ static void __init gic_setup_intr(unsigned int intr, unsigned int cpu,
382386
GIC_CLR_INTR_MASK(intr);
383387

384388
/* Initialise per-cpu Interrupt software masks */
389+
for (i = 0; i < NR_CPUS; i++)
390+
clear_bit(intr, pcpu_masks[i].pcpu_mask);
385391
set_bit(intr, pcpu_masks[cpu].pcpu_mask);
386392

387393
if ((flags & GIC_FLAG_TRANSPARENT) && (cpu_has_veic == 0))
@@ -433,6 +439,29 @@ static void __init gic_basic_init(int numintrs, int numvpes,
433439
vpe_local_setup(numvpes);
434440
}
435441

442+
static 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+
460+
static struct irq_domain_ops gic_irq_domain_ops = {
461+
.map = gic_irq_domain_map,
462+
.xlate = irq_domain_xlate_twocell,
463+
};
464+
436465
void __init gic_init(unsigned long gic_base_addr,
437466
unsigned long gic_addrspace_size,
438467
struct gic_intr_map *intr_map, unsigned int intr_map_size,
@@ -454,7 +483,10 @@ void __init gic_init(unsigned long gic_base_addr,
454483
GIC_SH_CONFIG_NUMVPES_SHF;
455484
numvpes = numvpes + 1;
456485

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");
458490

459-
gic_platform_init(numintrs, &gic_irq_controller);
491+
gic_basic_init(numintrs, numvpes, intr_map, intr_map_size);
460492
}

0 commit comments

Comments
 (0)