Linux Input/HID development
 help / color / mirror / Atom feed
From: Emfox Zhou <emfox@debian.org>
To: Even Xu <even.xu@intel.com>, Xinpeng Sun <xinpeng.sun@intel.com>,
	Jiri Kosina <jikos@kernel.org>,
	Benjamin Tissoires <bentiss@kernel.org>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v11 1/6] HID: intel-thc-hid: intel-thc: expose the port operations IPTS needs
Date: Thu,  3 Dec 2026 10:04:10 +0800	[thread overview]
Message-ID: <20261203020433.2631656-1-emfox@debian.org> (raw)
In-Reply-To: <cover.1796215044.git.emfox@debian.org>

Add thc_port_supported() and thc_port_reset(), so a backend can read the
port capability bit and drive the touch controller reset pin without
writing THC_M_PRT_CONTROL itself.

Signed-off-by: Emfox Zhou <emfox@debian.org>
---
 .../intel-thc-hid/intel-thc/intel-thc-dev.c   | 58 +++++++++++++++++++
 .../intel-thc-hid/intel-thc/intel-thc-dev.h   |  2 +
 2 files changed, 60 insertions(+)

diff --git a/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c b/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c
index 03d3b60b3..c7d495915 100644
--- a/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c
+++ b/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c
@@ -1111,6 +1111,64 @@ int thc_port_select(struct thc_device *dev, enum thc_port_type port_type)
 }
 EXPORT_SYMBOL_NS_GPL(thc_port_select, "INTEL_THC");
 
+/**
+ * thc_port_supported - Tell whether the port has a touch device interface
+ *
+ * @dev: the pointer of THC private device context
+ * @supported: set to whether the port can drive a device at all
+ *
+ * Reads the capability bit of the port control register. A port that is not
+ * supported answers nothing on the bus, so this is worth asking before the
+ * port is brought up.
+ *
+ * Return: 0 on success, other error codes on failed
+ */
+int thc_port_supported(struct thc_device *dev, bool *supported)
+{
+	u32 ctrl;
+	int ret;
+
+	ret = regmap_read(dev->thc_regmap, THC_M_PRT_CONTROL_OFFSET, &ctrl);
+	if (ret)
+		return ret;
+
+	*supported = ctrl & THC_M_PRT_CONTROL_PORT_SUPPORTED;
+
+	return 0;
+}
+EXPORT_SYMBOL_NS_GPL(thc_port_supported, "INTEL_THC");
+
+/**
+ * thc_port_reset - Drive the reset line of the touch IC
+ *
+ * @dev: the pointer of THC private device context
+ * @hold: keep the touch IC in reset instead of releasing it
+ *
+ * The reset bit of the port control register drives the reset pin of the
+ * touch IC: zero asserts the reset, one releases it. Firmware may leave
+ * the pin released, so a start asserts it and then lets it go rather than
+ * assume it was held.
+ *
+ * Return: 0 on success, other error codes on failed
+ */
+int thc_port_reset(struct thc_device *dev, bool hold)
+{
+	int ret;
+
+	/* DEVRST: 0 asserts the reset, 1 releases it. */
+	ret = regmap_write_bits(dev->thc_regmap, THC_M_PRT_CONTROL_OFFSET,
+				THC_M_PRT_CONTROL_DEVRST, 0);
+	if (ret || hold)
+		return ret;
+
+	usleep_range(1000, 2000);
+
+	return regmap_write_bits(dev->thc_regmap, THC_M_PRT_CONTROL_OFFSET,
+				 THC_M_PRT_CONTROL_DEVRST,
+				 THC_M_PRT_CONTROL_DEVRST);
+}
+EXPORT_SYMBOL_NS_GPL(thc_port_reset, "INTEL_THC");
+
 /* 125 MHz / (8 * N), with the low frequency bit set. */
 #define THC_SPI_FREQUENCY_2M2	2232143
 #define THC_SPI_FREQUENCY_2M6	2604167
diff --git a/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.h b/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.h
index be8a9605d..c34611e78 100644
--- a/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.h
+++ b/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.h
@@ -135,6 +135,8 @@ void thc_ltr_unconfig(struct thc_device *dev);
 u32 thc_int_cause_read(struct thc_device *dev);
 int thc_interrupt_handler(struct thc_device *dev);
 int thc_port_select(struct thc_device *dev, enum thc_port_type port_type);
+int thc_port_reset(struct thc_device *dev, bool hold);
+int thc_port_supported(struct thc_device *dev, bool *supported);
 int thc_spi_read_config(struct thc_device *dev, u32 spi_freq_val,
 			u32 io_mode, u32 opcode, u32 spi_rd_mps);
 int thc_spi_write_config(struct thc_device *dev, u32 spi_freq_val,

  reply	other threads:[~2026-12-03  2:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  2:04 [PATCH v11 0/6] HID: intel-thc-hid: intel-ipts: support THC IPTS ports Emfox Zhou
2026-12-03  2:04 ` Emfox Zhou [this message]
2026-12-03  2:11   ` [PATCH v11 1/6] HID: intel-thc-hid: intel-thc: expose the port operations IPTS needs sashiko-bot
2026-12-03  2:04 ` [PATCH v11 2/6] HID: intel-thc-hid: intel-ipts: bring up the port Emfox Zhou
2026-12-03  2:15   ` sashiko-bot
2026-12-03  2:04 ` [PATCH v11 3/6] HID: intel-thc-hid: intel-ipts: receive reports Emfox Zhou
2026-12-03  2:26   ` sashiko-bot
2026-12-03  2:04 ` [PATCH v11 4/6] HID: intel-thc-hid: intel-ipts: add the HID device Emfox Zhou
2026-12-03  2:04 ` [PATCH v11 5/6] HID: intel-thc-hid: intel-ipts: handle system sleep Emfox Zhou
2026-12-03  2:04 ` [PATCH v11 6/6] HID: intel-thc-hid: intel-ipts: document the IPTS mode Emfox Zhou

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=20261203020433.2631656-1-emfox@debian.org \
    --to=emfox@debian.org \
    --cc=bentiss@kernel.org \
    --cc=even.xu@intel.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xinpeng.sun@intel.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