[PATCH 2/2] HID: Intel-thc-hid: Intel-quicki2c: Support full I2C BUS config parameters
From: Even Xu
Date: Sun Jul 26 2026 - 23:04:27 EST
Read complete I2C bus configuration parameters from ACPI and passes them
to thc_i2c_subip_init() to properly initialize the THC I2C subip with
platform-specific settings.
This change enhances hardware compatibility by allowing full
platform-specific I2C bus configurations.
Signed-off-by: Even Xu <even.xu@xxxxxxxxx>
---
.../intel-quicki2c/pci-quicki2c.c | 46 ++++++++++---------
.../intel-quicki2c/quicki2c-dev.h | 14 ++----
2 files changed, 29 insertions(+), 31 deletions(-)
diff --git a/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c b/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c
index 3ccbddfe8e5e..c3c7cf8e4b63 100644
--- a/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c
+++ b/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c
@@ -175,7 +175,9 @@ static int quicki2c_get_acpi_resources(struct quicki2c_device *qcdev)
if (i2c_param.addressing_mode != HIDI2C_ADDRESSING_MODE_7BIT)
return -EOPNOTSUPP;
- qcdev->i2c_slave_addr = i2c_param.device_address;
+ qcdev->i2c_config.addr_mode = HIDI2C_ADDRESSING_MODE_7BIT;
+
+ qcdev->i2c_config.target_addr = i2c_param.device_address;
ret = quicki2c_acpi_get_dsd_property(adev, QUICKI2C_ACPI_METHOD_NAME_ISUB,
ACPI_TYPE_BUFFER, &i2c_config);
@@ -184,24 +186,32 @@ static int quicki2c_get_acpi_resources(struct quicki2c_device *qcdev)
if (i2c_param.connection_speed > 0 &&
i2c_param.connection_speed <= QUICKI2C_SUBIP_STANDARD_MODE_MAX_SPEED) {
- qcdev->i2c_speed_mode = THC_I2C_STANDARD;
- qcdev->i2c_clock_hcnt = i2c_config.SMHX;
- qcdev->i2c_clock_lcnt = i2c_config.SMLX;
+ qcdev->i2c_config.speed = THC_I2C_STANDARD;
+ qcdev->i2c_config.scl_hcnt = (u32)i2c_config.SMHX;
+ qcdev->i2c_config.scl_lcnt = (u32)i2c_config.SMLX;
+ qcdev->i2c_config.sda_tx_hold = (u32)i2c_config.SMTD;
+ qcdev->i2c_config.sda_rx_hold = (u32)i2c_config.SMRD;
} else if (i2c_param.connection_speed > QUICKI2C_SUBIP_STANDARD_MODE_MAX_SPEED &&
i2c_param.connection_speed <= QUICKI2C_SUBIP_FAST_MODE_MAX_SPEED) {
- qcdev->i2c_speed_mode = THC_I2C_FAST_AND_PLUS;
- qcdev->i2c_clock_hcnt = i2c_config.FMHX;
- qcdev->i2c_clock_lcnt = i2c_config.FMLX;
+ qcdev->i2c_config.speed = THC_I2C_FAST_AND_PLUS;
+ qcdev->i2c_config.scl_hcnt = (u32)i2c_config.FMHX;
+ qcdev->i2c_config.scl_lcnt = (u32)i2c_config.FMLX;
+ qcdev->i2c_config.sda_tx_hold = (u32)i2c_config.FMTD;
+ qcdev->i2c_config.sda_rx_hold = (u32)i2c_config.FMRD;
} else if (i2c_param.connection_speed > QUICKI2C_SUBIP_FAST_MODE_MAX_SPEED &&
i2c_param.connection_speed <= QUICKI2C_SUBIP_FASTPLUS_MODE_MAX_SPEED) {
- qcdev->i2c_speed_mode = THC_I2C_FAST_AND_PLUS;
- qcdev->i2c_clock_hcnt = i2c_config.FPHX;
- qcdev->i2c_clock_lcnt = i2c_config.FPLX;
+ qcdev->i2c_config.speed = THC_I2C_FAST_AND_PLUS;
+ qcdev->i2c_config.scl_hcnt = (u32)i2c_config.FPHX;
+ qcdev->i2c_config.scl_lcnt = (u32)i2c_config.FPLX;
+ qcdev->i2c_config.sda_tx_hold = (u32)i2c_config.FPTD;
+ qcdev->i2c_config.sda_rx_hold = (u32)i2c_config.FPRD;
} else if (i2c_param.connection_speed > QUICKI2C_SUBIP_FASTPLUS_MODE_MAX_SPEED &&
i2c_param.connection_speed <= QUICKI2C_SUBIP_HIGH_SPEED_MODE_MAX_SPEED) {
- qcdev->i2c_speed_mode = THC_I2C_HIGH_SPEED;
- qcdev->i2c_clock_hcnt = i2c_config.HMHX;
- qcdev->i2c_clock_lcnt = i2c_config.HMLX;
+ qcdev->i2c_config.speed = THC_I2C_HIGH_SPEED;
+ qcdev->i2c_config.scl_hcnt = (u32)i2c_config.HMHX;
+ qcdev->i2c_config.scl_lcnt = (u32)i2c_config.HMLX;
+ qcdev->i2c_config.sda_tx_hold = (u32)i2c_config.HMTD;
+ qcdev->i2c_config.sda_rx_hold = (u32)i2c_config.HMRD;
} else {
return -EOPNOTSUPP;
}
@@ -415,10 +425,7 @@ static struct quicki2c_device *quicki2c_dev_init(struct pci_dev *pdev, void __io
return ERR_PTR(ret);
}
- ret = thc_i2c_subip_init(qcdev->thc_hw, qcdev->i2c_slave_addr,
- qcdev->i2c_speed_mode,
- qcdev->i2c_clock_hcnt,
- qcdev->i2c_clock_lcnt);
+ ret = thc_i2c_subip_init(qcdev->thc_hw, &qcdev->i2c_config);
if (ret)
return ERR_PTR(ret);
@@ -978,10 +985,7 @@ static int quicki2c_restore(struct device *device)
if (ret)
return ret;
- ret = thc_i2c_subip_init(qcdev->thc_hw, qcdev->i2c_slave_addr,
- qcdev->i2c_speed_mode,
- qcdev->i2c_clock_hcnt,
- qcdev->i2c_clock_lcnt);
+ ret = thc_i2c_subip_init(qcdev->thc_hw, &qcdev->i2c_config);
if (ret)
return ret;
diff --git a/drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-dev.h b/drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-dev.h
index d72565de67b9..6d25a846153e 100644
--- a/drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-dev.h
+++ b/drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-dev.h
@@ -7,6 +7,8 @@
#include <linux/hid-over-i2c.h>
#include <linux/workqueue.h>
+#include "intel-thc-dev.h"
+
#define PCI_DEVICE_ID_INTEL_THC_LNL_DEVICE_ID_I2C_PORT1 0xA848
#define PCI_DEVICE_ID_INTEL_THC_LNL_DEVICE_ID_I2C_PORT2 0xA84A
#define PCI_DEVICE_ID_INTEL_THC_PTL_H_DEVICE_ID_I2C_PORT1 0xE348
@@ -159,7 +161,6 @@ struct quicki2c_ddata {
struct device;
struct pci_dev;
-struct thc_device;
struct hid_device;
struct acpi_device;
@@ -174,13 +175,10 @@ struct acpi_device;
* @state: THC I2C device state
* @mem_addr: MMIO memory address
* @dev_desc: Device descriptor for HIDI2C protocol
- * @i2c_slave_addr: HIDI2C device slave address
+ * @i2c_config: I2C bus configuration
* @hid_desc_addr: Register address for retrieve HID device descriptor
* @active_ltr_val: THC active LTR value
* @low_power_ltr_val: THC low power LTR value
- * @i2c_speed_mode: 0 - standard mode, 1 - fast mode, 2 - fast mode plus
- * @i2c_clock_hcnt: I2C CLK high period time (unit in cycle count)
- * @i2c_clock_lcnt: I2C CLK low period time (unit in cycle count)
* @report_descriptor: Store a copy of device report descriptor
* @input_buf: Store a copy of latest input report data
* @report_buf: Store a copy of latest input/output report packet from set/get feature
@@ -206,16 +204,12 @@ struct quicki2c_device {
void __iomem *mem_addr;
struct hidi2c_dev_descriptor dev_desc;
- u8 i2c_slave_addr;
+ struct thc_i2c_config i2c_config;
u16 hid_desc_addr;
u32 active_ltr_val;
u32 low_power_ltr_val;
- u32 i2c_speed_mode;
- u32 i2c_clock_hcnt;
- u32 i2c_clock_lcnt;
-
u8 *report_descriptor;
u8 *input_buf;
u8 *report_buf;
--
2.43.0