Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

HID: Intel-thc-hid: Intel-quicki2c: Add two new features to PTL

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>

authored by

Even Xu and committed by
Jiri Kosina
2c7c9c5d 48f151a5

+64 -4
+58 -4
drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c
··· 18 18 #include "quicki2c-hid.h" 19 19 #include "quicki2c-protocol.h" 20 20 21 + struct quicki2c_ddata ptl_ddata = { 22 + .max_detect_size = MAX_RX_DETECT_SIZE_PTL, 23 + }; 24 + 21 25 /* THC QuickI2C ACPI method to get device properties */ 22 26 /* HIDI2C device method */ 23 27 static guid_t i2c_hid_guid = ··· 413 409 } 414 410 415 411 /** 412 + * quicki2c_dma_adv_enable - Configure and enable DMA advanced features 413 + * @qcdev: Pointer to the quicki2c_device structure 414 + * 415 + * If platform supports THC DMA advanced features, such as max input size 416 + * control or interrupt delay, configures and enables them. 417 + */ 418 + static void quicki2c_dma_adv_enable(struct quicki2c_device *qcdev) 419 + { 420 + /* 421 + * If platform supports max input size control feature and touch device 422 + * max input length <= THC detect capability, enable the feature with device 423 + * max input length. 424 + */ 425 + if (qcdev->ddata->max_detect_size >= 426 + le16_to_cpu(qcdev->dev_desc.max_input_len)) { 427 + thc_i2c_set_rx_max_size(qcdev->thc_hw, 428 + le16_to_cpu(qcdev->dev_desc.max_input_len)); 429 + thc_i2c_rx_max_size_enable(qcdev->thc_hw, true); 430 + } 431 + 432 + /* If platform supports interrupt delay feature, enable it with given delay */ 433 + if (qcdev->ddata->interrupt_delay) { 434 + thc_i2c_set_rx_int_delay(qcdev->thc_hw, 435 + qcdev->ddata->interrupt_delay); 436 + thc_i2c_rx_int_delay_enable(qcdev->thc_hw, true); 437 + } 438 + } 439 + 440 + /** 441 + * quicki2c_dma_adv_disable - Disable DMA advanced features 442 + * @qcdev: Pointer to the quicki2c device structure 443 + * 444 + * Disable all DMA advanced features if platform supports. 445 + */ 446 + static void quicki2c_dma_adv_disable(struct quicki2c_device *qcdev) 447 + { 448 + if (qcdev->ddata->max_detect_size) 449 + thc_i2c_rx_max_size_enable(qcdev->thc_hw, false); 450 + 451 + if (qcdev->ddata->interrupt_delay) 452 + thc_i2c_rx_int_delay_enable(qcdev->thc_hw, false); 453 + } 454 + 455 + /** 416 456 * quicki2c_dma_init - Configure THC DMA for QuickI2C device 417 457 * @qcdev: Pointer to the quicki2c_device structure 418 458 * ··· 495 447 return ret; 496 448 } 497 449 450 + if (qcdev->ddata) 451 + quicki2c_dma_adv_enable(qcdev); 452 + 498 453 return 0; 499 454 } 500 455 ··· 512 461 { 513 462 thc_dma_unconfigure(qcdev->thc_hw); 514 463 thc_dma_release(qcdev->thc_hw); 464 + 465 + if (qcdev->ddata) 466 + quicki2c_dma_adv_disable(qcdev); 515 467 } 516 468 517 469 /** ··· 978 924 static const struct pci_device_id quicki2c_pci_tbl[] = { 979 925 { PCI_DEVICE_DATA(INTEL, THC_LNL_DEVICE_ID_I2C_PORT1, NULL) }, 980 926 { PCI_DEVICE_DATA(INTEL, THC_LNL_DEVICE_ID_I2C_PORT2, NULL) }, 981 - { PCI_DEVICE_DATA(INTEL, THC_PTL_H_DEVICE_ID_I2C_PORT1, NULL) }, 982 - { PCI_DEVICE_DATA(INTEL, THC_PTL_H_DEVICE_ID_I2C_PORT2, NULL) }, 983 - { PCI_DEVICE_DATA(INTEL, THC_PTL_U_DEVICE_ID_I2C_PORT1, NULL) }, 984 - { PCI_DEVICE_DATA(INTEL, THC_PTL_U_DEVICE_ID_I2C_PORT2, NULL) }, 927 + { PCI_DEVICE_DATA(INTEL, THC_PTL_H_DEVICE_ID_I2C_PORT1, &ptl_ddata) }, 928 + { PCI_DEVICE_DATA(INTEL, THC_PTL_H_DEVICE_ID_I2C_PORT2, &ptl_ddata) }, 929 + { PCI_DEVICE_DATA(INTEL, THC_PTL_U_DEVICE_ID_I2C_PORT1, &ptl_ddata) }, 930 + { PCI_DEVICE_DATA(INTEL, THC_PTL_U_DEVICE_ID_I2C_PORT2, &ptl_ddata) }, 985 931 { } 986 932 }; 987 933 MODULE_DEVICE_TABLE(pci, quicki2c_pci_tbl);
+6
drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-dev.h
··· 36 36 #define QUICKI2C_DEFAULT_LP_LTR_VALUE 500 37 37 #define QUICKI2C_RPM_TIMEOUT_MS 500 38 38 39 + /* PTL Max packet size detection capability is 255 Bytes */ 40 + #define MAX_RX_DETECT_SIZE_PTL 255 41 + 42 + /* Default interrupt delay is 1ms, suitable for most devices */ 43 + #define DEFAULT_INTERRUPT_DELAY_US (1 * USEC_PER_MSEC) 44 + 39 45 /* 40 46 * THC uses runtime auto suspend to dynamically switch between THC active LTR 41 47 * and low power LTR to save CPU power.