From patchwork Mon Dec 20 23:43:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raul Rangel X-Patchwork-Id: 526208 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 3B960C433F5 for ; Mon, 20 Dec 2021 23:44:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233135AbhLTXn7 (ORCPT ); Mon, 20 Dec 2021 18:43:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233110AbhLTXn7 (ORCPT ); Mon, 20 Dec 2021 18:43:59 -0500 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 E5F23C061574 for ; Mon, 20 Dec 2021 15:43:58 -0800 (PST) Received: by mail-io1-xd30.google.com with SMTP id z26so15398549iod.10 for ; Mon, 20 Dec 2021 15:43:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=U7gfCT4e8tEF3Otc3jGKu2gDoX5PakWDro5ts+abDGE=; b=YxZu/YPWyU2AnSsazyq+qxcIZ3Z409yrt6LhZuMx630zssLhbn5w2/gVZ/5qrvV1vj 05Mlb43Bv98Yja/AAHpIVPAE9ZaQ8Ep1DdxIoYgDG+e7zhoA5v8OYsKfrYAIJYeQNHXw s853/lpIHRnNE7VCbm/DFmlTL5EargiFErddY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=U7gfCT4e8tEF3Otc3jGKu2gDoX5PakWDro5ts+abDGE=; b=nA7OW8+/UQqGFKhrXeVC2rDrjIsnRYU551YC6fFB4DEWDlsh9wN0mZ9JuQTdI5IIv6 piv/J7+MV23woUP3Mk/VegUP7rUwUVLHAS1oiy0EYChi0IqCPYOMsC9mAKp6OV3c57gW Lh6ZFR6HOGTgz56An98g8Rv0AnfBIMxB40neqK2uSLm/ekmQcjWFtlE9wgWnMRplF96+ f89ylDG504r2u2XpWuwwZf13vQL+7VgESaaktc8wxgrZHWTIZbaSDvv+20sTSEpNgRvF EZDV81Sly0LoNx/ehFqO3Z0SH/YgAYt9rHiznVkgYjas/GQrcikBfd2lQldDfIGz3mV2 NaDQ== X-Gm-Message-State: AOAM5329sPlJNlWOU+SKX/CXfvWCaMPDkDN5agmufMGWqIHRQEGHFFKD T/dzAQSKkWvl40prSZ2y/yU8JQ== X-Google-Smtp-Source: ABdhPJzryZU8oQ0MchKWRjKQoAN9qnAYWbQhhUUaSNuHjYogepM/WJ4dd4hjqKHJ0ndKKiJ9LyzumQ== X-Received: by 2002:a05:6638:140e:: with SMTP id k14mr335461jad.251.1640043838339; Mon, 20 Dec 2021 15:43:58 -0800 (PST) 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 k19sm4077521ilr.34.2021.12.20.15.43.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Dec 2021 15:43:58 -0800 (PST) From: Raul E Rangel To: linux-kernel@vger.kernel.org Cc: mario.limonciello@amd.com, linux-input@vger.kernel.org, dianders@chromium.org, Raul E Rangel , Andy Shevchenko , Benjamin Tissoires , Hans de Goede , Jiri Kosina Subject: [PATCH 1/3] HID: i2c-hid-acpi: Remove explicit device_set_wakeup_capable Date: Mon, 20 Dec 2021 16:43:44 -0700 Message-Id: <20211220163823.1.Ie20ca47a26d3ea68124d8197b67bb1344c67f650@changeid> X-Mailer: git-send-email 2.34.1.307.g9b7440fafd-goog In-Reply-To: <20211220234346.2798027-1-rrangel@chromium.org> References: <20211220234346.2798027-1-rrangel@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org The ACPI subsystem is responsible for managing the power and wake sources for an ACPI device. By explicitly calling device_set_wakeup_capable, we are circumvent the ACPI subsystem and setting wake capabilities on the device when it doesn't support it. Take the following example: * We have an ACPI HID device that has `_PR0` and `_PR3`. It doesn't have `_PRW` so that means the device can't wake the system. * The IRQ line is active level low for this device and is pulled up by the power resource defined in `_PR0`/`_PR3`. Since the i2c-hid driver has set the device as wake capable, the wake pin gets enabled on suspend. As part of suspend, ACPI will power down the device since it's not a wake source. When the device is powered down, the IRQ line will drop, and it will trigger a wake event. See the following debug log: [ 42.335804] PM: Suspending system (s2idle) [ 42.340186] amd_gpio AMD0030:00: RX: Setting wake for pin 89 to enable [ 42.467736] power-0416 __acpi_power_off : Power resource [PR00] turned off [ 42.467739] device_pm-0280 device_set_power : Device [H05D] transitioned to D3cold [ 42.475210] PM: pm_system_irq_wakeup: 11 triggered pinctrl_amd [ 42.535293] PM: Wakeup unrelated to ACPI SCI [ 42.535294] PM: resume from suspend-to-idle Signed-off-by: Raul E Rangel --- 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 a6f0257a26de..fc311a19a19d 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); } From patchwork Mon Dec 20 23:43:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raul Rangel X-Patchwork-Id: 526743 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 18B25C433FE for ; Mon, 20 Dec 2021 23:44:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233144AbhLTXoA (ORCPT ); Mon, 20 Dec 2021 18:44:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233131AbhLTXn7 (ORCPT ); Mon, 20 Dec 2021 18:43:59 -0500 Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6890BC061574 for ; Mon, 20 Dec 2021 15:43:59 -0800 (PST) Received: by mail-io1-xd2f.google.com with SMTP id e128so15533381iof.1 for ; Mon, 20 Dec 2021 15:43:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lNqaSlrOE70VPTa+GjJ5DlEK6n0EAgcYkJbBO9oyFQk=; b=jUmFumTvIIdji9Cf7/UTW3J0mtygeMxgJLE07pAbntRBj5W7WGySBEXF+XrO69kC58 55pP1A/xiMYYlW9P4IwZDtIE1fSy17IXppqoMS3o/u8B0n2/cXxDq9bq/2ZnGdwYcApg acU0YA94vLuG9mB+6GrJ5ql40FjSItokhabYw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lNqaSlrOE70VPTa+GjJ5DlEK6n0EAgcYkJbBO9oyFQk=; b=SNzZLuZhrEwOD+J6/AxFiZXyGl45eNShaUfG23nRtt3hgvWpjd+6eeCCr+1gP8ZmzA SrZJIr163S8TSa1h4qI8cgMQBeAPr3PY0x795YJ3IG0+ckaV9TLX1gw1PgatQCLS0MUO n7lO/eMrTrVXVuvWtAYilylC+L8hx+KhUgt+nkbU/wFlAyjAKxZtjgt6dgv9vV+BoFA8 dSbzwTyORlscKsVR23EBNYIp7qUQCwWnB5VJQn0Gj4sZqBuYLicx+C3fjvS1ltASHrC2 rxnOvHpqNSccVQEd57GIvT1mf50j7u7pmM5kUg1ePfZxLapYO7SViV+K3s6/B9j5hRQB eaJg== X-Gm-Message-State: AOAM533KRlO3OaXCwx13MIanDTBbIv7XLP2aPjb0d2zxnvQTlCu2SkYd pIV5qePLxwFzh1RDQjhUb1ZBeg== X-Google-Smtp-Source: ABdhPJzUHNnstH41oXkBeK5J7PARGhWrTMv2EcttYGTcNS5AYBraDp2A2GI+XOH/RQC6P87vAEUWWg== X-Received: by 2002:a02:8501:: with SMTP id g1mr369627jai.144.1640043838916; Mon, 20 Dec 2021 15:43:58 -0800 (PST) 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 k19sm4077521ilr.34.2021.12.20.15.43.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Dec 2021 15:43:58 -0800 (PST) From: Raul E Rangel To: linux-kernel@vger.kernel.org Cc: mario.limonciello@amd.com, linux-input@vger.kernel.org, dianders@chromium.org, Raul E Rangel , Dmitry Torokhov , "jingle.wu" Subject: [PATCH 2/3] Input: elan_i2c - Use PM subsystem to manage wake irq Date: Mon, 20 Dec 2021 16:43:45 -0700 Message-Id: <20211220163823.2.Id022caf53d01112188308520915798f08a33cd3e@changeid> X-Mailer: git-send-email 2.34.1.307.g9b7440fafd-goog In-Reply-To: <20211220234346.2798027-1-rrangel@chromium.org> References: <20211220234346.2798027-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. When a device is managed by device tree or ACPI it is expected that those subsystems manage defining the wake pin and manage enabling it. This change removes the explicit enable_irq_wake/disable_irq_wake and relies on the PM subsystem. See device_wakeup_arm_wake_irqs. It also registers the IRQ using dev_pm_set_wake_irq only in the case where the device isn't DT or ACPI managed. This should preserve the existing behavior. I'm not sure how we actually get into this state though. I tested this with an ACPI device that has a `_PRW` method that uses a GPE was the wake event. I no longer see the GPIO controller being called to enable the wake pin. This results in the GPE correctly being marked as the wake source. Signed-off-by: Raul E Rangel --- drivers/input/mouse/elan_i2c_core.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c index 47af62c12267..58f056ee0747 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; @@ -1368,11 +1367,13 @@ static int elan_probe(struct i2c_client *client, } /* - * Systems using device tree should set up wakeup via DTS, + * Systems using device tree or ACPI should set up wakeup via DTS/ACPI, * the rest will configure device as wakeup source by default. */ - if (!dev->of_node) + if (!dev->of_node && !ACPI_COMPANION(dev)) { device_init_wakeup(dev, true); + dev_pm_set_wake_irq(dev, client->irq); + } return 0; } @@ -1394,13 +1395,10 @@ static int __maybe_unused elan_suspend(struct device *dev) disable_irq(client->irq); - if (device_may_wakeup(dev)) { + if (device_may_wakeup(dev)) ret = elan_sleep(data); - /* Enable wake from IRQ */ - data->irq_wake = (enable_irq_wake(client->irq) == 0); - } else { + else ret = elan_disable_power(data); - } mutex_unlock(&data->sysfs_mutex); return ret; @@ -1412,11 +1410,6 @@ static int __maybe_unused elan_resume(struct device *dev) struct elan_tp_data *data = i2c_get_clientdata(client); int error; - if (device_may_wakeup(dev) && data->irq_wake) { - disable_irq_wake(client->irq); - data->irq_wake = false; - } - error = elan_enable_power(data); if (error) { dev_err(dev, "power up when resuming failed: %d\n", error); From patchwork Mon Dec 20 23:43:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raul Rangel X-Patchwork-Id: 526207 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 29883C433F5 for ; Mon, 20 Dec 2021 23:44:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233165AbhLTXoA (ORCPT ); Mon, 20 Dec 2021 18:44:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233131AbhLTXoA (ORCPT ); Mon, 20 Dec 2021 18:44:00 -0500 Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 224D3C061574 for ; Mon, 20 Dec 2021 15:44:00 -0800 (PST) Received: by mail-io1-xd31.google.com with SMTP id e128so15533402iof.1 for ; Mon, 20 Dec 2021 15:44:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qPLa+lTt8vCW4IqiZRoAjFD2+DlmxgEl4wmSi4FTuOw=; b=O9l0LEb7TUTSspyh/AxCMkfk93Be4GaRLHafsGgHpnuCZ44FW2+fOwGF33R7FZiIk+ HaBxmoAoqGeayPqmlu/1yOxD+aemuqviVdRi3nLfpJVTx0VhJJiO1eGIkEzSyTeYJxdC VwX0i/zyKbxKb9Obr+VcykFgeAWGZ56+0Gp54= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qPLa+lTt8vCW4IqiZRoAjFD2+DlmxgEl4wmSi4FTuOw=; b=BpnU+u3fGcG7e4HLC79a6zcJLAe5AaHW3sNODWddzB5kFcecLsQpi8JJa3HSIsWlwB t/6m9OA6lHNkwocEFIzxRDp1WREL9Iwo0Gmp52MO9+mzLJqCTC5ikwlTqmX2EQK4DWZ+ IEElPtkuc35JChJuroIg0YsAYgbHCYmaEhADyzuWyQgx8jYYUTKWhq3WtiaPCMIVJL3R OozcIgYQBSUe69WlMpaVp6a6uY0HpxPpMfTX+ielnjh76c7JncAq/hQim1lteFGyWUSf lKp29TeXdjJP25VAnrzYjXDIdrZpuRWGhRe6sEb9HDkanwmH3wO5Mr0kniSHH1Aahsv9 bo/w== X-Gm-Message-State: AOAM5335uCvtd+zycKXu53r3J9+SlYA+YUFHEoVYRhusaG3+qSu3G1pr uDNPgcqIoc2dTuaB0SAgiazVUA== X-Google-Smtp-Source: ABdhPJxt7kvyeNHdnIFlVtQ7EkSTD2BNbhkBbLVbnBSYJW9499zBRWaFWT7dSKIXap6NXxEEnSftAg== X-Received: by 2002:a05:6638:25cd:: with SMTP id u13mr392376jat.8.1640043839566; Mon, 20 Dec 2021 15:43:59 -0800 (PST) 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 k19sm4077521ilr.34.2021.12.20.15.43.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Dec 2021 15:43:59 -0800 (PST) From: Raul E Rangel To: linux-kernel@vger.kernel.org Cc: mario.limonciello@amd.com, linux-input@vger.kernel.org, dianders@chromium.org, Raul E Rangel , Benson Leung , Enric Balletbo i Serra , Guenter Roeck , Gwendal Grignou , Prashant Malani Subject: [PATCH 3/3] platform/chrome: cros_ec: Don't enable wake pin if ACPI managed Date: Mon, 20 Dec 2021 16:43:46 -0700 Message-Id: <20211220163823.3.I2339b40dd2ed02569ba204734dc335866a1c5b98@changeid> X-Mailer: git-send-email 2.34.1.307.g9b7440fafd-goog In-Reply-To: <20211220234346.2798027-1-rrangel@chromium.org> References: <20211220234346.2798027-1-rrangel@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org In ACPI managed systems, the `_PRW` method defines the wake source for the device. This could be a GPE or a GPIO not related to the IRQ. The way the cros_ec_lpc driver works is that the irq field is optional. The IRQ defined in the `_CRS` is only used to speed up sensor event processing. Before this change, the SYNC_IRQ GPIO would have its wake bit enabled. This means that we now have two wake sources defined for the EC. This change makes the CrOS EC driver leave wake configuration alone if the device is ACPI managed. I tested this on guybrush and no longer see the EC SYNC IRQ enabled as a wake source when suspending. Signed-off-by: Raul E Rangel --- drivers/platform/chrome/cros_ec.c | 8 ++++++-- include/linux/platform_data/cros_ec_proto.h | 1 - 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/platform/chrome/cros_ec.c b/drivers/platform/chrome/cros_ec.c index fc5aa1525d13..81e334157338 100644 --- a/drivers/platform/chrome/cros_ec.c +++ b/drivers/platform/chrome/cros_ec.c @@ -9,6 +9,7 @@ * battery charging and regulator control, firmware update. */ +#include #include #include #include @@ -336,11 +337,14 @@ int cros_ec_suspend(struct cros_ec_device *ec_dev) dev_dbg(ec_dev->dev, "Error %d sending suspend event to ec", ret); - if (device_may_wakeup(dev)) + /* + * For non-ACPI subsystems we need to explicitly enable the wake source. + * For ACPI systems, the ACPI subsystem will handle all the details. + */ + if (device_may_wakeup(dev) && !ACPI_COMPANION(ec_dev->dev)) ec_dev->wake_enabled = !enable_irq_wake(ec_dev->irq); disable_irq(ec_dev->irq); - ec_dev->was_wake_device = ec_dev->wake_enabled; ec_dev->suspended = true; return 0; diff --git a/include/linux/platform_data/cros_ec_proto.h b/include/linux/platform_data/cros_ec_proto.h index 992796e40cd6..054d28ddb4c1 100644 --- a/include/linux/platform_data/cros_ec_proto.h +++ b/include/linux/platform_data/cros_ec_proto.h @@ -139,7 +139,6 @@ struct cros_ec_device { /* These are used by other drivers that want to talk to the EC */ const char *phys_name; struct device *dev; - bool was_wake_device; struct class *cros_class; int (*cmd_readmem)(struct cros_ec_device *ec, unsigned int offset, unsigned int bytes, void *dest);