All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pinctrl: intel: Configure GPIO chip IRQ as wakeup interrupts
@ 2016-09-21 23:03 Nilesh Bacchewar
  2016-10-07 17:59 ` Andy Shevchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Nilesh Bacchewar @ 2016-09-21 23:03 UTC (permalink / raw)
  To: mika.westerberg, heikki.krogerus, linus.walleij, linux-gpio,
	linux-kernel

On some Intel BXT platform, wake-up from suspend-to-idle on pressing
power-button is not working. Its noticed that gpio-keys driver marking the
second level IRQ/power-button as wake capable but Intel pintctrl
driver is missing to mark GPIO chip/controller IRQ which first level IRQ
as wake cable if its GPIO pin IRQ is wakeble. So, though the first level
IRQ gets generated on power-button press, since it is not marked as
wake capable resume/wake-up flow is not happening.
Intel pintctrl/GPIO driver need to mark GPIO chip/controller IRQ (first
level IRQ) as wake capable iff GPIO pin's IRQ (second level IRQ) is marked
as wake cable.

Signed-off-by: Nilesh Bacchewar <nilesh.bacchewar@intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/pinctrl/intel/pinctrl-intel.c | 32 ++++----------------------------
 1 file changed, 4 insertions(+), 28 deletions(-)

diff --git a/drivers/pinctrl/intel/pinctrl-intel.c b/drivers/pinctrl/intel/pinctrl-intel.c
index 257cab1..ad19592 100644
--- a/drivers/pinctrl/intel/pinctrl-intel.c
+++ b/drivers/pinctrl/intel/pinctrl-intel.c
@@ -86,6 +86,7 @@ struct intel_pinctrl_context {
  * @communities: All communities in this pin controller
  * @ncommunities: Number of communities in this pin controller
  * @context: Configuration saved over system sleep
+ * @irq: pinctrl/GPIO chip irq number
  */
 struct intel_pinctrl {
 	struct device *dev;
@@ -97,6 +98,7 @@ struct intel_pinctrl {
 	struct intel_community *communities;
 	size_t ncommunities;
 	struct intel_pinctrl_context context;
+	int irq;
 };
 
 #define pin_to_padno(c, p)	((p) - (c)->pin_base)
@@ -793,38 +795,12 @@ static int intel_gpio_irq_wake(struct irq_data *d, unsigned int on)
 {
 	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 padno, gpp, gpp_offset;
-	unsigned long flags;
-	u32 gpe_en;
-
-	community = intel_get_community(pctrl, pin);
-	if (!community)
-		return -EINVAL;
-
-	raw_spin_lock_irqsave(&pctrl->lock, flags);
 
-	padno = pin_to_padno(community, pin);
-	gpp = padno / community->gpp_size;
-	gpp_offset = padno % community->gpp_size;
-
-	/* Clear the existing wake status */
-	writel(BIT(gpp_offset), community->regs + GPI_GPE_STS + gpp * 4);
-
-	/*
-	 * The controller will generate wake when GPE of the corresponding
-	 * pad is enabled and it is not routed to SCI (GPIROUTSCI is not
-	 * set).
-	 */
-	gpe_en = readl(community->regs + GPI_GPE_EN + gpp * 4);
 	if (on)
-		gpe_en |= BIT(gpp_offset);
+		enable_irq_wake(pctrl->irq);
 	else
-		gpe_en &= ~BIT(gpp_offset);
-	writel(gpe_en, community->regs + GPI_GPE_EN + gpp * 4);
-
-	raw_spin_unlock_irqrestore(&pctrl->lock, flags);
+		disable_irq_wake(pctrl->irq);
 
 	dev_dbg(pctrl->dev, "%sable wake for pin %u\n", on ? "en" : "dis", pin);
 	return 0;
-- 
1.9.1


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

* Re: [PATCH] pinctrl: intel: Configure GPIO chip IRQ as wakeup interrupts
  2016-09-21 23:03 [PATCH] pinctrl: intel: Configure GPIO chip IRQ as wakeup interrupts Nilesh Bacchewar
@ 2016-10-07 17:59 ` Andy Shevchenko
  2016-10-07 18:17   ` Bacchewar, Nilesh
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2016-10-07 17:59 UTC (permalink / raw)
  To: Nilesh Bacchewar
  Cc: Mika Westerberg, Krogerus, Heikki, Linus Walleij, linux-gpio,
	linux-kernel

On Thu, Sep 22, 2016 at 2:03 AM, Nilesh Bacchewar
<nilesh.bacchewar@intel.com> wrote:
> On some Intel BXT platform, wake-up from suspend-to-idle on pressing
> power-button is not working. Its noticed that gpio-keys driver marking the
> second level IRQ/power-button as wake capable but Intel pintctrl
> driver is missing to mark GPIO chip/controller IRQ which first level IRQ
> as wake cable if its GPIO pin IRQ is wakeble. So, though the first level
> IRQ gets generated on power-button press, since it is not marked as
> wake capable resume/wake-up flow is not happening.
> Intel pintctrl/GPIO driver need to mark GPIO chip/controller IRQ (first
> level IRQ) as wake capable iff GPIO pin's IRQ (second level IRQ) is marked
> as wake cable.

>         if (on)
> -               gpe_en |= BIT(gpp_offset);
> +               enable_irq_wake(pctrl->irq);
>         else
> -               gpe_en &= ~BIT(gpp_offset);
> -       writel(gpe_en, community->regs + GPI_GPE_EN + gpp * 4);
> -
> -       raw_spin_unlock_irqrestore(&pctrl->lock, flags);
> +               disable_irq_wake(pctrl->irq);

Shouldn't be refcounting here or I missed something?
What I think of is 2+ GPIO lines marked as wake capable IRQ sources
and one of them is disabled earlier by some reason.

-- 
With Best Regards,
Andy Shevchenko

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

* RE: [PATCH] pinctrl: intel: Configure GPIO chip IRQ as wakeup interrupts
  2016-10-07 17:59 ` Andy Shevchenko
