mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Xu, Even" <even.xu@intel.com>
To: Emfox Zhou <emfox@debian.org>,
	"Sun, Xinpeng" <xinpeng.sun@intel.com>,
	Jiri Kosina <jikos@kernel.org>,
	Benjamin Tissoires <bentiss@kernel.org>
Cc: "linux-input@vger.kernel.org" <linux-input@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH v10 2/6] HID: intel-thc-hid: intel-ipts: bring up the port
Date: Wed, 2 Dec 2026 06:56:22 +0000	[thread overview]
Message-ID: <SJ0PR11MB7704830BF8B5AD21D09EB78DF44C2@SJ0PR11MB7704.namprd11.prod.outlook.com> (raw)
In-Reply-To: <011c212a1187be630f0106a059adc16ba7540fec.1795794049.git.emfox@debian.org>



> -----Original Message-----
> From: Emfox Zhou <emfox@debian.org>
> Sent: Friday, November 27, 2026 11:52 PM
> To: Xu, Even <even.xu@intel.com>; Sun, Xinpeng <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 v10 2/6] HID: intel-thc-hid: intel-ipts: bring up the port
> 
> Ports on Tiger Lake, Lakefield, Alder Lake and Raptor Lake can run in IPTS mode:
> instead of HIDSPI the port drives the touch controller over plain SPI, and the
> controller answers with a 64 byte configuration block at address zero that carries
> the vendor and product IDs, the buffer sizes and the SPI timing it expects.
> 
> Add a port driver that does that much: select the SPI port, release the controller
> from reset, read the configuration block over the existing PIO path, apply the
> timing the controller asked for and enable the touch engine. Removal puts it back
> into reset.
> 
> Three things are not obvious from the register names:
> 
>   - The bulk data window is at 0x1000, not at zero, and has to be set
>     before the DMA engines run: they write there, and left unset they
>     write into the configuration block, where the controller drops the
>     frames without reporting an error.
> 
>   - Quiescing gates the whole data path, not only the interrupt. The
>     port stays quiesced while the block is read and the timing applied,
>     and is released only once that is done.
> 
>   - The edge detect bit belongs to the interrupt setup, but is set
>     here: the first configuration read is unreliable without it.
> 
> How far the bring-up got is recorded as one state rather than a flag per
> step: the teardown has to undo exactly what completed, and a start that fails half
> way leaves the port at the last step that did. The state moves forward only while
> the port starts and backward only while it stops, so the checks on both paths read
> as the question they answer.
> 
> Meteor Lake and newer IDs are deliberately absent: those ports are already
> claimed by the HIDSPI driver.
> 
> Signed-off-by: Emfox Zhou <emfox@debian.org>
> ---
>  drivers/hid/intel-thc-hid/Kconfig             |  13 ++
>  drivers/hid/intel-thc-hid/Makefile            |   4 +
>  drivers/hid/intel-thc-hid/intel-ipts/ipts.c   | 212 ++++++++++++++++++
>  drivers/hid/intel-thc-hid/intel-ipts/ipts.h   | 140 ++++++++++++
>  .../hid/intel-thc-hid/intel-ipts/pci-ipts.c   | 124 ++++++++++
>  5 files changed, 493 insertions(+)
>  create mode 100644 drivers/hid/intel-thc-hid/intel-ipts/ipts.c
>  create mode 100644 drivers/hid/intel-thc-hid/intel-ipts/ipts.h
>  create mode 100644 drivers/hid/intel-thc-hid/intel-ipts/pci-ipts.c
> 
> diff --git a/drivers/hid/intel-thc-hid/Kconfig b/drivers/hid/intel-thc-hid/Kconfig
> index 9d74e53b8..40e3ce198 100644
> --- a/drivers/hid/intel-thc-hid/Kconfig
> +++ b/drivers/hid/intel-thc-hid/Kconfig
> @@ -40,4 +40,17 @@ config INTEL_QUICKI2C
> 
>  	  Say Y/M here if you want to support Intel QuickI2C. If unsure, say N.
> 
> +config INTEL_IPTS
> +	tristate "Intel Touch Host Controller IPTS mode"
> +	depends on INTEL_THC_HID
> +	help
> +	  Support for THC ports in IPTS mode. Instead of HIDSPI these ports
> +	  drive the touch controller over plain SPI and carry its reports in a
> +	  private framing. This driver brings such a port up and reads the
> +	  controller's configuration block, which describes the report
> +	  framing.
> +
> +	  Say Y/M here if you have an Intel touch controller that runs in IPTS
> +	  mode. If unsure, say N.
> +
>  endmenu
> diff --git a/drivers/hid/intel-thc-hid/Makefile b/drivers/hid/intel-thc-hid/Makefile
> index f1182253b..049009592 100644
> --- a/drivers/hid/intel-thc-hid/Makefile
> +++ b/drivers/hid/intel-thc-hid/Makefile
> @@ -20,4 +20,8 @@ intel-quicki2c-objs += intel-quicki2c/pci-quicki2c.o  intel-
> quicki2c-objs += intel-quicki2c/quicki2c-hid.o  intel-quicki2c-objs += intel-
> quicki2c/quicki2c-protocol.o
> 
> +obj-$(CONFIG_INTEL_IPTS) += intel-ipts.o intel-ipts-objs +=
> +intel-ipts/pci-ipts.o intel-ipts-objs += intel-ipts/ipts.o
> +
>  ccflags-y += -I $(src)/intel-thc
> diff --git a/drivers/hid/intel-thc-hid/intel-ipts/ipts.c b/drivers/hid/intel-thc-
> hid/intel-ipts/ipts.c
> new file mode 100644
> index 000000000..c680b0926
> --- /dev/null
> +++ b/drivers/hid/intel-thc-hid/intel-ipts/ipts.c
> @@ -0,0 +1,212 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Transport for THC ports in IPTS mode: plain SPI with a private framing.
> + */
> +
> +#include <linux/delay.h>
> +#include <linux/string.h>
> +
> +#include "intel-thc-hw.h"
> +#include "ipts.h"
> +
> +/* Bulk transfers have no address phase, so the SPI opcode is zero. */
> +#define THC_IPTS_SPI_OPCODE		0
> +
> +/* Clock used until the controller has been read, the slowest known-good one.
> */
> +#define THC_IPTS_BOOT_SPI_HZ		7812500
> +
> +/* Time the controller needs after reset before it answers on the bus. */
> +#define THC_IPTS_BOOT_MS		100
> +
> +static int thc_ipts_read_cfg(struct thc_ipts *idev) {
> +	int ret, try;
> +
> +	for (try = 0; try < THC_IPTS_CFG_TRIES; try++) {
> +		u32 got = 0;
> +
> +		memset(&idev->cfg, 0, sizeof(idev->cfg));
> +		ret = thc_tic_pio_read(idev->thc, 0, THC_IPTS_CFG_SIZE, &got,
> +				       (u32 *)&idev->cfg);
> +		if (!ret && got == THC_IPTS_CFG_SIZE &&
> +		    le32_to_cpu(idev->cfg.device_id) == THC_IPTS_TIC_ID)
> +			return 0;
> +
> +		if (try + 1 < THC_IPTS_CFG_TRIES)
> +			msleep(THC_IPTS_CFG_RETRY_MS);
> +	}
> +
> +	dev_err(idev->dev,
> +		"controller did not answer, last id 0x%08x, error %d\n",
> +		le32_to_cpu(idev->cfg.device_id), ret ?: -EIO);
> +
> +	return ret ?: -EIO;
> +}
> +
> +static int thc_ipts_spi_set(struct thc_ipts *idev, u32 hz, u32 mode) {
> +	int ret;
> +
> +	/* No multi-packet transfers in this mode, so both sizes stay zero. */
> +	ret = thc_spi_read_config(idev->thc, hz, mode, THC_IPTS_SPI_OPCODE,
> 0);
> +	if (ret)
> +		return ret;
> +
> +	return thc_spi_write_config(idev->thc, hz, mode,
> THC_IPTS_SPI_OPCODE,
> +				     0, 0);
> +}
> +
> +/* The core takes the fastest gear that is not above the request. */
> +static void thc_ipts_spi_from_cfg(struct thc_ipts *idev, u32 *hz, u32
> +*mode) {
> +	u32 cfg = le32_to_cpu(idev->cfg.spi_cfg);
> +
> +	*hz = thc_spi_hz_from_div(THC_IPTS_SPI_CLKDIV(cfg),
> +				  cfg & THC_IPTS_SPI_CLKDIV8);
> +	if (!*hz) {
> +		dev_warn_once(idev->dev, "controller asks for divisor 0\n");
> +		*hz = THC_IPTS_SPI_MIN_HZ;
> +	}
> +
> +	/*
> +	 * THC_IPTS_SPI_MIN_HZ is the slowest gear the core has, so a lower
> +	 * request would be refused: run at the floor and keep the port.
> +	 */
> +	if (*hz < THC_IPTS_SPI_MIN_HZ) {
> +		dev_warn_once(idev->dev,
> +			      "controller asks for %u Hz, running at %u Hz\n",
> +			      *hz, THC_IPTS_SPI_MIN_HZ);
> +		*hz = THC_IPTS_SPI_MIN_HZ;
> +	}

THC already has above logic in thc_get_spi_freq_div_val() in intel-thc-dev.c.
So it's unnecessary to calculate frequency from div, just set frequency to THC, thc_get_spi_freq_div_val() will handle

> +
> +	if (cfg & THC_IPTS_SPI_QUAD)
> +		*mode = THC_QUAD_IO;
> +	else if (cfg & THC_IPTS_SPI_DUAL)
> +		*mode = THC_DUAL_IO;
> +	else
> +		*mode = THC_SINGLE_IO;
> +}
> +
> +static int thc_ipts_touch_set(struct thc_ipts *idev, bool enable) {
> +	u32 touch = le32_to_cpu(idev->cfg.touch_cfg);
> +
> +	touch &= ~(THC_IPTS_TOUCH_POWER_MASK |
> THC_IPTS_TOUCH_ENABLE |
> +		   THC_IPTS_TOUCH_HID_REPORT);
> +	touch |= THC_IPTS_TOUCH_POWER(enable ?
> THC_IPTS_TOUCH_POWER_ON : 0);
> +	if (enable)
> +		touch |= THC_IPTS_TOUCH_ENABLE |
> THC_IPTS_TOUCH_HID_REPORT;
> +
> +	return thc_tic_pio_write(idev->thc, THC_IPTS_CFG_TOUCH,
> sizeof(touch),
> +				 &touch);
> +}
> +
> +/**
> + * thc_ipts_port_start - bring one port up
> + * @idev: port to start
> + */
> +int thc_ipts_port_start(struct thc_ipts *idev) {
> +	u32 hz, mode;
> +	bool supported;
> +	int ret;
> +
> +	ret = thc_interrupt_quiesce(idev->thc, true);
> +	if (ret)
> +		return ret;
> +
> +	ret = thc_port_select(idev->thc, THC_PORT_TYPE_SPI);
> +	if (ret)
> +		return ret;
> +
> +	ret = thc_port_supported(idev->thc, &supported);
> +	if (ret)
> +		return ret;
> +	if (!supported)
> +		return -ENODEV;
> +
> +	/* Without this the engines write into the configuration block. */
> +	thc_spi_input_output_address_config(idev->thc, 0,
> THC_IPTS_BULK_ADDR,
> +					    THC_IPTS_BULK_ADDR);
> +
> +	/*
> +	 * Firmware may leave the receive engines armed with the PRD base of
> +	 * whatever it had mapped. Stop them before the controller starts
> +	 * pushing frames again, or those frames land in stale pages.
> +	 */
> +	thc_dma_unconfigure(idev->thc);
> +
> +	ret = thc_ipts_spi_set(idev, THC_IPTS_BOOT_SPI_HZ, THC_SINGLE_IO);
> +	if (ret)
> +		return ret;
> +
> +	/* The first configuration read is unreliable without edge detect. */
> +	thc_int_trigger_type_select(idev->thc, true);
> +
> +	/*
> +	 * Release the controller from reset; it answers only after this.
> +	 * The bit is the reset request and one means out of reset, so it has
> +	 * to be written whatever it reads back.
> +	 */
> +	ret = thc_port_reset_release(idev->thc);
> +	if (ret)
> +		return ret;

If this is thc_port_reset_release() function use case, I suggestion to combine thc_port_reset_release() and thc_port_reset_hold() to one function thc_port_reset(bool hold).
When hold is false, set THC_M_PRT_CONTROL_DEVRST and sleep then release THC_M_PRT_CONTROL_DEVRST; if hold is true, only set THC_M_PRT_CONTROL_DEVRST.

Because you cann't guarantee BIOS/UEFI will hold THC_M_PRT_CONTROL_DEVRST in pre-os stage.

> +
> +	/* Out of reset from here: a teardown has to put it back. */
> +	WRITE_ONCE(idev->state, THC_IPTS_RESET);
> +
> +	msleep(THC_IPTS_BOOT_MS);
> +
> +	ret = thc_ipts_read_cfg(idev);
> +	if (ret)
> +		return ret;
> +
> +	idev->vendor = le16_to_cpu(idev->cfg.vendor);
> +	idev->product = le16_to_cpu(idev->cfg.product);
> +	idev->max_rx = THC_IPTS_RX_BUF_SIZE(le32_to_cpu(idev-
> >cfg.buf_sizes));
> +	idev->max_tx = THC_IPTS_TX_BUF_SIZE(le32_to_cpu(idev-
> >cfg.buf_sizes));
> +	/* TX_BUF_SIZE() never goes below 64, so only the rx half can fail. */
> +	if (idev->max_rx <= THC_IPTS_RX_HDR_SIZE) {
> +		dev_err(idev->dev, "receive buffer of %zu bytes is too small\n",
> +			idev->max_rx);
> +		return -ENODEV;
> +	}
> +	thc_ipts_spi_from_cfg(idev, &hz, &mode);
> +	ret = thc_ipts_spi_set(idev, hz, mode);
> +	if (ret) {
> +		dev_warn(idev->dev,
> +			 "cannot follow the SPI timing, going slow\n");
> +		ret = thc_ipts_spi_set(idev, THC_IPTS_BOOT_SPI_HZ,
> +				       THC_SINGLE_IO);
> +		if (ret)
> +			return ret;
> +	} else {
> +		dev_dbg(idev->dev, "SPI clock asked for %u Hz\n", hz);
> +	}
> +
> +	ret = thc_interrupt_quiesce(idev->thc, false);
> +	if (ret)
> +		return ret;
> +
> +	ret = thc_ipts_touch_set(idev, true);
> +	if (ret)
> +		return ret;
> +	WRITE_ONCE(idev->state, THC_IPTS_CONFIG);
> +
> +	return 0;
> +}
> +
> +/**
> + * thc_ipts_port_stop - tear one port down
> + * @idev: port to stop
> + */
> +void thc_ipts_port_stop(struct thc_ipts *idev) {
> +	if (READ_ONCE(idev->state) >= THC_IPTS_CONFIG)
> +		thc_ipts_touch_set(idev, false);
> +
> +	/* Forced: the bit may read as clear and still need the command. */
> +	thc_port_reset_hold(idev->thc);
> +	thc_interrupt_quiesce(idev->thc, true);
> +	WRITE_ONCE(idev->state, THC_IPTS_DOWN); }
> diff --git a/drivers/hid/intel-thc-hid/intel-ipts/ipts.h b/drivers/hid/intel-thc-
> hid/intel-ipts/ipts.h
> new file mode 100644
> index 000000000..0f8bcb8dc
> --- /dev/null
> +++ b/drivers/hid/intel-thc-hid/intel-ipts/ipts.h
> @@ -0,0 +1,140 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef _THC_IPTS_H_
> +#define _THC_IPTS_H_
> +
> +#include <linux/bitfield.h>
> +#include <linux/bits.h>
> +#include <linux/build_bug.h>
> +#include <linux/device.h>
> +#include <linux/interrupt.h>
> +#include <linux/types.h>
> +
> +#include "intel-thc-dev.h"
> +
> +/* Configuration block the controller keeps at address zero. */
> +#define THC_IPTS_CFG_SIZE		64
> +#define THC_IPTS_CFG_TOUCH		0x0c
> +#define THC_IPTS_TIC_ID		0x43495424	/* "$TIC" */
> +
> +/* Bulk data window. The DMA engines have to be pointed here, not at zero. */
> +#define THC_IPTS_BULK_ADDR		0x1000
> +
> +#define PCI_DEVICE_ID_INTEL_THC_LKF_PORT1	0x98d0
> +#define PCI_DEVICE_ID_INTEL_THC_LKF_PORT2	0x98d1
> +#define PCI_DEVICE_ID_INTEL_THC_TGL_LP_PORT1	0xa0d0
> +#define PCI_DEVICE_ID_INTEL_THC_TGL_LP_PORT2	0xa0d1
> +#define PCI_DEVICE_ID_INTEL_THC_TGL_H_PORT1	0x43d0
> +#define PCI_DEVICE_ID_INTEL_THC_TGL_H_PORT2	0x43d1
> +#define PCI_DEVICE_ID_INTEL_THC_ADL_S_PORT1	0x7ad8
> +#define PCI_DEVICE_ID_INTEL_THC_ADL_S_PORT2	0x7ad9
> +#define PCI_DEVICE_ID_INTEL_THC_ADL_P_PORT1	0x51d0
> +#define PCI_DEVICE_ID_INTEL_THC_ADL_P_PORT2	0x51d1
> +#define PCI_DEVICE_ID_INTEL_THC_ADL_M_PORT1	0x54d0
> +#define PCI_DEVICE_ID_INTEL_THC_ADL_M_PORT2	0x54d1
> +#define PCI_DEVICE_ID_INTEL_THC_RPL_S_PORT1	0x7a58
> +#define PCI_DEVICE_ID_INTEL_THC_RPL_S_PORT2	0x7a59
> +
> +/* The block fills in while the controller starts, so $TIC is retried. */
> +#define THC_IPTS_CFG_TRIES		10
> +#define THC_IPTS_CFG_RETRY_MS		100
> +
> +#define THC_IPTS_CFG_KNOWN		40
> +
> +/* The block as far as this driver reads it, padded to its full size.
> +*/ struct thc_ipts_cfg {
> +	__le32	irq_cause;
> +	__le32	error;		/* protocol error flags, not used */
> +	__le32	buf_sizes;	/* Rx/Tx sizes, see *_BUF_SIZE() */
> +	__le32	touch_cfg;	/* touch engine control, writable */
> +	__le32	touch_state;	/* touch engine state, not used */
> +	__le32	device_id;	/* THC_IPTS_TIC_ID after a good read */
> +	__le32	spi_cfg;
> +	__le16	vendor;
> +	__le16	product;
> +	__le32	revision;
> +	__le32	fw_version;	/* changes on every reset, not a version */
> +	u8	rest[THC_IPTS_CFG_SIZE - THC_IPTS_CFG_KNOWN];
> +};
> +
> +static_assert(sizeof(struct thc_ipts_cfg) == THC_IPTS_CFG_SIZE);
> +
> +/* The core is handed the struct itself, so the offsets are part of the
> +deal. */ static_assert(offsetof(struct thc_ipts_cfg, buf_sizes) ==
> +0x08); static_assert(offsetof(struct thc_ipts_cfg, touch_cfg) == 0x0c);
> +static_assert(offsetof(struct thc_ipts_cfg, spi_cfg) == 0x18);
> +static_assert(offsetof(struct thc_ipts_cfg, vendor) == 0x1c);
> +static_assert(offsetof(struct thc_ipts_cfg, product) == 0x1e);
> +static_assert(offsetof(struct thc_ipts_cfg, revision) == 0x20);
> +static_assert(offsetof(struct thc_ipts_cfg, device_id) == 0x14);
> +
> +/* Buffer sizes are stored as (size / 64) - 1, Rx in bits 13:0, Tx in 23:14. */
> +#define THC_IPTS_DMA_UNIT		64
> +#define THC_IPTS_RX_BUF_SIZE(val)	\
> +	((size_t)(FIELD_GET(GENMASK(13, 0), (val)) + 1) * THC_IPTS_DMA_UNIT)
> +#define THC_IPTS_TX_BUF_SIZE(val)	\
> +	((size_t)(FIELD_GET(GENMASK(23, 14), (val)) + 1) *
> THC_IPTS_DMA_UNIT)
> +
> +#define THC_IPTS_TOUCH_ENABLE		BIT(0)
> +#define THC_IPTS_TOUCH_HID_REPORT	BIT(2)
> +#define THC_IPTS_TOUCH_POWER_ON	3
> +#define THC_IPTS_TOUCH_POWER_MASK	GENMASK(5, 3)
> +#define THC_IPTS_TOUCH_POWER(val)	\
> +	FIELD_PREP(THC_IPTS_TOUCH_POWER_MASK, (val))
> +
> +#define THC_IPTS_SPI_CLKDIV(val)	FIELD_GET(GENMASK(3, 1), (val))
> +#define THC_IPTS_SPI_CLKDIV8		BIT(4)
> +#define THC_IPTS_SPI_DUAL		BIT(6)
> +#define THC_IPTS_SPI_QUAD		BIT(7)
> +/* Slowest gear in the core's SPI table; anything under it is refused. */
> +#define THC_IPTS_SPI_MIN_HZ		2232143
> +
> +/* Code and length in front of the payload; the long one is inbound. */
> +#define THC_IPTS_RX_HDR_SIZE		64
> +#define THC_IPTS_TX_HDR_SIZE		8
> +
> +/**
> + * enum thc_ipts_state - how far the port has been brought up
> + * @THC_IPTS_DOWN: no controller, no buffers, no HID device
> + * @THC_IPTS_RESET: out of reset, configuration not read yet
> + * @THC_IPTS_CONFIG: configuration read, engines not configured
> + * @THC_IPTS_DMA: DMA engines configured and may be written to
> + * @THC_IPTS_UP: HID device registered
> + *
> + * The steps only move forward while the port starts and only backward
> +while
> + * it stops. A failure therefore leaves the port at the last step that
> + * completed, and the teardown knows how far to unwind.
> + */
> +enum thc_ipts_state {
> +	THC_IPTS_DOWN,
> +	THC_IPTS_RESET,
> +	THC_IPTS_CONFIG,
> +	THC_IPTS_DMA,
> +	THC_IPTS_UP,
> +};
> +
> +/**
> + * struct thc_ipts - state of one THC port in IPTS mode
> + * @dev: device used for resources and logging
> + * @thc: shared THC core context
> + * @cfg: configuration block last read from the controller
> + * @vendor: vendor ID the controller reports for its HID device
> + * @product: product ID the controller reports for its HID device
> + * @max_rx: largest frame the controller may send, in bytes
> + * @max_tx: largest frame the driver may send, in bytes
> + * @state: how far the port has been brought up, see enum
> +thc_ipts_state  */ struct thc_ipts {
> +	struct device		*dev;
> +	struct thc_device	*thc;
> +	struct thc_ipts_cfg	cfg;
> +	u16			vendor;
> +	u16			product;
> +	size_t			max_rx;
> +	size_t			max_tx;
> +	enum thc_ipts_state	state;
> +};
> +
> +int thc_ipts_port_start(struct thc_ipts *idev); void
> +thc_ipts_port_stop(struct thc_ipts *idev);
> +
> +#endif /* _THC_IPTS_H_ */
> diff --git a/drivers/hid/intel-thc-hid/intel-ipts/pci-ipts.c b/drivers/hid/intel-thc-
> hid/intel-ipts/pci-ipts.c
> new file mode 100644
> index 000000000..8386d9250
> --- /dev/null
> +++ b/drivers/hid/intel-thc-hid/intel-ipts/pci-ipts.c
> @@ -0,0 +1,124 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * PCI glue for the Intel Touch Host Controller in IPTS mode. Ports
> +that
> + * the HIDSPI driver already claims are deliberately left out of the ID table.
> + */
> +
> +#include <linux/dma-mapping.h>
> +#include <linux/module.h>
> +#include <linux/pci.h>
> +#include <linux/workqueue.h>
> +
> +#include "ipts.h"
> +
> +static const struct pci_device_id thc_ipts_pci_ids[] = {
> +	/* Lakefield */
> +	{PCI_DEVICE_DATA(INTEL, THC_LKF_PORT1, NULL)},
> +	{PCI_DEVICE_DATA(INTEL, THC_LKF_PORT2, NULL)},
> +	/* Tiger Lake */
> +	{PCI_DEVICE_DATA(INTEL, THC_TGL_LP_PORT1, NULL)},
> +	{PCI_DEVICE_DATA(INTEL, THC_TGL_LP_PORT2, NULL)},
> +	{PCI_DEVICE_DATA(INTEL, THC_TGL_H_PORT1, NULL)},
> +	{PCI_DEVICE_DATA(INTEL, THC_TGL_H_PORT2, NULL)},
> +	/* Alder Lake */
> +	{PCI_DEVICE_DATA(INTEL, THC_ADL_S_PORT1, NULL)},
> +	{PCI_DEVICE_DATA(INTEL, THC_ADL_S_PORT2, NULL)},
> +	{PCI_DEVICE_DATA(INTEL, THC_ADL_P_PORT1, NULL)},
> +	{PCI_DEVICE_DATA(INTEL, THC_ADL_P_PORT2, NULL)},
> +	{PCI_DEVICE_DATA(INTEL, THC_ADL_M_PORT1, NULL)},
> +	{PCI_DEVICE_DATA(INTEL, THC_ADL_M_PORT2, NULL)},
> +	/* Raptor Lake */
> +	{PCI_DEVICE_DATA(INTEL, THC_RPL_S_PORT1, NULL)},
> +	{PCI_DEVICE_DATA(INTEL, THC_RPL_S_PORT2, NULL)},
> +	{}
> +};
> +MODULE_DEVICE_TABLE(pci, thc_ipts_pci_ids);
> +
> +static int thc_ipts_probe(struct pci_dev *pci, const struct
> +pci_device_id *id) {
> +	struct thc_ipts *idev;
> +	void __iomem *mem;
> +	int ret;
> +
> +	idev = devm_kzalloc(&pci->dev, sizeof(*idev), GFP_KERNEL);
> +	if (!idev)
> +		return -ENOMEM;
> +
> +	idev->dev = &pci->dev;
> +	pci_set_drvdata(pci, idev);
> +
> +	ret = pcim_enable_device(pci);
> +	if (ret) {
> +		dev_err(idev->dev,
> +			"cannot enable the PCI function, error %d\n", ret);
> +		return ret;
> +	}
> +
> +	pci_set_master(pci);
> +
> +	mem = pcim_iomap_region(pci, 0, KBUILD_MODNAME);
> +	ret = PTR_ERR_OR_ZERO(mem);
> +	if (ret) {
> +		dev_err(idev->dev, "cannot map the register space, error %d\n",
> +			ret);
> +		return ret;
> +	}
> +
> +	ret = dma_set_mask_and_coherent(idev->dev, DMA_BIT_MASK(64));
> +	if (ret)
> +		ret = dma_set_mask_and_coherent(idev->dev,
> DMA_BIT_MASK(32));
> +	if (ret) {
> +		dev_err(idev->dev, "no usable DMA configuration, error %d\n",
> +			ret);
> +		return ret;
> +	}
> +
> +	idev->thc = thc_dev_init(idev->dev, mem);
> +	if (IS_ERR(idev->thc))
> +		return PTR_ERR(idev->thc);
> +
> +	ret = thc_ipts_port_start(idev);
> +	if (ret) {
> +		thc_ipts_port_stop(idev);
> +		return ret;
> +	}
> +
> +	dev_info(idev->dev, "controller %04x:%04x rev %u\n",
> +		 idev->vendor, idev->product, le32_to_cpu(idev->cfg.revision));
> +	dev_info(idev->dev, "spi cfg 0x%08x, rx %zu tx %zu bytes\n",
> +		 le32_to_cpu(idev->cfg.spi_cfg), idev->max_rx, idev->max_tx);
> +
> +	return 0;
> +}
> +
> +static void thc_ipts_remove(struct pci_dev *pci) {
> +	struct thc_ipts *idev = pci_get_drvdata(pci);
> +
> +	thc_ipts_port_stop(idev);
> +	pci_clear_master(pci);
> +}
> +
> +static void thc_ipts_shutdown(struct pci_dev *pci) {
> +	struct thc_ipts *idev = pci_get_drvdata(pci);
> +
> +	if (idev)
> +		thc_ipts_port_stop(idev);
> +}
> +
> +static struct pci_driver thc_ipts_driver = {
> +	.name		= "intel-ipts",
> +	.id_table	= thc_ipts_pci_ids,
> +	.probe		= thc_ipts_probe,
> +	.remove		= thc_ipts_remove,
> +	.shutdown	= thc_ipts_shutdown,
> +	/* Bring-up waits for the controller, up to a few seconds. */
> +	.driver.probe_type = PROBE_PREFER_ASYNCHRONOUS, };
> +module_pci_driver(thc_ipts_driver);
> +
> +MODULE_AUTHOR("Emfox Zhou <emfox@debian.org>");
> +MODULE_DESCRIPTION("IPTS transport for the Intel Touch Host
> +Controller"); MODULE_LICENSE("GPL"); MODULE_IMPORT_NS("INTEL_THC");

  reply	other threads:[~2026-12-02  6:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 15:51 [PATCH v10 0/6] HID: intel-thc-hid: intel-ipts: support THC IPTS ports Emfox Zhou
2026-11-27 15:51 ` [PATCH v10 1/6] HID: intel-thc-hid: intel-thc: expose the operations an IPTS port needs Emfox Zhou
2026-12-02  6:21   ` Xu, Even
2026-11-27 15:51 ` [PATCH v10 2/6] HID: intel-thc-hid: intel-ipts: bring up the port Emfox Zhou
2026-12-02  6:56   ` Xu, Even [this message]
2026-11-27 15:51 ` [PATCH v10 3/6] HID: intel-thc-hid: intel-ipts: receive reports Emfox Zhou
2026-12-02  8:22   ` Xu, Even
2026-11-27 15:51 ` [PATCH v10 4/6] HID: intel-thc-hid: intel-ipts: add the HID device Emfox Zhou
2026-12-02  8:43   ` Xu, Even
2026-12-02 15:39     ` Emfox Zhou
2026-11-27 15:51 ` [PATCH v10 5/6] HID: intel-thc-hid: intel-ipts: handle system sleep Emfox Zhou
2026-11-27 15:51 ` [PATCH v10 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=SJ0PR11MB7704830BF8B5AD21D09EB78DF44C2@SJ0PR11MB7704.namprd11.prod.outlook.com \
    --to=even.xu@intel.com \
    --cc=bentiss@kernel.org \
    --cc=emfox@debian.org \
    --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

all inboxes | Powered by JetHome®