GIC OF bindings
Subsystems (2)
cover GIC OF bindings
From: Rob Herring <[email protected]>
With recent patches for VIC device tree support and GIC MULTI_IRQ support, it is evident that the irq domain support should be moved into the core GIC code and not be dependent on the DT initialization. So I've split things up into 2 patches separating irq_domain and device-tree code.
This should only change the internals of the GIC code. The binding is unchanged from the previous version. Yeah!
The full series is available here. This includes Russell's devel-stable and for-next branches and Nico's vmalloc branch.
git://git.jdl.com/software/linux-3.0.git gic
Rob
Rob Herring (2):
ARM: gic: add irq_domain support
ARM: gic: add OF based initialization
Documentation/devicetree/bindings/arm/gic.txt | 55 ++++++++++ arch/arm/common/Kconfig | 1 + arch/arm/common/gic.c | 144 +++++++++++++++++++------ arch/arm/include/asm/hardware/gic.h | 4 + 4 files changed, 171 insertions(+), 33 deletions(-) create mode 100644 Documentation/devicetree/bindings/arm/gic.txt
Signature · 1 line
1.7.5.4
PATCH 1/2 ARM: gic: add irq_domain support
From: Rob Herring <[email protected]>
Convert the gic interrupt controller to use irq domains in preparation for device-tree binding and MULTI_IRQ. This allows for translation between GIC interrupt IDs and Linux irq numbers.
The meaning of irq_offset has changed. It now is just the number of skipped GIC interrupt IDs for the controller. It will be 16 for primary GIC and 32 for secondary GICs.
--- arch/arm/common/Kconfig | 1 + arch/arm/common/gic.c | 80 ++++++++++++++++++++-------------- arch/arm/include/asm/hardware/gic.h | 3 + 3 files changed, 51 insertions(+), 33 deletions(-)
arch/arm/common/Kconfig +1 -0
@@ -1,4 +1,5 @@ config ARM_GIC + select IRQ_DOMAIN bool config ARM_VIC
arch/arm/common/gic.c +47 -33
157 lines not on this page · raw message
arch/arm/include/asm/hardware/gic.h +3 -0
@@ -33,6 +33,8 @@#define GIC_DIST_SOFTINT 0xf00#ifndef __ASSEMBLY__ +#include <linux/irqdomain.h> +extern void __iomem *gic_cpu_base_addr;extern struct irq_chip gic_arch_extn;
@@ -53,6 +55,7 @@ struct gic_chip_data {u32 __percpu *saved_ppi_enable;u32 __percpu *saved_ppi_conf;#endif +struct irq_domain domain; unsigned int gic_irqs; };#endif
Signature · 1 line
1.7.5.4
PATCH 2/2 ARM: gic: add OF based initialization
In reply to Rob HerringFrom: Rob Herring <[email protected]>
This adds ARM gic interrupt controller initialization using device tree data.
The initialization function is intended to be called by of_irq_init function like this:
const static struct of_device_id irq_match[] = {
{ .compatible = "arm,cortex-a9-gic", .data = gic_of_init, },
{}
};static void __init init_irqs(void)
{
of_irq_init(irq_match);
}--- Documentation/devicetree/bindings/arm/gic.txt | 55 +++++++++++++++++++++ arch/arm/common/gic.c | 64 +++++++++++++++++++++++++ arch/arm/include/asm/hardware/gic.h | 1 + 3 files changed, 120 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/arm/gic.txt
Documentation/devicetree/bindings/arm/gic.txt new file +55 -0
@@ -0,0 +1,55 @@ +* ARM Generic Interrupt Controller + +ARM SMP cores are often associated with a GIC, providing per processor +interrupts (PPI), shared processor interrupts (SPI) and software +generated interrupts (SGI). + +Primary GIC is attached directly to the CPU and typically has PPIs and SGIs. +Secondary GICs are cascaded into the upward interrupt controller and do not +have PPIs or SGIs. + +Main node required properties: + +- compatible : should be one of: + "arm,cortex-a9-gic" + "arm,arm11mp-gic" +- interrupt-controller : Identifies the node as an interrupt controller +- #interrupt-cells : Specifies the number of cells needed to encode an + interrupt source. The type shall be a <u32> and the value shall be 3. + + The 1st cell is the interrupt type; 0 for SPI interrupts, 1 for PPI + interrupts. + + The 2nd cell contains the interrupt number for the interrupt type. + SPI interrupts are in the range [0-987]. PPI interrupts are in the + range [0-15]. + + The 3rd cell is the flags, encoded as follows: + bits[3:0] trigger type and level flags. + 1 = low-to-high edge triggered + 2 = high-to-low edge triggered + 4 = active high level-sensitive + 8 = active low level-sensitive + bits[15:8] PPI interrupt cpu mask. Each bit corresponds to each of + the 8 possible cpus attached to the GIC. A bit set to '1' indicated + the interrupt is wired to that CPU. Only valid for PPI interrupts. + +- reg : Specifies base physical address(s) and size of the GIC registers. The + first region is the GIC distributor register base and size. The 2nd region is + the GIC cpu interface register base and size. + +Optional +- interrupts : Interrupt source of the parent interrupt controller. Only + present on secondary GICs. + +Example: + + intc: interrupt-controller at fff11000 { + compatible = "arm,cortex-a9-gic"; + #interrupt-cells = <3>; + #address-cells = <1>; + interrupt-controller; + reg = <0xfff11000 0x1000>, + <0xfff10100 0x100>; + }; +
arch/arm/common/gic.c +64 -0
80 lines not on this page · raw message
arch/arm/include/asm/hardware/gic.h +1 -0
@@ -39,6 +39,7 @@ extern void __iomem *gic_cpu_base_addr;extern struct irq_chip gic_arch_extn;void gic_init (unsigned int ,unsigned int ,void __iomem *,void __iomem *); +int gic_of_init (struct device_node *node,struct device_node *parent);void gic_secondary_init (unsigned int );void gic_cascade_irq (unsigned int gic_nr,unsigned int irq);void gic_raise_softirq (const struct cpumask *mask,unsigned int irq);
Signature · 1 line
1.7.5.4
Quoted 7 lines · Rob Herring
From: Rob Herring <[email protected]>
With recent patches for VIC device tree support and GIC
MULTI_IRQsupport, it is evident that the irq domain support should be moved into the core GIC code and not be dependent on the DT initialization. So I've split things up into 2 patches separatingirq_domainand device-tree code.
Quoted 5 lines
This should only change the internals of the GIC code. The binding is unchanged from the previous version. Yeah!
The full series is available here. This includes Russell's devel-stable and for-next branches and Nico's vmalloc branch.
Looks good to me!
Re: [PATCH 1/2] ARM: gic: add irq_domain support
In reply to Rob HerringQuoted 9 lines · Rob Herring
From: Rob Herring <[email protected]>
Convert the gic interrupt controller to use irq domains in preparation for device-tree binding and
MULTI_IRQ. This allows for translation between GIC interrupt IDs and Linux irq numbers.The meaning of
irq_offsethas changed. It now is just the number of skipped GIC interrupt IDs for the controller. It will be 16 for primary GIC and 32 for secondary GICs.
[...]
arch/arm/common/gic.c static inline unsigned int gic_irq(struct irq_data *d) · line 85
Quoted 7 lines
/*
arch/arm/common/gic.c +1
-1@@ -81,7 +82,7 @@ static inline unsigned int gic_irq(struct irq_data *d)*/ static void gic_mask_irq (struct irq_data *d) { -u32 mask =1 << (d->irq %32 ); +u32 mask =1 << (gic_irq (d) %32 );
This can probably change simply to d->hwirq if irq_offset is eliminated as I describe below.
Quoted 14 lines
arch/arm/common/gic.c +0
-0void __init gic_init (unsigned int gic_nr,unsigned int irq_start,void __iomem *dist_base,void __iomem *cpu_base) {arch/arm/common/gic.c +3
-1struct gic_chip_data *gic; +struct irq_domain *domain; +int gic_irqs;BUG_ON (gic_nr >=MAX_GIC_NR ); gic = &gic_data[gic_nr]; + domain = &gic->domain; gic->dist_base = dist_base; gic->cpu_base = cpu_base; - gic->irq_offset = (irq_start -1 ) & ~31 ;
arch/arm/common/gic.c static void __init gic_pm_init(struct gic_chip_data *gic) · line 546
Quoted 10 lines
arch/arm/common/gic.c +7
-1-if (gic_nr ==0 ) +/* +* For primary GICs, skip over SGIs. +* For secondary GICs, skip over PPIs, too. +*/ +if (gic_nr ==0 ) { gic_cpu_base_addr = cpu_base; + gic->irq_offset =16 ; + irq_start = (irq_start & ~31 ) +16 ;
With the switch to irq_domain, there should no longer be any need for a ~31 mask on the irq_start number. Yes, you'll want to make sure that it doesn't allocate below irq 16, but the driver should completely use the irq_domain to manage the mapping from linux-irq number to hwirq number. The ~31 mask appears to have been an optimization to quickly calculate hwirq number from the linux one, but that value is now found in irq_data->hwirq.
irq_offset could almost be dropped entirely outside of probe because it no longer matters. Instead, populate the to_irq() hook so that the hwirq value gets set correctly from the outset.
It would be better in general to have a consistent view of what the hwirq number means regardless of if it is a root GIC.
g.
Re: [PATCH 2/2] ARM: gic: add OF based initialization
In reply to Rob HerringQuoted 13 lines · Rob Herring
From: Rob Herring <[email protected]>
This adds ARM gic interrupt controller initialization using device tree data.
The initialization function is intended to be called by
of_irq_initfunction like this:const static struct of_device_id irq_match[] = { { .compatible = "arm,cortex-a9-gic", .data = gic_of_init, }, {} };
Quoted 6 lines
static void
__initinit_irqs(void){ of_irq_init(irq_match); }Signed-off-by Rob Herring <[email protected]>
Looks good.
g.
Re: [PATCH 1/2] ARM: gic: add irq_domain support
In reply to Grant LikelyQuoted 49 lines · Grant Likely
Quoted 9 lines · Rob Herring
From: Rob Herring <[email protected]>
Convert the gic interrupt controller to use irq domains in preparation for device-tree binding and
MULTI_IRQ. This allows for translation between GIC interrupt IDs and Linux irq numbers.The meaning of
irq_offsethas changed. It now is just the number of skipped GIC interrupt IDs for the controller. It will be 16 for primary GIC and 32 for secondary GICs.[...]
arch/arm/common/gic.c static inline unsigned int gic_irq(struct irq_data *d) · line 85
Quoted 7 lines
/*
arch/arm/common/gic.c +1
-1@@ -81,7 +82,7 @@ static inline unsigned int gic_irq(struct irq_data *d)*/ static void gic_mask_irq (struct irq_data *d) { -u32 mask =1 << (d->irq %32 ); +u32 mask =1 << (gic_irq (d) %32 );This can probably change simply to
d->hwirqifirq_offsetis eliminated as I describe below.Quoted 14 lines
arch/arm/common/gic.c +0
-0void __init gic_init (unsigned int gic_nr,unsigned int irq_start,void __iomem *dist_base,void __iomem *cpu_base) {arch/arm/common/gic.c +3
-1struct gic_chip_data *gic; +struct irq_domain *domain; +int gic_irqs;BUG_ON (gic_nr >=MAX_GIC_NR ); gic = &gic_data[gic_nr]; + domain = &gic->domain; gic->dist_base = dist_base; gic->cpu_base = cpu_base; - gic->irq_offset = (irq_start -1 ) & ~31 ;arch/arm/common/gic.c static void __init gic_pm_init(struct gic_chip_data *gic) · line 546
Quoted 10 lines
arch/arm/common/gic.c +7
-1-if (gic_nr ==0 ) +/* +* For primary GICs, skip over SGIs. +* For secondary GICs, skip over PPIs, too. +*/ +if (gic_nr ==0 ) { gic_cpu_base_addr = cpu_base; + gic->irq_offset =16 ; + irq_start = (irq_start & ~31 ) +16 ;
Quoted 7 lines
With the switch to
irq_domain, there should no longer be any need for a ~31 mask on theirq_startnumber. Yes, you'll want to make sure that it doesn't allocate below irq 16, but the driver should completely use theirq_domainto manage the mapping from linux-irq number to hwirq number. The ~31 mask appears to have been an optimization to quickly calculate hwirq number from the linux one, but that value is now found inirq_data->hwirq.
I started out exactly this way removing irq_offset. The problem is the core irq domain code assumes that hwirq starts at 0, but for the gic it starts at 16 or 32.
It could be fixed in the domain core, but that would effectively mean moving irq_offset into the core.
The masking here is mainly to not break exynos. Everyone else passes in a value of 16-31 which I could just hardcode to 16. So when exynos gets all the interrupts converted over to domains, this can be removed. I looked at it briefly and it doesn't look trivial.
Quoted 7 lines
irq_offsetcould almost be dropped entirely outside of probe because it no longer matters. Instead, populate theto_irq()hook so that the hwirq value gets set correctly from the outset.It would be better in general to have a consistent view of what the hwirq number means regardless of if it is a root GIC.
Agreed.
Rob
Re: [PATCH 1/2] ARM: gic: add irq_domain support
Quoted 58 lines · Rob Herring
Quoted 49 lines · Grant Likely
Quoted 9 lines · Rob Herring
From: Rob Herring <[email protected]>
Convert the gic interrupt controller to use irq domains in preparation for device-tree binding and
MULTI_IRQ. This allows for translation between GIC interrupt IDs and Linux irq numbers.The meaning of
irq_offsethas changed. It now is just the number of skipped GIC interrupt IDs for the controller. It will be 16 for primary GIC and 32 for secondary GICs.[...]
arch/arm/common/gic.c static inline unsigned int gic_irq(struct irq_data *d) · line 85
Quoted 7 lines
/*
arch/arm/common/gic.c +1
-1@@ -81,7 +82,7 @@ static inline unsigned int gic_irq(struct irq_data *d)*/ static void gic_mask_irq (struct irq_data *d) { -u32 mask =1 << (d->irq %32 ); +u32 mask =1 << (gic_irq (d) %32 );This can probably change simply to
d->hwirqifirq_offsetis eliminated as I describe below.Quoted 14 lines
arch/arm/common/gic.c +0
-0void __init gic_init (unsigned int gic_nr,unsigned int irq_start,void __iomem *dist_base,void __iomem *cpu_base) {arch/arm/common/gic.c +3
-1struct gic_chip_data *gic; +struct irq_domain *domain; +int gic_irqs;BUG_ON (gic_nr >=MAX_GIC_NR ); gic = &gic_data[gic_nr]; + domain = &gic->domain; gic->dist_base = dist_base; gic->cpu_base = cpu_base; - gic->irq_offset = (irq_start -1 ) & ~31 ;arch/arm/common/gic.c static void __init gic_pm_init(struct gic_chip_data *gic) · line 546
Quoted 10 lines
arch/arm/common/gic.c +7
-1-if (gic_nr ==0 ) +/* +* For primary GICs, skip over SGIs. +* For secondary GICs, skip over PPIs, too. +*/ +if (gic_nr ==0 ) { gic_cpu_base_addr = cpu_base; + gic->irq_offset =16 ; + irq_start = (irq_start & ~31 ) +16 ;Quoted 7 lines
With the switch to
irq_domain, there should no longer be any need for a ~31 mask on theirq_startnumber. Yes, you'll want to make sure that it doesn't allocate below irq 16, but the driver should completely use theirq_domainto manage the mapping from linux-irq number to hwirq number. The ~31 mask appears to have been an optimization to quickly calculate hwirq number from the linux one, but that value is now found inirq_data->hwirq.
Quoted 6 lines
I started out exactly this way removing
irq_offset. The problem is the core irq domain code assumes that hwirq starts at 0, but for the gic it starts at 16 or 32.It could be fixed in the domain core, but that would effectively mean moving
irq_offsetinto the core.
Fix irq_domain. If it cannot handle this trivial case, then it won't be able to handle the complex powerpc use cases.
g.