@ 2016-10-07 18:17   ` Bacchewar, Nilesh
  2016-10-07 19:40     ` Andy Shevchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Bacchewar, Nilesh @ 2016-10-07 18:17 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Mika Westerberg, Krogerus, Heikki, Linus Walleij, linux-gpio,
	linux-kernel

Here, Its marking  GPIO controller IRQ line as wake capable not GPIO lines.

Regards,
Nilesh

-----Original Message-----
From: Andy Shevchenko [mailto:andy.shevchenko@gmail.com] 
Sent: Friday, October 7, 2016 10:59 AM
To: Bacchewar, Nilesh <nilesh.bacchewar@intel.com>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>; Krogerus, Heikki <heikki.krogerus@linux.intel.com>; Linus Walleij <linus.walleij@linaro.org>; linux-gpio@vger.kernel.org; linux-kernel@vger.kernel.org
Subject: Re: [PATCH] pinctrl: intel: Configure GPIO chip IRQ as wakeup interrupts

On Thu, Sep 22, 2016 at 2:03 AM, Nilesh Bacchewar <nilesh.bacchewar@intel.com> wrote:
> On some Intel BXT platform, wake-up from suspend-to-idle on pressing 
> power-button is not working. Its noticed that gpio-keys driver marking 
> the second level IRQ/power-button as wake capable but Intel pintctrl 
> driver is missing to mark GPIO chip/controller IRQ which first level 
> IRQ as wake cable if its GPIO pin IRQ is wakeble. So, though the first 
> level IRQ gets generated on power-button press, since it is not marked 
> as wake capable resume/wake-up flow is not happening.
> Intel pintctrl/GPIO driver need to mark GPIO chip/controller IRQ 
> (first level IRQ) as wake capable iff GPIO pin's IRQ (second level 
> IRQ) is marked as wake cable.

>         if (on)
> -               gpe_en |= BIT(gpp_offset);
> +               enable_irq_wake(pctrl->irq);
>         else
> -               gpe_en &= ~BIT(gpp_offset);
> -       writel(gpe_en, community->regs + GPI_GPE_EN + gpp * 4);
> -
> -       raw_spin_unlock_irqrestore(&pctrl->lock, flags);
> +               disable_irq_wake(pctrl->irq);

Shouldn't be refcounting here or I missed something?
What I think of is 2+ GPIO lines marked as wake capable IRQ sources and one of them is disabled earlier by some reason.

