- quicki2c: support ACPI config for advanced features: max input size and interrupt delay (Xinpeng Sun) - some more str_true_false() conversions
Unified · Split
| @@ -23,6 +23,7 @@ · 22 unmodified lines | ||
| 23 | 23 | |
| 24 | 24 | static struct quicki2c_ddata ptl_ddata = { |
| 25 | 25 | .max_detect_size = MAX_RX_DETECT_SIZE_PTL, |
| 26 | + .max_interrupt_delay = MAX_RX_INTERRUPT_DELAY, | |
| 26 | 27 | }; |
| 27 | 28 | |
| 28 | 29 | /* THC QuickI2C ACPI method to get device properties */ |
| @@ -200,6 +201,21 @@ static int quicki2c_get_acpi_resources(struct quicki2c_device *qcdev) · 171 unmodified lines | ||
| 200 | 201 | return -EOPNOTSUPP; |
| 201 | 202 | } |
| 202 | 203 | |
| 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 | + | |
| 203 | 219 | return 0; |
| 204 | 220 | } |
| 205 | 221 | |
| @@ -441,17 +457,24 @@ static void quicki2c_dma_adv_enable(struct quicki2c_device *qcdev) · 235 unmodified lines | ||
| 441 | 457 | * max input length <= THC detect capability, enable the feature with device |
| 442 | 458 | * max input length. |
| 443 | 459 | */ |
| 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 | + } | |
| 448 | 471 | thc_i2c_rx_max_size_enable(qcdev->thc_hw, true); |
| 449 | 472 | } |
| 450 | 473 | |
| 451 | 474 | /* If platform supports interrupt delay feature, enable it with given delay */ |
| 452 | − if (qcdev->ddata->interrupt_delay) { | |
| 475 | + if (qcdev->i2c_int_delay_enable) { | |
| 453 | 476 | thc_i2c_set_rx_int_delay(qcdev->thc_hw, |
| 454 | − qcdev->ddata->interrupt_delay); | |
| 477 | + qcdev->i2c_int_delay * 10); | |
| 455 | 478 | thc_i2c_rx_int_delay_enable(qcdev->thc_hw, true); |
| 456 | 479 | } |
| 457 | 480 | } |
| @@ -464,10 +487,10 @@ static void quicki2c_dma_adv_enable(struct quicki2c_device *qcdev) · 6 unmodified lines | ||
| 464 | 487 | */ |
| 465 | 488 | static void quicki2c_dma_adv_disable(struct quicki2c_device *qcdev) |
| 466 | 489 | { |
| 467 | − if (qcdev->ddata->max_detect_size) | |
| 490 | + if (qcdev->i2c_max_frame_size_enable) | |
| 468 | 491 | thc_i2c_rx_max_size_enable(qcdev->thc_hw, false); |
| 469 | 492 | |
| 470 | − if (qcdev->ddata->interrupt_delay) | |
| 493 | + if (qcdev->i2c_int_delay_enable) | |
| 471 | 494 | thc_i2c_rx_int_delay_enable(qcdev->thc_hw, false); |
| 472 | 495 | } |
| 473 | 496 | |
| @@ -40,6 +40,8 @@ · 39 unmodified lines | ||
| 40 | 40 | |
| 41 | 41 | /* PTL Max packet size detection capability is 255 Bytes */ |
| 42 | 42 | #define MAX_RX_DETECT_SIZE_PTL 255 |
| 43 | +/* Max interrupt delay capability is 2.56ms */ | |
| 44 | +#define MAX_RX_INTERRUPT_DELAY 256 | |
| 43 | 45 | |
| 44 | 46 | /* Default interrupt delay is 1ms, suitable for most devices */ |
| 45 | 47 | #define DEFAULT_INTERRUPT_DELAY_US (1 * USEC_PER_MSEC) |
| @@ -103,6 +105,10 @@ struct quicki2c_subip_acpi_parameter { · 57 unmodified lines | ||
| 103 | 105 | * @HMTD: High Speed Mode Plus (3.4Mbits/sec) Serial Data Line Transmit HOLD Period |
| 104 | 106 | * @HMRD: High Speed Mode Plus (3.4Mbits/sec) Serial Data Line Receive HOLD Period |
| 105 | 107 | * @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) | |
| 106 | 112 | * |
| 107 | 113 | * Those properties get from QUICKI2C_ACPI_METHOD_NAME_ISUB method, used for |
| 108 | 114 | * I2C timing configure. |
| @@ -129,17 +135,22 @@ struct quicki2c_subip_acpi_config { · 20 unmodified lines | ||
| 129 | 135 | u64 HMTD; |
| 130 | 136 | u64 HMRD; |
| 131 | 137 | u64 HMSL; |
| 138 | + | |
| 139 | + u64 FSEN; | |
| 140 | + u64 FSVL; | |
| 141 | + u64 INDE; | |
| 142 | + u64 INDV; | |
| 132 | 143 | u8 reserved; |
| 133 | 144 | }; |
| 134 | 145 | |
| 135 | 146 | /** |
| 136 | 147 | * struct quicki2c_ddata - Driver specific data for quicki2c device |
| 137 | 148 | * @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 | |
| 139 | 150 | */ |
| 140 | 151 | struct quicki2c_ddata { |
| 141 | 152 | u32 max_detect_size; |
| 142 | − u32 interrupt_delay; | |
| 153 | + u32 max_interrupt_delay; | |
| 143 | 154 | }; |
| 144 | 155 | |
| 145 | 156 | struct device; |
| @@ -172,6 +183,10 @@ struct acpi_device; · 26 unmodified lines | ||
| 172 | 183 | * @report_len: The length of input/output report packet |
| 173 | 184 | * @reset_ack_wq: Workqueue for waiting reset response from device |
| 174 | 185 | * @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) | |
| 175 | 190 | */ |
| 176 | 191 | struct quicki2c_device { |
| 177 | 192 | struct device *dev; |
| @@ -202,6 +217,11 @@ struct quicki2c_device { · 24 unmodified lines | ||
| 202 | 217 | |
| 203 | 218 | wait_queue_head_t reset_ack_wq; |
| 204 | 219 | 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; | |
| 205 | 225 | }; |
| 206 | 226 | |
| 207 | 227 | #endif /* _QUICKI2C_DEV_H_ */ |
| @@ -4,6 +4,7 @@ · 3 unmodified lines | ||
| 4 | 4 | #include <linux/bitfield.h> |
| 5 | 5 | #include <linux/math.h> |
| 6 | 6 | #include <linux/regmap.h> |
| 7 | +#include <linux/string_choices.h> | |
| 7 | 8 | |
| 8 | 9 | #include "intel-thc-dev.h" |
| 9 | 10 | #include "intel-thc-hw.h" |
| @@ -664,7 +665,7 @@ int thc_interrupt_quiesce(const struct thc_device *dev, bool int_quiesce) · 654 unmodified lines | ||
| 664 | 665 | if (ret) { |
| 665 | 666 | dev_err_once(dev->dev, |
| 666 | 667 | "Timeout while waiting THC idle, target quiesce state = %s\n", |
| 667 | − int_quiesce ? "true" : "false"); | |
| 668 | + str_true_false(int_quiesce)); | |
| 668 | 669 | return ret; |
| 669 | 670 | } |
| 670 | 671 | |