From patchwork Thu Nov 18 03:30:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 12625969 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F9C8C433F5 for ; Thu, 18 Nov 2021 03:30:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7A48961ABA for ; Thu, 18 Nov 2021 03:30:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242721AbhKRDdP (ORCPT ); Wed, 17 Nov 2021 22:33:15 -0500 Received: from new1-smtp.messagingengine.com ([66.111.4.221]:54123 "EHLO new1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241185AbhKRDdO (ORCPT ); Wed, 17 Nov 2021 22:33:14 -0500 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.nyi.internal (Postfix) with ESMTP id 1619F58096D; Wed, 17 Nov 2021 22:30:15 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 17 Nov 2021 22:30:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm1; bh=/cj2kNWq2UVok38XhOoZvbWa1e 3Ab7EbCh9ffCDhegQ=; b=SlaJoQPZ0D8JAqVMzmyHi0sw+sgy7uu/oANeIVxm29 HFrEmWErsV7kaRg+X1SIr5rXJU6D+FjcqyWejxatHkx2v1KTe4JjEi0W9BS2+cm9 bPBhbmL5y9XTvKFHq9QBfnezgc0urHipU2U7C6ABvCr6VWIFYI38DByxYYKeHHsX bswFcXp5iup85w9pjO4C1VkVckQwdRA6N4HdF9/3YB/cWk0+eeWbp2M928T96bxl cjkZ8Gslusr6IgLFnbvtfCGAZJvD7TMO+qiQTXxMrA7+v56pvngE+3cVZSXtKZDV aWVgbZa8Wd+olciVeTlQg2LNjVweNcORGWqbKgY/VE0Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=/cj2kNWq2UVok38Xh OoZvbWa1e3Ab7EbCh9ffCDhegQ=; b=dh0I2lx53fPhtPjNglmfjZXV7+KbNoQ/5 YZkfTZBKl3VGVI4+q6yJwFO861lkDJ2Y5gDT60h30hjEvNaOVq7Tmcj8Hn9Cu7E9 6SVTNpjJq2xN1wxBSzbHQQGaWtFjd3U3BIIIoYU2Vy84kEDYFRpjyUJdiXYfgl+J k1ixViqChTnIEFsnHQwh0/W/uIc8lC4oycDSA7n22JkTMEQiKKQTxnAUicFBzB+s aAaT1uH4FMma/annEutUQOVLLXn+qwQi6dh6TQpHkyRvI5hxi/0RhleRArMEZk8T 8QrHvaHHxPwOc+HMv331o+Uty6WEibTfDlzA8hnGOfUv6DN5ocVEw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrfeehgdehjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgggfestdekredtredttdenucfhrhhomhepufgrmhhuvghlucfj ohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecuggftrfgrth htvghrnhepieetkefhheduudfgledtudefjeejfeegveehkeeufffhhfejkeehiefftdev tdevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepsh grmhhuvghlsehshhholhhlrghnugdrohhrgh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 17 Nov 2021 22:30:13 -0500 (EST) From: Samuel Holland To: Dmitry Torokhov Cc: Hans de Goede , Rob Herring , Maxime Ripard , Chen-Yu Tsai , Jernej Skrabec , devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev, Ondrej Jirman , Samuel Holland Subject: [RERESEND PATCH v3] Input: sun4i-lradc-keys - Add wakup support Date: Wed, 17 Nov 2021 21:30:13 -0600 Message-Id: <20211118033013.43116-1-samuel@sholland.org> X-Mailer: git-send-email 2.32.0 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. Acked-by: Maxime Ripard Reviewed-by: Hans de Goede Signed-off-by: Ondrej Jirman Signed-off-by: Samuel Holland --- Changes since resend v3: - An entirely different, but equivalent, DT binding patch was merged, so there is only one patch left... Changes since v2: - Dropped unnecessary pr_err in platform_get_irq() error path - Dropped patch 3 (DT update) as it was merged - Added Acked-by/Reviewed-by tags Changes since v1: - Add requisite DT binding change - Only add wakeup capability if "wakeup-source" is present - Warn but do not error out if setting the wake IRQ fails - Add "wakeup-source" property to PinePhone device tree --- drivers/input/keyboard/sun4i-lradc-keys.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/input/keyboard/sun4i-lradc-keys.c b/drivers/input/keyboard/sun4i-lradc-keys.c index 4a796bed48ac..af1683d68c8c 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,11 @@ 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) + return irq; + + error = devm_request_irq(dev, irq, sun4i_lradc_irq, 0, "sun4i-a10-lradc-keys", lradc); if (error) return error; @@ -282,6 +286,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; }