Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=82.195.75.108 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796263486; b=b9KtfOIDhGOelDdUQosBKEKp0geejw24asQKrbygG0Oc/Z2oJwv4RFkk7OplTcns26XA UVHsOAn0JIpLGavCVKn0ALI/jvCS1v1Thj4fzX7tSE4kgQJkLAQPv3WcpLsEOECOx5Nmy lg6TAb/RKA8vNawn4FrlgTvJkZQjISXO3YxiO2FdmZwKicfUiTBmYK4a52+Q+J8Zbhog8 cvxZpCQ+/BDhBZKcnCBV92/UCOdfREqsYwK6/Rx3FXMz0Hp2sFGY8rjiMjbjV/+6x7ZP8 9ef2NCtV6LR7hr0nu7Lj18uO5S2AqOFHG8GF1DOW7ArWAQUDGhAUF78zbKAcD2vVlvQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796263486; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Debian-User; bh=HXIYnWK8W3aDC7fLaYuZLj91ng3zB6Jsg0k4Swe1qC0=; b=17PeFRxzo9G6K2z5V5ybAgXBv9RxxRMvfJmpFNMmS7EfMuM81hZrNCY3e5yLQi4nXMg9 0GxfyBp3ud3QeAGtg+rl77ikypDd+/qFGW9lTnkUsnPP/nkk2JlB4x0PtKuQUeNHISJC/ rH1S4+CAD9jwNv6y6HZ5ciqrF3cxSDoPhAnn7mNH3EqCNwx2p3otQz8dyEsAoy2e0d9Pr g9OTh4c91aQ3KjjF6kDmMNTgfuSsn97pPq7J+c1g8mpx/PrANXQQLCGLh0SxIEFmtuMYF 7Tu7paKap5nEowSR0uAx/HYL9bNks8gsNb7bDv0PIOm5uyNj0GCttIIh6FnRo7HItHg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=debian.org; spf=pass smtp.mailfrom=debian.org; dkim=pass header.d=debian.org header.i=@debian.org header.a=rsa-sha256 header.s=smtpauto.stravinsky header.b=a9iOmoxj; arc=none smtp.remote-ip=82.195.75.108 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE56B606A683; Thu, 3 Dec 2026 02:04:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org AE56B606A683 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.a=rsa-sha256 header.s=smtpauto.stravinsky header.b=a9iOmoxj DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Reply-To: Content-Type:Content-ID:Content-Description; bh=HXIYnWK8W3aDC7fLaYuZLj91ng3zB6Jsg0k4Swe1qC0=; b=a9iOmoxj5LAKpAyc9dxMjo7DvT gEp4MTOcqN579N4epFF9cbT/88IjzroG/JHTbS/1bx0IeXr0akeiwFHwy9qGzYzbQoFLQ9qIOcoPc Lcc4utyBpQ3gO1hUaOeFCG9oJRn/H41Evkjx5hbpstEffn7FtOuAgDdsTGGbtv1ghx8FnJhlnyIdb cQF62n7rfXWX7IDnjBA0Tb713dG0IKCeoPkJ2o9nIOjUGT50S6v1sPDhAHL2015s/I8S/6rCV90O5 eDfqfb6QmyfLwwiPkhRlRZ/+cOnAuUGz8LjDXyM9lG6HoOF4TT1cTcKUj6eJKIcbAnhojYiu8BziV x61quOCA==; Received: from authenticated-user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1xYwBc-001xKM-2L; Thu, 03 Dec 2026 02:04:41 +0000 From: Emfox Zhou To: Even Xu , Xinpeng Sun , Jiri Kosina , Benjamin Tissoires 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 Message-ID: <20261203020433.2631656-1-emfox@debian.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Debian-User: emfox 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 --- .../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,