Skip to content

Commit e641b98

Browse files
author
Linus Walleij
committed
irqchip: support cascaded VICs
This adds support for a VIC to be cascaded off another IRQ. On the Integrator/AP logical module IM-PD1 there is a VIC cascaded off the central FPGA IRQ controller so this is needed for that to work out. In order for the plug-in board to be able to register all the devices with their IRQs relative to the offset of the base obtained for the cascaded VIC, the base IRQ number is passed back to the caller. Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 3b4df9d commit e641b98

3 files changed

Lines changed: 52 additions & 9 deletions

File tree

‎arch/arm/mach-versatile/core.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ void __init versatile_init_irq(void)
108108

109109
np = of_find_matching_node_by_address(NULL, vic_of_match,
110110
VERSATILE_VIC_BASE);
111-
__vic_init(VA_VIC_BASE, IRQ_VIC_START, ~0, 0, np);
111+
__vic_init(VA_VIC_BASE, 0, IRQ_VIC_START, ~0, 0, np);
112112

113113
writel(~0, VA_SIC_BASE + SIC_IRQ_ENABLE_CLEAR);
114114

‎drivers/irqchip/irq-vic.c‎

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757

5858
/**
5959
* struct vic_device - VIC PM device
60+
* @parent_irq: The parent IRQ number of the VIC if cascaded, or 0.
6061
* @irq: The IRQ number for the base of the VIC.
6162
* @base: The register base for the VIC.
6263
* @valid_sources: A bitmask of valid interrupts
@@ -224,6 +225,17 @@ static int handle_one_vic(struct vic_device *vic, struct pt_regs *regs)
224225
return handled;
225226
}
226227

228+
static void vic_handle_irq_cascaded(unsigned int irq, struct irq_desc *desc)
229+
{
230+
u32 stat, hwirq;
231+
struct vic_device *vic = irq_desc_get_handler_data(desc);
232+
233+
while ((stat = readl_relaxed(vic->base + VIC_IRQ_STATUS))) {
234+
hwirq = ffs(stat) - 1;
235+
generic_handle_irq(irq_find_mapping(vic->domain, hwirq));
236+
}
237+
}
238+
227239
/*
228240
* Keep iterating over all registered VIC's until there are no pending
229241
* interrupts.
@@ -246,6 +258,7 @@ static struct irq_domain_ops vic_irqdomain_ops = {
246258
/**
247259
* vic_register() - Register a VIC.
248260
* @base: The base address of the VIC.
261+
* @parent_irq: The parent IRQ if cascaded, else 0.
249262
* @irq: The base IRQ for the VIC.
250263
* @valid_sources: bitmask of valid interrupts
251264
* @resume_sources: bitmask of interrupts allowed for resume sources.
@@ -257,7 +270,8 @@ static struct irq_domain_ops vic_irqdomain_ops = {
257270
*
258271
* This also configures the IRQ domain for the VIC.
259272
*/
260-
static void __init vic_register(void __iomem *base, unsigned int irq,
273+
static void __init vic_register(void __iomem *base, unsigned int parent_irq,
274+
unsigned int irq,
261275
u32 valid_sources, u32 resume_sources,
262276
struct device_node *node)
263277
{
@@ -275,6 +289,12 @@ static void __init vic_register(void __iomem *base, unsigned int irq,
275289
v->resume_sources = resume_sources;
276290
set_handle_irq(vic_handle_irq);
277291
vic_id++;
292+
293+
if (parent_irq) {
294+
irq_set_handler_data(parent_irq, v);
295+
irq_set_chained_handler(parent_irq, vic_handle_irq_cascaded);
296+
}
297+
278298
v->domain = irq_domain_add_simple(node, fls(valid_sources), irq,
279299
&vic_irqdomain_ops, v);
280300
/* create an IRQ mapping for each valid IRQ */
@@ -413,10 +433,10 @@ static void __init vic_init_st(void __iomem *base, unsigned int irq_start,
413433
writel(32, base + VIC_PL190_DEF_VECT_ADDR);
414434
}
415435

416-
vic_register(base, irq_start, vic_sources, 0, node);
436+
vic_register(base, 0, irq_start, vic_sources, 0, node);
417437
}
418438

419-
void __init __vic_init(void __iomem *base, int irq_start,
439+
void __init __vic_init(void __iomem *base, int parent_irq, int irq_start,
420440
u32 vic_sources, u32 resume_sources,
421441
struct device_node *node)
422442
{
@@ -453,7 +473,7 @@ void __init __vic_init(void __iomem *base, int irq_start,
453473

454474
vic_init2(base);
455475

456-
vic_register(base, irq_start, vic_sources, resume_sources, node);
476+
vic_register(base, parent_irq, irq_start, vic_sources, resume_sources, node);
457477
}
458478

459479
/**
@@ -466,7 +486,28 @@ void __init __vic_init(void __iomem *base, int irq_start,
466486
void __init vic_init(void __iomem *base, unsigned int irq_start,
467487
u32 vic_sources, u32 resume_sources)
468488
{
469-
__vic_init(base, irq_start, vic_sources, resume_sources, NULL);
489+
__vic_init(base, 0, irq_start, vic_sources, resume_sources, NULL);
490+
}
491+
492+
/**
493+
* vic_init_cascaded() - initialise a cascaded vectored interrupt controller
494+
* @base: iomem base address
495+
* @parent_irq: the parent IRQ we're cascaded off
496+
* @irq_start: starting interrupt number, must be muliple of 32
497+
* @vic_sources: bitmask of interrupt sources to allow
498+
* @resume_sources: bitmask of interrupt sources to allow for resume
499+
*
500+
* This returns the base for the new interrupts or negative on error.
501+
*/
502+
int __init vic_init_cascaded(void __iomem *base, unsigned int parent_irq,
503+
u32 vic_sources, u32 resume_sources)
504+
{
505+
struct vic_device *v;
506+
507+
v = &vic_devices[vic_id];
508+
__vic_init(base, parent_irq, 0, vic_sources, resume_sources, NULL);
509+
/* Return out acquired base */
510+
return v->irq;
470511
}
471512

472513
#ifdef CONFIG_OF
@@ -489,7 +530,7 @@ int __init vic_of_init(struct device_node *node, struct device_node *parent)
489530
/*
490531
* Passing 0 as first IRQ makes the simple domain allocate descriptors
491532
*/
492-
__vic_init(regs, 0, interrupt_mask, wakeup_mask, node);
533+
__vic_init(regs, 0, 0, interrupt_mask, wakeup_mask, node);
493534

494535
return 0;
495536
}

‎include/linux/irqchip/arm-vic.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@
2929
struct device_node;
3030
struct pt_regs;
3131

32-
void __vic_init(void __iomem *base, int irq_start, u32 vic_sources,
33-
u32 resume_sources, struct device_node *node);
32+
void __vic_init(void __iomem *base, int parent_irq, int irq_start,
33+
u32 vic_sources, u32 resume_sources, struct device_node *node);
3434
void vic_init(void __iomem *base, unsigned int irq_start, u32 vic_sources, u32 resume_sources);
35+
int vic_init_cascaded(void __iomem *base, unsigned int parent_irq,
36+
u32 vic_sources, u32 resume_sources);
3537

3638
#endif

0 commit comments

Comments
 (0)