From patchwork Wed Jan 13 04:05:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 363162 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 233E8C433E9 for ; Wed, 13 Jan 2021 04:07:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D222D2312F for ; Wed, 13 Jan 2021 04:07:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726711AbhAMEGy (ORCPT ); Tue, 12 Jan 2021 23:06:54 -0500 Received: from wnew2-smtp.messagingengine.com ([64.147.123.27]:50987 "EHLO wnew2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726682AbhAMEGw (ORCPT ); Tue, 12 Jan 2021 23:06:52 -0500 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.west.internal (Postfix) with ESMTP id E790719F2; Tue, 12 Jan 2021 23:05:45 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Tue, 12 Jan 2021 23:05:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=L/yNuOxj28hiX +c/tqAQ/Im+opvb6Nb/8TsVGhyxOMw=; b=D0NyJ/OcaJDR4QbYQlR2Cnrz6IOUX yCx2x4x1zXZM2TCMIgsIRE7Yeefvu+PIO2+QqKtZZpU8pwz4Ph/KrqX/Ff3BoIQQ YtrfEII/NBfEoThf3NUPsuWfHYDDORmxQaMCl6C9XhNX9LrSHaZ3mxDZ+IwW8KO8 bsjq5V3mlhfxsluoDRW+4jCvxNr1AS0lrZTead/r3tLRa+lvqz1LzlYFP6o1UbX7 jNhxGJE4bCfgXsZKc6mYF2zNkd9cKhthbLJe/1Dy3nziovvF9ZNJO2rS8mX4jC2d Z2yVzII7wC6ZEWXw9p32NWxvw6WR5W9r/ui3CqNh1VFa3WgiWmua6g4xQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=L/yNuOxj28hiX+c/tqAQ/Im+opvb6Nb/8TsVGhyxOMw=; b=d3klVUa9 XMuyK0GBxz/Ydg8zyowYyUKCjouwHVpPsUfnF9G6V/W7hDJPsaWIup6BwGbDabku JHkAS01fN93JUJj79oycIhnT2KnxB3wOB15Y3vEJHDgPlzT8hpGZZuio9wSjgF9J hzKqG1XKruHVOU0mWLVKYbjnWI3/LxKvbbeAf16zTUB6gsjpCwe2to+iFtZEFUnI WaCACsRRdGJZfo4y3MuAXCFyyiZlEZogqZfugqsIUgZcdWlBmo5Uvz+uUthwHHwB +YZUu1e1U5sCRkWaFOhDnYHaE0koHNNapEl29L5KP9R0PiKJzxeBLIeUN5AD4i4F 6NS8NHNM17+yBw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedukedrtddugdeilecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepufgrmhhuvghl ucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecuggftrf grthhtvghrnhepudfhjeefvdfhgfefheetgffhieeigfefhefgvddvveefgeejheejvdfg jeehueeinecukfhppeejtddrudefhedrudegkedrudehudenucevlhhushhtvghrufhiii gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehsrghmuhgvlhesshhhohhllhgrnhgu rdhorhhg X-ME-Proxy: Received: from titanium.stl.sholland.net (70-135-148-151.lightspeed.stlsmo.sbcglobal.net [70.135.148.151]) by mail.messagingengine.com (Postfix) with ESMTPA id 941EC240064; Tue, 12 Jan 2021 23:05:44 -0500 (EST) From: Samuel Holland To: Hans de Goede , Dmitry Torokhov , Rob Herring , Maxime Ripard , Chen-Yu Tsai , Jernej Skrabec Cc: devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, Samuel Holland , Ondrej Jirman Subject: [PATCH v2 2/3] input: sun4i-lradc-keys - Add wakup support Date: Tue, 12 Jan 2021 22:05:41 -0600 Message-Id: <20210113040542.34247-3-samuel@sholland.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210113040542.34247-1-samuel@sholland.org> References: <20210113040542.34247-1-samuel@sholland.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Ondrej Jirman Allow the driver to wake the system on key press if the "wakeup-source" property is provided in the device tree. Using the LRADC as a wakeup source requires keeping the AVCC domain active during sleep. Since this has a nontrivial impact on power consumption (sometimes doubling it), disable the LRADC wakeup source by default. Signed-off-by: Ondrej Jirman Signed-off-by: Samuel Holland --- drivers/input/keyboard/sun4i-lradc-keys.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/input/keyboard/sun4i-lradc-keys.c b/drivers/input/keyboard/sun4i-lradc-keys.c index 4a796bed48ac..a1eb2001c088 100644 --- a/drivers/input/keyboard/sun4i-lradc-keys.c +++ b/drivers/input/keyboard/sun4i-lradc-keys.c @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include #include @@ -226,8 +228,7 @@ static int sun4i_lradc_probe(struct platform_device *pdev) { struct sun4i_lradc_data *lradc; struct device *dev = &pdev->dev; - int i; - int error; + int error, i, irq; lradc = devm_kzalloc(dev, sizeof(struct sun4i_lradc_data), GFP_KERNEL); if (!lradc) @@ -272,8 +273,13 @@ static int sun4i_lradc_probe(struct platform_device *pdev) if (IS_ERR(lradc->base)) return PTR_ERR(lradc->base); - error = devm_request_irq(dev, platform_get_irq(pdev, 0), - sun4i_lradc_irq, 0, + irq = platform_get_irq(pdev, 0); + if (irq < 0) { + dev_err(&pdev->dev, "Failed to get IRQ\n"); + return irq; + } + + error = devm_request_irq(dev, irq, sun4i_lradc_irq, 0, "sun4i-a10-lradc-keys", lradc); if (error) return error; @@ -282,6 +288,14 @@ static int sun4i_lradc_probe(struct platform_device *pdev) if (error) return error; + if (device_property_read_bool(dev, "wakeup-source")) { + device_set_wakeup_capable(dev, true); + + error = dev_pm_set_wake_irq(dev, irq); + if (error) + dev_warn(dev, "Failed to set wake IRQ\n"); + } + return 0; }