linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] pinctrl: sunxi: Forward calls to irq_set_irq_wake
@ 2020-01-17 21:33 Samuel Holland
  2020-01-17 21:33 ` [PATCH 2/2] pinctrl: sunxi: Mask non-wakeup IRQs on suspend Samuel Holland
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Samuel Holland @ 2020-01-17 21:33 UTC (permalink / raw)
  To: Maxime Ripard, Chen-Yu Tsai, Linus Walleij
  Cc: linux-arm-kernel, linux-gpio, linux-kernel, linux-sunxi, Samuel Holland

The pinctrl irqchip may be connected to an irqchip that implements the
.irq_set_wake callback, such as the R_INTC on A31 and newer sunxi SoCs.
In order for GPIOs to be able to trigger wakeup, the IRQ from the
pinctrl to the upper irqchip must also be enabled for wakeup. Since the
kernel's IRQ core already manages the "wake_depth" of each IRQ, no
additional accounting is needed in the pinctrl driver.

Signed-off-by: Samuel Holland <samuel@sholland.org>
---
 drivers/pinctrl/sunxi/pinctrl-sunxi.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
index 0cbca30b75dc..df79da76321e 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
@@ -13,6 +13,7 @@
 #include <linux/io.h>
 #include <linux/clk.h>
 #include <linux/gpio/driver.h>
+#include <linux/interrupt.h>
 #include <linux/irqdomain.h>
 #include <linux/irqchip/chained_irq.h>
 #include <linux/export.h>
@@ -1058,6 +1059,14 @@ static void sunxi_pinctrl_irq_ack_unmask(struct irq_data *d)
 	sunxi_pinctrl_irq_unmask(d);
 }
 
+static int sunxi_pinctrl_irq_set_wake(struct irq_data *d, unsigned int on)
+{
+	struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d);
+	u8 bank = d->hwirq / IRQ_PER_BANK;
+
+	return irq_set_irq_wake(pctl->irq[bank], on);
+}
+
 static struct irq_chip sunxi_pinctrl_edge_irq_chip = {
 	.name		= "sunxi_pio_edge",
 	.irq_ack	= sunxi_pinctrl_irq_ack,
@@ -1066,7 +1075,7 @@ static struct irq_chip sunxi_pinctrl_edge_irq_chip = {
 	.irq_request_resources = sunxi_pinctrl_irq_request_resources,
 	.irq_release_resources = sunxi_pinctrl_irq_release_resources,
 	.irq_set_type	= sunxi_pinctrl_irq_set_type,
-	.flags		= IRQCHIP_SKIP_SET_WAKE,
+	.irq_set_wake	= sunxi_pinctrl_irq_set_wake,
 };
 
 static struct irq_chip sunxi_pinctrl_level_irq_chip = {
@@ -1081,7 +1090,8 @@ static struct irq_chip sunxi_pinctrl_level_irq_chip = {
 	.irq_request_resources = sunxi_pinctrl_irq_request_resources,
 	.irq_release_resources = sunxi_pinctrl_irq_release_resources,
 	.irq_set_type	= sunxi_pinctrl_irq_set_type,
-	.flags		= IRQCHIP_SKIP_SET_WAKE | IRQCHIP_EOI_THREADED |
+	.irq_set_wake	= sunxi_pinctrl_irq_set_wake,
+	.flags		= IRQCHIP_EOI_THREADED |
 			  IRQCHIP_EOI_IF_HANDLED,
 };
 
-- 
2.23.0


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

* [PATCH 2/2] pinctrl: sunxi: Mask non-wakeup IRQs on suspend
  2020-01-17 21:33 [PATCH 1/2] pinctrl: sunxi: Forward calls to irq_set_irq_wake Samuel Holland
@ 2020-01-17 21:33 ` Samuel Holland
  2020-02-21 14:15   ` Linus Walleij
  2020-02-13  1:45 ` [PATCH 1/2] pinctrl: sunxi: Forward calls to irq_set_irq_wake Samuel Holland
  2020-02-21 14:15 ` Linus Walleij
  2 siblings, 1 reply; 6+ messages in thread
From: Samuel Holland @ 2020-01-17 21:33 UTC (permalink / raw)
  To: Maxime Ripard, Chen-Yu Tsai, Linus Walleij
  Cc: linux-arm-kernel, linux-gpio, linux-kernel, linux-sunxi, Samuel Holland

The pin controller hardware does not distinguish IRQs intended for
wakeup from other IRQs, so we must mask non-wakeup IRQs in software to
prevent inadvertent wakeups. This is accomplished at the irqchip level
via the IRQCHIP_MASK_ON_SUSPEND flag.

Signed-off-by: Samuel Holland <samuel@sholland.org>
---
 drivers/pinctrl/sunxi/pinctrl-sunxi.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
index df79da76321e..24ff591efded 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
@@ -1076,6 +1076,7 @@ static struct irq_chip sunxi_pinctrl_edge_irq_chip = {
 	.irq_release_resources = sunxi_pinctrl_irq_release_resources,
 	.irq_set_type	= sunxi_pinctrl_irq_set_type,
 	.irq_set_wake	= sunxi_pinctrl_irq_set_wake,
+	.flags		= IRQCHIP_MASK_ON_SUSPEND,
 };
 
 static struct irq_chip sunxi_pinctrl_level_irq_chip = {
@@ -1092,6 +1093,7 @@ static struct irq_chip sunxi_pinctrl_level_irq_chip = {
 	.irq_set_type	= sunxi_pinctrl_irq_set_type,
 	.irq_set_wake	= sunxi_pinctrl_irq_set_wake,
 	.flags		= IRQCHIP_EOI_THREADED |
+			  IRQCHIP_MASK_ON_SUSPEND |
 			  IRQCHIP_EOI_IF_HANDLED,
 };
 
-- 
2.23.0


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

* Re: [PATCH 1/2] pinctrl: sunxi: Forward calls to irq_set_irq_wake
  2020-01-17 21:33 [PATCH 1/2] pinctrl: sunxi: Forward calls to irq_set_irq_wake Samuel Holland
  2020-01-17 21:33 ` [PATCH 2/2] pinctrl: sunxi: Mask non-wakeup IRQs on suspend Samuel Holland