--
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH] pinctrl: intel: Configure GPIO chip IRQ as wakeup interrupts
  2016-10-07 18:17   ` Bacchewar, Nilesh
@ 2016-10-07 19:40     ` Andy Shevchenko
  2016-10-09 14:59       ` Mika Westerberg
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2016-10-07 19:40 UTC (permalink / raw)
  To: Bacchewar, Nilesh
  Cc: Mika Westerberg, Krogerus, Heikki, Linus Walleij, linux-gpio,
	linux-kernel

On Fri, Oct 7, 2016 at 9:17 PM, Bacchewar, Nilesh
<nilesh.bacchewar@intel.com> wrote:
> Here, Its marking  GPIO controller IRQ line as wake capable not GPIO lines.

AFAIU this is called per (GPIO) pin which is IRQ enabled.

Imagine a case when you have more than one such pin.

1. Set IRQ wake for pin 1
2. Set IRQ wake for pin 2 (assume that is pin under the question)
3. Unset IRQ wake for pin 1 (for some reason)
4. Global pinctrl IRQ wake is unset. Resulting same issue as before.

What did I miss above?

>
> Regards,
> Nilesh
>
> -----Original Message-----
> From: Andy Shevchenko [mailto:andy.shevchenko@gmail.com]
> Sent: Friday, October 7, 2016 10:59 AM
> To: Bacchewar, Nilesh <nilesh.bacchewar@intel.com>
> Cc: Mika Westerberg <mika.westerberg@linux.intel.com>; Krogerus, Heikki <heikki.krogerus@linux.intel.com>; Linus Walleij <linus.walleij@linaro.org>; linux-gpio@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH] pinctrl: intel: Configure GPIO chip IRQ as wakeup interrupts
>
> On Thu, Sep 22, 2016 at 2:03 AM, Nilesh Bacchewar <nilesh.bacchewar@intel.com> wrote:
>> On some Intel BXT platform, wake-up from suspend-to-idle on pressing
>> power-button is not working. Its noticed that gpio-keys driver marking
>> the second level IRQ/power-button as wake capable but Intel pintctrl
>> driver is missing to mark GPIO chip/controller IRQ which first level
>> IRQ as wake cable if its GPIO pin IRQ is wakeble. So, though the first
>> level IRQ gets generated on power-button press, since it is not marked
>> as wake capable resume/wake-up flow is not happening.
>> Intel pintctrl/GPIO driver need to mark GPIO chip/controller IRQ
>> (first level IRQ) as wake capable iff GPIO pin's IRQ (second level
>> IRQ) is marked as wake cable.
>
>>         if (on)
>> -               gpe_en |= BIT(gpp_offset);
>> +               enable_irq_wake(pctrl->irq);
>>         else
>> -               gpe_en &= ~BIT(gpp_offset);
>> -       writel(gpe_en, community->regs + GPI_GPE_EN + gpp * 4);
>> -
>> -       raw_spin_unlock_irqrestore(&pctrl->lock, flags);
>> +               disable_irq_wake(pctrl->irq);
>
> Shouldn't be refcounting here or I missed something?
> What I think of is 2+ GPIO lines marked as wake capable IRQ sources and one of them is disabled earlier by some reason.
>
> --
> With Best Regards,
> Andy Shevchenko



-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH] pinctrl: intel: Configure GPIO chip IRQ as wakeup interrupts
  2016-10-07 19:40     ` Andy Shevchenko
@ 2016-10-09 14:59       ` Mika Westerberg
  2016-10-09 17:06         ` Andy Shevchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Mika Westerberg @ 2016-10-09 14:59 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Bacchewar, Nilesh, Krogerus, Heikki, Linus Walleij, linux-gpio,
	linux-kernel

On Fri, Oct 07, 2016 at 10:40:42PM +0300, Andy Shevchenko wrote:
> On Fri, Oct 7, 2016 at 9:17 PM, Bacchewar, Nilesh
> <nilesh.bacchewar@intel.com> wrote:
> > Here, Its marking  GPIO controller IRQ line as wake capable not GPIO lines.
> 
> AFAIU this is called per (GPIO) pin which is IRQ enabled.
> 
> Imagine a case when you have more than one such pin.
> 
> 1. Set IRQ wake for pin 1
> 2. Set IRQ wake for pin 2 (assume that is pin under the question)
> 3. Unset IRQ wake for pin 1 (for some reason)
> 4. Global pinctrl IRQ wake is unset. Resulting same issue as before.
> 
> What did I miss above?

enable/disable_irq_wake() include reference count.

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

* Re: [PATCH] pinctrl: intel: Configure GPIO chip IRQ as wakeup interrupts
  2016-10-09 14:59       ` Mika Westerberg
@ 2016-10-09 17:06         ` Andy Shevchenko
  0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2016-10-09 17:06 UTC (permalink / raw)
  To: Mika Westerberg
  Cc: Bacchewar, Nilesh, Krogerus, Heikki, Linus Walleij, linux-gpio,
	linux-kernel

On Sun, Oct 9, 2016 at 5:59 PM, Mika Westerberg
<mika.westerberg@linux.intel.com> wrote:
> On Fri, Oct 07, 2016 at 10:40:42PM +0300, Andy Shevchenko wrote:
>> On Fri, Oct 7, 2016 at 9:17 PM, Bacchewar, Nilesh
>> <nilesh.bacchewar@intel.com> wrote:
>> > Here, Its marking  GPIO controller IRQ line as wake capable not GPIO lines.
>>
>> AFAIU this is called per (GPIO) pin which is IRQ enabled.
>>
>> Imagine a case when you have more than one such pin.
>>
>> 1. Set IRQ wake for pin 1
>> 2. Set IRQ wake for pin 2 (assume that is pin under the question)
>> 3. Unset IRQ wake for pin 1 (for some reason)
>> 4. Global pinctrl IRQ wake is unset. Resulting same issue as before.
>>
>> What did I miss above?
>
> enable/disable_irq_wake() include reference count.

Good to know. Thanks!

-- 
With Best Regards,
Andy Shevchenko

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

end of thread, other threads:[~2016-10-09 17:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-21 23:03 [PATCH] pinctrl: intel: Configure GPIO chip IRQ as wakeup interrupts Nilesh Bacchewar
2016-10-07 17:59 ` Andy Shevchenko
2016-10-07 18:17   ` Bacchewar, Nilesh
2016-10-07 19:40     ` Andy Shevchenko
2016-10-09 14:59       ` Mika Westerberg
2016-10-09 17:06         ` Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.