linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpio: dwapb: Add wakeup source support
@ 2017-09-08 22:41 Hoan Tran
  2017-09-12  9:47 ` Linus Walleij
  0 siblings, 1 reply; 4+ messages in thread
From: Hoan Tran @ 2017-09-08 22:41 UTC (permalink / raw)
  To: Linus Walleij, Alexandre Courbot, Jamie Iles, Andy Shevchenko,
	Sebastian Andrzej Siewior
  Cc: linux-gpio, linux-kernel, lho, kdinh, Hoan Tran

This patch supports irq_set_wake for dwapb gpio. It allows GPIOs
to be configured as wakeup sources and wake the system from suspend.

Signed-off-by: Hoan Tran <hotran@apm.com>
---
 drivers/gpio/gpio-dwapb.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c
index c07ada9..5cdb7bc 100644
--- a/drivers/gpio/gpio-dwapb.c
+++ b/drivers/gpio/gpio-dwapb.c
@@ -77,6 +77,7 @@ struct dwapb_context {
 	u32 int_type;
 	u32 int_pol;
 	u32 int_deb;
+	u32 wake_en;
 };
 #endif
 
@@ -295,6 +296,22 @@ static int dwapb_irq_set_type(struct irq_data *d, u32 type)
 	return 0;
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int dwapb_irq_set_wake(struct irq_data *d, unsigned int enable)
+{
+	struct irq_chip_generic *igc = irq_data_get_irq_chip_data(d);
+	struct dwapb_gpio *gpio = igc->private;
+	struct dwapb_context *ctx = gpio->ports[0].ctx;
+
+	if (enable)
+		ctx->wake_en |= BIT(d->hwirq);
+	else
+		ctx->wake_en &= ~BIT(d->hwirq);
+
+	return 0;
+}
+#endif
+
 static int dwapb_gpio_set_debounce(struct gpio_chip *gc,
 				   unsigned offset, unsigned debounce)
 {
@@ -385,6 +402,9 @@ static void dwapb_configure_irqs(struct dwapb_gpio *gpio,
 		ct->chip.irq_disable = dwapb_irq_disable;
 		ct->chip.irq_request_resources = dwapb_irq_reqres;
 		ct->chip.irq_release_resources = dwapb_irq_relres;
+#ifdef CONFIG_PM_SLEEP
+		ct->chip.irq_set_wake = dwapb_irq_set_wake;
+#endif
 		ct->regs.ack = gpio_reg_convert(gpio, GPIO_PORTA_EOI);
 		ct->regs.mask = gpio_reg_convert(gpio, GPIO_INTMASK);
 		ct->type = IRQ_TYPE_LEVEL_MASK;
@@ -699,7 +719,8 @@ static int dwapb_gpio_suspend(struct device *dev)
 			ctx->int_deb	= dwapb_read(gpio, GPIO_PORTA_DEBOUNCE);
 
 			/* Mask out interrupts */
-			dwapb_write(gpio, GPIO_INTMASK, 0xffffffff);
+			dwapb_write(gpio, GPIO_INTMASK,
+				    0xffffffff & ~ctx->wake_en);
 		}
 	}
 	spin_unlock_irqrestore(&gc->bgpio_lock, flags);
-- 
1.9.1

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

* Re: [PATCH] gpio: dwapb: Add wakeup source support
  2017-09-08 22:41 [PATCH] gpio: dwapb: Add wakeup source support Hoan Tran
@ 2017-09-12  9:47 ` Linus Walleij
  2017-09-12 22:14   ` Jamie Iles
  0 siblings, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2017-09-12  9:47 UTC (permalink / raw)
  To: Hoan Tran, Xiaoguang Chen, Jisheng Zhang, Jamie Iles
  Cc: Alexandre Courbot, Andy Shevchenko, Sebastian Andrzej Siewior,
	linux-gpio, linux-kernel, Loc Ho, kdinh

On Sat, Sep 9, 2017 at 12:41 AM, Hoan Tran <hotran@apm.com> wrote:

> This patch supports irq_set_wake for dwapb gpio. It allows GPIOs
> to be configured as wakeup sources and wake the system from suspend.
>
> Signed-off-by: Hoan Tran <hotran@apm.com>

Seems very useful, patch applied for v4.15 (next).

This important, complex and versatile driver does not
have an active maintainer in MAINTAINERS.

Jamie, do you consider yourself maintainer? If not
would someone else using this driver please step up?

Yours,
Linus Walleij

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

* Re: [PATCH] gpio: dwapb: Add wakeup source support
  2017-09-12  9:47 ` Linus Walleij
@ 2017-09-12 22:14   ` Jamie Iles
  2017-09-14  9:15     ` Linus Walleij
  0 siblings, 1 reply; 4+ messages in thread
From: Jamie Iles @ 2017-09-12 22:14 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Hoan Tran, Xiaoguang Chen, Jisheng Zhang, Jamie Iles,
	Alexandre Courbot, Andy Shevchenko, Sebastian Andrzej Siewior,
	linux-gpio, linux-kernel, Loc Ho, kdinh

Hi Linus,

On Tue, Sep 12, 2017 at 11:47:52AM +0200, Linus Walleij wrote:
> Jamie, do you consider yourself maintainer? If not
> would someone else using this driver please step up?

I don't think I'm best suited to the job - I don't actually have access 
to the docs for this IP block any more so can't provide meaningful 
review for hardware details.

Thanks,

Jamie

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

* Re: [PATCH] gpio: dwapb: Add wakeup source support
  2017-09-12 22:14   ` Jamie Iles
@ 2017-09-14  9:15     ` Linus Walleij
  0 siblings, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2017-09-14  9:15 UTC (permalink / raw)
  To: Jamie Iles, Hoan Tran
  Cc: Xiaoguang Chen, Jisheng Zhang, Alexandre Courbot,
	Andy Shevchenko, Sebastian Andrzej Siewior, linux-gpio,
	linux-kernel, Loc Ho, Khuong Dinh

On Wed, Sep 13, 2017 at 12:14 AM, Jamie Iles <jamie@jamieiles.com> wrote:
> On Tue, Sep 12, 2017 at 11:47:52AM +0200, Linus Walleij wrote:
>> Jamie, do you consider yourself maintainer? If not
>> would someone else using this driver please step up?
>
> I don't think I'm best suited to the job - I don't actually have access
> to the docs for this IP block any more so can't provide meaningful
> review for hardware details.

Fair enough.

Hoan, would you please consider adding yourself as maintainer
for this driver in MAINTAINERS?

Yours,
Linus Walleij

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

end of thread, other threads:[~2017-09-14  9:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-08 22:41 [PATCH] gpio: dwapb: Add wakeup source support Hoan Tran
2017-09-12  9:47 ` Linus Walleij
2017-09-12 22:14   ` Jamie Iles
2017-09-14  9: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).