From patchwork Fri Sep 8 22:41:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hoan Tran X-Patchwork-Id: 811854 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=apm.com header.i=@apm.com header.b="JSfzykEx"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xpsnv5Cn0z9sRV for ; Sat, 9 Sep 2017 08:44:35 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756939AbdIHWoe (ORCPT ); Fri, 8 Sep 2017 18:44:34 -0400 Received: from mail-io0-f179.google.com ([209.85.223.179]:35187 "EHLO mail-io0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753011AbdIHWod (ORCPT ); Fri, 8 Sep 2017 18:44:33 -0400 Received: by mail-io0-f179.google.com with SMTP id i14so8514276ioe.2 for ; Fri, 08 Sep 2017 15:44:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apm.com; s=apm; h=from:to:cc:subject:date:message-id; bh=+6uS8+8Vq9ynyj+b1fJ5SPxzzXEQzQpEkR2ge3wQuLo=; b=JSfzykExwrsABsQGZQeT+xoppjnp0FQfNGJwMyzjcruqHsR/7rxE1q1/yM7mLeaH8t p4c06IA9ttUh8C83L+WkQNUyQOKVK2JV7qMGRzpvqGcCq8WG2wQEmaJ95XA1oEiJpjma hOKsmNjZuKO7cdjIfLIDvKPxK7CgEKEMKaHZE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=+6uS8+8Vq9ynyj+b1fJ5SPxzzXEQzQpEkR2ge3wQuLo=; b=WaqLypuUm/7H1T8SDcpm9jRVKt6G9QUYY0ZUsXrF3kxXaMF9h4dwlGXEo6rzJa6Ahj w+1gePyBgz8ZfAKbv5hw6uT9Ag+xEnVqiB69VMzp2ImcLjki/m/5ec5V5w6RQG4IGsCo GqPfaqxuzdoshfCApTFAmT8zhhv19V/TUSdLFWMn0o08T125VrEep2cFCMng3odDWzn5 GyDsqpSxuB6LMNfSAz2xmOoKg0NFUVoL2dY9YDDW9wGwUxFrEOUcMB4Jvi94WidxCgLm +mmjP/FyOwkUc+lhQDwIp3E5Eofm2hsJaJS5Mxaq5gaedcYl+gkArbBttTwhAtQs+IIy ePkQ== X-Gm-Message-State: AHPjjUhMjK8hiaYiOMyjaucNU94tFZT8EYK2GK9GVBjE1SzOF9vGD2Ks iBr9h0wXQko8Pvqu X-Google-Smtp-Source: AOwi7QDioUGYHzo7YEGc6O/dSGu8NoY7TiofJ5suOAaEzXPEhkdjQ4EuN5XZQh+lFNgwNL69xGe0Yw== X-Received: by 10.107.142.13 with SMTP id q13mr5217807iod.153.1504910672344; Fri, 08 Sep 2017 15:44:32 -0700 (PDT) Received: from hotran_localhost.amcc.com ([206.80.4.98]) by smtp.gmail.com with ESMTPSA id t197sm1535604itb.23.2017.09.08.15.44.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 08 Sep 2017 15:44:31 -0700 (PDT) From: Hoan Tran To: Linus Walleij , Alexandre Courbot , Jamie Iles , Andy Shevchenko , Sebastian Andrzej Siewior Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, lho@apm.com, kdinh@apm.com, Hoan Tran Subject: [PATCH] gpio: dwapb: Add wakeup source support Date: Fri, 8 Sep 2017 15:41:15 -0700 Message-Id: <1504910475-6682-1-git-send-email-hotran@apm.com> X-Mailer: git-send-email 1.9.1 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org 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 --- 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);