From patchwork Wed Sep 21 15:51:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raul E Rangel X-Patchwork-Id: 608069 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D189ECAAD8 for ; Wed, 21 Sep 2022 16:00:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232167AbiIUQAw (ORCPT ); Wed, 21 Sep 2022 12:00:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232711AbiIUQAT (ORCPT ); Wed, 21 Sep 2022 12:00:19 -0400 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FC9C804B2 for ; Wed, 21 Sep 2022 08:53:48 -0700 (PDT) Received: by mail-io1-xd34.google.com with SMTP id r134so5382707iod.8 for ; Wed, 21 Sep 2022 08:53:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=FeCM68gkQ9FF2bI4ULoqKrlayWCcShzPlt5I44au1/c=; b=GtmCk56HIqS2j7htWOn/zd2QgPTD1TYRl91W0+5vL/qucf8cUNggcbH51MiyegyUPJ A9CmJif3svdMmc0fGZYnepR08XJ2LAeeHufyL8dvufUYu+LQLUF4QeT/9obZ4+t/Kzwi tiV1uf63qtX/4WZCyIbo4VS4rbeUYscBntzyA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=FeCM68gkQ9FF2bI4ULoqKrlayWCcShzPlt5I44au1/c=; b=ByXbnN9x+1TaWOlCL9VIgRhwSR9XZ0pPt/nQCWyM0BW1C/dFPTPhZULJm3UVvpOrvO aydPDIlZXwGjRJ3RMeu1KK22GtWe27eUAGGuW5sfJ8pBH1UZIMwEVfVXa+xNOIdCdcxI kNIF3hXbvuy0XgyBWIOoQENq8WIy9YnlhlxryyFHE8hqqqa1cUPP6WQ8OEoeWJzbtPWN uBeyalQWK5wKh/2EykAqhyKpOsHmABog2lV9LObsNjeD/R03UVhPEIRBqAje2h7D3Irx jF+ON/PI1nQ+NBhtl+qrQG9by9ZE2dsekp9Fdw/L2quTyGzei7WIcq4D3f5c10uAk2MW aGxA== X-Gm-Message-State: ACrzQf3mcV5WPMRTFjoDttGR+7wy5pX0viZHU2sKigQ2WMbJFEqUH0EG 6izYSYZ86XxiiJss9I5si7sJmQ== X-Google-Smtp-Source: AMsMyM51AVUJbQY3PPH4vR13sh6JHTTSpHiCRizwFXEe4R+ue1vv4/RVAHvxMTPRddIJjnBApDIYUg== X-Received: by 2002:a05:6638:2595:b0:35a:5433:d7a9 with SMTP id s21-20020a056638259500b0035a5433d7a9mr13085111jat.320.1663775531648; Wed, 21 Sep 2022 08:52:11 -0700 (PDT) Received: from rrangel920.bld.corp.google.com (h24-56-189-219.arvdco.broadband.dynamic.tds.net. [24.56.189.219]) by smtp.gmail.com with ESMTPSA id c14-20020a023b0e000000b0035a8d644a31sm1148061jaa.117.2022.09.21.08.52.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 08:52:10 -0700 (PDT) From: Raul E Rangel To: linux-acpi@vger.kernel.org, linux-input@vger.kernel.org Cc: rafael@kernel.org, timvp@google.com, mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com, dmitry.torokhov@gmail.com, jingle.wu@emc.com.tw, hdegoede@redhat.com, mario.limonciello@amd.com, linus.walleij@linaro.org, Raul E Rangel , linux-kernel@vger.kernel.org Subject: [PATCH v5 02/13] Input: elan_i2c - Use PM subsystem to manage wake irq Date: Wed, 21 Sep 2022 09:51:54 -0600 Message-Id: <20220921094736.v5.2.Id022caf53d01112188308520915798f08a33cd3e@changeid> X-Mailer: git-send-email 2.37.3.968.ga6b4b080e4-goog In-Reply-To: <20220921155205.1332614-1-rrangel@chromium.org> References: <20220921155205.1332614-1-rrangel@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org The Elan I2C touchpad driver is currently manually managing the wake IRQ. This change removes the explicit enable_irq_wake/disable_irq_wake and instead relies on the PM subsystem. This is done by calling dev_pm_set_wake_irq. i2c_device_probe already calls dev_pm_set_wake_irq when using device tree, and i2c_device_remove also already calls dev_pm_clear_wake_irq. There could be some device tree systems that have incorrectly declared `wake` capabilities, so this change will set the wake irq if one is missing. This matches the previous behavior. I tested this on an ACPI system where the touchpad doesn't have _PRW defined. I verified I can still wake the system and that the wake source was the touchpad IRQ GPIO. Signed-off-by: Raul E Rangel --- (no changes since v2) Changes in v2: - Set the wake_irq when not configured by the i2c-core. This is different than v1, where the wake_irq was only set for non DT systems. drivers/input/mouse/elan_i2c_core.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c index e1758d5ffe4218..3947474e93d16a 100644 --- a/drivers/input/mouse/elan_i2c_core.c +++ b/drivers/input/mouse/elan_i2c_core.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -86,8 +87,6 @@ struct elan_tp_data { u16 fw_page_size; u32 fw_signature_address; - bool irq_wake; - u8 min_baseline; u8 max_baseline; bool baseline_ready; @@ -1340,6 +1339,15 @@ static int elan_probe(struct i2c_client *client, if (!dev->of_node) device_init_wakeup(dev, true); + /* + * The wake IRQ should be declared via device tree instead of assuming + * the IRQ can wake the system. This is here for legacy reasons and + * will be removed once the i2c-core supports querying ACPI for wake + * capabilities. + */ + if (!dev->power.wakeirq) + dev_pm_set_wake_irq(dev, client->irq); + return 0; } @@ -1362,8 +1370,6 @@ static int __maybe_unused elan_suspend(struct device *dev) if (device_may_wakeup(dev)) { ret = elan_sleep(data); - /* Enable wake from IRQ */ - data->irq_wake = (enable_irq_wake(client->irq) == 0); } else { ret = elan_set_power(data, false); if (ret) @@ -1394,9 +1400,6 @@ static int __maybe_unused elan_resume(struct device *dev) dev_err(dev, "error %d enabling regulator\n", error); goto err; } - } else if (data->irq_wake) { - disable_irq_wake(client->irq); - data->irq_wake = false; } error = elan_set_power(data, true);