Skip to content

Commit cd37706

Browse files
author
Benjamin Tissoires
committed
Merge branch 'for-6.18/intel-thc-hid' into for-linus
- quicki2c: support ACPI config for advanced features: max input size and interrupt delay (Xinpeng Sun) - some more str_true_false() conversions
2 parents 6a88bb2 + 0b1fca9 commit cd37706

File tree

3 files changed

+55
-11
lines changed

3 files changed

+55
-11
lines changed

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

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
static struct quicki2c_ddata ptl_ddata = {
2525
.max_detect_size = MAX_RX_DETECT_SIZE_PTL,
26+
.max_interrupt_delay = MAX_RX_INTERRUPT_DELAY,
2627
};
2728

2829
/* THC QuickI2C ACPI method to get device properties */
@@ -200,6 +201,21 @@ static int quicki2c_get_acpi_resources(struct quicki2c_device *qcdev)
200201
return -EOPNOTSUPP;
201202
}
202203

204+
if (qcdev->ddata) {
205+
qcdev->i2c_max_frame_size_enable = i2c_config.FSEN;
206+
qcdev->i2c_int_delay_enable = i2c_config.INDE;
207+
208+
if (i2c_config.FSVL <= qcdev->ddata->max_detect_size)
209+
qcdev->i2c_max_frame_size = i2c_config.FSVL;
210+
else
211+
qcdev->i2c_max_frame_size = qcdev->ddata->max_detect_size;
212+
213+
if (i2c_config.INDV <= qcdev->ddata->max_interrupt_delay)
214+
qcdev->i2c_int_delay = i2c_config.INDV;
215+
else
216+
qcdev->i2c_int_delay = qcdev->ddata->max_interrupt_delay;
217+
}
218+
203219
return 0;
204220
}
205221

@@ -441,17 +457,24 @@ static void quicki2c_dma_adv_enable(struct quicki2c_device *qcdev)
441457
* max input length <= THC detect capability, enable the feature with device
442458
* max input length.
443459
*/
444-
if (qcdev->ddata->max_detect_size >=
445-
le16_to_cpu(qcdev->dev_desc.max_input_len)) {
446-
thc_i2c_set_rx_max_size(qcdev->thc_hw,
447-
le16_to_cpu(qcdev->dev_desc.max_input_len));
460+
if (qcdev->i2c_max_frame_size_enable) {
461+
if (qcdev->i2c_max_frame_size >=
462+
le16_to_cpu(qcdev->dev_desc.max_input_len)) {
463+
thc_i2c_set_rx_max_size(qcdev->thc_hw,
464+
le16_to_cpu(qcdev->dev_desc.max_input_len));
465+
} else {
466+
dev_warn(qcdev->dev,
467+
"Max frame size is smaller than hid max input length!");
468+
thc_i2c_set_rx_max_size(qcdev->thc_hw,
469+
le16_to_cpu(qcdev->i2c_max_frame_size));
470+
}
448471
thc_i2c_rx_max_size_enable(qcdev->thc_hw, true);
449472
}
450473

451474
/* If platform supports interrupt delay feature, enable it with given delay */
452-
if (qcdev->ddata->interrupt_delay) {
475+
if (qcdev->i2c_int_delay_enable) {
453476
thc_i2c_set_rx_int_delay(qcdev->thc_hw,
454-
qcdev->ddata->interrupt_delay);
477+
qcdev->i2c_int_delay * 10);
455478
thc_i2c_rx_int_delay_enable(qcdev->thc_hw, true);
456479
}
457480
}
@@ -464,10 +487,10 @@ static void quicki2c_dma_adv_enable(struct quicki2c_device *qcdev)
464487
*/
465488
static void quicki2c_dma_adv_disable(struct quicki2c_device *qcdev)
466489
{
467-
if (qcdev->ddata->max_detect_size)
490+
if (qcdev->i2c_max_frame_size_enable)
468491
thc_i2c_rx_max_size_enable(qcdev->thc_hw, false);
469492

470-
if (qcdev->ddata->interrupt_delay)
493+
if (qcdev->i2c_int_delay_enable)
471494
thc_i2c_rx_int_delay_enable(qcdev->thc_hw, false);
472495
}
473496

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040

