All of lore.kernel.org
 help / color / mirror / Atom feed
From: Raul E Rangel <rrangel@chromium.org>
To: linux-acpi@vger.kernel.org, linux-input@vger.kernel.org
Cc: andriy.shevchenko@linux.intel.com, dmitry.torokhov@gmail.com,
	hdegoede@redhat.com, rafael@kernel.org,
	mika.westerberg@linux.intel.com, mario.limonciello@amd.com,
	timvp@google.com, linus.walleij@linaro.org, jingle.wu@emc.com.tw,
	Raul E Rangel <rrangel@chromium.org>,
	linux-kernel@vger.kernel.org
Subject: [PATCH v6 04/13] Input: raydium_ts_i2c - Use PM subsystem to manage wake irq
Date: Thu, 29 Sep 2022 10:19:08 -0600	[thread overview]
Message-ID: <20220929093200.v6.4.I06b417b274bbecb31775a73993a7a3c1bc80de7b@changeid> (raw)
In-Reply-To: <20220929161917.2348231-1-rrangel@chromium.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 <rrangel@chromium.org>
---

(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 3a4952935366f91..66c5b577b791d4f 100644
--- a/drivers/input/touchscreen/raydium_i2c_ts.c
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -21,6 +21,7 @@
 #include <linux/interrupt.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/pm_wakeirq.h>
 #include <linux/regulator/consumer.h>
 #include <linux/slab.h>
 #include <asm/unaligned.h>
@@ -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);
-- 
2.37.3.998.g577e59143f-goog


  parent reply	other threads:[~2022-09-29 16:19 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-29 16:19 [PATCH v6 00/13] acpi: i2c: Use SharedAndWake and ExclusiveAndWake to enable wake irq Raul E Rangel
2022-09-29 16:19 ` [PATCH v6 01/13] HID: i2c-hid: Use PM subsystem to manage " Raul E Rangel
2022-09-29 16:19 ` [PATCH v6 02/13] Input: elan_i2c - " Raul E Rangel
2022-09-29 16:19 ` [PATCH v6 03/13] Input: elants_i2c " Raul E Rangel
2022-09-29 16:19 ` Raul E Rangel [this message]
2022-09-29 16:19 ` [PATCH v6 05/13] gpiolib: acpi: Add wake_capable variants of acpi_dev_gpio_irq_get Raul E Rangel
2022-09-29 16:19 ` [PATCH v6 06/13] ACPI: resources: Add wake_capable parameter to acpi_dev_irq_flags Raul E Rangel
2022-09-29 19:17   ` Rafael J. Wysocki
2022-09-29 19:27     ` Raul Rangel
2022-09-29 19:38       ` Rafael J. Wysocki
2022-09-29 21:20         ` Raul Rangel
2022-09-29 23:22           ` Dmitry Torokhov
2022-09-30 17:13             ` Rafael J. Wysocki
2022-09-30 17:42               ` Andy Shevchenko
2022-09-30 17:54                 ` Rafael J. Wysocki
2022-09-30 17:55                 ` Dmitry Torokhov
2022-10-15 16:56                   ` Rafael J. Wysocki
2022-10-17 14:53                     ` Raul Rangel
2022-11-07 18:36                       ` Raul Rangel
2022-11-22 22:13                         ` Dmitry Torokhov
2022-09-29 16:19 ` [PATCH v6 07/13] i2c: acpi: Use ACPI wake capability bit to set wake_irq Raul E Rangel
2022-10-01 22:51   ` Wolfram Sang
2022-09-29 16:19 ` [PATCH v6 08/13] ACPI: PM: Take wake IRQ into consideration when entering suspend-to-idle Raul E Rangel
2022-09-29 19:06   ` Rafael J. Wysocki
2022-09-29 16:19 ` [PATCH v6 09/13] HID: i2c-hid: acpi: Stop setting wakeup_capable Raul E Rangel
2022-11-21 14:49   ` Andy Shevchenko
2022-11-30 18:06     ` Raul Rangel
2023-01-12 19:57   ` Werner Sembach
2023-01-12 20:09     ` Limonciello, Mario
2022-09-29 16:19 ` [PATCH v6 10/13] HID: i2c-hid: Don't set wake_capable and wake_irq Raul E Rangel
2022-09-29 16:19 ` [PATCH v6 11/13] Input: elan_i2c - " Raul E Rangel
2022-09-29 16:19 ` [PATCH v6 12/13] Input: elants_i2c " Raul E Rangel
2022-09-29 16:19 ` [PATCH v6 13/13] Input: raydium_ts_i2c " Raul E Rangel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220929093200.v6.4.I06b417b274bbecb31775a73993a7a3c1bc80de7b@changeid \
    --to=rrangel@chromium.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=hdegoede@redhat.com \
    --cc=jingle.wu@emc.com.tw \
    --cc=linus.walleij@linaro.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mario.limonciello@amd.com \
    --cc=mika.westerberg@linux.intel.com \
    --cc=rafael@kernel.org \
    --cc=timvp@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.