From patchwork Tue Dec 10 22:47:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 3320651 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 92D909F37C for ; Tue, 10 Dec 2013 22:48:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CDA4D20705 for ; Tue, 10 Dec 2013 22:48:26 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D094520700 for ; Tue, 10 Dec 2013 22:48:25 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VqW5y-0004hj-Cj; Tue, 10 Dec 2013 22:48:02 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VqW5o-0000FF-QP; Tue, 10 Dec 2013 22:47:52 +0000 Received: from mail-pd0-x235.google.com ([2607:f8b0:400e:c02::235]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VqW5m-0000DU-H8 for linux-arm-kernel@lists.infradead.org; Tue, 10 Dec 2013 22:47:51 +0000 Received: by mail-pd0-f181.google.com with SMTP id p10so8269162pdj.12 for ; Tue, 10 Dec 2013 14:47:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=WR34dNcmXmXIUMxgsPLUT2hdwCG7uzdyVJuTApwY0io=; b=BsVhvhdxIakQCUpkGLzPUmI0RRNt1RLbNBOqR/gaicm4RYdLA4kVkplgAg8ElVvUbY yjieNdizfgNLBPp29gQv0Pc2t6gdNWoKVhK7enCXgNzoN6bWnYofZvsy+9tbkTguIDhu YIjkvJuKLRS29WecSysuvb65twCh+NrZ7T4mkhw8pHdUFe/8Avze3W/TPEUGyHR5ql0h JmcGG+EzIXJKWgcTz8M7eAlJzJE8jBPrHR1P29/5OQzAsMm5sHadbbNr+Hso1V2DvMLx UYYR5SclqhfeDxyJ5FuwFAh60roKEIZcelVP0ztNXh8ftkhzaIKHBnNHIpS/D4lIS0hN /ceg== X-Received: by 10.66.250.163 with SMTP id zd3mr30607252pac.109.1386715647373; Tue, 10 Dec 2013 14:47:27 -0800 (PST) Received: from fangorn.rup.mentorg.com (nat-min.mentorg.com. [139.181.32.34]) by mx.google.com with ESMTPSA id g6sm38775196pat.2.2013.12.10.14.47.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Dec 2013 14:47:26 -0800 (PST) From: Dmitry Eremin-Solenikov To: linux-kernel@vger.kernel.org Subject: [PATCH] gpio-charger: support wakeup events Date: Wed, 11 Dec 2013 02:47:16 +0400 Message-Id: <1386715636-18134-1-git-send-email-dbaryshkov@gmail.com> X-Mailer: git-send-email 1.8.4.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131210_174750_641397_BB60E33A X-CRM114-Status: GOOD ( 13.06 ) X-Spam-Score: -2.0 (--) Cc: Anton Vorontsov , David Woodhouse , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add support for using gpio-charger IRQ as a wakeup event. Signed-off-by: Dmitry Eremin-Solenikov --- drivers/power/gpio-charger.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/power/gpio-charger.c b/drivers/power/gpio-charger.c index 4e858a2..a0024b2 100644 --- a/drivers/power/gpio-charger.c +++ b/drivers/power/gpio-charger.c @@ -28,6 +28,7 @@ struct gpio_charger { const struct gpio_charger_platform_data *pdata; unsigned int irq; + bool wakeup_enabled; struct power_supply charger; }; @@ -136,6 +137,8 @@ static int gpio_charger_probe(struct platform_device *pdev) platform_set_drvdata(pdev, gpio_charger); + device_init_wakeup(&pdev->dev, 1); + return 0; err_gpio_free: @@ -159,18 +162,32 @@ static int gpio_charger_remove(struct platform_device *pdev) } #ifdef CONFIG_PM_SLEEP +static int gpio_charger_suspend(struct device *dev) +{ + struct gpio_charger *gpio_charger = dev_get_drvdata(dev); + + if (device_may_wakeup(dev)) + gpio_charger->wakeup_enabled = + enable_irq_wake(gpio_charger->irq); + + return 0; +} + static int gpio_charger_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct gpio_charger *gpio_charger = platform_get_drvdata(pdev); + if (gpio_charger->wakeup_enabled) + disable_irq_wake(gpio_charger->irq); power_supply_changed(&gpio_charger->charger); return 0; } #endif -static SIMPLE_DEV_PM_OPS(gpio_charger_pm_ops, NULL, gpio_charger_resume); +static SIMPLE_DEV_PM_OPS(gpio_charger_pm_ops, + gpio_charger_suspend, gpio_charger_resume); static struct platform_driver gpio_charger_driver = { .probe = gpio_charger_probe,