Skip to contentSkip to conversation

pinctrl:Intel: make the high level interrupt working

PATCH In review Qipeng Zha 3 participants 7 messages Mar 16, 2016 – Apr 13, 2016

Subsystems (3)
lore
Share & tools
lore

Qipeng Zha

author
#0 lore raw

PATCH v2 1/2 pinctrl:Intel: make the high level interrupt working

High level trigger mode of GPIO interrupt is not set correctly in intel_gpio_irq_type(), and will make this kind of interrupt not respond.

---
 drivers/pinctrl/intel/pinctrl-intel.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/pinctrl/intel/pinctrl-intel.c +3 -2
index 85536b4..c216cb3 100644
@@ -741,8 +741,9 @@ static int intel_gpio_irq_type(struct irq_data *d, unsigned type)
 		value |= PADCFG0_RXINV;
 	} else if (type & IRQ_TYPE_EDGE_RISING) {
 		value |= PADCFG0_RXEVCFG_EDGE << PADCFG0_RXEVCFG_SHIFT;
-	} else if (type & IRQ_TYPE_LEVEL_LOW) {
-		value |= PADCFG0_RXINV;
+	} else if (type & IRQ_TYPE_LEVEL_MASK) {
+		if (type & IRQ_TYPE_LEVEL_LOW)
+			value |= PADCFG0_RXINV;
 	} else {
 		value |= PADCFG0_RXEVCFG_DISABLED << PADCFG0_RXEVCFG_SHIFT;
 	}
Signature · 1 line
1.8.3.2
author
#1 lore raw

PATCH v2 2/2 pinctrl:Intel: implement gpio_irq_enable

From: Qi Zheng <[email protected]>

There is unexpected gpio interrupt after irq_enable. If not implemeted gpio_irq_enable callback, irq_enable calls irq_unmask instead. But if there was interrupt set before the irq_enable, unmask it may trigger the unexpected interrupt. By implementing the gpio_irq_enable callback, do interrupt status ack, the issue has gone.

---
change in v2:
remove one blank line.

---
 drivers/pinctrl/intel/pinctrl-intel.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
drivers/pinctrl/intel/pinctrl-intel.c +30 -0
index c216cb3..6c2c816f 100644
@@ -665,6 +665,35 @@ static void intel_gpio_irq_ack(struct irq_data *d)
 	spin_unlock(&pctrl->lock);
 }
 
+static void intel_gpio_irq_enable(struct irq_data *d)
+{
+	struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
+	struct intel_pinctrl *pctrl = gpiochip_get_data(gc);
+	const struct intel_community *community;
+	unsigned pin = irqd_to_hwirq(d);
+	unsigned long flags;
+
+	spin_lock_irqsave(&pctrl->lock, flags);
+
+	community = intel_get_community(pctrl, pin);
+	if (community) {
+		unsigned padno = pin_to_padno(community, pin);
+		unsigned gpp_size = community->gpp_size;
+		unsigned gpp_offset = padno % gpp_size;
+		unsigned gpp = padno / gpp_size;
+		u32 value;
+
+		/* Clear interrupt status first to avoid unexpected interrupt */
+		writel(BIT(gpp_offset), community->regs + GPI_IS + gpp * 4);
+
+		value = readl(community->regs + community->ie_offset + gpp * 4);
+		value |= BIT(gpp_offset);
+		writel(value, community->regs + community->ie_offset + gpp * 4);
+	}
+
+	spin_unlock_irqrestore(&pctrl->lock, flags);
+}
+
 static void intel_gpio_irq_mask_unmask(struct irq_data *d, bool mask)
 {
 	struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
@@ -853,6 +882,7 @@ static irqreturn_t intel_gpio_irq(int irq, void *data)
 
 static struct irq_chip intel_gpio_irqchip = {
 	.name = "intel-gpio",
+	.irq_enable = intel_gpio_irq_enable,
 	.irq_ack = intel_gpio_irq_ack,
 	.irq_mask = intel_gpio_irq_mask,
 	.irq_unmask = intel_gpio_irq_unmask,
Signature · 1 line
1.8.3.2
#2 lore raw

Re: [PATCH v2 2/2] pinctrl:Intel: implement gpio_irq_enable

Quoted 9 lines · Qipeng Zha

From: Qi Zheng <[email protected]>

There is unexpected gpio interrupt after irq_enable. If not implemeted gpio_irq_enable callback, irq_enable calls irq_unmask instead. But if there was interrupt set before the irq_enable, unmask it may trigger the unexpected interrupt. By implementing the gpio_irq_enable callback, do interrupt status ack, the issue has gone.

Quoted 3 lines

Patch applied for fixes.

Yours,
Linus Walleij

#3 lore raw

Re: [PATCH v2 2/2] pinctrl:Intel: implement gpio_irq_enable

Quoted 11 lines · Linus Walleij
Quoted 9 lines · Qipeng Zha

From: Qi Zheng <[email protected]>

There is unexpected gpio interrupt after irq_enable. If not implemeted gpio_irq_enable callback, irq_enable calls irq_unmask instead. But if there was interrupt set before the irq_enable, unmask it may trigger the unexpected interrupt. By implementing the gpio_irq_enable callback, do interrupt status ack, the issue has gone.

Quoted 5 lines
Quoted 3 lines

Patch applied for fixes.

Linus, what happend to these two patches? I do not find them in the mainline for some reason.

#4 lore raw

Re: [PATCH v2 2/2] pinctrl:Intel: implement gpio_irq_enable

Quoted 12 lines · Mika
Quoted 11 lines · Linus Walleij
Quoted 9 lines · Qipeng Zha

From: Qi Zheng <[email protected]>

There is unexpected gpio interrupt after irq_enable. If not implemeted gpio_irq_enable callback, irq_enable calls irq_unmask instead. But if there was interrupt set before the irq_enable, unmask it may trigger the unexpected interrupt. By implementing the gpio_irq_enable callback, do interrupt status ack, the issue has gone.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Patch applied for fixes.

Linus, what happend to these two patches? I do not find them in the mainline for some reason.

I guess lack of patience or me being slow :)

It's there now AFAICT.

Yours,
Linus Walleij

#5 lore raw

Re: [PATCH v2 2/2] pinctrl:Intel: implement gpio_irq_enable

Quoted 18 lines · Linus Walleij
Quoted 16 lines · Mika
Quoted 15 lines · Linus Walleij
Quoted 12 lines · Qipeng Zha

From: Qi Zheng <[email protected]>

There is unexpected gpio interrupt after irq_enable. If not implemeted gpio_irq_enable callback, irq_enable calls irq_unmask instead. But if there was interrupt set before the irq_enable, unmask it may trigger the unexpected interrupt. By implementing the gpio_irq_enable callback, do interrupt status ack, the issue has gone.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Patch applied for fixes.

Linus, what happend to these two patches? I do not find them in the mainline for some reason.

I guess lack of patience or me being slow :)

It's there now AFAICT.

Thank you :)