- 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 | static struct quicki2c_ddata ptl_ddata = { | 24 | static struct quicki2c_ddata ptl_ddata = { |
| 25 | .max_detect_size = MAX_RX_DETECT_SIZE_PTL, | 25 | .max_detect_size = MAX_RX_DETECT_SIZE_PTL, |
| 26 | .max_interrupt_delay = MAX_RX_INTERRUPT_DELAY, | ||
| 26 | }; | 27 | }; |
| 27 | 28 | ||
| 28 | /* THC QuickI2C ACPI method to get device properties */ | 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 | return -EOPNOTSUPP; | 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 | return 0; | 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 | * max input length <= THC detect capability, enable the feature with device | 457 | * max input length <= THC detect capability, enable the feature with device |
| 442 | * max input length. | 458 | * max input length. |
| 443 | */ | 459 | */ |
| 444 | if (qcdev->ddata->max_detect_size >= | 460 | if (qcdev->i2c_max_frame_size_enable) { |
| 445 | le16_to_cpu(qcdev->dev_desc.max_input_len)) { | 461 | if (qcdev->i2c_max_frame_size >= |
| 446 | thc_i2c_set_rx_max_size(qcdev->thc_hw, | 462 | le16_to_cpu(qcdev->dev_desc.max_input_len)) { |
| 447 | 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 | thc_i2c_rx_max_size_enable(qcdev->thc_hw, true); | 471 | thc_i2c_rx_max_size_enable(qcdev->thc_hw, true); |
| 449 | } | 472 | } |
| 450 | 473 | ||
| 451 | /* If platform supports interrupt delay feature, enable it with given delay */ | 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 | thc_i2c_set_rx_int_delay(qcdev->thc_hw, | 476 | thc_i2c_set_rx_int_delay(qcdev->thc_hw, |
| 454 | qcdev->ddata->interrupt_delay); | 477 | qcdev->i2c_int_delay * 10); |
| 455 | thc_i2c_rx_int_delay_enable(qcdev->thc_hw, true); | 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 | static void quicki2c_dma_adv_disable(struct quicki2c_device *qcdev) | 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 | thc_i2c_rx_max_size_enable(qcdev->thc_hw, false); | 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 | thc_i2c_rx_int_delay_enable(qcdev->thc_hw, false); | 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 | /* PTL Max packet size detection capability is 255 Bytes */ | 41 | /* PTL Max packet size detection capability is 255 Bytes */ |
| 42 | #define MAX_RX_DETECT_SIZE_PTL 255 | 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 | /* Default interrupt delay is 1ms, suitable for most devices */ | 46 | /* Default interrupt delay is 1ms, suitable for most devices */ |
| 45 | #define DEFAULT_INTERRUPT_DELAY_US (1 * USEC_PER_MSEC) | 47 | #define DEFAULT_INTERRUPT_DELAY_US (1 * USEC_PER_MSEC) |
| @@ -103,6 +105,10 @@ struct quicki2c_subip_acpi_parameter { · 57 unmodified lines | |||
| 103 | * @HMTD: High Speed Mode Plus (3.4Mbits/sec) Serial Data Line Transmit HOLD Period | 105 | * @HMTD: High Speed Mode Plus (3.4Mbits/sec) Serial Data Line Transmit HOLD Period |
| 104 | * @HMRD: High Speed Mode Plus (3.4Mbits/sec) Serial Data Line Receive HOLD Period | 106 | * @HMRD: High Speed Mode Plus (3.4Mbits/sec) Serial Data Line Receive HOLD Period |
| 105 | * @HMSL: Maximum length (in ic_clk_cycles) of suppressed spikes in High Speed Mode | 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 | * Those properties get from QUICKI2C_ACPI_METHOD_NAME_ISUB method, used for | 113 | * Those properties get from QUICKI2C_ACPI_METHOD_NAME_ISUB method, used for |
| 108 | * I2C timing configure. | 114 | * I2C timing configure. |
| @@ -129,17 +135,22 @@ struct quicki2c_subip_acpi_config { · 20 unmodified lines | |||
| 129 | u64 HMTD; | 135 | u64 HMTD; |
| 130 | u64 HMRD; | 136 | u64 HMRD; |
| 131 | u64 HMSL; | 137 | u64 HMSL; |
| 138 | |||
| 139 | u64 FSEN; | ||
| 140 | u64 FSVL; | ||
| 141 | u64 INDE; | ||
| 142 | u64 INDV; | ||
| 132 | u8 reserved; | 143 | u8 reserved; |
| 133 | }; | 144 | }; |
| 134 | 145 | ||
| 135 | /** | 146 | /** |
| 136 | * struct quicki2c_ddata - Driver specific data for quicki2c device | 147 | * struct quicki2c_ddata - Driver specific data for quicki2c device |
| 137 | * @max_detect_size: Identify max packet size detect for rx | 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 | struct quicki2c_ddata { | 151 | struct quicki2c_ddata { |
| 141 | u32 max_detect_size; | 152 | u32 max_detect_size; |
| 142 | u32 interrupt_delay; | 153 | u32 max_interrupt_delay; |
| 143 | }; | 154 | }; |
| 144 | 155 | ||
| 145 | struct device; | 156 | struct device; |
| @@ -172,6 +183,10 @@ struct acpi_device; · 26 unmodified lines | |||
| 172 | * @report_len: The length of input/output report packet | 183 | * @report_len: The length of input/output report packet |
| 173 | * @reset_ack_wq: Workqueue for waiting reset response from device | 184 | * @reset_ack_wq: Workqueue for waiting reset response from device |
| 174 | * @reset_ack: Indicate reset response received or not | 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 | struct quicki2c_device { | 191 | struct quicki2c_device { |
| 177 | struct device *dev; | 192 | struct device *dev; |
| @@ -202,6 +217,11 @@ struct quicki2c_device { · 24 unmodified lines | |||
| 202 | 217 | ||
| 203 | wait_queue_head_t reset_ack_wq; | 218 | wait_queue_head_t reset_ack_wq; |
| 204 | bool reset_ack; | 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 | #endif /* _QUICKI2C_DEV_H_ */ | 227 | #endif /* _QUICKI2C_DEV_H_ */ |
| @@ -4,6 +4,7 @@ · 3 unmodified lines | |||
| 4 | #include <linux/bitfield.h> | 4 | #include <linux/bitfield.h> |
| 5 | #include <linux/math.h> | 5 | #include <linux/math.h> |
| 6 | #include <linux/regmap.h> | 6 | #include <linux/regmap.h> |
| 7 | #include <linux/string_choices.h> | ||
| 7 | 8 | ||
| 8 | #include "intel-thc-dev.h" | 9 | #include "intel-thc-dev.h" |
| 9 | #include "intel-thc-hw.h" | 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 | if (ret) { | 665 | if (ret) { |
| 665 | dev_err_once(dev->dev, | 666 | dev_err_once(dev->dev, |
| 666 | "Timeout while waiting THC idle, target quiesce state = %s\n", | 667 | "Timeout while waiting THC idle, target quiesce state = %s\n", |
| 667 | int_quiesce ? "true" : "false"); | 668 | str_true_false(int_quiesce)); |
| 668 | return ret; | 669 | return ret; |
| 669 | } | 670 | } |
| 670 | 671 | ||