mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Golle <daniel@makrotopia.org>
To: "Dmitry Torokhov" <dmitry.torokhov@gmail.com>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Daniel Golle" <daniel@makrotopia.org>,
	"Hendrik Noack" <hendrik-noack@gmx.de>,
	"Arnd Bergmann" <arnd@arndb.de>,
	"Ferass El Hafidi" <funderscore@postmarketos.org>,
	"Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
	"Oleh Kuzhylnyi" <kuzhylol@gmail.com>,
	linux-input@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH v2 5/5] Input: hynitron-cst816x: power sequence with the panel
Date: Fri, 2 Oct 2026 13:48:25 +0100	[thread overview]
Message-ID: <67e9a67e17a977053eaacef203416473f4c63968.1790944534.git.daniel@makrotopia.org> (raw)
In-Reply-To: <cover.1790944534.git.daniel@makrotopia.org>

Boards which mount the controller on the panel feed it from the
panel's rail, where a reset and the first interrupts are only
meaningful once the panel is powered. Register as a DRM panel follower
when the device tree points at a panel, so that the reset stays
asserted and the interrupt masked until the panel is prepared, and a
pressed key is released before the panel goes down again.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
v2: new patch

 drivers/input/touchscreen/Kconfig            |  2 +
 drivers/input/touchscreen/hynitron-cst816x.c | 60 ++++++++++++++++++--
 2 files changed, 57 insertions(+), 5 deletions(-)

diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 9b9ae8ac3f7fd..0beb499e24f20 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -478,6 +478,8 @@ config TOUCHSCREEN_HYNITRON_CSTXXX
 config TOUCHSCREEN_HYNITRON_CST816X
 	tristate "Hynitron CST816x touchscreen"
 	depends on I2C
+	# We call into panel code, so if DRM=m, this can't be 'y'
+	depends on DRM || !DRM
 	help
 	  Say Y here if you have a touchscreen using a Hynitron
 	  CST816x series touchscreen controller.
diff --git a/drivers/input/touchscreen/hynitron-cst816x.c b/drivers/input/touchscreen/hynitron-cst816x.c
index f17c2b03396a1..2e786f617067f 100644
--- a/drivers/input/touchscreen/hynitron-cst816x.c
+++ b/drivers/input/touchscreen/hynitron-cst816x.c
@@ -18,6 +18,8 @@
 #include <linux/spinlock.h>
 #include <linux/timer.h>
 
+#include <drm/drm_panel.h>
+
 #define CST816X_RD_REG		0x01
 #define CST816X_NUM_KEYS	5
 #define CST816X_GEST_HOLD_MS	40
@@ -39,6 +41,7 @@ struct cst816x_priv {
 	/* lock keeps the timeout out of the middle of a report */
 	spinlock_t lock;
 	struct touchscreen_properties prop;
+	struct drm_panel_follower follower;
 };
 
 static int cst816x_parse_keycodes(struct device *dev, struct cst816x_priv *priv)
@@ -256,6 +259,44 @@ static void cst816x_timer_stop(void *data)
 	timer_delete_sync(&priv->release_timer);
 }
 
+static int cst816x_panel_prepared(struct drm_panel_follower *follower)
+{
+	struct cst816x_priv *priv = container_of(follower, struct cst816x_priv,
+						 follower);
+
+	if (priv->reset)
+		cst816x_reset(priv);
+
+	enable_irq(priv->client->irq);
+
+	return 0;
+}
+
+static int cst816x_panel_unpreparing(struct drm_panel_follower *follower)
+{
+	struct cst816x_priv *priv = container_of(follower, struct cst816x_priv,
+						 follower);
+	unsigned long flags;
+
+	disable_irq(priv->client->irq);
+	timer_delete_sync(&priv->release_timer);
+
+	spin_lock_irqsave(&priv->lock, flags);
+
+	cst816x_release_keys(priv);
+	input_report_key(priv->input, BTN_TOUCH, 0);
+	input_sync(priv->input);
+
+	spin_unlock_irqrestore(&priv->lock, flags);
+
+	return 0;
+}
+
+static const struct drm_panel_follower_funcs cst816x_panel_follower_funcs = {
+	.panel_prepared = cst816x_panel_prepared,
+	.panel_unpreparing = cst816x_panel_unpreparing,
+};
+
 static int cst816x_probe(struct i2c_client *client)
 {
 	struct device *dev = &client->dev;
@@ -275,9 +316,6 @@ static int cst816x_probe(struct i2c_client *client)
 		return dev_err_probe(dev, PTR_ERR(priv->reset),
 				     "gpio reset request failed\n");
 
-	if (priv->reset)
-		cst816x_reset(priv);
-
 	error = cst816x_parse_keycodes(dev, priv);
 	if (error)
 		dev_warn(dev, "no gestures found in dt\n");
@@ -290,12 +328,24 @@ static int cst816x_probe(struct i2c_client *client)
 	if (error)
 		return error;
 
-	error = devm_request_threaded_irq(dev, client->irq,
-					  NULL, cst816x_irq_cb, IRQF_ONESHOT,
+	error = devm_request_threaded_irq(dev, client->irq, NULL,
+					  cst816x_irq_cb,
+					  IRQF_ONESHOT | IRQF_NO_AUTOEN,
 					  dev_driver_string(dev), priv);
 	if (error)
 		return dev_err_probe(dev, error, "irq request failed\n");
 
+	if (drm_is_panel_follower(dev)) {
+		priv->follower.funcs = &cst816x_panel_follower_funcs;
+
+		return devm_drm_panel_add_follower(dev, &priv->follower);
+	}
+
+	if (priv->reset)
+		cst816x_reset(priv);
+
+	enable_irq(client->irq);
+
 	return 0;
 }
 
-- 
2.55.0

      parent reply	other threads:[~2026-10-02 12:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-02 12:47 [PATCH v2 0/5] Input: hynitron-cst816x: axes, gesture keys and panel power Daniel Golle
2026-10-02 12:47 ` [PATCH v2 1/5] dt-bindings: input: touchscreen: hynitron,cst816x: axes and panel Daniel Golle
2026-10-04  7:24   ` Krzysztof Kozlowski
2026-10-04  7:29     ` Daniel Golle
2026-10-04  7:33       ` Krzysztof Kozlowski
2026-10-02 12:47 ` [PATCH v2 2/5] Input: hynitron-cst816x: respect touchscreen DT properties Daniel Golle
2026-10-04 20:30   ` Oleh Kuzhylnyi
2026-10-02 12:47 ` [PATCH v2 3/5] Input: hynitron-cst816x: release gesture keys Daniel Golle
2026-10-04 21:36   ` Oleh Kuzhylnyi
     [not found]   ` <XXX-PASTE-MESSAGE-ID-OF-OLEHS-MAIL>
2026-10-05 17:07     ` Daniel Golle
2026-10-02 12:48 ` [PATCH v2 4/5] Input: hynitron-cst816x: time out gesture key release Daniel Golle
2026-10-02 12:48 ` Daniel Golle [this message]

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=67e9a67e17a977053eaacef203416473f4c63968.1790944534.git.daniel@makrotopia.org \
    --to=daniel@makrotopia.org \
    --cc=arnd@arndb.de \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=funderscore@postmarketos.org \
    --cc=hendrik-noack@gmx.de \
    --cc=krzk+dt@kernel.org \
    --cc=kuzhylol@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=u.kleine-koenig@baylibre.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®