Skip to content

Commit 2c7c9c5

Browse files
EvenxfJiri Kosina
authored andcommitted
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 <[email protected]> Tested-by: Chong Han <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 48f151a commit 2c7c9c5

File tree

2 files changed

+64
-4
lines changed

2 files changed

+64
-4
lines changed

drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
#include "quicki2c-hid.h"
1919
#include "quicki2c-protocol.h"
2020

21+
struct quicki2c_ddata ptl_ddata = {
22+
.max_detect_size = MAX_RX_DETECT_SIZE_PTL,
23+
};
24+
2125
/* THC QuickI2C ACPI method to get device properties */
2226
/* HIDI2C device method */
2327
static guid_t i2c_hid_guid =
@@ -408,6 +412,50 @@ static void quicki2c_dev_deinit(struct quicki2c_device *qcdev)
408412
qcdev->state = QUICKI2C_DISABLED;
409413
}
410414

415+
/**
416+
* quicki2c_dma_adv_enable - Configure and enable DMA advanced features
417+
* @qcdev: Pointer to the quicki2c_device structure
418+
*
419+
* If platform supports THC DMA advanced features, such as max input size
420+
* control or interrupt delay, configures and enables them.
421+
*/
422+
static void quicki2c_dma_adv_enable(struct quicki2c_device *qcdev)
423+
{
424+
/*
425+
* If platform supports max input size control feature and touch device
426+
* max input length <= THC detect capability, enable the feature with device
427+
* max input length.
428+
*/
429+
if (qcdev->ddata->max_detect_size >=
430+
le16_to_cpu(qcdev->dev_desc.max_input_len)) {
431+
thc_i2c_set_rx_max_size(qcdev->thc_hw,
432+
le16_to_cpu(qcdev->dev_desc.max_input_len));
433+
thc_i2c_rx_max_size_enable(qcdev->thc_hw, true);
434+
}
435+
436+
/* If platform supports interrupt delay feature, enable it with given delay */
437+
if (qcdev->ddata->interrupt_delay) {
438+
thc_i2c_set_rx_int_delay(qcdev->thc_hw,
439+
qcdev->ddata->interrupt_delay);
440+
thc_i2c_rx_int_delay_enable(qcdev->thc_hw, true);
441+
}
442+
}
443+
444+
/**
445+
* quicki2c_dma_adv_disable - Disable DMA advanced features
446+
* @qcdev: Pointer to the quicki2c device structure
447+
*
448+
* Disable all DMA advanced features if platform supports.
449+
*/
450+
static void quicki2c_dma_adv_disable(struct quicki2c_device *qcdev)
451+
{
452+
if (qcdev->ddata->max_detect_size)
453+
thc_i2c_rx_max_size_enable(qcdev->thc_hw, false);
454+
455+
if (qcdev->ddata->interrupt_delay)
456+
thc_i2c_rx_int_delay_enable(qcdev->thc_hw, false);
457+
}
458+
411459
/**
412460
* quicki2c_dma_init - Configure THC DMA for QuickI2C device
413461
* @qcdev: Pointer to the quicki2c_device structure
@@ -447,6 +495,9 @@ static int quicki2c_dma_init(struct quicki2c_device *qcdev)
447495
return ret;
448496
}
449497

498+
if (qcdev->ddata)
499+
quicki2c_dma_adv_enable(qcdev);
500+
450501
return 0;
451502
}
452503

@@ -461,6 +512,9 @@ static void quicki2c_dma_deinit(struct quicki2c_device *qcdev)
461512
{
462513
thc_dma_unconfigure(qcdev->thc_hw);
463514
thc_dma_release(qcdev->thc_hw);
515+
516+
if (qcdev->ddata)
517+
quicki2c_dma_adv_disable(qcdev);
464518
}
465519

466520
/**
@@ -924,10 +978,10 @@ static const struct dev_pm_ops quicki2c_pm_ops = {
924978
static const struct pci_device_id quicki2c_pci_tbl[] = {
925979
{ PCI_DEVICE_DATA(INTEL, THC_LNL_DEVICE_ID_I2C_PORT1, NULL) },
926980
{ PCI_DEVICE_DATA(INTEL, THC_LNL_DEVICE_ID_I2C_PORT2, NULL) },
927-
{ PCI_DEVICE_DATA(INTEL, THC_PTL_H_DEVICE_ID_I2C_PORT1, NULL) },
928-
{ PCI_DEVICE_DATA(INTEL, THC_PTL_H_DEVICE_ID_I2C_PORT2, NULL) },
929-
{ PCI_DEVICE_DATA(INTEL, THC_PTL_U_DEVICE_ID_I2C_PORT1, NULL) },
930-
{ PCI_DEVICE_DATA(INTEL, THC_PTL_U_DEVICE_ID_I2C_PORT2, NULL) },
981+
{ PCI_DEVICE_DATA(INTEL, THC_PTL_H_DEVICE_ID_I2C_PORT1, &ptl_ddata) },
982+
{ PCI_DEVICE_DATA(INTEL, THC_PTL_H_DEVICE_ID_I2C_PORT2, &ptl_ddata) },
983+
{ PCI_DEVICE_DATA(INTEL, THC_PTL_U_DEVICE_ID_I2C_PORT1, &ptl_ddata) },
984+
{ PCI_DEVICE_DATA(INTEL, THC_PTL_U_DEVICE_ID_I2C_PORT2, &ptl_ddata) },
931985
{ }
932986
};
933987
MODULE_DEVICE_TABLE(pci, quicki2c_pci_tbl);

drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-dev.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@
3636
#define QUICKI2C_DEFAULT_LP_LTR_VALUE 500
3737
#define QUICKI2C_RPM_TIMEOUT_MS 500
3838

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+
3945
/*
4046
* THC uses runtime auto suspend to dynamically switch between THC active LTR
4147
* and low power LTR to save CPU power.

0 commit comments

Comments
 (0)