| 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #ifndef __DRIVERS_INTEL_TOUCH_CHIP_H__ |
| 4 | #define __DRIVERS_INTEL_TOUCH_CHIP_H__ |
| 5 | |
| 6 | #include <acpi/acpi_device.h> |
| 7 | |
| 8 | #define INTEL_THC0_NAME "THC0" |
| 9 | #define INTEL_THC1_NAME "THC1" |
| 10 | |
| 11 | struct intel_thc_hidi2c_dev_info { |
| 12 | /* Device I2C address */ |
| 13 | uint64_t addr; |
| 14 | /* Used in THC_HID_I2C mode */ |
| 15 | uint32_t descriptor_address; |
| 16 | }; |
| 17 | |
| 18 | struct intel_thc_hidspi_dev_info { |
| 19 | /* Touch Host Controller HID Over SPI Input Report Header Address */ |
| 20 | uint32_t input_report_header_address; |
| 21 | |
| 22 | /* Touch Host Controller HID Over SPI Input Report Body Address */ |
| 23 | uint32_t input_report_body_address; |
| 24 | |
| 25 | /* Touch Host Controller HID Over SPI Output Report Address */ |
| 26 | uint32_t output_report_address; |
| 27 | |
| 28 | /* Touch Host Controller HID Over SPI Read Opcode */ |
| 29 | uint32_t read_opcode; |
| 30 | |
| 31 | /* Touch Host Controller HID Over SPI Write Opcode */ |
| 32 | uint32_t write_opcode; |
| 33 | |
| 34 | }; |
| 35 | |
| 36 | union intel_thc_dev_intf_info { |
| 37 | struct intel_thc_hidi2c_dev_info hidi2c; |
| 38 | struct intel_thc_hidspi_dev_info hidspi; |
| 39 | }; |
| 40 | |
| 41 | struct intel_thc_dev_info { |
| 42 | /* Device ACPI _HID */ |
| 43 | const char *hid; |
| 44 | /* Device ACPI _CID */ |
| 45 | const char *cid; |
| 46 | union intel_thc_dev_intf_info intf; |
| 47 | }; |
| 48 | |
| 49 | struct intel_thc_hidi2c_info { |
| 50 | /* Device connection speed in Hz */ |
| 51 | uint64_t connection_speed; |
| 52 | /* Device address mode */ |
| 53 | uint64_t addr_mode; |
| 54 | /* Standard Mode (100 kbit/s) Serial Clock Line HIGH Period */ |
| 55 | /* NOTE: unit for period: # of reference clock count */ |
| 56 | uint64_t sm_scl_high_period; |
| 57 | /* Standard Mode (100 kbit/s) Serial Clock Line LOW Period */ |
| 58 | uint64_t sm_scl_low_period; |
| 59 | /* Standard Mode (100 kbit/s) Serial Data Line Transmit Hold Period */ |
| 60 | uint64_t sm_sda_hold_tx_period; |
| 61 | /* Standard Mode (100 kbit/s) Serial Data Receive Hold Period */ |
| 62 | uint64_t sm_sda_hold_rx_period; |
| 63 | /* Fast Mode (400 kbit/s) Serial Clock Line HIGH Period */ |
| 64 | uint64_t fm_scl_high_period; |
| 65 | /* Fast Mode (400 kbit/s) Serial Clock Line LOW Period */ |
| 66 | uint64_t fm_scl_low_period; |
| 67 | /* Fast Mode (400 kbit/s) Serial Data Line Transmit Hold Period */ |
| 68 | uint64_t fm_sda_hold_tx_period; |
| 69 | /* Fast Mode (400 kbit/s) Serial Data Line Receive Hold Period */ |
| 70 | uint64_t fm_sda_hold_rx_period; |
| 71 | /* |
| 72 | * Maximum length (in ic_clk_cycles) of suppressed spikes in Std Mode, Fast Mode, and |
| 73 | * Fast Mode Plus. |
| 74 | */ |
| 75 | uint64_t suppressed_spikes_s_f_fp; |
| 76 | /* Fast Mode Plus (1Mbit/sec) Serial Clock Line HIGH Period */ |
| 77 | uint64_t fmp_scl_high_period; |
| 78 | /* Fast Mode Plus (1Mbit/sec) Serial Clock Line LOW Period */ |
| 79 | uint64_t fmp_scl_low_period; |
| 80 | /* Fast Mode Plus (1Mbit/sec) Serial Data Line Transmit HOLD Period */ |
| 81 | uint64_t fmp_sda_hold_tx_period; |
| 82 | /* Fast Mode Plus (1Mbit/sec) Serial Data Line Receive HOLD Period */ |
| 83 | uint64_t fmp_sda_hold_rx_period; |
| 84 | /* High Speed Mode Plus (3.4Mbits/sec) Serial Clock Line HIGH Period */ |
| 85 | uint64_t hm_scl_high_period; |
| 86 | /* High Speed Mode Plus (3.4Mbits/sec) Serial Clock Line LOW Period */ |
| 87 | uint64_t hm_scl_low_period; |
| 88 | /* High Speed Mode Plus (3.4Mbits/sec) Serial Data Line Transmit HOLD Period */ |
| 89 | uint64_t hm_sda_hold_tx_period; |
| 90 | /* High Speed Mode Plus (3.4Mbits/sec) Serial Data Line Receive HOLD Period */ |
| 91 | uint64_t hm_sda_hold_rx_period; |
| 92 | /* Maximum length (in ic_clk_cycles) of suppressed spikes in High Speed Mode */ |
| 93 | uint64_t suppressed_spikes_h_fp; |
| 94 | }; |
| 95 | |
| 96 | struct intel_thc_hidspi_info { |
| 97 | /* |
| 98 | * Touch Host Controller HID Over SPI Connection Speed |
| 99 | * |
| 100 | * HID Over SPI Connection Speed - SPI Frequency |
| 101 | */ |
| 102 | uint32_t connection_speed; |
| 103 | |
| 104 | /* |
| 105 | * Touch Host Controller HID Over SPI Limit PacketSize |
| 106 | * |
| 107 | * When set, limits SPI read & write packet size to 64B. Otherwise, THC uses Max Soc |
| 108 | * packet size for SPI Read and Write 0x0- Max Soc Packet Size, 0x11 - 64 Bytes |
| 109 | */ |
| 110 | uint32_t limit_packet_size; |
| 111 | |
| 112 | /* |
| 113 | * Touch Host Controller HID Over SPI Flags |
| 114 | * |
| 115 | * HID Over SPI Flags 0x0:Single SPI Mode, 0x4000:Dual SPI Mode, 0x8000:Quad SPI Mode |
| 116 | * Bit 0-12: Reserved |
| 117 | * Bit 13: SPI Write Mode. |
| 118 | * 0b0 - Writes are carried in single SPI mode |
| 119 | * 0b1 - Writes are carried out in Multi-SPI mode as specified by bit 14-15 |
| 120 | * Bit 14-15: Multi-SPI Mode |
| 121 | * 0b00 - Single SPI Mode |
| 122 | * 0b01 - Dual SPI Mode |
| 123 | * 0b10 - Quad SPI Mode |
| 124 | * 0b11 - Reserved |
| 125 | */ |
| 126 | enum { |
| 127 | HIDSPI_WRITE_MODE_SINGLE = 0x0, |
| 128 | HIDSPI_WRITE_MODE_MULTI_SINGLE_SPI = 0x2000, |
| 129 | HIDSPI_WRITE_MODE_MULTI_DUAL_SPI = 0x6000, |
| 130 | HIDSPI_WRITE_MODE_MULTI_QUAD_SPI = 0xa000 |
| 131 | } write_mode; |
| 132 | |
| 133 | /* Touch Host Controller HID Over SPI ResetPad */ |
| 134 | /* NOTE: This could be the same pad as reset_gpio */ |
| 135 | struct acpi_gpio reset_gpio; |
| 136 | /* Delay to be inserted after device is taken out of reset */ |
| 137 | unsigned int reset_delay_ms; |
| 138 | /* Delay to be inserted after device is put into reset */ |
| 139 | unsigned int reset_off_delay_ms; |
| 140 | |
| 141 | /* |
| 142 | * Touch Host Controller HID Over SPI Limit PacketSize |
| 143 | * |
| 144 | * Minimum amount of delay the THC/QUICKSPI driver must wait between end of write |
| 145 | * operation and begin of read operation. This value shall be in 10us multiples 0x0: |
| 146 | * Disabled, 1-65535 (0xFFFF) - up to 655350 us |
| 147 | */ |
| 148 | uint32_t performance_limit; |
| 149 | |
| 150 | /* |
| 151 | * Touch Host Controller HID Over SPI Reset Sequencing Delay [ms] |
| 152 | * Policy control for reset sequencing delay (ACPI _INI, _RST) default 300ms |
| 153 | */ |
| 154 | uint16_t reset_sequencing_delay; |
| 155 | }; |
| 156 | |
| 157 | enum intel_touch_device { |
| 158 | TH_SENSOR_NONE, |
| 159 | TH_SENSOR_WACOM, /* BOM22 for SPI only */ |
| 160 | TH_SENSOR_ELAN, /* BOM36 for SPI and BOM37 for I2C */ |
| 161 | TH_SENSOR_HYNITRON, /* NYITRON for I2C only */ |
| 162 | TH_SENSOR_GENERIC, /* for device properity thru devicetree */ |
| 163 | TH_SENSOR_MAX |
| 164 | }; |
| 165 | |
| 166 | /* |
| 167 | * Intel Touch Controller (THC) & sensor device |
| 168 | * Reference document: Meteor Lake UH type4 EDS vol1 640228 |
| 169 | */ |
| 170 | struct drivers_intel_touch_config { |
| 171 | const char *name; |
| 172 | const char *desc; |
| 173 | |
| 174 | /* |
| 175 | * Touch Host Controller's (THC) 3 protocol modes: |
| 176 | * 0x0: THC IPTS (not supported at this time) |
| 177 | * 0x1: THC HID SPI (for MTL or later) |
| 178 | * 0x2: THC HID I2C (for PTL or later) |
| 179 | */ |
| 180 | enum { |
| 181 | THC_IPTS_MODE, |
| 182 | THC_HID_SPI_MODE, |
| 183 | THC_HID_I2C_MODE, |
| 184 | } mode; |
| 185 | |
| 186 | /* GPIO used to enable device. */ |
| 187 | struct acpi_gpio enable_gpio; |
| 188 | /* Delay to be inserted after device is enabled. */ |
| 189 | unsigned int enable_delay_ms; |
| 190 | /* Delay to be inserted after device is disabled. */ |
| 191 | unsigned int enable_off_delay_ms; |
| 192 | |
| 193 | /* GPIO used to take device out of reset or to put it into reset. */ |
| 194 | struct acpi_gpio reset_gpio; |
| 195 | /* Delay to be inserted after device is taken out of reset. */ |
| 196 | unsigned int reset_delay_ms; |
| 197 | /* Delay to be inserted after device is put into reset. */ |
| 198 | unsigned int reset_off_delay_ms; |
| 199 | |
| 200 | /* GPIO used for report enabling */ |
| 201 | struct acpi_gpio report_gpio; |
| 202 | /* Delay to be inserted after device is taken out of reset. */ |
| 203 | unsigned int report_delay_ms; |
| 204 | /* Delay to be inserted after device is put into reset. */ |
| 205 | unsigned int report_off_delay_ms; |
| 206 | |
| 207 | /* |
| 208 | * Touch Host Controller Wake On Touch |
| 209 | * |
| 210 | * Based on this setting vGPIO for given THC will be in native mode, and additional _CRS |
| 211 | * for wake will be exposed in ACPI |
| 212 | */ |
| 213 | uint8_t wake_on_touch; |
| 214 | |
| 215 | /* |
| 216 | * Either acpi_irq wake_irq or wake_gpio is needed for wake but not both use acpi_irq |
| 217 | * for Interrupt() and wake_gpio for GpioInt(). |
| 218 | */ |
| 219 | struct acpi_irq wake_irq; |
| 220 | struct acpi_gpio wake_gpio; |
| 221 | unsigned int wake_gpe; /* mapped GPE number for wake */ |
| 222 | /* sensor-specific */ |
| 223 | const char *sensor_dev_name; |
| 224 | const char *sensor_dev_desc; |
| 225 | |
| 226 | enum intel_touch_device connected_device; |
| 227 | |
| 228 | /* |
| 229 | * Touch Host Controller HID Over SPI Limit PacketSize |
| 230 | * |
| 231 | * When set, limits SPI read & write packet size to 64B. Otherwise, THC uses Max Soc |
| 232 | * packet size for SPI Read and Write 0x0- Max Soc Packet Size, 0x11 - 64 Bytes |
| 233 | */ |
| 234 | uint32_t limit_packet_size; |
| 235 | |
| 236 | struct intel_thc_dev_info dev_hidi2c; |
| 237 | struct intel_thc_dev_info dev_hidspi; |
| 238 | |
| 239 | struct intel_thc_hidspi_info soc_hidspi; |
| 240 | struct intel_thc_hidi2c_info soc_hidi2c; |
| 241 | |
| 242 | /* Touch Host Controller Active Ltr */ |
| 243 | uint32_t active_ltr; |
| 244 | |
| 245 | /* Touch Host Controller Idle Ltr */ |
| 246 | uint32_t idle_ltr; |
| 247 | |
| 248 | /* Add `DmaProperty` in _DSD */ |
| 249 | bool add_acpi_dma_property; |
| 250 | }; |
| 251 | |
| 252 | /* These functions are weak and need to be overridden by a SoC */ |
| 253 | const struct intel_thc_hidi2c_info *soc_get_thc_hidi2c_info(void); |
| 254 | const struct intel_thc_hidspi_info *soc_get_thc_hidspi_info(void); |
| 255 | |
| 256 | #endif /* __DRIVERS_INTEL_TOUCH_CHIP_H__ */ |