gic: implement set_type
PATCH 1/1 gic: implement set_type
Implement set_type() to allow configuration of the trigger type for SPIs.
--- arch/arm/common/gic.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 46 insertions(+), 0 deletions(-)
arch/arm/common/gic.c +46 -0
@@ -108,6 +108,51 @@ static void gic_unmask_irq(unsigned int irq)spin_unlock (&irq_controller_lock); } +static int gic_set_type (unsigned int irq,unsigned int type) +{ +void __iomem *base =gic_dist_base (irq); +unsigned int gicirq =gic_irq (irq); +u32 enablemask =1 << (gicirq %32 ); +u32 enableoff = (gicirq /32 ) *4 ; +u32 confmask =0x2 << ((gicirq %16 ) *2 ); +u32 confoff = (gicirq /16 ) *4 ; +bool enabled = false; +u32 val; + +/* Only SPIs' interrupt configuration can be changed */ +if (gicirq <32 ) +return -EINVAL ; + +if (type !=IRQ_TYPE_LEVEL_HIGH && type !=IRQ_TYPE_EDGE_RISING ) +return -EINVAL ; + +spin_lock (&irq_controller_lock); + + val =readl (base +GIC_DIST_CONFIG + confoff); +if (type ==IRQ_TYPE_LEVEL_HIGH ) + val &= ~confmask; +else if (type ==IRQ_TYPE_EDGE_RISING ) + val |= confmask; + +/* +* As recommended by the spec, only change the interrupt configuration +* when the SPI is disabled. +*/ +if (readl (base +GIC_DIST_ENABLE_SET + enableoff) & enablemask) { +writel (enablemask, base +GIC_DIST_ENABLE_CLEAR + enableoff); + enabled = true; + } + +writel (val, base +GIC_DIST_CONFIG + confoff); + +if (enabled) +writel (enablemask, base +GIC_DIST_ENABLE_SET + enableoff); + +spin_unlock (&irq_controller_lock); + +return 0 ; +} +#ifdef CONFIG_SMP static int gic_set_cpu (unsigned int irq,const struct cpumask *mask_val) {
@@ -161,6 +206,7 @@ static struct irq_chip gic_chip = { .ack = gic_ack_irq, .mask = gic_mask_irq, .unmask = gic_unmask_irq, + .set_type = gic_set_type,#ifdef CONFIG_SMP .set_affinity = gic_set_cpu,#endif
Signature · 1 line
1.7.0
PATCH 1/1 gic: implement set_type
Quoted 4 lines
arch/arm/common/gic.c +4
-0+static int gic_set_type (unsigned int irq,unsigned int type) +{ +void __iomem *base =gic_dist_base (irq); +unsigned int gicirq =gic_irq (irq);
arch/arm/common/gic.c static void gic_unmask_irq(unsigned int irq) · line 124
Quoted 10 lines
arch/arm/common/gic.c +10
-0+u32 enablemask =1 << (gicirq %32 ); +u32 enableoff = (gicirq /32 ) *4 ; +u32 confmask =0x2 << ((gicirq %16 ) *2 ); +u32 confoff = (gicirq /16 ) *4 ; +bool enabled = false; +u32 val; + +/* Only SPIs' interrupt configuration can be changed */ +if (gicirq <32 ) +return -EINVAL ;
This causes drivers who are requesting PPI's with IRQF_TRIGGER_* flags to fail.
Note that it is "Implementation Defined" whether PPI's are programmable .http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ihi0048a/index.html
I would request to change gicirq < 32 to gicirq < 16 , the writes will be ignored if PPI's are not programmable.
Abhijeet
PATCH 1/1 gic: implement set_type
Quoted 7 lines · Abhijeet Dharmapurikar
arch/arm/common/gic.c static void gic_unmask_irq(unsigned int irq) · line 124
Quoted 3 lines
arch/arm/common/gic.c +3
-0+/* Only SPIs' interrupt configuration can be changed */ +if (gicirq <32 ) +return -EINVAL ;This causes drivers who are requesting PPI's with IRQF_TRIGGER_* flags to fail.
Quoted 5 lines
Note that it is "Implementation Defined" whether PPI's are programmable .http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ihi0048a/index.html
I would request to change gicirq < 32 to gicirq < 16 , the writes will be ignored if PPI's are not programmable.
New patch below: