]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
HID: Intel-thc-hid: Intel-quicki2c: Add two new features to PTL
authorEven Xu <even.xu@intel.com>
Wed, 14 May 2025 06:19:44 +0000 (14:19 +0800)
committerJiri Kosina <jkosina@suse.com>
Tue, 10 Jun 2025 19:15:59 +0000 (21:15 +0200)
On Panther Lake platform (PTL), THC hardware introduces two new features
for I2C subsystem:
- Input max input size control
- Input interrupt delay

This patch adds above new advanced features into QuickI2C driver, and
enables max input size control feature on PTL to improve QuickI2C
driver compatibility.

Signed-off-by: Even Xu <even.xu@intel.com>
Tested-by: Chong Han <chong.han@intel.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c
drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-dev.h

index b8c38ed4f0438d4075185d6868085efec2c7f578..4691d100582b3826f360279c66fda1276fb42748 100644 (file)
 #include "quicki2c-hid.h"
 #include "quicki2c-protocol.h"
 
+struct quicki2c_ddata ptl_ddata = {
+       .max_detect_size = MAX_RX_DETECT_SIZE_PTL,
+};
+
 /* THC QuickI2C ACPI method to get device properties */
 /* HIDI2C device method */
 static guid_t i2c_hid_guid =
@@ -408,6 +412,50 @@ static void quicki2c_dev_deinit(struct quicki2c_device *qcdev)
        qcdev->state = QUICKI2C_DISABLED;
 }
 
+/**
+ * quicki2c_dma_adv_enable - Configure and enable DMA advanced features
+ * @qcdev: Pointer to the quicki2c_device structure
+ *
+ * If platform supports THC DMA advanced features, such as max input size
+ * control or interrupt delay, configures and enables them.
+ */
+static void quicki2c_dma_adv_enable(struct quicki2c_device *qcdev)
+{
+       /*
+        * If platform supports max input size control feature and touch device
+        * max input length <= THC detect capability, enable the feature with device
+        * max input length.
+        */
+       if (qcdev->ddata->max_detect_size >=
+           le16_to_cpu(qcdev->dev_desc.max_input_len)) {
+               thc_i2c_set_rx_max_size(qcdev->thc_hw,
+                                       le16_to_cpu(qcdev->dev_desc.max_input_len));
+               thc_i2c_rx_max_size_enable(qcdev->thc_hw, true);
+       }
+
+       /* If platform supports interrupt delay feature, enable it with given delay */
+       if (qcdev->ddata->interrupt_delay) {
+               thc_i2c_set_rx_int_delay(qcdev->thc_hw,
+                                        qcdev->ddata->interrupt_delay);
+               thc_i2c_rx_int_delay_enable(qcdev->thc_hw, true);
+       }
+}
+
+/**
+ * quicki2c_dma_adv_disable - Disable DMA advanced features
+ * @qcdev: Pointer to the quicki2c device structure
+ *
+ * Disable all DMA advanced features if platform supports.
+ */
+static void quicki2c_dma_adv_disable(struct quicki2c_device *qcdev)
+{
+       if (qcdev->ddata->max_detect_size)
+               thc_i2c_rx_max_size_enable(qcdev->thc_hw, false);
+
+       if (qcdev->ddata->interrupt_delay)
+               thc_i2c_rx_int_delay_enable(qcdev->thc_hw, false);
+}
+
 /**
  * quicki2c_dma_init - Configure THC DMA for QuickI2C device
  * @qcdev: Pointer to the quicki2c_device structure
@@ -447,6 +495,9 @@ static int quicki2c_dma_init(struct quicki2c_device *qcdev)
                return ret;
        }
 
+       if (qcdev->ddata)
+               quicki2c_dma_adv_enable(qcdev);
+
        return 0;
 }
 
@@ -461,6 +512,9 @@ static void quicki2c_dma_deinit(struct quicki2c_device *qcdev)
 {
        thc_dma_unconfigure(qcdev->thc_hw);
        thc_dma_release(qcdev->thc_hw);
+
+       if (qcdev->ddata)
+               quicki2c_dma_adv_disable(qcdev);
 }
 
 /**
@@ -924,10 +978,10 @@ static const struct dev_pm_ops quicki2c_pm_ops = {
 static const struct pci_device_id quicki2c_pci_tbl[] = {
        { PCI_DEVICE_DATA(INTEL, THC_LNL_DEVICE_ID_I2C_PORT1, NULL) },
        { PCI_DEVICE_DATA(INTEL, THC_LNL_DEVICE_ID_I2C_PORT2, NULL) },
-       { PCI_DEVICE_DATA(INTEL, THC_PTL_H_DEVICE_ID_I2C_PORT1, NULL) },
-       { PCI_DEVICE_DATA(INTEL, THC_PTL_H_DEVICE_ID_I2C_PORT2, NULL) },
-       { PCI_DEVICE_DATA(INTEL, THC_PTL_U_DEVICE_ID_I2C_PORT1, NULL) },
-       { PCI_DEVICE_DATA(INTEL, THC_PTL_U_DEVICE_ID_I2C_PORT2, NULL) },
+       { PCI_DEVICE_DATA(INTEL, THC_PTL_H_DEVICE_ID_I2C_PORT1, &ptl_ddata) },
+       { PCI_DEVICE_DATA(INTEL, THC_PTL_H_DEVICE_ID_I2C_PORT2, &ptl_ddata) },
+       { PCI_DEVICE_DATA(INTEL, THC_PTL_U_DEVICE_ID_I2C_PORT1, &ptl_ddata) },
+       { PCI_DEVICE_DATA(INTEL, THC_PTL_U_DEVICE_ID_I2C_PORT2, &ptl_ddata) },
        { }
 };
 MODULE_DEVICE_TABLE(pci, quicki2c_pci_tbl);
index e130598d13c155e1e561816c79b6bd6e995e5057..93d6fa982d60918728e353a9d28804584e6638ce 100644 (file)
 #define QUICKI2C_DEFAULT_LP_LTR_VALUE          500
 #define QUICKI2C_RPM_TIMEOUT_MS                        500
 
+/* PTL Max packet size detection capability is 255 Bytes */
+#define MAX_RX_DETECT_SIZE_PTL                 255
+
+/* Default interrupt delay is 1ms, suitable for most devices */
+#define DEFAULT_INTERRUPT_DELAY_US             (1 * USEC_PER_MSEC)
+
 /*
  * THC uses runtime auto suspend to dynamically switch between THC active LTR
  * and low power LTR to save CPU power.