From: phucduc.bui@gmail.com
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Rob Herring <robh@kernel.org>
Cc: Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Ingo Molnar <mingo@kernel.org>, Thomas Gleixner <tglx@kernel.org>,
Marek Vasut <marex@denx.de>, Michael Welling <mwelling@ieee.org>,
linux-input@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, phucduc.bui@gmail.com
Subject: [PATCH 2/2] Input: Touchscreen: tsc200x - delegate wakeup IRQ management to I2C core
Date: Mon, 9 Mar 2026 18:00:44 +0700 [thread overview]
Message-ID: <20260309110045.108209-3-phucduc.bui@gmail.com> (raw)
In-Reply-To: <20260309110045.108209-1-phucduc.bui@gmail.com>
From: bui duc phuc <phucduc.bui@gmail.com>
The tsc200x driver supports both I2C (tsc2004) and SPI (tsc2005)
interfaces.
Currently, the driver attempts to manually manage the wakeup interrupt by
calling enable_irq_wake() and disable_irq_wake() during suspend and resume.
However, for I2C devices, the I2C core already automatically handles the
wakeup source initialization and IRQ management if the "wakeup-source"
property is present in the device tree. Manually managing it again in the
driver is redundant and can lead to unbalanced IRQ wake reference counts.
Clean up the wakeup IRQ handling by checking the bus type:
- For I2C (BUS_I2C): Rely entirely on the I2C core for wakeup management.
- For SPI (BUS_SPI): Explicitly call device_init_wakeup() in probe and
manually manage enable/disable_irq_wake() during suspend/resume.
The ts->wake_irq_enabled flag is also updated accordingly to ensure the
driver accurately tracks the wakeup state across both buses.
Note: This patch is based on code analysis of the I2C subsystem and
has not been verified on actual hardware yet.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
drivers/input/touchscreen/tsc200x-core.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/drivers/input/touchscreen/tsc200x-core.c b/drivers/input/touchscreen/tsc200x-core.c
index eba53613b005..d14d967845c8 100644
--- a/drivers/input/touchscreen/tsc200x-core.c
+++ b/drivers/input/touchscreen/tsc200x-core.c
@@ -465,6 +465,7 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
ts->idev = input_dev;
ts->regmap = regmap;
ts->tsc200x_cmd = tsc200x_cmd;
+ ts->bustype = tsc_id->bustype;
error = device_property_read_u32(dev, "ti,x-plate-ohms", &x_plate_ohm);
ts->x_plate_ohm = error ? TSC200X_DEF_RESISTOR : x_plate_ohm;
@@ -547,8 +548,9 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
return error;
}
- device_init_wakeup(dev,
- device_property_read_bool(dev, "wakeup-source"));
+ if (ts->bustype == BUS_SPI)
+ device_init_wakeup(dev,
+ device_property_read_bool(dev, "wakeup-source"));
return 0;
}
@@ -565,8 +567,13 @@ static int tsc200x_suspend(struct device *dev)
ts->suspended = true;
- if (device_may_wakeup(dev))
- ts->wake_irq_enabled = enable_irq_wake(ts->irq) == 0;
+ if (device_may_wakeup(dev)) {
+ if (ts->bustype == BUS_SPI)
+ ts->wake_irq_enabled = enable_irq_wake(ts->irq) == 0;
+ else
+ ts->wake_irq_enabled = true;
+ } else
+ ts->wake_irq_enabled = false;
return 0;
}
@@ -578,7 +585,8 @@ static int tsc200x_resume(struct device *dev)
guard(mutex)(&ts->mutex);
if (ts->wake_irq_enabled) {
- disable_irq_wake(ts->irq);
+ if (ts->bustype == BUS_SPI)
+ disable_irq_wake(ts->irq);
ts->wake_irq_enabled = false;
}
--
2.43.0
next prev parent reply other threads:[~2026-03-09 11:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-09 11:00 [PATCH 0/2] Input: tsc200x: Improve wakeup source handling phucduc.bui
2026-03-09 11:00 ` [PATCH 1/2] dt-bindings: input: touchscreen: ti,tsc2005: Add wakeup-source phucduc.bui
2026-03-13 23:23 ` Rob Herring
2026-03-16 2:41 ` [PATCH 1/2] dt-bindings: input: touchscreen: ti,tsc2005: Add phucduc.bui
2026-03-09 11:00 ` phucduc.bui [this message]
2026-03-11 0:21 ` [PATCH 2/2] Input: Touchscreen: tsc200x - delegate wakeup IRQ management to I2C core Dmitry Torokhov
2026-03-11 3:17 ` [PATCH 2/2] Input: Touchscreen: tsc200x - delegate wakeup IRQ phucduc.bui
2026-03-16 2:44 ` phucduc.bui
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=20260309110045.108209-3-phucduc.bui@gmail.com \
--to=phucduc.bui@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marex@denx.de \
--cc=mingo@kernel.org \
--cc=mwelling@ieee.org \
--cc=robh@kernel.org \
--cc=tglx@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox