* [PATCH 0/2] Input: tsc200x: Improve wakeup source handling
@ 2026-03-09 11:00 phucduc.bui
2026-03-09 11:00 ` [PATCH 1/2] dt-bindings: input: touchscreen: ti,tsc2005: Add wakeup-source phucduc.bui
2026-03-09 11:00 ` [PATCH 2/2] Input: Touchscreen: tsc200x - delegate wakeup IRQ management to I2C core phucduc.bui
0 siblings, 2 replies; 8+ messages in thread
From: phucduc.bui @ 2026-03-09 11:00 UTC (permalink / raw)
To: Dmitry Torokhov, Rob Herring
Cc: Krzysztof Kozlowski, Conor Dooley, Ingo Molnar, Thomas Gleixner,
Marek Vasut, Michael Welling, linux-input, devicetree,
linux-kernel, phucduc.bui
From: bui duc phuc <phucduc.bui@gmail.com>
The tsc200x driver already uses device_init_wakeup() to read the
"wakeup-source" property from the Device Tree. However, this property
is currently not documented in the DT binding schema.
In addition, the I2C core already handles wakeup initialization and
IRQ wake management automatically when the "wakeup-source" property
is present. Therefore, the manual wakeup IRQ handling currently done
in the driver is redundant for I2C-based devices (TSC2004).
This series makes the following changes:
1. Document the "wakeup-source" property in the DT bindings.
2. Delegate wakeup IRQ management to the I2C core when running on
BUS_I2C, while keeping manual management for BUS_SPI (TSC2005)
to ensure correct behavior across both interfaces.
Note:
These changes are based on code inspection and the documented behavior
of the I2C core. They have not been tested on physical hardware yet.
bui duc phuc (2):
dt-bindings: input: touchscreen: ti,tsc2005: Add wakeup-source
Input: Touchscreen: tsc200x - delegate wakeup IRQ management to I2C
core
.../bindings/input/touchscreen/ti,tsc2005.yaml | 7 +++++++
drivers/input/touchscreen/tsc200x-core.c | 18 +++++++++++++-----
2 files changed, 20 insertions(+), 5 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH 1/2] dt-bindings: input: touchscreen: ti,tsc2005: Add wakeup-source 2026-03-09 11:00 [PATCH 0/2] Input: tsc200x: Improve wakeup source handling phucduc.bui @ 2026-03-09 11:00 ` phucduc.bui 2026-03-13 23:23 ` Rob Herring 2026-03-09 11:00 ` [PATCH 2/2] Input: Touchscreen: tsc200x - delegate wakeup IRQ management to I2C core phucduc.bui 1 sibling, 1 reply; 8+ messages in thread From: phucduc.bui @ 2026-03-09 11:00 UTC (permalink / raw) To: Dmitry Torokhov, Rob Herring Cc: Krzysztof Kozlowski, Conor Dooley, Ingo Molnar, Thomas Gleixner, Marek Vasut, Michael Welling, linux-input, devicetree, linux-kernel, phucduc.bui From: bui duc phuc <phucduc.bui@gmail.com> The tsc200x driver uses the "wakeup-source" device tree property to determine whether the device should be configured as a system wakeup source. In the driver, this property is read with: device_init_wakeup(dev, device_property_read_bool(dev, "wakeup-source")); Document this property in the binding to make it visible to DT schema validation tools and to clarify its usage in device tree descriptions. Signed-off-by: bui duc phuc <phucduc.bui@gmail.com> --- .../devicetree/bindings/input/touchscreen/ti,tsc2005.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/devicetree/bindings/input/touchscreen/ti,tsc2005.yaml b/Documentation/devicetree/bindings/input/touchscreen/ti,tsc2005.yaml index 7187c390b2f5..c0aae044d7d4 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/ti,tsc2005.yaml +++ b/Documentation/devicetree/bindings/input/touchscreen/ti,tsc2005.yaml @@ -55,6 +55,9 @@ properties: touchscreen-size-x: true touchscreen-size-y: true + wakeup-source: + type: boolean + allOf: - $ref: touchscreen.yaml# - if: @@ -97,6 +100,8 @@ examples: ti,x-plate-ohms = <280>; ti,esd-recovery-timeout-ms = <8000>; + + wakeup-source; }; }; - | @@ -124,5 +129,7 @@ examples: ti,x-plate-ohms = <280>; ti,esd-recovery-timeout-ms = <8000>; + + wakeup-source; }; }; -- 2.43.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] dt-bindings: input: touchscreen: ti,tsc2005: Add wakeup-source 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 0 siblings, 1 reply; 8+ messages in thread From: Rob Herring @ 2026-03-13 23:23 UTC (permalink / raw) To: phucduc.bui Cc: Dmitry Torokhov, Krzysztof Kozlowski, Conor Dooley, Ingo Molnar, Thomas Gleixner, Marek Vasut, Michael Welling, linux-input, devicetree, linux-kernel On Mon, Mar 09, 2026 at 06:00:43PM +0700, phucduc.bui@gmail.com wrote: > From: bui duc phuc <phucduc.bui@gmail.com> > > The tsc200x driver uses the "wakeup-source" device tree property to > determine whether the device should be configured as a system wakeup > source. > > In the driver, this property is read with: > > device_init_wakeup(dev, > device_property_read_bool(dev, "wakeup-source")); Write your commit messages independent of the Linux driver. > > Document this property in the binding to make it visible to DT schema > validation tools and to clarify its usage in device tree descriptions. > > Signed-off-by: bui duc phuc <phucduc.bui@gmail.com> > --- > .../devicetree/bindings/input/touchscreen/ti,tsc2005.yaml | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/Documentation/devicetree/bindings/input/touchscreen/ti,tsc2005.yaml b/Documentation/devicetree/bindings/input/touchscreen/ti,tsc2005.yaml > index 7187c390b2f5..c0aae044d7d4 100644 > --- a/Documentation/devicetree/bindings/input/touchscreen/ti,tsc2005.yaml > +++ b/Documentation/devicetree/bindings/input/touchscreen/ti,tsc2005.yaml > @@ -55,6 +55,9 @@ properties: > touchscreen-size-x: true > touchscreen-size-y: true > > + wakeup-source: > + type: boolean > + > allOf: > - $ref: touchscreen.yaml# > - if: > @@ -97,6 +100,8 @@ examples: > > ti,x-plate-ohms = <280>; > ti,esd-recovery-timeout-ms = <8000>; > + > + wakeup-source; > }; > }; > - | > @@ -124,5 +129,7 @@ examples: > > ti,x-plate-ohms = <280>; > ti,esd-recovery-timeout-ms = <8000>; > + > + wakeup-source; > }; > }; > -- > 2.43.0 > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] dt-bindings: input: touchscreen: ti,tsc2005: Add 2026-03-13 23:23 ` Rob Herring @ 2026-03-16 2:41 ` phucduc.bui 0 siblings, 0 replies; 8+ messages in thread From: phucduc.bui @ 2026-03-16 2:41 UTC (permalink / raw) To: robh Cc: conor+dt, devicetree, dmitry.torokhov, krzk+dt, linux-input, linux-kernel, marex, mingo, mwelling, phucduc.bui, tglx Hi Rob, > Write your commit messages independent of the Linux driver. Thanks for the feedback. I will rewrite the commit message to focus on the hardware description and formalizing the binding, and remove references to the Linux driver implementation. I will send a v2 shortly with this change. Best regards, Phuc ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/2] Input: Touchscreen: tsc200x - delegate wakeup IRQ management to I2C core 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-09 11:00 ` phucduc.bui 2026-03-11 0:21 ` Dmitry Torokhov 1 sibling, 1 reply; 8+ messages in thread From: phucduc.bui @ 2026-03-09 11:00 UTC (permalink / raw) To: Dmitry Torokhov, Rob Herring Cc: Krzysztof Kozlowski, Conor Dooley, Ingo Molnar, Thomas Gleixner, Marek Vasut, Michael Welling, linux-input, devicetree, linux-kernel, phucduc.bui 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 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] Input: Touchscreen: tsc200x - delegate wakeup IRQ management to I2C core 2026-03-09 11:00 ` [PATCH 2/2] Input: Touchscreen: tsc200x - delegate wakeup IRQ management to I2C core phucduc.bui @ 2026-03-11 0:21 ` 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 0 siblings, 2 replies; 8+ messages in thread From: Dmitry Torokhov @ 2026-03-11 0:21 UTC (permalink / raw) To: phucduc.bui Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Ingo Molnar, Thomas Gleixner, Marek Vasut, Michael Welling, linux-input, devicetree, linux-kernel On Mon, Mar 09, 2026 at 06:00:44PM +0700, phucduc.bui@gmail.com wrote: > 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; Sorry, but this just makes it all worse. There is no downside from letting the driver to control wakeup if it wants to, so I'd rather leave it as it was, at least for now. Thanks. -- Dmitry ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/2] Input: Touchscreen: tsc200x - delegate wakeup IRQ 2026-03-11 0:21 ` Dmitry Torokhov @ 2026-03-11 3:17 ` phucduc.bui 2026-03-16 2:44 ` phucduc.bui 1 sibling, 0 replies; 8+ messages in thread From: phucduc.bui @ 2026-03-11 3:17 UTC (permalink / raw) To: dmitry.torokhov Cc: conor+dt, devicetree, krzk+dt, linux-input, linux-kernel, marex, mingo, mwelling, phucduc.bui, robh, tglx Hi Dmitry, > Sorry, but this just makes it all worse. There is no downside from > letting the driver to control wakeup if it wants to, so I'd rather leave > it as it was, at least for now. Thanks you for your reply I was thinking that the code might be simplified by removing ts->wake_irq_enabled. In resume(), we could just check device_may_wakeup(dev) before calling disable_irq_wake(ts->irq). From what I can see, wake_irq_enabled is only used there, so it seems redundant. I don't have the hardware to test this right now, so I didn't try the change myself. Do you think it would make sense to remove this field? Best regards, Phuc ^ permalink raw reply [flat|nested] 8+ messages in thread
* (no subject) 2026-03-11 0:21 ` 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 1 sibling, 0 replies; 8+ messages in thread From: phucduc.bui @ 2026-03-16 2:44 UTC (permalink / raw) To: dmitry.torokhov Cc: conor+dt, devicetree, krzk+dt, linux-input, linux-kernel, marex, mingo, mwelling, phucduc.bui, robh, tglx Subject: Re: [PATCH 2/2] Input: Touchscreen: tsc200x - delegate wakeup IRQ management to I2C core Hi Dmitry, Thanks for the feedback. I will drop this patch and keep the previous behavior. I'll send a v2 shortly with only the commit message improvements for the first patch. Thanks for the review. Best regards, Phuc ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-03-16 2:44 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 ` [PATCH 2/2] Input: Touchscreen: tsc200x - delegate wakeup IRQ management to I2C core phucduc.bui 2026-03-11 0:21 ` 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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox