From patchwork Tue Feb 12 14:17:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 1040612 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; dmarc=none (p=none dis=none) header.from=glider.be Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43zPql2z8kz9s3x for ; Wed, 13 Feb 2019 01:17:23 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730223AbfBLORW (ORCPT ); Tue, 12 Feb 2019 09:17:22 -0500 Received: from xavier.telenet-ops.be ([195.130.132.52]:58132 "EHLO xavier.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730198AbfBLORS (ORCPT ); Tue, 12 Feb 2019 09:17:18 -0500 Received: from ramsan ([84.194.111.163]) by xavier.telenet-ops.be with bizsmtp id bqHG1z00c3XaVaC01qHGjt; Tue, 12 Feb 2019 15:17:16 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan with esmtp (Exim 4.90_1) (envelope-from ) id 1gtYs8-0005e9-FJ; Tue, 12 Feb 2019 15:17:16 +0100 Received: from geert by rox.of.borg with local (Exim 4.90_1) (envelope-from ) id 1gtYs8-00012h-D1; Tue, 12 Feb 2019 15:17:16 +0100 From: Geert Uytterhoeven To: Linus Walleij , Bartosz Golaszewski Cc: linux-gpio@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH] gpio: pca953x: Add wake-up support Date: Tue, 12 Feb 2019 15:17:15 +0100 Message-Id: <20190212141715.3966-1-geert+renesas@glider.be> X-Mailer: git-send-email 2.17.1 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Implement the irq_set_wake() method in the (optional) irq_chip of the GPIO expander, and propagate wake-up settings to the upstream interrupt controller. This allows GPIOs connected to a PCA953X GPIO expander to serve as wake-up sources. Signed-off-by: Geert Uytterhoeven --- Tested with a PCA9654 and gpio-keys on an R-Car Ebisu-4D board. --- drivers/gpio/gpio-pca953x.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index de52f63863dbe59b..8dfb8e326b9d12ca 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -151,6 +151,7 @@ struct pca953x_chip { u8 irq_trig_raise[MAX_BANK]; u8 irq_trig_fall[MAX_BANK]; struct irq_chip irq_chip; + unsigned int irq_parent; #endif struct i2c_client *client; @@ -513,6 +514,24 @@ static void pca953x_irq_unmask(struct irq_data *d) chip->irq_mask[d->hwirq / BANK_SZ] |= 1 << (d->hwirq % BANK_SZ); } +static int pca953x_irq_set_wake(struct irq_data *d, unsigned int on) +{ + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct pca953x_chip *chip = gpiochip_get_data(gc); + int error = 0; + + if (chip->irq_parent) { + error = irq_set_irq_wake(chip->irq_parent, on); + if (error) { + dev_dbg(&chip->client->dev, + "irq %u doesn't support irq_set_wake\n", + chip->irq_parent); + chip->irq_parent = 0; + } + } + return error; +} + static void pca953x_irq_bus_lock(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); @@ -732,6 +751,7 @@ static int pca953x_irq_setup(struct pca953x_chip *chip, irq_chip->name = dev_name(&chip->client->dev); irq_chip->irq_mask = pca953x_irq_mask; irq_chip->irq_unmask = pca953x_irq_unmask; + irq_chip->irq_set_wake = pca953x_irq_set_wake; irq_chip->irq_bus_lock = pca953x_irq_bus_lock; irq_chip->irq_bus_sync_unlock = pca953x_irq_bus_sync_unlock; irq_chip->irq_set_type = pca953x_irq_set_type; @@ -747,6 +767,7 @@ static int pca953x_irq_setup(struct pca953x_chip *chip, } gpiochip_set_nested_irqchip(&chip->gpio_chip, irq_chip, client->irq); + chip->irq_parent = client->irq; return 0; }