@ 2020-02-13  1:45 ` Samuel Holland
  2020-02-14 13:14   ` Maxime Ripard
  2020-02-21 14:15 ` Linus Walleij
  2 siblings, 1 reply; 6+ messages in thread
From: Samuel Holland @ 2020-02-13  1:45 UTC (permalink / raw)
  To: Maxime Ripard, Chen-Yu Tsai, Linus Walleij
  Cc: linux-arm-kernel, linux-gpio, linux-kernel, linux-sunxi

All,

On 1/17/20 3:33 PM, Samuel Holland wrote:
> The pinctrl irqchip may be connected to an irqchip that implements the
> .irq_set_wake callback, such as the R_INTC on A31 and newer sunxi SoCs.
> In order for GPIOs to be able to trigger wakeup, the IRQ from the
> pinctrl to the upper irqchip must also be enabled for wakeup. Since the
> kernel's IRQ core already manages the "wake_depth" of each IRQ, no
> additional accounting is needed in the pinctrl driver.

Ping. Any comments on these two patches?

Thanks,
Samuel Holland

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

* Re: [PATCH 1/2] pinctrl: sunxi: Forward calls to irq_set_irq_wake
  2020-02-13  1:45 ` [PATCH 1/2] pinctrl: sunxi: Forward calls to irq_set_irq_wake Samuel Holland
