linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/1] pinctrl: baytrail: Do not add all GPIOs to IRQ domain
@ 2017-01-11 13:49 Andy Shevchenko
  2017-01-11 14:02 ` Mika Westerberg
  2017-01-12  7:12 ` Linus Walleij
  0 siblings, 2 replies; 3+ messages in thread
From: Andy Shevchenko @ 2017-01-11 13:49 UTC (permalink / raw)
  To: Linus Walleij, linux-gpio, Mika Westerberg, Robert R . Howell
  Cc: Andy Shevchenko

When DIRECT_IRQ_EN is set, the pin is routed directly to the IO-APIC bypassing
the GPIO driver completely. However, the mask register is still used to
determine if the pin is supposed to generate IRQ or not.

So with commit 3ae02c14d964 the IRQ core masks all IRQs (because of
handle_bad_irq()) the pin connected to the touchscreen gets masked as well and
hence no interrupts.

To make this all work as expected we do not add those GPIOs to the IRQ domain
that can actually propagate interrupts.

Fixes: 3ae02c14d964 ("pinctrl: intel: set default handler to be handle_bad_irq()")
Reported-by: Robert R. Howell <rhowell@uwyo.edu>
Suggested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
In v3:
- drop upstreamed patch
- fix commit message (Mika)
- add Suggested-by tag
 drivers/pinctrl/intel/pinctrl-baytrail.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/pinctrl/intel/pinctrl-baytrail.c b/drivers/pinctrl/intel/pinctrl-baytrail.c
index 000eb79ecf07..e696a01365cb 100644
--- a/drivers/pinctrl/intel/pinctrl-baytrail.c
+++ b/drivers/pinctrl/intel/pinctrl-baytrail.c
@@ -1623,6 +1623,8 @@ static void byt_gpio_irq_handler(struct irq_desc *desc)
 
 static void byt_gpio_irq_init_hw(struct byt_gpio *vg)
 {
+	struct gpio_chip *gc = &vg->chip;
+	struct device *dev = &vg->pdev->dev;
 	void __iomem *reg;
 	u32 base, value;
 	int i;
@@ -1644,10 +1646,12 @@ static void byt_gpio_irq_init_hw(struct byt_gpio *vg)
 		}
 
 		value = readl(reg);
-		if ((value & BYT_PIN_MUX) == byt_get_gpio_mux(vg, i) &&
-		    !(value & BYT_DIRECT_IRQ_EN)) {
+		if (value & BYT_DIRECT_IRQ_EN) {
+			clear_bit(i, gc->irq_valid_mask);
+			dev_dbg(dev, "excluding GPIO %d from IRQ domain\n", i);
+		} else if ((value & BYT_PIN_MUX) == byt_get_gpio_mux(vg, i)) {
 			byt_gpio_clear_triggering(vg, i);
-			dev_dbg(&vg->pdev->dev, "disabling GPIO %d\n", i);
+			dev_dbg(dev, "disabling GPIO %d\n", i);
 		}
 	}
 
@@ -1686,6 +1690,7 @@ static int byt_gpio_probe(struct byt_gpio *vg)
 	gc->can_sleep	= false;
 	gc->parent	= &vg->pdev->dev;
 	gc->ngpio	= vg->soc_data->npins;
+	gc->irq_need_valid_mask	= true;
 
 #ifdef CONFIG_PM_SLEEP
 	vg->saved_context = devm_kcalloc(&vg->pdev->dev, gc->ngpio,
-- 
2.11.0


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

* Re: [PATCH v2 1/1] pinctrl: baytrail: Do not add all GPIOs to IRQ domain
  2017-01-11 13:49 [PATCH v2 1/1] pinctrl: baytrail: Do not add all GPIOs to IRQ domain Andy Shevchenko
@ 2017-01-11 14:02 ` Mika Westerberg
  2017-01-12  7:12 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Mika Westerberg @ 2017-01-11 14:02 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Linus Walleij, linux-gpio, Robert R . Howell

On Wed, Jan 11, 2017 at 03:49:00PM +0200, Andy Shevchenko wrote:
> When DIRECT_IRQ_EN is set, the pin is routed directly to the IO-APIC bypassing
> the GPIO driver completely. However, the mask register is still used to
> determine if the pin is supposed to generate IRQ or not.
> 
> So with commit 3ae02c14d964 the IRQ core masks all IRQs (because of
> handle_bad_irq()) the pin connected to the touchscreen gets masked as well and
> hence no interrupts.
> 
> To make this all work as expected we do not add those GPIOs to the IRQ domain
> that can actually propagate interrupts.
> 
> Fixes: 3ae02c14d964 ("pinctrl: intel: set default handler to be handle_bad_irq()")
> Reported-by: Robert R. Howell <rhowell@uwyo.edu>
> Suggested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>

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

* Re: [PATCH v2 1/1] pinctrl: baytrail: Do not add all GPIOs to IRQ domain
  2017-01-11 13:49 [PATCH v2 1/1] pinctrl: baytrail: Do not add all GPIOs to IRQ domain Andy Shevchenko
  2017-01-11 14:02 ` Mika Westerberg
@ 2017-01-12  7:12 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2017-01-12  7:12 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-gpio@vger.kernel.org, Mika Westerberg, Robert R . Howell

On Wed, Jan 11, 2017 at 2:49 PM, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:

> When DIRECT_IRQ_EN is set, the pin is routed directly to the IO-APIC bypassing
> the GPIO driver completely. However, the mask register is still used to
> determine if the pin is supposed to generate IRQ or not.
>
> So with commit 3ae02c14d964 the IRQ core masks all IRQs (because of
> handle_bad_irq()) the pin connected to the touchscreen gets masked as well and
> hence no interrupts.
>
> To make this all work as expected we do not add those GPIOs to the IRQ domain
> that can actually propagate interrupts.
>
> Fixes: 3ae02c14d964 ("pinctrl: intel: set default handler to be handle_bad_irq()")
> Reported-by: Robert R. Howell <rhowell@uwyo.edu>
> Suggested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> In v3:

Patch applied for fixes.

Yours,
Linus Walleij

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

end of thread, other threads:[~2017-01-12  7:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-11 13:49 [PATCH v2 1/1] pinctrl: baytrail: Do not add all GPIOs to IRQ domain Andy Shevchenko
2017-01-11 14:02 ` Mika Westerberg
2017-01-12  7:12 ` Linus Walleij

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).