From patchwork Wed Sep 21 15:51:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raul Rangel X-Patchwork-Id: 12983944 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 C3540C6FA82 for ; Wed, 21 Sep 2022 16:04:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231247AbiIUQE1 (ORCPT ); Wed, 21 Sep 2022 12:04:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232176AbiIUQCd (ORCPT ); Wed, 21 Sep 2022 12:02:33 -0400 Received: from mail-io1-f53.google.com (mail-io1-f53.google.com [209.85.166.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E3939F0FF for ; Wed, 21 Sep 2022 08:54:12 -0700 (PDT) Received: by mail-io1-f53.google.com with SMTP id d8so5355211iof.11 for ; Wed, 21 Sep 2022 08:54:12 -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=6u3eurb1Xgmesw5AwuVmsCmrALfE27B+XzNhz8oQb68=; b=GjNRcw26DfNp1l72ePzR8ypLaHtbjo9vTe+iNGgtnIGQ9xGOBVzZn5KboLP69H5myp y+dUWNcagsdvpiW4vKFj7s6IF0d19PAHzXGNM/sLcB18OZboAUtwHCt3UudddS4mef9O zXnDIjDUNMgv+xukGWZvkXhvcqKZDAVLsQl2c= 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=6u3eurb1Xgmesw5AwuVmsCmrALfE27B+XzNhz8oQb68=; b=y2R3mzgZQJEuxJdrAov1T8mZyn+fK6iJPfN4+Qzx1SKzJZGcach4SprFGsey0XzLoq AGIjZxTS8b+htkTpTHbt+TaaJI4pWFm0Yj3mtrpdLEqmxcqmJYM+WGRcwfUTrUnjB/qn tLhHtuNs9SJKdTCtQvIIYGj64b5d1QW66TIPBTU0BODoyI6XU1seQndUZ29nlsZDUsHC 8ovbKgSvNaxp6UBSNePM8B19bOvndRLxzh9+SkXa3wStl3ExeTcHAKw0P//sZx0tAvWc LQzAjuCoLO+qMw0v+myt2zEii+5WA8dJ4DdzrGZ9oWF2uxA0Uhg5QLXEj/RnGd1khqfC kc4w== X-Gm-Message-State: ACrzQf1dIk5ln80tlAdxDyOYYEd9LrdqqPdI32pK8l/OHQsERrOwvMyn dPZTVS70AzUyeeYMgFkj/MepCvHJna8YmA== X-Google-Smtp-Source: AMsMyM5FurtQcQ3Zhi3svvOfSucFfvzPX0N07mOcLz3OH6cod0plPgWlxJ+tS5OwcMy5uXtmsLl+iA== X-Received: by 2002:a05:6638:c48:b0:35a:3f5f:d382 with SMTP id g8-20020a0566380c4800b0035a3f5fd382mr13561628jal.6.1663775530256; Wed, 21 Sep 2022 08:52:10 -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.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 08:52:09 -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 , Benjamin Tissoires , Angela Czubak , Jiri Kosina , Matthias Kaehlcke , Rob Herring , Yang Li , linux-kernel@vger.kernel.org Subject: [PATCH v5 01/13] HID: i2c-hid: Use PM subsystem to manage wake irq Date: Wed, 21 Sep 2022 09:51:53 -0600 Message-Id: <20220921094736.v5.1.Id4b4bdfe06e2caf2d5a3c9dd4a9b1080c38b539c@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-acpi@vger.kernel.org The I2C hid 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 that has a HID touchscreen and verified the IRQ was armed for wake on suspend. Signed-off-by: Raul E Rangel Acked-by: Benjamin Tissoires --- Changes in v5: - Added Acked-by: Benjamin Tissoires Changes in v3: - Fixed typo in if condition 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/hid/i2c-hid/i2c-hid-core.c | 33 +++++++++++------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c index baa169fadd6632..a2fa40dec04ea5 100644 --- a/drivers/hid/i2c-hid/i2c-hid-core.c +++ b/drivers/hid/i2c-hid/i2c-hid-core.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -116,7 +117,6 @@ struct i2c_hid { wait_queue_head_t wait; /* For waiting the interrupt */ - bool irq_wake_enabled; struct mutex reset_lock; struct i2chid_ops *ops; @@ -1036,6 +1036,15 @@ int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops, if (ret < 0) goto err_powered; + /* + * 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 (!client->dev.power.wakeirq) + dev_pm_set_wake_irq(&client->dev, client->irq); + hid = hid_allocate_device(); if (IS_ERR(hid)) { ret = PTR_ERR(hid); @@ -1119,7 +1128,6 @@ static int i2c_hid_core_suspend(struct device *dev) struct i2c_hid *ihid = i2c_get_clientdata(client); struct hid_device *hid = ihid->hid; int ret; - int wake_status; ret = hid_driver_suspend(hid, PMSG_SUSPEND); if (ret < 0) @@ -1130,16 +1138,8 @@ static int i2c_hid_core_suspend(struct device *dev) disable_irq(client->irq); - if (device_may_wakeup(&client->dev)) { - wake_status = enable_irq_wake(client->irq); - if (!wake_status) - ihid->irq_wake_enabled = true; - else - hid_warn(hid, "Failed to enable irq wake: %d\n", - wake_status); - } else { + if (!device_may_wakeup(&client->dev)) i2c_hid_core_power_down(ihid); - } return 0; } @@ -1150,18 +1150,9 @@ static int i2c_hid_core_resume(struct device *dev) struct i2c_client *client = to_i2c_client(dev); struct i2c_hid *ihid = i2c_get_clientdata(client); struct hid_device *hid = ihid->hid; - int wake_status; - if (!device_may_wakeup(&client->dev)) { + if (!device_may_wakeup(&client->dev)) i2c_hid_core_power_up(ihid); - } else if (ihid->irq_wake_enabled) { - wake_status = disable_irq_wake(client->irq); - if (!wake_status) - ihid->irq_wake_enabled = false; - else - hid_warn(hid, "Failed to disable irq wake: %d\n", - wake_status); - } enable_irq(client->irq); 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 Rangel X-Patchwork-Id: 12983957 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 92B22C6FA82 for ; Wed, 21 Sep 2022 16:18:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232155AbiIUQSD (ORCPT ); Wed, 21 Sep 2022 12:18:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232386AbiIUQRe (ORCPT ); Wed, 21 Sep 2022 12:17:34 -0400 Received: from mail-qt1-x829.google.com (mail-qt1-x829.google.com [IPv6:2607:f8b0:4864:20::829]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAF60AA3F4 for ; Wed, 21 Sep 2022 09:02:36 -0700 (PDT) Received: by mail-qt1-x829.google.com with SMTP id f26so4398381qto.11 for ; Wed, 21 Sep 2022 09:02:36 -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=VDBR0gUY4LQyVMSY5Z4140/0ITlrJir2Cc3yK4Q+wt2BF5P1n/CAYrIc1wzJFsuEj0 eThd8dRhRAGcQZPltqFiiR6s5KV/E90kovr1IOxcOofl3ZZIUYDfSFwWL1zyizr2m0S4 RYxlJuIAgcGG4RX/fTOGZ5do5dVFpNEF0Xw/DB2ufc4ii8eoco3pWVV/e/1OEoYGqIkF NM6BYDNuGououeaigvuAGzvpPzws+NY7A29xbpL+JXbyzOmJNACkBQtC0fM+1fLysYPS gFXO3Ng3cs5jUkAH+sCGJhO4C0tvLohrNfPyOnERYTJlj4njXSHGAb8swjcHWgT845hr VJsA== X-Gm-Message-State: ACrzQf0Nb8EiXPBWpNcJeZGb54n5msWLqbfu9KHI0BOo8+bgDMXsSwX3 s4N6NmlxpUHqRO7BW4owo50DIZUEuvwiJA== 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-acpi@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); From patchwork Wed Sep 21 15:51:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raul Rangel X-Patchwork-Id: 12983934 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 93C8AC6FA90 for ; Wed, 21 Sep 2022 16:00:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232039AbiIUQAj (ORCPT ); Wed, 21 Sep 2022 12:00:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232618AbiIUQAF (ORCPT ); Wed, 21 Sep 2022 12:00:05 -0400 Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 558D4A262A for ; Wed, 21 Sep 2022 08:53:29 -0700 (PDT) Received: by mail-il1-x12e.google.com with SMTP id d14so2290588ilf.2 for ; Wed, 21 Sep 2022 08:53:29 -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=uLFsVomnZ3NOv94HIF7hfztjoJa5WoPp5LmQm5BO1Bo=; b=O6tqmj45Spb7X3ZoyObvQBcCU4s7qL9NiJJxoNs7Q9/xEpkjceGH08uJnsmGNyUPuz xQ+YtfY9IjBhD0lEdm0hxVfzAFv28LoymxsipYDB74khtXJWnnvSg/hw5dfpm9ZlPT0y uocBxTa36EUl8Na7frHwUeQDnrg8XXWBeGmUc= 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=uLFsVomnZ3NOv94HIF7hfztjoJa5WoPp5LmQm5BO1Bo=; b=pKtRtkN9pbZsw1ZeuaSwFNmz3s+KcScx22kN98M9HcHp3lkl1qGZ8rfTX+4IN5vrZb 35sNLx1vJsdwBQ3i+x1WADXS93Rgl8dlhw3J5GSCUAoay2nMShnBLG8CIxOrfEAjf2Nj NGdBwa1Hcq57iJ0s+zcxyvf3tXajjiIDPgXjokgB2upKZFjEsLjMrcihNCOv1vrc9mag 8wMeEAxaKjDimSO+uzr5WevkHGPaAyflALCikp17+itvid4urdZ1OCuH8UCJ07r3nVNP oNvo76HnVnj4t+ABt1JGoUBa1S7wIVihqZiRm2ydcf7bxbCZW7ABD09Jp9cF0sAnu3l1 n1Gg== X-Gm-Message-State: ACrzQf0XlbQ/0LpBmGbV225GDlnM+2BnusEKlD7RYK1tUOMddpVFqJC9 jjPtGzWndSPXoeOmgsw/bMDLNyOz5j2tZg== X-Google-Smtp-Source: AMsMyM77cC0aAph6/2CCkbrI9fOLUbmaAc6wstab/vTUVuUtZUk/2Lop5RRn6wgBxooER+YOjNg/RQ== X-Received: by 2002:a92:dcc2:0:b0:2e4:38f2:a9f6 with SMTP id b2-20020a92dcc2000000b002e438f2a9f6mr6283206ilr.130.1663775532851; Wed, 21 Sep 2022 08:52:12 -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.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 08:52:12 -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 , Cai Huoqing , Douglas Anderson , Johnny Chuang , linux-kernel@vger.kernel.org Subject: [PATCH v5 03/13] Input: elants_i2c - Use PM subsystem to manage wake irq Date: Wed, 21 Sep 2022 09:51:55 -0600 Message-Id: <20220921094736.v5.3.I5862429ee3e4de0f9ad5ba01ce07ad99eec10cf0@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-acpi@vger.kernel.org The Elan I2C touchscreen 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. Signed-off-by: Raul E Rangel --- (no changes since v2) Changes in v2: - Added elants_i2c to series drivers/input/touchscreen/elants_i2c.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c index a56f042adf9d82..80e16b533c452a 100644 --- a/drivers/input/touchscreen/elants_i2c.c +++ b/drivers/input/touchscreen/elants_i2c.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -180,7 +181,6 @@ struct elants_data { u8 cmd_resp[HEADER_SIZE]; struct completion cmd_done; - bool wake_irq_enabled; bool keep_power_in_suspend; /* Must be last to be used for DMA operations */ @@ -1582,6 +1582,15 @@ static int elants_i2c_probe(struct i2c_client *client) if (!client->dev.of_node) device_init_wakeup(&client->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 (!client->dev.power.wakeirq) + dev_pm_set_wake_irq(&client->dev, client->irq); + error = devm_device_add_group(&client->dev, &elants_attribute_group); if (error) { dev_err(&client->dev, "failed to create sysfs attributes: %d\n", @@ -1626,7 +1635,7 @@ static int __maybe_unused elants_i2c_suspend(struct device *dev) * The device will automatically enter idle mode * that has reduced power consumption. */ - ts->wake_irq_enabled = (enable_irq_wake(client->irq) == 0); + return 0; } else if (ts->keep_power_in_suspend) { for (retry_cnt = 0; retry_cnt < MAX_RETRIES; retry_cnt++) { error = elants_i2c_send(client, set_sleep_cmd, @@ -1655,8 +1664,6 @@ static int __maybe_unused elants_i2c_resume(struct device *dev) int error; if (device_may_wakeup(dev)) { - if (ts->wake_irq_enabled) - disable_irq_wake(client->irq); elants_i2c_sw_reset(client); } else if (ts->keep_power_in_suspend) { for (retry_cnt = 0; retry_cnt < MAX_RETRIES; retry_cnt++) { From patchwork Wed Sep 21 15:51:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raul Rangel X-Patchwork-Id: 12983943 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 A8D99C6FA82 for ; Wed, 21 Sep 2022 16:03:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232370AbiIUQDb (ORCPT ); Wed, 21 Sep 2022 12:03:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232277AbiIUQBj (ORCPT ); Wed, 21 Sep 2022 12:01:39 -0400 Received: from mail-io1-f51.google.com (mail-io1-f51.google.com [209.85.166.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2D022720 for ; Wed, 21 Sep 2022 08:54:13 -0700 (PDT) Received: by mail-io1-f51.google.com with SMTP id 138so5357553iou.9 for ; Wed, 21 Sep 2022 08:54:13 -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=bZ+qtxPfho04MrKrUszJh9/TiBJm28a0YpVnjrNGpL8=; b=mCF/QM7OAKcOvv9Q594jwoylSjpaNAuQp69j59Te3aQiMkxEPlUT3Dv1KiWFD5vrfv MCjFg9iaUGoW/gzddaj0RyfUeYKk57WpX4j6N+0h+YCJBWaCsErdvmINwQ6DtHKZ9mWR nUnR9Z8cdmKszF8iiy6up8A0cFeX85mFuPCdo= 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=bZ+qtxPfho04MrKrUszJh9/TiBJm28a0YpVnjrNGpL8=; b=oH80r2g2OEFvI4zf5wbxBJpqW45AhmU5FqPJsiaIWnXNpga8ju3CJP5XIIkngYGuv6 3Ck+7V21ZlQErKB+qYqPkIN6j8YHc6UTyqe4iDjAELsYnFtsb4RbJHeNprcdhC2JwpNu 8/22LqJjOYKc4ZjsfztnjNnV/f3lyaMHVvtuaXslV+pkr4cnf3YQGhFl2RwBLt0Q6QJt sQJFyhDwIQ6F5c7Uk8PjIElXUk50pILpG+jDciOjgNyWuB+UnQE7nLi6scyz4kyEc0z8 /ujcHhrshQKpsCzKgNJiq5uBicjgPgDRF4Z/h87S5modMF4cC7uzgrXjGsd3NuXw8x8V Gjqg== X-Gm-Message-State: ACrzQf3fpLB0LnqYTeM+db5pvEEqYYF8q/esoLkJ1R19oQHOanzzQX87 RiZ0RDkpVyf70DBdpVoWhX/qv/BgZEozLQ== X-Google-Smtp-Source: AMsMyM72fliVsNACh53kZswB/oyGlBYQMe9bQa0Qfw0v0ff/8pEMI0VtdtEy3JWGxSjVxhW3kLi6dw== X-Received: by 2002:a5e:df43:0:b0:6a1:ffc6:4e30 with SMTP id g3-20020a5edf43000000b006a1ffc64e30mr11835391ioq.192.1663775534113; Wed, 21 Sep 2022 08:52:14 -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.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 08:52:13 -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 , Cai Huoqing , linux-kernel@vger.kernel.org Subject: [PATCH v5 04/13] Input: raydium_ts_i2c - Use PM subsystem to manage wake irq Date: Wed, 21 Sep 2022 09:51:56 -0600 Message-Id: <20220921094736.v5.4.I06b417b274bbecb31775a73993a7a3c1bc80de7b@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-acpi@vger.kernel.org The raydium I2C touchscreen 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. Signed-off-by: Raul E Rangel --- (no changes since v2) Changes in v2: - Added raydium_ts_i2c to series drivers/input/touchscreen/raydium_i2c_ts.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c b/drivers/input/touchscreen/raydium_i2c_ts.c index 3a4952935366f9..66c5b577b791d4 100644 --- a/drivers/input/touchscreen/raydium_i2c_ts.c +++ b/drivers/input/touchscreen/raydium_i2c_ts.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -134,8 +135,6 @@ struct raydium_data { u8 pkg_size; enum raydium_boot_mode boot_mode; - - bool wake_irq_enabled; }; /* @@ -1186,6 +1185,15 @@ static int raydium_i2c_probe(struct i2c_client *client, return error; } + /* + * 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 (!client->dev.power.wakeirq) + dev_pm_set_wake_irq(&client->dev, client->irq); + error = devm_device_add_group(&client->dev, &raydium_i2c_attribute_group); if (error) { @@ -1222,8 +1230,6 @@ static int __maybe_unused raydium_i2c_suspend(struct device *dev) if (device_may_wakeup(dev)) { raydium_enter_sleep(client); - - ts->wake_irq_enabled = (enable_irq_wake(client->irq) == 0); } else { raydium_i2c_power_off(ts); } @@ -1237,8 +1243,6 @@ static int __maybe_unused raydium_i2c_resume(struct device *dev) struct raydium_data *ts = i2c_get_clientdata(client); if (device_may_wakeup(dev)) { - if (ts->wake_irq_enabled) - disable_irq_wake(client->irq); raydium_i2c_sw_reset(client); } else { raydium_i2c_power_on(ts); From patchwork Wed Sep 21 15:51:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raul Rangel X-Patchwork-Id: 12983935 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 F0E35C6FA8B for ; Wed, 21 Sep 2022 16:00:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232063AbiIUQAl (ORCPT ); Wed, 21 Sep 2022 12:00:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232651AbiIUQAM (ORCPT ); Wed, 21 Sep 2022 12:00:12 -0400 Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC643A0600 for ; Wed, 21 Sep 2022 08:53:36 -0700 (PDT) Received: by mail-il1-x133.google.com with SMTP id d14so2290652ilf.2 for ; Wed, 21 Sep 2022 08:53:36 -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=WRBW2mcaW8+vq4yiHKY35m1Azs9z2RcONx9gHz7vf2U=; b=VO4cs48ZFpEYZaKH/qDgmC15+Cy7PkP8Q+OnAIp5BxL8et2TZ4/axXYXBTu9PM83Hj X+n+cGoEAsRvSLLrluQaShmzaFmqc3bXhQq2Kdre5XX2H/jN3hmwbI42tIqfIm++/Mya EMWhewuhv5ako3Xe4dAr8UOWWMaWevb6RXbCE= 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=WRBW2mcaW8+vq4yiHKY35m1Azs9z2RcONx9gHz7vf2U=; b=s8JZ3OV2senRk8ey9Ch0IrkBV0nIjvsEFar1PCPkJLIR5NcfBlzlqIfpwTwPKa+Qc3 RDn0d3cSEHRcTRGC+r+rk3ii2Ln5cU/nRRptsFa5mTk0LfB4vz9k6q7Y9dm0TF9IrZOk 1M89gIV+q/m2JCc/Ayh9O4/d8Qh7E3+HpOvXGwTHuJ6agrvT+pT5fiDWWY2IX3VcipDU GXW+xurKiwExBgScFTXRZEGXuTfRVTSEgAM/yz/dggjO9ex+g+c3cS+rftBpxtqD0jDg WiNPFRU5DonlKrtKV2bZbOKXFHICQfh9DdkGEAjgyf7Z+rVtLbjeRAZefXpI/vyNgv3n a4/A== X-Gm-Message-State: ACrzQf1AnPWXC7CHpq2siKml4m+SPGIOgbKDaVFWU9EPQTuMFA84aFhp 4uYnI1n0cVTQ1G2dRxAO7YFznem12UIkFg== X-Google-Smtp-Source: AMsMyM5VPyvR6DQIqZsmpPS/DoMS/CArQiSDJLVISllh+W2lBYZzsvjugS90olTzlvJDy+CVhZc1Xw== X-Received: by 2002:a05:6e02:1ba7:b0:2f5:be22:6ba9 with SMTP id n7-20020a056e021ba700b002f5be226ba9mr6594196ili.295.1663775535297; Wed, 21 Sep 2022 08:52:15 -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.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 08:52:14 -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 , Bartosz Golaszewski , Len Brown , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 05/13] gpiolib: acpi: Add wake_capable variants of acpi_dev_gpio_irq_get Date: Wed, 21 Sep 2022 09:51:57 -0600 Message-Id: <20220921094736.v5.5.I4ff95ba7e884a486d7814ee888bf864be2ebdef4@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-acpi@vger.kernel.org The ACPI spec defines the SharedAndWake and ExclusiveAndWake share type keywords. This is an indication that the GPIO IRQ can also be used as a wake source. This change exposes the wake_capable bit so drivers can correctly enable wake functionality instead of making an assumption. Signed-off-by: Raul E Rangel Reviewed-by: Mika Westerberg Reviewed-by: Andy Shevchenko --- (no changes since v4) Changes in v4: - Added Reviewed-by - Reformatted with 96 char limit Changes in v3: - Kept `acpi_dev_gpio_irq_get_by` unchanged to avoid having to touch unrelated drivers. - Converted wake_capable parameter to bool. Changes in v2: - Fixed call site in mlxbf_gige_probe drivers/gpio/gpiolib-acpi.c | 15 ++++++++++++--- drivers/gpio/gpiolib-acpi.h | 2 ++ include/linux/acpi.h | 21 +++++++++++++++++---- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 9be1376f9a627f..1f2ade475b36cb 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -741,6 +741,7 @@ static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *data) lookup->info.pin_config = agpio->pin_config; lookup->info.debounce = agpio->debounce_timeout; lookup->info.gpioint = gpioint; + lookup->info.wake_capable = agpio->wake_capable == ACPI_WAKE_CAPABLE; /* * Polarity and triggering are only specified for GpioInt @@ -987,10 +988,11 @@ struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode, } /** - * acpi_dev_gpio_irq_get_by() - Find GpioInt and translate it to Linux IRQ number + * acpi_dev_gpio_irq_wake_get_by() - Find GpioInt and translate it to Linux IRQ number * @adev: pointer to a ACPI device to get IRQ from * @name: optional name of GpioInt resource * @index: index of GpioInt resource (starting from %0) + * @wake_capable: Set to true if the IRQ is wake capable * * If the device has one or more GpioInt resources, this function can be * used to translate from the GPIO offset in the resource to the Linux IRQ @@ -1002,9 +1004,13 @@ struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode, * The function takes optional @name parameter. If the resource has a property * name, then only those will be taken into account. * + * The GPIO is considered wake capable if the GpioInt resource specifies + * SharedAndWake or ExclusiveAndWake. + * * Return: Linux IRQ number (> %0) on success, negative errno on failure. */ -int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *name, int index) +int acpi_dev_gpio_irq_wake_get_by(struct acpi_device *adev, const char *name, int index, + bool *wake_capable) { int idx, i; unsigned int irq_flags; @@ -1061,13 +1067,16 @@ int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *name, int ind dev_dbg(&adev->dev, "IRQ %d already in use\n", irq); } + if (wake_capable) + *wake_capable = info.wake_capable; + return irq; } } return -ENOENT; } -EXPORT_SYMBOL_GPL(acpi_dev_gpio_irq_get_by); +EXPORT_SYMBOL_GPL(acpi_dev_gpio_irq_wake_get_by); static acpi_status acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address, diff --git a/drivers/gpio/gpiolib-acpi.h b/drivers/gpio/gpiolib-acpi.h index e476558d947136..1ac6816839dbce 100644 --- a/drivers/gpio/gpiolib-acpi.h +++ b/drivers/gpio/gpiolib-acpi.h @@ -18,6 +18,7 @@ struct acpi_device; * @pin_config: pin bias as provided by ACPI * @polarity: interrupt polarity as provided by ACPI * @triggering: triggering type as provided by ACPI + * @wake_capable: wake capability as provided by ACPI * @debounce: debounce timeout as provided by ACPI * @quirks: Linux specific quirks as provided by struct acpi_gpio_mapping */ @@ -28,6 +29,7 @@ struct acpi_gpio_info { int pin_config; int polarity; int triggering; + bool wake_capable; unsigned int debounce; unsigned int quirks; }; diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 6f64b2f3dc5479..cd7371a5f2839b 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1202,7 +1202,8 @@ bool acpi_gpio_get_irq_resource(struct acpi_resource *ares, struct acpi_resource_gpio **agpio); bool acpi_gpio_get_io_resource(struct acpi_resource *ares, struct acpi_resource_gpio **agpio); -int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *name, int index); +int acpi_dev_gpio_irq_wake_get_by(struct acpi_device *adev, const char *name, int index, + bool *wake_capable); #else static inline bool acpi_gpio_get_irq_resource(struct acpi_resource *ares, struct acpi_resource_gpio **agpio) @@ -1214,16 +1215,28 @@ static inline bool acpi_gpio_get_io_resource(struct acpi_resource *ares, { return false; } -static inline int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, - const char *name, int index) +static inline int acpi_dev_gpio_irq_wake_get_by(struct acpi_device *adev, const char *name, + int index, bool *wake_capable) { return -ENXIO; } #endif +static inline int acpi_dev_gpio_irq_wake_get(struct acpi_device *adev, int index, + bool *wake_capable) +{ + return acpi_dev_gpio_irq_wake_get_by(adev, NULL, index, wake_capable); +} + +static inline int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *name, + int index) +{ + return acpi_dev_gpio_irq_wake_get_by(adev, name, index, NULL); +} + static inline int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index) { - return acpi_dev_gpio_irq_get_by(adev, NULL, index); + return acpi_dev_gpio_irq_wake_get_by(adev, NULL, index, NULL); } /* Device properties */ From patchwork Wed Sep 21 15:51:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raul Rangel X-Patchwork-Id: 12983938 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 F3937C6FA90 for ; Wed, 21 Sep 2022 16:00:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232100AbiIUQAq (ORCPT ); Wed, 21 Sep 2022 12:00:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232596AbiIUQAC (ORCPT ); Wed, 21 Sep 2022 12:00:02 -0400 Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65C91A2637 for ; Wed, 21 Sep 2022 08:53:33 -0700 (PDT) Received: by mail-io1-xd30.google.com with SMTP id p3so5352901iof.13 for ; Wed, 21 Sep 2022 08:53:33 -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=8SWWrxYwFzT3rlQY2tEnjMDGqA2G3cQlA3Qe4PADSpg=; b=krNNpBUQ+zshH2wIuYM4KZH6sXHGRjFHgerTjhkPI5y6m5+actHf3iHYU4FOGat9yg F+t48u9GsyfyhtNoYTMH9LBPztNxurtwJPXJ0RxttmqZJV+jMaKUoX717dwrvSBa8kIi +O4ThsnmhMu29iWLrzJe5Fgq14jrvdYTy7MoY= 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=8SWWrxYwFzT3rlQY2tEnjMDGqA2G3cQlA3Qe4PADSpg=; b=hUY/IQ0VCMG72A0woBfTRQwz4YeVedVBUjif/ioMx3vNYmB43wg6jE/BhUqHuT090t 7fiVI7OPR1NzMfuqS+bMq/hoPq4OUP1i5sxcSgG0v9o0WlCbQq7m/TXnV3qQ/Jn9znqB gGYjvRwyQM7lOLCyST1cQS9GDsio5HcpY8tuos5dzkKO0SAZHQh0HRZzu8NA2oN7RHC9 vRXJANk6X3XniMdw1JR3xM5g5p8QE3SebKbP7Cvo0LzCmP36ePb0g1FWColUsjlWgPxs nza8U33+dwL48pvkDPerimZVr4fIivZMPMX/YLdiQD2kpaoOQpyXvOOkKSqrfz7BVpm2 hHLw== X-Gm-Message-State: ACrzQf07FonWMY+n8OGLvnrTh1XNSULcrQmRx2aiBqxrJBp8wM/4DxV3 36XEcvcxCMpV29x0oEhlzRUMsBdU3UGpQw== X-Google-Smtp-Source: AMsMyM7redZhuVtpcYd2TZE/aPDfUxbcgrXh6kfST+9BEzt3KOSN1uLWbXpVZ4NYE1fd2HaibPwgtg== X-Received: by 2002:a05:6638:370d:b0:35a:91f0:e358 with SMTP id k13-20020a056638370d00b0035a91f0e358mr12483069jav.84.1663775536531; Wed, 21 Sep 2022 08:52:16 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 08:52:16 -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 , Dan Williams , Greg Kroah-Hartman , Jonathan Cameron , Len Brown , Nathan Chancellor , Nick Desaulniers , Terry Bowman , Tom Rix , linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH v5 06/13] ACPI: resources: Add wake_capable parameter to acpi_dev_irq_flags Date: Wed, 21 Sep 2022 09:51:58 -0600 Message-Id: <20220921094736.v5.6.I8092e417a8152475d13d8d638eb4c5d8ea12ac7b@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-acpi@vger.kernel.org ACPI IRQ/Interrupt resources contain a bit that describes if the interrupt should wake the system. This change exposes that bit via a new IORESOURCE_IRQ_WAKECAPABLE flag. Drivers should check this flag before arming an IRQ to wake the system. Signed-off-by: Raul E Rangel Reviewed-by: Andy Shevchenko --- Changes in v5: - Removed clang-format white space changes Changes in v4: - Added Reviewed-by - Reformatted with 96 char limit Changes in v3: - Fixed bad indent Changes in v2: - Added ability to extract wake bit from Interrupt/IRQ resources drivers/acpi/irq.c | 8 +++++--- drivers/acpi/resource.c | 16 +++++++++++----- drivers/pnp/pnpacpi/rsparser.c | 7 ++++--- include/linux/acpi.h | 2 +- include/linux/ioport.h | 3 ++- 5 files changed, 23 insertions(+), 13 deletions(-) diff --git a/drivers/acpi/irq.c b/drivers/acpi/irq.c index dabe45eba055d1..4bb5ab33a5ceb1 100644 --- a/drivers/acpi/irq.c +++ b/drivers/acpi/irq.c @@ -147,6 +147,7 @@ struct acpi_irq_parse_one_ctx { * @polarity: polarity attributes of hwirq * @polarity: polarity attributes of hwirq * @shareable: shareable attributes of hwirq + * @wake_capable: wake capable attribute of hwirq * @ctx: acpi_irq_parse_one_ctx updated by this function * * Description: @@ -156,12 +157,13 @@ struct acpi_irq_parse_one_ctx { static inline void acpi_irq_parse_one_match(struct fwnode_handle *fwnode, u32 hwirq, u8 triggering, u8 polarity, u8 shareable, + u8 wake_capable, struct acpi_irq_parse_one_ctx *ctx) { if (!fwnode) return; ctx->rc = 0; - *ctx->res_flags = acpi_dev_irq_flags(triggering, polarity, shareable); + *ctx->res_flags = acpi_dev_irq_flags(triggering, polarity, shareable, wake_capable); ctx->fwspec->fwnode = fwnode; ctx->fwspec->param[0] = hwirq; ctx->fwspec->param[1] = acpi_dev_get_irq_type(triggering, polarity); @@ -204,7 +206,7 @@ static acpi_status acpi_irq_parse_one_cb(struct acpi_resource *ares, fwnode = acpi_get_gsi_domain_id(irq->interrupts[ctx->index]); acpi_irq_parse_one_match(fwnode, irq->interrupts[ctx->index], irq->triggering, irq->polarity, - irq->shareable, ctx); + irq->shareable, irq->wake_capable, ctx); return AE_CTRL_TERMINATE; case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: eirq = &ares->data.extended_irq; @@ -218,7 +220,7 @@ static acpi_status acpi_irq_parse_one_cb(struct acpi_resource *ares, eirq->interrupts[ctx->index]); acpi_irq_parse_one_match(fwnode, eirq->interrupts[ctx->index], eirq->triggering, eirq->polarity, - eirq->shareable, ctx); + eirq->shareable, eirq->wake_capable, ctx); return AE_CTRL_TERMINATE; } diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c index 510cdec375c4d8..81733369f4c1de 100644 --- a/drivers/acpi/resource.c +++ b/drivers/acpi/resource.c @@ -336,8 +336,9 @@ EXPORT_SYMBOL_GPL(acpi_dev_resource_ext_address_space); * @triggering: Triggering type as provided by ACPI. * @polarity: Interrupt polarity as provided by ACPI. * @shareable: Whether or not the interrupt is shareable. + * @wake_capable: Wake capability as provided by ACPI. */ -unsigned long acpi_dev_irq_flags(u8 triggering, u8 polarity, u8 shareable) +unsigned long acpi_dev_irq_flags(u8 triggering, u8 polarity, u8 shareable, u8 wake_capable) { unsigned long flags; @@ -351,6 +352,9 @@ unsigned long acpi_dev_irq_flags(u8 triggering, u8 polarity, u8 shareable) if (shareable == ACPI_SHARED) flags |= IORESOURCE_IRQ_SHAREABLE; + if (wake_capable == ACPI_WAKE_CAPABLE) + flags |= IORESOURCE_IRQ_WAKECAPABLE; + return flags | IORESOURCE_IRQ; } EXPORT_SYMBOL_GPL(acpi_dev_irq_flags); @@ -442,7 +446,7 @@ static bool acpi_dev_irq_override(u32 gsi, u8 triggering, u8 polarity, static void acpi_dev_get_irqresource(struct resource *res, u32 gsi, u8 triggering, u8 polarity, u8 shareable, - bool check_override) + u8 wake_capable, bool check_override) { int irq, p, t; @@ -475,7 +479,7 @@ static void acpi_dev_get_irqresource(struct resource *res, u32 gsi, } } - res->flags = acpi_dev_irq_flags(triggering, polarity, shareable); + res->flags = acpi_dev_irq_flags(triggering, polarity, shareable, wake_capable); irq = acpi_register_gsi(NULL, gsi, triggering, polarity); if (irq >= 0) { res->start = irq; @@ -523,7 +527,8 @@ bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index, } acpi_dev_get_irqresource(res, irq->interrupts[index], irq->triggering, irq->polarity, - irq->shareable, true); + irq->shareable, irq->wake_capable, + true); break; case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: ext_irq = &ares->data.extended_irq; @@ -534,7 +539,8 @@ bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index, if (is_gsi(ext_irq)) acpi_dev_get_irqresource(res, ext_irq->interrupts[index], ext_irq->triggering, ext_irq->polarity, - ext_irq->shareable, false); + ext_irq->shareable, ext_irq->wake_capable, + false); else irqresource_disabled(res, 0); break; diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index da78dc77aed32e..4f05f610391b00 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c @@ -206,7 +206,8 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, if (i >= 0) { flags = acpi_dev_irq_flags(gpio->triggering, gpio->polarity, - gpio->shareable); + gpio->shareable, + gpio->wake_capable); } else { flags = IORESOURCE_DISABLED; } @@ -315,7 +316,7 @@ static __init void pnpacpi_parse_irq_option(struct pnp_dev *dev, if (p->interrupts[i]) __set_bit(p->interrupts[i], map.bits); - flags = acpi_dev_irq_flags(p->triggering, p->polarity, p->shareable); + flags = acpi_dev_irq_flags(p->triggering, p->polarity, p->shareable, p->wake_capable); pnp_register_irq_resource(dev, option_flags, &map, flags); } @@ -339,7 +340,7 @@ static __init void pnpacpi_parse_ext_irq_option(struct pnp_dev *dev, } } - flags = acpi_dev_irq_flags(p->triggering, p->polarity, p->shareable); + flags = acpi_dev_irq_flags(p->triggering, p->polarity, p->shareable, p->wake_capable); pnp_register_irq_resource(dev, option_flags, &map, flags); } diff --git a/include/linux/acpi.h b/include/linux/acpi.h index cd7371a5f2839b..ea2efbdbeee511 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -495,7 +495,7 @@ bool acpi_dev_resource_address_space(struct acpi_resource *ares, struct resource_win *win); bool acpi_dev_resource_ext_address_space(struct acpi_resource *ares, struct resource_win *win); -unsigned long acpi_dev_irq_flags(u8 triggering, u8 polarity, u8 shareable); +unsigned long acpi_dev_irq_flags(u8 triggering, u8 polarity, u8 shareable, u8 wake_capable); unsigned int acpi_dev_get_irq_type(int triggering, int polarity); bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index, struct resource *res); diff --git a/include/linux/ioport.h b/include/linux/ioport.h index 616b683563a970..3baeea4d903bfd 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -79,7 +79,8 @@ struct resource { #define IORESOURCE_IRQ_HIGHLEVEL (1<<2) #define IORESOURCE_IRQ_LOWLEVEL (1<<3) #define IORESOURCE_IRQ_SHAREABLE (1<<4) -#define IORESOURCE_IRQ_OPTIONAL (1<<5) +#define IORESOURCE_IRQ_OPTIONAL (1<<5) +#define IORESOURCE_IRQ_WAKECAPABLE (1<<6) /* PnP DMA specific bits (IORESOURCE_BITS) */ #define IORESOURCE_DMA_TYPE_MASK (3<<0) From patchwork Wed Sep 21 15:51:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raul Rangel X-Patchwork-Id: 12983937 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 7A838C6FA82 for ; Wed, 21 Sep 2022 16:00:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232085AbiIUQAo (ORCPT ); Wed, 21 Sep 2022 12:00:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232597AbiIUQAC (ORCPT ); Wed, 21 Sep 2022 12:00:02 -0400 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A16DCA2616 for ; Wed, 21 Sep 2022 08:53:26 -0700 (PDT) Received: by mail-io1-xd2e.google.com with SMTP id z191so5352225iof.10 for ; Wed, 21 Sep 2022 08:53:26 -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=mgV9GFoD/PnPg8Ox/eIPiRcCrnyz5POWnt5SbHnSSbo=; b=EV1UpUr5zy/WnMQgW8qJLc7riVKMxTUd+amem7TJWyzDLmc4OH/r1vgThiXyeOZ7uK 5jq7Wg8r244cOMvOTabg3It9JHoY2XhrUVybCKLkY640SMg7Q3NKatOO+bRs4YaOlTef 0M26d83h/GNK7x5GPlX2oaQy7OEjI20Mnyll4= 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=mgV9GFoD/PnPg8Ox/eIPiRcCrnyz5POWnt5SbHnSSbo=; b=SIEZlgxyFf8SYPH9gtHx4DBuIQ/riBEMVD7PAf68EnTFqvtHu4YIJy8fkXUBoZQ6nA mRj9dNiBZaXyNPbuBvFrT5dj+H64g+vrh+7uB+fnfWxPU3vT/NQDEpfPY485zZ1uZr+A NBSrRvB5J20ytKNT8bkBbAvxFlWWLxZgAIOX0t9NfgRSbBt66YWFJnNdPaqB3w3MuPnW t67xZWKZlgmDTwDjMzfkXQ93nyE0i5uQJlhdwTsUZuU2FE3SIxrh8v5Z/ZnPYnbomVHW r26icPP4ycXUaoJTv2dqtH79f5RMJqDa14DQ0K1MoCRpf5BnYmaZpJfTWHzK67xVt8H9 NEkA== X-Gm-Message-State: ACrzQf1smchc07C1olNNj/Ear/wVBkEvIKYe9qZks/nBa/vOAuRJsV5t ztLjbJfSomlMvcUE0Bzkjsaol7C71/1fbQ== X-Google-Smtp-Source: AA6agR5GlvCTPL8WgGfiM7xhqoa+Nvp6/NTRIoJ9uiI5TX2+EalCVP2SL/LAb4FV9QoLgns+PEN+RQ== X-Received: by 2002:a05:6638:d0d:b0:35a:186a:b3ef with SMTP id q13-20020a0566380d0d00b0035a186ab3efmr13131871jaj.246.1663775537794; Wed, 21 Sep 2022 08:52:17 -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.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 08:52:17 -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 , Wolfram Sang , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 07/13] i2c: acpi: Use ACPI wake capability bit to set wake_irq Date: Wed, 21 Sep 2022 09:51:59 -0600 Message-Id: <20220921094736.v5.7.I8af4282adc72eb9f247adcd03676a43893a020a6@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-acpi@vger.kernel.org Device tree already has a mechanism to pass the wake_irq. It does this by looking for the wakeup-source property and setting the I2C_CLIENT_WAKE flag. This CL adds the ACPI equivalent. It uses the ACPI interrupt wake flag to determine if the interrupt can be used to wake the system. Previously the i2c drivers had to make assumptions and blindly enable the wake IRQ. This can cause spurious wake events. e.g., If there is a device with an Active Low interrupt and the device gets powered off while suspending, the interrupt line will go low since it's no longer powered and wakes the system. For this reason we should respect the board designers wishes and honor the wake bit defined on the interrupt. Signed-off-by: Raul E Rangel Reviewed-by: Mika Westerberg Reviewed-by: Andy Shevchenko Acked-by: Wolfram Sang --- Changes in v5: - Check irq return value before updating wake_capable pointer Changes in v4: - Removed unnecessary !! - Removed unrelated whitespace change - Added Reviewed-by - Renamed i2c_acpi_add_resource to i2c_acpi_add_irq_resource - Expanded logic in i2c_acpi_add_i2c_resource to make it easier to read Changes in v3: - Convert wake_capable to bool - Only update wake_capable pointer once - Move wake_capable local into local block Changes in v2: - Look at wake_cabple bit for IRQ/Interrupt resources drivers/i2c/i2c-core-acpi.c | 37 +++++++++++++++++++++++++++---------- drivers/i2c/i2c-core-base.c | 6 +++++- drivers/i2c/i2c-core.h | 4 ++-- 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c index c762a879c4cc6b..1618f5619d5ed9 100644 --- a/drivers/i2c/i2c-core-acpi.c +++ b/drivers/i2c/i2c-core-acpi.c @@ -137,6 +137,11 @@ static const struct acpi_device_id i2c_acpi_ignored_device_ids[] = { {} }; +struct i2c_acpi_irq_context { + int irq; + bool wake_capable; +}; + static int i2c_acpi_do_lookup(struct acpi_device *adev, struct i2c_acpi_lookup *lookup) { @@ -168,13 +173,19 @@ static int i2c_acpi_do_lookup(struct acpi_device *adev, return 0; } -static int i2c_acpi_add_resource(struct acpi_resource *ares, void *data) +static int i2c_acpi_add_irq_resource(struct acpi_resource *ares, void *data) { - int *irq = data; + struct i2c_acpi_irq_context *irq_ctx = data; struct resource r; - if (*irq <= 0 && acpi_dev_resource_interrupt(ares, 0, &r)) - *irq = i2c_dev_irq_from_resources(&r, 1); + if (irq_ctx->irq > 0) + return 1; + + if (!acpi_dev_resource_interrupt(ares, 0, &r)) + return 1; + + irq_ctx->irq = i2c_dev_irq_from_resources(&r, 1); + irq_ctx->wake_capable = r.flags & IORESOURCE_IRQ_WAKECAPABLE; return 1; /* No need to add resource to the list */ } @@ -182,31 +193,37 @@ static int i2c_acpi_add_resource(struct acpi_resource *ares, void *data) /** * i2c_acpi_get_irq - get device IRQ number from ACPI * @client: Pointer to the I2C client device + * @wake_capable: Set to true if the IRQ is wake capable * * Find the IRQ number used by a specific client device. * * Return: The IRQ number or an error code. */ -int i2c_acpi_get_irq(struct i2c_client *client) +int i2c_acpi_get_irq(struct i2c_client *client, bool *wake_capable) { struct acpi_device *adev = ACPI_COMPANION(&client->dev); struct list_head resource_list; - int irq = -ENOENT; + struct i2c_acpi_irq_context irq_ctx = { + .irq = -ENOENT, + }; int ret; INIT_LIST_HEAD(&resource_list); ret = acpi_dev_get_resources(adev, &resource_list, - i2c_acpi_add_resource, &irq); + i2c_acpi_add_irq_resource, &irq_ctx); if (ret < 0) return ret; acpi_dev_free_resource_list(&resource_list); - if (irq == -ENOENT) - irq = acpi_dev_gpio_irq_get(adev, 0); + if (irq_ctx.irq == -ENOENT) + irq_ctx.irq = acpi_dev_gpio_irq_wake_get(adev, 0, &irq_ctx.wake_capable); + + if (irq_ctx.irq > 0 && wake_capable) + *wake_capable = irq_ctx.wake_capable; - return irq; + return irq_ctx.irq; } static int i2c_acpi_get_info(struct acpi_device *adev, diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 91007558bcb260..fc4b85fb90b1b7 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -487,7 +487,11 @@ static int i2c_device_probe(struct device *dev) if (irq == -EINVAL || irq == -ENODATA) irq = of_irq_get(dev->of_node, 0); } else if (ACPI_COMPANION(dev)) { - irq = i2c_acpi_get_irq(client); + bool wake_capable; + + irq = i2c_acpi_get_irq(client, &wake_capable); + if (irq > 0 && wake_capable) + client->flags |= I2C_CLIENT_WAKE; } if (irq == -EPROBE_DEFER) { status = irq; diff --git a/drivers/i2c/i2c-core.h b/drivers/i2c/i2c-core.h index 87e2c914f1c57b..1247e6e6e97517 100644 --- a/drivers/i2c/i2c-core.h +++ b/drivers/i2c/i2c-core.h @@ -61,11 +61,11 @@ static inline int __i2c_check_suspended(struct i2c_adapter *adap) #ifdef CONFIG_ACPI void i2c_acpi_register_devices(struct i2c_adapter *adap); -int i2c_acpi_get_irq(struct i2c_client *client); +int i2c_acpi_get_irq(struct i2c_client *client, bool *wake_capable); #else /* CONFIG_ACPI */ static inline void i2c_acpi_register_devices(struct i2c_adapter *adap) { } -static inline int i2c_acpi_get_irq(struct i2c_client *client) +static inline int i2c_acpi_get_irq(struct i2c_client *client, bool *wake_capable) { return 0; } From patchwork Wed Sep 21 15:52:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raul Rangel X-Patchwork-Id: 12983958 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 59B72C6FA8B for ; Wed, 21 Sep 2022 16:18:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229657AbiIUQSv (ORCPT ); Wed, 21 Sep 2022 12:18:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230081AbiIUQSV (ORCPT ); Wed, 21 Sep 2022 12:18:21 -0400 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A143AB1B4 for ; Wed, 21 Sep 2022 09:03:06 -0700 (PDT) Received: by mail-pg1-x535.google.com with SMTP id t190so6360952pgd.9 for ; Wed, 21 Sep 2022 09:03:06 -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=RxwwHMPvk5ayq6Q0eWnQYvYby/RH2VOKKKhXm3+laCU=; b=LJOfJcIhk0yQdlJbSJLsffLY9QE0ItNjkIbsxhkWVifYPBdvXTclI2ynnNkd0fsMj1 ero0vR/f3i0Kvoy1WG9JCgsgqeSn3mr5T14kzHOeNKthpAVOGCDgY4rXZe5illCWXn3m CB+4PnJjrTitKBtcfISGYikqVVlrnjgpi9dTM= 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=RxwwHMPvk5ayq6Q0eWnQYvYby/RH2VOKKKhXm3+laCU=; b=68Ub89PYHCY56EUQdsVdtPXiZZbwMmRST5OabnO4zrjDV+on994ljqBe3JnnTyaYq+ nlikV9AdrnUllwvBG8zmM6krwGi6Hu2Pk5V0+qHvW5/b+lu1SIb7o5eapozOKavRlThJ KtCpb2bON278ud14TNBcV5PnbDUN1FmE44QsvrRoKVrix0wEUmS0aLbR6e3MD1wTUlGX bTdIBw1hIbVliiqCpeBuXc+ADZUMZkWamPwOPWYdUk3ZHKYKcqTdQ1GFuoVusUPVBmAQ VNuwCQrrhf6UxuqkYGwQqOB5Dx3EZ6CDNO+PXCORFfidS5j2+EFQc3SV2mK3kG17+Q4k GaDw== X-Gm-Message-State: ACrzQf3bx5Ydm719a0rl2pbczo4HQAhwOJb5YBB4TirlqOuTcISvLMZn KwWWCYkrlCRq5NkjXSSSZs3aWsZboyiVpA== X-Google-Smtp-Source: AMsMyM4HNU9p1Dc70gExDsuZAIHaSFxoo7r6SNYVPn+iImB9Fs6jDcQEM5mRn+8XnBttrvjUafvlBQ== X-Received: by 2002:a05:6602:1352:b0:69d:e793:abd with SMTP id i18-20020a056602135200b0069de7930abdmr12256877iov.172.1663775538996; Wed, 21 Sep 2022 08:52:18 -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.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 08:52:18 -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 , Len Brown , linux-kernel@vger.kernel.org Subject: [PATCH v5 08/13] ACPI: PM: Take wake IRQ into consideration when entering suspend-to-idle Date: Wed, 21 Sep 2022 09:52:00 -0600 Message-Id: <20220921094736.v5.8.I7d9202463f08373feccd6e8fd87482c4f40ece5d@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-acpi@vger.kernel.org This change adds support for ACPI devices that use ExclusiveAndWake or SharedAndWake in their _CRS GpioInt definition (instead of using _PRW), and also provide power resources. Previously the ACPI subsystem had no idea if the device had a wake capable interrupt armed. This resulted in the ACPI device PM system placing the device into D3Cold, and thus cutting power to the device. With this change we will now query the _S0W method to figure out the appropriate wake capable D-state. Signed-off-by: Raul E Rangel --- Changes in v5: - Go back to using adev->wakeup.flags.valid to keep the diff cleaner - Fix a typo in comment drivers/acpi/device_pm.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index 9dce1245689ca2..3111fc426e04fd 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c @@ -681,8 +681,23 @@ static int acpi_dev_pm_get_state(struct device *dev, struct acpi_device *adev, d_min = ret; wakeup = device_may_wakeup(dev) && adev->wakeup.flags.valid && adev->wakeup.sleep_state >= target_state; - } else { - wakeup = adev->wakeup.flags.valid; + } else if (adev->wakeup.flags.valid) { + /* ACPI GPE specified in _PRW. */ + wakeup = true; + } else if (device_may_wakeup(dev) && dev->power.wakeirq) { + /* + * The ACPI subsystem doesn't manage the wake bit for IRQs + * defined with ExclusiveAndWake and SharedAndWake. Instead we + * expect them to be managed via the PM subsystem. Drivers + * should call dev_pm_set_wake_irq to register an IRQ as a wake + * source. + * + * If a device has a wake IRQ attached we need to check the + * _S0W method to get the correct wake D-state. Otherwise we + * end up putting the device into D3Cold which will more than + * likely disable wake functionality. + */ + wakeup = true; } /* From patchwork Wed Sep 21 15:52:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raul Rangel X-Patchwork-Id: 12983936 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 A0276C6FA90 for ; Wed, 21 Sep 2022 16:00:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232077AbiIUQAm (ORCPT ); Wed, 21 Sep 2022 12:00:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232659AbiIUQAN (ORCPT ); Wed, 21 Sep 2022 12:00:13 -0400 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53C2BAE74 for ; Wed, 21 Sep 2022 08:53:40 -0700 (PDT) Received: by mail-io1-xd2e.google.com with SMTP id b23so5397969iof.2 for ; Wed, 21 Sep 2022 08:53:39 -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=BLdt6ZhvGr0RaD7VzP2mPYzzyAyFxpk+jb6URS+dUyM=; b=NW0DxOZCIOhi7D7pIYBZmi1MjcIGOGN5aKSPvNUUuHsu91/a4vEXXoU9yoKtVcVFy1 KdBLpQG6bfggGEj+YyGfdWIl7h49HmUDstUFnDxLcYrTNuZABzYm54SCfyQ65BqaDLVZ NEk5ON3+abjpYKgiOp6c76ILaDUJNeCAz8ecg= 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=BLdt6ZhvGr0RaD7VzP2mPYzzyAyFxpk+jb6URS+dUyM=; b=tjA9EpxDBPaufvX236P9AWSXvefvAW6uIeJs1uK5TchQaPON8KLOGszvv1WER2fAnn TwsZdBQnohnrWljp4Kt0Oucwdi5WIS4TiG1PBzyzmRBBYb0cwzIG36zf9cNsY379Xt8f M/Xm6T5TL/98/mrbbHyl8nXWnFP2/NniwZjOekYmiJAoxgW73ejrZHNthNkOHRXxfKoI fAun2H8alHx2nXNTIe2d4DD5bGPeec5MOssvtOMnZ+32PF9bXckFBRFwV5NeriFYAdrF zHGmU7/u2TYlXTPLQQtudcZaCkdZiHsPXSMTu1GiTyVMRFYwwfYDk+eg6uE2C/vyk1AH XHvA== X-Gm-Message-State: ACrzQf1MgA2AXk4Ur869A9QN8XwmT7b6GG6PvWRiOPXNfOhOQd7W2TQM D+rU/Cvmjhgtd6c+JX+wo02hpVyOg9Dm/Q== X-Google-Smtp-Source: AMsMyM7Imln63wm+6aXB+OaGfTzsZGZphFcReZdUZOOOW5iAvoeaP8vqNuJMBYexE48ezn3l+879nw== X-Received: by 2002:a05:6638:3a1a:b0:35a:26bc:8856 with SMTP id cn26-20020a0566383a1a00b0035a26bc8856mr13100319jab.47.1663775540394; Wed, 21 Sep 2022 08:52:20 -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.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 08:52:20 -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 , Benjamin Tissoires , Alistair Francis , Jiri Kosina , Rob Herring , linux-kernel@vger.kernel.org Subject: [PATCH v5 09/13] HID: i2c-hid: acpi: Stop setting wakeup_capable Date: Wed, 21 Sep 2022 09:52:01 -0600 Message-Id: <20220921094736.v5.9.I2efb7f551e0aa2dc4c53b5fd5bbea91a1cdd9b32@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-acpi@vger.kernel.org This is now handled by the i2c-core driver. Signed-off-by: Raul E Rangel Acked-by: Benjamin Tissoires --- Changes in v5: - Added Acked-by: Benjamin Tissoires drivers/hid/i2c-hid/i2c-hid-acpi.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/hid/i2c-hid/i2c-hid-acpi.c b/drivers/hid/i2c-hid/i2c-hid-acpi.c index b96ae15e0ad917..375c77c3db74d9 100644 --- a/drivers/hid/i2c-hid/i2c-hid-acpi.c +++ b/drivers/hid/i2c-hid/i2c-hid-acpi.c @@ -105,11 +105,6 @@ static int i2c_hid_acpi_probe(struct i2c_client *client) acpi_device_fix_up_power(adev); - if (acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0) { - device_set_wakeup_capable(dev, true); - device_set_wakeup_enable(dev, false); - } - return i2c_hid_core_probe(client, &ihid_acpi->ops, hid_descriptor_address, 0); } From patchwork Wed Sep 21 15:52:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raul Rangel X-Patchwork-Id: 12983959 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 0D8BCC6FA90 for ; Wed, 21 Sep 2022 16:18:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229688AbiIUQSw (ORCPT ); Wed, 21 Sep 2022 12:18:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232004AbiIUQS0 (ORCPT ); Wed, 21 Sep 2022 12:18:26 -0400 Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A56BAB409 for ; Wed, 21 Sep 2022 09:03:11 -0700 (PDT) Received: by mail-il1-x129.google.com with SMTP id x2so3351985ill.10 for ; Wed, 21 Sep 2022 09:03:10 -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=THUFniOK+VEaZvk3WrlhDVy764x1MLYSOQIxcILEvxQ=; b=X0gOecgOXbR09B7uWiGNA3l57ZH5gzdV7m2fMkuQmBtbM0SHP5TFh/xGTkWyKMdd6k bYpQNI35i3B3pvOfI+0U3gvY9f46t3tfzi3Cngcf2p06SP/YugBowaJzwFQnjtycWsIm yvQwRVcp/HB0tQHhH92QQfiTU3aLyBnLZx8zo= 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=THUFniOK+VEaZvk3WrlhDVy764x1MLYSOQIxcILEvxQ=; b=CLEX3gKs2Bt28VQ5n/UNzNPxaMBzZKvbRtIrrF/aPeQfj1CsDZWRYIzNaMy0mIWyOI 2Zkz84/4BQuiGTi1yniAju7c5L3cd22CrgFRv3+lRgsegdyYMDVVp3QYII4QVu+VJBDV BoyjE5Z3FTH8JgINEkrLkjHRWNlnRgebYZbAxj+rCgkuD+nUY+C3HM77M1KBbDU38b9x cNul/2miyUEcm8jktN7dWKvzyYYyIq9glFrANapJox6AgC1Iz1KEnoIAnCCTHd3Ql/In lpbuBrxgqo+Q8JSeZonBfeH1VdvtE3kDY//EDiL4QyNi58fuQAx/QUU9X7B83dW/QrCA eNdw== X-Gm-Message-State: ACrzQf3bBGuMfYNJ1gFkp8hzBsG48jqjrP/1Z0YTdVLpIDYSbLP+tVAe vggS6l5fw9eYIF97eeAunJUzuG9c4AHXlA== X-Google-Smtp-Source: AMsMyM7Y39hoLqgIounsHo+rfvleaY90wBHu2R1tTiv/+BtlKIZ58AXKbEM8mFWmHFs9E7lq3sofGg== X-Received: by 2002:a05:6e02:1c48:b0:2f1:db4b:66df with SMTP id d8-20020a056e021c4800b002f1db4b66dfmr12601061ilg.35.1663775541555; Wed, 21 Sep 2022 08:52:21 -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.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 08:52:21 -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 , Benjamin Tissoires , Alistair Francis , Bartosz Szczepanek , Jiri Kosina , Rob Herring , Yang Li , linux-kernel@vger.kernel.org Subject: [PATCH v5 10/13] HID: i2c-hid: Don't set wake_capable and wake_irq Date: Wed, 21 Sep 2022 09:52:02 -0600 Message-Id: <20220921094736.v5.10.Id22d056440953134d8e8fe2c2aff79c79bc78424@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-acpi@vger.kernel.org The i2c-core will now handle setting the wake_irq for DT and ACPI systems. Signed-off-by: Raul E Rangel Acked-by: Benjamin Tissoires --- Changes in v5: - Added Acked-by: Benjamin Tissoires drivers/hid/i2c-hid/i2c-hid-core.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c index a2fa40dec04ea5..65b7a95956866d 100644 --- a/drivers/hid/i2c-hid/i2c-hid-core.c +++ b/drivers/hid/i2c-hid/i2c-hid-core.c @@ -1036,15 +1036,6 @@ int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops, if (ret < 0) goto err_powered; - /* - * 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 (!client->dev.power.wakeirq) - dev_pm_set_wake_irq(&client->dev, client->irq); - hid = hid_allocate_device(); if (IS_ERR(hid)) { ret = PTR_ERR(hid); From patchwork Wed Sep 21 15:52:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raul Rangel X-Patchwork-Id: 12983939 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 A809CC6FA82 for ; Wed, 21 Sep 2022 16:02:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232301AbiIUQCB (ORCPT ); Wed, 21 Sep 2022 12:02:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232766AbiIUQA2 (ORCPT ); Wed, 21 Sep 2022 12:00:28 -0400 Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E53458DDF for ; Wed, 21 Sep 2022 08:53:53 -0700 (PDT) Received: by mail-il1-x134.google.com with SMTP id i16so333701ilq.0 for ; Wed, 21 Sep 2022 08:53:53 -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=H54d0G6AAErtN9paRV2+6Wo2Il0gAFeOcBLywRUXXa0=; b=aPT4P7qoRZWdL5Bmar/LZHlelSGaUIcO+KvnefvZmwjLeCnKyFua9Sdj/jZ3OYL968 cQxDi+jSWtUu8TdBqWCYELC8kdx3qAM2gxeRYH8iHLqWA9+l0/9xs6ERSCp/n70oZaHw z/ZVSYsY35pX3YiNhdheaP4Q62BbzLzk4j470= 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=H54d0G6AAErtN9paRV2+6Wo2Il0gAFeOcBLywRUXXa0=; b=ym9q8B5otzNYoIy/B0ipApcTN16zreWnFVyVlYt6lEEp11QRkf0yt0CrYIGdPeDNcD vGf7LQMxLjIFJbSebfZ3DDkixzv1D8jzxzS1F4/FZes/oqtUd+sz4SLlenY26lOVPnLZ /0NTAgr1xNqoaffC+7z8LtJeKIiiYvQicXZWii8rZBj+cjkVl8DfVrdF8SlNuWof6Yox v5qRwLVtSab06xnWQORO1RGG/YSiQey2Nvk3e6UgpCUwfJuvHv//5bghgTpagkW14cLs kypkhMVKMrnid9RXG0SWz17kwxIhbsTC/PL4qSL1806+/Lil836Y0WQLoV++IYf9kmUF sfFQ== X-Gm-Message-State: ACrzQf1GcJmrxbjbymYatvCPy/bd7ckuPAyVAQr9KVU/hQIfjCtmRvyd 4u2yQ717+y6rYeHBcwPKP/YiSjtKqxTIzQ== X-Google-Smtp-Source: AMsMyM7LF80A56RG5rA5mp7cs5aIJCOrf0Zc81Hwi3Jug3DDAhNSylTY9RpImJUvdn25Fw0A8rtlVg== X-Received: by 2002:a92:c546:0:b0:2f1:ceaf:89f8 with SMTP id a6-20020a92c546000000b002f1ceaf89f8mr12931327ilj.195.1663775542631; Wed, 21 Sep 2022 08:52:22 -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.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 08:52:22 -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 11/13] Input: elan_i2c - Don't set wake_capable and wake_irq Date: Wed, 21 Sep 2022 09:52:03 -0600 Message-Id: <20220921094736.v5.11.I7309b8f322082437b93581c6e2953886eeb998d7@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-acpi@vger.kernel.org The i2c-core will now handle setting the wake_irq and wake capability for DT and ACPI systems. Signed-off-by: Raul E Rangel --- (no changes since v2) Changes in v2: - I chose not to keep the legacy code around since systems without DT or ACPI should be rare. drivers/input/mouse/elan_i2c_core.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c index 3947474e93d16a..b25b94aba3e88e 100644 --- a/drivers/input/mouse/elan_i2c_core.c +++ b/drivers/input/mouse/elan_i2c_core.c @@ -1332,22 +1332,6 @@ static int elan_probe(struct i2c_client *client, } } - /* - * Systems using device tree should set up wakeup via DTS, - * the rest will configure device as wakeup source by default. - */ - 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; } From patchwork Wed Sep 21 15:52:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raul Rangel X-Patchwork-Id: 12983952 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 D4289C6FA82 for ; Wed, 21 Sep 2022 16:16:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230179AbiIUQQL (ORCPT ); Wed, 21 Sep 2022 12:16:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232555AbiIUQPh (ORCPT ); Wed, 21 Sep 2022 12:15:37 -0400 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42661A8308 for ; Wed, 21 Sep 2022 09:00:59 -0700 (PDT) Received: by mail-pf1-x434.google.com with SMTP id u132so6370737pfc.6 for ; Wed, 21 Sep 2022 09:00:59 -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=ETp6lHAE1kwX97QdZzpHEsClO/L2A3yvzqUq+PQbIOE=; b=LsTgob0Jg85X+GdHTPCcSKwZ6O2a3L53H9zaPDhgg7JKugVmorz8gKSf5/lX8WCOZp nZG53zTr0k8PM19xaliGlOyfRPyeIkAObqICnjZVpcHVWitsKYqlHKu0Vqgxj8H584J/ O8tm7uzFvYYTJxAeh4rsWifjh+TMPH0GFzoEU= 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=ETp6lHAE1kwX97QdZzpHEsClO/L2A3yvzqUq+PQbIOE=; b=bPljxAl5kQ9baKGknVaQ+BR4uBckiYZQOrqWQfaGk/gm56L0EAFL7K/9U48h5FhqFj HNN7W9hmN6Thn3lg85r1V9RGQk3atbjzbwyEMmS9g/A5i4Nfy5jMSiH2kMGpdXq3dd4J ChmQUBuXxCXegOCQ0xc6yMN2GSPgdIOmapdIXWWSU3GOXsyc8WopEdTv6VQDGglaIQeU dZFWXTiVUpWeY9MbUSY2yEsrJsKJRh6mcBKNhG++NXT4HYg4M4vWBsKgxZk5KyqDx5s9 JoEbCtYxhZJFgS8FB1xYBZ9be999oIfA70cU8miOUcMFrPtUFQHlXYcF0Q27NUGBTQfg R1oQ== X-Gm-Message-State: ACrzQf3j2E9UvwJsvBfmdENrkoDK7Fib3s3P2HuSCYj+E2xehu5iTGRN jCW5dJK1XFSbRH4fS5vIGRMNjXoXlysCmw== X-Google-Smtp-Source: AMsMyM4RLve9ZqCpyicxnvvWOvFh7ngh5UCRji7JOVJ7e3ZDfNCacVsOzJ8MXQ+l4aM3Hqtg+W3gOQ== X-Received: by 2002:a92:ccd0:0:b0:2f6:274c:f564 with SMTP id u16-20020a92ccd0000000b002f6274cf564mr4883656ilq.116.1663775544330; Wed, 21 Sep 2022 08:52:24 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 08:52:23 -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 , Cai Huoqing , Guenter Roeck , Johnny Chuang , linux-kernel@vger.kernel.org Subject: [PATCH v5 12/13] Input: elants_i2c - Don't set wake_capable and wake_irq Date: Wed, 21 Sep 2022 09:52:04 -0600 Message-Id: <20220921094736.v5.12.I031ffbe411e1bae20bf16a1876da5baf444c7928@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-acpi@vger.kernel.org The i2c-core will now handle setting the wake_irq and wake capability for DT and ACPI systems. Signed-off-by: Raul E Rangel --- (no changes since v1) drivers/input/touchscreen/elants_i2c.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c index 80e16b533c452a..3500293bb1d8e1 100644 --- a/drivers/input/touchscreen/elants_i2c.c +++ b/drivers/input/touchscreen/elants_i2c.c @@ -1575,22 +1575,6 @@ static int elants_i2c_probe(struct i2c_client *client) return error; } - /* - * Systems using device tree should set up wakeup via DTS, - * the rest will configure device as wakeup source by default. - */ - if (!client->dev.of_node) - device_init_wakeup(&client->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 (!client->dev.power.wakeirq) - dev_pm_set_wake_irq(&client->dev, client->irq); - error = devm_device_add_group(&client->dev, &elants_attribute_group); if (error) { dev_err(&client->dev, "failed to create sysfs attributes: %d\n", From patchwork Wed Sep 21 15:52:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raul Rangel X-Patchwork-Id: 12983956 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 40298ECAAD8 for ; Wed, 21 Sep 2022 16:17:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232206AbiIUQRK (ORCPT ); Wed, 21 Sep 2022 12:17:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232154AbiIUQQk (ORCPT ); Wed, 21 Sep 2022 12:16:40 -0400 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF6E7A98E8 for ; Wed, 21 Sep 2022 09:01:28 -0700 (PDT) Received: by mail-pg1-x52a.google.com with SMTP id e67so247973pgc.12 for ; Wed, 21 Sep 2022 09:01:28 -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=uhn02vEcgNMuC4NDL/sdnIiKkA3NV83noPVamoKM5ng=; b=J+m/6s3OweW7a/eo9st4eaQgCj5FBjVxWu4cd0CaPO5cml8TYlNkg/w5YMuvK+r+GQ wzhrojO6SeTZXM/fmsxo/ctc7AJ+AoKGqVMF18GQ8VM2foK5SHjyhGHiByVZJBVAX1i1 obzlAwJ08YXB3oRiWQZ0lmKoLJMRn+Pegtamw= 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=uhn02vEcgNMuC4NDL/sdnIiKkA3NV83noPVamoKM5ng=; b=hN5cD93YQtDh5tXCme5PT4eYj11o3WSn29sMApM2461vW4ta55/fiDPazT8oiKsL3R U6Eq+J39XPngVtLZkOcVMrrzG2lzXAZ7FoKTqh0bBdr/67UZ6uUf5onl83Y5MiDd1yIP 7z0wypoVftP1uI1h394KwyAfn0WY1Ig+n6JPkTP/KeSJCqYMuqOR/nMnuXvEeSv/LxxC SHmeXT3ZNGnFw+N6x82EEO967cMNX5pXTAwEkidHQo0wrIX6AEbGrK5z5NUfBT2ncg2L Y8AVNKFixpNYcV3RtnTqdcCvNCCi2owiay5kdvqeC0rOU1RVqsKsUrEflA4kOE8pSppn D6vw== X-Gm-Message-State: ACrzQf2jCdVd16o6OmY7AbzVZOHh1QPlsGGFM0O9m81BtlIjhZHXKw0a r14ba1f/zzBhF3nmGJoDayjwAKdISZWwuQ== X-Google-Smtp-Source: AMsMyM5y+0hpMGJsf2ExwaciR2mijAedWncBixNTzl39icNIG8bLyvsSsOzqJ1lKOuRVy46al2qq4w== X-Received: by 2002:a05:6e02:20ce:b0:2f3:4a1f:3db4 with SMTP id 14-20020a056e0220ce00b002f34a1f3db4mr12919850ilq.278.1663775545355; Wed, 21 Sep 2022 08:52:25 -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.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 08:52:25 -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 , Cai Huoqing , linux-kernel@vger.kernel.org Subject: [PATCH v5 13/13] Input: raydium_ts_i2c - Don't set wake_capable and wake_irq Date: Wed, 21 Sep 2022 09:52:05 -0600 Message-Id: <20220921094736.v5.13.Ia0b24ab02c22125c5fd686cc25872bd26c27ac23@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-acpi@vger.kernel.org The i2c-core will now handle setting the wake_irq and wake capability for DT and ACPI systems. Signed-off-by: Raul E Rangel --- (no changes since v1) drivers/input/touchscreen/raydium_i2c_ts.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c b/drivers/input/touchscreen/raydium_i2c_ts.c index 66c5b577b791d4..88d187dc5d325f 100644 --- a/drivers/input/touchscreen/raydium_i2c_ts.c +++ b/drivers/input/touchscreen/raydium_i2c_ts.c @@ -1185,15 +1185,6 @@ static int raydium_i2c_probe(struct i2c_client *client, return error; } - /* - * 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 (!client->dev.power.wakeirq) - dev_pm_set_wake_irq(&client->dev, client->irq); - error = devm_device_add_group(&client->dev, &raydium_i2c_attribute_group); if (error) {