4141
/* PTL Max packet size detection capability is 255 Bytes */
4242
#define MAX_RX_DETECT_SIZE_PTL 255
43+
/* Max interrupt delay capability is 2.56ms */
44+
#define MAX_RX_INTERRUPT_DELAY 256
4345

4446
/* Default interrupt delay is 1ms, suitable for most devices */
4547
#define DEFAULT_INTERRUPT_DELAY_US (1 * USEC_PER_MSEC)
@@ -103,6 +105,10 @@ struct quicki2c_subip_acpi_parameter {
103105
* @HMTD: High Speed Mode Plus (3.4Mbits/sec) Serial Data Line Transmit HOLD Period
104106
* @HMRD: High Speed Mode Plus (3.4Mbits/sec) Serial Data Line Receive HOLD Period
105107
* @HMSL: Maximum length (in ic_clk_cycles) of suppressed spikes in High Speed Mode
108+
* @FSEN: Maximum Frame Size Feature Enable Control
109+
* @FSVL: Maximum Frame Size Value (unit in Bytes)
110+
* @INDE: Interrupt Delay Feature Enable Control
111+
* @INDV: Interrupt Delay Value (unit in 10 us)
106112
*
107113
* Those properties get from QUICKI2C_ACPI_METHOD_NAME_ISUB method, used for
108114
* I2C timing configure.
@@ -129,17 +135,22 @@ struct quicki2c_subip_acpi_config {
129135
u64 HMTD;
130136
u64 HMRD;
131137
u64 HMSL;
138+
139+
u64 FSEN;
140+
u64 FSVL;
141+
u64 INDE;
142+
u64 INDV;
132143
u8 reserved;
133144
};
134145

135146
/**
136147
* struct quicki2c_ddata - Driver specific data for quicki2c device
137148
* @max_detect_size: Identify max packet size detect for rx
138-
* @interrupt_delay: Identify interrupt detect delay for rx
149+
* @interrupt_delay: Identify max interrupt detect delay for rx
139150
*/
140151
struct quicki2c_ddata {
141152
u32 max_detect_size;
142-
u32 interrupt_delay;
153+
u32 max_interrupt_delay;
143154
};
144155

145156
struct device;
@@ -172,6 +183,10 @@ struct acpi_device;
172183
* @report_len: The length of input/output report packet
173184
* @reset_ack_wq: Workqueue for waiting reset response from device
174185
* @reset_ack: Indicate reset response received or not
186+
* @i2c_max_frame_size_enable: Indicate max frame size feature enabled or not
187+
* @i2c_max_frame_size: Max RX frame size (unit in Bytes)
188+
* @i2c_int_delay_enable: Indicate interrupt delay feature enabled or not
189+
* @i2c_int_delay: Interrupt detection delay value (unit in 10 us)
175190
*/
176191
struct quicki2c_device {
177192
struct device *dev;
@@ -202,6 +217,11 @@ struct quicki2c_device {
202217

203218
wait_queue_head_t reset_ack_wq;
204219
bool reset_ack;
220+
221+
u32 i2c_max_frame_size_enable;
222+
u32 i2c_max_frame_size;
223+
u32 i2c_int_delay_enable;
224+
u32 i2c_int_delay;
205225
};
206226

207227
#endif /* _QUICKI2C_DEV_H_ */

drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <linux/bitfield.h>
55
#include <linux/math.h>
66
#include <linux/regmap.h>
7+
#include <linux/string_choices.h>
78

89
#include "intel-thc-dev.h"
910
#include "intel-thc-hw.h"
@@ -664,7 +665,7 @@ int thc_interrupt_quiesce(const struct thc_device *dev, bool int_quiesce)
664665
if (ret) {
665666
dev_err_once(dev->dev,
666667
"Timeout while waiting THC idle, target quiesce state = %s\n",
667-
int_quiesce ? "true" : "false");
668+
str_true_false(int_quiesce));
668669
return ret;
669670
}
670671

0 commit comments

Comments
 (0)