linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gic: implement set_type
@ 2010-01-05  4:26 Rabin Vincent
  0 siblings, 0 replies; 4+ messages in thread
From: Rabin Vincent @ 2010-01-05  4:26 UTC (permalink / raw)
  To: linux-arm-kernel

Implement set_type() to allow configuration of the trigger type.

Cc: Abhijeet Dharmapurikar <adharmap@quicinc.com>
Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com>
---
 arch/arm/common/gic.c |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/arch/arm/common/gic.c b/arch/arm/common/gic.c
index 337741f..7dfa9a8 100644
--- a/arch/arm/common/gic.c
+++ b/arch/arm/common/gic.c
@@ -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;
+
+	/* Interrupt configuration for SGIs can't be changed */
+	if (gicirq < 16)
+		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, disable the interrupt before changing
+	 * the configuration
+	 */
+	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
-- 
1.7.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] gic: implement set_type
@ 2010-05-11 10:48 Rabin Vincent
  2010-05-14 16:32 ` Abhijeet Dharmapurikar
  0 siblings, 1 reply; 4+ messages in thread
From: Rabin Vincent @ 2010-05-11 10:48 UTC (permalink / raw)
  To: linux-arm-kernel

Implement set_type() to allow configuration of the trigger type for
SPIs.

Cc: Abhijeet Dharmapurikar <adharmap@quicinc.com>
Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com>
---
 arch/arm/common/gic.c |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/arch/arm/common/gic.c b/arch/arm/common/gic.c
index 337741f..826cdac 100644
--- a/arch/arm/common/gic.c
+++ b/arch/arm/common/gic.c
@@ -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
-- 
1.7.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] gic: implement set_type
  2010-05-11 10:48 [PATCH] gic: implement set_type Rabin Vincent
@ 2010-05-14 16:32 ` Abhijeet Dharmapurikar
  2010-05-17  5:20   ` Rabin VINCENT
  0 siblings, 1 reply; 4+ messages in thread
From: Abhijeet Dharmapurikar @ 2010-05-14 16:32 UTC (permalink / raw)
  To: linux-arm-kernel

> +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;


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] gic: implement set_type
  2010-05-14 16:32 ` Abhijeet Dharmapurikar
@ 2010-05-17  5:20   ` Rabin VINCENT
  0 siblings, 0 replies; 4+ messages in thread
From: Rabin VINCENT @ 2010-05-17  5:20 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, May 14, 2010 at 06:32:00PM +0200, Abhijeet Dharmapurikar wrote:
> > +	/* 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.

New patch below:

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-05-17  5:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-11 10:48 [PATCH] gic: implement set_type Rabin Vincent
2010-05-14 16:32 ` Abhijeet Dharmapurikar
2010-05-17  5:20   ` Rabin VINCENT
  -- strict thread matches above, loose matches on Subject: below --
2010-01-05  4:26 Rabin Vincent

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).