linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4] Input: tsc2007 - enable cansleep pendown GPIO
@ 2023-03-30 19:10 Benjamin Bara
  2023-04-02  5:51 ` Dmitry Torokhov
  0 siblings, 1 reply; 2+ messages in thread
From: Benjamin Bara @ 2023-03-30 19:10 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: hns, richard.leitner, christophe.jaillet, linux-input,
	linux-kernel, Benjamin Bara, Richard Leitner

From: Benjamin Bara <benjamin.bara@skidata.com>

When a hard IRQ is triggered, the soft IRQ, which decides if an actual
pen down happened, should always be triggered. This enables the usage of
"can_sleep" GPIO chips as "pen down" GPIO, as the value is not read
during the hard IRQ anymore. This might be the case if the GPIO chip is
an expander behind i2c.

Signed-off-by: Benjamin Bara <benjamin.bara@skidata.com>
Signed-off-by: Richard Leitner <richard.leitner@skidata.com>
---
Hi!

I found a different approach to my problem:
If the primary IRQ handler is set to NULL, the default primary IRQ
handler simply triggers a soft IRQ handler wake up. As the hard IRQ is
only triggered when a pen down is detected, the gpiod_get_value() inside
tsc2007_is_pen_down() always returns true and therefore can be
neglected.

v3: https://lore.kernel.org/lkml/20230328-tsc2007-sleep-v3-1-5941e8dc0411@skidata.com/

----
v4:
- don't read value in hard IRQ

v3:
- extend commit message

v2:
- fix style mentioned by Christophe
---
 drivers/input/touchscreen/tsc2007_core.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/drivers/input/touchscreen/tsc2007_core.c b/drivers/input/touchscreen/tsc2007_core.c
index 3c793fb70a0e..fa4a71e3ad52 100644
--- a/drivers/input/touchscreen/tsc2007_core.c
+++ b/drivers/input/touchscreen/tsc2007_core.c
@@ -172,19 +172,6 @@ static irqreturn_t tsc2007_soft_irq(int irq, void *handle)
 	return IRQ_HANDLED;
 }
 
-static irqreturn_t tsc2007_hard_irq(int irq, void *handle)
-{
-	struct tsc2007 *ts = handle;
-
-	if (tsc2007_is_pen_down(ts))
-		return IRQ_WAKE_THREAD;
-
-	if (ts->clear_penirq)
-		ts->clear_penirq();
-
-	return IRQ_HANDLED;
-}
-
 static void tsc2007_stop(struct tsc2007 *ts)
 {
 	ts->stopped = true;
@@ -376,7 +363,7 @@ static int tsc2007_probe(struct i2c_client *client)
 	}
 
 	err = devm_request_threaded_irq(&client->dev, ts->irq,
-					tsc2007_hard_irq, tsc2007_soft_irq,
+					NULL, tsc2007_soft_irq,
 					IRQF_ONESHOT,
 					client->dev.driver->name, ts);
 	if (err) {

---
base-commit: 197b6b60ae7bc51dd0814953c562833143b292aa
change-id: 20230328-tsc2007-sleep-f65953ae32d0

Best regards,
-- 
Benjamin Bara <benjamin.bara@skidata.com>


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v4] Input: tsc2007 - enable cansleep pendown GPIO
  2023-03-30 19:10 [PATCH v4] Input: tsc2007 - enable cansleep pendown GPIO Benjamin Bara
@ 2023-04-02  5:51 ` Dmitry Torokhov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2023-04-02  5:51 UTC (permalink / raw)
  To: Benjamin Bara
  Cc: hns, richard.leitner, christophe.jaillet, linux-input,
	linux-kernel, Benjamin Bara

Hi Benjamin,

On Thu, Mar 30, 2023 at 09:10:37PM +0200, Benjamin Bara wrote:
> From: Benjamin Bara <benjamin.bara@skidata.com>
> 
> When a hard IRQ is triggered, the soft IRQ, which decides if an actual
> pen down happened, should always be triggered. This enables the usage of
> "can_sleep" GPIO chips as "pen down" GPIO, as the value is not read
> during the hard IRQ anymore. This might be the case if the GPIO chip is
> an expander behind i2c.
> 
> Signed-off-by: Benjamin Bara <benjamin.bara@skidata.com>
> Signed-off-by: Richard Leitner <richard.leitner@skidata.com>
> ---
> Hi!
> 
> I found a different approach to my problem:
> If the primary IRQ handler is set to NULL, the default primary IRQ
> handler simply triggers a soft IRQ handler wake up. As the hard IRQ is
> only triggered when a pen down is detected, the gpiod_get_value() inside
> tsc2007_is_pen_down() always returns true and therefore can be
> neglected.

Don't you need to switch to gpio_get_valued_cansleep() in
tsc2007_is_pen_down() to actually allow sleeping gpios?

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-04-02  5:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-30 19:10 [PATCH v4] Input: tsc2007 - enable cansleep pendown GPIO Benjamin Bara
2023-04-02  5:51 ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).