@ 2020-02-14 13:14   ` Maxime Ripard
  0 siblings, 0 replies; 6+ messages in thread
From: Maxime Ripard @ 2020-02-14 13:14 UTC (permalink / raw)
  To: Samuel Holland
  Cc: Chen-Yu Tsai, Linus Walleij, linux-arm-kernel, linux-gpio,
	linux-kernel, linux-sunxi

[-- Attachment #1: Type: text/plain, Size: 654 bytes --]

On Wed, Feb 12, 2020 at 07:45:50PM -0600, Samuel Holland wrote:
> All,
>
> On 1/17/20 3:33 PM, Samuel Holland wrote:
> > The pinctrl irqchip may be connected to an irqchip that implements the
> > .irq_set_wake callback, such as the R_INTC on A31 and newer sunxi SoCs.
> > In order for GPIOs to be able to trigger wakeup, the IRQ from the
> > pinctrl to the upper irqchip must also be enabled for wakeup. Since the
> > kernel's IRQ core already manages the "wake_depth" of each IRQ, no
> > additional accounting is needed in the pinctrl driver.
>
> Ping. Any comments on these two patches?

For both,

Acked-by: Maxime Ripard <mripard@kernel.org>

Maxime

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

* Re: [PATCH 1/2] pinctrl: sunxi: Forward calls to irq_set_irq_wake
  2020-01-17 21:33 [PATCH 1/2] pinctrl: sunxi: Forward calls to irq_set_irq_wake Samuel Holland
  2020-01-17 21:33 ` [PATCH 2/2] pinctrl: sunxi: Mask non-wakeup IRQs on suspend Samuel Holland
  2020-02-13  1:45 ` [PATCH 1/2] pinctrl: sunxi: Forward calls to irq_set_irq_wake Samuel Holland
@ 2020-02-21 14:15 ` Linus Walleij
  2 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2020-02-21 14:15 UTC (permalink / raw)
  To: Samuel Holland
  Cc: Maxime Ripard, Chen-Yu Tsai, Linux ARM, open list:GPIO SUBSYSTEM,
	linux-kernel, linux-sunxi

On Fri, Jan 17, 2020 at 10:33 PM Samuel Holland <samuel@sholland.org> wrote:

> The pinctrl irqchip may be connected to an irqchip that implements the
> .irq_set_wake callback, such as the R_INTC on A31 and newer sunxi SoCs.
> In order for GPIOs to be able to trigger wakeup, the IRQ from the
> pinctrl to the upper irqchip must also be enabled for wakeup. Since the
> kernel's IRQ core already manages the "wake_depth" of each IRQ, no
> additional accounting is needed in the pinctrl driver.
>
> Signed-off-by: Samuel Holland <samuel@sholland.org>

Patch applied with Maxime's ACK.

Yours,
Linus Walleij

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

* Re: [PATCH 2/2] pinctrl: sunxi: Mask non-wakeup IRQs on suspend
  2020-01-17 21:33 ` [PATCH 2/2] pinctrl: sunxi: Mask non-wakeup IRQs on suspend Samuel Holland
@ 2020-02-21 14:15   ` Linus Walleij
  0 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2020-02-21 14:15 UTC (permalink / raw)
  To: Samuel Holland
  Cc: Maxime Ripard, Chen-Yu Tsai, Linux ARM, open list:GPIO SUBSYSTEM,
	linux-kernel, linux-sunxi

On Fri, Jan 17, 2020 at 10:33 PM Samuel Holland <samuel@sholland.org> wrote:

> The pin controller hardware does not distinguish IRQs intended for
> wakeup from other IRQs, so we must mask non-wakeup IRQs in software to
> prevent inadvertent wakeups. This is accomplished at the irqchip level
> via the IRQCHIP_MASK_ON_SUSPEND flag.
>
> Signed-off-by: Samuel Holland <samuel@sholland.org>

Patch applied.

Yours,
Linus Walleij

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

end of thread, other threads:[~2020-02-21 14:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-17 21:33 [PATCH 1/2] pinctrl: sunxi: Forward calls to irq_set_irq_wake Samuel Holland
2020-01-17 21:33 ` [PATCH 2/2] pinctrl: sunxi: Mask non-wakeup IRQs on suspend Samuel Holland
2020-02-21 14:15   ` Linus Walleij
2020-02-13  1:45 ` [PATCH 1/2] pinctrl: sunxi: Forward calls to irq_set_irq_wake Samuel Holland
2020-02-14 13:14   ` Maxime Ripard
2020-02-21 14:15 ` 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).